eapp-amis-theme-editor
Version:
amis主题编辑器
268 lines (262 loc) • 9.91 kB
JavaScript
/**
* amis-theme-editor v2.0.11-beta.2
* Copyright 2018-2023 @fex
*/
'use strict';
var React = require('react');
var amisCore = require('amis-core');
var tpl = require('../tpl.js');
var cx = require('classnames');
var index = require('./index.js');
var i18nRuntime = require('i18n-runtime');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
var ThemeComboCommon = function (props) {
var title = props.title,
edit = props.edit,
body = props.body,
activeId = props.activeId,
refreshToken = props.refreshToken;
function handleEdit() {
props.onEdit(edit);
}
return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("div", {
className: "theme-component"
}, React__default["default"].createElement("div", {
className: "theme-component-title"
}, title), React__default["default"].createElement("div", {
className: cx__default["default"]('theme-component-content', 'theme-component-collapse-content', activeId === edit.path && 'theme-component-content--active'),
onClick: function () {
handleEdit();
}
}, refreshToken === edit.path ? null : body)));
};
var ThemeCombo = function (props) {
return {
title: '组合 Combo',
body: [{
title: i18nRuntime.i18n("e1371d733ff347664655629011b4130f"),
body: [{
title: i18nRuntime.i18n("18c63459a2c069022c7790430f761214"),
body: function (onEdit) {
return React__default["default"].createElement(ThemeComboCommon, {
activeId: props.activeId,
onEdit: onEdit,
title: "\u9ED8\u8BA4",
edit: {
title: i18nRuntime.i18n("c51efb736b7b9d54241ab06fd71e68b4"),
path: 'component.combo.base.body',
body: tpl.getSchemaTpl('normal', [{
type: 'amis-theme-wrapper',
label: false,
title: false,
body: [{
type: 'amis-theme-color-picker',
label: i18nRuntime.i18n("8e1b944f4389bdaab6f11d5bc83190c8"),
labelMode: 'input',
name: 'bg-color',
options: '${colorOptions}'
}]
}, {
type: 'amis-theme-wrapper',
label: false,
title: i18nRuntime.i18n("961534b4ea37e4e88aada736b299d063"),
body: [{
mode: 'default',
type: 'amis-theme-border',
name: 'vertical-border'
}]
}, {
type: 'amis-theme-wrapper',
label: false,
title: '边框悬浮',
body: [{
mode: 'default',
type: 'amis-theme-border',
name: 'vertical-hover-border'
}]
}, {
type: 'amis-theme-wrapper',
label: false,
title: i18nRuntime.i18n("0103eb2d3dca70270d1a74e9ec987ac9"),
body: [{
mode: 'default',
type: 'amis-theme-radius',
disableBorder: true,
name: 'vertical-border'
}]
}, {
type: 'amis-theme-wrapper',
label: false,
title: i18nRuntime.i18n("841d77223f0ec8cd0b530ed8e0775b20"),
body: [{
mode: 'default',
type: 'amis-theme-padding-and-margin',
name: 'vertical-padding-and-margin',
source: '${sizesOptions}',
hideMargin: true
}]
}])
},
body: amisCore.render({
type: 'combo',
name: 'combo1',
label: false,
multiLine: true,
items: [{
name: 'text',
label: '文本',
type: 'input-text'
}, {
name: 'select',
label: i18nRuntime.i18n("ea15ae2b7fba76c83eec6d0986d15197"),
type: 'select',
options: ['a', 'b', 'c']
}]
})
});
}
}, {
title: '多选模式',
body: function (onEdit) {
return React__default["default"].createElement(ThemeComboCommon, {
activeId: props.activeId,
refreshToken: props.refreshToken,
onEdit: onEdit,
title: "\u591A\u9009\u6A21\u5F0F",
edit: {
title: '多选模式配置',
path: 'component.combo.multi.body',
body: tpl.getSchemaTpl('collapseGroup', [{
title: '新增按钮',
body: [{
type: 'amis-theme-wrapper',
label: false,
title: false,
body: [{
type: 'amis-theme-color-picker',
label: i18nRuntime.i18n("8e1b944f4389bdaab6f11d5bc83190c8"),
labelMode: 'input',
name: 'addBtn-bg-color',
options: '${colorOptions}'
}, {
type: 'amis-theme-select',
name: 'addBtn-height',
label: i18nRuntime.i18n("c1df04eec5fa0857bc0df2d68d8e953c"),
options: '${sizesOptions}'
}]
}, {
type: 'amis-theme-font-editor',
label: false,
hasSenior: false,
hideFontFamily: true,
name: 'addBtn-font'
}, {
type: 'amis-theme-wrapper',
label: false,
title: i18nRuntime.i18n("0103eb2d3dca70270d1a74e9ec987ac9"),
body: [{
mode: 'default',
type: 'amis-theme-radius',
disableBorder: true,
name: 'addBtn-border'
}]
}, {
type: 'amis-theme-wrapper',
label: false,
title: i18nRuntime.i18n("841d77223f0ec8cd0b530ed8e0775b20"),
body: [{
mode: 'default',
type: 'amis-theme-padding-and-margin',
name: 'addBtn-padding-and-margin',
source: '${sizesOptions}',
hideMargin: true
}]
}, {
type: 'amis-theme-wrapper',
label: false,
title: i18nRuntime.i18n("062d0b688adb10f3af5ebc2fd2667f1c"),
body: [{
type: 'amis-theme-color-picker',
label: i18nRuntime.i18n("ca746b1ff10193a3ce20878dec04a733"),
labelMode: 'input',
name: 'addBtn-hover-color',
options: '${colorOptions}'
}, {
type: 'amis-theme-color-picker',
label: i18nRuntime.i18n("8e1b944f4389bdaab6f11d5bc83190c8"),
labelMode: 'input',
name: 'addBtn-hover-bg-color',
options: '${colorOptions}'
}]
}, {
type: 'amis-theme-wrapper',
label: false,
title: i18nRuntime.i18n("4363c17ebb346b646af55bd8c8075915"),
body: [{
type: 'amis-theme-color-picker',
label: i18nRuntime.i18n("ca746b1ff10193a3ce20878dec04a733"),
labelMode: 'input',
name: 'addBtn-active-color',
options: '${colorOptions}'
}, {
type: 'amis-theme-color-picker',
label: i18nRuntime.i18n("8e1b944f4389bdaab6f11d5bc83190c8"),
labelMode: 'input',
name: 'addBtn-active-bg-color',
options: '${colorOptions}'
}]
}]
}, {
title: i18nRuntime.i18n("a3a36a013c7e5e647062a8467940b618"),
body: [{
type: 'amis-theme-wrapper',
label: false,
title: false,
body: [{
type: 'amis-theme-color-picker',
label: i18nRuntime.i18n("6b36c6f7ec834692ec6c8e3816349fdd"),
labelMode: 'input',
name: 'delBtn-color',
options: '${colorOptions}'
}, {
type: 'amis-theme-color-picker',
label: i18nRuntime.i18n("062d0b688adb10f3af5ebc2fd2667f1c"),
labelMode: 'input',
name: 'delBtn-hover-color',
options: '${colorOptions}'
}]
}]
}])
},
body: amisCore.render({
type: 'combo',
name: 'combo2',
label: false,
multiple: true,
items: [{
name: 'text',
label: '文本',
type: 'input-text'
}, {
name: 'select',
label: i18nRuntime.i18n("ea15ae2b7fba76c83eec6d0986d15197"),
type: 'select',
options: ['a', 'b', 'c']
}]
})
});
}
}]
}]
};
};
index.registerComponent('combo', {
type: 'data-entry',
label: '组合',
key: 'combo',
component: function () {
return ThemeCombo;
}
});