@ishibashi0112/spreadsheet-grid-core 1.0.2 → 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 +4 -0
- package/dist/controllers/clipboardController.js +82 -54
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.d.ts +1 -0
- package/dist/controllers/columnAutosizeRunner.js +17 -16
- package/dist/controllers/columnHeaderDragController.cjs +1 -1
- package/dist/controllers/columnHeaderDragController.js +169 -168
- package/dist/controllers/columnMenuController.cjs +1 -1
- package/dist/controllers/columnMenuController.js +71 -69
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.d.ts +5 -1
- package/dist/controllers/contextMenuController.js +62 -40
- 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.d.ts +1 -0
- package/dist/controllers/fillHandleController.js +157 -157
- 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/historyController.cjs +1 -1
- package/dist/controllers/historyController.d.ts +6 -0
- package/dist/controllers/historyController.js +79 -37
- 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.d.ts +1 -0
- package/dist/controllers/keyboardController.js +46 -42
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.d.ts +1 -0
- package/dist/controllers/pointerInteractionsController.js +172 -172
- package/dist/controllers/popoverSupport.cjs +1 -1
- package/dist/controllers/popoverSupport.d.ts +1 -0
- package/dist/controllers/popoverSupport.js +9 -4
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +2 -0
- package/dist/controllers/rowDragController.js +160 -146
- 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/toolPanelController.cjs +1 -1
- package/dist/controllers/toolPanelController.js +26 -14
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.js +74 -72
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +4 -1
- package/dist/controllers/viewportSyncController.js +66 -28
- 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 +18 -9
- 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 +8 -2
- package/dist/engine/gridApi.js +197 -187
- 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 +3 -1
- package/dist/index.js +7 -6
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +5 -0
- package/dist/logic/autoScrollGeometry.cjs +1 -1
- package/dist/logic/autoScrollGeometry.d.ts +2 -0
- package/dist/logic/autoScrollGeometry.js +3 -3
- package/dist/logic/editorValues.cjs +1 -1
- package/dist/logic/editorValues.js +37 -34
- package/dist/logic/exportCsv.cjs +3 -3
- package/dist/logic/exportCsv.d.ts +4 -1
- package/dist/logic/exportCsv.js +22 -20
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +4 -1
- package/dist/logic/exportData.js +40 -36
- package/dist/logic/filtering.cjs +1 -1
- package/dist/logic/filtering.d.ts +2 -1
- package/dist/logic/filtering.js +16 -3
- 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/groupExport.cjs +1 -1
- package/dist/logic/groupExport.js +28 -27
- package/dist/logic/grouping.cjs +1 -1
- package/dist/logic/grouping.d.ts +1 -0
- package/dist/logic/grouping.js +52 -41
- package/dist/logic/historyRebase.cjs +1 -0
- package/dist/logic/historyRebase.d.ts +5 -0
- package/dist/logic/historyRebase.js +36 -0
- 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 +8 -0
- package/dist/logic/localeTextFeatures.js +11 -5
- package/dist/logic/localeTextPopups.cjs +1 -1
- package/dist/logic/localeTextPopups.d.ts +1 -0
- package/dist/logic/localeTextPopups.js +1 -0
- 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/selectLabels.cjs +1 -0
- package/dist/logic/selectLabels.d.ts +3 -0
- package/dist/logic/selectLabels.js +41 -0
- 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/logic/valueParsers.cjs +1 -0
- package/dist/logic/valueParsers.d.ts +14 -0
- package/dist/logic/valueParsers.js +23 -0
- 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 +345 -43
- package/dist/utils/clipboard.cjs +4 -4
- package/dist/utils/clipboard.d.ts +14 -2
- package/dist/utils/clipboard.js +101 -49
- 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/popupContainer.cjs +1 -0
- package/dist/utils/popupContainer.d.ts +8 -0
- package/dist/utils/popupContainer.js +60 -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 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("./popoverSupport.cjs");var n=220,r=`.ssg-menu-item`,i=8,a=6,o=289,s=()=>{let s=null,c=e.createValueStore({columnKey:null,layout:null}),l={current:null},u=null,d=!1,f=null,p=null,m=null,h=e=>{let t=c.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||c.setSnapshot({...t,layout:e})},g=()=>{m!==null&&(cancelAnimationFrame(m),m=null),b.detach(),c.setSnapshot({columnKey:null,layout:null})},_=()=>{if(c.getSnapshot().columnKey===null){h(null);return}let e,t,r,s=l.current,d=s?s.scrollHeight+(s.offsetHeight-s.clientHeight):o;if(u){if(!u.isConnected){u=null,g();return}let i=u.getBoundingClientRect();t=i.right-n,e=i.bottom+a,r=i.top-d-a}else if(f)t=f.x,e=f.y,r=f.y-d;else{h(null);return}t=Math.max(i,t),t=Math.min(t,window.innerWidth-n-i);let p=window.innerHeight-i;e+d>p&&r>=i&&(e=r),e=Math.max(i,e);let m=p-e;h({top:e,left:t,width:n,maxHeight:d>m?Math.max(m,0):void 0})},v=e=>{g(),u=null,f=null,s!==null&&e&&t.restoreGridFocus(s.gridRootRef)},y=()=>v(!0),b=t.createPopoverWindowBindings({onResize:_,onScroll:()
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("./popoverSupport.cjs");var n=220,r=`.ssg-menu-item`,i=8,a=6,o=289,s=()=>{let s=null,c=e.createValueStore({columnKey:null,layout:null}),l={current:null},u=null,d=!1,f=null,p=null,m=null,h=e=>{let t=c.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||c.setSnapshot({...t,layout:e})},g=()=>{m!==null&&(cancelAnimationFrame(m),m=null),b.detach(),c.setSnapshot({columnKey:null,layout:null})},_=()=>{if(c.getSnapshot().columnKey===null){h(null);return}let e,t,r,s=l.current,d=s?s.scrollHeight+(s.offsetHeight-s.clientHeight):o;if(u){if(!u.isConnected){u=null,g();return}let i=u.getBoundingClientRect();t=i.right-n,e=i.bottom+a,r=i.top-d-a}else if(f)t=f.x,e=f.y,r=f.y-d;else{h(null);return}t=Math.max(i,t),t=Math.min(t,window.innerWidth-n-i);let p=window.innerHeight-i;e+d>p&&r>=i&&(e=r),e=Math.max(i,e);let m=p-e;h({top:e,left:t,width:n,maxHeight:d>m?Math.max(m,0):void 0})},v=e=>{g(),u=null,f=null,s!==null&&e&&t.restoreGridFocus(s.gridRootRef)},y=()=>v(!0),b=t.createPopoverWindowBindings({onResize:_,onScroll:e=>{if(!(e.target instanceof Node&&l.current?.contains(e.target))){if(f){y();return}_()}},isInside:e=>l.current?.contains(e)===!0||u?.contains(e)===!0,onOutsidePointerDown:e=>v(s!==null&&t.isInsideGridRoot(s.gridRootRef,e)),getGridRoot:()=>s?.gridRootRef.current??null,onGridHidden:()=>v(!1),onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),y();return}let n=l.current;if(!n||t.handleMenuKeyNavigation(n,e,r))return;let i=document.activeElement;e.key===`Tab`&&i instanceof HTMLElement&&(i===n||i.matches(r)&&n.contains(i))&&(e.preventDefault(),y())}}),x=e=>{c.setSnapshot({...c.getSnapshot(),columnKey:e}),_(),m!==null&&cancelAnimationFrame(m),m=requestAnimationFrame(()=>{m=null,_(),d?(d=!1,l.current?.querySelector(r)?.focus()):t.focusPanelIfIdle(l.current,s?.gridRootRef.current??null)}),b.attach()},S=(e,n,r=!1)=>{t.blurForPopover(s?.gridRootRef.current??null),u=n,f=null,d=r,x(e.key)};return{update:e=>{s=e},subscribe:c.subscribe,getSnapshot:c.getSnapshot,panelRef:l,openFromButton:(e,t)=>{if(t.preventDefault(),t.stopPropagation(),!s?.enableColumnMenu||t.button!==0)return;let n=t.currentTarget;if(c.getSnapshot().columnKey===e.key&&u===n){y();return}if(t.pointerType===`touch`){p=n;return}S(e,n)},openFromButtonClick:(e,t)=>{let n=p;p=null;let r=n===null&&t.detail===0;!s?.enableColumnMenu||n!==t.currentTarget&&!r||(t.preventDefault(),t.stopPropagation(),S(e,t.currentTarget,r))},openFromContextMenu:(e,n)=>{s?.enableColumnMenu&&(n.preventDefault(),n.stopPropagation(),t.blurForPopover(s.gridRootRef.current),u=null,f={x:n.clientX,y:n.clientY},d=!1,x(e.key))},openFromKeyboard:(e,t)=>{s?.enableColumnMenu&&S(e,t,!0)},close:y,dispose:()=>{m!==null&&(cancelAnimationFrame(m),m=null),b.detach()}}};exports.createColumnMenuController=s;
|
|
@@ -1,124 +1,126 @@
|
|
|
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, focusPanelIfIdle as r, handleMenuKeyNavigation as i, isInsideGridRoot as a, restoreGridFocus as o } from "./popoverSupport.js";
|
|
3
3
|
//#region src/controllers/columnMenuController.ts
|
|
4
|
-
var
|
|
5
|
-
let
|
|
4
|
+
var s = 220, c = ".ssg-menu-item", l = 8, u = 6, d = 289, f = () => {
|
|
5
|
+
let f = null, p = 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
|
+
}), m = { current: null }, h = null, g = !1, _ = null, v = null, y = null, b = (e) => {
|
|
9
|
+
let t = p.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 || p.setSnapshot({
|
|
11
11
|
...t,
|
|
12
12
|
layout: e
|
|
13
13
|
});
|
|
14
|
-
},
|
|
15
|
-
|
|
14
|
+
}, x = () => {
|
|
15
|
+
y !== null && (cancelAnimationFrame(y), y = null), T.detach(), p.setSnapshot({
|
|
16
16
|
columnKey: null,
|
|
17
17
|
layout: null
|
|
18
18
|
});
|
|
19
|
-
},
|
|
20
|
-
if (
|
|
21
|
-
|
|
19
|
+
}, S = () => {
|
|
20
|
+
if (p.getSnapshot().columnKey === null) {
|
|
21
|
+
b(null);
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
let e, t, n, r =
|
|
25
|
-
if (
|
|
26
|
-
if (!
|
|
27
|
-
|
|
24
|
+
let e, t, n, r = m.current, i = r ? r.scrollHeight + (r.offsetHeight - r.clientHeight) : d;
|
|
25
|
+
if (h) {
|
|
26
|
+
if (!h.isConnected) {
|
|
27
|
+
h = null, x();
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
let r =
|
|
31
|
-
t = r.right -
|
|
32
|
-
} else if (
|
|
30
|
+
let r = h.getBoundingClientRect();
|
|
31
|
+
t = r.right - s, e = r.bottom + u, n = r.top - i - u;
|
|
32
|
+
} else if (_) t = _.x, e = _.y, n = _.y - i;
|
|
33
33
|
else {
|
|
34
|
-
|
|
34
|
+
b(null);
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
t = Math.max(
|
|
38
|
-
let a = window.innerHeight -
|
|
39
|
-
e + i > a && n >=
|
|
40
|
-
let
|
|
41
|
-
|
|
37
|
+
t = Math.max(l, t), t = Math.min(t, window.innerWidth - s - l);
|
|
38
|
+
let a = window.innerHeight - l;
|
|
39
|
+
e + i > a && n >= l && (e = n), e = Math.max(l, e);
|
|
40
|
+
let o = a - e;
|
|
41
|
+
b({
|
|
42
42
|
top: e,
|
|
43
43
|
left: t,
|
|
44
|
-
width:
|
|
45
|
-
maxHeight: i >
|
|
44
|
+
width: s,
|
|
45
|
+
maxHeight: i > o ? Math.max(o, 0) : void 0
|
|
46
46
|
});
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
onResize:
|
|
51
|
-
onScroll: () => {
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
}, C = (e) => {
|
|
48
|
+
x(), h = null, _ = null, f !== null && e && o(f.gridRootRef);
|
|
49
|
+
}, w = () => C(!0), T = n({
|
|
50
|
+
onResize: S,
|
|
51
|
+
onScroll: (e) => {
|
|
52
|
+
if (!(e.target instanceof Node && m.current?.contains(e.target))) {
|
|
53
|
+
if (_) {
|
|
54
|
+
w();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
S();
|
|
55
58
|
}
|
|
56
|
-
x();
|
|
57
59
|
},
|
|
58
|
-
isInside: (e) =>
|
|
59
|
-
onOutsidePointerDown: (e) =>
|
|
60
|
-
getGridRoot: () =>
|
|
61
|
-
onGridHidden: () =>
|
|
60
|
+
isInside: (e) => m.current?.contains(e) === !0 || h?.contains(e) === !0,
|
|
61
|
+
onOutsidePointerDown: (e) => C(f !== null && a(f.gridRootRef, e)),
|
|
62
|
+
getGridRoot: () => f?.gridRootRef.current ?? null,
|
|
63
|
+
onGridHidden: () => C(!1),
|
|
62
64
|
onKeyDown: (e) => {
|
|
63
65
|
if (e.key === "Escape") {
|
|
64
|
-
e.preventDefault(),
|
|
66
|
+
e.preventDefault(), w();
|
|
65
67
|
return;
|
|
66
68
|
}
|
|
67
|
-
let t =
|
|
68
|
-
if (!t ||
|
|
69
|
+
let t = m.current;
|
|
70
|
+
if (!t || i(t, e, c)) return;
|
|
69
71
|
let n = document.activeElement;
|
|
70
|
-
e.key === "Tab" && n instanceof HTMLElement && n.matches(
|
|
72
|
+
e.key === "Tab" && n instanceof HTMLElement && (n === t || n.matches(c) && t.contains(n)) && (e.preventDefault(), w());
|
|
71
73
|
}
|
|
72
|
-
}),
|
|
73
|
-
|
|
74
|
-
...
|
|
74
|
+
}), E = (e) => {
|
|
75
|
+
p.setSnapshot({
|
|
76
|
+
...p.getSnapshot(),
|
|
75
77
|
columnKey: e
|
|
76
|
-
}),
|
|
77
|
-
|
|
78
|
-
}),
|
|
79
|
-
},
|
|
80
|
-
t(
|
|
78
|
+
}), S(), y !== null && cancelAnimationFrame(y), y = requestAnimationFrame(() => {
|
|
79
|
+
y = null, S(), g ? (g = !1, m.current?.querySelector(c)?.focus()) : r(m.current, f?.gridRootRef.current ?? null);
|
|
80
|
+
}), T.attach();
|
|
81
|
+
}, D = (e, n, r = !1) => {
|
|
82
|
+
t(f?.gridRootRef.current ?? null), h = n, _ = null, g = r, E(e.key);
|
|
81
83
|
};
|
|
82
84
|
return {
|
|
83
85
|
update: (e) => {
|
|
84
|
-
|
|
86
|
+
f = e;
|
|
85
87
|
},
|
|
86
|
-
subscribe:
|
|
87
|
-
getSnapshot:
|
|
88
|
-
panelRef:
|
|
88
|
+
subscribe: p.subscribe,
|
|
89
|
+
getSnapshot: p.getSnapshot,
|
|
90
|
+
panelRef: m,
|
|
89
91
|
openFromButton: (e, t) => {
|
|
90
|
-
if (t.preventDefault(), t.stopPropagation(), !
|
|
92
|
+
if (t.preventDefault(), t.stopPropagation(), !f?.enableColumnMenu || t.button !== 0) return;
|
|
91
93
|
let n = t.currentTarget;
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
+
if (p.getSnapshot().columnKey === e.key && h === n) {
|
|
95
|
+
w();
|
|
94
96
|
return;
|
|
95
97
|
}
|
|
96
98
|
if (t.pointerType === "touch") {
|
|
97
|
-
|
|
99
|
+
v = n;
|
|
98
100
|
return;
|
|
99
101
|
}
|
|
100
|
-
|
|
102
|
+
D(e, n);
|
|
101
103
|
},
|
|
102
104
|
openFromButtonClick: (e, t) => {
|
|
103
|
-
let n =
|
|
104
|
-
|
|
105
|
+
let n = v;
|
|
106
|
+
v = null;
|
|
105
107
|
let r = n === null && t.detail === 0;
|
|
106
|
-
!
|
|
108
|
+
!f?.enableColumnMenu || n !== t.currentTarget && !r || (t.preventDefault(), t.stopPropagation(), D(e, t.currentTarget, r));
|
|
107
109
|
},
|
|
108
110
|
openFromContextMenu: (e, n) => {
|
|
109
|
-
|
|
111
|
+
f?.enableColumnMenu && (n.preventDefault(), n.stopPropagation(), t(f.gridRootRef.current), h = null, _ = {
|
|
110
112
|
x: n.clientX,
|
|
111
113
|
y: n.clientY
|
|
112
|
-
},
|
|
114
|
+
}, g = !1, E(e.key));
|
|
113
115
|
},
|
|
114
116
|
openFromKeyboard: (e, t) => {
|
|
115
|
-
|
|
117
|
+
f?.enableColumnMenu && D(e, t, !0);
|
|
116
118
|
},
|
|
117
|
-
close:
|
|
119
|
+
close: w,
|
|
118
120
|
dispose: () => {
|
|
119
|
-
|
|
121
|
+
y !== null && (cancelAnimationFrame(y), y = null), T.detach();
|
|
120
122
|
}
|
|
121
123
|
};
|
|
122
124
|
};
|
|
123
125
|
//#endregion
|
|
124
|
-
export {
|
|
126
|
+
export { f 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})},
|
|
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=null,f=()=>{d!==null&&(cancelAnimationFrame(d),d=null)},p=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&&t.layout.maxHeight===e.maxHeight||s.setSnapshot({...t,layout:e})},m=()=>{if(!l){p(null);return}let e=c.current,t=e?e.scrollHeight+(e.offsetHeight-e.clientHeight):u*i+a,o=l.x,s=l.y,d=l.y-t;o=Math.max(r,o),o=Math.min(o,window.innerWidth-n-r);let f=window.innerHeight-r;s+t>f&&(s=d),s=Math.max(r,s);let m=f-s;p({top:s,left:o,width:n,maxHeight:t>m?Math.max(m,0):void 0})},h=e=>{f(),s.setSnapshot({state:null,layout:null}),l=null,u=0,_.detach(),o!==null&&e&&t.restoreGridFocus(o.gridRootRef)},g=()=>h(!0),_=t.createPopoverWindowBindings({onResize:m,onScroll:g,isInside:e=>c.current?.contains(e)===!0,onOutsidePointerDown:e=>h(o!==null&&t.isInsideGridRoot(o.gridRootRef,e)),getGridRoot:()=>o?.gridRootRef.current??null,onGridHidden:()=>h(!1),onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),g();return}let n=c.current;if(!(!n||t.handleMenuKeyNavigation(n,e))&&e.key===`Tab`){let t=document.activeElement;(!(t instanceof HTMLElement&&n.contains(t))||t===n||t.getAttribute(`role`)===`menuitem`)&&(e.preventDefault(),g())}}});return{update:e=>{o=e},subscribe:s.subscribe,getSnapshot:s.getSnapshot,panelRef:c,open:(e,n,r)=>{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}}),m(),_.attach(),f();let i=r?.focus??`panel`;d=requestAnimationFrame(()=>{d=null,m();let e=c.current;if(!(e===null||e.contains(e.ownerDocument.activeElement))){if(i===`firstItem`){let t=e.querySelector(`[role="menuitem"]:not(:disabled):not([aria-disabled="true"])`);if(t!==null){t.focus({preventScroll:!0});return}}t.focusPanelIfIdle(e,o?.gridRootRef.current??null)}})},close:g,dispose:()=>{f(),_.detach()}}};exports.createContextMenuController=o;
|
|
@@ -4,6 +4,7 @@ export type CellContextMenuLayout = {
|
|
|
4
4
|
top: number;
|
|
5
5
|
left: number;
|
|
6
6
|
width: number;
|
|
7
|
+
maxHeight?: number | undefined;
|
|
7
8
|
};
|
|
8
9
|
export type CellContextMenuState<T> = {
|
|
9
10
|
params: GridContextMenuParams<T>;
|
|
@@ -13,6 +14,9 @@ export type ContextMenuSnapshot<T> = {
|
|
|
13
14
|
state: CellContextMenuState<T> | null;
|
|
14
15
|
layout: CellContextMenuLayout | null;
|
|
15
16
|
};
|
|
17
|
+
export type ContextMenuOpenOptions = {
|
|
18
|
+
focus?: 'panel' | 'firstItem';
|
|
19
|
+
};
|
|
16
20
|
export type ContextMenuControllerArgs = {
|
|
17
21
|
gridRootRef: ReadonlyElementRef;
|
|
18
22
|
};
|
|
@@ -23,7 +27,7 @@ export type ContextMenuController<T> = {
|
|
|
23
27
|
panelRef: {
|
|
24
28
|
current: HTMLDivElement | null;
|
|
25
29
|
};
|
|
26
|
-
open: (params: GridContextMenuParams<T>, items: GridContextMenuItem[]) => void;
|
|
30
|
+
open: (params: GridContextMenuParams<T>, items: GridContextMenuItem[], options?: ContextMenuOpenOptions) => void;
|
|
27
31
|
close: () => void;
|
|
28
32
|
dispose: () => void;
|
|
29
33
|
};
|
|
@@ -1,75 +1,97 @@
|
|
|
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, focusPanelIfIdle as r, handleMenuKeyNavigation as i, isInsideGridRoot as a, restoreGridFocus as o } from "./popoverSupport.js";
|
|
3
3
|
//#region src/controllers/contextMenuController.ts
|
|
4
|
-
var
|
|
5
|
-
let
|
|
4
|
+
var s = 220, c = 8, l = 34, u = 16, d = () => {
|
|
5
|
+
let d = null, f = e({
|
|
6
6
|
state: null,
|
|
7
7
|
layout: null
|
|
8
|
-
}),
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
}), p = { current: null }, m = null, h = 0, g = null, _ = () => {
|
|
9
|
+
g !== null && (cancelAnimationFrame(g), g = null);
|
|
10
|
+
}, v = (e) => {
|
|
11
|
+
let t = f.getSnapshot();
|
|
12
|
+
t.layout === e || t.layout !== null && e !== null && t.layout.top === e.top && t.layout.left === e.left && t.layout.width === e.width && t.layout.maxHeight === e.maxHeight || f.setSnapshot({
|
|
11
13
|
...t,
|
|
12
14
|
layout: e
|
|
13
15
|
});
|
|
14
|
-
},
|
|
15
|
-
if (!
|
|
16
|
-
|
|
16
|
+
}, y = () => {
|
|
17
|
+
if (!m) {
|
|
18
|
+
v(null);
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
19
|
-
let e =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
let e = p.current, t = e ? e.scrollHeight + (e.offsetHeight - e.clientHeight) : h * l + u, n = m.x, r = m.y, i = m.y - t;
|
|
22
|
+
n = Math.max(c, n), n = Math.min(n, window.innerWidth - s - c);
|
|
23
|
+
let a = window.innerHeight - c;
|
|
24
|
+
r + t > a && (r = i), r = Math.max(c, r);
|
|
25
|
+
let o = a - r;
|
|
26
|
+
v({
|
|
27
|
+
top: r,
|
|
28
|
+
left: n,
|
|
29
|
+
width: s,
|
|
30
|
+
maxHeight: t > o ? Math.max(o, 0) : void 0
|
|
24
31
|
});
|
|
25
|
-
},
|
|
26
|
-
|
|
32
|
+
}, b = (e) => {
|
|
33
|
+
_(), f.setSnapshot({
|
|
27
34
|
state: null,
|
|
28
35
|
layout: null
|
|
29
|
-
}),
|
|
30
|
-
},
|
|
31
|
-
onResize:
|
|
32
|
-
onScroll:
|
|
33
|
-
isInside: (e) =>
|
|
34
|
-
onOutsidePointerDown: (e) =>
|
|
35
|
-
getGridRoot: () =>
|
|
36
|
-
onGridHidden: () =>
|
|
36
|
+
}), m = null, h = 0, S.detach(), d !== null && e && o(d.gridRootRef);
|
|
37
|
+
}, x = () => b(!0), S = n({
|
|
38
|
+
onResize: y,
|
|
39
|
+
onScroll: x,
|
|
40
|
+
isInside: (e) => p.current?.contains(e) === !0,
|
|
41
|
+
onOutsidePointerDown: (e) => b(d !== null && a(d.gridRootRef, e)),
|
|
42
|
+
getGridRoot: () => d?.gridRootRef.current ?? null,
|
|
43
|
+
onGridHidden: () => b(!1),
|
|
37
44
|
onKeyDown: (e) => {
|
|
38
45
|
if (e.key === "Escape") {
|
|
39
|
-
e.preventDefault(),
|
|
46
|
+
e.preventDefault(), x();
|
|
40
47
|
return;
|
|
41
48
|
}
|
|
42
|
-
let t =
|
|
43
|
-
if (!(!t ||
|
|
49
|
+
let t = p.current;
|
|
50
|
+
if (!(!t || i(t, e)) && e.key === "Tab") {
|
|
44
51
|
let n = document.activeElement;
|
|
45
|
-
(!(n instanceof HTMLElement && t.contains(n)) || n.getAttribute("role") === "menuitem") && (e.preventDefault(),
|
|
52
|
+
(!(n instanceof HTMLElement && t.contains(n)) || n === t || n.getAttribute("role") === "menuitem") && (e.preventDefault(), x());
|
|
46
53
|
}
|
|
47
54
|
}
|
|
48
55
|
});
|
|
49
56
|
return {
|
|
50
57
|
update: (e) => {
|
|
51
|
-
|
|
58
|
+
d = e;
|
|
52
59
|
},
|
|
53
|
-
subscribe:
|
|
54
|
-
getSnapshot:
|
|
55
|
-
panelRef:
|
|
56
|
-
open: (e, n) => {
|
|
57
|
-
t(
|
|
60
|
+
subscribe: f.subscribe,
|
|
61
|
+
getSnapshot: f.getSnapshot,
|
|
62
|
+
panelRef: p,
|
|
63
|
+
open: (e, n, i) => {
|
|
64
|
+
t(d?.gridRootRef.current ?? null), m = {
|
|
58
65
|
x: e.clientX,
|
|
59
66
|
y: e.clientY
|
|
60
|
-
},
|
|
61
|
-
...
|
|
67
|
+
}, h = n.length, f.setSnapshot({
|
|
68
|
+
...f.getSnapshot(),
|
|
62
69
|
state: {
|
|
63
70
|
params: e,
|
|
64
71
|
items: n
|
|
65
72
|
}
|
|
66
|
-
}),
|
|
73
|
+
}), y(), S.attach(), _();
|
|
74
|
+
let a = i?.focus ?? "panel";
|
|
75
|
+
g = requestAnimationFrame(() => {
|
|
76
|
+
g = null, y();
|
|
77
|
+
let e = p.current;
|
|
78
|
+
if (!(e === null || e.contains(e.ownerDocument.activeElement))) {
|
|
79
|
+
if (a === "firstItem") {
|
|
80
|
+
let t = e.querySelector("[role=\"menuitem\"]:not(:disabled):not([aria-disabled=\"true\"])");
|
|
81
|
+
if (t !== null) {
|
|
82
|
+
t.focus({ preventScroll: !0 });
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
r(e, d?.gridRootRef.current ?? null);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
67
89
|
},
|
|
68
|
-
close:
|
|
90
|
+
close: x,
|
|
69
91
|
dispose: () => {
|
|
70
|
-
|
|
92
|
+
_(), S.detach();
|
|
71
93
|
}
|
|
72
94
|
};
|
|
73
95
|
};
|
|
74
96
|
//#endregion
|
|
75
|
-
export {
|
|
97
|
+
export { d as createContextMenuController };
|
|
@@ -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/detailRow.cjs"),r=require("../logic/geometry.cjs"),i=require("../logic/editorValues.cjs"),a=require("../logic/validation.cjs");var o=(e,t)=>t.activeCell!==e.activeCell||t.selection!==e.selection,s=e=>{if(n.isFocusInsideDetailCard())return!1;let t=e.ownerDocument,r=t.activeElement;return r===null||r===t.body||r===t.documentElement||e.contains(r)},c=e=>{if(e===null)return!1;let t=e.ownerDocument.activeElement;return t!==null&&t!==e&&e.contains(t)&&typeof t.closest==`function`&&t.closest(`.ssg-cell-editor`)!==null&&!n.isFocusInsideDetailCard()},l=()=>{let l=null,u=null,d=(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}},f=(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},p=t=>{l=t;let n=t.uiState.editingCell;if(!n){u=null;return}let r=d(t,n);if(u!==null&&r!==null&&Object.is(r.rowKey,u.rowKey)&&r.columnKey===u.columnKey){u={...u,cell:n};return}let i=u!==null&&u.cell.row===n.row&&u.cell.col===n.col;if(u===null||!i){u=r?{...r,cell:n}:null;return}let a=f(t,u);a?(u={...u,cell:a},t.dispatch(e.gridActions.retargetEdit(a,t.rowModel.getRowCount()))):(u=null,t.dispatch(e.gridActions.stopEdit()))},m=t=>{l!==null&&(l.dispatch(e.gridActions.startSelection(t)),l.dispatch(e.gridActions.endSelection()),l.dispatch(e.gridActions.activateCell(t)))},h=(t,n)=>{l!==null&&(l.setEditorInitialValue(n),l.dispatch(e.gridActions.startEdit(t)))},g=(e,t,n)=>{let i=e.getRowCount(),a=r.clamp(t,0,Math.max(i-1,0)),{getLabelRow:o}=e;if(o&&n!==void 0&&a!==n){let e=a>n?1:-1;for(;a>=0&&a<i&&o(a);)a+=e;(a<0||a>=i)&&(a=r.clamp(n,0,Math.max(i-1,0)))}return a},_=(e,t=null,i,a=!1,c)=>{let u=l;if(u===null)return;let d=!1,f=a=>{if(d||!a&&(l===null||l.uiState.editingCell!==null))return;d=!0;let f=u.gridRootRef.current;if(f!==null&&s(f)&&f.focus(),e!==null&&l!==null&&!(t!==null&&o(t,l.uiState))){let t=l.visibleColumns.length,a=c===void 0?-1:n.findViewRowIndexByKey(l.rowModel,c,new Map),o=a>=0?a:g(l.rowModel,e.row,i);m({row:o,col:r.clamp(e.col,0,Math.max(t-1,0))})}u.editorActionGuardRef.current=!1};a&&queueMicrotask(()=>f(!1)),requestAnimationFrame(()=>f(!0))},v=()=>{let e=l?.gridRootRef.current??null;return c(e)?(e.focus({preventScroll:!0}),!0):!1};return{update:p,activateSingleCell:m,startEditWithValue:h,commitEdit:(r,o)=>{if(l===null)return{status:`noop`};let{uiState:s,visibleColumns:c,rowModel:u,rows:d,applyServerSideCellEdits:f,onRowsChange:p,dispatch:m,editorActionGuardRef:h}=l;if(h.current||!s.editingCell)return{status:`noop`};let y=s.editingCell,b=o===`down`?{row:y.row+1,col:y.col}:o===`up`?{row:y.row-1,col:y.col}:o===`right`?{row:y.row,col:y.col+1}:o===`left`?{row:y.row,col:Math.max(y.col-1,n.resolveFirstDataColIndex(c))}:y,x=c[y.col],S=u.getSourceIndex(y.row),C=f?u.getRow(y.row):d[S];if(!x||!C)return m(e.gridActions.stopEdit()),{status:`noop`};if(!t.isViewCellEditable({readOnly:l.readOnly,canEditCell:l.canEditCell},u,y.row,y.col,C,x))return h.current=!0,m(e.gridActions.stopEdit()),_(null),{status:`noop`};let w=i.isUnchangedEditorCommit(x,t.getCellValue(C,x),r);if(!w&&f){let e=i.parseCommittedValue(x,r,C),t=a.decideCellWrite(x,C,e,l.localeTexts);if(t.action===`reject`)return{status:`rejected`,message:t.message};f([{viewIndex:y.row,column:x,value:e}])}else if(!w&&p){let e=i.parseCommittedValue(x,r,C),t=a.decideCellWrite(x,C,e,l.localeTexts);if(t.action===`reject`)return{status:`rejected`,message:t.message};p(i.writeRowsCell(d,S,x,e))}h.current=!0;let T=v(),E;if(l.followsRow===!0){let e=g(u,b.row,y.row);(u.getRow(e)!=null||u.getLabelRow?.(e)!==void 0)&&(E=u.getRowKey(e))}return _(b,o===void 0?{activeCell:s.activeCell,selection:s.selection}:null,y.row,T,E),m(e.gridActions.stopEdit()),{status:`committed`}},cancelEdit:()=>{if(l===null||l.editorActionGuardRef.current)return;l.editorActionGuardRef.current=!0;let t=v();l.dispatch(e.gridActions.stopEdit()),_(null,null,void 0,t)}}};exports.createEditController=l;
|
|
@@ -20,6 +20,7 @@ export type EditControllerArgs<T extends object> = {
|
|
|
20
20
|
readOnly?: boolean;
|
|
21
21
|
canEditCell?: SpreadsheetGridProps<T>['canEditCell'];
|
|
22
22
|
localeTexts?: ValidationLocaleText;
|
|
23
|
+
followsRow?: boolean | undefined;
|
|
23
24
|
};
|
|
24
25
|
export type EditController<T extends object> = {
|
|
25
26
|
update: (args: EditControllerArgs<T>) => void;
|