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[] = [];
|
||||
for (const prop of this.space) {
|
||||
if (!prop.isUnset()) {
|
||||
if (!prop.isUnset() && !prop.isVirtual()) {
|
||||
this.space.delete(prop);
|
||||
pending.push(prop);
|
||||
}
|
||||
|
||||
@ -225,6 +225,10 @@ export default class Prop implements IPropParent {
|
||||
return this._type === 'unset';
|
||||
}
|
||||
|
||||
isVirtual() {
|
||||
return typeof this.key === 'string' && this.key.charAt(0) === '!';
|
||||
}
|
||||
|
||||
// TODO: improve this logic
|
||||
compare(other: Prop | null): number {
|
||||
if (!other || other.isUnset()) {
|
||||
|
||||
@ -21,7 +21,8 @@ const DEFINITION_EVENT_TYPE = {
|
||||
};
|
||||
|
||||
export default class EventsSetter extends Component<{
|
||||
field:SettingField
|
||||
value: any[];
|
||||
onChange: (eventList: any[]) => void;
|
||||
}> {
|
||||
state = {
|
||||
showEventList: false,
|
||||
@ -37,9 +38,6 @@ export default class EventsSetter extends Component<{
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
// this.props.field.getValue()
|
||||
console.log(this.props);
|
||||
|
||||
this.initEventBtns();
|
||||
this.initEventList();
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ export interface FieldConfig extends FieldExtraProps {
|
||||
export class SettingField implements SettingTarget {
|
||||
readonly isSettingField = true;
|
||||
readonly id = uniqueId('field');
|
||||
readonly type: 'field' | 'virtual-field' | 'group';
|
||||
readonly type: 'field' | 'group';
|
||||
readonly isRequired: boolean = false;
|
||||
readonly isGroup: boolean;
|
||||
private _name: string | number;
|
||||
@ -193,8 +193,6 @@ export class SettingField implements SettingTarget {
|
||||
const c = typeof name === 'string' ? name.substr(0, 1) : '';
|
||||
if (c === '#') {
|
||||
this.type = 'group';
|
||||
} else if (c === '!') {
|
||||
this.type = 'virtual-field';
|
||||
} else {
|
||||
this.type = 'field';
|
||||
}
|
||||
|
||||
@ -310,55 +310,38 @@ registerMetadataTransducer(metadata => {
|
||||
if (componentName === 'Page' || componentName === 'Component') {
|
||||
isRoot = true;
|
||||
// 平台配置的,一般只有根节点才会配置
|
||||
eventsDefinition = [{
|
||||
type: 'lifeCycleEvent',
|
||||
title: '生命周期',
|
||||
list: [
|
||||
{
|
||||
description: '初始化时',
|
||||
name: 'constructor',
|
||||
},
|
||||
{
|
||||
description: '装载后',
|
||||
name: 'componentDidMount',
|
||||
},
|
||||
{
|
||||
description: '更新时',
|
||||
name: 'componentDidMount',
|
||||
},
|
||||
{
|
||||
description: '卸载时',
|
||||
name: 'componentWillUnmount',
|
||||
},
|
||||
]
|
||||
}];
|
||||
eventsDefinition = [
|
||||
{
|
||||
type: 'lifeCycleEvent',
|
||||
title: '生命周期',
|
||||
list: [
|
||||
{
|
||||
description: '初始化时',
|
||||
name: 'constructor',
|
||||
},
|
||||
{
|
||||
description: '装载后',
|
||||
name: 'componentDidMount',
|
||||
},
|
||||
{
|
||||
description: '更新时',
|
||||
name: 'componentDidMount',
|
||||
},
|
||||
{
|
||||
description: '卸载时',
|
||||
name: 'componentWillUnmount',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
} else {
|
||||
eventsDefinition = [{
|
||||
type: 'events',
|
||||
title: '事件',
|
||||
list: (events?.supportEvents || []).map((event: any) => {
|
||||
return typeof event === 'string'
|
||||
? {
|
||||
name: event,
|
||||
}
|
||||
: event;
|
||||
}),
|
||||
|
||||
// mock data
|
||||
list:[
|
||||
{
|
||||
name:'onClick',
|
||||
description:'点击回调'
|
||||
},
|
||||
{
|
||||
name:'onChange',
|
||||
description:'变更回调'
|
||||
},
|
||||
{
|
||||
name:'onSubmit'
|
||||
}
|
||||
]
|
||||
}];
|
||||
eventsDefinition = [
|
||||
{
|
||||
type: 'events',
|
||||
title: '事件',
|
||||
list: (events?.supportEvents || []).map((event: any) => (typeof event === 'string' ? { name: event } : event)),
|
||||
},
|
||||
];
|
||||
}
|
||||
// 通用设置
|
||||
const propsGroup = props || [];
|
||||
@ -439,8 +422,9 @@ registerMetadataTransducer(metadata => {
|
||||
return data;
|
||||
},
|
||||
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