twico-ui 1.20.0 → 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 +14 -0
- package/dist/index.cjs +49 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +49 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.cts
CHANGED
|
@@ -2094,7 +2094,9 @@ interface DatatableColumn<T = any> {
|
|
|
2094
2094
|
* Providing it makes the column editable (unless `editable: false`) and takes precedence over the
|
|
2095
2095
|
* built-in select/text editor. Call `commit(nextValue)` to save (fires `onRowUpdate`/`onRowsChange`)
|
|
2096
2096
|
* or `cancel()` to discard. Twico overlay dropdowns (portaled as `.twc-pop`) are exempt from the
|
|
2097
|
-
* cell's outside-click auto-cancel, so a Combobox popover works inside the cell.
|
|
2097
|
+
* cell's outside-click auto-cancel, so a Combobox popover works inside the cell. **Escape cancels**
|
|
2098
|
+
* the edit automatically (the wrapper calls `cancel()`), so you needn't wire a keydown — stop
|
|
2099
|
+
* propagation on Escape only if your control needs it (e.g. to close its own open dropdown). */
|
|
2098
2100
|
renderEditCell?: (args: { value: any; row: T; field: string; commit: (nextValue: any) => void; cancel: () => void }) => React.ReactNode;
|
|
2099
2101
|
/** Custom control for this column's clause in the **batch** editor (#247) — the counterpart of
|
|
2100
2102
|
* `renderEditCell` for the "Edit N selected rows" popover. Use it when the value is backed by a large,
|
package/dist/index.d.ts
CHANGED
|
@@ -2094,7 +2094,9 @@ interface DatatableColumn<T = any> {
|
|
|
2094
2094
|
* Providing it makes the column editable (unless `editable: false`) and takes precedence over the
|
|
2095
2095
|
* built-in select/text editor. Call `commit(nextValue)` to save (fires `onRowUpdate`/`onRowsChange`)
|
|
2096
2096
|
* or `cancel()` to discard. Twico overlay dropdowns (portaled as `.twc-pop`) are exempt from the
|
|
2097
|
-
* cell's outside-click auto-cancel, so a Combobox popover works inside the cell.
|
|
2097
|
+
* cell's outside-click auto-cancel, so a Combobox popover works inside the cell. **Escape cancels**
|
|
2098
|
+
* the edit automatically (the wrapper calls `cancel()`), so you needn't wire a keydown — stop
|
|
2099
|
+
* propagation on Escape only if your control needs it (e.g. to close its own open dropdown). */
|
|
2098
2100
|
renderEditCell?: (args: { value: any; row: T; field: string; commit: (nextValue: any) => void; cancel: () => void }) => React.ReactNode;
|
|
2099
2101
|
/** Custom control for this column's clause in the **batch** editor (#247) — the counterpart of
|
|
2100
2102
|
* `renderEditCell` for the "Edit N selected rows" popover. Use it when the value is backed by a large,
|
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(() => {
|
|
@@ -10477,7 +10501,22 @@ function Datatable({
|
|
|
10477
10501
|
// async Combobox, …) and drives the lifecycle via commit/cancel. Wrapped in
|
|
10478
10502
|
// .twc-dt__editor-wrap so inline clicks (and any .twc-pop portal dropdown) don't
|
|
10479
10503
|
// trip the outside-click auto-cancel.
|
|
10480
|
-
|
|
10504
|
+
// #273: the wrapper handles Escape → cancel so it works for every custom editor without
|
|
10505
|
+
// each having to wire a keydown (they only get commit/cancel). A custom control that
|
|
10506
|
+
// wants Escape itself (e.g. to close its own open dropdown) stops propagation first.
|
|
10507
|
+
/* @__PURE__ */ jsx(
|
|
10508
|
+
"div",
|
|
10509
|
+
{
|
|
10510
|
+
className: "twc-dt__editor-wrap",
|
|
10511
|
+
onKeyDown: (e) => {
|
|
10512
|
+
if (e.key === "Escape") {
|
|
10513
|
+
e.stopPropagation();
|
|
10514
|
+
cancelEdit();
|
|
10515
|
+
}
|
|
10516
|
+
},
|
|
10517
|
+
children: c.renderEditCell({ value: editing.value, row, field: c.field, commit: (v) => commitEdit(v), cancel: cancelEdit })
|
|
10518
|
+
}
|
|
10519
|
+
)
|
|
10481
10520
|
) : /* @__PURE__ */ jsx(
|
|
10482
10521
|
EditCell,
|
|
10483
10522
|
{
|