trotl-table 1.0.81 → 1.0.82

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/dist/Table.cjs.js CHANGED
@@ -9746,7 +9746,7 @@ function TableInner({
9746
9746
  });
9747
9747
  const [contextMenuModal, setContextMenuModal] = React.useState({
9748
9748
  visible: false,
9749
- title: '',
9749
+ title: "",
9750
9750
  component: null
9751
9751
  });
9752
9752
  React.useEffect(() => {
@@ -9761,7 +9761,7 @@ function TableInner({
9761
9761
  row: null
9762
9762
  });
9763
9763
  const handleEscape = event => {
9764
- if (event.key === 'Escape') {
9764
+ if (event.key === "Escape") {
9765
9765
  setContextMenu({
9766
9766
  visible: false,
9767
9767
  x: 0,
@@ -9770,13 +9770,13 @@ function TableInner({
9770
9770
  });
9771
9771
  }
9772
9772
  };
9773
- window.addEventListener('click', handleClick);
9774
- window.addEventListener('contextmenu', handleClick);
9775
- window.addEventListener('keydown', handleEscape);
9773
+ window.addEventListener("click", handleClick);
9774
+ window.addEventListener("contextmenu", handleClick);
9775
+ window.addEventListener("keydown", handleEscape);
9776
9776
  return () => {
9777
- window.removeEventListener('click', handleClick);
9778
- window.removeEventListener('contextmenu', handleClick);
9779
- window.removeEventListener('keydown', handleEscape);
9777
+ window.removeEventListener("click", handleClick);
9778
+ window.removeEventListener("contextmenu", handleClick);
9779
+ window.removeEventListener("keydown", handleEscape);
9780
9780
  };
9781
9781
  }, [contextMenu.visible]);
9782
9782
  React.useEffect(() => {
@@ -10054,7 +10054,7 @@ function TableInner({
10054
10054
  updateSearchFromUrl();
10055
10055
 
10056
10056
  // Listen for URL changes (back/forward navigation)
10057
- window.addEventListener('popstate', updateSearchFromUrl);
10057
+ window.addEventListener("popstate", updateSearchFromUrl);
10058
10058
 
10059
10059
  // Listen for programmatic URL changes if you use history.pushState/replaceState
10060
10060
  const originalPushState = window.history.pushState;
@@ -10068,7 +10068,7 @@ function TableInner({
10068
10068
  updateSearchFromUrl();
10069
10069
  };
10070
10070
  return () => {
10071
- window.removeEventListener('popstate', updateSearchFromUrl);
10071
+ window.removeEventListener("popstate", updateSearchFromUrl);
10072
10072
  // Restore original methods
10073
10073
  window.history.pushState = originalPushState;
10074
10074
  window.history.replaceState = originalReplaceState;
@@ -10111,7 +10111,7 @@ function TableInner({
10111
10111
  const closeContextMenuModal = React.useCallback(() => {
10112
10112
  setContextMenuModal({
10113
10113
  visible: false,
10114
- title: '',
10114
+ title: "",
10115
10115
  component: null
10116
10116
  });
10117
10117
  }, []);
@@ -10165,7 +10165,7 @@ function TableInner({
10165
10165
  };
10166
10166
 
10167
10167
  // Listen for popstate (back/forward navigation)
10168
- window.addEventListener('popstate', handleDateParamChange);
10168
+ window.addEventListener("popstate", handleDateParamChange);
10169
10169
 
10170
10170
  // Listen for programmatic URL changes
10171
10171
  const originalPushState = window.history.pushState;
@@ -10180,10 +10180,10 @@ function TableInner({
10180
10180
  };
10181
10181
 
10182
10182
  // Listen for hashchange (in case date params are in hash)
10183
- window.addEventListener('hashchange', handleDateParamChange);
10183
+ window.addEventListener("hashchange", handleDateParamChange);
10184
10184
  return () => {
10185
- window.removeEventListener('popstate', handleDateParamChange);
10186
- window.removeEventListener('hashchange', handleDateParamChange);
10185
+ window.removeEventListener("popstate", handleDateParamChange);
10186
+ window.removeEventListener("hashchange", handleDateParamChange);
10187
10187
  window.history.pushState = originalPushState;
10188
10188
  window.history.replaceState = originalReplaceState;
10189
10189
  };
@@ -10191,15 +10191,15 @@ function TableInner({
10191
10191
  const filterRows = React.useCallback(rows => {
10192
10192
  // Check for date-related URL params first
10193
10193
  const urlParams = new URLSearchParams(urlSearchString);
10194
- const _dateParams = ['startDate', 'endDate', 'date'];
10194
+ const _dateParams = ["startDate", "endDate", "date"];
10195
10195
  let dateFiltered = rows;
10196
10196
  for (const paramKey of _dateParams) {
10197
10197
  const paramValue = urlParams.get(paramKey);
10198
10198
  if (!paramValue) continue;
10199
10199
 
10200
10200
  // Check if it's a range (contains ~)
10201
- if (paramValue.includes('~')) {
10202
- const [startTs, endTs] = paramValue.split('~').map(Number);
10201
+ if (paramValue.includes("~")) {
10202
+ const [startTs, endTs] = paramValue.split("~").map(Number);
10203
10203
  if (isNaN(startTs) || isNaN(endTs)) continue;
10204
10204
  dateFiltered = dateFiltered.filter(row => {
10205
10205
  // Check if any date field in the row falls within the range
@@ -10410,7 +10410,7 @@ function TableInner({
10410
10410
  if (!el) return;
10411
10411
 
10412
10412
  // Try to find the actual scrollable grid element created by react-virtualized
10413
- const grid = el.querySelector('.ReactVirtualized__Grid');
10413
+ const grid = el.querySelector(".ReactVirtualized__Grid");
10414
10414
  const check = () => {
10415
10415
  if (!grid) {
10416
10416
  setHeaderPadRight(0);
@@ -10441,10 +10441,14 @@ function TableInner({
10441
10441
  cancelAnimationFrame(raf);
10442
10442
  try {
10443
10443
  ro.disconnect();
10444
- } catch {/* noop */}
10444
+ } catch {
10445
+ /* noop */
10446
+ }
10445
10447
  try {
10446
10448
  mo.disconnect();
10447
- } catch {/* noop */}
10449
+ } catch {
10450
+ /* noop */
10451
+ }
10448
10452
  };
10449
10453
  }, [listRef, tableDataFlat.length]);
10450
10454
 
@@ -10471,7 +10475,7 @@ function TableInner({
10471
10475
  if (res && res.success === false) return;
10472
10476
  } catch (err) {
10473
10477
  // if callback throws, don't block deletion
10474
- console.error('deleteCallback threw', err);
10478
+ console.error("deleteCallback threw", err);
10475
10479
  }
10476
10480
  }
10477
10481
  setLocalData(prev => {
@@ -10541,8 +10545,18 @@ function TableInner({
10541
10545
  const isUndefinedLike = v === undefined || typeof v === "string" && v.trim().toLowerCase() === "undefined";
10542
10546
  const isNoData = isUndefinedLike;
10543
10547
 
10548
+ // Custom column type (editable in-table)
10549
+ if (col && col.type === "custom") {
10550
+ const customComp = col["modal-comp"];
10551
+ if (customComp) {
10552
+ return /*#__PURE__*/React.createElement("customComp", {
10553
+ value: v
10554
+ });
10555
+ }
10556
+ }
10557
+
10544
10558
  // Checkbox column type (editable in-table)
10545
- if (col && col.type === 'checkbox') {
10559
+ if (col && col.type === "checkbox") {
10546
10560
  const checked = isUndefinedLike ? false : !!v;
10547
10561
  return /*#__PURE__*/React.createElement("input", {
10548
10562
  type: "checkbox",
@@ -10573,14 +10587,14 @@ function TableInner({
10573
10587
  try {
10574
10588
  onCellChangeRef.current?.(row, accessor, next);
10575
10589
  } catch (err) {
10576
- console.error('onCellChange error', err);
10590
+ console.error("onCellChange error", err);
10577
10591
  }
10578
10592
  }
10579
10593
  });
10580
10594
  }
10581
10595
 
10582
10596
  // Switch column type (uses internal Switch component)
10583
- if (col && col.type === 'switch') {
10597
+ if (col && col.type === "switch") {
10584
10598
  const checked = isUndefinedLike ? false : !!v;
10585
10599
  return /*#__PURE__*/React.createElement("div", {
10586
10600
  title: isNoData ? translate("noData") : undefined,
@@ -10591,7 +10605,7 @@ function TableInner({
10591
10605
  }, /*#__PURE__*/React.createElement(Switch.default, {
10592
10606
  checked: checked,
10593
10607
  onChange: valOrEvent => {
10594
- const next = typeof valOrEvent === 'boolean' ? valOrEvent : valOrEvent && valOrEvent.target ? !!valOrEvent.target.checked : !!valOrEvent;
10608
+ const next = typeof valOrEvent === "boolean" ? valOrEvent : valOrEvent && valOrEvent.target ? !!valOrEvent.target.checked : !!valOrEvent;
10595
10609
  setLocalData(prev => {
10596
10610
  if (isGrouped) {
10597
10611
  return prev.map(g => ({
@@ -10611,30 +10625,30 @@ function TableInner({
10611
10625
  try {
10612
10626
  onCellChangeRef.current?.(row, accessor, next);
10613
10627
  } catch (err) {
10614
- console.error('onCellChange error', err);
10628
+ console.error("onCellChange error", err);
10615
10629
  }
10616
10630
  }
10617
10631
  }));
10618
10632
  }
10619
10633
 
10620
10634
  // Color column type (display color swatch background)
10621
- if (col && col.type === 'color') {
10635
+ if (col && col.type === "color") {
10622
10636
  const colorVal = isUndefinedLike ? "transparent" : v || "transparent";
10623
10637
  const text = isUndefinedLike ? "..." : String(colorVal) ;
10624
10638
  return /*#__PURE__*/React.createElement("div", {
10625
10639
  style: {
10626
- width: '100%',
10627
- height: '100%',
10628
- minHeight: '20px',
10640
+ width: "100%",
10641
+ height: "100%",
10642
+ minHeight: "20px",
10629
10643
  backgroundColor: colorVal,
10630
- color: '#000',
10631
- border: '1px solid #ccc',
10632
- boxSizing: 'border-box',
10633
- display: 'flex',
10634
- alignItems: 'center',
10635
- justifyContent: 'center',
10636
- fontSize: '12px',
10637
- overflow: 'hidden'
10644
+ color: "#000",
10645
+ border: "1px solid #ccc",
10646
+ boxSizing: "border-box",
10647
+ display: "flex",
10648
+ alignItems: "center",
10649
+ justifyContent: "center",
10650
+ fontSize: "12px",
10651
+ overflow: "hidden"
10638
10652
  },
10639
10653
  title: isNoData ? translate("noData") : text,
10640
10654
  onClick: () => triggerCellCallback(row, col, colorVal)
@@ -10642,7 +10656,7 @@ function TableInner({
10642
10656
  }
10643
10657
 
10644
10658
  // Input column type (editable text)
10645
- if (col && col.type === 'input') {
10659
+ if (col && col.type === "input") {
10646
10660
  const text = isNoData ? "" : v == null ? "" : String(v);
10647
10661
  return /*#__PURE__*/React.createElement("input", {
10648
10662
  type: "text",
@@ -10675,7 +10689,7 @@ function TableInner({
10675
10689
  try {
10676
10690
  onCellChangeRef.current?.(row, accessor, next);
10677
10691
  } catch (err) {
10678
- console.error('onCellChange error', err);
10692
+ console.error("onCellChange error", err);
10679
10693
  }
10680
10694
  },
10681
10695
  style: {
@@ -10686,7 +10700,7 @@ function TableInner({
10686
10700
  }
10687
10701
 
10688
10702
  // Number column type (format decimals) - default two decimals
10689
- if (col && col.type === 'number') {
10703
+ if (col && col.type === "number") {
10690
10704
  if (isNoData) {
10691
10705
  return /*#__PURE__*/React.createElement("span", {
10692
10706
  title: translate("noData")
@@ -10710,7 +10724,7 @@ function TableInner({
10710
10724
  title: formatted
10711
10725
  }, formatted);
10712
10726
  }
10713
- if (col && col.type === 'array') {
10727
+ if (col && col.type === "array") {
10714
10728
  const arr = Array.isArray(v) ? v : [];
10715
10729
  const list = formatArrayValue(arr, col);
10716
10730
  const count = arr.length;
@@ -10813,7 +10827,7 @@ function TableInner({
10813
10827
  const from = tableDataFlat[fromIndex];
10814
10828
  let to = null;
10815
10829
  let emptyGroupId = null;
10816
- if (typeof toIndexOrGroup === 'object' && toIndexOrGroup && toIndexOrGroup.emptyGroupId) {
10830
+ if (typeof toIndexOrGroup === "object" && toIndexOrGroup && toIndexOrGroup.emptyGroupId) {
10817
10831
  emptyGroupId = toIndexOrGroup.emptyGroupId;
10818
10832
  } else {
10819
10833
  to = tableDataFlat[toIndexOrGroup];
@@ -10908,7 +10922,7 @@ function TableInner({
10908
10922
  newRow = res.newRow;
10909
10923
  }
10910
10924
  } catch (err) {
10911
- console.error('duplicateCallback threw', err);
10925
+ console.error("duplicateCallback threw", err);
10912
10926
  }
10913
10927
  }
10914
10928
  // fallback simple clone if callback didn't provide newRow
@@ -10979,13 +10993,13 @@ function TableInner({
10979
10993
  key: key,
10980
10994
  style: {
10981
10995
  ...style,
10982
- background: '#f6f6fa',
10983
- border: '2px dashed #bbb',
10984
- textAlign: 'center',
10985
- color: '#888',
10996
+ background: "#f6f6fa",
10997
+ border: "2px dashed #bbb",
10998
+ textAlign: "center",
10999
+ color: "#888",
10986
11000
  minHeight: rowHeight,
10987
- display: 'flex',
10988
- alignItems: 'center'
11001
+ display: "flex",
11002
+ alignItems: "center"
10989
11003
  },
10990
11004
  className: "table-row group-row empty-group-drop",
10991
11005
  onClick: () => toggleGroup(gid)
@@ -11014,7 +11028,7 @@ function TableInner({
11014
11028
  }), /*#__PURE__*/React.createElement("div", {
11015
11029
  className: "table-cell group-header",
11016
11030
  title: `${translate(item.groupName)} (0)`
11017
- }, item.expanded ? "▾" : "▸", " ", translate(item.groupName), " (0) \u2014 ", translate("DropHereToMoveIntoThisGroup")), showActions && /*#__PURE__*/React.createElement("div", {
11031
+ }, item.expanded ? "▾" : "▸", " ", translate(item.groupName), " (0) \u2014", " ", translate("DropHereToMoveIntoThisGroup")), showActions && /*#__PURE__*/React.createElement("div", {
11018
11032
  className: "table-cell action-cell",
11019
11033
  style: actionColumnStyle
11020
11034
  }));
@@ -11066,7 +11080,7 @@ function TableInner({
11066
11080
  // Insert custom columns at specified places
11067
11081
  if (Array.isArray(customColumns)) {
11068
11082
  customColumns.forEach(col => {
11069
- if (typeof col.place === 'number') {
11083
+ if (typeof col.place === "number") {
11070
11084
  allColumns.splice(col.place, 0, {
11071
11085
  ...col,
11072
11086
  isCustom: true
@@ -11078,7 +11092,7 @@ function TableInner({
11078
11092
  const handleRowDoubleClick = e => {
11079
11093
  if (!doubleClickEnable) return;
11080
11094
  // ignore if the event originated on an interactive element
11081
- if (e.target.closest('.checkbox-cell') || e.target.closest('button') || e.target.closest('input') || e.target.closest('a')) {
11095
+ if (e.target.closest(".checkbox-cell") || e.target.closest("button") || e.target.closest("input") || e.target.closest("a")) {
11082
11096
  return;
11083
11097
  }
11084
11098
  editCallbackRef.current(row);
@@ -11105,7 +11119,7 @@ function TableInner({
11105
11119
  className: "row-main",
11106
11120
  onDoubleClick: doubleClickEnable ? handleRowDoubleClick : undefined,
11107
11121
  style: {
11108
- display: 'flex',
11122
+ display: "flex",
11109
11123
  flex: 1
11110
11124
  }
11111
11125
  }, enableMultiSelect && /*#__PURE__*/React.createElement("div", {
@@ -11132,7 +11146,7 @@ function TableInner({
11132
11146
  className: "table-cell",
11133
11147
  style: cellStyle,
11134
11148
  onClick: () => triggerCellCallback(row, col)
11135
- }, col.isCustom ? typeof col.render === 'function' ? col.render(row, i) : col.render : renderCell(cellValue, resolvedAccessor, row, col));
11149
+ }, col.isCustom ? typeof col.render === "function" ? col.render(row, i) : col.render : renderCell(cellValue, resolvedAccessor, row, col));
11136
11150
  })), showActions && /*#__PURE__*/React.createElement("div", {
11137
11151
  className: "table-cell action-cell",
11138
11152
  style: actionColumnStyle
@@ -11238,7 +11252,7 @@ function TableInner({
11238
11252
  const allColumns = [...columns];
11239
11253
  if (Array.isArray(customColumns)) {
11240
11254
  customColumns.forEach(col => {
11241
- if (typeof col.place === 'number') {
11255
+ if (typeof col.place === "number") {
11242
11256
  allColumns.splice(col.place, 0, {
11243
11257
  ...col,
11244
11258
  isCustom: true
@@ -11250,9 +11264,9 @@ function TableInner({
11250
11264
  className: "table-container",
11251
11265
  ref: setTableRef,
11252
11266
  style: useExternalDndContext && enableExternalRowDrop ? {
11253
- transition: 'background 0.15s',
11254
- background: isExternalOver && canExternalDrop ? 'rgba(100,108,255,0.15)' : undefined,
11255
- outline: isExternalOver && canExternalDrop ? '2px dashed #646cff' : undefined
11267
+ transition: "background 0.15s",
11268
+ background: isExternalOver && canExternalDrop ? "rgba(100,108,255,0.15)" : undefined,
11269
+ outline: isExternalOver && canExternalDrop ? "2px dashed #646cff" : undefined
11256
11270
  } : undefined
11257
11271
  }, /*#__PURE__*/React.createElement("div", {
11258
11272
  className: "table-header",
@@ -11314,8 +11328,8 @@ function TableInner({
11314
11328
  className: "table-empty",
11315
11329
  style: {
11316
11330
  padding: 24,
11317
- textAlign: 'center',
11318
- color: '#666'
11331
+ textAlign: "center",
11332
+ color: "#666"
11319
11333
  }
11320
11334
  }, translate("noData")) : /*#__PURE__*/React.createElement(AutoSizer, null, ({
11321
11335
  height,
@@ -11336,15 +11350,15 @@ function TableInner({
11336
11350
  cancelLabel: translate("cancel"),
11337
11351
  showCancel: true,
11338
11352
  showConfirm: true
11339
- }, /*#__PURE__*/React.createElement("p", null, translate("areYouSureYouWantToDelete"), " ", /*#__PURE__*/React.createElement("strong", null, pendingDelete ? pendingDelete[deleteLabelKey] ?? pendingDelete.name ?? pendingDelete.id : ''), "?")));
11353
+ }, /*#__PURE__*/React.createElement("p", null, translate("areYouSureYouWantToDelete"), " ", /*#__PURE__*/React.createElement("strong", null, pendingDelete ? pendingDelete[deleteLabelKey] ?? pendingDelete.name ?? pendingDelete.id : ""), "?")));
11340
11354
  const contextMenuMarkup = contextMenu.visible && rightClickActions.length > 0 ? /*#__PURE__*/React.createElement("div", {
11341
11355
  style: {
11342
- position: 'fixed',
11356
+ position: "fixed",
11343
11357
  top: contextMenu.y,
11344
11358
  left: contextMenu.x,
11345
- backgroundColor: '#fff',
11346
- border: '1px solid #ccc',
11347
- boxShadow: '0 2px 8px rgba(0,0,0,.15)',
11359
+ backgroundColor: "#fff",
11360
+ border: "1px solid #ccc",
11361
+ boxShadow: "0 2px 8px rgba(0,0,0,.15)",
11348
11362
  zIndex: 9999,
11349
11363
  minWidth: 160,
11350
11364
  padding: 0,
@@ -11354,11 +11368,11 @@ function TableInner({
11354
11368
  }, rightClickActions.map((action, i) => /*#__PURE__*/React.createElement("div", {
11355
11369
  key: i,
11356
11370
  style: {
11357
- padding: '8px 12px',
11358
- cursor: 'pointer',
11359
- borderBottom: i < rightClickActions.length - 1 ? '1px solid #eee' : 'none',
11360
- backgroundColor: hoveredActionIndex === i ? '#f5f5f5' : '#fff',
11361
- color: hoveredActionIndex === i ? '#000' : '#333'
11371
+ padding: "8px 12px",
11372
+ cursor: "pointer",
11373
+ borderBottom: i < rightClickActions.length - 1 ? "1px solid #eee" : "none",
11374
+ backgroundColor: hoveredActionIndex === i ? "#f5f5f5" : "#fff",
11375
+ color: hoveredActionIndex === i ? "#000" : "#333"
11362
11376
  },
11363
11377
  onMouseEnter: () => setHoveredActionIndex(i),
11364
11378
  onMouseLeave: () => setHoveredActionIndex(null),
@@ -11366,17 +11380,17 @@ function TableInner({
11366
11380
  }, action.label || action.text || `Action ${i + 1}`))) : null;
11367
11381
  const contextMenuModalMarkup = contextMenuModal.visible && contextMenuModal.component ? /*#__PURE__*/React.createElement(Modal.default, {
11368
11382
  isOpen: true,
11369
- title: contextMenuModal.title || '',
11383
+ title: contextMenuModal.title || "",
11370
11384
  onConfirm: () => setContextMenuModal({
11371
11385
  visible: false,
11372
- title: '',
11386
+ title: "",
11373
11387
  component: null
11374
11388
  }),
11375
11389
  onCancel: () => closeContextMenuModal(),
11376
11390
  showConfirm: false,
11377
11391
  showCancel: true,
11378
- cancelLabel: translate('cancel')
11379
- }, typeof contextMenuModal.component === 'function' ? /*#__PURE__*/React.createElement(contextMenuModal.component, {
11392
+ cancelLabel: translate("cancel")
11393
+ }, typeof contextMenuModal.component === "function" ? /*#__PURE__*/React.createElement(contextMenuModal.component, {
11380
11394
  row: contextMenu.row
11381
11395
  }) : contextMenuModal.component) : null;
11382
11396
  return /*#__PURE__*/React.createElement(React.Fragment, null, tableMarkup, contextMenuMarkup, contextMenuModalMarkup);