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 1.75 kB
{"version":3,"file":"useFormComponentAttrs.cjs","sources":["../../../packages/hooks/useFormComponentAttrs.ts"],"sourcesContent":["import { toCamelCase } from '@ideaz/utils'\n\nexport function useFormComponentAttrs(props: Record<any, any>) {\n const attrs = useAttrs()\n const onAll = computed(() => {\n const newOn: any = {}\n if (props.evts) {\n // Temporary fix, events trigger faster than rendering, temporarily can only manually modify the corresponding data in the row\n Object.keys(props.evts).forEach((eventName: string) => {\n newOn[`on${toCamelCase(eventName)}`] = (...args: any) => {\n const scope = {\n ...props.scope,\n row: (eventName === 'input' || eventName === 'clear') ? { ...props.scope.row, [props.column.prop]: args[0] || '' } : props.scope.row,\n };\n (props.evts[eventName] || function () { })(scope, ...args)\n }\n })\n }\n return newOn\n })\n const attrsAll = computed(() => {\n return { ...props, ...attrs }\n })\n\n return { attrsAll, onAll }\n}\n"],"names":["useFormComponentAttrs","props","attrs","vue","onAll","newOn","eventName","string","args","scope"],"mappings":"sKAEO,SAAAA,EAAAC,EAAA,CACL,MAAAC,EAAAC,EAAA,SAAA,EACAC,EAAAD,EAAA,SAAA,IAAA,CACE,MAAAE,EAAA,CAAA,EACA,OAAAJ,EAAA,MAEE,OAAA,KAAAA,EAAA,IAAA,EAAA,QAAAK,GAAA,CACED,EAAA,KAAAE,EAAA,YAAAD,CAAA,CAAA,EAAA,EAAA,IAAAE,IAAA,CACE,MAAAC,EAAA,CAAc,GAAAR,EAAA,MACH,IAAAK,IAAA,SAAAA,IAAA,QAAA,CAAA,GAAAL,EAAA,MAAA,IAAA,CAAAA,EAAA,OAAA,IAAA,EAAAO,EAAA,CAAA,GAAA,EAAA,EAAAP,EAAA,MAAA,GACwH,GAEnIA,EAAA,KAAAK,CAAA,GAAA,UAAA,CAAsC,GAAAG,EAAA,GAAAD,CAAA,CAAmB,CAC3D,CAAA,EAGJH,CAAO,CAAA,EAMT,MAAA,CAAA,SAJAF,EAAA,SAAA,KACE,CAAA,GAAAF,EAAA,GAAAC,CAAA,EAA4B,EAG9B,MAAAE,CAAA,CACF"}