{"version":3,"file":"SlotComponent-DWxnwead.mjs","sources":["../../src/components/utils/SlotComponent.ts"],"sourcesContent":["import {\n    createVNode,\n    defineComponent,\n    type DefineComponent,\n    type VNode,\n    type VNodeChild,\n    type VNodeTypes,\n} from \"vue\";\nimport type { ComponentProps } from \"vue-component-type-helpers\";\nimport type { ClassBind, DynamicComponent } from \"@/types\";\n\ntype SlotComponentProps<C extends VNodeTypes> = {\n    /** Component to be get the slot from */\n    component: C;\n    /** Props to be binded to the injected component. */\n    props?: ComponentProps<C>;\n    /**\n     * Slot name\n     * @default \"default\"\n     */\n    name?: string;\n    /**\n     * Tag name of the slot wrapper element\n     * @default \"div\"\n     */\n    tag?: DynamicComponent;\n    /** Class for the slot wrapper element */\n    class?: ClassBind | ClassBind[];\n};\n\n/** This components renders a specific slot and only the slot of another component */\nexport default defineComponent<SlotComponentProps<any>>(\n    <C extends DefineComponent>(props: SlotComponentProps<C>, { slots }) => {\n        const _props = { tag: \"div\", name: \"default\", ...props };\n\n        return (): VNode => {\n            let slot: VNodeChild | (() => VNodeChild) = (): VNodeChild =>\n                props.component.$slots[_props.name]\n                    ? props.component.$slots[_props.name](props.props)\n                    : slots.default\n                      ? slots.default()\n                      : undefined;\n            if (typeof _props.tag === \"string\") {\n                // Vue prefers components' children to be passed as functions,\n                // but native elements' children can't be passed that way.\n                slot = slot();\n            }\n\n            return createVNode(\n                _props.tag as VNode,\n                { class: _props.class },\n                slot,\n            );\n        };\n    },\n    {\n        name: \"OSlotComponent\",\n        // manual runtime props declaration is currently still needed.\n        props: [\"component\", \"props\", \"name\", \"tag\"],\n    },\n);\n"],"names":[],"mappings":";;AA+BA,MAAA,iBAAe;AAAA,EACX,CAA4B,OAA8B,EAAE,YAAY;AACpE,UAAM,SAAS,EAAE,KAAK,OAAO,MAAM,WAAW,GAAG,MAAA;AAEjD,WAAO,MAAa;AAChB,UAAI,OAAwC,MACxC,MAAM,UAAU,OAAO,OAAO,IAAI,IAC5B,MAAM,UAAU,OAAO,OAAO,IAAI,EAAE,MAAM,KAAK,IAC/C,MAAM,UACJ,MAAM,QAAA,IACN;AACZ,UAAI,OAAO,OAAO,QAAQ,UAAU;AAGhC,eAAO,KAAA;AAAA,MACX;AAEA,aAAO;AAAA,QACH,OAAO;AAAA,QACP,EAAE,OAAO,OAAO,MAAA;AAAA,QAChB;AAAA,MAAA;AAAA,IAER;AAAA,EACJ;AAAA,EACA;AAAA,IACI,MAAM;AAAA;AAAA,IAEN,OAAO,CAAC,aAAa,SAAS,QAAQ,KAAK;AAAA,EAAA;AAEnD;"}