@egose/shadcn-theme-ng-tw 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +1 -1
  2. package/alert/fesm2022/alert.mjs +1 -1
  3. package/autocomplete/fesm2022/autocomplete.mjs +1 -1
  4. package/button/fesm2022/button.mjs +3 -3
  5. package/checkbox/fesm2022/checkbox.mjs +6 -7
  6. package/checkbox/types/checkbox.d.ts +1 -1
  7. package/combobox/fesm2022/combobox.mjs +1 -1
  8. package/date-picker/README.md +15 -11
  9. package/date-picker/fesm2022/date-picker.mjs +148 -30
  10. package/date-picker/types/date-picker.d.ts +102 -9
  11. package/form-autocomplete/README.md +177 -0
  12. package/form-autocomplete/fesm2022/form-autocomplete.mjs +211 -0
  13. package/form-autocomplete/package.json +24 -0
  14. package/form-autocomplete/types/form-autocomplete.d.ts +61 -0
  15. package/form-checkbox/README.md +13 -3
  16. package/form-checkbox/fesm2022/form-checkbox.mjs +22 -9
  17. package/form-checkbox/types/form-checkbox.d.ts +23 -4
  18. package/form-combobox/README.md +202 -0
  19. package/form-combobox/fesm2022/form-combobox.mjs +273 -0
  20. package/form-combobox/package.json +24 -0
  21. package/form-combobox/types/form-combobox.d.ts +73 -0
  22. package/form-date-picker/README.md +48 -22
  23. package/form-date-picker/fesm2022/form-date-picker.mjs +60 -16
  24. package/form-date-picker/types/form-date-picker.d.ts +17 -1
  25. package/form-date-picker-multi/README.md +191 -0
  26. package/form-date-picker-multi/fesm2022/form-date-picker-multi.mjs +239 -0
  27. package/form-date-picker-multi/package.json +24 -0
  28. package/form-date-picker-multi/types/form-date-picker-multi.d.ts +58 -0
  29. package/form-date-range-picker/README.md +253 -0
  30. package/form-date-range-picker/fesm2022/form-date-range-picker.mjs +236 -0
  31. package/form-date-range-picker/package.json +24 -0
  32. package/form-date-range-picker/types/form-date-range-picker.d.ts +55 -0
  33. package/form-input-otp/README.md +194 -0
  34. package/form-input-otp/fesm2022/form-input-otp.mjs +194 -0
  35. package/form-input-otp/package.json +24 -0
  36. package/form-input-otp/types/form-input-otp.d.ts +58 -0
  37. package/form-month-year-picker/README.md +188 -0
  38. package/form-month-year-picker/fesm2022/form-month-year-picker.mjs +229 -0
  39. package/form-month-year-picker/package.json +24 -0
  40. package/form-month-year-picker/types/form-month-year-picker.d.ts +53 -0
  41. package/form-native-select/README.md +205 -0
  42. package/form-native-select/fesm2022/form-native-select.mjs +187 -0
  43. package/form-native-select/package.json +24 -0
  44. package/form-native-select/types/form-native-select.d.ts +57 -0
  45. package/form-phone-input/README.md +188 -0
  46. package/form-phone-input/fesm2022/form-phone-input.mjs +203 -0
  47. package/form-phone-input/package.json +24 -0
  48. package/form-phone-input/types/form-phone-input.d.ts +58 -0
  49. package/form-radio-group/README.md +198 -0
  50. package/form-radio-group/fesm2022/form-radio-group.mjs +211 -0
  51. package/form-radio-group/package.json +24 -0
  52. package/form-radio-group/types/form-radio-group.d.ts +63 -0
  53. package/form-searchable-multiselect/README.md +11 -1
  54. package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs +19 -10
  55. package/form-searchable-multiselect/types/form-searchable-multiselect.d.ts +18 -1
  56. package/form-select/README.md +10 -0
  57. package/form-select/fesm2022/form-select.mjs +24 -15
  58. package/form-select/types/form-select.d.ts +18 -1
  59. package/form-slider/README.md +182 -0
  60. package/form-slider/fesm2022/form-slider.mjs +186 -0
  61. package/form-slider/package.json +24 -0
  62. package/form-slider/types/form-slider.d.ts +60 -0
  63. package/form-switch/README.md +173 -0
  64. package/form-switch/fesm2022/form-switch.mjs +178 -0
  65. package/form-switch/package.json +24 -0
  66. package/form-switch/types/form-switch.d.ts +50 -0
  67. package/form-text-input/README.md +10 -0
  68. package/form-text-input/fesm2022/form-text-input.mjs +19 -10
  69. package/form-text-input/types/form-text-input.d.ts +18 -1
  70. package/form-textarea/README.md +11 -1
  71. package/form-textarea/fesm2022/form-textarea.mjs +19 -10
  72. package/form-textarea/types/form-textarea.d.ts +18 -1
  73. package/form-toggle/README.md +186 -0
  74. package/form-toggle/fesm2022/form-toggle.mjs +241 -0
  75. package/form-toggle/package.json +24 -0
  76. package/form-toggle/types/form-toggle.d.ts +82 -0
  77. package/form-toggle-group/README.md +176 -0
  78. package/form-toggle-group/fesm2022/form-toggle-group.mjs +216 -0
  79. package/form-toggle-group/package.json +24 -0
  80. package/form-toggle-group/types/form-toggle-group.d.ts +65 -0
  81. package/input-group/fesm2022/input-group.mjs +20 -10
  82. package/input-group/types/input-group.d.ts +4 -1
  83. package/native-select/fesm2022/native-select.mjs +18 -6
  84. package/native-select/types/native-select.d.ts +7 -2
  85. package/package.json +57 -1
  86. package/phone-input/README.md +114 -0
  87. package/phone-input/fesm2022/phone-input.mjs +191 -0
  88. package/phone-input/package.json +24 -0
  89. package/phone-input/types/phone-input.d.ts +67 -0
  90. package/sheet/fesm2022/sheet.mjs +1 -1
  91. package/switch/fesm2022/switch.mjs +7 -5
  92. package/switch/types/switch.d.ts +2 -1
@@ -0,0 +1,182 @@
1
+ # Form Slider (`@egose/shadcn-theme-ng/form-slider`)
2
+
3
+ A ready-made reactive-form numeric field: label + `hlm-slider` + validation error/hint display in one tag. The model is a `number[]` (one entry per thumb), matching `BrnSlider`.
4
+
5
+ The Angular implementation is a standalone wrapper: it renders `HlmFormField` / `HlmError` / `HlmHint` from `@egose/shadcn-theme-ng/form-field`, `HlmLabel`, and `HlmSlider` from `@egose/shadcn-theme-ng/slider`. The slider is bound with `[formControlName]="controlName()"`, so the parent `FormGroup` owns the value. It must live inside a `FormGroupDirective` (`[formGroup]` parent); ids come from `HlmFormIdGenerator` unless overridden.
6
+
7
+ > **Ships as:** `@egose/shadcn-theme-ng/form-slider` and `@egose/shadcn-theme-ng-tw/form-slider`
8
+ > (the `tw:`-prefixed Tailwind variant). Both expose the identical TypeScript surface; only the
9
+ > emitted Tailwind class strings differ. See the [package README](../../README.md) for install
10
+ > steps, peer dependencies, and Tailwind setup. Do not publish this project directory independently.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ # Plain Tailwind (no prefix)
16
+ npm install @egose/shadcn-theme-ng
17
+
18
+ # tw:-prefixed Tailwind variant
19
+ npm install @egose/shadcn-theme-ng-tw
20
+ ```
21
+
22
+ Peer dependencies (Angular, `@spartan-ng/brain`, `rxjs`, …) are documented in the
23
+ [package README](../../README.md#peer-dependencies). This subpath additionally relies at runtime on
24
+ `@egose/shadcn-theme-ng/slider`, `@egose/shadcn-theme-ng/form-field`, and
25
+ `@egose/shadcn-theme-ng/label`.
26
+
27
+ ## Imports
28
+
29
+ Exported from the subpath root (`projects/form-slider/src/public-api.ts`):
30
+
31
+ ```ts
32
+ import { EgFormSlider, provideEgFormSliderConfig } from '@egose/shadcn-theme-ng/form-slider';
33
+ // tw variant: replace with '@egose/shadcn-theme-ng-tw/form-slider'
34
+ ```
35
+
36
+ Standalone usage:
37
+
38
+ ```ts
39
+ import { Component } from '@angular/core';
40
+ import { ReactiveFormsModule } from '@angular/forms';
41
+ import { EgFormSlider } from '@egose/shadcn-theme-ng/form-slider';
42
+
43
+ @Component({
44
+ selector: 'app-demo',
45
+ standalone: true,
46
+ imports: [ReactiveFormsModule, EgFormSlider],
47
+ template: `...`,
48
+ })
49
+ export class DemoComponent {}
50
+ ```
51
+
52
+ NgModule-based consumer: add `EgFormSlider` (and `ReactiveFormsModule`) to the module's
53
+ `imports` — it is a standalone component, not a module.
54
+
55
+ `ControlValueAccessor` behavior: `eg-form-slider` itself is not a `ControlValueAccessor`; the
56
+ inner `hlm-slider` is (bound via `formControlName`), so `formControlName`/`formGroup` handling,
57
+ `Validators`, and `disabled` state from the control all flow through the parent form. Thumb count
58
+ follows the model array length (e.g. `[20, 80]` renders two thumbs).
59
+
60
+ ## Anatomy / Structure
61
+
62
+ ```html
63
+ <form [formGroup]="form">
64
+ <eg-form-slider controlName="volume" label="Volume" [min]="0" [max]="100" [step]="5" />
65
+ </form>
66
+ ```
67
+
68
+ Selector (from source): `eg-form-slider` (standalone component, host `tw:w-full`).
69
+
70
+ ## API reference
71
+
72
+ ### `EgFormSlider` — `eg-form-slider`
73
+
74
+ | Input | Type | Default | Description |
75
+ | ------------- | --------------------- | ------- | ------------------------------------------------------------------ |
76
+ | `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.** |
77
+ | `label` | `string \| undefined` | — | Label text (hidden when omitted). |
78
+ | `error` | `string \| undefined` | — | Error text shown when invalid. |
79
+ | `hint` | `string \| undefined` | — | Hint text shown otherwise. |
80
+ | `controlId` | `string \| undefined` | — | Explicit id (first priority for `effectiveId`). |
81
+ | `id` | `string \| undefined` | — | Fallback id (second priority). |
82
+ | `min` | `number` | `0` | Minimum value forwarded to the slider. |
83
+ | `max` | `number` | `100` | Maximum value forwarded to the slider. |
84
+ | `step` | `number` | `1` | Step value forwarded to the slider. |
85
+ | `disabled` | `boolean` | `false` | Locks interaction (form control stays enabled). |
86
+ | `required` | `boolean` | `false` | Shows a red `*` next to the label. |
87
+ | `class` | `ClassValue` | `''` | Extra host classes (base `tw:w-full`). |
88
+ | `labelClass` | `string` | `''` | Extra label classes (base `tw:mb-1`). |
89
+ | `sliderClass` | `string` | `''` | Extra slider classes (base `tw:w-full`). |
90
+ | `errorClass` | `string` | `''` | Extra error classes (base `tw:mt-0`). |
91
+ | `hintClass` | `string` | `''` | Extra hint classes (base `tw:mt-0`). |
92
+
93
+ | Member | Description |
94
+ | -------------------- | -------------------------------------------------------------- |
95
+ | `effectiveId` | `controlId() \|\| id() \|\| generated` — wired to slider `id`. |
96
+ | `labelId` | `effectiveId + '-label'` — referenced by `aria-labelledby`. |
97
+ | `errorId` / `hintId` | `effectiveId + '-error' / '-hint'`. |
98
+
99
+ Requires a `[formGroup]` ancestor (injects `FormGroupDirective`, provides `ControlContainer → FormGroupDirective`).
100
+
101
+ ## Examples
102
+
103
+ ### 1. Basic volume slider
104
+
105
+ ```ts
106
+ import { Component, inject } from '@angular/core';
107
+ import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
108
+ import { EgFormSlider } from '@egose/shadcn-theme-ng/form-slider';
109
+
110
+ @Component({
111
+ selector: 'app-volume',
112
+ standalone: true,
113
+ imports: [ReactiveFormsModule, EgFormSlider],
114
+ template: `
115
+ <form [formGroup]="form">
116
+ <eg-form-slider controlName="volume" label="Volume" [min]="0" [max]="100" [step]="5" />
117
+ <p>Volume is {{ form.value.volume?.[0] }}.</p>
118
+ </form>
119
+ `,
120
+ })
121
+ export class VolumeComponent {
122
+ private readonly fb = inject(FormBuilder);
123
+ readonly form = this.fb.group({ volume: [[20] as number[]] });
124
+ }
125
+ ```
126
+
127
+ ### 2. Price range (two thumbs)
128
+
129
+ ```ts
130
+ import { Component, inject } from '@angular/core';
131
+ import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
132
+ import { EgFormSlider } from '@egose/shadcn-theme-ng/form-slider';
133
+
134
+ @Component({
135
+ selector: 'app-price',
136
+ standalone: true,
137
+ imports: [ReactiveFormsModule, EgFormSlider],
138
+ template: `
139
+ <form [formGroup]="form">
140
+ <eg-form-slider
141
+ controlName="price"
142
+ label="Price range"
143
+ [min]="0"
144
+ [max]="500"
145
+ [step]="10"
146
+ hint="Drag either thumb."
147
+ />
148
+ </form>
149
+ `,
150
+ })
151
+ export class PriceComponent {
152
+ private readonly fb = inject(FormBuilder);
153
+ readonly form = this.fb.group({ price: [[50, 300] as number[]] });
154
+ }
155
+ ```
156
+
157
+ ## Accessibility notes
158
+
159
+ - The label is linked via `aria-labelledby` (sliders have no `for`-compatible control); always pass a `label`.
160
+ - `BrnSlider` currently accepts but does not render `aria-labelledby` on its host — the binding documents intent and activates if upstream renders it. Error/hint ids render without an input-level `describedby` link for the same reason.
161
+
162
+ ## Theming / CSS variables
163
+
164
+ No component-specific CSS variables. Style per-instance via `class` / `labelClass` / `sliderClass` / `errorClass` / `hintClass` (precedence: library base < global config < per-instance).
165
+
166
+ Global defaults per styling slot via the wrapper config:
167
+
168
+ ```ts
169
+ import { provideEgFormSliderConfig } from '@egose/shadcn-theme-ng/form-slider';
170
+
171
+ await bootstrapApplication(App, {
172
+ providers: [provideEgFormSliderConfig({ labelClass: 'tw:font-medium' })],
173
+ });
174
+ ```
175
+
176
+ The host keeps `tw:w-full`; constrain width with `class` (e.g. `tw:max-w-sm`) or a wrapping container.
177
+
178
+ ## Related subpaths
179
+
180
+ - `@egose/shadcn-theme-ng/slider` — raw `hlm-slider` for custom layouts.
181
+ - `@egose/shadcn-theme-ng/form-field` — `hlm-form-field` / `hlm-error` / `hlm-hint` used internally.
182
+ - `@egose/shadcn-theme-ng/form-field-simple` — alternative minimal wrapper when you compose controls by hand.
@@ -0,0 +1,186 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, inject, input, numberAttribute, computed, Component } from '@angular/core';
3
+ import * as i1 from '@angular/forms';
4
+ import { FormGroupDirective, ReactiveFormsModule, ControlContainer } from '@angular/forms';
5
+ import { HlmFormIdGenerator, HlmFormField, HlmError, HlmHint } from '@egose/shadcn-theme-ng-tw/form-field';
6
+ import { HlmLabel } from '@egose/shadcn-theme-ng-tw/label';
7
+ import { HlmSlider } from '@egose/shadcn-theme-ng-tw/slider';
8
+ import { hlm } from '@egose/shadcn-theme-ng-tw/utils';
9
+
10
+ const EgFormSliderConfigToken = new InjectionToken('EgFormSliderConfig');
11
+ function provideEgFormSliderConfig(config) {
12
+ return { provide: EgFormSliderConfigToken, useValue: { ...config } };
13
+ }
14
+ function injectEgFormSliderConfig() {
15
+ return inject(EgFormSliderConfigToken, { optional: true }) ?? {};
16
+ }
17
+
18
+ class EgFormSlider {
19
+ formGroupDirective = inject(FormGroupDirective);
20
+ generatedId = inject(HlmFormIdGenerator).generate('eg-form-slider');
21
+ _config = injectEgFormSliderConfig();
22
+ label = input(undefined, /* @ts-ignore */
23
+ ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
24
+ controlId = input(undefined, /* @ts-ignore */
25
+ ...(ngDevMode ? [{ debugName: "controlId" }] : /* istanbul ignore next */ []));
26
+ controlName = input('', /* @ts-ignore */
27
+ ...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
28
+ error = input(undefined, /* @ts-ignore */
29
+ ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
30
+ hint = input(undefined, /* @ts-ignore */
31
+ ...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
32
+ id = input(undefined, /* @ts-ignore */
33
+ ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
34
+ disabled = input(false, /* @ts-ignore */
35
+ ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
36
+ required = input(false, /* @ts-ignore */
37
+ ...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
38
+ min = input(0, { ...(ngDevMode ? { debugName: "min" } : /* istanbul ignore next */ {}), transform: numberAttribute });
39
+ max = input(100, { ...(ngDevMode ? { debugName: "max" } : /* istanbul ignore next */ {}), transform: numberAttribute });
40
+ step = input(1, { ...(ngDevMode ? { debugName: "step" } : /* istanbul ignore next */ {}), transform: numberAttribute });
41
+ effectiveId = computed(() => this.controlId() || this.id() || this.generatedId, /* @ts-ignore */
42
+ ...(ngDevMode ? [{ debugName: "effectiveId" }] : /* istanbul ignore next */ []));
43
+ labelId = computed(() => `${this.effectiveId()}-label`, /* @ts-ignore */
44
+ ...(ngDevMode ? [{ debugName: "labelId" }] : /* istanbul ignore next */ []));
45
+ errorId = computed(() => `${this.effectiveId()}-error`, /* @ts-ignore */
46
+ ...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
47
+ hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
48
+ ...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
49
+ /**
50
+ * Combined lock for the brain `linkedSignal`-based disabled state: the raw
51
+ * input write always carries the resolved value, so a same-pass
52
+ * wrapper-toggle + `control.disable()` cannot clobber CVA state.
53
+ */
54
+ effectiveDisabled() {
55
+ return this.disabled() || !!this.formGroupDirective.form.get(this.controlName())?.disabled;
56
+ }
57
+ // NOTE: BrnSlider exposes aria-labelledby but no aria-describedby, so error/hint
58
+ // ids render for sighted users without an input-level describedby link.
59
+ // Styling
60
+ userClass = input('', { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: 'class' });
61
+ labelClass = input('', /* @ts-ignore */
62
+ ...(ngDevMode ? [{ debugName: "labelClass" }] : /* istanbul ignore next */ []));
63
+ sliderClass = input('', /* @ts-ignore */
64
+ ...(ngDevMode ? [{ debugName: "sliderClass" }] : /* istanbul ignore next */ []));
65
+ errorClass = input('', /* @ts-ignore */
66
+ ...(ngDevMode ? [{ debugName: "errorClass" }] : /* istanbul ignore next */ []));
67
+ hintClass = input('', /* @ts-ignore */
68
+ ...(ngDevMode ? [{ debugName: "hintClass" }] : /* istanbul ignore next */ []));
69
+ // Computed classes (library base < global config < per-instance)
70
+ $userClass = computed(() => hlm('tw:w-full', this.userClass()), /* @ts-ignore */
71
+ ...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
72
+ $labelClass = computed(() => hlm('tw:mb-1', this._config.labelClass, this.labelClass()), /* @ts-ignore */
73
+ ...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
74
+ $sliderClass = computed(() => hlm('tw:w-full', this._config.sliderClass, this.sliderClass()), /* @ts-ignore */
75
+ ...(ngDevMode ? [{ debugName: "$sliderClass" }] : /* istanbul ignore next */ []));
76
+ $errorClass = computed(() => hlm('tw:mt-0', this._config.errorClass, this.errorClass()), /* @ts-ignore */
77
+ ...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
78
+ $hintClass = computed(() => hlm('tw:mt-0', this._config.hintClass, this.hintClass()), /* @ts-ignore */
79
+ ...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
80
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormSlider, deps: [], target: i0.ɵɵFactoryTarget.Component });
81
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormSlider, isStandalone: true, selector: "eg-form-slider", 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 }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", 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 }, sliderClass: { classPropertyName: "sliderClass", publicName: "sliderClass", 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: `
82
+ @let lbl = label();
83
+ @let cnm = controlName();
84
+ @let err = error();
85
+ @let hnt = hint();
86
+ @let rqrd = required();
87
+
88
+ <hlm-form-field>
89
+ @if (lbl) {
90
+ <label hlmLabel [id]="labelId()" [class]="$labelClass()"
91
+ >{{ lbl }}
92
+ @if (rqrd) {
93
+ <span class="tw:text-red-500">*</span>
94
+ }
95
+ </label>
96
+ }
97
+
98
+ <hlm-slider
99
+ [id]="effectiveId()"
100
+ [formControlName]="cnm"
101
+ [min]="min()"
102
+ [max]="max()"
103
+ [step]="step()"
104
+ [disabled]="effectiveDisabled()"
105
+ [aria-labelledby]="lbl ? labelId() : null"
106
+ [class]="$sliderClass()"
107
+ />
108
+
109
+ @if (err) {
110
+ <hlm-error [id]="errorId()" [class]="$errorClass()">
111
+ {{ err }}
112
+ </hlm-error>
113
+ }
114
+
115
+ @if (hnt) {
116
+ <hlm-hint [id]="hintId()" [class]="$hintClass()">
117
+ {{ hnt }}
118
+ </hlm-hint>
119
+ }
120
+ </hlm-form-field>
121
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: HlmFormField, selector: "hlm-form-field", inputs: ["class"] }, { kind: "directive", type: HlmError, selector: "hlm-error", inputs: ["class"] }, { kind: "directive", type: HlmHint, selector: "hlm-hint", inputs: ["class"] }, { kind: "directive", type: HlmLabel, selector: "[hlmLabel]", inputs: ["class"] }, { kind: "component", type: HlmSlider, selector: "hlm-slider, brn-slider [hlm]" }] });
122
+ }
123
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormSlider, decorators: [{
124
+ type: Component,
125
+ args: [{
126
+ selector: 'eg-form-slider',
127
+ standalone: true,
128
+ host: {
129
+ '[class]': '$userClass()',
130
+ },
131
+ imports: [ReactiveFormsModule, HlmFormField, HlmError, HlmHint, HlmLabel, HlmSlider],
132
+ providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
133
+ template: `
134
+ @let lbl = label();
135
+ @let cnm = controlName();
136
+ @let err = error();
137
+ @let hnt = hint();
138
+ @let rqrd = required();
139
+
140
+ <hlm-form-field>
141
+ @if (lbl) {
142
+ <label hlmLabel [id]="labelId()" [class]="$labelClass()"
143
+ >{{ lbl }}
144
+ @if (rqrd) {
145
+ <span class="tw:text-red-500">*</span>
146
+ }
147
+ </label>
148
+ }
149
+
150
+ <hlm-slider
151
+ [id]="effectiveId()"
152
+ [formControlName]="cnm"
153
+ [min]="min()"
154
+ [max]="max()"
155
+ [step]="step()"
156
+ [disabled]="effectiveDisabled()"
157
+ [aria-labelledby]="lbl ? labelId() : null"
158
+ [class]="$sliderClass()"
159
+ />
160
+
161
+ @if (err) {
162
+ <hlm-error [id]="errorId()" [class]="$errorClass()">
163
+ {{ err }}
164
+ </hlm-error>
165
+ }
166
+
167
+ @if (hnt) {
168
+ <hlm-hint [id]="hintId()" [class]="$hintClass()">
169
+ {{ hnt }}
170
+ </hlm-hint>
171
+ }
172
+ </hlm-form-field>
173
+ `,
174
+ }]
175
+ }], 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 }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], sliderClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "sliderClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
176
+
177
+ /*
178
+ * Public API Surface of form-slider
179
+ */
180
+
181
+ /**
182
+ * Generated bundle index. Do not edit.
183
+ */
184
+
185
+ export { EgFormSlider, injectEgFormSliderConfig, provideEgFormSliderConfig };
186
+
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "form-slider",
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-slider.mjs",
13
+ "typings": "types/form-slider.d.ts",
14
+ "exports": {
15
+ "./package.json": {
16
+ "default": "./package.json"
17
+ },
18
+ ".": {
19
+ "types": "./types/form-slider.d.ts",
20
+ "default": "./fesm2022/form-slider.mjs"
21
+ }
22
+ },
23
+ "type": "module"
24
+ }
@@ -0,0 +1,60 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { ValueProvider } from '@angular/core';
3
+ import { ClassValue } from 'clsx';
4
+ import { NumberInput } from '@angular/cdk/coercion';
5
+
6
+ declare class EgFormSlider {
7
+ private readonly formGroupDirective;
8
+ private readonly generatedId;
9
+ private readonly _config;
10
+ label: _angular_core.InputSignal<string | undefined>;
11
+ controlId: _angular_core.InputSignal<string | undefined>;
12
+ controlName: _angular_core.InputSignal<string>;
13
+ error: _angular_core.InputSignal<string | undefined>;
14
+ hint: _angular_core.InputSignal<string | undefined>;
15
+ id: _angular_core.InputSignal<string | undefined>;
16
+ disabled: _angular_core.InputSignal<boolean>;
17
+ required: _angular_core.InputSignal<boolean>;
18
+ min: _angular_core.InputSignalWithTransform<number, NumberInput>;
19
+ max: _angular_core.InputSignalWithTransform<number, NumberInput>;
20
+ step: _angular_core.InputSignalWithTransform<number, NumberInput>;
21
+ readonly effectiveId: _angular_core.Signal<string>;
22
+ readonly labelId: _angular_core.Signal<string>;
23
+ readonly errorId: _angular_core.Signal<string>;
24
+ readonly hintId: _angular_core.Signal<string>;
25
+ /**
26
+ * Combined lock for the brain `linkedSignal`-based disabled state: the raw
27
+ * input write always carries the resolved value, so a same-pass
28
+ * wrapper-toggle + `control.disable()` cannot clobber CVA state.
29
+ */
30
+ effectiveDisabled(): boolean;
31
+ userClass: _angular_core.InputSignal<ClassValue>;
32
+ labelClass: _angular_core.InputSignal<string>;
33
+ sliderClass: _angular_core.InputSignal<string>;
34
+ errorClass: _angular_core.InputSignal<string>;
35
+ hintClass: _angular_core.InputSignal<string>;
36
+ $userClass: _angular_core.Signal<string>;
37
+ $labelClass: _angular_core.Signal<string>;
38
+ $sliderClass: _angular_core.Signal<string>;
39
+ $errorClass: _angular_core.Signal<string>;
40
+ $hintClass: _angular_core.Signal<string>;
41
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormSlider, never>;
42
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormSlider, "eg-form-slider", 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; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "step": { "alias": "step"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "sliderClass": { "alias": "sliderClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
43
+ }
44
+
45
+ interface EgFormSliderConfig {
46
+ /**
47
+ * Global class defaults for `eg-form-slider` styling slots.
48
+ * Each is merged under the matching per-instance `*Class` input
49
+ * (library base < global config < per-instance).
50
+ */
51
+ labelClass?: string;
52
+ sliderClass?: string;
53
+ errorClass?: string;
54
+ hintClass?: string;
55
+ }
56
+ declare function provideEgFormSliderConfig(config: Partial<EgFormSliderConfig>): ValueProvider;
57
+ declare function injectEgFormSliderConfig(): EgFormSliderConfig;
58
+
59
+ export { EgFormSlider, injectEgFormSliderConfig, provideEgFormSliderConfig };
60
+ export type { EgFormSliderConfig };
@@ -0,0 +1,173 @@
1
+ # Form Switch (`@egose/shadcn-theme-ng/form-switch`)
2
+
3
+ A ready-made reactive-form boolean field: `hlm-switch` + label + validation error/hint display in one tag. The switch equivalent of `eg-form-checkbox` for on/off settings.
4
+
5
+ The Angular implementation is a standalone wrapper: it renders `EgFormField` from `@egose/shadcn-theme-ng/form-field-simple` (like `eg-form-checkbox`, because `hlm-switch` exposes no `BrnFieldControl`), `HlmError` / `HlmHint`, `HlmLabel`, and `HlmSwitch` from `@egose/shadcn-theme-ng/switch`. The inner switch is bound with `[formControlName]="controlName()"`, so the parent `FormGroup` owns the `boolean` value. It must live inside a `FormGroupDirective` (`[formGroup]` parent); ids come from `HlmFormIdGenerator` unless overridden.
6
+
7
+ > **Ships as:** `@egose/shadcn-theme-ng/form-switch` and `@egose/shadcn-theme-ng-tw/form-switch`
8
+ > (the `tw:`-prefixed Tailwind variant). Both expose the identical TypeScript surface; only the
9
+ > emitted Tailwind class strings differ. See the [package README](../../README.md) for install
10
+ > steps, peer dependencies, and Tailwind setup. Do not publish this project directory independently.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ # Plain Tailwind (no prefix)
16
+ npm install @egose/shadcn-theme-ng
17
+
18
+ # tw:-prefixed Tailwind variant
19
+ npm install @egose/shadcn-theme-ng-tw
20
+ ```
21
+
22
+ Peer dependencies (Angular, `@spartan-ng/brain`, `rxjs`, …) are documented in the
23
+ [package README](../../README.md#peer-dependencies). This subpath additionally relies at runtime on
24
+ `@egose/shadcn-theme-ng/switch`, `@egose/shadcn-theme-ng/form-field`, `@egose/shadcn-theme-ng/form-field-simple`, and
25
+ `@egose/shadcn-theme-ng/label`.
26
+
27
+ ## Imports
28
+
29
+ Exported from the subpath root (`projects/form-switch/src/public-api.ts`):
30
+
31
+ ```ts
32
+ import { EgFormSwitch, provideEgFormSwitchConfig } from '@egose/shadcn-theme-ng/form-switch';
33
+ // tw variant: replace with '@egose/shadcn-theme-ng-tw/form-switch'
34
+ ```
35
+
36
+ Standalone usage:
37
+
38
+ ```ts
39
+ import { Component } from '@angular/core';
40
+ import { ReactiveFormsModule } from '@angular/forms';
41
+ import { EgFormSwitch } from '@egose/shadcn-theme-ng/form-switch';
42
+
43
+ @Component({
44
+ selector: 'app-demo',
45
+ standalone: true,
46
+ imports: [ReactiveFormsModule, EgFormSwitch],
47
+ template: `...`,
48
+ })
49
+ export class DemoComponent {}
50
+ ```
51
+
52
+ NgModule-based consumer: add `EgFormSwitch` (and `ReactiveFormsModule`) to the module's
53
+ `imports` — it is a standalone component, not a module.
54
+
55
+ `ControlValueAccessor` behavior: `eg-form-switch` itself is not a `ControlValueAccessor`; the
56
+ inner `hlm-switch` is (bound via `formControlName`), so `formControlName`/`formGroup` handling,
57
+ `Validators`, and `disabled` state from the control all flow through the parent form.
58
+
59
+ ## Anatomy / Structure
60
+
61
+ ```html
62
+ <form [formGroup]="form">
63
+ <eg-form-switch controlName="notifications" label="Email notifications" hint="Toggle to subscribe." />
64
+ </form>
65
+ ```
66
+
67
+ Selector (from source): `eg-form-switch` (standalone component, host `tw:w-full`).
68
+
69
+ ## API reference
70
+
71
+ ### `EgFormSwitch` — `eg-form-switch`
72
+
73
+ | Input | Type | Default | Description |
74
+ | ------------- | --------------------- | ------- | ------------------------------------------------------------------ |
75
+ | `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.** |
76
+ | `label` | `string \| undefined` | — | Label text beside the switch (hidden when omitted). |
77
+ | `error` | `string \| undefined` | — | Error text shown when invalid. |
78
+ | `hint` | `string \| undefined` | — | Hint text shown otherwise. |
79
+ | `controlId` | `string \| undefined` | — | Explicit id (first priority for `effectiveId`). |
80
+ | `id` | `string \| undefined` | — | Fallback id (second priority). |
81
+ | `disabled` | `boolean` | `false` | Locks interaction (form control stays enabled). |
82
+ | `required` | `boolean` | `false` | Shows a red `*` next to the label; forwarded to the switch. |
83
+ | `class` | `ClassValue` | `''` | Extra host classes (base `tw:w-full`). |
84
+ | `switchClass` | `string` | `''` | Extra switch classes, merged into `HlmSwitch.userClass`. |
85
+ | `labelClass` | `string` | `''` | Extra label classes. |
86
+ | `errorClass` | `string` | `''` | Extra error classes (base `tw:mt-0`). |
87
+ | `hintClass` | `string` | `''` | Extra hint classes (base `tw:mt-0`). |
88
+
89
+ | Member | Description |
90
+ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
91
+ | `effectiveId` | `controlId() \|\| id() \|\| generated` — wired to switch `id` and label `for`. |
92
+ | `errorId` / `hintId` | `effectiveId + '-error' / '-hint'`. |
93
+ | `describedBy()` | `errorId` when `error()` is set and control is invalid + dirty/touched, else `hintId` when `hint()` is set, else `null` — wired to switch `aria-describedby`. |
94
+
95
+ Requires a `[formGroup]` ancestor (injects `FormGroupDirective`, provides `ControlContainer → FormGroupDirective`).
96
+
97
+ ## Examples
98
+
99
+ ### 1. Basic settings toggle
100
+
101
+ ```ts
102
+ import { Component, inject } from '@angular/core';
103
+ import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
104
+ import { EgFormSwitch } from '@egose/shadcn-theme-ng/form-switch';
105
+
106
+ @Component({
107
+ selector: 'app-settings',
108
+ standalone: true,
109
+ imports: [ReactiveFormsModule, EgFormSwitch],
110
+ template: `
111
+ <form [formGroup]="form">
112
+ <eg-form-switch controlName="notifications" label="Email notifications" hint="Toggle to subscribe." />
113
+ </form>
114
+ `,
115
+ })
116
+ export class SettingsComponent {
117
+ private readonly fb = inject(FormBuilder);
118
+ readonly form = this.fb.group({ notifications: [true] });
119
+ }
120
+ ```
121
+
122
+ ### 2. Required opt-in with error
123
+
124
+ ```ts
125
+ import { Component, inject } from '@angular/core';
126
+ import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
127
+ import { EgFormSwitch } from '@egose/shadcn-theme-ng/form-switch';
128
+
129
+ @Component({
130
+ selector: 'app-consent',
131
+ standalone: true,
132
+ imports: [ReactiveFormsModule, EgFormSwitch],
133
+ template: `
134
+ <form [formGroup]="form" (ngSubmit)="submit()">
135
+ <eg-form-switch controlName="consent" label="I accept the terms" [required]="true" error="Consent is required." />
136
+ <button type="submit" [disabled]="form.invalid">Continue</button>
137
+ </form>
138
+ `,
139
+ })
140
+ export class ConsentComponent {
141
+ private readonly fb = inject(FormBuilder);
142
+ readonly form = this.fb.group({ consent: [false, Validators.requiredTrue] });
143
+ submit() {
144
+ console.log(this.form.value.consent);
145
+ }
146
+ }
147
+ ```
148
+
149
+ ## Accessibility notes
150
+
151
+ - Label `for` ↔ switch `id` wiring is automatic via `effectiveId`; the switch also receives `aria-describedby` (error/hint id) — always pass a `label`.
152
+ - The required `*` is visual; pair with `Validators.requiredTrue` so assistive tech and validation agree.
153
+
154
+ ## Theming / CSS variables
155
+
156
+ No component-specific CSS variables. Style per-instance via `class` / `switchClass` / `labelClass` / `errorClass` / `hintClass` (precedence: library base < global config < per-instance). The row layout (`flex items-center gap-1`) is fixed in the template.
157
+
158
+ Global defaults per styling slot via the wrapper config:
159
+
160
+ ```ts
161
+ import { provideEgFormSwitchConfig } from '@egose/shadcn-theme-ng/form-switch';
162
+
163
+ await bootstrapApplication(App, {
164
+ providers: [provideEgFormSwitchConfig({ labelClass: 'tw:font-medium' })],
165
+ });
166
+ ```
167
+
168
+ ## Related subpaths
169
+
170
+ - `@egose/shadcn-theme-ng/switch` — raw `hlm-switch` for custom layouts.
171
+ - `@egose/shadcn-theme-ng/form-checkbox` — the checkbox counterpart (`eg-form-checkbox`).
172
+ - `@egose/shadcn-theme-ng/form-field` — `hlm-error` / `hlm-hint` used internally.
173
+ - `@egose/shadcn-theme-ng/form-field-simple` — `eg-form-field` used internally.