@affino/datagrid-vue-app 0.1.27 → 0.1.29

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.
Files changed (36) hide show
  1. package/README.md +104 -9
  2. package/dist/DataGrid.d.ts +727 -403
  3. package/dist/DataGridTableStage.vue.d.ts +9 -0
  4. package/dist/advanced-filter.js +1 -1
  5. package/dist/aggregations.js +1 -1
  6. package/dist/chunks/{DataGridAdvancedFilterPopover-C3NQXP09.js → DataGridAdvancedFilterPopover-CXT1rG40.js} +1 -1
  7. package/dist/chunks/{DataGridAdvancedFilterPopover.vue_vue_type_script_setup_true_lang-D8T70_4c.js → DataGridAdvancedFilterPopover.vue_vue_type_script_setup_true_lang-BshOPOFV.js} +1 -1
  8. package/dist/chunks/{DataGridAggregationsPopover-Cc5jl8dA.js → DataGridAggregationsPopover-BRVx8c_y.js} +1 -1
  9. package/dist/chunks/{DataGridAggregationsPopover.vue_vue_type_script_setup_true_lang-DgbgGPYX.js → DataGridAggregationsPopover.vue_vue_type_script_setup_true_lang-CsQpLONh.js} +1 -1
  10. package/dist/chunks/{DataGridFilterableCombobox.vue_vue_type_script_setup_true_lang-_qhryKE2.js → DataGridFilterableCombobox.vue_vue_type_script_setup_true_lang-Dc5SowKk.js} +128 -120
  11. package/dist/chunks/{DataGridGanttStage.vue_vue_type_script_setup_true_lang-uUcd947u.js → DataGridGanttStage.vue_vue_type_script_setup_true_lang-Dsl2y3cS.js} +1 -1
  12. package/dist/chunks/{DataGridGanttStageEntry-Cm-Z--yH.js → DataGridGanttStageEntry-Dtor-tmD.js} +1 -1
  13. package/dist/chunks/DataGridTableStage.vue_vue_type_script_setup_true_lang-Bg0_YlVn.js +8571 -0
  14. package/dist/chunks/useDataGridAppRowModel-BgZKox-k.js +4156 -0
  15. package/dist/config/dataGridColumnReorder.d.ts +7 -0
  16. package/dist/config/dataGridFormulaOptions.d.ts +7 -3
  17. package/dist/dataGridEditability.d.ts +4 -1
  18. package/dist/gantt.js +1 -1
  19. package/dist/host/DataGridDefaultRenderer.d.ts +19 -1
  20. package/dist/index.d.ts +6 -3
  21. package/dist/index.js +896 -799
  22. package/dist/internal.d.ts +3 -1
  23. package/dist/internal.js +35 -34
  24. package/dist/overlays/DataGridColumnMenu.vue.d.ts +3 -1
  25. package/dist/stage/DataGridTableStage.vue.d.ts +10 -1
  26. package/dist/stage/DataGridTableStageCenterPane.vue.d.ts +10 -1
  27. package/dist/stage/DataGridTableStageOverlayLayer.vue.d.ts +37 -28
  28. package/dist/stage/dataGridChromeCanvasMath.d.ts +2 -0
  29. package/dist/stage/dataGridTableStage.types.d.ts +25 -0
  30. package/dist/stage/dataGridTableStageBody.types.d.ts +11 -0
  31. package/dist/stage/useDataGridTableStageRuntime.d.ts +11 -0
  32. package/dist/stage/useDataGridTableStageVisualSelection.d.ts +2 -0
  33. package/dist/types/bivariance.d.ts +3 -0
  34. package/package.json +3 -3
  35. package/dist/chunks/DataGridTableStage.vue_vue_type_script_setup_true_lang-CNQ6W53N.js +0 -8047
  36. package/dist/chunks/useDataGridAppRowModel-B6wKTGdm.js +0 -3965
package/README.md CHANGED
@@ -494,9 +494,9 @@ The object form lets you control the source, depth, shortcuts, and built-in cont
494
494
 
495
495
  ```vue
496
496
  <script setup lang="ts">
497
- import { ref } from "vue"
498
497
  import {
499
498
  DataGrid,
499
+ useDataGridRef,
500
500
  type DataGridHistoryProp,
501
501
  type DataGridTableStageHistoryAdapter,
502
502
  } from "@affino/datagrid-vue-app"
@@ -516,11 +516,13 @@ const history: DataGridHistoryProp = {
516
516
  adapter: historyAdapter,
517
517
  }
518
518
 
519
- const gridRef = ref<{
520
- getHistory?: () => {
521
- runHistoryAction?: (direction: "undo" | "redo") => Promise<string | null>
522
- }
523
- } | null>(null)
519
+ type DemoRow = {
520
+ rowId: string
521
+ owner: string
522
+ amount: number
523
+ }
524
+
525
+ const gridRef = useDataGridRef<DemoRow>()
524
526
 
525
527
  async function undoFromExternalButton() {
526
528
  await gridRef.value?.getHistory()?.runHistoryAction("undo")
@@ -1385,10 +1387,16 @@ Imperative state helpers via `ref`:
1385
1387
 
1386
1388
  ```vue
1387
1389
  <script setup lang="ts">
1388
- import { ref } from "vue"
1389
- import { DataGrid } from "@affino/datagrid-vue-app"
1390
+ import { DataGrid, useDataGridRef } from "@affino/datagrid-vue-app"
1390
1391
 
1391
- const gridRef = ref<InstanceType<typeof DataGrid> | null>(null)
1392
+ type DemoRow = {
1393
+ rowId: string
1394
+ owner: string
1395
+ region: string
1396
+ amount: number
1397
+ }
1398
+
1399
+ const gridRef = useDataGridRef<DemoRow>()
1392
1400
 
1393
1401
  function exportState() {
1394
1402
  return gridRef.value?.getState()
@@ -1454,6 +1462,73 @@ function persistSavedView() {
1454
1462
  </script>
1455
1463
  ```
1456
1464
 
1465
+ ### Typed facade helpers
1466
+
1467
+ When you want row-aware typing to stay explicit across columns, filter/selection readers, imperative refs, and authored `h()` / JSX rendering, use the typed facade helpers exported by `@affino/datagrid-vue-app`.
1468
+
1469
+ ```ts
1470
+ import { h } from "vue"
1471
+ import {
1472
+ defineDataGridColumns,
1473
+ defineDataGridComponent,
1474
+ defineDataGridFilterCellReader,
1475
+ defineDataGridSelectionCellReader,
1476
+ useDataGridRef,
1477
+ } from "@affino/datagrid-vue-app"
1478
+
1479
+ type InvoiceRow = {
1480
+ rowId: string
1481
+ statusCode: "a" | "b"
1482
+ formula: string
1483
+ effectiveAmount: number
1484
+ }
1485
+
1486
+ const TypedDataGrid = defineDataGridComponent<InvoiceRow>()
1487
+
1488
+ const columns = defineDataGridColumns<InvoiceRow>()([
1489
+ {
1490
+ key: "status",
1491
+ field: "statusCode",
1492
+ label: "Status",
1493
+ valueGetter: row => row.statusCode === "a" ? "Active" : "Blocked",
1494
+ },
1495
+ {
1496
+ key: "formula",
1497
+ label: "Formula",
1498
+ },
1499
+ ] as const)
1500
+
1501
+ const readFilterCell = defineDataGridFilterCellReader<InvoiceRow>()((row, columnKey) => {
1502
+ if (columnKey !== "status") {
1503
+ return undefined
1504
+ }
1505
+ return row.data.statusCode === "a" ? "Active" : "Blocked"
1506
+ })
1507
+
1508
+ const readSelectionCell = defineDataGridSelectionCellReader<InvoiceRow>()((row, columnKey) => {
1509
+ if (columnKey !== "formula") {
1510
+ return undefined
1511
+ }
1512
+ return row.data.effectiveAmount
1513
+ })
1514
+
1515
+ const gridRef = useDataGridRef<InvoiceRow>()
1516
+
1517
+ export function renderGrid(rows: readonly InvoiceRow[]) {
1518
+ return h(TypedDataGrid, {
1519
+ ref: gridRef,
1520
+ rows,
1521
+ columns,
1522
+ readFilterCell,
1523
+ readSelectionCell,
1524
+ })
1525
+ }
1526
+ ```
1527
+
1528
+ Use the regular `DataGrid` component directly in template-first SFCs. Reach for `defineDataGridComponent<TRow>()` when you are authoring render functions, JSX, or wrapper components that need one explicit row type carried through the whole facade.
1529
+
1530
+ For a live example, open the sandbox route `/vue/typed-facade-grid`.
1531
+
1457
1532
  ## Column State
1458
1533
 
1459
1534
  Column definitions can also declare `flex` when a center-pane column should absorb the remaining viewport width.
@@ -1588,6 +1663,26 @@ The component emits:
1588
1663
  - The built-in `Column layout`, `Advanced filter`, and `Find / replace` toolbar panels render through the shared Affino overlay host rather than inline in the grid tree.
1589
1664
  - These built-in panels are draggable by their header title area and reopen at the last detached position for the current grid instance during the active page session.
1590
1665
 
1666
+ ## Column Reorder
1667
+
1668
+ Column drag-and-drop is declarative and opt-in.
1669
+
1670
+ - `columnReorder: true` enables drag reorder from header cells
1671
+ - `columnReorder: false` keeps header cells non-draggable
1672
+ - the feature reorders regular visible data columns and can move them across `left` / `center` / `right` pin lanes by dropping onto a target header in that lane
1673
+ - row-selection headers and pivot header layouts do not participate in header drag reorder
1674
+ - after reorder, keyboard navigation continuity stays attached to the moved logical column instead of the previous visual column index
1675
+
1676
+ ```vue
1677
+ <DataGrid
1678
+ :rows="rows"
1679
+ :columns="columns"
1680
+ :column-reorder="true"
1681
+ />
1682
+ ```
1683
+
1684
+ If you only want manual order changes inside the built-in `Columns` panel, leave `columnReorder` unset and keep using `columnLayout`.
1685
+
1591
1686
  ## Row Reorder
1592
1687
 
1593
1688
  Row drag-and-drop is declarative and opt-in.