@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.
Files changed (69) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +35 -0
  3. package/dist/column-helpers.cjs +24 -0
  4. package/dist/column-helpers.d.cts +45 -0
  5. package/dist/column-helpers.d.ts +45 -0
  6. package/dist/column-helpers.js +20 -0
  7. package/dist/components/cerby-data-grid.client.cjs +14 -0
  8. package/dist/components/cerby-data-grid.client.d.cts +6 -0
  9. package/dist/components/cerby-data-grid.client.d.ts +6 -0
  10. package/dist/components/cerby-data-grid.client.js +10 -0
  11. package/dist/components/count-menu.client.cjs +52 -0
  12. package/dist/components/count-menu.client.d.cts +6 -0
  13. package/dist/components/count-menu.client.d.ts +6 -0
  14. package/dist/components/count-menu.client.js +48 -0
  15. package/dist/components/data-grid.client.cjs +85 -0
  16. package/dist/components/data-grid.client.d.cts +4 -0
  17. package/dist/components/data-grid.client.d.ts +4 -0
  18. package/dist/components/data-grid.client.js +81 -0
  19. package/dist/components/features.client.cjs +79 -0
  20. package/dist/components/features.client.d.cts +2 -0
  21. package/dist/components/features.client.d.ts +2 -0
  22. package/dist/components/features.client.js +75 -0
  23. package/dist/components/grid.client.cjs +319 -0
  24. package/dist/components/grid.client.d.cts +19 -0
  25. package/dist/components/grid.client.d.ts +19 -0
  26. package/dist/components/grid.client.js +312 -0
  27. package/dist/components/pagination.client.cjs +116 -0
  28. package/dist/components/pagination.client.d.cts +1 -0
  29. package/dist/components/pagination.client.d.ts +1 -0
  30. package/dist/components/pagination.client.js +112 -0
  31. package/dist/components/pinned-items.client.cjs +70 -0
  32. package/dist/components/pinned-items.client.d.cts +5 -0
  33. package/dist/components/pinned-items.client.d.ts +5 -0
  34. package/dist/components/pinned-items.client.js +66 -0
  35. package/dist/components/sort-items.client.cjs +58 -0
  36. package/dist/components/sort-items.client.d.cts +4 -0
  37. package/dist/components/sort-items.client.d.ts +4 -0
  38. package/dist/components/sort-items.client.js +54 -0
  39. package/dist/const.cjs +49 -0
  40. package/dist/const.d.cts +28 -0
  41. package/dist/const.d.ts +28 -0
  42. package/dist/const.js +33 -0
  43. package/dist/context.client.cjs +18 -0
  44. package/dist/context.client.d.cts +7 -0
  45. package/dist/context.client.d.ts +7 -0
  46. package/dist/context.client.js +13 -0
  47. package/dist/hooks.client.cjs +29 -0
  48. package/dist/hooks.client.d.cts +7 -0
  49. package/dist/hooks.client.d.ts +7 -0
  50. package/dist/hooks.client.js +23 -0
  51. package/dist/index.cjs +15 -0
  52. package/dist/index.d.cts +9 -0
  53. package/dist/index.d.ts +9 -0
  54. package/dist/index.js +4 -0
  55. package/dist/store.cjs +287 -0
  56. package/dist/store.d.cts +6 -0
  57. package/dist/store.d.ts +6 -0
  58. package/dist/store.js +283 -0
  59. package/dist/types.d.cts +198 -0
  60. package/dist/types.d.ts +198 -0
  61. package/dist/utils.cjs +59 -0
  62. package/dist/utils.d.cts +6 -0
  63. package/dist/utils.d.ts +6 -0
  64. package/dist/utils.js +51 -0
  65. package/dist/virtualizer.client.cjs +56 -0
  66. package/dist/virtualizer.client.d.cts +11 -0
  67. package/dist/virtualizer.client.d.ts +11 -0
  68. package/dist/virtualizer.client.js +52 -0
  69. package/package.json +72 -0
@@ -0,0 +1,312 @@
1
+ 'use client';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { For, Show, useCerberusContext, Tooltip, IconButton } from '@cerberus-design/react';
4
+ import { useRead } from '@cerberus-design/signals';
5
+ import { useRef, memo, useMemo } from 'react';
6
+ import { Scrollable, Box, HStack, Stack } from 'styled-system/jsx';
7
+ import { PARTS, SCOPE } from '../const.js';
8
+ import { useDataGridContext } from '../context.client.js';
9
+ import { useColumnStyles, usePinnedAttribute, usePinnedState } from '../hooks.client.js';
10
+ import { useVirtualizer } from '../virtualizer.client.js';
11
+ import { HeaderCellOptions } from './features.client.js';
12
+
13
+ function GridViewport() {
14
+ const viewportRef = useRef(null);
15
+ const store = useDataGridContext();
16
+ const { virtualRows, totalHeight } = useVirtualizer(store, viewportRef);
17
+ const columns = useRead(store.columns);
18
+ const isServerPaginated = useRead(store.isServerPaginated);
19
+ const staticRows = useRead(store.rows);
20
+ const currentPageRange = useRead(store.currentPageRange);
21
+ return /* @__PURE__ */ jsxs(
22
+ Scrollable,
23
+ {
24
+ hideScrollbar: true,
25
+ "data-scope": SCOPE,
26
+ "data-part": PARTS.VIEWPORT,
27
+ h: "full",
28
+ minH: "0",
29
+ minW: "full",
30
+ pos: "relative",
31
+ w: "full",
32
+ ref: viewportRef,
33
+ children: [
34
+ /* @__PURE__ */ jsx(
35
+ Box,
36
+ {
37
+ role: "grid",
38
+ "aria-rowcount": staticRows.length + 1,
39
+ "aria-colcount": columns.length,
40
+ h: "var(--row-height)",
41
+ pos: "sticky",
42
+ top: "0",
43
+ w: "var(--total-grid-width)",
44
+ zIndex: "sticky",
45
+ children: /* @__PURE__ */ jsx(
46
+ HStack,
47
+ {
48
+ "aria-rowIndex": "1",
49
+ role: "rowgroup",
50
+ gap: "0",
51
+ h: "full",
52
+ pos: "relative",
53
+ w: "full",
54
+ children: /* @__PURE__ */ jsx(For, { each: columns, children: (col) => /* @__PURE__ */ jsx(Show, { when: col.isVisible(), children: () => /* @__PURE__ */ jsx(GridHeaderCell, { column: col }) }, col.id) })
55
+ }
56
+ )
57
+ }
58
+ ),
59
+ /* @__PURE__ */ jsx(
60
+ Show,
61
+ {
62
+ when: isServerPaginated,
63
+ fallback: /* @__PURE__ */ jsx(
64
+ Box,
65
+ {
66
+ pos: "relative",
67
+ w: "var(--total-grid-width)",
68
+ style: {
69
+ height: `${totalHeight}px`
70
+ },
71
+ children: /* @__PURE__ */ jsx(For, { each: virtualRows, children: (vRow) => /* @__PURE__ */ jsx(
72
+ GridRow,
73
+ {
74
+ row: vRow.data,
75
+ index: vRow.index,
76
+ offsetY: vRow.offsetY
77
+ },
78
+ vRow.index
79
+ ) })
80
+ }
81
+ ),
82
+ children: () => /* @__PURE__ */ jsx(Stack, { direction: "column", gap: "0", w: "var(--total-grid-width)", children: /* @__PURE__ */ jsx(
83
+ For,
84
+ {
85
+ each: staticRows.slice(
86
+ currentPageRange.start,
87
+ currentPageRange.end
88
+ ),
89
+ children: (row, index) => /* @__PURE__ */ jsx(GridRow, { row, index }, index)
90
+ }
91
+ ) })
92
+ }
93
+ )
94
+ ]
95
+ }
96
+ );
97
+ }
98
+ const GridHeaderCell = memo(function GridHeaderCell2(props) {
99
+ const { column } = props;
100
+ const store = useDataGridContext();
101
+ const { icons } = useCerberusContext();
102
+ const pinnedVal = useRead(column.pinned);
103
+ const sortingVal = useRead(store.sorting);
104
+ const pinnedState = usePinnedState(pinnedVal);
105
+ const pinnedAttr = usePinnedAttribute(pinnedVal);
106
+ const style = useColumnStyles(column, pinnedVal);
107
+ const isSortedDesc = useMemo(() => {
108
+ const result = sortingVal.find((item) => item.id === column.id);
109
+ if (result) return result.desc;
110
+ return false;
111
+ }, [sortingVal, column.id]);
112
+ const SortAscIcon = icons.sortAsc;
113
+ const SortDescIcon = icons.sortDesc;
114
+ function handleToggleSorting(e) {
115
+ store.toggleSort(column.id, e.shiftKey);
116
+ }
117
+ return /* @__PURE__ */ jsxs(
118
+ HStack,
119
+ {
120
+ role: "columnheader",
121
+ "data-scope": SCOPE,
122
+ "data-part": PARTS.HEAD_CELL,
123
+ "data-state": pinnedState,
124
+ "data-col": column.id,
125
+ ...pinnedAttr,
126
+ bgColor: "page.bg.initial",
127
+ borderBottom: "1px solid",
128
+ borderColor: "page.border.200",
129
+ h: "full",
130
+ justify: "space-between",
131
+ pos: "relative",
132
+ px: "md",
133
+ userSelect: "none",
134
+ textAlign: "left",
135
+ textStyle: "label-md",
136
+ verticalAlign: "middle",
137
+ w: "full",
138
+ zIndex: "10",
139
+ _first: {
140
+ borderTopLeftRadius: "md"
141
+ },
142
+ _last: {
143
+ borderTopRightRadius: "md"
144
+ },
145
+ _pinned: {
146
+ pos: "sticky",
147
+ zIndex: 20
148
+ },
149
+ _leftPinned: {
150
+ borderRightColor: "page.border.200",
151
+ borderRight: "1px solid"
152
+ },
153
+ _rightPinned: {
154
+ borderLeftColor: "page.border.200",
155
+ borderLeft: "1px solid"
156
+ },
157
+ className: "group",
158
+ style,
159
+ children: [
160
+ /* @__PURE__ */ jsxs(
161
+ HStack,
162
+ {
163
+ gap: "sm",
164
+ _groupHover: {
165
+ "& :is(button)": {
166
+ opacity: "1"
167
+ }
168
+ },
169
+ children: [
170
+ typeof column.original.header === "function" ? column.original.header({ colId: column.id }) : column.original.header,
171
+ /* @__PURE__ */ jsx(Show, { when: column.sortable, children: /* @__PURE__ */ jsx(
172
+ Tooltip,
173
+ {
174
+ content: isSortedDesc ? "Sort Ascending" : "Sort Decending",
175
+ openDelay: 800,
176
+ asChild: true,
177
+ children: /* @__PURE__ */ jsx(
178
+ IconButton,
179
+ {
180
+ ariaLabel: "Toggle sorting",
181
+ size: "sm",
182
+ opacity: {
183
+ base: 1,
184
+ md: 0
185
+ },
186
+ transitionProperty: "opacity",
187
+ transitionDuration: "fast",
188
+ onClick: handleToggleSorting,
189
+ children: /* @__PURE__ */ jsx(Show, { when: isSortedDesc, fallback: /* @__PURE__ */ jsx(SortAscIcon, {}), children: /* @__PURE__ */ jsx(SortDescIcon, {}) })
190
+ }
191
+ )
192
+ }
193
+ ) })
194
+ ]
195
+ }
196
+ ),
197
+ /* @__PURE__ */ jsx(HeaderCellOptions, { ...column }),
198
+ /* @__PURE__ */ jsx(Show, { when: pinnedState === "pinned", children: () => /* @__PURE__ */ jsx(ShadowFiller, { style, ...pinnedAttr }) })
199
+ ]
200
+ }
201
+ );
202
+ });
203
+ const GridCell = memo(function GridCell2(props) {
204
+ const { column, row } = props;
205
+ const value = column.getValue(row);
206
+ const pinnedVal = useRead(column.pinned);
207
+ const pinnedState = usePinnedState(pinnedVal);
208
+ const pinnedAttr = usePinnedAttribute(pinnedVal);
209
+ const style = useColumnStyles(column, pinnedVal);
210
+ return /* @__PURE__ */ jsxs(
211
+ HStack,
212
+ {
213
+ role: "cell",
214
+ "data-scope": SCOPE,
215
+ "data-part": PARTS.CELL,
216
+ "data-state": pinnedState,
217
+ ...pinnedAttr,
218
+ bgColor: "inherit",
219
+ borderColor: "page.border.200",
220
+ h: "full",
221
+ pos: "relative",
222
+ px: "md",
223
+ userSelect: "none",
224
+ verticalAlign: "middle",
225
+ zIndex: "base",
226
+ _pinned: {
227
+ pos: "sticky",
228
+ zIndex: 20
229
+ },
230
+ _leftPinned: {
231
+ borderRightColor: "page.border.200",
232
+ borderRight: "1px solid"
233
+ },
234
+ _rightPinned: {
235
+ borderLeftColor: "page.border.200",
236
+ borderLeft: "1px solid"
237
+ },
238
+ style,
239
+ children: [
240
+ column.original.cell ? column.original.cell({ row, value }) : value,
241
+ /* @__PURE__ */ jsx(Show, { when: pinnedState === "pinned", children: () => /* @__PURE__ */ jsx(ShadowFiller, { style, ...pinnedAttr }) })
242
+ ]
243
+ }
244
+ );
245
+ });
246
+ const GridRow = memo(function GridRow2(props) {
247
+ const store = useDataGridContext();
248
+ const columns = useRead(store.columns);
249
+ return /* @__PURE__ */ jsx(GridRowContainer, { offsetY: props.offsetY, children: /* @__PURE__ */ jsx(For, { each: columns, children: (col) => /* @__PURE__ */ jsx(Show, { when: col.isVisible(), children: () => /* @__PURE__ */ jsx(GridCell, { row: props.row, column: col }) }, col.id) }) });
250
+ });
251
+ function GridRowContainer(props) {
252
+ const isVirtualized = props.offsetY !== void 0;
253
+ return /* @__PURE__ */ jsx(
254
+ HStack,
255
+ {
256
+ role: "row",
257
+ "data-scope": SCOPE,
258
+ "data-part": PARTS.ROW,
259
+ "data-render": isVirtualized ? "virtualized" : "static",
260
+ bgColor: "page.surface.100",
261
+ gap: "0",
262
+ h: "var(--row-height)",
263
+ w: "full",
264
+ _even: {
265
+ bgColor: "page.surface.initial"
266
+ },
267
+ _hover: {
268
+ bgColor: "page.surface.200"
269
+ },
270
+ css: {
271
+ "&:is([data-render=virtualized])": {
272
+ pos: "absolute",
273
+ left: 0
274
+ }
275
+ },
276
+ style: {
277
+ transform: isVirtualized ? `translateY(${props.offsetY}px)` : void 0
278
+ },
279
+ children: props.children
280
+ }
281
+ );
282
+ }
283
+ function ShadowFiller(props) {
284
+ const { style, ...rest } = props;
285
+ return /* @__PURE__ */ jsx(
286
+ Box,
287
+ {
288
+ bottom: "0",
289
+ h: "full",
290
+ pos: "absolute",
291
+ w: "0.75rem",
292
+ zIndex: "inherit",
293
+ _leftPinned: {
294
+ bgGradient: "to-r",
295
+ gradientFrom: "black/10",
296
+ gradientTo: "transparent"
297
+ },
298
+ _rightPinned: {
299
+ bgGradient: "to-l",
300
+ gradientFrom: "black/10",
301
+ gradientTo: "transparent"
302
+ },
303
+ style: {
304
+ left: style.left ? style.width : void 0,
305
+ right: style.right ? style.width : void 0
306
+ },
307
+ ...rest
308
+ }
309
+ );
310
+ }
311
+
312
+ export { GridCell, GridHeaderCell, GridRow, GridViewport };
@@ -0,0 +1,116 @@
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 jsx = require('styled-system/jsx');
9
+ const context_client = require('../context.client.cjs');
10
+ const countMenu_client = require('./count-menu.client.cjs');
11
+ const signals = require('@cerberus-design/signals');
12
+
13
+ function GridPagination() {
14
+ const store = context_client.useDataGridContext();
15
+ const pageIndex = signals.useRead(store.pageIndex);
16
+ const pageSize = signals.useRead(store.pageSize);
17
+ const rowCount = signals.useRead(store.rowCount);
18
+ function handlePageChange(details) {
19
+ store.setPage(details);
20
+ }
21
+ function handlePageSizeChange(details) {
22
+ store.setPageSize(details.pageSize);
23
+ }
24
+ return /* @__PURE__ */ jsxRuntime.jsx(react.Show, { when: pageSize, children: () => /* @__PURE__ */ jsxRuntime.jsx(
25
+ react.PaginationParts.Root,
26
+ {
27
+ defaultPage: pageIndex ? pageIndex : 1,
28
+ count: rowCount,
29
+ onPageChange: handlePageChange,
30
+ onPageSizeChange: handlePageSizeChange,
31
+ page: pageIndex,
32
+ pageSize,
33
+ children: /* @__PURE__ */ jsxRuntime.jsx(react.PaginationParts.Context, { children: (pagination) => /* @__PURE__ */ jsxRuntime.jsxs(
34
+ jsx.HStack,
35
+ {
36
+ bgColor: "page.surface.100",
37
+ borderTop: "1px solid",
38
+ borderTopColor: "page.border.initial",
39
+ justify: "space-between",
40
+ px: "md",
41
+ py: "sm",
42
+ w: "full",
43
+ children: [
44
+ /* @__PURE__ */ jsxRuntime.jsxs(jsx.HStack, { gap: "sm", children: [
45
+ /* @__PURE__ */ jsxRuntime.jsxs(
46
+ react.Text,
47
+ {
48
+ as: "small",
49
+ color: "page.text.100",
50
+ textStyle: "label-sm",
51
+ userSelect: "none",
52
+ children: [
53
+ pagination.pageRange.start,
54
+ "-",
55
+ pagination.pageRange.end,
56
+ " of",
57
+ " ",
58
+ pagination.count
59
+ ]
60
+ }
61
+ ),
62
+ /* @__PURE__ */ jsxRuntime.jsx(
63
+ jsx.Divider,
64
+ {
65
+ color: "page.border.200",
66
+ orientation: "vertical",
67
+ h: "1rem",
68
+ thickness: "1px"
69
+ }
70
+ ),
71
+ /* @__PURE__ */ jsxRuntime.jsx(
72
+ react.Text,
73
+ {
74
+ as: "small",
75
+ color: "page.text.initial",
76
+ textStyle: "label-sm",
77
+ userSelect: "none",
78
+ children: "Rows per page:"
79
+ }
80
+ ),
81
+ /* @__PURE__ */ jsxRuntime.jsx(
82
+ countMenu_client.CountMenu,
83
+ {
84
+ onValueChange: (details) => {
85
+ pagination.setPageSize(Number(details.value));
86
+ }
87
+ }
88
+ )
89
+ ] }),
90
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Group, { children: [
91
+ /* @__PURE__ */ jsxRuntime.jsx(react.PrevTrigger, { size: "sm" }),
92
+ /* @__PURE__ */ jsxRuntime.jsxs(
93
+ react.Text,
94
+ {
95
+ as: "small",
96
+ color: "page.text.200",
97
+ lineHeight: "inherit",
98
+ textStyle: "label-sm",
99
+ userSelect: "none",
100
+ children: [
101
+ pagination.page,
102
+ " of ",
103
+ pagination.totalPages
104
+ ]
105
+ }
106
+ ),
107
+ /* @__PURE__ */ jsxRuntime.jsx(react.NextTrigger, { size: "sm" })
108
+ ] })
109
+ ]
110
+ }
111
+ ) })
112
+ }
113
+ ) });
114
+ }
115
+
116
+ exports.GridPagination = GridPagination;
@@ -0,0 +1 @@
1
+ export declare function GridPagination(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function GridPagination(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,112 @@
1
+ 'use client';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { Show, PaginationParts, Text, Group, PrevTrigger, NextTrigger } from '@cerberus-design/react';
4
+ import { HStack, Divider } from 'styled-system/jsx';
5
+ import { useDataGridContext } from '../context.client.js';
6
+ import { CountMenu } from './count-menu.client.js';
7
+ import { useRead } from '@cerberus-design/signals';
8
+
9
+ function GridPagination() {
10
+ const store = useDataGridContext();
11
+ const pageIndex = useRead(store.pageIndex);
12
+ const pageSize = useRead(store.pageSize);
13
+ const rowCount = useRead(store.rowCount);
14
+ function handlePageChange(details) {
15
+ store.setPage(details);
16
+ }
17
+ function handlePageSizeChange(details) {
18
+ store.setPageSize(details.pageSize);
19
+ }
20
+ return /* @__PURE__ */ jsx(Show, { when: pageSize, children: () => /* @__PURE__ */ jsx(
21
+ PaginationParts.Root,
22
+ {
23
+ defaultPage: pageIndex ? pageIndex : 1,
24
+ count: rowCount,
25
+ onPageChange: handlePageChange,
26
+ onPageSizeChange: handlePageSizeChange,
27
+ page: pageIndex,
28
+ pageSize,
29
+ children: /* @__PURE__ */ jsx(PaginationParts.Context, { children: (pagination) => /* @__PURE__ */ jsxs(
30
+ HStack,
31
+ {
32
+ bgColor: "page.surface.100",
33
+ borderTop: "1px solid",
34
+ borderTopColor: "page.border.initial",
35
+ justify: "space-between",
36
+ px: "md",
37
+ py: "sm",
38
+ w: "full",
39
+ children: [
40
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", children: [
41
+ /* @__PURE__ */ jsxs(
42
+ Text,
43
+ {
44
+ as: "small",
45
+ color: "page.text.100",
46
+ textStyle: "label-sm",
47
+ userSelect: "none",
48
+ children: [
49
+ pagination.pageRange.start,
50
+ "-",
51
+ pagination.pageRange.end,
52
+ " of",
53
+ " ",
54
+ pagination.count
55
+ ]
56
+ }
57
+ ),
58
+ /* @__PURE__ */ jsx(
59
+ Divider,
60
+ {
61
+ color: "page.border.200",
62
+ orientation: "vertical",
63
+ h: "1rem",
64
+ thickness: "1px"
65
+ }
66
+ ),
67
+ /* @__PURE__ */ jsx(
68
+ Text,
69
+ {
70
+ as: "small",
71
+ color: "page.text.initial",
72
+ textStyle: "label-sm",
73
+ userSelect: "none",
74
+ children: "Rows per page:"
75
+ }
76
+ ),
77
+ /* @__PURE__ */ jsx(
78
+ CountMenu,
79
+ {
80
+ onValueChange: (details) => {
81
+ pagination.setPageSize(Number(details.value));
82
+ }
83
+ }
84
+ )
85
+ ] }),
86
+ /* @__PURE__ */ jsxs(Group, { children: [
87
+ /* @__PURE__ */ jsx(PrevTrigger, { size: "sm" }),
88
+ /* @__PURE__ */ jsxs(
89
+ Text,
90
+ {
91
+ as: "small",
92
+ color: "page.text.200",
93
+ lineHeight: "inherit",
94
+ textStyle: "label-sm",
95
+ userSelect: "none",
96
+ children: [
97
+ pagination.page,
98
+ " of ",
99
+ pagination.totalPages
100
+ ]
101
+ }
102
+ ),
103
+ /* @__PURE__ */ jsx(NextTrigger, { size: "sm" })
104
+ ] })
105
+ ]
106
+ }
107
+ ) })
108
+ }
109
+ ) });
110
+ }
111
+
112
+ export { GridPagination };
@@ -0,0 +1,70 @@
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 jsx = require('styled-system/jsx');
10
+
11
+ function MatchPinnedItems(props) {
12
+ const pinned = signals.useRead(props.pinned);
13
+ const MenuItems = {
14
+ right: PinRightItem,
15
+ left: PinLeftItem,
16
+ unpinRight: UnpinRightItem,
17
+ unpinLeft: UnpinLeftItem
18
+ };
19
+ switch (pinned) {
20
+ case "right":
21
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
22
+ /* @__PURE__ */ jsxRuntime.jsx(MenuItems.unpinRight, {}),
23
+ /* @__PURE__ */ jsxRuntime.jsx(MenuItems.left, {})
24
+ ] });
25
+ case "left":
26
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
27
+ /* @__PURE__ */ jsxRuntime.jsx(MenuItems.right, {}),
28
+ /* @__PURE__ */ jsxRuntime.jsx(MenuItems.unpinLeft, {})
29
+ ] });
30
+ default:
31
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
32
+ /* @__PURE__ */ jsxRuntime.jsx(MenuItems.right, {}),
33
+ /* @__PURE__ */ jsxRuntime.jsx(MenuItems.left, {})
34
+ ] });
35
+ }
36
+ }
37
+ function UnpinRightItem() {
38
+ const { icons } = react.useCerberusContext();
39
+ const Icon = icons.pinRightFilled;
40
+ return /* @__PURE__ */ jsxRuntime.jsx(react.MenuItem, { value: "unpin_right", children: /* @__PURE__ */ jsxRuntime.jsxs(jsx.HStack, { gap: "sm", w: "full", children: [
41
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, {}),
42
+ "Unpin Right"
43
+ ] }) });
44
+ }
45
+ function UnpinLeftItem() {
46
+ const { icons } = react.useCerberusContext();
47
+ const Icon = icons.pinLeftFilled;
48
+ return /* @__PURE__ */ jsxRuntime.jsx(react.MenuItem, { value: "unpin_left", children: /* @__PURE__ */ jsxRuntime.jsxs(jsx.HStack, { gap: "sm", w: "full", children: [
49
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, {}),
50
+ "Unpin Left"
51
+ ] }) });
52
+ }
53
+ function PinRightItem() {
54
+ const { icons } = react.useCerberusContext();
55
+ const Icon = icons.pinRight;
56
+ return /* @__PURE__ */ jsxRuntime.jsx(react.MenuItem, { value: "pin_right", children: /* @__PURE__ */ jsxRuntime.jsxs(jsx.HStack, { gap: "sm", w: "full", children: [
57
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, {}),
58
+ "Pin Right"
59
+ ] }) });
60
+ }
61
+ function PinLeftItem() {
62
+ const { icons } = react.useCerberusContext();
63
+ const Icon = icons.pinLeft;
64
+ return /* @__PURE__ */ jsxRuntime.jsx(react.MenuItem, { value: "pin_left", children: /* @__PURE__ */ jsxRuntime.jsxs(jsx.HStack, { gap: "sm", w: "full", children: [
65
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, {}),
66
+ "Pin Left"
67
+ ] }) });
68
+ }
69
+
70
+ exports.MatchPinnedItems = MatchPinnedItems;
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from 'react';
2
+ import { InternalColumn } from '../types';
3
+ export declare function MatchPinnedItems(props: {
4
+ pinned: InternalColumn<ReactNode>['pinned'];
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from 'react';
2
+ import { InternalColumn } from '../types';
3
+ export declare function MatchPinnedItems(props: {
4
+ pinned: InternalColumn<ReactNode>['pinned'];
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,66 @@
1
+ 'use client';
2
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
+ import { useCerberusContext, MenuItem } from '@cerberus-design/react';
4
+ import { useRead } from '@cerberus-design/signals';
5
+ import { HStack } from 'styled-system/jsx';
6
+
7
+ function MatchPinnedItems(props) {
8
+ const pinned = useRead(props.pinned);
9
+ const MenuItems = {
10
+ right: PinRightItem,
11
+ left: PinLeftItem,
12
+ unpinRight: UnpinRightItem,
13
+ unpinLeft: UnpinLeftItem
14
+ };
15
+ switch (pinned) {
16
+ case "right":
17
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
18
+ /* @__PURE__ */ jsx(MenuItems.unpinRight, {}),
19
+ /* @__PURE__ */ jsx(MenuItems.left, {})
20
+ ] });
21
+ case "left":
22
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
23
+ /* @__PURE__ */ jsx(MenuItems.right, {}),
24
+ /* @__PURE__ */ jsx(MenuItems.unpinLeft, {})
25
+ ] });
26
+ default:
27
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
28
+ /* @__PURE__ */ jsx(MenuItems.right, {}),
29
+ /* @__PURE__ */ jsx(MenuItems.left, {})
30
+ ] });
31
+ }
32
+ }
33
+ function UnpinRightItem() {
34
+ const { icons } = useCerberusContext();
35
+ const Icon = icons.pinRightFilled;
36
+ return /* @__PURE__ */ jsx(MenuItem, { value: "unpin_right", children: /* @__PURE__ */ jsxs(HStack, { gap: "sm", w: "full", children: [
37
+ /* @__PURE__ */ jsx(Icon, {}),
38
+ "Unpin Right"
39
+ ] }) });
40
+ }
41
+ function UnpinLeftItem() {
42
+ const { icons } = useCerberusContext();
43
+ const Icon = icons.pinLeftFilled;
44
+ return /* @__PURE__ */ jsx(MenuItem, { value: "unpin_left", children: /* @__PURE__ */ jsxs(HStack, { gap: "sm", w: "full", children: [
45
+ /* @__PURE__ */ jsx(Icon, {}),
46
+ "Unpin Left"
47
+ ] }) });
48
+ }
49
+ function PinRightItem() {
50
+ const { icons } = useCerberusContext();
51
+ const Icon = icons.pinRight;
52
+ return /* @__PURE__ */ jsx(MenuItem, { value: "pin_right", children: /* @__PURE__ */ jsxs(HStack, { gap: "sm", w: "full", children: [
53
+ /* @__PURE__ */ jsx(Icon, {}),
54
+ "Pin Right"
55
+ ] }) });
56
+ }
57
+ function PinLeftItem() {
58
+ const { icons } = useCerberusContext();
59
+ const Icon = icons.pinLeft;
60
+ return /* @__PURE__ */ jsx(MenuItem, { value: "pin_left", children: /* @__PURE__ */ jsxs(HStack, { gap: "sm", w: "full", children: [
61
+ /* @__PURE__ */ jsx(Icon, {}),
62
+ "Pin Left"
63
+ ] }) });
64
+ }
65
+
66
+ export { MatchPinnedItems };