@rozie-ui/data-table-solid 0.1.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.
@@ -0,0 +1,54 @@
1
+ /**
2
+ * middleware.ts — pure construction of the Floating UI middleware stack from the
3
+ * Popover's first-class props.
4
+ *
5
+ * This is the one piece of BRANCHY engine glue in Popover.rozie (offset always on,
6
+ * flip/shift opt-out via `disableFlip`/`disableShift`, arrow opt-in via `arrow` +
7
+ * an element). Extracted to `src/internal/` so it can be unit-tested in isolation
8
+ * (codegen vendors `src/internal/` into every leaf via copyInternal, excluding
9
+ * `*.test.ts`).
10
+ *
11
+ * It takes the Floating UI middleware FACTORIES as arguments (rather than importing
12
+ * `@floating-ui/dom` itself) so the unit test can pass lightweight stand-ins and
13
+ * assert ORDER + presence without pulling the real engine — and so the vendored
14
+ * copy in each leaf has zero engine import of its own (the leaf's Popover.* owns
15
+ * the single engine import).
16
+ *
17
+ * Floating UI ordering contract: offset → flip → shift → arrow. `offset` first so
18
+ * the gap is measured before collision detection; `arrow` last so it reads the
19
+ * final resolved placement.
20
+ */
21
+
22
+ export interface MiddlewareFactories {
23
+ offset: (value: number) => unknown;
24
+ flip: () => unknown;
25
+ shift: () => unknown;
26
+ arrow: (opts: { element: Element }) => unknown;
27
+ }
28
+
29
+ export interface MiddlewareConfig {
30
+ offset: number;
31
+ disableFlip: boolean;
32
+ disableShift: boolean;
33
+ arrow: boolean;
34
+ arrowEl: Element | null;
35
+ }
36
+
37
+ /**
38
+ * Build the ordered middleware array for `computePosition`. Pure — no engine
39
+ * import, no DOM read beyond the passed-in arrow element.
40
+ */
41
+ export function buildMiddleware(
42
+ factories: MiddlewareFactories,
43
+ config: MiddlewareConfig,
44
+ ): unknown[] {
45
+ const mw: unknown[] = [factories.offset(config.offset)];
46
+ if (!config.disableFlip) mw.push(factories.flip());
47
+ if (!config.disableShift) mw.push(factories.shift());
48
+ // The arrow middleware needs a real element to position; opt-in only when both
49
+ // the `arrow` prop is set AND the arrow element has mounted.
50
+ if (config.arrow && config.arrowEl) {
51
+ mw.push(factories.arrow({ element: config.arrowEl }));
52
+ }
53
+ return mw;
54
+ }
@@ -0,0 +1,102 @@
1
+ /*
2
+ * @rozie-ui/data-table — base token reference.
3
+ *
4
+ * Every COSMETIC value the table renders flows through a `--rozie-data-table-*`
5
+ * PUBLIC token. The component's scoped `<style>` reads short internal `--rdt-*`
6
+ * tokens with inline `var(--rdt-x, <fallback>)` defaults, so the table renders
7
+ * ZERO-CONFIG without importing this file — it already paints a sensible default.
8
+ * Importing this file simply makes the full public token surface explicit in one
9
+ * place and wires each public `--rozie-data-table-*` token onto the internal
10
+ * `--rdt-*` the component consumes, so a design-system bridge (shadcn / material /
11
+ * bootstrap) can re-skin the whole table by remapping ONLY the public tokens.
12
+ *
13
+ * NOTE the split (CONTEXT "Claude's Discretion" + the slider D-08 precedent): the
14
+ * STRUCTURAL rules — `border-collapse`, the keyed-r-for layout, `position: sticky`
15
+ * for the header + pinned columns, the resize-handle positioning, the
16
+ * `<details>` disclosure box — are behavior-critical and live in the component's
17
+ * scoped `<style>` (per-leaf, NOT consumer-overridable). Only the values below
18
+ * flow through tokens.
19
+ *
20
+ * Override any token at any ancestor scope (`:root`, `.dark`, a wrapper, or the
21
+ * `.rozie-data-table` / `.rozie-data-table-wrap` element). See
22
+ * themes/shadcn.css, themes/material.css and themes/bootstrap.css for the
23
+ * design-system bridges.
24
+ */
25
+ .rozie-data-table-wrap,
26
+ .rozie-data-table {
27
+ /* ── palette (the few values most consumers will set) ───────────────────── */
28
+ --rozie-data-table-fg: inherit;
29
+ --rozie-data-table-accent: #0066cc;
30
+ --rozie-data-table-border-color: rgba(0, 0, 0, 0.08);
31
+ --rozie-data-table-control-border-color: rgba(0, 0, 0, 0.2);
32
+ --rozie-data-table-radius: 4px;
33
+
34
+ /* ── typography / cell metrics ──────────────────────────────────────────── */
35
+ --rozie-data-table-font: 14px system-ui, sans-serif;
36
+ --rozie-data-table-cell-padding: 0.5rem 0.75rem;
37
+
38
+ /* ── header ─────────────────────────────────────────────────────────────── */
39
+ /* OPAQUE (was rgba(0,0,0,0.03)): a translucent header lets the scrolling body bleed
40
+ through in sticky mode. #f7f7f7 ≈ the old 3%-black tint over white, but solid —
41
+ matching the opaque header backgrounds the design-system themes already ship. */
42
+ --rozie-data-table-header-bg: #f7f7f7;
43
+ --rozie-data-table-header-weight: 600;
44
+
45
+ /* ── sort indicator ─────────────────────────────────────────────────────── */
46
+ --rozie-data-table-sort-indicator-opacity: 0.7;
47
+
48
+ /* ── resize handle (req-9) ──────────────────────────────────────────────── */
49
+ --rozie-data-table-resize-grip-color: rgba(0, 0, 0, 0.12);
50
+ --rozie-data-table-resize-grip-active: var(--rozie-data-table-accent);
51
+
52
+ /* ── pin controls (req-11) ──────────────────────────────────────────────── */
53
+ --rozie-data-table-pin-active-bg: rgba(0, 0, 0, 0.1);
54
+
55
+ /* ── column-visibility menu (req-8) ─────────────────────────────────────── */
56
+ --rozie-data-table-menu-bg: #fff;
57
+ --rozie-data-table-menu-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
58
+
59
+ /* ── selection checkboxes (req-7) ───────────────────────────────────────── */
60
+ --rozie-data-table-select-accent: var(--rozie-data-table-accent);
61
+
62
+ /* ── disabled pagination controls ──────────────────────────────────────── */
63
+ --rozie-data-table-disabled-opacity: 0.4;
64
+
65
+ /* ─────────────────────────────────────────────────────────────────────────
66
+ * Wire the PUBLIC tokens onto the INTERNAL `--rdt-*` the component reads. A
67
+ * bridge only needs to remap the public tokens above; these passthroughs do
68
+ * the rest. (The component still renders zero-config without this file via its
69
+ * own inline `var(--rdt-x, <fallback>)` defaults.)
70
+ * ───────────────────────────────────────────────────────────────────────── */
71
+ --rdt-font: var(--rozie-data-table-font);
72
+ --rdt-color: var(--rozie-data-table-fg);
73
+ --rdt-cell-padding: var(--rozie-data-table-cell-padding);
74
+ --rdt-border: 1px solid var(--rozie-data-table-border-color);
75
+ --rdt-header-bg: var(--rozie-data-table-header-bg);
76
+ --rdt-header-weight: var(--rozie-data-table-header-weight);
77
+ --rdt-sort-ind-opacity: var(--rozie-data-table-sort-indicator-opacity);
78
+
79
+ --rdt-filter-border: 1px solid var(--rozie-data-table-control-border-color);
80
+ --rdt-filter-radius: var(--rozie-data-table-radius);
81
+ --rdt-page-btn-border: 1px solid var(--rozie-data-table-control-border-color);
82
+ --rdt-page-btn-radius: var(--rozie-data-table-radius);
83
+ --rdt-page-btn-disabled-opacity: var(--rozie-data-table-disabled-opacity);
84
+ --rdt-page-size-border: 1px solid var(--rozie-data-table-control-border-color);
85
+ --rdt-page-size-radius: var(--rozie-data-table-radius);
86
+
87
+ --rdt-resize-grip-color: var(--rozie-data-table-resize-grip-color);
88
+ --rdt-resize-grip-active: var(--rozie-data-table-resize-grip-active);
89
+
90
+ --rdt-pin-btn-border: 1px solid var(--rozie-data-table-control-border-color);
91
+ --rdt-pin-btn-radius: var(--rozie-data-table-radius);
92
+ --rdt-pin-btn-active-bg: var(--rozie-data-table-pin-active-bg);
93
+
94
+ --rdt-colvis-summary-border: 1px solid var(--rozie-data-table-control-border-color);
95
+ --rdt-colvis-summary-radius: var(--rozie-data-table-radius);
96
+ --rdt-colvis-menu-border: 1px solid var(--rozie-data-table-border-color);
97
+ --rdt-colvis-menu-radius: var(--rozie-data-table-radius);
98
+ --rdt-colvis-menu-bg: var(--rozie-data-table-menu-bg);
99
+ --rdt-colvis-menu-shadow: var(--rozie-data-table-menu-shadow);
100
+
101
+ --rdt-select-accent: var(--rozie-data-table-select-accent);
102
+ }
@@ -0,0 +1,37 @@
1
+ /*
2
+ * @rozie-ui/data-table — Bootstrap 5 bridge.
3
+ *
4
+ * Maps the public `--rozie-data-table-*` tokens onto Bootstrap's `--bs-*` CSS
5
+ * variables (Bootstrap 5.2+). Reading them live means the table follows
6
+ * `data-bs-theme="dark"` and any custom `$primary` build automatically. Falls
7
+ * back to Bootstrap's default light palette when the vars are absent.
8
+ *
9
+ * Import this AFTER base.css (base.css wires the public tokens onto the internal
10
+ * `--rdt-*` the component reads):
11
+ *
12
+ * import '@rozie-ui/data-table-react/themes/base.css';
13
+ * import '@rozie-ui/data-table-react/themes/bootstrap.css';
14
+ */
15
+ .rozie-data-table-wrap,
16
+ .rozie-data-table {
17
+ --rozie-data-table-fg: var(--bs-body-color, #212529);
18
+ --rozie-data-table-accent: var(--bs-primary, #0d6efd);
19
+ --rozie-data-table-border-color: var(--bs-border-color, #dee2e6);
20
+ --rozie-data-table-control-border-color: var(--bs-border-color, #dee2e6);
21
+ --rozie-data-table-radius: var(--bs-border-radius, 0.375rem);
22
+
23
+ --rozie-data-table-header-bg: var(--bs-tertiary-bg, #f8f9fa);
24
+ --rozie-data-table-header-weight: 600;
25
+
26
+ --rozie-data-table-resize-grip-color: var(--bs-border-color, #dee2e6);
27
+ --rozie-data-table-resize-grip-active: var(--bs-primary, #0d6efd);
28
+
29
+ --rozie-data-table-pin-active-bg: var(--bs-secondary-bg, #e9ecef);
30
+
31
+ --rozie-data-table-menu-bg: var(--bs-body-bg, #fff);
32
+ --rozie-data-table-menu-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
33
+
34
+ --rozie-data-table-disabled-opacity: 0.5;
35
+
36
+ --rozie-data-table-select-accent: var(--bs-primary, #0d6efd);
37
+ }
@@ -0,0 +1,35 @@
1
+ /*
2
+ * @rozie-ui/data-table — Material Design 3 bridge.
3
+ *
4
+ * Maps the public `--rozie-data-table-*` tokens onto the MD3 system color roles
5
+ * (`--md-sys-color-*`) emitted by material-web / @material/material-color-utilities
6
+ * theme builders. Falls back to the baseline M3 light palette when those vars are
7
+ * absent, so it renders correctly even without a generated theme.
8
+ *
9
+ * Import this AFTER base.css (base.css wires the public tokens onto the internal
10
+ * `--rdt-*` the component reads):
11
+ *
12
+ * import '@rozie-ui/data-table-react/themes/base.css';
13
+ * import '@rozie-ui/data-table-react/themes/material.css';
14
+ */
15
+ .rozie-data-table-wrap,
16
+ .rozie-data-table {
17
+ --rozie-data-table-fg: var(--md-sys-color-on-surface, #1d1b20);
18
+ --rozie-data-table-accent: var(--md-sys-color-primary, #6750a4);
19
+ --rozie-data-table-border-color: var(--md-sys-color-outline-variant, #cac4d0);
20
+ --rozie-data-table-control-border-color: var(--md-sys-color-outline, #79747e);
21
+ --rozie-data-table-radius: 4px;
22
+
23
+ --rozie-data-table-header-bg: var(--md-sys-color-surface-container-highest, #e6e0e9);
24
+ --rozie-data-table-header-weight: 500;
25
+
26
+ --rozie-data-table-resize-grip-color: var(--md-sys-color-outline-variant, #cac4d0);
27
+ --rozie-data-table-resize-grip-active: var(--md-sys-color-primary, #6750a4);
28
+
29
+ --rozie-data-table-pin-active-bg: var(--md-sys-color-secondary-container, #e8def8);
30
+
31
+ --rozie-data-table-menu-bg: var(--md-sys-color-surface-container, #f3edf7);
32
+ --rozie-data-table-menu-shadow: 0 2px 6px rgb(0 0 0 / 0.3);
33
+
34
+ --rozie-data-table-select-accent: var(--md-sys-color-primary, #6750a4);
35
+ }
@@ -0,0 +1,41 @@
1
+ /*
2
+ * @rozie-ui/data-table — shadcn/ui (Radix) bridge.
3
+ *
4
+ * Maps the public `--rozie-data-table-*` tokens onto the shadcn/ui CSS variables
5
+ * defined on `:root` / `.dark` (the classic HSL-channel convention:
6
+ * `--background: 0 0% 100%` consumed as `hsl(var(--background))`). Because it
7
+ * reads those vars live, the table automatically follows light/dark theme
8
+ * switches and accent changes.
9
+ *
10
+ * import '@rozie-ui/data-table-react/themes/shadcn.css';
11
+ *
12
+ * Import this AFTER base.css (base.css wires the public tokens onto the internal
13
+ * `--rdt-*` the component reads; this file only remaps the public tokens):
14
+ *
15
+ * import '@rozie-ui/data-table-react/themes/base.css';
16
+ * import '@rozie-ui/data-table-react/themes/shadcn.css';
17
+ *
18
+ * If your shadcn setup predates the `hsl()`-wrapping convention (Tailwind v4 /
19
+ * oklch tokens emit pre-formed colors), drop the `hsl(...)` wrappers below.
20
+ */
21
+ .rozie-data-table-wrap,
22
+ .rozie-data-table {
23
+ --rozie-data-table-fg: hsl(var(--foreground, 222.2 47.4% 11.2%));
24
+ --rozie-data-table-accent: hsl(var(--primary, 222.2 47.4% 11.2%));
25
+ --rozie-data-table-border-color: hsl(var(--border, 214.3 31.8% 91.4%));
26
+ --rozie-data-table-control-border-color: hsl(var(--border, 214.3 31.8% 91.4%));
27
+ --rozie-data-table-radius: var(--radius, 0.5rem);
28
+
29
+ --rozie-data-table-header-bg: hsl(var(--muted, 210 40% 96.1%));
30
+ --rozie-data-table-header-weight: 600;
31
+
32
+ --rozie-data-table-resize-grip-color: hsl(var(--border, 214.3 31.8% 91.4%));
33
+ --rozie-data-table-resize-grip-active: hsl(var(--primary, 222.2 47.4% 11.2%));
34
+
35
+ --rozie-data-table-pin-active-bg: hsl(var(--accent, 210 40% 96.1%));
36
+
37
+ --rozie-data-table-menu-bg: hsl(var(--popover, 0 0% 100%));
38
+ --rozie-data-table-menu-shadow: 0 2px 8px rgb(0 0 0 / 0.12);
39
+
40
+ --rozie-data-table-select-accent: hsl(var(--primary, 222.2 47.4% 11.2%));
41
+ }