@affino/datagrid-vue-app 0.1.15 → 0.1.17

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 CHANGED
@@ -1019,6 +1019,8 @@ Supported preset names:
1019
1019
 
1020
1020
  The public component exposes full grid state round-tripping.
1021
1021
 
1022
+ When `state` is the only controlled input, the built-in app toolbar and filter affordances derive their effective sort, filter, grouping, and pivot state from that unified snapshot. You do not need to mirror the same payload back into separate `sort-model`, `filter-model`, `group-by`, or `pivot-model` props just to keep the default renderer synchronized.
1023
+
1022
1024
  Controlled state:
1023
1025
 
1024
1026
  ```vue
@@ -1050,6 +1052,38 @@ function importState(raw: unknown) {
1050
1052
  }
1051
1053
  }
1052
1054
 
1055
+ `applyState()` and `applySavedView()` also queue the restore until the runtime and declared columns are ready. Host pages can restore presets before async column definitions finish loading instead of maintaining a separate pending-saved-view scheduler.
1056
+
1057
+ Saved views sanitize transient transaction history before serialization and restore. The persisted envelope keeps layout, filters, grouping, pivoting, row selection, and `viewMode`, but drops undo/redo history.
1058
+
1059
+ ### Controlled Row Selection
1060
+
1061
+ `rowSelection` still enables the built-in checkbox column and header select-all control. When a page wants to own the selected-row snapshot directly, use `rowSelectionState` with `update:rowSelectionState`.
1062
+
1063
+ ```vue
1064
+ <script setup lang="ts">
1065
+ import { ref } from "vue"
1066
+ import { DataGrid } from "@affino/datagrid-vue-app"
1067
+
1068
+ const rowSelectionState = ref({
1069
+ focusedRow: null,
1070
+ selectedRows: ["r2"],
1071
+ })
1072
+ </script>
1073
+
1074
+ <template>
1075
+ <DataGrid
1076
+ :rows="rows"
1077
+ :columns="columns"
1078
+ row-selection
1079
+ :row-selection-state="rowSelectionState"
1080
+ @update:row-selection-state="rowSelectionState = $event"
1081
+ />
1082
+ </template>
1083
+ ```
1084
+
1085
+ The legacy `row-select` event still exists, but `rowSelectionState` is the stable controlled API when the page wants to bind selected row ids without diffing unified-state updates.
1086
+
1053
1087
  function exportSavedView() {
1054
1088
  return gridRef.value?.getSavedView()
1055
1089
  }
@@ -97,6 +97,10 @@ declare const _default: import("vue").DefineComponent<{
97
97
  type: BooleanConstructor;
98
98
  default: boolean;
99
99
  };
100
+ rowSelectionState: {
101
+ type: PropType<DataGridRowSelectionSnapshot | null | undefined>;
102
+ default: undefined;
103
+ };
100
104
  pageSize: {
101
105
  type: PropType<number | undefined>;
102
106
  default: undefined;
@@ -222,6 +226,7 @@ declare const _default: import("vue").DefineComponent<{
222
226
  "selection-change": (_payload: DataGridApiSelectionChangedEvent) => true;
223
227
  "row-selection-change": (_payload: DataGridApiRowSelectionChangedEvent) => true;
224
228
  "row-select": (_payload: DataGridRowSelectionSnapshot | null) => true;
229
+ "update:rowSelectionState": (_payload: DataGridRowSelectionSnapshot | null) => true;
225
230
  "update:columnState": (_payload: DataGridUnifiedColumnState | null) => true;
226
231
  "update:columnOrder": (_payload: readonly string[] | null) => true;
227
232
  "update:hiddenColumnKeys": (_payload: readonly string[] | null) => true;
@@ -315,6 +320,10 @@ declare const _default: import("vue").DefineComponent<{
315
320
  type: BooleanConstructor;
316
321
  default: boolean;
317
322
  };
323
+ rowSelectionState: {
324
+ type: PropType<DataGridRowSelectionSnapshot | null | undefined>;
325
+ default: undefined;
326
+ };
318
327
  pageSize: {
319
328
  type: PropType<number | undefined>;
320
329
  default: undefined;
@@ -440,6 +449,7 @@ declare const _default: import("vue").DefineComponent<{
440
449
  "onSelection-change"?: ((_payload: DataGridApiSelectionChangedEvent) => any) | undefined;
441
450
  "onRow-selection-change"?: ((_payload: DataGridApiRowSelectionChangedEvent) => any) | undefined;
442
451
  "onRow-select"?: ((_payload: DataGridRowSelectionSnapshot | null) => any) | undefined;
452
+ "onUpdate:rowSelectionState"?: ((_payload: DataGridRowSelectionSnapshot | null) => any) | undefined;
443
453
  "onUpdate:columnState"?: ((_payload: DataGridUnifiedColumnState | null) => any) | undefined;
444
454
  "onUpdate:columnOrder"?: ((_payload: readonly string[] | null) => any) | undefined;
445
455
  "onUpdate:hiddenColumnKeys"?: ((_payload: readonly string[] | null) => any) | undefined;
@@ -464,12 +474,12 @@ declare const _default: import("vue").DefineComponent<{
464
474
  isCellEditable: DataGridCellEditablePredicate<Record<string, unknown>> | undefined;
465
475
  rowSelection: boolean;
466
476
  gantt: DataGridGanttProp | undefined;
467
- virtualization: DataGridVirtualizationProp | undefined;
468
- pagination: DataGridPaginationProp | undefined;
469
477
  rowModel: DataGridRowModel<unknown> | undefined;
470
- aggregations: DataGridAggregationsProp | undefined;
471
478
  baseRowHeight: number;
472
479
  state: DataGridUnifiedState<Record<string, unknown>> | null | undefined;
480
+ virtualization: DataGridVirtualizationProp | undefined;
481
+ pagination: DataGridPaginationProp | undefined;
482
+ aggregations: DataGridAggregationsProp | undefined;
473
483
  sortModel: readonly DataGridSortState[] | undefined;
474
484
  filterModel: DataGridFilterSnapshot | null | undefined;
475
485
  groupBy: DataGridGroupByProp | undefined;
@@ -493,11 +503,12 @@ declare const _default: import("vue").DefineComponent<{
493
503
  plugins: readonly DataGridApiPluginDefinition<unknown>[];
494
504
  services: DataGridRuntimeOverrides | undefined;
495
505
  autoStart: boolean;
506
+ columnState: DataGridUnifiedColumnState | null | undefined;
496
507
  computedFields: readonly DataGridComputedFieldDefinition<unknown>[] | null | undefined;
497
508
  formulas: readonly DataGridFormulaFieldDefinition[] | null | undefined;
498
509
  formulaFunctions: Readonly<Record<string, import("@affino/datagrid-formula-engine").DataGridFormulaFunctionDefinition | ((args: readonly import("@affino/datagrid-formula-engine").DataGridFormulaValue[], context?: import("@affino/datagrid-formula-engine").DataGridComputedFieldComputeContext<unknown>) => unknown)>> | null | undefined;
499
510
  aggregationModel: DataGridAggregationModel<Record<string, unknown>> | null | undefined;
500
- columnState: DataGridUnifiedColumnState | null | undefined;
511
+ rowSelectionState: DataGridRowSelectionSnapshot | null | undefined;
501
512
  columnOrder: readonly string[] | null | undefined;
502
513
  hiddenColumnKeys: readonly string[] | null | undefined;
503
514
  columnWidths: Readonly<Record<string, number | null>> | null | undefined;