@nocopypaste/vue-grid 0.0.0-stage → 0.2.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 +285 -0
- package/CHANGELOG.md +31 -0
- package/README.md +881 -2
- package/agent/api.json +2336 -0
- package/agent/api.md +632 -0
- package/agent/grid-config.schema.json +609 -0
- package/dist/agent/api.js +2301 -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 +57 -0
- package/dist/agent/requirements.js.map +1 -0
- package/dist/agent/validate.js +181 -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 +759 -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 +39 -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/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 +178 -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/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/useGridFilters.js +125 -0
- package/dist/composables/useGridFilters.js.map +1 -0
- package/dist/composables/useGridKeyboard.js +111 -0
- package/dist/composables/useGridKeyboard.js.map +1 -0
- package/dist/composables/useGridMenus.js +214 -0
- package/dist/composables/useGridMenus.js.map +1 -0
- package/dist/composables/useGridSelection.js +75 -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/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/filter.js +218 -0
- package/dist/core/filter.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/filtering.js +13 -0
- package/dist/features/filtering.js.map +1 -0
- package/dist/features/index.js +38 -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/rowPinning.js +11 -0
- package/dist/features/rowPinning.js.map +1 -0
- package/dist/features/selection.js +11 -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 +67 -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 +11 -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 +188 -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/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 +205 -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/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/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/useGridFilters.d.ts +45 -0
- package/dist/types/composables/useGridKeyboard.d.ts +16 -0
- package/dist/types/composables/useGridMenus.d.ts +55 -0
- package/dist/types/composables/useGridSelection.d.ts +27 -0
- package/dist/types/composables/usePinnedOffsets.d.ts +22 -0
- package/dist/types/composables/usePinnedRows.d.ts +26 -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 +72 -0
- package/dist/types/core/aggregate.d.ts +9 -0
- package/dist/types/core/columns.d.ts +35 -0
- package/dist/types/core/filter.d.ts +85 -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/filtering.d.ts +7 -0
- package/dist/types/features/index.d.ts +20 -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/rowPinning.d.ts +8 -0
- package/dist/types/features/selection.d.ts +6 -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 +21 -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 +2 -0
- package/dist/types/internal/context.d.ts +123 -0
- package/dist/types/internal/dev.d.ts +1 -0
- package/dist/types/internal/features.d.ts +22 -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/text.d.ts +3 -0
- package/dist/types/types.d.ts +383 -0
- package/dist/vue-grid.css +1 -0
- package/llms-full.txt +1806 -0
- package/llms.txt +23 -0
- package/package.json +74 -4
package/llms-full.txt
ADDED
|
@@ -0,0 +1,1806 @@
|
|
|
1
|
+
# @nocopypaste/vue-grid — guide for coding agents
|
|
2
|
+
|
|
3
|
+
`<VGrid>` is a Vue 3 data grid laid out with CSS Grid (nested rows use `subgrid`). Everything
|
|
4
|
+
beyond a read-only table is an opt-in **feature**, and every cell type is an opt-in **renderer**,
|
|
5
|
+
so an app only bundles what it imports. This file is the shortest path to correct code; the full,
|
|
6
|
+
generated reference is [`agent/api.md`](agent/api.md) (also inside `llms-full.txt`), and
|
|
7
|
+
[`README.md`](README.md) explains each area in depth.
|
|
8
|
+
|
|
9
|
+
Machine-checkable: `validateGridConfig()` from `@nocopypaste/vue-grid/agent` checks a grid config and
|
|
10
|
+
says how to fix each problem; [`agent/grid-config.schema.json`](agent/grid-config.schema.json) is its
|
|
11
|
+
JSON Schema. The `@nocopypaste/vue-grid-mcp` MCP server serves all of this as tools.
|
|
12
|
+
|
|
13
|
+
## Rules (each one is a bug when skipped)
|
|
14
|
+
|
|
15
|
+
1. **Import the CSS once**: `import '@nocopypaste/vue-grid/style.css'` (in `main.ts`). Without it the
|
|
16
|
+
grid has no layout.
|
|
17
|
+
2. **Register every feature an option needs.** `sortable`, `filterable`, `pagination`,
|
|
18
|
+
`selectable`, `sub-rows`, `virtual`, `pinned`, `hidden`, `group`, `aggregate`, `totals`,
|
|
19
|
+
`pinned-rows`, `context-menu`… each needs its feature (table below). Without it the option
|
|
20
|
+
**silently does nothing** (dev builds log a `[vue-grid]` warning naming the feature). Per grid:
|
|
21
|
+
`:features="[sortingFeature, filteringFeature]"`; app-wide: `createVueGrid({ features: [...] })`;
|
|
22
|
+
everything: `allFeatures`. `features` is read once, when the grid is created.
|
|
23
|
+
3. **Pass renderer definitions**: `renderer: currencyRenderer` (imported). A string name
|
|
24
|
+
(`renderer: 'currency'`) only works after registering it (`createVueGrid({ renderers: [currencyRenderer] })`
|
|
25
|
+
or `:renderers`); unknown names fall back to text with a dev warning.
|
|
26
|
+
4. **`row-key` is required** and must be unique and stable (a property name or `(row) => id`).
|
|
27
|
+
5. **Sorting is controlled by default.** `sortable: true` plus `sortingFeature` only updates
|
|
28
|
+
`v-model:sort`. For the grid to sort rows itself, add `sort-mode="client"`.
|
|
29
|
+
6. **Give the grid a bounded height** (`style="height: 480px"`, or a flex child with
|
|
30
|
+
`min-height: 0`). Sticky headers, pinned rows, virtual scrolling and scroll-into-view need it.
|
|
31
|
+
7. **Virtual scrolling** needs `virtualScrollingFeature`, `:virtual="{ rowHeight: 40 }"` (every
|
|
32
|
+
row that height, px) and a bounded height. `pagination` is ignored while `virtual` is on.
|
|
33
|
+
8. **Rows are never mutated** by the grid. To change a cell: assign the field on a reactive row, or
|
|
34
|
+
replace rows (`patchRows(rows, patches, rowKey)` keeps unchanged rows' identity).
|
|
35
|
+
9. **Editable renderers are controlled** (`checkbox`, `switch`, `radio`, `icon-toggle`, `edit`,
|
|
36
|
+
buttons, menus): they emit `@cell-action="{ name, payload, row, rowKey, column }"`; your handler
|
|
37
|
+
updates the data.
|
|
38
|
+
10. **Type columns** with `const col = createColumnHelper<Row>()` → `col({ ... })`: `rendererOptions`
|
|
39
|
+
are then checked against the chosen renderer.
|
|
40
|
+
11. **Server data** (`:data-source` + `serverDataFeature`): don't also pass `rows`; pass the
|
|
41
|
+
`signal` to `fetch`; return `{ rows, total }` (`total` drives the pager).
|
|
42
|
+
12. Width is any CSS grid track as a **string**: `'8rem'`, `'1fr'`, `'minmax(10rem, 2fr)'`,
|
|
43
|
+
`'min-content'` (default `auto`). Numbers are not accepted.
|
|
44
|
+
|
|
45
|
+
## Which feature for what
|
|
46
|
+
|
|
47
|
+
| The user wants… | Feature(s) | Props / column options |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| Click a header to sort | `sortingFeature` | column `sortable: true`; `sort-mode="client"` (or handle `v-model:sort`) |
|
|
50
|
+
| Filters per column, a filter row, quick search | `filteringFeature` | column `filterable: true` (`filter: 'text' \| 'number' \| 'date' \| 'boolean' \| 'set'`); `filter-row`; `<VGridSearch />` in `#toolbar` |
|
|
51
|
+
| Pages | `paginationFeature` | `pagination` (or `{ pageSizes: [10, 25, 50] }`), `v-model:page`, `v-model:page-size` |
|
|
52
|
+
| Backend sorting / filtering / paging | `serverDataFeature` (+ the above) | `:data-source="(query, { signal }) => Promise<{ rows, total }>"` |
|
|
53
|
+
| Checkboxes / row selection | `selectionFeature` | `selectable` (or `'single'`), `v-model:selected`, `is-row-selectable` |
|
|
54
|
+
| Nested child rows aligned to the parent's columns | `subGridsFeature` | `:sub-rows="(row) => row.children"` or `:load-sub-rows` + `:has-sub-rows` |
|
|
55
|
+
| An expandable panel under a row | — | `#detail="{ row }"` slot (`row-expandable` to limit it) |
|
|
56
|
+
| 10,000+ rows | `virtualScrollingFeature` | `:virtual="{ rowHeight: 40 }"` + bounded height |
|
|
57
|
+
| Right-click menus (cells, headers) | `menusFeature` | `:context-menu="(ctx) => MenuItem[]"` + `@context-action`; header menu is on by default |
|
|
58
|
+
| Freeze columns left / right | `columnPinningFeature` | column `pinned: 'left' \| 'right'` |
|
|
59
|
+
| Show / hide columns | `columnVisibilityFeature` | column `hidden: true`; `<VGridColumnMenu>` in `#toolbar` |
|
|
60
|
+
| Drag columns to reorder | `columnReorderFeature` | column `reorderable: false` to lock one |
|
|
61
|
+
| Drag column edges to resize | `columnResizingFeature` | `minWidth` / `maxWidth`, `resizable: false` |
|
|
62
|
+
| Grouped headers ("Q1" over three columns) | `columnGroupsFeature` | column `group: 'Q1'` |
|
|
63
|
+
| Rows that stay on top / bottom | `rowPinningFeature` | `v-model:pinned-rows="{ top: [id], bottom: [] }"`, `pinRow()`, `pinned-top-rows` |
|
|
64
|
+
| A totals row (sum, avg, …) | `aggregationFeature` | column `aggregate: 'sum' \| 'avg' \| 'min' \| 'max' \| 'count' \| fn`; `totals` (or `'top'`) |
|
|
65
|
+
| Arrow-key navigation (ARIA grid) | `keyboardNavigationFeature` | — |
|
|
66
|
+
| Remember column layout | — | `storage="orders-grid"` (localStorage key) |
|
|
67
|
+
| Cell type (money, date, badge, link, …) | — | `renderer: currencyRenderer` etc. (list below) |
|
|
68
|
+
|
|
69
|
+
## Renderers (pick by data)
|
|
70
|
+
|
|
71
|
+
| Data | Renderer export | Useful options |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| Plain / long text | default (`text`) | `ellipsis`, `lines`, `tone`, `badge`, `copyable`, `tooltip` |
|
|
74
|
+
| Numbers | `numberRenderer` | `format` (Intl), `clickable` |
|
|
75
|
+
| Money | `currencyRenderer` | `currency` (code or `(v, row) => code`) |
|
|
76
|
+
| Up / down change | `changeRenderer` | `direction`, `currency`, `iconOnly` |
|
|
77
|
+
| Dates / date-times | `dateRenderer` / `dateTimeRenderer` | `format`, `twoLines` |
|
|
78
|
+
| Yes / no | `booleanRenderer` | `display: 'icon'`, labels |
|
|
79
|
+
| Status badge | `statusRenderer` | `tone: { Paid: 'success', Open: 'info' }`, `label`, `variant` |
|
|
80
|
+
| Colour chip / tag | `chipRenderer` | `color`, `tone`, `shape` |
|
|
81
|
+
| Links | `linkRenderer` | `href` / `to` (vue-router), `label`, `target` |
|
|
82
|
+
| Several lines in one cell | `multiLineRenderer` | `lines: (v, row) => [...]` |
|
|
83
|
+
| Arrays | `listRenderer` | `max`, `itemLabel` |
|
|
84
|
+
| Images | `imageRenderer` | `src`, `size`, `shape` |
|
|
85
|
+
| JSON / code | `jsonTreeRenderer`, `jsonRenderer`, `codeRenderer` | `collapseAt`, `language` |
|
|
86
|
+
| Badge + info popover | `detailsRenderer` | `items: (v, row) => [{ label, value }]` |
|
|
87
|
+
| Buttons / menus | `actionButtonRenderer`, `buttonGroupRenderer`, `actionsMenuRenderer` | `action`, `buttons`, `actions` |
|
|
88
|
+
| Toggles / inputs (controlled) | `checkboxRenderer`, `switchRenderer`, `radioRenderer`, `iconToggleRenderer`, `editRenderer` | handle `@cell-action` |
|
|
89
|
+
| Copy to clipboard | `copyRenderer` | `copyValue`, `iconOnly` |
|
|
90
|
+
|
|
91
|
+
Every option is in `agent/api.md` → Renderers. Options typed `RowFn` / `RowOption` also take
|
|
92
|
+
`(value, row) => …`. Status / chip / details `tone`s: `success`, `danger`, `warning`, `info`,
|
|
93
|
+
`neutral`, `accent`.
|
|
94
|
+
|
|
95
|
+
## Recipes
|
|
96
|
+
|
|
97
|
+
### Basic sortable table
|
|
98
|
+
|
|
99
|
+
```vue
|
|
100
|
+
<script setup lang="ts">
|
|
101
|
+
import { VGrid, createColumnHelper, currencyRenderer, dateRenderer, sortingFeature, statusRenderer } from '@nocopypaste/vue-grid'
|
|
102
|
+
|
|
103
|
+
interface Order { id: number; customer: { name: string }; total: number; status: 'Paid' | 'Open'; placedAt: string }
|
|
104
|
+
defineProps<{ orders: Order[] }>()
|
|
105
|
+
|
|
106
|
+
const col = createColumnHelper<Order>()
|
|
107
|
+
const columns = [
|
|
108
|
+
col({ key: 'id', header: '#', width: 'min-content' }),
|
|
109
|
+
col({ key: 'customer', header: 'Customer', field: 'customer.name', sortable: true, width: 'minmax(10rem, 1fr)' }),
|
|
110
|
+
col({ key: 'total', header: 'Total', renderer: currencyRenderer, sortable: true }),
|
|
111
|
+
col({ key: 'status', header: 'Status', renderer: statusRenderer, rendererOptions: { tone: { Paid: 'success', Open: 'info' } } }),
|
|
112
|
+
col({ key: 'placedAt', header: 'Placed', renderer: dateRenderer, sortable: true }),
|
|
113
|
+
]
|
|
114
|
+
</script>
|
|
115
|
+
|
|
116
|
+
<template>
|
|
117
|
+
<VGrid :rows="orders" :columns="columns" row-key="id" :features="[sortingFeature]" sort-mode="client" style="height: 480px" />
|
|
118
|
+
</template>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Filters, quick search, column picker and saved layout
|
|
122
|
+
|
|
123
|
+
```vue
|
|
124
|
+
<script setup lang="ts">
|
|
125
|
+
import {
|
|
126
|
+
VGrid, VGridColumnMenu, VGridSearch,
|
|
127
|
+
columnVisibilityFeature, filteringFeature, sortingFeature, type FilterState,
|
|
128
|
+
} from '@nocopypaste/vue-grid'
|
|
129
|
+
const filters = ref<FilterState | null>(null)
|
|
130
|
+
// columns: add `filterable: true` (type from the renderer, or `filter: 'date'` etc.)
|
|
131
|
+
</script>
|
|
132
|
+
|
|
133
|
+
<template>
|
|
134
|
+
<VGrid v-model:filters="filters" :rows="rows" :columns="columns" row-key="id" filter-row sort-mode="client"
|
|
135
|
+
storage="orders-grid" filter-storage="orders-filters"
|
|
136
|
+
:features="[sortingFeature, filteringFeature, columnVisibilityFeature]" style="height: 480px">
|
|
137
|
+
<template #toolbar="{ columnState, setColumnState, activeFilterCount, clearFilters }">
|
|
138
|
+
<VGridSearch />
|
|
139
|
+
<button v-if="activeFilterCount" @click="clearFilters()">Clear {{ activeFilterCount }}</button>
|
|
140
|
+
<VGridColumnMenu :columns="columns" :column-state="columnState" @update:column-state="setColumnState($event!)" />
|
|
141
|
+
</template>
|
|
142
|
+
</VGrid>
|
|
143
|
+
</template>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Server data with paging
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
import { filteringFeature, paginationFeature, serverDataFeature, sortingFeature, type DataSource } from '@nocopypaste/vue-grid'
|
|
150
|
+
|
|
151
|
+
const fetchOrders: DataSource<Order> = async (query, { signal }) => {
|
|
152
|
+
// query: { sort: { key, dir } | null, filters: { columns, search }, page, pageSize }
|
|
153
|
+
const res = await fetch('/api/orders/search', { method: 'POST', body: JSON.stringify(query), signal })
|
|
154
|
+
if (!res.ok) throw new Error(res.statusText) // the grid shows an error with Retry, emits load-error
|
|
155
|
+
return res.json() as Promise<{ rows: Order[]; total: number }>
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
```vue
|
|
160
|
+
<VGrid :data-source="fetchOrders" :columns="columns" row-key="id" pagination filter-row
|
|
161
|
+
:features="[serverDataFeature, sortingFeature, filteringFeature, paginationFeature]" style="height: 520px" />
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Server totals: pass them as `:aggregates="{ total: 125000 }"` with `totals` and `aggregationFeature`.
|
|
165
|
+
|
|
166
|
+
### Tree: nested and lazy child rows
|
|
167
|
+
|
|
168
|
+
```vue
|
|
169
|
+
<!-- synchronous children -->
|
|
170
|
+
<VGrid :rows="markets" :columns="columns" row-key="id" :sub-rows="(m) => m.children" :features="[subGridsFeature]" />
|
|
171
|
+
<!-- lazy children, fetched on first expand -->
|
|
172
|
+
<VGrid :rows="folders" :columns="columns" row-key="id" :load-sub-rows="loadChildren" :has-sub-rows="(f) => f.hasChildren"
|
|
173
|
+
v-model:expanded="expanded" :features="[subGridsFeature]" />
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Children share the parent's columns. For a different set of columns, use the `#detail` slot with
|
|
177
|
+
another `<VGrid>` inside.
|
|
178
|
+
|
|
179
|
+
### Detail row
|
|
180
|
+
|
|
181
|
+
```vue
|
|
182
|
+
<VGrid :rows="orders" :columns="columns" row-key="id">
|
|
183
|
+
<template #detail="{ row }"><OrderLines :order-id="row.id" /></template>
|
|
184
|
+
</VGrid>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Selection
|
|
188
|
+
|
|
189
|
+
```vue
|
|
190
|
+
<VGrid v-model:selected="selected" :rows="rows" :columns="columns" row-key="id" selectable
|
|
191
|
+
:is-row-selectable="(r) => r.status !== 'locked'" :features="[selectionFeature]" />
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### 10,000+ rows
|
|
195
|
+
|
|
196
|
+
```vue
|
|
197
|
+
<VGrid :rows="bigList" :columns="columns" row-key="id" :virtual="{ rowHeight: 40 }" sort-mode="client"
|
|
198
|
+
:features="[virtualScrollingFeature, sortingFeature]" style="height: 600px" />
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Totals and pinned rows
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
const columns = [
|
|
205
|
+
col({ key: 'customer', aggregate: 'count' }),
|
|
206
|
+
col({ key: 'total', renderer: currencyRenderer, aggregate: 'sum' }),
|
|
207
|
+
]
|
|
208
|
+
const pinned = ref<PinnedRowsState>({ top: [42] })
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
```vue
|
|
212
|
+
<VGrid ref="grid" v-model:pinned-rows="pinned" :rows="rows" :columns="columns" row-key="id" totals
|
|
213
|
+
:features="[aggregationFeature, rowPinningFeature]" style="height: 480px" />
|
|
214
|
+
<!-- grid.value.pinRow(key, 'top' | 'bottom' | null) from your own button or context menu -->
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Row actions and context menu
|
|
218
|
+
|
|
219
|
+
```vue
|
|
220
|
+
<script setup lang="ts">
|
|
221
|
+
import { actionsMenuRenderer, menusFeature, type CellActionEvent, type CellContext, type MenuItem } from '@nocopypaste/vue-grid'
|
|
222
|
+
const columns = [
|
|
223
|
+
/* … */
|
|
224
|
+
col({ key: 'actions', header: '', width: 'min-content', renderer: actionsMenuRenderer,
|
|
225
|
+
rendererOptions: { actions: [{ name: 'edit', label: 'Edit' }, { separator: true }, { name: 'delete', label: 'Delete', tone: 'danger' }] } }),
|
|
226
|
+
]
|
|
227
|
+
const cellMenu = (ctx: CellContext<Order>): MenuItem[] => [{ name: 'copy', label: `Copy ${ctx.column.header}` }]
|
|
228
|
+
function onAction(e: CellActionEvent<Order>) { if (e.name === 'delete') remove(e.rowKey) }
|
|
229
|
+
</script>
|
|
230
|
+
|
|
231
|
+
<template>
|
|
232
|
+
<VGrid :rows :columns row-key="id" :context-menu="cellMenu" :features="[menusFeature]"
|
|
233
|
+
@cell-action="onAction" @context-action="(e) => copy(String(e.value))" />
|
|
234
|
+
</template>
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Editable checkbox (controlled)
|
|
238
|
+
|
|
239
|
+
```ts
|
|
240
|
+
col({ key: 'active', renderer: switchRenderer })
|
|
241
|
+
// <VGrid … @cell-action="(e) => { if (e.column.key === 'active') e.row.active = e.payload }" />
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Your own renderer
|
|
245
|
+
|
|
246
|
+
```ts
|
|
247
|
+
import { defineCellRenderer } from '@nocopypaste/vue-grid'
|
|
248
|
+
import RatingCell from './RatingCell.vue' // props: CellRendererProps<Row, number, { max?: number }>; emit('action', 'rate', n)
|
|
249
|
+
export const ratingRenderer = defineCellRenderer<{ max?: number }>({ name: 'rating', component: RatingCell, defaults: { max: 5 } })
|
|
250
|
+
// column: { key: 'rating', renderer: ratingRenderer, rendererOptions: { max: 10 } }
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Theming
|
|
254
|
+
|
|
255
|
+
```css
|
|
256
|
+
.my-grid { --vg-color-accent: #db2777; --vg-radius: 1rem; --vg-font-size: 0.8125rem; }
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Tokens: `--vg-*` (see README → Theming). Dark mode follows `color-scheme`. Density:
|
|
260
|
+
`density="compact" | "cozy" | "comfortable"`. Utility classes per part: `:ui="{ cell: 'px-2' }"`.
|
|
261
|
+
|
|
262
|
+
## Check your work
|
|
263
|
+
|
|
264
|
+
1. Validate the config: `validateGridConfig({ columns, rowKey: 'id', features: ['sortingFeature'], sortMode: 'client' })`
|
|
265
|
+
from `@nocopypaste/vue-grid/agent` (or the MCP tool `vue_grid_validate`). Fix every `error`; read the
|
|
266
|
+
`warning`s.
|
|
267
|
+
2. Run the app in dev mode and read the console: `[vue-grid]` warnings name a missing feature, an
|
|
268
|
+
unknown renderer or a duplicate row key.
|
|
269
|
+
3. Look at it in a browser: the header sticks, rows scroll inside the grid, the features you added
|
|
270
|
+
respond (sort a column, open a filter, expand a row).
|
|
271
|
+
|
|
272
|
+
## Pitfalls
|
|
273
|
+
|
|
274
|
+
- Nothing sorts → `sort-mode="client"` missing (or `sortingFeature` missing).
|
|
275
|
+
- Columns are squeezed / the page scrolls sideways → give `width`s (`minmax(8rem, 1fr)`); the grid
|
|
276
|
+
scrolls horizontally inside itself when columns are wider than it.
|
|
277
|
+
- Grid grows forever / no sticky header → no bounded height.
|
|
278
|
+
- The page scrolls sideways on a phone → an element you wrapped the grid in sits in a flex or grid
|
|
279
|
+
layout without `min-width: 0` (so it grows to the columns' width). Add `min-width: 0` to it;
|
|
280
|
+
`<VGrid>`'s own root already has it.
|
|
281
|
+
- `renderer: 'currency'` shows plain text → the renderer isn't registered; import and pass `currencyRenderer`.
|
|
282
|
+
- Changing `:features` later does nothing → features are read at creation; re-create with `:key`.
|
|
283
|
+
- Virtual grid with variable row content → rows must share `rowHeight`; use `lines`/`ellipsis` to keep them uniform.
|
|
284
|
+
- `dataSource` plus `rows` → `rows` is ignored with a data source.
|
|
285
|
+
- A nested child with different columns → not a sub-grid; use `#detail` with another `<VGrid>`.
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
# @nocopypaste/vue-grid 0.2.0 — API reference
|
|
290
|
+
|
|
291
|
+
> Generated from the TypeScript sources (`scripts/gen-agent.mjs`). Machine-readable: `agent/api.json`, `agent/grid-config.schema.json`.
|
|
292
|
+
|
|
293
|
+
## Features
|
|
294
|
+
|
|
295
|
+
Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid({ features })` (`allFeatures` = all). An option whose feature is missing does nothing.
|
|
296
|
+
|
|
297
|
+
| Export | What it enables | Props | Column options |
|
|
298
|
+
|---|---|---|---|
|
|
299
|
+
| `aggregationFeature` | Aggregates and the totals row: columns with an `aggregate` (`sum`, `avg`, `min`, `max`, `count` or a function) and `totals` (`true` / `'bottom'` or `'top'`) show a sticky totals row over the rows that pass the filters, on every page. `aggregates` supplies the values instead (e.g. from a server). Without it, `aggregate` and `totals` are ignored. | `totals` `totalsLabel` `aggregates` | `aggregate` |
|
|
300
|
+
| `columnGroupsFeature` | Grouped column headers: give columns a `group` and adjacent visible columns of the same group get one header cell spanning them, in a sticky row above the column headers. Groups follow reordering, hiding and pinning (a pin boundary splits a group). Without it, `group` is ignored. | | `group` |
|
|
301
|
+
| `columnPinningFeature` | Pinned columns: `pinned: 'left' \| 'right'` columns stay put (sticky) while the grid scrolls sideways, with edge shadows; runtime pins from the header menu (Pin left / Pin right / Unpin) are kept in `v-model:column-state` and persisted with `storage`. Without it, pins are ignored. | | `pinned` `pinnable` |
|
|
302
|
+
| `columnReorderFeature` | Column reordering: drag a header (mouse, pen, touch), Alt+←/→ on a focused header, and the header menu's Move left / Move right. Columns opt out with `reorderable: false`. The order is part of `v-model:column-state` and persisted with `storage`; `<VGridColumnMenu>` works without it. | | `reorderable` |
|
|
303
|
+
| `columnResizingFeature` | Column resizing: drag a header's edge (mouse, pen, touch), use ←/→ on the focused edge (Alt+Shift+←/→ on a header with keyboard navigation), or double-click the edge to fit the content. `minWidth` / `maxWidth` bound it; columns opt out with `resizable: false`. Widths are kept in `columnState.widths` and persisted with `storage`. The header menu gains Fit width / Reset width. | | `maxWidth` `resizable` |
|
|
304
|
+
| `columnVisibilityFeature` | Column visibility: `hidden: true` columns, `columnState.hidden` (persisted with `storage`), the header menu's Hide column item and `<VGridColumnMenu>`'s checkboxes. Columns opt out with `hideable: false`. Without it, every column shows. | | `hidden` `hideable` |
|
|
305
|
+
| `filteringFeature` | Filtering: header funnels with typed filter popovers on `filterable` columns, the filter row, `<VGridSearch>`, the filter items of the header menu, `v-model:filters` and filter persistence. The popover body and the filter-row editors load on demand (own chunks). | `filterMode` `filterRow` `filterStorage` `noMatchText` `filters` | `filterable` `filter` `filterValue` `filterFn` `filterComponent` `searchable` |
|
|
306
|
+
| `keyboardNavigationFeature` | Keyboard navigation (the ARIA grid pattern): the grid is one tab stop, arrow keys / Home / End / PageUp / PageDown move between cells, Enter activates a cell's control, Space selects a row, →/← expand and collapse, Alt+←/→ move a column, ContextMenu / Shift+F10 open the cell menu. Without it the grid is an ARIA `table`: its own controls (sort buttons, expanders, checkboxes, filter buttons) sit in the normal Tab order instead. | | |
|
|
307
|
+
| `menusFeature` | Context menus: the built-in header menu (sort, filter, pin, move, hide, reset, your own items via `header-menu`) and body-cell menus (`context-menu`), opened by right-click, the ContextMenu key or Shift+F10. Without it the browser's own menu shows. The standalone `<VGridMenu>` and the `actions-menu` renderer don't need it. | `contextMenu` `headerMenu` | |
|
|
308
|
+
| `paginationFeature` | Built-in pagination: the `pagination` prop and `v-model:page` / `v-model:page-size`. Pages the client rows, or asks the `dataSource` for pages. The pager loads on demand (own chunk). Not needed for the standalone `<VGridPagination>` component. | `pagination` `page` `pageSize` | |
|
|
309
|
+
| `rowPinningFeature` | Pinned rows: `v-model:pinned-rows` (`{ top, bottom }` row keys), `pinned-top-rows` / `pinned-bottom-rows` (extra rows that aren't in the data) and the `pinRow()` method. Pinned rows stay in view (sticky) under the header or at the bottom while the body scrolls, and aren't filtered, sorted or paged. Without it, those options are ignored. | `pinnedTopRows` `pinnedBottomRows` `pinnedRows` | |
|
|
310
|
+
| `selectionFeature` | Row selection: the `selectable` prop (multi or single), `v-model:selected`, `selection-mode` (cascade through sub-grids), `is-row-selectable`, Space on a row and the select-all checkbox. | `selectable` `selectionMode` `isRowSelectable` `selected` | |
|
|
311
|
+
| `serverDataFeature` | Server data: the `dataSource` prop. The grid sends sort, filters and page to your function, cancels superseded requests, and shows loading, error and retry states. | `dataSource` | |
|
|
312
|
+
| `sortingFeature` | Sorting: the sort button on `sortable` column headers, the sort items of the header menu and, with `sort-mode="client"`, sorting the rows in the browser. | | `sortable` `sortValue` `sortFn` |
|
|
313
|
+
| `subGridsFeature` | Sub-grids: nested child rows in a CSS `subgrid`, from `sub-rows` (synchronous) or `load-sub-rows` (lazy, cached, with loading / error / retry). Detail rows (`#detail` slot) don't need it. | `subRows` `loadSubRows` `hasSubRows` | |
|
|
314
|
+
| `virtualScrollingFeature` | Virtual scrolling: `:virtual="{ rowHeight, overscan?, detailHeight? }"` renders only the rows in view (plus `overscan`), so tens of thousands of rows stay fast — sub-grids and detail rows included, inside the same CSS grid / subgrid layout. Without it, `virtual` is ignored and every row renders. | `virtual` | |
|
|
315
|
+
|
|
316
|
+
## `<VGrid>` props
|
|
317
|
+
|
|
318
|
+
| Prop | Type | Default | Needs | Description |
|
|
319
|
+
|---|---|---|---|---|
|
|
320
|
+
| `rows` | `readonly T[]` | `[]` | | The rows (client data), used as-is and never mutated. Omit when using `dataSource`. |
|
|
321
|
+
| `columns` (required) | `readonly ColumnDef<T>[]` | | | Column definitions, in default display order (see `ColumnDef`). |
|
|
322
|
+
| `rowKey` (required) | `RowKeyGetter<T>` | | | Stable unique id of a row: a property name or `(row) => string \| number`. All row state is keyed by it. |
|
|
323
|
+
| `features` | `readonly GridFeature[]` | | | Opt-in features for this grid (added to the app-wide `createVueGrid({ features })`): `sortingFeature`, `filteringFeature`, `serverDataFeature`, `paginationFeature`, or `allFeatures`. Read once, when the grid is created. |
|
|
324
|
+
| `dataSource` | `DataSource<T>` | | `serverDataFeature` | Server data: called with the current query (sort, filters, search, page) whenever it changes. The grid cancels superseded requests, shows loading and errors, and sorts / filters / pages nothing itself. |
|
|
325
|
+
| `pagination` | `boolean \| { pageSizes?: number[] }` | `false` | `paginationFeature` | Built-in pagination under the grid (server-side with `dataSource`, client-side otherwise). |
|
|
326
|
+
| `sortMode` | `'controlled' \| 'client'` | `'controlled'` | | `controlled` (default): a header click only updates `v-model:sort` (sort on the server or in your own code). `client`: the grid sorts the rows itself. Ignored with `dataSource`. |
|
|
327
|
+
| `filterMode` | `'client' \| 'controlled'` | `'client'` | `filteringFeature` | `client` (default): the grid filters its rows. `controlled`: it only emits `update:filters`. |
|
|
328
|
+
| `filterRow` | `boolean` | `false` | `filteringFeature` | Show the filter row: an input under each filterable column's header. |
|
|
329
|
+
| `filterStorage` | `FilterStateStorage \| string` | | `filteringFeature` | Persist the filter model (`string` = localStorage key). |
|
|
330
|
+
| `noMatchText` | `string` | `'No rows match the current filters.'` | `filteringFeature` | Shown when filters hide every row. |
|
|
331
|
+
| `selectable` | `boolean \| 'single'` | `false` | `selectionFeature` | A selection column: `true` = multi-select (with select-all), `'single'` = one row. |
|
|
332
|
+
| `selectionMode` | `'cascade' \| 'independent'` | `'cascade'` | `selectionFeature` | `cascade` (default): selecting a parent selects its children. `independent`: rows alone. |
|
|
333
|
+
| `isRowSelectable` | `(row: T) => boolean` | | `selectionFeature` | Rows that can't be selected get a disabled checkbox. |
|
|
334
|
+
| `subRows` | `(row: T) => T[] \| undefined \| null` | | `subGridsFeature` | Synchronous child rows of a row: shown in a nested sub-grid when expanded. |
|
|
335
|
+
| `loadSubRows` | `(row: T) => Promise<T[]>` | | `subGridsFeature` | Lazy child rows, loaded on first expand (cached, with loading / error / retry). |
|
|
336
|
+
| `hasSubRows` | `(row: T) => boolean` | | `subGridsFeature` | With `loadSubRows`: which rows get an expander (default: every row). |
|
|
337
|
+
| `rowExpandable` | `(row: T) => boolean` | | | With a `#detail` slot: which rows can expand to show it (default: every row). |
|
|
338
|
+
| `rowClickable` | `boolean` | `false` | | Pointer cursor on rows (`row-click` is emitted either way). |
|
|
339
|
+
| `rowClass` | `(row: T, index: number) => ClassValue` | | | Extra classes for a row. |
|
|
340
|
+
| `highlightedRows` | `readonly RowKey[]` | | | Keys of rows to highlight (e.g. the row being edited). |
|
|
341
|
+
| `flash` | `FlashMode` | | | Briefly highlight cells whose value changes (live data, enrichment). Columns can override. |
|
|
342
|
+
| `virtual` | `VirtualOptions \| false` | `false` | `virtualScrollingFeature` | Virtual scrolling: only the rows in view render. Rows share one height (`rowHeight`, px) and the grid needs a bounded height. Needs the virtual scrolling feature. |
|
|
343
|
+
| `storage` | `ColumnStateStorage \| string` | | | Persist column state (order, hidden, pins, widths): a localStorage key or your own storage. |
|
|
344
|
+
| `renderers` | `CellRendererDefinition[]` | | | Renderers usable by name in this grid (merged over the app-wide ones). |
|
|
345
|
+
| `locale` | `string` | | | Locale for number / date renderers (default: the plugin's, else the browser's). |
|
|
346
|
+
| `currency` | `string` | | | Default ISO 4217 currency for currency renderers. |
|
|
347
|
+
| `timeZone` | `string` | | | IANA time zone for date renderers and date filters. |
|
|
348
|
+
| `density` | `Density` | | | Cell padding scale. |
|
|
349
|
+
| `loading` | `boolean` | `false` | | Shows a progress bar and sets `aria-busy` (server data sets it by itself). |
|
|
350
|
+
| `emptyText` | `string` | `'No data to show.'` | | Shown when there are no rows. |
|
|
351
|
+
| `ariaLabel` | `string` | | | Accessible name of the grid. |
|
|
352
|
+
| `ui` | `Partial<Record<GridPart, ClassValue>>` | | | Extra classes per part (`root`, `header`, `headerCell`, `row`, `cell`, `subgrid`, `detail`, `empty`), e.g. Tailwind utilities. |
|
|
353
|
+
| `contextMenu` | `(ctx: CellContext<T>) => MenuItem[] \| null \| undefined` | | `menusFeature` | Right-click menu items for a body cell. Return `null`/`[]` to keep the browser's menu. |
|
|
354
|
+
| `headerMenu` | `boolean \| ((ctx: HeaderMenuContext<T>) => MenuItem[] \| null \| undefined)` | `true` | `menusFeature` | Header right-click menu: `true` = built-in items (sort, pin, move, hide, reset), `false` = off, or a function that receives the built-in items and returns the items to show. |
|
|
355
|
+
| `pinnedTopRows` | `readonly T[]` | | `rowPinningFeature` | Extra rows above the body, not part of the data (row pinning feature). |
|
|
356
|
+
| `pinnedBottomRows` | `readonly T[]` | | `rowPinningFeature` | Extra rows below the body, not part of the data (row pinning feature). |
|
|
357
|
+
| `totals` | `boolean \| 'top' \| 'bottom'` | `false` | `aggregationFeature` | A totals row with each column's `aggregate` (aggregation feature): `true` / `'bottom'` sticks it to the bottom, `'top'` under the header. |
|
|
358
|
+
| `totalsLabel` | `string` | `'Total'` | `aggregationFeature` | The totals row's label, in its first column (unless that column has an aggregate). |
|
|
359
|
+
| `aggregates` | `Record<string, unknown>` | | `aggregationFeature` | Totals row values by column key, instead of computing them (e.g. totals from a server). |
|
|
360
|
+
|
|
361
|
+
## `v-model`s
|
|
362
|
+
|
|
363
|
+
| Model | Type | Default | Needs | Description |
|
|
364
|
+
|---|---|---|---|---|
|
|
365
|
+
| `v-model:sort` | `SortState \| null` | `null` | | Sort state: a header click cycles asc → desc → none. Header UI needs the sorting feature. |
|
|
366
|
+
| `v-model:columnState` | `ColumnState \| undefined` | `undefined` | | Column order, hidden columns, runtime pins and resized widths (persisted with `storage`). |
|
|
367
|
+
| `v-model:expanded` | `RowKey[]` | `[]` | | Keys of expanded rows (sub-grids and detail rows). |
|
|
368
|
+
| `v-model:selected` | `RowKey[]` | `[]` | `selectionFeature` | Keys of selected rows. Needs the selection feature. |
|
|
369
|
+
| `v-model:filters` | `FilterState \| null` | `null` | `filteringFeature` | Column filters and quick search: `{ columns: Record<key, ColumnFilter>, search }`. Needs the filtering feature. |
|
|
370
|
+
| `v-model:page` | `number` | `1` | `paginationFeature` | Current page (1-based); resets to 1 when sort or filters change. Needs the pagination feature. |
|
|
371
|
+
| `v-model:pageSize` | `number` | `25` | `paginationFeature` | Rows per page. Needs the pagination feature. |
|
|
372
|
+
| `v-model:pinnedRows` | `PinnedRowsState \| null` | `null` | `rowPinningFeature` | Top-level rows pinned above / below the body, by key: `{ top, bottom }`. Needs the row pinning feature. |
|
|
373
|
+
|
|
374
|
+
## Events
|
|
375
|
+
|
|
376
|
+
| Event | Payload | Description |
|
|
377
|
+
|---|---|---|
|
|
378
|
+
| `query-change` | `[query: GridQuery]` | The combined query (sort, filters, search, page) — on mount and whenever it changes. |
|
|
379
|
+
| `load-error` | `[error: unknown]` | A `dataSource` call failed (the grid shows an error with Retry). |
|
|
380
|
+
| `row-click` | `[row: T, event: MouseEvent \| KeyboardEvent]` | A row was clicked (not on a link, button or input inside it, nor a `clickable` column). |
|
|
381
|
+
| `cell-click` | `[event: CellClickEvent<T>]` | A cell of a `clickable: true` column was clicked. |
|
|
382
|
+
| `cell-action` | `[event: CellActionEvent<T>]` | A renderer emitted an action (buttons, toggles, menus, edit, copy). |
|
|
383
|
+
| `sub-rows-error` | `[event: { row: T; error: unknown }]` | `loadSubRows` rejected for a row. |
|
|
384
|
+
| `context-action` | `[event: ContextActionEvent<T>]` | An item of the body-cell context menu was chosen. |
|
|
385
|
+
| `header-action` | `[event: HeaderActionEvent<T>]` | A custom item of the header menu was chosen (built-in items act by themselves). |
|
|
386
|
+
|
|
387
|
+
## Slots
|
|
388
|
+
|
|
389
|
+
| Slot | Scope | Description |
|
|
390
|
+
|---|---|---|
|
|
391
|
+
| `cell-<key>` | `{ row: T; value: unknown; rowKey: RowKey; rowIndex: number; depth: number; column: ColumnDef<T> }` | A column's body cell, replacing its renderer: `#cell-<key>`. |
|
|
392
|
+
| `header-<key>` | `{ column: ColumnDef<T> }` | A column's header content: `#header-<key>`. |
|
|
393
|
+
| `total-<key>` | `{ value: unknown; column: ColumnDef<T> }` | A column's cell in the totals row (aggregation feature). |
|
|
394
|
+
| `detail` | `{ row: T; rowKey: RowKey; depth: number }` | Expandable detail row under a row: any content, even another grid. |
|
|
395
|
+
| `empty` | | Shown when there are no rows. |
|
|
396
|
+
| `loading` | | Shown while loading with no rows yet. |
|
|
397
|
+
| `sub-rows-loading` | `{ row: T }` | Shown while a row's lazy children load. |
|
|
398
|
+
| `toolbar` | `{ columns: readonly ColumnDef<T>[]; columnState: ColumnState; setColumnState: (state: ColumnState) => void; filters: FilterState; setFilters: (state: FilterState) => void; clearFilters: () => void; activeFilterCount: number }` | Above the grid: put a search box, column menu or filter summary here. |
|
|
399
|
+
|
|
400
|
+
## Exposed methods (`ref<VGridExposed>()`)
|
|
401
|
+
|
|
402
|
+
| Method | Signature | Needs | Description |
|
|
403
|
+
|---|---|---|---|
|
|
404
|
+
| `scrollToTop` | `void` | | Scrolls the grid back to its first row. |
|
|
405
|
+
| `scrollToRow` | `void` | | Scrolls a row (top-level or nested, also in virtual mode) into view. |
|
|
406
|
+
| `expandAll` | `void` | | Expands every expandable row (sub-grids and detail rows) that passes the filters. |
|
|
407
|
+
| `collapseAll` | `void` | | Collapses every row. |
|
|
408
|
+
| `setColumnState` | `void` | | Replaces the column state (order, hidden, pins, widths), and saves it with `storage`. |
|
|
409
|
+
| `patchLoadedRows` | `number` | | Applies field patches to lazily loaded child rows (`loadSubRows`), which the grid caches and the; app can't reach. Top-level and synchronous `subRows` data belong to the app: update them there (assign fields on reactive rows, or use `patchRows`). Returns the number of rows patched. |
|
|
410
|
+
| `setFilters` | `void` | `filteringFeature` | Replaces the filter model (also persisted with `filter-storage`). |
|
|
411
|
+
| `clearFilters` | `void` | `filteringFeature` | Removes every column filter and the search. |
|
|
412
|
+
| `openFilter` | `void` | `filteringFeature` | Opens a column's filter popover. |
|
|
413
|
+
| `reload` | `Promise<void>` | `serverDataFeature` | Re-runs the `dataSource` with the current query; lazily loaded child rows load again too. |
|
|
414
|
+
| `reloadSubRows` | `void` | | Forgets lazily loaded child rows (one row's, or all): expanded rows load them again. |
|
|
415
|
+
| `pinRow` | `void` | `rowPinningFeature` | Pins a top-level row above or below the body, or unpins it (`null`). Row pinning feature. |
|
|
416
|
+
|
|
417
|
+
## `ColumnDef<T>`
|
|
418
|
+
|
|
419
|
+
| Option | Type | Needs | Description |
|
|
420
|
+
|---|---|---|---|
|
|
421
|
+
| `key` (required) | `string` | | Unique, stable column id. Also used for sort state, column state and slot names. |
|
|
422
|
+
| `header` | `string` | | Header text (default: the key). |
|
|
423
|
+
| `headerTooltip` | `string` | | Tooltip on the header cell. |
|
|
424
|
+
| `field` | `string` | | Dot path into the row, e.g. `user.address.city`. Defaults to `key`. |
|
|
425
|
+
| `value` | `(row: T) => unknown` | | Computes the cell value; wins over `field`. |
|
|
426
|
+
| `renderer` | `R \| Component` | | A renderer definition (`currencyRenderer`), a registered renderer name, or a component. Defaults to `text`. |
|
|
427
|
+
| `rendererOptions` | `RendererOptions<R>` | | Options of the column's renderer, typed against it (merged over the renderer's defaults). |
|
|
428
|
+
| `width` | `string` | | Any CSS grid track size. Defaults to `auto`. |
|
|
429
|
+
| `minWidth` | `string` | | Lower bound; combined with `width` into `minmax(minWidth, width)`, and the resize minimum. |
|
|
430
|
+
| `maxWidth` | `string` | `columnResizingFeature` | Upper bound when the user resizes the column (column resizing feature). |
|
|
431
|
+
| `resizable` | `boolean` | `columnResizingFeature` | Can the user resize this column (column resizing feature)? Default `true`. |
|
|
432
|
+
| `group` | `string` | `columnGroupsFeature` | Header group label (column groups feature): adjacent visible columns with the same `group`; share one header cell above their own headers. |
|
|
433
|
+
| `align` | `Align` | | Cell and header alignment (default: the renderer's, e.g. `end` for numbers, else `start`). |
|
|
434
|
+
| `sortable` | `boolean` | `sortingFeature` | A sort button in the header (sorting feature). Client sorting needs `sort-mode="client"`. |
|
|
435
|
+
| `sortValue` | `(row: T) => unknown` | `sortingFeature` | The value client sorting compares (default: the renderer's sort value, else the cell value). |
|
|
436
|
+
| `sortFn` | `(a: T, b: T) => number` | `sortingFeature` | A full comparator for client sorting; wins over `sortValue`. |
|
|
437
|
+
| `pinned` | `PinSide` | `columnPinningFeature` | Initial pin side (the header menu can change it at runtime unless `pinnable: false`). |
|
|
438
|
+
| `pinnable` | `boolean` | `columnPinningFeature` | Can the user pin/unpin it from the header menu? Default `true`. |
|
|
439
|
+
| `hidden` | `boolean` | `columnVisibilityFeature` | Initial visibility (column state wins once it exists). |
|
|
440
|
+
| `hideable` | `boolean` | `columnVisibilityFeature` | Can the user hide it from the column menu? Default `true`. |
|
|
441
|
+
| `reorderable` | `boolean` | `columnReorderFeature` | Can the user move it? Default `true`. |
|
|
442
|
+
| `clickable` | `boolean` | | Cell click emits `cell-click` instead of `row-click`. |
|
|
443
|
+
| `filterable` | `boolean` | `filteringFeature` | Show a filter for this column (funnel in the header, and an input in the filter row). |
|
|
444
|
+
| `filter` | `FilterType \| ColumnFilterOptions` | `filteringFeature` | Filter type — default from the renderer (number, date, boolean, set for status/chip, else text) — or options. |
|
|
445
|
+
| `filterValue` | `(row: T) => unknown` | `filteringFeature` | Value used for filtering (default: the cell value). |
|
|
446
|
+
| `filterFn` | `(row: T, filter: ColumnFilter, value: unknown) => boolean` | `filteringFeature` | Custom predicate; replaces the built-in matching for this column. |
|
|
447
|
+
| `filterComponent` | `Component` | `filteringFeature` | Custom filter UI (popover), receives `modelValue` / emits `update:modelValue` with a filter. |
|
|
448
|
+
| `searchable` | `boolean` | `filteringFeature` | Include in the quick search. Default `true` for visible columns. |
|
|
449
|
+
| `flash` | `FlashMode` | | Briefly highlight the cell when its value changes (overrides the grid's `flash` prop). `'direction'`: green when a number goes up, red when it goes down. |
|
|
450
|
+
| `aggregate` | `AggregateName \| AggregateFn<T>` | `aggregationFeature` | The column's value in the totals row (aggregation feature): `'sum' \| 'avg' \| 'min' \| 'max'`; over the cell values (empty values skipped), `'count'` of rows, or a function of the values and; the rows. Shown with the column's renderer (`count` as a plain number). |
|
|
451
|
+
| `cellClass` | `ClassValue \| ((row: T) => ClassValue)` | | Extra classes for the column's body cells (or a function of the row). |
|
|
452
|
+
| `headerClass` | `ClassValue` | | Extra classes for the column's header cell. |
|
|
453
|
+
|
|
454
|
+
## Renderers
|
|
455
|
+
|
|
456
|
+
Set `renderer` to the definition (`renderer: currencyRenderer`, tree-shakeable) or to a name registered with `createVueGrid({ renderers })` / `:renderers`; `rendererOptions` are typed against it. Option values marked `RowFn` / `RowOption` may also be `(value, row) => …`.
|
|
457
|
+
|
|
458
|
+
### `text` — `textRenderer`
|
|
459
|
+
|
|
460
|
+
Text, the default renderer (the only one `<VGrid>` bundles): ellipsis, line clamp, tone, badge, icon, secondary text, copy button. Align: `start` · filter type: `text`.
|
|
461
|
+
|
|
462
|
+
| Option | Type | Description |
|
|
463
|
+
|---|---|---|
|
|
464
|
+
| `ellipsis` | `boolean` | Single line with ellipsis (full text in a tooltip). |
|
|
465
|
+
| `lines` | `number` | Clamp to N lines. |
|
|
466
|
+
| `maxWidth` | `string` | |
|
|
467
|
+
| `preserveNewlines` | `boolean` | Keep line breaks in the value (`white-space: pre-line`). |
|
|
468
|
+
| `tooltip` | `boolean \| RowFn<string \| undefined>` | `true` = value as tooltip; a function computes it. |
|
|
469
|
+
| `placeholder` | `string` | Shown when the value is empty. |
|
|
470
|
+
| `tone` | `RowOption<Tone \| undefined>` | |
|
|
471
|
+
| `toneMode` | `'text' \| 'fill'` | `text` (default) colours the text; `fill` colours the badge-like background. |
|
|
472
|
+
| `bold` | `RowOption<boolean>` | |
|
|
473
|
+
| `secondary` | `RowFn<string \| null \| undefined>` | Muted text after the value, e.g. a half-time score: `2:1 (1:0)`. |
|
|
474
|
+
| `badge` | `RowFn<BadgeSpec \| string \| null \| undefined>` | Badge before (default) or after the value. |
|
|
475
|
+
| `badgePosition` | `'start' \| 'end'` | |
|
|
476
|
+
| `icon` | `RowFn<IconSpec \| null \| undefined>` | Icon before the value, e.g. `{ icon: BellIcon, tone: 'warning', label: 'Notify' }`. |
|
|
477
|
+
| `copyable` | `boolean` | Adds a copy-to-clipboard button; emits `copy` with the copied text. |
|
|
478
|
+
| `copyValue` | `RowFn<string>` | What gets copied (default: the displayed text). |
|
|
479
|
+
|
|
480
|
+
### `toggle-text` — `toggleTextRenderer`
|
|
481
|
+
|
|
482
|
+
Text that toggles a highlight when clicked. Emits `toggle` (with `clickable`). Align: `start` · filter type: `text`.
|
|
483
|
+
|
|
484
|
+
| Option | Type | Description |
|
|
485
|
+
|---|---|---|
|
|
486
|
+
| `clickable` | `boolean \| RowFn<boolean>` | When true, the text is a button that emits action `toggle`. |
|
|
487
|
+
| `highlighted` | `boolean \| RowFn<boolean>` | |
|
|
488
|
+
| `placeholder` | `string` | Shown when the value is empty. |
|
|
489
|
+
|
|
490
|
+
### `number` — `numberRenderer`
|
|
491
|
+
|
|
492
|
+
Locale-formatted numbers. With `clickable`, a link-style button that emits `click`. Align: `end` · filter type: `number`.
|
|
493
|
+
|
|
494
|
+
| Option | Type | Description |
|
|
495
|
+
|---|---|---|
|
|
496
|
+
| `format` | `Intl.NumberFormatOptions` | `Intl.NumberFormat` options, e.g. `{ maximumFractionDigits: 0 }` or `{ style: 'percent' }`. |
|
|
497
|
+
| `placeholder` | `string` | Shown when the value is empty. |
|
|
498
|
+
| `clickable` | `RowOption<boolean>` | Renders the number as a link-style button that emits `click` (drill-down). |
|
|
499
|
+
|
|
500
|
+
### `signed-number` — `signedNumberRenderer`
|
|
501
|
+
|
|
502
|
+
Numbers that always show their sign (+ / −). With `clickable`, emits `click`. Align: `end` · filter type: `number` · defaults: `{ signed: true }`.
|
|
503
|
+
|
|
504
|
+
| Option | Type | Description |
|
|
505
|
+
|---|---|---|
|
|
506
|
+
| `format` | `Intl.NumberFormatOptions` | `Intl.NumberFormat` options, e.g. `{ maximumFractionDigits: 0 }` or `{ style: 'percent' }`. |
|
|
507
|
+
| `placeholder` | `string` | Shown when the value is empty. |
|
|
508
|
+
| `clickable` | `RowOption<boolean>` | Renders the number as a link-style button that emits `click` (drill-down). |
|
|
509
|
+
| `signed` | `boolean` | |
|
|
510
|
+
|
|
511
|
+
### `currency` — `currencyRenderer`
|
|
512
|
+
|
|
513
|
+
Money in a fixed or per-row currency (default: the grid's `currency`). With `clickable`, emits `click`. Align: `end` · filter type: `number`.
|
|
514
|
+
|
|
515
|
+
| Option | Type | Description |
|
|
516
|
+
|---|---|---|
|
|
517
|
+
| `currency` | `string \| RowFn<string \| undefined>` | ISO 4217 code, or derived from the row. Defaults to the grid context currency. |
|
|
518
|
+
| `format` | `Intl.NumberFormatOptions` | `Intl.NumberFormat` options, e.g. `{ maximumFractionDigits: 0 }` or `{ style: 'percent' }`. |
|
|
519
|
+
| `placeholder` | `string` | Shown when the value is empty. |
|
|
520
|
+
| `clickable` | `RowOption<boolean>` | Renders the number as a link-style button that emits `click` (drill-down). |
|
|
521
|
+
|
|
522
|
+
### `change` — `changeRenderer`
|
|
523
|
+
|
|
524
|
+
A rise or fall: the value with an up / down arrow, green or red. Align: `end` · filter type: `number`.
|
|
525
|
+
|
|
526
|
+
| Option | Type | Description |
|
|
527
|
+
|---|---|---|
|
|
528
|
+
| `direction` | `RowFn<'up' \| 'down' \| 'equal' \| undefined>` | Defaults to the sign of a numeric value, or `true` / `false` (also as strings) → up / down. |
|
|
529
|
+
| `currency` | `boolean \| string` | Format as currency (`true` = context currency). |
|
|
530
|
+
| `iconOnly` | `boolean` | Only the arrow (the value becomes its accessible label). |
|
|
531
|
+
| `format` | `Intl.NumberFormatOptions` | `Intl.NumberFormat` options, e.g. `{ maximumFractionDigits: 0 }` or `{ style: 'percent' }`. |
|
|
532
|
+
| `placeholder` | `string` | Shown when the value is empty. |
|
|
533
|
+
| `clickable` | `RowOption<boolean>` | Renders the number as a link-style button that emits `click` (drill-down). |
|
|
534
|
+
|
|
535
|
+
### `date` — `dateRenderer`
|
|
536
|
+
|
|
537
|
+
A calendar day, in the grid's locale and time zone (date-only strings never shift a day). Align: `start` · filter type: `date`.
|
|
538
|
+
|
|
539
|
+
| Option | Type | Description |
|
|
540
|
+
|---|---|---|
|
|
541
|
+
| `format` | `Intl.DateTimeFormatOptions` | `Intl.DateTimeFormat` options, e.g. `{ dateStyle: 'medium' }`. |
|
|
542
|
+
| `placeholder` | `string` | Shown when the value is empty. |
|
|
543
|
+
|
|
544
|
+
### `datetime` — `dateTimeRenderer`
|
|
545
|
+
|
|
546
|
+
Date and time, on two lines by default. Align: `start` · filter type: `date`.
|
|
547
|
+
|
|
548
|
+
| Option | Type | Description |
|
|
549
|
+
|---|---|---|
|
|
550
|
+
| `milliseconds` | `boolean` | |
|
|
551
|
+
| `twoLines` | `boolean` | Date and time on two lines (default true). |
|
|
552
|
+
| `format` | `Intl.DateTimeFormatOptions` | `Intl.DateTimeFormat` options, e.g. `{ dateStyle: 'medium' }`. |
|
|
553
|
+
| `placeholder` | `string` | Shown when the value is empty. |
|
|
554
|
+
|
|
555
|
+
### `boolean` — `booleanRenderer`
|
|
556
|
+
|
|
557
|
+
Yes / no as text labels or icons. Align: `start` · filter type: `boolean`.
|
|
558
|
+
|
|
559
|
+
| Option | Type | Description |
|
|
560
|
+
|---|---|---|
|
|
561
|
+
| `trueLabel` | `string` | |
|
|
562
|
+
| `falseLabel` | `string` | |
|
|
563
|
+
| `nullLabel` | `string` | |
|
|
564
|
+
| `display` | `'text' \| 'icon'` | `text` (default): labels. `icon`: a check for true, nothing (or a cross) for false. |
|
|
565
|
+
| `falseIcon` | `boolean` | In icon mode, show a cross for false (default: nothing). |
|
|
566
|
+
|
|
567
|
+
### `status` — `statusRenderer`
|
|
568
|
+
|
|
569
|
+
A coloured status badge (tone from a map, a function or a constant). With `clickable`, emits `click`. Align: `start` · filter type: `set`.
|
|
570
|
+
|
|
571
|
+
| Option | Type | Description |
|
|
572
|
+
|---|---|---|
|
|
573
|
+
| `tone` | `ToneOption` | |
|
|
574
|
+
| `label` | `RowFn<string> \| Record<string, string>` | Label from a function, or a value → label map. |
|
|
575
|
+
| `dot` | `boolean` | |
|
|
576
|
+
| `variant` | `'soft' \| 'solid' \| 'outline'` | `soft` (default, tinted), `solid` (filled) or `outline`. |
|
|
577
|
+
| `placeholder` | `string` | Shown when the value is empty. |
|
|
578
|
+
| `clickable` | `RowOption<boolean>` | Badge becomes a button that emits `click`. |
|
|
579
|
+
|
|
580
|
+
### `link` — `linkRenderer`
|
|
581
|
+
|
|
582
|
+
A safe link (http(s), mailto, tel only), or a `<RouterLink>` with `to` when vue-router is installed. Align: `start` · filter type: `text`.
|
|
583
|
+
|
|
584
|
+
| Option | Type | Description |
|
|
585
|
+
|---|---|---|
|
|
586
|
+
| `href` | `RowFn<string \| undefined>` | |
|
|
587
|
+
| `to` | `RowFn<RouteTarget \| null \| undefined>` | Router location; rendered with `<RouterLink>` when vue-router is installed, else as an href. |
|
|
588
|
+
| `label` | `RowFn<string>` | |
|
|
589
|
+
| `target` | `'_self' \| '_blank'` | |
|
|
590
|
+
| `tooltip` | `RowFn<string \| undefined>` | |
|
|
591
|
+
|
|
592
|
+
### `icon` — `iconRenderer`
|
|
593
|
+
|
|
594
|
+
An icon component, fixed or picked per row. Align: `center` · filter type: `text`.
|
|
595
|
+
|
|
596
|
+
| Option | Type | Description |
|
|
597
|
+
|---|---|---|
|
|
598
|
+
| `icon` | `Component` | Static icon component. |
|
|
599
|
+
| `iconFor` | `RowFn<Component \| undefined>` | Picks the icon per row (wins over `icon`). Kept separate because functional components are functions too. |
|
|
600
|
+
| `show` | `RowFn<boolean>` | |
|
|
601
|
+
| `label` | `string \| RowFn<string>` | |
|
|
602
|
+
| `tone` | `Tone \| RowFn<Tone \| undefined>` | |
|
|
603
|
+
|
|
604
|
+
### `json` — `jsonRenderer`
|
|
605
|
+
|
|
606
|
+
A button that opens the value as escaped JSON in a dialog. Align: `start` · filter type: `text`.
|
|
607
|
+
|
|
608
|
+
| Option | Type | Description |
|
|
609
|
+
|---|---|---|
|
|
610
|
+
| `label` | `string` | |
|
|
611
|
+
| `dialogTitle` | `string \| RowFn<string>` | |
|
|
612
|
+
|
|
613
|
+
### `json-tree` — `jsonTreeRenderer`
|
|
614
|
+
|
|
615
|
+
A collapsible tree of nested data. Align: `start` · filter type: `text`.
|
|
616
|
+
|
|
617
|
+
| Option | Type | Description |
|
|
618
|
+
|---|---|---|
|
|
619
|
+
| `collapseAt` | `number` | Nodes deeper than this start collapsed. Default 1. |
|
|
620
|
+
| `maxDepth` | `number` | Deeper nodes are summarised (“3 items”) instead of expanded. Default unlimited. |
|
|
621
|
+
| `parseNested` | `boolean` | String values that contain JSON are shown as nested trees. |
|
|
622
|
+
| `collapsed` | `boolean` | Starts hidden behind a toggle button (labelled `toggleLabel`, default “More info”). |
|
|
623
|
+
| `toggleLabel` | `string` | |
|
|
624
|
+
| `emptyText` | `string` | Shown for null / empty values. Default: nothing. |
|
|
625
|
+
|
|
626
|
+
### `actions-menu` — `actionsMenuRenderer`
|
|
627
|
+
|
|
628
|
+
A `⋯` button with a keyboard-friendly menu. Emits the chosen item's `name`. Align: `center` · filter type: `text`.
|
|
629
|
+
|
|
630
|
+
| Option | Type | Description |
|
|
631
|
+
|---|---|---|
|
|
632
|
+
| `actions` | `MenuItem[] \| ((row: any) => MenuItem[])` | Menu items (actions and `{ separator: true }`), or a function of the row. |
|
|
633
|
+
| `label` | `string` | |
|
|
634
|
+
|
|
635
|
+
### `action-button` — `actionButtonRenderer`
|
|
636
|
+
|
|
637
|
+
One button per row. Emits its `action` (default `click`). Align: `start` · filter type: `text`.
|
|
638
|
+
|
|
639
|
+
| Option | Type | Description |
|
|
640
|
+
|---|---|---|
|
|
641
|
+
| `label` | `string \| RowFn<string>` | |
|
|
642
|
+
| `action` | `string` | Action name emitted on click. Default `click`. |
|
|
643
|
+
| `icon` | `Component` | |
|
|
644
|
+
| `tone` | `Tone` | |
|
|
645
|
+
| `disabled` | `RowFn<boolean>` | |
|
|
646
|
+
| `visible` | `RowFn<boolean>` | Hide the button for some rows. |
|
|
647
|
+
| `variant` | `ButtonVariant` | |
|
|
648
|
+
| `iconOnly` | `boolean` | Only the icon; the label becomes its accessible name and tooltip. |
|
|
649
|
+
|
|
650
|
+
### `multi-line` — `multiLineRenderer`
|
|
651
|
+
|
|
652
|
+
Stacked lines, each with its own style, link, badge, trend or action. Align: `start` · filter type: `text`.
|
|
653
|
+
|
|
654
|
+
| Option | Type | Description |
|
|
655
|
+
|---|---|---|
|
|
656
|
+
| `lines` | `RowFn<LineInput[] \| null \| undefined>` | Builds the lines; default: the value itself when it's an array. |
|
|
657
|
+
| `boldLines` | `number[]` | Indexes of lines to show in bold. |
|
|
658
|
+
| `ellipsis` | `boolean` | Each line on one row with ellipsis (default true). |
|
|
659
|
+
| `target` | `'_self' \| '_blank'` | |
|
|
660
|
+
| `placeholder` | `string` | Shown when the value is empty. |
|
|
661
|
+
|
|
662
|
+
### `copy` — `copyRenderer`
|
|
663
|
+
|
|
664
|
+
A value with a copy-to-clipboard button. Emits `copy` / `copy-error`. Align: `start` · filter type: `text`.
|
|
665
|
+
|
|
666
|
+
| Option | Type | Description |
|
|
667
|
+
|---|---|---|
|
|
668
|
+
| `copyValue` | `RowFn<string>` | What gets copied (default: the displayed text). |
|
|
669
|
+
| `iconOnly` | `boolean` | Only the copy button; the value becomes its tooltip. |
|
|
670
|
+
| `label` | `string` | Accessible name of the button. Default “Copy”. |
|
|
671
|
+
| `title` | `string` | Shown before the value in the tooltip, e.g. “Serial number”. |
|
|
672
|
+
| `placeholder` | `string` | Shown when the value is empty. |
|
|
673
|
+
|
|
674
|
+
### `chip` — `chipRenderer`
|
|
675
|
+
|
|
676
|
+
A chip in any colour (readable text picked by contrast), square, circle or pill. Align: `start` · filter type: `set`.
|
|
677
|
+
|
|
678
|
+
| Option | Type | Description |
|
|
679
|
+
|---|---|---|
|
|
680
|
+
| `color` | `RowOption<string \| null \| undefined>` | Any CSS colour (e.g. from an API); text colour is picked for contrast. |
|
|
681
|
+
| `tone` | `ToneOption` | Named tone instead of a raw colour. |
|
|
682
|
+
| `label` | `RowFn<string>` | |
|
|
683
|
+
| `tooltip` | `RowFn<string \| null \| undefined>` | |
|
|
684
|
+
| `shape` | `'square' \| 'circle' \| 'pill'` | |
|
|
685
|
+
| `size` | `string` | Box size for square/circle. Default `1.75rem`. |
|
|
686
|
+
| `placeholder` | `string` | Shown when the value is empty. |
|
|
687
|
+
|
|
688
|
+
### `checkbox` — `checkboxRenderer`
|
|
689
|
+
|
|
690
|
+
A controlled checkbox, with a tooltip when disabled. Emits `change` with the requested state. Align: `center` · filter type: `boolean`.
|
|
691
|
+
|
|
692
|
+
| Option | Type | Description |
|
|
693
|
+
|---|---|---|
|
|
694
|
+
| `checked` | `RowFn<boolean>` | Default: the value is truthy. |
|
|
695
|
+
| `disabled` | `RowOption<boolean>` | |
|
|
696
|
+
| `disabledReason` | `RowFn<string \| null \| undefined>` | Tooltip explaining why it's disabled. |
|
|
697
|
+
| `label` | `RowOption<string>` | Accessible name. Default: the column header. |
|
|
698
|
+
|
|
699
|
+
### `switch` — `switchRenderer`
|
|
700
|
+
|
|
701
|
+
A controlled on / off switch. Emits `change` with the requested state. Align: `center` · filter type: `boolean`.
|
|
702
|
+
|
|
703
|
+
| Option | Type | Description |
|
|
704
|
+
|---|---|---|
|
|
705
|
+
| `checked` | `RowFn<boolean>` | Default: the value is truthy. |
|
|
706
|
+
| `disabled` | `RowOption<boolean>` | |
|
|
707
|
+
| `disabledReason` | `RowFn<string \| null \| undefined>` | Tooltip explaining why it's disabled. |
|
|
708
|
+
| `label` | `RowOption<string>` | Accessible name. Default: the column header. |
|
|
709
|
+
|
|
710
|
+
### `radio` — `radioRenderer`
|
|
711
|
+
|
|
712
|
+
One selected row across the column (controlled). Emits `select`. Align: `center` · filter type: `boolean`.
|
|
713
|
+
|
|
714
|
+
| Option | Type | Description |
|
|
715
|
+
|---|---|---|
|
|
716
|
+
| `name` | `string` | Radio group name. Default: the column key. |
|
|
717
|
+
| `checked` | `RowFn<boolean>` | Default: the value is truthy. |
|
|
718
|
+
| `disabled` | `RowOption<boolean>` | |
|
|
719
|
+
| `disabledReason` | `RowFn<string \| null \| undefined>` | Tooltip explaining why it's disabled. |
|
|
720
|
+
| `label` | `RowOption<string>` | Accessible name. Default: the column header. |
|
|
721
|
+
|
|
722
|
+
### `edit` — `editRenderer`
|
|
723
|
+
|
|
724
|
+
A value with an edit button, for opening your own editor. Emits `edit`. Align: `start` · filter type: `text`.
|
|
725
|
+
|
|
726
|
+
| Option | Type | Description |
|
|
727
|
+
|---|---|---|
|
|
728
|
+
| `format` | `RowFn<string>` | Text shown next to the edit button (default: the value). |
|
|
729
|
+
| `placeholder` | `string` | Shown when the value is empty. |
|
|
730
|
+
| `label` | `string` | Accessible name of the button. Default “Edit”. |
|
|
731
|
+
| `disabled` | `RowOption<boolean>` | |
|
|
732
|
+
| `bold` | `boolean` | |
|
|
733
|
+
|
|
734
|
+
### `image` — `imageRenderer`
|
|
735
|
+
|
|
736
|
+
A thumbnail, with a placeholder when empty or broken. Align: `center` · filter type: `text`.
|
|
737
|
+
|
|
738
|
+
| Option | Type | Description |
|
|
739
|
+
|---|---|---|
|
|
740
|
+
| `src` | `RowFn<string \| null \| undefined>` | Default: the value. |
|
|
741
|
+
| `baseUrl` | `string` | Prefixed to relative paths (e.g. a CDN). |
|
|
742
|
+
| `alt` | `RowOption<string>` | |
|
|
743
|
+
| `size` | `string` | Default `2.5rem`. |
|
|
744
|
+
| `fit` | `'contain' \| 'cover'` | |
|
|
745
|
+
| `shape` | `'rounded' \| 'circle' \| 'square'` | |
|
|
746
|
+
|
|
747
|
+
### `code` — `codeRenderer`
|
|
748
|
+
|
|
749
|
+
Monospaced code, with JSON pretty-printing and highlighting. Align: `start` · filter type: `text`.
|
|
750
|
+
|
|
751
|
+
| Option | Type | Description |
|
|
752
|
+
|---|---|---|
|
|
753
|
+
| `language` | `'auto' \| 'json' \| 'text'` | `auto` (default): JSON for objects and JSON strings, plain text otherwise. |
|
|
754
|
+
| `lines` | `number` | Clamp to N lines (full text in a tooltip). |
|
|
755
|
+
| `indent` | `number` | JSON indent. Default 2. |
|
|
756
|
+
| `highlight` | `boolean` | Colour JSON tokens. Default true. |
|
|
757
|
+
|
|
758
|
+
### `button-group` — `buttonGroupRenderer`
|
|
759
|
+
|
|
760
|
+
Several buttons, fixed or per row. Emits the clicked button's `name`. Align: `start` · filter type: `text`.
|
|
761
|
+
|
|
762
|
+
| Option | Type | Description |
|
|
763
|
+
|---|---|---|
|
|
764
|
+
| `buttons` | `ButtonSpec[] \| ((row: any) => ButtonSpec[])` | |
|
|
765
|
+
|
|
766
|
+
### `icon-toggle` — `iconToggleRenderer`
|
|
767
|
+
|
|
768
|
+
A star / flag style on-off button (controlled). Emits `toggle`. Align: `center` · filter type: `boolean`.
|
|
769
|
+
|
|
770
|
+
| Option | Type | Description |
|
|
771
|
+
|---|---|---|
|
|
772
|
+
| `active` | `RowFn<boolean>` | Default: the value is truthy. |
|
|
773
|
+
| `icon` | `Component` | Default: an outlined star. |
|
|
774
|
+
| `activeIcon` | `Component` | Default: a filled star (or `icon`). |
|
|
775
|
+
| `label` | `RowOption<string>` | Accessible name. Default “Toggle”. |
|
|
776
|
+
| `activeTone` | `Tone` | Tone when active. Default `warning`. |
|
|
777
|
+
| `disabled` | `RowOption<boolean>` | |
|
|
778
|
+
|
|
779
|
+
### `details` — `detailsRenderer`
|
|
780
|
+
|
|
781
|
+
A status badge plus an info button with an anchored popover of label / value rows. Align: `start` · filter type: `text`.
|
|
782
|
+
|
|
783
|
+
| Option | Type | Description |
|
|
784
|
+
|---|---|---|
|
|
785
|
+
| `tone` | `ToneOption` | Summary badge tone, like `status`. |
|
|
786
|
+
| `label` | `RowFn<string>` | |
|
|
787
|
+
| `items` | `RowFn<DetailItem[] \| null \| undefined>` | Popover rows. Empty → no info button. |
|
|
788
|
+
| `title` | `RowOption<string>` | Popover heading. Default: the column header. |
|
|
789
|
+
| `triggerLabel` | `string` | Accessible name of the info button. Default “Details”. |
|
|
790
|
+
|
|
791
|
+
### `list` — `listRenderer`
|
|
792
|
+
|
|
793
|
+
The first items of a list, with a “+N more” toggle. Emits `expand`. Align: `start` · filter type: `text`.
|
|
794
|
+
|
|
795
|
+
| Option | Type | Description |
|
|
796
|
+
|---|---|---|
|
|
797
|
+
| `items` | `RowFn<unknown[] \| null \| undefined>` | Default: the value when it's an array. |
|
|
798
|
+
| `itemLabel` | `RowFn<string>` | |
|
|
799
|
+
| `max` | `number` | Items shown before “+N more”. Default 1. |
|
|
800
|
+
| `placeholder` | `string` | Shown when the value is empty. |
|
|
801
|
+
|
|
802
|
+
## Types
|
|
803
|
+
|
|
804
|
+
### `VirtualOptions`
|
|
805
|
+
|
|
806
|
+
| Field | Type | Description |
|
|
807
|
+
|---|---|---|
|
|
808
|
+
| `rowHeight` | `number` | Fixed row height in px. |
|
|
809
|
+
| `overscan`? | `number` | Extra rows rendered above/below the viewport. Default 6. |
|
|
810
|
+
| `detailHeight`? | `number` | Estimated height in px of a detail row (`#detail` slot) until it has been rendered and; measured. Default 4 × `rowHeight`. Data rows always have `rowHeight`. |
|
|
811
|
+
|
|
812
|
+
### `PinnedRowsState`
|
|
813
|
+
|
|
814
|
+
| Field | Type | Description |
|
|
815
|
+
|---|---|---|
|
|
816
|
+
| `top`? | `RowKey[]` | |
|
|
817
|
+
| `bottom`? | `RowKey[]` | |
|
|
818
|
+
|
|
819
|
+
### `ColumnState`
|
|
820
|
+
|
|
821
|
+
| Field | Type | Description |
|
|
822
|
+
|---|---|---|
|
|
823
|
+
| `order` | `string[]` | Column keys in display order (all known columns, visible or not). |
|
|
824
|
+
| `hidden` | `string[]` | Keys of hidden columns. |
|
|
825
|
+
| `pinned`? | `Record<string, PinSide \| null>` | Runtime pin overrides (e.g. from the header menu). `null` = explicitly unpinned; a missing key; falls back to the column's `pinned` definition. Optional so older persisted state still loads. |
|
|
826
|
+
| `widths`? | `Record<string, string>` | Widths the user resized columns to (CSS lengths, e.g. `'240px'`). Column resizing feature. |
|
|
827
|
+
|
|
828
|
+
### `SortState`
|
|
829
|
+
|
|
830
|
+
| Field | Type | Description |
|
|
831
|
+
|---|---|---|
|
|
832
|
+
| `key` | `string` | |
|
|
833
|
+
| `dir` | `SortDir` | |
|
|
834
|
+
|
|
835
|
+
### `ColumnFilterOptions`
|
|
836
|
+
|
|
837
|
+
| Field | Type | Description |
|
|
838
|
+
|---|---|---|
|
|
839
|
+
| `type`? | `FilterType` | |
|
|
840
|
+
| `options`? | `readonly FilterOption[] \| FilterOptionsLoader` | Choices for a `set` filter: a list, or a loader called with the search text (e.g. from a; backend — honour `signal`). Default: distinct values from the rows. |
|
|
841
|
+
| `placeholder`? | `string` | Placeholder of the filter-row input. |
|
|
842
|
+
|
|
843
|
+
### `FilterOption`
|
|
844
|
+
|
|
845
|
+
| Field | Type | Description |
|
|
846
|
+
|---|---|---|
|
|
847
|
+
| `value` | `unknown` | |
|
|
848
|
+
| `label`? | `string` | |
|
|
849
|
+
| `count`? | `number` | Shown next to the option (e.g. number of rows). |
|
|
850
|
+
|
|
851
|
+
### `MenuAction`
|
|
852
|
+
|
|
853
|
+
| Field | Type | Description |
|
|
854
|
+
|---|---|---|
|
|
855
|
+
| `name` | `string` | Emitted as the action name. |
|
|
856
|
+
| `label` | `string` | |
|
|
857
|
+
| `disabled`? | `boolean` | |
|
|
858
|
+
| `tone`? | `MenuTone` | |
|
|
859
|
+
| `icon`? | `Component` | |
|
|
860
|
+
| `hint`? | `string` | Shown right-aligned, e.g. a shortcut hint. |
|
|
861
|
+
|
|
862
|
+
### `CellContext`
|
|
863
|
+
|
|
864
|
+
| Field | Type | Description |
|
|
865
|
+
|---|---|---|
|
|
866
|
+
| `row` | `T` | |
|
|
867
|
+
| `rowKey` | `RowKey` | |
|
|
868
|
+
| `column` | `ColumnDef<T>` | |
|
|
869
|
+
| `value` | `unknown` | |
|
|
870
|
+
|
|
871
|
+
### `CellActionEvent`
|
|
872
|
+
|
|
873
|
+
| Field | Type | Description |
|
|
874
|
+
|---|---|---|
|
|
875
|
+
| `name` | `string` | |
|
|
876
|
+
| `payload` | `unknown` | |
|
|
877
|
+
| `row` | `T` | |
|
|
878
|
+
| `rowKey` | `RowKey` | |
|
|
879
|
+
| `column` | `ColumnDef<T>` | |
|
|
880
|
+
|
|
881
|
+
### `CellClickEvent`
|
|
882
|
+
|
|
883
|
+
| Field | Type | Description |
|
|
884
|
+
|---|---|---|
|
|
885
|
+
| `row` | `T` | |
|
|
886
|
+
| `rowKey` | `RowKey` | |
|
|
887
|
+
| `column` | `ColumnDef<T>` | |
|
|
888
|
+
| `value` | `unknown` | |
|
|
889
|
+
| `event` | `MouseEvent \| KeyboardEvent` | |
|
|
890
|
+
|
|
891
|
+
### `ContextActionEvent`
|
|
892
|
+
|
|
893
|
+
| Field | Type | Description |
|
|
894
|
+
|---|---|---|
|
|
895
|
+
| `name` | `string` | |
|
|
896
|
+
| `item` | `MenuAction` | |
|
|
897
|
+
| `row` | `T` | |
|
|
898
|
+
| `rowKey` | `RowKey` | |
|
|
899
|
+
| `column` | `ColumnDef<T>` | |
|
|
900
|
+
| `value` | `unknown` | |
|
|
901
|
+
|
|
902
|
+
### `HeaderActionEvent`
|
|
903
|
+
|
|
904
|
+
| Field | Type | Description |
|
|
905
|
+
|---|---|---|
|
|
906
|
+
| `name` | `string` | |
|
|
907
|
+
| `item` | `MenuAction` | |
|
|
908
|
+
| `column` | `ColumnDef<T>` | |
|
|
909
|
+
|
|
910
|
+
### `VueGridConfig`
|
|
911
|
+
|
|
912
|
+
| Field | Type | Description |
|
|
913
|
+
|---|---|---|
|
|
914
|
+
| `renderers`? | `CellRendererDefinition[]` | |
|
|
915
|
+
| `features`? | `readonly GridFeature[]` | Features every grid in the app gets (`allFeatures` for all of them). |
|
|
916
|
+
| `locale`? | `string` | |
|
|
917
|
+
| `currency`? | `string` | |
|
|
918
|
+
| `timeZone`? | `string` | |
|
|
919
|
+
| `density`? | `Density` | |
|
|
920
|
+
|
|
921
|
+
---
|
|
922
|
+
|
|
923
|
+
# README
|
|
924
|
+
|
|
925
|
+
# @nocopypaste/vue-grid
|
|
926
|
+
|
|
927
|
+
A data grid for Vue 3 built on **CSS Grid** — with real `subgrid` sub-rows, pinned columns, column
|
|
928
|
+
reorder/visibility with persistence, selection, virtual scrolling, pagination, a pluggable
|
|
929
|
+
**cell-renderer registry** for 3rd-party addons, and a theme you customise with **CSS variables**.
|
|
930
|
+
|
|
931
|
+
- Vue `^3.5` peer dependency, zero runtime dependencies, fully typed (`<VGrid generic="T">`).
|
|
932
|
+
- Plain CSS in `@layer vue-grid` — your CSS / Tailwind utilities override it without `!important`.
|
|
933
|
+
Published minified (Lightning CSS, no transpiling).
|
|
934
|
+
- Built for big data: virtual scrolling with sub-grids and detail rows, cell-level partial updates,
|
|
935
|
+
a GPU-animated change highlight — see [Performance](#performance).
|
|
936
|
+
- Safe with untrusted row data: no `v-html` / `innerHTML` anywhere. Link renderers allow only
|
|
937
|
+
http(s), mailto and tel, and URLs are checked after the cleanup browsers apply (so `java\tscript:`
|
|
938
|
+
is caught). Value maps ignore inherited keys, and saved state is validated.
|
|
939
|
+
|
|
940
|
+
**New here? Start with the [examples cookbook](../../docs/examples.md)** — runnable snippets for every
|
|
941
|
+
feature. This README is the API reference.
|
|
942
|
+
|
|
943
|
+
## Install
|
|
944
|
+
|
|
945
|
+
```sh
|
|
946
|
+
npm i @nocopypaste/vue-grid
|
|
947
|
+
```
|
|
948
|
+
|
|
949
|
+
The package is built for a bundler (Vite, webpack, Rollup, esbuild, or a framework built on one),
|
|
950
|
+
like Vue's own `esm-bundler` build. Dev-only warnings are wrapped in
|
|
951
|
+
`process.env.NODE_ENV !== 'production'`, which the bundler replaces, so they disappear from
|
|
952
|
+
production builds. Loading the files straight in a browser (an import map or CDN `<script>`, no
|
|
953
|
+
build step) throws `process is not defined`. If you must do that, define it first:
|
|
954
|
+
`<script>window.process = { env: { NODE_ENV: 'production' } }</script>`.
|
|
955
|
+
|
|
956
|
+
```ts
|
|
957
|
+
// main.ts
|
|
958
|
+
import { createApp } from 'vue'
|
|
959
|
+
import { createVueGrid } from '@nocopypaste/vue-grid'
|
|
960
|
+
import '@nocopypaste/vue-grid/style.css'
|
|
961
|
+
|
|
962
|
+
createApp(App)
|
|
963
|
+
.use(createVueGrid({ locale: 'en-US', currency: 'EUR' })) // optional: app-wide defaults
|
|
964
|
+
.mount('#app')
|
|
965
|
+
```
|
|
966
|
+
|
|
967
|
+
## Quick start
|
|
968
|
+
|
|
969
|
+
```vue
|
|
970
|
+
<script setup lang="ts">
|
|
971
|
+
import { ref } from 'vue'
|
|
972
|
+
import {
|
|
973
|
+
VGrid,
|
|
974
|
+
createColumnHelper,
|
|
975
|
+
currencyRenderer,
|
|
976
|
+
dateTimeRenderer,
|
|
977
|
+
numberRenderer,
|
|
978
|
+
columnPinningFeature,
|
|
979
|
+
sortingFeature,
|
|
980
|
+
statusRenderer,
|
|
981
|
+
type SortState,
|
|
982
|
+
} from '@nocopypaste/vue-grid'
|
|
983
|
+
|
|
984
|
+
interface Order { id: number; customer: { name: string }; total: number; status: 'Paid' | 'Open'; placedAt: string }
|
|
985
|
+
|
|
986
|
+
const rows = ref<Order[]>([/* … */])
|
|
987
|
+
const sort = ref<SortState | null>(null)
|
|
988
|
+
|
|
989
|
+
const col = createColumnHelper<Order>()
|
|
990
|
+
const columns = [
|
|
991
|
+
col({ key: 'id', header: '#', renderer: numberRenderer, width: 'min-content', pinned: 'left' }),
|
|
992
|
+
col({ key: 'customer', header: 'Customer', field: 'customer.name', sortable: true, width: 'minmax(10rem, 1fr)' }),
|
|
993
|
+
col({ key: 'total', header: 'Total', renderer: currencyRenderer, sortable: true }),
|
|
994
|
+
col({ key: 'status', header: 'Status', renderer: statusRenderer, rendererOptions: { tone: { Paid: 'success', Open: 'info' } } }),
|
|
995
|
+
col({ key: 'placedAt', header: 'Placed', renderer: dateTimeRenderer }),
|
|
996
|
+
]
|
|
997
|
+
</script>
|
|
998
|
+
|
|
999
|
+
<template>
|
|
1000
|
+
<VGrid
|
|
1001
|
+
v-model:sort="sort"
|
|
1002
|
+
:rows="rows"
|
|
1003
|
+
:columns="columns"
|
|
1004
|
+
row-key="id"
|
|
1005
|
+
:features="[sortingFeature, columnPinningFeature]"
|
|
1006
|
+
sort-mode="client"
|
|
1007
|
+
style="height: 480px"
|
|
1008
|
+
/>
|
|
1009
|
+
</template>
|
|
1010
|
+
```
|
|
1011
|
+
|
|
1012
|
+
`createColumnHelper<T>()` is optional; it types each column's `rendererOptions` from its renderer.
|
|
1013
|
+
|
|
1014
|
+
## Features: everything optional
|
|
1015
|
+
|
|
1016
|
+
Out of the box `<VGrid>` is a plain, read-only table: columns with any renderer and any width,
|
|
1017
|
+
saved column state (`storage`), detail rows, tabbable controls and theming. Everything else is
|
|
1018
|
+
an opt-in feature:
|
|
1019
|
+
|
|
1020
|
+
| Feature | Turns on |
|
|
1021
|
+
|---|---|
|
|
1022
|
+
| `sortingFeature` | Sort buttons on `sortable` headers, the header menu's sort items, `sort-mode="client"` sorting |
|
|
1023
|
+
| `filteringFeature` | Funnels on `filterable` headers, `filter-row`, `<VGridSearch>`, `v-model:filters`, `filter-storage`, the header menu's filter items |
|
|
1024
|
+
| `serverDataFeature` | `data-source`: the grid fetches sorted, filtered pages itself |
|
|
1025
|
+
| `paginationFeature` | `pagination` and `v-model:page` / `v-model:page-size` (the standalone `<VGridPagination>` doesn't need it) |
|
|
1026
|
+
| `selectionFeature` | `selectable` (multi or single), `v-model:selected`, `selection-mode`, `is-row-selectable`, select-all, Space to select |
|
|
1027
|
+
| `subGridsFeature` | `sub-rows` / `load-sub-rows` / `has-sub-rows`: nested rows in a CSS `subgrid` (detail rows don't need it) |
|
|
1028
|
+
| `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 |
|
|
1029
|
+
| `columnReorderFeature` | Dragging headers to reorder (mouse and pen; on touch, hold the header first), Alt+←/→ on a header, the header menu's Move items |
|
|
1030
|
+
| `columnPinningFeature` | Sticky `pinned: 'left' \| 'right'` columns with edge shadows, the header menu's Pin items; without it pins are ignored |
|
|
1031
|
+
| `virtualScrollingFeature` | `virtual: { rowHeight, overscan?, detailHeight? }`: only the rows in view render, sub-grids and detail rows included; without it every row renders |
|
|
1032
|
+
| `columnVisibilityFeature` | `hidden: true` columns, `columnState.hidden`, the header menu's Hide column item; without it every column shows |
|
|
1033
|
+
| `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 |
|
|
1034
|
+
| `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 |
|
|
1035
|
+
| `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) |
|
|
1036
|
+
| `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 |
|
|
1037
|
+
| `aggregationFeature` | Column `aggregate` (`sum`, `avg`, `min`, `max`, `count`, a function) and `totals`: a sticky totals row over the filtered rows |
|
|
1038
|
+
|
|
1039
|
+
```ts
|
|
1040
|
+
// per grid
|
|
1041
|
+
<VGrid :features="[sortingFeature, filteringFeature]" … />
|
|
1042
|
+
|
|
1043
|
+
// or for every grid in the app (merged with each grid's own list)
|
|
1044
|
+
app.use(createVueGrid({ features: [sortingFeature, filteringFeature] }))
|
|
1045
|
+
app.use(createVueGrid({ features: allFeatures })) // all of them
|
|
1046
|
+
```
|
|
1047
|
+
|
|
1048
|
+
Only the features you import reach your bundle. Without its feature, an option does nothing:
|
|
1049
|
+
a `sortable` column is a plain header and `data-source` is never called. In development a warning
|
|
1050
|
+
names the feature to add. A grid reads `features` once, when it is created; to change them,
|
|
1051
|
+
re-create it (for example with a `:key`).
|
|
1052
|
+
|
|
1053
|
+
## Tree-shaking: import only what you use
|
|
1054
|
+
|
|
1055
|
+
The package is ESM, one file per module, with `sideEffects` limited to CSS — bundlers keep only
|
|
1056
|
+
what you import.
|
|
1057
|
+
|
|
1058
|
+
- **Features are opt-in** (see above).
|
|
1059
|
+
- **Renderers are opt-in.** `<VGrid>` bundles just the default `text` renderer. Use others either
|
|
1060
|
+
- **per column** (recommended, smallest bundle, typed options): `renderer: currencyRenderer`, or
|
|
1061
|
+
- **by name**, after registering them: `createVueGrid({ renderers: [currencyRenderer, statusRenderer] })`
|
|
1062
|
+
or `<VGrid :renderers="[…]">`, then `renderer: 'currency'`. `allRenderers` registers every built-in.
|
|
1063
|
+
An unregistered name renders as plain text and logs a dev warning saying how to register it.
|
|
1064
|
+
- **Components and helpers** (`VGridPagination`, `VGridColumnMenu`, `VGridMenu`, `sortRows`, …) are
|
|
1065
|
+
only bundled when imported.
|
|
1066
|
+
- **CSS**: `@nocopypaste/vue-grid/style.css` has everything. Pick parts instead:
|
|
1067
|
+
|
|
1068
|
+
| File | What | gzip |
|
|
1069
|
+
|---|---|---|
|
|
1070
|
+
| `base.css` | Structure only: grid layout, subgrid, sticky header and pins, tree indent, popover placement, virtual rows, pinned rows, truncation | 2.2 kB |
|
|
1071
|
+
| `theme.css` | The default look on top of `base.css`: `--vg-*` tokens, colours, dark mode, densities, spacing, borders, typography, shadows, animation | 3.2 kB |
|
|
1072
|
+
| `core.css` | `base.css` + `theme.css` | 5.0 kB |
|
|
1073
|
+
| `renderers.css` | Styles for the cell renderers (other than text); uses the theme's tokens | 2.2 kB |
|
|
1074
|
+
| `style.css` | All of the above | 6.5 kB |
|
|
1075
|
+
|
|
1076
|
+
For a fully custom look, import only `base.css` (and `renderers.css` if you use renderers)
|
|
1077
|
+
and style the `.vg-*` classes yourself. See [Theming](#theming).
|
|
1078
|
+
|
|
1079
|
+
| Import (minified / gzip, Vue excluded) | Initial chunk |
|
|
1080
|
+
|---|---|
|
|
1081
|
+
| `VGrid` (no features) | 37.2 kB / 13.2 kB |
|
|
1082
|
+
| `VGrid` + `sortingFeature` | 38.0 kB / 13.5 kB |
|
|
1083
|
+
| `VGrid` + `filteringFeature` | 40.9 kB / 14.5 kB |
|
|
1084
|
+
| `VGrid` + `serverDataFeature` | 38.6 kB / 13.8 kB |
|
|
1085
|
+
| `VGrid` + `paginationFeature` | 37.4 kB / 13.2 kB |
|
|
1086
|
+
| `VGrid` + `selectionFeature` | 39.6 kB / 14.0 kB |
|
|
1087
|
+
| `VGrid` + `subGridsFeature` | 39.5 kB / 14.0 kB |
|
|
1088
|
+
| `VGrid` + `menusFeature` | 47.7 kB / 16.8 kB |
|
|
1089
|
+
| `VGrid` + `columnReorderFeature` | 40.9 kB / 14.5 kB |
|
|
1090
|
+
| `VGrid` + `columnPinningFeature` | 39.5 kB / 14.1 kB |
|
|
1091
|
+
| `VGrid` + `virtualScrollingFeature` | 43.0 kB / 15.5 kB |
|
|
1092
|
+
| `VGrid` + `columnVisibilityFeature` | 37.4 kB / 13.2 kB |
|
|
1093
|
+
| `VGrid` + `keyboardNavigationFeature` | 39.6 kB / 14.0 kB |
|
|
1094
|
+
| `VGrid` + `columnResizingFeature` | 40.1 kB / 14.3 kB |
|
|
1095
|
+
| `VGrid` + `columnGroupsFeature` | 38.8 kB / 13.8 kB |
|
|
1096
|
+
| `VGrid` + `rowPinningFeature` | 42.4 kB / 14.7 kB |
|
|
1097
|
+
| `VGrid` + `aggregationFeature` | 42.7 kB / 14.8 kB |
|
|
1098
|
+
| `VGrid` + `allFeatures` + `VGridSearch` | 81.0 kB / 28.1 kB |
|
|
1099
|
+
| `VGrid` + `currencyRenderer` | 38.5 kB / 13.6 kB |
|
|
1100
|
+
| `VGrid` + `VGridPagination` + `VGridColumnMenu` | 41.6 kB / 14.7 kB |
|
|
1101
|
+
| `sortRows` only | 0.7 kB / 0.5 kB |
|
|
1102
|
+
| everything | 124.1 kB / 40.4 kB |
|
|
1103
|
+
| `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) | 57.5 kB / 15.4 kB |
|
|
1104
|
+
|
|
1105
|
+
With `filteringFeature`, the filter popover body and the filter-row editors are **on-demand
|
|
1106
|
+
chunks**: they load the first time a popover opens or `filter-row` is on. With
|
|
1107
|
+
`paginationFeature`, the pager is one too. Measured with esbuild (`--bundle --minify --splitting`,
|
|
1108
|
+
`process.env.NODE_ENV` set to `production`, which also drops the dev warnings).
|
|
1109
|
+
|
|
1110
|
+
## `<VGrid>` API
|
|
1111
|
+
|
|
1112
|
+
### Props
|
|
1113
|
+
|
|
1114
|
+
| Prop | Type | Default | |
|
|
1115
|
+
|---|---|---|---|
|
|
1116
|
+
| `rows` | `T[]` | `[]` | Your data objects, used as-is (never mutated). Not needed with `dataSource`. |
|
|
1117
|
+
| `features` | `GridFeature[]` | — | Opt-in features for this grid, added to the app-wide ones. See [Features](#features-everything-optional). |
|
|
1118
|
+
| `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). |
|
|
1119
|
+
| `columns` | `ColumnDef<T>[]` | — | See below. |
|
|
1120
|
+
| `rowKey` | `keyof T \| (row) => string \| number` | — | Stable unique id; all row state is keyed by it. |
|
|
1121
|
+
| `v-model:sort` | `{ key, dir: 'asc' \| 'desc' } \| null` | `null` | Header click cycles asc → desc → none. Needs `sortingFeature` for the header UI. |
|
|
1122
|
+
| `sortMode` | `'controlled' \| 'client'` | `'controlled'` | `controlled` only emits (server-side sorting). Ignored with `dataSource`. |
|
|
1123
|
+
| `v-model:filters` | `FilterState \| null` | `null` | `{ columns: Record<key, ColumnFilter>, search }`. Needs `filteringFeature` (as do the next four). See [Filtering](#filtering). |
|
|
1124
|
+
| `filterMode` | `'client' \| 'controlled'` | `'client'` | `controlled` only emits (server-side filtering). Ignored with `dataSource`. |
|
|
1125
|
+
| `filterRow` | `boolean` | `false` | A row of inline filter inputs under the headers. |
|
|
1126
|
+
| `filterStorage` | `string \| FilterStateStorage` | — | Persist filters (`string` = localStorage key). |
|
|
1127
|
+
| `noMatchText` | `string` | `'No rows match the current filters.'` | Shown, with a *Clear filters* button, when filters hide every row. |
|
|
1128
|
+
| `pagination` | `boolean \| { pageSizes?: number[] }` | `false` | Built-in pagination bar: slices client rows, or asks the `dataSource` for pages. Needs `paginationFeature`. |
|
|
1129
|
+
| `v-model:page` / `v-model:pageSize` | `number` | `1` / `25` | Reset to page 1 when sort or filters change. |
|
|
1130
|
+
| `v-model:columnState` | `{ order: string[]; hidden: string[]; pinned?: Record<string, "left" \| "right" \| null>; widths?: Record<string, string> }` | derived | Column order, visibility and runtime pins. |
|
|
1131
|
+
| `storage` | `string \| ColumnStateStorage` | — | Persist column state (`string` = localStorage key). |
|
|
1132
|
+
| `v-model:expanded` | `RowKey[]` | `[]` | Expanded rows (sub-grids and detail rows). |
|
|
1133
|
+
| `subRows` | `(row) => T[] \| undefined` | — | Synchronous children → sub-grid. Needs `subGridsFeature` (as do the next two). |
|
|
1134
|
+
| `loadSubRows` | `(row) => Promise<T[]>` | — | Lazy children (cached, loading/error/retry). |
|
|
1135
|
+
| `hasSubRows` | `(row) => boolean` | — | Which rows get an expander when lazy. |
|
|
1136
|
+
| `rowExpandable` | `(row) => boolean` | — | Which rows can open the `#detail` slot. |
|
|
1137
|
+
| `selectable` | `boolean \| 'single'` | `false` | Adds a selection column. Needs `selectionFeature` (as do the next three). |
|
|
1138
|
+
| `v-model:selected` | `RowKey[]` | `[]` | |
|
|
1139
|
+
| `selectionMode` | `'cascade' \| 'independent'` | `'cascade'` | Whether selecting a parent selects its children. |
|
|
1140
|
+
| `isRowSelectable` | `(row) => boolean` | — | |
|
|
1141
|
+
| `virtual` | `{ rowHeight: number; overscan?: number; detailHeight?: number } \| false` | `false` | Virtual scrolling (fixed-height rows; sub-grids and measured detail rows included). Needs `virtualScrollingFeature`. |
|
|
1142
|
+
| `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). |
|
|
1143
|
+
| `pinnedTopRows` / `pinnedBottomRows` | `T[]` | — | Extra pinned rows that aren't part of `rows` (a target, last year's figures). |
|
|
1144
|
+
| `totals` | `boolean \| 'top' \| 'bottom'` | `false` | A totals row with each column's `aggregate`; `true` = `'bottom'`. Needs `aggregationFeature` (as do the next two). |
|
|
1145
|
+
| `totalsLabel` | `string` | `'Total'` | Shown in the totals row's first column (unless that column has an aggregate). |
|
|
1146
|
+
| `aggregates` | `Record<string, unknown>` | — | Totals by column key, used instead of computing them (e.g. from a server). |
|
|
1147
|
+
| `rowClickable` | `boolean` | `false` | Pointer cursor; `row-click` is always emitted. |
|
|
1148
|
+
| `rowClass` | `(row, index) => ClassValue` | — | |
|
|
1149
|
+
| `highlightedRows` | `RowKey[]` | — | |
|
|
1150
|
+
| `flash` | `boolean \| 'direction'` | `false` | Briefly highlight cells whose value changes; `'direction'` = green up / red down. Columns override with `flash`. |
|
|
1151
|
+
| `renderers` | `CellRendererDefinition[]` | — | Renderers usable by name in this grid (override plugin ones). |
|
|
1152
|
+
| `locale` / `currency` / `timeZone` | `string` | plugin → browser | Formatting context for renderers. |
|
|
1153
|
+
| `density` | `'compact' \| 'cozy' \| 'comfortable'` | `'cozy'` | Scales cell padding. |
|
|
1154
|
+
| `loading` | `boolean` | `false` | Progress bar + `aria-busy`. |
|
|
1155
|
+
| `emptyText` | `string` | `'No data to show.'` | |
|
|
1156
|
+
| `ariaLabel` | `string` | — | |
|
|
1157
|
+
| `contextMenu` | `(ctx: { row, rowKey, column, value }) => MenuItem[] \| null` | — | Right-click menu for body cells. Needs `menusFeature`. |
|
|
1158
|
+
| `headerMenu` | `boolean \| ({ column, items }) => MenuItem[] \| null` | `true` | Built-in header menu (sort, pin, move, hide, reset). Needs `menusFeature`. |
|
|
1159
|
+
| `ui` | `Partial<Record<'root' \| 'header' \| 'headerCell' \| 'row' \| 'cell' \| 'subgrid' \| 'detail' \| 'empty', ClassValue>>` | — | Extra classes per part (Tailwind-friendly). |
|
|
1160
|
+
|
|
1161
|
+
### Events
|
|
1162
|
+
|
|
1163
|
+
`row-click(row, event)` · `cell-click({ row, rowKey, column, value, event })` (columns with `clickable: true`) ·
|
|
1164
|
+
`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 })` ·
|
|
1165
|
+
`query-change(query: GridQuery)` (sort + filters + page as one object, on mount and on every real change) ·
|
|
1166
|
+
`load-error(error)` (a `dataSource` call failed) ·
|
|
1167
|
+
plus the `update:*` events of every `v-model`.
|
|
1168
|
+
|
|
1169
|
+
Clicks on links, buttons and inputs inside a cell never trigger `row-click`.
|
|
1170
|
+
|
|
1171
|
+
### Slots
|
|
1172
|
+
|
|
1173
|
+
`cell-<key>` (`{ row, value, rowKey, rowIndex, depth, column }`) · `header-<key>` (`{ column }`) ·
|
|
1174
|
+
`total-<key>` (`{ value, column }`, a cell of the totals row) · `detail` (`{ row, rowKey, depth }`) ·
|
|
1175
|
+
`toolbar` (`{ columns, columnState, setColumnState, filters, setFilters, clearFilters, activeFilterCount }`) ·
|
|
1176
|
+
`empty` · `loading` · `sub-rows-loading` (`{ row }`).
|
|
1177
|
+
|
|
1178
|
+
### Exposed methods
|
|
1179
|
+
|
|
1180
|
+
```ts
|
|
1181
|
+
const grid = ref<VGridExposed>()
|
|
1182
|
+
grid.value?.scrollToTop() / scrollToRow(key) / expandAll() / collapseAll() / setColumnState(state)
|
|
1183
|
+
grid.value?.patchLoadedRows([{ id: 'c2', city: 'Niš' }]) // field updates for lazy children and dataSource rows
|
|
1184
|
+
grid.value?.setFilters({ columns: { city: { type: 'text', op: 'contains', value: 'nis' } } })
|
|
1185
|
+
grid.value?.clearFilters() / openFilter('city') / reload() // reload: re-run the dataSource query
|
|
1186
|
+
grid.value?.reloadSubRows('c2') // forget lazily loaded children (of one row, or all): they load again
|
|
1187
|
+
grid.value?.pinRow(42, 'top') // pin a row above the body ('bottom' below it, null to unpin): rowPinningFeature
|
|
1188
|
+
```
|
|
1189
|
+
|
|
1190
|
+
`reload()` also forgets lazily loaded children, as does passing a different `load-sub-rows`
|
|
1191
|
+
function. With `selection-mode="cascade"`, children that load under a selected parent arrive
|
|
1192
|
+
selected.
|
|
1193
|
+
|
|
1194
|
+
### Partial updates
|
|
1195
|
+
|
|
1196
|
+
Changing part of the data re-renders only what changed — the table is never rebuilt:
|
|
1197
|
+
|
|
1198
|
+
- **Reactive rows** (`reactive()` / `ref()`): assign the field — `row.city = 'Niš'` — and only that
|
|
1199
|
+
cell re-renders.
|
|
1200
|
+
- **Immutable rows** (e.g. a `shallowRef` holding a large list): replace the changed rows and keep
|
|
1201
|
+
the others' identity. `patchRows(rows, patches, rowKey)` does exactly that for a batch of
|
|
1202
|
+
patches by key; only the patched rows re-render, and a batch that changes nothing returns the
|
|
1203
|
+
same array.
|
|
1204
|
+
- **Lazily loaded children** live in the grid's cache: use `grid.patchLoadedRows(patches)`.
|
|
1205
|
+
|
|
1206
|
+
Mutating a field in place under a `shallowRef` is not observed — assign a new array (`patchRows`)
|
|
1207
|
+
or use reactive rows.
|
|
1208
|
+
|
|
1209
|
+
**Change highlight.** `<VGrid flash>` briefly tints cells whose value changes (not on first render,
|
|
1210
|
+
not when a re-fetched row has equal values); `flash="direction"` tints numbers green when they rise
|
|
1211
|
+
and red when they fall. Columns override with `flash: false | true | 'direction'`. It's a CSS
|
|
1212
|
+
animation — tune it with `--vg-flash-color`, `--vg-flash-up`, `--vg-flash-down`,
|
|
1213
|
+
`--vg-flash-duration`. With `prefers-reduced-motion` the tint is held briefly instead of fading.
|
|
1214
|
+
The tint is a `::after` layer under the cell's content that fades with `opacity`, which browsers
|
|
1215
|
+
animate on the compositor (GPU): a busy live feed costs the main thread about a sixth of what a
|
|
1216
|
+
`background-color` animation would.
|
|
1217
|
+
|
|
1218
|
+
### `ColumnDef<T>`
|
|
1219
|
+
|
|
1220
|
+
```ts
|
|
1221
|
+
{
|
|
1222
|
+
key: string // unique; used by sort, column state and slot names
|
|
1223
|
+
header?: string; headerTooltip?: string
|
|
1224
|
+
field?: string // dot path, defaults to key
|
|
1225
|
+
value?: (row) => unknown // computed value, wins over field
|
|
1226
|
+
renderer?: RendererDefinition | string | Component // currencyRenderer (tree-shakeable), a registered name, or a component; default text
|
|
1227
|
+
rendererOptions?: object // typed from the renderer
|
|
1228
|
+
width?: string // any grid track: 'auto' (default), '8rem', '1fr', 'minmax(8rem, 2fr)', 'min-content'
|
|
1229
|
+
minWidth?: string // combined into minmax(minWidth, width); also the resize minimum
|
|
1230
|
+
maxWidth?: string // resize maximum (columnResizingFeature)
|
|
1231
|
+
resizable?: boolean // can the user resize it (columnResizingFeature, default true)
|
|
1232
|
+
group?: string // header group label (columnGroupsFeature)
|
|
1233
|
+
align?: 'start' | 'center' | 'end'
|
|
1234
|
+
sortable?: boolean; sortValue?: (row) => unknown; sortFn?: (a, b) => number
|
|
1235
|
+
pinned?: 'left' | 'right'; pinnable?: boolean // needs columnPinningFeature; pinnable: can the header menu change it (default true)
|
|
1236
|
+
hidden?: boolean; hideable?: boolean // need columnVisibilityFeature
|
|
1237
|
+
reorderable?: boolean // needs columnReorderFeature (default true)
|
|
1238
|
+
clickable?: boolean
|
|
1239
|
+
flash?: boolean | 'direction' // change highlight for this column (overrides the grid's `flash`)
|
|
1240
|
+
filterable?: boolean // funnel button in the header (and an input in the filter row)
|
|
1241
|
+
filter?: 'text' | 'number' | 'date' | 'boolean' | 'set'
|
|
1242
|
+
| { type?, options?: FilterOption[] | ((search, { signal }) => Promise<FilterOption[]>), placeholder? }
|
|
1243
|
+
filterValue?: (row) => unknown // value filters compare (default: the cell value)
|
|
1244
|
+
filterFn?: (row, filter) => boolean // replaces the built-in matching for this column
|
|
1245
|
+
filterComponent?: Component // custom popover body: props { modelValue, column }, emits update:modelValue
|
|
1246
|
+
searchable?: boolean // included in the quick search (default true for visible columns)
|
|
1247
|
+
aggregate?: 'sum' | 'avg' | 'min' | 'max' | 'count' | ((values, rows) => unknown) // totals row (aggregationFeature)
|
|
1248
|
+
cellClass?: ClassValue | ((row) => ClassValue); headerClass?: ClassValue
|
|
1249
|
+
}
|
|
1250
|
+
```
|
|
1251
|
+
|
|
1252
|
+
## Sub-grids (CSS `subgrid`)
|
|
1253
|
+
|
|
1254
|
+
```vue
|
|
1255
|
+
<VGrid :rows="markets" :columns="columns" row-key="id" :sub-rows="(row) => row.children" selectable />
|
|
1256
|
+
```
|
|
1257
|
+
|
|
1258
|
+
Expanded children render inside a `.vg-subgrid` element that spans every column and uses
|
|
1259
|
+
`grid-template-columns: subgrid` — so each child cell sits exactly in its parent's column, at any
|
|
1260
|
+
depth. Children reuse the parent's columns: reorder, hide and pin apply automatically. The first
|
|
1261
|
+
column is indented per depth (`--vg-subgrid-indent`), rows get `aria-level`, the grid becomes a
|
|
1262
|
+
`treegrid`. With `loadSubRows` children are fetched on first expand.
|
|
1263
|
+
|
|
1264
|
+
Need children with a **different** set of columns? Put another `<VGrid>` in the `#detail` slot.
|
|
1265
|
+
|
|
1266
|
+
## Column menu, reorder, persistence
|
|
1267
|
+
|
|
1268
|
+
```vue
|
|
1269
|
+
<VGrid :rows :columns row-key="id" storage="orders-grid" :features="[columnVisibilityFeature, columnReorderFeature]">
|
|
1270
|
+
<!-- the picker hides columns (columnVisibilityFeature); dragging headers needs columnReorderFeature -->
|
|
1271
|
+
<template #toolbar="{ columnState, setColumnState }">
|
|
1272
|
+
<VGridColumnMenu :columns="columns" :column-state="columnState" @update:column-state="setColumnState($event!)" />
|
|
1273
|
+
</template>
|
|
1274
|
+
</VGrid>
|
|
1275
|
+
```
|
|
1276
|
+
|
|
1277
|
+
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
|
|
1278
|
+
**Alt+←/→**. Pinned columns only move within their pin group. Stored state is reconciled with the
|
|
1279
|
+
current column definitions (unknown keys dropped, new columns appended).
|
|
1280
|
+
|
|
1281
|
+
## Context menus
|
|
1282
|
+
|
|
1283
|
+
Menus use the **Popover API** (top layer — never clipped by the grid's scroll container; Esc and
|
|
1284
|
+
outside click close them) and **CSS anchor positioning** (`position-anchor` + `position-area` +
|
|
1285
|
+
`position-try-fallbacks`): they flip to stay on screen and follow their anchor while the grid
|
|
1286
|
+
scrolls. No JS positioning, except a small fallback for browsers without anchor positioning.
|
|
1287
|
+
|
|
1288
|
+
### Body cells
|
|
1289
|
+
|
|
1290
|
+
```vue
|
|
1291
|
+
<VGrid
|
|
1292
|
+
:rows :columns row-key="id"
|
|
1293
|
+
:context-menu="({ row, column, value }) => column.key === 'link' ? [] : [
|
|
1294
|
+
{ name: 'copy', label: 'Copy', hint: 'Ctrl+C' },
|
|
1295
|
+
{ name: 'open', label: `Open #${row.id}` },
|
|
1296
|
+
{ separator: true },
|
|
1297
|
+
{ name: 'delete', label: 'Delete', tone: 'danger', disabled: !row.canDelete },
|
|
1298
|
+
]"
|
|
1299
|
+
@context-action="({ name, row, column, value }) => run(name, row)"
|
|
1300
|
+
/>
|
|
1301
|
+
```
|
|
1302
|
+
|
|
1303
|
+
Right-click opens the menu at the pointer; the **ContextMenu** key or **Shift+F10** opens it under the
|
|
1304
|
+
focused cell. Return `[]`/`null` to keep the browser's native menu for that cell. Items:
|
|
1305
|
+
`{ name, label, disabled?, tone?, icon?, hint? }` or `{ separator: true }`. Arrow keys, Home/End and
|
|
1306
|
+
typeahead move through items; focus returns to the cell on close.
|
|
1307
|
+
|
|
1308
|
+
### Column headers
|
|
1309
|
+
|
|
1310
|
+
Right-clicking a header opens a built-in menu: **Sort ascending / descending / Clear sort** (sortable
|
|
1311
|
+
columns), **Pin left / Pin right / Unpin**, **Move left / right**, **Hide column**, **Reset columns**.
|
|
1312
|
+
Pin items need `columnPinningFeature`, move items `columnReorderFeature`, Hide column `columnVisibilityFeature`. Runtime pins are stored in column state (`columnState.pinned`) and persisted with `storage`.
|
|
1313
|
+
|
|
1314
|
+
```vue
|
|
1315
|
+
<!-- extend (or replace) the built-in items; custom items emit header-action -->
|
|
1316
|
+
<VGrid :header-menu="({ column, items }) => [{ name: 'copy', label: 'Copy column' }, { separator: true }, ...items]"
|
|
1317
|
+
@header-action="({ name, column }) => …" />
|
|
1318
|
+
<VGrid :header-menu="false" /> <!-- off -->
|
|
1319
|
+
```
|
|
1320
|
+
|
|
1321
|
+
Columns opt out with `pinnable: false`, `reorderable: false`, `hideable: false`.
|
|
1322
|
+
|
|
1323
|
+
### `VGridMenu` for your own triggers
|
|
1324
|
+
|
|
1325
|
+
The same component powers the `actions-menu` renderer and is exported for add-ons:
|
|
1326
|
+
|
|
1327
|
+
```vue
|
|
1328
|
+
<button popovertarget="row-menu" :style="{ 'anchor-name': '--row-menu' }">⋮</button>
|
|
1329
|
+
<VGridMenu id="row-menu" anchor-name="--row-menu" :items="items" @select="(item) => …" />
|
|
1330
|
+
<!-- or imperatively: menuRef.value.openAt(element | { x, y }) -->
|
|
1331
|
+
```
|
|
1332
|
+
|
|
1333
|
+
## Filtering
|
|
1334
|
+
|
|
1335
|
+
```vue
|
|
1336
|
+
<script setup lang="ts">
|
|
1337
|
+
import { VGrid, VGridSearch, filteringFeature, numberRenderer, statusRenderer, type FilterState } from '@nocopypaste/vue-grid'
|
|
1338
|
+
|
|
1339
|
+
const filters = ref<FilterState | null>(null)
|
|
1340
|
+
const columns = [
|
|
1341
|
+
{ key: 'player', header: 'Player', filterable: true }, // text
|
|
1342
|
+
{ key: 'stake', header: 'Stake', filterable: true, renderer: numberRenderer }, // number (from the renderer)
|
|
1343
|
+
{ key: 'status', header: 'Status', filterable: true, renderer: statusRenderer },// value list
|
|
1344
|
+
{ key: 'placedAt', header: 'Placed', filterable: true, filter: 'date' }, // explicit type
|
|
1345
|
+
]
|
|
1346
|
+
</script>
|
|
1347
|
+
|
|
1348
|
+
<template>
|
|
1349
|
+
<VGrid v-model:filters="filters" :rows :columns row-key="id" :features="[filteringFeature]"
|
|
1350
|
+
filter-row filter-storage="bets-filters">
|
|
1351
|
+
<template #toolbar="{ activeFilterCount, clearFilters }">
|
|
1352
|
+
<VGridSearch />
|
|
1353
|
+
<button v-if="activeFilterCount" @click="clearFilters()">Clear {{ activeFilterCount }} filters</button>
|
|
1354
|
+
</template>
|
|
1355
|
+
</VGrid>
|
|
1356
|
+
</template>
|
|
1357
|
+
```
|
|
1358
|
+
|
|
1359
|
+
- **Header funnel.** Each `filterable` column gets a funnel button. It is hidden until you hover the
|
|
1360
|
+
header (on devices that can hover) and stays visible while a filter is active. It opens a
|
|
1361
|
+
popover through the Popover API and CSS anchor positioning, and the popover holds an editor for
|
|
1362
|
+
the column's type:
|
|
1363
|
+
|
|
1364
|
+
| Type | Editor | Operators |
|
|
1365
|
+
|---|---|---|
|
|
1366
|
+
| `text` | operator + value | contains, does not contain, equals, does not equal, starts with, ends with, is empty, is not empty |
|
|
1367
|
+
| `number` | operator + value(s) | `=` `≠` `<` `≤` `>` `≥`, between, is empty, is not empty |
|
|
1368
|
+
| `date` | operator + date(s) | on, before, after, between, is empty, is not empty |
|
|
1369
|
+
| `boolean` | radio group | any, yes, no, empty |
|
|
1370
|
+
| `set` | searchable checkbox list with counts | (the selected values) |
|
|
1371
|
+
| `custom` | your `filterComponent` | (anything; match it with `filterFn`) |
|
|
1372
|
+
|
|
1373
|
+
The type comes from `filter`, else from the renderer (number, currency, change → `number`;
|
|
1374
|
+
date, datetime → `date`; boolean, checkbox, switch → `boolean`; status, chip → `set`), else
|
|
1375
|
+
`text`.
|
|
1376
|
+
- **Filter row** (`filter-row`). An inline input under each header that accepts shorthand:
|
|
1377
|
+
`>10`, `>=10`, `5..20`, `-5..-1`, open ranges `5..` / `..20`, `!=3`, a decimal comma (`1,5`),
|
|
1378
|
+
and `>2026-01-01` or `2026-01-01..2026-03-31` for dates; plain text for text columns. Input that
|
|
1379
|
+
doesn't parse sets no filter. Boolean columns get a select; value-list and custom columns get a
|
|
1380
|
+
button that opens the popover.
|
|
1381
|
+
- **Quick search.** `<VGridSearch>` inside the `#toolbar` slot drives that grid's search. Anywhere
|
|
1382
|
+
else, bind it with `v-model` to `filters.search`. The search matches any visible column that is
|
|
1383
|
+
not marked `searchable: false`.
|
|
1384
|
+
- **Matching** is case- and accent-insensitive (`nis` finds *Niš*). Dates compare by calendar day
|
|
1385
|
+
in the grid's `timeZone`; a date-only string (`2026-01-05`) is that calendar day in every time
|
|
1386
|
+
zone, for filtering and for the `date` renderer. Column filters combine with AND, and then the
|
|
1387
|
+
search must match too. Saved filters for columns that no longer exist are ignored.
|
|
1388
|
+
- **Long value lists** render their first 300 values; a search narrows the rest.
|
|
1389
|
+
- **Trees.** A row shows when it matches, when a descendant matches (so the path stays visible), or
|
|
1390
|
+
when an ancestor matched (so a matching group keeps its children). Select-all and cascade only
|
|
1391
|
+
touch rows that are visible.
|
|
1392
|
+
- **Value lists from a backend.** Pass `filter: { type: 'set', options: (search, { signal }) => fetch(…) }`.
|
|
1393
|
+
The list is fetched when the popover opens and again on every search (debounced). Superseded
|
|
1394
|
+
requests are cancelled.
|
|
1395
|
+
- The header menu has **Filter… / Clear filter / Clear all filters** items. When filters hide
|
|
1396
|
+
every row, the grid shows `noMatchText` with a *Clear filters* button.
|
|
1397
|
+
|
|
1398
|
+
The model is plain JSON, so you can store it, put it in the URL or send it to an API as is:
|
|
1399
|
+
|
|
1400
|
+
```ts
|
|
1401
|
+
interface FilterState { columns: Record<string, ColumnFilter>; search?: string }
|
|
1402
|
+
type ColumnFilter =
|
|
1403
|
+
| { type: 'text'; op: 'contains' | 'notContains' | 'equals' | 'notEquals' | 'startsWith' | 'endsWith' | 'empty' | 'notEmpty'; value?: string }
|
|
1404
|
+
| { type: 'number'; op: 'eq' | 'ne' | 'lt' | 'lte' | 'gt' | 'gte' | 'between' | 'empty' | 'notEmpty'; value?: number | null; to?: number | null }
|
|
1405
|
+
| { type: 'date'; op: 'on' | 'before' | 'after' | 'between' | 'empty' | 'notEmpty'; value?: string; to?: string } // YYYY-MM-DD
|
|
1406
|
+
| { type: 'boolean'; value: boolean | null }
|
|
1407
|
+
| { type: 'set'; values: string[] } // '' stands for blank cells
|
|
1408
|
+
| { type: 'custom'; value: unknown }
|
|
1409
|
+
```
|
|
1410
|
+
|
|
1411
|
+
The matchers are exported too, for use on a server or in tests: `matchesFilter`,
|
|
1412
|
+
`parseQuickFilter`, `filterTree`, `isFilterActive`, `activeFilterCount`, `foldText`.
|
|
1413
|
+
|
|
1414
|
+
**Custom filter.** A `filterComponent` gets `{ modelValue, column }` and emits
|
|
1415
|
+
`update:modelValue` with a filter (or `undefined` to clear it). Pair it with `filterFn(row, filter)`.
|
|
1416
|
+
|
|
1417
|
+
## Server data
|
|
1418
|
+
|
|
1419
|
+
Two ways to connect sorting, filtering and paging to a backend.
|
|
1420
|
+
|
|
1421
|
+
**1. `dataSource`: the grid fetches.** You give it a function. The grid calls it on mount and
|
|
1422
|
+
whenever sort, filters, page or page size change. It does not sort, filter or slice the rows
|
|
1423
|
+
itself; it shows exactly what the function returns.
|
|
1424
|
+
|
|
1425
|
+
```vue
|
|
1426
|
+
<script setup lang="ts">
|
|
1427
|
+
import { filteringFeature, paginationFeature, serverDataFeature, sortingFeature, type DataSource } from '@nocopypaste/vue-grid'
|
|
1428
|
+
|
|
1429
|
+
const fetchBets: DataSource<Bet> = async (query, { signal }) => {
|
|
1430
|
+
// query: { sort: { key, dir } | null, filters: FilterState, page: number, pageSize: number | null }
|
|
1431
|
+
const res = await fetch('/api/bets', { method: 'POST', body: JSON.stringify(query), signal })
|
|
1432
|
+
if (!res.ok) throw new Error(res.statusText)
|
|
1433
|
+
return res.json() // { rows: Bet[], total?: number }
|
|
1434
|
+
}
|
|
1435
|
+
</script>
|
|
1436
|
+
|
|
1437
|
+
<template>
|
|
1438
|
+
<VGrid ref="grid" :data-source="fetchBets" :columns row-key="id" pagination filter-row @load-error="toast"
|
|
1439
|
+
:features="[serverDataFeature, sortingFeature, filteringFeature, paginationFeature]" />
|
|
1440
|
+
</template>
|
|
1441
|
+
```
|
|
1442
|
+
|
|
1443
|
+
- **Cancellation.** A new query aborts the previous request through `signal`, and a late response
|
|
1444
|
+
from a superseded request is ignored, so fast typing never shows stale rows.
|
|
1445
|
+
- **States.** The grid shows a progress bar while loading. If the function throws, it shows
|
|
1446
|
+
*Couldn't load the rows.* with a *Retry* button and emits `load-error`.
|
|
1447
|
+
- **Paging.** `pagination` adds the pager and sends `page` / `pageSize`; return `total` so the
|
|
1448
|
+
pager knows how many pages there are. Without `pagination`, `pageSize` is `null` (fetch
|
|
1449
|
+
everything). The page resets to 1 when sort or filters change.
|
|
1450
|
+
- `grid.reload()` re-runs the current query, and `grid.patchLoadedRows(patches)` updates fields of
|
|
1451
|
+
rows that are already loaded without a refetch.
|
|
1452
|
+
|
|
1453
|
+
**2. `@query-change`: you fetch.** Keep `rows` under your control, set `sort-mode="controlled"`
|
|
1454
|
+
and `filter-mode="controlled"`, and handle one event. The grid emits the combined query on mount
|
|
1455
|
+
and on every change, and skips duplicates:
|
|
1456
|
+
|
|
1457
|
+
```vue
|
|
1458
|
+
<VGrid :rows="rows" :columns row-key="id" :loading="loading" :features="[sortingFeature, filteringFeature]"
|
|
1459
|
+
sort-mode="controlled" filter-mode="controlled" @query-change="load" />
|
|
1460
|
+
```
|
|
1461
|
+
|
|
1462
|
+
Use this when the data comes from a store, a WebSocket or a GraphQL client that you already manage.
|
|
1463
|
+
|
|
1464
|
+
## Pagination
|
|
1465
|
+
|
|
1466
|
+
`pagination` gives you a built-in pager under the grid. With client rows it slices the sorted and
|
|
1467
|
+
filtered rows; with a `dataSource` it requests pages.
|
|
1468
|
+
|
|
1469
|
+
```vue
|
|
1470
|
+
<VGrid :rows :columns row-key="id" :features="[paginationFeature]" :pagination="{ pageSizes: [10, 25, 50] }" v-model:page="page" v-model:page-size="pageSize" />
|
|
1471
|
+
```
|
|
1472
|
+
|
|
1473
|
+
Or place the standalone component yourself and feed the grid one page at a time:
|
|
1474
|
+
|
|
1475
|
+
```vue
|
|
1476
|
+
<VGrid v-model:sort="sort" :rows="pageRows" :columns row-key="id" :loading="loading" :features="[sortingFeature]" />
|
|
1477
|
+
<VGridPagination v-model:page="page" v-model:page-size="pageSize" :total="total" :page-sizes="[10, 25, 50]" />
|
|
1478
|
+
```
|
|
1479
|
+
|
|
1480
|
+
## Pinned rows and totals
|
|
1481
|
+
|
|
1482
|
+
Rows that stay in view while the body scrolls: a totals row (`aggregationFeature`) and rows pinned
|
|
1483
|
+
above or below the body (`rowPinningFeature`).
|
|
1484
|
+
|
|
1485
|
+
```vue
|
|
1486
|
+
<script setup lang="ts">
|
|
1487
|
+
const columns = [
|
|
1488
|
+
col({ key: 'player', aggregate: 'count' }),
|
|
1489
|
+
col({ key: 'stake', renderer: currencyRenderer, aggregate: 'sum' }),
|
|
1490
|
+
col({ key: 'odds', renderer: numberRenderer, aggregate: 'avg' }),
|
|
1491
|
+
col({ key: 'placedAt', renderer: dateRenderer, aggregate: 'max' }),
|
|
1492
|
+
]
|
|
1493
|
+
const pinned = ref<PinnedRowsState>({ top: [42] })
|
|
1494
|
+
</script>
|
|
1495
|
+
|
|
1496
|
+
<template>
|
|
1497
|
+
<VGrid :rows="bets" :columns="columns" row-key="id" totals v-model:pinned-rows="pinned" />
|
|
1498
|
+
</template>
|
|
1499
|
+
```
|
|
1500
|
+
|
|
1501
|
+
- **Totals.** `totals` (or `totals="bottom"`) adds a totals row at the bottom; `totals="top"`
|
|
1502
|
+
puts it under the header. Each column with an `aggregate` shows it with the column's own
|
|
1503
|
+
renderer (so a currency column sums to a currency), `count` as a plain number; the first column
|
|
1504
|
+
shows `totals-label` (`'Total'`) unless it has an aggregate. `sum` / `avg` skip values that
|
|
1505
|
+
aren't numbers, `min` / `max` compare numbers, dates and strings, and a function gets the
|
|
1506
|
+
column's values and the rows. The totals cover the top-level rows that pass the filters, on
|
|
1507
|
+
every page (child rows aren't counted), and follow live data. With server data the grid only
|
|
1508
|
+
has the current page: pass the server's totals as `aggregates` (`{ stake: 125000 }`), which
|
|
1509
|
+
wins over computed values. The `total-<key>` slot renders a cell of the row yourself.
|
|
1510
|
+
- **Pinned rows.** `v-model:pinned-rows` (`{ top, bottom }`, row keys, in display order) or
|
|
1511
|
+
`grid.pinRow(key, 'top' | 'bottom' | null)` pins top-level rows. They leave the body, stay put
|
|
1512
|
+
while it scrolls, and aren't filtered, sorted or paged; selection, row clicks and context menus
|
|
1513
|
+
still work on them. Pin from your own context menu: `@context-action` → `pinRow(rowKey, …)`.
|
|
1514
|
+
- **Extra rows.** `pinned-top-rows` / `pinned-bottom-rows` show rows that aren't part of `rows`
|
|
1515
|
+
(a target, last year's figures) — no checkbox, not counted in the totals.
|
|
1516
|
+
|
|
1517
|
+
Each section is one sticky `subgrid` container, so its rows share the grid's columns, follow
|
|
1518
|
+
resizing, reordering and pinned columns, and need no measuring of their own. Keyboard navigation
|
|
1519
|
+
moves through them like any row, and a focused row scrolls clear of them (`scroll-padding`).
|
|
1520
|
+
With virtual scrolling, `aria-rowindex` / `aria-rowcount` count them. Style them with
|
|
1521
|
+
`.vg-pinned-top`, `.vg-pinned-bottom`, `.vg-row-pinned`, `.vg-row-total` and the
|
|
1522
|
+
`--vg-total-row-bg` / `--vg-total-row-font-weight` tokens.
|
|
1523
|
+
|
|
1524
|
+
## Virtual scrolling
|
|
1525
|
+
|
|
1526
|
+
```vue
|
|
1527
|
+
<VGrid :rows="tenThousandRows" :columns row-key="id" :features="[virtualScrollingFeature]"
|
|
1528
|
+
:virtual="{ rowHeight: 40 }" style="height: 600px" />
|
|
1529
|
+
```
|
|
1530
|
+
|
|
1531
|
+
Rows have a fixed height; only the visible window plus `overscan` is rendered.
|
|
1532
|
+
|
|
1533
|
+
Sub-grids and detail rows work in virtual mode too. The DOM keeps the same CSS grid / `subgrid`
|
|
1534
|
+
structure as without it: expanded children stay inside their parent's `subgrid` container (lined up
|
|
1535
|
+
with its columns), and at every level the rows out of view are replaced by spacers, so an expanded
|
|
1536
|
+
tree of tens of thousands of rows still renders about a screenful.
|
|
1537
|
+
|
|
1538
|
+
- **Data rows** (children too) have `rowHeight`.
|
|
1539
|
+
- **Detail rows** can be any height. They're measured once rendered; until then
|
|
1540
|
+
`virtual.detailHeight` is the estimate (default 4 × `rowHeight`).
|
|
1541
|
+
- **Lazy children** (`load-sub-rows`) are requested only for expanded rows in view, once a scroll
|
|
1542
|
+
has settled, so flying past expanded rows doesn't fire their requests.
|
|
1543
|
+
- **The view holds still** when rows above it change height (a detail row measured, children
|
|
1544
|
+
loaded): the grid keeps the first row in view where it was. It does this itself, the same in every
|
|
1545
|
+
browser, so virtual grids set `overflow-anchor: none` (browser scroll anchoring doesn't work
|
|
1546
|
+
reliably in a CSS grid like this one — Firefox doesn't anchor in it at all).
|
|
1547
|
+
- `scrollToRow(key)` reaches child rows too; `aria-rowcount` / `aria-rowindex` count every
|
|
1548
|
+
rendered row (data, detail and loading / error rows).
|
|
1549
|
+
|
|
1550
|
+
## Performance
|
|
1551
|
+
|
|
1552
|
+
What the grid does for you, and what helps on your side. The repository README lists the
|
|
1553
|
+
measurements.
|
|
1554
|
+
|
|
1555
|
+
**Many rows.** Above a few hundred rows, turn on `virtualScrollingFeature` and give the grid a
|
|
1556
|
+
fixed height. Without it, every row is in the DOM, and restyling or relayout (resizing the window,
|
|
1557
|
+
switching density) touches every cell. Tips:
|
|
1558
|
+
|
|
1559
|
+
- Keep `rowHeight` exact and cell content to one line (e.g. `rendererOptions: { ellipsis: true }`).
|
|
1560
|
+
- Set `detailHeight` close to your typical detail row: rows that render near their estimate settle
|
|
1561
|
+
without visible correction.
|
|
1562
|
+
- Raise `overscan` (default 6) only if fast scrolling shows blank rows on slow devices.
|
|
1563
|
+
|
|
1564
|
+
**Changing data.** Re-render only what changed:
|
|
1565
|
+
|
|
1566
|
+
- Reactive rows: assign the field (`row.status = 'Won'`); only that cell re-renders.
|
|
1567
|
+
- Large immutable lists (`shallowRef`): `patchRows(rows, patches, rowKey)` replaces just the patched
|
|
1568
|
+
rows, and a batch that changes nothing returns the same array.
|
|
1569
|
+
- Lazily loaded children live in the grid: use `grid.patchLoadedRows(patches)`.
|
|
1570
|
+
- For a live feed, batch patches per animation frame rather than per message.
|
|
1571
|
+
|
|
1572
|
+
**Filtering and sorting** are built for large client-side data:
|
|
1573
|
+
|
|
1574
|
+
- Filtering is one pass over the tree. Date filters reuse one formatter per time zone, and text
|
|
1575
|
+
matching has an ASCII fast path.
|
|
1576
|
+
- Value lists are counted once per column, and long lists render 300 values with a search to
|
|
1577
|
+
narrow them.
|
|
1578
|
+
- Sorting computes each row's value once, with a shared collator.
|
|
1579
|
+
- For much larger data, or data that lives on a server, use `data-source` (server mode).
|
|
1580
|
+
|
|
1581
|
+
**Lazy children** (`load-sub-rows`) are requested when an expanded row renders. Without virtual
|
|
1582
|
+
scrolling that is every expanded row. With it, only expanded rows on screen, and only once a scroll
|
|
1583
|
+
settles, so `expandAll()` on thousands of lazy rows sends a screenful of requests, not thousands.
|
|
1584
|
+
|
|
1585
|
+
**Motion** stays on the compositor: the change highlight (`flash`) fades an `opacity` layer, the
|
|
1586
|
+
resize handle grows with `transform`, and spinners and progress bars use `transform`. Row
|
|
1587
|
+
highlights appear instantly and fade out over `--vg-transition`.
|
|
1588
|
+
|
|
1589
|
+
**Bundle.** Import only the features and renderers you use. Everything else is tree-shaken, and
|
|
1590
|
+
the filter popover, filter-row editors and pager are separate chunks loaded on first use.
|
|
1591
|
+
|
|
1592
|
+
## Keyboard
|
|
1593
|
+
|
|
1594
|
+
Without `keyboardNavigationFeature` the grid is an ARIA `table`. The scroll area is one Tab stop,
|
|
1595
|
+
and the grid's own controls (sort buttons, expanders, checkboxes, filter buttons) follow in the
|
|
1596
|
+
normal Tab order.
|
|
1597
|
+
|
|
1598
|
+
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),
|
|
1599
|
+
`Home`/`End`, `Ctrl+Home`/`Ctrl+End`, `PageUp`/`PageDown`; `ContextMenu` / `Shift+F10` opens the context menu. `Enter` sorts a header or activates the
|
|
1600
|
+
cell's control; `Space` toggles row selection; `→`/`←` on a tree cell expands/collapses; `Alt+←/→` on a
|
|
1601
|
+
header moves the column; `Alt+Shift+←/→` on a header resizes it (with `columnResizingFeature`).
|
|
1602
|
+
|
|
1603
|
+
## Touch, phones and tablets
|
|
1604
|
+
|
|
1605
|
+
- **Layout.** The grid scrolls its columns inside its own frame at any width; it doesn't widen
|
|
1606
|
+
the page, also inside flex and grid layouts (`.vg-root` has `min-width: 0`). If you wrap it in
|
|
1607
|
+
your own element inside a flex or grid layout, give that element `min-width: 0` too, or it
|
|
1608
|
+
grows to the columns' width. The toolbar wraps, and on narrow screens the pager drops its
|
|
1609
|
+
« / » buttons (page 1 and the last page stay).
|
|
1610
|
+
- **Swipes scroll** the grid, also when they start on a header (except on a column's narrow
|
|
1611
|
+
resize edge).
|
|
1612
|
+
- **Hold a header** (about half a second) to pick the column up, then drag it to reorder
|
|
1613
|
+
(`columnReorderFeature`). Release it without moving to open the header menu (`menusFeature`).
|
|
1614
|
+
- **Hold a body cell**, then release, to open its `context-menu`. This works on iOS, which fires no
|
|
1615
|
+
`contextmenu` event; the browser's own long-press menu is suppressed while the grid's menu
|
|
1616
|
+
takes over.
|
|
1617
|
+
- Inputs (filters, search, pager) are 16 px on touch screens so iOS Safari doesn't zoom in, and
|
|
1618
|
+
row hover tints only apply where there is a real hover (a tapped row doesn't stay tinted).
|
|
1619
|
+
|
|
1620
|
+
## Built-in renderers
|
|
1621
|
+
|
|
1622
|
+
Screenshots of every renderer are in the repository README's
|
|
1623
|
+
[renderer gallery](../../README.md#29-cell-renderers).
|
|
1624
|
+
|
|
1625
|
+
**Display**
|
|
1626
|
+
|
|
1627
|
+
| Name | Options |
|
|
1628
|
+
|---|---|
|
|
1629
|
+
| `text` (default) | `ellipsis`, `lines`, `maxWidth`, `preserveNewlines`, `tooltip`, `placeholder`, `tone`, `toneMode` (`text`/`fill`), `bold`, `secondary` (muted suffix), `badge` + `badgePosition`, `icon`, `copyable` + `copyValue` → emits `copy` |
|
|
1630
|
+
| `toggle-text` | `clickable`, `highlighted` → emits `toggle` |
|
|
1631
|
+
| `number`, `signed-number` | `format` (`Intl.NumberFormatOptions`), `placeholder`, `clickable` → emits `click` |
|
|
1632
|
+
| `currency` | `currency` (code or `(value, row) => code`), `format`, `placeholder`, `clickable` → emits `click` |
|
|
1633
|
+
| `change` | `direction`, `currency`, `format`, `iconOnly` (arrow + colour; booleans / `'true'` = trend) |
|
|
1634
|
+
| `date`, `datetime` | `format`, `placeholder`; `datetime`: `milliseconds`, `twoLines` |
|
|
1635
|
+
| `boolean` | `trueLabel`, `falseLabel`, `nullLabel`, `display` (`text`/`icon`), `falseIcon` |
|
|
1636
|
+
| `status` | `tone` (map / fn / constant), `label` (fn or value → label map), `dot`, `variant` (`soft`/`solid`/`outline`), `placeholder`, `clickable` → emits `click` |
|
|
1637
|
+
| `chip` | `color` (any CSS colour, contrast text picked), `tone`, `label`, `tooltip`, `shape` (`square`/`circle`/`pill`), `size`; accepts `{ label \| name, color, description }` |
|
|
1638
|
+
| `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 }` |
|
|
1639
|
+
| `list` | `items`, `itemLabel`, `max` (default 1), `placeholder` → “+N more” toggle, emits `expand` |
|
|
1640
|
+
| `link` | `href`, `to` (router location → `<RouterLink>` when vue-router is installed), `label`, `target`, `tooltip` → emits `click` |
|
|
1641
|
+
| `icon` | `icon` / `iconFor`, `show`, `label`, `tone` |
|
|
1642
|
+
| `image` | `src`, `baseUrl`, `alt`, `size`, `fit`, `shape`; placeholder when empty or broken |
|
|
1643
|
+
| `code` | `language` (`auto`/`json`/`text`), `lines`, `indent`, `highlight` (JSON token colours) |
|
|
1644
|
+
| `json` | `label`, `dialogTitle` (escaped JSON in a `<dialog>`) |
|
|
1645
|
+
| `json-tree` | `collapseAt`, `maxDepth`, `parseNested`, `collapsed` + `toggleLabel`, `emptyText` |
|
|
1646
|
+
| `details` | `tone`, `label`, `items` (`{ label, value, tone, detail, tooltip }[]`), `title`, `triggerLabel` → badge + info popover |
|
|
1647
|
+
|
|
1648
|
+
**Actions and editing** — editable renderers are *controlled*: they show the data and emit the requested
|
|
1649
|
+
change; your `@cell-action` handler updates the row.
|
|
1650
|
+
|
|
1651
|
+
| Name | Options → emits |
|
|
1652
|
+
|---|---|
|
|
1653
|
+
| `actions-menu` | `actions: MenuItem[] \| (row) => MenuItem[]`, `label` → the item's `name` |
|
|
1654
|
+
| `action-button` | `label`, `action`, `icon`, `tone`, `disabled`, `visible`, `variant` (`outline`/`solid`/`ghost`), `iconOnly` → `action` (default `click`) |
|
|
1655
|
+
| `button-group` | `buttons: ButtonSpec[] \| (row) => ButtonSpec[]` (`{ name, label, tone, variant, disabled, icon, hidden }`) → the button's `name` |
|
|
1656
|
+
| `copy` | `copyValue`, `iconOnly`, `title`, `label`, `placeholder` → `copy` (payload: copied text) / `copy-error` |
|
|
1657
|
+
| `edit` | `format`, `placeholder`, `label`, `disabled`, `bold` → `edit` |
|
|
1658
|
+
| `checkbox`, `switch` | `checked`, `disabled`, `disabledReason`, `label` → `change` (payload: the requested boolean) |
|
|
1659
|
+
| `radio` | same + `name` → `select` (payload: the row key) |
|
|
1660
|
+
| `icon-toggle` | `active`, `icon`, `activeIcon`, `activeTone`, `label`, `disabled` → `toggle` (payload: next state) |
|
|
1661
|
+
|
|
1662
|
+
```vue
|
|
1663
|
+
<VGrid :rows="rows" :columns="[{ key: 'web', renderer: 'switch' }]" row-key="id"
|
|
1664
|
+
@cell-action="({ name, payload, rowKey }) => name === 'change' && setWeb(rowKey, payload)" />
|
|
1665
|
+
```
|
|
1666
|
+
|
|
1667
|
+
Values option callbacks receive `(value, row)`. The component of every renderer is exported too
|
|
1668
|
+
(`TextCell`, `CurrencyCell`, …) for composition.
|
|
1669
|
+
|
|
1670
|
+
## Writing a cell renderer (addons)
|
|
1671
|
+
|
|
1672
|
+
A renderer is a component plus a small definition. See
|
|
1673
|
+
[`@nocopypaste/vue-grid-renderer-template`](../cell-renderer-template) for a complete, publishable example.
|
|
1674
|
+
|
|
1675
|
+
```vue
|
|
1676
|
+
<!-- RatingCell.vue -->
|
|
1677
|
+
<script setup lang="ts">
|
|
1678
|
+
import type { CellRendererEmits, CellRendererProps } from '@nocopypaste/vue-grid'
|
|
1679
|
+
const props = defineProps<CellRendererProps<unknown, number, { max?: number }>>()
|
|
1680
|
+
const emit = defineEmits<CellRendererEmits>()
|
|
1681
|
+
</script>
|
|
1682
|
+
<template>
|
|
1683
|
+
<button v-for="n in options.max" :key="n" @click="emit('action', 'rate', n)">{{ n <= value ? '★' : '☆' }}</button>
|
|
1684
|
+
</template>
|
|
1685
|
+
```
|
|
1686
|
+
|
|
1687
|
+
```ts
|
|
1688
|
+
import { defineCellRenderer } from '@nocopypaste/vue-grid'
|
|
1689
|
+
declare module '@nocopypaste/vue-grid' {
|
|
1690
|
+
interface CellRendererRegistry { rating: { max?: number } } // typed `renderer: 'rating'`
|
|
1691
|
+
}
|
|
1692
|
+
export const ratingRenderer = defineCellRenderer<{ max?: number }>({
|
|
1693
|
+
name: 'rating', component: RatingCell, defaults: { max: 5 }, sortValue: (v) => Number(v),
|
|
1694
|
+
})
|
|
1695
|
+
// app.use(createVueGrid({ renderers: [ratingRenderer] })) or <VGrid :renderers="[ratingRenderer]">
|
|
1696
|
+
```
|
|
1697
|
+
|
|
1698
|
+
Renderer props: `value`, `row`, `rowKey`, `rowIndex`, `depth`, `column`, `options` (defaults merged
|
|
1699
|
+
with `rendererOptions`). Emit `action(name, payload)`; the grid re-emits it as `cell-action` with the
|
|
1700
|
+
row and column. `useGridContext()` gives `{ locale, currency, timeZone }`. Lookup order:
|
|
1701
|
+
a definition or component on the column → `:renderers` → plugin → `text` (the only renderer built in).
|
|
1702
|
+
|
|
1703
|
+
## Theming
|
|
1704
|
+
|
|
1705
|
+
Override any token on `:root`, a wrapper, or the grid itself:
|
|
1706
|
+
|
|
1707
|
+
```css
|
|
1708
|
+
.brand-grid {
|
|
1709
|
+
--vg-color-accent: #db2777;
|
|
1710
|
+
--vg-color-header-bg: #fdf2f8;
|
|
1711
|
+
--vg-radius: 1rem;
|
|
1712
|
+
--vg-cell-padding-x: 1.25rem;
|
|
1713
|
+
--vg-font-family: Georgia, serif;
|
|
1714
|
+
}
|
|
1715
|
+
```
|
|
1716
|
+
|
|
1717
|
+
| Group | Tokens |
|
|
1718
|
+
|---|---|
|
|
1719
|
+
| 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` |
|
|
1720
|
+
| 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` |
|
|
1721
|
+
| 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` |
|
|
1722
|
+
| Sub-grid | `--vg-subgrid-bg` `--vg-subgrid-indent` `--vg-subgrid-border` `--vg-subgrid-radius` |
|
|
1723
|
+
| Elevation | `--vg-shadow-pinned` `--vg-shadow-popover` `--vg-z-header` `--vg-z-pinned` `--vg-z-pinned-header` `--vg-transition` `--vg-menu-gap` |
|
|
1724
|
+
| Change highlight | `--vg-flash-color` `--vg-flash-up` `--vg-flash-down` `--vg-flash-duration` |
|
|
1725
|
+
|
|
1726
|
+
Motion stays on the compositor (`transform`, `opacity`) wherever layout would otherwise animate.
|
|
1727
|
+
Row highlights (hover, selection) appear at once and fade out over `--vg-transition`, so the grid
|
|
1728
|
+
responds the moment the pointer arrives.
|
|
1729
|
+
|
|
1730
|
+
Colours use `light-dark()`: set `color-scheme: light dark` on `html` to follow the OS, or
|
|
1731
|
+
`color-scheme: dark` to force dark. Stable class names (`.vg-header-cell`, `.vg-cell`, `.vg-row`,
|
|
1732
|
+
`.vg-subgrid`, `.vg-pin-left`, …) and the `ui` prop are there for anything tokens don't cover.
|
|
1733
|
+
|
|
1734
|
+
### Bring your own theme
|
|
1735
|
+
|
|
1736
|
+
The tokens above come from `theme.css`, which is optional. Import `base.css` instead and the grid
|
|
1737
|
+
keeps its structure (columns, sub-grid alignment, sticky header and pins, tree indent, anchored
|
|
1738
|
+
menus and popovers) with none of the default look. Then style the classes yourself:
|
|
1739
|
+
|
|
1740
|
+
```ts
|
|
1741
|
+
import '@nocopypaste/vue-grid/base.css'
|
|
1742
|
+
import './my-grid-theme.css'
|
|
1743
|
+
```
|
|
1744
|
+
|
|
1745
|
+
```css
|
|
1746
|
+
/* my-grid-theme.css — unlayered, or in your own layer after `vue-grid` */
|
|
1747
|
+
.vg-viewport { border: 1px solid #ddd; }
|
|
1748
|
+
.vg-header-cell { padding: 0.5rem 0.75rem; background: #fafafa; font-weight: 600; }
|
|
1749
|
+
.vg-cell { padding: 0.5rem 0.75rem; border-top: 1px solid #eee; }
|
|
1750
|
+
.vg-row:hover > .vg-cell { background: #f5f5f5; }
|
|
1751
|
+
```
|
|
1752
|
+
|
|
1753
|
+
Base only gives sticky header and pinned cells the system `Canvas` background, so content doesn't
|
|
1754
|
+
show through them; everything else (colours, spacing, borders, fonts, focus rings, animation) is
|
|
1755
|
+
yours. The structural tokens `--vg-select-column-width`, `--vg-expander-size`,
|
|
1756
|
+
`--vg-subgrid-indent`, `--vg-z-*` and `--vg-menu-gap` live in `base.css` and can be overridden
|
|
1757
|
+
the same way. `renderers.css` reads the theme's colour tokens; define them (or skip the file) when
|
|
1758
|
+
you drop `theme.css`.
|
|
1759
|
+
|
|
1760
|
+
## For coding agents
|
|
1761
|
+
|
|
1762
|
+
[`AGENTS.md`](AGENTS.md) is the short guide for AI coding agents (rules, which feature and
|
|
1763
|
+
renderer for what, recipes, pitfalls); [`llms.txt`](llms.txt) and `llms-full.txt` follow the
|
|
1764
|
+
llms.txt convention. The API reference is generated from the sources into
|
|
1765
|
+
[`agent/api.md`](agent/api.md) and `agent/api.json`, with a
|
|
1766
|
+
[JSON Schema](agent/grid-config.schema.json) of a grid config. To check a config:
|
|
1767
|
+
|
|
1768
|
+
```ts
|
|
1769
|
+
import { validateGridConfig } from '@nocopypaste/vue-grid/agent'
|
|
1770
|
+
|
|
1771
|
+
const { ok, diagnostics } = validateGridConfig({
|
|
1772
|
+
rowKey: 'id',
|
|
1773
|
+
features: ['sortingFeature'], // export names (or the feature objects); 'allFeatures' for all
|
|
1774
|
+
renderers: [], // registered renderer names / definitions
|
|
1775
|
+
columns: [{ key: 'total', renderer: 'currency', sortable: true, widht: '8rem' }],
|
|
1776
|
+
})
|
|
1777
|
+
// error columns[0].widht Columns have no option `widht`. Did you mean `width`?
|
|
1778
|
+
// warning columns[0].renderer Renderer name `currency` isn't registered … pass `renderer: currencyRenderer`
|
|
1779
|
+
// warning props.sortMode Sortable columns, but sorting is controlled … add `sort-mode="client"`
|
|
1780
|
+
```
|
|
1781
|
+
|
|
1782
|
+
`@nocopypaste/vue-grid/agent` is a separate entry: apps that don't import it never bundle it. The
|
|
1783
|
+
[`@nocopypaste/vue-grid-mcp`](../vue-grid-mcp) MCP server serves the same to agents as tools, and the
|
|
1784
|
+
[Claude Code plugin](../../plugins/vue-grid) adds a skill with the full workflow.
|
|
1785
|
+
|
|
1786
|
+
## Browser support
|
|
1787
|
+
|
|
1788
|
+
Evergreen browsers: CSS `subgrid`, `light-dark()`, `@layer`, the Popover API and `<dialog>`
|
|
1789
|
+
(Chrome/Edge 123+, Firefox 125+, Safari 17.5+).
|
|
1790
|
+
|
|
1791
|
+
**CSS first, JS only as a fallback.** Everything the browser can do in CSS / HTML is done there; a
|
|
1792
|
+
small JS fallback runs only when a feature check (`CSS.supports`) says the browser can't:
|
|
1793
|
+
|
|
1794
|
+
| Behaviour | Done with | JS fallback when unsupported |
|
|
1795
|
+
|---|---|---|
|
|
1796
|
+
| Menu / popover placement, flipping, following the anchor on scroll | Popover API + CSS anchor positioning | measured placement, re-run on scroll / resize |
|
|
1797
|
+
| Hiding a popover once its anchor scrolls out of view | `position-visibility: anchor-visible` | IntersectionObserver (e.g. Firefox 159) |
|
|
1798
|
+
| Sticky offsets of pinned columns | `calc()` sums of the declared widths | ResizeObserver, only for content-sized pinned columns |
|
|
1799
|
+
| Which pinned column gets the edge shadow | `:has()` / sibling selectors | a class |
|
|
1800
|
+
| Shadow only while content is scrolled under pinned columns | `@container scroll-state(scrollable: …)` | scroll listener sets `data-vg-scrollable` |
|
|
1801
|
+
| Readable text on data-coloured chips | `contrast-color()` / relative colours | computed black / white |
|
|
1802
|
+
| Expand / collapse (JSON tree, “More info”, list “+N more”) | native `<details>` / `<summary>` | — |
|
|
1803
|
+
| Closing the JSON dialog on a backdrop click | `<dialog closedby="any">` | backdrop click handler |
|
|
1804
|
+
|
|
1805
|
+
What stays in JS is what CSS can't express: data (sorting, selection, expansion state), keyboard
|
|
1806
|
+
navigation, column drag, virtual scrolling and lazy loading.
|