@egose/shadcn-theme-ng-tw 0.1.0 → 0.3.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 +2 -2
- package/accordion/README.md +405 -2
- package/alert/README.md +372 -2
- package/alert/fesm2022/alert.mjs +1 -1
- package/alert-dialog/README.md +471 -5
- package/aspect-ratio/README.md +272 -5
- package/autocomplete/README.md +502 -2
- package/autocomplete/fesm2022/autocomplete.mjs +1 -1
- package/avatar/README.md +357 -5
- package/badge/README.md +318 -2
- package/basic-alert/README.md +353 -2
- package/breadcrumb/README.md +406 -5
- package/button/README.md +482 -2
- package/button/fesm2022/button.mjs +85 -107
- package/button/types/button.d.ts +5 -8
- package/button-group/README.md +318 -5
- package/button-group/fesm2022/button-group.mjs +1 -1
- package/calendar/README.md +357 -2
- package/card/README.md +331 -5
- package/carousel/README.md +333 -5
- package/carousel/fesm2022/carousel.mjs +4 -1
- package/checkbox/README.md +320 -2
- package/checkbox/fesm2022/checkbox.mjs +6 -7
- package/checkbox/types/checkbox.d.ts +1 -1
- package/collapsible/README.md +332 -5
- package/combobox/README.md +507 -5
- package/combobox/fesm2022/combobox.mjs +5 -2
- package/command/README.md +435 -5
- package/confirmation-dialog/README.md +301 -2
- package/context-menu/README.md +366 -5
- package/date-picker/README.md +469 -2
- package/date-picker/fesm2022/date-picker.mjs +150 -32
- package/date-picker/types/date-picker.d.ts +102 -9
- package/dialog/README.md +448 -2
- package/drawer/README.md +395 -5
- package/dropdown-menu/README.md +417 -5
- package/empty/README.md +329 -5
- package/field/README.md +385 -5
- package/form-autocomplete/README.md +177 -0
- package/form-autocomplete/fesm2022/form-autocomplete.mjs +211 -0
- package/form-autocomplete/package.json +24 -0
- package/form-autocomplete/types/form-autocomplete.d.ts +61 -0
- package/form-checkbox/README.md +322 -2
- package/form-checkbox/fesm2022/form-checkbox.mjs +22 -9
- package/form-checkbox/types/form-checkbox.d.ts +23 -4
- package/form-combobox/README.md +202 -0
- package/form-combobox/fesm2022/form-combobox.mjs +273 -0
- package/form-combobox/package.json +24 -0
- package/form-combobox/types/form-combobox.d.ts +73 -0
- package/form-date-picker/README.md +348 -2
- package/form-date-picker/fesm2022/form-date-picker.mjs +60 -16
- package/form-date-picker/types/form-date-picker.d.ts +17 -1
- package/form-date-picker-multi/README.md +191 -0
- package/form-date-picker-multi/fesm2022/form-date-picker-multi.mjs +239 -0
- package/form-date-picker-multi/package.json +24 -0
- package/form-date-picker-multi/types/form-date-picker-multi.d.ts +58 -0
- package/form-date-range-picker/README.md +253 -0
- package/form-date-range-picker/fesm2022/form-date-range-picker.mjs +236 -0
- package/form-date-range-picker/package.json +24 -0
- package/form-date-range-picker/types/form-date-range-picker.d.ts +55 -0
- package/form-field/README.md +356 -2
- package/form-field-simple/README.md +340 -2
- package/form-input-otp/README.md +194 -0
- package/form-input-otp/fesm2022/form-input-otp.mjs +194 -0
- package/form-input-otp/package.json +24 -0
- package/form-input-otp/types/form-input-otp.d.ts +58 -0
- package/form-month-year-picker/README.md +188 -0
- package/form-month-year-picker/fesm2022/form-month-year-picker.mjs +229 -0
- package/form-month-year-picker/package.json +24 -0
- package/form-month-year-picker/types/form-month-year-picker.d.ts +53 -0
- package/form-native-select/README.md +205 -0
- package/form-native-select/fesm2022/form-native-select.mjs +187 -0
- package/form-native-select/package.json +24 -0
- package/form-native-select/types/form-native-select.d.ts +57 -0
- package/form-phone-input/README.md +188 -0
- package/form-phone-input/fesm2022/form-phone-input.mjs +203 -0
- package/form-phone-input/package.json +24 -0
- package/form-phone-input/types/form-phone-input.d.ts +58 -0
- package/form-radio-group/README.md +198 -0
- package/form-radio-group/fesm2022/form-radio-group.mjs +211 -0
- package/form-radio-group/package.json +24 -0
- package/form-radio-group/types/form-radio-group.d.ts +63 -0
- package/form-searchable-multiselect/README.md +371 -2
- package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs +19 -10
- package/form-searchable-multiselect/types/form-searchable-multiselect.d.ts +18 -1
- package/form-select/README.md +360 -2
- package/form-select/fesm2022/form-select.mjs +24 -15
- package/form-select/types/form-select.d.ts +18 -1
- package/form-slider/README.md +182 -0
- package/form-slider/fesm2022/form-slider.mjs +186 -0
- package/form-slider/package.json +24 -0
- package/form-slider/types/form-slider.d.ts +60 -0
- package/form-switch/README.md +173 -0
- package/form-switch/fesm2022/form-switch.mjs +178 -0
- package/form-switch/package.json +24 -0
- package/form-switch/types/form-switch.d.ts +50 -0
- package/form-text-input/README.md +381 -2
- package/form-text-input/fesm2022/form-text-input.mjs +19 -10
- package/form-text-input/types/form-text-input.d.ts +18 -1
- package/form-textarea/README.md +357 -2
- package/form-textarea/fesm2022/form-textarea.mjs +19 -10
- package/form-textarea/types/form-textarea.d.ts +18 -1
- package/form-toggle/README.md +186 -0
- package/form-toggle/fesm2022/form-toggle.mjs +241 -0
- package/form-toggle/package.json +24 -0
- package/form-toggle/types/form-toggle.d.ts +82 -0
- package/form-toggle-group/README.md +176 -0
- package/form-toggle-group/fesm2022/form-toggle-group.mjs +216 -0
- package/form-toggle-group/package.json +24 -0
- package/form-toggle-group/types/form-toggle-group.d.ts +65 -0
- package/hover-card/README.md +256 -5
- package/icon/README.md +239 -2
- package/input/README.md +269 -2
- package/input-group/README.md +335 -5
- package/input-group/fesm2022/input-group.mjs +23 -13
- package/input-group/types/input-group.d.ts +4 -1
- package/input-otp/README.md +375 -5
- package/item/README.md +385 -5
- package/item/fesm2022/item.mjs +3 -3
- package/kbd/README.md +291 -5
- package/label/README.md +272 -2
- package/layout-simple/README.md +193 -2
- package/layout-simple/fesm2022/layout-simple.mjs +877 -409
- package/layout-simple/types/layout-simple.d.ts +174 -137
- package/menu/README.md +417 -2
- package/menubar/README.md +343 -5
- package/native-select/README.md +323 -5
- package/native-select/fesm2022/native-select.mjs +18 -6
- package/native-select/types/native-select.d.ts +7 -2
- package/navigation-menu/README.md +369 -5
- package/package.json +57 -1
- package/pagination/README.md +388 -5
- 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/popover/README.md +331 -2
- package/progress/README.md +311 -5
- package/radio-group/README.md +364 -2
- package/radio-group/fesm2022/radio-group.mjs +5 -1
- package/resizable/README.md +269 -5
- package/scroll-area/README.md +233 -5
- package/searchable-multiselect/README.md +323 -2
- package/select/README.md +437 -2
- package/separator/README.md +222 -2
- package/sheet/README.md +311 -2
- package/sheet/fesm2022/sheet.mjs +1 -1
- package/sidebar/README.md +457 -5
- package/skeleton/README.md +217 -5
- package/slider/README.md +273 -5
- package/slider/fesm2022/slider.mjs +17 -13
- package/sonner/README.md +346 -2
- package/spinner/README.md +284 -2
- package/switch/README.md +310 -2
- package/switch/fesm2022/switch.mjs +7 -5
- package/switch/types/switch.d.ts +2 -1
- package/table/README.md +423 -5
- package/tabs/README.md +411 -2
- package/tabs/fesm2022/tabs.mjs +12 -2
- package/textarea/README.md +282 -5
- package/toggle/README.md +270 -5
- package/toggle-group/README.md +340 -5
- package/tooltip/README.md +269 -2
- package/typography/README.md +271 -5
- package/utils/README.md +303 -2
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, input, computed, Component } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/forms';
|
|
4
|
+
import { FormGroupDirective, ReactiveFormsModule, ControlContainer } from '@angular/forms';
|
|
5
|
+
import { HlmFormIdGenerator, HlmFormField, HlmError, HlmHint } from '@egose/shadcn-theme-ng-tw/form-field';
|
|
6
|
+
import { HlmLabel } from '@egose/shadcn-theme-ng-tw/label';
|
|
7
|
+
import { formatNanpPhoneNumber, HlmPhoneInput } from '@egose/shadcn-theme-ng-tw/phone-input';
|
|
8
|
+
import { hlm } from '@egose/shadcn-theme-ng-tw/utils';
|
|
9
|
+
|
|
10
|
+
const EgFormPhoneInputConfigToken = new InjectionToken('EgFormPhoneInputConfig');
|
|
11
|
+
function provideEgFormPhoneInputConfig(config) {
|
|
12
|
+
return { provide: EgFormPhoneInputConfigToken, useValue: { ...config } };
|
|
13
|
+
}
|
|
14
|
+
function injectEgFormPhoneInputConfig() {
|
|
15
|
+
return inject(EgFormPhoneInputConfigToken, { optional: true }) ?? {};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class EgFormPhoneInput {
|
|
19
|
+
formGroupDirective = inject(FormGroupDirective);
|
|
20
|
+
generatedId = inject(HlmFormIdGenerator).generate('eg-form-phone-input');
|
|
21
|
+
_config = injectEgFormPhoneInputConfig();
|
|
22
|
+
label = input(undefined, /* @ts-ignore */
|
|
23
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
24
|
+
controlId = input(undefined, /* @ts-ignore */
|
|
25
|
+
...(ngDevMode ? [{ debugName: "controlId" }] : /* istanbul ignore next */ []));
|
|
26
|
+
controlName = input('', /* @ts-ignore */
|
|
27
|
+
...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
|
|
28
|
+
error = input(undefined, /* @ts-ignore */
|
|
29
|
+
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
30
|
+
hint = input(undefined, /* @ts-ignore */
|
|
31
|
+
...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
32
|
+
id = input(undefined, /* @ts-ignore */
|
|
33
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
34
|
+
name = input(undefined, /* @ts-ignore */
|
|
35
|
+
...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
|
|
36
|
+
placeholder = input('(555) 123-4567', /* @ts-ignore */
|
|
37
|
+
...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
38
|
+
autocomplete = input('tel', /* @ts-ignore */
|
|
39
|
+
...(ngDevMode ? [{ debugName: "autocomplete" }] : /* istanbul ignore next */ []));
|
|
40
|
+
readonly = input(false, /* @ts-ignore */
|
|
41
|
+
...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
|
|
42
|
+
disabled = input(false, /* @ts-ignore */
|
|
43
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
44
|
+
required = input(false, /* @ts-ignore */
|
|
45
|
+
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
46
|
+
maxDigits = input(10, /* @ts-ignore */
|
|
47
|
+
...(ngDevMode ? [{ debugName: "maxDigits" }] : /* istanbul ignore next */ []));
|
|
48
|
+
formatPhoneNumber = input(formatNanpPhoneNumber, /* @ts-ignore */
|
|
49
|
+
...(ngDevMode ? [{ debugName: "formatPhoneNumber" }] : /* istanbul ignore next */ []));
|
|
50
|
+
modelFormat = input('digits', /* @ts-ignore */
|
|
51
|
+
...(ngDevMode ? [{ debugName: "modelFormat" }] : /* istanbul ignore next */ []));
|
|
52
|
+
effectiveId = computed(() => this.controlId() || this.id() || this.generatedId, /* @ts-ignore */
|
|
53
|
+
...(ngDevMode ? [{ debugName: "effectiveId" }] : /* istanbul ignore next */ []));
|
|
54
|
+
errorId = computed(() => `${this.effectiveId()}-error`, /* @ts-ignore */
|
|
55
|
+
...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
|
|
56
|
+
hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
|
|
57
|
+
...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
|
|
58
|
+
describedBy() {
|
|
59
|
+
const control = this.formGroupDirective.form.get(this.controlName());
|
|
60
|
+
return this.error() && control?.invalid && (control.dirty || control.touched)
|
|
61
|
+
? this.errorId()
|
|
62
|
+
: this.hint()
|
|
63
|
+
? this.hintId()
|
|
64
|
+
: null;
|
|
65
|
+
}
|
|
66
|
+
// Styling
|
|
67
|
+
userClass = input('', { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: 'class' });
|
|
68
|
+
labelClass = input('', /* @ts-ignore */
|
|
69
|
+
...(ngDevMode ? [{ debugName: "labelClass" }] : /* istanbul ignore next */ []));
|
|
70
|
+
inputClass = input('', /* @ts-ignore */
|
|
71
|
+
...(ngDevMode ? [{ debugName: "inputClass" }] : /* istanbul ignore next */ []));
|
|
72
|
+
errorClass = input('', /* @ts-ignore */
|
|
73
|
+
...(ngDevMode ? [{ debugName: "errorClass" }] : /* istanbul ignore next */ []));
|
|
74
|
+
hintClass = input('', /* @ts-ignore */
|
|
75
|
+
...(ngDevMode ? [{ debugName: "hintClass" }] : /* istanbul ignore next */ []));
|
|
76
|
+
// Computed classes (library base < global config < per-instance)
|
|
77
|
+
$userClass = computed(() => hlm('tw:w-full', this.userClass()), /* @ts-ignore */
|
|
78
|
+
...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
|
|
79
|
+
$labelClass = computed(() => hlm('tw:mb-1 tw:gap-0', this._config.labelClass, this.labelClass()), /* @ts-ignore */
|
|
80
|
+
...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
|
|
81
|
+
$inputClass = computed(() => hlm('tw:mb-1', this._config.inputClass, this.inputClass()), /* @ts-ignore */
|
|
82
|
+
...(ngDevMode ? [{ debugName: "$inputClass" }] : /* istanbul ignore next */ []));
|
|
83
|
+
$errorClass = computed(() => hlm('tw:mt-0', this._config.errorClass, this.errorClass()), /* @ts-ignore */
|
|
84
|
+
...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
|
|
85
|
+
$hintClass = computed(() => hlm('tw:mt-0', this._config.hintClass, this.hintClass()), /* @ts-ignore */
|
|
86
|
+
...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
|
|
87
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormPhoneInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
88
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormPhoneInput, isStandalone: true, selector: "eg-form-phone-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 }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, autocomplete: { classPropertyName: "autocomplete", publicName: "autocomplete", 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 }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, maxDigits: { classPropertyName: "maxDigits", publicName: "maxDigits", isSignal: true, isRequired: false, transformFunction: null }, formatPhoneNumber: { classPropertyName: "formatPhoneNumber", publicName: "formatPhoneNumber", isSignal: true, isRequired: false, transformFunction: null }, modelFormat: { classPropertyName: "modelFormat", publicName: "modelFormat", 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: `
|
|
89
|
+
@let lbl = label();
|
|
90
|
+
@let cnm = controlName();
|
|
91
|
+
@let err = error();
|
|
92
|
+
@let hnt = hint();
|
|
93
|
+
@let rqrd = required();
|
|
94
|
+
|
|
95
|
+
<hlm-form-field>
|
|
96
|
+
@if (lbl) {
|
|
97
|
+
<label hlmLabel [for]="effectiveId()" [class]="$labelClass()"
|
|
98
|
+
>{{ lbl }}
|
|
99
|
+
@if (rqrd) {
|
|
100
|
+
<span class="tw:text-red-500">*</span>
|
|
101
|
+
}
|
|
102
|
+
</label>
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
<hlm-phone-input
|
|
106
|
+
[inputId]="effectiveId()"
|
|
107
|
+
[name]="cnm || name()"
|
|
108
|
+
[readonly]="readonly()"
|
|
109
|
+
[ariaLabel]="lbl"
|
|
110
|
+
[ariaDescribedby]="describedBy()"
|
|
111
|
+
[placeholder]="placeholder()"
|
|
112
|
+
[autocomplete]="autocomplete()"
|
|
113
|
+
[maxDigits]="maxDigits()"
|
|
114
|
+
[formatPhoneNumber]="formatPhoneNumber()"
|
|
115
|
+
[modelFormat]="modelFormat()"
|
|
116
|
+
[disabled]="disabled()"
|
|
117
|
+
[formControlName]="cnm"
|
|
118
|
+
[class]="$inputClass()"
|
|
119
|
+
/>
|
|
120
|
+
|
|
121
|
+
@if (err) {
|
|
122
|
+
<hlm-error [id]="errorId()" [class]="$errorClass()">
|
|
123
|
+
{{ err }}
|
|
124
|
+
</hlm-error>
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@if (hnt) {
|
|
128
|
+
<hlm-hint [id]="hintId()" [class]="$hintClass()">
|
|
129
|
+
{{ hnt }}
|
|
130
|
+
</hlm-hint>
|
|
131
|
+
}
|
|
132
|
+
</hlm-form-field>
|
|
133
|
+
`, 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: HlmPhoneInput, selector: "hlm-phone-input", inputs: ["inputId", "name", "ariaLabel", "ariaDescribedby", "placeholder", "autocomplete", "readonly", "disabled", "forceInvalid", "maxDigits", "modelFormat", "formatPhoneNumber", "class", "inputClass"] }] });
|
|
134
|
+
}
|
|
135
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormPhoneInput, decorators: [{
|
|
136
|
+
type: Component,
|
|
137
|
+
args: [{
|
|
138
|
+
selector: 'eg-form-phone-input',
|
|
139
|
+
standalone: true,
|
|
140
|
+
host: {
|
|
141
|
+
'[class]': '$userClass()',
|
|
142
|
+
},
|
|
143
|
+
imports: [ReactiveFormsModule, HlmFormField, HlmError, HlmHint, HlmLabel, HlmPhoneInput],
|
|
144
|
+
providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
|
|
145
|
+
template: `
|
|
146
|
+
@let lbl = label();
|
|
147
|
+
@let cnm = controlName();
|
|
148
|
+
@let err = error();
|
|
149
|
+
@let hnt = hint();
|
|
150
|
+
@let rqrd = required();
|
|
151
|
+
|
|
152
|
+
<hlm-form-field>
|
|
153
|
+
@if (lbl) {
|
|
154
|
+
<label hlmLabel [for]="effectiveId()" [class]="$labelClass()"
|
|
155
|
+
>{{ lbl }}
|
|
156
|
+
@if (rqrd) {
|
|
157
|
+
<span class="tw:text-red-500">*</span>
|
|
158
|
+
}
|
|
159
|
+
</label>
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
<hlm-phone-input
|
|
163
|
+
[inputId]="effectiveId()"
|
|
164
|
+
[name]="cnm || name()"
|
|
165
|
+
[readonly]="readonly()"
|
|
166
|
+
[ariaLabel]="lbl"
|
|
167
|
+
[ariaDescribedby]="describedBy()"
|
|
168
|
+
[placeholder]="placeholder()"
|
|
169
|
+
[autocomplete]="autocomplete()"
|
|
170
|
+
[maxDigits]="maxDigits()"
|
|
171
|
+
[formatPhoneNumber]="formatPhoneNumber()"
|
|
172
|
+
[modelFormat]="modelFormat()"
|
|
173
|
+
[disabled]="disabled()"
|
|
174
|
+
[formControlName]="cnm"
|
|
175
|
+
[class]="$inputClass()"
|
|
176
|
+
/>
|
|
177
|
+
|
|
178
|
+
@if (err) {
|
|
179
|
+
<hlm-error [id]="errorId()" [class]="$errorClass()">
|
|
180
|
+
{{ err }}
|
|
181
|
+
</hlm-error>
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@if (hnt) {
|
|
185
|
+
<hlm-hint [id]="hintId()" [class]="$hintClass()">
|
|
186
|
+
{{ hnt }}
|
|
187
|
+
</hlm-hint>
|
|
188
|
+
}
|
|
189
|
+
</hlm-form-field>
|
|
190
|
+
`,
|
|
191
|
+
}]
|
|
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 }] }], autocomplete: [{ type: i0.Input, args: [{ isSignal: true, alias: "autocomplete", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], maxDigits: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxDigits", required: false }] }], formatPhoneNumber: [{ type: i0.Input, args: [{ isSignal: true, alias: "formatPhoneNumber", required: false }] }], modelFormat: [{ type: i0.Input, args: [{ isSignal: true, alias: "modelFormat", 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 }] }] } });
|
|
193
|
+
|
|
194
|
+
/*
|
|
195
|
+
* Public API Surface of form-phone-input
|
|
196
|
+
*/
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Generated bundle index. Do not edit.
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
export { EgFormPhoneInput, injectEgFormPhoneInputConfig, provideEgFormPhoneInputConfig };
|
|
203
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "form-phone-input",
|
|
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-phone-input.mjs",
|
|
13
|
+
"typings": "types/form-phone-input.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
"./package.json": {
|
|
16
|
+
"default": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./types/form-phone-input.d.ts",
|
|
20
|
+
"default": "./fesm2022/form-phone-input.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"type": "module"
|
|
24
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { ValueProvider } from '@angular/core';
|
|
3
|
+
import { PhoneNumberFormatter } from '@egose/shadcn-theme-ng-tw/phone-input';
|
|
4
|
+
import { ClassValue } from 'clsx';
|
|
5
|
+
|
|
6
|
+
declare class EgFormPhoneInput {
|
|
7
|
+
private readonly formGroupDirective;
|
|
8
|
+
private readonly generatedId;
|
|
9
|
+
private readonly _config;
|
|
10
|
+
label: _angular_core.InputSignal<string | undefined>;
|
|
11
|
+
controlId: _angular_core.InputSignal<string | undefined>;
|
|
12
|
+
controlName: _angular_core.InputSignal<string>;
|
|
13
|
+
error: _angular_core.InputSignal<string | undefined>;
|
|
14
|
+
hint: _angular_core.InputSignal<string | undefined>;
|
|
15
|
+
id: _angular_core.InputSignal<string | undefined>;
|
|
16
|
+
name: _angular_core.InputSignal<string | undefined>;
|
|
17
|
+
placeholder: _angular_core.InputSignal<string>;
|
|
18
|
+
autocomplete: _angular_core.InputSignal<string>;
|
|
19
|
+
readonly: _angular_core.InputSignal<boolean>;
|
|
20
|
+
disabled: _angular_core.InputSignal<boolean>;
|
|
21
|
+
required: _angular_core.InputSignal<boolean>;
|
|
22
|
+
maxDigits: _angular_core.InputSignal<number>;
|
|
23
|
+
formatPhoneNumber: _angular_core.InputSignal<PhoneNumberFormatter>;
|
|
24
|
+
modelFormat: _angular_core.InputSignal<"digits" | "formatted">;
|
|
25
|
+
readonly effectiveId: _angular_core.Signal<string>;
|
|
26
|
+
readonly errorId: _angular_core.Signal<string>;
|
|
27
|
+
readonly hintId: _angular_core.Signal<string>;
|
|
28
|
+
describedBy(): string | null;
|
|
29
|
+
userClass: _angular_core.InputSignal<ClassValue>;
|
|
30
|
+
labelClass: _angular_core.InputSignal<string>;
|
|
31
|
+
inputClass: _angular_core.InputSignal<string>;
|
|
32
|
+
errorClass: _angular_core.InputSignal<string>;
|
|
33
|
+
hintClass: _angular_core.InputSignal<string>;
|
|
34
|
+
$userClass: _angular_core.Signal<string>;
|
|
35
|
+
$labelClass: _angular_core.Signal<string>;
|
|
36
|
+
$inputClass: _angular_core.Signal<string>;
|
|
37
|
+
$errorClass: _angular_core.Signal<string>;
|
|
38
|
+
$hintClass: _angular_core.Signal<string>;
|
|
39
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormPhoneInput, never>;
|
|
40
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormPhoneInput, "eg-form-phone-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; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "autocomplete": { "alias": "autocomplete"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "maxDigits": { "alias": "maxDigits"; "required": false; "isSignal": true; }; "formatPhoneNumber": { "alias": "formatPhoneNumber"; "required": false; "isSignal": true; }; "modelFormat": { "alias": "modelFormat"; "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>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface EgFormPhoneInputConfig {
|
|
44
|
+
/**
|
|
45
|
+
* Global class defaults for `eg-form-phone-input` styling slots.
|
|
46
|
+
* Each is merged under the matching per-instance `*Class` input
|
|
47
|
+
* (library base < global config < per-instance).
|
|
48
|
+
*/
|
|
49
|
+
labelClass?: string;
|
|
50
|
+
inputClass?: string;
|
|
51
|
+
errorClass?: string;
|
|
52
|
+
hintClass?: string;
|
|
53
|
+
}
|
|
54
|
+
declare function provideEgFormPhoneInputConfig(config: Partial<EgFormPhoneInputConfig>): ValueProvider;
|
|
55
|
+
declare function injectEgFormPhoneInputConfig(): EgFormPhoneInputConfig;
|
|
56
|
+
|
|
57
|
+
export { EgFormPhoneInput, injectEgFormPhoneInputConfig, provideEgFormPhoneInputConfig };
|
|
58
|
+
export type { EgFormPhoneInputConfig };
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Form Radio Group (`@egose/shadcn-theme-ng/form-radio-group`)
|
|
2
|
+
|
|
3
|
+
A ready-made reactive-form radio field: group label + `hlm-radio-group` options + validation error/hint display in one tag.
|
|
4
|
+
|
|
5
|
+
The Angular implementation is a standalone wrapper: it renders `HlmFormField` / `HlmError` / `HlmHint` from `@egose/shadcn-theme-ng/form-field`, `HlmLabel`, and `HlmRadioGroup` / `HlmRadio` / `HlmRadioIndicator` from `@egose/shadcn-theme-ng/radio-group`. The group is bound with `[formControlName]="controlName()"`, so the parent `FormGroup` owns the `string` value. It must live inside a `FormGroupDirective` (`[formGroup]` parent); ids come from `HlmFormIdGenerator` unless overridden.
|
|
6
|
+
|
|
7
|
+
> **Ships as:** `@egose/shadcn-theme-ng/form-radio-group` and `@egose/shadcn-theme-ng-tw/form-radio-group`
|
|
8
|
+
> (the `tw:`-prefixed Tailwind variant). Both expose the identical TypeScript surface; only the
|
|
9
|
+
> emitted Tailwind class strings differ. See the [package README](../../README.md) for install
|
|
10
|
+
> steps, peer dependencies, and Tailwind setup. Do not publish this project directory independently.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Plain Tailwind (no prefix)
|
|
16
|
+
npm install @egose/shadcn-theme-ng
|
|
17
|
+
|
|
18
|
+
# tw:-prefixed Tailwind variant
|
|
19
|
+
npm install @egose/shadcn-theme-ng-tw
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Peer dependencies (Angular, `@spartan-ng/brain`, `rxjs`, …) are documented in the
|
|
23
|
+
[package README](../../README.md#peer-dependencies). This subpath additionally relies at runtime on
|
|
24
|
+
`@egose/shadcn-theme-ng/radio-group`, `@egose/shadcn-theme-ng/form-field`, and
|
|
25
|
+
`@egose/shadcn-theme-ng/label`.
|
|
26
|
+
|
|
27
|
+
## Imports
|
|
28
|
+
|
|
29
|
+
Exported from the subpath root (`projects/form-radio-group/src/public-api.ts`):
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { EgFormRadioGroup, provideEgFormRadioGroupConfig } from '@egose/shadcn-theme-ng/form-radio-group';
|
|
33
|
+
// tw variant: replace with '@egose/shadcn-theme-ng-tw/form-radio-group'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Standalone usage:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { Component } from '@angular/core';
|
|
40
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
41
|
+
import { EgFormRadioGroup } from '@egose/shadcn-theme-ng/form-radio-group';
|
|
42
|
+
|
|
43
|
+
@Component({
|
|
44
|
+
selector: 'app-demo',
|
|
45
|
+
standalone: true,
|
|
46
|
+
imports: [ReactiveFormsModule, EgFormRadioGroup],
|
|
47
|
+
template: `...`,
|
|
48
|
+
})
|
|
49
|
+
export class DemoComponent {}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
NgModule-based consumer: add `EgFormRadioGroup` (and `ReactiveFormsModule`) to the module's
|
|
53
|
+
`imports` — it is a standalone component, not a module.
|
|
54
|
+
|
|
55
|
+
`ControlValueAccessor` behavior: `eg-form-radio-group` itself is not a `ControlValueAccessor`; the
|
|
56
|
+
inner `hlm-radio-group` is (bound via `formControlName`), so `formControlName`/`formGroup` handling,
|
|
57
|
+
`Validators`, and `disabled` state from the control all flow through the parent form.
|
|
58
|
+
|
|
59
|
+
## Anatomy / Structure
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<form [formGroup]="form">
|
|
63
|
+
<eg-form-radio-group controlName="plan" label="Plan" [options]="plans" [required]="true" error="Plan is required." />
|
|
64
|
+
</form>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Selector (from source): `eg-form-radio-group` (standalone component, host `tw:w-full`).
|
|
68
|
+
|
|
69
|
+
## API reference
|
|
70
|
+
|
|
71
|
+
### `EgFormRadioGroup` — `eg-form-radio-group`
|
|
72
|
+
|
|
73
|
+
| Input | Type | Default | Description |
|
|
74
|
+
| ------------- | ------------------------------- | ------- | ------------------------------------------------------------------ |
|
|
75
|
+
| `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.** |
|
|
76
|
+
| `label` | `string \| undefined` | — | Group label text (hidden when omitted). |
|
|
77
|
+
| `error` | `string \| undefined` | — | Error text shown when invalid. |
|
|
78
|
+
| `hint` | `string \| undefined` | — | Hint text shown otherwise. |
|
|
79
|
+
| `controlId` | `string \| undefined` | — | Explicit id prefix (first priority for `effectiveId`). |
|
|
80
|
+
| `id` | `string \| undefined` | — | Fallback id prefix (second priority). |
|
|
81
|
+
| `name` | `string \| undefined` | — | Native group `name` (`controlName` wins when set). |
|
|
82
|
+
| `disabled` | `boolean` | `false` | Locks interaction (form control stays enabled). |
|
|
83
|
+
| `required` | `boolean` | `false` | Shows a red `*` next to the label; forwarded to the group. |
|
|
84
|
+
| `options` | `{ value, label, disabled? }[]` | `[]` | Rendered as labelled `hlm-radio` options. |
|
|
85
|
+
| `class` | `ClassValue` | `''` | Extra host classes (base `tw:w-full`). |
|
|
86
|
+
| `labelClass` | `string` | `''` | Extra group-label classes (base `tw:mb-1`). |
|
|
87
|
+
| `groupClass` | `string` | `''` | Extra group classes (base `tw:flex tw:flex-col tw:gap-2`). |
|
|
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` — id prefix for `errorId` / `hintId`. |
|
|
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 each radio's `aria-describedby`. |
|
|
96
|
+
|
|
97
|
+
Each option renders inside a native `<label>`, so every radio is implicitly labelled by its option text. Requires a `[formGroup]` ancestor (injects `FormGroupDirective`, provides `ControlContainer → FormGroupDirective`).
|
|
98
|
+
|
|
99
|
+
## Examples
|
|
100
|
+
|
|
101
|
+
### 1. Basic required group
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { Component, inject } from '@angular/core';
|
|
105
|
+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
106
|
+
import { EgFormRadioGroup } from '@egose/shadcn-theme-ng/form-radio-group';
|
|
107
|
+
|
|
108
|
+
@Component({
|
|
109
|
+
selector: 'app-plan',
|
|
110
|
+
standalone: true,
|
|
111
|
+
imports: [ReactiveFormsModule, EgFormRadioGroup],
|
|
112
|
+
template: `
|
|
113
|
+
<form [formGroup]="form" (ngSubmit)="submit()">
|
|
114
|
+
<eg-form-radio-group
|
|
115
|
+
controlName="plan"
|
|
116
|
+
label="Plan"
|
|
117
|
+
[options]="plans"
|
|
118
|
+
[required]="true"
|
|
119
|
+
error="Plan is required."
|
|
120
|
+
/>
|
|
121
|
+
<button type="submit" [disabled]="form.invalid">Continue</button>
|
|
122
|
+
</form>
|
|
123
|
+
`,
|
|
124
|
+
})
|
|
125
|
+
export class PlanComponent {
|
|
126
|
+
private readonly fb = inject(FormBuilder);
|
|
127
|
+
readonly form = this.fb.group({ plan: ['', Validators.required] });
|
|
128
|
+
readonly plans = [
|
|
129
|
+
{ value: 'starter', label: 'Starter' },
|
|
130
|
+
{ value: 'pro', label: 'Pro' },
|
|
131
|
+
{ value: 'enterprise', label: 'Enterprise', disabled: true },
|
|
132
|
+
];
|
|
133
|
+
submit() {
|
|
134
|
+
console.log(this.form.value.plan);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### 2. Hint + horizontal layout
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import { Component, inject } from '@angular/core';
|
|
143
|
+
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
|
144
|
+
import { EgFormRadioGroup } from '@egose/shadcn-theme-ng/form-radio-group';
|
|
145
|
+
|
|
146
|
+
@Component({
|
|
147
|
+
selector: 'app-billing',
|
|
148
|
+
standalone: true,
|
|
149
|
+
imports: [ReactiveFormsModule, EgFormRadioGroup],
|
|
150
|
+
template: `
|
|
151
|
+
<form [formGroup]="form">
|
|
152
|
+
<eg-form-radio-group
|
|
153
|
+
controlName="cycle"
|
|
154
|
+
label="Billing cycle"
|
|
155
|
+
[options]="cycles"
|
|
156
|
+
groupClass="tw:flex-row tw:gap-4"
|
|
157
|
+
hint="Switch or cancel anytime."
|
|
158
|
+
/>
|
|
159
|
+
</form>
|
|
160
|
+
`,
|
|
161
|
+
})
|
|
162
|
+
export class BillingComponent {
|
|
163
|
+
private readonly fb = inject(FormBuilder);
|
|
164
|
+
readonly form = this.fb.group({ cycle: ['monthly'] });
|
|
165
|
+
readonly cycles = [
|
|
166
|
+
{ value: 'monthly', label: 'Monthly' },
|
|
167
|
+
{ value: 'yearly', label: 'Yearly' },
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Accessibility notes
|
|
173
|
+
|
|
174
|
+
- Each radio is wrapped in a native `<label>` with its option text (implicit association), and receives `aria-describedby` (error/hint id) — the group label is visual.
|
|
175
|
+
- The required `*` is visual; pair with `Validators.required` so assistive tech and validation agree.
|
|
176
|
+
|
|
177
|
+
## Theming / CSS variables
|
|
178
|
+
|
|
179
|
+
No component-specific CSS variables. Style per-instance via `class` / `labelClass` / `groupClass` / `errorClass` / `hintClass` (precedence: library base < global config < per-instance).
|
|
180
|
+
|
|
181
|
+
Global defaults per styling slot via the wrapper config:
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
import { provideEgFormRadioGroupConfig } from '@egose/shadcn-theme-ng/form-radio-group';
|
|
185
|
+
|
|
186
|
+
await bootstrapApplication(App, {
|
|
187
|
+
providers: [provideEgFormRadioGroupConfig({ groupClass: 'tw:gap-3', labelClass: 'tw:font-medium' })],
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
The host keeps `tw:w-full`; constrain width with `class` or a wrapping container.
|
|
192
|
+
|
|
193
|
+
## Related subpaths
|
|
194
|
+
|
|
195
|
+
- `@egose/shadcn-theme-ng/radio-group` — raw `hlm-radio-group` / `hlm-radio` / `hlm-radio-indicator` for custom layouts.
|
|
196
|
+
- `@egose/shadcn-theme-ng/form-select` — single-choice alternative with a popover (`eg-form-select`).
|
|
197
|
+
- `@egose/shadcn-theme-ng/form-field` — `hlm-form-field` / `hlm-error` / `hlm-hint` used internally.
|
|
198
|
+
- `@egose/shadcn-theme-ng/form-field-simple` — alternative minimal wrapper when you compose controls by hand.
|