@ishibashi0112/spreadsheet-grid-core 1.10.0 → 1.11.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/changeHighlightController.cjs +1 -1
- package/dist/controllers/changeHighlightController.js +69 -71
- package/dist/controllers/changeTracker.cjs +1 -1
- package/dist/controllers/changeTracker.js +229 -228
- package/dist/controllers/clipboardController.cjs +2 -2
- package/dist/controllers/clipboardController.js +162 -152
- package/dist/controllers/dateTimeEditorController.cjs +1 -0
- package/dist/controllers/dateTimeEditorController.d.ts +62 -0
- package/dist/controllers/dateTimeEditorController.js +201 -0
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.js +202 -193
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.js +151 -150
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +1 -0
- package/dist/controllers/findController.js +27 -25
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.js +146 -145
- package/dist/controllers/multiSelectEditorController.cjs +1 -0
- package/dist/controllers/multiSelectEditorController.d.ts +54 -0
- package/dist/controllers/multiSelectEditorController.js +200 -0
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.js +155 -154
- package/dist/controllers/selectOptionsCollector.cjs +1 -1
- package/dist/controllers/selectOptionsCollector.d.ts +2 -1
- package/dist/controllers/selectOptionsCollector.js +53 -52
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.js +6 -1
- package/dist/engine/cellCommands.cjs +1 -1
- package/dist/engine/cellCommands.js +65 -64
- package/dist/engine/excelShortcutCommands.cjs +1 -1
- package/dist/engine/excelShortcutCommands.js +148 -123
- package/dist/engine/exportCommands.cjs +1 -1
- package/dist/engine/exportCommands.js +3 -1
- package/dist/engine/newRowController.cjs +1 -1
- package/dist/engine/newRowController.js +69 -68
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +11 -0
- package/dist/logic/cellText.cjs +1 -0
- package/dist/logic/cellText.d.ts +3 -0
- package/dist/logic/cellText.js +11 -0
- package/dist/logic/cellValueTransfer.cjs +1 -0
- package/dist/logic/cellValueTransfer.d.ts +8 -0
- package/dist/logic/cellValueTransfer.js +11 -0
- package/dist/logic/changeTracking.cjs +1 -1
- package/dist/logic/changeTracking.js +88 -85
- package/dist/logic/clearCells.cjs +1 -1
- package/dist/logic/clearCells.js +1 -1
- package/dist/logic/columnAutosize.cjs +1 -1
- package/dist/logic/columnAutosize.js +133 -115
- package/dist/logic/columnEditor.cjs +1 -0
- package/dist/logic/columnEditor.d.ts +26 -0
- package/dist/logic/columnEditor.js +15 -0
- package/dist/logic/dateTimeEditor.cjs +1 -0
- package/dist/logic/dateTimeEditor.d.ts +54 -0
- package/dist/logic/dateTimeEditor.js +100 -0
- package/dist/logic/dateTimeValues.cjs +1 -0
- package/dist/logic/dateTimeValues.d.ts +19 -0
- package/dist/logic/dateTimeValues.js +42 -0
- package/dist/logic/editorValues.cjs +1 -1
- package/dist/logic/editorValues.d.ts +4 -4
- package/dist/logic/editorValues.js +60 -49
- package/dist/logic/exportCsv.cjs +2 -2
- package/dist/logic/exportCsv.d.ts +2 -1
- package/dist/logic/exportCsv.js +17 -17
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +2 -1
- package/dist/logic/exportData.js +26 -26
- package/dist/logic/featureWarnings.cjs +1 -1
- package/dist/logic/featureWarnings.js +19 -10
- package/dist/logic/fillHandle.cjs +1 -1
- package/dist/logic/fillHandle.js +147 -100
- package/dist/logic/fillSeries.cjs +1 -1
- package/dist/logic/fillSeries.d.ts +2 -0
- package/dist/logic/fillSeries.js +104 -64
- package/dist/logic/filterSummary.cjs +1 -1
- package/dist/logic/filterSummary.js +38 -37
- package/dist/logic/filtering.cjs +1 -1
- package/dist/logic/filtering.js +160 -118
- package/dist/logic/find.cjs +1 -1
- package/dist/logic/find.d.ts +6 -2
- package/dist/logic/find.js +36 -20
- package/dist/logic/gridAsk.cjs +3 -3
- package/dist/logic/gridAsk.js +216 -211
- package/dist/logic/grouping.cjs +1 -1
- package/dist/logic/grouping.js +34 -38
- package/dist/logic/imeInput.cjs +1 -1
- package/dist/logic/imeInput.d.ts +1 -1
- package/dist/logic/imeInput.js +21 -20
- package/dist/logic/inferFilterType.cjs +1 -1
- package/dist/logic/inferFilterType.js +1 -1
- package/dist/logic/localeText.cjs +1 -1
- package/dist/logic/localeText.d.ts +3 -0
- package/dist/logic/localeText.js +3 -0
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +12 -0
- package/dist/logic/localeTextFeatures.js +17 -7
- package/dist/logic/multiSelect.cjs +1 -0
- package/dist/logic/multiSelect.d.ts +55 -0
- package/dist/logic/multiSelect.js +150 -0
- package/dist/logic/newRow.cjs +1 -1
- package/dist/logic/newRow.js +12 -11
- package/dist/logic/rowDragTarget.cjs +1 -1
- package/dist/logic/rowDragTarget.js +21 -23
- package/dist/logic/selectEditorState.cjs +1 -1
- package/dist/logic/selectEditorState.d.ts +1 -0
- package/dist/logic/selectEditorState.js +1 -1
- package/dist/logic/selectFillRow.cjs +1 -1
- package/dist/logic/selectFillRow.js +19 -18
- package/dist/logic/selectLabels.cjs +1 -1
- package/dist/logic/selectLabels.d.ts +4 -2
- package/dist/logic/selectLabels.js +36 -32
- package/dist/logic/selectOptions.cjs +1 -1
- package/dist/logic/selectOptions.d.ts +3 -2
- package/dist/logic/selectOptions.js +37 -16
- package/dist/logic/selectionAggregates.cjs +1 -1
- package/dist/logic/selectionAggregates.js +1 -1
- package/dist/logic/sorting.cjs +1 -1
- package/dist/logic/sorting.js +108 -102
- package/dist/logic/validation.cjs +1 -1
- package/dist/logic/validation.d.ts +1 -1
- package/dist/logic/validation.js +28 -21
- package/dist/model/gridTypes.core.d.ts +116 -8
- package/dist/utils/clipboard.cjs +1 -1
- package/dist/utils/clipboard.d.ts +2 -2
- package/dist/utils/clipboard.js +13 -13
- package/dist/utils/editorVisibleBounds.cjs +1 -1
- package/dist/utils/editorVisibleBounds.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/columnEditor.cjs"),r=require("../logic/detailRow.cjs"),i=require("../logic/geometry.cjs"),a=require("../logic/domGuards.cjs"),o=require("../logic/newRow.cjs"),s=require("./liveUiState.cjs"),c=require("./clipboardController.cjs"),l=require("./escapeClaimController.cjs");var u=10,d=(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},f=e=>d(e,0,1,0),p=e=>r.resolveFirstDataColIndex(e),m=(e,t)=>({row:f(e),col:p(t)}),h=()=>{let r=null,h=e=>{r=e},g=(e,t)=>d(e,t,-1,d(e,t,1,t)),_=e=>{let t=o.getSelectableRowCount(e),n=(t>0?t:e.getRowCount())-1;return d(e,n,-1,n)},v=(t,n,i)=>{if(r===null)return;let{dispatch:a}=r,o=s.readLiveUiState(r);if(i){let r=o.selection?.type===`cell`?o.selection.range.start:t;a(e.gridActions.startSelection(r)),a(e.gridActions.updateSelection(n)),a(e.gridActions.endSelection()),a(e.gridActions.activateCell(n));return}a(e.gridActions.startSelection(n)),a(e.gridActions.endSelection()),a(e.gridActions.activateCell(n))},y=()=>{if(r===null||s.readLiveUiState(r).activeCell)return!1;let{rowModel:e,visibleColumns:t}=r;if(e.getRowCount()===0||t.length===0)return!0;let n=m(e,t);return v(n,n,!1),!0},b=e=>{let t=r===null?void 0:s.readLiveUiState(r);return e&&t?.selection?.type===`cell`?t.selection.range.end:t?.activeCell??{row:0,col:0}},x=(e,t,n)=>{if(r===null)return;let{rowModel:a,visibleColumns:o}=r,s=a.getRowCount();if(s===0||o.length===0||y())return;let c=b(n),l=i.clamp(c.row+e,0,s-1);l=e===0?g(a,l):d(a,l,e>0?1:-1,c.row);let u={row:l,col:i.clamp(c.col+t,0,o.length-1)};v(c,u,n)},S=(e,t,n)=>{if(r===null)return;let{rowModel:a,visibleColumns:o}=r,c=s.readLiveUiState(r);if(a.getRowCount()===0||o.length===0)return;let l=c.activeCell?b(t):{row:f(a),col:p(o)},u=e(l,a,o),d=i.clamp(u.col,0,o.length-1);v(l,{row:g(a,i.clamp(u.row,0,a.getRowCount()-1)),col:d},t&&c.activeCell!==null);let m=n===void 0?null:r.scrollContainerRef?.current??null,h=o[d]?.pinned;m!==null&&(n===`start`?h===`left`:h===`right`)&&(m.scrollLeft=n===`start`?0:Math.max(m.scrollWidth-m.clientWidth,0))},C=(e,t,n)=>{let a=t.getRowCount(),o=r?.resolvePageRow?r.resolvePageRow(e.row,n):e.row+n*u,s=i.clamp(n>0?Math.max(o,e.row+1):Math.min(o,e.row-1),0,a-1),c=d(t,s,n,-1);return c>=0?c:d(t,s,n>0?-1:1,e.row)};return{update:h,handleKeyDown:async i=>{if(r===null)return;let{rowModel:u,visibleColumns:d,readOnly:m,canEditCell:h,setEditorInitialValue:g,dispatch:v,handleCopy:b,openFind:w,handleCellDoubleClick:T,selectEntireGrid:E,onUndo:D,onRedo:O,onClearSelection:k,enableClearOnDelete:A,onToggleCheckboxCell:j,onToggleGroup:M,onToggleDetailRow:N}=r,P=s.readLiveUiState(r),F=r.getUiState?c.computeIsWholeGridSelected(P.selection,o.getSelectableRowCount(u),d.length):r.isWholeGridSelected;if(a.shouldIgnoreGridKeydown(i.target)||s.isEditingAtEvent(r)||i.isComposing&&a.isImeInputTarget(i.target))return;if((i.ctrlKey||i.metaKey)&&i.key.toLowerCase()===`c`){i.preventDefault(),await b();return}if((i.ctrlKey||i.metaKey)&&!i.altKey&&i.key.toLowerCase()===`x`&&r.handleCut){i.preventDefault(),await r.handleCut();return}if((i.ctrlKey||i.metaKey)&&i.key.toLowerCase()===`f`&&w){i.preventDefault(),w();return}if((i.ctrlKey||i.metaKey)&&i.key.toLowerCase()===`a`){if(i.preventDefault(),F){v(e.gridActions.clearSelection()),v(e.gridActions.activateCell(null));return}E();return}if((i.ctrlKey||i.metaKey)&&!i.isComposing){if(i.key.toLowerCase()===`z`){i.preventDefault(),i.shiftKey?O():D();return}if(i.key.toLowerCase()===`y`&&!i.shiftKey){i.preventDefault(),O();return}}if(r.onShortcutKeyDown?.(i))return;let I=i.ctrlKey||i.metaKey;if((i.key===`ContextMenu`||i.key===`F10`&&i.shiftKey)&&!I&&!i.altKey&&P.activeCell&&r.openContextMenu?.(P.activeCell)){i.preventDefault();return}if((i.key===`ArrowDown`||i.key===`ArrowUp`)&&i.altKey&&i.shiftKey&&!I&&P.activeCell&&r.onToggleTreeRow?.(P.activeCell,i.key===`ArrowDown`)){i.preventDefault();return}if(i.key===`ArrowDown`&&i.altKey&&!I&&!i.shiftKey&&P.activeCell&&r.openColumnMenu?.(P.activeCell.col)){i.preventDefault();return}if(I&&!i.altKey&&(i.key===`ArrowUp`||i.key===`ArrowDown`)){i.preventDefault();let e=i.key===`ArrowDown`;S((t,n)=>({row:e?_(n):f(n),col:t.col}),i.shiftKey);return}if(I&&!i.altKey&&(i.key===`ArrowLeft`||i.key===`ArrowRight`)){i.preventDefault();let e=i.key===`ArrowRight`;S((t,n,r)=>({row:t.row,col:e?r.length-1:p(r)}),i.shiftKey,e?`end`:`start`);return}if((i.key===`Home`||i.key===`End`)&&!i.altKey){i.preventDefault();let e=i.key===`End`;S((t,n,r)=>({row:I?e?_(n):f(n):t.row,col:e?r.length-1:p(r)}),i.shiftKey,e?`end`:`start`);return}if((i.key===`PageDown`||i.key===`PageUp`)&&!I&&!i.altKey){if(i.preventDefault(),y())return;let e=i.key===`PageDown`?1:-1;S((t,n)=>({row:C(t,n,e),col:t.col}),i.shiftKey);return}if(i.key===`ArrowUp`){i.preventDefault(),x(-1,0,i.shiftKey);return}if(i.key===`ArrowDown`){i.preventDefault(),x(1,0,i.shiftKey);return}if(i.key===`ArrowLeft`){i.preventDefault(),x(0,-1,i.shiftKey);return}if(i.key===`ArrowRight`){i.preventDefault(),x(0,1,i.shiftKey);return}if(i.key===`Tab`){if(!P.activeCell&&!i.shiftKey){if(r.rowModel.getRowCount()===0||r.visibleColumns.length===0)return;i.preventDefault(),y();return}let e=P.activeCell?.col??0;if(i.shiftKey?e<=p(r.visibleColumns):e>=r.visibleColumns.length-1){!i.shiftKey&&P.activeCell&&(r.onTabPastLastColumn?.(P.activeCell.row)||r.onTabPastNewRowDraft?.(P.activeCell,o.resolveFirstEditableColIndex(r.visibleColumns,r.readOnly)))&&i.preventDefault();return}i.preventDefault(),x(0,i.shiftKey?-1:1,!1);return}if(i.key===`Escape`){if(P.activeCell&&r.onEscapeNewRow?.(P.activeCell)){i.preventDefault();return}l.isClearableSelection(P.selection)&&i.preventDefault(),v(e.gridActions.clearSelection());return}if((i.key===`Delete`||i.key===`Backspace`)&&A){i.preventDefault(),k();return}if((i.key===`Enter`||i.key===` `)&&P.activeCell){let e=u.getGroupRow?.(P.activeCell.row);if(e){i.preventDefault(),M(e.groupKey);return}if(N&&d[P.activeCell.col]?.key===`__ssg_detail_toggle__`&&N(P.activeCell)){i.preventDefault();return}}if(i.key===`Enter`||i.key===`F2`){if(i.preventDefault(),P.activeCell){T(P.activeCell);return}i.key===`Enter`&&y();return}if(i.key===` `&&!i.ctrlKey&&!i.metaKey&&!i.altKey&&i.preventDefault(),a.isPrintableKey(i)&&P.activeCell){let r=d[P.activeCell.col],a=o.resolveEditRow(u,P.activeCell.row,r!==void 0&&t.isColumnEditable(m,r));if(!a||!r||!t.isViewCellEditable({readOnly:m,canEditCell:h},u,P.activeCell.row,P.activeCell.col,a,r))return;if(n.resolveColumnEditor(r,a)?.type===`checkbox`){i.preventDefault(),i.key===` `&&j(P.activeCell);return}i.preventDefault(),g(i.key),v(e.gridActions.startEdit(P.activeCell))}}}};exports.createKeyboardController=h,exports.resolveFirstDataCell=m;
|
|
@@ -1,238 +1,239 @@
|
|
|
1
1
|
import { gridActions as e } from "../model/gridActions.js";
|
|
2
2
|
import { isColumnEditable as t, isViewCellEditable as n } from "../utils/permissions.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
3
|
+
import { resolveColumnEditor as r } from "../logic/columnEditor.js";
|
|
4
|
+
import { resolveFirstDataColIndex as i } from "../logic/detailRow.js";
|
|
5
|
+
import { clamp as a } from "../logic/geometry.js";
|
|
6
|
+
import { isImeInputTarget as o, isPrintableKey as s, shouldIgnoreGridKeydown as c } from "../logic/domGuards.js";
|
|
7
|
+
import { getSelectableRowCount as l, resolveEditRow as u, resolveFirstEditableColIndex as d } from "../logic/newRow.js";
|
|
8
|
+
import { isEditingAtEvent as f, readLiveUiState as p } from "./liveUiState.js";
|
|
9
|
+
import { computeIsWholeGridSelected as m } from "./clipboardController.js";
|
|
10
|
+
import { isClearableSelection as h } from "./escapeClaimController.js";
|
|
10
11
|
//#region src/controllers/keyboardController.ts
|
|
11
|
-
var
|
|
12
|
+
var g = 10, _ = (e, t, n, r) => {
|
|
12
13
|
if (!e.getLabelRow) return t;
|
|
13
14
|
let i = e.getRowCount(), a = t;
|
|
14
15
|
for (; a >= 0 && a < i && e.getLabelRow(a);) a += n;
|
|
15
16
|
return a >= 0 && a < i ? a : r;
|
|
16
|
-
},
|
|
17
|
-
row:
|
|
18
|
-
col:
|
|
19
|
-
}),
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
let t =
|
|
24
|
-
return
|
|
25
|
-
},
|
|
26
|
-
if (
|
|
27
|
-
let { dispatch: a } =
|
|
28
|
-
if (
|
|
17
|
+
}, v = (e) => _(e, 0, 1, 0), y = (e) => i(e), b = (e, t) => ({
|
|
18
|
+
row: v(e),
|
|
19
|
+
col: y(t)
|
|
20
|
+
}), x = () => {
|
|
21
|
+
let i = null, x = (e) => {
|
|
22
|
+
i = e;
|
|
23
|
+
}, S = (e, t) => _(e, t, -1, _(e, t, 1, t)), C = (e) => {
|
|
24
|
+
let t = l(e), n = (t > 0 ? t : e.getRowCount()) - 1;
|
|
25
|
+
return _(e, n, -1, n);
|
|
26
|
+
}, w = (t, n, r) => {
|
|
27
|
+
if (i === null) return;
|
|
28
|
+
let { dispatch: a } = i, o = p(i);
|
|
29
|
+
if (r) {
|
|
29
30
|
let r = o.selection?.type === "cell" ? o.selection.range.start : t;
|
|
30
31
|
a(e.startSelection(r)), a(e.updateSelection(n)), a(e.endSelection()), a(e.activateCell(n));
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
33
34
|
a(e.startSelection(n)), a(e.endSelection()), a(e.activateCell(n));
|
|
34
|
-
},
|
|
35
|
-
if (
|
|
36
|
-
let { rowModel: e, visibleColumns: t } =
|
|
35
|
+
}, T = () => {
|
|
36
|
+
if (i === null || p(i).activeCell) return !1;
|
|
37
|
+
let { rowModel: e, visibleColumns: t } = i;
|
|
37
38
|
if (e.getRowCount() === 0 || t.length === 0) return !0;
|
|
38
|
-
let n =
|
|
39
|
-
return
|
|
40
|
-
},
|
|
41
|
-
let t =
|
|
39
|
+
let n = b(e, t);
|
|
40
|
+
return w(n, n, !1), !0;
|
|
41
|
+
}, E = (e) => {
|
|
42
|
+
let t = i === null ? void 0 : p(i);
|
|
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:
|
|
49
|
-
if (s === 0 || o.length === 0 ||
|
|
50
|
-
let c =
|
|
51
|
-
l = e === 0 ?
|
|
47
|
+
}, D = (e, t, n) => {
|
|
48
|
+
if (i === null) return;
|
|
49
|
+
let { rowModel: r, visibleColumns: o } = i, s = r.getRowCount();
|
|
50
|
+
if (s === 0 || o.length === 0 || T()) return;
|
|
51
|
+
let c = E(n), l = a(c.row + e, 0, s - 1);
|
|
52
|
+
l = e === 0 ? S(r, l) : _(r, l, e > 0 ? 1 : -1, c.row);
|
|
52
53
|
let u = {
|
|
53
54
|
row: l,
|
|
54
|
-
col:
|
|
55
|
+
col: a(c.col + t, 0, o.length - 1)
|
|
55
56
|
};
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
if (
|
|
59
|
-
let { rowModel:
|
|
60
|
-
if (
|
|
61
|
-
let c = s.activeCell ?
|
|
62
|
-
row:
|
|
63
|
-
col:
|
|
64
|
-
}, l = e(c,
|
|
65
|
-
|
|
66
|
-
row:
|
|
57
|
+
w(c, u, n);
|
|
58
|
+
}, O = (e, t, n) => {
|
|
59
|
+
if (i === null) return;
|
|
60
|
+
let { rowModel: r, visibleColumns: o } = i, s = p(i);
|
|
61
|
+
if (r.getRowCount() === 0 || o.length === 0) return;
|
|
62
|
+
let c = s.activeCell ? E(t) : {
|
|
63
|
+
row: v(r),
|
|
64
|
+
col: y(o)
|
|
65
|
+
}, l = e(c, r, o), u = a(l.col, 0, o.length - 1);
|
|
66
|
+
w(c, {
|
|
67
|
+
row: S(r, a(l.row, 0, r.getRowCount() - 1)),
|
|
67
68
|
col: u
|
|
68
69
|
}, t && s.activeCell !== null);
|
|
69
|
-
let d = n === void 0 ? null :
|
|
70
|
-
d !== null && (n === "start" ?
|
|
71
|
-
},
|
|
72
|
-
let
|
|
73
|
-
return c >= 0 ? c :
|
|
70
|
+
let d = n === void 0 ? null : i.scrollContainerRef?.current ?? null, f = o[u]?.pinned;
|
|
71
|
+
d !== null && (n === "start" ? f === "left" : f === "right") && (d.scrollLeft = n === "start" ? 0 : Math.max(d.scrollWidth - d.clientWidth, 0));
|
|
72
|
+
}, k = (e, t, n) => {
|
|
73
|
+
let r = t.getRowCount(), o = i?.resolvePageRow ? i.resolvePageRow(e.row, n) : e.row + n * g, s = a(n > 0 ? Math.max(o, e.row + 1) : Math.min(o, e.row - 1), 0, r - 1), c = _(t, s, n, -1);
|
|
74
|
+
return c >= 0 ? c : _(t, s, n > 0 ? -1 : 1, e.row);
|
|
74
75
|
};
|
|
75
76
|
return {
|
|
76
|
-
update:
|
|
77
|
-
handleKeyDown: async (
|
|
78
|
-
if (
|
|
79
|
-
let { rowModel:
|
|
80
|
-
if (
|
|
81
|
-
if ((
|
|
82
|
-
|
|
77
|
+
update: x,
|
|
78
|
+
handleKeyDown: async (a) => {
|
|
79
|
+
if (i === null) return;
|
|
80
|
+
let { rowModel: g, visibleColumns: _, readOnly: b, canEditCell: x, setEditorInitialValue: S, dispatch: w, handleCopy: E, openFind: A, handleCellDoubleClick: j, selectEntireGrid: M, onUndo: N, onRedo: P, onClearSelection: F, enableClearOnDelete: I, onToggleCheckboxCell: L, onToggleGroup: R, onToggleDetailRow: z } = i, B = p(i), V = i.getUiState ? m(B.selection, l(g), _.length) : i.isWholeGridSelected;
|
|
81
|
+
if (c(a.target) || f(i) || a.isComposing && o(a.target)) return;
|
|
82
|
+
if ((a.ctrlKey || a.metaKey) && a.key.toLowerCase() === "c") {
|
|
83
|
+
a.preventDefault(), await E();
|
|
83
84
|
return;
|
|
84
85
|
}
|
|
85
|
-
if ((
|
|
86
|
-
|
|
86
|
+
if ((a.ctrlKey || a.metaKey) && !a.altKey && a.key.toLowerCase() === "x" && i.handleCut) {
|
|
87
|
+
a.preventDefault(), await i.handleCut();
|
|
87
88
|
return;
|
|
88
89
|
}
|
|
89
|
-
if ((
|
|
90
|
-
|
|
90
|
+
if ((a.ctrlKey || a.metaKey) && a.key.toLowerCase() === "f" && A) {
|
|
91
|
+
a.preventDefault(), A();
|
|
91
92
|
return;
|
|
92
93
|
}
|
|
93
|
-
if ((
|
|
94
|
-
if (
|
|
95
|
-
|
|
94
|
+
if ((a.ctrlKey || a.metaKey) && a.key.toLowerCase() === "a") {
|
|
95
|
+
if (a.preventDefault(), V) {
|
|
96
|
+
w(e.clearSelection()), w(e.activateCell(null));
|
|
96
97
|
return;
|
|
97
98
|
}
|
|
98
|
-
|
|
99
|
+
M();
|
|
99
100
|
return;
|
|
100
101
|
}
|
|
101
|
-
if ((
|
|
102
|
-
if (
|
|
103
|
-
|
|
102
|
+
if ((a.ctrlKey || a.metaKey) && !a.isComposing) {
|
|
103
|
+
if (a.key.toLowerCase() === "z") {
|
|
104
|
+
a.preventDefault(), a.shiftKey ? P() : N();
|
|
104
105
|
return;
|
|
105
106
|
}
|
|
106
|
-
if (
|
|
107
|
-
|
|
107
|
+
if (a.key.toLowerCase() === "y" && !a.shiftKey) {
|
|
108
|
+
a.preventDefault(), P();
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
|
-
if (
|
|
112
|
-
let
|
|
113
|
-
if ((
|
|
114
|
-
|
|
112
|
+
if (i.onShortcutKeyDown?.(a)) return;
|
|
113
|
+
let H = a.ctrlKey || a.metaKey;
|
|
114
|
+
if ((a.key === "ContextMenu" || a.key === "F10" && a.shiftKey) && !H && !a.altKey && B.activeCell && i.openContextMenu?.(B.activeCell)) {
|
|
115
|
+
a.preventDefault();
|
|
115
116
|
return;
|
|
116
117
|
}
|
|
117
|
-
if ((
|
|
118
|
-
|
|
118
|
+
if ((a.key === "ArrowDown" || a.key === "ArrowUp") && a.altKey && a.shiftKey && !H && B.activeCell && i.onToggleTreeRow?.(B.activeCell, a.key === "ArrowDown")) {
|
|
119
|
+
a.preventDefault();
|
|
119
120
|
return;
|
|
120
121
|
}
|
|
121
|
-
if (
|
|
122
|
-
|
|
122
|
+
if (a.key === "ArrowDown" && a.altKey && !H && !a.shiftKey && B.activeCell && i.openColumnMenu?.(B.activeCell.col)) {
|
|
123
|
+
a.preventDefault();
|
|
123
124
|
return;
|
|
124
125
|
}
|
|
125
|
-
if (
|
|
126
|
-
|
|
127
|
-
let e =
|
|
128
|
-
|
|
129
|
-
row: e ?
|
|
126
|
+
if (H && !a.altKey && (a.key === "ArrowUp" || a.key === "ArrowDown")) {
|
|
127
|
+
a.preventDefault();
|
|
128
|
+
let e = a.key === "ArrowDown";
|
|
129
|
+
O((t, n) => ({
|
|
130
|
+
row: e ? C(n) : v(n),
|
|
130
131
|
col: t.col
|
|
131
|
-
}),
|
|
132
|
+
}), a.shiftKey);
|
|
132
133
|
return;
|
|
133
134
|
}
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
let e =
|
|
137
|
-
|
|
135
|
+
if (H && !a.altKey && (a.key === "ArrowLeft" || a.key === "ArrowRight")) {
|
|
136
|
+
a.preventDefault();
|
|
137
|
+
let e = a.key === "ArrowRight";
|
|
138
|
+
O((t, n, r) => ({
|
|
138
139
|
row: t.row,
|
|
139
|
-
col: e ? r.length - 1 :
|
|
140
|
-
}),
|
|
140
|
+
col: e ? r.length - 1 : y(r)
|
|
141
|
+
}), a.shiftKey, e ? "end" : "start");
|
|
141
142
|
return;
|
|
142
143
|
}
|
|
143
|
-
if ((
|
|
144
|
-
|
|
145
|
-
let e =
|
|
146
|
-
|
|
147
|
-
row:
|
|
148
|
-
col: e ? r.length - 1 :
|
|
149
|
-
}),
|
|
144
|
+
if ((a.key === "Home" || a.key === "End") && !a.altKey) {
|
|
145
|
+
a.preventDefault();
|
|
146
|
+
let e = a.key === "End";
|
|
147
|
+
O((t, n, r) => ({
|
|
148
|
+
row: H ? e ? C(n) : v(n) : t.row,
|
|
149
|
+
col: e ? r.length - 1 : y(r)
|
|
150
|
+
}), a.shiftKey, e ? "end" : "start");
|
|
150
151
|
return;
|
|
151
152
|
}
|
|
152
|
-
if ((
|
|
153
|
-
if (
|
|
154
|
-
let e =
|
|
155
|
-
|
|
156
|
-
row:
|
|
153
|
+
if ((a.key === "PageDown" || a.key === "PageUp") && !H && !a.altKey) {
|
|
154
|
+
if (a.preventDefault(), T()) return;
|
|
155
|
+
let e = a.key === "PageDown" ? 1 : -1;
|
|
156
|
+
O((t, n) => ({
|
|
157
|
+
row: k(t, n, e),
|
|
157
158
|
col: t.col
|
|
158
|
-
}),
|
|
159
|
+
}), a.shiftKey);
|
|
159
160
|
return;
|
|
160
161
|
}
|
|
161
|
-
if (
|
|
162
|
-
|
|
162
|
+
if (a.key === "ArrowUp") {
|
|
163
|
+
a.preventDefault(), D(-1, 0, a.shiftKey);
|
|
163
164
|
return;
|
|
164
165
|
}
|
|
165
|
-
if (
|
|
166
|
-
|
|
166
|
+
if (a.key === "ArrowDown") {
|
|
167
|
+
a.preventDefault(), D(1, 0, a.shiftKey);
|
|
167
168
|
return;
|
|
168
169
|
}
|
|
169
|
-
if (
|
|
170
|
-
|
|
170
|
+
if (a.key === "ArrowLeft") {
|
|
171
|
+
a.preventDefault(), D(0, -1, a.shiftKey);
|
|
171
172
|
return;
|
|
172
173
|
}
|
|
173
|
-
if (
|
|
174
|
-
|
|
174
|
+
if (a.key === "ArrowRight") {
|
|
175
|
+
a.preventDefault(), D(0, 1, a.shiftKey);
|
|
175
176
|
return;
|
|
176
177
|
}
|
|
177
|
-
if (
|
|
178
|
-
if (!
|
|
179
|
-
if (
|
|
180
|
-
|
|
178
|
+
if (a.key === "Tab") {
|
|
179
|
+
if (!B.activeCell && !a.shiftKey) {
|
|
180
|
+
if (i.rowModel.getRowCount() === 0 || i.visibleColumns.length === 0) return;
|
|
181
|
+
a.preventDefault(), T();
|
|
181
182
|
return;
|
|
182
183
|
}
|
|
183
|
-
let e =
|
|
184
|
-
if (
|
|
185
|
-
!
|
|
184
|
+
let e = B.activeCell?.col ?? 0;
|
|
185
|
+
if (a.shiftKey ? e <= y(i.visibleColumns) : e >= i.visibleColumns.length - 1) {
|
|
186
|
+
!a.shiftKey && B.activeCell && (i.onTabPastLastColumn?.(B.activeCell.row) || i.onTabPastNewRowDraft?.(B.activeCell, d(i.visibleColumns, i.readOnly))) && a.preventDefault();
|
|
186
187
|
return;
|
|
187
188
|
}
|
|
188
|
-
|
|
189
|
+
a.preventDefault(), D(0, a.shiftKey ? -1 : 1, !1);
|
|
189
190
|
return;
|
|
190
191
|
}
|
|
191
|
-
if (
|
|
192
|
-
if (
|
|
193
|
-
|
|
192
|
+
if (a.key === "Escape") {
|
|
193
|
+
if (B.activeCell && i.onEscapeNewRow?.(B.activeCell)) {
|
|
194
|
+
a.preventDefault();
|
|
194
195
|
return;
|
|
195
196
|
}
|
|
196
|
-
|
|
197
|
+
h(B.selection) && a.preventDefault(), w(e.clearSelection());
|
|
197
198
|
return;
|
|
198
199
|
}
|
|
199
|
-
if ((
|
|
200
|
-
|
|
200
|
+
if ((a.key === "Delete" || a.key === "Backspace") && I) {
|
|
201
|
+
a.preventDefault(), F();
|
|
201
202
|
return;
|
|
202
203
|
}
|
|
203
|
-
if ((
|
|
204
|
-
let e =
|
|
204
|
+
if ((a.key === "Enter" || a.key === " ") && B.activeCell) {
|
|
205
|
+
let e = g.getGroupRow?.(B.activeCell.row);
|
|
205
206
|
if (e) {
|
|
206
|
-
|
|
207
|
+
a.preventDefault(), R(e.groupKey);
|
|
207
208
|
return;
|
|
208
209
|
}
|
|
209
|
-
if (
|
|
210
|
-
|
|
210
|
+
if (z && _[B.activeCell.col]?.key === "__ssg_detail_toggle__" && z(B.activeCell)) {
|
|
211
|
+
a.preventDefault();
|
|
211
212
|
return;
|
|
212
213
|
}
|
|
213
214
|
}
|
|
214
|
-
if (
|
|
215
|
-
if (
|
|
216
|
-
|
|
215
|
+
if (a.key === "Enter" || a.key === "F2") {
|
|
216
|
+
if (a.preventDefault(), B.activeCell) {
|
|
217
|
+
j(B.activeCell);
|
|
217
218
|
return;
|
|
218
219
|
}
|
|
219
|
-
|
|
220
|
+
a.key === "Enter" && T();
|
|
220
221
|
return;
|
|
221
222
|
}
|
|
222
|
-
if (
|
|
223
|
-
let
|
|
224
|
-
if (!
|
|
225
|
-
readOnly:
|
|
226
|
-
canEditCell:
|
|
227
|
-
},
|
|
228
|
-
if (r
|
|
229
|
-
|
|
223
|
+
if (a.key === " " && !a.ctrlKey && !a.metaKey && !a.altKey && a.preventDefault(), s(a) && B.activeCell) {
|
|
224
|
+
let i = _[B.activeCell.col], o = u(g, B.activeCell.row, i !== void 0 && t(b, i));
|
|
225
|
+
if (!o || !i || !n({
|
|
226
|
+
readOnly: b,
|
|
227
|
+
canEditCell: x
|
|
228
|
+
}, g, B.activeCell.row, B.activeCell.col, o, i)) return;
|
|
229
|
+
if (r(i, o)?.type === "checkbox") {
|
|
230
|
+
a.preventDefault(), a.key === " " && L(B.activeCell);
|
|
230
231
|
return;
|
|
231
232
|
}
|
|
232
|
-
|
|
233
|
+
a.preventDefault(), S(a.key), w(e.startEdit(B.activeCell));
|
|
233
234
|
}
|
|
234
235
|
}
|
|
235
236
|
};
|
|
236
237
|
};
|
|
237
238
|
//#endregion
|
|
238
|
-
export {
|
|
239
|
+
export { x as createKeyboardController, b as resolveFirstDataCell };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/multiSelect.cjs"),t=require("../logic/valueStore.cjs"),n=require("../logic/editorKeys.cjs"),r=require("../logic/selectEditorState.cjs"),i=require("../logic/selectSearch.cjs");require("./searchSelectEditorController.cjs");var a=e=>e instanceof Error?e.message||e.name:typeof e==`string`?e:String(e),o=o=>{let{search:s}=o,c=o.load!==void 0,l=o.now??Date.now,u={onCommit:o.onCommit,onCancel:o.onCancel,load:o.load},d=o.debounceMs??200,f=o.options,p=new Map,m=e=>{for(let t of e)p.set(t.value,t.label)};m(f);let h=!1,g=!1,_=r.createTypeaheadState(),v=s?o.initialText??``:``,y=i.foldSearchQuery(v),b=0,x=null,S=null,C=v.trim(),w=!1,T=e=>e.map(e=>({value:e,label:p.get(e)??e})),E=e.orderMultiSelectValues(e.toMultiSelectValues(o.value),f),D=c?[]:i.searchSelectOptions(f,y),O=(e,t)=>{if(e.length===0)return-1;if(y!==``)return 0;let n=e.findIndex(e=>t.includes(e.option.value));return n>=0?n:0},k=O(D,E);if(!s&&o.initialText){let e=r.findOptionByComposedText(f,o.initialText),t=r.typeaheadJump(_,o.initialText,l(),f);_=t.state,k=t.index??e??k}let A=t.createValueStore({text:v,results:D,highlight:k,status:c?`loading`:`ready`,errorMessage:null,filtered:y!==``,selected:E,chips:T(E)}),j=e=>{A.setSnapshot({...A.getSnapshot(),...e})},M=e=>{h=!0,j({selected:e,chips:T(e)})},N=t=>{let{selected:n}=A.getSnapshot();M(n.includes(t)?n.filter(e=>e!==t):e.orderMultiSelectValues([...n,t],f))},P=()=>{S!==null&&(clearTimeout(S),S=null)},F=e=>{let t=u.load;if(!t||!w)return;P(),x?.abort();let n=++b,r=new AbortController;x=r,C=e;let o=i.foldSearchQuery(e);j({status:`loading`,errorMessage:null});let s;try{s=Promise.resolve(t(e,r.signal))}catch(e){s=Promise.reject(e)}s.then(e=>{if(n!==b||r.signal.aborted)return;x=null;let t=Array.isArray(e)?e:[];m(t);let a=i.markSelectSearchMatches(t,o),{selected:s}=A.getSnapshot();j({results:a,highlight:O(a,s),status:`ready`,errorMessage:null,filtered:o!==``,chips:T(s)})},e=>{n!==b||r.signal.aborted||(x=null,j({results:[],highlight:-1,status:`error`,errorMessage:a(e),filtered:o!==``}))})},I=e=>{let t=i.foldSearchQuery(e);if(t===y&&!(c&&A.getSnapshot().status===`error`))return;if(y=t,c){P(),x?.abort(),x=null,b+=1,j({status:`loading`,errorMessage:null,highlight:-1}),S=setTimeout(()=>{S=null,F(e.trim())},d);return}let n=i.searchSelectOptions(f,t);j({results:n,highlight:O(n,A.getSnapshot().selected),filtered:t!==``})},L=()=>h?A.getSnapshot().selected:o.value,R=e=>u.onCommit(L(),e),z=e=>{let{results:t,highlight:n,status:i}=A.getSnapshot();t.length===0||c&&i===`loading`||(g=!0,j({highlight:r.moveSelectHighlight(e,n,t.length)}))},B=()=>{let{results:e,highlight:t}=A.getSnapshot(),n=e[t];n&&N(n.option.value)};return{getSnapshot:A.getSnapshot,subscribe:A.subscribe,input:(e,t)=>{s&&(g=!1,e!==A.getSnapshot().text&&j({text:e}),t||I(e))},keyDown:(e,t)=>{let{key:i}=e,a=e.ctrlKey===!0||e.metaKey===!0||e.altKey===!0;if(i===`ArrowDown`||i===`ArrowUp`||i===`PageDown`||i===`PageUp`)return e.preventDefault(),_=r.createTypeaheadState(),z(i),!0;if(!s&&(i===`Home`||i===`End`))return e.preventDefault(),z(i),!0;if(i===` `&&!a&&(!s||g))return e.preventDefault(),_=r.createTypeaheadState(),B(),!0;if(i===`Enter`&&!a&&s&&A.getSnapshot().text.trim()!==``){let{results:t,highlight:n,selected:r,status:i}=A.getSnapshot(),a=c&&i===`loading`?void 0:t[n];if(a&&!r.includes(a.option.value))return e.preventDefault(),N(a.option.value),g=!1,j({text:``}),I(``),!0}if(i===`Enter`&&c&&A.getSnapshot().status===`error`&&A.getSnapshot().text.trim()!==``)return e.preventDefault(),F(C),!0;if(i===`Enter`||i===`Tab`)return e.preventDefault(),R(i===`Enter`?n.resolveEnterDirection(t):e.shiftKey?`left`:`right`),!0;if(i===`Escape`)return e.preventDefault(),u.onCancel(),!0;if(i===`Backspace`&&!a&&A.getSnapshot().text===``){let{selected:t}=A.getSnapshot();return e.preventDefault(),t.length>0&&M(t.slice(0,-1)),!0}if(!s&&i.length===1&&!a){e.preventDefault();let t=r.typeaheadJump(_,i,l(),A.getSnapshot().results.map(e=>e.option));return _=t.state,t.index!==null&&j({highlight:t.index}),!0}return!1},hover:e=>{let{results:t,highlight:n,status:r}=A.getSnapshot();c&&r===`loading`||e!==n&&e>=0&&e<t.length&&j({highlight:e})},toggle:e=>{let t=A.getSnapshot().results[e];t&&(e!==A.getSnapshot().highlight&&j({highlight:e}),N(t.option.value))},remove:e=>{let{selected:t}=A.getSnapshot();t.includes(e)&&M(t.filter(t=>t!==e))},valueToCommit:L,blur:()=>{let e=R(void 0);e&&e.status===`rejected`&&u.onCancel()},retry:()=>{c&&F(C)},flush:()=>{h&&R(void 0)},setOptions:e=>{if(e===f)return;let t=e.length===f.length&&e.every((e,t)=>e===f[t]);if(f=e,m(e),t)return;let{results:n,highlight:r,selected:a}=A.getSnapshot();if(c){j({chips:T(a)});return}let o=n[r]?.option.value,s=i.searchSelectOptions(f,y),l=o===void 0?-1:s.findIndex(e=>e.option.value===o);j({results:s,highlight:l>=0?l:O(s,a),chips:T(a)})},setHandlers:e=>{u=e.load===void 0&&c?{...e,load:u.load}:e},attach:()=>(w=!0,c&&F(C),()=>{w=!1,P(),x?.abort(),x=null,b+=1})}};exports.createMultiSelectEditorController=o;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { EditorCommitDirection, EditorCommitResult, EditorEnterMove, GridSelectEditorOption } from '../model/gridTypes.unbound.js';
|
|
2
|
+
import { type SelectSearchResult } from '../logic/selectSearch.js';
|
|
3
|
+
import { type SearchSelectLoad, type SearchSelectStatus } from './searchSelectEditorController.js';
|
|
4
|
+
export type MultiSelectChip = {
|
|
5
|
+
value: string;
|
|
6
|
+
label: string;
|
|
7
|
+
};
|
|
8
|
+
export type MultiSelectSnapshot = {
|
|
9
|
+
text: string;
|
|
10
|
+
results: readonly SelectSearchResult[];
|
|
11
|
+
highlight: number;
|
|
12
|
+
status: SearchSelectStatus;
|
|
13
|
+
errorMessage: string | null;
|
|
14
|
+
filtered: boolean;
|
|
15
|
+
selected: readonly string[];
|
|
16
|
+
chips: readonly MultiSelectChip[];
|
|
17
|
+
};
|
|
18
|
+
export type MultiSelectEditorInit = {
|
|
19
|
+
options: readonly GridSelectEditorOption[];
|
|
20
|
+
value: unknown;
|
|
21
|
+
initialText: string | undefined;
|
|
22
|
+
search: boolean;
|
|
23
|
+
load?: SearchSelectLoad | undefined;
|
|
24
|
+
debounceMs?: number | undefined;
|
|
25
|
+
onCommit: (value: unknown, direction: EditorCommitDirection | undefined) => EditorCommitResult | void;
|
|
26
|
+
onCancel: () => void;
|
|
27
|
+
now?: (() => number) | undefined;
|
|
28
|
+
};
|
|
29
|
+
export type MultiSelectEditorHandlers = Pick<MultiSelectEditorInit, 'onCommit' | 'onCancel' | 'load'>;
|
|
30
|
+
export type MultiSelectKeyEventLike = {
|
|
31
|
+
key: string;
|
|
32
|
+
shiftKey: boolean;
|
|
33
|
+
ctrlKey?: boolean | undefined;
|
|
34
|
+
metaKey?: boolean | undefined;
|
|
35
|
+
altKey?: boolean | undefined;
|
|
36
|
+
preventDefault: () => void;
|
|
37
|
+
};
|
|
38
|
+
export type MultiSelectEditorController = {
|
|
39
|
+
getSnapshot: () => MultiSelectSnapshot;
|
|
40
|
+
subscribe: (listener: () => void) => () => void;
|
|
41
|
+
input: (text: string, composing: boolean) => void;
|
|
42
|
+
keyDown: (event: MultiSelectKeyEventLike, enterMove: EditorEnterMove | undefined) => boolean;
|
|
43
|
+
hover: (index: number) => void;
|
|
44
|
+
toggle: (index: number) => void;
|
|
45
|
+
remove: (value: string) => void;
|
|
46
|
+
valueToCommit: () => unknown;
|
|
47
|
+
blur: () => void;
|
|
48
|
+
retry: () => void;
|
|
49
|
+
flush: () => void;
|
|
50
|
+
setOptions: (options: readonly GridSelectEditorOption[]) => void;
|
|
51
|
+
setHandlers: (handlers: MultiSelectEditorHandlers) => void;
|
|
52
|
+
attach: () => () => void;
|
|
53
|
+
};
|
|
54
|
+
export declare const createMultiSelectEditorController: (init: MultiSelectEditorInit) => MultiSelectEditorController;
|