@ishibashi0112/spreadsheet-grid-core 0.60.0 → 0.62.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/README.md +2 -2
- package/dist/controllers/changeHighlightController.cjs +1 -1
- package/dist/controllers/changeHighlightController.js +54 -49
- package/dist/controllers/clipboardController.cjs +2 -2
- package/dist/controllers/clipboardController.js +71 -76
- package/dist/controllers/columnHeaderDragController.cjs +1 -1
- package/dist/controllers/columnHeaderDragController.js +74 -70
- package/dist/controllers/columnMenuController.cjs +1 -1
- package/dist/controllers/columnMenuController.d.ts +2 -0
- package/dist/controllers/columnMenuController.js +72 -60
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.js +40 -32
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.js +90 -84
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.js +71 -71
- package/dist/controllers/imeInputController.cjs +1 -1
- package/dist/controllers/imeInputController.js +68 -65
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +3 -0
- package/dist/controllers/keyboardController.js +184 -91
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.js +11 -2
- package/dist/controllers/popoverSupport.cjs +1 -1
- package/dist/controllers/popoverSupport.d.ts +1 -0
- package/dist/controllers/popoverSupport.js +14 -2
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +2 -0
- package/dist/controllers/rowDragController.js +222 -138
- package/dist/controllers/rowEnterController.cjs +1 -1
- package/dist/controllers/rowEnterController.js +49 -47
- package/dist/controllers/saveStatusController.cjs +1 -1
- package/dist/controllers/saveStatusController.js +101 -48
- package/dist/controllers/serverSideRowModel.cjs +1 -1
- package/dist/controllers/serverSideRowModel.d.ts +1 -0
- package/dist/controllers/serverSideRowModel.js +199 -130
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.js +38 -21
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +2 -1
- package/dist/controllers/viewportSyncController.js +3 -2
- package/dist/engine/columnLayout.cjs +1 -1
- package/dist/engine/columnLayout.d.ts +1 -0
- package/dist/engine/columnLayout.js +12 -11
- package/dist/engine/exportCommands.cjs +1 -1
- package/dist/engine/exportCommands.js +27 -25
- package/dist/engine/filterPopoverCommands.cjs +1 -1
- package/dist/engine/filterPopoverCommands.js +12 -7
- package/dist/engine/gridApi.cjs +1 -1
- package/dist/engine/gridApi.d.ts +4 -1
- package/dist/engine/gridApi.js +175 -129
- package/dist/engine/notifiers.cjs +1 -1
- package/dist/engine/notifiers.d.ts +1 -0
- package/dist/engine/notifiers.js +10 -5
- package/dist/logic/conditionalFormat.cjs +1 -1
- package/dist/logic/conditionalFormat.js +2 -2
- package/dist/logic/detailRow.cjs +1 -1
- package/dist/logic/detailRow.d.ts +1 -0
- package/dist/logic/detailRow.js +9 -4
- package/dist/logic/domGuards.cjs +1 -1
- package/dist/logic/domGuards.d.ts +4 -0
- package/dist/logic/domGuards.js +2 -2
- package/dist/logic/editorValues.cjs +1 -1
- package/dist/logic/editorValues.d.ts +2 -0
- package/dist/logic/editorValues.js +19 -9
- package/dist/logic/fillSeries.cjs +1 -1
- package/dist/logic/fillSeries.js +43 -36
- package/dist/logic/filterSummary.cjs +1 -1
- package/dist/logic/filterSummary.d.ts +9 -3
- package/dist/logic/filterSummary.js +39 -13
- package/dist/logic/find.cjs +1 -1
- package/dist/logic/find.d.ts +1 -0
- package/dist/logic/find.js +6 -6
- package/dist/logic/gridAsk.cjs +1 -1
- package/dist/logic/gridAsk.js +106 -106
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +14 -0
- package/dist/logic/gridState.js +114 -62
- package/dist/logic/numberFilterCondition.cjs +1 -1
- package/dist/logic/numberFilterCondition.d.ts +1 -1
- package/dist/logic/numberFilterCondition.js +12 -9
- package/dist/logic/selectionAggregates.cjs +1 -1
- package/dist/logic/selectionAggregates.js +5 -2
- package/dist/logic/serverSideEdits.cjs +1 -1
- package/dist/logic/serverSideEdits.d.ts +16 -2
- package/dist/logic/serverSideEdits.js +60 -14
- package/dist/logic/urgentFilters.cjs +1 -0
- package/dist/logic/urgentFilters.d.ts +3 -0
- package/dist/logic/urgentFilters.js +6 -0
- package/dist/logic/validation.cjs +1 -1
- package/dist/logic/validation.d.ts +1 -1
- package/dist/logic/validation.js +10 -10
- package/dist/logic/valueFormatters.d.ts +2 -1
- package/dist/model/gridStore.cjs +1 -1
- package/dist/model/gridStore.d.ts +1 -0
- package/dist/model/gridStore.js +2 -1
- package/dist/model/gridTypes.core.d.ts +92 -16
- package/dist/utils/clipboard.cjs +5 -5
- package/dist/utils/clipboard.d.ts +3 -0
- package/dist/utils/clipboard.js +58 -65
- package/dist/utils/permissions.cjs +1 -1
- package/dist/utils/permissions.js +5 -3
- package/package.json +1 -6
|
@@ -1,98 +1,101 @@
|
|
|
1
|
+
import { isInsideDetailCardOf as e } from "../logic/detailRow.js";
|
|
2
|
+
import { isImeComposingKeyEvent as t } from "../logic/domGuards.js";
|
|
1
3
|
//#region src/controllers/imeInputController.ts
|
|
2
|
-
var
|
|
3
|
-
let
|
|
4
|
-
for (let
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
var n = "ssg-ime-input--composing", r = (t, n, r) => {
|
|
5
|
+
let i = t.querySelectorAll(`.ssg-body-row[data-row-index="${n.row}"]`);
|
|
6
|
+
for (let n of Array.from(i)) {
|
|
7
|
+
if (e(t, n)) continue;
|
|
8
|
+
let i = n.querySelectorAll(".ssg-body-cell");
|
|
9
|
+
for (let e of Array.from(i)) if (e.getAttribute("data-ssg-col-key") === r) return e;
|
|
7
10
|
}
|
|
8
11
|
return null;
|
|
9
|
-
},
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
let
|
|
14
|
-
if (!
|
|
15
|
-
let s =
|
|
12
|
+
}, i = (e, t) => e === t || e !== null && t !== null && e.row === t.row && e.col === t.col, a = () => {
|
|
13
|
+
let e = null, a = null, o = null, s = null, c = !1, l = null, u = !1, d = !1, f = !1, p = null, m = () => e?.gridRootRef.current ?? null, h = () => {
|
|
14
|
+
a && a.ownerDocument.activeElement !== a && a.focus({ preventScroll: !0 });
|
|
15
|
+
}, g = (t, n) => {
|
|
16
|
+
let i = m(), o = e?.resolveCell(t) ?? null;
|
|
17
|
+
if (!a || !i || !o) return !1;
|
|
18
|
+
let s = r(i, t, o.colKey);
|
|
16
19
|
if (!s) return !1;
|
|
17
|
-
let c =
|
|
18
|
-
return
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
if (
|
|
25
|
-
|
|
20
|
+
let c = i.getBoundingClientRect(), l = s.getBoundingClientRect();
|
|
21
|
+
return a.style.left = `${l.left - c.left - i.clientLeft}px`, a.style.top = `${l.top - c.top - i.clientTop}px`, a.style.width = `${l.width}px`, a.style.height = `${l.height}px`, a.style.textAlign = n && o.align ? o.align : "", !0;
|
|
22
|
+
}, _ = () => {
|
|
23
|
+
a && (a.classList.remove(n), a.value = "", a.style.textAlign = "");
|
|
24
|
+
}, v = (t) => {
|
|
25
|
+
e === null || !e.enabled || e.editing || d || t.target === o && h();
|
|
26
|
+
}, y = () => {
|
|
27
|
+
if (e === null || !e.enabled || e.editing || e.activeCell === null) {
|
|
28
|
+
l = null;
|
|
26
29
|
return;
|
|
27
30
|
}
|
|
28
|
-
let t =
|
|
29
|
-
|
|
31
|
+
let t = e.activeCell, r = e.canStartEdit(t);
|
|
32
|
+
l = {
|
|
30
33
|
cell: t,
|
|
31
|
-
allowed:
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
let
|
|
37
|
-
if (
|
|
38
|
-
|
|
34
|
+
allowed: r
|
|
35
|
+
}, f = !1, r && (g(t, !0), p = t, a?.classList.add(n));
|
|
36
|
+
}, b = (t) => {
|
|
37
|
+
let n = l;
|
|
38
|
+
l = null;
|
|
39
|
+
let r = f;
|
|
40
|
+
if (f = !1, !a || n === null || !n.allowed || r) {
|
|
41
|
+
_();
|
|
39
42
|
return;
|
|
40
43
|
}
|
|
41
|
-
let
|
|
44
|
+
let i = a.value || t.data || "";
|
|
42
45
|
queueMicrotask(() => {
|
|
43
|
-
let
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
+
let t = a;
|
|
47
|
+
if (e === null || !e.enabled || !t || i === "" || t.ownerDocument.activeElement !== t || !e.canStartEdit(n.cell)) {
|
|
48
|
+
_();
|
|
46
49
|
return;
|
|
47
50
|
}
|
|
48
|
-
let
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
+
let r = e.resolveEditText ? e.resolveEditText(n.cell, i) : i;
|
|
52
|
+
if (r === null || r === "") {
|
|
53
|
+
_();
|
|
51
54
|
return;
|
|
52
55
|
}
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
u = !0, e.startEdit(n.cell, r), requestAnimationFrame(() => {
|
|
57
|
+
u && e !== null && !e.editing && (u = !1, _());
|
|
55
58
|
});
|
|
56
59
|
});
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
if (e.target !==
|
|
61
|
-
let
|
|
62
|
-
if (
|
|
63
|
-
|
|
60
|
+
}, x = () => {
|
|
61
|
+
l === null && !u && a && (a.value = "");
|
|
62
|
+
}, S = (e) => {
|
|
63
|
+
if (e.target !== a || e.key !== "Tab" || e.defaultPrevented || t(e)) return;
|
|
64
|
+
let n = m();
|
|
65
|
+
if (n) {
|
|
66
|
+
d = !0;
|
|
64
67
|
try {
|
|
65
|
-
|
|
68
|
+
n.focus({ preventScroll: !0 });
|
|
66
69
|
} finally {
|
|
67
|
-
|
|
70
|
+
d = !1;
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
}, C = (e) => {
|
|
73
|
-
a !== e && (a?.removeEventListener("focus", _), a = e, a?.addEventListener("focus", _));
|
|
73
|
+
}, C = () => {
|
|
74
|
+
l !== null && (f = !0);
|
|
74
75
|
}, w = (e) => {
|
|
75
|
-
|
|
76
|
+
o !== e && (o?.removeEventListener("focus", v), o = e, o?.addEventListener("focus", v));
|
|
76
77
|
}, T = (e) => {
|
|
77
|
-
|
|
78
|
+
typeof document > "u" || c === e || (c = e, e ? (document.addEventListener("keydown", S), document.addEventListener("pointerdown", C, !0)) : (document.removeEventListener("keydown", S), document.removeEventListener("pointerdown", C, !0)));
|
|
79
|
+
}, E = (e) => {
|
|
80
|
+
s !== e && (s && (s.removeEventListener("compositionstart", y), s.removeEventListener("compositionend", b), s.removeEventListener("input", x)), s = e, s && (s.addEventListener("compositionstart", y), s.addEventListener("compositionend", b), s.addEventListener("input", x)));
|
|
78
81
|
};
|
|
79
82
|
return {
|
|
80
|
-
update: (
|
|
81
|
-
|
|
82
|
-
let
|
|
83
|
-
if (
|
|
84
|
-
|
|
83
|
+
update: (t) => {
|
|
84
|
+
e = t;
|
|
85
|
+
let n = t.gridRootRef.current;
|
|
86
|
+
if (w(t.enabled ? n : null), E(t.enabled ? a : null), T(t.enabled), !t.enabled) {
|
|
87
|
+
l = null, u = !1, _(), a && n && a.ownerDocument.activeElement === a && n.focus({ preventScroll: !0 });
|
|
85
88
|
return;
|
|
86
89
|
}
|
|
87
|
-
|
|
90
|
+
u && t.editing && (u = !1, _()), !(l !== null || u) && (t.activeCell !== null && !i(p, t.activeCell) && g(t.activeCell, !1) && (p = t.activeCell), !t.editing && n && n.ownerDocument.activeElement === n && h());
|
|
88
91
|
},
|
|
89
|
-
attach: (
|
|
90
|
-
|
|
92
|
+
attach: (t) => {
|
|
93
|
+
a !== t && (a = t, E(e?.enabled ? a : null), a && (typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches && (a.inputMode = "none"), p = null));
|
|
91
94
|
},
|
|
92
95
|
dispose: () => {
|
|
93
|
-
|
|
96
|
+
E(null), w(null), T(!1), l = null, u = !1, e = null;
|
|
94
97
|
}
|
|
95
98
|
};
|
|
96
99
|
};
|
|
97
100
|
//#endregion
|
|
98
|
-
export {
|
|
101
|
+
export { n as IME_INPUT_COMPOSING_CLASS, a as createImeInputController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../model/gridActions.cjs"),n=require("../logic/geometry.cjs"),r=require("../logic/domGuards.cjs");var i=()=>{let
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs");require("../logic/rowReorder.cjs"),require("../logic/detailRow.cjs");const t=require("../model/gridActions.cjs"),n=require("../logic/geometry.cjs"),r=require("../logic/domGuards.cjs");var i=e=>e===`__ssg_row_drag_handle__`||e===`__ssg_detail_toggle__`,a=10,o=()=>{let o=null,s=e=>{o=e},c=(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},l=(e,t)=>c(e,t,-1,c(e,t,1,t)),u=e=>c(e,0,1,0),d=e=>{let t=e.getRowCount()-1;return c(e,t,-1,t)},f=e=>{let t=e.findIndex(e=>!i(e.key));return t<0?0:t},p=(e,n,r)=>{if(o===null)return;let{uiState:i,dispatch:a}=o;if(r){let r=i.selection?.type===`cell`?i.selection.range.start:e;a(t.gridActions.startSelection(r)),a(t.gridActions.updateSelection(n)),a(t.gridActions.endSelection()),a(t.gridActions.activateCell(n));return}a(t.gridActions.startSelection(n)),a(t.gridActions.endSelection()),a(t.gridActions.activateCell(n))},m=()=>{if(o===null||o.uiState.activeCell)return!1;let{rowModel:e,visibleColumns:t}=o;if(e.getRowCount()===0||t.length===0)return!0;let n={row:u(e),col:f(t)};return p(n,n,!1),!0},h=e=>{let t=o?.uiState;return e&&t?.selection?.type===`cell`?t.selection.range.end:t?.activeCell??{row:0,col:0}},g=(e,t,r)=>{if(o===null)return;let{rowModel:i,visibleColumns:a}=o,s=i.getRowCount();if(s===0||a.length===0||m())return;let u=h(r),d=n.clamp(u.row+e,0,s-1);d=e===0?l(i,d):c(i,d,e>0?1:-1,u.row);let f={row:d,col:n.clamp(u.col+t,0,a.length-1)};p(u,f,r)},_=(e,t)=>{if(o===null)return;let{uiState:r,rowModel:i,visibleColumns:a}=o;if(i.getRowCount()===0||a.length===0)return;let s=r.activeCell?h(t):{row:u(i),col:f(a)},c=e(s,i,a);p(s,{row:l(i,n.clamp(c.row,0,i.getRowCount()-1)),col:n.clamp(c.col,0,a.length-1)},t&&r.activeCell!==null)},v=(e,t,r)=>{let i=t.getRowCount(),s=o?.resolvePageRow?o.resolvePageRow(e.row,r):e.row+r*a,l=n.clamp(r>0?Math.max(s,e.row+1):Math.min(s,e.row-1),0,i-1),u=c(t,l,r,-1);return u>=0?u:c(t,l,r>0?-1:1,e.row)};return{update:s,handleKeyDown:async n=>{if(o===null)return;let{uiState:i,rowModel:a,visibleColumns:s,readOnly:c,canEditCell:l,setEditorInitialValue:p,dispatch:h,handleCopy:y,openFind:b,handleCellDoubleClick:x,isWholeGridSelected:S,selectEntireGrid:C,onUndo:w,onRedo:T,onClearSelection:E,enableClearOnDelete:D,onToggleCheckboxCell:O,onToggleGroup:k,onToggleDetailRow:A}=o;if(r.shouldIgnoreGridKeydown(n.target)||i.editingCell||n.isComposing&&r.isImeInputTarget(n.target))return;if((n.ctrlKey||n.metaKey)&&n.key.toLowerCase()===`c`){n.preventDefault(),await y();return}if((n.ctrlKey||n.metaKey)&&n.key.toLowerCase()===`f`&&b){n.preventDefault(),b();return}if((n.ctrlKey||n.metaKey)&&n.key.toLowerCase()===`a`){if(n.preventDefault(),S){h(t.gridActions.clearSelection()),h(t.gridActions.activateCell(null));return}C();return}if((n.ctrlKey||n.metaKey)&&!n.isComposing){if(n.key.toLowerCase()===`z`){n.preventDefault(),n.shiftKey?T():w();return}if(n.key.toLowerCase()===`y`&&!n.shiftKey){n.preventDefault(),T();return}}let j=n.ctrlKey||n.metaKey;if(n.key===`ArrowDown`&&n.altKey&&!j&&!n.shiftKey&&i.activeCell&&o.openColumnMenu?.(i.activeCell.col)){n.preventDefault();return}if(j&&!n.altKey&&(n.key===`ArrowUp`||n.key===`ArrowDown`)){n.preventDefault();let e=n.key===`ArrowDown`;_((t,n)=>({row:e?d(n):u(n),col:t.col}),n.shiftKey);return}if(j&&!n.altKey&&(n.key===`ArrowLeft`||n.key===`ArrowRight`)){n.preventDefault();let e=n.key===`ArrowRight`;_((t,n,r)=>({row:t.row,col:e?r.length-1:f(r)}),n.shiftKey);return}if((n.key===`Home`||n.key===`End`)&&!n.altKey){n.preventDefault();let e=n.key===`End`;_((t,n,r)=>({row:j?e?d(n):u(n):t.row,col:e?r.length-1:f(r)}),n.shiftKey);return}if((n.key===`PageDown`||n.key===`PageUp`)&&!j&&!n.altKey){if(n.preventDefault(),m())return;let e=n.key===`PageDown`?1:-1;_((t,n)=>({row:v(t,n,e),col:t.col}),n.shiftKey);return}if(n.key===`ArrowUp`){n.preventDefault(),g(-1,0,n.shiftKey);return}if(n.key===`ArrowDown`){n.preventDefault(),g(1,0,n.shiftKey);return}if(n.key===`ArrowLeft`){n.preventDefault(),g(0,-1,n.shiftKey);return}if(n.key===`ArrowRight`){n.preventDefault(),g(0,1,n.shiftKey);return}if(n.key===`Tab`){if(!i.activeCell&&!n.shiftKey){if(o.rowModel.getRowCount()===0||o.visibleColumns.length===0)return;n.preventDefault(),m();return}let e=i.activeCell?.col??0;if(n.shiftKey?e<=0:e>=o.visibleColumns.length-1)return;n.preventDefault(),g(0,n.shiftKey?-1:1,!1);return}if(n.key===`Escape`){n.preventDefault(),h(t.gridActions.clearSelection());return}if((n.key===`Delete`||n.key===`Backspace`)&&D){n.preventDefault(),E();return}if((n.key===`Enter`||n.key===` `)&&i.activeCell){let e=a.getGroupRow?.(i.activeCell.row);if(e){n.preventDefault(),k(e.groupKey);return}if(A&&s[i.activeCell.col]?.key===`__ssg_detail_toggle__`&&A(i.activeCell)){n.preventDefault();return}}if(n.key===`Enter`||n.key===`F2`){if(n.preventDefault(),i.activeCell){x(i.activeCell);return}n.key===`Enter`&&m();return}if(r.isPrintableKey(n)&&i.activeCell){let r=a.getRow(i.activeCell.row),o=s[i.activeCell.col];if(!r||!o||!e.isViewCellEditable({readOnly:c,canEditCell:l},a,i.activeCell.row,i.activeCell.col,r,o))return;if(o.editor?.type===`checkbox`){n.preventDefault(),n.key===` `&&O(i.activeCell);return}n.preventDefault(),p(n.key),h(t.gridActions.startEdit(i.activeCell))}}}};exports.createKeyboardController=o;
|
|
@@ -29,6 +29,9 @@ export type KeyboardControllerArgs<T> = {
|
|
|
29
29
|
enableClearOnDelete: boolean;
|
|
30
30
|
onToggleCheckboxCell: (cell: CellCoord) => void;
|
|
31
31
|
onToggleGroup: (groupKey: string) => void;
|
|
32
|
+
onToggleDetailRow?: (cell: CellCoord) => boolean;
|
|
33
|
+
resolvePageRow?: (fromRow: number, direction: 1 | -1) => number;
|
|
34
|
+
openColumnMenu?: (col: number) => boolean;
|
|
32
35
|
};
|
|
33
36
|
export type KeyboardController<T> = {
|
|
34
37
|
update: (args: KeyboardControllerArgs<T>) => void;
|
|
@@ -1,123 +1,216 @@
|
|
|
1
1
|
import { isViewCellEditable as e } from "../utils/permissions.js";
|
|
2
|
+
import "../logic/rowReorder.js";
|
|
3
|
+
import "../logic/detailRow.js";
|
|
2
4
|
import { gridActions as t } from "../model/gridActions.js";
|
|
3
5
|
import { clamp as n } from "../logic/geometry.js";
|
|
4
6
|
import { isImeInputTarget as r, isPrintableKey as i, shouldIgnoreGridKeydown as a } from "../logic/domGuards.js";
|
|
5
7
|
//#region src/controllers/keyboardController.ts
|
|
6
|
-
var o = () => {
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
if (
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
var o = (e) => e === "__ssg_row_drag_handle__" || e === "__ssg_detail_toggle__", s = 10, c = () => {
|
|
9
|
+
let c = null, l = (e) => {
|
|
10
|
+
c = e;
|
|
11
|
+
}, u = (e, t, n, r) => {
|
|
12
|
+
if (!e.getLabelRow) return t;
|
|
13
|
+
let i = e.getRowCount(), a = t;
|
|
14
|
+
for (; a >= 0 && a < i && e.getLabelRow(a);) a += n;
|
|
15
|
+
return a >= 0 && a < i ? a : r;
|
|
16
|
+
}, d = (e, t) => u(e, t, -1, u(e, t, 1, t)), f = (e) => u(e, 0, 1, 0), p = (e) => {
|
|
17
|
+
let t = e.getRowCount() - 1;
|
|
18
|
+
return u(e, t, -1, t);
|
|
19
|
+
}, m = (e) => {
|
|
20
|
+
let t = e.findIndex((e) => !o(e.key));
|
|
21
|
+
return t < 0 ? 0 : t;
|
|
22
|
+
}, h = (e, n, r) => {
|
|
23
|
+
if (c === null) return;
|
|
24
|
+
let { uiState: i, dispatch: a } = c;
|
|
25
|
+
if (r) {
|
|
26
|
+
let r = i.selection?.type === "cell" ? i.selection.range.start : e;
|
|
27
|
+
a(t.startSelection(r)), a(t.updateSelection(n)), a(t.endSelection()), a(t.activateCell(n));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
a(t.startSelection(n)), a(t.endSelection()), a(t.activateCell(n));
|
|
31
|
+
}, g = () => {
|
|
32
|
+
if (c === null || c.uiState.activeCell) return !1;
|
|
33
|
+
let { rowModel: e, visibleColumns: t } = c;
|
|
34
|
+
if (e.getRowCount() === 0 || t.length === 0) return !0;
|
|
35
|
+
let n = {
|
|
36
|
+
row: f(e),
|
|
37
|
+
col: m(t)
|
|
38
|
+
};
|
|
39
|
+
return h(n, n, !1), !0;
|
|
40
|
+
}, _ = (e) => {
|
|
41
|
+
let t = c?.uiState;
|
|
42
|
+
return e && t?.selection?.type === "cell" ? t.selection.range.end : t?.activeCell ?? {
|
|
14
43
|
row: 0,
|
|
15
44
|
col: 0
|
|
16
|
-
}, f = n(d.row + e, 0, u - 1);
|
|
17
|
-
if (e !== 0 && s.getLabelRow) {
|
|
18
|
-
let t = e > 0 ? 1 : -1, n = f;
|
|
19
|
-
for (; n >= 0 && n < u && s.getLabelRow(n);) n += t;
|
|
20
|
-
f = n >= 0 && n < u ? n : d.row;
|
|
21
|
-
}
|
|
22
|
-
let p = {
|
|
23
|
-
row: f,
|
|
24
|
-
col: n(d.col + r, 0, c.length - 1)
|
|
25
45
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
l(
|
|
46
|
+
}, v = (e, t, r) => {
|
|
47
|
+
if (c === null) return;
|
|
48
|
+
let { rowModel: i, visibleColumns: a } = c, o = i.getRowCount();
|
|
49
|
+
if (o === 0 || a.length === 0 || g()) return;
|
|
50
|
+
let s = _(r), l = n(s.row + e, 0, o - 1);
|
|
51
|
+
l = e === 0 ? d(i, l) : u(i, l, e > 0 ? 1 : -1, s.row);
|
|
52
|
+
let f = {
|
|
53
|
+
row: l,
|
|
54
|
+
col: n(s.col + t, 0, a.length - 1)
|
|
55
|
+
};
|
|
56
|
+
h(s, f, r);
|
|
57
|
+
}, y = (e, t) => {
|
|
58
|
+
if (c === null) return;
|
|
59
|
+
let { uiState: r, rowModel: i, visibleColumns: a } = c;
|
|
60
|
+
if (i.getRowCount() === 0 || a.length === 0) return;
|
|
61
|
+
let o = r.activeCell ? _(t) : {
|
|
62
|
+
row: f(i),
|
|
63
|
+
col: m(a)
|
|
64
|
+
}, s = e(o, i, a);
|
|
65
|
+
h(o, {
|
|
66
|
+
row: d(i, n(s.row, 0, i.getRowCount() - 1)),
|
|
67
|
+
col: n(s.col, 0, a.length - 1)
|
|
68
|
+
}, t && r.activeCell !== null);
|
|
69
|
+
}, b = (e, t, r) => {
|
|
70
|
+
let i = t.getRowCount(), a = c?.resolvePageRow ? c.resolvePageRow(e.row, r) : e.row + r * s, o = n(r > 0 ? Math.max(a, e.row + 1) : Math.min(a, e.row - 1), 0, i - 1), l = u(t, o, r, -1);
|
|
71
|
+
return l >= 0 ? l : u(t, o, r > 0 ? -1 : 1, e.row);
|
|
32
72
|
};
|
|
33
73
|
return {
|
|
34
|
-
update:
|
|
74
|
+
update: l,
|
|
35
75
|
handleKeyDown: async (n) => {
|
|
36
|
-
if (
|
|
37
|
-
let { uiState:
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
y();
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if ((n.ctrlKey || n.metaKey) && !n.isComposing) {
|
|
56
|
-
if (n.key.toLowerCase() === "z") {
|
|
57
|
-
n.preventDefault(), n.shiftKey ? x() : b();
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (n.key.toLowerCase() === "y" && !n.shiftKey) {
|
|
61
|
-
n.preventDefault(), x();
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (n.key === "ArrowUp") {
|
|
66
|
-
n.preventDefault(), c(-1, 0, n.shiftKey);
|
|
76
|
+
if (c === null) return;
|
|
77
|
+
let { uiState: o, rowModel: s, visibleColumns: l, readOnly: u, canEditCell: d, setEditorInitialValue: h, dispatch: _, handleCopy: x, openFind: S, handleCellDoubleClick: C, isWholeGridSelected: w, selectEntireGrid: T, onUndo: E, onRedo: D, onClearSelection: O, enableClearOnDelete: k, onToggleCheckboxCell: A, onToggleGroup: j, onToggleDetailRow: M } = c;
|
|
78
|
+
if (a(n.target) || o.editingCell || n.isComposing && r(n.target)) return;
|
|
79
|
+
if ((n.ctrlKey || n.metaKey) && n.key.toLowerCase() === "c") {
|
|
80
|
+
n.preventDefault(), await x();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if ((n.ctrlKey || n.metaKey) && n.key.toLowerCase() === "f" && S) {
|
|
84
|
+
n.preventDefault(), S();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if ((n.ctrlKey || n.metaKey) && n.key.toLowerCase() === "a") {
|
|
88
|
+
if (n.preventDefault(), w) {
|
|
89
|
+
_(t.clearSelection()), _(t.activateCell(null));
|
|
67
90
|
return;
|
|
68
91
|
}
|
|
69
|
-
|
|
70
|
-
|
|
92
|
+
T();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if ((n.ctrlKey || n.metaKey) && !n.isComposing) {
|
|
96
|
+
if (n.key.toLowerCase() === "z") {
|
|
97
|
+
n.preventDefault(), n.shiftKey ? D() : E();
|
|
71
98
|
return;
|
|
72
99
|
}
|
|
73
|
-
if (n.key === "
|
|
74
|
-
n.preventDefault(),
|
|
100
|
+
if (n.key.toLowerCase() === "y" && !n.shiftKey) {
|
|
101
|
+
n.preventDefault(), D();
|
|
75
102
|
return;
|
|
76
103
|
}
|
|
77
|
-
|
|
78
|
-
|
|
104
|
+
}
|
|
105
|
+
let N = n.ctrlKey || n.metaKey;
|
|
106
|
+
if (n.key === "ArrowDown" && n.altKey && !N && !n.shiftKey && o.activeCell && c.openColumnMenu?.(o.activeCell.col)) {
|
|
107
|
+
n.preventDefault();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (N && !n.altKey && (n.key === "ArrowUp" || n.key === "ArrowDown")) {
|
|
111
|
+
n.preventDefault();
|
|
112
|
+
let e = n.key === "ArrowDown";
|
|
113
|
+
y((t, n) => ({
|
|
114
|
+
row: e ? p(n) : f(n),
|
|
115
|
+
col: t.col
|
|
116
|
+
}), n.shiftKey);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (N && !n.altKey && (n.key === "ArrowLeft" || n.key === "ArrowRight")) {
|
|
120
|
+
n.preventDefault();
|
|
121
|
+
let e = n.key === "ArrowRight";
|
|
122
|
+
y((t, n, r) => ({
|
|
123
|
+
row: t.row,
|
|
124
|
+
col: e ? r.length - 1 : m(r)
|
|
125
|
+
}), n.shiftKey);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if ((n.key === "Home" || n.key === "End") && !n.altKey) {
|
|
129
|
+
n.preventDefault();
|
|
130
|
+
let e = n.key === "End";
|
|
131
|
+
y((t, n, r) => ({
|
|
132
|
+
row: N ? e ? p(n) : f(n) : t.row,
|
|
133
|
+
col: e ? r.length - 1 : m(r)
|
|
134
|
+
}), n.shiftKey);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if ((n.key === "PageDown" || n.key === "PageUp") && !N && !n.altKey) {
|
|
138
|
+
if (n.preventDefault(), g()) return;
|
|
139
|
+
let e = n.key === "PageDown" ? 1 : -1;
|
|
140
|
+
y((t, n) => ({
|
|
141
|
+
row: b(t, n, e),
|
|
142
|
+
col: t.col
|
|
143
|
+
}), n.shiftKey);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (n.key === "ArrowUp") {
|
|
147
|
+
n.preventDefault(), v(-1, 0, n.shiftKey);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (n.key === "ArrowDown") {
|
|
151
|
+
n.preventDefault(), v(1, 0, n.shiftKey);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (n.key === "ArrowLeft") {
|
|
155
|
+
n.preventDefault(), v(0, -1, n.shiftKey);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (n.key === "ArrowRight") {
|
|
159
|
+
n.preventDefault(), v(0, 1, n.shiftKey);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (n.key === "Tab") {
|
|
163
|
+
if (!o.activeCell && !n.shiftKey) {
|
|
164
|
+
if (c.rowModel.getRowCount() === 0 || c.visibleColumns.length === 0) return;
|
|
165
|
+
n.preventDefault(), g();
|
|
79
166
|
return;
|
|
80
167
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
168
|
+
let e = o.activeCell?.col ?? 0;
|
|
169
|
+
if (n.shiftKey ? e <= 0 : e >= c.visibleColumns.length - 1) return;
|
|
170
|
+
n.preventDefault(), v(0, n.shiftKey ? -1 : 1, !1);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (n.key === "Escape") {
|
|
174
|
+
n.preventDefault(), _(t.clearSelection());
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if ((n.key === "Delete" || n.key === "Backspace") && k) {
|
|
178
|
+
n.preventDefault(), O();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if ((n.key === "Enter" || n.key === " ") && o.activeCell) {
|
|
182
|
+
let e = s.getGroupRow?.(o.activeCell.row);
|
|
183
|
+
if (e) {
|
|
184
|
+
n.preventDefault(), j(e.groupKey);
|
|
85
185
|
return;
|
|
86
186
|
}
|
|
87
|
-
if (
|
|
88
|
-
n.preventDefault()
|
|
187
|
+
if (M && l[o.activeCell.col]?.key === "__ssg_detail_toggle__" && M(o.activeCell)) {
|
|
188
|
+
n.preventDefault();
|
|
89
189
|
return;
|
|
90
190
|
}
|
|
91
|
-
|
|
92
|
-
|
|
191
|
+
}
|
|
192
|
+
if (n.key === "Enter" || n.key === "F2") {
|
|
193
|
+
if (n.preventDefault(), o.activeCell) {
|
|
194
|
+
C(o.activeCell);
|
|
93
195
|
return;
|
|
94
196
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
197
|
+
n.key === "Enter" && g();
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (i(n) && o.activeCell) {
|
|
201
|
+
let r = s.getRow(o.activeCell.row), i = l[o.activeCell.col];
|
|
202
|
+
if (!r || !i || !e({
|
|
203
|
+
readOnly: u,
|
|
204
|
+
canEditCell: d
|
|
205
|
+
}, s, o.activeCell.row, o.activeCell.col, r, i)) return;
|
|
206
|
+
if (i.editor?.type === "checkbox") {
|
|
207
|
+
n.preventDefault(), n.key === " " && A(o.activeCell);
|
|
104
208
|
return;
|
|
105
209
|
}
|
|
106
|
-
|
|
107
|
-
let r = l.getRow(s.activeCell.row), i = u[s.activeCell.col];
|
|
108
|
-
if (!r || !i || !e({
|
|
109
|
-
readOnly: d,
|
|
110
|
-
canEditCell: f
|
|
111
|
-
}, l, s.activeCell.row, s.activeCell.col, r, i)) return;
|
|
112
|
-
if (i.editor?.type === "checkbox") {
|
|
113
|
-
n.preventDefault(), n.key === " " && w(s.activeCell);
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
n.preventDefault(), p(n.key), m(t.startEdit(s.activeCell));
|
|
117
|
-
}
|
|
210
|
+
n.preventDefault(), h(n.key), _(t.startEdit(o.activeCell));
|
|
118
211
|
}
|
|
119
212
|
}
|
|
120
213
|
};
|
|
121
214
|
};
|
|
122
215
|
//#endregion
|
|
123
|
-
export {
|
|
216
|
+
export { c as createKeyboardController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/sorting.cjs"),t=require("../logic/detailRow.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/geometry.cjs"),i=require("../logic/autoScrollGeometry.cjs"),a=require("../logic/verticalGeometry.cjs");var o=10,s=300,c=()=>{let o=null,s=!1,c=!1,l=null,u=null,d=`mouse`,f=null,p=null,m=!1,h=!1,g=()=>o?.uiState.dragState??null,_=e=>{let t=o?.footerHeight??0,n=o?.scrollContainerRef.current??null;return t<=0||!n?e:i.clampClientYAboveFooter(e,n.getBoundingClientRect().top+n.clientTop+n.clientHeight,t)},v=(e,t)=>{if(o===null)return null;let{bodyScrollRef:n,scrollContainerRef:i,leftPaneScrollRef:s,rightPaneScrollRef:c,filteredRowsLength:l,visibleColumnsLength:u,paneLayout:d,leftLeadingWidth:f,centerLeadingWidth:p,rightLeadingWidth:m,headerHeight:h,rowMetrics:g,verticalScaleFactor:v}=o,y=n.current;if(!y||l===0||u===0)return null;let b=y.getBoundingClientRect(),x=a.clientYToRowIndex(y.scrollTop+_(t)-b.top-h,i.current?.scrollTop??0,v,g),S=null,C=s.current;if(S===null&&C&&d.left.entries.length>0){let t=C.getBoundingClientRect();if(e<t.right){let n=e-t.left-f;S=r.findLogicalIndexFromPaneOffset(d.left,n)}}let w=c.current;if(S===null&&w&&d.right.entries.length>0){let t=w.getBoundingClientRect();if(e>=t.left){let n=e-t.left-m;S=r.findLogicalIndexFromPaneOffset(d.right,n)}}if(S===null&&d.center.entries.length>0){let t=y.scrollLeft+e-b.left-p;S=r.findLogicalIndexFromPaneOffset(d.center,Math.max(t,0))}return S===null?null:{row:x,col:r.clamp(S,0,u-1)}},y=(e,t)=>{let r=g();if(o===null||!r||r.type!==`selection`)return;let i=v(e,t);if(i){if(r.selectionKind===`cell`){o.dispatch(n.gridActions.updateSelection(i));return}if(r.selectionKind===`row`){o.dispatch(n.gridActions.updateRowSelection(i.row));return}r.selectionKind===`col`&&o.dispatch(n.gridActions.updateColumnSelection(i.col))}},b=(e,t)=>{let r=t.timeStamp;if(o===null)return;let{gridRootRef:i,dispatch:a,enableRangeSelection:s,enableRowSelection:c,onGutterRowSelect:l,onCellDoubleClickRef:d}=o;i.current?.focus({preventScroll:!0});let{target:f}=e;if(f.kind===`cell`){let e=u;if(e&&e.cell.row===f.cell.row&&e.cell.col===f.cell.col&&r-e.time<300){u=null,d.current(f.cell,t);return}u={cell:f.cell,time:r},a(n.gridActions.activateCell(f.cell)),s&&(a(n.gridActions.startSelection(f.cell)),a(n.gridActions.endSelection()));return}if(u=null,f.kind===`row`){if(c){l(f.rowIndex,{shiftKey:!1});return}a(n.gridActions.startRowSelection(f.rowIndex)),a(n.gridActions.endSelection());return}a(n.gridActions.startColumnSelection(f.colIndex)),a(n.gridActions.endSelection())},x=()=>{o!==null&&(c=!1,o.dispatch(n.gridActions.endSelection()),o.dispatch(n.gridActions.endColumnResize()))},S=e=>{o!==null&&(o.pointerClientRef.current={x:e.clientX,y:e.clientY},g()?.type===`columnResize`&&o.dispatch(n.gridActions.updateColumnResize(e.clientX)))},C=e=>{let t=l;t&&(l=null,e.pointerId===t.pointerId&&Math.abs(e.clientX-t.x)<10&&Math.abs(e.clientY-t.y)<10&&b(t,e)),x()},w=()=>{l=null,x()},T=()=>{s||(s=!0,window.addEventListener(`pointermove`,S),window.addEventListener(`pointerup`,C),window.addEventListener(`pointercancel`,w))},E=()=>{s&&(s=!1,window.removeEventListener(`pointermove`,S),window.removeEventListener(`pointerup`,C),window.removeEventListener(`pointercancel`,w))},D=()=>{h=!1,o!==null&&o.autoScrollFrameRef.current!==null&&(cancelAnimationFrame(o.autoScrollFrameRef.current),o.autoScrollFrameRef.current=null)},O=()=>{if(o===null||!h)return;let{scrollContainerRef:e,pointerClientRef:t,autoScrollFrameRef:n}=o,r=e.current,a=t.current;if(!r||!a){n.current=requestAnimationFrame(O);return}if(!m){let e=p;if(e&&!i.hasPointerLeftActivationRadius(e,a,6)){n.current=requestAnimationFrame(O);return}m=!0}let s=r.getBoundingClientRect(),c=i.resolveScrollContentBox({rectLeft:s.left,rectTop:s.top,clientLeft:r.clientLeft,clientTop:r.clientTop,clientWidth:r.clientWidth,clientHeight:r.clientHeight}),l=g(),u=l?.type===`selection`&&l.selectionKind===`col`,d=l?.type===`selection`&&l.selectionKind===`row`,f=u?0:i.resolveAutoScrollAxisDirection(a.y,c.top,c.bottom-(o.footerHeight??0),24),_=d?0:i.resolveAutoScrollAxisDirection(a.x,c.left,c.right,24),v=i.computeNextScrollPosition(r.scrollTop,f,18,r.scrollHeight-r.clientHeight),b=i.computeNextScrollPosition(r.scrollLeft,_,18,r.scrollWidth-r.clientWidth);(v!==r.scrollTop||b!==r.scrollLeft)&&(r.scrollTo({top:v,left:b,behavior:`auto`}),y(a.x,a.y)),n.current=requestAnimationFrame(O)},k=()=>{let e=g()?.type===`selection`;e&&!h?(h=!0,o!==null&&(o.autoScrollFrameRef.current=requestAnimationFrame(O))):!e&&h&&D()},A=()=>{if(f!==null)return;let e=()=>{if(!c||o===null){f=null;return}let{scrollContainerRef:t,pointerClientRef:n,onGutterRowSelectDrag:r}=o,a=t.current,s=n.current;if(!a||!s){f=requestAnimationFrame(e);return}if(!m){let t=p;if(t&&!i.hasPointerLeftActivationRadius(t,s,6)){f=requestAnimationFrame(e);return}m=!0}let l=a.getBoundingClientRect(),u=i.resolveScrollContentBox({rectLeft:l.left,rectTop:l.top,clientLeft:a.clientLeft,clientTop:a.clientTop,clientWidth:a.clientWidth,clientHeight:a.clientHeight}),d=i.resolveAutoScrollAxisDirection(s.y,u.top,u.bottom-(o.footerHeight??0),24),h=i.computeNextScrollPosition(a.scrollTop,d,18,a.scrollHeight-a.clientHeight);if(h!==a.scrollTop){a.scrollTo({top:h,left:a.scrollLeft,behavior:`auto`});let e=v(s.x,s.y);e&&r(e.row)}f=requestAnimationFrame(e)};f=requestAnimationFrame(e)},j=(e,t)=>(e.preventDefault(),o===null||e.button!==0?!1:(d=e.pointerType,e.pointerType===`touch`?(l={pointerId:e.pointerId,x:e.clientX,y:e.clientY,target:t},!1):(o.gridRootRef.current?.focus({preventScroll:!0}),o.pointerClientRef.current={x:e.clientX,y:e.clientY},p={x:e.clientX,y:e.clientY},m=!1,!0)));return{update:e=>{o=e,T(),k()},getCellCoordFromClientPoint:v,updateSelectionFromPointer:y,handleCellPointerDown:(e,t)=>{!j(t,{kind:`cell`,cell:e})||o===null
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/sorting.cjs"),t=require("../logic/detailRow.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/geometry.cjs"),i=require("../logic/autoScrollGeometry.cjs"),a=require("../logic/verticalGeometry.cjs");var o=10,s=300,c=()=>{let o=null,s=!1,c=!1,l=null,u=null,d=`mouse`,f=null,p=null,m=!1,h=!1,g=()=>o?.uiState.dragState??null,_=e=>{let t=o?.footerHeight??0,n=o?.scrollContainerRef.current??null;return t<=0||!n?e:i.clampClientYAboveFooter(e,n.getBoundingClientRect().top+n.clientTop+n.clientHeight,t)},v=(e,t)=>{if(o===null)return null;let{bodyScrollRef:n,scrollContainerRef:i,leftPaneScrollRef:s,rightPaneScrollRef:c,filteredRowsLength:l,visibleColumnsLength:u,paneLayout:d,leftLeadingWidth:f,centerLeadingWidth:p,rightLeadingWidth:m,headerHeight:h,rowMetrics:g,verticalScaleFactor:v}=o,y=n.current;if(!y||l===0||u===0)return null;let b=y.getBoundingClientRect(),x=a.clientYToRowIndex(y.scrollTop+_(t)-b.top-h,i.current?.scrollTop??0,v,g),S=null,C=s.current;if(S===null&&C&&d.left.entries.length>0){let t=C.getBoundingClientRect();if(e<t.right){let n=e-t.left-f;S=r.findLogicalIndexFromPaneOffset(d.left,n)}}let w=c.current;if(S===null&&w&&d.right.entries.length>0){let t=w.getBoundingClientRect();if(e>=t.left){let n=e-t.left-m;S=r.findLogicalIndexFromPaneOffset(d.right,n)}}if(S===null&&d.center.entries.length>0){let t=y.scrollLeft+e-b.left-p;S=r.findLogicalIndexFromPaneOffset(d.center,Math.max(t,0))}return S===null?null:{row:x,col:r.clamp(S,0,u-1)}},y=(e,t)=>{let r=g();if(o===null||!r||r.type!==`selection`)return;let i=v(e,t);if(i){if(r.selectionKind===`cell`){o.dispatch(n.gridActions.updateSelection(i));return}if(r.selectionKind===`row`){o.dispatch(n.gridActions.updateRowSelection(i.row));return}r.selectionKind===`col`&&o.dispatch(n.gridActions.updateColumnSelection(i.col))}},b=(e,t)=>{let r=t.timeStamp;if(o===null)return;let{gridRootRef:i,dispatch:a,enableRangeSelection:s,enableRowSelection:c,onGutterRowSelect:l,onCellDoubleClickRef:d}=o;i.current?.focus({preventScroll:!0});let{target:f}=e;if(f.kind===`cell`){let e=u;if(e&&e.cell.row===f.cell.row&&e.cell.col===f.cell.col&&r-e.time<300){u=null,d.current(f.cell,t);return}u={cell:f.cell,time:r},a(n.gridActions.activateCell(f.cell)),s&&(a(n.gridActions.startSelection(f.cell)),a(n.gridActions.endSelection()));return}if(u=null,f.kind===`row`){if(c){l(f.rowIndex,{shiftKey:!1});return}a(n.gridActions.startRowSelection(f.rowIndex)),a(n.gridActions.endSelection());return}a(n.gridActions.startColumnSelection(f.colIndex)),a(n.gridActions.endSelection())},x=()=>{o!==null&&(c=!1,o.dispatch(n.gridActions.endSelection()),o.dispatch(n.gridActions.endColumnResize()))},S=e=>{o!==null&&(o.pointerClientRef.current={x:e.clientX,y:e.clientY},g()?.type===`columnResize`&&o.dispatch(n.gridActions.updateColumnResize(e.clientX)))},C=e=>{let t=l;t&&(l=null,e.pointerId===t.pointerId&&Math.abs(e.clientX-t.x)<10&&Math.abs(e.clientY-t.y)<10&&b(t,e)),x()},w=()=>{l=null,x()},T=()=>{s||(s=!0,window.addEventListener(`pointermove`,S),window.addEventListener(`pointerup`,C),window.addEventListener(`pointercancel`,w))},E=()=>{s&&(s=!1,window.removeEventListener(`pointermove`,S),window.removeEventListener(`pointerup`,C),window.removeEventListener(`pointercancel`,w))},D=()=>{h=!1,o!==null&&o.autoScrollFrameRef.current!==null&&(cancelAnimationFrame(o.autoScrollFrameRef.current),o.autoScrollFrameRef.current=null)},O=()=>{if(o===null||!h)return;let{scrollContainerRef:e,pointerClientRef:t,autoScrollFrameRef:n}=o,r=e.current,a=t.current;if(!r||!a){n.current=requestAnimationFrame(O);return}if(!m){let e=p;if(e&&!i.hasPointerLeftActivationRadius(e,a,6)){n.current=requestAnimationFrame(O);return}m=!0}let s=r.getBoundingClientRect(),c=i.resolveScrollContentBox({rectLeft:s.left,rectTop:s.top,clientLeft:r.clientLeft,clientTop:r.clientTop,clientWidth:r.clientWidth,clientHeight:r.clientHeight}),l=g(),u=l?.type===`selection`&&l.selectionKind===`col`,d=l?.type===`selection`&&l.selectionKind===`row`,f=u?0:i.resolveAutoScrollAxisDirection(a.y,c.top,c.bottom-(o.footerHeight??0),24),_=d?0:i.resolveAutoScrollAxisDirection(a.x,c.left,c.right,24),v=i.computeNextScrollPosition(r.scrollTop,f,18,r.scrollHeight-r.clientHeight),b=i.computeNextScrollPosition(r.scrollLeft,_,18,r.scrollWidth-r.clientWidth);(v!==r.scrollTop||b!==r.scrollLeft)&&(r.scrollTo({top:v,left:b,behavior:`auto`}),y(a.x,a.y)),n.current=requestAnimationFrame(O)},k=()=>{let e=g()?.type===`selection`;e&&!h?(h=!0,o!==null&&(o.autoScrollFrameRef.current=requestAnimationFrame(O))):!e&&h&&D()},A=()=>{if(f!==null)return;let e=()=>{if(!c||o===null){f=null;return}let{scrollContainerRef:t,pointerClientRef:n,onGutterRowSelectDrag:r}=o,a=t.current,s=n.current;if(!a||!s){f=requestAnimationFrame(e);return}if(!m){let t=p;if(t&&!i.hasPointerLeftActivationRadius(t,s,6)){f=requestAnimationFrame(e);return}m=!0}let l=a.getBoundingClientRect(),u=i.resolveScrollContentBox({rectLeft:l.left,rectTop:l.top,clientLeft:a.clientLeft,clientTop:a.clientTop,clientWidth:a.clientWidth,clientHeight:a.clientHeight}),d=i.resolveAutoScrollAxisDirection(s.y,u.top,u.bottom-(o.footerHeight??0),24),h=i.computeNextScrollPosition(a.scrollTop,d,18,a.scrollHeight-a.clientHeight);if(h!==a.scrollTop){a.scrollTo({top:h,left:a.scrollLeft,behavior:`auto`});let e=v(s.x,s.y);e&&r(e.row)}f=requestAnimationFrame(e)};f=requestAnimationFrame(e)},j=(e,t)=>(e.preventDefault(),o===null||e.button!==0?!1:(d=e.pointerType,e.pointerType===`touch`?(l={pointerId:e.pointerId,x:e.clientX,y:e.clientY,target:t},!1):(o.gridRootRef.current?.focus({preventScroll:!0}),o.pointerClientRef.current={x:e.clientX,y:e.clientY},p={x:e.clientX,y:e.clientY},m=!1,!0)));return{update:e=>{o=e,T(),k()},getCellCoordFromClientPoint:v,updateSelectionFromPointer:y,handleCellPointerDown:(e,t)=>{if(!(!j(t,{kind:`cell`,cell:e})||o===null)){if(t.shiftKey&&o.enableRangeSelection){let{selection:t,activeCell:r}=o.uiState,i=t?.type===`cell`?t.range.start:r;if(i){o.dispatch(n.gridActions.startSelection(i)),o.dispatch(n.gridActions.updateSelection(e));return}}o.dispatch(n.gridActions.activateCell(e)),o.enableRangeSelection&&o.dispatch(n.gridActions.startSelection(e))}},handleCellDoubleClick:(e,t)=>{d===`touch`||o===null||o.onCellDoubleClickRef.current(e,t)},handleCellPointerEnter:(e,t)=>{if(o===null||(o.enableRowHover&&o.setHoveredRowIndex(e.row),o.enableColumnHover&&o.setHoveredColumnIndex(e.col),!o.enableRangeSelection))return;let r=g();r?.type!==`selection`||r.selectionKind!==`cell`||(o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.dispatch(n.gridActions.updateSelection(e)))},handleNativeDragStart:e=>{e.preventDefault()},handleRowHeaderPointerDown:(e,t)=>{if(!(!j(t,{kind:`row`,rowIndex:e})||o===null)){if(o.enableRowSelection){c=!0,o.onGutterRowSelect(e,{shiftKey:t.shiftKey}),A();return}o.dispatch(n.gridActions.startRowSelection(e))}},handleRowHeaderPointerEnter:(e,t)=>{if(o===null)return;if(o.enableRowHover&&o.setHoveredRowIndex(e),c){o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.onGutterRowSelectDrag(e);return}let r=g();r?.type!==`selection`||r.selectionKind!==`row`||(o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.dispatch(n.gridActions.updateRowSelection(e)))},handleColumnHeaderPointerDown:(r,i)=>{if(!(!j(i,{kind:`col`,colIndex:r})||o===null)){if(i.shiftKey&&o.enableSorting){let i=o.orderedColumns[r];if(i&&!t.isSyntheticColumnKey(i.key)){let t=o.uiState.sort,r=t.find(e=>e.columnKey===i.key)?.direction?`desc`:`asc`,a=e.nextSortEntries(t,i.key,r,!0);o.dispatch(a.length===0?n.gridActions.clearSort():n.gridActions.setSort(a))}return}o.dispatch(n.gridActions.startColumnSelection(r))}},handleColumnHeaderPointerEnter:(e,t)=>{if(o===null)return;o.setHoveredRowIndex(null),o.enableColumnHeaderHover&&o.setHoveredColumnIndex(e);let r=g();r?.type!==`selection`||r.selectionKind!==`col`||(o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.dispatch(n.gridActions.updateColumnSelection(e)))},dispose:()=>{E(),D(),f!==null&&(cancelAnimationFrame(f),f=null)}}};exports.TOUCH_DOUBLE_TAP_MS=s,exports.TOUCH_TAP_SLOP_PX=o,exports.createPointerInteractionsController=c;
|
|
@@ -187,10 +187,19 @@ var d = 10, f = 300, p = () => {
|
|
|
187
187
|
getCellCoordFromClientPoint: C,
|
|
188
188
|
updateSelectionFromPointer: w,
|
|
189
189
|
handleCellPointerDown: (e, t) => {
|
|
190
|
-
!I(t, {
|
|
190
|
+
if (!(!I(t, {
|
|
191
191
|
kind: "cell",
|
|
192
192
|
cell: e
|
|
193
|
-
}) || d === null
|
|
193
|
+
}) || d === null)) {
|
|
194
|
+
if (t.shiftKey && d.enableRangeSelection) {
|
|
195
|
+
let { selection: t, activeCell: r } = d.uiState, i = t?.type === "cell" ? t.range.start : r;
|
|
196
|
+
if (i) {
|
|
197
|
+
d.dispatch(n.startSelection(i)), d.dispatch(n.updateSelection(e));
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
d.dispatch(n.activateCell(e)), d.enableRangeSelection && d.dispatch(n.startSelection(e));
|
|
202
|
+
}
|
|
194
203
|
},
|
|
195
204
|
handleCellDoubleClick: (e, t) => {
|
|
196
205
|
g === "touch" || d === null || d.onCellDoubleClickRef.current(e, t);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs");var t=e=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e?.blur()},n=t=>{requestAnimationFrame(()=>{e.isFocusInsideDetailCard()||t.current?.focus()})},r=(e,t)=>e.current?.contains(t)===!0,i=e=>{let t=!1,n=()=>e.onResize?.(),r=t=>e.onScroll?.(t),i=t=>{let n=t.target;n&&(e.isInside(n)||e.onOutsidePointerDown(n))},a=t=>e.onKeyDown?.(t);return{attach:()=>{t||(t=!0,window.addEventListener(`resize`,n),window.addEventListener(`scroll`,r,!0),window.addEventListener(`pointerdown`,i),window.addEventListener(`keydown`,a,!0))},detach:()=>{t&&(t=!1,window.removeEventListener(`resize`,n),window.removeEventListener(`scroll`,r,!0),window.removeEventListener(`pointerdown`,i),window.removeEventListener(`keydown`,a,!0))},isAttached:()=>t}};exports.blurForPopover=t,exports.createPopoverWindowBindings=i,exports.isInsideGridRoot=r,exports.restoreGridFocus=n;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs");var t=e=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e?.blur()},n=t=>{requestAnimationFrame(()=>{e.isFocusInsideDetailCard()||t.current?.focus()})},r=(e,t)=>e.current?.contains(t)===!0,i=(e,t,n=`[role="menuitem"]`)=>{let r=document.activeElement,i=r instanceof HTMLElement&&e.contains(r);if(i&&!r.matches(n))return!1;let a=t.key;if(a===`ArrowDown`||a===`ArrowUp`||a===`Home`||a===`End`){t.preventDefault();let o=Array.from(e.querySelectorAll(`${n}:not(:disabled):not([aria-disabled="true"])`));if(o.length===0)return!0;let s=i?o.indexOf(r):-1,c;return c=a===`Home`?0:a===`End`?o.length-1:a===`ArrowDown`?s<0?0:(s+1)%o.length:s<0?o.length-1:(s-1+o.length)%o.length,o[c]?.focus(),!0}return!i&&(a===`PageUp`||a===`PageDown`||a===` `||a===`ArrowLeft`||a===`ArrowRight`)?(t.preventDefault(),!0):!1},a=e=>{let t=!1,n=()=>e.onResize?.(),r=t=>e.onScroll?.(t),i=t=>{let n=t.target;n&&(e.isInside(n)||e.onOutsidePointerDown(n))},a=t=>e.onKeyDown?.(t);return{attach:()=>{t||(t=!0,window.addEventListener(`resize`,n),window.addEventListener(`scroll`,r,!0),window.addEventListener(`pointerdown`,i),window.addEventListener(`keydown`,a,!0))},detach:()=>{t&&(t=!1,window.removeEventListener(`resize`,n),window.removeEventListener(`scroll`,r,!0),window.removeEventListener(`pointerdown`,i),window.removeEventListener(`keydown`,a,!0))},isAttached:()=>t}};exports.blurForPopover=t,exports.createPopoverWindowBindings=a,exports.handleMenuKeyNavigation=i,exports.isInsideGridRoot=r,exports.restoreGridFocus=n;
|
|
@@ -4,6 +4,7 @@ export type ReadonlyElementRef<E extends HTMLElement = HTMLElement> = {
|
|
|
4
4
|
export declare const blurForPopover: (gridRoot: HTMLElement | null) => void;
|
|
5
5
|
export declare const restoreGridFocus: (gridRootRef: ReadonlyElementRef) => void;
|
|
6
6
|
export declare const isInsideGridRoot: (gridRootRef: ReadonlyElementRef, target: Node) => boolean;
|
|
7
|
+
export declare const handleMenuKeyNavigation: (panel: HTMLElement, event: KeyboardEvent, itemSelector?: string) => boolean;
|
|
7
8
|
export type PopoverWindowHandlers = {
|
|
8
9
|
onResize?: () => void;
|
|
9
10
|
onScroll?: (event: Event) => void;
|
|
@@ -6,7 +6,19 @@ var t = (e) => {
|
|
|
6
6
|
requestAnimationFrame(() => {
|
|
7
7
|
e() || t.current?.focus();
|
|
8
8
|
});
|
|
9
|
-
}, r = (e, t) => e.current?.contains(t) === !0, i = (e) => {
|
|
9
|
+
}, r = (e, t) => e.current?.contains(t) === !0, i = (e, t, n = "[role=\"menuitem\"]") => {
|
|
10
|
+
let r = document.activeElement, i = r instanceof HTMLElement && e.contains(r);
|
|
11
|
+
if (i && !r.matches(n)) return !1;
|
|
12
|
+
let a = t.key;
|
|
13
|
+
if (a === "ArrowDown" || a === "ArrowUp" || a === "Home" || a === "End") {
|
|
14
|
+
t.preventDefault();
|
|
15
|
+
let o = Array.from(e.querySelectorAll(`${n}:not(:disabled):not([aria-disabled="true"])`));
|
|
16
|
+
if (o.length === 0) return !0;
|
|
17
|
+
let s = i ? o.indexOf(r) : -1, c;
|
|
18
|
+
return c = a === "Home" ? 0 : a === "End" ? o.length - 1 : a === "ArrowDown" ? s < 0 ? 0 : (s + 1) % o.length : s < 0 ? o.length - 1 : (s - 1 + o.length) % o.length, o[c]?.focus(), !0;
|
|
19
|
+
}
|
|
20
|
+
return !i && (a === "PageUp" || a === "PageDown" || a === " " || a === "ArrowLeft" || a === "ArrowRight") ? (t.preventDefault(), !0) : !1;
|
|
21
|
+
}, a = (e) => {
|
|
10
22
|
let t = !1, n = () => e.onResize?.(), r = (t) => e.onScroll?.(t), i = (t) => {
|
|
11
23
|
let n = t.target;
|
|
12
24
|
n && (e.isInside(n) || e.onOutsidePointerDown(n));
|
|
@@ -22,4 +34,4 @@ var t = (e) => {
|
|
|
22
34
|
};
|
|
23
35
|
};
|
|
24
36
|
//#endregion
|
|
25
|
-
export { t as blurForPopover,
|
|
37
|
+
export { t as blurForPopover, a as createPopoverWindowBindings, i as handleMenuKeyNavigation, r as isInsideGridRoot, n as restoreGridFocus };
|