@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,390 +0,0 @@
|
|
|
1
|
-
import { onBeforeUnmount, watch } from "vue";
|
|
2
|
-
function normalizeWidth(width) {
|
|
3
|
-
if (!Number.isFinite(width)) {
|
|
4
|
-
return null;
|
|
5
|
-
}
|
|
6
|
-
return Math.max(0, Math.trunc(width));
|
|
7
|
-
}
|
|
8
|
-
function createSyncKey(value) {
|
|
9
|
-
try {
|
|
10
|
-
return JSON.stringify(value);
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function cloneGroupBySpec(groupBy) {
|
|
17
|
-
if (!groupBy) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
fields: [...groupBy.fields],
|
|
22
|
-
expandedByDefault: groupBy.expandedByDefault,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export function useDataGridAppControlledState(options) {
|
|
26
|
-
let unsubscribeRowModel = null;
|
|
27
|
-
let unsubscribeColumnModel = null;
|
|
28
|
-
let scheduledSnapshotEmit = false;
|
|
29
|
-
let lastAppliedColumnInputsKey = null;
|
|
30
|
-
let lastAppliedStateInputKey = null;
|
|
31
|
-
let lastEmittedColumnStateKey = null;
|
|
32
|
-
let lastEmittedUnifiedStateKey = null;
|
|
33
|
-
let lastEmittedGroupByKey = null;
|
|
34
|
-
let lastObservedColumnStateKey = null;
|
|
35
|
-
let lastObservedUnifiedStateKey = null;
|
|
36
|
-
const disposeSubscriptions = () => {
|
|
37
|
-
unsubscribeRowModel?.();
|
|
38
|
-
unsubscribeColumnModel?.();
|
|
39
|
-
unsubscribeRowModel = null;
|
|
40
|
-
unsubscribeColumnModel = null;
|
|
41
|
-
};
|
|
42
|
-
const getColumnState = () => {
|
|
43
|
-
const columnsApi = options.gridRef.value?.api.columns;
|
|
44
|
-
if (!columnsApi) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
const snapshot = columnsApi.getSnapshot();
|
|
48
|
-
const visibility = {};
|
|
49
|
-
const widths = {};
|
|
50
|
-
const pins = {};
|
|
51
|
-
for (const column of snapshot.columns) {
|
|
52
|
-
visibility[column.key] = column.visible;
|
|
53
|
-
widths[column.key] = column.width;
|
|
54
|
-
pins[column.key] = column.pin;
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
order: [...snapshot.order],
|
|
58
|
-
visibility,
|
|
59
|
-
widths,
|
|
60
|
-
pins,
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
const emitSnapshotUpdates = () => {
|
|
64
|
-
if (scheduledSnapshotEmit) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
scheduledSnapshotEmit = true;
|
|
68
|
-
queueMicrotask(() => {
|
|
69
|
-
scheduledSnapshotEmit = false;
|
|
70
|
-
const columnState = getColumnState();
|
|
71
|
-
const api = options.gridRef.value?.api;
|
|
72
|
-
if (columnState) {
|
|
73
|
-
const columnStateKey = createSyncKey(columnState);
|
|
74
|
-
lastObservedColumnStateKey = columnStateKey;
|
|
75
|
-
if (columnStateKey !== lastEmittedColumnStateKey) {
|
|
76
|
-
lastEmittedColumnStateKey = columnStateKey;
|
|
77
|
-
options.emit.columnState(columnState);
|
|
78
|
-
options.emit.columnOrder(columnState.order);
|
|
79
|
-
options.emit.hiddenColumnKeys(Object.entries(columnState.visibility)
|
|
80
|
-
.filter(([, visible]) => !visible)
|
|
81
|
-
.map(([columnKey]) => columnKey));
|
|
82
|
-
options.emit.columnWidths(columnState.widths);
|
|
83
|
-
options.emit.columnPins(columnState.pins);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (api) {
|
|
87
|
-
const groupBy = cloneGroupBySpec(api.rows.getSnapshot().groupBy);
|
|
88
|
-
const groupByKey = createSyncKey(groupBy);
|
|
89
|
-
if (groupByKey !== lastEmittedGroupByKey) {
|
|
90
|
-
lastEmittedGroupByKey = groupByKey;
|
|
91
|
-
options.emit.groupBy(groupBy);
|
|
92
|
-
}
|
|
93
|
-
const unifiedState = api.state.get();
|
|
94
|
-
const unifiedStateKey = createSyncKey(unifiedState);
|
|
95
|
-
lastObservedUnifiedStateKey = unifiedStateKey;
|
|
96
|
-
if (unifiedStateKey !== lastEmittedUnifiedStateKey) {
|
|
97
|
-
lastEmittedUnifiedStateKey = unifiedStateKey;
|
|
98
|
-
options.emit.state(unifiedState);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
const syncSortAndFilterModel = () => {
|
|
104
|
-
const api = options.gridRef.value?.api;
|
|
105
|
-
if (!api || (options.props.sortModel === undefined && options.props.filterModel === undefined)) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
api.rows.setSortAndFilterModel({
|
|
109
|
-
sortModel: options.props.sortModel ?? [],
|
|
110
|
-
filterModel: options.props.filterModel ?? null,
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
const syncGroupBy = () => {
|
|
114
|
-
const api = options.gridRef.value?.api;
|
|
115
|
-
if (!api || options.props.groupBy === undefined) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
api.rows.setGroupBy(options.props.groupBy ?? null);
|
|
119
|
-
};
|
|
120
|
-
const syncAggregationModel = () => {
|
|
121
|
-
const api = options.gridRef.value?.api;
|
|
122
|
-
if (!api || options.props.aggregationModel === undefined) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
api.rows.setAggregationModel(options.props.aggregationModel ?? null);
|
|
126
|
-
};
|
|
127
|
-
const syncPivotModel = () => {
|
|
128
|
-
const api = options.gridRef.value?.api;
|
|
129
|
-
if (!api || options.props.pivotModel === undefined) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
api.pivot.setModel(options.props.pivotModel ?? null);
|
|
133
|
-
};
|
|
134
|
-
const syncColumnState = () => {
|
|
135
|
-
const api = options.gridRef.value?.api;
|
|
136
|
-
if (!api) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
if (options.props.columnState === undefined &&
|
|
140
|
-
options.props.columnOrder === undefined &&
|
|
141
|
-
options.props.hiddenColumnKeys === undefined &&
|
|
142
|
-
options.props.columnWidths === undefined &&
|
|
143
|
-
options.props.columnPins === undefined) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
const columnInputsKey = createSyncKey({
|
|
147
|
-
columnState: options.props.columnState,
|
|
148
|
-
columnOrder: options.props.columnOrder,
|
|
149
|
-
hiddenColumnKeys: options.props.hiddenColumnKeys,
|
|
150
|
-
columnWidths: options.props.columnWidths,
|
|
151
|
-
columnPins: options.props.columnPins,
|
|
152
|
-
});
|
|
153
|
-
if (columnInputsKey === lastAppliedColumnInputsKey) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
if (options.props.columnState &&
|
|
157
|
-
!options.props.columnOrder &&
|
|
158
|
-
!options.props.hiddenColumnKeys &&
|
|
159
|
-
!options.props.columnWidths &&
|
|
160
|
-
!options.props.columnPins &&
|
|
161
|
-
createSyncKey(options.props.columnState) === lastObservedColumnStateKey) {
|
|
162
|
-
lastAppliedColumnInputsKey = columnInputsKey;
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
if (options.props.columnState) {
|
|
166
|
-
api.columns.setOrder(options.props.columnState.order);
|
|
167
|
-
for (const [columnKey, visible] of Object.entries(options.props.columnState.visibility)) {
|
|
168
|
-
api.columns.setVisibility(columnKey, visible);
|
|
169
|
-
}
|
|
170
|
-
for (const [columnKey, width] of Object.entries(options.props.columnState.widths)) {
|
|
171
|
-
api.columns.setWidth(columnKey, normalizeWidth(width));
|
|
172
|
-
}
|
|
173
|
-
for (const [columnKey, pin] of Object.entries(options.props.columnState.pins)) {
|
|
174
|
-
api.columns.setPin(columnKey, pin);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
if (options.props.columnOrder) {
|
|
178
|
-
api.columns.setOrder(options.props.columnOrder);
|
|
179
|
-
}
|
|
180
|
-
if (options.props.hiddenColumnKeys) {
|
|
181
|
-
const hidden = new Set(options.props.hiddenColumnKeys);
|
|
182
|
-
const snapshot = api.columns.getSnapshot();
|
|
183
|
-
for (const column of snapshot.columns) {
|
|
184
|
-
api.columns.setVisibility(column.key, !hidden.has(column.key));
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
if (options.props.columnWidths) {
|
|
188
|
-
for (const [columnKey, width] of Object.entries(options.props.columnWidths)) {
|
|
189
|
-
api.columns.setWidth(columnKey, normalizeWidth(width));
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
if (options.props.columnPins) {
|
|
193
|
-
for (const [columnKey, pin] of Object.entries(options.props.columnPins)) {
|
|
194
|
-
api.columns.setPin(columnKey, pin);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
lastAppliedColumnInputsKey = columnInputsKey;
|
|
198
|
-
};
|
|
199
|
-
const syncUnifiedState = () => {
|
|
200
|
-
const api = options.gridRef.value?.api;
|
|
201
|
-
if (!api || options.props.state == null) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
const stateInputKey = createSyncKey(options.props.state);
|
|
205
|
-
if (stateInputKey === lastAppliedStateInputKey) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
if (stateInputKey === lastObservedUnifiedStateKey) {
|
|
209
|
-
lastAppliedStateInputKey = stateInputKey;
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
const migrated = api.state.migrate(options.props.state, { strict: options.props.stateOptions?.strict });
|
|
213
|
-
if (!migrated) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
api.state.set(migrated, options.props.stateOptions ?? {});
|
|
217
|
-
lastAppliedStateInputKey = stateInputKey;
|
|
218
|
-
};
|
|
219
|
-
const syncRowHeight = () => {
|
|
220
|
-
const api = options.gridRef.value?.api;
|
|
221
|
-
if (!api) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
api.view.setRowHeightMode(options.props.rowHeightMode);
|
|
225
|
-
api.view.setBaseRowHeight(Math.max(24, Math.trunc(options.props.baseRowHeight)));
|
|
226
|
-
};
|
|
227
|
-
const handleGridReady = () => {
|
|
228
|
-
const grid = options.gridRef.value;
|
|
229
|
-
if (!grid) {
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
lastAppliedColumnInputsKey = null;
|
|
233
|
-
lastAppliedStateInputKey = null;
|
|
234
|
-
disposeSubscriptions();
|
|
235
|
-
unsubscribeRowModel = grid.rowModel.subscribe(() => {
|
|
236
|
-
emitSnapshotUpdates();
|
|
237
|
-
});
|
|
238
|
-
unsubscribeColumnModel = grid.columnModel.subscribe(() => {
|
|
239
|
-
emitSnapshotUpdates();
|
|
240
|
-
});
|
|
241
|
-
syncUnifiedState();
|
|
242
|
-
syncColumnState();
|
|
243
|
-
syncSortAndFilterModel();
|
|
244
|
-
syncGroupBy();
|
|
245
|
-
syncAggregationModel();
|
|
246
|
-
syncPivotModel();
|
|
247
|
-
syncRowHeight();
|
|
248
|
-
emitSnapshotUpdates();
|
|
249
|
-
options.emit.ready({ api: grid.api });
|
|
250
|
-
};
|
|
251
|
-
const getState = () => {
|
|
252
|
-
return options.gridRef.value?.api.state.get() ?? null;
|
|
253
|
-
};
|
|
254
|
-
const migrateState = (state, migrateOptions) => {
|
|
255
|
-
return options.gridRef.value?.api.state.migrate(state, migrateOptions) ?? null;
|
|
256
|
-
};
|
|
257
|
-
const applyColumnState = (columnState) => {
|
|
258
|
-
const api = options.gridRef.value?.api;
|
|
259
|
-
if (!api) {
|
|
260
|
-
return false;
|
|
261
|
-
}
|
|
262
|
-
lastAppliedColumnInputsKey = createSyncKey({
|
|
263
|
-
columnState,
|
|
264
|
-
columnOrder: null,
|
|
265
|
-
hiddenColumnKeys: null,
|
|
266
|
-
columnWidths: null,
|
|
267
|
-
columnPins: null,
|
|
268
|
-
});
|
|
269
|
-
api.columns.setOrder(columnState.order);
|
|
270
|
-
for (const [columnKey, visible] of Object.entries(columnState.visibility)) {
|
|
271
|
-
api.columns.setVisibility(columnKey, visible);
|
|
272
|
-
}
|
|
273
|
-
for (const [columnKey, width] of Object.entries(columnState.widths)) {
|
|
274
|
-
api.columns.setWidth(columnKey, normalizeWidth(width));
|
|
275
|
-
}
|
|
276
|
-
for (const [columnKey, pin] of Object.entries(columnState.pins)) {
|
|
277
|
-
api.columns.setPin(columnKey, pin);
|
|
278
|
-
}
|
|
279
|
-
emitSnapshotUpdates();
|
|
280
|
-
return true;
|
|
281
|
-
};
|
|
282
|
-
const applyState = (state, setOptions) => {
|
|
283
|
-
const api = options.gridRef.value?.api;
|
|
284
|
-
if (!api) {
|
|
285
|
-
return false;
|
|
286
|
-
}
|
|
287
|
-
const migrated = api.state.migrate(state, { strict: setOptions?.strict });
|
|
288
|
-
if (!migrated) {
|
|
289
|
-
return false;
|
|
290
|
-
}
|
|
291
|
-
api.state.set(migrated, setOptions);
|
|
292
|
-
lastAppliedStateInputKey = createSyncKey(state);
|
|
293
|
-
emitSnapshotUpdates();
|
|
294
|
-
return true;
|
|
295
|
-
};
|
|
296
|
-
const exportPivotLayout = () => {
|
|
297
|
-
return options.gridRef.value?.api.pivot.exportLayout() ?? null;
|
|
298
|
-
};
|
|
299
|
-
const exportPivotInterop = () => {
|
|
300
|
-
return options.gridRef.value?.api.pivot.exportInterop() ?? null;
|
|
301
|
-
};
|
|
302
|
-
const importPivotLayout = (layout, importOptions) => {
|
|
303
|
-
const api = options.gridRef.value?.api;
|
|
304
|
-
if (!api) {
|
|
305
|
-
return false;
|
|
306
|
-
}
|
|
307
|
-
api.pivot.importLayout(layout, importOptions);
|
|
308
|
-
emitSnapshotUpdates();
|
|
309
|
-
return true;
|
|
310
|
-
};
|
|
311
|
-
const expandAllGroups = () => {
|
|
312
|
-
options.gridRef.value?.api.rows.expandAllGroups();
|
|
313
|
-
emitSnapshotUpdates();
|
|
314
|
-
};
|
|
315
|
-
const collapseAllGroups = () => {
|
|
316
|
-
options.gridRef.value?.api.rows.collapseAllGroups();
|
|
317
|
-
emitSnapshotUpdates();
|
|
318
|
-
};
|
|
319
|
-
watch(() => options.gridRef.value, () => {
|
|
320
|
-
handleGridReady();
|
|
321
|
-
}, { immediate: true });
|
|
322
|
-
watch(() => options.props.columns, () => {
|
|
323
|
-
lastAppliedColumnInputsKey = null;
|
|
324
|
-
lastAppliedStateInputKey = null;
|
|
325
|
-
syncUnifiedState();
|
|
326
|
-
syncColumnState();
|
|
327
|
-
emitSnapshotUpdates();
|
|
328
|
-
}, { deep: true });
|
|
329
|
-
watch(() => [options.props.state, options.props.stateOptions], () => {
|
|
330
|
-
syncUnifiedState();
|
|
331
|
-
syncColumnState();
|
|
332
|
-
syncSortAndFilterModel();
|
|
333
|
-
syncGroupBy();
|
|
334
|
-
syncAggregationModel();
|
|
335
|
-
syncPivotModel();
|
|
336
|
-
syncRowHeight();
|
|
337
|
-
emitSnapshotUpdates();
|
|
338
|
-
}, { deep: true });
|
|
339
|
-
watch(() => [
|
|
340
|
-
options.props.columnState,
|
|
341
|
-
options.props.columnOrder,
|
|
342
|
-
options.props.hiddenColumnKeys,
|
|
343
|
-
options.props.columnWidths,
|
|
344
|
-
options.props.columnPins,
|
|
345
|
-
], () => {
|
|
346
|
-
syncColumnState();
|
|
347
|
-
emitSnapshotUpdates();
|
|
348
|
-
}, { deep: true });
|
|
349
|
-
watch(() => [options.props.sortModel, options.props.filterModel], () => {
|
|
350
|
-
syncSortAndFilterModel();
|
|
351
|
-
emitSnapshotUpdates();
|
|
352
|
-
}, { deep: true });
|
|
353
|
-
watch(() => options.props.groupBy, () => {
|
|
354
|
-
syncGroupBy();
|
|
355
|
-
emitSnapshotUpdates();
|
|
356
|
-
}, { deep: true });
|
|
357
|
-
watch(() => options.props.aggregationModel, () => {
|
|
358
|
-
syncAggregationModel();
|
|
359
|
-
emitSnapshotUpdates();
|
|
360
|
-
}, { deep: true });
|
|
361
|
-
watch(() => options.props.pivotModel, () => {
|
|
362
|
-
syncPivotModel();
|
|
363
|
-
emitSnapshotUpdates();
|
|
364
|
-
}, { deep: true });
|
|
365
|
-
watch(() => [options.props.rowHeightMode, options.props.baseRowHeight], () => {
|
|
366
|
-
syncRowHeight();
|
|
367
|
-
emitSnapshotUpdates();
|
|
368
|
-
});
|
|
369
|
-
const dispose = () => {
|
|
370
|
-
disposeSubscriptions();
|
|
371
|
-
};
|
|
372
|
-
onBeforeUnmount(() => {
|
|
373
|
-
dispose();
|
|
374
|
-
});
|
|
375
|
-
return {
|
|
376
|
-
emitSnapshotUpdates,
|
|
377
|
-
handleGridReady,
|
|
378
|
-
dispose,
|
|
379
|
-
getColumnState,
|
|
380
|
-
getState,
|
|
381
|
-
migrateState,
|
|
382
|
-
applyColumnState,
|
|
383
|
-
applyState,
|
|
384
|
-
exportPivotLayout,
|
|
385
|
-
exportPivotInterop,
|
|
386
|
-
importPivotLayout,
|
|
387
|
-
expandAllGroups,
|
|
388
|
-
collapseAllGroups,
|
|
389
|
-
};
|
|
390
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { computed, onBeforeUnmount, ref, shallowRef, watch } from "vue";
|
|
2
|
-
import { createClientRowModel, } from "@affino/datagrid-vue";
|
|
3
|
-
function getProjectionStageNow() {
|
|
4
|
-
const performanceApi = globalThis.performance;
|
|
5
|
-
if (performanceApi && typeof performanceApi.now === "function") {
|
|
6
|
-
return performanceApi.now();
|
|
7
|
-
}
|
|
8
|
-
return Date.now();
|
|
9
|
-
}
|
|
10
|
-
const defaultProjectionStageTimer = (_stage, run) => {
|
|
11
|
-
const startedAt = getProjectionStageNow();
|
|
12
|
-
const result = run();
|
|
13
|
-
return {
|
|
14
|
-
result,
|
|
15
|
-
duration: Math.max(0, getProjectionStageNow() - startedAt),
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
function resolveClientRowModelOptions(value) {
|
|
19
|
-
return {
|
|
20
|
-
projectionStageTimer: defaultProjectionStageTimer,
|
|
21
|
-
...(value ?? {}),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export function useDataGridAppRowModel(options) {
|
|
25
|
-
const dataGridInstanceKey = ref(0);
|
|
26
|
-
const fallbackRowModel = createClientRowModel();
|
|
27
|
-
const internalRowModel = shallowRef(options.rowModel.value
|
|
28
|
-
? null
|
|
29
|
-
: createClientRowModel({
|
|
30
|
-
rows: options.rows.value,
|
|
31
|
-
...resolveClientRowModelOptions(options.clientRowModelOptions.value),
|
|
32
|
-
}));
|
|
33
|
-
const disposeOwnedRowModel = (model) => {
|
|
34
|
-
if (!model || model === options.rowModel.value) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if ("dispose" in model && typeof model.dispose === "function") {
|
|
38
|
-
model.dispose();
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const recreateInternalRowModel = () => {
|
|
42
|
-
if (options.rowModel.value) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
disposeOwnedRowModel(internalRowModel.value);
|
|
46
|
-
internalRowModel.value = createClientRowModel({
|
|
47
|
-
rows: options.rows.value,
|
|
48
|
-
...resolveClientRowModelOptions(options.clientRowModelOptions.value),
|
|
49
|
-
});
|
|
50
|
-
dataGridInstanceKey.value += 1;
|
|
51
|
-
options.onOwnedRowModelRecreated?.();
|
|
52
|
-
};
|
|
53
|
-
const resolvedRowModel = computed(() => {
|
|
54
|
-
return options.rowModel.value ?? internalRowModel.value ?? fallbackRowModel;
|
|
55
|
-
});
|
|
56
|
-
watch(options.rows, nextRows => {
|
|
57
|
-
if (!internalRowModel.value) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
internalRowModel.value.setRows(nextRows);
|
|
61
|
-
}, { deep: false });
|
|
62
|
-
watch(options.clientRowModelOptions, () => {
|
|
63
|
-
recreateInternalRowModel();
|
|
64
|
-
}, { deep: true });
|
|
65
|
-
watch(options.rowModel, nextRowModel => {
|
|
66
|
-
if (nextRowModel) {
|
|
67
|
-
disposeOwnedRowModel(internalRowModel.value);
|
|
68
|
-
internalRowModel.value = null;
|
|
69
|
-
dataGridInstanceKey.value += 1;
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (!internalRowModel.value) {
|
|
73
|
-
recreateInternalRowModel();
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
onBeforeUnmount(() => {
|
|
77
|
-
disposeOwnedRowModel(internalRowModel.value);
|
|
78
|
-
disposeOwnedRowModel(fallbackRowModel);
|
|
79
|
-
});
|
|
80
|
-
return {
|
|
81
|
-
dataGridInstanceKey,
|
|
82
|
-
resolvedRowModel,
|
|
83
|
-
disposeOwnedRowModel,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./stage/useDataGridTableStageBindings";
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { DataGridColumnSnapshot } from "@affino/datagrid-vue";
|
|
2
|
-
import type { DataGridCopyRange } from "@affino/datagrid-vue/advanced";
|
|
3
|
-
import type { DataGridTableRow } from "./dataGridTableStage.types";
|
|
4
|
-
export interface UseDataGridTableStageCellIoOptions<TRow extends Record<string, unknown>> {
|
|
5
|
-
runtime: Pick<import("@affino/datagrid-vue").UseDataGridRuntimeResult<TRow>, "api">;
|
|
6
|
-
viewportRowStart: import("vue").Ref<number>;
|
|
7
|
-
isRowSelectionColumnKey: (columnKey: string) => boolean;
|
|
8
|
-
isRowSelectionColumn: (column: DataGridColumnSnapshot) => boolean;
|
|
9
|
-
isCellEditableByKey: (row: DataGridTableRow<TRow>, rowIndex: number, columnKey: string, columnIndex: number) => boolean;
|
|
10
|
-
readRowSelectionCell: (row: DataGridTableRow<TRow>) => string;
|
|
11
|
-
readRowSelectionDisplayCell: (row: DataGridTableRow<TRow>) => string;
|
|
12
|
-
readCell: (row: DataGridTableRow<TRow>, columnKey: string) => string;
|
|
13
|
-
readDisplayCell: (row: DataGridTableRow<TRow>, columnKey: string) => string;
|
|
14
|
-
toggleRowCheckboxSelected: (row: DataGridTableRow<TRow>) => void;
|
|
15
|
-
captureHistorySnapshot: () => unknown;
|
|
16
|
-
recordHistoryIntentTransaction: (descriptor: {
|
|
17
|
-
intent: string;
|
|
18
|
-
label: string;
|
|
19
|
-
affectedRange?: DataGridCopyRange | null;
|
|
20
|
-
}, beforeSnapshot: unknown) => void;
|
|
21
|
-
syncViewport: () => void;
|
|
22
|
-
}
|
|
23
|
-
export interface UseDataGridTableStageCellIoResult<TRow extends Record<string, unknown>> {
|
|
24
|
-
readStageCell: (row: DataGridTableRow<TRow>, columnKey: string) => string;
|
|
25
|
-
readStageDisplayCell: (row: DataGridTableRow<TRow>, columnKey: string) => string;
|
|
26
|
-
handleCellClick: (row: DataGridTableRow<TRow>, rowOffset: number, column: DataGridColumnSnapshot, columnIndex: number) => void;
|
|
27
|
-
}
|
|
28
|
-
export declare function useDataGridTableStageCellIo<TRow extends Record<string, unknown>>(options: UseDataGridTableStageCellIoOptions<TRow>): UseDataGridTableStageCellIoResult<TRow>;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { resolveDataGridCellClickAction, toggleDataGridCellValue, } from "@affino/datagrid-core";
|
|
2
|
-
export function useDataGridTableStageCellIo(options) {
|
|
3
|
-
const readStageCell = (row, columnKey) => {
|
|
4
|
-
if (options.isRowSelectionColumnKey(columnKey)) {
|
|
5
|
-
return options.readRowSelectionCell(row);
|
|
6
|
-
}
|
|
7
|
-
return options.readCell(row, columnKey);
|
|
8
|
-
};
|
|
9
|
-
const readStageDisplayCell = (row, columnKey) => {
|
|
10
|
-
if (options.isRowSelectionColumnKey(columnKey)) {
|
|
11
|
-
return options.readRowSelectionDisplayCell(row);
|
|
12
|
-
}
|
|
13
|
-
return options.readDisplayCell(row, columnKey);
|
|
14
|
-
};
|
|
15
|
-
const handleCellClick = (row, rowOffset, column, columnIndex) => {
|
|
16
|
-
if (options.isRowSelectionColumn(column)) {
|
|
17
|
-
options.toggleRowCheckboxSelected(row);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const rowIndex = options.viewportRowStart.value + rowOffset;
|
|
21
|
-
const editable = options.isCellEditableByKey(row, rowIndex, column.key, columnIndex);
|
|
22
|
-
const clickAction = resolveDataGridCellClickAction({
|
|
23
|
-
column: column.column,
|
|
24
|
-
row: row.kind !== "group" ? row.data : undefined,
|
|
25
|
-
editable,
|
|
26
|
-
});
|
|
27
|
-
if (clickAction !== "toggle") {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (row.kind === "group" || row.rowId == null) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const beforeSnapshot = options.captureHistorySnapshot();
|
|
34
|
-
options.runtime.api.rows.applyEdits([
|
|
35
|
-
{
|
|
36
|
-
rowId: row.rowId,
|
|
37
|
-
data: {
|
|
38
|
-
[column.key]: toggleDataGridCellValue({
|
|
39
|
-
column: column.column,
|
|
40
|
-
row: row.data,
|
|
41
|
-
}),
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
]);
|
|
45
|
-
options.recordHistoryIntentTransaction({
|
|
46
|
-
intent: "edit",
|
|
47
|
-
label: `Toggle ${column.key}`,
|
|
48
|
-
affectedRange: {
|
|
49
|
-
startRow: rowIndex,
|
|
50
|
-
endRow: rowIndex,
|
|
51
|
-
startColumn: columnIndex,
|
|
52
|
-
endColumn: columnIndex,
|
|
53
|
-
},
|
|
54
|
-
}, beforeSnapshot);
|
|
55
|
-
options.syncViewport();
|
|
56
|
-
};
|
|
57
|
-
return {
|
|
58
|
-
readStageCell,
|
|
59
|
-
readStageDisplayCell,
|
|
60
|
-
handleCellClick,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type ComputedRef, type Ref } from "vue";
|
|
2
|
-
import type { DataGridColumnSnapshot } from "@affino/datagrid-vue";
|
|
3
|
-
import type { DataGridCellEditablePredicate } from "./dataGridEditability";
|
|
4
|
-
import type { DataGridTableRow } from "./dataGridTableStage.types";
|
|
5
|
-
export interface UseDataGridTableStageColumnsOptions<TRow extends Record<string, unknown>> {
|
|
6
|
-
runtime: Pick<import("@affino/datagrid-vue").UseDataGridRuntimeResult<TRow>, "api">;
|
|
7
|
-
visibleColumns: Ref<readonly DataGridColumnSnapshot[]>;
|
|
8
|
-
isCellEditable?: DataGridCellEditablePredicate<TRow>;
|
|
9
|
-
}
|
|
10
|
-
export interface UseDataGridTableStageColumnsResult<TRow extends Record<string, unknown>> {
|
|
11
|
-
orderedVisibleColumns: ComputedRef<readonly DataGridColumnSnapshot[]>;
|
|
12
|
-
centerColumns: ComputedRef<readonly DataGridColumnSnapshot[]>;
|
|
13
|
-
resolveColumnWidth: (column: DataGridColumnSnapshot) => number;
|
|
14
|
-
stageColumnStyle: (columnKey: string) => Record<string, string>;
|
|
15
|
-
isRowSelectionColumnKey: (columnKey: string) => boolean;
|
|
16
|
-
isRowSelectionColumn: (column: DataGridColumnSnapshot) => boolean;
|
|
17
|
-
isCellEditable: (row: DataGridTableRow<TRow>, rowIndex: number, column: DataGridColumnSnapshot) => boolean;
|
|
18
|
-
isCellEditableByKey: (row: DataGridTableRow<TRow>, rowIndex: number, columnKey: string, columnIndex: number) => boolean;
|
|
19
|
-
rowSelectionColumn: ComputedRef<DataGridColumnSnapshot | null>;
|
|
20
|
-
}
|
|
21
|
-
export declare function useDataGridTableStageColumns<TRow extends Record<string, unknown>>(options: UseDataGridTableStageColumnsOptions<TRow>): UseDataGridTableStageColumnsResult<TRow>;
|