@ishibashi0112/spreadsheet-grid-core 0.65.0 → 1.0.1
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/clipboardController.cjs +2 -2
- package/dist/controllers/clipboardController.d.ts +2 -1
- package/dist/controllers/clipboardController.js +78 -62
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.d.ts +2 -0
- package/dist/controllers/columnAutosizeRunner.js +49 -23
- package/dist/controllers/columnHeaderDragController.cjs +1 -1
- package/dist/controllers/columnHeaderDragController.d.ts +4 -0
- package/dist/controllers/columnHeaderDragController.js +140 -124
- package/dist/controllers/dateRolloverStore.cjs +1 -1
- package/dist/controllers/dateRolloverStore.js +1 -1
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.js +71 -55
- package/dist/controllers/escapeClaimController.cjs +1 -0
- package/dist/controllers/escapeClaimController.d.ts +18 -0
- package/dist/controllers/escapeClaimController.js +30 -0
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.js +129 -127
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +1 -0
- package/dist/controllers/findController.js +96 -75
- package/dist/controllers/globalFilteredOrder.cjs +1 -1
- package/dist/controllers/globalFilteredOrder.js +52 -21
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.js +98 -97
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.js +159 -144
- package/dist/controllers/popoverSupport.cjs +1 -1
- package/dist/controllers/popoverSupport.js +4 -1
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +1 -0
- package/dist/controllers/rowDragController.js +122 -120
- package/dist/controllers/scrollSyncController.cjs +1 -1
- package/dist/controllers/scrollSyncController.d.ts +1 -1
- package/dist/controllers/scrollSyncController.js +7 -4
- package/dist/controllers/selectOptionsCollector.cjs +1 -1
- package/dist/controllers/selectOptionsCollector.d.ts +5 -2
- package/dist/controllers/selectOptionsCollector.js +39 -27
- package/dist/controllers/toolPanelController.cjs +1 -1
- package/dist/controllers/toolPanelController.d.ts +6 -0
- package/dist/controllers/toolPanelController.js +69 -59
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.d.ts +2 -0
- package/dist/controllers/tooltipController.js +68 -38
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +4 -0
- package/dist/controllers/viewportSyncController.js +18 -8
- package/dist/engine/columnCommands.cjs +1 -1
- package/dist/engine/columnCommands.js +2 -1
- package/dist/engine/columnLayout.cjs +1 -1
- package/dist/engine/columnLayout.d.ts +2 -0
- package/dist/engine/columnLayout.js +51 -18
- package/dist/engine/exportCommands.cjs +2 -2
- package/dist/engine/exportCommands.js +37 -38
- package/dist/engine/gridApi.cjs +2 -2
- package/dist/engine/gridApi.d.ts +1 -1
- package/dist/engine/gridApi.js +8 -8
- package/dist/engine/rowPipeline.cjs +1 -1
- package/dist/engine/rowPipeline.js +46 -46
- package/dist/engine/rowSelectionCommands.cjs +1 -1
- package/dist/engine/rowSelectionCommands.d.ts +8 -1
- package/dist/engine/rowSelectionCommands.js +36 -25
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +1 -1
- package/dist/logic/autoScrollGeometry.cjs +1 -1
- package/dist/logic/autoScrollGeometry.d.ts +5 -1
- package/dist/logic/autoScrollGeometry.js +6 -6
- package/dist/logic/clearCells.cjs +1 -1
- package/dist/logic/clearCells.js +13 -13
- package/dist/logic/columnReset.cjs +1 -1
- package/dist/logic/columnReset.d.ts +1 -0
- package/dist/logic/columnReset.js +21 -19
- package/dist/logic/editorValues.cjs +1 -1
- package/dist/logic/editorValues.js +41 -15
- package/dist/logic/elementScale.cjs +1 -0
- package/dist/logic/elementScale.d.ts +8 -0
- package/dist/logic/elementScale.js +14 -0
- package/dist/logic/filtering.cjs +1 -1
- package/dist/logic/filtering.js +14 -11
- package/dist/logic/focusCycle.cjs +1 -0
- package/dist/logic/focusCycle.d.ts +1 -0
- package/dist/logic/focusCycle.js +15 -0
- package/dist/logic/labelRows.cjs +1 -1
- package/dist/logic/labelRows.d.ts +2 -0
- package/dist/logic/labelRows.js +8 -4
- package/dist/logic/localeText.cjs +1 -1
- package/dist/logic/localeText.js +1 -1
- package/dist/logic/rowSelection.cjs +1 -1
- package/dist/logic/rowSelection.d.ts +4 -0
- package/dist/logic/rowSelection.js +31 -8
- package/dist/logic/selectOptions.cjs +1 -1
- package/dist/logic/selectOptions.d.ts +2 -2
- package/dist/logic/selectOptions.js +16 -12
- package/dist/logic/selectionOverlayGeometry.cjs +1 -1
- package/dist/logic/selectionOverlayGeometry.js +12 -12
- package/dist/logic/sorting.cjs +1 -1
- package/dist/logic/sorting.d.ts +1 -0
- package/dist/logic/sorting.js +24 -12
- package/dist/model/gridTypes.core.d.ts +48 -28
- package/dist/utils/deprecation.cjs +1 -1
- package/dist/utils/deprecation.d.ts +1 -30
- package/dist/utils/deprecation.js +1 -30
- package/package.json +1 -1
- package/dist/logic/exportScope.cjs +0 -1
- package/dist/logic/exportScope.d.ts +0 -3
- package/dist/logic/exportScope.js +0 -5
|
@@ -4,216 +4,217 @@ import "../logic/detailRow.js";
|
|
|
4
4
|
import { gridActions as t } from "../model/gridActions.js";
|
|
5
5
|
import { clamp as n } from "../logic/geometry.js";
|
|
6
6
|
import { isImeInputTarget as r, isPrintableKey as i, shouldIgnoreGridKeydown as a } from "../logic/domGuards.js";
|
|
7
|
+
import { isClearableSelection as o } from "./escapeClaimController.js";
|
|
7
8
|
//#region src/controllers/keyboardController.ts
|
|
8
|
-
var
|
|
9
|
+
var s = (e) => e === "__ssg_row_drag_handle__" || e === "__ssg_detail_toggle__", c = 10, l = (e, t, n, r) => {
|
|
9
10
|
if (!e.getLabelRow) return t;
|
|
10
11
|
let i = e.getRowCount(), a = t;
|
|
11
12
|
for (; a >= 0 && a < i && e.getLabelRow(a);) a += n;
|
|
12
13
|
return a >= 0 && a < i ? a : r;
|
|
13
|
-
},
|
|
14
|
-
let t = e.findIndex((e) => !
|
|
14
|
+
}, u = (e) => l(e, 0, 1, 0), d = (e) => {
|
|
15
|
+
let t = e.findIndex((e) => !s(e.key));
|
|
15
16
|
return t < 0 ? 0 : t;
|
|
16
|
-
},
|
|
17
|
-
row:
|
|
18
|
-
col:
|
|
19
|
-
}),
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
},
|
|
17
|
+
}, f = (e, t) => ({
|
|
18
|
+
row: u(e),
|
|
19
|
+
col: d(t)
|
|
20
|
+
}), p = () => {
|
|
21
|
+
let s = null, p = (e) => {
|
|
22
|
+
s = e;
|
|
23
|
+
}, m = (e, t) => l(e, t, -1, l(e, t, 1, t)), h = (e) => {
|
|
23
24
|
let t = e.getRowCount() - 1;
|
|
24
|
-
return
|
|
25
|
-
},
|
|
26
|
-
if (
|
|
27
|
-
let { uiState: i, dispatch: a } =
|
|
25
|
+
return l(e, t, -1, t);
|
|
26
|
+
}, g = (e, n, r) => {
|
|
27
|
+
if (s === null) return;
|
|
28
|
+
let { uiState: i, dispatch: a } = s;
|
|
28
29
|
if (r) {
|
|
29
30
|
let r = i.selection?.type === "cell" ? i.selection.range.start : e;
|
|
30
31
|
a(t.startSelection(r)), a(t.updateSelection(n)), a(t.endSelection()), a(t.activateCell(n));
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
33
34
|
a(t.startSelection(n)), a(t.endSelection()), a(t.activateCell(n));
|
|
34
|
-
},
|
|
35
|
-
if (
|
|
36
|
-
let { rowModel: e, visibleColumns: t } =
|
|
35
|
+
}, _ = () => {
|
|
36
|
+
if (s === null || s.uiState.activeCell) return !1;
|
|
37
|
+
let { rowModel: e, visibleColumns: t } = s;
|
|
37
38
|
if (e.getRowCount() === 0 || t.length === 0) return !0;
|
|
38
|
-
let n =
|
|
39
|
-
return
|
|
40
|
-
},
|
|
41
|
-
let t =
|
|
39
|
+
let n = f(e, t);
|
|
40
|
+
return g(n, n, !1), !0;
|
|
41
|
+
}, v = (e) => {
|
|
42
|
+
let t = s?.uiState;
|
|
42
43
|
return e && t?.selection?.type === "cell" ? t.selection.range.end : t?.activeCell ?? {
|
|
43
44
|
row: 0,
|
|
44
45
|
col: 0
|
|
45
46
|
};
|
|
46
|
-
},
|
|
47
|
-
if (
|
|
48
|
-
let { rowModel: i, visibleColumns: a } =
|
|
49
|
-
if (
|
|
50
|
-
let
|
|
51
|
-
u = e === 0 ?
|
|
47
|
+
}, y = (e, t, r) => {
|
|
48
|
+
if (s === null) return;
|
|
49
|
+
let { rowModel: i, visibleColumns: a } = s, o = i.getRowCount();
|
|
50
|
+
if (o === 0 || a.length === 0 || _()) return;
|
|
51
|
+
let c = v(r), u = n(c.row + e, 0, o - 1);
|
|
52
|
+
u = e === 0 ? m(i, u) : l(i, u, e > 0 ? 1 : -1, c.row);
|
|
52
53
|
let d = {
|
|
53
54
|
row: u,
|
|
54
|
-
col: n(
|
|
55
|
+
col: n(c.col + t, 0, a.length - 1)
|
|
55
56
|
};
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
if (
|
|
59
|
-
let { uiState: r, rowModel: i, visibleColumns: a } =
|
|
57
|
+
g(c, d, r);
|
|
58
|
+
}, b = (e, t) => {
|
|
59
|
+
if (s === null) return;
|
|
60
|
+
let { uiState: r, rowModel: i, visibleColumns: a } = s;
|
|
60
61
|
if (i.getRowCount() === 0 || a.length === 0) return;
|
|
61
|
-
let
|
|
62
|
-
row:
|
|
63
|
-
col:
|
|
64
|
-
}, c = e(
|
|
65
|
-
|
|
66
|
-
row:
|
|
62
|
+
let o = r.activeCell ? v(t) : {
|
|
63
|
+
row: u(i),
|
|
64
|
+
col: d(a)
|
|
65
|
+
}, c = e(o, i, a);
|
|
66
|
+
g(o, {
|
|
67
|
+
row: m(i, n(c.row, 0, i.getRowCount() - 1)),
|
|
67
68
|
col: n(c.col, 0, a.length - 1)
|
|
68
69
|
}, t && r.activeCell !== null);
|
|
69
|
-
},
|
|
70
|
-
let i = t.getRowCount(), a =
|
|
71
|
-
return u >= 0 ? u :
|
|
70
|
+
}, x = (e, t, r) => {
|
|
71
|
+
let i = t.getRowCount(), a = s?.resolvePageRow ? s.resolvePageRow(e.row, r) : e.row + r * c, o = n(r > 0 ? Math.max(a, e.row + 1) : Math.min(a, e.row - 1), 0, i - 1), u = l(t, o, r, -1);
|
|
72
|
+
return u >= 0 ? u : l(t, o, r > 0 ? -1 : 1, e.row);
|
|
72
73
|
};
|
|
73
74
|
return {
|
|
74
|
-
update:
|
|
75
|
+
update: p,
|
|
75
76
|
handleKeyDown: async (n) => {
|
|
76
|
-
if (
|
|
77
|
-
let { uiState:
|
|
78
|
-
if (a(n.target) ||
|
|
77
|
+
if (s === null) return;
|
|
78
|
+
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 } = s;
|
|
79
|
+
if (a(n.target) || c.editingCell || n.isComposing && r(n.target)) return;
|
|
79
80
|
if ((n.ctrlKey || n.metaKey) && n.key.toLowerCase() === "c") {
|
|
80
|
-
n.preventDefault(), await
|
|
81
|
+
n.preventDefault(), await S();
|
|
81
82
|
return;
|
|
82
83
|
}
|
|
83
|
-
if ((n.ctrlKey || n.metaKey) && n.key.toLowerCase() === "f" &&
|
|
84
|
-
n.preventDefault(),
|
|
84
|
+
if ((n.ctrlKey || n.metaKey) && n.key.toLowerCase() === "f" && C) {
|
|
85
|
+
n.preventDefault(), C();
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
87
88
|
if ((n.ctrlKey || n.metaKey) && n.key.toLowerCase() === "a") {
|
|
88
|
-
if (n.preventDefault(),
|
|
89
|
-
|
|
89
|
+
if (n.preventDefault(), T) {
|
|
90
|
+
v(t.clearSelection()), v(t.activateCell(null));
|
|
90
91
|
return;
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
+
E();
|
|
93
94
|
return;
|
|
94
95
|
}
|
|
95
96
|
if ((n.ctrlKey || n.metaKey) && !n.isComposing) {
|
|
96
97
|
if (n.key.toLowerCase() === "z") {
|
|
97
|
-
n.preventDefault(), n.shiftKey ?
|
|
98
|
+
n.preventDefault(), n.shiftKey ? O() : D();
|
|
98
99
|
return;
|
|
99
100
|
}
|
|
100
101
|
if (n.key.toLowerCase() === "y" && !n.shiftKey) {
|
|
101
|
-
n.preventDefault(),
|
|
102
|
+
n.preventDefault(), O();
|
|
102
103
|
return;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
|
-
let
|
|
106
|
-
if (n.key === "ArrowDown" && n.altKey && !
|
|
106
|
+
let P = n.ctrlKey || n.metaKey;
|
|
107
|
+
if (n.key === "ArrowDown" && n.altKey && !P && !n.shiftKey && c.activeCell && s.openColumnMenu?.(c.activeCell.col)) {
|
|
107
108
|
n.preventDefault();
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
|
-
if (
|
|
111
|
+
if (P && !n.altKey && (n.key === "ArrowUp" || n.key === "ArrowDown")) {
|
|
111
112
|
n.preventDefault();
|
|
112
113
|
let e = n.key === "ArrowDown";
|
|
113
|
-
|
|
114
|
-
row: e ?
|
|
114
|
+
b((t, n) => ({
|
|
115
|
+
row: e ? h(n) : u(n),
|
|
115
116
|
col: t.col
|
|
116
117
|
}), n.shiftKey);
|
|
117
118
|
return;
|
|
118
119
|
}
|
|
119
|
-
if (
|
|
120
|
+
if (P && !n.altKey && (n.key === "ArrowLeft" || n.key === "ArrowRight")) {
|
|
120
121
|
n.preventDefault();
|
|
121
122
|
let e = n.key === "ArrowRight";
|
|
122
|
-
|
|
123
|
+
b((t, n, r) => ({
|
|
123
124
|
row: t.row,
|
|
124
|
-
col: e ? r.length - 1 :
|
|
125
|
+
col: e ? r.length - 1 : d(r)
|
|
125
126
|
}), n.shiftKey);
|
|
126
127
|
return;
|
|
127
128
|
}
|
|
128
129
|
if ((n.key === "Home" || n.key === "End") && !n.altKey) {
|
|
129
130
|
n.preventDefault();
|
|
130
131
|
let e = n.key === "End";
|
|
131
|
-
|
|
132
|
-
row:
|
|
133
|
-
col: e ? r.length - 1 :
|
|
132
|
+
b((t, n, r) => ({
|
|
133
|
+
row: P ? e ? h(n) : u(n) : t.row,
|
|
134
|
+
col: e ? r.length - 1 : d(r)
|
|
134
135
|
}), n.shiftKey);
|
|
135
136
|
return;
|
|
136
137
|
}
|
|
137
|
-
if ((n.key === "PageDown" || n.key === "PageUp") && !
|
|
138
|
-
if (n.preventDefault(),
|
|
138
|
+
if ((n.key === "PageDown" || n.key === "PageUp") && !P && !n.altKey) {
|
|
139
|
+
if (n.preventDefault(), _()) return;
|
|
139
140
|
let e = n.key === "PageDown" ? 1 : -1;
|
|
140
|
-
|
|
141
|
-
row:
|
|
141
|
+
b((t, n) => ({
|
|
142
|
+
row: x(t, n, e),
|
|
142
143
|
col: t.col
|
|
143
144
|
}), n.shiftKey);
|
|
144
145
|
return;
|
|
145
146
|
}
|
|
146
147
|
if (n.key === "ArrowUp") {
|
|
147
|
-
n.preventDefault(),
|
|
148
|
+
n.preventDefault(), y(-1, 0, n.shiftKey);
|
|
148
149
|
return;
|
|
149
150
|
}
|
|
150
151
|
if (n.key === "ArrowDown") {
|
|
151
|
-
n.preventDefault(),
|
|
152
|
+
n.preventDefault(), y(1, 0, n.shiftKey);
|
|
152
153
|
return;
|
|
153
154
|
}
|
|
154
155
|
if (n.key === "ArrowLeft") {
|
|
155
|
-
n.preventDefault(),
|
|
156
|
+
n.preventDefault(), y(0, -1, n.shiftKey);
|
|
156
157
|
return;
|
|
157
158
|
}
|
|
158
159
|
if (n.key === "ArrowRight") {
|
|
159
|
-
n.preventDefault(),
|
|
160
|
+
n.preventDefault(), y(0, 1, n.shiftKey);
|
|
160
161
|
return;
|
|
161
162
|
}
|
|
162
163
|
if (n.key === "Tab") {
|
|
163
|
-
if (!
|
|
164
|
-
if (
|
|
165
|
-
n.preventDefault(),
|
|
164
|
+
if (!c.activeCell && !n.shiftKey) {
|
|
165
|
+
if (s.rowModel.getRowCount() === 0 || s.visibleColumns.length === 0) return;
|
|
166
|
+
n.preventDefault(), _();
|
|
166
167
|
return;
|
|
167
168
|
}
|
|
168
|
-
let e =
|
|
169
|
-
if (n.shiftKey ? e <= 0 : e >=
|
|
170
|
-
!n.shiftKey &&
|
|
169
|
+
let e = c.activeCell?.col ?? 0;
|
|
170
|
+
if (n.shiftKey ? e <= 0 : e >= s.visibleColumns.length - 1) {
|
|
171
|
+
!n.shiftKey && c.activeCell && s.onTabPastLastColumn?.(c.activeCell.row) && n.preventDefault();
|
|
171
172
|
return;
|
|
172
173
|
}
|
|
173
|
-
n.preventDefault(),
|
|
174
|
+
n.preventDefault(), y(0, n.shiftKey ? -1 : 1, !1);
|
|
174
175
|
return;
|
|
175
176
|
}
|
|
176
177
|
if (n.key === "Escape") {
|
|
177
|
-
n.preventDefault(),
|
|
178
|
+
o(c.selection) && n.preventDefault(), v(t.clearSelection());
|
|
178
179
|
return;
|
|
179
180
|
}
|
|
180
|
-
if ((n.key === "Delete" || n.key === "Backspace") &&
|
|
181
|
-
n.preventDefault(),
|
|
181
|
+
if ((n.key === "Delete" || n.key === "Backspace") && A) {
|
|
182
|
+
n.preventDefault(), k();
|
|
182
183
|
return;
|
|
183
184
|
}
|
|
184
|
-
if ((n.key === "Enter" || n.key === " ") &&
|
|
185
|
-
let e =
|
|
185
|
+
if ((n.key === "Enter" || n.key === " ") && c.activeCell) {
|
|
186
|
+
let e = l.getGroupRow?.(c.activeCell.row);
|
|
186
187
|
if (e) {
|
|
187
|
-
n.preventDefault(),
|
|
188
|
+
n.preventDefault(), M(e.groupKey);
|
|
188
189
|
return;
|
|
189
190
|
}
|
|
190
|
-
if (
|
|
191
|
+
if (N && f[c.activeCell.col]?.key === "__ssg_detail_toggle__" && N(c.activeCell)) {
|
|
191
192
|
n.preventDefault();
|
|
192
193
|
return;
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
196
|
if (n.key === "Enter" || n.key === "F2") {
|
|
196
|
-
if (n.preventDefault(),
|
|
197
|
-
|
|
197
|
+
if (n.preventDefault(), c.activeCell) {
|
|
198
|
+
w(c.activeCell);
|
|
198
199
|
return;
|
|
199
200
|
}
|
|
200
|
-
n.key === "Enter" &&
|
|
201
|
+
n.key === "Enter" && _();
|
|
201
202
|
return;
|
|
202
203
|
}
|
|
203
|
-
if (i(n) &&
|
|
204
|
-
let r =
|
|
204
|
+
if (n.key === " " && !n.ctrlKey && !n.metaKey && !n.altKey && n.preventDefault(), i(n) && c.activeCell) {
|
|
205
|
+
let r = l.getRow(c.activeCell.row), i = f[c.activeCell.col];
|
|
205
206
|
if (!r || !i || !e({
|
|
206
|
-
readOnly:
|
|
207
|
-
canEditCell:
|
|
208
|
-
},
|
|
207
|
+
readOnly: p,
|
|
208
|
+
canEditCell: m
|
|
209
|
+
}, l, c.activeCell.row, c.activeCell.col, r, i)) return;
|
|
209
210
|
if (i.editor?.type === "checkbox") {
|
|
210
|
-
n.preventDefault(), n.key === " " &&
|
|
211
|
+
n.preventDefault(), n.key === " " && j(c.activeCell);
|
|
211
212
|
return;
|
|
212
213
|
}
|
|
213
|
-
n.preventDefault(),
|
|
214
|
+
n.preventDefault(), g(n.key), v(t.startEdit(c.activeCell));
|
|
214
215
|
}
|
|
215
216
|
}
|
|
216
217
|
};
|
|
217
218
|
};
|
|
218
219
|
//#endregion
|
|
219
|
-
export {
|
|
220
|
+
export { p as createKeyboardController, f as resolveFirstDataCell };
|
|
@@ -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
|
|
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/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?.scrollContainerRef.current??null;if(t<=0||!n)return e;let r=n.getBoundingClientRect(),o=a.resolveElementScale(n,r);return i.clampClientYAboveFooter(e,r.top+(n.clientTop+n.clientHeight)*o.y,t*o.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=(e,t)=>{let r=_();if(s===null||!r||r.type!==`selection`)return;let i=b(e,t);if(i){if(r.selectionKind===`cell`){s.dispatch(n.gridActions.updateSelection(i));return}if(r.selectionKind===`row`){s.dispatch(n.gridActions.updateRowSelection(i.row));return}r.selectionKind===`col`&&s.dispatch(n.gridActions.updateColumnSelection(i.col))}},S=(e,t)=>{let r=t.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}=e;if(p.kind===`cell`){let e=d;if(e&&e.cell.row===p.cell.row&&e.cell.col===p.cell.col&&r-e.time<300){d=null,u.current(p.cell,t);return}d={cell:p.cell,time:r},a(n.gridActions.activateCell(p.cell)),o&&(a(n.gridActions.startSelection(p.cell)),a(n.gridActions.endSelection()));return}if(d=null,p.kind===`row`){if(c){l(p.rowIndex,{shiftKey:!1});return}a(n.gridActions.startRowSelection(p.rowIndex,f?.().col)),a(n.gridActions.endSelection());return}a(n.gridActions.startColumnSelection(p.colIndex,f?.().row)),a(n.gridActions.endSelection())},C=()=>{s!==null&&(l=!1,s.dispatch(n.gridActions.endSelection()),s.dispatch(n.gridActions.endColumnResize()))},w=e=>{if(s===null)return;s.pointerClientRef.current={x:e.clientX,y:e.clientY};let t=_();if(t?.type===`columnResize`){(v===null||v.drag!==t)&&(v={drag:t,x:a.resolveElementScale(s.scrollContainerRef.current).x});let r=v.x===1?e.clientX:t.startX+(e.clientX-t.startX)/v.x;s.dispatch(n.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=i.resolveScrollContentBox({rectLeft:c.left,rectTop:c.top,clientLeft:r.clientLeft,clientTop:r.clientTop,clientWidth:r.clientWidth,clientHeight:r.clientHeight,scale:a.resolveElementScale(r,c)}),u=_(),d=u?.type===`selection`&&u.selectionKind===`col`,f=u?.type===`selection`&&u.selectionKind===`row`,p=d?0:i.resolveAutoScrollAxisDirection(o.y,l.top,l.bottom-(s.footerHeight??0),24),v=f?0:i.resolveAutoScrollAxisDirection(o.x,l.left,l.right,24),y=i.computeNextScrollPosition(r.scrollTop,p,18,r.scrollHeight-r.clientHeight),b=i.computeNextScrollPosition(r.scrollLeft,v,18,r.scrollWidth-r.clientWidth);(y!==r.scrollTop||b!==r.scrollLeft)&&(r.scrollTo({top:y,left:b,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=i.resolveScrollContentBox({rectLeft:u.left,rectTop:u.top,clientLeft:o.clientLeft,clientTop:o.clientTop,clientWidth:o.clientWidth,clientHeight:o.clientHeight,scale:a.resolveElementScale(o,u)}),f=i.resolveAutoScrollAxisDirection(c.y,d.top,d.bottom-(s.footerHeight??0),24),g=i.computeNextScrollPosition(o.scrollTop,f,18,o.scrollHeight-o.clientHeight);if(g!==o.scrollTop){o.scrollTo({top:g,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:(e,t)=>{if(!(!N(t,{kind:`cell`,cell:e})||s===null)){if(t.shiftKey&&s.enableRangeSelection){let{selection:t,activeCell:r}=s.uiState,i=t?.type===`cell`?t.range.start:r;if(i){s.dispatch(n.gridActions.startSelection(i)),s.dispatch(n.gridActions.updateSelection(e));return}}s.dispatch(n.gridActions.activateCell(e)),s.enableRangeSelection&&s.dispatch(n.gridActions.startSelection(e))}},handleCellDoubleClick:(e,t)=>{f===`touch`||s===null||s.onCellDoubleClickRef.current(e,t)},handleCellPointerEnter:(e,t)=>{if(s===null||(s.enableRowHover&&s.setHoveredRowIndex(e.row),s.enableColumnHover&&s.setHoveredColumnIndex(e.col),!s.enableRangeSelection))return;let r=_();r?.type!==`selection`||r.selectionKind!==`cell`||(s.pointerClientRef.current={x:t.clientX,y:t.clientY},s.dispatch(n.gridActions.updateSelection(e)))},handleNativeDragStart:e=>{e.preventDefault()},handleRowHeaderPointerDown:(e,t)=>{if(!(!N(t,{kind:`row`,rowIndex:e})||s===null)){if(s.enableRowSelection){l=!0,s.onGutterRowSelect(e,{shiftKey:t.shiftKey}),M();return}if(t.shiftKey){let{selection:t,activeCell:r}=s.uiState,i=t?.type===`row`?t.startRow:r?.row;if(i!==void 0){s.dispatch(n.gridActions.startRowSelection(i,s.resolveFirstDataCell?.().col)),s.dispatch(n.gridActions.updateRowSelection(e));return}}s.dispatch(n.gridActions.startRowSelection(e,s.resolveFirstDataCell?.().col))}},handleRowHeaderPointerEnter:(e,t)=>{if(s===null)return;if(s.enableRowHover&&s.setHoveredRowIndex(e),l){s.pointerClientRef.current={x:t.clientX,y:t.clientY},s.onGutterRowSelectDrag(e);return}let r=_();r?.type!==`selection`||r.selectionKind!==`row`||(s.pointerClientRef.current={x:t.clientX,y:t.clientY},s.dispatch(n.gridActions.updateRowSelection(e)))},handleColumnHeaderPointerDown:(r,i)=>{if(!(!N(i,{kind:`col`,colIndex:r})||s===null)){if(i.shiftKey&&s.enableSorting){let i=s.orderedColumns[r];if(i&&!t.isSyntheticColumnKey(i.key)){let t=s.uiState.sort,r=t.find(e=>e.columnKey===i.key)?.direction?`desc`:`asc`,a=e.nextSortEntries(t,i.key,r,!0);s.dispatch(a.length===0?n.gridActions.clearSort():n.gridActions.setSort(a))}return}s.dispatch(n.gridActions.startColumnSelection(r,s.resolveFirstDataCell?.().row))}},handleColumnHeaderPointerEnter:(e,t)=>{if(s===null)return;s.setHoveredRowIndex(null),s.enableColumnHeaderHover&&s.setHoveredColumnIndex(e);let r=_();r?.type!==`selection`||r.selectionKind!==`col`||(s.pointerClientRef.current={x:t.clientX,y:t.clientY},s.dispatch(n.gridActions.updateColumnSelection(e)))},dispose:()=>{O(),k(),p!==null&&(cancelAnimationFrame(p),p=null)}}};exports.TOUCH_DOUBLE_TAP_MS=c,exports.TOUCH_TAP_SLOP_PX=s,exports.createPointerInteractionsController=l;
|