UNPKG

yanzhen-design-vue

Version:

40 lines (39 loc) 983 B
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const vue = require("vue"); const utils = require("@yanzhen-libs/utils"); const lodashEs = require("lodash-es"); function handleSchema(schema) { let { grid = false, use = false, row, body, readOnly, type } = schema ?? {}; if (!grid) { switch (true) { case (typeof row === "boolean" && row): case !utils.isEmptyObject(row): grid = true; break; } } if (!use) { switch (true) { case type === "form": use = true; break; } } const rowOption = row && utils.isObject(row) ? row : {}; const rowProps = vue.mergeProps( { gutter: [8, 8] }, rowOption ); return { ...schema, readOnly: typeof readOnly === "boolean" ? readOnly : false, grid, row: rowProps, use, body: utils.isArray(body) ? body : lodashEs.isFunction(body) ? body : [body] }; } exports.handleSchema = handleSchema;