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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +1 -1
  2. package/alert/fesm2022/alert.mjs +1 -1
  3. package/autocomplete/fesm2022/autocomplete.mjs +1 -1
  4. package/button/fesm2022/button.mjs +3 -3
  5. package/checkbox/fesm2022/checkbox.mjs +6 -7
  6. package/checkbox/types/checkbox.d.ts +1 -1
  7. package/combobox/fesm2022/combobox.mjs +1 -1
  8. package/date-picker/README.md +15 -11
  9. package/date-picker/fesm2022/date-picker.mjs +148 -30
  10. package/date-picker/types/date-picker.d.ts +102 -9
  11. package/form-autocomplete/README.md +178 -0
  12. package/form-autocomplete/fesm2022/form-autocomplete.mjs +243 -0
  13. package/form-autocomplete/package.json +24 -0
  14. package/form-autocomplete/types/form-autocomplete.d.ts +81 -0
  15. package/form-checkbox/README.md +29 -18
  16. package/form-checkbox/fesm2022/form-checkbox.mjs +62 -22
  17. package/form-checkbox/types/form-checkbox.d.ts +43 -4
  18. package/form-combobox/README.md +203 -0
  19. package/form-combobox/fesm2022/form-combobox.mjs +305 -0
  20. package/form-combobox/package.json +24 -0
  21. package/form-combobox/types/form-combobox.d.ts +93 -0
  22. package/form-date-picker/README.md +49 -22
  23. package/form-date-picker/fesm2022/form-date-picker.mjs +100 -29
  24. package/form-date-picker/types/form-date-picker.d.ts +37 -1
  25. package/form-date-picker-multi/README.md +192 -0
  26. package/form-date-picker-multi/fesm2022/form-date-picker-multi.mjs +266 -0
  27. package/form-date-picker-multi/package.json +24 -0
  28. package/form-date-picker-multi/types/form-date-picker-multi.d.ts +78 -0
  29. package/form-date-range-picker/README.md +254 -0
  30. package/form-date-range-picker/fesm2022/form-date-range-picker.mjs +263 -0
  31. package/form-date-range-picker/package.json +24 -0
  32. package/form-date-range-picker/types/form-date-range-picker.d.ts +75 -0
  33. package/form-field/README.md +9 -0
  34. package/form-field/fesm2022/form-field.mjs +80 -5
  35. package/form-field/types/form-field.d.ts +50 -2
  36. package/form-field-simple/fesm2022/form-field-simple.mjs +15 -1
  37. package/form-field-simple/types/form-field-simple.d.ts +9 -2
  38. package/form-input-otp/README.md +195 -0
  39. package/form-input-otp/fesm2022/form-input-otp.mjs +226 -0
  40. package/form-input-otp/package.json +24 -0
  41. package/form-input-otp/types/form-input-otp.d.ts +78 -0
  42. package/form-month-year-picker/README.md +189 -0
  43. package/form-month-year-picker/fesm2022/form-month-year-picker.mjs +256 -0
  44. package/form-month-year-picker/package.json +24 -0
  45. package/form-month-year-picker/types/form-month-year-picker.d.ts +73 -0
  46. package/form-native-select/README.md +206 -0
  47. package/form-native-select/fesm2022/form-native-select.mjs +226 -0
  48. package/form-native-select/package.json +24 -0
  49. package/form-native-select/types/form-native-select.d.ts +77 -0
  50. package/form-phone-input/README.md +189 -0
  51. package/form-phone-input/fesm2022/form-phone-input.mjs +230 -0
  52. package/form-phone-input/package.json +24 -0
  53. package/form-phone-input/types/form-phone-input.d.ts +78 -0
  54. package/form-radio-group/README.md +199 -0
  55. package/form-radio-group/fesm2022/form-radio-group.mjs +238 -0
  56. package/form-radio-group/package.json +24 -0
  57. package/form-radio-group/types/form-radio-group.d.ts +83 -0
  58. package/form-searchable-multiselect/README.md +28 -17
  59. package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs +60 -24
  60. package/form-searchable-multiselect/types/form-searchable-multiselect.d.ts +39 -2
  61. package/form-select/README.md +30 -19
  62. package/form-select/fesm2022/form-select.mjs +65 -29
  63. package/form-select/types/form-select.d.ts +39 -2
  64. package/form-slider/README.md +183 -0
  65. package/form-slider/fesm2022/form-slider.mjs +218 -0
  66. package/form-slider/package.json +24 -0
  67. package/form-slider/types/form-slider.d.ts +80 -0
  68. package/form-switch/README.md +174 -0
  69. package/form-switch/fesm2022/form-switch.mjs +205 -0
  70. package/form-switch/package.json +24 -0
  71. package/form-switch/types/form-switch.d.ts +70 -0
  72. package/form-text-input/README.md +37 -26
  73. package/form-text-input/fesm2022/form-text-input.mjs +60 -24
  74. package/form-text-input/types/form-text-input.d.ts +39 -2
  75. package/form-textarea/README.md +33 -22
  76. package/form-textarea/fesm2022/form-textarea.mjs +60 -24
  77. package/form-textarea/types/form-textarea.d.ts +39 -2
  78. package/form-toggle/README.md +187 -0
  79. package/form-toggle/fesm2022/form-toggle.mjs +275 -0
  80. package/form-toggle/package.json +24 -0
  81. package/form-toggle/types/form-toggle.d.ts +100 -0
  82. package/form-toggle-group/README.md +177 -0
  83. package/form-toggle-group/fesm2022/form-toggle-group.mjs +243 -0
  84. package/form-toggle-group/package.json +24 -0
  85. package/form-toggle-group/types/form-toggle-group.d.ts +85 -0
  86. package/input-group/fesm2022/input-group.mjs +20 -10
  87. package/input-group/types/input-group.d.ts +4 -1
  88. package/native-select/fesm2022/native-select.mjs +18 -6
  89. package/native-select/types/native-select.d.ts +7 -2
  90. package/package.json +57 -1
  91. package/phone-input/README.md +114 -0
  92. package/phone-input/fesm2022/phone-input.mjs +191 -0
  93. package/phone-input/package.json +24 -0
  94. package/phone-input/types/phone-input.d.ts +67 -0
  95. package/sheet/fesm2022/sheet.mjs +1 -1
  96. package/switch/fesm2022/switch.mjs +7 -5
  97. package/switch/types/switch.d.ts +2 -1
@@ -1,15 +1,24 @@
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 EgFormCheckbox {
5
6
  private readonly formGroupDirective;
7
+ private readonly _errorMessages;
6
8
  private readonly generatedId;
9
+ private readonly _config;
7
10
  readonly userClass: _angular_core.InputSignal<ClassValue>;
8
11
  protected readonly _computedClass: _angular_core.Signal<string>;
9
12
  label: _angular_core.InputSignal<string>;
10
13
  controlId: _angular_core.InputSignal<string | undefined>;
11
14
  controlName: _angular_core.InputSignal<string>;
12
15
  error: _angular_core.InputSignal<string | undefined>;
16
+ /**
17
+ * Auto-resolve the displayed message from the control's `ValidationErrors`
18
+ * when `error()` is unset. Explicit `error()` always wins. Set to `false`
19
+ * for manual-only messages.
20
+ */
21
+ autoError: _angular_core.InputSignal<boolean>;
13
22
  hint: _angular_core.InputSignal<string | undefined>;
14
23
  id: _angular_core.InputSignal<string | undefined>;
15
24
  name: _angular_core.InputSignal<string | undefined>;
@@ -19,15 +28,45 @@ declare class EgFormCheckbox {
19
28
  readonly effectiveId: _angular_core.Signal<string>;
20
29
  readonly errorId: _angular_core.Signal<string>;
21
30
  readonly hintId: _angular_core.Signal<string>;
31
+ /**
32
+ * Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
33
+ * auto-resolved from the control's `ValidationErrors`. Plain method (not a
34
+ * computed): `ValidationErrors` is not a signal, so the control must be read
35
+ * fresh on every change-detection pass.
36
+ */
37
+ protected resolvedError(): string | undefined;
38
+ /**
39
+ * Whether the error is surfaced: message present + control invalid +
40
+ * touched/dirty/submitted. Gates the visual `<hlm-error>` (and
41
+ * `describedBy()`, where present) so sighted and screen-reader output agree.
42
+ */
43
+ protected showError(): boolean;
22
44
  describedBy(): string | null;
23
45
  checkboxClass: _angular_core.InputSignal<string>;
24
46
  labelClass: _angular_core.InputSignal<string>;
47
+ errorClass: _angular_core.InputSignal<string>;
48
+ hintClass: _angular_core.InputSignal<string>;
25
49
  $checkboxClass: _angular_core.Signal<string>;
26
50
  $labelClass: _angular_core.Signal<string>;
27
- $errorClass: _angular_core.InputSignal<string>;
28
- $hintClass: _angular_core.InputSignal<string>;
51
+ $errorClass: _angular_core.Signal<string>;
52
+ $hintClass: _angular_core.Signal<string>;
29
53
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormCheckbox, never>;
30
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormCheckbox, "eg-form-checkbox", never, { "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "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; }; "checked": { "alias": "checked"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "checkboxClass": { "alias": "checkboxClass"; "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>;
54
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormCheckbox, "eg-form-checkbox", never, { "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "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; }; "checked": { "alias": "checked"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "checkboxClass": { "alias": "checkboxClass"; "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>;
31
55
  }
32
56
 
33
- export { EgFormCheckbox };
57
+ interface EgFormCheckboxConfig {
58
+ /**
59
+ * Global class defaults for `eg-form-checkbox` styling slots.
60
+ * Each is merged under the matching per-instance `*Class` input
61
+ * (library base < global config < per-instance).
62
+ */
63
+ checkboxClass?: string;
64
+ labelClass?: string;
65
+ errorClass?: string;
66
+ hintClass?: string;
67
+ }
68
+ declare function provideEgFormCheckboxConfig(config: Partial<EgFormCheckboxConfig>): ValueProvider;
69
+ declare function injectEgFormCheckboxConfig(): EgFormCheckboxConfig;
70
+
71
+ export { EgFormCheckbox, injectEgFormCheckboxConfig, provideEgFormCheckboxConfig };
72
+ export type { EgFormCheckboxConfig };
@@ -0,0 +1,203 @@
1
+ # Form Combobox (`@egose/shadcn-theme-ng/form-combobox`)
2
+
3
+ A ready-made reactive-form combobox: label + searchable dropdown + validation error/hint display in one tag. Supports `multiple` mode (chips anchor, `string[]` model, the default) and `single` mode (trigger button, `string | null` model).
4
+
5
+ The Angular implementation is a standalone wrapper: it renders `HlmFormField` / `HlmError` / `HlmHint` from `@egose/shadcn-theme-ng/form-field`, `HlmLabel`, and the `HlmCombobox*` parts from `@egose/shadcn-theme-ng/combobox` (`HlmComboboxMultiple` + chips for multi, `HlmCombobox` + trigger for single). The picker root is bound with `[formControlName]="controlName()"` (both brain variants implement `ControlValueAccessor`), 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-combobox` and `@egose/shadcn-theme-ng-tw/form-combobox`
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`, `@ng-icons/*`, `rxjs`, …) are documented in the
23
+ [package README](../../README.md#peer-dependencies). This subpath additionally relies at runtime on
24
+ `@egose/shadcn-theme-ng/combobox`, `@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-combobox/src/public-api.ts`):
30
+
31
+ ```ts
32
+ import { EgFormCombobox, provideEgFormComboboxConfig } from '@egose/shadcn-theme-ng/form-combobox';
33
+ // tw variant: replace with '@egose/shadcn-theme-ng-tw/form-combobox'
34
+ ```
35
+
36
+ ## Anatomy / Structure
37
+
38
+ ```html
39
+ <form [formGroup]="form">
40
+ <eg-form-combobox controlName="tags" label="Tags" [options]="tags" [required]="true" error="Pick at least one." />
41
+ </form>
42
+ ```
43
+
44
+ Selector (from source): `eg-form-combobox` (standalone component, host `tw:w-full`).
45
+
46
+ ## API reference
47
+
48
+ ### `EgFormCombobox` — `eg-form-combobox`
49
+
50
+ | Input | Type | Default | Description |
51
+ | -------------- | ------------------------ | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
52
+ | `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.** |
53
+ | `mode` | `'single' \| 'multiple'` | `'multiple'` | `multiple` renders chips + multi-select (`string[]`); `single` renders a trigger button (`string \| null`). |
54
+ | `label` | `string \| undefined` | — | Label text (hidden when omitted). |
55
+ | `error` | `string \| undefined` | — | Error text shown when invalid. |
56
+ | `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`. |
57
+ | `hint` | `string \| undefined` | — | Hint text shown otherwise. |
58
+ | `controlId` | `string \| undefined` | — | Explicit id (first priority for `effectiveId`). |
59
+ | `id` | `string \| undefined` | — | Fallback id (second priority). |
60
+ | `placeholder` | `string` | `'Pick…'` | Search input placeholder. |
61
+ | `emptyText` | `string` | `'Nothing left to add.'` | Text shown when no option matches. |
62
+ | `disabled` | `boolean` | `false` | Locks interaction (form control stays enabled). |
63
+ | `required` | `boolean` | `false` | Shows a red `*` next to the label. |
64
+ | `options` | `string[]` | `[]` | Rendered as `hlm-combobox-item` entries. |
65
+ | `class` | `ClassValue` | `''` | Extra host classes (base `tw:w-full`). |
66
+ | `labelClass` | `string` | `''` | Extra label classes (base `tw:mb-1`). |
67
+ | `controlClass` | `string` | `''` | Extra multi-root classes. |
68
+ | `chipsClass` | `string` | `''` | Extra chips-anchor classes. |
69
+ | `errorClass` | `string` | `''` | Extra error classes (base `tw:mt-0`). |
70
+ | `hintClass` | `string` | `''` | Extra hint classes (base `tw:mt-0`). |
71
+
72
+ | Member | Description |
73
+ | -------------------- | ---------------------------------------------------------------------------------- |
74
+ | `effectiveId` | `controlId() \|\| id() \|\| generated` — wired to chip-input `id` and label `for`. |
75
+ | `errorId` / `hintId` | `effectiveId + '-error' / '-hint'`. |
76
+ | `selectedValues` | Current selection read reactively from the brain model — drives chip rendering. |
77
+
78
+ Requires a `[formGroup]` ancestor (injects `FormGroupDirective`, provides `ControlContainer → FormGroupDirective`).
79
+
80
+ ## Examples
81
+
82
+ ### 1. Required multi-select
83
+
84
+ ```ts
85
+ import { Component, inject } from '@angular/core';
86
+ import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
87
+ import { EgFormCombobox } from '@egose/shadcn-theme-ng/form-combobox';
88
+
89
+ @Component({
90
+ selector: 'app-tags',
91
+ standalone: true,
92
+ imports: [ReactiveFormsModule, EgFormCombobox],
93
+ template: `
94
+ <form [formGroup]="form" (ngSubmit)="submit()">
95
+ <eg-form-combobox controlName="tags" label="Tags" [options]="tags" [required]="true" error="Pick at least one." />
96
+ <button type="submit" [disabled]="form.invalid">Save</button>
97
+ </form>
98
+ `,
99
+ })
100
+ export class TagsComponent {
101
+ private readonly fb = inject(FormBuilder);
102
+ readonly form = this.fb.group({ tags: [<string[]>[], Validators.required] });
103
+ readonly tags = ['Angular', 'React', 'Vue', 'Svelte'];
104
+ submit() {
105
+ console.log(this.form.value.tags);
106
+ }
107
+ }
108
+ ```
109
+
110
+ ### 2. Preselected with hint
111
+
112
+ ```ts
113
+ import { Component, inject } from '@angular/core';
114
+ import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
115
+ import { EgFormCombobox } from '@egose/shadcn-theme-ng/form-combobox';
116
+
117
+ @Component({
118
+ selector: 'app-stack',
119
+ standalone: true,
120
+ imports: [ReactiveFormsModule, EgFormCombobox],
121
+ template: `
122
+ <form [formGroup]="form">
123
+ <eg-form-combobox
124
+ controlName="stack"
125
+ label="Stack"
126
+ [options]="options"
127
+ placeholder="Add tag…"
128
+ hint="Type to filter, click to add, × to remove."
129
+ />
130
+ </form>
131
+ `,
132
+ })
133
+ export class StackComponent {
134
+ private readonly fb = inject(FormBuilder);
135
+ readonly form = this.fb.group({ stack: [['Angular']] });
136
+ readonly options = ['Angular', 'React', 'Vue', 'Svelte', 'Solid'];
137
+ }
138
+ ```
139
+
140
+ ### 3. Single-select dropdown
141
+
142
+ ```ts
143
+ import { Component, inject } from '@angular/core';
144
+ import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
145
+ import { EgFormCombobox } from '@egose/shadcn-theme-ng/form-combobox';
146
+
147
+ @Component({
148
+ selector: 'app-fruit-single',
149
+ standalone: true,
150
+ imports: [ReactiveFormsModule, EgFormCombobox],
151
+ template: `
152
+ <form [formGroup]="form" (ngSubmit)="submit()">
153
+ <eg-form-combobox
154
+ controlName="fruit"
155
+ label="Fruit"
156
+ mode="single"
157
+ [options]="options"
158
+ placeholder="Select a fruit…"
159
+ [required]="true"
160
+ error="Fruit is required."
161
+ />
162
+ <button type="submit" [disabled]="form.invalid">Save</button>
163
+ </form>
164
+ `,
165
+ })
166
+ export class FruitSingleComponent {
167
+ private readonly fb = inject(FormBuilder);
168
+ readonly form = this.fb.group({ fruit: [null as string | null, Validators.required] });
169
+ readonly options = ['Apple', 'Banana', 'Cherry'];
170
+ submit() {
171
+ console.log(this.form.value.fruit);
172
+ }
173
+ }
174
+ ```
175
+
176
+ ## Accessibility notes
177
+
178
+ - Label `for` ↔ chip-search-input `id` wiring is automatic via `effectiveId` — always pass a `label`.
179
+ - The chip search input exposes no `aria-describedby`, so error/hint ids render without an input-level link.
180
+ - The required `*` is visual; pair with `Validators.required` so assistive tech and validation agree.
181
+
182
+ ## Theming / CSS variables
183
+
184
+ No component-specific CSS variables. Style per-instance via `class` / `labelClass` / `controlClass` / `chipsClass` / `errorClass` / `hintClass` (precedence: library base < global config < per-instance).
185
+
186
+ Global defaults per styling slot via the wrapper config:
187
+
188
+ ```ts
189
+ import { provideEgFormComboboxConfig } from '@egose/shadcn-theme-ng/form-combobox';
190
+
191
+ await bootstrapApplication(App, {
192
+ providers: [provideEgFormComboboxConfig({ labelClass: 'tw:font-medium' })],
193
+ });
194
+ ```
195
+
196
+ The host keeps `tw:w-full`; constrain width with `class` or a wrapping container.
197
+
198
+ ## Related subpaths
199
+
200
+ - `@egose/shadcn-theme-ng/combobox` — raw `HlmCombobox*` parts (single + multi) for custom layouts.
201
+ - `@egose/shadcn-theme-ng/form-autocomplete` — single-value text-search counterpart (`eg-form-autocomplete`).
202
+ - `@egose/shadcn-theme-ng/form-searchable-multiselect` — alternative multi-select with popover checkboxes.
203
+ - `@egose/shadcn-theme-ng/form-field` — `hlm-form-field` / `hlm-error` / `hlm-hint` used internally.
@@ -0,0 +1,305 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, inject, viewChild, input, computed, Component } from '@angular/core';
3
+ import * as i1 from '@angular/forms';
4
+ import { FormGroupDirective, ReactiveFormsModule, ControlContainer } from '@angular/forms';
5
+ import { injectEgFormErrorMessages, HlmFormIdGenerator, resolveEgFormError, HlmFormField, HlmError, HlmHint } from '@egose/shadcn-theme-ng-tw/form-field';
6
+ import { HlmLabel } from '@egose/shadcn-theme-ng-tw/label';
7
+ import { HlmCombobox, HlmComboboxChip, HlmComboboxChipInput, HlmComboboxChips, HlmComboboxContent, HlmComboboxEmpty, HlmComboboxInput, HlmComboboxItem, HlmComboboxList, HlmComboboxMultiple, HlmComboboxPortal, HlmComboboxTrigger } from '@egose/shadcn-theme-ng-tw/combobox';
8
+ import { BrnComboboxMultiple, BrnCombobox } from '@spartan-ng/brain/combobox';
9
+ import { hlm } from '@egose/shadcn-theme-ng-tw/utils';
10
+
11
+ const EgFormComboboxConfigToken = new InjectionToken('EgFormComboboxConfig');
12
+ function provideEgFormComboboxConfig(config) {
13
+ return { provide: EgFormComboboxConfigToken, useValue: { ...config } };
14
+ }
15
+ function injectEgFormComboboxConfig() {
16
+ return inject(EgFormComboboxConfigToken, { optional: true }) ?? {};
17
+ }
18
+
19
+ class EgFormCombobox {
20
+ formGroupDirective = inject(FormGroupDirective);
21
+ _errorMessages = injectEgFormErrorMessages();
22
+ generatedId = inject(HlmFormIdGenerator).generate('eg-form-combobox');
23
+ _config = injectEgFormComboboxConfig();
24
+ _picker = viewChild((BrnComboboxMultiple), /* @ts-ignore */
25
+ ...(ngDevMode ? [{ debugName: "_picker" }] : /* istanbul ignore next */ []));
26
+ _single = viewChild((BrnCombobox), /* @ts-ignore */
27
+ ...(ngDevMode ? [{ debugName: "_single" }] : /* istanbul ignore next */ []));
28
+ label = input(undefined, /* @ts-ignore */
29
+ ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
30
+ controlId = input(undefined, /* @ts-ignore */
31
+ ...(ngDevMode ? [{ debugName: "controlId" }] : /* istanbul ignore next */ []));
32
+ controlName = input('', /* @ts-ignore */
33
+ ...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
34
+ error = input(undefined, /* @ts-ignore */
35
+ ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
36
+ /**
37
+ * Auto-resolve the displayed message from the control's `ValidationErrors`
38
+ * when `error()` is unset. Explicit `error()` always wins. Set to `false`
39
+ * for manual-only messages.
40
+ */
41
+ autoError = input(true, /* @ts-ignore */
42
+ ...(ngDevMode ? [{ debugName: "autoError" }] : /* istanbul ignore next */ []));
43
+ hint = input(undefined, /* @ts-ignore */
44
+ ...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
45
+ id = input(undefined, /* @ts-ignore */
46
+ ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
47
+ placeholder = input('Pick…', /* @ts-ignore */
48
+ ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
49
+ emptyText = input('Nothing left to add.', /* @ts-ignore */
50
+ ...(ngDevMode ? [{ debugName: "emptyText" }] : /* istanbul ignore next */ []));
51
+ disabled = input(false, /* @ts-ignore */
52
+ ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
53
+ required = input(false, /* @ts-ignore */
54
+ ...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
55
+ /**
56
+ * Selection mode. `multiple` renders chips + checkbox-style multi-select
57
+ * (`string[]` model); `single` renders a trigger button + dropdown
58
+ * (`string | null` model). Defaults to `multiple` (original behavior).
59
+ */
60
+ mode = input('multiple', /* @ts-ignore */
61
+ ...(ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []));
62
+ options = input([], /* @ts-ignore */
63
+ ...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
64
+ effectiveId = computed(() => this.controlId() || this.id() || this.generatedId, /* @ts-ignore */
65
+ ...(ngDevMode ? [{ debugName: "effectiveId" }] : /* istanbul ignore next */ []));
66
+ errorId = computed(() => `${this.effectiveId()}-error`, /* @ts-ignore */
67
+ ...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
68
+ hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
69
+ ...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
70
+ /**
71
+ * Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
72
+ * auto-resolved from the control's `ValidationErrors`. Plain method (not a
73
+ * computed): `ValidationErrors` is not a signal, so the control must be read
74
+ * fresh on every change-detection pass.
75
+ */
76
+ resolvedError() {
77
+ const explicit = this.error();
78
+ if (explicit)
79
+ return explicit;
80
+ if (!this.autoError())
81
+ return undefined;
82
+ const control = this.formGroupDirective.form.get(this.controlName());
83
+ return resolveEgFormError(control?.errors ?? null, this.label(), this._errorMessages);
84
+ }
85
+ /**
86
+ * Whether the error is surfaced: message present + control invalid +
87
+ * touched/dirty/submitted. Gates the visual `<hlm-error>` (and
88
+ * `describedBy()`, where present) so sighted and screen-reader output agree.
89
+ */
90
+ showError() {
91
+ const control = this.formGroupDirective.form.get(this.controlName());
92
+ return (!!this.resolvedError() &&
93
+ !!control?.invalid &&
94
+ (control.dirty || control.touched || this.formGroupDirective.submitted));
95
+ }
96
+ /** Selected values read reactively from the brain model so chips track selection. */
97
+ selectedValues = computed(() => this._picker()?.value() ?? [], /* @ts-ignore */
98
+ ...(ngDevMode ? [{ debugName: "selectedValues" }] : /* istanbul ignore next */ []));
99
+ /** Single-mode display value read reactively from the brain model. */
100
+ singleDisplay = computed(() => this._single()?.value() ?? null, /* @ts-ignore */
101
+ ...(ngDevMode ? [{ debugName: "singleDisplay" }] : /* istanbul ignore next */ []));
102
+ /**
103
+ * Combined lock for the brain `linkedSignal`-based disabled state: the raw
104
+ * input write always carries the resolved value, so a same-pass
105
+ * wrapper-toggle + `control.disable()` cannot clobber CVA state.
106
+ */
107
+ effectiveDisabled() {
108
+ return this.disabled() || !!this.formGroupDirective.form.get(this.controlName())?.disabled;
109
+ }
110
+ // Styling
111
+ userClass = input('', { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: 'class' });
112
+ labelClass = input('', /* @ts-ignore */
113
+ ...(ngDevMode ? [{ debugName: "labelClass" }] : /* istanbul ignore next */ []));
114
+ controlClass = input('', /* @ts-ignore */
115
+ ...(ngDevMode ? [{ debugName: "controlClass" }] : /* istanbul ignore next */ []));
116
+ chipsClass = input('', /* @ts-ignore */
117
+ ...(ngDevMode ? [{ debugName: "chipsClass" }] : /* istanbul ignore next */ []));
118
+ errorClass = input('', /* @ts-ignore */
119
+ ...(ngDevMode ? [{ debugName: "errorClass" }] : /* istanbul ignore next */ []));
120
+ hintClass = input('', /* @ts-ignore */
121
+ ...(ngDevMode ? [{ debugName: "hintClass" }] : /* istanbul ignore next */ []));
122
+ // Computed classes (library base < global config < per-instance).
123
+ // NOTE: the chip search input exposes no aria-describedby, so error/hint
124
+ // ids render without an input-level describedby link.
125
+ $userClass = computed(() => hlm('tw:w-full', this.userClass()), /* @ts-ignore */
126
+ ...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
127
+ $labelClass = computed(() => hlm('tw:mb-1', this._config.labelClass, this.labelClass()), /* @ts-ignore */
128
+ ...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
129
+ $controlClass = computed(() => hlm(this._config.controlClass, this.controlClass()), /* @ts-ignore */
130
+ ...(ngDevMode ? [{ debugName: "$controlClass" }] : /* istanbul ignore next */ []));
131
+ $chipsClass = computed(() => hlm(this._config.chipsClass, this.chipsClass()), /* @ts-ignore */
132
+ ...(ngDevMode ? [{ debugName: "$chipsClass" }] : /* istanbul ignore next */ []));
133
+ $errorClass = computed(() => hlm('tw:mt-0', this._config.errorClass, this.errorClass()), /* @ts-ignore */
134
+ ...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
135
+ $hintClass = computed(() => hlm('tw:mt-0', this._config.hintClass, this.hintClass()), /* @ts-ignore */
136
+ ...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
137
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormCombobox, deps: [], target: i0.ɵɵFactoryTarget.Component });
138
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormCombobox, isStandalone: true, selector: "eg-form-combobox", 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 }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, emptyText: { classPropertyName: "emptyText", publicName: "emptyText", 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 }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, labelClass: { classPropertyName: "labelClass", publicName: "labelClass", isSignal: true, isRequired: false, transformFunction: null }, controlClass: { classPropertyName: "controlClass", publicName: "controlClass", isSignal: true, isRequired: false, transformFunction: null }, chipsClass: { classPropertyName: "chipsClass", publicName: "chipsClass", 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 }], viewQueries: [{ propertyName: "_picker", first: true, predicate: (BrnComboboxMultiple), descendants: true, isSignal: true }, { propertyName: "_single", first: true, predicate: (BrnCombobox), descendants: true, isSignal: true }], ngImport: i0, template: `
139
+ @let lbl = label();
140
+ @let cnm = controlName();
141
+ @let hnt = hint();
142
+ @let rqrd = required();
143
+
144
+ <hlm-form-field>
145
+ @if (lbl) {
146
+ <label hlmLabel [for]="effectiveId()" [class]="$labelClass()"
147
+ >{{ lbl }}
148
+ @if (rqrd) {
149
+ <span class="tw:text-red-500">*</span>
150
+ }
151
+ </label>
152
+ }
153
+
154
+ @if (mode() === 'single') {
155
+ <hlm-combobox [formControlName]="cnm" [disabled]="effectiveDisabled()">
156
+ <hlm-combobox-trigger [buttonId]="effectiveId()" [class]="$controlClass()">
157
+ {{ singleDisplay() ?? placeholder() }}
158
+ </hlm-combobox-trigger>
159
+ <hlm-combobox-content *hlmComboboxPortal>
160
+ <hlm-combobox-input [inputId]="effectiveId()" [placeholder]="placeholder()" />
161
+ <div hlmComboboxList>
162
+ @for (option of options(); track option) {
163
+ <hlm-combobox-item [value]="option">{{ option }}</hlm-combobox-item>
164
+ }
165
+ </div>
166
+ <div hlmComboboxEmpty>{{ emptyText() }}</div>
167
+ </hlm-combobox-content>
168
+ </hlm-combobox>
169
+ } @else {
170
+ <hlm-combobox-multiple [formControlName]="cnm" [disabled]="effectiveDisabled()" [class]="$controlClass()">
171
+ <hlm-combobox-chips [class]="$chipsClass()">
172
+ @for (v of selectedValues(); track v) {
173
+ <hlm-combobox-chip [value]="v">{{ v }}</hlm-combobox-chip>
174
+ }
175
+ <input hlmComboboxChipInput [id]="effectiveId()" [placeholder]="placeholder()" />
176
+ </hlm-combobox-chips>
177
+ <hlm-combobox-content *hlmComboboxPortal>
178
+ <div hlmComboboxList>
179
+ @for (option of options(); track option) {
180
+ <hlm-combobox-item [value]="option">{{ option }}</hlm-combobox-item>
181
+ }
182
+ </div>
183
+ <div hlmComboboxEmpty>{{ emptyText() }}</div>
184
+ </hlm-combobox-content>
185
+ </hlm-combobox-multiple>
186
+ }
187
+
188
+ @if (showError()) {
189
+ <hlm-error [id]="errorId()" [class]="$errorClass()">
190
+ {{ resolvedError() }}
191
+ </hlm-error>
192
+ }
193
+
194
+ @if (hnt) {
195
+ <hlm-hint [id]="hintId()" [class]="$hintClass()">
196
+ {{ hnt }}
197
+ </hlm-hint>
198
+ }
199
+ </hlm-form-field>
200
+ `, 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: "directive", type: HlmCombobox, selector: "[hlmCombobox],hlm-combobox" }, { kind: "component", type: HlmComboboxChip, selector: "hlm-combobox-chip", inputs: ["showRemove"] }, { kind: "directive", type: HlmComboboxChipInput, selector: "input[hlmComboboxChipInput]" }, { kind: "directive", type: HlmComboboxChips, selector: "[hlmComboboxChips],hlm-combobox-chips", inputs: ["forceInvalid"] }, { kind: "directive", type: HlmComboboxContent, selector: "[hlmComboboxContent],hlm-combobox-content" }, { kind: "directive", type: HlmComboboxEmpty, selector: "[hlmComboboxEmpty],hlm-combobox-empty" }, { kind: "component", type: HlmComboboxInput, selector: "hlm-combobox-input", inputs: ["inputId", "placeholder", "showTrigger", "showClear", "forceInvalid", "aria-invalid"] }, { kind: "component", type: HlmComboboxItem, selector: "hlm-combobox-item" }, { kind: "directive", type: HlmComboboxList, selector: "[hlmComboboxList]" }, { kind: "directive", type: HlmComboboxMultiple, selector: "[hlmComboboxMultiple],hlm-combobox-multiple" }, { kind: "directive", type: HlmComboboxPortal, selector: "[hlmComboboxPortal]" }, { kind: "component", type: HlmComboboxTrigger, selector: "hlm-combobox-trigger", inputs: ["class", "buttonId", "variant", "forceInvalid"] }] });
201
+ }
202
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormCombobox, decorators: [{
203
+ type: Component,
204
+ args: [{
205
+ selector: 'eg-form-combobox',
206
+ standalone: true,
207
+ host: {
208
+ '[class]': '$userClass()',
209
+ },
210
+ imports: [
211
+ ReactiveFormsModule,
212
+ HlmFormField,
213
+ HlmError,
214
+ HlmHint,
215
+ HlmLabel,
216
+ HlmCombobox,
217
+ HlmComboboxChip,
218
+ HlmComboboxChipInput,
219
+ HlmComboboxChips,
220
+ HlmComboboxContent,
221
+ HlmComboboxEmpty,
222
+ HlmComboboxInput,
223
+ HlmComboboxItem,
224
+ HlmComboboxList,
225
+ HlmComboboxMultiple,
226
+ HlmComboboxPortal,
227
+ HlmComboboxTrigger,
228
+ ],
229
+ providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
230
+ template: `
231
+ @let lbl = label();
232
+ @let cnm = controlName();
233
+ @let hnt = hint();
234
+ @let rqrd = required();
235
+
236
+ <hlm-form-field>
237
+ @if (lbl) {
238
+ <label hlmLabel [for]="effectiveId()" [class]="$labelClass()"
239
+ >{{ lbl }}
240
+ @if (rqrd) {
241
+ <span class="tw:text-red-500">*</span>
242
+ }
243
+ </label>
244
+ }
245
+
246
+ @if (mode() === 'single') {
247
+ <hlm-combobox [formControlName]="cnm" [disabled]="effectiveDisabled()">
248
+ <hlm-combobox-trigger [buttonId]="effectiveId()" [class]="$controlClass()">
249
+ {{ singleDisplay() ?? placeholder() }}
250
+ </hlm-combobox-trigger>
251
+ <hlm-combobox-content *hlmComboboxPortal>
252
+ <hlm-combobox-input [inputId]="effectiveId()" [placeholder]="placeholder()" />
253
+ <div hlmComboboxList>
254
+ @for (option of options(); track option) {
255
+ <hlm-combobox-item [value]="option">{{ option }}</hlm-combobox-item>
256
+ }
257
+ </div>
258
+ <div hlmComboboxEmpty>{{ emptyText() }}</div>
259
+ </hlm-combobox-content>
260
+ </hlm-combobox>
261
+ } @else {
262
+ <hlm-combobox-multiple [formControlName]="cnm" [disabled]="effectiveDisabled()" [class]="$controlClass()">
263
+ <hlm-combobox-chips [class]="$chipsClass()">
264
+ @for (v of selectedValues(); track v) {
265
+ <hlm-combobox-chip [value]="v">{{ v }}</hlm-combobox-chip>
266
+ }
267
+ <input hlmComboboxChipInput [id]="effectiveId()" [placeholder]="placeholder()" />
268
+ </hlm-combobox-chips>
269
+ <hlm-combobox-content *hlmComboboxPortal>
270
+ <div hlmComboboxList>
271
+ @for (option of options(); track option) {
272
+ <hlm-combobox-item [value]="option">{{ option }}</hlm-combobox-item>
273
+ }
274
+ </div>
275
+ <div hlmComboboxEmpty>{{ emptyText() }}</div>
276
+ </hlm-combobox-content>
277
+ </hlm-combobox-multiple>
278
+ }
279
+
280
+ @if (showError()) {
281
+ <hlm-error [id]="errorId()" [class]="$errorClass()">
282
+ {{ resolvedError() }}
283
+ </hlm-error>
284
+ }
285
+
286
+ @if (hnt) {
287
+ <hlm-hint [id]="hintId()" [class]="$hintClass()">
288
+ {{ hnt }}
289
+ </hlm-hint>
290
+ }
291
+ </hlm-form-field>
292
+ `,
293
+ }]
294
+ }], propDecorators: { _picker: [{ type: i0.ViewChild, args: [i0.forwardRef(() => BrnComboboxMultiple), { isSignal: true }] }], _single: [{ type: i0.ViewChild, args: [i0.forwardRef(() => BrnCombobox), { isSignal: true }] }], 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 }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], emptyText: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyText", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], mode: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], controlClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlClass", required: false }] }], chipsClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "chipsClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
295
+
296
+ /*
297
+ * Public API Surface of form-combobox
298
+ */
299
+
300
+ /**
301
+ * Generated bundle index. Do not edit.
302
+ */
303
+
304
+ export { EgFormCombobox, injectEgFormComboboxConfig, provideEgFormComboboxConfig };
305
+
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "form-combobox",
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-combobox.mjs",
13
+ "typings": "types/form-combobox.d.ts",
14
+ "exports": {
15
+ "./package.json": {
16
+ "default": "./package.json"
17
+ },
18
+ ".": {
19
+ "types": "./types/form-combobox.d.ts",
20
+ "default": "./fesm2022/form-combobox.mjs"
21
+ }
22
+ },
23
+ "type": "module"
24
+ }