@egose/shadcn-theme-ng-tw 0.1.0 → 0.2.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.
Files changed (86) hide show
  1. package/README.md +1 -1
  2. package/accordion/README.md +405 -2
  3. package/alert/README.md +372 -2
  4. package/alert-dialog/README.md +471 -5
  5. package/aspect-ratio/README.md +272 -5
  6. package/autocomplete/README.md +502 -2
  7. package/avatar/README.md +357 -5
  8. package/badge/README.md +318 -2
  9. package/basic-alert/README.md +353 -2
  10. package/breadcrumb/README.md +406 -5
  11. package/button/README.md +482 -2
  12. package/button/fesm2022/button.mjs +85 -107
  13. package/button/types/button.d.ts +5 -8
  14. package/button-group/README.md +318 -5
  15. package/button-group/fesm2022/button-group.mjs +1 -1
  16. package/calendar/README.md +357 -2
  17. package/card/README.md +331 -5
  18. package/carousel/README.md +333 -5
  19. package/carousel/fesm2022/carousel.mjs +4 -1
  20. package/checkbox/README.md +320 -2
  21. package/collapsible/README.md +332 -5
  22. package/combobox/README.md +507 -5
  23. package/combobox/fesm2022/combobox.mjs +4 -1
  24. package/command/README.md +435 -5
  25. package/confirmation-dialog/README.md +301 -2
  26. package/context-menu/README.md +366 -5
  27. package/date-picker/README.md +465 -2
  28. package/date-picker/fesm2022/date-picker.mjs +2 -2
  29. package/dialog/README.md +448 -2
  30. package/drawer/README.md +395 -5
  31. package/dropdown-menu/README.md +417 -5
  32. package/empty/README.md +329 -5
  33. package/field/README.md +385 -5
  34. package/form-checkbox/README.md +312 -2
  35. package/form-date-picker/README.md +322 -2
  36. package/form-field/README.md +356 -2
  37. package/form-field-simple/README.md +340 -2
  38. package/form-searchable-multiselect/README.md +361 -2
  39. package/form-select/README.md +350 -2
  40. package/form-text-input/README.md +371 -2
  41. package/form-textarea/README.md +347 -2
  42. package/hover-card/README.md +256 -5
  43. package/icon/README.md +239 -2
  44. package/input/README.md +269 -2
  45. package/input-group/README.md +335 -5
  46. package/input-group/fesm2022/input-group.mjs +3 -3
  47. package/input-otp/README.md +375 -5
  48. package/item/README.md +385 -5
  49. package/item/fesm2022/item.mjs +3 -3
  50. package/kbd/README.md +291 -5
  51. package/label/README.md +272 -2
  52. package/layout-simple/README.md +193 -2
  53. package/layout-simple/fesm2022/layout-simple.mjs +877 -409
  54. package/layout-simple/types/layout-simple.d.ts +174 -137
  55. package/menu/README.md +417 -2
  56. package/menubar/README.md +343 -5
  57. package/native-select/README.md +323 -5
  58. package/navigation-menu/README.md +369 -5
  59. package/package.json +1 -1
  60. package/pagination/README.md +388 -5
  61. package/popover/README.md +331 -2
  62. package/progress/README.md +311 -5
  63. package/radio-group/README.md +364 -2
  64. package/radio-group/fesm2022/radio-group.mjs +5 -1
  65. package/resizable/README.md +269 -5
  66. package/scroll-area/README.md +233 -5
  67. package/searchable-multiselect/README.md +323 -2
  68. package/select/README.md +437 -2
  69. package/separator/README.md +222 -2
  70. package/sheet/README.md +311 -2
  71. package/sidebar/README.md +457 -5
  72. package/skeleton/README.md +217 -5
  73. package/slider/README.md +273 -5
  74. package/slider/fesm2022/slider.mjs +17 -13
  75. package/sonner/README.md +346 -2
  76. package/spinner/README.md +284 -2
  77. package/switch/README.md +310 -2
  78. package/table/README.md +423 -5
  79. package/tabs/README.md +411 -2
  80. package/tabs/fesm2022/tabs.mjs +12 -2
  81. package/textarea/README.md +282 -5
  82. package/toggle/README.md +270 -5
  83. package/toggle-group/README.md +340 -5
  84. package/tooltip/README.md +269 -2
  85. package/typography/README.md +271 -5
  86. package/utils/README.md +303 -2
@@ -1,3 +1,341 @@
1
- # Form Field Simple Subpath
1
+ # Form Field Simple (`@egose/shadcn-theme-ng/form-field-simple`)
2
2
 
3
- This project ships only as `@egose/shadcn-theme-ng/form-field-simple` or `@egose/shadcn-theme-ng-tw/form-field-simple`. See the [package README](../../README.md) for installation, compatibility, Tailwind variant, test, and release guidance. Do not publish this project directory independently.
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.