@teamix/pro 1.2.9 → 1.2.13
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/212.js +1 -1
- package/dist/pro.css +1 -1
- package/dist/pro.js +2103 -993
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/actions/base.d.ts +16 -6
- package/es/actions/base.js +66 -12
- package/es/actions/confirm.d.ts +1 -1
- package/es/actions/danger-confirm.d.ts +1 -1
- package/es/actions/dialog-component.d.ts +1 -1
- package/es/actions/dialog-form.d.ts +1 -1
- package/es/actions/dialog-form.js +2 -2
- package/es/actions/dialog-info.d.ts +1 -1
- package/es/actions/dialog-table.d.ts +1 -1
- package/es/actions/dialog.d.ts +6 -2
- package/es/actions/dialog.js +9 -5
- package/es/actions/drawer-form.d.ts +1 -1
- package/es/actions/drawer-info.d.ts +1 -1
- package/es/actions/drawer-table.d.ts +1 -1
- package/es/actions/drawer.d.ts +1 -1
- package/es/actions/error.d.ts +1 -1
- package/es/actions/index.js +9 -5
- package/es/actions/index.scss +28 -7
- package/es/actions/link.d.ts +2 -2
- package/es/actions/link.js +2 -2
- package/es/actions/notice.d.ts +1 -1
- package/es/actions/request.d.ts +1 -1
- package/es/actions/request.js +2 -2
- package/es/card/index.d.ts +10 -1
- package/es/card/index.js +20 -5
- package/es/card/index.scss +19 -0
- package/es/card/tab.d.ts +6 -0
- package/es/card/tab.js +27 -0
- package/es/form/Filter/index.d.ts +2 -5
- package/es/form/Filter/index.js +3 -44
- package/es/form/Filter/index.scss +71 -0
- package/es/form/Filter/index2.d.ts +8 -0
- package/es/form/Filter/index2.js +318 -0
- package/es/form/ProForm/index.js +3 -23
- package/es/form/ProForm/index.scss +10 -19
- package/es/form/ProForm/useFormDisplayValues.d.ts +3 -5
- package/es/form/ProForm/useFormDisplayValues.js +44 -38
- package/es/form/SchemaForm/index.js +7 -6
- package/es/form/index.d.ts +11 -10
- package/es/form/index.js +3 -2
- package/es/form/typing.d.ts +3 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/info/components/ProInfoItem/index.js +3 -1
- package/es/nocode/pages/renderer.d.ts +2 -2
- package/es/page-header/index.d.ts +20 -11
- package/es/page-header/index.js +23 -47
- package/es/page-header/index.scss +0 -11
- package/es/table/components/Filter/index.js +11 -9
- package/es/table/components/Filter/index.scss +7 -3
- package/es/table/components/Layout/index.js +10 -1
- package/es/table/index.js +21 -11
- package/es/table/typing.d.ts +6 -0
- package/es/table/utils/columnRender.js +38 -1
- package/es/table/utils/index.js +15 -1
- package/es/utils/components/tags/index.d.ts +15 -0
- package/es/utils/components/tags/index.js +94 -0
- package/es/utils/components/tags/index.scss +12 -0
- package/lib/actions/base.d.ts +16 -6
- package/lib/actions/base.js +67 -12
- package/lib/actions/confirm.d.ts +1 -1
- package/lib/actions/danger-confirm.d.ts +1 -1
- package/lib/actions/dialog-component.d.ts +1 -1
- package/lib/actions/dialog-form.d.ts +1 -1
- package/lib/actions/dialog-form.js +2 -2
- package/lib/actions/dialog-info.d.ts +1 -1
- package/lib/actions/dialog-table.d.ts +1 -1
- package/lib/actions/dialog.d.ts +6 -2
- package/lib/actions/dialog.js +9 -5
- package/lib/actions/drawer-form.d.ts +1 -1
- package/lib/actions/drawer-info.d.ts +1 -1
- package/lib/actions/drawer-table.d.ts +1 -1
- package/lib/actions/drawer.d.ts +1 -1
- package/lib/actions/error.d.ts +1 -1
- package/lib/actions/index.js +9 -5
- package/lib/actions/index.scss +28 -7
- package/lib/actions/link.d.ts +2 -2
- package/lib/actions/link.js +2 -2
- package/lib/actions/notice.d.ts +1 -1
- package/lib/actions/request.d.ts +1 -1
- package/lib/actions/request.js +2 -2
- package/lib/card/index.d.ts +10 -1
- package/lib/card/index.js +22 -4
- package/lib/card/index.scss +19 -0
- package/lib/card/tab.d.ts +6 -0
- package/lib/card/tab.js +39 -0
- package/lib/form/Filter/index.d.ts +2 -5
- package/lib/form/Filter/index.js +4 -45
- package/lib/form/Filter/index.scss +71 -0
- package/lib/form/Filter/index2.d.ts +8 -0
- package/lib/form/Filter/index2.js +342 -0
- package/lib/form/ProForm/index.js +3 -23
- package/lib/form/ProForm/index.scss +10 -19
- package/lib/form/ProForm/useFormDisplayValues.d.ts +3 -5
- package/lib/form/ProForm/useFormDisplayValues.js +51 -44
- package/lib/form/SchemaForm/index.js +7 -6
- package/lib/form/index.d.ts +11 -10
- package/lib/form/index.js +5 -3
- package/lib/form/typing.d.ts +3 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/info/components/ProInfoItem/index.js +3 -1
- package/lib/nocode/pages/renderer.d.ts +2 -2
- package/lib/page-header/index.d.ts +20 -11
- package/lib/page-header/index.js +22 -45
- package/lib/page-header/index.scss +0 -11
- package/lib/table/components/Filter/index.js +10 -8
- package/lib/table/components/Filter/index.scss +7 -3
- package/lib/table/components/Layout/index.js +10 -1
- package/lib/table/index.js +20 -10
- package/lib/table/typing.d.ts +6 -0
- package/lib/table/utils/columnRender.js +38 -1
- package/lib/table/utils/index.js +15 -1
- package/lib/utils/components/tags/index.d.ts +15 -0
- package/lib/utils/components/tags/index.js +114 -0
- package/lib/utils/components/tags/index.scss +12 -0
- package/package.json +4 -4
package/es/table/index.js
CHANGED
@@ -33,7 +33,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
33
33
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
34
34
|
|
35
35
|
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
36
|
-
import { Table, Pagination,
|
36
|
+
import { Table, Pagination, Checkbox } from '@alicloudfe/components';
|
37
37
|
import genProColumnToColumn from './utils/genProColumnToColumn';
|
38
38
|
import { baseClass, useRequest, request as utilResquest, getDeepValue, getMessage, pickProps } from '@teamix/utils';
|
39
39
|
import { ProSkeletonRaw as Skeleton } from '../skeleton';
|
@@ -349,7 +349,11 @@ var ProTable = function ProTable(props) {
|
|
349
349
|
}
|
350
350
|
}, [propsActionRef]);
|
351
351
|
useEffect(function () {
|
352
|
-
|
352
|
+
var _actionRef$current, _actionRef$current$se;
|
353
|
+
|
354
|
+
var columns = processColumns(propsColumns !== null && propsColumns !== void 0 ? propsColumns : []);
|
355
|
+
setFilteredColumns(columns);
|
356
|
+
(_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);
|
353
357
|
}, [propsColumns]); // 绑定 Actions
|
354
358
|
|
355
359
|
useActionType(actionRef, {
|
@@ -363,7 +367,11 @@ var ProTable = function ProTable(props) {
|
|
363
367
|
return state;
|
364
368
|
},
|
365
369
|
setColumn: function setColumn(newColumns) {
|
366
|
-
|
370
|
+
var _actionRef$current2, _actionRef$current2$s;
|
371
|
+
|
372
|
+
var columns = processColumns(newColumns);
|
373
|
+
setFilteredColumns(columns);
|
374
|
+
(_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);
|
367
375
|
},
|
368
376
|
setSize: function setSize(mode) {
|
369
377
|
_setSize(mode);
|
@@ -377,11 +385,11 @@ var ProTable = function ProTable(props) {
|
|
377
385
|
}
|
378
386
|
},
|
379
387
|
reset: function reset() {
|
380
|
-
var _actionRef$
|
388
|
+
var _actionRef$current3, _actionRef$current3$s;
|
381
389
|
|
382
390
|
(propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset()); // 清空列过滤参数
|
383
391
|
|
384
|
-
(_actionRef$
|
392
|
+
(_actionRef$current3 = actionRef.current) === null || _actionRef$current3 === void 0 ? void 0 : (_actionRef$current3$s = _actionRef$current3.setFilterRules) === null || _actionRef$current3$s === void 0 ? void 0 : _actionRef$current3$s.call(_actionRef$current3, {});
|
385
393
|
dataFilterForm.reset();
|
386
394
|
setCurrentPage(1);
|
387
395
|
|
@@ -481,8 +489,7 @@ var ProTable = function ProTable(props) {
|
|
481
489
|
|
482
490
|
if (props.onError) {
|
483
491
|
props.onError(error);
|
484
|
-
} else {
|
485
|
-
Message.error(error.toString());
|
492
|
+
} else {// Message.error(error.toString());
|
486
493
|
} // 重新计算是否需要吸底
|
487
494
|
|
488
495
|
|
@@ -493,7 +500,7 @@ var ProTable = function ProTable(props) {
|
|
493
500
|
}); // 请求函数
|
494
501
|
|
495
502
|
function _request(params, noLoading) {
|
496
|
-
var _actionRef$current$ge, _actionRef$
|
503
|
+
var _actionRef$current$ge, _actionRef$current4, _actionRef$current4$g, _objectSpread2;
|
497
504
|
|
498
505
|
// 如果没有传 url 且没有 customRequest,直接返回
|
499
506
|
if (!url && !customRequest) {
|
@@ -508,7 +515,7 @@ var ProTable = function ProTable(props) {
|
|
508
515
|
|
509
516
|
var dataFilterParams = toJS(dataFilterForm.values); // 列过滤请求参数
|
510
517
|
|
511
|
-
var columnsFilterParams = (_actionRef$current$ge = (_actionRef$
|
518
|
+
var columnsFilterParams = (_actionRef$current$ge = (_actionRef$current4 = actionRef.current) === null || _actionRef$current4 === void 0 ? void 0 : (_actionRef$current4$g = _actionRef$current4.getFilterRules) === null || _actionRef$current4$g === void 0 ? void 0 : _actionRef$current4$g.call(_actionRef$current4)) !== null && _actionRef$current$ge !== void 0 ? _actionRef$current$ge : {}; // 格式化后的请求参数
|
512
519
|
|
513
520
|
var requestData = formatParams(_objectSpread(_objectSpread({}, !showPagination ? _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, dataFilterParams), propsParams), sortParams), columnsFilterParams) : _objectSpread(_objectSpread(_objectSpread(_objectSpread((_objectSpread2 = {}, _defineProperty(_objectSpread2, targetPageKey, currentPage), _defineProperty(_objectSpread2, targetPageSizeKey, pageSize), _objectSpread2), dataFilterParams), propsParams), sortParams), columnsFilterParams)), params));
|
514
521
|
|
@@ -595,7 +602,10 @@ var ProTable = function ProTable(props) {
|
|
595
602
|
(propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter(_objectSpread({}, toJS(dataFilterForm.values))));
|
596
603
|
|
597
604
|
if (dataFilterForm.validate()) {
|
598
|
-
setCurrentPage(1);
|
605
|
+
setCurrentPage(1); // const { mode, schema } = propsDataFilter as ProTableDataFilterProps;
|
606
|
+
// TODO: 针对 inline 模式下的 search 组件做一下处理,如果空值切换下拉的时候不触发请求
|
607
|
+
// if (mode === 'inline') {
|
608
|
+
// }
|
599
609
|
|
600
610
|
_request(_defineProperty({}, targetPageKey, 1));
|
601
611
|
}
|
@@ -773,7 +783,7 @@ var ProTable = function ProTable(props) {
|
|
773
783
|
|
774
784
|
}),
|
775
785
|
ref: tableRef
|
776
|
-
}, renderTable(), footerSuctionState && footerSuction && /*#__PURE__*/React.createElement(ProPageContainer.FixedFooter, null, renderFooter()), !(footerSuctionState && footerSuction) && renderFooter()));
|
786
|
+
}, renderTable(), footerSuctionState && footerSuction && !fullscreenState && /*#__PURE__*/React.createElement(ProPageContainer.FixedFooter, null, renderFooter()), !(footerSuctionState && footerSuction) && !fullscreenState && renderFooter(), fullscreenState && renderFooter()));
|
777
787
|
};
|
778
788
|
|
779
789
|
export default ProTable;
|
package/es/table/typing.d.ts
CHANGED
@@ -180,6 +180,8 @@ export declare type ProTableActionType = {
|
|
180
180
|
export declare type ProTableActionTypeMutations = {
|
181
181
|
/** 获取state状态 */
|
182
182
|
getState?: () => ProTableActionTypeState;
|
183
|
+
/** 设置state状态 */
|
184
|
+
setState?: (key: string, value: any) => void;
|
183
185
|
/** 设置全屏状态 */
|
184
186
|
setFullScreenState?: (state: boolean) => void;
|
185
187
|
/** 绑定state监听事件 */
|
@@ -192,11 +194,15 @@ export declare type ProTableActionTypeMutations = {
|
|
192
194
|
getFilterRules?: () => object;
|
193
195
|
/** 重新计算表格maxHeight高度 */
|
194
196
|
resetTableMaxBodyHeight?: () => void;
|
197
|
+
/** 列筛选规则 */
|
198
|
+
filterColumns?: any[];
|
195
199
|
};
|
196
200
|
/** action Mutations 定义 */
|
197
201
|
export declare type ProTableActionTypeState = {
|
198
202
|
fullScreenState: boolean;
|
199
203
|
filterRules: ProTableColumnsFilterRulesItem;
|
204
|
+
filterColumns: ProTableColumnProps[];
|
205
|
+
[key: string]: any;
|
200
206
|
};
|
201
207
|
export declare type ProTableDataFilterProps = {
|
202
208
|
/** 展示形式 */
|
@@ -37,8 +37,45 @@ import Filter from '../components/Filter';
|
|
37
37
|
*/
|
38
38
|
|
39
39
|
export var renderColumnsTitle = function renderColumnsTitle(item, actionRef) {
|
40
|
+
var filterMode = item.filterMode,
|
41
|
+
filters = item.filters,
|
42
|
+
dataIndex = item.dataIndex,
|
43
|
+
dataSource = item.dataSource;
|
44
|
+
|
45
|
+
var getItemLable = function getItemLable() {
|
46
|
+
if (filterMode !== 'multiple') {
|
47
|
+
var _actionRef$current$ge, _actionRef$current, _actionRef$current$ge2;
|
48
|
+
|
49
|
+
var selectedItem = (_actionRef$current$ge = (_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$ge2 = _actionRef$current.getState) === null || _actionRef$current$ge2 === void 0 ? void 0 : _actionRef$current$ge2.call(_actionRef$current).filterRules) !== null && _actionRef$current$ge !== void 0 ? _actionRef$current$ge : {};
|
50
|
+
|
51
|
+
if (Object.keys(selectedItem).length > 0) {
|
52
|
+
var _selectedItem$dataInd;
|
53
|
+
|
54
|
+
if ((_selectedItem$dataInd = selectedItem[dataIndex]) === null || _selectedItem$dataInd === void 0 ? void 0 : _selectedItem$dataInd.params) {
|
55
|
+
var _targetFilters$find;
|
56
|
+
|
57
|
+
// 找到对应的 label
|
58
|
+
var targetFilters = filters !== null && filters !== void 0 ? filters : [];
|
59
|
+
|
60
|
+
if (filters === true) {
|
61
|
+
targetFilters = dataSource !== null && dataSource !== void 0 ? dataSource : [];
|
62
|
+
}
|
63
|
+
|
64
|
+
var label = (_targetFilters$find = targetFilters.find(function (item) {
|
65
|
+
var _selectedItem$dataInd2;
|
66
|
+
|
67
|
+
return item.value === ((_selectedItem$dataInd2 = selectedItem[dataIndex]) === null || _selectedItem$dataInd2 === void 0 ? void 0 : _selectedItem$dataInd2.params);
|
68
|
+
})) === null || _targetFilters$find === void 0 ? void 0 : _targetFilters$find.label;
|
69
|
+
return "".concat(item.title, " (").concat(label, ")");
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
return item.title;
|
75
|
+
};
|
76
|
+
|
40
77
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LabelIconTip, {
|
41
|
-
label:
|
78
|
+
label: getItemLable(),
|
42
79
|
tooltip: item.tooltip,
|
43
80
|
icon: item.tooltipIcon
|
44
81
|
}), item.filters && /*#__PURE__*/React.createElement(Filter, {
|
package/es/table/utils/index.js
CHANGED
@@ -20,7 +20,8 @@ import cloneDeepLodash from 'lodash.clonedeep'; // 组件内全局状态
|
|
20
20
|
|
21
21
|
var state = {
|
22
22
|
fullScreenState: false,
|
23
|
-
filterRules: {}
|
23
|
+
filterRules: {},
|
24
|
+
filterColumns: []
|
24
25
|
}; // 组件内全局监听事件
|
25
26
|
|
26
27
|
var callback = {
|
@@ -31,6 +32,15 @@ var mutations = {
|
|
31
32
|
getState: function getState() {
|
32
33
|
return state;
|
33
34
|
},
|
35
|
+
setState: function setState(key, value) {
|
36
|
+
state[key] = value;
|
37
|
+
useOn(key, value);
|
38
|
+
|
39
|
+
if (mutations.hasOwnProperty(key)) {
|
40
|
+
mutations[key] = value;
|
41
|
+
}
|
42
|
+
},
|
43
|
+
filterColumns: state.filterColumns,
|
34
44
|
setFullScreenState: function setFullScreenState(fullScreenState) {
|
35
45
|
state.fullScreenState = fullScreenState;
|
36
46
|
useOn('fullScreenState', fullScreenState);
|
@@ -74,6 +84,10 @@ var mutations = {
|
|
74
84
|
* @param name 监听名(作为销毁唯一id使用)
|
75
85
|
*/
|
76
86
|
on: function on(fun, state, name) {
|
87
|
+
if (!callback[state]) {
|
88
|
+
callback[state] = {};
|
89
|
+
}
|
90
|
+
|
77
91
|
callback[state][name] = fun;
|
78
92
|
},
|
79
93
|
off: function off(name) {
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { TagProps, CloseableProps } from '@alicloudfe/components/types/tag';
|
3
|
+
import './index.scss';
|
4
|
+
export declare type ProTagItem = (TagProps | (CloseableProps & {
|
5
|
+
closable: true;
|
6
|
+
})) & {
|
7
|
+
/**
|
8
|
+
* @deprecated 建议使用 children 代替
|
9
|
+
*/
|
10
|
+
text?: string;
|
11
|
+
};
|
12
|
+
export declare type ProTagProps = ProTagItem[] | ProTagItem | React.ReactNode | React.ReactNode[];
|
13
|
+
/** 全局注册 tag 配置 */
|
14
|
+
export declare type GlobalTagProps = ProTagItem[];
|
15
|
+
export declare const renderTags: (tags?: ProTagProps, size?: "small" | "medium" | "large" | undefined) => JSX.Element | null;
|
@@ -0,0 +1,94 @@
|
|
1
|
+
var _excluded = ["text", "children", "closable", "color"];
|
2
|
+
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
4
|
+
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
6
|
+
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
8
|
+
|
9
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
10
|
+
|
11
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
12
|
+
|
13
|
+
import React, { isValidElement } from 'react';
|
14
|
+
import { Tag } from '@alicloudfe/components';
|
15
|
+
import { baseClass, getTagColor, getGlobalConfig } from '../../../../../utils/src';
|
16
|
+
import './index.scss';
|
17
|
+
var cls = baseClass('teamix-pro-tags');
|
18
|
+
export var renderTags = function renderTags(tags, size) {
|
19
|
+
if (!tags || Array.isArray(tags) && !tags.length) {
|
20
|
+
return null;
|
21
|
+
} // 获取全局 tag
|
22
|
+
|
23
|
+
|
24
|
+
var getGlobalTag = function getGlobalTag() {
|
25
|
+
var globalTag = getGlobalConfig('tag'); // GlobalTagNodePropsItem 类型
|
26
|
+
|
27
|
+
if (globalTag) {
|
28
|
+
var globalTagMap = new Map(globalTag.map(function (item) {
|
29
|
+
return [item.color, item];
|
30
|
+
}));
|
31
|
+
return globalTagMap;
|
32
|
+
}
|
33
|
+
|
34
|
+
return null;
|
35
|
+
}; // 渲染单个 tag
|
36
|
+
|
37
|
+
|
38
|
+
var renderTag = function renderTag(item, index) {
|
39
|
+
// @ts-ignore
|
40
|
+
var text = item.text,
|
41
|
+
children = item.children,
|
42
|
+
closable = item.closable,
|
43
|
+
colorProps = item.color,
|
44
|
+
others = _objectWithoutProperties(item, _excluded);
|
45
|
+
|
46
|
+
var color = getTagColor(colorProps !== null && colorProps !== void 0 ? colorProps : '', 'tag');
|
47
|
+
var otherProps = {};
|
48
|
+
var globalTagMap = getGlobalTag();
|
49
|
+
|
50
|
+
if (globalTagMap && globalTagMap.get(color)) {
|
51
|
+
var _globalTagMap$get;
|
52
|
+
|
53
|
+
otherProps = (_globalTagMap$get = globalTagMap.get(color)) !== null && _globalTagMap$get !== void 0 ? _globalTagMap$get : {};
|
54
|
+
}
|
55
|
+
|
56
|
+
if (closable) {
|
57
|
+
return /*#__PURE__*/React.createElement(Tag.Closeable, _objectSpread(_objectSpread({
|
58
|
+
key: index,
|
59
|
+
size: size,
|
60
|
+
style: {
|
61
|
+
marginBottom: 0
|
62
|
+
},
|
63
|
+
color: color
|
64
|
+
}, otherProps), others), text || children);
|
65
|
+
}
|
66
|
+
|
67
|
+
return /*#__PURE__*/React.createElement(Tag, _objectSpread(_objectSpread({
|
68
|
+
key: index,
|
69
|
+
size: size,
|
70
|
+
style: {
|
71
|
+
marginBottom: 0
|
72
|
+
},
|
73
|
+
color: color
|
74
|
+
}, otherProps), others), text || children);
|
75
|
+
};
|
76
|
+
|
77
|
+
if (!Array.isArray(tags)) {
|
78
|
+
if ( /*#__PURE__*/isValidElement(tags)) {
|
79
|
+
return tags;
|
80
|
+
}
|
81
|
+
|
82
|
+
return renderTag(tags, 0);
|
83
|
+
}
|
84
|
+
|
85
|
+
return /*#__PURE__*/React.createElement(Tag.Group, {
|
86
|
+
className: cls('')
|
87
|
+
}, tags.map(function (tag, i) {
|
88
|
+
if ( /*#__PURE__*/isValidElement(tags)) {
|
89
|
+
return tags;
|
90
|
+
}
|
91
|
+
|
92
|
+
return renderTag(tag, i);
|
93
|
+
}));
|
94
|
+
};
|
package/lib/actions/base.d.ts
CHANGED
@@ -1,13 +1,23 @@
|
|
1
|
+
import { MaybePromise } from '@teamix/utils';
|
1
2
|
export interface BaseAction {
|
3
|
+
/** 事件触发方式,默认是 onClick */
|
2
4
|
trigger?: string;
|
3
|
-
|
4
|
-
onFinish?: (prams?: any) => any;
|
5
|
+
/** 事件发生时,是否执行 e.preventDefault() 方法 */
|
5
6
|
preventDefault?: boolean;
|
7
|
+
/** 事件发生时,是否执行 e.stopPropagation() 方法 */
|
6
8
|
stopPropagation?: boolean;
|
7
|
-
|
8
|
-
|
9
|
+
/** 事件执行前的处理函数
|
10
|
+
* 如果返回 false 或者 Promise<false>,则停止 Action 执行。
|
11
|
+
* 如果返回 true 或者 Promise<true>,则正常执行 Action。
|
12
|
+
* 如果返回其他对象,则正常执行 Action,并把返回的对象放到接下来 Action 的上下文中。
|
13
|
+
*/
|
14
|
+
beforeAction?: () => MaybePromise<any>;
|
15
|
+
/** 事件开始执行后的回调函数 */
|
16
|
+
onTrigger?: () => void;
|
17
|
+
/** 事件开始执行完毕的回调函数 */
|
18
|
+
onFinish?: (params?: any) => any;
|
9
19
|
}
|
10
|
-
export declare function eventHandler(action: BaseAction, onTrigger: () => void): {
|
11
|
-
[x: string]: (e: React.MouseEvent<HTMLElement>) => void
|
20
|
+
export declare function eventHandler(action: BaseAction, actionContext: any, onTrigger: (context: any) => void): {
|
21
|
+
[x: string]: (e: React.MouseEvent<HTMLElement>) => Promise<void>;
|
12
22
|
};
|
13
23
|
export default eventHandler;
|
package/lib/actions/base.js
CHANGED
@@ -6,27 +6,82 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.default = void 0;
|
7
7
|
exports.eventHandler = eventHandler;
|
8
8
|
|
9
|
+
var _utils = require("@teamix/utils");
|
10
|
+
|
9
11
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
10
12
|
|
11
|
-
function
|
13
|
+
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); } }
|
14
|
+
|
15
|
+
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); }); }; }
|
16
|
+
|
17
|
+
function eventHandler(action, actionContext, onTrigger) {
|
12
18
|
var _action$trigger = action.trigger,
|
13
19
|
trigger = _action$trigger === void 0 ? 'onClick' : _action$trigger,
|
14
20
|
preventDefault = action.preventDefault,
|
15
|
-
stopPropagation = action.stopPropagation
|
16
|
-
|
17
|
-
|
21
|
+
stopPropagation = action.stopPropagation,
|
22
|
+
beforeAction = action.beforeAction;
|
23
|
+
return _defineProperty({}, "".concat(trigger), function () {
|
24
|
+
var _2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(e) {
|
25
|
+
var _action$onTrigger;
|
18
26
|
|
19
|
-
|
20
|
-
|
21
|
-
|
27
|
+
var beforeActionContext;
|
28
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
29
|
+
while (1) {
|
30
|
+
switch (_context.prev = _context.next) {
|
31
|
+
case 0:
|
32
|
+
if (preventDefault) {
|
33
|
+
e.preventDefault();
|
34
|
+
}
|
35
|
+
|
36
|
+
if (stopPropagation) {
|
37
|
+
e.stopPropagation();
|
38
|
+
}
|
39
|
+
|
40
|
+
if (!beforeAction) {
|
41
|
+
_context.next = 14;
|
42
|
+
break;
|
43
|
+
}
|
44
|
+
|
45
|
+
_context.prev = 3;
|
46
|
+
_context.next = 6;
|
47
|
+
return (0, _utils.resolveMaybePromiseMethod)(beforeAction, actionContext);
|
48
|
+
|
49
|
+
case 6:
|
50
|
+
beforeActionContext = _context.sent;
|
51
|
+
_context.next = 12;
|
52
|
+
break;
|
53
|
+
|
54
|
+
case 9:
|
55
|
+
_context.prev = 9;
|
56
|
+
_context.t0 = _context["catch"](3);
|
57
|
+
beforeActionContext = false;
|
58
|
+
|
59
|
+
case 12:
|
60
|
+
if (!(beforeActionContext === false)) {
|
61
|
+
_context.next = 14;
|
62
|
+
break;
|
63
|
+
}
|
64
|
+
|
65
|
+
return _context.abrupt("return");
|
66
|
+
|
67
|
+
case 14:
|
68
|
+
onTrigger(Object.assign({}, beforeActionContext, actionContext));
|
69
|
+
(_action$onTrigger = action.onTrigger) === null || _action$onTrigger === void 0 ? void 0 : _action$onTrigger.call(action);
|
70
|
+
|
71
|
+
case 16:
|
72
|
+
case "end":
|
73
|
+
return _context.stop();
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}, _callee, null, [[3, 9]]);
|
77
|
+
}));
|
22
78
|
|
23
|
-
|
24
|
-
|
79
|
+
function _(_x) {
|
80
|
+
return _2.apply(this, arguments);
|
25
81
|
}
|
26
82
|
|
27
|
-
|
28
|
-
|
29
|
-
});
|
83
|
+
return _;
|
84
|
+
}());
|
30
85
|
}
|
31
86
|
|
32
87
|
var _default = eventHandler;
|
package/lib/actions/confirm.d.ts
CHANGED
@@ -2,6 +2,6 @@ import { DialogAction } from './dialog';
|
|
2
2
|
export interface ConfirmAction extends DialogAction {
|
3
3
|
}
|
4
4
|
export declare function useConfirmAction(action: DialogAction, context?: any): {
|
5
|
-
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void
|
5
|
+
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
6
6
|
};
|
7
7
|
export default useConfirmAction;
|
@@ -2,6 +2,6 @@ import { DialogAction } from './dialog';
|
|
2
2
|
export interface DangerConfirmAction extends DialogAction {
|
3
3
|
}
|
4
4
|
export declare function useDangerConfirmAction(action: DialogAction, context?: any): {
|
5
|
-
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void
|
5
|
+
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
6
6
|
};
|
7
7
|
export default useDangerConfirmAction;
|
@@ -5,6 +5,6 @@ export interface DialogComponentAction extends DialogAction {
|
|
5
5
|
component: React.FC<any>;
|
6
6
|
}
|
7
7
|
export declare function useDialogComponentAction(action: DialogComponentAction, context?: any): {
|
8
|
-
[x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void
|
8
|
+
[x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
9
9
|
};
|
10
10
|
export default useDialogComponentAction;
|
@@ -17,6 +17,6 @@ export interface DialogFormAction extends DialogAction {
|
|
17
17
|
schema: ProFormSchema | ProFormProps;
|
18
18
|
}
|
19
19
|
export declare function useDialogFormAction(action: DialogFormAction, context?: any): {
|
20
|
-
[x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void
|
20
|
+
[x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
21
21
|
};
|
22
22
|
export default useDialogFormAction;
|
@@ -163,14 +163,14 @@ function useDialogFormAction(action, context) {
|
|
163
163
|
return (0, _dialog.default)(Object.assign({
|
164
164
|
size: size,
|
165
165
|
closeable: true,
|
166
|
-
content: function content() {
|
166
|
+
content: function content(contentContext) {
|
167
167
|
var dialogFormProps = {
|
168
168
|
initialValues: initialValues,
|
169
169
|
initialRequest: initialRequest,
|
170
170
|
schema: schema,
|
171
171
|
size: size,
|
172
172
|
formProps: formProps,
|
173
|
-
context:
|
173
|
+
context: contentContext
|
174
174
|
};
|
175
175
|
return /*#__PURE__*/_react.default.createElement(DialogForm, _objectSpread({
|
176
176
|
formRef: formRef
|
@@ -4,6 +4,6 @@ export interface DialogInfoAction extends DialogAction {
|
|
4
4
|
schema: ProInfoProps;
|
5
5
|
}
|
6
6
|
export declare function useDialogInfoAction(action: DialogInfoAction, context?: any): {
|
7
|
-
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void
|
7
|
+
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
8
8
|
};
|
9
9
|
export default useDialogInfoAction;
|
@@ -4,6 +4,6 @@ export interface DialogTableAction extends DialogAction {
|
|
4
4
|
schema: ProTableProps;
|
5
5
|
}
|
6
6
|
export declare function useDialogTableAction(action: DialogTableAction, context?: any): {
|
7
|
-
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void
|
7
|
+
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
8
8
|
};
|
9
9
|
export default useDialogTableAction;
|
package/lib/actions/dialog.d.ts
CHANGED
@@ -21,8 +21,12 @@ export interface DialogAction extends Omit<RequestAction, 'url'>, Omit<QuickShow
|
|
21
21
|
afterContent?: React.ReactNode;
|
22
22
|
/** 弹窗页脚描述区,位于按钮组的对面 */
|
23
23
|
footerDescription?: React.ReactNode | ProFormSchema | ProFormSchemaItem;
|
24
|
+
/** 弹窗内容组件的 schema */
|
25
|
+
schema?: any;
|
26
|
+
/** 弹窗内容区的组件 */
|
27
|
+
component?: any;
|
24
28
|
}
|
25
|
-
export declare function useDialogAction(action: DialogAction,
|
26
|
-
[x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void
|
29
|
+
export declare function useDialogAction(action: DialogAction, actionContext?: any): {
|
30
|
+
[x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
27
31
|
};
|
28
32
|
export default useDialogAction;
|
package/lib/actions/dialog.js
CHANGED
@@ -29,7 +29,7 @@ var _request = require("./request");
|
|
29
29
|
var _utils2 = require("./utils");
|
30
30
|
|
31
31
|
var _excluded = ["url", "method", "params", "data", "extendParams", "successMsg", "errorMsg", "formatParams", "formatResult", "onSuccess", "onError"],
|
32
|
-
_excluded2 = ["title", "content", "component", "schema", "onFinish", "dialogType", "dialogQuickShowType", "messageType", "beforeRequest", "onTrigger", "link", "beforeContent", "afterContent", "message", "footerDescription", "footerAlign"];
|
32
|
+
_excluded2 = ["title", "content", "component", "schema", "onFinish", "dialogType", "dialogQuickShowType", "messageType", "beforeRequest", "onTrigger", "link", "beforeContent", "afterContent", "message", "footerDescription", "footerAlign", "className"];
|
33
33
|
|
34
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
35
35
|
|
@@ -93,7 +93,7 @@ function getFooterAlignClass(isDrawer, align) {
|
|
93
93
|
} // 弹窗 -> 请求(点击确认,发送数据请求)
|
94
94
|
|
95
95
|
|
96
|
-
function useDialogAction(action,
|
96
|
+
function useDialogAction(action, actionContext) {
|
97
97
|
var _useState = (0, _react.useState)(false),
|
98
98
|
_useState2 = _slicedToArray(_useState, 2),
|
99
99
|
loading = _useState2[0],
|
@@ -102,7 +102,7 @@ function useDialogAction(action, context) {
|
|
102
102
|
var footerDescriptionRef = (0, _react.useRef)();
|
103
103
|
var history = (0, _reactRouterDom.useHistory)();
|
104
104
|
|
105
|
-
var onActionStart = function onActionStart() {
|
105
|
+
var onActionStart = function onActionStart(context) {
|
106
106
|
var url = action.url,
|
107
107
|
method = action.method,
|
108
108
|
params = action.params,
|
@@ -134,6 +134,7 @@ function useDialogAction(action, context) {
|
|
134
134
|
message = _getTargetValue.message,
|
135
135
|
footerDescription = _getTargetValue.footerDescription,
|
136
136
|
footerAlign = _getTargetValue.footerAlign,
|
137
|
+
className = _getTargetValue.className,
|
137
138
|
containerProps = _objectWithoutProperties(_getTargetValue, _excluded2);
|
138
139
|
|
139
140
|
var isDrawer = dialogType === 'drawer';
|
@@ -256,14 +257,17 @@ function useDialogAction(action, context) {
|
|
256
257
|
className: (0, _classnames.default)('teamix-pro-dialog-footer-description', getFooterAlignClass(isDrawer, footerAlign))
|
257
258
|
}, renderDialogFooterDescription(footerDescription))),
|
258
259
|
closeable: !loading,
|
259
|
-
footerAlign: footerAlign
|
260
|
+
footerAlign: footerAlign,
|
261
|
+
className: (0, _classnames.default)('teamix-pro-action-dialog', {
|
262
|
+
'has-footer-description': !!footerDescription
|
263
|
+
})
|
260
264
|
}, containerOtherProps), containerProps);
|
261
265
|
|
262
266
|
var ret = container.show(quickShowProps);
|
263
267
|
store.hide = ret.hide;
|
264
268
|
};
|
265
269
|
|
266
|
-
return _objectSpread({}, (0, _base.eventHandler)(action, onActionStart));
|
270
|
+
return _objectSpread({}, (0, _base.eventHandler)(action, actionContext, onActionStart));
|
267
271
|
}
|
268
272
|
|
269
273
|
var _default = useDialogAction;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { DialogFormAction } from './dialog-form';
|
2
2
|
export declare type DrawerFormAction = DialogFormAction;
|
3
3
|
export declare function useDrawerFormAction(action: DrawerFormAction, context?: any): {
|
4
|
-
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void
|
4
|
+
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
5
5
|
};
|
6
6
|
export default useDrawerFormAction;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { DialogInfoAction } from './dialog-info';
|
2
2
|
export declare type DrawerInfoAction = DialogInfoAction;
|
3
3
|
export declare function useDrawerInfoAction(action: DrawerInfoAction, context?: any): {
|
4
|
-
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void
|
4
|
+
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
5
5
|
};
|
6
6
|
export default useDrawerInfoAction;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { DialogTableAction } from './dialog-table';
|
2
2
|
export declare type DrawerTableAction = DialogTableAction;
|
3
3
|
export declare function useDrawerTableAction(action: DrawerTableAction, context?: any): {
|
4
|
-
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void
|
4
|
+
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
5
5
|
};
|
6
6
|
export default useDrawerTableAction;
|
package/lib/actions/drawer.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { DialogAction } from './dialog';
|
2
2
|
export declare type DrawerAction = Omit<DialogAction, 'dialogQuickShowType' | 'messageType'>;
|
3
3
|
export declare function useDrawerAction(action: DrawerAction, context?: any): {
|
4
|
-
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void
|
4
|
+
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
5
5
|
};
|
6
6
|
export default useDrawerAction;
|
package/lib/actions/error.d.ts
CHANGED
@@ -2,6 +2,6 @@ import { DialogAction } from './dialog';
|
|
2
2
|
export interface ErrorAction extends DialogAction {
|
3
3
|
}
|
4
4
|
export declare function useErrorAction(action: DialogAction, context?: any): {
|
5
|
-
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void
|
5
|
+
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
6
6
|
};
|
7
7
|
export default useErrorAction;
|