@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.
- package/README.md +1 -1
- package/autocomplete/fesm2022/autocomplete.mjs +1 -1
- package/checkbox/fesm2022/checkbox.mjs +6 -7
- package/checkbox/types/checkbox.d.ts +1 -1
- package/combobox/fesm2022/combobox.mjs +1 -1
- package/date-picker/README.md +15 -11
- package/date-picker/fesm2022/date-picker.mjs +148 -30
- package/date-picker/types/date-picker.d.ts +102 -9
- package/form-autocomplete/README.md +178 -0
- package/form-autocomplete/fesm2022/form-autocomplete.mjs +159 -0
- package/form-autocomplete/package.json +24 -0
- package/form-autocomplete/types/form-autocomplete.d.ts +81 -0
- package/form-checkbox/README.md +29 -18
- package/form-checkbox/fesm2022/form-checkbox.mjs +59 -17
- package/form-checkbox/types/form-checkbox.d.ts +43 -4
- package/form-combobox/README.md +203 -0
- package/form-combobox/fesm2022/form-combobox.mjs +181 -0
- package/form-combobox/package.json +24 -0
- package/form-combobox/types/form-combobox.d.ts +93 -0
- package/form-date-picker/README.md +49 -22
- package/form-date-picker/fesm2022/form-date-picker.mjs +74 -19
- package/form-date-picker/types/form-date-picker.d.ts +37 -1
- package/form-date-picker-multi/README.md +192 -0
- package/form-date-picker-multi/fesm2022/form-date-picker-multi.mjs +158 -0
- package/form-date-picker-multi/package.json +24 -0
- package/form-date-picker-multi/types/form-date-picker-multi.d.ts +78 -0
- package/form-date-range-picker/README.md +254 -0
- package/form-date-range-picker/fesm2022/form-date-range-picker.mjs +159 -0
- package/form-date-range-picker/package.json +24 -0
- package/form-date-range-picker/types/form-date-range-picker.d.ts +75 -0
- package/form-field/README.md +9 -0
- package/form-field/fesm2022/form-field.mjs +80 -5
- package/form-field/types/form-field.d.ts +50 -2
- package/form-field-simple/fesm2022/form-field-simple.mjs +15 -1
- package/form-field-simple/types/form-field-simple.d.ts +9 -2
- package/form-input-otp/README.md +195 -0
- package/form-input-otp/fesm2022/form-input-otp.mjs +140 -0
- package/form-input-otp/package.json +24 -0
- package/form-input-otp/types/form-input-otp.d.ts +78 -0
- package/form-month-year-picker/README.md +189 -0
- package/form-month-year-picker/fesm2022/form-month-year-picker.mjs +154 -0
- package/form-month-year-picker/package.json +24 -0
- package/form-month-year-picker/types/form-month-year-picker.d.ts +73 -0
- package/form-native-select/README.md +206 -0
- package/form-native-select/fesm2022/form-native-select.mjs +132 -0
- package/form-native-select/package.json +24 -0
- package/form-native-select/types/form-native-select.d.ts +77 -0
- package/form-phone-input/README.md +189 -0
- package/form-phone-input/fesm2022/form-phone-input.mjs +142 -0
- package/form-phone-input/package.json +24 -0
- package/form-phone-input/types/form-phone-input.d.ts +78 -0
- package/form-radio-group/README.md +199 -0
- package/form-radio-group/fesm2022/form-radio-group.mjs +140 -0
- package/form-radio-group/package.json +24 -0
- package/form-radio-group/types/form-radio-group.d.ts +83 -0
- package/form-searchable-multiselect/README.md +28 -17
- package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs +57 -19
- package/form-searchable-multiselect/types/form-searchable-multiselect.d.ts +39 -2
- package/form-select/README.md +30 -19
- package/form-select/fesm2022/form-select.mjs +57 -19
- package/form-select/types/form-select.d.ts +39 -2
- package/form-slider/README.md +183 -0
- package/form-slider/fesm2022/form-slider.mjs +140 -0
- package/form-slider/package.json +24 -0
- package/form-slider/types/form-slider.d.ts +80 -0
- package/form-switch/README.md +174 -0
- package/form-switch/fesm2022/form-switch.mjs +129 -0
- package/form-switch/package.json +24 -0
- package/form-switch/types/form-switch.d.ts +70 -0
- package/form-text-input/README.md +37 -26
- package/form-text-input/fesm2022/form-text-input.mjs +57 -19
- package/form-text-input/types/form-text-input.d.ts +39 -2
- package/form-textarea/README.md +33 -22
- package/form-textarea/fesm2022/form-textarea.mjs +57 -19
- package/form-textarea/types/form-textarea.d.ts +39 -2
- package/form-toggle/README.md +187 -0
- package/form-toggle/fesm2022/form-toggle.mjs +193 -0
- package/form-toggle/package.json +24 -0
- package/form-toggle/types/form-toggle.d.ts +100 -0
- package/form-toggle-group/README.md +177 -0
- package/form-toggle-group/fesm2022/form-toggle-group.mjs +145 -0
- package/form-toggle-group/package.json +24 -0
- package/form-toggle-group/types/form-toggle-group.d.ts +85 -0
- package/input-group/fesm2022/input-group.mjs +19 -9
- package/input-group/types/input-group.d.ts +4 -1
- package/native-select/fesm2022/native-select.mjs +18 -6
- package/native-select/types/native-select.d.ts +7 -2
- package/package.json +57 -1
- package/phone-input/README.md +114 -0
- package/phone-input/fesm2022/phone-input.mjs +191 -0
- package/phone-input/package.json +24 -0
- package/phone-input/types/phone-input.d.ts +67 -0
- package/radio-group/types/radio-group.d.ts +1 -1
- package/switch/fesm2022/switch.mjs +7 -5
- package/switch/types/switch.d.ts +2 -1
- package/typography/types/typography.d.ts +8 -8
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { ValueProvider } from '@angular/core';
|
|
3
|
+
import { ClassValue } from 'clsx';
|
|
4
|
+
|
|
5
|
+
declare class EgFormAutocomplete {
|
|
6
|
+
private readonly formGroupDirective;
|
|
7
|
+
private readonly _errorMessages;
|
|
8
|
+
private readonly generatedId;
|
|
9
|
+
private readonly _config;
|
|
10
|
+
label: _angular_core.InputSignal<string | undefined>;
|
|
11
|
+
controlId: _angular_core.InputSignal<string | undefined>;
|
|
12
|
+
controlName: _angular_core.InputSignal<string>;
|
|
13
|
+
error: _angular_core.InputSignal<string | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Auto-resolve the displayed message from the control's `ValidationErrors`
|
|
16
|
+
* when `error()` is unset. Explicit `error()` always wins. Set to `false`
|
|
17
|
+
* for manual-only messages.
|
|
18
|
+
*/
|
|
19
|
+
autoError: _angular_core.InputSignal<boolean>;
|
|
20
|
+
hint: _angular_core.InputSignal<string | undefined>;
|
|
21
|
+
id: _angular_core.InputSignal<string | undefined>;
|
|
22
|
+
placeholder: _angular_core.InputSignal<string>;
|
|
23
|
+
emptyText: _angular_core.InputSignal<string>;
|
|
24
|
+
disabled: _angular_core.InputSignal<boolean>;
|
|
25
|
+
required: _angular_core.InputSignal<boolean>;
|
|
26
|
+
options: _angular_core.InputSignal<string[]>;
|
|
27
|
+
readonly effectiveId: _angular_core.Signal<string>;
|
|
28
|
+
readonly errorId: _angular_core.Signal<string>;
|
|
29
|
+
readonly hintId: _angular_core.Signal<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
32
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
33
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
34
|
+
* fresh on every change-detection pass.
|
|
35
|
+
*/
|
|
36
|
+
protected resolvedError(): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
39
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
40
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
41
|
+
*/
|
|
42
|
+
protected showError(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Combined lock for the brain `linkedSignal`-based disabled state: the raw
|
|
45
|
+
* input write always carries the resolved value, so a same-pass
|
|
46
|
+
* wrapper-toggle + `control.disable()` cannot clobber CVA state.
|
|
47
|
+
*/
|
|
48
|
+
effectiveDisabled(): boolean;
|
|
49
|
+
userClass: _angular_core.InputSignal<ClassValue>;
|
|
50
|
+
labelClass: _angular_core.InputSignal<string>;
|
|
51
|
+
controlClass: _angular_core.InputSignal<string>;
|
|
52
|
+
inputClass: _angular_core.InputSignal<string>;
|
|
53
|
+
errorClass: _angular_core.InputSignal<string>;
|
|
54
|
+
hintClass: _angular_core.InputSignal<string>;
|
|
55
|
+
$userClass: _angular_core.Signal<string>;
|
|
56
|
+
$labelClass: _angular_core.Signal<string>;
|
|
57
|
+
$controlClass: _angular_core.Signal<string>;
|
|
58
|
+
$inputClass: _angular_core.Signal<string>;
|
|
59
|
+
$errorClass: _angular_core.Signal<string>;
|
|
60
|
+
$hintClass: _angular_core.Signal<string>;
|
|
61
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormAutocomplete, never>;
|
|
62
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormAutocomplete, "eg-form-autocomplete", 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; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "emptyText": { "alias": "emptyText"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "controlClass": { "alias": "controlClass"; "required": false; "isSignal": true; }; "inputClass": { "alias": "inputClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface EgFormAutocompleteConfig {
|
|
66
|
+
/**
|
|
67
|
+
* Global class defaults for `eg-form-autocomplete` styling slots.
|
|
68
|
+
* Each is merged under the matching per-instance `*Class` input
|
|
69
|
+
* (library base < global config < per-instance).
|
|
70
|
+
*/
|
|
71
|
+
labelClass?: string;
|
|
72
|
+
controlClass?: string;
|
|
73
|
+
inputClass?: string;
|
|
74
|
+
errorClass?: string;
|
|
75
|
+
hintClass?: string;
|
|
76
|
+
}
|
|
77
|
+
declare function provideEgFormAutocompleteConfig(config: Partial<EgFormAutocompleteConfig>): ValueProvider;
|
|
78
|
+
declare function injectEgFormAutocompleteConfig(): EgFormAutocompleteConfig;
|
|
79
|
+
|
|
80
|
+
export { EgFormAutocomplete, injectEgFormAutocompleteConfig, provideEgFormAutocompleteConfig };
|
|
81
|
+
export type { EgFormAutocompleteConfig };
|
package/form-checkbox/README.md
CHANGED
|
@@ -83,23 +83,24 @@ Selector (from source): `eg-form-checkbox` (standalone component).
|
|
|
83
83
|
|
|
84
84
|
### `EgFormCheckbox` — `eg-form-checkbox`
|
|
85
85
|
|
|
86
|
-
| Input | Type | Default | Description
|
|
87
|
-
| --------------- | --------------------- | ------- |
|
|
88
|
-
| `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.**
|
|
89
|
-
| `label` | `string` | `''` | Label text next to the checkbox.
|
|
90
|
-
| `error` | `string \| undefined` | — | Error text shown when the control is invalid + touched/dirty (via `EgFormField` switching).
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
|
|
|
102
|
-
|
|
|
86
|
+
| Input | Type | Default | Description |
|
|
87
|
+
| --------------- | --------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
88
|
+
| `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.** |
|
|
89
|
+
| `label` | `string` | `''` | Label text next to the checkbox. |
|
|
90
|
+
| `error` | `string \| undefined` | — | Error text shown when the control is invalid + touched/dirty (via `EgFormField` switching). |
|
|
91
|
+
| `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`. |
|
|
92
|
+
| `hint` | `string \| undefined` | — | Hint text shown when there is no error to display. |
|
|
93
|
+
| `controlId` | `string \| undefined` | — | Explicit control id (first priority for `effectiveId`). |
|
|
94
|
+
| `id` | `string \| undefined` | — | Fallback id (second priority). |
|
|
95
|
+
| `name` | `string \| undefined` | — | Checkbox `name` attribute (defaults to `controlName`). |
|
|
96
|
+
| `checked` | `boolean` | `false` | Initial checked state passed to `hlm-checkbox`. |
|
|
97
|
+
| `required` | `boolean` | `false` | Shows a red `*` and sets checkbox `required`. |
|
|
98
|
+
| `disabled` | `boolean` | `false` | Locks interaction via checkbox `wrapperDisabled` (does not write to the form control). |
|
|
99
|
+
| `class` | `ClassValue` | `''` | Extra host classes. |
|
|
100
|
+
| `checkboxClass` | `string` | `''` | Extra classes for `hlm-checkbox`. |
|
|
101
|
+
| `labelClass` | `string` | `''` | Extra classes for the label. |
|
|
102
|
+
| `errorClass` | `string` | `''` | Extra classes for `hlm-error`. |
|
|
103
|
+
| `hintClass` | `string` | `''` | Extra classes for `hlm-hint`. |
|
|
103
104
|
|
|
104
105
|
| Member | Description |
|
|
105
106
|
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
@@ -303,7 +304,17 @@ export class SubmitCheckComponent {
|
|
|
303
304
|
|
|
304
305
|
## Theming / CSS variables
|
|
305
306
|
|
|
306
|
-
No component-specific CSS variables. Style via `class`, `checkboxClass`, `labelClass`,
|
|
307
|
+
No component-specific CSS variables. Style per-instance via `class`, `checkboxClass`, `labelClass`, `errorClass`, `hintClass` inputs. The row layout (`flex items-center gap-1`) is fixed in the template.
|
|
308
|
+
|
|
309
|
+
Global defaults per styling slot via the wrapper config (precedence: library base < global config < per-instance):
|
|
310
|
+
|
|
311
|
+
```ts
|
|
312
|
+
import { provideEgFormCheckboxConfig } from '@egose/shadcn-theme-ng/form-checkbox';
|
|
313
|
+
|
|
314
|
+
await bootstrapApplication(App, {
|
|
315
|
+
providers: [provideEgFormCheckboxConfig({ checkboxClass: 'tw:size-5', labelClass: 'tw:font-medium' })],
|
|
316
|
+
});
|
|
317
|
+
```
|
|
307
318
|
|
|
308
319
|
## Related subpaths
|
|
309
320
|
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, input, computed, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, input, computed, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/forms';
|
|
4
4
|
import { FormGroupDirective, ReactiveFormsModule, ControlContainer } from '@angular/forms';
|
|
5
5
|
import { HlmLabel } from '@egose/shadcn-theme-ng/label';
|
|
6
6
|
import { HlmCheckbox } from '@egose/shadcn-theme-ng/checkbox';
|
|
7
|
-
import { HlmFormIdGenerator, HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
7
|
+
import { injectEgFormErrorMessages, HlmFormIdGenerator, resolveEgFormError, HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
8
8
|
import { EgFormField } from '@egose/shadcn-theme-ng/form-field-simple';
|
|
9
9
|
import { hlm } from '@egose/shadcn-theme-ng/utils';
|
|
10
10
|
|
|
11
|
+
const EgFormCheckboxConfigToken = new InjectionToken('EgFormCheckboxConfig');
|
|
12
|
+
function provideEgFormCheckboxConfig(config) {
|
|
13
|
+
return { provide: EgFormCheckboxConfigToken, useValue: { ...config } };
|
|
14
|
+
}
|
|
15
|
+
function injectEgFormCheckboxConfig() {
|
|
16
|
+
return inject(EgFormCheckboxConfigToken, { optional: true }) ?? {};
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
class EgFormCheckbox {
|
|
12
20
|
formGroupDirective = inject(FormGroupDirective);
|
|
21
|
+
_errorMessages = injectEgFormErrorMessages();
|
|
13
22
|
generatedId = inject(HlmFormIdGenerator).generate('eg-form-checkbox');
|
|
23
|
+
_config = injectEgFormCheckboxConfig();
|
|
14
24
|
// Classes
|
|
15
25
|
userClass = input('', { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: 'class' });
|
|
16
26
|
_computedClass = computed(() => hlm('', this.userClass()), /* @ts-ignore */
|
|
@@ -24,6 +34,13 @@ class EgFormCheckbox {
|
|
|
24
34
|
...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
|
|
25
35
|
error = input(undefined, /* @ts-ignore */
|
|
26
36
|
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
37
|
+
/**
|
|
38
|
+
* Auto-resolve the displayed message from the control's `ValidationErrors`
|
|
39
|
+
* when `error()` is unset. Explicit `error()` always wins. Set to `false`
|
|
40
|
+
* for manual-only messages.
|
|
41
|
+
*/
|
|
42
|
+
autoError = input(true, /* @ts-ignore */
|
|
43
|
+
...(ngDevMode ? [{ debugName: "autoError" }] : /* istanbul ignore next */ []));
|
|
27
44
|
hint = input(undefined, /* @ts-ignore */
|
|
28
45
|
...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
29
46
|
id = input(undefined, /* @ts-ignore */
|
|
@@ -42,30 +59,55 @@ class EgFormCheckbox {
|
|
|
42
59
|
...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
|
|
43
60
|
hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
|
|
44
61
|
...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
|
|
45
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
64
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
65
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
66
|
+
* fresh on every change-detection pass.
|
|
67
|
+
*/
|
|
68
|
+
resolvedError() {
|
|
69
|
+
const explicit = this.error();
|
|
70
|
+
if (explicit)
|
|
71
|
+
return explicit;
|
|
72
|
+
if (!this.autoError())
|
|
73
|
+
return undefined;
|
|
46
74
|
const control = this.formGroupDirective.form.get(this.controlName());
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
75
|
+
return resolveEgFormError(control?.errors ?? null, this.label(), this._errorMessages);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
79
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
80
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
81
|
+
*/
|
|
82
|
+
showError() {
|
|
83
|
+
const control = this.formGroupDirective.form.get(this.controlName());
|
|
84
|
+
return (!!this.resolvedError() &&
|
|
85
|
+
!!control?.invalid &&
|
|
86
|
+
(control.dirty || control.touched || this.formGroupDirective.submitted));
|
|
87
|
+
}
|
|
88
|
+
describedBy() {
|
|
89
|
+
return this.showError() ? this.errorId() : this.hint() ? this.hintId() : null;
|
|
52
90
|
}
|
|
53
91
|
// Styling
|
|
54
92
|
checkboxClass = input('', /* @ts-ignore */
|
|
55
93
|
...(ngDevMode ? [{ debugName: "checkboxClass" }] : /* istanbul ignore next */ []));
|
|
56
94
|
labelClass = input('', /* @ts-ignore */
|
|
57
95
|
...(ngDevMode ? [{ debugName: "labelClass" }] : /* istanbul ignore next */ []));
|
|
58
|
-
|
|
59
|
-
|
|
96
|
+
errorClass = input('', /* @ts-ignore */
|
|
97
|
+
...(ngDevMode ? [{ debugName: "errorClass" }] : /* istanbul ignore next */ []));
|
|
98
|
+
hintClass = input('', /* @ts-ignore */
|
|
99
|
+
...(ngDevMode ? [{ debugName: "hintClass" }] : /* istanbul ignore next */ []));
|
|
100
|
+
// Computed styling (library base < global config < per-instance)
|
|
101
|
+
$checkboxClass = computed(() => hlm(this._config.checkboxClass, this.checkboxClass()), /* @ts-ignore */
|
|
60
102
|
...(ngDevMode ? [{ debugName: "$checkboxClass" }] : /* istanbul ignore next */ []));
|
|
61
|
-
$labelClass = computed(() => hlm(this.labelClass()), /* @ts-ignore */
|
|
103
|
+
$labelClass = computed(() => hlm(this._config.labelClass, this.labelClass()), /* @ts-ignore */
|
|
62
104
|
...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
|
|
63
|
-
$errorClass =
|
|
105
|
+
$errorClass = computed(() => hlm(this._config.errorClass, this.errorClass()), /* @ts-ignore */
|
|
64
106
|
...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
|
|
65
|
-
$hintClass =
|
|
107
|
+
$hintClass = computed(() => hlm(this._config.hintClass, this.hintClass()), /* @ts-ignore */
|
|
66
108
|
...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
|
|
67
109
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormCheckbox, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
68
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormCheckbox, isStandalone: true, selector: "eg-form-checkbox", inputs: { userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, 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 }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, checkboxClass: { classPropertyName: "checkboxClass", publicName: "checkboxClass", isSignal: true, isRequired: false, transformFunction: null }, labelClass: { classPropertyName: "labelClass", publicName: "labelClass", isSignal: true, isRequired: false, transformFunction: null },
|
|
110
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormCheckbox, isStandalone: true, selector: "eg-form-checkbox", inputs: { userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, 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 }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, checkboxClass: { classPropertyName: "checkboxClass", publicName: "checkboxClass", isSignal: true, isRequired: false, transformFunction: null }, labelClass: { classPropertyName: "labelClass", publicName: "labelClass", isSignal: true, isRequired: false, transformFunction: null }, errorClass: { classPropertyName: "errorClass", publicName: "errorClass", isSignal: true, isRequired: false, transformFunction: null }, hintClass: { classPropertyName: "hintClass", publicName: "hintClass", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "_computedClass()" } }, providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }], ngImport: i0, template: "\n @let lbl = label();\n @let cnm = controlName();\n @let hnt = hint();\n @let rqrd = required();\n\n <eg-form-field>\n <div class=\"flex items-center gap-1\">\n <hlm-checkbox\n [id]=\"effectiveId()\"\n [name]=\"cnm || name() || null\"\n [formControlName]=\"cnm\"\n [class]=\"$checkboxClass()\"\n [checked]=\"checked()\"\n [required]=\"rqrd\"\n [wrapperDisabled]=\"disabled()\"\n [aria-describedby]=\"describedBy()\"\n />\n <label hlmLabel [for]=\"effectiveId()\" [class]=\"$labelClass()\">\n {{ lbl }}\n @if (rqrd) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n </div>\n\n @if (showError()) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{ resolvedError() }}\n </hlm-error>\n }\n\n @if (hnt) {\n <hlm-hint [id]=\"hintId()\" [class]=\"$hintClass()\">\n {{ hnt }}\n </hlm-hint>\n }\n </eg-form-field>\n ", isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: HlmCheckbox, selector: "hlm-checkbox", inputs: ["class", "id", "aria-label", "aria-labelledby", "aria-describedby", "checked", "name", "required", "disabled", "wrapperDisabled"], outputs: ["checkedChange", "changed"] }, { kind: "directive", type: HlmLabel, selector: "[hlmLabel]", inputs: ["class"] }, { kind: "component", type: EgFormField, selector: "eg-form-field", inputs: ["class"] }, { kind: "directive", type: HlmError, selector: "hlm-error", inputs: ["class"] }, { kind: "directive", type: HlmHint, selector: "hlm-hint", inputs: ["class"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
69
111
|
}
|
|
70
112
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormCheckbox, decorators: [{
|
|
71
113
|
type: Component,
|
|
@@ -78,9 +120,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
78
120
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
79
121
|
imports: [ReactiveFormsModule, HlmCheckbox, HlmLabel, EgFormField, HlmError, HlmHint],
|
|
80
122
|
providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
|
|
81
|
-
template: "\n @let lbl = label();\n @let cnm = controlName();\n @let
|
|
123
|
+
template: "\n @let lbl = label();\n @let cnm = controlName();\n @let hnt = hint();\n @let rqrd = required();\n\n <eg-form-field>\n <div class=\"flex items-center gap-1\">\n <hlm-checkbox\n [id]=\"effectiveId()\"\n [name]=\"cnm || name() || null\"\n [formControlName]=\"cnm\"\n [class]=\"$checkboxClass()\"\n [checked]=\"checked()\"\n [required]=\"rqrd\"\n [wrapperDisabled]=\"disabled()\"\n [aria-describedby]=\"describedBy()\"\n />\n <label hlmLabel [for]=\"effectiveId()\" [class]=\"$labelClass()\">\n {{ lbl }}\n @if (rqrd) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n </div>\n\n @if (showError()) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{ resolvedError() }}\n </hlm-error>\n }\n\n @if (hnt) {\n <hlm-hint [id]=\"hintId()\" [class]=\"$hintClass()\">\n {{ hnt }}\n </hlm-hint>\n }\n </eg-form-field>\n ",
|
|
82
124
|
}]
|
|
83
|
-
}], propDecorators: { userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], 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 }] }], checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], checkboxClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "checkboxClass", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }],
|
|
125
|
+
}], propDecorators: { userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], 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 }] }], checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], checkboxClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "checkboxClass", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
|
|
84
126
|
|
|
85
127
|
/*
|
|
86
128
|
* Public API Surface of form-checkbox
|
|
@@ -90,5 +132,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
90
132
|
* Generated bundle index. Do not edit.
|
|
91
133
|
*/
|
|
92
134
|
|
|
93
|
-
export { EgFormCheckbox };
|
|
135
|
+
export { EgFormCheckbox, injectEgFormCheckboxConfig, provideEgFormCheckboxConfig };
|
|
94
136
|
|
|
@@ -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.
|
|
28
|
-
$hintClass: _angular_core.
|
|
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; }; "
|
|
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
|
-
|
|
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.
|