@egose/shadcn-theme-ng-tw 0.2.0 → 0.3.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/alert/fesm2022/alert.mjs +1 -1
- package/autocomplete/fesm2022/autocomplete.mjs +1 -1
- package/button/fesm2022/button.mjs +3 -3
- 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 +177 -0
- package/form-autocomplete/fesm2022/form-autocomplete.mjs +211 -0
- package/form-autocomplete/package.json +24 -0
- package/form-autocomplete/types/form-autocomplete.d.ts +61 -0
- package/form-checkbox/README.md +13 -3
- package/form-checkbox/fesm2022/form-checkbox.mjs +22 -9
- package/form-checkbox/types/form-checkbox.d.ts +23 -4
- package/form-combobox/README.md +202 -0
- package/form-combobox/fesm2022/form-combobox.mjs +273 -0
- package/form-combobox/package.json +24 -0
- package/form-combobox/types/form-combobox.d.ts +73 -0
- package/form-date-picker/README.md +48 -22
- package/form-date-picker/fesm2022/form-date-picker.mjs +60 -16
- package/form-date-picker/types/form-date-picker.d.ts +17 -1
- package/form-date-picker-multi/README.md +191 -0
- package/form-date-picker-multi/fesm2022/form-date-picker-multi.mjs +239 -0
- package/form-date-picker-multi/package.json +24 -0
- package/form-date-picker-multi/types/form-date-picker-multi.d.ts +58 -0
- package/form-date-range-picker/README.md +253 -0
- package/form-date-range-picker/fesm2022/form-date-range-picker.mjs +236 -0
- package/form-date-range-picker/package.json +24 -0
- package/form-date-range-picker/types/form-date-range-picker.d.ts +55 -0
- package/form-input-otp/README.md +194 -0
- package/form-input-otp/fesm2022/form-input-otp.mjs +194 -0
- package/form-input-otp/package.json +24 -0
- package/form-input-otp/types/form-input-otp.d.ts +58 -0
- package/form-month-year-picker/README.md +188 -0
- package/form-month-year-picker/fesm2022/form-month-year-picker.mjs +229 -0
- package/form-month-year-picker/package.json +24 -0
- package/form-month-year-picker/types/form-month-year-picker.d.ts +53 -0
- package/form-native-select/README.md +205 -0
- package/form-native-select/fesm2022/form-native-select.mjs +187 -0
- package/form-native-select/package.json +24 -0
- package/form-native-select/types/form-native-select.d.ts +57 -0
- package/form-phone-input/README.md +188 -0
- package/form-phone-input/fesm2022/form-phone-input.mjs +203 -0
- package/form-phone-input/package.json +24 -0
- package/form-phone-input/types/form-phone-input.d.ts +58 -0
- package/form-radio-group/README.md +198 -0
- package/form-radio-group/fesm2022/form-radio-group.mjs +211 -0
- package/form-radio-group/package.json +24 -0
- package/form-radio-group/types/form-radio-group.d.ts +63 -0
- package/form-searchable-multiselect/README.md +11 -1
- package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs +19 -10
- package/form-searchable-multiselect/types/form-searchable-multiselect.d.ts +18 -1
- package/form-select/README.md +10 -0
- package/form-select/fesm2022/form-select.mjs +24 -15
- package/form-select/types/form-select.d.ts +18 -1
- package/form-slider/README.md +182 -0
- package/form-slider/fesm2022/form-slider.mjs +186 -0
- package/form-slider/package.json +24 -0
- package/form-slider/types/form-slider.d.ts +60 -0
- package/form-switch/README.md +173 -0
- package/form-switch/fesm2022/form-switch.mjs +178 -0
- package/form-switch/package.json +24 -0
- package/form-switch/types/form-switch.d.ts +50 -0
- package/form-text-input/README.md +10 -0
- package/form-text-input/fesm2022/form-text-input.mjs +19 -10
- package/form-text-input/types/form-text-input.d.ts +18 -1
- package/form-textarea/README.md +11 -1
- package/form-textarea/fesm2022/form-textarea.mjs +19 -10
- package/form-textarea/types/form-textarea.d.ts +18 -1
- package/form-toggle/README.md +186 -0
- package/form-toggle/fesm2022/form-toggle.mjs +241 -0
- package/form-toggle/package.json +24 -0
- package/form-toggle/types/form-toggle.d.ts +82 -0
- package/form-toggle-group/README.md +176 -0
- package/form-toggle-group/fesm2022/form-toggle-group.mjs +216 -0
- package/form-toggle-group/package.json +24 -0
- package/form-toggle-group/types/form-toggle-group.d.ts +65 -0
- package/input-group/fesm2022/input-group.mjs +20 -10
- 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/sheet/fesm2022/sheet.mjs +1 -1
- package/switch/fesm2022/switch.mjs +7 -5
- package/switch/types/switch.d.ts +2 -1
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, input, numberAttribute, computed, Component } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/forms';
|
|
4
|
+
import { FormGroupDirective, ReactiveFormsModule, ControlContainer } from '@angular/forms';
|
|
5
|
+
import { HlmFormIdGenerator, HlmFormField, HlmError, HlmHint } from '@egose/shadcn-theme-ng-tw/form-field';
|
|
6
|
+
import { HlmLabel } from '@egose/shadcn-theme-ng-tw/label';
|
|
7
|
+
import { injectHlmDatePickerMultiConfig, HlmDatePickerMulti, HlmDateMultiInput } from '@egose/shadcn-theme-ng-tw/date-picker';
|
|
8
|
+
import { hlm } from '@egose/shadcn-theme-ng-tw/utils';
|
|
9
|
+
|
|
10
|
+
class EgFormDatePickerMulti {
|
|
11
|
+
formGroupDirective = inject(FormGroupDirective);
|
|
12
|
+
generatedId = inject(HlmFormIdGenerator).generate('eg-form-date-picker-multi');
|
|
13
|
+
_config = injectHlmDatePickerMultiConfig();
|
|
14
|
+
label = input(undefined, /* @ts-ignore */
|
|
15
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
16
|
+
controlId = input(undefined, /* @ts-ignore */
|
|
17
|
+
...(ngDevMode ? [{ debugName: "controlId" }] : /* istanbul ignore next */ []));
|
|
18
|
+
controlName = input('', /* @ts-ignore */
|
|
19
|
+
...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
|
|
20
|
+
error = input(undefined, /* @ts-ignore */
|
|
21
|
+
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
22
|
+
hint = input(undefined, /* @ts-ignore */
|
|
23
|
+
...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
24
|
+
id = input(undefined, /* @ts-ignore */
|
|
25
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
26
|
+
name = input(undefined, /* @ts-ignore */
|
|
27
|
+
...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
|
|
28
|
+
placeholder = input('Pick dates', /* @ts-ignore */
|
|
29
|
+
...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
30
|
+
readonly = input(false, /* @ts-ignore */
|
|
31
|
+
...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
|
|
32
|
+
disabled = input(false, /* @ts-ignore */
|
|
33
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
34
|
+
required = input(false, /* @ts-ignore */
|
|
35
|
+
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
36
|
+
min = input(null, /* @ts-ignore */
|
|
37
|
+
...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
|
|
38
|
+
max = input(null, /* @ts-ignore */
|
|
39
|
+
...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
|
|
40
|
+
minSelection = input(undefined, { ...(ngDevMode ? { debugName: "minSelection" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
41
|
+
maxSelection = input(undefined, { ...(ngDevMode ? { debugName: "maxSelection" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
42
|
+
// Picker behavior (defaults fall back to the injected HlmDatePickerMultiConfig)
|
|
43
|
+
autoCloseOnMaxSelection = input(this._config.autoCloseOnMaxSelection, /* @ts-ignore */
|
|
44
|
+
...(ngDevMode ? [{ debugName: "autoCloseOnMaxSelection" }] : /* istanbul ignore next */ []));
|
|
45
|
+
captionLayout = input('label', /* @ts-ignore */
|
|
46
|
+
...(ngDevMode ? [{ debugName: "captionLayout" }] : /* istanbul ignore next */ []));
|
|
47
|
+
formatDates = input(this._config.formatDates, /* @ts-ignore */
|
|
48
|
+
...(ngDevMode ? [{ debugName: "formatDates" }] : /* istanbul ignore next */ []));
|
|
49
|
+
transformDates = input(this._config.transformDates, /* @ts-ignore */
|
|
50
|
+
...(ngDevMode ? [{ debugName: "transformDates" }] : /* istanbul ignore next */ []));
|
|
51
|
+
parseDate = input(this._config.parseDate, /* @ts-ignore */
|
|
52
|
+
...(ngDevMode ? [{ debugName: "parseDate" }] : /* istanbul ignore next */ []));
|
|
53
|
+
formatInputDates = input(this._config.formatInputDates, /* @ts-ignore */
|
|
54
|
+
...(ngDevMode ? [{ debugName: "formatInputDates" }] : /* istanbul ignore next */ []));
|
|
55
|
+
effectiveId = computed(() => this.controlId() || this.id() || this.generatedId, /* @ts-ignore */
|
|
56
|
+
...(ngDevMode ? [{ debugName: "effectiveId" }] : /* istanbul ignore next */ []));
|
|
57
|
+
errorId = computed(() => `${this.effectiveId()}-error`, /* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
|
|
59
|
+
hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
|
|
60
|
+
...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
|
|
61
|
+
/**
|
|
62
|
+
* Bounds projected onto the picker's `Date` model. The cast keeps the
|
|
63
|
+
* template's generic inference on `Date` while passing runtime values
|
|
64
|
+
* through untouched.
|
|
65
|
+
*/
|
|
66
|
+
$min = computed(() => this.min(), /* @ts-ignore */
|
|
67
|
+
...(ngDevMode ? [{ debugName: "$min" }] : /* istanbul ignore next */ []));
|
|
68
|
+
$max = computed(() => this.max(), /* @ts-ignore */
|
|
69
|
+
...(ngDevMode ? [{ debugName: "$max" }] : /* istanbul ignore next */ []));
|
|
70
|
+
describedBy() {
|
|
71
|
+
const control = this.formGroupDirective.form.get(this.controlName());
|
|
72
|
+
return this.error() && control?.invalid && (control.dirty || control.touched)
|
|
73
|
+
? this.errorId()
|
|
74
|
+
: this.hint()
|
|
75
|
+
? this.hintId()
|
|
76
|
+
: null;
|
|
77
|
+
}
|
|
78
|
+
// Styling
|
|
79
|
+
userClass = input('', { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: 'class' });
|
|
80
|
+
labelClass = input('', /* @ts-ignore */
|
|
81
|
+
...(ngDevMode ? [{ debugName: "labelClass" }] : /* istanbul ignore next */ []));
|
|
82
|
+
pickerClass = input('', /* @ts-ignore */
|
|
83
|
+
...(ngDevMode ? [{ debugName: "pickerClass" }] : /* istanbul ignore next */ []));
|
|
84
|
+
inputClass = input('', /* @ts-ignore */
|
|
85
|
+
...(ngDevMode ? [{ debugName: "inputClass" }] : /* istanbul ignore next */ []));
|
|
86
|
+
errorClass = input('', /* @ts-ignore */
|
|
87
|
+
...(ngDevMode ? [{ debugName: "errorClass" }] : /* istanbul ignore next */ []));
|
|
88
|
+
hintClass = input('', /* @ts-ignore */
|
|
89
|
+
...(ngDevMode ? [{ debugName: "hintClass" }] : /* istanbul ignore next */ []));
|
|
90
|
+
// Computed classes (library base < global config < per-instance)
|
|
91
|
+
$userClass = computed(() => hlm('tw:w-full', this.userClass()), /* @ts-ignore */
|
|
92
|
+
...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
|
|
93
|
+
$labelClass = computed(() => hlm('tw:mb-1', this._config.labelClass, this.labelClass()), /* @ts-ignore */
|
|
94
|
+
...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
|
|
95
|
+
$pickerClass = computed(() => hlm('tw:mb-1', this._config.pickerClass, this.pickerClass()), /* @ts-ignore */
|
|
96
|
+
...(ngDevMode ? [{ debugName: "$pickerClass" }] : /* istanbul ignore next */ []));
|
|
97
|
+
$inputClass = computed(() => hlm(this._config.inputClass, this.inputClass()), /* @ts-ignore */
|
|
98
|
+
...(ngDevMode ? [{ debugName: "$inputClass" }] : /* istanbul ignore next */ []));
|
|
99
|
+
$errorClass = computed(() => hlm('tw:mt-0', this._config.errorClass, this.errorClass()), /* @ts-ignore */
|
|
100
|
+
...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
|
|
101
|
+
$hintClass = computed(() => hlm('tw:mt-0', this._config.hintClass, this.hintClass()), /* @ts-ignore */
|
|
102
|
+
...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
|
|
103
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormDatePickerMulti, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
104
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormDatePickerMulti, isStandalone: true, selector: "eg-form-date-picker-multi", 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 }, minSelection: { classPropertyName: "minSelection", publicName: "minSelection", isSignal: true, isRequired: false, transformFunction: null }, maxSelection: { classPropertyName: "maxSelection", publicName: "maxSelection", isSignal: true, isRequired: false, transformFunction: null }, autoCloseOnMaxSelection: { classPropertyName: "autoCloseOnMaxSelection", publicName: "autoCloseOnMaxSelection", isSignal: true, isRequired: false, transformFunction: null }, captionLayout: { classPropertyName: "captionLayout", publicName: "captionLayout", isSignal: true, isRequired: false, transformFunction: null }, formatDates: { classPropertyName: "formatDates", publicName: "formatDates", isSignal: true, isRequired: false, transformFunction: null }, transformDates: { classPropertyName: "transformDates", publicName: "transformDates", isSignal: true, isRequired: false, transformFunction: null }, parseDate: { classPropertyName: "parseDate", publicName: "parseDate", isSignal: true, isRequired: false, transformFunction: null }, formatInputDates: { classPropertyName: "formatInputDates", publicName: "formatInputDates", 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: `
|
|
105
|
+
@let lbl = label();
|
|
106
|
+
@let cnm = controlName();
|
|
107
|
+
@let err = error();
|
|
108
|
+
@let hnt = hint();
|
|
109
|
+
@let rqrd = required();
|
|
110
|
+
|
|
111
|
+
<hlm-form-field>
|
|
112
|
+
@if (lbl) {
|
|
113
|
+
<label hlmLabel [for]="effectiveId()" [class]="$labelClass()"
|
|
114
|
+
>{{ lbl }}
|
|
115
|
+
@if (rqrd) {
|
|
116
|
+
<span class="tw:text-red-500">*</span>
|
|
117
|
+
}
|
|
118
|
+
</label>
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
<hlm-date-picker-multi
|
|
122
|
+
[min]="$min()"
|
|
123
|
+
[max]="$max()"
|
|
124
|
+
[minSelection]="minSelection()"
|
|
125
|
+
[maxSelection]="maxSelection()"
|
|
126
|
+
[disabled]="disabled()"
|
|
127
|
+
[autoCloseOnMaxSelection]="autoCloseOnMaxSelection()"
|
|
128
|
+
[captionLayout]="captionLayout()"
|
|
129
|
+
[formatDates]="formatDates()"
|
|
130
|
+
[transformDates]="transformDates()"
|
|
131
|
+
[formControlName]="cnm"
|
|
132
|
+
[class]="$pickerClass()"
|
|
133
|
+
>
|
|
134
|
+
<hlm-date-multi-input
|
|
135
|
+
[inputId]="effectiveId()"
|
|
136
|
+
[name]="cnm || name()"
|
|
137
|
+
[readonly]="readonly()"
|
|
138
|
+
[ariaLabel]="lbl"
|
|
139
|
+
[ariaDescribedby]="describedBy()"
|
|
140
|
+
[placeholder]="placeholder()"
|
|
141
|
+
[parseDate]="parseDate()"
|
|
142
|
+
[formatInputDates]="formatInputDates()"
|
|
143
|
+
[inputClass]="$inputClass()"
|
|
144
|
+
/>
|
|
145
|
+
</hlm-date-picker-multi>
|
|
146
|
+
|
|
147
|
+
@if (err) {
|
|
148
|
+
<hlm-error [id]="errorId()" [class]="$errorClass()">
|
|
149
|
+
{{ err }}
|
|
150
|
+
</hlm-error>
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@if (hnt) {
|
|
154
|
+
<hlm-hint [id]="hintId()" [class]="$hintClass()">
|
|
155
|
+
{{ hnt }}
|
|
156
|
+
</hlm-hint>
|
|
157
|
+
}
|
|
158
|
+
</hlm-form-field>
|
|
159
|
+
`, 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: HlmDatePickerMulti, selector: "hlm-date-picker-multi", inputs: ["captionLayout", "min", "max", "minSelection", "maxSelection", "disabled", "date", "autoCloseOnMaxSelection", "formatDates", "transformDates"], outputs: ["dateChange"] }, { kind: "component", type: HlmDateMultiInput, selector: "hlm-date-multi-input", inputs: ["name", "readonly", "ariaLabel", "ariaDescribedby", "class", "inputClass", "parseDate", "formatInputDates"] }] });
|
|
160
|
+
}
|
|
161
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormDatePickerMulti, decorators: [{
|
|
162
|
+
type: Component,
|
|
163
|
+
args: [{
|
|
164
|
+
selector: 'eg-form-date-picker-multi',
|
|
165
|
+
standalone: true,
|
|
166
|
+
host: {
|
|
167
|
+
'[class]': '$userClass()',
|
|
168
|
+
},
|
|
169
|
+
imports: [ReactiveFormsModule, HlmFormField, HlmError, HlmHint, HlmLabel, HlmDatePickerMulti, HlmDateMultiInput],
|
|
170
|
+
providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
|
|
171
|
+
template: `
|
|
172
|
+
@let lbl = label();
|
|
173
|
+
@let cnm = controlName();
|
|
174
|
+
@let err = error();
|
|
175
|
+
@let hnt = hint();
|
|
176
|
+
@let rqrd = required();
|
|
177
|
+
|
|
178
|
+
<hlm-form-field>
|
|
179
|
+
@if (lbl) {
|
|
180
|
+
<label hlmLabel [for]="effectiveId()" [class]="$labelClass()"
|
|
181
|
+
>{{ lbl }}
|
|
182
|
+
@if (rqrd) {
|
|
183
|
+
<span class="tw:text-red-500">*</span>
|
|
184
|
+
}
|
|
185
|
+
</label>
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
<hlm-date-picker-multi
|
|
189
|
+
[min]="$min()"
|
|
190
|
+
[max]="$max()"
|
|
191
|
+
[minSelection]="minSelection()"
|
|
192
|
+
[maxSelection]="maxSelection()"
|
|
193
|
+
[disabled]="disabled()"
|
|
194
|
+
[autoCloseOnMaxSelection]="autoCloseOnMaxSelection()"
|
|
195
|
+
[captionLayout]="captionLayout()"
|
|
196
|
+
[formatDates]="formatDates()"
|
|
197
|
+
[transformDates]="transformDates()"
|
|
198
|
+
[formControlName]="cnm"
|
|
199
|
+
[class]="$pickerClass()"
|
|
200
|
+
>
|
|
201
|
+
<hlm-date-multi-input
|
|
202
|
+
[inputId]="effectiveId()"
|
|
203
|
+
[name]="cnm || name()"
|
|
204
|
+
[readonly]="readonly()"
|
|
205
|
+
[ariaLabel]="lbl"
|
|
206
|
+
[ariaDescribedby]="describedBy()"
|
|
207
|
+
[placeholder]="placeholder()"
|
|
208
|
+
[parseDate]="parseDate()"
|
|
209
|
+
[formatInputDates]="formatInputDates()"
|
|
210
|
+
[inputClass]="$inputClass()"
|
|
211
|
+
/>
|
|
212
|
+
</hlm-date-picker-multi>
|
|
213
|
+
|
|
214
|
+
@if (err) {
|
|
215
|
+
<hlm-error [id]="errorId()" [class]="$errorClass()">
|
|
216
|
+
{{ err }}
|
|
217
|
+
</hlm-error>
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@if (hnt) {
|
|
221
|
+
<hlm-hint [id]="hintId()" [class]="$hintClass()">
|
|
222
|
+
{{ hnt }}
|
|
223
|
+
</hlm-hint>
|
|
224
|
+
}
|
|
225
|
+
</hlm-form-field>
|
|
226
|
+
`,
|
|
227
|
+
}]
|
|
228
|
+
}], 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 }] }], minSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "minSelection", required: false }] }], maxSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxSelection", required: false }] }], autoCloseOnMaxSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoCloseOnMaxSelection", required: false }] }], captionLayout: [{ type: i0.Input, args: [{ isSignal: true, alias: "captionLayout", required: false }] }], formatDates: [{ type: i0.Input, args: [{ isSignal: true, alias: "formatDates", required: false }] }], transformDates: [{ type: i0.Input, args: [{ isSignal: true, alias: "transformDates", required: false }] }], parseDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "parseDate", required: false }] }], formatInputDates: [{ type: i0.Input, args: [{ isSignal: true, alias: "formatInputDates", 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 }] }] } });
|
|
229
|
+
|
|
230
|
+
/*
|
|
231
|
+
* Public API Surface of form-date-picker-multi
|
|
232
|
+
*/
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Generated bundle index. Do not edit.
|
|
236
|
+
*/
|
|
237
|
+
|
|
238
|
+
export { EgFormDatePickerMulti };
|
|
239
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "form-date-picker-multi",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^20.3.0 || ^22.0.0",
|
|
6
|
+
"@angular/core": "^20.3.0 || ^22.0.0"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"tslib": "^2.3.0"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"module": "fesm2022/form-date-picker-multi.mjs",
|
|
13
|
+
"typings": "types/form-date-picker-multi.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
"./package.json": {
|
|
16
|
+
"default": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./types/form-date-picker-multi.d.ts",
|
|
20
|
+
"default": "./fesm2022/form-date-picker-multi.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"type": "module"
|
|
24
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { ClassValue } from 'clsx';
|
|
3
|
+
import { NumberInput } from '@angular/cdk/coercion';
|
|
4
|
+
|
|
5
|
+
type DatePickerCaptionLayout = 'dropdown' | 'label' | 'dropdown-months' | 'dropdown-years';
|
|
6
|
+
declare class EgFormDatePickerMulti {
|
|
7
|
+
private readonly formGroupDirective;
|
|
8
|
+
private readonly generatedId;
|
|
9
|
+
private readonly _config;
|
|
10
|
+
label: _angular_core.InputSignal<string | undefined>;
|
|
11
|
+
controlId: _angular_core.InputSignal<string | undefined>;
|
|
12
|
+
controlName: _angular_core.InputSignal<string>;
|
|
13
|
+
error: _angular_core.InputSignal<string | undefined>;
|
|
14
|
+
hint: _angular_core.InputSignal<string | undefined>;
|
|
15
|
+
id: _angular_core.InputSignal<string | undefined>;
|
|
16
|
+
name: _angular_core.InputSignal<string | undefined>;
|
|
17
|
+
placeholder: _angular_core.InputSignal<string>;
|
|
18
|
+
readonly: _angular_core.InputSignal<boolean>;
|
|
19
|
+
disabled: _angular_core.InputSignal<boolean>;
|
|
20
|
+
required: _angular_core.InputSignal<boolean>;
|
|
21
|
+
min: _angular_core.InputSignal<string | Date | null>;
|
|
22
|
+
max: _angular_core.InputSignal<string | Date | null>;
|
|
23
|
+
minSelection: _angular_core.InputSignalWithTransform<number | undefined, NumberInput>;
|
|
24
|
+
maxSelection: _angular_core.InputSignalWithTransform<number | undefined, NumberInput>;
|
|
25
|
+
autoCloseOnMaxSelection: _angular_core.InputSignal<boolean>;
|
|
26
|
+
captionLayout: _angular_core.InputSignal<DatePickerCaptionLayout>;
|
|
27
|
+
formatDates: _angular_core.InputSignal<(dates: Date[]) => string>;
|
|
28
|
+
transformDates: _angular_core.InputSignal<(dates: Date[]) => Date[]>;
|
|
29
|
+
parseDate: _angular_core.InputSignal<(value: string) => Date[] | null>;
|
|
30
|
+
formatInputDates: _angular_core.InputSignal<(dates: Date[]) => string>;
|
|
31
|
+
readonly effectiveId: _angular_core.Signal<string>;
|
|
32
|
+
readonly errorId: _angular_core.Signal<string>;
|
|
33
|
+
readonly hintId: _angular_core.Signal<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Bounds projected onto the picker's `Date` model. The cast keeps the
|
|
36
|
+
* template's generic inference on `Date` while passing runtime values
|
|
37
|
+
* through untouched.
|
|
38
|
+
*/
|
|
39
|
+
protected readonly $min: _angular_core.Signal<Date | undefined>;
|
|
40
|
+
protected readonly $max: _angular_core.Signal<Date | undefined>;
|
|
41
|
+
describedBy(): string | null;
|
|
42
|
+
userClass: _angular_core.InputSignal<ClassValue>;
|
|
43
|
+
labelClass: _angular_core.InputSignal<string>;
|
|
44
|
+
pickerClass: _angular_core.InputSignal<string>;
|
|
45
|
+
inputClass: _angular_core.InputSignal<string>;
|
|
46
|
+
errorClass: _angular_core.InputSignal<string>;
|
|
47
|
+
hintClass: _angular_core.InputSignal<string>;
|
|
48
|
+
$userClass: _angular_core.Signal<string>;
|
|
49
|
+
$labelClass: _angular_core.Signal<string>;
|
|
50
|
+
$pickerClass: _angular_core.Signal<string>;
|
|
51
|
+
$inputClass: _angular_core.Signal<string>;
|
|
52
|
+
$errorClass: _angular_core.Signal<string>;
|
|
53
|
+
$hintClass: _angular_core.Signal<string>;
|
|
54
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormDatePickerMulti, never>;
|
|
55
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormDatePickerMulti, "eg-form-date-picker-multi", 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; }; "minSelection": { "alias": "minSelection"; "required": false; "isSignal": true; }; "maxSelection": { "alias": "maxSelection"; "required": false; "isSignal": true; }; "autoCloseOnMaxSelection": { "alias": "autoCloseOnMaxSelection"; "required": false; "isSignal": true; }; "captionLayout": { "alias": "captionLayout"; "required": false; "isSignal": true; }; "formatDates": { "alias": "formatDates"; "required": false; "isSignal": true; }; "transformDates": { "alias": "transformDates"; "required": false; "isSignal": true; }; "parseDate": { "alias": "parseDate"; "required": false; "isSignal": true; }; "formatInputDates": { "alias": "formatInputDates"; "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>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { EgFormDatePickerMulti };
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# Form Date Range Picker (`@egose/shadcn-theme-ng/form-date-range-picker`)
|
|
2
|
+
|
|
3
|
+
A ready-made reactive-form date-range field: label + `hlm-date-range-picker` + validation error/hint display in one tag. Equivalent to shadcn/ui `Form` + date-range-picker composition.
|
|
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
|
+
`HlmDateRangePicker` + `HlmDateRangeInput` from `@egose/shadcn-theme-ng/date-picker`. The inner
|
|
8
|
+
`hlm-date-range-picker` is bound with `[formControlName]="controlName()"`, so the parent `FormGroup`
|
|
9
|
+
owns the `[Date, Date] | null` value. It must live inside a `FormGroupDirective` (`[formGroup]` parent);
|
|
10
|
+
ids come from `HlmFormIdGenerator` unless overridden.
|
|
11
|
+
|
|
12
|
+
> **Ships as:** `@egose/shadcn-theme-ng/form-date-range-picker` and `@egose/shadcn-theme-ng-tw/form-date-range-picker`
|
|
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-range-picker/src/public-api.ts`). Note: this subpath
|
|
35
|
+
exports a single standalone component — there is no `*Imports` array or `*Module`:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { EgFormDateRangePicker } from '@egose/shadcn-theme-ng/form-date-range-picker';
|
|
39
|
+
// tw variant: replace with '@egose/shadcn-theme-ng-tw/form-date-range-picker'
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Standalone usage:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { Component } from '@angular/core';
|
|
46
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
47
|
+
import { EgFormDateRangePicker } from '@egose/shadcn-theme-ng/form-date-range-picker';
|
|
48
|
+
|
|
49
|
+
@Component({
|
|
50
|
+
selector: 'app-demo',
|
|
51
|
+
standalone: true,
|
|
52
|
+
imports: [ReactiveFormsModule, EgFormDateRangePicker],
|
|
53
|
+
template: `...`,
|
|
54
|
+
})
|
|
55
|
+
export class DemoComponent {}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
NgModule-based consumer: add `EgFormDateRangePicker` (and `ReactiveFormsModule`) to the module's
|
|
59
|
+
`imports` — it is a standalone component, not a module.
|
|
60
|
+
|
|
61
|
+
`ControlValueAccessor` behavior: `eg-form-date-range-picker` itself is not a `ControlValueAccessor`; the
|
|
62
|
+
inner `hlm-date-range-picker` is (bound via `formControlName`), so `formControlName`/`formGroup` handling,
|
|
63
|
+
`Validators`, `disabled` state from the control, and `dateChange` values (`[Date, Date] | null`) all flow
|
|
64
|
+
through the parent form.
|
|
65
|
+
|
|
66
|
+
## Anatomy / Structure
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<form [formGroup]="form">
|
|
70
|
+
<eg-form-date-range-picker
|
|
71
|
+
controlName="stay"
|
|
72
|
+
label="Stay dates"
|
|
73
|
+
placeholder="Pick a date range"
|
|
74
|
+
[required]="true"
|
|
75
|
+
hint="Pick check-in and check-out."
|
|
76
|
+
error="Stay dates are required."
|
|
77
|
+
/>
|
|
78
|
+
</form>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Selector (from source): `eg-form-date-range-picker` (standalone component, host `tw:w-full`).
|
|
82
|
+
|
|
83
|
+
## API reference
|
|
84
|
+
|
|
85
|
+
### `EgFormDateRangePicker` — `eg-form-date-range-picker`
|
|
86
|
+
|
|
87
|
+
| Input | Type | Default | Description |
|
|
88
|
+
| ------------------------- | ------------------------------------------------- | --------------------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
89
|
+
| `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.** |
|
|
90
|
+
| `label` | `string \| undefined` | — | Label text (hidden when omitted). |
|
|
91
|
+
| `error` | `string \| undefined` | — | Error text shown when invalid. |
|
|
92
|
+
| `hint` | `string \| undefined` | — | Hint text shown otherwise. |
|
|
93
|
+
| `controlId` | `string \| undefined` | — | Explicit id (first priority for `effectiveId`). |
|
|
94
|
+
| `id` | `string \| undefined` | — | Fallback id (second priority). |
|
|
95
|
+
| `name` | `string \| undefined` | — | Native `name` forwarded to the inner input (`controlName` wins when set, like `eg-form-text-input`). |
|
|
96
|
+
| `placeholder` | `string` | `'Pick a date range'` | Input placeholder. |
|
|
97
|
+
| `readonly` | `boolean` | `false` | Native `readonly` forwarded to the inner input (locks typed text; use `disabled` to lock the calendar too). |
|
|
98
|
+
| `disabled` | `boolean` | `false` | Locks interaction via picker `disabled` (form control stays enabled). |
|
|
99
|
+
| `required` | `boolean` | `false` | Shows a red `*` next to the label. |
|
|
100
|
+
| `min` | `Date \| string \| null` | `null` | Minimum date forwarded to `hlm-date-range-picker`. |
|
|
101
|
+
| `max` | `Date \| string \| null` | `null` | Maximum date forwarded to `hlm-date-range-picker`. |
|
|
102
|
+
| `autoCloseOnEndSelection` | `boolean` | config default | Forwarded to `hlm-date-range-picker` (falls back to `provideHlmDateRangePickerConfig`, default `false`). |
|
|
103
|
+
| `captionLayout` | union | `'label'` | Forwarded to `hlm-date-range-picker` (`'dropdown' \| 'label' \| 'dropdown-months' \| 'dropdown-years'`). |
|
|
104
|
+
| `formatDates` | `(dates: [Date \| null, Date \| null]) => string` | config default | Display format, forwarded to `hlm-date-range-picker` (falls back to `provideHlmDateRangePickerConfig`). |
|
|
105
|
+
| `transformDates` | `(dates: [Date, Date]) => [Date, Date]` | config default | Model transform, forwarded to `hlm-date-range-picker` (falls back to `provideHlmDateRangePickerConfig`). |
|
|
106
|
+
| `parseDate` | `(value: string) => [Date, Date] \| null` | config default | Input parsing, forwarded to `hlm-date-range-input` (falls back to `provideHlmDateRangePickerConfig`). |
|
|
107
|
+
| `formatInputDates` | `(dates: [Date \| null, Date \| null]) => string` | config default | Edit format while focused, forwarded to `hlm-date-range-input` (falls back to `provideHlmDateRangePickerConfig`). |
|
|
108
|
+
| `class` | `ClassValue` | `''` | Extra host classes (base `tw:w-full`). |
|
|
109
|
+
| `labelClass` | `string` | `''` | Extra label classes (base `tw:mb-1`). |
|
|
110
|
+
| `pickerClass` | `string` | `''` | Extra picker-container classes (base `tw:mb-1`). |
|
|
111
|
+
| `inputClass` | `string` | `''` | Extra inner-input classes (e.g. `tw:text-lg` for text size). |
|
|
112
|
+
| `errorClass` | `string` | `''` | Extra error classes (base `tw:mt-0`). |
|
|
113
|
+
| `hintClass` | `string` | `''` | Extra hint classes (base `tw:mt-0`). |
|
|
114
|
+
|
|
115
|
+
| Member | Description |
|
|
116
|
+
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
117
|
+
| `effectiveId` | `controlId() \|\| id() \|\| generated` — wired to input `inputId` and label `for`. |
|
|
118
|
+
| `errorId` / `hintId` | `effectiveId + '-error' / '-hint'`. |
|
|
119
|
+
| `describedBy()` | `errorId` when `error()` is set and control is invalid + dirty/touched, else `hintId` when `hint()` is set, else `null` — wired to input `ariaDescribedby`. |
|
|
120
|
+
|
|
121
|
+
Requires a `[formGroup]` ancestor (injects `FormGroupDirective`, provides `ControlContainer → FormGroupDirective`).
|
|
122
|
+
|
|
123
|
+
## Examples
|
|
124
|
+
|
|
125
|
+
### 1. Basic required range field
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
import { Component, inject } from '@angular/core';
|
|
129
|
+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
130
|
+
import { EgFormDateRangePicker } from '@egose/shadcn-theme-ng/form-date-range-picker';
|
|
131
|
+
|
|
132
|
+
@Component({
|
|
133
|
+
selector: 'app-stay',
|
|
134
|
+
standalone: true,
|
|
135
|
+
imports: [ReactiveFormsModule, EgFormDateRangePicker],
|
|
136
|
+
template: `
|
|
137
|
+
<form [formGroup]="form" (ngSubmit)="submit()">
|
|
138
|
+
<eg-form-date-range-picker
|
|
139
|
+
controlName="stay"
|
|
140
|
+
label="Stay dates"
|
|
141
|
+
[required]="true"
|
|
142
|
+
error="Stay dates are required."
|
|
143
|
+
/>
|
|
144
|
+
<button type="submit" [disabled]="form.invalid">Continue</button>
|
|
145
|
+
</form>
|
|
146
|
+
`,
|
|
147
|
+
})
|
|
148
|
+
export class StayComponent {
|
|
149
|
+
private readonly fb = inject(FormBuilder);
|
|
150
|
+
readonly form = this.fb.group({ stay: [null as [Date, Date] | null, Validators.required] });
|
|
151
|
+
submit() {
|
|
152
|
+
console.log(this.form.value.stay);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### 2. Hint + min bound
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
import { Component, inject } from '@angular/core';
|
|
161
|
+
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
|
162
|
+
import { EgFormDateRangePicker } from '@egose/shadcn-theme-ng/form-date-range-picker';
|
|
163
|
+
|
|
164
|
+
@Component({
|
|
165
|
+
selector: 'app-bounds',
|
|
166
|
+
standalone: true,
|
|
167
|
+
imports: [ReactiveFormsModule, EgFormDateRangePicker],
|
|
168
|
+
template: `
|
|
169
|
+
<form [formGroup]="form">
|
|
170
|
+
<eg-form-date-range-picker
|
|
171
|
+
controlName="booking"
|
|
172
|
+
label="Booking"
|
|
173
|
+
placeholder="Select your stay"
|
|
174
|
+
[min]="today"
|
|
175
|
+
hint="Stays start today or later."
|
|
176
|
+
error="Pick a valid stay."
|
|
177
|
+
/>
|
|
178
|
+
</form>
|
|
179
|
+
`,
|
|
180
|
+
})
|
|
181
|
+
export class BoundsComponent {
|
|
182
|
+
private readonly fb = inject(FormBuilder);
|
|
183
|
+
readonly form = this.fb.group({ booking: [null as [Date, Date] | null] });
|
|
184
|
+
readonly today = new Date();
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### 3. Custom label/input styling
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
import { Component, inject } from '@angular/core';
|
|
192
|
+
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
|
193
|
+
import { EgFormDateRangePicker } from '@egose/shadcn-theme-ng/form-date-range-picker';
|
|
194
|
+
|
|
195
|
+
@Component({
|
|
196
|
+
selector: 'app-styled-range',
|
|
197
|
+
standalone: true,
|
|
198
|
+
imports: [ReactiveFormsModule, EgFormDateRangePicker],
|
|
199
|
+
template: `
|
|
200
|
+
<form [formGroup]="form">
|
|
201
|
+
<eg-form-date-range-picker
|
|
202
|
+
controlName="event"
|
|
203
|
+
controlId="event-range"
|
|
204
|
+
label="Event range"
|
|
205
|
+
labelClass="tw:font-semibold"
|
|
206
|
+
pickerClass="tw:max-w-md"
|
|
207
|
+
inputClass="tw:text-lg"
|
|
208
|
+
hint="Doors open one hour earlier on day one."
|
|
209
|
+
/>
|
|
210
|
+
</form>
|
|
211
|
+
`,
|
|
212
|
+
})
|
|
213
|
+
export class StyledRangeComponent {
|
|
214
|
+
private readonly fb = inject(FormBuilder);
|
|
215
|
+
readonly form = this.fb.group({ event: [null as [Date, Date] | null] });
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Accessibility notes
|
|
220
|
+
|
|
221
|
+
- Label `for` ↔ input `inputId` wiring is automatic via `effectiveId`; the input also receives `ariaLabel` (the label text) and `ariaDescribedby` (error/hint id) — always pass a `label`.
|
|
222
|
+
- Closing the picker popover marks the control touched, so errors appear after interaction even without typing.
|
|
223
|
+
- The required `*` is visual; pair with `Validators.required` so assistive tech and validation agree.
|
|
224
|
+
- Arrow-down opens the calendar from the input; the calendar/popup primitives handle focus trap, escape, and outside-click dismissal.
|
|
225
|
+
|
|
226
|
+
## Theming / CSS variables
|
|
227
|
+
|
|
228
|
+
No component-specific CSS variables. Style per-instance via `class` / `labelClass` / `pickerClass` / `inputClass` / `errorClass` / `hintClass` (precedence: library base < global config < per-instance).
|
|
229
|
+
|
|
230
|
+
Global defaults (styling analogue of `formatDates`) via the range picker config:
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
import { provideHlmDateRangePickerConfig } from '@egose/shadcn-theme-ng/date-picker';
|
|
234
|
+
|
|
235
|
+
await bootstrapApplication(App, {
|
|
236
|
+
providers: [
|
|
237
|
+
provideHlmDateRangePickerConfig({
|
|
238
|
+
inputClass: 'tw:text-sm', // every range input; per-instance inputClass still wins on conflict
|
|
239
|
+
labelClass: 'tw:font-medium',
|
|
240
|
+
}),
|
|
241
|
+
],
|
|
242
|
+
});
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
The host keeps `tw:w-full`; constrain width with `class` (e.g. `tw:max-w-md`) or a wrapping container.
|
|
246
|
+
|
|
247
|
+
## Related subpaths
|
|
248
|
+
|
|
249
|
+
- `@egose/shadcn-theme-ng/date-picker` — raw `hlm-date-range-picker` + input/trigger/config tokens for custom layouts.
|
|
250
|
+
- `@egose/shadcn-theme-ng/form-date-picker` — the single-date counterpart (`eg-form-date-picker`).
|
|
251
|
+
- `@egose/shadcn-theme-ng/form-field` — `hlm-form-field` / `hlm-error` / `hlm-hint` used internally.
|
|
252
|
+
- `@egose/shadcn-theme-ng/calendar` — calendars rendered inside the picker popover.
|
|
253
|
+
- `@egose/shadcn-theme-ng/form-field-simple` — alternative minimal wrapper when you compose pickers by hand.
|