@dashforge/tw 0.7.0-beta → 0.8.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 (37) hide show
  1. package/CHANGELOG.md +193 -0
  2. package/dist/index.esm.js +1092 -74
  3. package/dist/src/components/DataGrid/DataGrid.d.ts.map +1 -1
  4. package/dist/src/components/DataGrid/dataGrid.types.d.ts +43 -0
  5. package/dist/src/components/DataGrid/dataGrid.types.d.ts.map +1 -1
  6. package/dist/src/components/DataGrid/dataGrid.variants.d.ts +6 -0
  7. package/dist/src/components/DataGrid/dataGrid.variants.d.ts.map +1 -1
  8. package/dist/src/components/DataGrid/filters/ColumnFilters.d.ts +23 -0
  9. package/dist/src/components/DataGrid/filters/ColumnFilters.d.ts.map +1 -0
  10. package/dist/src/components/DataGrid/reorder/useColumnReorder.d.ts +50 -0
  11. package/dist/src/components/DataGrid/reorder/useColumnReorder.d.ts.map +1 -0
  12. package/dist/src/components/DataGrid/resize/useColumnResize.d.ts +32 -0
  13. package/dist/src/components/DataGrid/resize/useColumnResize.d.ts.map +1 -0
  14. package/dist/src/components/DataGrid/visibility/ColumnVisibilityDialog.d.ts +33 -0
  15. package/dist/src/components/DataGrid/visibility/ColumnVisibilityDialog.d.ts.map +1 -0
  16. package/dist/src/components/Table/Table.d.ts.map +1 -1
  17. package/dist/src/components/Table/table.types.d.ts +69 -5
  18. package/dist/src/components/Table/table.types.d.ts.map +1 -1
  19. package/dist/src/components/_shared/data/useTableFilter.d.ts +30 -7
  20. package/dist/src/components/_shared/data/useTableFilter.d.ts.map +1 -1
  21. package/dist/src/index.d.ts +1 -1
  22. package/dist/src/index.d.ts.map +1 -1
  23. package/package.json +3 -3
  24. package/src/components/DataGrid/DataGrid.test.tsx +422 -1
  25. package/src/components/DataGrid/DataGrid.tsx +421 -53
  26. package/src/components/DataGrid/dataGrid.types.ts +50 -1
  27. package/src/components/DataGrid/dataGrid.variants.ts +9 -1
  28. package/src/components/DataGrid/filters/ColumnFilters.tsx +432 -0
  29. package/src/components/DataGrid/reorder/useColumnReorder.test.ts +38 -0
  30. package/src/components/DataGrid/reorder/useColumnReorder.ts +144 -0
  31. package/src/components/DataGrid/resize/useColumnResize.ts +106 -0
  32. package/src/components/DataGrid/visibility/ColumnVisibilityDialog.tsx +200 -0
  33. package/src/components/Table/Table.tsx +14 -0
  34. package/src/components/Table/table.types.ts +74 -5
  35. package/src/components/_shared/data/useTableFilter.test.ts +166 -0
  36. package/src/components/_shared/data/useTableFilter.ts +97 -16
  37. package/src/index.ts +2 -0
package/CHANGELOG.md CHANGED
@@ -12,6 +12,199 @@ 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.8.0-beta] — 2026-05-19
16
+
17
+ **Sprint 4.2-bis — DataGrid v1-bis.** Ships the five power-user
18
+ features deferred from `0.7.0-beta`'s DataGrid v1:
19
+
20
+ - **Per-column filter UI chips** — text contains / number range /
21
+ date range / boolean radio, auto-detected by column type
22
+ - **Column visibility dialog** — toolbar "Columns" button +
23
+ modal with checkboxes
24
+ - **Column resize** — grab the right edge of a `<th>` to drag,
25
+ min/max clamping
26
+ - **Column reorder** — native HTML5 drag-and-drop on headers,
27
+ visual drop indicator
28
+ - **Right-sticky columns** — mirror of `sticky: 'left'` (Sprint 4.2)
29
+
30
+ **Minor bump** for the new public API surface (3 new DataGrid
31
+ props, 5 new `TableColumn` axes, 13 new i18n labels). **Strictly
32
+ additive — zero breaking changes** on existing component APIs.
33
+ Drop-in upgrade from `0.7.0-beta`.
34
+
35
+ Zero new runtime deps: filter UI built on the existing
36
+ `<Popover>` (Sprint 3), visibility on `<Dialog>` (Sprint 3),
37
+ resize/reorder on native pointer + HTML5 drag events.
38
+
39
+ ### Added
40
+
41
+ - **Per-column filter UI** — opt in via `cols[i].filterable: true`.
42
+ A filter icon appears in the column header; clicking it opens a
43
+ `<Popover>` with the right input for the column type:
44
+ - `number` → Min/Max inputs (operator: `between`)
45
+ - `date` → From/To date inputs (operator: `between`)
46
+ - `boolean` → All / True / False radios (operator: `equals`)
47
+ - text / unknown → single text input (operator: `contains`,
48
+ case-insensitive substring against the stringified value)
49
+ - **Override autodetect** with `cols[i].filterType` (`'text' |
50
+ 'number' | 'boolean' | 'date'`) — useful when an ID column is
51
+ typed as number but you want a text-contains UI.
52
+ - The filter model uses the new
53
+ `TableFilterOperator = 'contains' | 'equals' | 'between'`
54
+ discriminator. The `between` value shape is `[min, max]` where
55
+ each end can be `null` for an open range. Backwards-compatible:
56
+ `0.7.0-beta` only emitted `contains`; consumers reading
57
+ `filterModel` should now branch on `op`.
58
+ - **Active state** — the filter icon highlights primary-700 when
59
+ a filter is active on that column (`aria-pressed=true`).
60
+ - **i18n** via the existing `labels` prop. New keys:
61
+ `filterMin`, `filterMax`, `filterFrom`, `filterTo`,
62
+ `filterAll`, `filterTrue`, `filterFalse` (plus the existing
63
+ `filterColumn`, `filterApply`, `filterClear`).
64
+
65
+ - **Column visibility dialog** — opt in via the existing
66
+ `enableColumnVisibility` (defaults `true`). A "Columns" button
67
+ appears in the toolbar (alongside the optional search input).
68
+ Clicking opens a `<Dialog>` with one checkbox per `hideable`
69
+ column.
70
+ - `cols[i].hideable: false` excludes a column from the dialog
71
+ entirely (structurally required — typically the ID or primary
72
+ label column).
73
+ - `cols[i].defaultHidden: true` hides the column on first mount;
74
+ the user re-shows it via the dialog.
75
+ - Show all / Hide all shortcuts inside the dialog.
76
+ - Controllable via `hiddenColumns` + `onHiddenColumnsChange` for
77
+ persistence (LocalStorage, server-side prefs, etc.).
78
+ - New `labels` keys: `columnsButton`, `columnsTitle`,
79
+ `columnsDescription`, `columnsShowAll`, `columnsHideAll`,
80
+ `columnsDone`.
81
+
82
+ - **Column resize** — opt in via the existing `enableColumnResize`
83
+ (defaults `true`). Hovering the right edge of a `<th>` shows
84
+ `cursor: col-resize`; pointer-drag commits a new width.
85
+ - Native pointer events with `setPointerCapture` so the drag
86
+ continues even if the cursor leaves the handle.
87
+ - Clamping: `cols[i].minWidth` (default `40px`) /
88
+ `cols[i].maxWidth` (default `1200px`).
89
+ - Per-column opt-out via `cols[i].resizable: false`.
90
+ - Controllable via `columnWidths: Record<string, number>` +
91
+ `onColumnWidthsChange` for persistence.
92
+ - Works with sticky columns and the virtualized body — the
93
+ width is applied to `<th>` and matching `<td>` cells.
94
+
95
+ - **Column reorder** — opt in via the existing
96
+ `enableColumnReorder` (defaults `true`). Drag any column header
97
+ onto another; a 2px primary-500 vertical indicator marks the
98
+ drop side (LEFT half = insert before / RIGHT half = insert
99
+ after). Release to commit.
100
+ - Built on native HTML5 drag-and-drop (`draggable` + `dragstart`
101
+ / `dragover` / `drop` / `dragend`) — no library.
102
+ - The dragged header dims to `opacity-50` while in flight.
103
+ - Per-column opt-out via `cols[i].reorderable: false`.
104
+ - Controllable via `columnOrder: string[]` (list of `field`s in
105
+ display order) + `onColumnOrderChange`. Columns not in the
106
+ order list are appended at the end in their original `cols`
107
+ order — safe to omit.
108
+
109
+ - **Right-sticky columns** — `cols[i].sticky: 'right'` mirrors the
110
+ existing `'left'` value from Sprint 4.2. CSS
111
+ `position: sticky; right: 0` plus a left border to visually
112
+ separate the pinned column from the scrollable area.
113
+ - Header / cell z-index ladder maintained (header top-right
114
+ intersection at z-20, body sticky-right cell at z-[1]).
115
+ - Useful for trailing action columns (Edit / Delete) that should
116
+ always be visible.
117
+
118
+ ### Changed
119
+
120
+ - **`TableFilterItem.op`** now accepts `'contains' | 'equals' |
121
+ 'between'` (was effectively `'contains'`-only in `0.7.0-beta`).
122
+ Consumers reading the model should branch on `op` to handle the
123
+ three value shapes (`string` / `unknown` / `[min, max]` tuple).
124
+ Consumers only emitting filters via the new in-header UI need no
125
+ changes.
126
+
127
+ - **`useTableFilter`** rewritten to support all three operators
128
+ with auto-coercion (number from string, date from ISO string /
129
+ Date instance). Exposed `passesFilter` / `toNumber` / `toDateMs`
130
+ for testing. 28 new unit tests cover the helpers across all
131
+ operator + value-type combinations.
132
+
133
+ - **`useColumnAutoDetect`** is now also the source of truth for the
134
+ filter UI dispatch — `inferredType` maps to `TableFilterType`
135
+ via the new `resolveFilterType` helper inside `DataGrid.tsx`.
136
+
137
+ - **Bundle impact**: +16 KB raw (~+5 KB gz) on top of
138
+ `0.7.0-beta` — the new filter UI, visibility dialog, resize, and
139
+ reorder code paths combined. Zero new runtime deps.
140
+
141
+ ### Migration
142
+
143
+ No code changes required:
144
+
145
+ ```bash
146
+ pnpm up @dashforge/tw@^0.8.0-beta
147
+ ```
148
+
149
+ To adopt the new v1-bis features, opt in per-column / per-grid:
150
+
151
+ ```tsx
152
+ <DataGrid
153
+ rows={users}
154
+ cols={[
155
+ { field: 'name',
156
+ header: 'Name',
157
+ sticky: 'left',
158
+ hideable: false }, // required column
159
+
160
+ { field: 'age',
161
+ header: 'Age',
162
+ filterable: true }, // → number range filter (auto)
163
+
164
+ { field: 'joinedAt',
165
+ header: 'Joined',
166
+ filterable: true }, // → date range filter (auto)
167
+
168
+ { field: 'active',
169
+ header: 'Active',
170
+ filterable: true,
171
+ defaultHidden: true }, // hidden until user re-shows
172
+
173
+ { field: 'actions',
174
+ header: 'Actions',
175
+ sticky: 'right', // pinned to right edge
176
+ resizable: false,
177
+ reorderable: false,
178
+ cellRenderer: ({ row }) => <RowActionsMenu row={row} ... /> },
179
+ ]}
180
+ getRowId={(r) => r.id}
181
+ rowHeight={48}
182
+ height="600px"
183
+
184
+ // Per-feature opt-out flags (all default true):
185
+ enableColumnVisibility
186
+ enableColumnResize
187
+ enableColumnReorder
188
+
189
+ // Controllable state for persistence:
190
+ hiddenColumns={hidden} onHiddenColumnsChange={setHidden}
191
+ columnWidths={widths} onColumnWidthsChange={setWidths}
192
+ columnOrder={order} onColumnOrderChange={setOrder}
193
+ />
194
+ ```
195
+
196
+ `<Table>` (non-virtualized) is **unchanged** in `0.8.0-beta` —
197
+ the in-header v1-bis features are DataGrid-only for now. Promoting
198
+ them to Table is on the v1-bis roadmap.
199
+
200
+ ### Heads-up — companion releases coming
201
+
202
+ - **Sprint 5 → `0.9.0-beta`** + starter kits v1: separate repos
203
+ `dashforge-starter-mui` + `dashforge-starter-tw` with Auth + RBAC
204
+ + form CRUD + dashboard with DataGrid admin views.
205
+ - **Sprint 6 → `1.0.0-rc.1 → 1.0.0`**: final A11Y audit, bundle
206
+ lockdown, beta freeze, cut `1.0.0`.
207
+
15
208
  ## [0.7.0-beta] — 2026-05-19
16
209
 
17
210
  **Combined Sprint 4.2 + 4.3 release.** Ships **`<DataGrid>`** — a