trotl-table 1.0.49 → 1.0.51

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/README.md CHANGED
@@ -122,6 +122,7 @@ export default function Demo() {
122
122
  - `showKey`: show row key (true/false)
123
123
  - `enableDragRow`: enable drag‑and‑drop (true/false)
124
124
  - `selectedRowsCallback`: callback with selected row IDs
125
+ - `initialSelectedRows` (or `initaialSelectedRows`): initial selected row IDs (or row objects with `id`) for preselection
125
126
  - `editCallback`: callback when editing a row
126
127
  - `viewCallback`: callback when viewing a row
127
128
  - `deleteCallback`: async callback for deleting a row
package/dist/Table.cjs.js CHANGED
@@ -9662,6 +9662,8 @@ function TableInner({
9662
9662
  enableDragRow = false,
9663
9663
  enableSearchUrlParam = false,
9664
9664
  enableMultiSelect = false,
9665
+ initialSelectedRows = [],
9666
+ initaialSelectedRows,
9665
9667
  enableExternalRowDrop = false,
9666
9668
  onExternalRowDrop = () => {},
9667
9669
  useExternalDndContext = false,
@@ -9724,10 +9726,17 @@ function TableInner({
9724
9726
  React.useEffect(() => {
9725
9727
  duplicateCallbackRef.current = duplicateCallback;
9726
9728
  }, [duplicateCallback]);
9729
+ const resolvedInitialSelectedRows = React.useMemo(() => {
9730
+ const source = Array.isArray(initialSelectedRows) ? initialSelectedRows : Array.isArray(initaialSelectedRows) ? initaialSelectedRows : [];
9731
+ return [...new Set(source.map(item => item && typeof item === "object" ? item.id : item).filter(id => id != null))];
9732
+ }, [initialSelectedRows, initaialSelectedRows]);
9727
9733
 
9728
9734
  // Local selection & sorting state (removed TableContext dependency)
9729
- const [selectedRows, setSelectedRows] = React.useState([]);
9735
+ const [selectedRows, setSelectedRows] = React.useState(() => resolvedInitialSelectedRows);
9730
9736
  const [sorting, setSorting] = React.useState(null);
9737
+ React.useEffect(() => {
9738
+ setSelectedRows(resolvedInitialSelectedRows);
9739
+ }, [resolvedInitialSelectedRows]);
9731
9740
 
9732
9741
  // Option to read search param from URL
9733
9742
  const [searchTerm, setSearchTerm] = React.useState(extraSearchTerm);
@@ -10389,16 +10398,6 @@ function TableInner({
10389
10398
  key,
10390
10399
  style
10391
10400
  }) => {
10392
- // override virtualization's fixed width so that flex-based cells can
10393
- // expand/contract with the header. without this the header adjusts but
10394
- // rows keep the original pixel width from the first render, leading to
10395
- // the mismatched behaviour described by the user.
10396
- const fullStyle = {
10397
- ...style,
10398
- width: "100%",
10399
- boxSizing: "border-box",
10400
- paddingRight: headerPadRight || 0
10401
- };
10402
10401
  const item = tableDataFlat[index];
10403
10402
  if (!item) return null;
10404
10403
  if (item.type === "group") {
@@ -10431,7 +10430,7 @@ function TableInner({
10431
10430
  ref: ref,
10432
10431
  key: key,
10433
10432
  style: {
10434
- ...fullStyle,
10433
+ ...style,
10435
10434
  background: '#f6f6fa',
10436
10435
  border: '2px dashed #bbb',
10437
10436
  textAlign: 'center',
@@ -10481,7 +10480,7 @@ function TableInner({
10481
10480
  // Default: normal group header
10482
10481
  return /*#__PURE__*/React.createElement("div", {
10483
10482
  key: key,
10484
- style: fullStyle,
10483
+ style: style,
10485
10484
  className: "table-row group-row",
10486
10485
  onClick: () => toggleGroup(gid)
10487
10486
  }, enableMultiSelect && showDelete && /*#__PURE__*/React.createElement("div", {
@@ -10542,15 +10541,14 @@ function TableInner({
10542
10541
  };
10543
10542
  const content = /*#__PURE__*/React.createElement("div", {
10544
10543
  key: key,
10545
- style: fullStyle,
10544
+ style: style,
10546
10545
  className: "table-row"
10547
10546
  }, /*#__PURE__*/React.createElement("div", {
10548
10547
  className: "row-main",
10549
10548
  onDoubleClick: doubleClickEnable ? handleRowDoubleClick : undefined,
10550
10549
  style: {
10551
10550
  display: 'flex',
10552
- flex: '1 1 0%',
10553
- minWidth: 0
10551
+ flex: 1
10554
10552
  }
10555
10553
  }, enableMultiSelect && showDelete && /*#__PURE__*/React.createElement("div", {
10556
10554
  className: "table-cell checkbox-cell"