@teamix/pro 1.1.29 → 1.1.33
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 +1329 -892
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/actions/dialog-form.js +3 -1
- package/es/actions/dialog.d.ts +0 -2
- package/es/actions/dialog.js +16 -23
- package/es/actions/index.js +13 -8
- package/es/actions/link.d.ts +2 -8
- package/es/actions/link.js +2 -22
- package/es/actions/request.d.ts +1 -1
- package/es/actions/request.js +6 -3
- package/es/form/Components/FormGroup/index.scss +1 -1
- package/es/form/Components/ProField/index.d.ts +4 -0
- package/es/form/Components/Query/index.scss +1 -6
- package/es/form/Components/Text/index.scss +4 -2
- package/es/form/ProForm/index.js +3 -16
- package/es/form/ProForm/index.scss +4 -11
- package/es/form/ProForm/useAutoSubmit.js +3 -1
- 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/index.js +5 -15
- package/es/form/SchemaForm/initializeProField.js +1 -0
- package/es/form/SchemaForm/initializeReactions.d.ts +2 -0
- package/es/form/SchemaForm/initializeReactions.js +89 -0
- package/es/form/SchemaForm/reactions.js +10 -2
- package/es/form/global.scss +12 -0
- 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/ProInfoItem/index.js +4 -2
- package/es/table/components/Filter/index.js +6 -2
- package/es/table/index.js +15 -3
- package/es/table/typing.d.ts +8 -4
- package/es/table/utils/columnRender.js +38 -11
- package/lib/actions/dialog-form.js +4 -1
- package/lib/actions/dialog.d.ts +0 -2
- package/lib/actions/dialog.js +15 -23
- package/lib/actions/index.js +12 -7
- package/lib/actions/link.d.ts +2 -8
- package/lib/actions/link.js +2 -25
- package/lib/actions/request.d.ts +1 -1
- package/lib/actions/request.js +7 -3
- package/lib/form/Components/FormGroup/index.scss +1 -1
- package/lib/form/Components/ProField/index.d.ts +4 -0
- package/lib/form/Components/Query/index.scss +1 -6
- package/lib/form/Components/Text/index.scss +4 -2
- package/lib/form/ProForm/index.js +2 -15
- package/lib/form/ProForm/index.scss +4 -11
- package/lib/form/ProForm/useAutoSubmit.js +4 -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/index.js +5 -14
- package/lib/form/SchemaForm/initializeProField.js +1 -0
- package/lib/form/SchemaForm/initializeReactions.d.ts +2 -0
- package/lib/form/SchemaForm/initializeReactions.js +101 -0
- package/lib/form/SchemaForm/reactions.js +10 -2
- package/lib/form/global.scss +12 -0
- 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/ProInfoItem/index.js +3 -1
- package/lib/table/components/Filter/index.js +6 -2
- package/lib/table/index.js +15 -3
- package/lib/table/typing.d.ts +8 -4
- package/lib/table/utils/columnRender.js +38 -11
- package/package.json +4 -4
@@ -23,6 +23,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
23
23
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
24
24
|
|
25
25
|
import React, { useState, useRef, useEffect } from 'react';
|
26
|
+
import { useHistory } from 'react-router-dom';
|
26
27
|
import { Loading } from '@alicloudfe/components';
|
27
28
|
import ProForm, { createForm } from '../form';
|
28
29
|
import { getTargetValue } from '@teamix/utils';
|
@@ -79,12 +80,13 @@ var DialogForm = function DialogForm(props) {
|
|
79
80
|
loading = _useState2[0],
|
80
81
|
setLoading = _useState2[1];
|
81
82
|
|
83
|
+
var history = useHistory();
|
82
84
|
useEffect(function () {
|
83
85
|
formRef.current = form;
|
84
86
|
|
85
87
|
if (initialRequest) {
|
86
88
|
setLoading(true);
|
87
|
-
doRequest(initialRequest, context).then(function (res) {
|
89
|
+
doRequest(initialRequest, context, history).then(function (res) {
|
88
90
|
form.setValues(res);
|
89
91
|
setLoading(false);
|
90
92
|
}).catch(function () {
|
package/es/actions/dialog.d.ts
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { QuickShowConfig } from '@alicloudfe/components/types/dialog';
|
3
3
|
import { quickShowDrawerProps } from '@alicloudfe/components/types/drawer';
|
4
|
-
import { LinkBase } from './link';
|
5
4
|
import { RequestAction } from './request';
|
6
5
|
export interface DialogAction extends Omit<RequestAction, 'url'>, Omit<QuickShowConfig, 'onError' | 'type'>, Omit<quickShowDrawerProps, 'trigger' | 'animation' | 'height' | 'locale' | 'onOk' | 'onCancel' | 'onError'> {
|
7
6
|
url?: string;
|
8
7
|
dialogType?: 'dialog' | 'drawer';
|
9
8
|
dialogQuickShowType?: 'alert' | 'confirm';
|
10
9
|
messageType?: 'success' | 'warning' | 'error' | 'notice' | 'help' | 'loading';
|
11
|
-
link?: LinkBase;
|
12
10
|
}
|
13
11
|
export declare function useDialogAction(action: DialogAction, context?: any): {
|
14
12
|
[x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
package/es/actions/dialog.js
CHANGED
@@ -30,9 +30,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
30
30
|
import React, { useState } from 'react';
|
31
31
|
import { useHistory } from 'react-router-dom';
|
32
32
|
import { Dialog, Drawer } from '@alicloudfe/components';
|
33
|
-
import { getTargetValue, uuid } from '@teamix/utils';
|
33
|
+
import { getTargetValue, uuid, goToLink } from '@teamix/utils';
|
34
34
|
import { eventHandler } from './base';
|
35
|
-
import { goToLink } from './link';
|
36
35
|
import { doRequest } from './request';
|
37
36
|
|
38
37
|
function addContextForReactNode(content, context) {
|
@@ -95,50 +94,44 @@ export function useDialogAction(action, context) {
|
|
95
94
|
while (1) {
|
96
95
|
switch (_context.prev = _context.next) {
|
97
96
|
case 0:
|
98
|
-
if (
|
97
|
+
if (url) {
|
99
98
|
_context.next = 5;
|
100
99
|
break;
|
101
100
|
}
|
102
101
|
|
103
|
-
|
104
|
-
|
105
|
-
resolve(true);
|
106
|
-
return _context.abrupt("return");
|
107
|
-
|
108
|
-
case 5:
|
109
|
-
if (url) {
|
110
|
-
_context.next = 9;
|
111
|
-
break;
|
102
|
+
if (link) {
|
103
|
+
goToLink(link, history);
|
112
104
|
}
|
113
105
|
|
114
106
|
onFinish && onFinish();
|
115
107
|
resolve(true);
|
116
108
|
return _context.abrupt("return");
|
117
109
|
|
118
|
-
case
|
110
|
+
case 5:
|
119
111
|
setLoading(true);
|
120
|
-
_context.prev =
|
121
|
-
_context.next =
|
122
|
-
return doRequest(action, context);
|
112
|
+
_context.prev = 6;
|
113
|
+
_context.next = 9;
|
114
|
+
return doRequest(action, context, history);
|
123
115
|
|
124
|
-
case
|
116
|
+
case 9:
|
125
117
|
onFinish && onFinish();
|
126
118
|
resolve(true);
|
127
|
-
_context.next =
|
119
|
+
_context.next = 18;
|
128
120
|
break;
|
129
121
|
|
130
|
-
case
|
131
|
-
_context.prev =
|
132
|
-
_context.t0 = _context["catch"](
|
122
|
+
case 13:
|
123
|
+
_context.prev = 13;
|
124
|
+
_context.t0 = _context["catch"](6);
|
133
125
|
setLoading(false);
|
134
126
|
resolve(false);
|
127
|
+
return _context.abrupt("return");
|
135
128
|
|
136
|
-
case
|
129
|
+
case 18:
|
137
130
|
case "end":
|
138
131
|
return _context.stop();
|
139
132
|
}
|
140
133
|
}
|
141
|
-
}, _callee, null, [[
|
134
|
+
}, _callee, null, [[6, 13]]);
|
142
135
|
}));
|
143
136
|
|
144
137
|
return function (_x) {
|
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';
|
@@ -121,16 +121,18 @@ export var useAction = function useAction(config, context) {
|
|
121
121
|
}, registedAction.defaultConfig), others), context);
|
122
122
|
};
|
123
123
|
|
124
|
-
var buttonContent = function buttonContent(content, iconType, iconSize) {
|
124
|
+
var buttonContent = function buttonContent(content, iconType, iconSize, context) {
|
125
|
+
var renderedContent = typeof content === 'function' ? content(context) : content;
|
126
|
+
|
125
127
|
if (!iconType) {
|
126
|
-
return
|
128
|
+
return renderedContent;
|
127
129
|
}
|
128
130
|
|
129
131
|
return [/*#__PURE__*/React.createElement(Icon, {
|
130
132
|
type: iconType,
|
131
133
|
size: iconSize,
|
132
134
|
key: "teamix-button-icon"
|
133
|
-
}),
|
135
|
+
}), renderedContent];
|
134
136
|
};
|
135
137
|
|
136
138
|
export var ActionButton = function ActionButton(props) {
|
@@ -154,7 +156,7 @@ export var ActionButton = function ActionButton(props) {
|
|
154
156
|
}) : _objectSpread(_objectSpread({}, actionProps), others);
|
155
157
|
return /*#__PURE__*/React.createElement(Button, _objectSpread({
|
156
158
|
type: type
|
157
|
-
}, buttonProps), buttonContent(children, icon, iconSize));
|
159
|
+
}, buttonProps), buttonContent(children, icon, iconSize, context));
|
158
160
|
};
|
159
161
|
|
160
162
|
function renderMenuButtonItem(item, key, context) {
|
@@ -173,7 +175,7 @@ function renderMenuButtonItem(item, key, context) {
|
|
173
175
|
}) : _objectSpread({}, menuItemProps);
|
174
176
|
return /*#__PURE__*/React.createElement(MenuButton.Item, _objectSpread({
|
175
177
|
key: key
|
176
|
-
}, buttonProps), buttonContent(item.children, item.icon));
|
178
|
+
}, buttonProps), buttonContent(item.children, item.icon, undefined, context));
|
177
179
|
}
|
178
180
|
|
179
181
|
function renderCommonActionButtonMenuItem(action, key, context) {
|
@@ -209,8 +211,11 @@ export var ActionMenuButton = function ActionMenuButton(props) {
|
|
209
211
|
mode: 'popup',
|
210
212
|
triggerType: 'hover'
|
211
213
|
},
|
214
|
+
popupProps: {
|
215
|
+
shouldUpdatePosition: true
|
216
|
+
},
|
212
217
|
type: type,
|
213
|
-
label: buttonContent(label || children, icon, iconSize)
|
218
|
+
label: buttonContent(label || children, icon, iconSize, context)
|
214
219
|
}, others), actions.map(function (action, i) {
|
215
220
|
return renderCommonActionButtonMenuItem(action, i, context);
|
216
221
|
}));
|
@@ -255,7 +260,7 @@ function renderCommonActionButton(button, context, isTypeText) {
|
|
255
260
|
function getDefaultMoreButton(type, moreText) {
|
256
261
|
if (type === 'button') {
|
257
262
|
return {
|
258
|
-
label: moreText || '
|
263
|
+
label: moreText || getMessage('more')
|
259
264
|
};
|
260
265
|
}
|
261
266
|
|
package/es/actions/link.d.ts
CHANGED
@@ -1,13 +1,7 @@
|
|
1
|
+
import { LocationHistory } from '@teamix/utils';
|
1
2
|
import { BaseAction } from './base';
|
2
|
-
export interface
|
3
|
-
to: string;
|
4
|
-
search?: string;
|
5
|
-
hash?: string;
|
6
|
-
blank?: boolean;
|
3
|
+
export interface LinkAction extends BaseAction, LocationHistory {
|
7
4
|
}
|
8
|
-
export interface LinkAction extends BaseAction, LinkBase {
|
9
|
-
}
|
10
|
-
export declare function goToLink(link: LinkBase, history: any): void;
|
11
5
|
export declare function useLinkAction(action: LinkAction, context?: any): {
|
12
6
|
[x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void;
|
13
7
|
};
|
package/es/actions/link.js
CHANGED
@@ -4,29 +4,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
4
4
|
|
5
5
|
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; }
|
6
6
|
|
7
|
-
import {
|
8
|
-
import { getTargetValue } from '@teamix/utils';
|
7
|
+
import { getTargetValue, goToLink } from '@teamix/utils';
|
9
8
|
import { eventHandler } from './base';
|
10
|
-
export function goToLink(link, history) {
|
11
|
-
var to = link.to,
|
12
|
-
search = link.search,
|
13
|
-
hash = link.hash,
|
14
|
-
blank = link.blank;
|
15
|
-
|
16
|
-
if (blank) {
|
17
|
-
window.open("".concat(to).concat(search ? "?".concat(search) : '').concat(hash ? "#".concat(hash) : ''));
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
|
21
|
-
history.push({
|
22
|
-
pathname: to,
|
23
|
-
search: search,
|
24
|
-
hash: hash
|
25
|
-
});
|
26
|
-
}
|
27
9
|
export function useLinkAction(action, context) {
|
28
|
-
var history = useHistory();
|
29
|
-
|
30
10
|
var _getTargetValue = getTargetValue(action, context),
|
31
11
|
to = _getTargetValue.to,
|
32
12
|
search = _getTargetValue.search,
|
@@ -39,7 +19,7 @@ export function useLinkAction(action, context) {
|
|
39
19
|
search: search,
|
40
20
|
hash: hash,
|
41
21
|
blank: blank
|
42
|
-
}
|
22
|
+
});
|
43
23
|
}));
|
44
24
|
}
|
45
25
|
export default useLinkAction;
|
package/es/actions/request.d.ts
CHANGED
@@ -2,7 +2,7 @@ import { CommonRequestConfig } from '@teamix/utils';
|
|
2
2
|
import { BaseAction } from './base';
|
3
3
|
export interface RequestAction extends CommonRequestConfig, BaseAction {
|
4
4
|
}
|
5
|
-
export declare function doRequest(action: RequestAction, context?: any): Promise<unknown>;
|
5
|
+
export declare function doRequest(action: RequestAction, context?: any, history?: any): Promise<unknown>;
|
6
6
|
export declare function useRequestAction(action: RequestAction, context?: any): {
|
7
7
|
loading: boolean;
|
8
8
|
};
|
package/es/actions/request.js
CHANGED
@@ -24,17 +24,18 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
24
24
|
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; }
|
25
25
|
|
26
26
|
import { useState } from 'react';
|
27
|
+
import { useHistory } from 'react-router-dom';
|
27
28
|
import { doCommonRequest } from '@teamix/utils';
|
28
29
|
import { eventHandler } from './base'; // action 里的数据请求都默认是 post 类型
|
29
30
|
|
30
|
-
export function doRequest(action, context) {
|
31
|
+
export function doRequest(action, context, history) {
|
31
32
|
var _action$method = action.method,
|
32
33
|
method = _action$method === void 0 ? 'post' : _action$method,
|
33
34
|
others = _objectWithoutProperties(action, _excluded);
|
34
35
|
|
35
36
|
return doCommonRequest(_objectSpread({
|
36
37
|
method: method
|
37
|
-
}, others), context);
|
38
|
+
}, others), context, history);
|
38
39
|
}
|
39
40
|
export function useRequestAction(action, context) {
|
40
41
|
var _useState = useState(false),
|
@@ -42,12 +43,14 @@ export function useRequestAction(action, context) {
|
|
42
43
|
loading = _useState2[0],
|
43
44
|
setLoading = _useState2[1];
|
44
45
|
|
46
|
+
var history = useHistory();
|
47
|
+
|
45
48
|
var onFinish = action.onFinish,
|
46
49
|
others = _objectWithoutProperties(action, _excluded2);
|
47
50
|
|
48
51
|
return _objectSpread(_objectSpread({}, eventHandler(action, function () {
|
49
52
|
setLoading(true);
|
50
|
-
doRequest(_objectSpread({}, others), context).then(function () {
|
53
|
+
doRequest(_objectSpread({}, others), context, history).then(function () {
|
51
54
|
setLoading(false);
|
52
55
|
onFinish && onFinish();
|
53
56
|
}).catch(function () {
|
@@ -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
|
} & {
|
@@ -1,9 +1,4 @@
|
|
1
|
-
@import '
|
2
|
-
|
3
|
-
$form-item-cls: #{$css-prefix}formily-item;
|
4
|
-
$noborder-font-weight-medium: calc(
|
5
|
-
var(--form-element-medium-height, 32px) - var(--input-border-width, 1px) * 2
|
6
|
-
);
|
1
|
+
@import '../../global.scss';
|
7
2
|
|
8
3
|
// Query样式
|
9
4
|
.#{$css-prefix}filter {
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
@import '../../global.scss';
|
2
2
|
|
3
|
-
|
3
|
+
$teamix-pro-form-text: #{$teamix-pro-form}-text;
|
4
|
+
|
5
|
+
.#{$teamix-pro-form-text} {
|
4
6
|
line-height: var(--form-element-medium-height, 32px);
|
5
7
|
color: var(--color-fill1-6, #848484);
|
6
8
|
}
|
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
|
});
|
@@ -85,20 +85,7 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
85
85
|
form.setInitialValues(values);
|
86
86
|
});
|
87
87
|
}
|
88
|
-
}, []);
|
89
|
-
// <Form
|
90
|
-
// className={cls(prefixCls, className)}
|
91
|
-
// {...otherProps}
|
92
|
-
// {...getTeamixLayout}
|
93
|
-
// form={form}
|
94
|
-
// onAutoSubmit={onAutoSubmit}
|
95
|
-
// onAutoSubmitFailed={onSubmitFailed}
|
96
|
-
// >
|
97
|
-
// <SchemaForm schema={schema} scope={scope} components={components} />
|
98
|
-
// {children}
|
99
|
-
// </Form>
|
100
|
-
// );
|
101
|
-
|
88
|
+
}, []);
|
102
89
|
return outerForm === false ?
|
103
90
|
/*#__PURE__*/
|
104
91
|
// 特殊表单,无需渲染form实例,例如FormDialog等
|
@@ -1,14 +1,11 @@
|
|
1
|
-
@import '
|
2
|
-
|
3
|
-
$form-item-cls: #{$css-prefix}formily-item;
|
4
|
-
$teamix-pro-form: teamix-pro-form;
|
1
|
+
@import '../global.scss';
|
5
2
|
|
6
3
|
// FormItem 样式重写
|
7
4
|
.#{$form-item-cls} {
|
8
5
|
// 标签加粗 主题颜色
|
9
6
|
.#{$form-item-cls}-label label {
|
10
7
|
color: var(--form-label-color, #333333);
|
11
|
-
font-weight:
|
8
|
+
font-weight: var(--font-weight-medium, 500);
|
12
9
|
}
|
13
10
|
|
14
11
|
// 溢出label样式
|
@@ -126,10 +123,6 @@ $teamix-pro-form: teamix-pro-form;
|
|
126
123
|
}
|
127
124
|
}
|
128
125
|
|
129
|
-
// 内嵌模式
|
130
|
-
$inset-font-weight-medium: calc(
|
131
|
-
var(--form-element-medium-height, 32px) - var(--input-border-width, 1px) * 2
|
132
|
-
);
|
133
126
|
// 内嵌模式 - 行高
|
134
127
|
.#{$form-item-cls}-inset {
|
135
128
|
line-height: $inset-font-weight-medium;
|
@@ -155,7 +148,7 @@ $inset-font-weight-medium: calc(
|
|
155
148
|
.#{$form-item-cls}-label-content {
|
156
149
|
label {
|
157
150
|
color: var(--color-text1-8, #848484);
|
158
|
-
font-weight:
|
151
|
+
font-weight: normal;
|
159
152
|
}
|
160
153
|
}
|
161
154
|
.#{$form-item-cls}-colon {
|
@@ -193,7 +186,7 @@ $inset-font-weight-medium: calc(
|
|
193
186
|
|
194
187
|
// Editable预览态行高
|
195
188
|
.#{$css-prefix}formily-editable-content {
|
196
|
-
line-height:
|
189
|
+
line-height: var(--form-element-medium-height, 32px);
|
197
190
|
}
|
198
191
|
|
199
192
|
// 折叠面板
|
@@ -4,10 +4,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
4
4
|
|
5
5
|
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; }
|
6
6
|
|
7
|
+
import { useHistory } from 'react-router-dom';
|
7
8
|
import { doCommonRequest, isObj } from '@teamix/utils';
|
8
9
|
|
9
10
|
var useAutoSubmit = function useAutoSubmit(onSubmit) {
|
10
11
|
if (isObj(onSubmit)) {
|
12
|
+
var history = useHistory();
|
11
13
|
var submitConfig = onSubmit;
|
12
14
|
return function (values) {
|
13
15
|
return doCommonRequest(_objectSpread(_objectSpread({
|
@@ -16,7 +18,7 @@ var useAutoSubmit = function useAutoSubmit(onSubmit) {
|
|
16
18
|
params: _objectSpread(_objectSpread({}, values), submitConfig.params || {})
|
17
19
|
}), {
|
18
20
|
fields: values
|
19
|
-
});
|
21
|
+
}, history);
|
20
22
|
};
|
21
23
|
}
|
22
24
|
|
@@ -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;
|
@@ -44,6 +44,7 @@ import adapterType from './adapterType';
|
|
44
44
|
import adapterComponent from './adapterComponent';
|
45
45
|
import adapterDecorator from './adapterDecorator';
|
46
46
|
import initializeRequest from './initializeRequest';
|
47
|
+
import initializeReactions from './initializeReactions';
|
47
48
|
import initializeDataSource from './initializeDataSource';
|
48
49
|
import initializeRules from './initializeRules';
|
49
50
|
import initializeProField, { proFieldTypeMap } from './initializeProField';
|
@@ -57,7 +58,7 @@ import initializeFormStep from './initializeFormStep';
|
|
57
58
|
import initializeFormTab from './initializeFormTab';
|
58
59
|
import initializeFormCollapse from './initializeFormCollapse';
|
59
60
|
import initializeArrayIcon from './initializeArrayIcon';
|
60
|
-
import { getRandomName,
|
61
|
+
import { getRandomName, mapSchemaName } from '../utils';
|
61
62
|
import warning from '../warning';
|
62
63
|
export default /*#__PURE__*/memo(function (_ref) {
|
63
64
|
var schema = _ref.schema,
|
@@ -211,21 +212,10 @@ export default /*#__PURE__*/memo(function (_ref) {
|
|
211
212
|
|
212
213
|
var _initializeRules = initializeRules(rules),
|
213
214
|
defaultRules = _initializeRules.rules,
|
214
|
-
rulesScope = _initializeRules.scope; // 合并reactions
|
215
|
+
rulesScope = _initializeRules.scope; // 合并reactions,初始化reactions
|
215
216
|
|
216
217
|
|
217
|
-
var
|
218
|
-
var innerReactions = [].concat(_toConsumableArray(requestReactions), _toConsumableArray(dataSourceReactions));
|
219
|
-
|
220
|
-
if (reactions && innerReactions.length) {
|
221
|
-
return mergeArrayValue(innerReactions, reactions);
|
222
|
-
} else if (innerReactions.length) {
|
223
|
-
return innerReactions;
|
224
|
-
}
|
225
|
-
|
226
|
-
return reactions;
|
227
|
-
}(); // 合并scope
|
228
|
-
|
218
|
+
var defaultReactions = initializeReactions(reactions, [].concat(_toConsumableArray(requestReactions), _toConsumableArray(dataSourceReactions))); // 合并scope
|
229
219
|
|
230
220
|
Object.entries(_objectSpread(_objectSpread(_objectSpread({}, requestScope), dataSourceScope), rulesScope)).map(function (_ref2) {
|
231
221
|
var _ref3 = _slicedToArray(_ref2, 2),
|
@@ -240,7 +230,7 @@ export default /*#__PURE__*/memo(function (_ref) {
|
|
240
230
|
decorator: defaultDecorator,
|
241
231
|
decoratorProps: defaultDecoratorProps,
|
242
232
|
rules: defaultRules,
|
243
|
-
reactions:
|
233
|
+
reactions: defaultReactions,
|
244
234
|
dataSource: defaultDataSource
|
245
235
|
})); // 递归子组件
|
246
236
|
|