vuestic-ui
Version:
Vue 3 UI Framework
1 lines • 1.57 kB
Source Map (JSON)
{"version":3,"file":"with-slot-inheritance.mjs","sources":["../../../../../src/utils/with-slot-inheritance/with-slot-inheritance.ts"],"sourcesContent":["import { DefineComponent, PropType, Slot, defineComponent, h } from 'vue'\n\nexport const WithSlotInheritance = <T>(component: T) => {\n return defineComponent({\n name: 'ProxySlots',\n\n props: {\n inheritSlots: { type: Array as PropType<string[]>, required: true },\n },\n\n render () {\n const parentSlots = this.$parent?.$slots || {}\n\n const slotsToProxy = this.$props.inheritSlots || Object.keys(parentSlots)\n\n const slots = slotsToProxy.reduce(\n (slots, name) => {\n if (parentSlots[name]) {\n slots[name] = parentSlots[name]!\n }\n\n return slots\n },\n {} as Record<string, Slot>,\n )\n\n return h(component as any, this.$attrs, {\n ...slots,\n ...this.$slots,\n })\n },\n }) as T & DefineComponent<{ inheritSlots: string[] }>\n}\n"],"names":["slots"],"mappings":";AAEa,MAAA,sBAAsB,CAAI,cAAiB;AACtD,SAAO,gBAAgB;AAAA,IACrB,MAAM;AAAA,IAEN,OAAO;AAAA,MACL,cAAc,EAAE,MAAM,OAA6B,UAAU,KAAK;AAAA,IACpE;AAAA,IAEA,SAAU;;AACR,YAAM,gBAAc,UAAK,YAAL,mBAAc,WAAU,CAAA;AAE5C,YAAM,eAAe,KAAK,OAAO,gBAAgB,OAAO,KAAK,WAAW;AAExE,YAAM,QAAQ,aAAa;AAAA,QACzB,CAACA,QAAO,SAAS;AACX,cAAA,YAAY,IAAI,GAAG;AACrBA,mBAAM,IAAI,IAAI,YAAY,IAAI;AAAA,UAChC;AAEOA,iBAAAA;AAAAA,QACT;AAAA,QACA,CAAC;AAAA,MAAA;AAGI,aAAA,EAAE,WAAkB,KAAK,QAAQ;AAAA,QACtC,GAAG;AAAA,QACH,GAAG,KAAK;AAAA,MAAA,CACT;AAAA,IACH;AAAA,EAAA,CACD;AACH;"}