bootstrap-vue-next 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/composables/useToast/index.d.mts +3 -1
- package/dist/composables/useToast/index.d.ts +3 -1
- package/dist/src/composables/orchestratorShared/index.mjs +1 -1
- package/dist/src/composables/orchestratorShared/index.mjs.map +1 -1
- package/dist/src/composables/useToast/index.mjs +62 -2
- package/dist/src/composables/useToast/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { MaybeRef, Ref } from 'vue';
|
|
2
2
|
import { OrchestratorStoreObject } from '../../utils/keys';
|
|
3
|
-
import { ComponentController, ToastOrchestratorArrayValue, ToastOrchestratorCreateParamBase } from '../../types';
|
|
3
|
+
import { ComponentController, ControllerKey, ToastOrchestratorArrayValue, ToastOrchestratorCreateParamBase } from '../../types';
|
|
4
4
|
import { BToast } from '../../components';
|
|
5
5
|
export declare const useToast: () => {
|
|
6
6
|
_isToastAppend: Readonly<Ref<boolean, boolean>>;
|
|
7
7
|
_isOrchestratorInstalled: Readonly<Ref<boolean, boolean>>;
|
|
8
8
|
store: Ref<OrchestratorStoreObject, OrchestratorStoreObject>;
|
|
9
9
|
create: <ComponentProps extends Record<string, unknown> = Record<string, unknown>, T extends ToastOrchestratorCreateParamBase<ComponentProps> = ToastOrchestratorCreateParamBase<ComponentProps>>(obj?: MaybeRef<T>) => ComponentController<typeof BToast, Ref<ToastOrchestratorArrayValue>>;
|
|
10
|
+
hide: (trigger?: string, id?: ControllerKey) => void;
|
|
11
|
+
hideAll: (trigger?: string) => void;
|
|
10
12
|
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { MaybeRef, Ref } from 'vue';
|
|
2
2
|
import { OrchestratorStoreObject } from '../../utils/keys';
|
|
3
|
-
import { ComponentController, ToastOrchestratorArrayValue, ToastOrchestratorCreateParamBase } from '../../types';
|
|
3
|
+
import { ComponentController, ControllerKey, ToastOrchestratorArrayValue, ToastOrchestratorCreateParamBase } from '../../types';
|
|
4
4
|
import { BToast } from '../../components';
|
|
5
5
|
export declare const useToast: () => {
|
|
6
6
|
_isToastAppend: Readonly<Ref<boolean, boolean>>;
|
|
7
7
|
_isOrchestratorInstalled: Readonly<Ref<boolean, boolean>>;
|
|
8
8
|
store: Ref<OrchestratorStoreObject, OrchestratorStoreObject>;
|
|
9
9
|
create: <ComponentProps extends Record<string, unknown> = Record<string, unknown>, T extends ToastOrchestratorCreateParamBase<ComponentProps> = ToastOrchestratorCreateParamBase<ComponentProps>>(obj?: MaybeRef<T>) => ComponentController<typeof BToast, Ref<ToastOrchestratorArrayValue>>;
|
|
10
|
+
hide: (trigger?: string, id?: ControllerKey) => void;
|
|
11
|
+
hideAll: (trigger?: string) => void;
|
|
10
12
|
};
|
|
@@ -48,9 +48,9 @@ var buildController = (id, store) => {
|
|
|
48
48
|
if (!item) return;
|
|
49
49
|
try {
|
|
50
50
|
if (item.value.props.modelValue) {
|
|
51
|
+
controller.hide("destroy");
|
|
51
52
|
await basePromise;
|
|
52
53
|
await nextTick();
|
|
53
|
-
controller.hide("destroy");
|
|
54
54
|
}
|
|
55
55
|
} finally {
|
|
56
56
|
store.value.delete(id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/composables/orchestratorShared/index.ts"],"sourcesContent":["import {type ComponentPublicInstance, inject, nextTick, provide, readonly, type Ref, ref} from 'vue'\nimport type {ComponentController, ControllerKey, PromiseWithController} from '../../types'\nimport type {BvTriggerableEvent} from '../../utils'\nimport {orchestratorRegistryKey, type OrchestratorStoreObject} from '../../utils/keys'\n\n/* oxlint-disable-next-line no-explicit-any */\n/* eslint-disable-next-line @typescript-eslint/no-explicit-any */\nexport type ValueInMapRecord<MapRecord> = MapRecord extends Map<any, infer I> ? I : never\n\nexport const buildController = <\n TComponent,\n TStore extends Readonly<Ref<OrchestratorStoreObject[keyof OrchestratorStoreObject]>>,\n>(\n id: ControllerKey,\n store: TStore\n): PromiseWithController<TComponent, ValueInMapRecord<TStore['value']>> => {\n let resolveFunc: (value: BvTriggerableEvent) => void = () => {}\n\n const basePromise = new Promise<BvTriggerableEvent>((resolve) => {\n resolveFunc = resolve\n })\n\n type RefWithMethods = ComponentPublicInstance<TComponent> & {\n show?: () => void\n hide?: (trigger?: string, noEmit?: boolean) => void\n toggle?: () => void\n }\n const findItem = () => store.value.get(id)\n\n const controller = {\n id,\n ref: null as RefWithMethods | null,\n async show() {\n const currentModelValue = controller.get()?.value.props.modelValue\n if (currentModelValue) {\n const event = await basePromise\n return Object.assign(Object.create(event), {\n [Symbol.asyncDispose]: controller.destroy,\n })\n }\n const refWithMethods = controller.ref\n if (\n refWithMethods !== null &&\n 'show' in refWithMethods &&\n typeof refWithMethods.show === 'function'\n ) {\n refWithMethods.show()\n } else {\n controller.set({modelValue: true})\n }\n const event = await basePromise\n return Object.assign(Object.create(event), {\n [Symbol.asyncDispose]: controller.destroy,\n })\n },\n hide(trigger?: string) {\n const refWithMethods = controller.ref\n if (\n refWithMethods !== null &&\n 'hide' in refWithMethods &&\n typeof refWithMethods.hide === 'function'\n ) {\n refWithMethods.hide(trigger, true)\n } else {\n controller.set({modelValue: false})\n }\n },\n toggle() {\n const currentItem = controller.get()\n const refWithMethods = controller.ref\n if (\n refWithMethods !== null &&\n 'toggle' in refWithMethods &&\n typeof refWithMethods.toggle === 'function'\n ) {\n refWithMethods.toggle()\n } else {\n controller.set({modelValue: !currentItem?.value.props.modelValue})\n }\n },\n get: findItem,\n set(val: Partial<ValueInMapRecord<TStore['value']>['value']['props']>) {\n const current = findItem()\n if (current?.value) {\n current.value = {\n ...current.value,\n props: {\n ...current.value.props,\n ...val,\n /* oxlint-disable no-explicit-any */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n } as any,\n }\n }\n },\n async destroy() {\n const item = findItem()\n if (!item) return\n try {\n if (item.value.props.modelValue) {\n await basePromise\n await nextTick()\n
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/composables/orchestratorShared/index.ts"],"sourcesContent":["import {type ComponentPublicInstance, inject, nextTick, provide, readonly, type Ref, ref} from 'vue'\nimport type {ComponentController, ControllerKey, PromiseWithController} from '../../types'\nimport type {BvTriggerableEvent} from '../../utils'\nimport {orchestratorRegistryKey, type OrchestratorStoreObject} from '../../utils/keys'\n\n/* oxlint-disable-next-line no-explicit-any */\n/* eslint-disable-next-line @typescript-eslint/no-explicit-any */\nexport type ValueInMapRecord<MapRecord> = MapRecord extends Map<any, infer I> ? I : never\n\nexport const buildController = <\n TComponent,\n TStore extends Readonly<Ref<OrchestratorStoreObject[keyof OrchestratorStoreObject]>>,\n>(\n id: ControllerKey,\n store: TStore\n): PromiseWithController<TComponent, ValueInMapRecord<TStore['value']>> => {\n let resolveFunc: (value: BvTriggerableEvent) => void = () => {}\n\n const basePromise = new Promise<BvTriggerableEvent>((resolve) => {\n resolveFunc = resolve\n })\n\n type RefWithMethods = ComponentPublicInstance<TComponent> & {\n show?: () => void\n hide?: (trigger?: string, noEmit?: boolean) => void\n toggle?: () => void\n }\n const findItem = () => store.value.get(id)\n\n const controller = {\n id,\n ref: null as RefWithMethods | null,\n async show() {\n const currentModelValue = controller.get()?.value.props.modelValue\n if (currentModelValue) {\n const event = await basePromise\n return Object.assign(Object.create(event), {\n [Symbol.asyncDispose]: controller.destroy,\n })\n }\n const refWithMethods = controller.ref\n if (\n refWithMethods !== null &&\n 'show' in refWithMethods &&\n typeof refWithMethods.show === 'function'\n ) {\n refWithMethods.show()\n } else {\n controller.set({modelValue: true})\n }\n const event = await basePromise\n return Object.assign(Object.create(event), {\n [Symbol.asyncDispose]: controller.destroy,\n })\n },\n hide(trigger?: string) {\n const refWithMethods = controller.ref\n if (\n refWithMethods !== null &&\n 'hide' in refWithMethods &&\n typeof refWithMethods.hide === 'function'\n ) {\n refWithMethods.hide(trigger, true)\n } else {\n controller.set({modelValue: false})\n }\n },\n toggle() {\n const currentItem = controller.get()\n const refWithMethods = controller.ref\n if (\n refWithMethods !== null &&\n 'toggle' in refWithMethods &&\n typeof refWithMethods.toggle === 'function'\n ) {\n refWithMethods.toggle()\n } else {\n controller.set({modelValue: !currentItem?.value.props.modelValue})\n }\n },\n get: findItem,\n set(val: Partial<ValueInMapRecord<TStore['value']>['value']['props']>) {\n const current = findItem()\n if (current?.value) {\n current.value = {\n ...current.value,\n props: {\n ...current.value.props,\n ...val,\n /* oxlint-disable no-explicit-any */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n } as any,\n }\n }\n },\n async destroy() {\n const item = findItem()\n if (!item) return\n try {\n if (item.value.props.modelValue) {\n controller.hide('destroy')\n await basePromise\n await nextTick()\n }\n } finally {\n store.value.delete(id)\n }\n },\n [Symbol.asyncDispose]() {\n return controller.destroy()\n },\n } as ComponentController<TComponent, ValueInMapRecord<TStore['value']>>\n\n return {\n controller,\n resolve: resolveFunc,\n }\n}\n\nexport const _newOrchestratorRegistry = (): {\n store: Readonly<Ref<OrchestratorStoreObject>>\n _isToastAppend: Readonly<Ref<boolean>>\n _setToastAppend: (value: boolean) => void\n _isOrchestratorInstalled: Readonly<Ref<boolean>>\n _setOrchestratorInstalled: (value: boolean) => void\n} => {\n const _isOrchestratorInstalled = ref(false)\n const _isToastAppend = ref(false)\n\n return {\n store: ref({\n modal: new Map(),\n tooltip: new Map(),\n popover: new Map(),\n toast: new Map(),\n }),\n _isOrchestratorInstalled: readonly(_isOrchestratorInstalled),\n _setOrchestratorInstalled: (v) => {\n _isOrchestratorInstalled.value = v\n },\n _isToastAppend: readonly(_isToastAppend),\n _setToastAppend: (v) => {\n _isToastAppend.value = v\n },\n }\n}\n\nexport const useOrchestratorRegistry = () => {\n const orchestratorRegistry = inject(orchestratorRegistryKey, null)\n\n if (orchestratorRegistry) {\n return orchestratorRegistry\n }\n const newOrchestratorRegistry = _newOrchestratorRegistry()\n provide(orchestratorRegistryKey, newOrchestratorRegistry)\n return newOrchestratorRegistry\n}\n\nexport const getOrchestratorControllerId = (propId: string | undefined) => {\n const id: ControllerKey = propId || Symbol('OrchestratorItem')\n\n return {\n /**\n * This id is used for stability in the store, using the createIdWatcher will update the store if the id ever changes\n */\n storeId: id,\n /**\n * Do not pass in the symbol as a prop. Html attribute cannot be a symbol. Thus it's internal\n */\n htmlAttributeId: typeof id === 'string' ? id : undefined,\n }\n}\n"],"mappings":";;;AASA,IAAa,mBAIX,IACA,UACyE;CACzE,IAAI,oBAAyD,CAAC;CAE9D,MAAM,cAAc,IAAI,SAA6B,YAAY;EAC/D,cAAc;CAChB,CAAC;CAOD,MAAM,iBAAiB,MAAM,MAAM,IAAI,EAAE;CAEzC,MAAM,aAAa;EACjB;EACA,KAAK;EACL,MAAM,OAAO;GAEX,IAD0B,WAAW,IAAI,CAAC,EAAE,MAAM,MAAM,YACjC;IACrB,MAAM,QAAQ,MAAM;IACpB,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK,GAAG,GACxC,OAAO,eAAe,WAAW,QACpC,CAAC;GACH;GACA,MAAM,iBAAiB,WAAW;GAClC,IACE,mBAAmB,QACnB,UAAU,kBACV,OAAO,eAAe,SAAS,YAE/B,eAAe,KAAK;QAEpB,WAAW,IAAI,EAAC,YAAY,KAAI,CAAC;GAEnC,MAAM,QAAQ,MAAM;GACpB,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK,GAAG,GACxC,OAAO,eAAe,WAAW,QACpC,CAAC;EACH;EACA,KAAK,SAAkB;GACrB,MAAM,iBAAiB,WAAW;GAClC,IACE,mBAAmB,QACnB,UAAU,kBACV,OAAO,eAAe,SAAS,YAE/B,eAAe,KAAK,SAAS,IAAI;QAEjC,WAAW,IAAI,EAAC,YAAY,MAAK,CAAC;EAEtC;EACA,SAAS;GACP,MAAM,cAAc,WAAW,IAAI;GACnC,MAAM,iBAAiB,WAAW;GAClC,IACE,mBAAmB,QACnB,YAAY,kBACZ,OAAO,eAAe,WAAW,YAEjC,eAAe,OAAO;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OAAO,WAAW,KAAK,KAAA;CACjD;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as orchestratorRegistryKey } from "../../../keys-BgLwJbLV.js";
|
|
1
|
+
import { _ as orchestratorRegistryKey, x as showHideRegistryKey } from "../../../keys-BgLwJbLV.js";
|
|
2
2
|
import { buildController, getOrchestratorControllerId } from "../orchestratorShared/index.mjs";
|
|
3
3
|
import { t as BToast_default } from "../../../BToast-Di9HwBOV.js";
|
|
4
4
|
import { computed, inject, markRaw, onScopeDispose, ref } from "vue";
|
|
@@ -8,6 +8,7 @@ var useToast = () => {
|
|
|
8
8
|
const orchestratorRegistry = inject(orchestratorRegistryKey, null);
|
|
9
9
|
if (!orchestratorRegistry) throw new Error("useToast() must be called within setup(), and BApp, useRegistry or plugin must be installed/provided.");
|
|
10
10
|
const { store, _isToastAppend, _isOrchestratorInstalled } = orchestratorRegistry;
|
|
11
|
+
const showHideRegistry = inject(showHideRegistryKey, null);
|
|
11
12
|
/**
|
|
12
13
|
* @returns {ComponentController<typeof BToast, ToastOrchestratorParam>}
|
|
13
14
|
*/
|
|
@@ -53,11 +54,70 @@ var useToast = () => {
|
|
|
53
54
|
}, true);
|
|
54
55
|
return controller;
|
|
55
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Hides a mounted BToast that registered itself under `id`. Going through the component, rather
|
|
59
|
+
* than through the store, is what lets the trigger flow through the regular hide cycle
|
|
60
|
+
*
|
|
61
|
+
* @returns whether a toast was found
|
|
62
|
+
*/
|
|
63
|
+
const hideRegisteredInstance = (id, trigger) => {
|
|
64
|
+
if (typeof id !== "string") return false;
|
|
65
|
+
const instances = showHideRegistry?.values.value.get(id)?.instances;
|
|
66
|
+
if (!instances) return false;
|
|
67
|
+
for (let i = instances.length - 1; i >= 0; i--) {
|
|
68
|
+
const instance = instances[i];
|
|
69
|
+
if (instance?.component.type !== BToast_default) continue;
|
|
70
|
+
instance.hide(trigger, true);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Hides a toast that lives in the orchestrator store. Prefers the mounted instance, falling back
|
|
77
|
+
* to the store entry itself, which also covers toasts that the orchestrator has yet to render
|
|
78
|
+
* and toasts rendered through a custom `component`
|
|
79
|
+
*/
|
|
80
|
+
const hideStoreItem = (item, trigger) => {
|
|
81
|
+
if (hideRegisteredInstance(item.value.props.id ?? item.value.id, trigger)) return;
|
|
82
|
+
item.value = {
|
|
83
|
+
...item.value,
|
|
84
|
+
props: {
|
|
85
|
+
...item.value.props,
|
|
86
|
+
modelValue: false
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Hide all toasts
|
|
92
|
+
* @param trigger - The trigger to hide all toasts
|
|
93
|
+
*/
|
|
94
|
+
const hideAll = (trigger) => {
|
|
95
|
+
for (const item of store.value.toast.values()) hideStoreItem(item, trigger);
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Hide a toast
|
|
99
|
+
* @param trigger - The trigger to hide the toast
|
|
100
|
+
* @param id - The id of the toast to hide, when omitted every toast is hidden
|
|
101
|
+
*/
|
|
102
|
+
const hide = (trigger, id) => {
|
|
103
|
+
if (id === void 0) {
|
|
104
|
+
hideAll(trigger);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const item = store.value.toast.get(id);
|
|
108
|
+
if (item) {
|
|
109
|
+
hideStoreItem(item, trigger);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
hideRegisteredInstance(id, trigger);
|
|
113
|
+
};
|
|
56
114
|
return {
|
|
57
115
|
_isToastAppend,
|
|
58
116
|
_isOrchestratorInstalled,
|
|
59
117
|
store,
|
|
60
|
-
create
|
|
118
|
+
create,
|
|
119
|
+
hide,
|
|
120
|
+
hideAll
|
|
61
121
|
};
|
|
62
122
|
};
|
|
63
123
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/composables/useToast/index.ts"],"sourcesContent":["import {\n type ComponentPublicInstance,\n computed,\n type ComputedRef,\n inject,\n markRaw,\n type MaybeRef,\n onScopeDispose,\n ref,\n type Ref,\n} from 'vue'\nimport {orchestratorRegistryKey
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/composables/useToast/index.ts"],"sourcesContent":["import {\n type ComponentPublicInstance,\n computed,\n type ComputedRef,\n inject,\n markRaw,\n type MaybeRef,\n onScopeDispose,\n ref,\n type Ref,\n} from 'vue'\nimport {\n orchestratorRegistryKey,\n type OrchestratorStoreObject,\n showHideRegistryKey,\n} from '../../utils/keys'\nimport type {ContainerPosition} from '../../types/Alignment'\nimport type {\n ComponentController,\n ControllerKey,\n ToastOrchestratorArrayValue,\n ToastOrchestratorCreateParamBase,\n} from '../../types'\nimport {buildController, getOrchestratorControllerId} from '../orchestratorShared'\nimport {BToast} from '../../components'\n\nconst posDefault: ContainerPosition = 'top-end'\n\nexport const useToast = () => {\n const orchestratorRegistry = inject(orchestratorRegistryKey, null)\n if (!orchestratorRegistry)\n throw new Error(\n 'useToast() must be called within setup(), and BApp, useRegistry or plugin must be installed/provided.'\n )\n const {store, _isToastAppend, _isOrchestratorInstalled} = orchestratorRegistry\n const showHideRegistry = inject(showHideRegistryKey, null)\n\n /**\n * @returns {ComponentController<typeof BToast, ToastOrchestratorParam>}\n */\n // Uses a `function` declaration (rather than a generic arrow function assigned to a const) so\n // that TypeScript preserves per-call generic inference when `create` is returned as part of\n // `useToast()`'s inferred return object.\n function create<\n ComponentProps extends Record<string, unknown> = Record<string, unknown>,\n T extends ToastOrchestratorCreateParamBase<ComponentProps> =\n ToastOrchestratorCreateParamBase<ComponentProps>,\n >(\n obj: MaybeRef<T> = {} as T\n ): ComponentController<typeof BToast, Ref<ToastOrchestratorArrayValue>> {\n if (!_isOrchestratorInstalled.value)\n throw new Error('The BApp component must be mounted to use the toast composable')\n\n const toastComp = markRaw(BToast)\n const resolvedProps = ref(obj)\n const toastStore = computed(() => store.value.toast)\n const {htmlAttributeId, storeId} = getOrchestratorControllerId(resolvedProps.value.id)\n\n const {resolve, controller} = buildController<\n typeof BToast,\n ComputedRef<OrchestratorStoreObject['toast']>\n >(storeId, toastStore)\n\n const value = computed<ToastOrchestratorArrayValue>({\n get: () => {\n const {component = toastComp, options, slots, ...props} = resolvedProps.value\n\n return {\n component,\n options,\n slots,\n id: storeId,\n fns: {\n resolve,\n setRef: (v: ComponentPublicInstance) => {\n controller.ref = v\n },\n destroy: controller.destroy,\n },\n props: {\n ...props,\n id: htmlAttributeId,\n position: props.position || posDefault,\n },\n }\n },\n set: (v) => {\n resolvedProps.value = {\n ...resolvedProps.value,\n ...v.props,\n }\n },\n })\n\n toastStore.value.set(storeId, value)\n\n onScopeDispose(async () => {\n await controller[Symbol.asyncDispose]()\n }, true)\n\n return controller\n }\n\n /**\n * Hides a mounted BToast that registered itself under `id`. Going through the component, rather\n * than through the store, is what lets the trigger flow through the regular hide cycle\n *\n * @returns whether a toast was found\n */\n const hideRegisteredInstance = (id: ControllerKey, trigger?: string): boolean => {\n // The show/hide registry is keyed by the html id, symbols never reach it\n if (typeof id !== 'string') return false\n const instances = showHideRegistry?.values.value.get(id)?.instances\n if (!instances) return false\n // Every show/hide component shares this registry, so an id may resolve to a BCollapse or a\n // BModal. Only toasts are ours to hide. Newest first, the way the registry's getActive does\n for (let i = instances.length - 1; i >= 0; i--) {\n const instance = instances[i]\n if (instance?.component.type !== BToast) continue\n instance.hide(trigger, true)\n return true\n }\n return false\n }\n\n /**\n * Hides a toast that lives in the orchestrator store. Prefers the mounted instance, falling back\n * to the store entry itself, which also covers toasts that the orchestrator has yet to render\n * and toasts rendered through a custom `component`\n */\n const hideStoreItem = (item: Ref<ToastOrchestratorArrayValue>, trigger?: string): void => {\n if (hideRegisteredInstance(item.value.props.id ?? item.value.id, trigger)) return\n item.value = {\n ...item.value,\n props: {\n ...item.value.props,\n modelValue: false,\n },\n }\n }\n\n /**\n * Hide all toasts\n * @param trigger - The trigger to hide all toasts\n */\n const hideAll = (trigger?: string): void => {\n for (const item of store.value.toast.values()) {\n hideStoreItem(item, trigger)\n }\n }\n\n /**\n * Hide a toast\n * @param trigger - The trigger to hide the toast\n * @param id - The id of the toast to hide, when omitted every toast is hidden\n */\n const hide = (trigger?: string, id?: ControllerKey): void => {\n if (id === undefined) {\n hideAll(trigger)\n return\n }\n const item = store.value.toast.get(id)\n if (item) {\n hideStoreItem(item, trigger)\n return\n }\n // Not created through the composable, it could still be a BToast declared in a template\n hideRegisteredInstance(id, trigger)\n }\n\n return {\n _isToastAppend,\n _isOrchestratorInstalled,\n store,\n create,\n hide,\n hideAll,\n }\n}\n"],"mappings":";;;;;AA0BA,IAAM,aAAgC;AAEtC,IAAa,iBAAiB;CAC5B,MAAM,uBAAuB,OAAO,yBAAyB,IAAI;CACjE,IAAI,CAAC,sBACH,MAAM,IAAI,MACR,uGACF;CACF,MAAM,EAAC,OAAO,gBAAgB,6BAA4B;CAC1D,MAAM,mBAAmB,OAAO,qBAAqB,IAAI;;;;CAQzD,SAAS,OAKP,MAAmB,CAAC,GACkD;EACtE,IAAI,CAAC,yBAAyB,OAC5B,MAAM,IAAI,MAAM,gEAAgE;EAElF,MAAM,YAAY,QAAQ,cAAM;EAChC,MAAM,gBAAgB,IAAI,GAAG;EAC7B,MAAM,aAAa,eAAe,MAAM,MAAM,KAAK;EACnD,MAAM,EAAC,iBAAiB,YAAW,4BAA4B,cAAc,MAAM,EAAE;EAErF,MAAM,EAAC,SAAS,eAAc,gBAG5B,SAAS,UAAU;EAErB,MAAM,QAAQ,SAAsC;GAClD,WAAW;IACT,MAAM,EAAC,YAAY,WAAW,SAAS,OAAO,GAAG,UAAS,cAAc;IAExE,OAAO;KACL;KACA;KACA;KACA,IAAI;KACJ,KAAK;MACH;MACA,SAAS,MAA+B;OACtC,WAAW,MAAM;MACnB;MACA,SAAS,WAAW;KACtB;KACA,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EACA;EACA;EACA;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "bootstrap-vue-next",
|
|
3
3
|
"displayName": "BootstrapVueNext",
|
|
4
4
|
"description": "Seamless integration of Vue 3, Bootstrap 5, and TypeScript for modern, type-safe UI development",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.2.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./dist/bootstrap-vue-next.mjs",
|