@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.esm.js
CHANGED
|
@@ -3345,7 +3345,7 @@ function _defineProperty$4(e, r, t) {
|
|
|
3345
3345
|
}) : e[r] = t, e;
|
|
3346
3346
|
}
|
|
3347
3347
|
|
|
3348
|
-
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"];
|
|
3348
|
+
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"];
|
|
3349
3349
|
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; }
|
|
3350
3350
|
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; }
|
|
3351
3351
|
|
|
@@ -3421,6 +3421,7 @@ var Select = /*#__PURE__*/React__default.forwardRef(function (_ref, forwardedRef
|
|
|
3421
3421
|
_ref$maxTagCount = _ref.maxTagCount,
|
|
3422
3422
|
maxTagCount = _ref$maxTagCount === void 0 ? 3 : _ref$maxTagCount,
|
|
3423
3423
|
renderGroupLabel = _ref.renderGroupLabel,
|
|
3424
|
+
name = _ref.name,
|
|
3424
3425
|
props = _objectWithoutProperties$1(_ref, _excluded$l);
|
|
3425
3426
|
var _useState = useState(false),
|
|
3426
3427
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -3829,7 +3830,24 @@ var Select = /*#__PURE__*/React__default.forwardRef(function (_ref, forwardedRef
|
|
|
3829
3830
|
className: cn$1("h-4 w-4 text-gray-400 transition-transform", {
|
|
3830
3831
|
"rotate-180": isOpen
|
|
3831
3832
|
})
|
|
3832
|
-
}))),
|
|
3833
|
+
}))), name && (multiSelect ?
|
|
3834
|
+
// For multi-select, create a hidden input for each selected value
|
|
3835
|
+
selectedValues.length > 0 ? selectedValues.map(function (val, idx) {
|
|
3836
|
+
return /*#__PURE__*/React__default.createElement("input", {
|
|
3837
|
+
key: "".concat(name, "-").concat(idx),
|
|
3838
|
+
type: "hidden",
|
|
3839
|
+
name: name,
|
|
3840
|
+
value: val !== null && val !== void 0 ? val : ""
|
|
3841
|
+
});
|
|
3842
|
+
}) : /*#__PURE__*/React__default.createElement("input", {
|
|
3843
|
+
type: "hidden",
|
|
3844
|
+
name: name,
|
|
3845
|
+
value: ""
|
|
3846
|
+
}) : /*#__PURE__*/React__default.createElement("input", {
|
|
3847
|
+
type: "hidden",
|
|
3848
|
+
name: name,
|
|
3849
|
+
value: selectedValues !== null && selectedValues !== void 0 ? selectedValues : ""
|
|
3850
|
+
})), isOpen && /*#__PURE__*/React__default.createElement("div", {
|
|
3833
3851
|
ref: menuRef,
|
|
3834
3852
|
className: cn$1("absolute z-50 w-full rounded-md border border-gray-300 bg-white shadow-lg", {
|
|
3835
3853
|
// if placement is bottom, place it below with margin-top; if top, place it above with bottom full and margin-bottom
|
|
@@ -3917,89 +3935,16 @@ var DEFAULT_ACTIONS = [{
|
|
|
3917
3935
|
})
|
|
3918
3936
|
}];
|
|
3919
3937
|
|
|
3920
|
-
//
|
|
3921
|
-
var
|
|
3922
|
-
var
|
|
3923
|
-
_ref$actions = _ref.actions,
|
|
3938
|
+
// Simple inline action menu component (no portal)
|
|
3939
|
+
var ActionMenu = /*#__PURE__*/memo(function ActionMenu(_ref) {
|
|
3940
|
+
var _ref$actions = _ref.actions,
|
|
3924
3941
|
actions = _ref$actions === void 0 ? [] : _ref$actions,
|
|
3925
|
-
|
|
3942
|
+
row = _ref.row,
|
|
3926
3943
|
onAction = _ref.onAction,
|
|
3927
3944
|
menuRef = _ref.menuRef;
|
|
3928
|
-
var _useState = useState({
|
|
3929
|
-
left: 0,
|
|
3930
|
-
top: 0,
|
|
3931
|
-
transformOrigin: "top right",
|
|
3932
|
-
maxHeight: 300,
|
|
3933
|
-
width: 180,
|
|
3934
|
-
opacity: 0
|
|
3935
|
-
}),
|
|
3936
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
3937
|
-
style = _useState2[0],
|
|
3938
|
-
setStyle = _useState2[1];
|
|
3939
|
-
var menuWidth = 180;
|
|
3940
|
-
var maxMenuHeight = 320;
|
|
3941
|
-
var margin = 8;
|
|
3942
|
-
var minMenuHeight = 80;
|
|
3943
|
-
useLayoutEffect(function () {
|
|
3944
|
-
if (!anchorElem) return;
|
|
3945
|
-
var computePosition = function computePosition() {
|
|
3946
|
-
var rect = anchorElem.getBoundingClientRect();
|
|
3947
|
-
var scrollY = window.scrollY || window.pageYOffset;
|
|
3948
|
-
var scrollX = window.scrollX || window.pageXOffset;
|
|
3949
|
-
var spaceBelow = window.innerHeight - rect.bottom;
|
|
3950
|
-
var spaceAbove = rect.top;
|
|
3951
|
-
var placement = "bottom";
|
|
3952
|
-
var allowedMaxHeight;
|
|
3953
|
-
if (spaceBelow < 160 && spaceAbove > spaceBelow) {
|
|
3954
|
-
placement = "top";
|
|
3955
|
-
allowedMaxHeight = Math.min(maxMenuHeight, Math.max(minMenuHeight, spaceAbove - margin));
|
|
3956
|
-
} else {
|
|
3957
|
-
allowedMaxHeight = Math.min(maxMenuHeight, Math.max(minMenuHeight, spaceBelow - margin));
|
|
3958
|
-
}
|
|
3959
|
-
var measuredMenuHeight = allowedMaxHeight;
|
|
3960
|
-
var menuEl = menuRef === null || menuRef === void 0 ? void 0 : menuRef.current;
|
|
3961
|
-
if (menuEl) {
|
|
3962
|
-
var contentHeight = menuEl.scrollHeight || menuEl.offsetHeight || allowedMaxHeight;
|
|
3963
|
-
measuredMenuHeight = Math.min(contentHeight, allowedMaxHeight);
|
|
3964
|
-
}
|
|
3965
|
-
var top = placement === "top" ? rect.top + scrollY - measuredMenuHeight - margin : rect.bottom + scrollY + margin;
|
|
3966
|
-
var minTop = margin + scrollY;
|
|
3967
|
-
var maxTop = window.innerHeight + scrollY - measuredMenuHeight - margin;
|
|
3968
|
-
top = Math.max(minTop, Math.min(top, maxTop));
|
|
3969
|
-
var left = rect.right + scrollX - menuWidth;
|
|
3970
|
-
left = Math.max(margin, Math.min(left, window.innerWidth - menuWidth - margin));
|
|
3971
|
-
setStyle({
|
|
3972
|
-
left: left,
|
|
3973
|
-
top: top,
|
|
3974
|
-
transformOrigin: placement === "bottom" ? "top right" : "bottom right",
|
|
3975
|
-
maxHeight: allowedMaxHeight,
|
|
3976
|
-
width: menuWidth,
|
|
3977
|
-
opacity: 1
|
|
3978
|
-
});
|
|
3979
|
-
};
|
|
3980
|
-
computePosition();
|
|
3981
|
-
var onScrollOrResize = function onScrollOrResize() {
|
|
3982
|
-
window.requestAnimationFrame(computePosition);
|
|
3983
|
-
};
|
|
3984
|
-
window.addEventListener("resize", onScrollOrResize);
|
|
3985
|
-
window.addEventListener("scroll", onScrollOrResize, true);
|
|
3986
|
-
return function () {
|
|
3987
|
-
window.removeEventListener("resize", onScrollOrResize);
|
|
3988
|
-
window.removeEventListener("scroll", onScrollOrResize, true);
|
|
3989
|
-
};
|
|
3990
|
-
}, [anchorElem, menuRef]);
|
|
3991
3945
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
3992
3946
|
ref: menuRef,
|
|
3993
|
-
|
|
3994
|
-
position: "absolute",
|
|
3995
|
-
top: style.top,
|
|
3996
|
-
left: style.left,
|
|
3997
|
-
width: style.width,
|
|
3998
|
-
maxHeight: style.maxHeight,
|
|
3999
|
-
transformOrigin: style.transformOrigin,
|
|
4000
|
-
opacity: style.opacity
|
|
4001
|
-
},
|
|
4002
|
-
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",
|
|
3947
|
+
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",
|
|
4003
3948
|
onClick: function onClick(e) {
|
|
4004
3949
|
return e.stopPropagation();
|
|
4005
3950
|
}
|
|
@@ -4015,9 +3960,9 @@ var ActionMenuPortal = /*#__PURE__*/memo(function ActionMenuPortal(_ref) {
|
|
|
4015
3960
|
className: "w-full text-left px-3 py-2 text-sm hover:bg-gray-100 flex items-center gap-2 rounded-md",
|
|
4016
3961
|
onClick: function onClick(e) {
|
|
4017
3962
|
e.stopPropagation();
|
|
4018
|
-
onAction === null || onAction === void 0 || onAction(action,
|
|
3963
|
+
onAction === null || onAction === void 0 || onAction(action, row);
|
|
4019
3964
|
}
|
|
4020
|
-
}, action.render ? action.render(
|
|
3965
|
+
}, action.render ? action.render(row) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, action.icon && /*#__PURE__*/React__default.createElement("span", {
|
|
4021
3966
|
className: "inline-flex"
|
|
4022
3967
|
}, action.icon), /*#__PURE__*/React__default.createElement("span", null, action.label))));
|
|
4023
3968
|
})));
|
|
@@ -4105,85 +4050,85 @@ var Table = function Table(_ref2) {
|
|
|
4105
4050
|
pageNumber = _ref2.pageNumber,
|
|
4106
4051
|
props = _objectWithoutProperties$1(_ref2, _excluded$k);
|
|
4107
4052
|
// Core state
|
|
4108
|
-
var
|
|
4109
|
-
|
|
4110
|
-
isMobileView =
|
|
4111
|
-
setIsMobileView =
|
|
4112
|
-
var
|
|
4053
|
+
var _useState = useState(false),
|
|
4054
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
4055
|
+
isMobileView = _useState2[0],
|
|
4056
|
+
setIsMobileView = _useState2[1];
|
|
4057
|
+
var _useState3 = useState(function () {
|
|
4113
4058
|
return Array.isArray(data) ? data : [];
|
|
4114
4059
|
}),
|
|
4060
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
4061
|
+
tableData = _useState4[0],
|
|
4062
|
+
setTableData = _useState4[1];
|
|
4063
|
+
var _useState5 = useState(false),
|
|
4115
4064
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
var _useState7 = useState(
|
|
4065
|
+
loading = _useState6[0],
|
|
4066
|
+
setLoading = _useState6[1];
|
|
4067
|
+
var _useState7 = useState(pageSize),
|
|
4119
4068
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
var _useState9 = useState(
|
|
4123
|
-
_useState0 = _slicedToArray(_useState9, 2),
|
|
4124
|
-
limit = _useState0[0],
|
|
4125
|
-
setLimit = _useState0[1];
|
|
4126
|
-
var _useState1 = useState(function () {
|
|
4069
|
+
limit = _useState8[0],
|
|
4070
|
+
setLimit = _useState8[1];
|
|
4071
|
+
var _useState9 = useState(function () {
|
|
4127
4072
|
return typeof pageNumber === "number" ? pageNumber : 1;
|
|
4128
4073
|
}),
|
|
4129
|
-
|
|
4130
|
-
currentPage =
|
|
4131
|
-
setCurrentPage =
|
|
4074
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
4075
|
+
currentPage = _useState0[0],
|
|
4076
|
+
setCurrentPage = _useState0[1];
|
|
4132
4077
|
|
|
4133
4078
|
// Column state
|
|
4134
|
-
var
|
|
4079
|
+
var _useState1 = useState(function () {
|
|
4135
4080
|
return Array.isArray(columns) ? columns.map(function (c) {
|
|
4136
4081
|
return _objectSpread$9({}, c);
|
|
4137
4082
|
}) : [];
|
|
4138
4083
|
}),
|
|
4084
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
4085
|
+
columnsState = _useState10[0],
|
|
4086
|
+
setColumnsState = _useState10[1];
|
|
4087
|
+
var _useState11 = useState(false),
|
|
4139
4088
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
var _useState13 = useState(false),
|
|
4143
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
4144
|
-
showColumnMenu = _useState14[0],
|
|
4145
|
-
setShowColumnMenu = _useState14[1];
|
|
4089
|
+
showColumnMenu = _useState12[0],
|
|
4090
|
+
setShowColumnMenu = _useState12[1];
|
|
4146
4091
|
|
|
4147
4092
|
// Sorting/filtering state
|
|
4148
|
-
var
|
|
4093
|
+
var _useState13 = useState({
|
|
4149
4094
|
key: null,
|
|
4150
4095
|
direction: "asc"
|
|
4151
4096
|
}),
|
|
4097
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
4098
|
+
sortConfig = _useState14[0],
|
|
4099
|
+
setSortConfig = _useState14[1];
|
|
4100
|
+
var _useState15 = useState({}),
|
|
4152
4101
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
var _useState17 = useState(
|
|
4102
|
+
filters = _useState16[0],
|
|
4103
|
+
setFilters = _useState16[1];
|
|
4104
|
+
var _useState17 = useState(""),
|
|
4156
4105
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
var _useState19 = useState(""),
|
|
4160
|
-
_useState20 = _slicedToArray(_useState19, 2),
|
|
4161
|
-
searchInput = _useState20[0],
|
|
4162
|
-
setSearchInput = _useState20[1];
|
|
4106
|
+
searchInput = _useState18[0],
|
|
4107
|
+
setSearchInput = _useState18[1];
|
|
4163
4108
|
|
|
4164
4109
|
// Selection/expansion state
|
|
4165
|
-
var
|
|
4110
|
+
var _useState19 = useState(function () {
|
|
4166
4111
|
return new Set();
|
|
4167
4112
|
}),
|
|
4168
|
-
|
|
4169
|
-
selectedRows =
|
|
4170
|
-
setSelectedRows =
|
|
4171
|
-
var
|
|
4113
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
4114
|
+
selectedRows = _useState20[0],
|
|
4115
|
+
setSelectedRows = _useState20[1];
|
|
4116
|
+
var _useState21 = useState(function () {
|
|
4172
4117
|
return new Set();
|
|
4173
4118
|
}),
|
|
4174
|
-
|
|
4175
|
-
expandedRows =
|
|
4176
|
-
setExpandedRows =
|
|
4119
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
4120
|
+
expandedRows = _useState22[0],
|
|
4121
|
+
setExpandedRows = _useState22[1];
|
|
4177
4122
|
|
|
4178
4123
|
// Action menu state
|
|
4179
|
-
var
|
|
4124
|
+
var _useState23 = useState(null),
|
|
4125
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
4126
|
+
actionAnchor = _useState24[0],
|
|
4127
|
+
setActionAnchor = _useState24[1];
|
|
4128
|
+
var _useState25 = useState(false),
|
|
4180
4129
|
_useState26 = _slicedToArray(_useState25, 2),
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
var _useState27 = useState(false),
|
|
4184
|
-
_useState28 = _slicedToArray(_useState27, 2),
|
|
4185
|
-
showMobileFilters = _useState28[0],
|
|
4186
|
-
setShowMobileFilters = _useState28[1];
|
|
4130
|
+
showMobileFilters = _useState26[0],
|
|
4131
|
+
setShowMobileFilters = _useState26[1];
|
|
4187
4132
|
|
|
4188
4133
|
// Refs
|
|
4189
4134
|
var columnMenuRef = useRef(null);
|
|
@@ -4524,15 +4469,14 @@ var Table = function Table(_ref2) {
|
|
|
4524
4469
|
title: "Actions"
|
|
4525
4470
|
}, /*#__PURE__*/React__default.createElement(MoreVertical, {
|
|
4526
4471
|
className: "h-4 w-4"
|
|
4527
|
-
})), (actionAnchor === null || actionAnchor === void 0 ? void 0 : actionAnchor.key) === actionCellKey && /*#__PURE__*/
|
|
4528
|
-
anchorElem: actionAnchor.elem,
|
|
4529
|
-
anchorRow: actionAnchor.row,
|
|
4472
|
+
})), (actionAnchor === null || actionAnchor === void 0 ? void 0 : actionAnchor.key) === actionCellKey && /*#__PURE__*/React__default.createElement(ActionMenu, {
|
|
4530
4473
|
actions: actionsToUse,
|
|
4474
|
+
row: row,
|
|
4531
4475
|
onAction: function onAction(action) {
|
|
4532
4476
|
return handleOnAction(action, row);
|
|
4533
4477
|
},
|
|
4534
4478
|
menuRef: actionMenuRef
|
|
4535
|
-
})
|
|
4479
|
+
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
4536
4480
|
className: "p-4"
|
|
4537
4481
|
}, visibleColumns.map(function (column, colIndex) {
|
|
4538
4482
|
var extraCellClass = typeof cellClass === "function" ? cellClass({
|
|
@@ -4914,7 +4858,7 @@ var Table = function Table(_ref2) {
|
|
|
4914
4858
|
return e.stopPropagation();
|
|
4915
4859
|
}
|
|
4916
4860
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
4917
|
-
className: "inline-block"
|
|
4861
|
+
className: "relative inline-block"
|
|
4918
4862
|
}, /*#__PURE__*/React__default.createElement("button", {
|
|
4919
4863
|
onClick: function onClick(e) {
|
|
4920
4864
|
return toggleActions(e, actionCellKey, row);
|
|
@@ -4924,15 +4868,14 @@ var Table = function Table(_ref2) {
|
|
|
4924
4868
|
title: "Actions"
|
|
4925
4869
|
}, /*#__PURE__*/React__default.createElement(MoreVertical, {
|
|
4926
4870
|
className: "h-4 w-4"
|
|
4927
|
-
}))
|
|
4928
|
-
anchorElem: actionAnchor.elem,
|
|
4929
|
-
anchorRow: actionAnchor.row,
|
|
4871
|
+
})), (actionAnchor === null || actionAnchor === void 0 ? void 0 : actionAnchor.key) === actionCellKey && /*#__PURE__*/React__default.createElement(ActionMenu, {
|
|
4930
4872
|
actions: actionsToUse,
|
|
4873
|
+
row: row,
|
|
4931
4874
|
onAction: function onAction(action) {
|
|
4932
4875
|
return handleOnAction(action, row);
|
|
4933
4876
|
},
|
|
4934
4877
|
menuRef: actionMenuRef
|
|
4935
|
-
})
|
|
4878
|
+
})))), hasDetails && isExpanded && DetailsComponent && /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
|
|
4936
4879
|
colSpan: visibleCount,
|
|
4937
4880
|
className: "px-6 py-4 bg-gray-50"
|
|
4938
4881
|
}, /*#__PURE__*/React__default.createElement(DetailsComponent, {
|