@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,115 @@
1
+ "use client";
2
+ "use client";
3
+ import { PARTS, SCOPE } from "../const.js";
4
+ import { useDataGridContext } from "../context.client.js";
5
+ import { DGPopoverContent } from "./popover.client.js";
6
+ import { useVirtualizer } from "../virtualizer.client.js";
7
+ import { GridHeaderCell, GridRow } from "./grid.client.js";
8
+ import { NoContentOverlay, PendingOverlay } from "./overlays.js";
9
+ import { For, Show } from "@cerberus-design/react";
10
+ import { createComputed, useRead } from "@cerberus-design/signals";
11
+ import { memo, useMemo, useRef } from "react";
12
+ import { Box, HStack, Scrollable, Stack } from "styled-system/jsx";
13
+ import { jsx, jsxs } from "react/jsx-runtime";
14
+ //#region src/components/viewport.client.tsx
15
+ var GridViewport = memo(function GridViewport(props) {
16
+ const viewportRef = useRef(null);
17
+ const store = useDataGridContext();
18
+ const columns = useRead(store.columns);
19
+ const rowCount = useRead(store.rowCount);
20
+ const staticRows = useRead(store.rows);
21
+ const pending = useRead(store.pending);
22
+ const shouldLock = createComputed(() => rowCount <= 0);
23
+ const hasNonSkeleton = useMemo(() => {
24
+ const overlays = props.overlays;
25
+ if (!overlays) return false;
26
+ return overlays?.pending !== "skeleton";
27
+ }, [props.overlays]);
28
+ return /* @__PURE__ */ jsxs(Scrollable, {
29
+ "data-scope": SCOPE,
30
+ "data-part": 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__ */ 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__ */ jsx(HStack, {
51
+ "aria-rowindex": 1,
52
+ role: "rowgroup",
53
+ gap: "0",
54
+ h: "full",
55
+ pos: "relative",
56
+ w: "full",
57
+ children: /* @__PURE__ */ jsx(For, {
58
+ each: columns,
59
+ children: (col) => /* @__PURE__ */ jsx(Show, {
60
+ when: col.isVisible(),
61
+ children: () => /* @__PURE__ */ jsx(GridHeaderCell, { column: col })
62
+ }, col.id)
63
+ })
64
+ })
65
+ }),
66
+ /* @__PURE__ */ jsx(Show, {
67
+ when: rowCount > 0,
68
+ fallback: /* @__PURE__ */ jsx(NoContentOverlay, { custom: props.overlays?.noContent }),
69
+ children: () => /* @__PURE__ */ jsx(TableRows, { viewportRef })
70
+ }),
71
+ /* @__PURE__ */ jsx(Show, {
72
+ when: pending,
73
+ children: () => /* @__PURE__ */ jsx(PendingOverlay, { variant: props.overlays?.pending })
74
+ }),
75
+ /* @__PURE__ */ jsx(DGPopoverContent, { ref: props.rootRef })
76
+ ]
77
+ });
78
+ });
79
+ var TableRows = memo((props) => {
80
+ const store = useDataGridContext();
81
+ const { virtualRows, totalHeight } = useVirtualizer(store, props.viewportRef);
82
+ const isServerPaginated = useRead(store.isServerPaginated);
83
+ const staticRows = useRead(store.rows);
84
+ const currentPageRange = useRead(store.currentPageRange);
85
+ return /* @__PURE__ */ jsx(Show, {
86
+ when: isServerPaginated,
87
+ fallback: /* @__PURE__ */ jsx(Box, {
88
+ pos: "relative",
89
+ w: "var(--total-grid-width)",
90
+ style: { height: `${totalHeight}px` },
91
+ children: /* @__PURE__ */ jsx(For, {
92
+ each: virtualRows,
93
+ children: (vRow) => /* @__PURE__ */ jsx(GridRow, {
94
+ row: vRow.data,
95
+ index: vRow.index,
96
+ offsetY: vRow.offsetY
97
+ }, vRow.index)
98
+ })
99
+ }),
100
+ children: () => /* @__PURE__ */ jsx(Stack, {
101
+ direction: "column",
102
+ gap: "0",
103
+ w: "var(--total-grid-width)",
104
+ children: /* @__PURE__ */ jsx(For, {
105
+ each: staticRows.slice(currentPageRange.start, currentPageRange.end),
106
+ children: (row, index) => /* @__PURE__ */ jsx(GridRow, {
107
+ row,
108
+ index
109
+ }, index)
110
+ })
111
+ })
112
+ });
113
+ });
114
+ //#endregion
115
+ export { GridViewport };
package/dist/const.cjs CHANGED
@@ -10,11 +10,35 @@ var PARTS = {
10
10
  CELL: "row-cell",
11
11
  FOOTER: "footer"
12
12
  };
13
+ var FEATURE_VALUES = {
14
+ filter: "filter",
15
+ filterClear: "clear-filter",
16
+ pin: "pin",
17
+ pinRight: "pin_right",
18
+ pinLeft: "pin_left",
19
+ unpin: "unpin",
20
+ unpinRight: "unpin_right",
21
+ unpinLeft: "unpin_left",
22
+ unsort: "unsort",
23
+ sort: "sort",
24
+ sortAsc: "sort_asc",
25
+ sortDesc: "sort_desc"
26
+ };
13
27
  var DEFAULT_PAGE_SIZES = [
14
28
  25,
15
29
  50,
16
30
  100
17
31
  ];
32
+ var OPERATORS = {
33
+ contains: "contains",
34
+ equals: "equals",
35
+ starts_with: "starts_with",
36
+ ends_with: "ends_with",
37
+ greater_than: "greater_than",
38
+ less_than: "less_than",
39
+ between: "between",
40
+ includes_some: "includes_some"
41
+ };
18
42
  var ROW_SIZES = {
19
43
  items: [
20
44
  "xs",
@@ -46,6 +70,8 @@ var DEFAULT_THEME = {
46
70
  //#endregion
47
71
  exports.DEFAULT_PAGE_SIZES = DEFAULT_PAGE_SIZES;
48
72
  exports.DEFAULT_THEME = DEFAULT_THEME;
73
+ exports.FEATURE_VALUES = FEATURE_VALUES;
74
+ exports.OPERATORS = OPERATORS;
49
75
  exports.PARTS = PARTS;
50
76
  exports.ROW_SIZES = ROW_SIZES;
51
77
  exports.SCOPE = SCOPE;
package/dist/const.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ThemeOptions } from './types';
1
+ import { FilterOperator, ThemeOptions } from './types';
2
2
  export declare const SCOPE = "data-grid";
3
3
  export declare const DEFAULT_COL_H = 40;
4
4
  export declare const PARTS: {
@@ -10,11 +10,26 @@ export declare const PARTS: {
10
10
  CELL: string;
11
11
  FOOTER: string;
12
12
  };
13
+ export declare const FEATURE_VALUES: {
14
+ filter: string;
15
+ filterClear: string;
16
+ pin: string;
17
+ pinRight: string;
18
+ pinLeft: string;
19
+ unpin: string;
20
+ unpinRight: string;
21
+ unpinLeft: string;
22
+ unsort: string;
23
+ sort: string;
24
+ sortAsc: string;
25
+ sortDesc: string;
26
+ };
13
27
  export declare const DEFAULT_PAGE_IDX = 1;
14
28
  export declare const SM_PAGE_SIZE = 25;
15
29
  export declare const MD_PAGE_SIZE = 50;
16
30
  export declare const LG_PAGE_SIZE = 100;
17
31
  export declare const DEFAULT_PAGE_SIZES: number[];
32
+ export declare const OPERATORS: Record<FilterOperator, FilterOperator>;
18
33
  export declare const XS = "xs";
19
34
  export declare const SM = "sm";
20
35
  export declare const MD = "md";
package/dist/const.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ThemeOptions } from './types';
1
+ import { FilterOperator, ThemeOptions } from './types';
2
2
  export declare const SCOPE = "data-grid";
3
3
  export declare const DEFAULT_COL_H = 40;
4
4
  export declare const PARTS: {
@@ -10,11 +10,26 @@ export declare const PARTS: {
10
10
  CELL: string;
11
11
  FOOTER: string;
12
12
  };
13
+ export declare const FEATURE_VALUES: {
14
+ filter: string;
15
+ filterClear: string;
16
+ pin: string;
17
+ pinRight: string;
18
+ pinLeft: string;
19
+ unpin: string;
20
+ unpinRight: string;
21
+ unpinLeft: string;
22
+ unsort: string;
23
+ sort: string;
24
+ sortAsc: string;
25
+ sortDesc: string;
26
+ };
13
27
  export declare const DEFAULT_PAGE_IDX = 1;
14
28
  export declare const SM_PAGE_SIZE = 25;
15
29
  export declare const MD_PAGE_SIZE = 50;
16
30
  export declare const LG_PAGE_SIZE = 100;
17
31
  export declare const DEFAULT_PAGE_SIZES: number[];
32
+ export declare const OPERATORS: Record<FilterOperator, FilterOperator>;
18
33
  export declare const XS = "xs";
19
34
  export declare const SM = "sm";
20
35
  export declare const MD = "md";
package/dist/const.js CHANGED
@@ -10,11 +10,35 @@ var PARTS = {
10
10
  CELL: "row-cell",
11
11
  FOOTER: "footer"
12
12
  };
13
+ var FEATURE_VALUES = {
14
+ filter: "filter",
15
+ filterClear: "clear-filter",
16
+ pin: "pin",
17
+ pinRight: "pin_right",
18
+ pinLeft: "pin_left",
19
+ unpin: "unpin",
20
+ unpinRight: "unpin_right",
21
+ unpinLeft: "unpin_left",
22
+ unsort: "unsort",
23
+ sort: "sort",
24
+ sortAsc: "sort_asc",
25
+ sortDesc: "sort_desc"
26
+ };
13
27
  var DEFAULT_PAGE_SIZES = [
14
28
  25,
15
29
  50,
16
30
  100
17
31
  ];
32
+ var OPERATORS = {
33
+ contains: "contains",
34
+ equals: "equals",
35
+ starts_with: "starts_with",
36
+ ends_with: "ends_with",
37
+ greater_than: "greater_than",
38
+ less_than: "less_than",
39
+ between: "between",
40
+ includes_some: "includes_some"
41
+ };
18
42
  var ROW_SIZES = {
19
43
  items: [
20
44
  "xs",
@@ -44,4 +68,4 @@ var DEFAULT_THEME = {
44
68
  gridCellPinnedBorderColor: "var(--cerberus-colors-page-border-200)"
45
69
  };
46
70
  //#endregion
47
- export { DEFAULT_PAGE_SIZES, DEFAULT_THEME, PARTS, ROW_SIZES, SCOPE };
71
+ export { DEFAULT_PAGE_SIZES, DEFAULT_THEME, FEATURE_VALUES, OPERATORS, PARTS, ROW_SIZES, SCOPE };
package/dist/index.cjs CHANGED
@@ -1,9 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_const = require("./const.cjs");
2
3
  const require_context_client = require("./context.client.cjs");
3
4
  const require_data_grid_client = require("./components/data-grid.client.cjs");
4
5
  const require_cerby_data_grid_client = require("./components/cerby-data-grid.client.cjs");
5
6
  const require_column_helpers = require("./column-helpers.cjs");
6
7
  exports.CerberusDataGrid = require_cerby_data_grid_client.CerberusDataGrid;
7
8
  exports.DataGrid = require_data_grid_client.DataGrid;
9
+ exports.OPERATORS = require_const.OPERATORS;
8
10
  exports.createColumnHelper = require_column_helpers.createColumnHelper;
9
11
  exports.useDataGridContext = require_context_client.useDataGridContext;
package/dist/index.d.cts CHANGED
@@ -6,4 +6,5 @@ export * from './components/data-grid.client';
6
6
  export * from './components/cerby-data-grid.client';
7
7
  export { useDataGridContext } from './context.client';
8
8
  export * from './column-helpers';
9
+ export { OPERATORS } from './const';
9
10
  export * from './types';
package/dist/index.d.ts CHANGED
@@ -6,4 +6,5 @@ export * from './components/data-grid.client';
6
6
  export * from './components/cerby-data-grid.client';
7
7
  export { useDataGridContext } from './context.client';
8
8
  export * from './column-helpers';
9
+ export { OPERATORS } from './const';
9
10
  export * from './types';
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
+ import { OPERATORS } from "./const.js";
1
2
  import { useDataGridContext } from "./context.client.js";
2
3
  import { DataGrid } from "./components/data-grid.client.js";
3
4
  import { CerberusDataGrid } from "./components/cerby-data-grid.client.js";
4
5
  import { createColumnHelper } from "./column-helpers.js";
5
- export { CerberusDataGrid, DataGrid, createColumnHelper, useDataGridContext };
6
+ export { CerberusDataGrid, DataGrid, OPERATORS, createColumnHelper, useDataGridContext };
@@ -102,34 +102,7 @@
102
102
  "transitionProperty]___[value:opacity",
103
103
  "transitionDuration]___[value:fast",
104
104
  "opacity]___[value:1]___[cond:_groupHover",
105
- "overflow]___[value:auto",
106
- "scrollBehavior]___[value:smooth",
107
- "scrollbarGutter]___[value:stable",
108
- "display]___[value:none]___[cond:&::-webkit-scrollbar",
109
- "width]___[value:0.5em]___[cond:&::-webkit-scrollbar",
110
- "background]___[value:transparent]___[cond:&::-webkit-scrollbar-track",
111
- "outline]___[value:none]___[cond:&::-webkit-scrollbar-track",
112
- "backgroundColor]___[value:page.border.100]___[cond:&::-webkit-scrollbar-thumb",
113
- "borderRadius]___[value:5px]___[cond:&::-webkit-scrollbar-thumb",
114
- "outline]___[value:none]___[cond:&::-webkit-scrollbar-thumb",
115
- "backgroundColor]___[value:page.border.100]___[cond:&:hover::-webkit-scrollbar-thumb",
116
- "minHeight]___[value:0",
117
- "minWidth]___[value:full",
118
- "height]___[value:var(--row-height)",
119
- "position]___[value:sticky",
120
- "top]___[value:0",
121
- "width]___[value:var(--total-grid-width)",
122
- "zIndex]___[value:sticky",
123
- "bottom]___[value:0",
124
- "position]___[value:absolute",
125
- "width]___[value:0.75rem",
126
- "zIndex]___[value:inherit",
127
- "backgroundGradient]___[value:to-r]___[cond:_leftPinned",
128
- "gradientFrom]___[value:black/10]___[cond:_leftPinned",
129
- "gradientTo]___[value:transparent]___[cond:_leftPinned",
130
- "backgroundGradient]___[value:to-l]___[cond:_rightPinned",
131
- "gradientFrom]___[value:black/10]___[cond:_rightPinned",
132
- "gradientTo]___[value:transparent]___[cond:_rightPinned",
105
+ "gap]___[value:sm",
133
106
  "backgroundColor]___[value:var(--head-cell-bg-color)",
134
107
  "borderBottom]___[value:1px solid",
135
108
  "borderBottomColor]___[value:var(--head-cell-border-bottom-color)",
@@ -145,7 +118,6 @@
145
118
  "borderRight]___[value:1px solid]___[cond:_leftPinned",
146
119
  "borderLeftColor]___[value:page.border.200]___[cond:_rightPinned",
147
120
  "borderLeft]___[value:1px solid]___[cond:_rightPinned",
148
- "gap]___[value:sm",
149
121
  "opacity]___[value:1]___[cond:_groupHover<___>& :is(button)",
150
122
  "backgroundColor]___[value:inherit",
151
123
  "borderColor]___[value:var(--grid-cell-border-color)",
@@ -155,10 +127,35 @@
155
127
  "position]___[value:absolute]___[cond:&:is([data-render=virtualized])",
156
128
  "left]___[value:0]___[cond:&:is([data-render=virtualized])",
157
129
  "backgroundColor]___[value:var(--row-bg-color)",
130
+ "height]___[value:var(--row-height)",
158
131
  "backgroundColor]___[value:var(--row-even-bg-color)]___[cond:_even",
159
132
  "backgroundColor]___[value:var(--row-hover-bg-color)]___[cond:_hover",
133
+ "content]___[value:Edit filters",
160
134
  "content]___[value:Sort Ascending",
161
135
  "content]___[value:Sort Decending",
136
+ "bottom]___[value:0",
137
+ "position]___[value:absolute",
138
+ "paddingInline]___[value:sm",
139
+ "right]___[value:0",
140
+ "top]___[value:0",
141
+ "width]___[value:fit-content",
142
+ "zIndex]___[value:11",
143
+ "marginBlock]___[value:xs",
144
+ "borderRadius]___[value:md",
145
+ "width]___[value:0.75rem",
146
+ "zIndex]___[value:inherit",
147
+ "backgroundGradient]___[value:to-r]___[cond:_leftPinned",
148
+ "gradientFrom]___[value:black/10]___[cond:_leftPinned",
149
+ "gradientTo]___[value:transparent]___[cond:_leftPinned",
150
+ "backgroundGradient]___[value:to-l]___[cond:_rightPinned",
151
+ "gradientFrom]___[value:black/10]___[cond:_rightPinned",
152
+ "gradientTo]___[value:transparent]___[cond:_rightPinned",
153
+ "left]___[value:0",
154
+ "top]___[value:var(--row-height)",
155
+ "zIndex]___[value:decorator",
156
+ "flex]___[value:0 0 auto",
157
+ "width]___[value:12",
158
+ "height]___[value:12",
162
159
  "backgroundColor]___[value:page.surface.100",
163
160
  "borderTop]___[value:1px solid",
164
161
  "borderTopColor]___[value:page.border.initial",
@@ -168,8 +165,29 @@
168
165
  "height]___[value:1rem",
169
166
  "borderInlineEndWidth]___[value:var(--thickness)",
170
167
  "borderColor]___[value:page.border.200",
171
- "flex]___[value:0 0 auto",
168
+ "--popover-size]___[value:37.5rem!",
169
+ "alignSelf]___[value:flex-end",
170
+ "marginBottom]___[value:0.25rem",
171
+ "height]___[value:2rem!",
172
+ "width]___[value:2rem!",
172
173
  "height]___[value:4",
174
+ "overflow]___[value:hidden!]___[cond:&:is([data-lock=true])",
175
+ "overflow]___[value:auto",
176
+ "scrollBehavior]___[value:smooth",
177
+ "scrollbarGutter]___[value:stable",
178
+ "display]___[value:none]___[cond:&::-webkit-scrollbar",
179
+ "width]___[value:0.5em]___[cond:&::-webkit-scrollbar",
180
+ "background]___[value:transparent]___[cond:&::-webkit-scrollbar-track",
181
+ "outline]___[value:none]___[cond:&::-webkit-scrollbar-track",
182
+ "backgroundColor]___[value:page.border.100]___[cond:&::-webkit-scrollbar-thumb",
183
+ "borderRadius]___[value:5px]___[cond:&::-webkit-scrollbar-thumb",
184
+ "outline]___[value:none]___[cond:&::-webkit-scrollbar-thumb",
185
+ "backgroundColor]___[value:page.border.100]___[cond:&:hover::-webkit-scrollbar-thumb",
186
+ "minHeight]___[value:0",
187
+ "minWidth]___[value:full",
188
+ "position]___[value:sticky",
189
+ "width]___[value:var(--total-grid-width)",
190
+ "zIndex]___[value:sticky",
173
191
  "colorPalette]___[value:page",
174
192
  "colorPalette]___[value:action",
175
193
  "colorPalette]___[value:secondary-action",
@@ -313,6 +331,7 @@
313
331
  "size]___[value:sm]___[recipe:progressBar",
314
332
  "usage]___[value:rounded]___[recipe:progressBar",
315
333
  "size]___[value:md]___[recipe:progressBar",
334
+ "size]___[value:xs]___[recipe:progressBar",
316
335
  "usage]___[value:block]___[recipe:progressBar"
317
336
  ],
318
337
  "toast": [],
@@ -324,6 +343,12 @@
324
343
  "layout]___[value:grow]___[recipe:group",
325
344
  "layout]___[value:stack]___[recipe:group"
326
345
  ],
346
+ "popover": [
347
+ "size]___[value:md]___[recipe:popover",
348
+ "size]___[value:xs]___[recipe:popover",
349
+ "size]___[value:sm]___[recipe:popover",
350
+ "size]___[value:lg]___[recipe:popover"
351
+ ],
327
352
  "radioGroup": [
328
353
  "orientation]___[value:horizontal]___[recipe:radioGroup",
329
354
  "size]___[value:sm]___[recipe:radioGroup",
package/dist/store.cjs CHANGED
@@ -11,7 +11,18 @@ function createGridStore(options) {
11
11
  const [containerWidth, setContainerWidth] = (0, _cerberus_design_signals.createSignal)(0);
12
12
  const [rows, setRows] = (0, _cerberus_design_signals.createSignal)(options.data);
13
13
  const [rowSize] = (0, _cerberus_design_signals.createSignal)(require_utils.determineRowHeight(options.rowSize));
14
- const [globalFilter, setGlobalFilter] = (0, _cerberus_design_signals.createSignal)("");
14
+ const [pending, setPending] = (0, _cerberus_design_signals.createSignal)(options.pending ?? false);
15
+ const [hasSkeleton] = (0, _cerberus_design_signals.createSignal)(options.overlays?.pending === "skeleton");
16
+ const [showColFilter, setShowColFilter] = (0, _cerberus_design_signals.createSignal)(false);
17
+ const [globalFilter, setGlobalFilter] = (0, _cerberus_design_signals.createSignal)({
18
+ operator: require_const.OPERATORS.contains,
19
+ value: null
20
+ });
21
+ const [colFilters, setColFilters] = (0, _cerberus_design_signals.createSignal)({
22
+ active: [],
23
+ filters: {},
24
+ editing: null
25
+ });
15
26
  const [sorting, setSorting] = (0, _cerberus_design_signals.createSignal)([]);
16
27
  const [pageIndex, setPageIndex] = (0, _cerberus_design_signals.createSignal)(require_utils.determinePageIndex(options.initialState?.pagination));
17
28
  const [pageSize, setPageSize] = (0, _cerberus_design_signals.createSignal)(require_utils.determinePageSize(options.initialState?.pagination));
@@ -52,17 +63,33 @@ function createGridStore(options) {
52
63
  end: pageIndex() * pageSize()
53
64
  };
54
65
  });
55
- const processedRows = (0, _cerberus_design_signals.createComputed)(() => {
66
+ const filteredRows = (0, _cerberus_design_signals.createComputed)(() => {
56
67
  let result = [...rows()];
57
- const filter = globalFilter().toLowerCase();
58
- const sortState = sorting();
59
- if (filter) result = result.filter((row) => {
68
+ const gFilter = globalFilter();
69
+ const cFilters = colFilters();
70
+ if (cFilters.active.length > 0) result = result.filter((row) => {
71
+ return cFilters.active.every((filterId) => {
72
+ const col = columns().find((c) => c.id === filterId);
73
+ const filter = cFilters.filters[filterId];
74
+ if (!col || !col.filterable) return true;
75
+ const customFn = typeof col.original.features?.filter === "function" ? col.original.features.filter : void 0;
76
+ if (customFn) return customFn(row, col.id, filter.value);
77
+ return require_utils.applyFilterOperator(col.getValue(row), filter.value, filter.operator);
78
+ });
79
+ });
80
+ if (gFilter.value) result = result.filter((row) => {
60
81
  return columns().some((col) => {
61
82
  if (!col.filterable) return false;
62
- return String(col.getValue(row)).toLowerCase().includes(filter);
83
+ return require_utils.applyFilterOperator(col.getValue(row), gFilter.value, gFilter.operator);
63
84
  });
64
85
  });
65
- if (sortState.length > 0) result.sort((a, b) => {
86
+ return result;
87
+ });
88
+ const sortedRows = (0, _cerberus_design_signals.createComputed)(() => {
89
+ const currentRows = [...filteredRows()];
90
+ const sortState = sorting();
91
+ if (sortState.length === 0) return currentRows;
92
+ return currentRows.sort((a, b) => {
66
93
  for (const sort of sortState) {
67
94
  const col = columns().find((c) => c.id === sort.id);
68
95
  if (!col) continue;
@@ -77,9 +104,10 @@ function createGridStore(options) {
77
104
  }
78
105
  return 0;
79
106
  });
80
- return result;
81
107
  });
82
- const rowCount = (0, _cerberus_design_signals.createComputed)(() => require_utils.determineInitialCount(options?.initialState?.pagination) ?? processedRows().length);
108
+ const rowCount = (0, _cerberus_design_signals.createComputed)(() => {
109
+ return require_utils.determineInitialCount(options?.initialState?.pagination) ?? sortedRows().length;
110
+ });
83
111
  const pageCount = (0, _cerberus_design_signals.createComputed)(() => Math.ceil(rowCount() / pageSize()));
84
112
  const orderedColumns = (0, _cerberus_design_signals.createComputed)(() => {
85
113
  const left = [];
@@ -97,18 +125,24 @@ function createGridStore(options) {
97
125
  ...right
98
126
  ];
99
127
  });
100
- const visibleRows = (0, _cerberus_design_signals.createComputed)(() => {
101
- if (pageSize() && pageCount() > 1) {
102
- const currentRange = currentPageRange();
103
- return processedRows().slice(currentRange.start, currentRange.end);
104
- }
105
- return processedRows();
106
- });
107
128
  return {
108
129
  columns,
109
130
  rows,
131
+ rowCount,
132
+ rowSize,
133
+ visibleRows: (0, _cerberus_design_signals.createComputed)(() => {
134
+ if (pageSize() && pageCount() > 1) {
135
+ const currentRange = currentPageRange();
136
+ return sortedRows().slice(currentRange.start, currentRange.end);
137
+ }
138
+ return sortedRows();
139
+ }),
140
+ showColFilter,
110
141
  globalFilter,
142
+ colFilters,
111
143
  sorting,
144
+ pending,
145
+ hasSkeleton,
112
146
  pageCount,
113
147
  pageIndex,
114
148
  pageSize,
@@ -174,13 +208,13 @@ function createGridStore(options) {
174
208
  vars["--grid-cell-pinned-border-color"] = theme.gridCellPinnedBorderColor;
175
209
  return vars;
176
210
  }),
177
- rowCount,
178
- rowSize,
179
211
  totalWidth: (0, _cerberus_design_signals.createComputed)(() => columns().reduce((acc, c) => acc + c.width(), 0)),
180
- visibleRows,
181
212
  updateData: (newData) => {
182
213
  setRows(newData);
183
214
  },
215
+ updatePending: (newState) => {
216
+ setPending(newState);
217
+ },
184
218
  setSort: (colId, direction, multi = false) => {
185
219
  if (direction === null) {
186
220
  setSorting(sorting().filter((s) => s.id !== colId));
@@ -233,10 +267,19 @@ function createGridStore(options) {
233
267
  },
234
268
  setGlobalFilter: (val) => {
235
269
  (0, _cerberus_design_signals.batch)(() => {
236
- setGlobalFilter(val);
270
+ setGlobalFilter((prev) => ({
271
+ ...prev,
272
+ ...val
273
+ }));
237
274
  setPageIndex(1);
238
275
  });
239
276
  },
277
+ setColFilter: (val) => {
278
+ setColFilters(val);
279
+ },
280
+ setShowColFilter: (val) => {
281
+ setShowColFilter(val);
282
+ },
240
283
  setContainerWidth: (w) => {
241
284
  setContainerWidth(w);
242
285
  },