cw-form-render-mobile
Version:
通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成
31 lines (30 loc) • 1.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isLayoutWidget = exports.isLayoutContainer = exports.LAYOUT_WIDGETS = void 0;
/**
* 布局容器 widget 列表
* 这些 widget 只用于布局,不应该产生数据嵌套
*/
var LAYOUT_WIDGETS = exports.LAYOUT_WIDGETS = ['collapse', 'boxCollapse', 'card', 'boxcard', 'boxLineTitle', 'boxSubInline', 'lineTitle', 'subInline', 'box', 'group', 'fieldset'];
/**
* 检查是否为布局容器
*/
var isLayoutWidget = exports.isLayoutWidget = function isLayoutWidget(widget) {
if (!widget) return false;
return LAYOUT_WIDGETS.includes(widget);
};
/**
* 检查 schema 是否为布局容器
*/
var isLayoutContainer = exports.isLayoutContainer = function isLayoutContainer(schema) {
if (!schema) return false;
// void 类型且没有 bind
var isVoidType = schema.type === 'void' && !schema.bind;
// widget 是布局组件
var hasLayoutWidget = schema.widget && isLayoutWidget(schema.widget);
// schemaType 是 group
var isGroupType = schema.schemaType === 'group';
return isVoidType || hasLayoutWidget || isGroupType;
};