@cerberus-design/data-grid 0.25.3
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.
- package/LICENSE +201 -0
- package/README.md +35 -0
- package/dist/column-helpers.cjs +24 -0
- package/dist/column-helpers.d.cts +45 -0
- package/dist/column-helpers.d.ts +45 -0
- package/dist/column-helpers.js +20 -0
- package/dist/components/cerby-data-grid.client.cjs +14 -0
- package/dist/components/cerby-data-grid.client.d.cts +6 -0
- package/dist/components/cerby-data-grid.client.d.ts +6 -0
- package/dist/components/cerby-data-grid.client.js +10 -0
- package/dist/components/count-menu.client.cjs +52 -0
- package/dist/components/count-menu.client.d.cts +6 -0
- package/dist/components/count-menu.client.d.ts +6 -0
- package/dist/components/count-menu.client.js +48 -0
- package/dist/components/data-grid.client.cjs +85 -0
- package/dist/components/data-grid.client.d.cts +4 -0
- package/dist/components/data-grid.client.d.ts +4 -0
- package/dist/components/data-grid.client.js +81 -0
- package/dist/components/features.client.cjs +79 -0
- package/dist/components/features.client.d.cts +2 -0
- package/dist/components/features.client.d.ts +2 -0
- package/dist/components/features.client.js +75 -0
- package/dist/components/grid.client.cjs +319 -0
- package/dist/components/grid.client.d.cts +19 -0
- package/dist/components/grid.client.d.ts +19 -0
- package/dist/components/grid.client.js +312 -0
- package/dist/components/pagination.client.cjs +116 -0
- package/dist/components/pagination.client.d.cts +1 -0
- package/dist/components/pagination.client.d.ts +1 -0
- package/dist/components/pagination.client.js +112 -0
- package/dist/components/pinned-items.client.cjs +70 -0
- package/dist/components/pinned-items.client.d.cts +5 -0
- package/dist/components/pinned-items.client.d.ts +5 -0
- package/dist/components/pinned-items.client.js +66 -0
- package/dist/components/sort-items.client.cjs +58 -0
- package/dist/components/sort-items.client.d.cts +4 -0
- package/dist/components/sort-items.client.d.ts +4 -0
- package/dist/components/sort-items.client.js +54 -0
- package/dist/const.cjs +49 -0
- package/dist/const.d.cts +28 -0
- package/dist/const.d.ts +28 -0
- package/dist/const.js +33 -0
- package/dist/context.client.cjs +18 -0
- package/dist/context.client.d.cts +7 -0
- package/dist/context.client.d.ts +7 -0
- package/dist/context.client.js +13 -0
- package/dist/hooks.client.cjs +29 -0
- package/dist/hooks.client.d.cts +7 -0
- package/dist/hooks.client.d.ts +7 -0
- package/dist/hooks.client.js +23 -0
- package/dist/index.cjs +15 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +4 -0
- package/dist/store.cjs +287 -0
- package/dist/store.d.cts +6 -0
- package/dist/store.d.ts +6 -0
- package/dist/store.js +283 -0
- package/dist/types.d.cts +198 -0
- package/dist/types.d.ts +198 -0
- package/dist/utils.cjs +59 -0
- package/dist/utils.d.cts +6 -0
- package/dist/utils.d.ts +6 -0
- package/dist/utils.js +51 -0
- package/dist/virtualizer.client.cjs +56 -0
- package/dist/virtualizer.client.d.cts +11 -0
- package/dist/virtualizer.client.d.ts +11 -0
- package/dist/virtualizer.client.js +52 -0
- package/package.json +72 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Show } from '@cerberus-design/react';
|
|
4
|
+
import { useSignal, createEffect } from '@cerberus-design/signals';
|
|
5
|
+
import { memo, useMemo, useRef, useEffect } from 'react';
|
|
6
|
+
import { HStack, Stack } from 'styled-system/jsx';
|
|
7
|
+
import { PARTS, SCOPE } from '../const.js';
|
|
8
|
+
import { DataGridProvider } from '../context.client.js';
|
|
9
|
+
import { createGridStore } from '../store.js';
|
|
10
|
+
import { GridViewport } from './grid.client.js';
|
|
11
|
+
import { GridPagination } from './pagination.client.js';
|
|
12
|
+
|
|
13
|
+
function DataGridEl(props) {
|
|
14
|
+
const { data } = props;
|
|
15
|
+
const store = useMemo(
|
|
16
|
+
() => createGridStore({
|
|
17
|
+
data,
|
|
18
|
+
columns: props.columns,
|
|
19
|
+
initialState: props.initialState,
|
|
20
|
+
rowSize: props.rowSize,
|
|
21
|
+
onPageChange: props.onPageChange
|
|
22
|
+
}),
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
[]
|
|
25
|
+
);
|
|
26
|
+
const [ready, setReady] = useSignal(false);
|
|
27
|
+
const rootRef = useRef(null);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
store.updateData(data);
|
|
30
|
+
}, [data, store]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const el = rootRef.current;
|
|
33
|
+
if (!el) return;
|
|
34
|
+
const observer = new ResizeObserver((entries) => {
|
|
35
|
+
for (const entry of entries) {
|
|
36
|
+
store.setContainerWidth(entry.contentRect.width);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
observer.observe(el);
|
|
40
|
+
const cleanupSignalEffect = createEffect(() => {
|
|
41
|
+
Object.entries(store.rootCssVars()).forEach(([key, val]) => {
|
|
42
|
+
el.style.setProperty(key, val);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
setReady(true);
|
|
46
|
+
return () => {
|
|
47
|
+
observer.disconnect();
|
|
48
|
+
cleanupSignalEffect();
|
|
49
|
+
};
|
|
50
|
+
}, [store, setReady]);
|
|
51
|
+
return /* @__PURE__ */ jsxs(DataGridProvider, { createStore: () => store, children: [
|
|
52
|
+
/* @__PURE__ */ jsx(Show, { when: props.toolbar, children: () => /* @__PURE__ */ jsx(HStack, { "data-scope": SCOPE, "data-part": PARTS.TOOLBAR, w: "full", children: props.toolbar }) }),
|
|
53
|
+
/* @__PURE__ */ jsxs(
|
|
54
|
+
Stack,
|
|
55
|
+
{
|
|
56
|
+
"data-scope": SCOPE,
|
|
57
|
+
"data-part": PARTS.ROOT,
|
|
58
|
+
dir: "columns",
|
|
59
|
+
maxH: "inherit",
|
|
60
|
+
minH: "inherit",
|
|
61
|
+
gap: "0",
|
|
62
|
+
h: "full",
|
|
63
|
+
bgColor: "page.surface.100/55",
|
|
64
|
+
border: "1px solid",
|
|
65
|
+
borderColor: "page.border.initial",
|
|
66
|
+
rounded: "lg",
|
|
67
|
+
overflow: "hidden",
|
|
68
|
+
w: "full",
|
|
69
|
+
ref: rootRef,
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ jsx(Show, { when: ready, children: () => /* @__PURE__ */ jsx(GridViewport, {}) }),
|
|
72
|
+
/* @__PURE__ */ jsx(Show, { when: props.footer, children: () => /* @__PURE__ */ jsx(HStack, { "data-scope": SCOPE, "data-part": PARTS.FOOTER, w: "full", children: props.footer }) }),
|
|
73
|
+
/* @__PURE__ */ jsx(GridPagination, {})
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
] });
|
|
78
|
+
}
|
|
79
|
+
const DataGrid = memo(DataGridEl);
|
|
80
|
+
|
|
81
|
+
export { DataGrid };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
const react = require('@cerberus-design/react');
|
|
8
|
+
const signals = require('@cerberus-design/signals');
|
|
9
|
+
const react$1 = require('react');
|
|
10
|
+
const context_client = require('../context.client.cjs');
|
|
11
|
+
const pinnedItems_client = require('./pinned-items.client.cjs');
|
|
12
|
+
const sortItems_client = require('./sort-items.client.cjs');
|
|
13
|
+
|
|
14
|
+
function HeaderCellOptions(props) {
|
|
15
|
+
const store = context_client.useDataGridContext();
|
|
16
|
+
const sorting = signals.useRead(store.sorting);
|
|
17
|
+
const { icons } = react.useCerberusContext();
|
|
18
|
+
const MoreOptionsIcon = icons.moreVertical;
|
|
19
|
+
const sortedVal = react$1.useMemo(() => {
|
|
20
|
+
const idx = sorting.findIndex((data) => data.id === props.id);
|
|
21
|
+
if (idx === -1) return void 0;
|
|
22
|
+
return sorting[idx];
|
|
23
|
+
}, [sorting, props.id]);
|
|
24
|
+
function handleSelect(details) {
|
|
25
|
+
const val = details.value;
|
|
26
|
+
const specialVal = val.split("_");
|
|
27
|
+
const category = specialVal[0];
|
|
28
|
+
const action = specialVal[1];
|
|
29
|
+
if (val === "filter") {
|
|
30
|
+
return console.log("Show Filter popover...");
|
|
31
|
+
}
|
|
32
|
+
if (val === "unsort") {
|
|
33
|
+
return store.setSort(props.id, null);
|
|
34
|
+
}
|
|
35
|
+
switch (category) {
|
|
36
|
+
case "pin":
|
|
37
|
+
return store.togglePinned(props.id, action);
|
|
38
|
+
case "unpin":
|
|
39
|
+
return store.togglePinned(props.id, false);
|
|
40
|
+
case "sort":
|
|
41
|
+
return store.setSort(props.id, action ?? null);
|
|
42
|
+
default:
|
|
43
|
+
console.error("Unhandled action:", { details, action });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (!props.sortable && !props.pinnable && !props.filterable) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Menu, { onSelect: handleSelect, children: [
|
|
50
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.MenuTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
51
|
+
react.IconButton,
|
|
52
|
+
{
|
|
53
|
+
ariaLabel: "View more options",
|
|
54
|
+
size: "sm",
|
|
55
|
+
opacity: {
|
|
56
|
+
base: 1,
|
|
57
|
+
md: 0
|
|
58
|
+
},
|
|
59
|
+
transitionProperty: "opacity",
|
|
60
|
+
transitionDuration: "fast",
|
|
61
|
+
_groupHover: { opacity: 1 },
|
|
62
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MoreOptionsIcon, {})
|
|
63
|
+
}
|
|
64
|
+
) }),
|
|
65
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.MenuContent, { children: [
|
|
66
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Show, { when: props.sortable, children: /* @__PURE__ */ jsxRuntime.jsx(sortItems_client.MatchSortItems, { sorting: sortedVal }) }),
|
|
67
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Show, { when: props.pinnable, children: [
|
|
68
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Show, { when: props.sortable, children: /* @__PURE__ */ jsxRuntime.jsx(react.MenuSeparator, {}) }),
|
|
69
|
+
/* @__PURE__ */ jsxRuntime.jsx(pinnedItems_client.MatchPinnedItems, { pinned: props.pinned })
|
|
70
|
+
] }),
|
|
71
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Show, { when: props.filterable, children: [
|
|
72
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.MenuSeparator, {}),
|
|
73
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.MenuItem, { value: "filter", children: "Filter" })
|
|
74
|
+
] })
|
|
75
|
+
] })
|
|
76
|
+
] });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
exports.HeaderCellOptions = HeaderCellOptions;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useCerberusContext, Menu, MenuTrigger, IconButton, MenuContent, Show, MenuSeparator, MenuItem } from '@cerberus-design/react';
|
|
4
|
+
import { useRead } from '@cerberus-design/signals';
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
import { useDataGridContext } from '../context.client.js';
|
|
7
|
+
import { MatchPinnedItems } from './pinned-items.client.js';
|
|
8
|
+
import { MatchSortItems } from './sort-items.client.js';
|
|
9
|
+
|
|
10
|
+
function HeaderCellOptions(props) {
|
|
11
|
+
const store = useDataGridContext();
|
|
12
|
+
const sorting = useRead(store.sorting);
|
|
13
|
+
const { icons } = useCerberusContext();
|
|
14
|
+
const MoreOptionsIcon = icons.moreVertical;
|
|
15
|
+
const sortedVal = useMemo(() => {
|
|
16
|
+
const idx = sorting.findIndex((data) => data.id === props.id);
|
|
17
|
+
if (idx === -1) return void 0;
|
|
18
|
+
return sorting[idx];
|
|
19
|
+
}, [sorting, props.id]);
|
|
20
|
+
function handleSelect(details) {
|
|
21
|
+
const val = details.value;
|
|
22
|
+
const specialVal = val.split("_");
|
|
23
|
+
const category = specialVal[0];
|
|
24
|
+
const action = specialVal[1];
|
|
25
|
+
if (val === "filter") {
|
|
26
|
+
return console.log("Show Filter popover...");
|
|
27
|
+
}
|
|
28
|
+
if (val === "unsort") {
|
|
29
|
+
return store.setSort(props.id, null);
|
|
30
|
+
}
|
|
31
|
+
switch (category) {
|
|
32
|
+
case "pin":
|
|
33
|
+
return store.togglePinned(props.id, action);
|
|
34
|
+
case "unpin":
|
|
35
|
+
return store.togglePinned(props.id, false);
|
|
36
|
+
case "sort":
|
|
37
|
+
return store.setSort(props.id, action ?? null);
|
|
38
|
+
default:
|
|
39
|
+
console.error("Unhandled action:", { details, action });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (!props.sortable && !props.pinnable && !props.filterable) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return /* @__PURE__ */ jsxs(Menu, { onSelect: handleSelect, children: [
|
|
46
|
+
/* @__PURE__ */ jsx(MenuTrigger, { children: /* @__PURE__ */ jsx(
|
|
47
|
+
IconButton,
|
|
48
|
+
{
|
|
49
|
+
ariaLabel: "View more options",
|
|
50
|
+
size: "sm",
|
|
51
|
+
opacity: {
|
|
52
|
+
base: 1,
|
|
53
|
+
md: 0
|
|
54
|
+
},
|
|
55
|
+
transitionProperty: "opacity",
|
|
56
|
+
transitionDuration: "fast",
|
|
57
|
+
_groupHover: { opacity: 1 },
|
|
58
|
+
children: /* @__PURE__ */ jsx(MoreOptionsIcon, {})
|
|
59
|
+
}
|
|
60
|
+
) }),
|
|
61
|
+
/* @__PURE__ */ jsxs(MenuContent, { children: [
|
|
62
|
+
/* @__PURE__ */ jsx(Show, { when: props.sortable, children: /* @__PURE__ */ jsx(MatchSortItems, { sorting: sortedVal }) }),
|
|
63
|
+
/* @__PURE__ */ jsxs(Show, { when: props.pinnable, children: [
|
|
64
|
+
/* @__PURE__ */ jsx(Show, { when: props.sortable, children: /* @__PURE__ */ jsx(MenuSeparator, {}) }),
|
|
65
|
+
/* @__PURE__ */ jsx(MatchPinnedItems, { pinned: props.pinned })
|
|
66
|
+
] }),
|
|
67
|
+
/* @__PURE__ */ jsxs(Show, { when: props.filterable, children: [
|
|
68
|
+
/* @__PURE__ */ jsx(MenuSeparator, {}),
|
|
69
|
+
/* @__PURE__ */ jsx(MenuItem, { value: "filter", children: "Filter" })
|
|
70
|
+
] })
|
|
71
|
+
] })
|
|
72
|
+
] });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { HeaderCellOptions };
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
const react$1 = require('@cerberus-design/react');
|
|
8
|
+
const signals = require('@cerberus-design/signals');
|
|
9
|
+
const react = require('react');
|
|
10
|
+
const jsx = require('styled-system/jsx');
|
|
11
|
+
const _const = require('../const.cjs');
|
|
12
|
+
const context_client = require('../context.client.cjs');
|
|
13
|
+
const hooks_client = require('../hooks.client.cjs');
|
|
14
|
+
const virtualizer_client = require('../virtualizer.client.cjs');
|
|
15
|
+
const features_client = require('./features.client.cjs');
|
|
16
|
+
|
|
17
|
+
function GridViewport() {
|
|
18
|
+
const viewportRef = react.useRef(null);
|
|
19
|
+
const store = context_client.useDataGridContext();
|
|
20
|
+
const { virtualRows, totalHeight } = virtualizer_client.useVirtualizer(store, viewportRef);
|
|
21
|
+
const columns = signals.useRead(store.columns);
|
|
22
|
+
const isServerPaginated = signals.useRead(store.isServerPaginated);
|
|
23
|
+
const staticRows = signals.useRead(store.rows);
|
|
24
|
+
const currentPageRange = signals.useRead(store.currentPageRange);
|
|
25
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
26
|
+
jsx.Scrollable,
|
|
27
|
+
{
|
|
28
|
+
hideScrollbar: true,
|
|
29
|
+
"data-scope": _const.SCOPE,
|
|
30
|
+
"data-part": _const.PARTS.VIEWPORT,
|
|
31
|
+
h: "full",
|
|
32
|
+
minH: "0",
|
|
33
|
+
minW: "full",
|
|
34
|
+
pos: "relative",
|
|
35
|
+
w: "full",
|
|
36
|
+
ref: viewportRef,
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
39
|
+
jsx.Box,
|
|
40
|
+
{
|
|
41
|
+
role: "grid",
|
|
42
|
+
"aria-rowcount": staticRows.length + 1,
|
|
43
|
+
"aria-colcount": columns.length,
|
|
44
|
+
h: "var(--row-height)",
|
|
45
|
+
pos: "sticky",
|
|
46
|
+
top: "0",
|
|
47
|
+
w: "var(--total-grid-width)",
|
|
48
|
+
zIndex: "sticky",
|
|
49
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
50
|
+
jsx.HStack,
|
|
51
|
+
{
|
|
52
|
+
"aria-rowIndex": "1",
|
|
53
|
+
role: "rowgroup",
|
|
54
|
+
gap: "0",
|
|
55
|
+
h: "full",
|
|
56
|
+
pos: "relative",
|
|
57
|
+
w: "full",
|
|
58
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(react$1.For, { each: columns, children: (col) => /* @__PURE__ */ jsxRuntime.jsx(react$1.Show, { when: col.isVisible(), children: () => /* @__PURE__ */ jsxRuntime.jsx(GridHeaderCell, { column: col }) }, col.id) })
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
64
|
+
react$1.Show,
|
|
65
|
+
{
|
|
66
|
+
when: isServerPaginated,
|
|
67
|
+
fallback: /* @__PURE__ */ jsxRuntime.jsx(
|
|
68
|
+
jsx.Box,
|
|
69
|
+
{
|
|
70
|
+
pos: "relative",
|
|
71
|
+
w: "var(--total-grid-width)",
|
|
72
|
+
style: {
|
|
73
|
+
height: `${totalHeight}px`
|
|
74
|
+
},
|
|
75
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(react$1.For, { each: virtualRows, children: (vRow) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
76
|
+
GridRow,
|
|
77
|
+
{
|
|
78
|
+
row: vRow.data,
|
|
79
|
+
index: vRow.index,
|
|
80
|
+
offsetY: vRow.offsetY
|
|
81
|
+
},
|
|
82
|
+
vRow.index
|
|
83
|
+
) })
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
children: () => /* @__PURE__ */ jsxRuntime.jsx(jsx.Stack, { direction: "column", gap: "0", w: "var(--total-grid-width)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
87
|
+
react$1.For,
|
|
88
|
+
{
|
|
89
|
+
each: staticRows.slice(
|
|
90
|
+
currentPageRange.start,
|
|
91
|
+
currentPageRange.end
|
|
92
|
+
),
|
|
93
|
+
children: (row, index) => /* @__PURE__ */ jsxRuntime.jsx(GridRow, { row, index }, index)
|
|
94
|
+
}
|
|
95
|
+
) })
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
const GridHeaderCell = react.memo(function GridHeaderCell2(props) {
|
|
103
|
+
const { column } = props;
|
|
104
|
+
const store = context_client.useDataGridContext();
|
|
105
|
+
const { icons } = react$1.useCerberusContext();
|
|
106
|
+
const pinnedVal = signals.useRead(column.pinned);
|
|
107
|
+
const sortingVal = signals.useRead(store.sorting);
|
|
108
|
+
const pinnedState = hooks_client.usePinnedState(pinnedVal);
|
|
109
|
+
const pinnedAttr = hooks_client.usePinnedAttribute(pinnedVal);
|
|
110
|
+
const style = hooks_client.useColumnStyles(column, pinnedVal);
|
|
111
|
+
const isSortedDesc = react.useMemo(() => {
|
|
112
|
+
const result = sortingVal.find((item) => item.id === column.id);
|
|
113
|
+
if (result) return result.desc;
|
|
114
|
+
return false;
|
|
115
|
+
}, [sortingVal, column.id]);
|
|
116
|
+
const SortAscIcon = icons.sortAsc;
|
|
117
|
+
const SortDescIcon = icons.sortDesc;
|
|
118
|
+
function handleToggleSorting(e) {
|
|
119
|
+
store.toggleSort(column.id, e.shiftKey);
|
|
120
|
+
}
|
|
121
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
122
|
+
jsx.HStack,
|
|
123
|
+
{
|
|
124
|
+
role: "columnheader",
|
|
125
|
+
"data-scope": _const.SCOPE,
|
|
126
|
+
"data-part": _const.PARTS.HEAD_CELL,
|
|
127
|
+
"data-state": pinnedState,
|
|
128
|
+
"data-col": column.id,
|
|
129
|
+
...pinnedAttr,
|
|
130
|
+
bgColor: "page.bg.initial",
|
|
131
|
+
borderBottom: "1px solid",
|
|
132
|
+
borderColor: "page.border.200",
|
|
133
|
+
h: "full",
|
|
134
|
+
justify: "space-between",
|
|
135
|
+
pos: "relative",
|
|
136
|
+
px: "md",
|
|
137
|
+
userSelect: "none",
|
|
138
|
+
textAlign: "left",
|
|
139
|
+
textStyle: "label-md",
|
|
140
|
+
verticalAlign: "middle",
|
|
141
|
+
w: "full",
|
|
142
|
+
zIndex: "10",
|
|
143
|
+
_first: {
|
|
144
|
+
borderTopLeftRadius: "md"
|
|
145
|
+
},
|
|
146
|
+
_last: {
|
|
147
|
+
borderTopRightRadius: "md"
|
|
148
|
+
},
|
|
149
|
+
_pinned: {
|
|
150
|
+
pos: "sticky",
|
|
151
|
+
zIndex: 20
|
|
152
|
+
},
|
|
153
|
+
_leftPinned: {
|
|
154
|
+
borderRightColor: "page.border.200",
|
|
155
|
+
borderRight: "1px solid"
|
|
156
|
+
},
|
|
157
|
+
_rightPinned: {
|
|
158
|
+
borderLeftColor: "page.border.200",
|
|
159
|
+
borderLeft: "1px solid"
|
|
160
|
+
},
|
|
161
|
+
className: "group",
|
|
162
|
+
style,
|
|
163
|
+
children: [
|
|
164
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
165
|
+
jsx.HStack,
|
|
166
|
+
{
|
|
167
|
+
gap: "sm",
|
|
168
|
+
_groupHover: {
|
|
169
|
+
"& :is(button)": {
|
|
170
|
+
opacity: "1"
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
children: [
|
|
174
|
+
typeof column.original.header === "function" ? column.original.header({ colId: column.id }) : column.original.header,
|
|
175
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$1.Show, { when: column.sortable, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
176
|
+
react$1.Tooltip,
|
|
177
|
+
{
|
|
178
|
+
content: isSortedDesc ? "Sort Ascending" : "Sort Decending",
|
|
179
|
+
openDelay: 800,
|
|
180
|
+
asChild: true,
|
|
181
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
182
|
+
react$1.IconButton,
|
|
183
|
+
{
|
|
184
|
+
ariaLabel: "Toggle sorting",
|
|
185
|
+
size: "sm",
|
|
186
|
+
opacity: {
|
|
187
|
+
base: 1,
|
|
188
|
+
md: 0
|
|
189
|
+
},
|
|
190
|
+
transitionProperty: "opacity",
|
|
191
|
+
transitionDuration: "fast",
|
|
192
|
+
onClick: handleToggleSorting,
|
|
193
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Show, { when: isSortedDesc, fallback: /* @__PURE__ */ jsxRuntime.jsx(SortAscIcon, {}), children: /* @__PURE__ */ jsxRuntime.jsx(SortDescIcon, {}) })
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
) })
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
),
|
|
201
|
+
/* @__PURE__ */ jsxRuntime.jsx(features_client.HeaderCellOptions, { ...column }),
|
|
202
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$1.Show, { when: pinnedState === "pinned", children: () => /* @__PURE__ */ jsxRuntime.jsx(ShadowFiller, { style, ...pinnedAttr }) })
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
});
|
|
207
|
+
const GridCell = react.memo(function GridCell2(props) {
|
|
208
|
+
const { column, row } = props;
|
|
209
|
+
const value = column.getValue(row);
|
|
210
|
+
const pinnedVal = signals.useRead(column.pinned);
|
|
211
|
+
const pinnedState = hooks_client.usePinnedState(pinnedVal);
|
|
212
|
+
const pinnedAttr = hooks_client.usePinnedAttribute(pinnedVal);
|
|
213
|
+
const style = hooks_client.useColumnStyles(column, pinnedVal);
|
|
214
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
215
|
+
jsx.HStack,
|
|
216
|
+
{
|
|
217
|
+
role: "cell",
|
|
218
|
+
"data-scope": _const.SCOPE,
|
|
219
|
+
"data-part": _const.PARTS.CELL,
|
|
220
|
+
"data-state": pinnedState,
|
|
221
|
+
...pinnedAttr,
|
|
222
|
+
bgColor: "inherit",
|
|
223
|
+
borderColor: "page.border.200",
|
|
224
|
+
h: "full",
|
|
225
|
+
pos: "relative",
|
|
226
|
+
px: "md",
|
|
227
|
+
userSelect: "none",
|
|
228
|
+
verticalAlign: "middle",
|
|
229
|
+
zIndex: "base",
|
|
230
|
+
_pinned: {
|
|
231
|
+
pos: "sticky",
|
|
232
|
+
zIndex: 20
|
|
233
|
+
},
|
|
234
|
+
_leftPinned: {
|
|
235
|
+
borderRightColor: "page.border.200",
|
|
236
|
+
borderRight: "1px solid"
|
|
237
|
+
},
|
|
238
|
+
_rightPinned: {
|
|
239
|
+
borderLeftColor: "page.border.200",
|
|
240
|
+
borderLeft: "1px solid"
|
|
241
|
+
},
|
|
242
|
+
style,
|
|
243
|
+
children: [
|
|
244
|
+
column.original.cell ? column.original.cell({ row, value }) : value,
|
|
245
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$1.Show, { when: pinnedState === "pinned", children: () => /* @__PURE__ */ jsxRuntime.jsx(ShadowFiller, { style, ...pinnedAttr }) })
|
|
246
|
+
]
|
|
247
|
+
}
|
|
248
|
+
);
|
|
249
|
+
});
|
|
250
|
+
const GridRow = react.memo(function GridRow2(props) {
|
|
251
|
+
const store = context_client.useDataGridContext();
|
|
252
|
+
const columns = signals.useRead(store.columns);
|
|
253
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GridRowContainer, { offsetY: props.offsetY, children: /* @__PURE__ */ jsxRuntime.jsx(react$1.For, { each: columns, children: (col) => /* @__PURE__ */ jsxRuntime.jsx(react$1.Show, { when: col.isVisible(), children: () => /* @__PURE__ */ jsxRuntime.jsx(GridCell, { row: props.row, column: col }) }, col.id) }) });
|
|
254
|
+
});
|
|
255
|
+
function GridRowContainer(props) {
|
|
256
|
+
const isVirtualized = props.offsetY !== void 0;
|
|
257
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
258
|
+
jsx.HStack,
|
|
259
|
+
{
|
|
260
|
+
role: "row",
|
|
261
|
+
"data-scope": _const.SCOPE,
|
|
262
|
+
"data-part": _const.PARTS.ROW,
|
|
263
|
+
"data-render": isVirtualized ? "virtualized" : "static",
|
|
264
|
+
bgColor: "page.surface.100",
|
|
265
|
+
gap: "0",
|
|
266
|
+
h: "var(--row-height)",
|
|
267
|
+
w: "full",
|
|
268
|
+
_even: {
|
|
269
|
+
bgColor: "page.surface.initial"
|
|
270
|
+
},
|
|
271
|
+
_hover: {
|
|
272
|
+
bgColor: "page.surface.200"
|
|
273
|
+
},
|
|
274
|
+
css: {
|
|
275
|
+
"&:is([data-render=virtualized])": {
|
|
276
|
+
pos: "absolute",
|
|
277
|
+
left: 0
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
style: {
|
|
281
|
+
transform: isVirtualized ? `translateY(${props.offsetY}px)` : void 0
|
|
282
|
+
},
|
|
283
|
+
children: props.children
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
function ShadowFiller(props) {
|
|
288
|
+
const { style, ...rest } = props;
|
|
289
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
290
|
+
jsx.Box,
|
|
291
|
+
{
|
|
292
|
+
bottom: "0",
|
|
293
|
+
h: "full",
|
|
294
|
+
pos: "absolute",
|
|
295
|
+
w: "0.75rem",
|
|
296
|
+
zIndex: "inherit",
|
|
297
|
+
_leftPinned: {
|
|
298
|
+
bgGradient: "to-r",
|
|
299
|
+
gradientFrom: "black/10",
|
|
300
|
+
gradientTo: "transparent"
|
|
301
|
+
},
|
|
302
|
+
_rightPinned: {
|
|
303
|
+
bgGradient: "to-l",
|
|
304
|
+
gradientFrom: "black/10",
|
|
305
|
+
gradientTo: "transparent"
|
|
306
|
+
},
|
|
307
|
+
style: {
|
|
308
|
+
left: style.left ? style.width : void 0,
|
|
309
|
+
right: style.right ? style.width : void 0
|
|
310
|
+
},
|
|
311
|
+
...rest
|
|
312
|
+
}
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
exports.GridCell = GridCell;
|
|
317
|
+
exports.GridHeaderCell = GridHeaderCell;
|
|
318
|
+
exports.GridRow = GridRow;
|
|
319
|
+
exports.GridViewport = GridViewport;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { InternalColumn } from '../types';
|
|
2
|
+
import { MemoExoticComponent, NamedExoticComponent } from 'react';
|
|
3
|
+
export declare function GridViewport(): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
interface GridHeaderCellProps<TData> {
|
|
5
|
+
column: InternalColumn<TData>;
|
|
6
|
+
}
|
|
7
|
+
export declare const GridHeaderCell: MemoExoticComponent<(<TData>(props: GridHeaderCellProps<TData>) => import("react/jsx-runtime").JSX.Element)>;
|
|
8
|
+
interface GridCellProps<TData> {
|
|
9
|
+
row: any;
|
|
10
|
+
column: InternalColumn<TData>;
|
|
11
|
+
}
|
|
12
|
+
export declare const GridCell: MemoExoticComponent<(<TData>(props: GridCellProps<TData>) => import("react/jsx-runtime").JSX.Element)>;
|
|
13
|
+
interface GridRowProps {
|
|
14
|
+
row: unknown;
|
|
15
|
+
index: number;
|
|
16
|
+
offsetY?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const GridRow: NamedExoticComponent<GridRowProps>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { InternalColumn } from '../types';
|
|
2
|
+
import { MemoExoticComponent, NamedExoticComponent } from 'react';
|
|
3
|
+
export declare function GridViewport(): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
interface GridHeaderCellProps<TData> {
|
|
5
|
+
column: InternalColumn<TData>;
|
|
6
|
+
}
|
|
7
|
+
export declare const GridHeaderCell: MemoExoticComponent<(<TData>(props: GridHeaderCellProps<TData>) => import("react/jsx-runtime").JSX.Element)>;
|
|
8
|
+
interface GridCellProps<TData> {
|
|
9
|
+
row: any;
|
|
10
|
+
column: InternalColumn<TData>;
|
|
11
|
+
}
|
|
12
|
+
export declare const GridCell: MemoExoticComponent<(<TData>(props: GridCellProps<TData>) => import("react/jsx-runtime").JSX.Element)>;
|
|
13
|
+
interface GridRowProps {
|
|
14
|
+
row: unknown;
|
|
15
|
+
index: number;
|
|
16
|
+
offsetY?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const GridRow: NamedExoticComponent<GridRowProps>;
|
|
19
|
+
export {};
|