fan-standard-comp 3.2.8 → 3.2.9
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/fan-standard-comp.umd.js +2 -2
- package/es/ButtonGroup/index.d.ts +3 -0
- package/es/ButtonGroup/index.js +112 -40
- package/es/ButtonGroup/index3.d.ts +39 -0
- package/es/ButtonGroup/index3.js +449 -0
- package/es/components/IconNode/index.d.ts +1 -0
- package/es/components/IconNode/index.js +6 -3
- package/lib/ButtonGroup/index.d.ts +3 -0
- package/lib/ButtonGroup/index.js +111 -39
- package/lib/ButtonGroup/index3.d.ts +39 -0
- package/lib/ButtonGroup/index3.js +459 -0
- package/lib/components/IconNode/index.d.ts +1 -0
- package/lib/components/IconNode/index.js +6 -3
- package/package.json +2 -2
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
import "antd/es/popconfirm/style";
|
|
2
|
+
import _Popconfirm from "antd/es/popconfirm";
|
|
3
|
+
import "antd/es/button/style";
|
|
4
|
+
import _Button from "antd/es/button";
|
|
5
|
+
import "antd/es/dropdown/style";
|
|
6
|
+
import _Dropdown from "antd/es/dropdown";
|
|
7
|
+
import "antd/es/menu/style";
|
|
8
|
+
import _Menu from "antd/es/menu";
|
|
9
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
10
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
12
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
13
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
14
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
16
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
17
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
18
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
19
|
+
import { __rest } from "tslib";
|
|
20
|
+
import React, { useState, useEffect } from "react";
|
|
21
|
+
import { IconNode } from "../components/index";
|
|
22
|
+
import SpecIcon from "../SpecIcon/index";
|
|
23
|
+
import PopConfirmTitle from './PopConfirmTitle';
|
|
24
|
+
import { funcCode } from "../data/index";
|
|
25
|
+
import { DownOutlined, QuestionCircleOutlined } from "@ant-design/icons";
|
|
26
|
+
import { removeNoPermission, btnIsDisabled } from '../utils/filterPermission.js';
|
|
27
|
+
import { convertToArray } from '../utils/index';
|
|
28
|
+
import _ from 'lodash';
|
|
29
|
+
import './style/index.less';
|
|
30
|
+
var ButtonGroup = function ButtonGroup(props) {
|
|
31
|
+
var _props$type = props.type,
|
|
32
|
+
type = _props$type === void 0 ? 'button' : _props$type,
|
|
33
|
+
_props$rowParams = props.rowParams,
|
|
34
|
+
rowParams = _props$rowParams === void 0 ? {
|
|
35
|
+
text: undefined,
|
|
36
|
+
record: undefined,
|
|
37
|
+
rowIndex: undefined
|
|
38
|
+
} : _props$rowParams,
|
|
39
|
+
codes = props.codes,
|
|
40
|
+
permissionCodes = props.permissionCodes,
|
|
41
|
+
_props$dropdownConfig = props.dropdownConfig,
|
|
42
|
+
dropdownConfig = _props$dropdownConfig === void 0 ? {} : _props$dropdownConfig,
|
|
43
|
+
_props$moreText = props.moreText,
|
|
44
|
+
moreText = _props$moreText === void 0 ? '更多' : _props$moreText,
|
|
45
|
+
moreIcon = props.moreIcon,
|
|
46
|
+
_props$showTextIcon = props.showTextIcon,
|
|
47
|
+
showTextIcon = _props$showTextIcon === void 0 ? false : _props$showTextIcon,
|
|
48
|
+
className = props.className,
|
|
49
|
+
style = props.style;
|
|
50
|
+
var _props$options = props.options,
|
|
51
|
+
options = _props$options === void 0 ? [] : _props$options,
|
|
52
|
+
_props$min = props.min,
|
|
53
|
+
min = _props$min === void 0 ? 3 : _props$min; // 最小展示长度不能小于2
|
|
54
|
+
if (!options) return null; // 没有配置list返回null
|
|
55
|
+
var _useState = useState(-1),
|
|
56
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
57
|
+
popVisibleIndex = _useState2[0],
|
|
58
|
+
setPopVisibleIndex = _useState2[1];
|
|
59
|
+
var _useState3 = useState({}),
|
|
60
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
61
|
+
popRow = _useState4[0],
|
|
62
|
+
setPopRow = _useState4[1];
|
|
63
|
+
var _useState5 = useState(-1),
|
|
64
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
65
|
+
popSubVisibleIndex = _useState6[0],
|
|
66
|
+
setPopSubVisibleIndex = _useState6[1];
|
|
67
|
+
var _useState7 = useState({}),
|
|
68
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
69
|
+
popSubRow = _useState8[0],
|
|
70
|
+
setPopSubRow = _useState8[1];
|
|
71
|
+
var _useState9 = useState([]),
|
|
72
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
73
|
+
resetList = _useState10[0],
|
|
74
|
+
setResetList = _useState10[1];
|
|
75
|
+
useEffect(function () {
|
|
76
|
+
// codes在方法内,再合并默认的权限配置
|
|
77
|
+
// 合并本地的codes
|
|
78
|
+
var codesConcat = _.unionBy(codes || [], funcCode.btnFuncCodes, 'code');
|
|
79
|
+
// 重组选项options集合数据,排除:无权限(有配置code,并且不包含permissionCodes内)的数据及,isHide 为true的数据
|
|
80
|
+
setResetList(_toConsumableArray(removeNoPermission(options, permissionCodes, codesConcat, rowParams)) || []);
|
|
81
|
+
return function () {
|
|
82
|
+
setResetList([]);
|
|
83
|
+
};
|
|
84
|
+
}, [options, codes, permissionCodes]);
|
|
85
|
+
useEffect(function () {
|
|
86
|
+
setPopVisibleIndex(-1);
|
|
87
|
+
setPopSubVisibleIndex(-1);
|
|
88
|
+
setPopRow({});
|
|
89
|
+
setPopSubRow({});
|
|
90
|
+
}, [rowParams]);
|
|
91
|
+
// 渲染按钮多层级形式 (用于筛选)
|
|
92
|
+
var buttonMenu = function buttonMenu(group) {
|
|
93
|
+
return /*#__PURE__*/React.createElement(_Menu, null, group.map(function (item, index) {
|
|
94
|
+
if (item.children) {
|
|
95
|
+
return /*#__PURE__*/React.createElement(_Menu.SubMenu, {
|
|
96
|
+
title: item.exName || item.name,
|
|
97
|
+
key: index
|
|
98
|
+
}, item.children.map(function (child, childIndex) {
|
|
99
|
+
return /*#__PURE__*/React.createElement(_Menu.Item, {
|
|
100
|
+
key: child.name + childIndex
|
|
101
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
102
|
+
onClick: child.fn ? function () {
|
|
103
|
+
return child.fn(child);
|
|
104
|
+
} : null
|
|
105
|
+
}, /*#__PURE__*/React.createElement(IconNode, {
|
|
106
|
+
icon: child.icon
|
|
107
|
+
}), " ", child.exName || child.name));
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
return /*#__PURE__*/React.createElement(_Menu.Item, {
|
|
111
|
+
key: item.name + index
|
|
112
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
113
|
+
onClick: item.fn ? function () {
|
|
114
|
+
return item.fn(item);
|
|
115
|
+
} : null
|
|
116
|
+
}, /*#__PURE__*/React.createElement(IconNode, {
|
|
117
|
+
icon: item.icon
|
|
118
|
+
}), " ", item.exName || item.name));
|
|
119
|
+
}));
|
|
120
|
+
};
|
|
121
|
+
// 渲染按钮形式 (用于筛选)
|
|
122
|
+
var RenderButtonList = function RenderButtonList(item) {
|
|
123
|
+
var exName = item.exName,
|
|
124
|
+
name = item.name,
|
|
125
|
+
type = item.type,
|
|
126
|
+
icon = item.icon,
|
|
127
|
+
ghost = item.ghost,
|
|
128
|
+
danger = item.danger,
|
|
129
|
+
disabled = item.disabled,
|
|
130
|
+
loading = item.loading,
|
|
131
|
+
fn = item.fn,
|
|
132
|
+
code = item.code,
|
|
133
|
+
rowParams = item.rowParams,
|
|
134
|
+
others = __rest(item, ["exName", "name", "type", "icon", "ghost", "danger", "disabled", "loading", "fn", "code", "rowParams"]);
|
|
135
|
+
if (Array.isArray(item.children) && item.children.length > 0) {
|
|
136
|
+
return /*#__PURE__*/React.createElement(_Dropdown, Object.assign({
|
|
137
|
+
overlay: buttonMenu(item.children),
|
|
138
|
+
placement: "bottomRight"
|
|
139
|
+
}, (item === null || item === void 0 ? void 0 : item.dropdownConfig) || dropdownConfig || {}), /*#__PURE__*/React.createElement(_Button, {
|
|
140
|
+
type: "primary"
|
|
141
|
+
}, item.exName || item.name, " ", /*#__PURE__*/React.createElement(SpecIcon, {
|
|
142
|
+
name: "down"
|
|
143
|
+
})));
|
|
144
|
+
}
|
|
145
|
+
return /*#__PURE__*/React.createElement(_Button, Object.assign({
|
|
146
|
+
type: type || 'primary',
|
|
147
|
+
danger: danger,
|
|
148
|
+
ghost: ghost,
|
|
149
|
+
loading: loading,
|
|
150
|
+
onClick: fn ? function () {
|
|
151
|
+
return fn(item);
|
|
152
|
+
} : null
|
|
153
|
+
}, others, {
|
|
154
|
+
icon: /*#__PURE__*/React.createElement(IconNode, {
|
|
155
|
+
icon: icon
|
|
156
|
+
}),
|
|
157
|
+
disabled: btnIsDisabled(disabled, rowParams)
|
|
158
|
+
}), exName || name);
|
|
159
|
+
};
|
|
160
|
+
/*const textMenuItems = (group) => {
|
|
161
|
+
return (group || []).map((gItem: any, gIndex) => {
|
|
162
|
+
return {
|
|
163
|
+
disabled: btnIsDisabled(gItem.disabled, rowParams),
|
|
164
|
+
label: gItem.hasOwnProperty('confirmText') || gItem.hasOwnProperty('confirmConfig') ?
|
|
165
|
+
// @ts-ignore
|
|
166
|
+
<a disabled={btnIsDisabled(gItem.disabled, rowParams)}
|
|
167
|
+
onClick={gItem.fn ? () => {
|
|
168
|
+
setPopVisibleIndex(rowParams.rowIndex)
|
|
169
|
+
setPopRow(gItem)
|
|
170
|
+
} : null}>
|
|
171
|
+
{gItem.render ? gItem.render(...Object.keys(rowParams).map((pItem) => rowParams[pItem])) : (gItem.exName || gItem.name)}
|
|
172
|
+
</a>
|
|
173
|
+
: <a className="spec-button-group-text"
|
|
174
|
+
onClick={gItem.fn ? () => gItem.fn(...Object.keys(rowParams).map((pItem) => rowParams[pItem])) : null}
|
|
175
|
+
// @ts-ignore
|
|
176
|
+
disabled={btnIsDisabled(gItem.disabled, rowParams)}>
|
|
177
|
+
{gItem.render ? gItem.render(...Object.keys(rowParams).map((pItem) => rowParams[pItem])) : (gItem.exName || gItem.name)}
|
|
178
|
+
</a>,
|
|
179
|
+
key: gIndex + (gItem.exName || gItem.name),
|
|
180
|
+
children: gItem.children ? (gItem.children || []).map((child: any, childIndex: number) => {
|
|
181
|
+
return {
|
|
182
|
+
label: <a onClick={child.fn ? () => child.fn(...Object.keys(rowParams).map((pItem) => rowParams[pItem])) : null}>
|
|
183
|
+
{child.render ? child.render(...Object.keys(rowParams).map((pItem) => rowParams[pItem])) : (child.exName || child.name)}
|
|
184
|
+
</a>,
|
|
185
|
+
key: childIndex
|
|
186
|
+
}
|
|
187
|
+
}) : undefined
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
}*/
|
|
191
|
+
// 自定义渲染显示的文本
|
|
192
|
+
var renderCustomLabel = function renderCustomLabel(gItem, hideIcon) {
|
|
193
|
+
return gItem.render ? gItem.render.apply(gItem, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
194
|
+
return rowParams[pItem];
|
|
195
|
+
}))) : (/*#__PURE__*/React.createElement(React.Fragment, null, !hideIcon && gItem.icon && showTextIcon ? /*#__PURE__*/React.createElement(IconNode, {
|
|
196
|
+
icon: gItem.icon
|
|
197
|
+
}) : '', " ", gItem.exName || gItem.name));
|
|
198
|
+
};
|
|
199
|
+
// 渲染文本形式多级菜单列表(用于表格)
|
|
200
|
+
var textMenu = function textMenu(group, source) {
|
|
201
|
+
var menuTitle = function menuTitle(gItem, displayClass) {
|
|
202
|
+
return gItem.hasOwnProperty('confirmText') || gItem.hasOwnProperty('confirmConfig') ?
|
|
203
|
+
/*#__PURE__*/
|
|
204
|
+
// @ts-ignore
|
|
205
|
+
React.createElement("a", {
|
|
206
|
+
disabled: btnIsDisabled(gItem.disabled, rowParams),
|
|
207
|
+
onClick: gItem.fn ? function () {
|
|
208
|
+
console.log('带二次确认节点点击区分处理更多里面还是直接展示里面的按钮');
|
|
209
|
+
setPopVisibleIndex(source === 'isMoreChild' ? rowParams.rowIndex : -1);
|
|
210
|
+
setPopRow(source === 'isMoreChild' ? gItem : {});
|
|
211
|
+
setPopSubVisibleIndex(source === 'isMoreChild' ? -1 : rowParams.rowIndex);
|
|
212
|
+
setPopSubRow(source === 'isMoreChild' ? {} : gItem);
|
|
213
|
+
} : null
|
|
214
|
+
}, renderCustomLabel(gItem)) : /*#__PURE__*/React.createElement("a", {
|
|
215
|
+
className: displayClass,
|
|
216
|
+
// className={"spec-button-group-text" }
|
|
217
|
+
onClick: gItem.fn ? function () {
|
|
218
|
+
return gItem.fn.apply(gItem, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
219
|
+
return rowParams[pItem];
|
|
220
|
+
})));
|
|
221
|
+
} : null,
|
|
222
|
+
// @ts-ignore
|
|
223
|
+
disabled: btnIsDisabled(gItem.disabled, rowParams)
|
|
224
|
+
}, renderCustomLabel(gItem));
|
|
225
|
+
};
|
|
226
|
+
return /*#__PURE__*/React.createElement(_Menu, {
|
|
227
|
+
className: "spec-button-text-dropdown"
|
|
228
|
+
}, group.map(function (gItem, gIndex) {
|
|
229
|
+
if (gItem.children) {
|
|
230
|
+
return /*#__PURE__*/React.createElement(_Menu.SubMenu, {
|
|
231
|
+
title: gItem.exName || gItem.name,
|
|
232
|
+
key: gItem.name + gIndex
|
|
233
|
+
}, gItem.children.map(function (child, childIndex) {
|
|
234
|
+
return /*#__PURE__*/React.createElement(_Menu.Item, {
|
|
235
|
+
key: child.name + childIndex
|
|
236
|
+
}, menuTitle(child));
|
|
237
|
+
}));
|
|
238
|
+
}
|
|
239
|
+
return /*#__PURE__*/React.createElement(_Menu.Item, {
|
|
240
|
+
key: gIndex,
|
|
241
|
+
disabled: btnIsDisabled(gItem.disabled, rowParams)
|
|
242
|
+
}, menuTitle(gItem, "spec-button-group-text"));
|
|
243
|
+
}));
|
|
244
|
+
};
|
|
245
|
+
// 渲染文本形式 列表(用于表格)
|
|
246
|
+
var RenderTextList = function RenderTextList(item) {
|
|
247
|
+
if (Array.isArray(item.children) && item.children.length > 0) {
|
|
248
|
+
var hasConfirmText = [];
|
|
249
|
+
item.children.forEach(function (child) {
|
|
250
|
+
hasConfirmText = hasConfirmText.concat(convertToArray([child]));
|
|
251
|
+
console.log('convertToArray', convertToArray([child]));
|
|
252
|
+
});
|
|
253
|
+
if (hasConfirmText.filter(function (hcItem) {
|
|
254
|
+
return hcItem.hasOwnProperty('confirmText') || hcItem.hasOwnProperty('confirmConfig');
|
|
255
|
+
}).length) {
|
|
256
|
+
// 子项有二次确认文本,需要显示浮层
|
|
257
|
+
return /*#__PURE__*/React.createElement(_Popconfirm, Object.assign({
|
|
258
|
+
placement: "topRight",
|
|
259
|
+
visible: popSubVisibleIndex === rowParams.rowIndex,
|
|
260
|
+
icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null),
|
|
261
|
+
trigger: "click"
|
|
262
|
+
}, popSubRow.hasOwnProperty('confirmConfig') ? popSubRow.confirmConfig : {}, {
|
|
263
|
+
title: /*#__PURE__*/React.createElement(PopConfirmTitle, Object.assign({}, popSubRow, {
|
|
264
|
+
extraRow: rowParams
|
|
265
|
+
})),
|
|
266
|
+
onCancel: function onCancel() {
|
|
267
|
+
setPopSubVisibleIndex(-1);
|
|
268
|
+
// 优先调用其 confirmConfig 配置的 onCancel 事件
|
|
269
|
+
if (popSubRow.hasOwnProperty('confirmConfig') && popSubRow.confirmConfig.onCancel) {
|
|
270
|
+
var _popSubRow$confirmCon;
|
|
271
|
+
(_popSubRow$confirmCon = popSubRow.confirmConfig).onCancel.apply(_popSubRow$confirmCon, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
272
|
+
return rowParams[pItem];
|
|
273
|
+
})));
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
onConfirm: function onConfirm() {
|
|
277
|
+
setPopSubVisibleIndex(-1);
|
|
278
|
+
// 优先调用其 confirmConfig 配置的 onConfirm 事件
|
|
279
|
+
if (popSubRow.hasOwnProperty('confirmConfig') && popSubRow.confirmConfig.onConfirm) {
|
|
280
|
+
var _popSubRow$confirmCon2;
|
|
281
|
+
(_popSubRow$confirmCon2 = popSubRow.confirmConfig).onConfirm.apply(_popSubRow$confirmCon2, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
282
|
+
return rowParams[pItem];
|
|
283
|
+
})));
|
|
284
|
+
} else if (popSubRow.fn) {
|
|
285
|
+
popSubRow.fn.apply(popSubRow, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
286
|
+
return rowParams[pItem];
|
|
287
|
+
})));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}), /*#__PURE__*/React.createElement(_Dropdown, Object.assign({
|
|
291
|
+
overlay: textMenu(item.children),
|
|
292
|
+
placement: "bottomRight"
|
|
293
|
+
}, (item === null || item === void 0 ? void 0 : item.dropdownConfig) || dropdownConfig || {}), /*#__PURE__*/React.createElement("a", {
|
|
294
|
+
className: "spec-button-group-text"
|
|
295
|
+
}, item.render ? item.render.apply(item, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
296
|
+
return rowParams[pItem];
|
|
297
|
+
}))) : item.exName || item.name, " ", /*#__PURE__*/React.createElement(SpecIcon, {
|
|
298
|
+
name: "down"
|
|
299
|
+
}))));
|
|
300
|
+
}
|
|
301
|
+
return /*#__PURE__*/React.createElement(_Dropdown, Object.assign({
|
|
302
|
+
overlay: textMenu(item.children),
|
|
303
|
+
placement: "bottomRight"
|
|
304
|
+
}, (item === null || item === void 0 ? void 0 : item.dropdownConfig) || dropdownConfig || {}), /*#__PURE__*/React.createElement("a", {
|
|
305
|
+
className: "spec-button-group-text"
|
|
306
|
+
}, item.render ? item.render.apply(item, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
307
|
+
return rowParams[pItem];
|
|
308
|
+
}))) : item.exName || item.name, " ", /*#__PURE__*/React.createElement(SpecIcon, {
|
|
309
|
+
name: "down"
|
|
310
|
+
})));
|
|
311
|
+
}
|
|
312
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, item.hasOwnProperty('confirmText') || item.hasOwnProperty('confirmConfig') ? /*#__PURE__*/React.createElement(_Popconfirm, Object.assign({
|
|
313
|
+
placement: "topRight",
|
|
314
|
+
icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null)
|
|
315
|
+
}, item.hasOwnProperty('confirmConfig') ? item.confirmConfig : {}, {
|
|
316
|
+
title: /*#__PURE__*/React.createElement(PopConfirmTitle, Object.assign({}, item, {
|
|
317
|
+
extraRow: rowParams
|
|
318
|
+
})),
|
|
319
|
+
onCancel: function onCancel() {
|
|
320
|
+
if (item.hasOwnProperty('confirmConfig') && item.confirmConfig.onCancel) {
|
|
321
|
+
var _item$confirmConfig;
|
|
322
|
+
(_item$confirmConfig = item.confirmConfig).onCancel.apply(_item$confirmConfig, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
323
|
+
return rowParams[pItem];
|
|
324
|
+
})));
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
onConfirm: function onConfirm() {
|
|
328
|
+
if (item.hasOwnProperty('confirmConfig') && item.confirmConfig.onConfirm) {
|
|
329
|
+
var _item$confirmConfig2;
|
|
330
|
+
(_item$confirmConfig2 = item.confirmConfig).onConfirm.apply(_item$confirmConfig2, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
331
|
+
return rowParams[pItem];
|
|
332
|
+
})));
|
|
333
|
+
} else if (item.fn) {
|
|
334
|
+
item.fn.apply(item, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
335
|
+
return rowParams[pItem];
|
|
336
|
+
})));
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}), /*#__PURE__*/React.createElement("a", {
|
|
340
|
+
className: "spec-button-group-text",
|
|
341
|
+
key: item.index,
|
|
342
|
+
title: item.exName || item.name,
|
|
343
|
+
// @ts-ignore
|
|
344
|
+
disabled: btnIsDisabled(item.disabled, rowParams)
|
|
345
|
+
}, item.render ? item.render.apply(item, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
346
|
+
return rowParams[pItem];
|
|
347
|
+
}))) : item.exName || item.name)) : /*#__PURE__*/React.createElement("a", {
|
|
348
|
+
className: "spec-button-group-text",
|
|
349
|
+
title: item.exName || item.name,
|
|
350
|
+
key: item.index,
|
|
351
|
+
// @ts-ignore
|
|
352
|
+
disabled: btnIsDisabled(item.disabled, rowParams),
|
|
353
|
+
onClick: item.fn ? function () {
|
|
354
|
+
return item.fn.apply(item, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
355
|
+
return rowParams[pItem];
|
|
356
|
+
})));
|
|
357
|
+
} : null
|
|
358
|
+
}, item.render ? item.render.apply(item, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
359
|
+
return rowParams[pItem];
|
|
360
|
+
}))) : item.exName || item.name));
|
|
361
|
+
};
|
|
362
|
+
// 渲染展示的按钮列表
|
|
363
|
+
var renderDisplayButton = function renderDisplayButton(item, index) {
|
|
364
|
+
/*渲染自定义*/
|
|
365
|
+
if (item.render) {
|
|
366
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, typeof item.render === 'function' ? item.render.apply(item, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
367
|
+
return rowParams[pItem];
|
|
368
|
+
}))) : item.render);
|
|
369
|
+
}
|
|
370
|
+
/*渲染按钮形式*/
|
|
371
|
+
if (type === 'button') {
|
|
372
|
+
return /*#__PURE__*/React.createElement(RenderButtonList, Object.assign({
|
|
373
|
+
key: index
|
|
374
|
+
}, item, {
|
|
375
|
+
rowParams: rowParams
|
|
376
|
+
}));
|
|
377
|
+
}
|
|
378
|
+
/*渲染文本形式*/
|
|
379
|
+
return /*#__PURE__*/React.createElement(RenderTextList, Object.assign({
|
|
380
|
+
key: index
|
|
381
|
+
}, item));
|
|
382
|
+
};
|
|
383
|
+
if (min < 2) min = 2;
|
|
384
|
+
if (resetList.length === 0) {
|
|
385
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, type !== 'button' ? '-' : null);
|
|
386
|
+
}
|
|
387
|
+
if (resetList.length > min) {
|
|
388
|
+
var forGroup = resetList.slice(0, min - 1);
|
|
389
|
+
var forDrop = resetList.slice(min - 1);
|
|
390
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
391
|
+
className: "spec-button-group ".concat(className || ''),
|
|
392
|
+
style: style
|
|
393
|
+
}, forGroup.map(function (item, index) {
|
|
394
|
+
return index < min - 1 ? renderDisplayButton(item, index) : null;
|
|
395
|
+
}), type === 'button' ? /*#__PURE__*/React.createElement(_Dropdown, Object.assign({
|
|
396
|
+
overlay: buttonMenu(forDrop),
|
|
397
|
+
placement: "bottomRight"
|
|
398
|
+
}, dropdownConfig), /*#__PURE__*/React.createElement(_Button, {
|
|
399
|
+
type: "primary"
|
|
400
|
+
}, moreText || '更多', moreIcon || /*#__PURE__*/React.createElement(DownOutlined, null))) : /*#__PURE__*/React.createElement(_Popconfirm, Object.assign({
|
|
401
|
+
placement: "topRight",
|
|
402
|
+
visible: popVisibleIndex === rowParams.rowIndex,
|
|
403
|
+
icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null),
|
|
404
|
+
trigger: "click"
|
|
405
|
+
}, popRow.hasOwnProperty('confirmConfig') ? popRow.confirmConfig : {}, {
|
|
406
|
+
title: /*#__PURE__*/React.createElement(PopConfirmTitle, Object.assign({}, popRow, {
|
|
407
|
+
extraRow: rowParams
|
|
408
|
+
})),
|
|
409
|
+
onCancel: function onCancel() {
|
|
410
|
+
setPopVisibleIndex(-1);
|
|
411
|
+
setPopSubVisibleIndex(-1);
|
|
412
|
+
// 优先调用其 confirmConfig 配置的 onCancel 事件
|
|
413
|
+
if (popRow.hasOwnProperty('confirmConfig') && popRow.confirmConfig.onCancel) {
|
|
414
|
+
var _popRow$confirmConfig;
|
|
415
|
+
(_popRow$confirmConfig = popRow.confirmConfig).onCancel.apply(_popRow$confirmConfig, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
416
|
+
return rowParams[pItem];
|
|
417
|
+
})));
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
onConfirm: function onConfirm() {
|
|
421
|
+
setPopVisibleIndex(-1);
|
|
422
|
+
setPopSubVisibleIndex(-1);
|
|
423
|
+
// 优先调用其 confirmConfig 配置的 onConfirm 事件
|
|
424
|
+
if (popRow.hasOwnProperty('confirmConfig') && popRow.confirmConfig.onConfirm) {
|
|
425
|
+
var _popRow$confirmConfig2;
|
|
426
|
+
(_popRow$confirmConfig2 = popRow.confirmConfig).onConfirm.apply(_popRow$confirmConfig2, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
427
|
+
return rowParams[pItem];
|
|
428
|
+
})));
|
|
429
|
+
} else if (popRow.fn) {
|
|
430
|
+
popRow.fn.apply(popRow, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
431
|
+
return rowParams[pItem];
|
|
432
|
+
})));
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}), /*#__PURE__*/React.createElement(_Dropdown, Object.assign({
|
|
436
|
+
overlay: textMenu(forDrop, 'isMoreChild'),
|
|
437
|
+
placement: "bottomRight"
|
|
438
|
+
}, dropdownConfig), /*#__PURE__*/React.createElement("a", {
|
|
439
|
+
className: "spec-button-group-text"
|
|
440
|
+
}, moreText || '更多', moreIcon || /*#__PURE__*/React.createElement(DownOutlined, null)))));
|
|
441
|
+
}
|
|
442
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
443
|
+
className: "spec-button-group ".concat(className || ''),
|
|
444
|
+
style: style
|
|
445
|
+
}, resetList.map(function (item, index) {
|
|
446
|
+
return renderDisplayButton(item, index);
|
|
447
|
+
}));
|
|
448
|
+
};
|
|
449
|
+
export default ButtonGroup;
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import SpecIcon from "../../SpecIcon/index";
|
|
2
2
|
import React from "react";
|
|
3
3
|
var IconNode = function IconNode(props) {
|
|
4
|
-
var icon = props.icon
|
|
4
|
+
var icon = props.icon,
|
|
5
|
+
style = props.style;
|
|
5
6
|
if (!icon) return null;
|
|
6
7
|
if (typeof icon === 'string') {
|
|
7
8
|
var iconArr = icon.split(',');
|
|
8
9
|
return /*#__PURE__*/React.createElement(SpecIcon, {
|
|
9
10
|
prefix: iconArr.length > 1 ? iconArr[0] : 'speci',
|
|
10
11
|
noPrefix: !iconArr[0] || iconArr[0] === 'noPrefix',
|
|
11
|
-
name: iconArr.length > 1 ? iconArr[1] : icon
|
|
12
|
+
name: iconArr.length > 1 ? iconArr[1] : icon,
|
|
13
|
+
style: style
|
|
12
14
|
});
|
|
13
15
|
}
|
|
14
16
|
if (Array.isArray(icon) && icon.length > 1) {
|
|
15
17
|
// @ts-ignore
|
|
16
18
|
return /*#__PURE__*/React.createElement(SpecIcon, {
|
|
17
19
|
prefix: icon[0],
|
|
18
|
-
name: icon[1]
|
|
20
|
+
name: icon[1],
|
|
21
|
+
style: style
|
|
19
22
|
}); // 预留 Array ['speci','plus']
|
|
20
23
|
}
|
|
21
24
|
return /*#__PURE__*/React.createElement(React.Fragment, null, icon);
|
|
@@ -29,8 +29,11 @@ interface ButtonGroupProps {
|
|
|
29
29
|
dropdownConfig?: Object;
|
|
30
30
|
moreText?: string;
|
|
31
31
|
moreIcon?: React.ReactNode | string | number;
|
|
32
|
+
size?: any;
|
|
33
|
+
showTextIcon?: boolean;
|
|
32
34
|
className?: string;
|
|
33
35
|
style?: object;
|
|
36
|
+
[k: string]: any;
|
|
34
37
|
}
|
|
35
38
|
declare const ButtonGroup: (props: ButtonGroupProps) => React.JSX.Element;
|
|
36
39
|
export default ButtonGroup;
|