@ccs-ui/rc-pro 2.3.6-beta-13 → 2.3.6-beta-14
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/es/button/group.js +32 -33
- package/package.json +1 -1
package/es/button/group.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["onDisabled", "onHidden"],
|
|
2
|
+
var _excluded = ["onDisabled", "onHidden", "auth"],
|
|
3
3
|
_excluded2 = ["key", "label", "auth", "confirm", "showRowsCount", "onDisabled", "onHidden"],
|
|
4
|
-
_excluded3 = ["key", "label", "disabled", "auth", "confirm", "showRowsCount"
|
|
4
|
+
_excluded3 = ["key", "label", "disabled", "auth", "confirm", "showRowsCount"];
|
|
5
5
|
function ownKeys(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; }
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -33,35 +33,35 @@ export default function CssButtonGroup(_ref) {
|
|
|
33
33
|
var modalRef = useRef(null);
|
|
34
34
|
var _ref3 = useContext(TableSelectionContext) || {},
|
|
35
35
|
selectedRows = _ref3.selectedRows;
|
|
36
|
+
|
|
37
|
+
// 有权限的按钮
|
|
36
38
|
var authButtons = [];
|
|
37
39
|
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
// 变量按钮
|
|
41
|
+
items.forEach(function (_ref4) {
|
|
42
|
+
var onDisabled = _ref4.onDisabled,
|
|
43
|
+
onHidden = _ref4.onHidden,
|
|
44
|
+
auth = _ref4.auth,
|
|
45
|
+
item = _objectWithoutProperties(_ref4, _excluded);
|
|
46
|
+
// 权限校验
|
|
47
|
+
if (onAuth && auth && !onAuth(auth)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
42
50
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var onDisabled = _ref4.onDisabled,
|
|
48
|
-
onHidden = _ref4.onHidden,
|
|
49
|
-
b = _objectWithoutProperties(_ref4, _excluded);
|
|
50
|
-
return _objectSpread({}, b);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
51
|
+
// 隐藏按钮
|
|
52
|
+
if (onHidden && onHidden(selectedRows || [])) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (!items || items.length === 0) return null;
|
|
56
|
+
// 禁用按钮
|
|
57
|
+
if (onDisabled && onDisabled(selectedRows || [])) {
|
|
58
|
+
item.disabled = true;
|
|
59
|
+
}
|
|
60
|
+
authButtons.push(item);
|
|
61
|
+
});
|
|
62
|
+
if (!authButtons || items.length === 0) return null;
|
|
62
63
|
|
|
63
|
-
//
|
|
64
|
-
var showBtns = authButtons.splice(0, showCount || items.length);
|
|
64
|
+
// 按钮点击
|
|
65
65
|
var handleOnClick = function handleOnClick(key) {
|
|
66
66
|
if (!onClick) return;
|
|
67
67
|
var item = items.find(function (i) {
|
|
@@ -84,6 +84,10 @@ export default function CssButtonGroup(_ref) {
|
|
|
84
84
|
}
|
|
85
85
|
onClick(key, selectedRows);
|
|
86
86
|
};
|
|
87
|
+
|
|
88
|
+
// 显示的按钮
|
|
89
|
+
var showBtns = authButtons.splice(0, showCount || items.length);
|
|
90
|
+
|
|
87
91
|
// link类型按钮
|
|
88
92
|
if (isLink) {
|
|
89
93
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -146,12 +150,7 @@ export default function CssButtonGroup(_ref) {
|
|
|
146
150
|
auth = _ref6.auth,
|
|
147
151
|
confirm = _ref6.confirm,
|
|
148
152
|
showRowsCount = _ref6.showRowsCount,
|
|
149
|
-
onDisabled = _ref6.onDisabled,
|
|
150
|
-
onHidden = _ref6.onHidden,
|
|
151
153
|
restProps = _objectWithoutProperties(_ref6, _excluded3);
|
|
152
|
-
// 按钮禁用
|
|
153
|
-
var isDisabled = disabled || onDisabled && onDisabled(selectedRows || []);
|
|
154
|
-
|
|
155
154
|
// 更多按钮
|
|
156
155
|
if (index === showBtns.length - 1 && authButtons.length > 0) {
|
|
157
156
|
return /*#__PURE__*/_jsxs(Space.Compact, {
|
|
@@ -160,7 +159,7 @@ export default function CssButtonGroup(_ref) {
|
|
|
160
159
|
onClick: function onClick() {
|
|
161
160
|
return handleOnClick(key);
|
|
162
161
|
},
|
|
163
|
-
disabled:
|
|
162
|
+
disabled: disabled,
|
|
164
163
|
children: [label, showRowsCount && selectedRows !== null && selectedRows !== void 0 && selectedRows.length ? "(".concat(selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length, ")") : '']
|
|
165
164
|
})), /*#__PURE__*/_jsx(Dropdown, {
|
|
166
165
|
menu: {
|
|
@@ -178,7 +177,7 @@ export default function CssButtonGroup(_ref) {
|
|
|
178
177
|
}
|
|
179
178
|
return /*#__PURE__*/_jsxs(Button, _objectSpread(_objectSpread({}, restProps), {}, {
|
|
180
179
|
size: size,
|
|
181
|
-
disabled:
|
|
180
|
+
disabled: disabled,
|
|
182
181
|
onClick: function onClick() {
|
|
183
182
|
return handleOnClick(key);
|
|
184
183
|
},
|