vitepress-theme-element-plus 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +3 -3
  3. package/client/components/A11yTag.vue +29 -29
  4. package/client/components/ApiTyping.vue +54 -54
  5. package/client/components/Backdrop.vue +41 -41
  6. package/client/components/Bili.vue +94 -94
  7. package/client/components/Content.vue +148 -148
  8. package/client/components/DeprecatedTag.vue +19 -19
  9. package/client/components/Doc.vue +185 -185
  10. package/client/components/DocAside.vue +46 -46
  11. package/client/components/DocAsideOutline.vue +145 -145
  12. package/client/components/DocFooter.vue +162 -162
  13. package/client/components/Footer.vue +100 -100
  14. package/client/components/FooterCopyright.vue +27 -27
  15. package/client/components/Layout.vue +156 -156
  16. package/client/components/Link.vue +41 -41
  17. package/client/components/LocalNav.vue +160 -160
  18. package/client/components/Nav.vue +69 -69
  19. package/client/components/NavBar.vue +203 -203
  20. package/client/components/NavBarTitle.vue +89 -89
  21. package/client/components/Sidebar.vue +129 -129
  22. package/client/components/SidebarGroup.vue +51 -51
  23. package/client/components/SidebarItem.vue +304 -304
  24. package/client/components/ThemeToggler.vue +129 -129
  25. package/client/components/VPNavBarSearch.vue +23 -23
  26. package/client/hooks/useBackTop.ts +71 -71
  27. package/client/hooks/useLangs.ts +50 -50
  28. package/client/hooks/useSidebarControl.ts +78 -78
  29. package/client/hooks/useSize.ts +69 -69
  30. package/client/icons/dark.vue +8 -8
  31. package/client/icons/light.vue +8 -8
  32. package/client/utils/client/common.ts +49 -49
  33. package/client/utils/client/outline.ts +133 -126
  34. package/client/utils/common.ts +90 -90
  35. package/index.ts +45 -45
  36. package/package.json +2 -2
  37. package/shared/constants.ts +3 -3
  38. package/styles/base.scss +105 -105
  39. package/styles/code.scss +290 -290
  40. package/styles/doc-content.scss +363 -363
  41. package/styles/index.scss +71 -71
  42. package/styles/tag-content.scss +30 -30
@@ -1,304 +1,304 @@
1
- <script setup lang="ts">
2
- import type { DefaultTheme } from 'vitepress'
3
- import { Icon } from '@iconify/vue'
4
- import { computed } from 'vue'
5
- import { useSidebarControl } from '../hooks/useSidebarControl'
6
- import Link from './Link.vue'
7
-
8
- const props = defineProps<{
9
- item: DefaultTheme.SidebarItem & {
10
- hide?: boolean
11
- icon?: string
12
- promotion?: string
13
- }
14
- depth: number
15
- }>()
16
- const {
17
- collapsed,
18
- collapsible,
19
- isLink,
20
- isActiveLink,
21
- hasActiveLink,
22
- hasChildren,
23
- toggle,
24
- } = useSidebarControl(computed(() => props.item))
25
-
26
- const sectionTag = computed(() => (hasChildren.value ? 'section' : 'div'))
27
-
28
- const linkTag = computed(() => (isLink.value ? 'a' : 'div'))
29
-
30
- const textTag = computed(() => {
31
- return !hasChildren.value
32
- ? 'p'
33
- : props.depth + 2 === 7
34
- ? 'p'
35
- : `h${props.depth + 2}`
36
- })
37
-
38
- const itemRole = computed(() => (isLink.value ? undefined : 'button'))
39
-
40
- const classes = computed(() => [
41
- [`level-${props.depth}`],
42
- { collapsible: collapsible.value },
43
- { collapsed: collapsed.value },
44
- { 'is-link': isLink.value },
45
- { 'is-active': isActiveLink.value },
46
- { 'has-active': hasActiveLink.value },
47
- ])
48
-
49
- function onItemInteraction(e: MouseEvent | Event) {
50
- if ('key' in e && e.key !== 'Enter') {
51
- return
52
- }
53
- !props.item.link && toggle()
54
- }
55
- function onCaretClick() {
56
- props.item.link && toggle()
57
- }
58
-
59
- function onLinkAreaClick(e: MouseEvent) {
60
- const elA = (e.target as HTMLElement).querySelector('a')
61
- elA && elA.click()
62
- }
63
- </script>
64
-
65
- <template>
66
- <component :is="sectionTag" class="VPSidebarItem" :class="classes">
67
- <div
68
- v-if="item.text && !item.hide"
69
- class="item"
70
- :role="itemRole"
71
- :tabindex="item.items && 0"
72
- v-on="
73
- item.items
74
- ? { click: onItemInteraction, keydown: onItemInteraction }
75
- : { click: onLinkAreaClick }
76
- "
77
- >
78
- <div class="indicator" />
79
- <Icon
80
- v-if="item.icon && item.items"
81
- :icon="item.icon"
82
- style="margin-right: 5px;"
83
- ssr
84
- />
85
- <Link
86
- v-if="item.link"
87
- :tag="linkTag"
88
- class="link"
89
- :href="item.link"
90
- :rel="item.rel"
91
- :target="item.target"
92
- >
93
- <Icon
94
- v-if="item.icon && item.link"
95
- :icon="item.icon"
96
- class="text text-icon"
97
- ssr
98
- />
99
- <component :is="textTag" class="text" v-html="item.text" />
100
- <span v-if="item.promotion" class="version-tag vp-tag">
101
- {{ item.promotion }}
102
- </span>
103
- </Link>
104
- <component
105
- :is="textTag"
106
- v-else
107
- class="text"
108
- v-html="item.text"
109
- />
110
-
111
- <div
112
- v-if="item.collapsed !== undefined && item.items && item.items.length"
113
- class="caret"
114
- role="button"
115
- aria-label="toggle section"
116
- tabindex="0"
117
- @click="onCaretClick"
118
- @keydown.enter="onCaretClick"
119
- >
120
- <span class="vpi-chevron-right caret-icon" />
121
- </div>
122
- </div>
123
-
124
- <div v-if="item?.items && item?.items.length" class="items">
125
- <template v-if="depth < 5">
126
- <SidebarItem
127
- v-for="i in item.items"
128
- :key="i.text"
129
- :item="i"
130
- :depth="depth + 1"
131
- />
132
- </template>
133
- </div>
134
- </component>
135
- </template>
136
-
137
- <style scoped lang="scss">
138
- .VPSidebarItem.collapsed.level-0 {
139
- padding-bottom: 10px;
140
- }
141
-
142
- .item {
143
- position: relative;
144
- display: flex;
145
- width: 100%;
146
- display: flex;
147
- align-items: center;
148
- border-radius: 8px;
149
- transition: background-color 0.25s;
150
- cursor: pointer;
151
- }
152
-
153
- .VPSidebarItem.collapsible > .item {
154
- cursor: pointer;
155
- }
156
-
157
- .indicator {
158
- position: absolute;
159
- top: 6px;
160
- bottom: 6px;
161
- left: -17px;
162
- width: 2px;
163
- border-radius: 2px;
164
- transition: background-color 0.25s;
165
- }
166
-
167
- .VPSidebarItem.level-2.is-active > .item > .indicator,
168
- .VPSidebarItem.level-3.is-active > .item > .indicator,
169
- .VPSidebarItem.level-4.is-active > .item > .indicator,
170
- .VPSidebarItem.level-5.is-active > .item > .indicator {
171
- background-color: var(--vp-c-brand);
172
- }
173
-
174
- .link {
175
- display: flex;
176
- align-items: center;
177
- padding: 10px 16px;
178
- line-height: 20px;
179
- font-size: 13px;
180
- }
181
-
182
- .text {
183
- flex-grow: 1;
184
- line-height: 20px;
185
- transition: color 0.25s;
186
- }
187
- .text-icon {
188
- flex-grow: 0;
189
- padding: 0;
190
- margin-right: 4px;
191
- }
192
- .version-tag {
193
- margin-left: 8px;
194
- background-color: var(--bg-color);
195
- font-weight: normal;
196
- }
197
- .VPSidebarItem.level-0 > .item {
198
- color: var(--vp-c-text-1);
199
- margin-bottom: 8px;
200
- line-height: 24px;
201
- }
202
- .VPSidebarItem.level-0 > .item h2 {
203
- color: var(--vp-c-text-1);
204
- font-size: 1rem;
205
- font-weight: 700;
206
- line-height: 24px;
207
- }
208
-
209
- .VPSidebarItem.level-1,
210
- .VPSidebarItem.level-2,
211
- .VPSidebarItem.level-3,
212
- .VPSidebarItem.level-4,
213
- .VPSidebarItem.level-5 {
214
- font-weight: 500;
215
- color: var(--vp-c-text-2);
216
- }
217
-
218
- .VPSidebarItem.level-0.is-link > .item > .link:hover,
219
- .VPSidebarItem.level-1.is-link > .item > .link:hover,
220
- .VPSidebarItem.level-2.is-link > .item > .link:hover,
221
- .VPSidebarItem.level-3.is-link > .item > .link:hover,
222
- .VPSidebarItem.level-4.is-link > .item > .link:hover,
223
- .VPSidebarItem.level-5.is-link > .item > .link:hover {
224
- color: var(--vp-c-brand);
225
- }
226
-
227
- .VPSidebarItem.level-0.has-active > .item,
228
- .VPSidebarItem.level-1.has-active > .item,
229
- .VPSidebarItem.level-2.has-active > .item,
230
- .VPSidebarItem.level-3.has-active > .item,
231
- .VPSidebarItem.level-4.has-active > .item,
232
- .VPSidebarItem.level-5.has-active > .item,
233
- .VPSidebarItem.level-0.has-active > .item > .link,
234
- .VPSidebarItem.level-1.has-active > .item > .link,
235
- .VPSidebarItem.level-2.has-active > .item > .link,
236
- .VPSidebarItem.level-3.has-active > .item > .link,
237
- .VPSidebarItem.level-4.has-active > .item > .link,
238
- .VPSidebarItem.level-5.has-active > .item > .link {
239
- color: var(--vp-c-text-1);
240
- }
241
-
242
- .VPSidebarItem.level-0.is-active > .item .link,
243
- .VPSidebarItem.level-1.is-active > .item .link,
244
- .VPSidebarItem.level-2.is-active > .item .link,
245
- .VPSidebarItem.level-3.is-active > .item .link,
246
- .VPSidebarItem.level-4.is-active > .item .link,
247
- .VPSidebarItem.level-5.is-active > .item .link {
248
- color: var(--vp-c-brand);
249
- font-weight: 600;
250
- }
251
-
252
- .VPSidebarItem.level-0.is-active > .item,
253
- .VPSidebarItem.level-1.is-active > .item,
254
- .VPSidebarItem.level-2.is-active > .item,
255
- .VPSidebarItem.level-3.is-active > .item,
256
- .VPSidebarItem.level-4.is-active > .item,
257
- .VPSidebarItem.level-5.is-active > .item {
258
- background-color: var(--bg-brand-color);
259
- }
260
-
261
- .caret {
262
- display: flex;
263
- justify-content: center;
264
- align-items: center;
265
- margin-right: -7px;
266
- width: 32px;
267
- height: 32px;
268
- color: var(--vp-c-text-3);
269
- cursor: pointer;
270
- transition: color 0.25s;
271
- flex-shrink: 0;
272
- }
273
-
274
- .item:hover .caret {
275
- color: var(--vp-c-text-2);
276
- }
277
-
278
- .item:hover .caret:hover {
279
- color: var(--vp-c-text-1);
280
- }
281
-
282
- .caret-icon {
283
- font-size: 18px;
284
- transform: rotate(90deg);
285
- transition: transform 0.25s;
286
- }
287
-
288
- .VPSidebarItem.collapsed .caret-icon {
289
- transform: rotate(0);
290
- }
291
-
292
- .VPSidebarItem.level-1 .items,
293
- .VPSidebarItem.level-2 .items,
294
- .VPSidebarItem.level-3 .items,
295
- .VPSidebarItem.level-4 .items,
296
- .VPSidebarItem.level-5 .items {
297
- border-left: 1px solid var(--vp-c-divider);
298
- padding-left: 16px;
299
- }
300
-
301
- .VPSidebarItem.collapsed .items {
302
- display: none;
303
- }
304
- </style>
1
+ <script setup lang="ts">
2
+ import type { DefaultTheme } from 'vitepress'
3
+ import { Icon } from '@iconify/vue'
4
+ import { computed } from 'vue'
5
+ import { useSidebarControl } from '../hooks/useSidebarControl'
6
+ import Link from './Link.vue'
7
+
8
+ const props = defineProps<{
9
+ item: DefaultTheme.SidebarItem & {
10
+ hide?: boolean
11
+ icon?: string
12
+ promotion?: string
13
+ }
14
+ depth: number
15
+ }>()
16
+ const {
17
+ collapsed,
18
+ collapsible,
19
+ isLink,
20
+ isActiveLink,
21
+ hasActiveLink,
22
+ hasChildren,
23
+ toggle,
24
+ } = useSidebarControl(computed(() => props.item))
25
+
26
+ const sectionTag = computed(() => (hasChildren.value ? 'section' : 'div'))
27
+
28
+ const linkTag = computed(() => (isLink.value ? 'a' : 'div'))
29
+
30
+ const textTag = computed(() => {
31
+ return !hasChildren.value
32
+ ? 'p'
33
+ : props.depth + 2 === 7
34
+ ? 'p'
35
+ : `h${props.depth + 2}`
36
+ })
37
+
38
+ const itemRole = computed(() => (isLink.value ? undefined : 'button'))
39
+
40
+ const classes = computed(() => [
41
+ [`level-${props.depth}`],
42
+ { collapsible: collapsible.value },
43
+ { collapsed: collapsed.value },
44
+ { 'is-link': isLink.value },
45
+ { 'is-active': isActiveLink.value },
46
+ { 'has-active': hasActiveLink.value },
47
+ ])
48
+
49
+ function onItemInteraction(e: MouseEvent | Event) {
50
+ if ('key' in e && e.key !== 'Enter') {
51
+ return
52
+ }
53
+ !props.item.link && toggle()
54
+ }
55
+ function onCaretClick() {
56
+ props.item.link && toggle()
57
+ }
58
+
59
+ function onLinkAreaClick(e: MouseEvent) {
60
+ const elA = (e.target as HTMLElement).querySelector('a')
61
+ elA && elA.click()
62
+ }
63
+ </script>
64
+
65
+ <template>
66
+ <component :is="sectionTag" class="VPSidebarItem" :class="classes">
67
+ <div
68
+ v-if="item.text && !item.hide"
69
+ class="item"
70
+ :role="itemRole"
71
+ :tabindex="item.items && 0"
72
+ v-on="
73
+ item.items
74
+ ? { click: onItemInteraction, keydown: onItemInteraction }
75
+ : { click: onLinkAreaClick }
76
+ "
77
+ >
78
+ <div class="indicator" />
79
+ <Icon
80
+ v-if="item.icon && item.items"
81
+ :icon="item.icon"
82
+ style="margin-right: 5px;"
83
+ ssr
84
+ />
85
+ <Link
86
+ v-if="item.link"
87
+ :tag="linkTag"
88
+ class="link"
89
+ :href="item.link"
90
+ :rel="item.rel"
91
+ :target="item.target"
92
+ >
93
+ <Icon
94
+ v-if="item.icon && item.link"
95
+ :icon="item.icon"
96
+ class="text text-icon"
97
+ ssr
98
+ />
99
+ <component :is="textTag" class="text" v-html="item.text" />
100
+ <span v-if="item.promotion" class="version-tag vp-tag">
101
+ {{ item.promotion }}
102
+ </span>
103
+ </Link>
104
+ <component
105
+ :is="textTag"
106
+ v-else
107
+ class="text"
108
+ v-html="item.text"
109
+ />
110
+
111
+ <div
112
+ v-if="item.collapsed !== undefined && item.items && item.items.length"
113
+ class="caret"
114
+ role="button"
115
+ aria-label="toggle section"
116
+ tabindex="0"
117
+ @click="onCaretClick"
118
+ @keydown.enter="onCaretClick"
119
+ >
120
+ <span class="vpi-chevron-right caret-icon" />
121
+ </div>
122
+ </div>
123
+
124
+ <div v-if="item?.items && item?.items.length" class="items">
125
+ <template v-if="depth < 5">
126
+ <SidebarItem
127
+ v-for="i in item.items"
128
+ :key="i.text"
129
+ :item="i"
130
+ :depth="depth + 1"
131
+ />
132
+ </template>
133
+ </div>
134
+ </component>
135
+ </template>
136
+
137
+ <style scoped lang="scss">
138
+ .VPSidebarItem.collapsed.level-0 {
139
+ padding-bottom: 10px;
140
+ }
141
+
142
+ .item {
143
+ position: relative;
144
+ display: flex;
145
+ width: 100%;
146
+ display: flex;
147
+ align-items: center;
148
+ border-radius: 8px;
149
+ transition: background-color 0.25s;
150
+ cursor: pointer;
151
+ }
152
+
153
+ .VPSidebarItem.collapsible > .item {
154
+ cursor: pointer;
155
+ }
156
+
157
+ .indicator {
158
+ position: absolute;
159
+ top: 6px;
160
+ bottom: 6px;
161
+ left: -17px;
162
+ width: 2px;
163
+ border-radius: 2px;
164
+ transition: background-color 0.25s;
165
+ }
166
+
167
+ .VPSidebarItem.level-2.is-active > .item > .indicator,
168
+ .VPSidebarItem.level-3.is-active > .item > .indicator,
169
+ .VPSidebarItem.level-4.is-active > .item > .indicator,
170
+ .VPSidebarItem.level-5.is-active > .item > .indicator {
171
+ background-color: var(--vp-c-brand);
172
+ }
173
+
174
+ .link {
175
+ display: flex;
176
+ align-items: center;
177
+ padding: 10px 16px;
178
+ line-height: 20px;
179
+ font-size: 13px;
180
+ }
181
+
182
+ .text {
183
+ flex-grow: 1;
184
+ line-height: 20px;
185
+ transition: color 0.25s;
186
+ }
187
+ .text-icon {
188
+ flex-grow: 0;
189
+ padding: 0;
190
+ margin-right: 4px;
191
+ }
192
+ .version-tag {
193
+ margin-left: 8px;
194
+ background-color: var(--bg-color);
195
+ font-weight: normal;
196
+ }
197
+ .VPSidebarItem.level-0 > .item {
198
+ color: var(--vp-c-text-1);
199
+ margin-bottom: 8px;
200
+ line-height: 24px;
201
+ }
202
+ .VPSidebarItem.level-0 > .item h2 {
203
+ color: var(--vp-c-text-1);
204
+ font-size: 1rem;
205
+ font-weight: 700;
206
+ line-height: 24px;
207
+ }
208
+
209
+ .VPSidebarItem.level-1,
210
+ .VPSidebarItem.level-2,
211
+ .VPSidebarItem.level-3,
212
+ .VPSidebarItem.level-4,
213
+ .VPSidebarItem.level-5 {
214
+ font-weight: 500;
215
+ color: var(--vp-c-text-2);
216
+ }
217
+
218
+ .VPSidebarItem.level-0.is-link > .item > .link:hover,
219
+ .VPSidebarItem.level-1.is-link > .item > .link:hover,
220
+ .VPSidebarItem.level-2.is-link > .item > .link:hover,
221
+ .VPSidebarItem.level-3.is-link > .item > .link:hover,
222
+ .VPSidebarItem.level-4.is-link > .item > .link:hover,
223
+ .VPSidebarItem.level-5.is-link > .item > .link:hover {
224
+ color: var(--vp-c-brand);
225
+ }
226
+
227
+ .VPSidebarItem.level-0.has-active > .item,
228
+ .VPSidebarItem.level-1.has-active > .item,
229
+ .VPSidebarItem.level-2.has-active > .item,
230
+ .VPSidebarItem.level-3.has-active > .item,
231
+ .VPSidebarItem.level-4.has-active > .item,
232
+ .VPSidebarItem.level-5.has-active > .item,
233
+ .VPSidebarItem.level-0.has-active > .item > .link,
234
+ .VPSidebarItem.level-1.has-active > .item > .link,
235
+ .VPSidebarItem.level-2.has-active > .item > .link,
236
+ .VPSidebarItem.level-3.has-active > .item > .link,
237
+ .VPSidebarItem.level-4.has-active > .item > .link,
238
+ .VPSidebarItem.level-5.has-active > .item > .link {
239
+ color: var(--vp-c-text-1);
240
+ }
241
+
242
+ .VPSidebarItem.level-0.is-active > .item .link,
243
+ .VPSidebarItem.level-1.is-active > .item .link,
244
+ .VPSidebarItem.level-2.is-active > .item .link,
245
+ .VPSidebarItem.level-3.is-active > .item .link,
246
+ .VPSidebarItem.level-4.is-active > .item .link,
247
+ .VPSidebarItem.level-5.is-active > .item .link {
248
+ color: var(--vp-c-brand);
249
+ font-weight: 600;
250
+ }
251
+
252
+ .VPSidebarItem.level-0.is-active > .item,
253
+ .VPSidebarItem.level-1.is-active > .item,
254
+ .VPSidebarItem.level-2.is-active > .item,
255
+ .VPSidebarItem.level-3.is-active > .item,
256
+ .VPSidebarItem.level-4.is-active > .item,
257
+ .VPSidebarItem.level-5.is-active > .item {
258
+ background-color: var(--bg-brand-color);
259
+ }
260
+
261
+ .caret {
262
+ display: flex;
263
+ justify-content: center;
264
+ align-items: center;
265
+ margin-right: -7px;
266
+ width: 32px;
267
+ height: 32px;
268
+ color: var(--vp-c-text-3);
269
+ cursor: pointer;
270
+ transition: color 0.25s;
271
+ flex-shrink: 0;
272
+ }
273
+
274
+ .item:hover .caret {
275
+ color: var(--vp-c-text-2);
276
+ }
277
+
278
+ .item:hover .caret:hover {
279
+ color: var(--vp-c-text-1);
280
+ }
281
+
282
+ .caret-icon {
283
+ font-size: 18px;
284
+ transform: rotate(90deg);
285
+ transition: transform 0.25s;
286
+ }
287
+
288
+ .VPSidebarItem.collapsed .caret-icon {
289
+ transform: rotate(0);
290
+ }
291
+
292
+ .VPSidebarItem.level-1 .items,
293
+ .VPSidebarItem.level-2 .items,
294
+ .VPSidebarItem.level-3 .items,
295
+ .VPSidebarItem.level-4 .items,
296
+ .VPSidebarItem.level-5 .items {
297
+ border-left: 1px solid var(--vp-c-divider);
298
+ padding-left: 16px;
299
+ }
300
+
301
+ .VPSidebarItem.collapsed .items {
302
+ display: none;
303
+ }
304
+ </style>