@xleddyl/443-components-vue 0.16.78 → 0.16.79
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/CATALOG.md +6 -6
- package/README.md +1 -1
- package/dist/grid/DataGrid.vue +61 -0
- package/dist/grid/DataGrid.vue.d.ts +1 -0
- package/dist/locale/de.mjs +2 -0
- package/dist/locale/en.mjs +2 -0
- package/dist/locale/it.mjs +2 -0
- package/dist/locale/types.d.ts +2 -0
- package/package.json +1 -1
package/CATALOG.md
CHANGED
|
@@ -299,12 +299,12 @@ Nuxt ready layouts: with `k: { layouts: true }` the module registers the layouts
|
|
|
299
299
|
|
|
300
300
|
Import from `@xleddyl/443-components-vue/grid`. It wraps AG Grid Community.
|
|
301
301
|
|
|
302
|
-
| Component | Purpose and when to use it | Main props, models, slots, events
|
|
303
|
-
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
304
|
-
| `DataGrid` | Big table: virtual scroll, column menu, search, CSV export, selection, server sort and paging, inline editing. For small tables use `Table`. | Models: `v-model:query`, `v-model:page`, `v-model:pageSize`, `v-model:sort` (`{ column, direction }`), `v-model:selected` (row ids, needs `rowIdKey` or `getRowId`; the header checkbox selects all the filtered rows across pages; a row hidden by the search or a filter leaves the selection, `keepHiddenSelected` keeps it; with `serverPagination` the ids of other pages stay, and leave only when `rows` holds the whole `total`). Template ref methods (`DataGridMethods` type, `useTemplateRef<DataGridMethods<Row>>`): `api`, `getSelectedRows`, `getSelectedIds`, `selectRows`, `selectAllRows`, `deselectAll`, `resetColumns` plus the spreadsheet ones. Props: `rows`, `columns` (AG Grid `ColDef`), `rowIdKey` or `getRowId`, `keepHiddenSelected`, `storageKey` (columns and page size in the preferences store; without `columnMenu` the column visibility always comes from `columns`), `density` (default `normal`), `selectable`, `loading`, `height`, `fill`, `autoHeight`, `toolbar`, `searchable`, `columnMenu` (default on), `exportable` (default on), `pageSizes` (default `[10, 25, 50, 100]`; these four defaults can be set for the whole app with `provideGridConfig` or the Nuxt option `k.grid: { density, columnMenu, exportable, pageSizes }`, a prop still wins), `serverSort`, `pagination`, `serverPagination`, `total`, `filterable`, `editable`, `spreadsheet`, `gridOptions`, `messages`, `filterCount`, `activeFilters` (`{ id, label, value }[]`, removable pills next to the filter button; a click opens the filters). Slots: `actions`, `actions-end`
|
|
305
|
-
| `DataGrid` with `spreadsheet` | Excel-like editing: cell range selection, copy and paste (TSV), fill down and right, clear, undo and redo, dirty cell tracking. Set `rowIdKey` or `getRowId`. | Template ref methods (`GridSpreadsheetMethods`): `getRange`, `getSelectedCells`, `selectRange`, `selectAll`, `setRangeValue`, `copyRange`, `paste`, `fillDown`, `fillRight`, `clearCells`, `clearRange`, `undo`, `redo`, `clearHistory`, `getDirtyCells`, `clearDirty`. The `actions` slot gets the same methods plus `range`, `selectedCellCount`, `dirtyCount`, `canUndo`, `canRedo`. Use `cellsChange` to save edits, `cellsInvalid` for rejected input.
|
|
306
|
-
| `GridToolbar` | Toolbar of `DataGrid` (search, column menu, export). `DataGrid` already renders it. Use it alone only for a custom grid setup. | Props: `api`, `searchable`, `columnMenu`, `exportable`, `exportFileName`, `debounce`, `filterCount`, `activeFilters`. Model: `v-model` (query). Slots: default (actions), `end`, `filters`. Events: `resetColumns`, `filtersReset`, `filterRemove`.
|
|
307
|
-
| Cell renderers | Use as `cellRenderer` in a column definition, with `cellRendererParams`. | `BadgeCell` (`tones`, `colors`, `labels`, `titles` (a record or a function of the value), `defaultTone`, `variant`; array values render one badge each, `max` adds a `+N` badge, `wrap`), `BooleanCell` (`trueLabel`, `falseLabel`), `DateCell` (`locale`, `options`, `relative`), `EmptyCell` (placeholder for empty values), `ImageCell` (`alt`, `rounded`, `fit`: `cover`, `contain` or `natural` (original aspect, height `size`), `size`), `LinkCell` (`href`, `label`, `target`), `ButtonCell` (`onClick`, `label`, `ariaLabel`, `tooltip`, `disabled`, `disabledReason` (functions of value and row; a disabled button ignores clicks and shows the reason in a tooltip), `emptyLabel`, `tone`, `variant`, `icon` (as `Button`, an `xs` button; without them an inline link style button); does not trigger the row click).
|
|
302
|
+
| Component | Purpose and when to use it | Main props, models, slots, events | Playground |
|
|
303
|
+
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
304
|
+
| `DataGrid` | Big table: virtual scroll, column menu, search, CSV export, selection, server sort and paging, inline editing. For small tables use `Table`. | Models: `v-model:query`, `v-model:page`, `v-model:pageSize`, `v-model:sort` (`{ column, direction }`), `v-model:selected` (row ids, needs `rowIdKey` or `getRowId`; the header checkbox selects all the filtered rows across pages; a row hidden by the search or a filter leaves the selection, `keepHiddenSelected` keeps it; with `serverPagination` the ids of other pages stay, and leave only when `rows` holds the whole `total`). Template ref methods (`DataGridMethods` type, `useTemplateRef<DataGridMethods<Row>>`): `api`, `getSelectedRows`, `getSelectedIds`, `selectRows`, `selectAllRows`, `deselectAll`, `resetColumns` plus the spreadsheet ones. Props: `rows`, `columns` (AG Grid `ColDef`), `rowIdKey` or `getRowId`, `keepHiddenSelected`, `storageKey` (columns and page size in the preferences store; without `columnMenu` the column visibility always comes from `columns`), `density` (default `normal`), `selectable`, `loading`, `height`, `fill`, `autoHeight`, `toolbar`, `searchable`, `columnMenu` (default on), `exportable` (default on), `pageSizes` (default `[10, 25, 50, 100]`; these four defaults can be set for the whole app with `provideGridConfig` or the Nuxt option `k.grid: { density, columnMenu, exportable, pageSizes }`, a prop still wins), `serverSort`, `pagination`, `serverPagination`, `total`, `allIds` (`() => Promise<string[]> | string[]`; with `serverPagination`, `selectable`multiple and a bound`v-model:selected`, once the whole page is selected a footer link "Select all N rows" selects every matching row through the ids the function returns, and "Clear selection" appears when all are selected), `filterable`, `editable`, `spreadsheet`, `gridOptions`, `messages`, `filterCount`, `activeFilters` (`{ id, label, value }[]`, removable pills next to the filter button; a click opens the filters). Slots: `actions`, `actions-end`(after the column menu and export buttons),`filters` (`{ close, count }`, hosted in a modal opened by a funnel button next to the search). Events: `filtersReset`, `filterRemove`(id),`rowClick`, `selectionChange`, `sortChange`, `filterChange`, `cellsChange`, `cellsInvalid`, `dirtyChange`, `rangeChange`, `copy`. | `grid/data-grid.vue` |
|
|
305
|
+
| `DataGrid` with `spreadsheet` | Excel-like editing: cell range selection, copy and paste (TSV), fill down and right, clear, undo and redo, dirty cell tracking. Set `rowIdKey` or `getRowId`. | Template ref methods (`GridSpreadsheetMethods`): `getRange`, `getSelectedCells`, `selectRange`, `selectAll`, `setRangeValue`, `copyRange`, `paste`, `fillDown`, `fillRight`, `clearCells`, `clearRange`, `undo`, `redo`, `clearHistory`, `getDirtyCells`, `clearDirty`. The `actions` slot gets the same methods plus `range`, `selectedCellCount`, `dirtyCount`, `canUndo`, `canRedo`. Use `cellsChange` to save edits, `cellsInvalid` for rejected input. | `grid/spreadsheet.vue` |
|
|
306
|
+
| `GridToolbar` | Toolbar of `DataGrid` (search, column menu, export). `DataGrid` already renders it. Use it alone only for a custom grid setup. | Props: `api`, `searchable`, `columnMenu`, `exportable`, `exportFileName`, `debounce`, `filterCount`, `activeFilters`. Model: `v-model` (query). Slots: default (actions), `end`, `filters`. Events: `resetColumns`, `filtersReset`, `filterRemove`. | - |
|
|
307
|
+
| Cell renderers | Use as `cellRenderer` in a column definition, with `cellRendererParams`. | `BadgeCell` (`tones`, `colors`, `labels`, `titles` (a record or a function of the value), `defaultTone`, `variant`; array values render one badge each, `max` adds a `+N` badge, `wrap`), `BooleanCell` (`trueLabel`, `falseLabel`), `DateCell` (`locale`, `options`, `relative`), `EmptyCell` (placeholder for empty values), `ImageCell` (`alt`, `rounded`, `fit`: `cover`, `contain` or `natural` (original aspect, height `size`), `size`), `LinkCell` (`href`, `label`, `target`), `ButtonCell` (`onClick`, `label`, `ariaLabel`, `tooltip`, `disabled`, `disabledReason` (functions of value and row; a disabled button ignores clicks and shows the reason in a tooltip), `emptyLabel`, `tone`, `variant`, `icon` (as `Button`, an `xs` button; without them an inline link style button); does not trigger the row click). | `grid/data-grid.vue` |
|
|
308
308
|
|
|
309
309
|
Grid helpers: `registerGridModules`, `registerGridEditorModules`, `registerGridFilterModules`, `registerGridSpreadsheetModules` (register AG Grid modules by hand), `createGridTheme`, `parseTsv`, `formatTsv`.
|
|
310
310
|
|
package/README.md
CHANGED
|
@@ -986,7 +986,7 @@ Accessibility related props and defaults:
|
|
|
986
986
|
- A column without a visible header (a photo column) keeps a name for the Columns menu with `headerValueGetter: ({ location }) => (location === 'header' ? '' : 'Photo')`: the menu reads the name for the `columnToolPanel` location.
|
|
987
987
|
- `DataGrid` takes `gridOptions` for any AG Grid option it does not wrap (`rowHeight`, `onCellEditingStopped`, `onFilterChanged`, ...). A prop of `DataGrid` wins only when it is set: `getRowId`, `rowSelection` (when `selectable` is off), `autoSizeStrategy` (also `undefined` to turn it off), `tooltipShowDelay`, `overlayNoRowsTemplate` and `overlayLoadingTemplate` from `gridOptions` are used otherwise; `defaultColDef` and `localeText` are merged over the component defaults, and `context` is merged under the cell context. Handlers from both run.
|
|
988
988
|
- `DataGrid` row ids: `getRowId: (params) => string` (wins), `rowIdKey` (a field of the row), or `gridOptions.getRowId`.
|
|
989
|
-
- `DataGrid` `v-model:selected` (`string[]`) is the selected row ids, two way, for `selectable` grids (also `'single'`, at most one id). It needs row ids (`rowIdKey`, `getRowId` or `gridOptions.getRowId`); a dev warning tells you when they are missing. Leave it unbound for an uncontrolled grid. The header checkbox selects all the filtered rows (`selectAll: 'filtered'`): not the rows hidden by the search or the column filters, and not only the current page. A row hidden by the toolbar search, a column filter or an external filter leaves the selection: the grid deselects it and drops its id from the model when the filter changes, and an id set in the model for a hidden row is dropped too, so a bulk action never acts on rows the user cannot see. `keepHiddenSelected` keeps the old behavior (a hidden row stays selected). Client pagination keeps the selection across pages. A row that disappears from `rows` is dropped from the model, except while `loading` is set or the rows are empty, so a preselected model survives the first load. With `serverPagination` the ids of rows that are not in the current `rows` stay in the model: the selection survives a page change and a re-fetch, the footer counts the whole model, and the header checkbox only selects the rows of the page. The grid cannot see the other pages, so it drops an id that the server filter excludes only when it knows the whole result: once `loading` is off and `rows` holds every row of `total` (or the result is empty), the ids that are not in `rows` leave the model. Rows of the page hidden by a client column filter leave it as in client mode. To drop the ids of other pages when your own filters change, set the model yourself (for example `selected = []` when the query changes). Ids of rows that are not loaded yet stay out of the grid and are selected when the rows arrive. `selectionChange` still emits the selected rows of the grid.
|
|
989
|
+
- `DataGrid` `v-model:selected` (`string[]`) is the selected row ids, two way, for `selectable` grids (also `'single'`, at most one id). It needs row ids (`rowIdKey`, `getRowId` or `gridOptions.getRowId`); a dev warning tells you when they are missing. Leave it unbound for an uncontrolled grid. The header checkbox selects all the filtered rows (`selectAll: 'filtered'`): not the rows hidden by the search or the column filters, and not only the current page. A row hidden by the toolbar search, a column filter or an external filter leaves the selection: the grid deselects it and drops its id from the model when the filter changes, and an id set in the model for a hidden row is dropped too, so a bulk action never acts on rows the user cannot see. `keepHiddenSelected` keeps the old behavior (a hidden row stays selected). Client pagination keeps the selection across pages. A row that disappears from `rows` is dropped from the model, except while `loading` is set or the rows are empty, so a preselected model survives the first load. With `serverPagination` the ids of rows that are not in the current `rows` stay in the model: the selection survives a page change and a re-fetch, the footer counts the whole model, and the header checkbox only selects the rows of the page. The grid cannot see the other pages, so it drops an id that the server filter excludes only when it knows the whole result: once `loading` is off and `rows` holds every row of `total` (or the result is empty), the ids that are not in `rows` leave the model. Rows of the page hidden by a client column filter leave it as in client mode. To drop the ids of other pages when your own filters change, set the model yourself (for example `selected = []` when the query changes). Ids of rows that are not loaded yet stay out of the grid and are selected when the rows arrive. With `serverPagination`, `allIds` (`() => Promise<readonly string[]> | readonly string[]`) adds a footer link "Select all N rows" (`N` is `total`) that shows when every row of the page is selected and the model holds fewer than `total` ids: it calls `allIds`, awaits it and sets the model to the returned ids (a rejected promise keeps the selection and logs an error). When the model holds `total` ids the link becomes "Clear selection". `selectionChange` still emits the selected rows of the grid.
|
|
990
990
|
- `DataGrid` template ref methods have a type: `DataGridMethods<Row>` (`api`, `getSelectedRows`, `getSelectedIds`, `selectRows(ids)`, `selectAllRows()` for the filtered rows, `deselectAll`, `resetColumns` and the `GridSpreadsheetMethods`; `selectAll` stays the cell range one of the spreadsheet).
|
|
991
991
|
|
|
992
992
|
```ts
|
package/dist/grid/DataGrid.vue
CHANGED
|
@@ -92,6 +92,22 @@
|
|
|
92
92
|
<template v-if="footerSelectedCount > 0">{{
|
|
93
93
|
formatLocaleMessage(locale.code, text.selected, { count: footerSelectedCount })
|
|
94
94
|
}}</template>
|
|
95
|
+
<Button
|
|
96
|
+
v-if="canSelectAllMatching"
|
|
97
|
+
size="xs"
|
|
98
|
+
variant="link"
|
|
99
|
+
:loading="selectingAll"
|
|
100
|
+
:disabled="selectingAll"
|
|
101
|
+
:label="formatLocaleMessage(locale.code, text.selectAllMatching, { count: total })"
|
|
102
|
+
@click="selectAllMatching"
|
|
103
|
+
/>
|
|
104
|
+
<Button
|
|
105
|
+
v-else-if="allMatchingSelected"
|
|
106
|
+
size="xs"
|
|
107
|
+
variant="link"
|
|
108
|
+
:label="text.clearSelection"
|
|
109
|
+
@click="clearSelection"
|
|
110
|
+
/>
|
|
95
111
|
</span>
|
|
96
112
|
<Pagination
|
|
97
113
|
v-if="paginationEnabled"
|
|
@@ -129,6 +145,7 @@ import {
|
|
|
129
145
|
watch
|
|
130
146
|
} from "vue";
|
|
131
147
|
import Pagination from "../components/data/Pagination.vue";
|
|
148
|
+
import Button from "../components/core/Button.vue";
|
|
132
149
|
import Spinner from "../components/core/Spinner.vue";
|
|
133
150
|
import { useCopy } from "../composables/useCopy";
|
|
134
151
|
import { useGridConfig } from "../composables/useGridConfig";
|
|
@@ -176,6 +193,7 @@ const props = defineProps({
|
|
|
176
193
|
showEdges: { type: Boolean, required: false },
|
|
177
194
|
showJump: { type: Boolean, required: false },
|
|
178
195
|
serverPagination: { type: Boolean, required: false },
|
|
196
|
+
allIds: { type: Function, required: false },
|
|
179
197
|
total: { type: Number, required: false, default: 0 },
|
|
180
198
|
pageSizes: { type: Array, required: false, default: void 0 },
|
|
181
199
|
messages: { type: Object, required: false },
|
|
@@ -594,6 +612,48 @@ function reconcileSelection() {
|
|
|
594
612
|
}
|
|
595
613
|
applySelection();
|
|
596
614
|
}
|
|
615
|
+
const selectingAll = ref(false);
|
|
616
|
+
const pageFullySelected = ref(false);
|
|
617
|
+
function refreshPageSelection() {
|
|
618
|
+
const current = api.value;
|
|
619
|
+
const model = selected.value;
|
|
620
|
+
if (!current || !model) {
|
|
621
|
+
pageFullySelected.value = false;
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
const lookup = new Set(model);
|
|
625
|
+
const ids = [...readNodeIds(current)];
|
|
626
|
+
pageFullySelected.value = ids.length > 0 && ids.every((id) => lookup.has(id));
|
|
627
|
+
}
|
|
628
|
+
const multipleSelection = computed(
|
|
629
|
+
() => props.selectable === true || props.selectable === "multiple"
|
|
630
|
+
);
|
|
631
|
+
const paginatedBeyondRows = computed(
|
|
632
|
+
() => props.serverPagination && props.total > props.rows.length
|
|
633
|
+
);
|
|
634
|
+
const canSelectAllMatching = computed(
|
|
635
|
+
() => paginatedBeyondRows.value && multipleSelection.value && Boolean(props.allIds) && Boolean(selected.value) && pageFullySelected.value && (selected.value?.length ?? 0) < props.total
|
|
636
|
+
);
|
|
637
|
+
const allMatchingSelected = computed(
|
|
638
|
+
() => paginatedBeyondRows.value && multipleSelection.value && (selected.value?.length ?? 0) >= props.total
|
|
639
|
+
);
|
|
640
|
+
async function selectAllMatching() {
|
|
641
|
+
if (!props.allIds || selectingAll.value) return;
|
|
642
|
+
selectingAll.value = true;
|
|
643
|
+
try {
|
|
644
|
+
const ids = await props.allIds();
|
|
645
|
+
if (isSelectionBound()) selected.value = [...ids];
|
|
646
|
+
applyIds(ids);
|
|
647
|
+
} catch (reason) {
|
|
648
|
+
console.error("[@xleddyl/443-components-vue] DataGrid allIds failed", reason);
|
|
649
|
+
} finally {
|
|
650
|
+
selectingAll.value = false;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
function clearSelection() {
|
|
654
|
+
if (isSelectionBound()) selected.value = [];
|
|
655
|
+
api.value?.deselectAll();
|
|
656
|
+
}
|
|
597
657
|
function deselectHidden() {
|
|
598
658
|
const current = api.value;
|
|
599
659
|
if (!current || !props.selectable) return;
|
|
@@ -615,6 +675,7 @@ function onSelectionChanged(event) {
|
|
|
615
675
|
writeSelection(event.api);
|
|
616
676
|
}
|
|
617
677
|
watch(selected, applySelection, { deep: true });
|
|
678
|
+
watch([selected, () => props.rows], refreshPageSelection, { deep: true, flush: "post" });
|
|
618
679
|
watch(
|
|
619
680
|
() => props.loading,
|
|
620
681
|
(value) => {
|
|
@@ -30,6 +30,7 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
|
|
|
30
30
|
showEdges?: boolean;
|
|
31
31
|
showJump?: boolean;
|
|
32
32
|
serverPagination?: boolean;
|
|
33
|
+
allIds?: () => Promise<readonly string[]> | readonly string[];
|
|
33
34
|
total?: number;
|
|
34
35
|
pageSizes?: PageSize[];
|
|
35
36
|
messages?: Partial<GridMessages>;
|
package/dist/locale/de.mjs
CHANGED
|
@@ -93,6 +93,8 @@ export const de = {
|
|
|
93
93
|
previousPage: "Vorherige Seite",
|
|
94
94
|
nextPage: "N\xE4chste Seite",
|
|
95
95
|
selected: "{count} ausgew\xE4hlt",
|
|
96
|
+
selectAllMatching: "Alle {count} Zeilen ausw\xE4hlen",
|
|
97
|
+
clearSelection: "Auswahl aufheben",
|
|
96
98
|
copied: "In die Zwischenablage kopiert",
|
|
97
99
|
yes: "Ja",
|
|
98
100
|
no: "Nein",
|
package/dist/locale/en.mjs
CHANGED
|
@@ -93,6 +93,8 @@ export const en = {
|
|
|
93
93
|
previousPage: "Previous page",
|
|
94
94
|
nextPage: "Next page",
|
|
95
95
|
selected: "{count} selected",
|
|
96
|
+
selectAllMatching: "Select all {count} rows",
|
|
97
|
+
clearSelection: "Clear selection",
|
|
96
98
|
copied: "Copied to clipboard",
|
|
97
99
|
yes: "Yes",
|
|
98
100
|
no: "No",
|
package/dist/locale/it.mjs
CHANGED
|
@@ -93,6 +93,8 @@ export const it = {
|
|
|
93
93
|
previousPage: "Pagina precedente",
|
|
94
94
|
nextPage: "Pagina successiva",
|
|
95
95
|
selected: "{count} selezionato | {count} selezionati",
|
|
96
|
+
selectAllMatching: "Seleziona tutte le {count} righe",
|
|
97
|
+
clearSelection: "Deseleziona tutte",
|
|
96
98
|
copied: "Copiato negli appunti",
|
|
97
99
|
yes: "S\xEC",
|
|
98
100
|
no: "No",
|
package/dist/locale/types.d.ts
CHANGED
package/package.json
CHANGED