import { h } from "vue"; //#region src/types/index.d.ts /** * Valid element types for Vue's `h()` render function * * @remarks * Includes HTML tag names, component definitions, and functional components. * Used by the `Atom` component for polymorphic rendering. */ type DOMElement = Parameters[0]; /** * Object with string keys and unknown values * * @remarks * Object with string keys and unknown values for generic record handling. */ type UnknownObject = Record; /** * Identifier type used throughout the registry system * * @remarks * All tickets, items, and registrable entities use this type for their `id` property. * * @example * ```ts * const id: ID = 'item-1' // string * const id: ID = 42 // number * ``` */ type ID = string | number; /** * Recursively makes all properties of T optional * * @template T The object type to make deeply partial * * @remarks * Used by `mergeDeep` to type partial source objects. * * @example * ```ts * type User = { name: string; address: { city: string } } * type PartialUser = DeepPartial * // { name?: string; address?: { city?: string } } * ``` */ type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial; } : T; /** * Union type that accepts either a single value or an array * * @template T The base type * * @remarks * Used for APIs that accept both single items and arrays. * * @example * ```ts * function process(input: MaybeArray) { ... } * process('single') // OK * process(['a', 'b', 'c']) // OK * ``` */ type MaybeArray = T | T[]; /** * Preserves string literal autocomplete while allowing arbitrary strings * * @template T The string literal union to preserve * * @remarks * TypeScript normally collapses `'a' | 'b' | string` into just `string`, * losing IDE autocomplete for the known values. This type uses the * `string & {}` trick to prevent that collapse. * * Use for extensible APIs where you want autocomplete for known values * but still accept custom strings: event names, theme tokens, CSS classes, etc. * * @example * ```ts * type Color = 'red' | 'blue' | 'green' * * // WITHOUT Extensible - autocomplete lost * type BadColor = Color | string // collapses to just `string` * * // WITH Extensible - autocomplete preserved * type GoodColor = Extensible * * function setColor(c: GoodColor) {} * setColor('red') // autocomplete suggests 'red' | 'blue' | 'green' * setColor('purple') // also OK - custom value accepted * ``` * * @example * ```ts * // Event system with typed + custom events * type KnownEvent = 'click' | 'hover' | 'focus' * * function on>(event: K, cb: Callback) {} * * on('click', ...) // autocomplete works * on('custom', ...) // custom events allowed * ``` */ type Extensible = T | (string & {}); /** * Keyboard activation mode for navigable components * * @remarks * Controls when selection occurs during keyboard navigation: * - `automatic` (default): Selection follows focus (arrow keys select). * This is the WAI-ARIA standard for radio groups. * - `manual`: Arrow keys move focus only; Enter/Space required to select. * Use for toolbar contexts or when deliberate selection is preferred. * * @example * ```vue * * ``` */ type Activation = 'automatic' | 'manual'; /** * Discriminated union of structured details attached to every v0-thrown error * * @remarks * Each arm pairs a stable `code` discriminant with the domain context for that * code. Consumed by the `V0Error` constructor in `#v0/utilities` — the union * is the source of truth for both what codes exist and what payload each code * carries. * * Prefer `isV0Error(err, code)` over manual narrowing — see * `V0Error` and `isV0Error` in `#v0/utilities` for the consumer-facing API * and worked examples. * * Inspiration: tRPC's `TRPCError.code`, Node's `error.code` registry. * * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause * @see https://nodejs.org/api/errors.html#nodejs-error-codes * @see https://trpc.io/docs/server/error-handling * * @example * ```ts * const details: V0ErrorDetails = { code: 'V0_CONTEXT_MISSING', key: 'theme' } * ``` */ type V0ErrorDetails = { code: 'V0_CONTEXT_MISSING'; key: string | symbol; } | { code: 'V0_PLUGIN_MISSING'; plugin: string; } | { code: 'V0_PALETTE_INVALID_SEED'; palette: 'material' | 'leonardo' | 'ant'; seed: string; } | { code: 'V0_PALETTE_UNKNOWN_VARIANT'; palette: 'material'; variant: string; } | { code: 'V0_ADAPTER_INSTANCE_MISSING'; adapter: string; } | { code: 'V0_DATE_INVALID'; value: string; } | { code: 'V0_THEME_INVALID_PREFIX'; prefix: string; }; /** * Union of every error code thrown by v0 * * @remarks * Convenience alias for the discriminant field of {@link V0ErrorDetails}. * * @example * ```ts * function describe (code: V0ErrorCode): string { * switch (code) { * case 'V0_CONTEXT_MISSING': return 'missing provider' * case 'V0_PLUGIN_MISSING': return 'plugin not installed' * } * } * ``` */ type V0ErrorCode = V0ErrorDetails['code']; //#endregion export { Activation, DOMElement, DeepPartial, Extensible, ID, MaybeArray, UnknownObject, V0ErrorCode, V0ErrorDetails };