UNPKG

ideaz-element

Version:

<p align="center"> <a href="" target="_blank" rel="noopener noreferrer"> <img src="./docs/public/logo.svg" alt="Ideaz Element" width="180" style="width: 180px;" /> </a> </p>

1 lines 2.68 kB
{"version":3,"file":"useTableSlots.cjs","sources":["../../../../../../packages/element/table/src/hooks/useTableSlots.ts"],"sourcesContent":["import { isFunction, isObject, isSlot, isString } from '@ideaz/utils'\nimport type { Ref } from 'vue'\nimport type { TableCol } from '../../../types'\n\nexport function useTableSlots(columns: Ref<TableCol[]>, slots: any) {\n const scopedSlots: any = {}\n const tableSlots: any = {}\n\n watch(\n () => columns.value,\n () => {\n columns.value.forEach((item: TableCol) => {\n if (item.slot && slots[item.slot]) {\n scopedSlots[item.slot] = (scope: any) =>\n slots[item.slot!](scope)\n }\n if (\n item.type === 'button'\n && isObject(item.dropdown)\n && isString(item.dropdown.reference)\n ) {\n if (\n item.dropdown.reference.includes('slot')\n || item.dropdown.reference.includes('Slot')\n ) {\n scopedSlots[item.dropdown.reference] = (scope: any) =>\n slots[item.dropdown.reference](scope)\n }\n }\n if (item.type === 'expand' && slots.expand) {\n scopedSlots.expand = (scope: any) =>\n slots.expand(scope)\n }\n\n const label = item.label as string\n if (isSlot(item.label) && slots[label]) {\n scopedSlots[label] = (scope: any) =>\n slots[label](scope)\n }\n })\n\n if (isFunction(slots.empty))\n tableSlots.empty = () => slots.empty()\n\n if (isFunction(slots.append))\n tableSlots.append = () => slots.append()\n },\n { immediate: true, deep: true },\n )\n\n return { scopedSlots, tableSlots }\n}\n"],"names":["useTableSlots","columns","slots","scopedSlots","tableSlots","vue","item","scope","is","label"],"mappings":"oLAIgB,SAAAA,EAAAC,EAAAC,EAAA,CACd,MAAAC,EAAA,CAAA,EACAC,EAAA,CAAA,EAEA,OAAAC,EAAA,MAAA,IAAAJ,EAAA,MACgB,IAAA,CAEZA,EAAA,MAAA,QAAAK,GAAA,CACEA,EAAA,MAAAJ,EAAAI,EAAA,IAAA,IACEH,EAAAG,EAAA,IAAA,EAAAC,GAAAL,EAAAI,EAAA,IAAA,EAAAC,CAAA,GAGFD,EAAA,OAAA,UAAAE,EAAA,SAAAF,EAAA,QAAA,GAAAE,EAAA,SAAAF,EAAA,SAAA,SAAA,IAKEA,EAAA,SAAA,UAAA,SAAA,MAAA,GAAAA,EAAA,SAAA,UAAA,SAAA,MAAA,KAIEH,EAAAG,EAAA,SAAA,SAAA,EAAAC,GAAAL,EAAAI,EAAA,SAAA,SAAA,EAAAC,CAAA,GAIJD,EAAA,OAAA,UAAAJ,EAAA,SACEC,EAAA,OAAAI,GAAAL,EAAA,OAAAK,CAAA,GAIF,MAAAE,EAAAH,EAAA,MACAE,EAAA,OAAAF,EAAA,KAAA,GAAAJ,EAAAO,CAAA,IACEN,EAAAM,CAAA,EAAAF,GAAAL,EAAAO,CAAA,EAAAF,CAAA,EAEF,CAAA,EAGFC,EAAA,WAAAN,EAAA,KAAA,IACEE,EAAA,MAAA,IAAAF,EAAA,MAAA,GAEFM,EAAA,WAAAN,EAAA,MAAA,IACEE,EAAA,OAAA,IAAAF,EAAA,OAAA,EAAuC,EAC3C,CAAA,UAAA,GAAA,KAAA,EAAA,CAC8B,EAGhC,CAAA,YAAAC,EAAA,WAAAC,CAAA,CACF"}