@affino/datagrid-vue-app 0.1.21 → 0.1.23
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/README.md +121 -1
- package/dist/DataGrid.d.ts +10 -0
- package/dist/chunks/{DataGridGanttStageEntry-Def2lt1S.js → DataGridGanttStageEntry-C888labI.js} +2868 -2755
- package/dist/chunks/useDataGridAppRowModel-qRa5om5I.js +3655 -0
- package/dist/dataGridHistory.d.ts +25 -0
- package/dist/gantt.js +1 -1
- package/dist/host/DataGridDefaultRenderer.d.ts +18 -0
- package/dist/host/DataGridHistoryToolbarButton.d.ts +39 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +445 -383
- package/dist/internal.js +2 -2
- package/dist/overlays/DataGridColumnMenu.vue.d.ts +8 -1
- package/dist/overlays/dataGridColumnMenu.d.ts +23 -0
- package/dist/stage/dataGridTableStage.types.d.ts +4 -2
- package/dist/stage/useDataGridTableStageHistory.d.ts +4 -1
- package/dist/stage/useDataGridTableStageRuntime.d.ts +8 -1
- package/package.json +4 -4
- package/dist/chunks/useDataGridAppRowModel-g0AWogvz.js +0 -3498
package/README.md
CHANGED
|
@@ -347,6 +347,83 @@ const toolbarModules: readonly DataGridAppToolbarModule[] = [
|
|
|
347
347
|
Prefer `toolbar-modules` over replacing the whole default slot when the only goal is to extend the built-in toolbar.
|
|
348
348
|
Use the default slot only when you need to take over the entire runtime renderer contract.
|
|
349
349
|
|
|
350
|
+
## Declarative History
|
|
351
|
+
|
|
352
|
+
Enable built-in undo/redo with one prop:
|
|
353
|
+
|
|
354
|
+
```vue
|
|
355
|
+
<DataGrid
|
|
356
|
+
:rows="rows"
|
|
357
|
+
:columns="columns"
|
|
358
|
+
history
|
|
359
|
+
/>
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
The object form lets you control the source, depth, shortcuts, and built-in controls:
|
|
363
|
+
|
|
364
|
+
```vue
|
|
365
|
+
<script setup lang="ts">
|
|
366
|
+
import { ref } from "vue"
|
|
367
|
+
import {
|
|
368
|
+
DataGrid,
|
|
369
|
+
type DataGridHistoryProp,
|
|
370
|
+
type DataGridTableStageHistoryAdapter,
|
|
371
|
+
} from "@affino/datagrid-vue-app"
|
|
372
|
+
|
|
373
|
+
const historyAdapter: DataGridTableStageHistoryAdapter = {
|
|
374
|
+
captureSnapshot: () => null,
|
|
375
|
+
recordIntentTransaction: () => undefined,
|
|
376
|
+
canUndo: () => true,
|
|
377
|
+
canRedo: () => false,
|
|
378
|
+
runHistoryAction: async direction => direction === "undo" ? "intent-1" : null,
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const history: DataGridHistoryProp = {
|
|
382
|
+
depth: 80,
|
|
383
|
+
shortcuts: "window",
|
|
384
|
+
controls: "toolbar",
|
|
385
|
+
adapter: historyAdapter,
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const gridRef = ref<{
|
|
389
|
+
getHistory?: () => {
|
|
390
|
+
runHistoryAction?: (direction: "undo" | "redo") => Promise<string | null>
|
|
391
|
+
}
|
|
392
|
+
} | null>(null)
|
|
393
|
+
|
|
394
|
+
async function undoFromExternalButton() {
|
|
395
|
+
await gridRef.value?.getHistory()?.runHistoryAction("undo")
|
|
396
|
+
}
|
|
397
|
+
</script>
|
|
398
|
+
|
|
399
|
+
<template>
|
|
400
|
+
<button type="button" @click="undoFromExternalButton">
|
|
401
|
+
Undo from external UI
|
|
402
|
+
</button>
|
|
403
|
+
|
|
404
|
+
<DataGrid
|
|
405
|
+
ref="gridRef"
|
|
406
|
+
:rows="rows"
|
|
407
|
+
:columns="columns"
|
|
408
|
+
:history="history"
|
|
409
|
+
/>
|
|
410
|
+
</template>
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
Supported history options:
|
|
414
|
+
|
|
415
|
+
- `enabled`: explicit on/off switch when the object form is used
|
|
416
|
+
- `depth`: max undo depth for recorded transactions/intents
|
|
417
|
+
- `shortcuts`: `false`, `"grid"`, or `"window"`
|
|
418
|
+
- `controls`: `false`, `"toolbar"`, or `"external-only"`
|
|
419
|
+
- `adapter`: provide an external history source instead of the built-in app intent history
|
|
420
|
+
|
|
421
|
+
Notes:
|
|
422
|
+
|
|
423
|
+
- `depth` limits undoable transactions/intents, not raw per-cell keystrokes.
|
|
424
|
+
- When `adapter` is omitted, the app facade falls back to its built-in intent history.
|
|
425
|
+
- The component ref always exposes a stable history controller through `history` and `getHistory()`.
|
|
426
|
+
|
|
350
427
|
## Declarative Column Menu
|
|
351
428
|
|
|
352
429
|
Enable the built-in header menu with one prop:
|
|
@@ -372,6 +449,7 @@ built-in sections instead of replacing the menu renderer.
|
|
|
372
449
|
import { DataGrid, type DataGridColumnMenuProp } from "@affino/datagrid-vue-app"
|
|
373
450
|
|
|
374
451
|
const columnMenu: DataGridColumnMenuProp = {
|
|
452
|
+
trigger: "button+contextmenu",
|
|
375
453
|
items: ["sort", "group", "pin", "filter"],
|
|
376
454
|
disabled: ["pin"],
|
|
377
455
|
disabledReasons: {
|
|
@@ -386,6 +464,16 @@ const columnMenu: DataGridColumnMenuProp = {
|
|
|
386
464
|
clearSort: { hidden: true },
|
|
387
465
|
pinMenu: { disabled: true, disabledReason: "Pinning is managed globally" },
|
|
388
466
|
},
|
|
467
|
+
customItems: [
|
|
468
|
+
{
|
|
469
|
+
key: "insert-left",
|
|
470
|
+
label: "Insert column left",
|
|
471
|
+
placement: "after:group",
|
|
472
|
+
onSelect: ({ columnKey }) => {
|
|
473
|
+
console.log("Insert before", columnKey)
|
|
474
|
+
},
|
|
475
|
+
},
|
|
476
|
+
],
|
|
389
477
|
columns: {
|
|
390
478
|
amount: {
|
|
391
479
|
hide: ["group"],
|
|
@@ -396,6 +484,19 @@ const columnMenu: DataGridColumnMenuProp = {
|
|
|
396
484
|
pinLeft: { label: "Freeze left" },
|
|
397
485
|
},
|
|
398
486
|
},
|
|
487
|
+
owner: {
|
|
488
|
+
customItems: [
|
|
489
|
+
{
|
|
490
|
+
key: "rename",
|
|
491
|
+
label: "Rename column",
|
|
492
|
+
placement: "end",
|
|
493
|
+
onSelect: ({ columnKey, closeMenu }) => {
|
|
494
|
+
console.log("Rename", columnKey)
|
|
495
|
+
closeMenu()
|
|
496
|
+
},
|
|
497
|
+
},
|
|
498
|
+
],
|
|
499
|
+
},
|
|
399
500
|
start: {
|
|
400
501
|
disabled: ["filter"],
|
|
401
502
|
disabledReasons: {
|
|
@@ -417,12 +518,22 @@ const columnMenu: DataGridColumnMenuProp = {
|
|
|
417
518
|
|
|
418
519
|
Supported app-level menu controls:
|
|
419
520
|
|
|
521
|
+
- `trigger`: `button`, `contextmenu`, or `button+contextmenu` (default)
|
|
420
522
|
- `items`: choose and order built-in sections (`sort`, `group`, `pin`, `filter`)
|
|
421
523
|
- `disabled`: force specific built-in sections into a disabled state
|
|
422
524
|
- `disabledReasons`: attach explanatory text to disabled built-in sections
|
|
423
525
|
- `labels`: override built-in section labels
|
|
424
526
|
- `actions`: override built-in action `label`, `hidden`, `disabled`, and `disabledReason` state
|
|
425
|
-
- `
|
|
527
|
+
- `customItems`: add custom menu entries around the built-in sections
|
|
528
|
+
- `columns[columnKey]`: per-column `items`, `hide`, `disabled`, `disabledReasons`, `labels`, `actions`, and `customItems`
|
|
529
|
+
|
|
530
|
+
Custom menu items support:
|
|
531
|
+
|
|
532
|
+
- `key`: stable item id
|
|
533
|
+
- `label`: rendered menu text
|
|
534
|
+
- `placement`: `start`, `end`, `before:sort`, `after:sort`, `before:group`, `after:group`, `before:pin`, `after:pin`, `before:filter`, `after:filter`
|
|
535
|
+
- `hidden`, `disabled`, `disabledReason`
|
|
536
|
+
- `onSelect(context)`: callback with `{ columnKey, columnLabel, closeMenu }`
|
|
426
537
|
|
|
427
538
|
Grouping triggered from the built-in column menu updates the public controlled
|
|
428
539
|
surface through `@update:groupBy` / `v-model:groupBy`.
|
|
@@ -443,6 +554,8 @@ Supported action keys for `actions` are:
|
|
|
443
554
|
- `clearFilter`, `addCurrentSelectionToFilter`, `selectAllValues`, `clearAllValues`, `applyFilter`, `cancelFilter`
|
|
444
555
|
|
|
445
556
|
Disabled sections and actions can expose a reason string so users see why a menu affordance is unavailable.
|
|
557
|
+
- `trigger: "button"` disables the standard header `contextmenu` open path while keeping the menu button.
|
|
558
|
+
- `trigger: "contextmenu"` keeps right-click open on the header cell and hides the button.
|
|
446
559
|
- clause-based advanced filter popover
|
|
447
560
|
- aggregation model popover
|
|
448
561
|
|
|
@@ -1315,6 +1428,13 @@ The component emits:
|
|
|
1315
1428
|
- `getRuntime()`
|
|
1316
1429
|
- `getCore()`
|
|
1317
1430
|
|
|
1431
|
+
### History
|
|
1432
|
+
|
|
1433
|
+
- `history.canUndo()`
|
|
1434
|
+
- `history.canRedo()`
|
|
1435
|
+
- `history.runHistoryAction(direction)`
|
|
1436
|
+
- `getHistory()`
|
|
1437
|
+
|
|
1318
1438
|
### Column state
|
|
1319
1439
|
|
|
1320
1440
|
- `getColumnState()`
|
package/dist/DataGrid.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { type DataGridColumnMenuProp } from "./overlays/dataGridColumnMenu";
|
|
|
14
14
|
import { type DataGridCellMenuProp, type DataGridRowIndexMenuProp } from "./overlays/dataGridContextMenu";
|
|
15
15
|
import { type DataGridVirtualizationProp } from "./config/dataGridVirtualization";
|
|
16
16
|
import type { DataGridCellEditablePredicate } from "./dataGridEditability";
|
|
17
|
+
import { type DataGridHistoryProp } from "./dataGridHistory";
|
|
17
18
|
import type { DataGridAppViewMode, DataGridGanttProp } from "./gantt/dataGridGantt";
|
|
18
19
|
type DataGridRuntimeOverrides = Omit<Partial<DataGridCoreServiceRegistry>, "rowModel" | "columnModel" | "viewport"> & {
|
|
19
20
|
viewport?: DataGridCoreServiceRegistry["viewport"];
|
|
@@ -227,6 +228,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
227
228
|
type: PropType<DataGridGanttProp | undefined>;
|
|
228
229
|
default: undefined;
|
|
229
230
|
};
|
|
231
|
+
history: {
|
|
232
|
+
type: PropType<DataGridHistoryProp | undefined>;
|
|
233
|
+
default: undefined;
|
|
234
|
+
};
|
|
230
235
|
toolbarModules: {
|
|
231
236
|
type: PropType<readonly DataGridAppToolbarModule[]>;
|
|
232
237
|
default: () => never[];
|
|
@@ -458,6 +463,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
458
463
|
type: PropType<DataGridGanttProp | undefined>;
|
|
459
464
|
default: undefined;
|
|
460
465
|
};
|
|
466
|
+
history: {
|
|
467
|
+
type: PropType<DataGridHistoryProp | undefined>;
|
|
468
|
+
default: undefined;
|
|
469
|
+
};
|
|
461
470
|
toolbarModules: {
|
|
462
471
|
type: PropType<readonly DataGridAppToolbarModule[]>;
|
|
463
472
|
default: () => never[];
|
|
@@ -516,6 +525,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
516
525
|
rangeMove: boolean;
|
|
517
526
|
viewMode: DataGridAppViewMode | undefined;
|
|
518
527
|
toolbarModules: readonly DataGridAppToolbarModule[];
|
|
528
|
+
history: DataGridHistoryProp | undefined;
|
|
519
529
|
pageSize: number | undefined;
|
|
520
530
|
currentPage: number | undefined;
|
|
521
531
|
startupOrder: readonly import("@affino/datagrid-core").DataGridCoreServiceName[] | undefined;
|