eapp-amis-theme-editor
Version:
amis主题编辑器
209 lines (206 loc) • 6.58 kB
JavaScript
/**
* amis-theme-editor v2.0.11-beta.2
* Copyright 2018-2023 @fex
*/
import { __spreadArray } from 'tslib';
import { render } from 'amis-core';
import React__default from 'react';
import cx from 'classnames';
import { getSchemaTpl } from '../tpl.js';
import { registerComponent } from './index.js';
import { i18n } from 'i18n-runtime';
var ListSelectStateFunc = function (visibleOn, state, type) {
return [{
title: i18n("3712972d84adf48acbd6ad24b4d75ad0"),
visibleOn: visibleOn,
body: [{
type: 'amis-theme-wrapper',
label: false,
title: i18n("961534b4ea37e4e88aada736b299d063"),
visibleOn: visibleOn,
body: [{
mode: 'default',
type: 'amis-theme-border',
name: "".concat(state, ".body.border")
}]
}, {
type: 'amis-theme-wrapper',
label: false,
title: i18n("0103eb2d3dca70270d1a74e9ec987ac9"),
visibleOn: visibleOn,
body: [{
mode: 'default',
type: 'amis-theme-radius',
disableBorder: true,
name: "".concat(state, ".body.border")
}]
}, {
type: 'amis-theme-wrapper',
label: false,
title: i18n("841d77223f0ec8cd0b530ed8e0775b20"),
visibleOn: visibleOn,
body: [{
mode: 'default',
type: 'amis-theme-padding-and-margin',
name: "".concat(state, ".body.padding-and-margin"),
source: '${sizesOptions}',
hideMargin: true
}]
}, {
type: 'amis-theme-wrapper',
label: false,
title: i18n("ca746b1ff10193a3ce20878dec04a733"),
visibleOn: visibleOn,
body: [{
type: 'amis-theme-color-picker',
label: i18n("6b36c6f7ec834692ec6c8e3816349fdd"),
labelMode: 'input',
name: "".concat(state, ".body.color"),
options: '${colorOptions}'
}]
}, {
type: 'amis-theme-wrapper',
label: false,
title: i18n("8e1b944f4389bdaab6f11d5bc83190c8"),
visibleOn: visibleOn,
body: [{
type: 'amis-theme-color-picker',
label: i18n("6b36c6f7ec834692ec6c8e3816349fdd"),
labelMode: 'input',
name: "".concat(state, ".body.bg-color"),
options: '${colorOptions}'
}]
}, {
type: 'amis-theme-wrapper',
label: false,
title: i18n("c8339fd2a85af4ba66084d28df808de4"),
body: [{
type: 'amis-theme-size-editor',
hideMinWidth: true,
hideHeight: true,
name: "size.body.size",
label: false,
state: state
}]
}]
}];
};
var InputTypeConfig = function (type) {
return getSchemaTpl('collapseGroup', __spreadArray(__spreadArray(__spreadArray(__spreadArray([{
title: i18n("4092ed98e9035652d4c9ca9441701ed7"),
body: [{
type: 'select',
name: 'state',
label: i18n("3fea7ca76cdece641436d7ab0d02ab1b"),
selectFirst: true,
options: [{
label: i18n("22b777e6fcb613b8ba83ced9594cd07e"),
value: 'default'
}, {
label: i18n("062d0b688adb10f3af5ebc2fd2667f1c"),
value: 'hover'
}, {
label: i18n("4363c17ebb346b646af55bd8c8075915"),
value: 'active'
}, {
label: i18n("710ad08b11419332713360d2750cd707"),
value: 'disabled'
}]
}]
}], ListSelectStateFunc("${state == 'default' || !state}", 'default'), true), ListSelectStateFunc("${state == 'hover'}", 'hover'), true), ListSelectStateFunc("${state == 'active'}", 'active'), true), ListSelectStateFunc("${state == 'disabled'}", 'disabled'), true));
};
var ThemeInputCommon = function (props) {
var title = props.title,
edit = props.edit,
body = props.body,
activeId = props.activeId;
function handleEdit() {
props.onEdit(edit);
}
return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
className: "theme-component"
}, React__default.createElement("div", {
className: "theme-component-title"
}, title), React__default.createElement("div", {
className: cx('theme-component-content', activeId === edit.path && 'theme-component-content--active'),
onClick: function () {
handleEdit();
}
}, body)));
};
var ThemeListSelect = function (props) {
return {
title: i18n("ae7e62862639fffed2ec9eecd5860e0c"),
body: [{
title: i18n("e1371d733ff347664655629011b4130f"),
body: [{
title: i18n("e1371d733ff347664655629011b4130f"),
body: function (onEdit) {
return React__default.createElement(ThemeInputCommon, {
activeId: props.activeId,
onEdit: onEdit,
title: "\u5217\u8868",
edit: {
title: i18n("54f15b374c1b1e4d70de811011221344"),
path: 'component.listSelect.base',
body: InputTypeConfig()
},
body: React__default.createElement("div", {
className: "theme-component-content-wrap"
}, render({
label: i18n("22b777e6fcb613b8ba83ced9594cd07e"),
type: 'list-select',
name: 'select',
clearable: true,
options: [{
label: 'Option A',
value: 'a'
}, {
label: 'Option B',
value: 'b'
}]
}), render({
type: 'list-select',
name: 'select',
label: i18n("062d0b688adb10f3af5ebc2fd2667f1c"),
clearable: true,
options: [{
label: 'Option A',
value: 'a'
}],
className: 'themeEditor-listSelect--hover'
}), render({
type: 'list-select',
name: 'select',
label: i18n("4363c17ebb346b646af55bd8c8075915"),
clearable: true,
options: [{
label: 'Option A',
value: 'a'
}],
className: 'themeEditor-listSelect--active'
}), render({
type: 'list-select',
name: 'select',
label: i18n("710ad08b11419332713360d2750cd707"),
clearable: true,
options: [{
label: 'Option A',
value: 'a'
}],
className: 'themeEditor-listSelect--disabled'
}))
});
}
}]
}]
};
};
registerComponent('list-select', {
type: 'data-entry',
label: i18n("3712972d84adf48acbd6ad24b4d75ad0"),
key: 'list-select',
component: function () {
return ThemeListSelect;
}
});