@egose/shadcn-theme-ng 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-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/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 +125 -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 +147 -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 +38 -12
- 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 +129 -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 +130 -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 +106 -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 +125 -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 +103 -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 +113 -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 +111 -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 +20 -11
- package/form-select/types/form-select.d.ts +18 -1
- package/form-slider/README.md +182 -0
- package/form-slider/fesm2022/form-slider.mjs +106 -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 +100 -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 +159 -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 +116 -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 +22 -12
- 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 +472 -236
- 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/sidebar/README.md +457 -5
- package/skeleton/README.md +217 -5
- package/slider/README.md +273 -5
- package/slider/fesm2022/slider.mjs +3 -3
- 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 +2 -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
|
@@ -1,3 +1,341 @@
|
|
|
1
|
-
# Form Field Simple
|
|
1
|
+
# Form Field Simple (`@egose/shadcn-theme-ng/form-field-simple`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A minimal reactive-form wrapper: `eg-form-field` projects your control and shows either the projected `hlm-error` or `hlm-hint` based on the control's touched/dirty error state. A lighter alternative to `hlm-form-field` with no brain dependency.
|
|
4
|
+
|
|
5
|
+
The Angular implementation is a standalone component with no headless primitive: it grabs the
|
|
6
|
+
projected `FormControlName` via `contentChild`, subscribes to its `statusChanges`, and exposes
|
|
7
|
+
`hasError` / `firstErrorKey` computed signals. Template logic is `@if (hasError())` → project
|
|
8
|
+
`hlm-error`, else project `hlm-hint`. It must live inside a `FormGroupDirective` (`[formGroup]`
|
|
9
|
+
parent) and provides `ControlContainer → FormGroupDirective` so `formControlName` resolves.
|
|
10
|
+
|
|
11
|
+
> **Ships as:** `@egose/shadcn-theme-ng/form-field-simple` and `@egose/shadcn-theme-ng-tw/form-field-simple`
|
|
12
|
+
> (the `tw:`-prefixed Tailwind variant). Both expose the identical TypeScript surface; only the
|
|
13
|
+
> emitted Tailwind class strings differ. See the [package README](../../README.md) for install
|
|
14
|
+
> steps, peer dependencies, and Tailwind setup. Do not publish this project directory independently.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Plain Tailwind (no prefix)
|
|
20
|
+
npm install @egose/shadcn-theme-ng
|
|
21
|
+
|
|
22
|
+
# tw:-prefixed Tailwind variant
|
|
23
|
+
npm install @egose/shadcn-theme-ng-tw
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Peer dependencies (Angular, `@spartan-ng/brain`, `@ng-icons/*`, `rxjs`, …) are documented in the
|
|
27
|
+
[package README](../../README.md#peer-dependencies). This subpath has no extra runtime component
|
|
28
|
+
dependencies beyond `@egose/shadcn-theme-ng/utils`.
|
|
29
|
+
|
|
30
|
+
## Imports
|
|
31
|
+
|
|
32
|
+
Exported from the subpath root (`projects/form-field-simple/src/public-api.ts`). Note: this subpath
|
|
33
|
+
exports a single standalone component — there is no `*Imports` array or `*Module`:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { EgFormField } from '@egose/shadcn-theme-ng/form-field-simple';
|
|
37
|
+
// tw variant: replace with '@egose/shadcn-theme-ng-tw/form-field-simple'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Standalone usage:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { Component } from '@angular/core';
|
|
44
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
45
|
+
import { EgFormField } from '@egose/shadcn-theme-ng/form-field-simple';
|
|
46
|
+
import { HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
47
|
+
|
|
48
|
+
@Component({
|
|
49
|
+
selector: 'app-demo',
|
|
50
|
+
standalone: true,
|
|
51
|
+
imports: [ReactiveFormsModule, EgFormField, HlmError, HlmHint],
|
|
52
|
+
template: `...`,
|
|
53
|
+
})
|
|
54
|
+
export class DemoComponent {}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
NgModule-based consumer: add `EgFormField` (and `ReactiveFormsModule`) to the module's `imports`.
|
|
58
|
+
|
|
59
|
+
`ControlValueAccessor` behavior: `eg-form-field` is not a form control and implements no
|
|
60
|
+
`ControlValueAccessor` — the projected control (e.g. `input[formControlName]`, `hlm-checkbox`,
|
|
61
|
+
`hlm-select`) owns the value. The wrapper only observes `FormControlName.control.errors`,
|
|
62
|
+
`touched`, and `dirty` to decide which message to project.
|
|
63
|
+
|
|
64
|
+
## Anatomy / Structure
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<form [formGroup]="form">
|
|
68
|
+
<eg-form-field>
|
|
69
|
+
<label hlmLabel for="email">Email</label>
|
|
70
|
+
<input hlmInput id="email" formControlName="email" />
|
|
71
|
+
<hlm-hint>We'll never share your email.</hlm-hint>
|
|
72
|
+
<hlm-error>Email is required.</hlm-error>
|
|
73
|
+
</eg-form-field>
|
|
74
|
+
</form>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Selector (from source): `eg-form-field` (standalone component).
|
|
78
|
+
|
|
79
|
+
Template (from source):
|
|
80
|
+
|
|
81
|
+
```html
|
|
82
|
+
<ng-content></ng-content>
|
|
83
|
+
|
|
84
|
+
@if (hasError()) {
|
|
85
|
+
<ng-content select="hlm-error"></ng-content>
|
|
86
|
+
} @else {
|
|
87
|
+
<ng-content select="hlm-hint"></ng-content>
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## API reference
|
|
92
|
+
|
|
93
|
+
### `EgFormField` — `eg-form-field`
|
|
94
|
+
|
|
95
|
+
| Input | Type | Default | Description |
|
|
96
|
+
| ------- | ------------ | ------- | ----------------------------------- |
|
|
97
|
+
| `class` | `ClassValue` | `''` | Extra host classes (base is empty). |
|
|
98
|
+
|
|
99
|
+
| Member | Type | Description |
|
|
100
|
+
| --------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
101
|
+
| `control` | `contentChild(FormControlName)` | The projected form-control directive. No control → `hasError` is always `false` (hint shows). |
|
|
102
|
+
| `form` | `FormGroup` | Parent group from injected `FormGroupDirective`. |
|
|
103
|
+
| `hasError` | `computed boolean` | `true` when `control.errors` is non-empty and the control is `touched` or `dirty` (subscribes to `statusChanges`). |
|
|
104
|
+
| `firstErrorKey` | `computed string \| null` | First key of `control.errors` (e.g. `'required'`), or `null`. Useful for per-key messages. |
|
|
105
|
+
|
|
106
|
+
Lifecycle: subscribes to `statusChanges` in `ngAfterContentInit`, unsubscribes in `ngOnDestroy`.
|
|
107
|
+
|
|
108
|
+
## Examples
|
|
109
|
+
|
|
110
|
+
### 1. Basic input with hint/error
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
import { Component, inject } from '@angular/core';
|
|
114
|
+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
115
|
+
import { EgFormField } from '@egose/shadcn-theme-ng/form-field-simple';
|
|
116
|
+
import { HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
117
|
+
import { HlmLabel } from '@egose/shadcn-theme-ng/label';
|
|
118
|
+
import { HlmInput } from '@egose/shadcn-theme-ng/input';
|
|
119
|
+
|
|
120
|
+
@Component({
|
|
121
|
+
selector: 'app-simple-basic',
|
|
122
|
+
standalone: true,
|
|
123
|
+
imports: [ReactiveFormsModule, EgFormField, HlmError, HlmHint, HlmLabel, HlmInput],
|
|
124
|
+
template: `
|
|
125
|
+
<form [formGroup]="form">
|
|
126
|
+
<eg-form-field>
|
|
127
|
+
<label hlmLabel for="name">Name</label>
|
|
128
|
+
<input hlmInput id="name" formControlName="name" placeholder="Ada" />
|
|
129
|
+
<hlm-hint>Your public display name.</hlm-hint>
|
|
130
|
+
<hlm-error>Name is required.</hlm-error>
|
|
131
|
+
</eg-form-field>
|
|
132
|
+
</form>
|
|
133
|
+
`,
|
|
134
|
+
})
|
|
135
|
+
export class SimpleBasicComponent {
|
|
136
|
+
private readonly fb = inject(FormBuilder);
|
|
137
|
+
readonly form = this.fb.group({ name: ['', Validators.required] });
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 2. Per-validator messages with `firstErrorKey`
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import { Component, inject, viewChild } from '@angular/core';
|
|
145
|
+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
146
|
+
import { EgFormField } from '@egose/shadcn-theme-ng/form-field-simple';
|
|
147
|
+
import { HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
148
|
+
import { HlmLabel } from '@egose/shadcn-theme-ng/label';
|
|
149
|
+
import { HlmInput } from '@egose/shadcn-theme-ng/input';
|
|
150
|
+
|
|
151
|
+
@Component({
|
|
152
|
+
selector: 'app-per-key',
|
|
153
|
+
standalone: true,
|
|
154
|
+
imports: [ReactiveFormsModule, EgFormField, HlmError, HlmHint, HlmLabel, HlmInput],
|
|
155
|
+
template: `
|
|
156
|
+
<form [formGroup]="form">
|
|
157
|
+
<eg-form-field #wrapper>
|
|
158
|
+
<label hlmLabel for="email">Email</label>
|
|
159
|
+
<input hlmInput id="email" type="email" formControlName="email" />
|
|
160
|
+
<hlm-hint>We'll send the receipt here.</hlm-hint>
|
|
161
|
+
<hlm-error>
|
|
162
|
+
@if (wrapper.firstErrorKey() === 'required') {
|
|
163
|
+
Email is required.
|
|
164
|
+
} @else if (wrapper.firstErrorKey() === 'email') {
|
|
165
|
+
Enter a valid email address.
|
|
166
|
+
} @else {
|
|
167
|
+
This field is invalid.
|
|
168
|
+
}
|
|
169
|
+
</hlm-error>
|
|
170
|
+
</eg-form-field>
|
|
171
|
+
</form>
|
|
172
|
+
`,
|
|
173
|
+
})
|
|
174
|
+
export class PerKeyComponent {
|
|
175
|
+
private readonly fb = inject(FormBuilder);
|
|
176
|
+
readonly field = viewChild(EgFormField);
|
|
177
|
+
readonly form = this.fb.group({ email: ['', [Validators.required, Validators.email]] });
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### 3. Template-driven-style submit gating
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
import { Component, inject } from '@angular/core';
|
|
185
|
+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
186
|
+
import { EgFormField } from '@egose/shadcn-theme-ng/form-field-simple';
|
|
187
|
+
import { HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
188
|
+
import { HlmLabel } from '@egose/shadcn-theme-ng/label';
|
|
189
|
+
import { HlmInput } from '@egose/shadcn-theme-ng/input';
|
|
190
|
+
|
|
191
|
+
@Component({
|
|
192
|
+
selector: 'app-submit-gate',
|
|
193
|
+
standalone: true,
|
|
194
|
+
imports: [ReactiveFormsModule, EgFormField, HlmError, HlmHint, HlmLabel, HlmInput],
|
|
195
|
+
template: `
|
|
196
|
+
<form [formGroup]="form" (ngSubmit)="submit()">
|
|
197
|
+
<eg-form-field>
|
|
198
|
+
<label hlmLabel for="password">Password</label>
|
|
199
|
+
<input hlmInput id="password" type="password" formControlName="password" />
|
|
200
|
+
<hlm-hint>At least 8 characters.</hlm-hint>
|
|
201
|
+
<hlm-error>Password must be at least 8 characters.</hlm-error>
|
|
202
|
+
</eg-form-field>
|
|
203
|
+
<button type="submit">Sign in</button>
|
|
204
|
+
</form>
|
|
205
|
+
`,
|
|
206
|
+
})
|
|
207
|
+
export class SubmitGateComponent {
|
|
208
|
+
private readonly fb = inject(FormBuilder);
|
|
209
|
+
readonly form = this.fb.group({ password: ['', [Validators.required, Validators.minLength(8)]] });
|
|
210
|
+
submit() {
|
|
211
|
+
this.form.markAllAsTouched();
|
|
212
|
+
if (this.form.valid) console.log('signing in…');
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### 4. Checkbox row (used by `eg-form-checkbox` internally)
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
import { Component, inject } from '@angular/core';
|
|
221
|
+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
222
|
+
import { EgFormField } from '@egose/shadcn-theme-ng/form-field-simple';
|
|
223
|
+
import { HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
224
|
+
import { HlmCheckbox } from '@egose/shadcn-theme-ng/checkbox';
|
|
225
|
+
import { HlmLabel } from '@egose/shadcn-theme-ng/label';
|
|
226
|
+
|
|
227
|
+
@Component({
|
|
228
|
+
selector: 'app-simple-check',
|
|
229
|
+
standalone: true,
|
|
230
|
+
imports: [ReactiveFormsModule, EgFormField, HlmError, HlmHint, HlmCheckbox, HlmLabel],
|
|
231
|
+
template: `
|
|
232
|
+
<form [formGroup]="form">
|
|
233
|
+
<eg-form-field>
|
|
234
|
+
<div class="tw:flex tw:items-center tw:gap-2">
|
|
235
|
+
<hlm-checkbox id="tos" formControlName="tos" />
|
|
236
|
+
<label hlmLabel for="tos">I agree to the terms</label>
|
|
237
|
+
</div>
|
|
238
|
+
<hlm-hint>You can withdraw consent anytime.</hlm-hint>
|
|
239
|
+
<hlm-error>You must agree to continue.</hlm-error>
|
|
240
|
+
</eg-form-field>
|
|
241
|
+
</form>
|
|
242
|
+
`,
|
|
243
|
+
})
|
|
244
|
+
export class SimpleCheckComponent {
|
|
245
|
+
private readonly fb = inject(FormBuilder);
|
|
246
|
+
readonly form = this.fb.group({ tos: [false, Validators.requiredTrue] });
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### 5. Select + async options
|
|
251
|
+
|
|
252
|
+
```ts
|
|
253
|
+
import { Component, inject, signal } from '@angular/core';
|
|
254
|
+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
255
|
+
import { EgFormField } from '@egose/shadcn-theme-ng/form-field-simple';
|
|
256
|
+
import { HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
257
|
+
import { HlmLabel } from '@egose/shadcn-theme-ng/label';
|
|
258
|
+
import { HlmSelectImports } from '@egose/shadcn-theme-ng/select';
|
|
259
|
+
|
|
260
|
+
@Component({
|
|
261
|
+
selector: 'app-simple-select',
|
|
262
|
+
standalone: true,
|
|
263
|
+
imports: [ReactiveFormsModule, EgFormField, HlmError, HlmHint, HlmLabel, ...HlmSelectImports],
|
|
264
|
+
template: `
|
|
265
|
+
<form [formGroup]="form">
|
|
266
|
+
<eg-form-field>
|
|
267
|
+
<label hlmLabel>Country</label>
|
|
268
|
+
<hlm-select formControlName="country" placeholder="Select a country">
|
|
269
|
+
<hlm-select-content>
|
|
270
|
+
@if (!countries().length) {
|
|
271
|
+
<hlm-select-item value="" disabled>Loading…</hlm-select-item>
|
|
272
|
+
}
|
|
273
|
+
@for (c of countries(); track c) {
|
|
274
|
+
<hlm-select-item [value]="c">{{ c }}</hlm-select-item>
|
|
275
|
+
}
|
|
276
|
+
</hlm-select-content>
|
|
277
|
+
</hlm-select>
|
|
278
|
+
<hlm-hint>Used for shipping estimates.</hlm-hint>
|
|
279
|
+
<hlm-error>Pick a country.</hlm-error>
|
|
280
|
+
</eg-form-field>
|
|
281
|
+
</form>
|
|
282
|
+
`,
|
|
283
|
+
})
|
|
284
|
+
export class SimpleSelectComponent {
|
|
285
|
+
private readonly fb = inject(FormBuilder);
|
|
286
|
+
readonly form = this.fb.group({ country: ['', Validators.required] });
|
|
287
|
+
readonly countries = signal<string[]>([]);
|
|
288
|
+
constructor() {
|
|
289
|
+
setTimeout(() => this.countries.set(['Germany', 'France', 'Japan']), 500);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### 6. Custom host styling + textarea
|
|
295
|
+
|
|
296
|
+
```ts
|
|
297
|
+
import { Component, inject } from '@angular/core';
|
|
298
|
+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
299
|
+
import { EgFormField } from '@egose/shadcn-theme-ng/form-field-simple';
|
|
300
|
+
import { HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
301
|
+
import { HlmLabel } from '@egose/shadcn-theme-ng/label';
|
|
302
|
+
import { HlmTextarea } from '@egose/shadcn-theme-ng/textarea';
|
|
303
|
+
|
|
304
|
+
@Component({
|
|
305
|
+
selector: 'app-simple-area',
|
|
306
|
+
standalone: true,
|
|
307
|
+
imports: [ReactiveFormsModule, EgFormField, HlmError, HlmHint, HlmLabel, HlmTextarea],
|
|
308
|
+
template: `
|
|
309
|
+
<form [formGroup]="form">
|
|
310
|
+
<eg-form-field class="tw:rounded-lg tw:border tw:p-4">
|
|
311
|
+
<label hlmLabel for="notes">Notes</label>
|
|
312
|
+
<textarea hlmTextarea id="notes" formControlName="notes" rows="3"></textarea>
|
|
313
|
+
<hlm-hint>Optional context for the reviewer.</hlm-hint>
|
|
314
|
+
<hlm-error>Notes are required for this step.</hlm-error>
|
|
315
|
+
</eg-form-field>
|
|
316
|
+
</form>
|
|
317
|
+
`,
|
|
318
|
+
})
|
|
319
|
+
export class SimpleAreaComponent {
|
|
320
|
+
private readonly fb = inject(FormBuilder);
|
|
321
|
+
readonly form = this.fb.group({ notes: ['', Validators.required] });
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
## Accessibility notes
|
|
326
|
+
|
|
327
|
+
- Errors only appear after the control is `touched` or `dirty`, so screen-reader users are not spammed on load; call `markAllAsTouched()` on submit to reveal outstanding errors.
|
|
328
|
+
- The wrapper adds no label itself — always include a `<label>` (or `aria-label`) so the field has an accessible name.
|
|
329
|
+
- Only one of `hlm-error` / `hlm-hint` is in the DOM at a time, keeping `aria-describedby` targets unambiguous when you wire ids.
|
|
330
|
+
- `firstErrorKey` lets you render a single assertive message per failure instead of stacking multiple errors.
|
|
331
|
+
|
|
332
|
+
## Theming / CSS variables
|
|
333
|
+
|
|
334
|
+
No component-specific CSS variables and no base host classes — layout comes from your content plus `class`. Pair with `hlm-error` / `hlm-hint` styling from `@egose/shadcn-theme-ng/form-field`.
|
|
335
|
+
|
|
336
|
+
## Related subpaths
|
|
337
|
+
|
|
338
|
+
- `@egose/shadcn-theme-ng/form-field` — `hlm-form-field` with brain `BrnField` state (stricter, throws without a field control).
|
|
339
|
+
- `@egose/shadcn-theme-ng/form-checkbox` — ready-made checkbox row built on `eg-form-field`.
|
|
340
|
+
- `@egose/shadcn-theme-ng/label` — `HlmLabel` for field labels.
|
|
341
|
+
- `@egose/shadcn-theme-ng/input`, `.../textarea`, `.../select` — controls to project inside the wrapper.
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# Form Input OTP (`@egose/shadcn-theme-ng/form-input-otp`)
|
|
2
|
+
|
|
3
|
+
A ready-made reactive-form one-time-code field: label + `brn-input-otp` slots + validation error/hint display in one tag. The model is a plain `string`.
|
|
4
|
+
|
|
5
|
+
The Angular implementation is a standalone wrapper: it renders `HlmFormField` / `HlmError` / `HlmHint` from `@egose/shadcn-theme-ng/form-field`, `HlmLabel`, and `BrnInputOtp` + `HlmInputOtp*` parts from `@egose/shadcn-theme-ng/input-otp` and `@spartan-ng/brain/input-otp`. The OTP input is bound with `[formControlName]="controlName()"` and renders one `hlm-input-otp-slot` per `length` unit in a single group. It must live inside a `FormGroupDirective` (`[formGroup]` parent); ids come from `HlmFormIdGenerator` unless overridden.
|
|
6
|
+
|
|
7
|
+
> **Ships as:** `@egose/shadcn-theme-ng/form-input-otp` and `@egose/shadcn-theme-ng-tw/form-input-otp`
|
|
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/input-otp`, `@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-input-otp/src/public-api.ts`):
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { EgFormInputOtp, provideEgFormInputOtpConfig } from '@egose/shadcn-theme-ng/form-input-otp';
|
|
33
|
+
// tw variant: replace with '@egose/shadcn-theme-ng-tw/form-input-otp'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Standalone usage:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { Component } from '@angular/core';
|
|
40
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
41
|
+
import { EgFormInputOtp } from '@egose/shadcn-theme-ng/form-input-otp';
|
|
42
|
+
|
|
43
|
+
@Component({
|
|
44
|
+
selector: 'app-demo',
|
|
45
|
+
standalone: true,
|
|
46
|
+
imports: [ReactiveFormsModule, EgFormInputOtp],
|
|
47
|
+
template: `...`,
|
|
48
|
+
})
|
|
49
|
+
export class DemoComponent {}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
NgModule-based consumer: add `EgFormInputOtp` (and `ReactiveFormsModule`) to the module's
|
|
53
|
+
`imports` — it is a standalone component, not a module.
|
|
54
|
+
|
|
55
|
+
`ControlValueAccessor` behavior: `eg-form-input-otp` itself is not a `ControlValueAccessor`; the
|
|
56
|
+
inner `brn-input-otp` 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-input-otp
|
|
64
|
+
controlName="code"
|
|
65
|
+
label="Verification code"
|
|
66
|
+
[length]="6"
|
|
67
|
+
[required]="true"
|
|
68
|
+
error="Enter the 6-digit code."
|
|
69
|
+
/>
|
|
70
|
+
</form>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Selector (from source): `eg-form-input-otp` (standalone component, host `tw:w-full`).
|
|
74
|
+
|
|
75
|
+
## API reference
|
|
76
|
+
|
|
77
|
+
### `EgFormInputOtp` — `eg-form-input-otp`
|
|
78
|
+
|
|
79
|
+
| Input | Type | Default | Description |
|
|
80
|
+
| ------------- | --------------------- | ------- | ------------------------------------------------------------------ |
|
|
81
|
+
| `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.** |
|
|
82
|
+
| `label` | `string \| undefined` | — | Label text (hidden when omitted). |
|
|
83
|
+
| `error` | `string \| undefined` | — | Error text shown when invalid. |
|
|
84
|
+
| `hint` | `string \| undefined` | — | Hint text shown otherwise. |
|
|
85
|
+
| `controlId` | `string \| undefined` | — | Explicit id (first priority for `effectiveId`). |
|
|
86
|
+
| `id` | `string \| undefined` | — | Fallback id (second priority). |
|
|
87
|
+
| `length` | `number` | `6` | Slot count; one `hlm-input-otp-slot` is rendered per unit. |
|
|
88
|
+
| `disabled` | `boolean` | `false` | Locks interaction (form control stays enabled). |
|
|
89
|
+
| `required` | `boolean` | `false` | Shows a red `*` next to the label. |
|
|
90
|
+
| `class` | `ClassValue` | `''` | Extra host classes (base `tw:w-full`). |
|
|
91
|
+
| `labelClass` | `string` | `''` | Extra label classes (base `tw:mb-1`). |
|
|
92
|
+
| `otpClass` | `string` | `''` | Extra OTP container classes. |
|
|
93
|
+
| `errorClass` | `string` | `''` | Extra error classes (base `tw:mt-0`). |
|
|
94
|
+
| `hintClass` | `string` | `''` | Extra hint classes (base `tw:mt-0`). |
|
|
95
|
+
|
|
96
|
+
| Member | Description |
|
|
97
|
+
| -------------------- | -------------------------------------------------------------------------------- |
|
|
98
|
+
| `effectiveId` | `controlId() \|\| id() \|\| generated` — wired to OTP `inputId` and label `for`. |
|
|
99
|
+
| `errorId` / `hintId` | `effectiveId + '-error' / '-hint'`. |
|
|
100
|
+
| `slotIndexes` | `0..length-1` — drives slot rendering. |
|
|
101
|
+
|
|
102
|
+
Requires a `[formGroup]` ancestor (injects `FormGroupDirective`, provides `ControlContainer → FormGroupDirective`).
|
|
103
|
+
|
|
104
|
+
## Examples
|
|
105
|
+
|
|
106
|
+
### 1. Basic verification code
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import { Component, inject } from '@angular/core';
|
|
110
|
+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
111
|
+
import { EgFormInputOtp } from '@egose/shadcn-theme-ng/form-input-otp';
|
|
112
|
+
|
|
113
|
+
@Component({
|
|
114
|
+
selector: 'app-verify',
|
|
115
|
+
standalone: true,
|
|
116
|
+
imports: [ReactiveFormsModule, EgFormInputOtp],
|
|
117
|
+
template: `
|
|
118
|
+
<form [formGroup]="form" (ngSubmit)="submit()">
|
|
119
|
+
<eg-form-input-otp
|
|
120
|
+
controlName="code"
|
|
121
|
+
label="Verification code"
|
|
122
|
+
[length]="6"
|
|
123
|
+
[required]="true"
|
|
124
|
+
error="Enter the 6-digit code."
|
|
125
|
+
/>
|
|
126
|
+
<button type="submit" [disabled]="form.invalid">Verify</button>
|
|
127
|
+
</form>
|
|
128
|
+
`,
|
|
129
|
+
})
|
|
130
|
+
export class VerifyComponent {
|
|
131
|
+
private readonly fb = inject(FormBuilder);
|
|
132
|
+
readonly form = this.fb.group({ code: ['', [Validators.required, Validators.minLength(6)]] });
|
|
133
|
+
submit() {
|
|
134
|
+
console.log(this.form.value.code);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### 2. Short PIN with hint
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import { Component, inject } from '@angular/core';
|
|
143
|
+
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
|
144
|
+
import { EgFormInputOtp } from '@egose/shadcn-theme-ng/form-input-otp';
|
|
145
|
+
|
|
146
|
+
@Component({
|
|
147
|
+
selector: 'app-pin',
|
|
148
|
+
standalone: true,
|
|
149
|
+
imports: [ReactiveFormsModule, EgFormInputOtp],
|
|
150
|
+
template: `
|
|
151
|
+
<form [formGroup]="form">
|
|
152
|
+
<eg-form-input-otp
|
|
153
|
+
controlName="pin"
|
|
154
|
+
label="PIN"
|
|
155
|
+
[length]="4"
|
|
156
|
+
hint="Check your authenticator app."
|
|
157
|
+
error="PIN is required."
|
|
158
|
+
/>
|
|
159
|
+
</form>
|
|
160
|
+
`,
|
|
161
|
+
})
|
|
162
|
+
export class PinComponent {
|
|
163
|
+
private readonly fb = inject(FormBuilder);
|
|
164
|
+
readonly form = this.fb.group({ pin: [''] });
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Accessibility notes
|
|
169
|
+
|
|
170
|
+
- Label `for` ↔ OTP `inputId` wiring is automatic via `effectiveId` — always pass a `label`.
|
|
171
|
+
- `BrnInputOtp` exposes no `aria-describedby`, so error/hint ids render without an input-level link.
|
|
172
|
+
- The required `*` is visual; pair with `Validators.required` (plus `minLength`) so assistive tech and validation agree.
|
|
173
|
+
|
|
174
|
+
## Theming / CSS variables
|
|
175
|
+
|
|
176
|
+
No component-specific CSS variables. Style per-instance via `class` / `labelClass` / `otpClass` / `errorClass` / `hintClass` (precedence: library base < global config < per-instance).
|
|
177
|
+
|
|
178
|
+
Global defaults per styling slot via the wrapper config:
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
import { provideEgFormInputOtpConfig } from '@egose/shadcn-theme-ng/form-input-otp';
|
|
182
|
+
|
|
183
|
+
await bootstrapApplication(App, {
|
|
184
|
+
providers: [provideEgFormInputOtpConfig({ labelClass: 'tw:font-medium' })],
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
The host keeps `tw:w-full`; constrain width with `class` or a wrapping container.
|
|
189
|
+
|
|
190
|
+
## Related subpaths
|
|
191
|
+
|
|
192
|
+
- `@egose/shadcn-theme-ng/input-otp` — raw `brn-input-otp` + slot/group/separator parts for custom layouts.
|
|
193
|
+
- `@egose/shadcn-theme-ng/form-field` — `hlm-form-field` / `hlm-error` / `hlm-hint` used internally.
|
|
194
|
+
- `@egose/shadcn-theme-ng/form-field-simple` — alternative minimal wrapper when you compose controls by hand.
|
|
@@ -0,0 +1,106 @@
|
|
|
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 { HlmFormIdGenerator, HlmFormField, HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
6
|
+
import { HlmLabel } from '@egose/shadcn-theme-ng/label';
|
|
7
|
+
import { BrnInputOtp } from '@spartan-ng/brain/input-otp';
|
|
8
|
+
import * as i2 from '@egose/shadcn-theme-ng/input-otp';
|
|
9
|
+
import { HlmInputOtpImports } from '@egose/shadcn-theme-ng/input-otp';
|
|
10
|
+
import { hlm } from '@egose/shadcn-theme-ng/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
|
+
generatedId = inject(HlmFormIdGenerator).generate('eg-form-input-otp');
|
|
23
|
+
_config = injectEgFormInputOtpConfig();
|
|
24
|
+
label = input(undefined, /* @ts-ignore */
|
|
25
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
26
|
+
controlId = input(undefined, /* @ts-ignore */
|
|
27
|
+
...(ngDevMode ? [{ debugName: "controlId" }] : /* istanbul ignore next */ []));
|
|
28
|
+
controlName = input('', /* @ts-ignore */
|
|
29
|
+
...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
|
|
30
|
+
error = input(undefined, /* @ts-ignore */
|
|
31
|
+
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
32
|
+
hint = input(undefined, /* @ts-ignore */
|
|
33
|
+
...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
34
|
+
id = input(undefined, /* @ts-ignore */
|
|
35
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
36
|
+
length = input(6, { ...(ngDevMode ? { debugName: "length" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
37
|
+
disabled = input(false, /* @ts-ignore */
|
|
38
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
39
|
+
required = input(false, /* @ts-ignore */
|
|
40
|
+
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
41
|
+
effectiveId = computed(() => this.controlId() || this.id() || this.generatedId, /* @ts-ignore */
|
|
42
|
+
...(ngDevMode ? [{ debugName: "effectiveId" }] : /* istanbul ignore next */ []));
|
|
43
|
+
errorId = computed(() => `${this.effectiveId()}-error`, /* @ts-ignore */
|
|
44
|
+
...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
|
|
45
|
+
hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
|
|
46
|
+
...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
|
|
47
|
+
slotIndexes = computed(() => Array.from({ length: this.length() }, (_, i) => i), /* @ts-ignore */
|
|
48
|
+
...(ngDevMode ? [{ debugName: "slotIndexes" }] : /* istanbul ignore next */ []));
|
|
49
|
+
/**
|
|
50
|
+
* Combined lock for the brain `linkedSignal`-based disabled state: the raw
|
|
51
|
+
* input write always carries the resolved value, so a same-pass
|
|
52
|
+
* wrapper-toggle + `control.disable()` cannot clobber CVA state.
|
|
53
|
+
*/
|
|
54
|
+
effectiveDisabled() {
|
|
55
|
+
return this.disabled() || !!this.formGroupDirective.form.get(this.controlName())?.disabled;
|
|
56
|
+
}
|
|
57
|
+
// NOTE: BrnInputOtp exposes inputId but no aria-describedby, so error/hint
|
|
58
|
+
// ids render for sighted users without an input-level describedby link.
|
|
59
|
+
// Styling
|
|
60
|
+
userClass = input('', { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: 'class' });
|
|
61
|
+
labelClass = input('', /* @ts-ignore */
|
|
62
|
+
...(ngDevMode ? [{ debugName: "labelClass" }] : /* istanbul ignore next */ []));
|
|
63
|
+
otpClass = input('', /* @ts-ignore */
|
|
64
|
+
...(ngDevMode ? [{ debugName: "otpClass" }] : /* istanbul ignore next */ []));
|
|
65
|
+
errorClass = input('', /* @ts-ignore */
|
|
66
|
+
...(ngDevMode ? [{ debugName: "errorClass" }] : /* istanbul ignore next */ []));
|
|
67
|
+
hintClass = input('', /* @ts-ignore */
|
|
68
|
+
...(ngDevMode ? [{ debugName: "hintClass" }] : /* istanbul ignore next */ []));
|
|
69
|
+
// Computed classes (library base < global config < per-instance)
|
|
70
|
+
$userClass = computed(() => hlm("w-full", this.userClass()), /* @ts-ignore */
|
|
71
|
+
...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
|
|
72
|
+
$labelClass = computed(() => hlm("mb-1", this._config.labelClass, this.labelClass()), /* @ts-ignore */
|
|
73
|
+
...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
|
|
74
|
+
$otpClass = computed(() => hlm(this._config.otpClass, this.otpClass()), /* @ts-ignore */
|
|
75
|
+
...(ngDevMode ? [{ debugName: "$otpClass" }] : /* istanbul ignore next */ []));
|
|
76
|
+
$errorClass = computed(() => hlm("mt-0", this._config.errorClass, this.errorClass()), /* @ts-ignore */
|
|
77
|
+
...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
|
|
78
|
+
$hintClass = computed(() => hlm("mt-0", this._config.hintClass, this.hintClass()), /* @ts-ignore */
|
|
79
|
+
...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
|
|
80
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormInputOtp, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
81
|
+
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 }, 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: "\n @let lbl = label();\n @let cnm = controlName();\n @let err = error();\n @let hnt = hint();\n @let rqrd = required();\n\n <hlm-form-field>\n @if (lbl) {\n <label hlmLabel [for]=\"effectiveId()\" [class]=\"$labelClass()\"\n >{{ lbl }}\n @if (rqrd) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n <brn-input-otp\n hlmInputOtp\n [length]=\"length()\"\n [formControlName]=\"cnm\"\n [inputId]=\"effectiveId()\"\n [disabled]=\"effectiveDisabled()\"\n [class]=\"$otpClass()\"\n >\n <div hlmInputOtpGroup>\n @for (i of slotIndexes(); track i) {\n <hlm-input-otp-slot [index]=\"i\" />\n }\n </div>\n </brn-input-otp>\n\n @if (err) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{ err }}\n </hlm-error>\n }\n\n @if (hnt) {\n <hlm-hint [id]=\"hintId()\" [class]=\"$hintClass()\">\n {{ hnt }}\n </hlm-hint>\n }\n </hlm-form-field>\n ", isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "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"] }] });
|
|
82
|
+
}
|
|
83
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormInputOtp, decorators: [{
|
|
84
|
+
type: Component,
|
|
85
|
+
args: [{
|
|
86
|
+
selector: 'eg-form-input-otp',
|
|
87
|
+
standalone: true,
|
|
88
|
+
host: {
|
|
89
|
+
'[class]': '$userClass()',
|
|
90
|
+
},
|
|
91
|
+
imports: [ReactiveFormsModule, HlmFormField, HlmError, HlmHint, HlmLabel, BrnInputOtp, HlmInputOtpImports],
|
|
92
|
+
providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
|
|
93
|
+
template: "\n @let lbl = label();\n @let cnm = controlName();\n @let err = error();\n @let hnt = hint();\n @let rqrd = required();\n\n <hlm-form-field>\n @if (lbl) {\n <label hlmLabel [for]=\"effectiveId()\" [class]=\"$labelClass()\"\n >{{ lbl }}\n @if (rqrd) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n }\n\n <brn-input-otp\n hlmInputOtp\n [length]=\"length()\"\n [formControlName]=\"cnm\"\n [inputId]=\"effectiveId()\"\n [disabled]=\"effectiveDisabled()\"\n [class]=\"$otpClass()\"\n >\n <div hlmInputOtpGroup>\n @for (i of slotIndexes(); track i) {\n <hlm-input-otp-slot [index]=\"i\" />\n }\n </div>\n </brn-input-otp>\n\n @if (err) {\n <hlm-error [id]=\"errorId()\" [class]=\"$errorClass()\">\n {{ err }}\n </hlm-error>\n }\n\n @if (hnt) {\n <hlm-hint [id]=\"hintId()\" [class]=\"$hintClass()\">\n {{ hnt }}\n </hlm-hint>\n }\n </hlm-form-field>\n ",
|
|
94
|
+
}]
|
|
95
|
+
}], 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 }] }], 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 }] }] } });
|
|
96
|
+
|
|
97
|
+
/*
|
|
98
|
+
* Public API Surface of form-input-otp
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Generated bundle index. Do not edit.
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
export { EgFormInputOtp, injectEgFormInputOtpConfig, provideEgFormInputOtpConfig };
|
|
106
|
+
|