@teamix/pro 1.3.8 → 1.3.11
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.js +370 -131
- package/dist/pro.min.js +1 -1
- package/es/actions/dialog-form.js +1 -1
- package/es/actions/dialog.d.ts +1 -1
- package/es/actions/dialog.js +14 -4
- package/es/form/Components/LightFilter/index.js +8 -6
- package/es/form/ProForm/index.js +15 -7
- package/es/form/SchemaForm/index.js +18 -26
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/sidebar/components/tree/index.js +12 -12
- package/es/sidebar/index.js +5 -4
- package/es/sidebar/utils/index.d.ts +12 -0
- package/es/sidebar/utils/index.js +58 -0
- package/lib/actions/dialog-form.js +1 -1
- package/lib/actions/dialog.d.ts +1 -1
- package/lib/actions/dialog.js +14 -4
- package/lib/form/Components/LightFilter/index.js +5 -3
- package/lib/form/ProForm/index.js +14 -6
- package/lib/form/SchemaForm/index.js +17 -26
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/sidebar/components/tree/index.js +14 -15
- package/lib/sidebar/index.js +6 -4
- package/lib/sidebar/utils/index.d.ts +12 -0
- package/lib/sidebar/utils/index.js +60 -0
- package/package.json +1 -1
|
@@ -232,6 +232,6 @@ export function useDialogFormAction(action, context) {
|
|
|
232
232
|
|
|
233
233
|
_onFinish && _onFinish((_innerFormRef$current2 = innerFormRef.current) === null || _innerFormRef$current2 === void 0 ? void 0 : _innerFormRef$current2.values);
|
|
234
234
|
}
|
|
235
|
-
}, others), context);
|
|
235
|
+
}, others), context, true);
|
|
236
236
|
}
|
|
237
237
|
export default useDialogFormAction;
|
package/es/actions/dialog.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface DialogAction extends Omit<RequestAction, 'url'>, Omit<QuickShow
|
|
|
26
26
|
/** 弹窗内容区的组件 */
|
|
27
27
|
component?: any;
|
|
28
28
|
}
|
|
29
|
-
export declare function useDialogAction(action: DialogAction, actionContext?: any): {
|
|
29
|
+
export declare function useDialogAction(action: DialogAction, actionContext?: any, hasForm?: boolean): {
|
|
30
30
|
[x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
|
31
31
|
};
|
|
32
32
|
export default useDialogAction;
|
package/es/actions/dialog.js
CHANGED
|
@@ -69,7 +69,7 @@ function getFooterAlignClass(isDrawer, align) {
|
|
|
69
69
|
} // 弹窗 -> 请求(点击确认,发送数据请求)
|
|
70
70
|
|
|
71
71
|
|
|
72
|
-
export function useDialogAction(action, actionContext) {
|
|
72
|
+
export function useDialogAction(action, actionContext, hasForm) {
|
|
73
73
|
var _useState = useState(false),
|
|
74
74
|
_useState2 = _slicedToArray(_useState, 2),
|
|
75
75
|
loading = _useState2[0],
|
|
@@ -174,17 +174,27 @@ export function useDialogAction(action, actionContext) {
|
|
|
174
174
|
case 6:
|
|
175
175
|
onFinish && onFinish();
|
|
176
176
|
resolve(true);
|
|
177
|
-
_context.next =
|
|
177
|
+
_context.next = 18;
|
|
178
178
|
break;
|
|
179
179
|
|
|
180
180
|
case 10:
|
|
181
181
|
_context.prev = 10;
|
|
182
182
|
_context.t0 = _context["catch"](2);
|
|
183
|
-
setLoading(false);
|
|
183
|
+
setLoading(false); // 如果 beforeRequest 中返回了 false 并且不是 dialog-form,则直接关闭弹窗
|
|
184
|
+
|
|
185
|
+
if (!(beforeRequest && !hasForm)) {
|
|
186
|
+
_context.next = 16;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
resolve(true);
|
|
191
|
+
return _context.abrupt("return");
|
|
192
|
+
|
|
193
|
+
case 16:
|
|
184
194
|
resolve(false);
|
|
185
195
|
return _context.abrupt("return");
|
|
186
196
|
|
|
187
|
-
case
|
|
197
|
+
case 18:
|
|
188
198
|
case "end":
|
|
189
199
|
return _context.stop();
|
|
190
200
|
}
|
|
@@ -16,12 +16,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
16
16
|
|
|
17
17
|
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; }
|
|
18
18
|
|
|
19
|
-
import React, { useState, useCallback } from 'react';
|
|
20
|
-
import { observer, useFieldSchema, RecursionField } from '@formily/react';
|
|
19
|
+
import React, { useState, useCallback, useContext } from 'react';
|
|
20
|
+
import { observer, useFieldSchema, RecursionField, SchemaExpressionScopeContext } from '@formily/react';
|
|
21
21
|
import { Select, Button } from '@alicloudfe/components';
|
|
22
22
|
import TeamixIcon from '@teamix/icon';
|
|
23
23
|
import cls from 'classnames';
|
|
24
|
-
import { usePrefixCls } from '@teamix/utils';
|
|
24
|
+
import { usePrefixCls, getTargetValue } from '@teamix/utils';
|
|
25
25
|
import { componentMap, inputCategory } from './componentMap';
|
|
26
26
|
import './index.scss';
|
|
27
27
|
|
|
@@ -56,13 +56,14 @@ var useMain = function useMain(active) {
|
|
|
56
56
|
}; // 筛选项数据
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
var useFilterItems = function useFilterItems(filterValues) {
|
|
59
|
+
var useFilterItems = function useFilterItems(filterValues, scope) {
|
|
60
60
|
var schema = useFieldSchema();
|
|
61
61
|
var filterItems = [];
|
|
62
62
|
schema.mapProperties(function (schema, name) {
|
|
63
63
|
if (!filterValues || filterValues && filterValues.includes(schema.name)) {
|
|
64
|
+
var label = /{{.*}}/.test(schema.title) ? getTargetValue(schema.title, scope) : schema.title;
|
|
64
65
|
filterItems.push({
|
|
65
|
-
label:
|
|
66
|
+
label: label,
|
|
66
67
|
value: schema.name
|
|
67
68
|
});
|
|
68
69
|
}
|
|
@@ -85,7 +86,8 @@ var LightFilter = observer(function (props) {
|
|
|
85
86
|
onFilterChange = props.onFilterChange,
|
|
86
87
|
filterProps = props.filterProps,
|
|
87
88
|
buttonProps = props.buttonProps;
|
|
88
|
-
var
|
|
89
|
+
var scope = useContext(SchemaExpressionScopeContext);
|
|
90
|
+
var filterItems = useFilterItems(filterValues, scope);
|
|
89
91
|
|
|
90
92
|
var _useState = useState(defaultFilterValue || ((_filterItems$ = filterItems[0]) === null || _filterItems$ === void 0 ? void 0 : _filterItems$.value)),
|
|
91
93
|
_useState2 = _slicedToArray(_useState, 2),
|
package/es/form/ProForm/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import cls from 'classnames';
|
|
|
15
15
|
import { createForm, onFieldValueChange, registerValidateLocale, setValidateLanguage } from '@formily/core';
|
|
16
16
|
import { toJS } from '@formily/reactive';
|
|
17
17
|
import { Form } from '@teamix/formily';
|
|
18
|
-
import { usePrefixCls, getLanguage } from '@teamix/utils';
|
|
18
|
+
import { usePrefixCls, getLanguage, getGlobalConfig } from '@teamix/utils';
|
|
19
19
|
import SchemaForm from '../SchemaForm';
|
|
20
20
|
import { mergeArrayValue } from '../utils';
|
|
21
21
|
import useAutoSubmit from './useAutoSubmit';
|
|
@@ -46,6 +46,11 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
|
46
46
|
validateFirst = _ref.validateFirst,
|
|
47
47
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
48
48
|
|
|
49
|
+
// 获取全局配置
|
|
50
|
+
var _ref2 = getGlobalConfig('ProForm') || {},
|
|
51
|
+
globalComponents = _ref2.components,
|
|
52
|
+
globalScope = _ref2.scope;
|
|
53
|
+
|
|
49
54
|
var form = useMemo(function () {
|
|
50
55
|
return outerForm || createForm({
|
|
51
56
|
validateFirst: validateFirst
|
|
@@ -54,11 +59,14 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
|
54
59
|
var prefixCls = usePrefixCls('', {
|
|
55
60
|
prefix: 'teamix-pro-form'
|
|
56
61
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
|
|
63
|
+
var mergedScope = _objectSpread(_objectSpread(_objectSpread({}, globalScope), scope), {}, {
|
|
64
|
+
context: context
|
|
65
|
+
}); // context需要实名不能解构
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
var mergedComponents = _objectSpread(_objectSpread({}, globalComponents), components);
|
|
69
|
+
|
|
62
70
|
var onAutoSubmit = useAutoSubmit(onSubmit); // todo 需要formily支持断点下的属性更新
|
|
63
71
|
|
|
64
72
|
var getTeamixLayout = useMemo(function () {
|
|
@@ -115,7 +123,7 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
|
115
123
|
}), /*#__PURE__*/React.createElement(SchemaForm, {
|
|
116
124
|
schema: schema,
|
|
117
125
|
scope: mergedScope,
|
|
118
|
-
components:
|
|
126
|
+
components: mergedComponents
|
|
119
127
|
}), children);
|
|
120
128
|
});
|
|
121
129
|
ProForm.defaultProps = {
|
|
@@ -30,7 +30,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
30
30
|
|
|
31
31
|
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; }
|
|
32
32
|
|
|
33
|
-
import React, { memo, useCallback, useMemo } from 'react';
|
|
33
|
+
import React, { memo, useCallback, useRef, useMemo } from 'react';
|
|
34
34
|
import { createSchemaField } from '@formily/react';
|
|
35
35
|
import { Affix } from '@alicloudfe/components';
|
|
36
36
|
import { Upload, SelectTable, FormLayout, FormItem, ArrayCollapse, ArrayCards, ArrayItems, ArrayTable, Space, FormGrid, FormTab, FormCollapse, FormStep, Editable, FormDialog, FormDrawer, FormButtonGroup, Submit, Reset } from '@teamix/formily';
|
|
@@ -59,22 +59,16 @@ import initializeSelectTable from './initializeSelectTable';
|
|
|
59
59
|
import { $request, $common, $dataSource, $validator } from './reactions';
|
|
60
60
|
import fieldTypeMap from '../fieldTypeMap';
|
|
61
61
|
import { getFieldName, mapSchemaName } from '../utils';
|
|
62
|
-
import { getGlobalConfig } from '@teamix/utils';
|
|
63
62
|
import warning from '../warning';
|
|
64
63
|
export default /*#__PURE__*/memo(function (_ref) {
|
|
65
64
|
var schema = _ref.schema,
|
|
66
65
|
scope = _ref.scope,
|
|
67
66
|
components = _ref.components;
|
|
68
|
-
|
|
69
|
-
// 获取全局配置
|
|
70
|
-
var _ref2 = getGlobalConfig('ProForm') || {},
|
|
71
|
-
globalComponents = _ref2.components,
|
|
72
|
-
globalScope = _ref2.scope; // 创建 SchemaField
|
|
73
|
-
|
|
67
|
+
var schemaScopeRef = useRef({}); // 创建 SchemaField,添加内置组件
|
|
74
68
|
|
|
75
69
|
var SchemaField = useMemo(function () {
|
|
76
70
|
return createSchemaField({
|
|
77
|
-
components: _objectSpread(_objectSpread(
|
|
71
|
+
components: _objectSpread(_objectSpread({}, ProFieldComponents), {}, {
|
|
78
72
|
FormLayout: FormLayout,
|
|
79
73
|
FormItem: FormItem,
|
|
80
74
|
ArrayCollapse: ArrayCollapse,
|
|
@@ -103,16 +97,7 @@ export default /*#__PURE__*/memo(function (_ref) {
|
|
|
103
97
|
Text: Text
|
|
104
98
|
})
|
|
105
99
|
});
|
|
106
|
-
}, []); //
|
|
107
|
-
|
|
108
|
-
var mergedScope = useMemo(function () {
|
|
109
|
-
return _objectSpread(_objectSpread(_objectSpread({}, globalScope), scope), {}, {
|
|
110
|
-
$request: $request,
|
|
111
|
-
$common: $common,
|
|
112
|
-
$dataSource: $dataSource,
|
|
113
|
-
$validator: $validator
|
|
114
|
-
});
|
|
115
|
-
}, [scope]); // 格式化 schema
|
|
100
|
+
}, []); // 格式化 schema
|
|
116
101
|
|
|
117
102
|
var formatSchema = useCallback(function (schema) {
|
|
118
103
|
var parentSuffix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
@@ -231,12 +216,12 @@ export default /*#__PURE__*/memo(function (_ref) {
|
|
|
231
216
|
|
|
232
217
|
var defaultReactions = initializeReactions(reactions, [].concat(_toConsumableArray(requestReactions), _toConsumableArray(dataSourceReactions))); // 合并scope
|
|
233
218
|
|
|
234
|
-
Object.entries(_objectSpread(_objectSpread(_objectSpread({}, requestScope), dataSourceScope), rulesScope)).map(function (
|
|
235
|
-
var
|
|
236
|
-
k =
|
|
237
|
-
v =
|
|
219
|
+
Object.entries(_objectSpread(_objectSpread(_objectSpread({}, requestScope), dataSourceScope), rulesScope)).map(function (_ref2) {
|
|
220
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
221
|
+
k = _ref3[0],
|
|
222
|
+
v = _ref3[1];
|
|
238
223
|
|
|
239
|
-
|
|
224
|
+
schemaScopeRef.current[k] = v;
|
|
240
225
|
});
|
|
241
226
|
var formatParam = mapSchemaName(_objectSpread(_objectSpread({}, otherProps), {}, {
|
|
242
227
|
type: defaultType,
|
|
@@ -261,13 +246,20 @@ export default /*#__PURE__*/memo(function (_ref) {
|
|
|
261
246
|
schemaProperties[name] = _objectSpread(_objectSpread(_objectSpread({}, formatParam), recursiveProperties), recursiveItems);
|
|
262
247
|
});
|
|
263
248
|
return schemaProperties;
|
|
264
|
-
}, [
|
|
249
|
+
}, []);
|
|
265
250
|
var formilySchema = useMemo(function () {
|
|
266
251
|
return {
|
|
267
252
|
type: 'object',
|
|
268
253
|
properties: formatSchema(schema)
|
|
269
254
|
};
|
|
270
|
-
}, [schema]);
|
|
255
|
+
}, [schema]);
|
|
256
|
+
|
|
257
|
+
var mergedScope = _objectSpread(_objectSpread({}, scope), {}, {
|
|
258
|
+
$request: $request,
|
|
259
|
+
$common: $common,
|
|
260
|
+
$dataSource: $dataSource,
|
|
261
|
+
$validator: $validator
|
|
262
|
+
}, schemaScopeRef.current);
|
|
271
263
|
|
|
272
264
|
return /*#__PURE__*/React.createElement(SchemaField, {
|
|
273
265
|
schema: formilySchema,
|
package/es/index.d.ts
CHANGED
|
@@ -26,5 +26,5 @@ export * from './table';
|
|
|
26
26
|
export * from './sidebar';
|
|
27
27
|
export * from './utils';
|
|
28
28
|
export * from './timeline';
|
|
29
|
-
declare const version = "1.3.
|
|
29
|
+
declare const version = "1.3.11";
|
|
30
30
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, hooks, nocode, templates, utils, };
|
package/es/index.js
CHANGED
|
@@ -31,6 +31,6 @@ export * from './sidebar';
|
|
|
31
31
|
export * from './utils'; // export * from './sidebar';
|
|
32
32
|
|
|
33
33
|
export * from './timeline';
|
|
34
|
-
var version = '1.3.
|
|
34
|
+
var version = '1.3.11';
|
|
35
35
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, // ProLayout,
|
|
36
36
|
ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, hooks, nocode, templates, utils };
|
|
@@ -36,10 +36,9 @@ import { Tree } from '@alicloudfe/components';
|
|
|
36
36
|
import { baseClass } from '@teamix/utils';
|
|
37
37
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
38
38
|
import { renderTreeNode, renderTreeNodeDependenceValue } from '../tree-node';
|
|
39
|
-
import debounce from 'lodash.debounce';
|
|
40
39
|
import './index.scss';
|
|
41
40
|
import '../tree-node/index.scss';
|
|
42
|
-
import {
|
|
41
|
+
import { filterTreeData, getAllNodeKey, getTreeLevelKey, loop } from '../../utils';
|
|
43
42
|
import { useUpdateEffect } from '@teamix/hooks';
|
|
44
43
|
import { useActionType } from '../../utils/action-ref';
|
|
45
44
|
import cloneDeep from 'lodash.clonedeep';
|
|
@@ -215,7 +214,7 @@ var ProSidebarTree = function ProSidebarTree(props) {
|
|
|
215
214
|
}; // 过滤
|
|
216
215
|
|
|
217
216
|
|
|
218
|
-
var filterDataSource =
|
|
217
|
+
var filterDataSource = function filterDataSource(value) {
|
|
219
218
|
var searchDataSource = processDataSource(dataSourceProp !== null && dataSourceProp !== void 0 ? dataSourceProp : []);
|
|
220
219
|
var expandedKeys = [];
|
|
221
220
|
|
|
@@ -227,21 +226,22 @@ var ProSidebarTree = function ProSidebarTree(props) {
|
|
|
227
226
|
return;
|
|
228
227
|
}
|
|
229
228
|
|
|
230
|
-
|
|
229
|
+
var _filterTreeData = filterTreeData(searchDataSource, function (node) {
|
|
230
|
+
var _node$label;
|
|
231
|
+
|
|
232
|
+
return ((_node$label = node === null || node === void 0 ? void 0 : node.label) !== null && _node$label !== void 0 ? _node$label : '').includes(value);
|
|
233
|
+
}),
|
|
234
|
+
filterTreeValue = _filterTreeData.filterTreeValue;
|
|
235
|
+
|
|
236
|
+
loop(filterTreeValue, function (item) {
|
|
231
237
|
hasSearchValue(value, item) && expandedKeys.push(String(item['value']));
|
|
232
238
|
}, {
|
|
233
239
|
children: 'children'
|
|
234
240
|
});
|
|
235
|
-
setExpandedKeys([].concat(expandedKeys));
|
|
236
241
|
setMatchedKeys(matchedKeys);
|
|
237
242
|
handleExpand(expandedKeys);
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
return ((_node$label = node === null || node === void 0 ? void 0 : node.label) !== null && _node$label !== void 0 ? _node$label : '').includes(value);
|
|
242
|
-
});
|
|
243
|
-
setDataSource(filterDataSource);
|
|
244
|
-
}, 100);
|
|
243
|
+
setDataSource(filterTreeValue);
|
|
244
|
+
};
|
|
245
245
|
|
|
246
246
|
var filterTreeNode = function filterTreeNode(node) {
|
|
247
247
|
return matchedKeys && matchedKeys.indexOf(node.props.eventKey) > -1;
|
package/es/sidebar/index.js
CHANGED
|
@@ -29,6 +29,7 @@ import ProSidebarContainer from './components/sidebar-container';
|
|
|
29
29
|
import ProSidebarTree from './components/tree';
|
|
30
30
|
import { getTreeLevel, ProSkeletonRaw } from '..';
|
|
31
31
|
import { useActionType } from './utils/action-ref';
|
|
32
|
+
import debounce from 'lodash.debounce';
|
|
32
33
|
export * from './typing';
|
|
33
34
|
export * from './utils';
|
|
34
35
|
var cls = baseClass('teamix-pro-sidebar');
|
|
@@ -40,7 +41,7 @@ var ProSidebar = function ProSidebar(props) {
|
|
|
40
41
|
_props$className = props.className,
|
|
41
42
|
className = _props$className === void 0 ? '' : _props$className,
|
|
42
43
|
style = props.style,
|
|
43
|
-
|
|
44
|
+
searchOnChange = props.searchOnChange,
|
|
44
45
|
_props$showSearch = props.showSearch,
|
|
45
46
|
showSearch = _props$showSearch === void 0 ? true : _props$showSearch,
|
|
46
47
|
onSelect = props.onSelect,
|
|
@@ -174,12 +175,12 @@ var ProSidebar = function ProSidebar(props) {
|
|
|
174
175
|
}), " ").concat(className),
|
|
175
176
|
style: style
|
|
176
177
|
}, /*#__PURE__*/React.createElement(ProSidebarContainer, _objectSpread(_objectSpread({
|
|
177
|
-
searchOnChange: function
|
|
178
|
+
searchOnChange: debounce(function (value) {
|
|
178
179
|
if (showSearch) {
|
|
179
|
-
|
|
180
|
+
searchOnChange === null || searchOnChange === void 0 ? void 0 : searchOnChange(value);
|
|
180
181
|
setSearchKey(value);
|
|
181
182
|
}
|
|
182
|
-
},
|
|
183
|
+
}, 300),
|
|
183
184
|
onExpandAllChange: onExpandAllChange,
|
|
184
185
|
onExpandLevelChange: onExpandLevelChange,
|
|
185
186
|
showSearch: showSearch,
|
|
@@ -69,3 +69,15 @@ export declare function getTreeLevelKey(data: any[], level: number, aliasMap?: {
|
|
|
69
69
|
key: string;
|
|
70
70
|
children: string;
|
|
71
71
|
}): any[];
|
|
72
|
+
/**
|
|
73
|
+
* 深度遍历并查找节点(展开查找到的字节点路径)
|
|
74
|
+
* @param nodes 数据
|
|
75
|
+
* @param predicate 条件
|
|
76
|
+
* @param aliasMap 标识
|
|
77
|
+
* @returns
|
|
78
|
+
*/
|
|
79
|
+
export declare function filterTreeData<T>(nodes: any[], predicate: (node: T) => boolean, aliasMap?: {
|
|
80
|
+
children: string;
|
|
81
|
+
}): {
|
|
82
|
+
filterTreeValue: T[];
|
|
83
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
1
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
4
|
|
|
3
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -225,4 +227,60 @@ export function getTreeLevelKey(data, level, aliasMap) {
|
|
|
225
227
|
children: children
|
|
226
228
|
});
|
|
227
229
|
return result;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* 深度遍历并查找节点(展开查找到的字节点路径)
|
|
233
|
+
* @param nodes 数据
|
|
234
|
+
* @param predicate 条件
|
|
235
|
+
* @param aliasMap 标识
|
|
236
|
+
* @returns
|
|
237
|
+
*/
|
|
238
|
+
|
|
239
|
+
export function filterTreeData(nodes, predicate, aliasMap) {
|
|
240
|
+
if (!(nodes && nodes.length)) {
|
|
241
|
+
return {
|
|
242
|
+
filterTreeValue: []
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
var _ref8 = aliasMap !== null && aliasMap !== void 0 ? aliasMap : {},
|
|
247
|
+
_ref8$children = _ref8.children,
|
|
248
|
+
children = _ref8$children === void 0 ? 'children' : _ref8$children;
|
|
249
|
+
|
|
250
|
+
var filterTreeValue = [];
|
|
251
|
+
|
|
252
|
+
var _iterator2 = _createForOfIteratorHelper(nodes),
|
|
253
|
+
_step2;
|
|
254
|
+
|
|
255
|
+
try {
|
|
256
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
257
|
+
var node = _step2.value;
|
|
258
|
+
|
|
259
|
+
var others = _extends({}, node);
|
|
260
|
+
|
|
261
|
+
if (predicate(node)) {
|
|
262
|
+
var _node$children3;
|
|
263
|
+
|
|
264
|
+
filterTreeValue.push(_objectSpread(_objectSpread({}, others), {}, {
|
|
265
|
+
children: filterTreeData((_node$children3 = node[children]) !== null && _node$children3 !== void 0 ? _node$children3 : [], predicate, aliasMap).filterTreeValue
|
|
266
|
+
}));
|
|
267
|
+
} else {
|
|
268
|
+
var subs = filterTreeData(node[children], predicate, aliasMap);
|
|
269
|
+
|
|
270
|
+
if (subs && subs.filterTreeValue.length) {
|
|
271
|
+
filterTreeValue.push(_objectSpread(_objectSpread({}, others), {}, {
|
|
272
|
+
children: subs.filterTreeValue
|
|
273
|
+
}));
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
} catch (err) {
|
|
278
|
+
_iterator2.e(err);
|
|
279
|
+
} finally {
|
|
280
|
+
_iterator2.f();
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return {
|
|
284
|
+
filterTreeValue: filterTreeValue
|
|
285
|
+
};
|
|
228
286
|
}
|
|
@@ -253,7 +253,7 @@ function useDialogFormAction(action, context) {
|
|
|
253
253
|
|
|
254
254
|
_onFinish && _onFinish((_innerFormRef$current2 = innerFormRef.current) === null || _innerFormRef$current2 === void 0 ? void 0 : _innerFormRef$current2.values);
|
|
255
255
|
}
|
|
256
|
-
}, others), context);
|
|
256
|
+
}, others), context, true);
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
var _default = useDialogFormAction;
|
package/lib/actions/dialog.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface DialogAction extends Omit<RequestAction, 'url'>, Omit<QuickShow
|
|
|
26
26
|
/** 弹窗内容区的组件 */
|
|
27
27
|
component?: any;
|
|
28
28
|
}
|
|
29
|
-
export declare function useDialogAction(action: DialogAction, actionContext?: any): {
|
|
29
|
+
export declare function useDialogAction(action: DialogAction, actionContext?: any, hasForm?: boolean): {
|
|
30
30
|
[x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
|
31
31
|
};
|
|
32
32
|
export default useDialogAction;
|
package/lib/actions/dialog.js
CHANGED
|
@@ -95,7 +95,7 @@ function getFooterAlignClass(isDrawer, align) {
|
|
|
95
95
|
} // 弹窗 -> 请求(点击确认,发送数据请求)
|
|
96
96
|
|
|
97
97
|
|
|
98
|
-
function useDialogAction(action, actionContext) {
|
|
98
|
+
function useDialogAction(action, actionContext, hasForm) {
|
|
99
99
|
var _useState = (0, _react.useState)(false),
|
|
100
100
|
_useState2 = _slicedToArray(_useState, 2),
|
|
101
101
|
loading = _useState2[0],
|
|
@@ -200,17 +200,27 @@ function useDialogAction(action, actionContext) {
|
|
|
200
200
|
case 6:
|
|
201
201
|
onFinish && onFinish();
|
|
202
202
|
resolve(true);
|
|
203
|
-
_context.next =
|
|
203
|
+
_context.next = 18;
|
|
204
204
|
break;
|
|
205
205
|
|
|
206
206
|
case 10:
|
|
207
207
|
_context.prev = 10;
|
|
208
208
|
_context.t0 = _context["catch"](2);
|
|
209
|
-
setLoading(false);
|
|
209
|
+
setLoading(false); // 如果 beforeRequest 中返回了 false 并且不是 dialog-form,则直接关闭弹窗
|
|
210
|
+
|
|
211
|
+
if (!(beforeRequest && !hasForm)) {
|
|
212
|
+
_context.next = 16;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
resolve(true);
|
|
217
|
+
return _context.abrupt("return");
|
|
218
|
+
|
|
219
|
+
case 16:
|
|
210
220
|
resolve(false);
|
|
211
221
|
return _context.abrupt("return");
|
|
212
222
|
|
|
213
|
-
case
|
|
223
|
+
case 18:
|
|
214
224
|
case "end":
|
|
215
225
|
return _context.stop();
|
|
216
226
|
}
|
|
@@ -78,13 +78,14 @@ var useMain = function useMain(active) {
|
|
|
78
78
|
}; // 筛选项数据
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
var useFilterItems = function useFilterItems(filterValues) {
|
|
81
|
+
var useFilterItems = function useFilterItems(filterValues, scope) {
|
|
82
82
|
var schema = (0, _react2.useFieldSchema)();
|
|
83
83
|
var filterItems = [];
|
|
84
84
|
schema.mapProperties(function (schema, name) {
|
|
85
85
|
if (!filterValues || filterValues && filterValues.includes(schema.name)) {
|
|
86
|
+
var label = /{{.*}}/.test(schema.title) ? (0, _utils.getTargetValue)(schema.title, scope) : schema.title;
|
|
86
87
|
filterItems.push({
|
|
87
|
-
label:
|
|
88
|
+
label: label,
|
|
88
89
|
value: schema.name
|
|
89
90
|
});
|
|
90
91
|
}
|
|
@@ -107,7 +108,8 @@ var LightFilter = (0, _react2.observer)(function (props) {
|
|
|
107
108
|
onFilterChange = props.onFilterChange,
|
|
108
109
|
filterProps = props.filterProps,
|
|
109
110
|
buttonProps = props.buttonProps;
|
|
110
|
-
var
|
|
111
|
+
var scope = (0, _react.useContext)(_react2.SchemaExpressionScopeContext);
|
|
112
|
+
var filterItems = useFilterItems(filterValues, scope);
|
|
111
113
|
|
|
112
114
|
var _useState = (0, _react.useState)(defaultFilterValue || ((_filterItems$ = filterItems[0]) === null || _filterItems$ === void 0 ? void 0 : _filterItems$.value)),
|
|
113
115
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -73,6 +73,11 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
73
73
|
validateFirst = _ref.validateFirst,
|
|
74
74
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
75
75
|
|
|
76
|
+
// 获取全局配置
|
|
77
|
+
var _ref2 = (0, _utils.getGlobalConfig)('ProForm') || {},
|
|
78
|
+
globalComponents = _ref2.components,
|
|
79
|
+
globalScope = _ref2.scope;
|
|
80
|
+
|
|
76
81
|
var form = (0, _react.useMemo)(function () {
|
|
77
82
|
return outerForm || (0, _core.createForm)({
|
|
78
83
|
validateFirst: validateFirst
|
|
@@ -81,11 +86,14 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
81
86
|
var prefixCls = (0, _utils.usePrefixCls)('', {
|
|
82
87
|
prefix: 'teamix-pro-form'
|
|
83
88
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
|
|
90
|
+
var mergedScope = _objectSpread(_objectSpread(_objectSpread({}, globalScope), scope), {}, {
|
|
91
|
+
context: context
|
|
92
|
+
}); // context需要实名不能解构
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
var mergedComponents = _objectSpread(_objectSpread({}, globalComponents), components);
|
|
96
|
+
|
|
89
97
|
var onAutoSubmit = (0, _useAutoSubmit.default)(onSubmit); // todo 需要formily支持断点下的属性更新
|
|
90
98
|
|
|
91
99
|
var getTeamixLayout = (0, _react.useMemo)(function () {
|
|
@@ -142,7 +150,7 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
142
150
|
}), /*#__PURE__*/_react.default.createElement(_SchemaForm.default, {
|
|
143
151
|
schema: schema,
|
|
144
152
|
scope: mergedScope,
|
|
145
|
-
components:
|
|
153
|
+
components: mergedComponents
|
|
146
154
|
}), children);
|
|
147
155
|
});
|
|
148
156
|
ProForm.defaultProps = {
|
|
@@ -65,8 +65,6 @@ var _fieldTypeMap = _interopRequireDefault(require("../fieldTypeMap"));
|
|
|
65
65
|
|
|
66
66
|
var _utils = require("../utils");
|
|
67
67
|
|
|
68
|
-
var _utils2 = require("@teamix/utils");
|
|
69
|
-
|
|
70
68
|
var _warning = _interopRequireDefault(require("../warning"));
|
|
71
69
|
|
|
72
70
|
var _excluded = ["component", "type", "name", "decorator", "decoratorProps", "dataSource", "reactions", "rules", "children", "items", "tooltip", "request", "data"];
|
|
@@ -111,16 +109,11 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
111
109
|
var schema = _ref.schema,
|
|
112
110
|
scope = _ref.scope,
|
|
113
111
|
components = _ref.components;
|
|
114
|
-
|
|
115
|
-
// 获取全局配置
|
|
116
|
-
var _ref2 = (0, _utils2.getGlobalConfig)('ProForm') || {},
|
|
117
|
-
globalComponents = _ref2.components,
|
|
118
|
-
globalScope = _ref2.scope; // 创建 SchemaField
|
|
119
|
-
|
|
112
|
+
var schemaScopeRef = (0, _react.useRef)({}); // 创建 SchemaField,添加内置组件
|
|
120
113
|
|
|
121
114
|
var SchemaField = (0, _react.useMemo)(function () {
|
|
122
115
|
return (0, _react2.createSchemaField)({
|
|
123
|
-
components: _objectSpread(_objectSpread(
|
|
116
|
+
components: _objectSpread(_objectSpread({}, _ProField.default), {}, {
|
|
124
117
|
FormLayout: _formily.FormLayout,
|
|
125
118
|
FormItem: _formily.FormItem,
|
|
126
119
|
ArrayCollapse: _formily.ArrayCollapse,
|
|
@@ -149,16 +142,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
149
142
|
Text: _index.default
|
|
150
143
|
})
|
|
151
144
|
});
|
|
152
|
-
}, []); //
|
|
153
|
-
|
|
154
|
-
var mergedScope = (0, _react.useMemo)(function () {
|
|
155
|
-
return _objectSpread(_objectSpread(_objectSpread({}, globalScope), scope), {}, {
|
|
156
|
-
$request: _reactions.$request,
|
|
157
|
-
$common: _reactions.$common,
|
|
158
|
-
$dataSource: _reactions.$dataSource,
|
|
159
|
-
$validator: _reactions.$validator
|
|
160
|
-
});
|
|
161
|
-
}, [scope]); // 格式化 schema
|
|
145
|
+
}, []); // 格式化 schema
|
|
162
146
|
|
|
163
147
|
var formatSchema = (0, _react.useCallback)(function (schema) {
|
|
164
148
|
var parentSuffix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
@@ -277,12 +261,12 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
277
261
|
|
|
278
262
|
var defaultReactions = (0, _initializeReactions.default)(reactions, [].concat(_toConsumableArray(requestReactions), _toConsumableArray(dataSourceReactions))); // 合并scope
|
|
279
263
|
|
|
280
|
-
Object.entries(_objectSpread(_objectSpread(_objectSpread({}, requestScope), dataSourceScope), rulesScope)).map(function (
|
|
281
|
-
var
|
|
282
|
-
k =
|
|
283
|
-
v =
|
|
264
|
+
Object.entries(_objectSpread(_objectSpread(_objectSpread({}, requestScope), dataSourceScope), rulesScope)).map(function (_ref2) {
|
|
265
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
266
|
+
k = _ref3[0],
|
|
267
|
+
v = _ref3[1];
|
|
284
268
|
|
|
285
|
-
|
|
269
|
+
schemaScopeRef.current[k] = v;
|
|
286
270
|
});
|
|
287
271
|
var formatParam = (0, _utils.mapSchemaName)(_objectSpread(_objectSpread({}, otherProps), {}, {
|
|
288
272
|
type: defaultType,
|
|
@@ -307,13 +291,20 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
307
291
|
schemaProperties[name] = _objectSpread(_objectSpread(_objectSpread({}, formatParam), recursiveProperties), recursiveItems);
|
|
308
292
|
});
|
|
309
293
|
return schemaProperties;
|
|
310
|
-
}, [
|
|
294
|
+
}, []);
|
|
311
295
|
var formilySchema = (0, _react.useMemo)(function () {
|
|
312
296
|
return {
|
|
313
297
|
type: 'object',
|
|
314
298
|
properties: formatSchema(schema)
|
|
315
299
|
};
|
|
316
|
-
}, [schema]);
|
|
300
|
+
}, [schema]);
|
|
301
|
+
|
|
302
|
+
var mergedScope = _objectSpread(_objectSpread({}, scope), {}, {
|
|
303
|
+
$request: _reactions.$request,
|
|
304
|
+
$common: _reactions.$common,
|
|
305
|
+
$dataSource: _reactions.$dataSource,
|
|
306
|
+
$validator: _reactions.$validator
|
|
307
|
+
}, schemaScopeRef.current);
|
|
317
308
|
|
|
318
309
|
return /*#__PURE__*/_react.default.createElement(SchemaField, {
|
|
319
310
|
schema: formilySchema,
|
package/lib/index.d.ts
CHANGED
|
@@ -26,5 +26,5 @@ export * from './table';
|
|
|
26
26
|
export * from './sidebar';
|
|
27
27
|
export * from './utils';
|
|
28
28
|
export * from './timeline';
|
|
29
|
-
declare const version = "1.3.
|
|
29
|
+
declare const version = "1.3.11";
|
|
30
30
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, hooks, nocode, templates, utils, };
|