@illinois-grad/grad-vue 5.0.2 → 5.0.4
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/components/GTable.vue.d.ts +1 -0
- package/dist/compose/useFiltering.d.ts +36 -4
- package/dist/compose/usePaging.d.ts +60 -0
- package/dist/{grad-vue-qPzpBTuo.js → grad-vue-ChdGX6W9.js} +460 -335
- package/dist/grad-vue-ChdGX6W9.js.map +1 -0
- package/dist/grad-vue-elements.css +30 -30
- package/dist/grad-vue-elements.js +98 -98
- package/dist/grad-vue-elements.js.map +1 -1
- package/dist/grad-vue.d.ts +4 -2
- package/dist/grad-vue.js +2 -2
- package/dist/plugin.js +2 -2
- package/package.json +1 -1
- package/dist/grad-vue-qPzpBTuo.js.map +0 -1
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import { Reactive, type Ref } from "vue";
|
|
2
2
|
export type FilterLocationQueryValueRaw = string | number;
|
|
3
|
+
export type FilterRouteQueryValue = string | null;
|
|
4
|
+
export type FilterRouteQuery = {
|
|
5
|
+
[p: string]: FilterRouteQueryValue | undefined | FilterRouteQueryValue[];
|
|
6
|
+
};
|
|
3
7
|
/**
|
|
4
8
|
* Query representation for filtering, compatible with vue-router
|
|
5
9
|
*/
|
|
6
10
|
export type FilterLocationQuery = {
|
|
7
|
-
[p: string]: string | null | number | undefined | FilterLocationQueryValueRaw[];
|
|
11
|
+
[p: string]: string | null | number | undefined | (FilterLocationQueryValueRaw | null)[];
|
|
8
12
|
};
|
|
9
13
|
export interface FilteringOptions {
|
|
10
|
-
syncWith?: Ref<
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
syncWith?: Ref<FilterRouteQuery>;
|
|
15
|
+
}
|
|
16
|
+
export interface QueryFilteringOptions<F extends Record<string, any> = Record<string, any>> {
|
|
17
|
+
route: {
|
|
18
|
+
query: FilterRouteQuery;
|
|
19
|
+
};
|
|
20
|
+
router: {
|
|
21
|
+
replace: (location: {
|
|
22
|
+
query: FilterLocationQuery;
|
|
23
|
+
}) => unknown;
|
|
24
|
+
};
|
|
25
|
+
booleanArrayKeys?: readonly Extract<keyof F, string>[];
|
|
13
26
|
}
|
|
14
27
|
/**
|
|
15
28
|
* Represents a type that defines a set of filters for a given record type.
|
|
@@ -43,6 +56,13 @@ export declare function filterOmitEmpty<T extends object>(value: T): Partial<T>;
|
|
|
43
56
|
* undefined if it's undefined.
|
|
44
57
|
*/
|
|
45
58
|
export declare function asArray<T>(value: T | T[]): NonNullable<T>[] | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Normalizes a route query value into a string array.
|
|
61
|
+
*
|
|
62
|
+
* Accepts either repeated query params (`?tag=a&tag=b`) or comma-separated
|
|
63
|
+
* values (`?tag=a,b`) and removes null entries from array values.
|
|
64
|
+
*/
|
|
65
|
+
export declare function parseQueryArrayValue(value: FilterRouteQueryValue | FilterRouteQueryValue[] | readonly FilterRouteQueryValue[] | undefined): string[] | undefined;
|
|
46
66
|
/**
|
|
47
67
|
* Converts filter criteria into a format suitable for use as a query object
|
|
48
68
|
* in vue-router.
|
|
@@ -57,6 +77,18 @@ export declare function filterAsQuery<T extends Record<string, any>, F extends {
|
|
|
57
77
|
* null, empty string, or false values. Supports single values and arrays.
|
|
58
78
|
*/
|
|
59
79
|
export declare function filtersToQueryParams<T extends Record<string, any>>(filters: T): Record<keyof T, string | string[]>;
|
|
80
|
+
/**
|
|
81
|
+
* Provides a router-agnostic wrapper for syncing filter state with route query params.
|
|
82
|
+
*
|
|
83
|
+
* Pass in `route` and `router` objects from your app so grad-vue does not need
|
|
84
|
+
* a direct dependency on vue-router. Filters whose defaults are arrays are
|
|
85
|
+
* read from and written to query params as arrays, and `booleanArrayKeys` can
|
|
86
|
+
* be used for multi-value filters that should be converted to boolean values
|
|
87
|
+
* inside the filter state.
|
|
88
|
+
*/
|
|
89
|
+
export declare function useQueryFiltering<T extends Record<string, any>, F extends {
|
|
90
|
+
[K in keyof T]?: any;
|
|
91
|
+
} = Record<keyof T, any>>(filters: F, options: QueryFilteringOptions<F>): UseFilteringReturn<T, F>;
|
|
60
92
|
/**
|
|
61
93
|
* Provides a mechanism to manage and synchronize filterable data with given filters and options.
|
|
62
94
|
*
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type Ref } from "vue";
|
|
2
|
+
import type { TableSort } from "../components/table/TableColumn";
|
|
3
|
+
import type { FilterLocationQuery, FilterRouteQuery, FilterRouteQueryValue } from "./useFiltering";
|
|
4
|
+
type SortKey = string;
|
|
5
|
+
type SortableRow = {
|
|
6
|
+
key: string;
|
|
7
|
+
} & Record<string, any>;
|
|
8
|
+
export type RawSortQuery = FilterRouteQueryValue | FilterRouteQueryValue[] | readonly FilterRouteQueryValue[] | undefined;
|
|
9
|
+
export type PagingSort<K extends SortKey = SortKey> = TableSort<SortableRow, K>;
|
|
10
|
+
export interface UsePagingOptions {
|
|
11
|
+
route?: {
|
|
12
|
+
query: FilterRouteQuery;
|
|
13
|
+
};
|
|
14
|
+
router?: {
|
|
15
|
+
replace: (location: {
|
|
16
|
+
query: FilterLocationQuery;
|
|
17
|
+
}) => unknown;
|
|
18
|
+
};
|
|
19
|
+
sortsKey?: string;
|
|
20
|
+
pageSizeKey?: string;
|
|
21
|
+
pageOffsetKey?: string;
|
|
22
|
+
defaultPageSize?: number;
|
|
23
|
+
defaultPageOffset?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface UsePagingReturn<K extends SortKey = SortKey> {
|
|
26
|
+
sorts: Ref<PagingSort<K>[]>;
|
|
27
|
+
pageSize: Ref<number>;
|
|
28
|
+
pageOffset: Ref<number>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Removes duplicate or invalid sort entries while keeping the original order.
|
|
32
|
+
*/
|
|
33
|
+
export declare function normalizeSorts<K extends SortKey>(sorts: readonly PagingSort<K>[] | undefined): PagingSort<K>[];
|
|
34
|
+
/**
|
|
35
|
+
* Parses the route query representation of sorts into table sort objects.
|
|
36
|
+
*
|
|
37
|
+
* Supports either repeated query params (`["name", "-status"]`) or a single
|
|
38
|
+
* comma-separated string (`"name,-status"`).
|
|
39
|
+
*/
|
|
40
|
+
export declare function parseSortQueryValue<K extends SortKey>(value: RawSortQuery): PagingSort<K>[];
|
|
41
|
+
/**
|
|
42
|
+
* Serializes table sort objects into the query-param form used by the apps.
|
|
43
|
+
*/
|
|
44
|
+
export declare function serializeSortQueryValue<K extends SortKey>(sorts: readonly PagingSort<K>[] | undefined): string[] | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Builds the API `sortBy` string from the current sorts and optional tie-breakers.
|
|
47
|
+
*
|
|
48
|
+
* When the only explicit sort is descending, tie-breakers inherit that same
|
|
49
|
+
* descending direction.
|
|
50
|
+
*/
|
|
51
|
+
export declare function buildSortBy<K extends SortKey>(sorts: readonly PagingSort<K>[] | undefined, tieBreakers?: readonly string[]): string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Manages table sorts and pagination state, optionally syncing it with route query params.
|
|
54
|
+
*
|
|
55
|
+
* Pass `route` and `router` objects to share query-backed paging state across apps
|
|
56
|
+
* without adding a direct vue-router dependency to grad-vue. If they are
|
|
57
|
+
* omitted, the composable still works as local reactive state.
|
|
58
|
+
*/
|
|
59
|
+
export declare function usePaging<K extends SortKey = SortKey>(options?: UsePagingOptions): UsePagingReturn<K>;
|
|
60
|
+
export {};
|