@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
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, input, numberAttribute, computed, Component } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/forms';
|
|
4
|
+
import { FormGroupDirective, ReactiveFormsModule, ControlContainer } from '@angular/forms';
|
|
5
|
+
import { injectEgFormErrorMessages, HlmFormIdGenerator, resolveEgFormError, HlmFormField, HlmError, HlmHint } from '@egose/shadcn-theme-ng-tw/form-field';
|
|
6
|
+
import { HlmLabel } from '@egose/shadcn-theme-ng-tw/label';
|
|
7
|
+
import { BrnInputOtp } from '@spartan-ng/brain/input-otp';
|
|
8
|
+
import * as i2 from '@egose/shadcn-theme-ng-tw/input-otp';
|
|
9
|
+
import { HlmInputOtpImports } from '@egose/shadcn-theme-ng-tw/input-otp';
|
|
10
|
+
import { hlm } from '@egose/shadcn-theme-ng-tw/utils';
|
|
11
|
+
|
|
12
|
+
const EgFormInputOtpConfigToken = new InjectionToken('EgFormInputOtpConfig');
|
|
13
|
+
function provideEgFormInputOtpConfig(config) {
|
|
14
|
+
return { provide: EgFormInputOtpConfigToken, useValue: { ...config } };
|
|
15
|
+
}
|
|
16
|
+
function injectEgFormInputOtpConfig() {
|
|
17
|
+
return inject(EgFormInputOtpConfigToken, { optional: true }) ?? {};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class EgFormInputOtp {
|
|
21
|
+
formGroupDirective = inject(FormGroupDirective);
|
|
22
|
+
_errorMessages = injectEgFormErrorMessages();
|
|
23
|
+
generatedId = inject(HlmFormIdGenerator).generate('eg-form-input-otp');
|
|
24
|
+
_config = injectEgFormInputOtpConfig();
|
|
25
|
+
label = input(undefined, /* @ts-ignore */
|
|
26
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
27
|
+
controlId = input(undefined, /* @ts-ignore */
|
|
28
|
+
...(ngDevMode ? [{ debugName: "controlId" }] : /* istanbul ignore next */ []));
|
|
29
|
+
controlName = input('', /* @ts-ignore */
|
|
30
|
+
...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
|
|
31
|
+
error = input(undefined, /* @ts-ignore */
|
|
32
|
+
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
33
|
+
/**
|
|
34
|
+
* Auto-resolve the displayed message from the control's `ValidationErrors`
|
|
35
|
+
* when `error()` is unset. Explicit `error()` always wins. Set to `false`
|
|
36
|
+
* for manual-only messages.
|
|
37
|
+
*/
|
|
38
|
+
autoError = input(true, /* @ts-ignore */
|
|
39
|
+
...(ngDevMode ? [{ debugName: "autoError" }] : /* istanbul ignore next */ []));
|
|
40
|
+
hint = input(undefined, /* @ts-ignore */
|
|
41
|
+
...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
42
|
+
id = input(undefined, /* @ts-ignore */
|
|
43
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
44
|
+
length = input(6, { ...(ngDevMode ? { debugName: "length" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
45
|
+
disabled = input(false, /* @ts-ignore */
|
|
46
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
47
|
+
required = input(false, /* @ts-ignore */
|
|
48
|
+
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
49
|
+
effectiveId = computed(() => this.controlId() || this.id() || this.generatedId, /* @ts-ignore */
|
|
50
|
+
...(ngDevMode ? [{ debugName: "effectiveId" }] : /* istanbul ignore next */ []));
|
|
51
|
+
errorId = computed(() => `${this.effectiveId()}-error`, /* @ts-ignore */
|
|
52
|
+
...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
|
|
53
|
+
hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
|
|
54
|
+
...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
|
|
55
|
+
/**
|
|
56
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
57
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
58
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
59
|
+
* fresh on every change-detection pass.
|
|
60
|
+
*/
|
|
61
|
+
resolvedError() {
|
|
62
|
+
const explicit = this.error();
|
|
63
|
+
if (explicit)
|
|
64
|
+
return explicit;
|
|
65
|
+
if (!this.autoError())
|
|
66
|
+
return undefined;
|
|
67
|
+
const control = this.formGroupDirective.form.get(this.controlName());
|
|
68
|
+
return resolveEgFormError(control?.errors ?? null, this.label(), this._errorMessages);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
72
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
73
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
74
|
+
*/
|
|
75
|
+
showError() {
|
|
76
|
+
const control = this.formGroupDirective.form.get(this.controlName());
|
|
77
|
+
return (!!this.resolvedError() &&
|
|
78
|
+
!!control?.invalid &&
|
|
79
|
+
(control.dirty || control.touched || this.formGroupDirective.submitted));
|
|
80
|
+
}
|
|
81
|
+
slotIndexes = computed(() => Array.from({ length: this.length() }, (_, i) => i), /* @ts-ignore */
|
|
82
|
+
...(ngDevMode ? [{ debugName: "slotIndexes" }] : /* istanbul ignore next */ []));
|
|
83
|
+
/**
|
|
84
|
+
* Combined lock for the brain `linkedSignal`-based disabled state: the raw
|
|
85
|
+
* input write always carries the resolved value, so a same-pass
|
|
86
|
+
* wrapper-toggle + `control.disable()` cannot clobber CVA state.
|
|
87
|
+
*/
|
|
88
|
+
effectiveDisabled() {
|
|
89
|
+
return this.disabled() || !!this.formGroupDirective.form.get(this.controlName())?.disabled;
|
|
90
|
+
}
|
|
91
|
+
// NOTE: BrnInputOtp exposes inputId but no aria-describedby, so error/hint
|
|
92
|
+
// ids render for sighted users without an input-level describedby link.
|
|
93
|
+
// Styling
|
|
94
|
+
userClass = input('', { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: 'class' });
|
|
95
|
+
labelClass = input('', /* @ts-ignore */
|
|
96
|
+
...(ngDevMode ? [{ debugName: "labelClass" }] : /* istanbul ignore next */ []));
|
|
97
|
+
otpClass = input('', /* @ts-ignore */
|
|
98
|
+
...(ngDevMode ? [{ debugName: "otpClass" }] : /* istanbul ignore next */ []));
|
|
99
|
+
errorClass = input('', /* @ts-ignore */
|
|
100
|
+
...(ngDevMode ? [{ debugName: "errorClass" }] : /* istanbul ignore next */ []));
|
|
101
|
+
hintClass = input('', /* @ts-ignore */
|
|
102
|
+
...(ngDevMode ? [{ debugName: "hintClass" }] : /* istanbul ignore next */ []));
|
|
103
|
+
// Computed classes (library base < global config < per-instance)
|
|
104
|
+
$userClass = computed(() => hlm('tw:w-full', this.userClass()), /* @ts-ignore */
|
|
105
|
+
...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
|
|
106
|
+
$labelClass = computed(() => hlm('tw:mb-1', this._config.labelClass, this.labelClass()), /* @ts-ignore */
|
|
107
|
+
...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
|
|
108
|
+
$otpClass = computed(() => hlm(this._config.otpClass, this.otpClass()), /* @ts-ignore */
|
|
109
|
+
...(ngDevMode ? [{ debugName: "$otpClass" }] : /* istanbul ignore next */ []));
|
|
110
|
+
$errorClass = computed(() => hlm('tw:mt-0', this._config.errorClass, this.errorClass()), /* @ts-ignore */
|
|
111
|
+
...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
|
|
112
|
+
$hintClass = computed(() => hlm('tw:mt-0', this._config.hintClass, this.hintClass()), /* @ts-ignore */
|
|
113
|
+
...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
|
|
114
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormInputOtp, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
115
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormInputOtp, isStandalone: true, selector: "eg-form-input-otp", 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 }, length: { classPropertyName: "length", publicName: "length", 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 }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, labelClass: { classPropertyName: "labelClass", publicName: "labelClass", isSignal: true, isRequired: false, transformFunction: null }, otpClass: { classPropertyName: "otpClass", publicName: "otpClass", 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
|
+
@let lbl = label();
|
|
117
|
+
@let cnm = controlName();
|
|
118
|
+
@let hnt = hint();
|
|
119
|
+
@let rqrd = required();
|
|
120
|
+
|
|
121
|
+
<hlm-form-field>
|
|
122
|
+
@if (lbl) {
|
|
123
|
+
<label hlmLabel [for]="effectiveId()" [class]="$labelClass()"
|
|
124
|
+
>{{ lbl }}
|
|
125
|
+
@if (rqrd) {
|
|
126
|
+
<span class="tw:text-red-500">*</span>
|
|
127
|
+
}
|
|
128
|
+
</label>
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
<brn-input-otp
|
|
132
|
+
hlmInputOtp
|
|
133
|
+
[length]="length()"
|
|
134
|
+
[formControlName]="cnm"
|
|
135
|
+
[inputId]="effectiveId()"
|
|
136
|
+
[disabled]="effectiveDisabled()"
|
|
137
|
+
[class]="$otpClass()"
|
|
138
|
+
>
|
|
139
|
+
<div hlmInputOtpGroup>
|
|
140
|
+
@for (i of slotIndexes(); track i) {
|
|
141
|
+
<hlm-input-otp-slot [index]="i" />
|
|
142
|
+
}
|
|
143
|
+
</div>
|
|
144
|
+
</brn-input-otp>
|
|
145
|
+
|
|
146
|
+
@if (showError()) {
|
|
147
|
+
<hlm-error [id]="errorId()" [class]="$errorClass()">
|
|
148
|
+
{{ resolvedError() }}
|
|
149
|
+
</hlm-error>
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@if (hnt) {
|
|
153
|
+
<hlm-hint [id]="hintId()" [class]="$hintClass()">
|
|
154
|
+
{{ hnt }}
|
|
155
|
+
</hlm-hint>
|
|
156
|
+
}
|
|
157
|
+
</hlm-form-field>
|
|
158
|
+
`, isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: HlmFormField, selector: "hlm-form-field", inputs: ["class"] }, { kind: "directive", type: HlmError, selector: "hlm-error", inputs: ["class"] }, { kind: "directive", type: HlmHint, selector: "hlm-hint", inputs: ["class"] }, { kind: "directive", type: HlmLabel, selector: "[hlmLabel]", inputs: ["class"] }, { kind: "component", type: BrnInputOtp, selector: "brn-input-otp", inputs: ["hostStyles", "inputId", "inputAutocomplete", "inputStyles", "containerStyles", "disabled", "length", "inputMode", "inputClass", "autofocus", "transformPaste", "value"], outputs: ["valueChange", "completed"] }, { kind: "directive", type: i2.HlmInputOtp, selector: "brn-input-otp[hlmInputOtp], brn-input-otp[hlm]" }, { kind: "directive", type: i2.HlmInputOtpGroup, selector: "[hlmInputOtpGroup],hlm-input-otp-group" }, { kind: "component", type: i2.HlmInputOtpSlot, selector: "hlm-input-otp-slot", inputs: ["index"] }] });
|
|
159
|
+
}
|
|
160
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormInputOtp, decorators: [{
|
|
161
|
+
type: Component,
|
|
162
|
+
args: [{
|
|
163
|
+
selector: 'eg-form-input-otp',
|
|
164
|
+
standalone: true,
|
|
165
|
+
host: {
|
|
166
|
+
'[class]': '$userClass()',
|
|
167
|
+
},
|
|
168
|
+
imports: [ReactiveFormsModule, HlmFormField, HlmError, HlmHint, HlmLabel, BrnInputOtp, HlmInputOtpImports],
|
|
169
|
+
providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
|
|
170
|
+
template: `
|
|
171
|
+
@let lbl = label();
|
|
172
|
+
@let cnm = controlName();
|
|
173
|
+
@let hnt = hint();
|
|
174
|
+
@let rqrd = required();
|
|
175
|
+
|
|
176
|
+
<hlm-form-field>
|
|
177
|
+
@if (lbl) {
|
|
178
|
+
<label hlmLabel [for]="effectiveId()" [class]="$labelClass()"
|
|
179
|
+
>{{ lbl }}
|
|
180
|
+
@if (rqrd) {
|
|
181
|
+
<span class="tw:text-red-500">*</span>
|
|
182
|
+
}
|
|
183
|
+
</label>
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
<brn-input-otp
|
|
187
|
+
hlmInputOtp
|
|
188
|
+
[length]="length()"
|
|
189
|
+
[formControlName]="cnm"
|
|
190
|
+
[inputId]="effectiveId()"
|
|
191
|
+
[disabled]="effectiveDisabled()"
|
|
192
|
+
[class]="$otpClass()"
|
|
193
|
+
>
|
|
194
|
+
<div hlmInputOtpGroup>
|
|
195
|
+
@for (i of slotIndexes(); track i) {
|
|
196
|
+
<hlm-input-otp-slot [index]="i" />
|
|
197
|
+
}
|
|
198
|
+
</div>
|
|
199
|
+
</brn-input-otp>
|
|
200
|
+
|
|
201
|
+
@if (showError()) {
|
|
202
|
+
<hlm-error [id]="errorId()" [class]="$errorClass()">
|
|
203
|
+
{{ resolvedError() }}
|
|
204
|
+
</hlm-error>
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
@if (hnt) {
|
|
208
|
+
<hlm-hint [id]="hintId()" [class]="$hintClass()">
|
|
209
|
+
{{ hnt }}
|
|
210
|
+
</hlm-hint>
|
|
211
|
+
}
|
|
212
|
+
</hlm-form-field>
|
|
213
|
+
`,
|
|
214
|
+
}]
|
|
215
|
+
}], 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 }] }], length: [{ type: i0.Input, args: [{ isSignal: true, alias: "length", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", 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 }] }], otpClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "otpClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
|
|
216
|
+
|
|
217
|
+
/*
|
|
218
|
+
* Public API Surface of form-input-otp
|
|
219
|
+
*/
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Generated bundle index. Do not edit.
|
|
223
|
+
*/
|
|
224
|
+
|
|
225
|
+
export { EgFormInputOtp, injectEgFormInputOtpConfig, provideEgFormInputOtpConfig };
|
|
226
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "form-input-otp",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^20.3.0 || ^22.0.0",
|
|
6
|
+
"@angular/core": "^20.3.0 || ^22.0.0"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"tslib": "^2.3.0"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"module": "fesm2022/form-input-otp.mjs",
|
|
13
|
+
"typings": "types/form-input-otp.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
"./package.json": {
|
|
16
|
+
"default": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./types/form-input-otp.d.ts",
|
|
20
|
+
"default": "./fesm2022/form-input-otp.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"type": "module"
|
|
24
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { ValueProvider } from '@angular/core';
|
|
3
|
+
import { ClassValue } from 'clsx';
|
|
4
|
+
import { NumberInput } from '@angular/cdk/coercion';
|
|
5
|
+
|
|
6
|
+
declare class EgFormInputOtp {
|
|
7
|
+
private readonly formGroupDirective;
|
|
8
|
+
private readonly _errorMessages;
|
|
9
|
+
private readonly generatedId;
|
|
10
|
+
private readonly _config;
|
|
11
|
+
label: _angular_core.InputSignal<string | undefined>;
|
|
12
|
+
controlId: _angular_core.InputSignal<string | undefined>;
|
|
13
|
+
controlName: _angular_core.InputSignal<string>;
|
|
14
|
+
error: _angular_core.InputSignal<string | undefined>;
|
|
15
|
+
/**
|
|
16
|
+
* Auto-resolve the displayed message from the control's `ValidationErrors`
|
|
17
|
+
* when `error()` is unset. Explicit `error()` always wins. Set to `false`
|
|
18
|
+
* for manual-only messages.
|
|
19
|
+
*/
|
|
20
|
+
autoError: _angular_core.InputSignal<boolean>;
|
|
21
|
+
hint: _angular_core.InputSignal<string | undefined>;
|
|
22
|
+
id: _angular_core.InputSignal<string | undefined>;
|
|
23
|
+
length: _angular_core.InputSignalWithTransform<number, NumberInput>;
|
|
24
|
+
disabled: _angular_core.InputSignal<boolean>;
|
|
25
|
+
required: _angular_core.InputSignal<boolean>;
|
|
26
|
+
readonly effectiveId: _angular_core.Signal<string>;
|
|
27
|
+
readonly errorId: _angular_core.Signal<string>;
|
|
28
|
+
readonly hintId: _angular_core.Signal<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Displayed message: explicit `error()` wins; otherwise (when `autoError()`)
|
|
31
|
+
* auto-resolved from the control's `ValidationErrors`. Plain method (not a
|
|
32
|
+
* computed): `ValidationErrors` is not a signal, so the control must be read
|
|
33
|
+
* fresh on every change-detection pass.
|
|
34
|
+
*/
|
|
35
|
+
protected resolvedError(): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the error is surfaced: message present + control invalid +
|
|
38
|
+
* touched/dirty/submitted. Gates the visual `<hlm-error>` (and
|
|
39
|
+
* `describedBy()`, where present) so sighted and screen-reader output agree.
|
|
40
|
+
*/
|
|
41
|
+
protected showError(): boolean;
|
|
42
|
+
readonly slotIndexes: _angular_core.Signal<number[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Combined lock for the brain `linkedSignal`-based disabled state: the raw
|
|
45
|
+
* input write always carries the resolved value, so a same-pass
|
|
46
|
+
* wrapper-toggle + `control.disable()` cannot clobber CVA state.
|
|
47
|
+
*/
|
|
48
|
+
effectiveDisabled(): boolean;
|
|
49
|
+
userClass: _angular_core.InputSignal<ClassValue>;
|
|
50
|
+
labelClass: _angular_core.InputSignal<string>;
|
|
51
|
+
otpClass: _angular_core.InputSignal<string>;
|
|
52
|
+
errorClass: _angular_core.InputSignal<string>;
|
|
53
|
+
hintClass: _angular_core.InputSignal<string>;
|
|
54
|
+
$userClass: _angular_core.Signal<string>;
|
|
55
|
+
$labelClass: _angular_core.Signal<string>;
|
|
56
|
+
$otpClass: _angular_core.Signal<string>;
|
|
57
|
+
$errorClass: _angular_core.Signal<string>;
|
|
58
|
+
$hintClass: _angular_core.Signal<string>;
|
|
59
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormInputOtp, never>;
|
|
60
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormInputOtp, "eg-form-input-otp", 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; }; "length": { "alias": "length"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "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; }; "otpClass": { "alias": "otpClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface EgFormInputOtpConfig {
|
|
64
|
+
/**
|
|
65
|
+
* Global class defaults for `eg-form-input-otp` 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
|
+
otpClass?: string;
|
|
71
|
+
errorClass?: string;
|
|
72
|
+
hintClass?: string;
|
|
73
|
+
}
|
|
74
|
+
declare function provideEgFormInputOtpConfig(config: Partial<EgFormInputOtpConfig>): ValueProvider;
|
|
75
|
+
declare function injectEgFormInputOtpConfig(): EgFormInputOtpConfig;
|
|
76
|
+
|
|
77
|
+
export { EgFormInputOtp, injectEgFormInputOtpConfig, provideEgFormInputOtpConfig };
|
|
78
|
+
export type { EgFormInputOtpConfig };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Form Month Year Picker (`@egose/shadcn-theme-ng/form-month-year-picker`)
|
|
2
|
+
|
|
3
|
+
A ready-made reactive-form month/year field: label + `hlm-month-year-picker` + validation error/hint display in one tag. Dates default to the `MM/YYYY` display/edit format.
|
|
4
|
+
|
|
5
|
+
The Angular implementation is a standalone wrapper (not a brain primitive): it renders
|
|
6
|
+
`HlmFormField` / `HlmError` / `HlmHint` from `@egose/shadcn-theme-ng/form-field`, `HlmLabel`, and
|
|
7
|
+
`HlmMonthYearPicker` + `HlmMonthYearInput` from `@egose/shadcn-theme-ng/date-picker`. The inner
|
|
8
|
+
picker is bound with `[formControlName]="controlName()"`, so the parent `FormGroup` owns the
|
|
9
|
+
`Date | null` value. It must live inside a `FormGroupDirective` (`[formGroup]` parent); ids come from
|
|
10
|
+
`HlmFormIdGenerator` unless overridden.
|
|
11
|
+
|
|
12
|
+
> **Ships as:** `@egose/shadcn-theme-ng/form-month-year-picker` and `@egose/shadcn-theme-ng-tw/form-month-year-picker`
|
|
13
|
+
> (the `tw:`-prefixed Tailwind variant). Both expose the identical TypeScript surface; only the
|
|
14
|
+
> emitted Tailwind class strings differ. See the [package README](../../README.md) for install
|
|
15
|
+
> steps, peer dependencies, and Tailwind setup. Do not publish this project directory independently.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Plain Tailwind (no prefix)
|
|
21
|
+
npm install @egose/shadcn-theme-ng
|
|
22
|
+
|
|
23
|
+
# tw:-prefixed Tailwind variant
|
|
24
|
+
npm install @egose/shadcn-theme-ng-tw
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Peer dependencies (Angular, `@spartan-ng/brain`, `@ng-icons/*`, `rxjs`, …) are documented in the
|
|
28
|
+
[package README](../../README.md#peer-dependencies). This subpath additionally relies at runtime on
|
|
29
|
+
`@egose/shadcn-theme-ng/date-picker`, `@egose/shadcn-theme-ng/form-field`, and
|
|
30
|
+
`@egose/shadcn-theme-ng/label`.
|
|
31
|
+
|
|
32
|
+
## Imports
|
|
33
|
+
|
|
34
|
+
Exported from the subpath root (`projects/form-month-year-picker/src/public-api.ts`):
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { EgFormMonthYearPicker } from '@egose/shadcn-theme-ng/form-month-year-picker';
|
|
38
|
+
// tw variant: replace with '@egose/shadcn-theme-ng-tw/form-month-year-picker'
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`ControlValueAccessor` behavior: `eg-form-month-year-picker` itself is not a `ControlValueAccessor`;
|
|
42
|
+
the inner `hlm-month-year-picker` is (bound via `formControlName`), so `formControlName`/`formGroup`
|
|
43
|
+
handling, `Validators`, and `disabled` state from the control all flow through the parent form.
|
|
44
|
+
|
|
45
|
+
## Anatomy / Structure
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<form [formGroup]="form">
|
|
49
|
+
<eg-form-month-year-picker
|
|
50
|
+
controlName="start"
|
|
51
|
+
label="Start month"
|
|
52
|
+
[required]="true"
|
|
53
|
+
error="Start month is required."
|
|
54
|
+
/>
|
|
55
|
+
</form>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Selector (from source): `eg-form-month-year-picker` (standalone component, host `tw:w-full`).
|
|
59
|
+
|
|
60
|
+
## API reference
|
|
61
|
+
|
|
62
|
+
### `EgFormMonthYearPicker` — `eg-form-month-year-picker`
|
|
63
|
+
|
|
64
|
+
| Input | Type | Default | Description |
|
|
65
|
+
| ------------------- | --------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
66
|
+
| `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.** |
|
|
67
|
+
| `label` | `string \| undefined` | — | Label text (hidden when omitted). |
|
|
68
|
+
| `error` | `string \| undefined` | — | Error text shown when invalid. |
|
|
69
|
+
| `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`. |
|
|
70
|
+
| `hint` | `string \| undefined` | — | Hint text shown otherwise. |
|
|
71
|
+
| `controlId` | `string \| undefined` | — | Explicit id (first priority for `effectiveId`). |
|
|
72
|
+
| `id` | `string \| undefined` | — | Fallback id (second priority). |
|
|
73
|
+
| `name` | `string \| undefined` | — | Native `name` forwarded to the inner input (`controlName` wins). |
|
|
74
|
+
| `placeholder` | `string` | `'MM/YYYY'` | Input placeholder. |
|
|
75
|
+
| `readonly` | `boolean` | `false` | Native `readonly` forwarded to the inner input. |
|
|
76
|
+
| `disabled` | `boolean` | `false` | Locks interaction (form control stays enabled). |
|
|
77
|
+
| `required` | `boolean` | `false` | Shows a red `*` next to the label. |
|
|
78
|
+
| `min` / `max` | `Date \| string \| null` | `null` | Date bounds forwarded to the picker. |
|
|
79
|
+
| `autoCloseOnSelect` | `boolean` | config default | Forwarded to the picker (falls back to `provideHlmMonthYearPickerConfig`, default `false`). |
|
|
80
|
+
| `formatDate` | `(date: Date) => string` | config default | Display format (falls back to `provideHlmMonthYearPickerConfig`, default `MM/YYYY`). |
|
|
81
|
+
| `transformDate` | `(date: Date) => Date` | config default | Model transform (falls back to `provideHlmMonthYearPickerConfig`). |
|
|
82
|
+
| `parseDate` | `(value: string) => Date \| null` | config default | Input parsing, forwarded to the input (falls back to `provideHlmMonthYearPickerConfig`). |
|
|
83
|
+
| `formatInputDate` | `(date: Date) => string` | config default | Edit format while focused (falls back to `provideHlmMonthYearPickerConfig`). |
|
|
84
|
+
| `class` | `ClassValue` | `''` | Extra host classes (base `tw:w-full`). |
|
|
85
|
+
| `labelClass` | `string` | `''` | Extra label classes (base `tw:mb-1`). |
|
|
86
|
+
| `pickerClass` | `string` | `''` | Extra picker-container classes (base `tw:mb-1`). |
|
|
87
|
+
| `inputClass` | `string` | `''` | Extra inner-input classes (e.g. `tw:text-lg`). |
|
|
88
|
+
| `errorClass` | `string` | `''` | Extra error classes (base `tw:mt-0`). |
|
|
89
|
+
| `hintClass` | `string` | `''` | Extra hint classes (base `tw:mt-0`). |
|
|
90
|
+
|
|
91
|
+
| Member | Description |
|
|
92
|
+
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
93
|
+
| `effectiveId` | `controlId() \|\| id() \|\| generated` — wired to input `inputId` and label `for`. |
|
|
94
|
+
| `errorId` / `hintId` | `effectiveId + '-error' / '-hint'`. |
|
|
95
|
+
| `describedBy()` | `errorId` when `error()` is set and control is invalid + dirty/touched, else `hintId` when `hint()` is set, else `null` — wired to input `ariaDescribedby`. |
|
|
96
|
+
|
|
97
|
+
Requires a `[formGroup]` ancestor (injects `FormGroupDirective`, provides `ControlContainer → FormGroupDirective`).
|
|
98
|
+
|
|
99
|
+
## Examples
|
|
100
|
+
|
|
101
|
+
### 1. Basic required month field
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { Component, inject } from '@angular/core';
|
|
105
|
+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
106
|
+
import { EgFormMonthYearPicker } from '@egose/shadcn-theme-ng/form-month-year-picker';
|
|
107
|
+
|
|
108
|
+
@Component({
|
|
109
|
+
selector: 'app-start',
|
|
110
|
+
standalone: true,
|
|
111
|
+
imports: [ReactiveFormsModule, EgFormMonthYearPicker],
|
|
112
|
+
template: `
|
|
113
|
+
<form [formGroup]="form" (ngSubmit)="submit()">
|
|
114
|
+
<eg-form-month-year-picker
|
|
115
|
+
controlName="start"
|
|
116
|
+
label="Start month"
|
|
117
|
+
[required]="true"
|
|
118
|
+
error="Start month is required."
|
|
119
|
+
/>
|
|
120
|
+
<button type="submit" [disabled]="form.invalid">Continue</button>
|
|
121
|
+
</form>
|
|
122
|
+
`,
|
|
123
|
+
})
|
|
124
|
+
export class StartComponent {
|
|
125
|
+
private readonly fb = inject(FormBuilder);
|
|
126
|
+
readonly form = this.fb.group({ start: [null as Date | null, Validators.required] });
|
|
127
|
+
submit() {
|
|
128
|
+
console.log(this.form.value.start);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 2. Card expiry with hint
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
import { Component, inject } from '@angular/core';
|
|
137
|
+
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
|
138
|
+
import { EgFormMonthYearPicker } from '@egose/shadcn-theme-ng/form-month-year-picker';
|
|
139
|
+
|
|
140
|
+
@Component({
|
|
141
|
+
selector: 'app-expiry',
|
|
142
|
+
standalone: true,
|
|
143
|
+
imports: [ReactiveFormsModule, EgFormMonthYearPicker],
|
|
144
|
+
template: `
|
|
145
|
+
<form [formGroup]="form">
|
|
146
|
+
<eg-form-month-year-picker
|
|
147
|
+
controlName="expiry"
|
|
148
|
+
label="Expiry"
|
|
149
|
+
[min]="today"
|
|
150
|
+
hint="As printed on the card."
|
|
151
|
+
error="Enter a valid future month."
|
|
152
|
+
/>
|
|
153
|
+
</form>
|
|
154
|
+
`,
|
|
155
|
+
})
|
|
156
|
+
export class ExpiryComponent {
|
|
157
|
+
private readonly fb = inject(FormBuilder);
|
|
158
|
+
readonly form = this.fb.group({ expiry: [null as Date | null] });
|
|
159
|
+
readonly today = new Date();
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Accessibility notes
|
|
164
|
+
|
|
165
|
+
- Label `for` ↔ input `inputId` wiring is automatic via `effectiveId`; the input also receives `ariaLabel` and `ariaDescribedby` — always pass a `label`.
|
|
166
|
+
- Closing the picker popover marks the control touched, so errors appear after interaction even without typing.
|
|
167
|
+
- The required `*` is visual; pair with `Validators.required` so assistive tech and validation agree.
|
|
168
|
+
|
|
169
|
+
## Theming / CSS variables
|
|
170
|
+
|
|
171
|
+
No component-specific CSS variables. Style per-instance via `class` / `labelClass` / `pickerClass` / `inputClass` / `errorClass` / `hintClass` (precedence: library base < global config < per-instance).
|
|
172
|
+
|
|
173
|
+
Global defaults via the month-year picker config:
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
import { provideHlmMonthYearPickerConfig } from '@egose/shadcn-theme-ng/date-picker';
|
|
177
|
+
|
|
178
|
+
await bootstrapApplication(App, {
|
|
179
|
+
providers: [provideHlmMonthYearPickerConfig({ inputClass: 'tw:text-sm', labelClass: 'tw:font-medium' })],
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
The host keeps `tw:w-full`; constrain width with `class` or a wrapping container.
|
|
184
|
+
|
|
185
|
+
## Related subpaths
|
|
186
|
+
|
|
187
|
+
- `@egose/shadcn-theme-ng/date-picker` — raw `hlm-month-year-picker` + input/trigger/config tokens for custom layouts.
|
|
188
|
+
- `@egose/shadcn-theme-ng/form-date-picker` — the full-date counterpart (`eg-form-date-picker`).
|
|
189
|
+
- `@egose/shadcn-theme-ng/form-field` — `hlm-form-field` / `hlm-error` / `hlm-hint` used internally.
|