@ishibashi0112/spreadsheet-grid-core 1.0.1 → 1.1.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.
- package/dist/controllers/autoHeightMeasurer.cjs +1 -1
- package/dist/controllers/autoHeightMeasurer.js +4 -2
- package/dist/controllers/clipboardController.cjs +1 -2
- package/dist/controllers/clipboardController.d.ts +3 -0
- package/dist/controllers/clipboardController.js +78 -59
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.d.ts +3 -1
- package/dist/controllers/columnAutosizeRunner.js +12 -10
- package/dist/controllers/columnHeaderDragController.cjs +1 -1
- package/dist/controllers/columnHeaderDragController.js +146 -140
- package/dist/controllers/columnMenuController.cjs +1 -1
- package/dist/controllers/columnMenuController.js +71 -69
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.d.ts +4 -1
- package/dist/controllers/contextMenuController.js +55 -38
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.js +78 -78
- package/dist/controllers/escapeClaimController.cjs +1 -1
- package/dist/controllers/escapeClaimController.d.ts +1 -0
- package/dist/controllers/escapeClaimController.js +11 -5
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.d.ts +1 -0
- package/dist/controllers/fillHandleController.js +148 -147
- package/dist/controllers/filterPopoverController.cjs +1 -1
- package/dist/controllers/filterPopoverController.js +81 -77
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +1 -0
- package/dist/controllers/findController.js +36 -29
- package/dist/controllers/historyController.cjs +1 -1
- package/dist/controllers/historyController.d.ts +6 -0
- package/dist/controllers/historyController.js +79 -37
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +1 -0
- package/dist/controllers/keyboardController.js +116 -116
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.d.ts +1 -0
- package/dist/controllers/pointerInteractionsController.js +142 -142
- package/dist/controllers/popoverSupport.cjs +1 -1
- package/dist/controllers/popoverSupport.d.ts +1 -0
- package/dist/controllers/popoverSupport.js +17 -7
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +1 -0
- package/dist/controllers/rowDragController.js +151 -149
- package/dist/controllers/rowEnterController.cjs +1 -1
- package/dist/controllers/rowEnterController.d.ts +1 -0
- package/dist/controllers/rowEnterController.js +47 -42
- package/dist/controllers/toolPanelController.cjs +1 -1
- package/dist/controllers/toolPanelController.js +26 -14
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.js +85 -66
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +4 -1
- package/dist/controllers/viewportSyncController.js +89 -30
- package/dist/engine/exportCommands.cjs +1 -1
- package/dist/engine/exportCommands.js +16 -9
- package/dist/engine/filterPopoverCommands.cjs +1 -1
- package/dist/engine/filterPopoverCommands.d.ts +2 -0
- package/dist/engine/filterPopoverCommands.js +15 -15
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +17 -17
- package/dist/engine/gridApi.cjs +3 -3
- package/dist/engine/gridApi.d.ts +7 -2
- package/dist/engine/gridApi.js +16 -16
- package/dist/engine/rowSelectionCommands.cjs +1 -1
- package/dist/engine/rowSelectionCommands.d.ts +1 -0
- package/dist/engine/rowSelectionCommands.js +21 -12
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +7 -6
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +10 -4
- package/dist/logic/autoScrollGeometry.cjs +1 -1
- package/dist/logic/autoScrollGeometry.d.ts +2 -0
- package/dist/logic/autoScrollGeometry.js +3 -3
- package/dist/logic/columnAutosize.cjs +1 -1
- package/dist/logic/columnAutosize.d.ts +8 -2
- package/dist/logic/columnAutosize.js +102 -87
- package/dist/logic/detailRow.cjs +1 -1
- package/dist/logic/detailRow.d.ts +4 -0
- package/dist/logic/detailRow.js +18 -15
- package/dist/logic/editorValues.cjs +1 -1
- package/dist/logic/editorValues.d.ts +1 -0
- package/dist/logic/editorValues.js +37 -34
- package/dist/logic/exportCsv.cjs +3 -3
- package/dist/logic/exportCsv.d.ts +3 -1
- package/dist/logic/exportCsv.js +22 -20
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +3 -1
- package/dist/logic/exportData.js +40 -36
- package/dist/logic/filterSummary.cjs +1 -1
- package/dist/logic/filterSummary.js +9 -2
- package/dist/logic/filtering.cjs +1 -1
- package/dist/logic/filtering.d.ts +2 -1
- package/dist/logic/filtering.js +16 -3
- package/dist/logic/find.cjs +1 -1
- package/dist/logic/find.d.ts +4 -3
- package/dist/logic/find.js +27 -13
- package/dist/logic/gridAsk.cjs +2 -2
- package/dist/logic/gridAsk.d.ts +7 -7
- package/dist/logic/gridAsk.js +140 -122
- package/dist/logic/gridAskLocaleText.cjs +1 -1
- package/dist/logic/gridAskLocaleText.d.ts +2 -0
- package/dist/logic/gridAskLocaleText.js +1 -0
- package/dist/logic/gridState.d.ts +2 -2
- package/dist/logic/groupExport.cjs +1 -1
- package/dist/logic/groupExport.js +28 -27
- package/dist/logic/grouping.cjs +1 -1
- package/dist/logic/grouping.d.ts +1 -0
- package/dist/logic/grouping.js +52 -41
- package/dist/logic/historyRebase.cjs +1 -0
- package/dist/logic/historyRebase.d.ts +5 -0
- package/dist/logic/historyRebase.js +36 -0
- package/dist/logic/localeText.cjs +1 -1
- package/dist/logic/localeText.d.ts +2 -0
- package/dist/logic/localeText.js +1 -0
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +4 -0
- package/dist/logic/localeTextFeatures.js +10 -7
- package/dist/logic/localeTextFilters.cjs +1 -1
- package/dist/logic/localeTextFilters.d.ts +1 -0
- package/dist/logic/localeTextFilters.js +1 -0
- package/dist/logic/localeTextPopups.cjs +1 -1
- package/dist/logic/localeTextPopups.d.ts +1 -0
- package/dist/logic/localeTextPopups.js +3 -2
- package/dist/logic/numberFilterCondition.cjs +1 -1
- package/dist/logic/numberFilterCondition.d.ts +1 -1
- package/dist/logic/numberFilterCondition.js +5 -5
- package/dist/logic/scrollTargets.cjs +1 -1
- package/dist/logic/scrollTargets.js +2 -2
- package/dist/logic/selectEditorState.cjs +1 -1
- package/dist/logic/selectEditorState.d.ts +1 -0
- package/dist/logic/selectEditorState.js +8 -1
- package/dist/logic/selectLabels.cjs +1 -0
- package/dist/logic/selectLabels.d.ts +3 -0
- package/dist/logic/selectLabels.js +41 -0
- package/dist/logic/valueFormatters.d.ts +5 -5
- package/dist/logic/valueParsers.cjs +1 -0
- package/dist/logic/valueParsers.d.ts +14 -0
- package/dist/logic/valueParsers.js +23 -0
- package/dist/logic/verticalGeometry.cjs +1 -1
- package/dist/logic/verticalGeometry.d.ts +1 -0
- package/dist/logic/verticalGeometry.js +12 -8
- package/dist/model/gridActions.cjs +1 -1
- package/dist/model/gridActions.d.ts +2 -1
- package/dist/model/gridActions.js +3 -2
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.js +145 -62
- package/dist/model/gridTypes.core.d.ts +492 -315
- package/dist/utils/clipboard.cjs +4 -6
- package/dist/utils/clipboard.d.ts +15 -2
- package/dist/utils/clipboard.js +103 -48
- package/dist/utils/popupContainer.cjs +1 -0
- package/dist/utils/popupContainer.d.ts +8 -0
- package/dist/utils/popupContainer.js +60 -0
- package/package.json +1 -1
|
@@ -15,75 +15,75 @@ var _ = 240, v = 8, y = 8, b = 230, x = 340, S = 480, C = (e, t) => {
|
|
|
15
15
|
...n,
|
|
16
16
|
filterType: t.filterType
|
|
17
17
|
};
|
|
18
|
-
}, w = () => {
|
|
19
|
-
let
|
|
18
|
+
}, w = () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(pointer: coarse)").matches, T = () => {
|
|
19
|
+
let T = null, E = e({
|
|
20
20
|
state: null,
|
|
21
21
|
layout: null
|
|
22
|
-
}),
|
|
23
|
-
let t =
|
|
24
|
-
n === e || n !== null && e !== null && n.top === e.top && n.left === e.left && n.width === e.width && n.maxHeight === e.maxHeight ||
|
|
22
|
+
}), D = { current: null }, O = { current: null }, k = { current: null }, A = null, j = null, M = null, N = null, P = null, F = null, I = null, L = null, R = (e) => {
|
|
23
|
+
let t = E.getSnapshot(), n = t.layout;
|
|
24
|
+
n === e || n !== null && e !== null && n.top === e.top && n.left === e.left && n.width === e.width && n.maxHeight === e.maxHeight || E.setSnapshot({
|
|
25
25
|
...t,
|
|
26
26
|
layout: e
|
|
27
27
|
});
|
|
28
|
-
},
|
|
29
|
-
let n =
|
|
28
|
+
}, z = () => T === null ? null : C(T.visibleColumns, E.getSnapshot().state), B = (e) => {
|
|
29
|
+
let n = T?.gridRootRef.current ?? null;
|
|
30
30
|
if (!n) return null;
|
|
31
|
-
let r =
|
|
31
|
+
let r = T?.resolveAnchorColumnKey?.(e) ?? e, i = n.querySelectorAll("[data-ssg-col-key]");
|
|
32
32
|
return Array.from(i).find((e) => e.dataset.ssgColKey === r && !t(n, e)) ?? null;
|
|
33
|
-
},
|
|
34
|
-
let e =
|
|
35
|
-
if (!e || !
|
|
36
|
-
|
|
33
|
+
}, V = () => {
|
|
34
|
+
let e = E.getSnapshot().state;
|
|
35
|
+
if (!e || !A) {
|
|
36
|
+
R(null);
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
-
if (!
|
|
40
|
-
let t =
|
|
39
|
+
if (!A.isConnected) {
|
|
40
|
+
let t = B(e.columnKey);
|
|
41
41
|
if (t === null) return;
|
|
42
|
-
|
|
42
|
+
A = t;
|
|
43
43
|
}
|
|
44
|
-
let t =
|
|
44
|
+
let t = A.getBoundingClientRect(), n = z()?.filterType, r = n === "numberSet" || n === "textSet" || n === "dateSet" ? S : n === "set" ? x : b, { top: i, left: a, maxHeight: o } = h({
|
|
45
45
|
anchorTop: t.top,
|
|
46
46
|
anchorBottom: t.bottom,
|
|
47
47
|
anchorRight: t.right,
|
|
48
48
|
viewportWidth: window.innerWidth,
|
|
49
49
|
viewportHeight: window.innerHeight,
|
|
50
50
|
popupWidth: _,
|
|
51
|
-
popupHeight:
|
|
51
|
+
popupHeight: j ?? r,
|
|
52
52
|
offsetY: y,
|
|
53
53
|
viewportMargin: v
|
|
54
54
|
});
|
|
55
|
-
|
|
55
|
+
R({
|
|
56
56
|
top: i,
|
|
57
57
|
left: a,
|
|
58
58
|
width: _,
|
|
59
59
|
maxHeight: o
|
|
60
60
|
});
|
|
61
|
-
}, V = () => {
|
|
62
|
-
N !== null && (cancelAnimationFrame(N), N = null), P !== null && (cancelAnimationFrame(P), P = null);
|
|
63
61
|
}, H = () => {
|
|
64
|
-
|
|
65
|
-
}, U = (
|
|
66
|
-
|
|
62
|
+
P !== null && (cancelAnimationFrame(P), P = null), F !== null && (cancelAnimationFrame(F), F = null);
|
|
63
|
+
}, U = () => {
|
|
64
|
+
M?.disconnect(), M = null, N = null;
|
|
65
|
+
}, W = (e) => {
|
|
66
|
+
E.setSnapshot({
|
|
67
67
|
state: null,
|
|
68
68
|
layout: null
|
|
69
|
-
}),
|
|
70
|
-
},
|
|
71
|
-
onResize:
|
|
72
|
-
onScroll:
|
|
73
|
-
isInside: (e) => !g(e,
|
|
74
|
-
onOutsidePointerDown: (e) =>
|
|
75
|
-
getGridRoot: () =>
|
|
76
|
-
onGridHidden: () =>
|
|
69
|
+
}), A = null, O.current = null, k.current = null, j = null, K.detach(), U(), H(), I = null, T !== null && e && a(T.gridRootRef);
|
|
70
|
+
}, G = () => W(!0), K = r({
|
|
71
|
+
onResize: V,
|
|
72
|
+
onScroll: V,
|
|
73
|
+
isInside: (e) => !g(e, D.current),
|
|
74
|
+
onOutsidePointerDown: (e) => W(T !== null && i(T.gridRootRef, e)),
|
|
75
|
+
getGridRoot: () => T?.gridRootRef.current ?? null,
|
|
76
|
+
onGridHidden: () => W(!1),
|
|
77
77
|
onKeyDown: (e) => {
|
|
78
|
-
e.key !== "Escape" ||
|
|
78
|
+
e.key !== "Escape" || D.current !== null || (e.preventDefault(), G());
|
|
79
79
|
}
|
|
80
|
-
}),
|
|
81
|
-
if (
|
|
82
|
-
let { gridRootRef: t, resolveColumnFilterType: r, columnFilterValues: i } =
|
|
83
|
-
n(t.current),
|
|
80
|
+
}), q = (e) => {
|
|
81
|
+
if (T === null || !T.enableColumnFilter) return;
|
|
82
|
+
let { gridRootRef: t, resolveColumnFilterType: r, columnFilterValues: i } = T;
|
|
83
|
+
n(t.current), A = B(e.key);
|
|
84
84
|
let a = e.filterType === "auto" && r ? r(e) : e.filterType ?? "text", h = i[e.key], g = a === "number" ? d(c(h) ? h : void 0) : a === "numberSet" ? f(l(h) ? h.condition : void 0) : null, _ = a === "textSet" ? p(u(h) ? h.condition : void 0) : null, v = a === "dateSet" ? m(s(h) ? h.condition : void 0) : null;
|
|
85
|
-
|
|
86
|
-
...
|
|
85
|
+
E.setSnapshot({
|
|
86
|
+
...E.getSnapshot(),
|
|
87
87
|
state: {
|
|
88
88
|
columnKey: e.key,
|
|
89
89
|
filterType: a,
|
|
@@ -92,47 +92,51 @@ var _ = 240, v = 8, y = 8, b = 230, x = 340, S = 480, C = (e, t) => {
|
|
|
92
92
|
textDraft: _,
|
|
93
93
|
dateDraft: v
|
|
94
94
|
}
|
|
95
|
-
}),
|
|
96
|
-
},
|
|
97
|
-
let t =
|
|
98
|
-
t.state &&
|
|
95
|
+
}), V(), K.attach();
|
|
96
|
+
}, J = (e) => {
|
|
97
|
+
let t = E.getSnapshot();
|
|
98
|
+
t.state && E.setSnapshot({
|
|
99
99
|
...t,
|
|
100
100
|
state: {
|
|
101
101
|
...t.state,
|
|
102
102
|
...e
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
|
-
},
|
|
106
|
-
let e =
|
|
107
|
-
if (!(
|
|
108
|
-
|
|
105
|
+
}, Y = () => {
|
|
106
|
+
let e = D.current;
|
|
107
|
+
if (!(E.getSnapshot().layout !== null && e !== null) || typeof ResizeObserver > "u") {
|
|
108
|
+
U();
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
let e =
|
|
113
|
-
e === null || e ===
|
|
114
|
-
}),
|
|
115
|
-
},
|
|
116
|
-
let { state: e, layout: t } =
|
|
111
|
+
N !== e && (U(), M = new ResizeObserver(() => {
|
|
112
|
+
let e = D.current?.getBoundingClientRect().height ?? null;
|
|
113
|
+
e === null || e === j || (j = e, V());
|
|
114
|
+
}), M.observe(e), N = e);
|
|
115
|
+
}, X = () => {
|
|
116
|
+
let { state: e, layout: t } = E.getSnapshot(), n = z();
|
|
117
117
|
if (!e || !n || !t) {
|
|
118
|
-
|
|
118
|
+
H(), I = null;
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
|
-
if (
|
|
122
|
-
|
|
121
|
+
if (D.current === null) {
|
|
122
|
+
H(), I = null;
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
|
-
let r =
|
|
126
|
-
if (!r &&
|
|
127
|
-
|
|
125
|
+
let r = L !== T?.visibleColumns, i = `${e.columnKey}|${e.filterType}|${t.top}|${t.left}|${t.width}`;
|
|
126
|
+
if (!r && I === i) return;
|
|
127
|
+
I = i, L = T?.visibleColumns ?? null, H();
|
|
128
128
|
let a = n.filterType ?? "text";
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (
|
|
132
|
-
|
|
129
|
+
P = requestAnimationFrame(() => {
|
|
130
|
+
P = null, F = requestAnimationFrame(() => {
|
|
131
|
+
if (F = null, a === "select") {
|
|
132
|
+
k.current?.focus();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (w()) {
|
|
136
|
+
D.current?.focus({ preventScroll: !0 });
|
|
133
137
|
return;
|
|
134
138
|
}
|
|
135
|
-
let e =
|
|
139
|
+
let e = O.current;
|
|
136
140
|
if (e && (e.focus(), e.type === "text")) {
|
|
137
141
|
let t = e.value.length;
|
|
138
142
|
e.setSelectionRange(t, t);
|
|
@@ -142,23 +146,23 @@ var _ = 240, v = 8, y = 8, b = 230, x = 340, S = 480, C = (e, t) => {
|
|
|
142
146
|
};
|
|
143
147
|
return {
|
|
144
148
|
update: (e) => {
|
|
145
|
-
|
|
149
|
+
T = e, Y(), X();
|
|
146
150
|
},
|
|
147
|
-
subscribe:
|
|
148
|
-
getSnapshot:
|
|
149
|
-
panelRef:
|
|
150
|
-
textInputRef:
|
|
151
|
-
selectRef:
|
|
152
|
-
open:
|
|
153
|
-
close:
|
|
154
|
-
updateDraft: (e) =>
|
|
155
|
-
updateNumberDraft: (e) =>
|
|
156
|
-
updateTextDraft: (e) =>
|
|
157
|
-
updateDateDraft: (e) =>
|
|
151
|
+
subscribe: E.subscribe,
|
|
152
|
+
getSnapshot: E.getSnapshot,
|
|
153
|
+
panelRef: D,
|
|
154
|
+
textInputRef: O,
|
|
155
|
+
selectRef: k,
|
|
156
|
+
open: q,
|
|
157
|
+
close: G,
|
|
158
|
+
updateDraft: (e) => J({ draftValue: e }),
|
|
159
|
+
updateNumberDraft: (e) => J({ numberDraft: e }),
|
|
160
|
+
updateTextDraft: (e) => J({ textDraft: e }),
|
|
161
|
+
updateDateDraft: (e) => J({ dateDraft: e }),
|
|
158
162
|
dispose: () => {
|
|
159
|
-
|
|
163
|
+
K.detach(), U(), H();
|
|
160
164
|
}
|
|
161
165
|
};
|
|
162
166
|
};
|
|
163
167
|
//#endregion
|
|
164
|
-
export {
|
|
168
|
+
export { T as createFilterPopoverController, C as resolveOpenedFilterColumn };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("../logic/chunkedLoop.cjs"),n=require("../logic/detailRow.cjs"),r=require("../logic/find.cjs");var i=1e4,a=5e4,o=new Map,s=[],c=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.rowIndex===r.rowIndex&&e.colIndex===r.colIndex&&e.columnKey===r.columnKey&&e.start===r.start&&e.length===r.length}),l=()=>{let i=null,l=0,u=null,d=!1,f=null,p=e.createValueStore({open:!1,query:``,matches:[],index:o,currentIndex:null,scanning:!1,truncated:!1}),m=e=>{p.setSnapshot({...p.getSnapshot(),...e})},h=null,g=()=>{let e=p.getSnapshot(),t={query:e.query,matchCount:e.matches.length,currentIndex:e.currentIndex,open:e.open};h!==null&&h.query===t.query&&h.matchCount===t.matchCount&&h.currentIndex===t.currentIndex&&h.open===t.open||(h=t,i?.onChange?.(t))},_=()=>{let e=p.getSnapshot();if(e.currentIndex===null)return;let t=e.matches[e.currentIndex];t&&i?.onNavigate(t.rowIndex,t.colIndex)},v=()=>{l+=1,f=null,u=null,d=!1,m({matches:[],index:o,currentIndex:null,scanning:!1,truncated:!1})},y=(e,o=!1)=>{let h=i,b=p.getSnapshot();if(!h||!b.open||b.query.length===0){v(),g();return}l+=1;let x=l,{rowModel:S,columns:C,caseSensitive:w}=h,T=b.query,
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("../logic/chunkedLoop.cjs"),n=require("../logic/detailRow.cjs"),r=require("../logic/find.cjs");var i=1e4,a=5e4,o=new Map,s=[],c=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.rowIndex===r.rowIndex&&e.colIndex===r.colIndex&&e.columnKey===r.columnKey&&e.start===r.start&&e.length===r.length}),l=()=>{let i=null,l=0,u=null,d=!1,f=null,p=e.createValueStore({open:!1,query:``,matches:[],index:o,currentIndex:null,scanning:!1,truncated:!1}),m=e=>{p.setSnapshot({...p.getSnapshot(),...e})},h=null,g=()=>{let e=p.getSnapshot(),t={query:e.query,matchCount:e.matches.length,currentIndex:e.currentIndex,open:e.open};h!==null&&h.query===t.query&&h.matchCount===t.matchCount&&h.currentIndex===t.currentIndex&&h.open===t.open||(h=t,i?.onChange?.(t))},_=()=>{let e=p.getSnapshot();if(e.currentIndex===null)return;let t=e.matches[e.currentIndex];t&&i?.onNavigate(t.rowIndex,t.colIndex)},v=()=>{l+=1,f=null,u=null,d=!1,m({matches:[],index:o,currentIndex:null,scanning:!1,truncated:!1})},y=(e,o=!1)=>{let h=i,b=p.getSnapshot();if(!h||!b.open||b.query.length===0){v(),g();return}l+=1;let x=l,{rowModel:S,columns:C,caseSensitive:w}=h,T=h.conditionalFormat!==!1,E=b.query,D=f!==null&&f.query===E&&f.caseSensitive===w;f={rowModel:S,columns:C,query:E,caseSensitive:w,conditionalFormatShown:T},(o||u===null||u.columns!==C||u.query!==E||u.caseSensitive!==w||u.conditionalFormatShown!==T)&&(u={columns:C,query:E,caseSensitive:w,conditionalFormatShown:T,byRow:new WeakMap});let O=u.byRow,k=0,A=e||d;d=A;let j=b.currentIndex===null?null:b.matches[b.currentIndex]??null,M=[],N=!1,P=S.getRowCount(),F=P>a,I=(e,t)=>{let i=[];return C.forEach((a,o)=>{if(n.isSyntheticColumnKey(a.key)||!r.isFindableColumn(a,T))return;let s=r.resolveFindCellText(a,e,!T||a.conditionalFormat?.chips===void 0?void 0:{rowIndex:t,sourceRowIndex:S.getSourceIndex(t)??t,rowKey:S.getRowKey(t)??t,colIndex:o});for(let e of r.findRangesInText(s,E,w))i.push({colIndex:o,columnKey:String(a.key),start:e.start,length:e.length})}),i.length===0?s:i};!D&&!b.scanning&&m({scanning:!0}),t.runChunked(P,e=>{if(N)return;let t=S.getRow(e);if(t===void 0)return;let n;F&&typeof t==`object`&&t?(n=O.get(t),n===void 0?(n=I(t,e),O.set(t,n)):k+=1):n=I(t,e);for(let t of n){if(M.length>=1e4){N=!0;return}M.push({rowIndex:e,colIndex:t.colIndex,columnKey:t.columnKey,start:t.start,length:t.length})}},{isCancelled:()=>l!==x}).then(e=>{if(!e||l!==x||(d=!1,o&&N===p.getSnapshot().truncated&&c(p.getSnapshot().matches,M)))return;let t=r.resolveCurrentAfterRescan(M,j);m({matches:M,index:r.buildFindIndex(M),currentIndex:t,scanning:!1,truncated:N}),g(),A&&_(),!o&&k>0&&y(!1,!0)})},b=()=>{let e=p.getSnapshot();return!i||!e.open||e.query.length===0?!1:f===null||f.rowModel!==i.rowModel||f.columns!==i.columns||f.query!==e.query||f.caseSensitive!==i.caseSensitive||f.conditionalFormatShown!==(i.conditionalFormat!==!1)};return{update:e=>{let t=i;if(i=e,!e.enabled){p.getSnapshot().open&&(m({open:!1,query:``}),v(),g());return}t!==e&&b()&&y(!1)},open:e=>{if(!i?.enabled)return;let t=p.getSnapshot(),n=e??t.query;m({open:!0,query:n}),n!==t.query||!t.open?y(!0):g()},close:()=>{p.getSnapshot().open&&(m({open:!1,query:``}),v(),g())},setQuery:e=>{let t=p.getSnapshot();!t.open||e===t.query||(m({query:e}),y(!0))},next:()=>{let e=p.getSnapshot(),t=r.stepFindIndex(e.currentIndex,e.matches.length,1);m({currentIndex:t}),g(),_()},prev:()=>{let e=p.getSnapshot(),t=r.stepFindIndex(e.currentIndex,e.matches.length,-1);m({currentIndex:t}),g(),_()},subscribe:p.subscribe,getSnapshot:p.getSnapshot,dispose:()=>{l+=1,i=null}}};exports.FIND_HIT_CACHE_ROW_THRESHOLD=a,exports.MAX_FIND_MATCHES=i,exports.createFindController=l;
|
|
@@ -13,6 +13,7 @@ export type FindArgs<T> = {
|
|
|
13
13
|
caseSensitive: boolean;
|
|
14
14
|
onNavigate: (rowIndex: number, colIndex: number) => void;
|
|
15
15
|
onChange?: (params: FindChangeParams) => void;
|
|
16
|
+
conditionalFormat?: boolean | undefined;
|
|
16
17
|
};
|
|
17
18
|
export type FindSnapshot = {
|
|
18
19
|
open: boolean;
|
|
@@ -48,45 +48,52 @@ var l = 1e4, u = 5e4, d = /* @__PURE__ */ new Map(), f = [], p = (e, t) => e.len
|
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
m += 1;
|
|
51
|
-
let T = m, { rowModel: E, columns: D, caseSensitive: O } = d, k = b.query,
|
|
51
|
+
let T = m, { rowModel: E, columns: D, caseSensitive: O } = d, k = d.conditionalFormat !== !1, A = b.query, j = _ !== null && _.query === A && _.caseSensitive === O;
|
|
52
52
|
_ = {
|
|
53
53
|
rowModel: E,
|
|
54
54
|
columns: D,
|
|
55
|
-
query:
|
|
56
|
-
caseSensitive: O
|
|
57
|
-
|
|
55
|
+
query: A,
|
|
56
|
+
caseSensitive: O,
|
|
57
|
+
conditionalFormatShown: k
|
|
58
|
+
}, (c || h === null || h.columns !== D || h.query !== A || h.caseSensitive !== O || h.conditionalFormatShown !== k) && (h = {
|
|
58
59
|
columns: D,
|
|
59
|
-
query:
|
|
60
|
+
query: A,
|
|
60
61
|
caseSensitive: O,
|
|
62
|
+
conditionalFormatShown: k,
|
|
61
63
|
byRow: /* @__PURE__ */ new WeakMap()
|
|
62
64
|
});
|
|
63
|
-
let
|
|
64
|
-
g =
|
|
65
|
-
let
|
|
66
|
-
let
|
|
67
|
-
return D.forEach((
|
|
68
|
-
if (n(
|
|
69
|
-
let
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
let M = h.byRow, N = 0, P = e || g;
|
|
66
|
+
g = P;
|
|
67
|
+
let F = b.currentIndex === null ? null : b.matches[b.currentIndex] ?? null, I = [], L = !1, R = E.getRowCount(), z = R > u, B = (e, t) => {
|
|
68
|
+
let r = [];
|
|
69
|
+
return D.forEach((o, c) => {
|
|
70
|
+
if (n(o.key) || !a(o, k)) return;
|
|
71
|
+
let l = s(o, e, !k || o.conditionalFormat?.chips === void 0 ? void 0 : {
|
|
72
|
+
rowIndex: t,
|
|
73
|
+
sourceRowIndex: E.getSourceIndex(t) ?? t,
|
|
74
|
+
rowKey: E.getRowKey(t) ?? t,
|
|
75
|
+
colIndex: c
|
|
76
|
+
});
|
|
77
|
+
for (let e of i(l, A, O)) r.push({
|
|
78
|
+
colIndex: c,
|
|
79
|
+
columnKey: String(o.key),
|
|
73
80
|
start: e.start,
|
|
74
81
|
length: e.length
|
|
75
82
|
});
|
|
76
|
-
}),
|
|
83
|
+
}), r.length === 0 ? f : r;
|
|
77
84
|
};
|
|
78
|
-
!
|
|
79
|
-
if (
|
|
85
|
+
!j && !b.scanning && y({ scanning: !0 }), t(R, (e) => {
|
|
86
|
+
if (L) return;
|
|
80
87
|
let t = E.getRow(e);
|
|
81
88
|
if (t === void 0) return;
|
|
82
89
|
let n;
|
|
83
|
-
|
|
90
|
+
z && typeof t == "object" && t ? (n = M.get(t), n === void 0 ? (n = B(t, e), M.set(t, n)) : N += 1) : n = B(t, e);
|
|
84
91
|
for (let t of n) {
|
|
85
|
-
if (
|
|
86
|
-
|
|
92
|
+
if (I.length >= 1e4) {
|
|
93
|
+
L = !0;
|
|
87
94
|
return;
|
|
88
95
|
}
|
|
89
|
-
|
|
96
|
+
I.push({
|
|
90
97
|
rowIndex: e,
|
|
91
98
|
colIndex: t.colIndex,
|
|
92
99
|
columnKey: t.columnKey,
|
|
@@ -95,19 +102,19 @@ var l = 1e4, u = 5e4, d = /* @__PURE__ */ new Map(), f = [], p = (e, t) => e.len
|
|
|
95
102
|
});
|
|
96
103
|
}
|
|
97
104
|
}, { isCancelled: () => m !== T }).then((e) => {
|
|
98
|
-
if (!e || m !== T || (g = !1, c &&
|
|
99
|
-
let t = o(
|
|
105
|
+
if (!e || m !== T || (g = !1, c && L === v.getSnapshot().truncated && p(v.getSnapshot().matches, I))) return;
|
|
106
|
+
let t = o(I, F);
|
|
100
107
|
y({
|
|
101
|
-
matches:
|
|
102
|
-
index: r(
|
|
108
|
+
matches: I,
|
|
109
|
+
index: r(I),
|
|
103
110
|
currentIndex: t,
|
|
104
111
|
scanning: !1,
|
|
105
|
-
truncated:
|
|
106
|
-
}), x(),
|
|
112
|
+
truncated: L
|
|
113
|
+
}), x(), P && S(), !c && N > 0 && w(!1, !0);
|
|
107
114
|
});
|
|
108
115
|
}, T = () => {
|
|
109
116
|
let e = v.getSnapshot();
|
|
110
|
-
return !l || !e.open || e.query.length === 0 ? !1 : _ === null || _.rowModel !== l.rowModel || _.columns !== l.columns || _.query !== e.query || _.caseSensitive !== l.caseSensitive;
|
|
117
|
+
return !l || !e.open || e.query.length === 0 ? !1 : _ === null || _.rowModel !== l.rowModel || _.columns !== l.columns || _.query !== e.query || _.caseSensitive !== l.caseSensitive || _.conditionalFormatShown !== (l.conditionalFormat !== !1);
|
|
111
118
|
};
|
|
112
119
|
return {
|
|
113
120
|
update: (e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../logic/history.cjs");var
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../logic/historyRebase.cjs"),n=require("../logic/history.cjs");var r=()=>{let r=null,i=n.createHistoryStack(),a=null,o=null,s={canUndo:!1,canRedo:!1},c=null,l=!1,u=()=>r!==null&&r.enabled&&r.onRowsChange!=null,d=()=>u()&&n.canUndoHistory(i),f=()=>u()&&n.canRedoHistory(i),p=()=>{let e={canUndo:d(),canRedo:f()};e.canUndo===s.canUndo&&e.canRedo===s.canRedo||(s=e,r?.onUndoRedoStateChange?.(e))},m=e=>{r=e,e.rows!==o&&(c=null),o===null?o=e.rows:e.rows!==o&&(o=e.rows,a===e.rows?a=null:(a=null,i=n.createHistoryStack(),l=!1)),p()},h=t=>{if(r===null)return;let{dispatch:n}=r,i=t.selection;i?.type===`cell`?(n(e.gridActions.startSelection(i.range.start)),n(e.gridActions.updateSelection(i.range.end)),n(e.gridActions.endSelection())):i?.type===`row`?(n(e.gridActions.startRowSelection(i.startRow)),n(e.gridActions.updateRowSelection(i.endRow)),n(e.gridActions.endSelection())):i?.type===`col`?(n(e.gridActions.startColumnSelection(i.startCol)),n(e.gridActions.updateColumnSelection(i.endCol)),n(e.gridActions.endSelection())):n(e.gridActions.clearSelection()),n(e.gridActions.activateCell(t.activeCell))},g=(e,t)=>{r===null||!r.onRowsChange||(r.enabled&&(i=n.pushHistory(i,{rows:e,after:t,selection:r.selection,activeCell:r.activeCell},r.limit),a=t,p()),c=t,r.onRowsChange(t))},_=e=>{r===null||!r.onRowsChange||g(r.rows,e)},v=e=>{if(!(r===null||!r.onRowsChange)){if(r.enabled){a=e;let t=i.past[i.past.length-1];t&&(i={...i,past:[...i.past.slice(0,-1),{...t,after:e}]})}c=e,r.onRowsChange(e)}},y=(e,t)=>{if(r===null||!r.onRowsChange)return;let n=c??r.rows,i=Array.isArray(e)?e:e(n);if(t?.undoable!==!1){g(n,i);return}r.enabled&&(a=i,l=!0),c=i,r.onRowsChange(i)},b=(e,n)=>{if(!e)return null;if(!l||e.after===n)return e.rows;let i=r?.rowKeyGetter;return!i&&(e.rows.length!==e.after.length||e.after.length!==n.length)?e.rows:t.revertRowsChange(e.rows,e.after,n,i??((e,t)=>t))},x=e=>{e===null||r===null||!r.onRowsChange||(i=e.stack,a=e.snapshot.rows,c=e.snapshot.rows,r.onRowsChange(e.snapshot.rows),h(e.snapshot),r.onAfterRestore?.(e.snapshot.activeCell),p())},S=(e,t)=>r===null?null:{rows:e,after:t,selection:r.selection,activeCell:r.activeCell},C=(e,t)=>{if(!u()||r===null)return;let n=c??r.rows,a=b(e,n),o=a===null?null:S(n,a);if(a===null||o===null)return;let s=t(i,o);x(s===null?null:{stack:s.stack,snapshot:{...s.snapshot,rows:a}})};return{update:m,handleRowsChange:_,amendRowsChange:v,applyRows:y,undo:()=>{C(i.past[i.past.length-1],n.undoHistory)},redo:()=>{C(i.future[i.future.length-1],n.redoHistory)},canUndo:d,canRedo:f,clearHistory:()=>{i=n.createHistoryStack(),l=!1,p()}}};exports.createHistoryController=r;
|
|
@@ -2,9 +2,13 @@ import { type GridUiAction } from '../model/gridActions.js';
|
|
|
2
2
|
import type { CellCoord, GridSelection, UndoRedoState } from '../model/gridTypes.unbound.js';
|
|
3
3
|
export type GridHistoryEntry<T> = {
|
|
4
4
|
rows: T[];
|
|
5
|
+
after: T[];
|
|
5
6
|
selection: GridSelection;
|
|
6
7
|
activeCell: CellCoord | null;
|
|
7
8
|
};
|
|
9
|
+
export type HistoryApplyRowsOptions = {
|
|
10
|
+
undoable?: boolean | undefined;
|
|
11
|
+
};
|
|
8
12
|
export type HistoryControllerArgs<T> = {
|
|
9
13
|
rows: T[];
|
|
10
14
|
selection: GridSelection;
|
|
@@ -15,11 +19,13 @@ export type HistoryControllerArgs<T> = {
|
|
|
15
19
|
limit: number;
|
|
16
20
|
onUndoRedoStateChange?: (state: UndoRedoState) => void;
|
|
17
21
|
onAfterRestore?: (activeCell: CellCoord | null) => void;
|
|
22
|
+
rowKeyGetter?: ((row: T, index: number) => unknown) | undefined;
|
|
18
23
|
};
|
|
19
24
|
export type HistoryController<T> = {
|
|
20
25
|
update: (args: HistoryControllerArgs<T>) => void;
|
|
21
26
|
handleRowsChange: (nextRows: T[]) => void;
|
|
22
27
|
amendRowsChange: (nextRows: T[]) => void;
|
|
28
|
+
applyRows: (next: T[] | ((prev: T[]) => T[]), options?: HistoryApplyRowsOptions) => void;
|
|
23
29
|
undo: () => void;
|
|
24
30
|
redo: () => void;
|
|
25
31
|
canUndo: () => boolean;
|
|
@@ -1,55 +1,97 @@
|
|
|
1
1
|
import { gridActions as e } from "../model/gridActions.js";
|
|
2
|
-
import {
|
|
2
|
+
import { revertRowsChange as t } from "../logic/historyRebase.js";
|
|
3
|
+
import { canRedoHistory as n, canUndoHistory as r, createHistoryStack as i, pushHistory as a, redoHistory as o, undoHistory as s } from "../logic/history.js";
|
|
3
4
|
//#region src/controllers/historyController.ts
|
|
4
|
-
var
|
|
5
|
-
let
|
|
5
|
+
var c = () => {
|
|
6
|
+
let c = null, l = i(), u = null, d = null, f = {
|
|
6
7
|
canUndo: !1,
|
|
7
8
|
canRedo: !1
|
|
8
|
-
},
|
|
9
|
+
}, p = null, m = !1, h = () => c !== null && c.enabled && c.onRowsChange != null, g = () => h() && r(l), _ = () => h() && n(l), v = () => {
|
|
9
10
|
let e = {
|
|
10
|
-
canUndo:
|
|
11
|
-
canRedo:
|
|
11
|
+
canUndo: g(),
|
|
12
|
+
canRedo: _()
|
|
12
13
|
};
|
|
13
|
-
e.canUndo ===
|
|
14
|
-
}, g = (e) => {
|
|
15
|
-
s = e, u === null ? u = e.rows : e.rows !== u && (u = e.rows, l === e.rows ? l = null : (l = null, c = r())), h();
|
|
16
|
-
}, _ = (t) => {
|
|
17
|
-
if (s === null) return;
|
|
18
|
-
let { dispatch: n } = s, r = t.selection;
|
|
19
|
-
r?.type === "cell" ? (n(e.startSelection(r.range.start)), n(e.updateSelection(r.range.end)), n(e.endSelection())) : r?.type === "row" ? (n(e.startRowSelection(r.startRow)), n(e.updateRowSelection(r.endRow)), n(e.endSelection())) : r?.type === "col" ? (n(e.startColumnSelection(r.startCol)), n(e.updateColumnSelection(r.endCol)), n(e.endSelection())) : n(e.clearSelection()), n(e.activateCell(t.activeCell));
|
|
20
|
-
}, v = (e) => {
|
|
21
|
-
s === null || !s.onRowsChange || (s.enabled && (c = i(c, {
|
|
22
|
-
rows: s.rows,
|
|
23
|
-
selection: s.selection,
|
|
24
|
-
activeCell: s.activeCell
|
|
25
|
-
}, s.limit), l = e, h()), s.onRowsChange(e));
|
|
14
|
+
e.canUndo === f.canUndo && e.canRedo === f.canRedo || (f = e, c?.onUndoRedoStateChange?.(e));
|
|
26
15
|
}, y = (e) => {
|
|
27
|
-
|
|
28
|
-
}, b = (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
c = e, e.rows !== d && (p = null), d === null ? d = e.rows : e.rows !== d && (d = e.rows, u === e.rows ? u = null : (u = null, l = i(), m = !1)), v();
|
|
17
|
+
}, b = (t) => {
|
|
18
|
+
if (c === null) return;
|
|
19
|
+
let { dispatch: n } = c, r = t.selection;
|
|
20
|
+
r?.type === "cell" ? (n(e.startSelection(r.range.start)), n(e.updateSelection(r.range.end)), n(e.endSelection())) : r?.type === "row" ? (n(e.startRowSelection(r.startRow)), n(e.updateRowSelection(r.endRow)), n(e.endSelection())) : r?.type === "col" ? (n(e.startColumnSelection(r.startCol)), n(e.updateColumnSelection(r.endCol)), n(e.endSelection())) : n(e.clearSelection()), n(e.activateCell(t.activeCell));
|
|
21
|
+
}, x = (e, t) => {
|
|
22
|
+
c === null || !c.onRowsChange || (c.enabled && (l = a(l, {
|
|
23
|
+
rows: e,
|
|
24
|
+
after: t,
|
|
25
|
+
selection: c.selection,
|
|
26
|
+
activeCell: c.activeCell
|
|
27
|
+
}, c.limit), u = t, v()), p = t, c.onRowsChange(t));
|
|
28
|
+
}, S = (e) => {
|
|
29
|
+
c === null || !c.onRowsChange || x(c.rows, e);
|
|
30
|
+
}, C = (e) => {
|
|
31
|
+
if (!(c === null || !c.onRowsChange)) {
|
|
32
|
+
if (c.enabled) {
|
|
33
|
+
u = e;
|
|
34
|
+
let t = l.past[l.past.length - 1];
|
|
35
|
+
t && (l = {
|
|
36
|
+
...l,
|
|
37
|
+
past: [...l.past.slice(0, -1), {
|
|
38
|
+
...t,
|
|
39
|
+
after: e
|
|
40
|
+
}]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
p = e, c.onRowsChange(e);
|
|
44
|
+
}
|
|
45
|
+
}, w = (e, t) => {
|
|
46
|
+
if (c === null || !c.onRowsChange) return;
|
|
47
|
+
let n = p ?? c.rows, r = Array.isArray(e) ? e : e(n);
|
|
48
|
+
if (t?.undoable !== !1) {
|
|
49
|
+
x(n, r);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
c.enabled && (u = r, m = !0), p = r, c.onRowsChange(r);
|
|
53
|
+
}, T = (e, n) => {
|
|
54
|
+
if (!e) return null;
|
|
55
|
+
if (!m || e.after === n) return e.rows;
|
|
56
|
+
let r = c?.rowKeyGetter;
|
|
57
|
+
return !r && (e.rows.length !== e.after.length || e.after.length !== n.length) ? e.rows : t(e.rows, e.after, n, r ?? ((e, t) => t));
|
|
58
|
+
}, E = (e) => {
|
|
59
|
+
e === null || c === null || !c.onRowsChange || (l = e.stack, u = e.snapshot.rows, p = e.snapshot.rows, c.onRowsChange(e.snapshot.rows), b(e.snapshot), c.onAfterRestore?.(e.snapshot.activeCell), v());
|
|
60
|
+
}, D = (e, t) => c === null ? null : {
|
|
61
|
+
rows: e,
|
|
62
|
+
after: t,
|
|
63
|
+
selection: c.selection,
|
|
64
|
+
activeCell: c.activeCell
|
|
65
|
+
}, O = (e, t) => {
|
|
66
|
+
if (!h() || c === null) return;
|
|
67
|
+
let n = p ?? c.rows, r = T(e, n), i = r === null ? null : D(n, r);
|
|
68
|
+
if (r === null || i === null) return;
|
|
69
|
+
let a = t(l, i);
|
|
70
|
+
E(a === null ? null : {
|
|
71
|
+
stack: a.stack,
|
|
72
|
+
snapshot: {
|
|
73
|
+
...a.snapshot,
|
|
74
|
+
rows: r
|
|
75
|
+
}
|
|
76
|
+
});
|
|
34
77
|
};
|
|
35
78
|
return {
|
|
36
|
-
update:
|
|
37
|
-
handleRowsChange:
|
|
38
|
-
amendRowsChange:
|
|
79
|
+
update: y,
|
|
80
|
+
handleRowsChange: S,
|
|
81
|
+
amendRowsChange: C,
|
|
82
|
+
applyRows: w,
|
|
39
83
|
undo: () => {
|
|
40
|
-
|
|
41
|
-
!f() || e === null || b(o(c, e));
|
|
84
|
+
O(l.past[l.past.length - 1], s);
|
|
42
85
|
},
|
|
43
86
|
redo: () => {
|
|
44
|
-
|
|
45
|
-
!f() || e === null || b(a(c, e));
|
|
87
|
+
O(l.future[l.future.length - 1], o);
|
|
46
88
|
},
|
|
47
|
-
canUndo:
|
|
48
|
-
canRedo:
|
|
89
|
+
canUndo: g,
|
|
90
|
+
canRedo: _,
|
|
49
91
|
clearHistory: () => {
|
|
50
|
-
|
|
92
|
+
l = i(), m = !1, v();
|
|
51
93
|
}
|
|
52
94
|
};
|
|
53
95
|
};
|
|
54
96
|
//#endregion
|
|
55
|
-
export {
|
|
97
|
+
export { c as createHistoryController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs")
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../logic/detailRow.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/geometry.cjs"),i=require("../logic/domGuards.cjs"),a=require("./escapeClaimController.cjs");var o=10,s=(e,t,n,r)=>{if(!e.getLabelRow)return t;let i=e.getRowCount(),a=t;for(;a>=0&&a<i&&e.getLabelRow(a);)a+=n;return a>=0&&a<i?a:r},c=e=>s(e,0,1,0),l=e=>t.resolveFirstDataColIndex(e),u=(e,t)=>({row:c(e),col:l(t)}),d=()=>{let t=null,d=e=>{t=e},f=(e,t)=>s(e,t,-1,s(e,t,1,t)),p=e=>{let t=e.getRowCount()-1;return s(e,t,-1,t)},m=(e,r,i)=>{if(t===null)return;let{uiState:a,dispatch:o}=t;if(i){let t=a.selection?.type===`cell`?a.selection.range.start:e;o(n.gridActions.startSelection(t)),o(n.gridActions.updateSelection(r)),o(n.gridActions.endSelection()),o(n.gridActions.activateCell(r));return}o(n.gridActions.startSelection(r)),o(n.gridActions.endSelection()),o(n.gridActions.activateCell(r))},h=()=>{if(t===null||t.uiState.activeCell)return!1;let{rowModel:e,visibleColumns:n}=t;if(e.getRowCount()===0||n.length===0)return!0;let r=u(e,n);return m(r,r,!1),!0},g=e=>{let n=t?.uiState;return e&&n?.selection?.type===`cell`?n.selection.range.end:n?.activeCell??{row:0,col:0}},_=(e,n,i)=>{if(t===null)return;let{rowModel:a,visibleColumns:o}=t,c=a.getRowCount();if(c===0||o.length===0||h())return;let l=g(i),u=r.clamp(l.row+e,0,c-1);u=e===0?f(a,u):s(a,u,e>0?1:-1,l.row);let d={row:u,col:r.clamp(l.col+n,0,o.length-1)};m(l,d,i)},v=(e,n)=>{if(t===null)return;let{uiState:i,rowModel:a,visibleColumns:o}=t;if(a.getRowCount()===0||o.length===0)return;let s=i.activeCell?g(n):{row:c(a),col:l(o)},u=e(s,a,o);m(s,{row:f(a,r.clamp(u.row,0,a.getRowCount()-1)),col:r.clamp(u.col,0,o.length-1)},n&&i.activeCell!==null)},y=(e,n,i)=>{let a=n.getRowCount(),c=t?.resolvePageRow?t.resolvePageRow(e.row,i):e.row+i*o,l=r.clamp(i>0?Math.max(c,e.row+1):Math.min(c,e.row-1),0,a-1),u=s(n,l,i,-1);return u>=0?u:s(n,l,i>0?-1:1,e.row)};return{update:d,handleKeyDown:async r=>{if(t===null)return;let{uiState:o,rowModel:s,visibleColumns:u,readOnly:d,canEditCell:f,setEditorInitialValue:m,dispatch:g,handleCopy:b,openFind:x,handleCellDoubleClick:S,isWholeGridSelected:C,selectEntireGrid:w,onUndo:T,onRedo:E,onClearSelection:D,enableClearOnDelete:O,onToggleCheckboxCell:k,onToggleGroup:A,onToggleDetailRow:j}=t;if(i.shouldIgnoreGridKeydown(r.target)||o.editingCell||r.isComposing&&i.isImeInputTarget(r.target))return;if((r.ctrlKey||r.metaKey)&&r.key.toLowerCase()===`c`){r.preventDefault(),await b();return}if((r.ctrlKey||r.metaKey)&&r.key.toLowerCase()===`f`&&x){r.preventDefault(),x();return}if((r.ctrlKey||r.metaKey)&&r.key.toLowerCase()===`a`){if(r.preventDefault(),C){g(n.gridActions.clearSelection()),g(n.gridActions.activateCell(null));return}w();return}if((r.ctrlKey||r.metaKey)&&!r.isComposing){if(r.key.toLowerCase()===`z`){r.preventDefault(),r.shiftKey?E():T();return}if(r.key.toLowerCase()===`y`&&!r.shiftKey){r.preventDefault(),E();return}}let M=r.ctrlKey||r.metaKey;if((r.key===`ContextMenu`||r.key===`F10`&&r.shiftKey)&&!M&&!r.altKey&&o.activeCell&&t.openContextMenu?.(o.activeCell)){r.preventDefault();return}if(r.key===`ArrowDown`&&r.altKey&&!M&&!r.shiftKey&&o.activeCell&&t.openColumnMenu?.(o.activeCell.col)){r.preventDefault();return}if(M&&!r.altKey&&(r.key===`ArrowUp`||r.key===`ArrowDown`)){r.preventDefault();let e=r.key===`ArrowDown`;v((t,n)=>({row:e?p(n):c(n),col:t.col}),r.shiftKey);return}if(M&&!r.altKey&&(r.key===`ArrowLeft`||r.key===`ArrowRight`)){r.preventDefault();let e=r.key===`ArrowRight`;v((t,n,r)=>({row:t.row,col:e?r.length-1:l(r)}),r.shiftKey);return}if((r.key===`Home`||r.key===`End`)&&!r.altKey){r.preventDefault();let e=r.key===`End`;v((t,n,r)=>({row:M?e?p(n):c(n):t.row,col:e?r.length-1:l(r)}),r.shiftKey);return}if((r.key===`PageDown`||r.key===`PageUp`)&&!M&&!r.altKey){if(r.preventDefault(),h())return;let e=r.key===`PageDown`?1:-1;v((t,n)=>({row:y(t,n,e),col:t.col}),r.shiftKey);return}if(r.key===`ArrowUp`){r.preventDefault(),_(-1,0,r.shiftKey);return}if(r.key===`ArrowDown`){r.preventDefault(),_(1,0,r.shiftKey);return}if(r.key===`ArrowLeft`){r.preventDefault(),_(0,-1,r.shiftKey);return}if(r.key===`ArrowRight`){r.preventDefault(),_(0,1,r.shiftKey);return}if(r.key===`Tab`){if(!o.activeCell&&!r.shiftKey){if(t.rowModel.getRowCount()===0||t.visibleColumns.length===0)return;r.preventDefault(),h();return}let e=o.activeCell?.col??0;if(r.shiftKey?e<=l(t.visibleColumns):e>=t.visibleColumns.length-1){!r.shiftKey&&o.activeCell&&t.onTabPastLastColumn?.(o.activeCell.row)&&r.preventDefault();return}r.preventDefault(),_(0,r.shiftKey?-1:1,!1);return}if(r.key===`Escape`){a.isClearableSelection(o.selection)&&r.preventDefault(),g(n.gridActions.clearSelection());return}if((r.key===`Delete`||r.key===`Backspace`)&&O){r.preventDefault(),D();return}if((r.key===`Enter`||r.key===` `)&&o.activeCell){let e=s.getGroupRow?.(o.activeCell.row);if(e){r.preventDefault(),A(e.groupKey);return}if(j&&u[o.activeCell.col]?.key===`__ssg_detail_toggle__`&&j(o.activeCell)){r.preventDefault();return}}if(r.key===`Enter`||r.key===`F2`){if(r.preventDefault(),o.activeCell){S(o.activeCell);return}r.key===`Enter`&&h();return}if(r.key===` `&&!r.ctrlKey&&!r.metaKey&&!r.altKey&&r.preventDefault(),i.isPrintableKey(r)&&o.activeCell){let t=s.getRow(o.activeCell.row),i=u[o.activeCell.col];if(!t||!i||!e.isViewCellEditable({readOnly:d,canEditCell:f},s,o.activeCell.row,o.activeCell.col,t,i))return;if(i.editor?.type===`checkbox`){r.preventDefault(),r.key===` `&&k(o.activeCell);return}r.preventDefault(),m(r.key),g(n.gridActions.startEdit(o.activeCell))}}}};exports.createKeyboardController=d,exports.resolveFirstDataCell=u;
|
|
@@ -32,6 +32,7 @@ export type KeyboardControllerArgs<T> = {
|
|
|
32
32
|
onToggleDetailRow?: (cell: CellCoord) => boolean;
|
|
33
33
|
resolvePageRow?: (fromRow: number, direction: 1 | -1) => number;
|
|
34
34
|
openColumnMenu?: (col: number) => boolean;
|
|
35
|
+
openContextMenu?: (cell: CellCoord) => boolean;
|
|
35
36
|
onTabPastLastColumn?: (viewRowIndex: number) => boolean;
|
|
36
37
|
};
|
|
37
38
|
export declare const resolveFirstDataCell: <T>(rowModel: RowModel<T>, visibleColumns: GridColumn<T>[]) => CellCoord;
|