@nocopypaste/vue-grid 0.0.0-stage → 0.3.0
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/AGENTS.md +350 -0
- package/CHANGELOG.md +70 -0
- package/README.md +1046 -2
- package/agent/api.json +2453 -0
- package/agent/api.md +648 -0
- package/agent/grid-config.schema.json +654 -0
- package/dist/agent/api.js +2409 -0
- package/dist/agent/api.js.map +1 -0
- package/dist/agent/index.js +8 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/requirements.js +66 -0
- package/dist/agent/requirements.js.map +1 -0
- package/dist/agent/validate.js +185 -0
- package/dist/agent/validate.js.map +1 -0
- package/dist/base.css +1 -0
- package/dist/components/VGrid.js +6 -0
- package/dist/components/VGrid.js.map +1 -0
- package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js +843 -0
- package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridCell.js +6 -0
- package/dist/components/VGridCell.js.map +1 -0
- package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js +167 -0
- package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridCheckbox.js +6 -0
- package/dist/components/VGridCheckbox.js.map +1 -0
- package/dist/components/VGridCheckbox.vue_vue_type_script_setup_true_lang.js +44 -0
- package/dist/components/VGridCheckbox.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridColumnMenu.js +6 -0
- package/dist/components/VGridColumnMenu.js.map +1 -0
- package/dist/components/VGridColumnMenu.vue_vue_type_script_setup_true_lang.js +100 -0
- package/dist/components/VGridColumnMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridFilterInput.js +6 -0
- package/dist/components/VGridFilterInput.js.map +1 -0
- package/dist/components/VGridFilterInput.vue_vue_type_script_setup_true_lang.js +89 -0
- package/dist/components/VGridFilterInput.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridFilterPanel.js +6 -0
- package/dist/components/VGridFilterPanel.js.map +1 -0
- package/dist/components/VGridFilterPanel.vue_vue_type_script_setup_true_lang.js +248 -0
- package/dist/components/VGridFilterPanel.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridFilterPopover.js +6 -0
- package/dist/components/VGridFilterPopover.js.map +1 -0
- package/dist/components/VGridFilterPopover.vue_vue_type_script_setup_true_lang.js +79 -0
- package/dist/components/VGridFilterPopover.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridGroupCells.js +6 -0
- package/dist/components/VGridGroupCells.js.map +1 -0
- package/dist/components/VGridGroupCells.vue_vue_type_script_setup_true_lang.js +181 -0
- package/dist/components/VGridGroupCells.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridGroupRow.js +6 -0
- package/dist/components/VGridGroupRow.js.map +1 -0
- package/dist/components/VGridGroupRow.vue_vue_type_script_setup_true_lang.js +49 -0
- package/dist/components/VGridGroupRow.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridHeader.js +6 -0
- package/dist/components/VGridHeader.js.map +1 -0
- package/dist/components/VGridHeader.vue_vue_type_script_setup_true_lang.js +130 -0
- package/dist/components/VGridHeader.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridMenu.js +6 -0
- package/dist/components/VGridMenu.js.map +1 -0
- package/dist/components/VGridMenu.vue_vue_type_script_setup_true_lang.js +133 -0
- package/dist/components/VGridMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridPagination.js +6 -0
- package/dist/components/VGridPagination.js.map +1 -0
- package/dist/components/VGridPagination.vue_vue_type_script_setup_true_lang.js +102 -0
- package/dist/components/VGridPagination.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridPinnedRows.js +6 -0
- package/dist/components/VGridPinnedRows.js.map +1 -0
- package/dist/components/VGridPinnedRows.vue_vue_type_script_setup_true_lang.js +75 -0
- package/dist/components/VGridPinnedRows.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridResizeHandle.js +6 -0
- package/dist/components/VGridResizeHandle.js.map +1 -0
- package/dist/components/VGridResizeHandle.vue_vue_type_script_setup_true_lang.js +34 -0
- package/dist/components/VGridResizeHandle.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridRows.js +6 -0
- package/dist/components/VGridRows.js.map +1 -0
- package/dist/components/VGridRows.vue_vue_type_script_setup_true_lang.js +191 -0
- package/dist/components/VGridRows.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridSearch.js +6 -0
- package/dist/components/VGridSearch.js.map +1 -0
- package/dist/components/VGridSearch.vue_vue_type_script_setup_true_lang.js +46 -0
- package/dist/components/VGridSearch.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridSelectionBanner.js +6 -0
- package/dist/components/VGridSelectionBanner.js.map +1 -0
- package/dist/components/VGridSelectionBanner.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/components/VGridSelectionBanner.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VGridTotalCell.js +6 -0
- package/dist/components/VGridTotalCell.js.map +1 -0
- package/dist/components/VGridTotalCell.vue_vue_type_script_setup_true_lang.js +74 -0
- package/dist/components/VGridTotalCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/composables/useColumnDrag.js +79 -0
- package/dist/composables/useColumnDrag.js.map +1 -0
- package/dist/composables/useColumnResize.js +68 -0
- package/dist/composables/useColumnResize.js.map +1 -0
- package/dist/composables/useDataSource.js +47 -0
- package/dist/composables/useDataSource.js.map +1 -0
- package/dist/composables/useGridExport.js +135 -0
- package/dist/composables/useGridExport.js.map +1 -0
- package/dist/composables/useGridFilters.js +125 -0
- package/dist/composables/useGridFilters.js.map +1 -0
- package/dist/composables/useGridKeyboard.js +115 -0
- package/dist/composables/useGridKeyboard.js.map +1 -0
- package/dist/composables/useGridMenus.js +234 -0
- package/dist/composables/useGridMenus.js.map +1 -0
- package/dist/composables/useGridSelection.js +138 -0
- package/dist/composables/useGridSelection.js.map +1 -0
- package/dist/composables/usePinnedOffsets.js +61 -0
- package/dist/composables/usePinnedOffsets.js.map +1 -0
- package/dist/composables/usePinnedRows.js +58 -0
- package/dist/composables/usePinnedRows.js.map +1 -0
- package/dist/composables/useRowGrouping.js +103 -0
- package/dist/composables/useRowGrouping.js.map +1 -0
- package/dist/composables/useScrollEdges.js +27 -0
- package/dist/composables/useScrollEdges.js.map +1 -0
- package/dist/composables/useSubRows.js +101 -0
- package/dist/composables/useSubRows.js.map +1 -0
- package/dist/composables/useTotals.js +30 -0
- package/dist/composables/useTotals.js.map +1 -0
- package/dist/composables/useVirtualRows.js +160 -0
- package/dist/composables/useVirtualRows.js.map +1 -0
- package/dist/core/aggregate.js +39 -0
- package/dist/core/aggregate.js.map +1 -0
- package/dist/core/columns.js +106 -0
- package/dist/core/columns.js.map +1 -0
- package/dist/core/csv.js +28 -0
- package/dist/core/csv.js.map +1 -0
- package/dist/core/filter.js +218 -0
- package/dist/core/filter.js.map +1 -0
- package/dist/core/grouping.js +66 -0
- package/dist/core/grouping.js.map +1 -0
- package/dist/core/helpers.js +7 -0
- package/dist/core/helpers.js.map +1 -0
- package/dist/core/pagination.js +25 -0
- package/dist/core/pagination.js.map +1 -0
- package/dist/core/patch.js +41 -0
- package/dist/core/patch.js.map +1 -0
- package/dist/core/selection.js +15 -0
- package/dist/core/selection.js.map +1 -0
- package/dist/core/sort.js +36 -0
- package/dist/core/sort.js.map +1 -0
- package/dist/core/storage.js +36 -0
- package/dist/core/storage.js.map +1 -0
- package/dist/core/value.js +19 -0
- package/dist/core/value.js.map +1 -0
- package/dist/core/virtual.js +83 -0
- package/dist/core/virtual.js.map +1 -0
- package/dist/core.css +1 -0
- package/dist/features/aggregation.js +11 -0
- package/dist/features/aggregation.js.map +1 -0
- package/dist/features/columnGroups.js +9 -0
- package/dist/features/columnGroups.js.map +1 -0
- package/dist/features/columnPinning.js +11 -0
- package/dist/features/columnPinning.js.map +1 -0
- package/dist/features/columnReorder.js +12 -0
- package/dist/features/columnReorder.js.map +1 -0
- package/dist/features/columnResizing.js +11 -0
- package/dist/features/columnResizing.js.map +1 -0
- package/dist/features/columnVisibility.js +9 -0
- package/dist/features/columnVisibility.js.map +1 -0
- package/dist/features/export.js +9 -0
- package/dist/features/export.js.map +1 -0
- package/dist/features/filtering.js +13 -0
- package/dist/features/filtering.js.map +1 -0
- package/dist/features/index.js +42 -0
- package/dist/features/index.js.map +1 -0
- package/dist/features/keyboardNavigation.js +9 -0
- package/dist/features/keyboardNavigation.js.map +1 -0
- package/dist/features/menus.js +11 -0
- package/dist/features/menus.js.map +1 -0
- package/dist/features/pagination.js +9 -0
- package/dist/features/pagination.js.map +1 -0
- package/dist/features/rowGrouping.js +11 -0
- package/dist/features/rowGrouping.js.map +1 -0
- package/dist/features/rowPinning.js +11 -0
- package/dist/features/rowPinning.js.map +1 -0
- package/dist/features/selection.js +13 -0
- package/dist/features/selection.js.map +1 -0
- package/dist/features/serverData.js +9 -0
- package/dist/features/serverData.js.map +1 -0
- package/dist/features/sorting.js +9 -0
- package/dist/features/sorting.js.map +1 -0
- package/dist/features/subGrids.js +9 -0
- package/dist/features/subGrids.js.map +1 -0
- package/dist/features/virtualScrolling.js +9 -0
- package/dist/features/virtualScrolling.js.map +1 -0
- package/dist/index.js +71 -0
- package/dist/internal/RenderSlot.js +6 -0
- package/dist/internal/RenderSlot.js.map +1 -0
- package/dist/internal/anchor.js +41 -0
- package/dist/internal/anchor.js.map +1 -0
- package/dist/internal/clipboard.js +17 -0
- package/dist/internal/clipboard.js.map +1 -0
- package/dist/internal/context.js +11 -0
- package/dist/internal/context.js.map +1 -0
- package/dist/internal/dev.js +8 -0
- package/dist/internal/dev.js.map +1 -0
- package/dist/internal/features.js +9 -0
- package/dist/internal/features.js.map +1 -0
- package/dist/internal/supports.js +10 -0
- package/dist/internal/supports.js.map +1 -0
- package/dist/internal/touchHold.js +43 -0
- package/dist/internal/touchHold.js.map +1 -0
- package/dist/registry/plugin.js +25 -0
- package/dist/registry/plugin.js.map +1 -0
- package/dist/registry/registry.js +15 -0
- package/dist/registry/registry.js.map +1 -0
- package/dist/renderers/ActionButtonCell.js +6 -0
- package/dist/renderers/ActionButtonCell.js.map +1 -0
- package/dist/renderers/ActionButtonCell.vue_vue_type_script_setup_true_lang.js +44 -0
- package/dist/renderers/ActionButtonCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/ActionsMenuCell.js +6 -0
- package/dist/renderers/ActionsMenuCell.js.map +1 -0
- package/dist/renderers/ActionsMenuCell.vue_vue_type_script_setup_true_lang.js +75 -0
- package/dist/renderers/ActionsMenuCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/BooleanCell.js +6 -0
- package/dist/renderers/BooleanCell.js.map +1 -0
- package/dist/renderers/BooleanCell.vue_vue_type_script_setup_true_lang.js +45 -0
- package/dist/renderers/BooleanCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/ButtonGroupCell.js +6 -0
- package/dist/renderers/ButtonGroupCell.js.map +1 -0
- package/dist/renderers/ButtonGroupCell.vue_vue_type_script_setup_true_lang.js +46 -0
- package/dist/renderers/ButtonGroupCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/ChangeCell.js +6 -0
- package/dist/renderers/ChangeCell.js.map +1 -0
- package/dist/renderers/ChangeCell.vue_vue_type_script_setup_true_lang.js +59 -0
- package/dist/renderers/ChangeCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/CheckboxCell.js +6 -0
- package/dist/renderers/CheckboxCell.js.map +1 -0
- package/dist/renderers/CheckboxCell.vue_vue_type_script_setup_true_lang.js +41 -0
- package/dist/renderers/CheckboxCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/ChipCell.js +6 -0
- package/dist/renderers/ChipCell.js.map +1 -0
- package/dist/renderers/ChipCell.vue_vue_type_script_setup_true_lang.js +59 -0
- package/dist/renderers/ChipCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/CodeCell.js +6 -0
- package/dist/renderers/CodeCell.js.map +1 -0
- package/dist/renderers/CodeCell.vue_vue_type_script_setup_true_lang.js +49 -0
- package/dist/renderers/CodeCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/CopyCell.js +6 -0
- package/dist/renderers/CopyCell.js.map +1 -0
- package/dist/renderers/CopyCell.vue_vue_type_script_setup_true_lang.js +51 -0
- package/dist/renderers/CopyCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/CurrencyCell.js +6 -0
- package/dist/renderers/CurrencyCell.js.map +1 -0
- package/dist/renderers/CurrencyCell.vue_vue_type_script_setup_true_lang.js +38 -0
- package/dist/renderers/CurrencyCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/DateCell.js +6 -0
- package/dist/renderers/DateCell.js.map +1 -0
- package/dist/renderers/DateCell.vue_vue_type_script_setup_true_lang.js +30 -0
- package/dist/renderers/DateCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/DateTimeCell.js +6 -0
- package/dist/renderers/DateTimeCell.js.map +1 -0
- package/dist/renderers/DateTimeCell.vue_vue_type_script_setup_true_lang.js +34 -0
- package/dist/renderers/DateTimeCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/DetailsCell.js +6 -0
- package/dist/renderers/DetailsCell.js.map +1 -0
- package/dist/renderers/DetailsCell.vue_vue_type_script_setup_true_lang.js +82 -0
- package/dist/renderers/DetailsCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/EditCell.js +6 -0
- package/dist/renderers/EditCell.js.map +1 -0
- package/dist/renderers/EditCell.vue_vue_type_script_setup_true_lang.js +41 -0
- package/dist/renderers/EditCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/IconCell.js +6 -0
- package/dist/renderers/IconCell.js.map +1 -0
- package/dist/renderers/IconCell.vue_vue_type_script_setup_true_lang.js +39 -0
- package/dist/renderers/IconCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/IconToggleCell.js +6 -0
- package/dist/renderers/IconToggleCell.js.map +1 -0
- package/dist/renderers/IconToggleCell.vue_vue_type_script_setup_true_lang.js +44 -0
- package/dist/renderers/IconToggleCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/ImageCell.js +6 -0
- package/dist/renderers/ImageCell.js.map +1 -0
- package/dist/renderers/ImageCell.vue_vue_type_script_setup_true_lang.js +47 -0
- package/dist/renderers/ImageCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/JsonCell.js +6 -0
- package/dist/renderers/JsonCell.js.map +1 -0
- package/dist/renderers/JsonCell.vue_vue_type_script_setup_true_lang.js +47 -0
- package/dist/renderers/JsonCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/JsonTreeCell.js +6 -0
- package/dist/renderers/JsonTreeCell.js.map +1 -0
- package/dist/renderers/JsonTreeCell.vue_vue_type_script_setup_true_lang.js +56 -0
- package/dist/renderers/JsonTreeCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/JsonTreeNode.js +6 -0
- package/dist/renderers/JsonTreeNode.js.map +1 -0
- package/dist/renderers/JsonTreeNode.vue_vue_type_script_setup_true_lang.js +80 -0
- package/dist/renderers/JsonTreeNode.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/LinkCell.js +6 -0
- package/dist/renderers/LinkCell.js.map +1 -0
- package/dist/renderers/LinkCell.vue_vue_type_script_setup_true_lang.js +63 -0
- package/dist/renderers/LinkCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/ListCell.js +6 -0
- package/dist/renderers/ListCell.js.map +1 -0
- package/dist/renderers/ListCell.vue_vue_type_script_setup_true_lang.js +46 -0
- package/dist/renderers/ListCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/MultiLineCell.js +6 -0
- package/dist/renderers/MultiLineCell.js.map +1 -0
- package/dist/renderers/MultiLineCell.vue_vue_type_script_setup_true_lang.js +102 -0
- package/dist/renderers/MultiLineCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/NumberCell.js +6 -0
- package/dist/renderers/NumberCell.js.map +1 -0
- package/dist/renderers/NumberCell.vue_vue_type_script_setup_true_lang.js +35 -0
- package/dist/renderers/NumberCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/RadioCell.js +6 -0
- package/dist/renderers/RadioCell.js.map +1 -0
- package/dist/renderers/RadioCell.vue_vue_type_script_setup_true_lang.js +43 -0
- package/dist/renderers/RadioCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/StatusCell.js +6 -0
- package/dist/renderers/StatusCell.js.map +1 -0
- package/dist/renderers/StatusCell.vue_vue_type_script_setup_true_lang.js +51 -0
- package/dist/renderers/StatusCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/SwitchCell.js +6 -0
- package/dist/renderers/SwitchCell.js.map +1 -0
- package/dist/renderers/SwitchCell.vue_vue_type_script_setup_true_lang.js +41 -0
- package/dist/renderers/SwitchCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/TextCell.js +6 -0
- package/dist/renderers/TextCell.js.map +1 -0
- package/dist/renderers/TextCell.vue_vue_type_script_setup_true_lang.js +92 -0
- package/dist/renderers/TextCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/ToggleTextCell.js +6 -0
- package/dist/renderers/ToggleTextCell.js.map +1 -0
- package/dist/renderers/ToggleTextCell.vue_vue_type_script_setup_true_lang.js +36 -0
- package/dist/renderers/ToggleTextCell.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/format.js +142 -0
- package/dist/renderers/format.js.map +1 -0
- package/dist/renderers/index.js +199 -0
- package/dist/renderers/index.js.map +1 -0
- package/dist/renderers/options.js +17 -0
- package/dist/renderers/options.js.map +1 -0
- package/dist/renderers/parts/CopyButton.js +6 -0
- package/dist/renderers/parts/CopyButton.js.map +1 -0
- package/dist/renderers/parts/CopyButton.vue_vue_type_script_setup_true_lang.js +37 -0
- package/dist/renderers/parts/CopyButton.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/parts/NumberValue.js +6 -0
- package/dist/renderers/parts/NumberValue.js.map +1 -0
- package/dist/renderers/parts/NumberValue.vue_vue_type_script_setup_true_lang.js +25 -0
- package/dist/renderers/parts/NumberValue.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/parts/ValueBadge.js +6 -0
- package/dist/renderers/parts/ValueBadge.js.map +1 -0
- package/dist/renderers/parts/ValueBadge.vue_vue_type_script_setup_true_lang.js +17 -0
- package/dist/renderers/parts/ValueBadge.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/renderers/parts/icons.js +27 -0
- package/dist/renderers/parts/icons.js.map +1 -0
- package/dist/renderers/parts/routerLink.js +9 -0
- package/dist/renderers/parts/routerLink.js.map +1 -0
- package/dist/renderers/parts/useToggleControl.js +15 -0
- package/dist/renderers/parts/useToggleControl.js.map +1 -0
- package/dist/renderers/plainText.js +34 -0
- package/dist/renderers/plainText.js.map +1 -0
- package/dist/renderers/text.js +10 -0
- package/dist/renderers/text.js.map +1 -0
- package/dist/renderers.css +1 -0
- package/dist/theme.css +1 -0
- package/dist/types/agent/index.d.ts +50 -0
- package/dist/types/agent/requirements.d.ts +17 -0
- package/dist/types/agent/validate.d.ts +33 -0
- package/dist/types/components/VGrid.vue.d.ts +243 -0
- package/dist/types/components/VGridCell.vue.d.ts +19 -0
- package/dist/types/components/VGridCheckbox.vue.d.ts +14 -0
- package/dist/types/components/VGridColumnMenu.vue.d.ts +22 -0
- package/dist/types/components/VGridFilterInput.vue.d.ts +17 -0
- package/dist/types/components/VGridFilterPanel.vue.d.ts +20 -0
- package/dist/types/components/VGridFilterPopover.vue.d.ts +12 -0
- package/dist/types/components/VGridGroupCells.vue.d.ts +14 -0
- package/dist/types/components/VGridGroupRow.vue.d.ts +3 -0
- package/dist/types/components/VGridHeader.vue.d.ts +26 -0
- package/dist/types/components/VGridMenu.vue.d.ts +42 -0
- package/dist/types/components/VGridPagination.vue.d.ts +27 -0
- package/dist/types/components/VGridPinnedRows.vue.d.ts +15 -0
- package/dist/types/components/VGridResizeHandle.vue.d.ts +8 -0
- package/dist/types/components/VGridRows.vue.d.ts +28 -0
- package/dist/types/components/VGridSearch.vue.d.ts +22 -0
- package/dist/types/components/VGridSelectionBanner.vue.d.ts +18 -0
- package/dist/types/components/VGridTotalCell.vue.d.ts +13 -0
- package/dist/types/composables/useColumnDrag.d.ts +26 -0
- package/dist/types/composables/useColumnResize.d.ts +29 -0
- package/dist/types/composables/useDataSource.d.ts +39 -0
- package/dist/types/composables/useGridExport.d.ts +49 -0
- package/dist/types/composables/useGridFilters.d.ts +45 -0
- package/dist/types/composables/useGridKeyboard.d.ts +16 -0
- package/dist/types/composables/useGridMenus.d.ts +63 -0
- package/dist/types/composables/useGridSelection.d.ts +51 -0
- package/dist/types/composables/usePinnedOffsets.d.ts +22 -0
- package/dist/types/composables/usePinnedRows.d.ts +26 -0
- package/dist/types/composables/useRowGrouping.d.ts +50 -0
- package/dist/types/composables/useScrollEdges.d.ts +8 -0
- package/dist/types/composables/useSubRows.d.ts +38 -0
- package/dist/types/composables/useTotals.d.ts +17 -0
- package/dist/types/composables/useVirtualRows.d.ts +74 -0
- package/dist/types/core/aggregate.d.ts +9 -0
- package/dist/types/core/columns.d.ts +35 -0
- package/dist/types/core/csv.d.ts +25 -0
- package/dist/types/core/filter.d.ts +85 -0
- package/dist/types/core/grouping.d.ts +51 -0
- package/dist/types/core/helpers.d.ts +3 -0
- package/dist/types/core/pagination.d.ts +3 -0
- package/dist/types/core/patch.d.ts +23 -0
- package/dist/types/core/selection.d.ts +8 -0
- package/dist/types/core/sort.d.ts +10 -0
- package/dist/types/core/storage.d.ts +6 -0
- package/dist/types/core/value.d.ts +6 -0
- package/dist/types/core/virtual.d.ts +72 -0
- package/dist/types/features/aggregation.d.ts +8 -0
- package/dist/types/features/columnGroups.d.ts +7 -0
- package/dist/types/features/columnPinning.d.ts +7 -0
- package/dist/types/features/columnReorder.d.ts +7 -0
- package/dist/types/features/columnResizing.d.ts +8 -0
- package/dist/types/features/columnVisibility.d.ts +7 -0
- package/dist/types/features/export.d.ts +8 -0
- package/dist/types/features/filtering.d.ts +7 -0
- package/dist/types/features/index.d.ts +22 -0
- package/dist/types/features/keyboardNavigation.d.ts +10 -0
- package/dist/types/features/menus.d.ts +8 -0
- package/dist/types/features/pagination.d.ts +8 -0
- package/dist/types/features/rowGrouping.d.ts +8 -0
- package/dist/types/features/rowPinning.d.ts +8 -0
- package/dist/types/features/selection.d.ts +8 -0
- package/dist/types/features/serverData.d.ts +6 -0
- package/dist/types/features/sorting.d.ts +6 -0
- package/dist/types/features/subGrids.d.ts +6 -0
- package/dist/types/features/virtualScrolling.d.ts +8 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/internal/RenderSlot.d.ts +6 -0
- package/dist/types/internal/anchor.d.ts +18 -0
- package/dist/types/internal/clipboard.d.ts +6 -0
- package/dist/types/internal/context.d.ts +130 -0
- package/dist/types/internal/dev.d.ts +1 -0
- package/dist/types/internal/features.d.ts +24 -0
- package/dist/types/internal/supports.d.ts +11 -0
- package/dist/types/internal/touchHold.d.ts +19 -0
- package/dist/types/registry/plugin.d.ts +18 -0
- package/dist/types/registry/registry.d.ts +18 -0
- package/dist/types/renderers/ActionButtonCell.vue.d.ts +10 -0
- package/dist/types/renderers/ActionsMenuCell.vue.d.ts +10 -0
- package/dist/types/renderers/BooleanCell.vue.d.ts +6 -0
- package/dist/types/renderers/ButtonGroupCell.vue.d.ts +10 -0
- package/dist/types/renderers/ChangeCell.vue.d.ts +6 -0
- package/dist/types/renderers/CheckboxCell.vue.d.ts +10 -0
- package/dist/types/renderers/ChipCell.vue.d.ts +6 -0
- package/dist/types/renderers/CodeCell.vue.d.ts +6 -0
- package/dist/types/renderers/CopyCell.vue.d.ts +10 -0
- package/dist/types/renderers/CurrencyCell.vue.d.ts +10 -0
- package/dist/types/renderers/DateCell.vue.d.ts +6 -0
- package/dist/types/renderers/DateTimeCell.vue.d.ts +6 -0
- package/dist/types/renderers/DetailsCell.vue.d.ts +6 -0
- package/dist/types/renderers/EditCell.vue.d.ts +10 -0
- package/dist/types/renderers/IconCell.vue.d.ts +6 -0
- package/dist/types/renderers/IconToggleCell.vue.d.ts +10 -0
- package/dist/types/renderers/ImageCell.vue.d.ts +6 -0
- package/dist/types/renderers/JsonCell.vue.d.ts +6 -0
- package/dist/types/renderers/JsonTreeCell.vue.d.ts +6 -0
- package/dist/types/renderers/JsonTreeNode.vue.d.ts +14 -0
- package/dist/types/renderers/LinkCell.vue.d.ts +10 -0
- package/dist/types/renderers/ListCell.vue.d.ts +10 -0
- package/dist/types/renderers/MultiLineCell.vue.d.ts +10 -0
- package/dist/types/renderers/NumberCell.vue.d.ts +12 -0
- package/dist/types/renderers/RadioCell.vue.d.ts +10 -0
- package/dist/types/renderers/StatusCell.vue.d.ts +10 -0
- package/dist/types/renderers/SwitchCell.vue.d.ts +10 -0
- package/dist/types/renderers/TextCell.vue.d.ts +10 -0
- package/dist/types/renderers/ToggleTextCell.vue.d.ts +10 -0
- package/dist/types/renderers/format.d.ts +27 -0
- package/dist/types/renderers/index.d.ts +132 -0
- package/dist/types/renderers/options.d.ts +325 -0
- package/dist/types/renderers/parts/CopyButton.vue.d.ts +16 -0
- package/dist/types/renderers/parts/NumberValue.vue.d.ts +12 -0
- package/dist/types/renderers/parts/ValueBadge.vue.d.ts +7 -0
- package/dist/types/renderers/parts/icons.d.ts +21 -0
- package/dist/types/renderers/parts/routerLink.d.ts +7 -0
- package/dist/types/renderers/parts/useToggleControl.d.ts +12 -0
- package/dist/types/renderers/plainText.d.ts +17 -0
- package/dist/types/renderers/text.d.ts +3 -0
- package/dist/types/types.d.ts +461 -0
- package/dist/vue-grid.css +1 -0
- package/llms-full.txt +2052 -0
- package/llms.txt +23 -0
- package/package.json +74 -4
package/README.md
CHANGED
|
@@ -1,3 +1,1047 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @nocopypaste/vue-grid
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A data grid for Vue 3 built on **CSS Grid** — with real `subgrid` sub-rows, pinned columns, column
|
|
4
|
+
reorder/visibility with persistence, selection, virtual scrolling, pagination, a pluggable
|
|
5
|
+
**cell-renderer registry** for 3rd-party addons, and a theme you customise with **CSS variables**.
|
|
6
|
+
|
|
7
|
+
- Vue `^3.5` peer dependency, zero runtime dependencies, fully typed (`<VGrid generic="T">`).
|
|
8
|
+
- Plain CSS in `@layer vue-grid` — your CSS / Tailwind utilities override it without `!important`.
|
|
9
|
+
Published minified (Lightning CSS, no transpiling).
|
|
10
|
+
- Built for big data: virtual scrolling with sub-grids and detail rows, cell-level partial updates,
|
|
11
|
+
a GPU-animated change highlight — see [Performance](#performance).
|
|
12
|
+
- Safe with untrusted row data: no `v-html` / `innerHTML` anywhere. Link renderers allow only
|
|
13
|
+
http(s), mailto and tel, and URLs are checked after the cleanup browsers apply (so `java\tscript:`
|
|
14
|
+
is caught). Value maps ignore inherited keys, and saved state is validated.
|
|
15
|
+
|
|
16
|
+
**New here? Start with the [examples cookbook](../../docs/examples.md)** — runnable snippets for every
|
|
17
|
+
feature. This README is the API reference.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm i @nocopypaste/vue-grid
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The package is built for a bundler (Vite, webpack, Rollup, esbuild, or a framework built on one),
|
|
26
|
+
like Vue's own `esm-bundler` build. Dev-only warnings are wrapped in
|
|
27
|
+
`process.env.NODE_ENV !== 'production'`, which the bundler replaces, so they disappear from
|
|
28
|
+
production builds. Loading the files straight in a browser (an import map or CDN `<script>`, no
|
|
29
|
+
build step) throws `process is not defined`. If you must do that, define it first:
|
|
30
|
+
`<script>window.process = { env: { NODE_ENV: 'production' } }</script>`.
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
// main.ts
|
|
34
|
+
import { createApp } from 'vue'
|
|
35
|
+
import { createVueGrid } from '@nocopypaste/vue-grid'
|
|
36
|
+
import '@nocopypaste/vue-grid/style.css'
|
|
37
|
+
|
|
38
|
+
createApp(App)
|
|
39
|
+
.use(createVueGrid({ locale: 'en-US', currency: 'EUR' })) // optional: app-wide defaults
|
|
40
|
+
.mount('#app')
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Quick start
|
|
44
|
+
|
|
45
|
+
```vue
|
|
46
|
+
<script setup lang="ts">
|
|
47
|
+
import { ref } from 'vue'
|
|
48
|
+
import {
|
|
49
|
+
VGrid,
|
|
50
|
+
createColumnHelper,
|
|
51
|
+
currencyRenderer,
|
|
52
|
+
dateTimeRenderer,
|
|
53
|
+
numberRenderer,
|
|
54
|
+
columnPinningFeature,
|
|
55
|
+
sortingFeature,
|
|
56
|
+
statusRenderer,
|
|
57
|
+
type SortState,
|
|
58
|
+
} from '@nocopypaste/vue-grid'
|
|
59
|
+
|
|
60
|
+
interface Order { id: number; customer: { name: string }; total: number; status: 'Paid' | 'Open'; placedAt: string }
|
|
61
|
+
|
|
62
|
+
const rows = ref<Order[]>([/* … */])
|
|
63
|
+
const sort = ref<SortState | null>(null)
|
|
64
|
+
|
|
65
|
+
const col = createColumnHelper<Order>()
|
|
66
|
+
const columns = [
|
|
67
|
+
col({ key: 'id', header: '#', renderer: numberRenderer, width: 'min-content', pinned: 'left' }),
|
|
68
|
+
col({ key: 'customer', header: 'Customer', field: 'customer.name', sortable: true, width: 'minmax(10rem, 1fr)' }),
|
|
69
|
+
col({ key: 'total', header: 'Total', renderer: currencyRenderer, sortable: true }),
|
|
70
|
+
col({ key: 'status', header: 'Status', renderer: statusRenderer, rendererOptions: { tone: { Paid: 'success', Open: 'info' } } }),
|
|
71
|
+
col({ key: 'placedAt', header: 'Placed', renderer: dateTimeRenderer }),
|
|
72
|
+
]
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<template>
|
|
76
|
+
<VGrid
|
|
77
|
+
v-model:sort="sort"
|
|
78
|
+
:rows="rows"
|
|
79
|
+
:columns="columns"
|
|
80
|
+
row-key="id"
|
|
81
|
+
:features="[sortingFeature, columnPinningFeature]"
|
|
82
|
+
sort-mode="client"
|
|
83
|
+
style="height: 480px"
|
|
84
|
+
/>
|
|
85
|
+
</template>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`createColumnHelper<T>()` is optional; it types each column's `rendererOptions` from its renderer.
|
|
89
|
+
|
|
90
|
+
## Features: everything optional
|
|
91
|
+
|
|
92
|
+
Out of the box `<VGrid>` is a plain, read-only table: columns with any renderer and any width,
|
|
93
|
+
saved column state (`storage`), detail rows, tabbable controls and theming. Everything else is
|
|
94
|
+
an opt-in feature:
|
|
95
|
+
|
|
96
|
+
| Feature | Turns on |
|
|
97
|
+
|---|---|
|
|
98
|
+
| `sortingFeature` | Sort buttons on `sortable` headers, the header menu's sort items, `sort-mode="client"` sorting |
|
|
99
|
+
| `filteringFeature` | Funnels on `filterable` headers, `filter-row`, `<VGridSearch>`, `v-model:filters`, `filter-storage`, the header menu's filter items |
|
|
100
|
+
| `serverDataFeature` | `data-source`: the grid fetches sorted, filtered pages itself |
|
|
101
|
+
| `paginationFeature` | `pagination` and `v-model:page` / `v-model:page-size` (the standalone `<VGridPagination>` doesn't need it) |
|
|
102
|
+
| `selectionFeature` | `selectable` (multi or single), `v-model:selected`, `selection-mode`, `is-row-selectable`, select-all, Space to select, shift-click / Shift+Space ranges, `prune-selection`, the selection in `#toolbar` for batch actions, "select all N matching rows" with server data (`v-model:select-all-matching`) |
|
|
103
|
+
| `subGridsFeature` | `sub-rows` / `load-sub-rows` / `has-sub-rows`: nested rows in a CSS `subgrid` (detail rows don't need it) |
|
|
104
|
+
| `menusFeature` | The header right-click menu (`header-menu`) and body-cell menus (`context-menu`); without it the browser's menu shows. The standalone `<VGridMenu>` and the `actions-menu` renderer don't need it |
|
|
105
|
+
| `columnReorderFeature` | Dragging headers to reorder (mouse and pen; on touch, hold the header first), Alt+←/→ on a header, the header menu's Move items |
|
|
106
|
+
| `columnPinningFeature` | Sticky `pinned: 'left' \| 'right'` columns with edge shadows, the header menu's Pin items; without it pins are ignored |
|
|
107
|
+
| `virtualScrollingFeature` | `virtual: { rowHeight, overscan?, detailHeight? }`: only the rows in view render, sub-grids and detail rows included; without it every row renders |
|
|
108
|
+
| `columnVisibilityFeature` | `hidden: true` columns, `columnState.hidden`, the header menu's Hide column item; without it every column shows |
|
|
109
|
+
| `keyboardNavigationFeature` | The ARIA grid pattern: one Tab stop, arrow keys / Home / End / PageUp / PageDown between cells, Enter, Space to select, →/← to expand, Alt+←/→ to move a column. Without it the grid is an ARIA `table` with its controls in the Tab order |
|
|
110
|
+
| `columnResizingFeature` | Drag a header edge to resize (mouse, pen, touch), double-click it to fit the content, ←/→ on the focused edge (Alt+Shift+←/→ on a header with keyboard navigation); `minWidth` / `maxWidth` bound it, `resizable: false` opts out; widths in `columnState.widths`, persisted with `storage`; Fit width / Reset width in the header menu |
|
|
111
|
+
| `columnGroupsFeature` | Grouped column headers: columns with the same `group` share a header cell in a sticky row above theirs; groups follow reordering, hiding, resizing and pinning (a pin boundary splits a group) |
|
|
112
|
+
| `rowPinningFeature` | `v-model:pinned-rows` / `pinRow()`: rows that stay in view above or below the body, plus `pinned-top-rows` / `pinned-bottom-rows` for rows that aren't in the data |
|
|
113
|
+
| `aggregationFeature` | Column `aggregate` (`sum`, `avg`, `min`, `max`, `count`, a function) and `totals`: a sticky totals row over the filtered rows |
|
|
114
|
+
| `rowGroupingFeature` | `v-model:group-by`: rows grouped by one or more columns into collapsible group rows with the value, row count and aggregates; Group by / Ungroup in the header menu for `groupable` columns |
|
|
115
|
+
| `exportFeature` | `exportCsv()` / `getCsv()` / `copyRows()`, Ctrl/⌘+C for the selected rows or the focused cell, the `copy` event; column `exportValue` / `exportable` |
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
// per grid
|
|
119
|
+
<VGrid :features="[sortingFeature, filteringFeature]" … />
|
|
120
|
+
|
|
121
|
+
// or for every grid in the app (merged with each grid's own list)
|
|
122
|
+
app.use(createVueGrid({ features: [sortingFeature, filteringFeature] }))
|
|
123
|
+
app.use(createVueGrid({ features: allFeatures })) // all of them
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Only the features you import reach your bundle. Without its feature, an option does nothing:
|
|
127
|
+
a `sortable` column is a plain header and `data-source` is never called. In development a warning
|
|
128
|
+
names the feature to add. A grid reads `features` once, when it is created; to change them,
|
|
129
|
+
re-create it (for example with a `:key`).
|
|
130
|
+
|
|
131
|
+
## Tree-shaking: import only what you use
|
|
132
|
+
|
|
133
|
+
The package is ESM, one file per module, with `sideEffects` limited to CSS — bundlers keep only
|
|
134
|
+
what you import.
|
|
135
|
+
|
|
136
|
+
- **Features are opt-in** (see above).
|
|
137
|
+
- **Renderers are opt-in.** `<VGrid>` bundles just the default `text` renderer. Use others either
|
|
138
|
+
- **per column** (recommended, smallest bundle, typed options): `renderer: currencyRenderer`, or
|
|
139
|
+
- **by name**, after registering them: `createVueGrid({ renderers: [currencyRenderer, statusRenderer] })`
|
|
140
|
+
or `<VGrid :renderers="[…]">`, then `renderer: 'currency'`. `allRenderers` registers every built-in.
|
|
141
|
+
An unregistered name renders as plain text and logs a dev warning saying how to register it.
|
|
142
|
+
- **Components and helpers** (`VGridPagination`, `VGridColumnMenu`, `VGridMenu`, `sortRows`, …) are
|
|
143
|
+
only bundled when imported.
|
|
144
|
+
- **CSS**: `@nocopypaste/vue-grid/style.css` has everything. Pick parts instead:
|
|
145
|
+
|
|
146
|
+
| File | What | gzip |
|
|
147
|
+
|---|---|---|
|
|
148
|
+
| `base.css` | Structure only: grid layout, subgrid, sticky header and pins, tree indent, popover placement, virtual rows, pinned rows, truncation | 2.2 kB |
|
|
149
|
+
| `theme.css` | The default look on top of `base.css`: `--vg-*` tokens, colours, dark mode, densities, spacing, borders, typography, shadows, animation | 3.3 kB |
|
|
150
|
+
| `core.css` | `base.css` + `theme.css` | 5.1 kB |
|
|
151
|
+
| `renderers.css` | Styles for the cell renderers (other than text); uses the theme's tokens | 2.2 kB |
|
|
152
|
+
| `style.css` | All of the above | 6.6 kB |
|
|
153
|
+
|
|
154
|
+
For a fully custom look, import only `base.css` (and `renderers.css` if you use renderers)
|
|
155
|
+
and style the `.vg-*` classes yourself. See [Theming](#theming).
|
|
156
|
+
|
|
157
|
+
| Import (minified / gzip, Vue excluded) | Initial chunk |
|
|
158
|
+
|---|---|
|
|
159
|
+
| `VGrid` (no features) | 39.0 kB / 13.6 kB |
|
|
160
|
+
| `VGrid` + `sortingFeature` | 39.8 kB / 13.9 kB |
|
|
161
|
+
| `VGrid` + `filteringFeature` | 49.7 kB / 17.4 kB |
|
|
162
|
+
| `VGrid` + `serverDataFeature` | 40.4 kB / 14.2 kB |
|
|
163
|
+
| `VGrid` + `paginationFeature` | 39.2 kB / 13.7 kB |
|
|
164
|
+
| `VGrid` + `selectionFeature` | 43.2 kB / 15.1 kB |
|
|
165
|
+
| `VGrid` + `subGridsFeature` | 41.4 kB / 14.5 kB |
|
|
166
|
+
| `VGrid` + `menusFeature` | 49.6 kB / 17.2 kB |
|
|
167
|
+
| `VGrid` + `columnReorderFeature` | 42.7 kB / 14.9 kB |
|
|
168
|
+
| `VGrid` + `columnPinningFeature` | 41.2 kB / 14.5 kB |
|
|
169
|
+
| `VGrid` + `virtualScrollingFeature` | 44.8 kB / 15.8 kB |
|
|
170
|
+
| `VGrid` + `columnVisibilityFeature` | 39.2 kB / 13.7 kB |
|
|
171
|
+
| `VGrid` + `keyboardNavigationFeature` | 41.5 kB / 14.5 kB |
|
|
172
|
+
| `VGrid` + `columnResizingFeature` | 41.8 kB / 14.7 kB |
|
|
173
|
+
| `VGrid` + `columnGroupsFeature` | 40.3 kB / 14.1 kB |
|
|
174
|
+
| `VGrid` + `rowPinningFeature` | 44.0 kB / 15.0 kB |
|
|
175
|
+
| `VGrid` + `aggregationFeature` | 44.2 kB / 15.1 kB |
|
|
176
|
+
| `VGrid` + `rowGroupingFeature` | 48.6 kB / 16.4 kB |
|
|
177
|
+
| `VGrid` + `exportFeature` | 42.8 kB / 15.1 kB |
|
|
178
|
+
| `VGrid` + `allFeatures` + `VGridSearch` | 102.8 kB / 34.7 kB |
|
|
179
|
+
| `VGrid` + `currencyRenderer` | 40.4 kB / 14.1 kB |
|
|
180
|
+
| `VGrid` + `VGridPagination` + `VGridColumnMenu` | 45.8 kB / 15.9 kB |
|
|
181
|
+
| `sortRows` only | 0.7 kB / 0.4 kB |
|
|
182
|
+
| `toCsv` only | 1.1 kB / 0.6 kB |
|
|
183
|
+
| everything | 147.4 kB / 47.2 kB |
|
|
184
|
+
| `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) | 63.7 kB / 17.1 kB |
|
|
185
|
+
|
|
186
|
+
With `filteringFeature`, the filter popover body and the filter-row editors are **on-demand
|
|
187
|
+
chunks**: they load the first time a popover opens or `filter-row` is on. With
|
|
188
|
+
`paginationFeature`, the pager is one too, and with `selectionFeature` the "select all N rows" banner.
|
|
189
|
+
|
|
190
|
+
Measured with Rolldown (the bundler in Vite) on tiny apps importing the published build:
|
|
191
|
+
minified, gzipped, Vue external, `process.env.NODE_ENV` set to `production` (which also drops the
|
|
192
|
+
dev warnings). "Initial" counts the entry and every chunk it loads up front; on-demand chunks are
|
|
193
|
+
left out. esbuild with `--splitting` tree-shakes the package too, but also loads the pager's and
|
|
194
|
+
the filter core's chunks (5.2 kB, 2.3 kB gzip) in a grid without those features: esbuild keeps
|
|
195
|
+
chunks that on-demand imports share with the entry, even when nothing uses them.
|
|
196
|
+
|
|
197
|
+
## `<VGrid>` API
|
|
198
|
+
|
|
199
|
+
### Props
|
|
200
|
+
|
|
201
|
+
| Prop | Type | Default | |
|
|
202
|
+
|---|---|---|---|
|
|
203
|
+
| `rows` | `T[]` | `[]` | Your data objects, used as-is (never mutated). Not needed with `dataSource`. |
|
|
204
|
+
| `features` | `GridFeature[]` | — | Opt-in features for this grid, added to the app-wide ones. See [Features](#features-everything-optional). |
|
|
205
|
+
| `dataSource` | `(query, { signal }) => Promise<{ rows, total? }>` | — | Server rows: the grid calls it whenever sort, filters or page change. Needs `serverDataFeature`. See [Server data](#server-data). |
|
|
206
|
+
| `columns` | `ColumnDef<T>[]` | — | See below. |
|
|
207
|
+
| `rowKey` | `keyof T \| (row) => string \| number` | — | Stable unique id; all row state is keyed by it. |
|
|
208
|
+
| `v-model:sort` | `{ key, dir: 'asc' \| 'desc' } \| null` | `null` | Header click cycles asc → desc → none. Needs `sortingFeature` for the header UI. |
|
|
209
|
+
| `sortMode` | `'controlled' \| 'client'` | `'controlled'` | `controlled` only emits (server-side sorting). Ignored with `dataSource`. |
|
|
210
|
+
| `v-model:filters` | `FilterState \| null` | `null` | `{ columns: Record<key, ColumnFilter>, search }`. Needs `filteringFeature` (as do the next four). See [Filtering](#filtering). |
|
|
211
|
+
| `filterMode` | `'client' \| 'controlled'` | `'client'` | `controlled` only emits (server-side filtering). Ignored with `dataSource`. |
|
|
212
|
+
| `filterRow` | `boolean` | `false` | A row of inline filter inputs under the headers. |
|
|
213
|
+
| `filterStorage` | `string \| FilterStateStorage` | — | Persist filters (`string` = localStorage key). |
|
|
214
|
+
| `noMatchText` | `string` | `'No rows match the current filters.'` | Shown, with a *Clear filters* button, when filters hide every row. |
|
|
215
|
+
| `pagination` | `boolean \| { pageSizes?: number[] }` | `false` | Built-in pagination bar: slices client rows, or asks the `dataSource` for pages. Needs `paginationFeature`. |
|
|
216
|
+
| `v-model:page` / `v-model:pageSize` | `number` | `1` / `25` | Reset to page 1 when sort or filters change. |
|
|
217
|
+
| `v-model:columnState` | `{ order: string[]; hidden: string[]; pinned?: Record<string, "left" \| "right" \| null>; widths?: Record<string, string> }` | derived | Column order, visibility and runtime pins. |
|
|
218
|
+
| `storage` | `string \| ColumnStateStorage` | — | Persist column state (`string` = localStorage key). |
|
|
219
|
+
| `v-model:expanded` | `RowKey[]` | `[]` | Expanded rows (sub-grids and detail rows). |
|
|
220
|
+
| `subRows` | `(row) => T[] \| undefined` | — | Synchronous children → sub-grid. Needs `subGridsFeature` (as do the next two). |
|
|
221
|
+
| `loadSubRows` | `(row) => Promise<T[]>` | — | Lazy children (cached, loading/error/retry). |
|
|
222
|
+
| `hasSubRows` | `(row) => boolean` | — | Which rows get an expander when lazy. |
|
|
223
|
+
| `rowExpandable` | `(row) => boolean` | — | Which rows can open the `#detail` slot. |
|
|
224
|
+
| `selectable` | `boolean \| 'single'` | `false` | Adds a selection column. Needs `selectionFeature` (as do the next five). See [Selection and batch actions](#selection-and-batch-actions). |
|
|
225
|
+
| `v-model:selected` | `RowKey[]` | `[]` | |
|
|
226
|
+
| `selectionMode` | `'cascade' \| 'independent'` | `'cascade'` | Whether selecting a parent selects its children. |
|
|
227
|
+
| `isRowSelectable` | `(row) => boolean` | — | |
|
|
228
|
+
| `pruneSelection` | `boolean` | `false` | Drop selected keys whose rows left the data (reload, delete, another server page). |
|
|
229
|
+
| `v-model:selectAllMatching` | `boolean` | `false` | Server data: every row matching the query is selected (from the banner). |
|
|
230
|
+
| `virtual` | `{ rowHeight: number; overscan?: number; detailHeight?: number } \| false` | `false` | Virtual scrolling (fixed-height rows; sub-grids and measured detail rows included). Needs `virtualScrollingFeature`. |
|
|
231
|
+
| `v-model:pinnedRows` | `{ top?: RowKey[]; bottom?: RowKey[] } \| null` | `null` | Top-level rows pinned above / below the body. Needs `rowPinningFeature` (as do the next two). See [Pinned rows and totals](#pinned-rows-and-totals). |
|
|
232
|
+
| `pinnedTopRows` / `pinnedBottomRows` | `T[]` | — | Extra pinned rows that aren't part of `rows` (a target, last year's figures). |
|
|
233
|
+
| `totals` | `boolean \| 'top' \| 'bottom'` | `false` | A totals row with each column's `aggregate`; `true` = `'bottom'`. Needs `aggregationFeature` (as do the next two). |
|
|
234
|
+
| `totalsLabel` | `string` | `'Total'` | Shown in the totals row's first column (unless that column has an aggregate). |
|
|
235
|
+
| `aggregates` | `Record<string, unknown>` | — | Totals by column key, used instead of computing them (e.g. from a server). |
|
|
236
|
+
| `v-model:groupBy` | `string[] \| string \| null` | `null` | Column keys to group the rows by, outermost first. Needs `rowGroupingFeature` (as does the next one). See [Row grouping](#row-grouping). |
|
|
237
|
+
| `groupsExpanded` | `boolean` | `false` | Groups start expanded. |
|
|
238
|
+
| `rowClickable` | `boolean` | `false` | Pointer cursor; `row-click` is always emitted. |
|
|
239
|
+
| `rowClass` | `(row, index) => ClassValue` | — | |
|
|
240
|
+
| `highlightedRows` | `RowKey[]` | — | |
|
|
241
|
+
| `flash` | `boolean \| 'direction'` | `false` | Briefly highlight cells whose value changes; `'direction'` = green up / red down. Columns override with `flash`. |
|
|
242
|
+
| `renderers` | `CellRendererDefinition[]` | — | Renderers usable by name in this grid (override plugin ones). |
|
|
243
|
+
| `locale` / `currency` / `timeZone` | `string` | plugin → browser | Formatting context for renderers. |
|
|
244
|
+
| `density` | `'compact' \| 'cozy' \| 'comfortable'` | `'cozy'` | Scales cell padding. |
|
|
245
|
+
| `loading` | `boolean` | `false` | Progress bar + `aria-busy`. |
|
|
246
|
+
| `emptyText` | `string` | `'No data to show.'` | |
|
|
247
|
+
| `ariaLabel` | `string` | — | |
|
|
248
|
+
| `contextMenu` | `(ctx: { row, rowKey, column, value }) => MenuItem[] \| null` | — | Right-click menu for body cells. Needs `menusFeature`. |
|
|
249
|
+
| `headerMenu` | `boolean \| ({ column, items }) => MenuItem[] \| null` | `true` | Built-in header menu (sort, pin, move, hide, reset). Needs `menusFeature`. |
|
|
250
|
+
| `ui` | `Partial<Record<'root' \| 'header' \| 'headerCell' \| 'row' \| 'cell' \| 'subgrid' \| 'detail' \| 'empty', ClassValue>>` | — | Extra classes per part (Tailwind-friendly). |
|
|
251
|
+
|
|
252
|
+
### Events
|
|
253
|
+
|
|
254
|
+
`row-click(row, event)` · `cell-click({ row, rowKey, column, value, event })` (columns with `clickable: true`) ·
|
|
255
|
+
`cell-action({ name, payload, row, rowKey, column })` (from renderers) · `sub-rows-error({ row, error })` · `context-action({ name, item, row, rowKey, column, value })` · `header-action({ name, item, column })` ·
|
|
256
|
+
`query-change(query: GridQuery)` (sort + filters + page as one object, on mount and on every real change) ·
|
|
257
|
+
`copy({ kind, text, rows, columns })` (rows or a cell were copied: `exportFeature`) ·
|
|
258
|
+
`load-error(error)` (a `dataSource` call failed) ·
|
|
259
|
+
plus the `update:*` events of every `v-model`.
|
|
260
|
+
|
|
261
|
+
Clicks on links, buttons and inputs inside a cell never trigger `row-click`.
|
|
262
|
+
|
|
263
|
+
### Slots
|
|
264
|
+
|
|
265
|
+
`cell-<key>` (`{ row, value, rowKey, rowIndex, depth, column }`) · `header-<key>` (`{ column }`) ·
|
|
266
|
+
`total-<key>` (`{ value, column, group? }`, a cell of the totals row or a group row) ·
|
|
267
|
+
`group-<key>` (`{ value, count, rows, column, group }`, the value of a group row) · `detail` (`{ row, rowKey, depth }`) ·
|
|
268
|
+
`toolbar` (`{ columns, columnState, setColumnState, filters, setFilters, clearFilters, activeFilterCount, selected, selectedCount, selectAllMatching, clearSelection }`) ·
|
|
269
|
+
`empty` · `loading` · `sub-rows-loading` (`{ row }`).
|
|
270
|
+
|
|
271
|
+
### Exposed methods
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
const grid = ref<VGridExposed>()
|
|
275
|
+
grid.value?.scrollToTop() / scrollToRow(key) / expandAll() / collapseAll() / setColumnState(state)
|
|
276
|
+
grid.value?.patchLoadedRows([{ id: 'c2', city: 'Niš' }]) // field updates for lazy children and dataSource rows
|
|
277
|
+
grid.value?.setFilters({ columns: { city: { type: 'text', op: 'contains', value: 'nis' } } })
|
|
278
|
+
grid.value?.clearFilters() / openFilter('city') / reload() // reload: re-run the dataSource query
|
|
279
|
+
grid.value?.clearSelection() // selectionFeature: clears the selection, "all matching" included
|
|
280
|
+
grid.value?.reloadSubRows('c2') // forget lazily loaded children (of one row, or all): they load again
|
|
281
|
+
grid.value?.pinRow(42, 'top') // pin a row above the body ('bottom' below it, null to unpin): rowPinningFeature
|
|
282
|
+
grid.value?.exportCsv({ filename: 'orders.csv' }) / getCsv() / copyRows() // exportFeature, see Export and copy
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
`reload()` also forgets lazily loaded children, as does passing a different `load-sub-rows`
|
|
286
|
+
function. With `selection-mode="cascade"`, children that load under a selected parent arrive
|
|
287
|
+
selected.
|
|
288
|
+
|
|
289
|
+
### Partial updates
|
|
290
|
+
|
|
291
|
+
Changing part of the data re-renders only what changed — the table is never rebuilt:
|
|
292
|
+
|
|
293
|
+
- **Reactive rows** (`reactive()` / `ref()`): assign the field — `row.city = 'Niš'` — and only that
|
|
294
|
+
cell re-renders.
|
|
295
|
+
- **Immutable rows** (e.g. a `shallowRef` holding a large list): replace the changed rows and keep
|
|
296
|
+
the others' identity. `patchRows(rows, patches, rowKey)` does exactly that for a batch of
|
|
297
|
+
patches by key; only the patched rows re-render, and a batch that changes nothing returns the
|
|
298
|
+
same array.
|
|
299
|
+
- **Lazily loaded children** live in the grid's cache: use `grid.patchLoadedRows(patches)`.
|
|
300
|
+
|
|
301
|
+
Mutating a field in place under a `shallowRef` is not observed — assign a new array (`patchRows`)
|
|
302
|
+
or use reactive rows.
|
|
303
|
+
|
|
304
|
+
**Change highlight.** `<VGrid flash>` briefly tints cells whose value changes (not on first render,
|
|
305
|
+
not when a re-fetched row has equal values); `flash="direction"` tints numbers green when they rise
|
|
306
|
+
and red when they fall. Columns override with `flash: false | true | 'direction'`. It's a CSS
|
|
307
|
+
animation — tune it with `--vg-flash-color`, `--vg-flash-up`, `--vg-flash-down`,
|
|
308
|
+
`--vg-flash-duration`. With `prefers-reduced-motion` the tint is held briefly instead of fading.
|
|
309
|
+
The tint is a `::after` layer under the cell's content that fades with `opacity`, which browsers
|
|
310
|
+
animate on the compositor (GPU): a busy live feed costs the main thread about a sixth of what a
|
|
311
|
+
`background-color` animation would.
|
|
312
|
+
|
|
313
|
+
### `ColumnDef<T>`
|
|
314
|
+
|
|
315
|
+
```ts
|
|
316
|
+
{
|
|
317
|
+
key: string // unique; used by sort, column state and slot names
|
|
318
|
+
header?: string; headerTooltip?: string
|
|
319
|
+
field?: string // dot path, defaults to key
|
|
320
|
+
value?: (row) => unknown // computed value, wins over field
|
|
321
|
+
renderer?: RendererDefinition | string | Component // currencyRenderer (tree-shakeable), a registered name, or a component; default text
|
|
322
|
+
rendererOptions?: object // typed from the renderer
|
|
323
|
+
width?: string // any grid track: 'auto' (default), '8rem', '1fr', 'minmax(8rem, 2fr)', 'min-content'
|
|
324
|
+
minWidth?: string // combined into minmax(minWidth, width); also the resize minimum
|
|
325
|
+
maxWidth?: string // resize maximum (columnResizingFeature)
|
|
326
|
+
resizable?: boolean // can the user resize it (columnResizingFeature, default true)
|
|
327
|
+
group?: string // header group label (columnGroupsFeature)
|
|
328
|
+
align?: 'start' | 'center' | 'end'
|
|
329
|
+
sortable?: boolean; sortValue?: (row) => unknown; sortFn?: (a, b) => number
|
|
330
|
+
pinned?: 'left' | 'right'; pinnable?: boolean // needs columnPinningFeature; pinnable: can the header menu change it (default true)
|
|
331
|
+
hidden?: boolean; hideable?: boolean // need columnVisibilityFeature
|
|
332
|
+
reorderable?: boolean // needs columnReorderFeature (default true)
|
|
333
|
+
clickable?: boolean
|
|
334
|
+
flash?: boolean | 'direction' // change highlight for this column (overrides the grid's `flash`)
|
|
335
|
+
filterable?: boolean // funnel button in the header (and an input in the filter row)
|
|
336
|
+
filter?: 'text' | 'number' | 'date' | 'boolean' | 'set'
|
|
337
|
+
| { type?, options?: FilterOption[] | ((search, { signal }) => Promise<FilterOption[]>), placeholder? }
|
|
338
|
+
filterValue?: (row) => unknown // value filters compare (default: the cell value)
|
|
339
|
+
filterFn?: (row, filter) => boolean // replaces the built-in matching for this column
|
|
340
|
+
filterComponent?: Component // custom popover body: props { modelValue, column }, emits update:modelValue
|
|
341
|
+
searchable?: boolean // included in the quick search (default true for visible columns)
|
|
342
|
+
aggregate?: 'sum' | 'avg' | 'min' | 'max' | 'count' | ((values, rows) => unknown) // totals row (aggregationFeature) and group rows
|
|
343
|
+
groupable?: boolean // Group by / Ungroup in the header menu (rowGroupingFeature)
|
|
344
|
+
groupValue?: (row) => unknown // what rows are grouped by (default: the cell value), e.g. the month of a date
|
|
345
|
+
exportValue?: (row) => unknown // what CSV exports and copying use (exportFeature), e.g. an id instead of a link
|
|
346
|
+
exportable?: boolean // in exports and copied rows (default true); false for action columns
|
|
347
|
+
cellClass?: ClassValue | ((row) => ClassValue); headerClass?: ClassValue
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## Selection and batch actions
|
|
352
|
+
|
|
353
|
+
`selectionFeature` adds a checkbox column. `v-model:selected` holds the selected row keys; the
|
|
354
|
+
`#toolbar` slot gets them too, so a batch-action bar lives in the grid:
|
|
355
|
+
|
|
356
|
+
```vue
|
|
357
|
+
<VGrid v-model:selected="selected" :rows="requests" :columns="columns" row-key="id" selectable prune-selection
|
|
358
|
+
:is-row-selectable="(r) => r.status === 'pending'" :features="[selectionFeature]">
|
|
359
|
+
<template #toolbar="{ selected, selectedCount, clearSelection }">
|
|
360
|
+
<template v-if="selectedCount">
|
|
361
|
+
{{ selectedCount }} selected
|
|
362
|
+
<button @click="approve(selected).then(clearSelection)">Approve</button>
|
|
363
|
+
<button @click="clearSelection()">Clear</button>
|
|
364
|
+
</template>
|
|
365
|
+
</template>
|
|
366
|
+
</VGrid>
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
- **Ranges.** Shift-click a checkbox (or Shift+Space with keyboard navigation) to give every row
|
|
370
|
+
on screen from the last toggled one to this one the clicked row's new state. Ranges follow the
|
|
371
|
+
display order (sort, filters, expanded sub-grids, open groups) and skip rows that can't be
|
|
372
|
+
selected.
|
|
373
|
+
- **Select all.** The header checkbox selects every selectable row that passes the filters, on
|
|
374
|
+
every page; `selectable="single"` has radio buttons and no select-all.
|
|
375
|
+
- **Rows that leave.** By default selected keys stay when their rows leave the data, so a
|
|
376
|
+
selection can span server pages. `prune-selection` drops them instead: after a reload, a batch
|
|
377
|
+
delete or a new page, `selected` only holds rows that exist.
|
|
378
|
+
- **All matching rows (server data).** With a `data-source`, the header checkbox selects the loaded
|
|
379
|
+
page; a banner then offers *Select all N rows* (N = the `total` the source returned). That sets
|
|
380
|
+
`v-model:select-all-matching`: every row shows ticked, `selectedCount` is N, and your batch
|
|
381
|
+
action should run on the query (`@query-change`) rather than on `selected`. Changing the
|
|
382
|
+
filters, unticking a row (the keys already in `selected` stay, plus the rest of the loaded page) or
|
|
383
|
+
*Clear selection* ends it.
|
|
384
|
+
- `grid.clearSelection()` clears it all from code. Cascading through sub-grids, group checkboxes
|
|
385
|
+
(row grouping) and copying the selected rows (export feature) work as described in their
|
|
386
|
+
sections.
|
|
387
|
+
|
|
388
|
+
## Sub-grids (CSS `subgrid`)
|
|
389
|
+
|
|
390
|
+
```vue
|
|
391
|
+
<VGrid :rows="markets" :columns="columns" row-key="id" :sub-rows="(row) => row.children" selectable />
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
Expanded children render inside a `.vg-subgrid` element that spans every column and uses
|
|
395
|
+
`grid-template-columns: subgrid` — so each child cell sits exactly in its parent's column, at any
|
|
396
|
+
depth. Children reuse the parent's columns: reorder, hide and pin apply automatically. The first
|
|
397
|
+
column is indented per depth (`--vg-subgrid-indent`), rows get `aria-level`, the grid becomes a
|
|
398
|
+
`treegrid`. With `loadSubRows` children are fetched on first expand.
|
|
399
|
+
|
|
400
|
+
Need children with a **different** set of columns? Put another `<VGrid>` in the `#detail` slot.
|
|
401
|
+
|
|
402
|
+
## Column menu, reorder, persistence
|
|
403
|
+
|
|
404
|
+
```vue
|
|
405
|
+
<VGrid :rows :columns row-key="id" storage="orders-grid" :features="[columnVisibilityFeature, columnReorderFeature]">
|
|
406
|
+
<!-- the picker hides columns (columnVisibilityFeature); dragging headers needs columnReorderFeature -->
|
|
407
|
+
<template #toolbar="{ columnState, setColumnState }">
|
|
408
|
+
<VGridColumnMenu :columns="columns" :column-state="columnState" @update:column-state="setColumnState($event!)" />
|
|
409
|
+
</template>
|
|
410
|
+
</VGrid>
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
With `columnReorderFeature`, drag a header to move it (mouse or pen; on a touch screen hold it for half a second first, see [Touch](#touch-phones-and-tablets)), or focus a header and press
|
|
414
|
+
**Alt+←/→**. Pinned columns only move within their pin group. Stored state is reconciled with the
|
|
415
|
+
current column definitions (unknown keys dropped, new columns appended).
|
|
416
|
+
|
|
417
|
+
## Context menus
|
|
418
|
+
|
|
419
|
+
Menus use the **Popover API** (top layer — never clipped by the grid's scroll container; Esc and
|
|
420
|
+
outside click close them) and **CSS anchor positioning** (`position-anchor` + `position-area` +
|
|
421
|
+
`position-try-fallbacks`): they flip to stay on screen and follow their anchor while the grid
|
|
422
|
+
scrolls. No JS positioning, except a small fallback for browsers without anchor positioning.
|
|
423
|
+
|
|
424
|
+
### Body cells
|
|
425
|
+
|
|
426
|
+
```vue
|
|
427
|
+
<VGrid
|
|
428
|
+
:rows :columns row-key="id"
|
|
429
|
+
:context-menu="({ row, column, value }) => column.key === 'link' ? [] : [
|
|
430
|
+
{ name: 'copy', label: 'Copy', hint: 'Ctrl+C' },
|
|
431
|
+
{ name: 'open', label: `Open #${row.id}` },
|
|
432
|
+
{ separator: true },
|
|
433
|
+
{ name: 'delete', label: 'Delete', tone: 'danger', disabled: !row.canDelete },
|
|
434
|
+
]"
|
|
435
|
+
@context-action="({ name, row, column, value }) => run(name, row)"
|
|
436
|
+
/>
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
Right-click opens the menu at the pointer; the **ContextMenu** key or **Shift+F10** opens it under the
|
|
440
|
+
focused cell. Return `[]`/`null` to keep the browser's native menu for that cell. Items:
|
|
441
|
+
`{ name, label, disabled?, tone?, icon?, hint? }` or `{ separator: true }`. Arrow keys, Home/End and
|
|
442
|
+
typeahead move through items; focus returns to the cell on close.
|
|
443
|
+
|
|
444
|
+
### Column headers
|
|
445
|
+
|
|
446
|
+
Right-clicking a header opens a built-in menu: **Sort ascending / descending / Clear sort** (sortable
|
|
447
|
+
columns), **Pin left / Pin right / Unpin**, **Move left / right**, **Hide column**, **Reset columns**.
|
|
448
|
+
Pin items need `columnPinningFeature`, move items `columnReorderFeature`, Hide column `columnVisibilityFeature`. Runtime pins are stored in column state (`columnState.pinned`) and persisted with `storage`.
|
|
449
|
+
|
|
450
|
+
```vue
|
|
451
|
+
<!-- extend (or replace) the built-in items; custom items emit header-action -->
|
|
452
|
+
<VGrid :header-menu="({ column, items }) => [{ name: 'copy', label: 'Copy column' }, { separator: true }, ...items]"
|
|
453
|
+
@header-action="({ name, column }) => …" />
|
|
454
|
+
<VGrid :header-menu="false" /> <!-- off -->
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
Columns opt out with `pinnable: false`, `reorderable: false`, `hideable: false`.
|
|
458
|
+
|
|
459
|
+
### `VGridMenu` for your own triggers
|
|
460
|
+
|
|
461
|
+
The same component powers the `actions-menu` renderer and is exported for add-ons:
|
|
462
|
+
|
|
463
|
+
```vue
|
|
464
|
+
<button popovertarget="row-menu" :style="{ 'anchor-name': '--row-menu' }">⋮</button>
|
|
465
|
+
<VGridMenu id="row-menu" anchor-name="--row-menu" :items="items" @select="(item) => …" />
|
|
466
|
+
<!-- or imperatively: menuRef.value.openAt(element | { x, y }) -->
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
## Filtering
|
|
470
|
+
|
|
471
|
+
```vue
|
|
472
|
+
<script setup lang="ts">
|
|
473
|
+
import { VGrid, VGridSearch, filteringFeature, numberRenderer, statusRenderer, type FilterState } from '@nocopypaste/vue-grid'
|
|
474
|
+
|
|
475
|
+
const filters = ref<FilterState | null>(null)
|
|
476
|
+
const columns = [
|
|
477
|
+
{ key: 'player', header: 'Player', filterable: true }, // text
|
|
478
|
+
{ key: 'stake', header: 'Stake', filterable: true, renderer: numberRenderer }, // number (from the renderer)
|
|
479
|
+
{ key: 'status', header: 'Status', filterable: true, renderer: statusRenderer },// value list
|
|
480
|
+
{ key: 'placedAt', header: 'Placed', filterable: true, filter: 'date' }, // explicit type
|
|
481
|
+
]
|
|
482
|
+
</script>
|
|
483
|
+
|
|
484
|
+
<template>
|
|
485
|
+
<VGrid v-model:filters="filters" :rows :columns row-key="id" :features="[filteringFeature]"
|
|
486
|
+
filter-row filter-storage="bets-filters">
|
|
487
|
+
<template #toolbar="{ activeFilterCount, clearFilters }">
|
|
488
|
+
<VGridSearch />
|
|
489
|
+
<button v-if="activeFilterCount" @click="clearFilters()">Clear {{ activeFilterCount }} filters</button>
|
|
490
|
+
</template>
|
|
491
|
+
</VGrid>
|
|
492
|
+
</template>
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
- **Header funnel.** Each `filterable` column gets a funnel button. It is hidden until you hover the
|
|
496
|
+
header (on devices that can hover) and stays visible while a filter is active. It opens a
|
|
497
|
+
popover through the Popover API and CSS anchor positioning, and the popover holds an editor for
|
|
498
|
+
the column's type:
|
|
499
|
+
|
|
500
|
+
| Type | Editor | Operators |
|
|
501
|
+
|---|---|---|
|
|
502
|
+
| `text` | operator + value | contains, does not contain, equals, does not equal, starts with, ends with, is empty, is not empty |
|
|
503
|
+
| `number` | operator + value(s) | `=` `≠` `<` `≤` `>` `≥`, between, is empty, is not empty |
|
|
504
|
+
| `date` | operator + date(s) | on, before, after, between, is empty, is not empty |
|
|
505
|
+
| `boolean` | radio group | any, yes, no, empty |
|
|
506
|
+
| `set` | searchable checkbox list with counts | (the selected values) |
|
|
507
|
+
| `custom` | your `filterComponent` | (anything; match it with `filterFn`) |
|
|
508
|
+
|
|
509
|
+
The type comes from `filter`, else from the renderer (number, currency, change → `number`;
|
|
510
|
+
date, datetime → `date`; boolean, checkbox, switch → `boolean`; status, chip → `set`), else
|
|
511
|
+
`text`.
|
|
512
|
+
- **Filter row** (`filter-row`). An inline input under each header that accepts shorthand:
|
|
513
|
+
`>10`, `>=10`, `5..20`, `-5..-1`, open ranges `5..` / `..20`, `!=3`, a decimal comma (`1,5`),
|
|
514
|
+
and `>2026-01-01` or `2026-01-01..2026-03-31` for dates; plain text for text columns. Input that
|
|
515
|
+
doesn't parse sets no filter. Boolean columns get a select; value-list and custom columns get a
|
|
516
|
+
button that opens the popover.
|
|
517
|
+
- **Quick search.** `<VGridSearch>` inside the `#toolbar` slot drives that grid's search. Anywhere
|
|
518
|
+
else, bind it with `v-model` to `filters.search`. The search matches any visible column that is
|
|
519
|
+
not marked `searchable: false`.
|
|
520
|
+
- **Matching** is case- and accent-insensitive (`nis` finds *Niš*). Dates compare by calendar day
|
|
521
|
+
in the grid's `timeZone`; a date-only string (`2026-01-05`) is that calendar day in every time
|
|
522
|
+
zone, for filtering and for the `date` renderer. Column filters combine with AND, and then the
|
|
523
|
+
search must match too. Saved filters for columns that no longer exist are ignored.
|
|
524
|
+
- **Long value lists** render their first 300 values; a search narrows the rest.
|
|
525
|
+
- **Trees.** A row shows when it matches, when a descendant matches (so the path stays visible), or
|
|
526
|
+
when an ancestor matched (so a matching group keeps its children). Select-all and cascade only
|
|
527
|
+
touch rows that are visible.
|
|
528
|
+
- **Value lists from a backend.** Pass `filter: { type: 'set', options: (search, { signal }) => fetch(…) }`.
|
|
529
|
+
The list is fetched when the popover opens and again on every search (debounced). Superseded
|
|
530
|
+
requests are cancelled.
|
|
531
|
+
- The header menu has **Filter… / Clear filter / Clear all filters** items. When filters hide
|
|
532
|
+
every row, the grid shows `noMatchText` with a *Clear filters* button.
|
|
533
|
+
|
|
534
|
+
The model is plain JSON, so you can store it, put it in the URL or send it to an API as is:
|
|
535
|
+
|
|
536
|
+
```ts
|
|
537
|
+
interface FilterState { columns: Record<string, ColumnFilter>; search?: string }
|
|
538
|
+
type ColumnFilter =
|
|
539
|
+
| { type: 'text'; op: 'contains' | 'notContains' | 'equals' | 'notEquals' | 'startsWith' | 'endsWith' | 'empty' | 'notEmpty'; value?: string }
|
|
540
|
+
| { type: 'number'; op: 'eq' | 'ne' | 'lt' | 'lte' | 'gt' | 'gte' | 'between' | 'empty' | 'notEmpty'; value?: number | null; to?: number | null }
|
|
541
|
+
| { type: 'date'; op: 'on' | 'before' | 'after' | 'between' | 'empty' | 'notEmpty'; value?: string; to?: string } // YYYY-MM-DD
|
|
542
|
+
| { type: 'boolean'; value: boolean | null }
|
|
543
|
+
| { type: 'set'; values: string[] } // '' stands for blank cells
|
|
544
|
+
| { type: 'custom'; value: unknown }
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
The matchers are exported too, for use on a server or in tests: `matchesFilter`,
|
|
548
|
+
`parseQuickFilter`, `filterTree`, `isFilterActive`, `activeFilterCount`, `foldText`.
|
|
549
|
+
|
|
550
|
+
**Custom filter.** A `filterComponent` gets `{ modelValue, column }` and emits
|
|
551
|
+
`update:modelValue` with a filter (or `undefined` to clear it). Pair it with `filterFn(row, filter)`.
|
|
552
|
+
|
|
553
|
+
## Server data
|
|
554
|
+
|
|
555
|
+
Two ways to connect sorting, filtering and paging to a backend.
|
|
556
|
+
|
|
557
|
+
**1. `dataSource`: the grid fetches.** You give it a function. The grid calls it on mount and
|
|
558
|
+
whenever sort, filters, page or page size change. It does not sort, filter or slice the rows
|
|
559
|
+
itself; it shows exactly what the function returns.
|
|
560
|
+
|
|
561
|
+
```vue
|
|
562
|
+
<script setup lang="ts">
|
|
563
|
+
import { filteringFeature, paginationFeature, serverDataFeature, sortingFeature, type DataSource } from '@nocopypaste/vue-grid'
|
|
564
|
+
|
|
565
|
+
const fetchBets: DataSource<Bet> = async (query, { signal }) => {
|
|
566
|
+
// query: { sort: { key, dir } | null, filters: FilterState, page: number, pageSize: number | null }
|
|
567
|
+
const res = await fetch('/api/bets', { method: 'POST', body: JSON.stringify(query), signal })
|
|
568
|
+
if (!res.ok) throw new Error(res.statusText)
|
|
569
|
+
return res.json() // { rows: Bet[], total?: number }
|
|
570
|
+
}
|
|
571
|
+
</script>
|
|
572
|
+
|
|
573
|
+
<template>
|
|
574
|
+
<VGrid ref="grid" :data-source="fetchBets" :columns row-key="id" pagination filter-row @load-error="toast"
|
|
575
|
+
:features="[serverDataFeature, sortingFeature, filteringFeature, paginationFeature]" />
|
|
576
|
+
</template>
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
- **Cancellation.** A new query aborts the previous request through `signal`, and a late response
|
|
580
|
+
from a superseded request is ignored, so fast typing never shows stale rows.
|
|
581
|
+
- **States.** The grid shows a progress bar while loading. If the function throws, it shows
|
|
582
|
+
*Couldn't load the rows.* with a *Retry* button and emits `load-error`.
|
|
583
|
+
- **Paging.** `pagination` adds the pager and sends `page` / `pageSize`; return `total` so the
|
|
584
|
+
pager knows how many pages there are. Without `pagination`, `pageSize` is `null` (fetch
|
|
585
|
+
everything). The page resets to 1 when sort or filters change.
|
|
586
|
+
- `grid.reload()` re-runs the current query, and `grid.patchLoadedRows(patches)` updates fields of
|
|
587
|
+
rows that are already loaded without a refetch.
|
|
588
|
+
|
|
589
|
+
**2. `@query-change`: you fetch.** Keep `rows` under your control, set `sort-mode="controlled"`
|
|
590
|
+
and `filter-mode="controlled"`, and handle one event. The grid emits the combined query on mount
|
|
591
|
+
and on every change, and skips duplicates:
|
|
592
|
+
|
|
593
|
+
```vue
|
|
594
|
+
<VGrid :rows="rows" :columns row-key="id" :loading="loading" :features="[sortingFeature, filteringFeature]"
|
|
595
|
+
sort-mode="controlled" filter-mode="controlled" @query-change="load" />
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
Use this when the data comes from a store, a WebSocket or a GraphQL client that you already manage.
|
|
599
|
+
|
|
600
|
+
## Pagination
|
|
601
|
+
|
|
602
|
+
`pagination` gives you a built-in pager under the grid. With client rows it slices the sorted and
|
|
603
|
+
filtered rows; with a `dataSource` it requests pages.
|
|
604
|
+
|
|
605
|
+
```vue
|
|
606
|
+
<VGrid :rows :columns row-key="id" :features="[paginationFeature]" :pagination="{ pageSizes: [10, 25, 50] }" v-model:page="page" v-model:page-size="pageSize" />
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
Or place the standalone component yourself and feed the grid one page at a time:
|
|
610
|
+
|
|
611
|
+
```vue
|
|
612
|
+
<VGrid v-model:sort="sort" :rows="pageRows" :columns row-key="id" :loading="loading" :features="[sortingFeature]" />
|
|
613
|
+
<VGridPagination v-model:page="page" v-model:page-size="pageSize" :total="total" :page-sizes="[10, 25, 50]" />
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
## Pinned rows and totals
|
|
617
|
+
|
|
618
|
+
Rows that stay in view while the body scrolls: a totals row (`aggregationFeature`) and rows pinned
|
|
619
|
+
above or below the body (`rowPinningFeature`).
|
|
620
|
+
|
|
621
|
+
```vue
|
|
622
|
+
<script setup lang="ts">
|
|
623
|
+
const columns = [
|
|
624
|
+
col({ key: 'player', aggregate: 'count' }),
|
|
625
|
+
col({ key: 'stake', renderer: currencyRenderer, aggregate: 'sum' }),
|
|
626
|
+
col({ key: 'odds', renderer: numberRenderer, aggregate: 'avg' }),
|
|
627
|
+
col({ key: 'placedAt', renderer: dateRenderer, aggregate: 'max' }),
|
|
628
|
+
]
|
|
629
|
+
const pinned = ref<PinnedRowsState>({ top: [42] })
|
|
630
|
+
</script>
|
|
631
|
+
|
|
632
|
+
<template>
|
|
633
|
+
<VGrid :rows="bets" :columns="columns" row-key="id" totals v-model:pinned-rows="pinned" />
|
|
634
|
+
</template>
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
- **Totals.** `totals` (or `totals="bottom"`) adds a totals row at the bottom; `totals="top"`
|
|
638
|
+
puts it under the header. Each column with an `aggregate` shows it with the column's own
|
|
639
|
+
renderer (so a currency column sums to a currency), `count` as a plain number; the first column
|
|
640
|
+
shows `totals-label` (`'Total'`) unless it has an aggregate. `sum` / `avg` skip values that
|
|
641
|
+
aren't numbers, `min` / `max` compare numbers, dates and strings, and a function gets the
|
|
642
|
+
column's values and the rows. The totals cover the top-level rows that pass the filters, on
|
|
643
|
+
every page (child rows aren't counted), and follow live data. With server data the grid only
|
|
644
|
+
has the current page: pass the server's totals as `aggregates` (`{ stake: 125000 }`), which
|
|
645
|
+
wins over computed values. The `total-<key>` slot renders a cell of the row yourself.
|
|
646
|
+
- **Pinned rows.** `v-model:pinned-rows` (`{ top, bottom }`, row keys, in display order) or
|
|
647
|
+
`grid.pinRow(key, 'top' | 'bottom' | null)` pins top-level rows. They leave the body, stay put
|
|
648
|
+
while it scrolls, and aren't filtered, sorted or paged; selection, row clicks and context menus
|
|
649
|
+
still work on them. Pin from your own context menu: `@context-action` → `pinRow(rowKey, …)`.
|
|
650
|
+
- **Extra rows.** `pinned-top-rows` / `pinned-bottom-rows` show rows that aren't part of `rows`
|
|
651
|
+
(a target, last year's figures) — no checkbox, not counted in the totals.
|
|
652
|
+
|
|
653
|
+
Each section is one sticky `subgrid` container, so its rows share the grid's columns, follow
|
|
654
|
+
resizing, reordering and pinned columns, and need no measuring of their own. Keyboard navigation
|
|
655
|
+
moves through them like any row, and a focused row scrolls clear of them (`scroll-padding`).
|
|
656
|
+
With virtual scrolling, `aria-rowindex` / `aria-rowcount` count them. Style them with
|
|
657
|
+
`.vg-pinned-top`, `.vg-pinned-bottom`, `.vg-row-pinned`, `.vg-row-total` and the
|
|
658
|
+
`--vg-total-row-bg` / `--vg-total-row-font-weight` tokens.
|
|
659
|
+
|
|
660
|
+
## Row grouping
|
|
661
|
+
|
|
662
|
+
`rowGroupingFeature` groups the rows by one or more columns. Each group is a row with the grouped
|
|
663
|
+
column's name, the value, the number of rows and each column's `aggregate` over the group; expand
|
|
664
|
+
it to see its sub-groups or, at the last level, its rows.
|
|
665
|
+
|
|
666
|
+
```vue
|
|
667
|
+
<script setup lang="ts">
|
|
668
|
+
const columns = [
|
|
669
|
+
col({ key: 'player', field: 'player.name' }),
|
|
670
|
+
col({ key: 'city', field: 'player.city', groupable: true }),
|
|
671
|
+
col({ key: 'status', renderer: statusRenderer, groupable: true }),
|
|
672
|
+
col({ key: 'stake', renderer: currencyRenderer, aggregate: 'sum' }),
|
|
673
|
+
col({ key: 'placedAt', renderer: dateRenderer, groupable: true, groupValue: (b) => b.placedAt.slice(0, 7) }),
|
|
674
|
+
]
|
|
675
|
+
const groupBy = ref(['status', 'city'])
|
|
676
|
+
</script>
|
|
677
|
+
|
|
678
|
+
<template>
|
|
679
|
+
<VGrid v-model:group-by="groupBy" :rows="bets" :columns="columns" row-key="id" totals
|
|
680
|
+
:features="[rowGroupingFeature, aggregationFeature]" />
|
|
681
|
+
</template>
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
- **What a group shows.** The first column holds the expander, the grouped column's header, the
|
|
685
|
+
value (with that column's renderer, so a status groups under its badge; a `groupValue` shows as
|
|
686
|
+
text) and the row count. That cell runs across the columns after it up to the first one with
|
|
687
|
+
an `aggregate`; those show the group's own aggregate. The `group-<key>` slot renders the value
|
|
688
|
+
yourself (`{ value, count, rows, column, group }`); `total-<key>` also renders group cells
|
|
689
|
+
(with `group` set). Empty values form a `(blank)` group, last.
|
|
690
|
+
- **Order, filters, pages.** Groups follow the filters and are ordered by value, descending when
|
|
691
|
+
the grid is sorted descending by the grouped column; sorting by any other column orders the
|
|
692
|
+
rows inside each group. Pagination pages the top-level groups. With server data, the rows of
|
|
693
|
+
the current page are grouped.
|
|
694
|
+
- **Expanding.** Groups start collapsed (`groups-expanded` opens them). Click a group's label or its
|
|
695
|
+
arrow, or use →/← with keyboard navigation; `expandAll()` / `collapseAll()` include groups.
|
|
696
|
+
Changing `group-by` starts over.
|
|
697
|
+
- **Selection.** A group's checkbox selects or clears every row in it, and shows partly
|
|
698
|
+
selected groups as indeterminate.
|
|
699
|
+
- **Header menu.** Columns with `groupable: true` get *Group by* (adds a level) / *Ungroup*, and
|
|
700
|
+
*Ungroup all*. Any column can be grouped through `v-model:group-by`.
|
|
701
|
+
- **Virtual scrolling.** Group rows are part of the virtual layout: thousands of rows in a few
|
|
702
|
+
groups render only what's in view.
|
|
703
|
+
|
|
704
|
+
Style group rows with `.vg-rowgroup` (and `[data-group-level]`), `.vg-rowgroup-name`,
|
|
705
|
+
`.vg-rowgroup-value`, `.vg-rowgroup-count` and the `--vg-rowgroup-bg` /
|
|
706
|
+
`--vg-rowgroup-font-weight` tokens. `groupRows()` and `isRowGroup()` are exported for using the
|
|
707
|
+
same grouping elsewhere.
|
|
708
|
+
|
|
709
|
+
## Export and copy
|
|
710
|
+
|
|
711
|
+
`exportFeature` turns the grid's rows into CSV and copies them to the clipboard.
|
|
712
|
+
|
|
713
|
+
```vue
|
|
714
|
+
<script setup lang="ts">
|
|
715
|
+
const grid = ref<VGridExposed>()
|
|
716
|
+
const columns = [
|
|
717
|
+
col({ key: 'customer', field: 'customer.name' }),
|
|
718
|
+
col({ key: 'total', renderer: currencyRenderer, aggregate: 'sum' }),
|
|
719
|
+
col({ key: 'link', renderer: linkRenderer, exportValue: (o) => o.id }), // export the id, not the link
|
|
720
|
+
col({ key: 'actions', renderer: actionsMenuRenderer, exportable: false }), // left out
|
|
721
|
+
]
|
|
722
|
+
</script>
|
|
723
|
+
|
|
724
|
+
<template>
|
|
725
|
+
<button @click="grid?.exportCsv({ filename: 'orders.csv', totals: true })">Download CSV</button>
|
|
726
|
+
<button @click="grid?.copyRows()">Copy selected</button>
|
|
727
|
+
<VGrid ref="grid" :rows="orders" :columns="columns" row-key="id" selectable totals
|
|
728
|
+
:features="[exportFeature, selectionFeature, aggregationFeature, keyboardNavigationFeature]"
|
|
729
|
+
@copy="(e) => toast(`Copied ${e.rows.length} rows`)" />
|
|
730
|
+
</template>
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
- **`exportCsv(options)`** downloads a `.csv` file (`filename`, default `export.csv`) in UTF-8 with
|
|
734
|
+
a BOM, so Excel shows accents right (`bom: false` to drop it). **`getCsv(options)`** returns the
|
|
735
|
+
same text, for uploading or previewing.
|
|
736
|
+
- **`copyRows(options)`** copies rows as tab-separated text, which pastes as cells into Excel,
|
|
737
|
+
Google Sheets or Numbers. It resolves `false` when nothing was copied.
|
|
738
|
+
- **Ctrl / ⌘ + C** inside the grid copies the selected rows; with none selected, the focused cell
|
|
739
|
+
(cells take focus with `keyboardNavigationFeature`). A text selection, or focus in an input,
|
|
740
|
+
is left to the browser.
|
|
741
|
+
- **Options** (all methods): `rows` — `'filtered'` (default for exports: the rows that pass the
|
|
742
|
+
filters, sorted, every page), `'all'`, `'page'`, `'selected'` (default for copying, nested rows
|
|
743
|
+
included); `children: true` adds the known sub-grid rows after their parent; `columns` — keys,
|
|
744
|
+
in order, hidden columns allowed (default: the visible columns without `exportable: false`);
|
|
745
|
+
`values` — `'raw'` (default for exports: numbers and ISO dates a spreadsheet can compute with)
|
|
746
|
+
or `'formatted'` (default for copying: as the cells show them); `header` (default `true` for
|
|
747
|
+
exports, `false` for copying); `totals: true` adds the totals row; `delimiter` (`,` / tab);
|
|
748
|
+
`guard` (default `true`).
|
|
749
|
+
- **Values.** A column's `exportValue(row)` wins. Formatted values come from the renderer's
|
|
750
|
+
`format` (numbers, currency, change, dates, date-times, booleans, status, chips and lists have
|
|
751
|
+
one; your own renderers can add it); other values are written as text: dates in ISO 8601,
|
|
752
|
+
arrays joined with `, `, objects as JSON. Grouped grids export their rows, not the group rows.
|
|
753
|
+
- **Safe for spreadsheets.** Fields are quoted per RFC 4180, and text that a spreadsheet would run
|
|
754
|
+
as a formula (`=…`, `+…`, `-…`, `@…`) gets a leading `'`; numbers are left alone.
|
|
755
|
+
- **Clipboard.** Copying uses the Clipboard API and falls back to the browser's copy command where
|
|
756
|
+
that API is missing or refused (pages served over plain http), as does the copy button of
|
|
757
|
+
text cells.
|
|
758
|
+
|
|
759
|
+
Without the grid: `toCsv(rows, columns, { delimiter, header, guard })` writes CSV from any rows
|
|
760
|
+
and column definitions (raw values, `exportValue`, `exportable`); `toDelimited(table)`,
|
|
761
|
+
`plainText(value)` and `guardFormula(text)` are its parts.
|
|
762
|
+
|
|
763
|
+
## Virtual scrolling
|
|
764
|
+
|
|
765
|
+
```vue
|
|
766
|
+
<VGrid :rows="tenThousandRows" :columns row-key="id" :features="[virtualScrollingFeature]"
|
|
767
|
+
:virtual="{ rowHeight: 40 }" style="height: 600px" />
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
Rows have a fixed height; only the visible window plus `overscan` is rendered.
|
|
771
|
+
|
|
772
|
+
Sub-grids and detail rows work in virtual mode too. The DOM keeps the same CSS grid / `subgrid`
|
|
773
|
+
structure as without it: expanded children stay inside their parent's `subgrid` container (lined up
|
|
774
|
+
with its columns), and at every level the rows out of view are replaced by spacers, so an expanded
|
|
775
|
+
tree of tens of thousands of rows still renders about a screenful.
|
|
776
|
+
|
|
777
|
+
- **Data rows** (children too) have `rowHeight`.
|
|
778
|
+
- **Detail rows** can be any height. They're measured once rendered; until then
|
|
779
|
+
`virtual.detailHeight` is the estimate (default 4 × `rowHeight`).
|
|
780
|
+
- **Lazy children** (`load-sub-rows`) are requested only for expanded rows in view, once a scroll
|
|
781
|
+
has settled, so flying past expanded rows doesn't fire their requests.
|
|
782
|
+
- **The view holds still** when rows above it change height (a detail row measured, children
|
|
783
|
+
loaded): the grid keeps the first row in view where it was. It does this itself, the same in every
|
|
784
|
+
browser, so virtual grids set `overflow-anchor: none` (browser scroll anchoring doesn't work
|
|
785
|
+
reliably in a CSS grid like this one — Firefox doesn't anchor in it at all).
|
|
786
|
+
- `scrollToRow(key)` reaches child rows too; `aria-rowcount` / `aria-rowindex` count every
|
|
787
|
+
rendered row (data, detail and loading / error rows).
|
|
788
|
+
|
|
789
|
+
## Performance
|
|
790
|
+
|
|
791
|
+
What the grid does for you, and what helps on your side. The repository README lists the
|
|
792
|
+
measurements.
|
|
793
|
+
|
|
794
|
+
**Many rows.** Above a few hundred rows, turn on `virtualScrollingFeature` and give the grid a
|
|
795
|
+
fixed height. Without it, every row is in the DOM, and restyling or relayout (resizing the window,
|
|
796
|
+
switching density) touches every cell. Tips:
|
|
797
|
+
|
|
798
|
+
- Keep `rowHeight` exact and cell content to one line (e.g. `rendererOptions: { ellipsis: true }`).
|
|
799
|
+
- Set `detailHeight` close to your typical detail row: rows that render near their estimate settle
|
|
800
|
+
without visible correction.
|
|
801
|
+
- Raise `overscan` (default 6) only if fast scrolling shows blank rows on slow devices.
|
|
802
|
+
|
|
803
|
+
**Changing data.** Re-render only what changed:
|
|
804
|
+
|
|
805
|
+
- Reactive rows: assign the field (`row.status = 'Won'`); only that cell re-renders.
|
|
806
|
+
- Large immutable lists (`shallowRef`): `patchRows(rows, patches, rowKey)` replaces just the patched
|
|
807
|
+
rows, and a batch that changes nothing returns the same array.
|
|
808
|
+
- Lazily loaded children live in the grid: use `grid.patchLoadedRows(patches)`.
|
|
809
|
+
- For a live feed, batch patches per animation frame rather than per message.
|
|
810
|
+
|
|
811
|
+
**Filtering and sorting** are built for large client-side data:
|
|
812
|
+
|
|
813
|
+
- Filtering is one pass over the tree. Date filters reuse one formatter per time zone, and text
|
|
814
|
+
matching has an ASCII fast path.
|
|
815
|
+
- Value lists are counted once per column, and long lists render 300 values with a search to
|
|
816
|
+
narrow them.
|
|
817
|
+
- Sorting computes each row's value once, with a shared collator.
|
|
818
|
+
- For much larger data, or data that lives on a server, use `data-source` (server mode).
|
|
819
|
+
|
|
820
|
+
**Lazy children** (`load-sub-rows`) are requested when an expanded row renders. Without virtual
|
|
821
|
+
scrolling that is every expanded row. With it, only expanded rows on screen, and only once a scroll
|
|
822
|
+
settles, so `expandAll()` on thousands of lazy rows sends a screenful of requests, not thousands.
|
|
823
|
+
|
|
824
|
+
**Motion** stays on the compositor: the change highlight (`flash`) fades an `opacity` layer, the
|
|
825
|
+
resize handle grows with `transform`, and spinners and progress bars use `transform`. Row
|
|
826
|
+
highlights appear instantly and fade out over `--vg-transition`.
|
|
827
|
+
|
|
828
|
+
**Bundle.** Import only the features and renderers you use. Everything else is tree-shaken, and
|
|
829
|
+
the filter popover, filter-row editors and pager are separate chunks loaded on first use.
|
|
830
|
+
|
|
831
|
+
## Keyboard
|
|
832
|
+
|
|
833
|
+
Without `keyboardNavigationFeature` the grid is an ARIA `table`. The scroll area is one Tab stop,
|
|
834
|
+
and the grid's own controls (sort buttons, expanders, checkboxes, filter buttons) follow in the
|
|
835
|
+
normal Tab order.
|
|
836
|
+
|
|
837
|
+
With `keyboardNavigationFeature` it is an ARIA `grid` (`treegrid` with sub-grids). The grid is one tab stop. Arrow keys move between cells (header, rows, sub-grid rows, detail rows),
|
|
838
|
+
`Home`/`End`, `Ctrl+Home`/`Ctrl+End`, `PageUp`/`PageDown`; `ContextMenu` / `Shift+F10` opens the context menu. `Enter` sorts a header or activates the
|
|
839
|
+
cell's control; `Space` toggles row selection; `→`/`←` on a tree cell expands/collapses; `Alt+←/→` on a
|
|
840
|
+
header moves the column; `Alt+Shift+←/→` on a header resizes it (with `columnResizingFeature`).
|
|
841
|
+
|
|
842
|
+
## Touch, phones and tablets
|
|
843
|
+
|
|
844
|
+
- **Layout.** The grid scrolls its columns inside its own frame at any width; it doesn't widen
|
|
845
|
+
the page, also inside flex and grid layouts (`.vg-root` has `min-width: 0`). If you wrap it in
|
|
846
|
+
your own element inside a flex or grid layout, give that element `min-width: 0` too, or it
|
|
847
|
+
grows to the columns' width. The toolbar wraps, and on narrow screens the pager drops its
|
|
848
|
+
« / » buttons (page 1 and the last page stay).
|
|
849
|
+
- **Swipes scroll** the grid, also when they start on a header (except on a column's narrow
|
|
850
|
+
resize edge).
|
|
851
|
+
- **Hold a header** (about half a second) to pick the column up, then drag it to reorder
|
|
852
|
+
(`columnReorderFeature`). Release it without moving to open the header menu (`menusFeature`).
|
|
853
|
+
- **Hold a body cell**, then release, to open its `context-menu`. This works on iOS, which fires no
|
|
854
|
+
`contextmenu` event; the browser's own long-press menu is suppressed while the grid's menu
|
|
855
|
+
takes over.
|
|
856
|
+
- Inputs (filters, search, pager) are 16 px on touch screens so iOS Safari doesn't zoom in, and
|
|
857
|
+
row hover tints only apply where there is a real hover (a tapped row doesn't stay tinted).
|
|
858
|
+
|
|
859
|
+
## Built-in renderers
|
|
860
|
+
|
|
861
|
+
Screenshots of every renderer are in the repository README's
|
|
862
|
+
[renderer gallery](../../README.md#29-cell-renderers).
|
|
863
|
+
|
|
864
|
+
**Display**
|
|
865
|
+
|
|
866
|
+
| Name | Options |
|
|
867
|
+
|---|---|
|
|
868
|
+
| `text` (default) | `ellipsis`, `lines`, `maxWidth`, `preserveNewlines`, `tooltip`, `placeholder`, `tone`, `toneMode` (`text`/`fill`), `bold`, `secondary` (muted suffix), `badge` + `badgePosition`, `icon`, `copyable` + `copyValue` → emits `copy` |
|
|
869
|
+
| `toggle-text` | `clickable`, `highlighted` → emits `toggle` |
|
|
870
|
+
| `number`, `signed-number` | `format` (`Intl.NumberFormatOptions`), `placeholder`, `clickable` → emits `click` |
|
|
871
|
+
| `currency` | `currency` (code or `(value, row) => code`), `format`, `placeholder`, `clickable` → emits `click` |
|
|
872
|
+
| `change` | `direction`, `currency`, `format`, `iconOnly` (arrow + colour; booleans / `'true'` = trend) |
|
|
873
|
+
| `date`, `datetime` | `format`, `placeholder`; `datetime`: `milliseconds`, `twoLines` |
|
|
874
|
+
| `boolean` | `trueLabel`, `falseLabel`, `nullLabel`, `display` (`text`/`icon`), `falseIcon` |
|
|
875
|
+
| `status` | `tone` (map / fn / constant), `label` (fn or value → label map), `dot`, `variant` (`soft`/`solid`/`outline`), `placeholder`, `clickable` → emits `click` |
|
|
876
|
+
| `chip` | `color` (any CSS colour, contrast text picked), `tone`, `label`, `tooltip`, `shape` (`square`/`circle`/`pill`), `size`; accepts `{ label \| name, color, description }` |
|
|
877
|
+
| `multi-line` | `lines` (builder; default: the value array), `boldLines`, `ellipsis`, `target`, `placeholder`; each line: `{ text, href, to, tone, fill, bold, muted, tooltip, trend, action, badge }` |
|
|
878
|
+
| `list` | `items`, `itemLabel`, `max` (default 1), `placeholder` → “+N more” toggle, emits `expand` |
|
|
879
|
+
| `link` | `href`, `to` (router location → `<RouterLink>` when vue-router is installed), `label`, `target`, `tooltip` → emits `click` |
|
|
880
|
+
| `icon` | `icon` / `iconFor`, `show`, `label`, `tone` |
|
|
881
|
+
| `image` | `src`, `baseUrl`, `alt`, `size`, `fit`, `shape`; placeholder when empty or broken |
|
|
882
|
+
| `code` | `language` (`auto`/`json`/`text`), `lines`, `indent`, `highlight` (JSON token colours) |
|
|
883
|
+
| `json` | `label`, `dialogTitle` (escaped JSON in a `<dialog>`) |
|
|
884
|
+
| `json-tree` | `collapseAt`, `maxDepth`, `parseNested`, `collapsed` + `toggleLabel`, `emptyText` |
|
|
885
|
+
| `details` | `tone`, `label`, `items` (`{ label, value, tone, detail, tooltip }[]`), `title`, `triggerLabel` → badge + info popover |
|
|
886
|
+
|
|
887
|
+
**Actions and editing** — editable renderers are *controlled*: they show the data and emit the requested
|
|
888
|
+
change; your `@cell-action` handler updates the row.
|
|
889
|
+
|
|
890
|
+
| Name | Options → emits |
|
|
891
|
+
|---|---|
|
|
892
|
+
| `actions-menu` | `actions: MenuItem[] \| (row) => MenuItem[]`, `label` → the item's `name` |
|
|
893
|
+
| `action-button` | `label`, `action`, `icon`, `tone`, `disabled`, `visible`, `variant` (`outline`/`solid`/`ghost`), `iconOnly` → `action` (default `click`) |
|
|
894
|
+
| `button-group` | `buttons: ButtonSpec[] \| (row) => ButtonSpec[]` (`{ name, label, tone, variant, disabled, icon, hidden }`) → the button's `name` |
|
|
895
|
+
| `copy` | `copyValue`, `iconOnly`, `title`, `label`, `placeholder` → `copy` (payload: copied text) / `copy-error` |
|
|
896
|
+
| `edit` | `format`, `placeholder`, `label`, `disabled`, `bold` → `edit` |
|
|
897
|
+
| `checkbox`, `switch` | `checked`, `disabled`, `disabledReason`, `label` → `change` (payload: the requested boolean) |
|
|
898
|
+
| `radio` | same + `name` → `select` (payload: the row key) |
|
|
899
|
+
| `icon-toggle` | `active`, `icon`, `activeIcon`, `activeTone`, `label`, `disabled` → `toggle` (payload: next state) |
|
|
900
|
+
|
|
901
|
+
```vue
|
|
902
|
+
<VGrid :rows="rows" :columns="[{ key: 'web', renderer: 'switch' }]" row-key="id"
|
|
903
|
+
@cell-action="({ name, payload, rowKey }) => name === 'change' && setWeb(rowKey, payload)" />
|
|
904
|
+
```
|
|
905
|
+
|
|
906
|
+
Values option callbacks receive `(value, row)`. The component of every renderer is exported too
|
|
907
|
+
(`TextCell`, `CurrencyCell`, …) for composition.
|
|
908
|
+
|
|
909
|
+
## Writing a cell renderer (addons)
|
|
910
|
+
|
|
911
|
+
A renderer is a component plus a small definition. See
|
|
912
|
+
[`@nocopypaste/vue-grid-renderer-template`](../cell-renderer-template) for a complete, publishable example.
|
|
913
|
+
|
|
914
|
+
```vue
|
|
915
|
+
<!-- RatingCell.vue -->
|
|
916
|
+
<script setup lang="ts">
|
|
917
|
+
import type { CellRendererEmits, CellRendererProps } from '@nocopypaste/vue-grid'
|
|
918
|
+
const props = defineProps<CellRendererProps<unknown, number, { max?: number }>>()
|
|
919
|
+
const emit = defineEmits<CellRendererEmits>()
|
|
920
|
+
</script>
|
|
921
|
+
<template>
|
|
922
|
+
<button v-for="n in options.max" :key="n" @click="emit('action', 'rate', n)">{{ n <= value ? '★' : '☆' }}</button>
|
|
923
|
+
</template>
|
|
924
|
+
```
|
|
925
|
+
|
|
926
|
+
```ts
|
|
927
|
+
import { defineCellRenderer } from '@nocopypaste/vue-grid'
|
|
928
|
+
declare module '@nocopypaste/vue-grid' {
|
|
929
|
+
interface CellRendererRegistry { rating: { max?: number } } // typed `renderer: 'rating'`
|
|
930
|
+
}
|
|
931
|
+
export const ratingRenderer = defineCellRenderer<{ max?: number }>({
|
|
932
|
+
name: 'rating', component: RatingCell, defaults: { max: 5 }, sortValue: (v) => Number(v),
|
|
933
|
+
// what Ctrl+C and formatted CSV exports copy (export feature); without it the raw value
|
|
934
|
+
format: (v, options, ctx, row) => `${Number(v ?? 0)} of ${options.max ?? 5}`,
|
|
935
|
+
})
|
|
936
|
+
// app.use(createVueGrid({ renderers: [ratingRenderer] })) or <VGrid :renderers="[ratingRenderer]">
|
|
937
|
+
```
|
|
938
|
+
|
|
939
|
+
Renderer props: `value`, `row`, `rowKey`, `rowIndex`, `depth`, `column`, `options` (defaults merged
|
|
940
|
+
with `rendererOptions`). Emit `action(name, payload)`; the grid re-emits it as `cell-action` with the
|
|
941
|
+
row and column. `useGridContext()` gives `{ locale, currency, timeZone }`. Lookup order:
|
|
942
|
+
a definition or component on the column → `:renderers` → plugin → `text` (the only renderer built in).
|
|
943
|
+
|
|
944
|
+
## Theming
|
|
945
|
+
|
|
946
|
+
Override any token on `:root`, a wrapper, or the grid itself:
|
|
947
|
+
|
|
948
|
+
```css
|
|
949
|
+
.brand-grid {
|
|
950
|
+
--vg-color-accent: #db2777;
|
|
951
|
+
--vg-color-header-bg: #fdf2f8;
|
|
952
|
+
--vg-radius: 1rem;
|
|
953
|
+
--vg-cell-padding-x: 1.25rem;
|
|
954
|
+
--vg-font-family: Georgia, serif;
|
|
955
|
+
}
|
|
956
|
+
```
|
|
957
|
+
|
|
958
|
+
| Group | Tokens |
|
|
959
|
+
|---|---|
|
|
960
|
+
| Type | `--vg-font-family` `--vg-font-size` `--vg-line-height` `--vg-header-font-size` `--vg-header-font-weight` `--vg-header-letter-spacing` `--vg-header-text-transform` |
|
|
961
|
+
| Colour | `--vg-color-text` `-text-muted` `-surface` `-surface-raised` `-header-bg` `-header-text` `-border` `-border-strong` `-row-hover` `-row-selected` `-row-highlight` `-accent` `-accent-contrast` `-focus-ring` `-success` `-danger` `-warning` `-info` `-neutral` |
|
|
962
|
+
| Space & shape | `--vg-cell-padding-x/y` `--vg-header-padding-x/y` `--vg-gap` `--vg-radius` `--vg-radius-sm` `--vg-radius-pill` `--vg-border-width` `--vg-row-border` `--vg-header-border` `--vg-outer-border` `--vg-select-column-width` `--vg-expander-size` |
|
|
963
|
+
| Sub-grid | `--vg-subgrid-bg` `--vg-subgrid-indent` `--vg-subgrid-border` `--vg-subgrid-radius` |
|
|
964
|
+
| Elevation | `--vg-shadow-pinned` `--vg-shadow-popover` `--vg-z-header` `--vg-z-pinned` `--vg-z-pinned-header` `--vg-transition` `--vg-menu-gap` |
|
|
965
|
+
| Change highlight | `--vg-flash-color` `--vg-flash-up` `--vg-flash-down` `--vg-flash-duration` |
|
|
966
|
+
|
|
967
|
+
Motion stays on the compositor (`transform`, `opacity`) wherever layout would otherwise animate.
|
|
968
|
+
Row highlights (hover, selection) appear at once and fade out over `--vg-transition`, so the grid
|
|
969
|
+
responds the moment the pointer arrives.
|
|
970
|
+
|
|
971
|
+
Colours use `light-dark()`: set `color-scheme: light dark` on `html` to follow the OS, or
|
|
972
|
+
`color-scheme: dark` to force dark. Stable class names (`.vg-header-cell`, `.vg-cell`, `.vg-row`,
|
|
973
|
+
`.vg-subgrid`, `.vg-pin-left`, …) and the `ui` prop are there for anything tokens don't cover.
|
|
974
|
+
|
|
975
|
+
### Bring your own theme
|
|
976
|
+
|
|
977
|
+
The tokens above come from `theme.css`, which is optional. Import `base.css` instead and the grid
|
|
978
|
+
keeps its structure (columns, sub-grid alignment, sticky header and pins, tree indent, anchored
|
|
979
|
+
menus and popovers) with none of the default look. Then style the classes yourself:
|
|
980
|
+
|
|
981
|
+
```ts
|
|
982
|
+
import '@nocopypaste/vue-grid/base.css'
|
|
983
|
+
import './my-grid-theme.css'
|
|
984
|
+
```
|
|
985
|
+
|
|
986
|
+
```css
|
|
987
|
+
/* my-grid-theme.css — unlayered, or in your own layer after `vue-grid` */
|
|
988
|
+
.vg-viewport { border: 1px solid #ddd; }
|
|
989
|
+
.vg-header-cell { padding: 0.5rem 0.75rem; background: #fafafa; font-weight: 600; }
|
|
990
|
+
.vg-cell { padding: 0.5rem 0.75rem; border-top: 1px solid #eee; }
|
|
991
|
+
.vg-row:hover > .vg-cell { background: #f5f5f5; }
|
|
992
|
+
```
|
|
993
|
+
|
|
994
|
+
Base only gives sticky header and pinned cells the system `Canvas` background, so content doesn't
|
|
995
|
+
show through them; everything else (colours, spacing, borders, fonts, focus rings, animation) is
|
|
996
|
+
yours. The structural tokens `--vg-select-column-width`, `--vg-expander-size`,
|
|
997
|
+
`--vg-subgrid-indent`, `--vg-z-*` and `--vg-menu-gap` live in `base.css` and can be overridden
|
|
998
|
+
the same way. `renderers.css` reads the theme's colour tokens; define them (or skip the file) when
|
|
999
|
+
you drop `theme.css`.
|
|
1000
|
+
|
|
1001
|
+
## For coding agents
|
|
1002
|
+
|
|
1003
|
+
[`AGENTS.md`](AGENTS.md) is the short guide for AI coding agents (rules, which feature and
|
|
1004
|
+
renderer for what, recipes, pitfalls); [`llms.txt`](llms.txt) and `llms-full.txt` follow the
|
|
1005
|
+
llms.txt convention. The API reference is generated from the sources into
|
|
1006
|
+
[`agent/api.md`](agent/api.md) and `agent/api.json`, with a
|
|
1007
|
+
[JSON Schema](agent/grid-config.schema.json) of a grid config. To check a config:
|
|
1008
|
+
|
|
1009
|
+
```ts
|
|
1010
|
+
import { validateGridConfig } from '@nocopypaste/vue-grid/agent'
|
|
1011
|
+
|
|
1012
|
+
const { ok, diagnostics } = validateGridConfig({
|
|
1013
|
+
rowKey: 'id',
|
|
1014
|
+
features: ['sortingFeature'], // export names (or the feature objects); 'allFeatures' for all
|
|
1015
|
+
renderers: [], // registered renderer names / definitions
|
|
1016
|
+
columns: [{ key: 'total', renderer: 'currency', sortable: true, widht: '8rem' }],
|
|
1017
|
+
})
|
|
1018
|
+
// error columns[0].widht Columns have no option `widht`. Did you mean `width`?
|
|
1019
|
+
// warning columns[0].renderer Renderer name `currency` isn't registered … pass `renderer: currencyRenderer`
|
|
1020
|
+
// warning props.sortMode Sortable columns, but sorting is controlled … add `sort-mode="client"`
|
|
1021
|
+
```
|
|
1022
|
+
|
|
1023
|
+
`@nocopypaste/vue-grid/agent` is a separate entry: apps that don't import it never bundle it. The
|
|
1024
|
+
[`@nocopypaste/vue-grid-mcp`](../vue-grid-mcp) MCP server serves the same to agents as tools, and the
|
|
1025
|
+
[Claude Code plugin](../../plugins/vue-grid) adds a skill with the full workflow.
|
|
1026
|
+
|
|
1027
|
+
## Browser support
|
|
1028
|
+
|
|
1029
|
+
Evergreen browsers: CSS `subgrid`, `light-dark()`, `@layer`, the Popover API and `<dialog>`
|
|
1030
|
+
(Chrome/Edge 123+, Firefox 125+, Safari 17.5+).
|
|
1031
|
+
|
|
1032
|
+
**CSS first, JS only as a fallback.** Everything the browser can do in CSS / HTML is done there; a
|
|
1033
|
+
small JS fallback runs only when a feature check (`CSS.supports`) says the browser can't:
|
|
1034
|
+
|
|
1035
|
+
| Behaviour | Done with | JS fallback when unsupported |
|
|
1036
|
+
|---|---|---|
|
|
1037
|
+
| Menu / popover placement, flipping, following the anchor on scroll | Popover API + CSS anchor positioning | measured placement, re-run on scroll / resize |
|
|
1038
|
+
| Hiding a popover once its anchor scrolls out of view | `position-visibility: anchor-visible` | IntersectionObserver (e.g. Firefox 159) |
|
|
1039
|
+
| Sticky offsets of pinned columns | `calc()` sums of the declared widths | ResizeObserver, only for content-sized pinned columns |
|
|
1040
|
+
| Which pinned column gets the edge shadow | `:has()` / sibling selectors | a class |
|
|
1041
|
+
| Shadow only while content is scrolled under pinned columns | `@container scroll-state(scrollable: …)` | scroll listener sets `data-vg-scrollable` |
|
|
1042
|
+
| Readable text on data-coloured chips | `contrast-color()` / relative colours | computed black / white |
|
|
1043
|
+
| Expand / collapse (JSON tree, “More info”, list “+N more”) | native `<details>` / `<summary>` | — |
|
|
1044
|
+
| Closing the JSON dialog on a backdrop click | `<dialog closedby="any">` | backdrop click handler |
|
|
1045
|
+
|
|
1046
|
+
What stays in JS is what CSS can't express: data (sorting, selection, expansion state), keyboard
|
|
1047
|
+
navigation, column drag, virtual scrolling and lazy loading.
|