UNPKG

yanzhen-design-vue

Version:

41 lines (40 loc) 1.59 kB
import { isEmptyObject } from "@yanzhen-libs/utils"; import { pick, mergeWith } from "lodash-es"; import "../../../form/index.mjs"; import "../../../form-item/index.mjs"; import "../../../row/index.mjs"; import "../../../col/index.mjs"; import { formProviderCommonPropsKey } from "../constant.mjs"; import { formProps } from "../../../form/src/form.mjs"; import { formItemProps } from "../../../form-item/src/form-item.mjs"; import { rowProps } from "../../../row/src/row.mjs"; import { colProps } from "../../../col/src/col.mjs"; const commonKey = formProviderCommonPropsKey; const formPropsKey = Object.keys(formProps); const formItemPropsKey = Object.keys(formItemProps); const rowPropsKey = Object.keys(rowProps); const colPropsKey = Object.keys(colProps); function handleSchemaOptions(options) { const { form, row, model, ...opts } = options ?? {}; const formProps2 = pick(form, ...formPropsKey, ...commonKey); const formItemProps2 = mergeWith( pick(form, ...formItemPropsKey), pick((form == null ? void 0 : form.item) ?? {}, ...formItemPropsKey, ...commonKey) ); const rowProps2 = pick(row, ...rowPropsKey, ...commonKey); const colProps2 = mergeWith( pick(row, ...rowPropsKey), pick((row == null ? void 0 : row.col) ?? {}, ...colPropsKey, ...commonKey) ); return { ...opts, model: !isEmptyObject(model) ? model : !isEmptyObject(form == null ? void 0 : form.model) ? form == null ? void 0 : form.model : void 0, form: formProps2, formItem: formItemProps2, row: rowProps2, col: colProps2 }; } export { handleSchemaOptions };