mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-20 07:14:23 +00:00
1. 修复 BoolSetter 不响应 value 的bug;
2. setter 支持配置 extraProps; 3. button 支持 icon 配置;
This commit is contained in:
parent
a66c0b1ea7
commit
a600cf4b37
@ -1440,6 +1440,11 @@
|
|||||||
"title": "内容",
|
"title": "内容",
|
||||||
"propType": "string"
|
"propType": "string"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "icon",
|
||||||
|
"propType": "string",
|
||||||
|
"description": "自定义内联样式"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "type",
|
"name": "type",
|
||||||
"title": "类型",
|
"title": "类型",
|
||||||
@ -1489,13 +1494,14 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "loading",
|
"name": "loading",
|
||||||
"title": "是否 loading",
|
"title": "loading",
|
||||||
"propType": "bool",
|
"propType": "bool",
|
||||||
"description": "设置按钮的载入状态",
|
"description": "设置按钮的载入状态",
|
||||||
"defaultValue": false
|
"defaultValue": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ghost",
|
"name": "ghost",
|
||||||
|
"title": "ghost",
|
||||||
"propType": {
|
"propType": {
|
||||||
"type": "oneOf",
|
"type": "oneOf",
|
||||||
"value": [
|
"value": [
|
||||||
@ -1510,18 +1516,21 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "text",
|
"name": "text",
|
||||||
|
"title": "text",
|
||||||
"propType": "bool",
|
"propType": "bool",
|
||||||
"description": "是否为文本按钮",
|
"description": "是否为文本按钮",
|
||||||
"defaultValue": false
|
"defaultValue": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "warning",
|
"name": "warning",
|
||||||
|
"title": "warning",
|
||||||
"propType": "bool",
|
"propType": "bool",
|
||||||
"description": "是否为警告按钮",
|
"description": "是否为警告按钮",
|
||||||
"defaultValue": false
|
"defaultValue": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "disabled",
|
"name": "disabled",
|
||||||
|
"title": "disabled",
|
||||||
"propType": "bool",
|
"propType": "bool",
|
||||||
"description": "是否禁用",
|
"description": "是否禁用",
|
||||||
"defaultValue": false
|
"defaultValue": false
|
||||||
@ -1550,37 +1559,29 @@
|
|||||||
"props": {
|
"props": {
|
||||||
"isExtends": true,
|
"isExtends": true,
|
||||||
"override": [
|
"override": [
|
||||||
|
{
|
||||||
|
"name": "icon",
|
||||||
|
"setter": "StringSetter",
|
||||||
|
"extraProps": {
|
||||||
|
"defaultValue": "success",
|
||||||
|
"onChange": {
|
||||||
|
"type": "JSFunction",
|
||||||
|
"value": "(val, field, editor) => {\n field.nodes[0].children.import({\"componentName\": \"Icon\", \"props\": {\"type\": val, \"style\": {\"marginRight\": 5}}}, true); //field.top.setPropValue('children', [{\"componentName\": \"Icon\", \"props\": {\"type\": val}}, (field.top.getPropValue('children') || []).slice(-1)]);\n}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "children",
|
"name": "children",
|
||||||
"setter": {
|
"setter": {
|
||||||
"componentName": "ArraySetter",
|
|
||||||
"props": {
|
|
||||||
"itemSetter": {
|
|
||||||
"componentName": "MixedSetter",
|
"componentName": "MixedSetter",
|
||||||
"props": {
|
"props": {
|
||||||
"setters": [
|
"setters": [
|
||||||
{
|
|
||||||
"componentName": "SlotSetter",
|
|
||||||
"initialValue": {
|
|
||||||
"type": "JSSlot",
|
|
||||||
"value": [
|
|
||||||
{
|
|
||||||
"componentName": "Icon",
|
|
||||||
"props": {
|
|
||||||
"type": "smile"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"StringSetter",
|
"StringSetter",
|
||||||
"ExpressionSetter"
|
"ExpressionSetter"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -11807,7 +11808,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"componentName": "Typography.Text",
|
"componentName": "Typography.Text",
|
||||||
"title": "Typography.Text",
|
"title": "Text",
|
||||||
"docUrl": "",
|
"docUrl": "",
|
||||||
"screenshot": "",
|
"screenshot": "",
|
||||||
"npm": {
|
"npm": {
|
||||||
@ -11820,9 +11821,8 @@
|
|||||||
},
|
},
|
||||||
"props": [
|
"props": [
|
||||||
{
|
{
|
||||||
"name": "prefix",
|
"name": "children",
|
||||||
"propType": "string",
|
"propType": "string"
|
||||||
"defaultValue": "next-"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "delete",
|
"name": "delete",
|
||||||
@ -11857,29 +11857,32 @@
|
|||||||
{
|
{
|
||||||
"name": "component",
|
"name": "component",
|
||||||
"propType": {
|
"propType": {
|
||||||
"type": "instanceOf",
|
"type": "oneOf",
|
||||||
"value": "elementType"
|
"value": [
|
||||||
|
"span",
|
||||||
|
"H1",
|
||||||
|
"H2",
|
||||||
|
"H3",
|
||||||
|
"H4"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"description": "设置标签类型",
|
"description": "设置标签类型",
|
||||||
"defaultValue": "span"
|
"defaultValue": "span"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "children",
|
|
||||||
"propType": "string"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "rtl",
|
|
||||||
"propType": "bool",
|
|
||||||
"defaultValue": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "style",
|
"name": "style",
|
||||||
"propType": "object"
|
"propType": "object"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"configure": {
|
"configure": {
|
||||||
"component": {
|
"props": {
|
||||||
"isContainer": true
|
"isExtends": true,
|
||||||
|
"override": [
|
||||||
|
{
|
||||||
|
"name": "children",
|
||||||
|
"setter": "TextAreaSetter"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -13735,16 +13738,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"componentName": "Typography",
|
"componentName": "Typography",
|
||||||
"title": "排版",
|
"title": "Text",
|
||||||
"icon": "",
|
"icon": "",
|
||||||
"package": "@alife/next",
|
"package": "@alife/next",
|
||||||
"library": "Next",
|
"library": "Next",
|
||||||
"snippets": [
|
"snippets": [
|
||||||
{
|
{
|
||||||
"title": "排版",
|
"title": "Text",
|
||||||
"screenshot": "",
|
"screenshot": "",
|
||||||
"schema": {
|
"schema": {
|
||||||
"componentName": "Typography",
|
"componentName": "Typography.Text",
|
||||||
"props": {
|
"props": {
|
||||||
"component": "span",
|
"component": "span",
|
||||||
"children": "基于 Ali-Lowcode-Engine 快速打造高生产力的低代码研发平台"
|
"children": "基于 Ali-Lowcode-Engine 快速打造高生产力的低代码研发平台"
|
||||||
|
|||||||
@ -9,12 +9,22 @@ import StyleSetter from './style-setter';
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
export const StringSetter = {
|
export const StringSetter = {
|
||||||
component: Input,
|
component: Input,
|
||||||
defaultProps: { placeholder: '请输入' },
|
defaultProps: { placeholder: '请输入', style: { maxWidth: 180 } },
|
||||||
title: 'StringSetter',
|
title: 'StringSetter',
|
||||||
recommend: true,
|
recommend: true,
|
||||||
};
|
};
|
||||||
export const NumberSetter = NumberPicker;
|
export const NumberSetter = NumberPicker;
|
||||||
export const BoolSetter = Switch;
|
export class BoolSetter extends Component {
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { onChange, value, defaultValue } = this.props;
|
||||||
|
return <Switch checked={value || defaultValue} onChange={
|
||||||
|
val => {
|
||||||
|
onChange(val)
|
||||||
|
}
|
||||||
|
}/>;
|
||||||
|
}
|
||||||
|
}
|
||||||
export const SelectSetter = Select;
|
export const SelectSetter = Select;
|
||||||
|
|
||||||
// suggest: 做成 SelectSetter 一种变体
|
// suggest: 做成 SelectSetter 一种变体
|
||||||
@ -25,7 +35,12 @@ export const RadioGroupSetter = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
// suggest: 做成 StringSetter 的一个参数,
|
// suggest: 做成 StringSetter 的一个参数,
|
||||||
export const TextAreaSetter = Input.TextArea;
|
export const TextAreaSetter = {
|
||||||
|
component: Input.TextArea,
|
||||||
|
defaultProps: { placeholder: '请输入', style: { maxWidth: 180 } },
|
||||||
|
title: 'TextAreaSetter',
|
||||||
|
recommend: true,
|
||||||
|
};
|
||||||
export const DateSetter = DatePicker;
|
export const DateSetter = DatePicker;
|
||||||
export const DateYearSetter = DatePicker.YearPicker;
|
export const DateYearSetter = DatePicker.YearPicker;
|
||||||
export const DateMonthSetter = DatePicker.MonthPicker;
|
export const DateMonthSetter = DatePicker.MonthPicker;
|
||||||
@ -36,7 +51,6 @@ export { ExpressionSetter, EventsSetter };
|
|||||||
class StringDateSetter extends Component {
|
class StringDateSetter extends Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
debugger
|
|
||||||
const { onChange, editor } = this.props;
|
const { onChange, editor } = this.props;
|
||||||
return <DatePicker onChange={
|
return <DatePicker onChange={
|
||||||
val => {
|
val => {
|
||||||
@ -48,7 +62,6 @@ class StringDateSetter extends Component {
|
|||||||
class StringTimePicker extends Component {
|
class StringTimePicker extends Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
debugger
|
|
||||||
const { onChange, editor } = this.props;
|
const { onChange, editor } = this.props;
|
||||||
return <TimePicker onChange={
|
return <TimePicker onChange={
|
||||||
val => {
|
val => {
|
||||||
|
|||||||
@ -8,7 +8,10 @@ import { SettingField, isSettingField, SettingTopEntry, SettingEntry } from '@al
|
|||||||
import { isSetterConfig, CustomView } from '@ali/lowcode-types';
|
import { isSetterConfig, CustomView } from '@ali/lowcode-types';
|
||||||
import { intl } from '../../locale';
|
import { intl } from '../../locale';
|
||||||
import { Skeleton } from 'editor-skeleton/src/skeleton';
|
import { Skeleton } from 'editor-skeleton/src/skeleton';
|
||||||
|
function transformStringToFunction(str) {
|
||||||
|
if (typeof str !== 'string') return str;
|
||||||
|
return new Function(`"use strict"; return ${str}`)();
|
||||||
|
}
|
||||||
@observer
|
@observer
|
||||||
class SettingFieldView extends Component<{ field: SettingField }> {
|
class SettingFieldView extends Component<{ field: SettingField }> {
|
||||||
render() {
|
render() {
|
||||||
@ -60,7 +63,10 @@ class SettingFieldView extends Component<{ field: SettingField }> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// todo: error handling
|
// todo: error handling
|
||||||
|
let _onChange = extraProps?.onChange?.value;
|
||||||
|
if (extraProps && extraProps.onChange && extraProps.onChange.type === 'JSFunction') {
|
||||||
|
_onChange = transformStringToFunction(extraProps.onChange.value);
|
||||||
|
}
|
||||||
return createField(
|
return createField(
|
||||||
{
|
{
|
||||||
meta: field?.componentMeta?.npm || field?.componentMeta?.componentName || '',
|
meta: field?.componentMeta?.npm || field?.componentMeta?.componentName || '',
|
||||||
@ -85,6 +91,7 @@ class SettingFieldView extends Component<{ field: SettingField }> {
|
|||||||
value,
|
value,
|
||||||
});
|
});
|
||||||
field.setValue(value);
|
field.setValue(value);
|
||||||
|
if(_onChange) _onChange(value, field);
|
||||||
},
|
},
|
||||||
onInitial: () => {
|
onInitial: () => {
|
||||||
if (initialValue == null) {
|
if (initialValue == null) {
|
||||||
|
|||||||
@ -199,14 +199,13 @@ export default class BaseRender extends PureComponent {
|
|||||||
if (!schema || !schema.props) {
|
if (!schema || !schema.props) {
|
||||||
return schema?.children;
|
return schema?.children;
|
||||||
}
|
}
|
||||||
let _children = schema.children;
|
if (!schema.children) return schema.props.children;
|
||||||
if (!_children) return schema.props.children;
|
if (!schema.props.children) return schema.children;
|
||||||
if (schema.props.children && schema.props.children.length) {
|
var _children = [].concat(schema.children);
|
||||||
if (Array.isArray(schema.props.children)) {
|
if (Array.isArray(schema.props.children)) {
|
||||||
_children = Array.isArray(_children) ? _children.concat(schema.props.children) : schema.props.children.unshift(_children);
|
_children = _children.concat(schema.props.children);
|
||||||
} else {
|
} else {
|
||||||
Array.isArray(_children) && _children.push(schema.props.children) || (_children = [_children] && _children.push(schema.props.children));
|
_children.push(schema.props.children);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return _children;
|
return _children;
|
||||||
};
|
};
|
||||||
@ -233,6 +232,7 @@ export default class BaseRender extends PureComponent {
|
|||||||
if (!schema) return null;
|
if (!schema) return null;
|
||||||
const { __appHelper: appHelper, __components: components = {} } =
|
const { __appHelper: appHelper, __components: components = {} } =
|
||||||
this.props || {};
|
this.props || {};
|
||||||
|
|
||||||
if (isJSExpression(schema)) {
|
if (isJSExpression(schema)) {
|
||||||
return parseExpression(schema, self);
|
return parseExpression(schema, self);
|
||||||
}
|
}
|
||||||
@ -249,7 +249,6 @@ export default class BaseRender extends PureComponent {
|
|||||||
this.__createVirtualDom(item, self, parentInfo, item && item.__ctx && item.__ctx.lunaKey ? '' : idx),
|
this.__createVirtualDom(item, self, parentInfo, item && item.__ctx && item.__ctx.lunaKey ? '' : idx),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
const _children = this.getSchemaChildren(schema);
|
const _children = this.getSchemaChildren(schema);
|
||||||
//解析占位组件
|
//解析占位组件
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user