mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-10 09:56:20 +00:00
chore: code style fix
This commit is contained in:
parent
298c810937
commit
a17573191f
@ -1,6 +1,6 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
extends: 'eslint-config-ali/typescript/react',
|
extends: 'eslint-config-ali/typescript/react',
|
||||||
ignorePatterns: [ 'tests/* '],
|
ignorePatterns: [ 'tests/** '],
|
||||||
rules: {
|
rules: {
|
||||||
'react/no-multi-comp': 0,
|
'react/no-multi-comp': 0,
|
||||||
'no-unused-expressions': 0,
|
'no-unused-expressions': 0,
|
||||||
@ -24,5 +24,7 @@ module.exports = {
|
|||||||
'no-useless-escape': 1,
|
'no-useless-escape': 1,
|
||||||
'brace-style': 1,
|
'brace-style': 1,
|
||||||
'@typescript-eslint/no-inferrable-types': 0,
|
'@typescript-eslint/no-inferrable-types': 0,
|
||||||
|
'no-proto': 0,
|
||||||
|
'prefer-const': 0,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -73,7 +73,7 @@ export class BorderDetecting extends Component<{ host: BuiltinSimulatorHost }> {
|
|||||||
render() {
|
render() {
|
||||||
const { host } = this.props;
|
const { host } = this.props;
|
||||||
const { current } = this;
|
const { current } = this;
|
||||||
|
|
||||||
const canHoverHook = current?.componentMeta.getMetadata()?.experimental?.callbacks?.onHoverHook;
|
const canHoverHook = current?.componentMeta.getMetadata()?.experimental?.callbacks?.onHoverHook;
|
||||||
const canHover = (canHoverHook && typeof canHoverHook === 'function') ? canHoverHook(current) : true;
|
const canHover = (canHoverHook && typeof canHoverHook === 'function') ? canHoverHook(current) : true;
|
||||||
|
|
||||||
|
|||||||
@ -224,7 +224,7 @@ export class BoxResizingInstance extends Component<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
const unBind: any[] = [];
|
const unBind: any[] = [];
|
||||||
const node = this.props.observed.node;
|
const { node } = this.props.observed;
|
||||||
|
|
||||||
unBind.push(
|
unBind.push(
|
||||||
...[
|
...[
|
||||||
|
|||||||
@ -39,12 +39,12 @@
|
|||||||
background: url(https://img.alicdn.com/tfs/TB1b4DHilFR4u4jSZFPXXanzFXa-750-1574.png) no-repeat top;
|
background: url(https://img.alicdn.com/tfs/TB1b4DHilFR4u4jSZFPXXanzFXa-750-1574.png) no-repeat top;
|
||||||
background-size: 378px 812px;
|
background-size: 378px 812px;
|
||||||
border-radius: 44px;
|
border-radius: 44px;
|
||||||
box-shadow: rgba(0, 0, 0, 0.1) 0px 36px 42px;
|
box-shadow: rgba(0, 0, 0, 0.1) 0 36px 42px;
|
||||||
.@{scope}-canvas-viewport {
|
.@{scope}-canvas-viewport {
|
||||||
width: auto;
|
width: auto;
|
||||||
top: 50px;
|
top: 50px;
|
||||||
left: 0px;
|
left: 0;
|
||||||
right: 0px;
|
right: 0;
|
||||||
margin-top: 40px;
|
margin-top: 40px;
|
||||||
max-height: 688px;
|
max-height: 688px;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -252,7 +252,6 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
private _iframe?: HTMLIFrameElement;
|
private _iframe?: HTMLIFrameElement;
|
||||||
|
|
||||||
async mountContentFrame(iframe: HTMLIFrameElement | null) {
|
async mountContentFrame(iframe: HTMLIFrameElement | null) {
|
||||||
|
|
||||||
if (!iframe || this._iframe === iframe) {
|
if (!iframe || this._iframe === iframe) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -340,7 +339,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
}
|
}
|
||||||
|
|
||||||
setupDragAndClick() {
|
setupDragAndClick() {
|
||||||
const designer = this.designer;
|
const { designer } = this;
|
||||||
const doc = this.contentDocument!;
|
const doc = this.contentDocument!;
|
||||||
|
|
||||||
// TODO: think of lock when edit a node
|
// TODO: think of lock when edit a node
|
||||||
@ -354,7 +353,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
if (this.liveEditing.editing || !documentModel) {
|
if (this.liveEditing.editing || !documentModel) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const selection = documentModel.selection;
|
const { selection } = documentModel;
|
||||||
let isMulti = false;
|
let isMulti = false;
|
||||||
if (this.designMode === 'design') {
|
if (this.designMode === 'design') {
|
||||||
isMulti = downEvent.metaKey || downEvent.ctrlKey;
|
isMulti = downEvent.metaKey || downEvent.ctrlKey;
|
||||||
@ -384,7 +383,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
doc.removeEventListener('mouseup', checkSelect, true);
|
doc.removeEventListener('mouseup', checkSelect, true);
|
||||||
// 鼠标是否移动
|
// 鼠标是否移动
|
||||||
if (!isShaken(downEvent, e)) {
|
if (!isShaken(downEvent, e)) {
|
||||||
let id = node.id;
|
let { id } = node;
|
||||||
designer.activeTracker.track({ node, instance: nodeInst?.instance });
|
designer.activeTracker.track({ node, instance: nodeInst?.instance });
|
||||||
if (isMulti && !isRootNode(node) && selection.has(id)) {
|
if (isMulti && !isRootNode(node) && selection.has(id)) {
|
||||||
selection.remove(id);
|
selection.remove(id);
|
||||||
@ -500,7 +499,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
*/
|
*/
|
||||||
setupDetecting() {
|
setupDetecting() {
|
||||||
const doc = this.contentDocument!;
|
const doc = this.contentDocument!;
|
||||||
const detecting = this.designer.detecting;
|
const { detecting } = this.designer;
|
||||||
const hover = (e: MouseEvent) => {
|
const hover = (e: MouseEvent) => {
|
||||||
if (!detecting.enable || this.designMode !== 'design') {
|
if (!detecting.enable || this.designMode !== 'design') {
|
||||||
return;
|
return;
|
||||||
@ -682,14 +681,14 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
getComponentInstances(node: Node, context?: NodeInstance): ComponentInstance[] | null {
|
getComponentInstances(node: Node, context?: NodeInstance): ComponentInstance[] | null {
|
||||||
const docId = node.document.id;
|
const docId = node.document.id;
|
||||||
|
|
||||||
let instances = this.instancesMap[docId]?.get(node.id) || null;
|
const instances = this.instancesMap[docId]?.get(node.id) || null;
|
||||||
if (!instances || !context) {
|
if (!instances || !context) {
|
||||||
return instances;
|
return instances;
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter with context
|
// filter with context
|
||||||
return instances.filter((instance) => {
|
return instances.filter((instance) => {
|
||||||
return this.getClosestNodeInstance(instance, context.nodeId)?.instance === context.instance
|
return this.getClosestNodeInstance(instance, context.nodeId)?.instance === context.instance;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1030,7 +1029,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
const locationData = {
|
const locationData = {
|
||||||
target: container as ParentalNode,
|
target: container as ParentalNode,
|
||||||
detail,
|
detail,
|
||||||
source: 'simulator' + document.id,
|
source: `simulator${ document.id}`,
|
||||||
event: e,
|
event: e,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1043,7 +1042,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
return this.designer.createLocation({
|
return this.designer.createLocation({
|
||||||
target: document.rootNode,
|
target: document.rootNode,
|
||||||
detail,
|
detail,
|
||||||
source: 'simulator' + document.id,
|
source: `simulator${ document.id}`,
|
||||||
event: e,
|
event: e,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1208,7 +1207,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
|
|
||||||
let dropContainer: DropContainer = {
|
let dropContainer: DropContainer = {
|
||||||
container: container as any,
|
container: container as any,
|
||||||
instance
|
instance,
|
||||||
};
|
};
|
||||||
|
|
||||||
let res: any;
|
let res: any;
|
||||||
@ -1232,7 +1231,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
instance = this.getClosestNodeInstance(dropContainer.instance, container.id)?.instance;
|
instance = this.getClosestNodeInstance(dropContainer.instance, container.id)?.instance;
|
||||||
dropContainer = {
|
dropContainer = {
|
||||||
container: container as ParentalNode,
|
container: container as ParentalNode,
|
||||||
instance
|
instance,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@ -1253,7 +1252,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
}
|
}
|
||||||
} else if (isNode(res)) {
|
} else if (isNode(res)) {
|
||||||
// TODO:
|
// TODO:
|
||||||
}*/
|
} */
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -1323,14 +1322,14 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
* 查找邻近容器
|
* 查找邻近容器
|
||||||
*/
|
*/
|
||||||
getNearByContainer({ container, instance }: DropContainer, drillDownExcludes: Set<Node>, e: LocateEvent) {
|
getNearByContainer({ container, instance }: DropContainer, drillDownExcludes: Set<Node>, e: LocateEvent) {
|
||||||
const children = container.children;
|
const { children } = container;
|
||||||
const document = this.project.currentDocument!;
|
const document = this.project.currentDocument!;
|
||||||
if (!children || children.isEmpty()) {
|
if (!children || children.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let nearDistance: any = null;
|
const nearDistance: any = null;
|
||||||
let nearBy: any = null;
|
const nearBy: any = null;
|
||||||
for (let i = 0, l = children.size; i < l; i++) {
|
for (let i = 0, l = children.size; i < l; i++) {
|
||||||
let child = children.get(i);
|
let child = children.get(i);
|
||||||
|
|
||||||
@ -1347,7 +1346,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
}
|
}
|
||||||
// TODO:
|
// TODO:
|
||||||
this.findDOMNodes(instance);
|
this.findDOMNodes(instance);
|
||||||
this.getComponentInstances(child)
|
this.getComponentInstances(child);
|
||||||
const rect = this.computeRect(child);
|
const rect = this.computeRect(child);
|
||||||
if (!rect) {
|
if (!rect) {
|
||||||
continue;
|
continue;
|
||||||
@ -1362,7 +1361,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
if (nearDistance === null || distance < nearDistance) {
|
if (nearDistance === null || distance < nearDistance) {
|
||||||
nearDistance = distance;
|
nearDistance = distance;
|
||||||
nearBy = child;
|
nearBy = child;
|
||||||
}*/
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
return nearBy;
|
return nearBy;
|
||||||
|
|||||||
@ -178,10 +178,10 @@ export class ComponentMeta {
|
|||||||
this._title =
|
this._title =
|
||||||
typeof title === 'string'
|
typeof title === 'string'
|
||||||
? {
|
? {
|
||||||
type: 'i18n',
|
type: 'i18n',
|
||||||
'en-US': this.componentName,
|
'en-US': this.componentName,
|
||||||
'zh-CN': title,
|
'zh-CN': title,
|
||||||
}
|
}
|
||||||
: title;
|
: title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -207,7 +207,7 @@ export class Designer {
|
|||||||
selectionDispose();
|
selectionDispose();
|
||||||
selectionDispose = undefined;
|
selectionDispose = undefined;
|
||||||
}
|
}
|
||||||
const currentSelection = this.currentSelection;
|
const { currentSelection } = this;
|
||||||
// TODO: 避免选中 Page 组件,默认选中第一个子节点;新增规则 或 判断 Live 模式
|
// TODO: 避免选中 Page 组件,默认选中第一个子节点;新增规则 或 判断 Live 模式
|
||||||
if (currentSelection && currentSelection.selected.length === 0 && this.simulatorProps?.designMode === 'live') {
|
if (currentSelection && currentSelection.selected.length === 0 && this.simulatorProps?.designMode === 'live') {
|
||||||
const rootNodeChildrens = this.currentDocument.getRoot().getChildren().children;
|
const rootNodeChildrens = this.currentDocument.getRoot().getChildren().children;
|
||||||
|
|||||||
@ -8,8 +8,8 @@ import './project.less';
|
|||||||
export class ProjectView extends Component<{ designer: Designer }> {
|
export class ProjectView extends Component<{ designer: Designer }> {
|
||||||
render() {
|
render() {
|
||||||
const { designer } = this.props;
|
const { designer } = this.props;
|
||||||
const project = designer.project;
|
const { project } = designer;
|
||||||
const simulatorProps = project.simulatorProps;
|
const { simulatorProps } = project;
|
||||||
const Simulator = designer.simulatorComponent || BuiltinSimulatorHostView;
|
const Simulator = designer.simulatorComponent || BuiltinSimulatorHostView;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -252,7 +252,7 @@ export class Project {
|
|||||||
* 提供给模拟器的参数
|
* 提供给模拟器的参数
|
||||||
*/
|
*/
|
||||||
@computed get simulatorProps(): object {
|
@computed get simulatorProps(): object {
|
||||||
let simulatorProps = this.designer.simulatorProps;
|
let { simulatorProps } = this.designer;
|
||||||
if (typeof simulatorProps === 'function') {
|
if (typeof simulatorProps === 'function') {
|
||||||
simulatorProps = simulatorProps(this);
|
simulatorProps = simulatorProps(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -149,7 +149,7 @@ export interface ISimulatorHost<P = object> extends ISensor {
|
|||||||
findDOMNodes(instance: ComponentInstance, selector?: string): Array<Element | Text> | null;
|
findDOMNodes(instance: ComponentInstance, selector?: string): Array<Element | Text> | null;
|
||||||
|
|
||||||
getDropContainer(e: LocateEvent): DropContainer | null;
|
getDropContainer(e: LocateEvent): DropContainer | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 销毁
|
* 销毁
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
export function invariant(check: any, message: string, thing?: any) {
|
export function invariant(check: any, message: string, thing?: any) {
|
||||||
if (!check) {
|
if (!check) {
|
||||||
throw new Error('[designer] Invariant failed: ' + message + (thing ? ` in '${thing}'` : ''));
|
throw new Error(`[designer] Invariant failed: ${ message }${thing ? ` in '${thing}'` : ''}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,4 +11,4 @@ export function foreachReverse(
|
|||||||
for (let i = arr.length - 1; i >= 0; i--) {
|
for (let i = arr.length - 1; i >= 0; i--) {
|
||||||
action.call(context, getter(arr, i));
|
action.call(context, getter(arr, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,4 +7,4 @@ export class DocumentModel {
|
|||||||
const c: number = 2;
|
const c: number = 2;
|
||||||
this.a = b?.x?.y;
|
this.a = b?.x?.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,4 +6,4 @@ export class Node2 {
|
|||||||
const c: number = 2;
|
const c: number = 2;
|
||||||
this.a = b?.x?.y;
|
this.a = b?.x?.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,4 +52,4 @@ it.todo('在同一个节点下,相同名称的 slot 只能有一个', () => {
|
|||||||
const exportSchema = currentDocument?.export(1);
|
const exportSchema = currentDocument?.export(1);
|
||||||
expect(getIdsFromSchema(exportSchema).length).toBe(expectedNodeCnt);
|
expect(getIdsFromSchema(exportSchema).length).toBe(expectedNodeCnt);
|
||||||
expect(mockCreateSettingEntry).toBeCalledTimes(expectedNodeCnt);
|
expect(mockCreateSettingEntry).toBeCalledTimes(expectedNodeCnt);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -28,5 +28,5 @@ describe('host-view 测试', () => {
|
|||||||
|
|
||||||
it('host-view', () => {
|
it('host-view', () => {
|
||||||
const hostView = render(<BuiltinSimulatorHostView project={designer.project} />);
|
const hostView = render(<BuiltinSimulatorHostView project={designer.project} />);
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -200,22 +200,21 @@ describe('Host 测试', () => {
|
|||||||
|
|
||||||
it('fixEvent', () => {
|
it('fixEvent', () => {
|
||||||
expect(host.fixEvent({ fixed: true, clientX: 1 })).toEqual({ fixed: true, clientX: 1 });
|
expect(host.fixEvent({ fixed: true, clientX: 1 })).toEqual({ fixed: true, clientX: 1 });
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('findDOMNodes', () => {
|
it('findDOMNodes', () => {
|
||||||
host.connect({
|
host.connect({
|
||||||
findDOMNodes: () => {
|
findDOMNodes: () => {
|
||||||
return null;
|
return null;
|
||||||
}
|
},
|
||||||
}, () => {});
|
}, () => {});
|
||||||
expect(host.findDOMNodes()).toBeNull();
|
expect(host.findDOMNodes()).toBeNull();
|
||||||
|
|
||||||
const mockElems = [document.createElement('div')]
|
const mockElems = [document.createElement('div')];
|
||||||
host.connect({
|
host.connect({
|
||||||
findDOMNodes: () => {
|
findDOMNodes: () => {
|
||||||
return mockElems;
|
return mockElems;
|
||||||
}
|
},
|
||||||
}, () => {});
|
}, () => {});
|
||||||
expect(host.findDOMNodes({})).toBe(mockElems);
|
expect(host.findDOMNodes({})).toBe(mockElems);
|
||||||
expect(host.findDOMNodes({}, 'xxx')).toBeNull();
|
expect(host.findDOMNodes({}, 'xxx')).toBeNull();
|
||||||
@ -231,7 +230,7 @@ describe('Host 测试', () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
host.connect({
|
host.connect({
|
||||||
getClosestNodeInstance: mockFn
|
getClosestNodeInstance: mockFn,
|
||||||
}, () => {});
|
}, () => {});
|
||||||
expect(host.getClosestNodeInstance()).toEqual({
|
expect(host.getClosestNodeInstance()).toEqual({
|
||||||
node: {},
|
node: {},
|
||||||
@ -244,14 +243,14 @@ describe('Host 测试', () => {
|
|||||||
expect(host.getNodeInstanceFromElement()).toBeNull();
|
expect(host.getNodeInstanceFromElement()).toBeNull();
|
||||||
host.getClosestNodeInstance = () => {
|
host.getClosestNodeInstance = () => {
|
||||||
return null;
|
return null;
|
||||||
}
|
};
|
||||||
expect(host.getNodeInstanceFromElement({})).toBeNull();
|
expect(host.getNodeInstanceFromElement({})).toBeNull();
|
||||||
host.getClosestNodeInstance = () => {
|
host.getClosestNodeInstance = () => {
|
||||||
return {
|
return {
|
||||||
docId: project.currentDocument.id,
|
docId: project.currentDocument.id,
|
||||||
nodeId: 'xxx'
|
nodeId: 'xxx',
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
expect(host.getNodeInstanceFromElement({})).toBeTruthy();
|
expect(host.getNodeInstanceFromElement({})).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -259,28 +258,28 @@ describe('Host 测试', () => {
|
|||||||
host.getNodeInstanceFromElement = () => {
|
host.getNodeInstanceFromElement = () => {
|
||||||
return {
|
return {
|
||||||
node: doc.rootNode,
|
node: doc.rootNode,
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
host.getDropContainer({
|
host.getDropContainer({
|
||||||
target: {},
|
target: {},
|
||||||
dragObject: {
|
dragObject: {
|
||||||
type: DragObjectType.Node,
|
type: DragObjectType.Node,
|
||||||
nodes: [doc.getNode('page')],
|
nodes: [doc.getNode('page')],
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getComponentInstances', () => {
|
it('getComponentInstances', () => {
|
||||||
const mockNode = {
|
const mockNode = {
|
||||||
document: { id: 'docId' }
|
document: { id: 'docId' },
|
||||||
};
|
};
|
||||||
host.instancesMap = {
|
host.instancesMap = {
|
||||||
'docId': {
|
docId: {
|
||||||
get() {
|
get() {
|
||||||
return [{ comp: true }, { comp2: true }];
|
return [{ comp: true }, { comp2: true }];
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
expect(host.getComponentInstances(mockNode))
|
expect(host.getComponentInstances(mockNode))
|
||||||
.toEqual([{ comp: true }, { comp2: true }]);
|
.toEqual([{ comp: true }, { comp2: true }]);
|
||||||
|
|
||||||
@ -288,8 +287,8 @@ describe('Host 测试', () => {
|
|||||||
host.getClosestNodeInstance = () => {
|
host.getClosestNodeInstance = () => {
|
||||||
return {
|
return {
|
||||||
instance: mockInst,
|
instance: mockInst,
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
expect(host.getComponentInstances(mockNode, { instance: mockInst }))
|
expect(host.getComponentInstances(mockNode, { instance: mockInst }))
|
||||||
.toEqual([{ comp: true }, { comp2: true }]);
|
.toEqual([{ comp: true }, { comp2: true }]);
|
||||||
});
|
});
|
||||||
@ -319,13 +318,13 @@ describe('Host 测试', () => {
|
|||||||
expect(host.sensorAvailable).toBeTruthy();
|
expect(host.sensorAvailable).toBeTruthy();
|
||||||
host.deactiveSensor();
|
host.deactiveSensor();
|
||||||
expect(host.sensing).toBeFalsy();
|
expect(host.sensing).toBeFalsy();
|
||||||
})
|
});
|
||||||
|
|
||||||
it('getComponent', () => {
|
it('getComponent', () => {
|
||||||
host.connect({
|
host.connect({
|
||||||
getComponent: () => {
|
getComponent: () => {
|
||||||
return {};
|
return {};
|
||||||
}
|
},
|
||||||
}, () => {});
|
}, () => {});
|
||||||
expect(host.getComponent()).toEqual({});
|
expect(host.getComponent()).toEqual({});
|
||||||
expect(host.createComponent()).toBeNull();
|
expect(host.createComponent()).toBeNull();
|
||||||
@ -335,10 +334,10 @@ describe('Host 测试', () => {
|
|||||||
it('setInstance', () => {
|
it('setInstance', () => {
|
||||||
host.instancesMap = {};
|
host.instancesMap = {};
|
||||||
host.setInstance('docId1', 'id1', [{}]);
|
host.setInstance('docId1', 'id1', [{}]);
|
||||||
expect(host.instancesMap['docId1'].get('id1')).toEqual([{}]);
|
expect(host.instancesMap.docId1.get('id1')).toEqual([{}]);
|
||||||
|
|
||||||
host.setInstance('docId1', 'id1', null);
|
host.setInstance('docId1', 'id1', null);
|
||||||
expect(host.instancesMap['docId1'].get('id1')).toBeUndefined();
|
expect(host.instancesMap.docId1.get('id1')).toBeUndefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -379,7 +378,7 @@ describe('Host 测试', () => {
|
|||||||
type: DragObjectType.Node,
|
type: DragObjectType.Node,
|
||||||
nodes: [doc.getNode('page')],
|
nodes: [doc.getNode('page')],
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -409,9 +408,9 @@ describe('Host 测试', () => {
|
|||||||
host.setupContextMenu();
|
host.setupContextMenu();
|
||||||
host.getNodeInstanceFromElement = () => {
|
host.getNodeInstanceFromElement = () => {
|
||||||
return {
|
return {
|
||||||
node: { componentMeta: { componentName: 'Button' }},
|
node: { componentMeta: { componentName: 'Button' } },
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
const mockFn = jest.fn();
|
const mockFn = jest.fn();
|
||||||
host.designer.editor.on('designer.builtinSimulator.contextmenu', mockFn);
|
host.designer.editor.on('designer.builtinSimulator.contextmenu', mockFn);
|
||||||
fireEvent.contextMenu(document, {});
|
fireEvent.contextMenu(document, {});
|
||||||
|
|||||||
@ -17,5 +17,5 @@ import { isSimulatorRenderer } from '../../src/builtin-simulator/renderer';
|
|||||||
describe('renderer 测试', () => {
|
describe('renderer 测试', () => {
|
||||||
it('renderer', () => {
|
it('renderer', () => {
|
||||||
expect(isSimulatorRenderer(getMockRenderer())).toBeTruthy();
|
expect(isSimulatorRenderer(getMockRenderer())).toBeTruthy();
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import ResourceConsumer from '../../src/builtin-simulator/resource-consumer';
|
|||||||
import { delayObxTick, delay } from '../utils';
|
import { delayObxTick, delay } from '../utils';
|
||||||
|
|
||||||
it('ResourceConsumer 测试,先消费再监听', async () => {
|
it('ResourceConsumer 测试,先消费再监听', async () => {
|
||||||
const con = new ResourceConsumer(() => ({ a: 1, b: 2}));
|
const con = new ResourceConsumer(() => ({ a: 1, b: 2 }));
|
||||||
|
|
||||||
const mockFn = jest.fn();
|
const mockFn = jest.fn();
|
||||||
con.consume((data) => {
|
con.consume((data) => {
|
||||||
@ -21,9 +21,9 @@ it('ResourceConsumer 测试,先消费再监听', async () => {
|
|||||||
|
|
||||||
it('ResourceConsumer 测试,先消费再监听,isSimulatorRenderer', async () => {
|
it('ResourceConsumer 测试,先消费再监听,isSimulatorRenderer', async () => {
|
||||||
const mockFn = jest.fn();
|
const mockFn = jest.fn();
|
||||||
const con = new ResourceConsumer(() => ({ a: 1, b: 2}), () => {
|
const con = new ResourceConsumer(() => ({ a: 1, b: 2 }), () => {
|
||||||
const o = { a: 3, b: 4 };
|
const o = { a: 3, b: 4 };
|
||||||
mockFn(o)
|
mockFn(o);
|
||||||
return o;
|
return o;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -39,13 +39,13 @@ it('ResourceConsumer 测试,先消费再监听,isSimulatorRenderer', async (
|
|||||||
|
|
||||||
it('ResourceConsumer 测试,先消费再监听,isSimulatorRenderer,没有 consume', async () => {
|
it('ResourceConsumer 测试,先消费再监听,isSimulatorRenderer,没有 consume', async () => {
|
||||||
const mockFn = jest.fn();
|
const mockFn = jest.fn();
|
||||||
const con = new ResourceConsumer(() => ({ a: 1, b: 2}));
|
const con = new ResourceConsumer(() => ({ a: 1, b: 2 }));
|
||||||
|
|
||||||
con.consume({ isSimulatorRenderer: true });
|
con.consume({ isSimulatorRenderer: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('ResourceConsumer 测试,先监听再消费', async () => {
|
it('ResourceConsumer 测试,先监听再消费', async () => {
|
||||||
const con = new ResourceConsumer(() => ({ a: 1, b: 2}));
|
const con = new ResourceConsumer(() => ({ a: 1, b: 2 }));
|
||||||
|
|
||||||
con.waitFirstConsume();
|
con.waitFirstConsume();
|
||||||
|
|
||||||
@ -57,4 +57,4 @@ it('ResourceConsumer 测试,先监听再消费', async () => {
|
|||||||
await delay(1000);
|
await delay(1000);
|
||||||
|
|
||||||
expect(mockFn).toHaveBeenCalledWith({ a: 1, b: 2 });
|
expect(mockFn).toHaveBeenCalledWith({ a: 1, b: 2 });
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,4 +6,4 @@ describe('parseMetadata', () => {
|
|||||||
const md1 = parseMetadata('Div');
|
const md1 = parseMetadata('Div');
|
||||||
const md2 = parseMetadata({ componentName: 'Div' });
|
const md2 = parseMetadata({ componentName: 'Div' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -75,4 +75,4 @@ describe('builtin-simulator/utils/path 测试', () => {
|
|||||||
expect(removeVersion('@ali/fe@1.0.0/index')).toBe('@ali/fe/index');
|
expect(removeVersion('@ali/fe@1.0.0/index')).toBe('@ali/fe/index');
|
||||||
expect(removeVersion('haha')).toBe('haha');
|
expect(removeVersion('haha')).toBe('haha');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -19,4 +19,4 @@ describe('throttle', () => {
|
|||||||
fn();
|
fn();
|
||||||
expect(cb).toBeCalledTimes(1);
|
expect(cb).toBeCalledTimes(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import '../fixtures/window';
|
import '../fixtures/window';
|
||||||
import { getMockWindow, set } from '../utils';
|
import { getMockWindow, set, getMockElement, delay } from '../utils';
|
||||||
import { Editor, globalContext } from '@ali/lowcode-editor-core';
|
import { Editor, globalContext } from '@ali/lowcode-editor-core';
|
||||||
import { Project } from '../../src/project/project';
|
import { Project } from '../../src/project/project';
|
||||||
import { DocumentModel } from '../../src/document/document-model';
|
import { DocumentModel } from '../../src/document/document-model';
|
||||||
import Viewport from '../../src/builtin-simulator/viewport';
|
import Viewport from '../../src/builtin-simulator/viewport';
|
||||||
import { Designer } from '../../src/designer/designer';
|
import { Designer } from '../../src/designer/designer';
|
||||||
import { fireEvent } from '@testing-library/react';
|
import { fireEvent } from '@testing-library/react';
|
||||||
import { getMockElement, delay } from '../utils';
|
|
||||||
|
|
||||||
describe('Viewport 测试', () => {
|
describe('Viewport 测试', () => {
|
||||||
let editor: Editor;
|
let editor: Editor;
|
||||||
@ -24,7 +24,7 @@ describe('Viewport 测试', () => {
|
|||||||
constructor(top, left, width, height) {
|
constructor(top, left, width, height) {
|
||||||
return { top, left, width, height };
|
return { top, left, width, height };
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -117,8 +117,8 @@ describe('Viewport 测试', () => {
|
|||||||
viewportElem.setHeight(300);
|
viewportElem.setHeight(300);
|
||||||
expect(viewport.contentHeight).toBe(300 / 2);
|
expect(viewport.contentHeight).toBe(300 / 2);
|
||||||
|
|
||||||
expect(() => viewport.scale = NaN).toThrow();
|
expect(() => { viewport.scale = NaN; }).toThrow();
|
||||||
expect(() => viewport.scale = -1).toThrow();
|
expect(() => { viewport.scale = -1; }).toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('setScrollTarget / scrollTarget / scrolling', async () => {
|
it('setScrollTarget / scrollTarget / scrolling', async () => {
|
||||||
|
|||||||
@ -37,4 +37,4 @@ it('ActiveTracker 测试,ActiveTarget', () => {
|
|||||||
mockFn.mockClear();
|
mockFn.mockClear();
|
||||||
tracker.track(mockNode);
|
tracker.track(mockNode);
|
||||||
expect(mockFn).not.toHaveBeenCalled();
|
expect(mockFn).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -58,7 +58,7 @@ describe('Designer 测试', () => {
|
|||||||
editor.on('designer.dragstart', dragStartMockFn2);
|
editor.on('designer.dragstart', dragStartMockFn2);
|
||||||
editor.on('designer.drag', dragMockFn2);
|
editor.on('designer.drag', dragMockFn2);
|
||||||
editor.on('designer.dragend', dragEndMockFn2);
|
editor.on('designer.dragend', dragEndMockFn2);
|
||||||
const dragon = designer.dragon;
|
const { dragon } = designer;
|
||||||
|
|
||||||
dragon.boost(
|
dragon.boost(
|
||||||
{
|
{
|
||||||
@ -124,7 +124,7 @@ describe('Designer 测试', () => {
|
|||||||
editor.on('designer.dragstart', dragStartMockFn2);
|
editor.on('designer.dragstart', dragStartMockFn2);
|
||||||
editor.on('designer.drag', dragMockFn2);
|
editor.on('designer.drag', dragMockFn2);
|
||||||
editor.on('designer.dragend', dragEndMockFn2);
|
editor.on('designer.dragend', dragEndMockFn2);
|
||||||
const dragon = designer.dragon;
|
const { dragon } = designer;
|
||||||
|
|
||||||
dragon.boost(
|
dragon.boost(
|
||||||
{
|
{
|
||||||
@ -183,37 +183,37 @@ describe('Designer 测试', () => {
|
|||||||
expect(designer.transformProps([{ num: 1 }], TransformStage.Init)).toEqual([{ num: 1 }]);
|
expect(designer.transformProps([{ num: 1 }], TransformStage.Init)).toEqual([{ num: 1 }]);
|
||||||
|
|
||||||
designer.addPropsReducer((props, node) => {
|
designer.addPropsReducer((props, node) => {
|
||||||
props.num = props.num + 1;
|
props.num += 1;
|
||||||
return props;
|
return props;
|
||||||
}, TransformStage.Init);
|
}, TransformStage.Init);
|
||||||
|
|
||||||
designer.addPropsReducer((props, node) => {
|
designer.addPropsReducer((props, node) => {
|
||||||
props.num = props.num + 1;
|
props.num += 1;
|
||||||
return props;
|
return props;
|
||||||
}, TransformStage.Init);
|
}, TransformStage.Init);
|
||||||
|
|
||||||
designer.addPropsReducer((props, node) => {
|
designer.addPropsReducer((props, node) => {
|
||||||
props.num = props.num + 1;
|
props.num += 1;
|
||||||
return props;
|
return props;
|
||||||
}, TransformStage.Clone);
|
}, TransformStage.Clone);
|
||||||
|
|
||||||
designer.addPropsReducer((props, node) => {
|
designer.addPropsReducer((props, node) => {
|
||||||
props.num = props.num + 1;
|
props.num += 1;
|
||||||
return props;
|
return props;
|
||||||
}, TransformStage.Serilize);
|
}, TransformStage.Serilize);
|
||||||
|
|
||||||
designer.addPropsReducer((props, node) => {
|
designer.addPropsReducer((props, node) => {
|
||||||
props.num = props.num + 1;
|
props.num += 1;
|
||||||
return props;
|
return props;
|
||||||
}, TransformStage.Render);
|
}, TransformStage.Render);
|
||||||
|
|
||||||
designer.addPropsReducer((props, node) => {
|
designer.addPropsReducer((props, node) => {
|
||||||
props.num = props.num + 1;
|
props.num += 1;
|
||||||
return props;
|
return props;
|
||||||
}, TransformStage.Save);
|
}, TransformStage.Save);
|
||||||
|
|
||||||
designer.addPropsReducer((props, node) => {
|
designer.addPropsReducer((props, node) => {
|
||||||
props.num = props.num + 1;
|
props.num += 1;
|
||||||
return props;
|
return props;
|
||||||
}, TransformStage.Upgrade);
|
}, TransformStage.Upgrade);
|
||||||
|
|
||||||
|
|||||||
@ -19,4 +19,4 @@ it('Detecting 测试', () => {
|
|||||||
detecting.capture(mockNode);
|
detecting.capture(mockNode);
|
||||||
detecting.enable = false;
|
detecting.enable = false;
|
||||||
expect(detecting.current).toBeNull();
|
expect(detecting.current).toBeNull();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -129,15 +129,15 @@ it('isRowContainer', () => {
|
|||||||
return {
|
return {
|
||||||
getPropertyValue: (pName) => {
|
getPropertyValue: (pName) => {
|
||||||
return pName === 'display' ? 'flex' : 'row';
|
return pName === 'display' ? 'flex' : 'row';
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
})
|
})
|
||||||
.mockImplementationOnce(() => {
|
.mockImplementationOnce(() => {
|
||||||
return {
|
return {
|
||||||
getPropertyValue: (pName) => {
|
getPropertyValue: (pName) => {
|
||||||
return pName === 'display' ? 'flex' : 'column';
|
return pName === 'display' ? 'flex' : 'column';
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
expect(isRowContainer(getMockElement('div'))).toBeFalsy();
|
expect(isRowContainer(getMockElement('div'))).toBeFalsy();
|
||||||
expect(isRowContainer(getMockElement('div'))).toBeTruthy();
|
expect(isRowContainer(getMockElement('div'))).toBeTruthy();
|
||||||
@ -149,8 +149,8 @@ it('isChildInline', () => {
|
|||||||
return {
|
return {
|
||||||
getPropertyValue: (pName) => {
|
getPropertyValue: (pName) => {
|
||||||
return pName === 'display' ? 'inline' : 'float';
|
return pName === 'display' ? 'inline' : 'float';
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(isChildInline({ nodeType: Node.TEXT_NODE })).toBeTruthy();
|
expect(isChildInline({ nodeType: Node.TEXT_NODE })).toBeTruthy();
|
||||||
@ -169,11 +169,11 @@ it('isVerticalContainer', () => {
|
|||||||
return {
|
return {
|
||||||
getPropertyValue: (pName) => {
|
getPropertyValue: (pName) => {
|
||||||
return pName === 'display' ? 'flex' : 'row';
|
return pName === 'display' ? 'flex' : 'row';
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
expect(isVerticalContainer()).toBeFalsy();
|
expect(isVerticalContainer()).toBeFalsy();
|
||||||
expect(isVerticalContainer({ elements: [getMockElement('div')] })).toBeTruthy()
|
expect(isVerticalContainer({ elements: [getMockElement('div')] })).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('isVertical', () => {
|
it('isVertical', () => {
|
||||||
@ -184,8 +184,8 @@ it('isVertical', () => {
|
|||||||
return {
|
return {
|
||||||
getPropertyValue: (pName) => {
|
getPropertyValue: (pName) => {
|
||||||
return pName === 'display' ? 'inline' : 'float';
|
return pName === 'display' ? 'inline' : 'float';
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
expect(isVertical({ elements: [getMockElement('div')] })).toBeTruthy();
|
expect(isVertical({ elements: [getMockElement('div')] })).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -78,7 +78,7 @@ describe('Scroller 测试', () => {
|
|||||||
scrollWidth: 500,
|
scrollWidth: 500,
|
||||||
document: {},
|
document: {},
|
||||||
nodeType: Node.ELEMENT_NODE,
|
nodeType: Node.ELEMENT_NODE,
|
||||||
}
|
};
|
||||||
return mockWindow;
|
return mockWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,6 @@ describe('Scroller 测试', () => {
|
|||||||
expect(target.left).toBe(100);
|
expect(target.left).toBe(100);
|
||||||
expect(target.top).toBe(100);
|
expect(target.top).toBe(100);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function mockRAF() {
|
function mockRAF() {
|
||||||
@ -119,7 +118,7 @@ describe('Scroller 测试', () => {
|
|||||||
|
|
||||||
mockRAF();
|
mockRAF();
|
||||||
scroller.scrolling({ globalX: 100, globalY: 100 });
|
scroller.scrolling({ globalX: 100, globalY: 100 });
|
||||||
})
|
});
|
||||||
|
|
||||||
it('scrollTarget: ScrollTarget, same left / top', () => {
|
it('scrollTarget: ScrollTarget, same left / top', () => {
|
||||||
const win = getMockWindow();
|
const win = getMockWindow();
|
||||||
@ -131,7 +130,7 @@ describe('Scroller 测试', () => {
|
|||||||
|
|
||||||
mockRAF();
|
mockRAF();
|
||||||
scroller.scrolling({ globalX: 100, globalY: 100 });
|
scroller.scrolling({ globalX: 100, globalY: 100 });
|
||||||
})
|
});
|
||||||
|
|
||||||
it('scrollTarget: Element', () => {
|
it('scrollTarget: Element', () => {
|
||||||
const win = getMockWindow();
|
const win = getMockWindow();
|
||||||
@ -142,7 +141,7 @@ describe('Scroller 测试', () => {
|
|||||||
|
|
||||||
mockRAF();
|
mockRAF();
|
||||||
scroller.scrolling({ globalX: 100, globalY: 100 });
|
scroller.scrolling({ globalX: 100, globalY: 100 });
|
||||||
})
|
});
|
||||||
|
|
||||||
it('scrollTarget: null', () => {
|
it('scrollTarget: null', () => {
|
||||||
const win = getMockWindow();
|
const win = getMockWindow();
|
||||||
@ -153,6 +152,6 @@ describe('Scroller 测试', () => {
|
|||||||
|
|
||||||
mockRAF();
|
mockRAF();
|
||||||
scroller.scrolling({ globalX: 100, globalY: 100 });
|
scroller.scrolling({ globalX: 100, globalY: 100 });
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -98,7 +98,7 @@ describe('setting-prop-entry 测试', () => {
|
|||||||
|
|
||||||
expect(customClassNameProp.getValue()).toEqual({
|
expect(customClassNameProp.getValue()).toEqual({
|
||||||
type: 'JSExpression',
|
type: 'JSExpression',
|
||||||
value: 'getFromSomewhere()'
|
value: 'getFromSomewhere()',
|
||||||
});
|
});
|
||||||
expect(customClassNameProp.getMockOrValue()).toBeUndefined();
|
expect(customClassNameProp.getMockOrValue()).toBeUndefined();
|
||||||
expect(customClassNameProp.getVariableValue()).toBe('getFromSomewhere()');
|
expect(customClassNameProp.getVariableValue()).toBe('getFromSomewhere()');
|
||||||
@ -111,4 +111,4 @@ describe('setting-prop-entry 测试', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -171,4 +171,4 @@ describe('setting-top-entry 测试', () => {
|
|||||||
// 思考:假如以后面向其他场景,比如用户用 API 强行调用,是否需要做健壮性保护?
|
// 思考:假如以后面向其他场景,比如用户用 API 强行调用,是否需要做健壮性保护?
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -171,7 +171,7 @@ describe('document-model 测试', () => {
|
|||||||
designer.createComponentMeta(divMeta);
|
designer.createComponentMeta(divMeta);
|
||||||
designer.createComponentMeta(otherMeta);
|
designer.createComponentMeta(otherMeta);
|
||||||
const doc = new DocumentModel(project, formSchema);
|
const doc = new DocumentModel(project, formSchema);
|
||||||
const ret = doc.acceptRootNodeVisitor('getPageId', function(root) {
|
const ret = doc.acceptRootNodeVisitor('getPageId', (root) => {
|
||||||
return 'page';
|
return 'page';
|
||||||
});
|
});
|
||||||
expect(ret).toBe('page');
|
expect(ret).toBe('page');
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import '../../fixtures/window';
|
import '../../fixtures/window';
|
||||||
import { set } from '../../utils';
|
import { set, delayObxTick, delay } from '../../utils';
|
||||||
import { Editor } from '@ali/lowcode-editor-core';
|
import { Editor } from '@ali/lowcode-editor-core';
|
||||||
import { Project } from '../../../src/project/project';
|
import { Project } from '../../../src/project/project';
|
||||||
import { DocumentModel } from '../../../src/document/document-model';
|
import { DocumentModel } from '../../../src/document/document-model';
|
||||||
@ -24,7 +24,7 @@ import pageMetadata from '../../fixtures/component-metadata/page';
|
|||||||
import rootHeaderMetadata from '../../fixtures/component-metadata/root-header';
|
import rootHeaderMetadata from '../../fixtures/component-metadata/root-header';
|
||||||
import rootContentMetadata from '../../fixtures/component-metadata/root-content';
|
import rootContentMetadata from '../../fixtures/component-metadata/root-content';
|
||||||
import rootFooterMetadata from '../../fixtures/component-metadata/root-footer';
|
import rootFooterMetadata from '../../fixtures/component-metadata/root-footer';
|
||||||
import { delayObxTick, delay } from '../../utils';
|
|
||||||
|
|
||||||
describe('ModalNodesManager 方法测试', () => {
|
describe('ModalNodesManager 方法测试', () => {
|
||||||
let editor: Editor;
|
let editor: Editor;
|
||||||
@ -81,7 +81,7 @@ describe('ModalNodesManager 方法测试', () => {
|
|||||||
const off = mgr.onModalNodesChange(nodesMockFn);
|
const off = mgr.onModalNodesChange(nodesMockFn);
|
||||||
const offVisible = mgr.onVisibleChange(visibleMockFn);
|
const offVisible = mgr.onVisibleChange(visibleMockFn);
|
||||||
|
|
||||||
const newNode = new Node(doc, { componentName: 'Dialog' })
|
const newNode = new Node(doc, { componentName: 'Dialog' });
|
||||||
mgr.addNode(newNode);
|
mgr.addNode(newNode);
|
||||||
expect(visibleMockFn).toHaveBeenCalledTimes(2);
|
expect(visibleMockFn).toHaveBeenCalledTimes(2);
|
||||||
expect(nodesMockFn).toHaveBeenCalledTimes(1);
|
expect(nodesMockFn).toHaveBeenCalledTimes(1);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import '../../fixtures/window';
|
import '../../fixtures/window';
|
||||||
import { set } from '../../utils';
|
import { set, delayObxTick, delay } from '../../utils';
|
||||||
import { Editor } from '@ali/lowcode-editor-core';
|
import { Editor } from '@ali/lowcode-editor-core';
|
||||||
import { Project } from '../../../src/project/project';
|
import { Project } from '../../../src/project/project';
|
||||||
import { DocumentModel } from '../../../src/document/document-model';
|
import { DocumentModel } from '../../../src/document/document-model';
|
||||||
@ -23,7 +23,7 @@ import pageMetadata from '../../fixtures/component-metadata/page';
|
|||||||
import rootHeaderMetadata from '../../fixtures/component-metadata/root-header';
|
import rootHeaderMetadata from '../../fixtures/component-metadata/root-header';
|
||||||
import rootContentMetadata from '../../fixtures/component-metadata/root-content';
|
import rootContentMetadata from '../../fixtures/component-metadata/root-content';
|
||||||
import rootFooterMetadata from '../../fixtures/component-metadata/root-footer';
|
import rootFooterMetadata from '../../fixtures/component-metadata/root-footer';
|
||||||
import { delayObxTick, delay } from '../../utils';
|
|
||||||
|
|
||||||
describe('NodeChildren 方法测试', () => {
|
describe('NodeChildren 方法测试', () => {
|
||||||
let editor: Editor;
|
let editor: Editor;
|
||||||
@ -105,7 +105,7 @@ describe('NodeChildren 方法测试', () => {
|
|||||||
const { children } = firstBtn.parent!;
|
const { children } = firstBtn.parent!;
|
||||||
|
|
||||||
children.some((item) => {
|
children.some((item) => {
|
||||||
expect(item.componentName).toBe('Button');
|
return expect(item.componentName).toBe('Button');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ describe('NodeChildren 方法测试', () => {
|
|||||||
const { children } = firstBtn.parent!;
|
const { children } = firstBtn.parent!;
|
||||||
|
|
||||||
children.every((item) => {
|
children.every((item) => {
|
||||||
expect(item.componentName).toBe('Button');
|
return expect(item.componentName).toBe('Button');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -167,7 +167,7 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
componentName: 'TextInput',
|
componentName: 'TextInput',
|
||||||
props: {
|
props: {
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
currentDocument?.insertNode(pageNode, node);
|
currentDocument?.insertNode(pageNode, node);
|
||||||
|
|
||||||
@ -198,25 +198,25 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
componentName: 'TextInput',
|
componentName: 'TextInput',
|
||||||
props: {
|
props: {
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
const node2 = currentDocument.createNode({
|
const node2 = currentDocument.createNode({
|
||||||
componentName: 'TextInput',
|
componentName: 'TextInput',
|
||||||
props: {
|
props: {
|
||||||
propA: 'heihei',
|
propA: 'heihei',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
const node3 = currentDocument.createNode({
|
const node3 = currentDocument.createNode({
|
||||||
componentName: 'TextInput',
|
componentName: 'TextInput',
|
||||||
props: {
|
props: {
|
||||||
propA: 'heihei2',
|
propA: 'heihei2',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
const node4 = currentDocument.createNode({
|
const node4 = currentDocument.createNode({
|
||||||
componentName: 'TextInput',
|
componentName: 'TextInput',
|
||||||
props: {
|
props: {
|
||||||
propA: 'heihei3',
|
propA: 'heihei3',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
formNode?.insertBefore(node2);
|
formNode?.insertBefore(node2);
|
||||||
@ -265,8 +265,8 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
id: 'nodeschema-id1',
|
id: 'nodeschema-id1',
|
||||||
props: {
|
props: {
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
propB: 3
|
propB: 3,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
expect(nodesMap.size).toBe(ids.length + 1);
|
expect(nodesMap.size).toBe(ids.length + 1);
|
||||||
expect(formNode.children?.length).toBe(4);
|
expect(formNode.children?.length).toBe(4);
|
||||||
@ -274,7 +274,7 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
expect(insertedNode.componentName).toBe('TextInput');
|
expect(insertedNode.componentName).toBe('TextInput');
|
||||||
expect(insertedNode.propsData).toEqual({
|
expect(insertedNode.propsData).toEqual({
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
propB: 3
|
propB: 3,
|
||||||
});
|
});
|
||||||
// TODO: 把 checkId 的 commit pick 过来
|
// TODO: 把 checkId 的 commit pick 过来
|
||||||
// expect(nodesMap.get('nodeschema-id1').componentName).toBe('TextInput');
|
// expect(nodesMap.get('nodeschema-id1').componentName).toBe('TextInput');
|
||||||
@ -284,15 +284,15 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
expect(project).toBeTruthy();
|
expect(project).toBeTruthy();
|
||||||
const ids = getIdsFromSchema(formSchema);
|
const ids = getIdsFromSchema(formSchema);
|
||||||
const { currentDocument } = project;
|
const { currentDocument } = project;
|
||||||
const nodesMap = currentDocument.nodesMap;
|
const { nodesMap } = currentDocument;
|
||||||
const formNode = nodesMap.get('form');
|
const formNode = nodesMap.get('form');
|
||||||
currentDocument?.insertNode(formNode, {
|
currentDocument?.insertNode(formNode, {
|
||||||
componentName: 'TextInput',
|
componentName: 'TextInput',
|
||||||
id: 'nodeschema-id1',
|
id: 'nodeschema-id1',
|
||||||
props: {
|
props: {
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
propB: 3
|
propB: 3,
|
||||||
}
|
},
|
||||||
}, 0);
|
}, 0);
|
||||||
expect(nodesMap.size).toBe(ids.length + 1);
|
expect(nodesMap.size).toBe(ids.length + 1);
|
||||||
expect(formNode.children.length).toBe(4);
|
expect(formNode.children.length).toBe(4);
|
||||||
@ -300,7 +300,7 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
expect(insertedNode.componentName).toBe('TextInput');
|
expect(insertedNode.componentName).toBe('TextInput');
|
||||||
expect(insertedNode.propsData).toEqual({
|
expect(insertedNode.propsData).toEqual({
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
propB: 3
|
propB: 3,
|
||||||
});
|
});
|
||||||
// TODO: 把 checkId 的 commit pick 过来
|
// TODO: 把 checkId 的 commit pick 过来
|
||||||
// expect(nodesMap.get('nodeschema-id1').componentName).toBe('TextInput');
|
// expect(nodesMap.get('nodeschema-id1').componentName).toBe('TextInput');
|
||||||
@ -317,8 +317,8 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
id: 'nodeschema-id1',
|
id: 'nodeschema-id1',
|
||||||
props: {
|
props: {
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
propB: 3
|
propB: 3,
|
||||||
}
|
},
|
||||||
}, 1);
|
}, 1);
|
||||||
expect(nodesMap.size).toBe(ids.length + 1);
|
expect(nodesMap.size).toBe(ids.length + 1);
|
||||||
expect(formNode.children.length).toBe(4);
|
expect(formNode.children.length).toBe(4);
|
||||||
@ -326,7 +326,7 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
expect(insertedNode.componentName).toBe('TextInput');
|
expect(insertedNode.componentName).toBe('TextInput');
|
||||||
expect(insertedNode.propsData).toEqual({
|
expect(insertedNode.propsData).toEqual({
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
propB: 3
|
propB: 3,
|
||||||
});
|
});
|
||||||
// TODO: 把 checkId 的 commit pick 过来
|
// TODO: 把 checkId 的 commit pick 过来
|
||||||
// expect(nodesMap.get('nodeschema-id1').componentName).toBe('TextInput');
|
// expect(nodesMap.get('nodeschema-id1').componentName).toBe('TextInput');
|
||||||
@ -342,24 +342,24 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
componentName: 'ParentNode',
|
componentName: 'ParentNode',
|
||||||
props: {
|
props: {
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
propB: 3
|
propB: 3,
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
componentName: 'SubNode',
|
componentName: 'SubNode',
|
||||||
props: {
|
props: {
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
propB: 3
|
propB: 3,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
componentName: 'SubNode2',
|
componentName: 'SubNode2',
|
||||||
props: {
|
props: {
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
propB: 3
|
propB: 3,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
});
|
});
|
||||||
expect(nodesMap.size).toBe(ids.length + 3);
|
expect(nodesMap.size).toBe(ids.length + 3);
|
||||||
expect(formNode.children.length).toBe(4);
|
expect(formNode.children.length).toBe(4);
|
||||||
@ -379,8 +379,8 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
id: 'nodeschema-id1',
|
id: 'nodeschema-id1',
|
||||||
props: {
|
props: {
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
propB: 3
|
propB: 3,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
expect(nodesMap.get('nodeschema-id1').componentName).toBe('TextInput');
|
expect(nodesMap.get('nodeschema-id1').componentName).toBe('TextInput');
|
||||||
expect(nodesMap.size).toBe(ids.length + 1);
|
expect(nodesMap.size).toBe(ids.length + 1);
|
||||||
@ -397,8 +397,8 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
id: 'nodeschema-id1',
|
id: 'nodeschema-id1',
|
||||||
props: {
|
props: {
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
propB: 3
|
propB: 3,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
expect(nodesMap.get('nodeschema-id1').componentName).toBe('TextInput');
|
expect(nodesMap.get('nodeschema-id1').componentName).toBe('TextInput');
|
||||||
expect(nodesMap.size).toBe(ids.length + 1);
|
expect(nodesMap.size).toBe(ids.length + 1);
|
||||||
@ -415,8 +415,8 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
id: 'nodeschema-id2',
|
id: 'nodeschema-id2',
|
||||||
props: {
|
props: {
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
propB: 3
|
propB: 3,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
currentDocument?.insertNode(formNode, inputNode);
|
currentDocument?.insertNode(formNode, inputNode);
|
||||||
expect(formNode.children?.get(3)?.componentName).toBe('TextInput');
|
expect(formNode.children?.get(3)?.componentName).toBe('TextInput');
|
||||||
@ -431,7 +431,7 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
const formNode = nodesMap.get('form') as Node;
|
const formNode = nodesMap.get('form') as Node;
|
||||||
currentDocument?.insertNode(formNode, {
|
currentDocument?.insertNode(formNode, {
|
||||||
type: 'JSExpression',
|
type: 'JSExpression',
|
||||||
value: 'just a expression'
|
value: 'just a expression',
|
||||||
});
|
});
|
||||||
expect(nodesMap.size).toBe(ids.length + 1);
|
expect(nodesMap.size).toBe(ids.length + 1);
|
||||||
expect(formNode.children?.get(3)?.componentName).toBe('Leaf');
|
expect(formNode.children?.get(3)?.componentName).toBe('Leaf');
|
||||||
@ -476,16 +476,16 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
componentName: 'TextInput',
|
componentName: 'TextInput',
|
||||||
props: {
|
props: {
|
||||||
propA: 'haha2',
|
propA: 'haha2',
|
||||||
propB: 3
|
propB: 3,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
componentName: 'TextInput2',
|
componentName: 'TextInput2',
|
||||||
props: {
|
props: {
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
propB: 3
|
propB: 3,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
], 1);
|
], 1);
|
||||||
expect(nodesMap.size).toBe(ids.length + 2);
|
expect(nodesMap.size).toBe(ids.length + 2);
|
||||||
expect(formNode.children?.length).toBe(5);
|
expect(formNode.children?.length).toBe(5);
|
||||||
@ -494,12 +494,12 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
expect(insertedNode1.componentName).toBe('TextInput');
|
expect(insertedNode1.componentName).toBe('TextInput');
|
||||||
expect(insertedNode1.propsData).toEqual({
|
expect(insertedNode1.propsData).toEqual({
|
||||||
propA: 'haha2',
|
propA: 'haha2',
|
||||||
propB: 3
|
propB: 3,
|
||||||
});
|
});
|
||||||
expect(insertedNode2.componentName).toBe('TextInput2');
|
expect(insertedNode2.componentName).toBe('TextInput2');
|
||||||
expect(insertedNode2.propsData).toEqual({
|
expect(insertedNode2.propsData).toEqual({
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
propB: 3
|
propB: 3,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -515,17 +515,17 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
componentName: 'TextInput',
|
componentName: 'TextInput',
|
||||||
props: {
|
props: {
|
||||||
propA: 'haha2',
|
propA: 'haha2',
|
||||||
propB: 3
|
propB: 3,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
const createdNode2 = currentDocument?.createNode({
|
const createdNode2 = currentDocument?.createNode({
|
||||||
componentName: 'TextInput2',
|
componentName: 'TextInput2',
|
||||||
props: {
|
props: {
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
propB: 3
|
propB: 3,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
currentDocument?.insertNodes(formNode, [ createdNode1, createdNode2 ], 1);
|
currentDocument?.insertNodes(formNode, [createdNode1, createdNode2], 1);
|
||||||
expect(nodesMap.size).toBe(ids.length + 2);
|
expect(nodesMap.size).toBe(ids.length + 2);
|
||||||
expect(formNode.children?.length).toBe(5);
|
expect(formNode.children?.length).toBe(5);
|
||||||
const insertedNode1 = formNode.children.get(1);
|
const insertedNode1 = formNode.children.get(1);
|
||||||
@ -533,16 +533,16 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
expect(insertedNode1.componentName).toBe('TextInput');
|
expect(insertedNode1.componentName).toBe('TextInput');
|
||||||
expect(insertedNode1.propsData).toEqual({
|
expect(insertedNode1.propsData).toEqual({
|
||||||
propA: 'haha2',
|
propA: 'haha2',
|
||||||
propB: 3
|
propB: 3,
|
||||||
});
|
});
|
||||||
expect(insertedNode2.componentName).toBe('TextInput2');
|
expect(insertedNode2.componentName).toBe('TextInput2');
|
||||||
expect(insertedNode2.propsData).toEqual({
|
expect(insertedNode2.propsData).toEqual({
|
||||||
propA: 'haha',
|
propA: 'haha',
|
||||||
propB: 3
|
propB: 3,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
describe('block ❌ | component ❌ | slot ✅', () => {
|
describe('block ❌ | component ❌ | slot ✅', () => {
|
||||||
it('基本的 slot 创建', () => {
|
it('基本的 slot 创建', () => {
|
||||||
@ -564,4 +564,4 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
expect(nodesMap.get('node_k1ow3cbd').slots).toHaveLength(1);
|
expect(nodesMap.get('node_k1ow3cbd').slots).toHaveLength(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -55,7 +55,5 @@ describe.skip('节点拖拽测试', () => {
|
|||||||
expect(getIdsFromSchema(exportSchema).length).toBe(expectedNodeCnt);
|
expect(getIdsFromSchema(exportSchema).length).toBe(expectedNodeCnt);
|
||||||
expect(mockCreateSettingEntry).toBeCalledTimes(expectedNodeCnt);
|
expect(mockCreateSettingEntry).toBeCalledTimes(expectedNodeCnt);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -143,7 +143,7 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
formNode?.setPropValue('obj', {
|
formNode?.setPropValue('obj', {
|
||||||
a: 2,
|
a: 2,
|
||||||
b: true,
|
b: true,
|
||||||
c: 'another string'
|
c: 'another string',
|
||||||
});
|
});
|
||||||
const objProp = formNode?.getProp('obj');
|
const objProp = formNode?.getProp('obj');
|
||||||
expect(objProp?.getValue()).toEqual({
|
expect(objProp?.getValue()).toEqual({
|
||||||
@ -211,7 +211,7 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
props?.setPropValue('obj', {
|
props?.setPropValue('obj', {
|
||||||
a: 2,
|
a: 2,
|
||||||
b: true,
|
b: true,
|
||||||
c: 'another string'
|
c: 'another string',
|
||||||
});
|
});
|
||||||
const objProp = formNode?.getProp('obj');
|
const objProp = formNode?.getProp('obj');
|
||||||
expect(objProp?.getValue()).toEqual({
|
expect(objProp?.getValue()).toEqual({
|
||||||
@ -266,7 +266,7 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
id: 'form',
|
id: 'form',
|
||||||
condition: true,
|
condition: true,
|
||||||
*/
|
*/
|
||||||
const sizeProp = formNode?.getProp('size');
|
const sizeProp = formNode?.getProp('size');
|
||||||
sizeProp?.setValue('large');
|
sizeProp?.setValue('large');
|
||||||
expect(sizeProp?.getAsString()).toBe('large');
|
expect(sizeProp?.getAsString()).toBe('large');
|
||||||
expect(sizeProp?.getValue()).toBe('large');
|
expect(sizeProp?.getValue()).toBe('large');
|
||||||
@ -278,10 +278,10 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
|
|
||||||
const objProp = formNode?.getProp('obj');
|
const objProp = formNode?.getProp('obj');
|
||||||
objProp?.setValue({
|
objProp?.setValue({
|
||||||
a: 2,
|
a: 2,
|
||||||
b: true,
|
b: true,
|
||||||
c: 'another string'
|
c: 'another string',
|
||||||
});
|
});
|
||||||
expect(objProp?.getValue()).toEqual({
|
expect(objProp?.getValue()).toEqual({
|
||||||
a: 2,
|
a: 2,
|
||||||
b: true,
|
b: true,
|
||||||
@ -329,16 +329,16 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
props: {
|
props: {
|
||||||
txt: 'haha',
|
txt: 'haha',
|
||||||
num: 1,
|
num: 1,
|
||||||
bool: true
|
bool: true,
|
||||||
}
|
},
|
||||||
}, {
|
}, {
|
||||||
componentName: 'TextInput2',
|
componentName: 'TextInput2',
|
||||||
props: {
|
props: {
|
||||||
txt: 'heihei',
|
txt: 'heihei',
|
||||||
num: 2,
|
num: 2,
|
||||||
bool: false
|
bool: false,
|
||||||
}
|
},
|
||||||
}]
|
}],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(nodesMap.size).toBe(ids.length + 3);
|
expect(nodesMap.size).toBe(ids.length + 3);
|
||||||
@ -371,16 +371,16 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
props: {
|
props: {
|
||||||
txt: 'haha',
|
txt: 'haha',
|
||||||
num: 1,
|
num: 1,
|
||||||
bool: true
|
bool: true,
|
||||||
}
|
},
|
||||||
}, {
|
}, {
|
||||||
componentName: 'TextInput2',
|
componentName: 'TextInput2',
|
||||||
props: {
|
props: {
|
||||||
txt: 'heihei',
|
txt: 'heihei',
|
||||||
num: 2,
|
num: 2,
|
||||||
bool: false
|
bool: false,
|
||||||
}
|
},
|
||||||
}]
|
}],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(nodesMap.size).toBe(ids.length + 3);
|
expect(nodesMap.size).toBe(ids.length + 3);
|
||||||
@ -408,16 +408,16 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
props: {
|
props: {
|
||||||
txt: 'haha',
|
txt: 'haha',
|
||||||
num: 1,
|
num: 1,
|
||||||
bool: true
|
bool: true,
|
||||||
}
|
},
|
||||||
}, {
|
}, {
|
||||||
componentName: 'TextInput2',
|
componentName: 'TextInput2',
|
||||||
props: {
|
props: {
|
||||||
txt: 'heihei',
|
txt: 'heihei',
|
||||||
num: 2,
|
num: 2,
|
||||||
bool: false
|
bool: false,
|
||||||
}
|
},
|
||||||
}]
|
}],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(nodesMap.size).toBe(ids.length + 3);
|
expect(nodesMap.size).toBe(ids.length + 3);
|
||||||
@ -438,9 +438,9 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
props: {
|
props: {
|
||||||
txt: 'xixi',
|
txt: 'xixi',
|
||||||
num: 3,
|
num: 3,
|
||||||
bool: false
|
bool: false,
|
||||||
}
|
},
|
||||||
}]
|
}],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(nodesMap.size).toBe(ids.length + 2);
|
expect(nodesMap.size).toBe(ids.length + 2);
|
||||||
@ -453,4 +453,4 @@ describe('schema 生成节点模型测试', () => {
|
|||||||
expect(firstChildNode?.getPropValue('bool')).toBe(false);
|
expect(firstChildNode?.getPropValue('bool')).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -119,4 +119,4 @@ describe('节点模型删除测试', () => {
|
|||||||
// Div + 2 * Button + Slot + Text
|
// Div + 2 * Button + Slot + Text
|
||||||
expect(nodesMap.size).toBe(originalNodeCnt - 5);
|
expect(nodesMap.size).toBe(originalNodeCnt - 5);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import '../../fixtures/window';
|
import '../../fixtures/window';
|
||||||
import { set } from '../../utils';
|
import { set, delayObxTick, delay } from '../../utils';
|
||||||
import { Editor } from '@ali/lowcode-editor-core';
|
import { Editor } from '@ali/lowcode-editor-core';
|
||||||
import { Project } from '../../../src/project/project';
|
import { Project } from '../../../src/project/project';
|
||||||
import { DocumentModel } from '../../../src/document/document-model';
|
import { DocumentModel } from '../../../src/document/document-model';
|
||||||
@ -22,7 +22,7 @@ import pageMetadata from '../../fixtures/component-metadata/page';
|
|||||||
import rootHeaderMetadata from '../../fixtures/component-metadata/root-header';
|
import rootHeaderMetadata from '../../fixtures/component-metadata/root-header';
|
||||||
import rootContentMetadata from '../../fixtures/component-metadata/root-content';
|
import rootContentMetadata from '../../fixtures/component-metadata/root-content';
|
||||||
import rootFooterMetadata from '../../fixtures/component-metadata/root-footer';
|
import rootFooterMetadata from '../../fixtures/component-metadata/root-footer';
|
||||||
import { delayObxTick, delay } from '../../utils';
|
|
||||||
|
|
||||||
describe('Node 方法测试', () => {
|
describe('Node 方法测试', () => {
|
||||||
let editor: Editor;
|
let editor: Editor;
|
||||||
@ -375,8 +375,8 @@ describe('Node 方法测试', () => {
|
|||||||
doc.project.mountSimulator({
|
doc.project.mountSimulator({
|
||||||
computeRect: () => ({ x: 2, y: 2 }),
|
computeRect: () => ({ x: 2, y: 2 }),
|
||||||
viewport: {
|
viewport: {
|
||||||
contentBounds: { x: 1, y: 1 }
|
contentBounds: { x: 1, y: 1 },
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(root.getRect()).toEqual({ x: 1, y: 1 });
|
expect(root.getRect()).toEqual({ x: 1, y: 1 });
|
||||||
@ -448,7 +448,7 @@ describe('Node 方法测试', () => {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return [{}];
|
return [{}];
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(root.getDOMNode()).toBeUndefined();
|
expect(root.getDOMNode()).toBeUndefined();
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import '../../../fixtures/window';
|
import '../../../fixtures/window';
|
||||||
import { set } from '../../../utils';
|
import { set, delayObxTick } from '../../../utils';
|
||||||
import { Editor } from '@ali/lowcode-editor-core';
|
import { Editor } from '@ali/lowcode-editor-core';
|
||||||
import { Props } from '../../../../src/document/node/props/props';
|
import { Props } from '../../../../src/document/node/props/props';
|
||||||
import { Designer } from '../../../../src/designer/designer';
|
import { Designer } from '../../../../src/designer/designer';
|
||||||
@ -7,7 +7,7 @@ import { Project } from '../../../../src/project/project';
|
|||||||
import { DocumentModel } from '../../../../src/document/document-model';
|
import { DocumentModel } from '../../../../src/document/document-model';
|
||||||
import { Prop, isProp, isValidArrayIndex } from '../../../../src/document/node/props/prop';
|
import { Prop, isProp, isValidArrayIndex } from '../../../../src/document/node/props/prop';
|
||||||
import { TransformStage } from '@ali/lowcode-types';
|
import { TransformStage } from '@ali/lowcode-types';
|
||||||
import { delayObxTick } from '../../../utils';
|
|
||||||
|
|
||||||
const mockedOwner = {
|
const mockedOwner = {
|
||||||
componentName: 'Div',
|
componentName: 'Div',
|
||||||
@ -147,7 +147,7 @@ describe('Prop 类测试', () => {
|
|||||||
|
|
||||||
it('迭代器 / map / forEach', () => {
|
it('迭代器 / map / forEach', () => {
|
||||||
const mockedFn = jest.fn();
|
const mockedFn = jest.fn();
|
||||||
for (let item of strProp) {
|
for (const item of strProp) {
|
||||||
mockedFn();
|
mockedFn();
|
||||||
}
|
}
|
||||||
expect(mockedFn).not.toHaveBeenCalled();
|
expect(mockedFn).not.toHaveBeenCalled();
|
||||||
@ -160,7 +160,7 @@ describe('Prop 类测试', () => {
|
|||||||
mockedFn.mockClear();
|
mockedFn.mockClear();
|
||||||
|
|
||||||
strProp.map(item => {
|
strProp.map(item => {
|
||||||
mockedFn();
|
return mockedFn();
|
||||||
});
|
});
|
||||||
expect(mockedFn).not.toHaveBeenCalled();
|
expect(mockedFn).not.toHaveBeenCalled();
|
||||||
mockedFn.mockClear();
|
mockedFn.mockClear();
|
||||||
@ -214,7 +214,7 @@ describe('Prop 类测试', () => {
|
|||||||
const fromStashProp = prop.get('l');
|
const fromStashProp = prop.get('l');
|
||||||
const fromStashNestedProp = prop.get('m.m1');
|
const fromStashNestedProp = prop.get('m.m1');
|
||||||
fromStashProp.setValue('fromStashProp');
|
fromStashProp.setValue('fromStashProp');
|
||||||
fromStashNestedProp?.setValue('fromStashNestedProp')
|
fromStashNestedProp?.setValue('fromStashNestedProp');
|
||||||
|
|
||||||
await delayObxTick();
|
await delayObxTick();
|
||||||
expect(prop.get('l').getValue()).toBe('fromStashProp');
|
expect(prop.get('l').getValue()).toBe('fromStashProp');
|
||||||
@ -277,7 +277,7 @@ describe('Prop 类测试', () => {
|
|||||||
|
|
||||||
it('迭代器 / map / forEach', () => {
|
it('迭代器 / map / forEach', () => {
|
||||||
const mockedFn = jest.fn();
|
const mockedFn = jest.fn();
|
||||||
for (let item of prop) {
|
for (const item of prop) {
|
||||||
mockedFn();
|
mockedFn();
|
||||||
}
|
}
|
||||||
expect(mockedFn).toHaveBeenCalledTimes(5);
|
expect(mockedFn).toHaveBeenCalledTimes(5);
|
||||||
@ -290,7 +290,7 @@ describe('Prop 类测试', () => {
|
|||||||
mockedFn.mockClear();
|
mockedFn.mockClear();
|
||||||
|
|
||||||
prop.map(item => {
|
prop.map(item => {
|
||||||
mockedFn();
|
return mockedFn();
|
||||||
});
|
});
|
||||||
expect(mockedFn).toHaveBeenCalledTimes(5);
|
expect(mockedFn).toHaveBeenCalledTimes(5);
|
||||||
mockedFn.mockClear();
|
mockedFn.mockClear();
|
||||||
@ -361,7 +361,7 @@ describe('Prop 类测试', () => {
|
|||||||
const slotProp = new Prop(div?.getProps(), {
|
const slotProp = new Prop(div?.getProps(), {
|
||||||
type: 'JSSlot',
|
type: 'JSSlot',
|
||||||
value: [{
|
value: [{
|
||||||
componentName: 'Button'
|
componentName: 'Button',
|
||||||
}],
|
}],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
|
|
||||||
import '../../../fixtures/window';
|
import '../../../fixtures/window';
|
||||||
import { set } from '../../../utils';
|
import { set, delayObxTick } from '../../../utils';
|
||||||
import { Editor } from '@ali/lowcode-editor-core';
|
import { Editor } from '@ali/lowcode-editor-core';
|
||||||
import { Props, getConvertedExtraKey, getOriginalExtraKey } from '../../../../src/document/node/props/props';
|
import { Props, getConvertedExtraKey, getOriginalExtraKey, Prop, isProp, isValidArrayIndex } from '../../../../src/document/node/props/props';
|
||||||
import { Designer } from '../../../../src/designer/designer';
|
import { Designer } from '../../../../src/designer/designer';
|
||||||
import { Project } from '../../../../src/project/project';
|
import { Project } from '../../../../src/project/project';
|
||||||
import { DocumentModel } from '../../../../src/document/document-model';
|
import { DocumentModel } from '../../../../src/document/document-model';
|
||||||
import { Prop, isProp, isValidArrayIndex } from '../../../../src/document/node/props/props';
|
|
||||||
import { TransformStage } from '@ali/lowcode-types';
|
import { TransformStage } from '@ali/lowcode-types';
|
||||||
import { delayObxTick } from '../../../utils';
|
|
||||||
|
|
||||||
const mockedOwner = { componentName: 'Page' };
|
const mockedOwner = { componentName: 'Page' };
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ describe('Props 类测试', () => {
|
|||||||
const fromStashProp = props.get('l', true);
|
const fromStashProp = props.get('l', true);
|
||||||
const fromStashNestedProp = props.get('m.m1', true);
|
const fromStashNestedProp = props.get('m.m1', true);
|
||||||
fromStashProp.setValue('fromStashProp');
|
fromStashProp.setValue('fromStashProp');
|
||||||
fromStashNestedProp?.setValue('fromStashNestedProp')
|
fromStashNestedProp?.setValue('fromStashNestedProp');
|
||||||
|
|
||||||
await delayObxTick();
|
await delayObxTick();
|
||||||
expect(props.get('l').getValue()).toBe('fromStashProp');
|
expect(props.get('l').getValue()).toBe('fromStashProp');
|
||||||
@ -122,7 +122,7 @@ describe('Props 类测试', () => {
|
|||||||
it('import', () => {
|
it('import', () => {
|
||||||
props.import({
|
props.import({
|
||||||
x: 1,
|
x: 1,
|
||||||
y: true
|
y: true,
|
||||||
}, { loop: false });
|
}, { loop: false });
|
||||||
expect(props.export()).toEqual({
|
expect(props.export()).toEqual({
|
||||||
props: {
|
props: {
|
||||||
@ -131,7 +131,7 @@ describe('Props 类测试', () => {
|
|||||||
},
|
},
|
||||||
extras: {
|
extras: {
|
||||||
loop: false,
|
loop: false,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
props.import();
|
props.import();
|
||||||
@ -167,7 +167,7 @@ describe('Props 类测试', () => {
|
|||||||
|
|
||||||
it('迭代器 / map / forEach', () => {
|
it('迭代器 / map / forEach', () => {
|
||||||
const mockedFn = jest.fn();
|
const mockedFn = jest.fn();
|
||||||
for (let item of props) {
|
for (const item of props) {
|
||||||
mockedFn();
|
mockedFn();
|
||||||
}
|
}
|
||||||
expect(mockedFn).toHaveBeenCalledTimes(6);
|
expect(mockedFn).toHaveBeenCalledTimes(6);
|
||||||
@ -180,13 +180,13 @@ describe('Props 类测试', () => {
|
|||||||
mockedFn.mockClear();
|
mockedFn.mockClear();
|
||||||
|
|
||||||
props.map(item => {
|
props.map(item => {
|
||||||
mockedFn();
|
return mockedFn();
|
||||||
});
|
});
|
||||||
expect(mockedFn).toHaveBeenCalledTimes(6);
|
expect(mockedFn).toHaveBeenCalledTimes(6);
|
||||||
mockedFn.mockClear();
|
mockedFn.mockClear();
|
||||||
|
|
||||||
props.filter(item => {
|
props.filter(item => {
|
||||||
mockedFn();
|
return mockedFn();
|
||||||
});
|
});
|
||||||
expect(mockedFn).toHaveBeenCalledTimes(6);
|
expect(mockedFn).toHaveBeenCalledTimes(6);
|
||||||
mockedFn.mockClear();
|
mockedFn.mockClear();
|
||||||
@ -213,14 +213,14 @@ describe('Props 类测试', () => {
|
|||||||
|
|
||||||
it('export', () => {
|
it('export', () => {
|
||||||
expect(props.export().extras).toEqual({
|
expect(props.export().extras).toEqual({
|
||||||
condition: true
|
condition: true,
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('import', () => {
|
it('import', () => {
|
||||||
props.import([1], { loop: true });
|
props.import([1], { loop: true });
|
||||||
expect(props.export().extras).toEqual({
|
expect(props.export().extras).toEqual({
|
||||||
loop: true
|
loop: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
props.items[0]?.unset();
|
props.items[0]?.unset();
|
||||||
@ -242,4 +242,4 @@ describe('其他函数', () => {
|
|||||||
expect(getOriginalExtraKey('___a___')).toBe('a');
|
expect(getOriginalExtraKey('___a___')).toBe('a');
|
||||||
expect(getOriginalExtraKey('___a___.b')).toBe('a.b');
|
expect(getOriginalExtraKey('___a___.b')).toBe('a.b');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -8,7 +8,7 @@ it('valueToSource', () => {
|
|||||||
expect(valueToSource([{ a: 1 }])).toMatchSnapshot();
|
expect(valueToSource([{ a: 1 }])).toMatchSnapshot();
|
||||||
expect(valueToSource({ a: 1 })).toMatchSnapshot();
|
expect(valueToSource({ a: 1 })).toMatchSnapshot();
|
||||||
expect(valueToSource(null)).toMatchSnapshot();
|
expect(valueToSource(null)).toMatchSnapshot();
|
||||||
expect(valueToSource(function haha() {})).toMatchSnapshot();
|
expect(valueToSource(() => {})).toMatchSnapshot();
|
||||||
expect(valueToSource(new Map())).toMatchSnapshot();
|
expect(valueToSource(new Map())).toMatchSnapshot();
|
||||||
expect(valueToSource(new Set())).toMatchSnapshot();
|
expect(valueToSource(new Set())).toMatchSnapshot();
|
||||||
expect(valueToSource(/haha/)).toMatchSnapshot();
|
expect(valueToSource(/haha/)).toMatchSnapshot();
|
||||||
@ -19,10 +19,10 @@ it('valueToSource', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('getSource', () => {
|
it('getSource', () => {
|
||||||
expect(getSource({ __source: { a: 1 }})).toEqual({ a: 1 });
|
expect(getSource({ __source: { a: 1 } })).toEqual({ a: 1 });
|
||||||
expect(getSource()).toBe('');
|
expect(getSource()).toBe('');
|
||||||
const value = { abc: 1 };
|
const value = { abc: 1 };
|
||||||
getSource(value);
|
getSource(value);
|
||||||
expect(value).toHaveProperty('__source');
|
expect(value).toHaveProperty('__source');
|
||||||
expect(getSource(1)).toBe('1');
|
expect(getSource(1)).toBe('1');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -242,4 +242,4 @@ describe('选择区测试', () => {
|
|||||||
expect(selection.selected).toEqual(['page']);
|
expect(selection.selected).toEqual(['page']);
|
||||||
selectionChangeHandler.mockClear();
|
selectionChangeHandler.mockClear();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
Object.defineProperty(window, 'requestAnimationFrame', {
|
Object.defineProperty(window, 'requestAnimationFrame', {
|
||||||
value: null,
|
value: null,
|
||||||
})
|
});
|
||||||
|
|||||||
@ -962,8 +962,8 @@ export default {
|
|||||||
value: [{
|
value: [{
|
||||||
componentName: 'Text',
|
componentName: 'Text',
|
||||||
props: {},
|
props: {},
|
||||||
}]
|
}],
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
condition: true,
|
condition: true,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -46,12 +46,12 @@ export default {
|
|||||||
useFieldIdAsDomId: false,
|
useFieldIdAsDomId: false,
|
||||||
customClassName: {
|
customClassName: {
|
||||||
type: 'JSExpression',
|
type: 'JSExpression',
|
||||||
value: 'getFromSomewhere()'
|
value: 'getFromSomewhere()',
|
||||||
},
|
},
|
||||||
customClassName2: {
|
customClassName2: {
|
||||||
type: 'JSExpression',
|
type: 'JSExpression',
|
||||||
mock: { hi: 'mock' },
|
mock: { hi: 'mock' },
|
||||||
value: 'getFromSomewhere()'
|
value: 'getFromSomewhere()',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
extraPropA: 'haha',
|
extraPropA: 'haha',
|
||||||
@ -85,6 +85,6 @@ export default {
|
|||||||
customClassName: '',
|
customClassName: '',
|
||||||
},
|
},
|
||||||
extraPropA: 'haha',
|
extraPropA: 'haha',
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
if (!process.env.LISTENING_TO_UNHANDLED_REJECTION) {
|
if (!process.env.LISTENING_TO_UNHANDLED_REJECTION) {
|
||||||
process.on('unhandledRejection', reason => {
|
process.on('unhandledRejection', reason => {
|
||||||
throw reason;
|
throw reason;
|
||||||
})
|
});
|
||||||
// Avoid memory leak by adding too many listeners
|
// Avoid memory leak by adding too many listeners
|
||||||
process.env.LISTENING_TO_UNHANDLED_REJECTION = true;
|
process.env.LISTENING_TO_UNHANDLED_REJECTION = true;
|
||||||
}
|
}
|
||||||
|
|||||||
2
packages/designer/tests/fixtures/window.ts
vendored
2
packages/designer/tests/fixtures/window.ts
vendored
@ -17,4 +17,4 @@ Object.defineProperty(window, 'React', {
|
|||||||
value: {},
|
value: {},
|
||||||
});
|
});
|
||||||
|
|
||||||
window.scrollTo = () => {};
|
window.scrollTo = () => {};
|
||||||
|
|||||||
@ -59,8 +59,8 @@ describe('组件元数据处理', () => {
|
|||||||
addBuiltinComponentAction({
|
addBuiltinComponentAction({
|
||||||
name: 'new',
|
name: 'new',
|
||||||
content: {
|
content: {
|
||||||
action() {}
|
action() {},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
// availableActions 有 computed 缓存
|
// availableActions 有 computed 缓存
|
||||||
expect(meta.availableActions).toHaveLength(3);
|
expect(meta.availableActions).toHaveLength(3);
|
||||||
@ -68,4 +68,4 @@ describe('组件元数据处理', () => {
|
|||||||
expect(meta.availableActions[1].name).toBe('hide');
|
expect(meta.availableActions[1].name).toBe('hide');
|
||||||
expect(meta.availableActions[2].name).toBe('copy');
|
expect(meta.availableActions[2].name).toBe('copy');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -44,8 +44,8 @@ describe('plugin 测试', () => {
|
|||||||
return {
|
return {
|
||||||
x: 1,
|
x: 1,
|
||||||
y: 2,
|
y: 2,
|
||||||
}
|
};
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}, { test: 1 });
|
}, { test: 1 });
|
||||||
await pluginManager.init();
|
await pluginManager.init();
|
||||||
@ -168,5 +168,5 @@ describe('plugin 测试', () => {
|
|||||||
await plugin.dispose();
|
await plugin.dispose();
|
||||||
|
|
||||||
expect(pluginManager.has('demo1')).toBeFalsy();
|
expect(pluginManager.has('demo1')).toBeFalsy();
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -53,7 +53,7 @@ describe.only('Project 方法测试', () => {
|
|||||||
componentsTree: [{
|
componentsTree: [{
|
||||||
componentName: 'Page',
|
componentName: 'Page',
|
||||||
fileName: 'f1',
|
fileName: 'f1',
|
||||||
}]
|
}],
|
||||||
}, 'f1');
|
}, 'f1');
|
||||||
expect(project.currentDocument?.fileName).toBe('f1');
|
expect(project.currentDocument?.fileName).toBe('f1');
|
||||||
});
|
});
|
||||||
@ -63,13 +63,13 @@ describe.only('Project 方法测试', () => {
|
|||||||
componentsTree: [{
|
componentsTree: [{
|
||||||
componentName: 'Page',
|
componentName: 'Page',
|
||||||
fileName: 'f1',
|
fileName: 'f1',
|
||||||
}]
|
}],
|
||||||
}, true);
|
}, true);
|
||||||
project.setSchema({
|
project.setSchema({
|
||||||
componentsTree: [{
|
componentsTree: [{
|
||||||
componentName: 'Page',
|
componentName: 'Page',
|
||||||
props: { a: 1 },
|
props: { a: 1 },
|
||||||
}]
|
}],
|
||||||
});
|
});
|
||||||
expect(project.currentDocument?.rootNode?.propsData).toEqual({ a: 1 });
|
expect(project.currentDocument?.rootNode?.propsData).toEqual({ a: 1 });
|
||||||
});
|
});
|
||||||
@ -79,7 +79,7 @@ describe.only('Project 方法测试', () => {
|
|||||||
componentsTree: [{
|
componentsTree: [{
|
||||||
componentName: 'Page',
|
componentName: 'Page',
|
||||||
fileName: 'f1',
|
fileName: 'f1',
|
||||||
}]
|
}],
|
||||||
});
|
});
|
||||||
const doc1 = project.createDocument({
|
const doc1 = project.createDocument({
|
||||||
componentName: 'Page',
|
componentName: 'Page',
|
||||||
@ -179,4 +179,4 @@ describe.only('Project 方法测试', () => {
|
|||||||
project.setRendererReady({ a: 1 });
|
project.setRendererReady({ a: 1 });
|
||||||
expect(mockedFn).not.toHaveBeenCalled();
|
expect(mockedFn).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -47,8 +47,8 @@ const mockCreateElement = jest.fn((tagName) => {
|
|||||||
removeEventListener: mockRemoveEventListener,
|
removeEventListener: mockRemoveEventListener,
|
||||||
triggerEventListener: mockTriggerEventListener,
|
triggerEventListener: mockTriggerEventListener,
|
||||||
removeAttribute: mockRemoveAttribute,
|
removeAttribute: mockRemoveAttribute,
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
|
|
||||||
export function getMockDocument(): MockDocument {
|
export function getMockDocument(): MockDocument {
|
||||||
return {
|
return {
|
||||||
@ -108,4 +108,4 @@ export function getMockElement(tagName, options = {}) {
|
|||||||
// elem.ownerDocument = document;
|
// elem.ownerDocument = document;
|
||||||
// elem.ownerDocument.defaultView = window;
|
// elem.ownerDocument.defaultView = window;
|
||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,4 +5,4 @@ export function getMockEvent(target, options) {
|
|||||||
stopPropagation() {},
|
stopPropagation() {},
|
||||||
...options,
|
...options,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,4 +2,4 @@ export { getIdsFromSchema, getNodeFromSchemaById } from '@ali/lowcode-test-mate/
|
|||||||
export * from './bom';
|
export * from './bom';
|
||||||
export * from './event';
|
export * from './event';
|
||||||
export * from './renderer';
|
export * from './renderer';
|
||||||
export * from './misc';
|
export * from './misc';
|
||||||
|
|||||||
@ -11,7 +11,7 @@ export function set(obj: any, path: any, val: any) {
|
|||||||
} else {
|
} else {
|
||||||
acc[seg] = val;
|
acc[seg] = val;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return lodashSet(obj, path, val);
|
return lodashSet(obj, path, val);
|
||||||
}
|
}
|
||||||
@ -22,4 +22,4 @@ export function delay(ms) {
|
|||||||
|
|
||||||
export function delayObxTick() {
|
export function delayObxTick() {
|
||||||
return delay(100);
|
return delay(100);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,6 @@ export function getMockRenderer() {
|
|||||||
isSimulatorRenderer: true,
|
isSimulatorRenderer: true,
|
||||||
run() {
|
run() {
|
||||||
// console.log('renderer run');
|
// console.log('renderer run');
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
img {
|
img {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
filter: brightness(0) invert(1)
|
filter: brightness(0) invert(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&.only-icon {
|
&.only-icon {
|
||||||
|
|||||||
@ -177,7 +177,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.engine-block-field {
|
&.engine-block-field {
|
||||||
>.engine-field-head{
|
>.engine-field-head {
|
||||||
> .engine-field-title {
|
> .engine-field-title {
|
||||||
letter-spacing: 1px;
|
letter-spacing: 1px;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,18 +43,16 @@ const pages = Object.assign(project, {
|
|||||||
componentsTree.push(item.componentsTree[0]);
|
componentsTree.push(item.componentsTree[0]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (isPageDataV1(pages[0])) {
|
||||||
|
componentsTree = [pages[0].layout];
|
||||||
} else {
|
} else {
|
||||||
if (isPageDataV1(pages[0])) {
|
// if (!pages[0].componentsTree) return;
|
||||||
componentsTree = [pages[0].layout];
|
componentsTree = pages[0].componentsTree;
|
||||||
} else {
|
if (componentsTree[0]) {
|
||||||
// if (!pages[0].componentsTree) return;
|
componentsTree[0].componentName = componentsTree[0].componentName || 'Page';
|
||||||
componentsTree = pages[0].componentsTree;
|
// FIXME
|
||||||
if (componentsTree[0]) {
|
if (componentsTree[0].componentName === 'Page' || componentsTree[0].componentName === 'Component') {
|
||||||
componentsTree[0].componentName = componentsTree[0].componentName || 'Page';
|
componentsTree[0].methods = {};
|
||||||
// FIXME
|
|
||||||
if (componentsTree[0].componentName === 'Page' || componentsTree[0].componentName === 'Component') {
|
|
||||||
componentsTree[0].methods = {};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,4 +22,4 @@ export function filterReducer(props: any, node: Node): any {
|
|||||||
return newProps;
|
return newProps;
|
||||||
}
|
}
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ export function liveLifecycleReducer(props: any, node: Node) {
|
|||||||
didMount: 'componentDidMount',
|
didMount: 'componentDidMount',
|
||||||
willUnmount: 'componentWillUnMount',
|
willUnmount: 'componentWillUnMount',
|
||||||
};
|
};
|
||||||
const lifeCycles = props.lifeCycles;
|
const { lifeCycles } = props;
|
||||||
Object.keys(lifeCycleMap).forEach(key => {
|
Object.keys(lifeCycleMap).forEach(key => {
|
||||||
if (lifeCycles[key]) {
|
if (lifeCycles[key]) {
|
||||||
lifeCycles[lifeCycleMap[key]] = lifeCycles[key];
|
lifeCycles[lifeCycleMap[key]] = lifeCycles[key];
|
||||||
@ -24,4 +24,4 @@ export function liveLifecycleReducer(props: any, node: Node) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,4 +9,4 @@ export function nodeTopFixedReducer(props: any, node: Node) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,4 +47,4 @@ function appendStyleNode(props: any, styleProp: any, cssClass: string, cssId: st
|
|||||||
return `${b / 2}px`;
|
return `${b / 2}px`;
|
||||||
}).replace(/:root/g, `.${cssClass}`)));
|
}).replace(/:root/g, `.${cssClass}`)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
html.engine-cursor-move, html.engine-cursor-move * {
|
html.engine-cursor-move, html.engine-cursor-move * {
|
||||||
cursor: grabbing !important
|
cursor: grabbing !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
html.engine-cursor-copy, html.engine-cursor-copy * {
|
html.engine-cursor-copy, html.engine-cursor-copy * {
|
||||||
cursor: copy !important
|
cursor: copy !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
html.engine-cursor-ew-resize, html.engine-cursor-ew-resize * {
|
html.engine-cursor-ew-resize, html.engine-cursor-ew-resize * {
|
||||||
cursor: ew-resize !important
|
cursor: ew-resize !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
body, #engine {
|
body, #engine {
|
||||||
@ -107,7 +107,7 @@ html.engine-blur #engine {
|
|||||||
// font-size: 14px;
|
// font-size: 14px;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
html.engine-preview-mode {
|
html.engine-preview-mode {
|
||||||
.lc-left-area, .lc-right-area {
|
.lc-left-area, .lc-right-area {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
@ -124,5 +124,5 @@ html.engine-preview-mode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.lc-setter-mixed {
|
.lc-setter-mixed {
|
||||||
flex: 1
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,4 +5,4 @@ React.PropTypes = PropTypes;
|
|||||||
window.React = React;
|
window.React = React;
|
||||||
|
|
||||||
document.documentElement.requestFullscreen = () => {};
|
document.documentElement.requestFullscreen = () => {};
|
||||||
document.exitFullscreen = () => {};
|
document.exitFullscreen = () => {};
|
||||||
|
|||||||
@ -62,7 +62,7 @@ describe('drag-engine 测试', () => {
|
|||||||
|
|
||||||
designer.dragon.emitter.emit('drag', {
|
designer.dragon.emitter.emit('drag', {
|
||||||
dragObject: {
|
dragObject: {
|
||||||
nodes: [designer.currentDocument?.getNode('node_k1ow3cbo')]
|
nodes: [designer.currentDocument?.getNode('node_k1ow3cbo')],
|
||||||
},
|
},
|
||||||
originalEvent: mousedownEvt,
|
originalEvent: mousedownEvt,
|
||||||
});
|
});
|
||||||
@ -72,7 +72,7 @@ describe('drag-engine 测试', () => {
|
|||||||
|
|
||||||
designer.dragon.emitter.emit('dragend', {
|
designer.dragon.emitter.emit('dragend', {
|
||||||
dragObject: {
|
dragObject: {
|
||||||
nodes: [designer.currentDocument?.getNode('node_k1ow3cbo')]
|
nodes: [designer.currentDocument?.getNode('node_k1ow3cbo')],
|
||||||
},
|
},
|
||||||
originalEvent: mousedownEvt,
|
originalEvent: mousedownEvt,
|
||||||
});
|
});
|
||||||
@ -102,7 +102,7 @@ describe('drag-engine 测试', () => {
|
|||||||
|
|
||||||
designer.dragon.emitter.emit('drag', {
|
designer.dragon.emitter.emit('drag', {
|
||||||
dragObject: {
|
dragObject: {
|
||||||
nodes: [designer.currentDocument?.getNode('node_k1ow3cbo')]
|
nodes: [designer.currentDocument?.getNode('node_k1ow3cbo')],
|
||||||
},
|
},
|
||||||
originalEvent: mousedownEvt,
|
originalEvent: mousedownEvt,
|
||||||
});
|
});
|
||||||
@ -111,7 +111,7 @@ describe('drag-engine 测试', () => {
|
|||||||
|
|
||||||
designer.dragon.emitter.emit('dragend', {
|
designer.dragon.emitter.emit('dragend', {
|
||||||
dragObject: {
|
dragObject: {
|
||||||
nodes: [designer.currentDocument?.getNode('node_k1ow3cbo')]
|
nodes: [designer.currentDocument?.getNode('node_k1ow3cbo')],
|
||||||
},
|
},
|
||||||
originalEvent: mousedownEvt,
|
originalEvent: mousedownEvt,
|
||||||
});
|
});
|
||||||
@ -141,7 +141,7 @@ describe('drag-engine 测试', () => {
|
|||||||
|
|
||||||
designer.dragon.emitter.emit('drag', {
|
designer.dragon.emitter.emit('drag', {
|
||||||
dragObject: {
|
dragObject: {
|
||||||
nodes: [designer.currentDocument?.getNode('node_k1ow3cbo')]
|
nodes: [designer.currentDocument?.getNode('node_k1ow3cbo')],
|
||||||
},
|
},
|
||||||
originalEvent: mousedownEvt,
|
originalEvent: mousedownEvt,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -84,4 +84,4 @@ describe('API 多种导出场景测试', () => {
|
|||||||
expect(VisualEngine.logger).toBe(logger);
|
expect(VisualEngine.logger).toBe(logger);
|
||||||
expect(VisualEngine.Symbols).toBe(Symbols);
|
expect(VisualEngine.Symbols).toBe(Symbols);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -14,7 +14,6 @@ describe('VisualEngine.Project 相关 API 测试', () => {
|
|||||||
componentsMap: {},
|
componentsMap: {},
|
||||||
componentsTree: [formSchema],
|
componentsTree: [formSchema],
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('setConfig', () => {
|
it('setConfig', () => {
|
||||||
|
|||||||
@ -75,7 +75,7 @@ export class ListSetter extends Component<ArraySetterProps, ArraySetterState> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static onItemChange(onChange: Function|undefined, items: Array<SettingField>) {
|
static onItemChange(onChange: Function|undefined, items: SettingField[]) {
|
||||||
onChange && onChange(items.map(item => {
|
onChange && onChange(items.map(item => {
|
||||||
return item && item.getValue();
|
return item && item.getValue();
|
||||||
}));
|
}));
|
||||||
@ -91,7 +91,7 @@ export class ListSetter extends Component<ArraySetterProps, ArraySetterState> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 对itemsMap重新生成并刷新当前setter数据
|
// 对itemsMap重新生成并刷新当前setter数据
|
||||||
const newItems: Array<SettingField> = [];
|
const newItems: SettingField[] = [];
|
||||||
// const newItemsMap = {};
|
// const newItemsMap = {};
|
||||||
itemsMap.clear();
|
itemsMap.clear();
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
.lc-setter-list-add {
|
.lc-setter-list-add {
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: 8px;;
|
margin-top: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
@x-gap: 12px;
|
@x-gap: 12px;
|
||||||
@y-gap: 8px;
|
@y-gap: 8px;
|
||||||
|
|
||||||
.lc-settings-content > .lc-field:first-child > .lc-field-head{
|
.lc-settings-content > .lc-field:first-child > .lc-field-head {
|
||||||
border-top: none !important;
|
border-top: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +110,7 @@
|
|||||||
user-select: none;
|
user-select: none;
|
||||||
|
|
||||||
> .lc-field-icon {
|
> .lc-field-icon {
|
||||||
color: #8F9BB3;
|
color: #8f9bb3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
.lc-title-icon svg {
|
.lc-title-icon svg {
|
||||||
fill: #8F9BB3;
|
fill: #8f9bb3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.variable-binded {
|
.variable-binded {
|
||||||
@ -59,10 +59,10 @@
|
|||||||
.lc-block-field > .lc-field-body > .lc-setter-mixed{
|
.lc-block-field > .lc-field-body > .lc-setter-mixed{
|
||||||
|
|
||||||
}
|
}
|
||||||
.lc-accordion-field > .lc-field-body > .lc-setter-mixed{
|
.lc-accordion-field > .lc-field-body > .lc-setter-mixed {
|
||||||
position: static;
|
position: static;
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
> .lc-setter-actions{
|
> .lc-setter-actions {
|
||||||
right: 36px;
|
right: 36px;
|
||||||
top: 4px;
|
top: 4px;
|
||||||
transform: none;
|
transform: none;
|
||||||
|
|||||||
@ -46,7 +46,7 @@
|
|||||||
.lc-settings-notice {
|
.lc-settings-notice {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-family: PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica,Arial,sans-serif;
|
font-family: PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica, Arial, sans-serif;
|
||||||
color: var(--color-text ,rgba(0,0,0,.6));
|
color: var(--color-text ,rgba(0,0,0,.6));
|
||||||
padding: 50px 15px 0;
|
padding: 50px 15px 0;
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@
|
|||||||
.lc-settings-tabs-content {
|
.lc-settings-tabs-content {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 70px;
|
top: 70px;
|
||||||
left:0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
.next-tabs-tabpane {
|
.next-tabs-tabpane {
|
||||||
|
|||||||
@ -23,8 +23,6 @@ type WillDetachMember = () => void;
|
|||||||
|
|
||||||
@observer
|
@observer
|
||||||
export default class StageBox extends Component<StageBoxProps> {
|
export default class StageBox extends Component<StageBoxProps> {
|
||||||
|
|
||||||
|
|
||||||
static defaultProps = StageBoxDefaultProps;
|
static defaultProps = StageBoxDefaultProps;
|
||||||
|
|
||||||
static displayName = 'StageBox';
|
static displayName = 'StageBox';
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
import * as editorCabin from '@ali/lowcode-editor-core';
|
import * as editorCabin from '@ali/lowcode-editor-core';
|
||||||
|
|
||||||
export type RegisteredSetter = editorCabin.RegisteredSetter;
|
export type RegisteredSetter = editorCabin.RegisteredSetter;
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
import * as skeletonCabin from '@ali/lowcode-editor-skeleton';
|
import * as skeletonCabin from '@ali/lowcode-editor-skeleton';
|
||||||
|
|
||||||
export type IWidgetBaseConfig = skeletonCabin.IWidgetBaseConfig;
|
export type IWidgetBaseConfig = skeletonCabin.IWidgetBaseConfig;
|
||||||
|
|||||||
@ -117,7 +117,7 @@
|
|||||||
transform: scale(0.8);
|
transform: scale(0.8);
|
||||||
transform-origin: top;
|
transform-origin: top;
|
||||||
color: white;
|
color: white;
|
||||||
text-shadow: 0px 0px 2px black;
|
text-shadow: 0 0 2px black;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@
|
|||||||
transform: scale(0.8);
|
transform: scale(0.8);
|
||||||
transform-origin: top;
|
transform-origin: top;
|
||||||
color: white;
|
color: white;
|
||||||
text-shadow: 0px 0px 2px black;
|
text-shadow: 0 0 2px black;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import {
|
|||||||
adapter,
|
adapter,
|
||||||
addonRendererFactory,
|
addonRendererFactory,
|
||||||
tempRendererFactory,
|
tempRendererFactory,
|
||||||
rendererFactory
|
rendererFactory,
|
||||||
} from '@ali/lowcode-renderer-core';
|
} from '@ali/lowcode-renderer-core';
|
||||||
import pageRendererFactory from './renderer/page';
|
import pageRendererFactory from './renderer/page';
|
||||||
import componentRendererFactory from './renderer/component';
|
import componentRendererFactory from './renderer/component';
|
||||||
@ -38,7 +38,7 @@ function factory() {
|
|||||||
isValidComponent(obj: any) {
|
isValidComponent(obj: any) {
|
||||||
return obj?.prototype?.setState || obj?.prototype instanceof Component;
|
return obj?.prototype?.setState || obj?.prototype instanceof Component;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const RaxRenderer = factory();
|
const RaxRenderer = factory();
|
||||||
@ -47,6 +47,6 @@ const Engine = RaxRenderer;
|
|||||||
export {
|
export {
|
||||||
Engine,
|
Engine,
|
||||||
CompFactory,
|
CompFactory,
|
||||||
}
|
};
|
||||||
|
|
||||||
export default RaxRenderer;
|
export default RaxRenderer;
|
||||||
|
|||||||
@ -11,7 +11,7 @@ export default function raxBlockRendererFactory() {
|
|||||||
return '区块 schema 结构异常!';
|
return '区块 schema 结构异常!';
|
||||||
}
|
}
|
||||||
that.__debug(`render - ${__schema.fileName}`);
|
that.__debug(`render - ${__schema.fileName}`);
|
||||||
|
|
||||||
const children = ((context) => {
|
const children = ((context) => {
|
||||||
that.context = context;
|
that.context = context;
|
||||||
that.__generateCtx({});
|
that.__generateCtx({});
|
||||||
@ -20,5 +20,5 @@ export default function raxBlockRendererFactory() {
|
|||||||
});
|
});
|
||||||
return that.__renderContextConsumer(children);
|
return that.__renderContextConsumer(children);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,8 +29,8 @@ export default function raxComponentRendererFactory() {
|
|||||||
if (noContainer) {
|
if (noContainer) {
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
return that.__renderContent(content);
|
return that.__renderContent(content);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ export default function raxPageRendererFactory() {
|
|||||||
return '页面 schema 结构异常!';
|
return '页面 schema 结构异常!';
|
||||||
}
|
}
|
||||||
that.__debug(`render - ${__schema?.fileName}`);
|
that.__debug(`render - ${__schema?.fileName}`);
|
||||||
|
|
||||||
const { Page } = __components as any;
|
const { Page } = __components as any;
|
||||||
if (Page) {
|
if (Page) {
|
||||||
const children = ((context) => {
|
const children = ((context) => {
|
||||||
@ -26,8 +26,8 @@ export default function raxPageRendererFactory() {
|
|||||||
});
|
});
|
||||||
return that.__renderContextConsumer(children);
|
return that.__renderContextConsumer(children);
|
||||||
}
|
}
|
||||||
|
|
||||||
return that.__renderContent(that.__renderContextProvider({ pageContext: that }));
|
return that.__renderContent(that.__renderContextProvider({ pageContext: that }));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,16 +22,16 @@ function matchPath(route, pathname, parentParams) {
|
|||||||
path = path || '';
|
path = path || '';
|
||||||
|
|
||||||
const regexpCacheKey = `${path}|${end}|${strict}|${sensitive}`;
|
const regexpCacheKey = `${path}|${end}|${strict}|${sensitive}`;
|
||||||
const keysCacheKey = regexpCacheKey + '|';
|
const keysCacheKey = `${regexpCacheKey }|`;
|
||||||
|
|
||||||
let regexp = cache[regexpCacheKey];
|
let regexp = cache[regexpCacheKey];
|
||||||
let keys = cache[keysCacheKey] || [];
|
const keys = cache[keysCacheKey] || [];
|
||||||
|
|
||||||
if (!regexp) {
|
if (!regexp) {
|
||||||
regexp = pathToRegexp(path, keys, {
|
regexp = pathToRegexp(path, keys, {
|
||||||
end,
|
end,
|
||||||
strict,
|
strict,
|
||||||
sensitive
|
sensitive,
|
||||||
});
|
});
|
||||||
cache[regexpCacheKey] = regexp;
|
cache[regexpCacheKey] = regexp;
|
||||||
cache[keysCacheKey] = keys;
|
cache[keysCacheKey] = keys;
|
||||||
@ -132,7 +132,7 @@ const router = {
|
|||||||
router.handles[handleId - 1] = null;
|
router.handles[handleId - 1] = null;
|
||||||
},
|
},
|
||||||
triggerHandles(component) {
|
triggerHandles(component) {
|
||||||
router.handles.map((handle) => {
|
router.handles.forEach((handle) => {
|
||||||
handle && handle(component);
|
handle && handle(component);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -145,7 +145,7 @@ const router = {
|
|||||||
const matched = matchRoute(
|
const matched = matchRoute(
|
||||||
parent,
|
parent,
|
||||||
parent.path,
|
parent.path,
|
||||||
fullpath
|
fullpath,
|
||||||
);
|
);
|
||||||
|
|
||||||
function next(parent) {
|
function next(parent) {
|
||||||
@ -156,7 +156,7 @@ const router = {
|
|||||||
return router.errorHandler(error, router.history.location);
|
return router.errorHandler(error, router.history.location);
|
||||||
}
|
}
|
||||||
|
|
||||||
let component = current.$.route.component;
|
let { component } = current.$.route;
|
||||||
if (typeof component === 'function') {
|
if (typeof component === 'function') {
|
||||||
component = component(current.$.params, router.history.location);
|
component = component(current.$.params, router.history.location);
|
||||||
}
|
}
|
||||||
@ -177,7 +177,7 @@ const router = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return next(parent);
|
return next(parent);
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function matchLocation({ pathname }) {
|
function matchLocation({ pathname }) {
|
||||||
@ -216,7 +216,7 @@ export function useRouter(routerConfig) {
|
|||||||
let newPathes = '';
|
let newPathes = '';
|
||||||
if (routerConfig) {
|
if (routerConfig) {
|
||||||
_routerConfig = routerConfig;
|
_routerConfig = routerConfig;
|
||||||
const routes = _routerConfig.routes;
|
const { routes } = _routerConfig;
|
||||||
router.root = Array.isArray(routes) ? { routes } : routes;
|
router.root = Array.isArray(routes) ? { routes } : routes;
|
||||||
if (Array.isArray(routes)) {
|
if (Array.isArray(routes)) {
|
||||||
newPathes = routes.map(it => it.path).join(',');
|
newPathes = routes.map(it => it.path).join(',');
|
||||||
@ -230,7 +230,7 @@ export function useRouter(routerConfig) {
|
|||||||
pathes = newPathes;
|
pathes = newPathes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (unlisten) {
|
if (unlisten) {
|
||||||
unlisten();
|
unlisten();
|
||||||
@ -242,8 +242,8 @@ export function useRouter(routerConfig) {
|
|||||||
handleId = null;
|
handleId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const history = _routerConfig.history;
|
const { history } = _routerConfig;
|
||||||
const routes = _routerConfig.routes;
|
const { routes } = _routerConfig;
|
||||||
|
|
||||||
router.root = Array.isArray(routes) ? { routes } : routes;
|
router.root = Array.isArray(routes) ? { routes } : routes;
|
||||||
|
|
||||||
@ -278,11 +278,11 @@ export function useRouter(routerConfig) {
|
|||||||
|
|
||||||
export function withRouter(Component) {
|
export function withRouter(Component) {
|
||||||
function Wrapper(props) {
|
function Wrapper(props) {
|
||||||
const history = router.history;
|
const { history } = router;
|
||||||
return createElement(Component, { ...props, history, location: history.location });
|
return createElement(Component, { ...props, history, location: history.location });
|
||||||
};
|
}
|
||||||
|
|
||||||
Wrapper.displayName = 'withRouter(' + (Component.displayName || Component.name) + ')';
|
Wrapper.displayName = `withRouter(${ Component.displayName || Component.name })`;
|
||||||
Wrapper.WrappedComponent = Component;
|
Wrapper.WrappedComponent = Component;
|
||||||
return Wrapper;
|
return Wrapper;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,13 +78,13 @@ export const Routes = (props: {
|
|||||||
routes: documentInstances.map(instance => {
|
routes: documentInstances.map(instance => {
|
||||||
return {
|
return {
|
||||||
path: instance.path,
|
path: instance.path,
|
||||||
component: (props: any) => <Renderer key={instance.id} rendererContainer={rendererContainer} documentInstance={instance} {...props} />
|
component: (props: any) => <Renderer key={instance.id} rendererContainer={rendererContainer} documentInstance={instance} {...props} />,
|
||||||
};
|
};
|
||||||
})
|
}),
|
||||||
};
|
};
|
||||||
const { component } = useRouter(routes);
|
const { component } = useRouter(routes);
|
||||||
return component;
|
return component;
|
||||||
}
|
};
|
||||||
|
|
||||||
function ucfirst(s: string) {
|
function ucfirst(s: string) {
|
||||||
return s.charAt(0).toUpperCase() + s.substring(1);
|
return s.charAt(0).toUpperCase() + s.substring(1);
|
||||||
@ -116,7 +116,7 @@ class Layout extends Component<{ rendererContainer: SimulatorRendererContainer }
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { rendererContainer, children } = this.props;
|
const { rendererContainer, children } = this.props;
|
||||||
const layout = rendererContainer.layout;
|
const { layout } = rendererContainer;
|
||||||
|
|
||||||
if (layout) {
|
if (layout) {
|
||||||
const { Component, props, componentName } = layout;
|
const { Component, props, componentName } = layout;
|
||||||
@ -180,7 +180,6 @@ class Renderer extends Component<{
|
|||||||
components={renderer.components}
|
components={renderer.components}
|
||||||
appHelper={renderer.context}
|
appHelper={renderer.context}
|
||||||
context={renderer.context}
|
context={renderer.context}
|
||||||
appHelper={renderer.context}
|
|
||||||
device={device}
|
device={device}
|
||||||
designMode={renderer.designMode}
|
designMode={renderer.designMode}
|
||||||
key={this.key}
|
key={this.key}
|
||||||
|
|||||||
@ -9,15 +9,15 @@ html.engine-design-mode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
html.engine-cursor-move, html.engine-cursor-move * {
|
html.engine-cursor-move, html.engine-cursor-move * {
|
||||||
cursor: grabbing !important
|
cursor: grabbing !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
html.engine-cursor-copy, html.engine-cursor-copy * {
|
html.engine-cursor-copy, html.engine-cursor-copy * {
|
||||||
cursor: copy !important
|
cursor: copy !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
html.engine-cursor-ew-resize, html.engine-cursor-ew-resize * {
|
html.engine-cursor-ew-resize, html.engine-cursor-ew-resize * {
|
||||||
cursor: ew-resize !important
|
cursor: ew-resize !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
@ -100,13 +100,13 @@ body.engine-document {
|
|||||||
.next-year-picker,
|
.next-year-picker,
|
||||||
.next-breadcrumb-item,.next-calendar-header,.next-calendar-table {
|
.next-breadcrumb-item,.next-calendar-header,.next-calendar-table {
|
||||||
pointer-events: none !important;
|
pointer-events: none !important;
|
||||||
}*/
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
.engine-live-editing {
|
.engine-live-editing {
|
||||||
cursor: text;
|
cursor: text;
|
||||||
outline: none;
|
outline: none;
|
||||||
box-shadow: 0 0 0px 2px rgb(102, 188, 92);
|
box-shadow: 0 0 0 2px rgb(102, 188, 92);
|
||||||
user-select: text;
|
user-select: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,6 +114,6 @@ body.engine-document {
|
|||||||
height: 100vh;
|
height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.luna-page{
|
.luna-page {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -126,7 +126,7 @@ export class DocumentInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get path(): string {
|
get path(): string {
|
||||||
return '/' + this.document.fileName;
|
return `/${ this.document.fileName}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
get id() {
|
get id() {
|
||||||
@ -157,7 +157,7 @@ export class DocumentInstance {
|
|||||||
|
|
||||||
mountInstance(id: string, instance: any) {
|
mountInstance(id: string, instance: any) {
|
||||||
const docId = this.document.id;
|
const docId = this.document.id;
|
||||||
const instancesMap = this.instancesMap;
|
const { instancesMap } = this;
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
let instances = this.instancesMap.get(id);
|
let instances = this.instancesMap.get(id);
|
||||||
if (instances) {
|
if (instances) {
|
||||||
@ -187,7 +187,7 @@ export class DocumentInstance {
|
|||||||
origUnmount = origUnmount.origUnmount;
|
origUnmount = origUnmount.origUnmount;
|
||||||
}
|
}
|
||||||
// hack! delete instance from map
|
// hack! delete instance from map
|
||||||
const newUnmount = function(this: any) {
|
const newUnmount = function (this: any) {
|
||||||
unmountIntance(id, instance);
|
unmountIntance(id, instance);
|
||||||
origUnmount && origUnmount.call(this);
|
origUnmount && origUnmount.call(this);
|
||||||
};
|
};
|
||||||
@ -314,11 +314,11 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
},
|
},
|
||||||
back() {
|
back() {
|
||||||
history.back();
|
history.back();
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
legaoBuiltins: {
|
legaoBuiltins: {
|
||||||
getUrlParams() {
|
getUrlParams() {
|
||||||
const search = history.location.search;
|
const { search } = history.location;
|
||||||
return parseQuery(search);
|
return parseQuery(search);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -396,8 +396,6 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
subs.unshift(sub);
|
subs.unshift(sub);
|
||||||
componentName = paths.join('.');
|
componentName = paths.join('.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getNodeInstance(dom: HTMLElement): NodeInstance<any> | null {
|
getNodeInstance(dom: HTMLElement): NodeInstance<any> | null {
|
||||||
@ -535,7 +533,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
};
|
};
|
||||||
viewProps._leaf = _leaf;
|
viewProps._leaf = _leaf;
|
||||||
return createElement(Comp, viewProps, children);
|
return createElement(Comp, viewProps, children);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -562,7 +560,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
document.body.classList.add('engine-document'); // important! Stylesheet.invoke depends
|
document.body.classList.add('engine-document'); // important! Stylesheet.invoke depends
|
||||||
|
|
||||||
raxRender(createElement(SimulatorRendererView, {
|
raxRender(createElement(SimulatorRendererView, {
|
||||||
rendererContainer: this
|
rendererContainer: this,
|
||||||
}), container, {
|
}), container, {
|
||||||
driver: DriverUniversal,
|
driver: DriverUniversal,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -17,4 +17,4 @@ module.exports = {
|
|||||||
'!**/node_modules/**',
|
'!**/node_modules/**',
|
||||||
'!**/vendor/**',
|
'!**/vendor/**',
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import {
|
|||||||
blockRendererFactory,
|
blockRendererFactory,
|
||||||
addonRendererFactory,
|
addonRendererFactory,
|
||||||
tempRendererFactory,
|
tempRendererFactory,
|
||||||
rendererFactory
|
rendererFactory,
|
||||||
} from '@ali/lowcode-renderer-core';
|
} from '@ali/lowcode-renderer-core';
|
||||||
import ConfigProvider from '@alifd/next/lib/config-provider';
|
import ConfigProvider from '@alifd/next/lib/config-provider';
|
||||||
|
|
||||||
@ -40,11 +40,11 @@ function factory() {
|
|||||||
constructor(props: any, context: any) {
|
constructor(props: any, context: any) {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
isValidComponent(obj: any) {
|
isValidComponent(obj: any) {
|
||||||
return obj?.prototype?.isReactComponent || obj?.prototype instanceof Component;
|
return obj?.prototype?.isReactComponent || obj?.prototype instanceof Component;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default factory();
|
export default factory();
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -103,7 +103,7 @@ class Layout extends Component<{ rendererContainer: SimulatorRendererContainer }
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { rendererContainer, children } = this.props;
|
const { rendererContainer, children } = this.props;
|
||||||
const layout = rendererContainer.layout;
|
const { layout } = rendererContainer;
|
||||||
if (layout) {
|
if (layout) {
|
||||||
const { Component, props, componentName } = layout;
|
const { Component, props, componentName } = layout;
|
||||||
if (Component) {
|
if (Component) {
|
||||||
@ -128,8 +128,8 @@ class Layout extends Component<{ rendererContainer: SimulatorRendererContainer }
|
|||||||
|
|
||||||
@observer
|
@observer
|
||||||
class Renderer extends Component<{
|
class Renderer extends Component<{
|
||||||
rendererContainer: SimulatorRendererContainer;
|
rendererContainer: SimulatorRendererContainer;
|
||||||
documentInstance: DocumentInstance }
|
documentInstance: DocumentInstance }
|
||||||
> {
|
> {
|
||||||
shouldComponentUpdate() {
|
shouldComponentUpdate() {
|
||||||
return false;
|
return false;
|
||||||
@ -205,9 +205,9 @@ class Renderer extends Component<{
|
|||||||
onCompGetRef={(schema: any, ref: ReactInstance | null) => {
|
onCompGetRef={(schema: any, ref: ReactInstance | null) => {
|
||||||
documentInstance.mountInstance(schema.id, ref);
|
documentInstance.mountInstance(schema.id, ref);
|
||||||
}}
|
}}
|
||||||
//onCompGetCtx={(schema: any, ctx: object) => {
|
// onCompGetCtx={(schema: any, ctx: object) => {
|
||||||
// documentInstance.mountContext(schema.id, ctx);
|
// documentInstance.mountContext(schema.id, ctx);
|
||||||
//}}
|
// }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,7 +80,7 @@ body.engine-document {
|
|||||||
.engine-live-editing {
|
.engine-live-editing {
|
||||||
cursor: text;
|
cursor: text;
|
||||||
outline: none;
|
outline: none;
|
||||||
box-shadow: 0 0 0px 2px rgb(102, 188, 92);
|
box-shadow: 0 0 0 2px rgb(102, 188, 92);
|
||||||
user-select: text;
|
user-select: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -96,7 +96,7 @@ export class DocumentInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get path(): string {
|
get path(): string {
|
||||||
return '/' + this.document.fileName;
|
return `/${ this.document.fileName}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
get id() {
|
get id() {
|
||||||
@ -116,7 +116,7 @@ export class DocumentInstance {
|
|||||||
|
|
||||||
mountInstance(id: string, instance: ReactInstance | null) {
|
mountInstance(id: string, instance: ReactInstance | null) {
|
||||||
const docId = this.document.id;
|
const docId = this.document.id;
|
||||||
const instancesMap = this.instancesMap;
|
const { instancesMap } = this;
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
let instances = this.instancesMap.get(id);
|
let instances = this.instancesMap.get(id);
|
||||||
if (instances) {
|
if (instances) {
|
||||||
@ -265,7 +265,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
},
|
},
|
||||||
legaoBuiltins: {
|
legaoBuiltins: {
|
||||||
getUrlParams() {
|
getUrlParams() {
|
||||||
const search = history.location.search;
|
const { search } = history.location;
|
||||||
return parseQuery(search);
|
return parseQuery(search);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -343,9 +343,9 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
/**
|
/**
|
||||||
* 加载资源
|
* 加载资源
|
||||||
*/
|
*/
|
||||||
load(asset: Asset): Promise<any> {
|
// load(asset: Asset): Promise<any> {
|
||||||
return loader.load(asset);
|
// return loader.load(asset);
|
||||||
}
|
// }
|
||||||
|
|
||||||
getComponent(componentName: string) {
|
getComponent(componentName: string) {
|
||||||
const paths = componentName.split('.');
|
const paths = componentName.split('.');
|
||||||
@ -364,8 +364,6 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
subs.unshift(sub);
|
subs.unshift(sub);
|
||||||
componentName = paths.join('.');
|
componentName = paths.join('.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getClosestNodeInstance(from: ReactInstance, nodeId?: string): NodeInstance<ReactInstance> | null {
|
getClosestNodeInstance(from: ReactInstance, nodeId?: string): NodeInstance<ReactInstance> | null {
|
||||||
@ -437,7 +435,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
};
|
};
|
||||||
viewProps._leaf = _leaf;
|
viewProps._leaf = _leaf;
|
||||||
return createElement(Comp, viewProps, children);
|
return createElement(Comp, viewProps, children);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,9 +7,13 @@ export enum Env {
|
|||||||
|
|
||||||
class Adapter {
|
class Adapter {
|
||||||
runtime: IRuntime;
|
runtime: IRuntime;
|
||||||
|
|
||||||
builtinModules = ['Component', 'PureComponent', 'createElement', 'createContext', 'forwardRef', 'findDOMNode'];
|
builtinModules = ['Component', 'PureComponent', 'createElement', 'createContext', 'forwardRef', 'findDOMNode'];
|
||||||
|
|
||||||
env: Env;
|
env: Env;
|
||||||
|
|
||||||
renderers: IRendererModules;
|
renderers: IRendererModules;
|
||||||
|
|
||||||
configProvider: any;
|
configProvider: any;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|||||||
@ -26,9 +26,7 @@ export default function visualDomFactory() {
|
|||||||
[
|
[
|
||||||
createElement('span', { className: 'title' }, title || label || text || __componentName),
|
createElement('span', { className: 'title' }, title || label || text || __componentName),
|
||||||
createElement('div', { className: 'content' }, mainContent),
|
createElement('div', { className: 'content' }, mainContent),
|
||||||
]
|
]));
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,9 +3,9 @@ import adapter from '../adapter';
|
|||||||
export function compWrapper(Comp: any) {
|
export function compWrapper(Comp: any) {
|
||||||
const { createElement, Component, forwardRef } = adapter.getRuntime();
|
const { createElement, Component, forwardRef } = adapter.getRuntime();
|
||||||
class Wrapper extends Component {
|
class Wrapper extends Component {
|
||||||
constructor(props: any, context: any) {
|
// constructor(props: any, context: any) {
|
||||||
super(props, context)
|
// super(props, context);
|
||||||
}
|
// }
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { forwardRef } = this.props;
|
const { forwardRef } = this.props;
|
||||||
|
|||||||
@ -7,6 +7,7 @@ export default function addonRendererFactory() {
|
|||||||
const BaseRenderer = baseRendererFactory();
|
const BaseRenderer = baseRendererFactory();
|
||||||
return class AddonRenderer extends BaseRenderer {
|
return class AddonRenderer extends BaseRenderer {
|
||||||
static dislayName = 'addon-renderer';
|
static dislayName = 'addon-renderer';
|
||||||
|
|
||||||
__namespace = 'addon';
|
__namespace = 'addon';
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import {
|
|||||||
capitalizeFirstLetter,
|
capitalizeFirstLetter,
|
||||||
DataHelper,
|
DataHelper,
|
||||||
isI18n,
|
isI18n,
|
||||||
isVariable
|
isVariable,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
import { IRendererProps, ISchema, IInfo, ComponentModel, IRenderer } from '../types';
|
import { IRendererProps, ISchema, IInfo, ComponentModel, IRenderer } from '../types';
|
||||||
import { compWrapper } from '../hoc';
|
import { compWrapper } from '../hoc';
|
||||||
@ -72,7 +72,7 @@ export default function baseRenererFactory() {
|
|||||||
this.__debug(`constructor - ${props?.__schema?.fileName}`);
|
this.__debug(`constructor - ${props?.__schema?.fileName}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
__beforeInit(props: IRendererProps) { }
|
__beforeInit(/* props: IRendererProps */) { }
|
||||||
|
|
||||||
__init(props: IRendererProps) {
|
__init(props: IRendererProps) {
|
||||||
this.appHelper = props.__appHelper;
|
this.appHelper = props.__appHelper;
|
||||||
@ -82,7 +82,7 @@ export default function baseRenererFactory() {
|
|||||||
this.__initI18nAPIs();
|
this.__initI18nAPIs();
|
||||||
}
|
}
|
||||||
|
|
||||||
__afterInit(props: IRendererProps) { }
|
__afterInit(/* props: IRendererProps */) { }
|
||||||
|
|
||||||
static getDerivedStateFromProps(props: IRendererProps, state: any) {
|
static getDerivedStateFromProps(props: IRendererProps, state: any) {
|
||||||
debug('getDerivedStateFromProps');
|
debug('getDerivedStateFromProps');
|
||||||
@ -470,7 +470,7 @@ export default function baseRenererFactory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let child: any = null;
|
let child: any = null;
|
||||||
if (/*!isFileSchema(schema) && */!!_children) {
|
if (/*! isFileSchema(schema) && */_children) {
|
||||||
child = this.__createVirtualDom(
|
child = this.__createVirtualDom(
|
||||||
isJSExpression(_children) ? parseExpression(_children, self) : _children,
|
isJSExpression(_children) ? parseExpression(_children, self) : _children,
|
||||||
self,
|
self,
|
||||||
@ -527,7 +527,7 @@ export default function baseRenererFactory() {
|
|||||||
if (!Array.isArray(schema.loop)) return null;
|
if (!Array.isArray(schema.loop)) return null;
|
||||||
const itemArg = (schema.loopArgs && schema.loopArgs[0]) || 'item';
|
const itemArg = (schema.loopArgs && schema.loopArgs[0]) || 'item';
|
||||||
const indexArg = (schema.loopArgs && schema.loopArgs[1]) || 'index';
|
const indexArg = (schema.loopArgs && schema.loopArgs[1]) || 'index';
|
||||||
return schema.loop.map((item: Array<string>, i: number) => {
|
return schema.loop.map((item: string[], i: number) => {
|
||||||
const loopSelf: any = {
|
const loopSelf: any = {
|
||||||
[itemArg]: item,
|
[itemArg]: item,
|
||||||
[indexArg]: i,
|
[indexArg]: i,
|
||||||
@ -679,13 +679,13 @@ export default function baseRenererFactory() {
|
|||||||
|
|
||||||
__initDebug = () => {
|
__initDebug = () => {
|
||||||
this.__logger = Debug(`renderer:${this.__namespace || 'base'}`);
|
this.__logger = Debug(`renderer:${this.__namespace || 'base'}`);
|
||||||
}
|
};
|
||||||
|
|
||||||
__debug = (msg: string = '') => {
|
__debug = (msg = '') => {
|
||||||
if (this.__logger) {
|
if (this.__logger) {
|
||||||
this.__logger(`${this.__namespace}.${msg}`);
|
this.__logger(`${this.__namespace}.${msg}`);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
__renderContextProvider = (customProps?: object, children?: any) => {
|
__renderContextProvider = (customProps?: object, children?: any) => {
|
||||||
customProps = customProps || {};
|
customProps = customProps || {};
|
||||||
@ -695,13 +695,14 @@ export default function baseRenererFactory() {
|
|||||||
...this.context,
|
...this.context,
|
||||||
blockContext: this,
|
blockContext: this,
|
||||||
...customProps,
|
...customProps,
|
||||||
}, children
|
},
|
||||||
|
children,
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
__renderContextConsumer = (children: any) => {
|
__renderContextConsumer = (children: any) => {
|
||||||
return createElement(AppContext.Consumer, {}, children);
|
return createElement(AppContext.Consumer, {}, children);
|
||||||
}
|
};
|
||||||
|
|
||||||
__renderComp(Comp: any, ctxProps: object) {
|
__renderComp(Comp: any, ctxProps: object) {
|
||||||
const { __schema } = this.props;
|
const { __schema } = this.props;
|
||||||
@ -744,8 +745,8 @@ export default function baseRenererFactory() {
|
|||||||
|
|
||||||
const buitin = capitalizeFirstLetter(this.__namespace);
|
const buitin = capitalizeFirstLetter(this.__namespace);
|
||||||
const componentNames = [buitin, ...extraComponents];
|
const componentNames = [buitin, ...extraComponents];
|
||||||
return !isSchema(schema, true) || !componentNames.includes(schema.componentName)
|
return !isSchema(schema, true) || !componentNames.includes(schema.componentName);
|
||||||
}
|
};
|
||||||
|
|
||||||
get requestHandlersMap() {
|
get requestHandlersMap() {
|
||||||
return this.appHelper?.requestHandlersMap;
|
return this.appHelper?.requestHandlersMap;
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
import classnames from 'classnames';
|
|
||||||
import baseRendererFactory from './base';
|
import baseRendererFactory from './base';
|
||||||
import { IRendererProps } from '../types';
|
import { IRendererProps } from '../types';
|
||||||
import { getFileCssName } from '../utils';
|
|
||||||
|
|
||||||
export default function blockRendererFactory() {
|
export default function blockRendererFactory() {
|
||||||
const BaseRenderer = baseRendererFactory();
|
const BaseRenderer = baseRendererFactory();
|
||||||
return class BlockRenderer extends BaseRenderer {
|
return class BlockRenderer extends BaseRenderer {
|
||||||
static dislayName = 'block-renderer';
|
static dislayName = 'block-renderer';
|
||||||
|
|
||||||
__namespace = 'block';
|
__namespace = 'block';
|
||||||
|
|
||||||
__afterInit(props: IRendererProps) {
|
__afterInit(props: IRendererProps) {
|
||||||
|
|||||||
@ -5,6 +5,7 @@ export default function componentRendererFactory() {
|
|||||||
const BaseRenderer = baseRendererFactory();
|
const BaseRenderer = baseRendererFactory();
|
||||||
return class CompRenderer extends BaseRenderer {
|
return class CompRenderer extends BaseRenderer {
|
||||||
static dislayName = 'comp-renderer';
|
static dislayName = 'comp-renderer';
|
||||||
|
|
||||||
__namespace = 'component';
|
__namespace = 'component';
|
||||||
|
|
||||||
__afterInit(props: IRendererProps) {
|
__afterInit(props: IRendererProps) {
|
||||||
|
|||||||
@ -6,6 +6,7 @@ export default function pageRendererFactory() {
|
|||||||
const BaseRenderer = baseRendererFactory();
|
const BaseRenderer = baseRendererFactory();
|
||||||
return class PageRenderer extends BaseRenderer {
|
return class PageRenderer extends BaseRenderer {
|
||||||
static dislayName = 'page-renderer';
|
static dislayName = 'page-renderer';
|
||||||
|
|
||||||
__namespace = 'page';
|
__namespace = 'page';
|
||||||
|
|
||||||
__afterInit(props: IRendererProps) {
|
__afterInit(props: IRendererProps) {
|
||||||
|
|||||||
@ -173,7 +173,7 @@ export default function rendererFactory() {
|
|||||||
appHelper,
|
appHelper,
|
||||||
components: allComponents,
|
components: allComponents,
|
||||||
engine: this,
|
engine: this,
|
||||||
}}, createElement(ConfigProvider, {device: this.props.device}, createElement(Comp, {
|
} }, createElement(ConfigProvider, { device: this.props.device }, createElement(Comp, {
|
||||||
key: schema.__ctx && `${schema.__ctx.lceKey}_${schema.__ctx.idx || '0'}`,
|
key: schema.__ctx && `${schema.__ctx.lceKey}_${schema.__ctx.idx || '0'}`,
|
||||||
ref: this.__getRef,
|
ref: this.__getRef,
|
||||||
__appHelper: appHelper,
|
__appHelper: appHelper,
|
||||||
|
|||||||
@ -5,6 +5,7 @@ export default function tempRendererFactory() {
|
|||||||
|
|
||||||
return class TempRenderer extends BaseRenderer {
|
return class TempRenderer extends BaseRenderer {
|
||||||
static dislayName = 'temp-renderer';
|
static dislayName = 'temp-renderer';
|
||||||
|
|
||||||
__namespace = 'temp';
|
__namespace = 'temp';
|
||||||
|
|
||||||
__init() {
|
__init() {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user