@ishibashi0112/spreadsheet-grid-core 1.2.1 → 1.3.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.js +79 -71
- package/dist/controllers/columnMenuController.cjs +1 -1
- package/dist/controllers/columnMenuController.js +75 -73
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.js +63 -61
- package/dist/controllers/detailRowController.cjs +1 -1
- package/dist/controllers/detailRowController.js +60 -59
- package/dist/controllers/detailTabOrder.cjs +1 -1
- package/dist/controllers/detailTabOrder.js +17 -16
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.d.ts +4 -1
- package/dist/controllers/editController.js +163 -91
- package/dist/controllers/escapeClaimController.cjs +1 -1
- package/dist/controllers/escapeClaimController.js +23 -19
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.js +107 -106
- package/dist/controllers/filterPopoverController.cjs +1 -1
- package/dist/controllers/filterPopoverController.js +1 -0
- package/dist/controllers/imeInputController.cjs +1 -1
- package/dist/controllers/imeInputController.js +87 -76
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +3 -0
- package/dist/controllers/keyboardController.js +15 -13
- package/dist/controllers/popoverSupport.cjs +1 -1
- package/dist/controllers/popoverSupport.d.ts +3 -0
- package/dist/controllers/popoverSupport.js +62 -41
- package/dist/controllers/toolPanelController.cjs +1 -1
- package/dist/controllers/toolPanelController.js +74 -73
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.d.ts +1 -1
- package/dist/controllers/tooltipController.js +122 -97
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.js +55 -54
- package/dist/engine/columnCommands.cjs +1 -1
- package/dist/engine/columnCommands.d.ts +2 -1
- package/dist/engine/columnCommands.js +98 -67
- package/dist/engine/exportCommands.cjs +1 -1
- package/dist/engine/exportCommands.js +2 -2
- package/dist/engine/gridApi.cjs +6 -5
- package/dist/engine/gridApi.d.ts +1 -0
- package/dist/engine/gridApi.js +151 -143
- package/dist/engine/rowSelectionCommands.cjs +1 -1
- package/dist/engine/rowSelectionCommands.d.ts +5 -0
- package/dist/engine/rowSelectionCommands.js +73 -38
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +2 -2
- package/dist/logic/contextMenuTarget.cjs +1 -1
- package/dist/logic/contextMenuTarget.d.ts +20 -2
- package/dist/logic/contextMenuTarget.js +62 -3
- package/dist/logic/dateFilterCondition.cjs +1 -1
- package/dist/logic/dateFilterCondition.d.ts +1 -0
- package/dist/logic/dateFilterCondition.js +17 -13
- package/dist/logic/detailRow.cjs +1 -1
- package/dist/logic/detailRow.d.ts +2 -1
- package/dist/logic/detailRow.js +19 -18
- package/dist/logic/domGuards.cjs +1 -1
- package/dist/logic/domGuards.d.ts +5 -0
- package/dist/logic/domGuards.js +11 -1
- package/dist/logic/editorValues.cjs +1 -1
- package/dist/logic/editorValues.d.ts +1 -0
- package/dist/logic/editorValues.js +10 -7
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +1 -0
- package/dist/logic/gridState.js +19 -16
- package/dist/logic/localeText.cjs +1 -1
- package/dist/logic/localeText.js +2 -2
- package/dist/logic/rowDragTarget.cjs +1 -0
- package/dist/logic/rowDragTarget.d.ts +14 -0
- package/dist/logic/rowDragTarget.js +47 -0
- package/dist/logic/selectEditorState.d.ts +4 -4
- package/dist/logic/valueFormatters.d.ts +8 -3
- package/dist/model/gridTypes.core.d.ts +31 -12
- package/dist/utils/clipboard.cjs +4 -4
- package/dist/utils/clipboard.js +60 -59
- package/dist/utils/popupContainer.cjs +1 -1
- package/dist/utils/popupContainer.js +35 -28
- package/dist/utils/shadowDom.cjs +1 -0
- package/dist/utils/shadowDom.d.ts +5 -0
- package/dist/utils/shadowDom.js +33 -0
- package/package.json +1 -1
|
@@ -1,97 +1,99 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getActiveElement as e } from "../utils/shadowDom.js";
|
|
2
|
+
import { createValueStore as t } from "../logic/valueStore.js";
|
|
3
|
+
import { blurForPopover as n, createPopoverWindowBindings as r, focusPanelIfIdle as i, handleMenuKeyNavigation as a, isFocusInPopupOpenedFromMenu as o, isInsideGridRoot as s, restoreGridFocus as c } from "./popoverSupport.js";
|
|
3
4
|
//#region src/controllers/contextMenuController.ts
|
|
4
|
-
var
|
|
5
|
-
let
|
|
5
|
+
var l = 220, u = 8, d = 34, f = 16, p = () => {
|
|
6
|
+
let p = null, m = t({
|
|
6
7
|
state: null,
|
|
7
8
|
layout: null
|
|
8
|
-
}),
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
let t =
|
|
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 ||
|
|
9
|
+
}), h = { current: null }, g = null, _ = 0, v = null, y = () => {
|
|
10
|
+
v !== null && (cancelAnimationFrame(v), v = null);
|
|
11
|
+
}, b = (e) => {
|
|
12
|
+
let t = m.getSnapshot();
|
|
13
|
+
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 || m.setSnapshot({
|
|
13
14
|
...t,
|
|
14
15
|
layout: e
|
|
15
16
|
});
|
|
16
|
-
},
|
|
17
|
-
if (!
|
|
18
|
-
|
|
17
|
+
}, x = () => {
|
|
18
|
+
if (!g) {
|
|
19
|
+
b(null);
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
21
|
-
let e =
|
|
22
|
-
n = Math.max(
|
|
23
|
-
let a = window.innerHeight -
|
|
24
|
-
r + t > a && (r = i), r = Math.max(
|
|
22
|
+
let e = h.current, t = e ? e.scrollHeight + (e.offsetHeight - e.clientHeight) : _ * d + f, n = g.x, r = g.y, i = g.y - t;
|
|
23
|
+
n = Math.max(u, n), n = Math.min(n, window.innerWidth - l - u);
|
|
24
|
+
let a = window.innerHeight - u;
|
|
25
|
+
r + t > a && (r = i), r = Math.max(u, r);
|
|
25
26
|
let o = a - r;
|
|
26
|
-
|
|
27
|
+
b({
|
|
27
28
|
top: r,
|
|
28
29
|
left: n,
|
|
29
|
-
width:
|
|
30
|
+
width: l,
|
|
30
31
|
maxHeight: t > o ? Math.max(o, 0) : void 0
|
|
31
32
|
});
|
|
32
|
-
},
|
|
33
|
-
|
|
33
|
+
}, S = (e) => {
|
|
34
|
+
y(), m.setSnapshot({
|
|
34
35
|
state: null,
|
|
35
36
|
layout: null
|
|
36
|
-
}),
|
|
37
|
-
},
|
|
38
|
-
onResize:
|
|
39
|
-
onScroll:
|
|
40
|
-
isInside: (e) =>
|
|
41
|
-
onOutsidePointerDown: (e) =>
|
|
42
|
-
getGridRoot: () =>
|
|
43
|
-
onGridHidden: () =>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
}), g = null, _ = 0, w.detach(), p !== null && e && !o(p.gridRootRef) && c(p.gridRootRef);
|
|
38
|
+
}, C = () => S(!0), w = r({
|
|
39
|
+
onResize: x,
|
|
40
|
+
onScroll: C,
|
|
41
|
+
isInside: (e) => h.current?.contains(e) === !0,
|
|
42
|
+
onOutsidePointerDown: (e) => S(p !== null && s(p.gridRootRef, e)),
|
|
43
|
+
getGridRoot: () => p?.gridRootRef.current ?? null,
|
|
44
|
+
onGridHidden: () => S(!1),
|
|
45
|
+
onOtherGridPopupOpen: () => S(!1),
|
|
46
|
+
onKeyDown: (t) => {
|
|
47
|
+
if (t.key === "Escape") {
|
|
48
|
+
t.preventDefault(), C();
|
|
47
49
|
return;
|
|
48
50
|
}
|
|
49
|
-
let
|
|
50
|
-
if (!(!
|
|
51
|
-
let
|
|
52
|
-
(!(
|
|
51
|
+
let n = h.current;
|
|
52
|
+
if (!(!n || a(n, t)) && t.key === "Tab") {
|
|
53
|
+
let r = e(n);
|
|
54
|
+
(!(r instanceof HTMLElement && n.contains(r)) || r === n || r.getAttribute("role") === "menuitem") && (t.preventDefault(), C());
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
});
|
|
56
58
|
return {
|
|
57
59
|
update: (e) => {
|
|
58
|
-
|
|
60
|
+
p = e;
|
|
59
61
|
},
|
|
60
|
-
subscribe:
|
|
61
|
-
getSnapshot:
|
|
62
|
-
panelRef:
|
|
63
|
-
open: (
|
|
64
|
-
|
|
65
|
-
x:
|
|
66
|
-
y:
|
|
67
|
-
},
|
|
68
|
-
...
|
|
62
|
+
subscribe: m.subscribe,
|
|
63
|
+
getSnapshot: m.getSnapshot,
|
|
64
|
+
panelRef: h,
|
|
65
|
+
open: (t, r, a) => {
|
|
66
|
+
n(p?.gridRootRef.current ?? null), g = {
|
|
67
|
+
x: t.clientX,
|
|
68
|
+
y: t.clientY
|
|
69
|
+
}, _ = r.length, m.setSnapshot({
|
|
70
|
+
...m.getSnapshot(),
|
|
69
71
|
state: {
|
|
70
|
-
params:
|
|
71
|
-
items:
|
|
72
|
+
params: t,
|
|
73
|
+
items: r
|
|
72
74
|
}
|
|
73
|
-
}),
|
|
74
|
-
let
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
let
|
|
78
|
-
if (!(
|
|
79
|
-
if (
|
|
80
|
-
let
|
|
81
|
-
if (
|
|
82
|
-
|
|
75
|
+
}), x(), w.attach(), y();
|
|
76
|
+
let o = a?.focus ?? "panel";
|
|
77
|
+
v = requestAnimationFrame(() => {
|
|
78
|
+
v = null, x();
|
|
79
|
+
let t = h.current;
|
|
80
|
+
if (!(t === null || t.contains(e(t)))) {
|
|
81
|
+
if (o === "firstItem") {
|
|
82
|
+
let e = t.querySelector("[role=\"menuitem\"]:not(:disabled):not([aria-disabled=\"true\"])");
|
|
83
|
+
if (e !== null) {
|
|
84
|
+
e.focus({ preventScroll: !0 });
|
|
83
85
|
return;
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
|
-
|
|
88
|
+
i(t, p?.gridRootRef.current ?? null);
|
|
87
89
|
}
|
|
88
90
|
});
|
|
89
91
|
},
|
|
90
|
-
close:
|
|
92
|
+
close: C,
|
|
91
93
|
dispose: () => {
|
|
92
|
-
|
|
94
|
+
y(), w.detach();
|
|
93
95
|
}
|
|
94
96
|
};
|
|
95
97
|
};
|
|
96
98
|
//#endregion
|
|
97
|
-
export {
|
|
99
|
+
export { p as createContextMenuController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../logic/detailRow.cjs"),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/shadowDom.cjs"),n=require("../logic/detailRow.cjs"),r=require("../logic/domGuards.cjs"),i=require("./detailTabOrder.cjs");var a=e=>r.isTabKeyEvent(e)&&!e.defaultPrevented&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!r.isImeComposingKeyEvent(e),o=()=>{let r=null,o=!1,s=()=>{r?.gridRootRef.current?.focus({preventScroll:!0})},c=t=>{r&&(r.dispatch(e.gridActions.startSelection(t)),r.dispatch(e.gridActions.endSelection()))},l=e=>{if(!r)return;let a=r.scrollContainerRef.current,o=a?i.findDetailCard(a,e):null;if(!o||!o.contains(t.getActiveElement(o)))return;let l={row:e,col:r.getUiState().activeCell?.col??n.resolveFirstDataColIndex(r.orderedColumns)};c(l),s(),r.scrollCellIntoView(l)},u=(t,i)=>{r&&(n.seedDetailIndexCache(r.detailIndexCache.current,t,i),r.getUiState().expandedDetailRowKeys.has(t)&&l(i),r.dispatch(e.gridActions.toggleDetailRow(t)))},d=(t,i,a)=>{r&&(n.seedDetailIndexCache(r.detailIndexCache.current,t,i),a||l(i),r.dispatch(e.gridActions.setDetailRowExpanded(t,a)))},f=e=>{if(!r)return!1;let{rowModel:t}=r,i=t.getRow(e.row);if(i===void 0)return!1;let a=t.getRowKey(e.row)??e.row;return n.isDetailRowExpandable(r.drawable,r.isExpandable,i,a,t.getSourceIndex(e.row)??e.row)?(u(a,e.row),!0):!1},p=e=>{for(let t of e)l(t)},m=()=>{let e=r?.tableExitRef.current;if(e){o=!0;try{e.focus({preventScroll:!0})}finally{o=!1}}};return{update:e=>{r=e},toggleAt:u,setExpandedAt:d,toggleFromKeyboard:f,returnFocusFromCards:p,moveFocusPastTable:m,handleTabPastLastColumn:e=>{let t=r?.scrollContainerRef.current,n=r?.hasCards&&t?i.findDetailCard(t,e):null;return n&&i.focusDetailCardEdge(n,`first`)?!0:(m(),!1)},handleCardKeyDown:(t,n,o)=>{if(!r||!a(t))return;let l=t.target;if(!(l instanceof Element)||!n.contains(l)||!i.isTabEdgeOfCard(n,l,t.shiftKey?`backward`:`forward`))return;if(!t.shiftKey){m();return}let u=r.orderedColumns.length-1;if(u<0)return;t.preventDefault();let d={row:o,col:u};c(d),r.dispatch(e.gridActions.activateCell(d)),s(),r.scrollCellIntoView(d)},handleCardFocusLost:s,handleTableExitFocus:e=>{if(o||!r)return;let t=r.tableExitRef.current,n=!(e instanceof Node)||t===null||(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)!==0,a=r.getUiState().activeCell,c=r.scrollContainerRef.current;if(n&&a&&c){let e=i.findDetailCard(c,a.row);if(e&&i.focusDetailCardEdge(e,`last`))return}s()},handleRootKeyDownAfter:e=>{if(!r?.hasCards||e.shiftKey||!a(e))return;let t=e.target,o=r.scrollContainerRef.current;!(t instanceof Element)||!o||!o.contains(t)||n.isInsideDetailCardOf(o,t)||!i.isTabEdgeOfCard(o,t,`forward`)||m()}}},s=(e,n)=>{!n||!e||!e.contains(t.getActiveElement(e))||queueMicrotask(()=>{let r=t.getActiveElement(e.ownerDocument);!e.isConnected&&(r===null||r===e.ownerDocument.body)&&n()})};exports.createDetailRowController=o,exports.notifyDetailCardFocusLost=s;
|
|
@@ -1,96 +1,97 @@
|
|
|
1
1
|
import { gridActions as e } from "../model/gridActions.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { getActiveElement as t } from "../utils/shadowDom.js";
|
|
3
|
+
import { isDetailRowExpandable as n, isInsideDetailCardOf as r, resolveFirstDataColIndex as i, seedDetailIndexCache as a } from "../logic/detailRow.js";
|
|
4
|
+
import { isImeComposingKeyEvent as o, isTabKeyEvent as s } from "../logic/domGuards.js";
|
|
5
|
+
import { findDetailCard as c, focusDetailCardEdge as l, isTabEdgeOfCard as u } from "./detailTabOrder.js";
|
|
5
6
|
//#region src/controllers/detailRowController.ts
|
|
6
|
-
var
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
if (!
|
|
13
|
-
let
|
|
14
|
-
if (!
|
|
15
|
-
let
|
|
7
|
+
var d = (e) => s(e) && !e.defaultPrevented && !e.altKey && !e.ctrlKey && !e.metaKey && !o(e), f = () => {
|
|
8
|
+
let o = null, s = !1, f = () => {
|
|
9
|
+
o?.gridRootRef.current?.focus({ preventScroll: !0 });
|
|
10
|
+
}, p = (t) => {
|
|
11
|
+
o && (o.dispatch(e.startSelection(t)), o.dispatch(e.endSelection()));
|
|
12
|
+
}, m = (e) => {
|
|
13
|
+
if (!o) return;
|
|
14
|
+
let n = o.scrollContainerRef.current, r = n ? c(n, e) : null;
|
|
15
|
+
if (!r || !r.contains(t(r))) return;
|
|
16
|
+
let a = {
|
|
16
17
|
row: e,
|
|
17
|
-
col:
|
|
18
|
+
col: o.getUiState().activeCell?.col ?? i(o.orderedColumns)
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
}, g = (e) => {
|
|
25
|
-
if (!a) return !1;
|
|
26
|
-
let { rowModel: n } = a, r = n.getRow(e.row);
|
|
27
|
-
if (r === void 0) return !1;
|
|
28
|
-
let i = n.getRowKey(e.row) ?? e.row;
|
|
29
|
-
return t(a.drawable, a.isExpandable, r, i, n.getSourceIndex(e.row) ?? e.row) ? (m(i, e.row), !0) : !1;
|
|
20
|
+
p(a), f(), o.scrollCellIntoView(a);
|
|
21
|
+
}, h = (t, n) => {
|
|
22
|
+
o && (a(o.detailIndexCache.current, t, n), o.getUiState().expandedDetailRowKeys.has(t) && m(n), o.dispatch(e.toggleDetailRow(t)));
|
|
23
|
+
}, g = (t, n, r) => {
|
|
24
|
+
o && (a(o.detailIndexCache.current, t, n), r || m(n), o.dispatch(e.setDetailRowExpanded(t, r)));
|
|
30
25
|
}, _ = (e) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
if (!o) return !1;
|
|
27
|
+
let { rowModel: t } = o, r = t.getRow(e.row);
|
|
28
|
+
if (r === void 0) return !1;
|
|
29
|
+
let i = t.getRowKey(e.row) ?? e.row;
|
|
30
|
+
return n(o.drawable, o.isExpandable, r, i, t.getSourceIndex(e.row) ?? e.row) ? (h(i, e.row), !0) : !1;
|
|
31
|
+
}, v = (e) => {
|
|
32
|
+
for (let t of e) m(t);
|
|
33
|
+
}, y = () => {
|
|
34
|
+
let e = o?.tableExitRef.current;
|
|
34
35
|
if (e) {
|
|
35
|
-
|
|
36
|
+
s = !0;
|
|
36
37
|
try {
|
|
37
38
|
e.focus({ preventScroll: !0 });
|
|
38
39
|
} finally {
|
|
39
|
-
|
|
40
|
+
s = !1;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
};
|
|
43
44
|
return {
|
|
44
45
|
update: (e) => {
|
|
45
|
-
|
|
46
|
+
o = e;
|
|
46
47
|
},
|
|
47
|
-
toggleAt:
|
|
48
|
-
setExpandedAt:
|
|
49
|
-
toggleFromKeyboard:
|
|
50
|
-
returnFocusFromCards:
|
|
51
|
-
moveFocusPastTable:
|
|
48
|
+
toggleAt: h,
|
|
49
|
+
setExpandedAt: g,
|
|
50
|
+
toggleFromKeyboard: _,
|
|
51
|
+
returnFocusFromCards: v,
|
|
52
|
+
moveFocusPastTable: y,
|
|
52
53
|
handleTabPastLastColumn: (e) => {
|
|
53
|
-
let t =
|
|
54
|
-
return n &&
|
|
54
|
+
let t = o?.scrollContainerRef.current, n = o?.hasCards && t ? c(t, e) : null;
|
|
55
|
+
return n && l(n, "first") ? !0 : (y(), !1);
|
|
55
56
|
},
|
|
56
57
|
handleCardKeyDown: (t, n, r) => {
|
|
57
|
-
if (!
|
|
58
|
+
if (!o || !d(t)) return;
|
|
58
59
|
let i = t.target;
|
|
59
|
-
if (!(i instanceof Element) || !n.contains(i) || !
|
|
60
|
+
if (!(i instanceof Element) || !n.contains(i) || !u(n, i, t.shiftKey ? "backward" : "forward")) return;
|
|
60
61
|
if (!t.shiftKey) {
|
|
61
|
-
|
|
62
|
+
y();
|
|
62
63
|
return;
|
|
63
64
|
}
|
|
64
|
-
let
|
|
65
|
-
if (
|
|
65
|
+
let a = o.orderedColumns.length - 1;
|
|
66
|
+
if (a < 0) return;
|
|
66
67
|
t.preventDefault();
|
|
67
68
|
let s = {
|
|
68
69
|
row: r,
|
|
69
|
-
col:
|
|
70
|
+
col: a
|
|
70
71
|
};
|
|
71
|
-
|
|
72
|
+
p(s), o.dispatch(e.activateCell(s)), f(), o.scrollCellIntoView(s);
|
|
72
73
|
},
|
|
73
|
-
handleCardFocusLost:
|
|
74
|
+
handleCardFocusLost: f,
|
|
74
75
|
handleTableExitFocus: (e) => {
|
|
75
|
-
if (
|
|
76
|
-
let t =
|
|
76
|
+
if (s || !o) return;
|
|
77
|
+
let t = o.tableExitRef.current, n = !(e instanceof Node) || t === null || (t.compareDocumentPosition(e) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0, r = o.getUiState().activeCell, i = o.scrollContainerRef.current;
|
|
77
78
|
if (n && r && i) {
|
|
78
|
-
let e =
|
|
79
|
-
if (e &&
|
|
79
|
+
let e = c(i, r.row);
|
|
80
|
+
if (e && l(e, "last")) return;
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
+
f();
|
|
82
83
|
},
|
|
83
84
|
handleRootKeyDownAfter: (e) => {
|
|
84
|
-
if (!
|
|
85
|
-
let t = e.target,
|
|
86
|
-
!(t instanceof Element) || !
|
|
85
|
+
if (!o?.hasCards || e.shiftKey || !d(e)) return;
|
|
86
|
+
let t = e.target, n = o.scrollContainerRef.current;
|
|
87
|
+
!(t instanceof Element) || !n || !n.contains(t) || r(n, t) || !u(n, t, "forward") || y();
|
|
87
88
|
}
|
|
88
89
|
};
|
|
89
|
-
},
|
|
90
|
-
!
|
|
91
|
-
let
|
|
92
|
-
!e.isConnected && (
|
|
90
|
+
}, p = (e, n) => {
|
|
91
|
+
!n || !e || !e.contains(t(e)) || queueMicrotask(() => {
|
|
92
|
+
let r = t(e.ownerDocument);
|
|
93
|
+
!e.isConnected && (r === null || r === e.ownerDocument.body) && n();
|
|
93
94
|
});
|
|
94
95
|
};
|
|
95
96
|
//#endregion
|
|
96
|
-
export {
|
|
97
|
+
export { f as createDetailRowController, p as notifyDetailCardFocusLost };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs");var
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/shadowDom.cjs"),t=require("../logic/detailRow.cjs");var n=[`a[href]`,`area[href]`,`button`,`input`,`select`,`textarea`,`iframe`,`summary`,`[tabindex]`,`[contenteditable]:not([contenteditable="false"])`].join(`,`),r=e=>{let t=[];for(let r of e.querySelectorAll(n))r.tabIndex<0||r.disabled!==!0&&(r instanceof HTMLInputElement&&r.type===`hidden`||r.closest(`[inert]`)===null&&(typeof r.checkVisibility==`function`&&!r.checkVisibility()||t.push(r)));return t},i=(e,n)=>{for(let r of e.querySelectorAll(`[data-detail-row-index="${n}"]`)){if(t.isInsideDetailCardOf(e,r))continue;let n=r.querySelector(`[data-ssg-detail]`);if(n!==null)return n}return null},a=(e,t,n)=>{let i=n===`forward`?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING;return!r(e).some(e=>e!==t&&(t.compareDocumentPosition(e)&i)!==0)},o=(t,n)=>{let i=r(t),a=n===`first`?i[0]:i[i.length-1];return a===void 0?!1:(a.focus(),e.getActiveElement(a)===a)};exports.findDetailCard=i,exports.focusDetailCardEdge=o,exports.isTabEdgeOfCard=a,exports.listTabbableElements=r;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getActiveElement as e } from "../utils/shadowDom.js";
|
|
2
|
+
import { isInsideDetailCardOf as t } from "../logic/detailRow.js";
|
|
2
3
|
//#region src/controllers/detailTabOrder.ts
|
|
3
|
-
var
|
|
4
|
+
var n = [
|
|
4
5
|
"a[href]",
|
|
5
6
|
"area[href]",
|
|
6
7
|
"button",
|
|
@@ -11,23 +12,23 @@ var t = [
|
|
|
11
12
|
"summary",
|
|
12
13
|
"[tabindex]",
|
|
13
14
|
"[contenteditable]:not([contenteditable=\"false\"])"
|
|
14
|
-
].join(","),
|
|
15
|
-
let
|
|
16
|
-
for (let r of e.querySelectorAll(
|
|
17
|
-
return
|
|
18
|
-
},
|
|
19
|
-
for (let r of
|
|
20
|
-
if (e
|
|
15
|
+
].join(","), r = (e) => {
|
|
16
|
+
let t = [];
|
|
17
|
+
for (let r of e.querySelectorAll(n)) r.tabIndex < 0 || r.disabled !== !0 && (r instanceof HTMLInputElement && r.type === "hidden" || r.closest("[inert]") === null && (typeof r.checkVisibility == "function" && !r.checkVisibility() || t.push(r)));
|
|
18
|
+
return t;
|
|
19
|
+
}, i = (e, n) => {
|
|
20
|
+
for (let r of e.querySelectorAll(`[data-detail-row-index="${n}"]`)) {
|
|
21
|
+
if (t(e, r)) continue;
|
|
21
22
|
let n = r.querySelector("[data-ssg-detail]");
|
|
22
23
|
if (n !== null) return n;
|
|
23
24
|
}
|
|
24
25
|
return null;
|
|
25
|
-
},
|
|
26
|
-
let i =
|
|
27
|
-
return !
|
|
28
|
-
},
|
|
29
|
-
let
|
|
30
|
-
return
|
|
26
|
+
}, a = (e, t, n) => {
|
|
27
|
+
let i = n === "forward" ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;
|
|
28
|
+
return !r(e).some((e) => e !== t && (t.compareDocumentPosition(e) & i) !== 0);
|
|
29
|
+
}, o = (t, n) => {
|
|
30
|
+
let i = r(t), a = n === "first" ? i[0] : i[i.length - 1];
|
|
31
|
+
return a === void 0 ? !1 : (a.focus(), e(a) === a);
|
|
31
32
|
};
|
|
32
33
|
//#endregion
|
|
33
|
-
export {
|
|
34
|
+
export { i as findDetailCard, o as focusDetailCardEdge, a as isTabEdgeOfCard, r as listTabbableElements };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/detailRow.cjs"),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../utils/shadowDom.cjs"),r=require("../logic/detailRow.cjs"),i=require("../logic/geometry.cjs"),a=require("../logic/editorValues.cjs"),o=require("../logic/validation.cjs");var s=(e,t)=>t.activeCell!==e.activeCell||t.selection!==e.selection,c=e=>{if(r.isFocusInsideDetailCard(e))return!1;let t=e.ownerDocument,i=n.getActiveElement(e);return i===null||i===t.body||i===t.documentElement||e.contains(i)},l=e=>{let t=e.ownerDocument,r=n.getActiveElement(e);return r===null||r===t.body||r===t.documentElement},u=e=>{if(e===null)return!1;let t=n.getActiveElement(e);return t!==null&&t!==e&&e.contains(t)&&typeof t.closest==`function`&&t.closest(`.ssg-cell-editor`)!==null&&!r.isFocusInsideDetailCard(e)},d=()=>{let n=null,d=null,f=null,p=null,m=!1,h=!1,g=null,_=(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}},v=(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},y=t=>{n=t;let r=t.uiState.editingCell;if(!r){d=null,g=null;return}let i=_(t,r);if(d!==null&&i!==null&&Object.is(i.rowKey,d.rowKey)&&i.columnKey===d.columnKey){d={...d,cell:r};return}let a=d!==null&&d.cell.row===r.row&&d.cell.col===r.col;if(d===null||!a){d=i?{...i,cell:r}:null,f!==null&&(f.superseded=!0,f=null,t.editorActionGuardRef.current=!1);return}let o=v(t,d);if(o)d={...d,cell:o},t.dispatch(e.gridActions.retargetEdit(o,t.rowModel.getRowCount()));else{let e=d;d=null,b(t,e)}},b=(t,n)=>{if(t.editorActionGuardRef.current){t.dispatch(e.gridActions.stopEdit());return}let r=t.visibleColumns.find(e=>e.key===n.columnKey),i=r===void 0||t.applyServerSideCellEdits!==void 0||t.onRowsChange===void 0?-1:x(t,n.rowKey);p=r!==void 0&&i>=0?{sourceIndex:i,column:r,cell:n.cell,rowKey:n.rowKey}:null,m=!1;let a=g;g=null,h=!0;let o;try{a!==null&&(a(),p=null),o=D()}finally{h=!1,p=null}let s=t.gridRootRef.current;if(!o&&s!==null&&s.isConnected&&l(s)&&(s.focus({preventScroll:!0}),o=!0),m&&t.editorActionGuardRef.current){m=!1;return}m=!1,t.editorActionGuardRef.current=!0,t.dispatch(e.gridActions.stopEdit()),E(null,null,void 0,o)},x=(e,t)=>{let{rows:n,rowKeyGetter:r}=e;for(let e=0;e<n.length;e+=1){let i=n[e];if(i!==void 0&&Object.is(r?r(i,e):e,t))return e}return-1},S=(e,n,r)=>{let{rows:i,onRowsChange:s}=e,c=i[n.sourceIndex];if(c===void 0||s===void 0||!t.isCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},n.cell.row,n.cell.col,c,n.column,{sourceRowIndex:n.sourceIndex,rowKey:n.rowKey}))return{status:`noop`};if(a.isUnchangedEditorCommit(n.column,t.getCellValue(c,n.column),r))return{status:`committed`};let l=a.parseCommittedValue(n.column,r,c);return o.decideCellWrite(n.column,c,l,e.localeTexts).action===`reject`?{status:`noop`}:(s(a.writeRowsCell(i,n.sourceIndex,n.column,l)),{status:`committed`})},C=t=>{n!==null&&(n.dispatch(e.gridActions.startSelection(t)),n.dispatch(e.gridActions.endSelection()),n.dispatch(e.gridActions.activateCell(t)))},w=(t,r)=>{n!==null&&(n.setEditorInitialValue(r),n.dispatch(e.gridActions.startEdit(t)))},T=(e,t,n)=>{let r=e.getRowCount(),a=i.clamp(t,0,Math.max(r-1,0)),{getLabelRow:o}=e;if(o&&n!==void 0&&a!==n){let e=a>n?1:-1;for(;a>=0&&a<r&&o(a);)a+=e;(a<0||a>=r)&&(a=i.clamp(n,0,Math.max(r-1,0)))}return a},E=(e,t=null,a,o=!1,l)=>{let u=n;if(u===null)return;let d=!1,p={superseded:!1};f=p;let m=u.uiState.editingCell,h=o=>{if(d)return;if(p.superseded){d=!0;return}let h=n===null?null:n.getUiState?.()??null;if(h!==null&&h.editingCell!==null&&h.editingCell!==m){d=!0,f===p&&(f=null),u.editorActionGuardRef.current=!1;return}if(!o&&(n===null||n.uiState.editingCell!==null))return;d=!0,f===p&&(f=null);let g=u.gridRootRef.current;if(g!==null&&c(g)&&g.focus(),e!==null&&n!==null&&!(t!==null&&s(t,n.uiState))){let t=n.visibleColumns.length,o=l===void 0?-1:r.findViewRowIndexByKey(n.rowModel,l,new Map),s=o>=0?o:T(n.rowModel,e.row,a);C({row:s,col:i.clamp(e.col,0,Math.max(t-1,0))})}u.editorActionGuardRef.current=!1};o&&queueMicrotask(()=>h(!1)),requestAnimationFrame(()=>h(!0))},D=()=>{let e=n?.gridRootRef.current??null;return u(e)?(e.focus({preventScroll:!0}),!0):!1};return{update:y,activateSingleCell:C,startEditWithValue:w,commitEdit:(i,s)=>{if(n===null)return{status:`noop`};let{uiState:c,visibleColumns:l,rowModel:u,rows:d,applyServerSideCellEdits:f,onRowsChange:m,dispatch:g,editorActionGuardRef:_}=n;if(_.current||!c.editingCell)return{status:`noop`};if(h){let e=p;return p=null,e===null?{status:`noop`}:S(n,e,i)}let v=c.editingCell,y=s===`down`?{row:v.row+1,col:v.col}:s===`up`?{row:v.row-1,col:v.col}:s===`right`?{row:v.row,col:v.col+1}:s===`left`?{row:v.row,col:Math.max(v.col-1,r.resolveFirstDataColIndex(l))}:v,b=l[v.col],x=u.getSourceIndex(v.row),C=f?u.getRow(v.row):d[x];if(!b||!C)return g(e.gridActions.stopEdit()),{status:`noop`};if(!t.isViewCellEditable({readOnly:n.readOnly,canEditCell:n.canEditCell},u,v.row,v.col,C,b))return _.current=!0,g(e.gridActions.stopEdit()),E(null),{status:`noop`};let w=a.isUnchangedEditorCommit(b,t.getCellValue(C,b),i);if(!w&&f){let e=a.parseCommittedValue(b,i,C),t=o.decideCellWrite(b,C,e,n.localeTexts);if(t.action===`reject`)return{status:`rejected`,message:t.message};f([{viewIndex:v.row,column:b,value:e}])}else if(!w&&m){let e=a.parseCommittedValue(b,i,C),t=o.decideCellWrite(b,C,e,n.localeTexts);if(t.action===`reject`)return{status:`rejected`,message:t.message};m(a.writeRowsCell(d,x,b,e))}_.current=!0;let O=D(),k;if(n.followsRow===!0){let e=T(u,y.row,v.row);(u.getRow(e)!=null||u.getLabelRow?.(e)!==void 0)&&(k=u.getRowKey(e))}return E(y,s===void 0?{activeCell:c.activeCell,selection:c.selection}:null,v.row,O,k),g(e.gridActions.stopEdit()),{status:`committed`}},cancelEdit:()=>{if(n===null||n.editorActionGuardRef.current)return;m=!0,p=null,n.editorActionGuardRef.current=!0;let t=D();n.dispatch(e.gridActions.stopEdit()),E(null,null,void 0,t)},registerDraftFlush:e=>{g=e}}};exports.createEditController=d;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type GridUiAction } from '../model/gridActions.js';
|
|
2
|
-
import type { CellCoord, EditorCommitDirection, EditorCommitResult, GridColumn, GridUiState, RowModel, SpreadsheetGridProps } from '../model/gridTypes.unbound.js';
|
|
2
|
+
import type { CellCoord, EditorCommitDirection, EditorCommitResult, GridColumn, GridRowKey, GridUiState, RowModel, SpreadsheetGridProps } from '../model/gridTypes.unbound.js';
|
|
3
3
|
import { type ValidationLocaleText } from '../logic/validation.js';
|
|
4
4
|
import type { ServerSideCellEditInput } from '../logic/serverSideEdits.js';
|
|
5
5
|
export type EditControllerArgs<T extends object> = {
|
|
@@ -21,6 +21,8 @@ export type EditControllerArgs<T extends object> = {
|
|
|
21
21
|
canEditCell?: SpreadsheetGridProps<T>['canEditCell'];
|
|
22
22
|
localeTexts?: ValidationLocaleText;
|
|
23
23
|
followsRow?: boolean | undefined;
|
|
24
|
+
getUiState?: (() => GridUiState) | undefined;
|
|
25
|
+
rowKeyGetter?: ((row: T, index: number) => GridRowKey) | undefined;
|
|
24
26
|
};
|
|
25
27
|
export type EditController<T extends object> = {
|
|
26
28
|
update: (args: EditControllerArgs<T>) => void;
|
|
@@ -28,5 +30,6 @@ export type EditController<T extends object> = {
|
|
|
28
30
|
startEditWithValue: (cell: CellCoord, initialValue: string) => void;
|
|
29
31
|
commitEdit: (committedValue: unknown, direction?: EditorCommitDirection) => EditorCommitResult;
|
|
30
32
|
cancelEdit: () => void;
|
|
33
|
+
registerDraftFlush: (flush: (() => void) | null) => void;
|
|
31
34
|
};
|
|
32
35
|
export declare const createEditController: <T extends object>() => EditController<T>;
|