@zat-design/sisyphus-react 3.6.0 → 3.6.1-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 +4 -0
- package/dist/less.esm.css +4 -0
- package/es/ProConfigProvider/index.d.ts +1 -0
- package/es/ProConfigProvider/index.js +6 -1
- package/es/ProEditTable/index.js +2 -1
- package/es/ProEditTable/utils/config.js +6 -2
- package/es/ProEnum/hooks/useEnumRequest.d.ts +1 -1
- package/es/ProEnum/hooks/useEnumRequest.js +113 -113
- package/es/ProForm/components/combination/ProModalSelect/index.js +1 -1
- package/es/ProForm/components/combination/ProNumberRange/index.js +4 -1
- package/es/ProForm/components/render/Render.js +8 -2
- package/es/ProForm/components/render/RenderFields.js +0 -6
- package/es/ProForm/components/render/propsType.d.ts +4 -0
- package/es/ProForm/index.js +7 -4
- package/es/ProForm/propsType.d.ts +4 -0
- package/es/ProForm/utils/index.d.ts +1 -1
- package/es/ProForm/utils/index.js +5 -2
- package/es/ProForm/utils/useForm.d.ts +7 -1
- package/es/ProForm/utils/useForm.js +59 -6
- package/es/ProTooltip/index.js +14 -14
- package/es/ProTreeModal/components/List.js +108 -17
- package/es/ProTreeModal/components/Tree.js +4 -2
- package/es/ProTreeModal/index.js +25 -20
- package/es/ProTreeModal/style/index.less +6 -0
- package/lib/ProConfigProvider/index.d.ts +1 -0
- package/lib/ProConfigProvider/index.js +6 -1
- package/lib/ProEditTable/index.js +2 -1
- package/lib/ProEditTable/utils/config.js +6 -2
- package/lib/ProEnum/hooks/useEnumRequest.d.ts +1 -1
- package/lib/ProEnum/hooks/useEnumRequest.js +113 -113
- package/lib/ProForm/components/combination/ProModalSelect/index.js +1 -1
- package/lib/ProForm/components/combination/ProNumberRange/index.js +4 -1
- package/lib/ProForm/components/render/Render.js +8 -2
- package/lib/ProForm/components/render/RenderFields.js +0 -6
- package/lib/ProForm/components/render/propsType.d.ts +4 -0
- package/lib/ProForm/index.js +7 -4
- package/lib/ProForm/propsType.d.ts +4 -0
- package/lib/ProForm/utils/index.d.ts +1 -1
- package/lib/ProForm/utils/index.js +5 -2
- package/lib/ProForm/utils/useForm.d.ts +7 -1
- package/lib/ProForm/utils/useForm.js +59 -6
- package/lib/ProTooltip/index.js +14 -14
- package/lib/ProTreeModal/components/List.js +106 -15
- package/lib/ProTreeModal/components/Tree.js +4 -2
- package/lib/ProTreeModal/index.js +24 -19
- package/lib/ProTreeModal/style/index.less +6 -0
- package/package.json +1 -1
package/dist/index.esm.css
CHANGED
|
@@ -3473,6 +3473,10 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
|
|
|
3473
3473
|
width: 0;
|
|
3474
3474
|
height: 0;
|
|
3475
3475
|
}
|
|
3476
|
+
.pro-tree-modal-box .pro-tree-modal-tree-warp ::-webkit-scrollbar {
|
|
3477
|
+
width: 16px;
|
|
3478
|
+
height: auto;
|
|
3479
|
+
}
|
|
3476
3480
|
.pro-tree-modal-cascader-box {
|
|
3477
3481
|
width: 592px;
|
|
3478
3482
|
}
|
package/dist/less.esm.css
CHANGED
|
@@ -3473,6 +3473,10 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
|
|
|
3473
3473
|
width: 0;
|
|
3474
3474
|
height: 0;
|
|
3475
3475
|
}
|
|
3476
|
+
.pro-tree-modal-box .pro-tree-modal-tree-warp ::-webkit-scrollbar {
|
|
3477
|
+
width: 16px;
|
|
3478
|
+
height: auto;
|
|
3479
|
+
}
|
|
3476
3480
|
.pro-tree-modal-cascader-box {
|
|
3477
3481
|
width: 592px;
|
|
3478
3482
|
}
|
|
@@ -75,7 +75,7 @@ export var ProConfigProvider = function ProConfigProvider(props) {
|
|
|
75
75
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
76
76
|
state = _useReducer2[0],
|
|
77
77
|
dispatch = _useReducer2[1];
|
|
78
|
-
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);
|
|
78
|
+
var enumRes = 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);
|
|
79
79
|
useEffect(function () {
|
|
80
80
|
// 本地配置取出
|
|
81
81
|
var localConfigStr = localStorage.getItem('localConfig');
|
|
@@ -93,6 +93,11 @@ export var ProConfigProvider = function ProConfigProvider(props) {
|
|
|
93
93
|
// 设置默认语言
|
|
94
94
|
setLanguage(props === null || props === void 0 ? void 0 : props.locale);
|
|
95
95
|
}
|
|
96
|
+
useEffect(function () {
|
|
97
|
+
if (enumRes === null || enumRes === void 0 ? void 0 : enumRes.data) {
|
|
98
|
+
(props === null || props === void 0 ? void 0 : props.onSuccess) && (props === null || props === void 0 ? void 0 : props.onSuccess(enumRes === null || enumRes === void 0 ? void 0 : enumRes.data, enumRes === null || enumRes === void 0 ? void 0 : enumRes.params));
|
|
99
|
+
}
|
|
100
|
+
}, [enumRes === null || enumRes === void 0 ? void 0 : enumRes.loading]);
|
|
96
101
|
return _jsx(ProConfigContext.Provider, {
|
|
97
102
|
value: {
|
|
98
103
|
state: merge(state, props.value),
|
package/es/ProEditTable/index.js
CHANGED
|
@@ -276,7 +276,8 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
|
276
276
|
return transformColumns(columns, config);
|
|
277
277
|
}, [valueChangeRef.current, disabled, forceUpdate, columns, page, actionProps, editingKeys, cellNamePath]);
|
|
278
278
|
useEffect(function () {
|
|
279
|
-
var
|
|
279
|
+
var _value$every;
|
|
280
|
+
var isAllHasKey = value === null || value === void 0 ? void 0 : (_value$every = value.every) === null || _value$every === void 0 ? void 0 : _value$every.call(value, function (item) {
|
|
280
281
|
return item.rowKey;
|
|
281
282
|
});
|
|
282
283
|
// 初始化默认生成row-key
|
|
@@ -204,9 +204,13 @@ export var actions = {
|
|
|
204
204
|
top: insertType === 'before' ? -10000 : 10000,
|
|
205
205
|
behavior: 'smooth'
|
|
206
206
|
});
|
|
207
|
-
|
|
207
|
+
if (!virtualKey) {
|
|
208
|
+
_context2.next = 15;
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
_context2.next = 15;
|
|
208
212
|
return form.validateFields([name]);
|
|
209
|
-
case
|
|
213
|
+
case 15:
|
|
210
214
|
case "end":
|
|
211
215
|
return _context2.stop();
|
|
212
216
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ProEnumConfig } from '../propsType';
|
|
2
2
|
import '../utils/eventCenter';
|
|
3
|
-
declare const useEnumRequest: (props: ProEnumConfig, dispatch: any) =>
|
|
3
|
+
declare const useEnumRequest: (props: ProEnumConfig, dispatch: any) => import("ahooks/lib/useRequest/src/types").Result<any, any>;
|
|
4
4
|
export default useEnumRequest;
|
|
@@ -45,120 +45,119 @@ var useEnumRequest = function useEnumRequest(props, dispatch) {
|
|
|
45
45
|
console.info('proEnum:', msg);
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
103
|
-
res.data = response;
|
|
104
|
-
}
|
|
105
|
-
cacheData = getEnumData(storage, cacheKey, baseEnumStorage) || {
|
|
106
|
-
data: {}
|
|
107
|
-
}; // 合并缓存数据
|
|
108
|
-
res.data = _objectSpread(_objectSpread({}, cacheData === null || cacheData === void 0 ? void 0 : cacheData.data), res.data);
|
|
109
|
-
setEnumData(storage, cacheKey, res);
|
|
110
|
-
// 同步数据到全局
|
|
111
|
-
dispatch({
|
|
112
|
-
type: 'setProEnumDic',
|
|
113
|
-
payload: _objectSpread(_objectSpread(_objectSpread({}, dics), dataSource), res.data)
|
|
48
|
+
var enumRes = useRequestFunc(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, _objectSpread(_objectSpread({
|
|
49
|
+
manual: true,
|
|
50
|
+
cacheKey: cacheKey,
|
|
51
|
+
cacheTime: -1,
|
|
52
|
+
staleTime: 6e4 * 60
|
|
53
|
+
}, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options), {}, {
|
|
54
|
+
setCache: function () {
|
|
55
|
+
var _setCache = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(res) {
|
|
56
|
+
var response, _locale$ProEnum2, _useRequest$options, ignoreCodes, cacheData;
|
|
57
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
58
|
+
while (1) switch (_context.prev = _context.next) {
|
|
59
|
+
case 0:
|
|
60
|
+
response = res.data;
|
|
61
|
+
if (!(transformResponse && typeof transformResponse === 'function')) {
|
|
62
|
+
_context.next = 10;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
_context.next = 4;
|
|
66
|
+
return transformResponse(res.data);
|
|
67
|
+
case 4:
|
|
68
|
+
response = _context.sent;
|
|
69
|
+
if (!(_typeof(response) !== 'object' || response == null)) {
|
|
70
|
+
_context.next = 9;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
throw new Error(locale === null || locale === void 0 ? void 0 : (_locale$ProEnum2 = locale.ProEnum) === null || _locale$ProEnum2 === void 0 ? void 0 : _locale$ProEnum2.errorMessage);
|
|
74
|
+
case 9:
|
|
75
|
+
res.data = response;
|
|
76
|
+
case 10:
|
|
77
|
+
if (!(_typeof(response) !== 'object' || response === null)) {
|
|
78
|
+
_context.next = 12;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
throw Error('response enum data must be object');
|
|
82
|
+
case 12:
|
|
83
|
+
if (!(Object.keys(response).length === 0)) {
|
|
84
|
+
_context.next = 14;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
throw Error('Please return valid enumeration data');
|
|
88
|
+
case 14:
|
|
89
|
+
// 只返回fieldNames对象的key
|
|
90
|
+
if (clear) {
|
|
91
|
+
// 忽略清洗的 codes
|
|
92
|
+
ignoreCodes = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options = useRequest.options) === null || _useRequest$options === void 0 ? void 0 : _useRequest$options.ignoreCodes) || [];
|
|
93
|
+
Object.keys(response).forEach(function (key) {
|
|
94
|
+
var options = _toConsumableArray(response[key]) || [];
|
|
95
|
+
if (ignoreCodes.includes(key)) {
|
|
96
|
+
response[key] = options;
|
|
97
|
+
} else {
|
|
98
|
+
response[key] = options.map(function (item) {
|
|
99
|
+
return cacheFieldNames(fieldNames, item);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
114
102
|
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
setTimeout(function () {
|
|
144
|
-
var _locale$ProEnum4;
|
|
145
|
-
window.eventCenter.publish('zat-design-pro-component-event', res.data);
|
|
146
|
-
logDebug(locale === null || locale === void 0 ? void 0 : (_locale$ProEnum4 = locale.ProEnum) === null || _locale$ProEnum4 === void 0 ? void 0 : _locale$ProEnum4.mainInitByCache);
|
|
147
|
-
}, 10000);
|
|
148
|
-
}
|
|
149
|
-
return res;
|
|
150
|
-
},
|
|
151
|
-
onSuccess: function onSuccess(res) {
|
|
152
|
-
var _res$status = res.status,
|
|
153
|
-
status = _res$status === void 0 ? 200 : _res$status,
|
|
154
|
-
msg = res.message;
|
|
155
|
-
if (status !== 200) {
|
|
156
|
-
var _locale$ProEnum5;
|
|
157
|
-
throw new Error(locale === null || locale === void 0 ? void 0 : (_locale$ProEnum5 = locale.ProEnum) === null || _locale$ProEnum5 === void 0 ? void 0 : _locale$ProEnum5.requestError);
|
|
158
|
-
}
|
|
103
|
+
res.data = response;
|
|
104
|
+
}
|
|
105
|
+
cacheData = getEnumData(storage, cacheKey, baseEnumStorage) || {
|
|
106
|
+
data: {}
|
|
107
|
+
}; // 合并缓存数据
|
|
108
|
+
res.data = _objectSpread(_objectSpread({}, cacheData === null || cacheData === void 0 ? void 0 : cacheData.data), res.data);
|
|
109
|
+
setEnumData(storage, cacheKey, res);
|
|
110
|
+
// 同步数据到全局
|
|
111
|
+
dispatch({
|
|
112
|
+
type: 'setProEnumDic',
|
|
113
|
+
payload: _objectSpread(_objectSpread(_objectSpread({}, dics), dataSource), res.data)
|
|
114
|
+
});
|
|
115
|
+
if (main) {
|
|
116
|
+
setTimeout(function () {
|
|
117
|
+
var _locale$ProEnum3;
|
|
118
|
+
window.eventCenter.publish('zat-design-pro-component-event', res.data);
|
|
119
|
+
logDebug(locale === null || locale === void 0 ? void 0 : (_locale$ProEnum3 = locale.ProEnum) === null || _locale$ProEnum3 === void 0 ? void 0 : _locale$ProEnum3.mainInitByRequest);
|
|
120
|
+
}, 10000);
|
|
121
|
+
}
|
|
122
|
+
return _context.abrupt("return", res);
|
|
123
|
+
case 21:
|
|
124
|
+
case "end":
|
|
125
|
+
return _context.stop();
|
|
126
|
+
}
|
|
127
|
+
}, _callee);
|
|
128
|
+
}));
|
|
129
|
+
function setCache(_x) {
|
|
130
|
+
return _setCache.apply(this, arguments);
|
|
159
131
|
}
|
|
160
|
-
|
|
161
|
-
|
|
132
|
+
return setCache;
|
|
133
|
+
}(),
|
|
134
|
+
getCache: function getCache() {
|
|
135
|
+
var res = getEnumData(storage, cacheKey, baseEnumStorage) || {
|
|
136
|
+
data: {}
|
|
137
|
+
};
|
|
138
|
+
dispatch({
|
|
139
|
+
type: 'setProEnumDic',
|
|
140
|
+
payload: _objectSpread(_objectSpread(_objectSpread({}, dics), dataSource), res === null || res === void 0 ? void 0 : res.data)
|
|
141
|
+
});
|
|
142
|
+
if (main) {
|
|
143
|
+
setTimeout(function () {
|
|
144
|
+
var _locale$ProEnum4;
|
|
145
|
+
window.eventCenter.publish('zat-design-pro-component-event', res.data);
|
|
146
|
+
logDebug(locale === null || locale === void 0 ? void 0 : (_locale$ProEnum4 = locale.ProEnum) === null || _locale$ProEnum4 === void 0 ? void 0 : _locale$ProEnum4.mainInitByCache);
|
|
147
|
+
}, 10000);
|
|
148
|
+
}
|
|
149
|
+
return res;
|
|
150
|
+
},
|
|
151
|
+
onSuccess: function onSuccess(res) {
|
|
152
|
+
var _res$status = res.status,
|
|
153
|
+
status = _res$status === void 0 ? 200 : _res$status,
|
|
154
|
+
msg = res.message;
|
|
155
|
+
if (status !== 200) {
|
|
156
|
+
var _locale$ProEnum5;
|
|
157
|
+
throw new Error(locale === null || locale === void 0 ? void 0 : (_locale$ProEnum5 = locale.ProEnum) === null || _locale$ProEnum5 === void 0 ? void 0 : _locale$ProEnum5.requestError);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}));
|
|
162
161
|
var mergeData = /*#__PURE__*/function () {
|
|
163
162
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
164
163
|
var cacheData, _useRequest$options2, _useRequest$options3, enumData, cacheCodes, codes, ignoreCodes, diff, response, res, _locale$ProEnum6;
|
|
@@ -258,7 +257,7 @@ var useEnumRequest = function useEnumRequest(props, dispatch) {
|
|
|
258
257
|
window.localStorage.removeItem(cacheKey);
|
|
259
258
|
window.sessionStorage.removeItem(cacheKey);
|
|
260
259
|
}
|
|
261
|
-
run(defaultParams);
|
|
260
|
+
enumRes.run(defaultParams);
|
|
262
261
|
// TODO 这段代码目前看起来是没啥用的、没起到作用
|
|
263
262
|
mergeData();
|
|
264
263
|
} else if (Object.keys(dataSource)) {
|
|
@@ -304,5 +303,6 @@ var useEnumRequest = function useEnumRequest(props, dispatch) {
|
|
|
304
303
|
window.eventCenter.unsubscribe('zat-design-pro-component-event', shareProEnumDic);
|
|
305
304
|
};
|
|
306
305
|
}, []);
|
|
306
|
+
return enumRes;
|
|
307
307
|
};
|
|
308
308
|
export default useEnumRequest;
|
|
@@ -709,7 +709,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
709
709
|
} : queryBean;
|
|
710
710
|
var nextParams = transformParams ? transformParams(params) : params;
|
|
711
711
|
run(nextParams);
|
|
712
|
-
},
|
|
712
|
+
}, 1000),
|
|
713
713
|
style: {
|
|
714
714
|
width: isView || disabled ? '100%' : 'calc(100% - 30px)'
|
|
715
715
|
}
|
|
@@ -129,7 +129,10 @@ var ProNumberRange = function ProNumberRange(props) {
|
|
|
129
129
|
case 'amount':
|
|
130
130
|
valueProps = {
|
|
131
131
|
formatter: function formatter(value) {
|
|
132
|
-
return
|
|
132
|
+
return typeof value === 'number' || value ? Number(value).toLocaleString('zh-CN', {
|
|
133
|
+
minimumFractionDigits: precision !== null && precision !== void 0 ? precision : null,
|
|
134
|
+
maximumFractionDigits: precision !== null && precision !== void 0 ? precision : 9
|
|
135
|
+
}) : value;
|
|
133
136
|
},
|
|
134
137
|
parser: function parser(value) {
|
|
135
138
|
return value.replace(/\$\s?|(,*)/g, '');
|
|
@@ -353,7 +353,13 @@ var Render = function Render(props) {
|
|
|
353
353
|
mark: 'pro_table_render',
|
|
354
354
|
render: function render(inputProps, doms) {
|
|
355
355
|
return _jsxs(_Fragment, {
|
|
356
|
-
children: [
|
|
356
|
+
children: [_jsx(_Space, {
|
|
357
|
+
size: 0,
|
|
358
|
+
style: {
|
|
359
|
+
marginTop: 8
|
|
360
|
+
},
|
|
361
|
+
children: formItemProps.above
|
|
362
|
+
}), _jsxs("div", {
|
|
357
363
|
style: {
|
|
358
364
|
display: 'flex',
|
|
359
365
|
alignItems: 'center'
|
|
@@ -383,7 +389,7 @@ var Render = function Render(props) {
|
|
|
383
389
|
if (originComponent) {
|
|
384
390
|
delete childProps.otherProps;
|
|
385
391
|
}
|
|
386
|
-
var child = /*#__PURE__*/React.isValidElement(AutoComponent) ? ( /*#__PURE__*/React.cloneElement(AutoComponent, childProps)) : _jsx(AutoComponent, _objectSpread(_objectSpread({}, omit(lastComponentProps, lastComponentPropsFilter)), {}, {
|
|
392
|
+
var child = /*#__PURE__*/React.isValidElement(AutoComponent) ? ( /*#__PURE__*/React.cloneElement(AutoComponent, childProps)) : _jsx(AutoComponent, _objectSpread(_objectSpread({}, omit(lastComponentProps, [].concat(lastComponentPropsFilter, ['debounceWait']))), {}, {
|
|
387
393
|
otherProps: _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
388
394
|
show: show,
|
|
389
395
|
disabled: lastDisabled,
|
|
@@ -186,12 +186,6 @@ var RenderFields = function RenderFields(props) {
|
|
|
186
186
|
globalControl: globalControl,
|
|
187
187
|
formDisabled: formDisabled
|
|
188
188
|
};
|
|
189
|
-
if (outerClearNotShow !== false && show === false && (column === null || column === void 0 ? void 0 : column.name) && form.getFieldValue(column === null || column === void 0 ? void 0 : column.name)) {
|
|
190
|
-
setTimeout(function () {
|
|
191
|
-
form.resetFields([column === null || column === void 0 ? void 0 : column.name]);
|
|
192
|
-
}, 200);
|
|
193
|
-
return null;
|
|
194
|
-
}
|
|
195
189
|
return _jsx(FieldProvider, {
|
|
196
190
|
value: otherProps,
|
|
197
191
|
children: _jsx(Render, {
|
|
@@ -214,6 +214,8 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
|
|
|
214
214
|
before?: string | React.ReactNode;
|
|
215
215
|
/** 表单后缀信息 */
|
|
216
216
|
after?: string | React.ReactNode;
|
|
217
|
+
/** 表单上方辅助信息 */
|
|
218
|
+
above?: string | React.ReactNode;
|
|
217
219
|
/** 表单下方辅助信息 */
|
|
218
220
|
extra?: string | React.ReactNode;
|
|
219
221
|
/** 是否固定字段, 不隐藏 */
|
|
@@ -244,6 +246,8 @@ export interface RenderProps<Values = any> {
|
|
|
244
246
|
before?: string | React.ReactNode;
|
|
245
247
|
/** 表单后缀信息 */
|
|
246
248
|
after?: string | React.ReactNode;
|
|
249
|
+
/** 表单上方辅助信息 */
|
|
250
|
+
above?: string | React.ReactNode;
|
|
247
251
|
/** 表单下方辅助信息 */
|
|
248
252
|
extra?: string | React.ReactNode;
|
|
249
253
|
parentNames?: string;
|
package/es/ProForm/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import _Space from "antd/es/space";
|
|
|
11
11
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
12
12
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
13
13
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
14
|
-
var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "originalValues", "submitOnEnter", "clearNotShow", "initialValues", "requiredOnView", "formId", "required", "originalDiffTip", "formKey", "globalControl", "scrollToError"];
|
|
14
|
+
var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "originalValues", "submitOnEnter", "clearNotShow", "initialValues", "requiredOnView", "formId", "required", "originalDiffTip", "formKey", "globalControl", "scrollToError", "optimize"];
|
|
15
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
16
|
import { DoubleLeftOutlined } from '@ant-design/icons';
|
|
17
17
|
import classnames from 'classnames';
|
|
@@ -67,6 +67,8 @@ var ProForm = function ProForm(props, ref) {
|
|
|
67
67
|
globalControl = props.globalControl,
|
|
68
68
|
_props$scrollToError = props.scrollToError,
|
|
69
69
|
scrollToError = _props$scrollToError === void 0 ? true : _props$scrollToError,
|
|
70
|
+
_props$optimize = props.optimize,
|
|
71
|
+
optimize = _props$optimize === void 0 ? false : _props$optimize,
|
|
70
72
|
otherProps = _objectWithoutProperties(props, _excluded);
|
|
71
73
|
var _useProConfig = useProConfig(),
|
|
72
74
|
state = _useProConfig.state,
|
|
@@ -74,7 +76,8 @@ var ProForm = function ProForm(props, ref) {
|
|
|
74
76
|
var config = state.ProForm,
|
|
75
77
|
forms = state.forms;
|
|
76
78
|
var _useForm = useForm((_forms$formKey = forms[formKey]) !== null && _forms$formKey !== void 0 ? _forms$formKey : originForm, {
|
|
77
|
-
scrollToError: scrollToError
|
|
79
|
+
scrollToError: scrollToError,
|
|
80
|
+
optimize: optimize
|
|
78
81
|
}),
|
|
79
82
|
_useForm2 = _slicedToArray(_useForm, 1),
|
|
80
83
|
form = _useForm2[0];
|
|
@@ -167,7 +170,7 @@ var ProForm = function ProForm(props, ref) {
|
|
|
167
170
|
// 暂时通过'-'区分组合组件字段和普通字段
|
|
168
171
|
var keys = Object.keys(changedValue);
|
|
169
172
|
if (!keys.length) {
|
|
170
|
-
onValuesChange(filterInternalFields(changedValue), form.getFieldsValue());
|
|
173
|
+
onValuesChange(filterInternalFields(changedValue, optimize), form.getFieldsValue());
|
|
171
174
|
} else {
|
|
172
175
|
var values = keys.map(function (key) {
|
|
173
176
|
if (key.includes('-')) {
|
|
@@ -179,7 +182,7 @@ var ProForm = function ProForm(props, ref) {
|
|
|
179
182
|
}
|
|
180
183
|
return {};
|
|
181
184
|
});
|
|
182
|
-
onValuesChange(filterInternalFields(merge.apply(void 0, [changedValue].concat(_toConsumableArray(values)))), form.getFieldsValue());
|
|
185
|
+
onValuesChange(filterInternalFields(merge.apply(void 0, [changedValue].concat(_toConsumableArray(values))), optimize), form.getFieldsValue());
|
|
183
186
|
}
|
|
184
187
|
};
|
|
185
188
|
// 包装一层兼容 names 改变
|
|
@@ -76,6 +76,10 @@ export interface ProFormProps<Values = any> extends FormProps<Values> {
|
|
|
76
76
|
required?: boolean | boolean[];
|
|
77
77
|
originalDiffTip?: boolean;
|
|
78
78
|
scrollToError?: boolean;
|
|
79
|
+
/** 性能模式,谨慎使用,默认不开启
|
|
80
|
+
* 1. 开启不过滤names的中间态值
|
|
81
|
+
*/
|
|
82
|
+
optimize?: boolean;
|
|
79
83
|
}
|
|
80
84
|
export interface Transform<T = any> {
|
|
81
85
|
normalize?: (value: StoreValue, prevValue: StoreValue, allValues: Store) => StoreValue;
|
|
@@ -28,7 +28,7 @@ export declare const isUpperCase: (type: string, upperCase: boolean) => any;
|
|
|
28
28
|
export declare const weedOutProps: (data: Record<string, any>, keys: string[]) => {}[];
|
|
29
29
|
export declare const diffField: (prevValues: any, curValues: any, names: NamePath[]) => boolean;
|
|
30
30
|
export declare const splitNameStr: (name: string) => string[][];
|
|
31
|
-
export declare const filterInternalFields: (values: any) => any;
|
|
31
|
+
export declare const filterInternalFields: (values: any, optimize?: boolean) => any;
|
|
32
32
|
export declare const getAllNamePath: (object: Record<string, any>, currentPath?: InternalNamePath) => InternalNamePath[];
|
|
33
33
|
export declare const isNullValue: (value: any) => boolean;
|
|
34
34
|
/**
|
|
@@ -4,8 +4,8 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
4
4
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
6
|
import React, { useState } from 'react';
|
|
7
|
-
import _, { isObject, isFunction, cloneDeep, get, set, omit, isNaN } from 'lodash';
|
|
8
7
|
import moment from 'moment';
|
|
8
|
+
import _, { isObject, isFunction, cloneDeep, get, set, omit, isNaN } from 'lodash';
|
|
9
9
|
export var getLayout = function getLayout(params) {
|
|
10
10
|
var _params$span = params.span,
|
|
11
11
|
span = _params$span === void 0 ? 8 : _params$span,
|
|
@@ -121,7 +121,10 @@ export var splitNameStr = function splitNameStr(name) {
|
|
|
121
121
|
});
|
|
122
122
|
};
|
|
123
123
|
// 过滤掉字段名中包含 '-' 的字段
|
|
124
|
-
export var filterInternalFields = function filterInternalFields(values) {
|
|
124
|
+
export var filterInternalFields = function filterInternalFields(values, optimize) {
|
|
125
|
+
if (optimize) {
|
|
126
|
+
return values;
|
|
127
|
+
}
|
|
125
128
|
var nextValues = values;
|
|
126
129
|
// fix: braft-editor对象不可遍历 Moment不过滤
|
|
127
130
|
if ((values === null || values === void 0 ? void 0 : values._immutable) || moment.isMoment(values)) {
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { FormInstance } from 'antd';
|
|
2
|
+
import { NamePath } from 'antd/es/form/interface';
|
|
3
|
+
import { ValuedNotifyInfo } from 'rc-field-form/es/interface';
|
|
2
4
|
type ModifiedFormInstance<T> = FormInstance<T> & {
|
|
3
5
|
isModified?: boolean;
|
|
6
|
+
/** 默认清空设置值的报错状态 */
|
|
7
|
+
setFieldValue: (name: NamePath, value: any, info?: ValuedNotifyInfo) => void;
|
|
8
|
+
_init?: boolean;
|
|
4
9
|
};
|
|
5
10
|
interface FormInstanceOption {
|
|
6
11
|
scrollToError?: boolean;
|
|
12
|
+
optimize?: boolean;
|
|
7
13
|
}
|
|
8
|
-
export declare const useForm: <T>(originForm
|
|
14
|
+
export declare const useForm: <T>(originForm?: FormInstanceOption | ModifiedFormInstance<T>, options?: FormInstanceOption) => [ModifiedFormInstance<T>];
|
|
9
15
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
3
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
4
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
@@ -7,22 +8,32 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
7
8
|
import { filterInternalFields } from './index';
|
|
8
9
|
import { handleScrollToError } from '../../ProEditTable/utils/tools';
|
|
9
10
|
export var useForm = function useForm(originForm, options) {
|
|
10
|
-
|
|
11
|
+
// 如果没有form实例可以直接把options放在第一个参数位置
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
var _originForm = (originForm === null || originForm === void 0 ? void 0 : originForm._init) ? originForm : undefined;
|
|
14
|
+
var _options =
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
options || originForm && !(originForm === null || originForm === void 0 ? void 0 : originForm._init) ? originForm : undefined;
|
|
17
|
+
var _ref = _options || {},
|
|
11
18
|
_ref$scrollToError = _ref.scrollToError,
|
|
12
|
-
scrollToError = _ref$scrollToError === void 0 ? true : _ref$scrollToError
|
|
13
|
-
|
|
19
|
+
scrollToError = _ref$scrollToError === void 0 ? true : _ref$scrollToError,
|
|
20
|
+
optimize = _ref.optimize;
|
|
21
|
+
var _Form$useForm = _Form.useForm(_originForm),
|
|
14
22
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
15
23
|
form = _Form$useForm2[0];
|
|
16
24
|
var getFieldsValue = form.getFieldsValue,
|
|
17
25
|
validateFields = form.validateFields,
|
|
18
|
-
isModified = form.isModified
|
|
26
|
+
isModified = form.isModified,
|
|
27
|
+
setFields = form.setFields,
|
|
28
|
+
getFieldsError = form.getFieldsError,
|
|
29
|
+
setFieldsValue = form.setFieldsValue;
|
|
19
30
|
if (isModified) return [form];
|
|
20
31
|
// @ts-ignore
|
|
21
32
|
var _getFieldsValue = function _getFieldsValue(nameList, filterFunc) {
|
|
22
33
|
// 全部查询
|
|
23
34
|
if (nameList !== true) {
|
|
24
35
|
var values = getFieldsValue(nameList || true, filterFunc);
|
|
25
|
-
return filterInternalFields(values);
|
|
36
|
+
return filterInternalFields(values, optimize);
|
|
26
37
|
}
|
|
27
38
|
return getFieldsValue(nameList, filterFunc);
|
|
28
39
|
};
|
|
@@ -70,7 +81,7 @@ export var useForm = function useForm(originForm, options) {
|
|
|
70
81
|
// delete rest[0].recursive;
|
|
71
82
|
_context.next = 11;
|
|
72
83
|
return validateFields.apply(void 0, [validateNames].concat(rest)).then(function (values) {
|
|
73
|
-
return filterInternalFields(values);
|
|
84
|
+
return filterInternalFields(values, optimize);
|
|
74
85
|
});
|
|
75
86
|
case 11:
|
|
76
87
|
return _context.abrupt("return", _context.sent);
|
|
@@ -102,6 +113,48 @@ export var useForm = function useForm(originForm, options) {
|
|
|
102
113
|
return _ref2.apply(this, arguments);
|
|
103
114
|
};
|
|
104
115
|
}();
|
|
116
|
+
var _setFieldValue = function _setFieldValue(name, value, info) {
|
|
117
|
+
if (info) {
|
|
118
|
+
setFields([_objectSpread({
|
|
119
|
+
name: name,
|
|
120
|
+
value: value
|
|
121
|
+
}, info)]);
|
|
122
|
+
} else {
|
|
123
|
+
setFields([{
|
|
124
|
+
name: name,
|
|
125
|
+
value: value,
|
|
126
|
+
errors: [],
|
|
127
|
+
warnings: []
|
|
128
|
+
}]);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
var _setFieldsValue = function _setFieldsValue(values) {
|
|
132
|
+
var errors = getFieldsError();
|
|
133
|
+
var errorNames = errors.reduce(function (acc, entry) {
|
|
134
|
+
if (entry.errors.length > 0) {
|
|
135
|
+
acc.push(entry.name[0]);
|
|
136
|
+
}
|
|
137
|
+
return acc;
|
|
138
|
+
}, []) || [];
|
|
139
|
+
if (errorNames.length) {
|
|
140
|
+
errorNames.forEach(function (errorName) {
|
|
141
|
+
// 只处理names的报错
|
|
142
|
+
if (errorName.includes('-')) {
|
|
143
|
+
setFields([{
|
|
144
|
+
name: errorName,
|
|
145
|
+
errors: [],
|
|
146
|
+
warnings: []
|
|
147
|
+
}]);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
setFieldsValue(values);
|
|
151
|
+
} else {
|
|
152
|
+
setFieldsValue(values);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
form.getFieldsValue = _getFieldsValue;
|
|
156
|
+
form.setFieldValue = _setFieldValue;
|
|
157
|
+
form.setFieldsValue = _setFieldsValue;
|
|
105
158
|
form.getFieldsValue = _getFieldsValue;
|
|
106
159
|
form.validateFields = _validateFields;
|
|
107
160
|
form.isModified = true;
|