@dreamtree-org/twreact-ui 1.0.63 → 1.0.65
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 +506 -201
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +506 -201
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -240,7 +240,7 @@ const Check = createLucideIcon$1("Check", [
|
|
|
240
240
|
*/
|
|
241
241
|
|
|
242
242
|
|
|
243
|
-
const ChevronDown = createLucideIcon$1("ChevronDown", [
|
|
243
|
+
const ChevronDown$1 = createLucideIcon$1("ChevronDown", [
|
|
244
244
|
["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
|
|
245
245
|
]);
|
|
246
246
|
|
|
@@ -394,6 +394,20 @@ const Info = createLucideIcon$1("Info", [
|
|
|
394
394
|
*/
|
|
395
395
|
|
|
396
396
|
|
|
397
|
+
const List = createLucideIcon$1("List", [
|
|
398
|
+
["line", { x1: "8", x2: "21", y1: "6", y2: "6", key: "7ey8pc" }],
|
|
399
|
+
["line", { x1: "8", x2: "21", y1: "12", y2: "12", key: "rjfblc" }],
|
|
400
|
+
["line", { x1: "8", x2: "21", y1: "18", y2: "18", key: "c3b1m8" }],
|
|
401
|
+
["line", { x1: "3", x2: "3.01", y1: "6", y2: "6", key: "1g7gq3" }],
|
|
402
|
+
["line", { x1: "3", x2: "3.01", y1: "12", y2: "12", key: "1pjlvk" }],
|
|
403
|
+
["line", { x1: "3", x2: "3.01", y1: "18", y2: "18", key: "28t2mc" }]
|
|
404
|
+
]);
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* lucide-react v0.0.1 - ISC
|
|
408
|
+
*/
|
|
409
|
+
|
|
410
|
+
|
|
397
411
|
const Loader2 = createLucideIcon$1("Loader2", [
|
|
398
412
|
["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]
|
|
399
413
|
]);
|
|
@@ -476,6 +490,24 @@ const Plus = createLucideIcon$1("Plus", [
|
|
|
476
490
|
*/
|
|
477
491
|
|
|
478
492
|
|
|
493
|
+
const RefreshCcw = createLucideIcon$1("RefreshCcw", [
|
|
494
|
+
[
|
|
495
|
+
"path",
|
|
496
|
+
{ d: "M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "14sxne" }
|
|
497
|
+
],
|
|
498
|
+
["path", { d: "M3 3v5h5", key: "1xhq8a" }],
|
|
499
|
+
[
|
|
500
|
+
"path",
|
|
501
|
+
{ d: "M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16", key: "1hlbsb" }
|
|
502
|
+
],
|
|
503
|
+
["path", { d: "M16 16h5v5", key: "ccwih5" }]
|
|
504
|
+
]);
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* lucide-react v0.0.1 - ISC
|
|
508
|
+
*/
|
|
509
|
+
|
|
510
|
+
|
|
479
511
|
const Search = createLucideIcon$1("Search", [
|
|
480
512
|
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
|
|
481
513
|
["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
|
|
@@ -3684,7 +3716,7 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
3684
3716
|
return _objectSpread$a(_objectSpread$a({}, prev), {}, _defineProperty$4({}, group.label, !prev[group.label]));
|
|
3685
3717
|
});
|
|
3686
3718
|
}
|
|
3687
|
-
}, /*#__PURE__*/React.createElement(ChevronDown, {
|
|
3719
|
+
}, /*#__PURE__*/React.createElement(ChevronDown$1, {
|
|
3688
3720
|
className: cn$1("h-4 w-4 text-gray-400 transition-transform", {
|
|
3689
3721
|
"rotate-180": collapsedGroups[group.label]
|
|
3690
3722
|
})
|
|
@@ -3793,7 +3825,7 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
3793
3825
|
"aria-label": "Clear selection"
|
|
3794
3826
|
}, /*#__PURE__*/React.createElement(X, {
|
|
3795
3827
|
className: "h-4 w-4"
|
|
3796
|
-
})), /*#__PURE__*/React.createElement(ChevronDown, {
|
|
3828
|
+
})), /*#__PURE__*/React.createElement(ChevronDown$1, {
|
|
3797
3829
|
className: cn$1("h-4 w-4 text-gray-400 transition-transform", {
|
|
3798
3830
|
"rotate-180": isOpen
|
|
3799
3831
|
})
|
|
@@ -3851,7 +3883,7 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
3851
3883
|
}, error));
|
|
3852
3884
|
});
|
|
3853
3885
|
|
|
3854
|
-
var _excluded$k = ["data", "columns", "sortable", "filterable", "selectable", "pagination", "pageSize", "onSort", "onFilter", "onFetch", "onFilterChange", "onSelectionChange", "onRowClick", "hasDetails", "DetailsComponent", "className", "withAction", "onAction", "actions", "showSerial", "cellClass", "rowClass", "globalSearch", "limitOptions", "showLimitSelector", "onLimitChange"];
|
|
3886
|
+
var _excluded$k = ["data", "columns", "sortable", "filterable", "selectable", "pagination", "pageSize", "onSort", "onFilter", "onFetch", "onFilterChange", "onSelectionChange", "onRowClick", "hasDetails", "DetailsComponent", "className", "withAction", "onAction", "actions", "showSerial", "cellClass", "rowClass", "globalSearch", "limitOptions", "showLimitSelector", "onLimitChange", "showReloadButton", "renderReloadButton", "onReload", "stripedRows", "stripedColors", "responsiveBreakpoint"];
|
|
3855
3887
|
function ownKeys$9(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3856
3888
|
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), true).forEach(function (r) { _defineProperty$4(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3857
3889
|
var Table = function Table(_ref) {
|
|
@@ -3895,87 +3927,123 @@ var Table = function Table(_ref) {
|
|
|
3895
3927
|
_ref$showLimitSelecto = _ref.showLimitSelector,
|
|
3896
3928
|
showLimitSelector = _ref$showLimitSelecto === void 0 ? true : _ref$showLimitSelecto,
|
|
3897
3929
|
onLimitChange = _ref.onLimitChange,
|
|
3930
|
+
_ref$showReloadButton = _ref.showReloadButton,
|
|
3931
|
+
showReloadButton = _ref$showReloadButton === void 0 ? true : _ref$showReloadButton,
|
|
3932
|
+
renderReloadButton = _ref.renderReloadButton,
|
|
3933
|
+
onReload = _ref.onReload,
|
|
3934
|
+
_ref$stripedRows = _ref.stripedRows,
|
|
3935
|
+
stripedRows = _ref$stripedRows === void 0 ? true : _ref$stripedRows,
|
|
3936
|
+
_ref$stripedColors = _ref.stripedColors,
|
|
3937
|
+
stripedColors = _ref$stripedColors === void 0 ? ["#ffffff", "#f7fafc"] : _ref$stripedColors,
|
|
3938
|
+
_ref$responsiveBreakp = _ref.responsiveBreakpoint,
|
|
3939
|
+
responsiveBreakpoint = _ref$responsiveBreakp === void 0 ? 768 : _ref$responsiveBreakp,
|
|
3898
3940
|
props = _objectWithoutProperties$1(_ref, _excluded$k);
|
|
3899
|
-
//
|
|
3900
|
-
var _useState = React.useState(
|
|
3941
|
+
// State for responsive view
|
|
3942
|
+
var _useState = React.useState(false),
|
|
3901
3943
|
_useState2 = _slicedToArray(_useState, 2),
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3944
|
+
isMobileView = _useState2[0],
|
|
3945
|
+
setIsMobileView = _useState2[1];
|
|
3946
|
+
|
|
3947
|
+
// Keep original table data / loading
|
|
3948
|
+
var _useState3 = React.useState(Array.isArray(data) ? data : []),
|
|
3905
3949
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
3906
|
-
|
|
3907
|
-
|
|
3950
|
+
tableData = _useState4[0],
|
|
3951
|
+
setTableData = _useState4[1];
|
|
3952
|
+
var _useState5 = React.useState(false),
|
|
3953
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
3954
|
+
loading = _useState6[0],
|
|
3955
|
+
setLoading = _useState6[1];
|
|
3908
3956
|
|
|
3909
|
-
//
|
|
3910
|
-
var
|
|
3957
|
+
// Column visibility state
|
|
3958
|
+
var _useState7 = React.useState(function () {
|
|
3911
3959
|
return Array.isArray(columns) ? columns.map(function (c) {
|
|
3912
3960
|
return _objectSpread$9({}, c);
|
|
3913
3961
|
}) : [];
|
|
3914
3962
|
}),
|
|
3915
|
-
|
|
3916
|
-
columnsState =
|
|
3917
|
-
setColumnsState =
|
|
3963
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
3964
|
+
columnsState = _useState8[0],
|
|
3965
|
+
setColumnsState = _useState8[1];
|
|
3918
3966
|
React.useEffect(function () {
|
|
3919
|
-
//
|
|
3967
|
+
// Sync when prop changes
|
|
3920
3968
|
setColumnsState(Array.isArray(columns) ? columns.map(function (c) {
|
|
3921
3969
|
return _objectSpread$9({}, c);
|
|
3922
3970
|
}) : []);
|
|
3923
3971
|
}, [columns]);
|
|
3924
3972
|
|
|
3925
|
-
//
|
|
3926
|
-
var
|
|
3927
|
-
|
|
3928
|
-
showColumnMenu =
|
|
3929
|
-
setShowColumnMenu =
|
|
3973
|
+
// Popover state for column toggler
|
|
3974
|
+
var _useState9 = React.useState(false),
|
|
3975
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
3976
|
+
showColumnMenu = _useState0[0],
|
|
3977
|
+
setShowColumnMenu = _useState0[1];
|
|
3930
3978
|
var columnMenuRef = React.useRef(null);
|
|
3931
3979
|
var columnToggleBtnRef = React.useRef(null);
|
|
3932
|
-
var
|
|
3933
|
-
|
|
3934
|
-
limit =
|
|
3935
|
-
setLimit =
|
|
3980
|
+
var _useState1 = React.useState(pageSize),
|
|
3981
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
3982
|
+
limit = _useState10[0],
|
|
3983
|
+
setLimit = _useState10[1];
|
|
3936
3984
|
|
|
3937
|
-
//
|
|
3938
|
-
var
|
|
3985
|
+
// Other states
|
|
3986
|
+
var _useState11 = React.useState({
|
|
3939
3987
|
key: null,
|
|
3940
3988
|
direction: "asc"
|
|
3941
3989
|
}),
|
|
3942
|
-
_useState10 = _slicedToArray(_useState1, 2),
|
|
3943
|
-
sortConfig = _useState10[0],
|
|
3944
|
-
setSortConfig = _useState10[1];
|
|
3945
|
-
var _useState11 = React.useState(new Set()),
|
|
3946
3990
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
3947
|
-
|
|
3948
|
-
|
|
3991
|
+
sortConfig = _useState12[0],
|
|
3992
|
+
setSortConfig = _useState12[1];
|
|
3949
3993
|
var _useState13 = React.useState(new Set()),
|
|
3950
3994
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
var _useState15 = React.useState(
|
|
3995
|
+
selectedRows = _useState14[0],
|
|
3996
|
+
setSelectedRows = _useState14[1];
|
|
3997
|
+
var _useState15 = React.useState(new Set()),
|
|
3954
3998
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
var _useState17 = React.useState(
|
|
3999
|
+
expandedRows = _useState16[0],
|
|
4000
|
+
setExpandedRows = _useState16[1];
|
|
4001
|
+
var _useState17 = React.useState(1),
|
|
3958
4002
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
var _useState19 = React.useState(
|
|
4003
|
+
currentPage = _useState18[0],
|
|
4004
|
+
setCurrentPage = _useState18[1];
|
|
4005
|
+
var _useState19 = React.useState({}),
|
|
3962
4006
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
//popover per-row
|
|
3967
|
-
var _useState21 = React.useState(null),
|
|
4007
|
+
filters = _useState20[0],
|
|
4008
|
+
setFilters = _useState20[1];
|
|
4009
|
+
var _useState21 = React.useState(filters.global || ""),
|
|
3968
4010
|
_useState22 = _slicedToArray(_useState21, 2),
|
|
3969
|
-
|
|
3970
|
-
|
|
4011
|
+
searchInput = _useState22[0],
|
|
4012
|
+
setSearchInput = _useState22[1];
|
|
4013
|
+
var _useState23 = React.useState(false),
|
|
4014
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
4015
|
+
showMobileFilters = _useState24[0],
|
|
4016
|
+
setShowMobileFilters = _useState24[1];
|
|
4017
|
+
|
|
4018
|
+
// Popover per-row
|
|
4019
|
+
var _useState25 = React.useState(null),
|
|
4020
|
+
_useState26 = _slicedToArray(_useState25, 2),
|
|
4021
|
+
actionAnchor = _useState26[0],
|
|
4022
|
+
setActionAnchor = _useState26[1];
|
|
3971
4023
|
var actionMenuRef = React.useRef(null);
|
|
3972
4024
|
|
|
3973
|
-
//
|
|
3974
|
-
var
|
|
3975
|
-
|
|
3976
|
-
openActionKey =
|
|
3977
|
-
setOpenActionKey =
|
|
4025
|
+
// Per-row action menu open key
|
|
4026
|
+
var _useState27 = React.useState(null),
|
|
4027
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
|
4028
|
+
openActionKey = _useState28[0],
|
|
4029
|
+
setOpenActionKey = _useState28[1];
|
|
3978
4030
|
var openRef = React.useRef(null);
|
|
4031
|
+
|
|
4032
|
+
// Check if mobile view
|
|
4033
|
+
React.useEffect(function () {
|
|
4034
|
+
var checkMobile = function checkMobile() {
|
|
4035
|
+
setIsMobileView(window.innerWidth < responsiveBreakpoint);
|
|
4036
|
+
};
|
|
4037
|
+
|
|
4038
|
+
// Initial check
|
|
4039
|
+
checkMobile();
|
|
4040
|
+
|
|
4041
|
+
// Add event listener
|
|
4042
|
+
window.addEventListener("resize", checkMobile);
|
|
4043
|
+
return function () {
|
|
4044
|
+
window.removeEventListener("resize", checkMobile);
|
|
4045
|
+
};
|
|
4046
|
+
}, [responsiveBreakpoint]);
|
|
3979
4047
|
var isValidList = function isValidList(d) {
|
|
3980
4048
|
return Array.isArray(d);
|
|
3981
4049
|
};
|
|
@@ -3983,7 +4051,7 @@ var Table = function Table(_ref) {
|
|
|
3983
4051
|
if (isValidList(newData)) setTableData(newData);else setTableData([]);
|
|
3984
4052
|
};
|
|
3985
4053
|
|
|
3986
|
-
//
|
|
4054
|
+
// Close column menu when clicking outside
|
|
3987
4055
|
React.useEffect(function () {
|
|
3988
4056
|
var onDocClick = function onDocClick(e) {
|
|
3989
4057
|
if (showColumnMenu && columnMenuRef.current && !columnMenuRef.current.contains(e.target) && columnToggleBtnRef.current && !columnToggleBtnRef.current.contains(e.target)) {
|
|
@@ -3996,7 +4064,7 @@ var Table = function Table(_ref) {
|
|
|
3996
4064
|
};
|
|
3997
4065
|
}, [showColumnMenu]);
|
|
3998
4066
|
|
|
3999
|
-
//
|
|
4067
|
+
// Close per-row actionmenu when clicking outside
|
|
4000
4068
|
React.useEffect(function () {
|
|
4001
4069
|
var handler = function handler(e) {
|
|
4002
4070
|
if (openActionKey && openRef.current && !openRef.current.contains(e.target)) {
|
|
@@ -4009,7 +4077,7 @@ var Table = function Table(_ref) {
|
|
|
4009
4077
|
};
|
|
4010
4078
|
}, [openActionKey]);
|
|
4011
4079
|
|
|
4012
|
-
//
|
|
4080
|
+
// Visible columns derived from columnsState
|
|
4013
4081
|
var visibleColumns = React.useMemo(function () {
|
|
4014
4082
|
return columnsState.filter(function (col) {
|
|
4015
4083
|
return col.isVisible !== false;
|
|
@@ -4026,7 +4094,7 @@ var Table = function Table(_ref) {
|
|
|
4026
4094
|
setCurrentPage(1);
|
|
4027
4095
|
};
|
|
4028
4096
|
|
|
4029
|
-
//
|
|
4097
|
+
// Handle actions
|
|
4030
4098
|
var handleOnAction = function handleOnAction(action, row) {
|
|
4031
4099
|
var _action$onClick;
|
|
4032
4100
|
(_action$onClick = action.onClick) === null || _action$onClick === void 0 || _action$onClick.call(action, {
|
|
@@ -4076,7 +4144,7 @@ var Table = function Table(_ref) {
|
|
|
4076
4144
|
return String(globalIndex);
|
|
4077
4145
|
};
|
|
4078
4146
|
|
|
4079
|
-
//
|
|
4147
|
+
// Sorting
|
|
4080
4148
|
var sortedData = React.useMemo(function () {
|
|
4081
4149
|
if (!sortConfig.key) return tableData;
|
|
4082
4150
|
var key = sortConfig.key,
|
|
@@ -4098,19 +4166,17 @@ var Table = function Table(_ref) {
|
|
|
4098
4166
|
});
|
|
4099
4167
|
}, [tableData, sortConfig]);
|
|
4100
4168
|
|
|
4101
|
-
//
|
|
4169
|
+
// Filtering
|
|
4102
4170
|
var filteredData = React.useMemo(function () {
|
|
4103
|
-
// if no filtering enabled, return sortedData
|
|
4104
|
-
|
|
4105
4171
|
if (!filterable || Object.keys(filters).length === 0) return sortedData;
|
|
4106
4172
|
var globalQuery = String(filters.global || "").trim().toLowerCase();
|
|
4107
4173
|
return sortedData.filter(function (row) {
|
|
4108
|
-
//
|
|
4174
|
+
// Per-column filters
|
|
4109
4175
|
var perColumnOk = Object.entries(filters).every(function (_ref2) {
|
|
4110
4176
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
4111
4177
|
key = _ref3[0],
|
|
4112
4178
|
value = _ref3[1];
|
|
4113
|
-
if (key === "global") return true;
|
|
4179
|
+
if (key === "global") return true;
|
|
4114
4180
|
if (!value) return true;
|
|
4115
4181
|
var cell = row === null || row === void 0 ? void 0 : row[key];
|
|
4116
4182
|
if (cell == null) return false;
|
|
@@ -4118,18 +4184,14 @@ var Table = function Table(_ref) {
|
|
|
4118
4184
|
});
|
|
4119
4185
|
if (!perColumnOk) return false;
|
|
4120
4186
|
|
|
4121
|
-
//
|
|
4122
|
-
// fallback to searching all row values
|
|
4187
|
+
// Global filter
|
|
4123
4188
|
if (globalQuery) {
|
|
4124
|
-
// try visible columns
|
|
4125
4189
|
var matchesVisible = visibleColumns.some(function (col) {
|
|
4126
4190
|
var v = row === null || row === void 0 ? void 0 : row[col.key];
|
|
4127
4191
|
if (v == null) return false;
|
|
4128
4192
|
return String(v).toLowerCase().includes(globalQuery);
|
|
4129
4193
|
});
|
|
4130
4194
|
if (matchesVisible) return true;
|
|
4131
|
-
|
|
4132
|
-
// fallback: check any value in the row object
|
|
4133
4195
|
return Object.values(row || {}).some(function (v) {
|
|
4134
4196
|
return v != null ? String(v).toLowerCase().includes(globalQuery) : false;
|
|
4135
4197
|
});
|
|
@@ -4138,18 +4200,18 @@ var Table = function Table(_ref) {
|
|
|
4138
4200
|
});
|
|
4139
4201
|
}, [sortedData, filters, filterable, visibleColumns]);
|
|
4140
4202
|
|
|
4141
|
-
//
|
|
4203
|
+
// Pagination indices
|
|
4142
4204
|
var startIndex = pagination ? (currentPage - 1) * limit : 0;
|
|
4143
4205
|
var endIndex = pagination ? startIndex + limit : filteredData.length;
|
|
4144
4206
|
|
|
4145
|
-
//
|
|
4207
|
+
// Paginated view
|
|
4146
4208
|
var paginatedData = React.useMemo(function () {
|
|
4147
4209
|
if (!pagination) return filteredData;
|
|
4148
4210
|
return filteredData.slice(startIndex, endIndex);
|
|
4149
4211
|
}, [filteredData, startIndex, endIndex, pagination]);
|
|
4150
4212
|
var totalPages = Math.max(1, Math.ceil(filteredData.length / limit));
|
|
4151
4213
|
|
|
4152
|
-
//
|
|
4214
|
+
// Sorting handler
|
|
4153
4215
|
var handleSort = function handleSort(key) {
|
|
4154
4216
|
if (!sortable) return;
|
|
4155
4217
|
var direction = sortConfig.key === key && sortConfig.direction === "asc" ? "desc" : "asc";
|
|
@@ -4160,10 +4222,9 @@ var Table = function Table(_ref) {
|
|
|
4160
4222
|
onSort === null || onSort === void 0 || onSort(key, direction);
|
|
4161
4223
|
};
|
|
4162
4224
|
|
|
4163
|
-
//
|
|
4225
|
+
// Selection handlers
|
|
4164
4226
|
var handleSelectAll = function handleSelectAll() {
|
|
4165
4227
|
var newSelection = new Set(selectedRows);
|
|
4166
|
-
// select/deselect all rows on current page
|
|
4167
4228
|
var pageRowKeys = paginatedData.map(function (r, i) {
|
|
4168
4229
|
return getRowKey(r, startIndex + i);
|
|
4169
4230
|
});
|
|
@@ -4221,7 +4282,7 @@ var Table = function Table(_ref) {
|
|
|
4221
4282
|
return row === null || row === void 0 ? void 0 : row[column.key];
|
|
4222
4283
|
};
|
|
4223
4284
|
|
|
4224
|
-
// UI counts
|
|
4285
|
+
// UI counts
|
|
4225
4286
|
var visibleCount = (showSerial ? 1 : 0) + visibleColumns.length + (selectable ? 1 : 0) + (hasDetails ? 1 : 0) + (withAction ? 1 : 0);
|
|
4226
4287
|
var toggleActions = function toggleActions(e, actionCellKey, row) {
|
|
4227
4288
|
e.stopPropagation();
|
|
@@ -4261,32 +4322,28 @@ var Table = function Table(_ref) {
|
|
|
4261
4322
|
};
|
|
4262
4323
|
}, [actionAnchor]);
|
|
4263
4324
|
React.useEffect(function () {
|
|
4264
|
-
if (onFetch)
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
});
|
|
4278
|
-
}
|
|
4279
|
-
}, [filters, onFetch, currentPage, limit, paginatedData]);
|
|
4325
|
+
if (!onFetch) return;
|
|
4326
|
+
onFetch({
|
|
4327
|
+
setData: setDataForExternal,
|
|
4328
|
+
filters: filters,
|
|
4329
|
+
setLoading: setLoading,
|
|
4330
|
+
pagination: {
|
|
4331
|
+
currentPage: currentPage,
|
|
4332
|
+
limit: limit,
|
|
4333
|
+
totalPages: totalPages,
|
|
4334
|
+
nextRecords: paginatedData
|
|
4335
|
+
}
|
|
4336
|
+
});
|
|
4337
|
+
}, [filters, currentPage, limit]);
|
|
4280
4338
|
React.useEffect(function () {
|
|
4281
4339
|
if (!onFetch && isValidList(data)) setTableData(data);
|
|
4282
4340
|
}, [data, onFetch]);
|
|
4283
4341
|
|
|
4284
|
-
//
|
|
4342
|
+
// Global search
|
|
4285
4343
|
React.useEffect(function () {
|
|
4286
4344
|
setSearchInput(filters.global || "");
|
|
4287
4345
|
}, [filters.global]);
|
|
4288
4346
|
var applyGlobalSearch = function applyGlobalSearch() {
|
|
4289
|
-
// apply filter only when user clicks Search or presses Enter
|
|
4290
4347
|
handleFilter("global", searchInput);
|
|
4291
4348
|
};
|
|
4292
4349
|
var onGlobalKeyDown = function onGlobalKeyDown(e) {
|
|
@@ -4305,38 +4362,274 @@ var Table = function Table(_ref) {
|
|
|
4305
4362
|
onLimitChange === null || onLimitChange === void 0 || onLimitChange(parsed);
|
|
4306
4363
|
};
|
|
4307
4364
|
|
|
4308
|
-
//
|
|
4365
|
+
// Render mobile card
|
|
4366
|
+
var renderMobileCard = function renderMobileCard(row, rowIndexInPage) {
|
|
4367
|
+
var globalIndex = startIndex + rowIndexInPage;
|
|
4368
|
+
var key = getRowKey(row, globalIndex);
|
|
4369
|
+
var actionCellKey = "actions-".concat(key);
|
|
4370
|
+
var extraRowClass = typeof rowClass === "function" ? rowClass({
|
|
4371
|
+
row: row,
|
|
4372
|
+
rowIndex: globalIndex
|
|
4373
|
+
}) : "";
|
|
4374
|
+
var safeExtraRowClass = typeof extraRowClass === "string" ? extraRowClass.trim() : "";
|
|
4375
|
+
var stripeBg = stripedRows && !selectedRows.has(key) ? stripedColors[globalIndex % stripedColors.length] : undefined;
|
|
4376
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
4377
|
+
key: key,
|
|
4378
|
+
style: stripeBg ? {
|
|
4379
|
+
backgroundColor: stripeBg
|
|
4380
|
+
} : undefined,
|
|
4381
|
+
className: cn$1("border rounded-lg mb-3 shadow-sm overflow-hidden transition-all duration-200", {
|
|
4382
|
+
"cursor-pointer": !!onRowClick,
|
|
4383
|
+
"bg-primary-50 border-primary-200": selectedRows.has(key),
|
|
4384
|
+
"hover:shadow-md": !selectedRows.has(key)
|
|
4385
|
+
}, safeExtraRowClass),
|
|
4386
|
+
onClick: function onClick() {
|
|
4387
|
+
return onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(row, globalIndex);
|
|
4388
|
+
}
|
|
4389
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4390
|
+
className: "flex items-center justify-between p-4 border-b bg-gray-50"
|
|
4391
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4392
|
+
className: "flex items-center gap-3"
|
|
4393
|
+
}, hasDetails && /*#__PURE__*/React.createElement("button", {
|
|
4394
|
+
onClick: function onClick(e) {
|
|
4395
|
+
e.stopPropagation();
|
|
4396
|
+
toggleExpandRow(row, rowIndexInPage);
|
|
4397
|
+
},
|
|
4398
|
+
"aria-expanded": expandedRows.has(key),
|
|
4399
|
+
className: "p-1 rounded hover:bg-gray-200"
|
|
4400
|
+
}, expandedRows.has(key) ? "▾" : "▸"), selectable && /*#__PURE__*/React.createElement("input", {
|
|
4401
|
+
type: "checkbox",
|
|
4402
|
+
className: "rounded border-gray-300 h-4 w-4",
|
|
4403
|
+
checked: selectedRows.has(key),
|
|
4404
|
+
onChange: function onChange(e) {
|
|
4405
|
+
e.stopPropagation();
|
|
4406
|
+
handleSelectRow(row, rowIndexInPage);
|
|
4407
|
+
},
|
|
4408
|
+
onClick: function onClick(e) {
|
|
4409
|
+
return e.stopPropagation();
|
|
4410
|
+
}
|
|
4411
|
+
}), showSerial && /*#__PURE__*/React.createElement("span", {
|
|
4412
|
+
className: "text-sm font-medium text-gray-600"
|
|
4413
|
+
}, "#", globalIndex + 1)), withAction && /*#__PURE__*/React.createElement("div", {
|
|
4414
|
+
className: "relative"
|
|
4415
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
4416
|
+
onClick: function onClick(e) {
|
|
4417
|
+
e.stopPropagation();
|
|
4418
|
+
toggleActions(e, actionCellKey, row);
|
|
4419
|
+
},
|
|
4420
|
+
"aria-expanded": openActionKey === actionCellKey,
|
|
4421
|
+
className: "p-1.5 rounded hover:bg-gray-200",
|
|
4422
|
+
title: "Actions"
|
|
4423
|
+
}, /*#__PURE__*/React.createElement(MoreVertical, {
|
|
4424
|
+
className: "h-4 w-4"
|
|
4425
|
+
})), actionAnchor && actionAnchor.key === actionCellKey && /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/React.createElement(ActionMenuPortal, {
|
|
4426
|
+
anchorElem: actionAnchor.elem,
|
|
4427
|
+
anchorRow: actionAnchor.row,
|
|
4428
|
+
actions: actionsToUse,
|
|
4429
|
+
onClose: function onClose() {
|
|
4430
|
+
setOpenActionKey(null);
|
|
4431
|
+
setActionAnchor(null);
|
|
4432
|
+
},
|
|
4433
|
+
onAction: function onAction(action) {
|
|
4434
|
+
handleOnAction(action, row);
|
|
4435
|
+
setOpenActionKey(null);
|
|
4436
|
+
setActionAnchor(null);
|
|
4437
|
+
},
|
|
4438
|
+
menuRef: actionMenuRef
|
|
4439
|
+
}), document.body))), /*#__PURE__*/React.createElement("div", {
|
|
4440
|
+
className: "p-4"
|
|
4441
|
+
}, visibleColumns.map(function (column, colIndex) {
|
|
4442
|
+
var extraCellClass = typeof cellClass === "function" ? cellClass({
|
|
4443
|
+
row: row,
|
|
4444
|
+
rowIndex: globalIndex,
|
|
4445
|
+
column: column,
|
|
4446
|
+
columnIndex: colIndex
|
|
4447
|
+
}) : "";
|
|
4448
|
+
var safeExtraCellClass = typeof extraCellClass === "string" ? extraCellClass.trim() : "";
|
|
4449
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
4450
|
+
key: column.key,
|
|
4451
|
+
className: cn$1("flex justify-between items-center flex-row py-2 border-b last:border-b-0", safeExtraCellClass)
|
|
4452
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4453
|
+
className: "text-xs font-medium text-gray-500 uppercase tracking-wide mb-1 sm:mb-0 sm:w-1/3 sm:pr-2"
|
|
4454
|
+
}, column.label), /*#__PURE__*/React.createElement("div", {
|
|
4455
|
+
className: "text-sm text-gray-900 sm:w-2/3 sm:pl-2 break-words"
|
|
4456
|
+
}, renderCell(column, row, globalIndex)));
|
|
4457
|
+
})), hasDetails && expandedRows.has(key) && DetailsComponent && /*#__PURE__*/React.createElement("div", {
|
|
4458
|
+
className: "border-t bg-gray-50 p-4"
|
|
4459
|
+
}, /*#__PURE__*/React.createElement(DetailsComponent, {
|
|
4460
|
+
row: row,
|
|
4461
|
+
index: globalIndex
|
|
4462
|
+
})));
|
|
4463
|
+
};
|
|
4464
|
+
|
|
4465
|
+
// Render mobile filters
|
|
4466
|
+
var renderMobileFilters = function renderMobileFilters() {
|
|
4467
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
4468
|
+
className: "mb-4 p-3 bg-gray-50 rounded-lg"
|
|
4469
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4470
|
+
className: "flex items-center justify-between mb-3"
|
|
4471
|
+
}, /*#__PURE__*/React.createElement("h3", {
|
|
4472
|
+
className: "text-sm font-medium text-gray-700"
|
|
4473
|
+
}, "Filters"), /*#__PURE__*/React.createElement("button", {
|
|
4474
|
+
onClick: function onClick() {
|
|
4475
|
+
return setShowMobileFilters(!showMobileFilters);
|
|
4476
|
+
},
|
|
4477
|
+
className: "text-xs text-gray-500 hover:text-gray-700"
|
|
4478
|
+
}, showMobileFilters ? "Hide" : "Show")), showMobileFilters && /*#__PURE__*/React.createElement("div", {
|
|
4479
|
+
className: "space-y-3"
|
|
4480
|
+
}, globalSearch && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
4481
|
+
className: "relative"
|
|
4482
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
4483
|
+
type: "text",
|
|
4484
|
+
placeholder: "Search...",
|
|
4485
|
+
className: "w-full rounded-md border border-gray-300 px-4 py-2 text-sm",
|
|
4486
|
+
value: searchInput,
|
|
4487
|
+
onChange: function onChange(e) {
|
|
4488
|
+
return setSearchInput(e.target.value);
|
|
4489
|
+
},
|
|
4490
|
+
onKeyDown: onGlobalKeyDown
|
|
4491
|
+
}), /*#__PURE__*/React.createElement(Search, {
|
|
4492
|
+
className: "absolute right-3 top-2.5 h-4 w-4 text-gray-400"
|
|
4493
|
+
}))), filterable && visibleColumns.map(function (column) {
|
|
4494
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
4495
|
+
key: column.key
|
|
4496
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
4497
|
+
className: "block text-xs font-medium text-gray-600 mb-1"
|
|
4498
|
+
}, column.label), /*#__PURE__*/React.createElement("input", {
|
|
4499
|
+
type: "text",
|
|
4500
|
+
placeholder: "Filter ".concat(column.label),
|
|
4501
|
+
className: "w-full rounded-md border border-gray-300 px-3 py-2 text-sm",
|
|
4502
|
+
value: filters[column.key] || "",
|
|
4503
|
+
onChange: function onChange(e) {
|
|
4504
|
+
return handleFilter(column.key, e.target.value);
|
|
4505
|
+
}
|
|
4506
|
+
}));
|
|
4507
|
+
})));
|
|
4508
|
+
};
|
|
4509
|
+
|
|
4510
|
+
// Render
|
|
4309
4511
|
return /*#__PURE__*/React.createElement("div", {
|
|
4310
|
-
className: "w-full"
|
|
4311
|
-
},
|
|
4312
|
-
className: "
|
|
4512
|
+
className: "w-full border rounded-lg md:rounded-md bg-white"
|
|
4513
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4514
|
+
className: "flex flex-col md:flex-row justify-between items-start md:items-center gap-3 p-4 border-b"
|
|
4515
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4516
|
+
className: "flex flex-col sm:flex-row items-start sm:items-center gap-3 w-full md:w-auto"
|
|
4517
|
+
}, showReloadButton && /*#__PURE__*/React.createElement(React.Fragment, null, renderReloadButton ? typeof renderReloadButton === "function" ? renderReloadButton() : renderReloadButton : /*#__PURE__*/React.createElement("button", {
|
|
4518
|
+
type: "button",
|
|
4519
|
+
className: "px-4 py-2 bg-primary-100 flex items-center gap-2 rounded-lg md:rounded text-primary-700 hover:bg-primary-200 transition-colors",
|
|
4520
|
+
onClick: onReload
|
|
4521
|
+
}, /*#__PURE__*/React.createElement(RefreshCcw, {
|
|
4522
|
+
className: "size-4"
|
|
4523
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
4524
|
+
className: "hidden sm:inline"
|
|
4525
|
+
}, "Reload"))), showLimitSelector && /*#__PURE__*/React.createElement("div", {
|
|
4526
|
+
className: "flex items-center gap-2"
|
|
4527
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
4528
|
+
htmlFor: "pagination-limit",
|
|
4529
|
+
className: "text-sm text-gray-600 whitespace-nowrap"
|
|
4530
|
+
}, "Show"), /*#__PURE__*/React.createElement(Select, {
|
|
4531
|
+
options: Array.isArray(limitOptions) && limitOptions.length > 0 ? limitOptions.map(function (opt) {
|
|
4532
|
+
return {
|
|
4533
|
+
label: String(opt),
|
|
4534
|
+
value: opt
|
|
4535
|
+
};
|
|
4536
|
+
}) : [25, 50, 100].map(function (opt) {
|
|
4537
|
+
return {
|
|
4538
|
+
label: String(opt),
|
|
4539
|
+
value: opt
|
|
4540
|
+
};
|
|
4541
|
+
}),
|
|
4542
|
+
value: limit,
|
|
4543
|
+
allowClear: false,
|
|
4544
|
+
placeholder: "",
|
|
4545
|
+
onChange: function onChange(e) {
|
|
4546
|
+
return handleLimitChange(e);
|
|
4547
|
+
},
|
|
4548
|
+
className: "w-20 md:w-30"
|
|
4549
|
+
}), /*#__PURE__*/React.createElement("p", {
|
|
4550
|
+
className: "text-sm text-gray-600 whitespace-nowrap"
|
|
4551
|
+
}, "entries"))), /*#__PURE__*/React.createElement("div", {
|
|
4552
|
+
className: "flex flex-col sm:flex-row items-start sm:items-center gap-3 w-full md:w-auto"
|
|
4553
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4554
|
+
className: "text-sm text-gray-700 whitespace-nowrap"
|
|
4555
|
+
}, filteredData.length === 0 ? 0 : startIndex + 1, " -", " ", Math.min(endIndex, filteredData.length), " of ", filteredData.length, " ", "results"), pagination && /*#__PURE__*/React.createElement("div", {
|
|
4556
|
+
className: "flex items-center gap-1"
|
|
4557
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4558
|
+
className: "flex gap-1"
|
|
4559
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
4560
|
+
className: "rounded-lg md:rounded-md border border-gray-300 p-2 disabled:opacity-50 hover:bg-gray-50",
|
|
4561
|
+
disabled: currentPage === 1,
|
|
4562
|
+
onClick: function onClick() {
|
|
4563
|
+
return setCurrentPage(function (p) {
|
|
4564
|
+
return Math.max(1, p - 1);
|
|
4565
|
+
});
|
|
4566
|
+
},
|
|
4567
|
+
"aria-label": "Previous page"
|
|
4568
|
+
}, /*#__PURE__*/React.createElement(ChevronLeft, {
|
|
4569
|
+
className: "size-4 md:size-5 text-gray-800"
|
|
4570
|
+
})), /*#__PURE__*/React.createElement("button", {
|
|
4571
|
+
className: "rounded-lg md:rounded-md border border-gray-300 p-2 disabled:opacity-50 hover:bg-gray-50",
|
|
4572
|
+
disabled: currentPage === totalPages,
|
|
4573
|
+
onClick: function onClick() {
|
|
4574
|
+
return setCurrentPage(function (p) {
|
|
4575
|
+
return Math.min(totalPages, p + 1);
|
|
4576
|
+
});
|
|
4577
|
+
},
|
|
4578
|
+
"aria-label": "Next page"
|
|
4579
|
+
}, /*#__PURE__*/React.createElement(ChevronRight, {
|
|
4580
|
+
className: "size-4 md:size-5 text-gray-800"
|
|
4581
|
+
})))))), globalSearch && /*#__PURE__*/React.createElement("div", {
|
|
4582
|
+
className: "p-4 border-b"
|
|
4583
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4584
|
+
className: "flex flex-col sm:flex-row items-start sm:items-center gap-2"
|
|
4313
4585
|
}, /*#__PURE__*/React.createElement("div", {
|
|
4314
4586
|
className: "relative w-full"
|
|
4315
4587
|
}, /*#__PURE__*/React.createElement("input", {
|
|
4316
4588
|
type: "text",
|
|
4317
|
-
placeholder: "
|
|
4318
|
-
className: "rounded-md border border-gray-300 px-4 py-3
|
|
4589
|
+
placeholder: "Search...",
|
|
4590
|
+
className: "w-full rounded-lg md:rounded-md border border-gray-300 px-4 py-3 md:py-2 text-sm flex-1 outline-none pr-12",
|
|
4319
4591
|
value: searchInput,
|
|
4320
4592
|
onChange: function onChange(e) {
|
|
4321
4593
|
return setSearchInput(e.target.value);
|
|
4322
|
-
}
|
|
4323
|
-
|
|
4324
|
-
onKeyDown: onGlobalKeyDown // apply on Enter
|
|
4594
|
+
},
|
|
4595
|
+
onKeyDown: onGlobalKeyDown
|
|
4325
4596
|
}), /*#__PURE__*/React.createElement("button", {
|
|
4326
|
-
onClick: applyGlobalSearch
|
|
4327
|
-
,
|
|
4328
|
-
className: "rounded-md border bg-secondary-100 border-gray-300 px-4 py-2 text-sm hover:bg-gray-100 absolute right-0 left-0 w-fit ml-auto h-full",
|
|
4597
|
+
onClick: applyGlobalSearch,
|
|
4598
|
+
className: "absolute right-2 top-1/2 transform -translate-y-1/2 p-2 rounded-lg hover:bg-gray-100",
|
|
4329
4599
|
title: "Search"
|
|
4330
4600
|
}, /*#__PURE__*/React.createElement(Search, {
|
|
4331
|
-
className: "text-gray-400"
|
|
4601
|
+
className: "h-4 w-4 text-gray-400"
|
|
4332
4602
|
}))), /*#__PURE__*/React.createElement("button", {
|
|
4333
4603
|
onClick: function onClick() {
|
|
4334
4604
|
setSearchInput("");
|
|
4335
4605
|
handleFilter("global", "");
|
|
4336
4606
|
},
|
|
4337
|
-
className: "rounded-md border border-gray-300
|
|
4338
|
-
|
|
4339
|
-
|
|
4607
|
+
className: "whitespace-nowrap rounded-lg md:rounded-md border border-gray-300 px-4 py-3 md:py-2 text-sm hover:bg-gray-100 w-full sm:w-auto"
|
|
4608
|
+
}, "Clear"))), filterable && isMobileView && renderMobileFilters(), showColumnMenu && /*#__PURE__*/React.createElement("div", {
|
|
4609
|
+
ref: columnMenuRef,
|
|
4610
|
+
className: "absolute right-4 mt-2 w-56 z-50 bg-white rounded-lg shadow-lg ring-1 ring-black ring-opacity-5 p-3 lg:block sm:block hidden",
|
|
4611
|
+
onClick: function onClick(e) {
|
|
4612
|
+
return e.stopPropagation();
|
|
4613
|
+
}
|
|
4614
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
4615
|
+
className: "text-sm font-medium text-center mb-2"
|
|
4616
|
+
}, "Show / hide columns"), /*#__PURE__*/React.createElement("div", {
|
|
4617
|
+
className: "max-h-56 overflow-auto"
|
|
4618
|
+
}, columnsState.map(function (col) {
|
|
4619
|
+
return /*#__PURE__*/React.createElement("label", {
|
|
4620
|
+
key: col.key,
|
|
4621
|
+
className: "flex cursor-pointer items-center gap-2 px-2 py-1.5 hover:bg-gray-50 rounded"
|
|
4622
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
4623
|
+
type: "checkbox",
|
|
4624
|
+
checked: col.isVisible !== false,
|
|
4625
|
+
onChange: function onChange() {
|
|
4626
|
+
return toggleColumnVisibility(col.key);
|
|
4627
|
+
},
|
|
4628
|
+
className: "rounded"
|
|
4629
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
4630
|
+
className: "text-sm font-normal"
|
|
4631
|
+
}, col.label));
|
|
4632
|
+
}))), !isMobileView && /*#__PURE__*/React.createElement("div", {
|
|
4340
4633
|
className: "overflow-x-auto"
|
|
4341
4634
|
}, /*#__PURE__*/React.createElement("table", _extends({
|
|
4342
4635
|
className: cn$1("min-w-full divide-y divide-gray-200", className)
|
|
@@ -4372,7 +4665,7 @@ var Table = function Table(_ref) {
|
|
|
4372
4665
|
className: cn$1("h-3 w-3", {
|
|
4373
4666
|
"text-primary-600": sortConfig.key === column.key && sortConfig.direction === "asc"
|
|
4374
4667
|
})
|
|
4375
|
-
}), /*#__PURE__*/React.createElement(ChevronDown, {
|
|
4668
|
+
}), /*#__PURE__*/React.createElement(ChevronDown$1, {
|
|
4376
4669
|
className: cn$1("h-3 w-3 -mt-1", {
|
|
4377
4670
|
"text-primary-600": sortConfig.key === column.key && sortConfig.direction === "desc"
|
|
4378
4671
|
})
|
|
@@ -4393,53 +4686,54 @@ var Table = function Table(_ref) {
|
|
|
4393
4686
|
className: "p-1 rounded hover:bg-gray-100"
|
|
4394
4687
|
}, /*#__PURE__*/React.createElement(MoreVertical, {
|
|
4395
4688
|
className: "h-4 w-4"
|
|
4396
|
-
})),
|
|
4397
|
-
ref: columnMenuRef,
|
|
4398
|
-
className: "absolute right-0 mt-2 w-56 z-50 bg-white rounded-md shadow-lg ring-1 ring-black ring-opacity-5 p-2",
|
|
4399
|
-
onClick: function onClick(e) {
|
|
4400
|
-
return e.stopPropagation();
|
|
4401
|
-
}
|
|
4402
|
-
}, /*#__PURE__*/React.createElement("p", {
|
|
4403
|
-
className: "text-sm font-normal text-center"
|
|
4404
|
-
}, "Show / hide columns"), /*#__PURE__*/React.createElement("div", {
|
|
4405
|
-
className: "max-h-56 overflow-auto"
|
|
4406
|
-
}, columnsState.map(function (col) {
|
|
4407
|
-
return /*#__PURE__*/React.createElement("label", {
|
|
4408
|
-
key: col.key,
|
|
4409
|
-
className: "flex cursor-pointer items-center gap-2 px-2 py-1 hover:bg-gray-50 rounded"
|
|
4410
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
4411
|
-
type: "checkbox",
|
|
4412
|
-
checked: col.isVisible !== false,
|
|
4413
|
-
onChange: function onChange() {
|
|
4414
|
-
return toggleColumnVisibility(col.key);
|
|
4415
|
-
}
|
|
4416
|
-
}), /*#__PURE__*/React.createElement("span", {
|
|
4417
|
-
className: "text-sm font-normal"
|
|
4418
|
-
}, col.label));
|
|
4419
|
-
}))))), withAction && /*#__PURE__*/React.createElement("th", {
|
|
4689
|
+
})))), withAction && /*#__PURE__*/React.createElement("th", {
|
|
4420
4690
|
className: "w-12 px-4 py-3"
|
|
4421
|
-
})), /*#__PURE__*/React.createElement("tr", null,
|
|
4691
|
+
})), filterable && /*#__PURE__*/React.createElement("tr", null, hasDetails && /*#__PURE__*/React.createElement("th", {
|
|
4692
|
+
className: "pb-4"
|
|
4693
|
+
}), showSerial && /*#__PURE__*/React.createElement("th", {
|
|
4694
|
+
className: "pb-4"
|
|
4695
|
+
}), selectable && /*#__PURE__*/React.createElement("th", {
|
|
4696
|
+
className: "pb-4"
|
|
4697
|
+
}), visibleColumns.map(function (column) {
|
|
4422
4698
|
return /*#__PURE__*/React.createElement("th", {
|
|
4423
|
-
className: "text-left pl-6 pb-4"
|
|
4424
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
4425
4699
|
key: column.key,
|
|
4700
|
+
className: "px-6 pb-4"
|
|
4701
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
4426
4702
|
type: "text",
|
|
4427
|
-
placeholder: "Filter ".concat(column.label
|
|
4428
|
-
className: "rounded-md border border-gray-300 px-3 py-1 text-sm
|
|
4703
|
+
placeholder: "Filter ".concat(column.label),
|
|
4704
|
+
className: "w-full rounded-md border border-gray-300 px-3 py-1.5 text-sm",
|
|
4429
4705
|
value: filters[column.key] || "",
|
|
4430
4706
|
onChange: function onChange(e) {
|
|
4431
4707
|
return handleFilter(column.key, e.target.value);
|
|
4432
4708
|
}
|
|
4433
4709
|
}));
|
|
4434
|
-
})
|
|
4710
|
+
}), /*#__PURE__*/React.createElement("th", {
|
|
4711
|
+
className: "pb-4"
|
|
4712
|
+
}), withAction && /*#__PURE__*/React.createElement("th", {
|
|
4713
|
+
className: "pb-4"
|
|
4714
|
+
}))), /*#__PURE__*/React.createElement("tbody", {
|
|
4435
4715
|
className: "divide-y divide-gray-200 bg-white"
|
|
4436
4716
|
}, loading ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
4437
4717
|
colSpan: visibleCount,
|
|
4438
|
-
className: "px-6 py-
|
|
4439
|
-
},
|
|
4718
|
+
className: "px-6 py-8 text-center"
|
|
4719
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4720
|
+
className: "flex flex-col items-center gap-2"
|
|
4721
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4722
|
+
className: "h-6 w-6 animate-spin rounded-full border-2 border-primary-600 border-t-transparent"
|
|
4723
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
4724
|
+
className: "text-sm text-gray-500"
|
|
4725
|
+
}, "Loading...")))) : paginatedData.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
4440
4726
|
colSpan: visibleCount,
|
|
4441
|
-
className: "px-6 py-
|
|
4442
|
-
},
|
|
4727
|
+
className: "px-6 py-8 text-center"
|
|
4728
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4729
|
+
className: "flex flex-col items-center gap-2"
|
|
4730
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4731
|
+
className: "text-gray-400"
|
|
4732
|
+
}, /*#__PURE__*/React.createElement(List, {
|
|
4733
|
+
className: "h-8 w-8"
|
|
4734
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
4735
|
+
className: "text-sm text-gray-500"
|
|
4736
|
+
}, "No results found.")))) : paginatedData.map(function (row, rowIndexInPage) {
|
|
4443
4737
|
var globalIndex = startIndex + rowIndexInPage;
|
|
4444
4738
|
var key = getRowKey(row, globalIndex);
|
|
4445
4739
|
var actionCellKey = "actions-".concat(key);
|
|
@@ -4448,9 +4742,13 @@ var Table = function Table(_ref) {
|
|
|
4448
4742
|
rowIndex: globalIndex
|
|
4449
4743
|
}) : "";
|
|
4450
4744
|
var safeExtraRowClass = typeof extraRowClass === "string" ? extraRowClass.trim() : "";
|
|
4745
|
+
var stripeBg = stripedRows && !selectedRows.has(key) ? stripedColors[globalIndex % stripedColors.length] : undefined;
|
|
4451
4746
|
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
4452
4747
|
key: key
|
|
4453
4748
|
}, /*#__PURE__*/React.createElement("tr", {
|
|
4749
|
+
style: stripeBg ? {
|
|
4750
|
+
backgroundColor: stripeBg
|
|
4751
|
+
} : undefined,
|
|
4454
4752
|
className: cn$1("hover:bg-gray-50", {
|
|
4455
4753
|
"cursor-pointer": !!onRowClick,
|
|
4456
4754
|
"bg-primary-50": selectedRows.has(key)
|
|
@@ -4491,9 +4789,7 @@ var Table = function Table(_ref) {
|
|
|
4491
4789
|
var safeExtraCellClass = typeof extraCellClass === "string" ? extraCellClass.trim() : "";
|
|
4492
4790
|
return /*#__PURE__*/React.createElement("td", {
|
|
4493
4791
|
key: column.key,
|
|
4494
|
-
className: cn$1("px-6 py-4 whitespace-nowrap text-sm text-gray-900",
|
|
4495
|
-
// append the cellClass string only if it's a string
|
|
4496
|
-
safeExtraCellClass)
|
|
4792
|
+
className: cn$1("px-6 py-4 whitespace-nowrap text-sm text-gray-900", safeExtraCellClass)
|
|
4497
4793
|
}, renderCell(column, row, globalIndex));
|
|
4498
4794
|
}), withAction && /*#__PURE__*/React.createElement("td", {
|
|
4499
4795
|
className: "px-4 py-4 text-sm text-right",
|
|
@@ -4513,6 +4809,7 @@ var Table = function Table(_ref) {
|
|
|
4513
4809
|
className: "h-4 w-4"
|
|
4514
4810
|
}))), actionAnchor && actionAnchor.key === actionCellKey && /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/React.createElement(ActionMenuPortal, {
|
|
4515
4811
|
anchorElem: actionAnchor.elem,
|
|
4812
|
+
anchorRow: actionAnchor.row,
|
|
4516
4813
|
actions: actionsToUse,
|
|
4517
4814
|
onClose: function onClose() {
|
|
4518
4815
|
setOpenActionKey(null);
|
|
@@ -4531,62 +4828,71 @@ var Table = function Table(_ref) {
|
|
|
4531
4828
|
row: row,
|
|
4532
4829
|
index: globalIndex
|
|
4533
4830
|
})))));
|
|
4534
|
-
})))),
|
|
4535
|
-
className: "
|
|
4831
|
+
})))), isMobileView && /*#__PURE__*/React.createElement("div", {
|
|
4832
|
+
className: "p-4"
|
|
4833
|
+
}, loading ? /*#__PURE__*/React.createElement("div", {
|
|
4834
|
+
className: "py-8 text-center"
|
|
4835
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4836
|
+
className: "flex flex-col items-center gap-2"
|
|
4837
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4838
|
+
className: "h-6 w-6 animate-spin rounded-full border-2 border-primary-600 border-t-transparent"
|
|
4839
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
4840
|
+
className: "text-sm text-gray-500"
|
|
4841
|
+
}, "Loading..."))) : paginatedData.length === 0 ? /*#__PURE__*/React.createElement("div", {
|
|
4842
|
+
className: "py-8 text-center"
|
|
4843
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4844
|
+
className: "flex flex-col items-center gap-2"
|
|
4845
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4846
|
+
className: "text-gray-400"
|
|
4847
|
+
}, /*#__PURE__*/React.createElement(List, {
|
|
4848
|
+
className: "h-8 w-8"
|
|
4849
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
4850
|
+
className: "text-sm text-gray-500"
|
|
4851
|
+
}, "No results found."))) : paginatedData.map(function (row, rowIndexInPage) {
|
|
4852
|
+
return renderMobileCard(row, rowIndexInPage);
|
|
4853
|
+
})), pagination && /*#__PURE__*/React.createElement("div", {
|
|
4854
|
+
className: "p-4 border-t"
|
|
4855
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4856
|
+
className: "flex flex-col sm:flex-row items-center justify-between gap-3"
|
|
4536
4857
|
}, /*#__PURE__*/React.createElement("div", {
|
|
4537
|
-
className: "text-sm text-gray-700"
|
|
4538
|
-
}, "Showing ", filteredData.length === 0 ? 0 : startIndex + 1, " to", " ", Math.min(endIndex, filteredData.length), " of ", filteredData.length, " ", "results"), /*#__PURE__*/React.createElement("div", {
|
|
4539
|
-
className: "flex items-center gap-1"
|
|
4540
|
-
}, showLimitSelector && /*#__PURE__*/React.createElement("div", {
|
|
4541
|
-
className: "flex items-center space-x-2"
|
|
4542
|
-
}, /*#__PURE__*/React.createElement("label", {
|
|
4543
|
-
htmlFor: "pagination-limit",
|
|
4544
4858
|
className: "text-sm text-gray-600"
|
|
4545
|
-
}, "
|
|
4546
|
-
|
|
4547
|
-
return {
|
|
4548
|
-
label: String(opt),
|
|
4549
|
-
value: opt
|
|
4550
|
-
};
|
|
4551
|
-
}) : [25, 50, 100].map(function (opt) {
|
|
4552
|
-
return {
|
|
4553
|
-
label: String(opt),
|
|
4554
|
-
value: opt
|
|
4555
|
-
};
|
|
4556
|
-
}),
|
|
4557
|
-
value: limit,
|
|
4558
|
-
allowClear: false,
|
|
4559
|
-
onChange: function onChange(e) {
|
|
4560
|
-
return handleLimitChange(e);
|
|
4561
|
-
},
|
|
4562
|
-
className: "w-20"
|
|
4563
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
4564
|
-
className: "flex gap-1"
|
|
4859
|
+
}, "Page ", currentPage, " of ", totalPages), /*#__PURE__*/React.createElement("div", {
|
|
4860
|
+
className: "flex items-center gap-2"
|
|
4565
4861
|
}, /*#__PURE__*/React.createElement("button", {
|
|
4566
|
-
className: "rounded-md border border-gray-300 px-
|
|
4862
|
+
className: "rounded-lg md:rounded-md border border-gray-300 px-4 py-2 text-sm disabled:opacity-50 hover:bg-gray-50",
|
|
4567
4863
|
disabled: currentPage === 1,
|
|
4568
4864
|
onClick: function onClick() {
|
|
4569
4865
|
return setCurrentPage(function (p) {
|
|
4570
4866
|
return Math.max(1, p - 1);
|
|
4571
4867
|
});
|
|
4572
4868
|
}
|
|
4573
|
-
}, "Previous"),
|
|
4574
|
-
|
|
4869
|
+
}, "Previous"), /*#__PURE__*/React.createElement("div", {
|
|
4870
|
+
className: "flex items-center gap-1"
|
|
4871
|
+
}, Array.from({
|
|
4872
|
+
length: Math.min(5, totalPages)
|
|
4575
4873
|
}, function (_, i) {
|
|
4576
|
-
|
|
4577
|
-
|
|
4874
|
+
var pageNum;
|
|
4875
|
+
if (totalPages <= 5) {
|
|
4876
|
+
pageNum = i + 1;
|
|
4877
|
+
} else if (currentPage <= 3) {
|
|
4878
|
+
pageNum = i + 1;
|
|
4879
|
+
} else if (currentPage >= totalPages - 2) {
|
|
4880
|
+
pageNum = totalPages - 4 + i;
|
|
4881
|
+
} else {
|
|
4882
|
+
pageNum = currentPage - 2 + i;
|
|
4883
|
+
}
|
|
4578
4884
|
return /*#__PURE__*/React.createElement("button", {
|
|
4579
|
-
key:
|
|
4580
|
-
className: cn$1("
|
|
4581
|
-
"bg-primary-600 text-white":
|
|
4582
|
-
"border border-gray-300":
|
|
4885
|
+
key: pageNum,
|
|
4886
|
+
className: cn$1("h-8 w-8 rounded-lg md:rounded-md text-sm", {
|
|
4887
|
+
"bg-primary-600 text-white": pageNum === currentPage,
|
|
4888
|
+
"border border-gray-300 hover:bg-gray-50": pageNum !== currentPage
|
|
4583
4889
|
}),
|
|
4584
4890
|
onClick: function onClick() {
|
|
4585
|
-
return setCurrentPage(
|
|
4891
|
+
return setCurrentPage(pageNum);
|
|
4586
4892
|
}
|
|
4587
|
-
},
|
|
4588
|
-
}), /*#__PURE__*/React.createElement("button", {
|
|
4589
|
-
className: "rounded-md border border-gray-300 px-
|
|
4893
|
+
}, pageNum);
|
|
4894
|
+
})), /*#__PURE__*/React.createElement("button", {
|
|
4895
|
+
className: "rounded-lg md:rounded-md border border-gray-300 px-4 py-2 text-sm disabled:opacity-50 hover:bg-gray-50",
|
|
4590
4896
|
disabled: currentPage === totalPages,
|
|
4591
4897
|
onClick: function onClick() {
|
|
4592
4898
|
return setCurrentPage(function (p) {
|
|
@@ -4596,7 +4902,7 @@ var Table = function Table(_ref) {
|
|
|
4596
4902
|
}, "Next")))));
|
|
4597
4903
|
};
|
|
4598
4904
|
|
|
4599
|
-
/* ---------------- ActionMenuPortal (
|
|
4905
|
+
/* ---------------- ActionMenuPortal (updated for mobile) ---------------- */
|
|
4600
4906
|
function ActionMenuPortal(_ref4) {
|
|
4601
4907
|
var anchorElem = _ref4.anchorElem,
|
|
4602
4908
|
anchorRow = _ref4.anchorRow,
|
|
@@ -4605,10 +4911,10 @@ function ActionMenuPortal(_ref4) {
|
|
|
4605
4911
|
_ref4.onClose;
|
|
4606
4912
|
var onAction = _ref4.onAction,
|
|
4607
4913
|
menuRef = _ref4.menuRef;
|
|
4608
|
-
var
|
|
4609
|
-
|
|
4610
|
-
setTick =
|
|
4611
|
-
var
|
|
4914
|
+
var _useState29 = React.useState(0),
|
|
4915
|
+
_useState30 = _slicedToArray(_useState29, 2),
|
|
4916
|
+
setTick = _useState30[1];
|
|
4917
|
+
var _useState31 = React.useState({
|
|
4612
4918
|
left: 0,
|
|
4613
4919
|
top: 0,
|
|
4614
4920
|
transformOrigin: "top right",
|
|
@@ -4616,9 +4922,9 @@ function ActionMenuPortal(_ref4) {
|
|
|
4616
4922
|
width: 180,
|
|
4617
4923
|
opacity: 0
|
|
4618
4924
|
}),
|
|
4619
|
-
|
|
4620
|
-
style =
|
|
4621
|
-
setStyle =
|
|
4925
|
+
_useState32 = _slicedToArray(_useState31, 2),
|
|
4926
|
+
style = _useState32[0],
|
|
4927
|
+
setStyle = _useState32[1];
|
|
4622
4928
|
var menuWidth = 180;
|
|
4623
4929
|
var maxMenuHeight = 320;
|
|
4624
4930
|
var computePosition = function computePosition() {
|
|
@@ -4665,7 +4971,6 @@ function ActionMenuPortal(_ref4) {
|
|
|
4665
4971
|
window.removeEventListener("resize", onScrollOrResize);
|
|
4666
4972
|
window.removeEventListener("scroll", onScrollOrResize, true);
|
|
4667
4973
|
};
|
|
4668
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4669
4974
|
}, [anchorElem]);
|
|
4670
4975
|
return /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/React.createElement("div", {
|
|
4671
4976
|
ref: menuRef,
|
|
@@ -4676,7 +4981,7 @@ function ActionMenuPortal(_ref4) {
|
|
|
4676
4981
|
maxHeight: style.maxHeight,
|
|
4677
4982
|
transformOrigin: style.transformOrigin
|
|
4678
4983
|
},
|
|
4679
|
-
className: "absolute z-50 bg-white rounded-
|
|
4984
|
+
className: "absolute z-50 bg-white rounded-lg shadow-lg ring-1 ring-black ring-opacity-5 overflow-y-auto transition-opacity duration-150 ease-out",
|
|
4680
4985
|
onClick: function onClick(e) {
|
|
4681
4986
|
return e.stopPropagation();
|
|
4682
4987
|
}
|
|
@@ -15261,7 +15566,7 @@ var Sidebar = function Sidebar(_ref2) {
|
|
|
15261
15566
|
className: "flex-1 truncate"
|
|
15262
15567
|
}, item.label), hasChildren && /*#__PURE__*/React.createElement("span", {
|
|
15263
15568
|
className: "ml-2 flex-shrink-0"
|
|
15264
|
-
}, isExpanded ? /*#__PURE__*/React.createElement(
|
|
15569
|
+
}, isExpanded ? /*#__PURE__*/React.createElement(ChevronDown, {
|
|
15265
15570
|
className: "h-4 w-4"
|
|
15266
15571
|
}) : /*#__PURE__*/React.createElement(ChevronRight, {
|
|
15267
15572
|
className: "h-4 w-4"
|