@egose/shadcn-theme-ng-tw 0.0.28 → 0.2.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 +130 -13
- package/accordion/README.md +376 -34
- package/accordion/fesm2022/accordion.mjs +20 -20
- package/alert/README.md +343 -34
- package/alert/fesm2022/alert.mjs +18 -18
- package/alert-dialog/README.md +471 -5
- package/alert-dialog/fesm2022/alert-dialog.mjs +48 -48
- package/alert-dialog/types/alert-dialog.d.ts +1 -1
- package/aspect-ratio/README.md +272 -5
- package/aspect-ratio/fesm2022/aspect-ratio.mjs +9 -9
- package/autocomplete/README.md +473 -34
- package/autocomplete/fesm2022/autocomplete.mjs +54 -54
- package/autocomplete/types/autocomplete.d.ts +1 -1
- package/avatar/README.md +357 -5
- package/avatar/fesm2022/avatar.mjs +32 -32
- package/badge/README.md +289 -34
- package/badge/fesm2022/badge.mjs +4 -4
- package/basic-alert/README.md +324 -34
- package/basic-alert/fesm2022/basic-alert.mjs +4 -4
- package/basic-alert/types/basic-alert.d.ts +1 -1
- package/breadcrumb/README.md +406 -5
- package/breadcrumb/fesm2022/breadcrumb.mjs +34 -34
- package/button/README.md +453 -34
- package/button/fesm2022/button.mjs +96 -118
- package/button/types/button.d.ts +7 -10
- package/button-group/README.md +318 -5
- package/button-group/fesm2022/button-group.mjs +20 -20
- package/calendar/README.md +328 -34
- package/calendar/fesm2022/calendar.mjs +154 -154
- package/card/README.md +331 -5
- package/card/fesm2022/card.mjs +33 -33
- package/carousel/README.md +333 -5
- package/carousel/fesm2022/carousel.mjs +47 -44
- package/carousel/types/carousel.d.ts +1 -1
- package/checkbox/README.md +291 -34
- package/checkbox/fesm2022/checkbox.mjs +22 -20
- package/checkbox/types/checkbox.d.ts +5 -4
- package/collapsible/README.md +332 -5
- package/collapsible/fesm2022/collapsible.mjs +15 -15
- package/combobox/README.md +507 -5
- package/combobox/fesm2022/combobox.mjs +95 -92
- package/combobox/types/combobox.d.ts +1 -1
- package/command/README.md +435 -5
- package/command/fesm2022/command.mjs +56 -56
- package/confirmation-dialog/README.md +272 -34
- package/confirmation-dialog/fesm2022/confirmation-dialog.mjs +13 -12
- package/confirmation-dialog/types/confirmation-dialog.d.ts +9 -5
- package/context-menu/README.md +366 -5
- package/context-menu/fesm2022/context-menu.mjs +9 -9
- package/date-picker/README.md +436 -34
- package/date-picker/fesm2022/date-picker.mjs +79 -68
- package/date-picker/types/date-picker.d.ts +8 -4
- package/dialog/README.md +419 -34
- package/dialog/fesm2022/dialog.mjs +48 -48
- package/drawer/README.md +395 -5
- package/drawer/fesm2022/drawer.mjs +45 -45
- package/dropdown-menu/README.md +417 -5
- package/dropdown-menu/fesm2022/dropdown-menu.mjs +85 -73
- package/dropdown-menu/types/dropdown-menu.d.ts +4 -0
- package/empty/README.md +329 -5
- package/empty/fesm2022/empty.mjs +31 -31
- package/field/README.md +385 -5
- package/field/fesm2022/field.mjs +59 -59
- package/field/types/field.d.ts +1 -1
- package/form-checkbox/README.md +283 -34
- package/form-checkbox/fesm2022/form-checkbox.mjs +37 -19
- package/form-checkbox/types/form-checkbox.d.ts +7 -1
- package/form-date-picker/README.md +293 -34
- package/form-date-picker/fesm2022/form-date-picker.mjs +59 -24
- package/form-date-picker/types/form-date-picker.d.ts +7 -1
- package/form-field/README.md +327 -34
- package/form-field/fesm2022/form-field.mjs +30 -16
- package/form-field/types/form-field.d.ts +28 -20
- package/form-field-simple/README.md +311 -34
- package/form-field-simple/fesm2022/form-field-simple.mjs +4 -4
- package/form-searchable-multiselect/README.md +332 -34
- package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs +41 -21
- package/form-searchable-multiselect/types/form-searchable-multiselect.d.ts +8 -2
- package/form-select/README.md +321 -34
- package/form-select/fesm2022/form-select.mjs +62 -29
- package/form-select/types/form-select.d.ts +7 -1
- package/form-text-input/README.md +342 -34
- package/form-text-input/fesm2022/form-text-input.mjs +43 -55
- package/form-text-input/types/form-text-input.d.ts +9 -12
- package/form-textarea/README.md +318 -34
- package/form-textarea/fesm2022/form-textarea.mjs +42 -23
- package/form-textarea/types/form-textarea.d.ts +8 -1
- package/hover-card/README.md +256 -5
- package/hover-card/fesm2022/hover-card.mjs +19 -19
- package/icon/README.md +210 -34
- package/icon/fesm2022/icon.mjs +8 -8
- package/input/README.md +240 -34
- package/input/fesm2022/input.mjs +17 -12
- package/input/types/input.d.ts +2 -1
- package/input-group/README.md +335 -5
- package/input-group/fesm2022/input-group.mjs +37 -37
- package/input-group/types/input-group.d.ts +3 -3
- package/input-otp/README.md +375 -5
- package/input-otp/fesm2022/input-otp.mjs +27 -27
- package/item/README.md +385 -5
- package/item/fesm2022/item.mjs +54 -54
- package/kbd/README.md +291 -5
- package/kbd/fesm2022/kbd.mjs +13 -13
- package/label/README.md +243 -34
- package/label/fesm2022/label.mjs +9 -9
- package/label/types/label.d.ts +1 -1
- package/layout-simple/README.md +174 -44
- package/layout-simple/fesm2022/layout-simple.mjs +917 -398
- package/layout-simple/types/layout-simple.d.ts +180 -129
- package/menu/README.md +418 -0
- package/menu/fesm2022/menu.mjs +461 -0
- package/menu/package.json +24 -0
- package/menu/types/menu.d.ts +137 -0
- package/menubar/README.md +343 -5
- package/menubar/fesm2022/menubar.mjs +13 -13
- package/native-select/README.md +323 -5
- package/native-select/fesm2022/native-select.mjs +19 -19
- package/navigation-menu/README.md +369 -5
- package/navigation-menu/fesm2022/navigation-menu.mjs +37 -37
- package/package.json +183 -154
- package/pagination/README.md +388 -5
- package/pagination/fesm2022/pagination.mjs +63 -63
- package/popover/README.md +302 -34
- package/popover/fesm2022/popover.mjs +30 -30
- package/progress/README.md +311 -5
- package/progress/fesm2022/progress.mjs +13 -13
- package/radio-group/README.md +335 -34
- package/radio-group/fesm2022/radio-group.mjs +26 -19
- package/resizable/README.md +269 -5
- package/resizable/fesm2022/resizable.mjs +19 -19
- package/scroll-area/README.md +233 -5
- package/scroll-area/fesm2022/scroll-area.mjs +9 -9
- package/searchable-multiselect/README.md +294 -34
- package/searchable-multiselect/fesm2022/searchable-multiselect.mjs +63 -16
- package/searchable-multiselect/types/searchable-multiselect.d.ts +8 -2
- package/select/README.md +408 -34
- package/select/fesm2022/select.mjs +80 -72
- package/select/types/select.d.ts +3 -1
- package/separator/README.md +193 -34
- package/separator/fesm2022/separator.mjs +9 -9
- package/separator/types/separator.d.ts +1 -1
- package/sheet/README.md +282 -34
- package/sheet/fesm2022/sheet.mjs +30 -30
- package/sidebar/README.md +457 -5
- package/sidebar/fesm2022/sidebar.mjs +136 -134
- package/sidebar/types/sidebar.d.ts +3 -3
- package/skeleton/README.md +217 -5
- package/skeleton/fesm2022/skeleton.mjs +9 -9
- package/slider/README.md +273 -5
- package/slider/fesm2022/slider.mjs +29 -25
- package/sonner/README.md +317 -34
- package/sonner/fesm2022/sonner.mjs +9 -9
- package/spinner/README.md +255 -34
- package/spinner/fesm2022/spinner.mjs +8 -8
- package/switch/README.md +281 -34
- package/switch/fesm2022/switch.mjs +12 -14
- package/table/README.md +423 -5
- package/table/fesm2022/table.mjs +41 -41
- package/tabs/README.md +382 -34
- package/tabs/fesm2022/tabs.mjs +48 -38
- package/textarea/README.md +282 -5
- package/textarea/fesm2022/textarea.mjs +9 -9
- package/toggle/README.md +270 -5
- package/toggle/fesm2022/toggle.mjs +14 -14
- package/toggle-group/README.md +340 -5
- package/toggle-group/fesm2022/toggle-group.mjs +13 -13
- package/toggle-group/types/toggle-group.d.ts +13 -7
- package/tooltip/README.md +240 -34
- package/tooltip/fesm2022/tooltip.mjs +14 -14
- package/typography/README.md +271 -5
- package/typography/fesm2022/typography.mjs +53 -53
- package/typography/types/typography.d.ts +12 -12
- package/utils/README.md +274 -34
- package/utils/fesm2022/utils.mjs +68 -44
- package/accordion/fesm2022/accordion.mjs.map +0 -1
- package/alert/fesm2022/alert.mjs.map +0 -1
- package/alert-dialog/fesm2022/alert-dialog.mjs.map +0 -1
- package/aspect-ratio/fesm2022/aspect-ratio.mjs.map +0 -1
- package/autocomplete/fesm2022/autocomplete.mjs.map +0 -1
- package/avatar/fesm2022/avatar.mjs.map +0 -1
- package/badge/fesm2022/badge.mjs.map +0 -1
- package/basic-alert/fesm2022/basic-alert.mjs.map +0 -1
- package/breadcrumb/fesm2022/breadcrumb.mjs.map +0 -1
- package/button/fesm2022/button.mjs.map +0 -1
- package/button-group/fesm2022/button-group.mjs.map +0 -1
- package/calendar/fesm2022/calendar.mjs.map +0 -1
- package/card/fesm2022/card.mjs.map +0 -1
- package/carousel/fesm2022/carousel.mjs.map +0 -1
- package/checkbox/fesm2022/checkbox.mjs.map +0 -1
- package/collapsible/fesm2022/collapsible.mjs.map +0 -1
- package/combobox/fesm2022/combobox.mjs.map +0 -1
- package/command/fesm2022/command.mjs.map +0 -1
- package/confirmation-dialog/fesm2022/confirmation-dialog.mjs.map +0 -1
- package/context-menu/fesm2022/context-menu.mjs.map +0 -1
- package/date-picker/fesm2022/date-picker.mjs.map +0 -1
- package/dialog/fesm2022/dialog.mjs.map +0 -1
- package/drawer/fesm2022/drawer.mjs.map +0 -1
- package/dropdown-menu/fesm2022/dropdown-menu.mjs.map +0 -1
- package/empty/fesm2022/empty.mjs.map +0 -1
- package/field/fesm2022/field.mjs.map +0 -1
- package/form-checkbox/fesm2022/form-checkbox.mjs.map +0 -1
- package/form-date-picker/fesm2022/form-date-picker.mjs.map +0 -1
- package/form-field/fesm2022/form-field.mjs.map +0 -1
- package/form-field-simple/fesm2022/form-field-simple.mjs.map +0 -1
- package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs.map +0 -1
- package/form-select/fesm2022/form-select.mjs.map +0 -1
- package/form-text-input/fesm2022/form-text-input.mjs.map +0 -1
- package/form-textarea/fesm2022/form-textarea.mjs.map +0 -1
- package/hover-card/fesm2022/hover-card.mjs.map +0 -1
- package/icon/fesm2022/icon.mjs.map +0 -1
- package/input/fesm2022/input.mjs.map +0 -1
- package/input-group/fesm2022/input-group.mjs.map +0 -1
- package/input-otp/fesm2022/input-otp.mjs.map +0 -1
- package/item/fesm2022/item.mjs.map +0 -1
- package/kbd/fesm2022/kbd.mjs.map +0 -1
- package/label/fesm2022/label.mjs.map +0 -1
- package/layout-simple/fesm2022/layout-simple.mjs.map +0 -1
- package/menubar/fesm2022/menubar.mjs.map +0 -1
- package/native-select/fesm2022/native-select.mjs.map +0 -1
- package/navigation-menu/fesm2022/navigation-menu.mjs.map +0 -1
- package/pagination/fesm2022/pagination.mjs.map +0 -1
- package/popover/fesm2022/popover.mjs.map +0 -1
- package/progress/fesm2022/progress.mjs.map +0 -1
- package/radio-group/fesm2022/radio-group.mjs.map +0 -1
- package/resizable/fesm2022/resizable.mjs.map +0 -1
- package/scroll-area/fesm2022/scroll-area.mjs.map +0 -1
- package/searchable-multiselect/fesm2022/searchable-multiselect.mjs.map +0 -1
- package/select/fesm2022/select.mjs.map +0 -1
- package/separator/fesm2022/separator.mjs.map +0 -1
- package/sheet/fesm2022/sheet.mjs.map +0 -1
- package/sidebar/fesm2022/sidebar.mjs.map +0 -1
- package/skeleton/fesm2022/skeleton.mjs.map +0 -1
- package/slider/fesm2022/slider.mjs.map +0 -1
- package/sonner/fesm2022/sonner.mjs.map +0 -1
- package/spinner/fesm2022/spinner.mjs.map +0 -1
- package/switch/fesm2022/switch.mjs.map +0 -1
- package/table/fesm2022/table.mjs.map +0 -1
- package/tabs/fesm2022/tabs.mjs.map +0 -1
- package/textarea/fesm2022/textarea.mjs.map +0 -1
- package/toggle/fesm2022/toggle.mjs.map +0 -1
- package/toggle-group/fesm2022/toggle-group.mjs.map +0 -1
- package/tooltip/fesm2022/tooltip.mjs.map +0 -1
- package/typography/fesm2022/typography.mjs.map +0 -1
- package/utils/fesm2022/utils.mjs.map +0 -1
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, computed, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { inject, input, computed, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/forms';
|
|
4
|
-
import {
|
|
4
|
+
import { FormGroupDirective, ReactiveFormsModule, ControlContainer } from '@angular/forms';
|
|
5
5
|
import { HlmLabel } from '@egose/shadcn-theme-ng-tw/label';
|
|
6
6
|
import { HlmCheckbox } from '@egose/shadcn-theme-ng-tw/checkbox';
|
|
7
|
-
import { HlmError, HlmHint } from '@egose/shadcn-theme-ng-tw/form-field';
|
|
7
|
+
import { HlmFormIdGenerator, HlmError, HlmHint } from '@egose/shadcn-theme-ng-tw/form-field';
|
|
8
8
|
import { EgFormField } from '@egose/shadcn-theme-ng-tw/form-field-simple';
|
|
9
9
|
import { hlm } from '@egose/shadcn-theme-ng-tw/utils';
|
|
10
10
|
|
|
11
11
|
class EgFormCheckbox {
|
|
12
|
+
formGroupDirective = inject(FormGroupDirective);
|
|
13
|
+
generatedId = inject(HlmFormIdGenerator).generate('eg-form-checkbox');
|
|
12
14
|
// Classes
|
|
13
15
|
userClass = input('', { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: 'class' });
|
|
14
16
|
_computedClass = computed(() => hlm('', this.userClass()), /* @ts-ignore */
|
|
@@ -24,7 +26,7 @@ class EgFormCheckbox {
|
|
|
24
26
|
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
25
27
|
hint = input(undefined, /* @ts-ignore */
|
|
26
28
|
...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
27
|
-
id = input(
|
|
29
|
+
id = input(undefined, /* @ts-ignore */
|
|
28
30
|
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
29
31
|
name = input(undefined, /* @ts-ignore */
|
|
30
32
|
...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
|
|
@@ -34,6 +36,20 @@ class EgFormCheckbox {
|
|
|
34
36
|
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
35
37
|
disabled = input(false, /* @ts-ignore */
|
|
36
38
|
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
39
|
+
effectiveId = computed(() => this.controlId() || this.id() || this.generatedId, /* @ts-ignore */
|
|
40
|
+
...(ngDevMode ? [{ debugName: "effectiveId" }] : /* istanbul ignore next */ []));
|
|
41
|
+
errorId = computed(() => `${this.effectiveId()}-error`, /* @ts-ignore */
|
|
42
|
+
...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
|
|
43
|
+
hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
|
|
44
|
+
...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
|
|
45
|
+
describedBy() {
|
|
46
|
+
const control = this.formGroupDirective.form.get(this.controlName());
|
|
47
|
+
return this.error() && control?.invalid && (control.dirty || control.touched)
|
|
48
|
+
? this.errorId()
|
|
49
|
+
: this.hint()
|
|
50
|
+
? this.hintId()
|
|
51
|
+
: null;
|
|
52
|
+
}
|
|
37
53
|
// Styling
|
|
38
54
|
checkboxClass = input('', /* @ts-ignore */
|
|
39
55
|
...(ngDevMode ? [{ debugName: "checkboxClass" }] : /* istanbul ignore next */ []));
|
|
@@ -48,10 +64,9 @@ class EgFormCheckbox {
|
|
|
48
64
|
...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
|
|
49
65
|
$hintClass = input('', /* @ts-ignore */
|
|
50
66
|
...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
|
|
51
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
52
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.
|
|
67
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormCheckbox, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
68
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormCheckbox, isStandalone: true, selector: "eg-form-checkbox", inputs: { userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, 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 }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, checkboxClass: { classPropertyName: "checkboxClass", publicName: "checkboxClass", isSignal: true, isRequired: false, transformFunction: null }, labelClass: { classPropertyName: "labelClass", publicName: "labelClass", 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": "_computedClass()" } }, providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }], ngImport: i0, template: `
|
|
53
69
|
@let lbl = label();
|
|
54
|
-
@let cid = controlId();
|
|
55
70
|
@let cnm = controlName();
|
|
56
71
|
@let err = error();
|
|
57
72
|
@let hnt = hint();
|
|
@@ -60,14 +75,16 @@ class EgFormCheckbox {
|
|
|
60
75
|
<eg-form-field>
|
|
61
76
|
<div class="tw:flex tw:items-center tw:gap-1">
|
|
62
77
|
<hlm-checkbox
|
|
63
|
-
[id]="
|
|
78
|
+
[id]="effectiveId()"
|
|
64
79
|
[name]="cnm || name() || null"
|
|
65
80
|
[formControlName]="cnm"
|
|
66
81
|
[class]="$checkboxClass()"
|
|
67
82
|
[checked]="checked()"
|
|
68
83
|
[required]="rqrd"
|
|
84
|
+
[wrapperDisabled]="disabled()"
|
|
85
|
+
[aria-describedby]="describedBy()"
|
|
69
86
|
/>
|
|
70
|
-
<label hlmLabel [for]="
|
|
87
|
+
<label hlmLabel [for]="effectiveId()" [class]="$labelClass()">
|
|
71
88
|
{{ lbl }}
|
|
72
89
|
@if (rqrd) {
|
|
73
90
|
<span class="tw:text-red-500">*</span>
|
|
@@ -76,20 +93,20 @@ class EgFormCheckbox {
|
|
|
76
93
|
</div>
|
|
77
94
|
|
|
78
95
|
@if (err) {
|
|
79
|
-
<hlm-error [class]="$errorClass()">
|
|
96
|
+
<hlm-error [id]="errorId()" [class]="$errorClass()">
|
|
80
97
|
{{ err }}
|
|
81
98
|
</hlm-error>
|
|
82
99
|
}
|
|
83
100
|
|
|
84
101
|
@if (hnt) {
|
|
85
|
-
<hlm-hint [class]="$hintClass()">
|
|
102
|
+
<hlm-hint [id]="hintId()" [class]="$hintClass()">
|
|
86
103
|
{{ hnt }}
|
|
87
104
|
</hlm-hint>
|
|
88
105
|
}
|
|
89
106
|
</eg-form-field>
|
|
90
|
-
`, isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: HlmCheckbox, selector: "hlm-checkbox", inputs: ["class", "id", "aria-label", "aria-labelledby", "aria-describedby", "checked", "name", "required", "disabled"], outputs: ["checkedChange", "changed"] }, { kind: "directive", type: HlmLabel, selector: "[hlmLabel]", inputs: ["class"] }, { kind: "component", type: EgFormField, selector: "eg-form-field", inputs: ["class"] }, { kind: "directive", type: HlmError, selector: "hlm-error", inputs: ["class"] }, { kind: "directive", type: HlmHint, selector: "hlm-hint", inputs: ["class"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
107
|
+
`, isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: HlmCheckbox, selector: "hlm-checkbox", inputs: ["class", "id", "aria-label", "aria-labelledby", "aria-describedby", "checked", "name", "required", "disabled", "wrapperDisabled"], outputs: ["checkedChange", "changed"] }, { kind: "directive", type: HlmLabel, selector: "[hlmLabel]", inputs: ["class"] }, { kind: "component", type: EgFormField, selector: "eg-form-field", inputs: ["class"] }, { kind: "directive", type: HlmError, selector: "hlm-error", inputs: ["class"] }, { kind: "directive", type: HlmHint, selector: "hlm-hint", inputs: ["class"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
91
108
|
}
|
|
92
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
109
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormCheckbox, decorators: [{
|
|
93
110
|
type: Component,
|
|
94
111
|
args: [{
|
|
95
112
|
selector: 'eg-form-checkbox',
|
|
@@ -102,7 +119,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
102
119
|
providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
|
|
103
120
|
template: `
|
|
104
121
|
@let lbl = label();
|
|
105
|
-
@let cid = controlId();
|
|
106
122
|
@let cnm = controlName();
|
|
107
123
|
@let err = error();
|
|
108
124
|
@let hnt = hint();
|
|
@@ -111,14 +127,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
111
127
|
<eg-form-field>
|
|
112
128
|
<div class="tw:flex tw:items-center tw:gap-1">
|
|
113
129
|
<hlm-checkbox
|
|
114
|
-
[id]="
|
|
130
|
+
[id]="effectiveId()"
|
|
115
131
|
[name]="cnm || name() || null"
|
|
116
132
|
[formControlName]="cnm"
|
|
117
133
|
[class]="$checkboxClass()"
|
|
118
134
|
[checked]="checked()"
|
|
119
135
|
[required]="rqrd"
|
|
136
|
+
[wrapperDisabled]="disabled()"
|
|
137
|
+
[aria-describedby]="describedBy()"
|
|
120
138
|
/>
|
|
121
|
-
<label hlmLabel [for]="
|
|
139
|
+
<label hlmLabel [for]="effectiveId()" [class]="$labelClass()">
|
|
122
140
|
{{ lbl }}
|
|
123
141
|
@if (rqrd) {
|
|
124
142
|
<span class="tw:text-red-500">*</span>
|
|
@@ -127,13 +145,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
127
145
|
</div>
|
|
128
146
|
|
|
129
147
|
@if (err) {
|
|
130
|
-
<hlm-error [class]="$errorClass()">
|
|
148
|
+
<hlm-error [id]="errorId()" [class]="$errorClass()">
|
|
131
149
|
{{ err }}
|
|
132
150
|
</hlm-error>
|
|
133
151
|
}
|
|
134
152
|
|
|
135
153
|
@if (hnt) {
|
|
136
|
-
<hlm-hint [class]="$hintClass()">
|
|
154
|
+
<hlm-hint [id]="hintId()" [class]="$hintClass()">
|
|
137
155
|
{{ hnt }}
|
|
138
156
|
</hlm-hint>
|
|
139
157
|
}
|
|
@@ -151,4 +169,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
151
169
|
*/
|
|
152
170
|
|
|
153
171
|
export { EgFormCheckbox };
|
|
154
|
-
|
|
172
|
+
|
|
@@ -2,6 +2,8 @@ import * as _angular_core from '@angular/core';
|
|
|
2
2
|
import { ClassValue } from 'clsx';
|
|
3
3
|
|
|
4
4
|
declare class EgFormCheckbox {
|
|
5
|
+
private readonly formGroupDirective;
|
|
6
|
+
private readonly generatedId;
|
|
5
7
|
readonly userClass: _angular_core.InputSignal<ClassValue>;
|
|
6
8
|
protected readonly _computedClass: _angular_core.Signal<string>;
|
|
7
9
|
label: _angular_core.InputSignal<string>;
|
|
@@ -9,11 +11,15 @@ declare class EgFormCheckbox {
|
|
|
9
11
|
controlName: _angular_core.InputSignal<string>;
|
|
10
12
|
error: _angular_core.InputSignal<string | undefined>;
|
|
11
13
|
hint: _angular_core.InputSignal<string | undefined>;
|
|
12
|
-
id: _angular_core.InputSignal<string>;
|
|
14
|
+
id: _angular_core.InputSignal<string | undefined>;
|
|
13
15
|
name: _angular_core.InputSignal<string | undefined>;
|
|
14
16
|
checked: _angular_core.InputSignal<boolean>;
|
|
15
17
|
required: _angular_core.InputSignal<boolean>;
|
|
16
18
|
disabled: _angular_core.InputSignal<boolean>;
|
|
19
|
+
readonly effectiveId: _angular_core.Signal<string>;
|
|
20
|
+
readonly errorId: _angular_core.Signal<string>;
|
|
21
|
+
readonly hintId: _angular_core.Signal<string>;
|
|
22
|
+
describedBy(): string | null;
|
|
17
23
|
checkboxClass: _angular_core.InputSignal<string>;
|
|
18
24
|
labelClass: _angular_core.InputSignal<string>;
|
|
19
25
|
$checkboxClass: _angular_core.Signal<string>;
|
|
@@ -1,64 +1,323 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Form Date Picker (`@egose/shadcn-theme-ng/form-date-picker`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A ready-made reactive-form date field: label + `hlm-date-picker` + validation error/hint display in one tag. Equivalent to shadcn/ui `Form` + date-picker composition.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
+
`HlmDatePicker` + `HlmDatePickerInput` from `@egose/shadcn-theme-ng/date-picker`. The inner
|
|
8
|
+
`hlm-date-picker` is bound with `[formControlName]="controlName()"`, so the parent `FormGroup`
|
|
9
|
+
owns the `Date | null` value. It must live inside a `FormGroupDirective` (`[formGroup]` parent);
|
|
10
|
+
ids come from `HlmFormIdGenerator` unless overridden.
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
> **Ships as:** `@egose/shadcn-theme-ng/form-date-picker` and `@egose/shadcn-theme-ng-tw/form-date-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
|
|
8
18
|
|
|
9
19
|
```bash
|
|
10
|
-
|
|
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
|
|
11
25
|
```
|
|
12
26
|
|
|
13
|
-
|
|
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`.
|
|
14
31
|
|
|
15
|
-
|
|
16
|
-
|
|
32
|
+
## Imports
|
|
33
|
+
|
|
34
|
+
Exported from the subpath root (`projects/form-date-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 { EgFormDatePicker } from '@egose/shadcn-theme-ng/form-date-picker';
|
|
39
|
+
// tw variant: replace with '@egose/shadcn-theme-ng-tw/form-date-picker'
|
|
17
40
|
```
|
|
18
41
|
|
|
19
|
-
|
|
42
|
+
Standalone usage:
|
|
20
43
|
|
|
21
|
-
|
|
44
|
+
```ts
|
|
45
|
+
import { Component } from '@angular/core';
|
|
46
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
47
|
+
import { EgFormDatePicker } from '@egose/shadcn-theme-ng/form-date-picker';
|
|
22
48
|
|
|
23
|
-
|
|
24
|
-
|
|
49
|
+
@Component({
|
|
50
|
+
selector: 'app-demo',
|
|
51
|
+
standalone: true,
|
|
52
|
+
imports: [ReactiveFormsModule, EgFormDatePicker],
|
|
53
|
+
template: `...`,
|
|
54
|
+
})
|
|
55
|
+
export class DemoComponent {}
|
|
25
56
|
```
|
|
26
57
|
|
|
27
|
-
|
|
58
|
+
NgModule-based consumer: add `EgFormDatePicker` (and `ReactiveFormsModule`) to the module's
|
|
59
|
+
`imports` — it is a standalone component, not a module.
|
|
60
|
+
|
|
61
|
+
`ControlValueAccessor` behavior: `eg-form-date-picker` itself is not a `ControlValueAccessor`; the
|
|
62
|
+
inner `hlm-date-picker` is (bound via `formControlName`), so `formControlName`/`formGroup` handling,
|
|
63
|
+
`Validators`, `disabled` state from the control, and `dateChange` values (`Date | null`) all flow
|
|
64
|
+
through the parent form.
|
|
28
65
|
|
|
29
|
-
|
|
66
|
+
## Anatomy / Structure
|
|
30
67
|
|
|
31
|
-
|
|
68
|
+
```html
|
|
69
|
+
<form [formGroup]="form">
|
|
70
|
+
<eg-form-date-picker
|
|
71
|
+
controlName="birthday"
|
|
72
|
+
label="Date of birth"
|
|
73
|
+
placeholder="Pick a date"
|
|
74
|
+
[required]="true"
|
|
75
|
+
hint="We use this to verify your age."
|
|
76
|
+
error="Birth date is required."
|
|
77
|
+
/>
|
|
78
|
+
</form>
|
|
79
|
+
```
|
|
32
80
|
|
|
33
|
-
|
|
81
|
+
Selector (from source): `eg-form-date-picker` (standalone component, host `tw:w-full`).
|
|
34
82
|
|
|
35
|
-
|
|
36
|
-
cd dist/form-date-picker
|
|
37
|
-
```
|
|
83
|
+
## API reference
|
|
38
84
|
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
npm publish
|
|
42
|
-
```
|
|
85
|
+
### `EgFormDatePicker` — `eg-form-date-picker`
|
|
43
86
|
|
|
44
|
-
|
|
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` | — | Declared input; **not bound** to the inner picker in the current template (surprise — see below). |
|
|
96
|
+
| `placeholder` | `string` | `'Pick a date'` | Input placeholder. |
|
|
97
|
+
| `readonly` | `boolean` | `false` | Declared input; **not bound** in the current template. |
|
|
98
|
+
| `disabled` | `boolean` | `false` | Locks interaction via picker `wrapperDisabled` (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-picker`. |
|
|
101
|
+
| `max` | `Date \| string \| null` | `null` | Maximum date forwarded to `hlm-date-picker`. |
|
|
102
|
+
| `autoCloseOnSelect` | `boolean` | `true` | Declared input; **not bound** to the inner picker in the current template (picker default `false` applies). |
|
|
103
|
+
| `class` | `ClassValue` | `''` | Declared but **not applied** to the host in the current template (host is fixed `tw:w-full`). |
|
|
104
|
+
| `labelClass` | `string` | `''` | Extra label classes (base `tw:mb-1`). |
|
|
105
|
+
| `pickerClass` | `string` | `''` | Extra picker classes (base `tw:mb-1`). |
|
|
106
|
+
| `errorClass` | `string` | `''` | Extra error classes (base `tw:mt-0`). |
|
|
107
|
+
| `hintClass` | `string` | `''` | Extra hint classes (base `tw:mt-0`). |
|
|
45
108
|
|
|
46
|
-
|
|
109
|
+
| Member | Description |
|
|
110
|
+
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
111
|
+
| `effectiveId` | `controlId() \|\| id() \|\| generated` — wired to input `inputId` and label `for`. |
|
|
112
|
+
| `errorId` / `hintId` | `effectiveId + '-error' / '-hint'`. |
|
|
113
|
+
| `describedBy()` | `errorId` when `error()` is set and control is invalid + dirty/touched, else `hintId` when `hint()` is set, else `null` — wired to input `ariaDescribedby`. |
|
|
47
114
|
|
|
48
|
-
|
|
49
|
-
|
|
115
|
+
Requires a `[formGroup]` ancestor (injects `FormGroupDirective`, provides `ControlContainer → FormGroupDirective`).
|
|
116
|
+
|
|
117
|
+
## Examples
|
|
118
|
+
|
|
119
|
+
### 1. Basic required date field
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
import { Component, inject } from '@angular/core';
|
|
123
|
+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
124
|
+
import { EgFormDatePicker } from '@egose/shadcn-theme-ng/form-date-picker';
|
|
125
|
+
|
|
126
|
+
@Component({
|
|
127
|
+
selector: 'app-birthday',
|
|
128
|
+
standalone: true,
|
|
129
|
+
imports: [ReactiveFormsModule, EgFormDatePicker],
|
|
130
|
+
template: `
|
|
131
|
+
<form [formGroup]="form" (ngSubmit)="submit()">
|
|
132
|
+
<eg-form-date-picker
|
|
133
|
+
controlName="birthday"
|
|
134
|
+
label="Date of birth"
|
|
135
|
+
[required]="true"
|
|
136
|
+
error="Birth date is required."
|
|
137
|
+
/>
|
|
138
|
+
<button type="submit" [disabled]="form.invalid">Continue</button>
|
|
139
|
+
</form>
|
|
140
|
+
`,
|
|
141
|
+
})
|
|
142
|
+
export class BirthdayComponent {
|
|
143
|
+
private readonly fb = inject(FormBuilder);
|
|
144
|
+
readonly form = this.fb.group({ birthday: [null as Date | null, Validators.required] });
|
|
145
|
+
submit() {
|
|
146
|
+
console.log(this.form.value.birthday);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
50
149
|
```
|
|
51
150
|
|
|
52
|
-
|
|
151
|
+
### 2. Hint + min/max bounds
|
|
53
152
|
|
|
54
|
-
|
|
153
|
+
```ts
|
|
154
|
+
import { Component, inject } from '@angular/core';
|
|
155
|
+
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
|
156
|
+
import { EgFormDatePicker } from '@egose/shadcn-theme-ng/form-date-picker';
|
|
55
157
|
|
|
56
|
-
|
|
57
|
-
|
|
158
|
+
@Component({
|
|
159
|
+
selector: 'app-bounds',
|
|
160
|
+
standalone: true,
|
|
161
|
+
imports: [ReactiveFormsModule, EgFormDatePicker],
|
|
162
|
+
template: `
|
|
163
|
+
<form [formGroup]="form">
|
|
164
|
+
<eg-form-date-picker
|
|
165
|
+
controlName="departure"
|
|
166
|
+
label="Departure"
|
|
167
|
+
placeholder="Select departure"
|
|
168
|
+
[min]="today"
|
|
169
|
+
[max]="nextYear"
|
|
170
|
+
hint="Bookings open up to one year ahead."
|
|
171
|
+
error="Pick a valid departure date."
|
|
172
|
+
/>
|
|
173
|
+
</form>
|
|
174
|
+
`,
|
|
175
|
+
})
|
|
176
|
+
export class BoundsComponent {
|
|
177
|
+
private readonly fb = inject(FormBuilder);
|
|
178
|
+
readonly form = this.fb.group({ departure: [null as Date | null] });
|
|
179
|
+
readonly today = new Date();
|
|
180
|
+
readonly nextYear = new Date(new Date().getFullYear() + 1, 11, 31);
|
|
181
|
+
}
|
|
58
182
|
```
|
|
59
183
|
|
|
60
|
-
|
|
184
|
+
### 3. Booking range (two fields, cross-validation)
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
import { Component, inject } from '@angular/core';
|
|
188
|
+
import { FormBuilder, ReactiveFormsModule, Validators, AbstractControl } from '@angular/forms';
|
|
189
|
+
import { EgFormDatePicker } from '@egose/shadcn-theme-ng/form-date-picker';
|
|
190
|
+
|
|
191
|
+
@Component({
|
|
192
|
+
selector: 'app-booking',
|
|
193
|
+
standalone: true,
|
|
194
|
+
imports: [ReactiveFormsModule, EgFormDatePicker],
|
|
195
|
+
template: `
|
|
196
|
+
<form [formGroup]="form" class="tw:grid tw:gap-4">
|
|
197
|
+
<eg-form-date-picker controlName="checkIn" label="Check-in" [required]="true" error="Check-in is required." />
|
|
198
|
+
<eg-form-date-picker
|
|
199
|
+
controlName="checkOut"
|
|
200
|
+
label="Check-out"
|
|
201
|
+
[required]="true"
|
|
202
|
+
[min]="form.value.checkIn"
|
|
203
|
+
error="Check-out must be after check-in."
|
|
204
|
+
/>
|
|
205
|
+
</form>
|
|
206
|
+
`,
|
|
207
|
+
})
|
|
208
|
+
export class BookingComponent {
|
|
209
|
+
private readonly fb = inject(FormBuilder);
|
|
210
|
+
readonly form = this.fb.group(
|
|
211
|
+
{ checkIn: [null as Date | null, Validators.required], checkOut: [null as Date | null, Validators.required] },
|
|
212
|
+
{
|
|
213
|
+
validators: (g: AbstractControl) =>
|
|
214
|
+
(g.get('checkOut')?.value ?? 0) >= (g.get('checkIn')?.value ?? 0) ? null : { order: true },
|
|
215
|
+
},
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### 4. Disabled / read-only preview
|
|
221
|
+
|
|
222
|
+
```ts
|
|
223
|
+
import { Component, inject } from '@angular/core';
|
|
224
|
+
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
|
225
|
+
import { EgFormDatePicker } from '@egose/shadcn-theme-ng/form-date-picker';
|
|
226
|
+
|
|
227
|
+
@Component({
|
|
228
|
+
selector: 'app-locked-date',
|
|
229
|
+
standalone: true,
|
|
230
|
+
imports: [ReactiveFormsModule, EgFormDatePicker],
|
|
231
|
+
template: `
|
|
232
|
+
<form [formGroup]="form">
|
|
233
|
+
<eg-form-date-picker
|
|
234
|
+
controlName="founded"
|
|
235
|
+
label="Founded"
|
|
236
|
+
[disabled]="true"
|
|
237
|
+
hint="Managed by workspace admins."
|
|
238
|
+
/>
|
|
239
|
+
</form>
|
|
240
|
+
`,
|
|
241
|
+
})
|
|
242
|
+
export class LockedDateComponent {
|
|
243
|
+
private readonly fb = inject(FormBuilder);
|
|
244
|
+
readonly form = this.fb.group({ founded: [new Date(2020, 0, 15)] });
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### 5. Submit-gated validation + value preview
|
|
249
|
+
|
|
250
|
+
```ts
|
|
251
|
+
import { Component, inject } from '@angular/core';
|
|
252
|
+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
253
|
+
import { EgFormDatePicker } from '@egose/shadcn-theme-ng/form-date-picker';
|
|
254
|
+
|
|
255
|
+
@Component({
|
|
256
|
+
selector: 'app-submit-date',
|
|
257
|
+
standalone: true,
|
|
258
|
+
imports: [ReactiveFormsModule, EgFormDatePicker],
|
|
259
|
+
template: `
|
|
260
|
+
<form [formGroup]="form" (ngSubmit)="submit()">
|
|
261
|
+
<eg-form-date-picker controlName="start" label="Start date" [required]="true" error="Start date is required." />
|
|
262
|
+
<button type="submit">Save</button>
|
|
263
|
+
</form>
|
|
264
|
+
<p class="tw:text-sm">ISO: {{ form.value.start?.toISOString() ?? '—' }}</p>
|
|
265
|
+
`,
|
|
266
|
+
})
|
|
267
|
+
export class SubmitDateComponent {
|
|
268
|
+
private readonly fb = inject(FormBuilder);
|
|
269
|
+
readonly form = this.fb.group({ start: [null as Date | null, Validators.required] });
|
|
270
|
+
submit() {
|
|
271
|
+
this.form.markAllAsTouched();
|
|
272
|
+
if (this.form.valid) console.log('saving', this.form.value.start);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### 6. Custom label/picker styling
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
import { Component, inject } from '@angular/core';
|
|
281
|
+
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
|
282
|
+
import { EgFormDatePicker } from '@egose/shadcn-theme-ng/form-date-picker';
|
|
283
|
+
|
|
284
|
+
@Component({
|
|
285
|
+
selector: 'app-styled-date',
|
|
286
|
+
standalone: true,
|
|
287
|
+
imports: [ReactiveFormsModule, EgFormDatePicker],
|
|
288
|
+
template: `
|
|
289
|
+
<form [formGroup]="form">
|
|
290
|
+
<eg-form-date-picker
|
|
291
|
+
controlName="event"
|
|
292
|
+
controlId="event-date"
|
|
293
|
+
label="Event date"
|
|
294
|
+
labelClass="tw:font-semibold"
|
|
295
|
+
pickerClass="tw:max-w-xs"
|
|
296
|
+
hint="Doors open one hour earlier."
|
|
297
|
+
/>
|
|
298
|
+
</form>
|
|
299
|
+
`,
|
|
300
|
+
})
|
|
301
|
+
export class StyledDateComponent {
|
|
302
|
+
private readonly fb = inject(FormBuilder);
|
|
303
|
+
readonly form = this.fb.group({ event: [null as Date | null] });
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Accessibility notes
|
|
308
|
+
|
|
309
|
+
- 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`.
|
|
310
|
+
- Closing the picker popover marks the control touched, so errors appear after interaction even without typing.
|
|
311
|
+
- The required `*` is visual; pair with `Validators.required` so assistive tech and validation agree.
|
|
312
|
+
- Arrow-down opens the calendar from the input; the calendar/popup primitives handle focus trap, escape, and outside-click dismissal.
|
|
313
|
+
|
|
314
|
+
## Theming / CSS variables
|
|
315
|
+
|
|
316
|
+
No component-specific CSS variables. Style via `labelClass` / `pickerClass` / `errorClass` / `hintClass` and global tokens. The host is fixed `tw:w-full`; constrain width with a wrapping container.
|
|
61
317
|
|
|
62
|
-
##
|
|
318
|
+
## Related subpaths
|
|
63
319
|
|
|
64
|
-
|
|
320
|
+
- `@egose/shadcn-theme-ng/date-picker` — raw `hlm-date-picker` + input/trigger/config tokens for custom layouts.
|
|
321
|
+
- `@egose/shadcn-theme-ng/form-field` — `hlm-form-field` / `hlm-error` / `hlm-hint` used internally.
|
|
322
|
+
- `@egose/shadcn-theme-ng/calendar` — calendars rendered inside the picker popover.
|
|
323
|
+
- `@egose/shadcn-theme-ng/form-field-simple` — alternative minimal wrapper when you compose pickers by hand.
|