@jetlinks-web/components 1.0.5 → 2.0.1
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/index.ts +54 -15
- package/package.json +11 -8
- package/src/AMap/Map.vue +110 -107
- package/src/BadgeStatus/Badge.vue +41 -40
- package/src/BadgeStatus/color.ts +25 -23
- package/src/CardSelect/CardSelect.vue +136 -0
- package/src/CardSelect/index.ts +3 -0
- package/src/CheckButton/CheckButton.vue +146 -0
- package/src/CheckButton/index.md +27 -0
- package/src/CheckButton/index.ts +3 -0
- package/src/ConfigProvider/context.ts +17 -0
- package/src/ConfigProvider/index.tsx +42 -0
- package/src/Echarts/Echarts.vue +43 -43
- package/src/Ellipsis/Ellipsis.vue +182 -0
- package/src/Ellipsis/index.ts +3 -0
- package/src/Empty/Empty.vue +43 -0
- package/src/Empty/image.ts +3 -0
- package/src/Empty/index.ts +2 -0
- package/src/FullPage/{index.vue → FullPage.vue} +30 -27
- package/src/FullPage/index.ts +3 -0
- package/src/Icon/icon.tsx +40 -0
- package/src/Icon/index.ts +3 -0
- package/src/MonacoEditor/Monaco.vue +242 -0
- package/src/MonacoEditor/index.md +26 -0
- package/src/MonacoEditor/index.ts +2 -0
- package/src/PermissionButton/index.tsx +95 -92
- package/src/ProLayout/Basic/BasicLayout.less +66 -0
- package/src/ProLayout/Basic/BasicLayout.tsx +392 -0
- package/src/ProLayout/Basic/Header.less +8 -0
- package/src/ProLayout/Basic/Header.tsx +115 -0
- package/src/ProLayout/PageContainer/index.less +103 -0
- package/src/ProLayout/PageContainer/index.tsx +441 -0
- package/src/ProLayout/PageContainer/typings.ts +56 -0
- package/src/ProLayout/RouteContext.ts +87 -0
- package/src/ProLayout/SiderMenu/BaseMenu.tsx +296 -0
- package/src/ProLayout/SiderMenu/SiderMenu.tsx +320 -0
- package/src/ProLayout/SiderMenu/index.less +212 -0
- package/src/ProLayout/SiderMenu/index.ts +2 -0
- package/src/ProLayout/SiderMenu/typings.ts +49 -0
- package/src/ProLayout/TopHeader/index.less +174 -0
- package/src/ProLayout/TopHeader/index.tsx +210 -0
- package/src/ProLayout/defaultSettings.ts +106 -0
- package/src/ProLayout/index.ts +6 -0
- package/src/ProLayout/style/default.less +4 -0
- package/src/ProLayout/style/index.ts +1 -0
- package/src/ProLayout/style/style.less +7 -0
- package/src/ProLayout/typings.ts +87 -0
- package/src/ProLayout/util.ts +64 -0
- package/src/ProTable/index.md +53 -0
- package/src/ProTable/index.tsx +551 -0
- package/src/ProTable/proTableTypes.ts +70 -0
- package/src/ProTable/style/index.less +92 -0
- package/src/ProTable/style/index.ts +1 -0
- package/src/Scrollbar/Bar.vue +75 -0
- package/src/Scrollbar/Scrollbar.vue +260 -0
- package/src/Scrollbar/Thumb.vue +163 -0
- package/src/Scrollbar/constants.ts +10 -0
- package/src/Scrollbar/index.ts +4 -0
- package/src/Scrollbar/scrollbar.ts +108 -0
- package/src/Scrollbar/thumb.ts +16 -0
- package/src/Scrollbar/util.ts +38 -0
- package/src/Search/Advanced/History.vue +140 -0
- package/src/Search/Advanced/SaveHistory.vue +108 -0
- package/src/Search/Advanced/index.vue +435 -0
- package/src/Search/Item.vue +525 -0
- package/src/Search/Search.vue +398 -0
- package/src/Search/hooks/index.ts +1 -0
- package/src/Search/hooks/useSearchItems.ts +68 -0
- package/src/Search/index.md +57 -0
- package/src/Search/index.ts +5 -0
- package/src/Search/setting.ts +55 -0
- package/src/Search/typing.ts +76 -0
- package/src/Search/util.ts +263 -0
- package/src/ValueItem/ValueItem.vue +50 -35
- package/src/ValueItem/util.ts +2 -1
- package/src/style/index.ts +3 -0
- package/src/style/variable.less +4 -0
- package/src/GeoComponent/GeoComponent.vue +0 -139
- package/src/GeoComponent/index.ts +0 -3
- package/src/PermissionButton/hooks.ts +0 -20
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
@import '../style/default.less';
|
|
2
|
+
|
|
3
|
+
@pro-layout-sider-menu-prefix-cls: ~'@{ant-prefix}-pro-sider';
|
|
4
|
+
|
|
5
|
+
@nav-header-height: @pro-layout-header-height;
|
|
6
|
+
|
|
7
|
+
.@{pro-layout-sider-menu-prefix-cls} {
|
|
8
|
+
position: relative;
|
|
9
|
+
background-color: @layout-sider-background;
|
|
10
|
+
border-right: 0;
|
|
11
|
+
// FIXME: 临时修正(可能不会做兼容)
|
|
12
|
+
z-index: 20;
|
|
13
|
+
|
|
14
|
+
// 这里关掉了动画,不然使用无法兼容
|
|
15
|
+
.@{ant-prefix}-menu {
|
|
16
|
+
background: transparent;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.@{ant-prefix}-layout-sider-light {
|
|
20
|
+
.@{ant-prefix}-menu-item a {
|
|
21
|
+
color: @heading-color;
|
|
22
|
+
}
|
|
23
|
+
.@{ant-prefix}-menu-item-selected a,
|
|
24
|
+
.@{ant-prefix}-menu-item a:hover {
|
|
25
|
+
color: @primary-color;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&-logo {
|
|
30
|
+
position: relative;
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
padding: 16px 16px;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
transition: padding 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
36
|
+
|
|
37
|
+
> a {
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
min-height: 32px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
img {
|
|
45
|
+
display: inline-block;
|
|
46
|
+
height: 32px;
|
|
47
|
+
vertical-align: middle;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
h1 {
|
|
51
|
+
display: inline-block;
|
|
52
|
+
height: 32px;
|
|
53
|
+
margin: 0 0 0 12px;
|
|
54
|
+
color: white;
|
|
55
|
+
font-weight: 600;
|
|
56
|
+
font-size: 18px;
|
|
57
|
+
line-height: 32px;
|
|
58
|
+
vertical-align: middle;
|
|
59
|
+
animation: pro-layout-title-hide 0.3s;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&-extra {
|
|
64
|
+
margin-bottom: 16px;
|
|
65
|
+
padding: 0 16px;
|
|
66
|
+
&-no-logo {
|
|
67
|
+
margin-top: 16px;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&-menu {
|
|
72
|
+
position: relative;
|
|
73
|
+
z-index: 10;
|
|
74
|
+
min-height: 100%;
|
|
75
|
+
box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.@{ant-prefix}-layout-sider-children {
|
|
79
|
+
display: flex;
|
|
80
|
+
flex-direction: column;
|
|
81
|
+
height: 100%;
|
|
82
|
+
|
|
83
|
+
::-webkit-scrollbar {
|
|
84
|
+
width: 6px;
|
|
85
|
+
height: 6px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
::-webkit-scrollbar-track {
|
|
89
|
+
background: rgba(255, 255, 255, 0.15);
|
|
90
|
+
border-radius: 3px;
|
|
91
|
+
box-shadow: inset 0 0 5px rgba(37, 37, 37, 0.05);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* 滚动条滑块 */
|
|
95
|
+
::-webkit-scrollbar-thumb {
|
|
96
|
+
background: rgba(255, 255, 255, 0.2);
|
|
97
|
+
border-radius: 3px;
|
|
98
|
+
box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.05);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
&.@{ant-prefix}-layout-sider-collapsed {
|
|
103
|
+
.@{ant-prefix}-menu-inline-collapsed {
|
|
104
|
+
width: 48px;
|
|
105
|
+
}
|
|
106
|
+
.@{pro-layout-sider-menu-prefix-cls} {
|
|
107
|
+
&-logo {
|
|
108
|
+
padding: 16px 8px;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
&.@{ant-prefix}-layout-sider.@{pro-layout-sider-menu-prefix-cls}-fixed {
|
|
114
|
+
position: fixed;
|
|
115
|
+
top: 0;
|
|
116
|
+
left: 0;
|
|
117
|
+
z-index: 99; // react pro-components: z-index: 100;
|
|
118
|
+
height: 100%;
|
|
119
|
+
overflow: auto;
|
|
120
|
+
overflow-x: hidden;
|
|
121
|
+
box-shadow: 2px 0 8px 0 rgba(29, 35, 41, 0.05);
|
|
122
|
+
> .@{ant-prefix}-menu-root {
|
|
123
|
+
:not(.@{pro-layout-sider-menu-prefix-cls}-link-menu) {
|
|
124
|
+
height: ~'calc(100vh - @{nav-header-height})';
|
|
125
|
+
overflow-y: auto;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&-light {
|
|
131
|
+
background-color: @component-background;
|
|
132
|
+
box-shadow: 2px 0 8px 0 rgba(29, 35, 41, 0.05);
|
|
133
|
+
|
|
134
|
+
.@{ant-prefix}-layout-sider-children {
|
|
135
|
+
::-webkit-scrollbar-track {
|
|
136
|
+
background: rgba(0, 0, 0, 0.06);
|
|
137
|
+
border-radius: 3px;
|
|
138
|
+
box-shadow: inset 0 0 5px rgba(0, 21, 41, 0.05);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* 滚动条滑块 */
|
|
142
|
+
::-webkit-scrollbar-thumb {
|
|
143
|
+
background: rgba(0, 0, 0, 0.12);
|
|
144
|
+
border-radius: 3px;
|
|
145
|
+
box-shadow: inset 0 0 5px rgba(0, 21, 41, 0.05);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.@{pro-layout-sider-menu-prefix-cls}-logo {
|
|
150
|
+
h1 {
|
|
151
|
+
color: @primary-color;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
.@{ant-prefix}-menu-light {
|
|
155
|
+
border-right-color: transparent;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.@{pro-layout-sider-menu-prefix-cls}-collapsed-button {
|
|
159
|
+
border-top: @border-width-base @border-style-base
|
|
160
|
+
@border-color-split;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
&-icon {
|
|
165
|
+
width: 14px;
|
|
166
|
+
vertical-align: baseline;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
&-links {
|
|
170
|
+
width: 100%;
|
|
171
|
+
ul.@{ant-prefix}-menu-root {
|
|
172
|
+
height: auto;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&-collapsed-button {
|
|
177
|
+
border-top: @border-width-base @border-style-base rgba(0, 0, 0, 0.25);
|
|
178
|
+
.anticon {
|
|
179
|
+
font-size: 16px;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.top-nav-menu li.@{ant-prefix}-menu-item {
|
|
184
|
+
height: 100%;
|
|
185
|
+
line-height: 1;
|
|
186
|
+
}
|
|
187
|
+
.drawer .drawer-content {
|
|
188
|
+
background: @layout-sider-background;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// 修正菜单 collapsed 时,icon 与 title 的间距
|
|
193
|
+
.@{ant-prefix}-pro-menu-item {
|
|
194
|
+
.anticon + .@{ant-prefix}-pro-menu-item-title {
|
|
195
|
+
margin-left: 10px;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
@keyframes pro-layout-title-hide {
|
|
200
|
+
0% {
|
|
201
|
+
display: none;
|
|
202
|
+
opacity: 0;
|
|
203
|
+
}
|
|
204
|
+
80% {
|
|
205
|
+
display: none;
|
|
206
|
+
opacity: 0;
|
|
207
|
+
}
|
|
208
|
+
100% {
|
|
209
|
+
display: unset;
|
|
210
|
+
opacity: 1;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { VNodeChild, CSSProperties, HTMLAttributes } from 'vue';
|
|
2
|
+
import type { Theme } from '../typings';
|
|
3
|
+
|
|
4
|
+
export type {
|
|
5
|
+
MenuMode,
|
|
6
|
+
MenuTheme,
|
|
7
|
+
} from 'ant-design-vue/lib/menu/src/interface';
|
|
8
|
+
|
|
9
|
+
export interface MenuInfo {
|
|
10
|
+
key: string | number;
|
|
11
|
+
keyPath: string[] | number[];
|
|
12
|
+
item: VNodeChild;
|
|
13
|
+
domEvent: MouseEvent;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface SelectInfo extends MenuInfo {
|
|
17
|
+
selectedKeys: string[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type OpenEventHandler = (
|
|
21
|
+
keys:
|
|
22
|
+
| string[]
|
|
23
|
+
| {
|
|
24
|
+
key: string;
|
|
25
|
+
item: VNodeChild;
|
|
26
|
+
trigger: string;
|
|
27
|
+
open: boolean;
|
|
28
|
+
},
|
|
29
|
+
) => void;
|
|
30
|
+
|
|
31
|
+
export type SiderTheme = Theme;
|
|
32
|
+
|
|
33
|
+
export type CollapseType = 'clickTrigger' | 'responsive';
|
|
34
|
+
|
|
35
|
+
export interface SiderProps extends HTMLAttributes {
|
|
36
|
+
prefixCls?: string;
|
|
37
|
+
collapsible?: boolean;
|
|
38
|
+
collapsed?: boolean;
|
|
39
|
+
defaultCollapsed?: boolean;
|
|
40
|
+
reverseArrow?: boolean;
|
|
41
|
+
onCollapse?: (collapsed: boolean, type: CollapseType) => void;
|
|
42
|
+
zeroWidthTriggerStyle?: CSSProperties;
|
|
43
|
+
trigger?: VNodeChild | JSX.Element;
|
|
44
|
+
width?: number | string;
|
|
45
|
+
collapsedWidth?: number | string;
|
|
46
|
+
breakpoint?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
47
|
+
theme?: SiderTheme;
|
|
48
|
+
onBreakpoint?: (broken: boolean) => void;
|
|
49
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
@import '../style/default.less';
|
|
2
|
+
|
|
3
|
+
@top-nav-header-prefix-cls: ~'@{ant-prefix}-pro-top-nav-header';
|
|
4
|
+
@pro-layout-global-header-prefix-cls: ~'@{ant-prefix}-pro-global-header';
|
|
5
|
+
|
|
6
|
+
@pro-layout-header-bg: @component-background;
|
|
7
|
+
@pro-layout-header-hover-bg: @component-background;
|
|
8
|
+
@pro-layout-header-box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
|
|
9
|
+
|
|
10
|
+
.@{pro-layout-global-header-prefix-cls} {
|
|
11
|
+
position: relative;
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
height: 100%;
|
|
15
|
+
padding: 0 16px;
|
|
16
|
+
background: @pro-layout-header-bg;
|
|
17
|
+
box-shadow: @pro-layout-header-box-shadow;
|
|
18
|
+
> * {
|
|
19
|
+
height: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&-collapsed-button {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
margin-left: 16px;
|
|
26
|
+
font-size: 20px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&-layout {
|
|
30
|
+
&-mix {
|
|
31
|
+
background-color: @layout-sider-background;
|
|
32
|
+
.@{pro-layout-global-header-prefix-cls}-logo {
|
|
33
|
+
h1 {
|
|
34
|
+
color: @btn-primary-color;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
.anticon {
|
|
38
|
+
color: @btn-primary-color;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&-logo {
|
|
44
|
+
position: relative;
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
a {
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
height: 100%;
|
|
50
|
+
img {
|
|
51
|
+
height: 28px;
|
|
52
|
+
}
|
|
53
|
+
h1 {
|
|
54
|
+
height: 32px;
|
|
55
|
+
margin: 0 0 0 8px;
|
|
56
|
+
margin: 0 0 0 12px;
|
|
57
|
+
color: @primary-color;
|
|
58
|
+
font-weight: 600;
|
|
59
|
+
font-size: 18px;
|
|
60
|
+
line-height: 32px;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&-menu {
|
|
66
|
+
.anticon {
|
|
67
|
+
margin-right: 8px;
|
|
68
|
+
}
|
|
69
|
+
.@{ant-prefix}-dropdown-menu-item {
|
|
70
|
+
min-width: 160px;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.dark {
|
|
75
|
+
height: @pro-layout-header-height;
|
|
76
|
+
.action {
|
|
77
|
+
color: rgba(255, 255, 255, 0.85);
|
|
78
|
+
> i {
|
|
79
|
+
color: rgba(255, 255, 255, 0.85);
|
|
80
|
+
}
|
|
81
|
+
&:hover,
|
|
82
|
+
&.opened {
|
|
83
|
+
background: @primary-color;
|
|
84
|
+
}
|
|
85
|
+
.@{ant-prefix}-badge {
|
|
86
|
+
color: rgba(255, 255, 255, 0.85);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.@{top-nav-header-prefix-cls} {
|
|
93
|
+
position: relative;
|
|
94
|
+
width: 100%;
|
|
95
|
+
height: 100%;
|
|
96
|
+
box-shadow: 0 1px 4px 0 rgba(0, 21, 41, 0.12);
|
|
97
|
+
transition: background 0.3s, width 0.2s;
|
|
98
|
+
|
|
99
|
+
.@{ant-prefix}-menu {
|
|
100
|
+
background: transparent;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&.light {
|
|
104
|
+
background-color: @component-background;
|
|
105
|
+
.@{top-nav-header-prefix-cls}-logo {
|
|
106
|
+
h1 {
|
|
107
|
+
color: @heading-color;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
.anticon {
|
|
111
|
+
color: inherit;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&-main {
|
|
116
|
+
display: flex;
|
|
117
|
+
height: 100%;
|
|
118
|
+
padding-left: 16px;
|
|
119
|
+
&-left {
|
|
120
|
+
display: flex;
|
|
121
|
+
min-width: 192px;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.anticon {
|
|
126
|
+
color: @btn-primary-color;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
&-logo {
|
|
130
|
+
position: relative;
|
|
131
|
+
min-width: 165px;
|
|
132
|
+
height: 100%;
|
|
133
|
+
overflow: hidden;
|
|
134
|
+
|
|
135
|
+
img {
|
|
136
|
+
display: inline-block;
|
|
137
|
+
height: 32px;
|
|
138
|
+
vertical-align: middle;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
h1 {
|
|
142
|
+
display: inline-block;
|
|
143
|
+
margin: 0 0 0 12px;
|
|
144
|
+
color: @btn-primary-color;
|
|
145
|
+
font-weight: 600;
|
|
146
|
+
font-size: 16px;
|
|
147
|
+
vertical-align: top;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&-menu {
|
|
152
|
+
min-width: 0;
|
|
153
|
+
|
|
154
|
+
.@{ant-prefix}-menu.@{ant-prefix}-menu-horizontal {
|
|
155
|
+
height: 100%;
|
|
156
|
+
border: none;
|
|
157
|
+
|
|
158
|
+
.@{ant-prefix}-menu-item {
|
|
159
|
+
height: 100%;
|
|
160
|
+
|
|
161
|
+
.@{ant-prefix}-badge {
|
|
162
|
+
color: unset;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// replace sub.item
|
|
170
|
+
.@{ant-prefix}-pro-menu-popup {
|
|
171
|
+
.@{ant-prefix}-badge {
|
|
172
|
+
color: unset;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { computed, ref } from 'vue';
|
|
2
|
+
import type { RouteRecordRaw } from 'vue-router';
|
|
3
|
+
import { default as ResizeObserver } from 'ant-design-vue/lib/vc-resize-observer';
|
|
4
|
+
import type { VueNode } from 'ant-design-vue/lib/_util/type';
|
|
5
|
+
import type { SiderMenuProps } from '../SiderMenu/SiderMenu';
|
|
6
|
+
import {
|
|
7
|
+
defaultRenderLogoAndTitle,
|
|
8
|
+
siderMenuProps,
|
|
9
|
+
} from '../SiderMenu/SiderMenu';
|
|
10
|
+
import PropTypes from 'ant-design-vue/lib/_util/vue-types';
|
|
11
|
+
import type {
|
|
12
|
+
MenuDataItem,
|
|
13
|
+
ProProps,
|
|
14
|
+
RightContentRender,
|
|
15
|
+
WithFalse,
|
|
16
|
+
Theme,
|
|
17
|
+
} from '../typings';
|
|
18
|
+
import { defaultSettingProps } from '../defaultSettings';
|
|
19
|
+
import type { PropType, FunctionalComponent, ExtractPropTypes } from 'vue';
|
|
20
|
+
import { defaultPrefixCls, useRouteContext } from '../RouteContext';
|
|
21
|
+
import BaseMenu from '../SiderMenu/BaseMenu';
|
|
22
|
+
import { clearMenuItem } from '../util';
|
|
23
|
+
|
|
24
|
+
export const baseHeaderProps = {
|
|
25
|
+
...defaultSettingProps,
|
|
26
|
+
prefixCls: PropTypes.string.def('ant-pro'),
|
|
27
|
+
collapsed: PropTypes.looseBool,
|
|
28
|
+
logo: siderMenuProps.logo,
|
|
29
|
+
logoStyle: siderMenuProps.logoStyle,
|
|
30
|
+
headerTheme: {
|
|
31
|
+
type: String as PropType<Theme>,
|
|
32
|
+
default: 'dark',
|
|
33
|
+
},
|
|
34
|
+
menuData: {
|
|
35
|
+
type: Array as PropType<MenuDataItem[]>,
|
|
36
|
+
default: () => [],
|
|
37
|
+
},
|
|
38
|
+
splitMenus: siderMenuProps.splitMenus,
|
|
39
|
+
menuRender: {
|
|
40
|
+
type: [Object, Function] as PropType<
|
|
41
|
+
WithFalse<
|
|
42
|
+
(
|
|
43
|
+
props: ProProps /* HeaderViewProps */,
|
|
44
|
+
defaultDom: VueNode,
|
|
45
|
+
) => VueNode
|
|
46
|
+
>
|
|
47
|
+
>,
|
|
48
|
+
default: () => undefined,
|
|
49
|
+
},
|
|
50
|
+
menuHeaderRender: siderMenuProps.menuHeaderRender,
|
|
51
|
+
menuItemRender: siderMenuProps.menuItemRender,
|
|
52
|
+
subMenuItemRender: siderMenuProps.subMenuItemRender,
|
|
53
|
+
rightContentRender: {
|
|
54
|
+
type: [Object, Function] as PropType<RightContentRender>,
|
|
55
|
+
default: () => undefined,
|
|
56
|
+
},
|
|
57
|
+
collapsedButtonRender: siderMenuProps.collapsedButtonRender,
|
|
58
|
+
matchMenuKeys: siderMenuProps.matchMenuKeys,
|
|
59
|
+
|
|
60
|
+
// events
|
|
61
|
+
onMenuHeaderClick: PropTypes.func,
|
|
62
|
+
onCollapse: siderMenuProps.onCollapse,
|
|
63
|
+
onOpenKeys: siderMenuProps.onOpenKeys,
|
|
64
|
+
onSelect: siderMenuProps.onSelect,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type BaseHeaderPropsType = ExtractPropTypes<typeof baseHeaderProps>;
|
|
68
|
+
|
|
69
|
+
export const topNavHeaderProps = { ...siderMenuProps, ...baseHeaderProps };
|
|
70
|
+
|
|
71
|
+
export type TopNavHeaderProps = Partial<
|
|
72
|
+
ExtractPropTypes<typeof topNavHeaderProps>
|
|
73
|
+
> &
|
|
74
|
+
Partial<SiderMenuProps>;
|
|
75
|
+
|
|
76
|
+
const RightContent: FunctionalComponent<TopNavHeaderProps> = ({
|
|
77
|
+
rightContentRender,
|
|
78
|
+
...props
|
|
79
|
+
}) => {
|
|
80
|
+
const rightSize = ref<number | string>('auto');
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<div
|
|
84
|
+
style={{
|
|
85
|
+
minWidth: rightSize.value,
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
<div
|
|
89
|
+
style={{
|
|
90
|
+
paddingRight: 8,
|
|
91
|
+
}}
|
|
92
|
+
>
|
|
93
|
+
<ResizeObserver
|
|
94
|
+
onResize={({ width }: { width: number }) => {
|
|
95
|
+
rightSize.value = width;
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
{rightContentRender &&
|
|
99
|
+
typeof rightContentRender === 'function' ? (
|
|
100
|
+
<div>
|
|
101
|
+
{rightContentRender({
|
|
102
|
+
...props,
|
|
103
|
+
})}
|
|
104
|
+
</div>
|
|
105
|
+
) : (
|
|
106
|
+
rightContentRender
|
|
107
|
+
)}
|
|
108
|
+
</ResizeObserver>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const TopNavHeader: FunctionalComponent<TopNavHeaderProps> = (props) => {
|
|
115
|
+
const headerRef = ref();
|
|
116
|
+
const {
|
|
117
|
+
prefixCls: propPrefixCls,
|
|
118
|
+
onMenuHeaderClick,
|
|
119
|
+
onOpenKeys,
|
|
120
|
+
onSelect,
|
|
121
|
+
contentWidth,
|
|
122
|
+
rightContentRender,
|
|
123
|
+
layout,
|
|
124
|
+
menuData,
|
|
125
|
+
mode,
|
|
126
|
+
} = props;
|
|
127
|
+
const context = useRouteContext();
|
|
128
|
+
const prefixCls = `${propPrefixCls || defaultPrefixCls}-top-nav-header`;
|
|
129
|
+
const headerDom = defaultRenderLogoAndTitle(
|
|
130
|
+
{ ...props, collapsed: false } as SiderMenuProps,
|
|
131
|
+
// REMARK:: Any time render header title
|
|
132
|
+
// layout === 'mix' ? 'headerTitleRender' : undefined,
|
|
133
|
+
// layout !== 'side' ? 'headerTitleRender' : undefined,
|
|
134
|
+
'headerTitleRender',
|
|
135
|
+
);
|
|
136
|
+
//
|
|
137
|
+
let MenusData = props.layout === 'side' ? [] : menuData;
|
|
138
|
+
if (props.layout === 'mix' && props.splitMenus) {
|
|
139
|
+
const noChildrenMenuData = (menuData || []).map((item) => ({
|
|
140
|
+
...item,
|
|
141
|
+
children: undefined,
|
|
142
|
+
component: undefined,
|
|
143
|
+
})) as RouteRecordRaw[];
|
|
144
|
+
MenusData = clearMenuItem(noChildrenMenuData);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const _mode = computed(() =>
|
|
148
|
+
props.layout === 'mix' && props.splitMenus ? 'horizontal' : mode,
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const className = computed(() => {
|
|
152
|
+
return {
|
|
153
|
+
[prefixCls]: true,
|
|
154
|
+
light: props.theme === 'light',
|
|
155
|
+
dark: props.theme === 'dark',
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<div class={className.value}>
|
|
161
|
+
<div
|
|
162
|
+
ref={headerRef}
|
|
163
|
+
class={`${prefixCls}-main ${
|
|
164
|
+
contentWidth === 'Fixed' ? 'wide' : ''
|
|
165
|
+
}`}
|
|
166
|
+
>
|
|
167
|
+
{headerDom && (
|
|
168
|
+
<div
|
|
169
|
+
class={`${prefixCls}-main-left`}
|
|
170
|
+
onClick={onMenuHeaderClick}
|
|
171
|
+
>
|
|
172
|
+
<div class={`${prefixCls}-logo`} key="logo" id="logo">
|
|
173
|
+
{headerDom}
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
)}
|
|
177
|
+
<div style={{ flex: 1 }} class={`${prefixCls}-menu`}>
|
|
178
|
+
<BaseMenu
|
|
179
|
+
prefixCls={propPrefixCls}
|
|
180
|
+
locale={props.locale || context.locale}
|
|
181
|
+
theme={props.theme}
|
|
182
|
+
mode={_mode.value}
|
|
183
|
+
collapsed={props.collapsed}
|
|
184
|
+
iconfontUrl={props.iconfontUrl}
|
|
185
|
+
menuData={MenusData}
|
|
186
|
+
menuItemRender={props.menuItemRender}
|
|
187
|
+
subMenuItemRender={props.subMenuItemRender}
|
|
188
|
+
openKeys={context.openKeys}
|
|
189
|
+
selectedKeys={context.selectedKeys}
|
|
190
|
+
class={{
|
|
191
|
+
'top-nav-menu': props.mode === 'horizontal',
|
|
192
|
+
}}
|
|
193
|
+
{...{
|
|
194
|
+
'onUpdate:openKeys': ($event: string[]) =>
|
|
195
|
+
onOpenKeys && onOpenKeys($event),
|
|
196
|
+
'onUpdate:selectedKeys': ($event: string[]) =>
|
|
197
|
+
onSelect && onSelect($event),
|
|
198
|
+
}}
|
|
199
|
+
/>
|
|
200
|
+
</div>
|
|
201
|
+
{rightContentRender && (
|
|
202
|
+
<RightContent
|
|
203
|
+
rightContentRender={rightContentRender}
|
|
204
|
+
{...props}
|
|
205
|
+
/>
|
|
206
|
+
)}
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
);
|
|
210
|
+
};
|