@zat-design/sisyphus-react 3.4.2 → 3.4.3-beta.2
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/index.esm.css +303 -267
- package/dist/less.esm.css +5024 -0
- package/dist/less.esm.js +3 -0
- package/es/ProConfigProvider/index.d.ts +1 -1
- package/es/ProConfigProvider/index.js +24 -2
- package/es/ProEditLabel/style/index.less +1 -2
- package/es/ProEditTable/components/RenderField/index.js +32 -21
- package/es/ProEditTable/index.js +3 -3
- package/es/ProEditTable/propsType.d.ts +1 -1
- package/es/ProEditTable/style/index.less +1 -1
- package/es/ProEditTable/utils/config.js +5 -5
- package/es/ProEditTable/utils/index.js +67 -30
- package/es/ProEditTable/utils/tools.js +3 -1
- package/es/ProEnum/components/Group.d.ts +2 -0
- package/es/ProEnum/components/Group.js +20 -19
- package/es/ProEnum/index.js +4 -3
- package/es/ProEnum/style/index.less +12 -3
- package/es/ProForm/components/base/DatePicker/index.js +2 -2
- package/es/ProForm/components/combination/FormList/index.js +6 -3
- package/es/ProForm/components/combination/FormList/utils.d.ts +2 -1
- package/es/ProForm/components/combination/FormList/utils.js +5 -3
- package/es/ProForm/components/combination/Group/index.js +31 -17
- package/es/ProForm/components/combination/Group/propsType.d.ts +6 -0
- package/es/ProForm/components/combination/Group/style/index.less +4 -4
- package/es/ProForm/components/combination/Group/utils.d.ts +2 -0
- package/es/ProForm/components/combination/Group/utils.js +10 -0
- package/es/ProForm/components/combination/ProTimeLimit/index.js +8 -2
- package/es/ProForm/components/combination/ProTimeLimit/style/index.less +1 -1
- package/es/ProForm/components/index.d.ts +0 -1
- package/es/ProForm/components/index.js +1 -1
- package/es/ProForm/components/render/ConfirmWrapper.js +1 -1
- package/es/ProForm/components/render/Render.js +21 -13
- package/es/ProForm/components/render/RenderFields.d.ts +3 -2
- package/es/ProForm/components/render/RenderFields.js +7 -3
- package/es/ProForm/components/render/propsType.d.ts +2 -5
- package/es/ProForm/index.js +12 -11
- package/es/ProForm/propsType.d.ts +7 -3
- package/es/ProForm/style/index.less +17 -13
- package/es/ProForm/utils/{contrastOriginal.d.ts → diffOriginal.d.ts} +2 -1
- package/es/ProForm/utils/diffOriginal.js +61 -0
- package/es/ProForm/utils/index.d.ts +2 -2
- package/es/ProForm/utils/index.js +7 -2
- package/es/ProForm/utils/rulesCreator.d.ts +7 -1
- package/es/ProForm/utils/rulesCreator.js +33 -3
- package/es/ProForm/utils/transformNames.d.ts +1 -1
- package/es/ProForm/utils/transformNames.js +11 -4
- package/es/ProForm/utils/transformValue.js +2 -2
- package/es/ProForm/utils/useChanged.js +4 -3
- package/es/ProForm/utils/useListChanged.d.ts +1 -1
- package/es/ProForm/utils/useListChanged.js +5 -3
- package/es/ProForm/utils/useRules.js +36 -11
- package/es/ProForm/utils/useShouldUpdate.js +4 -4
- package/es/ProForm/utils/valueType.d.ts +10 -5
- package/es/ProForm/utils/valueType.js +20 -10
- package/es/ProIcon/config/index.d.ts +2 -1
- package/es/ProIcon/config/index.js +191 -133
- package/es/ProIcon/index.d.ts +0 -1
- package/es/ProIcon/index.js +21 -36
- package/es/ProIcon/propsTypes.d.ts +2 -1
- package/es/ProLayout/components/Layout/Header/style/index.less +1 -1
- package/es/ProLayout/components/Layout/Menu/OpenMenu/style/index.less +58 -55
- package/es/ProLayout/components/Layout/Menu/SideMenu/style/index.less +25 -20
- package/es/ProLayout/components/Layout/Menu/style/index.less +52 -56
- package/es/ProLayout/components/ProCollapse/PropTypes.d.ts +5 -0
- package/es/ProLayout/components/ProCollapse/index.js +45 -4
- package/es/ProLayout/components/ProCollapse/style/index.less +29 -11
- package/es/ProLayout/components/ProFooter/index.js +1 -1
- package/es/ProLayout/components/ProFooter/style/index.less +1 -1
- package/es/ProLayout/components/ProHeader/style/index.less +6 -5
- package/es/ProLayout/style/index.less +176 -88
- package/es/ProStep/components/Item/index.js +2 -1
- package/es/ProStep/style/index.less +71 -70
- package/es/ProTable/components/RenderColumn/index.d.ts +1 -1
- package/es/ProTable/components/RenderColumn/index.js +3 -3
- package/es/ProTable/propsType.d.ts +1 -1
- package/es/ProTable/style/index.less +2 -2
- package/es/ProTable/utils.js +9 -9
- package/es/ProTabs/style/index.less +3 -1
- package/es/ProThemeTools/component/PrdTools/index.d.ts +1 -1
- package/es/ProThemeTools/component/PrdTools/index.js +14 -28
- package/es/ProThemeTools/component/PrdTools/style/index.less +1 -1
- package/es/ProThemeTools/index.js +21 -29
- package/es/ProThemeTools/propsType.d.ts +1 -1
- package/es/ProThemeTools/style/index.less +25 -8
- package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/index.js +7 -11
- package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/propsType.d.ts +1 -1
- package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/style/index.less +1 -1
- package/es/ProTree/index.js +1 -1
- package/es/ProTree/style/index.less +5 -0
- package/es/ProTreeModal/style/index.less +2 -2
- package/es/ProUpload/style/fileItem.less +2 -2
- package/es/ProUpload/style/index.less +2 -2
- package/es/assets/catalog.svg +30 -1
- package/es/assets/fold.svg +27 -0
- package/es/assets/setting.svg +14 -0
- package/es/locale/en_US.d.ts +4 -0
- package/es/locale/en_US.js +4 -0
- package/es/locale/zh_CN.d.ts +4 -0
- package/es/locale/zh_CN.js +4 -0
- package/es/style/components.less +0 -1
- package/es/style/less.less +2 -0
- package/es/style/theme/antd.less +14 -29
- package/es/style/theme/index.less +2 -2
- package/es/style/theme/tokens.less +2 -2
- package/es/tokens.js +2 -2
- package/lib/ProConfigProvider/index.d.ts +1 -1
- package/lib/ProConfigProvider/index.js +23 -1
- package/lib/ProEditLabel/style/index.less +1 -2
- package/lib/ProEditTable/components/RenderField/index.js +31 -20
- package/lib/ProEditTable/index.js +3 -3
- package/lib/ProEditTable/propsType.d.ts +1 -1
- package/lib/ProEditTable/style/index.less +1 -1
- package/lib/ProEditTable/utils/config.js +5 -5
- package/lib/ProEditTable/utils/index.js +67 -30
- package/lib/ProEditTable/utils/tools.js +3 -1
- package/lib/ProEnum/components/Group.d.ts +2 -0
- package/lib/ProEnum/components/Group.js +20 -19
- package/lib/ProEnum/index.js +4 -3
- package/lib/ProEnum/style/index.less +12 -3
- package/lib/ProForm/components/base/DatePicker/index.js +1 -1
- package/lib/ProForm/components/combination/FormList/index.js +6 -3
- package/lib/ProForm/components/combination/FormList/utils.d.ts +2 -1
- package/lib/ProForm/components/combination/FormList/utils.js +5 -3
- package/lib/ProForm/components/combination/Group/index.js +28 -14
- package/lib/ProForm/components/combination/Group/propsType.d.ts +6 -0
- package/lib/ProForm/components/combination/Group/style/index.less +4 -4
- package/lib/ProForm/components/combination/Group/utils.d.ts +2 -0
- package/lib/ProForm/components/combination/Group/utils.js +11 -1
- package/lib/ProForm/components/combination/ProTimeLimit/index.js +7 -1
- package/lib/ProForm/components/combination/ProTimeLimit/style/index.less +1 -1
- package/lib/ProForm/components/index.d.ts +0 -1
- package/lib/ProForm/components/index.js +0 -7
- package/lib/ProForm/components/render/ConfirmWrapper.js +1 -1
- package/lib/ProForm/components/render/Render.js +21 -13
- package/lib/ProForm/components/render/RenderFields.d.ts +3 -2
- package/lib/ProForm/components/render/RenderFields.js +7 -3
- package/lib/ProForm/components/render/propsType.d.ts +2 -5
- package/lib/ProForm/index.js +11 -10
- package/lib/ProForm/propsType.d.ts +7 -3
- package/lib/ProForm/style/index.less +17 -13
- package/lib/ProForm/utils/{contrastOriginal.d.ts → diffOriginal.d.ts} +2 -1
- package/lib/ProForm/utils/diffOriginal.js +68 -0
- package/lib/ProForm/utils/index.d.ts +2 -2
- package/lib/ProForm/utils/index.js +8 -3
- package/lib/ProForm/utils/rulesCreator.d.ts +7 -1
- package/lib/ProForm/utils/rulesCreator.js +33 -2
- package/lib/ProForm/utils/transformNames.d.ts +1 -1
- package/lib/ProForm/utils/transformNames.js +10 -3
- package/lib/ProForm/utils/transformValue.js +1 -1
- package/lib/ProForm/utils/useChanged.js +4 -3
- package/lib/ProForm/utils/useListChanged.d.ts +1 -1
- package/lib/ProForm/utils/useListChanged.js +5 -3
- package/lib/ProForm/utils/useRules.js +36 -11
- package/lib/ProForm/utils/useShouldUpdate.js +4 -4
- package/lib/ProForm/utils/valueType.d.ts +10 -5
- package/lib/ProForm/utils/valueType.js +20 -10
- package/lib/ProIcon/config/index.d.ts +2 -1
- package/lib/ProIcon/config/index.js +191 -133
- package/lib/ProIcon/index.d.ts +0 -1
- package/lib/ProIcon/index.js +21 -37
- package/lib/ProIcon/propsTypes.d.ts +2 -1
- package/lib/ProLayout/components/Layout/Header/style/index.less +1 -1
- package/lib/ProLayout/components/Layout/Menu/OpenMenu/style/index.less +58 -55
- package/lib/ProLayout/components/Layout/Menu/SideMenu/style/index.less +25 -20
- package/lib/ProLayout/components/Layout/Menu/style/index.less +52 -56
- package/lib/ProLayout/components/ProCollapse/PropTypes.d.ts +5 -0
- package/lib/ProLayout/components/ProCollapse/index.js +43 -4
- package/lib/ProLayout/components/ProCollapse/style/index.less +29 -11
- package/lib/ProLayout/components/ProFooter/index.js +1 -1
- package/lib/ProLayout/components/ProFooter/style/index.less +1 -1
- package/lib/ProLayout/components/ProHeader/style/index.less +6 -5
- package/lib/ProLayout/style/index.less +176 -88
- package/lib/ProStep/components/Item/index.js +2 -1
- package/lib/ProStep/style/index.less +71 -70
- package/lib/ProTable/components/RenderColumn/index.d.ts +1 -1
- package/lib/ProTable/components/RenderColumn/index.js +3 -3
- package/lib/ProTable/propsType.d.ts +1 -1
- package/lib/ProTable/style/index.less +2 -2
- package/lib/ProTable/utils.js +9 -9
- package/lib/ProTabs/style/index.less +3 -1
- package/lib/ProThemeTools/component/PrdTools/index.d.ts +1 -1
- package/lib/ProThemeTools/component/PrdTools/index.js +14 -28
- package/lib/ProThemeTools/component/PrdTools/style/index.less +1 -1
- package/lib/ProThemeTools/index.js +19 -28
- package/lib/ProThemeTools/propsType.d.ts +1 -1
- package/lib/ProThemeTools/style/index.less +25 -8
- package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/index.js +7 -11
- package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/propsType.d.ts +1 -1
- package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/style/index.less +1 -1
- package/lib/ProTree/index.js +1 -1
- package/lib/ProTree/style/index.less +5 -0
- package/lib/ProTreeModal/style/index.less +2 -2
- package/lib/ProUpload/style/fileItem.less +2 -2
- package/lib/ProUpload/style/index.less +2 -2
- package/lib/assets/catalog.svg +30 -1
- package/lib/assets/fold.svg +27 -0
- package/lib/assets/setting.svg +14 -0
- package/lib/locale/en_US.d.ts +4 -0
- package/lib/locale/en_US.js +4 -0
- package/lib/locale/zh_CN.d.ts +4 -0
- package/lib/locale/zh_CN.js +4 -0
- package/lib/style/components.less +0 -1
- package/lib/style/less.less +2 -0
- package/lib/style/theme/antd.less +14 -29
- package/lib/style/theme/index.less +2 -2
- package/lib/style/theme/tokens.less +2 -2
- package/lib/tokens.js +2 -2
- package/package.json +1 -1
- package/es/ProForm/utils/contrastOriginal.js +0 -24
- package/es/ProIcon/symbolIcon.js +0 -43
- package/lib/ProForm/utils/contrastOriginal.js +0 -30
- package/lib/ProIcon/symbolIcon.js +0 -45
- /package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/index.d.ts +0 -0
- /package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/propsType.js +0 -0
- /package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/index.d.ts +0 -0
- /package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/propsType.js +0 -0
package/dist/less.esm.js
ADDED
|
@@ -21,7 +21,7 @@ export declare const ProConfigContext: React.Context<ConfigContext>;
|
|
|
21
21
|
export declare function useProConfig(): ConfigContext;
|
|
22
22
|
export declare function useProConfig(name: keyof ConfigContext['state']): ConfigContext['state'][keyof ConfigContext['state']];
|
|
23
23
|
export declare function useContextForms(): Record<string, FormInstance<any>>;
|
|
24
|
-
type ActionsType = 'set' | 'setProEnum' | 'setProEnumDic';
|
|
24
|
+
type ActionsType = 'set' | 'setProEnum' | 'setProEnumDic' | 'setWithLocal';
|
|
25
25
|
interface Actions {
|
|
26
26
|
type: ActionsType;
|
|
27
27
|
payload: any;
|
|
@@ -3,7 +3,7 @@ import _ConfigProvider from "antd/es/config-provider";
|
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
4
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
5
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
import React, { useContext, useReducer } from 'react';
|
|
6
|
+
import React, { useContext, useEffect, useReducer } from 'react';
|
|
7
7
|
import zhCN from 'antd/es/locale/zh_CN';
|
|
8
8
|
import enUS from 'antd/es/locale/en_US';
|
|
9
9
|
import merge from 'lodash/merge';
|
|
@@ -13,12 +13,16 @@ var initialState = {
|
|
|
13
13
|
ProEnum: {
|
|
14
14
|
dics: {}
|
|
15
15
|
},
|
|
16
|
+
ProForm: {
|
|
17
|
+
labelAlign: 'left'
|
|
18
|
+
},
|
|
16
19
|
forms: {},
|
|
17
20
|
ProIcon: {
|
|
18
21
|
mode: 'icon',
|
|
19
22
|
mapList: [{
|
|
20
23
|
type: 'view',
|
|
21
|
-
text: '查看'
|
|
24
|
+
'text-cn': '查看',
|
|
25
|
+
'text-en': 'view'
|
|
22
26
|
}]
|
|
23
27
|
}
|
|
24
28
|
};
|
|
@@ -45,6 +49,15 @@ var reducer = function reducer(state, action) {
|
|
|
45
49
|
switch (action.type) {
|
|
46
50
|
case 'set':
|
|
47
51
|
return _objectSpread(_objectSpread({}, state), action.payload);
|
|
52
|
+
// 设置的值会被存入localStorage
|
|
53
|
+
case 'setWithLocal':
|
|
54
|
+
{
|
|
55
|
+
var _state = merge({}, state, action.payload);
|
|
56
|
+
var localConfigStr = localStorage.getItem('localConfig');
|
|
57
|
+
var localConfig = JSON.parse(localConfigStr || '{}');
|
|
58
|
+
localStorage.setItem('localConfig', JSON.stringify(merge(localConfig, action.payload)));
|
|
59
|
+
return _state;
|
|
60
|
+
}
|
|
48
61
|
case 'setProEnum':
|
|
49
62
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
50
63
|
ProEnum: _objectSpread(_objectSpread({}, state.ProEnum), action.payload)
|
|
@@ -66,6 +79,15 @@ export var ProConfigProvider = function ProConfigProvider(props) {
|
|
|
66
79
|
state = _useReducer2[0],
|
|
67
80
|
dispatch = _useReducer2[1];
|
|
68
81
|
useEnumRequest(_objectSpread(_objectSpread(_objectSpread({}, state.ProEnum), props === null || props === void 0 ? void 0 : (_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.ProEnum), props === null || props === void 0 ? void 0 : (_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2.globalConfig), dispatch);
|
|
82
|
+
useEffect(function () {
|
|
83
|
+
// 本地配置取出
|
|
84
|
+
var localConfigStr = localStorage.getItem('localConfig');
|
|
85
|
+
var localConfig = JSON.parse(localConfigStr || '{}');
|
|
86
|
+
dispatch({
|
|
87
|
+
type: 'set',
|
|
88
|
+
payload: merge(state, localConfig)
|
|
89
|
+
});
|
|
90
|
+
}, []);
|
|
69
91
|
var cacheLang = localStorage.getItem('locale');
|
|
70
92
|
// 如果是用户切换了语言那么优先使用用户切换的,否则从缓存中取用户语言,在取默认值
|
|
71
93
|
var lang = (state === null || state === void 0 ? void 0 : state.locale) || cacheLang || (props === null || props === void 0 ? void 0 : props.locale);
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
|
|
40
40
|
&:active {
|
|
41
41
|
background : #E3E8F0;
|
|
42
|
-
border-radius: var(--zaui-border-radius-card,
|
|
42
|
+
border-radius: var(--zaui-border-radius-card, 4px);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -120,7 +120,6 @@
|
|
|
120
120
|
|
|
121
121
|
.@{ant-prefix}-col-10 {
|
|
122
122
|
flex : 0 0 var(--zaui-form-label-width, 130px);
|
|
123
|
-
text-align : var(--zaui-form-align, left);
|
|
124
123
|
white-space : pre-wrap;
|
|
125
124
|
line-height : 1;
|
|
126
125
|
overflow : initial;
|
|
@@ -17,7 +17,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
17
17
|
/* eslint-disable prefer-const */
|
|
18
18
|
import React, { useCallback, useEffect } from 'react';
|
|
19
19
|
import classNames from 'classnames';
|
|
20
|
-
import { cloneDeep, isEqual, debounce, omit, isFunction
|
|
20
|
+
import { cloneDeep, isEqual, debounce, omit, isFunction } from 'lodash';
|
|
21
21
|
import valueTypeMap from '../../../ProForm/utils/valueType';
|
|
22
22
|
import transformMap from '../../utils/transform';
|
|
23
23
|
import { getNamePath, difference } from '../../utils/tools';
|
|
@@ -28,9 +28,8 @@ import { FieldProvider } from '../../../ProForm/utils/useFieldProps';
|
|
|
28
28
|
import { useListChanged } from '../../../ProForm/utils/useListChanged';
|
|
29
29
|
import useRules from '../../../ProForm/utils/useRules';
|
|
30
30
|
import { isSelect } from '../../../ProForm/utils';
|
|
31
|
-
import locale from '../../../locale';
|
|
32
31
|
var RenderField = function RenderField(_ref) {
|
|
33
|
-
var _type, _type$replace, _fieldProps2, _fieldProps3, _fieldProps4, _names,
|
|
32
|
+
var _type, _type$replace, _fieldProps2, _fieldProps3, _fieldProps4, _names, _TargetComponent4, _componentProps;
|
|
34
33
|
var value = _ref.text,
|
|
35
34
|
record = _ref.record,
|
|
36
35
|
index = _ref.index,
|
|
@@ -73,7 +72,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
73
72
|
virtualKey = config.virtualKey,
|
|
74
73
|
viewEmpty = config.viewEmpty,
|
|
75
74
|
originalValues = config.originalValues,
|
|
76
|
-
|
|
75
|
+
originalDiffTip = config.originalDiffTip;
|
|
77
76
|
var _fieldProps = fieldProps || formItemProps || {};
|
|
78
77
|
var _rules = rules || [];
|
|
79
78
|
var _required = required;
|
|
@@ -141,7 +140,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
141
140
|
var formItemChildProps = _objectSpread({}, _fieldProps);
|
|
142
141
|
// 允许formItem的属性放在column最外层
|
|
143
142
|
var _formItemProps = _objectSpread(_objectSpread({}, resetProps), internalRule);
|
|
144
|
-
if (['Switch', '
|
|
143
|
+
if (['Switch', 'SwitchCheckbox'].includes(type)) {
|
|
145
144
|
_formItemProps.valuePropName = 'checked';
|
|
146
145
|
valueType = 'switch';
|
|
147
146
|
}
|
|
@@ -167,6 +166,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
167
166
|
* @returns {}
|
|
168
167
|
*/
|
|
169
168
|
var valueTypeTransform = useCallback(function () {
|
|
169
|
+
var _fieldProps5;
|
|
170
170
|
// 不存在valueType返回空
|
|
171
171
|
if (!valueType) {
|
|
172
172
|
return {};
|
|
@@ -175,7 +175,9 @@ var RenderField = function RenderField(_ref) {
|
|
|
175
175
|
if (type === 'SwitchCheckbox') {
|
|
176
176
|
valueType = 'switch';
|
|
177
177
|
}
|
|
178
|
-
var params = _objectSpread({}, column)
|
|
178
|
+
var params = _objectSpread(_objectSpread({}, column), {}, {
|
|
179
|
+
mode: (_fieldProps5 = _fieldProps) === null || _fieldProps5 === void 0 ? void 0 : _fieldProps5.mode
|
|
180
|
+
});
|
|
179
181
|
return isFunction(valueTypeMap[valueType]) ? valueTypeMap[valueType](params) : {};
|
|
180
182
|
}, [valueType]);
|
|
181
183
|
if ((_names = names) === null || _names === void 0 ? void 0 : _names.length) {
|
|
@@ -211,7 +213,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
211
213
|
if (valueType) {
|
|
212
214
|
transform = valueTypeTransform();
|
|
213
215
|
}
|
|
214
|
-
return transformNames(_objectSpread(_objectSpread({}, _formItemProps), transform), form, names, namesStr);
|
|
216
|
+
return transformNames(_objectSpread(_objectSpread({}, _formItemProps), transform), form, names, namesStr, type);
|
|
215
217
|
};
|
|
216
218
|
if (!_editRender && typeof type === 'string') {
|
|
217
219
|
var _componentMap$type;
|
|
@@ -241,8 +243,6 @@ var RenderField = function RenderField(_ref) {
|
|
|
241
243
|
TargetComponent = viewRender;
|
|
242
244
|
}
|
|
243
245
|
}
|
|
244
|
-
var defaultPlaceholder = ['Select', 'EnumSelect', 'DatePicker', 'RangePicker', 'Cascader', 'ProSelect', 'ProEnum', 'ProTimeLimit'].includes(type) ? "".concat(locale.ProEditTable.select).concat(isString(label) ? label || title : '') : "".concat(locale.ProEditTable.enter).concat(isString(label) ? label || title : '');
|
|
245
|
-
var _placeholder = (_formItemChildProps$p = formItemChildProps === null || formItemChildProps === void 0 ? void 0 : formItemChildProps.placeholder) !== null && _formItemChildProps$p !== void 0 ? _formItemChildProps$p : defaultPlaceholder;
|
|
246
246
|
var onChange = formItemChildProps === null || formItemChildProps === void 0 ? void 0 : formItemChildProps.onChange;
|
|
247
247
|
var onFieldChange = formItemChildProps === null || formItemChildProps === void 0 ? void 0 : formItemChildProps.onFieldChange;
|
|
248
248
|
var onBlur = formItemChildProps === null || formItemChildProps === void 0 ? void 0 : formItemChildProps.onBlur;
|
|
@@ -303,7 +303,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
303
303
|
}
|
|
304
304
|
_args = [].concat(args);
|
|
305
305
|
rowPath = [].concat(_toConsumableArray(namePath), [index]);
|
|
306
|
-
row = form.getFieldValue(rowPath);
|
|
306
|
+
row = type === 'Group' ? _args[1] : form.getFieldValue(rowPath, true);
|
|
307
307
|
orgRow = cloneDeep(row);
|
|
308
308
|
if (!onFieldChange) {
|
|
309
309
|
_context.next = 18;
|
|
@@ -348,14 +348,16 @@ var RenderField = function RenderField(_ref) {
|
|
|
348
348
|
return onChange.apply(void 0, _toConsumableArray(_args));
|
|
349
349
|
case 27:
|
|
350
350
|
// 判断属性是否变动
|
|
351
|
-
form.setFieldValue(rowPath, row);
|
|
351
|
+
type !== 'Group' && form.setFieldValue(rowPath, row);
|
|
352
352
|
if (!isEqual(orgRow, row)) {
|
|
353
353
|
diff = difference(row, orgRow) || {};
|
|
354
354
|
validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
|
|
355
355
|
return [].concat(_toConsumableArray(rowPath), [key]);
|
|
356
356
|
});
|
|
357
357
|
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
|
358
|
-
|
|
358
|
+
setTimeout(function () {
|
|
359
|
+
form.validateFields(validateFieldKeys);
|
|
360
|
+
}, 100);
|
|
359
361
|
}
|
|
360
362
|
}
|
|
361
363
|
setState({
|
|
@@ -468,12 +470,13 @@ var RenderField = function RenderField(_ref) {
|
|
|
468
470
|
originalValue = _useListChanged2[1];
|
|
469
471
|
var componentProps = _objectSpread(_objectSpread(_objectSpread({
|
|
470
472
|
form: form,
|
|
471
|
-
name: cellName
|
|
472
|
-
placeholder: _placeholder
|
|
473
|
+
name: cellName
|
|
473
474
|
}, _fieldProps), (_TargetComponent4 = TargetComponent) === null || _TargetComponent4 === void 0 ? void 0 : _TargetComponent4.props), {}, {
|
|
475
|
+
namePath: [].concat(_toConsumableArray(namePath), [index]),
|
|
474
476
|
disabled: _disabled,
|
|
475
477
|
onChange: _onchange,
|
|
476
478
|
onBlur: _onblur,
|
|
479
|
+
index: index,
|
|
477
480
|
otherProps: {
|
|
478
481
|
form: form,
|
|
479
482
|
names: names,
|
|
@@ -483,11 +486,16 @@ var RenderField = function RenderField(_ref) {
|
|
|
483
486
|
isView: isView
|
|
484
487
|
}
|
|
485
488
|
});
|
|
489
|
+
if (type === 'Group') {
|
|
490
|
+
componentProps.onFieldChange = _onchange;
|
|
491
|
+
} else {
|
|
492
|
+
componentProps = omit(componentProps, ['onFieldChange', 'namePath', 'index']);
|
|
493
|
+
}
|
|
486
494
|
// 单元格编辑时,设置各个单元格disabled属性
|
|
487
495
|
if (isCell) {
|
|
488
496
|
record["".concat(dataIndex, "-Disabled")] = _disabled;
|
|
489
497
|
}
|
|
490
|
-
if (['Switch', '
|
|
498
|
+
if (['Switch', 'SwitchCheckbox'].includes(type)) {
|
|
491
499
|
_formItemProps.valuePropName = 'checked';
|
|
492
500
|
}
|
|
493
501
|
useEffect(function () {
|
|
@@ -507,12 +515,12 @@ var RenderField = function RenderField(_ref) {
|
|
|
507
515
|
delete _formItemProps.rules;
|
|
508
516
|
}
|
|
509
517
|
var _className = classNames(_defineProperty(_defineProperty({}, className, className), 'pro-form-item-changed', changed));
|
|
510
|
-
var originalTitle =
|
|
511
|
-
children: ["\u521D\u59CB\u503C\uFF1A", /*#__PURE__*/React.isValidElement(TargetComponent) ? ( /*#__PURE__*/React.cloneElement(TargetComponent, _objectSpread(_objectSpread({},
|
|
518
|
+
var originalTitle = originalDiffTip ? _jsxs(_Space, {
|
|
519
|
+
children: ["\u521D\u59CB\u503C\uFF1A", /*#__PURE__*/React.isValidElement(TargetComponent) ? ( /*#__PURE__*/React.cloneElement(TargetComponent, _objectSpread(_objectSpread({}, componentProps), {}, {
|
|
512
520
|
isView: true,
|
|
513
521
|
value: originalValue,
|
|
514
522
|
checked: type === 'Switch' ? originalValue : undefined
|
|
515
|
-
}))) : _jsx(TargetComponent, _objectSpread(_objectSpread({},
|
|
523
|
+
}))) : _jsx(TargetComponent, _objectSpread(_objectSpread({}, componentProps), {}, {
|
|
516
524
|
isView: true,
|
|
517
525
|
value: originalValue,
|
|
518
526
|
checked: type === 'Switch' ? originalValue : undefined
|
|
@@ -523,15 +531,18 @@ var RenderField = function RenderField(_ref) {
|
|
|
523
531
|
}, omit(_formItemProps, ['render', 'cache', 'key', 'width', 'hiddenNames', 'name'])), {}, {
|
|
524
532
|
className: _className,
|
|
525
533
|
name: cellName,
|
|
526
|
-
children: /*#__PURE__*/React.isValidElement(TargetComponent) ? ( /*#__PURE__*/React.cloneElement(TargetComponent,
|
|
534
|
+
children: /*#__PURE__*/React.isValidElement(TargetComponent) ? ( /*#__PURE__*/React.cloneElement(TargetComponent, componentProps)) : _jsx(TargetComponent, _objectSpread({}, componentProps))
|
|
527
535
|
})) : _jsx(Container, {
|
|
528
536
|
viewEmpty: viewEmpty
|
|
529
537
|
});
|
|
530
538
|
return _jsx(FieldProvider, {
|
|
531
|
-
value: componentProps === null ||
|
|
532
|
-
children: !
|
|
539
|
+
value: (_componentProps = componentProps) === null || _componentProps === void 0 ? void 0 : _componentProps.otherProps,
|
|
540
|
+
children: !originalDiffTip || ['FormList', 'ProEditTable'].includes(type) ? FormItem : _jsx(_Tooltip, {
|
|
533
541
|
title: originalTitle,
|
|
534
542
|
open: changed ? undefined : false,
|
|
543
|
+
getPopupContainer: function getPopupContainer(target) {
|
|
544
|
+
return target.parentElement;
|
|
545
|
+
},
|
|
535
546
|
children: FormItem
|
|
536
547
|
})
|
|
537
548
|
});
|
package/es/ProEditTable/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import _ConfigProvider from "antd/es/config-provider";
|
|
|
10
10
|
import "antd/es/form/style";
|
|
11
11
|
import _Form from "antd/es/form";
|
|
12
12
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
13
|
-
var _excluded = ["value", "onChange", "className", "columns", "type", "mode", "stripe", "draggable", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "otherProps", "requiredAlign", "summary", "max", "headerRender", "pagination", "originalValues", "
|
|
13
|
+
var _excluded = ["value", "onChange", "className", "columns", "type", "mode", "stripe", "draggable", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "otherProps", "requiredAlign", "summary", "max", "headerRender", "pagination", "originalValues", "originalDiffTip", "rowKey"];
|
|
14
14
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
15
|
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
16
16
|
import { get, isArray } from 'lodash';
|
|
@@ -49,7 +49,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
|
49
49
|
headerRender = _ref.headerRender,
|
|
50
50
|
pagination = _ref.pagination,
|
|
51
51
|
originalValues = _ref.originalValues,
|
|
52
|
-
|
|
52
|
+
originalDiffTip = _ref.originalDiffTip,
|
|
53
53
|
rowKey = _ref.rowKey,
|
|
54
54
|
resetProps = _objectWithoutProperties(_ref, _excluded);
|
|
55
55
|
// 上下文form
|
|
@@ -151,7 +151,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
|
151
151
|
tableLength: value === null || value === void 0 ? void 0 : value.length,
|
|
152
152
|
page: page,
|
|
153
153
|
originalValues: originalValues,
|
|
154
|
-
|
|
154
|
+
originalDiffTip: originalDiffTip,
|
|
155
155
|
prefixCls: prefixCls
|
|
156
156
|
};
|
|
157
157
|
// 编辑行设置下样式
|
|
@@ -130,7 +130,7 @@ export interface ProEditTableProps<T = any> extends Omit<TableProps<T>, 'onChang
|
|
|
130
130
|
* @description 原始数据源,是否tooltip显示
|
|
131
131
|
* @default -
|
|
132
132
|
*/
|
|
133
|
-
|
|
133
|
+
originalDiffTip?: boolean;
|
|
134
134
|
/**
|
|
135
135
|
* @description 可编辑表格的类型,单行、多行、单元格编辑
|
|
136
136
|
* @default false
|
|
@@ -190,11 +190,6 @@ export var actions = {
|
|
|
190
190
|
addData.isEditing = true;
|
|
191
191
|
}
|
|
192
192
|
insertType === 'before' ? nextData.unshift(addData) : nextData.push(addData);
|
|
193
|
-
form.setFieldValue(name, nextData);
|
|
194
|
-
(_tableRef$current$que = tableRef.current.querySelector(".".concat(prefixCls, "-table-body"))) === null || _tableRef$current$que === void 0 ? void 0 : (_tableRef$current$que2 = _tableRef$current$que.scrollTo) === null || _tableRef$current$que2 === void 0 ? void 0 : _tableRef$current$que2.call(_tableRef$current$que, {
|
|
195
|
-
top: 10000,
|
|
196
|
-
behavior: 'smooth'
|
|
197
|
-
});
|
|
198
193
|
// 当单选情况下,存储正在编辑值
|
|
199
194
|
if (virtualKey) {
|
|
200
195
|
nextEditingKeys = _toConsumableArray(editingKeys); // 开启编辑状态
|
|
@@ -204,6 +199,11 @@ export var actions = {
|
|
|
204
199
|
editingKeys: nextEditingKeys
|
|
205
200
|
});
|
|
206
201
|
}
|
|
202
|
+
form.setFieldValue(name, nextData);
|
|
203
|
+
(_tableRef$current$que = tableRef.current.querySelector(".".concat(prefixCls, "-table-body"))) === null || _tableRef$current$que === void 0 ? void 0 : (_tableRef$current$que2 = _tableRef$current$que.scrollTo) === null || _tableRef$current$que2 === void 0 ? void 0 : _tableRef$current$que2.call(_tableRef$current$que, {
|
|
204
|
+
top: insertType === 'before' ? -10000 : 10000,
|
|
205
|
+
behavior: 'smooth'
|
|
206
|
+
});
|
|
207
207
|
_context2.next = 14;
|
|
208
208
|
return form.validateFields([name]);
|
|
209
209
|
case 14:
|
|
@@ -85,40 +85,77 @@ var getActionColumn = function getActionColumn(config) {
|
|
|
85
85
|
index = tools.calc(firstIndex, '+', index);
|
|
86
86
|
rowName = [].concat(_toConsumableArray(virtualRowName), [index]);
|
|
87
87
|
if (!(type === 'save')) {
|
|
88
|
-
_context.next =
|
|
88
|
+
_context.next = 12;
|
|
89
89
|
break;
|
|
90
90
|
}
|
|
91
|
-
_context.
|
|
91
|
+
_context.prev = 3;
|
|
92
|
+
_context.next = 6;
|
|
92
93
|
return customValidate(validateKeys, form, rowName);
|
|
93
|
-
case
|
|
94
|
+
case 6:
|
|
95
|
+
_context.next = 12;
|
|
96
|
+
break;
|
|
97
|
+
case 8:
|
|
98
|
+
_context.prev = 8;
|
|
99
|
+
_context.t0 = _context["catch"](3);
|
|
100
|
+
setTimeout(function () {
|
|
101
|
+
var errorDom = document.querySelector('.ant-form-item-has-error');
|
|
102
|
+
if (errorDom) {
|
|
103
|
+
var tableBody = errorDom.closest('.ant-table-content') || errorDom.closest('.ant-table-body');
|
|
104
|
+
var tableCell = errorDom.closest('.ant-table-cell');
|
|
105
|
+
if (tableBody && tableCell) {
|
|
106
|
+
var previousSibling = tableCell.previousElementSibling;
|
|
107
|
+
var childOffsetLeft = 0;
|
|
108
|
+
var childFixedLeft = 0;
|
|
109
|
+
while (previousSibling) {
|
|
110
|
+
if (previousSibling.nodeType === 1) {
|
|
111
|
+
var _previousSibling, _previousSibling$clas, _previousSibling$clas2, _previousSibling$clas3;
|
|
112
|
+
var _ref2 = previousSibling.getBoundingClientRect() || {},
|
|
113
|
+
_ref2$width = _ref2.width,
|
|
114
|
+
width = _ref2$width === void 0 ? 0 : _ref2$width;
|
|
115
|
+
childOffsetLeft += width;
|
|
116
|
+
if ((_previousSibling = previousSibling) === null || _previousSibling === void 0 ? void 0 : (_previousSibling$clas = _previousSibling.classList) === null || _previousSibling$clas === void 0 ? void 0 : (_previousSibling$clas2 = (_previousSibling$clas3 = _previousSibling$clas).contains) === null || _previousSibling$clas2 === void 0 ? void 0 : _previousSibling$clas2.call(_previousSibling$clas3, 'ant-table-cell-fix-left')) {
|
|
117
|
+
childFixedLeft += width;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
previousSibling = previousSibling.previousElementSibling;
|
|
121
|
+
}
|
|
122
|
+
tableBody.scrollTo({
|
|
123
|
+
left: childOffsetLeft - childFixedLeft,
|
|
124
|
+
behavior: 'smooth'
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}, 0);
|
|
129
|
+
return _context.abrupt("return", Promise.reject(_context.t0));
|
|
130
|
+
case 12:
|
|
94
131
|
// 编辑状态使用自定义form值,非编辑状态直接使用行数据
|
|
95
132
|
_record = (_form$getFieldValue = form.getFieldValue(rowName)) !== null && _form$getFieldValue !== void 0 ? _form$getFieldValue : record; // 新增事件可以设置初始默认值,当做函数的出参导出
|
|
96
133
|
onEvent = onClick || onHandle;
|
|
97
|
-
_context.next =
|
|
134
|
+
_context.next = 16;
|
|
98
135
|
return onEvent === null || onEvent === void 0 ? void 0 : onEvent(_record, index, {
|
|
99
136
|
form: form,
|
|
100
137
|
namePath: virtualRowName
|
|
101
138
|
});
|
|
102
|
-
case
|
|
103
|
-
_context.
|
|
104
|
-
_context.
|
|
105
|
-
if (!_context.
|
|
106
|
-
_context.next =
|
|
139
|
+
case 16:
|
|
140
|
+
_context.t2 = _yield$onEvent = _context.sent;
|
|
141
|
+
_context.t1 = _context.t2 !== null;
|
|
142
|
+
if (!_context.t1) {
|
|
143
|
+
_context.next = 20;
|
|
107
144
|
break;
|
|
108
145
|
}
|
|
109
|
-
_context.
|
|
110
|
-
case
|
|
111
|
-
if (!_context.
|
|
112
|
-
_context.next =
|
|
146
|
+
_context.t1 = _yield$onEvent !== void 0;
|
|
147
|
+
case 20:
|
|
148
|
+
if (!_context.t1) {
|
|
149
|
+
_context.next = 24;
|
|
113
150
|
break;
|
|
114
151
|
}
|
|
115
|
-
_context.
|
|
116
|
-
_context.next =
|
|
152
|
+
_context.t3 = _yield$onEvent;
|
|
153
|
+
_context.next = 25;
|
|
117
154
|
break;
|
|
118
|
-
case
|
|
119
|
-
_context.
|
|
120
|
-
case
|
|
121
|
-
result = _context.
|
|
155
|
+
case 24:
|
|
156
|
+
_context.t3 = true;
|
|
157
|
+
case 25:
|
|
158
|
+
result = _context.t3;
|
|
122
159
|
if (result && type !== 'custom') {
|
|
123
160
|
actions[type](_objectSpread(_objectSpread({}, config), {}, {
|
|
124
161
|
rowName: [].concat(_toConsumableArray(name), [index]),
|
|
@@ -128,11 +165,11 @@ var getActionColumn = function getActionColumn(config) {
|
|
|
128
165
|
validateKeys: validateKeys
|
|
129
166
|
}));
|
|
130
167
|
}
|
|
131
|
-
case
|
|
168
|
+
case 27:
|
|
132
169
|
case "end":
|
|
133
170
|
return _context.stop();
|
|
134
171
|
}
|
|
135
|
-
}, _callee);
|
|
172
|
+
}, _callee, null, [[3, 8]]);
|
|
136
173
|
}));
|
|
137
174
|
return function (_x, _x2) {
|
|
138
175
|
return _ref.apply(this, arguments);
|
|
@@ -210,10 +247,10 @@ export var transformColumns = function transformColumns() {
|
|
|
210
247
|
if (typeof columnTitle === 'string') {
|
|
211
248
|
item.originTitle = columnTitle;
|
|
212
249
|
if (tooltip) {
|
|
213
|
-
var
|
|
214
|
-
tooltipTitle =
|
|
215
|
-
icon =
|
|
216
|
-
resetProps = _objectWithoutProperties(
|
|
250
|
+
var _ref3 = tooltip || {},
|
|
251
|
+
tooltipTitle = _ref3.title,
|
|
252
|
+
icon = _ref3.icon,
|
|
253
|
+
resetProps = _objectWithoutProperties(_ref3, _excluded2);
|
|
217
254
|
item.title = _jsxs("span", {
|
|
218
255
|
className: "pro-edit-table-title pro-edit-table-tooltip",
|
|
219
256
|
children: [before, columnTitle, _jsx(_Tooltip, _objectSpread(_objectSpread({
|
|
@@ -280,7 +317,7 @@ export var transformColumns = function transformColumns() {
|
|
|
280
317
|
(_item$fieldProps3 = item.fieldProps) === null || _item$fieldProps3 === void 0 ? true : delete _item$fieldProps3.useRequest;
|
|
281
318
|
}
|
|
282
319
|
var _render = function _render(text, record, index) {
|
|
283
|
-
var isEditing = !virtualKey || editingKeys.includes(record.rowKey);
|
|
320
|
+
var isEditing = !virtualKey || editingKeys.includes(record.rowKey) || record.addFlag;
|
|
284
321
|
var namePath = isArray(name) ? name : [name];
|
|
285
322
|
if (virtualKey && editingKeys.includes(record.rowKey)) {
|
|
286
323
|
namePath = getNamePath(name, virtualKey);
|
|
@@ -365,13 +402,13 @@ export var transformColumns = function transformColumns() {
|
|
|
365
402
|
// cacheMap 用来存储缓存值,若有值后不再请求
|
|
366
403
|
if (JSON.stringify(cacheMap.current) === '{}') {
|
|
367
404
|
Promise.all(Object.entries(_cacheMap).map( /*#__PURE__*/function () {
|
|
368
|
-
var
|
|
369
|
-
var _item, key, value,
|
|
405
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(item) {
|
|
406
|
+
var _item, key, value, _ref5, service, option;
|
|
370
407
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
371
408
|
while (1) switch (_context2.prev = _context2.next) {
|
|
372
409
|
case 0:
|
|
373
410
|
_item = _slicedToArray(item, 2), key = _item[0], value = _item[1];
|
|
374
|
-
|
|
411
|
+
_ref5 = (value === null || value === void 0 ? void 0 : value.useRequest) || {}, service = _ref5.service, option = _ref5.option;
|
|
375
412
|
if (!service) {
|
|
376
413
|
_context2.next = 8;
|
|
377
414
|
break;
|
|
@@ -391,7 +428,7 @@ export var transformColumns = function transformColumns() {
|
|
|
391
428
|
}, _callee2);
|
|
392
429
|
}));
|
|
393
430
|
return function (_x3) {
|
|
394
|
-
return
|
|
431
|
+
return _ref4.apply(this, arguments);
|
|
395
432
|
};
|
|
396
433
|
}())).then(function (res) {
|
|
397
434
|
res.forEach(function (item) {
|
|
@@ -6,7 +6,9 @@ export var getRandom = function getRandom() {
|
|
|
6
6
|
export var difference = function difference(object, base) {
|
|
7
7
|
var changes = function changes(object, base) {
|
|
8
8
|
return transform(object, function (result, value, key) {
|
|
9
|
-
if (
|
|
9
|
+
if (key.indexOf('-') > -1) {
|
|
10
|
+
result[key] = true;
|
|
11
|
+
} else if (!isEqual(value, base[key])) {
|
|
10
12
|
result[key] = isObject(value) && isObject(base[key]) ? changes(value, base[key]) : value;
|
|
11
13
|
}
|
|
12
14
|
});
|
|
@@ -2,6 +2,8 @@ import { ProEnum } from '../propsType';
|
|
|
2
2
|
interface Props extends Pick<ProEnum, 'value' | 'onChange' | 'dataSource'> {
|
|
3
3
|
fieldValue: string;
|
|
4
4
|
fieldLabel: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
allowClear?: boolean;
|
|
5
7
|
}
|
|
6
8
|
declare const Group: (props: Props) => JSX.Element;
|
|
7
9
|
export default Group;
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
2
|
import classNames from 'classnames';
|
|
4
|
-
import { useSetState } from 'ahooks';
|
|
5
3
|
import { useEffect, useRef } from 'react';
|
|
6
4
|
var Group = function Group(props) {
|
|
7
5
|
var value = props.value,
|
|
8
6
|
onChange = props.onChange,
|
|
9
7
|
dataSource = props.dataSource,
|
|
10
8
|
fieldValue = props.fieldValue,
|
|
11
|
-
fieldLabel = props.fieldLabel
|
|
9
|
+
fieldLabel = props.fieldLabel,
|
|
10
|
+
disabled = props.disabled,
|
|
11
|
+
_props$allowClear = props.allowClear,
|
|
12
|
+
allowClear = _props$allowClear === void 0 ? true : _props$allowClear;
|
|
12
13
|
var idx = useRef(-1);
|
|
13
|
-
var _useSetState = useSetState({
|
|
14
|
-
checked: ''
|
|
15
|
-
}),
|
|
16
|
-
_useSetState2 = _slicedToArray(_useSetState, 2),
|
|
17
|
-
state = _useSetState2[0],
|
|
18
|
-
setState = _useSetState2[1];
|
|
19
14
|
useEffect(function () {
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
var index = dataSource.findIndex(function (item) {
|
|
16
|
+
return item[fieldValue] === value;
|
|
22
17
|
});
|
|
18
|
+
idx.current = index;
|
|
23
19
|
}, [value]);
|
|
24
20
|
var handleClick = function handleClick(val, index) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
if (value === val) {
|
|
22
|
+
if (!allowClear) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
onChange === null || onChange === void 0 ? void 0 : onChange('');
|
|
26
|
+
idx.current = -1;
|
|
27
|
+
} else {
|
|
28
|
+
idx.current = index;
|
|
29
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(val);
|
|
30
|
+
}
|
|
30
31
|
};
|
|
31
32
|
if (dataSource.length === 0) {
|
|
32
33
|
return _jsx("span", {
|
|
@@ -34,15 +35,15 @@ var Group = function Group(props) {
|
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
return _jsx("div", {
|
|
37
|
-
className:
|
|
38
|
+
className: classNames('pro-enum-group-root', disabled ? 'pro-enum-group-root-disabled' : ''),
|
|
38
39
|
children: dataSource.map(function (item, index) {
|
|
39
40
|
return _jsx("div", {
|
|
40
41
|
onClick: function onClick() {
|
|
41
|
-
if (!item.disabled) {
|
|
42
|
+
if (!item.disabled && !disabled) {
|
|
42
43
|
handleClick(item[fieldValue], index);
|
|
43
44
|
}
|
|
44
45
|
},
|
|
45
|
-
className: classNames('pro-enum-group-item',
|
|
46
|
+
className: classNames('pro-enum-group-item', value === item[fieldValue] ? 'pro-enum-group-item-selected' : '', index === idx.current || index + 1 === idx.current ? 'pro-enum-group-item-disabled-after' : '', item.disabled ? 'pro-enum-group-item-disabled' : ''),
|
|
46
47
|
children: item[fieldLabel]
|
|
47
48
|
}, item[fieldValue]);
|
|
48
49
|
})
|
package/es/ProEnum/index.js
CHANGED
|
@@ -41,7 +41,8 @@ var ProEnum = function ProEnum(props) {
|
|
|
41
41
|
enumProps = _objectWithoutProperties(props, _excluded);
|
|
42
42
|
var _ref = otherProps || {},
|
|
43
43
|
isView = _ref.isView,
|
|
44
|
-
viewEmpty = _ref.viewEmpty
|
|
44
|
+
viewEmpty = _ref.viewEmpty,
|
|
45
|
+
disabled = _ref.disabled;
|
|
45
46
|
var _ref2 = useProConfig('ProEnum') || {},
|
|
46
47
|
fieldNames = _ref2.fieldNames,
|
|
47
48
|
_ref2$clear = _ref2.clear,
|
|
@@ -207,13 +208,13 @@ var ProEnum = function ProEnum(props) {
|
|
|
207
208
|
dataSource: list
|
|
208
209
|
});
|
|
209
210
|
case 'Group':
|
|
210
|
-
return _jsx(ProEnumGroup, {
|
|
211
|
+
return _jsx(ProEnumGroup, _objectSpread(_objectSpread({}, enumProps), {}, {
|
|
211
212
|
value: value,
|
|
212
213
|
onChange: onChange,
|
|
213
214
|
fieldLabel: label,
|
|
214
215
|
fieldValue: fieldValue,
|
|
215
216
|
dataSource: list
|
|
216
|
-
});
|
|
217
|
+
}));
|
|
217
218
|
default:
|
|
218
219
|
return null;
|
|
219
220
|
}
|