mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-14 13:03:07 +00:00
add events definition
This commit is contained in:
parent
59b9925665
commit
176a708f75
@ -23,7 +23,7 @@ export default class PropStash implements IPropParent {
|
|||||||
}
|
}
|
||||||
const pending: Prop[] = [];
|
const pending: Prop[] = [];
|
||||||
for (const prop of this.space) {
|
for (const prop of this.space) {
|
||||||
if (!prop.isUnset()) {
|
if (!prop.isUnset() && !prop.isVirtual()) {
|
||||||
this.space.delete(prop);
|
this.space.delete(prop);
|
||||||
pending.push(prop);
|
pending.push(prop);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -225,6 +225,10 @@ export default class Prop implements IPropParent {
|
|||||||
return this._type === 'unset';
|
return this._type === 'unset';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isVirtual() {
|
||||||
|
return typeof this.key === 'string' && this.key.charAt(0) === '!';
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: improve this logic
|
// TODO: improve this logic
|
||||||
compare(other: Prop | null): number {
|
compare(other: Prop | null): number {
|
||||||
if (!other || other.isUnset()) {
|
if (!other || other.isUnset()) {
|
||||||
|
|||||||
@ -21,7 +21,8 @@ const DEFINITION_EVENT_TYPE = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default class EventsSetter extends Component<{
|
export default class EventsSetter extends Component<{
|
||||||
field:SettingField
|
value: any[];
|
||||||
|
onChange: (eventList: any[]) => void;
|
||||||
}> {
|
}> {
|
||||||
state = {
|
state = {
|
||||||
showEventList: false,
|
showEventList: false,
|
||||||
@ -37,9 +38,6 @@ export default class EventsSetter extends Component<{
|
|||||||
};
|
};
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
// this.props.field.getValue()
|
|
||||||
console.log(this.props);
|
|
||||||
|
|
||||||
this.initEventBtns();
|
this.initEventBtns();
|
||||||
this.initEventList();
|
this.initEventList();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -159,7 +159,7 @@ export interface FieldConfig extends FieldExtraProps {
|
|||||||
export class SettingField implements SettingTarget {
|
export class SettingField implements SettingTarget {
|
||||||
readonly isSettingField = true;
|
readonly isSettingField = true;
|
||||||
readonly id = uniqueId('field');
|
readonly id = uniqueId('field');
|
||||||
readonly type: 'field' | 'virtual-field' | 'group';
|
readonly type: 'field' | 'group';
|
||||||
readonly isRequired: boolean = false;
|
readonly isRequired: boolean = false;
|
||||||
readonly isGroup: boolean;
|
readonly isGroup: boolean;
|
||||||
private _name: string | number;
|
private _name: string | number;
|
||||||
@ -193,8 +193,6 @@ export class SettingField implements SettingTarget {
|
|||||||
const c = typeof name === 'string' ? name.substr(0, 1) : '';
|
const c = typeof name === 'string' ? name.substr(0, 1) : '';
|
||||||
if (c === '#') {
|
if (c === '#') {
|
||||||
this.type = 'group';
|
this.type = 'group';
|
||||||
} else if (c === '!') {
|
|
||||||
this.type = 'virtual-field';
|
|
||||||
} else {
|
} else {
|
||||||
this.type = 'field';
|
this.type = 'field';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -310,55 +310,38 @@ registerMetadataTransducer(metadata => {
|
|||||||
if (componentName === 'Page' || componentName === 'Component') {
|
if (componentName === 'Page' || componentName === 'Component') {
|
||||||
isRoot = true;
|
isRoot = true;
|
||||||
// 平台配置的,一般只有根节点才会配置
|
// 平台配置的,一般只有根节点才会配置
|
||||||
eventsDefinition = [{
|
eventsDefinition = [
|
||||||
type: 'lifeCycleEvent',
|
{
|
||||||
title: '生命周期',
|
type: 'lifeCycleEvent',
|
||||||
list: [
|
title: '生命周期',
|
||||||
{
|
list: [
|
||||||
description: '初始化时',
|
{
|
||||||
name: 'constructor',
|
description: '初始化时',
|
||||||
},
|
name: 'constructor',
|
||||||
{
|
},
|
||||||
description: '装载后',
|
{
|
||||||
name: 'componentDidMount',
|
description: '装载后',
|
||||||
},
|
name: 'componentDidMount',
|
||||||
{
|
},
|
||||||
description: '更新时',
|
{
|
||||||
name: 'componentDidMount',
|
description: '更新时',
|
||||||
},
|
name: 'componentDidMount',
|
||||||
{
|
},
|
||||||
description: '卸载时',
|
{
|
||||||
name: 'componentWillUnmount',
|
description: '卸载时',
|
||||||
},
|
name: 'componentWillUnmount',
|
||||||
]
|
},
|
||||||
}];
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
} else {
|
} else {
|
||||||
eventsDefinition = [{
|
eventsDefinition = [
|
||||||
type: 'events',
|
{
|
||||||
title: '事件',
|
type: 'events',
|
||||||
list: (events?.supportEvents || []).map((event: any) => {
|
title: '事件',
|
||||||
return typeof event === 'string'
|
list: (events?.supportEvents || []).map((event: any) => (typeof event === 'string' ? { name: event } : event)),
|
||||||
? {
|
},
|
||||||
name: event,
|
];
|
||||||
}
|
|
||||||
: event;
|
|
||||||
}),
|
|
||||||
|
|
||||||
// mock data
|
|
||||||
list:[
|
|
||||||
{
|
|
||||||
name:'onClick',
|
|
||||||
description:'点击回调'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'onChange',
|
|
||||||
description:'变更回调'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'onSubmit'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}];
|
|
||||||
}
|
}
|
||||||
// 通用设置
|
// 通用设置
|
||||||
const propsGroup = props || [];
|
const propsGroup = props || [];
|
||||||
@ -439,8 +422,9 @@ registerMetadataTransducer(metadata => {
|
|||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
setValue(field: SettingField, eventDataList: any[]) {
|
setValue(field: SettingField, eventDataList: any[]) {
|
||||||
field.setPropValue('eventDataList', eventDataList);
|
console.info(eventDataList);
|
||||||
}
|
field.setPropValue('eventDataList', eventDataList);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user