@cerberus-design/data-grid 1.5.0-next-67466c4 → 1.5.0-next-727d6b2
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/dist/components/data-grid.client.cjs +2 -2
- package/dist/components/data-grid.client.js +2 -2
- package/dist/components/features.client.cjs +58 -18
- package/dist/components/features.client.js +59 -19
- package/dist/components/grid.client.cjs +9 -8
- package/dist/components/grid.client.d.cts +2 -2
- package/dist/components/grid.client.d.ts +2 -2
- package/dist/components/grid.client.js +9 -8
- package/dist/components/viewport.client.cjs +12 -6
- package/dist/components/viewport.client.js +12 -6
- package/dist/components/visibile-items.client.cjs +40 -0
- package/dist/components/visibile-items.client.d.cts +8 -0
- package/dist/components/visibile-items.client.d.ts +8 -0
- package/dist/components/visibile-items.client.js +40 -0
- package/dist/const.cjs +3 -1
- package/dist/const.d.cts +2 -0
- package/dist/const.d.ts +2 -0
- package/dist/const.js +3 -1
- package/dist/layouts/no-columns.client.cjs +45 -0
- package/dist/layouts/no-columns.client.d.cts +1 -0
- package/dist/layouts/no-columns.client.d.ts +1 -0
- package/dist/layouts/no-columns.client.js +45 -0
- package/dist/panda.buildinfo.json +18 -11
- package/dist/{components/popover.client.cjs → popovers/filter.client.cjs} +3 -56
- package/dist/popovers/filter.client.d.cts +1 -0
- package/dist/popovers/filter.client.d.ts +1 -0
- package/dist/{components/popover.client.js → popovers/filter.client.js} +4 -55
- package/dist/popovers/manage-cols.client.cjs +92 -0
- package/dist/popovers/manage-cols.client.d.cts +1 -0
- package/dist/popovers/manage-cols.client.d.ts +1 -0
- package/dist/popovers/manage-cols.client.js +92 -0
- package/dist/popovers/meta.cjs +25 -0
- package/dist/popovers/meta.d.cts +11 -0
- package/dist/popovers/meta.d.ts +11 -0
- package/dist/popovers/meta.js +24 -0
- package/dist/store.cjs +19 -1
- package/dist/store.js +19 -1
- package/dist/stores/data.cjs +20 -3
- package/dist/stores/data.d.cts +3 -0
- package/dist/stores/data.d.ts +3 -0
- package/dist/stores/data.js +20 -3
- package/dist/stores/index.cjs +2 -0
- package/dist/stores/index.d.cts +1 -0
- package/dist/stores/index.d.ts +1 -0
- package/dist/stores/index.js +2 -1
- package/dist/stores/visibility.cjs +12 -0
- package/dist/stores/visibility.d.cts +6 -0
- package/dist/stores/visibility.d.ts +6 -0
- package/dist/stores/visibility.js +12 -0
- package/dist/types.d.cts +22 -2
- package/dist/types.d.ts +22 -2
- package/dist/ui/popover.client.cjs +87 -0
- package/dist/ui/popover.client.d.cts +9 -0
- package/dist/ui/popover.client.d.ts +9 -0
- package/dist/ui/popover.client.js +85 -0
- package/package.json +7 -7
- package/dist/components/popover.client.d.cts +0 -9
- package/dist/components/popover.client.d.ts +0 -9
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
const require_const = require("../const.cjs");
|
|
4
4
|
const require_context_client = require("../context.client.cjs");
|
|
5
5
|
const require_store = require("../store.cjs");
|
|
6
|
+
const require_popover_client = require("../ui/popover.client.cjs");
|
|
6
7
|
const require_pagination_client = require("./pagination.client.cjs");
|
|
7
|
-
const require_popover_client = require("./popover.client.cjs");
|
|
8
8
|
const require_viewport_client = require("./viewport.client.cjs");
|
|
9
9
|
let _cerberus_design_react = require("@cerberus-design/react");
|
|
10
10
|
let _cerberus_design_signals = require("@cerberus-design/signals");
|
|
@@ -62,7 +62,7 @@ function DataGridEl(props) {
|
|
|
62
62
|
children: props.toolbar
|
|
63
63
|
})
|
|
64
64
|
}),
|
|
65
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_popover_client.
|
|
65
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_popover_client.Popover, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_popover_client.PopoverAnchor, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.Stack, {
|
|
66
66
|
"data-scope": require_const.SCOPE,
|
|
67
67
|
"data-part": require_const.PARTS.ROOT,
|
|
68
68
|
dir: "columns",
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { PARTS, SCOPE } from "../const.js";
|
|
4
4
|
import { DataGridProvider } from "../context.client.js";
|
|
5
5
|
import { createGridStore } from "../store.js";
|
|
6
|
+
import { Popover, PopoverAnchor } from "../ui/popover.client.js";
|
|
6
7
|
import { GridPagination } from "./pagination.client.js";
|
|
7
|
-
import { DGPopover, DGPopoverAnchor } from "./popover.client.js";
|
|
8
8
|
import { GridViewport } from "./viewport.client.js";
|
|
9
9
|
import { Show } from "@cerberus-design/react";
|
|
10
10
|
import { createEffect, useSignal, useStore } from "@cerberus-design/signals";
|
|
@@ -62,7 +62,7 @@ function DataGridEl(props) {
|
|
|
62
62
|
children: props.toolbar
|
|
63
63
|
})
|
|
64
64
|
}),
|
|
65
|
-
/* @__PURE__ */ jsx(
|
|
65
|
+
/* @__PURE__ */ jsx(Popover, { children: /* @__PURE__ */ jsx(PopoverAnchor, { children: /* @__PURE__ */ jsxs(Stack, {
|
|
66
66
|
"data-scope": SCOPE,
|
|
67
67
|
"data-part": PARTS.ROOT,
|
|
68
68
|
dir: "columns",
|
|
@@ -5,6 +5,7 @@ const require_context_client = require("../context.client.cjs");
|
|
|
5
5
|
const require_filter_item_client = require("./filter-item.client.cjs");
|
|
6
6
|
const require_pinned_items_client = require("./pinned-items.client.cjs");
|
|
7
7
|
const require_sort_items_client = require("./sort-items.client.cjs");
|
|
8
|
+
const require_visibile_items_client = require("./visibile-items.client.cjs");
|
|
8
9
|
let _cerberus_design_react = require("@cerberus-design/react");
|
|
9
10
|
let _cerberus_design_signals = require("@cerberus-design/signals");
|
|
10
11
|
let react = require("react");
|
|
@@ -13,6 +14,7 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
13
14
|
function HeaderCellOptions(props) {
|
|
14
15
|
const store = require_context_client.useDataGridContext();
|
|
15
16
|
const sorting = (0, _cerberus_design_signals.useRead)(store.sorting);
|
|
17
|
+
const hiddenColsMaxReached = (0, _cerberus_design_signals.useRead)(store.hiddenColsMaxReached);
|
|
16
18
|
const { icons } = (0, _cerberus_design_react.useCerberusContext)();
|
|
17
19
|
const MoreOptionsIcon = icons.moreVertical;
|
|
18
20
|
const sortedVal = (0, react.useMemo)(() => {
|
|
@@ -20,6 +22,22 @@ function HeaderCellOptions(props) {
|
|
|
20
22
|
if (idx === -1) return void 0;
|
|
21
23
|
return sorting[idx];
|
|
22
24
|
}, [sorting, props.id]);
|
|
25
|
+
const featureList = (0, react.useMemo)(() => {
|
|
26
|
+
return [
|
|
27
|
+
Number(props.sortable),
|
|
28
|
+
Number(props.pinnable),
|
|
29
|
+
Number(props.filterable),
|
|
30
|
+
Number(props.visibility)
|
|
31
|
+
];
|
|
32
|
+
}, [
|
|
33
|
+
props.sortable,
|
|
34
|
+
props.pinnable,
|
|
35
|
+
props.filterable,
|
|
36
|
+
props.visibility
|
|
37
|
+
]);
|
|
38
|
+
function hasParentFeatureOn(idx) {
|
|
39
|
+
return featureList.slice(0, idx).some((val) => val === 1);
|
|
40
|
+
}
|
|
23
41
|
function handleSelect(details) {
|
|
24
42
|
const val = details.value;
|
|
25
43
|
const specialVal = val.split("_");
|
|
@@ -33,18 +51,24 @@ function HeaderCellOptions(props) {
|
|
|
33
51
|
editing: null
|
|
34
52
|
}));
|
|
35
53
|
case require_const.FEATURE_VALUES.unsort: return store.setSort(props.id, null);
|
|
54
|
+
case require_const.FEATURE_VALUES.manageVisibility: return store.setShowManage(true);
|
|
36
55
|
default: break;
|
|
37
56
|
}
|
|
38
57
|
switch (category) {
|
|
39
58
|
case require_const.FEATURE_VALUES.pin: return store.togglePinned(props.id, action);
|
|
40
59
|
case require_const.FEATURE_VALUES.unpin: return store.togglePinned(props.id, false);
|
|
41
60
|
case require_const.FEATURE_VALUES.sort: return store.setSort(props.id, action ?? null);
|
|
61
|
+
case require_const.FEATURE_VALUES.hide: return handleHide();
|
|
42
62
|
default: console.error("Unhandled action:", {
|
|
43
63
|
details,
|
|
44
64
|
action
|
|
45
65
|
});
|
|
46
66
|
}
|
|
47
67
|
}
|
|
68
|
+
function handleHide() {
|
|
69
|
+
if (hiddenColsMaxReached) return;
|
|
70
|
+
props.setVisible(false);
|
|
71
|
+
}
|
|
48
72
|
function handleInitFilter() {
|
|
49
73
|
store.setColFilter((prev) => ({
|
|
50
74
|
...prev,
|
|
@@ -59,9 +83,8 @@ function HeaderCellOptions(props) {
|
|
|
59
83
|
}
|
|
60
84
|
}
|
|
61
85
|
}));
|
|
62
|
-
return store.setShowColFilter(true);
|
|
63
86
|
}
|
|
64
|
-
if (
|
|
87
|
+
if (featureList.every((val) => val === 0)) return null;
|
|
65
88
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_cerberus_design_react.Menu, {
|
|
66
89
|
onSelect: handleSelect,
|
|
67
90
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.MenuTrigger, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.IconButton, {
|
|
@@ -75,23 +98,40 @@ function HeaderCellOptions(props) {
|
|
|
75
98
|
transitionDuration: "fast",
|
|
76
99
|
_groupHover: { opacity: 1 },
|
|
77
100
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MoreOptionsIcon, {})
|
|
78
|
-
}) }), /* @__PURE__ */ (0, react_jsx_runtime.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}),
|
|
83
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_cerberus_design_react.Show, {
|
|
84
|
-
when: props.pinnable,
|
|
85
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
|
|
101
|
+
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_cerberus_design_react.MenuContent, {
|
|
102
|
+
maxH: "initial",
|
|
103
|
+
children: [
|
|
104
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
|
|
86
105
|
when: props.sortable,
|
|
87
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
88
|
-
}),
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
106
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_sort_items_client.MatchSortItems, { sorting: sortedVal })
|
|
107
|
+
}),
|
|
108
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_cerberus_design_react.Show, {
|
|
109
|
+
when: props.pinnable,
|
|
110
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
|
|
111
|
+
when: hasParentFeatureOn(1),
|
|
112
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.MenuSeparator, {})
|
|
113
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_pinned_items_client.MatchPinnedItems, { pinned: props.pinned })]
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_cerberus_design_react.Show, {
|
|
116
|
+
when: props.filterable,
|
|
117
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
|
|
118
|
+
when: hasParentFeatureOn(2),
|
|
119
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.MenuSeparator, {})
|
|
120
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_filter_item_client.FilterMenuItem, { colId: props.id })]
|
|
121
|
+
}),
|
|
122
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_cerberus_design_react.Show, {
|
|
123
|
+
when: props.visibility,
|
|
124
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
|
|
125
|
+
when: hasParentFeatureOn(3),
|
|
126
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.MenuSeparator, {})
|
|
127
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_visibile_items_client.MatchVisibleItems, {
|
|
128
|
+
colId: props.id,
|
|
129
|
+
isVisible: props.isVisible,
|
|
130
|
+
isLastVisibleCol: hiddenColsMaxReached
|
|
131
|
+
})]
|
|
132
|
+
})
|
|
133
|
+
]
|
|
134
|
+
}) })]
|
|
95
135
|
});
|
|
96
136
|
}
|
|
97
137
|
//#endregion
|
|
@@ -5,7 +5,8 @@ import { useDataGridContext } from "../context.client.js";
|
|
|
5
5
|
import { FilterMenuItem } from "./filter-item.client.js";
|
|
6
6
|
import { MatchPinnedItems } from "./pinned-items.client.js";
|
|
7
7
|
import { MatchSortItems } from "./sort-items.client.js";
|
|
8
|
-
import {
|
|
8
|
+
import { MatchVisibleItems } from "./visibile-items.client.js";
|
|
9
|
+
import { IconButton, Menu, MenuContent, MenuSeparator, MenuTrigger, Portal, Show, useCerberusContext } from "@cerberus-design/react";
|
|
9
10
|
import { useRead } from "@cerberus-design/signals";
|
|
10
11
|
import { useMemo } from "react";
|
|
11
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -13,6 +14,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
13
14
|
function HeaderCellOptions(props) {
|
|
14
15
|
const store = useDataGridContext();
|
|
15
16
|
const sorting = useRead(store.sorting);
|
|
17
|
+
const hiddenColsMaxReached = useRead(store.hiddenColsMaxReached);
|
|
16
18
|
const { icons } = useCerberusContext();
|
|
17
19
|
const MoreOptionsIcon = icons.moreVertical;
|
|
18
20
|
const sortedVal = useMemo(() => {
|
|
@@ -20,6 +22,22 @@ function HeaderCellOptions(props) {
|
|
|
20
22
|
if (idx === -1) return void 0;
|
|
21
23
|
return sorting[idx];
|
|
22
24
|
}, [sorting, props.id]);
|
|
25
|
+
const featureList = useMemo(() => {
|
|
26
|
+
return [
|
|
27
|
+
Number(props.sortable),
|
|
28
|
+
Number(props.pinnable),
|
|
29
|
+
Number(props.filterable),
|
|
30
|
+
Number(props.visibility)
|
|
31
|
+
];
|
|
32
|
+
}, [
|
|
33
|
+
props.sortable,
|
|
34
|
+
props.pinnable,
|
|
35
|
+
props.filterable,
|
|
36
|
+
props.visibility
|
|
37
|
+
]);
|
|
38
|
+
function hasParentFeatureOn(idx) {
|
|
39
|
+
return featureList.slice(0, idx).some((val) => val === 1);
|
|
40
|
+
}
|
|
23
41
|
function handleSelect(details) {
|
|
24
42
|
const val = details.value;
|
|
25
43
|
const specialVal = val.split("_");
|
|
@@ -33,18 +51,24 @@ function HeaderCellOptions(props) {
|
|
|
33
51
|
editing: null
|
|
34
52
|
}));
|
|
35
53
|
case FEATURE_VALUES.unsort: return store.setSort(props.id, null);
|
|
54
|
+
case FEATURE_VALUES.manageVisibility: return store.setShowManage(true);
|
|
36
55
|
default: break;
|
|
37
56
|
}
|
|
38
57
|
switch (category) {
|
|
39
58
|
case FEATURE_VALUES.pin: return store.togglePinned(props.id, action);
|
|
40
59
|
case FEATURE_VALUES.unpin: return store.togglePinned(props.id, false);
|
|
41
60
|
case FEATURE_VALUES.sort: return store.setSort(props.id, action ?? null);
|
|
61
|
+
case FEATURE_VALUES.hide: return handleHide();
|
|
42
62
|
default: console.error("Unhandled action:", {
|
|
43
63
|
details,
|
|
44
64
|
action
|
|
45
65
|
});
|
|
46
66
|
}
|
|
47
67
|
}
|
|
68
|
+
function handleHide() {
|
|
69
|
+
if (hiddenColsMaxReached) return;
|
|
70
|
+
props.setVisible(false);
|
|
71
|
+
}
|
|
48
72
|
function handleInitFilter() {
|
|
49
73
|
store.setColFilter((prev) => ({
|
|
50
74
|
...prev,
|
|
@@ -59,9 +83,8 @@ function HeaderCellOptions(props) {
|
|
|
59
83
|
}
|
|
60
84
|
}
|
|
61
85
|
}));
|
|
62
|
-
return store.setShowColFilter(true);
|
|
63
86
|
}
|
|
64
|
-
if (
|
|
87
|
+
if (featureList.every((val) => val === 0)) return null;
|
|
65
88
|
return /* @__PURE__ */ jsxs(Menu, {
|
|
66
89
|
onSelect: handleSelect,
|
|
67
90
|
children: [/* @__PURE__ */ jsx(MenuTrigger, { children: /* @__PURE__ */ jsx(IconButton, {
|
|
@@ -75,23 +98,40 @@ function HeaderCellOptions(props) {
|
|
|
75
98
|
transitionDuration: "fast",
|
|
76
99
|
_groupHover: { opacity: 1 },
|
|
77
100
|
children: /* @__PURE__ */ jsx(MoreOptionsIcon, {})
|
|
78
|
-
}) }), /* @__PURE__ */
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}),
|
|
83
|
-
/* @__PURE__ */ jsxs(Show, {
|
|
84
|
-
when: props.pinnable,
|
|
85
|
-
children: [/* @__PURE__ */ jsx(Show, {
|
|
101
|
+
}) }), /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsxs(MenuContent, {
|
|
102
|
+
maxH: "initial",
|
|
103
|
+
children: [
|
|
104
|
+
/* @__PURE__ */ jsx(Show, {
|
|
86
105
|
when: props.sortable,
|
|
87
|
-
children: /* @__PURE__ */ jsx(
|
|
88
|
-
}),
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
106
|
+
children: /* @__PURE__ */ jsx(MatchSortItems, { sorting: sortedVal })
|
|
107
|
+
}),
|
|
108
|
+
/* @__PURE__ */ jsxs(Show, {
|
|
109
|
+
when: props.pinnable,
|
|
110
|
+
children: [/* @__PURE__ */ jsx(Show, {
|
|
111
|
+
when: hasParentFeatureOn(1),
|
|
112
|
+
children: /* @__PURE__ */ jsx(MenuSeparator, {})
|
|
113
|
+
}), /* @__PURE__ */ jsx(MatchPinnedItems, { pinned: props.pinned })]
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ jsxs(Show, {
|
|
116
|
+
when: props.filterable,
|
|
117
|
+
children: [/* @__PURE__ */ jsx(Show, {
|
|
118
|
+
when: hasParentFeatureOn(2),
|
|
119
|
+
children: /* @__PURE__ */ jsx(MenuSeparator, {})
|
|
120
|
+
}), /* @__PURE__ */ jsx(FilterMenuItem, { colId: props.id })]
|
|
121
|
+
}),
|
|
122
|
+
/* @__PURE__ */ jsxs(Show, {
|
|
123
|
+
when: props.visibility,
|
|
124
|
+
children: [/* @__PURE__ */ jsx(Show, {
|
|
125
|
+
when: hasParentFeatureOn(3),
|
|
126
|
+
children: /* @__PURE__ */ jsx(MenuSeparator, {})
|
|
127
|
+
}), /* @__PURE__ */ jsx(MatchVisibleItems, {
|
|
128
|
+
colId: props.id,
|
|
129
|
+
isVisible: props.isVisible,
|
|
130
|
+
isLastVisibleCol: hiddenColsMaxReached
|
|
131
|
+
})]
|
|
132
|
+
})
|
|
133
|
+
]
|
|
134
|
+
}) })]
|
|
95
135
|
});
|
|
96
136
|
}
|
|
97
137
|
//#endregion
|
|
@@ -14,6 +14,7 @@ var GridHeaderCell = (0, react.memo)(function GridHeaderCell(props) {
|
|
|
14
14
|
const { column } = props;
|
|
15
15
|
const store = require_context_client.useDataGridContext();
|
|
16
16
|
const { icons } = (0, _cerberus_design_react.useCerberusContext)();
|
|
17
|
+
const isVisible = (0, _cerberus_design_signals.useRead)(column.isVisible);
|
|
17
18
|
const pinnedVal = (0, _cerberus_design_signals.useRead)(column.pinned);
|
|
18
19
|
const sortingVal = (0, _cerberus_design_signals.useRead)(store.sorting);
|
|
19
20
|
const colFilters = (0, _cerberus_design_signals.useRead)(store.colFilters);
|
|
@@ -56,6 +57,7 @@ var GridHeaderCell = (0, react.memo)(function GridHeaderCell(props) {
|
|
|
56
57
|
store.setShowColFilter(true);
|
|
57
58
|
});
|
|
58
59
|
}
|
|
60
|
+
if (!isVisible) return null;
|
|
59
61
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.HStack, {
|
|
60
62
|
role: "columnheader",
|
|
61
63
|
"data-scope": require_const.SCOPE,
|
|
@@ -160,10 +162,12 @@ var GridHeaderCell = (0, react.memo)(function GridHeaderCell(props) {
|
|
|
160
162
|
var GridCell = (0, react.memo)(function GridCell(props) {
|
|
161
163
|
const { column, row } = props;
|
|
162
164
|
const value = column.getValue(row);
|
|
165
|
+
const isVisible = (0, _cerberus_design_signals.useRead)(column.isVisible);
|
|
163
166
|
const pinnedVal = (0, _cerberus_design_signals.useRead)(column.pinned);
|
|
164
167
|
const pinnedState = require_hooks_client.usePinnedState(pinnedVal);
|
|
165
168
|
const pinnedAttr = require_hooks_client.usePinnedAttribute(pinnedVal);
|
|
166
169
|
const style = require_hooks_client.useColumnStyles(column, pinnedVal);
|
|
170
|
+
if (!isVisible) return null;
|
|
167
171
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.HStack, {
|
|
168
172
|
role: "cell",
|
|
169
173
|
"data-scope": require_const.SCOPE,
|
|
@@ -222,14 +226,11 @@ var GridRow = (0, react.memo)(function GridRow(props) {
|
|
|
222
226
|
offsetY: props.offsetY,
|
|
223
227
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.For, {
|
|
224
228
|
each: columns,
|
|
225
|
-
children: (col) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
hasSkeleton,
|
|
231
|
-
pending
|
|
232
|
-
})
|
|
229
|
+
children: (col) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GridCell, {
|
|
230
|
+
row: props.row,
|
|
231
|
+
column: col,
|
|
232
|
+
hasSkeleton,
|
|
233
|
+
pending
|
|
233
234
|
}, col.id)
|
|
234
235
|
})
|
|
235
236
|
});
|
|
@@ -3,14 +3,14 @@ import { InternalColumn } from '../types';
|
|
|
3
3
|
interface GridHeaderCellProps<TData> {
|
|
4
4
|
column: InternalColumn<TData>;
|
|
5
5
|
}
|
|
6
|
-
export declare const GridHeaderCell: MemoExoticComponent<(<TData>(props: GridHeaderCellProps<TData>) => import("react").JSX.Element)>;
|
|
6
|
+
export declare const GridHeaderCell: MemoExoticComponent<(<TData>(props: GridHeaderCellProps<TData>) => import("react").JSX.Element | null)>;
|
|
7
7
|
interface GridCellProps<TData> {
|
|
8
8
|
row: any;
|
|
9
9
|
column: InternalColumn<TData>;
|
|
10
10
|
pending: boolean;
|
|
11
11
|
hasSkeleton: boolean;
|
|
12
12
|
}
|
|
13
|
-
export declare const GridCell: MemoExoticComponent<(<TData>(props: GridCellProps<TData>) => import("react").JSX.Element)>;
|
|
13
|
+
export declare const GridCell: MemoExoticComponent<(<TData>(props: GridCellProps<TData>) => import("react").JSX.Element | null)>;
|
|
14
14
|
interface GridRowProps {
|
|
15
15
|
row: unknown;
|
|
16
16
|
index: number;
|
|
@@ -3,14 +3,14 @@ import { InternalColumn } from '../types';
|
|
|
3
3
|
interface GridHeaderCellProps<TData> {
|
|
4
4
|
column: InternalColumn<TData>;
|
|
5
5
|
}
|
|
6
|
-
export declare const GridHeaderCell: MemoExoticComponent<(<TData>(props: GridHeaderCellProps<TData>) => import("react").JSX.Element)>;
|
|
6
|
+
export declare const GridHeaderCell: MemoExoticComponent<(<TData>(props: GridHeaderCellProps<TData>) => import("react").JSX.Element | null)>;
|
|
7
7
|
interface GridCellProps<TData> {
|
|
8
8
|
row: any;
|
|
9
9
|
column: InternalColumn<TData>;
|
|
10
10
|
pending: boolean;
|
|
11
11
|
hasSkeleton: boolean;
|
|
12
12
|
}
|
|
13
|
-
export declare const GridCell: MemoExoticComponent<(<TData>(props: GridCellProps<TData>) => import("react").JSX.Element)>;
|
|
13
|
+
export declare const GridCell: MemoExoticComponent<(<TData>(props: GridCellProps<TData>) => import("react").JSX.Element | null)>;
|
|
14
14
|
interface GridRowProps {
|
|
15
15
|
row: unknown;
|
|
16
16
|
index: number;
|
|
@@ -14,6 +14,7 @@ var GridHeaderCell = memo(function GridHeaderCell(props) {
|
|
|
14
14
|
const { column } = props;
|
|
15
15
|
const store = useDataGridContext();
|
|
16
16
|
const { icons } = useCerberusContext();
|
|
17
|
+
const isVisible = useRead(column.isVisible);
|
|
17
18
|
const pinnedVal = useRead(column.pinned);
|
|
18
19
|
const sortingVal = useRead(store.sorting);
|
|
19
20
|
const colFilters = useRead(store.colFilters);
|
|
@@ -56,6 +57,7 @@ var GridHeaderCell = memo(function GridHeaderCell(props) {
|
|
|
56
57
|
store.setShowColFilter(true);
|
|
57
58
|
});
|
|
58
59
|
}
|
|
60
|
+
if (!isVisible) return null;
|
|
59
61
|
return /* @__PURE__ */ jsxs(HStack, {
|
|
60
62
|
role: "columnheader",
|
|
61
63
|
"data-scope": SCOPE,
|
|
@@ -160,10 +162,12 @@ var GridHeaderCell = memo(function GridHeaderCell(props) {
|
|
|
160
162
|
var GridCell = memo(function GridCell(props) {
|
|
161
163
|
const { column, row } = props;
|
|
162
164
|
const value = column.getValue(row);
|
|
165
|
+
const isVisible = useRead(column.isVisible);
|
|
163
166
|
const pinnedVal = useRead(column.pinned);
|
|
164
167
|
const pinnedState = usePinnedState(pinnedVal);
|
|
165
168
|
const pinnedAttr = usePinnedAttribute(pinnedVal);
|
|
166
169
|
const style = useColumnStyles(column, pinnedVal);
|
|
170
|
+
if (!isVisible) return null;
|
|
167
171
|
return /* @__PURE__ */ jsxs(HStack, {
|
|
168
172
|
role: "cell",
|
|
169
173
|
"data-scope": SCOPE,
|
|
@@ -222,14 +226,11 @@ var GridRow = memo(function GridRow(props) {
|
|
|
222
226
|
offsetY: props.offsetY,
|
|
223
227
|
children: /* @__PURE__ */ jsx(For, {
|
|
224
228
|
each: columns,
|
|
225
|
-
children: (col) => /* @__PURE__ */ jsx(
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
hasSkeleton,
|
|
231
|
-
pending
|
|
232
|
-
})
|
|
229
|
+
children: (col) => /* @__PURE__ */ jsx(GridCell, {
|
|
230
|
+
row: props.row,
|
|
231
|
+
column: col,
|
|
232
|
+
hasSkeleton,
|
|
233
|
+
pending
|
|
233
234
|
}, col.id)
|
|
234
235
|
})
|
|
235
236
|
});
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
const require_const = require("../const.cjs");
|
|
4
4
|
const require_context_client = require("../context.client.cjs");
|
|
5
|
-
const require_popover_client = require("
|
|
5
|
+
const require_popover_client = require("../ui/popover.client.cjs");
|
|
6
|
+
const require_no_columns_client = require("../layouts/no-columns.client.cjs");
|
|
6
7
|
const require_virtualizer_client = require("../virtualizer.client.cjs");
|
|
7
8
|
const require_grid_client = require("./grid.client.cjs");
|
|
8
9
|
const require_overlays = require("./overlays.cjs");
|
|
@@ -18,6 +19,7 @@ var GridViewport = (0, react.memo)(function GridViewport(props) {
|
|
|
18
19
|
const columns = (0, _cerberus_design_signals.useRead)(store.columns);
|
|
19
20
|
const rowCount = (0, _cerberus_design_signals.useRead)(store.rowCount);
|
|
20
21
|
const staticRows = (0, _cerberus_design_signals.useRead)(store.rows);
|
|
22
|
+
const allColsHidden = (0, _cerberus_design_signals.useRead)(store.allColsHidden);
|
|
21
23
|
const pending = (0, _cerberus_design_signals.useRead)(store.pending);
|
|
22
24
|
const pendingVariant = (0, _cerberus_design_signals.useRead)(store.pendingVariant);
|
|
23
25
|
const shouldLock = (0, _cerberus_design_signals.createComputed)(() => rowCount <= 0);
|
|
@@ -26,6 +28,7 @@ var GridViewport = (0, react.memo)(function GridViewport(props) {
|
|
|
26
28
|
if (!overlays) return false;
|
|
27
29
|
return overlays?.pending !== "skeleton";
|
|
28
30
|
}, [props.overlays]);
|
|
31
|
+
if (allColsHidden) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_no_columns_client.NoColumnsLayout, {});
|
|
29
32
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.Scrollable, {
|
|
30
33
|
"data-scope": require_const.SCOPE,
|
|
31
34
|
"data-part": require_const.PARTS.VIEWPORT,
|
|
@@ -57,10 +60,7 @@ var GridViewport = (0, react.memo)(function GridViewport(props) {
|
|
|
57
60
|
w: "full",
|
|
58
61
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.For, {
|
|
59
62
|
each: columns,
|
|
60
|
-
children: (col) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
61
|
-
when: col.isVisible(),
|
|
62
|
-
children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_grid_client.GridHeaderCell, { column: col })
|
|
63
|
-
}, col.id)
|
|
63
|
+
children: (col) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VisibleHeaderCell, { column: col }, col.id)
|
|
64
64
|
})
|
|
65
65
|
})
|
|
66
66
|
}),
|
|
@@ -73,10 +73,16 @@ var GridViewport = (0, react.memo)(function GridViewport(props) {
|
|
|
73
73
|
when: pending,
|
|
74
74
|
children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_overlays.PendingOverlay, { variant: pendingVariant })
|
|
75
75
|
}),
|
|
76
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_popover_client.
|
|
76
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_popover_client.PopoverContent, { ref: props.rootRef })
|
|
77
77
|
]
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
|
+
function VisibleHeaderCell(props) {
|
|
81
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
|
|
82
|
+
when: (0, _cerberus_design_signals.useRead)(props.column.isVisible),
|
|
83
|
+
children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_grid_client.GridHeaderCell, { column: props.column })
|
|
84
|
+
});
|
|
85
|
+
}
|
|
80
86
|
var TableRows = (0, react.memo)((props) => {
|
|
81
87
|
const store = require_context_client.useDataGridContext();
|
|
82
88
|
const { virtualRows, totalHeight } = require_virtualizer_client.useVirtualizer(store, props.viewportRef);
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import { PARTS, SCOPE } from "../const.js";
|
|
4
4
|
import { useDataGridContext } from "../context.client.js";
|
|
5
|
-
import {
|
|
5
|
+
import { PopoverContent } from "../ui/popover.client.js";
|
|
6
|
+
import { NoColumnsLayout } from "../layouts/no-columns.client.js";
|
|
6
7
|
import { useVirtualizer } from "../virtualizer.client.js";
|
|
7
8
|
import { GridHeaderCell, GridRow } from "./grid.client.js";
|
|
8
9
|
import { NoContentOverlay, PendingOverlay } from "./overlays.js";
|
|
@@ -18,6 +19,7 @@ var GridViewport = memo(function GridViewport(props) {
|
|
|
18
19
|
const columns = useRead(store.columns);
|
|
19
20
|
const rowCount = useRead(store.rowCount);
|
|
20
21
|
const staticRows = useRead(store.rows);
|
|
22
|
+
const allColsHidden = useRead(store.allColsHidden);
|
|
21
23
|
const pending = useRead(store.pending);
|
|
22
24
|
const pendingVariant = useRead(store.pendingVariant);
|
|
23
25
|
const shouldLock = createComputed(() => rowCount <= 0);
|
|
@@ -26,6 +28,7 @@ var GridViewport = memo(function GridViewport(props) {
|
|
|
26
28
|
if (!overlays) return false;
|
|
27
29
|
return overlays?.pending !== "skeleton";
|
|
28
30
|
}, [props.overlays]);
|
|
31
|
+
if (allColsHidden) return /* @__PURE__ */ jsx(NoColumnsLayout, {});
|
|
29
32
|
return /* @__PURE__ */ jsxs(Scrollable, {
|
|
30
33
|
"data-scope": SCOPE,
|
|
31
34
|
"data-part": PARTS.VIEWPORT,
|
|
@@ -57,10 +60,7 @@ var GridViewport = memo(function GridViewport(props) {
|
|
|
57
60
|
w: "full",
|
|
58
61
|
children: /* @__PURE__ */ jsx(For, {
|
|
59
62
|
each: columns,
|
|
60
|
-
children: (col) => /* @__PURE__ */ jsx(
|
|
61
|
-
when: col.isVisible(),
|
|
62
|
-
children: () => /* @__PURE__ */ jsx(GridHeaderCell, { column: col })
|
|
63
|
-
}, col.id)
|
|
63
|
+
children: (col) => /* @__PURE__ */ jsx(VisibleHeaderCell, { column: col }, col.id)
|
|
64
64
|
})
|
|
65
65
|
})
|
|
66
66
|
}),
|
|
@@ -73,10 +73,16 @@ var GridViewport = memo(function GridViewport(props) {
|
|
|
73
73
|
when: pending,
|
|
74
74
|
children: () => /* @__PURE__ */ jsx(PendingOverlay, { variant: pendingVariant })
|
|
75
75
|
}),
|
|
76
|
-
/* @__PURE__ */ jsx(
|
|
76
|
+
/* @__PURE__ */ jsx(PopoverContent, { ref: props.rootRef })
|
|
77
77
|
]
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
|
+
function VisibleHeaderCell(props) {
|
|
81
|
+
return /* @__PURE__ */ jsx(Show, {
|
|
82
|
+
when: useRead(props.column.isVisible),
|
|
83
|
+
children: () => /* @__PURE__ */ jsx(GridHeaderCell, { column: props.column })
|
|
84
|
+
});
|
|
85
|
+
}
|
|
80
86
|
var TableRows = memo((props) => {
|
|
81
87
|
const store = useDataGridContext();
|
|
82
88
|
const { virtualRows, totalHeight } = useVirtualizer(store, props.viewportRef);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
const require_const = require("../const.cjs");
|
|
4
|
+
let _cerberus_design_react = require("@cerberus-design/react");
|
|
5
|
+
let _cerberus_design_signals = require("@cerberus-design/signals");
|
|
6
|
+
let styled_system_jsx = require("styled-system/jsx");
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
//#region src/components/visibile-items.client.tsx
|
|
9
|
+
function MatchVisibleItems(props) {
|
|
10
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
|
|
11
|
+
when: (0, _cerberus_design_signals.useRead)(props.isVisible) && !props.isLastVisibleCol,
|
|
12
|
+
children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HideItem, {})
|
|
13
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ManageCols, {})] });
|
|
14
|
+
}
|
|
15
|
+
function HideItem() {
|
|
16
|
+
const { icons } = (0, _cerberus_design_react.useCerberusContext)();
|
|
17
|
+
const Icon = icons.viewOff;
|
|
18
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.MenuItem, {
|
|
19
|
+
value: require_const.FEATURE_VALUES.hide,
|
|
20
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.HStack, {
|
|
21
|
+
gap: "sm",
|
|
22
|
+
w: "full",
|
|
23
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {}), "Hide Column"]
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function ManageCols() {
|
|
28
|
+
const { icons } = (0, _cerberus_design_react.useCerberusContext)();
|
|
29
|
+
const Icon = icons.column;
|
|
30
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.MenuItem, {
|
|
31
|
+
value: require_const.FEATURE_VALUES.manageVisibility,
|
|
32
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.HStack, {
|
|
33
|
+
gap: "sm",
|
|
34
|
+
w: "full",
|
|
35
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {}), "Manage Columns"]
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
exports.MatchVisibleItems = MatchVisibleItems;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { FEATURE_VALUES } from "../const.js";
|
|
4
|
+
import { MenuItem, Show, useCerberusContext } from "@cerberus-design/react";
|
|
5
|
+
import { useRead } from "@cerberus-design/signals";
|
|
6
|
+
import { HStack } from "styled-system/jsx";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/visibile-items.client.tsx
|
|
9
|
+
function MatchVisibleItems(props) {
|
|
10
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Show, {
|
|
11
|
+
when: useRead(props.isVisible) && !props.isLastVisibleCol,
|
|
12
|
+
children: () => /* @__PURE__ */ jsx(HideItem, {})
|
|
13
|
+
}), /* @__PURE__ */ jsx(ManageCols, {})] });
|
|
14
|
+
}
|
|
15
|
+
function HideItem() {
|
|
16
|
+
const { icons } = useCerberusContext();
|
|
17
|
+
const Icon = icons.viewOff;
|
|
18
|
+
return /* @__PURE__ */ jsx(MenuItem, {
|
|
19
|
+
value: FEATURE_VALUES.hide,
|
|
20
|
+
children: /* @__PURE__ */ jsxs(HStack, {
|
|
21
|
+
gap: "sm",
|
|
22
|
+
w: "full",
|
|
23
|
+
children: [/* @__PURE__ */ jsx(Icon, {}), "Hide Column"]
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function ManageCols() {
|
|
28
|
+
const { icons } = useCerberusContext();
|
|
29
|
+
const Icon = icons.column;
|
|
30
|
+
return /* @__PURE__ */ jsx(MenuItem, {
|
|
31
|
+
value: FEATURE_VALUES.manageVisibility,
|
|
32
|
+
children: /* @__PURE__ */ jsxs(HStack, {
|
|
33
|
+
gap: "sm",
|
|
34
|
+
w: "full",
|
|
35
|
+
children: [/* @__PURE__ */ jsx(Icon, {}), "Manage Columns"]
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { MatchVisibleItems };
|
package/dist/const.cjs
CHANGED