mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-15 18:58:11 +00:00
chore: fix conflicts
This commit is contained in:
commit
e47f0e1cd1
@ -1,8 +1,5 @@
|
|||||||
{
|
{
|
||||||
"plugins": [
|
"plugins": [
|
||||||
[
|
|
||||||
"build-plugin-component"
|
"build-plugin-component"
|
||||||
],
|
|
||||||
"./build.plugin.js"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +0,0 @@
|
|||||||
module.exports = ({ onGetJestConfig }) => {
|
|
||||||
// console.log('== test ==');
|
|
||||||
onGetJestConfig((jestConfig) => {
|
|
||||||
// console.log(jestConfig);
|
|
||||||
return jestConfig;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
5
packages/designer/build.test.json
Normal file
5
packages/designer/build.test.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"@ali/lowcode-test-mate/plugin/index.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -22,6 +22,7 @@ import { TransformStage } from './transform-stage';
|
|||||||
import { ReactElement } from 'react';
|
import { ReactElement } from 'react';
|
||||||
import { SettingTopEntry } from 'designer/src/designer';
|
import { SettingTopEntry } from 'designer/src/designer';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
|
import { includeSlot, removeSlot } from '../../utils/slot';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基础节点
|
* 基础节点
|
||||||
@ -709,6 +710,11 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
|
|
||||||
addSlot(slotNode: Node) {
|
addSlot(slotNode: Node) {
|
||||||
slotNode.internalSetParent(this as ParentalNode, true);
|
slotNode.internalSetParent(this as ParentalNode, true);
|
||||||
|
const slotName = slotNode?.getExtraProp('name')?.getAsString();
|
||||||
|
// 一个组件下的所有 slot,相同 slotName 的 slot 应该是唯一的
|
||||||
|
if (includeSlot(this, slotName)) {
|
||||||
|
removeSlot(this, slotName);
|
||||||
|
}
|
||||||
this._slots.push(slotNode);
|
this._slots.push(slotNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import { valueToSource } from './value-to-source';
|
|||||||
import { Props } from './props';
|
import { Props } from './props';
|
||||||
import { SlotNode, Node } from '../node';
|
import { SlotNode, Node } from '../node';
|
||||||
import { TransformStage } from '../transform-stage';
|
import { TransformStage } from '../transform-stage';
|
||||||
import { includesSlot } from '../../../utils/slot';
|
|
||||||
|
|
||||||
export const UNSET = Symbol.for('unset');
|
export const UNSET = Symbol.for('unset');
|
||||||
export type UNSET = typeof UNSET;
|
export type UNSET = typeof UNSET;
|
||||||
@ -118,7 +117,7 @@ export class Prop implements IPropParent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'slot') {
|
if (type === 'slot') {
|
||||||
const schema = this._slotNode!.export(stage);
|
const schema = this._slotNode?.export(stage) || {};
|
||||||
if (stage === TransformStage.Render) {
|
if (stage === TransformStage.Render) {
|
||||||
return {
|
return {
|
||||||
type: 'JSSlot',
|
type: 'JSSlot',
|
||||||
@ -294,12 +293,10 @@ export class Prop implements IPropParent {
|
|||||||
this._slotNode.import(slotSchema);
|
this._slotNode.import(slotSchema);
|
||||||
} else {
|
} else {
|
||||||
const { owner } = this.props;
|
const { owner } = this.props;
|
||||||
if (!includesSlot(owner, data.name)) {
|
|
||||||
this._slotNode = owner.document.createNode<SlotNode>(slotSchema);
|
this._slotNode = owner.document.createNode<SlotNode>(slotSchema);
|
||||||
owner.addSlot(this._slotNode);
|
owner.addSlot(this._slotNode);
|
||||||
this._slotNode.internalSetSlotFor(this);
|
this._slotNode.internalSetSlotFor(this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,19 @@
|
|||||||
import { Node } from '../document/node/node';
|
import { Node } from '../document/node/node';
|
||||||
|
|
||||||
export function includesSlot(node: Node, slotName: string | undefined): boolean {
|
export function includeSlot(node: Node, slotName: string | undefined): boolean {
|
||||||
const { slots = [] } = node;
|
const { slots = [] } = node;
|
||||||
return slots.some(slot => {
|
return slots.some(slot => {
|
||||||
return slotName && slotName === slot?.getExtraProp('name')?.getAsString();
|
return slotName && slotName === slot?.getExtraProp('name')?.getAsString();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function removeSlot(node: Node, slotName: string | undefined): boolean {
|
||||||
|
const { slots = [] } = node;
|
||||||
|
return slots.some((slot, idx) => {
|
||||||
|
if (slotName && slotName === slot?.getExtraProp('name')?.getAsString()) {
|
||||||
|
slots.splice(idx, 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ jest.mock('../../src/designer/designer', () => {
|
|||||||
|
|
||||||
let designer = null;
|
let designer = null;
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
designer = new Designer({} as any);
|
designer = new Designer({});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('schema 生成节点模型测试', () => {
|
describe('schema 生成节点模型测试', () => {
|
||||||
|
|||||||
@ -1,28 +1 @@
|
|||||||
export function getIdsFromSchema(schema, ids = []) {
|
export { getIdsFromSchema, getNodeFromSchemaById } from '@ali/lowcode-test-mate/es/utils';
|
||||||
if (!schema) return ids;
|
|
||||||
const { componentName, id, children } = schema;
|
|
||||||
if (componentName) {
|
|
||||||
ids.push(id);
|
|
||||||
}
|
|
||||||
if (Array.isArray(children) && children.length > 0) {
|
|
||||||
children.forEach(node => getIdsFromSchema(node, ids));
|
|
||||||
}
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getNodeFromSchemaById(schema, _id) {
|
|
||||||
if (!schema) return null;
|
|
||||||
const { id, children } = schema;
|
|
||||||
let retNode = null;
|
|
||||||
if (_id === id) return schema;
|
|
||||||
if (Array.isArray(children) && children.length > 0) {
|
|
||||||
children.some(node => {
|
|
||||||
retNode = getNodeFromSchemaById(node, _id);
|
|
||||||
if (retNode) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return retNode;
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user