UNPKG

bootstrap-vue-next

Version:

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

174 lines (173 loc) 6.68 kB
import { s as unrefElement } from "./dist-B10a-gZ8.mjs"; import { Comment, Fragment, cloneVNode, computed, createBlock, defineComponent, h, inject, mergeProps, openBlock, provide, ref, renderSlot, unref, withCtx } from "vue"; //#region ../../node_modules/.pnpm/reka-ui@2.9.2_vue@3.5.31_typescript@5.9.3_/node_modules/reka-ui/dist/shared/createContext.js /** * @param providerComponentName - The name(s) of the component(s) providing the context. * * There are situations where context can come from multiple components. In such cases, you might need to give an array of component names to provide your context, instead of just a single string. * * @param contextName The description for injection key symbol. */ function createContext(providerComponentName, contextName) { const symbolDescription = typeof providerComponentName === "string" && !contextName ? `${providerComponentName}Context` : contextName; const injectionKey = Symbol(symbolDescription); /** * @param fallback The context value to return if the injection fails. * * @throws When context injection failed and no fallback is specified. * This happens when the component injecting the context is not a child of the root component providing the context. */ const injectContext = (fallback) => { const context = inject(injectionKey, fallback); if (context) return context; if (context === null) return context; throw new Error(`Injection \`${injectionKey.toString()}\` not found. Component must be used within ${Array.isArray(providerComponentName) ? `one of the following components: ${providerComponentName.join(", ")}` : `\`${providerComponentName}\``}`); }; const provideContext = (contextValue) => { provide(injectionKey, contextValue); return contextValue; }; return [injectContext, provideContext]; } //#endregion //#region ../../node_modules/.pnpm/reka-ui@2.9.2_vue@3.5.31_typescript@5.9.3_/node_modules/reka-ui/dist/shared/renderSlotFragments.js function renderSlotFragments(children) { if (!children) return []; return children.flatMap((child) => { if (child.type === Fragment) return renderSlotFragments(child.children); return [child]; }); } //#endregion //#region ../../node_modules/.pnpm/reka-ui@2.9.2_vue@3.5.31_typescript@5.9.3_/node_modules/reka-ui/dist/ConfigProvider/ConfigProvider.js var [injectConfigProviderContext, provideConfigProviderContext] = createContext("ConfigProvider"); //#endregion //#region ../../node_modules/.pnpm/reka-ui@2.9.2_vue@3.5.31_typescript@5.9.3_/node_modules/reka-ui/dist/shared/useDirection.js /** * The `useDirection` function provides a way to access the current direction in your application. * @param {Ref<Direction | undefined>} [dir] - An optional ref containing the direction (ltr or rtl). * @returns computed value that combines with the resolved direction. */ function useDirection(dir) { const context = injectConfigProviderContext({ dir: ref("ltr") }); return computed(() => dir?.value || context.dir?.value || "ltr"); } //#endregion //#region ../../node_modules/.pnpm/reka-ui@2.9.2_vue@3.5.31_typescript@5.9.3_/node_modules/reka-ui/dist/Primitive/Slot.js var Slot = defineComponent({ name: "PrimitiveSlot", inheritAttrs: false, setup(_, { attrs, slots }) { return () => { if (!slots.default) return null; const children = renderSlotFragments(slots.default()); const firstNonCommentChildrenIndex = children.findIndex((child) => child.type !== Comment); if (firstNonCommentChildrenIndex === -1) return children; const firstNonCommentChildren = children[firstNonCommentChildrenIndex]; delete firstNonCommentChildren.props?.ref; const mergedProps = firstNonCommentChildren.props ? mergeProps(attrs, firstNonCommentChildren.props) : attrs; const cloned = cloneVNode({ ...firstNonCommentChildren, props: {} }, mergedProps); if (children.length === 1) return cloned; children[firstNonCommentChildrenIndex] = cloned; return children; }; } }); //#endregion //#region ../../node_modules/.pnpm/reka-ui@2.9.2_vue@3.5.31_typescript@5.9.3_/node_modules/reka-ui/dist/Primitive/Primitive.js var SELF_CLOSING_TAGS = [ "area", "img", "input" ]; var Primitive = defineComponent({ name: "Primitive", inheritAttrs: false, props: { asChild: { type: Boolean, default: false }, as: { type: [String, Object], default: "div" } }, setup(props, { attrs, slots }) { const asTag = props.asChild ? "template" : props.as; if (typeof asTag === "string" && SELF_CLOSING_TAGS.includes(asTag)) return () => h(asTag, attrs); if (asTag !== "template") return () => h(props.as, attrs, { default: slots.default }); return () => h(Slot, attrs, { default: slots.default }); } }); //#endregion //#region ../../node_modules/.pnpm/reka-ui@2.9.2_vue@3.5.31_typescript@5.9.3_/node_modules/reka-ui/dist/Primitive/usePrimitiveElement.js function usePrimitiveElement() { const primitiveElement = ref(); return { primitiveElement, currentElement: computed(() => ["#text", "#comment"].includes(primitiveElement.value?.$el.nodeName) ? primitiveElement.value?.$el.nextElementSibling : unrefElement(primitiveElement)) }; } //#endregion //#region ../../node_modules/.pnpm/reka-ui@2.9.2_vue@3.5.31_typescript@5.9.3_/node_modules/reka-ui/dist/VisuallyHidden/VisuallyHidden.js var VisuallyHidden_default = /* @__PURE__ */ defineComponent({ __name: "VisuallyHidden", props: { feature: { type: String, required: false, default: "focusable" }, asChild: { type: Boolean, required: false }, as: { type: null, required: false, default: "span" } }, setup(__props) { return (_ctx, _cache) => { return openBlock(), createBlock(unref(Primitive), { as: _ctx.as, "as-child": _ctx.asChild, "aria-hidden": _ctx.feature === "focusable" ? "true" : void 0, "data-hidden": _ctx.feature === "fully-hidden" ? "" : void 0, tabindex: _ctx.feature === "fully-hidden" ? "-1" : void 0, style: { position: "absolute", border: 0, width: "1px", height: "1px", padding: 0, margin: "-1px", overflow: "hidden", clip: "rect(0, 0, 0, 0)", clipPath: "inset(50%)", whiteSpace: "nowrap", wordWrap: "normal", top: "-1px", left: "-1px" } }, { default: withCtx(() => [renderSlot(_ctx.$slots, "default")]), _: 3 }, 8, [ "as", "as-child", "aria-hidden", "data-hidden", "tabindex" ]); }; } }); //#endregion export { useDirection as a, createContext as c, Slot as i, usePrimitiveElement as n, injectConfigProviderContext as o, Primitive as r, renderSlotFragments as s, VisuallyHidden_default as t }; //# sourceMappingURL=VisuallyHidden-Bbwok8oL.mjs.map