@teselagen/ui 0.8.6-beta.6 → 0.8.6-beta.8
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/index.cjs.js +10 -4
- package/index.es.js +10 -4
- package/package.json +3 -2
- package/src/DataTable/utils/filterLocalEntitiesToHasura.js +17 -1
- package/src/DataTable/utils/filterLocalEntitiesToHasura.test.js +22 -4
- package/src/DataTable/utils/queryParams.js +1 -1
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +1 -1
package/index.cjs.js
CHANGED
|
@@ -19492,7 +19492,7 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19492
19492
|
case "contains":
|
|
19493
19493
|
return { [filterOn]: { _ilike: `%${filterValue}%` } };
|
|
19494
19494
|
case "notContains":
|
|
19495
|
-
return { [filterOn]: {
|
|
19495
|
+
return { [filterOn]: { _nilike: `%${filterValue}%` } };
|
|
19496
19496
|
case "isExactly":
|
|
19497
19497
|
return { [filterOn]: { _eq: filterValue } };
|
|
19498
19498
|
case "isEmpty":
|
|
@@ -22209,15 +22209,21 @@ __name(applyWhereClause, "applyWhereClause");
|
|
|
22209
22209
|
function applyOrderBy(records, _order_by) {
|
|
22210
22210
|
const order_by = isArray$2(_order_by) ? _order_by : isEmpty$1(_order_by) ? [] : [_order_by];
|
|
22211
22211
|
if (order_by.length > 0) {
|
|
22212
|
-
const fields = [];
|
|
22213
22212
|
const directions = [];
|
|
22213
|
+
const iteratees = [];
|
|
22214
22214
|
order_by.forEach((item) => {
|
|
22215
22215
|
const field = Object.keys(item)[0];
|
|
22216
22216
|
const direction = item[field];
|
|
22217
|
-
fields.push(field);
|
|
22218
22217
|
directions.push(direction);
|
|
22218
|
+
iteratees.push((record) => {
|
|
22219
|
+
const value = record[field];
|
|
22220
|
+
if (isString$1(value) && /\d/.test(value)) {
|
|
22221
|
+
return value.replace(/(\d+)/g, (num) => num.padStart(10, "0"));
|
|
22222
|
+
}
|
|
22223
|
+
return value;
|
|
22224
|
+
});
|
|
22219
22225
|
});
|
|
22220
|
-
records = orderBy$1(records,
|
|
22226
|
+
records = orderBy$1(records, iteratees, directions);
|
|
22221
22227
|
}
|
|
22222
22228
|
return records;
|
|
22223
22229
|
}
|
package/index.es.js
CHANGED
|
@@ -19474,7 +19474,7 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19474
19474
|
case "contains":
|
|
19475
19475
|
return { [filterOn]: { _ilike: `%${filterValue}%` } };
|
|
19476
19476
|
case "notContains":
|
|
19477
|
-
return { [filterOn]: {
|
|
19477
|
+
return { [filterOn]: { _nilike: `%${filterValue}%` } };
|
|
19478
19478
|
case "isExactly":
|
|
19479
19479
|
return { [filterOn]: { _eq: filterValue } };
|
|
19480
19480
|
case "isEmpty":
|
|
@@ -22191,15 +22191,21 @@ __name(applyWhereClause, "applyWhereClause");
|
|
|
22191
22191
|
function applyOrderBy(records, _order_by) {
|
|
22192
22192
|
const order_by = isArray$2(_order_by) ? _order_by : isEmpty$1(_order_by) ? [] : [_order_by];
|
|
22193
22193
|
if (order_by.length > 0) {
|
|
22194
|
-
const fields = [];
|
|
22195
22194
|
const directions = [];
|
|
22195
|
+
const iteratees = [];
|
|
22196
22196
|
order_by.forEach((item) => {
|
|
22197
22197
|
const field = Object.keys(item)[0];
|
|
22198
22198
|
const direction = item[field];
|
|
22199
|
-
fields.push(field);
|
|
22200
22199
|
directions.push(direction);
|
|
22200
|
+
iteratees.push((record) => {
|
|
22201
|
+
const value = record[field];
|
|
22202
|
+
if (isString$1(value) && /\d/.test(value)) {
|
|
22203
|
+
return value.replace(/(\d+)/g, (num) => num.padStart(10, "0"));
|
|
22204
|
+
}
|
|
22205
|
+
return value;
|
|
22206
|
+
});
|
|
22201
22207
|
});
|
|
22202
|
-
records = orderBy$1(records,
|
|
22208
|
+
records = orderBy$1(records, iteratees, directions);
|
|
22203
22209
|
}
|
|
22204
22210
|
return records;
|
|
22205
22211
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teselagen/ui",
|
|
3
|
-
"version": "0.8.6-beta.
|
|
3
|
+
"version": "0.8.6-beta.8",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
"chance": "^1.1.11",
|
|
56
56
|
"@dnd-kit/utilities": "3.2.2",
|
|
57
57
|
"@teselagen/file-utils": "0.3.20",
|
|
58
|
-
"@blueprintjs/icons": "3.33.0"
|
|
58
|
+
"@blueprintjs/icons": "3.33.0",
|
|
59
|
+
"jszip": "3.10.1"
|
|
59
60
|
},
|
|
60
61
|
"license": "MIT"
|
|
61
62
|
}
|
|
@@ -239,14 +239,30 @@ function applyOrderBy(records, _order_by) {
|
|
|
239
239
|
if (order_by.length > 0) {
|
|
240
240
|
const fields = [];
|
|
241
241
|
const directions = [];
|
|
242
|
+
const iteratees = [];
|
|
243
|
+
|
|
242
244
|
order_by.forEach(item => {
|
|
243
245
|
// Hasura-style: { field: "asc" }
|
|
244
246
|
const field = Object.keys(item)[0];
|
|
245
247
|
const direction = item[field];
|
|
246
248
|
fields.push(field);
|
|
247
249
|
directions.push(direction);
|
|
250
|
+
|
|
251
|
+
// Create a custom iteratee function for natural sorting
|
|
252
|
+
iteratees.push(record => {
|
|
253
|
+
const value = record[field];
|
|
254
|
+
// Use natural sorting only for strings that contain numbers
|
|
255
|
+
if (isString(value) && /\d/.test(value)) {
|
|
256
|
+
// Return the value in a format that can be naturally sorted
|
|
257
|
+
// This effectively creates a sort key that respects natural ordering
|
|
258
|
+
return value.replace(/(\d+)/g, num => num.padStart(10, '0'));
|
|
259
|
+
}
|
|
260
|
+
return value;
|
|
261
|
+
});
|
|
248
262
|
});
|
|
249
|
-
|
|
263
|
+
|
|
264
|
+
// Use the custom iteratees for natural sorting
|
|
265
|
+
records = orderBy(records, iteratees, directions);
|
|
250
266
|
}
|
|
251
267
|
return records;
|
|
252
268
|
}
|
|
@@ -536,13 +536,31 @@ describe("filterLocalEntitiesToHasura", () => {
|
|
|
536
536
|
expect(result.entitiesAcrossPages).toEqual([records[0], records[2]]);
|
|
537
537
|
expect(result.entityCount).toBe(2);
|
|
538
538
|
});
|
|
539
|
+
it("should order order well names properly, aka names a1, a11, a2, a3 should be sorted a1, a2, a3, a11", () => {
|
|
540
|
+
const recordsWithNames = [
|
|
541
|
+
{ id: 1, name: "a1" },
|
|
542
|
+
{ id: 2, name: "a11" },
|
|
543
|
+
{ id: 3, name: "a2" },
|
|
544
|
+
{ id: 4, name: "a3" }
|
|
545
|
+
];
|
|
546
|
+
const result = filterLocalEntitiesToHasura(recordsWithNames, {
|
|
547
|
+
order_by: { name: "asc" }
|
|
548
|
+
});
|
|
549
|
+
expect(result.entities).toEqual([
|
|
550
|
+
recordsWithNames[0], // a1
|
|
551
|
+
recordsWithNames[2], // a2
|
|
552
|
+
recordsWithNames[3], // a3
|
|
553
|
+
recordsWithNames[1] // a11
|
|
554
|
+
]);
|
|
555
|
+
expect(result.entityCount).toBe(4);
|
|
556
|
+
});
|
|
539
557
|
it("should order by multiple fields (age asc, name desc)", () => {
|
|
540
558
|
// Make two of the ages the same for testing secondary sort
|
|
541
559
|
const modifiedRecords = [
|
|
542
|
-
records[1],
|
|
560
|
+
records[1], // Jane Smith, age 25
|
|
543
561
|
{ ...records[0], age: 25 }, // John Doe, age 25
|
|
544
|
-
records[2],
|
|
545
|
-
records[3]
|
|
562
|
+
records[2], // Alice Johnson, age 35
|
|
563
|
+
records[3] // Bob Williams, age 20
|
|
546
564
|
];
|
|
547
565
|
const result = filterLocalEntitiesToHasura(modifiedRecords, {
|
|
548
566
|
order_by: [{ age: "asc" }, { name: "desc" }]
|
|
@@ -551,7 +569,7 @@ describe("filterLocalEntitiesToHasura", () => {
|
|
|
551
569
|
modifiedRecords[3], // age 20, name "Bob Williams"
|
|
552
570
|
modifiedRecords[1], // age 25, name "John Doe" (name desc)
|
|
553
571
|
modifiedRecords[0], // age 25, name "Jane Smith"
|
|
554
|
-
modifiedRecords[2]
|
|
572
|
+
modifiedRecords[2] // age 35, name "Alice Johnson"
|
|
555
573
|
]);
|
|
556
574
|
expect(result.entityCount).toBe(4);
|
|
557
575
|
});
|
|
@@ -108,7 +108,7 @@ export function tableQueryParamsToHasuraClauses({
|
|
|
108
108
|
case "contains":
|
|
109
109
|
return { [filterOn]: { _ilike: `%${filterValue}%` } };
|
|
110
110
|
case "notContains":
|
|
111
|
-
return { [filterOn]: {
|
|
111
|
+
return { [filterOn]: { _nilike: `%${filterValue}%` } };
|
|
112
112
|
case "isExactly":
|
|
113
113
|
return { [filterOn]: { _eq: filterValue } };
|
|
114
114
|
case "isEmpty":
|