mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-06 10:27:22 +00:00
Merge branch 'release/1.0.0' of gitlab.alibaba-inc.com:ali-lowcode/ali-lowcode-engine into release/1.0.0
This commit is contained in:
commit
2e6ff618a6
@ -3831,38 +3831,24 @@
|
|||||||
"subName": ""
|
"subName": ""
|
||||||
},
|
},
|
||||||
"props": [
|
"props": [
|
||||||
{
|
|
||||||
"name": "prefix",
|
|
||||||
"propType": "string",
|
|
||||||
"description": "样式前缀",
|
|
||||||
"defaultValue": "next-"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "style",
|
|
||||||
"propType": "object",
|
|
||||||
"description": "组件接受行内样式"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "dataSource",
|
"name": "dataSource",
|
||||||
"propType": {
|
"propType": "Json",
|
||||||
"type": "instanceOf",
|
|
||||||
"value": "array"
|
|
||||||
},
|
|
||||||
"description": "使用数据模型构建"
|
"description": "使用数据模型构建"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "defaultExpandedKeys",
|
"name": "defaultExpandedKeys",
|
||||||
"propType": {
|
"propType": {
|
||||||
"type": "instanceOf",
|
"type": "arrayOf",
|
||||||
"value": "array"
|
"value": "string"
|
||||||
},
|
},
|
||||||
"description": "默认展开keys"
|
"description": "默认展开keys"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "expandedKeys",
|
"name": "expandedKeys",
|
||||||
"propType": {
|
"propType": {
|
||||||
"type": "instanceOf",
|
"type": "arrayOf",
|
||||||
"value": "array"
|
"value": "string"
|
||||||
},
|
},
|
||||||
"description": "受控展开keys"
|
"description": "受控展开keys"
|
||||||
},
|
},
|
||||||
@ -3881,32 +3867,31 @@
|
|||||||
"propType": "string",
|
"propType": "string",
|
||||||
"description": "扩展class"
|
"description": "扩展class"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "style",
|
||||||
|
"propType": "object",
|
||||||
|
"description": "组件接受行内样式"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "accordion",
|
"name": "accordion",
|
||||||
"propType": "bool",
|
"propType": "bool",
|
||||||
"description": "手风琴模式,一次只能打开一个",
|
"description": "手风琴模式,一次只能打开一个",
|
||||||
"defaultValue": false
|
"defaultValue": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "children",
|
|
||||||
"propType": {
|
|
||||||
"type": "instanceOf",
|
|
||||||
"value": "node"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "id",
|
|
||||||
"propType": "string"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "rtl",
|
"name": "rtl",
|
||||||
"propType": "bool"
|
"propType": "bool"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"configure": {
|
||||||
|
"component": {
|
||||||
|
"isContainer": true
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"componentName": "Panel",
|
"componentName": "Collapse.Panel",
|
||||||
"title": "Panel",
|
"title": "Collapse.Panel",
|
||||||
"docUrl": "",
|
"docUrl": "",
|
||||||
"screenshot": "",
|
"screenshot": "",
|
||||||
"npm": {
|
"npm": {
|
||||||
@ -3919,25 +3904,14 @@
|
|||||||
},
|
},
|
||||||
"props": [
|
"props": [
|
||||||
{
|
{
|
||||||
"name": "prefix",
|
"name": "children",
|
||||||
"propType": "string",
|
"propType": "any"
|
||||||
"description": "样式类名的品牌前缀",
|
|
||||||
"defaultValue": "next-"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "style",
|
"name": "style",
|
||||||
"propType": "object",
|
"propType": "object",
|
||||||
"description": "子组件接受行内样式"
|
"description": "子组件接受行内样式"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "children",
|
|
||||||
"propType": "any"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "isExpanded",
|
|
||||||
"propType": "bool",
|
|
||||||
"defaultValue": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "disabled",
|
"name": "disabled",
|
||||||
"propType": "bool",
|
"propType": "bool",
|
||||||
@ -3950,21 +3924,15 @@
|
|||||||
"value": "node"
|
"value": "node"
|
||||||
},
|
},
|
||||||
"description": "标题"
|
"description": "标题"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "className",
|
|
||||||
"propType": "string",
|
|
||||||
"description": "扩展class"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "onClick",
|
|
||||||
"propType": "func"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "id",
|
|
||||||
"propType": "string"
|
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"configure": {
|
||||||
|
"component": {
|
||||||
|
"nestingRule": {
|
||||||
|
"parentWhitelist": ["Collapse"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"componentName": "ErrorBoundary",
|
"componentName": "ErrorBoundary",
|
||||||
@ -14073,10 +14041,8 @@
|
|||||||
"prefix": "next-"
|
"prefix": "next-"
|
||||||
},
|
},
|
||||||
"children": [{
|
"children": [{
|
||||||
"componentName": "Panel",
|
"componentName": "Collapse.Panel",
|
||||||
"props": {
|
"props": {
|
||||||
"prefix": "next-",
|
|
||||||
"isExpanded": true,
|
|
||||||
"title": "面板标题"
|
"title": "面板标题"
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
@ -14084,6 +14050,26 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"componentName": "Collapse.Panel",
|
||||||
|
"title": "折叠面板Panel",
|
||||||
|
"icon": "",
|
||||||
|
"package": "@alifd/next",
|
||||||
|
"library": "Next",
|
||||||
|
"snippets": [
|
||||||
|
{
|
||||||
|
"title": "折叠面板Panel",
|
||||||
|
"screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_collapse.png",
|
||||||
|
"schema": {
|
||||||
|
"componentName": "Collapse.Panel",
|
||||||
|
"props": {
|
||||||
|
"prefix": "next-",
|
||||||
|
"title": "面板标题"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"componentName": "List",
|
"componentName": "List",
|
||||||
"title": "列表",
|
"title": "列表",
|
||||||
|
|||||||
@ -18,6 +18,8 @@ const DEFINITION_EVENT_TYPE = {
|
|||||||
LIFE_CYCLE_EVENT: 'lifeCycleEvent',
|
LIFE_CYCLE_EVENT: 'lifeCycleEvent',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const SETTER_NAME = 'event-setter'
|
||||||
|
|
||||||
export default class EventsSetter extends Component<{
|
export default class EventsSetter extends Component<{
|
||||||
value: any[];
|
value: any[];
|
||||||
onChange: (eventList: any[]) => void;
|
onChange: (eventList: any[]) => void;
|
||||||
@ -61,7 +63,7 @@ export default class EventsSetter extends Component<{
|
|||||||
const {editor} = this.props.field;
|
const {editor} = this.props.field;
|
||||||
this.initEventBtns();
|
this.initEventBtns();
|
||||||
this.initEventList();
|
this.initEventList();
|
||||||
editor.on('event-setter.bindEvent',(relatedEventName)=>{
|
editor.on(`${SETTER_NAME}.bindEvent`,(relatedEventName)=>{
|
||||||
this.bindEvent(relatedEventName);
|
this.bindEvent(relatedEventName);
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -328,7 +330,7 @@ export default class EventsSetter extends Component<{
|
|||||||
openDialog = (bindEventName: String) => {
|
openDialog = (bindEventName: String) => {
|
||||||
const {editor} = this.props.field;
|
const {editor} = this.props.field;
|
||||||
this.bindEventName = bindEventName;
|
this.bindEventName = bindEventName;
|
||||||
editor.emit('eventBindDialog.openDialog',bindEventName);
|
editor.emit('eventBindDialog.openDialog',bindEventName,SETTER_NAME);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
30
packages/editor-setters/src/function-setter/index.scss
Normal file
30
packages/editor-setters/src/function-setter/index.scss
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
.lc-function-setter{
|
||||||
|
|
||||||
|
.function-container{
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.funtion-icon{
|
||||||
|
float: left;
|
||||||
|
width: 25px;
|
||||||
|
height: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.function-name{
|
||||||
|
font-size: 14px;
|
||||||
|
color:#5584FF;
|
||||||
|
margin-left:5px;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.funtion-operate-icon{
|
||||||
|
font-size: 16px;
|
||||||
|
margin-left:5px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
123
packages/editor-setters/src/function-setter/index.tsx
Normal file
123
packages/editor-setters/src/function-setter/index.tsx
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
import React, { PureComponent } from 'react';
|
||||||
|
// import PropTypes from 'prop-types';
|
||||||
|
import { Button, Icon } from '@alifd/next';
|
||||||
|
|
||||||
|
import './index.scss';
|
||||||
|
import { timingSafeEqual } from 'crypto';
|
||||||
|
|
||||||
|
const SETTER_NAME = 'function-setter'
|
||||||
|
|
||||||
|
interface FunctionSetterProps {
|
||||||
|
value: string;
|
||||||
|
type: string;
|
||||||
|
defaultValue: string;
|
||||||
|
placeholder: string;
|
||||||
|
hasClear: boolean;
|
||||||
|
onChange: (icon: string | object) => undefined;
|
||||||
|
icons: string[];
|
||||||
|
}
|
||||||
|
export default class FunctionSetter extends PureComponent<FunctionSetterProps, {}> {
|
||||||
|
static defaultProps = {
|
||||||
|
value: undefined,
|
||||||
|
type: 'string',
|
||||||
|
defaultValue: '',
|
||||||
|
hasClear: true,
|
||||||
|
placeholder: '请点击选择 Icon',
|
||||||
|
onChange: (icon: string | object) => undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
private emitEventName = '';
|
||||||
|
|
||||||
|
state = {
|
||||||
|
firstLoad: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
const { editor } = this.props.field;
|
||||||
|
this.emitEventName = `${SETTER_NAME}-${this.props.field.id}`;
|
||||||
|
editor.on(`${this.emitEventName}.bindEvent`, this.bindEvent)
|
||||||
|
}
|
||||||
|
|
||||||
|
bindEvent = (eventName) => {
|
||||||
|
this.bindEventCallback(eventName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
const { editor } = this.props.field;
|
||||||
|
editor.off(`${this.emitEventName}.bindEvent`, this.bindEvent)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bindFunction = () => {
|
||||||
|
const { field, value } = this.props;
|
||||||
|
field.editor.emit('eventBindDialog.openDialog', field.name, this.emitEventName);
|
||||||
|
}
|
||||||
|
|
||||||
|
removeFunctionBind = () => {
|
||||||
|
const { field ,removeProp} = this.props;
|
||||||
|
removeProp();
|
||||||
|
}
|
||||||
|
|
||||||
|
parseFunctionName = (functionString: String) => {
|
||||||
|
// 因为函数格式是固定的,所以可以按照字符换去匹配获取函数名
|
||||||
|
let funNameStr = functionString.split('.')[1];
|
||||||
|
let endIndex = funNameStr.indexOf('(');
|
||||||
|
|
||||||
|
return funNameStr.substr(0, endIndex);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渲染按钮(初始状态)
|
||||||
|
*/
|
||||||
|
renderButton = () => {
|
||||||
|
return <Button type="primary" onClick={() => this.bindFunction()}>绑定函数</Button>
|
||||||
|
}
|
||||||
|
|
||||||
|
focusFunctionName = (functionName) => {
|
||||||
|
const { editor } = this.props.field;
|
||||||
|
|
||||||
|
editor.get('skeleton').getPanel('sourceEditor').show();
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
editor.emit('sourceEditor.focusByFunction', {
|
||||||
|
functionName
|
||||||
|
})
|
||||||
|
}, 300)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渲染绑定函数
|
||||||
|
*/
|
||||||
|
renderBindFunction = () => {
|
||||||
|
const { value } = this.props;
|
||||||
|
// 解析函数名
|
||||||
|
let functionName = this.parseFunctionName(value.value);
|
||||||
|
// let functionName = 'onClick';
|
||||||
|
return <div className="function-container">
|
||||||
|
<img className="funtion-icon" src="https://gw.alicdn.com/tfs/TB1os6KRFT7gK0jSZFpXXaTkpXa-200-200.png"></img>
|
||||||
|
<span className="function-name" onClick={() => this.focusFunctionName(functionName)}>{functionName}</span>
|
||||||
|
<Icon type="set" size="medium" className="funtion-operate-icon" onClick={this.bindFunction} />
|
||||||
|
<Icon type="ashbin" size="medium" className="funtion-operate-icon" onClick={this.removeFunctionBind} />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bindEventCallback = (eventName: String) => {
|
||||||
|
const { onChange } = this.props;
|
||||||
|
onChange({
|
||||||
|
type: 'JSFunction',
|
||||||
|
value: `function(){ this.${eventName}() }`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { value } = this.props;
|
||||||
|
return <div className="lc-function-setter">
|
||||||
|
{
|
||||||
|
value ? this.renderBindFunction() : this.renderButton()
|
||||||
|
}
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,6 +8,7 @@ import JsonSetter from './json-setter';
|
|||||||
import EventsSetter from './events-setter';
|
import EventsSetter from './events-setter';
|
||||||
import StyleSetter from './style-setter';
|
import StyleSetter from './style-setter';
|
||||||
import IconSetter from './icon-setter';
|
import IconSetter from './icon-setter';
|
||||||
|
import FunctionSetter from './function-setter';
|
||||||
// import MixedSetter from './mixed-setter';
|
// import MixedSetter from './mixed-setter';
|
||||||
|
|
||||||
export const StringSetter = {
|
export const StringSetter = {
|
||||||
@ -109,6 +110,7 @@ const builtinSetters: any = {
|
|||||||
JsonSetter,
|
JsonSetter,
|
||||||
StyleSetter,
|
StyleSetter,
|
||||||
IconSetter,
|
IconSetter,
|
||||||
|
FunctionSetter
|
||||||
};
|
};
|
||||||
|
|
||||||
registerSetter(builtinSetters);
|
registerSetter(builtinSetters);
|
||||||
|
|||||||
@ -142,6 +142,10 @@ class SettingFieldView extends Component<{ field: SettingField }> {
|
|||||||
});
|
});
|
||||||
field.setValue(value);
|
field.setValue(value);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
removeProp:()=>{
|
||||||
|
field.parent.clearPropValue(field.name);
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
extraProps.forceInline ? 'plain' : extraProps.display,
|
extraProps.forceInline ? 'plain' : extraProps.display,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -24,6 +24,7 @@ export default class EventBindDialog extends Component<PluginProps> {
|
|||||||
|
|
||||||
state: any = {
|
state: any = {
|
||||||
visiable: false,
|
visiable: false,
|
||||||
|
setterName:'event-setter',
|
||||||
selectedEventName: '',
|
selectedEventName: '',
|
||||||
eventName: '',
|
eventName: '',
|
||||||
};
|
};
|
||||||
@ -46,8 +47,11 @@ export default class EventBindDialog extends Component<PluginProps> {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { editor, config } = this.props;
|
const { editor, config } = this.props;
|
||||||
editor.on(`${config.pluginKey}.openDialog`, (bindEventName: String) => {
|
editor.on(`${config.pluginKey}.openDialog`, (bindEventName: String,setterName:String) => {
|
||||||
this.openDialog(bindEventName);
|
this.openDialog(bindEventName);
|
||||||
|
this.setState({
|
||||||
|
setterName
|
||||||
|
})
|
||||||
|
|
||||||
let schema = editor.get('designer').project.getSchema();
|
let schema = editor.get('designer').project.getSchema();
|
||||||
let pageNode = schema.componentsTree[0];
|
let pageNode = schema.componentsTree[0];
|
||||||
@ -102,7 +106,10 @@ export default class EventBindDialog extends Component<PluginProps> {
|
|||||||
|
|
||||||
onOk = () => {
|
onOk = () => {
|
||||||
const { editor } = this.props;
|
const { editor } = this.props;
|
||||||
editor.emit('event-setter.bindEvent', this.state.eventName);
|
const {setterName,eventName} = this.state;
|
||||||
|
|
||||||
|
editor.emit(`${setterName}.bindEvent`, eventName);
|
||||||
|
|
||||||
// 选中的是新建事件
|
// 选中的是新建事件
|
||||||
if (this.state.selectedEventName == '') {
|
if (this.state.selectedEventName == '') {
|
||||||
// 判断面板是否处于激活状态
|
// 判断面板是否处于激活状态
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user