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.76 kB
{"version":3,"file":"useTableSlots.mjs","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","watch","item","scope","isObject","isString","label","isSlot","isFunction"],"mappings":";;;AAIgB,SAAAA,EAAAC,GAAAC,GAAA;AACd,QAAAC,IAAA,CAAA,GACAC,IAAA,CAAA;AAEA,SAAAC;AAAA,IAAA,MAAAJ,EAAA;AAAA,IACgB,MAAA;AAEZ,MAAAA,EAAA,MAAA,QAAA,CAAAK,MAAA;AACE,QAAAA,EAAA,QAAAJ,EAAAI,EAAA,IAAA,MACEH,EAAAG,EAAA,IAAA,IAAA,CAAAC,MAAAL,EAAAI,EAAA,IAAA,EAAAC,CAAA,IAGFD,EAAA,SAAA,YAAAE,EAAAF,EAAA,QAAA,KAAAG,EAAAH,EAAA,SAAA,SAAA,MAKEA,EAAA,SAAA,UAAA,SAAA,MAAA,KAAAA,EAAA,SAAA,UAAA,SAAA,MAAA,OAIEH,EAAAG,EAAA,SAAA,SAAA,IAAA,CAAAC,MAAAL,EAAAI,EAAA,SAAA,SAAA,EAAAC,CAAA,IAIJD,EAAA,SAAA,YAAAJ,EAAA,WACEC,EAAA,SAAA,CAAAI,MAAAL,EAAA,OAAAK,CAAA;AAIF,cAAAG,IAAAJ,EAAA;AACA,QAAAK,EAAAL,EAAA,KAAA,KAAAJ,EAAAQ,CAAA,MACEP,EAAAO,CAAA,IAAA,CAAAH,MAAAL,EAAAQ,CAAA,EAAAH,CAAA;AAAA,MAEF,CAAA,GAGFK,EAAAV,EAAA,KAAA,MACEE,EAAA,QAAA,MAAAF,EAAA,MAAA,IAEFU,EAAAV,EAAA,MAAA,MACEE,EAAA,SAAA,MAAAF,EAAA,OAAA;AAAA,IAAuC;AAAA,IAC3C,EAAA,WAAA,IAAA,MAAA,GAAA;AAAA,EAC8B,GAGhC,EAAA,aAAAC,GAAA,YAAAC,EAAA;AACF;"}