@affino/datagrid-orchestration 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +6 -0
- package/dist/src/createDataGridRuntime.d.ts +19 -0
- package/dist/src/createDataGridRuntime.d.ts.map +1 -0
- package/dist/src/createDataGridRuntime.js +33 -0
- package/dist/src/dataGridContextMenuContracts.d.ts +20 -0
- package/dist/src/dataGridContextMenuContracts.d.ts.map +1 -0
- package/dist/src/dataGridContextMenuContracts.js +1 -0
- package/dist/src/dataGridPointerContracts.d.ts +5 -0
- package/dist/src/dataGridPointerContracts.d.ts.map +1 -0
- package/dist/src/dataGridPointerContracts.js +1 -0
- package/dist/src/dataGridRangeMutationKernel.d.ts +27 -0
- package/dist/src/dataGridRangeMutationKernel.d.ts.map +1 -0
- package/dist/src/dataGridRangeMutationKernel.js +46 -0
- package/dist/src/dataGridWritableRef.d.ts +4 -0
- package/dist/src/dataGridWritableRef.d.ts.map +1 -0
- package/dist/src/dataGridWritableRef.js +1 -0
- package/dist/src/index.d.ts +77 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +76 -0
- package/dist/src/selectionOverlayTransform.d.ts +16 -0
- package/dist/src/selectionOverlayTransform.d.ts.map +1 -0
- package/dist/src/selectionOverlayTransform.js +21 -0
- package/dist/src/useDataGridA11yCellIds.d.ts +16 -0
- package/dist/src/useDataGridA11yCellIds.d.ts.map +1 -0
- package/dist/src/useDataGridA11yCellIds.js +26 -0
- package/dist/src/useDataGridAxisAutoScrollDelta.d.ts +10 -0
- package/dist/src/useDataGridAxisAutoScrollDelta.d.ts.map +1 -0
- package/dist/src/useDataGridAxisAutoScrollDelta.js +20 -0
- package/dist/src/useDataGridCellCoordNormalizer.d.ts +26 -0
- package/dist/src/useDataGridCellCoordNormalizer.d.ts.map +1 -0
- package/dist/src/useDataGridCellCoordNormalizer.js +29 -0
- package/dist/src/useDataGridCellDatasetResolver.d.ts +16 -0
- package/dist/src/useDataGridCellDatasetResolver.d.ts.map +1 -0
- package/dist/src/useDataGridCellDatasetResolver.js +23 -0
- package/dist/src/useDataGridCellNavigation.d.ts +23 -0
- package/dist/src/useDataGridCellNavigation.d.ts.map +1 -0
- package/dist/src/useDataGridCellNavigation.js +111 -0
- package/dist/src/useDataGridCellPointerDownRouter.d.ts +42 -0
- package/dist/src/useDataGridCellPointerDownRouter.d.ts.map +1 -0
- package/dist/src/useDataGridCellPointerDownRouter.js +48 -0
- package/dist/src/useDataGridCellPointerHoverRouter.d.ts +24 -0
- package/dist/src/useDataGridCellPointerHoverRouter.d.ts.map +1 -0
- package/dist/src/useDataGridCellPointerHoverRouter.js +25 -0
- package/dist/src/useDataGridCellRangeHelpers.d.ts +30 -0
- package/dist/src/useDataGridCellRangeHelpers.d.ts.map +1 -0
- package/dist/src/useDataGridCellRangeHelpers.js +89 -0
- package/dist/src/useDataGridCellVisibilityScroller.d.ts +41 -0
- package/dist/src/useDataGridCellVisibilityScroller.d.ts.map +1 -0
- package/dist/src/useDataGridCellVisibilityScroller.js +43 -0
- package/dist/src/useDataGridCellVisualStatePredicates.d.ts +40 -0
- package/dist/src/useDataGridCellVisualStatePredicates.d.ts.map +1 -0
- package/dist/src/useDataGridCellVisualStatePredicates.js +126 -0
- package/dist/src/useDataGridClearSelectionLifecycle.d.ts +27 -0
- package/dist/src/useDataGridClearSelectionLifecycle.d.ts.map +1 -0
- package/dist/src/useDataGridClearSelectionLifecycle.js +21 -0
- package/dist/src/useDataGridClipboardBridge.d.ts +31 -0
- package/dist/src/useDataGridClipboardBridge.d.ts.map +1 -0
- package/dist/src/useDataGridClipboardBridge.js +138 -0
- package/dist/src/useDataGridClipboardMutations.d.ts +47 -0
- package/dist/src/useDataGridClipboardMutations.d.ts.map +1 -0
- package/dist/src/useDataGridClipboardMutations.js +216 -0
- package/dist/src/useDataGridClipboardValuePolicy.d.ts +5 -0
- package/dist/src/useDataGridClipboardValuePolicy.d.ts.map +1 -0
- package/dist/src/useDataGridClipboardValuePolicy.js +14 -0
- package/dist/src/useDataGridColumnFilterOrchestration.d.ts +64 -0
- package/dist/src/useDataGridColumnFilterOrchestration.d.ts.map +1 -0
- package/dist/src/useDataGridColumnFilterOrchestration.js +359 -0
- package/dist/src/useDataGridColumnLayoutOrchestration.d.ts +59 -0
- package/dist/src/useDataGridColumnLayoutOrchestration.d.ts.map +1 -0
- package/dist/src/useDataGridColumnLayoutOrchestration.js +151 -0
- package/dist/src/useDataGridColumnUiPolicy.d.ts +25 -0
- package/dist/src/useDataGridColumnUiPolicy.d.ts.map +1 -0
- package/dist/src/useDataGridColumnUiPolicy.js +55 -0
- package/dist/src/useDataGridContextMenu.d.ts +30 -0
- package/dist/src/useDataGridContextMenu.d.ts.map +1 -0
- package/dist/src/useDataGridContextMenu.js +147 -0
- package/dist/src/useDataGridContextMenuActionRouter.d.ts +19 -0
- package/dist/src/useDataGridContextMenuActionRouter.d.ts.map +1 -0
- package/dist/src/useDataGridContextMenuActionRouter.js +29 -0
- package/dist/src/useDataGridContextMenuAnchor.d.ts +33 -0
- package/dist/src/useDataGridContextMenuAnchor.d.ts.map +1 -0
- package/dist/src/useDataGridContextMenuAnchor.js +60 -0
- package/dist/src/useDataGridCopyRangeHelpers.d.ts +20 -0
- package/dist/src/useDataGridCopyRangeHelpers.d.ts.map +1 -0
- package/dist/src/useDataGridCopyRangeHelpers.js +28 -0
- package/dist/src/useDataGridDragPointerSelection.d.ts +22 -0
- package/dist/src/useDataGridDragPointerSelection.d.ts.map +1 -0
- package/dist/src/useDataGridDragPointerSelection.js +23 -0
- package/dist/src/useDataGridDragSelectionLifecycle.d.ts +18 -0
- package/dist/src/useDataGridDragSelectionLifecycle.d.ts.map +1 -0
- package/dist/src/useDataGridDragSelectionLifecycle.js +11 -0
- package/dist/src/useDataGridEditableValuePolicy.d.ts +32 -0
- package/dist/src/useDataGridEditableValuePolicy.d.ts.map +1 -0
- package/dist/src/useDataGridEditableValuePolicy.js +95 -0
- package/dist/src/useDataGridEnumTrigger.d.ts +17 -0
- package/dist/src/useDataGridEnumTrigger.d.ts.map +1 -0
- package/dist/src/useDataGridEnumTrigger.js +28 -0
- package/dist/src/useDataGridFillHandleStart.d.ts +30 -0
- package/dist/src/useDataGridFillHandleStart.d.ts.map +1 -0
- package/dist/src/useDataGridFillHandleStart.js +27 -0
- package/dist/src/useDataGridFillSelectionLifecycle.d.ts +24 -0
- package/dist/src/useDataGridFillSelectionLifecycle.d.ts.map +1 -0
- package/dist/src/useDataGridFillSelectionLifecycle.js +15 -0
- package/dist/src/useDataGridGlobalMouseDownContextMenuCloser.d.ts +10 -0
- package/dist/src/useDataGridGlobalMouseDownContextMenuCloser.d.ts.map +1 -0
- package/dist/src/useDataGridGlobalMouseDownContextMenuCloser.js +17 -0
- package/dist/src/useDataGridGlobalPointerLifecycle.d.ts +40 -0
- package/dist/src/useDataGridGlobalPointerLifecycle.d.ts.map +1 -0
- package/dist/src/useDataGridGlobalPointerLifecycle.js +153 -0
- package/dist/src/useDataGridGroupBadge.d.ts +13 -0
- package/dist/src/useDataGridGroupBadge.d.ts.map +1 -0
- package/dist/src/useDataGridGroupBadge.js +19 -0
- package/dist/src/useDataGridGroupMetaOrchestration.d.ts +18 -0
- package/dist/src/useDataGridGroupMetaOrchestration.d.ts.map +1 -0
- package/dist/src/useDataGridGroupMetaOrchestration.js +43 -0
- package/dist/src/useDataGridGroupValueLabelResolver.d.ts +10 -0
- package/dist/src/useDataGridGroupValueLabelResolver.d.ts.map +1 -0
- package/dist/src/useDataGridGroupValueLabelResolver.js +15 -0
- package/dist/src/useDataGridGroupingSortOrchestration.d.ts +13 -0
- package/dist/src/useDataGridGroupingSortOrchestration.d.ts.map +1 -0
- package/dist/src/useDataGridGroupingSortOrchestration.js +22 -0
- package/dist/src/useDataGridHeaderContextActions.d.ts +15 -0
- package/dist/src/useDataGridHeaderContextActions.d.ts.map +1 -0
- package/dist/src/useDataGridHeaderContextActions.js +41 -0
- package/dist/src/useDataGridHeaderInteractionRouter.d.ts +12 -0
- package/dist/src/useDataGridHeaderInteractionRouter.d.ts.map +1 -0
- package/dist/src/useDataGridHeaderInteractionRouter.js +35 -0
- package/dist/src/useDataGridHeaderLayerOrchestration.d.ts +13 -0
- package/dist/src/useDataGridHeaderLayerOrchestration.d.ts.map +1 -0
- package/dist/src/useDataGridHeaderLayerOrchestration.js +18 -0
- package/dist/src/useDataGridHeaderResizeOrchestration.d.ts +43 -0
- package/dist/src/useDataGridHeaderResizeOrchestration.d.ts.map +1 -0
- package/dist/src/useDataGridHeaderResizeOrchestration.js +180 -0
- package/dist/src/useDataGridHeaderSortOrchestration.d.ts +20 -0
- package/dist/src/useDataGridHeaderSortOrchestration.d.ts.map +1 -0
- package/dist/src/useDataGridHeaderSortOrchestration.js +86 -0
- package/dist/src/useDataGridHistoryActionRunner.d.ts +15 -0
- package/dist/src/useDataGridHistoryActionRunner.d.ts.map +1 -0
- package/dist/src/useDataGridHistoryActionRunner.js +35 -0
- package/dist/src/useDataGridInlineEditOrchestration.d.ts +46 -0
- package/dist/src/useDataGridInlineEditOrchestration.d.ts.map +1 -0
- package/dist/src/useDataGridInlineEditOrchestration.js +116 -0
- package/dist/src/useDataGridInlineEditorFocus.d.ts +9 -0
- package/dist/src/useDataGridInlineEditorFocus.d.ts.map +1 -0
- package/dist/src/useDataGridInlineEditorFocus.js +37 -0
- package/dist/src/useDataGridInlineEditorKeyRouter.d.ts +12 -0
- package/dist/src/useDataGridInlineEditorKeyRouter.d.ts.map +1 -0
- package/dist/src/useDataGridInlineEditorKeyRouter.js +31 -0
- package/dist/src/useDataGridInlineEditorSchema.d.ts +11 -0
- package/dist/src/useDataGridInlineEditorSchema.d.ts.map +1 -0
- package/dist/src/useDataGridInlineEditorSchema.js +26 -0
- package/dist/src/useDataGridInlineEditorTargetNavigation.d.ts +30 -0
- package/dist/src/useDataGridInlineEditorTargetNavigation.d.ts.map +1 -0
- package/dist/src/useDataGridInlineEditorTargetNavigation.js +66 -0
- package/dist/src/useDataGridIntentHistory.d.ts +25 -0
- package/dist/src/useDataGridIntentHistory.d.ts.map +1 -0
- package/dist/src/useDataGridIntentHistory.js +109 -0
- package/dist/src/useDataGridKeyboardCommandRouter.d.ts +18 -0
- package/dist/src/useDataGridKeyboardCommandRouter.d.ts.map +1 -0
- package/dist/src/useDataGridKeyboardCommandRouter.js +81 -0
- package/dist/src/useDataGridMoveMutationPolicy.d.ts +12 -0
- package/dist/src/useDataGridMoveMutationPolicy.d.ts.map +1 -0
- package/dist/src/useDataGridMoveMutationPolicy.js +81 -0
- package/dist/src/useDataGridMutationSnapshot.d.ts +46 -0
- package/dist/src/useDataGridMutationSnapshot.d.ts.map +1 -0
- package/dist/src/useDataGridMutationSnapshot.js +57 -0
- package/dist/src/useDataGridNavigationPrimitives.d.ts +42 -0
- package/dist/src/useDataGridNavigationPrimitives.d.ts.map +1 -0
- package/dist/src/useDataGridNavigationPrimitives.js +105 -0
- package/dist/src/useDataGridPointerAutoScroll.d.ts +32 -0
- package/dist/src/useDataGridPointerAutoScroll.d.ts.map +1 -0
- package/dist/src/useDataGridPointerAutoScroll.js +85 -0
- package/dist/src/useDataGridPointerCellCoordResolver.d.ts +45 -0
- package/dist/src/useDataGridPointerCellCoordResolver.d.ts.map +1 -0
- package/dist/src/useDataGridPointerCellCoordResolver.js +107 -0
- package/dist/src/useDataGridPointerModifierPolicy.d.ts +5 -0
- package/dist/src/useDataGridPointerModifierPolicy.d.ts.map +1 -0
- package/dist/src/useDataGridPointerModifierPolicy.js +8 -0
- package/dist/src/useDataGridPointerPreviewRouter.d.ts +37 -0
- package/dist/src/useDataGridPointerPreviewRouter.d.ts.map +1 -0
- package/dist/src/useDataGridPointerPreviewRouter.js +55 -0
- package/dist/src/useDataGridQuickFilterActions.d.ts +10 -0
- package/dist/src/useDataGridQuickFilterActions.d.ts.map +1 -0
- package/dist/src/useDataGridQuickFilterActions.js +12 -0
- package/dist/src/useDataGridRangeMoveLifecycle.d.ts +15 -0
- package/dist/src/useDataGridRangeMoveLifecycle.d.ts.map +1 -0
- package/dist/src/useDataGridRangeMoveLifecycle.js +21 -0
- package/dist/src/useDataGridRangeMoveStart.d.ts +34 -0
- package/dist/src/useDataGridRangeMoveStart.d.ts.map +1 -0
- package/dist/src/useDataGridRangeMoveStart.js +23 -0
- package/dist/src/useDataGridRangeMutationEngine.d.ts +44 -0
- package/dist/src/useDataGridRangeMutationEngine.d.ts.map +1 -0
- package/dist/src/useDataGridRangeMutationEngine.js +210 -0
- package/dist/src/useDataGridRowSelectionInputHandlers.d.ts +10 -0
- package/dist/src/useDataGridRowSelectionInputHandlers.d.ts.map +1 -0
- package/dist/src/useDataGridRowSelectionInputHandlers.js +12 -0
- package/dist/src/useDataGridRowSelectionOrchestration.d.ts +7 -0
- package/dist/src/useDataGridRowSelectionOrchestration.d.ts.map +1 -0
- package/dist/src/useDataGridRowSelectionOrchestration.js +60 -0
- package/dist/src/useDataGridRowsProjection.d.ts +21 -0
- package/dist/src/useDataGridRowsProjection.d.ts.map +1 -0
- package/dist/src/useDataGridRowsProjection.js +69 -0
- package/dist/src/useDataGridRuntimeService.d.ts +33 -0
- package/dist/src/useDataGridRuntimeService.d.ts.map +1 -0
- package/dist/src/useDataGridRuntimeService.js +209 -0
- package/dist/src/useDataGridSelectionComparators.d.ts +16 -0
- package/dist/src/useDataGridSelectionComparators.d.ts.map +1 -0
- package/dist/src/useDataGridSelectionComparators.js +21 -0
- package/dist/src/useDataGridSelectionMoveHandle.d.ts +38 -0
- package/dist/src/useDataGridSelectionMoveHandle.d.ts.map +1 -0
- package/dist/src/useDataGridSelectionMoveHandle.js +49 -0
- package/dist/src/useDataGridSelectionOverlayOrchestration.d.ts +60 -0
- package/dist/src/useDataGridSelectionOverlayOrchestration.d.ts.map +1 -0
- package/dist/src/useDataGridSelectionOverlayOrchestration.js +137 -0
- package/dist/src/useDataGridTabTargetResolver.d.ts +17 -0
- package/dist/src/useDataGridTabTargetResolver.d.ts.map +1 -0
- package/dist/src/useDataGridTabTargetResolver.js +30 -0
- package/dist/src/useDataGridViewportBlurHandler.d.ts +16 -0
- package/dist/src/useDataGridViewportBlurHandler.d.ts.map +1 -0
- package/dist/src/useDataGridViewportBlurHandler.js +62 -0
- package/dist/src/useDataGridViewportContextMenuRouter.d.ts +31 -0
- package/dist/src/useDataGridViewportContextMenuRouter.d.ts.map +1 -0
- package/dist/src/useDataGridViewportContextMenuRouter.js +78 -0
- package/dist/src/useDataGridViewportMeasureScheduler.d.ts +22 -0
- package/dist/src/useDataGridViewportMeasureScheduler.d.ts.map +1 -0
- package/dist/src/useDataGridViewportMeasureScheduler.js +65 -0
- package/dist/src/useDataGridViewportScrollLifecycle.d.ts +16 -0
- package/dist/src/useDataGridViewportScrollLifecycle.d.ts.map +1 -0
- package/dist/src/useDataGridViewportScrollLifecycle.js +28 -0
- package/dist/src/useDataGridVirtualRangeMetrics.d.ts +32 -0
- package/dist/src/useDataGridVirtualRangeMetrics.d.ts.map +1 -0
- package/dist/src/useDataGridVirtualRangeMetrics.js +26 -0
- package/dist/src/useDataGridVisibleRowsSyncScheduler.d.ts +21 -0
- package/dist/src/useDataGridVisibleRowsSyncScheduler.d.ts.map +1 -0
- package/dist/src/useDataGridVisibleRowsSyncScheduler.js +70 -0
- package/dist/tsconfig.public.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
export function useDataGridCellVisualStatePredicates(options) {
|
|
2
|
+
const selectColumnKey = options.selectColumnKey ?? "select";
|
|
3
|
+
function resolveRowColumn(row, columnKey) {
|
|
4
|
+
if (columnKey === selectColumnKey) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
const columnIndex = options.resolveColumnIndex(columnKey);
|
|
8
|
+
if (columnIndex < 0) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
rowIndex: options.resolveRowIndex(row),
|
|
13
|
+
columnIndex,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function isCellInSelection(row, columnKey) {
|
|
17
|
+
const range = options.resolveSelectionRange();
|
|
18
|
+
if (!range) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const indexes = resolveRowColumn(row, columnKey);
|
|
22
|
+
if (!indexes) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return options.isCellWithinRange(indexes.rowIndex, indexes.columnIndex, range);
|
|
26
|
+
}
|
|
27
|
+
function isCellInCopiedRange(row, columnKey) {
|
|
28
|
+
const range = options.resolveCopiedRange();
|
|
29
|
+
if (!range) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const indexes = resolveRowColumn(row, columnKey);
|
|
33
|
+
if (!indexes) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return options.isCellWithinRange(indexes.rowIndex, indexes.columnIndex, range);
|
|
37
|
+
}
|
|
38
|
+
function isAnchorCell(row, columnKey) {
|
|
39
|
+
const anchor = options.resolveAnchorCoord();
|
|
40
|
+
if (!anchor) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const indexes = resolveRowColumn(row, columnKey);
|
|
44
|
+
if (!indexes) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return indexes.rowIndex === anchor.rowIndex && indexes.columnIndex === anchor.columnIndex;
|
|
48
|
+
}
|
|
49
|
+
function isActiveCell(row, columnKey) {
|
|
50
|
+
const active = options.resolveActiveCoord();
|
|
51
|
+
if (!active) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const indexes = resolveRowColumn(row, columnKey);
|
|
55
|
+
if (!indexes) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
return indexes.rowIndex === active.rowIndex && indexes.columnIndex === active.columnIndex;
|
|
59
|
+
}
|
|
60
|
+
function isRangeEndCell(row, columnKey) {
|
|
61
|
+
const range = options.resolveSelectionRange();
|
|
62
|
+
if (!range) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
const indexes = resolveRowColumn(row, columnKey);
|
|
66
|
+
if (!indexes) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
return indexes.rowIndex === range.endRow && indexes.columnIndex === range.endColumn;
|
|
70
|
+
}
|
|
71
|
+
function isCellInFillPreview(row, columnKey) {
|
|
72
|
+
const preview = options.resolveFillPreviewRange();
|
|
73
|
+
if (!options.isFillDragging() || !preview) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
const indexes = resolveRowColumn(row, columnKey);
|
|
77
|
+
if (!indexes) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (!options.isCellWithinRange(indexes.rowIndex, indexes.columnIndex, preview)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const base = options.resolveFillBaseRange();
|
|
84
|
+
if (!base) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
return !options.isCellWithinRange(indexes.rowIndex, indexes.columnIndex, base);
|
|
88
|
+
}
|
|
89
|
+
function isCellInMovePreview(row, columnKey) {
|
|
90
|
+
const preview = options.resolveMovePreviewRange();
|
|
91
|
+
if (!options.isRangeMoving() || !preview) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const indexes = resolveRowColumn(row, columnKey);
|
|
95
|
+
if (!indexes) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
if (!options.isCellWithinRange(indexes.rowIndex, indexes.columnIndex, preview)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
const base = options.resolveMoveBaseRange();
|
|
102
|
+
if (!base) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
return !options.isCellWithinRange(indexes.rowIndex, indexes.columnIndex, base);
|
|
106
|
+
}
|
|
107
|
+
function shouldShowFillHandle(row, columnKey) {
|
|
108
|
+
if (options.isFillDragging()) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
if (options.isInlineEditorOpen?.()) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return isRangeEndCell(row, columnKey);
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
isCellInSelection,
|
|
118
|
+
isCellInCopiedRange,
|
|
119
|
+
isAnchorCell,
|
|
120
|
+
isActiveCell,
|
|
121
|
+
isRangeEndCell,
|
|
122
|
+
isCellInFillPreview,
|
|
123
|
+
isCellInMovePreview,
|
|
124
|
+
shouldShowFillHandle,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface UseDataGridClearSelectionLifecycleOptions<TCoord, TRange> {
|
|
2
|
+
setCellAnchor: (coord: TCoord | null) => void;
|
|
3
|
+
setCellFocus: (coord: TCoord | null) => void;
|
|
4
|
+
setActiveCell: (coord: TCoord | null) => void;
|
|
5
|
+
setDragSelecting: (value: boolean) => void;
|
|
6
|
+
setFillDragging: (value: boolean) => void;
|
|
7
|
+
setDragPointer: (pointer: {
|
|
8
|
+
clientX: number;
|
|
9
|
+
clientY: number;
|
|
10
|
+
} | null) => void;
|
|
11
|
+
setFillPointer: (pointer: {
|
|
12
|
+
clientX: number;
|
|
13
|
+
clientY: number;
|
|
14
|
+
} | null) => void;
|
|
15
|
+
setFillBaseRange: (range: TRange | null) => void;
|
|
16
|
+
setFillPreviewRange: (range: TRange | null) => void;
|
|
17
|
+
clearLastDragCoord: () => void;
|
|
18
|
+
closeContextMenu: () => void;
|
|
19
|
+
stopRangeMove: (applyPreview: boolean) => void;
|
|
20
|
+
stopColumnResize: () => void;
|
|
21
|
+
stopAutoScrollFrameIfIdle: () => void;
|
|
22
|
+
}
|
|
23
|
+
export interface UseDataGridClearSelectionLifecycleResult {
|
|
24
|
+
clearCellSelection: () => void;
|
|
25
|
+
}
|
|
26
|
+
export declare function useDataGridClearSelectionLifecycle<TCoord, TRange>(options: UseDataGridClearSelectionLifecycleOptions<TCoord, TRange>): UseDataGridClearSelectionLifecycleResult;
|
|
27
|
+
//# sourceMappingURL=useDataGridClearSelectionLifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDataGridClearSelectionLifecycle.d.ts","sourceRoot":"","sources":["../../src/useDataGridClearSelectionLifecycle.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yCAAyC,CAAC,MAAM,EAAE,MAAM;IACvE,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IAC7C,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IAC5C,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IAC7C,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAC1C,eAAe,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACzC,cAAc,EAAE,CAAC,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,KAAK,IAAI,CAAA;IAC9E,cAAc,EAAE,CAAC,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,KAAK,IAAI,CAAA;IAC9E,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IAChD,mBAAmB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACnD,kBAAkB,EAAE,MAAM,IAAI,CAAA;IAC9B,gBAAgB,EAAE,MAAM,IAAI,CAAA;IAC5B,aAAa,EAAE,CAAC,YAAY,EAAE,OAAO,KAAK,IAAI,CAAA;IAC9C,gBAAgB,EAAE,MAAM,IAAI,CAAA;IAC5B,yBAAyB,EAAE,MAAM,IAAI,CAAA;CACtC;AAED,MAAM,WAAW,wCAAwC;IACvD,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAC/B;AAED,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,MAAM,EAC/D,OAAO,EAAE,yCAAyC,CAAC,MAAM,EAAE,MAAM,CAAC,GACjE,wCAAwC,CAqB1C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function useDataGridClearSelectionLifecycle(options) {
|
|
2
|
+
function clearCellSelection() {
|
|
3
|
+
options.setCellAnchor(null);
|
|
4
|
+
options.setCellFocus(null);
|
|
5
|
+
options.setActiveCell(null);
|
|
6
|
+
options.setDragSelecting(false);
|
|
7
|
+
options.setFillDragging(false);
|
|
8
|
+
options.setDragPointer(null);
|
|
9
|
+
options.setFillPointer(null);
|
|
10
|
+
options.setFillBaseRange(null);
|
|
11
|
+
options.setFillPreviewRange(null);
|
|
12
|
+
options.clearLastDragCoord();
|
|
13
|
+
options.closeContextMenu();
|
|
14
|
+
options.stopRangeMove(false);
|
|
15
|
+
options.stopColumnResize();
|
|
16
|
+
options.stopAutoScrollFrameIfIdle();
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
clearCellSelection,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { DataGridWritableRef } from "./dataGridWritableRef";
|
|
2
|
+
export interface DataGridClipboardRange {
|
|
3
|
+
startRow: number;
|
|
4
|
+
endRow: number;
|
|
5
|
+
startColumn: number;
|
|
6
|
+
endColumn: number;
|
|
7
|
+
}
|
|
8
|
+
export interface UseDataGridClipboardBridgeOptions<TRow, TRange extends DataGridClipboardRange = DataGridClipboardRange> {
|
|
9
|
+
copiedSelectionRange: DataGridWritableRef<TRange | null>;
|
|
10
|
+
lastCopiedPayload: DataGridWritableRef<string>;
|
|
11
|
+
resolveCopyRange: () => TRange | null;
|
|
12
|
+
getRowAtIndex: (rowIndex: number) => TRow | undefined;
|
|
13
|
+
getColumnKeyAtIndex: (columnIndex: number) => string | null;
|
|
14
|
+
getCellValue: (row: TRow, columnKey: string) => unknown;
|
|
15
|
+
setLastAction: (message: string) => void;
|
|
16
|
+
closeContextMenu: () => void;
|
|
17
|
+
copiedSelectionFlashMs?: number;
|
|
18
|
+
isColumnCopyable?: (columnKey: string) => boolean;
|
|
19
|
+
writeClipboardText?: (payload: string) => Promise<void>;
|
|
20
|
+
readClipboardText?: () => Promise<string>;
|
|
21
|
+
}
|
|
22
|
+
export interface UseDataGridClipboardBridgeResult<TRange extends DataGridClipboardRange = DataGridClipboardRange> {
|
|
23
|
+
copySelection: (trigger: "keyboard" | "context-menu") => Promise<boolean>;
|
|
24
|
+
readClipboardPayload: () => Promise<string>;
|
|
25
|
+
parseClipboardMatrix: (payload: string) => string[][];
|
|
26
|
+
clearCopiedSelectionFlash: () => void;
|
|
27
|
+
flashCopiedSelection: (range: TRange) => void;
|
|
28
|
+
dispose: () => void;
|
|
29
|
+
}
|
|
30
|
+
export declare function useDataGridClipboardBridge<TRow, TRange extends DataGridClipboardRange = DataGridClipboardRange>(options: UseDataGridClipboardBridgeOptions<TRow, TRange>): UseDataGridClipboardBridgeResult<TRange>;
|
|
31
|
+
//# sourceMappingURL=useDataGridClipboardBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDataGridClipboardBridge.d.ts","sourceRoot":"","sources":["../../src/useDataGridClipboardBridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAEhE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,iCAAiC,CAChD,IAAI,EACJ,MAAM,SAAS,sBAAsB,GAAG,s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B,CACxC,IAAI,EACJ,MAAM,SAAS,sBAAsB,GAAG,sBAAsB,EAE9D,OAAO,EAAE,iCAAiC,CAAC,IAAI,EAAE,MAAM,CAAC,GACvD,gCAAgC,CAAC,MAAM,CAAC,CA8I1C"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
const DEFAULT_FLASH_MS = 1200;
|
|
2
|
+
function normalizeClipboardValue(value) {
|
|
3
|
+
if (typeof value === "undefined" || value === null) {
|
|
4
|
+
return "";
|
|
5
|
+
}
|
|
6
|
+
return String(value);
|
|
7
|
+
}
|
|
8
|
+
export function useDataGridClipboardBridge(options) {
|
|
9
|
+
let copiedSelectionResetTimer = null;
|
|
10
|
+
const flashMs = Number.isFinite(options.copiedSelectionFlashMs)
|
|
11
|
+
? Math.max(0, Math.trunc(options.copiedSelectionFlashMs))
|
|
12
|
+
: DEFAULT_FLASH_MS;
|
|
13
|
+
const canCopyColumn = options.isColumnCopyable ?? (columnKey => columnKey !== "select");
|
|
14
|
+
function clearCopiedSelectionFlash() {
|
|
15
|
+
options.copiedSelectionRange.value = null;
|
|
16
|
+
if (copiedSelectionResetTimer !== null) {
|
|
17
|
+
clearTimeout(copiedSelectionResetTimer);
|
|
18
|
+
copiedSelectionResetTimer = null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function flashCopiedSelection(range) {
|
|
22
|
+
options.copiedSelectionRange.value = { ...range };
|
|
23
|
+
if (copiedSelectionResetTimer !== null) {
|
|
24
|
+
clearTimeout(copiedSelectionResetTimer);
|
|
25
|
+
}
|
|
26
|
+
if (flashMs === 0) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
copiedSelectionResetTimer = setTimeout(() => {
|
|
30
|
+
options.copiedSelectionRange.value = null;
|
|
31
|
+
copiedSelectionResetTimer = null;
|
|
32
|
+
}, flashMs);
|
|
33
|
+
}
|
|
34
|
+
function buildCopyPayload(range) {
|
|
35
|
+
const rows = [];
|
|
36
|
+
for (let rowIndex = range.startRow; rowIndex <= range.endRow; rowIndex += 1) {
|
|
37
|
+
const row = options.getRowAtIndex(rowIndex);
|
|
38
|
+
if (!row) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const cells = [];
|
|
42
|
+
for (let columnIndex = range.startColumn; columnIndex <= range.endColumn; columnIndex += 1) {
|
|
43
|
+
const columnKey = options.getColumnKeyAtIndex(columnIndex);
|
|
44
|
+
if (!columnKey || !canCopyColumn(columnKey)) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
cells.push(normalizeClipboardValue(options.getCellValue(row, columnKey)));
|
|
48
|
+
}
|
|
49
|
+
rows.push(cells.join("\t"));
|
|
50
|
+
}
|
|
51
|
+
return rows.join("\n");
|
|
52
|
+
}
|
|
53
|
+
async function writeClipboardPayload(payload) {
|
|
54
|
+
if (options.writeClipboardText) {
|
|
55
|
+
await options.writeClipboardText(payload);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (typeof navigator !== "undefined" &&
|
|
59
|
+
navigator.clipboard &&
|
|
60
|
+
typeof navigator.clipboard.writeText === "function") {
|
|
61
|
+
await navigator.clipboard.writeText(payload);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
throw new Error("Clipboard API unavailable");
|
|
65
|
+
}
|
|
66
|
+
async function copySelection(trigger) {
|
|
67
|
+
const range = options.resolveCopyRange();
|
|
68
|
+
if (!range) {
|
|
69
|
+
options.setLastAction("Copy skipped: no active selection");
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const payload = buildCopyPayload(range);
|
|
73
|
+
if (!payload) {
|
|
74
|
+
options.setLastAction("Copy skipped: empty selection");
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
await writeClipboardPayload(payload);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// Clipboard permissions can be unavailable in some environments.
|
|
82
|
+
}
|
|
83
|
+
options.lastCopiedPayload.value = payload;
|
|
84
|
+
flashCopiedSelection(range);
|
|
85
|
+
options.closeContextMenu();
|
|
86
|
+
const rows = range.endRow - range.startRow + 1;
|
|
87
|
+
const columns = range.endColumn - range.startColumn + 1;
|
|
88
|
+
options.setLastAction(`Copied ${rows}x${columns} cells (${trigger})`);
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
async function readClipboardPayload() {
|
|
92
|
+
if (options.readClipboardText) {
|
|
93
|
+
try {
|
|
94
|
+
const payload = await options.readClipboardText();
|
|
95
|
+
if (typeof payload === "string") {
|
|
96
|
+
return payload;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
// Fallback to in-memory payload.
|
|
101
|
+
}
|
|
102
|
+
return options.lastCopiedPayload.value;
|
|
103
|
+
}
|
|
104
|
+
if (typeof navigator !== "undefined" &&
|
|
105
|
+
navigator.clipboard &&
|
|
106
|
+
typeof navigator.clipboard.readText === "function") {
|
|
107
|
+
try {
|
|
108
|
+
return await navigator.clipboard.readText();
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
// Fallback to in-memory payload.
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return options.lastCopiedPayload.value;
|
|
115
|
+
}
|
|
116
|
+
function parseClipboardMatrix(payload) {
|
|
117
|
+
const normalized = payload.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
118
|
+
const rows = normalized
|
|
119
|
+
.split("\n")
|
|
120
|
+
.filter(row => row.length > 0)
|
|
121
|
+
.map(row => row.split("\t"));
|
|
122
|
+
return rows.length ? rows : [[]];
|
|
123
|
+
}
|
|
124
|
+
function dispose() {
|
|
125
|
+
if (copiedSelectionResetTimer !== null) {
|
|
126
|
+
clearTimeout(copiedSelectionResetTimer);
|
|
127
|
+
copiedSelectionResetTimer = null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
copySelection,
|
|
132
|
+
readClipboardPayload,
|
|
133
|
+
parseClipboardMatrix,
|
|
134
|
+
clearCopiedSelectionFlash,
|
|
135
|
+
flashCopiedSelection,
|
|
136
|
+
dispose,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { DataGridClipboardRange } from "./useDataGridClipboardBridge";
|
|
2
|
+
import type { DataGridWritableRef } from "./dataGridWritableRef";
|
|
3
|
+
export interface DataGridClipboardCoord {
|
|
4
|
+
rowIndex: number;
|
|
5
|
+
columnIndex: number;
|
|
6
|
+
}
|
|
7
|
+
export interface DataGridClipboardMutationResult<TRange extends DataGridClipboardRange = DataGridClipboardRange> {
|
|
8
|
+
applied: number;
|
|
9
|
+
blocked: number;
|
|
10
|
+
range: TRange;
|
|
11
|
+
}
|
|
12
|
+
export interface UseDataGridClipboardMutationsOptions<TRow, TColumnKey extends string, TRange extends DataGridClipboardRange = DataGridClipboardRange, TCoord extends DataGridClipboardCoord = DataGridClipboardCoord, TSnapshot = unknown> {
|
|
13
|
+
sourceRows: DataGridWritableRef<readonly TRow[]>;
|
|
14
|
+
setSourceRows: (rows: readonly TRow[]) => void;
|
|
15
|
+
cloneRow: (row: TRow) => TRow;
|
|
16
|
+
resolveRowId: (row: TRow) => string;
|
|
17
|
+
resolveCopyRange: () => TRange | null;
|
|
18
|
+
resolveCurrentCellCoord: () => TCoord | null;
|
|
19
|
+
normalizeCellCoord: (coord: TCoord) => TCoord | null;
|
|
20
|
+
normalizeSelectionRange: (range: TRange) => TRange | null;
|
|
21
|
+
resolveRowAtViewIndex: (rowIndex: number) => TRow | undefined;
|
|
22
|
+
resolveColumnKeyAtIndex: (columnIndex: number) => TColumnKey | null;
|
|
23
|
+
isEditableColumn: (columnKey: TColumnKey) => boolean;
|
|
24
|
+
canApplyPastedValue: (columnKey: TColumnKey, value: string) => boolean;
|
|
25
|
+
applyEditedValue: (row: TRow, columnKey: TColumnKey, value: string) => void;
|
|
26
|
+
clearValueForCut: (row: TRow, columnKey: TColumnKey) => boolean;
|
|
27
|
+
finalizeMutableRows?: (rowsById: Map<string, TRow>) => void;
|
|
28
|
+
applySelectionRange: (range: TRange) => void;
|
|
29
|
+
closeContextMenu: () => void;
|
|
30
|
+
setLastAction: (message: string) => void;
|
|
31
|
+
readClipboardPayload: () => Promise<string>;
|
|
32
|
+
parseClipboardMatrix: (payload: string) => string[][];
|
|
33
|
+
copySelection: (trigger: "keyboard" | "context-menu") => Promise<boolean>;
|
|
34
|
+
captureBeforeSnapshot?: () => TSnapshot;
|
|
35
|
+
recordIntentTransaction?: (descriptor: {
|
|
36
|
+
intent: "paste" | "clear" | "cut";
|
|
37
|
+
label: string;
|
|
38
|
+
affectedRange: TRange;
|
|
39
|
+
}, beforeSnapshot: TSnapshot) => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export interface UseDataGridClipboardMutationsResult<TRange extends DataGridClipboardRange = DataGridClipboardRange> {
|
|
42
|
+
pasteSelection: (trigger: "keyboard" | "context-menu") => Promise<boolean>;
|
|
43
|
+
clearCurrentSelection: (trigger: "keyboard" | "context-menu") => Promise<boolean>;
|
|
44
|
+
cutSelection: (trigger: "keyboard" | "context-menu") => Promise<boolean>;
|
|
45
|
+
}
|
|
46
|
+
export declare function useDataGridClipboardMutations<TRow, TColumnKey extends string, TRange extends DataGridClipboardRange = DataGridClipboardRange, TCoord extends DataGridClipboardCoord = DataGridClipboardCoord, TSnapshot = unknown>(options: UseDataGridClipboardMutationsOptions<TRow, TColumnKey, TRange, TCoord, TSnapshot>): UseDataGridClipboardMutationsResult<TRange>;
|
|
47
|
+
//# sourceMappingURL=useDataGridClipboardMutations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDataGridClipboardMutations.d.ts","sourceRoot":"","sources":["../../src/useDataGridClipboardMutations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,C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,YAAY,EAAE,CAAC,OAAO,EAAE,UAAU,GAAG,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CACzE;AAED,wBAAgB,6BAA6B,CAC3C,IAAI,EACJ,UAAU,SAAS,MAAM,EACzB,MAAM,SAAS,sBAAsB,GAAG,sBAAsB,EAC9D,MAAM,SAAS,sBAAsB,GAAG,sBAAsB,EAC9D,SAAS,GAAG,OAAO,EAEnB,OAAO,EAAE,oCAAoC,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,GACzF,mCAAmC,CAAC,MAAM,CAAC,CA0P7C"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { createDataGridMutableRowStore, forEachDataGridRangeCell, } from "./dataGridRangeMutationKernel";
|
|
2
|
+
export function useDataGridClipboardMutations(options) {
|
|
3
|
+
function resolvePasteStartCoord() {
|
|
4
|
+
const selected = options.resolveCopyRange();
|
|
5
|
+
if (selected) {
|
|
6
|
+
return options.normalizeCellCoord({
|
|
7
|
+
rowIndex: selected.startRow,
|
|
8
|
+
columnIndex: selected.startColumn,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
const current = options.resolveCurrentCellCoord();
|
|
12
|
+
if (!current) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return options.normalizeCellCoord(current);
|
|
16
|
+
}
|
|
17
|
+
function resolvePasteTargets(matrix, start) {
|
|
18
|
+
const rowCount = Math.max(1, matrix.length);
|
|
19
|
+
const columnCount = Math.max(1, matrix[0]?.length ?? 1);
|
|
20
|
+
const selected = options.resolveCopyRange();
|
|
21
|
+
if (selected &&
|
|
22
|
+
rowCount === 1 &&
|
|
23
|
+
columnCount === 1 &&
|
|
24
|
+
(selected.endRow !== selected.startRow || selected.endColumn !== selected.startColumn)) {
|
|
25
|
+
return selected;
|
|
26
|
+
}
|
|
27
|
+
return options.normalizeSelectionRange({
|
|
28
|
+
startRow: start.rowIndex,
|
|
29
|
+
endRow: start.rowIndex + rowCount - 1,
|
|
30
|
+
startColumn: start.columnIndex,
|
|
31
|
+
endColumn: start.columnIndex + columnCount - 1,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async function maybeRecordTransaction(descriptor, beforeSnapshot) {
|
|
35
|
+
if (!options.recordIntentTransaction || beforeSnapshot === null) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
await options.recordIntentTransaction(descriptor, beforeSnapshot);
|
|
39
|
+
}
|
|
40
|
+
async function pasteSelection(trigger) {
|
|
41
|
+
const start = resolvePasteStartCoord();
|
|
42
|
+
if (!start) {
|
|
43
|
+
options.closeContextMenu();
|
|
44
|
+
options.setLastAction("Paste skipped: no active target");
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
const payload = await options.readClipboardPayload();
|
|
48
|
+
if (!payload.trim()) {
|
|
49
|
+
options.closeContextMenu();
|
|
50
|
+
options.setLastAction("Paste skipped: clipboard empty");
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
const matrix = options.parseClipboardMatrix(payload);
|
|
54
|
+
const targetRange = resolvePasteTargets(matrix, start);
|
|
55
|
+
if (!targetRange) {
|
|
56
|
+
options.closeContextMenu();
|
|
57
|
+
options.setLastAction("Paste skipped: target out of range");
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const beforeSnapshot = options.captureBeforeSnapshot ? options.captureBeforeSnapshot() : null;
|
|
61
|
+
const rowStore = createDataGridMutableRowStore({
|
|
62
|
+
rows: options.sourceRows.value,
|
|
63
|
+
resolveRowId: options.resolveRowId,
|
|
64
|
+
cloneRow: options.cloneRow,
|
|
65
|
+
});
|
|
66
|
+
const { mutableById, getMutableRow } = rowStore;
|
|
67
|
+
let applied = 0;
|
|
68
|
+
let blocked = 0;
|
|
69
|
+
const matrixHeight = matrix.length;
|
|
70
|
+
const matrixWidth = Math.max(1, matrix[0]?.length ?? 1);
|
|
71
|
+
forEachDataGridRangeCell(targetRange, ({ rowIndex, columnIndex, rowOffset, columnOffset }) => {
|
|
72
|
+
const targetRow = options.resolveRowAtViewIndex(rowIndex);
|
|
73
|
+
if (!targetRow) {
|
|
74
|
+
blocked += 1;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const targetColumnKey = options.resolveColumnKeyAtIndex(columnIndex);
|
|
78
|
+
if (!targetColumnKey || !options.isEditableColumn(targetColumnKey)) {
|
|
79
|
+
blocked += 1;
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const sourceValue = matrix[rowOffset % matrixHeight]?.[columnOffset % matrixWidth] ?? "";
|
|
83
|
+
if (!options.canApplyPastedValue(targetColumnKey, sourceValue)) {
|
|
84
|
+
blocked += 1;
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const mutable = getMutableRow(options.resolveRowId(targetRow));
|
|
88
|
+
if (!mutable) {
|
|
89
|
+
blocked += 1;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
options.applyEditedValue(mutable, targetColumnKey, sourceValue);
|
|
93
|
+
applied += 1;
|
|
94
|
+
});
|
|
95
|
+
if (applied === 0) {
|
|
96
|
+
options.closeContextMenu();
|
|
97
|
+
options.setLastAction(`Paste blocked (${blocked} cells)`);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
options.finalizeMutableRows?.(mutableById);
|
|
101
|
+
options.setSourceRows(rowStore.commitRows(options.sourceRows.value));
|
|
102
|
+
options.applySelectionRange(targetRange);
|
|
103
|
+
await maybeRecordTransaction({
|
|
104
|
+
intent: "paste",
|
|
105
|
+
label: blocked > 0
|
|
106
|
+
? `Paste ${applied} cells (blocked ${blocked})`
|
|
107
|
+
: `Paste ${applied} cells`,
|
|
108
|
+
affectedRange: targetRange,
|
|
109
|
+
}, beforeSnapshot);
|
|
110
|
+
options.closeContextMenu();
|
|
111
|
+
options.setLastAction(blocked > 0
|
|
112
|
+
? `Pasted ${applied} cells (${trigger}), blocked ${blocked}`
|
|
113
|
+
: `Pasted ${applied} cells (${trigger})`);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
function clearSelectionValues(range) {
|
|
117
|
+
const rowStore = createDataGridMutableRowStore({
|
|
118
|
+
rows: options.sourceRows.value,
|
|
119
|
+
resolveRowId: options.resolveRowId,
|
|
120
|
+
cloneRow: options.cloneRow,
|
|
121
|
+
});
|
|
122
|
+
const { mutableById, getMutableRow } = rowStore;
|
|
123
|
+
let applied = 0;
|
|
124
|
+
let blocked = 0;
|
|
125
|
+
forEachDataGridRangeCell(range, ({ rowIndex, columnIndex }) => {
|
|
126
|
+
const targetRow = options.resolveRowAtViewIndex(rowIndex);
|
|
127
|
+
if (!targetRow) {
|
|
128
|
+
blocked += 1;
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const targetColumnKey = options.resolveColumnKeyAtIndex(columnIndex);
|
|
132
|
+
if (!targetColumnKey || !options.isEditableColumn(targetColumnKey)) {
|
|
133
|
+
blocked += 1;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const mutable = getMutableRow(options.resolveRowId(targetRow));
|
|
137
|
+
if (!mutable) {
|
|
138
|
+
blocked += 1;
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const didClear = options.clearValueForCut(mutable, targetColumnKey);
|
|
142
|
+
if (!didClear) {
|
|
143
|
+
blocked += 1;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
applied += 1;
|
|
147
|
+
});
|
|
148
|
+
if (applied > 0) {
|
|
149
|
+
options.finalizeMutableRows?.(mutableById);
|
|
150
|
+
options.setSourceRows(rowStore.commitRows(options.sourceRows.value));
|
|
151
|
+
options.applySelectionRange(range);
|
|
152
|
+
}
|
|
153
|
+
return { applied, blocked, range };
|
|
154
|
+
}
|
|
155
|
+
async function clearCurrentSelection(trigger) {
|
|
156
|
+
const range = options.resolveCopyRange();
|
|
157
|
+
if (!range) {
|
|
158
|
+
options.closeContextMenu();
|
|
159
|
+
options.setLastAction("Clear skipped: no active selection");
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
const beforeSnapshot = options.captureBeforeSnapshot ? options.captureBeforeSnapshot() : null;
|
|
163
|
+
const result = clearSelectionValues(range);
|
|
164
|
+
options.closeContextMenu();
|
|
165
|
+
if (result.applied === 0) {
|
|
166
|
+
options.setLastAction(`Clear blocked (${result.blocked} cells)`);
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
await maybeRecordTransaction({
|
|
170
|
+
intent: "clear",
|
|
171
|
+
label: result.blocked > 0
|
|
172
|
+
? `Clear ${result.applied} cells (blocked ${result.blocked})`
|
|
173
|
+
: `Clear ${result.applied} cells`,
|
|
174
|
+
affectedRange: range,
|
|
175
|
+
}, beforeSnapshot);
|
|
176
|
+
options.setLastAction(result.blocked > 0
|
|
177
|
+
? `Cleared ${result.applied} cells (${trigger}), blocked ${result.blocked}`
|
|
178
|
+
: `Cleared ${result.applied} cells (${trigger})`);
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
async function cutSelection(trigger) {
|
|
182
|
+
const range = options.resolveCopyRange();
|
|
183
|
+
if (!range) {
|
|
184
|
+
options.closeContextMenu();
|
|
185
|
+
options.setLastAction("Cut skipped: no active selection");
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
const copied = await options.copySelection(trigger);
|
|
189
|
+
if (!copied) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
const beforeSnapshot = options.captureBeforeSnapshot ? options.captureBeforeSnapshot() : null;
|
|
193
|
+
const result = clearSelectionValues(range);
|
|
194
|
+
options.closeContextMenu();
|
|
195
|
+
if (result.applied === 0) {
|
|
196
|
+
options.setLastAction(`Cut blocked (${result.blocked} cells)`);
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
await maybeRecordTransaction({
|
|
200
|
+
intent: "cut",
|
|
201
|
+
label: result.blocked > 0
|
|
202
|
+
? `Cut ${result.applied} cells (blocked ${result.blocked})`
|
|
203
|
+
: `Cut ${result.applied} cells`,
|
|
204
|
+
affectedRange: range,
|
|
205
|
+
}, beforeSnapshot);
|
|
206
|
+
options.setLastAction(result.blocked > 0
|
|
207
|
+
? `Cut ${result.applied} cells (${trigger}), blocked ${result.blocked}`
|
|
208
|
+
: `Cut ${result.applied} cells (${trigger})`);
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
pasteSelection,
|
|
213
|
+
clearCurrentSelection,
|
|
214
|
+
cutSelection,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export interface UseDataGridClipboardValuePolicyResult {
|
|
2
|
+
normalizeClipboardValue: (value: unknown) => string;
|
|
3
|
+
}
|
|
4
|
+
export declare function useDataGridClipboardValuePolicy(): UseDataGridClipboardValuePolicyResult;
|
|
5
|
+
//# sourceMappingURL=useDataGridClipboardValuePolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDataGridClipboardValuePolicy.d.ts","sourceRoot":"","sources":["../../src/useDataGridClipboardValuePolicy.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qCAAqC;IACpD,uBAAuB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAA;CACpD;AAED,wBAAgB,+BAA+B,IAAI,qCAAqC,CAcvF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function useDataGridClipboardValuePolicy() {
|
|
2
|
+
function normalizeClipboardValue(value) {
|
|
3
|
+
if (typeof value === "undefined" || value === null) {
|
|
4
|
+
return "";
|
|
5
|
+
}
|
|
6
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
7
|
+
return String(value);
|
|
8
|
+
}
|
|
9
|
+
return String(value);
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
normalizeClipboardValue,
|
|
13
|
+
};
|
|
14
|
+
}
|