@poupe/vue
Version:
Vue component library for Poupe UI framework with theme customization and accessibility support
90 lines (89 loc) • 2.54 kB
text/typescript
import type { App, InjectionKey } from "vue";
/**
* Extendable interface for component defaults
* Components can augment this interface to add their own defaults
*
* @example
* ```typescript
* declare module '@poupe/vue' {
* interface PoupeComponentDefaults {
* button?: {
* variant?: string
* size?: string
* ripple?: boolean
* }
* }
* }
* ```
*/
export interface PoupeComponentDefaults {}
export interface PoupeOptions {
accessibility?: {
highContrast?: boolean;
reducedMotion?: boolean;
};
defaults?: PoupeComponentDefaults;
ripple?: {
color?: string;
disabled?: boolean;
duration?: number;
opacity?: number;
};
theme?: {
colors?: Record<string, string>;
dark?: boolean;
};
}
export declare const poupeInjectionKey: InjectionKey<PoupeOptions>;
/**
* Creates a Poupe instance for the Vue app
* Used by `@poupe/nuxt` to inject app-wide defaults
*/
export declare function createPoupe(options?: PoupeOptions): {
install(app: App): void;
};
/**
* Use Poupe options in components
* Provides access to global defaults set via app.config.ts
*/
export declare function usePoupe(): PoupeOptions | undefined;
/**
* Helper to get component defaults with fallback
*/
export declare function usePoupeDefaults<T extends keyof PoupeComponentDefaults>(component: T): PoupeComponentDefaults[T] | undefined;
export declare function usePoupeDefaults<T>(component: string): T | undefined;
/**
* Provider for isolated Poupe instances (e.g., in stories)
*/
export declare function providePoupeOptions(options: PoupeOptions): void;
/**
* Helper to merge component props with global defaults
* Uses defu for deep merging with proper type inference
*
* @example
* ```typescript
* const finalProps = usePoupeMergeProps(props, 'button', {
* variant: 'filled',
* size: 'medium',
* });
* ```
*/
export declare function usePoupeMergeProps<T extends Record<string, unknown>>(props: T, componentName: keyof PoupeComponentDefaults, componentDefaults?: Partial<T>): T;
/**
* Helper to create merged props with proper type inference
* Ensures component defaults are properly typed
*
* @example
* ```typescript
* const mergedProps = usePoupeMergedProps(props, 'surface', {
* variant: 'surface',
* color: 'base',
* shape: 'none',
* // ... other defaults
* });
* ```
*/
export declare function usePoupeMergedProps<
TProps extends Record<string, unknown>,
TDefaults extends Partial<TProps>
>(props: TProps, componentName: keyof PoupeComponentDefaults, componentDefaults: TDefaults): Required<TDefaults> & TProps;