@teamix/pro 1.2.18 → 1.2.19
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 +733 -273
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/actions/base.d.ts +2 -1
- package/es/actions/base.js +1 -1
- package/es/actions/danger-pop-confirm.d.ts +5 -0
- package/es/actions/danger-pop-confirm.js +10 -0
- package/es/actions/dialog.d.ts +1 -1
- package/es/actions/dialog.js +32 -31
- package/es/actions/index.d.ts +3 -0
- package/es/actions/index.js +10 -0
- package/es/actions/pop-confirm.d.ts +9 -0
- package/es/actions/pop-confirm.js +9 -0
- package/es/form/Components/LightFilter/componentMap.d.ts +2 -1
- package/es/form/Components/LightFilter/componentMap.js +2 -1
- package/es/form/Components/LightFilter/index.d.ts +1 -0
- package/es/form/Components/LightFilter/index.js +19 -13
- package/es/form/Components/LightFilter/index.scss +13 -3
- package/es/form/Filter/index2.js +157 -50
- package/es/form/Filter/index2.scss +3 -0
- package/es/form/ProForm/index.js +3 -2
- package/es/form/typing.d.ts +5 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/table/components/ToolBar/FilterColumnIcon.js +1 -1
- package/es/table/index.js +39 -12
- package/lib/actions/base.d.ts +2 -1
- package/lib/actions/base.js +1 -1
- package/lib/actions/danger-pop-confirm.d.ts +5 -0
- package/lib/actions/danger-pop-confirm.js +22 -0
- package/lib/actions/dialog.d.ts +1 -1
- package/lib/actions/dialog.js +33 -31
- package/lib/actions/index.d.ts +3 -0
- package/lib/actions/index.js +12 -0
- package/lib/actions/pop-confirm.d.ts +9 -0
- package/lib/actions/pop-confirm.js +23 -0
- package/lib/form/Components/LightFilter/componentMap.d.ts +2 -1
- package/lib/form/Components/LightFilter/componentMap.js +4 -3
- package/lib/form/Components/LightFilter/index.d.ts +1 -0
- package/lib/form/Components/LightFilter/index.js +18 -12
- package/lib/form/Components/LightFilter/index.scss +13 -3
- package/lib/form/Filter/index2.js +157 -49
- package/lib/form/Filter/index2.scss +3 -0
- package/lib/form/ProForm/index.js +4 -2
- package/lib/form/typing.d.ts +5 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/table/components/ToolBar/FilterColumnIcon.js +1 -1
- package/lib/table/index.js +39 -12
- package/package.json +2 -2
package/es/form/Filter/index2.js
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
var _excluded = ["schema", "onChange", "onSubmit"],
|
2
2
|
_excluded2 = ["form", "schema", "onSubmit", "onChange"],
|
3
|
-
_excluded3 = ["schema", "onSubmit", "
|
4
|
-
_excluded4 = ["addonAfter", "addonBefore", "onFilter", "mode", "expand"];
|
3
|
+
_excluded3 = ["schema", "onSubmit", "onReset", "layout", "labelAlign", "wrapperAlign", "labelCol", "wrapperCol"],
|
4
|
+
_excluded4 = ["addonAfter", "addonBefore", "onFilter", "onInit", "onReset", "mode", "expand"];
|
5
|
+
|
6
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
7
|
+
|
8
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
5
9
|
|
6
10
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
7
11
|
|
@@ -38,7 +42,8 @@ import cls from 'classnames';
|
|
38
42
|
import { Tag, Button, Badge } from '@alicloudfe/components';
|
39
43
|
import TeamixIcon from '@teamix/icon';
|
40
44
|
import { createForm } from '@formily/core';
|
41
|
-
import {
|
45
|
+
import { toJS } from '@formily/reactive';
|
46
|
+
import { usePrefixCls, getMessage, isSignificative, isStr, isPlainObj } from '@teamix/utils';
|
42
47
|
import ProField from '../../field/index';
|
43
48
|
import ProForm from '../ProForm';
|
44
49
|
import fieldTypeMap from '../fieldTypeMap';
|
@@ -98,9 +103,17 @@ var LightFilter = /*#__PURE__*/memo(function (props) {
|
|
98
103
|
var prefixCls = usePrefixCls('', {
|
99
104
|
prefix: 'teamix-pro-form-query-filter-light'
|
100
105
|
});
|
106
|
+
var onBtnClick = useCallback(function () {
|
107
|
+
onChange && onChange(toJS(form.values));
|
108
|
+
}, [form]);
|
101
109
|
var LightSchema = useMemo(function () {
|
102
110
|
return [{
|
103
111
|
component: 'LightFilter',
|
112
|
+
props: {
|
113
|
+
buttonProps: {
|
114
|
+
onClick: onBtnClick
|
115
|
+
}
|
116
|
+
},
|
104
117
|
children: schema
|
105
118
|
}, {
|
106
119
|
component: 'Submit',
|
@@ -110,19 +123,12 @@ var LightFilter = /*#__PURE__*/memo(function (props) {
|
|
110
123
|
}
|
111
124
|
}
|
112
125
|
}];
|
113
|
-
}, [schema]);
|
114
|
-
// form.addEffects('onChange', () => {
|
115
|
-
// onFieldValueChange('',(field:any) => {
|
116
|
-
// console.log(field.value);
|
117
|
-
// });
|
118
|
-
// });
|
119
|
-
// }, [form, onChange]);
|
120
|
-
|
126
|
+
}, [schema, onBtnClick]);
|
121
127
|
return /*#__PURE__*/React.createElement(ProForm, _objectSpread(_objectSpread({}, otherProps), {}, {
|
122
128
|
form: form,
|
123
129
|
className: cls(prefixCls, props.className),
|
124
130
|
schema: LightSchema,
|
125
|
-
feedbackLayout: "
|
131
|
+
feedbackLayout: "none",
|
126
132
|
breakpoints: [],
|
127
133
|
bordered: false,
|
128
134
|
onSubmit: onSubmit,
|
@@ -136,7 +142,6 @@ var LightFilter = /*#__PURE__*/memo(function (props) {
|
|
136
142
|
var AdvancedFilter = /*#__PURE__*/memo(function (props) {
|
137
143
|
var schema = props.schema,
|
138
144
|
onSubmit = props.onSubmit,
|
139
|
-
onChange = props.onChange,
|
140
145
|
onReset = props.onReset,
|
141
146
|
layout = props.layout,
|
142
147
|
labelAlign = props.labelAlign,
|
@@ -211,25 +216,79 @@ AdvancedFilter.defaultProps = {
|
|
211
216
|
labelCol: 6,
|
212
217
|
wrapperCol: 18
|
213
218
|
};
|
219
|
+
|
220
|
+
var getSpecialProps = function getSpecialProps(props) {
|
221
|
+
var initialValues = props.initialValues,
|
222
|
+
initialRequest = props.initialRequest;
|
223
|
+
var hasDefault = !!initialValues;
|
224
|
+
var hasAsyncDefault = !!initialRequest;
|
225
|
+
var hasRequired = false;
|
226
|
+
|
227
|
+
var hasDefaultOrRule = function hasDefaultOrRule(schema) {
|
228
|
+
schema.forEach(function (item) {
|
229
|
+
var value = item.default,
|
230
|
+
required = item.required,
|
231
|
+
rules = item.rules,
|
232
|
+
request = item.request,
|
233
|
+
dataSource = item.dataSource,
|
234
|
+
children = item.children;
|
235
|
+
hasDefault = hasDefault || isSignificative(value);
|
236
|
+
hasRequired = hasRequired || required || !!rules;
|
237
|
+
hasAsyncDefault = hasAsyncDefault || !!request || // 如果dataSource是异步且default取自dataSource
|
238
|
+
!!(isPlainObj(dataSource) && isStr(value) && value.indexOf('.dataSource'));
|
239
|
+
|
240
|
+
if (children === null || children === void 0 ? void 0 : children.length) {
|
241
|
+
hasDefaultOrRule(children);
|
242
|
+
}
|
243
|
+
});
|
244
|
+
};
|
245
|
+
|
246
|
+
hasDefaultOrRule(props.schema);
|
247
|
+
return {
|
248
|
+
hasDefault: hasDefault,
|
249
|
+
hasAsyncDefault: hasAsyncDefault,
|
250
|
+
hasRequired: hasRequired
|
251
|
+
};
|
252
|
+
};
|
214
253
|
/**
|
215
254
|
* 查询筛选
|
216
255
|
*/
|
217
256
|
|
257
|
+
|
218
258
|
var QueryFilter = /*#__PURE__*/memo(function (props) {
|
219
259
|
var addonAfter = props.addonAfter,
|
220
260
|
addonBefore = props.addonBefore,
|
221
261
|
onFilter = props.onFilter,
|
262
|
+
onInit = props.onInit,
|
263
|
+
onReset = props.onReset,
|
222
264
|
mode = props.mode,
|
223
265
|
expand = props.expand,
|
224
266
|
otherProps = _objectWithoutProperties(props, _excluded4);
|
225
267
|
|
226
|
-
var
|
227
|
-
return
|
268
|
+
var simpleForm = useMemo(function () {
|
269
|
+
return createForm({
|
270
|
+
validateFirst: true
|
271
|
+
});
|
272
|
+
}, []);
|
273
|
+
var lightForm = useMemo(function () {
|
274
|
+
return createForm({
|
275
|
+
validateFirst: true
|
276
|
+
});
|
277
|
+
}, []);
|
278
|
+
var advancedForm = useMemo(function () {
|
279
|
+
return createForm({
|
228
280
|
validateFirst: true
|
229
281
|
});
|
230
282
|
}, []);
|
231
283
|
|
232
|
-
var
|
284
|
+
var _getSpecialProps = getSpecialProps(props),
|
285
|
+
hasDefault = _getSpecialProps.hasDefault,
|
286
|
+
hasAsyncDefault = _getSpecialProps.hasAsyncDefault,
|
287
|
+
hasRequired = _getSpecialProps.hasRequired;
|
288
|
+
|
289
|
+
var hasDefaultOrRequired = hasDefault || hasAsyncDefault || hasRequired;
|
290
|
+
|
291
|
+
var _useState = useState(!!expand || hasDefaultOrRequired),
|
233
292
|
_useState2 = _slicedToArray(_useState, 2),
|
234
293
|
advancedFilterVisible = _useState2[0],
|
235
294
|
setAdvancedFilterVisible = _useState2[1];
|
@@ -241,7 +300,8 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
241
300
|
|
242
301
|
var prefixCls = usePrefixCls('', {
|
243
302
|
prefix: 'teamix-pro-form-query-filter'
|
244
|
-
});
|
303
|
+
});
|
304
|
+
var currentForm = mode === 'panel' ? advancedFilterVisible ? 'advanced' : 'light' : 'simple'; // 展开收起高级筛选
|
245
305
|
|
246
306
|
var toggleAdvancedFilter = useCallback(function () {
|
247
307
|
setAdvancedFilterVisible(function (visible) {
|
@@ -267,31 +327,78 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
267
327
|
}).filter(function (item) {
|
268
328
|
return isSignificative(item.value);
|
269
329
|
});
|
270
|
-
}, []); //
|
271
|
-
|
272
|
-
var
|
273
|
-
setTagDataSource(getTagDataSource(
|
274
|
-
|
275
|
-
|
330
|
+
}, []); // 设置标签数据
|
331
|
+
|
332
|
+
var configTag = useCallback(function () {
|
333
|
+
setTagDataSource(getTagDataSource(advancedForm));
|
334
|
+
}, []); // 简单搜索Filter
|
335
|
+
|
336
|
+
var onSimpleFilter = useCallback(function (values) {
|
337
|
+
if (currentForm === 'simple') {
|
338
|
+
onFilter && onFilter(values);
|
339
|
+
}
|
340
|
+
}, [onFilter, currentForm]); // 轻量搜索Filter
|
341
|
+
|
342
|
+
var onLightFilter = useCallback( /*#__PURE__*/function () {
|
343
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(values) {
|
344
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
345
|
+
while (1) {
|
346
|
+
switch (_context.prev = _context.next) {
|
347
|
+
case 0:
|
348
|
+
if (!(currentForm === 'light')) {
|
349
|
+
_context.next = 5;
|
350
|
+
break;
|
351
|
+
}
|
352
|
+
|
353
|
+
onFilter && onFilter(values);
|
354
|
+
_context.next = 4;
|
355
|
+
return advancedForm.reset();
|
356
|
+
|
357
|
+
case 4:
|
358
|
+
configTag();
|
359
|
+
|
360
|
+
case 5:
|
361
|
+
case "end":
|
362
|
+
return _context.stop();
|
363
|
+
}
|
364
|
+
}
|
365
|
+
}, _callee);
|
366
|
+
}));
|
276
367
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
}, [form]); // 简单表单onChange
|
368
|
+
return function (_x) {
|
369
|
+
return _ref3.apply(this, arguments);
|
370
|
+
};
|
371
|
+
}(), [onFilter, currentForm]); // 高级搜索Filter
|
282
372
|
|
283
|
-
var
|
284
|
-
|
285
|
-
|
286
|
-
|
373
|
+
var onAdvancedFilter = useCallback(function (values) {
|
374
|
+
if (currentForm === 'advanced') {
|
375
|
+
onFilter && onFilter(values);
|
376
|
+
configTag();
|
377
|
+
lightForm.reset();
|
378
|
+
}
|
379
|
+
}, [onFilter, currentForm]); // 关闭标签清空表单字段值
|
287
380
|
|
288
381
|
var onTagClose = useCallback(function (key) {
|
289
|
-
|
290
|
-
|
382
|
+
advancedForm.setValuesIn(key, undefined);
|
383
|
+
setTagDataSource(getTagDataSource(advancedForm));
|
384
|
+
}, []); // 判断表单是否有校验和默认值
|
291
385
|
|
292
386
|
useEffect(function () {
|
293
|
-
|
294
|
-
}, []);
|
387
|
+
if (hasDefault || hasAsyncDefault || hasRequired) {}
|
388
|
+
}, [hasDefault, hasAsyncDefault, hasRequired]); // 设置默认值标签数据
|
389
|
+
|
390
|
+
useEffect(function () {// onInit
|
391
|
+
// if (mode === 'panel') {
|
392
|
+
// if (expand) {
|
393
|
+
// onInit && onInit(toJS(advancedForm.values));
|
394
|
+
// } else {
|
395
|
+
// onInit && onInit(toJS(lightForm.values));
|
396
|
+
// }
|
397
|
+
// configTag();
|
398
|
+
// } else {
|
399
|
+
// onInit && onInit(toJS(simpleForm.values));
|
400
|
+
// }
|
401
|
+
}, [mode]);
|
295
402
|
return /*#__PURE__*/React.createElement("div", {
|
296
403
|
className: cls(prefixCls, props.className)
|
297
404
|
}, /*#__PURE__*/React.createElement("div", {
|
@@ -301,11 +408,11 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
301
408
|
}, addonBefore ? /*#__PURE__*/React.createElement("div", {
|
302
409
|
className: "".concat(prefixCls, "-addonBefore")
|
303
410
|
}, addonBefore) : null, mode === 'panel' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
304
|
-
className: "".concat(prefixCls, "-inline-form")
|
411
|
+
className: cls("".concat(prefixCls, "-inline-form"), hasAsyncDefault ? "".concat(prefixCls, "-inline-form-hidden") : '')
|
305
412
|
}, /*#__PURE__*/React.createElement(LightFilter, _objectSpread(_objectSpread({}, otherProps), {}, {
|
306
|
-
form:
|
307
|
-
|
308
|
-
onSubmit:
|
413
|
+
form: lightForm,
|
414
|
+
onChange: onLightFilter,
|
415
|
+
onSubmit: onLightFilter
|
309
416
|
}))), /*#__PURE__*/React.createElement("div", {
|
310
417
|
className: "".concat(prefixCls, "-toggle")
|
311
418
|
}, /*#__PURE__*/React.createElement(Badge, {
|
@@ -325,20 +432,20 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
325
432
|
}), getMessage('advancedFilter'))))) : /*#__PURE__*/React.createElement("div", {
|
326
433
|
className: "".concat(prefixCls, "-inline-form")
|
327
434
|
}, /*#__PURE__*/React.createElement(SimpleFilter, _objectSpread(_objectSpread({}, otherProps), {}, {
|
328
|
-
form:
|
329
|
-
|
330
|
-
onSubmit:
|
435
|
+
form: simpleForm,
|
436
|
+
onChange: onSimpleFilter,
|
437
|
+
onSubmit: onSimpleFilter
|
331
438
|
})))), addonAfter ? /*#__PURE__*/React.createElement("div", {
|
332
439
|
className: "".concat(prefixCls, "-addonAfter")
|
333
440
|
}, addonAfter) : null), mode === 'panel' ? /*#__PURE__*/React.createElement("div", {
|
334
441
|
className: "".concat(prefixCls, "-panel")
|
335
442
|
}, /*#__PURE__*/React.createElement("div", {
|
336
443
|
className: cls("".concat(prefixCls, "-tag"), advancedFilterVisible ? "".concat(prefixCls, "-tag-hidden") : '')
|
337
|
-
}, /*#__PURE__*/React.createElement(Tag.Group, null, tagDataSource.map(function (
|
338
|
-
var key =
|
339
|
-
label =
|
340
|
-
value =
|
341
|
-
type =
|
444
|
+
}, /*#__PURE__*/React.createElement(Tag.Group, null, tagDataSource.map(function (_ref4) {
|
445
|
+
var key = _ref4.key,
|
446
|
+
label = _ref4.label,
|
447
|
+
value = _ref4.value,
|
448
|
+
type = _ref4.type;
|
342
449
|
return /*#__PURE__*/React.createElement(Tag.Closeable, {
|
343
450
|
key: key,
|
344
451
|
afterClose: function afterClose() {
|
@@ -355,8 +462,8 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
355
462
|
}))), /*#__PURE__*/React.createElement("div", {
|
356
463
|
className: cls("".concat(prefixCls, "-advanced-wrap"), !advancedFilterVisible ? "".concat(prefixCls, "-advanced-wrap-hidden") : '')
|
357
464
|
}, /*#__PURE__*/React.createElement(AdvancedFilter, _objectSpread(_objectSpread({}, otherProps), {}, {
|
358
|
-
form:
|
359
|
-
onSubmit:
|
465
|
+
form: advancedForm,
|
466
|
+
onSubmit: onAdvancedFilter
|
360
467
|
})))) : null);
|
361
468
|
});
|
362
469
|
QueryFilter.defaultProps = {
|
package/es/form/ProForm/index.js
CHANGED
@@ -21,6 +21,7 @@ import { mergeArrayValue } from '../utils';
|
|
21
21
|
import useAutoSubmit from './useAutoSubmit';
|
22
22
|
import useInitialRequest from './useInitialRequest';
|
23
23
|
import validateLocale from '../locales/validate';
|
24
|
+
import debounce from 'lodash.debounce';
|
24
25
|
import './index.scss';
|
25
26
|
registerValidateLocale(validateLocale);
|
26
27
|
var ProForm = /*#__PURE__*/memo(function (_ref) {
|
@@ -80,11 +81,11 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
80
81
|
useEffect(function () {
|
81
82
|
form.removeEffects('onChange');
|
82
83
|
form.addEffects('onChange', function () {
|
83
|
-
onFormValuesChange(function (form) {
|
84
|
+
onFormValuesChange(debounce(function (form) {
|
84
85
|
if (onChange) {
|
85
86
|
onChange(toJS(form.values));
|
86
87
|
}
|
87
|
-
});
|
88
|
+
}, 300));
|
88
89
|
});
|
89
90
|
}, [form, onChange]); // 配置表单默认值
|
90
91
|
|
package/es/form/typing.d.ts
CHANGED
@@ -64,6 +64,10 @@ export interface ProFormProps extends IFormLayoutProps {
|
|
64
64
|
onSubmit?: ((values: any) => any) | CommonRequestConfig;
|
65
65
|
onSubmitFailed?: (feedbacks: IFormFeedback[]) => void;
|
66
66
|
}
|
67
|
+
export interface FilterProps extends ProFormProps {
|
68
|
+
form: FormType;
|
69
|
+
onReset?: (payload?: any) => void;
|
70
|
+
}
|
67
71
|
export interface QueryFilterProps extends ProFormProps {
|
68
72
|
/**
|
69
73
|
* @deprecated triggerType已弃用
|
@@ -73,6 +77,7 @@ export interface QueryFilterProps extends ProFormProps {
|
|
73
77
|
expand?: boolean;
|
74
78
|
addonBefore?: ReactNode;
|
75
79
|
addonAfter?: ReactNode;
|
80
|
+
onInit?: (values: any) => void;
|
76
81
|
onFilter?: (values: any) => void;
|
77
82
|
onReset?: (payload?: any) => void;
|
78
83
|
}
|
package/es/index.d.ts
CHANGED
@@ -21,5 +21,5 @@ export * from './page-container';
|
|
21
21
|
export * from './page-header';
|
22
22
|
export * from './skeleton';
|
23
23
|
export * from './table';
|
24
|
-
declare const version = "1.2.
|
24
|
+
declare const version = "1.2.18";
|
25
25
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, hooks, nocode, templates, utils, };
|
package/es/index.js
CHANGED
@@ -27,7 +27,7 @@ export * from './page-header';
|
|
27
27
|
export * from './skeleton';
|
28
28
|
export * from './table'; // export * from './sidebar';
|
29
29
|
|
30
|
-
var version = '1.2.
|
30
|
+
var version = '1.2.18';
|
31
31
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, // ProLayout,
|
32
32
|
ProPageContainer, ProPageHeader, ProSkeleton, ProTable, // ProSidebar,
|
33
33
|
hooks, nocode, templates, utils };
|
package/es/table/index.js
CHANGED
@@ -59,10 +59,34 @@ var toJS = formilyReactive.toJS;
|
|
59
59
|
* @returns
|
60
60
|
*/
|
61
61
|
|
62
|
-
var processColumns = function processColumns(columns) {
|
63
|
-
|
62
|
+
var processColumns = function processColumns(columns, initialColumns) {
|
63
|
+
var filterColumns = columns.filter(function (item) {
|
64
64
|
return item.columnFilters !== false;
|
65
|
-
});
|
65
|
+
}); // 处理只剩一列批量选择的情况下宽度错乱问题
|
66
|
+
|
67
|
+
if ((filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) && (filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) === 1) {
|
68
|
+
var _filterColumns$, _filterColumns$2;
|
69
|
+
|
70
|
+
if ((_filterColumns$ = filterColumns[0]) === null || _filterColumns$ === void 0 ? void 0 : _filterColumns$.width) {
|
71
|
+
delete filterColumns[0].width;
|
72
|
+
}
|
73
|
+
|
74
|
+
if ((_filterColumns$2 = filterColumns[0]) === null || _filterColumns$2 === void 0 ? void 0 : _filterColumns$2.lock) {
|
75
|
+
filterColumns[0].lock = false;
|
76
|
+
}
|
77
|
+
} else {
|
78
|
+
var _initialColumns$, _initialColumns$2;
|
79
|
+
|
80
|
+
if ((_initialColumns$ = initialColumns[0]) === null || _initialColumns$ === void 0 ? void 0 : _initialColumns$.width) {
|
81
|
+
filterColumns[0].width = initialColumns[0].width;
|
82
|
+
}
|
83
|
+
|
84
|
+
if ((_initialColumns$2 = initialColumns[0]) === null || _initialColumns$2 === void 0 ? void 0 : _initialColumns$2.lock) {
|
85
|
+
filterColumns[0].lock = initialColumns[0].lock;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
return filterColumns;
|
66
90
|
};
|
67
91
|
/** 默认请求翻页参数 */
|
68
92
|
|
@@ -163,7 +187,7 @@ var ProTable = function ProTable(props) {
|
|
163
187
|
sort = _useState10[0],
|
164
188
|
setSort = _useState10[1];
|
165
189
|
|
166
|
-
var _useState11 = useState(requestWhenMount && propsShowSkeleton),
|
190
|
+
var _useState11 = useState(!propsDataSource && requestWhenMount && propsShowSkeleton),
|
167
191
|
_useState12 = _slicedToArray(_useState11, 2),
|
168
192
|
showSkeleton = _useState12[0],
|
169
193
|
setShowSkeleton = _useState12[1]; // 首次加载,渲染骨架屏
|
@@ -180,7 +204,7 @@ var ProTable = function ProTable(props) {
|
|
180
204
|
var tableRef = useRef(null);
|
181
205
|
var actionRef = useRef(); // 传给 table 的过滤后的 columns
|
182
206
|
|
183
|
-
var _useState15 = useState(processColumns(propsColumns !== null && propsColumns !== void 0 ? propsColumns : [])),
|
207
|
+
var _useState15 = useState(processColumns(propsColumns !== null && propsColumns !== void 0 ? propsColumns : [], propsColumns)),
|
184
208
|
_useState16 = _slicedToArray(_useState15, 2),
|
185
209
|
filteredColumns = _useState16[0],
|
186
210
|
setFilteredColumns = _useState16[1];
|
@@ -351,10 +375,16 @@ var ProTable = function ProTable(props) {
|
|
351
375
|
useEffect(function () {
|
352
376
|
var _actionRef$current, _actionRef$current$se;
|
353
377
|
|
354
|
-
var columns = processColumns(propsColumns !== null && propsColumns !== void 0 ? propsColumns : []);
|
378
|
+
var columns = processColumns(propsColumns !== null && propsColumns !== void 0 ? propsColumns : [], propsColumns);
|
355
379
|
setFilteredColumns(columns);
|
356
380
|
(_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$se = _actionRef$current.setState) === null || _actionRef$current$se === void 0 ? void 0 : _actionRef$current$se.call(_actionRef$current, 'filterColumns', columns);
|
357
|
-
}, [propsColumns]); //
|
381
|
+
}, [propsColumns]); // dataSource 受控
|
382
|
+
|
383
|
+
useEffect(function () {
|
384
|
+
if (propsDataSource) {
|
385
|
+
setData(propsDataSource);
|
386
|
+
}
|
387
|
+
}, [propsDataSource]); // 绑定 Actions
|
358
388
|
|
359
389
|
useActionType(actionRef, {
|
360
390
|
fullScreen: function fullScreen() {
|
@@ -369,7 +399,7 @@ var ProTable = function ProTable(props) {
|
|
369
399
|
setColumn: function setColumn(newColumns) {
|
370
400
|
var _actionRef$current2, _actionRef$current2$s;
|
371
401
|
|
372
|
-
var columns = processColumns(newColumns);
|
402
|
+
var columns = processColumns(newColumns, propsColumns);
|
373
403
|
setFilteredColumns(columns);
|
374
404
|
(_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$s = _actionRef$current2.setState) === null || _actionRef$current2$s === void 0 ? void 0 : _actionRef$current2$s.call(_actionRef$current2, 'filterColumns', columns);
|
375
405
|
},
|
@@ -623,10 +653,7 @@ var ProTable = function ProTable(props) {
|
|
623
653
|
|
624
654
|
// 搜索变化时,暂时先清空选择
|
625
655
|
(_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : (_actionRef$current6$c = _actionRef$current6.clearRowSelection) === null || _actionRef$current6$c === void 0 ? void 0 : _actionRef$current6$c.call(_actionRef$current6);
|
626
|
-
setCurrentPage(1);
|
627
|
-
// TODO: 针对 inline 模式下的 search 组件做一下处理,如果空值切换下拉的时候不触发请求
|
628
|
-
// if (mode === 'inline') {
|
629
|
-
// }
|
656
|
+
setCurrentPage(1);
|
630
657
|
|
631
658
|
_request(_defineProperty({}, targetPageKey, 1));
|
632
659
|
}
|
package/lib/actions/base.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
/// <reference types="react" />
|
1
2
|
import { MaybePromise } from '@teamix/utils';
|
2
3
|
export interface BaseAction {
|
3
4
|
/** 事件触发方式,默认是 onClick */
|
@@ -17,7 +18,7 @@ export interface BaseAction {
|
|
17
18
|
/** 事件开始执行完毕的回调函数 */
|
18
19
|
onFinish?: (params?: any) => any;
|
19
20
|
}
|
20
|
-
export declare function eventHandler(action: BaseAction, actionContext: any, onTrigger: (context: any) => void): {
|
21
|
+
export declare function eventHandler(action: BaseAction, actionContext: any, onTrigger: (context: any, e: React.MouseEvent<HTMLElement>) => void): {
|
21
22
|
[x: string]: (e: React.MouseEvent<HTMLElement>) => Promise<void>;
|
22
23
|
};
|
23
24
|
export default eventHandler;
|
package/lib/actions/base.js
CHANGED
@@ -65,7 +65,7 @@ function eventHandler(action, actionContext, onTrigger) {
|
|
65
65
|
return _context.abrupt("return");
|
66
66
|
|
67
67
|
case 14:
|
68
|
-
onTrigger(Object.assign({}, beforeActionContext, actionContext));
|
68
|
+
onTrigger(Object.assign({}, beforeActionContext, actionContext), e);
|
69
69
|
(_action$onTrigger = action.onTrigger) === null || _action$onTrigger === void 0 ? void 0 : _action$onTrigger.call(action);
|
70
70
|
|
71
71
|
case 16:
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { PopConfirmAction } from './pop-confirm';
|
2
|
+
export declare function useDangerPopConfirmAction(action: PopConfirmAction, context?: any): {
|
3
|
+
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
4
|
+
};
|
5
|
+
export default useDangerPopConfirmAction;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
exports.useDangerPopConfirmAction = useDangerPopConfirmAction;
|
8
|
+
|
9
|
+
var _utils = require("@teamix/utils");
|
10
|
+
|
11
|
+
var _dialog = require("./dialog");
|
12
|
+
|
13
|
+
function useDangerPopConfirmAction(action, context) {
|
14
|
+
return (0, _dialog.useDialogAction)((0, _utils.deepMerge)({
|
15
|
+
dialogType: 'pop',
|
16
|
+
popType: 'danger',
|
17
|
+
align: 'br'
|
18
|
+
}, action), context);
|
19
|
+
}
|
20
|
+
|
21
|
+
var _default = useDangerPopConfirmAction;
|
22
|
+
exports.default = _default;
|
package/lib/actions/dialog.d.ts
CHANGED
@@ -8,7 +8,7 @@ export interface DialogAction extends Omit<RequestAction, 'url'>, Omit<QuickShow
|
|
8
8
|
/** 点击「确认按钮」后的数据请求地址,非必填,不填就不发请求 */
|
9
9
|
url?: string;
|
10
10
|
/** 弹窗类型,支持普通弹窗和抽屉两种模式,默认为普通弹窗 */
|
11
|
-
dialogType?: 'dialog' | 'drawer';
|
11
|
+
dialogType?: 'dialog' | 'drawer' | 'pop';
|
12
12
|
/** 弹窗快捷调用类型 */
|
13
13
|
dialogQuickShowType?: 'alert' | 'confirm';
|
14
14
|
/** 弹窗消息类型 */
|