@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,26 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { clamp as
|
|
5
|
-
import { isUnchangedEditorCommit as
|
|
6
|
-
import { decideCellWrite as
|
|
1
|
+
import { gridActions as e } from "../model/gridActions.js";
|
|
2
|
+
import { getCellValue as t, isViewCellEditable as n } from "../utils/permissions.js";
|
|
3
|
+
import { findViewRowIndexByKey as r, isFocusInsideDetailCard as i, resolveFirstDataColIndex as a } from "../logic/detailRow.js";
|
|
4
|
+
import { clamp as o } from "../logic/geometry.js";
|
|
5
|
+
import { isUnchangedEditorCommit as s, parseCommittedValue as c, writeRowsCell as l } from "../logic/editorValues.js";
|
|
6
|
+
import { decideCellWrite as u } from "../logic/validation.js";
|
|
7
7
|
//#region src/controllers/editController.ts
|
|
8
|
-
var
|
|
9
|
-
if (
|
|
10
|
-
let t = e.ownerDocument,
|
|
11
|
-
return
|
|
12
|
-
},
|
|
8
|
+
var d = (e, t) => t.activeCell !== e.activeCell || t.selection !== e.selection, f = (e) => {
|
|
9
|
+
if (i()) return !1;
|
|
10
|
+
let t = e.ownerDocument, n = t.activeElement;
|
|
11
|
+
return n === null || n === t.body || n === t.documentElement || e.contains(n);
|
|
12
|
+
}, p = (e) => {
|
|
13
13
|
if (e === null) return !1;
|
|
14
14
|
let t = e.ownerDocument.activeElement;
|
|
15
|
-
return t !== null && t !== e && e.contains(t) && typeof t.closest == "function" && t.closest(".ssg-cell-editor") !== null && !
|
|
16
|
-
},
|
|
17
|
-
let
|
|
15
|
+
return t !== null && t !== e && e.contains(t) && typeof t.closest == "function" && t.closest(".ssg-cell-editor") !== null && !i();
|
|
16
|
+
}, m = () => {
|
|
17
|
+
let i = null, m = null, h = (e, t) => {
|
|
18
18
|
let n = e.visibleColumns[t.col];
|
|
19
19
|
return !n || t.row < 0 || t.row >= e.rowModel.getRowCount() || e.rowModel.getRow(t.row) === void 0 ? null : {
|
|
20
20
|
rowKey: e.rowModel.getRowKey(t.row),
|
|
21
21
|
columnKey: n.key
|
|
22
22
|
};
|
|
23
|
-
},
|
|
23
|
+
}, g = (e, t) => {
|
|
24
24
|
let n = e.visibleColumns.findIndex((e) => e.key === t.columnKey);
|
|
25
25
|
if (n < 0) return null;
|
|
26
26
|
let r = e.rowModel.getRowCount();
|
|
@@ -29,124 +29,131 @@ var u = (e, t) => t.activeCell !== e.activeCell || t.selection !== e.selection,
|
|
|
29
29
|
col: n
|
|
30
30
|
};
|
|
31
31
|
return null;
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
let
|
|
35
|
-
if (!
|
|
36
|
-
|
|
32
|
+
}, _ = (t) => {
|
|
33
|
+
i = t;
|
|
34
|
+
let n = t.uiState.editingCell;
|
|
35
|
+
if (!n) {
|
|
36
|
+
m = null;
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
-
let r =
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
...
|
|
43
|
-
cell:
|
|
39
|
+
let r = h(t, n);
|
|
40
|
+
if (m !== null && r !== null && Object.is(r.rowKey, m.rowKey) && r.columnKey === m.columnKey) {
|
|
41
|
+
m = {
|
|
42
|
+
...m,
|
|
43
|
+
cell: n
|
|
44
44
|
};
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
let a =
|
|
48
|
-
if (
|
|
49
|
-
|
|
47
|
+
let a = m !== null && m.cell.row === n.row && m.cell.col === n.col;
|
|
48
|
+
if (m === null || !a) {
|
|
49
|
+
m = r ? {
|
|
50
50
|
...r,
|
|
51
|
-
cell:
|
|
51
|
+
cell: n
|
|
52
52
|
} : null;
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
let o =
|
|
56
|
-
o ? (
|
|
57
|
-
...
|
|
55
|
+
let o = g(t, m);
|
|
56
|
+
o ? (m = {
|
|
57
|
+
...m,
|
|
58
58
|
cell: o
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
},
|
|
65
|
-
let o =
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
59
|
+
}, t.dispatch(e.retargetEdit(o, t.rowModel.getRowCount()))) : (m = null, t.dispatch(e.stopEdit()));
|
|
60
|
+
}, v = (t) => {
|
|
61
|
+
i !== null && (i.dispatch(e.startSelection(t)), i.dispatch(e.endSelection()), i.dispatch(e.activateCell(t)));
|
|
62
|
+
}, y = (t, n) => {
|
|
63
|
+
i !== null && (i.setEditorInitialValue(n), i.dispatch(e.startEdit(t)));
|
|
64
|
+
}, b = (e, t, n) => {
|
|
65
|
+
let r = e.getRowCount(), i = o(t, 0, Math.max(r - 1, 0)), { getLabelRow: a } = e;
|
|
66
|
+
if (a && n !== void 0 && i !== n) {
|
|
67
|
+
let e = i > n ? 1 : -1;
|
|
68
|
+
for (; i >= 0 && i < r && a(i);) i += e;
|
|
69
|
+
(i < 0 || i >= r) && (i = o(n, 0, Math.max(r - 1, 0)));
|
|
70
|
+
}
|
|
71
|
+
return i;
|
|
72
|
+
}, x = (e, t = null, n, a = !1, s) => {
|
|
73
|
+
let c = i;
|
|
74
|
+
if (c === null) return;
|
|
75
|
+
let l = !1, u = (a) => {
|
|
76
|
+
if (l || !a && (i === null || i.uiState.editingCell !== null)) return;
|
|
77
|
+
l = !0;
|
|
78
|
+
let u = c.gridRootRef.current;
|
|
79
|
+
if (u !== null && f(u) && u.focus(), e !== null && i !== null && !(t !== null && d(t, i.uiState))) {
|
|
80
|
+
let t = i.visibleColumns.length, a = s === void 0 ? -1 : r(i.rowModel, s, /* @__PURE__ */ new Map()), c = a >= 0 ? a : b(i.rowModel, e.row, n);
|
|
81
|
+
v({
|
|
82
|
+
row: c,
|
|
83
|
+
col: o(e.col, 0, Math.max(t - 1, 0))
|
|
81
84
|
});
|
|
82
85
|
}
|
|
83
|
-
|
|
86
|
+
c.editorActionGuardRef.current = !1;
|
|
84
87
|
};
|
|
85
|
-
|
|
86
|
-
},
|
|
87
|
-
let e =
|
|
88
|
-
return
|
|
88
|
+
a && queueMicrotask(() => u(!1)), requestAnimationFrame(() => u(!0));
|
|
89
|
+
}, S = () => {
|
|
90
|
+
let e = i?.gridRootRef.current ?? null;
|
|
91
|
+
return p(e) ? (e.focus({ preventScroll: !0 }), !0) : !1;
|
|
89
92
|
};
|
|
90
93
|
return {
|
|
91
|
-
update:
|
|
92
|
-
activateSingleCell:
|
|
93
|
-
startEditWithValue:
|
|
94
|
-
commitEdit: (
|
|
95
|
-
if (
|
|
96
|
-
let { uiState: d, visibleColumns: f, rowModel: p, rows: m, applyServerSideCellEdits: h, onRowsChange: g, dispatch: _, editorActionGuardRef: v } =
|
|
94
|
+
update: _,
|
|
95
|
+
activateSingleCell: v,
|
|
96
|
+
startEditWithValue: y,
|
|
97
|
+
commitEdit: (r, o) => {
|
|
98
|
+
if (i === null) return { status: "noop" };
|
|
99
|
+
let { uiState: d, visibleColumns: f, rowModel: p, rows: m, applyServerSideCellEdits: h, onRowsChange: g, dispatch: _, editorActionGuardRef: v } = i;
|
|
97
100
|
if (v.current || !d.editingCell) return { status: "noop" };
|
|
98
|
-
let
|
|
99
|
-
row:
|
|
100
|
-
col:
|
|
101
|
-
} :
|
|
102
|
-
row:
|
|
103
|
-
col:
|
|
104
|
-
} :
|
|
105
|
-
row:
|
|
106
|
-
col:
|
|
107
|
-
} :
|
|
108
|
-
row:
|
|
109
|
-
col: Math.max(
|
|
110
|
-
} :
|
|
111
|
-
if (!
|
|
112
|
-
if (!
|
|
113
|
-
readOnly:
|
|
114
|
-
canEditCell:
|
|
115
|
-
}, p,
|
|
116
|
-
let
|
|
117
|
-
if (!
|
|
118
|
-
let e =
|
|
101
|
+
let y = d.editingCell, C = o === "down" ? {
|
|
102
|
+
row: y.row + 1,
|
|
103
|
+
col: y.col
|
|
104
|
+
} : o === "up" ? {
|
|
105
|
+
row: y.row - 1,
|
|
106
|
+
col: y.col
|
|
107
|
+
} : o === "right" ? {
|
|
108
|
+
row: y.row,
|
|
109
|
+
col: y.col + 1
|
|
110
|
+
} : o === "left" ? {
|
|
111
|
+
row: y.row,
|
|
112
|
+
col: Math.max(y.col - 1, a(f))
|
|
113
|
+
} : y, w = f[y.col], T = p.getSourceIndex(y.row), E = h ? p.getRow(y.row) : m[T];
|
|
114
|
+
if (!w || !E) return _(e.stopEdit()), { status: "noop" };
|
|
115
|
+
if (!n({
|
|
116
|
+
readOnly: i.readOnly,
|
|
117
|
+
canEditCell: i.canEditCell
|
|
118
|
+
}, p, y.row, y.col, E, w)) return v.current = !0, _(e.stopEdit()), x(null), { status: "noop" };
|
|
119
|
+
let D = s(w, t(E, w), r);
|
|
120
|
+
if (!D && h) {
|
|
121
|
+
let e = c(w, r, E), t = u(w, E, e, i.localeTexts);
|
|
119
122
|
if (t.action === "reject") return {
|
|
120
123
|
status: "rejected",
|
|
121
124
|
message: t.message
|
|
122
125
|
};
|
|
123
126
|
h([{
|
|
124
|
-
viewIndex:
|
|
125
|
-
column:
|
|
127
|
+
viewIndex: y.row,
|
|
128
|
+
column: w,
|
|
126
129
|
value: e
|
|
127
130
|
}]);
|
|
128
|
-
} else if (!
|
|
129
|
-
let e =
|
|
131
|
+
} else if (!D && g) {
|
|
132
|
+
let e = c(w, r, E), t = u(w, E, e, i.localeTexts);
|
|
130
133
|
if (t.action === "reject") return {
|
|
131
134
|
status: "rejected",
|
|
132
135
|
message: t.message
|
|
133
136
|
};
|
|
134
|
-
g(
|
|
137
|
+
g(l(m, T, w, e));
|
|
135
138
|
}
|
|
136
139
|
v.current = !0;
|
|
137
|
-
let
|
|
138
|
-
|
|
140
|
+
let O = S(), k;
|
|
141
|
+
if (i.followsRow === !0) {
|
|
142
|
+
let e = b(p, C.row, y.row);
|
|
143
|
+
(p.getRow(e) != null || p.getLabelRow?.(e) !== void 0) && (k = p.getRowKey(e));
|
|
144
|
+
}
|
|
145
|
+
return x(C, o === void 0 ? {
|
|
139
146
|
activeCell: d.activeCell,
|
|
140
147
|
selection: d.selection
|
|
141
|
-
} : null,
|
|
148
|
+
} : null, y.row, O, k), _(e.stopEdit()), { status: "committed" };
|
|
142
149
|
},
|
|
143
150
|
cancelEdit: () => {
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
let
|
|
147
|
-
|
|
151
|
+
if (i === null || i.editorActionGuardRef.current) return;
|
|
152
|
+
i.editorActionGuardRef.current = !0;
|
|
153
|
+
let t = S();
|
|
154
|
+
i.dispatch(e.stopEdit()), x(null, null, void 0, t);
|
|
148
155
|
}
|
|
149
156
|
};
|
|
150
157
|
};
|
|
151
158
|
//#endregion
|
|
152
|
-
export {
|
|
159
|
+
export { m as createEditController };
|
|
@@ -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/valueStore.cjs"),r=require("../logic/autoScrollGeometry.cjs"),i=require("../logic/elementScale.cjs"),a=require("./escapeClaimController.cjs"),o=require("./popoverSupport.cjs"),s=require("../logic/fillHandle.cjs");var c=168,l=84,u=106,d=()=>typeof matchMedia==`function`&&matchMedia(`(pointer: coarse)`).matches?u:l,f=8,p={status:`idle`},m=(e,t,n)=>{if(e.valueFormatter)try{return e.valueFormatter({value:n,row:t,column:e})}catch{return String(n??``)}return String(n??``)},h=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>e.key===t[n].key),g=500,_=6,v=2,y=e=>{let t=e.currentTarget;if(!(t instanceof Element))return!0;let n=t.getBoundingClientRect();return e.clientX>=n.left-v&&e.clientX<=n.right+v&&e.clientY>=n.top-v&&e.clientY<=n.bottom+v},b=(e,t)=>e===t||e!==void 0&&t!==void 0&&e.length===t.length&&e.every((e,n)=>Object.is(e,t[n])),x=(e,t)=>Object.is(e,t)||e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime(),S=(e,t)=>e.length===t.length&&e.every((e,n)=>e.viewIndex===t[n].viewIndex&&e.column.key===t[n].column.key&&x(e.value,t[n].value)),C=()=>{let l=null,u=n.createValueStore(p),v=n.createValueStore(null),x={current:null},C={current:null},w=null,T=null,E=null,D=e=>e?`toggled`:`auto`,O=e=>(n,r,i,a)=>t.isViewCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},e.rowModel,n,r,i,a),k=()=>{if(E===null||l===null)return;let e=u.getSnapshot();if(e.status===`dragging`&&e.toggled===E.toggled&&(e.target===E.target||e.target!==null&&E.target!==null&&e.target.direction===E.target.direction&&s.isSameFillRange(e.target.range,E.target.range)))return;let t=null;if(E.target!==null){let e=s.previewFillValue({rowModel:l.rowModel,columns:l.columns,source:E.source,target:E.target,request:D(E.toggled),canWriteCell:O(l),getFillValue:l.getFillValue});t=e&&m(e.column,e.row,e.value)||null}u.setSnapshot({status:`dragging`,source:E.source,target:E.target,toggled:E.toggled,previewText:t})},A=()=>{if(E===null||l===null)return;let e=s.resolveFillColumnBounds(l.columns),t=l.hitTest(E.pointer.x,E.pointer.y);e===null||t===null||(E.target=s.resolveFillTarget(E.source,t,l.rowModel.getRowCount(),e),k())},j=()=>{if(E===null||l===null)return;let e=E;e.rafId=requestAnimationFrame(j);let t=l.scrollContainerRef.current;if(!t)return;if(!e.armed){if(!r.hasPointerLeftActivationRadius(e.origin,e.pointer,6))return;e.armed=!0}let n=t.getBoundingClientRect(),a=i.resolveElementScale(t,n),o=r.resolveScrollContentBox({rectLeft:n.left,rectTop:n.top,clientLeft:t.clientLeft,clientTop:t.clientTop,clientWidth:t.clientWidth,clientHeight:t.clientHeight,scale:a}),s=r.computeNextScrollPosition(t.scrollTop,r.resolveAutoScrollAxisDirection(e.pointer.y,r.resolveTopAutoScrollStart(o.top,(l.stickyTopHeight??0)*a.y,24),o.bottom-(l.footerHeight??0),24),18,t.scrollHeight-t.clientHeight),c=r.computeNextScrollPosition(t.scrollLeft,r.resolveAutoScrollAxisDirection(e.pointer.x,o.left,o.right,24),18,t.scrollWidth-t.clientWidth);(s!==t.scrollTop||c!==t.scrollLeft)&&(t.scrollTo({top:s,left:c,behavior:`auto`}),A())},M=(e,t)=>{let n=E;if(n!==null){if(E=null,n.cleanup(),n.rafId!==null&&cancelAnimationFrame(n.rafId),v.setSnapshot(null),u.setSnapshot(p),e&&n.target!==null){T=null,F(n.source,n.target,D(n.toggled),n.activeCell);return}T=e&&t!==void 0&&n.onSquare?{time:t,x:n.origin.x,y:n.origin.y}:null}},N=(t,n)=>{if(l===null)return;let{dispatch:r}=l;r(e.gridActions.startSelection({row:t.startRow,col:t.startCol})),r(e.gridActions.updateSelection({row:t.endRow,col:t.endCol})),r(e.gridActions.endSelection()),r(e.gridActions.activateCell(n??{row:t.startRow,col:t.startCol}))},P=(e,t)=>{let n=[];for(let r=t.startRow;r<=t.endRow;r+=1)n.push(e.getRowKey(r));return n},F=(e,t,n,r)=>{if(l===null||!l.enabled)return;let i=l,a=s.buildFillEdits({rowModel:i.rowModel,columns:i.columns,source:e,target:t,request:n,canWriteCell:O(i),getFillValue:i.getFillValue});if(a.edits.length===0)return;let o=s.unionFillRange(e,t),c=null,d=[],f=null;if(i.isServerSide){if(!i.applyServerSideCellEdits)return;f=P(i.rowModel,o),i.applyServerSideCellEdits(a.edits)}else{if(!i.applyRowsChange)return;let e=s.applyFillEditsToRows(i.rows,i.rowModel,a.edits);if(e===i.rows)return;c=i.rows,d.push(e),i.applyRowsChange(e)}w={source:e,target:t,range:o,previousSource:e,selectionConfirmed:!1,columns:i.columns,viewKey:i.viewKey,request:n,edits:a.edits,baseRows:c,baseRowModel:i.isServerSide?null:i.rowModel,emittedRows:d,rowKeys:f},N(o,r),u.setSnapshot({status:`filled`,range:o,kind:a.kind,seriesAvailable:a.seriesAvailable,menu:null})},I=o.createPopoverWindowBindings({onScroll:e=>{e.target instanceof Node&&x.current?.contains(e.target)||R(!1)},onResize:()=>R(!1),isInside:e=>x.current?.contains(e)===!0||C.current?.contains(e)===!0,onOutsidePointerDown:e=>R(l!==null&&o.isInsideGridRoot(l.gridRootRef,e)),getGridRoot:()=>l?.gridRootRef.current??null,onGridHidden:()=>R(!1),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),R(!0))}}),L=e=>{let t=u.getSnapshot();t.status!==`filled`||t.menu===e||u.setSnapshot({...t,menu:e})},R=e=>{I.detach(),L(null),e&&l!==null&&o.restoreGridFocus(l.gridRootRef)},z=()=>{let e=typeof document<`u`&&x.current?.contains(document.activeElement)===!0;w=null,I.detach(),u.getSnapshot().status===`filled`&&u.setSnapshot(p),e&&l!==null&&o.restoreGridFocus(l.gridRootRef)},B=e=>{let t=u.getSnapshot();if(t.status!==`filled`)return;if(t.menu!==null){R(!0);return}let n=Math.min(e.left,window.innerWidth-c-f);n=Math.max(f,n);let r=e.bottom+4,i=d();r+i>window.innerHeight-f&&(r=Math.max(f,e.top-4-i)),L({top:r,left:n}),I.attach()},V=(e,t)=>{let n=t.rowKeys;if(n===null)return!1;for(let r=0;r<n.length;r+=1)if(e.getRowKey(t.range.startRow+r)!==n[r])return!1;return!0},H=e=>{let n=u.getSnapshot(),r=w;if(R(!0),l===null||r===null||n.status!==`filled`||r.request===e)return;let i=l;if(i.isServerSide){if(!i.applyServerSideCellEdits||!V(i.rowModel,r)){z();return}let t=s.buildFillEdits({rowModel:i.rowModel,columns:r.columns,source:r.source,target:r.target,request:e,canWriteCell:O(i),getFillValue:i.getFillValue});r.request=e,t.edits.length>0&&!S(t.edits,r.edits)&&i.applyServerSideCellEdits(t.edits),r.edits=t.edits,u.setSnapshot({...n,kind:t.kind,menu:null});return}if(!i.amendRowsChange||r.baseRows===null||r.baseRowModel===null){z();return}let a=r.baseRowModel,o=s.buildFillEdits({rowModel:a,columns:r.columns,source:r.source,target:r.target,request:e,canWriteCell:(e,n,r,o)=>t.isViewCellEditable({readOnly:i.readOnly,canEditCell:i.canEditCell},a,e,n,r,o),getFillValue:i.getFillValue});if(r.request=e,!S(o.edits,r.edits)){let e=s.applyFillEditsToRows(r.baseRows,a,o.edits);r.emittedRows.push(e),r.edits=o.edits,i.amendRowsChange(e)}u.setSnapshot({...n,kind:o.kind,menu:null})},U=(e,t)=>{if(e?.type!==`cell`)return!1;let{start:n,end:r}=e.range;return s.isSameFillRange(t,{startRow:Math.min(n.row,r.row),endRow:Math.max(n.row,r.row),startCol:Math.min(n.col,r.col),endCol:Math.max(n.col,r.col)})},W=e=>{let t=w;if(t!==null){if(!e.enabled||e.editing||!h(e.columns,t.columns)||!b(e.viewKey,t.viewKey)){z();return}if(!e.isServerSide&&e.rows!==t.baseRows&&!t.emittedRows.includes(e.rows)){z();return}if(U(e.selection,t.range)){t.selectionConfirmed=!0;return}!t.selectionConfirmed&&U(e.selection,t.previousSource)||z()}},G=e=>{if(l===null||e.button!==0||(e.preventDefault(),E!==null||!l.enabled||l.editing))return;let t=s.resolveFillSource(l.selection,l.activeCell,l.rowModel.getRowCount(),l.columns.length);if(t===null)return;let n=T;T=null;let r=y(e);if(n!==null&&r&&e.timeStamp-n.time<=g&&Math.abs(e.clientX-n.x)<=_&&Math.abs(e.clientY-n.y)<=_){l.gridRootRef.current?.focus({preventScroll:!0}),K();return}z(),l.gridRootRef.current?.focus({preventScroll:!0});let i=e.pointerId,o=e=>{E===null||e.pointerId!==i||(E.pointer={x:e.clientX,y:e.clientY},E.toggled=e.ctrlKey||e.metaKey,v.setSnapshot(E.pointer),A())},c=e=>{E===null||e.pointerId!==i||(E.toggled=e.ctrlKey||e.metaKey,M(!0,e.timeStamp))},u=e=>{e.pointerId===i&&M(!1)},d=e=>{if(E===null)return;if(e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&e.key===`Escape`){M(!1);return}let t=e.ctrlKey||e.metaKey;t!==E.toggled&&(E.toggled=t,k())},f=()=>M(!1);window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,u),window.addEventListener(`keydown`,d,!0),window.addEventListener(`keyup`,d,!0),window.addEventListener(`blur`,f);let p=a.beginEscapeCancelableDrag(),m={x:e.clientX,y:e.clientY};E={pointerId:i,source:t,activeCell:l.activeCell,origin:m,onSquare:r,pointer:m,toggled:e.ctrlKey||e.metaKey,target:null,armed:!1,rafId:null,cleanup:()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,u),window.removeEventListener(`keydown`,d,!0),window.removeEventListener(`keyup`,d,!0),window.removeEventListener(`blur`,f),p()}},v.setSnapshot(m),k(),E.rafId=requestAnimationFrame(j)},K=()=>{if(l===null||E!==null||!l.enabled||l.editing)return;let e=s.resolveFillSource(l.selection,l.activeCell,l.rowModel.getRowCount(),l.columns.length);if(e===null)return;let t=s.resolveFillDoubleClickTarget(e,l.rowModel,l.columns);t!==null&&(z(),F(e,t,`auto`,l.activeCell))};return{update:e=>{l=e,E!==null&&(!e.enabled||e.editing)&&M(!1),W(e)},subscribe:u.subscribe,getSnapshot:u.getSnapshot,subscribePointer:v.subscribe,getPointerSnapshot:v.getSnapshot,handlePointerDown:G,handleDoubleClick:K,toggleMenu:B,closeMenu:()=>R(!0),chooseKind:H,menuPanel:x,chipElement:C,dispose:()=>{M(!1),I.detach(),w=null}}};exports.createFillHandleController=C;
|