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