@affino/datagrid-vue-app 0.1.1 → 0.1.2

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.
Files changed (110) hide show
  1. package/dist/DataGrid.d.ts +9 -9
  2. package/dist/DataGridTableStage.vue.d.ts +112 -0
  3. package/dist/chunks/useDataGridAppRowModel-CcTL-h8L.js +11251 -0
  4. package/dist/gantt/DataGridGanttStage.vue.d.ts +21 -0
  5. package/dist/host/DataGridDefaultRenderer.d.ts +3 -3
  6. package/dist/host/DataGridRuntimeHost.d.ts +1 -1
  7. package/dist/index.js +1125 -4
  8. package/dist/internal.js +37 -14
  9. package/dist/overlays/DataGridAdvancedFilterPopover.vue.d.ts +62 -0
  10. package/dist/overlays/DataGridAggregationsPopover.vue.d.ts +62 -0
  11. package/dist/overlays/DataGridCellComboboxEditor.vue.d.ts +29 -0
  12. package/dist/overlays/DataGridColumnLayoutPopover.vue.d.ts +51 -0
  13. package/dist/overlays/DataGridColumnMenu.vue.d.ts +65 -0
  14. package/dist/overlays/DataGridFilterableCombobox.vue.d.ts +76 -0
  15. package/dist/stage/DataGridTableStage.vue.d.ts +115 -0
  16. package/dist/stage/DataGridTableStageCenterPane.vue.d.ts +121 -0
  17. package/dist/stage/DataGridTableStageFillActionMenu.vue.d.ts +30 -0
  18. package/dist/stage/DataGridTableStageHeader.vue.d.ts +84 -0
  19. package/dist/stage/DataGridTableStageOverlayLayer.vue.d.ts +34 -0
  20. package/dist/stage/DataGridTableStagePinnedPane.vue.d.ts +43 -0
  21. package/package.json +8 -5
  22. package/dist/DataGrid.js +0 -565
  23. package/dist/DataGridDefaultRenderer.js +0 -2
  24. package/dist/DataGridModuleHost.js +0 -2
  25. package/dist/DataGridRuntimeHost.js +0 -1
  26. package/dist/config/dataGridAdvancedFilter.js +0 -21
  27. package/dist/config/dataGridAggregations.js +0 -21
  28. package/dist/config/dataGridColumnLayout.js +0 -21
  29. package/dist/config/dataGridFormulaOptions.js +0 -137
  30. package/dist/config/dataGridPublicProps.js +0 -58
  31. package/dist/config/dataGridSavedView.js +0 -73
  32. package/dist/config/dataGridVirtualization.js +0 -32
  33. package/dist/dataGridAdvancedFilter.js +0 -1
  34. package/dist/dataGridAggregations.js +0 -1
  35. package/dist/dataGridAppContext.js +0 -1
  36. package/dist/dataGridCellComboboxState.d.ts +0 -10
  37. package/dist/dataGridCellComboboxState.js +0 -67
  38. package/dist/dataGridColumnLayout.js +0 -1
  39. package/dist/dataGridColumnMenu.d.ts +0 -9
  40. package/dist/dataGridColumnMenu.js +0 -21
  41. package/dist/dataGridEditability.js +0 -1
  42. package/dist/dataGridFilterableCombobox.js +0 -1
  43. package/dist/dataGridFormulaOptions.js +0 -1
  44. package/dist/dataGridGantt.d.ts +0 -3
  45. package/dist/dataGridGantt.js +0 -1
  46. package/dist/dataGridGanttDependencySelection.d.ts +0 -7
  47. package/dist/dataGridGanttDependencySelection.js +0 -46
  48. package/dist/dataGridGanttLabel.d.ts +0 -2
  49. package/dist/dataGridGanttLabel.js +0 -30
  50. package/dist/dataGridGanttSplit.d.ts +0 -20
  51. package/dist/dataGridGanttSplit.js +0 -31
  52. package/dist/dataGridGanttWheel.d.ts +0 -10
  53. package/dist/dataGridGanttWheel.js +0 -30
  54. package/dist/dataGridOverlayThemeVars.d.ts +0 -1
  55. package/dist/dataGridOverlayThemeVars.js +0 -32
  56. package/dist/dataGridPublicProps.js +0 -1
  57. package/dist/dataGridTableStage.types.js +0 -1
  58. package/dist/dataGridTableStageBody.types.js +0 -1
  59. package/dist/dataGridTableStageContext.js +0 -1
  60. package/dist/dataGridTheme.js +0 -1
  61. package/dist/dataGridVirtualization.js +0 -1
  62. package/dist/ensureDataGridAppStyles.js +0 -1
  63. package/dist/gantt/dataGridGantt.js +0 -1
  64. package/dist/gantt/dataGridGanttDependencySelection.js +0 -46
  65. package/dist/gantt/dataGridGanttLabel.js +0 -30
  66. package/dist/gantt/dataGridGanttSplit.js +0 -31
  67. package/dist/gantt/dataGridGanttWheel.js +0 -30
  68. package/dist/host/DataGridDefaultRenderer.js +0 -1847
  69. package/dist/host/DataGridModuleHost.js +0 -23
  70. package/dist/host/DataGridRuntimeHost.js +0 -174
  71. package/dist/overlays/dataGridCellComboboxState.js +0 -67
  72. package/dist/overlays/dataGridColumnMenu.js +0 -190
  73. package/dist/overlays/dataGridContextMenu.js +0 -218
  74. package/dist/overlays/dataGridFilterableCombobox.js +0 -74
  75. package/dist/overlays/dataGridOverlayThemeVars.js +0 -32
  76. package/dist/stage/dataGridTableStage.types.js +0 -1
  77. package/dist/stage/dataGridTableStageBody.types.js +0 -1
  78. package/dist/stage/dataGridTableStageContext.js +0 -88
  79. package/dist/stage/useDataGridTableStageBindings.js +0 -162
  80. package/dist/stage/useDataGridTableStageCellIo.js +0 -62
  81. package/dist/stage/useDataGridTableStageColumns.js +0 -124
  82. package/dist/stage/useDataGridTableStageFillAction.js +0 -28
  83. package/dist/stage/useDataGridTableStageHistory.js +0 -46
  84. package/dist/stage/useDataGridTableStageRowSelection.js +0 -107
  85. package/dist/stage/useDataGridTableStageRuntime.js +0 -526
  86. package/dist/stage/useDataGridTableStageScrollSync.js +0 -49
  87. package/dist/stage/useDataGridTableStageViewportKeyboard.js +0 -58
  88. package/dist/stage/useDataGridTableStageVisualSelection.js +0 -83
  89. package/dist/theme/dataGridTheme.js +0 -84
  90. package/dist/theme/ensureDataGridAppStyles.js +0 -2656
  91. package/dist/useDataGridAppControlledState.js +0 -390
  92. package/dist/useDataGridAppRowModel.js +0 -85
  93. package/dist/useDataGridTableStageBindings.js +0 -1
  94. package/dist/useDataGridTableStageCellIo.d.ts +0 -28
  95. package/dist/useDataGridTableStageCellIo.js +0 -62
  96. package/dist/useDataGridTableStageColumns.d.ts +0 -21
  97. package/dist/useDataGridTableStageColumns.js +0 -122
  98. package/dist/useDataGridTableStageFillAction.d.ts +0 -19
  99. package/dist/useDataGridTableStageFillAction.js +0 -28
  100. package/dist/useDataGridTableStageHistory.d.ts +0 -31
  101. package/dist/useDataGridTableStageHistory.js +0 -46
  102. package/dist/useDataGridTableStageRowSelection.d.ts +0 -28
  103. package/dist/useDataGridTableStageRowSelection.js +0 -103
  104. package/dist/useDataGridTableStageRuntime.js +0 -1
  105. package/dist/useDataGridTableStageScrollSync.d.ts +0 -17
  106. package/dist/useDataGridTableStageScrollSync.js +0 -49
  107. package/dist/useDataGridTableStageViewportKeyboard.d.ts +0 -20
  108. package/dist/useDataGridTableStageViewportKeyboard.js +0 -58
  109. package/dist/useDataGridTableStageVisualSelection.d.ts +0 -24
  110. package/dist/useDataGridTableStageVisualSelection.js +0 -70
@@ -1,107 +0,0 @@
1
- import { buildDataGridCellRenderModel } from "@affino/datagrid-vue";
2
- import { computed } from "vue";
3
- export function useDataGridTableStageRowSelection(options) {
4
- const rowSelectionSet = computed(() => new Set(options.rowSelectionSnapshot.value?.selectedRows ?? []));
5
- const isRowFocused = (row) => {
6
- return row.rowId != null && options.rowSelectionSnapshot.value?.focusedRow === row.rowId;
7
- };
8
- const isRowCheckboxSelected = (row) => {
9
- return row.kind !== "group" && row.rowId != null && rowSelectionSet.value.has(row.rowId);
10
- };
11
- const readRowSelectionValue = (row) => {
12
- return isRowCheckboxSelected(row);
13
- };
14
- const readRowSelectionCell = (row) => {
15
- return readRowSelectionValue(row) ? "true" : "false";
16
- };
17
- const readRowSelectionDisplayCell = (row) => {
18
- const column = options.rowSelectionColumn.value?.column;
19
- if (!column || row.kind === "group") {
20
- return "";
21
- }
22
- return buildDataGridCellRenderModel({
23
- column,
24
- value: readRowSelectionValue(row),
25
- }).displayValue;
26
- };
27
- const selectableRowIds = computed(() => {
28
- const rowCount = options.runtime.api.rows.getCount();
29
- const rowIds = [];
30
- for (let rowIndex = 0; rowIndex < rowCount; rowIndex += 1) {
31
- const row = options.runtime.api.rows.get(rowIndex);
32
- if (!row || row.kind === "group" || row.rowId == null) {
33
- continue;
34
- }
35
- rowIds.push(row.rowId);
36
- }
37
- return rowIds;
38
- });
39
- const areAllVisibleRowsSelected = computed(() => {
40
- const rowIds = selectableRowIds.value;
41
- return rowIds.length > 0 && rowIds.every(rowId => rowSelectionSet.value.has(rowId));
42
- });
43
- const areSomeVisibleRowsSelected = computed(() => {
44
- const rowIds = selectableRowIds.value;
45
- return rowIds.some(rowId => rowSelectionSet.value.has(rowId));
46
- });
47
- const focusRow = (row) => {
48
- if (row.rowId == null || !options.runtime.api.rowSelection.hasSupport()) {
49
- return;
50
- }
51
- options.runtime.api.rowSelection.setFocusedRow(row.rowId);
52
- };
53
- const toggleRowCheckboxSelected = (row) => {
54
- if (row.kind === "group" || row.rowId == null || !options.runtime.api.rowSelection.hasSupport()) {
55
- return;
56
- }
57
- options.runtime.api.rowSelection.setSelected(row.rowId, !rowSelectionSet.value.has(row.rowId));
58
- };
59
- const toggleVisibleRowsSelected = () => {
60
- if (!options.runtime.api.rowSelection.hasSupport()) {
61
- return;
62
- }
63
- const rowIds = selectableRowIds.value;
64
- if (!areAllVisibleRowsSelected.value) {
65
- options.runtime.api.rowSelection.selectRows(rowIds);
66
- return;
67
- }
68
- options.runtime.api.rowSelection.deselectRows(rowIds);
69
- };
70
- const selectRowRange = (row, rowOffset, extend) => {
71
- focusRow(row);
72
- const lastColumnIndex = options.orderedVisibleColumns.value.length - 1;
73
- if (lastColumnIndex < 0) {
74
- return;
75
- }
76
- const rowIndex = options.viewportRowStart.value + rowOffset;
77
- if (!extend) {
78
- options.applySelectionRange({
79
- startRow: rowIndex,
80
- endRow: rowIndex,
81
- startColumn: 0,
82
- endColumn: lastColumnIndex,
83
- });
84
- return;
85
- }
86
- const anchorRowIndex = options.selectionAnchorCell.value?.rowIndex ?? rowIndex;
87
- options.applySelectionRange({
88
- startRow: Math.min(anchorRowIndex, rowIndex),
89
- endRow: Math.max(anchorRowIndex, rowIndex),
90
- startColumn: 0,
91
- endColumn: lastColumnIndex,
92
- });
93
- };
94
- return {
95
- rowSelectionSet,
96
- isRowFocused,
97
- isRowCheckboxSelected,
98
- readRowSelectionCell,
99
- readRowSelectionDisplayCell,
100
- areAllVisibleRowsSelected,
101
- areSomeVisibleRowsSelected,
102
- focusRow,
103
- toggleRowCheckboxSelected,
104
- toggleVisibleRowsSelected,
105
- selectRowRange,
106
- };
107
- }
@@ -1,526 +0,0 @@
1
- import { computed, nextTick, ref } from "vue";
2
- import { createDataGridAppRowHeightMetrics, useDataGridAppActiveCellViewport, useDataGridAppCellSelection, useDataGridAppClipboard, useDataGridAppHeaderResize, useDataGridAppInlineEditing, useDataGridAppInteractionController, useDataGridAppRowPresentation, useDataGridAppRowSizing, useDataGridAppViewport, useDataGridAppRuntimeSync, useDataGridAppViewportLifecycle, } from "@affino/datagrid-vue";
3
- import { useDataGridTableStageBindings } from "./useDataGridTableStageBindings";
4
- import { useDataGridTableStageCellIo } from "./useDataGridTableStageCellIo";
5
- import { useDataGridTableStageColumns } from "./useDataGridTableStageColumns";
6
- import { useDataGridTableStageFillAction } from "./useDataGridTableStageFillAction";
7
- import { useDataGridTableStageHistory } from "./useDataGridTableStageHistory";
8
- import { useDataGridTableStageRowSelection } from "./useDataGridTableStageRowSelection";
9
- import { useDataGridTableStageScrollSync } from "./useDataGridTableStageScrollSync";
10
- import { useDataGridTableStageViewportKeyboard } from "./useDataGridTableStageViewportKeyboard";
11
- import { useDataGridTableStageVisualSelection } from "./useDataGridTableStageVisualSelection";
12
- const DEFAULT_COLUMN_WIDTH = 140;
13
- const INDEX_COLUMN_WIDTH = 72;
14
- const MIN_COLUMN_WIDTH = 80;
15
- const MIN_ROW_HEIGHT = 24;
16
- const AUTO_RESIZE_SAMPLE_LIMIT = 400;
17
- export function useDataGridTableStageRuntime(options) {
18
- const syncRowSelectionSnapshotFromRuntime = options.syncRowSelectionSnapshotFromRuntime ?? (() => undefined);
19
- const rowSelectionSnapshotRef = options.rowSelectionSnapshot ?? ref(null);
20
- const showRowIndex = computed(() => options.showRowIndex?.value !== false);
21
- const totalBodyRows = computed(() => options.runtime.rowPartition.value.bodyRowCount);
22
- const totalSelectableRows = computed(() => Math.max(0, options.totalRuntimeRows.value));
23
- const effectiveIndexColumnWidth = computed(() => (showRowIndex.value ? INDEX_COLUMN_WIDTH : 0));
24
- const columnService = useDataGridTableStageColumns({
25
- runtime: options.runtime,
26
- visibleColumns: options.visibleColumns,
27
- showRowSelection: options.showRowSelection,
28
- isCellEditable: options.isCellEditable,
29
- });
30
- const { orderedVisibleColumns, centerColumns, resolveColumnWidth, isRowSelectionColumnKey, isRowSelectionColumn, isCellEditable, isCellEditableByKey, rowSelectionColumn, } = columnService;
31
- const rowHeightMetrics = createDataGridAppRowHeightMetrics({
32
- totalRows: () => totalBodyRows.value,
33
- resolveBaseRowHeight: () => options.normalizedBaseRowHeight.value,
34
- resolveRowHeightOverride: rowIndex => options.runtime.api.view.getRowHeightOverride(rowIndex),
35
- resolveRowHeightVersion: () => options.runtime.api.view.getRowHeightVersion(),
36
- hasRowHeightOverrides: () => options.runtime.api.view.getRowHeightVersion() > 0,
37
- });
38
- let isEditingCellForSelection = () => false;
39
- const { headerViewportRef, bodyViewportRef, displayRows, pinnedBottomRows, renderedColumns, viewportRowStart, viewportColumnStart, topSpacerHeight, bottomSpacerHeight, leftColumnSpacerWidth, rightColumnSpacerWidth, gridContentStyle, mainTrackStyle, indexColumnStyle, columnStyle: _viewportColumnStyle, handleViewportScroll, syncViewportFromDom, scheduleViewportSync, cancelScheduledViewportSync, } = useDataGridAppViewport({
40
- runtime: options.runtime,
41
- mode: options.mode,
42
- rowRenderMode: options.rowRenderMode,
43
- rowVirtualizationEnabled: computed(() => options.virtualization.value.rows),
44
- columnVirtualizationEnabled: computed(() => options.virtualization.value.columns),
45
- totalRows: totalBodyRows,
46
- visibleColumns: centerColumns,
47
- sizingColumns: orderedVisibleColumns,
48
- normalizedBaseRowHeight: options.normalizedBaseRowHeight,
49
- resolveColumnWidth,
50
- defaultColumnWidth: DEFAULT_COLUMN_WIDTH,
51
- indexColumnWidth: 0,
52
- flexFillOffsetWidth: effectiveIndexColumnWidth.value,
53
- rowOverscan: computed(() => options.virtualization.value.rowOverscan),
54
- columnOverscan: computed(() => options.virtualization.value.columnOverscan),
55
- measureVisibleRowHeights: () => measureVisibleRowHeights(),
56
- resolveRowHeight: rowHeightMetrics.resolveRowHeight,
57
- resolveRowOffset: rowHeightMetrics.resolveRowOffset,
58
- resolveRowIndexAtOffset: rowHeightMetrics.resolveRowIndexAtOffset,
59
- resolveTotalRowHeight: rowHeightMetrics.resolveTotalHeight,
60
- });
61
- const resolveStageColumnStyle = (columnKey) => {
62
- return _viewportColumnStyle(columnKey);
63
- };
64
- const getSelectableRowAtIndex = (rowIndex) => {
65
- if (totalSelectableRows.value <= 0) {
66
- return null;
67
- }
68
- const normalizedIndex = Math.max(0, Math.min(totalSelectableRows.value - 1, Math.trunc(rowIndex)));
69
- return options.runtime.api.rows.get(normalizedIndex) ?? null;
70
- };
71
- const resolveSelectableRowIndexById = (rowId) => {
72
- for (let rowIndex = 0; rowIndex < totalSelectableRows.value; rowIndex += 1) {
73
- if (options.runtime.api.rows.get(rowIndex)?.rowId === rowId) {
74
- return rowIndex;
75
- }
76
- }
77
- return options.runtime.resolveBodyRowIndexById(rowId);
78
- };
79
- const selectableRuntime = {
80
- ...options.runtime,
81
- getBodyRowAtIndex: getSelectableRowAtIndex,
82
- resolveBodyRowIndexById: resolveSelectableRowIndexById,
83
- };
84
- const { rowStyle, isRowAutosizeProbe, measureVisibleRowHeights, startRowResize, autosizeRow, dispose: disposeRowSizing, } = useDataGridAppRowSizing({
85
- mode: options.mode,
86
- rowHeightMode: options.rowHeightMode,
87
- normalizedBaseRowHeight: options.normalizedBaseRowHeight,
88
- viewportRowStart,
89
- bodyViewportRef,
90
- runtime: options.runtime,
91
- minRowHeight: MIN_ROW_HEIGHT,
92
- syncViewport: () => syncViewportFromDom(),
93
- });
94
- const selectionController = useDataGridAppCellSelection({
95
- mode: options.mode,
96
- runtime: selectableRuntime,
97
- totalRows: totalSelectableRows,
98
- visibleColumns: orderedVisibleColumns,
99
- viewportRowStart,
100
- selectionSnapshot: options.selectionSnapshot,
101
- selectionAnchor: options.selectionAnchor,
102
- isEditingCell: (row, columnKey) => isEditingCellForSelection(row, columnKey),
103
- });
104
- const { normalizeRowId, normalizeCellCoord, resolveSelectionRange: resolveSelectionRangeForClipboard, resolveCurrentCellCoord: resolveCurrentCellCoordForClipboard, applySelectionRange: applyClipboardSelectionRange, applyCellSelectionByCoord, setCellSelection, clearCellSelection, isCellSelected: isCommittedCellSelected, } = selectionController;
105
- const isCommittedSelectionAnchorCell = selectionController.isSelectionAnchorCell ?? (() => false);
106
- const shouldHighlightCommittedSelectedCell = selectionController.shouldHighlightSelectedCell
107
- ?? ((rowOffset, columnIndex) => isCommittedCellSelected(rowOffset, columnIndex));
108
- const isCommittedCellOnSelectionEdge = selectionController.isCellOnSelectionEdge
109
- ?? (() => false);
110
- const selectionAnchorCell = computed(() => {
111
- const snapshot = options.selectionSnapshot.value;
112
- if (!snapshot || snapshot.ranges.length === 0) {
113
- return null;
114
- }
115
- const activeIndex = snapshot.activeRangeIndex ?? 0;
116
- const anchor = snapshot.ranges[activeIndex]?.anchor ?? snapshot.ranges[0]?.anchor ?? null;
117
- if (!anchor
118
- || typeof anchor.rowIndex !== "number"
119
- || typeof anchor.colIndex !== "number"
120
- || !Number.isFinite(anchor.rowIndex)
121
- || !Number.isFinite(anchor.colIndex)) {
122
- return null;
123
- }
124
- return {
125
- rowIndex: Math.trunc(anchor.rowIndex),
126
- columnIndex: Math.trunc(anchor.colIndex),
127
- };
128
- });
129
- const rowSelectionService = useDataGridTableStageRowSelection({
130
- runtime: options.runtime,
131
- rowSelectionColumn,
132
- orderedVisibleColumns,
133
- displayRows,
134
- rowSelectionSnapshot: rowSelectionSnapshotRef,
135
- viewportRowStart,
136
- selectionAnchorCell,
137
- applySelectionRange: applyClipboardSelectionRange,
138
- });
139
- const { readRowSelectionCell, readRowSelectionDisplayCell, toggleRowCheckboxSelected, } = rowSelectionService;
140
- const stageIndexColumnStyle = computed(() => {
141
- const width = `${effectiveIndexColumnWidth.value}px`;
142
- return {
143
- ...indexColumnStyle.value,
144
- width,
145
- minWidth: width,
146
- maxWidth: width,
147
- };
148
- });
149
- const historyService = useDataGridTableStageHistory({
150
- runtime: options.runtime,
151
- cloneRowData: options.cloneRowData,
152
- syncViewport: () => syncViewportFromDom(),
153
- history: options.history,
154
- });
155
- const { captureHistorySnapshot, recordHistoryIntentTransaction, canUndoHistory, canRedoHistory, runHistoryAction, } = historyService;
156
- const { rowIndexLabel, readCell, readDisplayCell, rowClass, toggleGroupRow, } = useDataGridAppRowPresentation({
157
- mode: options.mode,
158
- runtime: options.runtime,
159
- viewportRowStart,
160
- firstColumnKey: options.firstColumnKey,
161
- });
162
- const cellIoService = useDataGridTableStageCellIo({
163
- runtime: options.runtime,
164
- viewportRowStart,
165
- isRowSelectionColumnKey,
166
- isRowSelectionColumn,
167
- isCellEditableByKey,
168
- readRowSelectionCell,
169
- readRowSelectionDisplayCell,
170
- readCell,
171
- readDisplayCell,
172
- toggleRowCheckboxSelected,
173
- captureHistorySnapshot,
174
- recordHistoryIntentTransaction,
175
- syncViewport: () => syncViewportFromDom(),
176
- });
177
- const { readStageCell, } = cellIoService;
178
- const clipboard = useDataGridAppClipboard({
179
- mode: options.mode,
180
- runtime: selectableRuntime,
181
- totalRows: totalSelectableRows,
182
- visibleColumns: orderedVisibleColumns,
183
- viewportRowStart,
184
- resolveSelectionRange: resolveSelectionRangeForClipboard,
185
- resolveCurrentCellCoord: resolveCurrentCellCoordForClipboard,
186
- applySelectionRange: applyClipboardSelectionRange,
187
- clearCellSelection,
188
- captureRowsSnapshot: captureHistorySnapshot,
189
- recordEditTransaction: beforeSnapshot => {
190
- recordHistoryIntentTransaction({
191
- intent: "edit",
192
- label: "Cell edit",
193
- }, beforeSnapshot);
194
- },
195
- readCell: (row, columnKey) => readStageCell(row, columnKey),
196
- readClipboardCell: options.readClipboardCell
197
- ? (row, columnKey) => options.readClipboardCell?.(row, columnKey) ?? ""
198
- : undefined,
199
- isCellEditable: isCellEditableByKey,
200
- syncViewport: () => syncViewportFromDom(),
201
- applyClipboardEdits: options.applyClipboardEdits,
202
- buildFillMatrixFromRange: options.buildFillMatrixFromRange,
203
- });
204
- const { normalizeClipboardRange, applyClipboardEdits, rangesEqual, buildFillMatrixFromRange, clearPendingClipboardOperation, copySelectedCells, pasteSelectedCells, cutSelectedCells, isCellInPendingClipboardRange, isCellOnPendingClipboardEdge, } = clipboard;
205
- const { ensureKeyboardActiveCellVisible, } = useDataGridAppActiveCellViewport({
206
- bodyViewportRef,
207
- visibleColumns: orderedVisibleColumns,
208
- resolveColumnWidth,
209
- normalizedBaseRowHeight: options.normalizedBaseRowHeight,
210
- resolveRowHeight: rowHeightMetrics.resolveRowHeight,
211
- resolveRowOffset: rowHeightMetrics.resolveRowOffset,
212
- indexColumnWidth: effectiveIndexColumnWidth.value,
213
- defaultColumnWidth: DEFAULT_COLUMN_WIDTH,
214
- syncViewport: () => syncViewportFromDom(),
215
- });
216
- const { editingCell, editingCellValue, editingCellInitialFilter, editingCellOpenOnMount, isEditingCell, startInlineEdit, commitInlineEdit, cancelInlineEdit, handleEditorKeydown, } = useDataGridAppInlineEditing({
217
- mode: options.mode,
218
- bodyViewportRef,
219
- visibleColumns: orderedVisibleColumns,
220
- totalRows: totalSelectableRows,
221
- runtime: selectableRuntime,
222
- readCell: (row, columnKey) => readStageCell(row, columnKey),
223
- resolveRowIndexById: resolveSelectableRowIndexById,
224
- applyCellSelection: coord => {
225
- applyCellSelectionByCoord(coord, false);
226
- },
227
- ensureActiveCellVisible: (rowIndex, columnIndex) => {
228
- ensureKeyboardActiveCellVisible(rowIndex, columnIndex);
229
- },
230
- isCellEditable: isCellEditableByKey,
231
- captureRowsSnapshot: captureHistorySnapshot,
232
- recordEditTransaction: beforeSnapshot => {
233
- recordHistoryIntentTransaction({
234
- intent: "edit",
235
- label: "Cell edit",
236
- }, beforeSnapshot);
237
- },
238
- });
239
- isEditingCellForSelection = isEditingCell;
240
- const editingCellRef = computed(() => editingCell.value);
241
- const interactionControllerOptions = {
242
- mode: options.mode,
243
- runtime: selectableRuntime,
244
- totalRows: totalSelectableRows,
245
- visibleColumns: orderedVisibleColumns,
246
- viewportRowStart,
247
- selectionSnapshot: options.selectionSnapshot,
248
- bodyViewportRef,
249
- indexColumnWidth: effectiveIndexColumnWidth.value,
250
- resolveColumnWidth,
251
- resolveRowHeight: rowHeightMetrics.resolveRowHeight,
252
- resolveRowIndexAtOffset: rowHeightMetrics.resolveRowIndexAtOffset,
253
- normalizeRowId,
254
- normalizeCellCoord,
255
- resolveSelectionRange: resolveSelectionRangeForClipboard,
256
- applySelectionRange: applyClipboardSelectionRange,
257
- applyCellSelectionByCoord,
258
- setCellSelection,
259
- clearCellSelection,
260
- readCell: (row, columnKey) => readStageCell(row, columnKey),
261
- isCellEditable: isCellEditableByKey,
262
- cloneRowData: options.cloneRowData,
263
- resolveRowIndexById: resolveSelectableRowIndexById,
264
- captureRowsSnapshot: captureHistorySnapshot,
265
- recordIntentTransaction: (descriptor, beforeSnapshot) => {
266
- recordHistoryIntentTransaction(descriptor, beforeSnapshot);
267
- },
268
- clearPendingClipboardOperation,
269
- clearExternalPendingClipboardOperation: options.clearExternalPendingClipboardOperation,
270
- copySelectedCells,
271
- pasteSelectedCells,
272
- cutSelectedCells,
273
- normalizeClipboardRange,
274
- applyClipboardEdits,
275
- rangesEqual,
276
- buildFillMatrixFromRange,
277
- applyRangeMove: options.applyRangeMove,
278
- syncViewport: () => syncViewportFromDom(),
279
- editingCell: editingCellRef,
280
- startInlineEdit,
281
- commitInlineEdit,
282
- canUndo: canUndoHistory,
283
- canRedo: canRedoHistory,
284
- runHistoryAction,
285
- ensureKeyboardActiveCellVisible,
286
- isContextMenuVisible: options.isContextMenuVisible,
287
- closeContextMenu: options.closeContextMenu,
288
- openContextMenuFromCurrentCell: options.openContextMenuFromCurrentCell,
289
- runRowIndexKeyboardAction: options.runRowIndexKeyboardAction,
290
- handleToggleCellAction: (row, rowIndex, columnIndex, column) => {
291
- if (!isRowSelectionColumn(column)) {
292
- return false;
293
- }
294
- void rowIndex;
295
- void columnIndex;
296
- toggleRowCheckboxSelected(row);
297
- return true;
298
- },
299
- };
300
- const interactionController = (useDataGridAppInteractionController(interactionControllerOptions));
301
- const { isPointerSelectingCells, isFillDragging, fillPreviewRange, lastAppliedFill, isRangeMoving, selectionRange: interactionSelectionRange, rangeMovePreviewRange, stopPointerSelection, stopFillSelection, startFillHandleDrag, startFillHandleDoubleClick, applyLastFillBehavior, handleCellMouseDown, handleCellKeydown, handleRowIndexKeydown, handleWindowMouseMove: handleInteractionWindowMouseMove, handleWindowMouseUp: handleInteractionWindowMouseUp, isCellInFillPreview, isFillHandleCell, clearSelectedCells, dispose: disposeInteractionController, } = interactionController;
302
- const viewportKeyboardService = useDataGridTableStageViewportKeyboard({
303
- runtime: selectableRuntime,
304
- selectionSnapshot: options.selectionSnapshot,
305
- totalRows: totalSelectableRows,
306
- orderedVisibleColumns,
307
- viewportRowStart,
308
- applySelectionRange: applyClipboardSelectionRange,
309
- handleCellKeydown,
310
- });
311
- const { isColumnResizing, startResize, handleResizeDoubleClick, applyColumnResizeFromPointer, stopColumnResize, dispose: disposeHeaderResize, } = useDataGridAppHeaderResize({
312
- visibleColumns: orderedVisibleColumns,
313
- rows: options.rows,
314
- persistColumnWidth: (columnKey, width) => {
315
- options.runtime.api.columns.setWidth(columnKey, width);
316
- },
317
- defaultColumnWidth: DEFAULT_COLUMN_WIDTH,
318
- minColumnWidth: MIN_COLUMN_WIDTH,
319
- autoSizeSampleLimit: AUTO_RESIZE_SAMPLE_LIMIT,
320
- autoSizeCharWidth: 7.2,
321
- autoSizeHorizontalPadding: 42,
322
- autoSizeMaxWidth: 640,
323
- isFillDragging: () => isFillDragging.value,
324
- stopFillSelection: () => {
325
- stopFillSelection(false);
326
- },
327
- isDragSelecting: () => isPointerSelectingCells.value,
328
- stopDragSelection: () => {
329
- stopPointerSelection();
330
- },
331
- readCellText: (row, columnKey) => {
332
- const value = row[columnKey];
333
- return value == null ? "" : String(value);
334
- },
335
- });
336
- const visualSelectionService = useDataGridTableStageVisualSelection({
337
- mode: options.mode,
338
- viewportRowStart,
339
- selectionAnchorCell,
340
- fillPreviewRange,
341
- isFillDragging,
342
- interactionSelectionRange,
343
- resolveCommittedSelectionRange: resolveSelectionRangeForClipboard,
344
- isCommittedSelectionAnchorCell,
345
- isCommittedCellSelected,
346
- shouldHighlightCommittedSelectedCell,
347
- isCommittedCellOnSelectionEdge,
348
- });
349
- const { selectionRange } = visualSelectionService;
350
- const fillActionService = useDataGridTableStageFillAction({
351
- lastAppliedFill,
352
- selectionRange,
353
- isFillDragging,
354
- });
355
- const scrollSyncService = useDataGridTableStageScrollSync({
356
- bodyViewportRef,
357
- isColumnResizing,
358
- applyColumnResizeFromPointer,
359
- stopColumnResize,
360
- handleInteractionWindowMouseMove,
361
- handleInteractionWindowMouseUp,
362
- syncViewport: syncViewportFromDom,
363
- });
364
- const stageServices = {
365
- columns: columnService,
366
- rowSelection: rowSelectionService,
367
- history: historyService,
368
- cellIo: cellIoService,
369
- viewportKeyboard: viewportKeyboardService,
370
- visualSelection: visualSelectionService,
371
- fillAction: fillActionService,
372
- scrollSync: scrollSyncService,
373
- };
374
- const { tableStageProps, tableStageContext, } = useDataGridTableStageBindings({
375
- mode: options.mode,
376
- rowHeightMode: options.rowHeightMode,
377
- visibleColumns: orderedVisibleColumns,
378
- renderedColumns,
379
- displayRows,
380
- pinnedBottomRows,
381
- sourceRows: options.sourceRows ?? options.rows,
382
- showRowIndex,
383
- rowHover: computed(() => options.rowHover?.value === true),
384
- stripedRows: computed(() => options.stripedRows?.value === true),
385
- columnFilterTextByKey: options.columnFilterTextByKey,
386
- gridContentStyle,
387
- mainTrackStyle,
388
- indexColumnStyle: stageIndexColumnStyle,
389
- topSpacerHeight,
390
- bottomSpacerHeight,
391
- viewportRowStart,
392
- columnWindowStart: viewportColumnStart,
393
- leftColumnSpacerWidth,
394
- rightColumnSpacerWidth,
395
- editingCellValueRef: editingCellValue,
396
- editingCellInitialFilter,
397
- editingCellOpenOnMount,
398
- selectionRange,
399
- selectionAnchorCell,
400
- fillPreviewRange,
401
- rangeMovePreviewRange,
402
- isFillDragging,
403
- isRangeMoving,
404
- headerViewportRef,
405
- bodyViewportRef,
406
- columnStyle: resolveStageColumnStyle,
407
- toggleSortForColumn: options.toggleSortForColumn,
408
- sortIndicator: options.sortIndicator,
409
- setColumnFilterText: options.setColumnFilterText,
410
- columnMenuEnabled: options.columnMenuEnabled,
411
- columnMenuValueFilterEnabled: options.columnMenuValueFilterEnabled,
412
- columnMenuValueFilterRowLimit: options.columnMenuValueFilterRowLimit,
413
- columnMenuMaxFilterValues: options.columnMenuMaxFilterValues,
414
- resolveColumnMenuItems: options.resolveColumnMenuItems,
415
- resolveColumnMenuDisabledItems: options.resolveColumnMenuDisabledItems,
416
- resolveColumnMenuDisabledReasons: options.resolveColumnMenuDisabledReasons,
417
- resolveColumnMenuLabels: options.resolveColumnMenuLabels,
418
- resolveColumnMenuActionOptions: options.resolveColumnMenuActionOptions,
419
- isColumnFilterActive: options.isColumnFilterActive,
420
- isColumnGrouped: options.isColumnGrouped,
421
- resolveColumnGroupOrder: options.resolveColumnGroupOrder,
422
- resolveColumnMenuSortDirection: options.resolveColumnMenuSortDirection,
423
- resolveColumnMenuSelectedTokens: options.resolveColumnMenuSelectedTokens,
424
- applyColumnMenuSort: options.applyColumnMenuSort,
425
- applyColumnMenuPin: options.applyColumnMenuPin,
426
- applyColumnMenuGroupBy: options.applyColumnMenuGroupBy,
427
- applyColumnMenuFilter: options.applyColumnMenuFilter,
428
- clearColumnMenuFilter: options.clearColumnMenuFilter,
429
- handleHeaderWheel: stageServices.scrollSync.handleHeaderWheel,
430
- handleHeaderScroll: stageServices.scrollSync.handleHeaderScroll,
431
- handleViewportScroll,
432
- handleViewportKeydown: stageServices.viewportKeyboard.handleViewportKeydown,
433
- rowClass,
434
- isRowAutosizeProbe,
435
- rowStyle,
436
- isRowInPendingClipboardCut: options.isRowInPendingClipboardCut,
437
- isRowFocused: stageServices.rowSelection.isRowFocused,
438
- isRowCheckboxSelected: stageServices.rowSelection.isRowCheckboxSelected,
439
- allVisibleRowsSelected: stageServices.rowSelection.areAllVisibleRowsSelected,
440
- someVisibleRowsSelected: stageServices.rowSelection.areSomeVisibleRowsSelected,
441
- handleRowClick: stageServices.rowSelection.focusRow,
442
- handleRowIndexClick: stageServices.rowSelection.selectRowRange,
443
- handleRowIndexKeydown,
444
- handleToggleAllVisibleRows: stageServices.rowSelection.toggleVisibleRowsSelected,
445
- toggleGroupRow,
446
- rowIndexLabel,
447
- startResize,
448
- handleResizeDoubleClick,
449
- startRowResize,
450
- autosizeRow,
451
- isCellSelected: stageServices.visualSelection.isCellSelected,
452
- isSelectionAnchorCell: stageServices.visualSelection.isSelectionAnchorCell,
453
- shouldHighlightSelectedCell: stageServices.visualSelection.shouldHighlightSelectedCell,
454
- isCellOnSelectionEdge: stageServices.visualSelection.isCellOnSelectionEdge,
455
- isCellInFillPreview,
456
- isCellInPendingClipboardRange,
457
- isCellOnPendingClipboardEdge,
458
- isEditingCell,
459
- isCellEditable: (row, rowOffset, column, columnIndex) => {
460
- void columnIndex;
461
- return isCellEditable(row, viewportRowStart.value + rowOffset, column);
462
- },
463
- handleCellMouseDown,
464
- handleCellClick: stageServices.cellIo.handleCellClick,
465
- handleCellKeydown,
466
- startInlineEdit,
467
- isFillHandleCell,
468
- startFillHandleDrag,
469
- startFillHandleDoubleClick,
470
- fillActionAnchorCell: stageServices.fillAction.fillActionAnchorCell,
471
- fillActionBehavior: stageServices.fillAction.fillActionBehavior,
472
- applyFillActionBehavior: applyLastFillBehavior,
473
- handleEditorKeydown,
474
- commitInlineEdit,
475
- cancelInlineEdit,
476
- readCell: stageServices.cellIo.readStageCell,
477
- readDisplayCell: stageServices.cellIo.readStageDisplayCell,
478
- });
479
- useDataGridAppRuntimeSync({
480
- mode: options.mode,
481
- rows: options.rows,
482
- runtime: options.runtime,
483
- totalRows: totalBodyRows,
484
- rowVersion: options.rowVersion,
485
- rowHeightMode: options.rowHeightMode,
486
- normalizedBaseRowHeight: options.normalizedBaseRowHeight,
487
- syncSelectionSnapshotFromRuntime: options.syncSelectionSnapshotFromRuntime,
488
- syncRowSelectionSnapshotFromRuntime,
489
- syncViewport: syncViewportFromDom,
490
- scheduleViewportSync,
491
- measureVisibleRowHeights,
492
- applyRowHeightSettings: options.applyRowHeightSettings,
493
- });
494
- useDataGridAppViewportLifecycle({
495
- bodyViewportRef,
496
- syncViewport: syncViewportFromDom,
497
- handleWindowMouseMove: stageServices.scrollSync.handleWindowMouseMove,
498
- handleWindowMouseUp: stageServices.scrollSync.handleWindowMouseUp,
499
- cancelScheduledViewportSync,
500
- onAfterMount: () => {
501
- options.syncSelectionSnapshotFromRuntime();
502
- syncRowSelectionSnapshotFromRuntime();
503
- void nextTick(() => {
504
- options.applyRowHeightSettings();
505
- syncViewportFromDom();
506
- });
507
- },
508
- dispose: [
509
- disposeRowSizing,
510
- disposeHeaderResize,
511
- disposeInteractionController,
512
- stageServices.history.disposeIntentHistory,
513
- ],
514
- });
515
- return {
516
- tableStageProps,
517
- tableStageContext,
518
- syncViewportFromDom,
519
- copySelectedCells,
520
- pasteSelectedCells,
521
- cutSelectedCells,
522
- clearSelectedCells,
523
- captureHistorySnapshot,
524
- recordHistoryIntentTransaction,
525
- };
526
- }
@@ -1,49 +0,0 @@
1
- export function useDataGridTableStageScrollSync(options) {
2
- const handleWindowMouseMove = (event) => {
3
- if (options.isColumnResizing.value) {
4
- options.applyColumnResizeFromPointer(event.clientX);
5
- return;
6
- }
7
- options.handleInteractionWindowMouseMove(event);
8
- };
9
- const handleHeaderWheel = (event) => {
10
- const bodyViewport = options.bodyViewportRef.value;
11
- if (!bodyViewport) {
12
- return;
13
- }
14
- const horizontalDelta = Math.abs(event.deltaX) > 0 ? event.deltaX : (event.shiftKey ? event.deltaY : 0);
15
- const verticalDelta = horizontalDelta === 0 ? event.deltaY : 0;
16
- if (horizontalDelta === 0 && verticalDelta === 0) {
17
- return;
18
- }
19
- event.preventDefault();
20
- if (horizontalDelta !== 0) {
21
- bodyViewport.scrollLeft += horizontalDelta;
22
- }
23
- if (verticalDelta !== 0) {
24
- bodyViewport.scrollTop += verticalDelta;
25
- }
26
- options.syncViewport();
27
- };
28
- const handleHeaderScroll = (event) => {
29
- const headerViewport = event.target;
30
- const bodyViewport = options.bodyViewportRef.value;
31
- if (!headerViewport || !bodyViewport) {
32
- return;
33
- }
34
- if (bodyViewport.scrollLeft !== headerViewport.scrollLeft) {
35
- bodyViewport.scrollLeft = headerViewport.scrollLeft;
36
- }
37
- options.syncViewport();
38
- };
39
- const handleWindowMouseUp = () => {
40
- options.stopColumnResize();
41
- options.handleInteractionWindowMouseUp();
42
- };
43
- return {
44
- handleWindowMouseMove,
45
- handleHeaderWheel,
46
- handleHeaderScroll,
47
- handleWindowMouseUp,
48
- };
49
- }