trotl-table 1.0.6 → 1.0.7

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/index.cjs.js CHANGED
@@ -1,8 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var React = require('react');
4
- require('react-dnd');
5
- require('react-dnd-html5-backend');
6
+ var reactDnd = require('react-dnd');
7
+ var reactDndHtml5Backend = require('react-dnd-html5-backend');
6
8
 
7
9
  function _interopNamespaceDefault(e) {
8
10
  var n = Object.create(null);
@@ -8437,7 +8439,7 @@ function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueO
8437
8439
  * Table component with fixed headers and virtualized rows for improved performance with large data sets.
8438
8440
  * This component expects explicit width, height, and padding parameters.
8439
8441
  */
8440
- var Table = /*#__PURE__*/function (_React$PureComponent) {
8442
+ var Table$1 = /*#__PURE__*/function (_React$PureComponent) {
8441
8443
  function Table(props) {
8442
8444
  var _this;
8443
8445
  _classCallCheck(this, Table);
@@ -8953,7 +8955,7 @@ var Table = /*#__PURE__*/function (_React$PureComponent) {
8953
8955
  }
8954
8956
  }]);
8955
8957
  }(React__namespace.PureComponent);
8956
- _defineProperty(Table, "defaultProps", {
8958
+ _defineProperty(Table$1, "defaultProps", {
8957
8959
  disableHeader: false,
8958
8960
  estimatedRowSize: 30,
8959
8961
  headerHeight: 0,
@@ -8976,7 +8978,7 @@ _defineProperty(Table, "defaultProps", {
8976
8978
  scrollToIndex: -1,
8977
8979
  style: {}
8978
8980
  });
8979
- Table.propTypes = process.env.NODE_ENV !== "production" ? {
8981
+ Table$1.propTypes = process.env.NODE_ENV !== "production" ? {
8980
8982
  /** This is just set on the grid top element. */
8981
8983
  'aria-label': PropTypes.string,
8982
8984
  /** This is just set on the grid top element. */
@@ -9539,4 +9541,552 @@ _defineProperty(WindowScroller, "defaultProps", {
9539
9541
  serverHeight: 0,
9540
9542
  serverWidth: 0
9541
9543
  });
9544
+
9545
+ const Modal = ({
9546
+ isOpen,
9547
+ title = 'Confirm',
9548
+ children,
9549
+ onConfirm,
9550
+ onCancel,
9551
+ confirmLabel = 'Confirm',
9552
+ cancelLabel = 'Cancel',
9553
+ showCancel = false,
9554
+ showConfirm = false,
9555
+ closeOnEscape = true,
9556
+ closeOnOutsideClick = true
9557
+ }) => {
9558
+ React.useEffect(() => {
9559
+ const handleKey = e => {
9560
+ if (e.key === 'Escape' && closeOnEscape) {
9561
+ onCancel?.();
9562
+ }
9563
+ };
9564
+ document.addEventListener('keydown', handleKey);
9565
+ return () => document.removeEventListener('keydown', handleKey);
9566
+ }, [closeOnEscape, onCancel]);
9567
+ if (!isOpen) return null;
9568
+ return /*#__PURE__*/React.createElement("div", {
9569
+ className: "modal-overlay",
9570
+ onClick: closeOnOutsideClick ? onCancel : undefined
9571
+ }, /*#__PURE__*/React.createElement("div", {
9572
+ className: "modal-box",
9573
+ onClick: e => e.stopPropagation()
9574
+ }, /*#__PURE__*/React.createElement("h3", {
9575
+ className: "modal-title"
9576
+ }, title), /*#__PURE__*/React.createElement("div", {
9577
+ className: "modal-content"
9578
+ }, children), /*#__PURE__*/React.createElement("div", {
9579
+ className: "modal-actions"
9580
+ }, showCancel && /*#__PURE__*/React.createElement("button", {
9581
+ className: "basic-button cancel",
9582
+ onClick: onCancel
9583
+ }, cancelLabel), showConfirm && /*#__PURE__*/React.createElement("button", {
9584
+ className: "basic-button confirm",
9585
+ onClick: onConfirm
9586
+ }, confirmLabel))));
9587
+ };
9588
+
9589
+ const ITEM_TYPE = "ROW";
9590
+
9591
+ // Normalize data into grouped format
9592
+ const normalizeData = (groups, rows) => {
9593
+ if (Array.isArray(groups) && groups.length > 0) {
9594
+ return groups.map(g => ({
9595
+ groupId: g.groupId ?? null,
9596
+ groupName: g.groupName ?? "",
9597
+ rows: Array.isArray(g.rows) ? g.rows : []
9598
+ }));
9599
+ }
9600
+ if (Array.isArray(rows)) {
9601
+ return [{
9602
+ groupId: null,
9603
+ groupName: null,
9604
+ rows
9605
+ }];
9606
+ }
9607
+ return [];
9608
+ };
9609
+
9610
+ // Drag-and-drop row wrapper with auto-scroll support
9611
+ const DraggableRow = ({
9612
+ index,
9613
+ moveRow,
9614
+ children,
9615
+ item,
9616
+ enableDrag,
9617
+ listRef
9618
+ }) => {
9619
+ const ref = React.useRef(null);
9620
+ const [, drop] = reactDnd.useDrop({
9621
+ accept: ITEM_TYPE,
9622
+ hover(draggedItem, monitor) {
9623
+ if (!ref.current || !enableDrag) return;
9624
+ ref.current.getBoundingClientRect();
9625
+ const clientOffset = monitor.getClientOffset();
9626
+
9627
+ // Auto-scroll logic
9628
+ if (listRef?.current && clientOffset) {
9629
+ const top = listRef.current.getBoundingClientRect().top;
9630
+ const bottom = listRef.current.getBoundingClientRect().bottom;
9631
+ const scrollSpeed = 15;
9632
+ if (clientOffset.y < top + 40) {
9633
+ listRef.current.scrollBy({
9634
+ top: -scrollSpeed,
9635
+ behavior: "smooth"
9636
+ });
9637
+ } else if (clientOffset.y > bottom - 40) {
9638
+ listRef.current.scrollBy({
9639
+ top: scrollSpeed,
9640
+ behavior: "smooth"
9641
+ });
9642
+ }
9643
+ }
9644
+ if (draggedItem.index === index) return;
9645
+ moveRow(draggedItem.index, index);
9646
+ draggedItem.index = index;
9647
+ }
9648
+ });
9649
+ const [{
9650
+ isDragging
9651
+ }, drag] = reactDnd.useDrag({
9652
+ type: ITEM_TYPE,
9653
+ item: {
9654
+ index
9655
+ },
9656
+ canDrag: enableDrag,
9657
+ collect: monitor => ({
9658
+ isDragging: monitor.isDragging()
9659
+ })
9660
+ });
9661
+ drag(drop(ref));
9662
+ return /*#__PURE__*/React.createElement("div", {
9663
+ ref: ref,
9664
+ style: {
9665
+ opacity: isDragging ? 0.5 : 1,
9666
+ cursor: enableDrag ? "move" : "default"
9667
+ }
9668
+ }, children);
9669
+ };
9670
+ function Table({
9671
+ tableId = "default",
9672
+ columns = [],
9673
+ data = [],
9674
+ isGrouped = false,
9675
+ groupKey = "groupId",
9676
+ extraSearchTerm = "",
9677
+ rowHeight = 34,
9678
+ groupHeaderHeight = 36,
9679
+ showKey = false,
9680
+ selectedRowsCallback = () => {},
9681
+ refreshTrigger = () => {},
9682
+ editCallback = () => {},
9683
+ viewCallback = () => {},
9684
+ deleteCallback = null,
9685
+ buttons = ["view", "edit", "delete"],
9686
+ enableDragRow = false // new prop
9687
+ }) {
9688
+ // Local selection & sorting state (removed TableContext dependency)
9689
+ const [selectedRows, setSelectedRows] = React.useState([]);
9690
+ const [sorting, setSorting] = React.useState(null);
9691
+ const toggleRowSelection = React.useCallback(rowId => {
9692
+ setSelectedRows(prev => prev.includes(rowId) ? prev.filter(r => r !== rowId) : [...prev, rowId]);
9693
+ }, []);
9694
+ const clearSelection = React.useCallback(() => setSelectedRows([]), []);
9695
+ const setSort = column => {
9696
+ setSorting(prev => {
9697
+ if (!prev || prev.column !== column) return {
9698
+ column,
9699
+ direction: "asc"
9700
+ };
9701
+ if (prev.direction === "asc") return {
9702
+ column,
9703
+ direction: "desc"
9704
+ };
9705
+ return null;
9706
+ });
9707
+ };
9708
+ console.log(extraSearchTerm);
9709
+ const [localData, setLocalData] = React.useState(data);
9710
+ React.useEffect(() => setLocalData(data), [data]);
9711
+ const listRef = React.useRef(null);
9712
+ const normalizedGroups = React.useMemo(() => {
9713
+ return normalizeData(isGrouped ? localData : [], isGrouped ? [] : localData);
9714
+ }, [localData, isGrouped]);
9715
+ const filterRows = React.useCallback(rows => {
9716
+ if (!extraSearchTerm) return rows;
9717
+ const query = extraSearchTerm.toLowerCase();
9718
+ return rows.filter(row => columns.some(col => {
9719
+ const val = row[col.accessor];
9720
+ if (val == null) return false;
9721
+ return String(val).toLowerCase().includes(query);
9722
+ }));
9723
+ }, [extraSearchTerm, columns]);
9724
+
9725
+ // Natural-ish comparator: handles nulls, numbers, strings, ISO dates
9726
+ const compare = (x, y, dir = "asc") => {
9727
+ const nullCmp = () => {
9728
+ if (x == null && y == null) return 0;
9729
+ if (x == null) return 1; // nulls last
9730
+ if (y == null) return -1;
9731
+ return null;
9732
+ };
9733
+ const n = nullCmp();
9734
+ if (n !== null) return n;
9735
+
9736
+ // Try numeric first
9737
+ const nx = typeof x === "number" ? x : Number.isFinite(Number(x)) ? Number(x) : null;
9738
+ const ny = typeof y === "number" ? y : Number.isFinite(Number(y)) ? Number(y) : null;
9739
+ if (nx !== null && ny !== null) {
9740
+ return dir === "asc" ? nx - ny : ny - nx;
9741
+ }
9742
+
9743
+ // Try date (ISO or parseable strings)
9744
+ const dx = typeof x === "string" ? Date.parse(x) : NaN;
9745
+ const dy = typeof y === "string" ? Date.parse(y) : NaN;
9746
+ if (!Number.isNaN(dx) && !Number.isNaN(dy)) {
9747
+ return dir === "asc" ? dx - dy : dy - dx;
9748
+ }
9749
+
9750
+ // Fallback string compare
9751
+ const sx = String(x).toLowerCase();
9752
+ const sy = String(y).toLowerCase();
9753
+ if (sx < sy) return dir === "asc" ? -1 : 1;
9754
+ if (sx > sy) return dir === "asc" ? 1 : -1;
9755
+ return 0;
9756
+ };
9757
+ const sortedGroupedData = React.useMemo(() => {
9758
+ const sortKey = sorting?.column;
9759
+ const direction = sorting?.direction || "asc";
9760
+ const sortRows = rows => {
9761
+ const arr = [...rows];
9762
+ if (!sortKey) return filterRows(arr); // fallback to drag order
9763
+ arr.sort((a, b) => compare(a?.[sortKey], b?.[sortKey], direction));
9764
+ return filterRows(arr);
9765
+ };
9766
+ return normalizedGroups.map(g => ({
9767
+ ...g,
9768
+ rows: sortRows(g.rows || [])
9769
+ }));
9770
+ }, [normalizedGroups, sorting, filterRows]);
9771
+ const [expandedGroups, setExpandedGroups] = React.useState({});
9772
+ const toggleGroup = gid => {
9773
+ setExpandedGroups(prev => ({
9774
+ ...prev,
9775
+ [gid]: !Boolean(prev[gid])
9776
+ }));
9777
+ };
9778
+ React.useEffect(() => {
9779
+ // Pre-populate expansion state for all groups
9780
+ setExpandedGroups(prev => {
9781
+ const next = {
9782
+ ...prev
9783
+ };
9784
+ for (const g of normalizedGroups) {
9785
+ const gid = g[groupKey] ?? g.groupId ?? g.groupName;
9786
+ if (!(gid in next)) next[gid] = true; // default expanded
9787
+ }
9788
+ return next;
9789
+ });
9790
+ }, [normalizedGroups, groupKey]);
9791
+ const groupRowsById = React.useMemo(() => {
9792
+ const map = {};
9793
+ for (const g of sortedGroupedData) {
9794
+ const gid = g[groupKey] ?? g.groupId ?? g.groupName;
9795
+ map[gid] = g.rows || [];
9796
+ }
9797
+ return map;
9798
+ }, [sortedGroupedData, groupKey]);
9799
+ const [tableDataFlat, setTableDataFlat] = React.useState([]);
9800
+ const flattened = React.useMemo(() => {
9801
+ const items = [];
9802
+ // Use the sortedGroupedData here so the flattened list reflects current sorting and filtering
9803
+ for (const g of sortedGroupedData) {
9804
+ const gid = g[groupKey] ?? g.groupId ?? g.groupName;
9805
+ const expanded = expandedGroups[gid] ?? true;
9806
+ if (isGrouped) {
9807
+ items.push({
9808
+ type: "group",
9809
+ groupId: gid,
9810
+ groupName: g.groupName,
9811
+ rowCount: (g.rows || []).length,
9812
+ expanded
9813
+ });
9814
+ }
9815
+ if (!isGrouped || expanded) {
9816
+ for (const row of g.rows) {
9817
+ items.push({
9818
+ type: "row",
9819
+ groupId: gid,
9820
+ row
9821
+ });
9822
+ }
9823
+ }
9824
+ }
9825
+ return items;
9826
+ }, [sortedGroupedData, expandedGroups, isGrouped, groupKey]);
9827
+ React.useEffect(() => {
9828
+ setTableDataFlat(flattened);
9829
+ }, [flattened]);
9830
+
9831
+ // useEffect(() => setTableDataFlat(flattened), [flattened]);
9832
+ React.useEffect(() => selectedRowsCallback(selectedRows), [selectedRows, selectedRowsCallback]);
9833
+
9834
+ // DELETE
9835
+ const [showConfirm, setShowConfirm] = React.useState(false);
9836
+ const [pendingDelete, setPendingDelete] = React.useState(null);
9837
+ const confirmDelete = async () => {
9838
+ if (!pendingDelete) return;
9839
+ if (deleteCallback) {
9840
+ const res = await deleteCallback(pendingDelete);
9841
+ if (!res?.success) return;
9842
+ }
9843
+ setLocalData(prev => {
9844
+ if (isGrouped) {
9845
+ return prev.map(g => ({
9846
+ ...g,
9847
+ rows: (g.rows || []).filter(r => r.id !== pendingDelete.id)
9848
+ }));
9849
+ } else {
9850
+ return (prev || []).filter(r => r.id !== pendingDelete.id);
9851
+ }
9852
+ });
9853
+ refreshTrigger?.();
9854
+ setShowConfirm(false);
9855
+ setPendingDelete(null);
9856
+ };
9857
+
9858
+ // RENDER CELL
9859
+ const highlight = React.useCallback(text => {
9860
+ if (!extraSearchTerm || typeof text !== "string") return text;
9861
+ const lower = text.toLowerCase();
9862
+ const query = extraSearchTerm.toLowerCase();
9863
+ const idx = lower.indexOf(query);
9864
+ if (idx === -1) return text;
9865
+ return /*#__PURE__*/React.createElement(React.Fragment, null, text.slice(0, idx), /*#__PURE__*/React.createElement("span", {
9866
+ className: "highlight"
9867
+ }, text.slice(idx, idx + query.length)), text.slice(idx + query.length));
9868
+ }, [extraSearchTerm]);
9869
+ const renderCell = React.useCallback((v, accessor) => {
9870
+ if (accessor === "deadlineISO") {
9871
+ return v ? new Date(v).toLocaleString("sl-SI", {
9872
+ day: "2-digit",
9873
+ month: "2-digit",
9874
+ year: "numeric",
9875
+ hour: "2-digit",
9876
+ minute: "2-digit"
9877
+ }) : "-";
9878
+ }
9879
+ // existing highlight logic for other fields
9880
+ return highlight(String(v));
9881
+ }, [highlight]);
9882
+ const showView = buttons.includes("view");
9883
+ const showEdit = buttons.includes("edit");
9884
+ const showDelete = buttons.includes("delete");
9885
+ const showActions = showView || showEdit || showDelete;
9886
+
9887
+ // MOVE ROW
9888
+ const moveRow = React.useCallback((fromIndex, toIndex) => {
9889
+ const from = tableDataFlat[fromIndex];
9890
+ const to = tableDataFlat[toIndex];
9891
+ if (!from || !to || from.type !== "row" || to.type !== "row") return;
9892
+
9893
+ // Only reorder within the same group to keep grouping consistent
9894
+ if (isGrouped && from.groupId !== to.groupId) return;
9895
+ setLocalData(prev => {
9896
+ if (isGrouped) {
9897
+ // Reorder within the target group
9898
+ const gid = from.groupId;
9899
+ return prev.map(group => {
9900
+ const groupId = group[groupKey] ?? group.groupId ?? group.groupName;
9901
+ if (groupId !== gid) return group;
9902
+ const rows = [...group.rows];
9903
+ const fromPos = rows.findIndex(r => r.id === from.row.id);
9904
+ const toPos = rows.findIndex(r => r.id === to.row.id);
9905
+ if (fromPos === -1 || toPos === -1) return group;
9906
+ const [moved] = rows.splice(fromPos, 1);
9907
+ rows.splice(toPos, 0, moved);
9908
+ return {
9909
+ ...group,
9910
+ rows
9911
+ };
9912
+ });
9913
+ } else {
9914
+ // Ungrouped: reorder the flat list
9915
+ const arr = Array.isArray(prev) ? [...prev] : [];
9916
+ const fromPos = arr.findIndex(r => r.id === from.row.id);
9917
+ const toPos = arr.findIndex(r => r.id === to.row.id);
9918
+ if (fromPos === -1 || toPos === -1) return prev;
9919
+ const [moved] = arr.splice(fromPos, 1);
9920
+ arr.splice(toPos, 0, moved);
9921
+ return arr;
9922
+ }
9923
+ });
9924
+ }, [tableDataFlat, isGrouped, groupKey]);
9925
+
9926
+ // ROW RENDERER
9927
+ const rowRenderer = React.useCallback(({
9928
+ index,
9929
+ key,
9930
+ style
9931
+ }) => {
9932
+ const item = tableDataFlat[index];
9933
+ if (!item) return null;
9934
+ if (item.type === "group") {
9935
+ const gid = item.groupId;
9936
+ const rows = groupRowsById[gid] || [];
9937
+ const allSelected = rows.length > 0 && rows.every(r => selectedRows.includes(r.id));
9938
+ return /*#__PURE__*/React.createElement("div", {
9939
+ key: key,
9940
+ style: style,
9941
+ className: "table-row group-row",
9942
+ onClick: () => toggleGroup(gid)
9943
+ }, /*#__PURE__*/React.createElement("div", {
9944
+ className: "table-cell checkbox-cell"
9945
+ }, /*#__PURE__*/React.createElement("input", {
9946
+ type: "checkbox",
9947
+ checked: allSelected,
9948
+ onChange: e => {
9949
+ e.stopPropagation();
9950
+ const ids = rows.map(r => r.id);
9951
+ ids.forEach(id => toggleRowSelection(tableId, id));
9952
+ },
9953
+ onClick: e => e.stopPropagation()
9954
+ })), showKey && /*#__PURE__*/React.createElement("div", {
9955
+ className: "table-cell key-cell"
9956
+ }), /*#__PURE__*/React.createElement("div", {
9957
+ className: "table-cell group-header"
9958
+ }, item.expanded ? "▾" : "▸", " ", item.groupName, " (", item.rowCount, ")"), columns.slice(1).map((_, i) => /*#__PURE__*/React.createElement("div", {
9959
+ key: i,
9960
+ className: "table-cell"
9961
+ })), showActions && /*#__PURE__*/React.createElement("div", {
9962
+ className: "table-cell action-cell"
9963
+ }));
9964
+ }
9965
+ const row = item.row;
9966
+ const visualIndex = tableDataFlat.slice(0, index).filter(i => i.type === "row").length + 1;
9967
+ const content = /*#__PURE__*/React.createElement("div", {
9968
+ key: key,
9969
+ style: style,
9970
+ className: "table-row"
9971
+ }, showDelete && /*#__PURE__*/React.createElement("div", {
9972
+ className: "table-cell checkbox-cell"
9973
+ }, /*#__PURE__*/React.createElement("input", {
9974
+ type: "checkbox",
9975
+ checked: selectedRows.includes(row.id),
9976
+ onChange: () => toggleRowSelection(row.id)
9977
+ })), showKey && /*#__PURE__*/React.createElement("div", {
9978
+ className: "table-cell key-cell"
9979
+ }, visualIndex), columns.map((col, i) => /*#__PURE__*/React.createElement("div", {
9980
+ key: i,
9981
+ className: "table-cell"
9982
+ }, renderCell(row[col.accessor], col.accessor))), showActions && /*#__PURE__*/React.createElement("div", {
9983
+ className: "table-cell action-cell"
9984
+ }, showView && /*#__PURE__*/React.createElement("button", {
9985
+ className: "action-btn-table",
9986
+ style: {
9987
+ background: "#646cffaa"
9988
+ },
9989
+ onClick: () => viewCallback(row)
9990
+ }, "View"), showEdit && /*#__PURE__*/React.createElement("button", {
9991
+ className: "action-btn-table",
9992
+ style: {
9993
+ background: "#4caf50"
9994
+ },
9995
+ onClick: () => editCallback(row)
9996
+ }, "Edit"), showDelete && /*#__PURE__*/React.createElement("button", {
9997
+ className: "action-btn-table",
9998
+ style: {
9999
+ background: "#f44336"
10000
+ },
10001
+ onClick: e => {
10002
+ e.stopPropagation();
10003
+ setPendingDelete(row);
10004
+ setShowConfirm(true);
10005
+ }
10006
+ }, "Delete")));
10007
+ if (enableDragRow && item.type === "row") {
10008
+ return /*#__PURE__*/React.createElement(DraggableRow, {
10009
+ key: key,
10010
+ index: index,
10011
+ moveRow: moveRow,
10012
+ item: item,
10013
+ enableDrag: true,
10014
+ listRef: listRef
10015
+ }, content);
10016
+ }
10017
+ return content;
10018
+ }, [tableDataFlat, columns, selectedRows, toggleRowSelection, groupRowsById, renderCell, showActions, showDelete, showEdit, showKey, showView, tableId, viewCallback, editCallback, enableDragRow, moveRow]);
10019
+ const rowHeightGetter = ({
10020
+ index
10021
+ }) => tableDataFlat[index]?.type === "group" ? groupHeaderHeight : rowHeight;
10022
+ return /*#__PURE__*/React.createElement(reactDnd.DndProvider, {
10023
+ backend: reactDndHtml5Backend.HTML5Backend
10024
+ }, /*#__PURE__*/React.createElement("div", {
10025
+ className: "table-container"
10026
+ }, /*#__PURE__*/React.createElement("div", {
10027
+ className: "table-header",
10028
+ style: {
10029
+ position: "sticky",
10030
+ top: 0,
10031
+ zIndex: 10,
10032
+ background: "#fff"
10033
+ }
10034
+ }, /*#__PURE__*/React.createElement("div", {
10035
+ className: "table-row header-row"
10036
+ }, showDelete && /*#__PURE__*/React.createElement("div", {
10037
+ className: "table-cell checkbox-cell"
10038
+ }, /*#__PURE__*/React.createElement("input", {
10039
+ type: "checkbox",
10040
+ checked: tableDataFlat.filter(i => i.type === "row").length > 0 && selectedRows.length === tableDataFlat.filter(i => i.type === "row").length,
10041
+ onChange: e => {
10042
+ if (e.target.checked) {
10043
+ clearSelection();
10044
+ tableDataFlat.filter(i => i.type === "row").forEach(i => toggleRowSelection(i.row.id));
10045
+ } else {
10046
+ clearSelection();
10047
+ }
10048
+ }
10049
+ })), showKey && /*#__PURE__*/React.createElement("div", {
10050
+ className: "table-cell key-cell"
10051
+ }, "#"), columns.map((col, i) => /*#__PURE__*/React.createElement("div", {
10052
+ key: i,
10053
+ className: "table-cell",
10054
+ onClick: () => setSort(col.accessor),
10055
+ style: {
10056
+ cursor: "pointer"
10057
+ }
10058
+ }, col.header, sorting?.column === col.accessor && (sorting.direction === "asc" ? " ↑" : " ↓"))), showActions && /*#__PURE__*/React.createElement("div", {
10059
+ className: "table-cell action-cell"
10060
+ }, "Action"))), /*#__PURE__*/React.createElement("div", {
10061
+ className: "main-table",
10062
+ ref: listRef
10063
+ }, tableDataFlat.length === 0 ? /*#__PURE__*/React.createElement("div", {
10064
+ className: "table-empty"
10065
+ }, "No items") : /*#__PURE__*/React.createElement(AutoSizer, null, ({
10066
+ height,
10067
+ width
10068
+ }) => /*#__PURE__*/React.createElement(List, {
10069
+ width: width,
10070
+ height: height,
10071
+ rowCount: tableDataFlat.length,
10072
+ rowHeight: rowHeightGetter,
10073
+ rowRenderer: rowRenderer,
10074
+ overscanRowCount: 8
10075
+ }))), /*#__PURE__*/React.createElement(Modal, {
10076
+ isOpen: showConfirm,
10077
+ title: "Confirm delete",
10078
+ onConfirm: confirmDelete,
10079
+ onCancel: () => setShowConfirm(false),
10080
+ confirmLabel: "Yes, delete",
10081
+ cancelLabel: "Cancel",
10082
+ showCancel: true,
10083
+ showConfirm: true
10084
+ }, /*#__PURE__*/React.createElement("p", null, "Are you sure you want to delete ", /*#__PURE__*/React.createElement("strong", null, pendingDelete?.name || pendingDelete?.id), "?"))));
10085
+ }
10086
+
10087
+ // src/index.js
10088
+ // if you want named import
10089
+
10090
+ exports.Table = Table;
10091
+ exports.default = Table;
9542
10092
  //# sourceMappingURL=index.cjs.js.map