yootd 0.0.43 → 0.0.45
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/LICENSE +21 -21
- package/README.md +43 -43
- package/dist/Preview/components/preview/phone.scss +8 -8
- package/dist/Preview/index.scss +35 -35
- package/dist/Preview/types/type.d.ts +22 -22
- package/dist/anchor/index.scss +23 -23
- package/dist/approval-process/index.scss +95 -95
- package/dist/areas/index.scss +21 -21
- package/dist/areas/types/types.d.ts +40 -40
- package/dist/areas-treeSelect/index.scss +6 -6
- package/dist/areas-treeSelect/types/type.d.ts +39 -39
- package/dist/aside/components/SortableItem.scss +93 -93
- package/dist/aside/index.scss +25 -25
- package/dist/aside/types/types.d.ts +44 -44
- package/dist/badge/index.scss +5 -5
- package/dist/buildings/types/types.d.ts +21 -21
- package/dist/button/index.scss +30 -30
- package/dist/cascader/index.scss +5 -5
- package/dist/courses/types/types.d.ts +18 -18
- package/dist/department/types/types.d.ts +23 -23
- package/dist/dictionary/types/types.d.ts +14 -14
- package/dist/drawer-modal/index.scss +39 -39
- package/dist/drawer-modal/types/types.d.ts +3 -3
- package/dist/dropdown/assets/arrow-down.svg +5 -5
- package/dist/empty/index.scss +15 -15
- package/dist/group-title/index.scss +31 -31
- package/dist/image/index.scss +26 -26
- package/dist/input/index.scss +5 -5
- package/dist/job-title/types/types.d.ts +17 -17
- package/dist/modal/index.scss +76 -76
- package/dist/pagination/index.scss +47 -47
- package/dist/role/types/types.d.ts +22 -22
- package/dist/school/index.scss +21 -21
- package/dist/school/types/types.d.ts +85 -85
- package/dist/state/index.scss +89 -89
- package/dist/steps/index.scss +32 -32
- package/dist/student-dropdown/types/types.d.ts +44 -44
- package/dist/table/components/primary-header-row/index.scss +58 -58
- package/dist/table/components/primary-tbody-row/index.scss +5 -5
- package/dist/table/index.module.scss +9 -9
- package/dist/table/index.scss +33 -33
- package/dist/tabs/index.scss +86 -86
- package/dist/tag/index.scss +4 -4
- package/dist/teacher/index.js +1 -1
- package/dist/teacher/types/types.d.ts +33 -31
- package/dist/tree/index copy.d.ts +27 -0
- package/dist/tree/index copy.js +231 -0
- package/dist/tree/index.d.ts +6 -1
- package/dist/tree/index.js +3 -3
- package/dist/tree/index.scss +25 -25
- package/dist/upload/index.scss +115 -115
- package/dist/user-dropdown/types/types.d.ts +45 -45
- package/dist/video-player/index.js +20 -20
- package/dist/video-player/index.scss +310 -310
- package/dist/year-term/index.scss +21 -21
- package/dist/year-term/types/types.d.ts +28 -28
- package/dist/zones/index.module.scss +23 -23
- package/dist/zones/types/types.d.ts +26 -26
- package/package.json +101 -101
package/dist/table/index.scss
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
.yot-table {
|
2
|
-
// .yot-table {
|
3
|
-
// &--primary {
|
4
|
-
// .ant-table-container {
|
5
|
-
// .ant-table-content {
|
6
|
-
// thead {
|
7
|
-
// tr {
|
8
|
-
// th {
|
9
|
-
// background-color: var(--ant-color-primary);
|
10
|
-
// color: var(--ant-color-bg-base);
|
11
|
-
// }
|
12
|
-
// }
|
13
|
-
// }
|
14
|
-
// }
|
15
|
-
// }
|
16
|
-
// }
|
17
|
-
|
18
|
-
&-header {
|
19
|
-
&:hover {
|
20
|
-
&__icon {
|
21
|
-
position: absolute;
|
22
|
-
right: 16px;
|
23
|
-
top: 50%;
|
24
|
-
transform: translateY(-50%);
|
25
|
-
cursor: pointer;
|
26
|
-
|
27
|
-
path {
|
28
|
-
fill: var(--ant-color-primary-bg);
|
29
|
-
}
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}
|
1
|
+
.yot-table {
|
2
|
+
// .yot-table {
|
3
|
+
// &--primary {
|
4
|
+
// .ant-table-container {
|
5
|
+
// .ant-table-content {
|
6
|
+
// thead {
|
7
|
+
// tr {
|
8
|
+
// th {
|
9
|
+
// background-color: var(--ant-color-primary);
|
10
|
+
// color: var(--ant-color-bg-base);
|
11
|
+
// }
|
12
|
+
// }
|
13
|
+
// }
|
14
|
+
// }
|
15
|
+
// }
|
16
|
+
// }
|
17
|
+
|
18
|
+
&-header {
|
19
|
+
&:hover {
|
20
|
+
&__icon {
|
21
|
+
position: absolute;
|
22
|
+
right: 16px;
|
23
|
+
top: 50%;
|
24
|
+
transform: translateY(-50%);
|
25
|
+
cursor: pointer;
|
26
|
+
|
27
|
+
path {
|
28
|
+
fill: var(--ant-color-primary-bg);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
package/dist/tabs/index.scss
CHANGED
@@ -1,86 +1,86 @@
|
|
1
|
-
.yot-tabs {
|
2
|
-
// 覆盖 ant 默认样式
|
3
|
-
.ant-tabs-top > .ant-tabs-nav .ant-tabs-ink-bar,
|
4
|
-
.ant-tabs-top > div > .ant-tabs-nav .ant-tabs-ink-bar {
|
5
|
-
bottom: 1px;
|
6
|
-
}
|
7
|
-
&-large {
|
8
|
-
.ant-tabs-tab.ant-tabs-tab-active {
|
9
|
-
color: var(--ant-color-primary);
|
10
|
-
}
|
11
|
-
.ant-tabs-tab-btn {
|
12
|
-
font-size: var(--ant-font-size-lg);
|
13
|
-
}
|
14
|
-
.ant-tabs-nav-wrap {
|
15
|
-
background-color: white;
|
16
|
-
padding-left: 1.5rem;
|
17
|
-
padding-right: 1.5rem;
|
18
|
-
}
|
19
|
-
.ant-tabs-nav::before {
|
20
|
-
content: '';
|
21
|
-
position: absolute;
|
22
|
-
right: 1.5rem;
|
23
|
-
left: 1.5rem;
|
24
|
-
z-index: 10;
|
25
|
-
border-bottom-width: var(--ant-line-width);
|
26
|
-
border-bottom-style: solid;
|
27
|
-
border-bottom-color: #e5e5e5;
|
28
|
-
}
|
29
|
-
}
|
30
|
-
&-small {
|
31
|
-
.ant-tabs-tab.ant-tabs-tab-active {
|
32
|
-
color: var(--ant-color-primary);
|
33
|
-
}
|
34
|
-
.ant-tabs-tab-btn {
|
35
|
-
font-size: var(--ant-font-size);
|
36
|
-
}
|
37
|
-
.ant-tabs-nav-wrap {
|
38
|
-
background-color: white;
|
39
|
-
padding-left: 1.5rem;
|
40
|
-
padding-right: 1.5rem;
|
41
|
-
}
|
42
|
-
.ant-tabs-nav::before {
|
43
|
-
content: '';
|
44
|
-
position: absolute;
|
45
|
-
right: 1.5rem;
|
46
|
-
left: 1.5rem;
|
47
|
-
z-index: 10;
|
48
|
-
border-bottom-width: var(--ant-line-width);
|
49
|
-
border-bottom-style: solid;
|
50
|
-
border-bottom-color: #e5e5e5;
|
51
|
-
}
|
52
|
-
}
|
53
|
-
&-capsule {
|
54
|
-
&__content {
|
55
|
-
padding-top: var(--ant-margin);
|
56
|
-
padding-bottom: var(--ant-margin);
|
57
|
-
box-sizing: border-box;
|
58
|
-
background-color: white;
|
59
|
-
padding-left: var(--ant-padding-lg);
|
60
|
-
padding-right: var(--ant-padding-lg);
|
61
|
-
}
|
62
|
-
.ant-radio-button-wrapper.ant-radio-button-wrapper-checked.css-var-r4.ant-radio-css-var {
|
63
|
-
padding-left: var(--ant-padding);
|
64
|
-
padding-right: var(--ant-padding);
|
65
|
-
box-sizing: border-box;
|
66
|
-
font-size: var(--ant-font-size);
|
67
|
-
color: var(--ant-color-primary);
|
68
|
-
}
|
69
|
-
.ant-radio-button.ant-radio-button-checked {
|
70
|
-
font-size: var(--ant-font-size);
|
71
|
-
color: var(--ant-color-primary);
|
72
|
-
}
|
73
|
-
&__value {
|
74
|
-
font-size: 14px;
|
75
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
|
76
|
-
'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji',
|
77
|
-
'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
78
|
-
color: #000000e0;
|
79
|
-
}
|
80
|
-
}
|
81
|
-
&-istabmargin {
|
82
|
-
.ant-tabs-nav {
|
83
|
-
margin-bottom: 0;
|
84
|
-
}
|
85
|
-
}
|
86
|
-
}
|
1
|
+
.yot-tabs {
|
2
|
+
// 覆盖 ant 默认样式
|
3
|
+
.ant-tabs-top > .ant-tabs-nav .ant-tabs-ink-bar,
|
4
|
+
.ant-tabs-top > div > .ant-tabs-nav .ant-tabs-ink-bar {
|
5
|
+
bottom: 1px;
|
6
|
+
}
|
7
|
+
&-large {
|
8
|
+
.ant-tabs-tab.ant-tabs-tab-active {
|
9
|
+
color: var(--ant-color-primary);
|
10
|
+
}
|
11
|
+
.ant-tabs-tab-btn {
|
12
|
+
font-size: var(--ant-font-size-lg);
|
13
|
+
}
|
14
|
+
.ant-tabs-nav-wrap {
|
15
|
+
background-color: white;
|
16
|
+
padding-left: 1.5rem;
|
17
|
+
padding-right: 1.5rem;
|
18
|
+
}
|
19
|
+
.ant-tabs-nav::before {
|
20
|
+
content: '';
|
21
|
+
position: absolute;
|
22
|
+
right: 1.5rem;
|
23
|
+
left: 1.5rem;
|
24
|
+
z-index: 10;
|
25
|
+
border-bottom-width: var(--ant-line-width);
|
26
|
+
border-bottom-style: solid;
|
27
|
+
border-bottom-color: #e5e5e5;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
&-small {
|
31
|
+
.ant-tabs-tab.ant-tabs-tab-active {
|
32
|
+
color: var(--ant-color-primary);
|
33
|
+
}
|
34
|
+
.ant-tabs-tab-btn {
|
35
|
+
font-size: var(--ant-font-size);
|
36
|
+
}
|
37
|
+
.ant-tabs-nav-wrap {
|
38
|
+
background-color: white;
|
39
|
+
padding-left: 1.5rem;
|
40
|
+
padding-right: 1.5rem;
|
41
|
+
}
|
42
|
+
.ant-tabs-nav::before {
|
43
|
+
content: '';
|
44
|
+
position: absolute;
|
45
|
+
right: 1.5rem;
|
46
|
+
left: 1.5rem;
|
47
|
+
z-index: 10;
|
48
|
+
border-bottom-width: var(--ant-line-width);
|
49
|
+
border-bottom-style: solid;
|
50
|
+
border-bottom-color: #e5e5e5;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
&-capsule {
|
54
|
+
&__content {
|
55
|
+
padding-top: var(--ant-margin);
|
56
|
+
padding-bottom: var(--ant-margin);
|
57
|
+
box-sizing: border-box;
|
58
|
+
background-color: white;
|
59
|
+
padding-left: var(--ant-padding-lg);
|
60
|
+
padding-right: var(--ant-padding-lg);
|
61
|
+
}
|
62
|
+
.ant-radio-button-wrapper.ant-radio-button-wrapper-checked.css-var-r4.ant-radio-css-var {
|
63
|
+
padding-left: var(--ant-padding);
|
64
|
+
padding-right: var(--ant-padding);
|
65
|
+
box-sizing: border-box;
|
66
|
+
font-size: var(--ant-font-size);
|
67
|
+
color: var(--ant-color-primary);
|
68
|
+
}
|
69
|
+
.ant-radio-button.ant-radio-button-checked {
|
70
|
+
font-size: var(--ant-font-size);
|
71
|
+
color: var(--ant-color-primary);
|
72
|
+
}
|
73
|
+
&__value {
|
74
|
+
font-size: 14px;
|
75
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
|
76
|
+
'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji',
|
77
|
+
'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
78
|
+
color: #000000e0;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
&-istabmargin {
|
82
|
+
.ant-tabs-nav {
|
83
|
+
margin-bottom: 0;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
package/dist/tag/index.scss
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
.yot-tag {
|
2
|
-
&__text {
|
3
|
-
font-weight: bold;
|
4
|
-
}
|
1
|
+
.yot-tag {
|
2
|
+
&__text {
|
3
|
+
font-weight: bold;
|
4
|
+
}
|
5
5
|
}
|
package/dist/teacher/index.js
CHANGED
@@ -48,7 +48,7 @@ export var Teacher = function Teacher(_ref) {
|
|
48
48
|
value: item.userId
|
49
49
|
};
|
50
50
|
});
|
51
|
-
}, [teacherData]);
|
51
|
+
}, [teacherData, label, connectors]);
|
52
52
|
return /*#__PURE__*/React.createElement(Select, _extends({
|
53
53
|
options: allTeacherOptions,
|
54
54
|
placeholder: placeholder,
|
@@ -1,31 +1,33 @@
|
|
1
|
-
import { SelectProps } from 'yootd';
|
2
|
-
|
3
|
-
export interface PageData<T> {
|
4
|
-
content: T[];
|
5
|
-
page: {
|
6
|
-
number: number;
|
7
|
-
size: number;
|
8
|
-
totalElements: number;
|
9
|
-
totalPages: number;
|
10
|
-
};
|
11
|
-
}
|
12
|
-
// 查询老师返回的数据类型
|
13
|
-
export interface IteacherItem {
|
14
|
-
[key: string]: string | number;
|
15
|
-
userId: number; // 老师ID
|
16
|
-
personalName: string; // 老师姓名
|
17
|
-
personalMobile?: string; // 手机号
|
18
|
-
uniqueNumber?: string; // 工号
|
19
|
-
nationName?: string; // 民族
|
20
|
-
gender?: number; // 性别
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
| '
|
25
|
-
| '
|
26
|
-
| '
|
27
|
-
| '
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
1
|
+
import { SelectProps } from 'yootd';
|
2
|
+
|
3
|
+
export interface PageData<T> {
|
4
|
+
content: T[];
|
5
|
+
page: {
|
6
|
+
number: number;
|
7
|
+
size: number;
|
8
|
+
totalElements: number;
|
9
|
+
totalPages: number;
|
10
|
+
};
|
11
|
+
}
|
12
|
+
// 查询老师返回的数据类型
|
13
|
+
export interface IteacherItem {
|
14
|
+
[key: string]: string | number;
|
15
|
+
userId: number; // 老师ID
|
16
|
+
personalName: string; // 老师姓名
|
17
|
+
personalMobile?: string; // 手机号
|
18
|
+
uniqueNumber?: string; // 工号
|
19
|
+
nationName?: string; // 民族
|
20
|
+
gender?: number; // 性别
|
21
|
+
personalEmail?: string; // 邮箱
|
22
|
+
}
|
23
|
+
type LabelOptions =
|
24
|
+
| 'personalName'
|
25
|
+
| 'uniqueNumber'
|
26
|
+
| 'personalMobile'
|
27
|
+
| 'nationName'
|
28
|
+
| 'genderName'
|
29
|
+
| 'personalEmail';
|
30
|
+
export type TeacherProps = SelectProps & {
|
31
|
+
label?: LabelOptions[];
|
32
|
+
connectors?: string;
|
33
|
+
};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import type { TreeDataNode as AntTreeDataNode, TreeProps as AntTreeProps } from 'antd';
|
2
|
+
import React from 'react';
|
3
|
+
import './index.scss';
|
4
|
+
export type { AntTreeNode, AntTreeNodeCheckedEvent, AntTreeNodeExpandedEvent, AntTreeNodeMouseEvent, AntTreeNodeProps, AntTreeNodeSelectedEvent, AntdTreeNodeAttribute, DirectoryTreeExpandAction, DirectoryTreeProps, EventDataNode, } from 'antd/es/tree';
|
5
|
+
export type TreeProps = AntTreeProps & {
|
6
|
+
showChildNumbers?: boolean;
|
7
|
+
placeholder?: string;
|
8
|
+
showSearch?: boolean;
|
9
|
+
type?: string;
|
10
|
+
depth?: number;
|
11
|
+
notRequireSchool?: boolean;
|
12
|
+
areaType?: number;
|
13
|
+
areaSubType?: number;
|
14
|
+
requireLastLevel?: boolean;
|
15
|
+
};
|
16
|
+
export type TreeDataNode = AntTreeDataNode;
|
17
|
+
export declare const Tree: React.ForwardRefExoticComponent<AntTreeProps<AntTreeDataNode> & {
|
18
|
+
showChildNumbers?: boolean | undefined;
|
19
|
+
placeholder?: string | undefined;
|
20
|
+
showSearch?: boolean | undefined;
|
21
|
+
type?: string | undefined;
|
22
|
+
depth?: number | undefined;
|
23
|
+
notRequireSchool?: boolean | undefined;
|
24
|
+
areaType?: number | undefined;
|
25
|
+
areaSubType?: number | undefined;
|
26
|
+
requireLastLevel?: boolean | undefined;
|
27
|
+
} & React.RefAttributes<any>>;
|
@@ -0,0 +1,231 @@
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
+
var _excluded = ["className", "treeData", "placeholder", "showChildNumbers", "showIcon", "showSearch", "type", "titleRender"];
|
3
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
4
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
5
|
+
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."); }
|
6
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
12
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
13
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
14
|
+
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."); }
|
15
|
+
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); }
|
16
|
+
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; }
|
17
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
18
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
19
|
+
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; }
|
20
|
+
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; }
|
21
|
+
import { Tree as AntTree } from 'antd';
|
22
|
+
import React, { forwardRef, useCallback, useEffect, useMemo, useState } from 'react';
|
23
|
+
import { Input } from "./..";
|
24
|
+
import "./index.scss";
|
25
|
+
import { useBem } from "../hooks/useBem";
|
26
|
+
import { BedIcon } from "./components/BedIcon";
|
27
|
+
import { CampusIcon } from "./components/CampusIcon";
|
28
|
+
import { DeptIcon } from "./components/DeptIcon";
|
29
|
+
import { FloorIcon } from "./components/FloorIcon";
|
30
|
+
import { RoomIcon } from "./components/RoomIcon";
|
31
|
+
import { SchoolIcon } from "./components/SchoolIcon";
|
32
|
+
import { TierlIcon } from "./components/TierlIcon";
|
33
|
+
var Search = Input.Search;
|
34
|
+
var dataList = [];
|
35
|
+
var generateList = function generateList(data) {
|
36
|
+
for (var i = 0; i < data.length; i++) {
|
37
|
+
var node = data[i];
|
38
|
+
var key = node.key,
|
39
|
+
title = node.title;
|
40
|
+
dataList.push({
|
41
|
+
key: key,
|
42
|
+
title: title
|
43
|
+
});
|
44
|
+
if (node.children) {
|
45
|
+
generateList(node.children);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
};
|
49
|
+
var getParentKey = function getParentKey(key, tree) {
|
50
|
+
var parentKey;
|
51
|
+
for (var i = 0; i < tree.length; i++) {
|
52
|
+
var node = tree[i];
|
53
|
+
if (node.children) {
|
54
|
+
if (node.children.some(function (item) {
|
55
|
+
return item.key === key;
|
56
|
+
})) {
|
57
|
+
parentKey = node.key;
|
58
|
+
} else if (getParentKey(key, node.children)) {
|
59
|
+
parentKey = getParentKey(key, node.children);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
return parentKey;
|
64
|
+
};
|
65
|
+
export var Tree = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
66
|
+
var className = _ref.className,
|
67
|
+
treeData = _ref.treeData,
|
68
|
+
_ref$placeholder = _ref.placeholder,
|
69
|
+
placeholder = _ref$placeholder === void 0 ? '请输入...' : _ref$placeholder,
|
70
|
+
_ref$showChildNumbers = _ref.showChildNumbers,
|
71
|
+
showChildNumbers = _ref$showChildNumbers === void 0 ? false : _ref$showChildNumbers,
|
72
|
+
_ref$showIcon = _ref.showIcon,
|
73
|
+
showIcon = _ref$showIcon === void 0 ? false : _ref$showIcon,
|
74
|
+
_ref$showSearch = _ref.showSearch,
|
75
|
+
showSearch = _ref$showSearch === void 0 ? false : _ref$showSearch,
|
76
|
+
type = _ref.type,
|
77
|
+
titleRender = _ref.titleRender,
|
78
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
79
|
+
var mb = useBem('tree');
|
80
|
+
var _useState = useState([]),
|
81
|
+
_useState2 = _slicedToArray(_useState, 2),
|
82
|
+
expandedKeys = _useState2[0],
|
83
|
+
setExpandedKeys = _useState2[1];
|
84
|
+
var _useState3 = useState(''),
|
85
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
86
|
+
searchValue = _useState4[0],
|
87
|
+
setSearchValue = _useState4[1];
|
88
|
+
var _useState5 = useState(true),
|
89
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
90
|
+
autoExpandParent = _useState6[0],
|
91
|
+
setAutoExpandParent = _useState6[1];
|
92
|
+
var _useState7 = useState([]),
|
93
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
94
|
+
defaultData = _useState8[0],
|
95
|
+
setDefaultData = _useState8[1];
|
96
|
+
var getSpaceIcon = useCallback(function (currentLevel, selected) {
|
97
|
+
var icons = [SchoolIcon, CampusIcon, FloorIcon, TierlIcon, RoomIcon, BedIcon];
|
98
|
+
var IconComponent = icons[currentLevel];
|
99
|
+
return IconComponent ? /*#__PURE__*/React.createElement(IconComponent, {
|
100
|
+
className: "".concat(mb.e('icon'), " ").concat(selected ? mb.is('selected') : '')
|
101
|
+
}) : null;
|
102
|
+
}, []);
|
103
|
+
var getDeptIcon = useCallback(function (selected) {
|
104
|
+
return /*#__PURE__*/React.createElement(DeptIcon, {
|
105
|
+
className: "".concat(mb.e('icon'), " ").concat(selected ? mb.is('selected') : '')
|
106
|
+
});
|
107
|
+
}, []);
|
108
|
+
var formatTreeData = function formatTreeData(treeData) {
|
109
|
+
var currentLevel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
110
|
+
return treeData === null || treeData === void 0 ? void 0 : treeData.map(function (t) {
|
111
|
+
if (t.children == null) {
|
112
|
+
return _objectSpread(_objectSpread({}, t), {}, {
|
113
|
+
icon: t.icon != null ? t.icon : function (_ref2) {
|
114
|
+
var selected = _ref2.selected;
|
115
|
+
return type === 'dept' ? getDeptIcon(selected) : type === 'area' ? getSpaceIcon(currentLevel, selected) : null;
|
116
|
+
}
|
117
|
+
});
|
118
|
+
} else {
|
119
|
+
var _t$children;
|
120
|
+
var _title;
|
121
|
+
if (typeof t.title === 'function') {
|
122
|
+
_title = t.title(t);
|
123
|
+
} else {
|
124
|
+
_title = t.title;
|
125
|
+
}
|
126
|
+
return _objectSpread(_objectSpread({}, t), {}, {
|
127
|
+
title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, _title), showChildNumbers ? /*#__PURE__*/React.createElement("span", {
|
128
|
+
style: {
|
129
|
+
marginLeft: 10
|
130
|
+
}
|
131
|
+
}, "(", (_t$children = t.children) === null || _t$children === void 0 ? void 0 : _t$children.length, ")") : null),
|
132
|
+
icon: t.icon != null ? t.icon : function (_ref3) {
|
133
|
+
var selected = _ref3.selected;
|
134
|
+
return type === 'dept' ? getDeptIcon(selected) : type === 'area' ? getSpaceIcon(currentLevel, selected) : null;
|
135
|
+
},
|
136
|
+
children: t.children != null ? formatTreeData(t.children, currentLevel + 1) : []
|
137
|
+
});
|
138
|
+
}
|
139
|
+
});
|
140
|
+
};
|
141
|
+
var onExpand = function onExpand(newExpandedKeys) {
|
142
|
+
setExpandedKeys(newExpandedKeys);
|
143
|
+
setAutoExpandParent(false);
|
144
|
+
};
|
145
|
+
var onChange = function onChange(e) {
|
146
|
+
var value = e.target.value;
|
147
|
+
var newExpandedKeys = dataList.map(function (item) {
|
148
|
+
if (item.title.indexOf(value) > -1) {
|
149
|
+
return getParentKey(item.key, defaultData);
|
150
|
+
}
|
151
|
+
return null;
|
152
|
+
}).filter(function (item, i, self) {
|
153
|
+
return !!(item && self.indexOf(item) === i);
|
154
|
+
});
|
155
|
+
setExpandedKeys(newExpandedKeys);
|
156
|
+
setSearchValue(value);
|
157
|
+
setAutoExpandParent(true);
|
158
|
+
};
|
159
|
+
var _treeData = useMemo(function () {
|
160
|
+
if (showSearch !== true) {
|
161
|
+
return defaultData;
|
162
|
+
}
|
163
|
+
var loop = function loop(data) {
|
164
|
+
return data.map(function (item) {
|
165
|
+
var strTitle = item.title;
|
166
|
+
var index = strTitle.indexOf(searchValue);
|
167
|
+
var beforeStr = strTitle.substring(0, index);
|
168
|
+
var afterStr = strTitle.slice(index + searchValue.length);
|
169
|
+
var title = index > -1 ? /*#__PURE__*/React.createElement("span", {
|
170
|
+
key: item.key
|
171
|
+
}, beforeStr, /*#__PURE__*/React.createElement("span", {
|
172
|
+
style: {
|
173
|
+
color: 'var(--ant-color-primary)'
|
174
|
+
}
|
175
|
+
}, searchValue), afterStr) : /*#__PURE__*/React.createElement("span", {
|
176
|
+
key: item.key
|
177
|
+
}, strTitle);
|
178
|
+
if (item.children) {
|
179
|
+
return {
|
180
|
+
title: title,
|
181
|
+
key: item.key,
|
182
|
+
children: loop(item.children)
|
183
|
+
};
|
184
|
+
}
|
185
|
+
return {
|
186
|
+
title: title,
|
187
|
+
key: item.key
|
188
|
+
};
|
189
|
+
});
|
190
|
+
};
|
191
|
+
return loop(defaultData);
|
192
|
+
}, [searchValue, defaultData]);
|
193
|
+
useEffect(function () {
|
194
|
+
if (treeData != null) {
|
195
|
+
setDefaultData(treeData);
|
196
|
+
generateList(treeData);
|
197
|
+
}
|
198
|
+
}, [treeData]);
|
199
|
+
useEffect(function () {
|
200
|
+
// 递归展开所有节点
|
201
|
+
var expandAllNodes = function expandAllNodes(nodes) {
|
202
|
+
nodes.forEach(function (node) {
|
203
|
+
setExpandedKeys(function (prevKeys) {
|
204
|
+
return [].concat(_toConsumableArray(prevKeys), [node.key]);
|
205
|
+
});
|
206
|
+
//@ts-ignore
|
207
|
+
if (node.children && (node.areaLevel <= 1 || node.deptLevel <= 1)) {
|
208
|
+
expandAllNodes(node.children);
|
209
|
+
}
|
210
|
+
});
|
211
|
+
};
|
212
|
+
if (treeData != null && treeData.length > 0) {
|
213
|
+
expandAllNodes(treeData);
|
214
|
+
}
|
215
|
+
}, [treeData]);
|
216
|
+
return /*#__PURE__*/React.createElement("div", null, showSearch ? /*#__PURE__*/React.createElement(Search, {
|
217
|
+
style: {
|
218
|
+
marginBottom: 8
|
219
|
+
},
|
220
|
+
placeholder: placeholder,
|
221
|
+
onChange: onChange
|
222
|
+
}) : null, /*#__PURE__*/React.createElement(AntTree, _extends({
|
223
|
+
ref: ref,
|
224
|
+
onExpand: onExpand,
|
225
|
+
expandedKeys: expandedKeys,
|
226
|
+
autoExpandParent: autoExpandParent,
|
227
|
+
className: "".concat(mb, " ").concat(className),
|
228
|
+
treeData: titleRender ? _treeData : formatTreeData(_treeData),
|
229
|
+
showIcon: showIcon
|
230
|
+
}, props)));
|
231
|
+
});
|
package/dist/tree/index.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import type { TreeDataNode as AntTreeDataNode, TreeProps as AntTreeProps } from 'antd';
|
2
|
+
import { Tree as AntTree } from 'antd';
|
2
3
|
import React from 'react';
|
3
4
|
import './index.scss';
|
4
5
|
export type { AntTreeNode, AntTreeNodeCheckedEvent, AntTreeNodeExpandedEvent, AntTreeNodeMouseEvent, AntTreeNodeProps, AntTreeNodeSelectedEvent, AntdTreeNodeAttribute, DirectoryTreeExpandAction, DirectoryTreeProps, EventDataNode, } from 'antd/es/tree';
|
@@ -14,7 +15,7 @@ export type TreeProps = AntTreeProps & {
|
|
14
15
|
requireLastLevel?: boolean;
|
15
16
|
};
|
16
17
|
export type TreeDataNode = AntTreeDataNode;
|
17
|
-
export declare const
|
18
|
+
export declare const TreeInternal: React.ForwardRefExoticComponent<AntTreeProps<AntTreeDataNode> & {
|
18
19
|
showChildNumbers?: boolean | undefined;
|
19
20
|
placeholder?: string | undefined;
|
20
21
|
showSearch?: boolean | undefined;
|
@@ -25,3 +26,7 @@ export declare const Tree: React.ForwardRefExoticComponent<AntTreeProps<AntTreeD
|
|
25
26
|
areaSubType?: number | undefined;
|
26
27
|
requireLastLevel?: boolean | undefined;
|
27
28
|
} & React.RefAttributes<any>>;
|
29
|
+
type CompoundedComponent = typeof TreeInternal & {
|
30
|
+
AntdTree: typeof AntTree;
|
31
|
+
};
|
32
|
+
export declare const Tree: CompoundedComponent;
|
package/dist/tree/index.js
CHANGED
@@ -62,7 +62,7 @@ var getParentKey = function getParentKey(key, tree) {
|
|
62
62
|
}
|
63
63
|
return parentKey;
|
64
64
|
};
|
65
|
-
export var
|
65
|
+
export var TreeInternal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
66
66
|
var className = _ref.className,
|
67
67
|
treeData = _ref.treeData,
|
68
68
|
_ref$placeholder = _ref.placeholder,
|
@@ -108,7 +108,6 @@ export var Tree = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
108
108
|
var formatTreeData = function formatTreeData(treeData) {
|
109
109
|
var currentLevel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
110
110
|
return treeData === null || treeData === void 0 ? void 0 : treeData.map(function (t) {
|
111
|
-
console.log('t', t);
|
112
111
|
if (t.children == null) {
|
113
112
|
return _objectSpread(_objectSpread({}, t), {}, {
|
114
113
|
icon: t.icon != null ? t.icon : function (_ref2) {
|
@@ -229,4 +228,5 @@ export var Tree = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
229
228
|
treeData: titleRender ? _treeData : formatTreeData(_treeData),
|
230
229
|
showIcon: showIcon
|
231
230
|
}, props)));
|
232
|
-
});
|
231
|
+
});
|
232
|
+
export var Tree = TreeInternal;
|