@teamix/pro 1.5.3 → 1.5.4-beta.0
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 +20239 -19807
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/dist/pro.min.js.LICENSE.txt +2 -6
- package/es/actions/base.js +8 -21
- package/es/actions/dialog-component.js +2 -9
- package/es/actions/dialog-form.js +37 -75
- package/es/actions/dialog-info.js +1 -5
- package/es/actions/dialog.js +57 -95
- package/es/actions/index.d.ts +2 -0
- package/es/actions/index.js +70 -156
- package/es/actions/link.js +3 -5
- package/es/actions/quick.js +0 -6
- package/es/actions/request.js +12 -27
- package/es/actions/utils.js +1 -9
- package/es/card/card-container.js +0 -5
- package/es/card/divider.js +0 -5
- package/es/card/index.js +56 -95
- package/es/card/selectable.js +4 -13
- package/es/card/tab.js +1 -10
- package/es/card/utils.js +0 -2
- package/es/form/Components/Editable/index.js +16 -55
- package/es/form/Components/FormGroup/index.d.ts +1 -0
- package/es/form/Components/FormGroup/index.js +7 -22
- package/es/form/Components/LightFilter/index.js +15 -35
- package/es/form/Components/ProField/index.js +2 -14
- package/es/form/Components/ProField/mapDateFormat.js +2 -28
- package/es/form/Components/Text/index.d.ts +1 -0
- package/es/form/Components/Text/index.js +2 -11
- package/es/form/Filter/AdvancedFilter.js +11 -26
- package/es/form/Filter/Layout.js +11 -24
- package/es/form/Filter/LightFilter.js +13 -24
- package/es/form/Filter/SimpleFilter.js +7 -21
- package/es/form/Filter/index.js +106 -171
- package/es/form/Filter/index2.js +11 -28
- package/es/form/Filter/useBindUrl.js +18 -46
- package/es/form/Filter/useSpecialProps.js +8 -13
- package/es/form/ProForm/addCascadeEffect.js +10 -32
- package/es/form/ProForm/customComponent.js +0 -5
- package/es/form/ProForm/index.js +23 -34
- package/es/form/ProForm/useAutoLayout.js +21 -42
- package/es/form/ProForm/useAutoSubmit.js +3 -8
- package/es/form/ProForm/useFieldRequest.js +0 -5
- package/es/form/ProForm/useFormDisplayValues.js +12 -28
- package/es/form/ProForm/useInitialRequest.js +0 -5
- package/es/form/SchemaForm/adapterComponent.js +0 -3
- package/es/form/SchemaForm/adapterDecorator.d.ts +1 -1
- package/es/form/SchemaForm/adapterDecorator.js +0 -8
- package/es/form/SchemaForm/adapterType.js +0 -2
- package/es/form/SchemaForm/index.js +78 -114
- package/es/form/SchemaForm/initializeArrayCards.js +0 -6
- package/es/form/SchemaForm/initializeArrayCollapse.js +0 -6
- package/es/form/SchemaForm/initializeArrayItems.js +2 -9
- package/es/form/SchemaForm/initializeArrayTable.js +21 -34
- package/es/form/SchemaForm/initializeDataSource.js +2 -6
- package/es/form/SchemaForm/initializeFormButton.js +14 -31
- package/es/form/SchemaForm/initializeFormCollapse.js +8 -18
- package/es/form/SchemaForm/initializeFormGroup.js +10 -20
- package/es/form/SchemaForm/initializeFormStep.js +11 -23
- package/es/form/SchemaForm/initializeFormTab.js +10 -20
- package/es/form/SchemaForm/initializeReactions.js +9 -33
- package/es/form/SchemaForm/initializeRequest.js +2 -16
- package/es/form/SchemaForm/initializeRules.js +4 -22
- package/es/form/SchemaForm/initializeSelectTable.js +7 -33
- package/es/form/SchemaForm/reactions.js +19 -34
- package/es/form/docs/ActionResponse.d.ts +1 -0
- package/es/form/index.d.ts +9 -9
- package/es/form/index.js +0 -9
- package/es/form/typing.d.ts +6 -4
- package/es/form/utils.d.ts +1 -1
- package/es/form/utils.js +4 -49
- package/es/form/warning.js +2 -7
- package/es/index-without-icon.js +4 -3
- package/es/index.d.ts +1 -1
- package/es/index.js +7 -8
- package/es/info/components/InfoGroup/index.js +21 -32
- package/es/info/components/InfoValueItem/index.js +66 -119
- package/es/info/components/ProInfoItem/index.js +13 -21
- package/es/info/components/baseInfo/index.js +14 -26
- package/es/info/components/headerInfo/index.js +8 -20
- package/es/info/components/tableInfo/index.js +20 -50
- package/es/info/index.js +53 -82
- package/es/info/utils/index.js +0 -11
- package/es/nocode/configurators/common.js +5 -6
- package/es/nocode/configurators/index.js +2 -3
- package/es/nocode/index.js +6 -6
- package/es/nocode/pages/editor.js +5 -9
- package/es/nocode/pages/index.js +4 -4
- package/es/nocode/pages/playground.js +18 -35
- package/es/nocode/pages/renderer.js +9 -42
- package/es/nocode/playground.js +10 -23
- package/es/page-header/index.d.ts +2 -2
- package/es/page-header/index.js +39 -75
- package/es/sidebar/components/sidebar-container/index.js +41 -72
- package/es/sidebar/components/tree/index.js +88 -144
- package/es/sidebar/components/tree-node/components/HoverTooltip/index.js +11 -26
- package/es/sidebar/components/tree-node/components/IconAction/index.js +9 -35
- package/es/sidebar/components/tree-node/components/IconSwitch/index.js +12 -25
- package/es/sidebar/components/tree-node/index.js +41 -83
- package/es/sidebar/index.js +69 -94
- package/es/sidebar/utils/action-ref.js +2 -7
- package/es/sidebar/utils/index.d.ts +5 -2
- package/es/sidebar/utils/index.js +41 -98
- package/es/table/components/CardView/index.js +62 -149
- package/es/table/components/Filter/index.js +42 -83
- package/es/table/components/Layout/index.js +25 -45
- package/es/table/components/LoadMore/index.js +15 -34
- package/es/table/components/Pagination/index.js +25 -58
- package/es/table/components/QuickAction/index.js +3 -11
- package/es/table/components/ToolBar/CardSwitch.js +6 -17
- package/es/table/components/ToolBar/DensityIcon.js +18 -31
- package/es/table/components/ToolBar/FilterColumnIcon.js +50 -106
- package/es/table/components/ToolBar/FullScreenIcon.js +2 -6
- package/es/table/components/ToolBar/Fullscreen.js +19 -35
- package/es/table/components/ToolBar/RefreshIcon.js +2 -5
- package/es/table/components/ToolBar/index.js +23 -45
- package/es/table/index.js +226 -399
- package/es/table/utils/columnRender.d.ts +1 -1
- package/es/table/utils/columnRender.js +32 -76
- package/es/table/utils/genProColumnToColumn.js +5 -14
- package/es/table/utils/index.js +14 -47
- package/es/table/utils/pureColumnRender.js +21 -53
- package/es/table/utils/pureGenProColumnToColumn.d.ts +1 -1
- package/es/table/utils/pureGenProColumnToColumn.js +2 -10
- package/es/table/utils/useTableSelection.js +6 -33
- package/es/templates/List/index.js +2 -9
- package/es/timeline/ProTimeLineItem/index.js +24 -64
- package/es/timeline/index.js +8 -22
- package/es/timeline/typing.d.ts +1 -0
- package/es/utils/message.d.ts +2 -2
- package/es/utils/message.js +0 -5
- package/es/utils/useRealHistory.d.ts +8 -0
- package/es/utils/useRealHistory.js +23 -0
- package/lib/actions/base.js +8 -24
- package/lib/actions/confirm.js +0 -5
- package/lib/actions/danger-confirm.js +0 -5
- package/lib/actions/danger-pop-confirm.js +0 -4
- package/lib/actions/dialog-component.js +2 -15
- package/lib/actions/dialog-form.js +36 -88
- package/lib/actions/dialog-info.js +1 -10
- package/lib/actions/dialog-table.js +0 -5
- package/lib/actions/dialog.js +55 -111
- package/lib/actions/drawer-form.js +0 -3
- package/lib/actions/drawer-info.js +0 -3
- package/lib/actions/drawer-table.js +0 -3
- package/lib/actions/drawer.js +0 -4
- package/lib/actions/error.js +0 -5
- package/lib/actions/index.d.ts +2 -0
- package/lib/actions/index.js +70 -186
- package/lib/actions/link.js +3 -10
- package/lib/actions/notice.js +0 -5
- package/lib/actions/pop-confirm.js +0 -5
- package/lib/actions/quick.js +0 -13
- package/lib/actions/request.js +10 -32
- package/lib/actions/utils.js +1 -9
- package/lib/card/card-container.js +0 -9
- package/lib/card/divider.js +0 -7
- package/lib/card/index.js +56 -122
- package/lib/card/selectable.js +4 -20
- package/lib/card/tab.js +1 -14
- package/lib/card/utils.js +0 -6
- package/lib/field/index.js +0 -6
- package/lib/form/Components/Editable/index.js +15 -65
- package/lib/form/Components/FormGroup/index.d.ts +1 -0
- package/lib/form/Components/FormGroup/index.js +7 -28
- package/lib/form/Components/LightFilter/index.js +15 -47
- package/lib/form/Components/ProField/index.js +2 -21
- package/lib/form/Components/ProField/mapDateFormat.js +2 -32
- package/lib/form/Components/Text/index.d.ts +1 -0
- package/lib/form/Components/Text/index.js +2 -16
- package/lib/form/Filter/AdvancedFilter.js +11 -34
- package/lib/form/Filter/Layout.js +11 -33
- package/lib/form/Filter/LightFilter.js +13 -32
- package/lib/form/Filter/SimpleFilter.js +5 -27
- package/lib/form/Filter/index.js +105 -191
- package/lib/form/Filter/index2.js +11 -38
- package/lib/form/Filter/useBindUrl.js +18 -50
- package/lib/form/Filter/useSpecialProps.js +6 -13
- package/lib/form/ProForm/addCascadeEffect.js +10 -35
- package/lib/form/ProForm/customComponent.js +0 -8
- package/lib/form/ProForm/index.js +23 -57
- package/lib/form/ProForm/useAutoLayout.js +21 -45
- package/lib/form/ProForm/useAutoSubmit.js +3 -10
- package/lib/form/ProForm/useFieldRequest.js +0 -8
- package/lib/form/ProForm/useFormDisplayValues.js +12 -34
- package/lib/form/ProForm/useInitialRequest.js +0 -6
- package/lib/form/SchemaForm/adapterComponent.js +0 -6
- package/lib/form/SchemaForm/adapterDecorator.d.ts +1 -1
- package/lib/form/SchemaForm/adapterDecorator.js +0 -12
- package/lib/form/SchemaForm/adapterType.js +0 -5
- package/lib/form/SchemaForm/index.js +78 -144
- package/lib/form/SchemaForm/initializeArrayCards.js +0 -7
- package/lib/form/SchemaForm/initializeArrayCollapse.js +0 -7
- package/lib/form/SchemaForm/initializeArrayItems.js +2 -10
- package/lib/form/SchemaForm/initializeArrayTable.js +21 -34
- package/lib/form/SchemaForm/initializeDataSource.js +2 -8
- package/lib/form/SchemaForm/initializeFormButton.js +14 -32
- package/lib/form/SchemaForm/initializeFormCollapse.js +8 -18
- package/lib/form/SchemaForm/initializeFormGroup.js +10 -20
- package/lib/form/SchemaForm/initializeFormStep.js +11 -23
- package/lib/form/SchemaForm/initializeFormTab.js +10 -20
- package/lib/form/SchemaForm/initializeReactions.js +9 -37
- package/lib/form/SchemaForm/initializeRequest.js +2 -18
- package/lib/form/SchemaForm/initializeRules.js +4 -24
- package/lib/form/SchemaForm/initializeSelectTable.js +7 -36
- package/lib/form/SchemaForm/reactions.js +17 -37
- package/lib/form/docs/ActionResponse.d.ts +1 -0
- package/lib/form/docs/ActionResponse.js +0 -5
- package/lib/form/index.d.ts +9 -9
- package/lib/form/index.js +0 -25
- package/lib/form/typing.d.ts +6 -4
- package/lib/form/utils.d.ts +1 -1
- package/lib/form/utils.js +4 -61
- package/lib/form/warning.js +2 -8
- package/lib/hooks/index.js +0 -5
- package/lib/index-without-icon.js +2 -36
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -39
- package/lib/info/components/InfoGroup/index.js +21 -42
- package/lib/info/components/InfoValueItem/index.js +66 -134
- package/lib/info/components/ProInfoItem/index.js +13 -29
- package/lib/info/components/baseInfo/index.js +14 -38
- package/lib/info/components/headerInfo/index.js +8 -31
- package/lib/info/components/tableInfo/index.js +20 -62
- package/lib/info/index.js +53 -97
- package/lib/info/utils/index.js +0 -19
- package/lib/info/utils/utils.js +0 -1
- package/lib/nocode/configurators/PageHeader.js +0 -2
- package/lib/nocode/configurators/ProTable.js +0 -2
- package/lib/nocode/configurators/common.js +5 -10
- package/lib/nocode/configurators/index.js +2 -10
- package/lib/nocode/configurators/map.js +0 -5
- package/lib/nocode/index.js +0 -11
- package/lib/nocode/pages/editor.js +5 -19
- package/lib/nocode/pages/index.js +2 -9
- package/lib/nocode/pages/playground.js +18 -52
- package/lib/nocode/pages/renderer.js +9 -53
- package/lib/nocode/playground.js +10 -35
- package/lib/page-container/index.js +0 -6
- package/lib/page-header/index.d.ts +2 -2
- package/lib/page-header/index.js +38 -88
- package/lib/sidebar/components/sidebar-container/index.js +41 -84
- package/lib/sidebar/components/tree/index.js +88 -158
- package/lib/sidebar/components/tree-node/components/HoverTooltip/index.js +11 -34
- package/lib/sidebar/components/tree-node/components/IconAction/index.js +9 -46
- package/lib/sidebar/components/tree-node/components/IconSwitch/index.js +12 -35
- package/lib/sidebar/components/tree-node/index.js +41 -99
- package/lib/sidebar/index.js +69 -112
- package/lib/sidebar/utils/action-ref.js +2 -8
- package/lib/sidebar/utils/index.d.ts +5 -2
- package/lib/sidebar/utils/index.js +41 -106
- package/lib/skeleton/index.js +0 -6
- package/lib/table/components/CardView/index.js +62 -161
- package/lib/table/components/EmptyContent/index.js +0 -6
- package/lib/table/components/Filter/index.js +42 -93
- package/lib/table/components/Layout/index.js +25 -58
- package/lib/table/components/LoadMore/index.js +15 -44
- package/lib/table/components/Pagination/index.js +25 -68
- package/lib/table/components/QuickAction/index.js +3 -15
- package/lib/table/components/ToolBar/CardSwitch.js +6 -28
- package/lib/table/components/ToolBar/DensityIcon.js +18 -42
- package/lib/table/components/ToolBar/FilterColumnIcon.js +50 -118
- package/lib/table/components/ToolBar/FullScreenIcon.js +3 -13
- package/lib/table/components/ToolBar/Fullscreen.js +19 -42
- package/lib/table/components/ToolBar/RefreshIcon.js +3 -12
- package/lib/table/components/ToolBar/index.js +23 -63
- package/lib/table/index.js +226 -423
- package/lib/table/utils/columnRender.d.ts +1 -1
- package/lib/table/utils/columnRender.js +32 -89
- package/lib/table/utils/genProColumnToColumn.js +5 -19
- package/lib/table/utils/getTableProps.js +0 -2
- package/lib/table/utils/getTableSortIcons.js +0 -5
- package/lib/table/utils/index.js +12 -55
- package/lib/table/utils/pureColumnRender.js +21 -64
- package/lib/table/utils/pureGenProColumnToColumn.d.ts +1 -1
- package/lib/table/utils/pureGenProColumnToColumn.js +2 -11
- package/lib/table/utils/useTableSelection.js +6 -35
- package/lib/templates/Detail/index.js +0 -5
- package/lib/templates/Form/index.js +0 -5
- package/lib/templates/List/index.js +2 -19
- package/lib/templates/index.js +0 -6
- package/lib/timeline/ProTimeLineItem/index.js +24 -75
- package/lib/timeline/index.js +8 -33
- package/lib/timeline/typing.d.ts +1 -0
- package/lib/utils/index.js +0 -6
- package/lib/utils/message.d.ts +2 -2
- package/lib/utils/message.js +0 -10
- package/lib/utils/useRealHistory.d.ts +8 -0
- package/lib/utils/useRealHistory.js +32 -0
- package/package.json +1 -1
package/es/form/Filter/index2.js
CHANGED
@@ -1,34 +1,21 @@
|
|
1
1
|
var _excluded = ["schema", "triggerType", "onFilter"];
|
2
|
-
|
3
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
4
|
-
|
5
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
6
|
-
|
7
4
|
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); }
|
8
|
-
|
9
5
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
10
|
-
|
11
6
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
12
|
-
|
13
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; }
|
14
|
-
|
15
8
|
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; }
|
16
|
-
|
17
9
|
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; }
|
18
|
-
|
19
10
|
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; }
|
20
|
-
|
21
11
|
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; }
|
22
|
-
|
23
12
|
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; }
|
24
|
-
|
25
13
|
import React, { memo, useMemo } from 'react';
|
26
14
|
import { usePrefixCls, getMessage, cls } from '@teamix/utils';
|
27
15
|
import { createForm } from '@formily/core';
|
28
16
|
import ProForm from '../ProForm';
|
29
17
|
import { mergeArrayValue } from '../utils';
|
30
18
|
import './index2.scss';
|
31
|
-
|
32
19
|
var getEventProps = function getEventProps(triggerType, onFilter) {
|
33
20
|
var keydownEvent = {
|
34
21
|
onSubmit: onFilter
|
@@ -46,14 +33,11 @@ var getEventProps = function getEventProps(triggerType, onFilter) {
|
|
46
33
|
/**
|
47
34
|
* 简单筛选
|
48
35
|
*/
|
49
|
-
|
50
|
-
|
51
36
|
var SimpleFilter = /*#__PURE__*/memo(function (props) {
|
52
37
|
var schema = props.schema,
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
38
|
+
triggerType = props.triggerType,
|
39
|
+
onFilter = props.onFilter,
|
40
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
57
41
|
var prefixCls = usePrefixCls('teamix-pro-form-filter-simple');
|
58
42
|
var simpleSchema = useMemo(function () {
|
59
43
|
return [{
|
@@ -89,20 +73,19 @@ SimpleFilter.defaultProps = {
|
|
89
73
|
/**
|
90
74
|
* 高级筛选
|
91
75
|
*/
|
92
|
-
|
93
76
|
var AdvancedFilter = /*#__PURE__*/memo(function (props) {
|
94
77
|
var form = useMemo(function () {
|
95
78
|
return (props === null || props === void 0 ? void 0 : props.form) || createForm();
|
96
79
|
}, []);
|
97
80
|
var schema = props.schema,
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
81
|
+
triggerType = props.triggerType,
|
82
|
+
onFilter = props.onFilter,
|
83
|
+
onReset = props.onReset,
|
84
|
+
layout = props.layout,
|
85
|
+
labelAlign = props.labelAlign,
|
86
|
+
wrapperAlign = props.wrapperAlign,
|
87
|
+
labelCol = props.labelCol,
|
88
|
+
wrapperCol = props.wrapperCol;
|
106
89
|
var prefixCls = usePrefixCls('teamix-pro-form-filter-advanced');
|
107
90
|
var gridSchema = useMemo(function () {
|
108
91
|
return [{
|
@@ -1,21 +1,12 @@
|
|
1
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
-
|
3
2
|
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
3
|
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
4
|
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
5
|
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
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
12
|
-
|
13
7
|
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; }
|
14
|
-
|
15
8
|
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; }
|
16
|
-
|
17
9
|
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
|
-
|
19
10
|
import { useUrlState } from '@teamix/hooks';
|
20
11
|
import { isUsable, isPlainObj } from '@teamix/utils';
|
21
12
|
export default (function (bindUrl, functions, formRef) {
|
@@ -24,25 +15,19 @@ export default (function (bindUrl, functions, formRef) {
|
|
24
15
|
return options ? _objectSpread(_objectSpread({}, options), {}, {
|
25
16
|
beforeStringify: function beforeStringify(values) {
|
26
17
|
var _Object$entries;
|
27
|
-
|
28
18
|
var beforeStringify = options.beforeStringify;
|
29
|
-
|
30
19
|
var newValues = _objectSpread({}, values);
|
31
|
-
|
32
20
|
(_Object$entries = Object.entries(values)) === null || _Object$entries === void 0 ? void 0 : _Object$entries.forEach(function (_ref) {
|
33
21
|
var _form$query;
|
34
|
-
|
35
22
|
var _ref2 = _slicedToArray(_ref, 2),
|
36
|
-
|
37
|
-
|
38
|
-
|
23
|
+
key = _ref2[0],
|
24
|
+
value = _ref2[1];
|
39
25
|
var form = formRef.current;
|
40
26
|
var field = (_form$query = form.query(key)) === null || _form$query === void 0 ? void 0 : _form$query.take();
|
41
|
-
|
42
27
|
if ((field === null || field === void 0 ? void 0 : field.component[0]) === 'SelectGroup') {
|
43
28
|
newValues[key] = value.map(function (_ref3) {
|
44
29
|
var key = _ref3.key,
|
45
|
-
|
30
|
+
value = _ref3.value;
|
46
31
|
return key && value ? "".concat(key, "||").concat(value === null || value === void 0 ? void 0 : value.join('|')) : '';
|
47
32
|
});
|
48
33
|
}
|
@@ -50,68 +35,55 @@ export default (function (bindUrl, functions, formRef) {
|
|
50
35
|
return beforeStringify ? beforeStringify(newValues) : newValues;
|
51
36
|
}
|
52
37
|
}) : options;
|
53
|
-
};
|
54
|
-
|
55
|
-
|
38
|
+
};
|
39
|
+
// 通过 useUrlState 获取 url 上的参数和 url 配置方法
|
56
40
|
var _ref4 = bindUrl ? useUrlState(undefined, initializeBindUrl(isPlainObj(bindUrl) ? bindUrl : {})) : [],
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
41
|
+
_ref5 = _slicedToArray(_ref4, 2),
|
42
|
+
urlState = _ref5[0],
|
43
|
+
setUrlState = _ref5[1];
|
44
|
+
// 输出配置url参数的函数
|
62
45
|
var initializedFunctions = Object.entries(functions).reduce(function (prev, _ref6) {
|
63
46
|
var _ref7 = _slicedToArray(_ref6, 2),
|
64
|
-
|
65
|
-
|
66
|
-
|
47
|
+
key = _ref7[0],
|
48
|
+
fun = _ref7[1];
|
67
49
|
prev[key] = function (values) {
|
68
50
|
fun === null || fun === void 0 ? void 0 : fun(values);
|
69
51
|
setUrlState === null || setUrlState === void 0 ? void 0 : setUrlState(values);
|
70
52
|
};
|
71
|
-
|
72
53
|
return prev;
|
73
|
-
}, {});
|
74
|
-
|
54
|
+
}, {});
|
55
|
+
// 使用 url 参数配置 QueryFilter 默认值(移除非表单值,兼容数组数据,兼容 SelectGroup 组件)
|
75
56
|
var setValuesByUrlState = function setValuesByUrlState(form) {
|
76
57
|
if (urlState) {
|
77
58
|
var _Object$entries2;
|
78
|
-
|
79
59
|
(_Object$entries2 = Object.entries(urlState)) === null || _Object$entries2 === void 0 ? void 0 : _Object$entries2.forEach(function (_ref8) {
|
80
60
|
var _form$query2;
|
81
|
-
|
82
61
|
var _ref9 = _slicedToArray(_ref8, 2),
|
83
|
-
|
84
|
-
|
85
|
-
|
62
|
+
key = _ref9[0],
|
63
|
+
value = _ref9[1];
|
86
64
|
var field = (_form$query2 = form.query(key)) === null || _form$query2 === void 0 ? void 0 : _form$query2.take();
|
87
|
-
|
88
65
|
if (field) {
|
89
66
|
var newValue = value;
|
90
|
-
|
91
67
|
if (field.displayName === 'ArrayField') {
|
92
68
|
newValue = [].concat(isUsable(newValue) ? newValue : []);
|
93
69
|
}
|
94
|
-
|
95
70
|
if (field.component[0] === 'SelectGroup') {
|
96
71
|
newValue = newValue.map(function (item) {
|
97
72
|
var _item$split = item === null || item === void 0 ? void 0 : item.split('||'),
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
73
|
+
_item$split2 = _slicedToArray(_item$split, 2),
|
74
|
+
key = _item$split2[0],
|
75
|
+
value = _item$split2[1];
|
102
76
|
return {
|
103
77
|
key: key,
|
104
78
|
value: value === null || value === void 0 ? void 0 : value.split('|')
|
105
79
|
};
|
106
80
|
});
|
107
81
|
}
|
108
|
-
|
109
82
|
form.setValuesIn(key, newValue);
|
110
83
|
}
|
111
84
|
});
|
112
85
|
}
|
113
86
|
};
|
114
|
-
|
115
87
|
return _objectSpread({
|
116
88
|
setValuesByUrlState: setValuesByUrlState
|
117
89
|
}, initializedFunctions);
|
@@ -1,31 +1,27 @@
|
|
1
|
-
import { isUsable, isStr, isPlainObj } from '@teamix/utils';
|
2
|
-
|
1
|
+
import { isUsable, isStr, isPlainObj } from '@teamix/utils';
|
2
|
+
// 获取Schema是否包含默认值、异步默认值、必选校验等
|
3
3
|
var useSpecialProps = function useSpecialProps(props) {
|
4
4
|
var initialValues = props.initialValues,
|
5
|
-
|
5
|
+
initialRequest = props.initialRequest;
|
6
6
|
var hasChangeDefault = !!initialValues || !!initialRequest; // 会触发onChange的默认值
|
7
|
-
|
8
7
|
var hasDefault = hasChangeDefault;
|
9
8
|
var hasRequired = false;
|
10
|
-
|
11
9
|
var hasDefaultOrRule = function hasDefaultOrRule(schema) {
|
12
10
|
schema.forEach(function (item) {
|
13
11
|
var value = item.default,
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
required = item.required,
|
13
|
+
rules = item.rules,
|
14
|
+
dataSource = item.dataSource,
|
15
|
+
children = item.children;
|
16
|
+
// 字符串变量配置default值会触发onChange
|
19
17
|
hasChangeDefault = hasChangeDefault || !!(isPlainObj(dataSource) && isStr(value) && value.indexOf('.dataSource'));
|
20
18
|
hasDefault = hasDefault || isUsable(value);
|
21
19
|
hasRequired = hasRequired || required || !!rules;
|
22
|
-
|
23
20
|
if (children === null || children === void 0 ? void 0 : children.length) {
|
24
21
|
hasDefaultOrRule(children);
|
25
22
|
}
|
26
23
|
});
|
27
24
|
};
|
28
|
-
|
29
25
|
hasDefaultOrRule(props.schema);
|
30
26
|
return {
|
31
27
|
hasDefault: hasDefault,
|
@@ -33,5 +29,4 @@ var useSpecialProps = function useSpecialProps(props) {
|
|
33
29
|
hasRequired: hasRequired
|
34
30
|
};
|
35
31
|
};
|
36
|
-
|
37
32
|
export default useSpecialProps;
|
@@ -1,9 +1,6 @@
|
|
1
1
|
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
|
-
|
3
2
|
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; }
|
4
|
-
|
5
3
|
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
|
-
|
7
4
|
import { onFieldReact, onFieldValueChange } from '@formily/core';
|
8
5
|
var OP_MAPS = {
|
9
6
|
'*': function _() {
|
@@ -68,13 +65,11 @@ var OP_MAPS = {
|
|
68
65
|
return l !== null && l !== undefined && l !== '' && (!Array.isArray(l) || l.length !== 0);
|
69
66
|
}
|
70
67
|
};
|
71
|
-
|
72
68
|
var getParsedValue = function getParsedValue(value, scope) {
|
73
69
|
if (typeof value === 'string' && value.startsWith('${') && value.endsWith('}')) {
|
74
70
|
return scope.$form.getValuesIn(value.slice(2, value.length - 1));
|
75
71
|
} else if (typeof value === 'string' && value.startsWith('{{') && value.endsWith('}}')) {
|
76
72
|
var code = value.slice(2, value.length - 2);
|
77
|
-
|
78
73
|
try {
|
79
74
|
return new Function("with(this){ return ".concat(code, " }")).call(scope);
|
80
75
|
} catch (e) {
|
@@ -84,21 +79,19 @@ var getParsedValue = function getParsedValue(value, scope) {
|
|
84
79
|
return value;
|
85
80
|
}
|
86
81
|
};
|
87
|
-
|
88
82
|
var bingo = function bingo(bingoItem, scope) {
|
89
83
|
var _bingoItem$when = bingoItem.when,
|
90
|
-
|
91
|
-
|
92
|
-
|
84
|
+
when = _bingoItem$when === void 0 ? [] : _bingoItem$when,
|
85
|
+
_bingoItem$logic = bingoItem.logic,
|
86
|
+
logic = _bingoItem$logic === void 0 ? '&&' : _bingoItem$logic;
|
93
87
|
var result = logic === '&&';
|
94
88
|
when.forEach(function (_ref) {
|
95
89
|
var left = _ref.left,
|
96
|
-
|
97
|
-
|
90
|
+
op = _ref.op,
|
91
|
+
right = _ref.right;
|
98
92
|
var leftValue = scope.$form.getValuesIn(left);
|
99
93
|
var rightValue = getParsedValue(right, scope);
|
100
94
|
var itemResult = OP_MAPS[op](leftValue, rightValue);
|
101
|
-
|
102
95
|
if (logic === '&&') {
|
103
96
|
result = result && itemResult;
|
104
97
|
} else {
|
@@ -107,13 +100,11 @@ var bingo = function bingo(bingoItem, scope) {
|
|
107
100
|
});
|
108
101
|
return result;
|
109
102
|
};
|
110
|
-
|
111
103
|
var loopAddFieldEffect = function loopAddFieldEffect(schema, form, scope) {
|
112
104
|
if (Array.isArray(schema)) {
|
113
105
|
schema === null || schema === void 0 ? void 0 : schema.forEach(function (item) {
|
114
106
|
if (item.name) {
|
115
107
|
var _item$cascade, _item$onChange;
|
116
|
-
|
117
108
|
(_item$cascade = item.cascade) === null || _item$cascade === void 0 ? void 0 : _item$cascade.forEach(function (cascade) {
|
118
109
|
onFieldReact(item.name, function (field) {
|
119
110
|
var contextScope = _objectSpread(_objectSpread({}, scope), {}, {
|
@@ -121,18 +112,15 @@ var loopAddFieldEffect = function loopAddFieldEffect(schema, form, scope) {
|
|
121
112
|
$self: field,
|
122
113
|
$values: form.values
|
123
114
|
});
|
124
|
-
|
125
115
|
var _cascade$state = cascade.state,
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
116
|
+
state = _cascade$state === void 0 ? {} : _cascade$state,
|
117
|
+
_cascade$props = cascade.props,
|
118
|
+
props = _cascade$props === void 0 ? {} : _cascade$props,
|
119
|
+
dataSourceFilter = cascade.dataSourceFilter,
|
120
|
+
dataSourceHide = cascade.dataSourceHide;
|
132
121
|
if (bingo(cascade, contextScope)) {
|
133
122
|
if (dataSourceFilter || dataSourceHide) {
|
134
123
|
var sourceDataSource = field.getState()._sourceDataSource;
|
135
|
-
|
136
124
|
if (!sourceDataSource) {
|
137
125
|
var dataSource = field.getState().dataSource;
|
138
126
|
field.setState({
|
@@ -140,20 +128,17 @@ var loopAddFieldEffect = function loopAddFieldEffect(schema, form, scope) {
|
|
140
128
|
});
|
141
129
|
sourceDataSource = dataSource;
|
142
130
|
}
|
143
|
-
|
144
131
|
if (sourceDataSource) {
|
145
132
|
var nextDataSource = sourceDataSource.filter(function (item) {
|
146
133
|
if (Array.isArray(dataSourceFilter)) {
|
147
134
|
return dataSourceFilter.includes(item.value);
|
148
135
|
}
|
149
|
-
|
150
136
|
if (Array.isArray(dataSourceHide)) {
|
151
137
|
return !dataSourceFilter.includes(item.value);
|
152
138
|
}
|
153
139
|
});
|
154
140
|
field.setDataSource(nextDataSource);
|
155
141
|
var value = field.getState().value;
|
156
|
-
|
157
142
|
if (!nextDataSource.some(function (item) {
|
158
143
|
return item.value === value;
|
159
144
|
})) {
|
@@ -161,7 +146,6 @@ var loopAddFieldEffect = function loopAddFieldEffect(schema, form, scope) {
|
|
161
146
|
}
|
162
147
|
}
|
163
148
|
}
|
164
|
-
|
165
149
|
var nextState = {};
|
166
150
|
Object.keys(state).forEach(function (stateKey) {
|
167
151
|
nextState[stateKey] = getParsedValue(state[stateKey], contextScope);
|
@@ -174,13 +158,10 @@ var loopAddFieldEffect = function loopAddFieldEffect(schema, form, scope) {
|
|
174
158
|
field.setComponentProps(nextProps);
|
175
159
|
} else {
|
176
160
|
var formState = form.getState();
|
177
|
-
|
178
161
|
if (dataSourceFilter || dataSourceHide) {
|
179
162
|
var _sourceDataSource = field.getState()._sourceDataSource;
|
180
|
-
|
181
163
|
_sourceDataSource && field.setDataSource(_sourceDataSource);
|
182
164
|
}
|
183
|
-
|
184
165
|
var _nextState = {};
|
185
166
|
Object.keys(state).forEach(function (stateKey) {
|
186
167
|
_nextState[stateKey] = stateKey in item ? item[stateKey] : formState[stateKey];
|
@@ -201,9 +182,7 @@ var loopAddFieldEffect = function loopAddFieldEffect(schema, form, scope) {
|
|
201
182
|
$self: field,
|
202
183
|
$values: form.values
|
203
184
|
});
|
204
|
-
|
205
185
|
var values = onChange.values;
|
206
|
-
|
207
186
|
if (bingo(onChange, contextScope)) {
|
208
187
|
Object.keys(values).forEach(function (valuesKey) {
|
209
188
|
form.setValuesIn(valuesKey, getParsedValue(values[valuesKey], contextScope));
|
@@ -217,7 +196,6 @@ var loopAddFieldEffect = function loopAddFieldEffect(schema, form, scope) {
|
|
217
196
|
});
|
218
197
|
}
|
219
198
|
};
|
220
|
-
|
221
199
|
export default (function (form, schema, scope) {
|
222
200
|
form.addEffects('cascade', function () {
|
223
201
|
loopAddFieldEffect(schema, form, scope);
|
@@ -1,13 +1,9 @@
|
|
1
1
|
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
|
-
|
3
2
|
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; }
|
4
|
-
|
5
3
|
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
|
-
|
7
4
|
import { connect, mapProps } from '@formily/react';
|
8
5
|
import { toJS } from '@formily/reactive';
|
9
6
|
import { mapSize, mapStatus, mapDataSource } from '../utils';
|
10
|
-
|
11
7
|
var customComponent = function customComponent(component) {
|
12
8
|
return connect(component, mapProps(function (props, field) {
|
13
9
|
return _objectSpread(_objectSpread({}, props), {}, {
|
@@ -17,5 +13,4 @@ var customComponent = function customComponent(component) {
|
|
17
13
|
});
|
18
14
|
}, mapSize, mapStatus, mapDataSource));
|
19
15
|
};
|
20
|
-
|
21
16
|
export { customComponent };
|
package/es/form/ProForm/index.js
CHANGED
@@ -1,15 +1,9 @@
|
|
1
1
|
var _excluded = ["form", "initialValues", "initialRequest", "scope", "context", "components", "onChange", "onChangeType", "onSubmit", "onSubmitFailed", "onInitialComplete", "className", "validateFirst", "schema", "children"];
|
2
|
-
|
3
2
|
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; }
|
4
|
-
|
5
3
|
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; }
|
6
|
-
|
7
4
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
8
|
-
|
9
5
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
10
|
-
|
11
6
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
12
|
-
|
13
7
|
import React, { memo, useEffect, useMemo, useRef } from 'react';
|
14
8
|
import { usePrefixCls, cls, getLanguage, getGlobalConfig } from '@teamix/utils';
|
15
9
|
import { createForm, onFieldValueChange, onFormValuesChange, registerValidateLocale, setValidateLanguage } from '@formily/core';
|
@@ -59,32 +53,29 @@ var formilyComponents = {
|
|
59
53
|
};
|
60
54
|
var ProForm = /*#__PURE__*/memo(function (_ref) {
|
61
55
|
var outerForm = _ref.form,
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
56
|
+
initialValues = _ref.initialValues,
|
57
|
+
initialRequest = _ref.initialRequest,
|
58
|
+
scope = _ref.scope,
|
59
|
+
context = _ref.context,
|
60
|
+
components = _ref.components,
|
61
|
+
onChange = _ref.onChange,
|
62
|
+
onChangeType = _ref.onChangeType,
|
63
|
+
onSubmit = _ref.onSubmit,
|
64
|
+
onSubmitFailed = _ref.onSubmitFailed,
|
65
|
+
onInitialComplete = _ref.onInitialComplete,
|
66
|
+
className = _ref.className,
|
67
|
+
validateFirst = _ref.validateFirst,
|
68
|
+
schema = _ref.schema,
|
69
|
+
children = _ref.children,
|
70
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
71
|
+
var formRef = useRef();
|
72
|
+
// 获取全局配置
|
80
73
|
var _ref2 = getGlobalConfig('ProForm') || {},
|
81
|
-
|
82
|
-
|
83
|
-
|
74
|
+
globalComponents = _ref2.components,
|
75
|
+
globalScope = _ref2.scope;
|
84
76
|
var mergedScope = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, context), globalScope), scope), {}, {
|
85
77
|
context: context
|
86
78
|
});
|
87
|
-
|
88
79
|
var form = useMemo(function () {
|
89
80
|
var nextForm = outerForm || createForm({
|
90
81
|
validateFirst: validateFirst
|
@@ -92,10 +83,9 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
92
83
|
addCascadeEffect(nextForm, schema, mergedScope);
|
93
84
|
return nextForm;
|
94
85
|
}, [outerForm]);
|
95
|
-
var prefixCls = usePrefixCls('teamix-pro-form');
|
96
|
-
|
86
|
+
var prefixCls = usePrefixCls('teamix-pro-form');
|
87
|
+
// 由于Actions需要,解构context供使用。原context键名的上下文继续保留。
|
97
88
|
var mergedComponents = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, globalComponents), components), formilyComponents), ProFieldComponents);
|
98
|
-
|
99
89
|
var onAutoSubmit = useAutoSubmit(onSubmit, context);
|
100
90
|
var autoTeamixLayout = useAutoLayout(_objectSpread(_objectSpread({}, otherProps), {}, {
|
101
91
|
schema: schema
|
@@ -111,8 +101,8 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
111
101
|
onInitialComplete === null || onInitialComplete === void 0 ? void 0 : onInitialComplete(form);
|
112
102
|
});
|
113
103
|
}
|
114
|
-
}, []);
|
115
|
-
|
104
|
+
}, []);
|
105
|
+
// 添加 onChange 事件
|
116
106
|
useMemo(function () {
|
117
107
|
if (onChangeType === 'form') {
|
118
108
|
// 使用 onFormValuesChange 无法监听具体变化字段
|
@@ -128,7 +118,6 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
128
118
|
form.addEffects('onChangeByFieldValueChange', function () {
|
129
119
|
onFieldValueChange('*', function (field, form) {
|
130
120
|
var _field$props;
|
131
|
-
|
132
121
|
onChange === null || onChange === void 0 ? void 0 : onChange(toJS(form.values), toJS(field.value), (_field$props = field.props) === null || _field$props === void 0 ? void 0 : _field$props.name);
|
133
122
|
});
|
134
123
|
});
|
@@ -1,61 +1,47 @@
|
|
1
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
-
|
3
2
|
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
3
|
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
4
|
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
5
|
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
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
12
|
-
|
13
7
|
import { useEffect, useMemo, useState } from 'react';
|
14
8
|
import { isPlainObj, isBool, autoWidthBySpace, getWidthByCharacterMap, isStr } from '@teamix/utils';
|
15
9
|
import { mergeArrayValue } from '../utils';
|
16
|
-
|
17
10
|
var useAutoLayout = function useAutoLayout(_ref, formRef) {
|
18
11
|
var outBreakpoints = _ref.breakpoints,
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
12
|
+
layout = _ref.layout,
|
13
|
+
labelAlign = _ref.labelAlign,
|
14
|
+
wrapperAlign = _ref.wrapperAlign,
|
15
|
+
outLabelCol = _ref.labelCol,
|
16
|
+
outWrapperCol = _ref.wrapperCol,
|
17
|
+
autoLayout = _ref.autoLayout,
|
18
|
+
schema = _ref.schema;
|
27
19
|
var _ref2 = isPlainObj(autoLayout) ? autoLayout : {
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
20
|
+
autoLabel: autoLayout
|
21
|
+
},
|
22
|
+
autoLabel = _ref2.autoLabel;
|
32
23
|
var breakpoints = useMemo(function () {
|
33
24
|
return autoLabel ? false : outBreakpoints;
|
34
25
|
}, []); // 当前断点不支持Col更新
|
35
|
-
|
36
26
|
var _useState = useState({
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
27
|
+
labelCol: outLabelCol,
|
28
|
+
wrapperCol: outWrapperCol
|
29
|
+
}),
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
31
|
+
autoCol = _useState2[0],
|
32
|
+
setAutoCol = _useState2[1];
|
44
33
|
var labelCol = autoCol.labelCol,
|
45
|
-
|
34
|
+
wrapperCol = autoCol.wrapperCol;
|
46
35
|
useEffect(function () {
|
47
36
|
/**
|
48
37
|
* autolayout
|
49
38
|
*/
|
50
39
|
if (autoLabel) {
|
51
40
|
var formWidth = formRef.current.getBoundingClientRect().width; // 表单宽度
|
52
|
-
|
53
41
|
var labelArray = schema.map(function (item) {
|
54
42
|
var text = item.title;
|
55
|
-
|
56
43
|
if (isStr(text)) {
|
57
44
|
var _item$decoratorProps;
|
58
|
-
|
59
45
|
if (item.required) {
|
60
46
|
text += '一'; // 必填 + 12
|
61
47
|
}
|
@@ -66,19 +52,13 @@ var useAutoLayout = function useAutoLayout(_ref, formRef) {
|
|
66
52
|
|
67
53
|
return text;
|
68
54
|
}
|
69
|
-
|
70
55
|
return '';
|
71
56
|
}); // 标题内容集合
|
72
|
-
|
73
57
|
var labelWidthArray = getWidthByCharacterMap(labelArray); // 标题宽度集合
|
74
|
-
|
75
58
|
var _autoWidthBySpace = autoWidthBySpace(labelWidthArray),
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
59
|
+
expectedWidth = _autoWidthBySpace.expectedWidth,
|
60
|
+
consoleArray = _autoWidthBySpace.consoleArray; // 智能计算预期宽度
|
80
61
|
var expectedCol = Math.ceil(expectedWidth / formWidth * 24); // 预期宽度转换为 Col 值
|
81
|
-
|
82
62
|
setAutoCol({
|
83
63
|
labelCol: expectedCol,
|
84
64
|
wrapperCol: wrapperCol
|
@@ -89,8 +69,8 @@ var useAutoLayout = function useAutoLayout(_ref, formRef) {
|
|
89
69
|
wrapperCol: outWrapperCol
|
90
70
|
});
|
91
71
|
}
|
92
|
-
}, [outLabelCol, outWrapperCol]);
|
93
|
-
|
72
|
+
}, [outLabelCol, outWrapperCol]);
|
73
|
+
// Layout配置By断点(配置断点后,目前不支持 Col 更新)
|
94
74
|
var autoTeamixLayout = useMemo(function () {
|
95
75
|
return breakpoints === true ? {
|
96
76
|
breakpoints: [480],
|
@@ -110,5 +90,4 @@ var useAutoLayout = function useAutoLayout(_ref, formRef) {
|
|
110
90
|
}, [breakpoints, layout, labelAlign, wrapperAlign, labelCol, wrapperCol]);
|
111
91
|
return autoTeamixLayout;
|
112
92
|
};
|
113
|
-
|
114
93
|
export default useAutoLayout;
|