UNPKG

yanzhen-design-vue

Version:

39 lines (38 loc) 878 B
import { isObject } from "@yanzhen-libs/utils"; import { handleSchema } from "./handleSchema.mjs"; function handleRawSchema(body, schema) { const { grid, use: _use, readOnly: _readOnly } = handleSchema(schema); let { col, use, readOnly, field, props, ...options } = body ?? {}; switch (true) { case (!_use && use !== true && !isObject(field)): use = false; break; default: use = true; } switch (true) { case _readOnly: readOnly = _readOnly; break; case typeof readOnly !== "boolean": readOnly = false; break; } if (!isObject(props)) { props = {}; } const formItemProps = isObject(field) ? field : {}; const colProps = isObject(col) ? col : {}; return { ...options, props, field: formItemProps, col: colProps, readOnly, grid, use }; } export { handleRawSchema };