Date Picker

A date picker component.

Installation

The Date Picker component is built with the Popover and the Calendar components.

npx nx g @spartan-ng/cli:ui datepicker

Usage

import { HlmDatePicker } from '@spartan-ng/helm/date-picker';
<hlm-date-picker [min]="minDate" [max]="maxDate">
	<span>Pick a date</span>
</hlm-date-picker>

Helm API

HlmDatePickerMulti

Selector: hlm-date-picker-multi

Inputs

PropTypeDefaultDescription
class ClassValue --
min T - The minimum date that can be selected.
max T - The maximum date that can be selected.
minSelection number undefined The minimum selectable dates.
maxSelection number undefined The maximum selectable dates.
disabled boolean false Determine if the date picker is disabled.
date T[] - The selected value.
autoCloseOnMaxSelection boolean this._config.autoCloseOnMaxSelection If true, the date picker will close when the max selection of dates is reached.
formatDates (date: T[]) => string this._config.formatDates Defines how the date should be displayed in the UI.
transformDates (date: T[]) => T[] this._config.transformDates Defines how the date should be transformed before saving to model/form.

Outputs

PropTypeDefaultDescription
dateChange T[] --

HlmDatePicker

Selector: hlm-date-picker

Inputs

PropTypeDefaultDescription
class ClassValue --
min T - The minimum date that can be selected.
max T - The maximum date that can be selected.
disabled boolean false Determine if the date picker is disabled.
date T - The selected value.
autoCloseOnSelect boolean this._config.autoCloseOnSelect If true, the date picker will close when a date is selected.
formatDate (date: T) => string this._config.formatDate Defines how the date should be displayed in the UI.
transformDate (date: T) => T this._config.transformDate Defines how the date should be transformed before saving to model/form.

Outputs

PropTypeDefaultDescription
dateChange T --

HlmDateRangePicker

Selector: hlm-date-range-picker

Inputs

PropTypeDefaultDescription
class ClassValue --
min T - The minimum date that can be selected.
max T - The maximum date that can be selected.
disabled boolean false Determine if the date picker is disabled.
date [T, T] - The selected value.
autoCloseOnEndSelection boolean this._config.autoCloseOnEndSelection If true, the date picker will close when the end date is selected
formatDates (dates: [T | undefined, T | undefined]) => string this._config.formatDates Defines how the date should be displayed in the UI.
transformDates (date: [T, T]) => [T, T] this._config.transformDates Defines how the date should be transformed before saving to model/form.

Outputs

PropTypeDefaultDescription
dateChange [T, T] | null --

Examples

Custom Configs

Use provideHlmDatePickerConfig to provide custom configs for the date picker component throughout the application.

  • autoCloseOnSelect: boolean; if true , the date picker will close when a date is selected.
  • formatDate: (date: T) => string; defines the default format how the date should be displayed in the UI.
  • transformDate: (date: T) => T; defines the default format how the date should be transformed before saving to model/form.

Multiple Selection

Use hlm-date-picker-multi for multiple date selection. Limit the selectable dates using minSelection and maxSelection inputs.

Range Picker

Use hlm-date-range-picker for range date selection. Set the range by using startDate and endDate inputs.

Format Date

Use formatDate input to override the global date format for the date picker component.

Form

Sync the date to a form by adding formControlName to hlm-date-picker .

Form Multiple Selection

Sync the dates to a form by adding formControlName to hlm-date-picker-multi .

Form Range Picker

Sync the dates to a form by adding formControlName to hlm-date-range-picker .

Dialog Data Table