import { ID } from "../../types/index.mjs"; import { ContextTrinity } from "../createTrinity/index.mjs"; import { RegistryOptions } from "../createRegistry/index.mjs"; import { SingleContext, SingleTicket, SingleTicketInput } from "../createSingle/index.mjs"; import { Plugin } from "../createPlugin/index.mjs"; import { TokenCollection } from "../createTokens/index.mjs"; import { ThemeAdapter } from "./adapters/adapter.mjs"; import { V0StyleSheetThemeAdapter } from "./adapters/v0.mjs"; import { V0UnheadThemeAdapter } from "./adapters/unhead.mjs"; import "./adapters/index.mjs"; import "../index.mjs"; import { ComputedRef, Ref } from "vue"; //#region src/composables/useTheme/index.d.ts type Colors = { [key: string]: string; }; type ThemeColors = { [key: string]: Colors | string; }; type ThemeRecord = { dark?: boolean; lazy?: boolean; colors: ThemeColors; }; /** * Input type for theme tickets - what users provide to register(). * Extend this interface to add custom properties. */ interface ThemeTicketInput extends SingleTicketInput { /** * Theme color definitions. When provided to `register()`, these are * onboarded as flat tokens for alias resolution and stored as the * ticket value. */ colors?: ThemeColors; /** * Indicates whether the theme is dark or light. * * @remarks Defaults to `false` (light theme). */ dark?: boolean; /** * Indicates whether the theme should be loaded lazily. * * @remarks Defaults to `false`. */ lazy?: boolean; } /** * Output type for theme tickets - what users receive from get(). * Includes all input properties plus guaranteed dark/lazy values. * * @template Z The input ticket type that extends ThemeTicketInput. */ type ThemeTicket = SingleTicket & { /** * Indicates whether the theme is dark or light. * * @remarks Defaults to `false` (light theme). */ dark: boolean; /** * Indicates whether the theme should be loaded lazily. * * @remarks Defaults to `false`. */ lazy: boolean; }; /** * Context for managing theme collections. * * @template Z The input ticket type. * @template E The output ticket type. */ interface ThemeContext = ThemeTicket> extends Omit, 'register'> { /** * A computed reference to the resolved colors of all registered themes. * * @remarks Returns a record keyed by theme ID. Each value contains the theme's colors * with any token aliases resolved to their actual values. Lazy themes are excluded * unless they are currently selected. * * @see https://0.vuetifyjs.com/composables/plugins/use-theme * * @example * ```ts * import { useTheme } from '@vuetify/v0' * * const theme = useTheme() * * console.log(theme.colors.value) * ``` */ colors: ComputedRef>; /** * A ref indicating whether the current theme is dark. * * @remarks Returns `true` if the current theme has `dark: true`, otherwise `false`. * * @see https://0.vuetifyjs.com/composables/plugins/use-theme * * @example * ```ts * import { useTheme } from '@vuetify/v0' * * const theme = useTheme() * * console.log(theme.isDark.value) // true or false * ``` */ isDark: Readonly>; /** * Cycles through the provided themes in order. * * @param themes An array of theme IDs to cycle through. Defaults to all registered themes. * * @see https://0.vuetifyjs.com/composables/plugins/use-theme * * @example * ```ts * import { useTheme } from '@vuetify/v0' * * const theme = useTheme() * * theme.cycle(['light', 'dark']) * ``` */ cycle: (themes?: ID[]) => void; /** * `true` while the configured `system` pair is driving selection. * Becomes `false` after an explicit `select`. * * @example * ```ts * const theme = useTheme() * console.log(theme.isSystem.value) * ``` */ isSystem: Readonly>; /** * Return to following the `system` pair. Without `system`, re-selects `default`. * * @example * ```ts * const theme = useTheme() * theme.select('dark') * theme.reset() * ``` */ reset: () => void; /** * Register a theme with optional colors. * * When `colors` is provided, onboards them as flat tokens for * alias resolution and stores them as the ticket value. * * @example * ```ts * const theme = createTheme({ themes: { light, dark }, default: 'light' }) * * // Register a custom theme at runtime * theme.register({ id: 'custom', dark: true, colors: { primary: '#ff5722' } }) * theme.select('custom') * ``` */ register: (registration?: Partial) => E; /** Bulk-register multiple themes in a single batch. */ onboard: (registrations: Partial[]) => E[]; /** * Release adapter resources (watchers, stylesheet, unhead entries). * Called automatically on `app.unmount` when using the plugin path. * Call manually when using a standalone context (`createThemeContext`). */ dispose: () => void; /** Active theme adapter. Defaults to `V0StyleSheetThemeAdapter`. */ adapter: ThemeAdapter; } interface ThemeSystemPair { light: ID; dark: ID; } interface ThemeOptions extends RegistryOptions { /** * The theme adapter to use. * * @remarks Defaults to `V0StyleSheetThemeAdapter`. */ adapter?: ThemeAdapter; /** * The default theme ID to select on initialization. * * @remarks Used on the server and when `system` is omitted or invalid. */ default?: ID; /** * Follow `prefers-color-scheme` using these registered theme ids until * the user calls `select`. Both ids must already be in `themes`. * * @example * ```ts * app.use( * createThemePlugin({ * system: { light: 'light', dark: 'dark' }, * persist: true, * themes: { * light: { colors: { primary: '#3b82f6' } }, * dark: { dark: true, colors: { primary: '#675496' } }, * }, * }), * ) * ``` */ system?: ThemeSystemPair; /** * Automatically generate `on-*` foreground colors for each theme color * using APCA contrast analysis. * * @remarks Defaults to `false`. */ foreground?: boolean; /** * A collection of tokens to use for resolving theme colors. */ palette?: TokenCollection; /** * Output CSS variable values as decomposed RGB channels (`R, G, B`) * instead of hex strings. * * @remarks Defaults to `false`. */ rgb?: boolean; /** * A record of themes to register. */ themes?: Record; /** * The target element or selector to apply theme classes to. * * @remarks If `null`, no classes will be applied. */ target?: string | HTMLElement | null; } interface ThemeContextOptions extends ThemeOptions { namespace?: string; } interface ThemePluginOptions extends ThemeContextOptions { persist?: boolean; /** When true, this plugin appears in the Vue DevTools v0 inspector. @default false */ devtools?: boolean; } /** * Creates a new theme instance. * * @param options The options for the theme instance. * @returns A new theme instance. * * @see https://0.vuetifyjs.com/composables/plugins/use-theme * * @example * ```ts * import { createTheme } from '@vuetify/v0' * * const theme = createTheme({ * default: 'light', * themes: { * light: { * dark: false, * colors: { * primary: '#3b82f6', * }, * }, * dark: { * dark: true, * colors: { * primary: '#675496', * }, * }, * }, * }) * ``` */ declare function createTheme(_options?: ThemeOptions): ThemeContext; declare const createThemeContext: <_E extends ThemeContext> = ThemeContext>>(_options?: ThemePluginOptions | undefined) => ContextTrinity<_E>, createThemePlugin: (_options?: (ThemePluginOptions & Pick<{ namespace?: string; persist?: boolean; devtools?: boolean; }, "devtools">) | undefined) => Plugin, useTheme: <_E extends ThemeContext> = ThemeContext>>(namespace?: string) => _E; //#endregion export { Colors, ThemeAdapter, ThemeColors, ThemeContext, ThemeContextOptions, ThemeOptions, ThemePluginOptions, ThemeRecord, ThemeSystemPair, ThemeTicket, ThemeTicketInput, V0StyleSheetThemeAdapter, V0UnheadThemeAdapter, createTheme, createThemeContext, createThemePlugin, useTheme };