@teamix/pro 1.1.32 → 1.1.36
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 +1183 -637
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/actions/dialog-form.d.ts +8 -1
- package/es/actions/dialog-form.js +32 -15
- package/es/actions/dialog-info.d.ts +9 -0
- package/es/actions/dialog-info.js +23 -0
- package/es/actions/dialog.d.ts +2 -0
- package/es/actions/dialog.js +11 -4
- package/es/actions/drawer-info.d.ts +6 -0
- package/es/actions/drawer-info.js +7 -0
- package/es/actions/index.d.ts +11 -5
- package/es/actions/index.js +40 -19
- package/es/actions/index.scss +8 -0
- package/es/actions/link.js +2 -12
- package/es/form/Components/ProField/index.d.ts +4 -0
- package/es/form/ProForm/index.js +2 -2
- package/es/form/ProForm/useFormDisplayValues.d.ts +6 -0
- package/es/form/ProForm/useFormDisplayValues.js +65 -0
- package/es/form/SchemaForm/adapterType.js +2 -1
- package/es/form/SchemaForm/initializeProField.js +1 -0
- package/es/form/SchemaForm/initializeReactions.js +82 -6
- package/es/form/SchemaForm/reactions.js +4 -2
- package/es/form/index.d.ts +3 -3
- package/es/form/index.js +3 -3
- package/es/form/typing.d.ts +2 -2
- package/es/form/utils.d.ts +31 -8
- package/es/form/utils.js +27 -44
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/info/components/InfoValueItem/index.js +108 -26
- package/es/info/components/baseInfo/index.d.ts +3 -1
- package/es/info/components/baseInfo/index.js +6 -33
- package/es/info/components/headerInfo/index.d.ts +3 -1
- package/es/info/components/headerInfo/index.js +8 -39
- package/es/info/components/tableInfo/index.js +4 -21
- package/es/info/index.js +47 -25
- package/es/info/index.scss +0 -4
- package/es/info/typing.d.ts +14 -5
- package/es/page-header/index.js +1 -1
- package/es/table/components/Filter/index.js +6 -2
- package/es/table/index.js +3 -1
- package/es/table/typing.d.ts +8 -4
- package/es/table/utils/columnRender.js +38 -11
- package/lib/actions/dialog-form.d.ts +8 -1
- package/lib/actions/dialog-form.js +32 -15
- package/lib/actions/dialog-info.d.ts +9 -0
- package/lib/actions/dialog-info.js +37 -0
- package/lib/actions/dialog.d.ts +2 -0
- package/lib/actions/dialog.js +11 -4
- package/lib/actions/drawer-info.d.ts +6 -0
- package/lib/actions/drawer-info.js +18 -0
- package/lib/actions/index.d.ts +11 -5
- package/lib/actions/index.js +41 -18
- package/lib/actions/index.scss +8 -0
- package/lib/actions/link.js +2 -12
- package/lib/form/Components/ProField/index.d.ts +4 -0
- package/lib/form/ProForm/index.js +1 -1
- package/lib/form/ProForm/useFormDisplayValues.d.ts +6 -0
- package/lib/form/ProForm/useFormDisplayValues.js +74 -0
- package/lib/form/SchemaForm/adapterType.js +2 -1
- package/lib/form/SchemaForm/initializeProField.js +1 -0
- package/lib/form/SchemaForm/initializeReactions.js +87 -7
- package/lib/form/SchemaForm/reactions.js +4 -2
- package/lib/form/index.d.ts +3 -3
- package/lib/form/index.js +15 -8
- package/lib/form/typing.d.ts +2 -2
- package/lib/form/utils.d.ts +31 -8
- package/lib/form/utils.js +28 -54
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/info/components/InfoValueItem/index.js +107 -25
- package/lib/info/components/baseInfo/index.d.ts +3 -1
- package/lib/info/components/baseInfo/index.js +5 -40
- package/lib/info/components/headerInfo/index.d.ts +3 -1
- package/lib/info/components/headerInfo/index.js +7 -46
- package/lib/info/components/tableInfo/index.js +4 -22
- package/lib/info/index.js +49 -25
- package/lib/info/index.scss +0 -4
- package/lib/info/typing.d.ts +14 -5
- package/lib/page-header/index.js +1 -1
- package/lib/table/components/Filter/index.js +6 -2
- package/lib/table/index.js +3 -1
- package/lib/table/typing.d.ts +8 -4
- package/lib/table/utils/columnRender.js +38 -11
- package/package.json +1 -1
@@ -3,11 +3,18 @@ import { IFormProps, IFormSchema } from '../form';
|
|
3
3
|
import { RequestAction } from './request';
|
4
4
|
import { DialogAction } from './dialog';
|
5
5
|
export interface DialogFormAction extends DialogAction {
|
6
|
+
/** 表单初始值 */
|
6
7
|
initialValues?: any;
|
8
|
+
/** 表单初始化数据请求 */
|
7
9
|
initialRequest?: RequestAction;
|
10
|
+
/** 表单提交发送数据请求时,是否携带全部表单数据。默认携带 */
|
8
11
|
useFieldValuesForRequest?: boolean;
|
12
|
+
/**
|
13
|
+
* @deprecated 建议使用 schema 配置 IFormProps 代替
|
14
|
+
*/
|
9
15
|
formProps?: Omit<IFormProps, 'schema'>;
|
10
|
-
|
16
|
+
/** 同时支持两种配置方式,如果想完整定制表单,可使用完整的表单配置项 IFormProps,否则可以只配置 IFormSchema */
|
17
|
+
schema: IFormSchema | IFormProps;
|
11
18
|
}
|
12
19
|
export declare function useDialogFormAction(action: DialogFormAction, context?: any): {
|
13
20
|
[x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
@@ -1,14 +1,5 @@
|
|
1
|
-
var _excluded = ["schema",
|
2
|
-
|
3
|
-
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; }
|
4
|
-
|
5
|
-
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; }
|
6
|
-
|
7
|
-
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; }
|
8
|
-
|
9
|
-
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; }
|
10
|
-
|
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; }
|
1
|
+
var _excluded = ["schema"],
|
2
|
+
_excluded2 = ["schema", "useFieldValuesForRequest", "initialValues", "initialRequest", "formProps", "size", "onFinish", "onCancel"];
|
12
3
|
|
13
4
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
14
5
|
|
@@ -22,6 +13,16 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
22
13
|
|
23
14
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
24
15
|
|
16
|
+
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; }
|
17
|
+
|
18
|
+
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; }
|
19
|
+
|
20
|
+
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; }
|
21
|
+
|
22
|
+
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; }
|
23
|
+
|
24
|
+
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; }
|
25
|
+
|
25
26
|
import React, { useState, useRef, useEffect } from 'react';
|
26
27
|
import { useHistory } from 'react-router-dom';
|
27
28
|
import { Loading } from '@alicloudfe/components';
|
@@ -62,15 +63,31 @@ function getDefaultFormPropsByDialogSize(size) {
|
|
62
63
|
};
|
63
64
|
}
|
64
65
|
|
66
|
+
function getSchemaAndFormProps(schema, formProps) {
|
67
|
+
if (schema instanceof Array) {
|
68
|
+
return _objectSpread({
|
69
|
+
schema: schema
|
70
|
+
}, formProps);
|
71
|
+
}
|
72
|
+
|
73
|
+
var formSchema = schema;
|
74
|
+
return formSchema;
|
75
|
+
}
|
76
|
+
|
65
77
|
var DialogForm = function DialogForm(props) {
|
66
78
|
var initialValues = props.initialValues,
|
67
79
|
initialRequest = props.initialRequest,
|
68
|
-
schema = props.schema,
|
69
80
|
_props$size = props.size,
|
70
81
|
size = _props$size === void 0 ? 'small' : _props$size,
|
82
|
+
schema = props.schema,
|
71
83
|
formProps = props.formProps,
|
72
84
|
context = props.context,
|
73
85
|
formRef = props.formRef;
|
86
|
+
|
87
|
+
var _getSchemaAndFormProp = getSchemaAndFormProps(schema, formProps),
|
88
|
+
formSchema = _getSchemaAndFormProp.schema,
|
89
|
+
others = _objectWithoutProperties(_getSchemaAndFormProp, _excluded);
|
90
|
+
|
74
91
|
var form = createForm({
|
75
92
|
initialValues: getTargetValue(initialValues, context)
|
76
93
|
});
|
@@ -101,8 +118,8 @@ var DialogForm = function DialogForm(props) {
|
|
101
118
|
}
|
102
119
|
}, /*#__PURE__*/React.createElement(ProForm, _objectSpread(_objectSpread({
|
103
120
|
form: form,
|
104
|
-
schema: getTargetValue(
|
105
|
-
}, getDefaultFormPropsByDialogSize(size)), getTargetValue(
|
121
|
+
schema: getTargetValue(formSchema, context)
|
122
|
+
}, getDefaultFormPropsByDialogSize(size)), getTargetValue(others, context))));
|
106
123
|
};
|
107
124
|
|
108
125
|
export function useDialogFormAction(action, context) {
|
@@ -117,7 +134,7 @@ export function useDialogFormAction(action, context) {
|
|
117
134
|
size = _action$size === void 0 ? 'small' : _action$size,
|
118
135
|
_onFinish = action.onFinish,
|
119
136
|
_onCancel = action.onCancel,
|
120
|
-
others = _objectWithoutProperties(action,
|
137
|
+
others = _objectWithoutProperties(action, _excluded2);
|
121
138
|
|
122
139
|
var formRef = useRef();
|
123
140
|
return useDialogAction(Object.assign({
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { DialogAction } from './dialog';
|
2
|
+
import { ProInfoProps } from '..';
|
3
|
+
export interface DialogInfoAction extends DialogAction {
|
4
|
+
schema: ProInfoProps;
|
5
|
+
}
|
6
|
+
export declare function useDialogInfoAction(action: DialogInfoAction, context?: any): {
|
7
|
+
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void;
|
8
|
+
};
|
9
|
+
export default useDialogInfoAction;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
var _excluded = ["schema"];
|
2
|
+
|
3
|
+
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; }
|
4
|
+
|
5
|
+
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; }
|
6
|
+
|
7
|
+
import useDialogAction from './dialog';
|
8
|
+
import { ProInfo } from '..';
|
9
|
+
export function useDialogInfoAction(action, context) {
|
10
|
+
var schema = action.schema,
|
11
|
+
others = _objectWithoutProperties(action, _excluded);
|
12
|
+
|
13
|
+
return useDialogAction(Object.assign({
|
14
|
+
component: ProInfo,
|
15
|
+
closeable: true,
|
16
|
+
size: 'mini',
|
17
|
+
schema: Object.assign({
|
18
|
+
backgroundColor: 'grey',
|
19
|
+
compacted: false
|
20
|
+
}, schema)
|
21
|
+
}, others), context);
|
22
|
+
}
|
23
|
+
export default useDialogInfoAction;
|
package/es/actions/dialog.d.ts
CHANGED
@@ -7,6 +7,8 @@ export interface DialogAction extends Omit<RequestAction, 'url'>, Omit<QuickShow
|
|
7
7
|
dialogType?: 'dialog' | 'drawer';
|
8
8
|
dialogQuickShowType?: 'alert' | 'confirm';
|
9
9
|
messageType?: 'success' | 'warning' | 'error' | 'notice' | 'help' | 'loading';
|
10
|
+
beforeContent?: React.ReactNode;
|
11
|
+
afterContent?: React.ReactNode;
|
10
12
|
}
|
11
13
|
export declare function useDialogAction(action: DialogAction, context?: any): {
|
12
14
|
[x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
package/es/actions/dialog.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
var _excluded = ["url", "method", "params", "data", "extendParams", "successMsg", "errorMsg", "formatParams", "formatResult", "onSuccess", "onError"],
|
2
|
-
_excluded2 = ["title", "content", "component", "schema", "onFinish", "dialogType", "dialogQuickShowType", "messageType", "beforeRequest", "onTrigger", "link"];
|
2
|
+
_excluded2 = ["title", "content", "component", "schema", "onFinish", "dialogType", "dialogQuickShowType", "messageType", "beforeRequest", "onTrigger", "link", "beforeContent", "afterContent"];
|
3
3
|
|
4
4
|
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); } }
|
5
5
|
|
@@ -77,6 +77,8 @@ export function useDialogAction(action, context) {
|
|
77
77
|
beforeRequest = _getTargetValue.beforeRequest,
|
78
78
|
onTrigger = _getTargetValue.onTrigger,
|
79
79
|
link = _getTargetValue.link,
|
80
|
+
beforeContent = _getTargetValue.beforeContent,
|
81
|
+
afterContent = _getTargetValue.afterContent,
|
80
82
|
dialogOtherProps = _objectWithoutProperties(_getTargetValue, _excluded2);
|
81
83
|
|
82
84
|
var dialogMethod = dialogType === 'drawer' ? Drawer : Dialog;
|
@@ -152,13 +154,18 @@ export function useDialogAction(action, context) {
|
|
152
154
|
var dialogContext = Object.assign({}, context, {
|
153
155
|
hide: hide
|
154
156
|
});
|
157
|
+
var dialogContent = Component ? /*#__PURE__*/React.createElement(Component, _objectSpread({
|
158
|
+
key: uuid()
|
159
|
+
}, componentProps)) : addContextForReactNode(content, dialogContext);
|
155
160
|
var ret = dialogMethod.show(_objectSpread(_objectSpread({
|
156
161
|
// @ts-ignore
|
157
162
|
onOk: onOk,
|
158
163
|
title: addContextForReactNode(title, dialogContext),
|
159
|
-
content:
|
160
|
-
|
161
|
-
},
|
164
|
+
content: /*#__PURE__*/React.createElement(React.Fragment, null, beforeContent && /*#__PURE__*/React.createElement("div", {
|
165
|
+
className: "teamix-pro-dialog-before-content"
|
166
|
+
}, beforeContent), dialogContent, afterContent && /*#__PURE__*/React.createElement("div", {
|
167
|
+
className: "teamix-pro-dialog-after-content"
|
168
|
+
}, afterContent)),
|
162
169
|
closeable: !loading
|
163
170
|
}, dialogProps), dialogOtherProps));
|
164
171
|
store.hide = ret.hide;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { DialogInfoAction } from './dialog-info';
|
2
|
+
export declare type DrawerInfoAction = DialogInfoAction;
|
3
|
+
export declare function useDrawerInfoAction(action: DrawerInfoAction, context?: any): {
|
4
|
+
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void;
|
5
|
+
};
|
6
|
+
export default useDrawerInfoAction;
|
package/es/actions/index.d.ts
CHANGED
@@ -10,17 +10,17 @@ import { NoticeAction } from './notice';
|
|
10
10
|
import { ErrorAction } from './error';
|
11
11
|
import { DialogFormAction } from './dialog-form';
|
12
12
|
import { DialogTableAction } from './dialog-table';
|
13
|
+
import { DialogInfoAction } from './dialog-info';
|
13
14
|
import { DrawerAction } from './drawer';
|
14
15
|
import { DrawerFormAction } from './drawer-form';
|
15
16
|
import { DrawerTableAction } from './drawer-table';
|
17
|
+
import { DrawerInfoAction } from './drawer-info';
|
16
18
|
import './index.scss';
|
17
19
|
export declare type ActionConfig = ({
|
18
20
|
type: 'link';
|
19
21
|
} & LinkAction) | ({
|
20
22
|
type: 'request';
|
21
23
|
} & RequestAction) | ({
|
22
|
-
type: 'dialog';
|
23
|
-
} & DialogAction) | ({
|
24
24
|
type: 'confirm';
|
25
25
|
} & ConfirmAction) | ({
|
26
26
|
type: 'danger-confirm';
|
@@ -29,16 +29,22 @@ export declare type ActionConfig = ({
|
|
29
29
|
} & NoticeAction) | ({
|
30
30
|
type: 'error';
|
31
31
|
} & ErrorAction) | ({
|
32
|
+
type: 'dialog';
|
33
|
+
} & DialogAction) | ({
|
32
34
|
type: 'dialog-form';
|
33
35
|
} & DialogFormAction) | ({
|
36
|
+
type: 'dialog-table';
|
37
|
+
} & DialogTableAction) | ({
|
38
|
+
type: 'dialog-info';
|
39
|
+
} & DialogInfoAction) | ({
|
34
40
|
type: 'drawer';
|
35
41
|
} & DrawerAction) | ({
|
36
42
|
type: 'drawer-form';
|
37
43
|
} & DrawerFormAction) | ({
|
38
|
-
type: 'dialog-table';
|
39
|
-
} & DialogTableAction) | ({
|
40
44
|
type: 'drawer-table';
|
41
|
-
} & DrawerTableAction)
|
45
|
+
} & DrawerTableAction) | ({
|
46
|
+
type: 'drawer-info';
|
47
|
+
} & DrawerInfoAction);
|
42
48
|
export declare function registerActionHandler(id: string, extendActionId: string, defaultConfig: any): void;
|
43
49
|
export declare const useAction: any;
|
44
50
|
export interface IActionButton extends ButtonProps {
|
package/es/actions/index.js
CHANGED
@@ -33,7 +33,7 @@ import React from 'react';
|
|
33
33
|
import cls from 'classnames';
|
34
34
|
import { Button, MenuButton, Menu, Divider } from '@alicloudfe/components';
|
35
35
|
import Icon from '@teamix/icon';
|
36
|
-
import { getTargetValue } from '@teamix/utils';
|
36
|
+
import { getTargetValue, getMessage } from '@teamix/utils';
|
37
37
|
import { useLinkAction } from './link';
|
38
38
|
import { useRequestAction } from './request';
|
39
39
|
import { useDialogAction } from './dialog';
|
@@ -43,9 +43,11 @@ import { useNoticeAction } from './notice';
|
|
43
43
|
import { useErrorAction } from './error';
|
44
44
|
import { useDialogFormAction } from './dialog-form';
|
45
45
|
import { useDialogTableAction } from './dialog-table';
|
46
|
+
import { useDialogInfoAction } from './dialog-info';
|
46
47
|
import { useDrawerAction } from './drawer';
|
47
48
|
import { useDrawerFormAction } from './drawer-form';
|
48
49
|
import { useDrawerTableAction } from './drawer-table';
|
50
|
+
import { useDrawerInfoAction } from './drawer-info';
|
49
51
|
import './index.scss';
|
50
52
|
var RegistedActions = new Map();
|
51
53
|
export function registerActionHandler(id, extendActionId, defaultConfig) {
|
@@ -98,6 +100,10 @@ export var useAction = function useAction(config, context) {
|
|
98
100
|
return useDialogTableAction(others, context);
|
99
101
|
}
|
100
102
|
|
103
|
+
if (type === 'dialog-info') {
|
104
|
+
return useDialogInfoAction(others, context);
|
105
|
+
}
|
106
|
+
|
101
107
|
if (type === 'drawer') {
|
102
108
|
return useDrawerAction(others, context);
|
103
109
|
}
|
@@ -110,6 +116,10 @@ export var useAction = function useAction(config, context) {
|
|
110
116
|
return useDrawerTableAction(others, context);
|
111
117
|
}
|
112
118
|
|
119
|
+
if (type === 'drawer-info') {
|
120
|
+
return useDrawerInfoAction(others, context);
|
121
|
+
}
|
122
|
+
|
113
123
|
var registedAction = RegistedActions.get(type);
|
114
124
|
|
115
125
|
if (!registedAction) {
|
@@ -121,16 +131,18 @@ export var useAction = function useAction(config, context) {
|
|
121
131
|
}, registedAction.defaultConfig), others), context);
|
122
132
|
};
|
123
133
|
|
124
|
-
var buttonContent = function buttonContent(content, iconType, iconSize) {
|
134
|
+
var buttonContent = function buttonContent(content, iconType, iconSize, context) {
|
135
|
+
var renderedContent = typeof content === 'function' ? content(context) : content;
|
136
|
+
|
125
137
|
if (!iconType) {
|
126
|
-
return
|
138
|
+
return renderedContent;
|
127
139
|
}
|
128
140
|
|
129
141
|
return [/*#__PURE__*/React.createElement(Icon, {
|
130
142
|
type: iconType,
|
131
143
|
size: iconSize,
|
132
144
|
key: "teamix-button-icon"
|
133
|
-
}),
|
145
|
+
}), renderedContent];
|
134
146
|
};
|
135
147
|
|
136
148
|
export var ActionButton = function ActionButton(props) {
|
@@ -154,37 +166,43 @@ export var ActionButton = function ActionButton(props) {
|
|
154
166
|
}) : _objectSpread(_objectSpread({}, actionProps), others);
|
155
167
|
return /*#__PURE__*/React.createElement(Button, _objectSpread({
|
156
168
|
type: type
|
157
|
-
}, buttonProps), buttonContent(children, icon, iconSize));
|
169
|
+
}, buttonProps), buttonContent(children, icon, iconSize, context));
|
158
170
|
};
|
159
171
|
|
160
172
|
function renderMenuButtonItem(item, key, context) {
|
161
|
-
var
|
173
|
+
var config = item.config,
|
174
|
+
btnContext = item.context,
|
175
|
+
_onClick2 = item.onClick,
|
176
|
+
children = item.children,
|
177
|
+
icon = item.icon,
|
178
|
+
disabled = item.disabled;
|
179
|
+
var menuItemActionConfig = Object.assign({}, config, {
|
162
180
|
trigger: 'onClick'
|
163
181
|
});
|
164
182
|
|
165
|
-
var _useAction = useAction(menuItemActionConfig,
|
183
|
+
var _useAction = useAction(menuItemActionConfig, btnContext || context),
|
166
184
|
loading = _useAction.loading,
|
167
185
|
menuItemProps = _objectWithoutProperties(_useAction, _excluded3);
|
168
186
|
|
169
|
-
var buttonProps =
|
187
|
+
var buttonProps = _onClick2 ? _objectSpread(_objectSpread({}, menuItemProps), {}, {
|
170
188
|
onClick: function onClick(e) {
|
171
|
-
return
|
189
|
+
return _onClick2(e, context);
|
172
190
|
}
|
173
191
|
}) : _objectSpread({}, menuItemProps);
|
174
192
|
return /*#__PURE__*/React.createElement(MenuButton.Item, _objectSpread({
|
175
|
-
key: key
|
176
|
-
|
193
|
+
key: key,
|
194
|
+
disabled: disabled
|
195
|
+
}, buttonProps), buttonContent(children, icon, undefined, context));
|
177
196
|
}
|
178
197
|
|
179
198
|
function renderCommonActionButtonMenuItem(action, key, context) {
|
180
|
-
|
181
|
-
|
199
|
+
var menuBtn = action;
|
200
|
+
|
201
|
+
if (menuBtn.actions && menuBtn.actions.length && menuBtn.disabled !== true) {
|
182
202
|
return /*#__PURE__*/React.createElement(Menu.SubMenu, {
|
183
203
|
key: key,
|
184
|
-
label:
|
185
|
-
|
186
|
-
}, //@ts-ignore
|
187
|
-
action.actions.map(function (a, j) {
|
204
|
+
label: menuBtn.label || menuBtn.children
|
205
|
+
}, menuBtn.actions.map(function (a, j) {
|
188
206
|
return renderCommonActionButtonMenuItem(a, j, context);
|
189
207
|
}));
|
190
208
|
}
|
@@ -209,8 +227,11 @@ export var ActionMenuButton = function ActionMenuButton(props) {
|
|
209
227
|
mode: 'popup',
|
210
228
|
triggerType: 'hover'
|
211
229
|
},
|
230
|
+
popupProps: {
|
231
|
+
shouldUpdatePosition: true
|
232
|
+
},
|
212
233
|
type: type,
|
213
|
-
label: buttonContent(label || children, icon, iconSize)
|
234
|
+
label: buttonContent(label || children, icon, iconSize, context)
|
214
235
|
}, others), actions.map(function (action, i) {
|
215
236
|
return renderCommonActionButtonMenuItem(action, i, context);
|
216
237
|
}));
|
@@ -255,7 +276,7 @@ function renderCommonActionButton(button, context, isTypeText) {
|
|
255
276
|
function getDefaultMoreButton(type, moreText) {
|
256
277
|
if (type === 'button') {
|
257
278
|
return {
|
258
|
-
label: moreText || '
|
279
|
+
label: moreText || getMessage('more')
|
259
280
|
};
|
260
281
|
}
|
261
282
|
|
package/es/actions/index.scss
CHANGED
package/es/actions/link.js
CHANGED
@@ -7,19 +7,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
7
7
|
import { getTargetValue, goToLink } from '@teamix/utils';
|
8
8
|
import { eventHandler } from './base';
|
9
9
|
export function useLinkAction(action, context) {
|
10
|
-
var
|
11
|
-
to = _getTargetValue.to,
|
12
|
-
search = _getTargetValue.search,
|
13
|
-
hash = _getTargetValue.hash,
|
14
|
-
blank = _getTargetValue.blank;
|
15
|
-
|
10
|
+
var linkAction = getTargetValue(action, context);
|
16
11
|
return _objectSpread({}, eventHandler(action, function () {
|
17
|
-
goToLink(
|
18
|
-
to: to,
|
19
|
-
search: search,
|
20
|
-
hash: hash,
|
21
|
-
blank: blank
|
22
|
-
});
|
12
|
+
goToLink(linkAction);
|
23
13
|
}));
|
24
14
|
}
|
25
15
|
export default useLinkAction;
|
@@ -143,6 +143,10 @@ declare const _default: React.ForwardRefExoticComponent<(Partial<import("@teamix
|
|
143
143
|
type: "tagFilter";
|
144
144
|
} & {
|
145
145
|
children?: React.ReactNode;
|
146
|
+
}> | Partial<import("@teamix/pro-field/lib/components/FieldTagFilter").IProFieldMultipleTagFilter & {
|
147
|
+
type: "multipleTagPicker";
|
148
|
+
} & {
|
149
|
+
children?: React.ReactNode;
|
146
150
|
}> | Partial<import("@teamix/pro-field/lib/components/FieldMenuSelect").IProFieldMenuSelect & {
|
147
151
|
type: "menuSelect";
|
148
152
|
} & {
|
package/es/form/ProForm/index.js
CHANGED
@@ -18,7 +18,7 @@ import { Form, FormLayout } from '@teamix/formily';
|
|
18
18
|
import TeamixIcon from '@teamix/icon';
|
19
19
|
import { usePrefixCls } from '@teamix/utils';
|
20
20
|
import SchemaForm from '../SchemaForm';
|
21
|
-
import { mergeArrayValue
|
21
|
+
import { mergeArrayValue } from '../utils';
|
22
22
|
import useAutoSubmit from './useAutoSubmit';
|
23
23
|
import useInitialRequest from './useInitialRequest';
|
24
24
|
import './index.scss';
|
@@ -71,7 +71,7 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
71
71
|
form.addEffects('onChange', function () {
|
72
72
|
onFormValuesChange(function (form) {
|
73
73
|
if (onChange) {
|
74
|
-
onChange(toJS(form.values)
|
74
|
+
onChange(toJS(form.values));
|
75
75
|
}
|
76
76
|
});
|
77
77
|
});
|
@@ -0,0 +1,65 @@
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
+
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
4
|
+
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
6
|
+
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
8
|
+
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
10
|
+
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
12
|
+
|
13
|
+
import { useForm } from '@formily/react';
|
14
|
+
import { isArr, isPlainObj, getValueByValue } from '@teamix/utils';
|
15
|
+
/**
|
16
|
+
* 获取表单值的可显示值
|
17
|
+
* @returns 如果某字段有dataSource,则返回value对应label
|
18
|
+
*/
|
19
|
+
|
20
|
+
var useFormDisplayValues = function useFormDisplayValues() {
|
21
|
+
var form = useForm();
|
22
|
+
var values = form.values; // 判断值的类型,递归获取每个值在该结构中的完整路径
|
23
|
+
|
24
|
+
var getDisplayValues = function getDisplayValues(values) {
|
25
|
+
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
26
|
+
var displayValues;
|
27
|
+
|
28
|
+
if (isPlainObj(values)) {
|
29
|
+
displayValues = {};
|
30
|
+
Object.entries(values).forEach(function (_ref) {
|
31
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
32
|
+
key = _ref2[0],
|
33
|
+
value = _ref2[1];
|
34
|
+
|
35
|
+
var path = prefix ? "".concat(prefix, ".").concat(key) : "".concat(key);
|
36
|
+
displayValues[key] = getDisplayValues(value, path);
|
37
|
+
});
|
38
|
+
} else if (isArr(values)) {
|
39
|
+
displayValues = [];
|
40
|
+
values.map(function (value, index) {
|
41
|
+
var path = prefix ? "".concat(prefix, ".").concat(index) : "".concat(index);
|
42
|
+
displayValues[index] = getDisplayValues(value, path);
|
43
|
+
});
|
44
|
+
} else {
|
45
|
+
// 通过值的完整路径获取字段address(从form实例的indexes中),然后获取该字段的value在该字段dataSource中对应的label
|
46
|
+
var address = form.indexes[prefix];
|
47
|
+
var field = form.query(address).take();
|
48
|
+
displayValues = getValueByValue(field === null || field === void 0 ? void 0 : field.dataSource, values) || values;
|
49
|
+
}
|
50
|
+
|
51
|
+
return displayValues;
|
52
|
+
}; // 测试样例
|
53
|
+
// const example = {
|
54
|
+
// a: [
|
55
|
+
// [{ b: 'a.0.0.b', c: 'a.0.0.c' }, { d: 'a.0.1.d' }],
|
56
|
+
// { e: [{ f: { g: [{ h: 'a.1.e.0.f.g.0.h' }] } }, 'a.1.e.1'] },
|
57
|
+
// ],
|
58
|
+
// };
|
59
|
+
// console.log(getDisplayValues(example));
|
60
|
+
|
61
|
+
|
62
|
+
return getDisplayValues(values);
|
63
|
+
};
|
64
|
+
|
65
|
+
export default useFormDisplayValues;
|