@affino/datagrid-vue-app 0.1.29 → 0.1.31

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
@@ -718,6 +718,90 @@ Supported action keys for `actions` are:
718
718
  - `pinMenu`, `pinLeft`, `pinRight`, `unpin`
719
719
  - `clearFilter`, `addCurrentSelectionToFilter`, `selectAllValues`, `clearAllValues`, `applyFilter`, `cancelFilter`
720
720
 
721
+ ## Declarative Cell Menu
722
+
723
+ `cell-menu` exposes the same native configuration direction as the header menu, so apps can tune the built-in cell context menu without replacing the renderer.
724
+
725
+ ```vue
726
+ <script setup lang="ts">
727
+ import { DataGrid, type DataGridCellMenuProp } from "@affino/datagrid-vue-app"
728
+
729
+ const cellMenu: DataGridCellMenuProp = {
730
+ items: ["clipboard", "pasteSpecial", "edit"],
731
+ labels: {
732
+ pasteSpecial: "Paste special",
733
+ },
734
+ actions: {
735
+ copy: { label: "Copy value" },
736
+ pasteValues: { label: "Values only" },
737
+ },
738
+ customItems: [
739
+ {
740
+ key: "organize",
741
+ label: "Organize",
742
+ placement: "after:pasteSpecial",
743
+ kind: "submenu",
744
+ items: [
745
+ {
746
+ key: "duplicate",
747
+ label: "Duplicate cell",
748
+ onSelect: ({ columnKey, rowId }) => {
749
+ console.log("Duplicate", columnKey, rowId)
750
+ },
751
+ },
752
+ ],
753
+ },
754
+ ],
755
+ columns: {
756
+ owner: {
757
+ customItems: [
758
+ {
759
+ key: "inspect",
760
+ label: "Inspect cell",
761
+ placement: "start",
762
+ onSelect: ({ zone, columnKey, rowId, closeMenu }) => {
763
+ console.log(zone, columnKey, rowId)
764
+ closeMenu()
765
+ },
766
+ },
767
+ ],
768
+ },
769
+ },
770
+ }
771
+ </script>
772
+
773
+ <template>
774
+ <DataGrid
775
+ :rows="rows"
776
+ :columns="columns"
777
+ :cell-menu="cellMenu"
778
+ />
779
+ </template>
780
+ ```
781
+
782
+ Supported built-in cell-menu sections:
783
+
784
+ - `clipboard`: `cut`, `copy`, `paste`
785
+ - `pasteSpecial`: `pasteValues`
786
+ - `edit`: `clear`
787
+
788
+ Supported cell-menu controls:
789
+
790
+ - `items`: choose and order built-in sections (`clipboard`, `pasteSpecial`, `edit`)
791
+ - `disabled`, `disabledReasons`, `labels`
792
+ - `actions`: override built-in action `label`, `hidden`, `disabled`, and `disabledReason`
793
+ - `customItems`: add custom items or nested submenus around the built-in sections
794
+ - `columns[columnKey]`: per-column `items`, `hide`, `disabled`, `disabledReasons`, `labels`, `actions`, and `customItems`
795
+
796
+ Custom cell-menu items support:
797
+
798
+ - `key`, `kind`, `label`, `hidden`, `disabled`, `disabledReason`
799
+ - `placement`: `start`, `end`, `before:clipboard`, `after:clipboard`, `before:pasteSpecial`, `after:pasteSpecial`, `before:edit`, `after:edit`
800
+ - `onSelect(context)`: leaf callbacks receive `{ zone, columnKey, rowId, closeMenu }`
801
+ - `items`: nested submenu entries when `kind: "submenu"`
802
+
803
+ `Paste special -> Values only` uses the same native clipboard pipeline as ordinary paste. When the source copy came from the grid itself, the app runtime can preserve internal semantics instead of degrading to a plain system-clipboard round trip.
804
+
721
805
  Disabled sections and actions can expose a reason string so users see why a menu affordance is unavailable.
722
806
  - `trigger: "button"` disables the standard header `contextmenu` open path while keeping the menu button.
723
807
  - `trigger: "contextmenu"` keeps right-click open on the header cell and hides the button.
@@ -1751,6 +1835,9 @@ Saved views are a thin app-level envelope around unified state plus `viewMode`,
1751
1835
  - `insertRowsAt(index, rows)`
1752
1836
  - `insertRowBefore(rowId, rows)`
1753
1837
  - `insertRowAfter(rowId, rows)`
1838
+ - `runStructuralRowAction(action, rowId)`
1839
+
1840
+ Use `runStructuralRowAction(...)` when row inserts or deletes must be delegated to a higher-level model such as a spreadsheet sheet/workbook that owns structural rewrite semantics. The built-in row-index menu and keyboard shortcuts route through the same entry point before falling back to generic row mutations.
1754
1841
 
1755
1842
  ### Selection
1756
1843
 
@@ -1,5 +1,6 @@
1
1
  import { type ExtractPublicPropTypes, type PropType, type VNode } from "vue";
2
2
  import { type CreateDataGridCoreOptions, type DataGridApi, type DataGridApiRowSelectionChangedEvent, type DataGridApiSelectionChangedEvent, type DataGridApiPluginDefinition, type DataGridAggregationModel, type DataGridColumnPin, type DataGridComputedFieldDefinition, type DataGridCoreServiceRegistry, type DataGridFilterSnapshot, type DataGridFormulaFieldDefinition, type DataGridFormulaFunctionRegistry, type DataGridGroupBySpec, type DataGridMigrateStateOptions, type DataGridRowNode, type DataGridRowSelectionSnapshot, type DataGridRowModel, type DataGridRowNodeInput, type DataGridSetStateOptions, type DataGridSortState, type DataGridUnifiedColumnState, type DataGridUnifiedState, type DataGridPivotSpec } from "@affino/datagrid-vue";
3
+ import { defineDataGridStructuralRowActionHandler, type DataGridStructuralRowActionHandler, type DataGridStructuralRowActionId } from "./dataGridStructuralRowActions";
3
4
  import type { DataGridBivariantCallback } from "./types/bivariance";
4
5
  import type { DataGridAppToolbarModule } from "./host/DataGridModuleHost";
5
6
  import { type DataGridAppClientRowModelOptions, type DataGridAppColumnInput } from "./config/dataGridFormulaOptions";
@@ -35,6 +36,7 @@ export type DataGridFilterCellReader<TRow = unknown> = DataGridBivariantCallback
35
36
  ], unknown>;
36
37
  export declare function defineDataGridSelectionCellReader<TRow = unknown>(): <TReader extends DataGridSelectionCellReader<TRow>>(reader: TReader) => TReader;
37
38
  export declare function defineDataGridFilterCellReader<TRow = unknown>(): <TReader extends DataGridFilterCellReader<TRow>>(reader: TReader) => TReader;
39
+ export { defineDataGridStructuralRowActionHandler };
38
40
  declare const dataGridProps: {
39
41
  readonly rows: {
40
42
  readonly type: PropType<readonly unknown[]>;
@@ -96,6 +98,10 @@ declare const dataGridProps: {
96
98
  readonly type: PropType<DataGridRowIndexMenuProp | undefined>;
97
99
  readonly default: undefined;
98
100
  };
101
+ readonly runStructuralRowAction: {
102
+ readonly type: PropType<DataGridStructuralRowActionHandler<Record<string, unknown>> | undefined>;
103
+ readonly default: undefined;
104
+ };
99
105
  readonly columnLayout: {
100
106
  readonly type: PropType<DataGridColumnLayoutProp | undefined>;
101
107
  readonly default: undefined;
@@ -296,6 +302,7 @@ export interface DataGridExposed<TRow = unknown> {
296
302
  getHistory: () => DataGridHistoryController;
297
303
  getApi: () => DataGridApi<TRow> | null;
298
304
  getSelectionAggregatesLabel: () => string;
305
+ runStructuralRowAction: (action: DataGridStructuralRowActionId, rowId: string | number) => Promise<boolean>;
299
306
  getState: () => DataGridUnifiedState<TRow> | null;
300
307
  getSavedView: () => DataGridSavedViewSnapshot<TRow & Record<string, unknown>> | null;
301
308
  migrateSavedView: (savedView: unknown, options?: DataGridMigrateStateOptions) => DataGridSavedViewSnapshot<TRow & Record<string, unknown>> | null;
@@ -364,6 +371,10 @@ declare const DataGridRuntimeComponent: import("vue").DefineComponent<{
364
371
  readonly type: PropType<DataGridRowIndexMenuProp | undefined>;
365
372
  readonly default: undefined;
366
373
  };
374
+ readonly runStructuralRowAction: {
375
+ readonly type: PropType<DataGridStructuralRowActionHandler<Record<string, unknown>> | undefined>;
376
+ readonly default: undefined;
377
+ };
367
378
  readonly columnLayout: {
368
379
  readonly type: PropType<DataGridColumnLayoutProp | undefined>;
369
380
  readonly default: undefined;
@@ -624,6 +635,10 @@ declare const DataGridRuntimeComponent: import("vue").DefineComponent<{
624
635
  readonly type: PropType<DataGridRowIndexMenuProp | undefined>;
625
636
  readonly default: undefined;
626
637
  };
638
+ readonly runStructuralRowAction: {
639
+ readonly type: PropType<DataGridStructuralRowActionHandler<Record<string, unknown>> | undefined>;
640
+ readonly default: undefined;
641
+ };
627
642
  readonly columnLayout: {
628
643
  readonly type: PropType<DataGridColumnLayoutProp | undefined>;
629
644
  readonly default: undefined;
@@ -866,6 +881,7 @@ declare const DataGridRuntimeComponent: import("vue").DefineComponent<{
866
881
  readonly viewMode: DataGridAppViewMode | undefined;
867
882
  readonly toolbarModules: readonly DataGridAppToolbarModule[];
868
883
  readonly history: DataGridHistoryProp | undefined;
884
+ readonly runStructuralRowAction: DataGridStructuralRowActionHandler<Record<string, unknown>> | undefined;
869
885
  readonly pageSize: number | undefined;
870
886
  readonly currentPage: number | undefined;
871
887
  readonly startupOrder: readonly import("@affino/datagrid-core").DataGridCoreServiceName[] | undefined;
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as _n, computed as d, ref as b, watch as fe, nextTick as Pt, onMounted as xn, onBeforeUnmount as En, openBlock as De, createElementBlock as We, createElementVNode as F, normalizeStyle as oe, createVNode as Cn, mergeProps as Ln, unref as Bn, createCommentVNode as Hn } from "vue";
2
- import { o as Gn, q as Vn, r as An, _ as Nn } from "./DataGridTableStage.vue_vue_type_script_setup_true_lang-Bg0_YlVn.js";
2
+ import { o as Gn, q as Vn, r as An, _ as Nn } from "./DataGridTableStage.vue_vue_type_script_setup_true_lang-Q2ri6J1V.js";
3
3
  import { resolveDataGridGanttAnalysis as zn, buildDataGridGanttVisibleBars as Fn, buildDataGridGanttDependencyPaths as Xn, resolveDataGridGanttRangeFrame as je, buildDataGridTimelineRenderModels as Dt, resolveDataGridTimelineDateToPixel as Wt, resolveDataGridTimelineScrollLeftForDate as On, applyDataGridGanttDragDelta as $n, hitTestDataGridGanttBar as kt, clampDataGridTimelineScrollLeft as Kn, buildDataGridGanttRowEditPatch as Un } from "@affino/datagrid-gantt";
4
4
  const Me = 0.5, jn = 1.25;
5
5
  function Yn(s) {
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as e, h as r } from "vue";
2
- import { _ as a } from "./DataGridGanttStage.vue_vue_type_script_setup_true_lang-Dsl2y3cS.js";
2
+ import { _ as a } from "./DataGridGanttStage.vue_vue_type_script_setup_true_lang-DJ72Tgpd.js";
3
3
  import { normalizeDataGridGanttOptions as n } from "@affino/datagrid-gantt";
4
4
  const m = e({
5
5
  name: "DataGridGanttStageEntry",