@balena/ui-shared-components 12.0.2-build-renovate-virtua-418c2c10d0fa82b41ef702198fabd623c02dd5fd-1 → 12.1.0-build-add-server-side-tag-order-by-990ba2861d7d8b91af9ea2121ebdbe45157950f4-1
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/RJST/Lenses/types/index.d.ts +3 -4
- package/dist/components/RJST/Lenses/types/table.js +5 -2
- package/dist/components/RJST/components/Table/AddTagHandler.d.ts +1 -1
- package/dist/components/RJST/components/Table/TableActions.d.ts +1 -1
- package/dist/components/RJST/components/Table/TableCell.d.ts +1 -1
- package/dist/components/RJST/components/Table/TableHeader.d.ts +1 -1
- package/dist/components/RJST/components/Table/TableRow.d.ts +1 -1
- package/dist/components/RJST/components/Table/TableToolbar.d.ts +1 -1
- package/dist/components/RJST/components/Table/index.d.ts +3 -3
- package/dist/components/RJST/components/Table/index.js +2 -1
- package/dist/components/RJST/components/Table/useColumns.d.ts +3 -3
- package/dist/components/RJST/components/Table/utils.d.ts +3 -1
- package/dist/components/RJST/index.d.ts +0 -13
- package/dist/components/RJST/oData/jsonToOData.d.ts +1 -1
- package/dist/components/RJST/oData/jsonToOData.js +2 -2
- package/dist/components/RJST/schemaOps.d.ts +13 -0
- package/package.json +3 -3
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { RJSTEntityPropertyDefinition } from '../../';
|
|
2
|
-
import type { RJSTContext, RJSTModel } from '../../schemaOps';
|
|
1
|
+
import type { RJSTContext, RJSTEntityPropertyDefinition, RJSTModel } from '../../schemaOps';
|
|
3
2
|
import type { CheckedState, Pagination, TableSortOptions } from '../../components/Table/utils';
|
|
4
3
|
import type { BoxProps } from '@mui/material';
|
|
5
4
|
export { table } from './table';
|
|
@@ -18,11 +17,11 @@ export interface CollectionLensRendererProps<T extends {
|
|
|
18
17
|
filtered: T[];
|
|
19
18
|
selected?: Array<Subset<T>>;
|
|
20
19
|
checkedState?: CheckedState;
|
|
21
|
-
sort: TableSortOptions | null;
|
|
20
|
+
sort: TableSortOptions<T> | null;
|
|
22
21
|
changeSelected: (selected: T[] | undefined, allChecked?: CheckedState) => void;
|
|
23
22
|
data: T[] | undefined;
|
|
24
23
|
onPageChange?: (page: number, itemsPerPage: number) => void;
|
|
25
|
-
onSort?: (sort: TableSortOptions) => void;
|
|
24
|
+
onSort?: (sort: TableSortOptions<T>) => void;
|
|
26
25
|
pagination: Pagination;
|
|
27
26
|
rowKey?: keyof T;
|
|
28
27
|
}
|
|
@@ -118,14 +118,17 @@ const TableRenderer = ({ filtered, selected, properties, hasUpdateActions, check
|
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
const additionalColumns = selectedTagColumns.map((key, index) => {
|
|
121
|
+
const field = rjstContext.tagField;
|
|
121
122
|
return {
|
|
122
123
|
title: key,
|
|
123
124
|
label: `Tag: ${key}`,
|
|
124
125
|
key: `${TAG_COLUMN_PREFIX}${key}`,
|
|
125
126
|
selected: true,
|
|
126
127
|
type: 'predefined',
|
|
127
|
-
field
|
|
128
|
-
sortable: pagination.serverSide
|
|
128
|
+
field,
|
|
129
|
+
sortable: pagination.serverSide
|
|
130
|
+
? `${field}(tag_key='${key}')/value`
|
|
131
|
+
: true,
|
|
129
132
|
index: index + 1 + columns.length,
|
|
130
133
|
priority: '',
|
|
131
134
|
render: tagKeyRender(key),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RJSTEntityPropertyDefinition } from '
|
|
1
|
+
import type { RJSTEntityPropertyDefinition } from '../../schemaOps';
|
|
2
2
|
import type { MenuItemProps } from '@mui/material';
|
|
3
3
|
import type { ColumnPreferencesChangeProp } from './index';
|
|
4
4
|
interface TableActionsProps<T> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { RJSTEntityPropertyDefinition } from '
|
|
2
|
+
import type { RJSTEntityPropertyDefinition } from '../../schemaOps';
|
|
3
3
|
export interface TableCellProps<T> {
|
|
4
4
|
href: string | undefined;
|
|
5
5
|
onRowClick: ((entity: T, event: React.MouseEvent<HTMLAnchorElement>) => void) | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as React from 'react';
|
|
2
2
|
import type { CheckedState, Order } from './utils';
|
|
3
|
-
import type { RJSTEntityPropertyDefinition } from '
|
|
3
|
+
import type { RJSTEntityPropertyDefinition } from '../../schemaOps';
|
|
4
4
|
interface TableHeaderProps<T> {
|
|
5
5
|
columns: Array<RJSTEntityPropertyDefinition<T>>;
|
|
6
6
|
data: T[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as React from 'react';
|
|
2
2
|
import type { CheckedState } from './utils';
|
|
3
3
|
import { type TableCellProps } from './TableCell';
|
|
4
|
-
import type { RJSTEntityPropertyDefinition } from '
|
|
4
|
+
import type { RJSTEntityPropertyDefinition } from '../../schemaOps';
|
|
5
5
|
export interface TableRowProps<T> {
|
|
6
6
|
row: T;
|
|
7
7
|
rowKey: keyof T;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MenuItemProps } from '@mui/material';
|
|
2
|
-
import type { RJSTEntityPropertyDefinition } from '
|
|
2
|
+
import type { RJSTEntityPropertyDefinition } from '../../schemaOps';
|
|
3
3
|
import type { ColumnPreferencesChangeProp } from './index';
|
|
4
4
|
interface TableToolbarProps<T> {
|
|
5
5
|
numSelected?: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { CheckedState, Pagination, TableSortOptions } from './utils';
|
|
3
3
|
import type { MenuItemProps } from '@mui/material';
|
|
4
|
-
import type { RJSTEntityPropertyDefinition } from '
|
|
4
|
+
import type { RJSTEntityPropertyDefinition } from '../../schemaOps';
|
|
5
5
|
export type ColumnPreferencesChangeProp<T> = (columns: Array<RJSTEntityPropertyDefinition<T>>, changeType: 'display' | 'reorder') => void;
|
|
6
6
|
interface TableProps<T> {
|
|
7
7
|
rowKey: keyof T;
|
|
@@ -10,10 +10,10 @@ interface TableProps<T> {
|
|
|
10
10
|
checkedState?: CheckedState;
|
|
11
11
|
columns: Array<RJSTEntityPropertyDefinition<T>>;
|
|
12
12
|
pagination: Pagination;
|
|
13
|
-
sort: TableSortOptions
|
|
13
|
+
sort: TableSortOptions<T>;
|
|
14
14
|
actions?: MenuItemProps[];
|
|
15
15
|
onCheck?: (selected: T[] | undefined, allChecked?: CheckedState) => void;
|
|
16
|
-
onSort?: (sort: TableSortOptions) => void;
|
|
16
|
+
onSort?: (sort: TableSortOptions<T>) => void;
|
|
17
17
|
getRowHref: ((entry: any) => string) | undefined;
|
|
18
18
|
onRowClick?: (entity: T, event: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
19
19
|
onPageChange?: (page: number, itemsPerPage: number) => void;
|
|
@@ -55,7 +55,7 @@ export const Table = ({ rowKey, data, checkedItems = [], checkedState, columns,
|
|
|
55
55
|
? new Map(visibleRows.map((row) => [row[rowKey], row]))
|
|
56
56
|
: null;
|
|
57
57
|
}, [visibleRows, rowKey]);
|
|
58
|
-
const handleOnSort = React.useCallback((_event, { key, field, refScheme }) => {
|
|
58
|
+
const handleOnSort = React.useCallback((_event, { key, field, refScheme, sortable }) => {
|
|
59
59
|
if (!sort) {
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
@@ -66,6 +66,7 @@ export const Table = ({ rowKey, data, checkedItems = [], checkedState, columns,
|
|
|
66
66
|
const sortObj = {
|
|
67
67
|
direction: newOrder,
|
|
68
68
|
field: field,
|
|
69
|
+
sortable,
|
|
69
70
|
key: key,
|
|
70
71
|
refScheme: refScheme,
|
|
71
72
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import type { TagField } from './utils';
|
|
3
|
-
import type { RJSTEntityPropertyDefinition } from '
|
|
3
|
+
import type { RJSTEntityPropertyDefinition } from '../../schemaOps';
|
|
4
4
|
export declare const TAG_COLUMN_PREFIX = "tag_column_";
|
|
5
5
|
export declare function useColumns<T>(resourceName: string, defaultColumns: Array<RJSTEntityPropertyDefinition<T>>, tagKeyRender: (key: string) => (tags: TagField[] | undefined) => React.ReactElement | null): readonly [{
|
|
6
6
|
render: ((tags: TagField[] | undefined) => React.ReactElement | null) | ((value: any, row: T) => string | number | JSX.Element | null | undefined);
|
|
@@ -10,7 +10,7 @@ export declare function useColumns<T>(resourceName: string, defaultColumns: Arra
|
|
|
10
10
|
label: string | JSX.Element;
|
|
11
11
|
field: Extract<keyof T, string>;
|
|
12
12
|
key: string;
|
|
13
|
-
sortable: boolean | ((a: T, b: T) => number);
|
|
13
|
+
sortable: string | boolean | ((a: T, b: T) => number);
|
|
14
14
|
type: string;
|
|
15
15
|
priority: string;
|
|
16
16
|
refScheme?: string;
|
|
@@ -22,7 +22,7 @@ export declare function useColumns<T>(resourceName: string, defaultColumns: Arra
|
|
|
22
22
|
label: string | JSX.Element;
|
|
23
23
|
field: Extract<keyof T, string>;
|
|
24
24
|
key: string;
|
|
25
|
-
sortable: boolean | ((a: T, b: T) => number);
|
|
25
|
+
sortable: string | boolean | ((a: T, b: T) => number);
|
|
26
26
|
type: string;
|
|
27
27
|
priority: string;
|
|
28
28
|
refScheme?: string;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { RJSTEntityPropertyDefinition } from '../../schemaOps';
|
|
1
2
|
export type Order = 'asc' | 'desc';
|
|
2
3
|
export type CheckedState = 'none' | 'some' | 'all';
|
|
3
|
-
export interface TableSortOptions {
|
|
4
|
+
export interface TableSortOptions<T> {
|
|
4
5
|
direction: Order;
|
|
5
6
|
field: string;
|
|
6
7
|
key: string;
|
|
8
|
+
sortable: RJSTEntityPropertyDefinition<T>['sortable'];
|
|
7
9
|
refScheme?: string;
|
|
8
10
|
}
|
|
9
11
|
export type Pagination = {
|
|
@@ -59,16 +59,3 @@ export interface RJSTProps<T> extends Omit<BoxProps, 'onChange'> {
|
|
|
59
59
|
}
|
|
60
60
|
export declare const RJST: <T extends RJSTBaseResource<T>>({ model: modelRaw, data, formats, actions, sdk, customSort, refresh, getBaseUrl, onEntityClick, onChange, pagination, customLenses, loading, rowKey, noDataInfo, persistFilters, ...boxProps }: RJSTProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
61
61
|
export { rjstRunTransformers, rjstDefaultPermissions, rjstGetModelForCollection, rjstAddToSchema, type RJSTAction, type RJSTBaseResource, type RJSTRawModel, type RJSTModel, rjstJsonSchemaPick, rjstGetDisabledReason, getPropertyScheme, getSubSchemaFromRefScheme, parseDescription, parseDescriptionProperty, generateSchemaFromRefScheme, };
|
|
62
|
-
export type RJSTEntityPropertyDefinition<T> = {
|
|
63
|
-
title: string;
|
|
64
|
-
label: string | JSX.Element;
|
|
65
|
-
field: Extract<keyof T, string>;
|
|
66
|
-
key: string;
|
|
67
|
-
selected: boolean;
|
|
68
|
-
index: number;
|
|
69
|
-
sortable: boolean | ((a: T, b: T) => number);
|
|
70
|
-
render: (value: any, row: T) => string | number | JSX.Element | null | undefined;
|
|
71
|
-
type: string;
|
|
72
|
-
priority: string;
|
|
73
|
-
refScheme?: string;
|
|
74
|
-
};
|
|
@@ -7,5 +7,5 @@ interface FilterMutation extends JSONSchema {
|
|
|
7
7
|
$or?: any[];
|
|
8
8
|
}
|
|
9
9
|
export declare const convertToPineClientFilter: (parentKeys: string[], filter: FilterMutation | FilterMutation[]) => PineFilterObject | undefined;
|
|
10
|
-
export declare const orderbyBuilder: <T>(sortInfo: TableSortOptions | null, customSort: RJSTContext<T>["customSort"]) => string[] | null;
|
|
10
|
+
export declare const orderbyBuilder: <T>(sortInfo: TableSortOptions<T> | null, customSort: RJSTContext<T>["customSort"]) => string[] | null;
|
|
11
11
|
export {};
|
|
@@ -177,7 +177,7 @@ export const convertToPineClientFilter = (parentKeys, filter) => {
|
|
|
177
177
|
return handlePrimitiveFilter(parentKeys, filter);
|
|
178
178
|
};
|
|
179
179
|
export const orderbyBuilder = (sortInfo, customSort) => {
|
|
180
|
-
var _a;
|
|
180
|
+
var _a, _b;
|
|
181
181
|
if (!sortInfo) {
|
|
182
182
|
return null;
|
|
183
183
|
}
|
|
@@ -188,7 +188,7 @@ export const orderbyBuilder = (sortInfo, customSort) => {
|
|
|
188
188
|
// TODO: Refactor this logic to create an object structure and retrieve the correct property using the refScheme.
|
|
189
189
|
// The customSort should look like: { user: { owns_items: [{ uuid: 'xx09x0' }] } }
|
|
190
190
|
// The refScheme will reference the property path, e.g., owns_items[0].uuid.
|
|
191
|
-
const customOrderByKey = (_a = customSort === null || customSort === void 0 ? void 0 : customSort[`${field}_${refScheme}`]) !== null && _a !== void 0 ? _a : customSort === null || customSort === void 0 ? void 0 : customSort[field];
|
|
191
|
+
const customOrderByKey = (_b = (_a = customSort === null || customSort === void 0 ? void 0 : customSort[`${field}_${refScheme}`]) !== null && _a !== void 0 ? _a : customSort === null || customSort === void 0 ? void 0 : customSort[field]) !== null && _b !== void 0 ? _b : (typeof sortInfo.sortable === 'string' ? sortInfo.sortable : undefined);
|
|
192
192
|
if (typeof customOrderByKey === 'string') {
|
|
193
193
|
return [`${customOrderByKey} ${direction}`, `id ${direction}`];
|
|
194
194
|
}
|
|
@@ -33,6 +33,19 @@ export interface RJSTModel<T> {
|
|
|
33
33
|
permissions: Permissions<T>;
|
|
34
34
|
priorities?: Priorities<T>;
|
|
35
35
|
}
|
|
36
|
+
export type RJSTEntityPropertyDefinition<T> = {
|
|
37
|
+
title: string;
|
|
38
|
+
label: string | JSX.Element;
|
|
39
|
+
field: Extract<keyof T, string>;
|
|
40
|
+
key: string;
|
|
41
|
+
selected: boolean;
|
|
42
|
+
sortable: boolean | ((a: T, b: T) => number) | string;
|
|
43
|
+
index: number;
|
|
44
|
+
render: (value: any, row: T) => string | number | JSX.Element | null | undefined;
|
|
45
|
+
type: string;
|
|
46
|
+
priority: string;
|
|
47
|
+
refScheme?: string;
|
|
48
|
+
};
|
|
36
49
|
export interface CustomSchemaDescription {
|
|
37
50
|
'x-ref-scheme'?: string[];
|
|
38
51
|
'x-foreign-key-scheme'?: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@balena/ui-shared-components",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.1.0-build-add-server-side-tag-order-by-990ba2861d7d8b91af9ea2121ebdbe45157950f4-1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"files": [
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"rimraf": "^6.0.0",
|
|
51
51
|
"ts-jest": "^29.2.5",
|
|
52
52
|
"typescript": "^5.8.2",
|
|
53
|
-
"virtua": "^0.
|
|
53
|
+
"virtua": "^0.37.3",
|
|
54
54
|
"zxcvbn": "^4.4.2"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
@@ -138,6 +138,6 @@
|
|
|
138
138
|
},
|
|
139
139
|
"homepage": "https://github.com/balena-io/ui-shared-components#readme",
|
|
140
140
|
"versionist": {
|
|
141
|
-
"publishedAt": "2025-04-
|
|
141
|
+
"publishedAt": "2025-04-08T10:35:24.000Z"
|
|
142
142
|
}
|
|
143
143
|
}
|