UNPKG

amis-theme-editor

Version:

amis主题编辑器

137 lines (134 loc) 4.45 kB
/** * 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("961534b4ea37e4e88aada736b299d063"), visibleOn: visibleOn, body: [{ mode: 'default', type: 'amis-theme-border', name: "".concat(state, ".body.border"), state: state }] }, { type: 'amis-theme-wrapper', label: false, title: i18n("0103eb2d3dca70270d1a74e9ec987ac9"), visibleOn: visibleOn, body: [{ mode: 'default', type: 'amis-theme-radius', name: "".concat(state, ".body.border"), state: state }] }]; }; 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' }, { label: i18n("710ad08b11419332713360d2750cd707"), value: 'disabled' }] }] }, { title: i18n("2aafc8011eec22ee269853b9f23614b8"), body: __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) }]); }; var ThemeInputRichTextCommon = 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', 'theme-component-collapse-content', activeId === edit.path && 'theme-component-content--active'), onClick: function () { handleEdit(); } }, refreshToken === edit.path ? null : body))); }; var ThemeInputRichText = function (props) { return { title: i18n("6b7ab4f984739ad5a6389b865857dca3"), body: [{ title: i18n("e1371d733ff347664655629011b4130f"), body: [{ title: i18n("18c63459a2c069022c7790430f761214"), body: function (onEdit) { return React__default.createElement(ThemeInputRichTextCommon, { activeId: props.activeId, refreshToken: props.refreshToken, onEdit: onEdit, title: i18n("18c63459a2c069022c7790430f761214"), edit: { title: i18n("c51efb736b7b9d54241ab06fd71e68b4"), path: 'component.inputRichText.base', body: ComponentTypeConfig() }, body: React__default.createElement("div", null, render({ type: 'input-rich-text', name: 'default', label: i18n("22b777e6fcb613b8ba83ced9594cd07e") }), React__default.createElement("div", { style: { height: '20px' } }), render({ type: 'input-rich-text', name: 'disabled', disabled: true, label: i18n("710ad08b11419332713360d2750cd707") })) }); } }] }] }; }; registerComponent('input-rich-text', { type: 'data-entry', label: i18n("24b6d4c0892a8f3ee2a982e3ab0afe38"), key: 'input-rich-text', component: function () { return ThemeInputRichText; } });