@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.js
CHANGED
|
@@ -3961,10 +3961,71 @@ var ActionMenu = /*#__PURE__*/React.memo(function ActionMenu(_ref) {
|
|
|
3961
3961
|
actions = _ref$actions === void 0 ? [] : _ref$actions,
|
|
3962
3962
|
row = _ref.row,
|
|
3963
3963
|
onAction = _ref.onAction,
|
|
3964
|
-
menuRef = _ref.menuRef
|
|
3964
|
+
menuRef = _ref.menuRef,
|
|
3965
|
+
anchorEl = _ref.anchorEl,
|
|
3966
|
+
onClose = _ref.onClose;
|
|
3967
|
+
var _useState = React.useState({
|
|
3968
|
+
top: 0,
|
|
3969
|
+
left: 0,
|
|
3970
|
+
visibility: "hidden"
|
|
3971
|
+
}),
|
|
3972
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3973
|
+
pos = _useState2[0],
|
|
3974
|
+
setPos = _useState2[1];
|
|
3975
|
+
|
|
3976
|
+
// compute position after mount / when anchor changes
|
|
3977
|
+
React.useLayoutEffect(function () {
|
|
3978
|
+
if (!anchorEl || !(menuRef !== null && menuRef !== void 0 && menuRef.current) || typeof window === "undefined") {
|
|
3979
|
+
setPos(function (p) {
|
|
3980
|
+
return _objectSpread$9(_objectSpread$9({}, p), {}, {
|
|
3981
|
+
visibility: "hidden"
|
|
3982
|
+
});
|
|
3983
|
+
});
|
|
3984
|
+
return;
|
|
3985
|
+
}
|
|
3986
|
+
var menu = menuRef.current;
|
|
3987
|
+
var rect = anchorEl.getBoundingClientRect();
|
|
3988
|
+
var menuWidth = menu.offsetWidth || 176; // w-44 ~ 176px fallback
|
|
3989
|
+
var menuHeight = menu.offsetHeight || menu.scrollHeight || 200;
|
|
3990
|
+
var viewportWidth = window.innerWidth;
|
|
3991
|
+
var viewportHeight = window.innerHeight;
|
|
3992
|
+
var scrollX = window.scrollX || window.pageXOffset || 0;
|
|
3993
|
+
var scrollY = window.scrollY || window.pageYOffset || 0;
|
|
3994
|
+
|
|
3995
|
+
// prefer placing below the button
|
|
3996
|
+
var preferBelowTop = rect.bottom + scrollY + 6;
|
|
3997
|
+
var preferAboveTop = rect.top + scrollY - menuHeight - 6;
|
|
3998
|
+
|
|
3999
|
+
// compute left so right-aligned to the button's right edge
|
|
4000
|
+
var left = rect.right + scrollX - menuWidth;
|
|
4001
|
+
if (left < 8) left = 8;
|
|
4002
|
+
if (left + menuWidth > viewportWidth - 8) left = Math.max(8, viewportWidth - menuWidth - 8);
|
|
4003
|
+
|
|
4004
|
+
// choose top based on available space
|
|
4005
|
+
var top;
|
|
4006
|
+
if (preferBelowTop + menuHeight <= scrollY + viewportHeight - 8) {
|
|
4007
|
+
top = preferBelowTop;
|
|
4008
|
+
} else if (preferAboveTop >= scrollY + 8) {
|
|
4009
|
+
top = preferAboveTop;
|
|
4010
|
+
} else {
|
|
4011
|
+
// fallback: clamp inside viewport
|
|
4012
|
+
top = Math.max(scrollY + 8, Math.min(preferBelowTop, scrollY + viewportHeight - menuHeight - 8));
|
|
4013
|
+
}
|
|
4014
|
+
setPos({
|
|
4015
|
+
top: top,
|
|
4016
|
+
left: left,
|
|
4017
|
+
visibility: "visible"
|
|
4018
|
+
});
|
|
4019
|
+
}, [anchorEl, menuRef, actions, row]);
|
|
3965
4020
|
return /*#__PURE__*/React.createElement("div", {
|
|
3966
4021
|
ref: menuRef,
|
|
3967
|
-
className: "
|
|
4022
|
+
className: "fixed z-50 bg-white rounded-lg shadow-lg ring-1 ring-black ring-opacity-5",
|
|
4023
|
+
style: {
|
|
4024
|
+
top: pos.top,
|
|
4025
|
+
left: pos.left,
|
|
4026
|
+
visibility: pos.visibility,
|
|
4027
|
+
minWidth: 176 // match w-44 fallback
|
|
4028
|
+
},
|
|
3968
4029
|
onClick: function onClick(e) {
|
|
3969
4030
|
return e.stopPropagation();
|
|
3970
4031
|
}
|
|
@@ -3981,6 +4042,7 @@ var ActionMenu = /*#__PURE__*/React.memo(function ActionMenu(_ref) {
|
|
|
3981
4042
|
onClick: function onClick(e) {
|
|
3982
4043
|
e.stopPropagation();
|
|
3983
4044
|
onAction === null || onAction === void 0 || onAction(action, row);
|
|
4045
|
+
onClose === null || onClose === void 0 || onClose();
|
|
3984
4046
|
}
|
|
3985
4047
|
}, action.render ? action.render(row) : /*#__PURE__*/React.createElement(React.Fragment, null, action.icon && /*#__PURE__*/React.createElement("span", {
|
|
3986
4048
|
className: "inline-flex"
|
|
@@ -3998,9 +4060,11 @@ function useClickOutside(refs, isActive, onClickOutside) {
|
|
|
3998
4060
|
});
|
|
3999
4061
|
if (isOutside) onClickOutside();
|
|
4000
4062
|
};
|
|
4001
|
-
|
|
4063
|
+
|
|
4064
|
+
// Use capture phase to ensure we handle clicks before they bubble
|
|
4065
|
+
document.addEventListener("mousedown", handler, true);
|
|
4002
4066
|
return function () {
|
|
4003
|
-
return document.removeEventListener("
|
|
4067
|
+
return document.removeEventListener("mousedown", handler, true);
|
|
4004
4068
|
};
|
|
4005
4069
|
}, [refs, isActive, onClickOutside]);
|
|
4006
4070
|
}
|
|
@@ -4070,90 +4134,91 @@ var Table = function Table(_ref2) {
|
|
|
4070
4134
|
pageNumber = _ref2.pageNumber,
|
|
4071
4135
|
props = _objectWithoutProperties$1(_ref2, _excluded$k);
|
|
4072
4136
|
// Core state
|
|
4073
|
-
var
|
|
4074
|
-
|
|
4075
|
-
isMobileView =
|
|
4076
|
-
setIsMobileView =
|
|
4077
|
-
var
|
|
4137
|
+
var _useState3 = React.useState(false),
|
|
4138
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
4139
|
+
isMobileView = _useState4[0],
|
|
4140
|
+
setIsMobileView = _useState4[1];
|
|
4141
|
+
var _useState5 = React.useState(function () {
|
|
4078
4142
|
return Array.isArray(data) ? data : [];
|
|
4079
4143
|
}),
|
|
4080
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
4081
|
-
tableData = _useState4[0],
|
|
4082
|
-
setTableData = _useState4[1];
|
|
4083
|
-
var _useState5 = React.useState(false),
|
|
4084
4144
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
var _useState7 = React.useState(
|
|
4145
|
+
tableData = _useState6[0],
|
|
4146
|
+
setTableData = _useState6[1];
|
|
4147
|
+
var _useState7 = React.useState(false),
|
|
4088
4148
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
var _useState9 = React.useState(
|
|
4149
|
+
loading = _useState8[0],
|
|
4150
|
+
setLoading = _useState8[1];
|
|
4151
|
+
var _useState9 = React.useState(pageSize),
|
|
4152
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
4153
|
+
limit = _useState0[0],
|
|
4154
|
+
setLimit = _useState0[1];
|
|
4155
|
+
var _useState1 = React.useState(function () {
|
|
4092
4156
|
return typeof pageNumber === "number" ? pageNumber : 1;
|
|
4093
4157
|
}),
|
|
4094
|
-
|
|
4095
|
-
currentPage =
|
|
4096
|
-
setCurrentPage =
|
|
4158
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
4159
|
+
currentPage = _useState10[0],
|
|
4160
|
+
setCurrentPage = _useState10[1];
|
|
4097
4161
|
|
|
4098
4162
|
// Column state
|
|
4099
|
-
var
|
|
4163
|
+
var _useState11 = React.useState(function () {
|
|
4100
4164
|
return Array.isArray(columns) ? columns.map(function (c) {
|
|
4101
4165
|
return _objectSpread$9({}, c);
|
|
4102
4166
|
}) : [];
|
|
4103
4167
|
}),
|
|
4104
|
-
_useState10 = _slicedToArray(_useState1, 2),
|
|
4105
|
-
columnsState = _useState10[0],
|
|
4106
|
-
setColumnsState = _useState10[1];
|
|
4107
|
-
var _useState11 = React.useState(false),
|
|
4108
4168
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
4109
|
-
|
|
4110
|
-
|
|
4169
|
+
columnsState = _useState12[0],
|
|
4170
|
+
setColumnsState = _useState12[1];
|
|
4171
|
+
var _useState13 = React.useState(false),
|
|
4172
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
4173
|
+
showColumnMenu = _useState14[0],
|
|
4174
|
+
setShowColumnMenu = _useState14[1];
|
|
4111
4175
|
|
|
4112
4176
|
// Sorting/filtering state
|
|
4113
|
-
var
|
|
4177
|
+
var _useState15 = React.useState({
|
|
4114
4178
|
key: null,
|
|
4115
4179
|
direction: "asc"
|
|
4116
4180
|
}),
|
|
4117
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
4118
|
-
sortConfig = _useState14[0],
|
|
4119
|
-
setSortConfig = _useState14[1];
|
|
4120
|
-
var _useState15 = React.useState({}),
|
|
4121
4181
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
var _useState17 = React.useState(
|
|
4182
|
+
sortConfig = _useState16[0],
|
|
4183
|
+
setSortConfig = _useState16[1];
|
|
4184
|
+
var _useState17 = React.useState({}),
|
|
4125
4185
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
4126
|
-
|
|
4127
|
-
|
|
4186
|
+
filters = _useState18[0],
|
|
4187
|
+
setFilters = _useState18[1];
|
|
4188
|
+
var _useState19 = React.useState(""),
|
|
4189
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
4190
|
+
searchInput = _useState20[0],
|
|
4191
|
+
setSearchInput = _useState20[1];
|
|
4128
4192
|
|
|
4129
4193
|
// Selection/expansion state
|
|
4130
|
-
var _useState19 = React.useState(function () {
|
|
4131
|
-
return new Set();
|
|
4132
|
-
}),
|
|
4133
|
-
_useState20 = _slicedToArray(_useState19, 2),
|
|
4134
|
-
selectedRows = _useState20[0],
|
|
4135
|
-
setSelectedRows = _useState20[1];
|
|
4136
4194
|
var _useState21 = React.useState(function () {
|
|
4137
4195
|
return new Set();
|
|
4138
4196
|
}),
|
|
4139
4197
|
_useState22 = _slicedToArray(_useState21, 2),
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4198
|
+
selectedRows = _useState22[0],
|
|
4199
|
+
setSelectedRows = _useState22[1];
|
|
4200
|
+
var _useState23 = React.useState(function () {
|
|
4201
|
+
return new Set();
|
|
4202
|
+
}),
|
|
4145
4203
|
_useState24 = _slicedToArray(_useState23, 2),
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4204
|
+
expandedRows = _useState24[0],
|
|
4205
|
+
setExpandedRows = _useState24[1];
|
|
4206
|
+
|
|
4207
|
+
// Action menu state - simplified to just store the clicked row key
|
|
4208
|
+
var _useState25 = React.useState(null),
|
|
4149
4209
|
_useState26 = _slicedToArray(_useState25, 2),
|
|
4150
|
-
|
|
4151
|
-
|
|
4210
|
+
activeActionRowKey = _useState26[0],
|
|
4211
|
+
setActiveActionRowKey = _useState26[1];
|
|
4212
|
+
var _useState27 = React.useState(false),
|
|
4213
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
|
4214
|
+
showMobileFilters = _useState28[0],
|
|
4215
|
+
setShowMobileFilters = _useState28[1];
|
|
4152
4216
|
|
|
4153
4217
|
// Refs
|
|
4154
4218
|
var columnMenuRef = React.useRef(null);
|
|
4155
4219
|
var columnToggleBtnRef = React.useRef(null);
|
|
4156
4220
|
var actionMenuRef = React.useRef(null);
|
|
4221
|
+
var actionButtonRefs = React.useRef({});
|
|
4157
4222
|
|
|
4158
4223
|
// Actions to use (memoized)
|
|
4159
4224
|
var actionsToUse = React.useMemo(function () {
|
|
@@ -4201,10 +4266,16 @@ var Table = function Table(_ref2) {
|
|
|
4201
4266
|
return setShowColumnMenu(false);
|
|
4202
4267
|
}, []);
|
|
4203
4268
|
var closeActionMenu = React.useCallback(function () {
|
|
4204
|
-
return
|
|
4269
|
+
return setActiveActionRowKey(null);
|
|
4205
4270
|
}, []);
|
|
4206
4271
|
useClickOutside([columnMenuRef, columnToggleBtnRef], showColumnMenu, closeColumnMenu);
|
|
4207
|
-
useClickOutside([actionMenuRef],
|
|
4272
|
+
useClickOutside([actionMenuRef], activeActionRowKey !== null, closeActionMenu);
|
|
4273
|
+
|
|
4274
|
+
// Get active anchor element
|
|
4275
|
+
var activeAnchorEl = React.useMemo(function () {
|
|
4276
|
+
if (activeActionRowKey === null) return null;
|
|
4277
|
+
return actionButtonRefs.current[activeActionRowKey];
|
|
4278
|
+
}, [activeActionRowKey]);
|
|
4208
4279
|
|
|
4209
4280
|
// Visible columns (memoized)
|
|
4210
4281
|
var visibleColumns = React.useMemo(function () {
|
|
@@ -4361,13 +4432,17 @@ var Table = function Table(_ref2) {
|
|
|
4361
4432
|
}, [startIndex]);
|
|
4362
4433
|
var toggleActions = React.useCallback(function (e, actionCellKey, row) {
|
|
4363
4434
|
e.stopPropagation();
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4435
|
+
e.preventDefault(); // Prevent default to avoid any other click handlers
|
|
4436
|
+
|
|
4437
|
+
// Store the button reference
|
|
4438
|
+
if (e.currentTarget) {
|
|
4439
|
+
actionButtonRefs.current[actionCellKey] = e.currentTarget;
|
|
4440
|
+
}
|
|
4441
|
+
setActiveActionRowKey(function (prev) {
|
|
4442
|
+
if (prev === actionCellKey) {
|
|
4443
|
+
return null; // Close if clicking same button
|
|
4444
|
+
}
|
|
4445
|
+
return actionCellKey; // Open new menu
|
|
4371
4446
|
});
|
|
4372
4447
|
}, []);
|
|
4373
4448
|
var handleOnAction = React.useCallback(function (action, row) {
|
|
@@ -4380,7 +4455,7 @@ var Table = function Table(_ref2) {
|
|
|
4380
4455
|
action: action,
|
|
4381
4456
|
row: row
|
|
4382
4457
|
});
|
|
4383
|
-
|
|
4458
|
+
setActiveActionRowKey(null);
|
|
4384
4459
|
}, [onAction]);
|
|
4385
4460
|
var handleLimitChange = React.useCallback(function (nextLimit) {
|
|
4386
4461
|
var parsed = Number(nextLimit);
|
|
@@ -4481,21 +4556,28 @@ var Table = function Table(_ref2) {
|
|
|
4481
4556
|
}, "#", globalIndex + 1)), withAction && /*#__PURE__*/React.createElement("div", {
|
|
4482
4557
|
className: "relative"
|
|
4483
4558
|
}, /*#__PURE__*/React.createElement("button", {
|
|
4559
|
+
ref: function ref(el) {
|
|
4560
|
+
if (el) {
|
|
4561
|
+
actionButtonRefs.current[actionCellKey] = el;
|
|
4562
|
+
}
|
|
4563
|
+
},
|
|
4484
4564
|
onClick: function onClick(e) {
|
|
4485
4565
|
return toggleActions(e, actionCellKey, row);
|
|
4486
4566
|
},
|
|
4487
|
-
"aria-expanded":
|
|
4567
|
+
"aria-expanded": activeActionRowKey === actionCellKey,
|
|
4488
4568
|
className: "p-1.5 rounded hover:bg-gray-200",
|
|
4489
4569
|
title: "Actions"
|
|
4490
4570
|
}, /*#__PURE__*/React.createElement(MoreVertical, {
|
|
4491
4571
|
className: "h-4 w-4"
|
|
4492
|
-
})),
|
|
4572
|
+
})), activeActionRowKey === actionCellKey && /*#__PURE__*/React.createElement(ActionMenu, {
|
|
4493
4573
|
actions: actionsToUse,
|
|
4494
4574
|
row: row,
|
|
4495
4575
|
onAction: function onAction(action) {
|
|
4496
4576
|
return handleOnAction(action, row);
|
|
4497
4577
|
},
|
|
4498
|
-
menuRef: actionMenuRef
|
|
4578
|
+
menuRef: actionMenuRef,
|
|
4579
|
+
anchorEl: activeAnchorEl,
|
|
4580
|
+
onClose: closeActionMenu
|
|
4499
4581
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
4500
4582
|
className: "p-4"
|
|
4501
4583
|
}, visibleColumns.map(function (column, colIndex) {
|
|
@@ -4520,7 +4602,7 @@ var Table = function Table(_ref2) {
|
|
|
4520
4602
|
row: row,
|
|
4521
4603
|
index: globalIndex
|
|
4522
4604
|
})));
|
|
4523
|
-
}, [startIndex, selectedRows, expandedRows, rowClass, stripedRows, stripedColors, onRowClick, hasDetails, selectable, showSerial, withAction, visibleColumns, cellClass, DetailsComponent, actionsToUse,
|
|
4605
|
+
}, [startIndex, selectedRows, expandedRows, rowClass, stripedRows, stripedColors, onRowClick, hasDetails, selectable, showSerial, withAction, visibleColumns, cellClass, DetailsComponent, actionsToUse, activeActionRowKey, activeAnchorEl, toggleExpandRow, handleSelectRow, toggleActions, handleOnAction, closeActionMenu, renderCell]);
|
|
4524
4606
|
|
|
4525
4607
|
// Render mobile filters
|
|
4526
4608
|
var renderMobileFilters = React.useCallback(function () {
|
|
@@ -4587,6 +4669,110 @@ var Table = function Table(_ref2) {
|
|
|
4587
4669
|
};
|
|
4588
4670
|
});
|
|
4589
4671
|
}, [limitOptions]);
|
|
4672
|
+
|
|
4673
|
+
// Render desktop table rows
|
|
4674
|
+
var renderDesktopTableRows = React.useCallback(function () {
|
|
4675
|
+
return paginatedData.map(function (row, rowIndexInPage) {
|
|
4676
|
+
var globalIndex = startIndex + rowIndexInPage;
|
|
4677
|
+
var key = getRowKey(row, globalIndex);
|
|
4678
|
+
var actionCellKey = "actions-".concat(key);
|
|
4679
|
+
var isSelected = selectedRows.has(key);
|
|
4680
|
+
var isExpanded = expandedRows.has(key);
|
|
4681
|
+
var extraRowClass = typeof rowClass === "function" ? rowClass({
|
|
4682
|
+
row: row,
|
|
4683
|
+
rowIndex: globalIndex
|
|
4684
|
+
}) : "";
|
|
4685
|
+
var safeExtraRowClass = typeof extraRowClass === "string" ? extraRowClass.trim() : "";
|
|
4686
|
+
var stripeBg = stripedRows && !isSelected ? stripedColors[globalIndex % stripedColors.length] : undefined;
|
|
4687
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
4688
|
+
key: key
|
|
4689
|
+
}, /*#__PURE__*/React.createElement("tr", {
|
|
4690
|
+
style: stripeBg ? {
|
|
4691
|
+
backgroundColor: stripeBg
|
|
4692
|
+
} : undefined,
|
|
4693
|
+
className: cn$1("hover:bg-gray-50", {
|
|
4694
|
+
"cursor-pointer": !!onRowClick,
|
|
4695
|
+
"bg-primary-50": isSelected
|
|
4696
|
+
}, safeExtraRowClass),
|
|
4697
|
+
onClick: function onClick() {
|
|
4698
|
+
return onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(row, globalIndex);
|
|
4699
|
+
}
|
|
4700
|
+
}, hasDetails && /*#__PURE__*/React.createElement("td", {
|
|
4701
|
+
className: "px-4 py-4 text-sm"
|
|
4702
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
4703
|
+
onClick: function onClick(e) {
|
|
4704
|
+
e.stopPropagation();
|
|
4705
|
+
toggleExpandRow(row, rowIndexInPage);
|
|
4706
|
+
},
|
|
4707
|
+
"aria-expanded": isExpanded,
|
|
4708
|
+
className: "p-1 rounded hover:bg-gray-100"
|
|
4709
|
+
}, isExpanded ? "▾" : "▸")), showSerial && /*#__PURE__*/React.createElement("td", {
|
|
4710
|
+
className: "px-4 py-4 whitespace-nowrap text-sm text-gray-900"
|
|
4711
|
+
}, globalIndex + 1), selectable && /*#__PURE__*/React.createElement("td", {
|
|
4712
|
+
className: "px-6 py-4",
|
|
4713
|
+
onClick: function onClick(e) {
|
|
4714
|
+
return e.stopPropagation();
|
|
4715
|
+
}
|
|
4716
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
4717
|
+
type: "checkbox",
|
|
4718
|
+
className: "rounded border-gray-300",
|
|
4719
|
+
checked: isSelected,
|
|
4720
|
+
onChange: function onChange() {
|
|
4721
|
+
return handleSelectRow(row, rowIndexInPage);
|
|
4722
|
+
}
|
|
4723
|
+
})), visibleColumns.map(function (column, columnIndex) {
|
|
4724
|
+
var extraCellClass = typeof cellClass === "function" ? cellClass({
|
|
4725
|
+
row: row,
|
|
4726
|
+
rowIndex: globalIndex,
|
|
4727
|
+
column: column,
|
|
4728
|
+
columnIndex: columnIndex
|
|
4729
|
+
}) : "";
|
|
4730
|
+
var safeExtraCellClass = typeof extraCellClass === "string" ? extraCellClass.trim() : "";
|
|
4731
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
4732
|
+
key: column.key,
|
|
4733
|
+
className: cn$1("px-6 py-4 whitespace-nowrap text-sm text-gray-900", safeExtraCellClass)
|
|
4734
|
+
}, renderCell(column, row, globalIndex));
|
|
4735
|
+
}), /*#__PURE__*/React.createElement("td", {
|
|
4736
|
+
className: "px-4 py-4"
|
|
4737
|
+
}), withAction && /*#__PURE__*/React.createElement("td", {
|
|
4738
|
+
className: "px-4 py-4 text-sm text-right",
|
|
4739
|
+
onClick: function onClick(e) {
|
|
4740
|
+
return e.stopPropagation();
|
|
4741
|
+
}
|
|
4742
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4743
|
+
className: "relative inline-block"
|
|
4744
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
4745
|
+
ref: function ref(el) {
|
|
4746
|
+
if (el) {
|
|
4747
|
+
actionButtonRefs.current[actionCellKey] = el;
|
|
4748
|
+
}
|
|
4749
|
+
},
|
|
4750
|
+
onClick: function onClick(e) {
|
|
4751
|
+
return toggleActions(e, actionCellKey, row);
|
|
4752
|
+
},
|
|
4753
|
+
"aria-expanded": activeActionRowKey === actionCellKey,
|
|
4754
|
+
className: "p-1 rounded hover:bg-gray-100",
|
|
4755
|
+
title: "Actions"
|
|
4756
|
+
}, /*#__PURE__*/React.createElement(MoreVertical, {
|
|
4757
|
+
className: "h-4 w-4"
|
|
4758
|
+
})), activeActionRowKey === actionCellKey && /*#__PURE__*/React.createElement(ActionMenu, {
|
|
4759
|
+
actions: actionsToUse,
|
|
4760
|
+
row: row,
|
|
4761
|
+
onAction: function onAction(action) {
|
|
4762
|
+
return handleOnAction(action, row);
|
|
4763
|
+
},
|
|
4764
|
+
menuRef: actionMenuRef,
|
|
4765
|
+
anchorEl: activeAnchorEl,
|
|
4766
|
+
onClose: closeActionMenu
|
|
4767
|
+
})))), hasDetails && isExpanded && DetailsComponent && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
4768
|
+
colSpan: visibleCount,
|
|
4769
|
+
className: "px-6 py-4 bg-gray-50"
|
|
4770
|
+
}, /*#__PURE__*/React.createElement(DetailsComponent, {
|
|
4771
|
+
row: row,
|
|
4772
|
+
index: globalIndex
|
|
4773
|
+
}))));
|
|
4774
|
+
});
|
|
4775
|
+
}, [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]);
|
|
4590
4776
|
return /*#__PURE__*/React.createElement("div", {
|
|
4591
4777
|
className: "w-full border rounded-lg md:rounded-md bg-white"
|
|
4592
4778
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -4619,7 +4805,7 @@ var Table = function Table(_ref2) {
|
|
|
4619
4805
|
className: "flex flex-col sm:flex-row items-start sm:items-center gap-3 w-full md:w-auto"
|
|
4620
4806
|
}, /*#__PURE__*/React.createElement("div", {
|
|
4621
4807
|
className: "text-sm text-gray-700 whitespace-nowrap"
|
|
4622
|
-
}, filteredData.length === 0 ? 0 : startIndex + 1, " -", " ", Math.min(endIndex, filteredData.length), " of ", filteredData.length, " results"), pagination && /*#__PURE__*/React.createElement("div", {
|
|
4808
|
+
}, filteredData.length === 0 ? 0 : startIndex + 1, " -", " ", Math.min(endIndex, filteredData.length), " of ", filteredData.length, " ", "results"), pagination && /*#__PURE__*/React.createElement("div", {
|
|
4623
4809
|
className: "flex items-center gap-1"
|
|
4624
4810
|
}, totalPages >= 4 && /*#__PURE__*/React.createElement("button", {
|
|
4625
4811
|
className: "rounded-lg md:rounded-md border border-gray-300 p-2 disabled:opacity-50 hover:bg-gray-50",
|
|
@@ -4810,99 +4996,7 @@ var Table = function Table(_ref2) {
|
|
|
4810
4996
|
className: "h-8 w-8"
|
|
4811
4997
|
})), /*#__PURE__*/React.createElement("span", {
|
|
4812
4998
|
className: "text-sm text-gray-500"
|
|
4813
|
-
}, "No results found.")))) :
|
|
4814
|
-
var globalIndex = startIndex + rowIndexInPage;
|
|
4815
|
-
var key = getRowKey(row, globalIndex);
|
|
4816
|
-
var actionCellKey = "actions-".concat(key);
|
|
4817
|
-
var isSelected = selectedRows.has(key);
|
|
4818
|
-
var isExpanded = expandedRows.has(key);
|
|
4819
|
-
var extraRowClass = typeof rowClass === "function" ? rowClass({
|
|
4820
|
-
row: row,
|
|
4821
|
-
rowIndex: globalIndex
|
|
4822
|
-
}) : "";
|
|
4823
|
-
var safeExtraRowClass = typeof extraRowClass === "string" ? extraRowClass.trim() : "";
|
|
4824
|
-
var stripeBg = stripedRows && !isSelected ? stripedColors[globalIndex % stripedColors.length] : undefined;
|
|
4825
|
-
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
4826
|
-
key: key
|
|
4827
|
-
}, /*#__PURE__*/React.createElement("tr", {
|
|
4828
|
-
style: stripeBg ? {
|
|
4829
|
-
backgroundColor: stripeBg
|
|
4830
|
-
} : undefined,
|
|
4831
|
-
className: cn$1("hover:bg-gray-50", {
|
|
4832
|
-
"cursor-pointer": !!onRowClick,
|
|
4833
|
-
"bg-primary-50": isSelected
|
|
4834
|
-
}, safeExtraRowClass),
|
|
4835
|
-
onClick: function onClick() {
|
|
4836
|
-
return onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(row, globalIndex);
|
|
4837
|
-
}
|
|
4838
|
-
}, hasDetails && /*#__PURE__*/React.createElement("td", {
|
|
4839
|
-
className: "px-4 py-4 text-sm"
|
|
4840
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
4841
|
-
onClick: function onClick(e) {
|
|
4842
|
-
e.stopPropagation();
|
|
4843
|
-
toggleExpandRow(row, rowIndexInPage);
|
|
4844
|
-
},
|
|
4845
|
-
"aria-expanded": isExpanded,
|
|
4846
|
-
className: "p-1 rounded hover:bg-gray-100"
|
|
4847
|
-
}, isExpanded ? "▾" : "▸")), showSerial && /*#__PURE__*/React.createElement("td", {
|
|
4848
|
-
className: "px-4 py-4 whitespace-nowrap text-sm text-gray-900"
|
|
4849
|
-
}, globalIndex + 1), selectable && /*#__PURE__*/React.createElement("td", {
|
|
4850
|
-
className: "px-6 py-4",
|
|
4851
|
-
onClick: function onClick(e) {
|
|
4852
|
-
return e.stopPropagation();
|
|
4853
|
-
}
|
|
4854
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
4855
|
-
type: "checkbox",
|
|
4856
|
-
className: "rounded border-gray-300",
|
|
4857
|
-
checked: isSelected,
|
|
4858
|
-
onChange: function onChange() {
|
|
4859
|
-
return handleSelectRow(row, rowIndexInPage);
|
|
4860
|
-
}
|
|
4861
|
-
})), visibleColumns.map(function (column, columnIndex) {
|
|
4862
|
-
var extraCellClass = typeof cellClass === "function" ? cellClass({
|
|
4863
|
-
row: row,
|
|
4864
|
-
rowIndex: globalIndex,
|
|
4865
|
-
column: column,
|
|
4866
|
-
columnIndex: columnIndex
|
|
4867
|
-
}) : "";
|
|
4868
|
-
var safeExtraCellClass = typeof extraCellClass === "string" ? extraCellClass.trim() : "";
|
|
4869
|
-
return /*#__PURE__*/React.createElement("td", {
|
|
4870
|
-
key: column.key,
|
|
4871
|
-
className: cn$1("px-6 py-4 whitespace-nowrap text-sm text-gray-900", safeExtraCellClass)
|
|
4872
|
-
}, renderCell(column, row, globalIndex));
|
|
4873
|
-
}), /*#__PURE__*/React.createElement("td", {
|
|
4874
|
-
className: "px-4 py-4"
|
|
4875
|
-
}), withAction && /*#__PURE__*/React.createElement("td", {
|
|
4876
|
-
className: "px-4 py-4 text-sm text-right",
|
|
4877
|
-
onClick: function onClick(e) {
|
|
4878
|
-
return e.stopPropagation();
|
|
4879
|
-
}
|
|
4880
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
4881
|
-
className: "relative inline-block"
|
|
4882
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
4883
|
-
onClick: function onClick(e) {
|
|
4884
|
-
return toggleActions(e, actionCellKey, row);
|
|
4885
|
-
},
|
|
4886
|
-
"aria-expanded": (actionAnchor === null || actionAnchor === void 0 ? void 0 : actionAnchor.key) === actionCellKey,
|
|
4887
|
-
className: "p-1 rounded hover:bg-gray-100",
|
|
4888
|
-
title: "Actions"
|
|
4889
|
-
}, /*#__PURE__*/React.createElement(MoreVertical, {
|
|
4890
|
-
className: "h-4 w-4"
|
|
4891
|
-
})), (actionAnchor === null || actionAnchor === void 0 ? void 0 : actionAnchor.key) === actionCellKey && /*#__PURE__*/React.createElement(ActionMenu, {
|
|
4892
|
-
actions: actionsToUse,
|
|
4893
|
-
row: row,
|
|
4894
|
-
onAction: function onAction(action) {
|
|
4895
|
-
return handleOnAction(action, row);
|
|
4896
|
-
},
|
|
4897
|
-
menuRef: actionMenuRef
|
|
4898
|
-
})))), hasDetails && isExpanded && DetailsComponent && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
4899
|
-
colSpan: visibleCount,
|
|
4900
|
-
className: "px-6 py-4 bg-gray-50"
|
|
4901
|
-
}, /*#__PURE__*/React.createElement(DetailsComponent, {
|
|
4902
|
-
row: row,
|
|
4903
|
-
index: globalIndex
|
|
4904
|
-
}))));
|
|
4905
|
-
})))), isMobileView && /*#__PURE__*/React.createElement("div", {
|
|
4999
|
+
}, "No results found.")))) : renderDesktopTableRows()))), isMobileView && /*#__PURE__*/React.createElement("div", {
|
|
4906
5000
|
className: "p-4"
|
|
4907
5001
|
}, loading ? /*#__PURE__*/React.createElement("div", {
|
|
4908
5002
|
className: "py-8 text-center"
|