twico-ui 1.20.1 → 1.21.0

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 CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to Twico UI are documented here (newest first). This file is generated automatically on each release by [semantic-release](https://semantic-release.gitbook.io/) from [Conventional Commits](https://www.conventionalcommits.org/) — do not edit it by hand. The same notes appear on each [GitHub Release](https://github.com/EncryptionL/twico-ui/releases).
4
4
 
5
+ # [1.21.0](https://github.com/EncryptionL/twico-ui/compare/v1.20.2...v1.21.0) (2026-07-28)
6
+
7
+
8
+ ### Features
9
+
10
+ * **datatable:** add toolbarActions slot for custom toolbar controls ([c1c3142](https://github.com/EncryptionL/twico-ui/commit/c1c3142787cb2a21811b16d6774f0e1f2c6045b9)), closes [#286](https://github.com/EncryptionL/twico-ui/issues/286)
11
+
12
+ ## [1.20.2](https://github.com/EncryptionL/twico-ui/compare/v1.20.1...v1.20.2) (2026-07-24)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **datatable:** restore persisted column order with new columns at their code position ([c1095eb](https://github.com/EncryptionL/twico-ui/commit/c1095eb238239914491ea004a3c297d33c98d69b)), closes [#259](https://github.com/EncryptionL/twico-ui/issues/259) [#284](https://github.com/EncryptionL/twico-ui/issues/284)
18
+
5
19
  ## [1.20.1](https://github.com/EncryptionL/twico-ui/compare/v1.20.0...v1.20.1) (2026-07-23)
6
20
 
7
21
 
package/dist/index.cjs CHANGED
@@ -8128,6 +8128,8 @@ var DT_CSS = `
8128
8128
  /* Toolbar */
8129
8129
  .twc-dt__toolbar { position: relative; z-index: 10; display: flex; align-items: center; gap: 6px; padding: 8px 10px;
8130
8130
  border-bottom: var(--border-thin) solid var(--color-divider); flex-wrap: wrap; }
8131
+ /* #286: host-supplied leading toolbar slot \u2014 a flex cluster so multiple buttons align with the built-ins. */
8132
+ .twc-dt__toolbar-actions { display: inline-flex; align-items: center; gap: 6px; }
8131
8133
  /* z-index above the scroll area's sticky header (z:3) so a toolbar button's
8132
8134
  hover tooltip (a ::after that hangs below the bar) paints over the table
8133
8135
  instead of being covered by the header/first rows. */
@@ -8647,6 +8649,37 @@ var filterTypeOf = (col) => {
8647
8649
  if (ft === "number" || ft === "string") return ft;
8648
8650
  return col && col.type === "number" ? "number" : "string";
8649
8651
  };
8652
+ function mergeColOrder(saved, propFields) {
8653
+ const known = new Set(propFields);
8654
+ const result = saved.filter((f) => known.has(f));
8655
+ const placed = new Set(result);
8656
+ for (let i = 0; i < propFields.length; i++) {
8657
+ const f = propFields[i];
8658
+ if (!f || placed.has(f)) continue;
8659
+ let at = 0;
8660
+ for (let j = i - 1; j >= 0; j--) {
8661
+ const idx = result.indexOf(propFields[j]);
8662
+ if (idx !== -1) {
8663
+ at = idx + 1;
8664
+ break;
8665
+ }
8666
+ }
8667
+ if (at === 0) {
8668
+ let before = result.length;
8669
+ for (let j = i + 1; j < propFields.length; j++) {
8670
+ const idx = result.indexOf(propFields[j]);
8671
+ if (idx !== -1) {
8672
+ before = idx;
8673
+ break;
8674
+ }
8675
+ }
8676
+ at = before;
8677
+ }
8678
+ result.splice(at, 0, f);
8679
+ placed.add(f);
8680
+ }
8681
+ return result;
8682
+ }
8650
8683
  var getColVal = (col, row) => col && col.valueGetter ? col.valueGetter(row) : row == null ? void 0 : row[col && col.field];
8651
8684
  var diffValueNode = (col, v, row) => col.renderCell ? col.renderCell(v, row) : col.valueFormatter ? col.valueFormatter(v, row) : v == null ? "" : v;
8652
8685
  function renderDiffCell(col, val, row) {
@@ -9051,6 +9084,7 @@ function Datatable({
9051
9084
  searchable = true,
9052
9085
  quickFilter,
9053
9086
  onQuickFilterChange,
9087
+ toolbarActions,
9054
9088
  rowPinning = false,
9055
9089
  rowReorder = false,
9056
9090
  rowResize = false,
@@ -9222,9 +9256,7 @@ function Datatable({
9222
9256
  if (typeof s.page === "number" && !pageControlled) setInternalPage(Math.max(0, Math.floor(s.page)));
9223
9257
  if (typeof s.pageSize === "number" && !pageSizeControlled) setInternalRpp(s.pageSize > 0 ? s.pageSize : 10);
9224
9258
  if (Array.isArray(s.columnOrder)) {
9225
- const savedOrder = s.columnOrder.filter((f) => known.has(f));
9226
- const missing = cols.map((c) => c.field).filter((f) => f && !savedOrder.includes(f));
9227
- setOrder([...savedOrder, ...missing]);
9259
+ setOrder(mergeColOrder(s.columnOrder, cols.map((c) => c.field).filter(Boolean)));
9228
9260
  }
9229
9261
  if (s.columnWidths && typeof s.columnWidths === "object") setWidths(Object.fromEntries(Object.entries(s.columnWidths).filter(([f, w]) => known.has(f) && typeof w === "number")));
9230
9262
  if (s.columnVisibility && typeof s.columnVisibility === "object") setHidden(new Set(Object.keys(s.columnVisibility).filter((f) => known.has(f) && s.columnVisibility[f] === false)));
@@ -9336,12 +9368,7 @@ function Datatable({
9336
9368
  }));
9337
9369
  const pivotActive = pivotOn && pivotConfig.rows.length > 0 && pivotConfig.values.length > 0;
9338
9370
  React51__namespace.default.useEffect(() => {
9339
- setOrder((prev) => {
9340
- const fields = columns.map((c) => c.field);
9341
- const kept = prev.filter((f) => fields.includes(f));
9342
- const added = fields.filter((f) => !kept.includes(f));
9343
- return [...kept, ...added];
9344
- });
9371
+ setOrder((prev) => mergeColOrder(prev, columns.map((c) => c.field).filter(Boolean)));
9345
9372
  }, [columns]);
9346
9373
  const densitySyncedRef = React51__namespace.default.useRef(false);
9347
9374
  React51__namespace.default.useEffect(() => {
@@ -10640,6 +10667,7 @@ function Datatable({
10640
10667
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `twc-dt ${className}`, ref: rootRef, "data-density": density, "data-resizing": resizing || void 0, ...rest, children: [
10641
10668
  __twcStyles,
10642
10669
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-dt__toolbar", "data-compact": compact || void 0, children: [
10670
+ toolbarActions != null ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twc-dt__toolbar-actions", children: toolbarActions }) : null,
10643
10671
  (batchActions.length || hasBatchEditor) && selected.size > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "twc-dt__batch", children: [
10644
10672
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "twc-dt__batch-x", onClick: clearSelection, "aria-label": "Clear selection", children: /* @__PURE__ */ jsxRuntime.jsx(Svg, { d: I.x }) }),
10645
10673
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "twc-dt__batch-count", children: [