@egose/shadcn-theme-ng-tw 0.3.0 → 0.5.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/form-autocomplete/README.md +20 -19
- package/form-autocomplete/fesm2022/form-autocomplete.mjs +47 -14
- package/form-autocomplete/types/form-autocomplete.d.ts +22 -1
- package/form-checkbox/README.md +20 -19
- package/form-checkbox/fesm2022/form-checkbox.mjs +102 -20
- package/form-checkbox/types/form-checkbox.d.ts +43 -3
- package/form-combobox/README.md +21 -20
- package/form-combobox/fesm2022/form-combobox.mjs +47 -14
- package/form-combobox/types/form-combobox.d.ts +22 -1
- package/form-date-picker/README.md +28 -27
- package/form-date-picker/fesm2022/form-date-picker.mjs +48 -20
- package/form-date-picker/types/form-date-picker.d.ts +22 -1
- package/form-date-picker-multi/README.md +28 -27
- package/form-date-picker-multi/fesm2022/form-date-picker-multi.mjs +48 -20
- package/form-date-picker-multi/types/form-date-picker-multi.d.ts +22 -1
- package/form-date-range-picker/README.md +28 -27
- package/form-date-range-picker/fesm2022/form-date-range-picker.mjs +48 -20
- package/form-date-range-picker/types/form-date-range-picker.d.ts +22 -1
- package/form-field/README.md +9 -0
- package/form-field/fesm2022/form-field.mjs +97 -5
- package/form-field/types/form-field.d.ts +96 -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 +46 -13
- package/form-input-otp/types/form-input-otp.d.ts +22 -1
- package/form-month-year-picker/README.md +26 -25
- package/form-month-year-picker/fesm2022/form-month-year-picker.mjs +48 -20
- package/form-month-year-picker/types/form-month-year-picker.d.ts +22 -1
- package/form-native-select/README.md +18 -17
- package/form-native-select/fesm2022/form-native-select.mjs +61 -21
- package/form-native-select/types/form-native-select.d.ts +22 -1
- package/form-phone-input/README.md +23 -22
- package/form-phone-input/fesm2022/form-phone-input.mjs +47 -19
- package/form-phone-input/types/form-phone-input.d.ts +22 -1
- package/form-radio-group/README.md +18 -17
- package/form-radio-group/fesm2022/form-radio-group.mjs +47 -19
- package/form-radio-group/types/form-radio-group.d.ts +22 -1
- package/form-searchable-multiselect/README.md +18 -17
- package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs +47 -19
- package/form-searchable-multiselect/types/form-searchable-multiselect.d.ts +22 -1
- package/form-select/README.md +20 -19
- package/form-select/fesm2022/form-select.mjs +47 -19
- package/form-select/types/form-select.d.ts +22 -1
- package/form-slider/README.md +19 -18
- package/form-slider/fesm2022/form-slider.mjs +46 -13
- package/form-slider/types/form-slider.d.ts +22 -1
- package/form-switch/README.md +16 -15
- package/form-switch/fesm2022/form-switch.mjs +47 -19
- package/form-switch/types/form-switch.d.ts +22 -1
- package/form-text-input/README.md +27 -26
- package/form-text-input/fesm2022/form-text-input.mjs +47 -19
- package/form-text-input/types/form-text-input.d.ts +22 -1
- package/form-textarea/README.md +23 -22
- package/form-textarea/fesm2022/form-textarea.mjs +47 -19
- package/form-textarea/types/form-textarea.d.ts +22 -1
- package/form-toggle/README.md +17 -16
- package/form-toggle/fesm2022/form-toggle.mjs +48 -11
- package/form-toggle/types/form-toggle.d.ts +22 -3
- package/form-toggle-group/README.md +20 -19
- package/form-toggle-group/fesm2022/form-toggle-group.mjs +47 -19
- package/form-toggle-group/types/form-toggle-group.d.ts +22 -1
- package/package.json +5 -1
- package/stepper/README.md +353 -0
- package/stepper/fesm2022/stepper.mjs +686 -0
- package/stepper/package.json +24 -0
- package/stepper/types/stepper.d.ts +116 -0
package/form-select/README.md
CHANGED
|
@@ -75,25 +75,26 @@ In multi mode the inner `brn-select` becomes `brn-select-multiple`; everything e
|
|
|
75
75
|
|
|
76
76
|
### `eg-form-select` — `EgFormSelect`
|
|
77
77
|
|
|
78
|
-
| Input | Type | Default | Description
|
|
79
|
-
| --------------------- | --------------------- | ----------- |
|
|
80
|
-
| `label` | `string \| undefined` | `undefined` | Field label rendered as `<label hlmLabel>` bound to the trigger button id.
|
|
81
|
-
| `controlName` | `string` | `''` | **Required.** Control name in the parent `FormGroup`; forwarded as `formControlName`.
|
|
82
|
-
| `controlId` | `string \| undefined` | `undefined` | Explicit id; falls back to `id`, then generated `eg-form-select-…`.
|
|
83
|
-
| `id` | `string \| undefined` | `undefined` | Alias for an explicit id (same fallback chain). Forwarded as `buttonId` to the select trigger.
|
|
84
|
-
| `error` | `string \| undefined` | `undefined` | Error text rendered in `<hlm-error>`.
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
78
|
+
| Input | Type | Default | Description |
|
|
79
|
+
| --------------------- | --------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
80
|
+
| `label` | `string \| undefined` | `undefined` | Field label rendered as `<label hlmLabel>` bound to the trigger button id. |
|
|
81
|
+
| `controlName` | `string` | `''` | **Required.** Control name in the parent `FormGroup`; forwarded as `formControlName`. |
|
|
82
|
+
| `controlId` | `string \| undefined` | `undefined` | Explicit id; falls back to `id`, then generated `eg-form-select-…`. |
|
|
83
|
+
| `id` | `string \| undefined` | `undefined` | Alias for an explicit id (same fallback chain). Forwarded as `buttonId` to the select trigger. |
|
|
84
|
+
| `error` | `string \| undefined` | `undefined` | Error text rendered in `<hlm-error>`. |
|
|
85
|
+
| `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`. |
|
|
86
|
+
| `hint` | `string \| undefined` | `undefined` | Hint text rendered in `<hlm-hint>`. |
|
|
87
|
+
| `placeholder` | `string` | `''` | Placeholder forwarded to `<hlm-select-value>`. |
|
|
88
|
+
| `disabled` | `boolean` | `false` | Forwarded as `wrapperDisabled` to `<hlm-select-trigger>`. |
|
|
89
|
+
| `required` | `boolean` | `false` | Renders a red `*` next to the label (pair with `Validators.required`). |
|
|
90
|
+
| `multiple` | `boolean` | `false` | When `true`, renders `brn-select-multiple` (value is `string[]`). |
|
|
91
|
+
| `options` | `SelectOption[]` | `[]` | `{ value: string; label: string }[]` rendered as `<hlm-select-item>` rows. Local interface, not exported. |
|
|
92
|
+
| `optionsLabel` | `string \| undefined` | `undefined` | Optional group heading rendered once as `<hlm-select-label>`. |
|
|
93
|
+
| `class` (`userClass`) | `ClassValue` | `''` | Extra host classes (merged over `tw:flex tw:flex-col`). |
|
|
94
|
+
| `labelClass` | `string` | `''` | Extra label classes (merged over `tw:mb-1 tw:gap-0`). |
|
|
95
|
+
| `selectClass` | `string` | `''` | Extra trigger classes (merged over `tw:w-full`). |
|
|
96
|
+
| `errorClass` | `string` | `''` | Extra error classes (merged over `tw:mt-0`). |
|
|
97
|
+
| `hintClass` | `string` | `''` | Extra hint classes (merged over `tw:mt-0`). |
|
|
97
98
|
|
|
98
99
|
No outputs. Readonly computeds/methods: `effectiveId()`, `errorId()`, `hintId()`, `describedBy(): string | null` (error id when invalid + dirty/touched, else hint id, else `null`).
|
|
99
100
|
|
|
@@ -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, HlmFormField, HlmError, HlmHint } from '@egose/shadcn-theme-ng-tw/form-field';
|
|
5
|
+
import { injectEgFormErrorMessages, HlmFormIdGenerator, injectEgFormSharedConfig, resolveEgFormError, HlmFormField, HlmError, HlmHint } from '@egose/shadcn-theme-ng-tw/form-field';
|
|
6
6
|
import { HlmLabel } from '@egose/shadcn-theme-ng-tw/label';
|
|
7
7
|
import { hlm } from '@egose/shadcn-theme-ng-tw/utils';
|
|
8
8
|
import { BrnSelectImports } from '@spartan-ng/brain/select';
|
|
@@ -19,8 +19,10 @@ function injectEgFormSelectConfig() {
|
|
|
19
19
|
|
|
20
20
|
class EgFormSelect {
|
|
21
21
|
formGroupDirective = inject(FormGroupDirective);
|
|
22
|
+
_errorMessages = injectEgFormErrorMessages();
|
|
22
23
|
generatedId = inject(HlmFormIdGenerator).generate('eg-form-select');
|
|
23
24
|
_config = injectEgFormSelectConfig();
|
|
25
|
+
_shared = injectEgFormSharedConfig();
|
|
24
26
|
label = input(undefined, /* @ts-ignore */
|
|
25
27
|
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
26
28
|
controlId = input(undefined, /* @ts-ignore */
|
|
@@ -29,6 +31,13 @@ class EgFormSelect {
|
|
|
29
31
|
...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
|
|
30
32
|
error = input(undefined, /* @ts-ignore */
|
|
31
33
|
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
34
|
+
/**
|
|
35
|
+
* Auto-resolve the displayed message from the control's `ValidationErrors`
|
|
36
|
+
* when `error()` is unset. Explicit `error()` always wins. Set to `false`
|
|
37
|
+
* for manual-only messages.
|
|
38
|
+
*/
|
|
39
|
+
autoError = input(true, /* @ts-ignore */
|
|
40
|
+
...(ngDevMode ? [{ debugName: "autoError" }] : /* istanbul ignore next */ []));
|
|
32
41
|
hint = input(undefined, /* @ts-ignore */
|
|
33
42
|
...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
34
43
|
// HTML/select attributes
|
|
@@ -46,13 +55,34 @@ class EgFormSelect {
|
|
|
46
55
|
...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
|
|
47
56
|
hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
|
|
48
57
|
...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
|
|
49
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
60
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
61
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
62
|
+
* fresh on every change-detection pass.
|
|
63
|
+
*/
|
|
64
|
+
resolvedError() {
|
|
65
|
+
const explicit = this.error();
|
|
66
|
+
if (explicit)
|
|
67
|
+
return explicit;
|
|
68
|
+
if (!this.autoError())
|
|
69
|
+
return undefined;
|
|
70
|
+
const control = this.formGroupDirective.form.get(this.controlName());
|
|
71
|
+
return resolveEgFormError(control?.errors ?? null, this.label(), this._errorMessages);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
75
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
76
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
77
|
+
*/
|
|
78
|
+
showError() {
|
|
50
79
|
const control = this.formGroupDirective.form.get(this.controlName());
|
|
51
|
-
return this.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
80
|
+
return (!!this.resolvedError() &&
|
|
81
|
+
!!control?.invalid &&
|
|
82
|
+
(control.dirty || control.touched || this.formGroupDirective.submitted));
|
|
83
|
+
}
|
|
84
|
+
describedBy() {
|
|
85
|
+
return this.showError() ? this.errorId() : this.hint() ? this.hintId() : null;
|
|
56
86
|
}
|
|
57
87
|
// Select-specific
|
|
58
88
|
multiple = input(false, /* @ts-ignore */
|
|
@@ -74,19 +104,18 @@ class EgFormSelect {
|
|
|
74
104
|
// Computed classes (library base < global config < per-instance)
|
|
75
105
|
$userClass = computed(() => hlm('tw:w-full', this.userClass()), /* @ts-ignore */
|
|
76
106
|
...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
|
|
77
|
-
$labelClass = computed(() => hlm('tw:mb-1 tw:gap-0', this._config.labelClass, this.labelClass()), /* @ts-ignore */
|
|
107
|
+
$labelClass = computed(() => hlm('tw:mb-1 tw:gap-0', this._shared.labelClass, this._config.labelClass, this.labelClass()), /* @ts-ignore */
|
|
78
108
|
...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
|
|
79
|
-
$selectClass = computed(() => hlm('tw:w-full', this._config.selectClass, this.selectClass()), /* @ts-ignore */
|
|
109
|
+
$selectClass = computed(() => hlm('tw:w-full', this._shared.selectClass, this._config.selectClass, this.selectClass()), /* @ts-ignore */
|
|
80
110
|
...(ngDevMode ? [{ debugName: "$selectClass" }] : /* istanbul ignore next */ []));
|
|
81
|
-
$errorClass = computed(() => hlm('tw:mt-0', this._config.errorClass, this.errorClass()), /* @ts-ignore */
|
|
111
|
+
$errorClass = computed(() => hlm('tw:mt-0', this._shared.errorClass, this._config.errorClass, this.errorClass()), /* @ts-ignore */
|
|
82
112
|
...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
|
|
83
|
-
$hintClass = computed(() => hlm('tw:mt-0', this._config.hintClass, this.hintClass()), /* @ts-ignore */
|
|
113
|
+
$hintClass = computed(() => hlm('tw:mt-0', this._shared.hintClass, this._config.hintClass, this.hintClass()), /* @ts-ignore */
|
|
84
114
|
...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
|
|
85
115
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormSelect, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
86
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormSelect, isStandalone: true, selector: "eg-form-select", 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 }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", 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 }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, optionsLabel: { classPropertyName: "optionsLabel", publicName: "optionsLabel", 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 }, selectClass: { classPropertyName: "selectClass", publicName: "selectClass", 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: `
|
|
116
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormSelect, isStandalone: true, selector: "eg-form-select", 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 }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, optionsLabel: { classPropertyName: "optionsLabel", publicName: "optionsLabel", 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 }, selectClass: { classPropertyName: "selectClass", publicName: "selectClass", 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: `
|
|
87
117
|
@let lbl = label();
|
|
88
118
|
@let cnm = controlName();
|
|
89
|
-
@let err = error();
|
|
90
119
|
@let hnt = hint();
|
|
91
120
|
@let rqrd = required();
|
|
92
121
|
|
|
@@ -146,9 +175,9 @@ class EgFormSelect {
|
|
|
146
175
|
</brn-select>
|
|
147
176
|
}
|
|
148
177
|
|
|
149
|
-
@if (
|
|
178
|
+
@if (showError()) {
|
|
150
179
|
<hlm-error [id]="errorId()" [class]="$errorClass()">
|
|
151
|
-
{{
|
|
180
|
+
{{ resolvedError() }}
|
|
152
181
|
</hlm-error>
|
|
153
182
|
}
|
|
154
183
|
|
|
@@ -187,7 +216,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
187
216
|
template: `
|
|
188
217
|
@let lbl = label();
|
|
189
218
|
@let cnm = controlName();
|
|
190
|
-
@let err = error();
|
|
191
219
|
@let hnt = hint();
|
|
192
220
|
@let rqrd = required();
|
|
193
221
|
|
|
@@ -247,9 +275,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
247
275
|
</brn-select>
|
|
248
276
|
}
|
|
249
277
|
|
|
250
|
-
@if (
|
|
278
|
+
@if (showError()) {
|
|
251
279
|
<hlm-error [id]="errorId()" [class]="$errorClass()">
|
|
252
|
-
{{
|
|
280
|
+
{{ resolvedError() }}
|
|
253
281
|
</hlm-error>
|
|
254
282
|
}
|
|
255
283
|
|
|
@@ -261,7 +289,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
261
289
|
</hlm-form-field>
|
|
262
290
|
`,
|
|
263
291
|
}]
|
|
264
|
-
}], 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 }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], optionsLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionsLabel", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], selectClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
|
|
292
|
+
}], 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 }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], optionsLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionsLabel", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], selectClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
|
|
265
293
|
|
|
266
294
|
/*
|
|
267
295
|
* Public API Surface of form-select
|
|
@@ -8,12 +8,20 @@ interface SelectOption {
|
|
|
8
8
|
}
|
|
9
9
|
declare class EgFormSelect {
|
|
10
10
|
private readonly formGroupDirective;
|
|
11
|
+
private readonly _errorMessages;
|
|
11
12
|
private readonly generatedId;
|
|
12
13
|
private readonly _config;
|
|
14
|
+
private readonly _shared;
|
|
13
15
|
label: _angular_core.InputSignal<string | undefined>;
|
|
14
16
|
controlId: _angular_core.InputSignal<string | undefined>;
|
|
15
17
|
controlName: _angular_core.InputSignal<string>;
|
|
16
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>;
|
|
17
25
|
hint: _angular_core.InputSignal<string | undefined>;
|
|
18
26
|
id: _angular_core.InputSignal<string | undefined>;
|
|
19
27
|
placeholder: _angular_core.InputSignal<string>;
|
|
@@ -22,6 +30,19 @@ declare class EgFormSelect {
|
|
|
22
30
|
readonly effectiveId: _angular_core.Signal<string>;
|
|
23
31
|
readonly errorId: _angular_core.Signal<string>;
|
|
24
32
|
readonly hintId: _angular_core.Signal<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
35
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
36
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
37
|
+
* fresh on every change-detection pass.
|
|
38
|
+
*/
|
|
39
|
+
protected resolvedError(): string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
42
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
43
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
44
|
+
*/
|
|
45
|
+
protected showError(): boolean;
|
|
25
46
|
describedBy(): string | null;
|
|
26
47
|
multiple: _angular_core.InputSignal<boolean>;
|
|
27
48
|
options: _angular_core.InputSignal<SelectOption[]>;
|
|
@@ -37,7 +58,7 @@ declare class EgFormSelect {
|
|
|
37
58
|
$errorClass: _angular_core.Signal<string>;
|
|
38
59
|
$hintClass: _angular_core.Signal<string>;
|
|
39
60
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormSelect, never>;
|
|
40
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormSelect, "eg-form-select", 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; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "multiple": { "alias": "multiple"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; "optionsLabel": { "alias": "optionsLabel"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "selectClass": { "alias": "selectClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
61
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormSelect, "eg-form-select", 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; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "multiple": { "alias": "multiple"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; "optionsLabel": { "alias": "optionsLabel"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "selectClass": { "alias": "selectClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
41
62
|
}
|
|
42
63
|
|
|
43
64
|
interface EgFormSelectConfig {
|
package/form-slider/README.md
CHANGED
|
@@ -71,24 +71,25 @@ Selector (from source): `eg-form-slider` (standalone component, host `tw:w-full`
|
|
|
71
71
|
|
|
72
72
|
### `EgFormSlider` — `eg-form-slider`
|
|
73
73
|
|
|
74
|
-
| Input | Type | Default | Description
|
|
75
|
-
| ------------- | --------------------- | ------- |
|
|
76
|
-
| `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.**
|
|
77
|
-
| `label` | `string \| undefined` | — | Label text (hidden when omitted).
|
|
78
|
-
| `error` | `string \| undefined` | — | Error text shown when invalid.
|
|
79
|
-
| `
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
91
|
-
| `
|
|
74
|
+
| Input | Type | Default | Description |
|
|
75
|
+
| ------------- | --------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
76
|
+
| `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.** |
|
|
77
|
+
| `label` | `string \| undefined` | — | Label text (hidden when omitted). |
|
|
78
|
+
| `error` | `string \| undefined` | — | Error text shown when invalid. |
|
|
79
|
+
| `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`. |
|
|
80
|
+
| `hint` | `string \| undefined` | — | Hint text shown otherwise. |
|
|
81
|
+
| `controlId` | `string \| undefined` | — | Explicit id (first priority for `effectiveId`). |
|
|
82
|
+
| `id` | `string \| undefined` | — | Fallback id (second priority). |
|
|
83
|
+
| `min` | `number` | `0` | Minimum value forwarded to the slider. |
|
|
84
|
+
| `max` | `number` | `100` | Maximum value forwarded to the slider. |
|
|
85
|
+
| `step` | `number` | `1` | Step value forwarded to the slider. |
|
|
86
|
+
| `disabled` | `boolean` | `false` | Locks interaction (form control stays enabled). |
|
|
87
|
+
| `required` | `boolean` | `false` | Shows a red `*` next to the label. |
|
|
88
|
+
| `class` | `ClassValue` | `''` | Extra host classes (base `tw:w-full`). |
|
|
89
|
+
| `labelClass` | `string` | `''` | Extra label classes (base `tw:mb-1`). |
|
|
90
|
+
| `sliderClass` | `string` | `''` | Extra slider classes (base `tw:w-full`). |
|
|
91
|
+
| `errorClass` | `string` | `''` | Extra error classes (base `tw:mt-0`). |
|
|
92
|
+
| `hintClass` | `string` | `''` | Extra hint classes (base `tw:mt-0`). |
|
|
92
93
|
|
|
93
94
|
| Member | Description |
|
|
94
95
|
| -------------------- | -------------------------------------------------------------- |
|
|
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { InjectionToken, inject, input, numberAttribute, 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, HlmFormField, HlmError, HlmHint } from '@egose/shadcn-theme-ng-tw/form-field';
|
|
5
|
+
import { injectEgFormErrorMessages, HlmFormIdGenerator, injectEgFormSharedConfig, resolveEgFormError, HlmFormField, HlmError, HlmHint } from '@egose/shadcn-theme-ng-tw/form-field';
|
|
6
6
|
import { HlmLabel } from '@egose/shadcn-theme-ng-tw/label';
|
|
7
7
|
import { HlmSlider } from '@egose/shadcn-theme-ng-tw/slider';
|
|
8
8
|
import { hlm } from '@egose/shadcn-theme-ng-tw/utils';
|
|
@@ -17,8 +17,10 @@ function injectEgFormSliderConfig() {
|
|
|
17
17
|
|
|
18
18
|
class EgFormSlider {
|
|
19
19
|
formGroupDirective = inject(FormGroupDirective);
|
|
20
|
+
_errorMessages = injectEgFormErrorMessages();
|
|
20
21
|
generatedId = inject(HlmFormIdGenerator).generate('eg-form-slider');
|
|
21
22
|
_config = injectEgFormSliderConfig();
|
|
23
|
+
_shared = injectEgFormSharedConfig();
|
|
22
24
|
label = input(undefined, /* @ts-ignore */
|
|
23
25
|
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
24
26
|
controlId = input(undefined, /* @ts-ignore */
|
|
@@ -27,6 +29,13 @@ class EgFormSlider {
|
|
|
27
29
|
...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
|
|
28
30
|
error = input(undefined, /* @ts-ignore */
|
|
29
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 */ []));
|
|
30
39
|
hint = input(undefined, /* @ts-ignore */
|
|
31
40
|
...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
32
41
|
id = input(undefined, /* @ts-ignore */
|
|
@@ -46,6 +55,32 @@ class EgFormSlider {
|
|
|
46
55
|
...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
|
|
47
56
|
hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
|
|
48
57
|
...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
|
|
58
|
+
/**
|
|
59
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
60
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
61
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
62
|
+
* fresh on every change-detection pass.
|
|
63
|
+
*/
|
|
64
|
+
resolvedError() {
|
|
65
|
+
const explicit = this.error();
|
|
66
|
+
if (explicit)
|
|
67
|
+
return explicit;
|
|
68
|
+
if (!this.autoError())
|
|
69
|
+
return undefined;
|
|
70
|
+
const control = this.formGroupDirective.form.get(this.controlName());
|
|
71
|
+
return resolveEgFormError(control?.errors ?? null, this.label(), this._errorMessages);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
75
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
76
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
77
|
+
*/
|
|
78
|
+
showError() {
|
|
79
|
+
const control = this.formGroupDirective.form.get(this.controlName());
|
|
80
|
+
return (!!this.resolvedError() &&
|
|
81
|
+
!!control?.invalid &&
|
|
82
|
+
(control.dirty || control.touched || this.formGroupDirective.submitted));
|
|
83
|
+
}
|
|
49
84
|
/**
|
|
50
85
|
* Combined lock for the brain `linkedSignal`-based disabled state: the raw
|
|
51
86
|
* input write always carries the resolved value, so a same-pass
|
|
@@ -69,19 +104,18 @@ class EgFormSlider {
|
|
|
69
104
|
// Computed classes (library base < global config < per-instance)
|
|
70
105
|
$userClass = computed(() => hlm('tw:w-full', this.userClass()), /* @ts-ignore */
|
|
71
106
|
...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
|
|
72
|
-
$labelClass = computed(() => hlm('tw:mb-1', this._config.labelClass, this.labelClass()), /* @ts-ignore */
|
|
107
|
+
$labelClass = computed(() => hlm('tw:mb-1', this._shared.labelClass, this._config.labelClass, this.labelClass()), /* @ts-ignore */
|
|
73
108
|
...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
|
|
74
|
-
$sliderClass = computed(() => hlm('tw:w-full', this._config.sliderClass, this.sliderClass()), /* @ts-ignore */
|
|
109
|
+
$sliderClass = computed(() => hlm('tw:w-full', this._shared.sliderClass, this._config.sliderClass, this.sliderClass()), /* @ts-ignore */
|
|
75
110
|
...(ngDevMode ? [{ debugName: "$sliderClass" }] : /* istanbul ignore next */ []));
|
|
76
|
-
$errorClass = computed(() => hlm('tw:mt-0', this._config.errorClass, this.errorClass()), /* @ts-ignore */
|
|
111
|
+
$errorClass = computed(() => hlm('tw:mt-0', this._shared.errorClass, this._config.errorClass, this.errorClass()), /* @ts-ignore */
|
|
77
112
|
...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
|
|
78
|
-
$hintClass = computed(() => hlm('tw:mt-0', this._config.hintClass, this.hintClass()), /* @ts-ignore */
|
|
113
|
+
$hintClass = computed(() => hlm('tw:mt-0', this._shared.hintClass, this._config.hintClass, this.hintClass()), /* @ts-ignore */
|
|
79
114
|
...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
|
|
80
115
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormSlider, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
81
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormSlider, isStandalone: true, selector: "eg-form-slider", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", isSignal: true, isRequired: false, transformFunction: null }, controlName: { classPropertyName: "controlName", publicName: "controlName", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, labelClass: { classPropertyName: "labelClass", publicName: "labelClass", isSignal: true, isRequired: false, transformFunction: null }, sliderClass: { classPropertyName: "sliderClass", publicName: "sliderClass", isSignal: true, isRequired: false, transformFunction: null }, errorClass: { classPropertyName: "errorClass", publicName: "errorClass", isSignal: true, isRequired: false, transformFunction: null }, hintClass: { classPropertyName: "hintClass", publicName: "hintClass", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "$userClass()" } }, providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }], ngImport: i0, template: `
|
|
116
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormSlider, isStandalone: true, selector: "eg-form-slider", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", isSignal: true, isRequired: false, transformFunction: null }, controlName: { classPropertyName: "controlName", publicName: "controlName", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, 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 }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, labelClass: { classPropertyName: "labelClass", publicName: "labelClass", isSignal: true, isRequired: false, transformFunction: null }, sliderClass: { classPropertyName: "sliderClass", publicName: "sliderClass", isSignal: true, isRequired: false, transformFunction: null }, errorClass: { classPropertyName: "errorClass", publicName: "errorClass", isSignal: true, isRequired: false, transformFunction: null }, hintClass: { classPropertyName: "hintClass", publicName: "hintClass", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "$userClass()" } }, providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }], ngImport: i0, template: `
|
|
82
117
|
@let lbl = label();
|
|
83
118
|
@let cnm = controlName();
|
|
84
|
-
@let err = error();
|
|
85
119
|
@let hnt = hint();
|
|
86
120
|
@let rqrd = required();
|
|
87
121
|
|
|
@@ -106,9 +140,9 @@ class EgFormSlider {
|
|
|
106
140
|
[class]="$sliderClass()"
|
|
107
141
|
/>
|
|
108
142
|
|
|
109
|
-
@if (
|
|
143
|
+
@if (showError()) {
|
|
110
144
|
<hlm-error [id]="errorId()" [class]="$errorClass()">
|
|
111
|
-
{{
|
|
145
|
+
{{ resolvedError() }}
|
|
112
146
|
</hlm-error>
|
|
113
147
|
}
|
|
114
148
|
|
|
@@ -133,7 +167,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
133
167
|
template: `
|
|
134
168
|
@let lbl = label();
|
|
135
169
|
@let cnm = controlName();
|
|
136
|
-
@let err = error();
|
|
137
170
|
@let hnt = hint();
|
|
138
171
|
@let rqrd = required();
|
|
139
172
|
|
|
@@ -158,9 +191,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
158
191
|
[class]="$sliderClass()"
|
|
159
192
|
/>
|
|
160
193
|
|
|
161
|
-
@if (
|
|
194
|
+
@if (showError()) {
|
|
162
195
|
<hlm-error [id]="errorId()" [class]="$errorClass()">
|
|
163
|
-
{{
|
|
196
|
+
{{ resolvedError() }}
|
|
164
197
|
</hlm-error>
|
|
165
198
|
}
|
|
166
199
|
|
|
@@ -172,7 +205,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
172
205
|
</hlm-form-field>
|
|
173
206
|
`,
|
|
174
207
|
}]
|
|
175
|
-
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], controlId: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlId", required: false }] }], controlName: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlName", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], sliderClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "sliderClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
|
|
208
|
+
}], 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 }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], sliderClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "sliderClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
|
|
176
209
|
|
|
177
210
|
/*
|
|
178
211
|
* Public API Surface of form-slider
|
|
@@ -5,12 +5,20 @@ import { NumberInput } from '@angular/cdk/coercion';
|
|
|
5
5
|
|
|
6
6
|
declare class EgFormSlider {
|
|
7
7
|
private readonly formGroupDirective;
|
|
8
|
+
private readonly _errorMessages;
|
|
8
9
|
private readonly generatedId;
|
|
9
10
|
private readonly _config;
|
|
11
|
+
private readonly _shared;
|
|
10
12
|
label: _angular_core.InputSignal<string | undefined>;
|
|
11
13
|
controlId: _angular_core.InputSignal<string | undefined>;
|
|
12
14
|
controlName: _angular_core.InputSignal<string>;
|
|
13
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>;
|
|
14
22
|
hint: _angular_core.InputSignal<string | undefined>;
|
|
15
23
|
id: _angular_core.InputSignal<string | undefined>;
|
|
16
24
|
disabled: _angular_core.InputSignal<boolean>;
|
|
@@ -22,6 +30,19 @@ declare class EgFormSlider {
|
|
|
22
30
|
readonly labelId: _angular_core.Signal<string>;
|
|
23
31
|
readonly errorId: _angular_core.Signal<string>;
|
|
24
32
|
readonly hintId: _angular_core.Signal<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
35
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
36
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
37
|
+
* fresh on every change-detection pass.
|
|
38
|
+
*/
|
|
39
|
+
protected resolvedError(): string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
42
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
43
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
44
|
+
*/
|
|
45
|
+
protected showError(): boolean;
|
|
25
46
|
/**
|
|
26
47
|
* Combined lock for the brain `linkedSignal`-based disabled state: the raw
|
|
27
48
|
* input write always carries the resolved value, so a same-pass
|
|
@@ -39,7 +60,7 @@ declare class EgFormSlider {
|
|
|
39
60
|
$errorClass: _angular_core.Signal<string>;
|
|
40
61
|
$hintClass: _angular_core.Signal<string>;
|
|
41
62
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormSlider, never>;
|
|
42
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormSlider, "eg-form-slider", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "controlId": { "alias": "controlId"; "required": false; "isSignal": true; }; "controlName": { "alias": "controlName"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; "hint": { "alias": "hint"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "step": { "alias": "step"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "sliderClass": { "alias": "sliderClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
63
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormSlider, "eg-form-slider", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "controlId": { "alias": "controlId"; "required": false; "isSignal": true; }; "controlName": { "alias": "controlName"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; "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; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "step": { "alias": "step"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "sliderClass": { "alias": "sliderClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
43
64
|
}
|
|
44
65
|
|
|
45
66
|
interface EgFormSliderConfig {
|
package/form-switch/README.md
CHANGED
|
@@ -70,21 +70,22 @@ Selector (from source): `eg-form-switch` (standalone component, host `tw:w-full`
|
|
|
70
70
|
|
|
71
71
|
### `EgFormSwitch` — `eg-form-switch`
|
|
72
72
|
|
|
73
|
-
| Input | Type | Default | Description
|
|
74
|
-
| ------------- | --------------------- | ------- |
|
|
75
|
-
| `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.**
|
|
76
|
-
| `label` | `string \| undefined` | — | Label text beside the switch (hidden when omitted).
|
|
77
|
-
| `error` | `string \| undefined` | — | Error text shown when invalid.
|
|
78
|
-
| `
|
|
79
|
-
| `
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
73
|
+
| Input | Type | Default | Description |
|
|
74
|
+
| ------------- | --------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
75
|
+
| `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.** |
|
|
76
|
+
| `label` | `string \| undefined` | — | Label text beside the switch (hidden when omitted). |
|
|
77
|
+
| `error` | `string \| undefined` | — | Error text shown when invalid. |
|
|
78
|
+
| `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`. |
|
|
79
|
+
| `hint` | `string \| undefined` | — | Hint text shown otherwise. |
|
|
80
|
+
| `controlId` | `string \| undefined` | — | Explicit id (first priority for `effectiveId`). |
|
|
81
|
+
| `id` | `string \| undefined` | — | Fallback id (second priority). |
|
|
82
|
+
| `disabled` | `boolean` | `false` | Locks interaction (form control stays enabled). |
|
|
83
|
+
| `required` | `boolean` | `false` | Shows a red `*` next to the label; forwarded to the switch. |
|
|
84
|
+
| `class` | `ClassValue` | `''` | Extra host classes (base `tw:w-full`). |
|
|
85
|
+
| `switchClass` | `string` | `''` | Extra switch classes, merged into `HlmSwitch.userClass`. |
|
|
86
|
+
| `labelClass` | `string` | `''` | Extra label classes. |
|
|
87
|
+
| `errorClass` | `string` | `''` | Extra error classes (base `tw:mt-0`). |
|
|
88
|
+
| `hintClass` | `string` | `''` | Extra hint classes (base `tw:mt-0`). |
|
|
88
89
|
|
|
89
90
|
| Member | Description |
|
|
90
91
|
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|