trotl-table 1.0.81 → 1.0.83

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.esm.js CHANGED
@@ -9724,7 +9724,7 @@ function TableInner({
9724
9724
  });
9725
9725
  const [contextMenuModal, setContextMenuModal] = useState({
9726
9726
  visible: false,
9727
- title: '',
9727
+ title: "",
9728
9728
  component: null
9729
9729
  });
9730
9730
  useEffect(() => {
@@ -9739,7 +9739,7 @@ function TableInner({
9739
9739
  row: null
9740
9740
  });
9741
9741
  const handleEscape = event => {
9742
- if (event.key === 'Escape') {
9742
+ if (event.key === "Escape") {
9743
9743
  setContextMenu({
9744
9744
  visible: false,
9745
9745
  x: 0,
@@ -9748,13 +9748,13 @@ function TableInner({
9748
9748
  });
9749
9749
  }
9750
9750
  };
9751
- window.addEventListener('click', handleClick);
9752
- window.addEventListener('contextmenu', handleClick);
9753
- window.addEventListener('keydown', handleEscape);
9751
+ window.addEventListener("click", handleClick);
9752
+ window.addEventListener("contextmenu", handleClick);
9753
+ window.addEventListener("keydown", handleEscape);
9754
9754
  return () => {
9755
- window.removeEventListener('click', handleClick);
9756
- window.removeEventListener('contextmenu', handleClick);
9757
- window.removeEventListener('keydown', handleEscape);
9755
+ window.removeEventListener("click", handleClick);
9756
+ window.removeEventListener("contextmenu", handleClick);
9757
+ window.removeEventListener("keydown", handleEscape);
9758
9758
  };
9759
9759
  }, [contextMenu.visible]);
9760
9760
  useEffect(() => {
@@ -10032,7 +10032,7 @@ function TableInner({
10032
10032
  updateSearchFromUrl();
10033
10033
 
10034
10034
  // Listen for URL changes (back/forward navigation)
10035
- window.addEventListener('popstate', updateSearchFromUrl);
10035
+ window.addEventListener("popstate", updateSearchFromUrl);
10036
10036
 
10037
10037
  // Listen for programmatic URL changes if you use history.pushState/replaceState
10038
10038
  const originalPushState = window.history.pushState;
@@ -10046,7 +10046,7 @@ function TableInner({
10046
10046
  updateSearchFromUrl();
10047
10047
  };
10048
10048
  return () => {
10049
- window.removeEventListener('popstate', updateSearchFromUrl);
10049
+ window.removeEventListener("popstate", updateSearchFromUrl);
10050
10050
  // Restore original methods
10051
10051
  window.history.pushState = originalPushState;
10052
10052
  window.history.replaceState = originalReplaceState;
@@ -10089,7 +10089,7 @@ function TableInner({
10089
10089
  const closeContextMenuModal = useCallback(() => {
10090
10090
  setContextMenuModal({
10091
10091
  visible: false,
10092
- title: '',
10092
+ title: "",
10093
10093
  component: null
10094
10094
  });
10095
10095
  }, []);
@@ -10143,7 +10143,7 @@ function TableInner({
10143
10143
  };
10144
10144
 
10145
10145
  // Listen for popstate (back/forward navigation)
10146
- window.addEventListener('popstate', handleDateParamChange);
10146
+ window.addEventListener("popstate", handleDateParamChange);
10147
10147
 
10148
10148
  // Listen for programmatic URL changes
10149
10149
  const originalPushState = window.history.pushState;
@@ -10158,10 +10158,10 @@ function TableInner({
10158
10158
  };
10159
10159
 
10160
10160
  // Listen for hashchange (in case date params are in hash)
10161
- window.addEventListener('hashchange', handleDateParamChange);
10161
+ window.addEventListener("hashchange", handleDateParamChange);
10162
10162
  return () => {
10163
- window.removeEventListener('popstate', handleDateParamChange);
10164
- window.removeEventListener('hashchange', handleDateParamChange);
10163
+ window.removeEventListener("popstate", handleDateParamChange);
10164
+ window.removeEventListener("hashchange", handleDateParamChange);
10165
10165
  window.history.pushState = originalPushState;
10166
10166
  window.history.replaceState = originalReplaceState;
10167
10167
  };
@@ -10169,15 +10169,15 @@ function TableInner({
10169
10169
  const filterRows = useCallback(rows => {
10170
10170
  // Check for date-related URL params first
10171
10171
  const urlParams = new URLSearchParams(urlSearchString);
10172
- const _dateParams = ['startDate', 'endDate', 'date'];
10172
+ const _dateParams = ["startDate", "endDate", "date"];
10173
10173
  let dateFiltered = rows;
10174
10174
  for (const paramKey of _dateParams) {
10175
10175
  const paramValue = urlParams.get(paramKey);
10176
10176
  if (!paramValue) continue;
10177
10177
 
10178
10178
  // Check if it's a range (contains ~)
10179
- if (paramValue.includes('~')) {
10180
- const [startTs, endTs] = paramValue.split('~').map(Number);
10179
+ if (paramValue.includes("~")) {
10180
+ const [startTs, endTs] = paramValue.split("~").map(Number);
10181
10181
  if (isNaN(startTs) || isNaN(endTs)) continue;
10182
10182
  dateFiltered = dateFiltered.filter(row => {
10183
10183
  // Check if any date field in the row falls within the range
@@ -10388,7 +10388,7 @@ function TableInner({
10388
10388
  if (!el) return;
10389
10389
 
10390
10390
  // Try to find the actual scrollable grid element created by react-virtualized
10391
- const grid = el.querySelector('.ReactVirtualized__Grid');
10391
+ const grid = el.querySelector(".ReactVirtualized__Grid");
10392
10392
  const check = () => {
10393
10393
  if (!grid) {
10394
10394
  setHeaderPadRight(0);
@@ -10419,10 +10419,14 @@ function TableInner({
10419
10419
  cancelAnimationFrame(raf);
10420
10420
  try {
10421
10421
  ro.disconnect();
10422
- } catch {/* noop */}
10422
+ } catch {
10423
+ /* noop */
10424
+ }
10423
10425
  try {
10424
10426
  mo.disconnect();
10425
- } catch {/* noop */}
10427
+ } catch {
10428
+ /* noop */
10429
+ }
10426
10430
  };
10427
10431
  }, [listRef, tableDataFlat.length]);
10428
10432
 
@@ -10449,7 +10453,7 @@ function TableInner({
10449
10453
  if (res && res.success === false) return;
10450
10454
  } catch (err) {
10451
10455
  // if callback throws, don't block deletion
10452
- console.error('deleteCallback threw', err);
10456
+ console.error("deleteCallback threw", err);
10453
10457
  }
10454
10458
  }
10455
10459
  setLocalData(prev => {
@@ -10519,8 +10523,18 @@ function TableInner({
10519
10523
  const isUndefinedLike = v === undefined || typeof v === "string" && v.trim().toLowerCase() === "undefined";
10520
10524
  const isNoData = isUndefinedLike;
10521
10525
 
10526
+ // Custom column type (editable in-table)
10527
+ if (col && col.type === "custom") {
10528
+ const CustomComp = col["modal-comp"];
10529
+ if (CustomComp) {
10530
+ return /*#__PURE__*/React__default.createElement(CustomComp, {
10531
+ value: v
10532
+ });
10533
+ }
10534
+ }
10535
+
10522
10536
  // Checkbox column type (editable in-table)
10523
- if (col && col.type === 'checkbox') {
10537
+ if (col && col.type === "checkbox") {
10524
10538
  const checked = isUndefinedLike ? false : !!v;
10525
10539
  return /*#__PURE__*/React__default.createElement("input", {
10526
10540
  type: "checkbox",
@@ -10551,14 +10565,14 @@ function TableInner({
10551
10565
  try {
10552
10566
  onCellChangeRef.current?.(row, accessor, next);
10553
10567
  } catch (err) {
10554
- console.error('onCellChange error', err);
10568
+ console.error("onCellChange error", err);
10555
10569
  }
10556
10570
  }
10557
10571
  });
10558
10572
  }
10559
10573
 
10560
10574
  // Switch column type (uses internal Switch component)
10561
- if (col && col.type === 'switch') {
10575
+ if (col && col.type === "switch") {
10562
10576
  const checked = isUndefinedLike ? false : !!v;
10563
10577
  return /*#__PURE__*/React__default.createElement("div", {
10564
10578
  title: isNoData ? translate("noData") : undefined,
@@ -10569,7 +10583,7 @@ function TableInner({
10569
10583
  }, /*#__PURE__*/React__default.createElement(Switch, {
10570
10584
  checked: checked,
10571
10585
  onChange: valOrEvent => {
10572
- const next = typeof valOrEvent === 'boolean' ? valOrEvent : valOrEvent && valOrEvent.target ? !!valOrEvent.target.checked : !!valOrEvent;
10586
+ const next = typeof valOrEvent === "boolean" ? valOrEvent : valOrEvent && valOrEvent.target ? !!valOrEvent.target.checked : !!valOrEvent;
10573
10587
  setLocalData(prev => {
10574
10588
  if (isGrouped) {
10575
10589
  return prev.map(g => ({
@@ -10589,30 +10603,30 @@ function TableInner({
10589
10603
  try {
10590
10604
  onCellChangeRef.current?.(row, accessor, next);
10591
10605
  } catch (err) {
10592
- console.error('onCellChange error', err);
10606
+ console.error("onCellChange error", err);
10593
10607
  }
10594
10608
  }
10595
10609
  }));
10596
10610
  }
10597
10611
 
10598
10612
  // Color column type (display color swatch background)
10599
- if (col && col.type === 'color') {
10613
+ if (col && col.type === "color") {
10600
10614
  const colorVal = isUndefinedLike ? "transparent" : v || "transparent";
10601
10615
  const text = isUndefinedLike ? "..." : String(colorVal) ;
10602
10616
  return /*#__PURE__*/React__default.createElement("div", {
10603
10617
  style: {
10604
- width: '100%',
10605
- height: '100%',
10606
- minHeight: '20px',
10618
+ width: "100%",
10619
+ height: "100%",
10620
+ minHeight: "20px",
10607
10621
  backgroundColor: colorVal,
10608
- color: '#000',
10609
- border: '1px solid #ccc',
10610
- boxSizing: 'border-box',
10611
- display: 'flex',
10612
- alignItems: 'center',
10613
- justifyContent: 'center',
10614
- fontSize: '12px',
10615
- overflow: 'hidden'
10622
+ color: "#000",
10623
+ border: "1px solid #ccc",
10624
+ boxSizing: "border-box",
10625
+ display: "flex",
10626
+ alignItems: "center",
10627
+ justifyContent: "center",
10628
+ fontSize: "12px",
10629
+ overflow: "hidden"
10616
10630
  },
10617
10631
  title: isNoData ? translate("noData") : text,
10618
10632
  onClick: () => triggerCellCallback(row, col, colorVal)
@@ -10620,7 +10634,7 @@ function TableInner({
10620
10634
  }
10621
10635
 
10622
10636
  // Input column type (editable text)
10623
- if (col && col.type === 'input') {
10637
+ if (col && col.type === "input") {
10624
10638
  const text = isNoData ? "" : v == null ? "" : String(v);
10625
10639
  return /*#__PURE__*/React__default.createElement("input", {
10626
10640
  type: "text",
@@ -10653,7 +10667,7 @@ function TableInner({
10653
10667
  try {
10654
10668
  onCellChangeRef.current?.(row, accessor, next);
10655
10669
  } catch (err) {
10656
- console.error('onCellChange error', err);
10670
+ console.error("onCellChange error", err);
10657
10671
  }
10658
10672
  },
10659
10673
  style: {
@@ -10664,7 +10678,7 @@ function TableInner({
10664
10678
  }
10665
10679
 
10666
10680
  // Number column type (format decimals) - default two decimals
10667
- if (col && col.type === 'number') {
10681
+ if (col && col.type === "number") {
10668
10682
  if (isNoData) {
10669
10683
  return /*#__PURE__*/React__default.createElement("span", {
10670
10684
  title: translate("noData")
@@ -10688,7 +10702,7 @@ function TableInner({
10688
10702
  title: formatted
10689
10703
  }, formatted);
10690
10704
  }
10691
- if (col && col.type === 'array') {
10705
+ if (col && col.type === "array") {
10692
10706
  const arr = Array.isArray(v) ? v : [];
10693
10707
  const list = formatArrayValue(arr, col);
10694
10708
  const count = arr.length;
@@ -10791,7 +10805,7 @@ function TableInner({
10791
10805
  const from = tableDataFlat[fromIndex];
10792
10806
  let to = null;
10793
10807
  let emptyGroupId = null;
10794
- if (typeof toIndexOrGroup === 'object' && toIndexOrGroup && toIndexOrGroup.emptyGroupId) {
10808
+ if (typeof toIndexOrGroup === "object" && toIndexOrGroup && toIndexOrGroup.emptyGroupId) {
10795
10809
  emptyGroupId = toIndexOrGroup.emptyGroupId;
10796
10810
  } else {
10797
10811
  to = tableDataFlat[toIndexOrGroup];
@@ -10886,7 +10900,7 @@ function TableInner({
10886
10900
  newRow = res.newRow;
10887
10901
  }
10888
10902
  } catch (err) {
10889
- console.error('duplicateCallback threw', err);
10903
+ console.error("duplicateCallback threw", err);
10890
10904
  }
10891
10905
  }
10892
10906
  // fallback simple clone if callback didn't provide newRow
@@ -10957,13 +10971,13 @@ function TableInner({
10957
10971
  key: key,
10958
10972
  style: {
10959
10973
  ...style,
10960
- background: '#f6f6fa',
10961
- border: '2px dashed #bbb',
10962
- textAlign: 'center',
10963
- color: '#888',
10974
+ background: "#f6f6fa",
10975
+ border: "2px dashed #bbb",
10976
+ textAlign: "center",
10977
+ color: "#888",
10964
10978
  minHeight: rowHeight,
10965
- display: 'flex',
10966
- alignItems: 'center'
10979
+ display: "flex",
10980
+ alignItems: "center"
10967
10981
  },
10968
10982
  className: "table-row group-row empty-group-drop",
10969
10983
  onClick: () => toggleGroup(gid)
@@ -10992,7 +11006,7 @@ function TableInner({
10992
11006
  }), /*#__PURE__*/React__default.createElement("div", {
10993
11007
  className: "table-cell group-header",
10994
11008
  title: `${translate(item.groupName)} (0)`
10995
- }, item.expanded ? "▾" : "▸", " ", translate(item.groupName), " (0) \u2014 ", translate("DropHereToMoveIntoThisGroup")), showActions && /*#__PURE__*/React__default.createElement("div", {
11009
+ }, item.expanded ? "▾" : "▸", " ", translate(item.groupName), " (0) \u2014", " ", translate("DropHereToMoveIntoThisGroup")), showActions && /*#__PURE__*/React__default.createElement("div", {
10996
11010
  className: "table-cell action-cell",
10997
11011
  style: actionColumnStyle
10998
11012
  }));
@@ -11044,7 +11058,7 @@ function TableInner({
11044
11058
  // Insert custom columns at specified places
11045
11059
  if (Array.isArray(customColumns)) {
11046
11060
  customColumns.forEach(col => {
11047
- if (typeof col.place === 'number') {
11061
+ if (typeof col.place === "number") {
11048
11062
  allColumns.splice(col.place, 0, {
11049
11063
  ...col,
11050
11064
  isCustom: true
@@ -11056,7 +11070,7 @@ function TableInner({
11056
11070
  const handleRowDoubleClick = e => {
11057
11071
  if (!doubleClickEnable) return;
11058
11072
  // ignore if the event originated on an interactive element
11059
- if (e.target.closest('.checkbox-cell') || e.target.closest('button') || e.target.closest('input') || e.target.closest('a')) {
11073
+ if (e.target.closest(".checkbox-cell") || e.target.closest("button") || e.target.closest("input") || e.target.closest("a")) {
11060
11074
  return;
11061
11075
  }
11062
11076
  editCallbackRef.current(row);
@@ -11083,7 +11097,7 @@ function TableInner({
11083
11097
  className: "row-main",
11084
11098
  onDoubleClick: doubleClickEnable ? handleRowDoubleClick : undefined,
11085
11099
  style: {
11086
- display: 'flex',
11100
+ display: "flex",
11087
11101
  flex: 1
11088
11102
  }
11089
11103
  }, enableMultiSelect && /*#__PURE__*/React__default.createElement("div", {
@@ -11110,7 +11124,7 @@ function TableInner({
11110
11124
  className: "table-cell",
11111
11125
  style: cellStyle,
11112
11126
  onClick: () => triggerCellCallback(row, col)
11113
- }, col.isCustom ? typeof col.render === 'function' ? col.render(row, i) : col.render : renderCell(cellValue, resolvedAccessor, row, col));
11127
+ }, col.isCustom ? typeof col.render === "function" ? col.render(row, i) : col.render : renderCell(cellValue, resolvedAccessor, row, col));
11114
11128
  })), showActions && /*#__PURE__*/React__default.createElement("div", {
11115
11129
  className: "table-cell action-cell",
11116
11130
  style: actionColumnStyle
@@ -11216,7 +11230,7 @@ function TableInner({
11216
11230
  const allColumns = [...columns];
11217
11231
  if (Array.isArray(customColumns)) {
11218
11232
  customColumns.forEach(col => {
11219
- if (typeof col.place === 'number') {
11233
+ if (typeof col.place === "number") {
11220
11234
  allColumns.splice(col.place, 0, {
11221
11235
  ...col,
11222
11236
  isCustom: true
@@ -11228,9 +11242,9 @@ function TableInner({
11228
11242
  className: "table-container",
11229
11243
  ref: setTableRef,
11230
11244
  style: useExternalDndContext && enableExternalRowDrop ? {
11231
- transition: 'background 0.15s',
11232
- background: isExternalOver && canExternalDrop ? 'rgba(100,108,255,0.15)' : undefined,
11233
- outline: isExternalOver && canExternalDrop ? '2px dashed #646cff' : undefined
11245
+ transition: "background 0.15s",
11246
+ background: isExternalOver && canExternalDrop ? "rgba(100,108,255,0.15)" : undefined,
11247
+ outline: isExternalOver && canExternalDrop ? "2px dashed #646cff" : undefined
11234
11248
  } : undefined
11235
11249
  }, /*#__PURE__*/React__default.createElement("div", {
11236
11250
  className: "table-header",
@@ -11292,8 +11306,8 @@ function TableInner({
11292
11306
  className: "table-empty",
11293
11307
  style: {
11294
11308
  padding: 24,
11295
- textAlign: 'center',
11296
- color: '#666'
11309
+ textAlign: "center",
11310
+ color: "#666"
11297
11311
  }
11298
11312
  }, translate("noData")) : /*#__PURE__*/React__default.createElement(AutoSizer, null, ({
11299
11313
  height,
@@ -11314,15 +11328,15 @@ function TableInner({
11314
11328
  cancelLabel: translate("cancel"),
11315
11329
  showCancel: true,
11316
11330
  showConfirm: true
11317
- }, /*#__PURE__*/React__default.createElement("p", null, translate("areYouSureYouWantToDelete"), " ", /*#__PURE__*/React__default.createElement("strong", null, pendingDelete ? pendingDelete[deleteLabelKey] ?? pendingDelete.name ?? pendingDelete.id : ''), "?")));
11331
+ }, /*#__PURE__*/React__default.createElement("p", null, translate("areYouSureYouWantToDelete"), " ", /*#__PURE__*/React__default.createElement("strong", null, pendingDelete ? pendingDelete[deleteLabelKey] ?? pendingDelete.name ?? pendingDelete.id : ""), "?")));
11318
11332
  const contextMenuMarkup = contextMenu.visible && rightClickActions.length > 0 ? /*#__PURE__*/React__default.createElement("div", {
11319
11333
  style: {
11320
- position: 'fixed',
11334
+ position: "fixed",
11321
11335
  top: contextMenu.y,
11322
11336
  left: contextMenu.x,
11323
- backgroundColor: '#fff',
11324
- border: '1px solid #ccc',
11325
- boxShadow: '0 2px 8px rgba(0,0,0,.15)',
11337
+ backgroundColor: "#fff",
11338
+ border: "1px solid #ccc",
11339
+ boxShadow: "0 2px 8px rgba(0,0,0,.15)",
11326
11340
  zIndex: 9999,
11327
11341
  minWidth: 160,
11328
11342
  padding: 0,
@@ -11332,11 +11346,11 @@ function TableInner({
11332
11346
  }, rightClickActions.map((action, i) => /*#__PURE__*/React__default.createElement("div", {
11333
11347
  key: i,
11334
11348
  style: {
11335
- padding: '8px 12px',
11336
- cursor: 'pointer',
11337
- borderBottom: i < rightClickActions.length - 1 ? '1px solid #eee' : 'none',
11338
- backgroundColor: hoveredActionIndex === i ? '#f5f5f5' : '#fff',
11339
- color: hoveredActionIndex === i ? '#000' : '#333'
11349
+ padding: "8px 12px",
11350
+ cursor: "pointer",
11351
+ borderBottom: i < rightClickActions.length - 1 ? "1px solid #eee" : "none",
11352
+ backgroundColor: hoveredActionIndex === i ? "#f5f5f5" : "#fff",
11353
+ color: hoveredActionIndex === i ? "#000" : "#333"
11340
11354
  },
11341
11355
  onMouseEnter: () => setHoveredActionIndex(i),
11342
11356
  onMouseLeave: () => setHoveredActionIndex(null),
@@ -11344,17 +11358,17 @@ function TableInner({
11344
11358
  }, action.label || action.text || `Action ${i + 1}`))) : null;
11345
11359
  const contextMenuModalMarkup = contextMenuModal.visible && contextMenuModal.component ? /*#__PURE__*/React__default.createElement(Modal, {
11346
11360
  isOpen: true,
11347
- title: contextMenuModal.title || '',
11361
+ title: contextMenuModal.title || "",
11348
11362
  onConfirm: () => setContextMenuModal({
11349
11363
  visible: false,
11350
- title: '',
11364
+ title: "",
11351
11365
  component: null
11352
11366
  }),
11353
11367
  onCancel: () => closeContextMenuModal(),
11354
11368
  showConfirm: false,
11355
11369
  showCancel: true,
11356
- cancelLabel: translate('cancel')
11357
- }, typeof contextMenuModal.component === 'function' ? /*#__PURE__*/React__default.createElement(contextMenuModal.component, {
11370
+ cancelLabel: translate("cancel")
11371
+ }, typeof contextMenuModal.component === "function" ? /*#__PURE__*/React__default.createElement(contextMenuModal.component, {
11358
11372
  row: contextMenu.row
11359
11373
  }) : contextMenuModal.component) : null;
11360
11374
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, tableMarkup, contextMenuMarkup, contextMenuModalMarkup);