@dashforge/tw 1.5.2 → 1.7.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 (37) hide show
  1. package/CHANGELOG.md +202 -0
  2. package/LICENSE +21 -0
  3. package/dist/index.esm.js +535 -140
  4. package/dist/src/components/Autocomplete/Autocomplete.d.ts +22 -0
  5. package/dist/src/components/Autocomplete/Autocomplete.d.ts.map +1 -1
  6. package/dist/src/components/Autocomplete/autocomplete.props.type-test.d.ts +2 -0
  7. package/dist/src/components/Autocomplete/autocomplete.props.type-test.d.ts.map +1 -0
  8. package/dist/src/components/Autocomplete/autocomplete.types.d.ts +103 -22
  9. package/dist/src/components/Autocomplete/autocomplete.types.d.ts.map +1 -1
  10. package/dist/src/components/Button/button.variants.d.ts.map +1 -1
  11. package/dist/src/components/Checkbox/Checkbox.d.ts.map +1 -1
  12. package/dist/src/components/Checkbox/checkbox.types.d.ts +16 -0
  13. package/dist/src/components/Checkbox/checkbox.types.d.ts.map +1 -1
  14. package/dist/src/components/Checkbox/checkbox.variants.d.ts +3 -0
  15. package/dist/src/components/Checkbox/checkbox.variants.d.ts.map +1 -1
  16. package/dist/src/components/DatePicker/DatePicker.d.ts.map +1 -1
  17. package/dist/src/components/DateRangePicker/DateRangePicker.d.ts.map +1 -1
  18. package/dist/src/components/DateTimePicker/DateTimePicker.d.ts.map +1 -1
  19. package/dist/src/components/Dialog/Dialog.d.ts.map +1 -1
  20. package/dist/src/components/Dialog/dialog.types.d.ts +28 -0
  21. package/dist/src/components/Dialog/dialog.types.d.ts.map +1 -1
  22. package/dist/src/components/NumberField/NumberField.d.ts.map +1 -1
  23. package/dist/src/components/OTPField/OTPField.d.ts.map +1 -1
  24. package/dist/src/components/RadioGroup/RadioGroup.d.ts.map +1 -1
  25. package/dist/src/components/RadioGroup/radioGroup.variants.d.ts.map +1 -1
  26. package/dist/src/components/Select/Select.d.ts.map +1 -1
  27. package/dist/src/components/Slider/Slider.d.ts.map +1 -1
  28. package/dist/src/components/Switch/Switch.d.ts.map +1 -1
  29. package/dist/src/components/Switch/switch.types.d.ts +15 -0
  30. package/dist/src/components/Switch/switch.types.d.ts.map +1 -1
  31. package/dist/src/components/Switch/switch.variants.d.ts +3 -0
  32. package/dist/src/components/Switch/switch.variants.d.ts.map +1 -1
  33. package/dist/src/components/Tabs/tabs.variants.d.ts.map +1 -1
  34. package/dist/src/components/TextField/TextField.d.ts.map +1 -1
  35. package/dist/src/components/Textarea/Textarea.d.ts.map +1 -1
  36. package/dist/src/components/TimePicker/TimePicker.d.ts.map +1 -1
  37. package/package.json +6 -4
package/CHANGELOG.md CHANGED
@@ -12,6 +12,208 @@ 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
+ ## [1.7.0] — 2026-09-22
16
+
17
+ ### Added
18
+
19
+ - **`<Checkbox required>` and `<Switch required>`** — the last two
20
+ bridge-integrated field components in the package that did not
21
+ accept `required` (the other twelve — Autocomplete, DatePicker,
22
+ DateRangePicker, DateTimePicker, NumberField, OTPField, RadioGroup,
23
+ Select, Slider, TextField, Textarea, TimePicker — already did).
24
+ Fixes BUG 21 in `libs/dashforge/README-BUG.md`. Both components now
25
+ render a `*` marker at the end of the label (styled via a new
26
+ `requiredMark` slot in the variants recipe, colour tokens matching
27
+ `textField.variants.ts` `requiredMark`) and set `aria-required="true"`
28
+ on the underlying Radix Root button via a **ref + `useEffect`
29
+ post-mount DOM setter** (Radix v1.3.3's own internal
30
+ context-then-re-emit path for `aria-required` was verified to strip
31
+ the attribute in production browser builds, though jsdom did not
32
+ catch that; the ref-based fallback is Radix-version-agnostic). HTML5
33
+ `required` is still passed through to Radix so
34
+ `Radix.CheckboxBubbleInput` picks it up for native form validation.
35
+ The `requiredMark` slot accepts a `className` via `slotProps` for
36
+ per-instance overrides, and via `theme.components.<Name>.slotProps`
37
+ for design-system-wide overrides. Presentational only, per the
38
+ library-wide convention: form-submit enforcement still requires
39
+ `rules={{ required: … }}` or a resolver rule. Seven regression tests
40
+ in `src/components/_shared/checkboxSwitchRequired.test.tsx` pin the
41
+ marker, the aria-required attribute, the no-render-when-omitted
42
+ invariant, and the slot override plumbing.
43
+
44
+ ### Fixed
45
+
46
+ - **14 field components now honour `bridge.shouldUnregister`** (BUG 22
47
+ cross-package fix). Autocomplete, Checkbox, DatePicker,
48
+ DateRangePicker, DateTimePicker, NumberField, OTPField, RadioGroup,
49
+ Select, Slider, Switch, TextField, Textarea, TimePicker — the
50
+ unmount cleanup that previously ran unconditionally
51
+ (`queueMicrotask` schedule of `bridge.unregister(name)`) now bails
52
+ out first with `if (!cap?.shouldUnregister) return;`. When
53
+ `bridge.shouldUnregister` is `false` (the new Dashforge default,
54
+ set in `DashFormProvider`) the field's row in `formState.values`
55
+ survives the unmount, which is what `<Stepper>` and tab-swap
56
+ patterns need. Requires `@dashforge/ui-core@≥1.2.0` (new bridge
57
+ field) and `@dashforge/forms@≥1.2.0` (bridge population). The
58
+ StrictMode-safe `queueMicrotask` + `isMountedRef` pattern is
59
+ preserved verbatim; the change only decides *whether* to run the
60
+ scheduled cleanup.
61
+
62
+ ## [1.6.0] — 2026-09-15
63
+
64
+ Minor release: three bug fixes (BUG 6 Dialog `actions` slot,
65
+ BUG 9 tooltip DOM leak, BUG 13 pointer cursor across every
66
+ interactive `<button>`), one runtime-rete for the DashForm mode
67
+ misuse (BUG 2 wiring on Autocomplete / Select / RadioGroup /
68
+ DatePicker via the new `useWarnIfControlledInFormMode` hook from
69
+ `@dashforge/ui-core@1.1.0`), and one type-only refactor of
70
+ `AutocompleteProps` into a discriminated union so form-mode and
71
+ standalone-mode props stop compiling together.
72
+
73
+ Requires `@dashforge/ui-core@^1.1.0` at runtime for the new hook.
74
+
75
+ ### Fixed
76
+
77
+ - **Every interactive `<button>` in the package now shows the pointer
78
+ cursor on hover** (BUG 13). `buttonVariants.base` lacked
79
+ `cursor-pointer`, and the browser UA stylesheet leaves `<button>`
80
+ at `cursor: default` — so every `<Button>`, `<IconButton>`, and
81
+ `Button` in `variant="link"` mode read as "unclickable" to the
82
+ person hovering. Same shape found in the same-pass audit on
83
+ `tabs.variants.ts` (Radix.Tabs.Trigger),
84
+ `checkbox.variants.ts` (Radix.Checkbox.Root), and
85
+ `radioGroup.variants.ts` (Radix.RadioGroup.Item) — all four are
86
+ Radix primitives that surface as `<button>` under the hood. Fixed
87
+ by adding `cursor-pointer` on each interactive base/slot; the
88
+ existing `disabled:pointer-events-none` /
89
+ `data-[disabled]:cursor-not-allowed` state resets already handle
90
+ disabled instances, and `loading` on `<Button>` still overrides
91
+ to `cursor-wait` (tailwind-variants precedence). New test file
92
+ `_shared/cursorPointerAffordance.test.tsx` (7 assertions) pins
93
+ both the recipe-level class string and the rendered-DOM
94
+ `className` for `<Button>` and `<IconButton>`, so a future edit
95
+ that strips the class fails loudly. See `README-BUG.md § BUG 13`.
96
+
97
+ ### Added
98
+
99
+ - **`<Dialog>` gained an `actions` prop** (`ReactNode`) that renders
100
+ a right-aligned footer row below the body and above the close
101
+ button. The variant + `slotProps.actions` entry already existed
102
+ in the package but had never been rendered — declared API that
103
+ did nothing (README-BUG § BUG 6). The alignment (`flex justify-end
104
+ gap-2 pt-2`) is the design-system decision encoded in
105
+ `dialog.variants.ts:52` and had been surfaced consistently in
106
+ hand-rolled action rows across consumer forms; the prop lets
107
+ consumers drop that boilerplate. Additive — existing dialogs
108
+ without `actions` render identically to before.
109
+
110
+ - **Dev-mode warning when controlled / uncontrolled props are passed
111
+ to a bridge-integrated field inside a `<DashFormProvider>`** — the
112
+ runtime rete for README-BUG § BUG 2. Applied to `<Autocomplete>`,
113
+ `<Select>`, `<RadioGroup>` and `<DatePicker>` (the four
114
+ highest-usage field components; 10 more follow in a consistency
115
+ pass). Each component calls the new `useWarnIfControlledInFormMode`
116
+ hook from `@dashforge/ui-core` with its name and the destructured
117
+ controlled props; the hook warns once per
118
+ `(componentName, name, propKey)` triple with a message naming the
119
+ offending prop and the correct API (`<DashForm defaultValues={{
120
+ [name]: … }} />`). Zero cost in production — the effect body is
121
+ guarded by `process.env.NODE_ENV !== 'production'`.
122
+
123
+ Works alongside the existing type-surface split on `Autocomplete`
124
+ (which catches `rules + defaultValue` at compile time). The two
125
+ reties are complementary: types cover the `rules`-carrying case
126
+ before compile, the runtime warning covers the common case
127
+ (`rules`-less) on first render.
128
+
129
+ ### Changed
130
+
131
+ - **`<Autocomplete>` — `AutocompleteProps` split into a discriminated
132
+ union of two mode variants** (form / standalone) to close the
133
+ type-surface bug where controlled/uncontrolled value props
134
+ (`value`, `defaultValue`, `onValueChange`) were accepted alongside
135
+ `rules` and silently ignored at runtime in form mode. The runtime
136
+ behaviour is unchanged (form-mode initial values still come from
137
+ `<DashForm defaultValues={...}>` via the bridge); the fix is
138
+ purely at the TypeScript layer:
139
+
140
+ - `AutocompleteFormMixin` marks form mode via optional `rules`;
141
+ the controlled/uncontrolled props are typed `never`.
142
+ - `AutocompleteStandaloneMixin` marks standalone mode via optional
143
+ `value` / `defaultValue` / `onValueChange`; `rules` is typed
144
+ `never`.
145
+ - Consumer surface `AutocompleteProps<TOption>` still exports as a
146
+ single name — the discrimination is transparent at import sites.
147
+
148
+ Consumer misuse audit (dash, docs-lab, kits) surfaced zero existing
149
+ callers with the mixed-mode pattern, so no downstream code
150
+ changes are required. Type-regression pinned by
151
+ `autocomplete.props.type-test.ts` (compile-only, three
152
+ `@ts-expect-error` markers). See `libs/dashforge/README-BUG.md`
153
+ § BUG 2 for the full context.
154
+
155
+ ### Fixed
156
+
157
+ - **`<TextField>`, `<NumberField>` and `<Textarea>` no longer leak
158
+ the `tooltip` prop onto the rendered `<input>` / `<textarea>` as
159
+ an unknown HTML attribute.** These three components spread
160
+ `{...rest}` onto their DOM element after destructuring `merged`,
161
+ and `tooltip` was not in the destructured keys, so its value
162
+ landed on the DOM as `tooltip="…"` (the object form of the prop
163
+ stringified to `"[object Object]"`). React 19 forwards lowercase
164
+ unknown attrs silently, so nothing signalled it in dev — it took
165
+ a Playwright strict-mode failure to notice. Fix: three one-line
166
+ destructure edits consuming `tooltip` before the `...rest` catch.
167
+ Regression guard in
168
+ `libs/dashforge/tw/src/components/_shared/tooltipDomLeak.test.tsx`.
169
+ See README-BUG § BUG 9 — the report's original "all nine field
170
+ components" scope was corrected to these three after verification
171
+ (the other six do not spread `{...rest}` onto any DOM element and
172
+ therefore cannot leak structurally; Autocomplete was empirically
173
+ probed as an anchor).
174
+
175
+ - **`<Autocomplete multiple>` — the control no longer overflows its
176
+ own width by ~6px** (a regression introduced by the BUG 3 chevron
177
+ wrap fix earlier in this Unreleased block). The controls group
178
+ and the input inside it both went from `min-w-[6rem]` to
179
+ `min-w-0`, so the input can shrink under pressure and the
180
+ `shrink-0` clear + chevron buttons always fit inside the group.
181
+ The previous floor combined with the shrink-0 buttons produced an
182
+ intrinsic min-content-size of ~156px and pushed the chevron 6px
183
+ past the group's right edge when chips had consumed most of the
184
+ outer wrapper — which turned into a horizontal scrollbar inside
185
+ a `<Dialog>` (whose body is `overflow-y-auto` and so computes
186
+ `overflow-x: auto`). The BUG 3 invariant is preserved: the
187
+ chevron stays on the same row as the input, never orphaned.
188
+ Fixes README-BUG § BUG 5.
189
+
190
+ - **`<Autocomplete multiple>` — the chevron no longer wraps onto its
191
+ own line on narrow fields.** Multi mode's outer `flex-wrap`
192
+ context (needed so chip rows can grow vertically) used to let the
193
+ chevron drop onto an orphan row whenever the row width fell below
194
+ ~400px with two or more chips, producing a 90px-tall control with
195
+ an empty band. The fix keeps the `flex-wrap` on the outer wrapper
196
+ (so chips still wrap freely) but nests the input, clear `×` and
197
+ chevron in a `flex-nowrap` inner row of their own — that inner
198
+ row is structurally indivisible, so the chevron can never orphan.
199
+ Single-mode DOM is unchanged. See `libs/dashforge/README-BUG.md`
200
+ § BUG 3 for the full context and the DOM verification.
201
+ - **`<Autocomplete>` — the listbox is now portaled** to `document.body`
202
+ via `RadixPopover.Portal`, so ancestor `overflow: hidden` /
203
+ `overflow: auto` containers can no longer clip it. Fixes the
204
+ fault-line that made "multi-select in a modal form" unusable
205
+ (`<Dialog><DashForm><Autocomplete multiple/></DashForm></Dialog>`
206
+ clipped the dropdown at the dialog body's scroll boundary, and the
207
+ same happened inside any `overflow-hidden` card such as the
208
+ `inventory-kit` `SectionCard`). See `libs/dashforge/README-BUG.md`
209
+ § BUG 1 for the full context. Width is still tied to the anchor
210
+ (via Radix's `--radix-popover-trigger-width` CSS var), keyboard
211
+ model / `aria-controls` / `aria-activedescendant` / `preventBlur`
212
+ on options are unchanged, and Radix's focus management is
213
+ intentionally disabled so focus stays on the input as before.
214
+ Downstream `overflowVisible`-prop workarounds can be removed
215
+ when this ships.
216
+
15
217
  ## [1.5.2] — 2026-08-30
16
218
 
17
219
  ### Fixed
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dashforge
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.