@teamix/pro 1.2.8 → 1.2.12

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 (117) hide show
  1. package/dist/pro.css +1 -1
  2. package/dist/pro.js +1787 -812
  3. package/dist/pro.min.css +1 -1
  4. package/dist/pro.min.js +1 -1
  5. package/es/actions/base.d.ts +16 -6
  6. package/es/actions/base.js +66 -12
  7. package/es/actions/confirm.d.ts +1 -1
  8. package/es/actions/danger-confirm.d.ts +1 -1
  9. package/es/actions/dialog-component.d.ts +1 -1
  10. package/es/actions/dialog-form.d.ts +1 -1
  11. package/es/actions/dialog-form.js +4 -4
  12. package/es/actions/dialog-info.d.ts +1 -1
  13. package/es/actions/dialog-table.d.ts +1 -1
  14. package/es/actions/dialog.d.ts +6 -2
  15. package/es/actions/dialog.js +19 -24
  16. package/es/actions/drawer-form.d.ts +1 -1
  17. package/es/actions/drawer-info.d.ts +1 -1
  18. package/es/actions/drawer-table.d.ts +1 -1
  19. package/es/actions/drawer.d.ts +1 -1
  20. package/es/actions/error.d.ts +1 -1
  21. package/es/actions/index.js +25 -22
  22. package/es/actions/index.scss +28 -7
  23. package/es/actions/link.d.ts +2 -2
  24. package/es/actions/link.js +2 -2
  25. package/es/actions/notice.d.ts +1 -1
  26. package/es/actions/request.d.ts +1 -1
  27. package/es/actions/request.js +2 -2
  28. package/es/card/index.d.ts +10 -1
  29. package/es/card/index.js +20 -6
  30. package/es/card/index.scss +19 -0
  31. package/es/card/tab.d.ts +6 -0
  32. package/es/card/tab.js +27 -0
  33. package/es/form/Filter/index.d.ts +2 -5
  34. package/es/form/Filter/index.js +3 -44
  35. package/es/form/Filter/index.scss +71 -0
  36. package/es/form/Filter/index2.d.ts +8 -0
  37. package/es/form/Filter/index2.js +318 -0
  38. package/es/form/ProForm/index.js +3 -23
  39. package/es/form/ProForm/index.scss +10 -19
  40. package/es/form/ProForm/useFormDisplayValues.d.ts +3 -5
  41. package/es/form/ProForm/useFormDisplayValues.js +44 -38
  42. package/es/form/SchemaForm/index.js +7 -6
  43. package/es/form/index.d.ts +2 -1
  44. package/es/form/index.js +3 -2
  45. package/es/form/typing.d.ts +3 -0
  46. package/es/index.d.ts +1 -1
  47. package/es/index.js +1 -1
  48. package/es/page-header/index.d.ts +20 -11
  49. package/es/page-header/index.js +23 -47
  50. package/es/page-header/index.scss +0 -11
  51. package/es/sidebar/components/tree/index.js +85 -18
  52. package/es/sidebar/index.js +9 -5
  53. package/es/sidebar/typing.d.ts +14 -1
  54. package/es/table/components/Filter/index.js +11 -9
  55. package/es/table/components/Filter/index.scss +7 -3
  56. package/es/table/components/Layout/index.js +10 -1
  57. package/es/table/index.js +3 -4
  58. package/es/utils/components/tags/index.d.ts +11 -0
  59. package/es/utils/components/tags/index.js +50 -0
  60. package/es/utils/components/tags/index.scss +12 -0
  61. package/lib/actions/base.d.ts +16 -6
  62. package/lib/actions/base.js +67 -12
  63. package/lib/actions/confirm.d.ts +1 -1
  64. package/lib/actions/danger-confirm.d.ts +1 -1
  65. package/lib/actions/dialog-component.d.ts +1 -1
  66. package/lib/actions/dialog-form.d.ts +1 -1
  67. package/lib/actions/dialog-form.js +3 -3
  68. package/lib/actions/dialog-info.d.ts +1 -1
  69. package/lib/actions/dialog-table.d.ts +1 -1
  70. package/lib/actions/dialog.d.ts +6 -2
  71. package/lib/actions/dialog.js +18 -23
  72. package/lib/actions/drawer-form.d.ts +1 -1
  73. package/lib/actions/drawer-info.d.ts +1 -1
  74. package/lib/actions/drawer-table.d.ts +1 -1
  75. package/lib/actions/drawer.d.ts +1 -1
  76. package/lib/actions/error.d.ts +1 -1
  77. package/lib/actions/index.js +25 -22
  78. package/lib/actions/index.scss +28 -7
  79. package/lib/actions/link.d.ts +2 -2
  80. package/lib/actions/link.js +2 -2
  81. package/lib/actions/notice.d.ts +1 -1
  82. package/lib/actions/request.d.ts +1 -1
  83. package/lib/actions/request.js +2 -2
  84. package/lib/card/index.d.ts +10 -1
  85. package/lib/card/index.js +22 -5
  86. package/lib/card/index.scss +19 -0
  87. package/lib/card/tab.d.ts +6 -0
  88. package/lib/card/tab.js +39 -0
  89. package/lib/form/Filter/index.d.ts +2 -5
  90. package/lib/form/Filter/index.js +4 -45
  91. package/lib/form/Filter/index.scss +71 -0
  92. package/lib/form/Filter/index2.d.ts +8 -0
  93. package/lib/form/Filter/index2.js +342 -0
  94. package/lib/form/ProForm/index.js +3 -23
  95. package/lib/form/ProForm/index.scss +10 -19
  96. package/lib/form/ProForm/useFormDisplayValues.d.ts +3 -5
  97. package/lib/form/ProForm/useFormDisplayValues.js +51 -44
  98. package/lib/form/SchemaForm/index.js +7 -6
  99. package/lib/form/index.d.ts +2 -1
  100. package/lib/form/index.js +5 -3
  101. package/lib/form/typing.d.ts +3 -0
  102. package/lib/index.d.ts +1 -1
  103. package/lib/index.js +1 -1
  104. package/lib/page-header/index.d.ts +20 -11
  105. package/lib/page-header/index.js +22 -45
  106. package/lib/page-header/index.scss +0 -11
  107. package/lib/sidebar/components/tree/index.js +83 -16
  108. package/lib/sidebar/index.js +9 -5
  109. package/lib/sidebar/typing.d.ts +14 -1
  110. package/lib/table/components/Filter/index.js +10 -8
  111. package/lib/table/components/Filter/index.scss +7 -3
  112. package/lib/table/components/Layout/index.js +10 -1
  113. package/lib/table/index.js +2 -3
  114. package/lib/utils/components/tags/index.d.ts +11 -0
  115. package/lib/utils/components/tags/index.js +66 -0
  116. package/lib/utils/components/tags/index.scss +12 -0
  117. package/package.json +4 -4
@@ -230,14 +230,12 @@
230
230
  }
231
231
  }
232
232
 
233
- // 筛选和抽屉按钮
234
- .#{$teamix-pro-form}-filter-advanced,
233
+ // 抽屉按钮
235
234
  .#{$css-prefix}drawer-footer {
236
235
  .#{$css-prefix}formily-button-group {
237
236
  margin-top: 0;
238
237
  }
239
238
  }
240
-
241
239
  .#{$teamix-pro-form}-button-affix-auto.#{$css-prefix}affix,
242
240
  .#{$teamix-pro-form}-button-affix-always.#{$css-prefix}affix {
243
241
  left: 0;
@@ -259,22 +257,6 @@
259
257
  }
260
258
  }
261
259
 
262
- // 高级筛选
263
- .#{$teamix-pro-form}-filter-advanced,
264
- .#{$teamix-pro-form}-filter-simple {
265
- .#{$form-item-cls}-feedback-layout-popover {
266
- margin-bottom: 0;
267
- }
268
- .#{$css-prefix}date-picker2-input {
269
- .#{$css-prefix}input {
270
- width: inherit;
271
- input {
272
- width: inherit;
273
- }
274
- }
275
- }
276
- }
277
-
278
260
  // ArrayItems
279
261
  .#{$css-prefix}formily-array-items {
280
262
  .#{$css-prefix}formily-grid-layout {
@@ -288,3 +270,12 @@
288
270
  cursor: pointer;
289
271
  }
290
272
  }
273
+
274
+ /* hack todo remove */
275
+ .#{$form-item-cls}-control-content-component {
276
+ .teamix-pro-field-tooltip.teamix-pro-field-checkbox {
277
+ .teamix-pro-lable-icon-tip-icon {
278
+ transform: translate(0px, 4px);
279
+ }
280
+ }
281
+ }
@@ -1,6 +1,4 @@
1
- /**
2
- * 获取表单值的可显示值
3
- * @returns 如果某字段有dataSource,则返回value对应label
4
- */
1
+ import type { Form } from '@formily/core';
5
2
  declare const useFormDisplayValues: () => any;
6
- export default useFormDisplayValues;
3
+ declare const getFormDisplayValues: (form: Form) => any;
4
+ export { useFormDisplayValues, getFormDisplayValues };
@@ -15,51 +15,57 @@ import { isArr, isPlainObj, getValueByValue } from '@teamix/utils';
15
15
  /**
16
16
  * 获取表单值的可显示值
17
17
  * @returns 如果某字段有dataSource,则返回value对应label
18
+ * @example const example = {
19
+ a: [
20
+ [{ b: 'a.0.0.b', c: 'a.0.0.c' }, { d: 'a.0.1.d' }],
21
+ { e: [{ f: { g: [{ h: 'a.1.e.0.f.g.0.h' }] } }, 'a.1.e.1'] },
22
+ ],
23
+ };
24
+ console.log(getDisplayValues(example));
18
25
  */
19
26
 
20
- var useFormDisplayValues = function useFormDisplayValues() {
21
- var form = useForm();
22
- var values = form.values; // 判断值的类型,递归获取每个值在该结构中的完整路径
27
+ var getDisplayValues = function getDisplayValues(form, values) {
28
+ var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
29
+ var displayValues; // 判断值的类型,递归获取每个值在该结构中的完整路径
23
30
 
24
- var getDisplayValues = function getDisplayValues(values) {
25
- var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
26
- var displayValues;
31
+ if (isPlainObj(values)) {
32
+ displayValues = {};
33
+ Object.entries(values).forEach(function (_ref) {
34
+ var _ref2 = _slicedToArray(_ref, 2),
35
+ key = _ref2[0],
36
+ value = _ref2[1];
27
37
 
28
- if (isPlainObj(values)) {
29
- displayValues = {};
30
- Object.entries(values).forEach(function (_ref) {
31
- var _ref2 = _slicedToArray(_ref, 2),
32
- key = _ref2[0],
33
- value = _ref2[1];
38
+ var path = prefix ? "".concat(prefix, ".").concat(key) : "".concat(key);
39
+ displayValues[key] = getDisplayValues(form, value, path);
40
+ });
41
+ } else if (isArr(values)) {
42
+ displayValues = []; // todo 如果对象或数组的值不再是对象或数组,并且找不到路径,判断为非复合组件,直接返回原始值
34
43
 
35
- var path = prefix ? "".concat(prefix, ".").concat(key) : "".concat(key);
36
- displayValues[key] = getDisplayValues(value, path);
37
- });
38
- } else if (isArr(values)) {
39
- displayValues = [];
40
- values.map(function (value, index) {
41
- var path = prefix ? "".concat(prefix, ".").concat(index) : "".concat(index);
42
- displayValues[index] = getDisplayValues(value, path);
43
- });
44
- } else {
45
- // 通过值的完整路径获取字段address(从form实例的indexes中),然后获取该字段的value在该字段dataSource中对应的label
46
- var address = form.indexes[prefix];
47
- var field = form.query(address).take();
48
- displayValues = getValueByValue(field === null || field === void 0 ? void 0 : field.dataSource, values) || values;
49
- }
44
+ values.map(function (value, index) {
45
+ var path = prefix ? "".concat(prefix, ".").concat(index) : "".concat(index);
46
+ displayValues[index] = getDisplayValues(form, value, path);
47
+ });
48
+ } else {
49
+ // 通过值的完整路径获取字段address(从form实例的indexes中),然后获取该字段的value在该字段dataSource中对应的label
50
+ var address = form.indexes[prefix];
51
+ var field = form.query(address).take();
52
+ displayValues = {
53
+ title: field === null || field === void 0 ? void 0 : field.title,
54
+ value: values,
55
+ displayValue: getValueByValue(field === null || field === void 0 ? void 0 : field.dataSource, values)
56
+ };
57
+ }
50
58
 
51
- return displayValues;
52
- }; // 测试样例
53
- // const example = {
54
- // a: [
55
- // [{ b: 'a.0.0.b', c: 'a.0.0.c' }, { d: 'a.0.1.d' }],
56
- // { e: [{ f: { g: [{ h: 'a.1.e.0.f.g.0.h' }] } }, 'a.1.e.1'] },
57
- // ],
58
- // };
59
- // console.log(getDisplayValues(example));
59
+ return displayValues;
60
+ };
60
61
 
62
+ var useFormDisplayValues = function useFormDisplayValues() {
63
+ var form = useForm();
64
+ return getDisplayValues(form, form.values);
65
+ };
61
66
 
62
- return getDisplayValues(values);
67
+ var getFormDisplayValues = function getFormDisplayValues(form) {
68
+ return getDisplayValues(form, form.values);
63
69
  };
64
70
 
65
- export default useFormDisplayValues;
71
+ export { useFormDisplayValues, getFormDisplayValues };
@@ -62,6 +62,7 @@ export default /*#__PURE__*/memo(function (_ref) {
62
62
  var schema = _ref.schema,
63
63
  scope = _ref.scope,
64
64
  components = _ref.components;
65
+ // 创建 SchemaField
65
66
  var SchemaField = useMemo(function () {
66
67
  return createSchemaField({
67
68
  components: _objectSpread(_objectSpread({}, ProFieldComponents), {}, {
@@ -92,15 +93,15 @@ export default /*#__PURE__*/memo(function (_ref) {
92
93
  Text: Text
93
94
  })
94
95
  });
95
- }, []); // 合并schema中request的scope
96
+ }, []); // 合并 schema request scope
96
97
 
97
98
  var mergedScope = useMemo(function () {
98
99
  return _objectSpread({}, scope);
99
- }, [scope]); // 格式化schema
100
+ }, [scope]); // 格式化 schema
100
101
 
101
102
  var formatSchema = useCallback(function (schema) {
102
103
  var schemaProperties = {};
103
- schema.forEach(function (item) {
104
+ schema === null || schema === void 0 ? void 0 : schema.forEach(function (item) {
104
105
  var newItem = warning(item);
105
106
  var _newItem = newItem,
106
107
  originalComponent = _newItem.component; // 根据component的不同,初始化为内置的item
@@ -236,15 +237,15 @@ export default /*#__PURE__*/memo(function (_ref) {
236
237
  });
237
238
  return schemaProperties;
238
239
  }, [mergedScope]);
239
- var schemaPro = useMemo(function () {
240
+ var proFormSchema = useMemo(function () {
240
241
  return {
241
242
  type: 'object',
242
243
  properties: formatSchema(schema)
243
244
  };
244
- }, []); // console.log(schemaPro);
245
+ }, []); // console.log(proFormSchema);
245
246
 
246
247
  return /*#__PURE__*/React.createElement(SchemaField, {
247
- schema: schemaPro,
248
+ schema: proFormSchema,
248
249
  components: components,
249
250
  scope: mergedScope
250
251
  });
@@ -108,7 +108,8 @@ export { createForm, FormConsumer, FormDialog, FormDrawer, FormStep, FormTab, Fo
108
108
  /**
109
109
  * 导出 Filter 组件
110
110
  */
111
- import { AdvancedFilter, SimpleFilter, QueryFilter } from './Filter';
111
+ import { AdvancedFilter, SimpleFilter } from './Filter';
112
+ import { QueryFilter } from './Filter/index2';
112
113
  export { AdvancedFilter, SimpleFilter, QueryFilter };
113
114
  /**
114
115
  * 导出 ProForm 组件,支持快速搭建表单
package/es/form/index.js CHANGED
@@ -19,7 +19,7 @@ export { _formilyReactive as formilyReactive };
19
19
  import * as _formilyTeamix from '@teamix/formily';
20
20
  export { _formilyTeamix as formilyTeamix };
21
21
  import * as originalFormilyReact from '@formily/react';
22
- import useFormDisplayValues from './ProForm/useFormDisplayValues';
22
+ import { useFormDisplayValues } from './ProForm/useFormDisplayValues';
23
23
  import useFieldRequest from './ProForm/useFieldRequest';
24
24
 
25
25
  var formilyReact = _objectSpread(_objectSpread({}, originalFormilyReact), {}, {
@@ -40,7 +40,8 @@ export { createForm, FormConsumer, FormDialog, FormDrawer, FormStep, FormTab, Fo
40
40
  * 导出 Filter 组件
41
41
  */
42
42
 
43
- import { AdvancedFilter, SimpleFilter, QueryFilter } from './Filter';
43
+ import { AdvancedFilter, SimpleFilter } from './Filter';
44
+ import { QueryFilter } from './Filter/index2';
44
45
  export { AdvancedFilter, SimpleFilter, QueryFilter };
45
46
  /**
46
47
  * 导出 ProForm 组件,支持快速搭建表单
@@ -2,6 +2,7 @@ import type { ReactNode } from 'react';
2
2
  import type { IFormFeedback, Form as FormType, FieldPatternTypes } from '@formily/core';
3
3
  import type { IFormLayoutProps } from '@teamix/formily';
4
4
  import { CommonRequestConfig } from '@teamix/utils';
5
+ import React from 'react';
5
6
  interface AnyObject {
6
7
  [propName: string]: any;
7
8
  }
@@ -64,6 +65,8 @@ export interface ProFormProps extends IFormLayoutProps {
64
65
  onSubmitFailed?: (feedbacks: IFormFeedback[]) => void;
65
66
  }
66
67
  export interface QueryFilterProps extends ProFormProps {
68
+ addonBefore?: ReactNode;
69
+ addonAfter?: ReactNode;
67
70
  onFilter?: (values: any) => void;
68
71
  onReset?: (payload?: any) => void;
69
72
  }
package/es/index.d.ts CHANGED
@@ -21,5 +21,5 @@ export * from './page-container';
21
21
  export * from './page-header';
22
22
  export * from './skeleton';
23
23
  export * from './table';
24
- declare const version = "1.2.7";
24
+ declare const version = "1.2.11";
25
25
  export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, hooks, nocode, templates, utils, };
package/es/index.js CHANGED
@@ -27,7 +27,7 @@ export * from './page-header';
27
27
  export * from './skeleton';
28
28
  export * from './table'; // export * from './sidebar';
29
29
 
30
- var version = '1.2.7';
30
+ var version = '1.2.11';
31
31
  export { version, ProAction, ProCard, ProField, ProForm, ProInfo, // ProLayout,
32
32
  ProPageContainer, ProPageHeader, ProSkeleton, ProTable, // ProSidebar,
33
33
  hooks, nocode, templates, utils };
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
- import { TagProps, CloseableProps } from '@alicloudfe/components/types/tag';
3
2
  import { ItemProps } from '@alicloudfe/components/types/breadcrumb';
3
+ import { LinkPath } from '@teamix/utils';
4
+ import { ProTagItem } from '../utils/components/tags';
4
5
  import { ProActionGroupProps } from '../actions';
5
6
  import { ProInfoProps } from '../info';
6
7
  import './index.scss';
@@ -10,14 +11,7 @@ export interface ProPageHeaderBreadcrumbItem extends ItemProps {
10
11
  */
11
12
  text?: string;
12
13
  }
13
- export declare type ProPageHeaderTagItem = (TagProps | (CloseableProps & {
14
- closable: true;
15
- })) & {
16
- /**
17
- * @deprecated 建议使用 children 代替
18
- */
19
- text?: string;
20
- };
14
+ export declare type ProPageHeaderTagItem = ProTagItem;
21
15
  declare type Color = 'blue' | 'green' | 'orange' | 'red' | 'yellow' | string;
22
16
  export declare type ProPageHeaderDataItem = {
23
17
  title: string;
@@ -25,20 +19,35 @@ export declare type ProPageHeaderDataItem = {
25
19
  color?: Color;
26
20
  } & React.HTMLAttributes<HTMLElement>;
27
21
  export declare type ProPageHeaderProps = {
22
+ /** 标题 */
28
23
  title?: React.ReactNode;
24
+ /** 描述 */
29
25
  description?: React.ReactNode;
30
- icon?: string;
26
+ /** 图标 */
27
+ icon?: React.ReactNode;
28
+ /** 图标颜色 */
31
29
  iconColor?: Color;
30
+ /** 图标背景类型 */
32
31
  iconBackgroundType?: 'circle' | 'square';
32
+ /** 图标背景色 */
33
33
  iconBackgroundColor?: Color;
34
- goback?: string | boolean;
34
+ /** 返回按钮配置 */
35
+ goback?: boolean | LinkPath | ((e: React.MouseEvent) => void);
36
+ /** 背景图 */
35
37
  image?: string;
38
+ /** 加载中 */
36
39
  loading?: boolean;
40
+ /** 面包屑配置 */
37
41
  breadcrumb?: ProPageHeaderBreadcrumbItem[];
42
+ /** 额外信息区配置 */
38
43
  extra?: ProActionGroupProps | React.ReactNode;
44
+ /** 操作区配置 */
39
45
  operation?: ProActionGroupProps | React.ReactNode;
46
+ /** 标签组 */
40
47
  tags?: ProPageHeaderTagItem[];
48
+ /** 数据概览项 */
41
49
  data?: ProPageHeaderDataItem[];
50
+ /** 底部详情 */
42
51
  info?: ProInfoProps | React.ReactNode;
43
52
  } & Omit<React.HTMLAttributes<HTMLElement>, 'title'>;
44
53
  declare const ProPageHeader: React.FC<ProPageHeaderProps>;
@@ -1,7 +1,6 @@
1
1
  var _excluded = ["text", "children"],
2
- _excluded2 = ["text", "children", "closable"],
3
- _excluded3 = ["color", "title", "num", "className"],
4
- _excluded4 = ["title", "description", "icon", "iconColor", "iconBackgroundType", "iconBackgroundColor", "goback", "operation", "extra", "image", "loading", "breadcrumb", "tags", "data", "info", "children", "className", "style"];
2
+ _excluded2 = ["color", "title", "num", "className"],
3
+ _excluded3 = ["title", "description", "icon", "iconColor", "iconBackgroundType", "iconBackgroundColor", "goback", "operation", "extra", "image", "loading", "breadcrumb", "tags", "data", "info", "children", "className", "style"];
5
4
 
6
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
7
6
 
@@ -17,8 +16,9 @@ import React from 'react';
17
16
  import { useHistory } from 'react-router-dom';
18
17
  import classnames from 'classnames';
19
18
  import TeamixIcon from '@teamix/icon';
20
- import { Breadcrumb, Tag } from '@alicloudfe/components';
21
- import { baseClass } from '@teamix/utils';
19
+ import { Breadcrumb } from '@alicloudfe/components';
20
+ import { baseClass, goToLink } from '@teamix/utils';
21
+ import { renderTags } from '../utils/components/tags';
22
22
  import { ProActionGroup } from '../actions';
23
23
  import { ProSkeletonRaw } from '../skeleton';
24
24
  import ProInfo from '../info';
@@ -64,40 +64,6 @@ var renderActionGroup = function renderActionGroup(group, defaultProps) {
64
64
  return group;
65
65
  };
66
66
 
67
- var renderTags = function renderTags(tags) {
68
- if (!tags) {
69
- return null;
70
- }
71
-
72
- return /*#__PURE__*/React.createElement(Tag.Group, {
73
- className: cls('tags')
74
- }, tags.map(function (tag, i) {
75
- // @ts-ignore
76
- var text = tag.text,
77
- children = tag.children,
78
- closable = tag.closable,
79
- others = _objectWithoutProperties(tag, _excluded2);
80
-
81
- if (closable) {
82
- return /*#__PURE__*/React.createElement(Tag.Closeable, _objectSpread({
83
- key: i,
84
- size: "large",
85
- style: {
86
- marginBottom: 0
87
- }
88
- }, others), text || children);
89
- }
90
-
91
- return /*#__PURE__*/React.createElement(Tag, _objectSpread({
92
- key: i,
93
- size: "large",
94
- style: {
95
- marginBottom: 0
96
- }
97
- }, others), text || children);
98
- }));
99
- };
100
-
101
67
  var isPresetColor = function isPresetColor(color) {
102
68
  if (!color) {
103
69
  return false;
@@ -135,7 +101,7 @@ var renderData = function renderData(data) {
135
101
  title = item.title,
136
102
  num = item.num,
137
103
  customClassName = item.className,
138
- others = _objectWithoutProperties(item, _excluded3);
104
+ others = _objectWithoutProperties(item, _excluded2);
139
105
 
140
106
  var _getColorAndStyle = getColorAndStyle(color),
141
107
  className = _getColorAndStyle.className,
@@ -183,7 +149,7 @@ var ProPageHeader = function ProPageHeader(props) {
183
149
  children = props.children,
184
150
  className = props.className,
185
151
  style = props.style,
186
- others = _objectWithoutProperties(props, _excluded4);
152
+ others = _objectWithoutProperties(props, _excluded3);
187
153
 
188
154
  var history = useHistory();
189
155
  var backgroundImage = image ? "url('".concat(image, "')") : undefined;
@@ -201,12 +167,22 @@ var ProPageHeader = function ProPageHeader(props) {
201
167
  iconClass = _getColorAndStyle2.className,
202
168
  iconStyle = _getColorAndStyle2.style;
203
169
 
204
- var onBack = function onBack() {
170
+ var onBack = function onBack(e) {
171
+ if (!goback) {
172
+ return;
173
+ }
174
+
175
+ if (typeof goback === 'function') {
176
+ goback(e);
177
+ return;
178
+ }
179
+
205
180
  if (goback === true) {
206
181
  history.go(-1);
207
- } else if (typeof goback === 'string') {
208
- history.push && history.push(goback);
182
+ return;
209
183
  }
184
+
185
+ goToLink(goback, history);
210
186
  };
211
187
 
212
188
  return /*#__PURE__*/React.createElement(React.Fragment, null, goback && /*#__PURE__*/React.createElement(TeamixIcon, {
@@ -214,14 +190,14 @@ var ProPageHeader = function ProPageHeader(props) {
214
190
  onClick: onBack,
215
191
  type: "return-line",
216
192
  size: "large"
217
- }), icon && /*#__PURE__*/React.createElement(TeamixIcon, {
193
+ }), icon && (typeof icon === 'string' ? /*#__PURE__*/React.createElement(TeamixIcon, {
218
194
  className: classnames(iconClass, cls('title-icon')),
219
195
  style: iconStyle,
220
196
  type: icon,
221
197
  size: "large"
222
- }), /*#__PURE__*/React.createElement("span", {
198
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null, icon)), /*#__PURE__*/React.createElement("span", {
223
199
  className: cls('title-name')
224
- }, title), renderTags(tags));
200
+ }, title), renderTags(tags, 'large'));
225
201
  };
226
202
 
227
203
  return /*#__PURE__*/React.createElement("header", _objectSpread({
@@ -124,17 +124,6 @@ $prefix: 'teamix-pro-page-header';
124
124
  cursor: pointer;
125
125
  }
126
126
 
127
- .#{$prefix}-tags {
128
- display: inline-flex;
129
- align-items: center;
130
-
131
- & > div {
132
- &:last-child {
133
- margin-right: 0;
134
- }
135
- }
136
- }
137
-
138
127
  .#{$prefix}-color {
139
128
  &-blue {
140
129
  color: var(--color-notice-5);
@@ -1,3 +1,11 @@
1
+ var _excluded = ["dataSource", "searchKey", "onSelect"];
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
+
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
+
1
9
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
10
 
3
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."); }
@@ -18,35 +26,63 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
18
26
 
19
27
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
28
 
29
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
30
+
31
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
32
+
21
33
  import { Tree } from '@alicloudfe/components';
22
- import { baseClass } from '@teamix/utils';
23
- import React, { useEffect, useState } from 'react';
34
+ import { baseClass, treeToList } from '@teamix/utils';
35
+ import React, { isValidElement, useEffect, useState } from 'react';
24
36
  var cls = baseClass('teamix-pro-sidebar-tree');
25
37
 
26
38
  var ProSidebarTree = function ProSidebarTree(props) {
27
39
  var dataSourceProp = props.dataSource,
28
- searchKey = props.searchKey; // 自动展开父节点。过滤时用
40
+ searchKey = props.searchKey,
41
+ onSelect = props.onSelect,
42
+ others = _objectWithoutProperties(props, _excluded); // 自动展开父节点。过滤时用
29
43
 
30
- var _useState = useState(),
44
+
45
+ var _useState = useState(false),
31
46
  _useState2 = _slicedToArray(_useState, 2),
32
- matchedKeys = _useState2[0],
33
- setMatchedKeys = _useState2[1];
47
+ autoExpandParent = _useState2[0],
48
+ setAutoExpandParent = _useState2[1];
34
49
 
35
50
  var _useState3 = useState(),
36
51
  _useState4 = _slicedToArray(_useState3, 2),
37
- expandedKeys = _useState4[0],
38
- setExpandedKeys = _useState4[1];
52
+ matchedKeys = _useState4[0],
53
+ setMatchedKeys = _useState4[1];
39
54
 
40
- var _useState5 = useState(dataSourceProp !== null && dataSourceProp !== void 0 ? dataSourceProp : []),
55
+ var _useState5 = useState(),
41
56
  _useState6 = _slicedToArray(_useState5, 2),
42
- dataSource = _useState6[0],
43
- setDataSource = _useState6[1];
57
+ expandedKeys = _useState6[0],
58
+ setExpandedKeys = _useState6[1];
59
+
60
+ var _useState7 = useState(dataSourceProp !== null && dataSourceProp !== void 0 ? dataSourceProp : []),
61
+ _useState8 = _slicedToArray(_useState7, 2),
62
+ dataSource = _useState8[0],
63
+ setDataSource = _useState8[1];
44
64
 
65
+ useEffect(function () {
66
+ getAllExpend();
67
+ }, []);
45
68
  useEffect(function () {
46
69
  filterDataSource(searchKey !== null && searchKey !== void 0 ? searchKey : '');
47
- }, [searchKey]); // 过滤
70
+ }, [searchKey]); // 获取全部展开节点key
71
+
72
+ var getAllExpend = function getAllExpend() {
73
+ var allKeys = treeToList(dataSource).map(function (item) {
74
+ return item.value;
75
+ });
76
+ setExpandedKeys(allKeys);
77
+ }; // 过滤
78
+
48
79
 
49
80
  var filterDataSource = function filterDataSource(value) {
81
+ if (!value) {
82
+ setExpandedKeys([]);
83
+ getAllExpend();
84
+ }
85
+
50
86
  value = value.trim();
51
87
  var matchedKeys = [];
52
88
 
@@ -58,7 +94,7 @@ var ProSidebarTree = function ProSidebarTree(props) {
58
94
  var loop = function loop(data) {
59
95
  return data.forEach(function (item) {
60
96
  if (item.label.indexOf(value) > -1) {
61
- matchedKeys.push(item.key);
97
+ matchedKeys.push(item.value);
62
98
  }
63
99
 
64
100
  if (item.children && item.children.length) {
@@ -69,27 +105,58 @@ var ProSidebarTree = function ProSidebarTree(props) {
69
105
 
70
106
  loop(dataSource);
71
107
  setExpandedKeys(_toConsumableArray(matchedKeys));
108
+ setAutoExpandParent(true);
72
109
  setMatchedKeys(matchedKeys);
73
110
  };
74
111
 
75
112
  var filterTreeNode = function filterTreeNode(node) {
76
113
  return matchedKeys && matchedKeys.indexOf(node.props.eventKey) > -1;
114
+ }; // 节点展开回调
115
+
116
+
117
+ var handleExpand = function handleExpand(key) {
118
+ setExpandedKeys(key);
119
+ setAutoExpandParent(false);
120
+ }; // 渲染树节点
121
+
122
+
123
+ var renderTreeNode = function renderTreeNode(data) {
124
+ return data.map(function (item) {
125
+ return /*#__PURE__*/React.createElement(Tree.Node, {
126
+ key: item.value,
127
+ label: renderTreeNodeItem(item)
128
+ }, item.children && item.children.length > 0 && renderTreeNode(item.children));
129
+ });
130
+ }; // 渲染单个树节点 label
131
+
132
+
133
+ var renderTreeNodeItem = function renderTreeNodeItem(data) {
134
+ var node = /*#__PURE__*/React.createElement(React.Fragment, null, data.label);
135
+
136
+ if (data.tag) {
137
+ if ( /*#__PURE__*/isValidElement(data.tag)) {
138
+ node = /*#__PURE__*/React.createElement(React.Fragment, null, node, data.tag);
139
+ }
140
+ }
141
+
142
+ return node;
77
143
  };
78
144
 
79
145
  return /*#__PURE__*/React.createElement("div", {
80
146
  className: cls()
81
- }, /*#__PURE__*/React.createElement(Tree, {
82
- draggable: true,
147
+ }, /*#__PURE__*/React.createElement(Tree, _objectSpread({
83
148
  defaultExpandAll: true,
84
149
  isLabelBlock: true,
85
150
  isNodeBlock: {
86
151
  defaultPaddingLeft: 8,
87
152
  indent: 16
88
153
  },
89
- dataSource: dataSource,
90
154
  filterTreeNode: filterTreeNode,
91
- expandedKeys: expandedKeys
92
- }));
155
+ expandedKeys: expandedKeys,
156
+ onExpand: handleExpand,
157
+ autoExpandParent: autoExpandParent,
158
+ onSelect: onSelect
159
+ }, others), renderTreeNode(dataSource)));
93
160
  };
94
161
 
95
162
  export default ProSidebarTree;