npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@libs-ui/components-datetime-picker

v0.2.356-3

Published

> Component chọn ngày tháng với hỗ trợ single date, date range, time picker và custom ranges

Readme

@libs-ui/components-datetime-picker

Component chọn ngày tháng với hỗ trợ single date, date range, time picker và custom ranges

Giới thiệu

LibsUiComponentsDatetimePickerComponent là một standalone Angular component cho phép người dùng chọn ngày tháng với nhiều chế độ khác nhau: single date, date range, có hoặc không có time picker.

Tính năng

  • ✅ Single Date Picker
  • ✅ Date Range Picker
  • ✅ Time Picker (có thể bật/tắt)
  • ✅ Quick Ranges (hôm nay, tuần này, tháng này, ...)
  • ✅ Custom Ranges
  • ✅ Min/Max Date validation
  • ✅ Required validation
  • ✅ Localization support
  • ✅ Standalone Component
  • ✅ OnPush Change Detection
  • ✅ Two-way binding với model signals

Khi nào sử dụng

  • Khi cần chọn một ngày cụ thể
  • Khi cần chọn khoảng thời gian
  • Khi cần chọn cả ngày và giờ
  • Khi cần quick ranges để chọn nhanh
  • Khi cần validation cho date input

Cài đặt

npm install @libs-ui/components-datetime-picker

Sử dụng cơ bản

Date Range Picker

import { Component, signal } from '@angular/core';
import { LibsUiComponentsDatetimePickerComponent, IEmitDateRange } from '@libs-ui/components-datetime-picker';

@Component({
  selector: 'app-example',
  standalone: true,
  imports: [LibsUiComponentsDatetimePickerComponent],
  template: `
    <libs_ui-components-datetime-picker
      [(dateRangeSelected)]="dateRangeSelected"
      (outSelectDateRange)="onDateRangeSelected($event)" />
  `,
})
export class ExampleComponent {
  readonly dateRangeSelected = signal<IEmitDateRange | undefined>(undefined);

  onDateRangeSelected(event: IEmitDateRange) {
    console.log('Date range selected:', event);
  }
}

Single Date Picker

import { Component, signal } from '@angular/core';
import { IEmitSingleDate } from '@libs-ui/components-datetime-picker';

@Component({
  template: `
    <libs_ui-components-datetime-picker
      [isSingle]="true"
      [(singleDateSelected)]="singleDateSelected" />
  `,
})
export class ExampleComponent {
  readonly singleDateSelected = signal<IEmitSingleDate | undefined>(undefined);
}

With Time Picker

<libs_ui-components-datetime-picker
  [hasTimePicker]="true"
  [(dateRangeSelected)]="dateRangeSelected"
/>

With Validation

<libs_ui-components-datetime-picker
  [validRequired]="{ message: 'Vui lòng chọn ngày' }"
  [(dateRangeSelected)]="dateRangeSelected"
/>

API

Inputs

| Property | Type | Default | Description | | ------------------------ | -------------------- | ----------- | ------------------------------------------ | | [isSingle] | boolean | false | Chế độ chọn single date thay vì date range | | [hasTimePicker] | boolean | true | Hiển thị time picker | | [dateOptions] | LocalizationConfig | default | Cấu hình localization và custom ranges | | [allowReset] | boolean | true | Cho phép reset date đã chọn | | [disable] | boolean | false | Disable picker | | [readonly] | boolean | false | Readonly mode | | [minDate] | Dayjs \| string | undefined | Ngày tối thiểu có thể chọn | | [maxDate] | Dayjs \| string | undefined | Ngày tối đa có thể chọn | | [placeholder] | string | undefined | Placeholder text | | [validRequired] | IDateTimeValid | undefined | Validation config | | [extendRanges] | Array<IDateRange> | [] | Custom quick ranges | | [autoApply] | boolean | false | Tự động apply khi chọn date | | [(singleDateSelected)] | IEmitSingleDate | undefined | Two-way binding cho single date | | [(dateRangeSelected)] | IEmitDateRange | undefined | Two-way binding cho date range |

Outputs

| Property | Type | Description | | ----------------------- | ------------------------------------- | -------------------------- | | (outSelectSingleDate) | IEmitSingleDate | Event khi chọn single date | | (outSelectDateRange) | IEmitDateRange | Event khi chọn date range | | (outReset) | IEmitDateRange \| IEmitSingleDate | Event khi reset | | (outFunctionsControl) | IDateTimePickerFunctionControlEvent | Function control event |

Interfaces

IEmitSingleDate

export interface IEmitSingleDate {
  date?: Dayjs | string;
  displayLabel?: string;
}

IEmitDateRange

export interface IEmitDateRange {
  startDate?: Dayjs | string;
  endDate?: Dayjs | string;
  displayLabel?: string;
  quickRangeId?: string;
}

IDateTimeValid

export interface IDateTimeValid {
  message?: string;
  interpolateParams?: TYPE_OBJECT;
}

LocalizationConfig

export interface LocalizationConfig {
  monthNames: string[];
  ranges: { [key: string]: string };
  daysOfWeek: string[];
  applyLabel: string;
  cancelLabel: string;
  fromLabel: string;
  toLabel: string;
  customRangeLabel: string;
  format?: string;
  direction?: string;
  separator?: string;
  weekLabel?: string;
  clearLabel?: string;
  firstDay?: number;
  displayFormat?: string;
}

Ví dụ nâng cao

Custom Ranges

import { IDateRange } from '@libs-ui/components-datetime-picker';
import { getDayjs } from '@libs-ui/utils';

const customRanges: IDateRange[] = [
  {
    id: 'last_7_days',
    label: '7 ngày qua',
    startDate: getDayjs().subtract(7, 'days'),
    endDate: getDayjs()
  },
  {
    id: 'last_30_days',
    label: '30 ngày qua',
    startDate: getDayjs().subtract(30, 'days'),
    endDate: getDayjs()
  }
];

// Sử dụng
<libs_ui-components-datetime-picker
  [extendRanges]="customRanges"
  [(dateRangeSelected)]="dateRangeSelected"
/>

Min/Max Date

import { getDayjs } from '@libs-ui/utils';

const minDate = getDayjs().subtract(1, 'year');
const maxDate = getDayjs().add(1, 'year');

<libs_ui-components-datetime-picker
  [minDate]="minDate"
  [maxDate]="maxDate"
  [(dateRangeSelected)]="dateRangeSelected"
/>

Dependencies

  • @angular/core >= 18.0.0
  • @angular/common >= 18.0.0
  • dayjs
  • @libs-ui/components-label
  • @libs-ui/components-popover
  • @libs-ui/utils
  • @ngx-translate/core

Demo

Xem demo tại: http://localhost:4500/datetime/picker

License

MIT