bootstrap-vue-next
Version:
BootstrapVueNext is an early and lovely component library for Vue 3 & Nuxt 3 based on Bootstrap 5 and Typescript.
208 lines (207 loc) • 8.57 kB
TypeScript
import { Component, ComponentPublicInstance, MaybeRef, MaybeRefOrGetter, WatchHandle } from 'vue';
import { BModalProps, BPopoverProps, BToastProps, BTooltipProps } from './ComponentProps';
import { ContainerPosition } from './Alignment';
import { BModalSlots, BPopoverSlots, BToastSlots } from './ComponentSlots';
import { BModalEmits, BPopoverEmits, BToastEmits } from './ComponentEmits';
import { BvTriggerableEvent } from '../utils';
import { default as BModal } from '../components/BModal/BModal.vue';
import { default as BToast } from '../components/BToast/BToast.vue';
import { default as BPopover } from '../components/BPopover/BPopover.vue';
import { default as BTooltip } from '../components/BTooltip/BTooltip.vue';
export type ControllerKey = symbol | string;
export interface PromiseWithComponent<T, P> extends Promise<BvTriggerableEvent | boolean | null>, PromiseWithComponentInternal<T, P> {
}
export interface PromiseWithComponentInternal<T, P> extends AsyncDisposable {
id: ControllerKey;
ref: ComponentPublicInstance<T> | null;
show: () => PromiseWithComponent<T, P>;
hide: (trigger?: string) => PromiseWithComponent<T, P>;
toggle: () => PromiseWithComponent<T, P>;
set: (val: Partial<P>) => PromiseWithComponent<T, P>;
get: () => P | undefined;
destroy: () => void;
}
type Prefix<P extends string, S extends string> = `${P}${S}`;
export type CamelCase<S extends string> = S extends `${infer P1}-${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : Lowercase<S>;
export type ToastOrchestratorArrayValue = Omit<BToastProps, 'modelValue'> & {
/**
* Position
* @default 'top-end'
*/
'position'?: ContainerPosition;
/**
* Sets whether or not the toast should be appended to the container
* @default undefined Implicitly defaults to the BOrchestrator's appendToast value
*/
'appendToast'?: boolean;
/**
* A proxy for the modelValue, essentially, you set this once, and it mimics the modelValue.
*
* Falsy values default to 5000
*
* @default 5000
*/
'modelValue'?: BToastProps['modelValue'];
'_self': ControllerKey;
'onUpdate:modelValue'?: (val: boolean) => void;
'_component'?: Readonly<Component>;
'options': OrchestratorCreateOptions;
'promise': {
value: PromiseWithComponent<typeof BToast, ToastOrchestratorParam>;
resolve: (value: BvTriggerableEvent | boolean | null) => void;
stop?: WatchHandle;
};
'type': 'toast';
} & {
[K in keyof BToastEmits as CamelCase<Prefix<'on-', K>>]?: (e: BToastEmits[K][0]) => void;
} & {
slots?: {
[K in keyof BToastSlots]?: BToastSlots[K] | Readonly<Component>;
};
};
export type ToastOrchestratorParam = Omit<BToastProps, 'modelValue'> & {
'title'?: MaybeRefOrGetter<BToastProps['title']>;
'body'?: MaybeRefOrGetter<BToastProps['body']>;
/**
* Position
* @default 'top-end'
* @deprecated
*/
'pos'?: ContainerPosition;
/**
* Position
* @default 'top-end'
*/
'position'?: ContainerPosition;
/**
* Sets whether or not the toast should be appended to the container
* @default undefined Implicitly defaults to the BOrchestrator's appendToast value
*/
'appendToast'?: boolean;
/**
* A proxy for the modelValue, essentially, you set this once, and it mimics the modelValue.
*
* Falsy values default to 5000
*
* @default 5000
*/
'modelValue'?: MaybeRefOrGetter<BToastProps['modelValue']>;
'onUpdate:modelValue'?: (val: boolean) => void;
'component'?: Readonly<Component>;
/**
* @deprecated
*/
'props'?: Record<string, unknown>;
} & {
[K in keyof BToastEmits as CamelCase<Prefix<'on-', K>>]?: (e: BToastEmits[K][0]) => void;
} & {
slots?: {
[K in keyof BToastSlots]?: MaybeRefOrGetter<BToastSlots[K] | Readonly<Component>>;
};
};
export type ToastOrchestratorCreateParam = MaybeRef<ToastOrchestratorParam>;
export type TooltipOrchestratorArrayValue = BTooltipProps & {
'type': 'tooltip';
'_self': ControllerKey;
'position': 'popover';
'options': OrchestratorCreateOptions;
'onUpdate:modelValue'?: (val: boolean) => void;
'_component'?: Readonly<Component>;
'promise': {
value: PromiseWithComponent<typeof BPopover | typeof BTooltip, PopoverOrchestratorParam>;
resolve: (value: BvTriggerableEvent | boolean | null) => void;
stop?: WatchHandle;
};
'slots'?: {
[K in keyof Omit<BPopoverSlots, 'target'>]?: BPopoverSlots[K] | Readonly<Component>;
};
} & {
[K in keyof BPopoverEmits as CamelCase<Prefix<'on-', K>>]?: (e: BPopoverEmits[K][0]) => void;
};
export type TooltipOrchestratorParam = Omit<BTooltipProps, 'body' | 'title' | 'modelValue'> & {
'onUpdate:modelValue'?: (val: boolean) => void;
'title'?: MaybeRefOrGetter<BTooltipProps['title']>;
'body'?: MaybeRefOrGetter<BTooltipProps['body']>;
'modelValue'?: MaybeRefOrGetter<BTooltipProps['modelValue']>;
'component'?: Readonly<Component>;
'slots'?: {
[K in keyof Omit<BPopoverSlots, 'target'>]?: MaybeRefOrGetter<BPopoverSlots[K] | Readonly<Component>>;
};
} & {
[K in keyof BPopoverEmits as CamelCase<Prefix<'on-', K>>]?: (e: BPopoverEmits[K][0]) => void;
};
export type TooltipOrchestratorCreateParam = MaybeRef<TooltipOrchestratorParam>;
export type PopoverOrchestratorArrayValue = BPopoverProps & BTooltipProps & {
'type': 'popover';
'_self': ControllerKey;
'position': 'popover';
'options': OrchestratorCreateOptions;
'onUpdate:modelValue'?: (val: boolean) => void;
'_component'?: Readonly<Component>;
'promise': {
value: PromiseWithComponent<typeof BPopover | typeof BTooltip, PopoverOrchestratorParam>;
resolve: (value: BvTriggerableEvent | boolean | null) => void;
stop?: WatchHandle;
};
'slots'?: {
[K in keyof Omit<BPopoverSlots, 'target'>]?: BPopoverSlots[K] | Readonly<Component>;
};
} & {
[K in keyof BPopoverEmits as CamelCase<Prefix<'on-', K>>]?: (e: BPopoverEmits[K][0]) => void;
};
export type PopoverOrchestratorParam = Omit<BPopoverProps, 'body' | 'title' | 'modelValue'> & {
'onUpdate:modelValue'?: (val: boolean) => void;
'title'?: MaybeRefOrGetter<BPopoverProps['title']>;
'body'?: MaybeRefOrGetter<BPopoverProps['body']>;
'modelValue'?: MaybeRefOrGetter<BPopoverProps['modelValue']>;
'component'?: Readonly<Component>;
'slots'?: {
[K in keyof Omit<BPopoverSlots, 'target'>]?: MaybeRefOrGetter<BPopoverSlots[K] | Readonly<Component>>;
};
} & {
[K in keyof BPopoverEmits as CamelCase<Prefix<'on-', K>>]?: (e: BPopoverEmits[K][0]) => void;
};
export type PopoverOrchestratorCreateParam = MaybeRef<PopoverOrchestratorParam>;
export type ModalOrchestratorArrayValue = BModalProps & {
'type': 'modal';
'_self': ControllerKey;
'position': 'modal';
'onUpdate:modelValue'?: (val: boolean) => void;
'options': OrchestratorCreateOptions;
'promise': {
value: PromiseWithComponent<typeof BModal, ModalOrchestratorParam>;
resolve: (value: BvTriggerableEvent | boolean | null) => void;
stop?: WatchHandle;
};
'_component'?: Readonly<Component>;
'slots'?: {
[K in keyof BModalSlots]?: BModalSlots[K] | Readonly<Component>;
};
} & {
[K in keyof BModalEmits as CamelCase<Prefix<'on-', K>>]?: (e: BModalEmits[K][0]) => void;
};
export type ModalOrchestratorParam = Omit<BModalProps, 'body' | 'title' | 'modelValue'> & {
'onUpdate:modelValue'?: (val: boolean) => void;
'title'?: MaybeRefOrGetter<BModalProps['title']>;
'body'?: MaybeRefOrGetter<BModalProps['body']>;
'modelValue'?: MaybeRefOrGetter<BModalProps['modelValue']>;
'options'?: OrchestratorCreateOptions;
'component'?: Readonly<Component>;
/**
* @deprecated
*/
'props'?: Record<string, unknown>;
'slots'?: {
[K in keyof BModalSlots]?: MaybeRefOrGetter<BModalSlots[K] | Readonly<Component>>;
};
} & {
[K in keyof BModalEmits as CamelCase<Prefix<'on-', K>>]?: (e: BModalEmits[K][0]) => void;
};
export type ModalOrchestratorCreateParam = MaybeRef<ModalOrchestratorParam>;
export type OrchestratorCreateOptions = {
keep?: boolean;
resolveOnHide?: boolean;
returnBoolean?: boolean;
};
export type OrchestratorArrayValue = ToastOrchestratorArrayValue | ModalOrchestratorArrayValue | PopoverOrchestratorArrayValue | TooltipOrchestratorArrayValue;
export {};