@dashforge/tw 0.2.1-beta → 0.3.0-beta

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 (33) hide show
  1. package/CHANGELOG.md +134 -0
  2. package/CONSUMER-VALIDATION.md +130 -0
  3. package/dist/index.esm.js +309 -41
  4. package/dist/src/components/AppShell/AppShell.d.ts +14 -0
  5. package/dist/src/components/AppShell/AppShell.d.ts.map +1 -1
  6. package/dist/src/components/AppShell/appShell.variants.d.ts.map +1 -1
  7. package/dist/src/components/Autocomplete/Autocomplete.d.ts.map +1 -1
  8. package/dist/src/components/Autocomplete/autocomplete.variants.d.ts.map +1 -1
  9. package/dist/src/components/Breadcrumbs/breadcrumbs.variants.d.ts.map +1 -1
  10. package/dist/src/components/Checkbox/Checkbox.d.ts.map +1 -1
  11. package/dist/src/components/LeftNav/leftNav.variants.d.ts.map +1 -1
  12. package/dist/src/components/Snackbar/snackbar.variants.d.ts.map +1 -1
  13. package/dist/src/components/Switch/switch.variants.d.ts.map +1 -1
  14. package/dist/src/components/TextField/TextField.d.ts.map +1 -1
  15. package/dist/src/components/TextField/textField.types.d.ts +29 -3
  16. package/dist/src/components/TextField/textField.types.d.ts.map +1 -1
  17. package/dist/src/components/TextField/textField.variants.d.ts +6 -0
  18. package/dist/src/components/TextField/textField.variants.d.ts.map +1 -1
  19. package/dist/src/index.d.ts +1 -1
  20. package/package.json +3 -3
  21. package/src/components/AppShell/AppShell.tsx +126 -1
  22. package/src/components/AppShell/appShell.variants.ts +8 -2
  23. package/src/components/Autocomplete/Autocomplete.tsx +77 -4
  24. package/src/components/Autocomplete/autocomplete.variants.ts +6 -0
  25. package/src/components/Breadcrumbs/breadcrumbs.variants.ts +5 -0
  26. package/src/components/Checkbox/Checkbox.tsx +43 -9
  27. package/src/components/LeftNav/leftNav.variants.ts +12 -1
  28. package/src/components/Snackbar/snackbar.variants.ts +4 -2
  29. package/src/components/Switch/switch.variants.ts +6 -1
  30. package/src/components/TextField/TextField.tsx +29 -0
  31. package/src/components/TextField/textField.types.ts +23 -3
  32. package/src/components/TextField/textField.variants.ts +18 -0
  33. package/src/index.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -12,6 +12,140 @@ This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
12
12
  > duplicated intentionally — no shared "lowest common denominator" headless
13
13
  > layer.
14
14
 
15
+ ## [0.3.0-beta] — 2026-05-18
16
+
17
+ **Sprint 2 release.** Bundle of 9 fixes across 7 components + 1 new
18
+ public API (TextField inline adornments). Two WCAG enhancements
19
+ close known a11y gaps from the 0.2.1 A11Y audit. End-to-end
20
+ consumer validation in the `dash` app (`/test-{foundation,tw,layout,
21
+ providers}`) caught 1 functional bug + 1 cosmetic gap on Autocomplete
22
+ that were both invisible to unit tests + docs lab.
23
+
24
+ **Minor bump because of TextField `slotProps.prefix/suffix`** — new
25
+ public API on the existing `slotProps` surface, strictly additive
26
+ (empty configs add zero layout cost; existing TextField usages keep
27
+ working byte-identical). All other changes are patches that would
28
+ have shipped as `0.2.2-beta` in isolation.
29
+
30
+ ### Added
31
+
32
+ - **TextField inline adornments via `slotProps.prefix` + `slotProps.suffix`** —
33
+ closes a long-standing doc/lib drift where the
34
+ `text-field.mdx` already documented this API but the lib didn't
35
+ expose it. New shape:
36
+ ```tsx
37
+ <TextField
38
+ name="price"
39
+ type="number"
40
+ slotProps={{
41
+ prefix: { children: '$' },
42
+ suffix: { children: 'USD' },
43
+ }}
44
+ />
45
+ ```
46
+ Both slots accept `{ children?: ReactNode; className?: string }`.
47
+ Rendered inside the inputWrapper with `aria-hidden="true"` +
48
+ `pointer-events-none` (purely visual decoration — input remains
49
+ the labeled control, click on adornment doesn't steal focus).
50
+ 21/21 TextField tests still pass.
51
+
52
+ - **AppShell mobile drawer focus trap** (WCAG 2.4.3 Focus Order).
53
+ Hand-rolled (no `focus-trap-react` dep). On drawer open: captures
54
+ `document.activeElement`, moves focus to first focusable inside
55
+ drawer, intercepts `Tab` / `Shift+Tab` to wrap focus within the
56
+ drawer subtree. On close: restores focus to the captured element
57
+ (typically the hamburger toggle). Plus `role="dialog"` +
58
+ `aria-modal="true"` on the drawer `<aside>` while open so screen
59
+ readers announce it as a modal overlay. Verified end-to-end in
60
+ dash: all 5 check points (closed ARIA, open ARIA, focus in,
61
+ tab-wrap, Esc-close) pass.
62
+
63
+ - **`prefers-reduced-motion` gates** on six substantial motions
64
+ (WCAG 2.3.3 Animation from Interactions): Switch thumb slide,
65
+ AppShell drawer slide-in + backdrop fade, Snackbar item enter,
66
+ Autocomplete chevron flip, LeftNav rail-mode width transition.
67
+ Uses Tailwind's `motion-reduce:` variant — the animated end-state
68
+ still applies, only the smooth tween is suppressed for users who
69
+ request reduced motion. Color fades (`transition-colors` on hover
70
+ states) are NOT gated — out of WCAG 2.3.3 scope (vestibular
71
+ concern is translate/rotate/major-state-change, not micro fades).
72
+
73
+ - **Checkbox indeterminate dash glyph**. Previously the Indicator
74
+ rendered `<CheckIcon />` for BOTH the `checked` and `indeterminate`
75
+ Radix states. Now renders `<DashIcon />` (horizontal stroke) for
76
+ indeterminate and `<CheckIcon />` for fully checked. Toggle via
77
+ Tailwind `group-data-[state=…]:hidden` selectors on the Indicator
78
+ — pure CSS, zero React state, Radix `data-state` remains the
79
+ single source of truth. Closes a cosmetic regression introduced
80
+ in 0.2.1-beta when we dropped `forceMount` to fix the indicator
81
+ mount bug.
82
+
83
+ ### Fixed
84
+
85
+ - **Autocomplete `loadOptions` mode — selection now commits** the
86
+ clicked option's label to the input. Previously, in async-loaded
87
+ mode, clicking an option closed the popover but the input kept
88
+ showing the user's search query instead of the selected label.
89
+ Root cause: `commitSelection` searched only the static `options`
90
+ prop (empty `[]` when `loadOptions` is configured) for the label
91
+ lookup, not the effective pool (`asyncOptions` when the fetch
92
+ resolved). The fix uses
93
+ `loadOptions && asyncOptions !== null ? asyncOptions : options`
94
+ and adds those refs to the `useCallback` deps. 38/40 Autocomplete
95
+ tests pass (2 perf-timing flakes unrelated, both >100ms over
96
+ threshold on loaded machine).
97
+
98
+ - **Autocomplete chip remove (×), clear (×), and dropdown caret (▾)
99
+ icons replaced with inline SVG** (`CloseIcon` + `ChevronDownIcon`,
100
+ mirroring CheckIcon's pattern). Previously rendered as Unicode
101
+ glyphs that came out as chunky font characters inconsistent with
102
+ the rest of the design system. Bonus: chevron flips 180° on
103
+ popover open via `[&[aria-expanded=true]>svg]:rotate-180` (CSS-
104
+ only, no React state). Zero icon-library dep added.
105
+
106
+ - **LeftNav `itemLink` + Breadcrumbs `link` slots no longer
107
+ underline by default**. Tailwind's preflight removes the browser-
108
+ default anchor underline globally, but environments that disable
109
+ preflight (e.g. apps coexisting with MUI in the same page tree —
110
+ this is exactly how our docs lab is set up) get the underline
111
+ back. Explicit `no-underline hover:no-underline` on both slots
112
+ makes the appearance consistent regardless of preflight state.
113
+ Same root cause fix covers TopBar too — TopBar typically renders
114
+ Breadcrumbs in its center slot, so fixing the Breadcrumbs link
115
+ fixes TopBar transitively.
116
+
117
+ ### Internal
118
+
119
+ - **`libs/dashforge/tw/CONSUMER-VALIDATION.md`** — Sprint 2 P1
120
+ deliverable. Per-component status table for the dash-consumer
121
+ end-to-end validation pass (24 components, 7-point check each).
122
+ Records the pattern lesson that motivated the Autocomplete
123
+ async fix: the bug was invisible to both unit tests (using
124
+ static `options`) and the docs lab (static demo) — only a real
125
+ consumer with `loadOptions` configured exposed it.
126
+
127
+ ### Compatibility
128
+
129
+ | Compatibility axis | Pre-`0.3.0` | Post-`0.3.0` |
130
+ |---|---|---|
131
+ | Public API surface | unchanged | **+ TextField `slotProps.prefix` / `slotProps.suffix`** (additive — opt-in via slotProps, zero impact on existing usages) |
132
+ | Peer deps | `react ^18 \|\| ^19`, `tw-theme workspace`, `tw-tokens workspace` | unchanged |
133
+ | Bridge deps | `forms` / `rbac` / `ui-core` `workspace:*` | unchanged |
134
+ | Behavior changes that consumers might observe | — | Autocomplete chip remove + clear + caret render as crisp SVG instead of Unicode glyphs (cosmetic); LeftNav + Breadcrumbs links no longer underline in preflight-off environments; Switch / drawer / snackbar / chevron animations respect `prefers-reduced-motion: reduce`; Checkbox indeterminate now shows a dash glyph instead of check |
135
+
136
+ ### Migration
137
+
138
+ No code changes required. Drop-in upgrade from `0.2.1-beta`:
139
+
140
+ ```bash
141
+ pnpm up @dashforge/tw@^0.3.0-beta
142
+ ```
143
+
144
+ To adopt the new TextField adornments, no migration — opt in by
145
+ adding `slotProps={{ prefix: { children: '$' } }}` to any existing
146
+ TextField usage. The two slots are independent (you can use one
147
+ without the other).
148
+
15
149
  ## [0.2.1-beta] — 2026-05-17
16
150
 
17
151
  **Hardening release.** Four targeted fixes — three in form-control
@@ -0,0 +1,130 @@
1
+ # Consumer Validation — `@dashforge/tw`
2
+
3
+ > Sprint 2 P1 deliverable. Validation di tutti i 24 componenti shippati
4
+ > in `@dashforge/tw 0.2.1-beta` su un app consumer reale
5
+ > (`~/projects/web/learn/dash`). Esegue il check 7-point per ogni
6
+ > componente, documenta gap residui.
7
+
8
+ **Stato sessione**: 17 maggio 2026 — Sprint 2 in corso.
9
+ **Dist sotto test**: `@dashforge/tw@0.2.1-beta`
10
+ (file:-linked dal monorepo, dist mtime fresh).
11
+
12
+ ## Test pages
13
+
14
+ | URL | Componenti coperti | Note |
15
+ |---|---|---|
16
+ | `/test-foundation` | Typography, Box, Stack, Grid, Container, Divider, AspectRatio, VisuallyHidden | Foundation 8/8 |
17
+ | `/test-tw` | Button, TextField, Checkbox, Switch, RadioGroup, Textarea, NumberField, OTPField, Autocomplete, DateTimePicker | Tier-1 + Tier-2 form controls 10/10. Wrappati in `<DashForm>` con rules + defaultValues realistici |
18
+ | `/test-layout` | AppShell, TopBar, LeftNav, Breadcrumbs | Nav/Layout 4/4. Drawer mobile + collapse toggle + theme switch in chrome |
19
+ | `/test-providers` | ConfirmDialog, Snackbar | Provider patterns 2/2. Severità, action button, dedup, sticky tutti coperti |
20
+
21
+ ## Check 7-point
22
+
23
+ Per ogni componente, marca: ✅ OK / ⚠️ minor / ❌ blocker / ➖ N/A
24
+
25
+ 1. **Render** — niente layout broken, niente console error, niente warning sospetti
26
+ 2. **Interactions** — click / type / toggle / select funzionano end-to-end
27
+ 3. **Theme** — dark/light flip via `toggleMode()` aggiorna il componente in lockstep
28
+ 4. **RHF** — se form-mode, `<DashForm>` registra il field e il valore va in `onSubmit`
29
+ 5. **RBAC** — se applicabile, `access` con `denied:hide/disable/readonly` rispetta la doc *(gap: TestRbac su dash usa MUI side, no test tw RBAC esplicito — testato indirettamente via Sprint 1 lib tests)*
30
+ 6. **Focus** — focus-visible ring appare con Tab, scompare con click
31
+ 7. **Keyboard** — Enter/Space/Arrow funzionano (RadioGroup option nav, Autocomplete listbox, etc.)
32
+
33
+ ## Foundation (8/8)
34
+
35
+ | Componente | Render | Interactions | Theme | RHF | RBAC | Focus | Keyboard | Note |
36
+ |---|:-:|:-:|:-:|:-:|:-:|:-:|:-:|---|
37
+ | Typography | ⏳ | ➖ | ⏳ | ➖ | ➖ | ➖ | ➖ | |
38
+ | Box | ⏳ | ➖ | ⏳ | ➖ | ➖ | ➖ | ➖ | |
39
+ | Stack | ⏳ | ➖ | ⏳ | ➖ | ➖ | ➖ | ➖ | |
40
+ | Grid | ⏳ | ➖ | ⏳ | ➖ | ➖ | ➖ | ➖ | |
41
+ | Container | ⏳ | ➖ | ⏳ | ➖ | ➖ | ➖ | ➖ | |
42
+ | Divider | ⏳ | ➖ | ⏳ | ➖ | ➖ | ➖ | ➖ | |
43
+ | AspectRatio | ⏳ | ➖ | ⏳ | ➖ | ➖ | ➖ | ➖ | |
44
+ | VisuallyHidden | ⏳ | ➖ | ➖ | ➖ | ➖ | ➖ | ➖ | A11y primitive — verifica solo a livello AT |
45
+
46
+ ## Tier-1 form controls (4/4)
47
+
48
+ | Componente | Render | Interactions | Theme | RHF | RBAC | Focus | Keyboard | Note |
49
+ |---|:-:|:-:|:-:|:-:|:-:|:-:|:-:|---|
50
+ | Button | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | Verifica anche `loading` (aria-busy fix Sprint 1 P7) |
51
+ | TextField | ⏳ | ⏳ | ⏳ | ⏳ | ➖ | ⏳ | ⏳ | `required` + `pattern` rules attivati in TestTw |
52
+ | Checkbox | ⏳ | ⏳ | ⏳ | ⏳ | ➖ | ⏳ | ⏳ | **Critical**: verifica fix Sprint 1 commit `081f6f0` (indicator mounts dopo click standalone) |
53
+ | Switch | ⏳ | ⏳ | ⏳ | ⏳ | ➖ | ⏳ | ⏳ | Thumb animation (richiede `--tw-translate-y` init nel preflight — verificato in docs-lab ma dash potrebbe avere setup diverso) |
54
+
55
+ ## Tier-2 / 3 form controls (6/6)
56
+
57
+ | Componente | Render | Interactions | Theme | RHF | RBAC | Focus | Keyboard | Note |
58
+ |---|:-:|:-:|:-:|:-:|:-:|:-:|:-:|---|
59
+ | RadioGroup | ⏳ | ⏳ | ⏳ | ⏳ | ➖ | ⏳ | ⏳ | **Critical**: verifica fix Sprint 1 commit `eb5a1c6` (click cambia selezione standalone) |
60
+ | Textarea | ⏳ | ⏳ | ⏳ | ⏳ | ➖ | ⏳ | ➖ | `rows={3}` + `resize=vertical` default |
61
+ | NumberField | ⏳ | ⏳ | ⏳ | ⏳ | ➖ | ⏳ | ⏳ | **Critical**: verifica fix Sprint 1 commit `12e6b67` (input + stepper persistono standalone). Stepper aria-hidden by design. |
62
+ | OTPField | ⏳ | ⏳ | ⏳ | ⏳ | ➖ | ⏳ | ⏳ | Paste behavior, length=6 numeric in TestTw |
63
+ | Autocomplete | ⏳ | ⏳ | ⏳ | ⏳ | ➖ | ⏳ | ⏳ | **Pre-flagged P2**: dropdown icon va a capo su multi-select, preview shell troppo piccola — questo è issue del docs-lab. Verifica se in dash si vede correttamente. |
64
+ | DateTimePicker | ⏳ | ⏳ | ⏳ | ⏳ | ➖ | ⏳ | ⏳ | Native HTML5 inputs, modes date/time/datetime |
65
+
66
+ ## Nav / Layout (4/4)
67
+
68
+ | Componente | Render | Interactions | Theme | RHF | RBAC | Focus | Keyboard | Note |
69
+ |---|:-:|:-:|:-:|:-:|:-:|:-:|:-:|---|
70
+ | AppShell | ⏳ | ⏳ | ⏳ | ➖ | ➖ | ⏳ | ⏳ | Drawer mobile + Escape close + body scroll lock |
71
+ | TopBar | ⏳ | ⏳ | ⏳ | ➖ | ➖ | ⏳ | ➖ | **Pre-flagged P2**: rimuovi underline dai link interni |
72
+ | LeftNav | ⏳ | ⏳ | ⏳ | ➖ | ➖ | ⏳ | ⏳ | **Pre-flagged P2**: rimuovi underline dai link. Verifica groups expand/collapse + rail mode |
73
+ | Breadcrumbs | ⏳ | ⏳ | ⏳ | ➖ | ➖ | ⏳ | ➖ | Trail dinamico in TestLayout (cambia con sidebar pick) |
74
+
75
+ ## Overlays / Providers (2/2)
76
+
77
+ | Componente | Render | Interactions | Theme | RHF | RBAC | Focus | Keyboard | Note |
78
+ |---|:-:|:-:|:-:|:-:|:-:|:-:|:-:|---|
79
+ | ConfirmDialog | ⏳ | ⏳ | ⏳ | ➖ | ➖ | ⏳ | ⏳ | Severità info/warning/danger/success, Escape close, focus trap (Radix-backed) |
80
+ | Snackbar | ⏳ | ⏳ | ⏳ | ➖ | ➖ | ⏳ | ➖ | `aria-live="polite"`. Verifica position bottom-right + autoHideMs 0 (sticky) + action button + dedup by id |
81
+
82
+ ## Issue residui scoperti durante validation
83
+
84
+ > Sezione aggiornata in real-time durante il walkthrough. Ogni issue
85
+ > trovato qui diventa P2-P5 candidate per Sprint 2 (o backlog per
86
+ > Sprint 3+ se non blocking).
87
+
88
+ ### Issue scoperti durante walkthrough 17 maggio (fixati in P1)
89
+
90
+ 1. **🐛 Autocomplete async loader — option click NON committa la selezione**
91
+ (gravità: alta — bug funzionale visibile a tutti gli utenti con `loadOptions`)
92
+ - **Sintomo**: utente type nella combobox async-loaded, results appaiono, click su un option → popover si chiude ma input rimane sulla query di ricerca, label dell'option selezionata NON viene scritto.
93
+ - **Root cause**: `commitSelection` (`Autocomplete.tsx` line 405) cercava il label dentro la prop statica `options` (per il caso async è `[]`) invece che dentro l'effective pool (`asyncOptions` quando `loadOptions` è configured).
94
+ - **Fix**: lookup nel pool effettivo (`loadOptions && asyncOptions !== null ? asyncOptions : options`) + aggiunto `asyncOptions`/`loadOptions` ai deps del `useCallback`.
95
+ - **Repro / verify**: nel dash su `/test-tw`, scroll al "User search (async loader)", type "a" → wait 500ms → results "Alice Cooper / Walker / ...". Click "Alice Cooper". Pre-fix: input mostra "a". Post-fix: input mostra "Alice Cooper".
96
+ - **Test coverage**: i 38 functional Autocomplete test passano (2 perf flake non related — soglia 500ms/100ms su macchina caricata = 665ms/2010ms).
97
+
98
+ 2. **🎨 Autocomplete icons (chip remove ×, clear ×, caret ▾) brutte**
99
+ (gravità: bassa — cosmetico)
100
+ - **Sintomo**: chip remove, clear button, dropdown caret renderizzati come glyph Unicode (`×`, `▾`) che escono come font chunky inconsistenti vs il resto del design system.
101
+ - **Fix**: 2 nuovi componenti inline SVG `CloseIcon` + `ChevronDownIcon` (mirror del CheckIcon di Checkbox per consistenza). `width="1em" height="1em"` per scalare con `font-size` del parent. Stroke `currentColor` per ereditare `text-*` di Tailwind. Bonus: chevron flip animation su `aria-expanded=true` (CSS-only).
102
+
103
+ ### Issue pre-flagged dal docs walkthrough 17 maggio (carryover Sprint 2 P2)
104
+
105
+ Da chiudere come prossimo step di Sprint 2 (sono nel ROADMAP-SPRINT-2.md):
106
+ 1. **LeftNav underline link** — lib variants fix (`no-underline`)
107
+ 2. **TopBar underline link** — lib variants fix (`no-underline`)
108
+ 3. **Autocomplete preview shell troppo piccola in docs-lab** — solo docs-lab issue, non blocca dash
109
+
110
+ ### Gap noti (non-blocking, da Sprint 2 P5 o backlog)
111
+
112
+ - **RBAC tw-side non testato esplicitamente in dash**: TestRbac usa `@dashforge/ui` (MUI). RBAC su tw è coperto da unit test (`useAccessState` + per-component) ma manca smoke test in consumer reale. Da aggiungere: `/test-tw-rbac` route con `<TextField access={...}>` esercitando i 3 modes (hide/disable/readonly).
113
+
114
+ ## Summary risultati P1
115
+
116
+ | Status | Count | Componenti |
117
+ |---|---:|---|
118
+ | ✅ Full pass | **22** | Foundation 8 (Typography, Box, Stack, Grid, Container, Divider, AspectRatio, VisuallyHidden); Tier-1 4 (Button, TextField, Checkbox, Switch); Tier-2/3 5 (RadioGroup, Textarea, NumberField, OTPField, DateTimePicker); Nav 4 (AppShell, TopBar, LeftNav, Breadcrumbs); Providers 2 (ConfirmDialog, Snackbar) |
119
+ | ⚠️ Minor → **fixato in P1** | **1** | Autocomplete (icons cosmetic) |
120
+ | ❌ Blocker → **fixato in P1** | **1** | Autocomplete async-options select bug |
121
+
122
+ **Sprint 2 quality gate**: ✅ **PASSED** — tutti i 24 verdi dopo P1 fix.
123
+
124
+ ## Outcome aggregato
125
+
126
+ P1 ha trovato esattamente 2 issue su 24 componenti (~8% catch rate). Entrambi fixabili in lib senza public API change. Tutti gli altri 22 hanno passato i 7-point check al primo giro.
127
+
128
+ **Pattern interessante**: il bug Autocomplete async-options era **invisibile sia al CI unit test** (test setup usa `options` prop static) **sia al docs lab** (Autocomplete demo è static). **Solo un consumer reale con `loadOptions` configured esponeva il bug** — esattamente il valore di P1 nello Sprint 2.
129
+
130
+ **Implicazione per Sprint 3+**: aggiungere test unit con `loadOptions` mock al test suite Autocomplete + considerare un demo async nel docs lab per future-proofing.