@bndynet/vue-site 1.4.1 → 1.8.0

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.
@@ -0,0 +1,36 @@
1
+ import { Ref } from 'vue';
2
+ /**
3
+ * Breakpoint in CSS pixels below which the site switches to the mobile layout.
4
+ *
5
+ * CSS `@media (max-width: ...)` rules cannot read this value (media queries do not
6
+ * support `var()`), so any change here must also update the matching media queries in
7
+ * `src/styles/layout.css`, `src/styles/markdown.css`, `src/components/SideNav.vue`,
8
+ * and `src/components/ShellActions.vue`. Those files carry a `keep in sync` comment.
9
+ */
10
+ export declare const MOBILE_BREAKPOINT_PX = 840;
11
+ /** Provide the active viewport state to components rendered by the site layout. */
12
+ export declare function provideMobileViewport(isMobileViewport: Ref<boolean>): void;
13
+ /**
14
+ * Return the site's reactive mobile viewport state.
15
+ *
16
+ * The value is `true` when the viewport is {@link MOBILE_BREAKPOINT_PX} CSS pixels wide or
17
+ * narrower. It is shared with the responsive site layout and updates when the viewport crosses
18
+ * that breakpoint.
19
+ *
20
+ * This composable must be called from a Vue component rendered inside `createSiteApp()`.
21
+ * The returned ref is read-only; use CSS media queries for presentation-only changes.
22
+ *
23
+ * @example
24
+ * ```vue
25
+ * <script setup lang="ts">
26
+ * import { useMobileViewport } from '@bndynet/vue-site'
27
+ *
28
+ * const isMobileViewport = useMobileViewport()
29
+ * </script>
30
+ *
31
+ * <template>
32
+ * <button v-if="isMobileViewport">Open compact menu</button>
33
+ * </template>
34
+ * ```
35
+ */
36
+ export declare function useMobileViewport(): Readonly<Ref<boolean>>;
@@ -10,5 +10,12 @@ export interface SiteContext {
10
10
  }
11
11
  /** Use `Symbol.for` so pages still inject context if Vite resolves the package twice. */
12
12
  export declare const siteContextKey: InjectionKey<SiteContext>;
13
+ /** Register the configuration for access outside Vue's injection context. */
14
+ export declare function registerSiteConfig(config: SiteConfig): void;
13
15
  export declare function provideSiteConfig(context: SiteContext): void;
16
+ /**
17
+ * Return the active site configuration outside Vue's setup / injection context.
18
+ * `createSiteApp()` must have started before this function is called.
19
+ */
20
+ export declare function getSiteConfig(): SiteConfig;
14
21
  export declare function useSiteConfig(): SiteContext;
@@ -1,11 +1,2 @@
1
1
  import { SiteConfig } from './types';
2
- /**
3
- * Returns the site config passed to `createSiteApp()`. Can be called from anywhere — plain
4
- * modules, `bootstrap.ts` (after the app is created), utility functions, etc. — without a Vue
5
- * injection context. Returns `undefined` if `createSiteApp` has not been called yet.
6
- *
7
- * For reactive, component-scoped access to the full `SiteContext` (config + nav + refreshAuthNav),
8
- * use {@link useSiteConfig} inside a Vue component instead.
9
- */
10
- export declare function getSiteConfig(): SiteConfig | undefined;
11
2
  export declare function createSiteApp(config: SiteConfig): Promise<import('vue').App<Element>>;
package/dist/index.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import { SiteConfig } from './types';
2
- export { createSiteApp, getSiteConfig } from './create-app';
2
+ export { createSiteApp } from './create-app';
3
3
  export { useTheme, themeRefKey } from './composables/useTheme';
4
4
  export { useLocale, localeRefKey } from './composables/useLocale';
5
5
  export { useLocalize } from './composables/useLocalize';
6
+ export { useMobileViewport } from './composables/useMobileViewport';
6
7
  export { resolveLocalized, resolveField, resolveMessage, mergeCatalog, flattenMessages, tk, isMessageRef, localizedPage } from './i18n-utils';
7
8
  export type { LocalizedPageOptions, MessageCatalog } from './i18n-utils';
8
9
  export { builtinMessages } from './i18n-messages';
9
- export { useSiteConfig } from './composables/useSiteConfig';
10
+ export { getSiteConfig, useSiteConfig } from './composables/useSiteConfig';
10
11
  export { builtinThemePalettes } from './theme/presets';
11
12
  export { ElMessage, ElMessageBox, ElNotification, } from 'element-plus';
12
13
  export type { SiteConfig, SiteEnvConfig, SiteViteConfig, SiteCustomConfig, SiteExternalLink, ShellConfig, ShellAction, ShellActionLoader, NavItem, StandalonePage, PageLayout, AuthRule, AuthContext, AuthConfig, RouterConfig, ThemeConfig, ThemeOption, ThemePaletteVars, ResolvedNavItem, LocaleCode, LocalizedString, IconRegistry, MessageRef, MessageTree, LocaleOption, I18nConfig, PageLoader, } from './types';