@balena/ui-shared-components 14.0.1-build-sdk23-orderby-e357d5b8ffc1975aa61a5978370ee31a3b72fcc7-1 → 14.0.1-build-update-analytics-client-93050948203c972f1a079d1ea74a91826a24bb3f-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.
|
@@ -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<T> | null, customSort: RJSTContext<T>["customSort"]) =>
|
|
10
|
+
export declare const orderbyBuilder: <T>(sortInfo: TableSortOptions<T> | null, customSort: RJSTContext<T>["customSort"]) => string[] | null;
|
|
11
11
|
export {};
|
|
@@ -176,43 +176,6 @@ export const convertToPineClientFilter = (parentKeys, filter) => {
|
|
|
176
176
|
}
|
|
177
177
|
return handlePrimitiveFilter(parentKeys, filter);
|
|
178
178
|
};
|
|
179
|
-
const keyToOrderByStructure = (path, direction) => {
|
|
180
|
-
console.log('*** path', path);
|
|
181
|
-
// Step 1: Normalize the path.
|
|
182
|
-
// Replace bracket notation like [0] with dot notation like .0
|
|
183
|
-
// This makes splitting the path into consistent parts easier.
|
|
184
|
-
const parts = path.replace(/\[(\d+)\]/g, '/$1').split('/');
|
|
185
|
-
const result = {};
|
|
186
|
-
// Step 2: Define the recursive helper function.
|
|
187
|
-
// This function will traverse the parts and build the object.
|
|
188
|
-
const build = (currentObject, currentParts) => {
|
|
189
|
-
var _a;
|
|
190
|
-
const key = currentParts.shift();
|
|
191
|
-
// If key is undefined (e.g. empty string), we stop.
|
|
192
|
-
if (!key) {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
// Base Case: If there are no more parts left, we've reached
|
|
196
|
-
// the end of the path. Assign the value to the current key.
|
|
197
|
-
if (currentParts.length === 0) {
|
|
198
|
-
currentObject[key] = direction;
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
// Recursive Step: If there are more parts, we need to go deeper.
|
|
202
|
-
// We peek at the *next* part to decide if we need to create
|
|
203
|
-
// an Array or an Object for the current key.
|
|
204
|
-
const nextKey = currentParts[0];
|
|
205
|
-
const needsArray = /^\d+$/.test(nextKey);
|
|
206
|
-
// If the path doesn't exist yet, create it.
|
|
207
|
-
// Create an array if the next part is a number, otherwise an object.
|
|
208
|
-
(_a = currentObject[key]) !== null && _a !== void 0 ? _a : (currentObject[key] = needsArray ? [] : {});
|
|
209
|
-
// Make the recursive call on the next level down.
|
|
210
|
-
build(currentObject[key], currentParts);
|
|
211
|
-
};
|
|
212
|
-
// Step 3: Kick off the recursion.
|
|
213
|
-
build(result, parts);
|
|
214
|
-
return result;
|
|
215
|
-
};
|
|
216
179
|
export const orderbyBuilder = (sortInfo, customSort) => {
|
|
217
180
|
var _a, _b;
|
|
218
181
|
if (!sortInfo) {
|
|
@@ -227,10 +190,7 @@ export const orderbyBuilder = (sortInfo, customSort) => {
|
|
|
227
190
|
// The refScheme will reference the property path, e.g., owns_items[0].uuid.
|
|
228
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);
|
|
229
192
|
if (typeof customOrderByKey === 'string') {
|
|
230
|
-
return [
|
|
231
|
-
keyToOrderByStructure(customOrderByKey, direction),
|
|
232
|
-
{ id: direction },
|
|
233
|
-
];
|
|
193
|
+
return [`${customOrderByKey} ${direction}`, `id ${direction}`];
|
|
234
194
|
}
|
|
235
195
|
if (Array.isArray(customOrderByKey)) {
|
|
236
196
|
if (customOrderByKey.length === 0 ||
|
|
@@ -238,8 +198,8 @@ export const orderbyBuilder = (sortInfo, customSort) => {
|
|
|
238
198
|
throw new Error(`Field ${field} error: custom sort for this field must be of type string or a non empty string array, ${customOrderByKey.join(',')} is not accepted.`);
|
|
239
199
|
}
|
|
240
200
|
return [
|
|
241
|
-
...customOrderByKey.map((k) =>
|
|
242
|
-
|
|
201
|
+
...customOrderByKey.map((k) => `${k} ${direction}`),
|
|
202
|
+
`id ${direction}`,
|
|
243
203
|
];
|
|
244
204
|
}
|
|
245
205
|
if (customOrderByKey != null && typeof customOrderByKey !== 'string') {
|
|
@@ -249,5 +209,5 @@ export const orderbyBuilder = (sortInfo, customSort) => {
|
|
|
249
209
|
if (refScheme) {
|
|
250
210
|
fieldPath += `/${refScheme.replace(/\[(.*?)\]/g, '').replace(/\./g, '/')}`;
|
|
251
211
|
}
|
|
252
|
-
return [
|
|
212
|
+
return [`${fieldPath} ${direction}`, `id ${direction}`];
|
|
253
213
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@balena/ui-shared-components",
|
|
3
|
-
"version": "14.0.1-build-
|
|
3
|
+
"version": "14.0.1-build-update-analytics-client-93050948203c972f1a079d1ea74a91826a24bb3f-1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"files": [
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"ajv": "^8.17.1",
|
|
32
32
|
"ajv-formats": "^3.0.1",
|
|
33
33
|
"ajv-keywords": "^5.1.0",
|
|
34
|
-
"analytics-client": "^3.1.
|
|
34
|
+
"analytics-client": "^3.1.2-build-update-engagement-plugin-4d8a6120e5420cff2121c0936d63ce17f3f7a215-1",
|
|
35
35
|
"color": "^5.0.0",
|
|
36
36
|
"color-hash": "^2.0.2",
|
|
37
37
|
"date-fns": "^4.1.0",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
},
|
|
133
133
|
"homepage": "https://github.com/balena-io/ui-shared-components#readme",
|
|
134
134
|
"versionist": {
|
|
135
|
-
"publishedAt": "2025-09-
|
|
135
|
+
"publishedAt": "2025-09-03T16:43:39.496Z"
|
|
136
136
|
},
|
|
137
137
|
"overrides": {
|
|
138
138
|
"storybook": "$storybook"
|