import type { VuesticComponentsMap } from '../vue-plugin'; import type { VNodeProps, AllowedComponentProps, HTMLAttributes, VNode, DefineComponent } from 'vue'; import { ComponentSlots } from '../../utils/component-options'; export type VuesticComponentName = keyof VuesticComponentsMap; export type VueDefaultPropNames = keyof (VNodeProps & AllowedComponentProps) | `on${string}`; export type PropTypes = C extends { new (): { $props: infer Props; }; } ? Omit : never; export type VuesticComponentPropsMap = { [componentName in VuesticComponentName]: { [key in keyof PropTypes]?: PropTypes[key]; } & HTMLAttributes; }; export type Props = { [propName: string]: any; }; /** * Removes index signature from object * * @example * * Type: * ``` * RemoveIndex<{ * [index: string]: number * a: number * b: number * }> * ``` * Converts to * * ``` * { a: number, b: number } * ``` * */ type RemoveIndex = { [K in keyof T as string extends K ? never : number extends K ? never : symbol extends K ? never : K]: T[K]; }; type VuesticComponentSlotsMap = { [componentName in VuesticComponentName]: { [key in keyof RemoveIndex>]?: ComponentSlots[key]; }; }; type SlotPropPrefix = `slot:${T}`; export type SlotProp = VNode | string | DefineComponent, {}, {}, {}, {}>; type VuesticComponentSlotPropsMap = { [componentName in VuesticComponentName]: { [key in keyof VuesticComponentSlotsMap[componentName] as SlotPropPrefix]: SlotProp[0]>; }; }; type VuesticComponentPreset = VuesticComponentPropsMap[T] & VuesticComponentSlotPropsMap[T]; export type Presets = { [componentName in VuesticComponentName]?: { [presetName: string]: VuesticComponentPreset; }; }; export type ComponentConfig = Partial; export type { DefineComponent as VuesticComponent } from 'vue';