@teamix/pro 1.2.34 → 1.3.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/pro.css +1 -1
- package/dist/pro.js +1542 -1149
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/actions/dialog-form.d.ts +9 -4
- package/es/actions/dialog-form.js +16 -9
- package/es/form/Components/ProField/mapDateFormat.d.ts +3 -0
- package/es/form/Components/ProField/mapDateFormat.js +113 -0
- package/es/form/Filter/AdvancedFilter.js +4 -4
- package/es/form/Filter/LightFilter.js +22 -15
- package/es/form/Filter/index.js +171 -133
- package/es/form/Filter/useSpecialProps.d.ts +1 -1
- package/es/form/Filter/useSpecialProps.js +9 -9
- package/es/form/ProForm/customComponent.js +2 -1
- package/es/form/ProForm/index.scss +8 -8
- package/es/form/SchemaForm/index.js +2 -2
- package/es/form/SchemaForm/initializeRequest.js +1 -2
- package/es/form/SchemaForm/reactions.d.ts +2 -2
- package/es/form/SchemaForm/reactions.js +32 -21
- package/es/form/fieldTypeMap.d.ts +3 -0
- package/es/form/fieldTypeMap.js +3 -0
- package/es/form/typing.d.ts +8 -1
- package/es/index.d.ts +4 -4
- package/es/index.js +4 -4
- package/es/nocode/configurators/PageHeader.js +2 -2
- package/es/page-header/index.js +7 -3
- package/es/table/components/Layout/index.js +2 -2
- package/es/table/components/Pagination/index.js +11 -1
- package/es/table/components/ToolBar/DensityIcon.js +5 -3
- package/es/table/components/ToolBar/FilterColumnIcon.js +12 -3
- package/es/table/components/ToolBar/Fullscreen.js +6 -6
- package/es/table/components/ToolBar/index.scss +2 -2
- package/es/table/index.js +40 -21
- package/es/table/index.scss +6 -0
- package/es/table/typing.d.ts +13 -6
- package/es/table/utils/columnRender.js +6 -0
- package/es/timeline/ProTimeLineItem/index.d.ts +5 -0
- package/es/{step/ProStepItem/components/VerStepItem → timeline/ProTimeLineItem}/index.js +59 -72
- package/es/{step/ProStepItem/components/VerStepItem → timeline/ProTimeLineItem}/index.scss +34 -86
- package/es/timeline/index.d.ts +10 -0
- package/es/{step → timeline}/index.js +33 -57
- package/es/timeline/index.scss +7 -0
- package/es/timeline/typing.d.ts +101 -0
- package/es/{step → timeline}/typing.js +0 -0
- package/lib/actions/dialog-form.d.ts +9 -4
- package/lib/actions/dialog-form.js +16 -9
- package/lib/form/Components/ProField/mapDateFormat.d.ts +3 -0
- package/lib/form/Components/ProField/mapDateFormat.js +125 -0
- package/lib/form/Filter/AdvancedFilter.js +4 -4
- package/lib/form/Filter/LightFilter.js +21 -15
- package/lib/form/Filter/index.js +170 -132
- package/lib/form/Filter/useSpecialProps.d.ts +1 -1
- package/lib/form/Filter/useSpecialProps.js +8 -8
- package/lib/form/ProForm/customComponent.js +3 -1
- package/lib/form/ProForm/index.scss +8 -8
- package/lib/form/SchemaForm/index.js +2 -2
- package/lib/form/SchemaForm/initializeRequest.js +1 -2
- package/lib/form/SchemaForm/reactions.d.ts +2 -2
- package/lib/form/SchemaForm/reactions.js +31 -20
- package/lib/form/fieldTypeMap.d.ts +3 -0
- package/lib/form/fieldTypeMap.js +5 -1
- package/lib/form/typing.d.ts +8 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.js +10 -10
- package/lib/nocode/configurators/PageHeader.js +2 -2
- package/lib/page-header/index.js +6 -2
- package/lib/table/components/Layout/index.js +2 -2
- package/lib/table/components/Pagination/index.js +10 -0
- package/lib/table/components/ToolBar/DensityIcon.js +5 -3
- package/lib/table/components/ToolBar/FilterColumnIcon.js +11 -2
- package/lib/table/components/ToolBar/Fullscreen.js +6 -6
- package/lib/table/components/ToolBar/index.scss +2 -2
- package/lib/table/index.js +40 -21
- package/lib/table/index.scss +6 -0
- package/lib/table/typing.d.ts +13 -6
- package/lib/table/utils/columnRender.js +6 -0
- package/lib/timeline/ProTimeLineItem/index.d.ts +5 -0
- package/lib/{step/ProStepItem/components/VerStepItem → timeline/ProTimeLineItem}/index.js +58 -72
- package/lib/{step/ProStepItem/components/VerStepItem → timeline/ProTimeLineItem}/index.scss +34 -86
- package/lib/timeline/index.d.ts +10 -0
- package/lib/{step → timeline}/index.js +38 -58
- package/lib/timeline/index.scss +7 -0
- package/lib/timeline/typing.d.ts +101 -0
- package/lib/{step → timeline}/typing.js +0 -0
- package/package.json +1 -1
- package/es/step/ProStepItem/components/HozStepItem/index.d.ts +0 -5
- package/es/step/ProStepItem/components/HozStepItem/index.js +0 -235
- package/es/step/ProStepItem/components/HozStepItem/index.scss +0 -279
- package/es/step/ProStepItem/components/VerStepItem/index.d.ts +0 -5
- package/es/step/ProStepItem/index.d.ts +0 -4
- package/es/step/ProStepItem/index.js +0 -57
- package/es/step/index.d.ts +0 -9
- package/es/step/typing.d.ts +0 -96
- package/lib/step/ProStepItem/components/HozStepItem/index.d.ts +0 -5
- package/lib/step/ProStepItem/components/HozStepItem/index.js +0 -258
- package/lib/step/ProStepItem/components/HozStepItem/index.scss +0 -279
- package/lib/step/ProStepItem/components/VerStepItem/index.d.ts +0 -5
- package/lib/step/ProStepItem/index.d.ts +0 -4
- package/lib/step/ProStepItem/index.js +0 -69
- package/lib/step/index.d.ts +0 -9
- package/lib/step/typing.d.ts +0 -96
package/es/form/Filter/index.js
CHANGED
@@ -40,7 +40,7 @@ import debounce from 'lodash.debounce';
|
|
40
40
|
import { Tag } from '@alicloudfe/components';
|
41
41
|
import { createForm, onFormReact, onFormInputChange } from '@formily/core';
|
42
42
|
import { toJS } from '@formily/reactive';
|
43
|
-
import { usePrefixCls,
|
43
|
+
import { usePrefixCls, isUsable, isNum, getValidValues } from '@teamix/utils';
|
44
44
|
import ProField from '../../field/index';
|
45
45
|
import fieldTypeMap from '../fieldTypeMap';
|
46
46
|
import { getFormDisplayValues } from '../ProForm/useFormDisplayValues';
|
@@ -67,16 +67,41 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
67
67
|
onInit = props.onInit,
|
68
68
|
onReset = props.onReset,
|
69
69
|
onExpand = props.onExpand,
|
70
|
-
otherProps = _objectWithoutProperties(props, _excluded);
|
70
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
71
71
|
|
72
|
+
var _useSpecialProps = useSpecialProps(props),
|
73
|
+
hasChangeDefault = _useSpecialProps.hasChangeDefault,
|
74
|
+
hasRequired = _useSpecialProps.hasRequired;
|
75
|
+
|
76
|
+
var _useState = useState(!!expand),
|
77
|
+
_useState2 = _slicedToArray(_useState, 2),
|
78
|
+
panelVisible = _useState2[0],
|
79
|
+
setPanelVisible = _useState2[1];
|
80
|
+
|
81
|
+
var _useState3 = useState([]),
|
82
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
83
|
+
tagDataSource = _useState4[0],
|
84
|
+
setTagDataSource = _useState4[1];
|
85
|
+
|
86
|
+
var filterItem = useRef([]);
|
87
|
+
var defaultForm = mode === 'panel' ? 'advanced' : 'simple';
|
88
|
+
var currentForm = useRef(defaultForm);
|
89
|
+
var activeFilterValueRef = useRef();
|
90
|
+
var prefixCls = usePrefixCls('', {
|
91
|
+
prefix: 'teamix-pro-form-query-filter'
|
92
|
+
});
|
93
|
+
/**
|
94
|
+
* 处理onInit与onFilter事件的触发问题
|
95
|
+
*/
|
72
96
|
|
73
|
-
var
|
97
|
+
var filterEnable = useRef('waiting');
|
98
|
+
|
99
|
+
var _onFormInit = function onFormInit(form, _ref) {
|
74
100
|
var initialRequest = _ref.initialRequest,
|
75
|
-
initialValues = _ref.initialValues
|
76
|
-
onInit = _ref.onInit;
|
101
|
+
initialValues = _ref.initialValues;
|
77
102
|
|
78
103
|
if (!form.mounted) {
|
79
|
-
// form的loading
|
104
|
+
// 借用form的loading属性来判断initialValues和initialRequest是否完成
|
80
105
|
form.setState({
|
81
106
|
loading: !!initialRequest || !!initialValues
|
82
107
|
});
|
@@ -84,32 +109,37 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
84
109
|
|
85
110
|
var loadingField = Object.values(form.fields).filter(function (field) {
|
86
111
|
return !!field.loading;
|
87
|
-
});
|
112
|
+
}); // 等待表单mounted + 字段loading结束 + form默认值初始化 => 表单初始化完成
|
88
113
|
|
89
|
-
if (form.mounted) {
|
90
|
-
|
91
|
-
// 仅执行一次onInit
|
92
|
-
_onFormInit = function onFormInit() {};
|
114
|
+
if (form.mounted && !loadingField.length && !form.loading) {
|
115
|
+
_onFormInit = function onFormInit() {}; // init后销毁 isFormInit 方法
|
93
116
|
|
94
|
-
var onInitResult = onInit === null || onInit === void 0 ? void 0 : onInit(toJS(form.values));
|
95
117
|
|
96
|
-
|
97
|
-
// 根据onInit返回值,判断是否使用该事件执行筛选,使用过则添加筛选标签
|
98
|
-
configFilterItem === null || configFilterItem === void 0 ? void 0 : configFilterItem(form);
|
99
|
-
configTag();
|
100
|
-
} // 防止onInit前后的无效onFilter
|
118
|
+
var values = getValidValues(form.values);
|
101
119
|
|
120
|
+
if (!isUsable(values) || !hasChangeDefault) {
|
121
|
+
// 表单无默认值 或 无触发onChange的默认值配置,不会触发onFilter内的onInit,所以主动触发onInit
|
122
|
+
filterEnable.current = 'filter';
|
123
|
+
setTimeout(function () {
|
124
|
+
onInit === null || onInit === void 0 ? void 0 : onInit(toJS(form.values));
|
125
|
+
}, 0);
|
102
126
|
|
103
|
-
if (
|
104
|
-
//
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
127
|
+
if (mode === 'panel') {
|
128
|
+
// 移除lightForm的默认值
|
129
|
+
// 设置Tag
|
130
|
+
configFilterItem(advancedForm);
|
131
|
+
|
132
|
+
if (!panelVisible) {
|
133
|
+
setTimeout(function () {
|
134
|
+
configTag();
|
135
|
+
}, 0);
|
136
|
+
}
|
109
137
|
}
|
138
|
+
} else {
|
139
|
+
filterEnable.current = 'initialized';
|
110
140
|
}
|
111
141
|
}
|
112
|
-
}; //
|
142
|
+
}; // 配置当前激活的form实例
|
113
143
|
|
114
144
|
|
115
145
|
var setCurrentForm = function setCurrentForm(formName) {
|
@@ -119,9 +149,11 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
119
149
|
var form = formMap[formName];
|
120
150
|
formRef.current = form;
|
121
151
|
|
122
|
-
formRef.current.updateTags
|
123
|
-
|
124
|
-
|
152
|
+
if (!formRef.current.updateTags) {
|
153
|
+
formRef.current.updateTags = function () {
|
154
|
+
configFilterItem(form);
|
155
|
+
};
|
156
|
+
}
|
125
157
|
}
|
126
158
|
}; // 创建简单筛选表单实例
|
127
159
|
|
@@ -131,7 +163,9 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
131
163
|
validateFirst: true,
|
132
164
|
effects: function effects() {
|
133
165
|
onFormReact(function (form) {
|
134
|
-
|
166
|
+
if (mode === 'inline') {
|
167
|
+
_onFormInit(form, props);
|
168
|
+
}
|
135
169
|
});
|
136
170
|
}
|
137
171
|
});
|
@@ -142,7 +176,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
142
176
|
validateFirst: true,
|
143
177
|
effects: function effects() {
|
144
178
|
onFormInputChange(function () {
|
145
|
-
setCurrentForm('light');
|
179
|
+
setCurrentForm('light'); // 主动修改轻量筛选值
|
146
180
|
});
|
147
181
|
}
|
148
182
|
});
|
@@ -153,11 +187,12 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
153
187
|
validateFirst: true,
|
154
188
|
effects: function effects() {
|
155
189
|
onFormReact(function (form) {
|
156
|
-
|
190
|
+
if (mode === 'panel') {
|
191
|
+
_onFormInit(form, props);
|
192
|
+
}
|
157
193
|
});
|
158
194
|
onFormInputChange(function (form) {
|
159
|
-
// 主动修改高级筛选值
|
160
|
-
setCurrentForm('advanced');
|
195
|
+
setCurrentForm('advanced'); // 主动修改高级筛选值
|
161
196
|
});
|
162
197
|
}
|
163
198
|
});
|
@@ -166,35 +201,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
166
201
|
simple: simpleForm,
|
167
202
|
light: lightForm,
|
168
203
|
advanced: advancedForm
|
169
|
-
};
|
170
|
-
|
171
|
-
var _useSpecialProps = useSpecialProps(props),
|
172
|
-
hasDefault = _useSpecialProps.hasDefault,
|
173
|
-
hasAsyncDefault = _useSpecialProps.hasAsyncDefault,
|
174
|
-
hasRequired = _useSpecialProps.hasRequired;
|
175
|
-
|
176
|
-
var hasDefaultOrRequired = hasDefault || hasAsyncDefault || hasRequired;
|
177
|
-
|
178
|
-
var _useState = useState(!!expand),
|
179
|
-
_useState2 = _slicedToArray(_useState, 2),
|
180
|
-
advancedFilterVisible = _useState2[0],
|
181
|
-
setAdvancedFilterVisible = _useState2[1];
|
182
|
-
|
183
|
-
var _useState3 = useState([]),
|
184
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
185
|
-
tagDataSource = _useState4[0],
|
186
|
-
setTagDataSource = _useState4[1];
|
187
|
-
|
188
|
-
var filterItem = useRef([]);
|
189
|
-
var currentForm = useRef(mode === 'panel' ? advancedFilterVisible ? 'advanced' : 'light' : 'simple');
|
190
|
-
var filterEnable = useRef(false);
|
191
|
-
var prefixCls = usePrefixCls('', {
|
192
|
-
prefix: 'teamix-pro-form-query-filter'
|
193
|
-
}); // 设置筛选数据
|
194
|
-
|
195
|
-
var configFilterItem = useCallback(function (form) {
|
196
|
-
filterItem.current = getFilterDisplayValues(form);
|
197
|
-
}, []); // 获取筛选数据Label
|
204
|
+
}; // 获取筛选数据Label
|
198
205
|
|
199
206
|
var getFilterDisplayValues = useCallback(function (form) {
|
200
207
|
var displayValues = getFormDisplayValues(form);
|
@@ -222,7 +229,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
222
229
|
index: index
|
223
230
|
});
|
224
231
|
});
|
225
|
-
} else if (
|
232
|
+
} else if (isUsable(value)) {
|
226
233
|
filterData.push({
|
227
234
|
key: key,
|
228
235
|
type: fieldTypeMap[component] || 'text',
|
@@ -232,43 +239,34 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
232
239
|
}
|
233
240
|
});
|
234
241
|
return filterData;
|
242
|
+
}, []); // 设置筛选数据
|
243
|
+
|
244
|
+
var configFilterItem = useCallback(function (form) {
|
245
|
+
filterItem.current = getFilterDisplayValues(form);
|
235
246
|
}, []); // 设置标签数据
|
236
247
|
|
237
248
|
var configTag = useCallback(function () {
|
238
249
|
setTagDataSource(filterItem.current);
|
239
|
-
}, [
|
250
|
+
}, []); // 展开收起高级筛选
|
240
251
|
|
241
252
|
var toggleAdvancedFilter = useCallback(function () {
|
242
|
-
var result = !
|
253
|
+
var result = !panelVisible;
|
243
254
|
|
244
255
|
if (result) {
|
245
256
|
// 展开高级筛选,Light回填Advanced
|
246
257
|
if (currentForm.current === 'light') {
|
247
|
-
|
258
|
+
var key = activeFilterValueRef.current;
|
259
|
+
var value = lightForm.values[key];
|
260
|
+
advancedForm.setValuesIn(key, value);
|
248
261
|
}
|
249
262
|
} else {
|
250
263
|
// 收起高级筛选,配置标签数据
|
251
264
|
configTag();
|
252
265
|
}
|
253
266
|
|
254
|
-
|
267
|
+
setPanelVisible(result);
|
255
268
|
onExpand === null || onExpand === void 0 ? void 0 : onExpand(result);
|
256
|
-
}, [
|
257
|
-
|
258
|
-
var enableFilter = function enableFilter(values) {
|
259
|
-
var initialValues = JSON.stringify(getValidValues(filterEnable.current));
|
260
|
-
var changeValues = JSON.stringify(getValidValues(values));
|
261
|
-
|
262
|
-
if (filterEnable.current === true) {
|
263
|
-
return true;
|
264
|
-
} else if (initialValues === changeValues) {
|
265
|
-
filterEnable.current = true;
|
266
|
-
return false;
|
267
|
-
}
|
268
|
-
|
269
|
-
return false;
|
270
|
-
}; // 简单搜索Filter
|
271
|
-
|
269
|
+
}, [panelVisible, configTag]); // 简单搜索Filter
|
272
270
|
|
273
271
|
var onSimpleFilter = useCallback( /*#__PURE__*/function () {
|
274
272
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(values) {
|
@@ -276,19 +274,18 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
276
274
|
while (1) {
|
277
275
|
switch (_context.prev = _context.next) {
|
278
276
|
case 0:
|
279
|
-
if (
|
280
|
-
_context.next =
|
277
|
+
if (!(currentForm.current === 'simple')) {
|
278
|
+
_context.next = 14;
|
281
279
|
break;
|
282
280
|
}
|
283
281
|
|
284
|
-
|
285
|
-
|
286
|
-
case 2:
|
287
|
-
if (!(currentForm.current === 'simple')) {
|
288
|
-
_context.next = 7;
|
282
|
+
if (!(filterEnable.current === 'initialized')) {
|
283
|
+
_context.next = 9;
|
289
284
|
break;
|
290
285
|
}
|
291
286
|
|
287
|
+
filterEnable.current = 'filter';
|
288
|
+
|
292
289
|
if (!hasRequired) {
|
293
290
|
_context.next = 6;
|
294
291
|
break;
|
@@ -298,9 +295,28 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
298
295
|
return simpleForm.validate();
|
299
296
|
|
300
297
|
case 6:
|
298
|
+
onInit === null || onInit === void 0 ? void 0 : onInit(values);
|
299
|
+
_context.next = 14;
|
300
|
+
break;
|
301
|
+
|
302
|
+
case 9:
|
303
|
+
if (!(filterEnable.current === 'filter')) {
|
304
|
+
_context.next = 14;
|
305
|
+
break;
|
306
|
+
}
|
307
|
+
|
308
|
+
if (!hasRequired) {
|
309
|
+
_context.next = 13;
|
310
|
+
break;
|
311
|
+
}
|
312
|
+
|
313
|
+
_context.next = 13;
|
314
|
+
return simpleForm.validate();
|
315
|
+
|
316
|
+
case 13:
|
301
317
|
onFilter === null || onFilter === void 0 ? void 0 : onFilter(values);
|
302
318
|
|
303
|
-
case
|
319
|
+
case 14:
|
304
320
|
case "end":
|
305
321
|
return _context.stop();
|
306
322
|
}
|
@@ -311,37 +327,81 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
311
327
|
return function (_x) {
|
312
328
|
return _ref4.apply(this, arguments);
|
313
329
|
};
|
314
|
-
}(), [onFilter,
|
330
|
+
}(), [onFilter, hasRequired, onInit]); // 轻量搜索Filter
|
331
|
+
|
332
|
+
var onLightFilter = useCallback(function (values) {
|
333
|
+
if (currentForm.current === 'light') {
|
334
|
+
if (filterEnable.current === 'filter') {
|
335
|
+
var _Object$keys;
|
336
|
+
|
337
|
+
onFilter === null || onFilter === void 0 ? void 0 : onFilter(values); // 清空advancedForm的值,配置Tag
|
338
|
+
|
339
|
+
var clearKeys = {};
|
340
|
+
(_Object$keys = Object.keys(advancedForm.values)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.forEach(function (key) {
|
341
|
+
clearKeys[key] = undefined;
|
342
|
+
});
|
343
|
+
advancedForm.setValues(clearKeys);
|
344
|
+
configFilterItem(advancedForm);
|
345
|
+
configTag();
|
346
|
+
}
|
347
|
+
}
|
348
|
+
}, [onFilter]); // 高级搜索Filter by Submit
|
349
|
+
|
350
|
+
var onAdvancedFilter = useCallback(function (values) {
|
351
|
+
setCurrentForm('advanced');
|
352
|
+
onFilter === null || onFilter === void 0 ? void 0 : onFilter(values);
|
353
|
+
configFilterItem(advancedForm); // 清空lightForm的值
|
354
|
+
|
355
|
+
lightForm.reset('*', {
|
356
|
+
forceClear: true
|
357
|
+
});
|
358
|
+
}, [onFilter]); // 高级搜索Reset
|
359
|
+
|
360
|
+
var onAdvancedReset = useCallback(function () {
|
361
|
+
setCurrentForm('advanced');
|
362
|
+
onReset === null || onReset === void 0 ? void 0 : onReset(toJS(advancedForm.values));
|
363
|
+
configFilterItem(advancedForm); // 清空lightForm的值
|
315
364
|
|
316
|
-
|
365
|
+
lightForm.reset('*', {
|
366
|
+
forceClear: true
|
367
|
+
});
|
368
|
+
}, [onReset]); // 高级搜索Filter by Change
|
369
|
+
|
370
|
+
var onAdvancedChange = useCallback( /*#__PURE__*/function () {
|
317
371
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(values) {
|
318
372
|
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
319
373
|
while (1) {
|
320
374
|
switch (_context2.prev = _context2.next) {
|
321
375
|
case 0:
|
322
|
-
if (
|
323
|
-
_context2.next =
|
376
|
+
if (!(currentForm.current === 'advanced')) {
|
377
|
+
_context2.next = 9;
|
324
378
|
break;
|
325
379
|
}
|
326
380
|
|
327
|
-
|
381
|
+
if (!(filterEnable.current === 'initialized')) {
|
382
|
+
_context2.next = 9;
|
383
|
+
break;
|
384
|
+
}
|
328
385
|
|
329
|
-
|
330
|
-
|
331
|
-
|
386
|
+
filterEnable.current = 'filter';
|
387
|
+
|
388
|
+
if (!hasRequired) {
|
389
|
+
_context2.next = 6;
|
332
390
|
break;
|
333
391
|
}
|
334
392
|
|
335
|
-
onFilter === null || onFilter === void 0 ? void 0 : onFilter(values);
|
336
393
|
_context2.next = 6;
|
337
|
-
return advancedForm.
|
394
|
+
return advancedForm.validate();
|
338
395
|
|
339
396
|
case 6:
|
340
|
-
|
397
|
+
onInit === null || onInit === void 0 ? void 0 : onInit(values);
|
341
398
|
configFilterItem(advancedForm);
|
342
|
-
configTag();
|
343
399
|
|
344
|
-
|
400
|
+
if (!panelVisible) {
|
401
|
+
configTag();
|
402
|
+
}
|
403
|
+
|
404
|
+
case 9:
|
345
405
|
case "end":
|
346
406
|
return _context2.stop();
|
347
407
|
}
|
@@ -352,31 +412,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
352
412
|
return function (_x2) {
|
353
413
|
return _ref5.apply(this, arguments);
|
354
414
|
};
|
355
|
-
}(), [
|
356
|
-
|
357
|
-
var onAdvancedFilter = useCallback(function (values) {
|
358
|
-
if (!enableFilter(values)) {
|
359
|
-
return;
|
360
|
-
}
|
361
|
-
|
362
|
-
setCurrentForm('advanced');
|
363
|
-
onFilter === null || onFilter === void 0 ? void 0 : onFilter(values);
|
364
|
-
configFilterItem(advancedForm);
|
365
|
-
lightForm.reset();
|
366
|
-
}, [onFilter, currentForm.current, enableFilter]); // 高级搜索Change
|
367
|
-
|
368
|
-
var onAdvancedChange = useCallback(function (values) {
|
369
|
-
if (!enableFilter(values)) {
|
370
|
-
return;
|
371
|
-
}
|
372
|
-
}, [enableFilter]); // 高级搜索Reset
|
373
|
-
|
374
|
-
var onAdvancedReset = useCallback(function () {
|
375
|
-
setCurrentForm('advanced');
|
376
|
-
onReset === null || onReset === void 0 ? void 0 : onReset(toJS(advancedForm.values));
|
377
|
-
configFilterItem(advancedForm);
|
378
|
-
lightForm.reset();
|
379
|
-
}, [onReset]); // 关闭标签清空表单字段值
|
415
|
+
}(), [hasRequired, onInit]); // 关闭标签清空表单字段值
|
380
416
|
|
381
417
|
var onTagClose = useCallback(function (key, index) {
|
382
418
|
var newValue = undefined;
|
@@ -390,13 +426,14 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
390
426
|
configFilterItem(advancedForm);
|
391
427
|
configTag();
|
392
428
|
onFilter === null || onFilter === void 0 ? void 0 : onFilter(toJS(advancedForm.values));
|
393
|
-
}, []); // initialValues和initialRequest的回调
|
429
|
+
}, [onFilter]); // initialValues和initialRequest的回调
|
394
430
|
|
395
431
|
var onInitialComplete = useCallback(function (form) {
|
396
432
|
form.setState({
|
397
433
|
loading: false
|
398
434
|
});
|
399
|
-
}, []);
|
435
|
+
}, []); // 组件挂载
|
436
|
+
|
400
437
|
useEffect(function () {
|
401
438
|
setCurrentForm(currentForm.current);
|
402
439
|
}, []);
|
@@ -404,13 +441,14 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
404
441
|
className: cls(prefixCls, props.className),
|
405
442
|
addonBefore: addonBefore,
|
406
443
|
addonAfter: addonAfter,
|
407
|
-
expand:
|
444
|
+
expand: panelVisible,
|
408
445
|
onExpand: toggleAdvancedFilter,
|
409
446
|
count: tagDataSource.length,
|
410
447
|
inlineContent: mode === 'panel' ? /*#__PURE__*/React.createElement("div", {
|
411
|
-
className: cls("".concat(prefixCls, "-inline"), purePanel ||
|
448
|
+
className: cls("".concat(prefixCls, "-inline"), purePanel || hasRequired ? "".concat(prefixCls, "-inline-hidden") : '')
|
412
449
|
}, /*#__PURE__*/React.createElement(LightFilter, _objectSpread(_objectSpread({}, otherProps), {}, {
|
413
450
|
defaultFilterValue: defaultFilterValue,
|
451
|
+
activeFilterValueRef: activeFilterValueRef,
|
414
452
|
form: lightForm,
|
415
453
|
onChange: debounce(onLightFilter, filterDebounce)
|
416
454
|
}))) : /*#__PURE__*/React.createElement("div", {
|
@@ -428,7 +466,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
428
466
|
onReset: onAdvancedReset,
|
429
467
|
onInitialComplete: onInitialComplete
|
430
468
|
})) : null
|
431
|
-
}, mode === 'panel' && !
|
469
|
+
}, mode === 'panel' && !panelVisible ? /*#__PURE__*/React.createElement(Tag.Group, null, tagDataSource.map(function (_ref6) {
|
432
470
|
var key = _ref6.key,
|
433
471
|
label = _ref6.label,
|
434
472
|
value = _ref6.value,
|
@@ -1,10 +1,11 @@
|
|
1
|
-
import {
|
1
|
+
import { isUsable, isStr, isPureObj } from '@teamix/utils'; // 获取Schema是否包含默认值、异步默认值、必选校验等
|
2
2
|
|
3
3
|
var useSpecialProps = function useSpecialProps(props) {
|
4
4
|
var initialValues = props.initialValues,
|
5
5
|
initialRequest = props.initialRequest;
|
6
|
-
var
|
7
|
-
|
6
|
+
var hasChangeDefault = !!initialValues || !!initialRequest; // 会触发onChange的默认值
|
7
|
+
|
8
|
+
var hasDefault = hasChangeDefault;
|
8
9
|
var hasRequired = false;
|
9
10
|
|
10
11
|
var hasDefaultOrRule = function hasDefaultOrRule(schema) {
|
@@ -12,13 +13,12 @@ var useSpecialProps = function useSpecialProps(props) {
|
|
12
13
|
var value = item.default,
|
13
14
|
required = item.required,
|
14
15
|
rules = item.rules,
|
15
|
-
request = item.request,
|
16
16
|
dataSource = item.dataSource,
|
17
|
-
children = item.children;
|
18
|
-
|
17
|
+
children = item.children; // 字符串变量配置default值会触发onChange
|
18
|
+
|
19
|
+
hasChangeDefault = hasChangeDefault || !!(isPureObj(dataSource) && isStr(value) && value.indexOf('.dataSource'));
|
20
|
+
hasDefault = hasDefault || isUsable(value);
|
19
21
|
hasRequired = hasRequired || required || !!rules;
|
20
|
-
hasAsyncDefault = hasAsyncDefault || !!request || // 如果dataSource是异步且default取自dataSource
|
21
|
-
!!(isPlainObj(dataSource) && isStr(value) && value.indexOf('.dataSource'));
|
22
22
|
|
23
23
|
if (children === null || children === void 0 ? void 0 : children.length) {
|
24
24
|
hasDefaultOrRule(children);
|
@@ -29,7 +29,7 @@ var useSpecialProps = function useSpecialProps(props) {
|
|
29
29
|
hasDefaultOrRule(props.schema);
|
30
30
|
return {
|
31
31
|
hasDefault: hasDefault,
|
32
|
-
|
32
|
+
hasChangeDefault: hasChangeDefault,
|
33
33
|
hasRequired: hasRequired
|
34
34
|
};
|
35
35
|
};
|
@@ -6,6 +6,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
6
6
|
|
7
7
|
import { connect, mapProps } from '@formily/react';
|
8
8
|
import { toJS } from '@formily/reactive';
|
9
|
+
import { mapSize, mapStatus, mapDataSource } from '../utils';
|
9
10
|
|
10
11
|
var customComponent = function customComponent(component) {
|
11
12
|
return connect(component, mapProps(function (props, field) {
|
@@ -14,7 +15,7 @@ var customComponent = function customComponent(component) {
|
|
14
15
|
form: field.form,
|
15
16
|
values: toJS(field.form.values)
|
16
17
|
});
|
17
|
-
}));
|
18
|
+
}, mapSize, mapStatus, mapDataSource));
|
18
19
|
};
|
19
20
|
|
20
21
|
export { customComponent };
|
@@ -197,14 +197,14 @@
|
|
197
197
|
margin-right: 4px;
|
198
198
|
}
|
199
199
|
}
|
200
|
-
// 数组类ArrayItem Icon
|
201
|
-
.#{$form-array}-items-item-inner {
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
}
|
200
|
+
// 数组类ArrayItem Icon 居中(移除,通过align:center配置)
|
201
|
+
// .#{$form-array}-items-item-inner {
|
202
|
+
// .#{$css-prefix}space-item {
|
203
|
+
// > .#{$css-prefix}formily-icon {
|
204
|
+
// margin-top: 9px;
|
205
|
+
// }
|
206
|
+
// }
|
207
|
+
// }
|
208
208
|
|
209
209
|
// Editable预览态行高
|
210
210
|
.#{$css-prefix}formily-editable-content {
|
@@ -106,10 +106,10 @@ export default /*#__PURE__*/memo(function (_ref) {
|
|
106
106
|
}, [scope]); // 格式化 schema
|
107
107
|
|
108
108
|
var formatSchema = useCallback(function (schema) {
|
109
|
-
var
|
109
|
+
var parentSuffix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
110
110
|
var schemaProperties = {};
|
111
111
|
schema === null || schema === void 0 ? void 0 : schema.forEach(function (item, index) {
|
112
|
-
suffix = "".concat(
|
112
|
+
var suffix = "".concat(parentSuffix).concat(index);
|
113
113
|
var newItem = warning(item);
|
114
114
|
var _newItem = newItem,
|
115
115
|
originalComponent = _newItem.component; // 根据component的不同,初始化为内置的item
|
@@ -37,9 +37,8 @@ var initializeRequest = function initializeRequest(requestConfig, suffix) {
|
|
37
37
|
};
|
38
38
|
} else {
|
39
39
|
var requestConfigName = "$requestConfig_".concat(suffix);
|
40
|
-
var requestIndex = (/\d{1,}\w(\d{0,})/g.exec(suffix) || [])[1];
|
41
40
|
return {
|
42
|
-
reactions: ["{{$common($request,".concat(requestConfigName, ",context
|
41
|
+
reactions: ["{{$common($request,".concat(requestConfigName, ",context)}}")],
|
43
42
|
scope: _defineProperty({}, requestConfigName, requestConfig)
|
44
43
|
};
|
45
44
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { ProFormRequestConfig } from '../typing';
|
2
|
-
declare const $request: (field: any, requestConfig: ProFormRequestConfig, context: any, type:
|
3
|
-
declare const $common: (services: any, requestConfig: ProFormRequestConfig, context: any
|
2
|
+
declare const $request: (field: any, requestConfig: ProFormRequestConfig, context: any, type: 'request' | 'validator' | 'dataSource') => Promise<unknown>;
|
3
|
+
declare const $common: (services: any, requestConfig: ProFormRequestConfig, context: any) => (field: any) => any;
|
4
4
|
declare const $validator: (services: any, requestConfig: ProFormRequestConfig, context: any) => (value: any, rules: any, { field }: any) => any;
|
5
5
|
declare const $dataSource: (services: any, requestConfig: ProFormRequestConfig, context: any) => (field: any) => any;
|
6
6
|
export { $request, $common, $dataSource, $validator };
|