@dreamtree-org/twreact-ui 1.0.80 → 1.0.82
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 +84 -141
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +84 -141
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3365,7 +3365,7 @@ function _defineProperty$4(e, r, t) {
|
|
|
3365
3365
|
}) : e[r] = t, e;
|
|
3366
3366
|
}
|
|
3367
3367
|
|
|
3368
|
-
var _excluded$l = ["options", "value", "onChange", "placeholder", "label", "error", "disabled", "required", "multiSelect", "searchable", "grouped", "onMenuItemRender", "className", "allowClear", "creatable", "onCreateOption", "onSearch", "loading", "selectAllOption", "closeOnSelect", "maxTagCount", "renderGroupLabel"];
|
|
3368
|
+
var _excluded$l = ["options", "value", "onChange", "placeholder", "label", "error", "disabled", "required", "multiSelect", "searchable", "grouped", "onMenuItemRender", "className", "allowClear", "creatable", "onCreateOption", "onSearch", "loading", "selectAllOption", "closeOnSelect", "maxTagCount", "renderGroupLabel", "name"];
|
|
3369
3369
|
function ownKeys$a(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; }
|
|
3370
3370
|
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), true).forEach(function (r) { _defineProperty$4(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3371
3371
|
|
|
@@ -3441,6 +3441,7 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
3441
3441
|
_ref$maxTagCount = _ref.maxTagCount,
|
|
3442
3442
|
maxTagCount = _ref$maxTagCount === void 0 ? 3 : _ref$maxTagCount,
|
|
3443
3443
|
renderGroupLabel = _ref.renderGroupLabel,
|
|
3444
|
+
name = _ref.name,
|
|
3444
3445
|
props = _objectWithoutProperties$1(_ref, _excluded$l);
|
|
3445
3446
|
var _useState = React.useState(false),
|
|
3446
3447
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -3849,7 +3850,24 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
3849
3850
|
className: cn$1("h-4 w-4 text-gray-400 transition-transform", {
|
|
3850
3851
|
"rotate-180": isOpen
|
|
3851
3852
|
})
|
|
3852
|
-
}))),
|
|
3853
|
+
}))), name && (multiSelect ?
|
|
3854
|
+
// For multi-select, create a hidden input for each selected value
|
|
3855
|
+
selectedValues.length > 0 ? selectedValues.map(function (val, idx) {
|
|
3856
|
+
return /*#__PURE__*/React.createElement("input", {
|
|
3857
|
+
key: "".concat(name, "-").concat(idx),
|
|
3858
|
+
type: "hidden",
|
|
3859
|
+
name: name,
|
|
3860
|
+
value: val !== null && val !== void 0 ? val : ""
|
|
3861
|
+
});
|
|
3862
|
+
}) : /*#__PURE__*/React.createElement("input", {
|
|
3863
|
+
type: "hidden",
|
|
3864
|
+
name: name,
|
|
3865
|
+
value: ""
|
|
3866
|
+
}) : /*#__PURE__*/React.createElement("input", {
|
|
3867
|
+
type: "hidden",
|
|
3868
|
+
name: name,
|
|
3869
|
+
value: selectedValues !== null && selectedValues !== void 0 ? selectedValues : ""
|
|
3870
|
+
})), isOpen && /*#__PURE__*/React.createElement("div", {
|
|
3853
3871
|
ref: menuRef,
|
|
3854
3872
|
className: cn$1("absolute z-50 w-full rounded-md border border-gray-300 bg-white shadow-lg", {
|
|
3855
3873
|
// if placement is bottom, place it below with margin-top; if top, place it above with bottom full and margin-bottom
|
|
@@ -3937,89 +3955,16 @@ var DEFAULT_ACTIONS = [{
|
|
|
3937
3955
|
})
|
|
3938
3956
|
}];
|
|
3939
3957
|
|
|
3940
|
-
//
|
|
3941
|
-
var
|
|
3942
|
-
var
|
|
3943
|
-
_ref$actions = _ref.actions,
|
|
3958
|
+
// Simple inline action menu component (no portal)
|
|
3959
|
+
var ActionMenu = /*#__PURE__*/React.memo(function ActionMenu(_ref) {
|
|
3960
|
+
var _ref$actions = _ref.actions,
|
|
3944
3961
|
actions = _ref$actions === void 0 ? [] : _ref$actions,
|
|
3945
|
-
|
|
3962
|
+
row = _ref.row,
|
|
3946
3963
|
onAction = _ref.onAction,
|
|
3947
3964
|
menuRef = _ref.menuRef;
|
|
3948
|
-
var _useState = React.useState({
|
|
3949
|
-
left: 0,
|
|
3950
|
-
top: 0,
|
|
3951
|
-
transformOrigin: "top right",
|
|
3952
|
-
maxHeight: 300,
|
|
3953
|
-
width: 180,
|
|
3954
|
-
opacity: 0
|
|
3955
|
-
}),
|
|
3956
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
3957
|
-
style = _useState2[0],
|
|
3958
|
-
setStyle = _useState2[1];
|
|
3959
|
-
var menuWidth = 180;
|
|
3960
|
-
var maxMenuHeight = 320;
|
|
3961
|
-
var margin = 8;
|
|
3962
|
-
var minMenuHeight = 80;
|
|
3963
|
-
React.useLayoutEffect(function () {
|
|
3964
|
-
if (!anchorElem) return;
|
|
3965
|
-
var computePosition = function computePosition() {
|
|
3966
|
-
var rect = anchorElem.getBoundingClientRect();
|
|
3967
|
-
var scrollY = window.scrollY || window.pageYOffset;
|
|
3968
|
-
var scrollX = window.scrollX || window.pageXOffset;
|
|
3969
|
-
var spaceBelow = window.innerHeight - rect.bottom;
|
|
3970
|
-
var spaceAbove = rect.top;
|
|
3971
|
-
var placement = "bottom";
|
|
3972
|
-
var allowedMaxHeight;
|
|
3973
|
-
if (spaceBelow < 160 && spaceAbove > spaceBelow) {
|
|
3974
|
-
placement = "top";
|
|
3975
|
-
allowedMaxHeight = Math.min(maxMenuHeight, Math.max(minMenuHeight, spaceAbove - margin));
|
|
3976
|
-
} else {
|
|
3977
|
-
allowedMaxHeight = Math.min(maxMenuHeight, Math.max(minMenuHeight, spaceBelow - margin));
|
|
3978
|
-
}
|
|
3979
|
-
var measuredMenuHeight = allowedMaxHeight;
|
|
3980
|
-
var menuEl = menuRef === null || menuRef === void 0 ? void 0 : menuRef.current;
|
|
3981
|
-
if (menuEl) {
|
|
3982
|
-
var contentHeight = menuEl.scrollHeight || menuEl.offsetHeight || allowedMaxHeight;
|
|
3983
|
-
measuredMenuHeight = Math.min(contentHeight, allowedMaxHeight);
|
|
3984
|
-
}
|
|
3985
|
-
var top = placement === "top" ? rect.top + scrollY - measuredMenuHeight - margin : rect.bottom + scrollY + margin;
|
|
3986
|
-
var minTop = margin + scrollY;
|
|
3987
|
-
var maxTop = window.innerHeight + scrollY - measuredMenuHeight - margin;
|
|
3988
|
-
top = Math.max(minTop, Math.min(top, maxTop));
|
|
3989
|
-
var left = rect.right + scrollX - menuWidth;
|
|
3990
|
-
left = Math.max(margin, Math.min(left, window.innerWidth - menuWidth - margin));
|
|
3991
|
-
setStyle({
|
|
3992
|
-
left: left,
|
|
3993
|
-
top: top,
|
|
3994
|
-
transformOrigin: placement === "bottom" ? "top right" : "bottom right",
|
|
3995
|
-
maxHeight: allowedMaxHeight,
|
|
3996
|
-
width: menuWidth,
|
|
3997
|
-
opacity: 1
|
|
3998
|
-
});
|
|
3999
|
-
};
|
|
4000
|
-
computePosition();
|
|
4001
|
-
var onScrollOrResize = function onScrollOrResize() {
|
|
4002
|
-
window.requestAnimationFrame(computePosition);
|
|
4003
|
-
};
|
|
4004
|
-
window.addEventListener("resize", onScrollOrResize);
|
|
4005
|
-
window.addEventListener("scroll", onScrollOrResize, true);
|
|
4006
|
-
return function () {
|
|
4007
|
-
window.removeEventListener("resize", onScrollOrResize);
|
|
4008
|
-
window.removeEventListener("scroll", onScrollOrResize, true);
|
|
4009
|
-
};
|
|
4010
|
-
}, [anchorElem, menuRef]);
|
|
4011
3965
|
return /*#__PURE__*/React.createElement("div", {
|
|
4012
3966
|
ref: menuRef,
|
|
4013
|
-
|
|
4014
|
-
position: "absolute",
|
|
4015
|
-
top: style.top,
|
|
4016
|
-
left: style.left,
|
|
4017
|
-
width: style.width,
|
|
4018
|
-
maxHeight: style.maxHeight,
|
|
4019
|
-
transformOrigin: style.transformOrigin,
|
|
4020
|
-
opacity: style.opacity
|
|
4021
|
-
},
|
|
4022
|
-
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",
|
|
3967
|
+
className: "absolute right-0 top-full mt-1 z-50 w-44 bg-white rounded-lg shadow-lg ring-1 ring-black ring-opacity-5 overflow-y-auto max-h-64",
|
|
4023
3968
|
onClick: function onClick(e) {
|
|
4024
3969
|
return e.stopPropagation();
|
|
4025
3970
|
}
|
|
@@ -4035,9 +3980,9 @@ var ActionMenuPortal = /*#__PURE__*/React.memo(function ActionMenuPortal(_ref) {
|
|
|
4035
3980
|
className: "w-full text-left px-3 py-2 text-sm hover:bg-gray-100 flex items-center gap-2 rounded-md",
|
|
4036
3981
|
onClick: function onClick(e) {
|
|
4037
3982
|
e.stopPropagation();
|
|
4038
|
-
onAction === null || onAction === void 0 || onAction(action,
|
|
3983
|
+
onAction === null || onAction === void 0 || onAction(action, row);
|
|
4039
3984
|
}
|
|
4040
|
-
}, action.render ? action.render(
|
|
3985
|
+
}, action.render ? action.render(row) : /*#__PURE__*/React.createElement(React.Fragment, null, action.icon && /*#__PURE__*/React.createElement("span", {
|
|
4041
3986
|
className: "inline-flex"
|
|
4042
3987
|
}, action.icon), /*#__PURE__*/React.createElement("span", null, action.label))));
|
|
4043
3988
|
})));
|
|
@@ -4125,85 +4070,85 @@ var Table = function Table(_ref2) {
|
|
|
4125
4070
|
pageNumber = _ref2.pageNumber,
|
|
4126
4071
|
props = _objectWithoutProperties$1(_ref2, _excluded$k);
|
|
4127
4072
|
// Core state
|
|
4128
|
-
var
|
|
4129
|
-
|
|
4130
|
-
isMobileView =
|
|
4131
|
-
setIsMobileView =
|
|
4132
|
-
var
|
|
4073
|
+
var _useState = React.useState(false),
|
|
4074
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
4075
|
+
isMobileView = _useState2[0],
|
|
4076
|
+
setIsMobileView = _useState2[1];
|
|
4077
|
+
var _useState3 = React.useState(function () {
|
|
4133
4078
|
return Array.isArray(data) ? data : [];
|
|
4134
4079
|
}),
|
|
4080
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
4081
|
+
tableData = _useState4[0],
|
|
4082
|
+
setTableData = _useState4[1];
|
|
4083
|
+
var _useState5 = React.useState(false),
|
|
4135
4084
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
var _useState7 = React.useState(
|
|
4085
|
+
loading = _useState6[0],
|
|
4086
|
+
setLoading = _useState6[1];
|
|
4087
|
+
var _useState7 = React.useState(pageSize),
|
|
4139
4088
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
var _useState9 = React.useState(
|
|
4143
|
-
_useState0 = _slicedToArray(_useState9, 2),
|
|
4144
|
-
limit = _useState0[0],
|
|
4145
|
-
setLimit = _useState0[1];
|
|
4146
|
-
var _useState1 = React.useState(function () {
|
|
4089
|
+
limit = _useState8[0],
|
|
4090
|
+
setLimit = _useState8[1];
|
|
4091
|
+
var _useState9 = React.useState(function () {
|
|
4147
4092
|
return typeof pageNumber === "number" ? pageNumber : 1;
|
|
4148
4093
|
}),
|
|
4149
|
-
|
|
4150
|
-
currentPage =
|
|
4151
|
-
setCurrentPage =
|
|
4094
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
4095
|
+
currentPage = _useState0[0],
|
|
4096
|
+
setCurrentPage = _useState0[1];
|
|
4152
4097
|
|
|
4153
4098
|
// Column state
|
|
4154
|
-
var
|
|
4099
|
+
var _useState1 = React.useState(function () {
|
|
4155
4100
|
return Array.isArray(columns) ? columns.map(function (c) {
|
|
4156
4101
|
return _objectSpread$9({}, c);
|
|
4157
4102
|
}) : [];
|
|
4158
4103
|
}),
|
|
4104
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
4105
|
+
columnsState = _useState10[0],
|
|
4106
|
+
setColumnsState = _useState10[1];
|
|
4107
|
+
var _useState11 = React.useState(false),
|
|
4159
4108
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
var _useState13 = React.useState(false),
|
|
4163
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
4164
|
-
showColumnMenu = _useState14[0],
|
|
4165
|
-
setShowColumnMenu = _useState14[1];
|
|
4109
|
+
showColumnMenu = _useState12[0],
|
|
4110
|
+
setShowColumnMenu = _useState12[1];
|
|
4166
4111
|
|
|
4167
4112
|
// Sorting/filtering state
|
|
4168
|
-
var
|
|
4113
|
+
var _useState13 = React.useState({
|
|
4169
4114
|
key: null,
|
|
4170
4115
|
direction: "asc"
|
|
4171
4116
|
}),
|
|
4117
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
4118
|
+
sortConfig = _useState14[0],
|
|
4119
|
+
setSortConfig = _useState14[1];
|
|
4120
|
+
var _useState15 = React.useState({}),
|
|
4172
4121
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
var _useState17 = React.useState(
|
|
4122
|
+
filters = _useState16[0],
|
|
4123
|
+
setFilters = _useState16[1];
|
|
4124
|
+
var _useState17 = React.useState(""),
|
|
4176
4125
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
var _useState19 = React.useState(""),
|
|
4180
|
-
_useState20 = _slicedToArray(_useState19, 2),
|
|
4181
|
-
searchInput = _useState20[0],
|
|
4182
|
-
setSearchInput = _useState20[1];
|
|
4126
|
+
searchInput = _useState18[0],
|
|
4127
|
+
setSearchInput = _useState18[1];
|
|
4183
4128
|
|
|
4184
4129
|
// Selection/expansion state
|
|
4185
|
-
var
|
|
4130
|
+
var _useState19 = React.useState(function () {
|
|
4186
4131
|
return new Set();
|
|
4187
4132
|
}),
|
|
4188
|
-
|
|
4189
|
-
selectedRows =
|
|
4190
|
-
setSelectedRows =
|
|
4191
|
-
var
|
|
4133
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
4134
|
+
selectedRows = _useState20[0],
|
|
4135
|
+
setSelectedRows = _useState20[1];
|
|
4136
|
+
var _useState21 = React.useState(function () {
|
|
4192
4137
|
return new Set();
|
|
4193
4138
|
}),
|
|
4194
|
-
|
|
4195
|
-
expandedRows =
|
|
4196
|
-
setExpandedRows =
|
|
4139
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
4140
|
+
expandedRows = _useState22[0],
|
|
4141
|
+
setExpandedRows = _useState22[1];
|
|
4197
4142
|
|
|
4198
4143
|
// Action menu state
|
|
4199
|
-
var
|
|
4144
|
+
var _useState23 = React.useState(null),
|
|
4145
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
4146
|
+
actionAnchor = _useState24[0],
|
|
4147
|
+
setActionAnchor = _useState24[1];
|
|
4148
|
+
var _useState25 = React.useState(false),
|
|
4200
4149
|
_useState26 = _slicedToArray(_useState25, 2),
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
var _useState27 = React.useState(false),
|
|
4204
|
-
_useState28 = _slicedToArray(_useState27, 2),
|
|
4205
|
-
showMobileFilters = _useState28[0],
|
|
4206
|
-
setShowMobileFilters = _useState28[1];
|
|
4150
|
+
showMobileFilters = _useState26[0],
|
|
4151
|
+
setShowMobileFilters = _useState26[1];
|
|
4207
4152
|
|
|
4208
4153
|
// Refs
|
|
4209
4154
|
var columnMenuRef = React.useRef(null);
|
|
@@ -4544,15 +4489,14 @@ var Table = function Table(_ref2) {
|
|
|
4544
4489
|
title: "Actions"
|
|
4545
4490
|
}, /*#__PURE__*/React.createElement(MoreVertical, {
|
|
4546
4491
|
className: "h-4 w-4"
|
|
4547
|
-
})), (actionAnchor === null || actionAnchor === void 0 ? void 0 : actionAnchor.key) === actionCellKey && /*#__PURE__*/
|
|
4548
|
-
anchorElem: actionAnchor.elem,
|
|
4549
|
-
anchorRow: actionAnchor.row,
|
|
4492
|
+
})), (actionAnchor === null || actionAnchor === void 0 ? void 0 : actionAnchor.key) === actionCellKey && /*#__PURE__*/React.createElement(ActionMenu, {
|
|
4550
4493
|
actions: actionsToUse,
|
|
4494
|
+
row: row,
|
|
4551
4495
|
onAction: function onAction(action) {
|
|
4552
4496
|
return handleOnAction(action, row);
|
|
4553
4497
|
},
|
|
4554
4498
|
menuRef: actionMenuRef
|
|
4555
|
-
})
|
|
4499
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
4556
4500
|
className: "p-4"
|
|
4557
4501
|
}, visibleColumns.map(function (column, colIndex) {
|
|
4558
4502
|
var extraCellClass = typeof cellClass === "function" ? cellClass({
|
|
@@ -4934,7 +4878,7 @@ var Table = function Table(_ref2) {
|
|
|
4934
4878
|
return e.stopPropagation();
|
|
4935
4879
|
}
|
|
4936
4880
|
}, /*#__PURE__*/React.createElement("div", {
|
|
4937
|
-
className: "inline-block"
|
|
4881
|
+
className: "relative inline-block"
|
|
4938
4882
|
}, /*#__PURE__*/React.createElement("button", {
|
|
4939
4883
|
onClick: function onClick(e) {
|
|
4940
4884
|
return toggleActions(e, actionCellKey, row);
|
|
@@ -4944,15 +4888,14 @@ var Table = function Table(_ref2) {
|
|
|
4944
4888
|
title: "Actions"
|
|
4945
4889
|
}, /*#__PURE__*/React.createElement(MoreVertical, {
|
|
4946
4890
|
className: "h-4 w-4"
|
|
4947
|
-
}))
|
|
4948
|
-
anchorElem: actionAnchor.elem,
|
|
4949
|
-
anchorRow: actionAnchor.row,
|
|
4891
|
+
})), (actionAnchor === null || actionAnchor === void 0 ? void 0 : actionAnchor.key) === actionCellKey && /*#__PURE__*/React.createElement(ActionMenu, {
|
|
4950
4892
|
actions: actionsToUse,
|
|
4893
|
+
row: row,
|
|
4951
4894
|
onAction: function onAction(action) {
|
|
4952
4895
|
return handleOnAction(action, row);
|
|
4953
4896
|
},
|
|
4954
4897
|
menuRef: actionMenuRef
|
|
4955
|
-
})
|
|
4898
|
+
})))), hasDetails && isExpanded && DetailsComponent && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
4956
4899
|
colSpan: visibleCount,
|
|
4957
4900
|
className: "px-6 py-4 bg-gray-50"
|
|
4958
4901
|
}, /*#__PURE__*/React.createElement(DetailsComponent, {
|