@crispy-seed/data-table 0.1.1 → 0.1.2

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 (49) hide show
  1. package/dist/index.cjs +4563 -2
  2. package/dist/index.js +4547 -1
  3. package/package.json +1 -1
  4. package/dist/DataTable-12s-D02v6Qj5.js +0 -1523
  5. package/dist/DataTable-12s-Gpv6I4J8.cjs +0 -1574
  6. package/dist/DataTable-12s-Zml1x9Kr-12s-B-mwMBhn.cjs +0 -161
  7. package/dist/DataTable-12s-Zml1x9Kr-12s-BR-yHfob.js +0 -153
  8. package/dist/Menu-12s-A4lEc__n.cjs +0 -103
  9. package/dist/Menu-12s-v9vnaq8F.js +0 -77
  10. package/dist/Select-12s-CE3SMzFp.js +0 -218
  11. package/dist/Select-12s-CNQC9z8t.cjs +0 -249
  12. package/dist/body-cells-12s-2sTwdliH.cjs +0 -461
  13. package/dist/body-cells-12s-Ba2uF4T-.js +0 -452
  14. package/dist/column-calc-12s-C1-I2KdV.js +0 -129
  15. package/dist/column-calc-12s-CJ26VuDJ.cjs +0 -149
  16. package/dist/column-layout-12s-BhQmNTJG.js +0 -99
  17. package/dist/column-layout-12s-k2fZYeKl.cjs +0 -120
  18. package/dist/column-menu-12s-6Yvu4SZ0.js +0 -406
  19. package/dist/column-menu-12s-BnknuXGh.cjs +0 -426
  20. package/dist/editors-12s-C0RxmTcI.cjs +0 -554
  21. package/dist/editors-12s-COixUnI2.js +0 -524
  22. package/dist/resize-12s-CajyNXFB.js +0 -58
  23. package/dist/resize-12s-ChLpxb4i.cjs +0 -58
  24. package/dist/states-12s-BB0PT_bq.cjs +0 -125
  25. package/dist/states-12s-m5mBR90e.js +0 -122
  26. package/dist/toolbar-12s-B1xiS-Zu.js +0 -68
  27. package/dist/toolbar-12s-DzLbghpK.cjs +0 -70
  28. package/dist/useDataTable-12s-BHiDUubw-12s-CBeCwTe7.js +0 -61
  29. package/dist/useDataTable-12s-BHiDUubw-12s-Dgvt7XDk.cjs +0 -61
  30. package/dist/useDataTableColumnCalc-12s-DTQQTtEJ-12s-CvD14JYo.cjs +0 -207
  31. package/dist/useDataTableColumnCalc-12s-DTQQTtEJ-12s-DsEse3uq.js +0 -183
  32. package/dist/useDataTableColumns-12s-Cn2ZAzFL-12s-CD6goR59.js +0 -289
  33. package/dist/useDataTableColumns-12s-Cn2ZAzFL-12s-CUk_CpYT.cjs +0 -292
  34. package/dist/useDataTableEdit-12s-9Wb_UCrN-12s-BoOHq3GB.js +0 -98
  35. package/dist/useDataTableEdit-12s-9Wb_UCrN-12s-De6YHBba.cjs +0 -98
  36. package/dist/useDataTableFilter-12s-ZzbmWMin-12s-CWyBeFna.js +0 -74
  37. package/dist/useDataTableFilter-12s-ZzbmWMin-12s-lpjzZY3_.cjs +0 -74
  38. package/dist/useDataTableInfiniteScroll-12s-8ZG31URd-12s-BexjP6iO.js +0 -104
  39. package/dist/useDataTableInfiniteScroll-12s-8ZG31URd-12s-Bt8gojr9.cjs +0 -104
  40. package/dist/useDataTableRow-12s-CPYaDa1p-12s-4qkGoz-j.js +0 -30
  41. package/dist/useDataTableRow-12s-CPYaDa1p-12s-DG64uYjn.cjs +0 -30
  42. package/dist/useDataTableScroll-12s-BKDCr0en-12s-C7f2vHeG.js +0 -61
  43. package/dist/useDataTableScroll-12s-BKDCr0en-12s-CUvUYMtt.cjs +0 -61
  44. package/dist/useDataTableSearch-12s-Ck3iWcpX-12s-B-65V6gH.js +0 -37
  45. package/dist/useDataTableSearch-12s-Ck3iWcpX-12s-DhVfN2Hq.cjs +0 -37
  46. package/dist/useDataTableSelection-12s-BIDtiRQq-12s-IS__VAnU.cjs +0 -71
  47. package/dist/useDataTableSelection-12s-BIDtiRQq-12s-O6M_BhrH.js +0 -71
  48. package/dist/useDataTableSort-12s-DvJYtmeS-12s-C5VGnsq4.cjs +0 -78
  49. package/dist/useDataTableSort-12s-DvJYtmeS-12s-DABSNt6U.js +0 -78
@@ -1,104 +0,0 @@
1
- 'use client';
2
- function __insertCSS(code) {
3
- if (!code || typeof document == 'undefined') return
4
- let head = document.head || document.getElementsByTagName('head')[0]
5
- let style = document.createElement('style')
6
- style.type = 'text/css'
7
- head.appendChild(style)
8
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
9
- }
10
-
11
- import { useState, useRef, useCallback, useEffect } from 'react';
12
- import { s as shouldTriggerLoadMore } from './useDataTableColumns-12s-Cn2ZAzFL-12s-CD6goR59.js';
13
-
14
- // Triggers before the sentinel is actually on-screen -- Attio's own list prefetches
15
- // a page ahead of the visible edge so the next batch of rows is already there by the
16
- // time a fast scroll reaches them, rather than the user briefly out-running the data.
17
- const ROOT_MARGIN = "160px";
18
- /**
19
- * Owns the "is the user close enough to the bottom to load more" concern -- the way
20
- * useDataTableScroll owns the horizontal scroll-shadow edge state. An
21
- * IntersectionObserver watching a single sentinel row the styled layer renders as the
22
- * last child of `<tbody>` while `hasMore` is true (DataTable.tsx's own
23
- * `InfiniteScrollRow`), observed against `scrollRootRef`'s element (useDataTable.ts
24
- * wires this to useDataTableScroll's own scroll container) so a BOUNDED table
25
- * triggers off its own internal scroll, not the browsing viewport.
26
- */ function useDataTableInfiniteScroll(props) {
27
- const { onLoadMore, hasMore = true, loadingMore: loadingMoreProp, scrollRootRef } = props;
28
- const [internalLoadingMore, setInternalLoadingMore] = useState(false);
29
- const loadingMore = loadingMoreProp ?? internalLoadingMore;
30
- // Mirrors the latest props into a ref the observer callback reads -- the callback
31
- // is registered once per sentinel element (see the effect below) and must not
32
- // recreate the whole IntersectionObserver on every render just because a fresh
33
- // `onLoadMore` closure came in, the same "ref mirrors the latest value" shape a
34
- // debounced/throttled handler needs.
35
- const latest = useRef({
36
- onLoadMore,
37
- hasMore,
38
- loadingMore
39
- });
40
- latest.current = {
41
- onLoadMore,
42
- hasMore,
43
- loadingMore
44
- };
45
- const triggerLoadMore = useCallback(()=>{
46
- const { onLoadMore: fn, hasMore: has, loadingMore: busy } = latest.current;
47
- if (!shouldTriggerLoadMore(true, has, busy) || !fn) return;
48
- const result = fn();
49
- // Only a THENABLE result puts this hook in charge of `loadingMore` -- a
50
- // synchronous `onLoadMore` (already-fetched data, a local page) commits
51
- // immediately and never becomes "busy" at all, matching `loadingMoreProp`'s own
52
- // controlled shape: nothing to suppress a very next scroll-triggered call with.
53
- if (result && typeof result.then === "function") {
54
- if (loadingMoreProp === undefined) setInternalLoadingMore(true);
55
- result.finally(()=>{
56
- if (loadingMoreProp === undefined) setInternalLoadingMore(false);
57
- });
58
- }
59
- }, [
60
- loadingMoreProp
61
- ]);
62
- // A state slot (not a plain ref) so attaching the sentinel re-runs the effect below
63
- // -- a callback ref's own node can't be an effect dependency otherwise.
64
- const [sentinelNode, setSentinelNode] = useState(null);
65
- const sentinelRef = useCallback((node)=>setSentinelNode(node), []);
66
- useEffect(()=>{
67
- if (!sentinelNode || !onLoadMore || typeof IntersectionObserver === "undefined") return;
68
- // Effects run after every ref callback of the SAME commit (including
69
- // `scrollRootRef`'s own, set by useDataTableScroll's `scrollAreaRef`) regardless
70
- // of sibling ref attach order, so `scrollRootRef.current` is already populated
71
- // here even on the very first render that mounts both elements at once. `null`
72
- // (no scroll container yet, or none supplied) falls back to the browsing
73
- // viewport, IntersectionObserver's own default.
74
- const root = scrollRootRef?.current ?? null;
75
- const observer = new IntersectionObserver((entries)=>{
76
- if (entries.some((entry)=>entry.isIntersecting)) triggerLoadMore();
77
- }, {
78
- root,
79
- rootMargin: ROOT_MARGIN
80
- });
81
- observer.observe(sentinelNode);
82
- return ()=>observer.disconnect();
83
- }, [
84
- sentinelNode,
85
- onLoadMore,
86
- scrollRootRef,
87
- triggerLoadMore
88
- ]);
89
- return {
90
- /** Attach to the sentinel row's DOM node (a ref callback, `DataTable.tsx`'s own
91
- * `InfiniteScrollRow`). A no-op (no observer ever created) when `onLoadMore` is
92
- * omitted -- the styled layer still shouldn't render the sentinel at all in that
93
- * case (nothing to load more OF), this is just the inert fallback. */ sentinelRef,
94
- /** Whether to keep rendering the sentinel row at all. */ hasMore,
95
- /** A fetch is in flight -- shows the loading-more spinner row and gates further
96
- * triggers, whichever side (controlled or internal) reports it. */ loadingMore,
97
- /** Fires `onLoadMore` directly, subject to the same `hasMore`/`loadingMore` gate
98
- * the observer itself uses -- exposed for a consumer that wants a manual retry
99
- * affordance (e.g. after a failed load) rather than only the observer's own
100
- * scroll trigger. */ triggerLoadMore
101
- };
102
- }
103
-
104
- export { useDataTableInfiniteScroll as u };
@@ -1,104 +0,0 @@
1
- 'use client';
2
- function __insertCSS(code) {
3
- if (!code || typeof document == 'undefined') return
4
- let head = document.head || document.getElementsByTagName('head')[0]
5
- let style = document.createElement('style')
6
- style.type = 'text/css'
7
- head.appendChild(style)
8
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
9
- }
10
-
11
- var React = require('react');
12
- var useDataTableColumns12sCn2ZAzFL12s = require('./useDataTableColumns-12s-Cn2ZAzFL-12s-CUk_CpYT.cjs');
13
-
14
- // Triggers before the sentinel is actually on-screen -- Attio's own list prefetches
15
- // a page ahead of the visible edge so the next batch of rows is already there by the
16
- // time a fast scroll reaches them, rather than the user briefly out-running the data.
17
- const ROOT_MARGIN = "160px";
18
- /**
19
- * Owns the "is the user close enough to the bottom to load more" concern -- the way
20
- * useDataTableScroll owns the horizontal scroll-shadow edge state. An
21
- * IntersectionObserver watching a single sentinel row the styled layer renders as the
22
- * last child of `<tbody>` while `hasMore` is true (DataTable.tsx's own
23
- * `InfiniteScrollRow`), observed against `scrollRootRef`'s element (useDataTable.ts
24
- * wires this to useDataTableScroll's own scroll container) so a BOUNDED table
25
- * triggers off its own internal scroll, not the browsing viewport.
26
- */ function useDataTableInfiniteScroll(props) {
27
- const { onLoadMore, hasMore = true, loadingMore: loadingMoreProp, scrollRootRef } = props;
28
- const [internalLoadingMore, setInternalLoadingMore] = React.useState(false);
29
- const loadingMore = loadingMoreProp ?? internalLoadingMore;
30
- // Mirrors the latest props into a ref the observer callback reads -- the callback
31
- // is registered once per sentinel element (see the effect below) and must not
32
- // recreate the whole IntersectionObserver on every render just because a fresh
33
- // `onLoadMore` closure came in, the same "ref mirrors the latest value" shape a
34
- // debounced/throttled handler needs.
35
- const latest = React.useRef({
36
- onLoadMore,
37
- hasMore,
38
- loadingMore
39
- });
40
- latest.current = {
41
- onLoadMore,
42
- hasMore,
43
- loadingMore
44
- };
45
- const triggerLoadMore = React.useCallback(()=>{
46
- const { onLoadMore: fn, hasMore: has, loadingMore: busy } = latest.current;
47
- if (!useDataTableColumns12sCn2ZAzFL12s.shouldTriggerLoadMore(true, has, busy) || !fn) return;
48
- const result = fn();
49
- // Only a THENABLE result puts this hook in charge of `loadingMore` -- a
50
- // synchronous `onLoadMore` (already-fetched data, a local page) commits
51
- // immediately and never becomes "busy" at all, matching `loadingMoreProp`'s own
52
- // controlled shape: nothing to suppress a very next scroll-triggered call with.
53
- if (result && typeof result.then === "function") {
54
- if (loadingMoreProp === undefined) setInternalLoadingMore(true);
55
- result.finally(()=>{
56
- if (loadingMoreProp === undefined) setInternalLoadingMore(false);
57
- });
58
- }
59
- }, [
60
- loadingMoreProp
61
- ]);
62
- // A state slot (not a plain ref) so attaching the sentinel re-runs the effect below
63
- // -- a callback ref's own node can't be an effect dependency otherwise.
64
- const [sentinelNode, setSentinelNode] = React.useState(null);
65
- const sentinelRef = React.useCallback((node)=>setSentinelNode(node), []);
66
- React.useEffect(()=>{
67
- if (!sentinelNode || !onLoadMore || typeof IntersectionObserver === "undefined") return;
68
- // Effects run after every ref callback of the SAME commit (including
69
- // `scrollRootRef`'s own, set by useDataTableScroll's `scrollAreaRef`) regardless
70
- // of sibling ref attach order, so `scrollRootRef.current` is already populated
71
- // here even on the very first render that mounts both elements at once. `null`
72
- // (no scroll container yet, or none supplied) falls back to the browsing
73
- // viewport, IntersectionObserver's own default.
74
- const root = scrollRootRef?.current ?? null;
75
- const observer = new IntersectionObserver((entries)=>{
76
- if (entries.some((entry)=>entry.isIntersecting)) triggerLoadMore();
77
- }, {
78
- root,
79
- rootMargin: ROOT_MARGIN
80
- });
81
- observer.observe(sentinelNode);
82
- return ()=>observer.disconnect();
83
- }, [
84
- sentinelNode,
85
- onLoadMore,
86
- scrollRootRef,
87
- triggerLoadMore
88
- ]);
89
- return {
90
- /** Attach to the sentinel row's DOM node (a ref callback, `DataTable.tsx`'s own
91
- * `InfiniteScrollRow`). A no-op (no observer ever created) when `onLoadMore` is
92
- * omitted -- the styled layer still shouldn't render the sentinel at all in that
93
- * case (nothing to load more OF), this is just the inert fallback. */ sentinelRef,
94
- /** Whether to keep rendering the sentinel row at all. */ hasMore,
95
- /** A fetch is in flight -- shows the loading-more spinner row and gates further
96
- * triggers, whichever side (controlled or internal) reports it. */ loadingMore,
97
- /** Fires `onLoadMore` directly, subject to the same `hasMore`/`loadingMore` gate
98
- * the observer itself uses -- exposed for a consumer that wants a manual retry
99
- * affordance (e.g. after a failed load) rather than only the observer's own
100
- * scroll trigger. */ triggerLoadMore
101
- };
102
- }
103
-
104
- exports.useDataTableInfiniteScroll = useDataTableInfiniteScroll;
@@ -1,30 +0,0 @@
1
- 'use client';
2
- function __insertCSS(code) {
3
- if (!code || typeof document == 'undefined') return
4
- let head = document.head || document.getElementsByTagName('head')[0]
5
- let style = document.createElement('style')
6
- style.type = 'text/css'
7
- head.appendChild(style)
8
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
9
- }
10
-
11
- import { u as useDataTableContext } from './DataTable-12s-Zml1x9Kr-12s-BR-yHfob.js';
12
-
13
- // Per-row read of the root's selection state -- the way useSelectItem reads
14
- // `getItemProps` off the root for one option. Kept as its own hook (rather than
15
- // inlined into the styled `DataTableRow`) so `DataTableCell`/`DataTableSelectionCell`
16
- // can read the SAME row's `isSelected`/`toggleRow` through `useDataTableRowContext`
17
- // without either subscribing to the whole table's context or being handed `rowId`
18
- // again as a prop.
19
- function useDataTableRow(props) {
20
- const { rowId } = props;
21
- const { isSelected, toggleRow, getRowProps } = useDataTableContext();
22
- return {
23
- rowId,
24
- isSelected: isSelected(rowId),
25
- toggleRow: ()=>toggleRow(rowId),
26
- rootProps: getRowProps(rowId)
27
- };
28
- }
29
-
30
- export { useDataTableRow as u };
@@ -1,30 +0,0 @@
1
- 'use client';
2
- function __insertCSS(code) {
3
- if (!code || typeof document == 'undefined') return
4
- let head = document.head || document.getElementsByTagName('head')[0]
5
- let style = document.createElement('style')
6
- style.type = 'text/css'
7
- head.appendChild(style)
8
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
9
- }
10
-
11
- var DataTable12sZml1x9Kr12s = require('./DataTable-12s-Zml1x9Kr-12s-B-mwMBhn.cjs');
12
-
13
- // Per-row read of the root's selection state -- the way useSelectItem reads
14
- // `getItemProps` off the root for one option. Kept as its own hook (rather than
15
- // inlined into the styled `DataTableRow`) so `DataTableCell`/`DataTableSelectionCell`
16
- // can read the SAME row's `isSelected`/`toggleRow` through `useDataTableRowContext`
17
- // without either subscribing to the whole table's context or being handed `rowId`
18
- // again as a prop.
19
- function useDataTableRow(props) {
20
- const { rowId } = props;
21
- const { isSelected, toggleRow, getRowProps } = DataTable12sZml1x9Kr12s.useDataTableContext();
22
- return {
23
- rowId,
24
- isSelected: isSelected(rowId),
25
- toggleRow: ()=>toggleRow(rowId),
26
- rootProps: getRowProps(rowId)
27
- };
28
- }
29
-
30
- exports.useDataTableRow = useDataTableRow;
@@ -1,61 +0,0 @@
1
- 'use client';
2
- function __insertCSS(code) {
3
- if (!code || typeof document == 'undefined') return
4
- let head = document.head || document.getElementsByTagName('head')[0]
5
- let style = document.createElement('style')
6
- style.type = 'text/css'
7
- head.appendChild(style)
8
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
9
- }
10
-
11
- import { useRef, useState, useCallback } from 'react';
12
-
13
- /**
14
- * Tracks a horizontally-scrolling element's edge state for the sticky-column scroll
15
- * shadow (DATATABLE-ATTIO-SPEC.md's `stickyFirst`/`stickyLast`) -- crisp's own
16
- * `.crisp-table-scroll[data-scrolled-x]`/`[data-scrolled-x-end]`. Owns the DOM
17
- * measurement the way `useSelectFloating` owns floating-ui's own DOM measurement: a
18
- * real ref to a real scrollable element, re-measured on every scroll (and whenever the
19
- * styled layer calls `remeasure`, e.g. after a column resize/reorder changes the
20
- * scrollable width without the element itself ever firing a `scroll` event).
21
- */ function useDataTableScroll() {
22
- const elementRef = useRef(null);
23
- const [scrolledStart, setScrolledStart] = useState(false);
24
- const [scrolledEnd, setScrolledEnd] = useState(false);
25
- const remeasure = useCallback(()=>{
26
- const element = elementRef.current;
27
- if (!element) return;
28
- setScrolledStart(element.scrollLeft > 0);
29
- // A 1px slop: sub-pixel layout can leave `scrollLeft + clientWidth` a fraction
30
- // short of `scrollWidth` even when fully scrolled, which would otherwise leave
31
- // the trailing shadow stuck on forever.
32
- setScrolledEnd(element.scrollLeft + element.clientWidth < element.scrollWidth - 1);
33
- }, []);
34
- const scrollAreaRef = useCallback((node)=>{
35
- elementRef.current = node;
36
- if (node) remeasure();
37
- }, [
38
- remeasure
39
- ]);
40
- const onScroll = useCallback(()=>remeasure(), [
41
- remeasure
42
- ]);
43
- return {
44
- scrollAreaRef,
45
- scrolledStart,
46
- scrolledEnd,
47
- onScroll,
48
- remeasure,
49
- // The raw ref object itself (not just the callback ref above) -- useDataTable.ts
50
- // hands this to useDataTableInfiniteScroll as the IntersectionObserver `root` for
51
- // its sentinel row, so a scrolled/bounded table (DATATABLE-ATTIO-SPEC.md's
52
- // full-body-height feature) auto-loads against ITS OWN scroll boundary rather
53
- // than the browsing viewport. A stable object identity (a plain ref, not state):
54
- // useDataTableInfiniteScroll reads `.current` inside an effect, which always runs
55
- // after every ref callback of the same commit (including this one), so the
56
- // element is never read before it's attached regardless of sibling ref order.
57
- elementRef
58
- };
59
- }
60
-
61
- export { useDataTableScroll as u };
@@ -1,61 +0,0 @@
1
- 'use client';
2
- function __insertCSS(code) {
3
- if (!code || typeof document == 'undefined') return
4
- let head = document.head || document.getElementsByTagName('head')[0]
5
- let style = document.createElement('style')
6
- style.type = 'text/css'
7
- head.appendChild(style)
8
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
9
- }
10
-
11
- var React = require('react');
12
-
13
- /**
14
- * Tracks a horizontally-scrolling element's edge state for the sticky-column scroll
15
- * shadow (DATATABLE-ATTIO-SPEC.md's `stickyFirst`/`stickyLast`) -- crisp's own
16
- * `.crisp-table-scroll[data-scrolled-x]`/`[data-scrolled-x-end]`. Owns the DOM
17
- * measurement the way `useSelectFloating` owns floating-ui's own DOM measurement: a
18
- * real ref to a real scrollable element, re-measured on every scroll (and whenever the
19
- * styled layer calls `remeasure`, e.g. after a column resize/reorder changes the
20
- * scrollable width without the element itself ever firing a `scroll` event).
21
- */ function useDataTableScroll() {
22
- const elementRef = React.useRef(null);
23
- const [scrolledStart, setScrolledStart] = React.useState(false);
24
- const [scrolledEnd, setScrolledEnd] = React.useState(false);
25
- const remeasure = React.useCallback(()=>{
26
- const element = elementRef.current;
27
- if (!element) return;
28
- setScrolledStart(element.scrollLeft > 0);
29
- // A 1px slop: sub-pixel layout can leave `scrollLeft + clientWidth` a fraction
30
- // short of `scrollWidth` even when fully scrolled, which would otherwise leave
31
- // the trailing shadow stuck on forever.
32
- setScrolledEnd(element.scrollLeft + element.clientWidth < element.scrollWidth - 1);
33
- }, []);
34
- const scrollAreaRef = React.useCallback((node)=>{
35
- elementRef.current = node;
36
- if (node) remeasure();
37
- }, [
38
- remeasure
39
- ]);
40
- const onScroll = React.useCallback(()=>remeasure(), [
41
- remeasure
42
- ]);
43
- return {
44
- scrollAreaRef,
45
- scrolledStart,
46
- scrolledEnd,
47
- onScroll,
48
- remeasure,
49
- // The raw ref object itself (not just the callback ref above) -- useDataTable.ts
50
- // hands this to useDataTableInfiniteScroll as the IntersectionObserver `root` for
51
- // its sentinel row, so a scrolled/bounded table (DATATABLE-ATTIO-SPEC.md's
52
- // full-body-height feature) auto-loads against ITS OWN scroll boundary rather
53
- // than the browsing viewport. A stable object identity (a plain ref, not state):
54
- // useDataTableInfiniteScroll reads `.current` inside an effect, which always runs
55
- // after every ref callback of the same commit (including this one), so the
56
- // element is never read before it's attached regardless of sibling ref order.
57
- elementRef
58
- };
59
- }
60
-
61
- exports.useDataTableScroll = useDataTableScroll;
@@ -1,37 +0,0 @@
1
- 'use client';
2
- function __insertCSS(code) {
3
- if (!code || typeof document == 'undefined') return
4
- let head = document.head || document.getElementsByTagName('head')[0]
5
- let style = document.createElement('style')
6
- style.type = 'text/css'
7
- head.appendChild(style)
8
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
9
- }
10
-
11
- import { d as useControllableState } from './useDataTableColumnCalc-12s-DTQQTtEJ-12s-DsEse3uq.js';
12
- import { useCallback } from 'react';
13
-
14
- // Owns the toolbar's single free-text query -- the way useDataTableSort owns the single
15
- // active sort column. It has no idea which columns are searchable or how a row's value
16
- // is read off them (that needs `TRow`, a type this headless package never sees), so
17
- // narrowing `data` against the query is the styled layer's job (DataTable.tsx's
18
- // `getVisibleRows`) -- the same split sort already draws: this hook tracks WHICH state
19
- // is active, the styled layer decides what that state does to the rows.
20
- function useDataTableSearch(props) {
21
- const { query: queryProp, defaultQuery = "", onQueryChange } = props;
22
- const [query = "", setQuery] = useControllableState({
23
- prop: queryProp,
24
- defaultProp: defaultQuery,
25
- onChange: onQueryChange
26
- });
27
- const clearQuery = useCallback(()=>setQuery(""), [
28
- setQuery
29
- ]);
30
- return {
31
- query,
32
- setQuery,
33
- clearQuery
34
- };
35
- }
36
-
37
- export { useDataTableSearch as u };
@@ -1,37 +0,0 @@
1
- 'use client';
2
- function __insertCSS(code) {
3
- if (!code || typeof document == 'undefined') return
4
- let head = document.head || document.getElementsByTagName('head')[0]
5
- let style = document.createElement('style')
6
- style.type = 'text/css'
7
- head.appendChild(style)
8
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
9
- }
10
-
11
- var useDataTableColumnCalc12sDTQQTtEJ12s = require('./useDataTableColumnCalc-12s-DTQQTtEJ-12s-CvD14JYo.cjs');
12
- var React = require('react');
13
-
14
- // Owns the toolbar's single free-text query -- the way useDataTableSort owns the single
15
- // active sort column. It has no idea which columns are searchable or how a row's value
16
- // is read off them (that needs `TRow`, a type this headless package never sees), so
17
- // narrowing `data` against the query is the styled layer's job (DataTable.tsx's
18
- // `getVisibleRows`) -- the same split sort already draws: this hook tracks WHICH state
19
- // is active, the styled layer decides what that state does to the rows.
20
- function useDataTableSearch(props) {
21
- const { query: queryProp, defaultQuery = "", onQueryChange } = props;
22
- const [query = "", setQuery] = useDataTableColumnCalc12sDTQQTtEJ12s.useControllableState({
23
- prop: queryProp,
24
- defaultProp: defaultQuery,
25
- onChange: onQueryChange
26
- });
27
- const clearQuery = React.useCallback(()=>setQuery(""), [
28
- setQuery
29
- ]);
30
- return {
31
- query,
32
- setQuery,
33
- clearQuery
34
- };
35
- }
36
-
37
- exports.useDataTableSearch = useDataTableSearch;
@@ -1,71 +0,0 @@
1
- 'use client';
2
- function __insertCSS(code) {
3
- if (!code || typeof document == 'undefined') return
4
- let head = document.head || document.getElementsByTagName('head')[0]
5
- let style = document.createElement('style')
6
- style.type = 'text/css'
7
- head.appendChild(style)
8
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
9
- }
10
-
11
- var useDataTableColumnCalc12sDTQQTtEJ12s = require('./useDataTableColumnCalc-12s-DTQQTtEJ-12s-CvD14JYo.cjs');
12
- var domUtils = require('@seed-design/dom-utils');
13
- var React = require('react');
14
- var useDataTableColumns12sCn2ZAzFL12s = require('./useDataTableColumns-12s-Cn2ZAzFL-12s-CUk_CpYT.cjs');
15
-
16
- // Owns the selected-id set and its two shapes of toggle (one row, select-all) --
17
- // the way useSelectOptions owns the selected VALUE. `selectionState` and `toggleAll`
18
- // are always computed against `rowIds` (the currently rendered order), never against
19
- // `selectedIds` alone -- see dom.ts's `computeSelectionState` doc comment.
20
- function useDataTableSelection(props) {
21
- const { rowIds = [], selectable = false, selectedIds: selectedIdsProp, defaultSelectedIds = [], onSelectionChange } = props;
22
- const [selectedIds = [], setSelectedIds] = useDataTableColumnCalc12sDTQQTtEJ12s.useControllableState({
23
- prop: selectedIdsProp,
24
- defaultProp: defaultSelectedIds,
25
- onChange: onSelectionChange
26
- });
27
- const selectedIdSet = React.useMemo(()=>new Set(selectedIds), [
28
- selectedIds
29
- ]);
30
- const isSelected = React.useCallback((id)=>selectedIdSet.has(id), [
31
- selectedIdSet
32
- ]);
33
- const toggleRow = React.useCallback((id)=>{
34
- setSelectedIds((current = [])=>useDataTableColumns12sCn2ZAzFL12s.toggleMembership(current, id));
35
- }, [
36
- setSelectedIds
37
- ]);
38
- const selectionState = React.useMemo(()=>useDataTableColumns12sCn2ZAzFL12s.computeSelectionState(rowIds, selectedIds), [
39
- rowIds,
40
- selectedIds
41
- ]);
42
- const toggleAll = React.useCallback(()=>{
43
- setSelectedIds(selectionState === "all" ? [] : rowIds);
44
- }, [
45
- selectionState,
46
- rowIds,
47
- setSelectedIds
48
- ]);
49
- const getRowProps = React.useCallback((rowId)=>{
50
- const isRowSelected = isSelected(rowId);
51
- return domUtils.elementProps({
52
- role: "row",
53
- "aria-selected": domUtils.ariaAttr(isRowSelected),
54
- "data-selected": domUtils.dataAttr(isRowSelected)
55
- });
56
- }, [
57
- isSelected
58
- ]);
59
- return {
60
- selectable,
61
- rowIds,
62
- selectedIds,
63
- selectionState,
64
- isSelected,
65
- toggleRow,
66
- toggleAll,
67
- getRowProps
68
- };
69
- }
70
-
71
- exports.useDataTableSelection = useDataTableSelection;
@@ -1,71 +0,0 @@
1
- 'use client';
2
- function __insertCSS(code) {
3
- if (!code || typeof document == 'undefined') return
4
- let head = document.head || document.getElementsByTagName('head')[0]
5
- let style = document.createElement('style')
6
- style.type = 'text/css'
7
- head.appendChild(style)
8
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
9
- }
10
-
11
- import { d as useControllableState } from './useDataTableColumnCalc-12s-DTQQTtEJ-12s-DsEse3uq.js';
12
- import { elementProps, dataAttr, ariaAttr } from '@seed-design/dom-utils';
13
- import { useMemo, useCallback } from 'react';
14
- import { t as toggleMembership, c as computeSelectionState } from './useDataTableColumns-12s-Cn2ZAzFL-12s-CD6goR59.js';
15
-
16
- // Owns the selected-id set and its two shapes of toggle (one row, select-all) --
17
- // the way useSelectOptions owns the selected VALUE. `selectionState` and `toggleAll`
18
- // are always computed against `rowIds` (the currently rendered order), never against
19
- // `selectedIds` alone -- see dom.ts's `computeSelectionState` doc comment.
20
- function useDataTableSelection(props) {
21
- const { rowIds = [], selectable = false, selectedIds: selectedIdsProp, defaultSelectedIds = [], onSelectionChange } = props;
22
- const [selectedIds = [], setSelectedIds] = useControllableState({
23
- prop: selectedIdsProp,
24
- defaultProp: defaultSelectedIds,
25
- onChange: onSelectionChange
26
- });
27
- const selectedIdSet = useMemo(()=>new Set(selectedIds), [
28
- selectedIds
29
- ]);
30
- const isSelected = useCallback((id)=>selectedIdSet.has(id), [
31
- selectedIdSet
32
- ]);
33
- const toggleRow = useCallback((id)=>{
34
- setSelectedIds((current = [])=>toggleMembership(current, id));
35
- }, [
36
- setSelectedIds
37
- ]);
38
- const selectionState = useMemo(()=>computeSelectionState(rowIds, selectedIds), [
39
- rowIds,
40
- selectedIds
41
- ]);
42
- const toggleAll = useCallback(()=>{
43
- setSelectedIds(selectionState === "all" ? [] : rowIds);
44
- }, [
45
- selectionState,
46
- rowIds,
47
- setSelectedIds
48
- ]);
49
- const getRowProps = useCallback((rowId)=>{
50
- const isRowSelected = isSelected(rowId);
51
- return elementProps({
52
- role: "row",
53
- "aria-selected": ariaAttr(isRowSelected),
54
- "data-selected": dataAttr(isRowSelected)
55
- });
56
- }, [
57
- isSelected
58
- ]);
59
- return {
60
- selectable,
61
- rowIds,
62
- selectedIds,
63
- selectionState,
64
- isSelected,
65
- toggleRow,
66
- toggleAll,
67
- getRowProps
68
- };
69
- }
70
-
71
- export { useDataTableSelection as u };