@ishibashi0112/spreadsheet-grid-core 0.61.0 → 0.62.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/columnMenuController.cjs +1 -1
- package/dist/controllers/columnMenuController.d.ts +2 -0
- package/dist/controllers/columnMenuController.js +72 -60
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.js +40 -32
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +3 -0
- package/dist/controllers/keyboardController.js +184 -91
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.js +11 -2
- package/dist/controllers/popoverSupport.cjs +1 -1
- package/dist/controllers/popoverSupport.d.ts +1 -0
- package/dist/controllers/popoverSupport.js +14 -2
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.js +153 -109
- package/dist/controllers/saveStatusController.cjs +1 -1
- package/dist/controllers/saveStatusController.js +71 -25
- package/dist/controllers/serverSideRowModel.cjs +1 -1
- package/dist/controllers/serverSideRowModel.d.ts +1 -0
- package/dist/controllers/serverSideRowModel.js +180 -133
- package/dist/engine/gridApi.cjs +1 -1
- package/dist/engine/gridApi.d.ts +4 -1
- package/dist/engine/gridApi.js +173 -127
- package/dist/engine/notifiers.cjs +1 -1
- package/dist/engine/notifiers.d.ts +1 -0
- package/dist/engine/notifiers.js +10 -5
- package/dist/logic/detailRow.cjs +1 -1
- package/dist/logic/detailRow.d.ts +1 -0
- package/dist/logic/detailRow.js +9 -4
- package/dist/logic/editorValues.cjs +1 -1
- package/dist/logic/editorValues.js +14 -13
- package/dist/logic/filterSummary.cjs +1 -1
- package/dist/logic/filterSummary.d.ts +9 -3
- package/dist/logic/filterSummary.js +39 -13
- package/dist/logic/gridAsk.cjs +1 -1
- package/dist/logic/gridAsk.js +106 -106
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +14 -0
- package/dist/logic/gridState.js +80 -45
- package/dist/logic/numberFilterCondition.cjs +1 -1
- package/dist/logic/numberFilterCondition.d.ts +1 -1
- package/dist/logic/numberFilterCondition.js +12 -9
- package/dist/logic/urgentFilters.cjs +1 -0
- package/dist/logic/urgentFilters.d.ts +3 -0
- package/dist/logic/urgentFilters.js +6 -0
- package/dist/logic/validation.cjs +1 -1
- package/dist/logic/validation.d.ts +1 -1
- package/dist/logic/validation.js +10 -10
- package/dist/logic/valueFormatters.d.ts +2 -1
- package/dist/model/gridStore.cjs +1 -1
- package/dist/model/gridStore.d.ts +1 -0
- package/dist/model/gridStore.js +2 -1
- package/dist/model/gridTypes.core.d.ts +86 -13
- package/dist/utils/permissions.cjs +1 -1
- package/dist/utils/permissions.js +5 -3
- 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=200,r=8,
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("./popoverSupport.cjs");var n=200,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:()=>{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)),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.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())}),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;
|
|
@@ -24,6 +24,7 @@ export type MenuButtonPointerEvent = {
|
|
|
24
24
|
};
|
|
25
25
|
export type MenuButtonClickEvent = {
|
|
26
26
|
currentTarget: HTMLButtonElement;
|
|
27
|
+
detail: number;
|
|
27
28
|
preventDefault: () => void;
|
|
28
29
|
stopPropagation: () => void;
|
|
29
30
|
};
|
|
@@ -43,6 +44,7 @@ export type ColumnMenuController<T> = {
|
|
|
43
44
|
openFromButton: (column: GridColumn<T>, event: MenuButtonPointerEvent) => void;
|
|
44
45
|
openFromButtonClick: (column: GridColumn<T>, event: MenuButtonClickEvent) => void;
|
|
45
46
|
openFromContextMenu: (column: GridColumn<T>, event: MenuContextEvent) => void;
|
|
47
|
+
openFromKeyboard: (column: GridColumn<T>, anchor: HTMLElement) => void;
|
|
46
48
|
close: () => void;
|
|
47
49
|
dispose: () => void;
|
|
48
50
|
};
|
|
@@ -1,110 +1,122 @@
|
|
|
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, handleMenuKeyNavigation as r, isInsideGridRoot as i, restoreGridFocus as a } from "./popoverSupport.js";
|
|
3
3
|
//#region src/controllers/columnMenuController.ts
|
|
4
|
-
var
|
|
5
|
-
let
|
|
4
|
+
var o = 200, s = ".ssg-menu-item", c = 8, l = 6, u = 289, d = () => {
|
|
5
|
+
let d = null, f = 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
|
+
}), p = { current: null }, m = null, h = !1, g = null, _ = null, v = null, y = (e) => {
|
|
9
|
+
let t = f.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 || f.setSnapshot({
|
|
11
11
|
...t,
|
|
12
12
|
layout: e
|
|
13
13
|
});
|
|
14
|
-
},
|
|
15
|
-
|
|
14
|
+
}, b = () => {
|
|
15
|
+
v !== null && (cancelAnimationFrame(v), v = null), w.detach(), f.setSnapshot({
|
|
16
16
|
columnKey: null,
|
|
17
17
|
layout: null
|
|
18
18
|
});
|
|
19
|
-
},
|
|
20
|
-
if (
|
|
21
|
-
|
|
19
|
+
}, x = () => {
|
|
20
|
+
if (f.getSnapshot().columnKey === null) {
|
|
21
|
+
y(null);
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
let e, t, n, r =
|
|
25
|
-
if (
|
|
26
|
-
if (!
|
|
27
|
-
|
|
24
|
+
let e, t, n, r = p.current, i = r ? r.scrollHeight + (r.offsetHeight - r.clientHeight) : u;
|
|
25
|
+
if (m) {
|
|
26
|
+
if (!m.isConnected) {
|
|
27
|
+
m = null, b();
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
let r =
|
|
31
|
-
t = r.right -
|
|
32
|
-
} else if (
|
|
30
|
+
let r = m.getBoundingClientRect();
|
|
31
|
+
t = r.right - o, e = r.bottom + l, n = r.top - i - l;
|
|
32
|
+
} else if (g) t = g.x, e = g.y, n = g.y - i;
|
|
33
33
|
else {
|
|
34
|
-
|
|
34
|
+
y(null);
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
t = Math.max(
|
|
38
|
-
let
|
|
39
|
-
e + i >
|
|
40
|
-
let
|
|
41
|
-
|
|
37
|
+
t = Math.max(c, t), t = Math.min(t, window.innerWidth - o - c);
|
|
38
|
+
let a = window.innerHeight - c;
|
|
39
|
+
e + i > a && n >= c && (e = n), e = Math.max(c, e);
|
|
40
|
+
let s = a - e;
|
|
41
|
+
y({
|
|
42
42
|
top: e,
|
|
43
43
|
left: t,
|
|
44
|
-
width:
|
|
45
|
-
maxHeight: i >
|
|
44
|
+
width: o,
|
|
45
|
+
maxHeight: i > s ? Math.max(s, 0) : void 0
|
|
46
46
|
});
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
onResize:
|
|
47
|
+
}, S = (e) => {
|
|
48
|
+
b(), m = null, g = null, d !== null && e && a(d.gridRootRef);
|
|
49
|
+
}, C = () => S(!0), w = n({
|
|
50
|
+
onResize: x,
|
|
51
51
|
onScroll: () => {
|
|
52
|
-
if (
|
|
53
|
-
|
|
52
|
+
if (g) {
|
|
53
|
+
C();
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
x();
|
|
57
57
|
},
|
|
58
|
-
isInside: (e) =>
|
|
59
|
-
onOutsidePointerDown: (e) =>
|
|
58
|
+
isInside: (e) => p.current?.contains(e) === !0 || m?.contains(e) === !0,
|
|
59
|
+
onOutsidePointerDown: (e) => S(d !== null && i(d.gridRootRef, e)),
|
|
60
60
|
onKeyDown: (e) => {
|
|
61
|
-
e.key === "Escape"
|
|
61
|
+
if (e.key === "Escape") {
|
|
62
|
+
e.preventDefault(), C();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
let t = p.current;
|
|
66
|
+
if (!t || r(t, e, s)) return;
|
|
67
|
+
let n = document.activeElement;
|
|
68
|
+
e.key === "Tab" && n instanceof HTMLElement && n.matches(s) && t.contains(n) && (e.preventDefault(), C());
|
|
62
69
|
}
|
|
63
|
-
}),
|
|
64
|
-
|
|
65
|
-
...
|
|
70
|
+
}), T = (e) => {
|
|
71
|
+
f.setSnapshot({
|
|
72
|
+
...f.getSnapshot(),
|
|
66
73
|
columnKey: e
|
|
67
|
-
}),
|
|
68
|
-
|
|
69
|
-
}),
|
|
70
|
-
},
|
|
71
|
-
t(
|
|
74
|
+
}), x(), v !== null && cancelAnimationFrame(v), v = requestAnimationFrame(() => {
|
|
75
|
+
v = null, x(), h && (h = !1, p.current?.querySelector(s)?.focus());
|
|
76
|
+
}), w.attach();
|
|
77
|
+
}, E = (e, n, r = !1) => {
|
|
78
|
+
t(d?.gridRootRef.current ?? null), m = n, g = null, h = r, T(e.key);
|
|
72
79
|
};
|
|
73
80
|
return {
|
|
74
81
|
update: (e) => {
|
|
75
|
-
|
|
82
|
+
d = e;
|
|
76
83
|
},
|
|
77
|
-
subscribe:
|
|
78
|
-
getSnapshot:
|
|
79
|
-
panelRef:
|
|
84
|
+
subscribe: f.subscribe,
|
|
85
|
+
getSnapshot: f.getSnapshot,
|
|
86
|
+
panelRef: p,
|
|
80
87
|
openFromButton: (e, t) => {
|
|
81
|
-
if (t.preventDefault(), t.stopPropagation(), !
|
|
88
|
+
if (t.preventDefault(), t.stopPropagation(), !d?.enableColumnMenu || t.button !== 0) return;
|
|
82
89
|
let n = t.currentTarget;
|
|
83
|
-
if (
|
|
84
|
-
|
|
90
|
+
if (f.getSnapshot().columnKey === e.key && m === n) {
|
|
91
|
+
C();
|
|
85
92
|
return;
|
|
86
93
|
}
|
|
87
94
|
if (t.pointerType === "touch") {
|
|
88
|
-
|
|
95
|
+
_ = n;
|
|
89
96
|
return;
|
|
90
97
|
}
|
|
91
|
-
|
|
98
|
+
E(e, n);
|
|
92
99
|
},
|
|
93
100
|
openFromButtonClick: (e, t) => {
|
|
94
|
-
let n =
|
|
95
|
-
|
|
101
|
+
let n = _;
|
|
102
|
+
_ = null;
|
|
103
|
+
let r = n === null && t.detail === 0;
|
|
104
|
+
!d?.enableColumnMenu || n !== t.currentTarget && !r || (t.preventDefault(), t.stopPropagation(), E(e, t.currentTarget, r));
|
|
96
105
|
},
|
|
97
106
|
openFromContextMenu: (e, n) => {
|
|
98
|
-
|
|
107
|
+
d?.enableColumnMenu && (n.preventDefault(), n.stopPropagation(), t(d.gridRootRef.current), m = null, g = {
|
|
99
108
|
x: n.clientX,
|
|
100
109
|
y: n.clientY
|
|
101
|
-
},
|
|
110
|
+
}, h = !1, T(e.key));
|
|
111
|
+
},
|
|
112
|
+
openFromKeyboard: (e, t) => {
|
|
113
|
+
d?.enableColumnMenu && E(e, t, !0);
|
|
102
114
|
},
|
|
103
|
-
close:
|
|
115
|
+
close: C,
|
|
104
116
|
dispose: () => {
|
|
105
|
-
|
|
117
|
+
v !== null && (cancelAnimationFrame(v), v = null), w.detach();
|
|
106
118
|
}
|
|
107
119
|
};
|
|
108
120
|
};
|
|
109
121
|
//#endregion
|
|
110
|
-
export {
|
|
122
|
+
export { d as createColumnMenuController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("./popoverSupport.cjs");var n=220,r=8,i=34,a=16,o=()=>{let o=null,s=e.createValueStore({state:null,layout:null}),c={current:null},l=null,u=0,d=e=>{let t=s.getSnapshot();t.layout===e||t.layout!==null&&e!==null&&t.layout.top===e.top&&t.layout.left===e.left&&t.layout.width===e.width||s.setSnapshot({...t,layout:e})},f=()=>{if(!l){d(null);return}let e=u*i+a,t=l.x,o=l.y,s=l.y-e;t=Math.max(r,t),t=Math.min(t,window.innerWidth-n-r),o+e>window.innerHeight-r&&(o=s),o=Math.max(r,o),d({top:o,left:t,width:n})},p=e=>{s.setSnapshot({state:null,layout:null}),l=null,u=0,h.detach(),o!==null&&e&&t.restoreGridFocus(o.gridRootRef)},m=()=>p(!0),h=t.createPopoverWindowBindings({onResize:f,onScroll:m,isInside:e=>c.current?.contains(e)===!0,onOutsidePointerDown:e=>p(o!==null&&t.isInsideGridRoot(o.gridRootRef,e)),onKeyDown:e=>{e.key===`Escape
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("./popoverSupport.cjs");var n=220,r=8,i=34,a=16,o=()=>{let o=null,s=e.createValueStore({state:null,layout:null}),c={current:null},l=null,u=0,d=e=>{let t=s.getSnapshot();t.layout===e||t.layout!==null&&e!==null&&t.layout.top===e.top&&t.layout.left===e.left&&t.layout.width===e.width||s.setSnapshot({...t,layout:e})},f=()=>{if(!l){d(null);return}let e=u*i+a,t=l.x,o=l.y,s=l.y-e;t=Math.max(r,t),t=Math.min(t,window.innerWidth-n-r),o+e>window.innerHeight-r&&(o=s),o=Math.max(r,o),d({top:o,left:t,width:n})},p=e=>{s.setSnapshot({state:null,layout:null}),l=null,u=0,h.detach(),o!==null&&e&&t.restoreGridFocus(o.gridRootRef)},m=()=>p(!0),h=t.createPopoverWindowBindings({onResize:f,onScroll:m,isInside:e=>c.current?.contains(e)===!0,onOutsidePointerDown:e=>p(o!==null&&t.isInsideGridRoot(o.gridRootRef,e)),onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),m();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.getAttribute(`role`)===`menuitem`)&&(e.preventDefault(),m())}}});return{update:e=>{o=e},subscribe:s.subscribe,getSnapshot:s.getSnapshot,panelRef:c,open:(e,n)=>{t.blurForPopover(o?.gridRootRef.current??null),l={x:e.clientX,y:e.clientY},u=n.length,s.setSnapshot({...s.getSnapshot(),state:{params:e,items:n}}),f(),h.attach()},close:m,dispose:()=>{h.detach()}}};exports.createContextMenuController=o;
|
|
@@ -1,65 +1,73 @@
|
|
|
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, handleMenuKeyNavigation as r, isInsideGridRoot as i, restoreGridFocus as a } from "./popoverSupport.js";
|
|
3
3
|
//#region src/controllers/contextMenuController.ts
|
|
4
|
-
var
|
|
5
|
-
let
|
|
4
|
+
var o = 220, s = 8, c = 34, l = 16, u = () => {
|
|
5
|
+
let u = null, d = e({
|
|
6
6
|
state: null,
|
|
7
7
|
layout: null
|
|
8
|
-
}),
|
|
9
|
-
let t =
|
|
10
|
-
t.layout === e || t.layout !== null && e !== null && t.layout.top === e.top && t.layout.left === e.left && t.layout.width === e.width ||
|
|
8
|
+
}), f = { current: null }, p = null, m = 0, h = (e) => {
|
|
9
|
+
let t = d.getSnapshot();
|
|
10
|
+
t.layout === e || t.layout !== null && e !== null && t.layout.top === e.top && t.layout.left === e.left && t.layout.width === e.width || d.setSnapshot({
|
|
11
11
|
...t,
|
|
12
12
|
layout: e
|
|
13
13
|
});
|
|
14
|
-
},
|
|
15
|
-
if (!
|
|
16
|
-
|
|
14
|
+
}, g = () => {
|
|
15
|
+
if (!p) {
|
|
16
|
+
h(null);
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
let e =
|
|
20
|
-
t = Math.max(
|
|
19
|
+
let e = m * c + l, t = p.x, n = p.y, r = p.y - e;
|
|
20
|
+
t = Math.max(s, t), t = Math.min(t, window.innerWidth - o - s), n + e > window.innerHeight - s && (n = r), n = Math.max(s, n), h({
|
|
21
21
|
top: n,
|
|
22
22
|
left: t,
|
|
23
|
-
width:
|
|
23
|
+
width: o
|
|
24
24
|
});
|
|
25
|
-
},
|
|
26
|
-
|
|
25
|
+
}, _ = (e) => {
|
|
26
|
+
d.setSnapshot({
|
|
27
27
|
state: null,
|
|
28
28
|
layout: null
|
|
29
|
-
}),
|
|
30
|
-
},
|
|
31
|
-
onResize:
|
|
32
|
-
onScroll:
|
|
33
|
-
isInside: (e) =>
|
|
34
|
-
onOutsidePointerDown: (e) =>
|
|
29
|
+
}), p = null, m = 0, y.detach(), u !== null && e && a(u.gridRootRef);
|
|
30
|
+
}, v = () => _(!0), y = n({
|
|
31
|
+
onResize: g,
|
|
32
|
+
onScroll: v,
|
|
33
|
+
isInside: (e) => f.current?.contains(e) === !0,
|
|
34
|
+
onOutsidePointerDown: (e) => _(u !== null && i(u.gridRootRef, e)),
|
|
35
35
|
onKeyDown: (e) => {
|
|
36
|
-
e.key === "Escape"
|
|
36
|
+
if (e.key === "Escape") {
|
|
37
|
+
e.preventDefault(), v();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
let t = f.current;
|
|
41
|
+
if (!(!t || r(t, e)) && e.key === "Tab") {
|
|
42
|
+
let n = document.activeElement;
|
|
43
|
+
(!(n instanceof HTMLElement && t.contains(n)) || n.getAttribute("role") === "menuitem") && (e.preventDefault(), v());
|
|
44
|
+
}
|
|
37
45
|
}
|
|
38
46
|
});
|
|
39
47
|
return {
|
|
40
48
|
update: (e) => {
|
|
41
|
-
|
|
49
|
+
u = e;
|
|
42
50
|
},
|
|
43
|
-
subscribe:
|
|
44
|
-
getSnapshot:
|
|
45
|
-
panelRef:
|
|
51
|
+
subscribe: d.subscribe,
|
|
52
|
+
getSnapshot: d.getSnapshot,
|
|
53
|
+
panelRef: f,
|
|
46
54
|
open: (e, n) => {
|
|
47
|
-
t(
|
|
55
|
+
t(u?.gridRootRef.current ?? null), p = {
|
|
48
56
|
x: e.clientX,
|
|
49
57
|
y: e.clientY
|
|
50
|
-
},
|
|
51
|
-
...
|
|
58
|
+
}, m = n.length, d.setSnapshot({
|
|
59
|
+
...d.getSnapshot(),
|
|
52
60
|
state: {
|
|
53
61
|
params: e,
|
|
54
62
|
items: n
|
|
55
63
|
}
|
|
56
|
-
}),
|
|
64
|
+
}), g(), y.attach();
|
|
57
65
|
},
|
|
58
|
-
close:
|
|
66
|
+
close: v,
|
|
59
67
|
dispose: () => {
|
|
60
|
-
|
|
68
|
+
y.detach();
|
|
61
69
|
}
|
|
62
70
|
};
|
|
63
71
|
};
|
|
64
72
|
//#endregion
|
|
65
|
-
export {
|
|
73
|
+
export { u as createContextMenuController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../model/gridActions.cjs"),n=require("../logic/geometry.cjs"),r=require("../logic/domGuards.cjs");var i=()=>{let
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs");require("../logic/rowReorder.cjs"),require("../logic/detailRow.cjs");const t=require("../model/gridActions.cjs"),n=require("../logic/geometry.cjs"),r=require("../logic/domGuards.cjs");var i=e=>e===`__ssg_row_drag_handle__`||e===`__ssg_detail_toggle__`,a=10,o=()=>{let o=null,s=e=>{o=e},c=(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},l=(e,t)=>c(e,t,-1,c(e,t,1,t)),u=e=>c(e,0,1,0),d=e=>{let t=e.getRowCount()-1;return c(e,t,-1,t)},f=e=>{let t=e.findIndex(e=>!i(e.key));return t<0?0:t},p=(e,n,r)=>{if(o===null)return;let{uiState:i,dispatch:a}=o;if(r){let r=i.selection?.type===`cell`?i.selection.range.start:e;a(t.gridActions.startSelection(r)),a(t.gridActions.updateSelection(n)),a(t.gridActions.endSelection()),a(t.gridActions.activateCell(n));return}a(t.gridActions.startSelection(n)),a(t.gridActions.endSelection()),a(t.gridActions.activateCell(n))},m=()=>{if(o===null||o.uiState.activeCell)return!1;let{rowModel:e,visibleColumns:t}=o;if(e.getRowCount()===0||t.length===0)return!0;let n={row:u(e),col:f(t)};return p(n,n,!1),!0},h=e=>{let t=o?.uiState;return e&&t?.selection?.type===`cell`?t.selection.range.end:t?.activeCell??{row:0,col:0}},g=(e,t,r)=>{if(o===null)return;let{rowModel:i,visibleColumns:a}=o,s=i.getRowCount();if(s===0||a.length===0||m())return;let u=h(r),d=n.clamp(u.row+e,0,s-1);d=e===0?l(i,d):c(i,d,e>0?1:-1,u.row);let f={row:d,col:n.clamp(u.col+t,0,a.length-1)};p(u,f,r)},_=(e,t)=>{if(o===null)return;let{uiState:r,rowModel:i,visibleColumns:a}=o;if(i.getRowCount()===0||a.length===0)return;let s=r.activeCell?h(t):{row:u(i),col:f(a)},c=e(s,i,a);p(s,{row:l(i,n.clamp(c.row,0,i.getRowCount()-1)),col:n.clamp(c.col,0,a.length-1)},t&&r.activeCell!==null)},v=(e,t,r)=>{let i=t.getRowCount(),s=o?.resolvePageRow?o.resolvePageRow(e.row,r):e.row+r*a,l=n.clamp(r>0?Math.max(s,e.row+1):Math.min(s,e.row-1),0,i-1),u=c(t,l,r,-1);return u>=0?u:c(t,l,r>0?-1:1,e.row)};return{update:s,handleKeyDown:async n=>{if(o===null)return;let{uiState:i,rowModel:a,visibleColumns:s,readOnly:c,canEditCell:l,setEditorInitialValue:p,dispatch:h,handleCopy:y,openFind:b,handleCellDoubleClick:x,isWholeGridSelected:S,selectEntireGrid:C,onUndo:w,onRedo:T,onClearSelection:E,enableClearOnDelete:D,onToggleCheckboxCell:O,onToggleGroup:k,onToggleDetailRow:A}=o;if(r.shouldIgnoreGridKeydown(n.target)||i.editingCell||n.isComposing&&r.isImeInputTarget(n.target))return;if((n.ctrlKey||n.metaKey)&&n.key.toLowerCase()===`c`){n.preventDefault(),await y();return}if((n.ctrlKey||n.metaKey)&&n.key.toLowerCase()===`f`&&b){n.preventDefault(),b();return}if((n.ctrlKey||n.metaKey)&&n.key.toLowerCase()===`a`){if(n.preventDefault(),S){h(t.gridActions.clearSelection()),h(t.gridActions.activateCell(null));return}C();return}if((n.ctrlKey||n.metaKey)&&!n.isComposing){if(n.key.toLowerCase()===`z`){n.preventDefault(),n.shiftKey?T():w();return}if(n.key.toLowerCase()===`y`&&!n.shiftKey){n.preventDefault(),T();return}}let j=n.ctrlKey||n.metaKey;if(n.key===`ArrowDown`&&n.altKey&&!j&&!n.shiftKey&&i.activeCell&&o.openColumnMenu?.(i.activeCell.col)){n.preventDefault();return}if(j&&!n.altKey&&(n.key===`ArrowUp`||n.key===`ArrowDown`)){n.preventDefault();let e=n.key===`ArrowDown`;_((t,n)=>({row:e?d(n):u(n),col:t.col}),n.shiftKey);return}if(j&&!n.altKey&&(n.key===`ArrowLeft`||n.key===`ArrowRight`)){n.preventDefault();let e=n.key===`ArrowRight`;_((t,n,r)=>({row:t.row,col:e?r.length-1:f(r)}),n.shiftKey);return}if((n.key===`Home`||n.key===`End`)&&!n.altKey){n.preventDefault();let e=n.key===`End`;_((t,n,r)=>({row:j?e?d(n):u(n):t.row,col:e?r.length-1:f(r)}),n.shiftKey);return}if((n.key===`PageDown`||n.key===`PageUp`)&&!j&&!n.altKey){if(n.preventDefault(),m())return;let e=n.key===`PageDown`?1:-1;_((t,n)=>({row:v(t,n,e),col:t.col}),n.shiftKey);return}if(n.key===`ArrowUp`){n.preventDefault(),g(-1,0,n.shiftKey);return}if(n.key===`ArrowDown`){n.preventDefault(),g(1,0,n.shiftKey);return}if(n.key===`ArrowLeft`){n.preventDefault(),g(0,-1,n.shiftKey);return}if(n.key===`ArrowRight`){n.preventDefault(),g(0,1,n.shiftKey);return}if(n.key===`Tab`){if(!i.activeCell&&!n.shiftKey){if(o.rowModel.getRowCount()===0||o.visibleColumns.length===0)return;n.preventDefault(),m();return}let e=i.activeCell?.col??0;if(n.shiftKey?e<=0:e>=o.visibleColumns.length-1)return;n.preventDefault(),g(0,n.shiftKey?-1:1,!1);return}if(n.key===`Escape`){n.preventDefault(),h(t.gridActions.clearSelection());return}if((n.key===`Delete`||n.key===`Backspace`)&&D){n.preventDefault(),E();return}if((n.key===`Enter`||n.key===` `)&&i.activeCell){let e=a.getGroupRow?.(i.activeCell.row);if(e){n.preventDefault(),k(e.groupKey);return}if(A&&s[i.activeCell.col]?.key===`__ssg_detail_toggle__`&&A(i.activeCell)){n.preventDefault();return}}if(n.key===`Enter`||n.key===`F2`){if(n.preventDefault(),i.activeCell){x(i.activeCell);return}n.key===`Enter`&&m();return}if(r.isPrintableKey(n)&&i.activeCell){let r=a.getRow(i.activeCell.row),o=s[i.activeCell.col];if(!r||!o||!e.isViewCellEditable({readOnly:c,canEditCell:l},a,i.activeCell.row,i.activeCell.col,r,o))return;if(o.editor?.type===`checkbox`){n.preventDefault(),n.key===` `&&O(i.activeCell);return}n.preventDefault(),p(n.key),h(t.gridActions.startEdit(i.activeCell))}}}};exports.createKeyboardController=o;
|
|
@@ -29,6 +29,9 @@ export type KeyboardControllerArgs<T> = {
|
|
|
29
29
|
enableClearOnDelete: boolean;
|
|
30
30
|
onToggleCheckboxCell: (cell: CellCoord) => void;
|
|
31
31
|
onToggleGroup: (groupKey: string) => void;
|
|
32
|
+
onToggleDetailRow?: (cell: CellCoord) => boolean;
|
|
33
|
+
resolvePageRow?: (fromRow: number, direction: 1 | -1) => number;
|
|
34
|
+
openColumnMenu?: (col: number) => boolean;
|
|
32
35
|
};
|
|
33
36
|
export type KeyboardController<T> = {
|
|
34
37
|
update: (args: KeyboardControllerArgs<T>) => void;
|