UNPKG

eapp-amis-theme-editor

Version:

amis主题编辑器

372 lines (369 loc) 12.2 kB
/** * amis-theme-editor v2.0.11-beta.2 * Copyright 2018-2023 @fex */ 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 ThemeFieldSetCommon = 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 ThemeFieldSet = function (props) { return { title: '表单项集合 FieldSet', body: [{ title: i18n("e1371d733ff347664655629011b4130f"), body: [{ title: i18n("18c63459a2c069022c7790430f761214"), body: function (onEdit) { return React__default.createElement(ThemeFieldSetCommon, { activeId: props.activeId, onEdit: onEdit, title: "\u6807\u9898", edit: { title: '标题配置', path: 'component.fieldSet.legend.body', body: getSchemaTpl('normal', [{ type: 'amis-theme-font-editor', label: false, hasSenior: false, hideLineHeight: true, hideFontFamily: true, name: 'font' }, { type: 'amis-theme-wrapper', label: false, title: false, body: [{ type: 'amis-theme-select', name: 'height', label: i18n("c1df04eec5fa0857bc0df2d68d8e953c"), options: '${sizesOptions}' }] }, { type: 'amis-theme-wrapper', label: false, title: i18n("e8ed49e9fde0bb778e2185876c2d2697"), body: [{ mode: 'default', type: 'amis-theme-padding-and-margin', name: 'padding-and-margin', source: '${sizesOptions}' }] }, { type: 'amis-theme-wrapper', label: false, title: i18n("45235f6c8fa2f6bbb0d5b69742eb1076"), body: [{ type: 'amis-theme-select', name: 'border-width', label: i18n("c28479019e24e0e4745f4948e9e97ee7"), options: '${sizesOptions}' }, { type: 'amis-theme-color-picker', label: i18n("6b36c6f7ec834692ec6c8e3816349fdd"), labelMode: 'input', name: 'border-color', options: '${colorOptions}' }] }]) }, body: render({ type: 'fieldSet', title: '基本配置', body: [{ name: 'text1', type: 'input-text', label: '文本1' }, { name: 'text2', type: 'input-text', label: '文本2' }] }) }); } }] }, { title: '不同大小', body: [{ title: 'xs', body: function (onEdit) { return React__default.createElement(ThemeFieldSetCommon, { activeId: props.activeId, onEdit: onEdit, title: "xs", edit: { title: 'xs配置', path: 'component.fieldSet.size.xs.body', body: getSchemaTpl('normal', [{ type: 'amis-theme-wrapper', label: false, title: i18n("e8ed49e9fde0bb778e2185876c2d2697"), body: [{ mode: 'default', type: 'amis-theme-padding-and-margin', name: 'padding-and-margin', hideMargin: true, source: '${sizesOptions}' }] }, { type: 'amis-theme-wrapper', label: false, title: i18n("9c07532d0c9acfecfc4ec2eb265c3e03"), body: [{ type: 'amis-theme-select', name: 'fontSize', label: i18n("fc55aff8c7e01416e93ac218d98b3b74"), extraUnit: ['px'], options: '${fontSizeOptions}' }] }]) }, body: render({ type: 'fieldSet', title: '基本配置', size: 'xs', body: [{ name: 'text1', type: 'input-text', label: '文本1' }, { name: 'text2', type: 'input-text', label: '文本2' }] }) }); } }, { title: 'sm', body: function (onEdit) { return React__default.createElement(ThemeFieldSetCommon, { activeId: props.activeId, onEdit: onEdit, title: "sm", edit: { title: 'sm配置', path: 'component.fieldSet.size.sm.body', body: getSchemaTpl('normal', [{ type: 'amis-theme-wrapper', label: false, title: i18n("e8ed49e9fde0bb778e2185876c2d2697"), body: [{ mode: 'default', type: 'amis-theme-padding-and-margin', name: 'padding-and-margin', hideMargin: true, source: '${sizesOptions}' }] }, { type: 'amis-theme-wrapper', label: false, title: i18n("9c07532d0c9acfecfc4ec2eb265c3e03"), body: [{ type: 'amis-theme-select', name: 'fontSize', label: i18n("fc55aff8c7e01416e93ac218d98b3b74"), extraUnit: ['px'], options: '${fontSizeOptions}' }] }]) }, body: render({ type: 'fieldSet', title: '基本配置', size: 'sm', body: [{ name: 'text1', type: 'input-text', label: '文本1' }, { name: 'text2', type: 'input-text', label: '文本2' }] }) }); } }, { title: 'base', body: function (onEdit) { return React__default.createElement(ThemeFieldSetCommon, { activeId: props.activeId, onEdit: onEdit, title: "base", edit: { title: 'base配置', path: 'component.fieldSet.size.base.body', body: getSchemaTpl('normal', [{ type: 'amis-theme-wrapper', label: false, title: i18n("e8ed49e9fde0bb778e2185876c2d2697"), body: [{ mode: 'default', type: 'amis-theme-padding-and-margin', name: 'padding-and-margin', hideMargin: true, source: '${sizesOptions}' }] }, { type: 'amis-theme-wrapper', label: false, title: i18n("9c07532d0c9acfecfc4ec2eb265c3e03"), body: [{ type: 'amis-theme-select', name: 'fontSize', label: i18n("fc55aff8c7e01416e93ac218d98b3b74"), extraUnit: ['px'], options: '${fontSizeOptions}' }] }]) }, body: render({ type: 'fieldSet', title: '基本配置', size: 'base', body: [{ name: 'text1', type: 'input-text', label: '文本1' }, { name: 'text2', type: 'input-text', label: '文本2' }] }) }); } }, { title: 'md', body: function (onEdit) { return React__default.createElement(ThemeFieldSetCommon, { activeId: props.activeId, onEdit: onEdit, title: "md", edit: { title: 'md配置', path: 'component.fieldSet.size.md.body', body: getSchemaTpl('normal', [{ type: 'amis-theme-wrapper', label: false, title: i18n("e8ed49e9fde0bb778e2185876c2d2697"), body: [{ mode: 'default', type: 'amis-theme-padding-and-margin', name: 'padding-and-margin', hideMargin: true, source: '${sizesOptions}' }] }, { type: 'amis-theme-wrapper', label: false, title: i18n("9c07532d0c9acfecfc4ec2eb265c3e03"), body: [{ type: 'amis-theme-select', name: 'fontSize', label: i18n("fc55aff8c7e01416e93ac218d98b3b74"), extraUnit: ['px'], options: '${fontSizeOptions}' }] }]) }, body: render({ type: 'fieldSet', title: '基本配置', size: 'md', body: [{ name: 'text1', type: 'input-text', label: '文本1' }, { name: 'text2', type: 'input-text', label: '文本2' }] }) }); } }, { title: 'lg', body: function (onEdit) { return React__default.createElement(ThemeFieldSetCommon, { activeId: props.activeId, onEdit: onEdit, title: "lg", edit: { title: 'lg配置', path: 'component.fieldSet.size.lg.body', body: getSchemaTpl('normal', [{ type: 'amis-theme-wrapper', label: false, title: i18n("e8ed49e9fde0bb778e2185876c2d2697"), body: [{ mode: 'default', type: 'amis-theme-padding-and-margin', name: 'padding-and-margin', hideMargin: true, source: '${sizesOptions}' }] }, { type: 'amis-theme-wrapper', label: false, title: i18n("9c07532d0c9acfecfc4ec2eb265c3e03"), body: [{ type: 'amis-theme-select', name: 'fontSize', label: i18n("fc55aff8c7e01416e93ac218d98b3b74"), extraUnit: ['px'], options: '${fontSizeOptions}' }] }]) }, body: render({ type: 'fieldSet', title: '基本配置', size: 'lg', body: [{ name: 'text1', type: 'input-text', label: '文本1' }, { name: 'text2', type: 'input-text', label: '文本2' }] }) }); } }] }] }; }; registerComponent('fieldSet', { type: 'data-entry', label: '表单项集合', key: 'fieldSet', component: function () { return ThemeFieldSet; } });