@teamix/pro 1.4.25 → 1.4.27

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.
Files changed (52) hide show
  1. package/dist/pro.css +1 -1
  2. package/dist/pro.js +45535 -35222
  3. package/dist/pro.min.css +1 -1
  4. package/dist/pro.min.js +1 -1
  5. package/dist/pro.min.js.LICENSE.txt +11 -0
  6. package/es/card/index.js +2 -2
  7. package/es/form/Filter/layout.scss +1 -1
  8. package/es/form/ProForm/addCascadeEffect.d.ts +2 -0
  9. package/es/form/ProForm/addCascadeEffect.js +225 -0
  10. package/es/form/ProForm/index.js +8 -5
  11. package/es/form/typing.d.ts +20 -0
  12. package/es/index.d.ts +1 -1
  13. package/es/index.js +2 -1
  14. package/es/sidebar/components/sidebar-container/index.js +18 -2
  15. package/es/sidebar/components/sidebar-container/index.scss +21 -14
  16. package/es/sidebar/components/tree/index.js +24 -6
  17. package/es/sidebar/components/tree-node/index.js +1 -1
  18. package/es/sidebar/components/tree-node/index.scss +6 -0
  19. package/es/sidebar/typing.d.ts +4 -0
  20. package/es/table/components/Layout/index.scss +1 -1
  21. package/es/table/components/ToolBar/DensityIcon.js +1 -0
  22. package/es/table/components/ToolBar/FilterColumnIcon.js +2 -0
  23. package/es/table/components/ToolBar/FullScreenIcon.js +6 -57
  24. package/es/table/components/ToolBar/index.d.ts +1 -1
  25. package/es/table/components/ToolBar/index.js +99 -16
  26. package/es/table/components/ToolBar/index.scss +22 -2
  27. package/es/table/index.js +6 -3
  28. package/es/table/typing.d.ts +4 -1
  29. package/lib/card/index.js +2 -2
  30. package/lib/form/Filter/layout.scss +1 -1
  31. package/lib/form/ProForm/addCascadeEffect.d.ts +2 -0
  32. package/lib/form/ProForm/addCascadeEffect.js +235 -0
  33. package/lib/form/ProForm/index.js +9 -5
  34. package/lib/form/typing.d.ts +20 -0
  35. package/lib/index.d.ts +1 -1
  36. package/lib/index.js +2 -1
  37. package/lib/sidebar/components/sidebar-container/index.js +18 -2
  38. package/lib/sidebar/components/sidebar-container/index.scss +21 -14
  39. package/lib/sidebar/components/tree/index.js +24 -6
  40. package/lib/sidebar/components/tree-node/index.js +1 -1
  41. package/lib/sidebar/components/tree-node/index.scss +6 -0
  42. package/lib/sidebar/typing.d.ts +4 -0
  43. package/lib/table/components/Layout/index.scss +1 -1
  44. package/lib/table/components/ToolBar/DensityIcon.js +1 -0
  45. package/lib/table/components/ToolBar/FilterColumnIcon.js +2 -0
  46. package/lib/table/components/ToolBar/FullScreenIcon.js +9 -63
  47. package/lib/table/components/ToolBar/index.d.ts +1 -1
  48. package/lib/table/components/ToolBar/index.js +109 -16
  49. package/lib/table/components/ToolBar/index.scss +22 -2
  50. package/lib/table/index.js +6 -3
  51. package/lib/table/typing.d.ts +4 -1
  52. package/package.json +1 -1
@@ -1,35 +1,16 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
-
3
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
-
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
-
9
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
-
11
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
-
13
1
  /**
14
2
  * 全屏展示 Icon
15
3
  */
16
4
  import { Button } from '@alicloudfe/components';
17
5
  import TeamixIcon from '@teamix/icon';
18
6
  import { usePrefixCls } from '@teamix/utils';
19
- import React, { useEffect, useState } from 'react';
7
+ import React from 'react';
20
8
  import './index.scss';
21
9
  var cls = usePrefixCls('teamix-pro-table-toolbar-icon');
22
10
 
23
11
  var FullScreenIcon = function FullScreenIcon(props) {
24
- var _actionRef$current3, _actionRef$current3$o;
25
-
26
- var actionRef = props.actionRef;
27
-
28
- var _useState = useState(false),
29
- _useState2 = _slicedToArray(_useState, 2),
30
- fullscreen = _useState2[0],
31
- setFullscreen = _useState2[1]; // 点击全屏
32
-
12
+ var actionRef = props.actionRef,
13
+ fullScreenState = props.fullScreenState; // 点击全屏
33
14
 
34
15
  var allScreenHandle = function allScreenHandle() {
35
16
  setTimeout(function () {
@@ -37,48 +18,16 @@ var FullScreenIcon = function FullScreenIcon(props) {
37
18
 
38
19
  (_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$fu = _actionRef$current.fullScreen) === null || _actionRef$current$fu === void 0 ? void 0 : _actionRef$current$fu.call(_actionRef$current);
39
20
  }, 0);
40
- }; // 销毁监听函数
41
-
42
-
43
- useEffect(function () {
44
- return function () {
45
- var _actionRef$current2, _actionRef$current2$o;
46
-
47
- (_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$o = _actionRef$current2.off) === null || _actionRef$current2$o === void 0 ? void 0 : _actionRef$current2$o.call(_actionRef$current2, 'fullscreenIcon');
48
- };
49
- }, []); // 监听全屏变化
21
+ };
50
22
 
51
- (_actionRef$current3 = actionRef.current) === null || _actionRef$current3 === void 0 ? void 0 : (_actionRef$current3$o = _actionRef$current3.on) === null || _actionRef$current3$o === void 0 ? void 0 : _actionRef$current3$o.call(_actionRef$current3, function (state) {
52
- // console.log('dataFilterForm', actionRef.current?.dataFilterForm);
53
- setFullscreen(state); // actionRef.current?.dataFilterForm?.setValues(formValues);
54
- }, 'fullScreenState', 'fullscreenIcon');
55
23
  return /*#__PURE__*/React.createElement(Button, {
56
24
  iconSize: "small",
57
25
  className: cls(),
58
26
  onClick: allScreenHandle
59
27
  }, /*#__PURE__*/React.createElement(TeamixIcon, {
60
28
  size: "small",
61
- type: fullscreen ? 'close-line' : 'full-screen-line'
62
- })) // <Balloon.Tooltip
63
- // trigger={
64
- // <Button iconSize="small" className={cls()} onClick={allScreenHandle}>
65
- // <TeamixIcon
66
- // size="small"
67
- // type={fullscreen ? 'close-line' : 'full-screen-line'}
68
- // />
69
- // </Button>
70
- // }
71
- // align={fullscreen ? 'b' : 't'}
72
- // popupProps={{
73
- // visible: visible,
74
- // onVisibleChange: (state) => {
75
- // setVisible(state);
76
- // },
77
- // }}
78
- // >
79
- // {getMessage('fullScreen')}
80
- // </Balloon.Tooltip>
81
- ;
29
+ type: fullScreenState ? 'close-line' : 'full-screen-line'
30
+ }));
82
31
  };
83
32
 
84
33
  export default FullScreenIcon;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import './index.scss';
3
2
  import { ProTableLayoutProps } from '../../typing';
3
+ import './index.scss';
4
4
  declare const ToolBar: React.FC<ProTableLayoutProps>;
5
5
  export default ToolBar;
@@ -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 toolBar = props.toolBar;
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
- }, toolBarList.map(function (_ref) {
65
- var type = _ref.type,
66
- name = _ref.name,
67
- Component = _ref.component;
68
- return /*#__PURE__*/React.createElement("span", {
69
- className: cls(_defineProperty({}, name, true)),
70
- key: name
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
- return utilResquest(params);
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,
@@ -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
 
@@ -26,7 +26,7 @@ $query-filter-layout: #{$teamix-pro-form}-query-filter-layout;
26
26
  margin-bottom: 8px;
27
27
  }
28
28
  .#{$query-filter-layout}-addonAfter {
29
- flex: 0 1 auto;
29
+ flex: 0 0 auto;
30
30
  margin-left: 8px;
31
31
  }
32
32
  .#{$query-filter-layout}-panel {
@@ -0,0 +1,2 @@
1
+ declare const _default: (form: any, schema: any, scope: any) => void;
2
+ export default _default;
@@ -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
- return outerForm || (0, _core.createForm)({
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);