trotl-table 1.0.13 → 1.0.14
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 +86 -86
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +61 -61
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var React
|
|
5
|
+
var React = require('react');
|
|
6
6
|
var reactDnd = require('react-dnd');
|
|
7
7
|
var reactDndHtml5Backend = require('react-dnd-html5-backend');
|
|
8
8
|
|
|
@@ -23,7 +23,7 @@ function _interopNamespaceDefault(e) {
|
|
|
23
23
|
return Object.freeze(n);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React
|
|
26
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
27
27
|
|
|
28
28
|
function _classCallCheck(a, n) {
|
|
29
29
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
@@ -912,7 +912,7 @@ var CellMeasurer = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
912
912
|
if (resolvedChildren === null) {
|
|
913
913
|
return resolvedChildren;
|
|
914
914
|
}
|
|
915
|
-
return /*#__PURE__*/React
|
|
915
|
+
return /*#__PURE__*/React.cloneElement(resolvedChildren, {
|
|
916
916
|
ref: function ref(node) {
|
|
917
917
|
if (typeof resolvedChildren.ref === 'function') {
|
|
918
918
|
resolvedChildren.ref(node);
|
|
@@ -4140,7 +4140,7 @@ function defaultCellRangeRenderer(_ref /*:: */) {
|
|
|
4140
4140
|
warnAboutMissingStyle(parent, renderedCell);
|
|
4141
4141
|
}
|
|
4142
4142
|
if (!renderedCell.props.role) {
|
|
4143
|
-
renderedCell = /*#__PURE__*/React
|
|
4143
|
+
renderedCell = /*#__PURE__*/React.cloneElement(renderedCell, {
|
|
4144
4144
|
role: 'gridcell'
|
|
4145
4145
|
});
|
|
4146
4146
|
}
|
|
@@ -9555,7 +9555,7 @@ const Modal = ({
|
|
|
9555
9555
|
closeOnEscape = true,
|
|
9556
9556
|
closeOnOutsideClick = true
|
|
9557
9557
|
}) => {
|
|
9558
|
-
React
|
|
9558
|
+
React.useEffect(() => {
|
|
9559
9559
|
const handleKey = e => {
|
|
9560
9560
|
if (e.key === 'Escape' && closeOnEscape) {
|
|
9561
9561
|
onCancel?.();
|
|
@@ -9565,22 +9565,22 @@ const Modal = ({
|
|
|
9565
9565
|
return () => document.removeEventListener('keydown', handleKey);
|
|
9566
9566
|
}, [closeOnEscape, onCancel]);
|
|
9567
9567
|
if (!isOpen) return null;
|
|
9568
|
-
return /*#__PURE__*/React
|
|
9568
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
9569
9569
|
className: "modal-overlay",
|
|
9570
9570
|
onClick: closeOnOutsideClick ? onCancel : undefined
|
|
9571
|
-
}, /*#__PURE__*/React
|
|
9571
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
9572
9572
|
className: "modal-box",
|
|
9573
9573
|
onClick: e => e.stopPropagation()
|
|
9574
|
-
}, /*#__PURE__*/React
|
|
9574
|
+
}, /*#__PURE__*/React.createElement("h3", {
|
|
9575
9575
|
className: "modal-title"
|
|
9576
|
-
}, title), /*#__PURE__*/React
|
|
9576
|
+
}, title), /*#__PURE__*/React.createElement("div", {
|
|
9577
9577
|
className: "modal-content"
|
|
9578
|
-
}, children), /*#__PURE__*/React
|
|
9578
|
+
}, children), /*#__PURE__*/React.createElement("div", {
|
|
9579
9579
|
className: "modal-actions"
|
|
9580
|
-
}, showCancel && /*#__PURE__*/React
|
|
9580
|
+
}, showCancel && /*#__PURE__*/React.createElement("button", {
|
|
9581
9581
|
className: "basic-button cancel",
|
|
9582
9582
|
onClick: onCancel
|
|
9583
|
-
}, cancelLabel), showConfirm && /*#__PURE__*/React
|
|
9583
|
+
}, cancelLabel), showConfirm && /*#__PURE__*/React.createElement("button", {
|
|
9584
9584
|
className: "basic-button confirm",
|
|
9585
9585
|
onClick: onConfirm
|
|
9586
9586
|
}, confirmLabel))));
|
|
@@ -9617,7 +9617,7 @@ const DraggableRow = ({
|
|
|
9617
9617
|
enableDrag,
|
|
9618
9618
|
listRef
|
|
9619
9619
|
}) => {
|
|
9620
|
-
const ref = React
|
|
9620
|
+
const ref = React.useRef(null);
|
|
9621
9621
|
const [, drop] = reactDnd.useDrop({
|
|
9622
9622
|
accept: ITEM_TYPE,
|
|
9623
9623
|
hover(draggedItem, monitor) {
|
|
@@ -9661,13 +9661,13 @@ const DraggableRow = ({
|
|
|
9661
9661
|
})
|
|
9662
9662
|
});
|
|
9663
9663
|
// Compose drag & drop refs in effect to avoid reading ref during render
|
|
9664
|
-
const setRef = React
|
|
9664
|
+
const setRef = React.useCallback(node => {
|
|
9665
9665
|
if (node) {
|
|
9666
9666
|
ref.current = node;
|
|
9667
9667
|
drag(drop(node));
|
|
9668
9668
|
}
|
|
9669
9669
|
}, [drag, drop]);
|
|
9670
|
-
return /*#__PURE__*/React
|
|
9670
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
9671
9671
|
ref: setRef,
|
|
9672
9672
|
style: {
|
|
9673
9673
|
opacity: isDragging ? 0.5 : 1,
|
|
@@ -9700,14 +9700,14 @@ function TableInner({
|
|
|
9700
9700
|
customColumns = []
|
|
9701
9701
|
}) {
|
|
9702
9702
|
// Local selection & sorting state (removed TableContext dependency)
|
|
9703
|
-
const [selectedRows, setSelectedRows] = React
|
|
9704
|
-
const [sorting, setSorting] = React
|
|
9703
|
+
const [selectedRows, setSelectedRows] = React.useState([]);
|
|
9704
|
+
const [sorting, setSorting] = React.useState(null);
|
|
9705
9705
|
|
|
9706
9706
|
// Option to read search param from URL
|
|
9707
|
-
const [searchTerm, setSearchTerm] = React
|
|
9707
|
+
const [searchTerm, setSearchTerm] = React.useState(extraSearchTerm);
|
|
9708
9708
|
|
|
9709
9709
|
// Listen to URL changes via popstate (back/forward) and custom events
|
|
9710
|
-
React
|
|
9710
|
+
React.useEffect(() => {
|
|
9711
9711
|
if (!enableSearchUrlParam) {
|
|
9712
9712
|
setSearchTerm(extraSearchTerm);
|
|
9713
9713
|
return;
|
|
@@ -9749,10 +9749,10 @@ function TableInner({
|
|
|
9749
9749
|
window.history.replaceState = originalReplaceState;
|
|
9750
9750
|
};
|
|
9751
9751
|
}, [enableSearchUrlParam, extraSearchTerm]);
|
|
9752
|
-
const toggleRowSelection = React
|
|
9752
|
+
const toggleRowSelection = React.useCallback(rowId => {
|
|
9753
9753
|
setSelectedRows(prev => prev.includes(rowId) ? prev.filter(r => r !== rowId) : [...prev, rowId]);
|
|
9754
9754
|
}, []);
|
|
9755
|
-
const clearSelection = React
|
|
9755
|
+
const clearSelection = React.useCallback(() => setSelectedRows([]), []);
|
|
9756
9756
|
const setSort = column => {
|
|
9757
9757
|
setSorting(prev => {
|
|
9758
9758
|
if (!prev || prev.column !== column) return {
|
|
@@ -9769,13 +9769,13 @@ function TableInner({
|
|
|
9769
9769
|
|
|
9770
9770
|
// console.log(extraSearchTerm)
|
|
9771
9771
|
|
|
9772
|
-
const [localData, setLocalData] = React
|
|
9773
|
-
React
|
|
9774
|
-
const listRef = React
|
|
9775
|
-
const normalizedGroups = React
|
|
9772
|
+
const [localData, setLocalData] = React.useState(data);
|
|
9773
|
+
React.useEffect(() => setLocalData(data), [data]);
|
|
9774
|
+
const listRef = React.useRef(null);
|
|
9775
|
+
const normalizedGroups = React.useMemo(() => {
|
|
9776
9776
|
return normalizeData(isGrouped ? localData : [], isGrouped ? [] : localData);
|
|
9777
9777
|
}, [localData, isGrouped]);
|
|
9778
|
-
const filterRows = React
|
|
9778
|
+
const filterRows = React.useCallback(rows => {
|
|
9779
9779
|
if (!searchTerm) return rows;
|
|
9780
9780
|
const query = searchTerm.toLowerCase();
|
|
9781
9781
|
return rows.filter(row => columns.some(col => {
|
|
@@ -9817,7 +9817,7 @@ function TableInner({
|
|
|
9817
9817
|
if (sx > sy) return dir === "asc" ? 1 : -1;
|
|
9818
9818
|
return 0;
|
|
9819
9819
|
};
|
|
9820
|
-
const sortedGroupedData = React
|
|
9820
|
+
const sortedGroupedData = React.useMemo(() => {
|
|
9821
9821
|
const sortKey = sorting?.column;
|
|
9822
9822
|
const direction = sorting?.direction || "asc";
|
|
9823
9823
|
const sortRows = rows => {
|
|
@@ -9831,14 +9831,14 @@ function TableInner({
|
|
|
9831
9831
|
rows: sortRows(g.rows || [])
|
|
9832
9832
|
}));
|
|
9833
9833
|
}, [normalizedGroups, sorting, filterRows]);
|
|
9834
|
-
const [expandedGroups, setExpandedGroups] = React
|
|
9834
|
+
const [expandedGroups, setExpandedGroups] = React.useState({});
|
|
9835
9835
|
const toggleGroup = gid => {
|
|
9836
9836
|
setExpandedGroups(prev => ({
|
|
9837
9837
|
...prev,
|
|
9838
9838
|
[gid]: !prev[gid]
|
|
9839
9839
|
}));
|
|
9840
9840
|
};
|
|
9841
|
-
React
|
|
9841
|
+
React.useEffect(() => {
|
|
9842
9842
|
// Pre-populate expansion state for all groups
|
|
9843
9843
|
setExpandedGroups(prev => {
|
|
9844
9844
|
const next = {
|
|
@@ -9851,7 +9851,7 @@ function TableInner({
|
|
|
9851
9851
|
return next;
|
|
9852
9852
|
});
|
|
9853
9853
|
}, [normalizedGroups, groupKey]);
|
|
9854
|
-
const groupRowsById = React
|
|
9854
|
+
const groupRowsById = React.useMemo(() => {
|
|
9855
9855
|
const map = {};
|
|
9856
9856
|
for (const g of sortedGroupedData) {
|
|
9857
9857
|
const gid = g[groupKey] ?? g.groupId ?? g.groupName;
|
|
@@ -9859,8 +9859,8 @@ function TableInner({
|
|
|
9859
9859
|
}
|
|
9860
9860
|
return map;
|
|
9861
9861
|
}, [sortedGroupedData, groupKey]);
|
|
9862
|
-
const [tableDataFlat, setTableDataFlat] = React
|
|
9863
|
-
const flattened = React
|
|
9862
|
+
const [tableDataFlat, setTableDataFlat] = React.useState([]);
|
|
9863
|
+
const flattened = React.useMemo(() => {
|
|
9864
9864
|
const items = [];
|
|
9865
9865
|
// Use the sortedGroupedData here so the flattened list reflects current sorting and filtering
|
|
9866
9866
|
for (const g of sortedGroupedData) {
|
|
@@ -9887,16 +9887,16 @@ function TableInner({
|
|
|
9887
9887
|
}
|
|
9888
9888
|
return items;
|
|
9889
9889
|
}, [sortedGroupedData, expandedGroups, isGrouped, groupKey]);
|
|
9890
|
-
React
|
|
9890
|
+
React.useEffect(() => {
|
|
9891
9891
|
setTableDataFlat(flattened);
|
|
9892
9892
|
}, [flattened]);
|
|
9893
9893
|
|
|
9894
9894
|
// useEffect(() => setTableDataFlat(flattened), [flattened]);
|
|
9895
|
-
React
|
|
9895
|
+
React.useEffect(() => selectedRowsCallback(selectedRows), [selectedRows, selectedRowsCallback]);
|
|
9896
9896
|
|
|
9897
9897
|
// DELETE
|
|
9898
|
-
const [showConfirm, setShowConfirm] = React
|
|
9899
|
-
const [pendingDelete, setPendingDelete] = React
|
|
9898
|
+
const [showConfirm, setShowConfirm] = React.useState(false);
|
|
9899
|
+
const [pendingDelete, setPendingDelete] = React.useState(null);
|
|
9900
9900
|
const confirmDelete = async () => {
|
|
9901
9901
|
if (!pendingDelete) return;
|
|
9902
9902
|
if (deleteCallback) {
|
|
@@ -9919,18 +9919,18 @@ function TableInner({
|
|
|
9919
9919
|
};
|
|
9920
9920
|
|
|
9921
9921
|
// RENDER CELL
|
|
9922
|
-
const highlight = React
|
|
9922
|
+
const highlight = React.useCallback(text => {
|
|
9923
9923
|
// Use the actual searchTerm (from URL or prop) for highlighting
|
|
9924
9924
|
if (!searchTerm || typeof text !== "string") return text;
|
|
9925
9925
|
const lower = text.toLowerCase();
|
|
9926
9926
|
const query = searchTerm.toLowerCase();
|
|
9927
9927
|
const idx = lower.indexOf(query);
|
|
9928
9928
|
if (idx === -1) return text;
|
|
9929
|
-
return /*#__PURE__*/React
|
|
9929
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, text.slice(0, idx), /*#__PURE__*/React.createElement("span", {
|
|
9930
9930
|
className: "highlight"
|
|
9931
9931
|
}, text.slice(idx, idx + query.length)), text.slice(idx + query.length));
|
|
9932
9932
|
}, [searchTerm]);
|
|
9933
|
-
const renderCell = React
|
|
9933
|
+
const renderCell = React.useCallback((v, accessor) => {
|
|
9934
9934
|
if (accessor === "deadlineISO") {
|
|
9935
9935
|
return v ? new Date(v).toLocaleString("sl-SI", {
|
|
9936
9936
|
day: "2-digit",
|
|
@@ -9950,7 +9950,7 @@ function TableInner({
|
|
|
9950
9950
|
|
|
9951
9951
|
// MOVE ROW (internal + between groups)
|
|
9952
9952
|
// moveRow: allow toIndex to be null or an object { emptyGroupId } for empty group drop
|
|
9953
|
-
const moveRow = React
|
|
9953
|
+
const moveRow = React.useCallback((fromIndex, toIndexOrGroup) => {
|
|
9954
9954
|
const from = tableDataFlat[fromIndex];
|
|
9955
9955
|
let to = null;
|
|
9956
9956
|
let emptyGroupId = null;
|
|
@@ -10038,7 +10038,7 @@ function TableInner({
|
|
|
10038
10038
|
}, [tableDataFlat, isGrouped, groupKey]);
|
|
10039
10039
|
|
|
10040
10040
|
// ROW RENDERER
|
|
10041
|
-
const rowRenderer = React
|
|
10041
|
+
const rowRenderer = React.useCallback(({
|
|
10042
10042
|
index,
|
|
10043
10043
|
key,
|
|
10044
10044
|
style
|
|
@@ -10054,7 +10054,7 @@ function TableInner({
|
|
|
10054
10054
|
if (item.expanded && rows.length === 0 && enableDragRow) {
|
|
10055
10055
|
// For empty group, drop target pushes into this group
|
|
10056
10056
|
const GroupHeaderDrop = () => {
|
|
10057
|
-
const ref = React
|
|
10057
|
+
const ref = React.useRef(null);
|
|
10058
10058
|
const [, drop] = reactDnd.useDrop({
|
|
10059
10059
|
accept: ITEM_TYPE,
|
|
10060
10060
|
drop(draggedItem) {
|
|
@@ -10071,7 +10071,7 @@ function TableInner({
|
|
|
10071
10071
|
})
|
|
10072
10072
|
});
|
|
10073
10073
|
drop(ref);
|
|
10074
|
-
return /*#__PURE__*/React
|
|
10074
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
10075
10075
|
ref: ref,
|
|
10076
10076
|
key: key,
|
|
10077
10077
|
style: {
|
|
@@ -10086,9 +10086,9 @@ function TableInner({
|
|
|
10086
10086
|
},
|
|
10087
10087
|
className: "table-row group-row empty-group-drop",
|
|
10088
10088
|
onClick: () => toggleGroup(gid)
|
|
10089
|
-
}, enableMultiSelect && showDelete && /*#__PURE__*/React
|
|
10089
|
+
}, enableMultiSelect && showDelete && /*#__PURE__*/React.createElement("div", {
|
|
10090
10090
|
className: "table-cell checkbox-cell"
|
|
10091
|
-
}, /*#__PURE__*/React
|
|
10091
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
10092
10092
|
type: "checkbox",
|
|
10093
10093
|
checked: allSelected,
|
|
10094
10094
|
onChange: e => {
|
|
@@ -10101,31 +10101,31 @@ function TableInner({
|
|
|
10101
10101
|
}
|
|
10102
10102
|
},
|
|
10103
10103
|
onClick: e => e.stopPropagation()
|
|
10104
|
-
})), showKey && /*#__PURE__*/React
|
|
10104
|
+
})), showKey && /*#__PURE__*/React.createElement("div", {
|
|
10105
10105
|
className: "table-cell key-cell"
|
|
10106
|
-
}), /*#__PURE__*/React
|
|
10106
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
10107
10107
|
className: "table-cell group-header",
|
|
10108
10108
|
style: {
|
|
10109
10109
|
width: '100%'
|
|
10110
10110
|
}
|
|
10111
|
-
}, item.expanded ? "▾" : "▸", " ", item.groupName, " (0) \u2014 Drop here to move into this group"), columns.slice(1).map((_, i) => /*#__PURE__*/React
|
|
10111
|
+
}, item.expanded ? "▾" : "▸", " ", item.groupName, " (0) \u2014 Drop here to move into this group"), columns.slice(1).map((_, i) => /*#__PURE__*/React.createElement("div", {
|
|
10112
10112
|
key: i,
|
|
10113
10113
|
className: "table-cell"
|
|
10114
|
-
})), showActions && /*#__PURE__*/React
|
|
10114
|
+
})), showActions && /*#__PURE__*/React.createElement("div", {
|
|
10115
10115
|
className: "table-cell action-cell"
|
|
10116
10116
|
}));
|
|
10117
10117
|
};
|
|
10118
|
-
return /*#__PURE__*/React
|
|
10118
|
+
return /*#__PURE__*/React.createElement(GroupHeaderDrop, null);
|
|
10119
10119
|
}
|
|
10120
10120
|
// Default: normal group header
|
|
10121
|
-
return /*#__PURE__*/React
|
|
10121
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
10122
10122
|
key: key,
|
|
10123
10123
|
style: style,
|
|
10124
10124
|
className: "table-row group-row",
|
|
10125
10125
|
onClick: () => toggleGroup(gid)
|
|
10126
|
-
}, enableMultiSelect && showDelete && /*#__PURE__*/React
|
|
10126
|
+
}, enableMultiSelect && showDelete && /*#__PURE__*/React.createElement("div", {
|
|
10127
10127
|
className: "table-cell checkbox-cell"
|
|
10128
|
-
}, /*#__PURE__*/React
|
|
10128
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
10129
10129
|
type: "checkbox",
|
|
10130
10130
|
checked: allSelected,
|
|
10131
10131
|
onChange: e => {
|
|
@@ -10138,14 +10138,14 @@ function TableInner({
|
|
|
10138
10138
|
}
|
|
10139
10139
|
},
|
|
10140
10140
|
onClick: e => e.stopPropagation()
|
|
10141
|
-
})), showKey && /*#__PURE__*/React
|
|
10141
|
+
})), showKey && /*#__PURE__*/React.createElement("div", {
|
|
10142
10142
|
className: "table-cell key-cell"
|
|
10143
|
-
}), /*#__PURE__*/React
|
|
10143
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
10144
10144
|
className: "table-cell group-header"
|
|
10145
|
-
}, item.expanded ? "▾" : "▸", " ", item.groupName, " (", item.rowCount, ")"), columns.slice(1).map((_, i) => /*#__PURE__*/React
|
|
10145
|
+
}, item.expanded ? "▾" : "▸", " ", item.groupName, " (", item.rowCount, ")"), columns.slice(1).map((_, i) => /*#__PURE__*/React.createElement("div", {
|
|
10146
10146
|
key: i,
|
|
10147
10147
|
className: "table-cell"
|
|
10148
|
-
})), showActions && /*#__PURE__*/React
|
|
10148
|
+
})), showActions && /*#__PURE__*/React.createElement("div", {
|
|
10149
10149
|
className: "table-cell action-cell"
|
|
10150
10150
|
}));
|
|
10151
10151
|
}
|
|
@@ -10165,17 +10165,17 @@ function TableInner({
|
|
|
10165
10165
|
}
|
|
10166
10166
|
});
|
|
10167
10167
|
}
|
|
10168
|
-
const content = /*#__PURE__*/React
|
|
10168
|
+
const content = /*#__PURE__*/React.createElement("div", {
|
|
10169
10169
|
key: key,
|
|
10170
10170
|
style: style,
|
|
10171
10171
|
className: "table-row"
|
|
10172
|
-
}, enableMultiSelect && showDelete && /*#__PURE__*/React
|
|
10172
|
+
}, enableMultiSelect && showDelete && /*#__PURE__*/React.createElement("div", {
|
|
10173
10173
|
className: "table-cell checkbox-cell"
|
|
10174
|
-
}, /*#__PURE__*/React
|
|
10174
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
10175
10175
|
type: "checkbox",
|
|
10176
10176
|
checked: selectedRows.includes(row.id),
|
|
10177
10177
|
onChange: () => toggleRowSelection(row.id)
|
|
10178
|
-
})), showKey && /*#__PURE__*/React
|
|
10178
|
+
})), showKey && /*#__PURE__*/React.createElement("div", {
|
|
10179
10179
|
className: "table-cell key-cell"
|
|
10180
10180
|
}, visualIndex), allColumns.map((col, i) => {
|
|
10181
10181
|
let cellStyle = col.isCustom && col.style ? {
|
|
@@ -10187,26 +10187,26 @@ function TableInner({
|
|
|
10187
10187
|
cellStyle.maxWidth = col.style.width;
|
|
10188
10188
|
cellStyle.width = col.style.width;
|
|
10189
10189
|
}
|
|
10190
|
-
return /*#__PURE__*/React
|
|
10190
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
10191
10191
|
key: i,
|
|
10192
10192
|
className: "table-cell",
|
|
10193
10193
|
style: cellStyle
|
|
10194
10194
|
}, col.isCustom ? typeof col.render === 'function' ? col.render(row, i) : col.render : renderCell(row[col.accessor], col.accessor, row));
|
|
10195
|
-
}), showActions && /*#__PURE__*/React
|
|
10195
|
+
}), showActions && /*#__PURE__*/React.createElement("div", {
|
|
10196
10196
|
className: "table-cell action-cell"
|
|
10197
|
-
}, showView && /*#__PURE__*/React
|
|
10197
|
+
}, showView && /*#__PURE__*/React.createElement("button", {
|
|
10198
10198
|
className: "action-btn-table",
|
|
10199
10199
|
style: {
|
|
10200
10200
|
background: "#646cffaa"
|
|
10201
10201
|
},
|
|
10202
10202
|
onClick: () => viewCallback(row)
|
|
10203
|
-
}, "View"), showEdit && /*#__PURE__*/React
|
|
10203
|
+
}, "View"), showEdit && /*#__PURE__*/React.createElement("button", {
|
|
10204
10204
|
className: "action-btn-table",
|
|
10205
10205
|
style: {
|
|
10206
10206
|
background: "#4caf50"
|
|
10207
10207
|
},
|
|
10208
10208
|
onClick: () => editCallback(row)
|
|
10209
|
-
}, "Edit"), showDelete && /*#__PURE__*/React
|
|
10209
|
+
}, "Edit"), showDelete && /*#__PURE__*/React.createElement("button", {
|
|
10210
10210
|
className: "action-btn-table",
|
|
10211
10211
|
style: {
|
|
10212
10212
|
background: "#f44336"
|
|
@@ -10218,7 +10218,7 @@ function TableInner({
|
|
|
10218
10218
|
}
|
|
10219
10219
|
}, "Delete")));
|
|
10220
10220
|
if (enableDragRow && item.type === "row") {
|
|
10221
|
-
return /*#__PURE__*/React
|
|
10221
|
+
return /*#__PURE__*/React.createElement(DraggableRow, {
|
|
10222
10222
|
key: key,
|
|
10223
10223
|
index: index,
|
|
10224
10224
|
moveRow: moveRow,
|
|
@@ -10235,7 +10235,7 @@ function TableInner({
|
|
|
10235
10235
|
}) => tableDataFlat[index]?.type === "group" ? groupHeaderHeight : rowHeight;
|
|
10236
10236
|
|
|
10237
10237
|
// Table-level drop target only when using external DnD context
|
|
10238
|
-
const tableContainerRef = React
|
|
10238
|
+
const tableContainerRef = React.useRef(null);
|
|
10239
10239
|
const [{
|
|
10240
10240
|
isOver: isExternalOver,
|
|
10241
10241
|
canDrop: canExternalDrop
|
|
@@ -10248,7 +10248,7 @@ function TableInner({
|
|
|
10248
10248
|
onExternalRowDrop(draggedItem.row, draggedItem.sourceTableId, tableId);
|
|
10249
10249
|
}
|
|
10250
10250
|
});
|
|
10251
|
-
const setTableRef = React
|
|
10251
|
+
const setTableRef = React.useCallback(node => {
|
|
10252
10252
|
tableContainerRef.current = node;
|
|
10253
10253
|
if (node && useExternalDndContext && enableExternalRowDrop) {
|
|
10254
10254
|
externalDrop(node);
|
|
@@ -10267,7 +10267,7 @@ function TableInner({
|
|
|
10267
10267
|
}
|
|
10268
10268
|
});
|
|
10269
10269
|
}
|
|
10270
|
-
const tableMarkup = /*#__PURE__*/React
|
|
10270
|
+
const tableMarkup = /*#__PURE__*/React.createElement("div", {
|
|
10271
10271
|
className: "table-container",
|
|
10272
10272
|
ref: setTableRef,
|
|
10273
10273
|
style: useExternalDndContext && enableExternalRowDrop ? {
|
|
@@ -10275,7 +10275,7 @@ function TableInner({
|
|
|
10275
10275
|
background: isExternalOver && canExternalDrop ? 'rgba(100,108,255,0.15)' : undefined,
|
|
10276
10276
|
outline: isExternalOver && canExternalDrop ? '2px dashed #646cff' : undefined
|
|
10277
10277
|
} : undefined
|
|
10278
|
-
}, /*#__PURE__*/React
|
|
10278
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
10279
10279
|
className: "table-header",
|
|
10280
10280
|
style: {
|
|
10281
10281
|
position: "sticky",
|
|
@@ -10283,11 +10283,11 @@ function TableInner({
|
|
|
10283
10283
|
zIndex: 10,
|
|
10284
10284
|
background: "#fff"
|
|
10285
10285
|
}
|
|
10286
|
-
}, /*#__PURE__*/React
|
|
10286
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
10287
10287
|
className: "table-row header-row"
|
|
10288
|
-
}, enableMultiSelect && showDelete && /*#__PURE__*/React
|
|
10288
|
+
}, enableMultiSelect && showDelete && /*#__PURE__*/React.createElement("div", {
|
|
10289
10289
|
className: "table-cell checkbox-cell"
|
|
10290
|
-
}, /*#__PURE__*/React
|
|
10290
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
10291
10291
|
type: "checkbox",
|
|
10292
10292
|
checked: tableDataFlat.filter(i => i.type === "row").length > 0 && selectedRows.length === tableDataFlat.filter(i => i.type === "row").length,
|
|
10293
10293
|
onChange: e => {
|
|
@@ -10298,7 +10298,7 @@ function TableInner({
|
|
|
10298
10298
|
clearSelection();
|
|
10299
10299
|
}
|
|
10300
10300
|
}
|
|
10301
|
-
})), showKey && /*#__PURE__*/React
|
|
10301
|
+
})), showKey && /*#__PURE__*/React.createElement("div", {
|
|
10302
10302
|
className: "table-cell key-cell"
|
|
10303
10303
|
}, "#"), allColumns.map((col, i) => {
|
|
10304
10304
|
// For custom columns, apply width and textAlign to header cell
|
|
@@ -10316,30 +10316,30 @@ function TableInner({
|
|
|
10316
10316
|
cellStyle.maxWidth = col.style.width;
|
|
10317
10317
|
cellStyle.width = col.style.width;
|
|
10318
10318
|
}
|
|
10319
|
-
return /*#__PURE__*/React
|
|
10319
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
10320
10320
|
key: i,
|
|
10321
10321
|
className: "table-cell",
|
|
10322
10322
|
style: cellStyle,
|
|
10323
10323
|
onClick: col.isCustom ? undefined : () => setSort(col.accessor)
|
|
10324
10324
|
}, col.isCustom ? col.header ?? '' : col.header, !col.isCustom && sorting?.column === col.accessor && (sorting.direction === "asc" ? " ↑" : " ↓"));
|
|
10325
|
-
}), showActions && /*#__PURE__*/React
|
|
10325
|
+
}), showActions && /*#__PURE__*/React.createElement("div", {
|
|
10326
10326
|
className: "table-cell action-cell"
|
|
10327
|
-
}, "Action"))), /*#__PURE__*/React
|
|
10327
|
+
}, "Action"))), /*#__PURE__*/React.createElement("div", {
|
|
10328
10328
|
className: "main-table",
|
|
10329
10329
|
ref: listRef
|
|
10330
|
-
}, tableDataFlat.length === 0 ? /*#__PURE__*/React
|
|
10330
|
+
}, tableDataFlat.length === 0 ? /*#__PURE__*/React.createElement("div", {
|
|
10331
10331
|
className: "table-empty"
|
|
10332
|
-
}, "No items") : /*#__PURE__*/React
|
|
10332
|
+
}, "No items") : /*#__PURE__*/React.createElement(AutoSizer, null, ({
|
|
10333
10333
|
height,
|
|
10334
10334
|
width
|
|
10335
|
-
}) => /*#__PURE__*/React
|
|
10335
|
+
}) => /*#__PURE__*/React.createElement(List, {
|
|
10336
10336
|
width: width,
|
|
10337
10337
|
height: height,
|
|
10338
10338
|
rowCount: tableDataFlat.length,
|
|
10339
10339
|
rowHeight: rowHeightGetter,
|
|
10340
10340
|
rowRenderer: rowRenderer,
|
|
10341
10341
|
overscanRowCount: 8
|
|
10342
|
-
}))), /*#__PURE__*/React
|
|
10342
|
+
}))), /*#__PURE__*/React.createElement(Modal, {
|
|
10343
10343
|
isOpen: showConfirm,
|
|
10344
10344
|
title: "Confirm delete",
|
|
10345
10345
|
onConfirm: confirmDelete,
|
|
@@ -10348,7 +10348,7 @@ function TableInner({
|
|
|
10348
10348
|
cancelLabel: "Cancel",
|
|
10349
10349
|
showCancel: true,
|
|
10350
10350
|
showConfirm: true
|
|
10351
|
-
}, /*#__PURE__*/React
|
|
10351
|
+
}, /*#__PURE__*/React.createElement("p", null, "Are you sure you want to delete ", /*#__PURE__*/React.createElement("strong", null, pendingDelete?.name || pendingDelete?.id), "?")));
|
|
10352
10352
|
return tableMarkup;
|
|
10353
10353
|
}
|
|
10354
10354
|
function Table(props) {
|
|
@@ -10356,12 +10356,12 @@ function Table(props) {
|
|
|
10356
10356
|
useExternalDndContext = false
|
|
10357
10357
|
} = props;
|
|
10358
10358
|
if (useExternalDndContext) {
|
|
10359
|
-
return /*#__PURE__*/React
|
|
10359
|
+
return /*#__PURE__*/React.createElement(TableInner, props);
|
|
10360
10360
|
}
|
|
10361
10361
|
// Provide DnD context when not supplied externally
|
|
10362
|
-
return /*#__PURE__*/React
|
|
10362
|
+
return /*#__PURE__*/React.createElement(reactDnd.DndProvider, {
|
|
10363
10363
|
backend: reactDndHtml5Backend.HTML5Backend
|
|
10364
|
-
}, /*#__PURE__*/React
|
|
10364
|
+
}, /*#__PURE__*/React.createElement(TableInner, props));
|
|
10365
10365
|
}
|
|
10366
10366
|
|
|
10367
10367
|
function Switch({
|