UNPKG

oadp-material

Version:
331 lines (330 loc) 10.9 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports["default"] = void 0; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var OadpTabMeta = { "componentName": "OadpTab", "title": "选项卡", "docUrl": "", "category": "高级组件", "group": "低代码组件", "screenshot": "https://img.alicdn.com/imgextra/i4/O1CN01mh9LPG268B90t8DaA_!!6000000007616-55-tps-56-56.svg", "devMode": "proCode", "npm": { "package": "oadp-material", "version": "{{version}}", "exportName": "OadpTab", "main": "src/index.tsx", "destructuring": true, "subName": "" }, "configure": { "props": [{ "name": "DataSetting", "title": "数据设置", "type": "group", "display": "block", "items": [{ "name": "name", "title": { "label": { "type": "i18n", "zh_CN": "表单标识", "en_US": "Name" }, "tip": { "type": "i18n", "zh_CN": "属性: name | 说明: 表单标识", "en_US": "prop: name | description: switch name" } }, "setter": "StringSetter", "supportVariable": false }, { "name": "id", "title": { "label": { "type": "i18n", "zh_CN": "唯一标识", "en_US": "ID" }, "tip": { "type": "i18n", "zh_CN": "属性: id | 说明: 唯一标识", "en_US": "prop: id | description: switch id" } }, "setter": "StringSetter" }, { "name": "items", "title": "选项", "setter": { "componentName": "ArraySetter", "props": { "itemSetter": { "componentName": "ObjectSetter", "props": { "config": { "items": [{ "name": "title", "title": "名称", "defaultValue": "选项", "important": true, "setter": "StringSetter" }, { "name": "primaryKey", "title": "项目编号", "condition": function condition() { return false; }, "setter": "StringSetter" }, { "name": "closeable", "title": "可关闭", "initialValue": false, "setter": "BoolSetter" }, { "name": "disabled", "title": "是否禁用", "initialValue": false, "setter": "BoolSetter" }] } }, "initialValue": function initialValue() { return { "primaryKey": String(Math.floor(Math.random() * 10000)), "title": "选项", "closeable": false, "disabled": false }; } } } }, "extraProps": { getValue: function getValue(target) { var map = target.node.children.map(function (child) { var primaryKey = child.getPropValue('primaryKey') ? String(child.getPropValue('primaryKey')) : child.id; return { primaryKey: primaryKey, title: child.getPropValue('title') || '标签项', closeable: child.getPropValue('closeable'), disabled: child.getPropValue('disabled') }; }); return map; }, setValue: function setValue(target, value) { var node = target.node; var map = {}; if (!Array.isArray(value)) { value = []; } value.forEach(function (item) { var tabitem = Object.assign({}, item); map[item.primaryKey] = tabitem; }); node.children.mergeChildren(function (child) { var primaryKey = String(child.getPropValue('primaryKey')); if (Object.hasOwnProperty.call(map, primaryKey)) { child.setPropValue('title', map[primaryKey].title); child.setPropValue('closeable', map[primaryKey].closeable); child.setPropValue('disabled', map[primaryKey].disabled); delete map[primaryKey]; return false; } return true; }, function () { var items = []; for (var primaryKey in map) { if (Object.hasOwnProperty.call(map, primaryKey)) { items.push({ "componentName": "OadpTabItem", "props": map[primaryKey] }); } } return items; }, function (child1, child2) { var a = value.findIndex(function (item) { return String(item.primaryKey) === String(child1.getPropValue('primaryKey')); }); var b = value.findIndex(function (item) { return String(item.primaryKey) === String(child2.getPropValue('primaryKey')); }); return a - b; }); } } }] }, { "name": "DisplaySetting", "title": "显示设置", "type": "group", "display": "block", "items": [{ "name": "size", "title": { "label": { "type": "i18n", "en-US": "Size", "zh-CN": "尺寸模式" }, "tip": { "type": "i18n", "zh_CN": "属性: size | 说明: 尺寸模式,可选值:small=紧凑模式, medium=普通模式。默认为:medium。", "en_US": "prop: size | description: Size mode, optional values: small=compact mode, medium=normal mode. The default is: medium." } }, "description": "属性: size | 说明: 尺寸模式,可选值:small=紧凑模式, medium=普通模式。默认为:medium。", "setter": { "componentName": "RadioGroupSetter", "props": { "dataSource": [{ "label": "普通模式", "value": "medium" }, { "label": "紧凑模式", "value": "small" }], "options": [{ "label": "普通模式", "value": "medium" }, { "label": "紧凑模式", "value": "small" }] }, "initialValue": "medium" } }, { "name": "shape", "title": { "label": { "type": "i18n", "en-US": "Shape", "zh-CN": "外观形态" }, "tip": { "type": "i18n", "zh_CN": "属性: shape | 说明: 外观形态,可选值:pure=普通模式, wrapped=包裹模式, text=文本模式, capsule=胶囊模式。默认为:pure。", "en_US": "prop: shape | description: shape mode, optional values: pure=normal mode, wrapped=package mode, text=text mode, capsule=capsule mode. Default: pure." } }, "description": "属性: mode | 说明: 外观形态,可选值:pure=普通模式, wrapped=包裹模式, text=文本模式, capsule=胶囊模式。默认为:pure。", "setter": { "componentName": "RadioGroupSetter", "props": { "dataSource": [{ "label": "普通模式", "value": "pure" }, { "label": "包裹模式", "value": "wrapped" }, { "label": "文本模式", "value": "text" }, { "label": "胶囊模式", "value": "capsule" }], "options": [{ "label": "普通模式", "value": "pure" }, { "label": "包裹模式", "value": "wrapped" }, { "label": "文本模式", "value": "text" }, { "label": "胶囊模式", "value": "capsule" }] }, "initialValue": "pure" } }] }, { "name": "InteractionSetting", "title": "交互设置", "type": "group", "display": "block", "items": [{ "name": "excessMode", "title": { "label": { "type": "i18n", "en-US": "Excess Mode", "zh-CN": "展示更多" }, "tip": { "type": "i18n", "zh_CN": "属性: excessMode | 说明: 展示更多,选项卡过多时的滑动模式,可选值:slide=滑动模式, dropdown=下拉模式。默认为:slide。", "en_US": "prop: excessMode | description: Display more, sliding mode with too many tabs, optional values: slide=sliding mode, dropout=drop-down mode. Default is: slide." } }, "description": "属性: size | 说明: 展示更多,选项卡过多时的滑动模式,可选值:slide=滑动模式, dropdown=下拉模式。默认为:slide。", "setter": { "componentName": "RadioGroupSetter", "props": { "dataSource": [{ "label": "滑动模式", "value": "slide" }, { "label": "下拉模式", "value": "dropdown" }], "options": [{ "label": "滑动模式", "value": "slide" }, { "label": "下拉模式", "value": "dropdown" }] }, "initialValue": "slide" } }] }], "supports": { "style": true }, "component": { "isContainer": true, "nestingRule": { "childWhitelist": ["OadpTabItem"] } } } }; var snippets = [{ "title": "选项卡", "screenshot": "https://img.alicdn.com/imgextra/i4/O1CN01mh9LPG268B90t8DaA_!!6000000007616-55-tps-56-56.svg", "schema": { "componentName": "OadpTab", "props": { "shape": "pure", "size": "medium", "excessMode": "slide" }, "children": [{ "componentName": "OadpTabItem", "props": { "title": '选项1', "primaryKey": 'tab-item-1' } }, { "componentName": "OadpTabItem", "props": { "title": '选项2', "primaryKey": 'tab-item-2' } }] } }]; var _default = exports["default"] = (0, _extends2["default"])({}, OadpTabMeta, { snippets: snippets });