@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
@@ -75,28 +75,29 @@ Real selectors: `eg-form-textarea`, `hlm-form-field`, `label[hlmLabel]`, `textar
75
75
 
76
76
  ### `eg-form-textarea` — `EgFormTextarea`
77
77
 
78
- | Input | Type | Default | Description |
79
- | --------------------- | ------------------------------- | ----------- | ------------------------------------------------------------------------------------------------ |
80
- | `label` | `string \| undefined` | `undefined` | Field label rendered as `<label hlmLabel>` bound to the textarea 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-textarea-…`. |
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
- | `placeholder` | `string` | `''` | Placeholder text. |
88
- | `readonly` | `boolean` | `false` | Native `readonly` attribute. |
89
- | `disabled` | `boolean` | `false` | Wrapper-level disable (OR-ed with the reactive disabled state — see `effectiveDisabled()`). |
90
- | `maxlength` | `string \| number \| null` | `null` | Native `maxlength`. |
91
- | `minlength` | `string \| number \| null` | `null` | Native `minlength`. |
92
- | `required` | `boolean` | `false` | Native `required` + red `*` on the label. |
93
- | `rows` | `string \| number \| undefined` | `3` | Native `rows` (visible height). |
94
- | `cols` | `string \| number \| undefined` | `undefined` | Native `cols` (visible width). |
95
- | `class` (`userClass`) | `ClassValue` | `''` | Extra host classes (merged over `tw:flex tw:flex-col`). |
96
- | `labelClass` | `string` | `''` | Extra label classes (merged over `tw:mb-1 tw:gap-0`). |
97
- | `textareaClass` | `string` | `''` | Extra textarea classes (merged over `tw:mb-1`). |
98
- | `errorClass` | `string` | `''` | Extra error classes (merged over `tw:mt-0`). |
99
- | `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 textarea 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-textarea-…`. |
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
+ | `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
+ | `required` | `boolean` | `false` | Native `required` + red `*` on the label. |
94
+ | `rows` | `string \| number \| undefined` | `3` | Native `rows` (visible height). |
95
+ | `cols` | `string \| number \| undefined` | `undefined` | Native `cols` (visible width). |
96
+ | `class` (`userClass`) | `ClassValue` | `''` | Extra host classes (merged over `tw:w-full`). |
97
+ | `labelClass` | `string` | `''` | Extra label classes (merged over `tw:mb-1 tw:gap-0`). |
98
+ | `textareaClass` | `string` | `''` | Extra textarea classes (merged over `tw:mb-1`). |
99
+ | `errorClass` | `string` | `''` | Extra error classes (merged over `tw:mt-0`). |
100
+ | `hintClass` | `string` | `''` | Extra hint classes (merged over `tw:mt-0`). |
100
101
 
101
102
  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). Readonly computeds: `effectiveId()`, `errorId()`, `hintId()`.
102
103
 
@@ -340,6 +341,16 @@ export class ProgrammaticExample {
340
341
 
341
342
  No component-specific CSS variables; visuals come from the shared theme tokens via the `hlmInput` class hook. Control height with `rows` and `textareaClass` (`tw:min-h-*`, `tw:resize-y` / `tw:resize-none`).
342
343
 
344
+ Global defaults per styling slot via the wrapper config (precedence: library base < global config < per-instance):
345
+
346
+ ```ts
347
+ import { provideEgFormTextareaConfig } from '@egose/shadcn-theme-ng/form-textarea';
348
+
349
+ await bootstrapApplication(App, {
350
+ providers: [provideEgFormTextareaConfig({ textareaClass: 'tw:text-sm', labelClass: 'tw:font-medium' })],
351
+ });
352
+ ```
353
+
343
354
  ## Related subpaths
344
355
 
345
356
  - `@egose/shadcn-theme-ng/form-text-input` — the single-line sibling.
@@ -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 EgFormTextareaConfigToken = new InjectionToken('EgFormTextareaConfig');
11
+ function provideEgFormTextareaConfig(config) {
12
+ return { provide: EgFormTextareaConfigToken, useValue: { ...config } };
13
+ }
14
+ function injectEgFormTextareaConfig() {
15
+ return inject(EgFormTextareaConfigToken, { optional: true }) ?? {};
16
+ }
17
+
10
18
  class EgFormTextarea {
11
19
  formGroupDirective = inject(FormGroupDirective);
20
+ _errorMessages = injectEgFormErrorMessages();
12
21
  generatedId = inject(HlmFormIdGenerator).generate('eg-form-textarea');
22
+ _config = injectEgFormTextareaConfig();
13
23
  // General props
14
24
  label = input(undefined, /* @ts-ignore */
15
25
  ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
@@ -19,6 +29,13 @@ class EgFormTextarea {
19
29
  ...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
20
30
  error = input(undefined, /* @ts-ignore */
21
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 */ []));
22
39
  hint = input(undefined, /* @ts-ignore */
23
40
  ...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
24
41
  // HTML/textarea attributes
@@ -48,13 +65,34 @@ class EgFormTextarea {
48
65
  ...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
49
66
  hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
50
67
  ...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
51
- describedBy() {
68
+ /**
69
+ * Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
70
+ * auto-resolved from the control's `ValidationErrors`. Plain method (not a
71
+ * computed): `ValidationErrors` is not a signal, so the control must be read
72
+ * fresh on every change-detection pass.
73
+ */
74
+ resolvedError() {
75
+ const explicit = this.error();
76
+ if (explicit)
77
+ return explicit;
78
+ if (!this.autoError())
79
+ return undefined;
52
80
  const control = this.formGroupDirective.form.get(this.controlName());
53
- return this.error() && control?.invalid && (control.dirty || control.touched)
54
- ? this.errorId()
55
- : this.hint()
56
- ? this.hintId()
57
- : null;
81
+ return resolveEgFormError(control?.errors ?? null, this.label(), this._errorMessages);
82
+ }
83
+ /**
84
+ * Whether the error is surfaced: message present + control invalid +
85
+ * touched/dirty/submitted. Gates the visual `<hlm-error>` (and
86
+ * `describedBy()`, where present) so sighted and screen-reader output agree.
87
+ */
88
+ showError() {
89
+ const control = this.formGroupDirective.form.get(this.controlName());
90
+ return (!!this.resolvedError() &&
91
+ !!control?.invalid &&
92
+ (control.dirty || control.touched || this.formGroupDirective.submitted));
93
+ }
94
+ describedBy() {
95
+ return this.showError() ? this.errorId() : this.hint() ? this.hintId() : null;
58
96
  }
59
97
  effectiveDisabled() {
60
98
  return this.disabled() || !!this.formGroupDirective.form.get(this.controlName())?.disabled;
@@ -69,19 +107,19 @@ class EgFormTextarea {
69
107
  ...(ngDevMode ? [{ debugName: "errorClass" }] : /* istanbul ignore next */ []));
70
108
  hintClass = input('', /* @ts-ignore */
71
109
  ...(ngDevMode ? [{ debugName: "hintClass" }] : /* istanbul ignore next */ []));
72
- // Computed class bindings
73
- $userClass = computed(() => hlm("flex flex-col", this.userClass()), /* @ts-ignore */
110
+ // Computed class bindings (library base < global config < per-instance)
111
+ $userClass = computed(() => hlm("w-full", this.userClass()), /* @ts-ignore */
74
112
  ...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
75
- $labelClass = computed(() => hlm("mb-1 gap-0", this.labelClass()), /* @ts-ignore */
113
+ $labelClass = computed(() => hlm("mb-1 gap-0", this._config.labelClass, this.labelClass()), /* @ts-ignore */
76
114
  ...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
77
- $textareaClass = computed(() => hlm("mb-1", this.textareaClass()), /* @ts-ignore */
115
+ $textareaClass = computed(() => hlm("mb-1", this._config.textareaClass, this.textareaClass()), /* @ts-ignore */
78
116
  ...(ngDevMode ? [{ debugName: "$textareaClass" }] : /* istanbul ignore next */ []));
79
- $errorClass = computed(() => hlm("mt-0", this.errorClass()), /* @ts-ignore */
117
+ $errorClass = computed(() => hlm("mt-0", this._config.errorClass, this.errorClass()), /* @ts-ignore */
80
118
  ...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
81
- $hintClass = computed(() => hlm("mt-0", this.hintClass()), /* @ts-ignore */
119
+ $hintClass = computed(() => hlm("mt-0", this._config.hintClass, this.hintClass()), /* @ts-ignore */
82
120
  ...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
83
121
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormTextarea, deps: [], target: i0.ɵɵFactoryTarget.Component });
84
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormTextarea, isStandalone: true, selector: "eg-form-textarea", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", isSignal: true, isRequired: false, transformFunction: null }, controlName: { classPropertyName: "controlName", publicName: "controlName", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, maxlength: { classPropertyName: "maxlength", publicName: "maxlength", isSignal: true, isRequired: false, transformFunction: null }, minlength: { classPropertyName: "minlength", publicName: "minlength", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, rows: { classPropertyName: "rows", publicName: "rows", isSignal: true, isRequired: false, transformFunction: null }, cols: { classPropertyName: "cols", publicName: "cols", 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 }, textareaClass: { classPropertyName: "textareaClass", publicName: "textareaClass", 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 <textarea\n hlmInput\n [attr.aria-label]=\"lbl\"\n [id]=\"effectiveId()\"\n [name]=\"cnm || name()\"\n [formControlName]=\"cnm\"\n [class]=\"$textareaClass()\"\n [placeholder]=\"placeholder()\"\n [readonly]=\"readonly()\"\n [attr.disabled]=\"effectiveDisabled() ? '' : null\"\n [ariaDescribedby]=\"describedBy()\"\n [maxlength]=\"maxlength()\"\n [minlength]=\"minlength()\"\n [required]=\"rqrd\"\n [rows]=\"rows()\"\n [cols]=\"cols()\"\n ></textarea>\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.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"] }] });
122
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormTextarea, isStandalone: true, selector: "eg-form-textarea", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", isSignal: true, isRequired: false, transformFunction: null }, controlName: { classPropertyName: "controlName", publicName: "controlName", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, autoError: { classPropertyName: "autoError", publicName: "autoError", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, maxlength: { classPropertyName: "maxlength", publicName: "maxlength", isSignal: true, isRequired: false, transformFunction: null }, minlength: { classPropertyName: "minlength", publicName: "minlength", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, rows: { classPropertyName: "rows", publicName: "rows", isSignal: true, isRequired: false, transformFunction: null }, cols: { classPropertyName: "cols", publicName: "cols", 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 }, textareaClass: { classPropertyName: "textareaClass", publicName: "textareaClass", 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 <textarea\n hlmInput\n [attr.aria-label]=\"lbl\"\n [id]=\"effectiveId()\"\n [name]=\"cnm || name()\"\n [formControlName]=\"cnm\"\n [class]=\"$textareaClass()\"\n [placeholder]=\"placeholder()\"\n [readonly]=\"readonly()\"\n [attr.disabled]=\"effectiveDisabled() ? '' : null\"\n [ariaDescribedby]=\"describedBy()\"\n [maxlength]=\"maxlength()\"\n [minlength]=\"minlength()\"\n [required]=\"rqrd\"\n [rows]=\"rows()\"\n [cols]=\"cols()\"\n ></textarea>\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.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"] }] });
85
123
  }
86
124
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormTextarea, decorators: [{
87
125
  type: Component,
@@ -89,13 +127,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
89
127
  selector: 'eg-form-textarea',
90
128
  standalone: true,
91
129
  host: {
92
- class: "w-full",
130
+ '[class]': '$userClass()',
93
131
  },
94
132
  imports: [ReactiveFormsModule, HlmFormField, HlmError, HlmHint, HlmLabel, HlmInput],
95
133
  providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
96
- 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 <textarea\n hlmInput\n [attr.aria-label]=\"lbl\"\n [id]=\"effectiveId()\"\n [name]=\"cnm || name()\"\n [formControlName]=\"cnm\"\n [class]=\"$textareaClass()\"\n [placeholder]=\"placeholder()\"\n [readonly]=\"readonly()\"\n [attr.disabled]=\"effectiveDisabled() ? '' : null\"\n [ariaDescribedby]=\"describedBy()\"\n [maxlength]=\"maxlength()\"\n [minlength]=\"minlength()\"\n [required]=\"rqrd\"\n [rows]=\"rows()\"\n [cols]=\"cols()\"\n ></textarea>\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 ",
134
+ 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 <textarea\n hlmInput\n [attr.aria-label]=\"lbl\"\n [id]=\"effectiveId()\"\n [name]=\"cnm || name()\"\n [formControlName]=\"cnm\"\n [class]=\"$textareaClass()\"\n [placeholder]=\"placeholder()\"\n [readonly]=\"readonly()\"\n [attr.disabled]=\"effectiveDisabled() ? '' : null\"\n [ariaDescribedby]=\"describedBy()\"\n [maxlength]=\"maxlength()\"\n [minlength]=\"minlength()\"\n [required]=\"rqrd\"\n [rows]=\"rows()\"\n [cols]=\"cols()\"\n ></textarea>\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 ",
97
135
  }]
98
- }], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], controlId: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlId", required: false }] }], controlName: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlName", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], maxlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxlength", required: false }] }], minlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "minlength", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], rows: [{ type: i0.Input, args: [{ isSignal: true, alias: "rows", required: false }] }], cols: [{ type: i0.Input, args: [{ isSignal: true, alias: "cols", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], textareaClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "textareaClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
136
+ }], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], controlId: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlId", required: false }] }], controlName: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlName", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], autoError: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoError", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], maxlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxlength", required: false }] }], minlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "minlength", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], rows: [{ type: i0.Input, args: [{ isSignal: true, alias: "rows", required: false }] }], cols: [{ type: i0.Input, args: [{ isSignal: true, alias: "cols", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], textareaClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "textareaClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
99
137
 
100
138
  /*
101
139
  * Public API Surface of form-textarea
@@ -105,5 +143,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
105
143
  * Generated bundle index. Do not edit.
106
144
  */
107
145
 
108
- export { EgFormTextarea };
146
+ export { EgFormTextarea, injectEgFormTextareaConfig, provideEgFormTextareaConfig };
109
147
 
@@ -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 EgFormTextarea {
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>;
@@ -22,6 +31,19 @@ declare class EgFormTextarea {
22
31
  readonly effectiveId: _angular_core.Signal<string>;
23
32
  readonly errorId: _angular_core.Signal<string>;
24
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;
25
47
  describedBy(): string | null;
26
48
  effectiveDisabled(): boolean;
27
49
  userClass: _angular_core.InputSignal<ClassValue>;
@@ -35,7 +57,22 @@ declare class EgFormTextarea {
35
57
  $errorClass: _angular_core.Signal<string>;
36
58
  $hintClass: _angular_core.Signal<string>;
37
59
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormTextarea, never>;
38
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormTextarea, "eg-form-textarea", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "controlId": { "alias": "controlId"; "required": false; "isSignal": true; }; "controlName": { "alias": "controlName"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; "hint": { "alias": "hint"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "maxlength": { "alias": "maxlength"; "required": false; "isSignal": true; }; "minlength": { "alias": "minlength"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "rows": { "alias": "rows"; "required": false; "isSignal": true; }; "cols": { "alias": "cols"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "textareaClass": { "alias": "textareaClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
60
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormTextarea, "eg-form-textarea", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "controlId": { "alias": "controlId"; "required": false; "isSignal": true; }; "controlName": { "alias": "controlName"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; "autoError": { "alias": "autoError"; "required": false; "isSignal": true; }; "hint": { "alias": "hint"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "maxlength": { "alias": "maxlength"; "required": false; "isSignal": true; }; "minlength": { "alias": "minlength"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "rows": { "alias": "rows"; "required": false; "isSignal": true; }; "cols": { "alias": "cols"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "textareaClass": { "alias": "textareaClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
39
61
  }
40
62
 
41
- export { EgFormTextarea };
63
+ interface EgFormTextareaConfig {
64
+ /**
65
+ * Global class defaults for `eg-form-textarea` styling slots.
66
+ * Each is merged under the matching per-instance `*Class` input
67
+ * (library base < global config < per-instance).
68
+ */
69
+ labelClass?: string;
70
+ textareaClass?: string;
71
+ errorClass?: string;
72
+ hintClass?: string;
73
+ }
74
+ declare function provideEgFormTextareaConfig(config: Partial<EgFormTextareaConfig>): ValueProvider;
75
+ declare function injectEgFormTextareaConfig(): EgFormTextareaConfig;
76
+
77
+ export { EgFormTextarea, injectEgFormTextareaConfig, provideEgFormTextareaConfig };
78
+ export type { EgFormTextareaConfig };
@@ -0,0 +1,187 @@
1
+ # Form Toggle (`@egose/shadcn-theme-ng/form-toggle`)
2
+
3
+ A ready-made reactive-form boolean field: toggle button + label + validation error/hint display in one tag. For on/off settings where a button-style toggle fits better than a switch or checkbox.
4
+
5
+ The Angular implementation is a standalone wrapper: it renders `HlmError` / `HlmHint` from `@egose/shadcn-theme-ng/form-field`, `HlmLabel`, and a `button[hlmToggle]` from `@egose/shadcn-theme-ng/toggle`.
6
+
7
+ > **Structural note:** unlike the other `eg-form-*` wrappers, the toggle itself is the
8
+ > `ControlValueAccessor` (`BrnToggle` exposes no CVA, speaking `'on'`/`'off'` strings while the
9
+ > form model stays `boolean`). Bind `formControlName` **directly on this element** instead of
10
+ > using a `controlName` input:
11
+ >
12
+ > ```html
13
+ > <eg-form-toggle formControlName="bold" label="Bold" />
14
+ > ```
15
+
16
+ > **Ships as:** `@egose/shadcn-theme-ng/form-toggle` and `@egose/shadcn-theme-ng-tw/form-toggle`
17
+ > (the `tw:`-prefixed Tailwind variant). Both expose the identical TypeScript surface; only the
18
+ > emitted Tailwind class strings differ. See the [package README](../../README.md) for install
19
+ > steps, peer dependencies, and Tailwind setup. Do not publish this project directory independently.
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ # Plain Tailwind (no prefix)
25
+ npm install @egose/shadcn-theme-ng
26
+
27
+ # tw:-prefixed Tailwind variant
28
+ npm install @egose/shadcn-theme-ng-tw
29
+ ```
30
+
31
+ Peer dependencies (Angular, `@spartan-ng/brain`, `@ng-icons/*`, `rxjs`, …) are documented in the
32
+ [package README](../../README.md#peer-dependencies). This subpath additionally relies at runtime on
33
+ `@egose/shadcn-theme-ng/toggle`, `@egose/shadcn-theme-ng/form-field`, and
34
+ `@egose/shadcn-theme-ng/label`.
35
+
36
+ ## Imports
37
+
38
+ Exported from the subpath root (`projects/form-toggle/src/public-api.ts`):
39
+
40
+ ```ts
41
+ import { EgFormToggle, provideEgFormToggleConfig } from '@egose/shadcn-theme-ng/form-toggle';
42
+ // tw variant: replace with '@egose/shadcn-theme-ng-tw/form-toggle'
43
+ ```
44
+
45
+ Standalone usage:
46
+
47
+ ```ts
48
+ import { Component } from '@angular/core';
49
+ import { ReactiveFormsModule } from '@angular/forms';
50
+ import { EgFormToggle } from '@egose/shadcn-theme-ng/form-toggle';
51
+
52
+ @Component({
53
+ selector: 'app-demo',
54
+ standalone: true,
55
+ imports: [ReactiveFormsModule, EgFormToggle],
56
+ template: `...`,
57
+ })
58
+ export class DemoComponent {}
59
+ ```
60
+
61
+ NgModule-based consumer: add `EgFormToggle` (and `ReactiveFormsModule`) to the module's
62
+ `imports` — it is a standalone component, not a module.
63
+
64
+ ## Anatomy / Structure
65
+
66
+ ```html
67
+ <form [formGroup]="form">
68
+ <eg-form-toggle formControlName="bold" label="Bold" hint="Toggle rich-text formatting." />
69
+ </form>
70
+ ```
71
+
72
+ Selector (from source): `eg-form-toggle` (standalone component, host `tw:w-full`).
73
+
74
+ ## API reference
75
+
76
+ ### `EgFormToggle` — `eg-form-toggle`
77
+
78
+ Bind `formControlName` on the element; there is no `controlName` input.
79
+
80
+ | Input | Type | Default | Description |
81
+ | ------------- | --------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
82
+ | `label` | `string \| undefined` | — | Label text beside the toggle (hidden when omitted). |
83
+ | `error` | `string \| undefined` | — | Error text shown when invalid. |
84
+ | `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`. |
85
+ | `hint` | `string \| undefined` | — | Hint text shown otherwise. |
86
+ | `controlId` | `string \| undefined` | — | Explicit id (first priority for `effectiveId`). |
87
+ | `id` | `string \| undefined` | — | Fallback id (second priority). |
88
+ | `disabled` | `boolean` | `false` | Locks interaction (form control stays enabled). |
89
+ | `required` | `boolean` | `false` | Shows a red `*` next to the label. |
90
+ | `variant` | `'default' \| 'outline'` | `'default'` | Toggle variant forwarded to `hlmToggle`. |
91
+ | `size` | `'default' \| 'sm' \| 'lg'` | `'default'` | Toggle size forwarded to `hlmToggle`. |
92
+ | `class` | `ClassValue` | `''` | Extra host classes (base `tw:w-full`). |
93
+ | `toggleClass` | `string` | `''` | Extra toggle-button classes. |
94
+ | `labelClass` | `string` | `''` | Extra label 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 button `id` and label `for`. |
101
+ | `errorId` / `hintId` | `effectiveId + '-error' / '-hint'`. |
102
+
103
+ Requires a `[formGroup]` ancestor (or a standalone `formControl` binding).
104
+
105
+ ## Examples
106
+
107
+ ### 1. Text-formatting toggles
108
+
109
+ ```ts
110
+ import { Component, inject } from '@angular/core';
111
+ import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
112
+ import { EgFormToggle } from '@egose/shadcn-theme-ng/form-toggle';
113
+
114
+ @Component({
115
+ selector: 'app-format',
116
+ standalone: true,
117
+ imports: [ReactiveFormsModule, EgFormToggle],
118
+ template: `
119
+ <form [formGroup]="form" class="tw:flex tw:gap-4">
120
+ <eg-form-toggle formControlName="bold" label="Bold" />
121
+ <eg-form-toggle formControlName="italic" label="Italic" />
122
+ </form>
123
+ `,
124
+ })
125
+ export class FormatComponent {
126
+ private readonly fb = inject(FormBuilder);
127
+ readonly form = this.fb.group({ bold: [false], italic: [false] });
128
+ }
129
+ ```
130
+
131
+ ### 2. Required opt-in with error
132
+
133
+ ```ts
134
+ import { Component, inject } from '@angular/core';
135
+ import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
136
+ import { EgFormToggle } from '@egose/shadcn-theme-ng/form-toggle';
137
+
138
+ @Component({
139
+ selector: 'app-consent-toggle',
140
+ standalone: true,
141
+ imports: [ReactiveFormsModule, EgFormToggle],
142
+ template: `
143
+ <form [formGroup]="form" (ngSubmit)="submit()">
144
+ <eg-form-toggle
145
+ formControlName="consent"
146
+ label="I accept the terms"
147
+ [required]="true"
148
+ error="Consent is required."
149
+ />
150
+ <button type="submit" [disabled]="form.invalid">Continue</button>
151
+ </form>
152
+ `,
153
+ })
154
+ export class ConsentToggleComponent {
155
+ private readonly fb = inject(FormBuilder);
156
+ readonly form = this.fb.group({ consent: [false, Validators.requiredTrue] });
157
+ submit() {
158
+ console.log(this.form.value.consent);
159
+ }
160
+ }
161
+ ```
162
+
163
+ ## Accessibility notes
164
+
165
+ - Label `for` ↔ button `id` wiring is automatic via `effectiveId` — always pass a `label`.
166
+ - The required `*` is visual; pair with `Validators.requiredTrue` so assistive tech and validation agree.
167
+
168
+ ## Theming / CSS variables
169
+
170
+ No component-specific CSS variables. Style per-instance via `class` / `toggleClass` / `labelClass` / `errorClass` / `hintClass` (precedence: library base < global config < per-instance). The row layout (`flex items-center gap-1`) is fixed in the template.
171
+
172
+ Global defaults per styling slot via the wrapper config:
173
+
174
+ ```ts
175
+ import { provideEgFormToggleConfig } from '@egose/shadcn-theme-ng/form-toggle';
176
+
177
+ await bootstrapApplication(App, {
178
+ providers: [provideEgFormToggleConfig({ labelClass: 'tw:font-medium' })],
179
+ });
180
+ ```
181
+
182
+ ## Related subpaths
183
+
184
+ - `@egose/shadcn-theme-ng/toggle` — raw `hlmToggle` directive for custom layouts.
185
+ - `@egose/shadcn-theme-ng/form-toggle-group` — multi-option button group (`eg-form-toggle-group`).
186
+ - `@egose/shadcn-theme-ng/form-switch` / `@egose/shadcn-theme-ng/form-checkbox` — boolean alternatives.
187
+ - `@egose/shadcn-theme-ng/form-field` — `hlm-error` / `hlm-hint` used internally.