@ishibashi0112/spreadsheet-grid-core 0.41.1 → 0.42.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/asyncSelectOptionsSource.d.ts +2 -2
- package/dist/controllers/autoHeightMeasurer.d.ts +3 -3
- package/dist/controllers/clipboardController.cjs +2 -2
- package/dist/controllers/clipboardController.d.ts +5 -3
- package/dist/controllers/clipboardController.js +60 -57
- package/dist/controllers/columnAutosizeRunner.d.ts +2 -2
- package/dist/controllers/columnHeaderDragController.d.ts +2 -2
- package/dist/controllers/columnMenuController.cjs +1 -1
- package/dist/controllers/columnMenuController.d.ts +2 -2
- package/dist/controllers/columnMenuController.js +60 -60
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.d.ts +2 -2
- package/dist/controllers/contextMenuController.js +32 -32
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.d.ts +5 -3
- package/dist/controllers/editController.js +97 -51
- package/dist/controllers/filterPopoverController.cjs +1 -1
- package/dist/controllers/filterPopoverController.d.ts +5 -5
- package/dist/controllers/filterPopoverController.js +78 -78
- package/dist/controllers/globalFilteredOrder.d.ts +2 -2
- package/dist/controllers/historyController.d.ts +2 -2
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +2 -2
- package/dist/controllers/keyboardController.js +2 -0
- package/dist/controllers/pointerInteractionsController.d.ts +4 -4
- package/dist/controllers/popoverSupport.cjs +1 -1
- package/dist/controllers/popoverSupport.d.ts +2 -1
- package/dist/controllers/popoverSupport.js +3 -3
- package/dist/controllers/rowDragController.d.ts +2 -2
- package/dist/controllers/scrollSyncController.d.ts +2 -2
- package/dist/controllers/selectOptionsCollector.d.ts +2 -2
- package/dist/controllers/serverSideRowModel.cjs +1 -1
- package/dist/controllers/serverSideRowModel.d.ts +2 -2
- package/dist/controllers/serverSideRowModel.js +5 -3
- package/dist/controllers/toolPanelController.cjs +1 -1
- package/dist/controllers/toolPanelController.d.ts +1 -1
- package/dist/controllers/toolPanelController.js +53 -53
- package/dist/controllers/tooltipController.d.ts +1 -1
- package/dist/controllers/viewportSyncController.d.ts +2 -2
- package/dist/engine/columnCommands.cjs +1 -1
- package/dist/engine/columnCommands.d.ts +4 -4
- package/dist/engine/columnCommands.js +2 -2
- package/dist/engine/columnLayout.d.ts +2 -2
- package/dist/engine/createGridEngine.cjs +1 -1
- package/dist/engine/createGridEngine.d.ts +14 -14
- package/dist/engine/createGridEngine.js +1 -1
- package/dist/engine/filterPopoverCommands.d.ts +7 -7
- package/dist/engine/gridApi.cjs +1 -1
- package/dist/engine/gridApi.d.ts +10 -8
- package/dist/engine/gridApi.js +115 -79
- package/dist/engine/notifiers.d.ts +1 -1
- package/dist/engine/rowPipeline.cjs +1 -1
- package/dist/engine/rowPipeline.d.ts +5 -5
- package/dist/engine/rowPipeline.js +1 -1
- package/dist/engine/rowSelectionCommands.d.ts +2 -2
- package/dist/engine/verticalLayout.d.ts +5 -5
- package/dist/index.d.ts +8 -8
- package/dist/logic/aggregation.d.ts +1 -1
- package/dist/logic/autoSizeOnData.d.ts +1 -1
- package/dist/logic/clearCells.d.ts +2 -2
- package/dist/logic/columnAutosize.d.ts +1 -1
- package/dist/logic/columnFlex.d.ts +1 -1
- package/dist/logic/columnReset.d.ts +1 -1
- package/dist/logic/columnWidthState.cjs +1 -0
- package/dist/logic/columnWidthState.d.ts +2 -0
- package/dist/logic/columnWidthState.js +30 -0
- package/dist/logic/contextMenuTarget.d.ts +1 -1
- package/dist/logic/dateFilterCondition.d.ts +2 -2
- package/dist/logic/dateFilterPresets.d.ts +1 -1
- package/dist/logic/detailRow.d.ts +2 -2
- package/dist/logic/domGuards.cjs +1 -1
- package/dist/logic/domGuards.js +1 -1
- package/dist/logic/editorValues.d.ts +1 -1
- package/dist/logic/exportCsv.d.ts +1 -1
- package/dist/logic/exportData.d.ts +2 -2
- package/dist/logic/exportScope.d.ts +1 -1
- package/dist/logic/filterSummary.d.ts +2 -2
- package/dist/logic/filtering.d.ts +2 -2
- package/dist/logic/geometry.d.ts +1 -1
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +1 -1
- package/dist/logic/gridState.js +59 -44
- package/dist/logic/grouping.d.ts +3 -3
- package/dist/logic/inferFilterType.d.ts +1 -1
- package/dist/logic/labelRows.d.ts +2 -2
- package/dist/logic/numberFilterCondition.d.ts +1 -1
- package/dist/logic/rowHeightStore.d.ts +2 -2
- package/dist/logic/rowReorder.d.ts +1 -1
- package/dist/logic/rowSelection.d.ts +1 -1
- package/dist/logic/scrollHint.d.ts +1 -1
- package/dist/logic/scrollTargets.d.ts +1 -1
- package/dist/logic/selectEditorState.d.ts +1 -1
- package/dist/logic/serverSideEdits.d.ts +1 -1
- package/dist/logic/serverSideQuery.d.ts +1 -1
- package/dist/logic/sorting.cjs +1 -1
- package/dist/logic/sorting.d.ts +3 -2
- package/dist/logic/sorting.js +81 -50
- package/dist/logic/textFilterCondition.d.ts +1 -1
- package/dist/logic/theme.d.ts +1 -1
- package/dist/logic/validation.d.ts +1 -1
- package/dist/logic/valueFormatters.cjs +1 -1
- package/dist/logic/valueFormatters.d.ts +1 -1
- package/dist/logic/valueFormatters.js +12 -9
- package/dist/model/gridActions.cjs +1 -1
- package/dist/model/gridActions.d.ts +10 -1
- package/dist/model/gridActions.js +9 -0
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.d.ts +3 -3
- package/dist/model/gridReducer.js +178 -110
- package/dist/model/gridSelectors.d.ts +3 -3
- package/dist/model/gridStore.d.ts +2 -2
- package/dist/model/gridTypes.core.d.ts +47 -9
- package/dist/model/gridTypes.unbound.d.ts +2 -2
- package/dist/utils/clipboard.cjs +6 -5
- package/dist/utils/clipboard.d.ts +4 -2
- package/dist/utils/clipboard.js +52 -17
- package/dist/utils/permissions.d.ts +1 -1
- package/package.json +4 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ColumnFilterValue, GetFilterOptionsResult, GridColumn } from '../model/gridTypes.unbound';
|
|
2
|
-
import { type ColumnSelectOptionsResult } from './selectOptionsCollector';
|
|
1
|
+
import type { ColumnFilterValue, GetFilterOptionsResult, GridColumn } from '../model/gridTypes.unbound.js';
|
|
2
|
+
import { type ColumnSelectOptionsResult } from './selectOptionsCollector.js';
|
|
3
3
|
export type AsyncSelectOptionsFetchParams<T> = {
|
|
4
4
|
columnKey: string;
|
|
5
5
|
column: GridColumn<T>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { GridRowKey, RowModel } from '../model/gridTypes.unbound';
|
|
2
|
-
import { type RowHeightStore } from '../logic/rowHeightStore';
|
|
3
|
-
import type { RowMetrics, VerticalGeometry } from '../logic/verticalGeometry';
|
|
1
|
+
import type { GridRowKey, RowModel } from '../model/gridTypes.unbound.js';
|
|
2
|
+
import { type RowHeightStore } from '../logic/rowHeightStore.js';
|
|
3
|
+
import type { RowMetrics, VerticalGeometry } from '../logic/verticalGeometry.js';
|
|
4
4
|
type ReadonlyRef<V> = {
|
|
5
5
|
readonly current: V;
|
|
6
6
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
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("../utils/clipboard.cjs"),
|
|
2
|
-
`)};return{update:
|
|
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"),i=require("../utils/clipboard.cjs"),a=require("../logic/labelRows.cjs");var o=(e,t,n)=>{if(t===0||n===0||e?.type!==`cell`)return!1;let{start:r,end:i}=e.range,a=Math.min(r.row,i.row),o=Math.min(r.col,i.col),s=Math.max(r.row,i.row),c=Math.max(r.col,i.col);return a===0&&o===0&&s===t-1&&c===n-1},s=()=>{let s=null,c=e=>{s=e},l=e=>{let{isRowExportable:t,rowModel:n}=e;if(t)return(e,r)=>t(e,{viewRowIndex:r,rowKey:n.getRowKey(r)??r})},u=t=>{let{rowModel:n,visibleColumns:r}=t,a=n.getRowCount();if(a===0||r.length===0)return``;let o=l(t),s=[];for(let t=0;t<a;t+=1){let a=n.getRow(t);if(!a||o&&!o(a,t))continue;let c=r.map(t=>{let n=e.getCellValue(a,t);return t.formatClipboardValue?t.formatClipboardValue(n,a):String(n??``)});s.push(i.joinTsvRow(c))}return s.join(`
|
|
2
|
+
`)};return{update:c,handleCopy:async()=>{if(s===null)return;let e=s,{rowModel:t,visibleColumns:n,uiState:r}=e,a=o(r.selection,t.getRowCount(),n.length)?u(e):i.serializeSelectionToTsv(t.getRow,t.getRowCount(),n,r.selection,l(e));a&&await i.writeTextToClipboard(a)},handlePaste:o=>{if(s===null)return;let{rows:c,rowModel:l,columns:u,visibleColumns:d,uiState:f,readOnly:p,canEditCell:m,createRow:h,createOverflowColumn:g,onRowsChange:_,onColumnsChange:v,applyServerSideCellEdits:y,dispatch:b}=s;if(f.editingCell||r.shouldIgnoreGridKeydown(o.target??null)||p||!_&&!y||!f.activeCell)return;let x=o.clipboardData?.getData(`text/plain`)??``;if(!x)return;o.preventDefault();let S=i.parseClipboardText(x);if(S.length===0)return;let C=S.reduce((e,t)=>Math.max(e,t.length),0);if(C===0)return;let w=f.activeCell.row,T=f.activeCell.col,E=l.getLabelRow===void 0?null:a.resolvePasteTargetViewIndexes(l,w,S.length),D=e=>E?E[e-w]:e,O=E?E[E.length-1]:f.activeCell.row+Math.max(S.length-1,0);if(y){let r=i.buildClipboardCellEdits(e=>l.getRow(D(e)),d,S,w,T,(t,n,r,i)=>e.isCellEditable({readOnly:p,canEditCell:m},D(t),n,r,i)).map(e=>({...e,viewIndex:D(e.viewIndex)}));r.length>0&&y(r);let a=n.clamp(O,0,Math.max(l.getRowCount()-1,0)),o=n.clamp(f.activeCell.col+Math.max(C-1,0),0,Math.max(d.length-1,0));b(t.gridActions.startSelection(f.activeCell)),b(t.gridActions.updateSelection({row:a,col:o})),b(t.gridActions.endSelection()),b(t.gridActions.activateCell(f.activeCell));return}if(!_||l.getSourceIndex(w)===void 0)return;let k=f.activeCell.col,A=[...c],j=[...d],M=l.getRowCount(),N=A.length,P=e=>{let t=D(e);return t<M?l.getSourceIndex(t):N+(t-M)},F=Math.max(O+1-M,0),I=A.length+F;if(I>A.length&&h)for(;A.length<I;)A.push(h());let L=k+C;if(L>j.length&&v&&g){let e=[];for(;j.length<L;){let t=g(j.length);j.push(t),e.push(t)}v(u?[...u,...e]:j)}let R=i.applyClipboardMatrixToRows(A,P,j,S,w,k,(t,n,r,i)=>e.isCellEditable({readOnly:p,canEditCell:m},t,n,r,i)),z=n.clamp(O,0,Math.max(Math.max(l.getRowCount()-1,0),O)),B=n.clamp(f.activeCell.col+Math.max((S[0]?.length??1)-1,0),0,Math.max(Math.max(j.length-1,0),k+C-1));_(R),b(t.gridActions.startSelection(f.activeCell)),b(t.gridActions.updateSelection({row:z,col:B})),b(t.gridActions.endSelection()),b(t.gridActions.activateCell(f.activeCell))}}};exports.computeIsWholeGridSelected=o,exports.createClipboardController=s;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { type GridUiAction } from '../model/gridActions';
|
|
2
|
-
import type { GridColumn, GridSelection, GridUiState, RowModel, SpreadsheetGridProps } from '../model/gridTypes.unbound';
|
|
3
|
-
import type { ServerSideCellEditInput } from '../logic/serverSideEdits';
|
|
1
|
+
import { type GridUiAction } from '../model/gridActions.js';
|
|
2
|
+
import type { GridColumn, GridSelection, GridUiState, RowModel, SpreadsheetGridProps } from '../model/gridTypes.unbound.js';
|
|
3
|
+
import type { ServerSideCellEditInput } from '../logic/serverSideEdits.js';
|
|
4
4
|
export type ClipboardEventLike = {
|
|
5
5
|
clipboardData: {
|
|
6
6
|
getData: (type: string) => string;
|
|
7
7
|
} | null;
|
|
8
8
|
preventDefault: () => void;
|
|
9
|
+
target?: EventTarget | null;
|
|
9
10
|
};
|
|
10
11
|
export type ClipboardControllerArgs<T extends object> = {
|
|
11
12
|
rows: T[];
|
|
12
13
|
rowModel: RowModel<T>;
|
|
14
|
+
columns?: readonly GridColumn<T>[];
|
|
13
15
|
visibleColumns: GridColumn<T>[];
|
|
14
16
|
uiState: GridUiState;
|
|
15
17
|
readOnly: boolean;
|
|
@@ -1,95 +1,98 @@
|
|
|
1
1
|
import { getCellValue as e, isCellEditable as t } from "../utils/permissions.js";
|
|
2
2
|
import { gridActions as n } from "../model/gridActions.js";
|
|
3
3
|
import { clamp as r } from "../logic/geometry.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { shouldIgnoreGridKeydown as i } from "../logic/domGuards.js";
|
|
5
|
+
import { applyClipboardMatrixToRows as a, buildClipboardCellEdits as o, joinTsvRow as s, parseClipboardText as c, serializeSelectionToTsv as l, writeTextToClipboard as u } from "../utils/clipboard.js";
|
|
6
|
+
import { resolvePasteTargetViewIndexes as d } from "../logic/labelRows.js";
|
|
6
7
|
//#region src/controllers/clipboardController.ts
|
|
7
|
-
var
|
|
8
|
+
var f = (e, t, n) => {
|
|
8
9
|
if (t === 0 || n === 0 || e?.type !== "cell") return !1;
|
|
9
10
|
let { start: r, end: i } = e.range, a = Math.min(r.row, i.row), o = Math.min(r.col, i.col), s = Math.max(r.row, i.row), c = Math.max(r.col, i.col);
|
|
10
11
|
return a === 0 && o === 0 && s === t - 1 && c === n - 1;
|
|
11
|
-
},
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
},
|
|
12
|
+
}, p = () => {
|
|
13
|
+
let p = null, m = (e) => {
|
|
14
|
+
p = e;
|
|
15
|
+
}, h = (e) => {
|
|
15
16
|
let { isRowExportable: t, rowModel: n } = e;
|
|
16
17
|
if (t) return (e, r) => t(e, {
|
|
17
18
|
viewRowIndex: r,
|
|
18
19
|
rowKey: n.getRowKey(r) ?? r
|
|
19
20
|
});
|
|
20
|
-
},
|
|
21
|
+
}, g = (t) => {
|
|
21
22
|
let { rowModel: n, visibleColumns: r } = t, i = n.getRowCount();
|
|
22
23
|
if (i === 0 || r.length === 0) return "";
|
|
23
|
-
let a =
|
|
24
|
+
let a = h(t), o = [];
|
|
24
25
|
for (let t = 0; t < i; t += 1) {
|
|
25
26
|
let i = n.getRow(t);
|
|
26
27
|
if (!i || a && !a(i, t)) continue;
|
|
27
|
-
let
|
|
28
|
+
let c = r.map((t) => {
|
|
28
29
|
let n = e(i, t);
|
|
29
30
|
return t.formatClipboardValue ? t.formatClipboardValue(n, i) : String(n ?? "");
|
|
30
31
|
});
|
|
31
|
-
o.push(s
|
|
32
|
+
o.push(s(c));
|
|
32
33
|
}
|
|
33
34
|
return o.join("\n");
|
|
34
35
|
};
|
|
35
36
|
return {
|
|
36
|
-
update:
|
|
37
|
+
update: m,
|
|
37
38
|
handleCopy: async () => {
|
|
38
|
-
if (
|
|
39
|
-
let e =
|
|
40
|
-
i && await
|
|
39
|
+
if (p === null) return;
|
|
40
|
+
let e = p, { rowModel: t, visibleColumns: n, uiState: r } = e, i = f(r.selection, t.getRowCount(), n.length) ? g(e) : l(t.getRow, t.getRowCount(), n, r.selection, h(e));
|
|
41
|
+
i && await u(i);
|
|
41
42
|
},
|
|
42
43
|
handlePaste: (e) => {
|
|
43
|
-
if (
|
|
44
|
-
let { rows: s, rowModel:
|
|
45
|
-
if (
|
|
46
|
-
let
|
|
47
|
-
if (!
|
|
44
|
+
if (p === null) return;
|
|
45
|
+
let { rows: s, rowModel: l, columns: u, visibleColumns: f, uiState: m, readOnly: h, canEditCell: g, createRow: _, createOverflowColumn: v, onRowsChange: y, onColumnsChange: b, applyServerSideCellEdits: x, dispatch: S } = p;
|
|
46
|
+
if (m.editingCell || i(e.target ?? null) || h || !y && !x || !m.activeCell) return;
|
|
47
|
+
let C = e.clipboardData?.getData("text/plain") ?? "";
|
|
48
|
+
if (!C) return;
|
|
48
49
|
e.preventDefault();
|
|
49
|
-
let
|
|
50
|
-
if (
|
|
51
|
-
let
|
|
52
|
-
if (
|
|
53
|
-
let
|
|
54
|
-
if (
|
|
55
|
-
let e =
|
|
56
|
-
readOnly:
|
|
57
|
-
canEditCell:
|
|
58
|
-
},
|
|
50
|
+
let w = c(C);
|
|
51
|
+
if (w.length === 0) return;
|
|
52
|
+
let T = w.reduce((e, t) => Math.max(e, t.length), 0);
|
|
53
|
+
if (T === 0) return;
|
|
54
|
+
let E = m.activeCell.row, D = m.activeCell.col, O = l.getLabelRow === void 0 ? null : d(l, E, w.length), k = (e) => O ? O[e - E] : e, A = O ? O[O.length - 1] : m.activeCell.row + Math.max(w.length - 1, 0);
|
|
55
|
+
if (x) {
|
|
56
|
+
let e = o((e) => l.getRow(k(e)), f, w, E, D, (e, n, r, i) => t({
|
|
57
|
+
readOnly: h,
|
|
58
|
+
canEditCell: g
|
|
59
|
+
}, k(e), n, r, i)).map((e) => ({
|
|
59
60
|
...e,
|
|
60
|
-
viewIndex:
|
|
61
|
+
viewIndex: k(e.viewIndex)
|
|
61
62
|
}));
|
|
62
|
-
e.length > 0 &&
|
|
63
|
-
let i = r(
|
|
64
|
-
|
|
63
|
+
e.length > 0 && x(e);
|
|
64
|
+
let i = r(A, 0, Math.max(l.getRowCount() - 1, 0)), a = r(m.activeCell.col + Math.max(T - 1, 0), 0, Math.max(f.length - 1, 0));
|
|
65
|
+
S(n.startSelection(m.activeCell)), S(n.updateSelection({
|
|
65
66
|
row: i,
|
|
66
|
-
col:
|
|
67
|
-
})),
|
|
67
|
+
col: a
|
|
68
|
+
})), S(n.endSelection()), S(n.activateCell(m.activeCell));
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
70
|
-
if (!
|
|
71
|
-
let
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
if (!y || l.getSourceIndex(E) === void 0) return;
|
|
72
|
+
let j = m.activeCell.col, M = [...s], N = [...f], P = l.getRowCount(), F = M.length, I = (e) => {
|
|
73
|
+
let t = k(e);
|
|
74
|
+
return t < P ? l.getSourceIndex(t) : F + (t - P);
|
|
75
|
+
}, L = Math.max(A + 1 - P, 0), R = M.length + L;
|
|
76
|
+
if (R > M.length && _) for (; M.length < R;) M.push(_());
|
|
77
|
+
let z = j + T;
|
|
78
|
+
if (z > N.length && b && v) {
|
|
79
|
+
let e = [];
|
|
80
|
+
for (; N.length < z;) {
|
|
81
|
+
let t = v(N.length);
|
|
82
|
+
N.push(t), e.push(t);
|
|
83
|
+
}
|
|
84
|
+
b(u ? [...u, ...e] : N);
|
|
82
85
|
}
|
|
83
|
-
let
|
|
84
|
-
readOnly:
|
|
85
|
-
canEditCell:
|
|
86
|
-
}, e, n, r, i)),
|
|
87
|
-
|
|
88
|
-
row:
|
|
89
|
-
col:
|
|
90
|
-
})),
|
|
86
|
+
let B = a(M, I, N, w, E, j, (e, n, r, i) => t({
|
|
87
|
+
readOnly: h,
|
|
88
|
+
canEditCell: g
|
|
89
|
+
}, e, n, r, i)), V = r(A, 0, Math.max(Math.max(l.getRowCount() - 1, 0), A)), H = r(m.activeCell.col + Math.max((w[0]?.length ?? 1) - 1, 0), 0, Math.max(Math.max(N.length - 1, 0), j + T - 1));
|
|
90
|
+
y(B), S(n.startSelection(m.activeCell)), S(n.updateSelection({
|
|
91
|
+
row: V,
|
|
92
|
+
col: H
|
|
93
|
+
})), S(n.endSelection()), S(n.activateCell(m.activeCell));
|
|
91
94
|
}
|
|
92
95
|
};
|
|
93
96
|
};
|
|
94
97
|
//#endregion
|
|
95
|
-
export {
|
|
98
|
+
export { f as computeIsWholeGridSelected, p as createClipboardController };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { gridActions } from '../model/gridActions';
|
|
2
|
-
import type { AutoSizeColumnsMode, GridColumn, RowModel } from '../model/gridTypes.unbound';
|
|
1
|
+
import { gridActions } from '../model/gridActions.js';
|
|
2
|
+
import type { AutoSizeColumnsMode, GridColumn, RowModel } from '../model/gridTypes.unbound.js';
|
|
3
3
|
type ReadonlyRef<V> = {
|
|
4
4
|
readonly current: V;
|
|
5
5
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { GridColumn, GridColumnPinned, GridResolvedSlot } from '../model/gridTypes.unbound';
|
|
2
|
-
import { type ColumnPane, type GridPaneLayout } from '../logic/geometry';
|
|
1
|
+
import type { GridColumn, GridColumnPinned, GridResolvedSlot } from '../model/gridTypes.unbound.js';
|
|
2
|
+
import { type ColumnPane, type GridPaneLayout } from '../logic/geometry.js';
|
|
3
3
|
type ApplyColumnOrderAndPin = (orderedKeys: string[], pinOverride?: Map<string, GridColumnPinned | undefined>) => void;
|
|
4
4
|
export declare function computeHeaderReorderedKeys<T>(columns: GridColumn<T>[], draggedKey: string, targetPane: ColumnPane, slotInTargetVisible: number): string[] | null;
|
|
5
5
|
type ReadonlyRef<V> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("./popoverSupport.cjs");var n=200,r=8,i=6,a=289,o=()=>{let o=null,s=e.createValueStore({columnKey:null,layout:null}),c={current:null},l=null,u=null,d=null,f=null,p=e=>{let t=s.getSnapshot(),n=t.layout;n===e||n!==null&&e!==null&&n.top===e.top&&n.left===e.left&&n.width===e.width&&n.maxHeight===e.maxHeight||s.setSnapshot({...t,layout:e})},m=()=>{f!==null&&(cancelAnimationFrame(f),f=null),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("./popoverSupport.cjs");var n=200,r=8,i=6,a=289,o=()=>{let o=null,s=e.createValueStore({columnKey:null,layout:null}),c={current:null},l=null,u=null,d=null,f=null,p=e=>{let t=s.getSnapshot(),n=t.layout;n===e||n!==null&&e!==null&&n.top===e.top&&n.left===e.left&&n.width===e.width&&n.maxHeight===e.maxHeight||s.setSnapshot({...t,layout:e})},m=()=>{f!==null&&(cancelAnimationFrame(f),f=null),v.detach(),s.setSnapshot({columnKey:null,layout:null})},h=()=>{if(s.getSnapshot().columnKey===null){p(null);return}let e,t,o,d=c.current,f=d?d.scrollHeight+(d.offsetHeight-d.clientHeight):a;if(l){if(!l.isConnected){l=null,m();return}let r=l.getBoundingClientRect();t=r.right-n,e=r.bottom+i,o=r.top-f-i}else if(u)t=u.x,e=u.y,o=u.y-f;else{p(null);return}t=Math.max(r,t),t=Math.min(t,window.innerWidth-n-r);let h=window.innerHeight-r;e+f>h&&o>=r&&(e=o),e=Math.max(r,e);let g=h-e;p({top:e,left:t,width:n,maxHeight:f>g?Math.max(g,0):void 0})},g=e=>{m(),l=null,u=null,o!==null&&e&&t.restoreGridFocus(o.gridRootRef)},_=()=>g(!0),v=t.createPopoverWindowBindings({onResize:h,onScroll:()=>{if(u){_();return}h()},isInside:e=>c.current?.contains(e)===!0||l?.contains(e)===!0,onOutsidePointerDown:e=>g(o!==null&&t.isInsideGridRoot(o.gridRootRef,e)),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),_())}}),y=e=>{s.setSnapshot({...s.getSnapshot(),columnKey:e}),h(),f!==null&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{f=null,h()}),v.attach()},b=(e,n)=>{t.blurForPopover(o?.gridRootRef.current??null),l=n,u=null,y(e.key)};return{update:e=>{o=e},subscribe:s.subscribe,getSnapshot:s.getSnapshot,panelRef:c,openFromButton:(e,t)=>{if(t.preventDefault(),t.stopPropagation(),!o?.enableColumnMenu||t.button!==0)return;let n=t.currentTarget;if(s.getSnapshot().columnKey===e.key&&l===n){_();return}if(t.pointerType===`touch`){d=n;return}b(e,n)},openFromButtonClick:(e,t)=>{let n=d;d=null,!(!o?.enableColumnMenu||n!==t.currentTarget)&&(t.preventDefault(),t.stopPropagation(),b(e,t.currentTarget))},openFromContextMenu:(e,n)=>{o?.enableColumnMenu&&(n.preventDefault(),n.stopPropagation(),t.blurForPopover(o.gridRootRef.current),l=null,u={x:n.clientX,y:n.clientY},y(e.key))},close:_,dispose:()=>{f!==null&&(cancelAnimationFrame(f),f=null),v.detach()}}};exports.createColumnMenuController=o;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { GridColumn } from '../model/gridTypes.unbound';
|
|
2
|
-
import { type ReadonlyElementRef } from './popoverSupport';
|
|
1
|
+
import type { GridColumn } from '../model/gridTypes.unbound.js';
|
|
2
|
+
import { type ReadonlyElementRef } from './popoverSupport.js';
|
|
3
3
|
export type ColumnMenuLayout = {
|
|
4
4
|
top: number;
|
|
5
5
|
left: number;
|
|
@@ -1,110 +1,110 @@
|
|
|
1
1
|
import { createValueStore as e } from "../logic/valueStore.js";
|
|
2
|
-
import { blurForPopover as t, createPopoverWindowBindings as n,
|
|
2
|
+
import { blurForPopover as t, createPopoverWindowBindings as n, isInsideGridRoot as r, restoreGridFocus as i } from "./popoverSupport.js";
|
|
3
3
|
//#region src/controllers/columnMenuController.ts
|
|
4
|
-
var
|
|
5
|
-
let
|
|
4
|
+
var a = 200, o = 8, s = 6, c = 289, l = () => {
|
|
5
|
+
let l = null, u = e({
|
|
6
6
|
columnKey: null,
|
|
7
7
|
layout: null
|
|
8
|
-
}),
|
|
9
|
-
let t =
|
|
10
|
-
n === e || n !== null && e !== null && n.top === e.top && n.left === e.left && n.width === e.width && n.maxHeight === e.maxHeight ||
|
|
8
|
+
}), d = { current: null }, f = null, p = null, m = null, h = null, g = (e) => {
|
|
9
|
+
let t = u.getSnapshot(), n = t.layout;
|
|
10
|
+
n === e || n !== null && e !== null && n.top === e.top && n.left === e.left && n.width === e.width && n.maxHeight === e.maxHeight || u.setSnapshot({
|
|
11
11
|
...t,
|
|
12
12
|
layout: e
|
|
13
13
|
});
|
|
14
|
-
},
|
|
15
|
-
|
|
14
|
+
}, _ = () => {
|
|
15
|
+
h !== null && (cancelAnimationFrame(h), h = null), x.detach(), u.setSnapshot({
|
|
16
16
|
columnKey: null,
|
|
17
17
|
layout: null
|
|
18
18
|
});
|
|
19
|
-
},
|
|
20
|
-
if (
|
|
21
|
-
|
|
19
|
+
}, v = () => {
|
|
20
|
+
if (u.getSnapshot().columnKey === null) {
|
|
21
|
+
g(null);
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
let e, t, n, r =
|
|
25
|
-
if (
|
|
26
|
-
if (!
|
|
27
|
-
|
|
24
|
+
let e, t, n, r = d.current, i = r ? r.scrollHeight + (r.offsetHeight - r.clientHeight) : c;
|
|
25
|
+
if (f) {
|
|
26
|
+
if (!f.isConnected) {
|
|
27
|
+
f = null, _();
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
let r =
|
|
31
|
-
t = r.right -
|
|
32
|
-
} else if (
|
|
30
|
+
let r = f.getBoundingClientRect();
|
|
31
|
+
t = r.right - a, e = r.bottom + s, n = r.top - i - s;
|
|
32
|
+
} else if (p) t = p.x, e = p.y, n = p.y - i;
|
|
33
33
|
else {
|
|
34
|
-
|
|
34
|
+
g(null);
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
t = Math.max(
|
|
38
|
-
let
|
|
39
|
-
e +
|
|
40
|
-
let m =
|
|
41
|
-
|
|
37
|
+
t = Math.max(o, t), t = Math.min(t, window.innerWidth - a - o);
|
|
38
|
+
let l = window.innerHeight - o;
|
|
39
|
+
e + i > l && n >= o && (e = n), e = Math.max(o, e);
|
|
40
|
+
let m = l - e;
|
|
41
|
+
g({
|
|
42
42
|
top: e,
|
|
43
43
|
left: t,
|
|
44
|
-
width:
|
|
45
|
-
maxHeight:
|
|
44
|
+
width: a,
|
|
45
|
+
maxHeight: i > m ? Math.max(m, 0) : void 0
|
|
46
46
|
});
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
}, y = n({
|
|
50
|
-
onResize:
|
|
47
|
+
}, y = (e) => {
|
|
48
|
+
_(), f = null, p = null, l !== null && e && i(l.gridRootRef);
|
|
49
|
+
}, b = () => y(!0), x = n({
|
|
50
|
+
onResize: v,
|
|
51
51
|
onScroll: () => {
|
|
52
|
-
if (
|
|
53
|
-
|
|
52
|
+
if (p) {
|
|
53
|
+
b();
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
v();
|
|
57
57
|
},
|
|
58
|
-
isInside: (e) =>
|
|
59
|
-
onOutsidePointerDown:
|
|
58
|
+
isInside: (e) => d.current?.contains(e) === !0 || f?.contains(e) === !0,
|
|
59
|
+
onOutsidePointerDown: (e) => y(l !== null && r(l.gridRootRef, e)),
|
|
60
60
|
onKeyDown: (e) => {
|
|
61
|
-
e.key === "Escape" && (e.preventDefault(),
|
|
61
|
+
e.key === "Escape" && (e.preventDefault(), b());
|
|
62
62
|
}
|
|
63
|
-
}),
|
|
64
|
-
|
|
65
|
-
...
|
|
63
|
+
}), S = (e) => {
|
|
64
|
+
u.setSnapshot({
|
|
65
|
+
...u.getSnapshot(),
|
|
66
66
|
columnKey: e
|
|
67
|
-
}),
|
|
68
|
-
|
|
69
|
-
}),
|
|
70
|
-
},
|
|
71
|
-
t(
|
|
67
|
+
}), v(), h !== null && cancelAnimationFrame(h), h = requestAnimationFrame(() => {
|
|
68
|
+
h = null, v();
|
|
69
|
+
}), x.attach();
|
|
70
|
+
}, C = (e, n) => {
|
|
71
|
+
t(l?.gridRootRef.current ?? null), f = n, p = null, S(e.key);
|
|
72
72
|
};
|
|
73
73
|
return {
|
|
74
74
|
update: (e) => {
|
|
75
|
-
|
|
75
|
+
l = e;
|
|
76
76
|
},
|
|
77
|
-
subscribe:
|
|
78
|
-
getSnapshot:
|
|
79
|
-
panelRef:
|
|
77
|
+
subscribe: u.subscribe,
|
|
78
|
+
getSnapshot: u.getSnapshot,
|
|
79
|
+
panelRef: d,
|
|
80
80
|
openFromButton: (e, t) => {
|
|
81
|
-
if (t.preventDefault(), t.stopPropagation(), !
|
|
81
|
+
if (t.preventDefault(), t.stopPropagation(), !l?.enableColumnMenu || t.button !== 0) return;
|
|
82
82
|
let n = t.currentTarget;
|
|
83
|
-
if (
|
|
84
|
-
|
|
83
|
+
if (u.getSnapshot().columnKey === e.key && f === n) {
|
|
84
|
+
b();
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
87
|
if (t.pointerType === "touch") {
|
|
88
|
-
|
|
88
|
+
m = n;
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
C(e, n);
|
|
92
92
|
},
|
|
93
93
|
openFromButtonClick: (e, t) => {
|
|
94
|
-
let n =
|
|
95
|
-
|
|
94
|
+
let n = m;
|
|
95
|
+
m = null, !(!l?.enableColumnMenu || n !== t.currentTarget) && (t.preventDefault(), t.stopPropagation(), C(e, t.currentTarget));
|
|
96
96
|
},
|
|
97
97
|
openFromContextMenu: (e, n) => {
|
|
98
|
-
|
|
98
|
+
l?.enableColumnMenu && (n.preventDefault(), n.stopPropagation(), t(l.gridRootRef.current), f = null, p = {
|
|
99
99
|
x: n.clientX,
|
|
100
100
|
y: n.clientY
|
|
101
|
-
},
|
|
101
|
+
}, S(e.key));
|
|
102
102
|
},
|
|
103
|
-
close:
|
|
103
|
+
close: b,
|
|
104
104
|
dispose: () => {
|
|
105
|
-
|
|
105
|
+
h !== null && (cancelAnimationFrame(h), h = null), x.detach();
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
};
|
|
109
109
|
//#endregion
|
|
110
|
-
export {
|
|
110
|
+
export { l as createColumnMenuController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("./popoverSupport.cjs");var n=220,r=8,i=34,a=16,o=()=>{let o=null,s=e.createValueStore({state:null,layout:null}),c={current:null},l=null,u=0,d=e=>{let t=s.getSnapshot();t.layout===e||t.layout!==null&&e!==null&&t.layout.top===e.top&&t.layout.left===e.left&&t.layout.width===e.width||s.setSnapshot({...t,layout:e})},f=()=>{if(!l){d(null);return}let e=u*i+a,t=l.x,o=l.y,s=l.y-e;t=Math.max(r,t),t=Math.min(t,window.innerWidth-n-r),o+e>window.innerHeight-r&&(o=s),o=Math.max(r,o),d({top:o,left:t,width:n})},p=
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("./popoverSupport.cjs");var n=220,r=8,i=34,a=16,o=()=>{let o=null,s=e.createValueStore({state:null,layout:null}),c={current:null},l=null,u=0,d=e=>{let t=s.getSnapshot();t.layout===e||t.layout!==null&&e!==null&&t.layout.top===e.top&&t.layout.left===e.left&&t.layout.width===e.width||s.setSnapshot({...t,layout:e})},f=()=>{if(!l){d(null);return}let e=u*i+a,t=l.x,o=l.y,s=l.y-e;t=Math.max(r,t),t=Math.min(t,window.innerWidth-n-r),o+e>window.innerHeight-r&&(o=s),o=Math.max(r,o),d({top:o,left:t,width:n})},p=e=>{s.setSnapshot({state:null,layout:null}),l=null,u=0,h.detach(),o!==null&&e&&t.restoreGridFocus(o.gridRootRef)},m=()=>p(!0),h=t.createPopoverWindowBindings({onResize:f,onScroll:m,isInside:e=>c.current?.contains(e)===!0,onOutsidePointerDown:e=>p(o!==null&&t.isInsideGridRoot(o.gridRootRef,e)),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),m())}});return{update:e=>{o=e},subscribe:s.subscribe,getSnapshot:s.getSnapshot,panelRef:c,open:(e,n)=>{t.blurForPopover(o?.gridRootRef.current??null),l={x:e.clientX,y:e.clientY},u=n.length,s.setSnapshot({...s.getSnapshot(),state:{params:e,items:n}}),f(),h.attach()},close:m,dispose:()=>{h.detach()}}};exports.createContextMenuController=o;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { GridContextMenuItem, GridContextMenuParams } from '../model/gridTypes.unbound';
|
|
2
|
-
import { type ReadonlyElementRef } from './popoverSupport';
|
|
1
|
+
import type { GridContextMenuItem, GridContextMenuParams } from '../model/gridTypes.unbound.js';
|
|
2
|
+
import { type ReadonlyElementRef } from './popoverSupport.js';
|
|
3
3
|
export type CellContextMenuLayout = {
|
|
4
4
|
top: number;
|
|
5
5
|
left: number;
|
|
@@ -1,65 +1,65 @@
|
|
|
1
1
|
import { createValueStore as e } from "../logic/valueStore.js";
|
|
2
|
-
import { blurForPopover as t, createPopoverWindowBindings as n,
|
|
2
|
+
import { blurForPopover as t, createPopoverWindowBindings as n, isInsideGridRoot as r, restoreGridFocus as i } from "./popoverSupport.js";
|
|
3
3
|
//#region src/controllers/contextMenuController.ts
|
|
4
|
-
var
|
|
5
|
-
let
|
|
4
|
+
var a = 220, o = 8, s = 34, c = 16, l = () => {
|
|
5
|
+
let l = null, u = e({
|
|
6
6
|
state: null,
|
|
7
7
|
layout: null
|
|
8
|
-
}),
|
|
9
|
-
let t =
|
|
10
|
-
t.layout === e || t.layout !== null && e !== null && t.layout.top === e.top && t.layout.left === e.left && t.layout.width === e.width ||
|
|
8
|
+
}), d = { current: null }, f = null, p = 0, m = (e) => {
|
|
9
|
+
let t = u.getSnapshot();
|
|
10
|
+
t.layout === e || t.layout !== null && e !== null && t.layout.top === e.top && t.layout.left === e.left && t.layout.width === e.width || u.setSnapshot({
|
|
11
11
|
...t,
|
|
12
12
|
layout: e
|
|
13
13
|
});
|
|
14
|
-
},
|
|
15
|
-
if (!
|
|
16
|
-
|
|
14
|
+
}, h = () => {
|
|
15
|
+
if (!f) {
|
|
16
|
+
m(null);
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
let e =
|
|
20
|
-
t = Math.max(
|
|
19
|
+
let e = p * s + c, t = f.x, n = f.y, r = f.y - e;
|
|
20
|
+
t = Math.max(o, t), t = Math.min(t, window.innerWidth - a - o), n + e > window.innerHeight - o && (n = r), n = Math.max(o, n), m({
|
|
21
21
|
top: n,
|
|
22
22
|
left: t,
|
|
23
|
-
width:
|
|
23
|
+
width: a
|
|
24
24
|
});
|
|
25
|
-
},
|
|
26
|
-
|
|
25
|
+
}, g = (e) => {
|
|
26
|
+
u.setSnapshot({
|
|
27
27
|
state: null,
|
|
28
28
|
layout: null
|
|
29
|
-
}),
|
|
30
|
-
}, g = n({
|
|
31
|
-
onResize:
|
|
32
|
-
onScroll:
|
|
33
|
-
isInside: (e) =>
|
|
34
|
-
onOutsidePointerDown:
|
|
29
|
+
}), f = null, p = 0, v.detach(), l !== null && e && i(l.gridRootRef);
|
|
30
|
+
}, _ = () => g(!0), v = n({
|
|
31
|
+
onResize: h,
|
|
32
|
+
onScroll: _,
|
|
33
|
+
isInside: (e) => d.current?.contains(e) === !0,
|
|
34
|
+
onOutsidePointerDown: (e) => g(l !== null && r(l.gridRootRef, e)),
|
|
35
35
|
onKeyDown: (e) => {
|
|
36
|
-
e.key === "Escape" && (e.preventDefault(),
|
|
36
|
+
e.key === "Escape" && (e.preventDefault(), _());
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
return {
|
|
40
40
|
update: (e) => {
|
|
41
|
-
|
|
41
|
+
l = e;
|
|
42
42
|
},
|
|
43
|
-
subscribe:
|
|
44
|
-
getSnapshot:
|
|
45
|
-
panelRef:
|
|
43
|
+
subscribe: u.subscribe,
|
|
44
|
+
getSnapshot: u.getSnapshot,
|
|
45
|
+
panelRef: d,
|
|
46
46
|
open: (e, n) => {
|
|
47
|
-
t(
|
|
47
|
+
t(l?.gridRootRef.current ?? null), f = {
|
|
48
48
|
x: e.clientX,
|
|
49
49
|
y: e.clientY
|
|
50
|
-
},
|
|
51
|
-
...
|
|
50
|
+
}, p = n.length, u.setSnapshot({
|
|
51
|
+
...u.getSnapshot(),
|
|
52
52
|
state: {
|
|
53
53
|
params: e,
|
|
54
54
|
items: n
|
|
55
55
|
}
|
|
56
|
-
}),
|
|
56
|
+
}), h(), v.attach();
|
|
57
57
|
},
|
|
58
|
-
close:
|
|
58
|
+
close: _,
|
|
59
59
|
dispose: () => {
|
|
60
|
-
|
|
60
|
+
v.detach();
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
64
|
//#endregion
|
|
65
|
-
export {
|
|
65
|
+
export { l as createContextMenuController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs"),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../logic/detailRow.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/geometry.cjs"),i=require("../logic/editorValues.cjs"),a=require("../logic/validation.cjs");var o=()=>{let o=null,s=null,c=(e,t)=>{let n=e.visibleColumns[t.col];return!n||t.row<0||t.row>=e.rowModel.getRowCount()||e.rowModel.getRow(t.row)===void 0?null:{rowKey:e.rowModel.getRowKey(t.row),columnKey:n.key}},l=(e,t)=>{let n=e.visibleColumns.findIndex(e=>e.key===t.columnKey);if(n<0)return null;let r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1)if(e.rowModel.getRow(i)!==void 0&&Object.is(e.rowModel.getRowKey(i),t.rowKey))return{row:i,col:n};return null},u=e=>{o=e;let t=e.uiState.editingCell;if(!t){s=null;return}let r=c(e,t);if(s!==null&&r!==null&&Object.is(r.rowKey,s.rowKey)&&r.columnKey===s.columnKey){s={...s,cell:t};return}let i=s!==null&&s.cell.row===t.row&&s.cell.col===t.col;if(s===null||!i){s=r?{...r,cell:t}:null;return}let a=l(e,s);a?(s={...s,cell:a},e.dispatch(n.gridActions.startEdit(a))):(s=null,e.dispatch(n.gridActions.stopEdit()))},d=e=>{o!==null&&(o.dispatch(n.gridActions.startSelection(e)),o.dispatch(n.gridActions.endSelection()),o.dispatch(n.gridActions.activateCell(e)))},f=(e,t)=>{o!==null&&(o.setEditorInitialValue(t),o.dispatch(n.gridActions.startEdit(e)))},p=e=>{let n=o;n!==null&&requestAnimationFrame(()=>{if(t.isFocusInsideDetailCard()||n.gridRootRef.current?.focus(),e!==null&&o!==null){let t=o.rowModel.getRowCount(),n=o.visibleColumns.length;d({row:r.clamp(e.row,0,Math.max(t-1,0)),col:r.clamp(e.col,0,Math.max(n-1,0))})}n.editorActionGuardRef.current=!1})};return{update:u,activateSingleCell:d,startEditWithValue:f,commitEdit:(t,r)=>{if(o===null)return{status:`noop`};let{uiState:s,visibleColumns:c,rowModel:l,rows:u,applyServerSideCellEdits:d,onRowsChange:f,dispatch:m,editorActionGuardRef:h}=o;if(h.current||!s.editingCell)return{status:`noop`};let g=s.editingCell,_=r===`down`?{row:g.row+1,col:g.col}:r===`up`?{row:g.row-1,col:g.col}:r===`right`?{row:g.row,col:g.col+1}:r===`left`?{row:g.row,col:g.col-1}:g,v=c[g.col],y=l.getSourceIndex(g.row),b=d?l.getRow(g.row):u[y];if(!v||!b)return m(n.gridActions.stopEdit()),{status:`noop`};if(!e.isCellEditable({readOnly:o.readOnly,canEditCell:o.canEditCell},g.row,g.col,b,v))return h.current=!0,m(n.gridActions.stopEdit()),p(null),{status:`noop`};if(d){let e=i.parseCommittedValue(v,t,b),n=a.decideCellWrite(v,b,e);if(n.action===`reject`)return{status:`rejected`,message:n.message};d([{viewIndex:g.row,column:v,value:e}])}else if(f){let e=i.parseCommittedValue(v,t,b),n=a.decideCellWrite(v,b,e);if(n.action===`reject`)return{status:`rejected`,message:n.message};f(i.writeRowsCell(u,y,v,e))}return h.current=!0,p(_),m(n.gridActions.stopEdit()),{status:`committed`}},cancelEdit:()=>{o===null||o.editorActionGuardRef.current||(o.editorActionGuardRef.current=!0,o.dispatch(n.gridActions.stopEdit()),p(null))}}};exports.createEditController=o;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type GridUiAction } from '../model/gridActions';
|
|
2
|
-
import type { CellCoord, EditorCommitDirection, EditorCommitResult, GridColumn, GridUiState, RowModel } from '../model/gridTypes.unbound';
|
|
3
|
-
import type { ServerSideCellEditInput } from '../logic/serverSideEdits';
|
|
1
|
+
import { type GridUiAction } from '../model/gridActions.js';
|
|
2
|
+
import type { CellCoord, EditorCommitDirection, EditorCommitResult, GridColumn, GridUiState, RowModel, SpreadsheetGridProps } from '../model/gridTypes.unbound.js';
|
|
3
|
+
import type { ServerSideCellEditInput } from '../logic/serverSideEdits.js';
|
|
4
4
|
export type EditControllerArgs<T extends object> = {
|
|
5
5
|
uiState: GridUiState;
|
|
6
6
|
rows: T[];
|
|
@@ -16,6 +16,8 @@ export type EditControllerArgs<T extends object> = {
|
|
|
16
16
|
editorActionGuardRef: {
|
|
17
17
|
current: boolean;
|
|
18
18
|
};
|
|
19
|
+
readOnly?: boolean;
|
|
20
|
+
canEditCell?: SpreadsheetGridProps<T>['canEditCell'];
|
|
19
21
|
};
|
|
20
22
|
export type EditController<T extends object> = {
|
|
21
23
|
update: (args: EditControllerArgs<T>) => void;
|