@egose/shadcn-theme-ng 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +1 -1
  2. package/autocomplete/fesm2022/autocomplete.mjs +1 -1
  3. package/checkbox/fesm2022/checkbox.mjs +6 -7
  4. package/checkbox/types/checkbox.d.ts +1 -1
  5. package/combobox/fesm2022/combobox.mjs +1 -1
  6. package/date-picker/README.md +15 -11
  7. package/date-picker/fesm2022/date-picker.mjs +148 -30
  8. package/date-picker/types/date-picker.d.ts +102 -9
  9. package/form-autocomplete/README.md +178 -0
  10. package/form-autocomplete/fesm2022/form-autocomplete.mjs +159 -0
  11. package/form-autocomplete/package.json +24 -0
  12. package/form-autocomplete/types/form-autocomplete.d.ts +81 -0
  13. package/form-checkbox/README.md +29 -18
  14. package/form-checkbox/fesm2022/form-checkbox.mjs +59 -17
  15. package/form-checkbox/types/form-checkbox.d.ts +43 -4
  16. package/form-combobox/README.md +203 -0
  17. package/form-combobox/fesm2022/form-combobox.mjs +181 -0
  18. package/form-combobox/package.json +24 -0
  19. package/form-combobox/types/form-combobox.d.ts +93 -0
  20. package/form-date-picker/README.md +49 -22
  21. package/form-date-picker/fesm2022/form-date-picker.mjs +74 -19
  22. package/form-date-picker/types/form-date-picker.d.ts +37 -1
  23. package/form-date-picker-multi/README.md +192 -0
  24. package/form-date-picker-multi/fesm2022/form-date-picker-multi.mjs +158 -0
  25. package/form-date-picker-multi/package.json +24 -0
  26. package/form-date-picker-multi/types/form-date-picker-multi.d.ts +78 -0
  27. package/form-date-range-picker/README.md +254 -0
  28. package/form-date-range-picker/fesm2022/form-date-range-picker.mjs +159 -0
  29. package/form-date-range-picker/package.json +24 -0
  30. package/form-date-range-picker/types/form-date-range-picker.d.ts +75 -0
  31. package/form-field/README.md +9 -0
  32. package/form-field/fesm2022/form-field.mjs +80 -5
  33. package/form-field/types/form-field.d.ts +50 -2
  34. package/form-field-simple/fesm2022/form-field-simple.mjs +15 -1
  35. package/form-field-simple/types/form-field-simple.d.ts +9 -2
  36. package/form-input-otp/README.md +195 -0
  37. package/form-input-otp/fesm2022/form-input-otp.mjs +140 -0
  38. package/form-input-otp/package.json +24 -0
  39. package/form-input-otp/types/form-input-otp.d.ts +78 -0
  40. package/form-month-year-picker/README.md +189 -0
  41. package/form-month-year-picker/fesm2022/form-month-year-picker.mjs +154 -0
  42. package/form-month-year-picker/package.json +24 -0
  43. package/form-month-year-picker/types/form-month-year-picker.d.ts +73 -0
  44. package/form-native-select/README.md +206 -0
  45. package/form-native-select/fesm2022/form-native-select.mjs +132 -0
  46. package/form-native-select/package.json +24 -0
  47. package/form-native-select/types/form-native-select.d.ts +77 -0
  48. package/form-phone-input/README.md +189 -0
  49. package/form-phone-input/fesm2022/form-phone-input.mjs +142 -0
  50. package/form-phone-input/package.json +24 -0
  51. package/form-phone-input/types/form-phone-input.d.ts +78 -0
  52. package/form-radio-group/README.md +199 -0
  53. package/form-radio-group/fesm2022/form-radio-group.mjs +140 -0
  54. package/form-radio-group/package.json +24 -0
  55. package/form-radio-group/types/form-radio-group.d.ts +83 -0
  56. package/form-searchable-multiselect/README.md +28 -17
  57. package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs +57 -19
  58. package/form-searchable-multiselect/types/form-searchable-multiselect.d.ts +39 -2
  59. package/form-select/README.md +30 -19
  60. package/form-select/fesm2022/form-select.mjs +57 -19
  61. package/form-select/types/form-select.d.ts +39 -2
  62. package/form-slider/README.md +183 -0
  63. package/form-slider/fesm2022/form-slider.mjs +140 -0
  64. package/form-slider/package.json +24 -0
  65. package/form-slider/types/form-slider.d.ts +80 -0
  66. package/form-switch/README.md +174 -0
  67. package/form-switch/fesm2022/form-switch.mjs +129 -0
  68. package/form-switch/package.json +24 -0
  69. package/form-switch/types/form-switch.d.ts +70 -0
  70. package/form-text-input/README.md +37 -26
  71. package/form-text-input/fesm2022/form-text-input.mjs +57 -19
  72. package/form-text-input/types/form-text-input.d.ts +39 -2
  73. package/form-textarea/README.md +33 -22
  74. package/form-textarea/fesm2022/form-textarea.mjs +57 -19
  75. package/form-textarea/types/form-textarea.d.ts +39 -2
  76. package/form-toggle/README.md +187 -0
  77. package/form-toggle/fesm2022/form-toggle.mjs +193 -0
  78. package/form-toggle/package.json +24 -0
  79. package/form-toggle/types/form-toggle.d.ts +100 -0
  80. package/form-toggle-group/README.md +177 -0
  81. package/form-toggle-group/fesm2022/form-toggle-group.mjs +145 -0
  82. package/form-toggle-group/package.json +24 -0
  83. package/form-toggle-group/types/form-toggle-group.d.ts +85 -0
  84. package/input-group/fesm2022/input-group.mjs +19 -9
  85. package/input-group/types/input-group.d.ts +4 -1
  86. package/native-select/fesm2022/native-select.mjs +18 -6
  87. package/native-select/types/native-select.d.ts +7 -2
  88. package/package.json +57 -1
  89. package/phone-input/README.md +114 -0
  90. package/phone-input/fesm2022/phone-input.mjs +191 -0
  91. package/phone-input/package.json +24 -0
  92. package/phone-input/types/phone-input.d.ts +67 -0
  93. package/radio-group/types/radio-group.d.ts +1 -1
  94. package/switch/fesm2022/switch.mjs +7 -5
  95. package/switch/types/switch.d.ts +2 -1
  96. package/typography/types/typography.d.ts +8 -8
@@ -0,0 +1,129 @@
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, HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
6
+ import { EgFormField } from '@egose/shadcn-theme-ng/form-field-simple';
7
+ import { HlmLabel } from '@egose/shadcn-theme-ng/label';
8
+ import { HlmSwitch } from '@egose/shadcn-theme-ng/switch';
9
+ import { hlm } from '@egose/shadcn-theme-ng/utils';
10
+
11
+ const EgFormSwitchConfigToken = new InjectionToken('EgFormSwitchConfig');
12
+ function provideEgFormSwitchConfig(config) {
13
+ return { provide: EgFormSwitchConfigToken, useValue: { ...config } };
14
+ }
15
+ function injectEgFormSwitchConfig() {
16
+ return inject(EgFormSwitchConfigToken, { optional: true }) ?? {};
17
+ }
18
+
19
+ class EgFormSwitch {
20
+ formGroupDirective = inject(FormGroupDirective);
21
+ _errorMessages = injectEgFormErrorMessages();
22
+ generatedId = inject(HlmFormIdGenerator).generate('eg-form-switch');
23
+ _config = injectEgFormSwitchConfig();
24
+ label = input(undefined, /* @ts-ignore */
25
+ ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
26
+ controlId = input(undefined, /* @ts-ignore */
27
+ ...(ngDevMode ? [{ debugName: "controlId" }] : /* istanbul ignore next */ []));
28
+ controlName = input('', /* @ts-ignore */
29
+ ...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
30
+ error = input(undefined, /* @ts-ignore */
31
+ ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
32
+ /**
33
+ * Auto-resolve the displayed message from the control's `ValidationErrors`
34
+ * when `error()` is unset. Explicit `error()` always wins. Set to `false`
35
+ * for manual-only messages.
36
+ */
37
+ autoError = input(true, /* @ts-ignore */
38
+ ...(ngDevMode ? [{ debugName: "autoError" }] : /* istanbul ignore next */ []));
39
+ hint = input(undefined, /* @ts-ignore */
40
+ ...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
41
+ id = input(undefined, /* @ts-ignore */
42
+ ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
43
+ disabled = input(false, /* @ts-ignore */
44
+ ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
45
+ required = input(false, /* @ts-ignore */
46
+ ...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
47
+ effectiveId = computed(() => this.controlId() || this.id() || this.generatedId, /* @ts-ignore */
48
+ ...(ngDevMode ? [{ debugName: "effectiveId" }] : /* istanbul ignore next */ []));
49
+ errorId = computed(() => `${this.effectiveId()}-error`, /* @ts-ignore */
50
+ ...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
51
+ hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
52
+ ...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
53
+ /**
54
+ * Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
55
+ * auto-resolved from the control's `ValidationErrors`. Plain method (not a
56
+ * computed): `ValidationErrors` is not a signal, so the control must be read
57
+ * fresh on every change-detection pass.
58
+ */
59
+ resolvedError() {
60
+ const explicit = this.error();
61
+ if (explicit)
62
+ return explicit;
63
+ if (!this.autoError())
64
+ return undefined;
65
+ const control = this.formGroupDirective.form.get(this.controlName());
66
+ return resolveEgFormError(control?.errors ?? null, this.label(), this._errorMessages);
67
+ }
68
+ /**
69
+ * Whether the error is surfaced: message present + control invalid +
70
+ * touched/dirty/submitted. Gates the visual `<hlm-error>` (and
71
+ * `describedBy()`, where present) so sighted and screen-reader output agree.
72
+ */
73
+ showError() {
74
+ const control = this.formGroupDirective.form.get(this.controlName());
75
+ return (!!this.resolvedError() &&
76
+ !!control?.invalid &&
77
+ (control.dirty || control.touched || this.formGroupDirective.submitted));
78
+ }
79
+ describedBy() {
80
+ return this.showError() ? this.errorId() : this.hint() ? this.hintId() : null;
81
+ }
82
+ // Styling
83
+ userClass = input('', { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: 'class' });
84
+ switchClass = input('', /* @ts-ignore */
85
+ ...(ngDevMode ? [{ debugName: "switchClass" }] : /* istanbul ignore next */ []));
86
+ labelClass = input('', /* @ts-ignore */
87
+ ...(ngDevMode ? [{ debugName: "labelClass" }] : /* istanbul ignore next */ []));
88
+ errorClass = input('', /* @ts-ignore */
89
+ ...(ngDevMode ? [{ debugName: "errorClass" }] : /* istanbul ignore next */ []));
90
+ hintClass = input('', /* @ts-ignore */
91
+ ...(ngDevMode ? [{ debugName: "hintClass" }] : /* istanbul ignore next */ []));
92
+ // Computed classes (library base < global config < per-instance)
93
+ $userClass = computed(() => hlm("w-full", this.userClass()), /* @ts-ignore */
94
+ ...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
95
+ $switchClass = computed(() => hlm(this._config.switchClass, this.switchClass()), /* @ts-ignore */
96
+ ...(ngDevMode ? [{ debugName: "$switchClass" }] : /* istanbul ignore next */ []));
97
+ $labelClass = computed(() => hlm(this._config.labelClass, this.labelClass()), /* @ts-ignore */
98
+ ...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
99
+ $errorClass = computed(() => hlm("mt-0", this._config.errorClass, this.errorClass()), /* @ts-ignore */
100
+ ...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
101
+ $hintClass = computed(() => hlm("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: EgFormSwitch, deps: [], target: i0.ɵɵFactoryTarget.Component });
104
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormSwitch, isStandalone: true, selector: "eg-form-switch", 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 }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, switchClass: { classPropertyName: "switchClass", publicName: "switchClass", 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": "$userClass()" } }, providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }], ngImport: i0, template: "\n @let lbl = label();\n @let cnm = controlName();\n @let hnt = hint();\n @let rqrd = required();\n\n <eg-form-field>\n <div class=\"flex items-center gap-1\">\n <hlm-switch\n [id]=\"effectiveId()\"\n [formControlName]=\"cnm\"\n [required]=\"rqrd\"\n [disabled]=\"disabled()\"\n [aria-describedby]=\"describedBy()\"\n [class]=\"$switchClass()\"\n />\n @if (lbl) {\n <label hlmLabel [for]=\"effectiveId()\" [class]=\"$labelClass()\"\n >{{ lbl }}\n @if (rqrd) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n </div>\n\n @if (showError()) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{ resolvedError() }}\n </hlm-error>\n }\n\n @if (hnt) {\n <hlm-hint [id]=\"hintId()\" [class]=\"$hintClass()\">\n {{ hnt }}\n </hlm-hint>\n }\n </eg-form-field>\n ", 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: "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: HlmSwitch, selector: "hlm-switch", inputs: ["class", "checked", "disabled", "id", "aria-label", "aria-labelledby", "aria-describedby"], outputs: ["checkedChange", "changed"] }, { kind: "component", type: EgFormField, selector: "eg-form-field", inputs: ["class"] }] });
105
+ }
106
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormSwitch, decorators: [{
107
+ type: Component,
108
+ args: [{
109
+ selector: 'eg-form-switch',
110
+ standalone: true,
111
+ host: {
112
+ '[class]': '$userClass()',
113
+ },
114
+ imports: [ReactiveFormsModule, HlmError, HlmHint, HlmLabel, HlmSwitch, EgFormField],
115
+ providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
116
+ template: "\n @let lbl = label();\n @let cnm = controlName();\n @let hnt = hint();\n @let rqrd = required();\n\n <eg-form-field>\n <div class=\"flex items-center gap-1\">\n <hlm-switch\n [id]=\"effectiveId()\"\n [formControlName]=\"cnm\"\n [required]=\"rqrd\"\n [disabled]=\"disabled()\"\n [aria-describedby]=\"describedBy()\"\n [class]=\"$switchClass()\"\n />\n @if (lbl) {\n <label hlmLabel [for]=\"effectiveId()\" [class]=\"$labelClass()\"\n >{{ lbl }}\n @if (rqrd) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n </div>\n\n @if (showError()) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{ resolvedError() }}\n </hlm-error>\n }\n\n @if (hnt) {\n <hlm-hint [id]=\"hintId()\" [class]=\"$hintClass()\">\n {{ hnt }}\n </hlm-hint>\n }\n </eg-form-field>\n ",
117
+ }]
118
+ }], 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 }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], switchClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "switchClass", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
119
+
120
+ /*
121
+ * Public API Surface of form-switch
122
+ */
123
+
124
+ /**
125
+ * Generated bundle index. Do not edit.
126
+ */
127
+
128
+ export { EgFormSwitch, injectEgFormSwitchConfig, provideEgFormSwitchConfig };
129
+
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "form-switch",
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-switch.mjs",
13
+ "typings": "types/form-switch.d.ts",
14
+ "exports": {
15
+ "./package.json": {
16
+ "default": "./package.json"
17
+ },
18
+ ".": {
19
+ "types": "./types/form-switch.d.ts",
20
+ "default": "./fesm2022/form-switch.mjs"
21
+ }
22
+ },
23
+ "type": "module"
24
+ }
@@ -0,0 +1,70 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { ValueProvider } from '@angular/core';
3
+ import { ClassValue } from 'clsx';
4
+
5
+ declare class EgFormSwitch {
6
+ private readonly formGroupDirective;
7
+ private readonly _errorMessages;
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
+ /**
15
+ * Auto-resolve the displayed message from the control's `ValidationErrors`
16
+ * when `error()` is unset. Explicit `error()` always wins. Set to `false`
17
+ * for manual-only messages.
18
+ */
19
+ autoError: _angular_core.InputSignal<boolean>;
20
+ hint: _angular_core.InputSignal<string | undefined>;
21
+ id: _angular_core.InputSignal<string | undefined>;
22
+ disabled: _angular_core.InputSignal<boolean>;
23
+ required: _angular_core.InputSignal<boolean>;
24
+ readonly effectiveId: _angular_core.Signal<string>;
25
+ readonly errorId: _angular_core.Signal<string>;
26
+ readonly hintId: _angular_core.Signal<string>;
27
+ /**
28
+ * Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
29
+ * auto-resolved from the control's `ValidationErrors`. Plain method (not a
30
+ * computed): `ValidationErrors` is not a signal, so the control must be read
31
+ * fresh on every change-detection pass.
32
+ */
33
+ protected resolvedError(): string | undefined;
34
+ /**
35
+ * Whether the error is surfaced: message present + control invalid +
36
+ * touched/dirty/submitted. Gates the visual `<hlm-error>` (and
37
+ * `describedBy()`, where present) so sighted and screen-reader output agree.
38
+ */
39
+ protected showError(): boolean;
40
+ describedBy(): string | null;
41
+ userClass: _angular_core.InputSignal<ClassValue>;
42
+ switchClass: _angular_core.InputSignal<string>;
43
+ labelClass: _angular_core.InputSignal<string>;
44
+ errorClass: _angular_core.InputSignal<string>;
45
+ hintClass: _angular_core.InputSignal<string>;
46
+ $userClass: _angular_core.Signal<string>;
47
+ $switchClass: _angular_core.Signal<string>;
48
+ $labelClass: _angular_core.Signal<string>;
49
+ $errorClass: _angular_core.Signal<string>;
50
+ $hintClass: _angular_core.Signal<string>;
51
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormSwitch, never>;
52
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormSwitch, "eg-form-switch", 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; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "switchClass": { "alias": "switchClass"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
53
+ }
54
+
55
+ interface EgFormSwitchConfig {
56
+ /**
57
+ * Global class defaults for `eg-form-switch` styling slots.
58
+ * Each is merged under the matching per-instance `*Class` input
59
+ * (library base < global config < per-instance).
60
+ */
61
+ switchClass?: string;
62
+ labelClass?: string;
63
+ errorClass?: string;
64
+ hintClass?: string;
65
+ }
66
+ declare function provideEgFormSwitchConfig(config: Partial<EgFormSwitchConfig>): ValueProvider;
67
+ declare function injectEgFormSwitchConfig(): EgFormSwitchConfig;
68
+
69
+ export { EgFormSwitch, injectEgFormSwitchConfig, provideEgFormSwitchConfig };
70
+ export type { EgFormSwitchConfig };
@@ -75,32 +75,33 @@ Real selectors: `eg-form-text-input`, `hlm-form-field`, `label[hlmLabel]`, `inpu
75
75
 
76
76
  ### `eg-form-text-input` — `EgFormTextInput`
77
77
 
78
- | Input | Type | Default | Description |
79
- | --------------------- | -------------------------- | ----------- | ------------------------------------------------------------------------------------------------ |
80
- | `label` | `string \| undefined` | `undefined` | Field label rendered as `<label hlmLabel>` bound to the input id. |
81
- | `controlName` | `string` | `''` | **Required.** Control name in the parent `FormGroup`; forwarded as `formControlName` and `name`. |
82
- | `controlId` | `string \| undefined` | `undefined` | Explicit id; falls back to `id`, then generated `eg-form-text-input-…`. |
83
- | `id` | `string \| undefined` | `undefined` | Alias for an explicit id (same fallback chain). |
84
- | `error` | `string \| undefined` | `undefined` | Error text rendered in `<hlm-error>`. |
85
- | `hint` | `string \| undefined` | `undefined` | Hint text rendered in `<hlm-hint>`. |
86
- | `name` | `string \| undefined` | `undefined` | `name` attribute fallback when `controlName` is empty. |
87
- | `type` | `string` | `'text'` | Native input `type` (`text`, `email`, `password`, `number`, `tel`, `url`, …). |
88
- | `placeholder` | `string` | `''` | Placeholder text. |
89
- | `readonly` | `boolean` | `false` | Native `readonly` attribute. |
90
- | `disabled` | `boolean` | `false` | Wrapper-level disable (OR-ed with the reactive disabled state — see `effectiveDisabled()`). |
91
- | `maxlength` | `string \| number \| null` | `null` | Native `maxlength`. |
92
- | `minlength` | `string \| number \| null` | `null` | Native `minlength`. |
93
- | `max` | `string \| number \| null` | `null` | Native `max` (number/date inputs). |
94
- | `min` | `string \| number \| null` | `null` | Native `min` (number/date inputs). |
95
- | `pattern` | `string \| RegExp` | `''` | Native `pattern` attribute. |
96
- | `autocomplete` | `string \| undefined` | `undefined` | Native `autocomplete` (e.g. `email`, `current-password`). |
97
- | `autofocus` | `boolean` | `false` | Native `autofocus`. |
98
- | `required` | `boolean` | `false` | Native `required` + red `*` on the label. |
99
- | `class` (`userClass`) | `ClassValue` | `''` | Extra host classes (merged over `tw:flex tw:flex-col`). |
100
- | `labelClass` | `string` | `''` | Extra label classes (merged over `tw:mb-1 tw:gap-0`). |
101
- | `inputClass` | `string` | `''` | Extra input classes (merged over `tw:mb-1`). |
102
- | `errorClass` | `string` | `''` | Extra error classes (merged over `tw:mt-0`). |
103
- | `hintClass` | `string` | `''` | Extra hint classes (merged over `tw:mt-0`). |
78
+ | Input | Type | Default | Description |
79
+ | --------------------- | -------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
80
+ | `label` | `string \| undefined` | `undefined` | Field label rendered as `<label hlmLabel>` bound to the input id. |
81
+ | `controlName` | `string` | `''` | **Required.** Control name in the parent `FormGroup`; forwarded as `formControlName` and `name`. |
82
+ | `controlId` | `string \| undefined` | `undefined` | Explicit id; falls back to `id`, then generated `eg-form-text-input-…`. |
83
+ | `id` | `string \| undefined` | `undefined` | Alias for an explicit id (same fallback chain). |
84
+ | `error` | `string \| undefined` | `undefined` | Error text rendered in `<hlm-error>`. |
85
+ | `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`. |
86
+ | `hint` | `string \| undefined` | `undefined` | Hint text rendered in `<hlm-hint>`. |
87
+ | `name` | `string \| undefined` | `undefined` | `name` attribute fallback when `controlName` is empty. |
88
+ | `type` | `string` | `'text'` | Native input `type` (`text`, `email`, `password`, `number`, `tel`, `url`, …). |
89
+ | `placeholder` | `string` | `''` | Placeholder text. |
90
+ | `readonly` | `boolean` | `false` | Native `readonly` attribute. |
91
+ | `disabled` | `boolean` | `false` | Wrapper-level disable (OR-ed with the reactive disabled state — see `effectiveDisabled()`). |
92
+ | `maxlength` | `string \| number \| null` | `null` | Native `maxlength`. |
93
+ | `minlength` | `string \| number \| null` | `null` | Native `minlength`. |
94
+ | `max` | `string \| number \| null` | `null` | Native `max` (number/date inputs). |
95
+ | `min` | `string \| number \| null` | `null` | Native `min` (number/date inputs). |
96
+ | `pattern` | `string \| RegExp` | `''` | Native `pattern` attribute. |
97
+ | `autocomplete` | `string \| undefined` | `undefined` | Native `autocomplete` (e.g. `email`, `current-password`). |
98
+ | `autofocus` | `boolean` | `false` | Native `autofocus`. |
99
+ | `required` | `boolean` | `false` | Native `required` + red `*` on the label. |
100
+ | `class` (`userClass`) | `ClassValue` | `''` | Extra host classes (merged over `tw:flex tw:flex-col`). |
101
+ | `labelClass` | `string` | `''` | Extra label classes (merged over `tw:mb-1 tw:gap-0`). |
102
+ | `inputClass` | `string` | `''` | Extra input classes (merged over `tw:mb-1`). |
103
+ | `errorClass` | `string` | `''` | Extra error classes (merged over `tw:mt-0`). |
104
+ | `hintClass` | `string` | `''` | Extra hint classes (merged over `tw:mt-0`). |
104
105
 
105
106
  No outputs. Methods: `describedBy(): string | null` (error id when invalid + dirty/touched, else hint id, else `null`); `effectiveDisabled(): boolean` (`disabled()` OR the control's reactive disabled state — bound as the native `disabled` attribute). Readonly computeds: `effectiveId()`, `errorId()`, `hintId()`.
106
107
 
@@ -364,6 +365,16 @@ export class ProfileExample {
364
365
 
365
366
  No component-specific CSS variables; the input look comes from the shared theme tokens consumed by `HlmInput`. Adjust density with `inputClass` (e.g. `tw:h-11`), label/error/hint spacing with their `*Class` inputs.
366
367
 
368
+ Global defaults per styling slot via the wrapper config (precedence: library base < global config < per-instance):
369
+
370
+ ```ts
371
+ import { provideEgFormTextInputConfig } from '@egose/shadcn-theme-ng/form-text-input';
372
+
373
+ await bootstrapApplication(App, {
374
+ providers: [provideEgFormTextInputConfig({ inputClass: 'tw:text-sm', labelClass: 'tw:font-medium' })],
375
+ });
376
+ ```
377
+
367
378
  ## Related subpaths
368
379
 
369
380
  - `@egose/shadcn-theme-ng/input` — the raw `HlmInput` directive for non-form or template-driven inputs.
@@ -1,15 +1,25 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, input, computed, Component } from '@angular/core';
2
+ import { InjectionToken, inject, input, computed, Component } from '@angular/core';
3
3
  import * as i1 from '@angular/forms';
4
4
  import { FormGroupDirective, ReactiveFormsModule, ControlContainer } from '@angular/forms';
5
- import { HlmFormIdGenerator, HlmFormField, HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
5
+ import { injectEgFormErrorMessages, HlmFormIdGenerator, resolveEgFormError, HlmFormField, HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
6
6
  import { HlmLabel } from '@egose/shadcn-theme-ng/label';
7
7
  import { HlmInput } from '@egose/shadcn-theme-ng/input';
8
8
  import { hlm } from '@egose/shadcn-theme-ng/utils';
9
9
 
10
+ const EgFormTextInputConfigToken = new InjectionToken('EgFormTextInputConfig');
11
+ function provideEgFormTextInputConfig(config) {
12
+ return { provide: EgFormTextInputConfigToken, useValue: { ...config } };
13
+ }
14
+ function injectEgFormTextInputConfig() {
15
+ return inject(EgFormTextInputConfigToken, { optional: true }) ?? {};
16
+ }
17
+
10
18
  class EgFormTextInput {
11
19
  formGroupDirective = inject(FormGroupDirective);
20
+ _errorMessages = injectEgFormErrorMessages();
12
21
  generatedId = inject(HlmFormIdGenerator).generate('eg-form-text-input');
22
+ _config = injectEgFormTextInputConfig();
13
23
  label = input(undefined, /* @ts-ignore */
14
24
  ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
15
25
  controlId = input(undefined, /* @ts-ignore */
@@ -18,6 +28,13 @@ class EgFormTextInput {
18
28
  ...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
19
29
  error = input(undefined, /* @ts-ignore */
20
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 */ []));
21
38
  hint = input(undefined, /* @ts-ignore */
22
39
  ...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
23
40
  // HTML/input attributes
@@ -55,13 +72,34 @@ class EgFormTextInput {
55
72
  ...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
56
73
  hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
57
74
  ...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
58
- describedBy() {
75
+ /**
76
+ * Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
77
+ * auto-resolved from the control's `ValidationErrors`. Plain method (not a
78
+ * computed): `ValidationErrors` is not a signal, so the control must be read
79
+ * fresh on every change-detection pass.
80
+ */
81
+ resolvedError() {
82
+ const explicit = this.error();
83
+ if (explicit)
84
+ return explicit;
85
+ if (!this.autoError())
86
+ return undefined;
59
87
  const control = this.formGroupDirective.form.get(this.controlName());
60
- return this.error() && control?.invalid && (control.dirty || control.touched)
61
- ? this.errorId()
62
- : this.hint()
63
- ? this.hintId()
64
- : null;
88
+ return resolveEgFormError(control?.errors ?? null, this.label(), this._errorMessages);
89
+ }
90
+ /**
91
+ * Whether the error is surfaced: message present + control invalid +
92
+ * touched/dirty/submitted. Gates the visual `<hlm-error>` (and
93
+ * `describedBy()`, where present) so sighted and screen-reader output agree.
94
+ */
95
+ showError() {
96
+ const control = this.formGroupDirective.form.get(this.controlName());
97
+ return (!!this.resolvedError() &&
98
+ !!control?.invalid &&
99
+ (control.dirty || control.touched || this.formGroupDirective.submitted));
100
+ }
101
+ describedBy() {
102
+ return this.showError() ? this.errorId() : this.hint() ? this.hintId() : null;
65
103
  }
66
104
  effectiveDisabled() {
67
105
  return this.disabled() || !!this.formGroupDirective.form.get(this.controlName())?.disabled;
@@ -76,19 +114,19 @@ class EgFormTextInput {
76
114
  ...(ngDevMode ? [{ debugName: "errorClass" }] : /* istanbul ignore next */ []));
77
115
  hintClass = input('', /* @ts-ignore */
78
116
  ...(ngDevMode ? [{ debugName: "hintClass" }] : /* istanbul ignore next */ []));
79
- // Computed class bindings
80
- $userClass = computed(() => hlm("flex flex-col", this.userClass()), /* @ts-ignore */
117
+ // Computed class bindings (library base < global config < per-instance)
118
+ $userClass = computed(() => hlm("w-full", this.userClass()), /* @ts-ignore */
81
119
  ...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
82
- $labelClass = computed(() => hlm("mb-1 gap-0", this.labelClass()), /* @ts-ignore */
120
+ $labelClass = computed(() => hlm("mb-1 gap-0", this._config.labelClass, this.labelClass()), /* @ts-ignore */
83
121
  ...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
84
- $inputClass = computed(() => hlm("mb-1", this.inputClass()), /* @ts-ignore */
122
+ $inputClass = computed(() => hlm("mb-1", this._config.inputClass, this.inputClass()), /* @ts-ignore */
85
123
  ...(ngDevMode ? [{ debugName: "$inputClass" }] : /* istanbul ignore next */ []));
86
- $errorClass = computed(() => hlm("mt-0", this.errorClass()), /* @ts-ignore */
124
+ $errorClass = computed(() => hlm("mt-0", this._config.errorClass, this.errorClass()), /* @ts-ignore */
87
125
  ...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
88
- $hintClass = computed(() => hlm("mt-0", this.hintClass()), /* @ts-ignore */
126
+ $hintClass = computed(() => hlm("mt-0", this._config.hintClass, this.hintClass()), /* @ts-ignore */
89
127
  ...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
90
128
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormTextInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
91
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormTextInput, isStandalone: true, selector: "eg-form-text-input", 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 }, type: { classPropertyName: "type", publicName: "type", 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 }, maxlength: { classPropertyName: "maxlength", publicName: "maxlength", isSignal: true, isRequired: false, transformFunction: null }, minlength: { classPropertyName: "minlength", publicName: "minlength", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, pattern: { classPropertyName: "pattern", publicName: "pattern", isSignal: true, isRequired: false, transformFunction: null }, autocomplete: { classPropertyName: "autocomplete", publicName: "autocomplete", isSignal: true, isRequired: false, transformFunction: null }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", 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 }, 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: { classAttribute: "w-full" }, providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }], ngImport: i0, template: "\n @let lbl = label();\n @let cnm = controlName();\n @let err = error();\n @let hnt = hint();\n @let rqrd = required();\n\n <hlm-form-field>\n @if (lbl) {\n <label hlmLabel [for]=\"effectiveId()\" [class]=\"$labelClass()\"\n >{{ lbl }}\n @if (rqrd) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n <input\n hlmInput\n [attr.aria-label]=\"lbl\"\n [id]=\"effectiveId()\"\n [name]=\"cnm || name()\"\n [formControlName]=\"cnm\"\n [class]=\"$inputClass()\"\n [type]=\"type()\"\n [placeholder]=\"placeholder()\"\n [readonly]=\"readonly()\"\n [attr.disabled]=\"effectiveDisabled() ? '' : null\"\n [ariaDescribedby]=\"describedBy()\"\n [max]=\"max()\"\n [min]=\"min()\"\n [maxlength]=\"maxlength()\"\n [minlength]=\"minlength()\"\n [pattern]=\"pattern()\"\n [autocomplete]=\"autocomplete()\"\n [autofocus]=\"autofocus()\"\n [required]=\"rqrd\"\n />\n\n @if (err) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{ err }}\n </hlm-error>\n }\n\n @if (hnt) {\n <hlm-hint [id]=\"hintId()\" [class]=\"$hintClass()\">\n {{ hnt }}\n </hlm-hint>\n }\n </hlm-form-field>\n ", isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { 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.MinLengthValidator, selector: "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", inputs: ["minlength"] }, { kind: "directive", type: i1.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i1.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { 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: "directive", type: HlmInput, selector: "[hlmInput]", inputs: ["ariaDescribedby"] }] });
129
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormTextInput, isStandalone: true, selector: "eg-form-text-input", 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 }, type: { classPropertyName: "type", publicName: "type", 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 }, maxlength: { classPropertyName: "maxlength", publicName: "maxlength", isSignal: true, isRequired: false, transformFunction: null }, minlength: { classPropertyName: "minlength", publicName: "minlength", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, pattern: { classPropertyName: "pattern", publicName: "pattern", isSignal: true, isRequired: false, transformFunction: null }, autocomplete: { classPropertyName: "autocomplete", publicName: "autocomplete", isSignal: true, isRequired: false, transformFunction: null }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", 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 }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", isSignal: true, isRequired: false, transformFunction: null }, errorClass: { classPropertyName: "errorClass", publicName: "errorClass", isSignal: true, isRequired: false, transformFunction: null }, hintClass: { classPropertyName: "hintClass", publicName: "hintClass", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "$userClass()" } }, providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }], ngImport: i0, template: "\n @let lbl = label();\n @let cnm = controlName();\n @let hnt = hint();\n @let rqrd = required();\n\n <hlm-form-field>\n @if (lbl) {\n <label hlmLabel [for]=\"effectiveId()\" [class]=\"$labelClass()\"\n >{{ lbl }}\n @if (rqrd) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n <input\n hlmInput\n [attr.aria-label]=\"lbl\"\n [id]=\"effectiveId()\"\n [name]=\"cnm || name()\"\n [formControlName]=\"cnm\"\n [class]=\"$inputClass()\"\n [type]=\"type()\"\n [placeholder]=\"placeholder()\"\n [readonly]=\"readonly()\"\n [attr.disabled]=\"effectiveDisabled() ? '' : null\"\n [ariaDescribedby]=\"describedBy()\"\n [max]=\"max()\"\n [min]=\"min()\"\n [maxlength]=\"maxlength()\"\n [minlength]=\"minlength()\"\n [pattern]=\"pattern()\"\n [autocomplete]=\"autocomplete()\"\n [autofocus]=\"autofocus()\"\n [required]=\"rqrd\"\n />\n\n @if (showError()) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{ resolvedError() }}\n </hlm-error>\n }\n\n @if (hnt) {\n <hlm-hint [id]=\"hintId()\" [class]=\"$hintClass()\">\n {{ hnt }}\n </hlm-hint>\n }\n </hlm-form-field>\n ", isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { 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.MinLengthValidator, selector: "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", inputs: ["minlength"] }, { kind: "directive", type: i1.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i1.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { 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: "directive", type: HlmInput, selector: "[hlmInput]", inputs: ["ariaDescribedby"] }] });
92
130
  }
93
131
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormTextInput, decorators: [{
94
132
  type: Component,
@@ -96,13 +134,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
96
134
  selector: 'eg-form-text-input',
97
135
  standalone: true,
98
136
  host: {
99
- class: "w-full",
137
+ '[class]': '$userClass()',
100
138
  },
101
139
  imports: [ReactiveFormsModule, HlmFormField, HlmError, HlmHint, HlmLabel, HlmInput],
102
140
  providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
103
- template: "\n @let lbl = label();\n @let cnm = controlName();\n @let err = error();\n @let hnt = hint();\n @let rqrd = required();\n\n <hlm-form-field>\n @if (lbl) {\n <label hlmLabel [for]=\"effectiveId()\" [class]=\"$labelClass()\"\n >{{ lbl }}\n @if (rqrd) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n <input\n hlmInput\n [attr.aria-label]=\"lbl\"\n [id]=\"effectiveId()\"\n [name]=\"cnm || name()\"\n [formControlName]=\"cnm\"\n [class]=\"$inputClass()\"\n [type]=\"type()\"\n [placeholder]=\"placeholder()\"\n [readonly]=\"readonly()\"\n [attr.disabled]=\"effectiveDisabled() ? '' : null\"\n [ariaDescribedby]=\"describedBy()\"\n [max]=\"max()\"\n [min]=\"min()\"\n [maxlength]=\"maxlength()\"\n [minlength]=\"minlength()\"\n [pattern]=\"pattern()\"\n [autocomplete]=\"autocomplete()\"\n [autofocus]=\"autofocus()\"\n [required]=\"rqrd\"\n />\n\n @if (err) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{ err }}\n </hlm-error>\n }\n\n @if (hnt) {\n <hlm-hint [id]=\"hintId()\" [class]=\"$hintClass()\">\n {{ hnt }}\n </hlm-hint>\n }\n </hlm-form-field>\n ",
141
+ template: "\n @let lbl = label();\n @let cnm = controlName();\n @let hnt = hint();\n @let rqrd = required();\n\n <hlm-form-field>\n @if (lbl) {\n <label hlmLabel [for]=\"effectiveId()\" [class]=\"$labelClass()\"\n >{{ lbl }}\n @if (rqrd) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n <input\n hlmInput\n [attr.aria-label]=\"lbl\"\n [id]=\"effectiveId()\"\n [name]=\"cnm || name()\"\n [formControlName]=\"cnm\"\n [class]=\"$inputClass()\"\n [type]=\"type()\"\n [placeholder]=\"placeholder()\"\n [readonly]=\"readonly()\"\n [attr.disabled]=\"effectiveDisabled() ? '' : null\"\n [ariaDescribedby]=\"describedBy()\"\n [max]=\"max()\"\n [min]=\"min()\"\n [maxlength]=\"maxlength()\"\n [minlength]=\"minlength()\"\n [pattern]=\"pattern()\"\n [autocomplete]=\"autocomplete()\"\n [autofocus]=\"autofocus()\"\n [required]=\"rqrd\"\n />\n\n @if (showError()) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{ resolvedError() }}\n </hlm-error>\n }\n\n @if (hnt) {\n <hlm-hint [id]=\"hintId()\" [class]=\"$hintClass()\">\n {{ hnt }}\n </hlm-hint>\n }\n </hlm-form-field>\n ",
104
142
  }]
105
- }], 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 }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", 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 }] }], maxlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxlength", required: false }] }], minlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "minlength", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], pattern: [{ type: i0.Input, args: [{ isSignal: true, alias: "pattern", required: false }] }], autocomplete: [{ type: i0.Input, args: [{ isSignal: true, alias: "autocomplete", required: false }] }], autofocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocus", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", 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 }] }] } });
143
+ }], 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 }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", 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 }] }], maxlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxlength", required: false }] }], minlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "minlength", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], pattern: [{ type: i0.Input, args: [{ isSignal: true, alias: "pattern", required: false }] }], autocomplete: [{ type: i0.Input, args: [{ isSignal: true, alias: "autocomplete", required: false }] }], autofocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocus", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", 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 }] }] } });
106
144
 
107
145
  /*
108
146
  * Public API Surface of form-text-input
@@ -112,5 +150,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
112
150
  * Generated bundle index. Do not edit.
113
151
  */
114
152
 
115
- export { EgFormTextInput };
153
+ export { EgFormTextInput, injectEgFormTextInputConfig, provideEgFormTextInputConfig };
116
154
 
@@ -1,13 +1,22 @@
1
1
  import * as _angular_core from '@angular/core';
2
+ import { ValueProvider } from '@angular/core';
2
3
  import { ClassValue } from 'clsx';
3
4
 
4
5
  declare class EgFormTextInput {
5
6
  private readonly formGroupDirective;
7
+ private readonly _errorMessages;
6
8
  private readonly generatedId;
9
+ private readonly _config;
7
10
  label: _angular_core.InputSignal<string | undefined>;
8
11
  controlId: _angular_core.InputSignal<string | undefined>;
9
12
  controlName: _angular_core.InputSignal<string>;
10
13
  error: _angular_core.InputSignal<string | undefined>;
14
+ /**
15
+ * Auto-resolve the displayed message from the control's `ValidationErrors`
16
+ * when `error()` is unset. Explicit `error()` always wins. Set to `false`
17
+ * for manual-only messages.
18
+ */
19
+ autoError: _angular_core.InputSignal<boolean>;
11
20
  hint: _angular_core.InputSignal<string | undefined>;
12
21
  id: _angular_core.InputSignal<string | undefined>;
13
22
  name: _angular_core.InputSignal<string | undefined>;
@@ -26,6 +35,19 @@ declare class EgFormTextInput {
26
35
  readonly effectiveId: _angular_core.Signal<string>;
27
36
  readonly errorId: _angular_core.Signal<string>;
28
37
  readonly hintId: _angular_core.Signal<string>;
38
+ /**
39
+ * Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
40
+ * auto-resolved from the control's `ValidationErrors`. Plain method (not a
41
+ * computed): `ValidationErrors` is not a signal, so the control must be read
42
+ * fresh on every change-detection pass.
43
+ */
44
+ protected resolvedError(): string | undefined;
45
+ /**
46
+ * Whether the error is surfaced: message present + control invalid +
47
+ * touched/dirty/submitted. Gates the visual `<hlm-error>` (and
48
+ * `describedBy()`, where present) so sighted and screen-reader output agree.
49
+ */
50
+ protected showError(): boolean;
29
51
  describedBy(): string | null;
30
52
  effectiveDisabled(): boolean;
31
53
  userClass: _angular_core.InputSignal<ClassValue>;
@@ -39,7 +61,22 @@ declare class EgFormTextInput {
39
61
  $errorClass: _angular_core.Signal<string>;
40
62
  $hintClass: _angular_core.Signal<string>;
41
63
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormTextInput, never>;
42
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormTextInput, "eg-form-text-input", 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; }; "type": { "alias": "type"; "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; }; "maxlength": { "alias": "maxlength"; "required": false; "isSignal": true; }; "minlength": { "alias": "minlength"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "pattern": { "alias": "pattern"; "required": false; "isSignal": true; }; "autocomplete": { "alias": "autocomplete"; "required": false; "isSignal": true; }; "autofocus": { "alias": "autofocus"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "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>;
64
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormTextInput, "eg-form-text-input", 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; }; "type": { "alias": "type"; "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; }; "maxlength": { "alias": "maxlength"; "required": false; "isSignal": true; }; "minlength": { "alias": "minlength"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "pattern": { "alias": "pattern"; "required": false; "isSignal": true; }; "autocomplete": { "alias": "autocomplete"; "required": false; "isSignal": true; }; "autofocus": { "alias": "autofocus"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "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>;
43
65
  }
44
66
 
45
- export { EgFormTextInput };
67
+ interface EgFormTextInputConfig {
68
+ /**
69
+ * Global class defaults for `eg-form-text-input` styling slots.
70
+ * Each is merged under the matching per-instance `*Class` input
71
+ * (library base < global config < per-instance).
72
+ */
73
+ labelClass?: string;
74
+ inputClass?: string;
75
+ errorClass?: string;
76
+ hintClass?: string;
77
+ }
78
+ declare function provideEgFormTextInputConfig(config: Partial<EgFormTextInputConfig>): ValueProvider;
79
+ declare function injectEgFormTextInputConfig(): EgFormTextInputConfig;
80
+
81
+ export { EgFormTextInput, injectEgFormTextInputConfig, provideEgFormTextInputConfig };
82
+ export type { EgFormTextInputConfig };