@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,181 @@
|
|
|
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/form-field';
|
|
6
|
+
import { HlmLabel } from '@egose/shadcn-theme-ng/label';
|
|
7
|
+
import { HlmCombobox, HlmComboboxChip, HlmComboboxChipInput, HlmComboboxChips, HlmComboboxContent, HlmComboboxEmpty, HlmComboboxInput, HlmComboboxItem, HlmComboboxList, HlmComboboxMultiple, HlmComboboxPortal, HlmComboboxTrigger } from '@egose/shadcn-theme-ng/combobox';
|
|
8
|
+
import { BrnComboboxMultiple, BrnCombobox } from '@spartan-ng/brain/combobox';
|
|
9
|
+
import { hlm } from '@egose/shadcn-theme-ng/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("w-full", this.userClass()), /* @ts-ignore */
|
|
126
|
+
...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
|
|
127
|
+
$labelClass = computed(() => hlm("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("mt-0", this._config.errorClass, this.errorClass()), /* @ts-ignore */
|
|
134
|
+
...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
|
|
135
|
+
$hintClass = computed(() => hlm("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: "\n @let lbl = label();\n @let cnm = controlName();\n @let hnt = hint();\n @let rqrd = required();\n\n <hlm-form-field>\n @if (lbl) {\n <label hlmLabel [for]=\"effectiveId()\" [class]=\"$labelClass()\"\n >{{ lbl }}\n @if (rqrd) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n @if (mode() === 'single') {\n <hlm-combobox [formControlName]=\"cnm\" [disabled]=\"effectiveDisabled()\">\n <hlm-combobox-trigger [buttonId]=\"effectiveId()\" [class]=\"$controlClass()\">\n {{ singleDisplay() ?? placeholder() }}\n </hlm-combobox-trigger>\n <hlm-combobox-content *hlmComboboxPortal>\n <hlm-combobox-input [inputId]=\"effectiveId()\" [placeholder]=\"placeholder()\" />\n <div hlmComboboxList>\n @for (option of options(); track option) {\n <hlm-combobox-item [value]=\"option\">{{ option }}</hlm-combobox-item>\n }\n </div>\n <div hlmComboboxEmpty>{{ emptyText() }}</div>\n </hlm-combobox-content>\n </hlm-combobox>\n } @else {\n <hlm-combobox-multiple [formControlName]=\"cnm\" [disabled]=\"effectiveDisabled()\" [class]=\"$controlClass()\">\n <hlm-combobox-chips [class]=\"$chipsClass()\">\n @for (v of selectedValues(); track v) {\n <hlm-combobox-chip [value]=\"v\">{{ v }}</hlm-combobox-chip>\n }\n <input hlmComboboxChipInput [id]=\"effectiveId()\" [placeholder]=\"placeholder()\" />\n </hlm-combobox-chips>\n <hlm-combobox-content *hlmComboboxPortal>\n <div hlmComboboxList>\n @for (option of options(); track option) {\n <hlm-combobox-item [value]=\"option\">{{ option }}</hlm-combobox-item>\n }\n </div>\n <div hlmComboboxEmpty>{{ emptyText() }}</div>\n </hlm-combobox-content>\n </hlm-combobox-multiple>\n }\n\n @if (showError()) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{ resolvedError() }}\n </hlm-error>\n }\n\n @if (hnt) {\n <hlm-hint [id]=\"hintId()\" [class]=\"$hintClass()\">\n {{ hnt }}\n </hlm-hint>\n }\n </hlm-form-field>\n ", isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.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"] }] });
|
|
139
|
+
}
|
|
140
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormCombobox, decorators: [{
|
|
141
|
+
type: Component,
|
|
142
|
+
args: [{
|
|
143
|
+
selector: 'eg-form-combobox',
|
|
144
|
+
standalone: true,
|
|
145
|
+
host: {
|
|
146
|
+
'[class]': '$userClass()',
|
|
147
|
+
},
|
|
148
|
+
imports: [
|
|
149
|
+
ReactiveFormsModule,
|
|
150
|
+
HlmFormField,
|
|
151
|
+
HlmError,
|
|
152
|
+
HlmHint,
|
|
153
|
+
HlmLabel,
|
|
154
|
+
HlmCombobox,
|
|
155
|
+
HlmComboboxChip,
|
|
156
|
+
HlmComboboxChipInput,
|
|
157
|
+
HlmComboboxChips,
|
|
158
|
+
HlmComboboxContent,
|
|
159
|
+
HlmComboboxEmpty,
|
|
160
|
+
HlmComboboxInput,
|
|
161
|
+
HlmComboboxItem,
|
|
162
|
+
HlmComboboxList,
|
|
163
|
+
HlmComboboxMultiple,
|
|
164
|
+
HlmComboboxPortal,
|
|
165
|
+
HlmComboboxTrigger,
|
|
166
|
+
],
|
|
167
|
+
providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
|
|
168
|
+
template: "\n @let lbl = label();\n @let cnm = controlName();\n @let hnt = hint();\n @let rqrd = required();\n\n <hlm-form-field>\n @if (lbl) {\n <label hlmLabel [for]=\"effectiveId()\" [class]=\"$labelClass()\"\n >{{ lbl }}\n @if (rqrd) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n @if (mode() === 'single') {\n <hlm-combobox [formControlName]=\"cnm\" [disabled]=\"effectiveDisabled()\">\n <hlm-combobox-trigger [buttonId]=\"effectiveId()\" [class]=\"$controlClass()\">\n {{ singleDisplay() ?? placeholder() }}\n </hlm-combobox-trigger>\n <hlm-combobox-content *hlmComboboxPortal>\n <hlm-combobox-input [inputId]=\"effectiveId()\" [placeholder]=\"placeholder()\" />\n <div hlmComboboxList>\n @for (option of options(); track option) {\n <hlm-combobox-item [value]=\"option\">{{ option }}</hlm-combobox-item>\n }\n </div>\n <div hlmComboboxEmpty>{{ emptyText() }}</div>\n </hlm-combobox-content>\n </hlm-combobox>\n } @else {\n <hlm-combobox-multiple [formControlName]=\"cnm\" [disabled]=\"effectiveDisabled()\" [class]=\"$controlClass()\">\n <hlm-combobox-chips [class]=\"$chipsClass()\">\n @for (v of selectedValues(); track v) {\n <hlm-combobox-chip [value]=\"v\">{{ v }}</hlm-combobox-chip>\n }\n <input hlmComboboxChipInput [id]=\"effectiveId()\" [placeholder]=\"placeholder()\" />\n </hlm-combobox-chips>\n <hlm-combobox-content *hlmComboboxPortal>\n <div hlmComboboxList>\n @for (option of options(); track option) {\n <hlm-combobox-item [value]=\"option\">{{ option }}</hlm-combobox-item>\n }\n </div>\n <div hlmComboboxEmpty>{{ emptyText() }}</div>\n </hlm-combobox-content>\n </hlm-combobox-multiple>\n }\n\n @if (showError()) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{ resolvedError() }}\n </hlm-error>\n }\n\n @if (hnt) {\n <hlm-hint [id]=\"hintId()\" [class]=\"$hintClass()\">\n {{ hnt }}\n </hlm-hint>\n }\n </hlm-form-field>\n ",
|
|
169
|
+
}]
|
|
170
|
+
}], 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 }] }] } });
|
|
171
|
+
|
|
172
|
+
/*
|
|
173
|
+
* Public API Surface of form-combobox
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Generated bundle index. Do not edit.
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
export { EgFormCombobox, injectEgFormComboboxConfig, provideEgFormComboboxConfig };
|
|
181
|
+
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { ValueProvider } from '@angular/core';
|
|
3
|
+
import { ClassValue } from 'clsx';
|
|
4
|
+
|
|
5
|
+
declare class EgFormCombobox {
|
|
6
|
+
private readonly formGroupDirective;
|
|
7
|
+
private readonly _errorMessages;
|
|
8
|
+
private readonly generatedId;
|
|
9
|
+
private readonly _config;
|
|
10
|
+
private readonly _picker;
|
|
11
|
+
private readonly _single;
|
|
12
|
+
label: _angular_core.InputSignal<string | undefined>;
|
|
13
|
+
controlId: _angular_core.InputSignal<string | undefined>;
|
|
14
|
+
controlName: _angular_core.InputSignal<string>;
|
|
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>;
|
|
22
|
+
hint: _angular_core.InputSignal<string | undefined>;
|
|
23
|
+
id: _angular_core.InputSignal<string | undefined>;
|
|
24
|
+
placeholder: _angular_core.InputSignal<string>;
|
|
25
|
+
emptyText: _angular_core.InputSignal<string>;
|
|
26
|
+
disabled: _angular_core.InputSignal<boolean>;
|
|
27
|
+
required: _angular_core.InputSignal<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* Selection mode. `multiple` renders chips + checkbox-style multi-select
|
|
30
|
+
* (`string[]` model); `single` renders a trigger button + dropdown
|
|
31
|
+
* (`string | null` model). Defaults to `multiple` (original behavior).
|
|
32
|
+
*/
|
|
33
|
+
mode: _angular_core.InputSignal<"single" | "multiple">;
|
|
34
|
+
options: _angular_core.InputSignal<string[]>;
|
|
35
|
+
readonly effectiveId: _angular_core.Signal<string>;
|
|
36
|
+
readonly errorId: _angular_core.Signal<string>;
|
|
37
|
+
readonly hintId: _angular_core.Signal<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
40
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
41
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
42
|
+
* fresh on every change-detection pass.
|
|
43
|
+
*/
|
|
44
|
+
protected resolvedError(): string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
47
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
48
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
49
|
+
*/
|
|
50
|
+
protected showError(): boolean;
|
|
51
|
+
/** Selected values read reactively from the brain model so chips track selection. */
|
|
52
|
+
readonly selectedValues: _angular_core.Signal<string[]>;
|
|
53
|
+
/** Single-mode display value read reactively from the brain model. */
|
|
54
|
+
readonly singleDisplay: _angular_core.Signal<string | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Combined lock for the brain `linkedSignal`-based disabled state: the raw
|
|
57
|
+
* input write always carries the resolved value, so a same-pass
|
|
58
|
+
* wrapper-toggle + `control.disable()` cannot clobber CVA state.
|
|
59
|
+
*/
|
|
60
|
+
effectiveDisabled(): boolean;
|
|
61
|
+
userClass: _angular_core.InputSignal<ClassValue>;
|
|
62
|
+
labelClass: _angular_core.InputSignal<string>;
|
|
63
|
+
controlClass: _angular_core.InputSignal<string>;
|
|
64
|
+
chipsClass: _angular_core.InputSignal<string>;
|
|
65
|
+
errorClass: _angular_core.InputSignal<string>;
|
|
66
|
+
hintClass: _angular_core.InputSignal<string>;
|
|
67
|
+
$userClass: _angular_core.Signal<string>;
|
|
68
|
+
$labelClass: _angular_core.Signal<string>;
|
|
69
|
+
$controlClass: _angular_core.Signal<string>;
|
|
70
|
+
$chipsClass: _angular_core.Signal<string>;
|
|
71
|
+
$errorClass: _angular_core.Signal<string>;
|
|
72
|
+
$hintClass: _angular_core.Signal<string>;
|
|
73
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormCombobox, never>;
|
|
74
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormCombobox, "eg-form-combobox", 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; }; "mode": { "alias": "mode"; "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; }; "chipsClass": { "alias": "chipsClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface EgFormComboboxConfig {
|
|
78
|
+
/**
|
|
79
|
+
* Global class defaults for `eg-form-combobox` styling slots.
|
|
80
|
+
* Each is merged under the matching per-instance `*Class` input
|
|
81
|
+
* (library base < global config < per-instance).
|
|
82
|
+
*/
|
|
83
|
+
labelClass?: string;
|
|
84
|
+
controlClass?: string;
|
|
85
|
+
chipsClass?: string;
|
|
86
|
+
errorClass?: string;
|
|
87
|
+
hintClass?: string;
|
|
88
|
+
}
|
|
89
|
+
declare function provideEgFormComboboxConfig(config: Partial<EgFormComboboxConfig>): ValueProvider;
|
|
90
|
+
declare function injectEgFormComboboxConfig(): EgFormComboboxConfig;
|
|
91
|
+
|
|
92
|
+
export { EgFormCombobox, injectEgFormComboboxConfig, provideEgFormComboboxConfig };
|
|
93
|
+
export type { EgFormComboboxConfig };
|
|
@@ -84,27 +84,34 @@ Selector (from source): `eg-form-date-picker` (standalone component, host `tw:w-
|
|
|
84
84
|
|
|
85
85
|
### `EgFormDatePicker` — `eg-form-date-picker`
|
|
86
86
|
|
|
87
|
-
| Input | Type
|
|
88
|
-
| ------------------- |
|
|
89
|
-
| `controlName` | `string`
|
|
90
|
-
| `label` | `string \| undefined`
|
|
91
|
-
| `error` | `string \| undefined`
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
87
|
+
| Input | Type | Default | Description |
|
|
88
|
+
| ------------------- | --------------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
89
|
+
| `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.** |
|
|
90
|
+
| `label` | `string \| undefined` | — | Label text (hidden when omitted). |
|
|
91
|
+
| `error` | `string \| undefined` | — | Error text shown when invalid. |
|
|
92
|
+
| `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`. |
|
|
93
|
+
| `hint` | `string \| undefined` | — | Hint text shown otherwise. |
|
|
94
|
+
| `controlId` | `string \| undefined` | — | Explicit id (first priority for `effectiveId`). |
|
|
95
|
+
| `id` | `string \| undefined` | — | Fallback id (second priority). |
|
|
96
|
+
| `name` | `string \| undefined` | — | Native `name` forwarded to the inner input (`controlName` wins when set, like `eg-form-text-input`). |
|
|
97
|
+
| `placeholder` | `string` | `'Pick a date'` | Input placeholder. |
|
|
98
|
+
| `readonly` | `boolean` | `false` | Native `readonly` forwarded to the inner input (locks typed text; use `disabled` to lock the calendar too). |
|
|
99
|
+
| `disabled` | `boolean` | `false` | Locks interaction via picker `wrapperDisabled` (form control stays enabled). |
|
|
100
|
+
| `required` | `boolean` | `false` | Shows a red `*` next to the label. |
|
|
101
|
+
| `min` | `Date \| string \| null` | `null` | Minimum date forwarded to `hlm-date-picker`. |
|
|
102
|
+
| `max` | `Date \| string \| null` | `null` | Maximum date forwarded to `hlm-date-picker`. |
|
|
103
|
+
| `autoCloseOnSelect` | `boolean` | config default | Forwarded to `hlm-date-picker` (falls back to `provideHlmDatePickerConfig`, default `false`). |
|
|
104
|
+
| `captionLayout` | union | `'label'` | Forwarded to `hlm-date-picker` (`'dropdown' \| 'label' \| 'dropdown-months' \| 'dropdown-years'`). |
|
|
105
|
+
| `formatDate` | `(date: Date) => string` | config default | Display format, forwarded to `hlm-date-picker` (falls back to `provideHlmDatePickerConfig`). |
|
|
106
|
+
| `transformDate` | `(date: Date) => Date` | config default | Model transform, forwarded to `hlm-date-picker` (falls back to `provideHlmDatePickerConfig`). |
|
|
107
|
+
| `parseDate` | `(value: string) => Date \| null` | config default | Input parsing, forwarded to `hlm-date-picker-input` (falls back to `provideHlmDatePickerConfig`). |
|
|
108
|
+
| `formatInputDate` | `(date: Date) => string` | config default | Edit format while focused, forwarded to `hlm-date-picker-input` (falls back to `provideHlmDatePickerConfig`). |
|
|
109
|
+
| `class` | `ClassValue` | `''` | Extra host classes (base `tw:w-full`). |
|
|
110
|
+
| `labelClass` | `string` | `''` | Extra label classes (base `tw:mb-1`). |
|
|
111
|
+
| `pickerClass` | `string` | `''` | Extra picker-container classes (base `tw:mb-1`). |
|
|
112
|
+
| `inputClass` | `string` | `''` | Extra inner-input classes (e.g. `tw:text-lg` for text size). |
|
|
113
|
+
| `errorClass` | `string` | `''` | Extra error classes (base `tw:mt-0`). |
|
|
114
|
+
| `hintClass` | `string` | `''` | Extra hint classes (base `tw:mt-0`). |
|
|
108
115
|
|
|
109
116
|
| Member | Description |
|
|
110
117
|
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -293,6 +300,7 @@ import { EgFormDatePicker } from '@egose/shadcn-theme-ng/form-date-picker';
|
|
|
293
300
|
label="Event date"
|
|
294
301
|
labelClass="tw:font-semibold"
|
|
295
302
|
pickerClass="tw:max-w-xs"
|
|
303
|
+
inputClass="tw:text-lg"
|
|
296
304
|
hint="Doors open one hour earlier."
|
|
297
305
|
/>
|
|
298
306
|
</form>
|
|
@@ -313,7 +321,26 @@ export class StyledDateComponent {
|
|
|
313
321
|
|
|
314
322
|
## Theming / CSS variables
|
|
315
323
|
|
|
316
|
-
No component-specific CSS variables. Style via `labelClass` / `pickerClass` / `errorClass` / `hintClass`
|
|
324
|
+
No component-specific CSS variables. Style per-instance via `class` / `labelClass` / `pickerClass` / `inputClass` / `errorClass` / `hintClass` (precedence: library base < global config < per-instance).
|
|
325
|
+
|
|
326
|
+
Global defaults (styling analogue of `formatDate`) via the picker config:
|
|
327
|
+
|
|
328
|
+
```ts
|
|
329
|
+
import { provideHlmDatePickerConfig } from '@egose/shadcn-theme-ng/date-picker';
|
|
330
|
+
|
|
331
|
+
await bootstrapApplication(App, {
|
|
332
|
+
providers: [
|
|
333
|
+
provideHlmDatePickerConfig({
|
|
334
|
+
inputClass: 'tw:text-sm', // every date input; per-instance inputClass still wins on conflict
|
|
335
|
+
labelClass: 'tw:font-medium',
|
|
336
|
+
}),
|
|
337
|
+
],
|
|
338
|
+
});
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
The same `labelClass` / `pickerClass` / `inputClass` / `errorClass` / `hintClass` keys exist on
|
|
342
|
+
`HlmDateRangePickerConfig`, `HlmDatePickerMultiConfig`, and `HlmMonthYearPickerConfig` for future
|
|
343
|
+
wrappers. The host keeps `tw:w-full`; constrain width with `class` (e.g. `tw:max-w-xs`) or a wrapping container.
|
|
317
344
|
|
|
318
345
|
## Related subpaths
|
|
319
346
|
|