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
|
@@ -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;
|
package/es/ButtonGroup/index.js
CHANGED
|
@@ -17,13 +17,14 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
17
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
18
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
19
19
|
import { __rest } from "tslib";
|
|
20
|
-
import React, { useState, useEffect } from "react";
|
|
20
|
+
import React, { useState, useEffect, Fragment } from "react";
|
|
21
21
|
import { IconNode } from "../components/index";
|
|
22
22
|
import SpecIcon from "../SpecIcon/index";
|
|
23
23
|
import PopConfirmTitle from './PopConfirmTitle';
|
|
24
24
|
import { funcCode } from "../data/index";
|
|
25
25
|
import { DownOutlined, QuestionCircleOutlined } from "@ant-design/icons";
|
|
26
26
|
import { removeNoPermission, btnIsDisabled } from '../utils/filterPermission.js';
|
|
27
|
+
import { convertToArray } from '../utils/index';
|
|
27
28
|
import _ from 'lodash';
|
|
28
29
|
import './style/index.less';
|
|
29
30
|
var ButtonGroup = function ButtonGroup(props) {
|
|
@@ -42,6 +43,8 @@ var ButtonGroup = function ButtonGroup(props) {
|
|
|
42
43
|
_props$moreText = props.moreText,
|
|
43
44
|
moreText = _props$moreText === void 0 ? '更多' : _props$moreText,
|
|
44
45
|
moreIcon = props.moreIcon,
|
|
46
|
+
_props$showTextIcon = props.showTextIcon,
|
|
47
|
+
showTextIcon = _props$showTextIcon === void 0 ? false : _props$showTextIcon,
|
|
45
48
|
className = props.className,
|
|
46
49
|
style = props.style;
|
|
47
50
|
var _props$options = props.options,
|
|
@@ -57,10 +60,18 @@ var ButtonGroup = function ButtonGroup(props) {
|
|
|
57
60
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
58
61
|
popRow = _useState4[0],
|
|
59
62
|
setPopRow = _useState4[1];
|
|
60
|
-
var _useState5 = useState(
|
|
63
|
+
var _useState5 = useState(-1),
|
|
61
64
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
62
|
-
|
|
63
|
-
|
|
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];
|
|
64
75
|
useEffect(function () {
|
|
65
76
|
// codes在方法内,再合并默认的权限配置
|
|
66
77
|
// 合并本地的codes
|
|
@@ -73,6 +84,7 @@ var ButtonGroup = function ButtonGroup(props) {
|
|
|
73
84
|
}, [options, codes, permissionCodes]);
|
|
74
85
|
useEffect(function () {
|
|
75
86
|
setPopVisibleIndex(-1);
|
|
87
|
+
setPopSubVisibleIndex(-1);
|
|
76
88
|
}, [rowParams]);
|
|
77
89
|
// 渲染按钮多层级形式 (用于筛选)
|
|
78
90
|
var buttonMenu = function buttonMenu(group) {
|
|
@@ -174,8 +186,41 @@ var ButtonGroup = function ButtonGroup(props) {
|
|
|
174
186
|
}
|
|
175
187
|
})
|
|
176
188
|
}*/
|
|
189
|
+
// 自定义渲染显示的文本
|
|
190
|
+
var renderCustomLabel = function renderCustomLabel(gItem, hideIcon) {
|
|
191
|
+
return gItem.render ? gItem.render.apply(gItem, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
192
|
+
return rowParams[pItem];
|
|
193
|
+
}))) : (/*#__PURE__*/React.createElement(React.Fragment, null, !hideIcon && gItem.icon && showTextIcon ? /*#__PURE__*/React.createElement(IconNode, {
|
|
194
|
+
icon: gItem.icon
|
|
195
|
+
}) : '', " ", gItem.exName || gItem.name));
|
|
196
|
+
};
|
|
177
197
|
// 渲染文本形式多级菜单列表(用于表格)
|
|
178
|
-
var textMenu = function textMenu(group) {
|
|
198
|
+
var textMenu = function textMenu(group, source) {
|
|
199
|
+
var menuTitle = function menuTitle(gItem, displayClass) {
|
|
200
|
+
return gItem.hasOwnProperty('confirmText') || gItem.hasOwnProperty('confirmConfig') ?
|
|
201
|
+
/*#__PURE__*/
|
|
202
|
+
// @ts-ignore
|
|
203
|
+
React.createElement("a", {
|
|
204
|
+
disabled: btnIsDisabled(gItem.disabled, rowParams),
|
|
205
|
+
onClick: gItem.fn ? function () {
|
|
206
|
+
// console.log('带二次确认节点点击区分处理更多里面还是直接展示里面的按钮')
|
|
207
|
+
setPopVisibleIndex(source === 'isMoreChild' ? rowParams.rowIndex : -1);
|
|
208
|
+
setPopRow(source === 'isMoreChild' ? gItem : {});
|
|
209
|
+
setPopSubVisibleIndex(source === 'isMoreChild' ? -1 : rowParams.rowIndex);
|
|
210
|
+
setPopSubRow(source === 'isMoreChild' ? {} : gItem);
|
|
211
|
+
} : null
|
|
212
|
+
}, renderCustomLabel(gItem)) : /*#__PURE__*/React.createElement("a", {
|
|
213
|
+
className: displayClass,
|
|
214
|
+
// className={"spec-button-group-text" }
|
|
215
|
+
onClick: gItem.fn ? function () {
|
|
216
|
+
return gItem.fn.apply(gItem, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
217
|
+
return rowParams[pItem];
|
|
218
|
+
})));
|
|
219
|
+
} : null,
|
|
220
|
+
// @ts-ignore
|
|
221
|
+
disabled: btnIsDisabled(gItem.disabled, rowParams)
|
|
222
|
+
}, renderCustomLabel(gItem));
|
|
223
|
+
};
|
|
179
224
|
return /*#__PURE__*/React.createElement(_Menu, {
|
|
180
225
|
className: "spec-button-text-dropdown"
|
|
181
226
|
}, group.map(function (gItem, gIndex) {
|
|
@@ -186,48 +231,71 @@ var ButtonGroup = function ButtonGroup(props) {
|
|
|
186
231
|
}, gItem.children.map(function (child, childIndex) {
|
|
187
232
|
return /*#__PURE__*/React.createElement(_Menu.Item, {
|
|
188
233
|
key: child.name + childIndex
|
|
189
|
-
},
|
|
190
|
-
onClick: child.fn ? function () {
|
|
191
|
-
return child.fn.apply(child, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
192
|
-
return rowParams[pItem];
|
|
193
|
-
})));
|
|
194
|
-
} : null
|
|
195
|
-
}, child.render ? child.render.apply(child, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
196
|
-
return rowParams[pItem];
|
|
197
|
-
}))) : child.exName || child.name));
|
|
234
|
+
}, menuTitle(child));
|
|
198
235
|
}));
|
|
199
236
|
}
|
|
200
237
|
return /*#__PURE__*/React.createElement(_Menu.Item, {
|
|
201
238
|
key: gIndex,
|
|
202
239
|
disabled: btnIsDisabled(gItem.disabled, rowParams)
|
|
203
|
-
}, gItem
|
|
204
|
-
/*#__PURE__*/
|
|
205
|
-
// @ts-ignore
|
|
206
|
-
React.createElement("a", {
|
|
207
|
-
disabled: btnIsDisabled(gItem.disabled, rowParams),
|
|
208
|
-
onClick: gItem.fn ? function () {
|
|
209
|
-
setPopVisibleIndex(rowParams.rowIndex);
|
|
210
|
-
setPopRow(gItem);
|
|
211
|
-
} : null
|
|
212
|
-
}, gItem.render ? gItem.render.apply(gItem, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
213
|
-
return rowParams[pItem];
|
|
214
|
-
}))) : gItem.exName || gItem.name) : /*#__PURE__*/React.createElement("a", {
|
|
215
|
-
className: "spec-button-group-text",
|
|
216
|
-
onClick: gItem.fn ? function () {
|
|
217
|
-
return gItem.fn.apply(gItem, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
218
|
-
return rowParams[pItem];
|
|
219
|
-
})));
|
|
220
|
-
} : null,
|
|
221
|
-
// @ts-ignore
|
|
222
|
-
disabled: btnIsDisabled(gItem.disabled, rowParams)
|
|
223
|
-
}, gItem.render ? gItem.render.apply(gItem, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
224
|
-
return rowParams[pItem];
|
|
225
|
-
}))) : gItem.exName || gItem.name));
|
|
240
|
+
}, menuTitle(gItem, "spec-button-group-text"));
|
|
226
241
|
}));
|
|
227
242
|
};
|
|
228
243
|
// 渲染文本形式 列表(用于表格)
|
|
229
244
|
var RenderTextList = function RenderTextList(item) {
|
|
230
245
|
if (Array.isArray(item.children) && item.children.length > 0) {
|
|
246
|
+
var hasConfirmText = [];
|
|
247
|
+
item.children.forEach(function (child) {
|
|
248
|
+
hasConfirmText = hasConfirmText.concat(convertToArray([child]));
|
|
249
|
+
});
|
|
250
|
+
if (hasConfirmText.filter(function (hcItem) {
|
|
251
|
+
return hcItem.hasOwnProperty('confirmText') || hcItem.hasOwnProperty('confirmConfig');
|
|
252
|
+
}).length) {
|
|
253
|
+
// 子项有二次确认文本,需要显示浮层
|
|
254
|
+
return /*#__PURE__*/React.createElement(_Popconfirm, Object.assign({
|
|
255
|
+
key: (item === null || item === void 0 ? void 0 : item.index) || JSON.stringify(item),
|
|
256
|
+
placement: "topRight",
|
|
257
|
+
open: popSubVisibleIndex === rowParams.rowIndex,
|
|
258
|
+
icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null),
|
|
259
|
+
trigger: "click"
|
|
260
|
+
}, popSubRow.hasOwnProperty('confirmConfig') ? popSubRow.confirmConfig : {}, {
|
|
261
|
+
title: /*#__PURE__*/React.createElement(PopConfirmTitle, Object.assign({}, popSubRow, {
|
|
262
|
+
extraRow: rowParams
|
|
263
|
+
})),
|
|
264
|
+
onCancel: function onCancel() {
|
|
265
|
+
setPopSubVisibleIndex(-1);
|
|
266
|
+
// 优先调用其 confirmConfig 配置的 onCancel 事件
|
|
267
|
+
if (popSubRow.hasOwnProperty('confirmConfig') && popSubRow.confirmConfig.onCancel) {
|
|
268
|
+
var _popSubRow$confirmCon;
|
|
269
|
+
(_popSubRow$confirmCon = popSubRow.confirmConfig).onCancel.apply(_popSubRow$confirmCon, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
270
|
+
return rowParams[pItem];
|
|
271
|
+
})));
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
onConfirm: function onConfirm() {
|
|
275
|
+
setPopSubVisibleIndex(-1);
|
|
276
|
+
// 优先调用其 confirmConfig 配置的 onConfirm 事件
|
|
277
|
+
if (popSubRow.hasOwnProperty('confirmConfig') && popSubRow.confirmConfig.onConfirm) {
|
|
278
|
+
var _popSubRow$confirmCon2;
|
|
279
|
+
(_popSubRow$confirmCon2 = popSubRow.confirmConfig).onConfirm.apply(_popSubRow$confirmCon2, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
280
|
+
return rowParams[pItem];
|
|
281
|
+
})));
|
|
282
|
+
} else if (popSubRow.fn) {
|
|
283
|
+
popSubRow.fn.apply(popSubRow, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
284
|
+
return rowParams[pItem];
|
|
285
|
+
})));
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}), /*#__PURE__*/React.createElement(_Dropdown, Object.assign({
|
|
289
|
+
overlay: textMenu(item.children),
|
|
290
|
+
placement: "bottomRight"
|
|
291
|
+
}, (item === null || item === void 0 ? void 0 : item.dropdownConfig) || dropdownConfig || {}), /*#__PURE__*/React.createElement("a", {
|
|
292
|
+
className: "spec-button-group-text"
|
|
293
|
+
}, item.render ? item.render.apply(item, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
294
|
+
return rowParams[pItem];
|
|
295
|
+
}))) : item.exName || item.name, " ", /*#__PURE__*/React.createElement(SpecIcon, {
|
|
296
|
+
name: "down"
|
|
297
|
+
}))));
|
|
298
|
+
}
|
|
231
299
|
return /*#__PURE__*/React.createElement(_Dropdown, Object.assign({
|
|
232
300
|
overlay: textMenu(item.children),
|
|
233
301
|
placement: "bottomRight"
|
|
@@ -293,7 +361,9 @@ var ButtonGroup = function ButtonGroup(props) {
|
|
|
293
361
|
var renderDisplayButton = function renderDisplayButton(item, index) {
|
|
294
362
|
/*渲染自定义*/
|
|
295
363
|
if (item.render) {
|
|
296
|
-
return /*#__PURE__*/React.createElement(
|
|
364
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
365
|
+
key: index
|
|
366
|
+
}, typeof item.render === 'function' ? item.render.apply(item, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
|
|
297
367
|
return rowParams[pItem];
|
|
298
368
|
}))) : item.render);
|
|
299
369
|
}
|
|
@@ -329,7 +399,7 @@ var ButtonGroup = function ButtonGroup(props) {
|
|
|
329
399
|
type: "primary"
|
|
330
400
|
}, moreText || '更多', moreIcon || /*#__PURE__*/React.createElement(DownOutlined, null))) : /*#__PURE__*/React.createElement(_Popconfirm, Object.assign({
|
|
331
401
|
placement: "topRight",
|
|
332
|
-
|
|
402
|
+
open: popVisibleIndex === rowParams.rowIndex,
|
|
333
403
|
icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null),
|
|
334
404
|
trigger: "click"
|
|
335
405
|
}, popRow.hasOwnProperty('confirmConfig') ? popRow.confirmConfig : {}, {
|
|
@@ -338,6 +408,7 @@ var ButtonGroup = function ButtonGroup(props) {
|
|
|
338
408
|
})),
|
|
339
409
|
onCancel: function onCancel() {
|
|
340
410
|
setPopVisibleIndex(-1);
|
|
411
|
+
setPopSubVisibleIndex(-1);
|
|
341
412
|
// 优先调用其 confirmConfig 配置的 onCancel 事件
|
|
342
413
|
if (popRow.hasOwnProperty('confirmConfig') && popRow.confirmConfig.onCancel) {
|
|
343
414
|
var _popRow$confirmConfig;
|
|
@@ -348,6 +419,7 @@ var ButtonGroup = function ButtonGroup(props) {
|
|
|
348
419
|
},
|
|
349
420
|
onConfirm: function onConfirm() {
|
|
350
421
|
setPopVisibleIndex(-1);
|
|
422
|
+
setPopSubVisibleIndex(-1);
|
|
351
423
|
// 优先调用其 confirmConfig 配置的 onConfirm 事件
|
|
352
424
|
if (popRow.hasOwnProperty('confirmConfig') && popRow.confirmConfig.onConfirm) {
|
|
353
425
|
var _popRow$confirmConfig2;
|
|
@@ -361,7 +433,7 @@ var ButtonGroup = function ButtonGroup(props) {
|
|
|
361
433
|
}
|
|
362
434
|
}
|
|
363
435
|
}), /*#__PURE__*/React.createElement(_Dropdown, Object.assign({
|
|
364
|
-
overlay: textMenu(forDrop),
|
|
436
|
+
overlay: textMenu(forDrop, 'isMoreChild'),
|
|
365
437
|
placement: "bottomRight"
|
|
366
438
|
}, dropdownConfig), /*#__PURE__*/React.createElement("a", {
|
|
367
439
|
className: "spec-button-group-text"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import './style/index.less';
|
|
3
|
+
interface ButtonGroupRowParamsProps {
|
|
4
|
+
text?: any;
|
|
5
|
+
record?: object;
|
|
6
|
+
rowIndex?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ButtonGroupOptionsProps {
|
|
9
|
+
name?: string;
|
|
10
|
+
code?: string;
|
|
11
|
+
exName?: string;
|
|
12
|
+
isHide?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
icon?: React.ReactNode | string | string[];
|
|
15
|
+
fn?: any;
|
|
16
|
+
children?: ButtonGroupOptionsProps[];
|
|
17
|
+
render?: (() => React.ReactNode) | React.ReactNode;
|
|
18
|
+
confirmText?: any;
|
|
19
|
+
confirmConfig?: any;
|
|
20
|
+
dropdownConfig?: any;
|
|
21
|
+
}
|
|
22
|
+
interface ButtonGroupProps {
|
|
23
|
+
type?: 'button' | 'text';
|
|
24
|
+
rowParams?: ButtonGroupRowParamsProps;
|
|
25
|
+
codes?: object[];
|
|
26
|
+
permissionCodes?: string[];
|
|
27
|
+
options?: ButtonGroupOptionsProps[];
|
|
28
|
+
min?: number;
|
|
29
|
+
dropdownConfig?: Object;
|
|
30
|
+
moreText?: string;
|
|
31
|
+
moreIcon?: React.ReactNode | string | number;
|
|
32
|
+
size?: any;
|
|
33
|
+
showTextIcon?: boolean;
|
|
34
|
+
className?: string;
|
|
35
|
+
style?: object;
|
|
36
|
+
[k: string]: any;
|
|
37
|
+
}
|
|
38
|
+
declare const ButtonGroup: (props: ButtonGroupProps) => React.JSX.Element;
|
|
39
|
+
export default ButtonGroup;
|