@egose/shadcn-theme-ng 0.3.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/form-autocomplete/README.md +20 -19
- package/form-autocomplete/fesm2022/form-autocomplete.mjs +38 -4
- package/form-autocomplete/types/form-autocomplete.d.ts +21 -1
- package/form-checkbox/README.md +18 -17
- package/form-checkbox/fesm2022/form-checkbox.mjs +39 -10
- package/form-checkbox/types/form-checkbox.d.ts +21 -1
- package/form-combobox/README.md +21 -20
- package/form-combobox/fesm2022/form-combobox.mjs +38 -4
- package/form-combobox/types/form-combobox.d.ts +21 -1
- package/form-date-picker/README.md +28 -27
- package/form-date-picker/fesm2022/form-date-picker.mjs +39 -10
- package/form-date-picker/types/form-date-picker.d.ts +21 -1
- package/form-date-picker-multi/README.md +28 -27
- package/form-date-picker-multi/fesm2022/form-date-picker-multi.mjs +39 -10
- package/form-date-picker-multi/types/form-date-picker-multi.d.ts +21 -1
- package/form-date-range-picker/README.md +28 -27
- package/form-date-range-picker/fesm2022/form-date-range-picker.mjs +39 -10
- package/form-date-range-picker/types/form-date-range-picker.d.ts +21 -1
- 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 +17 -16
- package/form-input-otp/fesm2022/form-input-otp.mjs +38 -4
- package/form-input-otp/types/form-input-otp.d.ts +21 -1
- package/form-month-year-picker/README.md +26 -25
- package/form-month-year-picker/fesm2022/form-month-year-picker.mjs +39 -10
- package/form-month-year-picker/types/form-month-year-picker.d.ts +21 -1
- package/form-native-select/README.md +18 -17
- package/form-native-select/fesm2022/form-native-select.mjs +39 -10
- package/form-native-select/types/form-native-select.d.ts +21 -1
- package/form-phone-input/README.md +23 -22
- package/form-phone-input/fesm2022/form-phone-input.mjs +39 -10
- package/form-phone-input/types/form-phone-input.d.ts +21 -1
- package/form-radio-group/README.md +18 -17
- package/form-radio-group/fesm2022/form-radio-group.mjs +39 -10
- package/form-radio-group/types/form-radio-group.d.ts +21 -1
- package/form-searchable-multiselect/README.md +18 -17
- package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs +39 -10
- package/form-searchable-multiselect/types/form-searchable-multiselect.d.ts +21 -1
- package/form-select/README.md +20 -19
- package/form-select/fesm2022/form-select.mjs +39 -10
- package/form-select/types/form-select.d.ts +21 -1
- package/form-slider/README.md +19 -18
- package/form-slider/fesm2022/form-slider.mjs +38 -4
- package/form-slider/types/form-slider.d.ts +21 -1
- package/form-switch/README.md +16 -15
- package/form-switch/fesm2022/form-switch.mjs +39 -10
- package/form-switch/types/form-switch.d.ts +21 -1
- package/form-text-input/README.md +27 -26
- package/form-text-input/fesm2022/form-text-input.mjs +39 -10
- package/form-text-input/types/form-text-input.d.ts +21 -1
- package/form-textarea/README.md +23 -22
- package/form-textarea/fesm2022/form-textarea.mjs +39 -10
- package/form-textarea/types/form-textarea.d.ts +21 -1
- package/form-toggle/README.md +17 -16
- package/form-toggle/fesm2022/form-toggle.mjs +40 -6
- package/form-toggle/types/form-toggle.d.ts +21 -3
- package/form-toggle-group/README.md +20 -19
- package/form-toggle-group/fesm2022/form-toggle-group.mjs +39 -10
- package/form-toggle-group/types/form-toggle-group.d.ts +21 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, inject, forwardRef, Injector, DestroyRef, input, booleanAttribute, computed, signal, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
|
-
import { NG_VALUE_ACCESSOR, FormControlName } from '@angular/forms';
|
|
5
|
-
import { HlmFormIdGenerator, HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
4
|
+
import { NG_VALUE_ACCESSOR, FormGroupDirective, FormControlName } from '@angular/forms';
|
|
5
|
+
import { HlmFormIdGenerator, injectEgFormErrorMessages, resolveEgFormError, HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
6
6
|
import { HlmLabel } from '@egose/shadcn-theme-ng/label';
|
|
7
7
|
import { HlmToggle } from '@egose/shadcn-theme-ng/toggle';
|
|
8
8
|
import { hlm } from '@egose/shadcn-theme-ng/utils';
|
|
@@ -34,6 +34,8 @@ class EgFormToggle {
|
|
|
34
34
|
_config = injectEgFormToggleConfig();
|
|
35
35
|
_injector = inject(Injector);
|
|
36
36
|
_destroyRef = inject(DestroyRef);
|
|
37
|
+
_formGroupDirective = inject(FormGroupDirective, { optional: true });
|
|
38
|
+
_errorMessages = injectEgFormErrorMessages();
|
|
37
39
|
_controlDir = null;
|
|
38
40
|
label = input(undefined, /* @ts-ignore */
|
|
39
41
|
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
@@ -41,6 +43,13 @@ class EgFormToggle {
|
|
|
41
43
|
...(ngDevMode ? [{ debugName: "controlId" }] : /* istanbul ignore next */ []));
|
|
42
44
|
error = input(undefined, /* @ts-ignore */
|
|
43
45
|
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
46
|
+
/**
|
|
47
|
+
* Auto-resolve the displayed message from the control's `ValidationErrors`
|
|
48
|
+
* when `error()` is unset. Explicit `error()` always wins. Set to `false`
|
|
49
|
+
* for manual-only messages.
|
|
50
|
+
*/
|
|
51
|
+
autoError = input(true, /* @ts-ignore */
|
|
52
|
+
...(ngDevMode ? [{ debugName: "autoError" }] : /* istanbul ignore next */ []));
|
|
44
53
|
hint = input(undefined, /* @ts-ignore */
|
|
45
54
|
...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
46
55
|
id = input(undefined, /* @ts-ignore */
|
|
@@ -66,16 +75,41 @@ class EgFormToggle {
|
|
|
66
75
|
...(ngDevMode ? [{ debugName: "_disabled" }] : /* istanbul ignore next */ []));
|
|
67
76
|
_status = signal(null, /* @ts-ignore */
|
|
68
77
|
...(ngDevMode ? [{ debugName: "_status" }] : /* istanbul ignore next */ []));
|
|
78
|
+
_submitted = signal(false, /* @ts-ignore */
|
|
79
|
+
...(ngDevMode ? [{ debugName: "_submitted" }] : /* istanbul ignore next */ []));
|
|
80
|
+
/**
|
|
81
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
82
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
83
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
84
|
+
* fresh on every change-detection pass (`showError()` re-evaluates with it
|
|
85
|
+
* via the `_status`/`_submitted` signals).
|
|
86
|
+
*/
|
|
87
|
+
resolvedError() {
|
|
88
|
+
const explicit = this.error();
|
|
89
|
+
if (explicit)
|
|
90
|
+
return explicit;
|
|
91
|
+
if (!this.autoError())
|
|
92
|
+
return undefined;
|
|
93
|
+
return resolveEgFormError(this._controlDir?.control?.errors ?? null, this.label(), this._errorMessages);
|
|
94
|
+
}
|
|
69
95
|
showError = computed(() => {
|
|
70
96
|
this._status();
|
|
97
|
+
this._submitted();
|
|
71
98
|
const control = this._controlDir?.control;
|
|
72
|
-
return !!this.
|
|
99
|
+
return (!!this.resolvedError() &&
|
|
100
|
+
!!control?.errors &&
|
|
101
|
+
(control.touched || control.dirty || !!this._formGroupDirective?.submitted));
|
|
73
102
|
}, /* @ts-ignore */
|
|
74
103
|
...(ngDevMode ? [{ debugName: "showError" }] : /* istanbul ignore next */ []));
|
|
75
104
|
showHint = computed(() => !this.showError() && !!this.hint(), /* @ts-ignore */
|
|
76
105
|
...(ngDevMode ? [{ debugName: "showHint" }] : /* istanbul ignore next */ []));
|
|
77
106
|
_onChange;
|
|
78
107
|
_onTouched;
|
|
108
|
+
ngDoCheck() {
|
|
109
|
+
const submitted = !!this._formGroupDirective?.submitted;
|
|
110
|
+
if (this._submitted() !== submitted)
|
|
111
|
+
this._submitted.set(submitted);
|
|
112
|
+
}
|
|
79
113
|
ngAfterViewInit() {
|
|
80
114
|
// Resolved here (not earlier): this component IS the value accessor for
|
|
81
115
|
// the host FormControlName, so eager self-injection would close a
|
|
@@ -130,7 +164,7 @@ class EgFormToggle {
|
|
|
130
164
|
$hintClass = computed(() => hlm("mt-0", this._config.hintClass, this.hintClass()), /* @ts-ignore */
|
|
131
165
|
...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
|
|
132
166
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormToggle, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
133
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormToggle, isStandalone: true, selector: "eg-form-toggle", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, toggleClass: { classPropertyName: "toggleClass", publicName: "toggleClass", 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": "$userClass()" } }, providers: [EG_FORM_TOGGLE_VALUE_ACCESSOR, provideIcons({ lucideCheck })], ngImport: i0, template: "\n @let lbl = label();\n @let rqrd = required();\n\n <div>\n <div class=\"flex items-center gap-1\">\n <button\n hlmToggle\n type=\"button\"\n [id]=\"effectiveId()\"\n [state]=\"_state() ? 'on' : 'off'\"\n (stateChange)=\"_handleStateChange($event)\"\n [disabled]=\"_disabled()\"\n [variant]=\"variant()\"\n [size]=\"size()\"\n [class]=\"$toggleClass()\"\n >\n @if (_state()) {\n <ng-icon name=\"lucideCheck\" />\n }\n </button>\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 </div>\n\n @if (showError()) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{
|
|
167
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormToggle, isStandalone: true, selector: "eg-form-toggle", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", 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 }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, toggleClass: { classPropertyName: "toggleClass", publicName: "toggleClass", 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": "$userClass()" } }, providers: [EG_FORM_TOGGLE_VALUE_ACCESSOR, provideIcons({ lucideCheck })], ngImport: i0, template: "\n @let lbl = label();\n @let rqrd = required();\n\n <div>\n <div class=\"flex items-center gap-1\">\n <button\n hlmToggle\n type=\"button\"\n [id]=\"effectiveId()\"\n [state]=\"_state() ? 'on' : 'off'\"\n (stateChange)=\"_handleStateChange($event)\"\n [disabled]=\"_disabled()\"\n [variant]=\"variant()\"\n [size]=\"size()\"\n [class]=\"$toggleClass()\"\n >\n @if (_state()) {\n <ng-icon name=\"lucideCheck\" />\n }\n </button>\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 </div>\n\n @if (showError()) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{ resolvedError() }}\n </hlm-error>\n } @else if (showHint()) {\n <hlm-hint [id]=\"hintId()\" [class]=\"$hintClass()\">\n {{ hint() }}\n </hlm-hint>\n }\n </div>\n ", isInline: true, dependencies: [{ kind: "directive", type: HlmToggle, selector: "button[hlmToggle]", inputs: ["variant", "size"] }, { kind: "directive", type: HlmError, selector: "hlm-error", inputs: ["class"] }, { kind: "directive", type: HlmHint, selector: "hlm-hint", inputs: ["class"] }, { kind: "directive", type: HlmLabel, selector: "[hlmLabel]", inputs: ["class"] }, { kind: "component", type: NgIcon, selector: "ng-icon", inputs: ["name", "svg", "size", "strokeWidth", "color"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
134
168
|
}
|
|
135
169
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormToggle, decorators: [{
|
|
136
170
|
type: Component,
|
|
@@ -143,9 +177,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
143
177
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
144
178
|
imports: [HlmToggle, HlmError, HlmHint, HlmLabel, NgIcon],
|
|
145
179
|
providers: [EG_FORM_TOGGLE_VALUE_ACCESSOR, provideIcons({ lucideCheck })],
|
|
146
|
-
template: "\n @let lbl = label();\n @let rqrd = required();\n\n <div>\n <div class=\"flex items-center gap-1\">\n <button\n hlmToggle\n type=\"button\"\n [id]=\"effectiveId()\"\n [state]=\"_state() ? 'on' : 'off'\"\n (stateChange)=\"_handleStateChange($event)\"\n [disabled]=\"_disabled()\"\n [variant]=\"variant()\"\n [size]=\"size()\"\n [class]=\"$toggleClass()\"\n >\n @if (_state()) {\n <ng-icon name=\"lucideCheck\" />\n }\n </button>\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 </div>\n\n @if (showError()) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{
|
|
180
|
+
template: "\n @let lbl = label();\n @let rqrd = required();\n\n <div>\n <div class=\"flex items-center gap-1\">\n <button\n hlmToggle\n type=\"button\"\n [id]=\"effectiveId()\"\n [state]=\"_state() ? 'on' : 'off'\"\n (stateChange)=\"_handleStateChange($event)\"\n [disabled]=\"_disabled()\"\n [variant]=\"variant()\"\n [size]=\"size()\"\n [class]=\"$toggleClass()\"\n >\n @if (_state()) {\n <ng-icon name=\"lucideCheck\" />\n }\n </button>\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 </div>\n\n @if (showError()) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{ resolvedError() }}\n </hlm-error>\n } @else if (showHint()) {\n <hlm-hint [id]=\"hintId()\" [class]=\"$hintClass()\">\n {{ hint() }}\n </hlm-hint>\n }\n </div>\n ",
|
|
147
181
|
}]
|
|
148
|
-
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], controlId: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlId", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], toggleClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "toggleClass", 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 }] }] } });
|
|
182
|
+
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], controlId: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlId", 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 }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], toggleClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "toggleClass", 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 }] }] } });
|
|
149
183
|
|
|
150
184
|
/*
|
|
151
185
|
* Public API Surface of form-toggle
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
|
-
import { AfterViewInit, ValueProvider } from '@angular/core';
|
|
2
|
+
import { AfterViewInit, DoCheck, ValueProvider } from '@angular/core';
|
|
3
3
|
import { BooleanInput } from '@angular/cdk/coercion';
|
|
4
4
|
import { ControlValueAccessor } from '@angular/forms';
|
|
5
5
|
import { ChangeFn, TouchFn } from '@spartan-ng/brain/forms';
|
|
@@ -17,15 +17,23 @@ declare const EG_FORM_TOGGLE_VALUE_ACCESSOR: {
|
|
|
17
17
|
* `ControlValueAccessor` (`BrnToggle` exposes no CVA): bind `formControlName`
|
|
18
18
|
* directly on this element instead of using a `controlName` input.
|
|
19
19
|
*/
|
|
20
|
-
declare class EgFormToggle implements ControlValueAccessor, AfterViewInit {
|
|
20
|
+
declare class EgFormToggle implements ControlValueAccessor, AfterViewInit, DoCheck {
|
|
21
21
|
private readonly generatedId;
|
|
22
22
|
private readonly _config;
|
|
23
23
|
private readonly _injector;
|
|
24
24
|
private readonly _destroyRef;
|
|
25
|
+
private readonly _formGroupDirective;
|
|
26
|
+
private readonly _errorMessages;
|
|
25
27
|
private _controlDir;
|
|
26
28
|
label: _angular_core.InputSignal<string | undefined>;
|
|
27
29
|
controlId: _angular_core.InputSignal<string | undefined>;
|
|
28
30
|
error: _angular_core.InputSignal<string | undefined>;
|
|
31
|
+
/**
|
|
32
|
+
* Auto-resolve the displayed message from the control's `ValidationErrors`
|
|
33
|
+
* when `error()` is unset. Explicit `error()` always wins. Set to `false`
|
|
34
|
+
* for manual-only messages.
|
|
35
|
+
*/
|
|
36
|
+
autoError: _angular_core.InputSignal<boolean>;
|
|
29
37
|
hint: _angular_core.InputSignal<string | undefined>;
|
|
30
38
|
id: _angular_core.InputSignal<string | undefined>;
|
|
31
39
|
disabled: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
|
|
@@ -39,10 +47,20 @@ declare class EgFormToggle implements ControlValueAccessor, AfterViewInit {
|
|
|
39
47
|
private readonly _formDisabled;
|
|
40
48
|
protected readonly _disabled: _angular_core.Signal<boolean>;
|
|
41
49
|
private readonly _status;
|
|
50
|
+
private readonly _submitted;
|
|
51
|
+
/**
|
|
52
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
53
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
54
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
55
|
+
* fresh on every change-detection pass (`showError()` re-evaluates with it
|
|
56
|
+
* via the `_status`/`_submitted` signals).
|
|
57
|
+
*/
|
|
58
|
+
protected resolvedError(): string | undefined;
|
|
42
59
|
protected readonly showError: _angular_core.Signal<boolean>;
|
|
43
60
|
protected readonly showHint: _angular_core.Signal<boolean>;
|
|
44
61
|
protected _onChange?: ChangeFn<boolean>;
|
|
45
62
|
protected _onTouched?: TouchFn;
|
|
63
|
+
ngDoCheck(): void;
|
|
46
64
|
ngAfterViewInit(): void;
|
|
47
65
|
protected _handleStateChange(state: string): void;
|
|
48
66
|
/** CONTROL VALUE ACCESSOR */
|
|
@@ -61,7 +79,7 @@ declare class EgFormToggle implements ControlValueAccessor, AfterViewInit {
|
|
|
61
79
|
$errorClass: _angular_core.Signal<string>;
|
|
62
80
|
$hintClass: _angular_core.Signal<string>;
|
|
63
81
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormToggle, never>;
|
|
64
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormToggle, "eg-form-toggle", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "controlId": { "alias": "controlId"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; "hint": { "alias": "hint"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "toggleClass": { "alias": "toggleClass"; "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>;
|
|
82
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormToggle, "eg-form-toggle", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "controlId": { "alias": "controlId"; "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; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "toggleClass": { "alias": "toggleClass"; "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>;
|
|
65
83
|
}
|
|
66
84
|
|
|
67
85
|
interface EgFormToggleConfig {
|
|
@@ -51,25 +51,26 @@ Selector (from source): `eg-form-toggle-group` (standalone component, host `tw:w
|
|
|
51
51
|
|
|
52
52
|
### `EgFormToggleGroup` — `eg-form-toggle-group`
|
|
53
53
|
|
|
54
|
-
| Input | Type | Default | Description
|
|
55
|
-
| ------------- | ------------------------------- | ----------- |
|
|
56
|
-
| `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.**
|
|
57
|
-
| `label` | `string \| undefined` | — | Group label text (hidden when omitted).
|
|
58
|
-
| `error` | `string \| undefined` | — | Error text shown when invalid.
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
| `
|
|
68
|
-
| `
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
54
|
+
| Input | Type | Default | Description |
|
|
55
|
+
| ------------- | ------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
56
|
+
| `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.** |
|
|
57
|
+
| `label` | `string \| undefined` | — | Group label text (hidden when omitted). |
|
|
58
|
+
| `error` | `string \| undefined` | — | Error text shown when invalid. |
|
|
59
|
+
| `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`. |
|
|
60
|
+
| `hint` | `string \| undefined` | — | Hint text shown otherwise. |
|
|
61
|
+
| `controlId` | `string \| undefined` | — | Explicit id prefix (first priority for `effectiveId`). |
|
|
62
|
+
| `id` | `string \| undefined` | — | Fallback id prefix (second priority). |
|
|
63
|
+
| `type` | `'single' \| 'multiple'` | `'single'` | Selection mode forwarded to the group. |
|
|
64
|
+
| `disabled` | `boolean` | `false` | Locks interaction (form control stays enabled). |
|
|
65
|
+
| `required` | `boolean` | `false` | Shows a red `*` next to the label. |
|
|
66
|
+
| `variant` | toggle variant | `'default'` | Variant forwarded to the group. |
|
|
67
|
+
| `size` | toggle size | `'default'` | Size forwarded to the group. |
|
|
68
|
+
| `options` | `{ value, label, disabled? }[]` | `[]` | Rendered as `hlmToggleGroupItem` buttons. |
|
|
69
|
+
| `class` | `ClassValue` | `''` | Extra host classes (base `tw:w-full`). |
|
|
70
|
+
| `labelClass` | `string` | `''` | Extra group-label classes (base `tw:mb-1`). |
|
|
71
|
+
| `groupClass` | `string` | `''` | Extra group classes. |
|
|
72
|
+
| `errorClass` | `string` | `''` | Extra error classes (base `tw:mt-0`). |
|
|
73
|
+
| `hintClass` | `string` | `''` | Extra hint classes (base `tw:mt-0`). |
|
|
73
74
|
|
|
74
75
|
| Member | Description |
|
|
75
76
|
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { InjectionToken, inject, input, computed, Component } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/forms';
|
|
4
4
|
import { FormGroupDirective, ReactiveFormsModule, ControlContainer } from '@angular/forms';
|
|
5
|
-
import { HlmFormIdGenerator, HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
5
|
+
import { injectEgFormErrorMessages, HlmFormIdGenerator, resolveEgFormError, HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
6
6
|
import { EgFormField } from '@egose/shadcn-theme-ng/form-field-simple';
|
|
7
7
|
import { HlmLabel } from '@egose/shadcn-theme-ng/label';
|
|
8
8
|
import { HlmToggleGroup, HlmToggleGroupItem } from '@egose/shadcn-theme-ng/toggle-group';
|
|
@@ -18,6 +18,7 @@ function injectEgFormToggleGroupConfig() {
|
|
|
18
18
|
|
|
19
19
|
class EgFormToggleGroup {
|
|
20
20
|
formGroupDirective = inject(FormGroupDirective);
|
|
21
|
+
_errorMessages = injectEgFormErrorMessages();
|
|
21
22
|
generatedId = inject(HlmFormIdGenerator).generate('eg-form-toggle-group');
|
|
22
23
|
_config = injectEgFormToggleGroupConfig();
|
|
23
24
|
label = input(undefined, /* @ts-ignore */
|
|
@@ -28,6 +29,13 @@ class EgFormToggleGroup {
|
|
|
28
29
|
...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
|
|
29
30
|
error = input(undefined, /* @ts-ignore */
|
|
30
31
|
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
32
|
+
/**
|
|
33
|
+
* Auto-resolve the displayed message from the control's `ValidationErrors`
|
|
34
|
+
* when `error()` is unset. Explicit `error()` always wins. Set to `false`
|
|
35
|
+
* for manual-only messages.
|
|
36
|
+
*/
|
|
37
|
+
autoError = input(true, /* @ts-ignore */
|
|
38
|
+
...(ngDevMode ? [{ debugName: "autoError" }] : /* istanbul ignore next */ []));
|
|
31
39
|
hint = input(undefined, /* @ts-ignore */
|
|
32
40
|
...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
33
41
|
id = input(undefined, /* @ts-ignore */
|
|
@@ -50,6 +58,32 @@ class EgFormToggleGroup {
|
|
|
50
58
|
...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
|
|
51
59
|
hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
|
|
52
60
|
...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
|
|
61
|
+
/**
|
|
62
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
63
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
64
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
65
|
+
* fresh on every change-detection pass.
|
|
66
|
+
*/
|
|
67
|
+
resolvedError() {
|
|
68
|
+
const explicit = this.error();
|
|
69
|
+
if (explicit)
|
|
70
|
+
return explicit;
|
|
71
|
+
if (!this.autoError())
|
|
72
|
+
return undefined;
|
|
73
|
+
const control = this.formGroupDirective.form.get(this.controlName());
|
|
74
|
+
return resolveEgFormError(control?.errors ?? null, this.label(), this._errorMessages);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
78
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
79
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
80
|
+
*/
|
|
81
|
+
showError() {
|
|
82
|
+
const control = this.formGroupDirective.form.get(this.controlName());
|
|
83
|
+
return (!!this.resolvedError() &&
|
|
84
|
+
!!control?.invalid &&
|
|
85
|
+
(control.dirty || control.touched || this.formGroupDirective.submitted));
|
|
86
|
+
}
|
|
53
87
|
/**
|
|
54
88
|
* Combined lock for the brain `linkedSignal`-based disabled state: the raw
|
|
55
89
|
* input write always carries the resolved value, so a same-pass
|
|
@@ -59,12 +93,7 @@ class EgFormToggleGroup {
|
|
|
59
93
|
return this.disabled() || !!this.formGroupDirective.form.get(this.controlName())?.disabled;
|
|
60
94
|
}
|
|
61
95
|
describedBy() {
|
|
62
|
-
|
|
63
|
-
return this.error() && control?.invalid && (control.dirty || control.touched)
|
|
64
|
-
? this.errorId()
|
|
65
|
-
: this.hint()
|
|
66
|
-
? this.hintId()
|
|
67
|
-
: null;
|
|
96
|
+
return this.showError() ? this.errorId() : this.hint() ? this.hintId() : null;
|
|
68
97
|
}
|
|
69
98
|
// Styling
|
|
70
99
|
userClass = input('', { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: 'class' });
|
|
@@ -88,7 +117,7 @@ class EgFormToggleGroup {
|
|
|
88
117
|
$hintClass = computed(() => hlm("mt-0", this._config.hintClass, this.hintClass()), /* @ts-ignore */
|
|
89
118
|
...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
|
|
90
119
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormToggleGroup, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
91
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormToggleGroup, isStandalone: true, selector: "eg-form-toggle-group", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", isSignal: true, isRequired: false, transformFunction: null }, controlName: { classPropertyName: "controlName", publicName: "controlName", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", 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 }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", 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 }, groupClass: { classPropertyName: "groupClass", publicName: "groupClass", isSignal: true, isRequired: false, transformFunction: null }, errorClass: { classPropertyName: "errorClass", publicName: "errorClass", isSignal: true, isRequired: false, transformFunction: null }, hintClass: { classPropertyName: "hintClass", publicName: "hintClass", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "$userClass()" } }, providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }], ngImport: i0, template: "\n @let lbl = label();\n @let cnm = controlName();\n @let
|
|
120
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormToggleGroup, isStandalone: true, selector: "eg-form-toggle-group", 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 }, type: { classPropertyName: "type", publicName: "type", 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 }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", 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 }, groupClass: { classPropertyName: "groupClass", publicName: "groupClass", isSignal: true, isRequired: false, transformFunction: null }, errorClass: { classPropertyName: "errorClass", publicName: "errorClass", isSignal: true, isRequired: false, transformFunction: null }, hintClass: { classPropertyName: "hintClass", publicName: "hintClass", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "$userClass()" } }, providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }], ngImport: i0, template: "\n @let lbl = label();\n @let cnm = controlName();\n @let hnt = hint();\n @let rqrd = required();\n\n <eg-form-field>\n @if (lbl) {\n <span hlmLabel [class]=\"$labelClass()\"\n >{{ lbl }}\n @if (rqrd) {\n <span class=\"text-red-500\">*</span>\n }\n </span>\n }\n\n <hlm-toggle-group\n [formControlName]=\"cnm\"\n [type]=\"type()\"\n [disabled]=\"effectiveDisabled()\"\n [variant]=\"variant()\"\n [size]=\"size()\"\n [class]=\"$groupClass()\"\n >\n @for (option of options(); track option.value) {\n <button\n hlmToggleGroupItem\n type=\"button\"\n [value]=\"option.value\"\n [disabled]=\"option.disabled ?? false\"\n [attr.aria-describedby]=\"describedBy()\"\n >\n {{ option.label }}\n </button>\n }\n </hlm-toggle-group>\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.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { 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: HlmToggleGroup, selector: "[hlmToggleGroup],hlm-toggle-group", inputs: ["variant", "size", "spacing", "orientation"] }, { kind: "directive", type: HlmToggleGroupItem, selector: "button[hlmToggleGroupItem]", inputs: ["variant", "size"] }, { kind: "component", type: EgFormField, selector: "eg-form-field", inputs: ["class"] }] });
|
|
92
121
|
}
|
|
93
122
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormToggleGroup, decorators: [{
|
|
94
123
|
type: Component,
|
|
@@ -100,9 +129,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
100
129
|
},
|
|
101
130
|
imports: [ReactiveFormsModule, HlmError, HlmHint, HlmLabel, HlmToggleGroup, HlmToggleGroupItem, EgFormField],
|
|
102
131
|
providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
|
|
103
|
-
template: "\n @let lbl = label();\n @let cnm = controlName();\n @let
|
|
132
|
+
template: "\n @let lbl = label();\n @let cnm = controlName();\n @let hnt = hint();\n @let rqrd = required();\n\n <eg-form-field>\n @if (lbl) {\n <span hlmLabel [class]=\"$labelClass()\"\n >{{ lbl }}\n @if (rqrd) {\n <span class=\"text-red-500\">*</span>\n }\n </span>\n }\n\n <hlm-toggle-group\n [formControlName]=\"cnm\"\n [type]=\"type()\"\n [disabled]=\"effectiveDisabled()\"\n [variant]=\"variant()\"\n [size]=\"size()\"\n [class]=\"$groupClass()\"\n >\n @for (option of options(); track option.value) {\n <button\n hlmToggleGroupItem\n type=\"button\"\n [value]=\"option.value\"\n [disabled]=\"option.disabled ?? false\"\n [attr.aria-describedby]=\"describedBy()\"\n >\n {{ option.label }}\n </button>\n }\n </hlm-toggle-group>\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 ",
|
|
104
133
|
}]
|
|
105
|
-
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], controlId: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlId", required: false }] }], controlName: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlName", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", 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 }] }], groupClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
|
|
134
|
+
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], controlId: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlId", required: false }] }], controlName: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlName", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], autoError: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoError", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", 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 }] }], groupClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
|
|
106
135
|
|
|
107
136
|
/*
|
|
108
137
|
* Public API Surface of form-toggle-group
|
|
@@ -9,12 +9,19 @@ interface ToggleGroupOption {
|
|
|
9
9
|
}
|
|
10
10
|
declare class EgFormToggleGroup {
|
|
11
11
|
private readonly formGroupDirective;
|
|
12
|
+
private readonly _errorMessages;
|
|
12
13
|
private readonly generatedId;
|
|
13
14
|
private readonly _config;
|
|
14
15
|
label: _angular_core.InputSignal<string | undefined>;
|
|
15
16
|
controlId: _angular_core.InputSignal<string | undefined>;
|
|
16
17
|
controlName: _angular_core.InputSignal<string>;
|
|
17
18
|
error: _angular_core.InputSignal<string | undefined>;
|
|
19
|
+
/**
|
|
20
|
+
* Auto-resolve the displayed message from the control's `ValidationErrors`
|
|
21
|
+
* when `error()` is unset. Explicit `error()` always wins. Set to `false`
|
|
22
|
+
* for manual-only messages.
|
|
23
|
+
*/
|
|
24
|
+
autoError: _angular_core.InputSignal<boolean>;
|
|
18
25
|
hint: _angular_core.InputSignal<string | undefined>;
|
|
19
26
|
id: _angular_core.InputSignal<string | undefined>;
|
|
20
27
|
type: _angular_core.InputSignal<"single" | "multiple">;
|
|
@@ -26,6 +33,19 @@ declare class EgFormToggleGroup {
|
|
|
26
33
|
readonly effectiveId: _angular_core.Signal<string>;
|
|
27
34
|
readonly errorId: _angular_core.Signal<string>;
|
|
28
35
|
readonly hintId: _angular_core.Signal<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
38
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
39
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
40
|
+
* fresh on every change-detection pass.
|
|
41
|
+
*/
|
|
42
|
+
protected resolvedError(): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
45
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
46
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
47
|
+
*/
|
|
48
|
+
protected showError(): boolean;
|
|
29
49
|
/**
|
|
30
50
|
* Combined lock for the brain `linkedSignal`-based disabled state: the raw
|
|
31
51
|
* input write always carries the resolved value, so a same-pass
|
|
@@ -44,7 +64,7 @@ declare class EgFormToggleGroup {
|
|
|
44
64
|
$errorClass: _angular_core.Signal<string>;
|
|
45
65
|
$hintClass: _angular_core.Signal<string>;
|
|
46
66
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormToggleGroup, never>;
|
|
47
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormToggleGroup, "eg-form-toggle-group", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "controlId": { "alias": "controlId"; "required": false; "isSignal": true; }; "controlName": { "alias": "controlName"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; "hint": { "alias": "hint"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "type": { "alias": "type"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "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; }; "groupClass": { "alias": "groupClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
67
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormToggleGroup, "eg-form-toggle-group", 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; }; "type": { "alias": "type"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "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; }; "groupClass": { "alias": "groupClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
48
68
|
}
|
|
49
69
|
|
|
50
70
|
interface EgFormToggleGroupConfig {
|