trotl-table 1.0.100 → 1.0.102

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
@@ -88,11 +88,10 @@ export default function Demo() {
88
88
  tableId="demo-grouped"
89
89
  columns={columns}
90
90
  data={data}
91
+ styles="professional"
91
92
  isGrouped={false}
92
93
  groupKey="groupId"
93
94
  extraSearchTerm=""
94
- rowHeight={40}
95
- groupHeaderHeight={40}
96
95
  showKey={true}
97
96
  enableDragRow={true}
98
97
  selectedRowsCallback={(arr) => console.log("selected", arr)}
@@ -122,11 +121,12 @@ export default function Demo() {
122
121
  - `tableId`: unique string ID for the table
123
122
  - `columns`: array of `{ header, accessor }`
124
123
  - `data`: array of row objects
124
+ - `styles`: optional table theme. Set to `"professional"` for a compact premium business grid: a graphite-navy header, fine horizontal separators, subtle row banding, outlined action icons, and blue selection/focus states. Other values retain the default appearance.
125
125
  - `isGrouped`: enable grouped mode (true/false)
126
126
  - `groupKey`: key to group rows by
127
127
  - `extraSearchTerm`: string to filter + highlight rows
128
- - `rowHeight`: row height in px
129
- - `groupHeaderHeight`: group header height in px
128
+ - `rowHeight`: row height in px (default `34`, or `30` with `styles="professional"`). Explicit values override the theme default.
129
+ - `groupHeaderHeight`: group header height in px (default `36`, or `32` with `styles="professional"`). Explicit values override the theme default.
130
130
  - `mobileColumnCount`: number of data columns shown at viewport widths of 768px or less (1 or 2; default `2`). The full row details are shown in a modal when a mobile row is clicked.
131
131
  - `mobileRowClick`: optional callback `(row) => {}` invoked instead of opening the built-in details modal when a mobile row is clicked. Clicks on row controls and action buttons keep their existing behavior.
132
132
  - On mobile, when `enableMouseRightClick` actions are provided, double-tapping a row opens the same context menu as a right click (a single tap then opens details after a short ~280ms delay).
package/dist/Table.cjs.js CHANGED
@@ -9546,6 +9546,33 @@ _defineProperty(WindowScroller, "defaultProps", {
9546
9546
  });
9547
9547
 
9548
9548
  const ITEM_TYPE = "ROW";
9549
+ const actionIconPaths = {
9550
+ view: "M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0",
9551
+ edit: "m15 5 4 4 M4 20l4-1L20 7a2.8 2.8 0 0 0-4-4L4 15v5Z",
9552
+ duplicate: "M9 9h11v11H9Z M15 5V3H3v12h2",
9553
+ delete: "M3 6h18 M9 6V3h6v3 M5 6l1 15h12l1-15 M10 10v7 M14 10v7",
9554
+ undelete: "M3 4v6h6 M3 10a9 9 0 1 1 1 8",
9555
+ share: "M10 14 21 3 M14 3h7v7 M10 3H3v18h18v-7",
9556
+ download: "M12 3v12 m-5-5 5 5 5-5 M3 16v5h18v-5"
9557
+ };
9558
+ function ActionIcon({
9559
+ name
9560
+ }) {
9561
+ return /*#__PURE__*/React.createElement("svg", {
9562
+ width: "14",
9563
+ height: "14",
9564
+ viewBox: "0 0 24 24",
9565
+ fill: "none",
9566
+ stroke: "currentColor",
9567
+ strokeWidth: "1.7",
9568
+ strokeLinecap: "round",
9569
+ strokeLinejoin: "round",
9570
+ "aria-hidden": "true",
9571
+ focusable: "false"
9572
+ }, /*#__PURE__*/React.createElement("path", {
9573
+ d: actionIconPaths[name]
9574
+ }));
9575
+ }
9549
9576
  const getColumnType = column => Array.isArray(column?.type) ? column.type[0] : column?.type;
9550
9577
  const getColumnDateFormat = column => {
9551
9578
  if (Array.isArray(column?.type)) return column.type[1] || null;
@@ -9694,8 +9721,9 @@ function TableInner({
9694
9721
  groupKey = "groupId",
9695
9722
  routePath = null,
9696
9723
  extraSearchTerm = "",
9697
- rowHeight = 34,
9698
- groupHeaderHeight = 36,
9724
+ styles,
9725
+ rowHeight = styles === "professional" ? 30 : 34,
9726
+ groupHeaderHeight = styles === "professional" ? 32 : 36,
9699
9727
  showKey = false,
9700
9728
  keyWidth = null,
9701
9729
  selectedRowsCallback = () => {},
@@ -9734,6 +9762,7 @@ function TableInner({
9734
9762
  timeoutLoading = 5,
9735
9763
  t
9736
9764
  }) {
9765
+ const isProfessional = styles === "professional";
9737
9766
  let translate;
9738
9767
  if (t) {
9739
9768
  translate = t;
@@ -9841,10 +9870,15 @@ function TableInner({
9841
9870
  });
9842
9871
  }
9843
9872
  };
9844
- window.addEventListener("click", handleClick);
9845
- window.addEventListener("contextmenu", handleClick);
9873
+
9874
+ // Deferred so the tap that opened the menu cannot close it right away.
9875
+ const registerTimer = window.setTimeout(() => {
9876
+ window.addEventListener("click", handleClick);
9877
+ window.addEventListener("contextmenu", handleClick);
9878
+ }, 350);
9846
9879
  window.addEventListener("keydown", handleEscape);
9847
9880
  return () => {
9881
+ window.clearTimeout(registerTimer);
9848
9882
  window.removeEventListener("click", handleClick);
9849
9883
  window.removeEventListener("contextmenu", handleClick);
9850
9884
  window.removeEventListener("keydown", handleEscape);
@@ -10828,10 +10862,6 @@ function TableInner({
10828
10862
  } catch (err) {
10829
10863
  console.error("onCellChange error", err);
10830
10864
  }
10831
- },
10832
- style: {
10833
- border: "1px solid var(--border-light, #ccc)",
10834
- padding: "2px 4px"
10835
10865
  }
10836
10866
  });
10837
10867
  }
@@ -10870,10 +10900,6 @@ function TableInner({
10870
10900
  } catch (err) {
10871
10901
  console.error("onCellChange error", err);
10872
10902
  }
10873
- },
10874
- style: {
10875
- border: "1px solid var(--border-light, #ccc)",
10876
- padding: "2px 4px"
10877
10903
  }
10878
10904
  });
10879
10905
  }
@@ -11129,10 +11155,10 @@ function TableInner({
11129
11155
  key: key,
11130
11156
  style: {
11131
11157
  ...style,
11132
- background: "#f6f6fa",
11133
- border: "2px dashed #bbb",
11158
+ background: "var(--table-group-bg, #f6f6fa)",
11159
+ border: "2px dashed var(--table-group-border, #bbb)",
11134
11160
  textAlign: "center",
11135
- color: "#888",
11161
+ color: "var(--table-group-color, #888)",
11136
11162
  minHeight: rowHeight,
11137
11163
  display: "flex",
11138
11164
  alignItems: "center"
@@ -11273,6 +11299,8 @@ function TableInner({
11273
11299
  ...highlightRowStyle
11274
11300
  } : style,
11275
11301
  className: isMobile ? "table-row mobile-clickable" : "table-row",
11302
+ "data-stripe": visualIndex % 2 === 0 ? "even" : "odd",
11303
+ "data-selected": selectedRows.includes(row.id) ? "true" : undefined,
11276
11304
  onClick: isMobile ? handleMobileRowClick : undefined,
11277
11305
  onContextMenu: e => {
11278
11306
  if (!Array.isArray(enableMouseRightClick) || enableMouseRightClick.length === 0) return;
@@ -11335,7 +11363,9 @@ function TableInner({
11335
11363
  role: "img",
11336
11364
  "aria-hidden": "false",
11337
11365
  title: translate("view")
11338
- }, "\uD83D\uDC41\uFE0F") : translate("view")), showEdit && /*#__PURE__*/React.createElement("button", {
11366
+ }, isProfessional ? /*#__PURE__*/React.createElement(ActionIcon, {
11367
+ name: "view"
11368
+ }) : "👁️") : translate("view")), showEdit && /*#__PURE__*/React.createElement("button", {
11339
11369
  className: "action-btn-table",
11340
11370
  onClick: () => editCallbackRef.current(row),
11341
11371
  onDoubleClick: e => e.stopPropagation(),
@@ -11344,20 +11374,25 @@ function TableInner({
11344
11374
  role: "img",
11345
11375
  "aria-hidden": "false",
11346
11376
  title: translate("edit")
11347
- }, "\u270F\uFE0F") : translate("edit")), showDuplicate && /*#__PURE__*/React.createElement("button", {
11377
+ }, isProfessional ? /*#__PURE__*/React.createElement(ActionIcon, {
11378
+ name: "edit"
11379
+ }) : "✏️") : translate("edit")), showDuplicate && /*#__PURE__*/React.createElement("button", {
11348
11380
  className: "action-btn-table",
11349
11381
  onClick: () => duplicateCallbackRef.current(row),
11350
11382
  onDoubleClick: e => e.stopPropagation(),
11351
11383
  "aria-label": translate("duplicate")
11352
11384
  }, showIcons ? /*#__PURE__*/React.createElement("span", {
11353
- style: {
11385
+ style: isProfessional ? undefined : {
11354
11386
  color: "black"
11355
11387
  },
11356
11388
  role: "img",
11357
11389
  "aria-hidden": "false",
11358
11390
  title: translate("duplicate")
11359
- }, "\uD83D\uDDD0") : translate("duplicate")), showDelete && /*#__PURE__*/React.createElement("button", {
11391
+ }, isProfessional ? /*#__PURE__*/React.createElement(ActionIcon, {
11392
+ name: "duplicate"
11393
+ }) : "🗐") : translate("duplicate")), showDelete && /*#__PURE__*/React.createElement("button", {
11360
11394
  className: "action-btn-table",
11395
+ "data-action": "delete",
11361
11396
  onClick: () => deleteCallbackRef.current(row),
11362
11397
  onDoubleClick: e => e.stopPropagation(),
11363
11398
  "aria-label": translate("delete")
@@ -11365,7 +11400,9 @@ function TableInner({
11365
11400
  role: "img",
11366
11401
  "aria-hidden": "false",
11367
11402
  title: translate("delete")
11368
- }, "\uD83D\uDDD1\uFE0F") : translate("delete")), showUndelete && /*#__PURE__*/React.createElement("button", {
11403
+ }, isProfessional ? /*#__PURE__*/React.createElement(ActionIcon, {
11404
+ name: "delete"
11405
+ }) : "🗑️") : translate("delete")), showUndelete && /*#__PURE__*/React.createElement("button", {
11369
11406
  className: "action-btn-table",
11370
11407
  onClick: () => undeleteCallbackRef.current(row),
11371
11408
  onDoubleClick: e => e.stopPropagation(),
@@ -11374,7 +11411,9 @@ function TableInner({
11374
11411
  role: "img",
11375
11412
  "aria-hidden": "false",
11376
11413
  title: translate("undelete")
11377
- }, "\u267B\uFE0F") : translate("undelete")), showShare && /*#__PURE__*/React.createElement("button", {
11414
+ }, isProfessional ? /*#__PURE__*/React.createElement(ActionIcon, {
11415
+ name: "undelete"
11416
+ }) : "♻️") : translate("undelete")), showShare && /*#__PURE__*/React.createElement("button", {
11378
11417
  className: "action-btn-table",
11379
11418
  onClick: () => shareCallbackRef.current(row),
11380
11419
  onDoubleClick: e => e.stopPropagation(),
@@ -11383,7 +11422,9 @@ function TableInner({
11383
11422
  role: "img",
11384
11423
  "aria-hidden": "false",
11385
11424
  title: translate("share")
11386
- }, "\uD83D\uDD17") : translate("share")), showDownload && /*#__PURE__*/React.createElement("button", {
11425
+ }, isProfessional ? /*#__PURE__*/React.createElement(ActionIcon, {
11426
+ name: "share"
11427
+ }) : "🔗") : translate("share")), showDownload && /*#__PURE__*/React.createElement("button", {
11387
11428
  className: "action-btn-table",
11388
11429
  onClick: () => downloadCallbackRef.current(row),
11389
11430
  onDoubleClick: e => e.stopPropagation(),
@@ -11392,7 +11433,9 @@ function TableInner({
11392
11433
  role: "img",
11393
11434
  "aria-hidden": "false",
11394
11435
  title: translate("download") || "Download"
11395
- }, "\uD83D\uDCE5") : translate("download") || "Download")));
11436
+ }, isProfessional ? /*#__PURE__*/React.createElement(ActionIcon, {
11437
+ name: "download"
11438
+ }) : "📥") : translate("download") || "Download")));
11396
11439
  if (enableDragRow && item.type === "row") {
11397
11440
  return /*#__PURE__*/React.createElement(DraggableRow, {
11398
11441
  key: key,
@@ -11405,7 +11448,7 @@ function TableInner({
11405
11448
  }, content);
11406
11449
  }
11407
11450
  return content;
11408
- }, [tableDataFlat, visibleColumns, selectedRows, toggleRowSelection, groupRowsById, renderCell, getCellStyle, showActions, showDelete, showEdit, showKey, showView, translate, enableDragRow, moveRow, enableMultiSelect, rowHeight, tableId, customColumns, isMobile, enableMouseRightClick, doubleClickEnable, keyWidth, actionColumnStyle, showDuplicate, showDownload, showIcons, showShare, getHighlightRowStyle, triggerCellCallback, getAccessorKey, getAccessorValue]);
11451
+ }, [tableDataFlat, visibleColumns, selectedRows, toggleRowSelection, groupRowsById, renderCell, getCellStyle, showActions, showDelete, showEdit, showKey, showView, translate, enableDragRow, moveRow, enableMultiSelect, rowHeight, tableId, customColumns, isMobile, enableMouseRightClick, doubleClickEnable, keyWidth, actionColumnStyle, showDuplicate, showDownload, showIcons, isProfessional, showShare, getHighlightRowStyle, triggerCellCallback, getAccessorKey, getAccessorValue]);
11409
11452
  const rightClickActions = Array.isArray(enableMouseRightClick) ? enableMouseRightClick : [];
11410
11453
  const [hoveredActionIndex, setHoveredActionIndex] = React.useState(null);
11411
11454
  const rowHeightGetter = ({
@@ -11437,6 +11480,7 @@ function TableInner({
11437
11480
  }, [useExternalDndContext, enableExternalRowDrop, externalDrop]);
11438
11481
  const tableMarkup = /*#__PURE__*/React.createElement("div", {
11439
11482
  className: "table-container",
11483
+ "data-table-style": isProfessional ? styles : undefined,
11440
11484
  ref: setTableRef,
11441
11485
  style: useExternalDndContext && enableExternalRowDrop ? {
11442
11486
  transition: "background 0.15s",
@@ -11450,7 +11494,7 @@ function TableInner({
11450
11494
  position: "sticky",
11451
11495
  top: 0,
11452
11496
  zIndex: 10,
11453
- background: "#fff",
11497
+ background: "var(--table-header-bg, var(--table-bg))",
11454
11498
  paddingRight: headerPadRight || undefined
11455
11499
  }
11456
11500
  }, /*#__PURE__*/React.createElement("div", {
@@ -11500,7 +11544,7 @@ function TableInner({
11500
11544
  className: "table-cell action-cell",
11501
11545
  style: actionColumnStyle,
11502
11546
  title: translate("action")
11503
- }, showIcons ? /*#__PURE__*/React.createElement("span", {
11547
+ }, showIcons && !isProfessional ? /*#__PURE__*/React.createElement("span", {
11504
11548
  title: translate("action")
11505
11549
  }, "\u2699\uFE0F") : translate("action")))), /*#__PURE__*/React.createElement("div", {
11506
11550
  className: "main-table",