nuxt-ui-tools 1.27.5 → 1.29.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/dist/module.json +1 -1
- package/dist/module.mjs +7 -0
- package/dist/runtime/file-preview/components/renderers/audio-renderer.vue +1 -1
- package/dist/runtime/file-preview/components/renderers/video-renderer.vue +26 -84
- package/dist/runtime/i18n/locales/en.js +5 -0
- package/dist/runtime/i18n/locales/fr.js +5 -0
- package/dist/runtime/i18n/types.d.ts +7 -0
- package/dist/runtime/{file-preview/components/renderers → media/components}/media-controls.vue +3 -3
- package/dist/runtime/media/components/video-player.d.vue.ts +58 -0
- package/dist/runtime/media/components/video-player.vue +155 -0
- package/dist/runtime/media/components/video-player.vue.d.ts +58 -0
- package/dist/runtime/media/index.d.ts +1 -0
- package/dist/runtime/media/index.js +0 -0
- package/dist/runtime/media/types/index.d.ts +1 -0
- package/dist/runtime/media/types/index.js +0 -0
- package/dist/runtime/media/types/media.d.ts +8 -0
- package/dist/runtime/media/types/media.js +0 -0
- package/dist/runtime/table/components/grid/grid-renderer.vue +33 -8
- package/dist/runtime/table/components/table/table-group-header.d.vue.ts +9 -0
- package/dist/runtime/table/components/table/table-group-header.vue +77 -0
- package/dist/runtime/table/components/table/table-group-header.vue.d.ts +9 -0
- package/dist/runtime/table/components/table/table-renderer.vue +12 -7
- package/dist/runtime/table/components/table/table-row.d.vue.ts +4 -1
- package/dist/runtime/table/components/table/table-row.vue +16 -1
- package/dist/runtime/table/components/table/table-row.vue.d.ts +4 -1
- package/dist/runtime/table/components/table/table-selection-control.d.vue.ts +2 -0
- package/dist/runtime/table/components/table/table-selection-control.vue +3 -2
- package/dist/runtime/table/components/table/table-selection-control.vue.d.ts +2 -0
- package/dist/runtime/table/composables/use-table-grid.d.ts +7 -3
- package/dist/runtime/table/composables/use-table-grid.js +27 -2
- package/dist/runtime/table/composables/use-table-groups.d.ts +28 -0
- package/dist/runtime/table/composables/use-table-groups.js +133 -0
- package/dist/runtime/table/composables/use-table-internals.d.ts +42 -0
- package/dist/runtime/table/composables/use-table-internals.js +9 -0
- package/dist/runtime/table/composables/use-table-selection.d.ts +5 -0
- package/dist/runtime/table/composables/use-table-selection.js +13 -3
- package/dist/runtime/table/composables/use-table-tree.js +7 -5
- package/dist/runtime/table/constants/row-motion.d.ts +8 -0
- package/dist/runtime/table/constants/row-motion.js +5 -0
- package/dist/runtime/table/types/groups.d.ts +44 -0
- package/dist/runtime/table/types/groups.js +0 -0
- package/dist/runtime/table/types/index.d.ts +1 -0
- package/dist/runtime/table/types/layout.d.ts +5 -0
- package/dist/runtime/table/utils/groups.d.ts +14 -0
- package/dist/runtime/table/utils/groups.js +55 -0
- package/dist/runtime/table/utils/index.d.ts +1 -0
- package/dist/runtime/table/utils/index.js +1 -0
- package/package.json +16 -1
- /package/dist/runtime/{file-preview/components/renderers → media/components}/media-controls.d.vue.ts +0 -0
- /package/dist/runtime/{file-preview/components/renderers → media/components}/media-controls.vue.d.ts +0 -0
|
@@ -61,6 +61,12 @@ export function useTableSelection(options) {
|
|
|
61
61
|
function isRowSelected(params) {
|
|
62
62
|
return selectedKeys.value.includes(params.rowId);
|
|
63
63
|
}
|
|
64
|
+
function getRowsSelectionState(params) {
|
|
65
|
+
const selected = new Set(selectedKeys.value);
|
|
66
|
+
const count = params.rowIds.filter((rowId) => selected.has(rowId)).length;
|
|
67
|
+
if (count === 0) return false;
|
|
68
|
+
return count === params.rowIds.length ? true : "indeterminate";
|
|
69
|
+
}
|
|
64
70
|
function selectRows(params) {
|
|
65
71
|
if (!selectionEnabled.value) {
|
|
66
72
|
return;
|
|
@@ -117,9 +123,12 @@ export function useTableSelection(options) {
|
|
|
117
123
|
}
|
|
118
124
|
lastTouchedRowId.value = params.rowId;
|
|
119
125
|
}
|
|
120
|
-
const rangeRowIds = computed(
|
|
121
|
-
(
|
|
122
|
-
|
|
126
|
+
const rangeRowIds = computed(() => {
|
|
127
|
+
if (options.tree.enabled.value) {
|
|
128
|
+
return options.tree.visibleNodes.value.filter((node) => options.tree.isSelectable(node)).map((node) => node.id);
|
|
129
|
+
}
|
|
130
|
+
return options.groups.enabled.value ? options.groups.visibleRowIds.value : scopeRowIds.value;
|
|
131
|
+
});
|
|
123
132
|
function getRangeRowIds(params) {
|
|
124
133
|
const anchorIndex = rangeRowIds.value.indexOf(params.anchorRowId);
|
|
125
134
|
const targetIndex = rangeRowIds.value.indexOf(params.targetRowId);
|
|
@@ -157,6 +166,7 @@ export function useTableSelection(options) {
|
|
|
157
166
|
bulkScope,
|
|
158
167
|
clearSelection,
|
|
159
168
|
getRowId,
|
|
169
|
+
getRowsSelectionState,
|
|
160
170
|
isRowSelected,
|
|
161
171
|
lastTouchedRowId,
|
|
162
172
|
partiallySelected,
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { usePreferredReducedMotion } from "@vueuse/core";
|
|
2
2
|
import { computed, onScopeDispose, reactive, ref, shallowRef } from "vue";
|
|
3
|
+
import {
|
|
4
|
+
ROW_CONCEAL_MS as CONCEAL_MS,
|
|
5
|
+
ROW_MOTION_LIMIT as MOTION_ROW_LIMIT,
|
|
6
|
+
ROW_REVEAL_MS as REVEAL_MS,
|
|
7
|
+
ROW_STAGGER_LIMIT as STAGGER_ROW_LIMIT,
|
|
8
|
+
ROW_STAGGER_MS as STAGGER_MS
|
|
9
|
+
} from "../constants/row-motion.js";
|
|
3
10
|
import { resolveTableRowId } from "../utils/rows.js";
|
|
4
11
|
import {
|
|
5
12
|
buildTableTree,
|
|
@@ -8,11 +15,6 @@ import {
|
|
|
8
15
|
getVisibleDescendants,
|
|
9
16
|
isOpenByDefault
|
|
10
17
|
} from "../utils/tree.js";
|
|
11
|
-
const CONCEAL_MS = 120;
|
|
12
|
-
const REVEAL_MS = 190;
|
|
13
|
-
const STAGGER_MS = 24;
|
|
14
|
-
const MOTION_ROW_LIMIT = 24;
|
|
15
|
-
const STAGGER_ROW_LIMIT = 8;
|
|
16
18
|
const EMPTY_INDEX = {
|
|
17
19
|
branches: [],
|
|
18
20
|
byId: /* @__PURE__ */ new Map(),
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** How long a closing branch or group plays out before its rows leave the list. */
|
|
2
|
+
export declare const ROW_CONCEAL_MS = 120;
|
|
3
|
+
/** How long the last revealed row takes to settle; the row's CSS owns the actual timing. */
|
|
4
|
+
export declare const ROW_REVEAL_MS = 190;
|
|
5
|
+
export declare const ROW_STAGGER_MS = 24;
|
|
6
|
+
/** Rows beyond these start or stop without a transition: they are mostly off screen anyway. */
|
|
7
|
+
export declare const ROW_MOTION_LIMIT = 24;
|
|
8
|
+
export declare const ROW_STAGGER_LIMIT = 8;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { GenericObject, RenderableType, TableKnownFieldPath } from './utils.js';
|
|
2
|
+
/** What a group's `label`, `summary` and `collapsed` receive. */
|
|
3
|
+
export interface TableGroupParams<TRow extends GenericObject = GenericObject> {
|
|
4
|
+
/** The value its rows share; `undefined` for rows that have none. */
|
|
5
|
+
value: unknown;
|
|
6
|
+
/** Its rows among those loaded, in display order. */
|
|
7
|
+
rows: TRow[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Gathers rows that share a value under a header row that folds them.
|
|
11
|
+
*
|
|
12
|
+
* Groups exist only on screen: the data stays flat, so filters, pagination and bulk actions keep
|
|
13
|
+
* working on rows. They cover the rows that are loaded, so a remote source needs a page large
|
|
14
|
+
* enough to hold a whole group. A column sort applies inside each group.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* table: {
|
|
19
|
+
* groupBy: {
|
|
20
|
+
* key: 'country',
|
|
21
|
+
* label: ({ value }) => countryName(value),
|
|
22
|
+
* },
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export interface TableGroupBySchema<TRow extends GenericObject = GenericObject> {
|
|
27
|
+
/** The row field to group on, or a function for a value the row does not hold as a field. */
|
|
28
|
+
key: TableKnownFieldPath<TRow> | ((row: TRow) => unknown);
|
|
29
|
+
/** The header's text. Defaults to the value, or the locale's "Other" for rows with none. */
|
|
30
|
+
label?: (params: TableGroupParams<TRow>) => RenderableType;
|
|
31
|
+
/** Shown next to the label. Defaults to the number of rows. */
|
|
32
|
+
summary?: (params: TableGroupParams<TRow>) => RenderableType;
|
|
33
|
+
/** Values listed here come first, in this order. The rest follow by value, empty ones last. */
|
|
34
|
+
order?: readonly unknown[];
|
|
35
|
+
/** Whether a group starts folded. A group the reader has toggled keeps that state. */
|
|
36
|
+
collapsed?: boolean | ((params: TableGroupParams<TRow>) => boolean);
|
|
37
|
+
}
|
|
38
|
+
/** One group of the loaded rows, resolved once per data change. */
|
|
39
|
+
export interface TableGroup<TRow extends GenericObject = GenericObject> {
|
|
40
|
+
readonly key: string;
|
|
41
|
+
readonly value: unknown;
|
|
42
|
+
readonly rows: TRow[];
|
|
43
|
+
readonly rowIds: string[];
|
|
44
|
+
}
|
|
File without changes
|
|
@@ -3,6 +3,7 @@ export type * from './columns';
|
|
|
3
3
|
export type * from './context';
|
|
4
4
|
export type * from './data-list';
|
|
5
5
|
export type * from './filters';
|
|
6
|
+
export type * from './groups';
|
|
6
7
|
export type * from './layout';
|
|
7
8
|
export type * from './query-state';
|
|
8
9
|
export type * from './remote-options';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ButtonProps } from '@nuxt/ui/components/Button.vue';
|
|
2
2
|
import type { LinkProps } from '@nuxt/ui/components/Link.vue';
|
|
3
3
|
import type { TableColumnCollection, TableSummaryRequest, TableSummaryScope, TableSummaryValue } from './columns.js';
|
|
4
|
+
import type { TableGroupBySchema } from './groups.js';
|
|
4
5
|
import type { TableTreeSchema } from './tree.js';
|
|
5
6
|
import type { GenericObject, TableDefaultSort, TableGridSortOption, TableLayout, TableRowRenderParams, RenderableType, TableSortKey, TableTextValue } from './utils.js';
|
|
6
7
|
export interface TablePersistenceOptions {
|
|
@@ -75,12 +76,16 @@ export interface TableGridSchema<TRow extends GenericObject = GenericObject, TCo
|
|
|
75
76
|
itemSize?: number | string | (() => number | string);
|
|
76
77
|
sortOptions?: TableGridSortOption<TSortKey>[];
|
|
77
78
|
defaultSorting?: TableDefaultSort<TSortKey>;
|
|
79
|
+
/** Gathers the cards that share a value under a header that folds them. See `TableGroupBySchema`. */
|
|
80
|
+
groupBy?: TableGroupBySchema<TRow>;
|
|
78
81
|
}
|
|
79
82
|
export interface TableTableSchema<TRow extends GenericObject = GenericObject, TContext extends GenericObject = GenericObject, TPageContext extends GenericObject = GenericObject, TSortKey extends string = TableSortKey<TRow>, TData = unknown> {
|
|
80
83
|
enabled?: boolean | string | (() => boolean | string);
|
|
81
84
|
columns?: TableColumnCollection<TRow, TContext, TPageContext, string, TSortKey, TData>;
|
|
82
85
|
/** Lets rows hold child rows that open beneath them. See `TableTreeSchema`. */
|
|
83
86
|
tree?: TableTreeSchema<TRow>;
|
|
87
|
+
/** Gathers rows that share a value under a header row that folds them. Ignored with `tree`. See `TableGroupBySchema`. */
|
|
88
|
+
groupBy?: TableGroupBySchema<TRow>;
|
|
84
89
|
defaultSorting?: TableDefaultSort<TSortKey>;
|
|
85
90
|
selection?: boolean | 'auto';
|
|
86
91
|
summaries?: TableSummariesSchema<TRow>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { GenericObject, TableGroup, TableGroupBySchema } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Brings the rows sharing a value together. Rows keep their order inside a group, so the sort the
|
|
4
|
+
* source applied survives in each one.
|
|
5
|
+
*/
|
|
6
|
+
export declare function buildTableGroups<TRow extends GenericObject>(options: {
|
|
7
|
+
rows: TRow[];
|
|
8
|
+
groupBy: TableGroupBySchema<TRow>;
|
|
9
|
+
getRowId: (row: TRow, index: number) => string;
|
|
10
|
+
}): TableGroup<TRow>[];
|
|
11
|
+
export declare function tableGroupRow(group: TableGroup): GenericObject;
|
|
12
|
+
export declare function tableGroupOf(row: GenericObject): TableGroup | undefined;
|
|
13
|
+
export declare function tableGroupsStorageKey(tableKey: string): string;
|
|
14
|
+
export declare function parseStoredGroupKeys(raw: string | null): string[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getTableRowValue } from "./rows.js";
|
|
2
|
+
const GROUP_ROW_KEY = "__nutTableGroup";
|
|
3
|
+
function groupValueOf(row, groupBy) {
|
|
4
|
+
const { key } = groupBy;
|
|
5
|
+
const value = typeof key === "function" ? key(row) : getTableRowValue({ path: String(key), row });
|
|
6
|
+
return value === null || value === void 0 || value === "" ? void 0 : value;
|
|
7
|
+
}
|
|
8
|
+
function compareGroupValues(order, left, right) {
|
|
9
|
+
const leftRank = order.indexOf(left);
|
|
10
|
+
const rightRank = order.indexOf(right);
|
|
11
|
+
if (leftRank !== -1 && rightRank !== -1) return leftRank - rightRank;
|
|
12
|
+
if (leftRank !== -1) return -1;
|
|
13
|
+
if (rightRank !== -1) return 1;
|
|
14
|
+
if (left === void 0) return 1;
|
|
15
|
+
if (right === void 0) return -1;
|
|
16
|
+
return String(left).localeCompare(String(right), void 0, { numeric: true });
|
|
17
|
+
}
|
|
18
|
+
export function buildTableGroups(options) {
|
|
19
|
+
const groups = /* @__PURE__ */ new Map();
|
|
20
|
+
for (const [index, row] of options.rows.entries()) {
|
|
21
|
+
const value = groupValueOf(row, options.groupBy);
|
|
22
|
+
const group = groups.get(value) ?? { rowIds: [], rows: [] };
|
|
23
|
+
group.rows.push(row);
|
|
24
|
+
group.rowIds.push(options.getRowId(row, index));
|
|
25
|
+
groups.set(value, group);
|
|
26
|
+
}
|
|
27
|
+
const order = options.groupBy.order ?? [];
|
|
28
|
+
return [...groups.entries()].sort(([left], [right]) => compareGroupValues(order, left, right)).map(([value, group]) => ({
|
|
29
|
+
key: `group:${JSON.stringify(value ?? null)}`,
|
|
30
|
+
rowIds: group.rowIds,
|
|
31
|
+
rows: group.rows,
|
|
32
|
+
value
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
export function tableGroupRow(group) {
|
|
36
|
+
return { [GROUP_ROW_KEY]: group };
|
|
37
|
+
}
|
|
38
|
+
function isTableGroupRow(row) {
|
|
39
|
+
return GROUP_ROW_KEY in row;
|
|
40
|
+
}
|
|
41
|
+
export function tableGroupOf(row) {
|
|
42
|
+
return isTableGroupRow(row) ? row[GROUP_ROW_KEY] : void 0;
|
|
43
|
+
}
|
|
44
|
+
export function tableGroupsStorageKey(tableKey) {
|
|
45
|
+
return `nuxt-ui-tools:table-groups:${tableKey}`;
|
|
46
|
+
}
|
|
47
|
+
export function parseStoredGroupKeys(raw) {
|
|
48
|
+
if (!raw) return [];
|
|
49
|
+
try {
|
|
50
|
+
const parsed = JSON.parse(raw);
|
|
51
|
+
return Array.isArray(parsed) ? parsed.filter((key) => typeof key === "string") : [];
|
|
52
|
+
} catch {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -6,6 +6,7 @@ export * from './data-list-ui.js';
|
|
|
6
6
|
export * from './facets.js';
|
|
7
7
|
export * from './filter-persistence.js';
|
|
8
8
|
export * from './filters/index.js';
|
|
9
|
+
export * from './groups.js';
|
|
9
10
|
export * from './pagination.js';
|
|
10
11
|
export * from './prefetch.js';
|
|
11
12
|
export * from './query-state.js';
|
|
@@ -6,6 +6,7 @@ export * from "./data-list-ui.js";
|
|
|
6
6
|
export * from "./facets.js";
|
|
7
7
|
export * from "./filter-persistence.js";
|
|
8
8
|
export * from "./filters/index.js";
|
|
9
|
+
export * from "./groups.js";
|
|
9
10
|
export * from "./pagination.js";
|
|
10
11
|
export * from "./prefetch.js";
|
|
11
12
|
export * from "./query-state.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-ui-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.29.0",
|
|
4
4
|
"description": "Nuxt module and runtime toolkit for UI-heavy Nuxt applications",
|
|
5
5
|
"homepage": "https://github.com/ChronicStone/nuxt-ui-tools#readme",
|
|
6
6
|
"bugs": "https://github.com/ChronicStone/nuxt-ui-tools/issues",
|
|
@@ -35,6 +35,9 @@
|
|
|
35
35
|
"i18n": [
|
|
36
36
|
"./dist/runtime/i18n/index.d.ts"
|
|
37
37
|
],
|
|
38
|
+
"media": [
|
|
39
|
+
"./dist/runtime/media/index.d.ts"
|
|
40
|
+
],
|
|
38
41
|
"query-state": [
|
|
39
42
|
"./dist/runtime/query-state/index.d.ts"
|
|
40
43
|
],
|
|
@@ -93,6 +96,14 @@
|
|
|
93
96
|
"types": "./dist/runtime/i18n/*.d.ts",
|
|
94
97
|
"default": "./dist/runtime/i18n/*.js"
|
|
95
98
|
},
|
|
99
|
+
"#ui-tools/media": {
|
|
100
|
+
"types": "./dist/runtime/media/index.d.ts",
|
|
101
|
+
"default": "./dist/runtime/media/index.js"
|
|
102
|
+
},
|
|
103
|
+
"#ui-tools/media/*": {
|
|
104
|
+
"types": "./dist/runtime/media/*.d.ts",
|
|
105
|
+
"default": "./dist/runtime/media/*.js"
|
|
106
|
+
},
|
|
96
107
|
"#ui-tools/query-state": {
|
|
97
108
|
"types": "./dist/runtime/query-state/index.d.ts",
|
|
98
109
|
"default": "./dist/runtime/query-state/index.js"
|
|
@@ -159,6 +170,10 @@
|
|
|
159
170
|
"types": "./dist/runtime/i18n/index.d.ts",
|
|
160
171
|
"import": "./dist/runtime/i18n/index.js"
|
|
161
172
|
},
|
|
173
|
+
"./media": {
|
|
174
|
+
"types": "./dist/runtime/media/index.d.ts",
|
|
175
|
+
"import": "./dist/runtime/media/index.js"
|
|
176
|
+
},
|
|
162
177
|
"./query-state": {
|
|
163
178
|
"types": "./dist/runtime/query-state/index.d.ts",
|
|
164
179
|
"import": "./dist/runtime/query-state/index.js"
|
/package/dist/runtime/{file-preview/components/renderers → media/components}/media-controls.d.vue.ts
RENAMED
|
File without changes
|
/package/dist/runtime/{file-preview/components/renderers → media/components}/media-controls.vue.d.ts
RENAMED
|
File without changes
|