@dashforge/tw 0.6.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 (107) hide show
  1. package/CHANGELOG.md +451 -0
  2. package/THEME-AUDIT.md +175 -0
  3. package/dist/index.esm.js +2009 -87
  4. package/dist/src/components/Accordion/accordion.variants.d.ts.map +1 -1
  5. package/dist/src/components/Box/box.variants.d.ts.map +1 -1
  6. package/dist/src/components/DataGrid/DataGrid.d.ts +29 -0
  7. package/dist/src/components/DataGrid/DataGrid.d.ts.map +1 -0
  8. package/dist/src/components/DataGrid/dataGrid.types.d.ts +214 -0
  9. package/dist/src/components/DataGrid/dataGrid.types.d.ts.map +1 -0
  10. package/dist/src/components/DataGrid/dataGrid.variants.d.ts +222 -0
  11. package/dist/src/components/DataGrid/dataGrid.variants.d.ts.map +1 -0
  12. package/dist/src/components/DataGrid/filters/ColumnFilters.d.ts +23 -0
  13. package/dist/src/components/DataGrid/filters/ColumnFilters.d.ts.map +1 -0
  14. package/dist/src/components/DataGrid/reorder/useColumnReorder.d.ts +50 -0
  15. package/dist/src/components/DataGrid/reorder/useColumnReorder.d.ts.map +1 -0
  16. package/dist/src/components/DataGrid/resize/useColumnResize.d.ts +32 -0
  17. package/dist/src/components/DataGrid/resize/useColumnResize.d.ts.map +1 -0
  18. package/dist/src/components/DataGrid/visibility/ColumnVisibilityDialog.d.ts +33 -0
  19. package/dist/src/components/DataGrid/visibility/ColumnVisibilityDialog.d.ts.map +1 -0
  20. package/dist/src/components/Dialog/dialog.variants.d.ts.map +1 -1
  21. package/dist/src/components/Divider/divider.variants.d.ts.map +1 -1
  22. package/dist/src/components/Pagination/Pagination.d.ts.map +1 -1
  23. package/dist/src/components/Pagination/pagination.variants.d.ts.map +1 -1
  24. package/dist/src/components/Popover/popover.variants.d.ts.map +1 -1
  25. package/dist/src/components/Skeleton/skeleton.variants.d.ts.map +1 -1
  26. package/dist/src/components/Table/Table.d.ts.map +1 -1
  27. package/dist/src/components/Table/table.types.d.ts +77 -5
  28. package/dist/src/components/Table/table.types.d.ts.map +1 -1
  29. package/dist/src/components/Tabs/tabs.variants.d.ts.map +1 -1
  30. package/dist/src/components/Tooltip/tooltip.variants.d.ts.map +1 -1
  31. package/dist/src/components/Typography/typography.variants.d.ts.map +1 -1
  32. package/dist/src/components/_shared/data/getNestedValue.d.ts.map +1 -0
  33. package/dist/src/components/{Table/_internal → _shared/data}/useColumnAutoDetect.d.ts +1 -1
  34. package/dist/src/components/_shared/data/useColumnAutoDetect.d.ts.map +1 -0
  35. package/dist/src/components/_shared/data/useControllableState.d.ts.map +1 -0
  36. package/dist/src/components/_shared/data/useDebouncedValue.d.ts.map +1 -0
  37. package/dist/src/components/_shared/data/useTableFilter.d.ts +36 -0
  38. package/dist/src/components/_shared/data/useTableFilter.d.ts.map +1 -0
  39. package/dist/src/components/{Table/_internal → _shared/data}/useTableSearch.d.ts +1 -1
  40. package/dist/src/components/_shared/data/useTableSearch.d.ts.map +1 -0
  41. package/dist/src/components/{Table/_internal → _shared/data}/useTableSelection.d.ts +1 -1
  42. package/dist/src/components/_shared/data/useTableSelection.d.ts.map +1 -0
  43. package/dist/src/components/{Table/_internal → _shared/data}/useTableSort.d.ts +1 -1
  44. package/dist/src/components/_shared/data/useTableSort.d.ts.map +1 -0
  45. package/dist/src/components/_shared/data/useVirtualizer.d.ts +107 -0
  46. package/dist/src/components/_shared/data/useVirtualizer.d.ts.map +1 -0
  47. package/dist/src/index.d.ts +6 -3
  48. package/dist/src/index.d.ts.map +1 -1
  49. package/package.json +5 -5
  50. package/src/components/Accordion/accordion.variants.ts +5 -3
  51. package/src/components/Box/Box.test.tsx +32 -11
  52. package/src/components/Box/box.variants.ts +23 -4
  53. package/src/components/DataGrid/DataGrid.test.tsx +917 -0
  54. package/src/components/DataGrid/DataGrid.tsx +1199 -0
  55. package/src/components/DataGrid/dataGrid.types.ts +238 -0
  56. package/src/components/DataGrid/dataGrid.variants.ts +152 -0
  57. package/src/components/DataGrid/filters/ColumnFilters.tsx +432 -0
  58. package/src/components/DataGrid/reorder/useColumnReorder.test.ts +38 -0
  59. package/src/components/DataGrid/reorder/useColumnReorder.ts +144 -0
  60. package/src/components/DataGrid/resize/useColumnResize.ts +106 -0
  61. package/src/components/DataGrid/visibility/ColumnVisibilityDialog.tsx +200 -0
  62. package/src/components/Dialog/dialog.variants.ts +10 -6
  63. package/src/components/Divider/Divider.test.tsx +3 -1
  64. package/src/components/Divider/Divider.tsx +1 -1
  65. package/src/components/Divider/divider.variants.ts +2 -1
  66. package/src/components/Pagination/Pagination.tsx +3 -1
  67. package/src/components/Pagination/pagination.variants.ts +19 -13
  68. package/src/components/Popover/popover.variants.ts +10 -4
  69. package/src/components/Skeleton/skeleton.variants.ts +2 -1
  70. package/src/components/Table/Table.tsx +22 -8
  71. package/src/components/Table/table.types.ts +83 -5
  72. package/src/components/Tabs/tabs.variants.ts +19 -8
  73. package/src/components/Tooltip/tooltip.variants.ts +12 -2
  74. package/src/components/Typography/Typography.test.tsx +3 -1
  75. package/src/components/Typography/typography.variants.ts +6 -2
  76. package/src/components/{Table/_internal → _shared/data}/useColumnAutoDetect.test.ts +1 -1
  77. package/src/components/{Table/_internal → _shared/data}/useColumnAutoDetect.ts +1 -1
  78. package/src/components/_shared/data/useTableFilter.test.ts +166 -0
  79. package/src/components/_shared/data/useTableFilter.ts +118 -0
  80. package/src/components/{Table/_internal → _shared/data}/useTableSearch.test.ts +1 -1
  81. package/src/components/{Table/_internal → _shared/data}/useTableSearch.ts +1 -1
  82. package/src/components/{Table/_internal → _shared/data}/useTableSelection.ts +1 -1
  83. package/src/components/{Table/_internal → _shared/data}/useTableSort.test.ts +1 -1
  84. package/src/components/{Table/_internal → _shared/data}/useTableSort.ts +1 -1
  85. package/src/components/_shared/data/useVirtualizer.test.ts +158 -0
  86. package/src/components/_shared/data/useVirtualizer.ts +199 -0
  87. package/src/components/_shared/themeIdentity.test.ts +113 -0
  88. package/src/index.ts +20 -2
  89. package/dist/src/components/Table/_internal/getNestedValue.d.ts.map +0 -1
  90. package/dist/src/components/Table/_internal/useColumnAutoDetect.d.ts.map +0 -1
  91. package/dist/src/components/Table/_internal/useControllableState.d.ts.map +0 -1
  92. package/dist/src/components/Table/_internal/useDebouncedValue.d.ts.map +0 -1
  93. package/dist/src/components/Table/_internal/useTableFilter.d.ts +0 -13
  94. package/dist/src/components/Table/_internal/useTableFilter.d.ts.map +0 -1
  95. package/dist/src/components/Table/_internal/useTableSearch.d.ts.map +0 -1
  96. package/dist/src/components/Table/_internal/useTableSelection.d.ts.map +0 -1
  97. package/dist/src/components/Table/_internal/useTableSort.d.ts.map +0 -1
  98. package/src/components/Table/_internal/themeIdentity.test.ts +0 -84
  99. package/src/components/Table/_internal/useTableFilter.ts +0 -37
  100. /package/dist/src/components/{Table/_internal → _shared/data}/getNestedValue.d.ts +0 -0
  101. /package/dist/src/components/{Table/_internal → _shared/data}/useControllableState.d.ts +0 -0
  102. /package/dist/src/components/{Table/_internal → _shared/data}/useDebouncedValue.d.ts +0 -0
  103. /package/src/components/{Table/_internal → _shared/data}/getNestedValue.test.ts +0 -0
  104. /package/src/components/{Table/_internal → _shared/data}/getNestedValue.ts +0 -0
  105. /package/src/components/{Table/_internal → _shared/data}/useControllableState.ts +0 -0
  106. /package/src/components/{Table/_internal → _shared/data}/useDebouncedValue.ts +0 -0
  107. /package/src/components/{Table/_internal → _shared/data}/useTableSelection.test.ts +0 -0
@@ -0,0 +1,199 @@
1
+ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
2
+
3
+ /**
4
+ * Window descriptor — which slice of the row array is currently
5
+ * mounted in DOM, and how much spacer height to render above and
6
+ * below the visible window so the scrollbar size matches the
7
+ * "virtual" total height.
8
+ */
9
+ export interface VirtualizerWindow {
10
+ /** First row index inside the visible window (inclusive). */
11
+ startIndex: number;
12
+ /** Last row index inside the visible window (inclusive). */
13
+ endIndex: number;
14
+ /** Pixels to render above the visible rows (spacer top). */
15
+ paddingTop: number;
16
+ /** Pixels to render below the visible rows (spacer bottom). */
17
+ paddingBottom: number;
18
+ }
19
+
20
+ export interface UseVirtualizerArgs {
21
+ /** Total number of rows in the underlying data set. */
22
+ totalCount: number;
23
+ /** Fixed row height in pixels. */
24
+ rowHeight: number;
25
+ /**
26
+ * Visible viewport height in pixels. Pass the height of the
27
+ * scroll container.
28
+ */
29
+ viewportHeight: number;
30
+ /** Current scrollTop of the scroll container. */
31
+ scrollTop: number;
32
+ /**
33
+ * How many extra rows to render above / below the visible window
34
+ * for smoother scrolling (reduces blank-flash on fast scroll).
35
+ * @default 5
36
+ */
37
+ overscan?: number;
38
+ }
39
+
40
+ /**
41
+ * Compute the visible window of rows + the spacer heights given the
42
+ * current scroll position. Pure function — exported for testability.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * computeWindow({ totalCount: 1000, rowHeight: 48, viewportHeight: 600,
47
+ * scrollTop: 0, overscan: 5 });
48
+ * // → { startIndex: 0, endIndex: 17, paddingTop: 0, paddingBottom: 47136 }
49
+ * ```
50
+ */
51
+ export function computeWindow(args: UseVirtualizerArgs): VirtualizerWindow {
52
+ const { totalCount, rowHeight, viewportHeight, scrollTop, overscan = 5 } = args;
53
+
54
+ if (totalCount <= 0 || rowHeight <= 0 || viewportHeight <= 0) {
55
+ return { startIndex: 0, endIndex: -1, paddingTop: 0, paddingBottom: 0 };
56
+ }
57
+
58
+ // Raw visible range from scrollTop alone.
59
+ const rawStart = Math.floor(scrollTop / rowHeight);
60
+ const rawEnd = Math.ceil((scrollTop + viewportHeight) / rowHeight);
61
+
62
+ // Apply overscan + clamp to [0, totalCount - 1].
63
+ const startIndex = Math.max(0, rawStart - overscan);
64
+ const endIndex = Math.min(totalCount - 1, rawEnd + overscan);
65
+
66
+ const paddingTop = startIndex * rowHeight;
67
+ const paddingBottom = Math.max(0, (totalCount - 1 - endIndex) * rowHeight);
68
+
69
+ return { startIndex, endIndex, paddingTop, paddingBottom };
70
+ }
71
+
72
+ /**
73
+ * `useVirtualizer` — viewport-based row windowing for `<DataGrid>`.
74
+ *
75
+ * Hand-rolled (no `@tanstack/react-virtual` dep — constraint memorized
76
+ * in `feedback_dashforge_preset_is_identity` companion: "no new
77
+ * external runtime deps"). Uses scroll event + `requestAnimationFrame`
78
+ * debounce + `ResizeObserver` on the container. Fixed row height
79
+ * only in v1 — variable-height with measurement cache deferred to
80
+ * v1-bis.
81
+ *
82
+ * Returns:
83
+ * - `scrollRef`: attach to the scroll container `<div>`.
84
+ * - `window`: which row indices to mount + top/bottom spacer heights
85
+ * to preserve scroll-area size.
86
+ * - `viewportHeight`: current container height (re-measured on
87
+ * `ResizeObserver` ticks).
88
+ *
89
+ * The DataGrid renders `rows.slice(window.startIndex, window.endIndex + 1)`
90
+ * between two spacer `<tr style={{ height: paddingTop }} />` elements
91
+ * (above and below). This preserves `<table>` semantics — screen
92
+ * readers see a continuous structure with `aria-hidden` spacers.
93
+ *
94
+ * @example
95
+ * ```tsx
96
+ * const { scrollRef, window } = useVirtualizer({
97
+ * totalCount: rows.length,
98
+ * rowHeight: 48,
99
+ * overscan: 5,
100
+ * });
101
+ *
102
+ * return (
103
+ * <div ref={scrollRef} style={{ height: 600, overflow: 'auto' }}>
104
+ * <table>
105
+ * <tbody>
106
+ * <tr aria-hidden="true" style={{ height: window.paddingTop }} />
107
+ * {rows.slice(window.startIndex, window.endIndex + 1).map(...)}
108
+ * <tr aria-hidden="true" style={{ height: window.paddingBottom }} />
109
+ * </tbody>
110
+ * </table>
111
+ * </div>
112
+ * );
113
+ * ```
114
+ */
115
+ export function useVirtualizer(args: {
116
+ totalCount: number;
117
+ rowHeight: number;
118
+ overscan?: number;
119
+ /**
120
+ * Initial viewport height — used before the ResizeObserver
121
+ * settles on first paint. Pass an explicit `height` prop value
122
+ * if you have one; otherwise the hook re-measures on layout.
123
+ * @default 400
124
+ */
125
+ initialViewportHeight?: number;
126
+ }): {
127
+ scrollRef: React.RefObject<HTMLDivElement | null>;
128
+ window: VirtualizerWindow;
129
+ viewportHeight: number;
130
+ } {
131
+ const { totalCount, rowHeight, overscan = 5, initialViewportHeight = 400 } = args;
132
+
133
+ const scrollRef = useRef<HTMLDivElement | null>(null);
134
+ const [scrollTop, setScrollTop] = useState(0);
135
+ const [viewportHeight, setViewportHeight] = useState(initialViewportHeight);
136
+
137
+ // Debounce scroll handler via requestAnimationFrame so we never
138
+ // re-render more than once per paint frame even when the scroll
139
+ // event fires rapidly during fast scrolling.
140
+ const rafIdRef = useRef<number | null>(null);
141
+ const handleScroll = useCallback(() => {
142
+ if (rafIdRef.current != null) return;
143
+ rafIdRef.current = requestAnimationFrame(() => {
144
+ rafIdRef.current = null;
145
+ const el = scrollRef.current;
146
+ if (!el) return;
147
+ setScrollTop(el.scrollTop);
148
+ });
149
+ }, []);
150
+
151
+ // Attach scroll listener.
152
+ useEffect(() => {
153
+ const el = scrollRef.current;
154
+ if (!el) return;
155
+ el.addEventListener('scroll', handleScroll, { passive: true });
156
+ return () => {
157
+ el.removeEventListener('scroll', handleScroll);
158
+ if (rafIdRef.current != null) {
159
+ cancelAnimationFrame(rafIdRef.current);
160
+ rafIdRef.current = null;
161
+ }
162
+ };
163
+ }, [handleScroll]);
164
+
165
+ // Track container viewport height via ResizeObserver — re-virtualize
166
+ // when the container size changes (window resize, sidebar collapse,
167
+ // etc.). Use `useLayoutEffect` so the first measurement happens
168
+ // before paint to avoid a flash of stale window.
169
+ //
170
+ // **Defensive**: only accept measurements > 0. jsdom (test env)
171
+ // returns `clientHeight === 0` for unmounted containers, which would
172
+ // collapse the window to empty. The hook keeps the
173
+ // `initialViewportHeight` fallback in that case.
174
+ useLayoutEffect(() => {
175
+ const el = scrollRef.current;
176
+ if (!el) return;
177
+ if (el.clientHeight > 0) {
178
+ setViewportHeight(el.clientHeight);
179
+ }
180
+ if (typeof ResizeObserver === 'undefined') return;
181
+ const observer = new ResizeObserver((entries) => {
182
+ const entry = entries[0];
183
+ if (!entry || entry.contentRect.height <= 0) return;
184
+ setViewportHeight(entry.contentRect.height);
185
+ });
186
+ observer.observe(el);
187
+ return () => observer.disconnect();
188
+ }, []);
189
+
190
+ const window = computeWindow({
191
+ totalCount,
192
+ rowHeight,
193
+ viewportHeight,
194
+ scrollTop,
195
+ overscan,
196
+ });
197
+
198
+ return { scrollRef, window, viewportHeight };
199
+ }
@@ -0,0 +1,113 @@
1
+ import { readFileSync, readdirSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { describe, it, expect } from 'vitest';
4
+
5
+ /**
6
+ * Package-level theme-identity regression test.
7
+ *
8
+ * Enforces the Dashforge rule
9
+ * (memory: `feedback_dashforge_preset_is_identity`):
10
+ * the `@dashforge/tw-theme` default preset auto-inverts the neutral
11
+ * palette via a CSS-variable swap (`bg-neutral-50` is light surface
12
+ * in light mode AND dark surface in dark mode — same class, different
13
+ * physical color). Adding a `dark:` Tailwind variant on a
14
+ * `neutral-*` class creates a DOUBLE inversion that breaks dark mode.
15
+ *
16
+ * The Sprint 4.1 Table fix established the rule; Sprint 4.3 applies
17
+ * it to the whole catalog and adds this test as a regression guard.
18
+ *
19
+ * **Allowed exception** (Category B in `THEME-AUDIT.md`): the pattern
20
+ * `bg-white dark:bg-neutral-N` / `fill-white dark:fill-neutral-N` is
21
+ * LEGITIMATE — `bg-white` is hardcoded (no auto-inversion via CSS
22
+ * vars) so a `dark:` counterpart IS needed to get a dark elevated
23
+ * surface in dark mode. The regex below strips these legitimate
24
+ * patterns before scanning for the anti-pattern.
25
+ *
26
+ * Color palettes (`primary` / `secondary` / `success` / `warning` /
27
+ * `danger` / `info`) are EXEMPT from this rule by design — they
28
+ * do not auto-invert, so `dark:` shifts on them are legitimate
29
+ * design choices (tone refinement across modes).
30
+ */
31
+ const COMPONENTS_DIR = join(__dirname, '..');
32
+
33
+ // The legitimate Category B patterns we allow:
34
+ // 1. `bg-white dark:bg-neutral-N`
35
+ // 2. `fill-white dark:fill-neutral-N`
36
+ // 3. variant-prefixed versions, e.g.
37
+ // `data-[state=active]:bg-white dark:data-[state=active]:bg-neutral-N`
38
+ //
39
+ // Strip these from the source before scanning for the anti-pattern.
40
+ const CATEGORY_B_RE =
41
+ /(?:[\w[\]:-]+:)?(?:bg|fill)-white\s+dark:(?:[\w[\]:-]+:)*(?:bg|fill)-neutral-\d+/g;
42
+
43
+ // Anti-pattern: any `dark:` variant on a `neutral-N` class.
44
+ // Covers `bg`, `text`, `border`, `ring`, `placeholder:text`,
45
+ // `hover:bg`, `focus-visible:bg`, `data-[state=*]:bg`, etc.
46
+ const NEUTRAL_DARK_RE =
47
+ /dark:(?:[\w[\]:-]+:)*(?:bg|text|border|ring|fill|placeholder|focus-visible|hover|focus|data)?-?neutral-\d+/;
48
+
49
+ function walkSourceFiles(dir: string): string[] {
50
+ const entries = readdirSync(dir, { withFileTypes: true });
51
+ const out: string[] = [];
52
+ for (const entry of entries) {
53
+ const full = join(dir, entry.name);
54
+ if (entry.isDirectory()) {
55
+ out.push(...walkSourceFiles(full));
56
+ continue;
57
+ }
58
+ if (!entry.isFile()) continue;
59
+ if (entry.name.endsWith('.test.ts')) continue;
60
+ if (entry.name.endsWith('.test.tsx')) continue;
61
+ if (entry.name.endsWith('.spec.ts')) continue;
62
+ if (entry.name.endsWith('.spec.tsx')) continue;
63
+ if (!/\.(ts|tsx)$/.test(entry.name)) continue;
64
+ out.push(full);
65
+ }
66
+ return out;
67
+ }
68
+
69
+ describe('Catalog — theme identity rule (no `dark:` on neutral palette)', () => {
70
+ const files = walkSourceFiles(COMPONENTS_DIR);
71
+
72
+ it('finds the catalog source files', () => {
73
+ expect(files.length).toBeGreaterThan(20);
74
+ });
75
+
76
+ for (const file of files) {
77
+ const rel = file.replace(COMPONENTS_DIR + '/', '');
78
+ it(`${rel} — no \`dark:*-neutral-N\` anti-pattern`, () => {
79
+ const source = readFileSync(file, 'utf-8');
80
+ const stripped = source
81
+ // 1. Strip legitimate Category B patterns (bg-white / fill-white
82
+ // paired with a `dark:` neutral target — bg-white doesn't
83
+ // auto-invert, so the `dark:` is intentional).
84
+ .replace(CATEGORY_B_RE, '')
85
+ // 2. Strip comments — the regex examples in THEME-AUDIT and
86
+ // this test source itself contain the anti-pattern as text.
87
+ .replace(/\/\/.*$/gm, '')
88
+ .replace(/\/\*[\s\S]*?\*\//g, '');
89
+
90
+ const match = stripped.match(NEUTRAL_DARK_RE);
91
+ if (match) {
92
+ const idx = stripped.indexOf(match[0]);
93
+ const context = stripped.slice(
94
+ Math.max(0, idx - 80),
95
+ idx + match[0].length + 80,
96
+ );
97
+ throw new Error(
98
+ `Found \`dark:*-neutral-N\` anti-pattern in ${rel}:\n` +
99
+ ` ...${context.replace(/\s+/g, ' ').trim()}...\n\n` +
100
+ `Rule: dashforgePreset() auto-inverts neutral palette via CSS-var swap. ` +
101
+ `Adding \`dark:bg-neutral-N\` (or similar) creates double inversion ` +
102
+ `and breaks dark mode.\n\n` +
103
+ `Fix: drop the \`dark:\` variant — the base class auto-inverts.\n\n` +
104
+ `Exception: \`bg-white dark:bg-neutral-N\` IS allowed (bg-white doesn't ` +
105
+ `auto-invert, the dark variant is required for proper dark elevation).\n\n` +
106
+ `See: libs/dashforge/tw/THEME-AUDIT.md, ` +
107
+ `memory \`feedback_dashforge_preset_is_identity\`.`,
108
+ );
109
+ }
110
+ expect(match).toBeNull();
111
+ });
112
+ }
113
+ });
package/src/index.ts CHANGED
@@ -294,6 +294,8 @@ export type {
294
294
  TableSortModel,
295
295
  TableFilterItem,
296
296
  TableFilterModel,
297
+ TableFilterOperator,
298
+ TableFilterType,
297
299
  TableRowSelectionMode,
298
300
  TableExpandableConfig,
299
301
  TableLabels,
@@ -319,7 +321,23 @@ export type {
319
321
  } from './components/Table/cells/index.js';
320
322
  // Helpers (exported for power users building custom Table-like
321
323
  // components on top of the same primitives).
322
- export { getNestedValue } from './components/Table/_internal/getNestedValue.js';
324
+ export { getNestedValue } from './components/_shared/data/getNestedValue.js';
325
+
326
+ // F14 tier-5: virtualized data grid for large data sets. Companion to
327
+ // `<Table>` — same column model, sort/search/filter/selection logic
328
+ // (shared via `_shared/data/` helpers) but uses homemade
329
+ // virtualization (`IntersectionObserver` + scroll-event +
330
+ // `requestAnimationFrame` — zero new runtime deps).
331
+
332
+ export { DataGrid } from './components/DataGrid/DataGrid.js';
333
+ export type {
334
+ DataGridProps,
335
+ DataGridSlotProps,
336
+ DataGridSelectAllScope,
337
+ DataGridServerSideFlags,
338
+ DataGridPaginationConfig,
339
+ } from './components/DataGrid/dataGrid.types.js';
340
+ export { dataGridVariants } from './components/DataGrid/dataGrid.variants.js';
323
341
 
324
342
  // ───── Hooks ─────
325
343
  export { useAccessState } from './hooks/useAccessState.js';
@@ -335,4 +353,4 @@ export type { VariantProps } from 'tailwind-variants';
335
353
  /**
336
354
  * Package version (synced with `package.json` at publish time).
337
355
  */
338
- export const VERSION = '0.6.0-beta';
356
+ export const VERSION = '0.7.0-beta';
@@ -1 +0,0 @@
1
- {"version":3,"file":"getNestedValue.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/_internal/getNestedValue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC7C,GAAG,EAAE,CAAC,EACN,IAAI,EAAE,MAAM,GACX,OAAO,CAUT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useColumnAutoDetect.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/_internal/useColumnAutoDetect.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAClD,IAAI,EAAE,CAAC,EAAE,EACT,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,EACtB,UAAU,SAAK,GACd,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAiBtC;AAcD;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;CAAE,EAC5C,QAAQ,EAAE,uBAAuB,GAAG,SAAS,GAC5C,MAAM,GAAG,OAAO,GAAG,QAAQ,CAU7B;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,EAC9B,QAAQ,EAAE,uBAAuB,GAAG,SAAS,GAC5C,OAAO,CAGT;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAC3B,OAAO,CAET"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useControllableState.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/_internal/useControllableState.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,IAAI,EAAE;IAC5C,eAAe,EAAE,CAAC,GAAG,SAAS,CAAC;IAC/B,YAAY,EAAE,CAAC,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;CAC/B,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,CAwB5C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useDebouncedValue.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/_internal/useDebouncedValue.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAajE"}
@@ -1,13 +0,0 @@
1
- import type { TableFilterModel } from '../table.types.js';
2
- /**
3
- * Filters `rows` by the per-column filter model. v1 only supports
4
- * the `contains` operator (text substring) — additional ops
5
- * (`equals`, `in`, `gte`, `lte`, `between`, `before`, `after`)
6
- * land in v1-bis once the filter UI surface for each shape is
7
- * fleshed out.
8
- *
9
- * AND semantics across columns: a row must match EVERY active
10
- * filter. Within a single filter, the op decides the predicate.
11
- */
12
- export declare function useTableFilter<T extends object>(rows: T[], filterModel: TableFilterModel): T[];
13
- //# sourceMappingURL=useTableFilter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTableFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/_internal/useTableFilter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC7C,IAAI,EAAE,CAAC,EAAE,EACT,WAAW,EAAE,gBAAgB,GAC5B,CAAC,EAAE,CAkBL"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTableSearch.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/_internal/useTableSearch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAqBzD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC7C,IAAI,EAAE,CAAC,EAAE,EACT,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,EACtB,KAAK,EAAE,MAAM,GACZ,CAAC,EAAE,CAeL"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTableSelection.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/_internal/useTableSelection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D,MAAM,WAAW,uBAAuB;IACtC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACvC,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACzC,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,qDAAqD;IACrD,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC;IAChD,uEAAuE;IACvE,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC;CACnD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,qBAAqB,EAC3B,cAAc,EAAE,MAAM,EAAE,EACxB,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC,KAAK,IAAI,GAC3E,uBAAuB,CAqEzB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTableSort.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/_internal/useTableSort.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EAEf,MAAM,mBAAmB,CAAC;AA+C3B;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAC3C,IAAI,EAAE,CAAC,EAAE,EACT,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,EACtB,SAAS,EAAE,cAAc,GACxB,CAAC,EAAE,CA2CL;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,OAAO,GACb,cAAc,CAkBhB"}
@@ -1,84 +0,0 @@
1
- import { readFileSync, readdirSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import { describe, it, expect } from 'vitest';
4
-
5
- /**
6
- * Theme-identity regression test.
7
- *
8
- * Enforces the Dashforge rule (memory: `feedback_dashforge_preset_is_identity`):
9
- * the `@dashforge/tw-theme` default preset auto-inverts the neutral
10
- * palette via a CSS-variable swap. Adding `dark:` Tailwind variants
11
- * on `neutral-*` classes creates a DOUBLE inversion that breaks
12
- * dark mode (both classes resolve to the dark value).
13
- *
14
- * This test scans Table source files for the anti-pattern and fails
15
- * if any are introduced. Color palettes (`primary`, `secondary`,
16
- * `success`, `warning`, `danger`, `info`) are EXEMPT — they do not
17
- * auto-invert, so `dark:` variants on them are a legitimate design
18
- * choice (e.g. RenderChip color rows).
19
- */
20
- const TABLE_DIR = join(__dirname, '..');
21
-
22
- /**
23
- * Match `dark:<modifier>?:bg-neutral-X` / `text-neutral-X` /
24
- * `border-neutral-X` / `placeholder:text-neutral-X` / `ring-neutral-X` etc.
25
- *
26
- * The `(?:[a-z-]+:)*` chunk eats arbitrary intermediate variants
27
- * (e.g. `dark:hover:bg-neutral-...`, `dark:placeholder:text-neutral-...`).
28
- */
29
- const NEUTRAL_DARK_RE =
30
- /dark:(?:[a-z-]+:)*(?:bg|text|border|ring|placeholder:text|focus-visible:bg|hover:bg|hover:text|focus:bg)?-?neutral-\d+/;
31
-
32
- function walkSourceFiles(dir: string): string[] {
33
- const entries = readdirSync(dir, { withFileTypes: true });
34
- const out: string[] = [];
35
- for (const entry of entries) {
36
- const full = join(dir, entry.name);
37
- if (entry.isDirectory()) {
38
- out.push(...walkSourceFiles(full));
39
- continue;
40
- }
41
- if (!entry.isFile()) continue;
42
- if (entry.name.endsWith('.test.ts')) continue;
43
- if (entry.name.endsWith('.test.tsx')) continue;
44
- if (!/\.(ts|tsx)$/.test(entry.name)) continue;
45
- out.push(full);
46
- }
47
- return out;
48
- }
49
-
50
- describe('Table — theme identity rule (no `dark:` on neutral palette)', () => {
51
- const files = walkSourceFiles(TABLE_DIR).filter(
52
- // The test file itself contains the regex example — exclude.
53
- (f) => !f.endsWith('themeIdentity.test.ts'),
54
- );
55
-
56
- it('finds at least the expected source files', () => {
57
- expect(files.length).toBeGreaterThan(5);
58
- });
59
-
60
- for (const file of files) {
61
- const rel = file.replace(TABLE_DIR + '/', '');
62
- it(`${rel} — contains no \`dark:*-neutral-N\` classes`, () => {
63
- const source = readFileSync(file, 'utf-8');
64
- // Strip line comments to avoid false positives in docstrings
65
- const stripped = source
66
- .replace(/\/\/.*$/gm, '')
67
- .replace(/\/\*[\s\S]*?\*\//g, '');
68
- const match = stripped.match(NEUTRAL_DARK_RE);
69
- if (match) {
70
- // Surface the offending excerpt to make the failure actionable.
71
- const idx = stripped.indexOf(match[0]);
72
- const context = stripped.slice(Math.max(0, idx - 60), idx + match[0].length + 60);
73
- throw new Error(
74
- `Found \`dark:\`-on-neutral anti-pattern in ${rel}:\n ...${context}...\n` +
75
- `Rule: dashforgePreset() auto-inverts neutral palette via CSS-var swap. ` +
76
- `Adding \`dark:bg-neutral-N\` (etc.) creates double inversion and breaks dark mode.\n` +
77
- `Fix: drop the \`dark:\` variant — the same class works in both modes.\n` +
78
- `See memory: \`feedback_dashforge_preset_is_identity\`.`,
79
- );
80
- }
81
- expect(match).toBeNull();
82
- });
83
- }
84
- });
@@ -1,37 +0,0 @@
1
- import { useMemo } from 'react';
2
- import { getNestedValue } from './getNestedValue.js';
3
- import { stringifyForSearch } from './useTableSearch.js';
4
- import type { TableFilterModel } from '../table.types.js';
5
-
6
- /**
7
- * Filters `rows` by the per-column filter model. v1 only supports
8
- * the `contains` operator (text substring) — additional ops
9
- * (`equals`, `in`, `gte`, `lte`, `between`, `before`, `after`)
10
- * land in v1-bis once the filter UI surface for each shape is
11
- * fleshed out.
12
- *
13
- * AND semantics across columns: a row must match EVERY active
14
- * filter. Within a single filter, the op decides the predicate.
15
- */
16
- export function useTableFilter<T extends object>(
17
- rows: T[],
18
- filterModel: TableFilterModel,
19
- ): T[] {
20
- return useMemo(() => {
21
- if (!filterModel || filterModel.length === 0) return rows;
22
- return rows.filter((row) =>
23
- filterModel.every((filter) => {
24
- const value = getNestedValue(row, filter.field);
25
- const stringValue = stringifyForSearch(value).toLowerCase();
26
- const needle = filter.value.trim().toLowerCase();
27
- if (!needle) return true; // empty filter == no-op
28
- switch (filter.op) {
29
- case 'contains':
30
- return stringValue.includes(needle);
31
- default:
32
- return true;
33
- }
34
- }),
35
- );
36
- }, [rows, filterModel]);
37
- }