twico-ui 1.28.0 → 1.29.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,13 @@
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.29.0](https://github.com/EncryptionL/twico-ui/compare/v1.28.0...v1.29.0) (2026-08-03)
6
+
7
+
8
+ ### Features
9
+
10
+ * **datatable:** controlled active row for selectionMode="row" (activeRowId) ([#324](https://github.com/EncryptionL/twico-ui/issues/324)) ([c118a06](https://github.com/EncryptionL/twico-ui/commit/c118a069d3f91ce9640b39751cab24717569be2b))
11
+
5
12
  # [1.28.0](https://github.com/EncryptionL/twico-ui/compare/v1.27.0...v1.28.0) (2026-08-03)
6
13
 
7
14
 
package/dist/index.cjs CHANGED
@@ -9183,6 +9183,8 @@ function Datatable({
9183
9183
  onCellClick,
9184
9184
  onActiveCellChange,
9185
9185
  onCellSelectionChange,
9186
+ activeRowId,
9187
+ scrollActiveRowIntoView = true,
9186
9188
  enableClipboard = false,
9187
9189
  onCellsCopy,
9188
9190
  onCellsPaste,
@@ -9315,6 +9317,8 @@ function Datatable({
9315
9317
  };
9316
9318
  const [selected, setSelected] = React51__namespace.default.useState(() => /* @__PURE__ */ new Set());
9317
9319
  const [activeRow, setActiveRow] = React51__namespace.default.useState(null);
9320
+ const activeRowControlled = activeRowId !== void 0;
9321
+ const activeRowVal = activeRowControlled ? activeRowId : activeRow;
9318
9322
  const [activeCell, setActiveCell] = React51__namespace.default.useState(null);
9319
9323
  const [anchorCell, setAnchorCell] = React51__namespace.default.useState(null);
9320
9324
  const gridId = React51__namespace.default.useId();
@@ -10302,7 +10306,7 @@ function Datatable({
10302
10306
  if (selectionMode === "none") return;
10303
10307
  if (e.target.closest("button, a, input, select, .twc-dt__check, .twc-dt__editor-wrap")) return;
10304
10308
  if (selectionMode === "row") {
10305
- setActiveRow(k);
10309
+ if (!activeRowControlled) setActiveRow(k);
10306
10310
  onRowClick?.(row, k);
10307
10311
  onActiveCellChange?.(null);
10308
10312
  }
@@ -10381,8 +10385,9 @@ function Datatable({
10381
10385
  }
10382
10386
  if (selectionMode === "row") {
10383
10387
  e.preventDefault();
10384
- setActiveRow(keyOf(leafRows[r2], r2));
10385
- onRowClick?.(leafRows[r2], keyOf(leafRows[r2], r2));
10388
+ const rk = keyOf(leafRows[r2], r2);
10389
+ if (!activeRowControlled) setActiveRow(rk);
10390
+ onRowClick?.(leafRows[r2], rk);
10386
10391
  return;
10387
10392
  }
10388
10393
  handled = false;
@@ -10423,6 +10428,11 @@ function Datatable({
10423
10428
  prevRowSelSigRef.current = sig;
10424
10429
  cb(selKeys, selectedRows);
10425
10430
  }, [selKeys, selectedRows]);
10431
+ React51__namespace.default.useEffect(() => {
10432
+ if (!activeRowControlled || !scrollActiveRowIntoView || activeRowId == null) return;
10433
+ const el = gridRef.current && gridRef.current.querySelector('.twc-dt__row[data-active="true"]');
10434
+ if (el && el.scrollIntoView) el.scrollIntoView({ block: "nearest" });
10435
+ }, [activeRowId, activeRowControlled, scrollActiveRowIntoView]);
10426
10436
  function clearSelection() {
10427
10437
  setSelected(/* @__PURE__ */ new Set());
10428
10438
  }
@@ -11140,7 +11150,7 @@ function Datatable({
11140
11150
  function renderLeaf(row, ri, pinSide, midIdx) {
11141
11151
  const k = keyOf(row, ri);
11142
11152
  const sel = selected.has(k);
11143
- const rowActive = selectionMode === "row" && activeRow === k;
11153
+ const rowActive = selectionMode === "row" && activeRowVal === k;
11144
11154
  const stickyStyle = pinSide === "top" ? { position: "sticky", top: headH, zIndex: 5 } : pinSide === "bottom" ? { position: "sticky", bottom: 0, zIndex: 5 } : void 0;
11145
11155
  const h = rowHeights[k];
11146
11156
  const rowStyle = { ...stickyStyle || {}, ...h ? { height: h } : {} };