@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.
- package/dist/pro.css +1 -1
- package/dist/pro.js +1787 -812
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/actions/base.d.ts +16 -6
- package/es/actions/base.js +66 -12
- package/es/actions/confirm.d.ts +1 -1
- package/es/actions/danger-confirm.d.ts +1 -1
- package/es/actions/dialog-component.d.ts +1 -1
- package/es/actions/dialog-form.d.ts +1 -1
- package/es/actions/dialog-form.js +4 -4
- package/es/actions/dialog-info.d.ts +1 -1
- package/es/actions/dialog-table.d.ts +1 -1
- package/es/actions/dialog.d.ts +6 -2
- package/es/actions/dialog.js +19 -24
- package/es/actions/drawer-form.d.ts +1 -1
- package/es/actions/drawer-info.d.ts +1 -1
- package/es/actions/drawer-table.d.ts +1 -1
- package/es/actions/drawer.d.ts +1 -1
- package/es/actions/error.d.ts +1 -1
- package/es/actions/index.js +25 -22
- package/es/actions/index.scss +28 -7
- package/es/actions/link.d.ts +2 -2
- package/es/actions/link.js +2 -2
- package/es/actions/notice.d.ts +1 -1
- package/es/actions/request.d.ts +1 -1
- package/es/actions/request.js +2 -2
- package/es/card/index.d.ts +10 -1
- package/es/card/index.js +20 -6
- package/es/card/index.scss +19 -0
- package/es/card/tab.d.ts +6 -0
- package/es/card/tab.js +27 -0
- package/es/form/Filter/index.d.ts +2 -5
- package/es/form/Filter/index.js +3 -44
- package/es/form/Filter/index.scss +71 -0
- package/es/form/Filter/index2.d.ts +8 -0
- package/es/form/Filter/index2.js +318 -0
- package/es/form/ProForm/index.js +3 -23
- package/es/form/ProForm/index.scss +10 -19
- package/es/form/ProForm/useFormDisplayValues.d.ts +3 -5
- package/es/form/ProForm/useFormDisplayValues.js +44 -38
- package/es/form/SchemaForm/index.js +7 -6
- package/es/form/index.d.ts +2 -1
- package/es/form/index.js +3 -2
- package/es/form/typing.d.ts +3 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/page-header/index.d.ts +20 -11
- package/es/page-header/index.js +23 -47
- package/es/page-header/index.scss +0 -11
- package/es/sidebar/components/tree/index.js +85 -18
- package/es/sidebar/index.js +9 -5
- package/es/sidebar/typing.d.ts +14 -1
- package/es/table/components/Filter/index.js +11 -9
- package/es/table/components/Filter/index.scss +7 -3
- package/es/table/components/Layout/index.js +10 -1
- package/es/table/index.js +3 -4
- package/es/utils/components/tags/index.d.ts +11 -0
- package/es/utils/components/tags/index.js +50 -0
- package/es/utils/components/tags/index.scss +12 -0
- package/lib/actions/base.d.ts +16 -6
- package/lib/actions/base.js +67 -12
- package/lib/actions/confirm.d.ts +1 -1
- package/lib/actions/danger-confirm.d.ts +1 -1
- package/lib/actions/dialog-component.d.ts +1 -1
- package/lib/actions/dialog-form.d.ts +1 -1
- package/lib/actions/dialog-form.js +3 -3
- package/lib/actions/dialog-info.d.ts +1 -1
- package/lib/actions/dialog-table.d.ts +1 -1
- package/lib/actions/dialog.d.ts +6 -2
- package/lib/actions/dialog.js +18 -23
- package/lib/actions/drawer-form.d.ts +1 -1
- package/lib/actions/drawer-info.d.ts +1 -1
- package/lib/actions/drawer-table.d.ts +1 -1
- package/lib/actions/drawer.d.ts +1 -1
- package/lib/actions/error.d.ts +1 -1
- package/lib/actions/index.js +25 -22
- package/lib/actions/index.scss +28 -7
- package/lib/actions/link.d.ts +2 -2
- package/lib/actions/link.js +2 -2
- package/lib/actions/notice.d.ts +1 -1
- package/lib/actions/request.d.ts +1 -1
- package/lib/actions/request.js +2 -2
- package/lib/card/index.d.ts +10 -1
- package/lib/card/index.js +22 -5
- package/lib/card/index.scss +19 -0
- package/lib/card/tab.d.ts +6 -0
- package/lib/card/tab.js +39 -0
- package/lib/form/Filter/index.d.ts +2 -5
- package/lib/form/Filter/index.js +4 -45
- package/lib/form/Filter/index.scss +71 -0
- package/lib/form/Filter/index2.d.ts +8 -0
- package/lib/form/Filter/index2.js +342 -0
- package/lib/form/ProForm/index.js +3 -23
- package/lib/form/ProForm/index.scss +10 -19
- package/lib/form/ProForm/useFormDisplayValues.d.ts +3 -5
- package/lib/form/ProForm/useFormDisplayValues.js +51 -44
- package/lib/form/SchemaForm/index.js +7 -6
- package/lib/form/index.d.ts +2 -1
- package/lib/form/index.js +5 -3
- package/lib/form/typing.d.ts +3 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/page-header/index.d.ts +20 -11
- package/lib/page-header/index.js +22 -45
- package/lib/page-header/index.scss +0 -11
- package/lib/sidebar/components/tree/index.js +83 -16
- package/lib/sidebar/index.js +9 -5
- package/lib/sidebar/typing.d.ts +14 -1
- package/lib/table/components/Filter/index.js +10 -8
- package/lib/table/components/Filter/index.scss +7 -3
- package/lib/table/components/Layout/index.js +10 -1
- package/lib/table/index.js +2 -3
- package/lib/utils/components/tags/index.d.ts +11 -0
- package/lib/utils/components/tags/index.js +66 -0
- package/lib/utils/components/tags/index.scss +12 -0
- 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
|
-
|
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
|
21
|
-
var
|
22
|
-
var
|
27
|
+
var getDisplayValues = function getDisplayValues(form, values) {
|
28
|
+
var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
29
|
+
var displayValues; // 判断值的类型,递归获取每个值在该结构中的完整路径
|
23
30
|
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
29
|
-
displayValues =
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
}
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
|
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
|
-
|
67
|
+
var getFormDisplayValues = function getFormDisplayValues(form) {
|
68
|
+
return getDisplayValues(form, form.values);
|
63
69
|
};
|
64
70
|
|
65
|
-
export
|
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
|
240
|
+
var proFormSchema = useMemo(function () {
|
240
241
|
return {
|
241
242
|
type: 'object',
|
242
243
|
properties: formatSchema(schema)
|
243
244
|
};
|
244
|
-
}, []); // console.log(
|
245
|
+
}, []); // console.log(proFormSchema);
|
245
246
|
|
246
247
|
return /*#__PURE__*/React.createElement(SchemaField, {
|
247
|
-
schema:
|
248
|
+
schema: proFormSchema,
|
248
249
|
components: components,
|
249
250
|
scope: mergedScope
|
250
251
|
});
|
package/es/form/index.d.ts
CHANGED
@@ -108,7 +108,8 @@ export { createForm, FormConsumer, FormDialog, FormDrawer, FormStep, FormTab, Fo
|
|
108
108
|
/**
|
109
109
|
* 导出 Filter 组件
|
110
110
|
*/
|
111
|
-
import { AdvancedFilter, SimpleFilter
|
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
|
43
|
+
import { AdvancedFilter, SimpleFilter } from './Filter';
|
44
|
+
import { QueryFilter } from './Filter/index2';
|
44
45
|
export { AdvancedFilter, SimpleFilter, QueryFilter };
|
45
46
|
/**
|
46
47
|
* 导出 ProForm 组件,支持快速搭建表单
|
package/es/form/typing.d.ts
CHANGED
@@ -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.
|
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.
|
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 =
|
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
|
-
|
26
|
+
/** 图标 */
|
27
|
+
icon?: React.ReactNode;
|
28
|
+
/** 图标颜色 */
|
31
29
|
iconColor?: Color;
|
30
|
+
/** 图标背景类型 */
|
32
31
|
iconBackgroundType?: 'circle' | 'square';
|
32
|
+
/** 图标背景色 */
|
33
33
|
iconBackgroundColor?: Color;
|
34
|
-
|
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>;
|
package/es/page-header/index.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
var _excluded = ["text", "children"],
|
2
|
-
_excluded2 = ["
|
3
|
-
_excluded3 = ["
|
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
|
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,
|
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,
|
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
|
-
|
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
|
-
|
44
|
+
|
45
|
+
var _useState = useState(false),
|
31
46
|
_useState2 = _slicedToArray(_useState, 2),
|
32
|
-
|
33
|
-
|
47
|
+
autoExpandParent = _useState2[0],
|
48
|
+
setAutoExpandParent = _useState2[1];
|
34
49
|
|
35
50
|
var _useState3 = useState(),
|
36
51
|
_useState4 = _slicedToArray(_useState3, 2),
|
37
|
-
|
38
|
-
|
52
|
+
matchedKeys = _useState4[0],
|
53
|
+
setMatchedKeys = _useState4[1];
|
39
54
|
|
40
|
-
var _useState5 = useState(
|
55
|
+
var _useState5 = useState(),
|
41
56
|
_useState6 = _slicedToArray(_useState5, 2),
|
42
|
-
|
43
|
-
|
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.
|
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;
|