@egose/shadcn-theme-ng 0.2.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 +1 -1
- package/autocomplete/fesm2022/autocomplete.mjs +1 -1
- 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 +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 +13 -3
- 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 +48 -22
- 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-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 +11 -1
- 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 +10 -0
- 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 +10 -0
- 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 +11 -1
- 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/input-group/fesm2022/input-group.mjs +19 -9
- 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/radio-group/types/radio-group.d.ts +1 -1
- package/switch/fesm2022/switch.mjs +7 -5
- package/switch/types/switch.d.ts +2 -1
- package/typography/types/typography.d.ts +8 -8
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Form Switch (`@egose/shadcn-theme-ng/form-switch`)
|
|
2
|
+
|
|
3
|
+
A ready-made reactive-form boolean field: `hlm-switch` + label + validation error/hint display in one tag. The switch equivalent of `eg-form-checkbox` for on/off settings.
|
|
4
|
+
|
|
5
|
+
The Angular implementation is a standalone wrapper: it renders `EgFormField` from `@egose/shadcn-theme-ng/form-field-simple` (like `eg-form-checkbox`, because `hlm-switch` exposes no `BrnFieldControl`), `HlmError` / `HlmHint`, `HlmLabel`, and `HlmSwitch` from `@egose/shadcn-theme-ng/switch`. The inner switch is bound with `[formControlName]="controlName()"`, so the parent `FormGroup` owns the `boolean` value. It must live inside a `FormGroupDirective` (`[formGroup]` parent); ids come from `HlmFormIdGenerator` unless overridden.
|
|
6
|
+
|
|
7
|
+
> **Ships as:** `@egose/shadcn-theme-ng/form-switch` and `@egose/shadcn-theme-ng-tw/form-switch`
|
|
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/switch`, `@egose/shadcn-theme-ng/form-field`, `@egose/shadcn-theme-ng/form-field-simple`, and
|
|
25
|
+
`@egose/shadcn-theme-ng/label`.
|
|
26
|
+
|
|
27
|
+
## Imports
|
|
28
|
+
|
|
29
|
+
Exported from the subpath root (`projects/form-switch/src/public-api.ts`):
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { EgFormSwitch, provideEgFormSwitchConfig } from '@egose/shadcn-theme-ng/form-switch';
|
|
33
|
+
// tw variant: replace with '@egose/shadcn-theme-ng-tw/form-switch'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Standalone usage:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { Component } from '@angular/core';
|
|
40
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
41
|
+
import { EgFormSwitch } from '@egose/shadcn-theme-ng/form-switch';
|
|
42
|
+
|
|
43
|
+
@Component({
|
|
44
|
+
selector: 'app-demo',
|
|
45
|
+
standalone: true,
|
|
46
|
+
imports: [ReactiveFormsModule, EgFormSwitch],
|
|
47
|
+
template: `...`,
|
|
48
|
+
})
|
|
49
|
+
export class DemoComponent {}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
NgModule-based consumer: add `EgFormSwitch` (and `ReactiveFormsModule`) to the module's
|
|
53
|
+
`imports` — it is a standalone component, not a module.
|
|
54
|
+
|
|
55
|
+
`ControlValueAccessor` behavior: `eg-form-switch` itself is not a `ControlValueAccessor`; the
|
|
56
|
+
inner `hlm-switch` 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-switch controlName="notifications" label="Email notifications" hint="Toggle to subscribe." />
|
|
64
|
+
</form>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Selector (from source): `eg-form-switch` (standalone component, host `tw:w-full`).
|
|
68
|
+
|
|
69
|
+
## API reference
|
|
70
|
+
|
|
71
|
+
### `EgFormSwitch` — `eg-form-switch`
|
|
72
|
+
|
|
73
|
+
| Input | Type | Default | Description |
|
|
74
|
+
| ------------- | --------------------- | ------- | ------------------------------------------------------------------ |
|
|
75
|
+
| `controlName` | `string` | `''` | `formControlName` key inside the parent `FormGroup`. **Required.** |
|
|
76
|
+
| `label` | `string \| undefined` | — | Label text beside the switch (hidden when omitted). |
|
|
77
|
+
| `error` | `string \| undefined` | — | Error text shown when invalid. |
|
|
78
|
+
| `hint` | `string \| undefined` | — | Hint text shown otherwise. |
|
|
79
|
+
| `controlId` | `string \| undefined` | — | Explicit id (first priority for `effectiveId`). |
|
|
80
|
+
| `id` | `string \| undefined` | — | Fallback id (second priority). |
|
|
81
|
+
| `disabled` | `boolean` | `false` | Locks interaction (form control stays enabled). |
|
|
82
|
+
| `required` | `boolean` | `false` | Shows a red `*` next to the label; forwarded to the switch. |
|
|
83
|
+
| `class` | `ClassValue` | `''` | Extra host classes (base `tw:w-full`). |
|
|
84
|
+
| `switchClass` | `string` | `''` | Extra switch classes, merged into `HlmSwitch.userClass`. |
|
|
85
|
+
| `labelClass` | `string` | `''` | Extra label classes. |
|
|
86
|
+
| `errorClass` | `string` | `''` | Extra error classes (base `tw:mt-0`). |
|
|
87
|
+
| `hintClass` | `string` | `''` | Extra hint classes (base `tw:mt-0`). |
|
|
88
|
+
|
|
89
|
+
| Member | Description |
|
|
90
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
91
|
+
| `effectiveId` | `controlId() \|\| id() \|\| generated` — wired to switch `id` and label `for`. |
|
|
92
|
+
| `errorId` / `hintId` | `effectiveId + '-error' / '-hint'`. |
|
|
93
|
+
| `describedBy()` | `errorId` when `error()` is set and control is invalid + dirty/touched, else `hintId` when `hint()` is set, else `null` — wired to switch `aria-describedby`. |
|
|
94
|
+
|
|
95
|
+
Requires a `[formGroup]` ancestor (injects `FormGroupDirective`, provides `ControlContainer → FormGroupDirective`).
|
|
96
|
+
|
|
97
|
+
## Examples
|
|
98
|
+
|
|
99
|
+
### 1. Basic settings toggle
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { Component, inject } from '@angular/core';
|
|
103
|
+
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
|
104
|
+
import { EgFormSwitch } from '@egose/shadcn-theme-ng/form-switch';
|
|
105
|
+
|
|
106
|
+
@Component({
|
|
107
|
+
selector: 'app-settings',
|
|
108
|
+
standalone: true,
|
|
109
|
+
imports: [ReactiveFormsModule, EgFormSwitch],
|
|
110
|
+
template: `
|
|
111
|
+
<form [formGroup]="form">
|
|
112
|
+
<eg-form-switch controlName="notifications" label="Email notifications" hint="Toggle to subscribe." />
|
|
113
|
+
</form>
|
|
114
|
+
`,
|
|
115
|
+
})
|
|
116
|
+
export class SettingsComponent {
|
|
117
|
+
private readonly fb = inject(FormBuilder);
|
|
118
|
+
readonly form = this.fb.group({ notifications: [true] });
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 2. Required opt-in with error
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import { Component, inject } from '@angular/core';
|
|
126
|
+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
127
|
+
import { EgFormSwitch } from '@egose/shadcn-theme-ng/form-switch';
|
|
128
|
+
|
|
129
|
+
@Component({
|
|
130
|
+
selector: 'app-consent',
|
|
131
|
+
standalone: true,
|
|
132
|
+
imports: [ReactiveFormsModule, EgFormSwitch],
|
|
133
|
+
template: `
|
|
134
|
+
<form [formGroup]="form" (ngSubmit)="submit()">
|
|
135
|
+
<eg-form-switch controlName="consent" label="I accept the terms" [required]="true" error="Consent is required." />
|
|
136
|
+
<button type="submit" [disabled]="form.invalid">Continue</button>
|
|
137
|
+
</form>
|
|
138
|
+
`,
|
|
139
|
+
})
|
|
140
|
+
export class ConsentComponent {
|
|
141
|
+
private readonly fb = inject(FormBuilder);
|
|
142
|
+
readonly form = this.fb.group({ consent: [false, Validators.requiredTrue] });
|
|
143
|
+
submit() {
|
|
144
|
+
console.log(this.form.value.consent);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Accessibility notes
|
|
150
|
+
|
|
151
|
+
- Label `for` ↔ switch `id` wiring is automatic via `effectiveId`; the switch also receives `aria-describedby` (error/hint id) — always pass a `label`.
|
|
152
|
+
- The required `*` is visual; pair with `Validators.requiredTrue` so assistive tech and validation agree.
|
|
153
|
+
|
|
154
|
+
## Theming / CSS variables
|
|
155
|
+
|
|
156
|
+
No component-specific CSS variables. Style per-instance via `class` / `switchClass` / `labelClass` / `errorClass` / `hintClass` (precedence: library base < global config < per-instance). The row layout (`flex items-center gap-1`) is fixed in the template.
|
|
157
|
+
|
|
158
|
+
Global defaults per styling slot via the wrapper config:
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
import { provideEgFormSwitchConfig } from '@egose/shadcn-theme-ng/form-switch';
|
|
162
|
+
|
|
163
|
+
await bootstrapApplication(App, {
|
|
164
|
+
providers: [provideEgFormSwitchConfig({ labelClass: 'tw:font-medium' })],
|
|
165
|
+
});
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Related subpaths
|
|
169
|
+
|
|
170
|
+
- `@egose/shadcn-theme-ng/switch` — raw `hlm-switch` for custom layouts.
|
|
171
|
+
- `@egose/shadcn-theme-ng/form-checkbox` — the checkbox counterpart (`eg-form-checkbox`).
|
|
172
|
+
- `@egose/shadcn-theme-ng/form-field` — `hlm-error` / `hlm-hint` used internally.
|
|
173
|
+
- `@egose/shadcn-theme-ng/form-field-simple` — `eg-form-field` used internally.
|
|
@@ -0,0 +1,100 @@
|
|
|
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, HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
6
|
+
import { EgFormField } from '@egose/shadcn-theme-ng/form-field-simple';
|
|
7
|
+
import { HlmLabel } from '@egose/shadcn-theme-ng/label';
|
|
8
|
+
import { HlmSwitch } from '@egose/shadcn-theme-ng/switch';
|
|
9
|
+
import { hlm } from '@egose/shadcn-theme-ng/utils';
|
|
10
|
+
|
|
11
|
+
const EgFormSwitchConfigToken = new InjectionToken('EgFormSwitchConfig');
|
|
12
|
+
function provideEgFormSwitchConfig(config) {
|
|
13
|
+
return { provide: EgFormSwitchConfigToken, useValue: { ...config } };
|
|
14
|
+
}
|
|
15
|
+
function injectEgFormSwitchConfig() {
|
|
16
|
+
return inject(EgFormSwitchConfigToken, { optional: true }) ?? {};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class EgFormSwitch {
|
|
20
|
+
formGroupDirective = inject(FormGroupDirective);
|
|
21
|
+
generatedId = inject(HlmFormIdGenerator).generate('eg-form-switch');
|
|
22
|
+
_config = injectEgFormSwitchConfig();
|
|
23
|
+
label = input(undefined, /* @ts-ignore */
|
|
24
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
25
|
+
controlId = input(undefined, /* @ts-ignore */
|
|
26
|
+
...(ngDevMode ? [{ debugName: "controlId" }] : /* istanbul ignore next */ []));
|
|
27
|
+
controlName = input('', /* @ts-ignore */
|
|
28
|
+
...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
|
|
29
|
+
error = input(undefined, /* @ts-ignore */
|
|
30
|
+
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
31
|
+
hint = input(undefined, /* @ts-ignore */
|
|
32
|
+
...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
33
|
+
id = input(undefined, /* @ts-ignore */
|
|
34
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
35
|
+
disabled = input(false, /* @ts-ignore */
|
|
36
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
37
|
+
required = input(false, /* @ts-ignore */
|
|
38
|
+
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
39
|
+
effectiveId = computed(() => this.controlId() || this.id() || this.generatedId, /* @ts-ignore */
|
|
40
|
+
...(ngDevMode ? [{ debugName: "effectiveId" }] : /* istanbul ignore next */ []));
|
|
41
|
+
errorId = computed(() => `${this.effectiveId()}-error`, /* @ts-ignore */
|
|
42
|
+
...(ngDevMode ? [{ debugName: "errorId" }] : /* istanbul ignore next */ []));
|
|
43
|
+
hintId = computed(() => `${this.effectiveId()}-hint`, /* @ts-ignore */
|
|
44
|
+
...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
|
|
45
|
+
describedBy() {
|
|
46
|
+
const control = this.formGroupDirective.form.get(this.controlName());
|
|
47
|
+
return this.error() && control?.invalid && (control.dirty || control.touched)
|
|
48
|
+
? this.errorId()
|
|
49
|
+
: this.hint()
|
|
50
|
+
? this.hintId()
|
|
51
|
+
: null;
|
|
52
|
+
}
|
|
53
|
+
// Styling
|
|
54
|
+
userClass = input('', { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: 'class' });
|
|
55
|
+
switchClass = input('', /* @ts-ignore */
|
|
56
|
+
...(ngDevMode ? [{ debugName: "switchClass" }] : /* istanbul ignore next */ []));
|
|
57
|
+
labelClass = input('', /* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [{ debugName: "labelClass" }] : /* istanbul ignore next */ []));
|
|
59
|
+
errorClass = input('', /* @ts-ignore */
|
|
60
|
+
...(ngDevMode ? [{ debugName: "errorClass" }] : /* istanbul ignore next */ []));
|
|
61
|
+
hintClass = input('', /* @ts-ignore */
|
|
62
|
+
...(ngDevMode ? [{ debugName: "hintClass" }] : /* istanbul ignore next */ []));
|
|
63
|
+
// Computed classes (library base < global config < per-instance)
|
|
64
|
+
$userClass = computed(() => hlm("w-full", this.userClass()), /* @ts-ignore */
|
|
65
|
+
...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
|
|
66
|
+
$switchClass = computed(() => hlm(this._config.switchClass, this.switchClass()), /* @ts-ignore */
|
|
67
|
+
...(ngDevMode ? [{ debugName: "$switchClass" }] : /* istanbul ignore next */ []));
|
|
68
|
+
$labelClass = computed(() => hlm(this._config.labelClass, this.labelClass()), /* @ts-ignore */
|
|
69
|
+
...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
|
|
70
|
+
$errorClass = computed(() => hlm("mt-0", this._config.errorClass, this.errorClass()), /* @ts-ignore */
|
|
71
|
+
...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
|
|
72
|
+
$hintClass = computed(() => hlm("mt-0", this._config.hintClass, this.hintClass()), /* @ts-ignore */
|
|
73
|
+
...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
|
|
74
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormSwitch, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
75
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormSwitch, isStandalone: true, selector: "eg-form-switch", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", isSignal: true, isRequired: false, transformFunction: null }, controlName: { classPropertyName: "controlName", publicName: "controlName", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, switchClass: { classPropertyName: "switchClass", publicName: "switchClass", isSignal: true, isRequired: false, transformFunction: null }, labelClass: { classPropertyName: "labelClass", publicName: "labelClass", 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 <eg-form-field>\n <div class=\"flex items-center gap-1\">\n <hlm-switch\n [id]=\"effectiveId()\"\n [formControlName]=\"cnm\"\n [required]=\"rqrd\"\n [disabled]=\"disabled()\"\n [aria-describedby]=\"describedBy()\"\n [class]=\"$switchClass()\"\n />\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 </div>\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 </eg-form-field>\n ", isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { 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: HlmSwitch, selector: "hlm-switch", inputs: ["class", "checked", "disabled", "id", "aria-label", "aria-labelledby", "aria-describedby"], outputs: ["checkedChange", "changed"] }, { kind: "component", type: EgFormField, selector: "eg-form-field", inputs: ["class"] }] });
|
|
76
|
+
}
|
|
77
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormSwitch, decorators: [{
|
|
78
|
+
type: Component,
|
|
79
|
+
args: [{
|
|
80
|
+
selector: 'eg-form-switch',
|
|
81
|
+
standalone: true,
|
|
82
|
+
host: {
|
|
83
|
+
'[class]': '$userClass()',
|
|
84
|
+
},
|
|
85
|
+
imports: [ReactiveFormsModule, HlmError, HlmHint, HlmLabel, HlmSwitch, EgFormField],
|
|
86
|
+
providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
|
|
87
|
+
template: "\n @let lbl = label();\n @let cnm = controlName();\n @let err = error();\n @let hnt = hint();\n @let rqrd = required();\n\n <eg-form-field>\n <div class=\"flex items-center gap-1\">\n <hlm-switch\n [id]=\"effectiveId()\"\n [formControlName]=\"cnm\"\n [required]=\"rqrd\"\n [disabled]=\"disabled()\"\n [aria-describedby]=\"describedBy()\"\n [class]=\"$switchClass()\"\n />\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 </div>\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 </eg-form-field>\n ",
|
|
88
|
+
}]
|
|
89
|
+
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], controlId: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlId", required: false }] }], controlName: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlName", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], switchClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "switchClass", required: false }] }], labelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelClass", required: false }] }], errorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorClass", required: false }] }], hintClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintClass", required: false }] }] } });
|
|
90
|
+
|
|
91
|
+
/*
|
|
92
|
+
* Public API Surface of form-switch
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Generated bundle index. Do not edit.
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
export { EgFormSwitch, injectEgFormSwitchConfig, provideEgFormSwitchConfig };
|
|
100
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "form-switch",
|
|
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-switch.mjs",
|
|
13
|
+
"typings": "types/form-switch.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
"./package.json": {
|
|
16
|
+
"default": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./types/form-switch.d.ts",
|
|
20
|
+
"default": "./fesm2022/form-switch.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"type": "module"
|
|
24
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { ValueProvider } from '@angular/core';
|
|
3
|
+
import { ClassValue } from 'clsx';
|
|
4
|
+
|
|
5
|
+
declare class EgFormSwitch {
|
|
6
|
+
private readonly formGroupDirective;
|
|
7
|
+
private readonly generatedId;
|
|
8
|
+
private readonly _config;
|
|
9
|
+
label: _angular_core.InputSignal<string | undefined>;
|
|
10
|
+
controlId: _angular_core.InputSignal<string | undefined>;
|
|
11
|
+
controlName: _angular_core.InputSignal<string>;
|
|
12
|
+
error: _angular_core.InputSignal<string | undefined>;
|
|
13
|
+
hint: _angular_core.InputSignal<string | undefined>;
|
|
14
|
+
id: _angular_core.InputSignal<string | undefined>;
|
|
15
|
+
disabled: _angular_core.InputSignal<boolean>;
|
|
16
|
+
required: _angular_core.InputSignal<boolean>;
|
|
17
|
+
readonly effectiveId: _angular_core.Signal<string>;
|
|
18
|
+
readonly errorId: _angular_core.Signal<string>;
|
|
19
|
+
readonly hintId: _angular_core.Signal<string>;
|
|
20
|
+
describedBy(): string | null;
|
|
21
|
+
userClass: _angular_core.InputSignal<ClassValue>;
|
|
22
|
+
switchClass: _angular_core.InputSignal<string>;
|
|
23
|
+
labelClass: _angular_core.InputSignal<string>;
|
|
24
|
+
errorClass: _angular_core.InputSignal<string>;
|
|
25
|
+
hintClass: _angular_core.InputSignal<string>;
|
|
26
|
+
$userClass: _angular_core.Signal<string>;
|
|
27
|
+
$switchClass: _angular_core.Signal<string>;
|
|
28
|
+
$labelClass: _angular_core.Signal<string>;
|
|
29
|
+
$errorClass: _angular_core.Signal<string>;
|
|
30
|
+
$hintClass: _angular_core.Signal<string>;
|
|
31
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgFormSwitch, never>;
|
|
32
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormSwitch, "eg-form-switch", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "controlId": { "alias": "controlId"; "required": false; "isSignal": true; }; "controlName": { "alias": "controlName"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; "hint": { "alias": "hint"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "switchClass": { "alias": "switchClass"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface EgFormSwitchConfig {
|
|
36
|
+
/**
|
|
37
|
+
* Global class defaults for `eg-form-switch` styling slots.
|
|
38
|
+
* Each is merged under the matching per-instance `*Class` input
|
|
39
|
+
* (library base < global config < per-instance).
|
|
40
|
+
*/
|
|
41
|
+
switchClass?: string;
|
|
42
|
+
labelClass?: string;
|
|
43
|
+
errorClass?: string;
|
|
44
|
+
hintClass?: string;
|
|
45
|
+
}
|
|
46
|
+
declare function provideEgFormSwitchConfig(config: Partial<EgFormSwitchConfig>): ValueProvider;
|
|
47
|
+
declare function injectEgFormSwitchConfig(): EgFormSwitchConfig;
|
|
48
|
+
|
|
49
|
+
export { EgFormSwitch, injectEgFormSwitchConfig, provideEgFormSwitchConfig };
|
|
50
|
+
export type { EgFormSwitchConfig };
|
|
@@ -364,6 +364,16 @@ export class ProfileExample {
|
|
|
364
364
|
|
|
365
365
|
No component-specific CSS variables; the input look comes from the shared theme tokens consumed by `HlmInput`. Adjust density with `inputClass` (e.g. `tw:h-11`), label/error/hint spacing with their `*Class` inputs.
|
|
366
366
|
|
|
367
|
+
Global defaults per styling slot via the wrapper config (precedence: library base < global config < per-instance):
|
|
368
|
+
|
|
369
|
+
```ts
|
|
370
|
+
import { provideEgFormTextInputConfig } from '@egose/shadcn-theme-ng/form-text-input';
|
|
371
|
+
|
|
372
|
+
await bootstrapApplication(App, {
|
|
373
|
+
providers: [provideEgFormTextInputConfig({ inputClass: 'tw:text-sm', labelClass: 'tw:font-medium' })],
|
|
374
|
+
});
|
|
375
|
+
```
|
|
376
|
+
|
|
367
377
|
## Related subpaths
|
|
368
378
|
|
|
369
379
|
- `@egose/shadcn-theme-ng/input` — the raw `HlmInput` directive for non-form or template-driven inputs.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, input, computed, Component } from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, input, computed, Component } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/forms';
|
|
4
4
|
import { FormGroupDirective, ReactiveFormsModule, ControlContainer } from '@angular/forms';
|
|
5
5
|
import { HlmFormIdGenerator, HlmFormField, HlmError, HlmHint } from '@egose/shadcn-theme-ng/form-field';
|
|
@@ -7,9 +7,18 @@ import { HlmLabel } from '@egose/shadcn-theme-ng/label';
|
|
|
7
7
|
import { HlmInput } from '@egose/shadcn-theme-ng/input';
|
|
8
8
|
import { hlm } from '@egose/shadcn-theme-ng/utils';
|
|
9
9
|
|
|
10
|
+
const EgFormTextInputConfigToken = new InjectionToken('EgFormTextInputConfig');
|
|
11
|
+
function provideEgFormTextInputConfig(config) {
|
|
12
|
+
return { provide: EgFormTextInputConfigToken, useValue: { ...config } };
|
|
13
|
+
}
|
|
14
|
+
function injectEgFormTextInputConfig() {
|
|
15
|
+
return inject(EgFormTextInputConfigToken, { optional: true }) ?? {};
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
class EgFormTextInput {
|
|
11
19
|
formGroupDirective = inject(FormGroupDirective);
|
|
12
20
|
generatedId = inject(HlmFormIdGenerator).generate('eg-form-text-input');
|
|
21
|
+
_config = injectEgFormTextInputConfig();
|
|
13
22
|
label = input(undefined, /* @ts-ignore */
|
|
14
23
|
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
15
24
|
controlId = input(undefined, /* @ts-ignore */
|
|
@@ -76,19 +85,19 @@ class EgFormTextInput {
|
|
|
76
85
|
...(ngDevMode ? [{ debugName: "errorClass" }] : /* istanbul ignore next */ []));
|
|
77
86
|
hintClass = input('', /* @ts-ignore */
|
|
78
87
|
...(ngDevMode ? [{ debugName: "hintClass" }] : /* istanbul ignore next */ []));
|
|
79
|
-
// Computed class bindings
|
|
80
|
-
$userClass = computed(() => hlm("
|
|
88
|
+
// Computed class bindings (library base < global config < per-instance)
|
|
89
|
+
$userClass = computed(() => hlm("w-full", this.userClass()), /* @ts-ignore */
|
|
81
90
|
...(ngDevMode ? [{ debugName: "$userClass" }] : /* istanbul ignore next */ []));
|
|
82
|
-
$labelClass = computed(() => hlm("mb-1 gap-0", this.labelClass()), /* @ts-ignore */
|
|
91
|
+
$labelClass = computed(() => hlm("mb-1 gap-0", this._config.labelClass, this.labelClass()), /* @ts-ignore */
|
|
83
92
|
...(ngDevMode ? [{ debugName: "$labelClass" }] : /* istanbul ignore next */ []));
|
|
84
|
-
$inputClass = computed(() => hlm("mb-1", this.inputClass()), /* @ts-ignore */
|
|
93
|
+
$inputClass = computed(() => hlm("mb-1", this._config.inputClass, this.inputClass()), /* @ts-ignore */
|
|
85
94
|
...(ngDevMode ? [{ debugName: "$inputClass" }] : /* istanbul ignore next */ []));
|
|
86
|
-
$errorClass = computed(() => hlm("mt-0", this.errorClass()), /* @ts-ignore */
|
|
95
|
+
$errorClass = computed(() => hlm("mt-0", this._config.errorClass, this.errorClass()), /* @ts-ignore */
|
|
87
96
|
...(ngDevMode ? [{ debugName: "$errorClass" }] : /* istanbul ignore next */ []));
|
|
88
|
-
$hintClass = computed(() => hlm("mt-0", this.hintClass()), /* @ts-ignore */
|
|
97
|
+
$hintClass = computed(() => hlm("mt-0", this._config.hintClass, this.hintClass()), /* @ts-ignore */
|
|
89
98
|
...(ngDevMode ? [{ debugName: "$hintClass" }] : /* istanbul ignore next */ []));
|
|
90
99
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormTextInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
91
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormTextInput, isStandalone: true, selector: "eg-form-text-input", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", isSignal: true, isRequired: false, transformFunction: null }, controlName: { classPropertyName: "controlName", publicName: "controlName", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, maxlength: { classPropertyName: "maxlength", publicName: "maxlength", isSignal: true, isRequired: false, transformFunction: null }, minlength: { classPropertyName: "minlength", publicName: "minlength", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, pattern: { classPropertyName: "pattern", publicName: "pattern", isSignal: true, isRequired: false, transformFunction: null }, autocomplete: { classPropertyName: "autocomplete", publicName: "autocomplete", isSignal: true, isRequired: false, transformFunction: null }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, labelClass: { classPropertyName: "labelClass", publicName: "labelClass", isSignal: true, isRequired: false, transformFunction: null }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", isSignal: true, isRequired: false, transformFunction: null }, errorClass: { classPropertyName: "errorClass", publicName: "errorClass", isSignal: true, isRequired: false, transformFunction: null }, hintClass: { classPropertyName: "hintClass", publicName: "hintClass", isSignal: true, isRequired: false, transformFunction: null } }, host: {
|
|
100
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EgFormTextInput, isStandalone: true, selector: "eg-form-text-input", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", isSignal: true, isRequired: false, transformFunction: null }, controlName: { classPropertyName: "controlName", publicName: "controlName", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, maxlength: { classPropertyName: "maxlength", publicName: "maxlength", isSignal: true, isRequired: false, transformFunction: null }, minlength: { classPropertyName: "minlength", publicName: "minlength", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, pattern: { classPropertyName: "pattern", publicName: "pattern", isSignal: true, isRequired: false, transformFunction: null }, autocomplete: { classPropertyName: "autocomplete", publicName: "autocomplete", isSignal: true, isRequired: false, transformFunction: null }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, labelClass: { classPropertyName: "labelClass", publicName: "labelClass", isSignal: true, isRequired: false, transformFunction: null }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", isSignal: true, isRequired: false, transformFunction: null }, errorClass: { classPropertyName: "errorClass", publicName: "errorClass", isSignal: true, isRequired: false, transformFunction: null }, hintClass: { classPropertyName: "hintClass", publicName: "hintClass", isSignal: true, isRequired: false, transformFunction: null } }, host: { 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 <input\n hlmInput\n [attr.aria-label]=\"lbl\"\n [id]=\"effectiveId()\"\n [name]=\"cnm || name()\"\n [formControlName]=\"cnm\"\n [class]=\"$inputClass()\"\n [type]=\"type()\"\n [placeholder]=\"placeholder()\"\n [readonly]=\"readonly()\"\n [attr.disabled]=\"effectiveDisabled() ? '' : null\"\n [ariaDescribedby]=\"describedBy()\"\n [max]=\"max()\"\n [min]=\"min()\"\n [maxlength]=\"maxlength()\"\n [minlength]=\"minlength()\"\n [pattern]=\"pattern()\"\n [autocomplete]=\"autocomplete()\"\n [autofocus]=\"autofocus()\"\n [required]=\"rqrd\"\n />\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.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.MinLengthValidator, selector: "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", inputs: ["minlength"] }, { kind: "directive", type: i1.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i1.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { 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: "directive", type: HlmInput, selector: "[hlmInput]", inputs: ["ariaDescribedby"] }] });
|
|
92
101
|
}
|
|
93
102
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgFormTextInput, decorators: [{
|
|
94
103
|
type: Component,
|
|
@@ -96,7 +105,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
96
105
|
selector: 'eg-form-text-input',
|
|
97
106
|
standalone: true,
|
|
98
107
|
host: {
|
|
99
|
-
class:
|
|
108
|
+
'[class]': '$userClass()',
|
|
100
109
|
},
|
|
101
110
|
imports: [ReactiveFormsModule, HlmFormField, HlmError, HlmHint, HlmLabel, HlmInput],
|
|
102
111
|
providers: [{ provide: ControlContainer, useExisting: FormGroupDirective }],
|
|
@@ -112,5 +121,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
112
121
|
* Generated bundle index. Do not edit.
|
|
113
122
|
*/
|
|
114
123
|
|
|
115
|
-
export { EgFormTextInput };
|
|
124
|
+
export { EgFormTextInput, injectEgFormTextInputConfig, provideEgFormTextInputConfig };
|
|
116
125
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { ValueProvider } from '@angular/core';
|
|
2
3
|
import { ClassValue } from 'clsx';
|
|
3
4
|
|
|
4
5
|
declare class EgFormTextInput {
|
|
5
6
|
private readonly formGroupDirective;
|
|
6
7
|
private readonly generatedId;
|
|
8
|
+
private readonly _config;
|
|
7
9
|
label: _angular_core.InputSignal<string | undefined>;
|
|
8
10
|
controlId: _angular_core.InputSignal<string | undefined>;
|
|
9
11
|
controlName: _angular_core.InputSignal<string>;
|
|
@@ -42,4 +44,19 @@ declare class EgFormTextInput {
|
|
|
42
44
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<EgFormTextInput, "eg-form-text-input", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "controlId": { "alias": "controlId"; "required": false; "isSignal": true; }; "controlName": { "alias": "controlName"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; "hint": { "alias": "hint"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "type": { "alias": "type"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "maxlength": { "alias": "maxlength"; "required": false; "isSignal": true; }; "minlength": { "alias": "minlength"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "pattern": { "alias": "pattern"; "required": false; "isSignal": true; }; "autocomplete": { "alias": "autocomplete"; "required": false; "isSignal": true; }; "autofocus": { "alias": "autofocus"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "labelClass": { "alias": "labelClass"; "required": false; "isSignal": true; }; "inputClass": { "alias": "inputClass"; "required": false; "isSignal": true; }; "errorClass": { "alias": "errorClass"; "required": false; "isSignal": true; }; "hintClass": { "alias": "hintClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
interface EgFormTextInputConfig {
|
|
48
|
+
/**
|
|
49
|
+
* Global class defaults for `eg-form-text-input` styling slots.
|
|
50
|
+
* Each is merged under the matching per-instance `*Class` input
|
|
51
|
+
* (library base < global config < per-instance).
|
|
52
|
+
*/
|
|
53
|
+
labelClass?: string;
|
|
54
|
+
inputClass?: string;
|
|
55
|
+
errorClass?: string;
|
|
56
|
+
hintClass?: string;
|
|
57
|
+
}
|
|
58
|
+
declare function provideEgFormTextInputConfig(config: Partial<EgFormTextInputConfig>): ValueProvider;
|
|
59
|
+
declare function injectEgFormTextInputConfig(): EgFormTextInputConfig;
|
|
60
|
+
|
|
61
|
+
export { EgFormTextInput, injectEgFormTextInputConfig, provideEgFormTextInputConfig };
|
|
62
|
+
export type { EgFormTextInputConfig };
|
package/form-textarea/README.md
CHANGED
|
@@ -92,7 +92,7 @@ Real selectors: `eg-form-textarea`, `hlm-form-field`, `label[hlmLabel]`, `textar
|
|
|
92
92
|
| `required` | `boolean` | `false` | Native `required` + red `*` on the label. |
|
|
93
93
|
| `rows` | `string \| number \| undefined` | `3` | Native `rows` (visible height). |
|
|
94
94
|
| `cols` | `string \| number \| undefined` | `undefined` | Native `cols` (visible width). |
|
|
95
|
-
| `class` (`userClass`) | `ClassValue` | `''` | Extra host classes (merged over `tw:
|
|
95
|
+
| `class` (`userClass`) | `ClassValue` | `''` | Extra host classes (merged over `tw:w-full`). |
|
|
96
96
|
| `labelClass` | `string` | `''` | Extra label classes (merged over `tw:mb-1 tw:gap-0`). |
|
|
97
97
|
| `textareaClass` | `string` | `''` | Extra textarea classes (merged over `tw:mb-1`). |
|
|
98
98
|
| `errorClass` | `string` | `''` | Extra error classes (merged over `tw:mt-0`). |
|
|
@@ -340,6 +340,16 @@ export class ProgrammaticExample {
|
|
|
340
340
|
|
|
341
341
|
No component-specific CSS variables; visuals come from the shared theme tokens via the `hlmInput` class hook. Control height with `rows` and `textareaClass` (`tw:min-h-*`, `tw:resize-y` / `tw:resize-none`).
|
|
342
342
|
|
|
343
|
+
Global defaults per styling slot via the wrapper config (precedence: library base < global config < per-instance):
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
import { provideEgFormTextareaConfig } from '@egose/shadcn-theme-ng/form-textarea';
|
|
347
|
+
|
|
348
|
+
await bootstrapApplication(App, {
|
|
349
|
+
providers: [provideEgFormTextareaConfig({ textareaClass: 'tw:text-sm', labelClass: 'tw:font-medium' })],
|
|
350
|
+
});
|
|
351
|
+
```
|
|
352
|
+
|
|
343
353
|
## Related subpaths
|
|
344
354
|
|
|
345
355
|
- `@egose/shadcn-theme-ng/form-text-input` — the single-line sibling.
|