@dreamtree-org/twreact-ui 1.0.83 → 1.0.85
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.css +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +257 -163
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +257 -163
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -3941,10 +3941,71 @@ var ActionMenu = /*#__PURE__*/memo(function ActionMenu(_ref) {
|
|
|
3941
3941
|
actions = _ref$actions === void 0 ? [] : _ref$actions,
|
|
3942
3942
|
row = _ref.row,
|
|
3943
3943
|
onAction = _ref.onAction,
|
|
3944
|
-
menuRef = _ref.menuRef
|
|
3944
|
+
menuRef = _ref.menuRef,
|
|
3945
|
+
anchorEl = _ref.anchorEl,
|
|
3946
|
+
onClose = _ref.onClose;
|
|
3947
|
+
var _useState = useState({
|
|
3948
|
+
top: 0,
|
|
3949
|
+
left: 0,
|
|
3950
|
+
visibility: "hidden"
|
|
3951
|
+
}),
|
|
3952
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3953
|
+
pos = _useState2[0],
|
|
3954
|
+
setPos = _useState2[1];
|
|
3955
|
+
|
|
3956
|
+
// compute position after mount / when anchor changes
|
|
3957
|
+
useLayoutEffect(function () {
|
|
3958
|
+
if (!anchorEl || !(menuRef !== null && menuRef !== void 0 && menuRef.current) || typeof window === "undefined") {
|
|
3959
|
+
setPos(function (p) {
|
|
3960
|
+
return _objectSpread$9(_objectSpread$9({}, p), {}, {
|
|
3961
|
+
visibility: "hidden"
|
|
3962
|
+
});
|
|
3963
|
+
});
|
|
3964
|
+
return;
|
|
3965
|
+
}
|
|
3966
|
+
var menu = menuRef.current;
|
|
3967
|
+
var rect = anchorEl.getBoundingClientRect();
|
|
3968
|
+
var menuWidth = menu.offsetWidth || 176; // w-44 ~ 176px fallback
|
|
3969
|
+
var menuHeight = menu.offsetHeight || menu.scrollHeight || 200;
|
|
3970
|
+
var viewportWidth = window.innerWidth;
|
|
3971
|
+
var viewportHeight = window.innerHeight;
|
|
3972
|
+
var scrollX = window.scrollX || window.pageXOffset || 0;
|
|
3973
|
+
var scrollY = window.scrollY || window.pageYOffset || 0;
|
|
3974
|
+
|
|
3975
|
+
// prefer placing below the button
|
|
3976
|
+
var preferBelowTop = rect.bottom + scrollY + 6;
|
|
3977
|
+
var preferAboveTop = rect.top + scrollY - menuHeight - 6;
|
|
3978
|
+
|
|
3979
|
+
// compute left so right-aligned to the button's right edge
|
|
3980
|
+
var left = rect.right + scrollX - menuWidth;
|
|
3981
|
+
if (left < 8) left = 8;
|
|
3982
|
+
if (left + menuWidth > viewportWidth - 8) left = Math.max(8, viewportWidth - menuWidth - 8);
|
|
3983
|
+
|
|
3984
|
+
// choose top based on available space
|
|
3985
|
+
var top;
|
|
3986
|
+
if (preferBelowTop + menuHeight <= scrollY + viewportHeight - 8) {
|
|
3987
|
+
top = preferBelowTop;
|
|
3988
|
+
} else if (preferAboveTop >= scrollY + 8) {
|
|
3989
|
+
top = preferAboveTop;
|
|
3990
|
+
} else {
|
|
3991
|
+
// fallback: clamp inside viewport
|
|
3992
|
+
top = Math.max(scrollY + 8, Math.min(preferBelowTop, scrollY + viewportHeight - menuHeight - 8));
|
|
3993
|
+
}
|
|
3994
|
+
setPos({
|
|
3995
|
+
top: top,
|
|
3996
|
+
left: left,
|
|
3997
|
+
visibility: "visible"
|
|
3998
|
+
});
|
|
3999
|
+
}, [anchorEl, menuRef, actions, row]);
|
|
3945
4000
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
3946
4001
|
ref: menuRef,
|
|
3947
|
-
className: "
|
|
4002
|
+
className: "fixed z-50 bg-white rounded-lg shadow-lg ring-1 ring-black ring-opacity-5",
|
|
4003
|
+
style: {
|
|
4004
|
+
top: pos.top,
|
|
4005
|
+
left: pos.left,
|
|
4006
|
+
visibility: pos.visibility,
|
|
4007
|
+
minWidth: 176 // match w-44 fallback
|
|
4008
|
+
},
|
|
3948
4009
|
onClick: function onClick(e) {
|
|
3949
4010
|
return e.stopPropagation();
|
|
3950
4011
|
}
|
|
@@ -3961,6 +4022,7 @@ var ActionMenu = /*#__PURE__*/memo(function ActionMenu(_ref) {
|
|
|
3961
4022
|
onClick: function onClick(e) {
|
|
3962
4023
|
e.stopPropagation();
|
|
3963
4024
|
onAction === null || onAction === void 0 || onAction(action, row);
|
|
4025
|
+
onClose === null || onClose === void 0 || onClose();
|
|
3964
4026
|
}
|
|
3965
4027
|
}, action.render ? action.render(row) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, action.icon && /*#__PURE__*/React__default.createElement("span", {
|
|
3966
4028
|
className: "inline-flex"
|
|
@@ -3978,9 +4040,11 @@ function useClickOutside(refs, isActive, onClickOutside) {
|
|
|
3978
4040
|
});
|
|
3979
4041
|
if (isOutside) onClickOutside();
|
|
3980
4042
|
};
|
|
3981
|
-
|
|
4043
|
+
|
|
4044
|
+
// Use capture phase to ensure we handle clicks before they bubble
|
|
4045
|
+
document.addEventListener("mousedown", handler, true);
|
|
3982
4046
|
return function () {
|
|
3983
|
-
return document.removeEventListener("
|
|
4047
|
+
return document.removeEventListener("mousedown", handler, true);
|
|
3984
4048
|
};
|
|
3985
4049
|
}, [refs, isActive, onClickOutside]);
|
|
3986
4050
|
}
|
|
@@ -4050,90 +4114,91 @@ var Table = function Table(_ref2) {
|
|
|
4050
4114
|
pageNumber = _ref2.pageNumber,
|
|
4051
4115
|
props = _objectWithoutProperties$1(_ref2, _excluded$k);
|
|
4052
4116
|
// Core state
|
|
4053
|
-
var
|
|
4054
|
-
|
|
4055
|
-
isMobileView =
|
|
4056
|
-
setIsMobileView =
|
|
4057
|
-
var
|
|
4117
|
+
var _useState3 = useState(false),
|
|
4118
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
4119
|
+
isMobileView = _useState4[0],
|
|
4120
|
+
setIsMobileView = _useState4[1];
|
|
4121
|
+
var _useState5 = useState(function () {
|
|
4058
4122
|
return Array.isArray(data) ? data : [];
|
|
4059
4123
|
}),
|
|
4060
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
4061
|
-
tableData = _useState4[0],
|
|
4062
|
-
setTableData = _useState4[1];
|
|
4063
|
-
var _useState5 = useState(false),
|
|
4064
4124
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
var _useState7 = useState(
|
|
4125
|
+
tableData = _useState6[0],
|
|
4126
|
+
setTableData = _useState6[1];
|
|
4127
|
+
var _useState7 = useState(false),
|
|
4068
4128
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
var _useState9 = useState(
|
|
4129
|
+
loading = _useState8[0],
|
|
4130
|
+
setLoading = _useState8[1];
|
|
4131
|
+
var _useState9 = useState(pageSize),
|
|
4132
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
4133
|
+
limit = _useState0[0],
|
|
4134
|
+
setLimit = _useState0[1];
|
|
4135
|
+
var _useState1 = useState(function () {
|
|
4072
4136
|
return typeof pageNumber === "number" ? pageNumber : 1;
|
|
4073
4137
|
}),
|
|
4074
|
-
|
|
4075
|
-
currentPage =
|
|
4076
|
-
setCurrentPage =
|
|
4138
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
4139
|
+
currentPage = _useState10[0],
|
|
4140
|
+
setCurrentPage = _useState10[1];
|
|
4077
4141
|
|
|
4078
4142
|
// Column state
|
|
4079
|
-
var
|
|
4143
|
+
var _useState11 = useState(function () {
|
|
4080
4144
|
return Array.isArray(columns) ? columns.map(function (c) {
|
|
4081
4145
|
return _objectSpread$9({}, c);
|
|
4082
4146
|
}) : [];
|
|
4083
4147
|
}),
|
|
4084
|
-
_useState10 = _slicedToArray(_useState1, 2),
|
|
4085
|
-
columnsState = _useState10[0],
|
|
4086
|
-
setColumnsState = _useState10[1];
|
|
4087
|
-
var _useState11 = useState(false),
|
|
4088
4148
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
4089
|
-
|
|
4090
|
-
|
|
4149
|
+
columnsState = _useState12[0],
|
|
4150
|
+
setColumnsState = _useState12[1];
|
|
4151
|
+
var _useState13 = useState(false),
|
|
4152
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
4153
|
+
showColumnMenu = _useState14[0],
|
|
4154
|
+
setShowColumnMenu = _useState14[1];
|
|
4091
4155
|
|
|
4092
4156
|
// Sorting/filtering state
|
|
4093
|
-
var
|
|
4157
|
+
var _useState15 = useState({
|
|
4094
4158
|
key: null,
|
|
4095
4159
|
direction: "asc"
|
|
4096
4160
|
}),
|
|
4097
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
4098
|
-
sortConfig = _useState14[0],
|
|
4099
|
-
setSortConfig = _useState14[1];
|
|
4100
|
-
var _useState15 = useState({}),
|
|
4101
4161
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
var _useState17 = useState(
|
|
4162
|
+
sortConfig = _useState16[0],
|
|
4163
|
+
setSortConfig = _useState16[1];
|
|
4164
|
+
var _useState17 = useState({}),
|
|
4105
4165
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
4106
|
-
|
|
4107
|
-
|
|
4166
|
+
filters = _useState18[0],
|
|
4167
|
+
setFilters = _useState18[1];
|
|
4168
|
+
var _useState19 = useState(""),
|
|
4169
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
4170
|
+
searchInput = _useState20[0],
|
|
4171
|
+
setSearchInput = _useState20[1];
|
|
4108
4172
|
|
|
4109
4173
|
// Selection/expansion state
|
|
4110
|
-
var _useState19 = useState(function () {
|
|
4111
|
-
return new Set();
|
|
4112
|
-
}),
|
|
4113
|
-
_useState20 = _slicedToArray(_useState19, 2),
|
|
4114
|
-
selectedRows = _useState20[0],
|
|
4115
|
-
setSelectedRows = _useState20[1];
|
|
4116
4174
|
var _useState21 = useState(function () {
|
|
4117
4175
|
return new Set();
|
|
4118
4176
|
}),
|
|
4119
4177
|
_useState22 = _slicedToArray(_useState21, 2),
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4178
|
+
selectedRows = _useState22[0],
|
|
4179
|
+
setSelectedRows = _useState22[1];
|
|
4180
|
+
var _useState23 = useState(function () {
|
|
4181
|
+
return new Set();
|
|
4182
|
+
}),
|
|
4125
4183
|
_useState24 = _slicedToArray(_useState23, 2),
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4184
|
+
expandedRows = _useState24[0],
|
|
4185
|
+
setExpandedRows = _useState24[1];
|
|
4186
|
+
|
|
4187
|
+
// Action menu state - simplified to just store the clicked row key
|
|
4188
|
+
var _useState25 = useState(null),
|
|
4129
4189
|
_useState26 = _slicedToArray(_useState25, 2),
|
|
4130
|
-
|
|
4131
|
-
|
|
4190
|
+
activeActionRowKey = _useState26[0],
|
|
4191
|
+
setActiveActionRowKey = _useState26[1];
|
|
4192
|
+
var _useState27 = useState(false),
|
|
4193
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
|
4194
|
+
showMobileFilters = _useState28[0],
|
|
4195
|
+
setShowMobileFilters = _useState28[1];
|
|
4132
4196
|
|
|
4133
4197
|
// Refs
|
|
4134
4198
|
var columnMenuRef = useRef(null);
|
|
4135
4199
|
var columnToggleBtnRef = useRef(null);
|
|
4136
4200
|
var actionMenuRef = useRef(null);
|
|
4201
|
+
var actionButtonRefs = useRef({});
|
|
4137
4202
|
|
|
4138
4203
|
// Actions to use (memoized)
|
|
4139
4204
|
var actionsToUse = useMemo(function () {
|
|
@@ -4181,10 +4246,16 @@ var Table = function Table(_ref2) {
|
|
|
4181
4246
|
return setShowColumnMenu(false);
|
|
4182
4247
|
}, []);
|
|
4183
4248
|
var closeActionMenu = useCallback(function () {
|
|
4184
|
-
return
|
|
4249
|
+
return setActiveActionRowKey(null);
|
|
4185
4250
|
}, []);
|
|
4186
4251
|
useClickOutside([columnMenuRef, columnToggleBtnRef], showColumnMenu, closeColumnMenu);
|
|
4187
|
-
useClickOutside([actionMenuRef],
|
|
4252
|
+
useClickOutside([actionMenuRef], activeActionRowKey !== null, closeActionMenu);
|
|
4253
|
+
|
|
4254
|
+
// Get active anchor element
|
|
4255
|
+
var activeAnchorEl = useMemo(function () {
|
|
4256
|
+
if (activeActionRowKey === null) return null;
|
|
4257
|
+
return actionButtonRefs.current[activeActionRowKey];
|
|
4258
|
+
}, [activeActionRowKey]);
|
|
4188
4259
|
|
|
4189
4260
|
// Visible columns (memoized)
|
|
4190
4261
|
var visibleColumns = useMemo(function () {
|
|
@@ -4341,13 +4412,17 @@ var Table = function Table(_ref2) {
|
|
|
4341
4412
|
}, [startIndex]);
|
|
4342
4413
|
var toggleActions = useCallback(function (e, actionCellKey, row) {
|
|
4343
4414
|
e.stopPropagation();
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4415
|
+
e.preventDefault(); // Prevent default to avoid any other click handlers
|
|
4416
|
+
|
|
4417
|
+
// Store the button reference
|
|
4418
|
+
if (e.currentTarget) {
|
|
4419
|
+
actionButtonRefs.current[actionCellKey] = e.currentTarget;
|
|
4420
|
+
}
|
|
4421
|
+
setActiveActionRowKey(function (prev) {
|
|
4422
|
+
if (prev === actionCellKey) {
|
|
4423
|
+
return null; // Close if clicking same button
|
|
4424
|
+
}
|
|
4425
|
+
return actionCellKey; // Open new menu
|
|
4351
4426
|
});
|
|
4352
4427
|
}, []);
|
|
4353
4428
|
var handleOnAction = useCallback(function (action, row) {
|
|
@@ -4360,7 +4435,7 @@ var Table = function Table(_ref2) {
|
|
|
4360
4435
|
action: action,
|
|
4361
4436
|
row: row
|
|
4362
4437
|
});
|
|
4363
|
-
|
|
4438
|
+
setActiveActionRowKey(null);
|
|
4364
4439
|
}, [onAction]);
|
|
4365
4440
|
var handleLimitChange = useCallback(function (nextLimit) {
|
|
4366
4441
|
var parsed = Number(nextLimit);
|
|
@@ -4461,21 +4536,28 @@ var Table = function Table(_ref2) {
|
|
|
4461
4536
|
}, "#", globalIndex + 1)), withAction && /*#__PURE__*/React__default.createElement("div", {
|
|
4462
4537
|
className: "relative"
|
|
4463
4538
|
}, /*#__PURE__*/React__default.createElement("button", {
|
|
4539
|
+
ref: function ref(el) {
|
|
4540
|
+
if (el) {
|
|
4541
|
+
actionButtonRefs.current[actionCellKey] = el;
|
|
4542
|
+
}
|
|
4543
|
+
},
|
|
4464
4544
|
onClick: function onClick(e) {
|
|
4465
4545
|
return toggleActions(e, actionCellKey, row);
|
|
4466
4546
|
},
|
|
4467
|
-
"aria-expanded":
|
|
4547
|
+
"aria-expanded": activeActionRowKey === actionCellKey,
|
|
4468
4548
|
className: "p-1.5 rounded hover:bg-gray-200",
|
|
4469
4549
|
title: "Actions"
|
|
4470
4550
|
}, /*#__PURE__*/React__default.createElement(MoreVertical, {
|
|
4471
4551
|
className: "h-4 w-4"
|
|
4472
|
-
})),
|
|
4552
|
+
})), activeActionRowKey === actionCellKey && /*#__PURE__*/React__default.createElement(ActionMenu, {
|
|
4473
4553
|
actions: actionsToUse,
|
|
4474
4554
|
row: row,
|
|
4475
4555
|
onAction: function onAction(action) {
|
|
4476
4556
|
return handleOnAction(action, row);
|
|
4477
4557
|
},
|
|
4478
|
-
menuRef: actionMenuRef
|
|
4558
|
+
menuRef: actionMenuRef,
|
|
4559
|
+
anchorEl: activeAnchorEl,
|
|
4560
|
+
onClose: closeActionMenu
|
|
4479
4561
|
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
4480
4562
|
className: "p-4"
|
|
4481
4563
|
}, visibleColumns.map(function (column, colIndex) {
|
|
@@ -4500,7 +4582,7 @@ var Table = function Table(_ref2) {
|
|
|
4500
4582
|
row: row,
|
|
4501
4583
|
index: globalIndex
|
|
4502
4584
|
})));
|
|
4503
|
-
}, [startIndex, selectedRows, expandedRows, rowClass, stripedRows, stripedColors, onRowClick, hasDetails, selectable, showSerial, withAction, visibleColumns, cellClass, DetailsComponent, actionsToUse,
|
|
4585
|
+
}, [startIndex, selectedRows, expandedRows, rowClass, stripedRows, stripedColors, onRowClick, hasDetails, selectable, showSerial, withAction, visibleColumns, cellClass, DetailsComponent, actionsToUse, activeActionRowKey, activeAnchorEl, toggleExpandRow, handleSelectRow, toggleActions, handleOnAction, closeActionMenu, renderCell]);
|
|
4504
4586
|
|
|
4505
4587
|
// Render mobile filters
|
|
4506
4588
|
var renderMobileFilters = useCallback(function () {
|
|
@@ -4567,6 +4649,110 @@ var Table = function Table(_ref2) {
|
|
|
4567
4649
|
};
|
|
4568
4650
|
});
|
|
4569
4651
|
}, [limitOptions]);
|
|
4652
|
+
|
|
4653
|
+
// Render desktop table rows
|
|
4654
|
+
var renderDesktopTableRows = useCallback(function () {
|
|
4655
|
+
return paginatedData.map(function (row, rowIndexInPage) {
|
|
4656
|
+
var globalIndex = startIndex + rowIndexInPage;
|
|
4657
|
+
var key = getRowKey(row, globalIndex);
|
|
4658
|
+
var actionCellKey = "actions-".concat(key);
|
|
4659
|
+
var isSelected = selectedRows.has(key);
|
|
4660
|
+
var isExpanded = expandedRows.has(key);
|
|
4661
|
+
var extraRowClass = typeof rowClass === "function" ? rowClass({
|
|
4662
|
+
row: row,
|
|
4663
|
+
rowIndex: globalIndex
|
|
4664
|
+
}) : "";
|
|
4665
|
+
var safeExtraRowClass = typeof extraRowClass === "string" ? extraRowClass.trim() : "";
|
|
4666
|
+
var stripeBg = stripedRows && !isSelected ? stripedColors[globalIndex % stripedColors.length] : undefined;
|
|
4667
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
|
|
4668
|
+
key: key
|
|
4669
|
+
}, /*#__PURE__*/React__default.createElement("tr", {
|
|
4670
|
+
style: stripeBg ? {
|
|
4671
|
+
backgroundColor: stripeBg
|
|
4672
|
+
} : undefined,
|
|
4673
|
+
className: cn$1("hover:bg-gray-50", {
|
|
4674
|
+
"cursor-pointer": !!onRowClick,
|
|
4675
|
+
"bg-primary-50": isSelected
|
|
4676
|
+
}, safeExtraRowClass),
|
|
4677
|
+
onClick: function onClick() {
|
|
4678
|
+
return onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(row, globalIndex);
|
|
4679
|
+
}
|
|
4680
|
+
}, hasDetails && /*#__PURE__*/React__default.createElement("td", {
|
|
4681
|
+
className: "px-4 py-4 text-sm"
|
|
4682
|
+
}, /*#__PURE__*/React__default.createElement("button", {
|
|
4683
|
+
onClick: function onClick(e) {
|
|
4684
|
+
e.stopPropagation();
|
|
4685
|
+
toggleExpandRow(row, rowIndexInPage);
|
|
4686
|
+
},
|
|
4687
|
+
"aria-expanded": isExpanded,
|
|
4688
|
+
className: "p-1 rounded hover:bg-gray-100"
|
|
4689
|
+
}, isExpanded ? "▾" : "▸")), showSerial && /*#__PURE__*/React__default.createElement("td", {
|
|
4690
|
+
className: "px-4 py-4 whitespace-nowrap text-sm text-gray-900"
|
|
4691
|
+
}, globalIndex + 1), selectable && /*#__PURE__*/React__default.createElement("td", {
|
|
4692
|
+
className: "px-6 py-4",
|
|
4693
|
+
onClick: function onClick(e) {
|
|
4694
|
+
return e.stopPropagation();
|
|
4695
|
+
}
|
|
4696
|
+
}, /*#__PURE__*/React__default.createElement("input", {
|
|
4697
|
+
type: "checkbox",
|
|
4698
|
+
className: "rounded border-gray-300",
|
|
4699
|
+
checked: isSelected,
|
|
4700
|
+
onChange: function onChange() {
|
|
4701
|
+
return handleSelectRow(row, rowIndexInPage);
|
|
4702
|
+
}
|
|
4703
|
+
})), visibleColumns.map(function (column, columnIndex) {
|
|
4704
|
+
var extraCellClass = typeof cellClass === "function" ? cellClass({
|
|
4705
|
+
row: row,
|
|
4706
|
+
rowIndex: globalIndex,
|
|
4707
|
+
column: column,
|
|
4708
|
+
columnIndex: columnIndex
|
|
4709
|
+
}) : "";
|
|
4710
|
+
var safeExtraCellClass = typeof extraCellClass === "string" ? extraCellClass.trim() : "";
|
|
4711
|
+
return /*#__PURE__*/React__default.createElement("td", {
|
|
4712
|
+
key: column.key,
|
|
4713
|
+
className: cn$1("px-6 py-4 whitespace-nowrap text-sm text-gray-900", safeExtraCellClass)
|
|
4714
|
+
}, renderCell(column, row, globalIndex));
|
|
4715
|
+
}), /*#__PURE__*/React__default.createElement("td", {
|
|
4716
|
+
className: "px-4 py-4"
|
|
4717
|
+
}), withAction && /*#__PURE__*/React__default.createElement("td", {
|
|
4718
|
+
className: "px-4 py-4 text-sm text-right",
|
|
4719
|
+
onClick: function onClick(e) {
|
|
4720
|
+
return e.stopPropagation();
|
|
4721
|
+
}
|
|
4722
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
4723
|
+
className: "relative inline-block"
|
|
4724
|
+
}, /*#__PURE__*/React__default.createElement("button", {
|
|
4725
|
+
ref: function ref(el) {
|
|
4726
|
+
if (el) {
|
|
4727
|
+
actionButtonRefs.current[actionCellKey] = el;
|
|
4728
|
+
}
|
|
4729
|
+
},
|
|
4730
|
+
onClick: function onClick(e) {
|
|
4731
|
+
return toggleActions(e, actionCellKey, row);
|
|
4732
|
+
},
|
|
4733
|
+
"aria-expanded": activeActionRowKey === actionCellKey,
|
|
4734
|
+
className: "p-1 rounded hover:bg-gray-100",
|
|
4735
|
+
title: "Actions"
|
|
4736
|
+
}, /*#__PURE__*/React__default.createElement(MoreVertical, {
|
|
4737
|
+
className: "h-4 w-4"
|
|
4738
|
+
})), activeActionRowKey === actionCellKey && /*#__PURE__*/React__default.createElement(ActionMenu, {
|
|
4739
|
+
actions: actionsToUse,
|
|
4740
|
+
row: row,
|
|
4741
|
+
onAction: function onAction(action) {
|
|
4742
|
+
return handleOnAction(action, row);
|
|
4743
|
+
},
|
|
4744
|
+
menuRef: actionMenuRef,
|
|
4745
|
+
anchorEl: activeAnchorEl,
|
|
4746
|
+
onClose: closeActionMenu
|
|
4747
|
+
})))), hasDetails && isExpanded && DetailsComponent && /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
|
|
4748
|
+
colSpan: visibleCount,
|
|
4749
|
+
className: "px-6 py-4 bg-gray-50"
|
|
4750
|
+
}, /*#__PURE__*/React__default.createElement(DetailsComponent, {
|
|
4751
|
+
row: row,
|
|
4752
|
+
index: globalIndex
|
|
4753
|
+
}))));
|
|
4754
|
+
});
|
|
4755
|
+
}, [paginatedData, startIndex, selectedRows, expandedRows, rowClass, stripedRows, stripedColors, onRowClick, hasDetails, showSerial, selectable, visibleColumns, cellClass, withAction, visibleCount, DetailsComponent, actionsToUse, activeActionRowKey, activeAnchorEl, toggleExpandRow, handleSelectRow, toggleActions, handleOnAction, closeActionMenu, renderCell]);
|
|
4570
4756
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
4571
4757
|
className: "w-full border rounded-lg md:rounded-md bg-white"
|
|
4572
4758
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -4599,7 +4785,7 @@ var Table = function Table(_ref2) {
|
|
|
4599
4785
|
className: "flex flex-col sm:flex-row items-start sm:items-center gap-3 w-full md:w-auto"
|
|
4600
4786
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
4601
4787
|
className: "text-sm text-gray-700 whitespace-nowrap"
|
|
4602
|
-
}, filteredData.length === 0 ? 0 : startIndex + 1, " -", " ", Math.min(endIndex, filteredData.length), " of ", filteredData.length, " results"), pagination && /*#__PURE__*/React__default.createElement("div", {
|
|
4788
|
+
}, filteredData.length === 0 ? 0 : startIndex + 1, " -", " ", Math.min(endIndex, filteredData.length), " of ", filteredData.length, " ", "results"), pagination && /*#__PURE__*/React__default.createElement("div", {
|
|
4603
4789
|
className: "flex items-center gap-1"
|
|
4604
4790
|
}, totalPages >= 4 && /*#__PURE__*/React__default.createElement("button", {
|
|
4605
4791
|
className: "rounded-lg md:rounded-md border border-gray-300 p-2 disabled:opacity-50 hover:bg-gray-50",
|
|
@@ -4790,99 +4976,7 @@ var Table = function Table(_ref2) {
|
|
|
4790
4976
|
className: "h-8 w-8"
|
|
4791
4977
|
})), /*#__PURE__*/React__default.createElement("span", {
|
|
4792
4978
|
className: "text-sm text-gray-500"
|
|
4793
|
-
}, "No results found.")))) :
|
|
4794
|
-
var globalIndex = startIndex + rowIndexInPage;
|
|
4795
|
-
var key = getRowKey(row, globalIndex);
|
|
4796
|
-
var actionCellKey = "actions-".concat(key);
|
|
4797
|
-
var isSelected = selectedRows.has(key);
|
|
4798
|
-
var isExpanded = expandedRows.has(key);
|
|
4799
|
-
var extraRowClass = typeof rowClass === "function" ? rowClass({
|
|
4800
|
-
row: row,
|
|
4801
|
-
rowIndex: globalIndex
|
|
4802
|
-
}) : "";
|
|
4803
|
-
var safeExtraRowClass = typeof extraRowClass === "string" ? extraRowClass.trim() : "";
|
|
4804
|
-
var stripeBg = stripedRows && !isSelected ? stripedColors[globalIndex % stripedColors.length] : undefined;
|
|
4805
|
-
return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
|
|
4806
|
-
key: key
|
|
4807
|
-
}, /*#__PURE__*/React__default.createElement("tr", {
|
|
4808
|
-
style: stripeBg ? {
|
|
4809
|
-
backgroundColor: stripeBg
|
|
4810
|
-
} : undefined,
|
|
4811
|
-
className: cn$1("hover:bg-gray-50", {
|
|
4812
|
-
"cursor-pointer": !!onRowClick,
|
|
4813
|
-
"bg-primary-50": isSelected
|
|
4814
|
-
}, safeExtraRowClass),
|
|
4815
|
-
onClick: function onClick() {
|
|
4816
|
-
return onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(row, globalIndex);
|
|
4817
|
-
}
|
|
4818
|
-
}, hasDetails && /*#__PURE__*/React__default.createElement("td", {
|
|
4819
|
-
className: "px-4 py-4 text-sm"
|
|
4820
|
-
}, /*#__PURE__*/React__default.createElement("button", {
|
|
4821
|
-
onClick: function onClick(e) {
|
|
4822
|
-
e.stopPropagation();
|
|
4823
|
-
toggleExpandRow(row, rowIndexInPage);
|
|
4824
|
-
},
|
|
4825
|
-
"aria-expanded": isExpanded,
|
|
4826
|
-
className: "p-1 rounded hover:bg-gray-100"
|
|
4827
|
-
}, isExpanded ? "▾" : "▸")), showSerial && /*#__PURE__*/React__default.createElement("td", {
|
|
4828
|
-
className: "px-4 py-4 whitespace-nowrap text-sm text-gray-900"
|
|
4829
|
-
}, globalIndex + 1), selectable && /*#__PURE__*/React__default.createElement("td", {
|
|
4830
|
-
className: "px-6 py-4",
|
|
4831
|
-
onClick: function onClick(e) {
|
|
4832
|
-
return e.stopPropagation();
|
|
4833
|
-
}
|
|
4834
|
-
}, /*#__PURE__*/React__default.createElement("input", {
|
|
4835
|
-
type: "checkbox",
|
|
4836
|
-
className: "rounded border-gray-300",
|
|
4837
|
-
checked: isSelected,
|
|
4838
|
-
onChange: function onChange() {
|
|
4839
|
-
return handleSelectRow(row, rowIndexInPage);
|
|
4840
|
-
}
|
|
4841
|
-
})), visibleColumns.map(function (column, columnIndex) {
|
|
4842
|
-
var extraCellClass = typeof cellClass === "function" ? cellClass({
|
|
4843
|
-
row: row,
|
|
4844
|
-
rowIndex: globalIndex,
|
|
4845
|
-
column: column,
|
|
4846
|
-
columnIndex: columnIndex
|
|
4847
|
-
}) : "";
|
|
4848
|
-
var safeExtraCellClass = typeof extraCellClass === "string" ? extraCellClass.trim() : "";
|
|
4849
|
-
return /*#__PURE__*/React__default.createElement("td", {
|
|
4850
|
-
key: column.key,
|
|
4851
|
-
className: cn$1("px-6 py-4 whitespace-nowrap text-sm text-gray-900", safeExtraCellClass)
|
|
4852
|
-
}, renderCell(column, row, globalIndex));
|
|
4853
|
-
}), /*#__PURE__*/React__default.createElement("td", {
|
|
4854
|
-
className: "px-4 py-4"
|
|
4855
|
-
}), withAction && /*#__PURE__*/React__default.createElement("td", {
|
|
4856
|
-
className: "px-4 py-4 text-sm text-right",
|
|
4857
|
-
onClick: function onClick(e) {
|
|
4858
|
-
return e.stopPropagation();
|
|
4859
|
-
}
|
|
4860
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
4861
|
-
className: "relative inline-block"
|
|
4862
|
-
}, /*#__PURE__*/React__default.createElement("button", {
|
|
4863
|
-
onClick: function onClick(e) {
|
|
4864
|
-
return toggleActions(e, actionCellKey, row);
|
|
4865
|
-
},
|
|
4866
|
-
"aria-expanded": (actionAnchor === null || actionAnchor === void 0 ? void 0 : actionAnchor.key) === actionCellKey,
|
|
4867
|
-
className: "p-1 rounded hover:bg-gray-100",
|
|
4868
|
-
title: "Actions"
|
|
4869
|
-
}, /*#__PURE__*/React__default.createElement(MoreVertical, {
|
|
4870
|
-
className: "h-4 w-4"
|
|
4871
|
-
})), (actionAnchor === null || actionAnchor === void 0 ? void 0 : actionAnchor.key) === actionCellKey && /*#__PURE__*/React__default.createElement(ActionMenu, {
|
|
4872
|
-
actions: actionsToUse,
|
|
4873
|
-
row: row,
|
|
4874
|
-
onAction: function onAction(action) {
|
|
4875
|
-
return handleOnAction(action, row);
|
|
4876
|
-
},
|
|
4877
|
-
menuRef: actionMenuRef
|
|
4878
|
-
})))), hasDetails && isExpanded && DetailsComponent && /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
|
|
4879
|
-
colSpan: visibleCount,
|
|
4880
|
-
className: "px-6 py-4 bg-gray-50"
|
|
4881
|
-
}, /*#__PURE__*/React__default.createElement(DetailsComponent, {
|
|
4882
|
-
row: row,
|
|
4883
|
-
index: globalIndex
|
|
4884
|
-
}))));
|
|
4885
|
-
})))), isMobileView && /*#__PURE__*/React__default.createElement("div", {
|
|
4979
|
+
}, "No results found.")))) : renderDesktopTableRows()))), isMobileView && /*#__PURE__*/React__default.createElement("div", {
|
|
4886
4980
|
className: "p-4"
|
|
4887
4981
|
}, loading ? /*#__PURE__*/React__default.createElement("div", {
|
|
4888
4982
|
className: "py-8 text-center"
|