@teamix/pro 1.2.15 → 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 +832 -320
- 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 +5 -0
- package/es/actions/index.js +38 -14
- 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 -14
- package/es/form/Components/LightFilter/index.scss +13 -3
- package/es/form/Filter/index.js +2 -2
- package/es/form/Filter/index2.js +157 -50
- package/es/form/Filter/index2.scss +3 -0
- package/es/form/ProForm/index.js +4 -2
- package/es/form/ProForm/useFieldRequest.js +1 -8
- package/es/form/SchemaForm/index.js +4 -2
- package/es/form/typing.d.ts +5 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/nocode/configurators/ProTable.js +1 -0
- package/es/table/components/Filter/index.js +42 -16
- package/es/table/components/ToolBar/FilterColumnIcon.js +1 -1
- package/es/table/index.js +61 -13
- package/es/table/typing.d.ts +5 -0
- package/es/table/utils/columnRender.js +1 -1
- 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 +5 -0
- package/lib/actions/index.js +40 -14
- 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 -13
- package/lib/form/Components/LightFilter/index.scss +13 -3
- package/lib/form/Filter/index.js +2 -2
- package/lib/form/Filter/index2.js +157 -49
- package/lib/form/Filter/index2.scss +3 -0
- package/lib/form/ProForm/index.js +5 -2
- package/lib/form/ProForm/useFieldRequest.js +1 -9
- package/lib/form/SchemaForm/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/nocode/configurators/ProTable.js +1 -0
- package/lib/table/components/Filter/index.js +42 -16
- package/lib/table/components/ToolBar/FilterColumnIcon.js +1 -1
- package/lib/table/index.js +61 -13
- package/lib/table/typing.d.ts +5 -0
- package/lib/table/utils/columnRender.js +1 -1
- package/package.json +2 -2
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
|
},
|
@@ -381,6 +411,15 @@ var ProTable = function ProTable(props) {
|
|
381
411
|
},
|
382
412
|
request: function request(params) {
|
383
413
|
if (dataFilterForm.validate()) {
|
414
|
+
// 如果请求中还有翻页相关信息,需要自动设置到指定页
|
415
|
+
if (params === null || params === void 0 ? void 0 : params[targetPageKey]) {
|
416
|
+
setCurrentPage(params[targetPageKey]);
|
417
|
+
}
|
418
|
+
|
419
|
+
if (params === null || params === void 0 ? void 0 : params[targetPageSizeKey]) {
|
420
|
+
setPageSize(params[targetPageSizeKey]);
|
421
|
+
}
|
422
|
+
|
384
423
|
_request(params);
|
385
424
|
}
|
386
425
|
},
|
@@ -398,6 +437,7 @@ var ProTable = function ProTable(props) {
|
|
398
437
|
resetPage: function resetPage() {
|
399
438
|
setCurrentPage(1);
|
400
439
|
},
|
440
|
+
rowSelection: rowSelection,
|
401
441
|
clearRowSelection: function clearRowSelection() {
|
402
442
|
rowSelectionHook.setSelectedRowKeys([]);
|
403
443
|
rowSelectionHook.setSelectedRecords([]);
|
@@ -410,6 +450,7 @@ var ProTable = function ProTable(props) {
|
|
410
450
|
targetPageSizeKey: targetPageSizeKey,
|
411
451
|
pageSize: pageSize
|
412
452
|
},
|
453
|
+
data: data,
|
413
454
|
dataFilterForm: dataFilterForm,
|
414
455
|
resetTableMaxBodyHeight: function resetTableMaxBodyHeight() {
|
415
456
|
getHeaderHeight().then(function (height) {
|
@@ -608,10 +649,11 @@ var ProTable = function ProTable(props) {
|
|
608
649
|
(propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter(_objectSpread({}, toJS(dataFilterForm.values))));
|
609
650
|
|
610
651
|
if (dataFilterForm.validate()) {
|
611
|
-
|
612
|
-
|
613
|
-
//
|
614
|
-
|
652
|
+
var _actionRef$current6, _actionRef$current6$c;
|
653
|
+
|
654
|
+
// 搜索变化时,暂时先清空选择
|
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);
|
656
|
+
setCurrentPage(1);
|
615
657
|
|
616
658
|
_request(_defineProperty({}, targetPageKey, 1));
|
617
659
|
}
|
@@ -704,15 +746,21 @@ var ProTable = function ProTable(props) {
|
|
704
746
|
|
705
747
|
var renderFooter = function renderFooter() {
|
706
748
|
function onChangePagination(currentPage) {
|
749
|
+
var _actionRef$current7, _actionRef$current7$c;
|
750
|
+
|
707
751
|
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
752
|
+
// 翻页暂时先清空选择
|
753
|
+
(_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$c = _actionRef$current7.clearRowSelection) === null || _actionRef$current7$c === void 0 ? void 0 : _actionRef$current7$c.call(_actionRef$current7);
|
708
754
|
setCurrentPage(currentPage);
|
709
755
|
|
710
756
|
_request(_objectSpread(_defineProperty({}, targetPageKey, currentPage), params));
|
711
757
|
}
|
712
758
|
|
713
759
|
function onChangePaginationSize(currentPageSize) {
|
714
|
-
var _request5;
|
760
|
+
var _actionRef$current8, _actionRef$current8$c, _request5;
|
715
761
|
|
762
|
+
// 翻页暂时先清空选择
|
763
|
+
(_actionRef$current8 = actionRef.current) === null || _actionRef$current8 === void 0 ? void 0 : (_actionRef$current8$c = _actionRef$current8.clearRowSelection) === null || _actionRef$current8$c === void 0 ? void 0 : _actionRef$current8$c.call(_actionRef$current8);
|
716
764
|
setPageSize(currentPageSize);
|
717
765
|
setCurrentPage(1);
|
718
766
|
|
package/es/table/typing.d.ts
CHANGED
@@ -129,6 +129,7 @@ export declare type rowSelectionType = {
|
|
129
129
|
onSelect?: (selected: boolean, record: any, records: Array<any>) => void;
|
130
130
|
onSelectAll?: (selected: boolean, records: Array<any>) => void;
|
131
131
|
selectedRowKeys?: Array<any>;
|
132
|
+
selectedRecords?: any[];
|
132
133
|
mode?: 'single' | 'multiple';
|
133
134
|
titleProps?: () => any;
|
134
135
|
columnProps?: () => any;
|
@@ -154,6 +155,8 @@ export declare type ProTableActionType = {
|
|
154
155
|
request?: (params?: any) => void;
|
155
156
|
/** 重置表格 */
|
156
157
|
reset?: () => void;
|
158
|
+
/** 表格选择相关属性 */
|
159
|
+
rowSelection?: innerRowSelectionType | rowSelectionType;
|
157
160
|
/** 清空表格选择 */
|
158
161
|
clearRowSelection?: () => void;
|
159
162
|
/** 过滤 DataSource */
|
@@ -175,6 +178,8 @@ export declare type ProTableActionType = {
|
|
175
178
|
resetPage?: () => void;
|
176
179
|
/** 获取数据过滤区表单实例 */
|
177
180
|
dataFilterForm?: FormType;
|
181
|
+
/** 表格当前的数据 */
|
182
|
+
data?: any[];
|
178
183
|
} & ProTableActionTypeMutations;
|
179
184
|
/** action State 定义 */
|
180
185
|
export declare type ProTableActionTypeMutations = {
|
@@ -96,7 +96,7 @@ export var renderColumnsTitle = function renderColumnsTitle(item, actionRef) {
|
|
96
96
|
};
|
97
97
|
|
98
98
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LabelIconTip, {
|
99
|
-
label:
|
99
|
+
label: item.title,
|
100
100
|
tooltip: item.tooltip,
|
101
101
|
icon: item.tooltipIcon
|
102
102
|
}), item.filters && /*#__PURE__*/React.createElement(Filter, {
|
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
|
/** 弹窗消息类型 */
|
package/lib/actions/dialog.js
CHANGED
@@ -16,6 +16,8 @@ var _reactRouterDom = require("react-router-dom");
|
|
16
16
|
|
17
17
|
var _components = require("@alicloudfe/components");
|
18
18
|
|
19
|
+
var _popConfirm = _interopRequireDefault(require("@teamix/pop-confirm"));
|
20
|
+
|
19
21
|
var _utils = require("@teamix/utils");
|
20
22
|
|
21
23
|
var _form = _interopRequireWildcard(require("../form"));
|
@@ -29,7 +31,7 @@ var _request = require("./request");
|
|
29
31
|
var _utils2 = require("./utils");
|
30
32
|
|
31
33
|
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", "className"];
|
34
|
+
_excluded2 = ["title", "content", "component", "schema", "onFinish", "dialogType", "dialogQuickShowType", "messageType", "popType", "beforeRequest", "onTrigger", "link", "beforeContent", "afterContent", "message", "footerDescription", "footerAlign", "className"];
|
33
35
|
|
34
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
35
37
|
|
@@ -102,7 +104,9 @@ function useDialogAction(action, actionContext) {
|
|
102
104
|
var footerDescriptionRef = (0, _react.useRef)();
|
103
105
|
var history = (0, _reactRouterDom.useHistory)();
|
104
106
|
|
105
|
-
var onActionStart = function onActionStart(context) {
|
107
|
+
var onActionStart = function onActionStart(context, e) {
|
108
|
+
var _objectSpread2;
|
109
|
+
|
106
110
|
var url = action.url,
|
107
111
|
method = action.method,
|
108
112
|
params = action.params,
|
@@ -126,6 +130,7 @@ function useDialogAction(action, actionContext) {
|
|
126
130
|
dialogQuickShowType = _getTargetValue.dialogQuickShowType,
|
127
131
|
_getTargetValue$messa = _getTargetValue.messageType,
|
128
132
|
messageType = _getTargetValue$messa === void 0 ? 'notice' : _getTargetValue$messa,
|
133
|
+
popType = _getTargetValue.popType,
|
129
134
|
beforeRequest = _getTargetValue.beforeRequest,
|
130
135
|
onTrigger = _getTargetValue.onTrigger,
|
131
136
|
link = _getTargetValue.link,
|
@@ -135,20 +140,25 @@ function useDialogAction(action, actionContext) {
|
|
135
140
|
footerDescription = _getTargetValue.footerDescription,
|
136
141
|
footerAlign = _getTargetValue.footerAlign,
|
137
142
|
className = _getTargetValue.className,
|
138
|
-
|
143
|
+
containerOtherProps = _objectWithoutProperties(_getTargetValue, _excluded2);
|
139
144
|
|
140
145
|
var isDrawer = dialogType === 'drawer';
|
141
|
-
var
|
142
|
-
var
|
146
|
+
var isPop = dialogType === 'pop';
|
147
|
+
var container = isDrawer ? _components.Drawer : isPop ? _popConfirm.default : _components.Dialog;
|
148
|
+
var containerProps = isDrawer ? {
|
149
|
+
okText: (0, _utils.getMessage)('ok'),
|
150
|
+
cancelText: (0, _utils.getMessage)('cancel'),
|
151
|
+
closeable: !loading
|
152
|
+
} : isPop ? {
|
153
|
+
type: popType,
|
154
|
+
trigger: e.currentTarget
|
155
|
+
} : {
|
143
156
|
type: dialogQuickShowType,
|
144
157
|
messageProps: {
|
145
158
|
type: messageType
|
146
|
-
}
|
159
|
+
},
|
160
|
+
closeable: !loading
|
147
161
|
};
|
148
|
-
var containerOtherProps = isDrawer ? {
|
149
|
-
okText: (0, _utils.getMessage)('ok'),
|
150
|
-
cancelText: (0, _utils.getMessage)('cancel')
|
151
|
-
} : dialogOnlyProps;
|
152
162
|
|
153
163
|
var renderDialogFooterDescription = function renderDialogFooterDescription(footer) {
|
154
164
|
if (footer instanceof Array || footer.component) {
|
@@ -243,27 +253,19 @@ function useDialogAction(action, actionContext) {
|
|
243
253
|
key: (0, _utils.uuid)()
|
244
254
|
}, (0, _utils2.addContext)(componentProps, dialogContext))) : addContextForReactNode(content, dialogContext);
|
245
255
|
|
246
|
-
var quickShowProps = _objectSpread(_objectSpread({
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
className: (0, _classnames.default)('teamix-pro-dialog-footer-description', getFooterAlignClass(isDrawer, footerAlign))
|
260
|
-
}, renderDialogFooterDescription(footerDescription))),
|
261
|
-
closeable: !loading,
|
262
|
-
footerAlign: footerAlign,
|
263
|
-
className: (0, _classnames.default)('teamix-pro-action-dialog', {
|
264
|
-
'has-footer-description': !!footerDescription
|
265
|
-
})
|
266
|
-
}, containerOtherProps), containerProps);
|
256
|
+
var quickShowProps = _objectSpread(_objectSpread((_objectSpread2 = {}, _defineProperty(_objectSpread2, "".concat(isPop ? 'onConfirm' : 'onOk'), onOk), _defineProperty(_objectSpread2, "title", addContextForReactNode(title, dialogContext)), _defineProperty(_objectSpread2, "content", /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, beforeContent && /*#__PURE__*/_react.default.createElement("div", {
|
257
|
+
className: "teamix-pro-dialog-before-content"
|
258
|
+
}, addContextForReactNode(beforeContent, dialogContext)), message && /*#__PURE__*/_react.default.createElement("div", {
|
259
|
+
className: "teamix-pro-dialog-message"
|
260
|
+
}, (0, _message.renderProMessage)(message, {
|
261
|
+
type: 'notice'
|
262
|
+
})), dialogContent, afterContent && /*#__PURE__*/_react.default.createElement("div", {
|
263
|
+
className: "teamix-pro-dialog-after-content"
|
264
|
+
}, addContextForReactNode(afterContent, dialogContext)), !isPop && footerDescription && /*#__PURE__*/_react.default.createElement("div", {
|
265
|
+
className: (0, _classnames.default)('teamix-pro-dialog-footer-description', getFooterAlignClass(isDrawer, footerAlign))
|
266
|
+
}, renderDialogFooterDescription(footerDescription)))), _defineProperty(_objectSpread2, "footerAlign", footerAlign), _defineProperty(_objectSpread2, "className", (0, _classnames.default)('teamix-pro-action-dialog', {
|
267
|
+
'has-footer-description': !!footerDescription
|
268
|
+
})), _objectSpread2), containerProps), containerOtherProps);
|
267
269
|
|
268
270
|
var ret = container.show(quickShowProps);
|
269
271
|
store.hide = ret.hide;
|
package/lib/actions/index.d.ts
CHANGED
@@ -7,6 +7,7 @@ import { DialogAction } from './dialog';
|
|
7
7
|
import { DialogFormAction } from './dialog-form';
|
8
8
|
import { DialogTableAction } from './dialog-table';
|
9
9
|
import { DialogInfoAction } from './dialog-info';
|
10
|
+
import { PopConfirmAction } from './pop-confirm';
|
10
11
|
import './index.scss';
|
11
12
|
export declare type ProActionConfig = ({
|
12
13
|
type: 'dialog-form' | 'drawer-form';
|
@@ -15,6 +16,8 @@ export declare type ProActionConfig = ({
|
|
15
16
|
} & DialogTableAction) | ({
|
16
17
|
type: 'dialog-info' | 'drawer-info';
|
17
18
|
} & DialogInfoAction) | ({
|
19
|
+
type: 'pop-confirm' | 'danger-pop-confirm';
|
20
|
+
} & PopConfirmAction) | ({
|
18
21
|
type: 'dialog' | 'drawer' | 'confirm' | 'danger-confirm' | 'notice' | 'error';
|
19
22
|
} & DialogAction) | ({
|
20
23
|
type: 'request';
|
@@ -24,6 +27,7 @@ export declare type ProActionConfig = ({
|
|
24
27
|
export declare function registerActionHandler(id: string, extendActionId: string, defaultConfig: any): void;
|
25
28
|
export declare function useAction(config?: ProActionConfig, context?: any): any;
|
26
29
|
export interface ProActionButtonProps extends ButtonProps {
|
30
|
+
key?: string | number;
|
27
31
|
config?: ProActionConfig;
|
28
32
|
visible?: any;
|
29
33
|
disabled?: any;
|
@@ -33,6 +37,7 @@ export interface ProActionButtonProps extends ButtonProps {
|
|
33
37
|
}
|
34
38
|
export declare const ProActionButton: (props: ProActionButtonProps) => JSX.Element;
|
35
39
|
export interface ProActionMenuButtonProps extends MenuButtonProps {
|
40
|
+
key?: string | number;
|
36
41
|
actions: ProActionProps[];
|
37
42
|
visible?: any;
|
38
43
|
icon?: string;
|
package/lib/actions/index.js
CHANGED
@@ -47,6 +47,10 @@ var _drawerTable = require("./drawer-table");
|
|
47
47
|
|
48
48
|
var _drawerInfo = require("./drawer-info");
|
49
49
|
|
50
|
+
var _popConfirm = require("./pop-confirm");
|
51
|
+
|
52
|
+
var _dangerPopConfirm = require("./danger-pop-confirm");
|
53
|
+
|
50
54
|
require("./index.scss");
|
51
55
|
|
52
56
|
var _excluded = ["type"],
|
@@ -54,8 +58,8 @@ var _excluded = ["type"],
|
|
54
58
|
_excluded3 = ["loading"],
|
55
59
|
_excluded4 = ["icon", "iconSize", "label", "actions", "children", "context", "type"],
|
56
60
|
_excluded5 = ["context", "text"],
|
57
|
-
_excluded6 = ["actions"],
|
58
|
-
_excluded7 = ["config"],
|
61
|
+
_excluded6 = ["key", "actions"],
|
62
|
+
_excluded7 = ["key", "config"],
|
59
63
|
_excluded8 = ["type", "divider", "max", "moreText", "context", "actions", "className"];
|
60
64
|
|
61
65
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -155,6 +159,14 @@ function useAction(config, context) {
|
|
155
159
|
return (0, _drawerInfo.useDrawerInfoAction)(others, context);
|
156
160
|
}
|
157
161
|
|
162
|
+
if (type === 'pop-confirm') {
|
163
|
+
return (0, _popConfirm.usePopConfirmAction)(others, context);
|
164
|
+
}
|
165
|
+
|
166
|
+
if (type === 'danger-pop-confirm') {
|
167
|
+
return (0, _dangerPopConfirm.useDangerPopConfirmAction)(others, context);
|
168
|
+
}
|
169
|
+
|
158
170
|
var registedAction = RegistedActions.get(type);
|
159
171
|
|
160
172
|
if (!registedAction) {
|
@@ -242,8 +254,8 @@ function renderCommonActionButtonMenuItem(action, key, context) {
|
|
242
254
|
return /*#__PURE__*/_react.default.createElement(_components.Menu.SubMenu, {
|
243
255
|
key: key,
|
244
256
|
label: menuBtn.label || menuBtn.children
|
245
|
-
}, menuBtn.actions.map(function (a
|
246
|
-
return renderCommonActionButtonMenuItem(a,
|
257
|
+
}, menuBtn.actions.map(function (a) {
|
258
|
+
return renderCommonActionButtonMenuItem(a, a.key, context);
|
247
259
|
}));
|
248
260
|
}
|
249
261
|
|
@@ -278,7 +290,7 @@ var ProActionMenuButton = function ProActionMenuButton(props) {
|
|
278
290
|
type: type,
|
279
291
|
label: buttonContent(label || children, icon, iconSize, context)
|
280
292
|
}, others), actions.map(function (action, i) {
|
281
|
-
return renderCommonActionButtonMenuItem(action,
|
293
|
+
return renderCommonActionButtonMenuItem(action, action.key || i, context);
|
282
294
|
}));
|
283
295
|
}; // 如果 actions 数量超过了 max,则把第 max 个和剩余超出部分折叠起来成为一个 menu
|
284
296
|
|
@@ -292,7 +304,9 @@ function formatGroupActions(actions, max, moreConfig) {
|
|
292
304
|
return actions;
|
293
305
|
}
|
294
306
|
|
295
|
-
return [].concat(_toConsumableArray(actions.slice(0, MAX - 1)), [_objectSpread(_objectSpread({
|
307
|
+
return [].concat(_toConsumableArray(actions.slice(0, MAX - 1)), [_objectSpread(_objectSpread({
|
308
|
+
key: '__teamix_pro_action_group_more_btn'
|
309
|
+
}, moreConfig), {}, {
|
296
310
|
actions: actions.slice(MAX - 1)
|
297
311
|
})]);
|
298
312
|
} // 渲染一个 button 或者 menu button
|
@@ -338,22 +352,34 @@ function getDefaultMoreButton(type, moreText) {
|
|
338
352
|
|
339
353
|
var MAX_ACTTIONS = 4;
|
340
354
|
|
341
|
-
function
|
355
|
+
function getKey(index, key) {
|
356
|
+
if (key !== undefined) {
|
357
|
+
return key;
|
358
|
+
}
|
359
|
+
|
360
|
+
return "__teamix_pro_action_key_".concat(index);
|
361
|
+
}
|
362
|
+
|
363
|
+
function getActionConfig(action, index, context) {
|
342
364
|
if (action.actions) {
|
343
|
-
var
|
365
|
+
var _key = action.key,
|
366
|
+
actions = action.actions,
|
344
367
|
_others = _objectWithoutProperties(action, _excluded6);
|
345
368
|
|
346
369
|
return _objectSpread({
|
347
|
-
|
348
|
-
|
370
|
+
key: getKey(index, _key),
|
371
|
+
actions: actions.map(function (a, j) {
|
372
|
+
return getActionConfig(a, j, context);
|
349
373
|
})
|
350
374
|
}, (0, _utils.getTargetValue)(_others, context));
|
351
375
|
}
|
352
376
|
|
353
|
-
var
|
377
|
+
var key = action.key,
|
378
|
+
config = action.config,
|
354
379
|
others = _objectWithoutProperties(action, _excluded7);
|
355
380
|
|
356
381
|
return _objectSpread({
|
382
|
+
key: getKey(index, key),
|
357
383
|
config: config
|
358
384
|
}, (0, _utils.getTargetValue)(others, context));
|
359
385
|
}
|
@@ -373,8 +399,8 @@ function ProActionGroup(props) {
|
|
373
399
|
containerProps = _objectWithoutProperties(props, _excluded8);
|
374
400
|
|
375
401
|
var isTypeText = type === 'text';
|
376
|
-
var filteredActions = actions.map(function (action) {
|
377
|
-
return getActionConfig(action, context);
|
402
|
+
var filteredActions = actions.map(function (action, index) {
|
403
|
+
return getActionConfig(action, index, context);
|
378
404
|
}).filter(function (action) {
|
379
405
|
return action.visible !== false;
|
380
406
|
});
|
@@ -386,7 +412,7 @@ function ProActionGroup(props) {
|
|
386
412
|
}, containerProps), formatedActions.map(function (actionBtn, i) {
|
387
413
|
var isLastOne = i === formatedActions.length - 1;
|
388
414
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
389
|
-
key:
|
415
|
+
key: actionBtn.key
|
390
416
|
}, renderCommonActionButton(actionBtn, context, isTypeText), isTypeText && divider && !isLastOne && /*#__PURE__*/_react.default.createElement(_components.Divider, {
|
391
417
|
direction: "ver"
|
392
418
|
}));
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { IPopConfirmProps } from '@teamix/pop-confirm';
|
2
|
+
import { DialogAction } from './dialog';
|
3
|
+
export declare type PopConfirmAction = DialogAction & Omit<IPopConfirmProps, 'type' | 'trigger'> & {
|
4
|
+
popType?: IPopConfirmProps['type'];
|
5
|
+
};
|
6
|
+
export declare function usePopConfirmAction(action: PopConfirmAction, context?: any): {
|
7
|
+
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
8
|
+
};
|
9
|
+
export default usePopConfirmAction;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
exports.usePopConfirmAction = usePopConfirmAction;
|
8
|
+
|
9
|
+
var _utils = require("@teamix/utils");
|
10
|
+
|
11
|
+
var _dialog = _interopRequireDefault(require("./dialog"));
|
12
|
+
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
|
+
|
15
|
+
function usePopConfirmAction(action, context) {
|
16
|
+
return (0, _dialog.default)((0, _utils.deepMerge)({
|
17
|
+
dialogType: 'pop',
|
18
|
+
align: 'br'
|
19
|
+
}, action), context);
|
20
|
+
}
|
21
|
+
|
22
|
+
var _default = usePopConfirmAction;
|
23
|
+
exports.default = _default;
|
@@ -3,10 +3,11 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.inputCategory = exports.componentMap = void 0;
|
7
7
|
var componentMap = {
|
8
8
|
Radio: 'Select',
|
9
9
|
Checkbox: 'Select'
|
10
10
|
};
|
11
|
-
|
12
|
-
|
11
|
+
exports.componentMap = componentMap;
|
12
|
+
var inputCategory = ['Input', 'Password', 'TextArea', 'NumberPicker', 'Percent', 'Money'];
|
13
|
+
exports.inputCategory = inputCategory;
|