@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.
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -54
- package/dist/patterns/table/TableWrapper.d.ts.map +1 -1
- package/dist/patterns/table/TableWrapper.js +681 -543
- package/dist/patterns/table/index.d.ts +1 -1
- package/dist/patterns/table/index.d.ts.map +1 -1
- package/dist/patterns/table/rowReorderDrag.d.ts +57 -0
- package/dist/patterns/table/rowReorderDrag.d.ts.map +1 -0
- package/dist/patterns/table/rowReorderDrag.js +120 -0
- package/dist/patterns/table/table.d.ts.map +1 -1
- package/dist/patterns/table/table.js +36 -36
- package/dist/patterns/table/tableUndoRedo.d.ts.map +1 -1
- package/dist/patterns/table/tableUndoRedo.js +21 -18
- package/dist/patterns/table/toolbar/RowActionsMenu.d.ts +17 -1
- package/dist/patterns/table/toolbar/RowActionsMenu.d.ts.map +1 -1
- package/dist/patterns/table/toolbar/RowActionsMenu.js +69 -51
- package/dist/patterns/table/useTableUndoRedo.d.ts +9 -0
- package/dist/patterns/table/useTableUndoRedo.d.ts.map +1 -1
- package/dist/patterns/table/useTableUndoRedo.js +217 -127
- package/dist/primitives/checkbox/checkbox.d.ts.map +1 -1
- package/dist/primitives/checkbox/checkbox.js +16 -16
- package/dist/primitives/select/ExpandableSearchInput.d.ts.map +1 -1
- package/dist/primitives/select/ExpandableSearchInput.js +2 -1
- package/dist/primitives/select/SearchInput.d.ts +7 -7
- package/dist/primitives/select/SearchInput.d.ts.map +1 -1
- package/dist/primitives/select/SearchInput.js +66 -62
- package/dist/styles/components.css +1 -1
- package/package.json +1 -1
|
@@ -1,84 +1,102 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { ArrowUp as
|
|
4
|
-
import { Button as
|
|
5
|
-
import { cx as
|
|
6
|
-
import { TOOLBAR_ICONS as
|
|
7
|
-
import { Dropdown as
|
|
8
|
-
const a = ({ icon:
|
|
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:
|
|
13
|
-
onClick:
|
|
14
|
-
className:
|
|
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
|
-
|
|
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__ */
|
|
20
|
-
|
|
19
|
+
/* @__PURE__ */ r(
|
|
20
|
+
e,
|
|
21
21
|
{
|
|
22
22
|
size: 16,
|
|
23
|
-
className:
|
|
23
|
+
className: b(
|
|
24
24
|
"shrink-0",
|
|
25
|
-
|
|
25
|
+
l ? "text-fg-disabled" : i ? "text-error-primary" : "text-fg-quaternary"
|
|
26
26
|
)
|
|
27
27
|
}
|
|
28
28
|
),
|
|
29
|
-
/* @__PURE__ */
|
|
29
|
+
/* @__PURE__ */ r("span", { className: "flex-1 truncate", children: s })
|
|
30
30
|
]
|
|
31
31
|
}
|
|
32
|
-
),
|
|
33
|
-
function
|
|
34
|
-
config:
|
|
35
|
-
sourceRowIndex:
|
|
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:
|
|
38
|
-
onOpenChange:
|
|
37
|
+
triggerClassName: l,
|
|
38
|
+
onOpenChange: n,
|
|
39
|
+
isDragging: A = !1,
|
|
40
|
+
enableDrag: c = !1,
|
|
41
|
+
onDragHandlePointerDown: p
|
|
39
42
|
}) {
|
|
40
|
-
const [
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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": `
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
55
|
-
|
|
72
|
+
d && "opacity-100",
|
|
73
|
+
l
|
|
56
74
|
),
|
|
57
|
-
children: /* @__PURE__ */
|
|
75
|
+
children: /* @__PURE__ */ r("img", { src: q.reorderDotsNew, alt: "", className: "h-4 w-4", draggable: !1 })
|
|
58
76
|
}
|
|
59
77
|
),
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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:
|
|
87
|
+
icon: O,
|
|
70
88
|
label: "Paste row values",
|
|
71
|
-
disabled: !
|
|
72
|
-
onClick:
|
|
89
|
+
disabled: !P,
|
|
90
|
+
onClick: t(e.onPasteRowValues)
|
|
73
91
|
}
|
|
74
92
|
),
|
|
75
|
-
|
|
76
|
-
(
|
|
77
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
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;
|
|
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;AAEzB,eAAO,MAAM,WAAW,KAAK,CAAC;AAE9B,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;IACjB,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,4EAA4E;IAC5E,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,IAAI,EAAE,MAAM,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
|
|
2
|
-
import { captureTableUndoSnapshot as
|
|
3
|
-
import { wrapColumnHeaderActionWithUndoRedo as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
if (!(
|
|
7
|
-
const
|
|
8
|
-
return !!(
|
|
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
|
|
11
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
19
|
-
|
|
20
|
-
}, []),
|
|
21
|
-
(
|
|
22
|
-
|
|
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
|
-
),
|
|
26
|
-
(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
),
|
|
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
|
|
92
|
+
const r = c.current[c.current.length - 1];
|
|
36
93
|
c.current = c.current.slice(0, -1);
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
|
|
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]),
|
|
101
|
+
}, [u]), g = d(() => {
|
|
45
102
|
for (; s.current.length > 0; ) {
|
|
46
|
-
const
|
|
103
|
+
const r = s.current[s.current.length - 1];
|
|
47
104
|
s.current = s.current.slice(0, -1);
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
|
|
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]),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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",
|
|
70
|
-
}, [
|
|
71
|
-
const
|
|
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:
|
|
136
|
+
canUndo: T,
|
|
74
137
|
canRedo: w,
|
|
75
|
-
undo:
|
|
76
|
-
redo:
|
|
77
|
-
recordCommit:
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
[
|
|
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
|
|
161
|
+
return Z(Q.Provider, { value: E }, n);
|
|
84
162
|
}
|
|
85
|
-
function
|
|
86
|
-
enabled:
|
|
87
|
-
tableId:
|
|
88
|
-
sharedUndoGroup:
|
|
89
|
-
toolbar:
|
|
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:
|
|
93
|
-
data:
|
|
94
|
-
getData:
|
|
95
|
-
onDataRestore:
|
|
170
|
+
appliedFilterConditions: y,
|
|
171
|
+
data: x,
|
|
172
|
+
getData: H,
|
|
173
|
+
onDataRestore: u
|
|
96
174
|
}) {
|
|
97
|
-
const
|
|
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:
|
|
177
|
+
toolbar: f,
|
|
100
178
|
columnAlignments: c,
|
|
101
179
|
summaryFooterProps: s,
|
|
102
|
-
appliedFilterConditions:
|
|
103
|
-
data:
|
|
104
|
-
getData:
|
|
105
|
-
onDataRestore:
|
|
180
|
+
appliedFilterConditions: y,
|
|
181
|
+
data: x,
|
|
182
|
+
getData: H,
|
|
183
|
+
onDataRestore: u
|
|
106
184
|
}),
|
|
107
|
-
[
|
|
108
|
-
),
|
|
109
|
-
!
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
}, [
|
|
121
|
-
if (!
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
}, [
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (!(!n || !
|
|
141
|
-
return (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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:
|
|
147
|
-
canRedo:
|
|
148
|
-
undo:
|
|
149
|
-
redo:
|
|
150
|
-
commitBeforeMutation:
|
|
151
|
-
shortcut:
|
|
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
|
-
[
|
|
243
|
+
[M, k, X, Y, S, R, A]
|
|
155
244
|
);
|
|
156
245
|
}
|
|
157
246
|
export {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC;IACpC,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,WAAW,EACX,OAAO,EACP,SAAS,EACT,EAAE,EACF,GAAG,KAAK,EACT,EAAE,aAAa,
|
|
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,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC;IACpC,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,WAAW,EACX,OAAO,EACP,SAAS,EACT,EAAE,EACF,GAAG,KAAK,EACT,EAAE,aAAa,2CA4Cf;yBAnDe,QAAQ"}
|