@ishibashi0112/spreadsheet-grid-core 0.39.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/LICENSE +21 -0
- package/dist/controllers/autoHeightMeasurer.cjs +1 -0
- package/dist/controllers/autoHeightMeasurer.d.ts +30 -0
- package/dist/controllers/autoHeightMeasurer.js +74 -0
- package/dist/controllers/clipboardController.cjs +2 -0
- package/dist/controllers/clipboardController.d.ts +31 -0
- package/dist/controllers/clipboardController.js +88 -0
- package/dist/controllers/columnAutosizeRunner.cjs +1 -0
- package/dist/controllers/columnAutosizeRunner.d.ts +31 -0
- package/dist/controllers/columnAutosizeRunner.js +61 -0
- package/dist/controllers/columnHeaderDragController.cjs +1 -0
- package/dist/controllers/columnHeaderDragController.d.ts +44 -0
- package/dist/controllers/columnHeaderDragController.js +256 -0
- package/dist/controllers/columnMenuController.cjs +1 -0
- package/dist/controllers/columnMenuController.d.ts +49 -0
- package/dist/controllers/columnMenuController.js +110 -0
- package/dist/controllers/contextMenuController.cjs +1 -0
- package/dist/controllers/contextMenuController.d.ts +30 -0
- package/dist/controllers/contextMenuController.js +65 -0
- package/dist/controllers/debouncedValueStore.cjs +1 -0
- package/dist/controllers/debouncedValueStore.d.ts +11 -0
- package/dist/controllers/debouncedValueStore.js +22 -0
- package/dist/controllers/editController.cjs +1 -0
- package/dist/controllers/editController.d.ts +27 -0
- package/dist/controllers/editController.js +76 -0
- package/dist/controllers/filterPopoverController.cjs +1 -0
- package/dist/controllers/filterPopoverController.d.ts +53 -0
- package/dist/controllers/filterPopoverController.js +146 -0
- package/dist/controllers/globalFilteredOrder.cjs +1 -0
- package/dist/controllers/globalFilteredOrder.d.ts +38 -0
- package/dist/controllers/globalFilteredOrder.js +78 -0
- package/dist/controllers/historyController.cjs +1 -0
- package/dist/controllers/historyController.d.ts +28 -0
- package/dist/controllers/historyController.js +52 -0
- package/dist/controllers/keyboardController.cjs +1 -0
- package/dist/controllers/keyboardController.d.ts +36 -0
- package/dist/controllers/keyboardController.js +111 -0
- package/dist/controllers/panelHeaderDragController.cjs +1 -0
- package/dist/controllers/panelHeaderDragController.d.ts +21 -0
- package/dist/controllers/panelHeaderDragController.js +32 -0
- package/dist/controllers/pointerInteractionsController.cjs +1 -0
- package/dist/controllers/pointerInteractionsController.d.ts +74 -0
- package/dist/controllers/pointerInteractionsController.js +262 -0
- package/dist/controllers/popoverSupport.cjs +1 -0
- package/dist/controllers/popoverSupport.d.ts +18 -0
- package/dist/controllers/popoverSupport.js +25 -0
- package/dist/controllers/rowDragController.cjs +1 -0
- package/dist/controllers/rowDragController.d.ts +40 -0
- package/dist/controllers/rowDragController.js +192 -0
- package/dist/controllers/scrollSyncController.cjs +1 -0
- package/dist/controllers/scrollSyncController.d.ts +17 -0
- package/dist/controllers/scrollSyncController.js +51 -0
- package/dist/controllers/selectOptionsCollector.cjs +1 -0
- package/dist/controllers/selectOptionsCollector.d.ts +31 -0
- package/dist/controllers/selectOptionsCollector.js +88 -0
- package/dist/controllers/serverSideRowModel.cjs +1 -0
- package/dist/controllers/serverSideRowModel.d.ts +36 -0
- package/dist/controllers/serverSideRowModel.js +153 -0
- package/dist/controllers/systemColorSchemeStore.cjs +1 -0
- package/dist/controllers/systemColorSchemeStore.d.ts +5 -0
- package/dist/controllers/systemColorSchemeStore.js +18 -0
- package/dist/controllers/toolPanelController.cjs +1 -0
- package/dist/controllers/toolPanelController.d.ts +36 -0
- package/dist/controllers/toolPanelController.js +112 -0
- package/dist/controllers/tooltipController.cjs +1 -0
- package/dist/controllers/tooltipController.d.ts +6 -0
- package/dist/controllers/tooltipController.js +75 -0
- package/dist/controllers/viewportSyncController.cjs +1 -0
- package/dist/controllers/viewportSyncController.d.ts +30 -0
- package/dist/controllers/viewportSyncController.js +40 -0
- package/dist/engine/columnCommands.cjs +1 -0
- package/dist/engine/columnCommands.d.ts +56 -0
- package/dist/engine/columnCommands.js +199 -0
- package/dist/engine/columnLayout.cjs +1 -0
- package/dist/engine/columnLayout.d.ts +43 -0
- package/dist/engine/columnLayout.js +91 -0
- package/dist/engine/createGridEngine.cjs +1 -0
- package/dist/engine/createGridEngine.d.ts +46 -0
- package/dist/engine/createGridEngine.js +52 -0
- package/dist/engine/filterPopoverCommands.cjs +1 -0
- package/dist/engine/filterPopoverCommands.d.ts +56 -0
- package/dist/engine/filterPopoverCommands.js +303 -0
- package/dist/engine/gridApi.cjs +1 -0
- package/dist/engine/gridApi.d.ts +61 -0
- package/dist/engine/gridApi.js +389 -0
- package/dist/engine/memo.cjs +1 -0
- package/dist/engine/memo.d.ts +2 -0
- package/dist/engine/memo.js +18 -0
- package/dist/engine/notifiers.cjs +1 -0
- package/dist/engine/notifiers.d.ts +35 -0
- package/dist/engine/notifiers.js +34 -0
- package/dist/engine/rowPipeline.cjs +1 -0
- package/dist/engine/rowPipeline.d.ts +50 -0
- package/dist/engine/rowPipeline.js +84 -0
- package/dist/engine/rowSelectionCommands.cjs +1 -0
- package/dist/engine/rowSelectionCommands.d.ts +21 -0
- package/dist/engine/rowSelectionCommands.js +57 -0
- package/dist/engine/verticalLayout.cjs +1 -0
- package/dist/engine/verticalLayout.d.ts +52 -0
- package/dist/engine/verticalLayout.js +60 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +5 -0
- package/dist/logic/aggregation.cjs +1 -0
- package/dist/logic/aggregation.d.ts +13 -0
- package/dist/logic/aggregation.js +28 -0
- package/dist/logic/autoScrollGeometry.cjs +1 -0
- package/dist/logic/autoScrollGeometry.d.ts +27 -0
- package/dist/logic/autoScrollGeometry.js +19 -0
- package/dist/logic/autoSizeOnData.cjs +1 -0
- package/dist/logic/autoSizeOnData.d.ts +10 -0
- package/dist/logic/autoSizeOnData.js +19 -0
- package/dist/logic/cellOverflowTooltip.cjs +1 -0
- package/dist/logic/cellOverflowTooltip.d.ts +5 -0
- package/dist/logic/cellOverflowTooltip.js +4 -0
- package/dist/logic/checkboxEditor.cjs +1 -0
- package/dist/logic/checkboxEditor.d.ts +12 -0
- package/dist/logic/checkboxEditor.js +17 -0
- package/dist/logic/chunkedLoop.cjs +1 -0
- package/dist/logic/chunkedLoop.d.ts +8 -0
- package/dist/logic/chunkedLoop.js +18 -0
- package/dist/logic/clearCells.cjs +1 -0
- package/dist/logic/clearCells.d.ts +31 -0
- package/dist/logic/clearCells.js +91 -0
- package/dist/logic/columnAutosize.cjs +1 -0
- package/dist/logic/columnAutosize.d.ts +18 -0
- package/dist/logic/columnAutosize.js +150 -0
- package/dist/logic/columnFlex.cjs +1 -0
- package/dist/logic/columnFlex.d.ts +4 -0
- package/dist/logic/columnFlex.js +60 -0
- package/dist/logic/columnReset.cjs +1 -0
- package/dist/logic/columnReset.d.ts +7 -0
- package/dist/logic/columnReset.js +25 -0
- package/dist/logic/contextMenuTarget.cjs +1 -0
- package/dist/logic/contextMenuTarget.d.ts +4 -0
- package/dist/logic/contextMenuTarget.js +18 -0
- package/dist/logic/cx.cjs +1 -0
- package/dist/logic/cx.d.ts +1 -0
- package/dist/logic/cx.js +6 -0
- package/dist/logic/dateFilterCondition.cjs +1 -0
- package/dist/logic/dateFilterCondition.d.ts +26 -0
- package/dist/logic/dateFilterCondition.js +110 -0
- package/dist/logic/dateFilterPresets.cjs +1 -0
- package/dist/logic/dateFilterPresets.d.ts +13 -0
- package/dist/logic/dateFilterPresets.js +30 -0
- package/dist/logic/dateFilterTree.cjs +1 -0
- package/dist/logic/dateFilterTree.d.ts +17 -0
- package/dist/logic/dateFilterTree.js +75 -0
- package/dist/logic/datePickerCalendar.cjs +1 -0
- package/dist/logic/datePickerCalendar.d.ts +12 -0
- package/dist/logic/datePickerCalendar.js +41 -0
- package/dist/logic/detailRow.cjs +1 -0
- package/dist/logic/detailRow.d.ts +38 -0
- package/dist/logic/detailRow.js +78 -0
- package/dist/logic/domGuards.cjs +1 -0
- package/dist/logic/domGuards.d.ts +7 -0
- package/dist/logic/domGuards.js +4 -0
- package/dist/logic/editorValues.cjs +1 -0
- package/dist/logic/editorValues.d.ts +5 -0
- package/dist/logic/editorValues.js +32 -0
- package/dist/logic/exportCsv.cjs +3 -0
- package/dist/logic/exportCsv.d.ts +12 -0
- package/dist/logic/exportCsv.js +19 -0
- package/dist/logic/exportData.cjs +1 -0
- package/dist/logic/exportData.d.ts +9 -0
- package/dist/logic/exportData.js +24 -0
- package/dist/logic/exportScope.cjs +1 -0
- package/dist/logic/exportScope.d.ts +3 -0
- package/dist/logic/exportScope.js +4 -0
- package/dist/logic/filterPopoverLayout.cjs +1 -0
- package/dist/logic/filterPopoverLayout.d.ts +17 -0
- package/dist/logic/filterPopoverLayout.js +13 -0
- package/dist/logic/filterPopoverOutsideClick.cjs +1 -0
- package/dist/logic/filterPopoverOutsideClick.d.ts +2 -0
- package/dist/logic/filterPopoverOutsideClick.js +4 -0
- package/dist/logic/filterSummary.cjs +1 -0
- package/dist/logic/filterSummary.d.ts +3 -0
- package/dist/logic/filterSummary.js +22 -0
- package/dist/logic/filtering.cjs +1 -0
- package/dist/logic/filtering.d.ts +33 -0
- package/dist/logic/filtering.js +313 -0
- package/dist/logic/geometry.cjs +1 -0
- package/dist/logic/geometry.d.ts +72 -0
- package/dist/logic/geometry.js +161 -0
- package/dist/logic/gridState.cjs +1 -0
- package/dist/logic/gridState.d.ts +13 -0
- package/dist/logic/gridState.js +165 -0
- package/dist/logic/grouping.cjs +1 -0
- package/dist/logic/grouping.d.ts +34 -0
- package/dist/logic/grouping.js +93 -0
- package/dist/logic/history.cjs +1 -0
- package/dist/logic/history.d.ts +16 -0
- package/dist/logic/history.js +34 -0
- package/dist/logic/inferFilterType.cjs +1 -0
- package/dist/logic/inferFilterType.d.ts +19 -0
- package/dist/logic/inferFilterType.js +54 -0
- package/dist/logic/numberFilterCondition.cjs +1 -0
- package/dist/logic/numberFilterCondition.d.ts +21 -0
- package/dist/logic/numberFilterCondition.js +130 -0
- package/dist/logic/panelDragGeometry.cjs +1 -0
- package/dist/logic/panelDragGeometry.d.ts +13 -0
- package/dist/logic/panelDragGeometry.js +10 -0
- package/dist/logic/rowHeightStore.cjs +1 -0
- package/dist/logic/rowHeightStore.d.ts +13 -0
- package/dist/logic/rowHeightStore.js +41 -0
- package/dist/logic/rowReorder.cjs +1 -0
- package/dist/logic/rowReorder.d.ts +18 -0
- package/dist/logic/rowReorder.js +22 -0
- package/dist/logic/rowSelection.cjs +1 -0
- package/dist/logic/rowSelection.d.ts +16 -0
- package/dist/logic/rowSelection.js +49 -0
- package/dist/logic/scrollHint.cjs +1 -0
- package/dist/logic/scrollHint.d.ts +41 -0
- package/dist/logic/scrollHint.js +66 -0
- package/dist/logic/scrollTargets.cjs +1 -0
- package/dist/logic/scrollTargets.d.ts +22 -0
- package/dist/logic/scrollTargets.js +24 -0
- package/dist/logic/selectEditorState.cjs +1 -0
- package/dist/logic/selectEditorState.d.ts +28 -0
- package/dist/logic/selectEditorState.js +31 -0
- package/dist/logic/selectOptions.cjs +1 -0
- package/dist/logic/selectOptions.d.ts +9 -0
- package/dist/logic/selectOptions.js +23 -0
- package/dist/logic/serverSideBlocks.cjs +1 -0
- package/dist/logic/serverSideBlocks.d.ts +2 -0
- package/dist/logic/serverSideBlocks.js +14 -0
- package/dist/logic/serverSideCache.cjs +1 -0
- package/dist/logic/serverSideCache.d.ts +14 -0
- package/dist/logic/serverSideCache.js +42 -0
- package/dist/logic/serverSideEdits.cjs +1 -0
- package/dist/logic/serverSideEdits.d.ts +16 -0
- package/dist/logic/serverSideEdits.js +47 -0
- package/dist/logic/serverSideQuery.cjs +1 -0
- package/dist/logic/serverSideQuery.d.ts +7 -0
- package/dist/logic/serverSideQuery.js +21 -0
- package/dist/logic/setFilterSearch.cjs +1 -0
- package/dist/logic/setFilterSearch.d.ts +14 -0
- package/dist/logic/setFilterSearch.js +14 -0
- package/dist/logic/setFilterSelection.cjs +1 -0
- package/dist/logic/setFilterSelection.d.ts +5 -0
- package/dist/logic/setFilterSelection.js +4 -0
- package/dist/logic/slotDom.cjs +1 -0
- package/dist/logic/slotDom.d.ts +8 -0
- package/dist/logic/slotDom.js +22 -0
- package/dist/logic/slotProps.cjs +1 -0
- package/dist/logic/slotProps.d.ts +18 -0
- package/dist/logic/slotProps.js +63 -0
- package/dist/logic/sorting.cjs +1 -0
- package/dist/logic/sorting.d.ts +11 -0
- package/dist/logic/sorting.js +96 -0
- package/dist/logic/textFilterCondition.cjs +1 -0
- package/dist/logic/textFilterCondition.d.ts +18 -0
- package/dist/logic/textFilterCondition.js +55 -0
- package/dist/logic/theme.cjs +1 -0
- package/dist/logic/theme.d.ts +3 -0
- package/dist/logic/theme.js +4 -0
- package/dist/logic/tooltipGeometry.cjs +1 -0
- package/dist/logic/tooltipGeometry.d.ts +19 -0
- package/dist/logic/tooltipGeometry.js +16 -0
- package/dist/logic/validation.cjs +1 -0
- package/dist/logic/validation.d.ts +14 -0
- package/dist/logic/validation.js +47 -0
- package/dist/logic/valueFormatters.cjs +1 -0
- package/dist/logic/valueFormatters.d.ts +9 -0
- package/dist/logic/valueFormatters.js +17 -0
- package/dist/logic/valueStore.cjs +1 -0
- package/dist/logic/valueStore.d.ts +6 -0
- package/dist/logic/valueStore.js +18 -0
- package/dist/logic/verticalGeometry.cjs +1 -0
- package/dist/logic/verticalGeometry.d.ts +58 -0
- package/dist/logic/verticalGeometry.js +90 -0
- package/dist/model/gridActions.cjs +1 -0
- package/dist/model/gridActions.d.ts +125 -0
- package/dist/model/gridActions.js +114 -0
- package/dist/model/gridReducer.cjs +1 -0
- package/dist/model/gridReducer.d.ts +4 -0
- package/dist/model/gridReducer.js +247 -0
- package/dist/model/gridSelectors.cjs +1 -0
- package/dist/model/gridSelectors.d.ts +40 -0
- package/dist/model/gridSelectors.js +68 -0
- package/dist/model/gridStore.cjs +1 -0
- package/dist/model/gridStore.d.ts +24 -0
- package/dist/model/gridStore.js +38 -0
- package/dist/model/gridTypes.core.cjs +1 -0
- package/dist/model/gridTypes.core.d.ts +797 -0
- package/dist/model/gridTypes.core.js +0 -0
- package/dist/model/gridTypes.unbound.cjs +1 -0
- package/dist/model/gridTypes.unbound.d.ts +31 -0
- package/dist/model/gridTypes.unbound.js +0 -0
- package/dist/testing/index.cjs +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.js +51 -0
- package/dist/utils/clipboard.cjs +7 -0
- package/dist/utils/clipboard.d.ts +29 -0
- package/dist/utils/clipboard.js +110 -0
- package/dist/utils/excelColumnName.cjs +1 -0
- package/dist/utils/excelColumnName.d.ts +1 -0
- package/dist/utils/excelColumnName.js +9 -0
- package/dist/utils/permissions.cjs +1 -0
- package/dist/utils/permissions.d.ts +4 -0
- package/dist/utils/permissions.js +7 -0
- package/dist/utils/scheduler.cjs +1 -0
- package/dist/utils/scheduler.d.ts +1 -0
- package/dist/utils/scheduler.js +13 -0
- package/package.json +58 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { isInsideDetailCardOf as e } from "../logic/detailRow.js";
|
|
2
|
+
import { findPaneDropSlot as t, getColumnPane as n, paneDropSlotBoundaryX as r } from "../logic/geometry.js";
|
|
3
|
+
import { computeNextScrollPosition as i, hasPointerLeftActivationRadius as a, resolveAutoScrollAxisDirection as o, resolveScrollContentBox as s } from "../logic/autoScrollGeometry.js";
|
|
4
|
+
import { applySlotToElement as c } from "../logic/slotDom.js";
|
|
5
|
+
//#region src/controllers/columnHeaderDragController.ts
|
|
6
|
+
function l(e, t, r, i) {
|
|
7
|
+
let a = e.find((e) => e.key === t);
|
|
8
|
+
if (!a) return null;
|
|
9
|
+
let o = n(a), s = {
|
|
10
|
+
left: [],
|
|
11
|
+
center: [],
|
|
12
|
+
right: []
|
|
13
|
+
}, c = /* @__PURE__ */ new Map();
|
|
14
|
+
for (let t of e) s[n(t)].push(t.key), c.set(t.key, t.visible !== !1);
|
|
15
|
+
let l = s[r].filter((e) => c.get(e)).indexOf(t), u = s[o].indexOf(t);
|
|
16
|
+
if (u < 0) return null;
|
|
17
|
+
s[o].splice(u, 1);
|
|
18
|
+
let d = i;
|
|
19
|
+
o === r && l >= 0 && d > l && --d;
|
|
20
|
+
let f = s[r].filter((e) => c.get(e));
|
|
21
|
+
if (d = Math.max(0, Math.min(d, f.length)), o === r && l >= 0 && d === l) return null;
|
|
22
|
+
let p;
|
|
23
|
+
return p = d >= f.length ? s[r].length : s[r].indexOf(f[d]), s[r].splice(p, 0, t), [
|
|
24
|
+
...s.left,
|
|
25
|
+
...s.center,
|
|
26
|
+
...s.right
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
var u = 32, d = 2, f = 14, p = 12, m = "<svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"5 9 2 12 5 15\"/><polyline points=\"9 5 12 2 15 5\"/><polyline points=\"15 19 12 22 9 19\"/><polyline points=\"19 9 22 12 19 15\"/><line x1=\"2\" y1=\"12\" x2=\"22\" y2=\"12\"/><line x1=\"12\" y1=\"2\" x2=\"12\" y2=\"22\"/></svg>", h = "<svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"12\" y1=\"17\" x2=\"12\" y2=\"22\"/><path d=\"M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z\"/></svg>", g = "<svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"4.9\" y1=\"4.9\" x2=\"19.1\" y2=\"19.1\"/></svg>", _ = "0.5", v = 200, y = "cubic-bezier(0.2, 0.7, 0.3, 1)", b = () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, x = (t) => {
|
|
30
|
+
if (!t) return null;
|
|
31
|
+
let n = /* @__PURE__ */ new Map();
|
|
32
|
+
return t.querySelectorAll("[data-ssg-col-key]").forEach((r) => {
|
|
33
|
+
if (e(t, r)) return;
|
|
34
|
+
let i = r.dataset.ssgColKey;
|
|
35
|
+
i && !n.has(i) && n.set(i, r.getBoundingClientRect().left);
|
|
36
|
+
}), n;
|
|
37
|
+
}, S = () => {
|
|
38
|
+
let S = null, C = null, w = null, T = null, E = {
|
|
39
|
+
x: 0,
|
|
40
|
+
y: 0
|
|
41
|
+
}, D = null, O = !1, k = null, A = null, j = null, M = null, N = null, P = () => ({
|
|
42
|
+
left: S?.leftIndicatorRef.current ?? null,
|
|
43
|
+
center: S?.centerIndicatorRef.current ?? null,
|
|
44
|
+
right: S?.rightIndicatorRef.current ?? null
|
|
45
|
+
}), F = () => {
|
|
46
|
+
for (let e of Object.values(P())) e && (e.style.display = "none");
|
|
47
|
+
}, I = (e) => {
|
|
48
|
+
if (j) return;
|
|
49
|
+
let t = document.createElement("div");
|
|
50
|
+
t.setAttribute("data-grid-drag-ghost", ""), S?.scrollContainerRef.current?.closest(".ssg-theme-dark") != null && t.classList.add("ssg-theme-dark"), t.style.cssText = [
|
|
51
|
+
"position:fixed",
|
|
52
|
+
"top:0",
|
|
53
|
+
"left:0",
|
|
54
|
+
"display:inline-flex",
|
|
55
|
+
"align-items:center",
|
|
56
|
+
"gap:7px",
|
|
57
|
+
"padding:7px 12px 7px 10px",
|
|
58
|
+
"border-radius:9px",
|
|
59
|
+
"border:1px solid var(--ssg-ghost-border)",
|
|
60
|
+
"background:var(--ssg-ghost-bg)",
|
|
61
|
+
"color:var(--ssg-ghost-text)",
|
|
62
|
+
"font-size:12px",
|
|
63
|
+
"font-weight:600",
|
|
64
|
+
"line-height:1",
|
|
65
|
+
"white-space:nowrap",
|
|
66
|
+
"box-shadow:var(--ssg-ghost-shadow)",
|
|
67
|
+
"pointer-events:none",
|
|
68
|
+
"user-select:none",
|
|
69
|
+
"z-index:9999",
|
|
70
|
+
"will-change:transform",
|
|
71
|
+
"transform:translate(-9999px,-9999px)"
|
|
72
|
+
].join(";"), c(t, S?.ghostSlot);
|
|
73
|
+
let n = document.createElement("span");
|
|
74
|
+
n.style.cssText = "display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none";
|
|
75
|
+
let r = document.createElement("span");
|
|
76
|
+
r.textContent = e, t.appendChild(n), t.appendChild(r), document.body.appendChild(t), j = t, M = n, N = null;
|
|
77
|
+
}, L = (e) => {
|
|
78
|
+
let t = j;
|
|
79
|
+
if (!t) return;
|
|
80
|
+
t.style.transform = "translate(" + (E.x + f) + "px," + (E.y + p) + "px)";
|
|
81
|
+
let n = e ?? "out";
|
|
82
|
+
if (N === n) return;
|
|
83
|
+
N = n;
|
|
84
|
+
let r = M;
|
|
85
|
+
n === "out" ? (t.style.opacity = _, r && (r.innerHTML = g)) : (t.style.opacity = "1", r && (r.innerHTML = n === "center" ? m : h));
|
|
86
|
+
}, R = () => {
|
|
87
|
+
j && j.parentNode && j.parentNode.removeChild(j), j = null, M = null, N = null;
|
|
88
|
+
}, z = (e, n) => {
|
|
89
|
+
if (S === null) return null;
|
|
90
|
+
let { paneLayout: i, leftPaneScrollRef: a, rightPaneScrollRef: o, bodyScrollRef: s, scrollContainerRef: c, leftLeadingWidth: l, centerLeadingWidth: f, rightLeadingWidth: p } = S, m = c.current;
|
|
91
|
+
if (m) {
|
|
92
|
+
let t = m.getBoundingClientRect();
|
|
93
|
+
if (e < t.left || e > t.right || n < t.top || n > t.bottom) return null;
|
|
94
|
+
}
|
|
95
|
+
let h = a.current, g = o.current;
|
|
96
|
+
if (h && i.left.entries.length === 0 && e <= h.getBoundingClientRect().left + u) return {
|
|
97
|
+
pane: "left",
|
|
98
|
+
slot: 0,
|
|
99
|
+
leftPx: d
|
|
100
|
+
};
|
|
101
|
+
if (h && i.left.entries.length > 0) {
|
|
102
|
+
let n = h.getBoundingClientRect();
|
|
103
|
+
if (e < n.right) {
|
|
104
|
+
let a = e - n.left - l, o = t(i.left, a);
|
|
105
|
+
return {
|
|
106
|
+
pane: "left",
|
|
107
|
+
slot: o,
|
|
108
|
+
leftPx: l + r(i.left, o)
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (g && i.right.entries.length === 0 && e >= g.getBoundingClientRect().left - u) return {
|
|
113
|
+
pane: "right",
|
|
114
|
+
slot: 0,
|
|
115
|
+
leftPx: -2
|
|
116
|
+
};
|
|
117
|
+
if (g && i.right.entries.length > 0) {
|
|
118
|
+
let n = g.getBoundingClientRect();
|
|
119
|
+
if (e >= n.left) {
|
|
120
|
+
let a = e - n.left - p, o = t(i.right, a);
|
|
121
|
+
return {
|
|
122
|
+
pane: "right",
|
|
123
|
+
slot: o,
|
|
124
|
+
leftPx: p + r(i.right, o)
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
let _ = s.current;
|
|
129
|
+
if (_ && i.center.entries.length > 0) {
|
|
130
|
+
let n = _.getBoundingClientRect(), a = _.scrollLeft + e - n.left - f, o = t(i.center, Math.max(a, 0));
|
|
131
|
+
return {
|
|
132
|
+
pane: "center",
|
|
133
|
+
slot: o,
|
|
134
|
+
leftPx: f + r(i.center, o)
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}, B = () => {
|
|
139
|
+
let e = z(E.x, E.y);
|
|
140
|
+
if (L(e ? e.pane : null), !e) {
|
|
141
|
+
w = null, F();
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
w = {
|
|
145
|
+
pane: e.pane,
|
|
146
|
+
slot: e.slot
|
|
147
|
+
};
|
|
148
|
+
let t = P();
|
|
149
|
+
for (let n of [
|
|
150
|
+
"left",
|
|
151
|
+
"center",
|
|
152
|
+
"right"
|
|
153
|
+
]) {
|
|
154
|
+
let r = t[n];
|
|
155
|
+
r && (n === e.pane ? (r.style.left = `${e.leftPx}px`, r.style.display = "block") : r.style.display = "none");
|
|
156
|
+
}
|
|
157
|
+
}, V = () => {
|
|
158
|
+
if (C === null) {
|
|
159
|
+
A = null;
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
let e = S?.scrollContainerRef.current ?? null;
|
|
163
|
+
if (e && (O || (!D || a(D, E, 6)) && (O = !0), O)) {
|
|
164
|
+
let t = e.getBoundingClientRect(), n = s({
|
|
165
|
+
rectLeft: t.left,
|
|
166
|
+
rectTop: t.top,
|
|
167
|
+
clientLeft: e.clientLeft,
|
|
168
|
+
clientTop: e.clientTop,
|
|
169
|
+
clientWidth: e.clientWidth,
|
|
170
|
+
clientHeight: e.clientHeight
|
|
171
|
+
}), r = o(E.x, n.left, n.right, 24), a = i(e.scrollLeft, r, 18, e.scrollWidth - e.clientWidth);
|
|
172
|
+
a !== e.scrollLeft && e.scrollTo({
|
|
173
|
+
left: a,
|
|
174
|
+
behavior: "auto"
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
B(), A = requestAnimationFrame(V);
|
|
178
|
+
}, H = (e) => {
|
|
179
|
+
A !== null && (cancelAnimationFrame(A), A = null), document.body.style.cursor = "", F(), R();
|
|
180
|
+
let t = C, r = w;
|
|
181
|
+
if (C = null, w = null, !e || !t || !r || S === null) return;
|
|
182
|
+
let { columns: i, applyColumnOrderAndPin: a, scrollContainerRef: o } = S, s = l(i, t, r.pane, r.slot);
|
|
183
|
+
if (!s) return;
|
|
184
|
+
let c = i.find((e) => e.key === t), u = c ? n(c) : null;
|
|
185
|
+
T = u !== null && u === r.pane && !b() ? x(o.current) : null, a(s, /* @__PURE__ */ new Map([[t, r.pane === "center" ? void 0 : r.pane]]));
|
|
186
|
+
};
|
|
187
|
+
return {
|
|
188
|
+
update: (e) => {
|
|
189
|
+
S = e;
|
|
190
|
+
},
|
|
191
|
+
onColumnDragHandlePointerDown: (e, t) => {
|
|
192
|
+
if (S === null || !S.enabled || t.button !== 0) return;
|
|
193
|
+
t.stopPropagation(), t.preventDefault(), C = e.key, E = {
|
|
194
|
+
x: t.clientX,
|
|
195
|
+
y: t.clientY
|
|
196
|
+
}, D = {
|
|
197
|
+
x: t.clientX,
|
|
198
|
+
y: t.clientY
|
|
199
|
+
}, O = !1, document.body.style.cursor = "grabbing", I(e.title || e.key);
|
|
200
|
+
let n = t.currentTarget, r = t.pointerId;
|
|
201
|
+
try {
|
|
202
|
+
n.setPointerCapture(r);
|
|
203
|
+
} catch {}
|
|
204
|
+
let i = (e) => {
|
|
205
|
+
e.pointerId === r && (E = {
|
|
206
|
+
x: e.clientX,
|
|
207
|
+
y: e.clientY
|
|
208
|
+
}, B());
|
|
209
|
+
}, a = () => {
|
|
210
|
+
window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", o), window.removeEventListener("pointercancel", s), k = null;
|
|
211
|
+
try {
|
|
212
|
+
n.releasePointerCapture(r);
|
|
213
|
+
} catch {}
|
|
214
|
+
};
|
|
215
|
+
function o(e) {
|
|
216
|
+
e.pointerId === r && (a(), H(!0));
|
|
217
|
+
}
|
|
218
|
+
function s(e) {
|
|
219
|
+
e.pointerId === r && (a(), H(!1));
|
|
220
|
+
}
|
|
221
|
+
window.addEventListener("pointermove", i), window.addEventListener("pointerup", o), window.addEventListener("pointercancel", s), k = a, B(), A = requestAnimationFrame(V);
|
|
222
|
+
},
|
|
223
|
+
applyReorderSettle: () => {
|
|
224
|
+
let t = T;
|
|
225
|
+
if (T = null, !t) return;
|
|
226
|
+
let n = S?.scrollContainerRef.current ?? null;
|
|
227
|
+
if (!n) return;
|
|
228
|
+
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
229
|
+
n.querySelectorAll("[data-ssg-col-key]").forEach((a) => {
|
|
230
|
+
if (e(n, a)) return;
|
|
231
|
+
let o = a.dataset.ssgColKey;
|
|
232
|
+
if (!o || !t.has(o)) return;
|
|
233
|
+
let s = r.get(o);
|
|
234
|
+
s ? s.push(a) : (r.set(o, [a]), i.set(o, a.getBoundingClientRect().left));
|
|
235
|
+
});
|
|
236
|
+
let a = [];
|
|
237
|
+
if (r.forEach((e, n) => {
|
|
238
|
+
let r = t.get(n), o = i.get(n);
|
|
239
|
+
if (r === void 0 || o === void 0) return;
|
|
240
|
+
let s = r - o;
|
|
241
|
+
if (!(Math.abs(s) < .5)) for (let t of e) t.style.transition = "none", t.style.transform = `translateX(${s}px)`, t.style.willChange = "transform", a.push(t);
|
|
242
|
+
}), a.length !== 0) {
|
|
243
|
+
n.getBoundingClientRect();
|
|
244
|
+
for (let e of a) e.style.transition = `transform ${v}ms ${y}`, e.style.transform = "translateX(0)";
|
|
245
|
+
window.setTimeout(() => {
|
|
246
|
+
for (let e of a) e.style.transition = "", e.style.transform = "", e.style.willChange = "";
|
|
247
|
+
}, 280);
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
dispose: () => {
|
|
251
|
+
k?.(), k = null, A !== null && (cancelAnimationFrame(A), A = null), C = null, w = null, document.body.style.cursor = "", R();
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
//#endregion
|
|
256
|
+
export { l as computeHeaderReorderedKeys, S as createColumnHeaderDragController };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("./popoverSupport.cjs");var n=200,r=8,i=6,a=289,o=()=>{let o=null,s=e.createValueStore({columnKey:null,layout:null}),c={current:null},l=null,u=null,d=null,f=null,p=e=>{let t=s.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||s.setSnapshot({...t,layout:e})},m=()=>{f!==null&&(cancelAnimationFrame(f),f=null),_.detach(),s.setSnapshot({columnKey:null,layout:null})},h=()=>{if(s.getSnapshot().columnKey===null){p(null);return}let e,t,o,d=c.current,f=d?d.scrollHeight+(d.offsetHeight-d.clientHeight):a;if(l){if(!l.isConnected){l=null,m();return}let r=l.getBoundingClientRect();t=r.right-n,e=r.bottom+i,o=r.top-f-i}else if(u)t=u.x,e=u.y,o=u.y-f;else{p(null);return}t=Math.max(r,t),t=Math.min(t,window.innerWidth-n-r);let h=window.innerHeight-r;e+f>h&&o>=r&&(e=o),e=Math.max(r,e);let g=h-e;p({top:e,left:t,width:n,maxHeight:f>g?Math.max(g,0):void 0})},g=()=>{m(),l=null,u=null,o!==null&&t.restoreGridFocus(o.gridRootRef)},_=t.createPopoverWindowBindings({onResize:h,onScroll:()=>{if(u){g();return}h()},isInside:e=>c.current?.contains(e)===!0||l?.contains(e)===!0,onOutsidePointerDown:g,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),g())}}),v=e=>{s.setSnapshot({...s.getSnapshot(),columnKey:e}),h(),f!==null&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{f=null,h()}),_.attach()},y=(e,n)=>{t.blurForPopover(o?.gridRootRef.current??null),l=n,u=null,v(e.key)};return{update:e=>{o=e},subscribe:s.subscribe,getSnapshot:s.getSnapshot,panelRef:c,openFromButton:(e,t)=>{if(t.preventDefault(),t.stopPropagation(),!o?.enableColumnMenu||t.button!==0)return;let n=t.currentTarget;if(s.getSnapshot().columnKey===e.key&&l===n){g();return}if(t.pointerType===`touch`){d=n;return}y(e,n)},openFromButtonClick:(e,t)=>{let n=d;d=null,!(!o?.enableColumnMenu||n!==t.currentTarget)&&(t.preventDefault(),t.stopPropagation(),y(e,t.currentTarget))},openFromContextMenu:(e,n)=>{o?.enableColumnMenu&&(n.preventDefault(),n.stopPropagation(),t.blurForPopover(o.gridRootRef.current),l=null,u={x:n.clientX,y:n.clientY},v(e.key))},close:g,dispose:()=>{f!==null&&(cancelAnimationFrame(f),f=null),_.detach()}}};exports.createColumnMenuController=o;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { GridColumn } from '../model/gridTypes.unbound';
|
|
2
|
+
import { type ReadonlyElementRef } from './popoverSupport';
|
|
3
|
+
export type ColumnMenuLayout = {
|
|
4
|
+
top: number;
|
|
5
|
+
left: number;
|
|
6
|
+
width: number;
|
|
7
|
+
maxHeight?: number;
|
|
8
|
+
};
|
|
9
|
+
export type ColumnMenuSnapshot = {
|
|
10
|
+
columnKey: string | null;
|
|
11
|
+
layout: ColumnMenuLayout | null;
|
|
12
|
+
};
|
|
13
|
+
export type ColumnMenuControllerArgs<T> = {
|
|
14
|
+
visibleColumns: GridColumn<T>[];
|
|
15
|
+
enableColumnMenu: boolean;
|
|
16
|
+
gridRootRef: ReadonlyElementRef;
|
|
17
|
+
};
|
|
18
|
+
export type MenuButtonPointerEvent = {
|
|
19
|
+
button: number;
|
|
20
|
+
pointerType: string;
|
|
21
|
+
currentTarget: HTMLButtonElement;
|
|
22
|
+
preventDefault: () => void;
|
|
23
|
+
stopPropagation: () => void;
|
|
24
|
+
};
|
|
25
|
+
export type MenuButtonClickEvent = {
|
|
26
|
+
currentTarget: HTMLButtonElement;
|
|
27
|
+
preventDefault: () => void;
|
|
28
|
+
stopPropagation: () => void;
|
|
29
|
+
};
|
|
30
|
+
export type MenuContextEvent = {
|
|
31
|
+
clientX: number;
|
|
32
|
+
clientY: number;
|
|
33
|
+
preventDefault: () => void;
|
|
34
|
+
stopPropagation: () => void;
|
|
35
|
+
};
|
|
36
|
+
export type ColumnMenuController<T> = {
|
|
37
|
+
update: (args: ColumnMenuControllerArgs<T>) => void;
|
|
38
|
+
subscribe: (listener: () => void) => () => void;
|
|
39
|
+
getSnapshot: () => ColumnMenuSnapshot;
|
|
40
|
+
panelRef: {
|
|
41
|
+
current: HTMLDivElement | null;
|
|
42
|
+
};
|
|
43
|
+
openFromButton: (column: GridColumn<T>, event: MenuButtonPointerEvent) => void;
|
|
44
|
+
openFromButtonClick: (column: GridColumn<T>, event: MenuButtonClickEvent) => void;
|
|
45
|
+
openFromContextMenu: (column: GridColumn<T>, event: MenuContextEvent) => void;
|
|
46
|
+
close: () => void;
|
|
47
|
+
dispose: () => void;
|
|
48
|
+
};
|
|
49
|
+
export declare const createColumnMenuController: <T>() => ColumnMenuController<T>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { createValueStore as e } from "../logic/valueStore.js";
|
|
2
|
+
import { blurForPopover as t, createPopoverWindowBindings as n, restoreGridFocus as r } from "./popoverSupport.js";
|
|
3
|
+
//#region src/controllers/columnMenuController.ts
|
|
4
|
+
var i = 200, a = 8, o = 6, s = 289, c = () => {
|
|
5
|
+
let c = null, l = e({
|
|
6
|
+
columnKey: null,
|
|
7
|
+
layout: null
|
|
8
|
+
}), u = { current: null }, d = null, f = null, p = null, m = null, h = (e) => {
|
|
9
|
+
let t = l.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 || l.setSnapshot({
|
|
11
|
+
...t,
|
|
12
|
+
layout: e
|
|
13
|
+
});
|
|
14
|
+
}, g = () => {
|
|
15
|
+
m !== null && (cancelAnimationFrame(m), m = null), y.detach(), l.setSnapshot({
|
|
16
|
+
columnKey: null,
|
|
17
|
+
layout: null
|
|
18
|
+
});
|
|
19
|
+
}, _ = () => {
|
|
20
|
+
if (l.getSnapshot().columnKey === null) {
|
|
21
|
+
h(null);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
let e, t, n, r = u.current, c = r ? r.scrollHeight + (r.offsetHeight - r.clientHeight) : s;
|
|
25
|
+
if (d) {
|
|
26
|
+
if (!d.isConnected) {
|
|
27
|
+
d = null, g();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
let r = d.getBoundingClientRect();
|
|
31
|
+
t = r.right - i, e = r.bottom + o, n = r.top - c - o;
|
|
32
|
+
} else if (f) t = f.x, e = f.y, n = f.y - c;
|
|
33
|
+
else {
|
|
34
|
+
h(null);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
t = Math.max(a, t), t = Math.min(t, window.innerWidth - i - a);
|
|
38
|
+
let p = window.innerHeight - a;
|
|
39
|
+
e + c > p && n >= a && (e = n), e = Math.max(a, e);
|
|
40
|
+
let m = p - e;
|
|
41
|
+
h({
|
|
42
|
+
top: e,
|
|
43
|
+
left: t,
|
|
44
|
+
width: i,
|
|
45
|
+
maxHeight: c > m ? Math.max(m, 0) : void 0
|
|
46
|
+
});
|
|
47
|
+
}, v = () => {
|
|
48
|
+
g(), d = null, f = null, c !== null && r(c.gridRootRef);
|
|
49
|
+
}, y = n({
|
|
50
|
+
onResize: _,
|
|
51
|
+
onScroll: () => {
|
|
52
|
+
if (f) {
|
|
53
|
+
v();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
_();
|
|
57
|
+
},
|
|
58
|
+
isInside: (e) => u.current?.contains(e) === !0 || d?.contains(e) === !0,
|
|
59
|
+
onOutsidePointerDown: v,
|
|
60
|
+
onKeyDown: (e) => {
|
|
61
|
+
e.key === "Escape" && (e.preventDefault(), v());
|
|
62
|
+
}
|
|
63
|
+
}), b = (e) => {
|
|
64
|
+
l.setSnapshot({
|
|
65
|
+
...l.getSnapshot(),
|
|
66
|
+
columnKey: e
|
|
67
|
+
}), _(), m !== null && cancelAnimationFrame(m), m = requestAnimationFrame(() => {
|
|
68
|
+
m = null, _();
|
|
69
|
+
}), y.attach();
|
|
70
|
+
}, x = (e, n) => {
|
|
71
|
+
t(c?.gridRootRef.current ?? null), d = n, f = null, b(e.key);
|
|
72
|
+
};
|
|
73
|
+
return {
|
|
74
|
+
update: (e) => {
|
|
75
|
+
c = e;
|
|
76
|
+
},
|
|
77
|
+
subscribe: l.subscribe,
|
|
78
|
+
getSnapshot: l.getSnapshot,
|
|
79
|
+
panelRef: u,
|
|
80
|
+
openFromButton: (e, t) => {
|
|
81
|
+
if (t.preventDefault(), t.stopPropagation(), !c?.enableColumnMenu || t.button !== 0) return;
|
|
82
|
+
let n = t.currentTarget;
|
|
83
|
+
if (l.getSnapshot().columnKey === e.key && d === n) {
|
|
84
|
+
v();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (t.pointerType === "touch") {
|
|
88
|
+
p = n;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
x(e, n);
|
|
92
|
+
},
|
|
93
|
+
openFromButtonClick: (e, t) => {
|
|
94
|
+
let n = p;
|
|
95
|
+
p = null, !(!c?.enableColumnMenu || n !== t.currentTarget) && (t.preventDefault(), t.stopPropagation(), x(e, t.currentTarget));
|
|
96
|
+
},
|
|
97
|
+
openFromContextMenu: (e, n) => {
|
|
98
|
+
c?.enableColumnMenu && (n.preventDefault(), n.stopPropagation(), t(c.gridRootRef.current), d = null, f = {
|
|
99
|
+
x: n.clientX,
|
|
100
|
+
y: n.clientY
|
|
101
|
+
}, b(e.key));
|
|
102
|
+
},
|
|
103
|
+
close: v,
|
|
104
|
+
dispose: () => {
|
|
105
|
+
m !== null && (cancelAnimationFrame(m), m = null), y.detach();
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
//#endregion
|
|
110
|
+
export { c as createColumnMenuController };
|
|
@@ -0,0 +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=()=>{s.setSnapshot({state:null,layout:null}),l=null,u=0,m.detach(),o!==null&&t.restoreGridFocus(o.gridRootRef)},m=t.createPopoverWindowBindings({onResize:f,onScroll:p,isInside:e=>c.current?.contains(e)===!0,onOutsidePointerDown:p,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),p())}});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(),m.attach()},close:p,dispose:()=>{m.detach()}}};exports.createContextMenuController=o;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { GridContextMenuItem, GridContextMenuParams } from '../model/gridTypes.unbound';
|
|
2
|
+
import { type ReadonlyElementRef } from './popoverSupport';
|
|
3
|
+
export type CellContextMenuLayout = {
|
|
4
|
+
top: number;
|
|
5
|
+
left: number;
|
|
6
|
+
width: number;
|
|
7
|
+
};
|
|
8
|
+
export type CellContextMenuState<T> = {
|
|
9
|
+
params: GridContextMenuParams<T>;
|
|
10
|
+
items: GridContextMenuItem[];
|
|
11
|
+
};
|
|
12
|
+
export type ContextMenuSnapshot<T> = {
|
|
13
|
+
state: CellContextMenuState<T> | null;
|
|
14
|
+
layout: CellContextMenuLayout | null;
|
|
15
|
+
};
|
|
16
|
+
export type ContextMenuControllerArgs = {
|
|
17
|
+
gridRootRef: ReadonlyElementRef;
|
|
18
|
+
};
|
|
19
|
+
export type ContextMenuController<T> = {
|
|
20
|
+
update: (args: ContextMenuControllerArgs) => void;
|
|
21
|
+
subscribe: (listener: () => void) => () => void;
|
|
22
|
+
getSnapshot: () => ContextMenuSnapshot<T>;
|
|
23
|
+
panelRef: {
|
|
24
|
+
current: HTMLDivElement | null;
|
|
25
|
+
};
|
|
26
|
+
open: (params: GridContextMenuParams<T>, items: GridContextMenuItem[]) => void;
|
|
27
|
+
close: () => void;
|
|
28
|
+
dispose: () => void;
|
|
29
|
+
};
|
|
30
|
+
export declare const createContextMenuController: <T>() => ContextMenuController<T>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createValueStore as e } from "../logic/valueStore.js";
|
|
2
|
+
import { blurForPopover as t, createPopoverWindowBindings as n, restoreGridFocus as r } from "./popoverSupport.js";
|
|
3
|
+
//#region src/controllers/contextMenuController.ts
|
|
4
|
+
var i = 220, a = 8, o = 34, s = 16, c = () => {
|
|
5
|
+
let c = null, l = e({
|
|
6
|
+
state: null,
|
|
7
|
+
layout: null
|
|
8
|
+
}), u = { current: null }, d = null, f = 0, p = (e) => {
|
|
9
|
+
let t = l.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 || l.setSnapshot({
|
|
11
|
+
...t,
|
|
12
|
+
layout: e
|
|
13
|
+
});
|
|
14
|
+
}, m = () => {
|
|
15
|
+
if (!d) {
|
|
16
|
+
p(null);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
let e = f * o + s, t = d.x, n = d.y, r = d.y - e;
|
|
20
|
+
t = Math.max(a, t), t = Math.min(t, window.innerWidth - i - a), n + e > window.innerHeight - a && (n = r), n = Math.max(a, n), p({
|
|
21
|
+
top: n,
|
|
22
|
+
left: t,
|
|
23
|
+
width: i
|
|
24
|
+
});
|
|
25
|
+
}, h = () => {
|
|
26
|
+
l.setSnapshot({
|
|
27
|
+
state: null,
|
|
28
|
+
layout: null
|
|
29
|
+
}), d = null, f = 0, g.detach(), c !== null && r(c.gridRootRef);
|
|
30
|
+
}, g = n({
|
|
31
|
+
onResize: m,
|
|
32
|
+
onScroll: h,
|
|
33
|
+
isInside: (e) => u.current?.contains(e) === !0,
|
|
34
|
+
onOutsidePointerDown: h,
|
|
35
|
+
onKeyDown: (e) => {
|
|
36
|
+
e.key === "Escape" && (e.preventDefault(), h());
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
update: (e) => {
|
|
41
|
+
c = e;
|
|
42
|
+
},
|
|
43
|
+
subscribe: l.subscribe,
|
|
44
|
+
getSnapshot: l.getSnapshot,
|
|
45
|
+
panelRef: u,
|
|
46
|
+
open: (e, n) => {
|
|
47
|
+
t(c?.gridRootRef.current ?? null), d = {
|
|
48
|
+
x: e.clientX,
|
|
49
|
+
y: e.clientY
|
|
50
|
+
}, f = n.length, l.setSnapshot({
|
|
51
|
+
...l.getSnapshot(),
|
|
52
|
+
state: {
|
|
53
|
+
params: e,
|
|
54
|
+
items: n
|
|
55
|
+
}
|
|
56
|
+
}), m(), g.attach();
|
|
57
|
+
},
|
|
58
|
+
close: h,
|
|
59
|
+
dispose: () => {
|
|
60
|
+
g.detach();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { c as createContextMenuController };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs");var t=(t,n)=>{let r=e.createValueStore(t),i=null,a=null,o=()=>{i!==null&&(clearTimeout(i),i=null)};return{update:({value:e,enabled:t})=>{a!==null&&Object.is(a.value,e)&&a.enabled===t||(a={value:e,enabled:t},o(),t&&(i=setTimeout(()=>{i=null,r.setSnapshot(e)},n)))},getSnapshot:r.getSnapshot,subscribe:r.subscribe,dispose:o}};exports.createDebouncedValueStore=t;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type DebouncedValueArgs<V> = {
|
|
2
|
+
value: V;
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
};
|
|
5
|
+
export type DebouncedValueStore<V> = {
|
|
6
|
+
update: (args: DebouncedValueArgs<V>) => void;
|
|
7
|
+
getSnapshot: () => V;
|
|
8
|
+
subscribe: (listener: () => void) => () => void;
|
|
9
|
+
dispose: () => void;
|
|
10
|
+
};
|
|
11
|
+
export declare const createDebouncedValueStore: <V>(initial: V, delayMs: number) => DebouncedValueStore<V>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createValueStore as e } from "../logic/valueStore.js";
|
|
2
|
+
//#region src/controllers/debouncedValueStore.ts
|
|
3
|
+
var t = (t, n) => {
|
|
4
|
+
let r = e(t), i = null, a = null, o = () => {
|
|
5
|
+
i !== null && (clearTimeout(i), i = null);
|
|
6
|
+
};
|
|
7
|
+
return {
|
|
8
|
+
update: ({ value: e, enabled: t }) => {
|
|
9
|
+
a !== null && Object.is(a.value, e) && a.enabled === t || (a = {
|
|
10
|
+
value: e,
|
|
11
|
+
enabled: t
|
|
12
|
+
}, o(), t && (i = setTimeout(() => {
|
|
13
|
+
i = null, r.setSnapshot(e);
|
|
14
|
+
}, n)));
|
|
15
|
+
},
|
|
16
|
+
getSnapshot: r.getSnapshot,
|
|
17
|
+
subscribe: r.subscribe,
|
|
18
|
+
dispose: o
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { t as createDebouncedValueStore };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs"),t=require("../model/gridActions.cjs"),n=require("../logic/geometry.cjs"),r=require("../logic/editorValues.cjs"),i=require("../logic/validation.cjs");var a=()=>{let a=null,o=e=>{a=e},s=e=>{a!==null&&(a.dispatch(t.gridActions.startSelection(e)),a.dispatch(t.gridActions.endSelection()),a.dispatch(t.gridActions.activateCell(e)))},c=(e,n)=>{a!==null&&(a.setEditorInitialValue(n),a.dispatch(t.gridActions.startEdit(e)))},l=t=>{let r=a;r!==null&&requestAnimationFrame(()=>{if(e.isFocusInsideDetailCard()||r.gridRootRef.current?.focus(),t!==null&&a!==null){let e=a.rowModel.getRowCount(),r=a.visibleColumns.length;s({row:n.clamp(t.row,0,Math.max(e-1,0)),col:n.clamp(t.col,0,Math.max(r-1,0))})}r.editorActionGuardRef.current=!1})};return{update:o,activateSingleCell:s,startEditWithValue:c,commitEdit:(e,n)=>{if(a===null)return{status:`noop`};let{uiState:o,visibleColumns:s,rowModel:c,rows:u,applyServerSideCellEdits:d,onRowsChange:f,dispatch:p,editorActionGuardRef:m}=a;if(m.current||!o.editingCell)return{status:`noop`};let h=o.editingCell,g=n===`down`?{row:h.row+1,col:h.col}:n===`up`?{row:h.row-1,col:h.col}:n===`right`?{row:h.row,col:h.col+1}:n===`left`?{row:h.row,col:h.col-1}:h,_=s[h.col],v=c.getSourceIndex(h.row),y=d?c.getRow(h.row):u[v];if(!_||!y)return p(t.gridActions.stopEdit()),{status:`noop`};if(d){let t=r.parseCommittedValue(_,e,y),n=i.decideCellWrite(_,y,t);if(n.action===`reject`)return{status:`rejected`,message:n.message};d([{viewIndex:h.row,column:_,value:t}])}else if(f){let t=r.parseCommittedValue(_,e,y),n=i.decideCellWrite(_,y,t);if(n.action===`reject`)return{status:`rejected`,message:n.message};f(r.writeRowsCell(u,v,_,t))}return m.current=!0,l(g),p(t.gridActions.stopEdit()),{status:`committed`}},cancelEdit:()=>{a===null||a.editorActionGuardRef.current||(a.editorActionGuardRef.current=!0,a.dispatch(t.gridActions.stopEdit()),l(null))}}};exports.createEditController=a;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type GridUiAction } from '../model/gridActions';
|
|
2
|
+
import type { CellCoord, EditorCommitDirection, EditorCommitResult, GridColumn, GridUiState, RowModel } from '../model/gridTypes.unbound';
|
|
3
|
+
import type { ServerSideCellEditInput } from '../logic/serverSideEdits';
|
|
4
|
+
export type EditControllerArgs<T extends object> = {
|
|
5
|
+
uiState: GridUiState;
|
|
6
|
+
rows: T[];
|
|
7
|
+
visibleColumns: GridColumn<T>[];
|
|
8
|
+
rowModel: RowModel<T>;
|
|
9
|
+
setEditorInitialValue: (value: string) => void;
|
|
10
|
+
onRowsChange?: (nextRows: T[]) => void;
|
|
11
|
+
applyServerSideCellEdits?: (edits: ServerSideCellEditInput<T>[]) => number;
|
|
12
|
+
dispatch: (action: GridUiAction) => void;
|
|
13
|
+
gridRootRef: {
|
|
14
|
+
readonly current: HTMLElement | null;
|
|
15
|
+
};
|
|
16
|
+
editorActionGuardRef: {
|
|
17
|
+
current: boolean;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type EditController<T extends object> = {
|
|
21
|
+
update: (args: EditControllerArgs<T>) => void;
|
|
22
|
+
activateSingleCell: (cell: CellCoord) => void;
|
|
23
|
+
startEditWithValue: (cell: CellCoord, initialValue: string) => void;
|
|
24
|
+
commitEdit: (committedValue: unknown, direction?: EditorCommitDirection) => EditorCommitResult;
|
|
25
|
+
cancelEdit: () => void;
|
|
26
|
+
};
|
|
27
|
+
export declare const createEditController: <T extends object>() => EditController<T>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { isFocusInsideDetailCard as e } from "../logic/detailRow.js";
|
|
2
|
+
import { gridActions as t } from "../model/gridActions.js";
|
|
3
|
+
import { clamp as n } from "../logic/geometry.js";
|
|
4
|
+
import { parseCommittedValue as r, writeRowsCell as i } from "../logic/editorValues.js";
|
|
5
|
+
import { decideCellWrite as a } from "../logic/validation.js";
|
|
6
|
+
//#region src/controllers/editController.ts
|
|
7
|
+
var o = () => {
|
|
8
|
+
let o = null, s = (e) => {
|
|
9
|
+
o = e;
|
|
10
|
+
}, c = (e) => {
|
|
11
|
+
o !== null && (o.dispatch(t.startSelection(e)), o.dispatch(t.endSelection()), o.dispatch(t.activateCell(e)));
|
|
12
|
+
}, l = (e, n) => {
|
|
13
|
+
o !== null && (o.setEditorInitialValue(n), o.dispatch(t.startEdit(e)));
|
|
14
|
+
}, u = (t) => {
|
|
15
|
+
let r = o;
|
|
16
|
+
r !== null && requestAnimationFrame(() => {
|
|
17
|
+
if (e() || r.gridRootRef.current?.focus(), t !== null && o !== null) {
|
|
18
|
+
let e = o.rowModel.getRowCount(), r = o.visibleColumns.length;
|
|
19
|
+
c({
|
|
20
|
+
row: n(t.row, 0, Math.max(e - 1, 0)),
|
|
21
|
+
col: n(t.col, 0, Math.max(r - 1, 0))
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
r.editorActionGuardRef.current = !1;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
update: s,
|
|
29
|
+
activateSingleCell: c,
|
|
30
|
+
startEditWithValue: l,
|
|
31
|
+
commitEdit: (e, n) => {
|
|
32
|
+
if (o === null) return { status: "noop" };
|
|
33
|
+
let { uiState: s, visibleColumns: c, rowModel: l, rows: d, applyServerSideCellEdits: f, onRowsChange: p, dispatch: m, editorActionGuardRef: h } = o;
|
|
34
|
+
if (h.current || !s.editingCell) return { status: "noop" };
|
|
35
|
+
let g = s.editingCell, _ = n === "down" ? {
|
|
36
|
+
row: g.row + 1,
|
|
37
|
+
col: g.col
|
|
38
|
+
} : n === "up" ? {
|
|
39
|
+
row: g.row - 1,
|
|
40
|
+
col: g.col
|
|
41
|
+
} : n === "right" ? {
|
|
42
|
+
row: g.row,
|
|
43
|
+
col: g.col + 1
|
|
44
|
+
} : n === "left" ? {
|
|
45
|
+
row: g.row,
|
|
46
|
+
col: g.col - 1
|
|
47
|
+
} : g, v = c[g.col], y = l.getSourceIndex(g.row), b = f ? l.getRow(g.row) : d[y];
|
|
48
|
+
if (!v || !b) return m(t.stopEdit()), { status: "noop" };
|
|
49
|
+
if (f) {
|
|
50
|
+
let t = r(v, e, b), n = a(v, b, t);
|
|
51
|
+
if (n.action === "reject") return {
|
|
52
|
+
status: "rejected",
|
|
53
|
+
message: n.message
|
|
54
|
+
};
|
|
55
|
+
f([{
|
|
56
|
+
viewIndex: g.row,
|
|
57
|
+
column: v,
|
|
58
|
+
value: t
|
|
59
|
+
}]);
|
|
60
|
+
} else if (p) {
|
|
61
|
+
let t = r(v, e, b), n = a(v, b, t);
|
|
62
|
+
if (n.action === "reject") return {
|
|
63
|
+
status: "rejected",
|
|
64
|
+
message: n.message
|
|
65
|
+
};
|
|
66
|
+
p(i(d, y, v, t));
|
|
67
|
+
}
|
|
68
|
+
return h.current = !0, u(_), m(t.stopEdit()), { status: "committed" };
|
|
69
|
+
},
|
|
70
|
+
cancelEdit: () => {
|
|
71
|
+
o === null || o.editorActionGuardRef.current || (o.editorActionGuardRef.current = !0, o.dispatch(t.stopEdit()), u(null));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
export { o as createEditController };
|