trotl-table 1.0.101 → 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;
@@ -10833,10 +10862,6 @@ function TableInner({
10833
10862
  } catch (err) {
10834
10863
  console.error("onCellChange error", err);
10835
10864
  }
10836
- },
10837
- style: {
10838
- border: "1px solid var(--border-light, #ccc)",
10839
- padding: "2px 4px"
10840
10865
  }
10841
10866
  });
10842
10867
  }
@@ -10875,10 +10900,6 @@ function TableInner({
10875
10900
  } catch (err) {
10876
10901
  console.error("onCellChange error", err);
10877
10902
  }
10878
- },
10879
- style: {
10880
- border: "1px solid var(--border-light, #ccc)",
10881
- padding: "2px 4px"
10882
10903
  }
10883
10904
  });
10884
10905
  }
@@ -11134,10 +11155,10 @@ function TableInner({
11134
11155
  key: key,
11135
11156
  style: {
11136
11157
  ...style,
11137
- background: "#f6f6fa",
11138
- border: "2px dashed #bbb",
11158
+ background: "var(--table-group-bg, #f6f6fa)",
11159
+ border: "2px dashed var(--table-group-border, #bbb)",
11139
11160
  textAlign: "center",
11140
- color: "#888",
11161
+ color: "var(--table-group-color, #888)",
11141
11162
  minHeight: rowHeight,
11142
11163
  display: "flex",
11143
11164
  alignItems: "center"
@@ -11278,6 +11299,8 @@ function TableInner({
11278
11299
  ...highlightRowStyle
11279
11300
  } : style,
11280
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,
11281
11304
  onClick: isMobile ? handleMobileRowClick : undefined,
11282
11305
  onContextMenu: e => {
11283
11306
  if (!Array.isArray(enableMouseRightClick) || enableMouseRightClick.length === 0) return;
@@ -11340,7 +11363,9 @@ function TableInner({
11340
11363
  role: "img",
11341
11364
  "aria-hidden": "false",
11342
11365
  title: translate("view")
11343
- }, "\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", {
11344
11369
  className: "action-btn-table",
11345
11370
  onClick: () => editCallbackRef.current(row),
11346
11371
  onDoubleClick: e => e.stopPropagation(),
@@ -11349,20 +11374,25 @@ function TableInner({
11349
11374
  role: "img",
11350
11375
  "aria-hidden": "false",
11351
11376
  title: translate("edit")
11352
- }, "\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", {
11353
11380
  className: "action-btn-table",
11354
11381
  onClick: () => duplicateCallbackRef.current(row),
11355
11382
  onDoubleClick: e => e.stopPropagation(),
11356
11383
  "aria-label": translate("duplicate")
11357
11384
  }, showIcons ? /*#__PURE__*/React.createElement("span", {
11358
- style: {
11385
+ style: isProfessional ? undefined : {
11359
11386
  color: "black"
11360
11387
  },
11361
11388
  role: "img",
11362
11389
  "aria-hidden": "false",
11363
11390
  title: translate("duplicate")
11364
- }, "\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", {
11365
11394
  className: "action-btn-table",
11395
+ "data-action": "delete",
11366
11396
  onClick: () => deleteCallbackRef.current(row),
11367
11397
  onDoubleClick: e => e.stopPropagation(),
11368
11398
  "aria-label": translate("delete")
@@ -11370,7 +11400,9 @@ function TableInner({
11370
11400
  role: "img",
11371
11401
  "aria-hidden": "false",
11372
11402
  title: translate("delete")
11373
- }, "\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", {
11374
11406
  className: "action-btn-table",
11375
11407
  onClick: () => undeleteCallbackRef.current(row),
11376
11408
  onDoubleClick: e => e.stopPropagation(),
@@ -11379,7 +11411,9 @@ function TableInner({
11379
11411
  role: "img",
11380
11412
  "aria-hidden": "false",
11381
11413
  title: translate("undelete")
11382
- }, "\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", {
11383
11417
  className: "action-btn-table",
11384
11418
  onClick: () => shareCallbackRef.current(row),
11385
11419
  onDoubleClick: e => e.stopPropagation(),
@@ -11388,7 +11422,9 @@ function TableInner({
11388
11422
  role: "img",
11389
11423
  "aria-hidden": "false",
11390
11424
  title: translate("share")
11391
- }, "\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", {
11392
11428
  className: "action-btn-table",
11393
11429
  onClick: () => downloadCallbackRef.current(row),
11394
11430
  onDoubleClick: e => e.stopPropagation(),
@@ -11397,7 +11433,9 @@ function TableInner({
11397
11433
  role: "img",
11398
11434
  "aria-hidden": "false",
11399
11435
  title: translate("download") || "Download"
11400
- }, "\uD83D\uDCE5") : translate("download") || "Download")));
11436
+ }, isProfessional ? /*#__PURE__*/React.createElement(ActionIcon, {
11437
+ name: "download"
11438
+ }) : "📥") : translate("download") || "Download")));
11401
11439
  if (enableDragRow && item.type === "row") {
11402
11440
  return /*#__PURE__*/React.createElement(DraggableRow, {
11403
11441
  key: key,
@@ -11410,7 +11448,7 @@ function TableInner({
11410
11448
  }, content);
11411
11449
  }
11412
11450
  return content;
11413
- }, [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]);
11414
11452
  const rightClickActions = Array.isArray(enableMouseRightClick) ? enableMouseRightClick : [];
11415
11453
  const [hoveredActionIndex, setHoveredActionIndex] = React.useState(null);
11416
11454
  const rowHeightGetter = ({
@@ -11442,6 +11480,7 @@ function TableInner({
11442
11480
  }, [useExternalDndContext, enableExternalRowDrop, externalDrop]);
11443
11481
  const tableMarkup = /*#__PURE__*/React.createElement("div", {
11444
11482
  className: "table-container",
11483
+ "data-table-style": isProfessional ? styles : undefined,
11445
11484
  ref: setTableRef,
11446
11485
  style: useExternalDndContext && enableExternalRowDrop ? {
11447
11486
  transition: "background 0.15s",
@@ -11455,7 +11494,7 @@ function TableInner({
11455
11494
  position: "sticky",
11456
11495
  top: 0,
11457
11496
  zIndex: 10,
11458
- background: "#fff",
11497
+ background: "var(--table-header-bg, var(--table-bg))",
11459
11498
  paddingRight: headerPadRight || undefined
11460
11499
  }
11461
11500
  }, /*#__PURE__*/React.createElement("div", {
@@ -11505,7 +11544,7 @@ function TableInner({
11505
11544
  className: "table-cell action-cell",
11506
11545
  style: actionColumnStyle,
11507
11546
  title: translate("action")
11508
- }, showIcons ? /*#__PURE__*/React.createElement("span", {
11547
+ }, showIcons && !isProfessional ? /*#__PURE__*/React.createElement("span", {
11509
11548
  title: translate("action")
11510
11549
  }, "\u2699\uFE0F") : translate("action")))), /*#__PURE__*/React.createElement("div", {
11511
11550
  className: "main-table",