yootd 0.0.49 → 0.0.51
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/dropdown-select/assets/ArrowDown.js +1 -1
- package/dist/dropdown-select/index.scss +6 -6
- package/dist/dropdown-select/types/type.d.ts +18 -18
- package/dist/empty/index.scss +15 -15
- package/dist/go-back/components/GoBackIcon.d.ts +4 -0
- package/dist/go-back/components/GoBackIcon.js +43 -0
- package/dist/go-back/components/index.scss +5 -0
- package/dist/go-back/index.d.ts +7 -0
- package/dist/go-back/index.js +24 -0
- package/dist/go-back/index.scss +24 -0
- package/dist/group-title/index.scss +31 -31
- package/dist/hooks/useBem.js +10 -10
- 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/types/types.d.ts +33 -33
- package/dist/tree/index.scss +25 -25
- package/dist/upload/index.js +3 -1
- 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 +102 -101
- package/dist/tree/index copy.d.ts +0 -27
- package/dist/tree/index copy.js +0 -231
@@ -1,28 +1,28 @@
|
|
1
|
-
export interface PageData<T> {
|
2
|
-
content: T[];
|
3
|
-
page: {
|
4
|
-
number: number;
|
5
|
-
size: number;
|
6
|
-
totalElements: number;
|
7
|
-
totalPages: number;
|
8
|
-
};
|
9
|
-
}
|
10
|
-
// 查询学年返回的数据类型
|
11
|
-
export interface IYearItem {
|
12
|
-
id: number; // ID
|
13
|
-
yearName: string; // 学年名称
|
14
|
-
}
|
15
|
-
// 查询学期返回的数据类型
|
16
|
-
export interface ITermItem {
|
17
|
-
termId: number; // ID
|
18
|
-
termName: string; // 学期名称
|
19
|
-
}
|
20
|
-
type YearTermProps = {
|
21
|
-
type?: 'yearTerm' | 'year' | 'term';
|
22
|
-
style?: React.CSSProperties;
|
23
|
-
showSearch?: boolean;
|
24
|
-
value?: Record<string, number>;
|
25
|
-
onChange?: (record: Record<string, number | undefined>) => void;
|
26
|
-
allowClear?: boolean;
|
27
|
-
placeholder?: string[];
|
28
|
-
};
|
1
|
+
export interface PageData<T> {
|
2
|
+
content: T[];
|
3
|
+
page: {
|
4
|
+
number: number;
|
5
|
+
size: number;
|
6
|
+
totalElements: number;
|
7
|
+
totalPages: number;
|
8
|
+
};
|
9
|
+
}
|
10
|
+
// 查询学年返回的数据类型
|
11
|
+
export interface IYearItem {
|
12
|
+
id: number; // ID
|
13
|
+
yearName: string; // 学年名称
|
14
|
+
}
|
15
|
+
// 查询学期返回的数据类型
|
16
|
+
export interface ITermItem {
|
17
|
+
termId: number; // ID
|
18
|
+
termName: string; // 学期名称
|
19
|
+
}
|
20
|
+
type YearTermProps = {
|
21
|
+
type?: 'yearTerm' | 'year' | 'term';
|
22
|
+
style?: React.CSSProperties;
|
23
|
+
showSearch?: boolean;
|
24
|
+
value?: Record<string, number>;
|
25
|
+
onChange?: (record: Record<string, number | undefined>) => void;
|
26
|
+
allowClear?: boolean;
|
27
|
+
placeholder?: string[];
|
28
|
+
};
|
@@ -1,23 +1,23 @@
|
|
1
|
-
.content {
|
2
|
-
border: var(--ant-line-width) var(--ant-line-type) var(--ant-color-border);
|
3
|
-
border-radius: var(--ant-border-radius);
|
4
|
-
:global {
|
5
|
-
.zone-select::after {
|
6
|
-
content: '';
|
7
|
-
position: absolute;
|
8
|
-
right: 0;
|
9
|
-
top: 50%; /* 从中间开始 */
|
10
|
-
width: 1px; /* 边框宽度 */
|
11
|
-
height: 50%; /* 设为盒子高度的百分之五十 */
|
12
|
-
background-color: var(--ant-color-border); /* 边框颜色 */
|
13
|
-
transform: translateY(-50%);
|
14
|
-
}
|
15
|
-
.ant-select.ant-select-outlined.css-var-yootd.ant-select-css-var.ant-select-single.ant-select-show-arrow {
|
16
|
-
.ant-select-selector {
|
17
|
-
padding-left: var(--ant-padding);
|
18
|
-
padding-right: var(--ant-padding);
|
19
|
-
border: 0;
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}
|
23
|
-
}
|
1
|
+
.content {
|
2
|
+
border: var(--ant-line-width) var(--ant-line-type) var(--ant-color-border);
|
3
|
+
border-radius: var(--ant-border-radius);
|
4
|
+
:global {
|
5
|
+
.zone-select::after {
|
6
|
+
content: '';
|
7
|
+
position: absolute;
|
8
|
+
right: 0;
|
9
|
+
top: 50%; /* 从中间开始 */
|
10
|
+
width: 1px; /* 边框宽度 */
|
11
|
+
height: 50%; /* 设为盒子高度的百分之五十 */
|
12
|
+
background-color: var(--ant-color-border); /* 边框颜色 */
|
13
|
+
transform: translateY(-50%);
|
14
|
+
}
|
15
|
+
.ant-select.ant-select-outlined.css-var-yootd.ant-select-css-var.ant-select-single.ant-select-show-arrow {
|
16
|
+
.ant-select-selector {
|
17
|
+
padding-left: var(--ant-padding);
|
18
|
+
padding-right: var(--ant-padding);
|
19
|
+
border: 0;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
@@ -1,26 +1,26 @@
|
|
1
|
-
export interface PageData<T> {
|
2
|
-
content: T[];
|
3
|
-
page: {
|
4
|
-
number: number;
|
5
|
-
size: number;
|
6
|
-
totalElements: number;
|
7
|
-
totalPages: number;
|
8
|
-
};
|
9
|
-
}
|
10
|
-
|
11
|
-
export interface ZoneItem {
|
12
|
-
zoneId: string; // 区域ID
|
13
|
-
zoneName: string; // 区域名称
|
14
|
-
zoneLevel: number; // 区域等级(1全国2省级3市级4区级)
|
15
|
-
zoneLevel1Id: string;
|
16
|
-
zoneLevel2Id: string;
|
17
|
-
}
|
18
|
-
export interface ZoneProps {
|
19
|
-
zoneLevel?: 'province' | 'city' | 'district';
|
20
|
-
value?: string[];
|
21
|
-
onChange?: (zoneIds: string[]) => void;
|
22
|
-
style?: React.CSSProperties;
|
23
|
-
placeholder?: string[];
|
24
|
-
allowClear?: boolean;
|
25
|
-
showSearch?: boolean;
|
26
|
-
}
|
1
|
+
export interface PageData<T> {
|
2
|
+
content: T[];
|
3
|
+
page: {
|
4
|
+
number: number;
|
5
|
+
size: number;
|
6
|
+
totalElements: number;
|
7
|
+
totalPages: number;
|
8
|
+
};
|
9
|
+
}
|
10
|
+
|
11
|
+
export interface ZoneItem {
|
12
|
+
zoneId: string; // 区域ID
|
13
|
+
zoneName: string; // 区域名称
|
14
|
+
zoneLevel: number; // 区域等级(1全国2省级3市级4区级)
|
15
|
+
zoneLevel1Id: string;
|
16
|
+
zoneLevel2Id: string;
|
17
|
+
}
|
18
|
+
export interface ZoneProps {
|
19
|
+
zoneLevel?: 'province' | 'city' | 'district';
|
20
|
+
value?: string[];
|
21
|
+
onChange?: (zoneIds: string[]) => void;
|
22
|
+
style?: React.CSSProperties;
|
23
|
+
placeholder?: string[];
|
24
|
+
allowClear?: boolean;
|
25
|
+
showSearch?: boolean;
|
26
|
+
}
|
package/package.json
CHANGED
@@ -1,101 +1,102 @@
|
|
1
|
-
{
|
2
|
-
"name": "yootd",
|
3
|
-
"version": "0.0.
|
4
|
-
"description": "A react library developed with dumi",
|
5
|
-
"license": "MIT",
|
6
|
-
"module": "dist/index.js",
|
7
|
-
"types": "dist/index.d.ts",
|
8
|
-
"files": [
|
9
|
-
"dist"
|
10
|
-
],
|
11
|
-
"scripts": {
|
12
|
-
"build": "father build",
|
13
|
-
"build:watch": "father dev",
|
14
|
-
"dev": "dumi dev",
|
15
|
-
"docs:build": "dumi build",
|
16
|
-
"docs:preview": "dumi preview",
|
17
|
-
"doctor": "father doctor",
|
18
|
-
"lint": "npm run lint:es && npm run lint:css",
|
19
|
-
"lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
|
20
|
-
"lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
|
21
|
-
"prepare": "husky install && dumi setup",
|
22
|
-
"prepublishOnly": "father doctor && npm run build",
|
23
|
-
"start": "npm run dev"
|
24
|
-
},
|
25
|
-
"commitlint": {
|
26
|
-
"extends": [
|
27
|
-
"@commitlint/config-conventional"
|
28
|
-
]
|
29
|
-
},
|
30
|
-
"lint-staged": {
|
31
|
-
"*.{md,json}": [
|
32
|
-
"prettier --write --no-error-on-unmatched-pattern"
|
33
|
-
],
|
34
|
-
"*.{css,less}": [
|
35
|
-
"stylelint --fix",
|
36
|
-
"prettier --write"
|
37
|
-
],
|
38
|
-
"*.{js,jsx}": [
|
39
|
-
"eslint --fix",
|
40
|
-
"prettier --write"
|
41
|
-
],
|
42
|
-
"*.{ts,tsx}": [
|
43
|
-
"eslint --fix",
|
44
|
-
"prettier --parser=typescript --write"
|
45
|
-
]
|
46
|
-
},
|
47
|
-
"devDependencies": {
|
48
|
-
"@commitlint/cli": "^17.1.2",
|
49
|
-
"@commitlint/config-conventional": "^17.1.0",
|
50
|
-
"@dnd-kit/core": "^6.1.0",
|
51
|
-
"@dnd-kit/modifiers": "^7.0.0",
|
52
|
-
"@dnd-kit/sortable": "^8.0.0",
|
53
|
-
"@dnd-kit/utilities": "^3.2.2",
|
54
|
-
"@tanstack/react-query": "^5.59.15",
|
55
|
-
"@types/lodash": "^4.17.12",
|
56
|
-
"@types/react": "^18.0.0",
|
57
|
-
"@types/react-dom": "^18.0.0",
|
58
|
-
"@umijs/lint": "^4.0.0",
|
59
|
-
"@vladmandic/face-api": "^1.7.14",
|
60
|
-
"antd": "^5.21.4",
|
61
|
-
"axios": "^1.7.7",
|
62
|
-
"dayjs": "^1.11.13",
|
63
|
-
"dumi": "^2.3.0",
|
64
|
-
"dumi-theme-antd": "^0.4.2",
|
65
|
-
"eslint": "^8.23.0",
|
66
|
-
"father": "^4.1.0",
|
67
|
-
"husky": "^8.0.1",
|
68
|
-
"lint-staged": "^13.0.3",
|
69
|
-
"lodash": "^4.17.21",
|
70
|
-
"nanoid": "^5.0.8",
|
71
|
-
"prettier": "^2.7.1",
|
72
|
-
"prettier-plugin-organize-imports": "^3.0.0",
|
73
|
-
"prettier-plugin-packagejson": "^2.2.18",
|
74
|
-
"react": "^18.0.0",
|
75
|
-
"react-dom": "^18.0.0",
|
76
|
-
"sass": "^1.80.0",
|
77
|
-
"stylelint": "^14.9.1",
|
78
|
-
"yootd-webrtc-sdk": "^1.0.1"
|
79
|
-
},
|
80
|
-
"peerDependencies": {
|
81
|
-
"@dnd-kit/core": ">=6.1.0",
|
82
|
-
"@dnd-kit/modifiers": ">=7.0.0",
|
83
|
-
"@dnd-kit/sortable": ">=8.0.0",
|
84
|
-
"@dnd-kit/utilities": ">=3.2.2",
|
85
|
-
"@tanstack/react-query": ">=5.59.15",
|
86
|
-
"@vladmandic/face-api": "^1.7.14",
|
87
|
-
"@xyflow/react": ">=12.3.3",
|
88
|
-
"antd": ">=5.21.4",
|
89
|
-
"axios": ">=1.7.7",
|
90
|
-
"dayjs": ">=1.11.13",
|
91
|
-
"lodash": ">=4.17.21",
|
92
|
-
"nanoid": ">=5.0.8",
|
93
|
-
"react": ">=16.9.0",
|
94
|
-
"react-dom": ">=16.9.0",
|
95
|
-
"yootd-webrtc-sdk": "^1.0.1"
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
1
|
+
{
|
2
|
+
"name": "yootd",
|
3
|
+
"version": "0.0.51",
|
4
|
+
"description": "A react library developed with dumi",
|
5
|
+
"license": "MIT",
|
6
|
+
"module": "dist/index.js",
|
7
|
+
"types": "dist/index.d.ts",
|
8
|
+
"files": [
|
9
|
+
"dist"
|
10
|
+
],
|
11
|
+
"scripts": {
|
12
|
+
"build": "father build",
|
13
|
+
"build:watch": "father dev",
|
14
|
+
"dev": "dumi dev",
|
15
|
+
"docs:build": "dumi build",
|
16
|
+
"docs:preview": "dumi preview",
|
17
|
+
"doctor": "father doctor",
|
18
|
+
"lint": "npm run lint:es && npm run lint:css",
|
19
|
+
"lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
|
20
|
+
"lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
|
21
|
+
"prepare": "husky install && dumi setup",
|
22
|
+
"prepublishOnly": "father doctor && npm run build",
|
23
|
+
"start": "npm run dev"
|
24
|
+
},
|
25
|
+
"commitlint": {
|
26
|
+
"extends": [
|
27
|
+
"@commitlint/config-conventional"
|
28
|
+
]
|
29
|
+
},
|
30
|
+
"lint-staged": {
|
31
|
+
"*.{md,json}": [
|
32
|
+
"prettier --write --no-error-on-unmatched-pattern"
|
33
|
+
],
|
34
|
+
"*.{css,less}": [
|
35
|
+
"stylelint --fix",
|
36
|
+
"prettier --write"
|
37
|
+
],
|
38
|
+
"*.{js,jsx}": [
|
39
|
+
"eslint --fix",
|
40
|
+
"prettier --write"
|
41
|
+
],
|
42
|
+
"*.{ts,tsx}": [
|
43
|
+
"eslint --fix",
|
44
|
+
"prettier --parser=typescript --write"
|
45
|
+
]
|
46
|
+
},
|
47
|
+
"devDependencies": {
|
48
|
+
"@commitlint/cli": "^17.1.2",
|
49
|
+
"@commitlint/config-conventional": "^17.1.0",
|
50
|
+
"@dnd-kit/core": "^6.1.0",
|
51
|
+
"@dnd-kit/modifiers": "^7.0.0",
|
52
|
+
"@dnd-kit/sortable": "^8.0.0",
|
53
|
+
"@dnd-kit/utilities": "^3.2.2",
|
54
|
+
"@tanstack/react-query": "^5.59.15",
|
55
|
+
"@types/lodash": "^4.17.12",
|
56
|
+
"@types/react": "^18.0.0",
|
57
|
+
"@types/react-dom": "^18.0.0",
|
58
|
+
"@umijs/lint": "^4.0.0",
|
59
|
+
"@vladmandic/face-api": "^1.7.14",
|
60
|
+
"antd": "^5.21.4",
|
61
|
+
"axios": "^1.7.7",
|
62
|
+
"dayjs": "^1.11.13",
|
63
|
+
"dumi": "^2.3.0",
|
64
|
+
"dumi-theme-antd": "^0.4.2",
|
65
|
+
"eslint": "^8.23.0",
|
66
|
+
"father": "^4.1.0",
|
67
|
+
"husky": "^8.0.1",
|
68
|
+
"lint-staged": "^13.0.3",
|
69
|
+
"lodash": "^4.17.21",
|
70
|
+
"nanoid": "^5.0.8",
|
71
|
+
"prettier": "^2.7.1",
|
72
|
+
"prettier-plugin-organize-imports": "^3.0.0",
|
73
|
+
"prettier-plugin-packagejson": "^2.2.18",
|
74
|
+
"react": "^18.0.0",
|
75
|
+
"react-dom": "^18.0.0",
|
76
|
+
"sass": "^1.80.0",
|
77
|
+
"stylelint": "^14.9.1",
|
78
|
+
"yootd-webrtc-sdk": "^1.0.1"
|
79
|
+
},
|
80
|
+
"peerDependencies": {
|
81
|
+
"@dnd-kit/core": ">=6.1.0",
|
82
|
+
"@dnd-kit/modifiers": ">=7.0.0",
|
83
|
+
"@dnd-kit/sortable": ">=8.0.0",
|
84
|
+
"@dnd-kit/utilities": ">=3.2.2",
|
85
|
+
"@tanstack/react-query": ">=5.59.15",
|
86
|
+
"@vladmandic/face-api": "^1.7.14",
|
87
|
+
"@xyflow/react": ">=12.3.3",
|
88
|
+
"antd": ">=5.21.4",
|
89
|
+
"axios": ">=1.7.7",
|
90
|
+
"dayjs": ">=1.11.13",
|
91
|
+
"lodash": ">=4.17.21",
|
92
|
+
"nanoid": ">=5.0.8",
|
93
|
+
"react": ">=16.9.0",
|
94
|
+
"react-dom": ">=16.9.0",
|
95
|
+
"yootd-webrtc-sdk": "^1.0.1",
|
96
|
+
"react-router-dom": ">=6.25.0"
|
97
|
+
},
|
98
|
+
"publishConfig": {
|
99
|
+
"access": "public"
|
100
|
+
},
|
101
|
+
"authors": []
|
102
|
+
}
|
@@ -1,27 +0,0 @@
|
|
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>>;
|
package/dist/tree/index copy.js
DELETED
@@ -1,231 +0,0 @@
|
|
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
|
-
});
|