UNPKG

bootstrap-vue-next

Version:

Seamless integration of Vue 3, Bootstrap 5, and TypeScript for modern, type-safe UI development

1 lines 10.5 kB
{"version":3,"file":"keys-BLeKMItg.mjs","sources":["../src/utils/keys.ts"],"sourcesContent":["import type {ComponentInternalInstance, ComputedRef, InjectionKey, Ref, ShallowRef} from 'vue'\nimport type {TabType} from '../types/Tab'\nimport type {ClassValue} from '../types/AnyValuedAttributes'\nimport type {Numberish, ValidationState} from '../types/CommonTypes'\nimport type {LiteralUnion} from '../types/LiteralUnion'\nimport type {Size} from '../types/Size'\nimport type {RadiusElement} from '../types/RadiusElement'\nimport type {\n BgColorVariant,\n ButtonVariant,\n ColorVariant,\n TextColorVariant,\n} from '../types/ColorTypes'\nimport type {CheckboxValue} from '../types/CheckboxTypes'\nimport type {RadioValue} from '../types/RadioTypes'\nimport type {BreadcrumbItemRaw} from '../types/BreadcrumbTypes'\nimport type {OrchestratorArrayValue} from '../types/ComponentOrchestratorTypes'\nimport type {BvnComponentProps} from '../types/BootstrapVueOptions'\n\nexport const genericBvnPrefix = 'BootstrapVueNext__'\n\nexport const withBvnPrefix = (value: string, suffix: string = '') => {\n const suffixWithTrail = `${suffix}___`\n return `${genericBvnPrefix}ID__${value}__${suffix ? suffixWithTrail : ''}`\n}\n\nconst createBvnInjectionKey = (name: string) => withBvnPrefix(name) as unknown as symbol // Type cast to symbol, these should be static\nconst createBvnRegistryInjectionKey = (name: string) =>\n withBvnPrefix(`${name}__registry`) as unknown as symbol\n\n// BCarousel\nexport const carouselInjectionKey: InjectionKey<{\n background: Readonly<Ref<string | undefined>>\n width: Readonly<Ref<string | undefined>>\n height: Readonly<Ref<string | undefined>>\n}> = createBvnInjectionKey('carousel')\n\n// BTabs\nexport const tabsInjectionKey: InjectionKey<{\n lazy: Readonly<Ref<boolean>>\n card: Readonly<Ref<boolean>>\n noFade: Readonly<Ref<boolean>>\n registerTab: (tab: ComputedRef<TabType>) => string\n unregisterTab: (id: string) => void\n activateTab: (id: string | undefined) => void\n activeTabClass: Readonly<Ref<ClassValue>>\n inactiveTabClass: Readonly<Ref<ClassValue>>\n tabClass: Readonly<Ref<ClassValue>>\n activeId: Readonly<Ref<string | undefined>>\n}> = createBvnInjectionKey('tabs')\n\n// BProgress\nexport const progressInjectionKey: InjectionKey<{\n animated: Readonly<Ref<boolean | undefined>>\n max: Readonly<Ref<Numberish>>\n showProgress: Readonly<Ref<boolean | undefined>>\n showValue: Readonly<Ref<boolean | undefined>>\n striped: Readonly<Ref<boolean | undefined>>\n}> = createBvnInjectionKey('progress')\n\n// BListGroup\nexport const listGroupInjectionKey: InjectionKey<{\n numbered: Readonly<Ref<boolean>>\n}> = createBvnInjectionKey('listGroup')\n\n// BAvatarGroup\nexport const avatarGroupInjectionKey: InjectionKey<{\n overlapScale: Readonly<Ref<number>>\n size: Readonly<Ref<LiteralUnion<Size, Numberish> | undefined>>\n square: Readonly<Ref<boolean>>\n rounded: Readonly<Ref<RadiusElement | boolean>>\n roundedTop: Readonly<Ref<RadiusElement | boolean | undefined>>\n roundedBottom: Readonly<Ref<RadiusElement | boolean | undefined>>\n roundedStart: Readonly<Ref<RadiusElement | boolean | undefined>>\n roundedEnd: Readonly<Ref<RadiusElement | boolean | undefined>>\n variant: Readonly<Ref<ColorVariant | null>>\n bgVariant: Readonly<Ref<BgColorVariant | null>>\n textVariant: Readonly<Ref<TextColorVariant | null>>\n}> = createBvnInjectionKey('avatarGroup')\n\n// BAccordion\nexport const accordionInjectionKey: InjectionKey<{\n openItem: Readonly<Ref<string | string[] | undefined>>\n free: Readonly<Ref<boolean>>\n initialAnimation: Readonly<Ref<boolean>>\n lazy: Readonly<Ref<boolean>>\n unmountLazy: Readonly<Ref<boolean>>\n setOpenItem: (id: string) => void\n setCloseItem: (id: string) => void\n registerAccordionItem: (id: string, el: Readonly<ShallowRef<HTMLElement | null>>) => void\n unregisterAccordionItem: (id: string) => void\n}> = createBvnInjectionKey('accordion')\n\n// BFormCheckboxGroup\nexport const checkboxGroupKey: InjectionKey<{\n modelValue: Ref<readonly CheckboxValue[]>\n switch: Readonly<Ref<boolean>>\n buttonVariant: Readonly<Ref<ButtonVariant | null>>\n form: Readonly<Ref<string | undefined>>\n name: Readonly<Ref<string>>\n state: Readonly<Ref<ValidationState | undefined>>\n plain: Readonly<Ref<boolean>>\n size: Readonly<Ref<Size>>\n inline: Readonly<Ref<boolean>>\n reverse: Readonly<Ref<boolean>>\n required: Readonly<Ref<boolean>>\n buttons: Readonly<Ref<boolean>>\n disabled: Readonly<Ref<boolean>>\n}> = createBvnInjectionKey('checkboxGroup')\n\nexport const radioGroupKey: InjectionKey<{\n modelValue: Ref<RadioValue>\n buttonVariant: Readonly<Ref<ButtonVariant | null>>\n form: Readonly<Ref<string | undefined>>\n name: Readonly<Ref<string>>\n buttons: Readonly<Ref<boolean>>\n state: Readonly<Ref<ValidationState | undefined>>\n plain: Readonly<Ref<boolean>>\n size: Readonly<Ref<Size>>\n inline: Readonly<Ref<boolean>>\n reverse: Readonly<Ref<boolean>>\n required: Readonly<Ref<boolean>>\n disabled: Readonly<Ref<boolean>>\n}> = createBvnInjectionKey('radioGroup')\n\n// Collapse\nexport const collapseInjectionKey: InjectionKey<{\n id?: Readonly<Ref<string>>\n readonly hide?: () => void\n readonly show?: () => void\n readonly toggle?: () => void\n visible?: Readonly<Ref<boolean>>\n isNav?: Readonly<Ref<boolean>>\n}> = createBvnInjectionKey('collapse')\n\n// Show/Hide components\nexport type RegisterShowHideFnInput = {\n id: string\n component: ComponentInternalInstance\n value: Ref<boolean>\n toggle: (resolveOnHide?: boolean) => Promise<boolean | string>\n show: (resolveOnHide?: boolean) => Promise<boolean | string>\n hide: (trigger?: string) => Promise<boolean | string>\n registerTrigger: (trigger: string, el: Element) => void\n unregisterTrigger: (trigger: string, el: Element, clean: boolean) => void\n}\n\nexport interface RegisterShowHideMapValue {\n id: string\n component: ComponentInternalInstance\n value: Readonly<Ref<boolean>>\n toggle: (resolveOnHide?: boolean) => Promise<boolean | string | null>\n show: (resolveOnHide?: boolean) => Promise<boolean | string | null>\n hide: (trigger?: string, noTraverse?: boolean) => Promise<boolean | string | null>\n registerTrigger: (trigger: string, el: Element) => void\n unregisterTrigger: (trigger: string, el: Element, clean: boolean) => void\n}\n\n/**\n * Represents an array of component instances with the same ID\n * Used to handle race conditions where multiple instances mount/unmount out of order\n */\nexport interface RegisterShowHideInstances {\n instances: RegisterShowHideMapValue[]\n getActive: () => RegisterShowHideMapValue | undefined\n}\n\nexport interface RegisterShowHideValue {\n register: (input: RegisterShowHideFnInput) => {\n unregister: () => void\n updateId: (newId: string, oldId: string) => void\n }\n values: Ref<Map<string, RegisterShowHideInstances>>\n}\nexport const showHideRegistryKey: InjectionKey<RegisterShowHideValue> =\n createBvnRegistryInjectionKey('showHide')\n\nexport const dropdownInjectionKey: InjectionKey<{\n id?: Readonly<Ref<string>>\n readonly hide?: () => void\n readonly show?: () => void\n readonly toggle?: () => void\n visible?: Readonly<Ref<boolean>>\n isNav?: Readonly<Ref<boolean>>\n}> = createBvnInjectionKey('dropdown')\n\nexport const navbarInjectionKey: InjectionKey<{\n tag?: Readonly<Ref<string>>\n noAutoClose?: Readonly<Ref<boolean>>\n}> = createBvnInjectionKey('navbar')\n\nexport const rtlRegistryKey: InjectionKey<{\n isRtl: Ref<boolean>\n locale: Ref<string | undefined>\n}> = createBvnRegistryInjectionKey('rtl')\n\nexport const breadcrumbGlobalIndexKey = `${genericBvnPrefix}global_breadcrumb`\nexport const breadcrumbRegistryKey: InjectionKey<{\n items: Ref<Record<string, BreadcrumbItemRaw[]>>\n reset: (key?: string) => void\n}> = createBvnRegistryInjectionKey('breadcrumb')\n\nexport const modalManagerKey: InjectionKey<{\n stack: ComputedRef<ComponentInternalInstance[]>\n countStack: ComputedRef<number>\n lastStack: ComputedRef<ComponentInternalInstance | undefined>\n pushStack: (modal: Readonly<ComponentInternalInstance>) => void\n removeStack: (modal: Readonly<ComponentInternalInstance>) => void\n registry: Readonly<Ref<Map<number, ComponentInternalInstance>>>\n pushRegistry: (modal: Readonly<ComponentInternalInstance>) => void\n removeRegistry: (modal: Readonly<ComponentInternalInstance>) => void\n}> = createBvnRegistryInjectionKey('modalManager')\n\nexport const defaultsKey: InjectionKey<Ref<Partial<BvnComponentProps>>> =\n createBvnRegistryInjectionKey('defaults')\n\nexport const inputGroupKey: InjectionKey<boolean> = createBvnInjectionKey('inputGroup')\nexport const buttonGroupKey: InjectionKey<boolean> = createBvnInjectionKey('buttonGroup')\n\nexport const orchestratorRegistryKey: InjectionKey<{\n store: Ref<OrchestratorArrayValue[]>\n _isToastAppend: Ref<boolean>\n _isOrchestratorInstalled: Ref<boolean>\n}> = createBvnRegistryInjectionKey('orchestrator')\n\nexport const formGroupKey: InjectionKey<\n (id: Ref<string>) => {\n state: Readonly<Ref<ValidationState | undefined>>\n }\n> = createBvnInjectionKey('formGroupPlugin')\n\nexport const formSelectKey: InjectionKey<{\n modelValue: Readonly<Ref<unknown>>\n}> = createBvnInjectionKey('formSelect')\n// BTable keyboard navigation\nexport const tableKeyboardNavigationKey: InjectionKey<{\n rowNavigation: Readonly<Ref<boolean>>\n headerNavigation: Readonly<Ref<boolean>>\n}> = createBvnInjectionKey('tableKeyboardNavigation')\n"],"names":[],"mappings":"AAmBO,MAAM,mBAAmB;AAEzB,MAAM,gBAAgB,CAAC,OAAe,SAAiB,OAAO;AACnE,QAAM,kBAAkB,GAAG,MAAM;AACjC,SAAO,GAAG,gBAAgB,OAAO,KAAK,KAAK,SAAS,kBAAkB,EAAE;AAC1E;AAEA,MAAM,wBAAwB,CAAC,SAAiB,cAAc,IAAI;AAClE,MAAM,gCAAgC,CAAC,SACrC,cAAc,GAAG,IAAI,YAAY;AAG5B,MAAM,uBAIR,sBAAsB,UAAU;AAG9B,MAAM,mBAWR,sBAAsB,MAAM;AAG1B,MAAM,uBAMR,sBAAsB,UAAU;AAG9B,MAAM,wBAER,sBAAsB,WAAW;AAG/B,MAAM,0BAYR,sBAAsB,aAAa;AAGjC,MAAM,wBAUR,sBAAsB,WAAW;AAG/B,MAAM,mBAcR,sBAAsB,eAAe;AAEnC,MAAM,gBAaR,sBAAsB,YAAY;AAGhC,MAAM,uBAOR,sBAAsB,UAAU;AAyC9B,MAAM,sBACX,8BAA8B,UAAU;AAEnC,MAAM,uBAOR,sBAAsB,UAAU;AAE9B,MAAM,qBAGR,sBAAsB,QAAQ;AAE5B,MAAM,iBAGR,8BAA8B,KAAK;AAEjC,MAAM,2BAA2B,GAAG,gBAAgB;AACpD,MAAM,wBAGR,8BAA8B,YAAY;AAExC,MAAM,kBASR,8BAA8B,cAAc;AAE1C,MAAM,cACX,8BAA8B,UAAU;AAEnC,MAAM,gBAAuC,sBAAsB,YAAY;AAC/E,MAAM,iBAAwC,sBAAsB,aAAa;AAEjF,MAAM,0BAIR,8BAA8B,cAAc;AAE1C,MAAM,eAIT,sBAAsB,iBAAiB;AAEpC,MAAM,gBAER,sBAAsB,YAAY;AAEhC,MAAM,6BAGR,sBAAsB,yBAAyB;"}