@pibit.ai/cure-design-system 0.3.26 → 0.3.28

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 (29) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +55 -54
  4. package/dist/patterns/table/TableWrapper.d.ts.map +1 -1
  5. package/dist/patterns/table/TableWrapper.js +681 -543
  6. package/dist/patterns/table/index.d.ts +1 -1
  7. package/dist/patterns/table/index.d.ts.map +1 -1
  8. package/dist/patterns/table/rowReorderDrag.d.ts +57 -0
  9. package/dist/patterns/table/rowReorderDrag.d.ts.map +1 -0
  10. package/dist/patterns/table/rowReorderDrag.js +120 -0
  11. package/dist/patterns/table/table.d.ts.map +1 -1
  12. package/dist/patterns/table/table.js +36 -36
  13. package/dist/patterns/table/tableUndoRedo.d.ts.map +1 -1
  14. package/dist/patterns/table/tableUndoRedo.js +21 -18
  15. package/dist/patterns/table/toolbar/RowActionsMenu.d.ts +17 -1
  16. package/dist/patterns/table/toolbar/RowActionsMenu.d.ts.map +1 -1
  17. package/dist/patterns/table/toolbar/RowActionsMenu.js +69 -51
  18. package/dist/patterns/table/useTableUndoRedo.d.ts +9 -0
  19. package/dist/patterns/table/useTableUndoRedo.d.ts.map +1 -1
  20. package/dist/patterns/table/useTableUndoRedo.js +217 -127
  21. package/dist/primitives/checkbox/checkbox.d.ts.map +1 -1
  22. package/dist/primitives/checkbox/checkbox.js +16 -16
  23. package/dist/primitives/select/ExpandableSearchInput.d.ts.map +1 -1
  24. package/dist/primitives/select/ExpandableSearchInput.js +2 -1
  25. package/dist/primitives/select/SearchInput.d.ts +7 -7
  26. package/dist/primitives/select/SearchInput.d.ts.map +1 -1
  27. package/dist/primitives/select/SearchInput.js +66 -62
  28. package/dist/styles/components.css +1 -1
  29. package/package.json +1 -1
@@ -1,84 +1,102 @@
1
- import { jsxs as c, jsx as e, Fragment as v } from "react/jsx-runtime";
2
- import { useState as A } from "react";
3
- import { ArrowUp as h, ArrowDown as C, Copy06 as f, Copy01 as D, Clipboard as N, Trash01 as k } from "@untitledui/icons";
4
- import { Button as P } from "react-aria-components";
5
- import { cx as u } from "../../../utils/cn.js";
6
- import { TOOLBAR_ICONS as V } from "../toolbar-icons.js";
7
- import { Dropdown as b } from "../../../primitives/dropdown/dropdown.js";
8
- const a = ({ icon: o, label: n, danger: i, disabled: s, onClick: l }) => /* @__PURE__ */ c(
1
+ import { jsxs as u, jsx as r, Fragment as D } from "react/jsx-runtime";
2
+ import { useState as M, useRef as V } from "react";
3
+ import { ArrowUp as B, ArrowDown as S, Copy06 as _, Copy01 as F, Clipboard as O, Trash01 as g } from "@untitledui/icons";
4
+ import { Button as j } from "react-aria-components";
5
+ import { cx as b } from "../../../utils/cn.js";
6
+ import { TOOLBAR_ICONS as q } from "../toolbar-icons.js";
7
+ import { Dropdown as x } from "../../../primitives/dropdown/dropdown.js";
8
+ const a = ({ icon: e, label: s, danger: i, disabled: l, onClick: n }) => /* @__PURE__ */ u(
9
9
  "button",
10
10
  {
11
11
  type: "button",
12
- disabled: s,
13
- onClick: l,
14
- className: u(
12
+ disabled: l,
13
+ onClick: n,
14
+ className: b(
15
15
  "flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-xs font-medium transition-colors outline-none",
16
- s ? "cursor-not-allowed text-disabled" : i ? "cursor-pointer text-error-primary hover:bg-error-primary" : "cursor-pointer text-secondary hover:bg-primary_hover"
16
+ l ? "cursor-not-allowed text-disabled" : i ? "cursor-pointer text-error-primary hover:bg-error-primary" : "cursor-pointer text-secondary hover:bg-primary_hover"
17
17
  ),
18
18
  children: [
19
- /* @__PURE__ */ e(
20
- o,
19
+ /* @__PURE__ */ r(
20
+ e,
21
21
  {
22
22
  size: 16,
23
- className: u(
23
+ className: b(
24
24
  "shrink-0",
25
- s ? "text-fg-disabled" : i ? "text-error-primary" : "text-fg-quaternary"
25
+ l ? "text-fg-disabled" : i ? "text-error-primary" : "text-fg-quaternary"
26
26
  )
27
27
  }
28
28
  ),
29
- /* @__PURE__ */ e("span", { className: "flex-1 truncate", children: n })
29
+ /* @__PURE__ */ r("span", { className: "flex-1 truncate", children: s })
30
30
  ]
31
31
  }
32
- ), y = () => /* @__PURE__ */ e("div", { className: "my-1 h-px w-full bg-secondary" });
33
- function G({
34
- config: o,
35
- sourceRowIndex: n,
32
+ ), h = () => /* @__PURE__ */ r("div", { className: "my-1 h-px w-full bg-secondary" });
33
+ function E({
34
+ config: e,
35
+ sourceRowIndex: s,
36
36
  item: i,
37
- triggerClassName: s,
38
- onOpenChange: l
37
+ triggerClassName: l,
38
+ onOpenChange: n,
39
+ isDragging: A = !1,
40
+ enableDrag: c = !1,
41
+ onDragHandlePointerDown: p
39
42
  }) {
40
- const [p, x] = A(!1), d = (t) => {
41
- x(t), l == null || l(t);
42
- }, r = (t) => () => {
43
- t == null || t(n, i), d(!1);
44
- }, w = o.onAddRowAbove || o.onAddRowBelow, m = o.onDuplicateRow || o.onCopyRowValues || o.onPasteRowValues, R = o.canPasteRowValues ?? !0;
45
- return /* @__PURE__ */ c(b.Root, { isOpen: p, onOpenChange: d, children: [
46
- /* @__PURE__ */ e(
47
- P,
43
+ const [d, C] = M(!1), w = V(!1), m = (o) => {
44
+ o && !w.current || (o && (w.current = !1), C(o), n == null || n(o));
45
+ }, f = () => {
46
+ w.current = !0, m(!0);
47
+ }, v = (o) => {
48
+ o.preventDefault(), o.stopPropagation(), f();
49
+ }, k = (o) => {
50
+ !c || o.button !== 0 || (o.stopPropagation(), p == null || p(o));
51
+ }, N = (o) => {
52
+ (o.key === "ContextMenu" || o.key === "F10" && o.shiftKey) && (o.preventDefault(), o.stopPropagation(), f());
53
+ }, t = (o) => () => {
54
+ o == null || o(s, i), m(!1);
55
+ }, y = e.onAddRowAbove || e.onAddRowBelow, R = e.onDuplicateRow || e.onCopyRowValues || e.onPasteRowValues, P = e.canPasteRowValues ?? !0;
56
+ return /* @__PURE__ */ u(x.Root, { isOpen: d, onOpenChange: m, children: [
57
+ /* @__PURE__ */ r(
58
+ j,
48
59
  {
49
- "aria-label": `Open row actions for row ${n + 1}`,
50
- className: u(
51
- "flex items-center justify-center outline-none cursor-pointer",
60
+ "aria-label": c ? `Reorder or row actions for row ${s + 1}. Drag to reorder. Right-click or Shift+F10 for actions.` : `Row actions for row ${s + 1}. Right-click or Shift+F10 to open.`,
61
+ "aria-haspopup": "menu",
62
+ "aria-expanded": d,
63
+ onContextMenu: v,
64
+ onPointerDown: k,
65
+ onKeyDown: N,
66
+ className: b(
67
+ "flex touch-none items-center justify-center outline-none select-none",
68
+ // Grab cursor only when drag is enabled (sort/filter/group disable drag via enableDrag).
69
+ A ? "cursor-grabbing" : c ? "cursor-grab active:cursor-grabbing" : "cursor-default",
52
70
  "text-fg-quaternary hover:bg-secondary_subtle hover:text-fg-quaternary_hover",
53
71
  "data-[pressed]:bg-secondary_subtle data-[focus-visible]:ring-2 data-[focus-visible]:ring-focus-ring",
54
- p && "opacity-100",
55
- s
72
+ d && "opacity-100",
73
+ l
56
74
  ),
57
- children: /* @__PURE__ */ e("img", { src: V.reorderDotsNew, alt: "", className: "h-4 w-4" })
75
+ children: /* @__PURE__ */ r("img", { src: q.reorderDotsNew, alt: "", className: "h-4 w-4", draggable: !1 })
58
76
  }
59
77
  ),
60
- /* @__PURE__ */ e(b.Popover, { className: "w-56", children: /* @__PURE__ */ c("div", { className: "flex flex-col px-1.5 py-1", children: [
61
- o.onAddRowAbove && /* @__PURE__ */ e(a, { icon: h, label: "Add row above", onClick: r(o.onAddRowAbove) }),
62
- o.onAddRowBelow && /* @__PURE__ */ e(a, { icon: C, label: "Add row below", onClick: r(o.onAddRowBelow) }),
63
- w && m && /* @__PURE__ */ e(y, {}),
64
- o.onDuplicateRow && /* @__PURE__ */ e(a, { icon: f, label: "Duplicate row", onClick: r(o.onDuplicateRow) }),
65
- o.onCopyRowValues && /* @__PURE__ */ e(a, { icon: D, label: "Copy row values", onClick: r(o.onCopyRowValues) }),
66
- o.onPasteRowValues && /* @__PURE__ */ e(
78
+ /* @__PURE__ */ r(x.Popover, { className: "w-56", children: /* @__PURE__ */ u("div", { className: "flex flex-col px-1.5 py-1", children: [
79
+ e.onAddRowAbove && /* @__PURE__ */ r(a, { icon: B, label: "Add row above", onClick: t(e.onAddRowAbove) }),
80
+ e.onAddRowBelow && /* @__PURE__ */ r(a, { icon: S, label: "Add row below", onClick: t(e.onAddRowBelow) }),
81
+ y && R && /* @__PURE__ */ r(h, {}),
82
+ e.onDuplicateRow && /* @__PURE__ */ r(a, { icon: _, label: "Duplicate row", onClick: t(e.onDuplicateRow) }),
83
+ e.onCopyRowValues && /* @__PURE__ */ r(a, { icon: F, label: "Copy row values", onClick: t(e.onCopyRowValues) }),
84
+ e.onPasteRowValues && /* @__PURE__ */ r(
67
85
  a,
68
86
  {
69
- icon: N,
87
+ icon: O,
70
88
  label: "Paste row values",
71
- disabled: !R,
72
- onClick: r(o.onPasteRowValues)
89
+ disabled: !P,
90
+ onClick: t(e.onPasteRowValues)
73
91
  }
74
92
  ),
75
- o.onDeleteRow && /* @__PURE__ */ c(v, { children: [
76
- (w || m) && /* @__PURE__ */ e(y, {}),
77
- /* @__PURE__ */ e(a, { icon: k, label: "Delete row", danger: !0, onClick: r(o.onDeleteRow) })
93
+ e.onDeleteRow && /* @__PURE__ */ u(D, { children: [
94
+ (y || R) && /* @__PURE__ */ r(h, {}),
95
+ /* @__PURE__ */ r(a, { icon: g, label: "Delete row", danger: !0, onClick: t(e.onDeleteRow) })
78
96
  ] })
79
97
  ] }) })
80
98
  ] });
81
99
  }
82
100
  export {
83
- G as RowActionsMenu
101
+ E as RowActionsMenu
84
102
  };
@@ -1,5 +1,6 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  import { TableUndoSnapshotSources } from './tableUndoRedo';
3
+ export declare const MAX_HISTORY = 50;
3
4
  export type UseTableUndoRedoOptions = TableUndoSnapshotSources & {
4
5
  enabled?: boolean;
5
6
  tableId?: string;
@@ -20,6 +21,8 @@ export type TableUndoRedoRegistration = {
20
21
  canRedo: boolean;
21
22
  undo: () => void;
22
23
  redo: () => void;
24
+ /** Drop this table's local redo stack (used when it commits a new edit). */
25
+ clearRedo: () => void;
23
26
  };
24
27
  export type TableUndoRedoScopeApi = {
25
28
  canUndo: boolean;
@@ -27,6 +30,12 @@ export type TableUndoRedoScopeApi = {
27
30
  undo: () => void;
28
31
  redo: () => void;
29
32
  recordCommit: (tableId: string) => void;
33
+ /** Sync global order after a table toolbar undo (remove last occurrence of tableId). */
34
+ recordLocalUndo: (tableId: string) => void;
35
+ /** Sync global order after a table toolbar redo (remove last occurrence of tableId). */
36
+ recordLocalRedo: (tableId: string) => void;
37
+ /** Drop the oldest pastOrder entry for tableId when local history is capped. */
38
+ recordHistoryEviction: (tableId: string) => void;
30
39
  registerTable: (registration: TableUndoRedoRegistration) => () => void;
31
40
  unregisterTable: (tableId: string) => void;
32
41
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useTableUndoRedo.d.ts","sourceRoot":"","sources":["../../../src/patterns/table/useTableUndoRedo.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EAOvB,MAAM,OAAO,CAAC;AACf,OAAO,EAIL,KAAK,wBAAwB,EAC9B,MAAM,iBAAiB,CAAC;AAIzB,MAAM,MAAM,uBAAuB,GAAG,wBAAwB,GAAG;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC/C,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,IAAI,EAAE,MAAM,IAAI,CAAC;I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IAAI,CAAC;IACjB,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,wFAAwF;IACxF,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,wFAAwF;IACxF,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,gFAAgF;IAChF,qBAAqB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,aAAa,EAAE,CAAC,YAAY,EAAE,yBAAyB,KAAK,MAAM,IAAI,CAAC;IACvE,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C,CAAC;AAiDF,wBAAgB,qBAAqB,IAAI,qBAAqB,GAAG,IAAI,CAEpE;AAED,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,SAAgB,EAChB,UAAkB,GACnB,EAAE,iBAAiB,CAAC;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,yGAyNlE;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,OAAe,EACf,OAAO,EACP,eAAe,EACf,OAAO,EACP,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,IAAI,EACJ,OAAO,EACP,aAAa,GACd,EAAE,uBAAuB,GAAG,kBAAkB,CAyI9C;AAED,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,kCAAkC,EAClC,0BAA0B,EAC1B,0BAA0B,EAC1B,6BAA6B,EAC7B,uBAAuB,GACxB,MAAM,iBAAiB,CAAC"}
@@ -1,168 +1,258 @@
1
- import { useRef as y, useState as X, useCallback as f, useEffect as A, useMemo as M, createElement as q, createContext as D, useContext as J } from "react";
2
- import { captureTableUndoSnapshot as Q, applyTableUndoSnapshot as O } from "./tableUndoRedo.js";
3
- import { wrapColumnHeaderActionWithUndoRedo as I, wrapEditChromeWithUndoRedo as rr, wrapRowActionsWithUndoRedo as er, wrapSummaryFooterWithUndoRedo as tr, wrapToolbarWithUndoRedo as nr } from "./tableUndoRedo.js";
4
- const j = D(null);
5
- function V(t) {
6
- if (!(t instanceof HTMLElement)) return !1;
7
- const n = t.tagName;
8
- return !!(n === "INPUT" || n === "TEXTAREA" || n === "SELECT" || t.isContentEditable);
1
+ import { useRef as h, useState as D, useCallback as d, useMemo as P, useEffect as F, createElement as Z, createContext as $, useContext as G } from "react";
2
+ import { captureTableUndoSnapshot as I, applyTableUndoSnapshot as _ } from "./tableUndoRedo.js";
3
+ import { wrapColumnHeaderActionWithUndoRedo as ie, wrapEditChromeWithUndoRedo as de, wrapRowActionsWithUndoRedo as fe, wrapSummaryFooterWithUndoRedo as le, wrapToolbarWithUndoRedo as ae } from "./tableUndoRedo.js";
4
+ const J = 50, Q = $(null);
5
+ function b(n) {
6
+ if (!(n instanceof HTMLElement)) return !1;
7
+ const t = n.tagName;
8
+ return !!(t === "INPUT" || t === "TEXTAREA" || t === "SELECT" || n.isContentEditable);
9
9
  }
10
- function Y() {
11
- return J(j);
10
+ function j(n, t) {
11
+ const o = n.lastIndexOf(t);
12
+ return o === -1 ? n : [...n.slice(0, o), ...n.slice(o + 1)];
12
13
  }
13
- function $({
14
- children: t,
15
- shortcuts: n = !0,
16
- isDisabled: C = !1
14
+ function V(n, t) {
15
+ const o = n.indexOf(t);
16
+ return o === -1 ? n : [...n.slice(0, o), ...n.slice(o + 1)];
17
+ }
18
+ function ee(n, t) {
19
+ let o = 0;
20
+ for (const f of n)
21
+ f === t && (o += 1);
22
+ return o;
23
+ }
24
+ function q(n, t) {
25
+ let o = [...n, t];
26
+ for (; ee(o, t) > J; )
27
+ o = V(o, t);
28
+ return o;
29
+ }
30
+ function re() {
31
+ return G(Q);
32
+ }
33
+ function ce({
34
+ children: n,
35
+ shortcuts: t = !0,
36
+ isDisabled: o = !1
17
37
  }) {
18
- const a = y(/* @__PURE__ */ new Map()), c = y([]), s = y([]), [S, E] = X(0), u = f(() => {
19
- E((e) => e + 1);
20
- }, []), U = f(
21
- (e) => {
22
- a.current.delete(e), c.current = c.current.filter((r) => r !== e), s.current = s.current.filter((r) => r !== e), u();
38
+ const f = h(/* @__PURE__ */ new Map()), c = h([]), s = h([]), y = h(/* @__PURE__ */ new Map()), [x, H] = D(0), u = d(() => {
39
+ H((r) => r + 1);
40
+ }, []), l = d(
41
+ (r) => {
42
+ c.current = c.current.filter((e) => e !== r), s.current = s.current.filter((e) => e !== r), u();
23
43
  },
24
44
  [u]
25
- ), i = f(
26
- (e) => (a.current.set(e.tableId, e), u(), () => U(e.tableId)),
27
- [u, U]
28
- ), l = f(
29
- (e) => {
30
- c.current = [...c.current, e], s.current = [], u();
45
+ ), p = d(
46
+ (r) => {
47
+ f.current.delete(r);
48
+ const e = y.current.get(r);
49
+ e !== void 0 && (clearTimeout(e), y.current.delete(r)), l(r);
50
+ },
51
+ [l]
52
+ ), U = d(
53
+ (r) => {
54
+ const e = y.current.get(r.tableId);
55
+ e !== void 0 && (clearTimeout(e), y.current.delete(r.tableId));
56
+ const a = f.current.get(r.tableId);
57
+ return f.current.set(r.tableId, r), (!a || a.canUndo !== r.canUndo || a.canRedo !== r.canRedo) && u(), () => {
58
+ f.current.delete(r.tableId);
59
+ const L = setTimeout(() => {
60
+ y.current.delete(r.tableId), f.current.has(r.tableId) || l(r.tableId);
61
+ }, 0);
62
+ y.current.set(r.tableId, L);
63
+ };
64
+ },
65
+ [u, l]
66
+ ), A = d(
67
+ (r) => {
68
+ var e;
69
+ c.current = [...c.current, r], s.current = s.current.filter((a) => a !== r), (e = f.current.get(r)) == null || e.clearRedo(), u();
70
+ },
71
+ [u]
72
+ ), C = d(
73
+ (r) => {
74
+ const e = j(c.current, r);
75
+ e !== c.current && (c.current = e), s.current = [...s.current, r], u();
31
76
  },
32
77
  [u]
33
- ), d = f(() => {
78
+ ), K = d(
79
+ (r) => {
80
+ const e = j(s.current, r);
81
+ e !== s.current && (s.current = e), c.current = q(c.current, r), u();
82
+ },
83
+ [u]
84
+ ), i = d(
85
+ (r) => {
86
+ const e = V(c.current, r);
87
+ e !== c.current && (c.current = e, u());
88
+ },
89
+ [u]
90
+ ), R = d(() => {
34
91
  for (; c.current.length > 0; ) {
35
- const e = c.current[c.current.length - 1];
92
+ const r = c.current[c.current.length - 1];
36
93
  c.current = c.current.slice(0, -1);
37
- const r = a.current.get(e);
38
- if (r != null && r.canUndo) {
39
- r.undo(), s.current = [...s.current, e], u();
94
+ const e = f.current.get(r);
95
+ if (e && e.canUndo) {
96
+ e.undo(), s.current = [...s.current, r], u();
40
97
  return;
41
98
  }
42
99
  }
43
100
  u();
44
- }, [u]), T = f(() => {
101
+ }, [u]), g = d(() => {
45
102
  for (; s.current.length > 0; ) {
46
- const e = s.current[s.current.length - 1];
103
+ const r = s.current[s.current.length - 1];
47
104
  s.current = s.current.slice(0, -1);
48
- const r = a.current.get(e);
49
- if (r != null && r.canRedo) {
50
- r.redo(), c.current = [...c.current, e], u();
105
+ const e = f.current.get(r);
106
+ if (e && e.canRedo) {
107
+ e.redo(), c.current = q(c.current, r), u();
51
108
  return;
52
109
  }
53
110
  }
54
111
  u();
55
- }, [u]), R = c.current.some((e) => {
56
- var r;
57
- return (r = a.current.get(e)) == null ? void 0 : r.canUndo;
58
- }), w = s.current.some((e) => {
59
- var r;
60
- return (r = a.current.get(e)) == null ? void 0 : r.canRedo;
61
- });
62
- A(() => {
63
- if (!n || C) return;
64
- const e = (r) => {
65
- if (V(r.target) || !(r.metaKey || r.ctrlKey) || r.altKey) return;
66
- const g = r.key.toLowerCase(), m = g === "z" && !r.shiftKey, h = g === "z" && r.shiftKey || g === "y";
67
- m && R ? (r.preventDefault(), r.stopPropagation(), d()) : h && w && (r.preventDefault(), r.stopPropagation(), T());
112
+ }, [u]), T = P(
113
+ () => c.current.some((r) => {
114
+ var e;
115
+ return (e = f.current.get(r)) == null ? void 0 : e.canUndo;
116
+ }),
117
+ [x]
118
+ ), w = P(
119
+ () => s.current.some((r) => {
120
+ var e;
121
+ return (e = f.current.get(r)) == null ? void 0 : e.canRedo;
122
+ }),
123
+ [x]
124
+ );
125
+ F(() => {
126
+ if (!t || o) return;
127
+ const r = (e) => {
128
+ if (b(e.target) || !(e.metaKey || e.ctrlKey) || e.altKey) return;
129
+ const S = e.key.toLowerCase(), L = S === "z" && !e.shiftKey, v = S === "z" && e.shiftKey || S === "y";
130
+ L && T ? (e.preventDefault(), e.stopPropagation(), R()) : v && w && (e.preventDefault(), e.stopPropagation(), g());
68
131
  };
69
- return window.addEventListener("keydown", e, { capture: !0 }), () => window.removeEventListener("keydown", e, { capture: !0 });
70
- }, [n, C, R, w, d, T]);
71
- const o = M(
132
+ return window.addEventListener("keydown", r, { capture: !0 }), () => window.removeEventListener("keydown", r, { capture: !0 });
133
+ }, [t, o, T, w, R, g]);
134
+ const E = P(
72
135
  () => ({
73
- canUndo: R,
136
+ canUndo: T,
74
137
  canRedo: w,
75
- undo: d,
76
- redo: T,
77
- recordCommit: l,
78
- registerTable: i,
79
- unregisterTable: U
138
+ undo: R,
139
+ redo: g,
140
+ recordCommit: A,
141
+ recordLocalUndo: C,
142
+ recordLocalRedo: K,
143
+ recordHistoryEviction: i,
144
+ registerTable: U,
145
+ unregisterTable: p
80
146
  }),
81
- [R, w, d, T, l, i, U, S]
147
+ [
148
+ T,
149
+ w,
150
+ R,
151
+ g,
152
+ A,
153
+ C,
154
+ K,
155
+ i,
156
+ U,
157
+ p,
158
+ x
159
+ ]
82
160
  );
83
- return q(j.Provider, { value: o }, t);
161
+ return Z(Q.Provider, { value: E }, n);
84
162
  }
85
- function F({
86
- enabled: t = !1,
87
- tableId: n,
88
- sharedUndoGroup: C,
89
- toolbar: a,
163
+ function oe({
164
+ enabled: n = !1,
165
+ tableId: t,
166
+ sharedUndoGroup: o,
167
+ toolbar: f,
90
168
  columnAlignments: c,
91
169
  summaryFooterProps: s,
92
- appliedFilterConditions: S,
93
- data: E,
94
- getData: u,
95
- onDataRestore: U
170
+ appliedFilterConditions: y,
171
+ data: x,
172
+ getData: H,
173
+ onDataRestore: u
96
174
  }) {
97
- const i = y([]), l = y([]), d = y(!1), [T, R] = X(0), w = Y(), o = C === void 0 ? w : C, e = !!(t && n && o), r = o == null ? void 0 : o.recordCommit, x = o == null ? void 0 : o.registerTable, g = o == null ? void 0 : o.unregisterTable, m = M(
175
+ const l = h([]), p = h([]), U = h(!1), [A, C] = D(0), K = re(), i = o === void 0 ? K : o, R = !!(n && t && i), g = i == null ? void 0 : i.recordCommit, T = i == null ? void 0 : i.recordLocalUndo, w = i == null ? void 0 : i.recordLocalRedo, E = i == null ? void 0 : i.recordHistoryEviction, r = i == null ? void 0 : i.registerTable, e = P(
98
176
  () => ({
99
- toolbar: a,
177
+ toolbar: f,
100
178
  columnAlignments: c,
101
179
  summaryFooterProps: s,
102
- appliedFilterConditions: S,
103
- data: E,
104
- getData: u,
105
- onDataRestore: U
180
+ appliedFilterConditions: y,
181
+ data: x,
182
+ getData: H,
183
+ onDataRestore: u
106
184
  }),
107
- [a, c, s, S, E, u, U]
108
- ), h = f(() => Q(m), [m]), P = f(() => {
109
- !t || d.current || (i.current = [...i.current.slice(-49), h()], l.current = [], n && r && r(n), R((p) => p + 1));
110
- }, [t, h, r, n]), v = f(() => {
111
- if (!(!t || i.current.length === 0)) {
112
- d.current = !0;
113
- try {
114
- const p = h(), W = i.current.pop();
115
- l.current = [p, ...l.current], O(W, m);
116
- } finally {
117
- d.current = !1, R((p) => p + 1);
118
- }
185
+ [f, c, s, y, x, H, u]
186
+ ), a = d(() => I(e), [e]), S = d(() => {
187
+ if (!n || U.current) return;
188
+ const m = l.current.length >= J;
189
+ l.current = [...l.current.slice(-49), a()], p.current = [], t && g && (g(t), m && E && E(t)), C((O) => O + 1);
190
+ }, [n, a, g, E, t]), L = d(() => {
191
+ if (!n || l.current.length === 0) return !1;
192
+ U.current = !0;
193
+ try {
194
+ const m = a(), O = l.current.pop();
195
+ return p.current = [m, ...p.current], _(O, e), !0;
196
+ } finally {
197
+ U.current = !1, C((m) => m + 1);
119
198
  }
120
- }, [t, h, m]), K = f(() => {
121
- if (!(!t || l.current.length === 0)) {
122
- d.current = !0;
123
- try {
124
- const p = h(), W = l.current.shift();
125
- i.current = [...i.current, p], O(W, m);
126
- } finally {
127
- d.current = !1, R((p) => p + 1);
128
- }
199
+ }, [n, a, e]), v = d(() => {
200
+ if (!n || p.current.length === 0) return !1;
201
+ U.current = !0;
202
+ try {
203
+ const m = a(), O = p.current.shift();
204
+ return l.current = [...l.current, m], _(O, e), !0;
205
+ } finally {
206
+ U.current = !1, C((m) => m + 1);
129
207
  }
130
- }, [t, h, m]), k = t && i.current.length > 0, L = t && l.current.length > 0;
131
- A(() => {
132
- !t || !n || !x || x({
133
- tableId: n,
134
- canUndo: k,
135
- canRedo: L,
136
- undo: v,
137
- redo: K
138
- });
139
- }, [t, n, x, k, L, v, K]), A(() => {
140
- if (!(!n || !g))
141
- return () => g(n);
142
- }, [n, g]);
143
- const z = e ? o.canUndo : k, B = e ? o.canRedo : L, H = e ? o.undo : v, N = e ? o.redo : K;
144
- return M(
208
+ }, [n, a, e]), W = d(() => {
209
+ p.current.length !== 0 && (p.current = [], C((m) => m + 1));
210
+ }, []), M = n && l.current.length > 0, k = n && p.current.length > 0, B = h(L), z = h(v), N = h(W);
211
+ B.current = L, z.current = v, N.current = W;
212
+ const X = d(() => {
213
+ L() && R && t && T && T(t);
214
+ }, [L, R, t, T]), Y = d(() => {
215
+ v() && R && t && w && w(t);
216
+ }, [v, R, t, w]);
217
+ return F(() => {
218
+ if (!(!n || !t || !r))
219
+ return r({
220
+ tableId: t,
221
+ canUndo: M,
222
+ canRedo: k,
223
+ undo: () => {
224
+ B.current();
225
+ },
226
+ redo: () => {
227
+ z.current();
228
+ },
229
+ clearRedo: () => {
230
+ N.current();
231
+ }
232
+ });
233
+ }, [n, t, r, M, k]), P(
145
234
  () => ({
146
- canUndo: z,
147
- canRedo: B,
148
- undo: H,
149
- redo: N,
150
- commitBeforeMutation: P,
151
- shortcut: e ? !1 : void 0
235
+ canUndo: M,
236
+ canRedo: k,
237
+ undo: X,
238
+ redo: Y,
239
+ commitBeforeMutation: S,
240
+ shortcut: R ? !1 : void 0
152
241
  }),
153
242
  // revision drives canUndo/canRedo updates after history mutations
154
- [z, B, H, N, P, e, T]
243
+ [M, k, X, Y, S, R, A]
155
244
  );
156
245
  }
157
246
  export {
158
- $ as TableUndoRedoProvider,
159
- O as applyTableUndoSnapshot,
160
- Q as captureTableUndoSnapshot,
161
- F as useTableUndoRedo,
162
- Y as useTableUndoRedoScope,
163
- I as wrapColumnHeaderActionWithUndoRedo,
164
- rr as wrapEditChromeWithUndoRedo,
165
- er as wrapRowActionsWithUndoRedo,
166
- tr as wrapSummaryFooterWithUndoRedo,
167
- nr as wrapToolbarWithUndoRedo
247
+ J as MAX_HISTORY,
248
+ ce as TableUndoRedoProvider,
249
+ _ as applyTableUndoSnapshot,
250
+ I as captureTableUndoSnapshot,
251
+ oe as useTableUndoRedo,
252
+ re as useTableUndoRedoScope,
253
+ ie as wrapColumnHeaderActionWithUndoRedo,
254
+ de as wrapEditChromeWithUndoRedo,
255
+ fe as wrapRowActionsWithUndoRedo,
256
+ le as wrapSummaryFooterWithUndoRedo,
257
+ ae as wrapToolbarWithUndoRedo
168
258
  };
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/primitives/checkbox/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAG1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,aACf,SAAQ,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,SAAS,CAAC;IACpD,qBAAqB;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,uBAAuB;IACvB,WAAW,CAAC,EAA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