@zat-design/sisyphus-react 3.4.4 → 3.4.5
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/babel.config.js +3 -0
- package/es/ProEditTable/components/RenderField/index.js +3 -2
- package/es/ProEditTable/index.js +13 -2
- package/es/ProEditTable/propsType.d.ts +1 -0
- package/es/ProEditTable/utils/index.js +7 -1
- package/es/ProEnum/components/Group.js +7 -1
- package/es/ProEnum/style/index.less +3 -2
- package/es/ProForm/components/combination/FormList/index.js +5 -5
- package/es/ProForm/components/combination/GroupCopy/component/ComRender.d.ts +14 -0
- package/es/ProForm/components/combination/GroupCopy/component/ComRender.js +36 -0
- package/es/ProForm/components/combination/GroupCopy/index.d.ts +10 -0
- package/es/ProForm/components/combination/GroupCopy/index.js +84 -0
- package/es/ProForm/components/combination/GroupCopy/propsType.d.ts +47 -0
- package/es/ProForm/components/combination/GroupCopy/propsType.js +1 -0
- package/es/ProForm/components/combination/GroupCopy/style/index.less +131 -0
- package/es/ProForm/components/combination/GroupCopy/utils.d.ts +53 -0
- package/es/ProForm/components/combination/GroupCopy/utils.js +180 -0
- package/es/ProForm/components/combination/ProModalSelect/index.js +22 -18
- package/es/ProForm/components/index.js +1 -0
- package/es/ProForm/components/render/Render.js +2 -2
- package/es/ProForm/components/render/propsType.d.ts +1 -1
- package/es/ProIcon/config/index.d.ts +12 -0
- package/es/ProIcon/config/index.js +15 -1
- package/es/ProIcon/index.js +97 -19
- package/es/ProIcon/propsTypes.d.ts +19 -0
- package/es/ProIcon/utils/index.d.ts +1 -0
- package/es/ProIcon/utils/index.js +23 -0
- package/es/ProThemeTools/component/PrdTools/index.js +16 -0
- package/es/ProTreeModal/index.js +11 -15
- package/es/ProWaterMark/__snapshots__/index.test.tsx.snap +7 -0
- package/es/global.less +38 -2
- package/jest.config.js +8 -0
- package/lib/ProEditTable/components/RenderField/index.js +3 -2
- package/lib/ProEditTable/index.js +13 -2
- package/lib/ProEditTable/propsType.d.ts +1 -0
- package/lib/ProEditTable/utils/index.js +7 -1
- package/lib/ProEnum/components/Group.js +6 -0
- package/lib/ProEnum/style/index.less +3 -2
- package/lib/ProForm/components/combination/FormList/index.js +5 -5
- package/lib/ProForm/components/combination/GroupCopy/component/ComRender.d.ts +14 -0
- package/lib/ProForm/components/combination/GroupCopy/component/ComRender.js +44 -0
- package/lib/ProForm/components/combination/GroupCopy/index.d.ts +10 -0
- package/lib/ProForm/components/combination/GroupCopy/index.js +91 -0
- package/lib/ProForm/components/combination/GroupCopy/propsType.d.ts +47 -0
- package/lib/ProForm/components/combination/GroupCopy/propsType.js +5 -0
- package/lib/ProForm/components/combination/GroupCopy/style/index.less +131 -0
- package/lib/ProForm/components/combination/GroupCopy/utils.d.ts +53 -0
- package/lib/ProForm/components/combination/GroupCopy/utils.js +187 -0
- package/lib/ProForm/components/combination/ProModalSelect/index.js +23 -19
- package/lib/ProForm/components/render/Render.js +2 -2
- package/lib/ProForm/components/render/propsType.d.ts +1 -1
- package/lib/ProIcon/config/index.d.ts +12 -0
- package/lib/ProIcon/config/index.js +16 -2
- package/lib/ProIcon/index.js +94 -18
- package/lib/ProIcon/propsTypes.d.ts +19 -0
- package/lib/ProIcon/utils/index.d.ts +1 -0
- package/lib/ProIcon/utils/index.js +29 -0
- package/lib/ProThemeTools/component/PrdTools/index.js +16 -0
- package/lib/ProTreeModal/index.js +11 -15
- package/lib/ProWaterMark/__snapshots__/index.test.tsx.snap +7 -0
- package/lib/global.less +38 -2
- package/package.json +6 -2
- package/test/__mocks__/fileMock.js +0 -0
- package/test/__mocks__/styleMock.js +0 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
|
+
import "antd/es/button/style";
|
|
4
|
+
import _Button from "antd/es/button";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
import { isFunction } from 'lodash';
|
|
7
|
+
import valueTypeMap from '../../../utils/valueType';
|
|
8
|
+
/**
|
|
9
|
+
* 插入间隔符
|
|
10
|
+
* @param columns 表单配置数组
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export var insertSeparator = function insertSeparator(columns, space) {
|
|
14
|
+
if (!(space === null || space === void 0 ? void 0 : space.separator)) {
|
|
15
|
+
return columns;
|
|
16
|
+
}
|
|
17
|
+
return columns.reduce(function (result, current, index, array) {
|
|
18
|
+
// 将当前元素添加到结果数组中
|
|
19
|
+
result.push(current);
|
|
20
|
+
// 如果当前元素不是最后一个元素,则添加间隔符
|
|
21
|
+
if (index < array.length - 1) {
|
|
22
|
+
result.push({
|
|
23
|
+
component: _jsx(_Button, {
|
|
24
|
+
className: "group-separator",
|
|
25
|
+
children: space.separator
|
|
26
|
+
}),
|
|
27
|
+
fieldProps: {
|
|
28
|
+
disabled: true
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}, []);
|
|
34
|
+
};
|
|
35
|
+
/** 带出event的组件默认取值方法 */
|
|
36
|
+
export function defaultGetValueFromEvent(valuePropName) {
|
|
37
|
+
var event = arguments.length <= 1 ? undefined : arguments[1];
|
|
38
|
+
if (event && event.target && _typeof(event.target) === 'object' && valuePropName in event.target) {
|
|
39
|
+
return event.target[valuePropName];
|
|
40
|
+
}
|
|
41
|
+
return event;
|
|
42
|
+
}
|
|
43
|
+
/** 转换names */
|
|
44
|
+
export var transformNamesString = function transformNamesString(arr) {
|
|
45
|
+
var result = arr.map(function (subArr) {
|
|
46
|
+
if (Array.isArray(subArr)) {
|
|
47
|
+
return subArr.join('_');
|
|
48
|
+
}
|
|
49
|
+
return subArr;
|
|
50
|
+
});
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
/** 计算响应式参数的值 */
|
|
54
|
+
export var getReactiveProps = function getReactiveProps(params) {
|
|
55
|
+
var form = params.form,
|
|
56
|
+
index = params.index,
|
|
57
|
+
namePath = params.namePath,
|
|
58
|
+
disabled = params.disabled,
|
|
59
|
+
show = params.show,
|
|
60
|
+
component = params.component,
|
|
61
|
+
fieldProps = params.fieldProps,
|
|
62
|
+
name = params.name;
|
|
63
|
+
var values = form.getFieldsValue(namePath || undefined);
|
|
64
|
+
var _disabled = isFunction(disabled) ? disabled(values, {
|
|
65
|
+
form: form,
|
|
66
|
+
index: index,
|
|
67
|
+
namePath: namePath
|
|
68
|
+
}) : disabled;
|
|
69
|
+
var _show = isFunction(show) ? show(values, {
|
|
70
|
+
form: form,
|
|
71
|
+
index: index,
|
|
72
|
+
namePath: namePath
|
|
73
|
+
}) : show;
|
|
74
|
+
var _component = isFunction(component) ? component(values, {
|
|
75
|
+
form: form,
|
|
76
|
+
index: index,
|
|
77
|
+
namePath: namePath
|
|
78
|
+
}) : component;
|
|
79
|
+
var _fieldProps = isFunction(fieldProps) ? fieldProps(values, {
|
|
80
|
+
form: form,
|
|
81
|
+
index: index,
|
|
82
|
+
namePath: namePath
|
|
83
|
+
}) : fieldProps;
|
|
84
|
+
return {
|
|
85
|
+
disabled: _disabled,
|
|
86
|
+
show: _show,
|
|
87
|
+
component: _component,
|
|
88
|
+
fieldProps: _fieldProps
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
/** 获取当前字段的转换函数 */
|
|
92
|
+
export var getValueTypeTrans = function getValueTypeTrans(params) {
|
|
93
|
+
var _valueTypeMap$valueTy;
|
|
94
|
+
var valueType = params.valueType;
|
|
95
|
+
var transform = (_valueTypeMap$valueTy = valueTypeMap[valueType]) === null || _valueTypeMap$valueTy === void 0 ? void 0 : _valueTypeMap$valueTy.call(valueTypeMap, params);
|
|
96
|
+
return transform;
|
|
97
|
+
};
|
|
98
|
+
/** 转换columns */
|
|
99
|
+
export var transformColumns = function transformColumns(params) {
|
|
100
|
+
var form = params.form,
|
|
101
|
+
columns = params.columns,
|
|
102
|
+
name = params.name,
|
|
103
|
+
names = params.names,
|
|
104
|
+
outerIndex = params.index,
|
|
105
|
+
namePath = params.namePath,
|
|
106
|
+
value = params.value,
|
|
107
|
+
internalChange = params.onChange;
|
|
108
|
+
return columns === null || columns === void 0 ? void 0 : columns.flatMap(function (column, index) {
|
|
109
|
+
var type = column.type,
|
|
110
|
+
valueType = column.valueType,
|
|
111
|
+
switchValue = column.switchValue,
|
|
112
|
+
toISOString = column.toISOString,
|
|
113
|
+
fieldProps = column.fieldProps,
|
|
114
|
+
getValueFromEvent = column.getValueFromEvent,
|
|
115
|
+
_column$valuePropName = column.valuePropName,
|
|
116
|
+
valuePropName = _column$valuePropName === void 0 ? 'value' : _column$valuePropName,
|
|
117
|
+
normalize = column.normalize,
|
|
118
|
+
disabled = column.disabled,
|
|
119
|
+
show = column.show,
|
|
120
|
+
component = column.component;
|
|
121
|
+
var _ref = fieldProps || {},
|
|
122
|
+
mode = _ref.mode,
|
|
123
|
+
onChange = _ref.onChange,
|
|
124
|
+
onFieldChange = _ref.onFieldChange,
|
|
125
|
+
comDisabled = _ref.disabled;
|
|
126
|
+
var _disabled = disabled !== null && disabled !== void 0 ? disabled : comDisabled;
|
|
127
|
+
var columnName = names ? names[index] : [].concat(name, index);
|
|
128
|
+
// 响应式字段
|
|
129
|
+
var reactiveProps = getReactiveProps({
|
|
130
|
+
form: form,
|
|
131
|
+
index: index,
|
|
132
|
+
type: type,
|
|
133
|
+
namePath: namePath,
|
|
134
|
+
disabled: _disabled,
|
|
135
|
+
show: show,
|
|
136
|
+
component: component,
|
|
137
|
+
fieldProps: fieldProps,
|
|
138
|
+
name: columnName
|
|
139
|
+
});
|
|
140
|
+
if (reactiveProps.show === false) return [];
|
|
141
|
+
var transform = getValueTypeTrans({
|
|
142
|
+
type: type,
|
|
143
|
+
valueType: valueType,
|
|
144
|
+
switchValue: switchValue,
|
|
145
|
+
toISOString: toISOString,
|
|
146
|
+
mode: mode
|
|
147
|
+
});
|
|
148
|
+
var newValue;
|
|
149
|
+
var handleChange = function handleChange() {
|
|
150
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
151
|
+
args[_key] = arguments[_key];
|
|
152
|
+
}
|
|
153
|
+
if (getValueFromEvent) {
|
|
154
|
+
newValue = getValueFromEvent.apply(void 0, args);
|
|
155
|
+
} else {
|
|
156
|
+
newValue = defaultGetValueFromEvent.apply(void 0, [valuePropName].concat(args));
|
|
157
|
+
}
|
|
158
|
+
if ((transform === null || transform === void 0 ? void 0 : transform.normalize) || normalize) {
|
|
159
|
+
var _transform$normalize;
|
|
160
|
+
// @ts-ignore
|
|
161
|
+
newValue = ((_transform$normalize = transform.normalize) === null || _transform$normalize === void 0 ? void 0 : _transform$normalize.call(transform, newValue)) || (normalize === null || normalize === void 0 ? void 0 : normalize(newValue));
|
|
162
|
+
}
|
|
163
|
+
internalChange === null || internalChange === void 0 ? void 0 : internalChange(newValue, args[1], index);
|
|
164
|
+
onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, args);
|
|
165
|
+
onFieldChange === null || onFieldChange === void 0 ? void 0 : onFieldChange(newValue, form.getFieldValue(namePath), {
|
|
166
|
+
index: outerIndex,
|
|
167
|
+
namePath: namePath,
|
|
168
|
+
form: form
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
return _objectSpread(_objectSpread(_objectSpread({}, column), {}, {
|
|
172
|
+
name: columnName
|
|
173
|
+
}, reactiveProps), {}, {
|
|
174
|
+
fieldProps: _objectSpread(_objectSpread({}, column === null || column === void 0 ? void 0 : column.fieldProps), {}, {
|
|
175
|
+
onChange: handleChange,
|
|
176
|
+
value: value === null || value === void 0 ? void 0 : value[index]
|
|
177
|
+
})
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
};
|
|
@@ -22,7 +22,6 @@ var _excluded = ["value", "onChange", "disabled", "labelInValue", "fieldNames",
|
|
|
22
22
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
23
23
|
import { SearchOutlined } from '@ant-design/icons';
|
|
24
24
|
import { useMount, useSetState } from 'ahooks';
|
|
25
|
-
import { useRequest as useUmiRequest } from 'umi';
|
|
26
25
|
import { cloneDeep, debounce, isArray, isEqual, isFunction, omit } from 'lodash';
|
|
27
26
|
import { ReactSVG } from 'react-svg';
|
|
28
27
|
import React, { forwardRef, useEffect, useImperativeHandle, useMemo } from 'react';
|
|
@@ -127,17 +126,22 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
127
126
|
form = _Form$useForm2[0];
|
|
128
127
|
var selectedRows = (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.selectedRows) || _selectedRows;
|
|
129
128
|
var selectedRowKeys = (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.selectedRowKeys) || _selectedRowKeys;
|
|
130
|
-
var
|
|
129
|
+
var _useRequestList = useRequestList(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, {
|
|
130
|
+
withPagination: withPagination,
|
|
131
|
+
transformParams: transformParams,
|
|
132
|
+
transformResponse: transformResponse
|
|
133
|
+
}, _objectSpread(_objectSpread({}, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options), {}, {
|
|
131
134
|
manual: true,
|
|
132
|
-
onSuccess: function onSuccess(
|
|
133
|
-
var
|
|
135
|
+
onSuccess: function onSuccess(res) {
|
|
136
|
+
var _res$data;
|
|
137
|
+
var list = withPagination ? res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.list : res === null || res === void 0 ? void 0 : res.data;
|
|
134
138
|
setState({
|
|
135
139
|
options: list
|
|
136
140
|
});
|
|
137
141
|
}
|
|
138
142
|
})),
|
|
139
|
-
run =
|
|
140
|
-
var
|
|
143
|
+
run = _useRequestList.run;
|
|
144
|
+
var _useRequestList2 = useRequestList(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, {
|
|
141
145
|
withPagination: withPagination,
|
|
142
146
|
transformParams: transformParams,
|
|
143
147
|
transformResponse: transformResponse
|
|
@@ -145,13 +149,13 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
145
149
|
manual: true,
|
|
146
150
|
ready: ((useRequest === null || useRequest === void 0 ? void 0 : useRequest.initParams) || defaultOne) && !readOnly || visible
|
|
147
151
|
}, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options)),
|
|
148
|
-
data =
|
|
149
|
-
loading =
|
|
150
|
-
pagination =
|
|
151
|
-
onSearch =
|
|
152
|
-
onReset =
|
|
153
|
-
runAsync =
|
|
154
|
-
mutate =
|
|
152
|
+
data = _useRequestList2.data,
|
|
153
|
+
loading = _useRequestList2.loading,
|
|
154
|
+
pagination = _useRequestList2.pagination,
|
|
155
|
+
onSearch = _useRequestList2.onSearch,
|
|
156
|
+
onReset = _useRequestList2.onReset,
|
|
157
|
+
runAsync = _useRequestList2.runAsync,
|
|
158
|
+
mutate = _useRequestList2.mutate;
|
|
155
159
|
var defaultOptionRender = function defaultOptionRender(rowData) {
|
|
156
160
|
return rowData === null || rowData === void 0 ? void 0 : rowData[labelKey];
|
|
157
161
|
};
|
|
@@ -423,7 +427,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
423
427
|
// 初始化回显,当传入initParams时,前端用来回险
|
|
424
428
|
var getInitValues = /*#__PURE__*/function () {
|
|
425
429
|
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
426
|
-
var _contentForm$getField, _useRequest$options2, _useRequest$options3, queryBean, page, params, res, _list, list, _res$
|
|
430
|
+
var _contentForm$getField, _useRequest$options2, _useRequest$options3, queryBean, page, params, res, _list, list, _res$data2, _data2, nextSelectRowKeys;
|
|
427
431
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
428
432
|
while (1) switch (_context4.prev = _context4.next) {
|
|
429
433
|
case 0:
|
|
@@ -452,7 +456,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
452
456
|
if (transformResponse) {
|
|
453
457
|
list = transformResponse(res === null || res === void 0 ? void 0 : res.data);
|
|
454
458
|
} else {
|
|
455
|
-
list = withPagination ? res === null || res === void 0 ? void 0 : (_res$
|
|
459
|
+
list = withPagination ? res === null || res === void 0 ? void 0 : (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.list : res === null || res === void 0 ? void 0 : res.data;
|
|
456
460
|
}
|
|
457
461
|
_data2 = isMultiple ? list : (_list = list) === null || _list === void 0 ? void 0 : _list[0];
|
|
458
462
|
if (_data2) {
|
|
@@ -489,7 +493,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
489
493
|
var getDefaultOneValues = /*#__PURE__*/function () {
|
|
490
494
|
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
491
495
|
var _useRequest$options4, _useRequest$options5;
|
|
492
|
-
var queryBean, page, params, res, _list2, list, _res$
|
|
496
|
+
var queryBean, page, params, res, _list2, list, _res$data3, _data3, nextSelectRowKeys;
|
|
493
497
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
494
498
|
while (1) switch (_context5.prev = _context5.next) {
|
|
495
499
|
case 0:
|
|
@@ -511,7 +515,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
511
515
|
if (transformResponse) {
|
|
512
516
|
list = transformResponse(res === null || res === void 0 ? void 0 : res.data);
|
|
513
517
|
} else {
|
|
514
|
-
list = withPagination ? res === null || res === void 0 ? void 0 : (_res$
|
|
518
|
+
list = withPagination ? res === null || res === void 0 ? void 0 : (_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.list : res === null || res === void 0 ? void 0 : res.data;
|
|
515
519
|
}
|
|
516
520
|
_data3 = isMultiple ? list : (_list2 = list) === null || _list2 === void 0 ? void 0 : _list2[0];
|
|
517
521
|
nextSelectRowKeys = isMultiple ? value : [value];
|
|
@@ -670,7 +674,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
670
674
|
// 没有值的时候,初始化点击默认查询前五十条
|
|
671
675
|
if (!value && isInit || !(options === null || options === void 0 ? void 0 : options.length)) {
|
|
672
676
|
var _useRequest$options9;
|
|
673
|
-
var queryBean = useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options9 = useRequest.options) === null || _useRequest$options9 === void 0 ? void 0 : _useRequest$options9.defaultParams;
|
|
677
|
+
var queryBean = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options9 = useRequest.options) === null || _useRequest$options9 === void 0 ? void 0 : _useRequest$options9.defaultParams) || {};
|
|
674
678
|
var params = withPagination ? {
|
|
675
679
|
pageNum: 1,
|
|
676
680
|
pageSize: 50,
|
|
@@ -21,6 +21,7 @@ export { default as ProModalSelect } from './combination/ProModalSelect';
|
|
|
21
21
|
export { default as ProTimeLimit } from './combination/ProTimeLimit';
|
|
22
22
|
export { default as ProRangeLimit } from './combination/ProRangeLimit';
|
|
23
23
|
export { default as Group } from './combination/Group';
|
|
24
|
+
// export { default as GroupCopy } from './combination/GroupCopy';
|
|
24
25
|
export { default as ProCollapse } from './combination/Container';
|
|
25
26
|
export { default as Container } from './combination/Container';
|
|
26
27
|
export { default as ProEnum } from '../../ProEnum';
|
|
@@ -155,9 +155,9 @@ var Render = function Render(props) {
|
|
|
155
155
|
Object.assign(otherFormItemProps, transforms, {
|
|
156
156
|
names: otherProps.names
|
|
157
157
|
}, internalRule, {
|
|
158
|
-
required: typeof labelRequired === 'boolean' ? labelRequired : _required || (rules === null || rules === void 0 ? void 0 : rules.some(function (item) {
|
|
158
|
+
required: typeof labelRequired === 'boolean' ? labelRequired : _required || Array.isArray(rules) && (rules === null || rules === void 0 ? void 0 : rules.some(function (item) {
|
|
159
159
|
return item === null || item === void 0 ? void 0 : item.required;
|
|
160
|
-
}))
|
|
160
|
+
})) || false
|
|
161
161
|
}, otherProps.isView && !requiredOnView ? {
|
|
162
162
|
required: false
|
|
163
163
|
} : null, _objectSpread({}, isTrim(type, trim, useProConfig())), // 优先取传进来的,其次取ProConfigProvider配置的
|
|
@@ -52,7 +52,7 @@ interface ControlProps {
|
|
|
52
52
|
/**
|
|
53
53
|
* 扩展函数的参数
|
|
54
54
|
*/
|
|
55
|
-
type FunctionArgs<Values, R = any> = (value: any, record: any, { form, index, namePath, option, selectedOptions, dateString, }: {
|
|
55
|
+
export type FunctionArgs<Values, R = any> = (value: any, record: any, { form, index, namePath, option, selectedOptions, dateString, }: {
|
|
56
56
|
form: FormInstance<Values>;
|
|
57
57
|
index?: number;
|
|
58
58
|
namePath?: NamePath;
|
|
@@ -3,3 +3,15 @@ export declare const iconMap: {
|
|
|
3
3
|
'text-cn': string;
|
|
4
4
|
'text-en': string;
|
|
5
5
|
}[];
|
|
6
|
+
export declare const themeMap: {
|
|
7
|
+
'#006AFF': string[];
|
|
8
|
+
'#00BC70': string[];
|
|
9
|
+
'#FF8C16': string[];
|
|
10
|
+
'#A00F20': string[];
|
|
11
|
+
};
|
|
12
|
+
export declare const themeFillMap: {
|
|
13
|
+
'#006AFF': string[];
|
|
14
|
+
'#00BC70': string[];
|
|
15
|
+
'#FF8C16': string[];
|
|
16
|
+
'#A00F20': string[];
|
|
17
|
+
};
|
|
@@ -254,4 +254,18 @@ export var iconMap = [{
|
|
|
254
254
|
type: 'tiaozhengxuhao',
|
|
255
255
|
'text-cn': '调整序号',
|
|
256
256
|
'text-en': 'adjust order'
|
|
257
|
-
}];
|
|
257
|
+
}];
|
|
258
|
+
// 渐变色icon预设
|
|
259
|
+
export var themeMap = {
|
|
260
|
+
'#006AFF': ['#ADDDFF', '#5FB3D8', '#4181FF'],
|
|
261
|
+
'#00BC70': ['#FFFFFF', '#54DFA7', '#00BC70'],
|
|
262
|
+
'#FF8C16': ['#FFFFFF', '#FFA74E', '#FF8C17'],
|
|
263
|
+
'#A00F20': ['#FFFFFF', '#E47B7B', '#A00E20']
|
|
264
|
+
};
|
|
265
|
+
// 双色icon预设
|
|
266
|
+
export var themeFillMap = {
|
|
267
|
+
'#006AFF': ['none', '#87F1FC', 'black', '#4181FF'],
|
|
268
|
+
'#00BC70': ['none', '#05FFEC', 'black', '#00BC70'],
|
|
269
|
+
'#FF8C16': ['none', '#FED736', 'black', '#FF8C17'],
|
|
270
|
+
'#A00F20': ['none', '#FD8357', 'black', '#A00E20']
|
|
271
|
+
};
|
package/es/ProIcon/index.js
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import "antd/es/button/style";
|
|
2
2
|
import _Button from "antd/es/button";
|
|
3
|
+
import "antd/es/tooltip/style";
|
|
4
|
+
import _Tooltip from "antd/es/tooltip";
|
|
3
5
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
6
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
|
-
var _excluded = ["type", "onClick", "size", "color", "className", "style", "spin", "rotate", "theme", "disabled", "mode", "buttonProps", "children", "mapList"];
|
|
7
|
+
var _excluded = ["type", "onClick", "size", "color", "className", "style", "spin", "rotate", "theme", "disabled", "mode", "buttonProps", "children", "mapList", "src", "actionMap"];
|
|
6
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
9
|
import { useExternal } from 'ahooks';
|
|
8
10
|
import classNames from 'classnames';
|
|
9
11
|
import { uniqBy } from 'lodash';
|
|
12
|
+
import { ReactSVG } from 'react-svg';
|
|
10
13
|
import { useProConfig } from '../ProConfigProvider';
|
|
11
|
-
import { iconMap } from './config';
|
|
14
|
+
import { iconMap, themeMap, themeFillMap } from './config';
|
|
15
|
+
import { recurseGetNodes } from './utils';
|
|
12
16
|
import locale from '../locale';
|
|
13
17
|
var ProIcon = function ProIcon(props) {
|
|
14
|
-
var
|
|
18
|
+
var _useProConfig = useProConfig(),
|
|
19
|
+
state = _useProConfig.state;
|
|
20
|
+
var config = state.ProIcon,
|
|
21
|
+
antdTheme = state.theme;
|
|
15
22
|
var _config = _objectSpread(_objectSpread({}, config), props !== null && props !== void 0 ? props : {});
|
|
16
23
|
var _config$type = _config.type,
|
|
17
24
|
type = _config$type === void 0 ? null : _config$type,
|
|
@@ -35,14 +42,17 @@ var ProIcon = function ProIcon(props) {
|
|
|
35
42
|
children = _config.children,
|
|
36
43
|
_config$mapList = _config.mapList,
|
|
37
44
|
mapList = _config$mapList === void 0 ? [] : _config$mapList,
|
|
45
|
+
src = _config.src,
|
|
46
|
+
actionMap = _config.actionMap,
|
|
38
47
|
reset = _objectWithoutProperties(_config, _excluded);
|
|
48
|
+
// 主题色
|
|
49
|
+
var _ref = antdTheme !== null && antdTheme !== void 0 ? antdTheme : {},
|
|
50
|
+
_ref$primaryColor = _ref.primaryColor,
|
|
51
|
+
primaryColor = _ref$primaryColor === void 0 ? '#006AFF' : _ref$primaryColor;
|
|
39
52
|
// 语言
|
|
40
53
|
var language = locale.ProIcon.language;
|
|
41
54
|
// 加载内部icon
|
|
42
|
-
|
|
43
|
-
if (status !== 'ready') {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
55
|
+
useExternal('https://at.alicdn.com/t/c/font_4063056_jmnz9g5uycp.js');
|
|
46
56
|
var rotateStyle = rotate ? {
|
|
47
57
|
msTransform: "rotate(".concat(rotate, "deg)"),
|
|
48
58
|
transform: "rotate(".concat(rotate, "deg)")
|
|
@@ -64,6 +74,8 @@ var ProIcon = function ProIcon(props) {
|
|
|
64
74
|
var mergedMapList = uniqBy(mapList.concat(iconMap), targetTextFill);
|
|
65
75
|
var _type = type;
|
|
66
76
|
var _text = children;
|
|
77
|
+
// svg图标对应文本
|
|
78
|
+
var iconText = '';
|
|
67
79
|
var typeIsExistAndIncludeEnglish = _type && /[a-zA-Z]/.test(_type);
|
|
68
80
|
// 模式为icon下,对传入的text进行指定语言-icon 映射
|
|
69
81
|
if (isIconMode && !type) {
|
|
@@ -73,6 +85,7 @@ var ProIcon = function ProIcon(props) {
|
|
|
73
85
|
});
|
|
74
86
|
if (target) {
|
|
75
87
|
_type = target === null || target === void 0 ? void 0 : target.type;
|
|
88
|
+
iconText = target[targetTextFill];
|
|
76
89
|
}
|
|
77
90
|
}
|
|
78
91
|
}
|
|
@@ -87,24 +100,89 @@ var ProIcon = function ProIcon(props) {
|
|
|
87
100
|
}
|
|
88
101
|
}
|
|
89
102
|
}
|
|
103
|
+
var svgProps = {
|
|
104
|
+
className: proIconClassNames,
|
|
105
|
+
fill: 'currentColor',
|
|
106
|
+
style: _objectSpread(_objectSpread({
|
|
107
|
+
width: size,
|
|
108
|
+
height: size
|
|
109
|
+
}, rotateStyle), style)
|
|
110
|
+
};
|
|
90
111
|
var RenderIcon = _jsx("span", _objectSpread(_objectSpread({
|
|
91
112
|
className: "anticon",
|
|
92
113
|
style: {
|
|
93
114
|
color: color
|
|
94
115
|
}
|
|
95
116
|
}, reset), {}, {
|
|
96
|
-
children: _jsx(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
117
|
+
children: _jsx(_Tooltip, {
|
|
118
|
+
title: iconText,
|
|
119
|
+
children: !src ? _jsx("svg", _objectSpread(_objectSpread({}, svgProps), {}, {
|
|
120
|
+
onClick: onClick,
|
|
121
|
+
"aria-hidden": "true",
|
|
122
|
+
children: _jsx("use", {
|
|
123
|
+
xlinkHref: "#icon-".concat(_type)
|
|
124
|
+
})
|
|
125
|
+
})) : _jsx(ReactSVG, _objectSpread(_objectSpread({}, svgProps), {}, {
|
|
126
|
+
// @ts-ignore
|
|
127
|
+
onClick: onClick,
|
|
128
|
+
"aria-hidden": "true",
|
|
129
|
+
src: src,
|
|
130
|
+
beforeInjection: function beforeInjection(svg) {
|
|
131
|
+
if (actionMap && svg) {
|
|
132
|
+
var _actionMap$themeMap, _actionMap$themeFillM, _actionMap$gradation, _actionMap$fill;
|
|
133
|
+
// 项目内置的四种主题匹配渐变色
|
|
134
|
+
var mergeThemeMap = _objectSpread(_objectSpread({}, themeMap), (_actionMap$themeMap = actionMap.themeMap) !== null && _actionMap$themeMap !== void 0 ? _actionMap$themeMap : {});
|
|
135
|
+
// 项目内置的四种双色匹配fill
|
|
136
|
+
var mergeFillThemeMap = _objectSpread(_objectSpread({}, themeFillMap), (_actionMap$themeFillM = actionMap.themeFillMap) !== null && _actionMap$themeFillM !== void 0 ? _actionMap$themeFillM : {});
|
|
137
|
+
var _gradList = mergeThemeMap[primaryColor];
|
|
138
|
+
var _fillList = mergeFillThemeMap[primaryColor];
|
|
139
|
+
// 渐变操作序列
|
|
140
|
+
var gradList = (_actionMap$gradation = actionMap === null || actionMap === void 0 ? void 0 : actionMap.gradation) !== null && _actionMap$gradation !== void 0 ? _actionMap$gradation : _gradList;
|
|
141
|
+
// 填充操作序列
|
|
142
|
+
var fillList = (_actionMap$fill = actionMap === null || actionMap === void 0 ? void 0 : actionMap.fill) !== null && _actionMap$fill !== void 0 ? _actionMap$fill : _fillList;
|
|
143
|
+
// 节点收集
|
|
144
|
+
var nodeMap = {
|
|
145
|
+
// 渐变色节点收集
|
|
146
|
+
gradation: [],
|
|
147
|
+
// 具有fill属性的节点收集
|
|
148
|
+
fill: []
|
|
149
|
+
};
|
|
150
|
+
// 目前只支持处理渐变及fill填充
|
|
151
|
+
var types = Reflect.ownKeys(nodeMap !== null && nodeMap !== void 0 ? nodeMap : {});
|
|
152
|
+
types.forEach(function (typeKey) {
|
|
153
|
+
recurseGetNodes(typeKey, svg, nodeMap[typeKey]);
|
|
154
|
+
});
|
|
155
|
+
if ((gradList === null || gradList === void 0 ? void 0 : gradList.length) > 0) {
|
|
156
|
+
nodeMap.gradation.forEach(function (item, index) {
|
|
157
|
+
// 下一步准备替换的
|
|
158
|
+
var nextStr = gradList[index];
|
|
159
|
+
// 属性原本的值
|
|
160
|
+
var originStr = item.getAttribute('stop-color');
|
|
161
|
+
if (nextStr && originStr !== nextStr) {
|
|
162
|
+
item.setAttribute('stop-color', nextStr);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if ((fillList === null || fillList === void 0 ? void 0 : fillList.length) > 0) {
|
|
167
|
+
nodeMap.fill.forEach(function (item, index) {
|
|
168
|
+
// 默认接收的
|
|
169
|
+
var receiveStr = fillList[index];
|
|
170
|
+
// 下一步准备替换的
|
|
171
|
+
var nextFillStr = receiveStr === 'theme' ? primaryColor : receiveStr;
|
|
172
|
+
// 属性原本的值
|
|
173
|
+
var originFill = item.getAttribute('fill');
|
|
174
|
+
// 如果包含url(则是内链,不作替换处理
|
|
175
|
+
if (!(originFill && originFill.includes('url(')) && nextFillStr) {
|
|
176
|
+
// 不同才替换
|
|
177
|
+
if (originFill !== nextFillStr) {
|
|
178
|
+
item.setAttribute('fill', nextFillStr);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}))
|
|
108
186
|
})
|
|
109
187
|
}));
|
|
110
188
|
return !isExtendButtonMode ? RenderIcon : _jsx(_Button, _objectSpread(_objectSpread(_objectSpread({
|
|
@@ -6,7 +6,21 @@ interface iconMap {
|
|
|
6
6
|
'text-cn'?: string;
|
|
7
7
|
'text-en'?: string;
|
|
8
8
|
}
|
|
9
|
+
interface themeMap {
|
|
10
|
+
[key: string]: string[];
|
|
11
|
+
}
|
|
12
|
+
interface actionMap {
|
|
13
|
+
themeMap?: themeMap;
|
|
14
|
+
themeFillMap?: themeMap;
|
|
15
|
+
gradation?: string[];
|
|
16
|
+
fill?: string[];
|
|
17
|
+
}
|
|
9
18
|
export interface ProIconProps {
|
|
19
|
+
/**
|
|
20
|
+
* @description 本地import引入
|
|
21
|
+
* @default ""
|
|
22
|
+
*/
|
|
23
|
+
src?: string;
|
|
10
24
|
/**
|
|
11
25
|
* @description 图标的名称
|
|
12
26
|
* @default -
|
|
@@ -75,5 +89,10 @@ export interface ProIconProps {
|
|
|
75
89
|
* @default 项目内认默映射
|
|
76
90
|
*/
|
|
77
91
|
mapList?: iconMap[];
|
|
92
|
+
/**
|
|
93
|
+
* @description svg变更操作表 请到 ProThemeTools 主题配置查看示例
|
|
94
|
+
* @default
|
|
95
|
+
*/
|
|
96
|
+
actionMap?: actionMap;
|
|
78
97
|
}
|
|
79
98
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const recurseGetNodes: (type: any, node: any, queue: any) => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export var recurseGetNodes = function recurseGetNodes(type, node, queue) {
|
|
2
|
+
switch (type) {
|
|
3
|
+
// 渐变
|
|
4
|
+
case 'gradation':
|
|
5
|
+
if (node.nodeName === 'stop' && node.getAttribute('stop-color')) {
|
|
6
|
+
queue.push(node);
|
|
7
|
+
}
|
|
8
|
+
break;
|
|
9
|
+
// 填充
|
|
10
|
+
case 'fill':
|
|
11
|
+
if (node.getAttribute && node.getAttribute('fill')) {
|
|
12
|
+
queue.push(node);
|
|
13
|
+
}
|
|
14
|
+
break;
|
|
15
|
+
default:
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
if (node.childNodes) {
|
|
19
|
+
for (var i = 0; i < node.childNodes.length; i++) {
|
|
20
|
+
recurseGetNodes(type, node.childNodes[i], queue);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -65,6 +65,14 @@ var PrdTools = function PrdTools(_ref) {
|
|
|
65
65
|
};
|
|
66
66
|
});
|
|
67
67
|
setActive(newArray);
|
|
68
|
+
dispatch({
|
|
69
|
+
type: 'set',
|
|
70
|
+
payload: {
|
|
71
|
+
theme: {
|
|
72
|
+
primaryColor: zauiBrand
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
68
76
|
}
|
|
69
77
|
}, []);
|
|
70
78
|
return _jsxs(NewDrawer, {
|
|
@@ -105,6 +113,14 @@ var PrdTools = function PrdTools(_ref) {
|
|
|
105
113
|
setThemes({
|
|
106
114
|
'zaui-brand': item.color
|
|
107
115
|
});
|
|
116
|
+
dispatch({
|
|
117
|
+
type: 'set',
|
|
118
|
+
payload: {
|
|
119
|
+
theme: {
|
|
120
|
+
primaryColor: item.color
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
108
124
|
},
|
|
109
125
|
children: item.active ? _jsx(CheckOutlined, {}) : null
|
|
110
126
|
}, item.color);
|
package/es/ProTreeModal/index.js
CHANGED
|
@@ -206,10 +206,11 @@ var ProTreeModal = function ProTreeModal(props) {
|
|
|
206
206
|
setState({
|
|
207
207
|
checkedValues: checkedValues,
|
|
208
208
|
checkAll: checkedValues.length === allKeys.length,
|
|
209
|
-
treeViewData: treeViewData
|
|
209
|
+
treeViewData: treeViewData,
|
|
210
|
+
beforeClearAllValues: checkedValues
|
|
210
211
|
});
|
|
211
212
|
}
|
|
212
|
-
}, [value, state.allKeys]);
|
|
213
|
+
}, [value, state.allKeys, state.open]);
|
|
213
214
|
var handleClick = function handleClick() {
|
|
214
215
|
setState({
|
|
215
216
|
open: true
|
|
@@ -276,24 +277,19 @@ var ProTreeModal = function ProTreeModal(props) {
|
|
|
276
277
|
treeViewData: [],
|
|
277
278
|
checkAll: false
|
|
278
279
|
});
|
|
279
|
-
|
|
280
|
+
/* ******** fix:3.4.4-beta.4 点击清空全部不应该回调、所有的都是应该走统一的确定 ********* */
|
|
281
|
+
// onChange?.(_checkedValues);
|
|
280
282
|
};
|
|
281
283
|
/**
|
|
282
284
|
* Drawer close
|
|
283
285
|
*/
|
|
284
286
|
var handleClose = function handleClose() {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
});
|
|
292
|
-
} else {
|
|
293
|
-
setState({
|
|
294
|
-
open: false
|
|
295
|
-
});
|
|
296
|
-
}
|
|
287
|
+
setState({
|
|
288
|
+
open: false,
|
|
289
|
+
checkedValues: state.beforeClearAllValues,
|
|
290
|
+
beforeClearAllValues: []
|
|
291
|
+
});
|
|
292
|
+
// onChange?.(state.beforeClearAllValues);
|
|
297
293
|
openChange === null || openChange === void 0 ? void 0 : openChange(false);
|
|
298
294
|
};
|
|
299
295
|
/**
|