@teselagen/ui 0.8.6-beta.13 → 0.8.6-beta.14
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
CHANGED
|
@@ -22243,8 +22243,12 @@ function applyOrderBy(records, _order_by) {
|
|
|
22243
22243
|
const direction = item[field];
|
|
22244
22244
|
if (direction === "desc") {
|
|
22245
22245
|
sortedRecords = [
|
|
22246
|
-
...sortedRecords.filter(
|
|
22247
|
-
|
|
22246
|
+
...sortedRecords.filter(
|
|
22247
|
+
(record) => !isNull(record[field]) && record[field] !== void 0
|
|
22248
|
+
),
|
|
22249
|
+
...sortedRecords.filter(
|
|
22250
|
+
(record) => isNull(record[field]) || record[field] === void 0
|
|
22251
|
+
)
|
|
22248
22252
|
];
|
|
22249
22253
|
}
|
|
22250
22254
|
});
|
|
@@ -61177,7 +61181,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
61177
61181
|
try {
|
|
61178
61182
|
const allEntities = yield safeQuery(fragment, {
|
|
61179
61183
|
variables: {
|
|
61180
|
-
|
|
61184
|
+
where: variables.where,
|
|
61181
61185
|
sort: variables.sort
|
|
61182
61186
|
},
|
|
61183
61187
|
canCancel: true
|
package/index.es.js
CHANGED
|
@@ -22225,8 +22225,12 @@ function applyOrderBy(records, _order_by) {
|
|
|
22225
22225
|
const direction = item[field];
|
|
22226
22226
|
if (direction === "desc") {
|
|
22227
22227
|
sortedRecords = [
|
|
22228
|
-
...sortedRecords.filter(
|
|
22229
|
-
|
|
22228
|
+
...sortedRecords.filter(
|
|
22229
|
+
(record) => !isNull(record[field]) && record[field] !== void 0
|
|
22230
|
+
),
|
|
22231
|
+
...sortedRecords.filter(
|
|
22232
|
+
(record) => isNull(record[field]) || record[field] === void 0
|
|
22233
|
+
)
|
|
22230
22234
|
];
|
|
22231
22235
|
}
|
|
22232
22236
|
});
|
|
@@ -61159,7 +61163,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
61159
61163
|
try {
|
|
61160
61164
|
const allEntities = yield safeQuery(fragment, {
|
|
61161
61165
|
variables: {
|
|
61162
|
-
|
|
61166
|
+
where: variables.where,
|
|
61163
61167
|
sort: variables.sort
|
|
61164
61168
|
},
|
|
61165
61169
|
canCancel: true
|
package/package.json
CHANGED
package/src/DataTable/index.js
CHANGED
|
@@ -230,8 +230,6 @@ function applyWhereClause(records, where) {
|
|
|
230
230
|
// order_by looks like this: [{ some_field: "asc" }, { some_other_field: "desc" }] or {some_field: "asc"}
|
|
231
231
|
// returns the records sorted by the order_by clause
|
|
232
232
|
function applyOrderBy(records, _order_by) {
|
|
233
|
-
// console.log('records start:', records)
|
|
234
|
-
// console.log('_order_by:', _order_by)
|
|
235
233
|
const order_by = isArray(_order_by)
|
|
236
234
|
? _order_by
|
|
237
235
|
: isEmpty(_order_by)
|
|
@@ -255,7 +253,7 @@ function applyOrderBy(records, _order_by) {
|
|
|
255
253
|
const value = record[field];
|
|
256
254
|
// Handle null values based on sort direction
|
|
257
255
|
if (isNull(value) || value === undefined) {
|
|
258
|
-
return direction ===
|
|
256
|
+
return direction === "asc" ? -Infinity : -Infinity;
|
|
259
257
|
}
|
|
260
258
|
// Use natural sorting only for strings that contain numbers
|
|
261
259
|
if (isString(value) && /\d/.test(value)) {
|
|
@@ -266,25 +264,29 @@ function applyOrderBy(records, _order_by) {
|
|
|
266
264
|
return value;
|
|
267
265
|
});
|
|
268
266
|
});
|
|
269
|
-
|
|
267
|
+
|
|
270
268
|
// First sort normally
|
|
271
269
|
let sortedRecords = orderBy(records, iteratees, directions);
|
|
272
|
-
|
|
270
|
+
|
|
273
271
|
// Then ensure entries with a value for the field come before entries without a value
|
|
274
272
|
// for any field sorted in descending order
|
|
275
|
-
order_by.forEach(
|
|
273
|
+
order_by.forEach(item => {
|
|
276
274
|
const field = Object.keys(item)[0];
|
|
277
275
|
const direction = item[field];
|
|
278
|
-
|
|
279
|
-
if (direction ===
|
|
276
|
+
|
|
277
|
+
if (direction === "desc") {
|
|
280
278
|
// For descending sorts, we want entries with values to appear before entries without values
|
|
281
279
|
sortedRecords = [
|
|
282
|
-
...sortedRecords.filter(
|
|
283
|
-
|
|
280
|
+
...sortedRecords.filter(
|
|
281
|
+
record => !isNull(record[field]) && record[field] !== undefined
|
|
282
|
+
),
|
|
283
|
+
...sortedRecords.filter(
|
|
284
|
+
record => isNull(record[field]) || record[field] === undefined
|
|
285
|
+
)
|
|
284
286
|
];
|
|
285
287
|
}
|
|
286
288
|
});
|
|
287
|
-
|
|
289
|
+
|
|
288
290
|
records = sortedRecords;
|
|
289
291
|
}
|
|
290
292
|
return records;
|