@xleddyl/443-components-vue 0.16.37 → 0.16.39
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
CHANGED
|
@@ -83,7 +83,7 @@ Playground paths in this file are relative to `playground/nuxt/app/pages/compone
|
|
|
83
83
|
| Global search, command menu (Cmd+K) | `CommandPalette` (the `DashboardLayout` has it with `search`) |
|
|
84
84
|
| Small table, simple sort | `Table` (+ `useTableSort` for client sort) |
|
|
85
85
|
| Big table, many rows, editing, Excel-like | `DataGrid` (+ `spreadsheet` prop for Excel-like editing) |
|
|
86
|
-
| Filters for a grid (selects, dates in a modal from the toolbar) | `DataGrid` `#filters` slot with `filterCount` and `@filters-reset`
|
|
86
|
+
| Filters for a grid (selects, dates in a modal from the toolbar) | `DataGrid` `#filters` slot with `activeFilters` (or `filterCount`), `@filter-remove` and `@filters-reset` |
|
|
87
87
|
| Several tags or statuses in one grid cell | `BadgeCell` with an array value (`max` adds a `+N` badge) |
|
|
88
88
|
| Whole list page: search, filters, table, pagination | `ListPage` |
|
|
89
89
|
| Page numbers and page size | `Pagination` |
|
|
@@ -293,12 +293,12 @@ Nuxt ready layouts: with `k: { layouts: true }` the module registers the layouts
|
|
|
293
293
|
|
|
294
294
|
Import from `@xleddyl/443-components-vue/grid`. It wraps AG Grid Community.
|
|
295
295
|
|
|
296
|
-
| Component | Purpose and when to use it | Main props, models, slots, events
|
|
297
|
-
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
298
|
-
| `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 }`). Props: `rows`, `columns` (AG Grid `ColDef`), `rowIdKey` or `getRowId`, `storageKey` (columns and page size in the preferences store), `density`, `selectable`, `loading`, `height`, `fill`, `autoHeight`, `toolbar`, `searchable`, `columnMenu`, `exportable`, `serverSort`, `pagination`, `serverPagination`, `total`, `filterable`, `editable`, `spreadsheet`, `gridOptions`, `messages`, `filterCount
|
|
299
|
-
| `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`, `undo`, `redo`, `getDirtyCells`, `clearDirty`. The `actions` slot gets the same methods plus `range`, `selectedCellCount`, `dirtyCount`, `canUndo`, `canRedo`. Use `cellsChange` to save edits, `cellsInvalid` for rejected input.
|
|
300
|
-
| `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`. Model: `v-model` (query). Slots: default (actions), `filters`. Events: `resetColumns`, `filtersReset`.
|
|
301
|
-
| 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`, `emptyLabel`; an inline button that does not trigger the row click).
|
|
296
|
+
| Component | Purpose and when to use it | Main props, models, slots, events | Playground |
|
|
297
|
+
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- |
|
|
298
|
+
| `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 }`). Props: `rows`, `columns` (AG Grid `ColDef`), `rowIdKey` or `getRowId`, `storageKey` (columns and page size in the preferences store; without `columnMenu` the column visibility always comes from `columns`), `density`, `selectable`, `loading`, `height`, `fill`, `autoHeight`, `toolbar`, `searchable`, `columnMenu`, `exportable`, `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` (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` |
|
|
299
|
+
| `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`, `undo`, `redo`, `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` |
|
|
300
|
+
| `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), `filters`. Events: `resetColumns`, `filtersReset`, `filterRemove`. | - |
|
|
301
|
+
| 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`, `emptyLabel`; an inline button that does not trigger the row click). | `grid/data-grid.vue` |
|
|
302
302
|
|
|
303
303
|
Grid helpers: `registerGridModules`, `registerGridEditorModules`, `registerGridFilterModules`, `registerGridSpreadsheetModules` (register AG Grid modules by hand), `createGridTheme`, `parseTsv`, `formatTsv`.
|
|
304
304
|
|
package/dist/grid/DataGrid.vue
CHANGED
|
@@ -23,8 +23,10 @@
|
|
|
23
23
|
:export-file-name="exportFileName"
|
|
24
24
|
:debounce="searchDebounce"
|
|
25
25
|
:filter-count="filterCount"
|
|
26
|
+
:active-filters="activeFilters"
|
|
26
27
|
@reset-columns="clearStoredState"
|
|
27
28
|
@filters-reset="emit('filtersReset')"
|
|
29
|
+
@filter-remove="(id) => emit('filterRemove', id)"
|
|
28
30
|
>
|
|
29
31
|
<slot name="actions" :api="api" v-bind="sheetSlot" />
|
|
30
32
|
<template v-if="$slots['actions-end']" #end>
|
|
@@ -156,6 +158,7 @@ const props = defineProps({
|
|
|
156
158
|
exportFileName: { type: String, required: false, default: "export" },
|
|
157
159
|
searchDebounce: { type: Number, required: false, default: 0 },
|
|
158
160
|
filterCount: { type: Number, required: false, default: 0 },
|
|
161
|
+
activeFilters: { type: Array, required: false },
|
|
159
162
|
serverSort: { type: Boolean, required: false },
|
|
160
163
|
pagination: { type: Boolean, required: false },
|
|
161
164
|
showEdges: { type: Boolean, required: false },
|
|
@@ -173,7 +176,7 @@ const props = defineProps({
|
|
|
173
176
|
editable: { type: Boolean, required: false },
|
|
174
177
|
spreadsheet: { type: Boolean, required: false }
|
|
175
178
|
});
|
|
176
|
-
const emit = defineEmits(["rowClick", "selectionChange", "sortChange", "filterChange", "copy", "cellsChange", "cellsInvalid", "dirtyChange", "rangeChange", "filtersReset"]);
|
|
179
|
+
const emit = defineEmits(["rowClick", "selectionChange", "sortChange", "filterChange", "copy", "cellsChange", "cellsInvalid", "dirtyChange", "rangeChange", "filtersReset", "filterRemove"]);
|
|
177
180
|
const query = defineModel("query", { type: String, ...{ default: "" } });
|
|
178
181
|
const page = defineModel("page", { type: Number, ...{ default: 1 } });
|
|
179
182
|
const pageSize = defineModel("pageSize", { type: [Number, String], ...{ default: 25 } });
|
|
@@ -383,7 +386,8 @@ function writePreference(patch) {
|
|
|
383
386
|
}
|
|
384
387
|
function readStoredState() {
|
|
385
388
|
const columns = readPreference()?.columns;
|
|
386
|
-
|
|
389
|
+
if (!Array.isArray(columns)) return null;
|
|
390
|
+
return props.columnMenu ? columns : columns.map(({ hide: _hide, ...column }) => column);
|
|
387
391
|
}
|
|
388
392
|
function clearStoredState() {
|
|
389
393
|
writePreference({ columns: void 0 });
|
|
@@ -391,7 +395,9 @@ function clearStoredState() {
|
|
|
391
395
|
function persistState(event) {
|
|
392
396
|
if (event && event.finished === false) return;
|
|
393
397
|
if (!preferenceKey.value || !api.value) return;
|
|
394
|
-
const columns = api.value.getColumnState().map(
|
|
398
|
+
const columns = api.value.getColumnState().map(
|
|
399
|
+
({ colId, hide, width, pinned }) => props.columnMenu ? { colId, hide, width, pinned } : { colId, width, pinned }
|
|
400
|
+
);
|
|
395
401
|
writePreference({ columns });
|
|
396
402
|
}
|
|
397
403
|
function isPageSize(value) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FilterChangedEvent, FilterModel, ColDef, GetRowIdParams, GridApi, GridOptions, RowClickedEvent } from 'ag-grid-community';
|
|
2
2
|
import type { PageSize } from '../components/data/types';
|
|
3
|
-
import type { GridCellRange, GridCellsChange, GridCellsInvalid, GridDensity, GridMessages, GridSelection, GridSortChange } from './types';
|
|
3
|
+
import type { GridCellRange, GridCellsChange, GridCellsInvalid, GridActiveFilter, GridDensity, GridMessages, GridSelection, GridSortChange } from './types';
|
|
4
4
|
declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
5
5
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<({
|
|
6
6
|
rows?: T[];
|
|
@@ -22,6 +22,7 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
|
|
|
22
22
|
exportFileName?: string;
|
|
23
23
|
searchDebounce?: number;
|
|
24
24
|
filterCount?: number;
|
|
25
|
+
activeFilters?: GridActiveFilter[];
|
|
25
26
|
serverSort?: boolean;
|
|
26
27
|
pagination?: boolean;
|
|
27
28
|
showEdges?: boolean;
|
|
@@ -51,6 +52,7 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
|
|
|
51
52
|
"onUpdate:sort"?: ((value: GridSortChange | null | undefined) => any) | undefined;
|
|
52
53
|
"onUpdate:query"?: ((value: string) => any) | undefined;
|
|
53
54
|
onFiltersReset?: (() => any) | undefined;
|
|
55
|
+
onFilterRemove?: ((id: string) => any) | undefined;
|
|
54
56
|
onSelectionChange?: ((rows: T[]) => any) | undefined;
|
|
55
57
|
onSortChange?: ((change: GridSortChange | null) => any) | undefined;
|
|
56
58
|
onFilterChange?: ((model: FilterModel, event: FilterChangedEvent<T, any>) => any) | undefined;
|
|
@@ -140,7 +142,7 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
|
|
|
140
142
|
count: number;
|
|
141
143
|
}) => any;
|
|
142
144
|
};
|
|
143
|
-
emit: (((evt: "copy", text: string) => void) & ((evt: "rowClick", event: RowClickedEvent<T, any>) => void) & ((evt: "filtersReset") => void) & ((evt: "selectionChange", rows: T[]) => void) & ((evt: "sortChange", change: GridSortChange | null) => void) & ((evt: "filterChange", model: FilterModel, event: FilterChangedEvent<T, any>) => void) & ((evt: "cellsChange", event: GridCellsChange) => void) & ((evt: "cellsInvalid", event: GridCellsInvalid) => void) & ((evt: "dirtyChange", count: number) => void) & ((evt: "rangeChange", range: GridCellRange | null) => void)) & (((event: "update:page", value: number) => void) & ((event: "update:pageSize", value: PageSize) => void) & ((event: "update:sort", value: GridSortChange | null | undefined) => void) & ((event: "update:query", value: string) => void));
|
|
145
|
+
emit: (((evt: "copy", text: string) => void) & ((evt: "rowClick", event: RowClickedEvent<T, any>) => void) & ((evt: "filtersReset") => void) & ((evt: "filterRemove", id: string) => void) & ((evt: "selectionChange", rows: T[]) => void) & ((evt: "sortChange", change: GridSortChange | null) => void) & ((evt: "filterChange", model: FilterModel, event: FilterChangedEvent<T, any>) => void) & ((evt: "cellsChange", event: GridCellsChange) => void) & ((evt: "cellsInvalid", event: GridCellsInvalid) => void) & ((evt: "dirtyChange", count: number) => void) & ((evt: "rangeChange", range: GridCellRange | null) => void)) & (((event: "update:page", value: number) => void) & ((event: "update:pageSize", value: PageSize) => void) & ((event: "update:sort", value: GridSortChange | null | undefined) => void) & ((event: "update:query", value: string) => void));
|
|
144
146
|
}>) => import("vue").VNode & {
|
|
145
147
|
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
146
148
|
};
|
|
@@ -35,6 +35,15 @@
|
|
|
35
35
|
aria-hidden="true"
|
|
36
36
|
/>
|
|
37
37
|
</span>
|
|
38
|
+
<FilterPills
|
|
39
|
+
v-if="$slots.filters && filterPills.length"
|
|
40
|
+
class="k-data-grid-active-filters"
|
|
41
|
+
size="sm"
|
|
42
|
+
:options="filterPills"
|
|
43
|
+
:label="text.filters"
|
|
44
|
+
@select="filtersOpen = true"
|
|
45
|
+
@remove="(id) => emit('filterRemove', id)"
|
|
46
|
+
/>
|
|
38
47
|
<Modal v-if="$slots.filters" v-model:open="filtersOpen" :title="text.filters" size="sm">
|
|
39
48
|
<div class="k-data-grid-filters-body">
|
|
40
49
|
<slot name="filters" :close="closeFilters" :count="activeFilters" />
|
|
@@ -89,6 +98,7 @@ import { computed, onBeforeUnmount, ref, watch } from "vue";
|
|
|
89
98
|
import Button from "../components/core/Button.vue";
|
|
90
99
|
import Input from "../components/core/Input.vue";
|
|
91
100
|
import Badge from "../components/data/Badge.vue";
|
|
101
|
+
import FilterPills from "../components/data/FilterPills.vue";
|
|
92
102
|
import DropdownMenu from "../components/overlays/DropdownMenu.vue";
|
|
93
103
|
import Modal from "../components/overlays/Modal.vue";
|
|
94
104
|
import { useLocale } from "../composables/useLocale";
|
|
@@ -101,13 +111,24 @@ const props = defineProps({
|
|
|
101
111
|
exportable: { type: Boolean, required: false, default: true },
|
|
102
112
|
exportFileName: { type: String, required: false, default: "export" },
|
|
103
113
|
debounce: { type: Number, required: false, default: 0 },
|
|
104
|
-
filterCount: { type: Number, required: false, default: 0 }
|
|
114
|
+
filterCount: { type: Number, required: false, default: 0 },
|
|
115
|
+
activeFilters: { type: Array, required: false }
|
|
105
116
|
});
|
|
106
|
-
const emit = defineEmits(["resetColumns", "filtersReset"]);
|
|
117
|
+
const emit = defineEmits(["resetColumns", "filtersReset", "filterRemove"]);
|
|
107
118
|
const query = defineModel({ type: String, ...{ default: "" } });
|
|
108
119
|
const { locale } = useLocale();
|
|
109
120
|
const filtersOpen = ref(false);
|
|
110
|
-
const activeFilters = computed(
|
|
121
|
+
const activeFilters = computed(
|
|
122
|
+
() => Math.max(0, Math.floor(props.filterCount), props.activeFilters?.length ?? 0)
|
|
123
|
+
);
|
|
124
|
+
const filterPills = computed(
|
|
125
|
+
() => (props.activeFilters ?? []).map((filter) => ({
|
|
126
|
+
value: filter.id,
|
|
127
|
+
label: filter.label,
|
|
128
|
+
valueLabel: filter.value,
|
|
129
|
+
removable: true
|
|
130
|
+
}))
|
|
131
|
+
);
|
|
111
132
|
const text = computed(() => ({
|
|
112
133
|
...locale.value.messages.grid,
|
|
113
134
|
...props.messages
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { GridMessages } from './types';
|
|
2
2
|
declare function closeFilters(): void;
|
|
3
|
-
declare var
|
|
3
|
+
declare var __VLS_36: {
|
|
4
4
|
close: typeof closeFilters;
|
|
5
5
|
count: number;
|
|
6
|
-
},
|
|
6
|
+
}, __VLS_53: {}, __VLS_73: {};
|
|
7
7
|
type __VLS_Slots = {} & {
|
|
8
|
-
filters?: (props: typeof
|
|
8
|
+
filters?: (props: typeof __VLS_36) => any;
|
|
9
9
|
} & {
|
|
10
|
-
default?: (props: typeof
|
|
10
|
+
default?: (props: typeof __VLS_53) => any;
|
|
11
11
|
} & {
|
|
12
|
-
end?: (props: typeof
|
|
12
|
+
end?: (props: typeof __VLS_73) => any;
|
|
13
13
|
};
|
|
14
14
|
declare const __VLS_base: import("vue").DefineComponent<{
|
|
15
15
|
api?: import("ag-grid-community").GridApi | null;
|
|
@@ -20,6 +20,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
20
20
|
exportFileName?: string;
|
|
21
21
|
debounce?: number;
|
|
22
22
|
filterCount?: number;
|
|
23
|
+
activeFilters?: import("./types").GridActiveFilter[];
|
|
23
24
|
modelValue?: string;
|
|
24
25
|
key?: PropertyKey | undefined;
|
|
25
26
|
prefix?: string | undefined | undefined;
|
|
@@ -217,6 +218,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
217
218
|
resetColumns: () => any;
|
|
218
219
|
"update:modelValue": (value: string) => any;
|
|
219
220
|
filtersReset: () => any;
|
|
221
|
+
filterRemove: (id: string) => any;
|
|
220
222
|
}, string, import("vue").PublicProps, Readonly<{
|
|
221
223
|
api?: import("ag-grid-community").GridApi | null;
|
|
222
224
|
messages?: Partial<GridMessages>;
|
|
@@ -226,6 +228,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
226
228
|
exportFileName?: string;
|
|
227
229
|
debounce?: number;
|
|
228
230
|
filterCount?: number;
|
|
231
|
+
activeFilters?: import("./types").GridActiveFilter[];
|
|
229
232
|
modelValue?: string;
|
|
230
233
|
key?: PropertyKey | undefined;
|
|
231
234
|
prefix?: string | undefined | undefined;
|
|
@@ -423,6 +426,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
423
426
|
onResetColumns?: (() => any) | undefined;
|
|
424
427
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
425
428
|
onFiltersReset?: (() => any) | undefined;
|
|
429
|
+
onFilterRemove?: ((id: string) => any) | undefined;
|
|
426
430
|
}>, {
|
|
427
431
|
debounce: number;
|
|
428
432
|
searchable: boolean;
|
package/dist/grid/data-grid.css
CHANGED
package/dist/grid/types.d.ts
CHANGED
|
@@ -36,6 +36,12 @@ export interface GridToolbarProps {
|
|
|
36
36
|
exportFileName?: string;
|
|
37
37
|
debounce?: number;
|
|
38
38
|
filterCount?: number;
|
|
39
|
+
activeFilters?: GridActiveFilter[];
|
|
40
|
+
}
|
|
41
|
+
export interface GridActiveFilter {
|
|
42
|
+
id: string;
|
|
43
|
+
label: string;
|
|
44
|
+
value: string;
|
|
39
45
|
}
|
|
40
46
|
export interface BooleanCellParams {
|
|
41
47
|
trueLabel?: string;
|
package/package.json
CHANGED