amis-theme-editor
Version:
amis主题编辑器
156 lines (150 loc) • 5.38 kB
JavaScript
/**
* amis-theme-editor v2.0.22-beta.2
* Copyright 2018-2023 @fex
*/
'use strict';
var tslib = require('tslib');
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 ComponentStateFunc = function (visibleOn, state, type) {
return [{
type: 'amis-theme-wrapper',
label: false,
title: i18nRuntime.i18n("6b36c6f7ec834692ec6c8e3816349fdd"),
visibleOn: visibleOn,
body: [{
type: 'amis-theme-color-picker',
label: i18nRuntime.i18n("ca746b1ff10193a3ce20878dec04a733"),
labelMode: 'input',
name: "".concat(state, ".body.color"),
options: '${colorOptions}'
}, {
type: 'amis-theme-color-picker',
label: i18nRuntime.i18n("8e1b944f4389bdaab6f11d5bc83190c8"),
labelMode: 'input',
name: "".concat(state, ".body.bg-color"),
options: '${colorOptions}'
}]
}];
};
var ComponentTypeConfig = function (type, props) {
return tpl.getSchemaTpl('collapseGroup', [{
title: i18nRuntime.i18n("4092ed98e9035652d4c9ca9441701ed7"),
body: [{
type: 'input-text',
label: i18nRuntime.i18n("d7ec2d3fea4756bc1642e0f10c180cf5"),
disabled: true,
name: 'label'
}, {
type: 'select',
name: 'state',
label: i18nRuntime.i18n("3fea7ca76cdece641436d7ab0d02ab1b"),
selectFirst: true,
options: [{
label: i18nRuntime.i18n("22b777e6fcb613b8ba83ced9594cd07e"),
value: 'default'
}, {
label: i18nRuntime.i18n("062d0b688adb10f3af5ebc2fd2667f1c"),
value: 'hover'
}, {
label: i18nRuntime.i18n("4363c17ebb346b646af55bd8c8075915"),
value: 'active'
}]
}]
}, {
title: i18nRuntime.i18n("2aafc8011eec22ee269853b9f23614b8"),
body: tslib.__spreadArray(tslib.__spreadArray(tslib.__spreadArray(tslib.__spreadArray(tslib.__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: i18nRuntime.i18n("ac9571cd665c66c2e444bf2c556f985d"),
visibleOn: "${state == 'default' || !state}",
body: [{
name: 'default.body.icon',
label: i18nRuntime.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["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', activeId === edit.path && 'theme-component-content--active'),
onClick: function () {
handleEdit();
}
}, refreshToken === edit.path ? null : body)));
};
var ThemeInputTime = function (props) {
return {
title: i18nRuntime.i18n("601fd75542cb0690568b273e67580ff0"),
body: [{
title: i18nRuntime.i18n("e1371d733ff347664655629011b4130f"),
body: [{
title: i18nRuntime.i18n("18c63459a2c069022c7790430f761214"),
body: function (onEdit) {
return React__default["default"].createElement(ThemeInputTimeCommon, {
activeId: props.activeId,
refreshToken: props.refreshToken,
onEdit: onEdit,
title: i18nRuntime.i18n("18c63459a2c069022c7790430f761214"),
edit: {
title: i18nRuntime.i18n("c51efb736b7b9d54241ab06fd71e68b4"),
path: 'component.inputTime.base',
body: ComponentTypeConfig('', props)
},
body: amisCore.render({
type: 'input-time',
name: 'default',
label: i18nRuntime.i18n("22b777e6fcb613b8ba83ced9594cd07e")
})
});
}
}]
}]
};
};
index.registerComponent('input-time', {
type: 'data-entry',
label: i18nRuntime.i18n("824e6f89eb435901caf46539c4598460"),
key: 'input-time',
component: function () {
return ThemeInputTime;
}
});