tav-ui
Version:
1 lines • 2.15 kB
Source Map (JSON)
{"version":3,"file":"tsxHelper2.mjs","sources":["../../../../../../packages/utils/helper/tsxHelper.ts"],"sourcesContent":["import type { Slots } from 'vue'\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nfunction isFunction(val: unknown): val is Function {\n return typeof val === 'function'\n}\n\n/**\n * @description: Get slot to prevent empty error\n */\nexport function getSlot(slots: Slots, slot = 'default', data?: any) {\n if (!slots || !Reflect.has(slots, slot)) return null\n\n if (!isFunction(slots[slot])) {\n console.error(`${slot} is not a function!`)\n return null\n }\n const slotFn = slots[slot]\n if (!slotFn) return null\n return slotFn(data)\n}\n\n/**\n * extends slots\n * @param slots\n * @param excludeKeys\n */\nexport function extendSlots(slots: Slots, excludeKeys: string[] = []) {\n const slotKeys = Object.keys(slots)\n const ret: any = {}\n slotKeys.map((key) => {\n if (excludeKeys.includes(key)) {\n return null\n } else {\n ret[key] = () => getSlot(slots, key)\n return ret[key]\n }\n })\n return ret\n}\n"],"names":[],"mappings":"AAAA,SAAS,UAAU,CAAC,GAAG,EAAE;AACzB,EAAE,OAAO,OAAO,GAAG,KAAK,UAAU,CAAC;AACnC,CAAC;AACM,SAAS,OAAO,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE;AACvD,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC;AACzC,IAAI,OAAO,IAAI,CAAC;AAChB,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE;AAChC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;AAChD,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;AAC7B,EAAE,IAAI,CAAC,MAAM;AACb,IAAI,OAAO,I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