@cerberus-design/data-grid 1.1.3 → 1.2.0-rc.1

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 (50) hide show
  1. package/dist/components/data-grid.client.cjs +13 -4
  2. package/dist/components/data-grid.client.js +13 -4
  3. package/dist/components/features.client.cjs +32 -9
  4. package/dist/components/features.client.js +33 -10
  5. package/dist/components/filter-item.client.cjs +38 -0
  6. package/dist/components/filter-item.client.d.cts +6 -0
  7. package/dist/components/filter-item.client.d.ts +6 -0
  8. package/dist/components/filter-item.client.js +38 -0
  9. package/dist/components/grid.client.cjs +101 -104
  10. package/dist/components/grid.client.d.cts +7 -2
  11. package/dist/components/grid.client.d.ts +7 -2
  12. package/dist/components/grid.client.js +105 -109
  13. package/dist/components/no-content.client.cjs +23 -0
  14. package/dist/components/no-content.client.d.cts +1 -0
  15. package/dist/components/no-content.client.d.ts +1 -0
  16. package/dist/components/no-content.client.js +23 -0
  17. package/dist/components/overlays.cjs +69 -0
  18. package/dist/components/overlays.d.cts +14 -0
  19. package/dist/components/overlays.d.ts +14 -0
  20. package/dist/components/overlays.js +68 -0
  21. package/dist/components/pinned-items.client.cjs +5 -4
  22. package/dist/components/pinned-items.client.js +5 -4
  23. package/dist/components/popover.client.cjs +186 -0
  24. package/dist/components/popover.client.d.cts +9 -0
  25. package/dist/components/popover.client.d.ts +9 -0
  26. package/dist/components/popover.client.js +184 -0
  27. package/dist/components/sort-items.client.cjs +4 -3
  28. package/dist/components/sort-items.client.js +4 -3
  29. package/dist/components/viewport.client.cjs +115 -0
  30. package/dist/components/viewport.client.d.cts +8 -0
  31. package/dist/components/viewport.client.d.ts +8 -0
  32. package/dist/components/viewport.client.js +115 -0
  33. package/dist/const.cjs +26 -0
  34. package/dist/const.d.cts +16 -1
  35. package/dist/const.d.ts +16 -1
  36. package/dist/const.js +25 -1
  37. package/dist/index.cjs +2 -0
  38. package/dist/index.d.cts +1 -0
  39. package/dist/index.d.ts +1 -0
  40. package/dist/index.js +2 -1
  41. package/dist/panda.buildinfo.json +55 -30
  42. package/dist/store.cjs +63 -20
  43. package/dist/store.js +65 -22
  44. package/dist/types.d.cts +52 -6
  45. package/dist/types.d.ts +52 -6
  46. package/dist/utils.cjs +23 -0
  47. package/dist/utils.d.cts +2 -1
  48. package/dist/utils.d.ts +2 -1
  49. package/dist/utils.js +24 -2
  50. package/package.json +4 -4
@@ -0,0 +1,186 @@
1
+ "use client";
2
+ "use client";
3
+ const require_const = require("../const.cjs");
4
+ const require_context_client = require("../context.client.cjs");
5
+ let _cerberus_design_react = require("@cerberus-design/react");
6
+ let _cerberus_design_signals = require("@cerberus-design/signals");
7
+ let styled_system_jsx = require("styled-system/jsx");
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+ let react_dom = require("react-dom");
10
+ //#region src/components/popover.client.tsx
11
+ function DGPopover(props) {
12
+ const store = require_context_client.useDataGridContext();
13
+ const colH = (0, _cerberus_design_signals.useRead)(store.rowSize);
14
+ const open = (0, _cerberus_design_signals.useRead)(store.showColFilter);
15
+ const mainAxis = 119 + colH;
16
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.PopoverParts.Root, {
17
+ ...props,
18
+ lazyMount: true,
19
+ open,
20
+ onOpenChange: (details) => {
21
+ if (!details.open) store.setColFilter((prev) => ({
22
+ ...prev,
23
+ active: prev.active.filter((filterId) => prev.filters[filterId].value),
24
+ editing: null
25
+ }));
26
+ store.setShowColFilter(details.open);
27
+ },
28
+ portalled: true,
29
+ positioning: {
30
+ placement: "top-start",
31
+ offset: { mainAxis: -mainAxis }
32
+ }
33
+ });
34
+ }
35
+ function DGPopoverAnchor(props) {
36
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.PopoverParts.Anchor, {
37
+ ...props,
38
+ asChild: true
39
+ });
40
+ }
41
+ function DGPopoverContent(props) {
42
+ const { icons } = (0, _cerberus_design_react.useCerberusContext)();
43
+ const CloseIcon = icons?.close;
44
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Portal, {
45
+ container: props.ref,
46
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.PopoverParts.Positioner, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_cerberus_design_react.PopoverParts.Content, {
47
+ css: { "--popover-size": "37.5rem!" },
48
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_cerberus_design_react.PopoverParts.Header, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.PopoverParts.CloseTrigger, {
49
+ asChild: true,
50
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.IconButtonRoot, {
51
+ size: "sm",
52
+ usage: "ghost",
53
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CloseIcon, {})
54
+ })
55
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.PopoverParts.Title, {
56
+ textStyle: "label-md",
57
+ children: "Filter By Column"
58
+ })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterForm, {})]
59
+ }) })
60
+ });
61
+ }
62
+ function FilterForm() {
63
+ const store = require_context_client.useDataGridContext();
64
+ function filter(formData) {
65
+ const payload = {
66
+ id: formData.get("column"),
67
+ operator: formData.get("operator"),
68
+ value: formData.get("value")
69
+ };
70
+ (0, _cerberus_design_signals.batch)(() => {
71
+ store.setColFilter((prev) => ({
72
+ ...prev,
73
+ active: [...prev.active, payload.id],
74
+ filters: {
75
+ ...prev.filters,
76
+ [payload.id]: payload
77
+ },
78
+ editing: null
79
+ }));
80
+ store.setShowColFilter(false);
81
+ });
82
+ }
83
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.cerberus.form, {
84
+ action: filter,
85
+ w: "full",
86
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.PopoverParts.Body, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormFields, {}) })
87
+ });
88
+ }
89
+ function FormFields() {
90
+ const status = (0, react_dom.useFormStatus)();
91
+ const store = require_context_client.useDataGridContext();
92
+ const cols = (0, _cerberus_design_signals.useRead)(store.columns);
93
+ const colFilters = (0, _cerberus_design_signals.useRead)(store.colFilters);
94
+ const filterToEdit = (0, _cerberus_design_signals.createComputed)(() => {
95
+ return colFilters.filters[colFilters.editing];
96
+ });
97
+ const colCollection = (0, _cerberus_design_react.createSelectCollection)(cols.map((col) => ({
98
+ value: col.id,
99
+ label: String(col.original.header)
100
+ })));
101
+ const operatorCollection = (0, _cerberus_design_react.createSelectCollection)(Object.keys(require_const.OPERATORS).map((key) => ({
102
+ value: key,
103
+ label: require_const.OPERATORS[key].replaceAll("_", " ")
104
+ })));
105
+ if (!filterToEdit()) return null;
106
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(styled_system_jsx.Stack, {
107
+ direction: "column",
108
+ gap: "sm",
109
+ w: "full",
110
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormSection, {
111
+ colCollection,
112
+ operatorCollection,
113
+ defaultColValue: cols[0].id,
114
+ filter: filterToEdit(),
115
+ status
116
+ })
117
+ });
118
+ }
119
+ function FormSection(props) {
120
+ const { filter } = props;
121
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.HStack, {
122
+ gap: "sm",
123
+ w: "full",
124
+ children: [
125
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Field, {
126
+ label: "Select a column",
127
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Select, {
128
+ collection: props.colCollection,
129
+ name: "column",
130
+ placeholder: "Choose option",
131
+ size: "sm",
132
+ defaultValue: [filter?.id ?? props.defaultColValue],
133
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.For, {
134
+ each: props.colCollection.items,
135
+ children: (item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Option, { item }, item.value)
136
+ })
137
+ })
138
+ }),
139
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Field, {
140
+ label: "Select a operator",
141
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Select, {
142
+ collection: props.operatorCollection,
143
+ name: "operator",
144
+ placeholder: "Choose option",
145
+ size: "sm",
146
+ defaultValue: [filter?.operator ?? require_const.OPERATORS.contains],
147
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.For, {
148
+ each: props.operatorCollection.items,
149
+ children: (item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Option, { item }, item.value)
150
+ })
151
+ })
152
+ }),
153
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Field, {
154
+ label: "Value",
155
+ required: true,
156
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Input, {
157
+ name: "value",
158
+ size: "sm",
159
+ defaultValue: filter?.value
160
+ })
161
+ }),
162
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SubmitButton, { pending: props.status.pending })
163
+ ]
164
+ });
165
+ }
166
+ function SubmitButton(props) {
167
+ const { icons } = (0, _cerberus_design_react.useCerberusContext)();
168
+ const { arrowRight: Icon } = icons;
169
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(styled_system_jsx.Box, {
170
+ alignSelf: "flex-end",
171
+ mb: "0.25rem",
172
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.IconButton, {
173
+ ariaLabel: "Submit form",
174
+ disabled: props.pending,
175
+ type: "submit",
176
+ usage: "filled",
177
+ h: "2rem!",
178
+ w: "2rem!",
179
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {})
180
+ })
181
+ });
182
+ }
183
+ //#endregion
184
+ exports.DGPopover = DGPopover;
185
+ exports.DGPopoverAnchor = DGPopoverAnchor;
186
+ exports.DGPopoverContent = DGPopoverContent;
@@ -0,0 +1,9 @@
1
+ import { PopoverRootProps } from '@cerberus-design/react';
2
+ import { HTMLAttributes, PropsWithChildren, RefObject } from 'react';
3
+ export declare function DGPopover(props: PropsWithChildren<PopoverRootProps>): import("react/jsx-runtime").JSX.Element;
4
+ export declare function DGPopoverAnchor(props: PropsWithChildren<HTMLAttributes<HTMLDivElement>>): import("react/jsx-runtime").JSX.Element;
5
+ interface DGPopoverContentProps {
6
+ ref: RefObject<HTMLDivElement | null>;
7
+ }
8
+ export declare function DGPopoverContent(props: DGPopoverContentProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,9 @@
1
+ import { PopoverRootProps } from '@cerberus-design/react';
2
+ import { HTMLAttributes, PropsWithChildren, RefObject } from 'react';
3
+ export declare function DGPopover(props: PropsWithChildren<PopoverRootProps>): import("react/jsx-runtime").JSX.Element;
4
+ export declare function DGPopoverAnchor(props: PropsWithChildren<HTMLAttributes<HTMLDivElement>>): import("react/jsx-runtime").JSX.Element;
5
+ interface DGPopoverContentProps {
6
+ ref: RefObject<HTMLDivElement | null>;
7
+ }
8
+ export declare function DGPopoverContent(props: DGPopoverContentProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,184 @@
1
+ "use client";
2
+ "use client";
3
+ import { OPERATORS } from "../const.js";
4
+ import { useDataGridContext } from "../context.client.js";
5
+ import { Field, For, IconButton, IconButtonRoot, Input, Option, PopoverParts, Portal, Select, cerberus, createSelectCollection, useCerberusContext } from "@cerberus-design/react";
6
+ import { batch, createComputed, useRead } from "@cerberus-design/signals";
7
+ import { Box, HStack, Stack } from "styled-system/jsx";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ import { useFormStatus } from "react-dom";
10
+ //#region src/components/popover.client.tsx
11
+ function DGPopover(props) {
12
+ const store = useDataGridContext();
13
+ const colH = useRead(store.rowSize);
14
+ const open = useRead(store.showColFilter);
15
+ const mainAxis = 119 + colH;
16
+ return /* @__PURE__ */ jsx(PopoverParts.Root, {
17
+ ...props,
18
+ lazyMount: true,
19
+ open,
20
+ onOpenChange: (details) => {
21
+ if (!details.open) store.setColFilter((prev) => ({
22
+ ...prev,
23
+ active: prev.active.filter((filterId) => prev.filters[filterId].value),
24
+ editing: null
25
+ }));
26
+ store.setShowColFilter(details.open);
27
+ },
28
+ portalled: true,
29
+ positioning: {
30
+ placement: "top-start",
31
+ offset: { mainAxis: -mainAxis }
32
+ }
33
+ });
34
+ }
35
+ function DGPopoverAnchor(props) {
36
+ return /* @__PURE__ */ jsx(PopoverParts.Anchor, {
37
+ ...props,
38
+ asChild: true
39
+ });
40
+ }
41
+ function DGPopoverContent(props) {
42
+ const { icons } = useCerberusContext();
43
+ const CloseIcon = icons?.close;
44
+ return /* @__PURE__ */ jsx(Portal, {
45
+ container: props.ref,
46
+ children: /* @__PURE__ */ jsx(PopoverParts.Positioner, { children: /* @__PURE__ */ jsxs(PopoverParts.Content, {
47
+ css: { "--popover-size": "37.5rem!" },
48
+ children: [/* @__PURE__ */ jsxs(PopoverParts.Header, { children: [/* @__PURE__ */ jsx(PopoverParts.CloseTrigger, {
49
+ asChild: true,
50
+ children: /* @__PURE__ */ jsx(IconButtonRoot, {
51
+ size: "sm",
52
+ usage: "ghost",
53
+ children: /* @__PURE__ */ jsx(CloseIcon, {})
54
+ })
55
+ }), /* @__PURE__ */ jsx(PopoverParts.Title, {
56
+ textStyle: "label-md",
57
+ children: "Filter By Column"
58
+ })] }), /* @__PURE__ */ jsx(FilterForm, {})]
59
+ }) })
60
+ });
61
+ }
62
+ function FilterForm() {
63
+ const store = useDataGridContext();
64
+ function filter(formData) {
65
+ const payload = {
66
+ id: formData.get("column"),
67
+ operator: formData.get("operator"),
68
+ value: formData.get("value")
69
+ };
70
+ batch(() => {
71
+ store.setColFilter((prev) => ({
72
+ ...prev,
73
+ active: [...prev.active, payload.id],
74
+ filters: {
75
+ ...prev.filters,
76
+ [payload.id]: payload
77
+ },
78
+ editing: null
79
+ }));
80
+ store.setShowColFilter(false);
81
+ });
82
+ }
83
+ return /* @__PURE__ */ jsx(cerberus.form, {
84
+ action: filter,
85
+ w: "full",
86
+ children: /* @__PURE__ */ jsx(PopoverParts.Body, { children: /* @__PURE__ */ jsx(FormFields, {}) })
87
+ });
88
+ }
89
+ function FormFields() {
90
+ const status = useFormStatus();
91
+ const store = useDataGridContext();
92
+ const cols = useRead(store.columns);
93
+ const colFilters = useRead(store.colFilters);
94
+ const filterToEdit = createComputed(() => {
95
+ return colFilters.filters[colFilters.editing];
96
+ });
97
+ const colCollection = createSelectCollection(cols.map((col) => ({
98
+ value: col.id,
99
+ label: String(col.original.header)
100
+ })));
101
+ const operatorCollection = createSelectCollection(Object.keys(OPERATORS).map((key) => ({
102
+ value: key,
103
+ label: OPERATORS[key].replaceAll("_", " ")
104
+ })));
105
+ if (!filterToEdit()) return null;
106
+ return /* @__PURE__ */ jsx(Stack, {
107
+ direction: "column",
108
+ gap: "sm",
109
+ w: "full",
110
+ children: /* @__PURE__ */ jsx(FormSection, {
111
+ colCollection,
112
+ operatorCollection,
113
+ defaultColValue: cols[0].id,
114
+ filter: filterToEdit(),
115
+ status
116
+ })
117
+ });
118
+ }
119
+ function FormSection(props) {
120
+ const { filter } = props;
121
+ return /* @__PURE__ */ jsxs(HStack, {
122
+ gap: "sm",
123
+ w: "full",
124
+ children: [
125
+ /* @__PURE__ */ jsx(Field, {
126
+ label: "Select a column",
127
+ children: /* @__PURE__ */ jsx(Select, {
128
+ collection: props.colCollection,
129
+ name: "column",
130
+ placeholder: "Choose option",
131
+ size: "sm",
132
+ defaultValue: [filter?.id ?? props.defaultColValue],
133
+ children: /* @__PURE__ */ jsx(For, {
134
+ each: props.colCollection.items,
135
+ children: (item) => /* @__PURE__ */ jsx(Option, { item }, item.value)
136
+ })
137
+ })
138
+ }),
139
+ /* @__PURE__ */ jsx(Field, {
140
+ label: "Select a operator",
141
+ children: /* @__PURE__ */ jsx(Select, {
142
+ collection: props.operatorCollection,
143
+ name: "operator",
144
+ placeholder: "Choose option",
145
+ size: "sm",
146
+ defaultValue: [filter?.operator ?? OPERATORS.contains],
147
+ children: /* @__PURE__ */ jsx(For, {
148
+ each: props.operatorCollection.items,
149
+ children: (item) => /* @__PURE__ */ jsx(Option, { item }, item.value)
150
+ })
151
+ })
152
+ }),
153
+ /* @__PURE__ */ jsx(Field, {
154
+ label: "Value",
155
+ required: true,
156
+ children: /* @__PURE__ */ jsx(Input, {
157
+ name: "value",
158
+ size: "sm",
159
+ defaultValue: filter?.value
160
+ })
161
+ }),
162
+ /* @__PURE__ */ jsx(SubmitButton, { pending: props.status.pending })
163
+ ]
164
+ });
165
+ }
166
+ function SubmitButton(props) {
167
+ const { icons } = useCerberusContext();
168
+ const { arrowRight: Icon } = icons;
169
+ return /* @__PURE__ */ jsx(Box, {
170
+ alignSelf: "flex-end",
171
+ mb: "0.25rem",
172
+ children: /* @__PURE__ */ jsx(IconButton, {
173
+ ariaLabel: "Submit form",
174
+ disabled: props.pending,
175
+ type: "submit",
176
+ usage: "filled",
177
+ h: "2rem!",
178
+ w: "2rem!",
179
+ children: /* @__PURE__ */ jsx(Icon, {})
180
+ })
181
+ });
182
+ }
183
+ //#endregion
184
+ export { DGPopover, DGPopoverAnchor, DGPopoverContent };
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  "use client";
3
+ const require_const = require("../const.cjs");
3
4
  let _cerberus_design_react = require("@cerberus-design/react");
4
5
  let styled_system_jsx = require("styled-system/jsx");
5
6
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -17,7 +18,7 @@ function MatchSortItems(props) {
17
18
  }
18
19
  function UnsortItem() {
19
20
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.MenuItem, {
20
- value: "unsort",
21
+ value: require_const.FEATURE_VALUES.unsort,
21
22
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.HStack, {
22
23
  gap: "sm",
23
24
  w: "full",
@@ -29,7 +30,7 @@ function SortAsc() {
29
30
  const { icons } = (0, _cerberus_design_react.useCerberusContext)();
30
31
  const Icon = icons.sortAsc;
31
32
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.MenuItem, {
32
- value: "sort_asc",
33
+ value: require_const.FEATURE_VALUES.sortAsc,
33
34
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.HStack, {
34
35
  gap: "sm",
35
36
  w: "full",
@@ -41,7 +42,7 @@ function SortDesc() {
41
42
  const { icons } = (0, _cerberus_design_react.useCerberusContext)();
42
43
  const Icon = icons.sortDesc;
43
44
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.MenuItem, {
44
- value: "sort_desc",
45
+ value: require_const.FEATURE_VALUES.sortDesc,
45
46
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.HStack, {
46
47
  gap: "sm",
47
48
  w: "full",
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  "use client";
3
+ import { FEATURE_VALUES } from "../const.js";
3
4
  import { MenuItem, useCerberusContext } from "@cerberus-design/react";
4
5
  import { HStack, Square } from "styled-system/jsx";
5
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -17,7 +18,7 @@ function MatchSortItems(props) {
17
18
  }
18
19
  function UnsortItem() {
19
20
  return /* @__PURE__ */ jsx(MenuItem, {
20
- value: "unsort",
21
+ value: FEATURE_VALUES.unsort,
21
22
  children: /* @__PURE__ */ jsxs(HStack, {
22
23
  gap: "sm",
23
24
  w: "full",
@@ -29,7 +30,7 @@ function SortAsc() {
29
30
  const { icons } = useCerberusContext();
30
31
  const Icon = icons.sortAsc;
31
32
  return /* @__PURE__ */ jsx(MenuItem, {
32
- value: "sort_asc",
33
+ value: FEATURE_VALUES.sortAsc,
33
34
  children: /* @__PURE__ */ jsxs(HStack, {
34
35
  gap: "sm",
35
36
  w: "full",
@@ -41,7 +42,7 @@ function SortDesc() {
41
42
  const { icons } = useCerberusContext();
42
43
  const Icon = icons.sortDesc;
43
44
  return /* @__PURE__ */ jsx(MenuItem, {
44
- value: "sort_desc",
45
+ value: FEATURE_VALUES.sortDesc,
45
46
  children: /* @__PURE__ */ jsxs(HStack, {
46
47
  gap: "sm",
47
48
  w: "full",
@@ -0,0 +1,115 @@
1
+ "use client";
2
+ "use client";
3
+ const require_const = require("../const.cjs");
4
+ const require_context_client = require("../context.client.cjs");
5
+ const require_popover_client = require("./popover.client.cjs");
6
+ const require_virtualizer_client = require("../virtualizer.client.cjs");
7
+ const require_grid_client = require("./grid.client.cjs");
8
+ const require_overlays = require("./overlays.cjs");
9
+ let _cerberus_design_react = require("@cerberus-design/react");
10
+ let _cerberus_design_signals = require("@cerberus-design/signals");
11
+ let react = require("react");
12
+ let styled_system_jsx = require("styled-system/jsx");
13
+ let react_jsx_runtime = require("react/jsx-runtime");
14
+ //#region src/components/viewport.client.tsx
15
+ var GridViewport = (0, react.memo)(function GridViewport(props) {
16
+ const viewportRef = (0, react.useRef)(null);
17
+ const store = require_context_client.useDataGridContext();
18
+ const columns = (0, _cerberus_design_signals.useRead)(store.columns);
19
+ const rowCount = (0, _cerberus_design_signals.useRead)(store.rowCount);
20
+ const staticRows = (0, _cerberus_design_signals.useRead)(store.rows);
21
+ const pending = (0, _cerberus_design_signals.useRead)(store.pending);
22
+ const shouldLock = (0, _cerberus_design_signals.createComputed)(() => rowCount <= 0);
23
+ const hasNonSkeleton = (0, react.useMemo)(() => {
24
+ const overlays = props.overlays;
25
+ if (!overlays) return false;
26
+ return overlays?.pending !== "skeleton";
27
+ }, [props.overlays]);
28
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.Scrollable, {
29
+ "data-scope": require_const.SCOPE,
30
+ "data-part": require_const.PARTS.VIEWPORT,
31
+ "data-lock": pending && hasNonSkeleton || shouldLock(),
32
+ hideScrollbar: true,
33
+ h: "full",
34
+ minH: "0",
35
+ minW: "full",
36
+ pos: "relative",
37
+ w: "full",
38
+ css: { "&:is([data-lock=true])": { overflow: "hidden!" } },
39
+ ref: viewportRef,
40
+ children: [
41
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(styled_system_jsx.Box, {
42
+ role: "grid",
43
+ "aria-rowcount": staticRows.length + 1,
44
+ "aria-colcount": columns.length,
45
+ h: "var(--row-height)",
46
+ pos: "sticky",
47
+ top: "0",
48
+ w: "var(--total-grid-width)",
49
+ zIndex: "sticky",
50
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(styled_system_jsx.HStack, {
51
+ "aria-rowindex": 1,
52
+ role: "rowgroup",
53
+ gap: "0",
54
+ h: "full",
55
+ pos: "relative",
56
+ w: "full",
57
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.For, {
58
+ each: columns,
59
+ children: (col) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
60
+ when: col.isVisible(),
61
+ children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_grid_client.GridHeaderCell, { column: col })
62
+ }, col.id)
63
+ })
64
+ })
65
+ }),
66
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
67
+ when: rowCount > 0,
68
+ fallback: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_overlays.NoContentOverlay, { custom: props.overlays?.noContent }),
69
+ children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableRows, { viewportRef })
70
+ }),
71
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
72
+ when: pending,
73
+ children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_overlays.PendingOverlay, { variant: props.overlays?.pending })
74
+ }),
75
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_popover_client.DGPopoverContent, { ref: props.rootRef })
76
+ ]
77
+ });
78
+ });
79
+ var TableRows = (0, react.memo)((props) => {
80
+ const store = require_context_client.useDataGridContext();
81
+ const { virtualRows, totalHeight } = require_virtualizer_client.useVirtualizer(store, props.viewportRef);
82
+ const isServerPaginated = (0, _cerberus_design_signals.useRead)(store.isServerPaginated);
83
+ const staticRows = (0, _cerberus_design_signals.useRead)(store.rows);
84
+ const currentPageRange = (0, _cerberus_design_signals.useRead)(store.currentPageRange);
85
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
86
+ when: isServerPaginated,
87
+ fallback: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(styled_system_jsx.Box, {
88
+ pos: "relative",
89
+ w: "var(--total-grid-width)",
90
+ style: { height: `${totalHeight}px` },
91
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.For, {
92
+ each: virtualRows,
93
+ children: (vRow) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_grid_client.GridRow, {
94
+ row: vRow.data,
95
+ index: vRow.index,
96
+ offsetY: vRow.offsetY
97
+ }, vRow.index)
98
+ })
99
+ }),
100
+ children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(styled_system_jsx.Stack, {
101
+ direction: "column",
102
+ gap: "0",
103
+ w: "var(--total-grid-width)",
104
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.For, {
105
+ each: staticRows.slice(currentPageRange.start, currentPageRange.end),
106
+ children: (row, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_grid_client.GridRow, {
107
+ row,
108
+ index
109
+ }, index)
110
+ })
111
+ })
112
+ });
113
+ });
114
+ //#endregion
115
+ exports.GridViewport = GridViewport;
@@ -0,0 +1,8 @@
1
+ import { RefObject, NamedExoticComponent } from 'react';
2
+ import { OverlaySlots } from '../types';
3
+ interface GridViewportProps {
4
+ rootRef: RefObject<HTMLDivElement | null>;
5
+ overlays?: OverlaySlots;
6
+ }
7
+ export declare const GridViewport: NamedExoticComponent<GridViewportProps>;
8
+ export {};
@@ -0,0 +1,8 @@
1
+ import { RefObject, NamedExoticComponent } from 'react';
2
+ import { OverlaySlots } from '../types';
3
+ interface GridViewportProps {
4
+ rootRef: RefObject<HTMLDivElement | null>;
5
+ overlays?: OverlaySlots;
6
+ }
7
+ export declare const GridViewport: NamedExoticComponent<GridViewportProps>;
8
+ export {};