UNPKG

amis-theme-editor

Version:

amis主题编辑器

216 lines (210 loc) 7.3 kB
/** * amis-theme-editor v2.0.22-beta.2 * Copyright 2018-2023 @fex */ 'use strict'; var tslib = require('tslib'); var amisCore = require('amis-core'); var React = require('react'); var cx = require('classnames'); var tpl = require('../tpl.js'); 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 ListSelectStateFunc = function (visibleOn, state, type) { return [{ title: i18nRuntime.i18n("3712972d84adf48acbd6ad24b4d75ad0"), visibleOn: visibleOn, body: [{ type: 'amis-theme-wrapper', label: false, title: i18nRuntime.i18n("961534b4ea37e4e88aada736b299d063"), visibleOn: visibleOn, body: [{ mode: 'default', type: 'amis-theme-border', name: "".concat(state, ".body.border") }] }, { type: 'amis-theme-wrapper', label: false, title: i18nRuntime.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: i18nRuntime.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: i18nRuntime.i18n("ca746b1ff10193a3ce20878dec04a733"), visibleOn: visibleOn, body: [{ type: 'amis-theme-color-picker', label: i18nRuntime.i18n("6b36c6f7ec834692ec6c8e3816349fdd"), labelMode: 'input', name: "".concat(state, ".body.color"), options: '${colorOptions}' }] }, { type: 'amis-theme-wrapper', label: false, title: i18nRuntime.i18n("8e1b944f4389bdaab6f11d5bc83190c8"), visibleOn: visibleOn, body: [{ type: 'amis-theme-color-picker', label: i18nRuntime.i18n("6b36c6f7ec834692ec6c8e3816349fdd"), labelMode: 'input', name: "".concat(state, ".body.bg-color"), options: '${colorOptions}' }] }, { type: 'amis-theme-wrapper', label: false, title: i18nRuntime.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 tpl.getSchemaTpl('collapseGroup', tslib.__spreadArray(tslib.__spreadArray(tslib.__spreadArray(tslib.__spreadArray([{ title: i18nRuntime.i18n("4092ed98e9035652d4c9ca9441701ed7"), body: [{ 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' }, { label: i18nRuntime.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["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(); } }, body))); }; var ThemeListSelect = function (props) { return { title: i18nRuntime.i18n("ae7e62862639fffed2ec9eecd5860e0c"), body: [{ title: i18nRuntime.i18n("e1371d733ff347664655629011b4130f"), body: [{ title: i18nRuntime.i18n("e1371d733ff347664655629011b4130f"), body: function (onEdit) { return React__default["default"].createElement(ThemeInputCommon, { activeId: props.activeId, onEdit: onEdit, title: i18nRuntime.i18n("3712972d84adf48acbd6ad24b4d75ad0"), edit: { title: i18nRuntime.i18n("54f15b374c1b1e4d70de811011221344"), path: 'component.listSelect.base', body: InputTypeConfig() }, body: React__default["default"].createElement("div", { className: "theme-component-content-wrap" }, amisCore.render({ label: i18nRuntime.i18n("22b777e6fcb613b8ba83ced9594cd07e"), type: 'list-select', name: 'select', clearable: true, options: [{ label: 'Option A', value: 'a' }, { label: 'Option B', value: 'b' }] }), amisCore.render({ type: 'list-select', name: 'select', label: i18nRuntime.i18n("062d0b688adb10f3af5ebc2fd2667f1c"), clearable: true, options: [{ label: 'Option A', value: 'a' }], className: 'themeEditor-listSelect--hover' }), amisCore.render({ type: 'list-select', name: 'select', label: i18nRuntime.i18n("4363c17ebb346b646af55bd8c8075915"), clearable: true, options: [{ label: 'Option A', value: 'a' }], className: 'themeEditor-listSelect--active' }), amisCore.render({ type: 'list-select', name: 'select', label: i18nRuntime.i18n("710ad08b11419332713360d2750cd707"), clearable: true, options: [{ label: 'Option A', value: 'a' }], className: 'themeEditor-listSelect--disabled' })) }); } }] }] }; }; index.registerComponent('list-select', { type: 'data-entry', label: i18nRuntime.i18n("3712972d84adf48acbd6ad24b4d75ad0"), key: 'list-select', component: function () { return ThemeListSelect; } });