@teamix/pro 1.2.26 → 1.2.30

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 (75) hide show
  1. package/dist/212.js +129 -129
  2. package/dist/pro.css +1 -1
  3. package/dist/pro.js +18415 -16897
  4. package/dist/pro.min.css +1 -1
  5. package/dist/pro.min.js +1 -1
  6. package/dist/pro.min.js.LICENSE.txt +2 -0
  7. package/es/actions/index.d.ts +2 -3
  8. package/es/actions/index.js +15 -19
  9. package/es/form/Filter/AdvancedFilter.js +1 -1
  10. package/es/form/Filter/Layout.d.ts +5 -0
  11. package/es/form/Filter/Layout.js +82 -0
  12. package/es/form/Filter/SimpleFilter.js +30 -6
  13. package/es/form/Filter/index2.d.ts +2 -1
  14. package/es/form/Filter/index2.js +97 -116
  15. package/es/form/Filter/index2.scss +16 -45
  16. package/es/form/Filter/layout.scss +36 -0
  17. package/es/form/Filter/useSpecialProps.d.ts +6 -0
  18. package/es/form/Filter/useSpecialProps.js +37 -0
  19. package/es/form/ProForm/customComponent.d.ts +3 -0
  20. package/es/form/ProForm/customComponent.js +20 -0
  21. package/es/form/ProForm/index.scss +5 -6
  22. package/es/form/ProForm/useFormDisplayValues.js +14 -24
  23. package/es/form/SchemaForm/adapterType.js +1 -0
  24. package/es/form/fieldTypeMap.js +2 -1
  25. package/es/form/index.d.ts +4 -2
  26. package/es/form/index.js +4 -2
  27. package/es/form/typing.d.ts +25 -1
  28. package/es/index.d.ts +1 -1
  29. package/es/index.js +1 -1
  30. package/es/info/index.scss +1 -1
  31. package/es/nocode/pages/renderer.js +1 -1
  32. package/es/table/components/Layout/index.js +74 -163
  33. package/es/table/components/Layout/index.scss +4 -3
  34. package/es/table/components/Pagination/index.js +1 -0
  35. package/es/table/components/ToolBar/FullScreenIcon.js +4 -9
  36. package/es/table/components/ToolBar/Fullscreen.js +21 -11
  37. package/es/table/index.js +84 -102
  38. package/es/table/index.scss +4 -0
  39. package/es/table/typing.d.ts +12 -10
  40. package/es/table/utils/columnRender.js +21 -3
  41. package/lib/actions/index.d.ts +2 -3
  42. package/lib/actions/index.js +15 -19
  43. package/lib/form/Filter/AdvancedFilter.js +1 -1
  44. package/lib/form/Filter/Layout.d.ts +5 -0
  45. package/lib/form/Filter/Layout.js +102 -0
  46. package/lib/form/Filter/SimpleFilter.js +29 -4
  47. package/lib/form/Filter/index2.d.ts +2 -1
  48. package/lib/form/Filter/index2.js +101 -114
  49. package/lib/form/Filter/index2.scss +16 -45
  50. package/lib/form/Filter/layout.scss +36 -0
  51. package/lib/form/Filter/useSpecialProps.d.ts +6 -0
  52. package/lib/form/Filter/useSpecialProps.js +46 -0
  53. package/lib/form/ProForm/customComponent.d.ts +3 -0
  54. package/lib/form/ProForm/customComponent.js +28 -0
  55. package/lib/form/ProForm/index.scss +5 -6
  56. package/lib/form/ProForm/useFormDisplayValues.js +17 -24
  57. package/lib/form/SchemaForm/adapterType.js +1 -0
  58. package/lib/form/fieldTypeMap.js +2 -1
  59. package/lib/form/index.d.ts +4 -2
  60. package/lib/form/index.js +19 -1
  61. package/lib/form/typing.d.ts +25 -1
  62. package/lib/index.d.ts +1 -1
  63. package/lib/index.js +1 -1
  64. package/lib/info/index.scss +1 -1
  65. package/lib/nocode/pages/renderer.js +1 -1
  66. package/lib/table/components/Layout/index.js +72 -163
  67. package/lib/table/components/Layout/index.scss +4 -3
  68. package/lib/table/components/Pagination/index.js +1 -0
  69. package/lib/table/components/ToolBar/FullScreenIcon.js +4 -9
  70. package/lib/table/components/ToolBar/Fullscreen.js +22 -11
  71. package/lib/table/index.js +81 -100
  72. package/lib/table/index.scss +4 -0
  73. package/lib/table/typing.d.ts +12 -10
  74. package/lib/table/utils/columnRender.js +21 -3
  75. package/package.json +4 -4
@@ -24,6 +24,8 @@ object-assign
24
24
  * (c) Sindre Sorhus; MIT License
25
25
  */
26
26
 
27
+ /*! js-cookie v3.0.1 | MIT */
28
+
27
29
  /** @license React v16.13.1
28
30
  * react-is.production.min.js
29
31
  *
@@ -41,6 +41,7 @@ export interface ProActionCommonProps {
41
41
  export interface ProActionMenuButtonProps extends ProActionCommonProps, Omit<MenuButtonProps, 'visible'> {
42
42
  actions: ProActionProps[];
43
43
  icon?: string;
44
+ noArrow?: boolean;
44
45
  }
45
46
  export declare const ProActionMenuButton: (props: ProActionMenuButtonProps) => JSX.Element;
46
47
  export interface ProActionDividerProps extends ProActionCommonProps {
@@ -61,9 +62,7 @@ export declare type ProActionGroupProps = {
61
62
  */
62
63
  moreText?: string;
63
64
  /** 更多按钮的配置,只有在actions数量超过max时才有效 */
64
- more?: string | (ProActionButtonProps & {
65
- noArrow?: boolean;
66
- });
65
+ more?: string | Omit<ProActionMenuButtonProps, 'actions'>;
67
66
  /** 是否有分割线,只有type="text"时生效,默认有分割线 */
68
67
  divider?: boolean;
69
68
  } & React.HTMLAttributes<HTMLElement>;
@@ -1,12 +1,11 @@
1
1
  var _excluded = ["type"],
2
2
  _excluded2 = ["config", "icon", "iconSize", "type", "context", "children", "visible", "onClick"],
3
3
  _excluded3 = ["loading"],
4
- _excluded4 = ["icon", "iconSize", "label", "actions", "children", "context", "type"],
4
+ _excluded4 = ["icon", "iconSize", "label", "actions", "children", "context", "type", "className", "noArrow"],
5
5
  _excluded5 = ["context", "text"],
6
- _excluded6 = ["noArrow", "className"],
7
- _excluded7 = ["key", "actions"],
8
- _excluded8 = ["key", "config"],
9
- _excluded9 = ["type", "divider", "max", "moreText", "more", "context", "actions", "className"];
6
+ _excluded6 = ["key", "actions"],
7
+ _excluded7 = ["key", "config"],
8
+ _excluded8 = ["type", "divider", "max", "moreText", "more", "context", "actions", "className"];
10
9
 
11
10
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
11
 
@@ -243,6 +242,8 @@ export var ProActionMenuButton = function ProActionMenuButton(props) {
243
242
  context = props.context,
244
243
  _props$type2 = props.type,
245
244
  type = _props$type2 === void 0 ? 'primary' : _props$type2,
245
+ className = props.className,
246
+ noArrow = props.noArrow,
246
247
  others = _objectWithoutProperties(props, _excluded4);
247
248
 
248
249
  return /*#__PURE__*/React.createElement(MenuButton, _objectSpread({
@@ -256,7 +257,10 @@ export var ProActionMenuButton = function ProActionMenuButton(props) {
256
257
  v2: true
257
258
  },
258
259
  type: type,
259
- label: buttonContent(label || children, icon, iconSize, context)
260
+ label: buttonContent(label || children, icon, iconSize, context),
261
+ className: cls(className, {
262
+ 'teamix-pro-actions-text-menu-btn-no-arrow': noArrow
263
+ })
260
264
  }, others), actions.map(function (action, i) {
261
265
  return renderCommonActionButtonMenuItem(action, action.key || i, context);
262
266
  }));
@@ -316,14 +320,12 @@ function renderCommonActionButton(button, context, isTypeText) {
316
320
  }
317
321
 
318
322
  function getDefaultMoreButton(type, more) {
319
- var noArrowClassName = 'teamix-pro-actions-text-menu-btn-no-arrow';
320
323
  var defaultConfig = type === 'button' ? {
321
324
  children: getMessage('more')
322
325
  } : {
323
326
  icon: 'more-line',
324
- // iconSize: 'small',
325
327
  autoWidth: false,
326
- className: noArrowClassName
328
+ noArrow: true
327
329
  };
328
330
 
329
331
  if (!more) {
@@ -338,13 +340,7 @@ function getDefaultMoreButton(type, more) {
338
340
  return Object.assign(defaultConfig, moreConfig);
339
341
  }
340
342
 
341
- var noArrow = moreConfig.noArrow,
342
- className = moreConfig.className,
343
- others = _objectWithoutProperties(moreConfig, _excluded6);
344
-
345
- return _objectSpread({
346
- className: cls(className, _defineProperty({}, "".concat(noArrowClassName), noArrow))
347
- }, others);
343
+ return moreConfig;
348
344
  }
349
345
 
350
346
  var MAX_ACTTIONS = 4;
@@ -361,7 +357,7 @@ function getActionConfig(action, index, context) {
361
357
  if (action.actions) {
362
358
  var _key = action.key,
363
359
  actions = action.actions,
364
- _others = _objectWithoutProperties(action, _excluded7);
360
+ _others = _objectWithoutProperties(action, _excluded6);
365
361
 
366
362
  return _objectSpread({
367
363
  key: getKey(index, _key),
@@ -373,7 +369,7 @@ function getActionConfig(action, index, context) {
373
369
 
374
370
  var key = action.key,
375
371
  config = action.config,
376
- others = _objectWithoutProperties(action, _excluded8);
372
+ others = _objectWithoutProperties(action, _excluded7);
377
373
 
378
374
  return _objectSpread({
379
375
  key: getKey(index, key),
@@ -394,7 +390,7 @@ export function ProActionGroup(props) {
394
390
  _props$actions = props.actions,
395
391
  actions = _props$actions === void 0 ? [] : _props$actions,
396
392
  className = props.className,
397
- containerProps = _objectWithoutProperties(props, _excluded9);
393
+ containerProps = _objectWithoutProperties(props, _excluded8);
398
394
 
399
395
  var isTypeText = type === 'text';
400
396
  var filteredActions = actions.map(function (action, index) {
@@ -53,7 +53,7 @@ var AdvancedFilter = /*#__PURE__*/memo(function (props) {
53
53
  props: {
54
54
  breakpoints: [480, 720, 990, 1200, Infinity],
55
55
  maxColumns: [1, 2, 3, 3, 4],
56
- maxWidth: [480, 360, 330, 330, 300],
56
+ maxWidth: [480, 360, 330, 400],
57
57
  columnGap: 16,
58
58
  rowGap: 12
59
59
  },
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { QueryFilterLayoutProps } from '../typing';
3
+ import './layout.scss';
4
+ declare const QueryFilterLayout: React.FC<QueryFilterLayoutProps>;
5
+ export { QueryFilterLayout };
@@ -0,0 +1,82 @@
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
+ 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
+ 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
+ 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
+
19
+ import React, { useCallback, useState } from 'react';
20
+ import cls from 'classnames';
21
+ import { Button, Badge } from '@alicloudfe/components';
22
+ import TeamixIcon from '@teamix/icon';
23
+ import { usePrefixCls, getMessage, isValid } from '@teamix/utils';
24
+ import './layout.scss';
25
+
26
+ var QueryFilterLayout = function QueryFilterLayout(_ref) {
27
+ var className = _ref.className,
28
+ addonBefore = _ref.addonBefore,
29
+ addonAfter = _ref.addonAfter,
30
+ inlineContent = _ref.inlineContent,
31
+ panelContent = _ref.panelContent,
32
+ count = _ref.count,
33
+ expand = _ref.expand,
34
+ onExpand = _ref.onExpand,
35
+ children = _ref.children;
36
+ var prefixCls = usePrefixCls('', {
37
+ prefix: 'teamix-pro-form-query-filter-layout'
38
+ });
39
+
40
+ var _useState = useState(!!expand),
41
+ _useState2 = _slicedToArray(_useState, 2),
42
+ visible = _useState2[0],
43
+ setVisible = _useState2[1];
44
+
45
+ var onClick = useCallback(function () {
46
+ setVisible(!visible);
47
+ onExpand === null || onExpand === void 0 ? void 0 : onExpand(!visible);
48
+ }, [visible]);
49
+ return /*#__PURE__*/React.createElement("div", {
50
+ className: cls(prefixCls, className)
51
+ }, /*#__PURE__*/React.createElement("div", {
52
+ className: "".concat(prefixCls, "-inline")
53
+ }, /*#__PURE__*/React.createElement("div", {
54
+ className: "".concat(prefixCls, "-left")
55
+ }, addonBefore ? /*#__PURE__*/React.createElement("div", {
56
+ className: "".concat(prefixCls, "-addonBefore")
57
+ }, addonBefore) : null, inlineContent, isValid(panelContent) ? /*#__PURE__*/React.createElement("div", {
58
+ className: "".concat(prefixCls, "-toggle")
59
+ }, /*#__PURE__*/React.createElement(Badge, {
60
+ count: count,
61
+ style: _objectSpread({
62
+ backgroundColor: 'var(--color-brand1-6, #0064c8)',
63
+ color: 'var(--color-white, #fff)'
64
+ }, visible ? {
65
+ display: 'none'
66
+ } : {})
67
+ }, /*#__PURE__*/React.createElement(Button, {
68
+ onClick: onClick
69
+ }, visible ? /*#__PURE__*/React.createElement(TeamixIcon, {
70
+ type: "up-line"
71
+ }) : /*#__PURE__*/React.createElement(TeamixIcon, {
72
+ type: "filter-line"
73
+ }), getMessage('advancedFilter')))) : null), addonAfter ? /*#__PURE__*/React.createElement("div", {
74
+ className: "".concat(prefixCls, "-addonAfter")
75
+ }, addonAfter) : null), /*#__PURE__*/React.createElement("div", {
76
+ className: cls("".concat(prefixCls, "-panel"), visible && isValid(panelContent) ? '' : "".concat(prefixCls, "-panel-hidden"))
77
+ }, panelContent), /*#__PURE__*/React.createElement("div", {
78
+ className: "".concat(prefixCls, "-children")
79
+ }, children));
80
+ };
81
+
82
+ export { QueryFilterLayout };
@@ -10,14 +10,16 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
10
10
 
11
11
  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; }
12
12
 
13
- import React, { memo, useMemo } from 'react';
13
+ import React, { memo, useCallback, useMemo, useRef } from 'react';
14
14
  import cls from 'classnames';
15
15
  import { usePrefixCls } from '@teamix/utils';
16
- import ProForm from '../ProForm';
16
+ import ProForm from '../ProForm'; // 初始化Search组件,内置部分属性
17
17
 
18
18
  var initializeSearch = function initializeSearch(schema) {
19
- return schema.map(function (item) {
19
+ var searchName;
20
+ var initializedSchema = schema.map(function (item) {
20
21
  if (item.component === 'Search') {
22
+ searchName = item.name;
21
23
  return _objectSpread(_objectSpread({}, item), {}, {
22
24
  decoratorProps: _objectSpread(_objectSpread({}, item.decoratorProps), {}, {
23
25
  inset: false
@@ -30,6 +32,10 @@ var initializeSearch = function initializeSearch(schema) {
30
32
 
31
33
  return item;
32
34
  });
35
+ return {
36
+ searchName: searchName,
37
+ initializedSchema: initializedSchema
38
+ };
33
39
  };
34
40
  /**
35
41
  * 简单筛选
@@ -37,6 +43,8 @@ var initializeSearch = function initializeSearch(schema) {
37
43
 
38
44
 
39
45
  var SimpleFilter = /*#__PURE__*/memo(function (props) {
46
+ var searchValue = useRef(undefined);
47
+
40
48
  var schema = props.schema,
41
49
  onChange = props.onChange,
42
50
  onSubmit = props.onSubmit,
@@ -45,13 +53,18 @@ var SimpleFilter = /*#__PURE__*/memo(function (props) {
45
53
  var prefixCls = usePrefixCls('', {
46
54
  prefix: 'teamix-pro-form-query-filter-simple'
47
55
  });
56
+
57
+ var _initializeSearch = initializeSearch(schema),
58
+ searchName = _initializeSearch.searchName,
59
+ initializedSchema = _initializeSearch.initializedSchema;
60
+
48
61
  var simpleSchema = useMemo(function () {
49
62
  return [{
50
63
  component: 'FormFlex',
51
64
  props: {
52
65
  size: 8
53
66
  },
54
- children: initializeSearch(schema)
67
+ children: initializedSchema
55
68
  }, {
56
69
  component: 'Submit',
57
70
  props: {
@@ -60,7 +73,18 @@ var SimpleFilter = /*#__PURE__*/memo(function (props) {
60
73
  }
61
74
  }
62
75
  }];
63
- }, [schema]);
76
+ }, [initializedSchema]);
77
+ var onInnerChange = useCallback(function (values, value, name) {
78
+ // 处理Search组件,Select切换时不触发onChange
79
+ if (searchName === name) {
80
+ if (searchValue.current !== value[1]) {
81
+ onChange === null || onChange === void 0 ? void 0 : onChange(values, name, value);
82
+ searchValue.current = value[1];
83
+ }
84
+ } else {
85
+ onChange === null || onChange === void 0 ? void 0 : onChange(values, name, value);
86
+ }
87
+ }, [searchName, searchValue.current]);
64
88
  return /*#__PURE__*/React.createElement(ProForm, _objectSpread(_objectSpread({}, otherProps), {}, {
65
89
  className: cls(prefixCls, props.className),
66
90
  schema: simpleSchema,
@@ -68,7 +92,7 @@ var SimpleFilter = /*#__PURE__*/memo(function (props) {
68
92
  breakpoints: [],
69
93
  inset: true,
70
94
  onSubmit: onSubmit,
71
- onChange: onChange
95
+ onChange: onInnerChange
72
96
  }));
73
97
  });
74
98
  export default SimpleFilter;
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
+ import { QueryFilterLayout } from './Layout';
2
3
  import type { QueryFilterProps } from '../typing';
3
4
  import './index2.scss';
4
5
  /**
5
6
  * 查询筛选
6
7
  */
7
8
  declare const QueryFilter: React.FC<QueryFilterProps>;
8
- export { QueryFilter };
9
+ export { QueryFilter, QueryFilterLayout };
@@ -1,4 +1,4 @@
1
- var _excluded = ["addonAfter", "addonBefore", "onFilter", "onInit", "onReset", "mode", "expand", "formRef", "defaultFilterValue"];
1
+ var _excluded = ["addonAfter", "addonBefore", "mode", "expand", "formRef", "defaultFilterValue", "filterDebounce", "onFilter", "onInit", "onReset", "onExpand"];
2
2
 
3
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
4
 
@@ -6,6 +6,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
6
6
 
7
7
  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
8
 
9
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
10
+
11
+ 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."); }
12
+
13
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
+
15
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
+
9
17
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
10
18
 
11
19
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -28,68 +36,36 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
28
36
 
29
37
  import React, { memo, useCallback, useMemo, useState, useRef, useEffect } from 'react';
30
38
  import cls from 'classnames';
31
- import { Tag, Button, Badge } from '@alicloudfe/components';
32
- import TeamixIcon from '@teamix/icon';
39
+ import debounce from 'lodash.debounce';
40
+ import { Tag } from '@alicloudfe/components';
33
41
  import { createForm, onFormReact, onFormInputChange } from '@formily/core';
34
42
  import { toJS } from '@formily/reactive';
35
- import { usePrefixCls, getMessage, isSignificative, isStr, isPlainObj } from '@teamix/utils';
43
+ import { usePrefixCls, isSignificative, isNum } from '@teamix/utils';
36
44
  import ProField from '../../field/index';
37
45
  import fieldTypeMap from '../fieldTypeMap';
38
46
  import { getFormDisplayValues } from '../ProForm/useFormDisplayValues';
39
47
  import SimpleFilter from './SimpleFilter';
40
48
  import LightFilter from './LightFilter';
41
49
  import AdvancedFilter from './AdvancedFilter';
42
- import debounce from 'lodash.debounce';
43
- import './index2.scss'; // 获取Schema是否包含默认值、异步默认值、必选校验等
44
-
45
- var getSpecialProps = function getSpecialProps(props) {
46
- var initialValues = props.initialValues,
47
- initialRequest = props.initialRequest;
48
- var hasDefault = !!initialValues;
49
- var hasAsyncDefault = !!initialRequest;
50
- var hasRequired = false;
51
-
52
- var hasDefaultOrRule = function hasDefaultOrRule(schema) {
53
- schema.forEach(function (item) {
54
- var value = item.default,
55
- required = item.required,
56
- rules = item.rules,
57
- request = item.request,
58
- dataSource = item.dataSource,
59
- children = item.children;
60
- hasDefault = hasDefault || isSignificative(value);
61
- hasRequired = hasRequired || required || !!rules;
62
- hasAsyncDefault = hasAsyncDefault || !!request || // 如果dataSource是异步且default取自dataSource
63
- !!(isPlainObj(dataSource) && isStr(value) && value.indexOf('.dataSource'));
64
-
65
- if (children === null || children === void 0 ? void 0 : children.length) {
66
- hasDefaultOrRule(children);
67
- }
68
- });
69
- };
70
-
71
- hasDefaultOrRule(props.schema);
72
- return {
73
- hasDefault: hasDefault,
74
- hasAsyncDefault: hasAsyncDefault,
75
- hasRequired: hasRequired
76
- };
77
- };
50
+ import { QueryFilterLayout } from './Layout';
51
+ import useSpecialProps from './useSpecialProps';
52
+ import './index2.scss';
78
53
  /**
79
54
  * 查询筛选
80
55
  */
81
56
 
82
-
83
57
  var QueryFilter = /*#__PURE__*/memo(function (props) {
84
58
  var addonAfter = props.addonAfter,
85
59
  addonBefore = props.addonBefore,
86
- onFilter = props.onFilter,
87
- onInit = props.onInit,
88
- onReset = props.onReset,
89
60
  mode = props.mode,
90
61
  expand = props.expand,
91
62
  formRef = props.formRef,
92
63
  defaultFilterValue = props.defaultFilterValue,
64
+ filterDebounce = props.filterDebounce,
65
+ onFilter = props.onFilter,
66
+ onInit = props.onInit,
67
+ onReset = props.onReset,
68
+ onExpand = props.onExpand,
93
69
  otherProps = _objectWithoutProperties(props, _excluded); // 表单默认值初始化回调
94
70
 
95
71
 
@@ -176,10 +152,10 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
176
152
  advanced: advancedForm
177
153
  };
178
154
 
179
- var _getSpecialProps = getSpecialProps(props),
180
- hasDefault = _getSpecialProps.hasDefault,
181
- hasAsyncDefault = _getSpecialProps.hasAsyncDefault,
182
- hasRequired = _getSpecialProps.hasRequired;
155
+ var _useSpecialProps = useSpecialProps(props),
156
+ hasDefault = _useSpecialProps.hasDefault,
157
+ hasAsyncDefault = _useSpecialProps.hasAsyncDefault,
158
+ hasRequired = _useSpecialProps.hasRequired;
183
159
 
184
160
  var hasDefaultOrRequired = hasDefault || hasAsyncDefault || hasRequired;
185
161
 
@@ -205,22 +181,40 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
205
181
 
206
182
  var getFilterDisplayValues = useCallback(function (form) {
207
183
  var displayValues = getFormDisplayValues(form);
208
- return Object.entries(displayValues).map(function (_ref2) {
184
+ var originalData = Object.entries(displayValues);
185
+ var filterData = [];
186
+ originalData.forEach(function (_ref2) {
209
187
  var _data$displayValue;
210
188
 
211
189
  var _ref3 = _slicedToArray(_ref2, 2),
212
190
  key = _ref3[0],
213
191
  data = _ref3[1];
214
192
 
215
- return {
216
- key: key,
217
- type: fieldTypeMap[data.component] || 'text',
218
- label: data.title,
219
- value: (_data$displayValue = data.displayValue) !== null && _data$displayValue !== void 0 ? _data$displayValue : data.value
220
- };
221
- }).filter(function (item) {
222
- return isSignificative(item.value);
193
+ var value = (_data$displayValue = data.displayValue) !== null && _data$displayValue !== void 0 ? _data$displayValue : data.value;
194
+ var component = data.component;
195
+
196
+ if (component === 'SelectGroup') {
197
+ var _data$value;
198
+
199
+ (_data$value = data.value) === null || _data$value === void 0 ? void 0 : _data$value.forEach(function (item, index) {
200
+ filterData.push({
201
+ key: key,
202
+ type: fieldTypeMap['MultipleSelect'],
203
+ label: item.key,
204
+ value: item.value,
205
+ index: index
206
+ });
207
+ });
208
+ } else if (isSignificative(value)) {
209
+ filterData.push({
210
+ key: key,
211
+ type: fieldTypeMap[component] || 'text',
212
+ label: data.title,
213
+ value: value
214
+ });
215
+ }
223
216
  });
217
+ return filterData;
224
218
  }, []); // 设置标签数据
225
219
 
226
220
  var configTag = useCallback(function () {
@@ -241,6 +235,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
241
235
  }
242
236
 
243
237
  setAdvancedFilterVisible(result);
238
+ onExpand === null || onExpand === void 0 ? void 0 : onExpand(result);
244
239
  }, [advancedFilterVisible, configTag, currentForm.current]); // 简单搜索Filter
245
240
 
246
241
  var onSimpleFilter = useCallback( /*#__PURE__*/function () {
@@ -325,8 +320,15 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
325
320
  lightForm.reset();
326
321
  }, [onReset]); // 关闭标签清空表单字段值
327
322
 
328
- var onTagClose = useCallback(function (key) {
329
- advancedForm.setValuesIn(key, undefined);
323
+ var onTagClose = useCallback(function (key, index) {
324
+ var newValue = undefined;
325
+
326
+ if (isNum(index)) {
327
+ newValue = _toConsumableArray(advancedForm.getValuesIn(key));
328
+ newValue.splice(index, 1);
329
+ }
330
+
331
+ advancedForm.setValuesIn(key, newValue);
330
332
  configFilterItem(advancedForm);
331
333
  configTag();
332
334
  onFilter && onFilter(toJS(advancedForm.values));
@@ -341,57 +343,44 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
341
343
  useEffect(function () {
342
344
  setCurrentForm(currentForm.current);
343
345
  }, []);
344
- return /*#__PURE__*/React.createElement("div", {
345
- className: cls(prefixCls, props.className)
346
- }, /*#__PURE__*/React.createElement("div", {
347
- className: "".concat(prefixCls, "-inline")
348
- }, /*#__PURE__*/React.createElement("div", {
349
- className: "".concat(prefixCls, "-left")
350
- }, addonBefore ? /*#__PURE__*/React.createElement("div", {
351
- className: "".concat(prefixCls, "-addonBefore")
352
- }, addonBefore) : null, mode === 'panel' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
353
- className: cls("".concat(prefixCls, "-inline-form"), hasDefaultOrRequired ? "".concat(prefixCls, "-inline-form-hidden") : '')
354
- }, /*#__PURE__*/React.createElement(LightFilter, _objectSpread(_objectSpread({}, otherProps), {}, {
355
- defaultFilterValue: defaultFilterValue,
356
- form: lightForm,
357
- onChange: debounce(onLightFilter, 300)
358
- }))), /*#__PURE__*/React.createElement("div", {
359
- className: "".concat(prefixCls, "-toggle")
360
- }, /*#__PURE__*/React.createElement(Badge, {
346
+ return /*#__PURE__*/React.createElement(QueryFilterLayout, {
347
+ className: cls(prefixCls, props.className),
348
+ addonBefore: addonBefore,
349
+ addonAfter: addonAfter,
350
+ expand: advancedFilterVisible,
351
+ onExpand: toggleAdvancedFilter,
361
352
  count: tagDataSource.length,
362
- style: _objectSpread({
363
- backgroundColor: 'var(--color-brand1-6, #0064c8)',
364
- color: 'var(--color-white, #fff)'
365
- }, advancedFilterVisible ? {
366
- display: 'none'
367
- } : {})
368
- }, /*#__PURE__*/React.createElement(Button, {
369
- onClick: toggleAdvancedFilter
370
- }, advancedFilterVisible ? /*#__PURE__*/React.createElement(TeamixIcon, {
371
- type: "up-line"
372
- }) : /*#__PURE__*/React.createElement(TeamixIcon, {
373
- type: "filter-line"
374
- }), getMessage('advancedFilter'))))) : /*#__PURE__*/React.createElement("div", {
375
- className: "".concat(prefixCls, "-inline-form")
376
- }, /*#__PURE__*/React.createElement(SimpleFilter, _objectSpread(_objectSpread({}, otherProps), {}, {
377
- form: simpleForm,
378
- onChange: debounce(onSimpleFilter, 300),
379
- onSubmit: onSimpleFilter
380
- })))), addonAfter ? /*#__PURE__*/React.createElement("div", {
381
- className: "".concat(prefixCls, "-addonAfter")
382
- }, addonAfter) : null), mode === 'panel' ? /*#__PURE__*/React.createElement("div", {
383
- className: "".concat(prefixCls, "-panel")
384
- }, /*#__PURE__*/React.createElement("div", {
385
- className: cls("".concat(prefixCls, "-tag"), advancedFilterVisible ? "".concat(prefixCls, "-tag-hidden") : '')
386
- }, /*#__PURE__*/React.createElement(Tag.Group, null, tagDataSource.map(function (_ref7) {
353
+ inlineContent: mode === 'panel' ? /*#__PURE__*/React.createElement("div", {
354
+ className: cls("".concat(prefixCls, "-inline"), hasDefaultOrRequired ? "".concat(prefixCls, "-inline-hidden") : '')
355
+ }, /*#__PURE__*/React.createElement(LightFilter, _objectSpread(_objectSpread({}, otherProps), {}, {
356
+ defaultFilterValue: defaultFilterValue,
357
+ form: lightForm,
358
+ onChange: debounce(onLightFilter, filterDebounce)
359
+ }))) : /*#__PURE__*/React.createElement("div", {
360
+ className: "".concat(prefixCls, "-inline")
361
+ }, /*#__PURE__*/React.createElement(SimpleFilter, _objectSpread(_objectSpread({}, otherProps), {}, {
362
+ form: simpleForm,
363
+ onChange: debounce(onSimpleFilter, filterDebounce),
364
+ onSubmit: onSimpleFilter
365
+ }))),
366
+ panelContent: mode === 'panel' ? /*#__PURE__*/React.createElement(AdvancedFilter, _objectSpread(_objectSpread({}, otherProps), {}, {
367
+ initialRequest: otherProps.initialRequest ? _objectSpread(_objectSpread({}, otherProps.initialRequest), {}, {
368
+ onComplete: onInitialRequestComplete
369
+ }) : undefined,
370
+ form: advancedForm,
371
+ onSubmit: onAdvancedFilter,
372
+ onReset: onAdvancedReset
373
+ })) : null
374
+ }, mode === 'panel' && !advancedFilterVisible ? /*#__PURE__*/React.createElement(Tag.Group, null, tagDataSource.map(function (_ref7) {
387
375
  var key = _ref7.key,
388
376
  label = _ref7.label,
389
377
  value = _ref7.value,
390
- type = _ref7.type;
378
+ type = _ref7.type,
379
+ index = _ref7.index;
391
380
  return /*#__PURE__*/React.createElement(Tag.Closeable, {
392
- key: key,
381
+ key: isNum(index) ? key + label : key,
393
382
  afterClose: function afterClose() {
394
- return onTagClose(key);
383
+ return onTagClose(key, index);
395
384
  }
396
385
  }, /*#__PURE__*/React.createElement("span", {
397
386
  className: "".concat(prefixCls, "-tag-title")
@@ -401,19 +390,11 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
401
390
  type: type,
402
391
  value: value
403
392
  })));
404
- }))), /*#__PURE__*/React.createElement("div", {
405
- className: cls("".concat(prefixCls, "-advanced-wrap"), !advancedFilterVisible ? "".concat(prefixCls, "-advanced-wrap-hidden") : '')
406
- }, /*#__PURE__*/React.createElement(AdvancedFilter, _objectSpread(_objectSpread({}, otherProps), {}, {
407
- initialRequest: otherProps.initialRequest ? _objectSpread(_objectSpread({}, otherProps.initialRequest), {}, {
408
- onComplete: onInitialRequestComplete
409
- }) : undefined,
410
- form: advancedForm,
411
- onSubmit: onAdvancedFilter,
412
- onReset: onAdvancedReset
413
- })))) : null);
393
+ })) : null);
414
394
  });
415
395
  QueryFilter.defaultProps = {
416
396
  mode: 'inline',
417
- expand: false
397
+ expand: false,
398
+ filterDebounce: 300
418
399
  };
419
- export { QueryFilter };
400
+ export { QueryFilter, QueryFilterLayout };