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.54 kB
Source Map (JSON)
{"version":3,"file":"useFormSlots.cjs","sources":["../../../../../../packages/element/form/src/hooks/useFormSlots.tsx"],"sourcesContent":["// import { h } from 'vue';\nimport { isFunction, isSlot } from '@ideaz/utils'\nimport type { VNode } from 'vue'\nimport FormItemLabel from '../FormItemLabel'\nimport type { FormProps } from '../props'\nimport type { FormColumn, Slots } from '../../../types'\n\nexport function useFormSlots(col: FormColumn, slots: Slots, props: FormProps) {\n const scopedSlots: Slots = {}\n\n const getLabelSlotName = () => {\n if (isSlot(col.label))\n return col.label as string\n return 'label'\n }\n\n scopedSlots[getLabelSlotName()] = () => {\n const labelSlotName = getLabelSlotName()\n if (isSlot(col.label) && isFunction(slots[labelSlotName]))\n return (slots[labelSlotName] as (() => VNode))()\n\n if (isFunction(col.label))\n return col.label()\n\n if (col.formItemProps && isFunction(col.formItemProps.label))\n return col.formItemProps.label()\n\n return (\n <FormItemLabel\n {...{\n ...col.formItemProps,\n colon: Object.prototype.hasOwnProperty.call(\n col.formItemProps || {},\n 'colon',\n )\n ? col.formItemProps?.colon\n : props.colon,\n }}\n />\n )\n }\n\n if (col.error) {\n if (isSlot(col.error) && isFunction(slots[col.error as string])) {\n const error = col.error as string\n scopedSlots[error] = () => <div class=\"el-form-item__error\">{(slots[error!] as (() => VNode))()}</div>\n }\n else if (isFunction(col.error)) {\n scopedSlots.error = () => <div class=\"el-form-item__error\">{(col.error as (() => VNode))()}</div>\n }\n else {\n scopedSlots.error = () => <div class=\"el-form-item__error\">{col.error}</div>\n }\n }\n\n return { scopedSlots }\n}\n"],"names":["useFormSlots","col","slots","props","scopedSlots","labelSlotName","getLabelSlotName","is","error"],"mappings":"4NAOO,SAAAA,EAAAC,EAAAC,EAAAC,EAAA,4CAMH,WAGFC,EAAAA,EAAAA,CAAAA,EAAAA,IAAAA,OACE,MAAAC,EAAAC,EAAA,sDAIAC,EAAA,WAAAN,EAAA,KAAA,EAAAA,EAAA,MAAA,2OAeqB,EAAA,IAAA,WAOrB,GAAAM,EAAA,OAAAN,EAAA,KAAA,GAAAM,EAAA,WAAAL,EAAAD,EAAA,KAAA,CAAA,EAAA,CACE,MAAAO,EAAAP,EAAA,MACAG,EAAAA,CAAAA,EAAAA,IAAAA,EAAAA,YAAAA,MAAAA,CAAqB,MAAA,qBAAA,EAAA,CAAAF,EAAAM,CAAA,EAAA,CAAA,CAAA,6BAGrBJ,EAAAA,MAAAA,IAAAA,EAAAA,YAAAA,MAAAA,CAAoB,MAAA,qBAAA,EAAA,CAAAH,EAAA,MAAA,CAAA,CAAA,EAGpBG,EAAAA,MAAAA,IAAAA,EAAAA,YAAAA,MAAAA,CAAoB,MAAA,yCAIfA,YAAAA,EACX"}