@egose/shadcn-theme-ng-tw 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.
Files changed (97) hide show
  1. package/README.md +1 -1
  2. package/alert/fesm2022/alert.mjs +1 -1
  3. package/autocomplete/fesm2022/autocomplete.mjs +1 -1
  4. package/button/fesm2022/button.mjs +3 -3
  5. package/checkbox/fesm2022/checkbox.mjs +6 -7
  6. package/checkbox/types/checkbox.d.ts +1 -1
  7. package/combobox/fesm2022/combobox.mjs +1 -1
  8. package/date-picker/README.md +15 -11
  9. package/date-picker/fesm2022/date-picker.mjs +148 -30
  10. package/date-picker/types/date-picker.d.ts +102 -9
  11. package/form-autocomplete/README.md +178 -0
  12. package/form-autocomplete/fesm2022/form-autocomplete.mjs +243 -0
  13. package/form-autocomplete/package.json +24 -0
  14. package/form-autocomplete/types/form-autocomplete.d.ts +81 -0
  15. package/form-checkbox/README.md +29 -18
  16. package/form-checkbox/fesm2022/form-checkbox.mjs +62 -22
  17. package/form-checkbox/types/form-checkbox.d.ts +43 -4
  18. package/form-combobox/README.md +203 -0
  19. package/form-combobox/fesm2022/form-combobox.mjs +305 -0
  20. package/form-combobox/package.json +24 -0
  21. package/form-combobox/types/form-combobox.d.ts +93 -0
  22. package/form-date-picker/README.md +49 -22
  23. package/form-date-picker/fesm2022/form-date-picker.mjs +100 -29
  24. package/form-date-picker/types/form-date-picker.d.ts +37 -1
  25. package/form-date-picker-multi/README.md +192 -0
  26. package/form-date-picker-multi/fesm2022/form-date-picker-multi.mjs +266 -0
  27. package/form-date-picker-multi/package.json +24 -0
  28. package/form-date-picker-multi/types/form-date-picker-multi.d.ts +78 -0
  29. package/form-date-range-picker/README.md +254 -0
  30. package/form-date-range-picker/fesm2022/form-date-range-picker.mjs +263 -0
  31. package/form-date-range-picker/package.json +24 -0
  32. package/form-date-range-picker/types/form-date-range-picker.d.ts +75 -0
  33. package/form-field/README.md +9 -0
  34. package/form-field/fesm2022/form-field.mjs +80 -5
  35. package/form-field/types/form-field.d.ts +50 -2
  36. package/form-field-simple/fesm2022/form-field-simple.mjs +15 -1
  37. package/form-field-simple/types/form-field-simple.d.ts +9 -2
  38. package/form-input-otp/README.md +195 -0
  39. package/form-input-otp/fesm2022/form-input-otp.mjs +226 -0
  40. package/form-input-otp/package.json +24 -0
  41. package/form-input-otp/types/form-input-otp.d.ts +78 -0
  42. package/form-month-year-picker/README.md +189 -0
  43. package/form-month-year-picker/fesm2022/form-month-year-picker.mjs +256 -0
  44. package/form-month-year-picker/package.json +24 -0
  45. package/form-month-year-picker/types/form-month-year-picker.d.ts +73 -0
  46. package/form-native-select/README.md +206 -0
  47. package/form-native-select/fesm2022/form-native-select.mjs +226 -0
  48. package/form-native-select/package.json +24 -0
  49. package/form-native-select/types/form-native-select.d.ts +77 -0
  50. package/form-phone-input/README.md +189 -0
  51. package/form-phone-input/fesm2022/form-phone-input.mjs +230 -0
  52. package/form-phone-input/package.json +24 -0
  53. package/form-phone-input/types/form-phone-input.d.ts +78 -0
  54. package/form-radio-group/README.md +199 -0
  55. package/form-radio-group/fesm2022/form-radio-group.mjs +238 -0
  56. package/form-radio-group/package.json +24 -0
  57. package/form-radio-group/types/form-radio-group.d.ts +83 -0
  58. package/form-searchable-multiselect/README.md +28 -17
  59. package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs +60 -24
  60. package/form-searchable-multiselect/types/form-searchable-multiselect.d.ts +39 -2
  61. package/form-select/README.md +30 -19
  62. package/form-select/fesm2022/form-select.mjs +65 -29
  63. package/form-select/types/form-select.d.ts +39 -2
  64. package/form-slider/README.md +183 -0
  65. package/form-slider/fesm2022/form-slider.mjs +218 -0
  66. package/form-slider/package.json +24 -0
  67. package/form-slider/types/form-slider.d.ts +80 -0
  68. package/form-switch/README.md +174 -0
  69. package/form-switch/fesm2022/form-switch.mjs +205 -0
  70. package/form-switch/package.json +24 -0
  71. package/form-switch/types/form-switch.d.ts +70 -0
  72. package/form-text-input/README.md +37 -26
  73. package/form-text-input/fesm2022/form-text-input.mjs +60 -24
  74. package/form-text-input/types/form-text-input.d.ts +39 -2
  75. package/form-textarea/README.md +33 -22
  76. package/form-textarea/fesm2022/form-textarea.mjs +60 -24
  77. package/form-textarea/types/form-textarea.d.ts +39 -2
  78. package/form-toggle/README.md +187 -0
  79. package/form-toggle/fesm2022/form-toggle.mjs +275 -0
  80. package/form-toggle/package.json +24 -0
  81. package/form-toggle/types/form-toggle.d.ts +100 -0
  82. package/form-toggle-group/README.md +177 -0
  83. package/form-toggle-group/fesm2022/form-toggle-group.mjs +243 -0
  84. package/form-toggle-group/package.json +24 -0
  85. package/form-toggle-group/types/form-toggle-group.d.ts +85 -0
  86. package/input-group/fesm2022/input-group.mjs +20 -10
  87. package/input-group/types/input-group.d.ts +4 -1
  88. package/native-select/fesm2022/native-select.mjs +18 -6
  89. package/native-select/types/native-select.d.ts +7 -2
  90. package/package.json +57 -1
  91. package/phone-input/README.md +114 -0
  92. package/phone-input/fesm2022/phone-input.mjs +191 -0
  93. package/phone-input/package.json +24 -0
  94. package/phone-input/types/phone-input.d.ts +67 -0
  95. package/sheet/fesm2022/sheet.mjs +1 -1
  96. package/switch/fesm2022/switch.mjs +7 -5
  97. package/switch/types/switch.d.ts +2 -1
@@ -0,0 +1,226 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, inject, input, computed, Component } from '@angular/core';
3
+ import * as i1 from '@angular/forms';
4
+ import { FormGroupDirective, ReactiveFormsModule, ControlContainer } from '@angular/forms';
5
+ import { injectEgFormErrorMessages, HlmFormIdGenerator, resolveEgFormError, HlmFormField, HlmError, HlmHint } from '@egose/shadcn-theme-ng-tw/form-field';
6
+ import { HlmLabel } from '@egose/shadcn-theme-ng-tw/label';
7
+ import { HlmNativeSelect } from '@egose/shadcn-theme-ng-tw/native-select';
8
+ import { hlm } from '@egose/shadcn-theme-ng-tw/utils';
9
+
10
+ const EgFormNativeSelectConfigToken = new InjectionToken('EgFormNativeSelectConfig');
11
+ function provideEgFormNativeSelectConfig(config) {
12
+ return { provide: EgFormNativeSelectConfigToken, useValue: { ...config } };
13
+ }
14
+ function injectEgFormNativeSelectConfig() {
15
+ return inject(EgFormNativeSelectConfigToken, { optional: true }) ?? {};
16
+ }
17
+
18
+ class EgFormNativeSelect {
19
+ formGroupDirective = inject(FormGroupDirective);
20
+ _errorMessages = injectEgFormErrorMessages();
21
+ generatedId = inject(HlmFormIdGenerator).generate('eg-form-native-select');
22
+ _config = injectEgFormNativeSelectConfig();
23
+ label = input(undefined, /* @ts-ignore */
24
+ ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
25
+ controlId = input(undefined, /* @ts-ignore */
26
+ ...(ngDevMode ? [{ debugName: "controlId" }] : /* istanbul ignore next */ []));
27
+ controlName = input('', /* @ts-ignore */
28
+ ...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
29
+ error = input(undefined, /* @ts-ignore */
30
+ ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
31
+ /**
32
+ * Auto-resolve the displayed message from the control's `ValidationErrors`
33
+ * when `error()` is unset. Explicit `error()` always wins. Set to `false`
34
+ * for manual-only messages.
35
+ */
36
+ autoError = input(true, /* @ts-ignore */
37
+ ...(ngDevMode ? [{ debugName: "autoError" }] : /* istanbul ignore next */ []));
38
+ hint = input(undefined, /* @ts-ignore */
39
+ ...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
40
+ id = input(undefined, /* @ts-ignore */
41
+ ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
42
+ name = input(undefined, /* @ts-ignore */
43
+ ...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
44
+ disabled = input(false, /* @ts-ignore */
45
+ ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
46
+ required = input(false, /* @ts-ignore */
47
+ ...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
48
+ options = input([], /* @ts-ignore */
49
+ ...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
50
+ effectiveId = computed(() => this.controlId() || this.id() || this.generatedId, /* @ts-ignore */
51
+ ...(ngDevMode ? [{ debugName: "effectiveId" }] : /* istanbul ignore next */ []));
52
+ errorId = computed(() => `${this.effectiveId()}-error`, /* @ts-ignore */
53
+ ...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
54
+ hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
55
+ ...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
56
+ /**
57
+ * Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
58
+ * auto-resolved from the control's `ValidationErrors`. Plain method (not a
59
+ * computed): `ValidationErrors` is not a signal, so the control must be read
60
+ * fresh on every change-detection pass.
61
+ */
62
+ resolvedError() {
63
+ const explicit = this.error();
64
+ if (explicit)
65
+ return explicit;
66
+ if (!this.autoError())
67
+ return undefined;
68
+ const control = this.formGroupDirective.form.get(this.controlName());
69
+ return resolveEgFormError(control?.errors ?? null, this.label(), this._errorMessages);
70
+ }
71
+ /**
72
+ * Whether the error is surfaced: message present + control invalid +
73
+ * touched/dirty/submitted. Gates the visual `<hlm-error>` (and
74
+ * `describedBy()`, where present) so sighted and screen-reader output agree.
75
+ */
76
+ showError() {
77
+ const control = this.formGroupDirective.form.get(this.controlName());
78
+ return (!!this.resolvedError() &&
79
+ !!control?.invalid &&
80
+ (control.dirty || control.touched || this.formGroupDirective.submitted));
81
+ }
82
+ describedBy() {
83
+ return this.showError() ? this.errorId() : this.hint() ? this.hintId() : null;
84
+ }
85
+ // Styling
86
+ userClass = input('', { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: 'class' });
87
+ labelClass = input('', /* @ts-ignore */
88
+ ...(ngDevMode ? [{ debugName: "labelClass" }] : /* istanbul ignore next */ []));
89
+ selectClass = input('', /* @ts-ignore */
90
+ ...(ngDevMode ? [{ debugName: "selectClass" }] : /* istanbul ignore next */ []));
91
+ errorClass = input('', /* @ts-ignore */
92
+ ...(ngDevMode ? [{ debugName: "errorClass" }] : /* istanbul ignore next */ []));
93
+ hintClass = input('', /* @ts-ignore */
94
+ ...(ngDevMode ? [{ debugName: "hintClass" }] : /* istanbul ignore next */ []));
95
+ // Computed classes (library base < global config < per-instance)
96
+ $userClass = computed(() => hlm('tw:w-full', this.userClass()), /* @ts-ignore */
97
+ ...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
98
+ $labelClass = computed(() => hlm('tw:mb-1 tw:gap-0', this._config.labelClass, this.labelClass()), /* @ts-ignore */
99
+ ...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
100
+ $selectClass = computed(() => hlm('tw:w-full', this._config.selectClass, this.selectClass()), /* @ts-ignore */
101
+ ...(ngDevMode ? [{ debugName: "$selectClass" }] : /* istanbul ignore next */ []));
102
+ $errorClass = computed(() => hlm('tw:mt-0', this._config.errorClass, this.errorClass()), /* @ts-ignore */
103
+ ...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
104
+ $hintClass = computed(() => hlm('tw:mt-0', this._config.hintClass, this.hintClass()), /* @ts-ignore */
105
+ ...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
106
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormNativeSelect, deps: [], target: i0.ɵɵFactoryTarget.Component });
107
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormNativeSelect, isStandalone: true, selector: "eg-form-native-select", 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 }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", 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 }, selectClass: { classPropertyName: "selectClass", publicName: "selectClass", 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: `
108
+ @let lbl = label();
109
+ @let cnm = controlName();
110
+ @let hnt = hint();
111
+ @let rqrd = required();
112
+
113
+ <hlm-form-field>
114
+ @if (lbl) {
115
+ <label hlmLabel [for]="effectiveId()" [class]="$labelClass()"
116
+ >{{ lbl }}
117
+ @if (rqrd) {
118
+ <span class="tw:text-red-500">*</span>
119
+ }
120
+ </label>
121
+ }
122
+
123
+ <hlm-native-select
124
+ [selectId]="effectiveId()"
125
+ [name]="cnm || name()"
126
+ [ariaDescribedby]="describedBy()"
127
+ [disabled]="disabled()"
128
+ [formControlName]="cnm"
129
+ [selectClass]="$selectClass()"
130
+ >
131
+ @for (option of options(); track option.value) {
132
+ <option
133
+ class="tw:bg-[Canvas] tw:text-[CanvasText]"
134
+ [value]="option.value"
135
+ [disabled]="option.disabled ?? false"
136
+ >
137
+ {{ option.label }}
138
+ </option>
139
+ }
140
+ </hlm-native-select>
141
+
142
+ @if (showError()) {
143
+ <hlm-error [id]="errorId()" [class]="$errorClass()">
144
+ {{ resolvedError() }}
145
+ </hlm-error>
146
+ }
147
+
148
+ @if (hnt) {
149
+ <hlm-hint [id]="hintId()" [class]="$hintClass()">
150
+ {{ hnt }}
151
+ </hlm-hint>
152
+ }
153
+ </hlm-form-field>
154
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { 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: HlmNativeSelect, selector: "hlm-native-select", inputs: ["selectId", "name", "ariaDescribedby", "selectClass", "selectIconClass", "size", "disabled", "forceInvalid", "aria-invalid", "value"], outputs: ["valueChange"] }] });
155
+ }
156
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormNativeSelect, decorators: [{
157
+ type: Component,
158
+ args: [{
159
+ selector: 'eg-form-native-select',
160
+ standalone: true,
161
+ host: {
162
+ '[class]': '$userClass()',
163
+ },
164
+ imports: [ReactiveFormsModule, HlmFormField, HlmError, HlmHint, HlmLabel, HlmNativeSelect],
165
+ providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
166
+ template: `
167
+ @let lbl = label();
168
+ @let cnm = controlName();
169
+ @let hnt = hint();
170
+ @let rqrd = required();
171
+
172
+ <hlm-form-field>
173
+ @if (lbl) {
174
+ <label hlmLabel [for]="effectiveId()" [class]="$labelClass()"
175
+ >{{ lbl }}
176
+ @if (rqrd) {
177
+ <span class="tw:text-red-500">*</span>
178
+ }
179
+ </label>
180
+ }
181
+
182
+ <hlm-native-select
183
+ [selectId]="effectiveId()"
184
+ [name]="cnm || name()"
185
+ [ariaDescribedby]="describedBy()"
186
+ [disabled]="disabled()"
187
+ [formControlName]="cnm"
188
+ [selectClass]="$selectClass()"
189
+ >
190
+ @for (option of options(); track option.value) {
191
+ <option
192
+ class="tw:bg-[Canvas] tw:text-[CanvasText]"
193
+ [value]="option.value"
194
+ [disabled]="option.disabled ?? false"
195
+ >
196
+ {{ option.label }}
197
+ </option>
198
+ }
199
+ </hlm-native-select>
200
+
201
+ @if (showError()) {
202
+ <hlm-error [id]="errorId()" [class]="$errorClass()">
203
+ {{ resolvedError() }}
204
+ </hlm-error>
205
+ }
206
+
207
+ @if (hnt) {
208
+ <hlm-hint [id]="hintId()" [class]="$hintClass()">
209
+ {{ hnt }}
210
+ </hlm-hint>
211
+ }
212
+ </hlm-form-field>
213
+ `,
214
+ }]
215
+ }], 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 }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], selectClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
216
+
217
+ /*
218
+ * Public API Surface of form-native-select
219
+ */
220
+
221
+ /**
222
+ * Generated bundle index. Do not edit.
223
+ */
224
+
225
+ export { EgFormNativeSelect, injectEgFormNativeSelectConfig, provideEgFormNativeSelectConfig };
226
+
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "form-native-select",
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-native-select.mjs",
13
+ "typings": "types/form-native-select.d.ts",
14
+ "exports": {
15
+ "./package.json": {
16
+ "default": "./package.json"
17
+ },
18
+ ".": {
19
+ "types": "./types/form-native-select.d.ts",
20
+ "default": "./fesm2022/form-native-select.mjs"
21
+ }
22
+ },
23
+ "type": "module"
24
+ }
@@ -0,0 +1,77 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { ValueProvider } from '@angular/core';
3
+ import { ClassValue } from 'clsx';
4
+
5
+ interface NativeSelectOption {
6
+ value: string;
7
+ label: string;
8
+ disabled?: boolean;
9
+ }
10
+ declare class EgFormNativeSelect {
11
+ private readonly formGroupDirective;
12
+ private readonly _errorMessages;
13
+ private readonly generatedId;
14
+ private readonly _config;
15
+ label: _angular_core.InputSignal<string | undefined>;
16
+ controlId: _angular_core.InputSignal<string | undefined>;
17
+ controlName: _angular_core.InputSignal<string>;
18
+ error: _angular_core.InputSignal<string | undefined>;
19
+ /**
20
+ * Auto-resolve the displayed message from the control's `ValidationErrors`
21
+ * when `error()` is unset. Explicit `error()` always wins. Set to `false`
22
+ * for manual-only messages.
23
+ */
24
+ autoError: _angular_core.InputSignal<boolean>;
25
+ hint: _angular_core.InputSignal<string | undefined>;
26
+ id: _angular_core.InputSignal<string | undefined>;
27
+ name: _angular_core.InputSignal<string | undefined>;
28
+ disabled: _angular_core.InputSignal<boolean>;
29
+ required: _angular_core.InputSignal<boolean>;
30
+ options: _angular_core.InputSignal<NativeSelectOption[]>;
31
+ readonly effectiveId: _angular_core.Signal<string>;
32
+ readonly errorId: _angular_core.Signal<string>;
33
+ readonly hintId: _angular_core.Signal<string>;
34
+ /**
35
+ * Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
36
+ * auto-resolved from the control's `ValidationErrors`. Plain method (not a
37
+ * computed): `ValidationErrors` is not a signal, so the control must be read
38
+ * fresh on every change-detection pass.
39
+ */
40
+ protected resolvedError(): string | undefined;
41
+ /**
42
+ * Whether the error is surfaced: message present + control invalid +
43
+ * touched/dirty/submitted. Gates the visual `<hlm-error>` (and
44
+ * `describedBy()`, where present) so sighted and screen-reader output agree.
45
+ */
46
+ protected showError(): boolean;
47
+ describedBy(): string | null;
48
+ userClass: _angular_core.InputSignal<ClassValue>;
49
+ labelClass: _angular_core.InputSignal<string>;
50
+ selectClass: _angular_core.InputSignal<string>;
51
+ errorClass: _angular_core.InputSignal<string>;
52
+ hintClass: _angular_core.InputSignal<string>;
53
+ $userClass: _angular_core.Signal<string>;
54
+ $labelClass: _angular_core.Signal<string>;
55
+ $selectClass: _angular_core.Signal<string>;
56
+ $errorClass: _angular_core.Signal<string>;
57
+ $hintClass: _angular_core.Signal<string>;
58
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormNativeSelect, never>;
59
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormNativeSelect, "eg-form-native-select", 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; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "selectClass": { "alias": "selectClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
60
+ }
61
+
62
+ interface EgFormNativeSelectConfig {
63
+ /**
64
+ * Global class defaults for `eg-form-native-select` styling slots.
65
+ * Each is merged under the matching per-instance `*Class` input
66
+ * (library base < global config < per-instance).
67
+ */
68
+ labelClass?: string;
69
+ selectClass?: string;
70
+ errorClass?: string;
71
+ hintClass?: string;
72
+ }
73
+ declare function provideEgFormNativeSelectConfig(config: Partial<EgFormNativeSelectConfig>): ValueProvider;
74
+ declare function injectEgFormNativeSelectConfig(): EgFormNativeSelectConfig;
75
+
76
+ export { EgFormNativeSelect, injectEgFormNativeSelectConfig, provideEgFormNativeSelectConfig };
77
+ export type { EgFormNativeSelectConfig };
@@ -0,0 +1,189 @@
1
+ # Form Phone Input (`@egose/shadcn-theme-ng/form-phone-input`)
2
+
3
+ A ready-made reactive-form phone field: label + `hlm-phone-input` + validation error/hint display in one tag. The model holds raw digits; the visible text is masked.
4
+
5
+ The Angular implementation is a standalone wrapper: it renders `HlmFormField` / `HlmError` / `HlmHint` from `@egose/shadcn-theme-ng/form-field`, `HlmLabel`, and `HlmPhoneInput` from `@egose/shadcn-theme-ng/phone-input`. The inner input is bound with `[formControlName]="controlName()"`, so the parent `FormGroup` owns the digit string. It must live inside a `FormGroupDirective` (`[formGroup]` parent); ids come from `HlmFormIdGenerator` unless overridden.
6
+
7
+ > **Ships as:** `@egose/shadcn-theme-ng/form-phone-input` and `@egose/shadcn-theme-ng-tw/form-phone-input`
8
+ > (the `tw:`-prefixed Tailwind variant). Both expose the identical TypeScript surface; only the
9
+ > emitted Tailwind class strings differ. See the [package README](../../README.md) for install
10
+ > steps, peer dependencies, and Tailwind setup. Do not publish this project directory independently.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ # Plain Tailwind (no prefix)
16
+ npm install @egose/shadcn-theme-ng
17
+
18
+ # tw:-prefixed Tailwind variant
19
+ npm install @egose/shadcn-theme-ng-tw
20
+ ```
21
+
22
+ Peer dependencies (Angular, `@spartan-ng/brain`, `rxjs`, …) are documented in the
23
+ [package README](../../README.md#peer-dependencies). This subpath additionally relies at runtime on
24
+ `@egose/shadcn-theme-ng/phone-input`, `@egose/shadcn-theme-ng/form-field`, and
25
+ `@egose/shadcn-theme-ng/label`.
26
+
27
+ ## Imports
28
+
29
+ Exported from the subpath root (`projects/form-phone-input/src/public-api.ts`):
30
+
31
+ ```ts
32
+ import { EgFormPhoneInput, provideEgFormPhoneInputConfig } from '@egose/shadcn-theme-ng/form-phone-input';
33
+ // tw variant: replace with '@egose/shadcn-theme-ng-tw/form-phone-input'
34
+ ```
35
+
36
+ Standalone usage:
37
+
38
+ ```ts
39
+ import { Component } from '@angular/core';
40
+ import { ReactiveFormsModule } from '@angular/forms';
41
+ import { EgFormPhoneInput } from '@egose/shadcn-theme-ng/form-phone-input';
42
+
43
+ @Component({
44
+ selector: 'app-demo',
45
+ standalone: true,
46
+ imports: [ReactiveFormsModule, EgFormPhoneInput],
47
+ template: `...`,
48
+ })
49
+ export class DemoComponent {}
50
+ ```
51
+
52
+ NgModule-based consumer: add `EgFormPhoneInput` (and `ReactiveFormsModule`) to the module's
53
+ `imports` — it is a standalone component, not a module.
54
+
55
+ `ControlValueAccessor` behavior: `eg-form-phone-input` itself is not a `ControlValueAccessor`; the
56
+ inner `hlm-phone-input` is (bound via `formControlName`), so `formControlName`/`formGroup` handling,
57
+ `Validators`, and `disabled` state from the control all flow through the parent form. Validate
58
+ against digit length (`Validators.minLength(10)`) since the model holds raw digits.
59
+
60
+ ## Anatomy / Structure
61
+
62
+ ```html
63
+ <form [formGroup]="form">
64
+ <eg-form-phone-input controlName="phone" label="Phone" [required]="true" error="Enter a 10-digit number." />
65
+ </form>
66
+ ```
67
+
68
+ Selector (from source): `eg-form-phone-input` (standalone component, host `tw:w-full`).
69
+
70
+ ## API reference
71
+
72
+ ### `EgFormPhoneInput` — `eg-form-phone-input`
73
+
74
+ | Input | Type | Default | Description |
75
+ | ------------------- | ---------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
76
+ | `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.** |
77
+ | `label` | `string \| undefined` | — | Label text (hidden when omitted). |
78
+ | `error` | `string \| undefined` | — | Error text shown when invalid. |
79
+ | `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`. |
80
+ | `hint` | `string \| undefined` | — | Hint text shown otherwise. |
81
+ | `controlId` | `string \| undefined` | — | Explicit id (first priority for `effectiveId`). |
82
+ | `id` | `string \| undefined` | — | Fallback id (second priority). |
83
+ | `name` | `string \| undefined` | — | Native `name` forwarded to the inner input (`controlName` wins). |
84
+ | `placeholder` | `string` | `'(555) 123-4567'` | Input placeholder. |
85
+ | `autocomplete` | `string` | `'tel'` | Native autocomplete token. |
86
+ | `readonly` | `boolean` | `false` | Native `readonly` forwarded to the inner input. |
87
+ | `disabled` | `boolean` | `false` | Locks interaction (form control stays enabled). |
88
+ | `required` | `boolean` | `false` | Shows a red `*` next to the label. |
89
+ | `maxDigits` | `number` | `10` | Maximum digit count kept in the model. |
90
+ | `modelFormat` | `'digits' \| 'formatted'` | `'digits'` | Model shape: raw digits or formatted display text. |
91
+ | `formatPhoneNumber` | `(digits: string) => string` | `formatNanpPhoneNumber` | Display formatter forwarded to the input. |
92
+ | `class` | `ClassValue` | `''` | Extra host classes (base `tw:w-full`). |
93
+ | `labelClass` | `string` | `''` | Extra label classes (base `tw:mb-1 tw:gap-0`). |
94
+ | `inputClass` | `string` | `''` | Extra inner-input classes. |
95
+ | `errorClass` | `string` | `''` | Extra error classes (base `tw:mt-0`). |
96
+ | `hintClass` | `string` | `''` | Extra hint classes (base `tw:mt-0`). |
97
+
98
+ | Member | Description |
99
+ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
100
+ | `effectiveId` | `controlId() \|\| id() \|\| generated` — wired to input `inputId` and label `for`. |
101
+ | `errorId` / `hintId` | `effectiveId + '-error' / '-hint'`. |
102
+ | `describedBy()` | `errorId` when `error()` is set and control is invalid + dirty/touched, else `hintId` when `hint()` is set, else `null` — wired to input `ariaDescribedby`. |
103
+
104
+ Requires a `[formGroup]` ancestor (injects `FormGroupDirective`, provides `ControlContainer → FormGroupDirective`).
105
+
106
+ ## Examples
107
+
108
+ ### 1. Required US number
109
+
110
+ ```ts
111
+ import { Component, inject } from '@angular/core';
112
+ import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
113
+ import { EgFormPhoneInput } from '@egose/shadcn-theme-ng/form-phone-input';
114
+
115
+ @Component({
116
+ selector: 'app-callback',
117
+ standalone: true,
118
+ imports: [ReactiveFormsModule, EgFormPhoneInput],
119
+ template: `
120
+ <form [formGroup]="form" (ngSubmit)="submit()">
121
+ <eg-form-phone-input
122
+ controlName="phone"
123
+ label="Callback number"
124
+ [required]="true"
125
+ error="Enter a 10-digit number."
126
+ />
127
+ <button type="submit" [disabled]="form.invalid">Request callback</button>
128
+ </form>
129
+ `,
130
+ })
131
+ export class CallbackComponent {
132
+ private readonly fb = inject(FormBuilder);
133
+ readonly form = this.fb.group({ phone: [null as string | null, [Validators.required, Validators.minLength(10)]] });
134
+ submit() {
135
+ console.log(this.form.value.phone); // raw digits, e.g. "4155552671"
136
+ }
137
+ }
138
+ ```
139
+
140
+ ### 2. Optional with hint
141
+
142
+ ```ts
143
+ import { Component, inject } from '@angular/core';
144
+ import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
145
+ import { EgFormPhoneInput } from '@egose/shadcn-theme-ng/form-phone-input';
146
+
147
+ @Component({
148
+ selector: 'app-profile-phone',
149
+ standalone: true,
150
+ imports: [ReactiveFormsModule, EgFormPhoneInput],
151
+ template: `
152
+ <form [formGroup]="form">
153
+ <eg-form-phone-input controlName="mobile" label="Mobile (optional)" hint="US format, digits only in storage." />
154
+ </form>
155
+ `,
156
+ })
157
+ export class ProfilePhoneComponent {
158
+ private readonly fb = inject(FormBuilder);
159
+ readonly form = this.fb.group({ mobile: [null as string | null] });
160
+ }
161
+ ```
162
+
163
+ ## Accessibility notes
164
+
165
+ - Label `for` ↔ input `inputId` wiring is automatic via `effectiveId`; the input also receives `name`, `autocomplete="tel"`, and `ariaDescribedby` — always pass a `label`.
166
+ - The required `*` is visual; pair with `Validators.required` (plus `minLength`) so assistive tech and validation agree.
167
+
168
+ ## Theming / CSS variables
169
+
170
+ No component-specific CSS variables; the inner input carries the shared `HlmInput` base. Style per-instance via `class` / `labelClass` / `inputClass` / `errorClass` / `hintClass` (precedence: library base < global config < per-instance).
171
+
172
+ Global defaults per styling slot via the wrapper config:
173
+
174
+ ```ts
175
+ import { provideEgFormPhoneInputConfig } from '@egose/shadcn-theme-ng/form-phone-input';
176
+
177
+ await bootstrapApplication(App, {
178
+ providers: [provideEgFormPhoneInputConfig({ inputClass: 'tw:text-sm', labelClass: 'tw:font-medium' })],
179
+ });
180
+ ```
181
+
182
+ The host keeps `tw:w-full`; constrain width with `class` (e.g. `tw:max-w-xs`) or a wrapping container.
183
+
184
+ ## Related subpaths
185
+
186
+ - `@egose/shadcn-theme-ng/phone-input` — raw `hlm-phone-input` + `formatNanpPhoneNumber` for custom layouts.
187
+ - `@egose/shadcn-theme-ng/form-text-input` — the plain-text counterpart (`eg-form-text-input`).
188
+ - `@egose/shadcn-theme-ng/form-field` — `hlm-form-field` / `hlm-error` / `hlm-hint` used internally.
189
+ - `@egose/shadcn-theme-ng/form-field-simple` — alternative minimal wrapper when you compose controls by hand.