@ishibashi0112/spreadsheet-grid-core 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controllers/activeRowFollowController.cjs +1 -0
- package/dist/controllers/activeRowFollowController.d.ts +18 -0
- package/dist/controllers/activeRowFollowController.js +68 -0
- package/dist/controllers/autoHeightMeasurer.cjs +1 -1
- package/dist/controllers/autoHeightMeasurer.js +17 -17
- package/dist/controllers/clipboardController.cjs +1 -1
- package/dist/controllers/clipboardController.d.ts +1 -0
- package/dist/controllers/clipboardController.js +58 -49
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.js +10 -10
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.d.ts +1 -0
- package/dist/controllers/contextMenuController.js +12 -7
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.d.ts +1 -0
- package/dist/controllers/editController.js +106 -99
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.js +78 -78
- package/dist/controllers/filterPopoverController.cjs +1 -1
- package/dist/controllers/filterPopoverController.js +6 -6
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +1 -0
- package/dist/controllers/findController.js +16 -15
- package/dist/controllers/imeInputController.cjs +1 -1
- package/dist/controllers/imeInputController.js +65 -54
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.js +43 -43
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.js +64 -64
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +1 -0
- package/dist/controllers/rowDragController.js +117 -104
- package/dist/controllers/scrollSyncController.cjs +1 -1
- package/dist/controllers/scrollSyncController.js +45 -43
- package/dist/controllers/serverSideRowModel.cjs +1 -1
- package/dist/controllers/serverSideRowModel.js +19 -19
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +1 -0
- package/dist/controllers/viewportSyncController.js +1 -1
- package/dist/engine/columnCommands.cjs +1 -1
- package/dist/engine/columnCommands.js +113 -113
- package/dist/engine/createGridEngine.cjs +3 -3
- package/dist/engine/createGridEngine.d.ts +2 -0
- package/dist/engine/createGridEngine.js +72 -70
- package/dist/engine/exportCommands.cjs +1 -1
- package/dist/engine/exportCommands.js +4 -2
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +6 -6
- package/dist/engine/gridApi.cjs +6 -6
- package/dist/engine/gridApi.d.ts +2 -0
- package/dist/engine/gridApi.js +193 -183
- package/dist/engine/notifiers.cjs +1 -1
- package/dist/engine/notifiers.d.ts +4 -0
- package/dist/engine/notifiers.js +7 -7
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +2 -0
- package/dist/logic/exportCsv.cjs +2 -2
- package/dist/logic/exportCsv.d.ts +2 -1
- package/dist/logic/exportCsv.js +13 -13
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +2 -1
- package/dist/logic/exportData.js +18 -18
- package/dist/logic/geometry.cjs +1 -1
- package/dist/logic/geometry.d.ts +2 -0
- package/dist/logic/geometry.js +41 -20
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +3 -2
- package/dist/logic/gridState.js +32 -23
- package/dist/logic/grouping.cjs +1 -1
- package/dist/logic/grouping.js +1 -1
- package/dist/logic/imeInput.cjs +1 -1
- package/dist/logic/imeInput.js +6 -4
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +4 -0
- package/dist/logic/localeTextFeatures.js +8 -5
- package/dist/logic/pasteFill.cjs +1 -0
- package/dist/logic/pasteFill.d.ts +2 -0
- package/dist/logic/pasteFill.js +25 -0
- package/dist/logic/selectEditorState.cjs +1 -1
- package/dist/logic/selectEditorState.d.ts +4 -1
- package/dist/logic/selectEditorState.js +14 -14
- package/dist/logic/selectionAggregates.cjs +1 -1
- package/dist/logic/selectionAggregates.js +2 -3
- package/dist/logic/validation.cjs +1 -1
- package/dist/logic/validation.d.ts +1 -1
- package/dist/logic/validation.js +21 -21
- package/dist/model/gridActions.cjs +1 -1
- package/dist/model/gridActions.d.ts +13 -0
- package/dist/model/gridActions.js +11 -0
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.js +128 -65
- package/dist/model/gridTypes.core.d.ts +172 -26
- package/dist/utils/gridVisibleBand.cjs +1 -0
- package/dist/utils/gridVisibleBand.d.ts +4 -0
- package/dist/utils/gridVisibleBand.js +24 -0
- package/dist/utils/scrollBottom.cjs +1 -0
- package/dist/utils/scrollBottom.d.ts +1 -0
- package/dist/utils/scrollBottom.js +4 -0
- package/dist/utils/topAlignedInput.cjs +1 -0
- package/dist/utils/topAlignedInput.d.ts +3 -0
- package/dist/utils/topAlignedInput.js +23 -0
- package/package.json +1 -1
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { isInsideDetailCardOf as e } from "../logic/detailRow.js";
|
|
2
2
|
import { isImeComposingKeyEvent as t } from "../logic/domGuards.js";
|
|
3
|
+
import { resolveElementScale as n } from "../logic/elementScale.js";
|
|
4
|
+
import { resolveGridVisibleBand as r } from "../utils/gridVisibleBand.js";
|
|
5
|
+
import { alignInputTextToTop as i } from "../utils/topAlignedInput.js";
|
|
3
6
|
//#region src/controllers/imeInputController.ts
|
|
4
|
-
var
|
|
7
|
+
var a = 24, o = "ssg-ime-input--composing", s = (t, n, r) => {
|
|
5
8
|
let i = t.querySelectorAll(`.ssg-body-row[data-row-index="${n.row}"]`);
|
|
6
9
|
for (let n of Array.from(i)) {
|
|
7
10
|
if (e(t, n)) continue;
|
|
@@ -9,93 +12,101 @@ var n = "ssg-ime-input--composing", r = (t, n, r) => {
|
|
|
9
12
|
for (let e of Array.from(i)) if (e.getAttribute("data-ssg-col-key") === r) return e;
|
|
10
13
|
}
|
|
11
14
|
return null;
|
|
12
|
-
},
|
|
13
|
-
let e = null,
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
let
|
|
17
|
-
if (!
|
|
18
|
-
let
|
|
19
|
-
if (!
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
}, c = (e, t) => e === t || e !== null && t !== null && e.row === t.row && e.col === t.col, l = () => {
|
|
16
|
+
let e = null, l = null, u = null, d = null, f = !1, p = null, m = !1, h = !1, g = !1, _ = null, v = () => e?.gridRootRef.current ?? null, y = () => {
|
|
17
|
+
l && l.ownerDocument.activeElement !== l && l.focus({ preventScroll: !0 });
|
|
18
|
+
}, b = (t, o) => {
|
|
19
|
+
let c = v(), u = e?.resolveCell(t) ?? null;
|
|
20
|
+
if (!l || !c || !u) return !1;
|
|
21
|
+
let d = s(c, t, u.colKey);
|
|
22
|
+
if (!d) return !1;
|
|
23
|
+
let f = c.getBoundingClientRect(), p = d.getBoundingClientRect(), m = n(c, f), h = p.top, g = p.bottom;
|
|
24
|
+
if (o) {
|
|
25
|
+
let e = r(d);
|
|
26
|
+
if (e !== null) {
|
|
27
|
+
let t = Math.max(h, e.top), n = Math.min(g, e.bottom);
|
|
28
|
+
n - t >= a * m.y && (h = t, g = n);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
let _ = (g - h) / m.y;
|
|
32
|
+
return l.style.left = `${(p.left - f.left) / m.x - c.clientLeft}px`, l.style.top = `${(h - f.top) / m.y - c.clientTop}px`, l.style.width = `${p.width / m.x}px`, l.style.height = `${_}px`, l.style.textAlign = o && u.align ? u.align : "", i(l, o && d.classList.contains("ssg-body-cell--valign-top"), _), !0;
|
|
33
|
+
}, x = () => {
|
|
34
|
+
l && (l.classList.remove(o), l.value = "", l.style.textAlign = "", i(l, !1, 0));
|
|
35
|
+
}, S = (t) => {
|
|
36
|
+
e === null || !e.enabled || e.editing || h || t.target === u && y();
|
|
37
|
+
}, C = () => {
|
|
27
38
|
if (e === null || !e.enabled || e.editing || e.activeCell === null) {
|
|
28
|
-
|
|
39
|
+
p = null;
|
|
29
40
|
return;
|
|
30
41
|
}
|
|
31
|
-
let t = e.activeCell,
|
|
32
|
-
|
|
42
|
+
let t = e.activeCell, n = e.canStartEdit(t);
|
|
43
|
+
p = {
|
|
33
44
|
cell: t,
|
|
34
|
-
allowed:
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
let n =
|
|
38
|
-
|
|
39
|
-
let r =
|
|
40
|
-
if (
|
|
41
|
-
|
|
45
|
+
allowed: n
|
|
46
|
+
}, g = !1, n && (l?.classList.add(o), b(t, !0), _ = t);
|
|
47
|
+
}, w = (t) => {
|
|
48
|
+
let n = p;
|
|
49
|
+
p = null;
|
|
50
|
+
let r = g;
|
|
51
|
+
if (g = !1, !l || n === null || !n.allowed || r) {
|
|
52
|
+
x();
|
|
42
53
|
return;
|
|
43
54
|
}
|
|
44
|
-
let i =
|
|
55
|
+
let i = l.value || t.data || "";
|
|
45
56
|
queueMicrotask(() => {
|
|
46
|
-
let t =
|
|
57
|
+
let t = l;
|
|
47
58
|
if (e === null || !e.enabled || !t || i === "" || t.ownerDocument.activeElement !== t || !e.canStartEdit(n.cell)) {
|
|
48
|
-
|
|
59
|
+
x();
|
|
49
60
|
return;
|
|
50
61
|
}
|
|
51
62
|
let r = e.resolveEditText ? e.resolveEditText(n.cell, i) : i;
|
|
52
63
|
if (r === null || r === "") {
|
|
53
|
-
|
|
64
|
+
x();
|
|
54
65
|
return;
|
|
55
66
|
}
|
|
56
|
-
|
|
57
|
-
|
|
67
|
+
m = !0, e.startEdit(n.cell, r), requestAnimationFrame(() => {
|
|
68
|
+
m && e !== null && !e.editing && (m = !1, x());
|
|
58
69
|
});
|
|
59
70
|
});
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
if (e.target !==
|
|
64
|
-
let n =
|
|
71
|
+
}, T = () => {
|
|
72
|
+
p === null && !m && l && (l.value = "");
|
|
73
|
+
}, E = (e) => {
|
|
74
|
+
if (e.target !== l || e.key !== "Tab" || e.defaultPrevented || t(e) || document.activeElement !== l) return;
|
|
75
|
+
let n = v();
|
|
65
76
|
if (n) {
|
|
66
|
-
|
|
77
|
+
h = !0;
|
|
67
78
|
try {
|
|
68
79
|
n.focus({ preventScroll: !0 });
|
|
69
80
|
} finally {
|
|
70
|
-
|
|
81
|
+
h = !1;
|
|
71
82
|
}
|
|
72
83
|
}
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
typeof document > "u" ||
|
|
79
|
-
},
|
|
80
|
-
|
|
84
|
+
}, D = () => {
|
|
85
|
+
p !== null && (g = !0);
|
|
86
|
+
}, O = (e) => {
|
|
87
|
+
u !== e && (u?.removeEventListener("focus", S), u = e, u?.addEventListener("focus", S));
|
|
88
|
+
}, k = (e) => {
|
|
89
|
+
typeof document > "u" || f === e || (f = e, e ? (document.addEventListener("keydown", E), document.addEventListener("pointerdown", D, !0)) : (document.removeEventListener("keydown", E), document.removeEventListener("pointerdown", D, !0)));
|
|
90
|
+
}, A = (e) => {
|
|
91
|
+
d !== e && (d && (d.removeEventListener("compositionstart", C), d.removeEventListener("compositionend", w), d.removeEventListener("input", T)), d = e, d && (d.addEventListener("compositionstart", C), d.addEventListener("compositionend", w), d.addEventListener("input", T)));
|
|
81
92
|
};
|
|
82
93
|
return {
|
|
83
94
|
update: (t) => {
|
|
84
95
|
e = t;
|
|
85
96
|
let n = t.gridRootRef.current;
|
|
86
|
-
if (
|
|
87
|
-
|
|
97
|
+
if (O(t.enabled ? n : null), A(t.enabled ? l : null), k(t.enabled), !t.enabled) {
|
|
98
|
+
p = null, m = !1, x(), l && n && l.ownerDocument.activeElement === l && n.focus({ preventScroll: !0 });
|
|
88
99
|
return;
|
|
89
100
|
}
|
|
90
|
-
|
|
101
|
+
m && t.editing && (m = !1, x()), !(p !== null || m) && (t.activeCell !== null && !c(_, t.activeCell) && b(t.activeCell, !1) && (_ = t.activeCell), !t.editing && n && n.ownerDocument.activeElement === n && y());
|
|
91
102
|
},
|
|
92
103
|
attach: (t) => {
|
|
93
|
-
|
|
104
|
+
l !== t && (l = t, A(e?.enabled ? l : null), l && (typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches && (l.inputMode = "none"), _ = null));
|
|
94
105
|
},
|
|
95
106
|
dispose: () => {
|
|
96
|
-
|
|
107
|
+
A(null), O(null), k(!1), p = null, m = !1, e = null;
|
|
97
108
|
}
|
|
98
109
|
};
|
|
99
110
|
};
|
|
100
111
|
//#endregion
|
|
101
|
-
export {
|
|
112
|
+
export { o as IME_INPUT_COMPOSING_CLASS, l as createImeInputController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/detailRow.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=>n.resolveFirstDataColIndex(e),u=(e,t)=>({row:c(e),col:l(t)}),d=()=>{let n=null,d=e=>{n=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=(t,r,i)=>{if(n===null)return;let{uiState:a,dispatch:o}=n;if(i){let n=a.selection?.type===`cell`?a.selection.range.start:t;o(e.gridActions.startSelection(n)),o(e.gridActions.updateSelection(r)),o(e.gridActions.endSelection()),o(e.gridActions.activateCell(r));return}o(e.gridActions.startSelection(r)),o(e.gridActions.endSelection()),o(e.gridActions.activateCell(r))},h=()=>{if(n===null||n.uiState.activeCell)return!1;let{rowModel:e,visibleColumns:t}=n;if(e.getRowCount()===0||t.length===0)return!0;let r=u(e,t);return m(r,r,!1),!0},g=e=>{let t=n?.uiState;return e&&t?.selection?.type===`cell`?t.selection.range.end:t?.activeCell??{row:0,col:0}},_=(e,t,i)=>{if(n===null)return;let{rowModel:a,visibleColumns:o}=n,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+t,0,o.length-1)};m(l,d,i)},v=(e,t)=>{if(n===null)return;let{uiState:i,rowModel:a,visibleColumns:o}=n;if(a.getRowCount()===0||o.length===0)return;let s=i.activeCell?g(t):{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)},t&&i.activeCell!==null)},y=(e,t,i)=>{let a=t.getRowCount(),c=n?.resolvePageRow?n.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(t,l,i,-1);return u>=0?u:s(t,l,i>0?-1:1,e.row)};return{update:d,handleKeyDown:async r=>{if(n===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}=n;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(e.gridActions.clearSelection()),g(e.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&&n.openContextMenu?.(o.activeCell)){r.preventDefault();return}if(r.key===`ArrowDown`&&r.altKey&&!M&&!r.shiftKey&&o.activeCell&&n.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(n.rowModel.getRowCount()===0||n.visibleColumns.length===0)return;r.preventDefault(),h();return}let e=o.activeCell?.col??0;if(r.shiftKey?e<=l(n.visibleColumns):e>=n.visibleColumns.length-1){!r.shiftKey&&o.activeCell&&n.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(e.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 n=s.getRow(o.activeCell.row),i=u[o.activeCell.col];if(!n||!i||!t.isViewCellEditable({readOnly:d,canEditCell:f},s,o.activeCell.row,o.activeCell.col,n,i))return;if(i.editor?.type===`checkbox`){r.preventDefault(),r.key===` `&&k(o.activeCell);return}r.preventDefault(),m(r.key),g(e.gridActions.startEdit(o.activeCell))}}}};exports.createKeyboardController=d,exports.resolveFirstDataCell=u;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { gridActions as e } from "../model/gridActions.js";
|
|
2
|
+
import { isViewCellEditable as t } from "../utils/permissions.js";
|
|
3
|
+
import { resolveFirstDataColIndex as n } from "../logic/detailRow.js";
|
|
4
4
|
import { clamp as r } from "../logic/geometry.js";
|
|
5
5
|
import { isImeInputTarget as i, isPrintableKey as a, shouldIgnoreGridKeydown as o } from "../logic/domGuards.js";
|
|
6
6
|
import { isClearableSelection as s } from "./escapeClaimController.js";
|
|
@@ -10,68 +10,68 @@ var c = 10, l = (e, t, n, r) => {
|
|
|
10
10
|
let i = e.getRowCount(), a = t;
|
|
11
11
|
for (; a >= 0 && a < i && e.getLabelRow(a);) a += n;
|
|
12
12
|
return a >= 0 && a < i ? a : r;
|
|
13
|
-
}, u = (e) => l(e, 0, 1, 0), d = (e) =>
|
|
13
|
+
}, u = (e) => l(e, 0, 1, 0), d = (e) => n(e), f = (e, t) => ({
|
|
14
14
|
row: u(e),
|
|
15
15
|
col: d(t)
|
|
16
16
|
}), p = () => {
|
|
17
|
-
let
|
|
18
|
-
|
|
17
|
+
let n = null, p = (e) => {
|
|
18
|
+
n = e;
|
|
19
19
|
}, m = (e, t) => l(e, t, -1, l(e, t, 1, t)), h = (e) => {
|
|
20
20
|
let t = e.getRowCount() - 1;
|
|
21
21
|
return l(e, t, -1, t);
|
|
22
|
-
}, g = (
|
|
23
|
-
if (
|
|
24
|
-
let { uiState: a, dispatch: o } =
|
|
22
|
+
}, g = (t, r, i) => {
|
|
23
|
+
if (n === null) return;
|
|
24
|
+
let { uiState: a, dispatch: o } = n;
|
|
25
25
|
if (i) {
|
|
26
|
-
let
|
|
27
|
-
o(
|
|
26
|
+
let n = a.selection?.type === "cell" ? a.selection.range.start : t;
|
|
27
|
+
o(e.startSelection(n)), o(e.updateSelection(r)), o(e.endSelection()), o(e.activateCell(r));
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
o(
|
|
30
|
+
o(e.startSelection(r)), o(e.endSelection()), o(e.activateCell(r));
|
|
31
31
|
}, _ = () => {
|
|
32
|
-
if (
|
|
33
|
-
let { rowModel: e, visibleColumns:
|
|
34
|
-
if (e.getRowCount() === 0 ||
|
|
35
|
-
let r = f(e,
|
|
32
|
+
if (n === null || n.uiState.activeCell) return !1;
|
|
33
|
+
let { rowModel: e, visibleColumns: t } = n;
|
|
34
|
+
if (e.getRowCount() === 0 || t.length === 0) return !0;
|
|
35
|
+
let r = f(e, t);
|
|
36
36
|
return g(r, r, !1), !0;
|
|
37
37
|
}, v = (e) => {
|
|
38
|
-
let
|
|
39
|
-
return e &&
|
|
38
|
+
let t = n?.uiState;
|
|
39
|
+
return e && t?.selection?.type === "cell" ? t.selection.range.end : t?.activeCell ?? {
|
|
40
40
|
row: 0,
|
|
41
41
|
col: 0
|
|
42
42
|
};
|
|
43
|
-
}, y = (e,
|
|
44
|
-
if (
|
|
45
|
-
let { rowModel: a, visibleColumns: o } =
|
|
43
|
+
}, y = (e, t, i) => {
|
|
44
|
+
if (n === null) return;
|
|
45
|
+
let { rowModel: a, visibleColumns: o } = n, s = a.getRowCount();
|
|
46
46
|
if (s === 0 || o.length === 0 || _()) return;
|
|
47
47
|
let c = v(i), u = r(c.row + e, 0, s - 1);
|
|
48
48
|
u = e === 0 ? m(a, u) : l(a, u, e > 0 ? 1 : -1, c.row);
|
|
49
49
|
let d = {
|
|
50
50
|
row: u,
|
|
51
|
-
col: r(c.col +
|
|
51
|
+
col: r(c.col + t, 0, o.length - 1)
|
|
52
52
|
};
|
|
53
53
|
g(c, d, i);
|
|
54
|
-
}, b = (e,
|
|
55
|
-
if (
|
|
56
|
-
let { uiState: i, rowModel: a, visibleColumns: o } =
|
|
54
|
+
}, b = (e, t) => {
|
|
55
|
+
if (n === null) return;
|
|
56
|
+
let { uiState: i, rowModel: a, visibleColumns: o } = n;
|
|
57
57
|
if (a.getRowCount() === 0 || o.length === 0) return;
|
|
58
|
-
let s = i.activeCell ? v(
|
|
58
|
+
let s = i.activeCell ? v(t) : {
|
|
59
59
|
row: u(a),
|
|
60
60
|
col: d(o)
|
|
61
61
|
}, c = e(s, a, o);
|
|
62
62
|
g(s, {
|
|
63
63
|
row: m(a, r(c.row, 0, a.getRowCount() - 1)),
|
|
64
64
|
col: r(c.col, 0, o.length - 1)
|
|
65
|
-
},
|
|
66
|
-
}, x = (e,
|
|
67
|
-
let a =
|
|
68
|
-
return u >= 0 ? u : l(
|
|
65
|
+
}, t && i.activeCell !== null);
|
|
66
|
+
}, x = (e, t, i) => {
|
|
67
|
+
let a = t.getRowCount(), o = n?.resolvePageRow ? n.resolvePageRow(e.row, i) : e.row + i * c, s = r(i > 0 ? Math.max(o, e.row + 1) : Math.min(o, e.row - 1), 0, a - 1), u = l(t, s, i, -1);
|
|
68
|
+
return u >= 0 ? u : l(t, s, i > 0 ? -1 : 1, e.row);
|
|
69
69
|
};
|
|
70
70
|
return {
|
|
71
71
|
update: p,
|
|
72
72
|
handleKeyDown: async (r) => {
|
|
73
|
-
if (
|
|
74
|
-
let { uiState: c, rowModel: l, visibleColumns: f, readOnly: p, canEditCell: m, setEditorInitialValue: g, dispatch: v, handleCopy: S, openFind: C, handleCellDoubleClick: w, isWholeGridSelected: T, selectEntireGrid: E, onUndo: D, onRedo: O, onClearSelection: k, enableClearOnDelete: A, onToggleCheckboxCell: j, onToggleGroup: M, onToggleDetailRow: N } =
|
|
73
|
+
if (n === null) return;
|
|
74
|
+
let { uiState: c, rowModel: l, visibleColumns: f, readOnly: p, canEditCell: m, setEditorInitialValue: g, dispatch: v, handleCopy: S, openFind: C, handleCellDoubleClick: w, isWholeGridSelected: T, selectEntireGrid: E, onUndo: D, onRedo: O, onClearSelection: k, enableClearOnDelete: A, onToggleCheckboxCell: j, onToggleGroup: M, onToggleDetailRow: N } = n;
|
|
75
75
|
if (o(r.target) || c.editingCell || r.isComposing && i(r.target)) return;
|
|
76
76
|
if ((r.ctrlKey || r.metaKey) && r.key.toLowerCase() === "c") {
|
|
77
77
|
r.preventDefault(), await S();
|
|
@@ -83,7 +83,7 @@ var c = 10, l = (e, t, n, r) => {
|
|
|
83
83
|
}
|
|
84
84
|
if ((r.ctrlKey || r.metaKey) && r.key.toLowerCase() === "a") {
|
|
85
85
|
if (r.preventDefault(), T) {
|
|
86
|
-
v(
|
|
86
|
+
v(e.clearSelection()), v(e.activateCell(null));
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
89
|
E();
|
|
@@ -100,11 +100,11 @@ var c = 10, l = (e, t, n, r) => {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
let P = r.ctrlKey || r.metaKey;
|
|
103
|
-
if ((r.key === "ContextMenu" || r.key === "F10" && r.shiftKey) && !P && !r.altKey && c.activeCell &&
|
|
103
|
+
if ((r.key === "ContextMenu" || r.key === "F10" && r.shiftKey) && !P && !r.altKey && c.activeCell && n.openContextMenu?.(c.activeCell)) {
|
|
104
104
|
r.preventDefault();
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
|
-
if (r.key === "ArrowDown" && r.altKey && !P && !r.shiftKey && c.activeCell &&
|
|
107
|
+
if (r.key === "ArrowDown" && r.altKey && !P && !r.shiftKey && c.activeCell && n.openColumnMenu?.(c.activeCell.col)) {
|
|
108
108
|
r.preventDefault();
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
@@ -162,20 +162,20 @@ var c = 10, l = (e, t, n, r) => {
|
|
|
162
162
|
}
|
|
163
163
|
if (r.key === "Tab") {
|
|
164
164
|
if (!c.activeCell && !r.shiftKey) {
|
|
165
|
-
if (
|
|
165
|
+
if (n.rowModel.getRowCount() === 0 || n.visibleColumns.length === 0) return;
|
|
166
166
|
r.preventDefault(), _();
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
169
169
|
let e = c.activeCell?.col ?? 0;
|
|
170
|
-
if (r.shiftKey ? e <= d(
|
|
171
|
-
!r.shiftKey && c.activeCell &&
|
|
170
|
+
if (r.shiftKey ? e <= d(n.visibleColumns) : e >= n.visibleColumns.length - 1) {
|
|
171
|
+
!r.shiftKey && c.activeCell && n.onTabPastLastColumn?.(c.activeCell.row) && r.preventDefault();
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
174
|
r.preventDefault(), y(0, r.shiftKey ? -1 : 1, !1);
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
177
177
|
if (r.key === "Escape") {
|
|
178
|
-
s(c.selection) && r.preventDefault(), v(
|
|
178
|
+
s(c.selection) && r.preventDefault(), v(e.clearSelection());
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
181
181
|
if ((r.key === "Delete" || r.key === "Backspace") && A) {
|
|
@@ -202,16 +202,16 @@ var c = 10, l = (e, t, n, r) => {
|
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
204
|
if (r.key === " " && !r.ctrlKey && !r.metaKey && !r.altKey && r.preventDefault(), a(r) && c.activeCell) {
|
|
205
|
-
let
|
|
206
|
-
if (!
|
|
205
|
+
let n = l.getRow(c.activeCell.row), i = f[c.activeCell.col];
|
|
206
|
+
if (!n || !i || !t({
|
|
207
207
|
readOnly: p,
|
|
208
208
|
canEditCell: m
|
|
209
|
-
}, l, c.activeCell.row, c.activeCell.col,
|
|
209
|
+
}, l, c.activeCell.row, c.activeCell.col, n, i)) return;
|
|
210
210
|
if (i.editor?.type === "checkbox") {
|
|
211
211
|
r.preventDefault(), r.key === " " && j(c.activeCell);
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
|
-
r.preventDefault(), g(r.key), v(
|
|
214
|
+
r.preventDefault(), g(r.key), v(e.startEdit(c.activeCell));
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../logic/sorting.cjs"),n=require("../logic/detailRow.cjs"),r=require("../logic/geometry.cjs"),i=require("../logic/autoScrollGeometry.cjs"),a=require("../logic/elementScale.cjs"),o=require("../logic/verticalGeometry.cjs");var s=10,c=300,l=()=>{let s=null,c=!1,l=!1,u=null,d=null,f=`mouse`,p=null,m=null,h=!1,g=!1,_=()=>s?.uiState.dragState??null,v=null,y=e=>{let t=s?.footerHeight??0,n=s?.stickyTopHeight??0,r=s?.scrollContainerRef.current??null;if(t<=0&&n<=0||!r)return e;let o=r.getBoundingClientRect(),c=a.resolveElementScale(r,o);return i.clampClientYBelowHeader(i.clampClientYAboveFooter(e,o.top+(r.clientTop+r.clientHeight)*c.y,t*c.y),o.top+r.clientTop*c.y,n*c.y)},b=(e,t)=>{if(s===null)return null;let{bodyScrollRef:n,scrollContainerRef:i,leftPaneScrollRef:c,rightPaneScrollRef:l,filteredRowsLength:u,visibleColumnsLength:d,paneLayout:f,leftLeadingWidth:p,centerLeadingWidth:m,rightLeadingWidth:h,headerHeight:g,rowMetrics:_,verticalScaleFactor:v}=s,b=n.current;if(!b||u===0||d===0)return null;let x=b.getBoundingClientRect(),S=a.resolveElementScale(b,x),C=o.clientYToRowIndex(b.scrollTop+(y(t)-x.top)/S.y-g,i.current?.scrollTop??0,v,_),w=null,T=c.current;if(w===null&&T&&f.left.entries.length>0){let t=T.getBoundingClientRect();if(e<t.right){let n=(e-t.left)/S.x-p;w=r.findLogicalIndexFromPaneOffset(f.left,n)}}let E=l.current;if(w===null&&E&&f.right.entries.length>0){let t=E.getBoundingClientRect();if(e>=t.left){let n=(e-t.left)/S.x-h;w=r.findLogicalIndexFromPaneOffset(f.right,n)}}if(w===null&&f.center.entries.length>0){let t=T&&f.left.entries.length===0?Math.max(e,T.getBoundingClientRect().left+p*S.x):e,n=b.scrollLeft+(t-x.left)/S.x-m;w=r.findLogicalIndexFromPaneOffset(f.center,Math.max(n,0))}return w===null?null:{row:C,col:r.clamp(w,0,d-1)}},x=(t,n)=>{let r=_();if(s===null||!r||r.type!==`selection`)return;let i=b(t,n);if(i){if(r.selectionKind===`cell`){s.dispatch(e.gridActions.updateSelection(i));return}if(r.selectionKind===`row`){s.dispatch(e.gridActions.updateRowSelection(i.row));return}r.selectionKind===`col`&&s.dispatch(e.gridActions.updateColumnSelection(i.col))}},S=(t,n)=>{let r=n.timeStamp;if(s===null)return;let{gridRootRef:i,dispatch:a,enableRangeSelection:o,enableRowSelection:c,onGutterRowSelect:l,onCellDoubleClickRef:u,resolveFirstDataCell:f}=s;i.current?.focus({preventScroll:!0});let{target:p}=t;if(p.kind===`cell`){let t=d;if(t&&t.cell.row===p.cell.row&&t.cell.col===p.cell.col&&r-t.time<300){d=null,u.current(p.cell,n);return}d={cell:p.cell,time:r},a(e.gridActions.activateCell(p.cell)),o&&(a(e.gridActions.startSelection(p.cell)),a(e.gridActions.endSelection()));return}if(d=null,p.kind===`row`){if(c){l(p.rowIndex,{shiftKey:!1});return}a(e.gridActions.startRowSelection(p.rowIndex,f?.().col)),a(e.gridActions.endSelection());return}a(e.gridActions.startColumnSelection(p.colIndex,f?.().row)),a(e.gridActions.endSelection())},C=()=>{s!==null&&(l=!1,s.dispatch(e.gridActions.endSelection()),s.dispatch(e.gridActions.endColumnResize()))},w=t=>{if(s===null)return;s.pointerClientRef.current={x:t.clientX,y:t.clientY};let n=_();if(n?.type===`columnResize`){(v===null||v.drag!==n)&&(v={drag:n,x:a.resolveElementScale(s.scrollContainerRef.current).x});let r=v.x===1?t.clientX:n.startX+(t.clientX-n.startX)/v.x;s.dispatch(e.gridActions.updateColumnResize(r))}},T=e=>{let t=u;t&&(u=null,e.pointerId===t.pointerId&&Math.abs(e.clientX-t.x)<10&&Math.abs(e.clientY-t.y)<10&&S(t,e)),C()},E=()=>{u=null,C()},D=()=>{c||(c=!0,window.addEventListener(`pointermove`,w),window.addEventListener(`pointerup`,T),window.addEventListener(`pointercancel`,E))},O=()=>{c&&(c=!1,window.removeEventListener(`pointermove`,w),window.removeEventListener(`pointerup`,T),window.removeEventListener(`pointercancel`,E))},k=()=>{g=!1,s!==null&&s.autoScrollFrameRef.current!==null&&(cancelAnimationFrame(s.autoScrollFrameRef.current),s.autoScrollFrameRef.current=null)},A=()=>{if(s===null||!g)return;let{scrollContainerRef:e,pointerClientRef:t,autoScrollFrameRef:n}=s,r=e.current,o=t.current;if(!r||!o){n.current=requestAnimationFrame(A);return}if(!h){let e=m;if(e&&!i.hasPointerLeftActivationRadius(e,o,6)){n.current=requestAnimationFrame(A);return}h=!0}let c=r.getBoundingClientRect(),l=a.resolveElementScale(r,c),u=i.resolveScrollContentBox({rectLeft:c.left,rectTop:c.top,clientLeft:r.clientLeft,clientTop:r.clientTop,clientWidth:r.clientWidth,clientHeight:r.clientHeight,scale:l}),d=_(),f=d?.type===`selection`&&d.selectionKind===`col`,p=d?.type===`selection`&&d.selectionKind===`row`,v=f?0:i.resolveAutoScrollAxisDirection(o.y,i.resolveTopAutoScrollStart(u.top,(s.stickyTopHeight??0)*l.y,24),u.bottom-(s.footerHeight??0),24),y=p?0:i.resolveAutoScrollAxisDirection(o.x,u.left,u.right,24),b=i.computeNextScrollPosition(r.scrollTop,v,18,r.scrollHeight-r.clientHeight),S=i.computeNextScrollPosition(r.scrollLeft,y,18,r.scrollWidth-r.clientWidth);(b!==r.scrollTop||S!==r.scrollLeft)&&(r.scrollTo({top:b,left:S,behavior:`auto`}),x(o.x,o.y)),n.current=requestAnimationFrame(A)},j=()=>{let e=_()?.type===`selection`;e&&!g?(g=!0,s!==null&&(s.autoScrollFrameRef.current=requestAnimationFrame(A))):!e&&g&&k()},M=()=>{if(p!==null)return;let e=()=>{if(!l||s===null){p=null;return}let{scrollContainerRef:t,pointerClientRef:n,onGutterRowSelectDrag:r}=s,o=t.current,c=n.current;if(!o||!c){p=requestAnimationFrame(e);return}if(!h){let t=m;if(t&&!i.hasPointerLeftActivationRadius(t,c,6)){p=requestAnimationFrame(e);return}h=!0}let u=o.getBoundingClientRect(),d=a.resolveElementScale(o,u),f=i.resolveScrollContentBox({rectLeft:u.left,rectTop:u.top,clientLeft:o.clientLeft,clientTop:o.clientTop,clientWidth:o.clientWidth,clientHeight:o.clientHeight,scale:d}),g=i.resolveAutoScrollAxisDirection(c.y,i.resolveTopAutoScrollStart(f.top,(s.stickyTopHeight??0)*d.y,24),f.bottom-(s.footerHeight??0),24),_=i.computeNextScrollPosition(o.scrollTop,g,18,o.scrollHeight-o.clientHeight);if(_!==o.scrollTop){o.scrollTo({top:_,left:o.scrollLeft,behavior:`auto`});let e=b(c.x,c.y);e&&r(e.row)}p=requestAnimationFrame(e)};p=requestAnimationFrame(e)},N=(e,t)=>(e.preventDefault(),s===null||e.button!==0?!1:(f=e.pointerType,e.pointerType===`touch`?(u={pointerId:e.pointerId,x:e.clientX,y:e.clientY,target:t},!1):(s.gridRootRef.current?.focus({preventScroll:!0}),s.pointerClientRef.current={x:e.clientX,y:e.clientY},m={x:e.clientX,y:e.clientY},h=!1,!0)));return{update:e=>{s=e,D(),j()},getCellCoordFromClientPoint:b,updateSelectionFromPointer:x,handleCellPointerDown:(t,n)=>{if(!(!N(n,{kind:`cell`,cell:t})||s===null)){if(n.shiftKey&&s.enableRangeSelection){let{selection:n,activeCell:r}=s.uiState,i=n?.type===`cell`?n.range.start:r;if(i){s.dispatch(e.gridActions.startSelection(i)),s.dispatch(e.gridActions.updateSelection(t));return}}s.dispatch(e.gridActions.activateCell(t)),s.enableRangeSelection&&s.dispatch(e.gridActions.startSelection(t))}},handleCellDoubleClick:(e,t)=>{f===`touch`||s===null||s.onCellDoubleClickRef.current(e,t)},handleCellPointerEnter:(t,n)=>{if(s===null||(s.enableRowHover&&s.setHoveredRowIndex(t.row),s.enableColumnHover&&s.setHoveredColumnIndex(t.col),!s.enableRangeSelection))return;let r=_();r?.type!==`selection`||r.selectionKind!==`cell`||(s.pointerClientRef.current={x:n.clientX,y:n.clientY},s.dispatch(e.gridActions.updateSelection(t)))},handleNativeDragStart:e=>{e.preventDefault()},handleRowHeaderPointerDown:(t,n)=>{if(!(!N(n,{kind:`row`,rowIndex:t})||s===null)){if(s.enableRowSelection){l=!0,s.onGutterRowSelect(t,{shiftKey:n.shiftKey}),M();return}if(n.shiftKey){let{selection:n,activeCell:r}=s.uiState,i=n?.type===`row`?n.startRow:r?.row;if(i!==void 0){s.dispatch(e.gridActions.startRowSelection(i,s.resolveFirstDataCell?.().col)),s.dispatch(e.gridActions.updateRowSelection(t));return}}s.dispatch(e.gridActions.startRowSelection(t,s.resolveFirstDataCell?.().col))}},handleRowHeaderPointerEnter:(t,n)=>{if(s===null)return;if(s.enableRowHover&&s.setHoveredRowIndex(t),l){s.pointerClientRef.current={x:n.clientX,y:n.clientY},s.onGutterRowSelectDrag(t);return}let r=_();r?.type!==`selection`||r.selectionKind!==`row`||(s.pointerClientRef.current={x:n.clientX,y:n.clientY},s.dispatch(e.gridActions.updateRowSelection(t)))},handleColumnHeaderPointerDown:(r,i)=>{if(!(!N(i,{kind:`col`,colIndex:r})||s===null)){if(i.shiftKey&&s.enableSorting){let i=s.orderedColumns[r];if(i&&!n.isSyntheticColumnKey(i.key)){let n=s.uiState.sort,r=n.find(e=>e.columnKey===i.key)?.direction?`desc`:`asc`,a=t.nextSortEntries(n,i.key,r,!0);s.dispatch(a.length===0?e.gridActions.clearSort():e.gridActions.setSort(a))}return}s.dispatch(e.gridActions.startColumnSelection(r,s.resolveFirstDataCell?.().row))}},handleColumnHeaderPointerEnter:(t,n)=>{if(s===null)return;s.setHoveredRowIndex(null),s.enableColumnHeaderHover&&s.setHoveredColumnIndex(t);let r=_();r?.type!==`selection`||r.selectionKind!==`col`||(s.pointerClientRef.current={x:n.clientX,y:n.clientY},s.dispatch(e.gridActions.updateColumnSelection(t)))},dispose:()=>{O(),k(),p!==null&&(cancelAnimationFrame(p),p=null)}}};exports.TOUCH_DOUBLE_TAP_MS=c,exports.TOUCH_TAP_SLOP_PX=s,exports.createPointerInteractionsController=l;
|