@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.
- package/dist/DataGrid.d.ts +9 -9
- package/dist/DataGridTableStage.vue.d.ts +112 -0
- package/dist/chunks/useDataGridAppRowModel-CcTL-h8L.js +11251 -0
- package/dist/gantt/DataGridGanttStage.vue.d.ts +21 -0
- package/dist/host/DataGridDefaultRenderer.d.ts +3 -3
- package/dist/host/DataGridRuntimeHost.d.ts +1 -1
- package/dist/index.js +1125 -4
- package/dist/internal.js +37 -14
- package/dist/overlays/DataGridAdvancedFilterPopover.vue.d.ts +62 -0
- package/dist/overlays/DataGridAggregationsPopover.vue.d.ts +62 -0
- package/dist/overlays/DataGridCellComboboxEditor.vue.d.ts +29 -0
- package/dist/overlays/DataGridColumnLayoutPopover.vue.d.ts +51 -0
- package/dist/overlays/DataGridColumnMenu.vue.d.ts +65 -0
- package/dist/overlays/DataGridFilterableCombobox.vue.d.ts +76 -0
- package/dist/stage/DataGridTableStage.vue.d.ts +115 -0
- package/dist/stage/DataGridTableStageCenterPane.vue.d.ts +121 -0
- package/dist/stage/DataGridTableStageFillActionMenu.vue.d.ts +30 -0
- package/dist/stage/DataGridTableStageHeader.vue.d.ts +84 -0
- package/dist/stage/DataGridTableStageOverlayLayer.vue.d.ts +34 -0
- package/dist/stage/DataGridTableStagePinnedPane.vue.d.ts +43 -0
- package/package.json +8 -5
- package/dist/DataGrid.js +0 -565
- package/dist/DataGridDefaultRenderer.js +0 -2
- package/dist/DataGridModuleHost.js +0 -2
- package/dist/DataGridRuntimeHost.js +0 -1
- package/dist/config/dataGridAdvancedFilter.js +0 -21
- package/dist/config/dataGridAggregations.js +0 -21
- package/dist/config/dataGridColumnLayout.js +0 -21
- package/dist/config/dataGridFormulaOptions.js +0 -137
- package/dist/config/dataGridPublicProps.js +0 -58
- package/dist/config/dataGridSavedView.js +0 -73
- package/dist/config/dataGridVirtualization.js +0 -32
- package/dist/dataGridAdvancedFilter.js +0 -1
- package/dist/dataGridAggregations.js +0 -1
- package/dist/dataGridAppContext.js +0 -1
- package/dist/dataGridCellComboboxState.d.ts +0 -10
- package/dist/dataGridCellComboboxState.js +0 -67
- package/dist/dataGridColumnLayout.js +0 -1
- package/dist/dataGridColumnMenu.d.ts +0 -9
- package/dist/dataGridColumnMenu.js +0 -21
- package/dist/dataGridEditability.js +0 -1
- package/dist/dataGridFilterableCombobox.js +0 -1
- package/dist/dataGridFormulaOptions.js +0 -1
- package/dist/dataGridGantt.d.ts +0 -3
- package/dist/dataGridGantt.js +0 -1
- package/dist/dataGridGanttDependencySelection.d.ts +0 -7
- package/dist/dataGridGanttDependencySelection.js +0 -46
- package/dist/dataGridGanttLabel.d.ts +0 -2
- package/dist/dataGridGanttLabel.js +0 -30
- package/dist/dataGridGanttSplit.d.ts +0 -20
- package/dist/dataGridGanttSplit.js +0 -31
- package/dist/dataGridGanttWheel.d.ts +0 -10
- package/dist/dataGridGanttWheel.js +0 -30
- package/dist/dataGridOverlayThemeVars.d.ts +0 -1
- package/dist/dataGridOverlayThemeVars.js +0 -32
- package/dist/dataGridPublicProps.js +0 -1
- package/dist/dataGridTableStage.types.js +0 -1
- package/dist/dataGridTableStageBody.types.js +0 -1
- package/dist/dataGridTableStageContext.js +0 -1
- package/dist/dataGridTheme.js +0 -1
- package/dist/dataGridVirtualization.js +0 -1
- package/dist/ensureDataGridAppStyles.js +0 -1
- package/dist/gantt/dataGridGantt.js +0 -1
- package/dist/gantt/dataGridGanttDependencySelection.js +0 -46
- package/dist/gantt/dataGridGanttLabel.js +0 -30
- package/dist/gantt/dataGridGanttSplit.js +0 -31
- package/dist/gantt/dataGridGanttWheel.js +0 -30
- package/dist/host/DataGridDefaultRenderer.js +0 -1847
- package/dist/host/DataGridModuleHost.js +0 -23
- package/dist/host/DataGridRuntimeHost.js +0 -174
- package/dist/overlays/dataGridCellComboboxState.js +0 -67
- package/dist/overlays/dataGridColumnMenu.js +0 -190
- package/dist/overlays/dataGridContextMenu.js +0 -218
- package/dist/overlays/dataGridFilterableCombobox.js +0 -74
- package/dist/overlays/dataGridOverlayThemeVars.js +0 -32
- package/dist/stage/dataGridTableStage.types.js +0 -1
- package/dist/stage/dataGridTableStageBody.types.js +0 -1
- package/dist/stage/dataGridTableStageContext.js +0 -88
- package/dist/stage/useDataGridTableStageBindings.js +0 -162
- package/dist/stage/useDataGridTableStageCellIo.js +0 -62
- package/dist/stage/useDataGridTableStageColumns.js +0 -124
- package/dist/stage/useDataGridTableStageFillAction.js +0 -28
- package/dist/stage/useDataGridTableStageHistory.js +0 -46
- package/dist/stage/useDataGridTableStageRowSelection.js +0 -107
- package/dist/stage/useDataGridTableStageRuntime.js +0 -526
- package/dist/stage/useDataGridTableStageScrollSync.js +0 -49
- package/dist/stage/useDataGridTableStageViewportKeyboard.js +0 -58
- package/dist/stage/useDataGridTableStageVisualSelection.js +0 -83
- package/dist/theme/dataGridTheme.js +0 -84
- package/dist/theme/ensureDataGridAppStyles.js +0 -2656
- package/dist/useDataGridAppControlledState.js +0 -390
- package/dist/useDataGridAppRowModel.js +0 -85
- package/dist/useDataGridTableStageBindings.js +0 -1
- package/dist/useDataGridTableStageCellIo.d.ts +0 -28
- package/dist/useDataGridTableStageCellIo.js +0 -62
- package/dist/useDataGridTableStageColumns.d.ts +0 -21
- package/dist/useDataGridTableStageColumns.js +0 -122
- package/dist/useDataGridTableStageFillAction.d.ts +0 -19
- package/dist/useDataGridTableStageFillAction.js +0 -28
- package/dist/useDataGridTableStageHistory.d.ts +0 -31
- package/dist/useDataGridTableStageHistory.js +0 -46
- package/dist/useDataGridTableStageRowSelection.d.ts +0 -28
- package/dist/useDataGridTableStageRowSelection.js +0 -103
- package/dist/useDataGridTableStageRuntime.js +0 -1
- package/dist/useDataGridTableStageScrollSync.d.ts +0 -17
- package/dist/useDataGridTableStageScrollSync.js +0 -49
- package/dist/useDataGridTableStageViewportKeyboard.d.ts +0 -20
- package/dist/useDataGridTableStageViewportKeyboard.js +0 -58
- package/dist/useDataGridTableStageVisualSelection.d.ts +0 -24
- package/dist/useDataGridTableStageVisualSelection.js +0 -70
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { computed } from "vue";
|
|
2
|
-
const DEFAULT_COLUMN_WIDTH = 140;
|
|
3
|
-
const ROW_SELECTION_COLUMN_WIDTH = 108;
|
|
4
|
-
const ROW_SELECTION_COLUMN_KEY = "__datagrid_row_selection__";
|
|
5
|
-
export function useDataGridTableStageColumns(options) {
|
|
6
|
-
const hasRowSelectionSupport = computed(() => options.runtime.api.rowSelection.hasSupport());
|
|
7
|
-
const rowSelectionColumn = computed(() => {
|
|
8
|
-
if (!hasRowSelectionSupport.value) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
return {
|
|
12
|
-
key: ROW_SELECTION_COLUMN_KEY,
|
|
13
|
-
state: {
|
|
14
|
-
visible: true,
|
|
15
|
-
pin: "left",
|
|
16
|
-
width: ROW_SELECTION_COLUMN_WIDTH,
|
|
17
|
-
},
|
|
18
|
-
visible: true,
|
|
19
|
-
pin: "left",
|
|
20
|
-
width: ROW_SELECTION_COLUMN_WIDTH,
|
|
21
|
-
column: {
|
|
22
|
-
key: ROW_SELECTION_COLUMN_KEY,
|
|
23
|
-
label: "",
|
|
24
|
-
cellType: "checkbox",
|
|
25
|
-
minWidth: ROW_SELECTION_COLUMN_WIDTH,
|
|
26
|
-
maxWidth: ROW_SELECTION_COLUMN_WIDTH,
|
|
27
|
-
capabilities: {
|
|
28
|
-
editable: true,
|
|
29
|
-
sortable: false,
|
|
30
|
-
filterable: false,
|
|
31
|
-
groupable: false,
|
|
32
|
-
pivotable: false,
|
|
33
|
-
aggregatable: false,
|
|
34
|
-
},
|
|
35
|
-
presentation: {
|
|
36
|
-
align: "center",
|
|
37
|
-
headerAlign: "center",
|
|
38
|
-
},
|
|
39
|
-
meta: {
|
|
40
|
-
isSystem: true,
|
|
41
|
-
rowSelection: true,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
|
-
const isRowSelectionColumnKey = (columnKey) => columnKey === ROW_SELECTION_COLUMN_KEY;
|
|
47
|
-
const isRowSelectionColumn = (column) => isRowSelectionColumnKey(column.key);
|
|
48
|
-
const orderedVisibleColumns = computed(() => {
|
|
49
|
-
const selectionColumn = rowSelectionColumn.value;
|
|
50
|
-
const left = options.visibleColumns.value.filter((column) => column.pin === "left");
|
|
51
|
-
const center = options.visibleColumns.value.filter((column) => column.pin !== "left" && column.pin !== "right");
|
|
52
|
-
const right = options.visibleColumns.value.filter((column) => column.pin === "right");
|
|
53
|
-
return selectionColumn ? [selectionColumn, ...left, ...center, ...right] : [...left, ...center, ...right];
|
|
54
|
-
});
|
|
55
|
-
const centerColumns = computed(() => (orderedVisibleColumns.value.filter((column) => column.pin !== "left" && column.pin !== "right")));
|
|
56
|
-
const resolveColumnWidth = (column) => {
|
|
57
|
-
return column.width ?? DEFAULT_COLUMN_WIDTH;
|
|
58
|
-
};
|
|
59
|
-
const stageColumnStyle = (columnKey) => {
|
|
60
|
-
const column = orderedVisibleColumns.value.find((candidate) => candidate.key === columnKey);
|
|
61
|
-
const width = column ? resolveColumnWidth(column) : DEFAULT_COLUMN_WIDTH;
|
|
62
|
-
const px = `${width}px`;
|
|
63
|
-
return {
|
|
64
|
-
width: px,
|
|
65
|
-
minWidth: px,
|
|
66
|
-
maxWidth: px,
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
const isColumnEditable = (column) => {
|
|
70
|
-
return column.column.capabilities?.editable !== false;
|
|
71
|
-
};
|
|
72
|
-
const isCellEditable = (row, rowIndex, column) => {
|
|
73
|
-
if (isRowSelectionColumn(column)) {
|
|
74
|
-
return row.kind !== "group" && row.rowId != null;
|
|
75
|
-
}
|
|
76
|
-
if (row.kind === "group" || row.rowId == null || !isColumnEditable(column)) {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
if (!options.isCellEditable) {
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
return options.isCellEditable({
|
|
83
|
-
row: row.data,
|
|
84
|
-
rowId: row.rowId,
|
|
85
|
-
rowIndex,
|
|
86
|
-
column: column.column,
|
|
87
|
-
columnKey: column.key,
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
const resolveEditableColumn = (columnKey, columnIndex) => {
|
|
91
|
-
const columnAtIndex = orderedVisibleColumns.value[columnIndex];
|
|
92
|
-
if (columnAtIndex?.key === columnKey) {
|
|
93
|
-
return { column: columnAtIndex, columnIndex };
|
|
94
|
-
}
|
|
95
|
-
const resolvedColumnIndex = orderedVisibleColumns.value.findIndex((column) => column.key === columnKey);
|
|
96
|
-
if (resolvedColumnIndex < 0) {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
return {
|
|
100
|
-
column: orderedVisibleColumns.value[resolvedColumnIndex],
|
|
101
|
-
columnIndex: resolvedColumnIndex,
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
const isCellEditableByKey = (row, rowIndex, columnKey, columnIndex) => {
|
|
105
|
-
const resolved = resolveEditableColumn(columnKey, columnIndex);
|
|
106
|
-
if (!resolved) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
return isCellEditable(row, rowIndex, resolved.column);
|
|
110
|
-
};
|
|
111
|
-
return {
|
|
112
|
-
orderedVisibleColumns,
|
|
113
|
-
centerColumns,
|
|
114
|
-
resolveColumnWidth,
|
|
115
|
-
stageColumnStyle,
|
|
116
|
-
isRowSelectionColumnKey,
|
|
117
|
-
isRowSelectionColumn,
|
|
118
|
-
isCellEditable,
|
|
119
|
-
isCellEditableByKey,
|
|
120
|
-
rowSelectionColumn,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type ComputedRef, type Ref } from "vue";
|
|
2
|
-
import type { DataGridCopyRange, DataGridFillBehavior } from "@affino/datagrid-vue/advanced";
|
|
3
|
-
import type { DataGridTableStageAnchorCell } from "./dataGridTableStage.types";
|
|
4
|
-
interface DataGridTableStageLastAppliedFillSession {
|
|
5
|
-
previewRange: DataGridCopyRange;
|
|
6
|
-
behavior: DataGridFillBehavior;
|
|
7
|
-
allowBehaviorToggle: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface UseDataGridTableStageFillActionOptions {
|
|
10
|
-
lastAppliedFill: Ref<DataGridTableStageLastAppliedFillSession | null>;
|
|
11
|
-
selectionRange: ComputedRef<DataGridCopyRange | null>;
|
|
12
|
-
isFillDragging: Ref<boolean>;
|
|
13
|
-
}
|
|
14
|
-
export interface UseDataGridTableStageFillActionResult {
|
|
15
|
-
fillActionAnchorCell: ComputedRef<DataGridTableStageAnchorCell | null>;
|
|
16
|
-
fillActionBehavior: ComputedRef<DataGridFillBehavior | null>;
|
|
17
|
-
}
|
|
18
|
-
export declare function useDataGridTableStageFillAction(options: UseDataGridTableStageFillActionOptions): UseDataGridTableStageFillActionResult;
|
|
19
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { computed } from "vue";
|
|
2
|
-
export function useDataGridTableStageFillAction(options) {
|
|
3
|
-
const fillActionAnchorCell = computed(() => {
|
|
4
|
-
const session = options.lastAppliedFill.value;
|
|
5
|
-
const activeSelectionRange = options.selectionRange.value;
|
|
6
|
-
if (!session || !activeSelectionRange || options.isFillDragging.value) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
if (session.allowBehaviorToggle === false) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
if (session.previewRange.startRow !== activeSelectionRange.startRow
|
|
13
|
-
|| session.previewRange.endRow !== activeSelectionRange.endRow
|
|
14
|
-
|| session.previewRange.startColumn !== activeSelectionRange.startColumn
|
|
15
|
-
|| session.previewRange.endColumn !== activeSelectionRange.endColumn) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
rowIndex: session.previewRange.endRow,
|
|
20
|
-
columnIndex: session.previewRange.endColumn,
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
const fillActionBehavior = computed(() => options.lastAppliedFill.value?.behavior ?? null);
|
|
24
|
-
return {
|
|
25
|
-
fillActionAnchorCell,
|
|
26
|
-
fillActionBehavior,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { DataGridCopyRange } from "@affino/datagrid-vue/advanced";
|
|
2
|
-
export interface DataGridTableStageHistoryAdapter {
|
|
3
|
-
captureSnapshot: () => unknown;
|
|
4
|
-
recordIntentTransaction: (descriptor: {
|
|
5
|
-
intent: string;
|
|
6
|
-
label: string;
|
|
7
|
-
affectedRange?: DataGridCopyRange | null;
|
|
8
|
-
}, beforeSnapshot: unknown) => void | Promise<void>;
|
|
9
|
-
canUndo: () => boolean;
|
|
10
|
-
canRedo: () => boolean;
|
|
11
|
-
runHistoryAction: (direction: "undo" | "redo") => Promise<string | null>;
|
|
12
|
-
}
|
|
13
|
-
export interface UseDataGridTableStageHistoryOptions<TRow extends Record<string, unknown>> {
|
|
14
|
-
runtime: Pick<import("@affino/datagrid-vue").UseDataGridRuntimeResult<TRow>, "api" | "syncRowsInRange" | "virtualWindow" | "columnSnapshot">;
|
|
15
|
-
cloneRowData: (row: TRow) => TRow;
|
|
16
|
-
syncViewport: () => void;
|
|
17
|
-
history?: DataGridTableStageHistoryAdapter;
|
|
18
|
-
}
|
|
19
|
-
export interface UseDataGridTableStageHistoryResult {
|
|
20
|
-
captureHistorySnapshot: () => unknown;
|
|
21
|
-
recordHistoryIntentTransaction: (descriptor: {
|
|
22
|
-
intent: string;
|
|
23
|
-
label: string;
|
|
24
|
-
affectedRange?: DataGridCopyRange | null;
|
|
25
|
-
}, beforeSnapshot: unknown) => void;
|
|
26
|
-
canUndoHistory: () => boolean;
|
|
27
|
-
canRedoHistory: () => boolean;
|
|
28
|
-
runHistoryAction: (direction: "undo" | "redo") => Promise<string | null>;
|
|
29
|
-
disposeIntentHistory: () => void;
|
|
30
|
-
}
|
|
31
|
-
export declare function useDataGridTableStageHistory<TRow extends Record<string, unknown>>(options: UseDataGridTableStageHistoryOptions<TRow>): UseDataGridTableStageHistoryResult;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { useDataGridAppIntentHistory } from "@affino/datagrid-vue";
|
|
2
|
-
export function useDataGridTableStageHistory(options) {
|
|
3
|
-
const internalIntentHistory = options.history
|
|
4
|
-
? null
|
|
5
|
-
: useDataGridAppIntentHistory({
|
|
6
|
-
runtime: options.runtime,
|
|
7
|
-
cloneRowData: options.cloneRowData,
|
|
8
|
-
syncViewport: options.syncViewport,
|
|
9
|
-
});
|
|
10
|
-
const captureHistorySnapshot = () => {
|
|
11
|
-
if (options.history) {
|
|
12
|
-
return options.history.captureSnapshot();
|
|
13
|
-
}
|
|
14
|
-
return internalIntentHistory?.captureRowsSnapshot() ?? null;
|
|
15
|
-
};
|
|
16
|
-
const recordHistoryIntentTransaction = (descriptor, beforeSnapshot) => {
|
|
17
|
-
if (options.history) {
|
|
18
|
-
void options.history.recordIntentTransaction(descriptor, beforeSnapshot);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
void internalIntentHistory?.recordIntentTransaction(descriptor, beforeSnapshot);
|
|
22
|
-
};
|
|
23
|
-
const canUndoHistory = () => {
|
|
24
|
-
return options.history ? options.history.canUndo() : (internalIntentHistory?.canUndo.value ?? false);
|
|
25
|
-
};
|
|
26
|
-
const canRedoHistory = () => {
|
|
27
|
-
return options.history ? options.history.canRedo() : (internalIntentHistory?.canRedo.value ?? false);
|
|
28
|
-
};
|
|
29
|
-
const runHistoryAction = (direction) => {
|
|
30
|
-
if (options.history) {
|
|
31
|
-
return options.history.runHistoryAction(direction);
|
|
32
|
-
}
|
|
33
|
-
return internalIntentHistory?.runHistoryAction(direction) ?? Promise.resolve(null);
|
|
34
|
-
};
|
|
35
|
-
const disposeIntentHistory = () => {
|
|
36
|
-
internalIntentHistory?.dispose();
|
|
37
|
-
};
|
|
38
|
-
return {
|
|
39
|
-
captureHistorySnapshot,
|
|
40
|
-
recordHistoryIntentTransaction,
|
|
41
|
-
canUndoHistory,
|
|
42
|
-
canRedoHistory,
|
|
43
|
-
runHistoryAction,
|
|
44
|
-
disposeIntentHistory,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { DataGridColumnSnapshot, DataGridRowId, DataGridRowSelectionSnapshot } from "@affino/datagrid-vue";
|
|
2
|
-
import { type ComputedRef, type Ref } from "vue";
|
|
3
|
-
import type { DataGridCopyRange } from "@affino/datagrid-vue/advanced";
|
|
4
|
-
import type { DataGridTableRow, DataGridTableStageAnchorCell } from "./dataGridTableStage.types";
|
|
5
|
-
export interface UseDataGridTableStageRowSelectionOptions<TRow extends Record<string, unknown>> {
|
|
6
|
-
runtime: Pick<import("@affino/datagrid-vue").UseDataGridRuntimeResult<TRow>, "api">;
|
|
7
|
-
rowSelectionColumn: ComputedRef<DataGridColumnSnapshot | null>;
|
|
8
|
-
orderedVisibleColumns: ComputedRef<readonly DataGridColumnSnapshot[]>;
|
|
9
|
-
displayRows: Ref<readonly DataGridTableRow<TRow>[]>;
|
|
10
|
-
rowSelectionSnapshot: Ref<DataGridRowSelectionSnapshot | null>;
|
|
11
|
-
viewportRowStart: Ref<number>;
|
|
12
|
-
selectionAnchorCell: ComputedRef<DataGridTableStageAnchorCell | null>;
|
|
13
|
-
applySelectionRange: (range: DataGridCopyRange) => void;
|
|
14
|
-
}
|
|
15
|
-
export interface UseDataGridTableStageRowSelectionResult<TRow extends Record<string, unknown>> {
|
|
16
|
-
rowSelectionSet: ComputedRef<Set<DataGridRowId>>;
|
|
17
|
-
isRowFocused: (row: DataGridTableRow<TRow>) => boolean;
|
|
18
|
-
isRowCheckboxSelected: (row: DataGridTableRow<TRow>) => boolean;
|
|
19
|
-
readRowSelectionCell: (row: DataGridTableRow<TRow>) => string;
|
|
20
|
-
readRowSelectionDisplayCell: (row: DataGridTableRow<TRow>) => string;
|
|
21
|
-
areAllVisibleRowsSelected: ComputedRef<boolean>;
|
|
22
|
-
areSomeVisibleRowsSelected: ComputedRef<boolean>;
|
|
23
|
-
focusRow: (row: DataGridTableRow<TRow>) => void;
|
|
24
|
-
toggleRowCheckboxSelected: (row: DataGridTableRow<TRow>) => void;
|
|
25
|
-
toggleVisibleRowsSelected: () => void;
|
|
26
|
-
selectRowRange: (row: DataGridTableRow<TRow>, rowOffset: number, extend: boolean) => void;
|
|
27
|
-
}
|
|
28
|
-
export declare function useDataGridTableStageRowSelection<TRow extends Record<string, unknown>>(options: UseDataGridTableStageRowSelectionOptions<TRow>): UseDataGridTableStageRowSelectionResult<TRow>;
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { buildDataGridCellRenderModel } from "@affino/datagrid-core";
|
|
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 resolveVisibleSelectableRowIds = () => {
|
|
28
|
-
return options.displayRows.value.flatMap(row => {
|
|
29
|
-
if (row.kind === "group" || row.rowId == null) {
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
return [row.rowId];
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
const areAllVisibleRowsSelected = computed(() => {
|
|
36
|
-
const rowIds = resolveVisibleSelectableRowIds();
|
|
37
|
-
return rowIds.length > 0 && rowIds.every(rowId => rowSelectionSet.value.has(rowId));
|
|
38
|
-
});
|
|
39
|
-
const areSomeVisibleRowsSelected = computed(() => {
|
|
40
|
-
const rowIds = resolveVisibleSelectableRowIds();
|
|
41
|
-
return rowIds.some(rowId => rowSelectionSet.value.has(rowId));
|
|
42
|
-
});
|
|
43
|
-
const focusRow = (row) => {
|
|
44
|
-
if (row.rowId == null || !options.runtime.api.rowSelection.hasSupport()) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
options.runtime.api.rowSelection.setFocusedRow(row.rowId);
|
|
48
|
-
};
|
|
49
|
-
const toggleRowCheckboxSelected = (row) => {
|
|
50
|
-
if (row.kind === "group" || row.rowId == null || !options.runtime.api.rowSelection.hasSupport()) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
options.runtime.api.rowSelection.setSelected(row.rowId, !rowSelectionSet.value.has(row.rowId));
|
|
54
|
-
};
|
|
55
|
-
const toggleVisibleRowsSelected = () => {
|
|
56
|
-
if (!options.runtime.api.rowSelection.hasSupport()) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const rowIds = resolveVisibleSelectableRowIds();
|
|
60
|
-
if (!areAllVisibleRowsSelected.value) {
|
|
61
|
-
options.runtime.api.rowSelection.selectRows(rowIds);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
options.runtime.api.rowSelection.deselectRows(rowIds);
|
|
65
|
-
};
|
|
66
|
-
const selectRowRange = (row, rowOffset, extend) => {
|
|
67
|
-
focusRow(row);
|
|
68
|
-
const lastColumnIndex = options.orderedVisibleColumns.value.length - 1;
|
|
69
|
-
if (lastColumnIndex < 0) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
const rowIndex = options.viewportRowStart.value + rowOffset;
|
|
73
|
-
if (!extend) {
|
|
74
|
-
options.applySelectionRange({
|
|
75
|
-
startRow: rowIndex,
|
|
76
|
-
endRow: rowIndex,
|
|
77
|
-
startColumn: 0,
|
|
78
|
-
endColumn: lastColumnIndex,
|
|
79
|
-
});
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const anchorRowIndex = options.selectionAnchorCell.value?.rowIndex ?? rowIndex;
|
|
83
|
-
options.applySelectionRange({
|
|
84
|
-
startRow: Math.min(anchorRowIndex, rowIndex),
|
|
85
|
-
endRow: Math.max(anchorRowIndex, rowIndex),
|
|
86
|
-
startColumn: 0,
|
|
87
|
-
endColumn: lastColumnIndex,
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
return {
|
|
91
|
-
rowSelectionSet,
|
|
92
|
-
isRowFocused,
|
|
93
|
-
isRowCheckboxSelected,
|
|
94
|
-
readRowSelectionCell,
|
|
95
|
-
readRowSelectionDisplayCell,
|
|
96
|
-
areAllVisibleRowsSelected,
|
|
97
|
-
areSomeVisibleRowsSelected,
|
|
98
|
-
focusRow,
|
|
99
|
-
toggleRowCheckboxSelected,
|
|
100
|
-
toggleVisibleRowsSelected,
|
|
101
|
-
selectRowRange,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./stage/useDataGridTableStageRuntime";
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Ref } from "vue";
|
|
2
|
-
export interface UseDataGridTableStageScrollSyncOptions {
|
|
3
|
-
bodyViewportRef: Ref<HTMLElement | null>;
|
|
4
|
-
isColumnResizing: Ref<boolean>;
|
|
5
|
-
applyColumnResizeFromPointer: (clientX: number) => void;
|
|
6
|
-
stopColumnResize: () => void;
|
|
7
|
-
handleInteractionWindowMouseMove: (event: MouseEvent) => void;
|
|
8
|
-
handleInteractionWindowMouseUp: () => void;
|
|
9
|
-
syncViewport: () => void;
|
|
10
|
-
}
|
|
11
|
-
export interface UseDataGridTableStageScrollSyncResult {
|
|
12
|
-
handleWindowMouseMove: (event: MouseEvent) => void;
|
|
13
|
-
handleHeaderWheel: (event: WheelEvent) => void;
|
|
14
|
-
handleHeaderScroll: (event: Event) => void;
|
|
15
|
-
handleWindowMouseUp: () => void;
|
|
16
|
-
}
|
|
17
|
-
export declare function useDataGridTableStageScrollSync(options: UseDataGridTableStageScrollSyncOptions): UseDataGridTableStageScrollSyncResult;
|
|
@@ -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
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, Ref } from "vue";
|
|
2
|
-
import type { DataGridColumnSnapshot, DataGridSelectionSnapshot } from "@affino/datagrid-vue";
|
|
3
|
-
export interface UseDataGridTableStageViewportKeyboardOptions<TRow extends Record<string, unknown>> {
|
|
4
|
-
runtime: Pick<import("@affino/datagrid-vue").UseDataGridRuntimeResult<TRow>, "api">;
|
|
5
|
-
selectionSnapshot: Ref<DataGridSelectionSnapshot | null>;
|
|
6
|
-
totalRows: Ref<number>;
|
|
7
|
-
orderedVisibleColumns: ComputedRef<readonly DataGridColumnSnapshot[]>;
|
|
8
|
-
viewportRowStart: Ref<number>;
|
|
9
|
-
applySelectionRange: (range: {
|
|
10
|
-
startRow: number;
|
|
11
|
-
endRow: number;
|
|
12
|
-
startColumn: number;
|
|
13
|
-
endColumn: number;
|
|
14
|
-
}) => void;
|
|
15
|
-
handleCellKeydown: (event: KeyboardEvent, row: import("@affino/datagrid-vue").DataGridRowNode<TRow>, rowOffset: number, columnIndex: number) => void;
|
|
16
|
-
}
|
|
17
|
-
export interface UseDataGridTableStageViewportKeyboardResult {
|
|
18
|
-
handleViewportKeydown: (event: KeyboardEvent) => void;
|
|
19
|
-
}
|
|
20
|
-
export declare function useDataGridTableStageViewportKeyboard<TRow extends Record<string, unknown>>(options: UseDataGridTableStageViewportKeyboardOptions<TRow>): UseDataGridTableStageViewportKeyboardResult;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export function useDataGridTableStageViewportKeyboard(options) {
|
|
2
|
-
const isViewportOwnedKeyboardEvent = (event) => {
|
|
3
|
-
if (event.ctrlKey || event.metaKey || event.altKey) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
return (event.key.startsWith("Arrow")
|
|
7
|
-
|| event.key === "Home"
|
|
8
|
-
|| event.key === "End"
|
|
9
|
-
|| event.key === "PageUp"
|
|
10
|
-
|| event.key === "PageDown"
|
|
11
|
-
|| event.key === "Tab"
|
|
12
|
-
|| event.key === "Enter"
|
|
13
|
-
|| event.key === " "
|
|
14
|
-
|| event.key === "Spacebar"
|
|
15
|
-
|| event.key === "F2"
|
|
16
|
-
|| event.key === "Escape"
|
|
17
|
-
|| event.key.length === 1);
|
|
18
|
-
};
|
|
19
|
-
const isViewportSelectAllKeyboardEvent = (event) => {
|
|
20
|
-
return (event.ctrlKey || event.metaKey)
|
|
21
|
-
&& !event.altKey
|
|
22
|
-
&& !event.shiftKey
|
|
23
|
-
&& event.key.toLowerCase() === "a";
|
|
24
|
-
};
|
|
25
|
-
const selectAllVisibleCells = () => {
|
|
26
|
-
const lastRowIndex = options.totalRows.value - 1;
|
|
27
|
-
const lastColumnIndex = options.orderedVisibleColumns.value.length - 1;
|
|
28
|
-
if (lastRowIndex < 0 || lastColumnIndex < 0) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
options.applySelectionRange({
|
|
32
|
-
startRow: 0,
|
|
33
|
-
endRow: lastRowIndex,
|
|
34
|
-
startColumn: 0,
|
|
35
|
-
endColumn: lastColumnIndex,
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
const handleViewportKeydown = (event) => {
|
|
39
|
-
if (isViewportOwnedKeyboardEvent(event) || isViewportSelectAllKeyboardEvent(event)) {
|
|
40
|
-
event.preventDefault();
|
|
41
|
-
}
|
|
42
|
-
const activeCell = options.selectionSnapshot.value?.activeCell;
|
|
43
|
-
if (!activeCell) {
|
|
44
|
-
if (isViewportSelectAllKeyboardEvent(event)) {
|
|
45
|
-
selectAllVisibleCells();
|
|
46
|
-
}
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const row = options.runtime.api.rows.get(activeCell.rowIndex);
|
|
50
|
-
if (!row) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
options.handleCellKeydown(event, row, activeCell.rowIndex - options.viewportRowStart.value, activeCell.colIndex);
|
|
54
|
-
};
|
|
55
|
-
return {
|
|
56
|
-
handleViewportKeydown,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type ComputedRef, type Ref } from "vue";
|
|
2
|
-
import type { DataGridCopyRange } from "@affino/datagrid-vue/advanced";
|
|
3
|
-
import type { DataGridPendingEdge, DataGridTableMode, DataGridTableStageAnchorCell } from "./dataGridTableStage.types";
|
|
4
|
-
export interface UseDataGridTableStageVisualSelectionOptions {
|
|
5
|
-
mode: Ref<DataGridTableMode>;
|
|
6
|
-
viewportRowStart: Ref<number>;
|
|
7
|
-
selectionAnchorCell: ComputedRef<DataGridTableStageAnchorCell | null>;
|
|
8
|
-
fillPreviewRange: Ref<DataGridCopyRange | null>;
|
|
9
|
-
isFillDragging: Ref<boolean>;
|
|
10
|
-
interactionSelectionRange: Ref<DataGridCopyRange | null>;
|
|
11
|
-
resolveCommittedSelectionRange: () => DataGridCopyRange | null;
|
|
12
|
-
isCommittedSelectionAnchorCell: (rowOffset: number, columnIndex: number) => boolean;
|
|
13
|
-
isCommittedCellSelected: (rowOffset: number, columnIndex: number) => boolean;
|
|
14
|
-
shouldHighlightCommittedSelectedCell: (rowOffset: number, columnIndex: number) => boolean;
|
|
15
|
-
isCommittedCellOnSelectionEdge: (rowOffset: number, columnIndex: number, edge: DataGridPendingEdge) => boolean;
|
|
16
|
-
}
|
|
17
|
-
export interface UseDataGridTableStageVisualSelectionResult {
|
|
18
|
-
selectionRange: ComputedRef<DataGridCopyRange | null>;
|
|
19
|
-
isSelectionAnchorCell: (rowOffset: number, columnIndex: number) => boolean;
|
|
20
|
-
isCellSelected: (rowOffset: number, columnIndex: number) => boolean;
|
|
21
|
-
shouldHighlightSelectedCell: (rowOffset: number, columnIndex: number) => boolean;
|
|
22
|
-
isCellOnSelectionEdge: (rowOffset: number, columnIndex: number, edge: DataGridPendingEdge) => boolean;
|
|
23
|
-
}
|
|
24
|
-
export declare function useDataGridTableStageVisualSelection(options: UseDataGridTableStageVisualSelectionOptions): UseDataGridTableStageVisualSelectionResult;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { computed } from "vue";
|
|
2
|
-
export function useDataGridTableStageVisualSelection(options) {
|
|
3
|
-
const selectionRange = computed(() => (options.interactionSelectionRange.value ?? options.resolveCommittedSelectionRange()));
|
|
4
|
-
const resolveVisualSelectionRange = () => selectionRange.value;
|
|
5
|
-
const isVisualFillSelectionActive = () => {
|
|
6
|
-
return options.mode.value === "base" && options.isFillDragging.value && Boolean(options.fillPreviewRange.value);
|
|
7
|
-
};
|
|
8
|
-
const isCellWithinRange = (range, rowOffset, columnIndex) => {
|
|
9
|
-
const rowIndex = options.viewportRowStart.value + rowOffset;
|
|
10
|
-
return (rowIndex >= range.startRow
|
|
11
|
-
&& rowIndex <= range.endRow
|
|
12
|
-
&& columnIndex >= range.startColumn
|
|
13
|
-
&& columnIndex <= range.endColumn);
|
|
14
|
-
};
|
|
15
|
-
const isSelectionAnchorCell = (rowOffset, columnIndex) => {
|
|
16
|
-
if (options.selectionAnchorCell.value) {
|
|
17
|
-
return options.selectionAnchorCell.value.rowIndex === options.viewportRowStart.value + rowOffset
|
|
18
|
-
&& options.selectionAnchorCell.value.columnIndex === columnIndex;
|
|
19
|
-
}
|
|
20
|
-
return options.isCommittedSelectionAnchorCell(rowOffset, columnIndex);
|
|
21
|
-
};
|
|
22
|
-
const isCellSelected = (rowOffset, columnIndex) => {
|
|
23
|
-
if (!isVisualFillSelectionActive()) {
|
|
24
|
-
return options.isCommittedCellSelected(rowOffset, columnIndex);
|
|
25
|
-
}
|
|
26
|
-
const range = resolveVisualSelectionRange();
|
|
27
|
-
return range ? isCellWithinRange(range, rowOffset, columnIndex) : false;
|
|
28
|
-
};
|
|
29
|
-
const shouldHighlightSelectedCell = (rowOffset, columnIndex) => {
|
|
30
|
-
if (!isVisualFillSelectionActive()) {
|
|
31
|
-
return options.shouldHighlightCommittedSelectedCell(rowOffset, columnIndex);
|
|
32
|
-
}
|
|
33
|
-
const range = resolveVisualSelectionRange();
|
|
34
|
-
if (!range || !isCellWithinRange(range, rowOffset, columnIndex)) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
const isSingleCell = range.startRow === range.endRow && range.startColumn === range.endColumn;
|
|
38
|
-
if (isSingleCell) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
return !isSelectionAnchorCell(rowOffset, columnIndex);
|
|
42
|
-
};
|
|
43
|
-
const isCellOnSelectionEdge = (rowOffset, columnIndex, edge) => {
|
|
44
|
-
if (!isVisualFillSelectionActive()) {
|
|
45
|
-
return options.isCommittedCellOnSelectionEdge(rowOffset, columnIndex, edge);
|
|
46
|
-
}
|
|
47
|
-
const range = resolveVisualSelectionRange();
|
|
48
|
-
if (!range || !isCellWithinRange(range, rowOffset, columnIndex)) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
const rowIndex = options.viewportRowStart.value + rowOffset;
|
|
52
|
-
switch (edge) {
|
|
53
|
-
case "top":
|
|
54
|
-
return rowIndex === range.startRow;
|
|
55
|
-
case "right":
|
|
56
|
-
return columnIndex === range.endColumn;
|
|
57
|
-
case "bottom":
|
|
58
|
-
return rowIndex === range.endRow;
|
|
59
|
-
case "left":
|
|
60
|
-
return columnIndex === range.startColumn;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
return {
|
|
64
|
-
selectionRange,
|
|
65
|
-
isSelectionAnchorCell,
|
|
66
|
-
isCellSelected,
|
|
67
|
-
shouldHighlightSelectedCell,
|
|
68
|
-
isCellOnSelectionEdge,
|
|
69
|
-
};
|
|
70
|
-
}
|