amis-theme-editor
Version:
amis主题编辑器
149 lines (146 loc) • 4.79 kB
JavaScript
/**
* amis-theme-editor v2.0.22-beta.2
* Copyright 2018-2023 @fex
*/
import { __spreadArray } from 'tslib';
import React__default from 'react';
import { render } from 'amis-core';
import { getSchemaTpl } from '../tpl.js';
import cx from 'classnames';
import { registerComponent } from './index.js';
import { i18n } from 'i18n-runtime';
var ComponentStateFunc = function (visibleOn, state, type) {
return [{
type: 'amis-theme-wrapper',
label: false,
title: i18n("6b36c6f7ec834692ec6c8e3816349fdd"),
visibleOn: visibleOn,
body: [{
type: 'amis-theme-color-picker',
label: i18n("ca746b1ff10193a3ce20878dec04a733"),
labelMode: 'input',
name: "".concat(state, ".body.color"),
options: '${colorOptions}'
}, {
type: 'amis-theme-color-picker',
label: i18n("8e1b944f4389bdaab6f11d5bc83190c8"),
labelMode: 'input',
name: "".concat(state, ".body.bg-color"),
options: '${colorOptions}'
}]
}];
};
var ComponentTypeConfig = function (type, props) {
return getSchemaTpl('collapseGroup', [{
title: i18n("4092ed98e9035652d4c9ca9441701ed7"),
body: [{
type: 'input-text',
label: i18n("d7ec2d3fea4756bc1642e0f10c180cf5"),
disabled: true,
name: 'label'
}, {
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'
}]
}]
}, {
title: i18n("2aafc8011eec22ee269853b9f23614b8"),
body: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], ComponentStateFunc("${state == 'default' || !state}", 'default'), true), ComponentStateFunc("${state == 'hover'}", 'hover'), true), ComponentStateFunc("${state == 'active'}", 'active'), true), ComponentStateFunc("${state == 'disabled'}", 'disabled'), true), [{
type: 'amis-theme-font-editor',
label: false,
hasSenior: false,
visibleOn: "${state == 'default' || !state}",
hideColor: true,
hideLineHeight: true,
hideFontFamily: true,
name: 'default.body.font'
}, {
type: 'amis-theme-wrapper',
label: false,
title: i18n("ac9571cd665c66c2e444bf2c556f985d"),
visibleOn: "${state == 'default' || !state}",
body: [{
name: 'default.body.icon',
label: i18n("598f69a9b640508d8e124fd7d33131f0"),
type: 'icon-select',
returnSvg: true,
onChange: function (svg) {
if (!svg && svg !== '') {
return;
}
setTimeout(function () {
props.handleReFreshToken('component.inputTime.base');
}, 400);
}
}]
}], false)
}]);
};
var ThemeInputTimeCommon = 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.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();
}
}, refreshToken === edit.path ? null : body)));
};
var ThemeInputTime = function (props) {
return {
title: i18n("601fd75542cb0690568b273e67580ff0"),
body: [{
title: i18n("e1371d733ff347664655629011b4130f"),
body: [{
title: i18n("18c63459a2c069022c7790430f761214"),
body: function (onEdit) {
return React__default.createElement(ThemeInputTimeCommon, {
activeId: props.activeId,
refreshToken: props.refreshToken,
onEdit: onEdit,
title: i18n("18c63459a2c069022c7790430f761214"),
edit: {
title: i18n("c51efb736b7b9d54241ab06fd71e68b4"),
path: 'component.inputTime.base',
body: ComponentTypeConfig('', props)
},
body: render({
type: 'input-time',
name: 'default',
label: i18n("22b777e6fcb613b8ba83ced9594cd07e")
})
});
}
}]
}]
};
};
registerComponent('input-time', {
type: 'data-entry',
label: i18n("824e6f89eb435901caf46539c4598460"),
key: 'input-time',
component: function () {
return ThemeInputTime;
}
});