vitepress 2.0.0-alpha.2 → 2.0.0-alpha.21
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/README.md +34 -2
- package/THIRD-PARTY-NOTICES.md +1736 -0
- package/bin/vitepress.js +14 -0
- package/client.d.ts +9 -0
- package/dist/client/app/components/ClientOnly.d.ts +5 -0
- package/dist/client/app/components/ClientOnly.js +11 -10
- package/dist/client/app/components/Content.d.ts +17 -0
- package/dist/client/app/components/Content.js +25 -22
- package/dist/client/app/composables/codeGroups.d.ts +3 -0
- package/dist/client/app/composables/codeGroups.js +36 -39
- package/dist/client/app/composables/copyCode.d.ts +3 -0
- package/dist/client/app/composables/copyCode.js +59 -70
- package/dist/client/app/composables/head.d.ts +5 -0
- package/dist/client/app/composables/head.js +56 -74
- package/dist/client/app/composables/icon.d.ts +12 -0
- package/dist/client/app/composables/icon.js +56 -0
- package/dist/client/app/composables/preFetch.d.ts +3 -0
- package/dist/client/app/composables/preFetch.js +64 -96
- package/dist/client/app/data.d.ts +9 -0
- package/dist/client/app/data.js +34 -59
- package/dist/client/app/devtools.d.ts +7 -0
- package/dist/client/app/devtools.js +29 -28
- package/dist/client/app/index.d.ts +11 -0
- package/dist/client/app/index.js +106 -131
- package/dist/client/app/router.d.ts +49 -0
- package/dist/client/app/router.js +198 -239
- package/dist/client/app/ssr.d.ts +4 -0
- package/dist/client/app/ssr.js +14 -9
- package/dist/client/app/theme.d.ts +24 -0
- package/dist/client/app/theme.js +0 -1
- package/dist/client/app/utils.d.ts +35 -0
- package/dist/client/app/utils.js +77 -110
- package/dist/client/index.d.ts +21 -137
- package/dist/client/index.js +8 -9
- package/dist/client/shared.d.ts +88 -0
- package/dist/client/shared.js +265 -141
- package/dist/client/theme-default/Layout.d.vue.ts +79 -0
- package/dist/client/theme-default/Layout.vue +33 -36
- package/dist/client/theme-default/NotFound.d.vue.ts +3 -0
- package/dist/client/theme-default/NotFound.vue +33 -35
- package/dist/client/theme-default/components/VPAlgoliaSearchBox.d.vue.ts +11 -0
- package/dist/client/theme-default/components/VPAlgoliaSearchBox.vue +202 -70
- package/dist/client/theme-default/components/VPBackdrop.d.vue.ts +6 -0
- package/dist/client/theme-default/components/VPBackdrop.vue +8 -12
- package/dist/client/theme-default/components/VPBadge.d.vue.ts +19 -0
- package/dist/client/theme-default/components/VPBadge.vue +49 -26
- package/dist/client/theme-default/components/VPButton.d.vue.ts +25 -0
- package/dist/client/theme-default/components/VPButton.vue +53 -36
- package/dist/client/theme-default/components/VPCarbonAds.d.vue.ts +7 -0
- package/dist/client/theme-default/components/VPCarbonAds.vue +51 -52
- package/dist/client/theme-default/components/VPContent.d.vue.ts +59 -0
- package/dist/client/theme-default/components/VPContent.vue +27 -26
- package/dist/client/theme-default/components/VPDoc.d.vue.ts +33 -0
- package/dist/client/theme-default/components/VPDoc.vue +52 -48
- package/dist/client/theme-default/components/VPDocAside.d.vue.ts +23 -0
- package/dist/client/theme-default/components/VPDocAside.vue +7 -8
- package/dist/client/theme-default/components/VPDocAsideCarbonAds.d.vue.ts +7 -0
- package/dist/client/theme-default/components/VPDocAsideCarbonAds.vue +7 -11
- package/dist/client/theme-default/components/VPDocAsideOutline.d.vue.ts +3 -0
- package/dist/client/theme-default/components/VPDocAsideOutline.vue +22 -38
- package/dist/client/theme-default/components/VPDocAsideSponsors.d.vue.ts +10 -0
- package/dist/client/theme-default/components/VPDocAsideSponsors.vue +17 -11
- package/dist/client/theme-default/components/VPDocFooter.d.vue.ts +13 -0
- package/dist/client/theme-default/components/VPDocFooter.vue +38 -45
- package/dist/client/theme-default/components/VPDocFooterLastUpdated.d.vue.ts +3 -0
- package/dist/client/theme-default/components/VPDocFooterLastUpdated.vue +30 -29
- package/dist/client/theme-default/components/VPDocOutlineItem.d.vue.ts +8 -0
- package/dist/client/theme-default/components/VPDocOutlineItem.vue +20 -19
- package/dist/client/theme-default/components/VPFeature.d.vue.ts +13 -0
- package/dist/client/theme-default/components/VPFeature.vue +62 -36
- package/dist/client/theme-default/components/VPFeatures.d.vue.ts +16 -0
- package/dist/client/theme-default/components/VPFeatures.vue +35 -48
- package/dist/client/theme-default/components/VPFlyout.d.vue.ts +26 -0
- package/dist/client/theme-default/components/VPFlyout.vue +111 -47
- package/dist/client/theme-default/components/VPFooter.d.vue.ts +3 -0
- package/dist/client/theme-default/components/VPFooter.vue +22 -15
- package/dist/client/theme-default/components/VPHero.d.vue.ts +38 -0
- package/dist/client/theme-default/components/VPHero.vue +109 -99
- package/dist/client/theme-default/components/VPHome.d.vue.ts +31 -0
- package/dist/client/theme-default/components/VPHome.vue +15 -15
- package/dist/client/theme-default/components/VPHomeContent.d.vue.ts +13 -0
- package/dist/client/theme-default/components/VPHomeContent.vue +9 -27
- package/dist/client/theme-default/components/VPHomeFeatures.d.vue.ts +3 -0
- package/dist/client/theme-default/components/VPHomeFeatures.vue +4 -5
- package/dist/client/theme-default/components/VPHomeHero.d.vue.ts +23 -0
- package/dist/client/theme-default/components/VPHomeHero.vue +5 -5
- package/dist/client/theme-default/components/VPHomeSponsors.d.vue.ts +21 -0
- package/dist/client/theme-default/components/VPHomeSponsors.vue +42 -43
- package/dist/client/theme-default/components/VPIcon.d.vue.ts +8 -0
- package/dist/client/theme-default/components/VPIcon.vue +29 -0
- package/dist/client/theme-default/components/VPImage.d.vue.ts +8 -0
- package/dist/client/theme-default/components/VPImage.vue +20 -14
- package/dist/client/theme-default/components/VPLink.d.vue.ts +23 -0
- package/dist/client/theme-default/components/VPLink.vue +42 -23
- package/dist/client/theme-default/components/VPLocalNav.d.vue.ts +10 -0
- package/dist/client/theme-default/components/VPLocalNav.vue +69 -86
- package/dist/client/theme-default/components/VPLocalNavOutlineDropdown.d.vue.ts +8 -0
- package/dist/client/theme-default/components/VPLocalNavOutlineDropdown.vue +98 -96
- package/dist/client/theme-default/components/VPLocalSearchBox.d.vue.ts +7 -0
- package/dist/client/theme-default/components/VPLocalSearchBox.vue +391 -454
- package/dist/client/theme-default/components/VPMenu.d.vue.ts +23 -0
- package/dist/client/theme-default/components/VPMenu.vue +19 -31
- package/dist/client/theme-default/components/VPMenuGroup.d.vue.ts +22 -0
- package/dist/client/theme-default/components/VPMenuGroup.vue +72 -18
- package/dist/client/theme-default/components/VPMenuLink.d.vue.ts +22 -0
- package/dist/client/theme-default/components/VPMenuLink.vue +65 -31
- package/dist/client/theme-default/components/VPNav.d.vue.ts +23 -0
- package/dist/client/theme-default/components/VPNav.vue +18 -24
- package/dist/client/theme-default/components/VPNavAppearance.d.vue.ts +9 -0
- package/dist/client/theme-default/components/VPNavAppearance.vue +88 -0
- package/dist/client/theme-default/components/VPNavBar.d.vue.ts +26 -0
- package/dist/client/theme-default/components/VPNavBar.vue +170 -142
- package/dist/client/theme-default/components/VPNavBarAskAiButton.d.vue.ts +3 -0
- package/dist/client/theme-default/components/VPNavBarAskAiButton.vue +31 -0
- package/dist/client/theme-default/components/VPNavBarExtra.d.vue.ts +3 -0
- package/dist/client/theme-default/components/VPNavBarExtra.vue +51 -73
- package/dist/client/theme-default/components/VPNavBarHamburger.d.vue.ts +10 -0
- package/dist/client/theme-default/components/VPNavBarHamburger.vue +38 -28
- package/dist/client/theme-default/components/VPNavBarSearch.d.vue.ts +3 -0
- package/dist/client/theme-default/components/VPNavBarSearch.vue +129 -160
- package/dist/client/theme-default/components/VPNavBarSearchButton.d.vue.ts +6 -0
- package/dist/client/theme-default/components/VPNavBarSearchButton.vue +48 -182
- package/dist/client/theme-default/components/VPNavBarTitle.d.vue.ts +15 -0
- package/dist/client/theme-default/components/VPNavBarTitle.vue +39 -38
- package/dist/client/theme-default/components/VPNavMenu.d.vue.ts +6 -0
- package/dist/client/theme-default/components/VPNavMenu.vue +76 -0
- package/dist/client/theme-default/components/VPNavMenuGroup.d.vue.ts +11 -0
- package/dist/client/theme-default/components/VPNavMenuGroup.vue +140 -0
- package/dist/client/theme-default/components/VPNavMenuLink.d.vue.ts +8 -0
- package/dist/client/theme-default/components/VPNavMenuLink.vue +69 -0
- package/dist/client/theme-default/components/VPNavScreen.d.vue.ts +18 -0
- package/dist/client/theme-default/components/VPNavScreen.vue +36 -34
- package/dist/client/theme-default/components/VPNavSocialLinks.d.vue.ts +6 -0
- package/dist/client/theme-default/components/VPNavSocialLinks.vue +36 -0
- package/dist/client/theme-default/components/VPNavTranslations.d.vue.ts +9 -0
- package/dist/client/theme-default/components/VPNavTranslations.vue +170 -0
- package/dist/client/theme-default/components/VPPage.d.vue.ts +15 -0
- package/dist/client/theme-default/components/VPSidebar.d.vue.ts +18 -0
- package/dist/client/theme-default/components/VPSidebar.vue +40 -53
- package/dist/client/theme-default/components/VPSidebarGroup.d.vue.ts +7 -0
- package/dist/client/theme-default/components/VPSidebarGroup.vue +24 -29
- package/dist/client/theme-default/components/VPSidebarItem.d.vue.ts +8 -0
- package/dist/client/theme-default/components/VPSidebarItem.vue +60 -93
- package/dist/client/theme-default/components/VPSkipLink.d.vue.ts +6 -0
- package/dist/client/theme-default/components/VPSkipLink.vue +23 -42
- package/dist/client/theme-default/components/VPSocialLink.d.vue.ts +11 -0
- package/dist/client/theme-default/components/VPSocialLink.vue +42 -49
- package/dist/client/theme-default/components/VPSocialLinks.d.vue.ts +10 -0
- package/dist/client/theme-default/components/VPSocialLinks.vue +26 -16
- package/dist/client/theme-default/components/VPSponsors.d.vue.ts +18 -0
- package/dist/client/theme-default/components/VPSponsors.vue +34 -33
- package/dist/client/theme-default/components/VPSponsorsGrid.d.vue.ts +15 -0
- package/dist/client/theme-default/components/VPSponsorsGrid.vue +23 -26
- package/dist/client/theme-default/components/VPSwitch.d.vue.ts +13 -0
- package/dist/client/theme-default/components/VPSwitch.vue +12 -13
- package/dist/client/theme-default/components/VPSwitchAppearance.d.vue.ts +3 -0
- package/dist/client/theme-default/components/VPSwitchAppearance.vue +16 -21
- package/dist/client/theme-default/components/VPTeamMembers.d.vue.ts +10 -0
- package/dist/client/theme-default/components/VPTeamMembers.vue +59 -32
- package/dist/client/theme-default/components/VPTeamMembersItem.d.vue.ts +10 -0
- package/dist/client/theme-default/components/VPTeamMembersItem.vue +62 -58
- package/dist/client/theme-default/components/VPTeamPage.d.vue.ts +13 -0
- package/dist/client/theme-default/components/VPTeamPage.vue +14 -14
- package/dist/client/theme-default/components/VPTeamPageSection.d.vue.ts +17 -0
- package/dist/client/theme-default/components/VPTeamPageSection.vue +20 -19
- package/dist/client/theme-default/components/VPTeamPageTitle.d.vue.ts +15 -0
- package/dist/client/theme-default/components/VPTeamPageTitle.vue +22 -22
- package/dist/client/theme-default/composables/data.d.ts +5 -0
- package/dist/client/theme-default/composables/data.js +5 -2
- package/dist/client/theme-default/composables/edit-link.d.ts +6 -0
- package/dist/client/theme-default/composables/edit-link.js +17 -15
- package/dist/client/theme-default/composables/flyout.d.ts +10 -0
- package/dist/client/theme-default/composables/flyout.js +33 -32
- package/dist/client/theme-default/composables/langs.d.ts +44 -0
- package/dist/client/theme-default/composables/langs.js +48 -24
- package/dist/client/theme-default/composables/layout.d.ts +13 -0
- package/dist/client/theme-default/composables/layout.js +68 -0
- package/dist/client/theme-default/composables/nav-overflow.d.ts +54 -0
- package/dist/client/theme-default/composables/nav-overflow.js +179 -0
- package/dist/client/theme-default/composables/nav.d.ts +25 -0
- package/dist/client/theme-default/composables/nav.js +58 -29
- package/dist/client/theme-default/composables/outline.d.ts +8 -0
- package/dist/client/theme-default/composables/outline.js +144 -166
- package/dist/client/theme-default/composables/prev-next.d.ts +16 -0
- package/dist/client/theme-default/composables/prev-next.js +34 -56
- package/dist/client/theme-default/composables/scroll-lock.d.ts +4 -0
- package/dist/client/theme-default/composables/scroll-lock.js +95 -0
- package/dist/client/theme-default/composables/sidebar.d.ts +25 -0
- package/dist/client/theme-default/composables/sidebar.js +96 -133
- package/dist/client/theme-default/composables/sponsor-grid.d.ts +10 -0
- package/dist/client/theme-default/composables/sponsor-grid.js +69 -76
- package/dist/client/theme-default/fonts/inter-italic-cyrillic-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-cyrillic.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-greek-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-greek.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-latin-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-latin.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-symbols.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-vietnamese.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-cyrillic-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-cyrillic.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-greek-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-greek.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-latin-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-latin.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-symbols.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-vietnamese.woff2 +0 -0
- package/dist/client/theme-default/index.d.ts +3 -0
- package/dist/client/theme-default/index.js +4 -3
- package/dist/client/theme-default/styles/base.css +279 -211
- package/dist/client/theme-default/styles/components/custom-block.css +12 -7
- package/dist/client/theme-default/styles/components/vp-code-group.css +13 -16
- package/dist/client/theme-default/styles/components/vp-code.css +10 -2
- package/dist/client/theme-default/styles/components/vp-doc.css +188 -142
- package/dist/client/theme-default/styles/components/vp-sponsor.css +48 -37
- package/dist/client/theme-default/styles/docsearch.css +138 -0
- package/dist/client/theme-default/styles/fonts.css +216 -55
- package/dist/client/theme-default/styles/icons.css +42 -22
- package/dist/client/theme-default/styles/vars.css +111 -46
- package/dist/client/theme-default/support/docsearch.d.ts +57 -0
- package/dist/client/theme-default/support/docsearch.js +145 -0
- package/dist/client/theme-default/support/local-search.d.ts +9 -0
- package/dist/client/theme-default/support/local-search.js +31 -0
- package/dist/client/theme-default/support/lru.d.ts +11 -0
- package/dist/client/theme-default/support/lru.js +30 -33
- package/dist/client/theme-default/support/reactivity.d.ts +4 -0
- package/dist/client/theme-default/support/reactivity.js +10 -0
- package/dist/client/theme-default/support/sidebar.d.ts +27 -0
- package/dist/client/theme-default/support/sidebar.js +69 -80
- package/dist/client/theme-default/support/translation.d.ts +6 -0
- package/dist/client/theme-default/support/translation.js +33 -47
- package/dist/client/theme-default/support/utils.d.ts +7 -0
- package/dist/client/theme-default/support/utils.js +39 -30
- package/dist/client/theme-default/without-fonts.d.ts +25 -0
- package/dist/client/theme-default/without-fonts.js +37 -36
- package/dist/node/chunk-BjrVv9r8.js +28627 -0
- package/dist/node/cli.d.ts +1 -0
- package/dist/node/cli.js +160 -423
- package/dist/node/index.d.ts +1761 -2476
- package/dist/node/index.js +1 -121
- package/dist/web-types.json +75 -0
- package/package.json +89 -98
- package/template/.vitepress/config.js +3 -1
- package/template/.vitepress/theme/style.css +3 -11
- package/theme.d.ts +30 -23
- package/types/default-theme.d.ts +109 -113
- package/types/docsearch.d.ts +61 -142
- package/types/shared.d.ts +469 -50
- package/dist/client/theme-default/components/VPNavBarAppearance.vue +0 -32
- package/dist/client/theme-default/components/VPNavBarMenu.vue +0 -40
- package/dist/client/theme-default/components/VPNavBarMenuGroup.vue +0 -42
- package/dist/client/theme-default/components/VPNavBarMenuLink.vue +0 -53
- package/dist/client/theme-default/components/VPNavBarSocialLinks.vue +0 -27
- package/dist/client/theme-default/components/VPNavBarTranslations.vue +0 -47
- package/dist/client/theme-default/components/VPNavScreenAppearance.vue +0 -40
- package/dist/client/theme-default/components/VPNavScreenMenu.vue +0 -26
- package/dist/client/theme-default/components/VPNavScreenMenuGroup.vue +0 -112
- package/dist/client/theme-default/components/VPNavScreenMenuGroupLink.vue +0 -40
- package/dist/client/theme-default/components/VPNavScreenMenuGroupSection.vue +0 -34
- package/dist/client/theme-default/components/VPNavScreenMenuLink.vue +0 -43
- package/dist/client/theme-default/components/VPNavScreenSocialLinks.vue +0 -14
- package/dist/client/theme-default/components/VPNavScreenTranslations.vue +0 -73
- package/dist/client/theme-default/components/icons/VPIconAlignJustify.vue +0 -8
- package/dist/client/theme-default/components/icons/VPIconAlignLeft.vue +0 -8
- package/dist/client/theme-default/components/icons/VPIconAlignRight.vue +0 -8
- package/dist/client/theme-default/components/icons/VPIconArrowLeft.vue +0 -7
- package/dist/client/theme-default/components/icons/VPIconArrowRight.vue +0 -7
- package/dist/client/theme-default/components/icons/VPIconChevronDown.vue +0 -5
- package/dist/client/theme-default/components/icons/VPIconChevronLeft.vue +0 -5
- package/dist/client/theme-default/components/icons/VPIconChevronRight.vue +0 -5
- package/dist/client/theme-default/components/icons/VPIconChevronUp.vue +0 -5
- package/dist/client/theme-default/components/icons/VPIconEdit.vue +0 -6
- package/dist/client/theme-default/components/icons/VPIconHeart.vue +0 -5
- package/dist/client/theme-default/components/icons/VPIconLanguages.vue +0 -9
- package/dist/client/theme-default/components/icons/VPIconMinus.vue +0 -5
- package/dist/client/theme-default/components/icons/VPIconMinusSquare.vue +0 -6
- package/dist/client/theme-default/components/icons/VPIconMoon.vue +0 -5
- package/dist/client/theme-default/components/icons/VPIconMoreHorizontal.vue +0 -7
- package/dist/client/theme-default/components/icons/VPIconPlus.vue +0 -5
- package/dist/client/theme-default/components/icons/VPIconPlusSquare.vue +0 -6
- package/dist/client/theme-default/components/icons/VPIconSun.vue +0 -13
- package/dist/client/theme-default/composables/aside.js +0 -17
- package/dist/client/theme-default/composables/local-nav.js +0 -18
- package/dist/node/chunk-C-d2RJOW.js +0 -470
- package/dist/node/chunk-CxQfvv8o.js +0 -49065
- package/dist/node/worker_shikiResolveLang.js +0 -13
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
import { onUnmounted, readonly, ref, watch } from
|
|
2
|
-
import { inBrowser } from
|
|
3
|
-
|
|
1
|
+
import { onUnmounted, readonly, ref, watch } from "vue";
|
|
2
|
+
import { inBrowser } from "vitepress";
|
|
3
|
+
//#region src/client/theme-default/composables/flyout.ts
|
|
4
|
+
const focusedElement = ref();
|
|
4
5
|
let active = false;
|
|
5
6
|
let listeners = 0;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
return readonly(focus);
|
|
7
|
+
function useFlyout(options) {
|
|
8
|
+
const focus = ref(false);
|
|
9
|
+
if (inBrowser) {
|
|
10
|
+
!active && activateFocusTracking();
|
|
11
|
+
listeners++;
|
|
12
|
+
const unwatch = watch(focusedElement, (el) => {
|
|
13
|
+
if (el === options.el.value || options.el.value?.contains(el)) {
|
|
14
|
+
focus.value = true;
|
|
15
|
+
options.onFocus?.();
|
|
16
|
+
} else {
|
|
17
|
+
focus.value = false;
|
|
18
|
+
options.onBlur?.();
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
onUnmounted(() => {
|
|
22
|
+
unwatch();
|
|
23
|
+
listeners--;
|
|
24
|
+
if (!listeners) deactivateFocusTracking();
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return readonly(focus);
|
|
30
28
|
}
|
|
31
29
|
function activateFocusTracking() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
document.addEventListener("focusin", handleFocusIn);
|
|
31
|
+
active = true;
|
|
32
|
+
focusedElement.value = document.activeElement;
|
|
35
33
|
}
|
|
36
34
|
function deactivateFocusTracking() {
|
|
37
|
-
|
|
35
|
+
document.removeEventListener("focusin", handleFocusIn);
|
|
36
|
+
active = false;
|
|
38
37
|
}
|
|
39
38
|
function handleFocusIn() {
|
|
40
|
-
|
|
39
|
+
focusedElement.value = document.activeElement;
|
|
41
40
|
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { focusedElement, useFlyout };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Route, VitePressData } from "../../shared.js";
|
|
2
|
+
import { DefaultTheme } from "vitepress/theme";
|
|
3
|
+
//#region src/client/theme-default/composables/langs.d.ts
|
|
4
|
+
export declare function useLangs({ linkToCorrespondingPage }?: {
|
|
5
|
+
/**
|
|
6
|
+
* Link each entry of the translations menu to the current page's
|
|
7
|
+
* equivalent in that locale (resolved by `resolveLocaleLink`) instead of
|
|
8
|
+
* that locale's home page.
|
|
9
|
+
*/
|
|
10
|
+
linkToCorrespondingPage?: boolean;
|
|
11
|
+
}): {
|
|
12
|
+
currentLang: import("vue").ComputedRef<{
|
|
13
|
+
label: string | undefined;
|
|
14
|
+
link: string;
|
|
15
|
+
}>;
|
|
16
|
+
localeLinks: import("vue").ComputedRef<{
|
|
17
|
+
text: string;
|
|
18
|
+
link: string;
|
|
19
|
+
lang: string | undefined;
|
|
20
|
+
dir: "ltr" | "rtl" | "auto" | undefined;
|
|
21
|
+
}[]>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Resolves the link used for switching from the current page to
|
|
25
|
+
* `targetLocale`. Without `linkToCorrespondingPage`, this is simply the home
|
|
26
|
+
* of the target locale. With it, the current page's path is rewritten into
|
|
27
|
+
* the target locale (honoring `cleanUrls`) — unless
|
|
28
|
+
* `themeConfig.i18nRouting` is `false` (the locale home is used instead) or
|
|
29
|
+
* a function (which then fully controls the resolution).
|
|
30
|
+
*
|
|
31
|
+
* The current query and hash are carried over, except when a custom
|
|
32
|
+
* `i18nRouting` function is used.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveLocaleLink(data: VitePressData<DefaultTheme.Config>, route: Route, { targetLocale, targetLocaleLink, currentLocaleLink, linkToCorrespondingPage }: {
|
|
35
|
+
/** Key of the target locale in `site.locales`, e.g. `'fr'` or `'root'`. */
|
|
36
|
+
targetLocale: string;
|
|
37
|
+
/** Home link of the target locale, e.g. `'/fr/'`. */
|
|
38
|
+
targetLocaleLink: string;
|
|
39
|
+
/** Home link of the locale the current page is in, e.g. `'/'`. */
|
|
40
|
+
currentLocaleLink: string;
|
|
41
|
+
/** Link to the current page's equivalent instead of the locale home. */
|
|
42
|
+
linkToCorrespondingPage: boolean;
|
|
43
|
+
}): string;
|
|
44
|
+
//#endregion
|
|
@@ -1,26 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { useRoute } from "../../app/router.js";
|
|
2
|
+
import { useData } from "./data.js";
|
|
3
|
+
import { ensureStartingSlash } from "../support/utils.js";
|
|
4
|
+
import { computed } from "vue";
|
|
5
|
+
//#region src/client/theme-default/composables/langs.ts
|
|
6
|
+
function useLangs({ linkToCorrespondingPage = false } = {}) {
|
|
7
|
+
const data = useData();
|
|
8
|
+
const route = useRoute();
|
|
9
|
+
const { site, localeIndex } = data;
|
|
10
|
+
const currentLang = computed(() => ({
|
|
11
|
+
label: site.value.locales[localeIndex.value]?.label,
|
|
12
|
+
link: site.value.locales[localeIndex.value]?.link || (localeIndex.value === "root" ? "/" : `/${localeIndex.value}/`)
|
|
13
|
+
}));
|
|
14
|
+
return {
|
|
15
|
+
currentLang,
|
|
16
|
+
localeLinks: computed(() => Object.entries(site.value.locales).flatMap(([key, value]) => currentLang.value.label === value.label ? [] : {
|
|
17
|
+
text: value.label,
|
|
18
|
+
link: resolveLocaleLink(data, route, {
|
|
19
|
+
targetLocale: key,
|
|
20
|
+
targetLocaleLink: value.link || (key === "root" ? "/" : `/${key}/`),
|
|
21
|
+
currentLocaleLink: currentLang.value.link,
|
|
22
|
+
linkToCorrespondingPage
|
|
23
|
+
}),
|
|
24
|
+
lang: value.lang,
|
|
25
|
+
dir: value.dir
|
|
26
|
+
}))
|
|
27
|
+
};
|
|
18
28
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Resolves the link used for switching from the current page to
|
|
31
|
+
* `targetLocale`. Without `linkToCorrespondingPage`, this is simply the home
|
|
32
|
+
* of the target locale. With it, the current page's path is rewritten into
|
|
33
|
+
* the target locale (honoring `cleanUrls`) — unless
|
|
34
|
+
* `themeConfig.i18nRouting` is `false` (the locale home is used instead) or
|
|
35
|
+
* a function (which then fully controls the resolution).
|
|
36
|
+
*
|
|
37
|
+
* The current query and hash are carried over, except when a custom
|
|
38
|
+
* `i18nRouting` function is used.
|
|
39
|
+
*/
|
|
40
|
+
function resolveLocaleLink(data, route, { targetLocale, targetLocaleLink, currentLocaleLink, linkToCorrespondingPage }) {
|
|
41
|
+
const { site, theme } = data;
|
|
42
|
+
const i18nRouting = theme.value.i18nRouting;
|
|
43
|
+
if (linkToCorrespondingPage && typeof i18nRouting === "function") return i18nRouting(data, route, targetLocale);
|
|
44
|
+
return normalizeLink(targetLocaleLink, i18nRouting !== false && linkToCorrespondingPage, route.data.relativePath.slice(currentLocaleLink.length - 1), !site.value.cleanUrls) + route.query + route.hash;
|
|
26
45
|
}
|
|
46
|
+
function normalizeLink(localeLink, appendPagePath, pagePath, addHtmlExt) {
|
|
47
|
+
return appendPagePath ? localeLink.replace(/\/$/, "") + ensureStartingSlash(pagePath.replace(/(^|\/)index\.md$/, "$1").replace(/\.md$/, addHtmlExt ? ".html" : "")) : localeLink;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { resolveLocaleLink, useLangs };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComputedRef, InjectionKey } from "vue";
|
|
2
|
+
import { DefaultTheme } from "vitepress/theme";
|
|
3
|
+
//#region src/client/theme-default/composables/layout.d.ts
|
|
4
|
+
export declare function useLayout(): DefaultTheme.Layout;
|
|
5
|
+
interface RegisterWatchersOptions {
|
|
6
|
+
closeSidebar: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function registerWatchers({ closeSidebar }: RegisterWatchersOptions): void;
|
|
9
|
+
export interface LayoutInfo {
|
|
10
|
+
heroImageSlotExists: ComputedRef<boolean>;
|
|
11
|
+
}
|
|
12
|
+
export declare const layoutInfoInjectionKey: InjectionKey<LayoutInfo>;
|
|
13
|
+
//#endregion
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useData as useData$1 } from "./data.js";
|
|
2
|
+
import { getSidebar, getSidebarGroups } from "../support/sidebar.js";
|
|
3
|
+
import { getHeaders } from "./outline.js";
|
|
4
|
+
import { useCloseSidebarOnEscape } from "./sidebar.js";
|
|
5
|
+
import { computed, shallowReadonly, shallowRef, watch } from "vue";
|
|
6
|
+
import { onContentUpdated, useRoute } from "vitepress";
|
|
7
|
+
import { useMediaQuery } from "@vueuse/core";
|
|
8
|
+
//#region src/client/theme-default/composables/layout.ts
|
|
9
|
+
const headers = shallowRef([]);
|
|
10
|
+
const sidebar = shallowRef([]);
|
|
11
|
+
const isDesktop = useMediaQuery("(min-width: 60rem)");
|
|
12
|
+
function useLayout() {
|
|
13
|
+
const { frontmatter, theme } = useData$1();
|
|
14
|
+
const isHome = computed(() => {
|
|
15
|
+
return !!(frontmatter.value.isHome ?? frontmatter.value.layout === "home");
|
|
16
|
+
});
|
|
17
|
+
const hasSidebar = computed(() => {
|
|
18
|
+
return frontmatter.value.sidebar !== false && sidebar.value.length > 0 && !isHome.value;
|
|
19
|
+
});
|
|
20
|
+
const isSidebarEnabled = computed(() => hasSidebar.value && isDesktop.value);
|
|
21
|
+
const sidebarGroups = computed(() => {
|
|
22
|
+
return hasSidebar.value ? getSidebarGroups(sidebar.value) : [];
|
|
23
|
+
});
|
|
24
|
+
const hasAside = computed(() => {
|
|
25
|
+
if (isHome.value) return false;
|
|
26
|
+
if (frontmatter.value.aside != null) return !!frontmatter.value.aside;
|
|
27
|
+
return theme.value.aside !== false;
|
|
28
|
+
});
|
|
29
|
+
const leftAside = computed(() => {
|
|
30
|
+
if (!hasAside.value) return false;
|
|
31
|
+
return frontmatter.value.aside == null ? theme.value.aside === "left" : frontmatter.value.aside === "left";
|
|
32
|
+
});
|
|
33
|
+
const hasLocalNav = computed(() => {
|
|
34
|
+
return headers.value.length > 0;
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
isHome,
|
|
38
|
+
sidebar: shallowReadonly(sidebar),
|
|
39
|
+
sidebarGroups,
|
|
40
|
+
hasSidebar,
|
|
41
|
+
isSidebarEnabled,
|
|
42
|
+
hasAside,
|
|
43
|
+
leftAside,
|
|
44
|
+
headers: shallowReadonly(headers),
|
|
45
|
+
hasLocalNav
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function registerWatchers({ closeSidebar }) {
|
|
49
|
+
const { theme, page, frontmatter } = useData$1();
|
|
50
|
+
watch(() => [page.value.relativePath, theme.value.sidebar], ([relativePath, sidebarConfig]) => {
|
|
51
|
+
const newSidebar = sidebarConfig ? getSidebar(sidebarConfig, relativePath) : [];
|
|
52
|
+
if (JSON.stringify(newSidebar) !== JSON.stringify(sidebar.value)) sidebar.value = newSidebar;
|
|
53
|
+
}, {
|
|
54
|
+
immediate: true,
|
|
55
|
+
deep: true,
|
|
56
|
+
flush: "sync"
|
|
57
|
+
});
|
|
58
|
+
onContentUpdated(() => {
|
|
59
|
+
headers.value = getHeaders(frontmatter.value.outline ?? theme.value.outline);
|
|
60
|
+
});
|
|
61
|
+
const route = useRoute();
|
|
62
|
+
watch(() => route.path, closeSidebar);
|
|
63
|
+
watch(isDesktop, closeSidebar);
|
|
64
|
+
useCloseSidebarOnEscape(closeSidebar);
|
|
65
|
+
}
|
|
66
|
+
const layoutInfoInjectionKey = Symbol("layout-info");
|
|
67
|
+
//#endregion
|
|
68
|
+
export { layoutInfoInjectionKey, registerWatchers, useLayout };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { MaybeRefOrGetter } from "vue";
|
|
2
|
+
//#region src/client/theme-default/composables/nav-overflow.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Priority+ overflow for the navbar (#1271, #2842).
|
|
5
|
+
*
|
|
6
|
+
* Collapse order under space pressure: social links → appearance switch →
|
|
7
|
+
* translations → menu items right-to-left. Collapsed units move into the
|
|
8
|
+
* `⋯` flyout (VPNavBarExtra) instead of being clipped, so nothing ever
|
|
9
|
+
* becomes unreachable.
|
|
10
|
+
*
|
|
11
|
+
* Collapsed units stay mounted but hidden (visibility: hidden + absolute,
|
|
12
|
+
* which also removes them from the a11y tree and tab order), so their
|
|
13
|
+
* natural widths remain measurable and observed — re-expanding never works
|
|
14
|
+
* from stale data.
|
|
15
|
+
*/
|
|
16
|
+
export declare const navClusterUnits: readonly ["translations", "appearance", "socialLinks"];
|
|
17
|
+
export type NavClusterUnit = (typeof navClusterUnits)[number];
|
|
18
|
+
export interface NavFitInput {
|
|
19
|
+
/** widths of the top-level menu items, in nav order (px) */
|
|
20
|
+
itemWidths: number[];
|
|
21
|
+
/** cluster unit widths; null = the unit isn't configured on this site */
|
|
22
|
+
translations: number | null;
|
|
23
|
+
appearance: number | null;
|
|
24
|
+
socialLinks: number | null;
|
|
25
|
+
/** px available to all collapsible units */
|
|
26
|
+
available: number;
|
|
27
|
+
/** px the `⋯` button occupies once anything is collapsed */
|
|
28
|
+
extraWidth: number;
|
|
29
|
+
}
|
|
30
|
+
export interface NavFitResult {
|
|
31
|
+
/** number of menu items that stay in the bar (Infinity = all) */
|
|
32
|
+
visibleItemCount: number;
|
|
33
|
+
translations: boolean;
|
|
34
|
+
appearance: boolean;
|
|
35
|
+
socialLinks: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare function computeNavFit(input: NavFitInput): NavFitResult;
|
|
38
|
+
export interface NavOverflow {
|
|
39
|
+
/** reactive collapse state, all-visible during SSR and below 48rem */
|
|
40
|
+
state: NavFitResult;
|
|
41
|
+
/** true when anything is collapsed into the `⋯` menu */
|
|
42
|
+
hasCollapsed: () => boolean;
|
|
43
|
+
setContainerEl(el: HTMLElement | null): void;
|
|
44
|
+
setMenuEl(el: HTMLElement | null): void;
|
|
45
|
+
setExtraEl(el: HTMLElement | null): void;
|
|
46
|
+
setItemEl(index: number, el: HTMLElement | null): void;
|
|
47
|
+
setClusterEl(unit: NavClusterUnit, el: HTMLElement | null): void;
|
|
48
|
+
}
|
|
49
|
+
export declare function useNavOverflow(): NavOverflow | null;
|
|
50
|
+
export declare function provideNavOverflow(options: {
|
|
51
|
+
/** stringified nav config — collapse state resets when it changes */
|
|
52
|
+
itemsKey: MaybeRefOrGetter<string>;
|
|
53
|
+
}): NavOverflow;
|
|
54
|
+
//#endregion
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { inject, onScopeDispose, provide, reactive, toValue, watch } from "vue";
|
|
2
|
+
import { inBrowser } from "vitepress";
|
|
3
|
+
import { useMediaQuery } from "@vueuse/core";
|
|
4
|
+
//#region src/client/theme-default/composables/nav-overflow.ts
|
|
5
|
+
/**
|
|
6
|
+
* Priority+ overflow for the navbar (#1271, #2842).
|
|
7
|
+
*
|
|
8
|
+
* Collapse order under space pressure: social links → appearance switch →
|
|
9
|
+
* translations → menu items right-to-left. Collapsed units move into the
|
|
10
|
+
* `⋯` flyout (VPNavBarExtra) instead of being clipped, so nothing ever
|
|
11
|
+
* becomes unreachable.
|
|
12
|
+
*
|
|
13
|
+
* Collapsed units stay mounted but hidden (visibility: hidden + absolute,
|
|
14
|
+
* which also removes them from the a11y tree and tab order), so their
|
|
15
|
+
* natural widths remain measurable and observed — re-expanding never works
|
|
16
|
+
* from stale data.
|
|
17
|
+
*/
|
|
18
|
+
const navClusterUnits = [
|
|
19
|
+
"translations",
|
|
20
|
+
"appearance",
|
|
21
|
+
"socialLinks"
|
|
22
|
+
];
|
|
23
|
+
const allVisible = {
|
|
24
|
+
visibleItemCount: Infinity,
|
|
25
|
+
translations: true,
|
|
26
|
+
appearance: true,
|
|
27
|
+
socialLinks: true
|
|
28
|
+
};
|
|
29
|
+
function computeNavFit(input) {
|
|
30
|
+
const { itemWidths, available, extraWidth } = input;
|
|
31
|
+
const itemsTotal = itemWidths.reduce((sum, w) => sum + w, 0);
|
|
32
|
+
if (itemsTotal + ((input.translations ?? 0) + (input.appearance ?? 0) + (input.socialLinks ?? 0)) <= available) return allVisible;
|
|
33
|
+
const budget = available - extraWidth;
|
|
34
|
+
if (itemsTotal > budget) {
|
|
35
|
+
let used = 0;
|
|
36
|
+
let visibleItemCount = 0;
|
|
37
|
+
for (const width of itemWidths) {
|
|
38
|
+
if (used + width > budget) break;
|
|
39
|
+
used += width;
|
|
40
|
+
visibleItemCount++;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
visibleItemCount,
|
|
44
|
+
translations: input.translations == null,
|
|
45
|
+
appearance: input.appearance == null,
|
|
46
|
+
socialLinks: input.socialLinks == null
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const result = { ...allVisible };
|
|
50
|
+
let used = itemsTotal;
|
|
51
|
+
let dropRest = false;
|
|
52
|
+
for (const unit of navClusterUnits) {
|
|
53
|
+
const width = input[unit];
|
|
54
|
+
if (width == null) continue;
|
|
55
|
+
if (dropRest || used + width > budget) {
|
|
56
|
+
dropRest = true;
|
|
57
|
+
result[unit] = false;
|
|
58
|
+
} else used += width;
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
/** headroom against sub-pixel rounding and the inter-unit dividers */
|
|
63
|
+
const SLACK = 24;
|
|
64
|
+
/** used until the real `⋯` button has been measured once */
|
|
65
|
+
const EXTRA_WIDTH_ESTIMATE = 48;
|
|
66
|
+
const navOverflowKey = Symbol("nav-overflow");
|
|
67
|
+
function useNavOverflow() {
|
|
68
|
+
return inject(navOverflowKey, null);
|
|
69
|
+
}
|
|
70
|
+
function provideNavOverflow(options) {
|
|
71
|
+
const state = reactive({ ...allVisible });
|
|
72
|
+
const itemEls = /* @__PURE__ */ new Map();
|
|
73
|
+
const clusterEls = /* @__PURE__ */ new Map();
|
|
74
|
+
let containerEl = null;
|
|
75
|
+
let menuEl = null;
|
|
76
|
+
let extraEl = null;
|
|
77
|
+
let extraWidth = EXTRA_WIDTH_ESTIMATE;
|
|
78
|
+
let observer = null;
|
|
79
|
+
const observed = /* @__PURE__ */ new Set();
|
|
80
|
+
let scheduled = false;
|
|
81
|
+
function observe(el) {
|
|
82
|
+
if (!inBrowser || !(el instanceof Element) || observed.has(el)) return;
|
|
83
|
+
observed.add(el);
|
|
84
|
+
(observer ??= new ResizeObserver(schedule)).observe(el);
|
|
85
|
+
}
|
|
86
|
+
function schedule() {
|
|
87
|
+
if (!inBrowser || scheduled) return;
|
|
88
|
+
scheduled = true;
|
|
89
|
+
requestAnimationFrame(() => {
|
|
90
|
+
scheduled = false;
|
|
91
|
+
recompute();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
const controller = {
|
|
95
|
+
state,
|
|
96
|
+
hasCollapsed: () => state.visibleItemCount !== Infinity || !state.translations || !state.appearance || !state.socialLinks,
|
|
97
|
+
setContainerEl(el) {
|
|
98
|
+
containerEl = el;
|
|
99
|
+
observe(el);
|
|
100
|
+
schedule();
|
|
101
|
+
},
|
|
102
|
+
setMenuEl(el) {
|
|
103
|
+
menuEl = el;
|
|
104
|
+
observe(el);
|
|
105
|
+
schedule();
|
|
106
|
+
},
|
|
107
|
+
setExtraEl(el) {
|
|
108
|
+
extraEl = el;
|
|
109
|
+
observe(el);
|
|
110
|
+
schedule();
|
|
111
|
+
},
|
|
112
|
+
setItemEl(index, el) {
|
|
113
|
+
el ? itemEls.set(index, el) : itemEls.delete(index);
|
|
114
|
+
observe(el);
|
|
115
|
+
schedule();
|
|
116
|
+
},
|
|
117
|
+
setClusterEl(unit, el) {
|
|
118
|
+
el ? clusterEls.set(unit, el) : clusterEls.delete(unit);
|
|
119
|
+
observe(el);
|
|
120
|
+
schedule();
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
provide(navOverflowKey, controller);
|
|
124
|
+
if (!inBrowser) return controller;
|
|
125
|
+
const isEngineActive = useMediaQuery("(min-width: 48rem)");
|
|
126
|
+
function measureUnit(el) {
|
|
127
|
+
return Math.max(el.offsetWidth, el.scrollWidth);
|
|
128
|
+
}
|
|
129
|
+
function recompute() {
|
|
130
|
+
if (!isEngineActive.value) return applyResult(allVisible);
|
|
131
|
+
if (!containerEl) return;
|
|
132
|
+
if (extraEl && extraEl.offsetWidth > 0) extraWidth = extraEl.offsetWidth;
|
|
133
|
+
let fixed = 0;
|
|
134
|
+
for (const child of Array.from(containerEl.children)) {
|
|
135
|
+
if (!(child instanceof HTMLElement)) continue;
|
|
136
|
+
if (child === menuEl || child === extraEl) continue;
|
|
137
|
+
let isCluster = false;
|
|
138
|
+
for (const el of clusterEls.values()) if (el === child) {
|
|
139
|
+
isCluster = true;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
if (isCluster) continue;
|
|
143
|
+
fixed += child.offsetWidth;
|
|
144
|
+
}
|
|
145
|
+
const itemWidths = [];
|
|
146
|
+
for (let i = 0; i < itemEls.size; i++) {
|
|
147
|
+
const el = itemEls.get(i);
|
|
148
|
+
if (!el) return;
|
|
149
|
+
itemWidths.push(measureUnit(el));
|
|
150
|
+
}
|
|
151
|
+
const clusterWidth = (unit) => {
|
|
152
|
+
const el = clusterEls.get(unit);
|
|
153
|
+
return el ? measureUnit(el) : null;
|
|
154
|
+
};
|
|
155
|
+
applyResult(computeNavFit({
|
|
156
|
+
itemWidths,
|
|
157
|
+
translations: clusterWidth("translations"),
|
|
158
|
+
appearance: clusterWidth("appearance"),
|
|
159
|
+
socialLinks: clusterWidth("socialLinks"),
|
|
160
|
+
available: containerEl.clientWidth - fixed - SLACK,
|
|
161
|
+
extraWidth
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
function applyResult(result) {
|
|
165
|
+
if (state.visibleItemCount !== result.visibleItemCount) state.visibleItemCount = result.visibleItemCount;
|
|
166
|
+
for (const unit of navClusterUnits) if (state[unit] !== result[unit]) state[unit] = result[unit];
|
|
167
|
+
}
|
|
168
|
+
watch(isEngineActive, schedule);
|
|
169
|
+
watch(() => toValue(options.itemsKey), schedule);
|
|
170
|
+
if (document.fonts?.ready) document.fonts.ready.then(schedule).catch(() => {});
|
|
171
|
+
onScopeDispose(() => {
|
|
172
|
+
observer?.disconnect();
|
|
173
|
+
observer = null;
|
|
174
|
+
observed.clear();
|
|
175
|
+
});
|
|
176
|
+
return controller;
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
export { computeNavFit, navClusterUnits, provideNavOverflow, useNavOverflow };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { InjectionKey, MaybeRefOrGetter } from "vue";
|
|
2
|
+
import { DefaultTheme } from "vitepress/theme";
|
|
3
|
+
//#region src/client/theme-default/composables/nav.d.ts
|
|
4
|
+
declare function openScreen(): void;
|
|
5
|
+
declare function closeScreen(): void;
|
|
6
|
+
declare function toggleScreen(): void;
|
|
7
|
+
export declare function useNav(): {
|
|
8
|
+
isScreenOpen: import("vue").Ref<boolean, boolean>;
|
|
9
|
+
screenTriggerEl: import("vue").ShallowRef<HTMLButtonElement | null, HTMLButtonElement | null>;
|
|
10
|
+
openScreen: typeof openScreen;
|
|
11
|
+
closeScreen: typeof closeScreen;
|
|
12
|
+
toggleScreen: typeof toggleScreen;
|
|
13
|
+
};
|
|
14
|
+
export declare function useAppearanceSwitch(): import("vue").ComputedRef<boolean>;
|
|
15
|
+
export declare function useNavItemLink(item: MaybeRefOrGetter<DefaultTheme.NavItemWithLink>): {
|
|
16
|
+
href: import("vue").ComputedRef<string>;
|
|
17
|
+
isActiveLink: import("vue").ComputedRef<boolean>;
|
|
18
|
+
isCurrentLink: import("vue").ComputedRef<boolean>;
|
|
19
|
+
};
|
|
20
|
+
export interface NavExposedMethods {
|
|
21
|
+
closeScreen: () => void;
|
|
22
|
+
}
|
|
23
|
+
export declare const navInjectionKey: InjectionKey<NavExposedMethods>;
|
|
24
|
+
export declare const navScreenInjectionKey: InjectionKey<boolean>;
|
|
25
|
+
//#endregion
|
|
@@ -1,30 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
window.removeEventListener('resize', closeScreenOnTabletWindow);
|
|
12
|
-
}
|
|
13
|
-
function toggleScreen() {
|
|
14
|
-
isScreenOpen.value ? closeScreen() : openScreen();
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Close screen when the user resizes the window wider than tablet size.
|
|
18
|
-
*/
|
|
19
|
-
function closeScreenOnTabletWindow() {
|
|
20
|
-
window.outerWidth >= 768 && closeScreen();
|
|
21
|
-
}
|
|
22
|
-
const route = useRoute();
|
|
23
|
-
watch(() => route.path, closeScreen);
|
|
24
|
-
return {
|
|
25
|
-
isScreenOpen,
|
|
26
|
-
openScreen,
|
|
27
|
-
closeScreen,
|
|
28
|
-
toggleScreen
|
|
29
|
-
};
|
|
1
|
+
import { isActive } from "../../shared.js";
|
|
2
|
+
import { useData as useData$1 } from "./data.js";
|
|
3
|
+
import { computed, ref, shallowRef, toValue, watch } from "vue";
|
|
4
|
+
import { inBrowser, useRoute } from "vitepress";
|
|
5
|
+
import { useMediaQuery, whenever } from "@vueuse/core";
|
|
6
|
+
//#region src/client/theme-default/composables/nav.ts
|
|
7
|
+
const isScreenOpen = ref(false);
|
|
8
|
+
const screenTriggerEl = shallowRef(null);
|
|
9
|
+
function openScreen() {
|
|
10
|
+
isScreenOpen.value = true;
|
|
30
11
|
}
|
|
12
|
+
function closeScreen() {
|
|
13
|
+
isScreenOpen.value = false;
|
|
14
|
+
}
|
|
15
|
+
function toggleScreen() {
|
|
16
|
+
isScreenOpen.value ? closeScreen() : openScreen();
|
|
17
|
+
}
|
|
18
|
+
let watchersRegistered = false;
|
|
19
|
+
function useNav() {
|
|
20
|
+
if (inBrowser && !watchersRegistered) {
|
|
21
|
+
watchersRegistered = true;
|
|
22
|
+
const isTablet = useMediaQuery("(min-width: 48rem)");
|
|
23
|
+
whenever(isTablet, closeScreen);
|
|
24
|
+
const route = useRoute();
|
|
25
|
+
watch(() => route.path, closeScreen);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
isScreenOpen,
|
|
29
|
+
screenTriggerEl,
|
|
30
|
+
openScreen,
|
|
31
|
+
closeScreen,
|
|
32
|
+
toggleScreen
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function useAppearanceSwitch() {
|
|
36
|
+
const { site } = useData$1();
|
|
37
|
+
return computed(() => !!site.value.appearance && site.value.appearance !== "force-dark" && site.value.appearance !== "force-auto");
|
|
38
|
+
}
|
|
39
|
+
function useNavItemLink(item) {
|
|
40
|
+
const route = useRoute();
|
|
41
|
+
const href = computed(() => {
|
|
42
|
+
const { link } = toValue(item);
|
|
43
|
+
return typeof link === "function" ? link(route.data) : link;
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
href,
|
|
47
|
+
isActiveLink: computed(() => {
|
|
48
|
+
const { activeMatch } = toValue(item);
|
|
49
|
+
return isActive(route.data.relativePath, route.hash, activeMatch || href.value, !!activeMatch);
|
|
50
|
+
}),
|
|
51
|
+
isCurrentLink: computed(() => {
|
|
52
|
+
return isActive(route.data.relativePath, route.hash, href.value);
|
|
53
|
+
})
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const navInjectionKey = Symbol("nav");
|
|
57
|
+
const navScreenInjectionKey = Symbol("nav-screen");
|
|
58
|
+
//#endregion
|
|
59
|
+
export { navInjectionKey, navScreenInjectionKey, useAppearanceSwitch, useNav, useNavItemLink };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TemplateRef } from "vue";
|
|
2
|
+
import { DefaultTheme } from "vitepress/theme";
|
|
3
|
+
//#region src/client/theme-default/composables/outline.d.ts
|
|
4
|
+
export declare function resolveTitle(theme: DefaultTheme.Config): string;
|
|
5
|
+
export declare function getHeaders(range: DefaultTheme.Config['outline']): DefaultTheme.OutlineItem[];
|
|
6
|
+
export declare function resolveHeaders(headers: DefaultTheme.OutlineItem[], range?: DefaultTheme.Config['outline']): DefaultTheme.OutlineItem[];
|
|
7
|
+
export declare function useActiveAnchor(container: TemplateRef<HTMLElement>, marker: TemplateRef<HTMLElement>): void;
|
|
8
|
+
//#endregion
|