@teamix/pro 1.5.0-beta.1 → 1.5.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 +45535 -35222
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/dist/pro.min.js.LICENSE.txt +11 -0
- package/es/card/index.js +2 -2
- package/es/form/Filter/layout.scss +1 -1
- package/es/form/ProForm/addCascadeEffect.d.ts +2 -0
- package/es/form/ProForm/addCascadeEffect.js +225 -0
- package/es/form/ProForm/index.js +8 -5
- package/es/form/typing.d.ts +20 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +2 -1
- package/es/sidebar/components/sidebar-container/index.js +18 -2
- package/es/sidebar/components/sidebar-container/index.scss +21 -14
- package/es/sidebar/components/tree/index.js +24 -6
- package/es/sidebar/components/tree-node/index.js +1 -1
- package/es/sidebar/typing.d.ts +4 -0
- package/es/table/components/ToolBar/DensityIcon.js +1 -0
- package/es/table/components/ToolBar/FilterColumnIcon.js +2 -0
- package/es/table/components/ToolBar/FullScreenIcon.js +6 -57
- package/es/table/components/ToolBar/index.d.ts +1 -1
- package/es/table/components/ToolBar/index.js +99 -16
- package/es/table/components/ToolBar/index.scss +22 -2
- package/es/table/index.js +6 -3
- package/es/table/typing.d.ts +4 -1
- package/lib/card/index.js +2 -2
- package/lib/form/Filter/layout.scss +1 -1
- package/lib/form/ProForm/addCascadeEffect.d.ts +2 -0
- package/lib/form/ProForm/addCascadeEffect.js +235 -0
- package/lib/form/ProForm/index.js +9 -5
- package/lib/form/typing.d.ts +20 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -1
- package/lib/sidebar/components/sidebar-container/index.js +18 -2
- package/lib/sidebar/components/sidebar-container/index.scss +21 -14
- package/lib/sidebar/components/tree/index.js +24 -6
- package/lib/sidebar/components/tree-node/index.js +1 -1
- package/lib/sidebar/typing.d.ts +4 -0
- package/lib/table/components/ToolBar/DensityIcon.js +1 -0
- package/lib/table/components/ToolBar/FilterColumnIcon.js +2 -0
- package/lib/table/components/ToolBar/FullScreenIcon.js +9 -63
- package/lib/table/components/ToolBar/index.d.ts +1 -1
- package/lib/table/components/ToolBar/index.js +109 -16
- package/lib/table/components/ToolBar/index.scss +22 -2
- package/lib/table/index.js +6 -3
- package/lib/table/typing.d.ts +4 -1
- package/package.json +1 -1
@@ -4,12 +4,28 @@ 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
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
8
|
+
|
9
|
+
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."); }
|
10
|
+
|
11
|
+
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); }
|
12
|
+
|
13
|
+
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
|
+
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; }
|
16
|
+
|
17
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
18
|
+
|
7
19
|
import { usePrefixCls } from '@teamix/utils';
|
8
|
-
import React from 'react';
|
20
|
+
import React, { useEffect, useRef } from 'react';
|
21
|
+
import { Button, Balloon } from '@alicloudfe/components';
|
22
|
+
import TeamixIcon from '@teamix/icon';
|
9
23
|
import FullScreenIcon from './FullScreenIcon';
|
10
24
|
import FilterColumnIcon from './FilterColumnIcon';
|
11
25
|
import DensityIcon from './DensityIcon';
|
12
26
|
import RefreshIcon from './RefreshIcon';
|
27
|
+
import { useSize, useSafeState } from '@teamix/hooks';
|
28
|
+
import debounce from 'lodash.debounce';
|
13
29
|
import './index.scss';
|
14
30
|
var cls = usePrefixCls('teamix-pro-table-toolbar');
|
15
31
|
var presetToolBarMap = {
|
@@ -38,7 +54,46 @@ var presetToolBar = [{
|
|
38
54
|
}];
|
39
55
|
|
40
56
|
var ToolBar = function ToolBar(props) {
|
41
|
-
var
|
57
|
+
var _toolBarRef$current, _toolBarRef$current$p, _toolBarRef$current$p2;
|
58
|
+
|
59
|
+
var toolBar = props.toolBar,
|
60
|
+
fullScreenState = props.fullScreenState;
|
61
|
+
var toolBarRef = useRef(null); // const toolBarSize = useSize(toolBarRef);
|
62
|
+
// 用于获取内容宽度
|
63
|
+
|
64
|
+
var toolBarContentRef = useRef(null); // '.teamix-pro-form-query-filter-layout-inline' 元素
|
65
|
+
|
66
|
+
var layoutInlineDom = (_toolBarRef$current = toolBarRef.current) === null || _toolBarRef$current === void 0 ? void 0 : (_toolBarRef$current$p = _toolBarRef$current.parentElement) === null || _toolBarRef$current$p === void 0 ? void 0 : (_toolBarRef$current$p2 = _toolBarRef$current$p.parentElement) === null || _toolBarRef$current$p2 === void 0 ? void 0 : _toolBarRef$current$p2.parentElement; // 监听它的尺寸变化
|
67
|
+
|
68
|
+
var layoutInlineSize = useSize(layoutInlineDom); // '.teamix-pro-form-query-filter-layout-left' 元素
|
69
|
+
|
70
|
+
var layoutLeftDom = layoutInlineDom === null || layoutInlineDom === void 0 ? void 0 : layoutInlineDom.firstElementChild;
|
71
|
+
var leftWidth = layoutLeftDom === null || layoutLeftDom === void 0 ? void 0 : layoutLeftDom.clientWidth; // 展示形式,是否平铺
|
72
|
+
|
73
|
+
var _useSafeState = useSafeState(),
|
74
|
+
_useSafeState2 = _slicedToArray(_useSafeState, 2),
|
75
|
+
flat = _useSafeState2[0],
|
76
|
+
setFlat = _useSafeState2[1]; // 监听高度,> 32px则切换形态
|
77
|
+
|
78
|
+
|
79
|
+
useEffect(debounce(function () {
|
80
|
+
// console.log(
|
81
|
+
// layoutInlineSize?.width,
|
82
|
+
// leftWidth,
|
83
|
+
// toolBarContentRef.current?.clientWidth,
|
84
|
+
// );
|
85
|
+
if ((layoutInlineSize === null || layoutInlineSize === void 0 ? void 0 : layoutInlineSize.width) && leftWidth && toolBarContentRef.current) {
|
86
|
+
var _toolBarContentRef$cu;
|
87
|
+
|
88
|
+
var width = layoutInlineSize.width; // console.log('layoutInlineSize-width', width);
|
89
|
+
|
90
|
+
if (width - leftWidth <= ((_toolBarContentRef$cu = toolBarContentRef.current) === null || _toolBarContentRef$cu === void 0 ? void 0 : _toolBarContentRef$cu.clientWidth) + 8) {
|
91
|
+
setFlat(false);
|
92
|
+
} else {
|
93
|
+
setFlat(true);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}, 300));
|
42
97
|
var toolBarList = toolBar !== false ? presetToolBar : [];
|
43
98
|
|
44
99
|
if (Array.isArray(toolBar)) {
|
@@ -59,21 +114,49 @@ var ToolBar = function ToolBar(props) {
|
|
59
114
|
});
|
60
115
|
}
|
61
116
|
|
117
|
+
var renderFlatShape = function renderFlatShape() {
|
118
|
+
return /*#__PURE__*/React.createElement("div", {
|
119
|
+
className: cls('content')
|
120
|
+
}, toolBarList.map(function (_ref) {
|
121
|
+
var type = _ref.type,
|
122
|
+
name = _ref.name,
|
123
|
+
Component = _ref.component;
|
124
|
+
return /*#__PURE__*/React.createElement("span", {
|
125
|
+
className: cls('item', _defineProperty({}, name, true)),
|
126
|
+
key: name
|
127
|
+
}, type === 'preset' && /*#__PURE__*/React.createElement(Component, _objectSpread({}, props)), type === 'custom' && /*#__PURE__*/React.createElement("div", {
|
128
|
+
className: cls({
|
129
|
+
custom: true
|
130
|
+
})
|
131
|
+
}, Component));
|
132
|
+
}));
|
133
|
+
};
|
134
|
+
|
135
|
+
var renderUnFlatShape = function renderUnFlatShape() {
|
136
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Balloon.Tooltip, {
|
137
|
+
triggerType: ['click'],
|
138
|
+
popupProps: {
|
139
|
+
cache: true
|
140
|
+
},
|
141
|
+
style: {
|
142
|
+
padding: 8
|
143
|
+
},
|
144
|
+
trigger: /*#__PURE__*/React.createElement(Button, null, /*#__PURE__*/React.createElement(TeamixIcon, {
|
145
|
+
type: "more-line"
|
146
|
+
})),
|
147
|
+
align: "tr"
|
148
|
+
}, renderFlatShape()));
|
149
|
+
};
|
150
|
+
|
62
151
|
return /*#__PURE__*/React.createElement("div", {
|
63
|
-
className: cls(
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
}, type === 'preset' && /*#__PURE__*/React.createElement(Component, _objectSpread({}, props)), type === 'custom' && /*#__PURE__*/React.createElement("div", {
|
72
|
-
className: cls({
|
73
|
-
custom: true
|
74
|
-
})
|
75
|
-
}, Component));
|
76
|
-
}));
|
152
|
+
className: cls('', {
|
153
|
+
flat: flat
|
154
|
+
}),
|
155
|
+
ref: toolBarRef
|
156
|
+
}, !flat && !fullScreenState ? renderUnFlatShape() : renderFlatShape(), /*#__PURE__*/React.createElement("div", {
|
157
|
+
className: cls('shadow'),
|
158
|
+
ref: toolBarContentRef
|
159
|
+
}, renderFlatShape()));
|
77
160
|
};
|
78
161
|
|
79
162
|
export default ToolBar;
|
@@ -2,20 +2,40 @@
|
|
2
2
|
width: 100%;
|
3
3
|
text-align: right;
|
4
4
|
margin-bottom: 8px;
|
5
|
+
&-flat {
|
6
|
+
margin-left: 8px;
|
7
|
+
}
|
8
|
+
&-item {
|
9
|
+
display: inline-block;
|
10
|
+
&:not(:first-child) {
|
11
|
+
margin-left: 8px;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
&-content {
|
15
|
+
display: flex;
|
16
|
+
}
|
17
|
+
&-shadow {
|
18
|
+
visibility: hidden;
|
19
|
+
pointer-events: none;
|
20
|
+
opacity: 0;
|
21
|
+
height: 0px;
|
22
|
+
position: absolute;
|
23
|
+
z-index: -1;
|
24
|
+
overflow: hidden;
|
25
|
+
}
|
5
26
|
}
|
6
27
|
.teamix-pro-table-toolbar-custom {
|
7
28
|
display: inline-block;
|
8
|
-
margin-left: 8px;
|
9
29
|
}
|
10
30
|
|
11
31
|
// FullScreen
|
12
32
|
.teamix-pro-table-toolbar-icon {
|
13
|
-
margin-left: 8px;
|
14
33
|
i {
|
15
34
|
color: var(--color-fill1-6, #848484);
|
16
35
|
}
|
17
36
|
}
|
18
37
|
|
38
|
+
|
19
39
|
// FilterColumn
|
20
40
|
.teamix-pro-table-toolbar-filter-column {
|
21
41
|
min-width: 180px;
|
package/es/table/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "afterDataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestWhenMount", "showPagination", "pageSizeList", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "customRequest", "filterColumnType", "defaultFilterParams", "reserveSelectedRecords", "size", "disableSelectAll", "context", "fixedTableBody", "isTree"];
|
1
|
+
var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "afterDataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestConfig", "requestWhenMount", "showPagination", "pageSizeList", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "customRequest", "filterColumnType", "defaultFilterParams", "reserveSelectedRecords", "size", "disableSelectAll", "context", "fixedTableBody", "isTree"];
|
2
2
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
4
4
|
|
@@ -142,6 +142,7 @@ var ProTable = function ProTable(props) {
|
|
142
142
|
return params;
|
143
143
|
} : _props$formatParams,
|
144
144
|
formatResult = props.formatResult,
|
145
|
+
requestConfig = props.requestConfig,
|
145
146
|
_props$requestWhenMou = props.requestWhenMount,
|
146
147
|
requestWhenMount = _props$requestWhenMou === void 0 ? true : _props$requestWhenMou,
|
147
148
|
_props$showPagination = props.showPagination,
|
@@ -682,7 +683,8 @@ var ProTable = function ProTable(props) {
|
|
682
683
|
}, {
|
683
684
|
// 使用 request 方法代替 fetch
|
684
685
|
requestMethod: function requestMethod(params) {
|
685
|
-
|
686
|
+
// 支持使用 requestConfig 自定义请求配置
|
687
|
+
return utilResquest(_objectSpread(_objectSpread({}, params), requestConfig));
|
686
688
|
},
|
687
689
|
manual: true,
|
688
690
|
onSuccess: function onSuccess(result) {
|
@@ -904,7 +906,8 @@ var ProTable = function ProTable(props) {
|
|
904
906
|
afterDataFilter: afterDataFilter,
|
905
907
|
dataFilterFormRef: isFullScreen ? fullscreenDataFilterFormRef : normalDataFilterFormRef,
|
906
908
|
rowSelection: rowSelection,
|
907
|
-
filterColumnType: filterColumnType
|
909
|
+
filterColumnType: filterColumnType,
|
910
|
+
fullScreenState: isFullScreen
|
908
911
|
}), /*#__PURE__*/React.createElement(Table.StickyLock, _objectSpread({
|
909
912
|
hasBorder: false,
|
910
913
|
dataSource: showSkeleton ? skeletonDataSource : data || props.dataSource,
|
package/es/table/typing.d.ts
CHANGED
@@ -7,7 +7,7 @@ import { QueryFilterProps, ProFormType } from '../form';
|
|
7
7
|
import { ProActionGroupProps, ProActionButtonProps } from '../actions';
|
8
8
|
import { PaginationProps } from '@alicloudfe/components/types/pagination';
|
9
9
|
import { HeaderProps as ProTableHeaderProps } from '../field';
|
10
|
-
import { Method } from 'axios';
|
10
|
+
import { Method, AxiosRequestConfig } from 'axios';
|
11
11
|
import React from 'react';
|
12
12
|
declare type IFieldRenderProps = keyof ProFieldRenderProps;
|
13
13
|
/** 列record函数 */
|
@@ -86,6 +86,8 @@ export declare type ProTableProps = {
|
|
86
86
|
onSuccess?: (res: any) => void;
|
87
87
|
/** 内部请求失败时的回调 */
|
88
88
|
onError?: (error: Error) => void;
|
89
|
+
/** 自定义的请求配置 */
|
90
|
+
requestConfig?: AxiosRequestConfig;
|
89
91
|
/** 翻页页数的请求参数名 */
|
90
92
|
pageKey?: string;
|
91
93
|
/** 翻页器页数对应字段 */
|
@@ -274,6 +276,7 @@ export declare type ProTableLayoutProps = {
|
|
274
276
|
actionRef: React.MutableRefObject<ProTableActionType | undefined>;
|
275
277
|
columns?: ProTableColumnProps[];
|
276
278
|
rowSelection?: innerRowSelectionType | rowSelectionType;
|
279
|
+
fullScreenState?: boolean;
|
277
280
|
} & ProTableTopAreaProps;
|
278
281
|
/** columns 列过滤 */
|
279
282
|
export declare type ProTableColumnsFilterItemProps = {
|
package/lib/card/index.js
CHANGED
@@ -271,9 +271,9 @@ var ProCard = function ProCard(props) {
|
|
271
271
|
});
|
272
272
|
var width = widthList.reduce(function (acc, cur) {
|
273
273
|
return acc + cur;
|
274
|
-
}, 0) + widthList.length * 8; // 无法取出精准宽度,减去1作为阈值
|
274
|
+
}, 0) + widthList.length * 8; // 无法取出精准宽度,减去1作为阈值 10为右padding
|
275
275
|
|
276
|
-
setHeaderWithoutTitleWidth(width - 1);
|
276
|
+
setHeaderWithoutTitleWidth(width - 1 + 10);
|
277
277
|
}
|
278
278
|
};
|
279
279
|
|
@@ -0,0 +1,235 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _core = require("@formily/core");
|
9
|
+
|
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; }
|
11
|
+
|
12
|
+
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; }
|
13
|
+
|
14
|
+
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; }
|
15
|
+
|
16
|
+
var OP_MAPS = {
|
17
|
+
'*': function _() {
|
18
|
+
return true;
|
19
|
+
},
|
20
|
+
'=': function _(l, r) {
|
21
|
+
return l === r;
|
22
|
+
},
|
23
|
+
'==': function _(l, r) {
|
24
|
+
return l === r;
|
25
|
+
},
|
26
|
+
'!': function _(l, r) {
|
27
|
+
return l !== r;
|
28
|
+
},
|
29
|
+
'!=': function _(l, r) {
|
30
|
+
return l != r;
|
31
|
+
},
|
32
|
+
'>': function _(l, r) {
|
33
|
+
return l > r;
|
34
|
+
},
|
35
|
+
'<': function _(l, r) {
|
36
|
+
return l < r;
|
37
|
+
},
|
38
|
+
'>=': function _(l, r) {
|
39
|
+
return l >= r;
|
40
|
+
},
|
41
|
+
'<=': function _(l, r) {
|
42
|
+
return l <= r;
|
43
|
+
},
|
44
|
+
ied: function ied(l, r) {
|
45
|
+
if (Array.isArray(l) || typeof l === 'string' && r) {
|
46
|
+
return l.includes(r);
|
47
|
+
} else {
|
48
|
+
return false;
|
49
|
+
}
|
50
|
+
},
|
51
|
+
eed: function eed(l, r) {
|
52
|
+
if (Array.isArray(l) || typeof l === 'string' && r) {
|
53
|
+
return !l.includes(r);
|
54
|
+
} else {
|
55
|
+
return true;
|
56
|
+
}
|
57
|
+
},
|
58
|
+
i: function i(l, r) {
|
59
|
+
if (Array.isArray(r) || typeof r === 'string' && l) {
|
60
|
+
return r.includes(l);
|
61
|
+
} else {
|
62
|
+
return false;
|
63
|
+
}
|
64
|
+
},
|
65
|
+
e: function e(l, r) {
|
66
|
+
if (Array.isArray(r) || typeof r === 'string' && l) {
|
67
|
+
return !r.includes(l);
|
68
|
+
} else {
|
69
|
+
return true;
|
70
|
+
}
|
71
|
+
},
|
72
|
+
isEmpty: function isEmpty(l, r) {
|
73
|
+
return l === null || l === undefined || l === '' || Array.isArray(l) && l.length === 0;
|
74
|
+
},
|
75
|
+
notEmpty: function notEmpty(l, r) {
|
76
|
+
return l !== null && l !== undefined && l !== '' && (!Array.isArray(l) || l.length !== 0);
|
77
|
+
}
|
78
|
+
};
|
79
|
+
|
80
|
+
var getParsedValue = function getParsedValue(value, scope) {
|
81
|
+
if (typeof value === 'string' && value.startsWith('${') && value.endsWith('}')) {
|
82
|
+
return scope.$form.getValuesIn(value.slice(2, value.length - 1));
|
83
|
+
} else if (typeof value === 'string' && value.startsWith('{{') && value.endsWith('}}')) {
|
84
|
+
var code = value.slice(2, value.length - 2);
|
85
|
+
|
86
|
+
try {
|
87
|
+
return new Function("with(this){ return ".concat(code, " }")).call(scope);
|
88
|
+
} catch (e) {
|
89
|
+
return undefined;
|
90
|
+
}
|
91
|
+
} else {
|
92
|
+
return value;
|
93
|
+
}
|
94
|
+
};
|
95
|
+
|
96
|
+
var bingo = function bingo(bingoItem, scope) {
|
97
|
+
var _bingoItem$when = bingoItem.when,
|
98
|
+
when = _bingoItem$when === void 0 ? [] : _bingoItem$when,
|
99
|
+
_bingoItem$logic = bingoItem.logic,
|
100
|
+
logic = _bingoItem$logic === void 0 ? '&&' : _bingoItem$logic;
|
101
|
+
var result = logic === '&&';
|
102
|
+
when.forEach(function (_ref) {
|
103
|
+
var left = _ref.left,
|
104
|
+
op = _ref.op,
|
105
|
+
right = _ref.right;
|
106
|
+
var leftValue = scope.$form.getValuesIn(left);
|
107
|
+
var rightValue = getParsedValue(right, scope);
|
108
|
+
var itemResult = OP_MAPS[op](leftValue, rightValue);
|
109
|
+
|
110
|
+
if (logic === '&&') {
|
111
|
+
result = result && itemResult;
|
112
|
+
} else {
|
113
|
+
result = result || itemResult;
|
114
|
+
}
|
115
|
+
});
|
116
|
+
return result;
|
117
|
+
};
|
118
|
+
|
119
|
+
var loopAddFieldEffect = function loopAddFieldEffect(schema, form, scope) {
|
120
|
+
if (Array.isArray(schema)) {
|
121
|
+
schema === null || schema === void 0 ? void 0 : schema.forEach(function (item) {
|
122
|
+
if (item.name) {
|
123
|
+
var _item$cascade, _item$onChange;
|
124
|
+
|
125
|
+
(_item$cascade = item.cascade) === null || _item$cascade === void 0 ? void 0 : _item$cascade.forEach(function (cascade) {
|
126
|
+
(0, _core.onFieldReact)(item.name, function (field) {
|
127
|
+
var contextScope = _objectSpread(_objectSpread({}, scope), {}, {
|
128
|
+
$form: form,
|
129
|
+
$self: field,
|
130
|
+
$values: form.values
|
131
|
+
});
|
132
|
+
|
133
|
+
var _cascade$state = cascade.state,
|
134
|
+
state = _cascade$state === void 0 ? {} : _cascade$state,
|
135
|
+
_cascade$props = cascade.props,
|
136
|
+
props = _cascade$props === void 0 ? {} : _cascade$props,
|
137
|
+
dataSourceFilter = cascade.dataSourceFilter,
|
138
|
+
dataSourceHide = cascade.dataSourceHide;
|
139
|
+
|
140
|
+
if (bingo(cascade, contextScope)) {
|
141
|
+
if (dataSourceFilter || dataSourceHide) {
|
142
|
+
var sourceDataSource = field.getState()._sourceDataSource;
|
143
|
+
|
144
|
+
if (!sourceDataSource) {
|
145
|
+
var dataSource = field.getState().dataSource;
|
146
|
+
field.setState({
|
147
|
+
_sourceDataSource: dataSource
|
148
|
+
});
|
149
|
+
sourceDataSource = dataSource;
|
150
|
+
}
|
151
|
+
|
152
|
+
if (sourceDataSource) {
|
153
|
+
var nextDataSource = sourceDataSource.filter(function (item) {
|
154
|
+
if (Array.isArray(dataSourceFilter)) {
|
155
|
+
return dataSourceFilter.includes(item.value);
|
156
|
+
}
|
157
|
+
|
158
|
+
if (Array.isArray(dataSourceHide)) {
|
159
|
+
return !dataSourceFilter.includes(item.value);
|
160
|
+
}
|
161
|
+
});
|
162
|
+
field.setDataSource(nextDataSource);
|
163
|
+
var value = field.getState().value;
|
164
|
+
|
165
|
+
if (!nextDataSource.some(function (item) {
|
166
|
+
return item.value === value;
|
167
|
+
})) {
|
168
|
+
field.setValue(undefined);
|
169
|
+
}
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
var nextState = {};
|
174
|
+
Object.keys(state).forEach(function (stateKey) {
|
175
|
+
nextState[stateKey] = getParsedValue(state[stateKey], contextScope);
|
176
|
+
});
|
177
|
+
field.setState(nextState);
|
178
|
+
var nextProps = {};
|
179
|
+
Object.keys(props).forEach(function (propsKey) {
|
180
|
+
nextProps[propsKey] = getParsedValue(props[propsKey], contextScope);
|
181
|
+
});
|
182
|
+
field.setComponentProps(nextProps);
|
183
|
+
} else {
|
184
|
+
var formState = form.getState();
|
185
|
+
|
186
|
+
if (dataSourceFilter || dataSourceHide) {
|
187
|
+
var _sourceDataSource = field.getState()._sourceDataSource;
|
188
|
+
|
189
|
+
_sourceDataSource && field.setDataSource(_sourceDataSource);
|
190
|
+
}
|
191
|
+
|
192
|
+
var _nextState = {};
|
193
|
+
Object.keys(state).forEach(function (stateKey) {
|
194
|
+
_nextState[stateKey] = stateKey in item ? item[stateKey] : formState[stateKey];
|
195
|
+
});
|
196
|
+
field.setState(_nextState);
|
197
|
+
var _nextProps = {};
|
198
|
+
Object.keys(props).forEach(function (propsKey) {
|
199
|
+
_nextProps[propsKey] = item.props ? item.props[propsKey] : undefined;
|
200
|
+
});
|
201
|
+
field.setComponentProps(_nextProps);
|
202
|
+
}
|
203
|
+
});
|
204
|
+
});
|
205
|
+
(_item$onChange = item.onChange) === null || _item$onChange === void 0 ? void 0 : _item$onChange.forEach(function (onChange) {
|
206
|
+
(0, _core.onFieldValueChange)(item.name, function (field) {
|
207
|
+
var contextScope = _objectSpread(_objectSpread({}, scope), {}, {
|
208
|
+
$form: form,
|
209
|
+
$self: field,
|
210
|
+
$values: form.values
|
211
|
+
});
|
212
|
+
|
213
|
+
var values = onChange.values;
|
214
|
+
|
215
|
+
if (bingo(onChange, contextScope)) {
|
216
|
+
Object.keys(values).forEach(function (valuesKey) {
|
217
|
+
form.setValuesIn(valuesKey, getParsedValue(values[valuesKey], contextScope));
|
218
|
+
});
|
219
|
+
}
|
220
|
+
});
|
221
|
+
});
|
222
|
+
} else if (item.children) {
|
223
|
+
loopAddFieldEffect(item.children, form, scope);
|
224
|
+
}
|
225
|
+
});
|
226
|
+
}
|
227
|
+
};
|
228
|
+
|
229
|
+
var _default = function _default(form, schema, scope) {
|
230
|
+
form.addEffects('cascade', function () {
|
231
|
+
loopAddFieldEffect(schema, form, scope);
|
232
|
+
});
|
233
|
+
};
|
234
|
+
|
235
|
+
exports.default = _default;
|
@@ -21,6 +21,8 @@ var _components = require("@alicloudfe/components");
|
|
21
21
|
|
22
22
|
var _ProField = _interopRequireDefault(require("../Components/ProField"));
|
23
23
|
|
24
|
+
var _addCascadeEffect = _interopRequireDefault(require("./addCascadeEffect"));
|
25
|
+
|
24
26
|
var _Editable = require("../Components/Editable");
|
25
27
|
|
26
28
|
var _FormGroup = _interopRequireDefault(require("../Components/FormGroup"));
|
@@ -112,17 +114,19 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
112
114
|
globalComponents = _ref2.components,
|
113
115
|
globalScope = _ref2.scope;
|
114
116
|
|
117
|
+
var mergedScope = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, context), globalScope), scope), {}, {
|
118
|
+
context: context
|
119
|
+
});
|
120
|
+
|
115
121
|
var form = (0, _react.useMemo)(function () {
|
116
|
-
|
122
|
+
var nextForm = outerForm || (0, _core.createForm)({
|
117
123
|
validateFirst: validateFirst
|
118
124
|
});
|
125
|
+
(0, _addCascadeEffect.default)(nextForm, schema, mergedScope);
|
126
|
+
return nextForm;
|
119
127
|
}, [outerForm]);
|
120
128
|
var prefixCls = (0, _utils.usePrefixCls)('teamix-pro-form'); // 由于Actions需要,解构context供使用。原context键名的上下文继续保留。
|
121
129
|
|
122
|
-
var mergedScope = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, context), globalScope), scope), {}, {
|
123
|
-
context: context
|
124
|
-
});
|
125
|
-
|
126
130
|
var mergedComponents = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, globalComponents), components), formilyComponents), _ProField.default);
|
127
131
|
|
128
132
|
var onAutoSubmit = (0, _useAutoSubmit.default)(onSubmit, context);
|
package/lib/form/typing.d.ts
CHANGED
@@ -34,6 +34,24 @@ export interface ProFormRequestConfig extends Omit<ProFormCommonRequestConfig, '
|
|
34
34
|
extraConfig?: AnyObject;
|
35
35
|
onComplete?: (res?: any, field?: any, context?: any) => any;
|
36
36
|
}
|
37
|
+
export interface CascadeWhen {
|
38
|
+
left: string;
|
39
|
+
op: string;
|
40
|
+
right: any;
|
41
|
+
}
|
42
|
+
export interface Cascade {
|
43
|
+
when: CascadeWhen[];
|
44
|
+
logic?: '||' | '&&';
|
45
|
+
props?: any;
|
46
|
+
state?: any;
|
47
|
+
dataSourceFilter?: any[];
|
48
|
+
dataSourceHide?: any[];
|
49
|
+
}
|
50
|
+
export interface OnChange {
|
51
|
+
when: CascadeWhen[];
|
52
|
+
logic?: '||' | '&&';
|
53
|
+
values: any;
|
54
|
+
}
|
37
55
|
export interface ProFormSchemaItem {
|
38
56
|
type?: string;
|
39
57
|
name?: string;
|
@@ -61,6 +79,8 @@ export interface ProFormSchemaItem {
|
|
61
79
|
default?: any;
|
62
80
|
request?: ProFormRequestConfig | ProFormRequestConfig[];
|
63
81
|
data?: AnyObject;
|
82
|
+
cascade?: Cascade[];
|
83
|
+
onChange?: OnChange[];
|
64
84
|
}
|
65
85
|
export declare type ProFormSchema = ProFormSchemaItem[];
|
66
86
|
interface AutoLayout {
|
package/lib/index.d.ts
CHANGED
@@ -28,5 +28,5 @@ export * from './table';
|
|
28
28
|
export * from './sidebar';
|
29
29
|
export * from './utils';
|
30
30
|
export * from './timeline';
|
31
|
-
declare const version = "1.5.0
|
31
|
+
declare const version = "1.5.0";
|
32
32
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, TeamixIcon, hooks, nocode, templates, utils, };
|
package/lib/index.js
CHANGED
@@ -313,9 +313,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
313
313
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
314
314
|
|
315
315
|
// 设置图标源
|
316
|
+
// @ts-ignore
|
316
317
|
if (!((_window = window) === null || _window === void 0 ? void 0 : _window.TEAMIXPRO_WITHOUT_ICON)) {
|
317
318
|
_icon.default.setConfig(_utils.default.getTeamixIconConfig());
|
318
319
|
}
|
319
320
|
|
320
|
-
var version = '1.5.0
|
321
|
+
var version = '1.5.0';
|
321
322
|
exports.version = version;
|
@@ -21,7 +21,7 @@ require("./index.scss");
|
|
21
21
|
|
22
22
|
var _icon = _interopRequireDefault(require("@teamix/icon"));
|
23
23
|
|
24
|
-
var _excluded = ["children", "searchPlaceholder", "showSearch", "searchProps", "customSearch", "searchOnChange", "message", "messageProps", "customMessage", "scrollArea", "showExpandAll", "showExpandLevel", "onExpandAllChange", "onExpandLevelChange", "expandLevel", "isTree"];
|
24
|
+
var _excluded = ["children", "searchPlaceholder", "showSearch", "searchProps", "customSearch", "searchOnChange", "message", "messageProps", "customMessage", "scrollArea", "showExpandAll", "showExpandLevel", "onExpandAllChange", "onExpandLevelChange", "expandLevel", "expandLevelState", "expandAllState", "isTree"];
|
25
25
|
|
26
26
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
27
27
|
|
@@ -81,6 +81,10 @@ var ProSidebarContainer = function ProSidebarContainer(props) {
|
|
81
81
|
onExpandLevelChange = props.onExpandLevelChange,
|
82
82
|
_props$expandLevel = props.expandLevel,
|
83
83
|
expandLevel = _props$expandLevel === void 0 ? 1 : _props$expandLevel,
|
84
|
+
_props$expandLevelSta = props.expandLevelState,
|
85
|
+
expandLevelStateProp = _props$expandLevelSta === void 0 ? 1 : _props$expandLevelSta,
|
86
|
+
_props$expandAllState = props.expandAllState,
|
87
|
+
expandAllStateProp = _props$expandAllState === void 0 ? false : _props$expandAllState,
|
84
88
|
isTree = props.isTree,
|
85
89
|
others = _objectWithoutProperties(props, _excluded);
|
86
90
|
|
@@ -114,7 +118,19 @@ var ProSidebarContainer = function ProSidebarContainer(props) {
|
|
114
118
|
setTreeHeight("calc(100% - ".concat(remainHeight, "px + 16px)"));
|
115
119
|
}
|
116
120
|
}
|
117
|
-
}, []);
|
121
|
+
}, []);
|
122
|
+
(0, _react.useEffect)(function () {
|
123
|
+
setExpandLevelState(expandLevelStateProp);
|
124
|
+
setTimeout(function () {
|
125
|
+
onExpandLevelChange === null || onExpandLevelChange === void 0 ? void 0 : onExpandLevelChange(expandLevelStateProp);
|
126
|
+
});
|
127
|
+
}, [expandLevelStateProp]);
|
128
|
+
(0, _react.useEffect)(function () {
|
129
|
+
setExpandAllState(expandAllStateProp);
|
130
|
+
setTimeout(function () {
|
131
|
+
onExpandAllChange === null || onExpandAllChange === void 0 ? void 0 : onExpandAllChange(expandAllStateProp);
|
132
|
+
});
|
133
|
+
}, [expandAllStateProp]); // 渲染搜索区域
|
118
134
|
|
119
135
|
var renderSearch = function renderSearch() {
|
120
136
|
if (customSearch || showSearch) {
|