@cerberus-design/data-grid 1.1.3 → 1.2.0

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 +6 -6
@@ -3,8 +3,9 @@
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_grid_client = require("./grid.client.cjs");
7
6
  const require_pagination_client = require("./pagination.client.cjs");
7
+ const require_popover_client = require("./popover.client.cjs");
8
+ const require_viewport_client = require("./viewport.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");
@@ -19,6 +20,8 @@ function DataGridEl(props) {
19
20
  initialState: props.initialState,
20
21
  rowSize: props.rowSize,
21
22
  onPageChange: props.onPageChange,
23
+ overlays: props.overlays,
24
+ pending: props.pending,
22
25
  theme: props.theme
23
26
  }), []);
24
27
  const [ready, setReady] = (0, _cerberus_design_signals.useSignal)(false);
@@ -26,6 +29,9 @@ function DataGridEl(props) {
26
29
  (0, react.useEffect)(() => {
27
30
  store.updateData(data);
28
31
  }, [data, store]);
32
+ (0, react.useEffect)(() => {
33
+ store.updatePending(Boolean(props.pending));
34
+ }, [props.pending, store]);
29
35
  (0, react.useEffect)(() => {
30
36
  const el = rootRef.current;
31
37
  if (!el) return;
@@ -56,7 +62,7 @@ function DataGridEl(props) {
56
62
  children: props.toolbar
57
63
  })
58
64
  }),
59
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.Stack, {
65
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_popover_client.DGPopover, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_popover_client.DGPopoverAnchor, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.Stack, {
60
66
  "data-scope": require_const.SCOPE,
61
67
  "data-part": require_const.PARTS.ROOT,
62
68
  dir: "columns",
@@ -73,9 +79,12 @@ function DataGridEl(props) {
73
79
  ref: rootRef,
74
80
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
75
81
  when: ready,
76
- children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_grid_client.GridViewport, {})
82
+ children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_viewport_client.GridViewport, {
83
+ overlays: props.overlays,
84
+ rootRef
85
+ })
77
86
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_pagination_client.GridPagination, {})]
78
- }),
87
+ }) }) }),
79
88
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
80
89
  when: props.footer,
81
90
  children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(styled_system_jsx.HStack, {
@@ -3,8 +3,9 @@
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 { GridViewport } from "./grid.client.js";
7
6
  import { GridPagination } from "./pagination.client.js";
7
+ import { DGPopover, DGPopoverAnchor } from "./popover.client.js";
8
+ import { GridViewport } from "./viewport.client.js";
8
9
  import { Show } from "@cerberus-design/react";
9
10
  import { createEffect, useSignal } from "@cerberus-design/signals";
10
11
  import { memo, useEffect, useMemo, useRef } from "react";
@@ -19,6 +20,8 @@ function DataGridEl(props) {
19
20
  initialState: props.initialState,
20
21
  rowSize: props.rowSize,
21
22
  onPageChange: props.onPageChange,
23
+ overlays: props.overlays,
24
+ pending: props.pending,
22
25
  theme: props.theme
23
26
  }), []);
24
27
  const [ready, setReady] = useSignal(false);
@@ -26,6 +29,9 @@ function DataGridEl(props) {
26
29
  useEffect(() => {
27
30
  store.updateData(data);
28
31
  }, [data, store]);
32
+ useEffect(() => {
33
+ store.updatePending(Boolean(props.pending));
34
+ }, [props.pending, store]);
29
35
  useEffect(() => {
30
36
  const el = rootRef.current;
31
37
  if (!el) return;
@@ -56,7 +62,7 @@ function DataGridEl(props) {
56
62
  children: props.toolbar
57
63
  })
58
64
  }),
59
- /* @__PURE__ */ jsxs(Stack, {
65
+ /* @__PURE__ */ jsx(DGPopover, { children: /* @__PURE__ */ jsx(DGPopoverAnchor, { children: /* @__PURE__ */ jsxs(Stack, {
60
66
  "data-scope": SCOPE,
61
67
  "data-part": PARTS.ROOT,
62
68
  dir: "columns",
@@ -73,9 +79,12 @@ function DataGridEl(props) {
73
79
  ref: rootRef,
74
80
  children: [/* @__PURE__ */ jsx(Show, {
75
81
  when: ready,
76
- children: () => /* @__PURE__ */ jsx(GridViewport, {})
82
+ children: () => /* @__PURE__ */ jsx(GridViewport, {
83
+ overlays: props.overlays,
84
+ rootRef
85
+ })
77
86
  }), /* @__PURE__ */ jsx(GridPagination, {})]
78
- }),
87
+ }) }) }),
79
88
  /* @__PURE__ */ jsx(Show, {
80
89
  when: props.footer,
81
90
  children: () => /* @__PURE__ */ jsx(HStack, {
@@ -1,6 +1,8 @@
1
1
  "use client";
2
2
  "use client";
3
+ const require_const = require("../const.cjs");
3
4
  const require_context_client = require("../context.client.cjs");
5
+ const require_filter_item_client = require("./filter-item.client.cjs");
4
6
  const require_pinned_items_client = require("./pinned-items.client.cjs");
5
7
  const require_sort_items_client = require("./sort-items.client.cjs");
6
8
  let _cerberus_design_react = require("@cerberus-design/react");
@@ -23,18 +25,42 @@ function HeaderCellOptions(props) {
23
25
  const specialVal = val.split("_");
24
26
  const category = specialVal[0];
25
27
  const action = specialVal[1];
26
- if (val === "filter") return console.log("Show Filter popover...");
27
- if (val === "unsort") return store.setSort(props.id, null);
28
+ switch (val) {
29
+ case require_const.FEATURE_VALUES.filter: return handleInitFilter();
30
+ case require_const.FEATURE_VALUES.filterClear: return store.setColFilter((prev) => ({
31
+ ...prev,
32
+ active: prev.active.filter((id) => id !== props.id),
33
+ editing: null
34
+ }));
35
+ case require_const.FEATURE_VALUES.unsort: return store.setSort(props.id, null);
36
+ default: break;
37
+ }
28
38
  switch (category) {
29
- case "pin": return store.togglePinned(props.id, action);
30
- case "unpin": return store.togglePinned(props.id, false);
31
- case "sort": return store.setSort(props.id, action ?? null);
39
+ case require_const.FEATURE_VALUES.pin: return store.togglePinned(props.id, action);
40
+ case require_const.FEATURE_VALUES.unpin: return store.togglePinned(props.id, false);
41
+ case require_const.FEATURE_VALUES.sort: return store.setSort(props.id, action ?? null);
32
42
  default: console.error("Unhandled action:", {
33
43
  details,
34
44
  action
35
45
  });
36
46
  }
37
47
  }
48
+ function handleInitFilter() {
49
+ store.setColFilter((prev) => ({
50
+ ...prev,
51
+ editing: props.id,
52
+ active: [...prev.active, props.id],
53
+ filters: {
54
+ ...prev.filters,
55
+ [props.id]: {
56
+ id: props.id,
57
+ operator: require_const.OPERATORS.contains,
58
+ value: ""
59
+ }
60
+ }
61
+ }));
62
+ return store.setShowColFilter(true);
63
+ }
38
64
  if (!props.sortable && !props.pinnable && !props.filterable) return null;
39
65
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_cerberus_design_react.Menu, {
40
66
  onSelect: handleSelect,
@@ -63,10 +89,7 @@ function HeaderCellOptions(props) {
63
89
  }),
64
90
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_cerberus_design_react.Show, {
65
91
  when: props.filterable,
66
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.MenuSeparator, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.MenuItem, {
67
- value: "filter",
68
- children: "Filter"
69
- })]
92
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.MenuSeparator, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_filter_item_client.FilterMenuItem, { colId: props.id })]
70
93
  })
71
94
  ] })]
72
95
  });
@@ -1,9 +1,11 @@
1
1
  "use client";
2
2
  "use client";
3
+ import { FEATURE_VALUES, OPERATORS } from "../const.js";
3
4
  import { useDataGridContext } from "../context.client.js";
5
+ import { FilterMenuItem } from "./filter-item.client.js";
4
6
  import { MatchPinnedItems } from "./pinned-items.client.js";
5
7
  import { MatchSortItems } from "./sort-items.client.js";
6
- import { IconButton, Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger, Show, useCerberusContext } from "@cerberus-design/react";
8
+ import { IconButton, Menu, MenuContent, MenuSeparator, MenuTrigger, Show, useCerberusContext } from "@cerberus-design/react";
7
9
  import { useRead } from "@cerberus-design/signals";
8
10
  import { useMemo } from "react";
9
11
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -23,18 +25,42 @@ function HeaderCellOptions(props) {
23
25
  const specialVal = val.split("_");
24
26
  const category = specialVal[0];
25
27
  const action = specialVal[1];
26
- if (val === "filter") return console.log("Show Filter popover...");
27
- if (val === "unsort") return store.setSort(props.id, null);
28
+ switch (val) {
29
+ case FEATURE_VALUES.filter: return handleInitFilter();
30
+ case FEATURE_VALUES.filterClear: return store.setColFilter((prev) => ({
31
+ ...prev,
32
+ active: prev.active.filter((id) => id !== props.id),
33
+ editing: null
34
+ }));
35
+ case FEATURE_VALUES.unsort: return store.setSort(props.id, null);
36
+ default: break;
37
+ }
28
38
  switch (category) {
29
- case "pin": return store.togglePinned(props.id, action);
30
- case "unpin": return store.togglePinned(props.id, false);
31
- case "sort": return store.setSort(props.id, action ?? null);
39
+ case FEATURE_VALUES.pin: return store.togglePinned(props.id, action);
40
+ case FEATURE_VALUES.unpin: return store.togglePinned(props.id, false);
41
+ case FEATURE_VALUES.sort: return store.setSort(props.id, action ?? null);
32
42
  default: console.error("Unhandled action:", {
33
43
  details,
34
44
  action
35
45
  });
36
46
  }
37
47
  }
48
+ function handleInitFilter() {
49
+ store.setColFilter((prev) => ({
50
+ ...prev,
51
+ editing: props.id,
52
+ active: [...prev.active, props.id],
53
+ filters: {
54
+ ...prev.filters,
55
+ [props.id]: {
56
+ id: props.id,
57
+ operator: OPERATORS.contains,
58
+ value: ""
59
+ }
60
+ }
61
+ }));
62
+ return store.setShowColFilter(true);
63
+ }
38
64
  if (!props.sortable && !props.pinnable && !props.filterable) return null;
39
65
  return /* @__PURE__ */ jsxs(Menu, {
40
66
  onSelect: handleSelect,
@@ -63,10 +89,7 @@ function HeaderCellOptions(props) {
63
89
  }),
64
90
  /* @__PURE__ */ jsxs(Show, {
65
91
  when: props.filterable,
66
- children: [/* @__PURE__ */ jsx(MenuSeparator, {}), /* @__PURE__ */ jsx(MenuItem, {
67
- value: "filter",
68
- children: "Filter"
69
- })]
92
+ children: [/* @__PURE__ */ jsx(MenuSeparator, {}), /* @__PURE__ */ jsx(FilterMenuItem, { colId: props.id })]
70
93
  })
71
94
  ] })]
72
95
  });
@@ -0,0 +1,38 @@
1
+ "use client";
2
+ "use client";
3
+ const require_context_client = require("../context.client.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/filter-item.client.tsx
9
+ function FilterMenuItem(props) {
10
+ const colDefs = (0, _cerberus_design_signals.useRead)(require_context_client.useDataGridContext().colFilters);
11
+ const hasFilter = (0, _cerberus_design_signals.createComputed)(() => {
12
+ return colDefs.active.some((filterId) => filterId === props.colId);
13
+ });
14
+ const { icons } = (0, _cerberus_design_react.useCerberusContext)();
15
+ const FilterIcon = icons.filter;
16
+ const ClearIcon = icons.filterClear;
17
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
18
+ when: hasFilter(),
19
+ fallback: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.MenuItem, {
20
+ value: "filter",
21
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.HStack, {
22
+ gap: "sm",
23
+ w: "full",
24
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterIcon, {}), "Filter"]
25
+ })
26
+ }),
27
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.MenuItem, {
28
+ value: "clear-filter",
29
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.HStack, {
30
+ gap: "sm",
31
+ w: "full",
32
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ClearIcon, {}), "Clear Filter"]
33
+ })
34
+ })
35
+ });
36
+ }
37
+ //#endregion
38
+ exports.FilterMenuItem = FilterMenuItem;
@@ -0,0 +1,6 @@
1
+ import { InternalColumn } from '../types';
2
+ interface FilterMenuItemProps<TData> {
3
+ colId: InternalColumn<TData>['id'];
4
+ }
5
+ export declare function FilterMenuItem<TData>(props: FilterMenuItemProps<TData>): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ import { InternalColumn } from '../types';
2
+ interface FilterMenuItemProps<TData> {
3
+ colId: InternalColumn<TData>['id'];
4
+ }
5
+ export declare function FilterMenuItem<TData>(props: FilterMenuItemProps<TData>): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,38 @@
1
+ "use client";
2
+ "use client";
3
+ import { useDataGridContext } from "../context.client.js";
4
+ import { MenuItem, Show, useCerberusContext } from "@cerberus-design/react";
5
+ import { createComputed, useRead } from "@cerberus-design/signals";
6
+ import { HStack } from "styled-system/jsx";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ //#region src/components/filter-item.client.tsx
9
+ function FilterMenuItem(props) {
10
+ const colDefs = useRead(useDataGridContext().colFilters);
11
+ const hasFilter = createComputed(() => {
12
+ return colDefs.active.some((filterId) => filterId === props.colId);
13
+ });
14
+ const { icons } = useCerberusContext();
15
+ const FilterIcon = icons.filter;
16
+ const ClearIcon = icons.filterClear;
17
+ return /* @__PURE__ */ jsx(Show, {
18
+ when: hasFilter(),
19
+ fallback: /* @__PURE__ */ jsx(MenuItem, {
20
+ value: "filter",
21
+ children: /* @__PURE__ */ jsxs(HStack, {
22
+ gap: "sm",
23
+ w: "full",
24
+ children: [/* @__PURE__ */ jsx(FilterIcon, {}), "Filter"]
25
+ })
26
+ }),
27
+ children: /* @__PURE__ */ jsx(MenuItem, {
28
+ value: "clear-filter",
29
+ children: /* @__PURE__ */ jsxs(HStack, {
30
+ gap: "sm",
31
+ w: "full",
32
+ children: [/* @__PURE__ */ jsx(ClearIcon, {}), "Clear Filter"]
33
+ })
34
+ })
35
+ });
36
+ }
37
+ //#endregion
38
+ export { FilterMenuItem };
@@ -3,7 +3,6 @@
3
3
  const require_const = require("../const.cjs");
4
4
  const require_context_client = require("../context.client.cjs");
5
5
  const require_hooks_client = require("../hooks.client.cjs");
6
- const require_virtualizer_client = require("../virtualizer.client.cjs");
7
6
  const require_features_client = require("./features.client.cjs");
8
7
  let _cerberus_design_react = require("@cerberus-design/react");
9
8
  let _cerberus_design_signals = require("@cerberus-design/signals");
@@ -11,97 +10,52 @@ let react = require("react");
11
10
  let styled_system_jsx = require("styled-system/jsx");
12
11
  let react_jsx_runtime = require("react/jsx-runtime");
13
12
  //#region src/components/grid.client.tsx
14
- function GridViewport() {
15
- const viewportRef = (0, react.useRef)(null);
16
- const store = require_context_client.useDataGridContext();
17
- const { virtualRows, totalHeight } = require_virtualizer_client.useVirtualizer(store, viewportRef);
18
- const columns = (0, _cerberus_design_signals.useRead)(store.columns);
19
- const isServerPaginated = (0, _cerberus_design_signals.useRead)(store.isServerPaginated);
20
- const staticRows = (0, _cerberus_design_signals.useRead)(store.rows);
21
- const currentPageRange = (0, _cerberus_design_signals.useRead)(store.currentPageRange);
22
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.Scrollable, {
23
- hideScrollbar: true,
24
- "data-scope": require_const.SCOPE,
25
- "data-part": require_const.PARTS.VIEWPORT,
26
- h: "full",
27
- minH: "0",
28
- minW: "full",
29
- pos: "relative",
30
- w: "full",
31
- ref: viewportRef,
32
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(styled_system_jsx.Box, {
33
- role: "grid",
34
- "aria-rowcount": staticRows.length + 1,
35
- "aria-colcount": columns.length,
36
- h: "var(--row-height)",
37
- pos: "sticky",
38
- top: "0",
39
- w: "var(--total-grid-width)",
40
- zIndex: "sticky",
41
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(styled_system_jsx.HStack, {
42
- "aria-rowindex": 1,
43
- role: "rowgroup",
44
- gap: "0",
45
- h: "full",
46
- pos: "relative",
47
- w: "full",
48
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.For, {
49
- each: columns,
50
- children: (col) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
51
- when: col.isVisible(),
52
- children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GridHeaderCell, { column: col })
53
- }, col.id)
54
- })
55
- })
56
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
57
- when: isServerPaginated,
58
- fallback: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(styled_system_jsx.Box, {
59
- pos: "relative",
60
- w: "var(--total-grid-width)",
61
- style: { height: `${totalHeight}px` },
62
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.For, {
63
- each: virtualRows,
64
- children: (vRow) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GridRow, {
65
- row: vRow.data,
66
- index: vRow.index,
67
- offsetY: vRow.offsetY
68
- }, vRow.index)
69
- })
70
- }),
71
- children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(styled_system_jsx.Stack, {
72
- direction: "column",
73
- gap: "0",
74
- w: "var(--total-grid-width)",
75
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.For, {
76
- each: staticRows.slice(currentPageRange.start, currentPageRange.end),
77
- children: (row, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GridRow, {
78
- row,
79
- index
80
- }, index)
81
- })
82
- })
83
- })]
84
- });
85
- }
86
13
  var GridHeaderCell = (0, react.memo)(function GridHeaderCell(props) {
87
14
  const { column } = props;
88
15
  const store = require_context_client.useDataGridContext();
89
16
  const { icons } = (0, _cerberus_design_react.useCerberusContext)();
90
17
  const pinnedVal = (0, _cerberus_design_signals.useRead)(column.pinned);
91
18
  const sortingVal = (0, _cerberus_design_signals.useRead)(store.sorting);
19
+ const colFilters = (0, _cerberus_design_signals.useRead)(store.colFilters);
92
20
  const pinnedState = require_hooks_client.usePinnedState(pinnedVal);
93
21
  const pinnedAttr = require_hooks_client.usePinnedAttribute(pinnedVal);
94
22
  const style = require_hooks_client.useColumnStyles(column, pinnedVal);
95
- const isSortedDesc = (0, react.useMemo)(() => {
23
+ const isSortedDesc = (0, _cerberus_design_signals.createComputed)(() => {
96
24
  const result = sortingVal.find((item) => item.id === column.id);
97
25
  if (result) return result.desc;
98
26
  return false;
99
- }, [sortingVal, column.id]);
27
+ });
28
+ const hasFilters = (0, _cerberus_design_signals.createComputed)(() => {
29
+ return colFilters.active.some((filterId) => filterId === column.id);
30
+ });
100
31
  const SortAscIcon = icons.sortAsc;
101
32
  const SortDescIcon = icons.sortDesc;
33
+ const EditFilterIcon = icons.filterEdit;
102
34
  function handleToggleSorting(e) {
103
35
  store.toggleSort(column.id, e.shiftKey);
104
36
  }
37
+ function handleEditFilters() {
38
+ const fallbackFilter = {
39
+ id: column.id,
40
+ operator: require_const.OPERATORS.contains,
41
+ value: ""
42
+ };
43
+ (0, _cerberus_design_signals.batch)(() => {
44
+ store.setColFilter((prev) => ({
45
+ ...prev,
46
+ active: [...prev.active, column.id],
47
+ filters: {
48
+ ...prev.filters,
49
+ [column.id]: {
50
+ ...fallbackFilter,
51
+ ...prev.filters[column.id]
52
+ }
53
+ },
54
+ editing: column.id
55
+ }));
56
+ store.setShowColFilter(true);
57
+ });
58
+ }
105
59
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.HStack, {
106
60
  role: "columnheader",
107
61
  "data-scope": require_const.SCOPE,
@@ -142,32 +96,59 @@ var GridHeaderCell = (0, react.memo)(function GridHeaderCell(props) {
142
96
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(styled_system_jsx.HStack, {
143
97
  gap: "sm",
144
98
  _groupHover: { "& :is(button)": { opacity: "1" } },
145
- children: [typeof column.original.header === "function" ? column.original.header({ colId: column.id }) : column.original.header, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
146
- when: column.sortable,
147
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Tooltip, {
148
- content: isSortedDesc ? "Sort Ascending" : "Sort Decending",
149
- openDelay: 800,
150
- asChild: true,
151
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.IconButton, {
152
- ariaLabel: "Toggle sorting",
153
- size: "sm",
154
- opacity: {
155
- base: 1,
156
- md: 0
157
- },
158
- transitionProperty: "opacity",
159
- transitionDuration: "fast",
160
- onClick: handleToggleSorting,
161
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
162
- when: isSortedDesc,
163
- fallback: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SortAscIcon, {}),
164
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SortDescIcon, {})
99
+ children: [
100
+ typeof column.original.header === "function" ? column.original.header({ colId: column.id }) : column.original.header,
101
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
102
+ when: hasFilters(),
103
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Tooltip, {
104
+ content: "Edit filters",
105
+ openDelay: 800,
106
+ asChild: true,
107
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.IconButton, {
108
+ ariaLabel: "Edit filters",
109
+ size: "sm",
110
+ onClick: handleEditFilters,
111
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EditFilterIcon, {})
112
+ })
113
+ })
114
+ }),
115
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
116
+ when: column.sortable,
117
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Tooltip, {
118
+ content: isSortedDesc() ? "Sort Ascending" : "Sort Decending",
119
+ openDelay: 800,
120
+ asChild: true,
121
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.IconButton, {
122
+ ariaLabel: "Toggle sorting",
123
+ size: "sm",
124
+ opacity: {
125
+ base: 1,
126
+ md: 0
127
+ },
128
+ transitionProperty: "opacity",
129
+ transitionDuration: "fast",
130
+ onClick: handleToggleSorting,
131
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
132
+ when: isSortedDesc(),
133
+ fallback: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SortAscIcon, {}),
134
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SortDescIcon, {})
135
+ })
165
136
  })
166
137
  })
167
138
  })
168
- })]
139
+ ]
140
+ }),
141
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(styled_system_jsx.Center, {
142
+ bgColor: "var(--head-cell-bg-color)",
143
+ bottom: "0",
144
+ pos: "absolute",
145
+ px: "sm",
146
+ right: "0",
147
+ top: "0",
148
+ w: "fit-content",
149
+ zIndex: "11",
150
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_features_client.HeaderCellOptions, { ...column })
169
151
  }),
170
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_features_client.HeaderCellOptions, { ...column }),
171
152
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
172
153
  when: pinnedState === "pinned",
173
154
  children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShadowFiller, {
@@ -212,10 +193,20 @@ var GridCell = (0, react.memo)(function GridCell(props) {
212
193
  borderLeft: "1px solid"
213
194
  },
214
195
  style,
215
- children: [column.original.cell ? column.original.cell({
216
- row,
217
- value
218
- }) : value, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
196
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
197
+ when: props.pending && props.hasSkeleton,
198
+ fallback: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: column.original.cell ? column.original.cell({
199
+ row,
200
+ value
201
+ }) : value }),
202
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(styled_system_jsx.Box, {
203
+ "aria-busy": "true",
204
+ my: "xs",
205
+ rounded: "md",
206
+ w: "full",
207
+ style: { height: "calc(var(--row-height) / 3)" }
208
+ })
209
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
219
210
  when: pinnedState === "pinned",
220
211
  children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShadowFiller, {
221
212
  style,
@@ -225,7 +216,10 @@ var GridCell = (0, react.memo)(function GridCell(props) {
225
216
  });
226
217
  });
227
218
  var GridRow = (0, react.memo)(function GridRow(props) {
228
- const columns = (0, _cerberus_design_signals.useRead)(require_context_client.useDataGridContext().columns);
219
+ const store = require_context_client.useDataGridContext();
220
+ const columns = (0, _cerberus_design_signals.useRead)(store.columns);
221
+ const pending = (0, _cerberus_design_signals.useRead)(store.pending);
222
+ const hasSkeleton = (0, _cerberus_design_signals.useRead)(store.hasSkeleton);
229
223
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GridRowContainer, {
230
224
  offsetY: props.offsetY,
231
225
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.For, {
@@ -234,7 +228,9 @@ var GridRow = (0, react.memo)(function GridRow(props) {
234
228
  when: col.isVisible(),
235
229
  children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GridCell, {
236
230
  row: props.row,
237
- column: col
231
+ column: col,
232
+ hasSkeleton,
233
+ pending
238
234
  })
239
235
  }, col.id)
240
236
  })
@@ -287,4 +283,5 @@ function ShadowFiller(props) {
287
283
  });
288
284
  }
289
285
  //#endregion
290
- exports.GridViewport = GridViewport;
286
+ exports.GridHeaderCell = GridHeaderCell;
287
+ exports.GridRow = GridRow;
@@ -1,6 +1,5 @@
1
+ import { PropsWithChildren, MemoExoticComponent, NamedExoticComponent } from 'react';
1
2
  import { InternalColumn } from '../types';
2
- import { MemoExoticComponent, NamedExoticComponent } from 'react';
3
- export declare function GridViewport(): import("react/jsx-runtime").JSX.Element;
4
3
  interface GridHeaderCellProps<TData> {
5
4
  column: InternalColumn<TData>;
6
5
  }
@@ -8,6 +7,8 @@ export declare const GridHeaderCell: MemoExoticComponent<(<TData>(props: GridHea
8
7
  interface GridCellProps<TData> {
9
8
  row: any;
10
9
  column: InternalColumn<TData>;
10
+ pending: boolean;
11
+ hasSkeleton: boolean;
11
12
  }
12
13
  export declare const GridCell: MemoExoticComponent<(<TData>(props: GridCellProps<TData>) => import("react/jsx-runtime").JSX.Element)>;
13
14
  interface GridRowProps {
@@ -16,4 +17,8 @@ interface GridRowProps {
16
17
  offsetY?: number;
17
18
  }
18
19
  export declare const GridRow: NamedExoticComponent<GridRowProps>;
20
+ interface GridRowContainerProps {
21
+ offsetY?: number;
22
+ }
23
+ export declare function GridRowContainer(props: PropsWithChildren<GridRowContainerProps>): import("react/jsx-runtime").JSX.Element;
19
24
  export {};
@@ -1,6 +1,5 @@
1
+ import { PropsWithChildren, MemoExoticComponent, NamedExoticComponent } from 'react';
1
2
  import { InternalColumn } from '../types';
2
- import { MemoExoticComponent, NamedExoticComponent } from 'react';
3
- export declare function GridViewport(): import("react/jsx-runtime").JSX.Element;
4
3
  interface GridHeaderCellProps<TData> {
5
4
  column: InternalColumn<TData>;
6
5
  }
@@ -8,6 +7,8 @@ export declare const GridHeaderCell: MemoExoticComponent<(<TData>(props: GridHea
8
7
  interface GridCellProps<TData> {
9
8
  row: any;
10
9
  column: InternalColumn<TData>;
10
+ pending: boolean;
11
+ hasSkeleton: boolean;
11
12
  }
12
13
  export declare const GridCell: MemoExoticComponent<(<TData>(props: GridCellProps<TData>) => import("react/jsx-runtime").JSX.Element)>;
13
14
  interface GridRowProps {
@@ -16,4 +17,8 @@ interface GridRowProps {
16
17
  offsetY?: number;
17
18
  }
18
19
  export declare const GridRow: NamedExoticComponent<GridRowProps>;
20
+ interface GridRowContainerProps {
21
+ offsetY?: number;
22
+ }
23
+ export declare function GridRowContainer(props: PropsWithChildren<GridRowContainerProps>): import("react/jsx-runtime").JSX.Element;
19
24
  export {};