el-plus-powerful-form
Version:
## [DOCS](https://peng-xiao-shuai.github.io/vite-vue-admin-docs/zh-CN/component_directive/component/powerful-form-doc.html)
1 lines • 2.43 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","sources":["../packages/index.ts"],"sourcesContent":["import powerfulForm from './powerful-form'\nimport { PowerfulFormSymbol } from './keys'\nimport components from './components'\nimport type { InjectProps } from '~/index'\nimport type { App, Plugin } from 'vue'\nimport type { FormType } from './typings/form-view'\nexport * from './powerful-form'\nexport * from './locale/packages'\nexport * from '~/utils'\nexport * from '~/hooks/useGetRefs'\nexport type * from './typings/index'\n\n// 获取类型\nexport const getType = <T>(target: T) =>\n Object.prototype.toString.call(target).slice(8, -1)\n\n// 深度克隆\nexport const deepClone = <T>(target: T) => {\n let result\n if (getType(target) === 'Object') {\n result = {} as T\n } else if (getType(target) === 'Array') {\n result = [] as T\n } else result = target\n\n for (const i in target) {\n const item = target[i]\n if (getType(item) === 'Object' || getType(item) === 'Array') {\n result[i] = deepClone(item)\n } else result[i] = item\n }\n return result\n}\n\nexport const formViewSetData = <T extends keyof FormType>(\n data: FormType[T]\n): FormType[T] => data\n\nexport const componentRegister = (app: App) => {\n components.forEach((c) => {\n if (!app._context.components[c.name!]) {\n app.component(c.name!, c)\n }\n })\n}\n\nconst makeInstaller = (components: Plugin[] = []) => {\n const install = (app: App, options?: InjectProps) => {\n components.forEach((c) => {\n app.use(c)\n })\n app.provide(PowerfulFormSymbol, options ? options : {})\n }\n\n return install\n}\n\nexport default {\n install: makeInstaller([powerfulForm]),\n}\n"],"names":["getType","target","deepClone","result","i","item","components","formViewSetData","data","componentRegister","app","c"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4Ba,MAAAA,IAAK,CAAAC,MAAc,OAAA,UAAA,SAAA,KAAAA,CAAA,EAAA,MAAA,GAAA,EAAA,GAC5BC,IAAA,CAAAD,MAAA;AAAO,MAAAE;AACT,EAAAH,EAAAC,CAAA,MAAA,WACOE,IAAA,CAAA,IACTH,EAAAC,CAAA,MAAA,UAEaE,IAAA,CAAA,IAKAA,IAAAF;AACT,aAASG,KAAAH,GAAoB;AACvB,UAAAI,IAAAJ,EAAYG,CAAA;AAClB,IAAAJ,EAAAK,CAAA,MAAA,YAAAL,EAAAK,CAAA,MAAA,UACDF,EAAAC,CAAA,IAAAF,EAAAG,CAAA,IAGGF,EAAgBC,CAAA,IAAAC;AAAA,EACd;AACJC,SAAAA;AACE,GACDC,IAAA,CAAAC,MAAAA,GACWC,IAAA,CAAAC,MAA8B;AAC5C,EAAAJ,EAAA,QAAA,CAAAK,MAAA;AAEO,IAAAD,EAAA,SAAA,WAAAC,EAAA,IAAA,KACTD,EAAA,UAAAC,EAAA,MAAAA,CAAA;AAAA,EAEe,CACJ;AACX;;;;;;;"}