twico-ui 1.20.1 → 1.20.2
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/CHANGELOG.md +7 -0
- package/dist/index.cjs +33 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +33 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -8626,6 +8626,37 @@ var filterTypeOf = (col) => {
|
|
|
8626
8626
|
if (ft === "number" || ft === "string") return ft;
|
|
8627
8627
|
return col && col.type === "number" ? "number" : "string";
|
|
8628
8628
|
};
|
|
8629
|
+
function mergeColOrder(saved, propFields) {
|
|
8630
|
+
const known = new Set(propFields);
|
|
8631
|
+
const result = saved.filter((f) => known.has(f));
|
|
8632
|
+
const placed = new Set(result);
|
|
8633
|
+
for (let i = 0; i < propFields.length; i++) {
|
|
8634
|
+
const f = propFields[i];
|
|
8635
|
+
if (!f || placed.has(f)) continue;
|
|
8636
|
+
let at = 0;
|
|
8637
|
+
for (let j = i - 1; j >= 0; j--) {
|
|
8638
|
+
const idx = result.indexOf(propFields[j]);
|
|
8639
|
+
if (idx !== -1) {
|
|
8640
|
+
at = idx + 1;
|
|
8641
|
+
break;
|
|
8642
|
+
}
|
|
8643
|
+
}
|
|
8644
|
+
if (at === 0) {
|
|
8645
|
+
let before = result.length;
|
|
8646
|
+
for (let j = i + 1; j < propFields.length; j++) {
|
|
8647
|
+
const idx = result.indexOf(propFields[j]);
|
|
8648
|
+
if (idx !== -1) {
|
|
8649
|
+
before = idx;
|
|
8650
|
+
break;
|
|
8651
|
+
}
|
|
8652
|
+
}
|
|
8653
|
+
at = before;
|
|
8654
|
+
}
|
|
8655
|
+
result.splice(at, 0, f);
|
|
8656
|
+
placed.add(f);
|
|
8657
|
+
}
|
|
8658
|
+
return result;
|
|
8659
|
+
}
|
|
8629
8660
|
var getColVal = (col, row) => col && col.valueGetter ? col.valueGetter(row) : row == null ? void 0 : row[col && col.field];
|
|
8630
8661
|
var diffValueNode = (col, v, row) => col.renderCell ? col.renderCell(v, row) : col.valueFormatter ? col.valueFormatter(v, row) : v == null ? "" : v;
|
|
8631
8662
|
function renderDiffCell(col, val, row) {
|
|
@@ -9201,9 +9232,7 @@ function Datatable({
|
|
|
9201
9232
|
if (typeof s.page === "number" && !pageControlled) setInternalPage(Math.max(0, Math.floor(s.page)));
|
|
9202
9233
|
if (typeof s.pageSize === "number" && !pageSizeControlled) setInternalRpp(s.pageSize > 0 ? s.pageSize : 10);
|
|
9203
9234
|
if (Array.isArray(s.columnOrder)) {
|
|
9204
|
-
|
|
9205
|
-
const missing = cols.map((c) => c.field).filter((f) => f && !savedOrder.includes(f));
|
|
9206
|
-
setOrder([...savedOrder, ...missing]);
|
|
9235
|
+
setOrder(mergeColOrder(s.columnOrder, cols.map((c) => c.field).filter(Boolean)));
|
|
9207
9236
|
}
|
|
9208
9237
|
if (s.columnWidths && typeof s.columnWidths === "object") setWidths(Object.fromEntries(Object.entries(s.columnWidths).filter(([f, w]) => known.has(f) && typeof w === "number")));
|
|
9209
9238
|
if (s.columnVisibility && typeof s.columnVisibility === "object") setHidden(new Set(Object.keys(s.columnVisibility).filter((f) => known.has(f) && s.columnVisibility[f] === false)));
|
|
@@ -9315,12 +9344,7 @@ function Datatable({
|
|
|
9315
9344
|
}));
|
|
9316
9345
|
const pivotActive = pivotOn && pivotConfig.rows.length > 0 && pivotConfig.values.length > 0;
|
|
9317
9346
|
React51__default.useEffect(() => {
|
|
9318
|
-
setOrder((prev) =>
|
|
9319
|
-
const fields = columns.map((c) => c.field);
|
|
9320
|
-
const kept = prev.filter((f) => fields.includes(f));
|
|
9321
|
-
const added = fields.filter((f) => !kept.includes(f));
|
|
9322
|
-
return [...kept, ...added];
|
|
9323
|
-
});
|
|
9347
|
+
setOrder((prev) => mergeColOrder(prev, columns.map((c) => c.field).filter(Boolean)));
|
|
9324
9348
|
}, [columns]);
|
|
9325
9349
|
const densitySyncedRef = React51__default.useRef(false);
|
|
9326
9350
|
React51__default.useEffect(() => {
|