@egose/shadcn-theme-ng-tw 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/alert/fesm2022/alert.mjs +1 -1
- package/autocomplete/fesm2022/autocomplete.mjs +1 -1
- package/button/fesm2022/button.mjs +3 -3
- package/checkbox/fesm2022/checkbox.mjs +6 -7
- package/checkbox/types/checkbox.d.ts +1 -1
- package/combobox/fesm2022/combobox.mjs +1 -1
- package/date-picker/README.md +15 -11
- package/date-picker/fesm2022/date-picker.mjs +148 -30
- package/date-picker/types/date-picker.d.ts +102 -9
- package/form-autocomplete/README.md +178 -0
- package/form-autocomplete/fesm2022/form-autocomplete.mjs +243 -0
- package/form-autocomplete/package.json +24 -0
- package/form-autocomplete/types/form-autocomplete.d.ts +81 -0
- package/form-checkbox/README.md +29 -18
- package/form-checkbox/fesm2022/form-checkbox.mjs +62 -22
- package/form-checkbox/types/form-checkbox.d.ts +43 -4
- package/form-combobox/README.md +203 -0
- package/form-combobox/fesm2022/form-combobox.mjs +305 -0
- package/form-combobox/package.json +24 -0
- package/form-combobox/types/form-combobox.d.ts +93 -0
- package/form-date-picker/README.md +49 -22
- package/form-date-picker/fesm2022/form-date-picker.mjs +100 -29
- package/form-date-picker/types/form-date-picker.d.ts +37 -1
- package/form-date-picker-multi/README.md +192 -0
- package/form-date-picker-multi/fesm2022/form-date-picker-multi.mjs +266 -0
- package/form-date-picker-multi/package.json +24 -0
- package/form-date-picker-multi/types/form-date-picker-multi.d.ts +78 -0
- package/form-date-range-picker/README.md +254 -0
- package/form-date-range-picker/fesm2022/form-date-range-picker.mjs +263 -0
- package/form-date-range-picker/package.json +24 -0
- package/form-date-range-picker/types/form-date-range-picker.d.ts +75 -0
- package/form-field/README.md +9 -0
- package/form-field/fesm2022/form-field.mjs +80 -5
- package/form-field/types/form-field.d.ts +50 -2
- package/form-field-simple/fesm2022/form-field-simple.mjs +15 -1
- package/form-field-simple/types/form-field-simple.d.ts +9 -2
- package/form-input-otp/README.md +195 -0
- package/form-input-otp/fesm2022/form-input-otp.mjs +226 -0
- package/form-input-otp/package.json +24 -0
- package/form-input-otp/types/form-input-otp.d.ts +78 -0
- package/form-month-year-picker/README.md +189 -0
- package/form-month-year-picker/fesm2022/form-month-year-picker.mjs +256 -0
- package/form-month-year-picker/package.json +24 -0
- package/form-month-year-picker/types/form-month-year-picker.d.ts +73 -0
- package/form-native-select/README.md +206 -0
- package/form-native-select/fesm2022/form-native-select.mjs +226 -0
- package/form-native-select/package.json +24 -0
- package/form-native-select/types/form-native-select.d.ts +77 -0
- package/form-phone-input/README.md +189 -0
- package/form-phone-input/fesm2022/form-phone-input.mjs +230 -0
- package/form-phone-input/package.json +24 -0
- package/form-phone-input/types/form-phone-input.d.ts +78 -0
- package/form-radio-group/README.md +199 -0
- package/form-radio-group/fesm2022/form-radio-group.mjs +238 -0
- package/form-radio-group/package.json +24 -0
- package/form-radio-group/types/form-radio-group.d.ts +83 -0
- package/form-searchable-multiselect/README.md +28 -17
- package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs +60 -24
- package/form-searchable-multiselect/types/form-searchable-multiselect.d.ts +39 -2
- package/form-select/README.md +30 -19
- package/form-select/fesm2022/form-select.mjs +65 -29
- package/form-select/types/form-select.d.ts +39 -2
- package/form-slider/README.md +183 -0
- package/form-slider/fesm2022/form-slider.mjs +218 -0
- package/form-slider/package.json +24 -0
- package/form-slider/types/form-slider.d.ts +80 -0
- package/form-switch/README.md +174 -0
- package/form-switch/fesm2022/form-switch.mjs +205 -0
- package/form-switch/package.json +24 -0
- package/form-switch/types/form-switch.d.ts +70 -0
- package/form-text-input/README.md +37 -26
- package/form-text-input/fesm2022/form-text-input.mjs +60 -24
- package/form-text-input/types/form-text-input.d.ts +39 -2
- package/form-textarea/README.md +33 -22
- package/form-textarea/fesm2022/form-textarea.mjs +60 -24
- package/form-textarea/types/form-textarea.d.ts +39 -2
- package/form-toggle/README.md +187 -0
- package/form-toggle/fesm2022/form-toggle.mjs +275 -0
- package/form-toggle/package.json +24 -0
- package/form-toggle/types/form-toggle.d.ts +100 -0
- package/form-toggle-group/README.md +177 -0
- package/form-toggle-group/fesm2022/form-toggle-group.mjs +243 -0
- package/form-toggle-group/package.json +24 -0
- package/form-toggle-group/types/form-toggle-group.d.ts +85 -0
- package/input-group/fesm2022/input-group.mjs +20 -10
- package/input-group/types/input-group.d.ts +4 -1
- package/native-select/fesm2022/native-select.mjs +18 -6
- package/native-select/types/native-select.d.ts +7 -2
- package/package.json +57 -1
- package/phone-input/README.md +114 -0
- package/phone-input/fesm2022/phone-input.mjs +191 -0
- package/phone-input/package.json +24 -0
- package/phone-input/types/phone-input.d.ts +67 -0
- package/sheet/fesm2022/sheet.mjs +1 -1
- package/switch/fesm2022/switch.mjs +7 -5
- package/switch/types/switch.d.ts +2 -1
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, input, computed, Component } from '@angular/core';
|
|
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, 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 { HlmInput } from '@egose/shadcn-theme-ng-tw/input';
|
|
8
8
|
import { hlm } from '@egose/shadcn-theme-ng-tw/utils';
|
|
9
9
|
|
|
10
|
+
const EgFormTextInputConfigToken = new InjectionToken('EgFormTextInputConfig');
|
|
11
|
+
function provideEgFormTextInputConfig(config) {
|
|
12
|
+
return { provide: EgFormTextInputConfigToken, useValue: { ...config } };
|
|
13
|
+
}
|
|
14
|
+
function injectEgFormTextInputConfig() {
|
|
15
|
+
return inject(EgFormTextInputConfigToken, { optional: true }) ?? {};
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
class EgFormTextInput {
|
|
11
19
|
formGroupDirective = inject(FormGroupDirective);
|
|
20
|
+
_errorMessages = injectEgFormErrorMessages();
|
|
12
21
|
generatedId = inject(HlmFormIdGenerator).generate('eg-form-text-input');
|
|
22
|
+
_config = injectEgFormTextInputConfig();
|
|
13
23
|
label = input(undefined, /* @ts-ignore */
|
|
14
24
|
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
15
25
|
controlId = input(undefined, /* @ts-ignore */
|
|
@@ -18,6 +28,13 @@ class EgFormTextInput {
|
|
|
18
28
|
...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
|
|
19
29
|
error = input(undefined, /* @ts-ignore */
|
|
20
30
|
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
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 = input(true, /* @ts-ignore */
|
|
37
|
+
...(ngDevMode ? [{ debugName: "autoError" }] : /* istanbul ignore next */ []));
|
|
21
38
|
hint = input(undefined, /* @ts-ignore */
|
|
22
39
|
...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
23
40
|
// HTML/input attributes
|
|
@@ -55,13 +72,34 @@ class EgFormTextInput {
|
|
|
55
72
|
...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
|
|
56
73
|
hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
|
|
57
74
|
...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
|
|
58
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
77
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
78
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
79
|
+
* fresh on every change-detection pass.
|
|
80
|
+
*/
|
|
81
|
+
resolvedError() {
|
|
82
|
+
const explicit = this.error();
|
|
83
|
+
if (explicit)
|
|
84
|
+
return explicit;
|
|
85
|
+
if (!this.autoError())
|
|
86
|
+
return undefined;
|
|
59
87
|
const control = this.formGroupDirective.form.get(this.controlName());
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
88
|
+
return resolveEgFormError(control?.errors ?? null, this.label(), this._errorMessages);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
92
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
93
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
94
|
+
*/
|
|
95
|
+
showError() {
|
|
96
|
+
const control = this.formGroupDirective.form.get(this.controlName());
|
|
97
|
+
return (!!this.resolvedError() &&
|
|
98
|
+
!!control?.invalid &&
|
|
99
|
+
(control.dirty || control.touched || this.formGroupDirective.submitted));
|
|
100
|
+
}
|
|
101
|
+
describedBy() {
|
|
102
|
+
return this.showError() ? this.errorId() : this.hint() ? this.hintId() : null;
|
|
65
103
|
}
|
|
66
104
|
effectiveDisabled() {
|
|
67
105
|
return this.disabled() || !!this.formGroupDirective.form.get(this.controlName())?.disabled;
|
|
@@ -76,22 +114,21 @@ class EgFormTextInput {
|
|
|
76
114
|
...(ngDevMode ? [{ debugName: "errorClass" }] : /* istanbul ignore next */ []));
|
|
77
115
|
hintClass = input('', /* @ts-ignore */
|
|
78
116
|
...(ngDevMode ? [{ debugName: "hintClass" }] : /* istanbul ignore next */ []));
|
|
79
|
-
// Computed class bindings
|
|
80
|
-
$userClass = computed(() => hlm('tw:
|
|
117
|
+
// Computed class bindings (library base < global config < per-instance)
|
|
118
|
+
$userClass = computed(() => hlm('tw:w-full', this.userClass()), /* @ts-ignore */
|
|
81
119
|
...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
|
|
82
|
-
$labelClass = computed(() => hlm('tw:mb-1 tw:gap-0', this.labelClass()), /* @ts-ignore */
|
|
120
|
+
$labelClass = computed(() => hlm('tw:mb-1 tw:gap-0', this._config.labelClass, this.labelClass()), /* @ts-ignore */
|
|
83
121
|
...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
|
|
84
|
-
$inputClass = computed(() => hlm('tw:mb-1', this.inputClass()), /* @ts-ignore */
|
|
122
|
+
$inputClass = computed(() => hlm('tw:mb-1', this._config.inputClass, this.inputClass()), /* @ts-ignore */
|
|
85
123
|
...(ngDevMode ? [{ debugName: "$inputClass" }] : /* istanbul ignore next */ []));
|
|
86
|
-
$errorClass = computed(() => hlm('tw:mt-0', this.errorClass()), /* @ts-ignore */
|
|
124
|
+
$errorClass = computed(() => hlm('tw:mt-0', this._config.errorClass, this.errorClass()), /* @ts-ignore */
|
|
87
125
|
...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
|
|
88
|
-
$hintClass = computed(() => hlm('tw:mt-0', this.hintClass()), /* @ts-ignore */
|
|
126
|
+
$hintClass = computed(() => hlm('tw:mt-0', this._config.hintClass, this.hintClass()), /* @ts-ignore */
|
|
89
127
|
...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
|
|
90
128
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormTextInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
91
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormTextInput, isStandalone: true, selector: "eg-form-text-input", 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 }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, maxlength: { classPropertyName: "maxlength", publicName: "maxlength", isSignal: true, isRequired: false, transformFunction: null }, minlength: { classPropertyName: "minlength", publicName: "minlength", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, pattern: { classPropertyName: "pattern", publicName: "pattern", isSignal: true, isRequired: false, transformFunction: null }, autocomplete: { classPropertyName: "autocomplete", publicName: "autocomplete", isSignal: true, isRequired: false, transformFunction: null }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", 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 }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", 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: {
|
|
129
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormTextInput, isStandalone: true, selector: "eg-form-text-input", 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 }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, maxlength: { classPropertyName: "maxlength", publicName: "maxlength", isSignal: true, isRequired: false, transformFunction: null }, minlength: { classPropertyName: "minlength", publicName: "minlength", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, pattern: { classPropertyName: "pattern", publicName: "pattern", isSignal: true, isRequired: false, transformFunction: null }, autocomplete: { classPropertyName: "autocomplete", publicName: "autocomplete", isSignal: true, isRequired: false, transformFunction: null }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", 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 }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", 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: `
|
|
92
130
|
@let lbl = label();
|
|
93
131
|
@let cnm = controlName();
|
|
94
|
-
@let err = error();
|
|
95
132
|
@let hnt = hint();
|
|
96
133
|
@let rqrd = required();
|
|
97
134
|
|
|
@@ -127,9 +164,9 @@ class EgFormTextInput {
|
|
|
127
164
|
[required]="rqrd"
|
|
128
165
|
/>
|
|
129
166
|
|
|
130
|
-
@if (
|
|
167
|
+
@if (showError()) {
|
|
131
168
|
<hlm-error [id]="errorId()" [class]="$errorClass()">
|
|
132
|
-
{{
|
|
169
|
+
{{ resolvedError() }}
|
|
133
170
|
</hlm-error>
|
|
134
171
|
}
|
|
135
172
|
|
|
@@ -147,14 +184,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
147
184
|
selector: 'eg-form-text-input',
|
|
148
185
|
standalone: true,
|
|
149
186
|
host: {
|
|
150
|
-
class: '
|
|
187
|
+
'[class]': '$userClass()',
|
|
151
188
|
},
|
|
152
189
|
imports: [ReactiveFormsModule, HlmFormField, HlmError, HlmHint, HlmLabel, HlmInput],
|
|
153
190
|
providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
|
|
154
191
|
template: `
|
|
155
192
|
@let lbl = label();
|
|
156
193
|
@let cnm = controlName();
|
|
157
|
-
@let err = error();
|
|
158
194
|
@let hnt = hint();
|
|
159
195
|
@let rqrd = required();
|
|
160
196
|
|
|
@@ -190,9 +226,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
190
226
|
[required]="rqrd"
|
|
191
227
|
/>
|
|
192
228
|
|
|
193
|
-
@if (
|
|
229
|
+
@if (showError()) {
|
|
194
230
|
<hlm-error [id]="errorId()" [class]="$errorClass()">
|
|
195
|
-
{{
|
|
231
|
+
{{ resolvedError() }}
|
|
196
232
|
</hlm-error>
|
|
197
233
|
}
|
|
198
234
|
|
|
@@ -204,7 +240,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
204
240
|
</hlm-form-field>
|
|
205
241
|
`,
|
|
206
242
|
}]
|
|
207
|
-
}], 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 }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], maxlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxlength", required: false }] }], minlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "minlength", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], pattern: [{ type: i0.Input, args: [{ isSignal: true, alias: "pattern", required: false }] }], autocomplete: [{ type: i0.Input, args: [{ isSignal: true, alias: "autocomplete", required: false }] }], autofocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocus", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], inputClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
|
|
243
|
+
}], 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 }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], maxlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxlength", required: false }] }], minlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "minlength", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], pattern: [{ type: i0.Input, args: [{ isSignal: true, alias: "pattern", required: false }] }], autocomplete: [{ type: i0.Input, args: [{ isSignal: true, alias: "autocomplete", required: false }] }], autofocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocus", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], inputClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputClass", 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
244
|
|
|
209
245
|
/*
|
|
210
246
|
* Public API Surface of form-text-input
|
|
@@ -214,5 +250,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
214
250
|
* Generated bundle index. Do not edit.
|
|
215
251
|
*/
|
|
216
252
|
|
|
217
|
-
export { EgFormTextInput };
|
|
253
|
+
export { EgFormTextInput, injectEgFormTextInputConfig, provideEgFormTextInputConfig };
|
|
218
254
|
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { ValueProvider } from '@angular/core';
|
|
2
3
|
import { ClassValue } from 'clsx';
|
|
3
4
|
|
|
4
5
|
declare class EgFormTextInput {
|
|
5
6
|
private readonly formGroupDirective;
|
|
7
|
+
private readonly _errorMessages;
|
|
6
8
|
private readonly generatedId;
|
|
9
|
+
private readonly _config;
|
|
7
10
|
label: _angular_core.InputSignal<string | undefined>;
|
|
8
11
|
controlId: _angular_core.InputSignal<string | undefined>;
|
|
9
12
|
controlName: _angular_core.InputSignal<string>;
|
|
10
13
|
error: _angular_core.InputSignal<string | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Auto-resolve the displayed message from the control's `ValidationErrors`
|
|
16
|
+
* when `error()` is unset. Explicit `error()` always wins. Set to `false`
|
|
17
|
+
* for manual-only messages.
|
|
18
|
+
*/
|
|
19
|
+
autoError: _angular_core.InputSignal<boolean>;
|
|
11
20
|
hint: _angular_core.InputSignal<string | undefined>;
|
|
12
21
|
id: _angular_core.InputSignal<string | undefined>;
|
|
13
22
|
name: _angular_core.InputSignal<string | undefined>;
|
|
@@ -26,6 +35,19 @@ declare class EgFormTextInput {
|
|
|
26
35
|
readonly effectiveId: _angular_core.Signal<string>;
|
|
27
36
|
readonly errorId: _angular_core.Signal<string>;
|
|
28
37
|
readonly hintId: _angular_core.Signal<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
40
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
41
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
42
|
+
* fresh on every change-detection pass.
|
|
43
|
+
*/
|
|
44
|
+
protected resolvedError(): string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
47
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
48
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
49
|
+
*/
|
|
50
|
+
protected showError(): boolean;
|
|
29
51
|
describedBy(): string | null;
|
|
30
52
|
effectiveDisabled(): boolean;
|
|
31
53
|
userClass: _angular_core.InputSignal<ClassValue>;
|
|
@@ -39,7 +61,22 @@ declare class EgFormTextInput {
|
|
|
39
61
|
$errorClass: _angular_core.Signal<string>;
|
|
40
62
|
$hintClass: _angular_core.Signal<string>;
|
|
41
63
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormTextInput, never>;
|
|
42
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormTextInput, "eg-form-text-input", 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; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "type": { "alias": "type"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "maxlength": { "alias": "maxlength"; "required": false; "isSignal": true; }; "minlength": { "alias": "minlength"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "pattern": { "alias": "pattern"; "required": false; "isSignal": true; }; "autocomplete": { "alias": "autocomplete"; "required": false; "isSignal": true; }; "autofocus": { "alias": "autofocus"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "inputClass": { "alias": "inputClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
64
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormTextInput, "eg-form-text-input", 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; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "type": { "alias": "type"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "maxlength": { "alias": "maxlength"; "required": false; "isSignal": true; }; "minlength": { "alias": "minlength"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "pattern": { "alias": "pattern"; "required": false; "isSignal": true; }; "autocomplete": { "alias": "autocomplete"; "required": false; "isSignal": true; }; "autofocus": { "alias": "autofocus"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "inputClass": { "alias": "inputClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
43
65
|
}
|
|
44
66
|
|
|
45
|
-
|
|
67
|
+
interface EgFormTextInputConfig {
|
|
68
|
+
/**
|
|
69
|
+
* Global class defaults for `eg-form-text-input` styling slots.
|
|
70
|
+
* Each is merged under the matching per-instance `*Class` input
|
|
71
|
+
* (library base < global config < per-instance).
|
|
72
|
+
*/
|
|
73
|
+
labelClass?: string;
|
|
74
|
+
inputClass?: string;
|
|
75
|
+
errorClass?: string;
|
|
76
|
+
hintClass?: string;
|
|
77
|
+
}
|
|
78
|
+
declare function provideEgFormTextInputConfig(config: Partial<EgFormTextInputConfig>): ValueProvider;
|
|
79
|
+
declare function injectEgFormTextInputConfig(): EgFormTextInputConfig;
|
|
80
|
+
|
|
81
|
+
export { EgFormTextInput, injectEgFormTextInputConfig, provideEgFormTextInputConfig };
|
|
82
|
+
export type { EgFormTextInputConfig };
|
package/form-textarea/README.md
CHANGED
|
@@ -75,28 +75,29 @@ Real selectors: `eg-form-textarea`, `hlm-form-field`, `label[hlmLabel]`, `textar
|
|
|
75
75
|
|
|
76
76
|
### `eg-form-textarea` — `EgFormTextarea`
|
|
77
77
|
|
|
78
|
-
| Input | Type | Default | Description
|
|
79
|
-
| --------------------- | ------------------------------- | ----------- |
|
|
80
|
-
| `label` | `string \| undefined` | `undefined` | Field label rendered as `<label hlmLabel>` bound to the textarea id.
|
|
81
|
-
| `controlName` | `string` | `''` | **Required.** Control name in the parent `FormGroup`; forwarded as `formControlName` and `name`.
|
|
82
|
-
| `controlId` | `string \| undefined` | `undefined` | Explicit id; falls back to `id`, then generated `eg-form-textarea-…`.
|
|
83
|
-
| `id` | `string \| undefined` | `undefined` | Alias for an explicit id (same fallback chain).
|
|
84
|
-
| `error` | `string \| undefined` | `undefined` | Error text rendered in `<hlm-error>`.
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
78
|
+
| Input | Type | Default | Description |
|
|
79
|
+
| --------------------- | ------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
80
|
+
| `label` | `string \| undefined` | `undefined` | Field label rendered as `<label hlmLabel>` bound to the textarea id. |
|
|
81
|
+
| `controlName` | `string` | `''` | **Required.** Control name in the parent `FormGroup`; forwarded as `formControlName` and `name`. |
|
|
82
|
+
| `controlId` | `string \| undefined` | `undefined` | Explicit id; falls back to `id`, then generated `eg-form-textarea-…`. |
|
|
83
|
+
| `id` | `string \| undefined` | `undefined` | Alias for an explicit id (same fallback chain). |
|
|
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
|
+
| `name` | `string \| undefined` | `undefined` | `name` attribute fallback when `controlName` is empty. |
|
|
88
|
+
| `placeholder` | `string` | `''` | Placeholder text. |
|
|
89
|
+
| `readonly` | `boolean` | `false` | Native `readonly` attribute. |
|
|
90
|
+
| `disabled` | `boolean` | `false` | Wrapper-level disable (OR-ed with the reactive disabled state — see `effectiveDisabled()`). |
|
|
91
|
+
| `maxlength` | `string \| number \| null` | `null` | Native `maxlength`. |
|
|
92
|
+
| `minlength` | `string \| number \| null` | `null` | Native `minlength`. |
|
|
93
|
+
| `required` | `boolean` | `false` | Native `required` + red `*` on the label. |
|
|
94
|
+
| `rows` | `string \| number \| undefined` | `3` | Native `rows` (visible height). |
|
|
95
|
+
| `cols` | `string \| number \| undefined` | `undefined` | Native `cols` (visible width). |
|
|
96
|
+
| `class` (`userClass`) | `ClassValue` | `''` | Extra host classes (merged over `tw:w-full`). |
|
|
97
|
+
| `labelClass` | `string` | `''` | Extra label classes (merged over `tw:mb-1 tw:gap-0`). |
|
|
98
|
+
| `textareaClass` | `string` | `''` | Extra textarea classes (merged over `tw:mb-1`). |
|
|
99
|
+
| `errorClass` | `string` | `''` | Extra error classes (merged over `tw:mt-0`). |
|
|
100
|
+
| `hintClass` | `string` | `''` | Extra hint classes (merged over `tw:mt-0`). |
|
|
100
101
|
|
|
101
102
|
No outputs. Methods: `describedBy(): string | null` (error id when invalid + dirty/touched, else hint id, else `null`); `effectiveDisabled(): boolean` (`disabled()` OR the control's reactive disabled state). Readonly computeds: `effectiveId()`, `errorId()`, `hintId()`.
|
|
102
103
|
|
|
@@ -340,6 +341,16 @@ export class ProgrammaticExample {
|
|
|
340
341
|
|
|
341
342
|
No component-specific CSS variables; visuals come from the shared theme tokens via the `hlmInput` class hook. Control height with `rows` and `textareaClass` (`tw:min-h-*`, `tw:resize-y` / `tw:resize-none`).
|
|
342
343
|
|
|
344
|
+
Global defaults per styling slot via the wrapper config (precedence: library base < global config < per-instance):
|
|
345
|
+
|
|
346
|
+
```ts
|
|
347
|
+
import { provideEgFormTextareaConfig } from '@egose/shadcn-theme-ng/form-textarea';
|
|
348
|
+
|
|
349
|
+
await bootstrapApplication(App, {
|
|
350
|
+
providers: [provideEgFormTextareaConfig({ textareaClass: 'tw:text-sm', labelClass: 'tw:font-medium' })],
|
|
351
|
+
});
|
|
352
|
+
```
|
|
353
|
+
|
|
343
354
|
## Related subpaths
|
|
344
355
|
|
|
345
356
|
- `@egose/shadcn-theme-ng/form-text-input` — the single-line sibling.
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, input, computed, Component } from '@angular/core';
|
|
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, 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 { HlmInput } from '@egose/shadcn-theme-ng-tw/input';
|
|
8
8
|
import { hlm } from '@egose/shadcn-theme-ng-tw/utils';
|
|
9
9
|
|
|
10
|
+
const EgFormTextareaConfigToken = new InjectionToken('EgFormTextareaConfig');
|
|
11
|
+
function provideEgFormTextareaConfig(config) {
|
|
12
|
+
return { provide: EgFormTextareaConfigToken, useValue: { ...config } };
|
|
13
|
+
}
|
|
14
|
+
function injectEgFormTextareaConfig() {
|
|
15
|
+
return inject(EgFormTextareaConfigToken, { optional: true }) ?? {};
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
class EgFormTextarea {
|
|
11
19
|
formGroupDirective = inject(FormGroupDirective);
|
|
20
|
+
_errorMessages = injectEgFormErrorMessages();
|
|
12
21
|
generatedId = inject(HlmFormIdGenerator).generate('eg-form-textarea');
|
|
22
|
+
_config = injectEgFormTextareaConfig();
|
|
13
23
|
// General props
|
|
14
24
|
label = input(undefined, /* @ts-ignore */
|
|
15
25
|
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
@@ -19,6 +29,13 @@ class EgFormTextarea {
|
|
|
19
29
|
...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
|
|
20
30
|
error = input(undefined, /* @ts-ignore */
|
|
21
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 */ []));
|
|
22
39
|
hint = input(undefined, /* @ts-ignore */
|
|
23
40
|
...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
24
41
|
// HTML/textarea attributes
|
|
@@ -48,13 +65,34 @@ class EgFormTextarea {
|
|
|
48
65
|
...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
|
|
49
66
|
hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
|
|
50
67
|
...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
|
|
51
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
70
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
71
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
72
|
+
* fresh on every change-detection pass.
|
|
73
|
+
*/
|
|
74
|
+
resolvedError() {
|
|
75
|
+
const explicit = this.error();
|
|
76
|
+
if (explicit)
|
|
77
|
+
return explicit;
|
|
78
|
+
if (!this.autoError())
|
|
79
|
+
return undefined;
|
|
52
80
|
const control = this.formGroupDirective.form.get(this.controlName());
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
81
|
+
return resolveEgFormError(control?.errors ?? null, this.label(), this._errorMessages);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
85
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
86
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
87
|
+
*/
|
|
88
|
+
showError() {
|
|
89
|
+
const control = this.formGroupDirective.form.get(this.controlName());
|
|
90
|
+
return (!!this.resolvedError() &&
|
|
91
|
+
!!control?.invalid &&
|
|
92
|
+
(control.dirty || control.touched || this.formGroupDirective.submitted));
|
|
93
|
+
}
|
|
94
|
+
describedBy() {
|
|
95
|
+
return this.showError() ? this.errorId() : this.hint() ? this.hintId() : null;
|
|
58
96
|
}
|
|
59
97
|
effectiveDisabled() {
|
|
60
98
|
return this.disabled() || !!this.formGroupDirective.form.get(this.controlName())?.disabled;
|
|
@@ -69,22 +107,21 @@ class EgFormTextarea {
|
|
|
69
107
|
...(ngDevMode ? [{ debugName: "errorClass" }] : /* istanbul ignore next */ []));
|
|
70
108
|
hintClass = input('', /* @ts-ignore */
|
|
71
109
|
...(ngDevMode ? [{ debugName: "hintClass" }] : /* istanbul ignore next */ []));
|
|
72
|
-
// Computed class bindings
|
|
73
|
-
$userClass = computed(() => hlm('tw:
|
|
110
|
+
// Computed class bindings (library base < global config < per-instance)
|
|
111
|
+
$userClass = computed(() => hlm('tw:w-full', this.userClass()), /* @ts-ignore */
|
|
74
112
|
...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
|
|
75
|
-
$labelClass = computed(() => hlm('tw:mb-1 tw:gap-0', this.labelClass()), /* @ts-ignore */
|
|
113
|
+
$labelClass = computed(() => hlm('tw:mb-1 tw:gap-0', this._config.labelClass, this.labelClass()), /* @ts-ignore */
|
|
76
114
|
...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
|
|
77
|
-
$textareaClass = computed(() => hlm('tw:mb-1', this.textareaClass()), /* @ts-ignore */
|
|
115
|
+
$textareaClass = computed(() => hlm('tw:mb-1', this._config.textareaClass, this.textareaClass()), /* @ts-ignore */
|
|
78
116
|
...(ngDevMode ? [{ debugName: "$textareaClass" }] : /* istanbul ignore next */ []));
|
|
79
|
-
$errorClass = computed(() => hlm('tw:mt-0', this.errorClass()), /* @ts-ignore */
|
|
117
|
+
$errorClass = computed(() => hlm('tw:mt-0', this._config.errorClass, this.errorClass()), /* @ts-ignore */
|
|
80
118
|
...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
|
|
81
|
-
$hintClass = computed(() => hlm('tw:mt-0', this.hintClass()), /* @ts-ignore */
|
|
119
|
+
$hintClass = computed(() => hlm('tw:mt-0', this._config.hintClass, this.hintClass()), /* @ts-ignore */
|
|
82
120
|
...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
|
|
83
121
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormTextarea, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
84
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormTextarea, isStandalone: true, selector: "eg-form-textarea", 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 }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, maxlength: { classPropertyName: "maxlength", publicName: "maxlength", isSignal: true, isRequired: false, transformFunction: null }, minlength: { classPropertyName: "minlength", publicName: "minlength", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, rows: { classPropertyName: "rows", publicName: "rows", isSignal: true, isRequired: false, transformFunction: null }, cols: { classPropertyName: "cols", publicName: "cols", 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 }, textareaClass: { classPropertyName: "textareaClass", publicName: "textareaClass", 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: {
|
|
122
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormTextarea, isStandalone: true, selector: "eg-form-textarea", 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 }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, maxlength: { classPropertyName: "maxlength", publicName: "maxlength", isSignal: true, isRequired: false, transformFunction: null }, minlength: { classPropertyName: "minlength", publicName: "minlength", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, rows: { classPropertyName: "rows", publicName: "rows", isSignal: true, isRequired: false, transformFunction: null }, cols: { classPropertyName: "cols", publicName: "cols", 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 }, textareaClass: { classPropertyName: "textareaClass", publicName: "textareaClass", 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: `
|
|
85
123
|
@let lbl = label();
|
|
86
124
|
@let cnm = controlName();
|
|
87
|
-
@let err = error();
|
|
88
125
|
@let hnt = hint();
|
|
89
126
|
@let rqrd = required();
|
|
90
127
|
|
|
@@ -116,9 +153,9 @@ class EgFormTextarea {
|
|
|
116
153
|
[cols]="cols()"
|
|
117
154
|
></textarea>
|
|
118
155
|
|
|
119
|
-
@if (
|
|
156
|
+
@if (showError()) {
|
|
120
157
|
<hlm-error [id]="errorId()" [class]="$errorClass()">
|
|
121
|
-
{{
|
|
158
|
+
{{ resolvedError() }}
|
|
122
159
|
</hlm-error>
|
|
123
160
|
}
|
|
124
161
|
|
|
@@ -136,14 +173,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
136
173
|
selector: 'eg-form-textarea',
|
|
137
174
|
standalone: true,
|
|
138
175
|
host: {
|
|
139
|
-
class: '
|
|
176
|
+
'[class]': '$userClass()',
|
|
140
177
|
},
|
|
141
178
|
imports: [ReactiveFormsModule, HlmFormField, HlmError, HlmHint, HlmLabel, HlmInput],
|
|
142
179
|
providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
|
|
143
180
|
template: `
|
|
144
181
|
@let lbl = label();
|
|
145
182
|
@let cnm = controlName();
|
|
146
|
-
@let err = error();
|
|
147
183
|
@let hnt = hint();
|
|
148
184
|
@let rqrd = required();
|
|
149
185
|
|
|
@@ -175,9 +211,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
175
211
|
[cols]="cols()"
|
|
176
212
|
></textarea>
|
|
177
213
|
|
|
178
|
-
@if (
|
|
214
|
+
@if (showError()) {
|
|
179
215
|
<hlm-error [id]="errorId()" [class]="$errorClass()">
|
|
180
|
-
{{
|
|
216
|
+
{{ resolvedError() }}
|
|
181
217
|
</hlm-error>
|
|
182
218
|
}
|
|
183
219
|
|
|
@@ -189,7 +225,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
189
225
|
</hlm-form-field>
|
|
190
226
|
`,
|
|
191
227
|
}]
|
|
192
|
-
}], 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 }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], maxlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxlength", required: false }] }], minlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "minlength", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], rows: [{ type: i0.Input, args: [{ isSignal: true, alias: "rows", required: false }] }], cols: [{ type: i0.Input, args: [{ isSignal: true, alias: "cols", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], textareaClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "textareaClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
|
|
228
|
+
}], 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 }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], maxlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxlength", required: false }] }], minlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "minlength", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], rows: [{ type: i0.Input, args: [{ isSignal: true, alias: "rows", required: false }] }], cols: [{ type: i0.Input, args: [{ isSignal: true, alias: "cols", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], textareaClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "textareaClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
|
|
193
229
|
|
|
194
230
|
/*
|
|
195
231
|
* Public API Surface of form-textarea
|
|
@@ -199,5 +235,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
199
235
|
* Generated bundle index. Do not edit.
|
|
200
236
|
*/
|
|
201
237
|
|
|
202
|
-
export { EgFormTextarea };
|
|
238
|
+
export { EgFormTextarea, injectEgFormTextareaConfig, provideEgFormTextareaConfig };
|
|
203
239
|
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { ValueProvider } from '@angular/core';
|
|
2
3
|
import { ClassValue } from 'clsx';
|
|
3
4
|
|
|
4
5
|
declare class EgFormTextarea {
|
|
5
6
|
private readonly formGroupDirective;
|
|
7
|
+
private readonly _errorMessages;
|
|
6
8
|
private readonly generatedId;
|
|
9
|
+
private readonly _config;
|
|
7
10
|
label: _angular_core.InputSignal<string | undefined>;
|
|
8
11
|
controlId: _angular_core.InputSignal<string | undefined>;
|
|
9
12
|
controlName: _angular_core.InputSignal<string>;
|
|
10
13
|
error: _angular_core.InputSignal<string | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Auto-resolve the displayed message from the control's `ValidationErrors`
|
|
16
|
+
* when `error()` is unset. Explicit `error()` always wins. Set to `false`
|
|
17
|
+
* for manual-only messages.
|
|
18
|
+
*/
|
|
19
|
+
autoError: _angular_core.InputSignal<boolean>;
|
|
11
20
|
hint: _angular_core.InputSignal<string | undefined>;
|
|
12
21
|
id: _angular_core.InputSignal<string | undefined>;
|
|
13
22
|
name: _angular_core.InputSignal<string | undefined>;
|
|
@@ -22,6 +31,19 @@ declare class EgFormTextarea {
|
|
|
22
31
|
readonly effectiveId: _angular_core.Signal<string>;
|
|
23
32
|
readonly errorId: _angular_core.Signal<string>;
|
|
24
33
|
readonly hintId: _angular_core.Signal<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
36
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
37
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
38
|
+
* fresh on every change-detection pass.
|
|
39
|
+
*/
|
|
40
|
+
protected resolvedError(): string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
43
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
44
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
45
|
+
*/
|
|
46
|
+
protected showError(): boolean;
|
|
25
47
|
describedBy(): string | null;
|
|
26
48
|
effectiveDisabled(): boolean;
|
|
27
49
|
userClass: _angular_core.InputSignal<ClassValue>;
|
|
@@ -35,7 +57,22 @@ declare class EgFormTextarea {
|
|
|
35
57
|
$errorClass: _angular_core.Signal<string>;
|
|
36
58
|
$hintClass: _angular_core.Signal<string>;
|
|
37
59
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormTextarea, never>;
|
|
38
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormTextarea, "eg-form-textarea", 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; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "maxlength": { "alias": "maxlength"; "required": false; "isSignal": true; }; "minlength": { "alias": "minlength"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "rows": { "alias": "rows"; "required": false; "isSignal": true; }; "cols": { "alias": "cols"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "textareaClass": { "alias": "textareaClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
60
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormTextarea, "eg-form-textarea", 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; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "maxlength": { "alias": "maxlength"; "required": false; "isSignal": true; }; "minlength": { "alias": "minlength"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "rows": { "alias": "rows"; "required": false; "isSignal": true; }; "cols": { "alias": "cols"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "textareaClass": { "alias": "textareaClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
39
61
|
}
|
|
40
62
|
|
|
41
|
-
|
|
63
|
+
interface EgFormTextareaConfig {
|
|
64
|
+
/**
|
|
65
|
+
* Global class defaults for `eg-form-textarea` styling slots.
|
|
66
|
+
* Each is merged under the matching per-instance `*Class` input
|
|
67
|
+
* (library base < global config < per-instance).
|
|
68
|
+
*/
|
|
69
|
+
labelClass?: string;
|
|
70
|
+
textareaClass?: string;
|
|
71
|
+
errorClass?: string;
|
|
72
|
+
hintClass?: string;
|
|
73
|
+
}
|
|
74
|
+
declare function provideEgFormTextareaConfig(config: Partial<EgFormTextareaConfig>): ValueProvider;
|
|
75
|
+
declare function injectEgFormTextareaConfig(): EgFormTextareaConfig;
|
|
76
|
+
|
|
77
|
+
export { EgFormTextarea, injectEgFormTextareaConfig, provideEgFormTextareaConfig };
|
|
78
|
+
export type { EgFormTextareaConfig };
|