@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,74 @@
|
|
|
1
|
+
import { type GridUiAction } from '../model/gridActions';
|
|
2
|
+
import type { CellCoord, GridColumn, GridUiState } from '../model/gridTypes.unbound';
|
|
3
|
+
import { type GridPaneLayout } from '../logic/geometry';
|
|
4
|
+
import { type RowMetrics } from '../logic/verticalGeometry';
|
|
5
|
+
export declare const TOUCH_TAP_SLOP_PX = 10;
|
|
6
|
+
export declare const TOUCH_DOUBLE_TAP_MS = 300;
|
|
7
|
+
type MutableRef<V> = {
|
|
8
|
+
current: V;
|
|
9
|
+
};
|
|
10
|
+
type ReadonlyRef<V> = {
|
|
11
|
+
readonly current: V;
|
|
12
|
+
};
|
|
13
|
+
export type GridPointerEventLike = {
|
|
14
|
+
button: number;
|
|
15
|
+
pointerType: string;
|
|
16
|
+
pointerId: number;
|
|
17
|
+
clientX: number;
|
|
18
|
+
clientY: number;
|
|
19
|
+
shiftKey: boolean;
|
|
20
|
+
preventDefault: () => void;
|
|
21
|
+
};
|
|
22
|
+
export type PointerInteractionsArgs<T> = {
|
|
23
|
+
gridRootRef: ReadonlyRef<HTMLElement | null>;
|
|
24
|
+
bodyScrollRef: ReadonlyRef<HTMLElement | null>;
|
|
25
|
+
scrollContainerRef: ReadonlyRef<HTMLElement | null>;
|
|
26
|
+
leftPaneScrollRef: ReadonlyRef<HTMLElement | null>;
|
|
27
|
+
rightPaneScrollRef: ReadonlyRef<HTMLElement | null>;
|
|
28
|
+
pointerClientRef: MutableRef<{
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
} | null>;
|
|
32
|
+
autoScrollFrameRef: MutableRef<number | null>;
|
|
33
|
+
uiState: GridUiState;
|
|
34
|
+
dispatch: (action: GridUiAction) => void;
|
|
35
|
+
enableRangeSelection: boolean;
|
|
36
|
+
enableSorting: boolean;
|
|
37
|
+
orderedColumns: GridColumn<T>[];
|
|
38
|
+
filteredRowsLength: number;
|
|
39
|
+
visibleColumnsLength: number;
|
|
40
|
+
paneLayout: GridPaneLayout<T>;
|
|
41
|
+
leftLeadingWidth: number;
|
|
42
|
+
centerLeadingWidth: number;
|
|
43
|
+
rightLeadingWidth: number;
|
|
44
|
+
headerHeight: number;
|
|
45
|
+
rowMetrics: RowMetrics;
|
|
46
|
+
verticalScaleFactor: number;
|
|
47
|
+
setHoveredRowIndex: (value: number | null) => void;
|
|
48
|
+
setHoveredColumnIndex: (value: number | null) => void;
|
|
49
|
+
enableRowHover: boolean;
|
|
50
|
+
enableColumnHeaderHover: boolean;
|
|
51
|
+
enableRowSelection: boolean;
|
|
52
|
+
onGutterRowSelect: (viewIndex: number, opts: {
|
|
53
|
+
shiftKey: boolean;
|
|
54
|
+
}) => void;
|
|
55
|
+
onGutterRowSelectDrag: (viewIndex: number) => void;
|
|
56
|
+
onCellDoubleClickRef: ReadonlyRef<(cell: CellCoord) => void>;
|
|
57
|
+
};
|
|
58
|
+
export type PointerInteractionsController<T> = {
|
|
59
|
+
update: (args: PointerInteractionsArgs<T>) => void;
|
|
60
|
+
updateSelectionFromPointer: (clientX: number, clientY: number) => void;
|
|
61
|
+
handleCellPointerDown: (cell: CellCoord, event: GridPointerEventLike) => void;
|
|
62
|
+
handleCellDoubleClick: (cell: CellCoord) => void;
|
|
63
|
+
handleCellPointerEnter: (cell: CellCoord, event: GridPointerEventLike) => void;
|
|
64
|
+
handleNativeDragStart: (event: {
|
|
65
|
+
preventDefault: () => void;
|
|
66
|
+
}) => void;
|
|
67
|
+
handleRowHeaderPointerDown: (rowIndex: number, event: GridPointerEventLike) => void;
|
|
68
|
+
handleRowHeaderPointerEnter: (rowIndex: number, event: GridPointerEventLike) => void;
|
|
69
|
+
handleColumnHeaderPointerDown: (colIndex: number, event: GridPointerEventLike) => void;
|
|
70
|
+
handleColumnHeaderPointerEnter: (colIndex: number, event: GridPointerEventLike) => void;
|
|
71
|
+
dispose: () => void;
|
|
72
|
+
};
|
|
73
|
+
export declare const createPointerInteractionsController: <T>() => PointerInteractionsController<T>;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { isSyntheticColumnKey as e } from "../logic/detailRow.js";
|
|
2
|
+
import { gridActions as t } from "../model/gridActions.js";
|
|
3
|
+
import { clamp as n, findLogicalIndexFromPaneOffset as r } from "../logic/geometry.js";
|
|
4
|
+
import { computeNextScrollPosition as i, hasPointerLeftActivationRadius as a, resolveAutoScrollAxisDirection as o, resolveScrollContentBox as s } from "../logic/autoScrollGeometry.js";
|
|
5
|
+
import { nextSortEntries as c } from "../logic/sorting.js";
|
|
6
|
+
import { clientYToRowIndex as l } from "../logic/verticalGeometry.js";
|
|
7
|
+
//#region src/controllers/pointerInteractionsController.ts
|
|
8
|
+
var u = 10, d = 300, f = () => {
|
|
9
|
+
let u = null, d = !1, f = !1, p = null, m = null, h = "mouse", g = null, _ = null, v = !1, y = !1, b = () => u?.uiState.dragState ?? null, x = (e, t) => {
|
|
10
|
+
if (u === null) return null;
|
|
11
|
+
let { bodyScrollRef: i, scrollContainerRef: a, leftPaneScrollRef: o, rightPaneScrollRef: s, filteredRowsLength: c, visibleColumnsLength: d, paneLayout: f, leftLeadingWidth: p, centerLeadingWidth: m, rightLeadingWidth: h, headerHeight: g, rowMetrics: _, verticalScaleFactor: v } = u, y = i.current;
|
|
12
|
+
if (!y || c === 0 || d === 0) return null;
|
|
13
|
+
let b = y.getBoundingClientRect(), x = l(y.scrollTop + t - b.top - g, a.current?.scrollTop ?? 0, v, _), S = null, C = o.current;
|
|
14
|
+
if (S === null && C && f.left.entries.length > 0) {
|
|
15
|
+
let t = C.getBoundingClientRect();
|
|
16
|
+
if (e < t.right) {
|
|
17
|
+
let n = e - t.left - p;
|
|
18
|
+
S = r(f.left, n);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
let w = s.current;
|
|
22
|
+
if (S === null && w && f.right.entries.length > 0) {
|
|
23
|
+
let t = w.getBoundingClientRect();
|
|
24
|
+
if (e >= t.left) {
|
|
25
|
+
let n = e - t.left - h;
|
|
26
|
+
S = r(f.right, n);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (S === null && f.center.entries.length > 0) {
|
|
30
|
+
let t = y.scrollLeft + e - b.left - m;
|
|
31
|
+
S = r(f.center, Math.max(t, 0));
|
|
32
|
+
}
|
|
33
|
+
return S === null ? null : {
|
|
34
|
+
row: x,
|
|
35
|
+
col: n(S, 0, d - 1)
|
|
36
|
+
};
|
|
37
|
+
}, S = (e, n) => {
|
|
38
|
+
let r = b();
|
|
39
|
+
if (u === null || !r || r.type !== "selection") return;
|
|
40
|
+
let i = x(e, n);
|
|
41
|
+
if (i) {
|
|
42
|
+
if (r.selectionKind === "cell") {
|
|
43
|
+
u.dispatch(t.updateSelection(i));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (r.selectionKind === "row") {
|
|
47
|
+
u.dispatch(t.updateRowSelection(i.row));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
r.selectionKind === "col" && u.dispatch(t.updateColumnSelection(i.col));
|
|
51
|
+
}
|
|
52
|
+
}, C = (e, n) => {
|
|
53
|
+
if (u === null) return;
|
|
54
|
+
let { gridRootRef: r, dispatch: i, enableRangeSelection: a, enableRowSelection: o, onGutterRowSelect: s, onCellDoubleClickRef: c } = u;
|
|
55
|
+
r.current?.focus({ preventScroll: !0 });
|
|
56
|
+
let { target: l } = e;
|
|
57
|
+
if (l.kind === "cell") {
|
|
58
|
+
let e = m;
|
|
59
|
+
if (e && e.cell.row === l.cell.row && e.cell.col === l.cell.col && n - e.time < 300) {
|
|
60
|
+
m = null, c.current(l.cell);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
m = {
|
|
64
|
+
cell: l.cell,
|
|
65
|
+
time: n
|
|
66
|
+
}, i(t.activateCell(l.cell)), a && (i(t.startSelection(l.cell)), i(t.endSelection()));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (m = null, l.kind === "row") {
|
|
70
|
+
if (o) {
|
|
71
|
+
s(l.rowIndex, { shiftKey: !1 });
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
i(t.startRowSelection(l.rowIndex)), i(t.endSelection());
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
i(t.startColumnSelection(l.colIndex)), i(t.endSelection());
|
|
78
|
+
}, w = () => {
|
|
79
|
+
u !== null && (f = !1, u.dispatch(t.endSelection()), u.dispatch(t.endColumnResize()));
|
|
80
|
+
}, T = (e) => {
|
|
81
|
+
u !== null && (u.pointerClientRef.current = {
|
|
82
|
+
x: e.clientX,
|
|
83
|
+
y: e.clientY
|
|
84
|
+
}, b()?.type === "columnResize" && u.dispatch(t.updateColumnResize(e.clientX)));
|
|
85
|
+
}, E = (e) => {
|
|
86
|
+
let t = p;
|
|
87
|
+
t && (p = null, e.pointerId === t.pointerId && Math.abs(e.clientX - t.x) < 10 && Math.abs(e.clientY - t.y) < 10 && C(t, e.timeStamp)), w();
|
|
88
|
+
}, D = () => {
|
|
89
|
+
p = null, w();
|
|
90
|
+
}, O = () => {
|
|
91
|
+
d || (d = !0, window.addEventListener("pointermove", T), window.addEventListener("pointerup", E), window.addEventListener("pointercancel", D));
|
|
92
|
+
}, k = () => {
|
|
93
|
+
d && (d = !1, window.removeEventListener("pointermove", T), window.removeEventListener("pointerup", E), window.removeEventListener("pointercancel", D));
|
|
94
|
+
}, A = () => {
|
|
95
|
+
y = !1, u !== null && u.autoScrollFrameRef.current !== null && (cancelAnimationFrame(u.autoScrollFrameRef.current), u.autoScrollFrameRef.current = null);
|
|
96
|
+
}, j = () => {
|
|
97
|
+
if (u === null || !y) return;
|
|
98
|
+
let { scrollContainerRef: e, pointerClientRef: t, autoScrollFrameRef: n } = u, r = e.current, c = t.current;
|
|
99
|
+
if (!r || !c) {
|
|
100
|
+
n.current = requestAnimationFrame(j);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (!v) {
|
|
104
|
+
let e = _;
|
|
105
|
+
if (e && !a(e, c, 6)) {
|
|
106
|
+
n.current = requestAnimationFrame(j);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
v = !0;
|
|
110
|
+
}
|
|
111
|
+
let l = r.getBoundingClientRect(), d = s({
|
|
112
|
+
rectLeft: l.left,
|
|
113
|
+
rectTop: l.top,
|
|
114
|
+
clientLeft: r.clientLeft,
|
|
115
|
+
clientTop: r.clientTop,
|
|
116
|
+
clientWidth: r.clientWidth,
|
|
117
|
+
clientHeight: r.clientHeight
|
|
118
|
+
}), f = b(), p = f?.type === "selection" && f.selectionKind === "col", m = f?.type === "selection" && f.selectionKind === "row", h = p ? 0 : o(c.y, d.top, d.bottom, 24), g = m ? 0 : o(c.x, d.left, d.right, 24), x = i(r.scrollTop, h, 18, r.scrollHeight - r.clientHeight), C = i(r.scrollLeft, g, 18, r.scrollWidth - r.clientWidth);
|
|
119
|
+
(x !== r.scrollTop || C !== r.scrollLeft) && (r.scrollTo({
|
|
120
|
+
top: x,
|
|
121
|
+
left: C,
|
|
122
|
+
behavior: "auto"
|
|
123
|
+
}), S(c.x, c.y)), n.current = requestAnimationFrame(j);
|
|
124
|
+
}, M = () => {
|
|
125
|
+
let e = b()?.type === "selection";
|
|
126
|
+
e && !y ? (y = !0, u !== null && (u.autoScrollFrameRef.current = requestAnimationFrame(j))) : !e && y && A();
|
|
127
|
+
}, N = () => {
|
|
128
|
+
if (g !== null) return;
|
|
129
|
+
let e = () => {
|
|
130
|
+
if (!f || u === null) {
|
|
131
|
+
g = null;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
let { scrollContainerRef: t, pointerClientRef: n, onGutterRowSelectDrag: r } = u, c = t.current, l = n.current;
|
|
135
|
+
if (!c || !l) {
|
|
136
|
+
g = requestAnimationFrame(e);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (!v) {
|
|
140
|
+
let t = _;
|
|
141
|
+
if (t && !a(t, l, 6)) {
|
|
142
|
+
g = requestAnimationFrame(e);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
v = !0;
|
|
146
|
+
}
|
|
147
|
+
let d = c.getBoundingClientRect(), p = s({
|
|
148
|
+
rectLeft: d.left,
|
|
149
|
+
rectTop: d.top,
|
|
150
|
+
clientLeft: c.clientLeft,
|
|
151
|
+
clientTop: c.clientTop,
|
|
152
|
+
clientWidth: c.clientWidth,
|
|
153
|
+
clientHeight: c.clientHeight
|
|
154
|
+
}), m = o(l.y, p.top, p.bottom, 24), h = i(c.scrollTop, m, 18, c.scrollHeight - c.clientHeight);
|
|
155
|
+
if (h !== c.scrollTop) {
|
|
156
|
+
c.scrollTo({
|
|
157
|
+
top: h,
|
|
158
|
+
left: c.scrollLeft,
|
|
159
|
+
behavior: "auto"
|
|
160
|
+
});
|
|
161
|
+
let e = x(l.x, l.y);
|
|
162
|
+
e && r(e.row);
|
|
163
|
+
}
|
|
164
|
+
g = requestAnimationFrame(e);
|
|
165
|
+
};
|
|
166
|
+
g = requestAnimationFrame(e);
|
|
167
|
+
}, P = (e, t) => (e.preventDefault(), u === null || e.button !== 0 ? !1 : (h = e.pointerType, e.pointerType === "touch" ? (p = {
|
|
168
|
+
pointerId: e.pointerId,
|
|
169
|
+
x: e.clientX,
|
|
170
|
+
y: e.clientY,
|
|
171
|
+
target: t
|
|
172
|
+
}, !1) : (u.gridRootRef.current?.focus({ preventScroll: !0 }), u.pointerClientRef.current = {
|
|
173
|
+
x: e.clientX,
|
|
174
|
+
y: e.clientY
|
|
175
|
+
}, _ = {
|
|
176
|
+
x: e.clientX,
|
|
177
|
+
y: e.clientY
|
|
178
|
+
}, v = !1, !0)));
|
|
179
|
+
return {
|
|
180
|
+
update: (e) => {
|
|
181
|
+
u = e, O(), M();
|
|
182
|
+
},
|
|
183
|
+
updateSelectionFromPointer: S,
|
|
184
|
+
handleCellPointerDown: (e, n) => {
|
|
185
|
+
!P(n, {
|
|
186
|
+
kind: "cell",
|
|
187
|
+
cell: e
|
|
188
|
+
}) || u === null || (u.dispatch(t.activateCell(e)), u.enableRangeSelection && u.dispatch(t.startSelection(e)));
|
|
189
|
+
},
|
|
190
|
+
handleCellDoubleClick: (e) => {
|
|
191
|
+
h === "touch" || u === null || u.onCellDoubleClickRef.current(e);
|
|
192
|
+
},
|
|
193
|
+
handleCellPointerEnter: (e, n) => {
|
|
194
|
+
if (u === null || (u.enableRowHover && u.setHoveredRowIndex(e.row), !u.enableRangeSelection)) return;
|
|
195
|
+
let r = b();
|
|
196
|
+
r?.type !== "selection" || r.selectionKind !== "cell" || (u.pointerClientRef.current = {
|
|
197
|
+
x: n.clientX,
|
|
198
|
+
y: n.clientY
|
|
199
|
+
}, u.dispatch(t.updateSelection(e)));
|
|
200
|
+
},
|
|
201
|
+
handleNativeDragStart: (e) => {
|
|
202
|
+
e.preventDefault();
|
|
203
|
+
},
|
|
204
|
+
handleRowHeaderPointerDown: (e, n) => {
|
|
205
|
+
if (!(!P(n, {
|
|
206
|
+
kind: "row",
|
|
207
|
+
rowIndex: e
|
|
208
|
+
}) || u === null)) {
|
|
209
|
+
if (u.enableRowSelection) {
|
|
210
|
+
f = !0, u.onGutterRowSelect(e, { shiftKey: n.shiftKey }), N();
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
u.dispatch(t.startRowSelection(e));
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
handleRowHeaderPointerEnter: (e, n) => {
|
|
217
|
+
if (u === null) return;
|
|
218
|
+
if (u.enableRowHover && u.setHoveredRowIndex(e), f) {
|
|
219
|
+
u.pointerClientRef.current = {
|
|
220
|
+
x: n.clientX,
|
|
221
|
+
y: n.clientY
|
|
222
|
+
}, u.onGutterRowSelectDrag(e);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
let r = b();
|
|
226
|
+
r?.type !== "selection" || r.selectionKind !== "row" || (u.pointerClientRef.current = {
|
|
227
|
+
x: n.clientX,
|
|
228
|
+
y: n.clientY
|
|
229
|
+
}, u.dispatch(t.updateRowSelection(e)));
|
|
230
|
+
},
|
|
231
|
+
handleColumnHeaderPointerDown: (n, r) => {
|
|
232
|
+
if (!(!P(r, {
|
|
233
|
+
kind: "col",
|
|
234
|
+
colIndex: n
|
|
235
|
+
}) || u === null)) {
|
|
236
|
+
if (r.shiftKey && u.enableSorting) {
|
|
237
|
+
let r = u.orderedColumns[n];
|
|
238
|
+
if (r && !e(r.key)) {
|
|
239
|
+
let e = u.uiState.sort, n = e.find((e) => e.columnKey === r.key)?.direction ? "desc" : "asc", i = c(e, r.key, n, !0);
|
|
240
|
+
u.dispatch(i.length === 0 ? t.clearSort() : t.setSort(i));
|
|
241
|
+
}
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
u.dispatch(t.startColumnSelection(n));
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
handleColumnHeaderPointerEnter: (e, n) => {
|
|
248
|
+
if (u === null) return;
|
|
249
|
+
u.setHoveredRowIndex(null), u.enableColumnHeaderHover && u.setHoveredColumnIndex(e);
|
|
250
|
+
let r = b();
|
|
251
|
+
r?.type !== "selection" || r.selectionKind !== "col" || (u.pointerClientRef.current = {
|
|
252
|
+
x: n.clientX,
|
|
253
|
+
y: n.clientY
|
|
254
|
+
}, u.dispatch(t.updateColumnSelection(e)));
|
|
255
|
+
},
|
|
256
|
+
dispose: () => {
|
|
257
|
+
k(), A(), g !== null && (cancelAnimationFrame(g), g = null);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
//#endregion
|
|
262
|
+
export { d as TOUCH_DOUBLE_TAP_MS, u as TOUCH_TAP_SLOP_PX, f as createPointerInteractionsController };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs");var t=e=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e?.blur()},n=t=>{requestAnimationFrame(()=>{e.isFocusInsideDetailCard()||t.current?.focus()})},r=e=>{let t=!1,n=()=>e.onResize?.(),r=t=>e.onScroll?.(t),i=t=>{let n=t.target;n&&(e.isInside(n)||e.onOutsidePointerDown())},a=t=>e.onKeyDown?.(t);return{attach:()=>{t||(t=!0,window.addEventListener(`resize`,n),window.addEventListener(`scroll`,r,!0),window.addEventListener(`pointerdown`,i),window.addEventListener(`keydown`,a,!0))},detach:()=>{t&&(t=!1,window.removeEventListener(`resize`,n),window.removeEventListener(`scroll`,r,!0),window.removeEventListener(`pointerdown`,i),window.removeEventListener(`keydown`,a,!0))},isAttached:()=>t}};exports.blurForPopover=t,exports.createPopoverWindowBindings=r,exports.restoreGridFocus=n;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type ReadonlyElementRef<E extends HTMLElement = HTMLElement> = {
|
|
2
|
+
readonly current: E | null;
|
|
3
|
+
};
|
|
4
|
+
export declare const blurForPopover: (gridRoot: HTMLElement | null) => void;
|
|
5
|
+
export declare const restoreGridFocus: (gridRootRef: ReadonlyElementRef) => void;
|
|
6
|
+
export type PopoverWindowHandlers = {
|
|
7
|
+
onResize?: () => void;
|
|
8
|
+
onScroll?: (event: Event) => void;
|
|
9
|
+
isInside: (target: Node) => boolean;
|
|
10
|
+
onOutsidePointerDown: () => void;
|
|
11
|
+
onKeyDown?: (event: KeyboardEvent) => void;
|
|
12
|
+
};
|
|
13
|
+
export type PopoverWindowBindings = {
|
|
14
|
+
attach: () => void;
|
|
15
|
+
detach: () => void;
|
|
16
|
+
isAttached: () => boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare const createPopoverWindowBindings: (handlers: PopoverWindowHandlers) => PopoverWindowBindings;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isFocusInsideDetailCard as e } from "../logic/detailRow.js";
|
|
2
|
+
//#region src/controllers/popoverSupport.ts
|
|
3
|
+
var t = (e) => {
|
|
4
|
+
document.activeElement instanceof HTMLElement && document.activeElement.blur(), e?.blur();
|
|
5
|
+
}, n = (t) => {
|
|
6
|
+
requestAnimationFrame(() => {
|
|
7
|
+
e() || t.current?.focus();
|
|
8
|
+
});
|
|
9
|
+
}, r = (e) => {
|
|
10
|
+
let t = !1, n = () => e.onResize?.(), r = (t) => e.onScroll?.(t), i = (t) => {
|
|
11
|
+
let n = t.target;
|
|
12
|
+
n && (e.isInside(n) || e.onOutsidePointerDown());
|
|
13
|
+
}, a = (t) => e.onKeyDown?.(t);
|
|
14
|
+
return {
|
|
15
|
+
attach: () => {
|
|
16
|
+
t || (t = !0, window.addEventListener("resize", n), window.addEventListener("scroll", r, !0), window.addEventListener("pointerdown", i), window.addEventListener("keydown", a, !0));
|
|
17
|
+
},
|
|
18
|
+
detach: () => {
|
|
19
|
+
t && (t = !1, window.removeEventListener("resize", n), window.removeEventListener("scroll", r, !0), window.removeEventListener("pointerdown", i), window.removeEventListener("keydown", a, !0));
|
|
20
|
+
},
|
|
21
|
+
isAttached: () => t
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { t as blurForPopover, r as createPopoverWindowBindings, n as restoreGridFocus };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/rowReorder.cjs"),t=require("../logic/detailRow.cjs"),n=require("../logic/autoScrollGeometry.cjs"),r=require("../logic/slotDom.cjs");var i=14,a=12,o=`0.5`,s=`<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="8 6 12 2 16 6"/><polyline points="16 18 12 22 8 18"/><line x1="12" y1="2" x2="12" y2="22"/></svg>`,c=`<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>`,l=200,u=`cubic-bezier(0.2, 0.7, 0.3, 1)`,d=`data-ssg-row-dragging`,f=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,p=/translateY\((-?[\d.]+)px\)/,m=e=>{let n=[];return e.querySelectorAll(`.ssg-body-row[data-row-index]`).forEach(r=>{t.isInsideDetailCardOf(e,r)||n.push(r)}),n},h=()=>{let h=null,g=null,_=null,v={x:0,y:0},y=null,b=!1,x=null,S=null,C=null,w=null,T=null,E=null,D=()=>[h?.leftIndicatorRef.current??null,h?.centerIndicatorRef.current??null,h?.rightIndicatorRef.current??null],O=()=>{for(let e of D())e&&(e.style.display=`none`)},k=e=>{if(w)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),h?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`display:inline-flex`,`align-items:center`,`gap:7px`,`padding:7px 12px 7px 10px`,`border-radius:9px`,`border:1px solid var(--ssg-ghost-border)`,`background:var(--ssg-ghost-bg)`,`color:var(--ssg-ghost-text)`,`font-size:12px`,`font-weight:600`,`line-height:1`,`white-space:nowrap`,`max-width:280px`,`overflow:hidden`,`text-overflow:ellipsis`,`box-shadow:var(--ssg-ghost-shadow)`,`pointer-events:none`,`user-select:none`,`z-index:9999`,`will-change:transform`,`transform:translate(-9999px,-9999px)`].join(`;`),r.applySlotToElement(t,h?.ghostSlot);let n=document.createElement(`span`);n.style.cssText=`display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none`;let i=document.createElement(`span`);i.style.cssText=`overflow:hidden;text-overflow:ellipsis`,i.textContent=e,t.appendChild(n),t.appendChild(i),document.body.appendChild(t),w=t,T=n,E=null},A=e=>{let t=w;if(!t)return;t.style.transform=`translate(`+(v.x+i)+`px,`+(v.y+a)+`px)`;let n=e?`move`:`out`;if(E===n)return;E=n;let r=T;n===`out`?(t.style.opacity=o,r&&(r.innerHTML=c)):(t.style.opacity=`1`,r&&(r.innerHTML=s))},j=()=>{w&&w.parentNode&&w.parentNode.removeChild(w),w=null,T=null,E=null},M=(e,n)=>{let r=h?.scrollContainerRef.current??null;!r||e===null||r.querySelectorAll(`.ssg-body-row[data-row-index="${e}"]`).forEach(e=>{t.isInsideDetailCardOf(r,e)||(n?e.setAttribute(d,``):e.removeAttribute(d))})},N=(t,n)=>{if(h===null)return null;let{scrollContainerRef:r,bodyScrollRef:i,rowMetrics:a,headerHeight:o,verticalScaleFactor:s,windowBaseOffsetPx:c}=h,l=r.current,u=i.current;if(!l||!u)return null;let d=l.getBoundingClientRect();if(t<d.left||t>d.right||n<d.top||n>d.bottom)return null;let f=u.getBoundingClientRect(),p=e.resolveRowDropSlot(u.scrollTop+n-f.top-o-l.scrollTop*(1-s),a);return{slot:p,top:o+e.resolveRowDropSlotTop(p,a)-c}},P=()=>{let t=N(v.x,v.y);A(t);let n=g;if(!t||n===null||e.resolveMoveTargetIndex(n,t.slot)===null){_=null,O();return}_=t.slot;for(let e of D())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},F=()=>{if(g===null){S=null;return}let e=h?.scrollContainerRef.current??null;if(e&&(b||(!y||n.hasPointerLeftActivationRadius(y,v,6))&&(b=!0),b)){let t=e.getBoundingClientRect(),r=n.resolveScrollContentBox({rectLeft:t.left,rectTop:t.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight}),i=n.resolveAutoScrollAxisDirection(v.y,r.top,r.bottom,24),a=n.computeNextScrollPosition(e.scrollTop,i,18,e.scrollHeight-e.clientHeight);a!==e.scrollTop&&e.scrollTo({top:a,behavior:`auto`})}P(),S=requestAnimationFrame(F)},I=()=>{let e=h?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of m(e))t.set(n,n.getBoundingClientRect().top);return t},L=t=>{S!==null&&(cancelAnimationFrame(S),S=null),document.body.style.cursor=``,O(),j();let n=g,r=_;if(M(n,!1),g=null,_=null,y=null,!t||n===null||r===null||h===null)return;let i=e.resolveMoveTargetIndex(n,r);i!==null&&(C=f()?null:I(),h.commitRowMove(n,i))};return{update:e=>{h=e},onRowDragHandlePointerDown:(e,t)=>{if(h===null||!h.enabled||t.button!==0)return;t.stopPropagation(),t.preventDefault(),g=e,_=null,v={x:t.clientX,y:t.clientY},y={x:t.clientX,y:t.clientY},b=!1,document.body.style.cursor=`grabbing`,k(h.getRowDragLabel(e)),M(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let i=e=>{e.pointerId===r&&(v={x:e.clientX,y:e.clientY},P())},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,s),window.removeEventListener(`keydown`,c),x=null;try{n.releasePointerCapture(r)}catch{}};function o(e){e.pointerId===r&&(a(),L(!0))}function s(e){e.pointerId===r&&(a(),L(!1))}function c(e){e.key===`Escape`&&(a(),L(!1))}window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,s),window.addEventListener(`keydown`,c),x=a,P(),S=requestAnimationFrame(F)},applyReorderSettle:()=>{let e=C;if(C=null,!e)return;let t=h?.scrollContainerRef.current??null;if(!t)return;let n=[],r=new Map;if(e.forEach((e,t)=>{if(!t.isConnected)return;let i=e-t.getBoundingClientRect().top;if(Math.abs(i)<.5)return;let a=p.exec(t.style.transform);if(!a)return;let o=parseFloat(a[1]);r.set(t,o),t.style.transition=`none`,t.style.transform=`translateY(${o+i}px)`,t.style.willChange=`transform`,n.push(t)}),n.length!==0){t.getBoundingClientRect();for(let e of n)e.style.transition=`transform ${l}ms ${u}`,e.style.transform=`translateY(${r.get(e)??0}px)`;window.setTimeout(()=>{for(let e of n)e.style.transition=``,e.style.willChange=``},280)}},dispose:()=>{x?.(),x=null,S!==null&&(cancelAnimationFrame(S),S=null),document.body.style.cursor=``,j(),M(g,!1),g=null,_=null}}};exports.createRowDragController=h;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { RowMetrics } from '../logic/verticalGeometry';
|
|
2
|
+
import type { GridResolvedSlot } from '../model/gridTypes.unbound';
|
|
3
|
+
type ReadonlyRef<V> = {
|
|
4
|
+
readonly current: V;
|
|
5
|
+
};
|
|
6
|
+
export type RowDragArgs = {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
rowMetrics: RowMetrics;
|
|
9
|
+
headerHeight: number;
|
|
10
|
+
verticalScaleFactor: number;
|
|
11
|
+
windowBaseOffsetPx: number;
|
|
12
|
+
scrollContainerRef: ReadonlyRef<HTMLElement | null>;
|
|
13
|
+
bodyScrollRef: ReadonlyRef<HTMLElement | null>;
|
|
14
|
+
leftIndicatorRef: ReadonlyRef<HTMLElement | null>;
|
|
15
|
+
centerIndicatorRef: ReadonlyRef<HTMLElement | null>;
|
|
16
|
+
rightIndicatorRef: ReadonlyRef<HTMLElement | null>;
|
|
17
|
+
getRowDragLabel: (viewIndex: number) => string;
|
|
18
|
+
commitRowMove: (fromIndex: number, toIndex: number) => void;
|
|
19
|
+
ghostSlot?: GridResolvedSlot;
|
|
20
|
+
};
|
|
21
|
+
export type RowDragHandlePointerEvent = {
|
|
22
|
+
button: number;
|
|
23
|
+
pointerId: number;
|
|
24
|
+
clientX: number;
|
|
25
|
+
clientY: number;
|
|
26
|
+
currentTarget: {
|
|
27
|
+
setPointerCapture: (pointerId: number) => void;
|
|
28
|
+
releasePointerCapture: (pointerId: number) => void;
|
|
29
|
+
};
|
|
30
|
+
preventDefault: () => void;
|
|
31
|
+
stopPropagation: () => void;
|
|
32
|
+
};
|
|
33
|
+
export type RowDragController = {
|
|
34
|
+
update: (args: RowDragArgs) => void;
|
|
35
|
+
onRowDragHandlePointerDown: (viewIndex: number, event: RowDragHandlePointerEvent) => void;
|
|
36
|
+
applyReorderSettle: () => void;
|
|
37
|
+
dispose: () => void;
|
|
38
|
+
};
|
|
39
|
+
export declare const createRowDragController: () => RowDragController;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { resolveMoveTargetIndex as e, resolveRowDropSlot as t, resolveRowDropSlotTop as n } from "../logic/rowReorder.js";
|
|
2
|
+
import { isInsideDetailCardOf as r } from "../logic/detailRow.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/rowDragController.ts
|
|
6
|
+
var l = 14, u = 12, d = "0.5", f = "<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=\"8 6 12 2 16 6\"/><polyline points=\"16 18 12 22 8 18\"/><line x1=\"12\" y1=\"2\" x2=\"12\" y2=\"22\"/></svg>", p = "<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>", m = 200, h = "cubic-bezier(0.2, 0.7, 0.3, 1)", g = "data-ssg-row-dragging", _ = () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, v = /translateY\((-?[\d.]+)px\)/, y = (e) => {
|
|
7
|
+
let t = [];
|
|
8
|
+
return e.querySelectorAll(".ssg-body-row[data-row-index]").forEach((n) => {
|
|
9
|
+
r(e, n) || t.push(n);
|
|
10
|
+
}), t;
|
|
11
|
+
}, b = () => {
|
|
12
|
+
let b = null, x = null, S = null, C = {
|
|
13
|
+
x: 0,
|
|
14
|
+
y: 0
|
|
15
|
+
}, w = null, T = !1, E = null, D = null, O = null, k = null, A = null, j = null, M = () => [
|
|
16
|
+
b?.leftIndicatorRef.current ?? null,
|
|
17
|
+
b?.centerIndicatorRef.current ?? null,
|
|
18
|
+
b?.rightIndicatorRef.current ?? null
|
|
19
|
+
], N = () => {
|
|
20
|
+
for (let e of M()) e && (e.style.display = "none");
|
|
21
|
+
}, P = (e) => {
|
|
22
|
+
if (k) return;
|
|
23
|
+
let t = document.createElement("div");
|
|
24
|
+
t.setAttribute("data-grid-drag-ghost", ""), b?.scrollContainerRef.current?.closest(".ssg-theme-dark") != null && t.classList.add("ssg-theme-dark"), t.style.cssText = [
|
|
25
|
+
"position:fixed",
|
|
26
|
+
"top:0",
|
|
27
|
+
"left:0",
|
|
28
|
+
"display:inline-flex",
|
|
29
|
+
"align-items:center",
|
|
30
|
+
"gap:7px",
|
|
31
|
+
"padding:7px 12px 7px 10px",
|
|
32
|
+
"border-radius:9px",
|
|
33
|
+
"border:1px solid var(--ssg-ghost-border)",
|
|
34
|
+
"background:var(--ssg-ghost-bg)",
|
|
35
|
+
"color:var(--ssg-ghost-text)",
|
|
36
|
+
"font-size:12px",
|
|
37
|
+
"font-weight:600",
|
|
38
|
+
"line-height:1",
|
|
39
|
+
"white-space:nowrap",
|
|
40
|
+
"max-width:280px",
|
|
41
|
+
"overflow:hidden",
|
|
42
|
+
"text-overflow:ellipsis",
|
|
43
|
+
"box-shadow:var(--ssg-ghost-shadow)",
|
|
44
|
+
"pointer-events:none",
|
|
45
|
+
"user-select:none",
|
|
46
|
+
"z-index:9999",
|
|
47
|
+
"will-change:transform",
|
|
48
|
+
"transform:translate(-9999px,-9999px)"
|
|
49
|
+
].join(";"), c(t, b?.ghostSlot);
|
|
50
|
+
let n = document.createElement("span");
|
|
51
|
+
n.style.cssText = "display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none";
|
|
52
|
+
let r = document.createElement("span");
|
|
53
|
+
r.style.cssText = "overflow:hidden;text-overflow:ellipsis", r.textContent = e, t.appendChild(n), t.appendChild(r), document.body.appendChild(t), k = t, A = n, j = null;
|
|
54
|
+
}, F = (e) => {
|
|
55
|
+
let t = k;
|
|
56
|
+
if (!t) return;
|
|
57
|
+
t.style.transform = "translate(" + (C.x + l) + "px," + (C.y + u) + "px)";
|
|
58
|
+
let n = e ? "move" : "out";
|
|
59
|
+
if (j === n) return;
|
|
60
|
+
j = n;
|
|
61
|
+
let r = A;
|
|
62
|
+
n === "out" ? (t.style.opacity = d, r && (r.innerHTML = p)) : (t.style.opacity = "1", r && (r.innerHTML = f));
|
|
63
|
+
}, I = () => {
|
|
64
|
+
k && k.parentNode && k.parentNode.removeChild(k), k = null, A = null, j = null;
|
|
65
|
+
}, L = (e, t) => {
|
|
66
|
+
let n = b?.scrollContainerRef.current ?? null;
|
|
67
|
+
!n || e === null || n.querySelectorAll(`.ssg-body-row[data-row-index="${e}"]`).forEach((e) => {
|
|
68
|
+
r(n, e) || (t ? e.setAttribute(g, "") : e.removeAttribute(g));
|
|
69
|
+
});
|
|
70
|
+
}, R = (e, r) => {
|
|
71
|
+
if (b === null) return null;
|
|
72
|
+
let { scrollContainerRef: i, bodyScrollRef: a, rowMetrics: o, headerHeight: s, verticalScaleFactor: c, windowBaseOffsetPx: l } = b, u = i.current, d = a.current;
|
|
73
|
+
if (!u || !d) return null;
|
|
74
|
+
let f = u.getBoundingClientRect();
|
|
75
|
+
if (e < f.left || e > f.right || r < f.top || r > f.bottom) return null;
|
|
76
|
+
let p = d.getBoundingClientRect(), m = t(d.scrollTop + r - p.top - s - u.scrollTop * (1 - c), o);
|
|
77
|
+
return {
|
|
78
|
+
slot: m,
|
|
79
|
+
top: s + n(m, o) - l
|
|
80
|
+
};
|
|
81
|
+
}, z = () => {
|
|
82
|
+
let t = R(C.x, C.y);
|
|
83
|
+
F(t);
|
|
84
|
+
let n = x;
|
|
85
|
+
if (!t || n === null || e(n, t.slot) === null) {
|
|
86
|
+
S = null, N();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
S = t.slot;
|
|
90
|
+
for (let e of M()) e && (e.style.top = `${t.top}px`, e.style.display = "block");
|
|
91
|
+
}, B = () => {
|
|
92
|
+
if (x === null) {
|
|
93
|
+
D = null;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
let e = b?.scrollContainerRef.current ?? null;
|
|
97
|
+
if (e && (T || (!w || a(w, C, 6)) && (T = !0), T)) {
|
|
98
|
+
let t = e.getBoundingClientRect(), n = s({
|
|
99
|
+
rectLeft: t.left,
|
|
100
|
+
rectTop: t.top,
|
|
101
|
+
clientLeft: e.clientLeft,
|
|
102
|
+
clientTop: e.clientTop,
|
|
103
|
+
clientWidth: e.clientWidth,
|
|
104
|
+
clientHeight: e.clientHeight
|
|
105
|
+
}), r = o(C.y, n.top, n.bottom, 24), a = i(e.scrollTop, r, 18, e.scrollHeight - e.clientHeight);
|
|
106
|
+
a !== e.scrollTop && e.scrollTo({
|
|
107
|
+
top: a,
|
|
108
|
+
behavior: "auto"
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
z(), D = requestAnimationFrame(B);
|
|
112
|
+
}, V = () => {
|
|
113
|
+
let e = b?.scrollContainerRef.current ?? null;
|
|
114
|
+
if (!e) return null;
|
|
115
|
+
let t = /* @__PURE__ */ new Map();
|
|
116
|
+
for (let n of y(e)) t.set(n, n.getBoundingClientRect().top);
|
|
117
|
+
return t;
|
|
118
|
+
}, H = (t) => {
|
|
119
|
+
D !== null && (cancelAnimationFrame(D), D = null), document.body.style.cursor = "", N(), I();
|
|
120
|
+
let n = x, r = S;
|
|
121
|
+
if (L(n, !1), x = null, S = null, w = null, !t || n === null || r === null || b === null) return;
|
|
122
|
+
let i = e(n, r);
|
|
123
|
+
i !== null && (O = _() ? null : V(), b.commitRowMove(n, i));
|
|
124
|
+
};
|
|
125
|
+
return {
|
|
126
|
+
update: (e) => {
|
|
127
|
+
b = e;
|
|
128
|
+
},
|
|
129
|
+
onRowDragHandlePointerDown: (e, t) => {
|
|
130
|
+
if (b === null || !b.enabled || t.button !== 0) return;
|
|
131
|
+
t.stopPropagation(), t.preventDefault(), x = e, S = null, C = {
|
|
132
|
+
x: t.clientX,
|
|
133
|
+
y: t.clientY
|
|
134
|
+
}, w = {
|
|
135
|
+
x: t.clientX,
|
|
136
|
+
y: t.clientY
|
|
137
|
+
}, T = !1, document.body.style.cursor = "grabbing", P(b.getRowDragLabel(e)), L(e, !0);
|
|
138
|
+
let n = t.currentTarget, r = t.pointerId;
|
|
139
|
+
try {
|
|
140
|
+
n.setPointerCapture(r);
|
|
141
|
+
} catch {}
|
|
142
|
+
let i = (e) => {
|
|
143
|
+
e.pointerId === r && (C = {
|
|
144
|
+
x: e.clientX,
|
|
145
|
+
y: e.clientY
|
|
146
|
+
}, z());
|
|
147
|
+
}, a = () => {
|
|
148
|
+
window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", o), window.removeEventListener("pointercancel", s), window.removeEventListener("keydown", c), E = null;
|
|
149
|
+
try {
|
|
150
|
+
n.releasePointerCapture(r);
|
|
151
|
+
} catch {}
|
|
152
|
+
};
|
|
153
|
+
function o(e) {
|
|
154
|
+
e.pointerId === r && (a(), H(!0));
|
|
155
|
+
}
|
|
156
|
+
function s(e) {
|
|
157
|
+
e.pointerId === r && (a(), H(!1));
|
|
158
|
+
}
|
|
159
|
+
function c(e) {
|
|
160
|
+
e.key === "Escape" && (a(), H(!1));
|
|
161
|
+
}
|
|
162
|
+
window.addEventListener("pointermove", i), window.addEventListener("pointerup", o), window.addEventListener("pointercancel", s), window.addEventListener("keydown", c), E = a, z(), D = requestAnimationFrame(B);
|
|
163
|
+
},
|
|
164
|
+
applyReorderSettle: () => {
|
|
165
|
+
let e = O;
|
|
166
|
+
if (O = null, !e) return;
|
|
167
|
+
let t = b?.scrollContainerRef.current ?? null;
|
|
168
|
+
if (!t) return;
|
|
169
|
+
let n = [], r = /* @__PURE__ */ new Map();
|
|
170
|
+
if (e.forEach((e, t) => {
|
|
171
|
+
if (!t.isConnected) return;
|
|
172
|
+
let i = e - t.getBoundingClientRect().top;
|
|
173
|
+
if (Math.abs(i) < .5) return;
|
|
174
|
+
let a = v.exec(t.style.transform);
|
|
175
|
+
if (!a) return;
|
|
176
|
+
let o = parseFloat(a[1]);
|
|
177
|
+
r.set(t, o), t.style.transition = "none", t.style.transform = `translateY(${o + i}px)`, t.style.willChange = "transform", n.push(t);
|
|
178
|
+
}), n.length !== 0) {
|
|
179
|
+
t.getBoundingClientRect();
|
|
180
|
+
for (let e of n) e.style.transition = `transform ${m}ms ${h}`, e.style.transform = `translateY(${r.get(e) ?? 0}px)`;
|
|
181
|
+
window.setTimeout(() => {
|
|
182
|
+
for (let e of n) e.style.transition = "", e.style.willChange = "";
|
|
183
|
+
}, 280);
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
dispose: () => {
|
|
187
|
+
E?.(), E = null, D !== null && (cancelAnimationFrame(D), D = null), document.body.style.cursor = "", I(), L(x, !1), x = null, S = null;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
//#endregion
|
|
192
|
+
export { b as createRowDragController };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=()=>{let e=null,t=null,n=0,r=null,i=null,a=()=>{i=null;let t=r;r=null,t&&e?.onScroll?.(t)},o=o=>{e?.setViewState({scrollTop:o.scrollTop,viewportHeight:o.clientHeight,viewportWidth:o.clientWidth});let s=()=>{e?.setViewState({scrollTop:o.scrollTop});let t=n>0?`api`:`user`;t===`api`&&--n;let s=r;r={top:o.scrollTop,left:o.scrollLeft,source:s?.source===`user`?`user`:t},e?.onScroll&&i===null&&(i=requestAnimationFrame(a))};o.addEventListener(`scroll`,s,{passive:!0});let c=new ResizeObserver(()=>{e?.setViewState({viewportHeight:o.clientHeight,viewportWidth:o.clientWidth})});c.observe(o),t=()=>{o.removeEventListener(`scroll`,s),i!==null&&(cancelAnimationFrame(i),i=null),c.disconnect()}};return{update:n=>{if(e=n,t===null){let e=n.scrollContainerRef.current;e&&o(e)}},markApiScroll:()=>{n+=1},dispose:()=>{t?.(),t=null}}};exports.createScrollSyncController=e;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { GridScrollEventParams } from '../model/gridTypes.unbound';
|
|
2
|
+
import type { GridViewStatePatch } from '../model/gridStore';
|
|
3
|
+
type ReadonlyRef<V> = {
|
|
4
|
+
readonly current: V;
|
|
5
|
+
};
|
|
6
|
+
export type ScrollSyncArgs = {
|
|
7
|
+
scrollContainerRef: ReadonlyRef<HTMLElement | null>;
|
|
8
|
+
setViewState: (patch: GridViewStatePatch) => void;
|
|
9
|
+
onScroll: ((params: GridScrollEventParams) => void) | undefined;
|
|
10
|
+
};
|
|
11
|
+
export type ScrollSyncController = {
|
|
12
|
+
update: (args: ScrollSyncArgs) => void;
|
|
13
|
+
markApiScroll: () => void;
|
|
14
|
+
dispose: () => void;
|
|
15
|
+
};
|
|
16
|
+
export declare const createScrollSyncController: () => ScrollSyncController;
|
|
17
|
+
export {};
|