@egose/shadcn-theme-ng 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/autocomplete/fesm2022/autocomplete.mjs +1 -1
- package/checkbox/fesm2022/checkbox.mjs +6 -7
- package/checkbox/types/checkbox.d.ts +1 -1
- package/combobox/fesm2022/combobox.mjs +1 -1
- package/date-picker/README.md +15 -11
- package/date-picker/fesm2022/date-picker.mjs +148 -30
- package/date-picker/types/date-picker.d.ts +102 -9
- package/form-autocomplete/README.md +178 -0
- package/form-autocomplete/fesm2022/form-autocomplete.mjs +159 -0
- package/form-autocomplete/package.json +24 -0
- package/form-autocomplete/types/form-autocomplete.d.ts +81 -0
- package/form-checkbox/README.md +29 -18
- package/form-checkbox/fesm2022/form-checkbox.mjs +59 -17
- package/form-checkbox/types/form-checkbox.d.ts +43 -4
- package/form-combobox/README.md +203 -0
- package/form-combobox/fesm2022/form-combobox.mjs +181 -0
- package/form-combobox/package.json +24 -0
- package/form-combobox/types/form-combobox.d.ts +93 -0
- package/form-date-picker/README.md +49 -22
- package/form-date-picker/fesm2022/form-date-picker.mjs +74 -19
- package/form-date-picker/types/form-date-picker.d.ts +37 -1
- package/form-date-picker-multi/README.md +192 -0
- package/form-date-picker-multi/fesm2022/form-date-picker-multi.mjs +158 -0
- package/form-date-picker-multi/package.json +24 -0
- package/form-date-picker-multi/types/form-date-picker-multi.d.ts +78 -0
- package/form-date-range-picker/README.md +254 -0
- package/form-date-range-picker/fesm2022/form-date-range-picker.mjs +159 -0
- package/form-date-range-picker/package.json +24 -0
- package/form-date-range-picker/types/form-date-range-picker.d.ts +75 -0
- package/form-field/README.md +9 -0
- package/form-field/fesm2022/form-field.mjs +80 -5
- package/form-field/types/form-field.d.ts +50 -2
- package/form-field-simple/fesm2022/form-field-simple.mjs +15 -1
- package/form-field-simple/types/form-field-simple.d.ts +9 -2
- package/form-input-otp/README.md +195 -0
- package/form-input-otp/fesm2022/form-input-otp.mjs +140 -0
- package/form-input-otp/package.json +24 -0
- package/form-input-otp/types/form-input-otp.d.ts +78 -0
- package/form-month-year-picker/README.md +189 -0
- package/form-month-year-picker/fesm2022/form-month-year-picker.mjs +154 -0
- package/form-month-year-picker/package.json +24 -0
- package/form-month-year-picker/types/form-month-year-picker.d.ts +73 -0
- package/form-native-select/README.md +206 -0
- package/form-native-select/fesm2022/form-native-select.mjs +132 -0
- package/form-native-select/package.json +24 -0
- package/form-native-select/types/form-native-select.d.ts +77 -0
- package/form-phone-input/README.md +189 -0
- package/form-phone-input/fesm2022/form-phone-input.mjs +142 -0
- package/form-phone-input/package.json +24 -0
- package/form-phone-input/types/form-phone-input.d.ts +78 -0
- package/form-radio-group/README.md +199 -0
- package/form-radio-group/fesm2022/form-radio-group.mjs +140 -0
- package/form-radio-group/package.json +24 -0
- package/form-radio-group/types/form-radio-group.d.ts +83 -0
- package/form-searchable-multiselect/README.md +28 -17
- package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs +57 -19
- package/form-searchable-multiselect/types/form-searchable-multiselect.d.ts +39 -2
- package/form-select/README.md +30 -19
- package/form-select/fesm2022/form-select.mjs +57 -19
- package/form-select/types/form-select.d.ts +39 -2
- package/form-slider/README.md +183 -0
- package/form-slider/fesm2022/form-slider.mjs +140 -0
- package/form-slider/package.json +24 -0
- package/form-slider/types/form-slider.d.ts +80 -0
- package/form-switch/README.md +174 -0
- package/form-switch/fesm2022/form-switch.mjs +129 -0
- package/form-switch/package.json +24 -0
- package/form-switch/types/form-switch.d.ts +70 -0
- package/form-text-input/README.md +37 -26
- package/form-text-input/fesm2022/form-text-input.mjs +57 -19
- package/form-text-input/types/form-text-input.d.ts +39 -2
- package/form-textarea/README.md +33 -22
- package/form-textarea/fesm2022/form-textarea.mjs +57 -19
- package/form-textarea/types/form-textarea.d.ts +39 -2
- package/form-toggle/README.md +187 -0
- package/form-toggle/fesm2022/form-toggle.mjs +193 -0
- package/form-toggle/package.json +24 -0
- package/form-toggle/types/form-toggle.d.ts +100 -0
- package/form-toggle-group/README.md +177 -0
- package/form-toggle-group/fesm2022/form-toggle-group.mjs +145 -0
- package/form-toggle-group/package.json +24 -0
- package/form-toggle-group/types/form-toggle-group.d.ts +85 -0
- package/input-group/fesm2022/input-group.mjs +19 -9
- package/input-group/types/input-group.d.ts +4 -1
- package/native-select/fesm2022/native-select.mjs +18 -6
- package/native-select/types/native-select.d.ts +7 -2
- package/package.json +57 -1
- package/phone-input/README.md +114 -0
- package/phone-input/fesm2022/phone-input.mjs +191 -0
- package/phone-input/package.json +24 -0
- package/phone-input/types/phone-input.d.ts +67 -0
- package/radio-group/types/radio-group.d.ts +1 -1
- package/switch/fesm2022/switch.mjs +7 -5
- package/switch/types/switch.d.ts +2 -1
- package/typography/types/typography.d.ts +8 -8
|
@@ -2,14 +2,16 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { inject, input, computed, Component } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/forms';
|
|
4
4
|
import { FormGroupDirective, ReactiveFormsModule, ControlContainer } from '@angular/forms';
|
|
5
|
-
import { HlmFormIdGenerator, HlmFormField, HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
5
|
+
import { injectEgFormErrorMessages, HlmFormIdGenerator, resolveEgFormError, HlmFormField, HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
6
6
|
import { HlmLabel } from '@egose/shadcn-theme-ng/label';
|
|
7
|
-
import { HlmDatePicker, HlmDatePickerInput } from '@egose/shadcn-theme-ng/date-picker';
|
|
7
|
+
import { injectHlmDatePickerConfig, HlmDatePicker, HlmDatePickerInput } from '@egose/shadcn-theme-ng/date-picker';
|
|
8
8
|
import { hlm } from '@egose/shadcn-theme-ng/utils';
|
|
9
9
|
|
|
10
10
|
class EgFormDatePicker {
|
|
11
11
|
formGroupDirective = inject(FormGroupDirective);
|
|
12
|
+
_errorMessages = injectEgFormErrorMessages();
|
|
12
13
|
generatedId = inject(HlmFormIdGenerator).generate('eg-form-date-picker');
|
|
14
|
+
_config = injectHlmDatePickerConfig();
|
|
13
15
|
// Inputs
|
|
14
16
|
label = input(undefined, /* @ts-ignore */
|
|
15
17
|
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
@@ -19,6 +21,13 @@ class EgFormDatePicker {
|
|
|
19
21
|
...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
|
|
20
22
|
error = input(undefined, /* @ts-ignore */
|
|
21
23
|
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
24
|
+
/**
|
|
25
|
+
* Auto-resolve the displayed message from the control's `ValidationErrors`
|
|
26
|
+
* when `error()` is unset. Explicit `error()` always wins. Set to `false`
|
|
27
|
+
* for manual-only messages.
|
|
28
|
+
*/
|
|
29
|
+
autoError = input(true, /* @ts-ignore */
|
|
30
|
+
...(ngDevMode ? [{ debugName: "autoError" }] : /* istanbul ignore next */ []));
|
|
22
31
|
hint = input(undefined, /* @ts-ignore */
|
|
23
32
|
...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
24
33
|
// HTML attributes
|
|
@@ -38,21 +47,63 @@ class EgFormDatePicker {
|
|
|
38
47
|
...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
|
|
39
48
|
max = input(null, /* @ts-ignore */
|
|
40
49
|
...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
|
|
41
|
-
|
|
50
|
+
// Picker behavior (defaults fall back to the injected HlmDatePickerConfig,
|
|
51
|
+
// so global `provideHlmDatePickerConfig` values keep working unless overridden)
|
|
52
|
+
autoCloseOnSelect = input(this._config.autoCloseOnSelect, /* @ts-ignore */
|
|
42
53
|
...(ngDevMode ? [{ debugName: "autoCloseOnSelect" }] : /* istanbul ignore next */ []));
|
|
54
|
+
captionLayout = input('label', /* @ts-ignore */
|
|
55
|
+
...(ngDevMode ? [{ debugName: "captionLayout" }] : /* istanbul ignore next */ []));
|
|
56
|
+
formatDate = input(this._config.formatDate, /* @ts-ignore */
|
|
57
|
+
...(ngDevMode ? [{ debugName: "formatDate" }] : /* istanbul ignore next */ []));
|
|
58
|
+
transformDate = input(this._config.transformDate, /* @ts-ignore */
|
|
59
|
+
...(ngDevMode ? [{ debugName: "transformDate" }] : /* istanbul ignore next */ []));
|
|
60
|
+
parseDate = input(this._config.parseDate, /* @ts-ignore */
|
|
61
|
+
...(ngDevMode ? [{ debugName: "parseDate" }] : /* istanbul ignore next */ []));
|
|
62
|
+
formatInputDate = input(this._config.formatInputDate, /* @ts-ignore */
|
|
63
|
+
...(ngDevMode ? [{ debugName: "formatInputDate" }] : /* istanbul ignore next */ []));
|
|
43
64
|
effectiveId = computed(() => this.controlId() || this.id() || this.generatedId, /* @ts-ignore */
|
|
44
65
|
...(ngDevMode ? [{ debugName: "effectiveId" }] : /* istanbul ignore next */ []));
|
|
45
66
|
errorId = computed(() => `${this.effectiveId()}-error`, /* @ts-ignore */
|
|
46
67
|
...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
|
|
47
68
|
hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
|
|
48
69
|
...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
|
|
49
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
72
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
73
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
74
|
+
* fresh on every change-detection pass.
|
|
75
|
+
*/
|
|
76
|
+
resolvedError() {
|
|
77
|
+
const explicit = this.error();
|
|
78
|
+
if (explicit)
|
|
79
|
+
return explicit;
|
|
80
|
+
if (!this.autoError())
|
|
81
|
+
return undefined;
|
|
82
|
+
const control = this.formGroupDirective.form.get(this.controlName());
|
|
83
|
+
return resolveEgFormError(control?.errors ?? null, this.label(), this._errorMessages);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
87
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
88
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
89
|
+
*/
|
|
90
|
+
showError() {
|
|
50
91
|
const control = this.formGroupDirective.form.get(this.controlName());
|
|
51
|
-
return this.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
92
|
+
return (!!this.resolvedError() &&
|
|
93
|
+
!!control?.invalid &&
|
|
94
|
+
(control.dirty || control.touched || this.formGroupDirective.submitted));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Bounds projected onto the picker's `Date` model. The cast keeps the
|
|
98
|
+
* template's generic inference on `Date` while passing runtime values
|
|
99
|
+
* (including `string` bounds, as before) through untouched.
|
|
100
|
+
*/
|
|
101
|
+
$min = computed(() => this.min(), /* @ts-ignore */
|
|
102
|
+
...(ngDevMode ? [{ debugName: "$min" }] : /* istanbul ignore next */ []));
|
|
103
|
+
$max = computed(() => this.max(), /* @ts-ignore */
|
|
104
|
+
...(ngDevMode ? [{ debugName: "$max" }] : /* istanbul ignore next */ []));
|
|
105
|
+
describedBy() {
|
|
106
|
+
return this.showError() ? this.errorId() : this.hint() ? this.hintId() : null;
|
|
56
107
|
}
|
|
57
108
|
// Styling
|
|
58
109
|
userClass = input('', { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: 'class' });
|
|
@@ -60,23 +111,27 @@ class EgFormDatePicker {
|
|
|
60
111
|
...(ngDevMode ? [{ debugName: "labelClass" }] : /* istanbul ignore next */ []));
|
|
61
112
|
pickerClass = input('', /* @ts-ignore */
|
|
62
113
|
...(ngDevMode ? [{ debugName: "pickerClass" }] : /* istanbul ignore next */ []));
|
|
114
|
+
inputClass = input('', /* @ts-ignore */
|
|
115
|
+
...(ngDevMode ? [{ debugName: "inputClass" }] : /* istanbul ignore next */ []));
|
|
63
116
|
errorClass = input('', /* @ts-ignore */
|
|
64
117
|
...(ngDevMode ? [{ debugName: "errorClass" }] : /* istanbul ignore next */ []));
|
|
65
118
|
hintClass = input('', /* @ts-ignore */
|
|
66
119
|
...(ngDevMode ? [{ debugName: "hintClass" }] : /* istanbul ignore next */ []));
|
|
67
|
-
// Computed classes
|
|
68
|
-
$userClass = computed(() => hlm("
|
|
120
|
+
// Computed classes (library base < global config < per-instance)
|
|
121
|
+
$userClass = computed(() => hlm("w-full", this.userClass()), /* @ts-ignore */
|
|
69
122
|
...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
|
|
70
|
-
$labelClass = computed(() => hlm("mb-1", this.labelClass()), /* @ts-ignore */
|
|
123
|
+
$labelClass = computed(() => hlm("mb-1", this._config.labelClass, this.labelClass()), /* @ts-ignore */
|
|
71
124
|
...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
|
|
72
|
-
$pickerClass = computed(() => hlm("mb-1", this.pickerClass()), /* @ts-ignore */
|
|
125
|
+
$pickerClass = computed(() => hlm("mb-1", this._config.pickerClass, this.pickerClass()), /* @ts-ignore */
|
|
73
126
|
...(ngDevMode ? [{ debugName: "$pickerClass" }] : /* istanbul ignore next */ []));
|
|
74
|
-
$
|
|
127
|
+
$inputClass = computed(() => hlm(this._config.inputClass, this.inputClass()), /* @ts-ignore */
|
|
128
|
+
...(ngDevMode ? [{ debugName: "$inputClass" }] : /* istanbul ignore next */ []));
|
|
129
|
+
$errorClass = computed(() => hlm("mt-0", this._config.errorClass, this.errorClass()), /* @ts-ignore */
|
|
75
130
|
...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
|
|
76
|
-
$hintClass = computed(() => hlm("mt-0", this.hintClass()), /* @ts-ignore */
|
|
131
|
+
$hintClass = computed(() => hlm("mt-0", this._config.hintClass, this.hintClass()), /* @ts-ignore */
|
|
77
132
|
...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
|
|
78
133
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormDatePicker, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
79
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormDatePicker, isStandalone: true, selector: "eg-form-date-picker", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", isSignal: true, isRequired: false, transformFunction: null }, controlName: { classPropertyName: "controlName", publicName: "controlName", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, autoCloseOnSelect: { classPropertyName: "autoCloseOnSelect", publicName: "autoCloseOnSelect", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, labelClass: { classPropertyName: "labelClass", publicName: "labelClass", isSignal: true, isRequired: false, transformFunction: null }, pickerClass: { classPropertyName: "pickerClass", publicName: "pickerClass", isSignal: true, isRequired: false, transformFunction: null }, errorClass: { classPropertyName: "errorClass", publicName: "errorClass", isSignal: true, isRequired: false, transformFunction: null }, hintClass: { classPropertyName: "hintClass", publicName: "hintClass", isSignal: true, isRequired: false, transformFunction: null } }, host: {
|
|
134
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormDatePicker, isStandalone: true, selector: "eg-form-date-picker", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", isSignal: true, isRequired: false, transformFunction: null }, controlName: { classPropertyName: "controlName", publicName: "controlName", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, autoError: { classPropertyName: "autoError", publicName: "autoError", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, autoCloseOnSelect: { classPropertyName: "autoCloseOnSelect", publicName: "autoCloseOnSelect", isSignal: true, isRequired: false, transformFunction: null }, captionLayout: { classPropertyName: "captionLayout", publicName: "captionLayout", isSignal: true, isRequired: false, transformFunction: null }, formatDate: { classPropertyName: "formatDate", publicName: "formatDate", isSignal: true, isRequired: false, transformFunction: null }, transformDate: { classPropertyName: "transformDate", publicName: "transformDate", isSignal: true, isRequired: false, transformFunction: null }, parseDate: { classPropertyName: "parseDate", publicName: "parseDate", isSignal: true, isRequired: false, transformFunction: null }, formatInputDate: { classPropertyName: "formatInputDate", publicName: "formatInputDate", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, labelClass: { classPropertyName: "labelClass", publicName: "labelClass", isSignal: true, isRequired: false, transformFunction: null }, pickerClass: { classPropertyName: "pickerClass", publicName: "pickerClass", isSignal: true, isRequired: false, transformFunction: null }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", isSignal: true, isRequired: false, transformFunction: null }, errorClass: { classPropertyName: "errorClass", publicName: "errorClass", isSignal: true, isRequired: false, transformFunction: null }, hintClass: { classPropertyName: "hintClass", publicName: "hintClass", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "$userClass()" } }, providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }], ngImport: i0, template: "\n @let lbl = label();\n @let cnm = controlName();\n @let hnt = hint();\n @let rqrd = required();\n\n <hlm-form-field>\n @if (lbl) {\n <label hlmLabel [for]=\"effectiveId()\" [class]=\"$labelClass()\"\n >{{ lbl }}\n @if (rqrd) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n <hlm-date-picker\n [min]=\"$min()\"\n [max]=\"$max()\"\n [wrapperDisabled]=\"disabled()\"\n [autoCloseOnSelect]=\"autoCloseOnSelect()\"\n [captionLayout]=\"captionLayout()\"\n [formatDate]=\"formatDate()\"\n [transformDate]=\"transformDate()\"\n [formControlName]=\"cnm\"\n [class]=\"$pickerClass()\"\n >\n <hlm-date-picker-input\n [inputId]=\"effectiveId()\"\n [name]=\"cnm || name()\"\n [readonly]=\"readonly()\"\n [ariaLabel]=\"lbl\"\n [ariaDescribedby]=\"describedBy()\"\n [placeholder]=\"placeholder()\"\n [parseDate]=\"parseDate()\"\n [formatInputDate]=\"formatInputDate()\"\n [inputClass]=\"$inputClass()\"\n />\n </hlm-date-picker>\n\n @if (showError()) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{ resolvedError() }}\n </hlm-error>\n }\n\n @if (hnt) {\n <hlm-hint [id]=\"hintId()\" [class]=\"$hintClass()\">\n {{ hnt }}\n </hlm-hint>\n }\n </hlm-form-field>\n ", isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: HlmFormField, selector: "hlm-form-field", inputs: ["class"] }, { kind: "directive", type: HlmError, selector: "hlm-error", inputs: ["class"] }, { kind: "directive", type: HlmHint, selector: "hlm-hint", inputs: ["class"] }, { kind: "directive", type: HlmLabel, selector: "[hlmLabel]", inputs: ["class"] }, { kind: "component", type: HlmDatePicker, selector: "hlm-date-picker", inputs: ["captionLayout", "min", "max", "disabled", "wrapperDisabled", "date", "defaultFocusedDate", "autoCloseOnSelect", "formatDate", "transformDate"], outputs: ["dateChange"] }, { kind: "component", type: HlmDatePickerInput, selector: "hlm-date-picker-input", inputs: ["ariaLabel", "ariaDescribedby", "name", "readonly", "class", "inputClass", "parseDate", "formatInputDate"] }] });
|
|
80
135
|
}
|
|
81
136
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormDatePicker, decorators: [{
|
|
82
137
|
type: Component,
|
|
@@ -84,13 +139,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
84
139
|
selector: 'eg-form-date-picker',
|
|
85
140
|
standalone: true,
|
|
86
141
|
host: {
|
|
87
|
-
class:
|
|
142
|
+
'[class]': '$userClass()',
|
|
88
143
|
},
|
|
89
144
|
imports: [ReactiveFormsModule, HlmFormField, HlmError, HlmHint, HlmLabel, HlmDatePicker, HlmDatePickerInput],
|
|
90
145
|
providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
|
|
91
|
-
template: "\n @let lbl = label();\n @let cnm = controlName();\n @let
|
|
146
|
+
template: "\n @let lbl = label();\n @let cnm = controlName();\n @let hnt = hint();\n @let rqrd = required();\n\n <hlm-form-field>\n @if (lbl) {\n <label hlmLabel [for]=\"effectiveId()\" [class]=\"$labelClass()\"\n >{{ lbl }}\n @if (rqrd) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n <hlm-date-picker\n [min]=\"$min()\"\n [max]=\"$max()\"\n [wrapperDisabled]=\"disabled()\"\n [autoCloseOnSelect]=\"autoCloseOnSelect()\"\n [captionLayout]=\"captionLayout()\"\n [formatDate]=\"formatDate()\"\n [transformDate]=\"transformDate()\"\n [formControlName]=\"cnm\"\n [class]=\"$pickerClass()\"\n >\n <hlm-date-picker-input\n [inputId]=\"effectiveId()\"\n [name]=\"cnm || name()\"\n [readonly]=\"readonly()\"\n [ariaLabel]=\"lbl\"\n [ariaDescribedby]=\"describedBy()\"\n [placeholder]=\"placeholder()\"\n [parseDate]=\"parseDate()\"\n [formatInputDate]=\"formatInputDate()\"\n [inputClass]=\"$inputClass()\"\n />\n </hlm-date-picker>\n\n @if (showError()) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{ resolvedError() }}\n </hlm-error>\n }\n\n @if (hnt) {\n <hlm-hint [id]=\"hintId()\" [class]=\"$hintClass()\">\n {{ hnt }}\n </hlm-hint>\n }\n </hlm-form-field>\n ",
|
|
92
147
|
}]
|
|
93
|
-
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], controlId: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlId", required: false }] }], controlName: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlName", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], autoCloseOnSelect: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoCloseOnSelect", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], pickerClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "pickerClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
|
|
148
|
+
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], controlId: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlId", required: false }] }], controlName: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlName", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], autoError: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoError", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], autoCloseOnSelect: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoCloseOnSelect", required: false }] }], captionLayout: [{ type: i0.Input, args: [{ isSignal: true, alias: "captionLayout", required: false }] }], formatDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "formatDate", required: false }] }], transformDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "transformDate", required: false }] }], parseDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "parseDate", required: false }] }], formatInputDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "formatInputDate", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], pickerClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "pickerClass", required: false }] }], inputClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
|
|
94
149
|
|
|
95
150
|
/*
|
|
96
151
|
* Public API Surface of form-date-picker
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
2
|
import { ClassValue } from 'clsx';
|
|
3
3
|
|
|
4
|
+
type DatePickerCaptionLayout = 'dropdown' | 'label' | 'dropdown-months' | 'dropdown-years';
|
|
4
5
|
declare class EgFormDatePicker {
|
|
5
6
|
private readonly formGroupDirective;
|
|
7
|
+
private readonly _errorMessages;
|
|
6
8
|
private readonly generatedId;
|
|
9
|
+
private readonly _config;
|
|
7
10
|
label: _angular_core.InputSignal<string | undefined>;
|
|
8
11
|
controlId: _angular_core.InputSignal<string | undefined>;
|
|
9
12
|
controlName: _angular_core.InputSignal<string>;
|
|
10
13
|
error: _angular_core.InputSignal<string | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Auto-resolve the displayed message from the control's `ValidationErrors`
|
|
16
|
+
* when `error()` is unset. Explicit `error()` always wins. Set to `false`
|
|
17
|
+
* for manual-only messages.
|
|
18
|
+
*/
|
|
19
|
+
autoError: _angular_core.InputSignal<boolean>;
|
|
11
20
|
hint: _angular_core.InputSignal<string | undefined>;
|
|
12
21
|
id: _angular_core.InputSignal<string | undefined>;
|
|
13
22
|
name: _angular_core.InputSignal<string | undefined>;
|
|
@@ -18,22 +27,49 @@ declare class EgFormDatePicker {
|
|
|
18
27
|
min: _angular_core.InputSignal<string | Date | null>;
|
|
19
28
|
max: _angular_core.InputSignal<string | Date | null>;
|
|
20
29
|
autoCloseOnSelect: _angular_core.InputSignal<boolean>;
|
|
30
|
+
captionLayout: _angular_core.InputSignal<DatePickerCaptionLayout>;
|
|
31
|
+
formatDate: _angular_core.InputSignal<(date: Date) => string>;
|
|
32
|
+
transformDate: _angular_core.InputSignal<(date: Date) => Date>;
|
|
33
|
+
parseDate: _angular_core.InputSignal<(value: string) => Date | null>;
|
|
34
|
+
formatInputDate: _angular_core.InputSignal<(date: Date) => string>;
|
|
21
35
|
readonly effectiveId: _angular_core.Signal<string>;
|
|
22
36
|
readonly errorId: _angular_core.Signal<string>;
|
|
23
37
|
readonly hintId: _angular_core.Signal<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
40
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
41
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
42
|
+
* fresh on every change-detection pass.
|
|
43
|
+
*/
|
|
44
|
+
protected resolvedError(): string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
47
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
48
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
49
|
+
*/
|
|
50
|
+
protected showError(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Bounds projected onto the picker's `Date` model. The cast keeps the
|
|
53
|
+
* template's generic inference on `Date` while passing runtime values
|
|
54
|
+
* (including `string` bounds, as before) through untouched.
|
|
55
|
+
*/
|
|
56
|
+
protected readonly $min: _angular_core.Signal<Date | undefined>;
|
|
57
|
+
protected readonly $max: _angular_core.Signal<Date | undefined>;
|
|
24
58
|
describedBy(): string | null;
|
|
25
59
|
userClass: _angular_core.InputSignal<ClassValue>;
|
|
26
60
|
labelClass: _angular_core.InputSignal<string>;
|
|
27
61
|
pickerClass: _angular_core.InputSignal<string>;
|
|
62
|
+
inputClass: _angular_core.InputSignal<string>;
|
|
28
63
|
errorClass: _angular_core.InputSignal<string>;
|
|
29
64
|
hintClass: _angular_core.InputSignal<string>;
|
|
30
65
|
$userClass: _angular_core.Signal<string>;
|
|
31
66
|
$labelClass: _angular_core.Signal<string>;
|
|
32
67
|
$pickerClass: _angular_core.Signal<string>;
|
|
68
|
+
$inputClass: _angular_core.Signal<string>;
|
|
33
69
|
$errorClass: _angular_core.Signal<string>;
|
|
34
70
|
$hintClass: _angular_core.Signal<string>;
|
|
35
71
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormDatePicker, never>;
|
|
36
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormDatePicker, "eg-form-date-picker", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "controlId": { "alias": "controlId"; "required": false; "isSignal": true; }; "controlName": { "alias": "controlName"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; "hint": { "alias": "hint"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "autoCloseOnSelect": { "alias": "autoCloseOnSelect"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "pickerClass": { "alias": "pickerClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
72
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormDatePicker, "eg-form-date-picker", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "controlId": { "alias": "controlId"; "required": false; "isSignal": true; }; "controlName": { "alias": "controlName"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; "autoError": { "alias": "autoError"; "required": false; "isSignal": true; }; "hint": { "alias": "hint"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "autoCloseOnSelect": { "alias": "autoCloseOnSelect"; "required": false; "isSignal": true; }; "captionLayout": { "alias": "captionLayout"; "required": false; "isSignal": true; }; "formatDate": { "alias": "formatDate"; "required": false; "isSignal": true; }; "transformDate": { "alias": "transformDate"; "required": false; "isSignal": true; }; "parseDate": { "alias": "parseDate"; "required": false; "isSignal": true; }; "formatInputDate": { "alias": "formatInputDate"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "pickerClass": { "alias": "pickerClass"; "required": false; "isSignal": true; }; "inputClass": { "alias": "inputClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
37
73
|
}
|
|
38
74
|
|
|
39
75
|
export { EgFormDatePicker };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Form Date Picker Multi (`@egose/shadcn-theme-ng/form-date-picker-multi`)
|
|
2
|
+
|
|
3
|
+
A ready-made reactive-form multi-date field: label + `hlm-date-picker-multi` + validation error/hint display in one tag. The model is a `Date[] | null`.
|
|
4
|
+
|
|
5
|
+
The Angular implementation is a standalone wrapper (not a brain primitive): it renders
|
|
6
|
+
`HlmFormField` / `HlmError` / `HlmHint` from `@egose/shadcn-theme-ng/form-field`, `HlmLabel`, and
|
|
7
|
+
`HlmDatePickerMulti` + `HlmDateMultiInput` from `@egose/shadcn-theme-ng/date-picker`. The inner
|
|
8
|
+
picker is bound with `[formControlName]="controlName()"`, so the parent `FormGroup` owns the value.
|
|
9
|
+
It must live inside a `FormGroupDirective` (`[formGroup]` parent); ids come from `HlmFormIdGenerator`
|
|
10
|
+
unless overridden.
|
|
11
|
+
|
|
12
|
+
> **Ships as:** `@egose/shadcn-theme-ng/form-date-picker-multi` and `@egose/shadcn-theme-ng-tw/form-date-picker-multi`
|
|
13
|
+
> (the `tw:`-prefixed Tailwind variant). Both expose the identical TypeScript surface; only the
|
|
14
|
+
> emitted Tailwind class strings differ. See the [package README](../../README.md) for install
|
|
15
|
+
> steps, peer dependencies, and Tailwind setup. Do not publish this project directory independently.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Plain Tailwind (no prefix)
|
|
21
|
+
npm install @egose/shadcn-theme-ng
|
|
22
|
+
|
|
23
|
+
# tw:-prefixed Tailwind variant
|
|
24
|
+
npm install @egose/shadcn-theme-ng-tw
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Peer dependencies (Angular, `@spartan-ng/brain`, `@ng-icons/*`, `rxjs`, …) are documented in the
|
|
28
|
+
[package README](../../README.md#peer-dependencies). This subpath additionally relies at runtime on
|
|
29
|
+
`@egose/shadcn-theme-ng/date-picker`, `@egose/shadcn-theme-ng/form-field`, and
|
|
30
|
+
`@egose/shadcn-theme-ng/label`.
|
|
31
|
+
|
|
32
|
+
## Imports
|
|
33
|
+
|
|
34
|
+
Exported from the subpath root (`projects/form-date-picker-multi/src/public-api.ts`):
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { EgFormDatePickerMulti } from '@egose/shadcn-theme-ng/form-date-picker-multi';
|
|
38
|
+
// tw variant: replace with '@egose/shadcn-theme-ng-tw/form-date-picker-multi'
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`ControlValueAccessor` behavior: `eg-form-date-picker-multi` itself is not a `ControlValueAccessor`;
|
|
42
|
+
the inner `hlm-date-picker-multi` is (bound via `formControlName`), so `formControlName`/`formGroup`
|
|
43
|
+
handling, `Validators`, and `disabled` state from the control all flow through the parent form.
|
|
44
|
+
|
|
45
|
+
## Anatomy / Structure
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<form [formGroup]="form">
|
|
49
|
+
<eg-form-date-picker-multi
|
|
50
|
+
controlName="holidays"
|
|
51
|
+
label="Holidays"
|
|
52
|
+
placeholder="Pick dates"
|
|
53
|
+
[required]="true"
|
|
54
|
+
error="Pick at least one day."
|
|
55
|
+
/>
|
|
56
|
+
</form>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Selector (from source): `eg-form-date-picker-multi` (standalone component, host `tw:w-full`).
|
|
60
|
+
|
|
61
|
+
## API reference
|
|
62
|
+
|
|
63
|
+
### `EgFormDatePickerMulti` — `eg-form-date-picker-multi`
|
|
64
|
+
|
|
65
|
+
| Input | Type | Default | Description |
|
|
66
|
+
| ------------------------------- | ----------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
67
|
+
| `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.** |
|
|
68
|
+
| `label` | `string \| undefined` | — | Label text (hidden when omitted). |
|
|
69
|
+
| `error` | `string \| undefined` | — | Error text shown when invalid. |
|
|
70
|
+
| `autoError` | `boolean` | `true` | Auto-resolve the message from the control's `ValidationErrors` when `error` is unset. Explicit `error` always wins; `error=""` counts as unset. Global wording via `provideEgFormErrorMessages`. |
|
|
71
|
+
| `hint` | `string \| undefined` | — | Hint text shown otherwise. |
|
|
72
|
+
| `controlId` | `string \| undefined` | — | Explicit id (first priority for `effectiveId`). |
|
|
73
|
+
| `id` | `string \| undefined` | — | Fallback id (second priority). |
|
|
74
|
+
| `name` | `string \| undefined` | — | Native `name` forwarded to the inner input (`controlName` wins). |
|
|
75
|
+
| `placeholder` | `string` | `'Pick dates'` | Input placeholder. |
|
|
76
|
+
| `readonly` | `boolean` | `false` | Native `readonly` forwarded to the inner input. |
|
|
77
|
+
| `disabled` | `boolean` | `false` | Locks interaction (form control stays enabled). |
|
|
78
|
+
| `required` | `boolean` | `false` | Shows a red `*` next to the label. |
|
|
79
|
+
| `min` / `max` | `Date \| string \| null` | `null` | Date bounds forwarded to the picker. |
|
|
80
|
+
| `minSelection` / `maxSelection` | `number \| undefined` | — | Selection-count bounds forwarded to the picker. |
|
|
81
|
+
| `autoCloseOnMaxSelection` | `boolean` | config default | Forwarded to the picker (falls back to `provideHlmDatePickerMultiConfig`, default `false`). |
|
|
82
|
+
| `captionLayout` | union | `'label'` | Forwarded to the picker (`'dropdown' \| 'label' \| 'dropdown-months' \| 'dropdown-years'`). |
|
|
83
|
+
| `formatDates` | `(dates: Date[]) => string` | config default | Display format (falls back to `provideHlmDatePickerMultiConfig`). |
|
|
84
|
+
| `transformDates` | `(dates: Date[]) => Date[]` | config default | Model transform (falls back to `provideHlmDatePickerMultiConfig`). |
|
|
85
|
+
| `parseDate` | `(value: string) => Date[] \| null` | config default | Input parsing, forwarded to the input (falls back to `provideHlmDatePickerMultiConfig`). |
|
|
86
|
+
| `formatInputDates` | `(dates: Date[]) => string` | config default | Edit format while focused (falls back to `provideHlmDatePickerMultiConfig`). |
|
|
87
|
+
| `class` | `ClassValue` | `''` | Extra host classes (base `tw:w-full`). |
|
|
88
|
+
| `labelClass` | `string` | `''` | Extra label classes (base `tw:mb-1`). |
|
|
89
|
+
| `pickerClass` | `string` | `''` | Extra picker-container classes (base `tw:mb-1`). |
|
|
90
|
+
| `inputClass` | `string` | `''` | Extra inner-input classes (e.g. `tw:text-lg`). |
|
|
91
|
+
| `errorClass` | `string` | `''` | Extra error classes (base `tw:mt-0`). |
|
|
92
|
+
| `hintClass` | `string` | `''` | Extra hint classes (base `tw:mt-0`). |
|
|
93
|
+
|
|
94
|
+
| Member | Description |
|
|
95
|
+
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
96
|
+
| `effectiveId` | `controlId() \|\| id() \|\| generated` — wired to input `inputId` and label `for`. |
|
|
97
|
+
| `errorId` / `hintId` | `effectiveId + '-error' / '-hint'`. |
|
|
98
|
+
| `describedBy()` | `errorId` when `error()` is set and control is invalid + dirty/touched, else `hintId` when `hint()` is set, else `null` — wired to input `ariaDescribedby`. |
|
|
99
|
+
|
|
100
|
+
Requires a `[formGroup]` ancestor (injects `FormGroupDirective`, provides `ControlContainer → FormGroupDirective`).
|
|
101
|
+
|
|
102
|
+
## Examples
|
|
103
|
+
|
|
104
|
+
### 1. Basic multi-date field
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import { Component, inject } from '@angular/core';
|
|
108
|
+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
109
|
+
import { EgFormDatePickerMulti } from '@egose/shadcn-theme-ng/form-date-picker-multi';
|
|
110
|
+
|
|
111
|
+
@Component({
|
|
112
|
+
selector: 'app-holidays',
|
|
113
|
+
standalone: true,
|
|
114
|
+
imports: [ReactiveFormsModule, EgFormDatePickerMulti],
|
|
115
|
+
template: `
|
|
116
|
+
<form [formGroup]="form" (ngSubmit)="submit()">
|
|
117
|
+
<eg-form-date-picker-multi
|
|
118
|
+
controlName="holidays"
|
|
119
|
+
label="Holidays"
|
|
120
|
+
[required]="true"
|
|
121
|
+
error="Pick at least one day."
|
|
122
|
+
/>
|
|
123
|
+
<button type="submit" [disabled]="form.invalid">Continue</button>
|
|
124
|
+
</form>
|
|
125
|
+
`,
|
|
126
|
+
})
|
|
127
|
+
export class HolidaysComponent {
|
|
128
|
+
private readonly fb = inject(FormBuilder);
|
|
129
|
+
readonly form = this.fb.group({ holidays: [null as Date[] | null, Validators.required] });
|
|
130
|
+
submit() {
|
|
131
|
+
console.log(this.form.value.holidays);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 2. Capped selection with hint
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import { Component, inject } from '@angular/core';
|
|
140
|
+
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
|
141
|
+
import { EgFormDatePickerMulti } from '@egose/shadcn-theme-ng/form-date-picker-multi';
|
|
142
|
+
|
|
143
|
+
@Component({
|
|
144
|
+
selector: 'app-blackout',
|
|
145
|
+
standalone: true,
|
|
146
|
+
imports: [ReactiveFormsModule, EgFormDatePickerMulti],
|
|
147
|
+
template: `
|
|
148
|
+
<form [formGroup]="form">
|
|
149
|
+
<eg-form-date-picker-multi
|
|
150
|
+
controlName="blackout"
|
|
151
|
+
label="Blackout dates"
|
|
152
|
+
[maxSelection]="5"
|
|
153
|
+
[autoCloseOnMaxSelection]="true"
|
|
154
|
+
hint="Up to five days, comma-separated."
|
|
155
|
+
/>
|
|
156
|
+
</form>
|
|
157
|
+
`,
|
|
158
|
+
})
|
|
159
|
+
export class BlackoutComponent {
|
|
160
|
+
private readonly fb = inject(FormBuilder);
|
|
161
|
+
readonly form = this.fb.group({ blackout: [null as Date[] | null] });
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Accessibility notes
|
|
166
|
+
|
|
167
|
+
- Label `for` ↔ input `inputId` wiring is automatic via `effectiveId`; the input also receives `ariaLabel` and `ariaDescribedby` — always pass a `label`.
|
|
168
|
+
- Closing the picker popover marks the control touched, so errors appear after interaction even without typing.
|
|
169
|
+
- The required `*` is visual; pair with `Validators.required` so assistive tech and validation agree.
|
|
170
|
+
|
|
171
|
+
## Theming / CSS variables
|
|
172
|
+
|
|
173
|
+
No component-specific CSS variables. Style per-instance via `class` / `labelClass` / `pickerClass` / `inputClass` / `errorClass` / `hintClass` (precedence: library base < global config < per-instance).
|
|
174
|
+
|
|
175
|
+
Global defaults via the multi picker config:
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
import { provideHlmDatePickerMultiConfig } from '@egose/shadcn-theme-ng/date-picker';
|
|
179
|
+
|
|
180
|
+
await bootstrapApplication(App, {
|
|
181
|
+
providers: [provideHlmDatePickerMultiConfig({ inputClass: 'tw:text-sm', labelClass: 'tw:font-medium' })],
|
|
182
|
+
});
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
The host keeps `tw:w-full`; constrain width with `class` or a wrapping container.
|
|
186
|
+
|
|
187
|
+
## Related subpaths
|
|
188
|
+
|
|
189
|
+
- `@egose/shadcn-theme-ng/date-picker` — raw `hlm-date-picker-multi` + input/trigger/config tokens for custom layouts.
|
|
190
|
+
- `@egose/shadcn-theme-ng/form-date-picker` — the single-date counterpart (`eg-form-date-picker`).
|
|
191
|
+
- `@egose/shadcn-theme-ng/form-date-range-picker` — the range counterpart (`eg-form-date-range-picker`).
|
|
192
|
+
- `@egose/shadcn-theme-ng/form-field` — `hlm-form-field` / `hlm-error` / `hlm-hint` used internally.
|