@ishibashi0112/spreadsheet-grid-core 1.0.2 → 1.1.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/clipboardController.cjs +1 -1
- package/dist/controllers/clipboardController.d.ts +3 -0
- package/dist/controllers/clipboardController.js +69 -50
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.d.ts +1 -0
- package/dist/controllers/columnAutosizeRunner.js +10 -9
- 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 +4 -1
- package/dist/controllers/contextMenuController.js +55 -38
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.d.ts +1 -0
- package/dist/controllers/fillHandleController.js +135 -135
- 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/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +1 -0
- package/dist/controllers/keyboardController.js +4 -0
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.d.ts +1 -0
- package/dist/controllers/pointerInteractionsController.js +142 -142
- 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 +1 -0
- package/dist/controllers/rowDragController.js +145 -144
- 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 +3 -1
- package/dist/controllers/viewportSyncController.js +66 -28
- package/dist/engine/exportCommands.cjs +1 -1
- package/dist/engine/exportCommands.js +16 -9
- package/dist/engine/gridApi.cjs +2 -2
- package/dist/engine/gridApi.d.ts +6 -2
- package/dist/engine/gridApi.js +5 -5
- 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 +3 -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 +3 -1
- package/dist/logic/exportCsv.js +22 -20
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +3 -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/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/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +4 -0
- package/dist/logic/localeTextFeatures.js +8 -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/selectLabels.cjs +1 -0
- package/dist/logic/selectLabels.d.ts +3 -0
- package/dist/logic/selectLabels.js +41 -0
- 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/gridTypes.core.d.ts +174 -18
- 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/popupContainer.cjs +1 -0
- package/dist/utils/popupContainer.d.ts +8 -0
- package/dist/utils/popupContainer.js +60 -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||s.setSnapshot({...t,layout:e})},m=()=>{if(!l){p(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),p({top:o,left:t,width:n})},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;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;
|
|
@@ -13,6 +13,9 @@ export type ContextMenuSnapshot<T> = {
|
|
|
13
13
|
state: CellContextMenuState<T> | null;
|
|
14
14
|
layout: CellContextMenuLayout | null;
|
|
15
15
|
};
|
|
16
|
+
export type ContextMenuOpenOptions = {
|
|
17
|
+
focus?: 'panel' | 'firstItem';
|
|
18
|
+
};
|
|
16
19
|
export type ContextMenuControllerArgs = {
|
|
17
20
|
gridRootRef: ReadonlyElementRef;
|
|
18
21
|
};
|
|
@@ -23,7 +26,7 @@ export type ContextMenuController<T> = {
|
|
|
23
26
|
panelRef: {
|
|
24
27
|
current: HTMLDivElement | null;
|
|
25
28
|
};
|
|
26
|
-
open: (params: GridContextMenuParams<T>, items: GridContextMenuItem[]) => void;
|
|
29
|
+
open: (params: GridContextMenuParams<T>, items: GridContextMenuItem[], options?: ContextMenuOpenOptions) => void;
|
|
27
30
|
close: () => void;
|
|
28
31
|
dispose: () => void;
|
|
29
32
|
};
|
|
@@ -1,75 +1,92 @@
|
|
|
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 || 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
|
-
t = Math.max(
|
|
21
|
+
let e = h * l + u, t = m.x, n = m.y, r = m.y - e;
|
|
22
|
+
t = Math.max(c, t), t = Math.min(t, window.innerWidth - s - c), n + e > window.innerHeight - c && (n = r), n = Math.max(c, n), v({
|
|
21
23
|
top: n,
|
|
22
24
|
left: t,
|
|
23
|
-
width:
|
|
25
|
+
width: s
|
|
24
26
|
});
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
+
}, b = (e) => {
|
|
28
|
+
_(), f.setSnapshot({
|
|
27
29
|
state: null,
|
|
28
30
|
layout: null
|
|
29
|
-
}),
|
|
30
|
-
},
|
|
31
|
-
onResize:
|
|
32
|
-
onScroll:
|
|
33
|
-
isInside: (e) =>
|
|
34
|
-
onOutsidePointerDown: (e) =>
|
|
35
|
-
getGridRoot: () =>
|
|
36
|
-
onGridHidden: () =>
|
|
31
|
+
}), m = null, h = 0, S.detach(), d !== null && e && o(d.gridRootRef);
|
|
32
|
+
}, x = () => b(!0), S = n({
|
|
33
|
+
onResize: y,
|
|
34
|
+
onScroll: x,
|
|
35
|
+
isInside: (e) => p.current?.contains(e) === !0,
|
|
36
|
+
onOutsidePointerDown: (e) => b(d !== null && a(d.gridRootRef, e)),
|
|
37
|
+
getGridRoot: () => d?.gridRootRef.current ?? null,
|
|
38
|
+
onGridHidden: () => b(!1),
|
|
37
39
|
onKeyDown: (e) => {
|
|
38
40
|
if (e.key === "Escape") {
|
|
39
|
-
e.preventDefault(),
|
|
41
|
+
e.preventDefault(), x();
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
42
|
-
let t =
|
|
43
|
-
if (!(!t ||
|
|
44
|
+
let t = p.current;
|
|
45
|
+
if (!(!t || i(t, e)) && e.key === "Tab") {
|
|
44
46
|
let n = document.activeElement;
|
|
45
|
-
(!(n instanceof HTMLElement && t.contains(n)) || n.getAttribute("role") === "menuitem") && (e.preventDefault(),
|
|
47
|
+
(!(n instanceof HTMLElement && t.contains(n)) || n === t || n.getAttribute("role") === "menuitem") && (e.preventDefault(), x());
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
});
|
|
49
51
|
return {
|
|
50
52
|
update: (e) => {
|
|
51
|
-
|
|
53
|
+
d = e;
|
|
52
54
|
},
|
|
53
|
-
subscribe:
|
|
54
|
-
getSnapshot:
|
|
55
|
-
panelRef:
|
|
56
|
-
open: (e, n) => {
|
|
57
|
-
t(
|
|
55
|
+
subscribe: f.subscribe,
|
|
56
|
+
getSnapshot: f.getSnapshot,
|
|
57
|
+
panelRef: p,
|
|
58
|
+
open: (e, n, i) => {
|
|
59
|
+
t(d?.gridRootRef.current ?? null), m = {
|
|
58
60
|
x: e.clientX,
|
|
59
61
|
y: e.clientY
|
|
60
|
-
},
|
|
61
|
-
...
|
|
62
|
+
}, h = n.length, f.setSnapshot({
|
|
63
|
+
...f.getSnapshot(),
|
|
62
64
|
state: {
|
|
63
65
|
params: e,
|
|
64
66
|
items: n
|
|
65
67
|
}
|
|
66
|
-
}),
|
|
68
|
+
}), y(), S.attach(), _();
|
|
69
|
+
let a = i?.focus ?? "panel";
|
|
70
|
+
g = requestAnimationFrame(() => {
|
|
71
|
+
g = null;
|
|
72
|
+
let e = p.current;
|
|
73
|
+
if (!(e === null || e.contains(e.ownerDocument.activeElement))) {
|
|
74
|
+
if (a === "firstItem") {
|
|
75
|
+
let t = e.querySelector("[role=\"menuitem\"]:not(:disabled):not([aria-disabled=\"true\"])");
|
|
76
|
+
if (t !== null) {
|
|
77
|
+
t.focus({ preventScroll: !0 });
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
r(e, d?.gridRootRef.current ?? null);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
67
84
|
},
|
|
68
|
-
close:
|
|
85
|
+
close: x,
|
|
69
86
|
dispose: () => {
|
|
70
|
-
|
|
87
|
+
_(), S.detach();
|
|
71
88
|
}
|
|
72
89
|
};
|
|
73
90
|
};
|
|
74
91
|
//#endregion
|
|
75
|
-
export {
|
|
92
|
+
export { d as createContextMenuController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("../utils/permissions.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/autoScrollGeometry.cjs"),i=require("../logic/elementScale.cjs"),a=require("./escapeClaimController.cjs"),o=require("./popoverSupport.cjs"),s=require("../logic/fillHandle.cjs");var c=168,l=84,u=8,d={status:`idle`},f=(e,t,n)=>{if(e.valueFormatter)try{return e.valueFormatter({value:n,row:t,column:e})}catch{return String(n??``)}return String(n??``)},p=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>e.key===t[n].key),m=500,h=6,g=2,_=e=>{let t=e.currentTarget;if(!(t instanceof Element))return!0;let n=t.getBoundingClientRect();return e.clientX>=n.left-g&&e.clientX<=n.right+g&&e.clientY>=n.top-g&&e.clientY<=n.bottom+g},v=(e,t)=>e===t||e!==void 0&&t!==void 0&&e.length===t.length&&e.every((e,n)=>Object.is(e,t[n])),y=(e,t)=>Object.is(e,t)||e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime(),b=(e,t)=>e.length===t.length&&e.every((e,n)=>e.viewIndex===t[n].viewIndex&&e.column.key===t[n].column.key&&y(e.value,t[n].value)),x=()=>{let g=null,y=e.createValueStore(d),x=e.createValueStore(null),S={current:null},C={current:null},w=null,T=null,E=null,D=e=>e?`toggled`:`auto`,O=e=>(n,r,i,a)=>t.isViewCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},e.rowModel,n,r,i,a),k=()=>{if(E===null||g===null)return;let e=y.getSnapshot();if(e.status===`dragging`&&e.toggled===E.toggled&&(e.target===E.target||e.target!==null&&E.target!==null&&e.target.direction===E.target.direction&&s.isSameFillRange(e.target.range,E.target.range)))return;let t=null;if(E.target!==null){let e=s.previewFillValue({rowModel:g.rowModel,columns:g.columns,source:E.source,target:E.target,request:D(E.toggled),canWriteCell:O(g),getFillValue:g.getFillValue});t=e&&f(e.column,e.row,e.value)||null}y.setSnapshot({status:`dragging`,source:E.source,target:E.target,toggled:E.toggled,previewText:t})},A=()=>{if(E===null||g===null)return;let e=s.resolveFillColumnBounds(g.columns),t=g.hitTest(E.pointer.x,E.pointer.y);e===null||t===null||(E.target=s.resolveFillTarget(E.source,t,g.rowModel.getRowCount(),e),k())},j=()=>{if(E===null||g===null)return;let e=E;e.rafId=requestAnimationFrame(j);let t=g.scrollContainerRef.current;if(!t)return;if(!e.armed){if(!r.hasPointerLeftActivationRadius(e.origin,e.pointer,6))return;e.armed=!0}let n=t.getBoundingClientRect(),a=r.resolveScrollContentBox({rectLeft:n.left,rectTop:n.top,clientLeft:t.clientLeft,clientTop:t.clientTop,clientWidth:t.clientWidth,clientHeight:t.clientHeight,scale:
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("../utils/permissions.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/autoScrollGeometry.cjs"),i=require("../logic/elementScale.cjs"),a=require("./escapeClaimController.cjs"),o=require("./popoverSupport.cjs"),s=require("../logic/fillHandle.cjs");var c=168,l=84,u=8,d={status:`idle`},f=(e,t,n)=>{if(e.valueFormatter)try{return e.valueFormatter({value:n,row:t,column:e})}catch{return String(n??``)}return String(n??``)},p=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>e.key===t[n].key),m=500,h=6,g=2,_=e=>{let t=e.currentTarget;if(!(t instanceof Element))return!0;let n=t.getBoundingClientRect();return e.clientX>=n.left-g&&e.clientX<=n.right+g&&e.clientY>=n.top-g&&e.clientY<=n.bottom+g},v=(e,t)=>e===t||e!==void 0&&t!==void 0&&e.length===t.length&&e.every((e,n)=>Object.is(e,t[n])),y=(e,t)=>Object.is(e,t)||e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime(),b=(e,t)=>e.length===t.length&&e.every((e,n)=>e.viewIndex===t[n].viewIndex&&e.column.key===t[n].column.key&&y(e.value,t[n].value)),x=()=>{let g=null,y=e.createValueStore(d),x=e.createValueStore(null),S={current:null},C={current:null},w=null,T=null,E=null,D=e=>e?`toggled`:`auto`,O=e=>(n,r,i,a)=>t.isViewCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},e.rowModel,n,r,i,a),k=()=>{if(E===null||g===null)return;let e=y.getSnapshot();if(e.status===`dragging`&&e.toggled===E.toggled&&(e.target===E.target||e.target!==null&&E.target!==null&&e.target.direction===E.target.direction&&s.isSameFillRange(e.target.range,E.target.range)))return;let t=null;if(E.target!==null){let e=s.previewFillValue({rowModel:g.rowModel,columns:g.columns,source:E.source,target:E.target,request:D(E.toggled),canWriteCell:O(g),getFillValue:g.getFillValue});t=e&&f(e.column,e.row,e.value)||null}y.setSnapshot({status:`dragging`,source:E.source,target:E.target,toggled:E.toggled,previewText:t})},A=()=>{if(E===null||g===null)return;let e=s.resolveFillColumnBounds(g.columns),t=g.hitTest(E.pointer.x,E.pointer.y);e===null||t===null||(E.target=s.resolveFillTarget(E.source,t,g.rowModel.getRowCount(),e),k())},j=()=>{if(E===null||g===null)return;let e=E;e.rafId=requestAnimationFrame(j);let t=g.scrollContainerRef.current;if(!t)return;if(!e.armed){if(!r.hasPointerLeftActivationRadius(e.origin,e.pointer,6))return;e.armed=!0}let n=t.getBoundingClientRect(),a=i.resolveElementScale(t,n),o=r.resolveScrollContentBox({rectLeft:n.left,rectTop:n.top,clientLeft:t.clientLeft,clientTop:t.clientTop,clientWidth:t.clientWidth,clientHeight:t.clientHeight,scale:a}),s=r.computeNextScrollPosition(t.scrollTop,r.resolveAutoScrollAxisDirection(e.pointer.y,r.resolveTopAutoScrollStart(o.top,(g.stickyTopHeight??0)*a.y,24),o.bottom-(g.footerHeight??0),24),18,t.scrollHeight-t.clientHeight),c=r.computeNextScrollPosition(t.scrollLeft,r.resolveAutoScrollAxisDirection(e.pointer.x,o.left,o.right,24),18,t.scrollWidth-t.clientWidth);(s!==t.scrollTop||c!==t.scrollLeft)&&(t.scrollTo({top:s,left:c,behavior:`auto`}),A())},M=(e,t)=>{let n=E;if(n!==null){if(E=null,n.cleanup(),n.rafId!==null&&cancelAnimationFrame(n.rafId),x.setSnapshot(null),y.setSnapshot(d),e&&n.target!==null){T=null,F(n.source,n.target,D(n.toggled),n.activeCell);return}T=e&&t!==void 0&&n.onSquare?{time:t,x:n.origin.x,y:n.origin.y}:null}},N=(e,t)=>{if(g===null)return;let{dispatch:r}=g;r(n.gridActions.startSelection({row:e.startRow,col:e.startCol})),r(n.gridActions.updateSelection({row:e.endRow,col:e.endCol})),r(n.gridActions.endSelection()),r(n.gridActions.activateCell(t??{row:e.startRow,col:e.startCol}))},P=(e,t)=>{let n=[];for(let r=t.startRow;r<=t.endRow;r+=1)n.push(e.getRowKey(r));return n},F=(e,t,n,r)=>{if(g===null||!g.enabled)return;let i=g,a=s.buildFillEdits({rowModel:i.rowModel,columns:i.columns,source:e,target:t,request:n,canWriteCell:O(i),getFillValue:i.getFillValue});if(a.edits.length===0)return;let o=s.unionFillRange(e,t),c=null,l=[],u=null;if(i.isServerSide){if(!i.applyServerSideCellEdits)return;u=P(i.rowModel,o),i.applyServerSideCellEdits(a.edits)}else{if(!i.applyRowsChange)return;let e=s.applyFillEditsToRows(i.rows,i.rowModel,a.edits);if(e===i.rows)return;c=i.rows,l.push(e),i.applyRowsChange(e)}w={source:e,target:t,range:o,previousSource:e,selectionConfirmed:!1,columns:i.columns,viewKey:i.viewKey,request:n,edits:a.edits,baseRows:c,baseRowModel:i.isServerSide?null:i.rowModel,emittedRows:l,rowKeys:u},N(o,r),y.setSnapshot({status:`filled`,range:o,kind:a.kind,seriesAvailable:a.seriesAvailable,menu:null})},I=o.createPopoverWindowBindings({onScroll:e=>{e.target instanceof Node&&S.current?.contains(e.target)||R(!1)},onResize:()=>R(!1),isInside:e=>S.current?.contains(e)===!0||C.current?.contains(e)===!0,onOutsidePointerDown:e=>R(g!==null&&o.isInsideGridRoot(g.gridRootRef,e)),getGridRoot:()=>g?.gridRootRef.current??null,onGridHidden:()=>R(!1),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),R(!0))}}),L=e=>{let t=y.getSnapshot();t.status!==`filled`||t.menu===e||y.setSnapshot({...t,menu:e})},R=e=>{I.detach(),L(null),e&&g!==null&&o.restoreGridFocus(g.gridRootRef)},z=()=>{let e=typeof document<`u`&&S.current?.contains(document.activeElement)===!0;w=null,I.detach(),y.getSnapshot().status===`filled`&&y.setSnapshot(d),e&&g!==null&&o.restoreGridFocus(g.gridRootRef)},B=e=>{let t=y.getSnapshot();if(t.status!==`filled`)return;if(t.menu!==null){R(!0);return}let n=Math.min(e.left,window.innerWidth-c-u);n=Math.max(u,n);let r=e.bottom+4;r+l>window.innerHeight-u&&(r=Math.max(u,e.top-4-l)),L({top:r,left:n}),I.attach()},V=(e,t)=>{let n=t.rowKeys;if(n===null)return!1;for(let r=0;r<n.length;r+=1)if(e.getRowKey(t.range.startRow+r)!==n[r])return!1;return!0},H=e=>{let n=y.getSnapshot(),r=w;if(R(!0),g===null||r===null||n.status!==`filled`||r.request===e)return;let i=g;if(i.isServerSide){if(!i.applyServerSideCellEdits||!V(i.rowModel,r)){z();return}let t=s.buildFillEdits({rowModel:i.rowModel,columns:r.columns,source:r.source,target:r.target,request:e,canWriteCell:O(i),getFillValue:i.getFillValue});r.request=e,t.edits.length>0&&!b(t.edits,r.edits)&&i.applyServerSideCellEdits(t.edits),r.edits=t.edits,y.setSnapshot({...n,kind:t.kind,menu:null});return}if(!i.amendRowsChange||r.baseRows===null||r.baseRowModel===null){z();return}let a=r.baseRowModel,o=s.buildFillEdits({rowModel:a,columns:r.columns,source:r.source,target:r.target,request:e,canWriteCell:(e,n,r,o)=>t.isViewCellEditable({readOnly:i.readOnly,canEditCell:i.canEditCell},a,e,n,r,o),getFillValue:i.getFillValue});if(r.request=e,!b(o.edits,r.edits)){let e=s.applyFillEditsToRows(r.baseRows,a,o.edits);r.emittedRows.push(e),r.edits=o.edits,i.amendRowsChange(e)}y.setSnapshot({...n,kind:o.kind,menu:null})},U=(e,t)=>{if(e?.type!==`cell`)return!1;let{start:n,end:r}=e.range;return s.isSameFillRange(t,{startRow:Math.min(n.row,r.row),endRow:Math.max(n.row,r.row),startCol:Math.min(n.col,r.col),endCol:Math.max(n.col,r.col)})},W=e=>{let t=w;if(t!==null){if(!e.enabled||e.editing||!p(e.columns,t.columns)||!v(e.viewKey,t.viewKey)){z();return}if(!e.isServerSide&&e.rows!==t.baseRows&&!t.emittedRows.includes(e.rows)){z();return}if(U(e.selection,t.range)){t.selectionConfirmed=!0;return}!t.selectionConfirmed&&U(e.selection,t.previousSource)||z()}},G=e=>{if(g===null||e.button!==0||(e.preventDefault(),E!==null||!g.enabled||g.editing))return;let t=s.resolveFillSource(g.selection,g.activeCell,g.rowModel.getRowCount(),g.columns.length);if(t===null)return;let n=T;T=null;let r=_(e);if(n!==null&&r&&e.timeStamp-n.time<=m&&Math.abs(e.clientX-n.x)<=h&&Math.abs(e.clientY-n.y)<=h){g.gridRootRef.current?.focus({preventScroll:!0}),K();return}z(),g.gridRootRef.current?.focus({preventScroll:!0});let i=e.pointerId,o=e=>{E===null||e.pointerId!==i||(E.pointer={x:e.clientX,y:e.clientY},E.toggled=e.ctrlKey||e.metaKey,x.setSnapshot(E.pointer),A())},c=e=>{E===null||e.pointerId!==i||(E.toggled=e.ctrlKey||e.metaKey,M(!0,e.timeStamp))},l=e=>{e.pointerId===i&&M(!1)},u=e=>{if(E===null)return;if(e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&e.key===`Escape`){M(!1);return}let t=e.ctrlKey||e.metaKey;t!==E.toggled&&(E.toggled=t,k())},d=()=>M(!1);window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,l),window.addEventListener(`keydown`,u,!0),window.addEventListener(`keyup`,u,!0),window.addEventListener(`blur`,d);let f=a.beginEscapeCancelableDrag(),p={x:e.clientX,y:e.clientY};E={pointerId:i,source:t,activeCell:g.activeCell,origin:p,onSquare:r,pointer:p,toggled:e.ctrlKey||e.metaKey,target:null,armed:!1,rafId:null,cleanup:()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,l),window.removeEventListener(`keydown`,u,!0),window.removeEventListener(`keyup`,u,!0),window.removeEventListener(`blur`,d),f()}},x.setSnapshot(p),k(),E.rafId=requestAnimationFrame(j)},K=()=>{if(g===null||E!==null||!g.enabled||g.editing)return;let e=s.resolveFillSource(g.selection,g.activeCell,g.rowModel.getRowCount(),g.columns.length);if(e===null)return;let t=s.resolveFillDoubleClickTarget(e,g.rowModel,g.columns);t!==null&&(z(),F(e,t,`auto`,g.activeCell))};return{update:e=>{g=e,E!==null&&(!e.enabled||e.editing)&&M(!1),W(e)},subscribe:y.subscribe,getSnapshot:y.getSnapshot,subscribePointer:x.subscribe,getPointerSnapshot:x.getSnapshot,handlePointerDown:G,handleDoubleClick:K,toggleMenu:B,closeMenu:()=>R(!0),chooseKind:H,menuPanel:S,chipElement:C,dispose:()=>{M(!1),I.detach(),w=null}}};exports.createFillHandleController=x;
|
|
@@ -41,6 +41,7 @@ export type FillHandleControllerArgs<T> = {
|
|
|
41
41
|
scrollContainerRef: ReadonlyRef<HTMLElement | null>;
|
|
42
42
|
gridRootRef: ReadonlyRef<HTMLElement | null>;
|
|
43
43
|
footerHeight?: number;
|
|
44
|
+
stickyTopHeight?: number;
|
|
44
45
|
applyRowsChange?: (nextRows: T[]) => void;
|
|
45
46
|
amendRowsChange?: (nextRows: T[]) => void;
|
|
46
47
|
applyServerSideCellEdits?: (edits: FillCellEdit<T>[]) => number;
|