mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 09:41:57 +00:00
chore: fix conflicts
This commit is contained in:
commit
e47f0e1cd1
@ -1,8 +1,5 @@
|
||||
{
|
||||
"plugins": [
|
||||
[
|
||||
"build-plugin-component"
|
||||
],
|
||||
"./build.plugin.js"
|
||||
"build-plugin-component"
|
||||
]
|
||||
}
|
||||
|
||||
@ -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 { SettingTopEntry } from 'designer/src/designer';
|
||||
import { EventEmitter } from 'events';
|
||||
import { includeSlot, removeSlot } from '../../utils/slot';
|
||||
|
||||
/**
|
||||
* 基础节点
|
||||
@ -709,6 +710,11 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
||||
|
||||
addSlot(slotNode: Node) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,6 @@ import { valueToSource } from './value-to-source';
|
||||
import { Props } from './props';
|
||||
import { SlotNode, Node } from '../node';
|
||||
import { TransformStage } from '../transform-stage';
|
||||
import { includesSlot } from '../../../utils/slot';
|
||||
|
||||
export const UNSET = Symbol.for('unset');
|
||||
export type UNSET = typeof UNSET;
|
||||
@ -118,7 +117,7 @@ export class Prop implements IPropParent {
|
||||
}
|
||||
|
||||
if (type === 'slot') {
|
||||
const schema = this._slotNode!.export(stage);
|
||||
const schema = this._slotNode?.export(stage) || {};
|
||||
if (stage === TransformStage.Render) {
|
||||
return {
|
||||
type: 'JSSlot',
|
||||
@ -294,11 +293,9 @@ export class Prop implements IPropParent {
|
||||
this._slotNode.import(slotSchema);
|
||||
} else {
|
||||
const { owner } = this.props;
|
||||
if (!includesSlot(owner, data.name)) {
|
||||
this._slotNode = owner.document.createNode<SlotNode>(slotSchema);
|
||||
owner.addSlot(this._slotNode);
|
||||
this._slotNode.internalSetSlotFor(this);
|
||||
}
|
||||
this._slotNode = owner.document.createNode<SlotNode>(slotSchema);
|
||||
owner.addSlot(this._slotNode);
|
||||
this._slotNode.internalSetSlotFor(this);
|
||||
}
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
@ -1,8 +1,19 @@
|
||||
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;
|
||||
return slots.some(slot => {
|
||||
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;
|
||||
beforeAll(() => {
|
||||
designer = new Designer({} as any);
|
||||
designer = new Designer({});
|
||||
});
|
||||
|
||||
describe('schema 生成节点模型测试', () => {
|
||||
|
||||
@ -1,28 +1 @@
|
||||
export function getIdsFromSchema(schema, ids = []) {
|
||||
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;
|
||||
}
|
||||
export { getIdsFromSchema, getNodeFromSchemaById } from '@ali/lowcode-test-mate/es/utils';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user