mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-11 10:26:03 +00:00
feat: add types for shell, and move functions in types to utils
This commit is contained in:
parent
403be8e47e
commit
9f60b113dd
@ -248,7 +248,7 @@ onChangeNodeVisible(fn: (node: Node, visible: boolean) => void)
|
|||||||
|
|
||||||
### onChangeNodeChildren
|
### onChangeNodeChildren
|
||||||
|
|
||||||
onChangeNodeChildren(fn: (info?: IOnChangeOptions) => void)
|
onChangeNodeChildren(fn: (info?: IPublicOnChangeOptions) => void)
|
||||||
|
|
||||||
当前 document 的节点 children 变更事件
|
当前 document 的节点 children 变更事件
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,8 @@ import * as React from 'react';
|
|||||||
import { Component, Fragment, ReactElement, PureComponent } from 'react';
|
import { Component, Fragment, ReactElement, PureComponent } from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { computed, observer, Title, globalLocale } from '@alilc/lowcode-editor-core';
|
import { computed, observer, Title, globalLocale } from '@alilc/lowcode-editor-core';
|
||||||
import { I18nData, isI18nData, TitleContent } from '@alilc/lowcode-types';
|
import { I18nData, TitleContent } from '@alilc/lowcode-types';
|
||||||
|
import { isI18nData } from '@alilc/lowcode-utils';
|
||||||
import { DropLocation } from '../../designer';
|
import { DropLocation } from '../../designer';
|
||||||
import { BuiltinSimulatorHost } from '../../builtin-simulator/host';
|
import { BuiltinSimulatorHost } from '../../builtin-simulator/host';
|
||||||
import { ParentalNode } from '../../document/node';
|
import { ParentalNode } from '../../document/node';
|
||||||
|
|||||||
@ -9,9 +9,9 @@ import {
|
|||||||
ComponentType,
|
ComponentType,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { observer, computed, Tip, globalContext, makeObservable } from '@alilc/lowcode-editor-core';
|
import { observer, computed, Tip, globalContext } from '@alilc/lowcode-editor-core';
|
||||||
import { createIcon, isReactComponent } from '@alilc/lowcode-utils';
|
import { createIcon, isReactComponent, isActionContentObject } from '@alilc/lowcode-utils';
|
||||||
import { ActionContentObject, isActionContentObject } from '@alilc/lowcode-types';
|
import { ActionContentObject } from '@alilc/lowcode-types';
|
||||||
import { BuiltinSimulatorHost } from '../host';
|
import { BuiltinSimulatorHost } from '../host';
|
||||||
import { OffsetObserver } from '../../designer';
|
import { OffsetObserver } from '../../designer';
|
||||||
import { Node } from '../../document';
|
import { Node } from '../../document';
|
||||||
|
|||||||
@ -39,8 +39,6 @@ import {
|
|||||||
transactionManager,
|
transactionManager,
|
||||||
} from '@alilc/lowcode-utils';
|
} from '@alilc/lowcode-utils';
|
||||||
import {
|
import {
|
||||||
DragObjectType,
|
|
||||||
DragNodeObject,
|
|
||||||
isShaken,
|
isShaken,
|
||||||
LocateEvent,
|
LocateEvent,
|
||||||
isDragAnyObject,
|
isDragAnyObject,
|
||||||
@ -62,6 +60,8 @@ import {
|
|||||||
ComponentSchema,
|
ComponentSchema,
|
||||||
Package,
|
Package,
|
||||||
TransitionType,
|
TransitionType,
|
||||||
|
DragObjectType,
|
||||||
|
DragNodeObject,
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
import { BuiltinSimulatorRenderer } from './renderer';
|
import { BuiltinSimulatorRenderer } from './renderer';
|
||||||
import clipboard from '../designer/clipboard';
|
import clipboard from '../designer/clipboard';
|
||||||
|
|||||||
@ -8,12 +8,12 @@ import {
|
|||||||
TitleContent,
|
TitleContent,
|
||||||
TransformedComponentMetadata,
|
TransformedComponentMetadata,
|
||||||
NestingFilter,
|
NestingFilter,
|
||||||
isTitleConfig,
|
|
||||||
I18nData,
|
I18nData,
|
||||||
LiveTextEditingConfig,
|
LiveTextEditingConfig,
|
||||||
FieldConfig,
|
FieldConfig,
|
||||||
|
MetadataTransducer,
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
import { deprecate, isRegExp } from '@alilc/lowcode-utils';
|
import { deprecate, isRegExp, isTitleConfig } from '@alilc/lowcode-utils';
|
||||||
import { computed, engineConfig } from '@alilc/lowcode-editor-core';
|
import { computed, engineConfig } from '@alilc/lowcode-editor-core';
|
||||||
import EventEmitter from 'events';
|
import EventEmitter from 'events';
|
||||||
import { componentDefaults, legacyIssues } from './transducers';
|
import { componentDefaults, legacyIssues } from './transducers';
|
||||||
@ -128,8 +128,8 @@ export class ComponentMeta {
|
|||||||
|
|
||||||
private _isTopFixed?: boolean;
|
private _isTopFixed?: boolean;
|
||||||
|
|
||||||
get isTopFixed() {
|
get isTopFixed(): boolean {
|
||||||
return this._isTopFixed;
|
return !!(this._isTopFixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private parentWhitelist?: NestingFilter | null;
|
private parentWhitelist?: NestingFilter | null;
|
||||||
@ -279,7 +279,7 @@ export class ComponentMeta {
|
|||||||
return result as any;
|
return result as any;
|
||||||
}
|
}
|
||||||
|
|
||||||
isRootComponent(includeBlock = true) {
|
isRootComponent(includeBlock = true): boolean {
|
||||||
return (
|
return (
|
||||||
this.componentName === 'Page' ||
|
this.componentName === 'Page' ||
|
||||||
this.componentName === 'Component' ||
|
this.componentName === 'Component' ||
|
||||||
@ -326,7 +326,7 @@ export class ComponentMeta {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkNestingDown(my: Node, target: Node | NodeSchema | NodeSchema[]) {
|
checkNestingDown(my: Node, target: Node | NodeSchema | NodeSchema[]): boolean {
|
||||||
// 检查父子关系,直接约束型,在画布中拖拽直接掠过目标容器
|
// 检查父子关系,直接约束型,在画布中拖拽直接掠过目标容器
|
||||||
if (this.childWhitelist) {
|
if (this.childWhitelist) {
|
||||||
const _target: any = !Array.isArray(target) ? [target] : target;
|
const _target: any = !Array.isArray(target) ? [target] : target;
|
||||||
@ -375,19 +375,7 @@ function preprocessMetadata(metadata: ComponentMetadata): TransformedComponentMe
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MetadataTransducer {
|
|
||||||
(prev: TransformedComponentMetadata): TransformedComponentMetadata;
|
|
||||||
/**
|
|
||||||
* 0 - 9 system
|
|
||||||
* 10 - 99 builtin-plugin
|
|
||||||
* 100 - app & plugin
|
|
||||||
*/
|
|
||||||
level?: number;
|
|
||||||
/**
|
|
||||||
* use to replace TODO
|
|
||||||
*/
|
|
||||||
id?: string;
|
|
||||||
}
|
|
||||||
const metadataTransducers: MetadataTransducer[] = [];
|
const metadataTransducers: MetadataTransducer[] = [];
|
||||||
|
|
||||||
export function registerMetadataTransducer(
|
export function registerMetadataTransducer(
|
||||||
|
|||||||
@ -8,10 +8,10 @@ import {
|
|||||||
IEditor,
|
IEditor,
|
||||||
CompositeObject,
|
CompositeObject,
|
||||||
PropsList,
|
PropsList,
|
||||||
isNodeSchema,
|
|
||||||
NodeSchema,
|
NodeSchema,
|
||||||
|
PropsTransducer,
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
import { megreAssets, AssetsJson } from '@alilc/lowcode-utils';
|
import { megreAssets, AssetsJson, isNodeSchema } from '@alilc/lowcode-utils';
|
||||||
import { Project } from '../project';
|
import { Project } from '../project';
|
||||||
import { Node, DocumentModel, insertChildren, ParentalNode, TransformStage } from '../document';
|
import { Node, DocumentModel, insertChildren, ParentalNode, TransformStage } from '../document';
|
||||||
import { ComponentMeta } from '../component-meta';
|
import { ComponentMeta } from '../component-meta';
|
||||||
@ -494,7 +494,7 @@ export class Designer {
|
|||||||
getComponentMeta(
|
getComponentMeta(
|
||||||
componentName: string,
|
componentName: string,
|
||||||
generateMetadata?: () => ComponentMetadata | null,
|
generateMetadata?: () => ComponentMetadata | null,
|
||||||
): ComponentMeta {
|
) {
|
||||||
if (this._componentMetasMap.has(componentName)) {
|
if (this._componentMetasMap.has(componentName)) {
|
||||||
return this._componentMetasMap.get(componentName)!;
|
return this._componentMetasMap.get(componentName)!;
|
||||||
}
|
}
|
||||||
@ -536,7 +536,7 @@ export class Designer {
|
|||||||
return maps;
|
return maps;
|
||||||
}
|
}
|
||||||
|
|
||||||
private propsReducers = new Map<TransformStage, PropsReducer[]>();
|
private propsReducers = new Map<TransformStage, PropsTransducer[]>();
|
||||||
|
|
||||||
transformProps(props: CompositeObject | PropsList, node: Node, stage: TransformStage) {
|
transformProps(props: CompositeObject | PropsList, node: Node, stage: TransformStage) {
|
||||||
if (Array.isArray(props)) {
|
if (Array.isArray(props)) {
|
||||||
@ -560,7 +560,7 @@ export class Designer {
|
|||||||
}, props);
|
}, props);
|
||||||
}
|
}
|
||||||
|
|
||||||
addPropsReducer(reducer: PropsReducer, stage: TransformStage) {
|
addPropsReducer(reducer: PropsTransducer, stage: TransformStage) {
|
||||||
const reducers = this.propsReducers.get(stage);
|
const reducers = this.propsReducers.get(stage);
|
||||||
if (reducers) {
|
if (reducers) {
|
||||||
reducers.push(reducer);
|
reducers.push(reducer);
|
||||||
@ -577,10 +577,3 @@ export class Designer {
|
|||||||
// TODO:
|
// TODO:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PropsReducerContext = { stage: TransformStage };
|
|
||||||
export type PropsReducer = (
|
|
||||||
props: CompositeObject,
|
|
||||||
node: Node,
|
|
||||||
ctx?: PropsReducerContext,
|
|
||||||
) => CompositeObject;
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import { obx, makeObservable } from '@alilc/lowcode-editor-core';
|
import { obx, makeObservable } from '@alilc/lowcode-editor-core';
|
||||||
import { NodeSchema } from '@alilc/lowcode-types';
|
import { DragNodeObject, DragAnyObject, DragObjectType, DragNodeDataObject, DragObject } from '@alilc/lowcode-types';
|
||||||
import { Node as ShellNode } from '@alilc/lowcode-shell';
|
import { Node as ShellNode } from '@alilc/lowcode-shell';
|
||||||
import { setNativeSelection, cursor } from '@alilc/lowcode-utils';
|
import { setNativeSelection, cursor } from '@alilc/lowcode-utils';
|
||||||
import { DropLocation } from './location';
|
import { DropLocation } from './location';
|
||||||
@ -80,31 +80,6 @@ export interface ISensor {
|
|||||||
getNodeInstanceFromElement(e: Element | null): NodeInstance<ComponentInstance> | null;
|
getNodeInstanceFromElement(e: Element | null): NodeInstance<ComponentInstance> | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DragObject = DragNodeObject | DragNodeDataObject | DragAnyObject;
|
|
||||||
|
|
||||||
export enum DragObjectType {
|
|
||||||
// eslint-disable-next-line no-shadow
|
|
||||||
Node = 'node',
|
|
||||||
NodeData = 'nodedata',
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DragNodeObject {
|
|
||||||
type: DragObjectType.Node;
|
|
||||||
nodes: (Node | ShellNode)[];
|
|
||||||
}
|
|
||||||
export interface DragNodeDataObject {
|
|
||||||
type: DragObjectType.NodeData;
|
|
||||||
data: NodeSchema | NodeSchema[];
|
|
||||||
thumbnail?: string;
|
|
||||||
description?: string;
|
|
||||||
[extra: string]: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DragAnyObject {
|
|
||||||
type: string;
|
|
||||||
[key: string]: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isDragNodeObject(obj: any): obj is DragNodeObject {
|
export function isDragNodeObject(obj: any): obj is DragNodeObject {
|
||||||
return obj && obj.type === DragObjectType.Node;
|
return obj && obj.type === DragObjectType.Node;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
import { TitleContent, isDynamicSetter, SetterType, DynamicSetter, FieldExtraProps, FieldConfig, CustomView, isCustomView } from '@alilc/lowcode-types';
|
import { TitleContent, SetterType, DynamicSetter, FieldExtraProps, FieldConfig, CustomView, ISetValueOptions } from '@alilc/lowcode-types';
|
||||||
import { Transducer } from './utils';
|
import { Transducer } from './utils';
|
||||||
import { SettingPropEntry } from './setting-prop-entry';
|
import { SettingPropEntry } from './setting-prop-entry';
|
||||||
import { SettingEntry } from './setting-entry';
|
import { SettingEntry } from './setting-entry';
|
||||||
import { computed, obx, makeObservable, action } from '@alilc/lowcode-editor-core';
|
import { computed, obx, makeObservable, action } from '@alilc/lowcode-editor-core';
|
||||||
import { cloneDeep } from '@alilc/lowcode-utils';
|
import { cloneDeep, isCustomView, isDynamicSetter } from '@alilc/lowcode-utils';
|
||||||
import type { ISetValueOptions } from '../../types';
|
|
||||||
|
|
||||||
function getSettingFieldCollectorKey(parent: SettingEntry, config: FieldConfig) {
|
function getSettingFieldCollectorKey(parent: SettingEntry, config: FieldConfig) {
|
||||||
let cur = parent;
|
let cur = parent;
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
import { obx, computed, makeObservable, runInAction } from '@alilc/lowcode-editor-core';
|
import { obx, computed, makeObservable, runInAction } from '@alilc/lowcode-editor-core';
|
||||||
import { GlobalEvent, IEditor, isJSExpression } from '@alilc/lowcode-types';
|
import { GlobalEvent, IEditor, ISetValueOptions } from '@alilc/lowcode-types';
|
||||||
import { uniqueId } from '@alilc/lowcode-utils';
|
import { uniqueId, isJSExpression } from '@alilc/lowcode-utils';
|
||||||
import { SettingPropEntry as ShellSettingPropEntry } from '@alilc/lowcode-shell';
|
import { SettingPropEntry as ShellSettingPropEntry } from '@alilc/lowcode-shell';
|
||||||
import { SettingEntry } from './setting-entry';
|
import { SettingEntry } from './setting-entry';
|
||||||
import { Node } from '../../document';
|
import { Node } from '../../document';
|
||||||
import { ComponentMeta } from '../../component-meta';
|
import { ComponentMeta } from '../../component-meta';
|
||||||
import { Designer } from '../designer';
|
import { Designer } from '../designer';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import { ISetValueOptions } from '../../types';
|
|
||||||
import { isSettingField } from './setting-field';
|
import { isSettingField } from './setting-field';
|
||||||
|
|
||||||
export class SettingPropEntry implements SettingEntry {
|
export class SettingPropEntry implements SettingEntry {
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import { CustomView, isCustomView, IEditor } from '@alilc/lowcode-types';
|
import { CustomView, IEditor } from '@alilc/lowcode-types';
|
||||||
|
import { isCustomView } from '@alilc/lowcode-utils';
|
||||||
import { computed } from '@alilc/lowcode-editor-core';
|
import { computed } from '@alilc/lowcode-editor-core';
|
||||||
import { SettingEntry } from './setting-entry';
|
import { SettingEntry } from './setting-entry';
|
||||||
import { SettingField } from './setting-field';
|
import { SettingField } from './setting-field';
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
// all this file for polyfill vision logic
|
// all this file for polyfill vision logic
|
||||||
import { isValidElement } from 'react';
|
import { isValidElement } from 'react';
|
||||||
import { isSetterConfig, isDynamicSetter, FieldConfig, SetterConfig } from '@alilc/lowcode-types';
|
import { FieldConfig, SetterConfig } from '@alilc/lowcode-types';
|
||||||
|
import { isSetterConfig, isDynamicSetter } from '@alilc/lowcode-utils';
|
||||||
import { getSetter } from '@alilc/lowcode-editor-core';
|
import { getSetter } from '@alilc/lowcode-editor-core';
|
||||||
import { SettingField } from './setting-field';
|
import { SettingField } from './setting-field';
|
||||||
|
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
import { makeObservable, obx, engineConfig, action, runWithGlobalEventOff, wrapWithEventSwitch } from '@alilc/lowcode-editor-core';
|
import { makeObservable, obx, engineConfig, action, runWithGlobalEventOff, wrapWithEventSwitch } from '@alilc/lowcode-editor-core';
|
||||||
import { NodeData, isJSExpression, isDOMText, NodeSchema, isNodeSchema, RootSchema, PageSchema, ComponentsMap } from '@alilc/lowcode-types';
|
import { NodeData, NodeSchema, RootSchema, PageSchema, ComponentsMap, DragNodeObject, DragNodeDataObject } from '@alilc/lowcode-types';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import { Project } from '../project';
|
import { Project } from '../project';
|
||||||
import { ISimulatorHost } from '../simulator';
|
import { ISimulatorHost } from '../simulator';
|
||||||
import { ComponentMeta } from '../component-meta';
|
import { ComponentMeta } from '../component-meta';
|
||||||
import { isDragNodeDataObject, DragNodeObject, DragNodeDataObject, DropLocation, Designer, isDragNodeObject } from '../designer';
|
import { isDragNodeDataObject, DropLocation, Designer, isDragNodeObject } from '../designer';
|
||||||
import { Node, insertChildren, insertChild, isNode, RootNode, ParentalNode } from './node/node';
|
import { Node, insertChildren, insertChild, isNode, RootNode, ParentalNode } from './node/node';
|
||||||
import { Selection } from './selection';
|
import { Selection } from './selection';
|
||||||
import { History } from './history';
|
import { History } from './history';
|
||||||
import { TransformStage, ModalNodesManager } from './node';
|
import { TransformStage, ModalNodesManager } from './node';
|
||||||
import { uniqueId, isPlainObject, compatStage } from '@alilc/lowcode-utils';
|
import { uniqueId, isPlainObject, compatStage, isJSExpression, isDOMText, isNodeSchema } from '@alilc/lowcode-utils';
|
||||||
|
|
||||||
export type GetDataType<T, NodeType> = T extends undefined
|
export type GetDataType<T, NodeType> = T extends undefined
|
||||||
? NodeType extends {
|
? NodeType extends {
|
||||||
|
|||||||
@ -1,17 +1,15 @@
|
|||||||
import { obx, computed, globalContext, makeObservable } from '@alilc/lowcode-editor-core';
|
import { obx, computed, globalContext, makeObservable } from '@alilc/lowcode-editor-core';
|
||||||
import { Node, ParentalNode } from './node';
|
import { Node, ParentalNode } from './node';
|
||||||
import { TransformStage } from './transform-stage';
|
import { TransformStage } from './transform-stage';
|
||||||
import { NodeData, isNodeSchema } from '@alilc/lowcode-types';
|
import { NodeData } from '@alilc/lowcode-types';
|
||||||
import { shallowEqual, compatStage } from '@alilc/lowcode-utils';
|
import { shallowEqual, compatStage, isNodeSchema } from '@alilc/lowcode-utils';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import { foreachReverse } from '../../utils/tree';
|
import { foreachReverse } from '../../utils/tree';
|
||||||
import { NodeRemoveOptions } from '../../types';
|
import { NodeRemoveOptions } from '../../types';
|
||||||
|
|
||||||
export interface IOnChangeOptions {
|
export interface IOnChangeOptions {
|
||||||
type: string;
|
type: string;
|
||||||
node: Node;
|
node: Node;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NodeChildren {
|
export class NodeChildren {
|
||||||
@obx.shallow private children: Node[];
|
@obx.shallow private children: Node[];
|
||||||
|
|
||||||
@ -350,7 +348,7 @@ export class NodeChildren {
|
|||||||
return this.children.find(fn);
|
return this.children.find(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
reduce(fn: (acc: any, cur: Node) => any, initialValue: any) {
|
reduce(fn: (acc: any, cur: Node) => any, initialValue: any): void {
|
||||||
return this.children.reduce(fn, initialValue);
|
return this.children.reduce(fn, initialValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +356,7 @@ export class NodeChildren {
|
|||||||
remover: (node: Node, idx: number) => boolean,
|
remover: (node: Node, idx: number) => boolean,
|
||||||
adder: (children: Node[]) => NodeData[] | null,
|
adder: (children: Node[]) => NodeData[] | null,
|
||||||
sorter: (firstNode: Node, secondNode: Node) => number,
|
sorter: (firstNode: Node, secondNode: Node) => number,
|
||||||
) {
|
): any {
|
||||||
let changed = false;
|
let changed = false;
|
||||||
if (remover) {
|
if (remover) {
|
||||||
const willRemove = this.children.filter(remover);
|
const willRemove = this.children.filter(remover);
|
||||||
|
|||||||
@ -2,8 +2,6 @@ import { ReactElement } from 'react';
|
|||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import { obx, computed, autorun, makeObservable, runInAction, wrapWithEventSwitch, action } from '@alilc/lowcode-editor-core';
|
import { obx, computed, autorun, makeObservable, runInAction, wrapWithEventSwitch, action } from '@alilc/lowcode-editor-core';
|
||||||
import {
|
import {
|
||||||
isDOMText,
|
|
||||||
isJSExpression,
|
|
||||||
NodeSchema,
|
NodeSchema,
|
||||||
PropsMap,
|
PropsMap,
|
||||||
PropsList,
|
PropsList,
|
||||||
@ -17,7 +15,7 @@ import {
|
|||||||
GlobalEvent,
|
GlobalEvent,
|
||||||
ComponentAction,
|
ComponentAction,
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
import { compatStage } from '@alilc/lowcode-utils';
|
import { compatStage, isDOMText, isJSExpression } from '@alilc/lowcode-utils';
|
||||||
import { SettingTopEntry } from '@alilc/lowcode-designer';
|
import { SettingTopEntry } from '@alilc/lowcode-designer';
|
||||||
import { Node as ShellNode } from '@alilc/lowcode-shell';
|
import { Node as ShellNode } from '@alilc/lowcode-shell';
|
||||||
import { Props, getConvertedExtraKey } from './props/props';
|
import { Props, getConvertedExtraKey } from './props/props';
|
||||||
@ -94,7 +92,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 节点组件类型
|
* 节点组件类型
|
||||||
* 特殊节点:
|
* 特殊节点:
|
||||||
* * Page 页面
|
* * Page 页面
|
||||||
* * Block 区块
|
* * Block 区块
|
||||||
* * Component 组件/元件
|
* * Component 组件/元件
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { untracked, computed, obx, engineConfig, action, makeObservable, mobx, runInAction } from '@alilc/lowcode-editor-core';
|
import { untracked, computed, obx, engineConfig, action, makeObservable, mobx, runInAction } from '@alilc/lowcode-editor-core';
|
||||||
import { CompositeValue, GlobalEvent, isJSExpression, isJSSlot, JSSlot, SlotSchema } from '@alilc/lowcode-types';
|
import { CompositeValue, GlobalEvent, JSSlot, SlotSchema } from '@alilc/lowcode-types';
|
||||||
import { uniqueId, isPlainObject, hasOwnProperty, compatStage } from '@alilc/lowcode-utils';
|
import { uniqueId, isPlainObject, hasOwnProperty, compatStage, isJSExpression, isJSSlot } from '@alilc/lowcode-utils';
|
||||||
import { valueToSource } from './value-to-source';
|
import { valueToSource } from './value-to-source';
|
||||||
import { Props } from './props';
|
import { Props } from './props';
|
||||||
import { SlotNode, Node } from '../node';
|
import { SlotNode, Node } from '../node';
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
import { CompositeObject, ComponentAction } from '@alilc/lowcode-types';
|
import { CompositeObject, ComponentAction, MetadataTransducer } from '@alilc/lowcode-types';
|
||||||
import Logger from 'zen-logger';
|
import Logger from 'zen-logger';
|
||||||
import { Hotkey, Skeleton, Project, Event, Material, Common } from '@alilc/lowcode-shell';
|
import { Hotkey, Skeleton, Project, Event, Material, Common } from '@alilc/lowcode-shell';
|
||||||
import { EngineConfig } from '@alilc/lowcode-editor-core';
|
import { EngineConfig } from '@alilc/lowcode-editor-core';
|
||||||
import { MetadataTransducer } from '@alilc/lowcode-designer';
|
|
||||||
import { Setters } from '../types';
|
import { Setters } from '../types';
|
||||||
|
|
||||||
export type PreferenceValueType = string | number | boolean;
|
export type PreferenceValueType = string | number | boolean;
|
||||||
|
|||||||
@ -7,9 +7,8 @@ import {
|
|||||||
RootSchema,
|
RootSchema,
|
||||||
ComponentsMap,
|
ComponentsMap,
|
||||||
TransformStage,
|
TransformStage,
|
||||||
isLowCodeComponentType,
|
|
||||||
isProCodeComponentType,
|
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
|
import { isLowCodeComponentType, isProCodeComponentType } from '@alilc/lowcode-utils';
|
||||||
import { ISimulatorHost } from '../simulator';
|
import { ISimulatorHost } from '../simulator';
|
||||||
|
|
||||||
export class Project {
|
export class Project {
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { getSetter, registerSetter, getSettersMap } from '@alilc/lowcode-editor-core';
|
import { getSetter, registerSetter, getSettersMap } from '@alilc/lowcode-editor-core';
|
||||||
import { isFormEvent, compatibleLegaoSchema, getNodeSchemaById } from '@alilc/lowcode-utils';
|
import { isFormEvent, compatibleLegaoSchema, getNodeSchemaById, isNodeSchema } from '@alilc/lowcode-utils';
|
||||||
import { isNodeSchema } from '@alilc/lowcode-types';
|
|
||||||
|
|
||||||
export type Setters = {
|
export type Setters = {
|
||||||
getSetter: typeof getSetter;
|
getSetter: typeof getSetter;
|
||||||
@ -19,20 +18,3 @@ export const utils = {
|
|||||||
getNodeSchemaById,
|
getNodeSchemaById,
|
||||||
};
|
};
|
||||||
export type Utils = typeof utils;
|
export type Utils = typeof utils;
|
||||||
|
|
||||||
export enum PROP_VALUE_CHANGED_TYPE {
|
|
||||||
/**
|
|
||||||
* normal set value
|
|
||||||
*/
|
|
||||||
SET_VALUE = 'SET_VALUE',
|
|
||||||
/**
|
|
||||||
* value changed caused by sub-prop value change
|
|
||||||
*/
|
|
||||||
SUB_VALUE_CHANGE = 'SUB_VALUE_CHANGE',
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ISetValueOptions {
|
|
||||||
disableMutator?: boolean;
|
|
||||||
type?: PROP_VALUE_CHANGED_TYPE;
|
|
||||||
fromSetHotValue?: boolean;
|
|
||||||
}
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { Editor } from '@alilc/lowcode-editor-core';
|
import { Editor } from '@alilc/lowcode-editor-core';
|
||||||
import { isJSBlock, TransformStage } from '@alilc/lowcode-types';
|
import { TransformStage } from '@alilc/lowcode-types';
|
||||||
import { isPlainObject, isVariable } from '@alilc/lowcode-utils';
|
import { isPlainObject, isVariable, isJSBlock } from '@alilc/lowcode-utils';
|
||||||
import '../fixtures/window';
|
import '../fixtures/window';
|
||||||
import { Designer } from '../../src/designer/designer';
|
import { Designer } from '../../src/designer/designer';
|
||||||
import { DocumentModel } from '../../src/document/document-model';
|
import { DocumentModel } from '../../src/document/document-model';
|
||||||
|
|||||||
@ -1,30 +1,14 @@
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import React from 'react';
|
|
||||||
import set from 'lodash/set';
|
|
||||||
import cloneDeep from 'lodash/cloneDeep';
|
|
||||||
import '../fixtures/window';
|
import '../fixtures/window';
|
||||||
import { Editor, globalContext } from '@alilc/lowcode-editor-core';
|
import { Editor, globalContext } from '@alilc/lowcode-editor-core';
|
||||||
import {
|
import {
|
||||||
AssetLevel,
|
|
||||||
Asset,
|
|
||||||
AssetList,
|
|
||||||
assetBundle,
|
|
||||||
assetItem,
|
|
||||||
AssetType,
|
AssetType,
|
||||||
} from '@alilc/lowcode-utils';
|
} from '@alilc/lowcode-utils';
|
||||||
import {
|
import {
|
||||||
Dragon,
|
|
||||||
isDragNodeObject,
|
|
||||||
isDragNodeDataObject,
|
|
||||||
isDragAnyObject,
|
|
||||||
isLocateEvent,
|
|
||||||
DragObjectType,
|
DragObjectType,
|
||||||
isShaken,
|
} from '@alilc/lowcode-types';
|
||||||
setShaken,
|
|
||||||
} from '../../src/designer/dragon';
|
|
||||||
import { Project } from '../../src/project/project';
|
import { Project } from '../../src/project/project';
|
||||||
import pageMetadata from '../fixtures/component-metadata/page';
|
import pageMetadata from '../fixtures/component-metadata/page';
|
||||||
import { Node } from '../../src/document/node/node';
|
|
||||||
import { Designer } from '../../src/designer/designer';
|
import { Designer } from '../../src/designer/designer';
|
||||||
import { DocumentModel } from '../../src/document/document-model';
|
import { DocumentModel } from '../../src/document/document-model';
|
||||||
import formSchema from '../fixtures/schema/form';
|
import formSchema from '../fixtures/schema/form';
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { Editor, globalContext } from '@alilc/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 { Designer } from '../../src/designer/designer';
|
import { Designer } from '../../src/designer/designer';
|
||||||
import { Dragon, DragObjectType } from '../../src/designer/dragon';
|
import { Dragon } from '../../src/designer/dragon';
|
||||||
import { TransformStage } from '../../src/document/node/transform-stage';
|
import { TransformStage } from '../../src/document/node/transform-stage';
|
||||||
import formSchema from '../fixtures/schema/form';
|
import formSchema from '../fixtures/schema/form';
|
||||||
import buttonMetadata from '../fixtures/component-metadata/button';
|
import buttonMetadata from '../fixtures/component-metadata/button';
|
||||||
@ -11,6 +11,7 @@ import pageMetadata from '../fixtures/component-metadata/page';
|
|||||||
import divMetadata from '../fixtures/component-metadata/div';
|
import divMetadata from '../fixtures/component-metadata/div';
|
||||||
import { delayObxTick } from '../utils';
|
import { delayObxTick } from '../utils';
|
||||||
import { fireEvent } from '@testing-library/react';
|
import { fireEvent } from '@testing-library/react';
|
||||||
|
import { DragObjectType } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
const mockNode = {
|
const mockNode = {
|
||||||
internalToShellNode() {
|
internalToShellNode() {
|
||||||
|
|||||||
@ -10,12 +10,12 @@ import {
|
|||||||
isDragNodeDataObject,
|
isDragNodeDataObject,
|
||||||
isDragAnyObject,
|
isDragAnyObject,
|
||||||
isLocateEvent,
|
isLocateEvent,
|
||||||
DragObjectType,
|
|
||||||
isShaken,
|
isShaken,
|
||||||
setShaken,
|
setShaken,
|
||||||
isInvalidPoint,
|
isInvalidPoint,
|
||||||
isSameAs,
|
isSameAs,
|
||||||
} from '../../src/designer/dragon';
|
} from '../../src/designer/dragon';
|
||||||
|
import { DragObjectType } from '@alilc/lowcode-types';
|
||||||
import formSchema from '../fixtures/schema/form';
|
import formSchema from '../fixtures/schema/form';
|
||||||
import { fireEvent } from '@testing-library/react';
|
import { fireEvent } from '@testing-library/react';
|
||||||
|
|
||||||
|
|||||||
@ -1,35 +1,13 @@
|
|||||||
import '../fixtures/window';
|
import '../fixtures/window';
|
||||||
import { set } from '../utils';
|
|
||||||
import { Editor, globalContext } from '@alilc/lowcode-editor-core';
|
import { Editor, globalContext } from '@alilc/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 { ScrollTarget, Scroller } from '../../src/designer/scroller';
|
import { ScrollTarget, Scroller } from '../../src/designer/scroller';
|
||||||
import {
|
|
||||||
isRootNode,
|
|
||||||
isNode,
|
|
||||||
comparePosition,
|
|
||||||
contains,
|
|
||||||
insertChild,
|
|
||||||
insertChildren,
|
|
||||||
PositionNO,
|
|
||||||
} from '../../src/document/node/node';
|
|
||||||
import { Designer } from '../../src/designer/designer';
|
import { Designer } from '../../src/designer/designer';
|
||||||
import {
|
import {
|
||||||
Dragon,
|
Dragon,
|
||||||
isDragNodeObject,
|
|
||||||
isDragNodeDataObject,
|
|
||||||
isDragAnyObject,
|
|
||||||
isLocateEvent,
|
|
||||||
DragObjectType,
|
|
||||||
isShaken,
|
|
||||||
setShaken,
|
|
||||||
} from '../../src/designer/dragon';
|
} from '../../src/designer/dragon';
|
||||||
import formSchema from '../fixtures/schema/form';
|
import formSchema from '../fixtures/schema/form';
|
||||||
import divMetadata from '../fixtures/component-metadata/div';
|
|
||||||
import formMetadata from '../fixtures/component-metadata/form';
|
|
||||||
import otherMeta from '../fixtures/component-metadata/other';
|
|
||||||
import pageMetadata from '../fixtures/component-metadata/page';
|
|
||||||
import { fireEvent } from '@testing-library/react';
|
|
||||||
|
|
||||||
describe('Scroller 测试', () => {
|
describe('Scroller 测试', () => {
|
||||||
let editor: Editor;
|
let editor: Editor;
|
||||||
|
|||||||
@ -1,23 +1,8 @@
|
|||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { CustomView, isCustomView, TitleContent } from '@alilc/lowcode-types';
|
import { CustomView, RegisteredSetter } from '@alilc/lowcode-types';
|
||||||
import { createContent } from '@alilc/lowcode-utils';
|
import { createContent, isCustomView } from '@alilc/lowcode-utils';
|
||||||
|
|
||||||
|
|
||||||
export type RegisteredSetter = {
|
|
||||||
component: CustomView;
|
|
||||||
defaultProps?: object;
|
|
||||||
title?: TitleContent;
|
|
||||||
/**
|
|
||||||
* for MixedSetter to check this setter if available
|
|
||||||
*/
|
|
||||||
condition?: (field: any) => boolean;
|
|
||||||
/**
|
|
||||||
* for MixedSetter to manual change to this setter
|
|
||||||
*/
|
|
||||||
initialValue?: any | ((field: any) => any);
|
|
||||||
recommend?: boolean;
|
|
||||||
// 标识是否为动态setter,默认为true
|
|
||||||
isDynamic?: boolean;
|
|
||||||
};
|
|
||||||
const settersMap = new Map<string, RegisteredSetter & {
|
const settersMap = new Map<string, RegisteredSetter & {
|
||||||
type: string;
|
type: string;
|
||||||
}>();
|
}>();
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
import { globalContext } from './di';
|
import { globalContext } from './di';
|
||||||
import { Editor } from './editor';
|
import { Editor } from './editor';
|
||||||
|
import { HotkeyCallback } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
interface KeyMap {
|
interface KeyMap {
|
||||||
[key: number]: string;
|
[key: number]: string;
|
||||||
@ -22,8 +23,6 @@ interface HotkeyDirectMap {
|
|||||||
[key: string]: HotkeyCallback;
|
[key: string]: HotkeyCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type HotkeyCallback = (e: KeyboardEvent, combo?: string) => any | false;
|
|
||||||
|
|
||||||
interface HotkeyCallbackCfg {
|
interface HotkeyCallbackCfg {
|
||||||
callback: HotkeyCallback;
|
callback: HotkeyCallback;
|
||||||
modifiers: string[];
|
modifiers: string[];
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { ReactNode, Component, createElement } from 'react';
|
import { ReactNode, Component, createElement } from 'react';
|
||||||
import { IntlMessageFormat } from 'intl-messageformat';
|
import { IntlMessageFormat } from 'intl-messageformat';
|
||||||
import { globalLocale } from './global-locale';
|
import { globalLocale } from './global-locale';
|
||||||
import { isI18nData } from '@alilc/lowcode-types';
|
import { isI18nData } from '@alilc/lowcode-utils';
|
||||||
import { observer } from '../utils';
|
import { observer } from '../utils';
|
||||||
|
|
||||||
function generateTryLocales(locale: string) {
|
function generateTryLocales(locale: string) {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Component, isValidElement, ReactNode } from 'react';
|
import { Component, isValidElement, ReactNode } from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { createIcon } from '@alilc/lowcode-utils';
|
import { createIcon, isI18nData } from '@alilc/lowcode-utils';
|
||||||
import { TitleContent, isI18nData, I18nData } from '@alilc/lowcode-types';
|
import { TitleContent, I18nData } from '@alilc/lowcode-types';
|
||||||
import { intl } from '../../intl';
|
import { intl } from '../../intl';
|
||||||
import { Tip } from '../tip';
|
import { Tip } from '../tip';
|
||||||
import './title.less';
|
import './title.less';
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
import { Component, MouseEvent, Fragment } from 'react';
|
import { Component, MouseEvent, Fragment } from 'react';
|
||||||
import { shallowIntl, createSetterContent, observer, obx, engineConfig, runInAction, globalContext } from '@alilc/lowcode-editor-core';
|
import { shallowIntl, createSetterContent, observer, obx, engineConfig, runInAction, globalContext } from '@alilc/lowcode-editor-core';
|
||||||
import { createContent } from '@alilc/lowcode-utils';
|
import { createContent, isJSSlot, isSetterConfig } from '@alilc/lowcode-utils';
|
||||||
import { Skeleton } from '@alilc/lowcode-editor-skeleton';
|
import { Skeleton } from '@alilc/lowcode-editor-skeleton';
|
||||||
import { isSetterConfig, CustomView, isJSSlot } from '@alilc/lowcode-types';
|
import { CustomView } from '@alilc/lowcode-types';
|
||||||
import { SettingField, isSettingField, SettingTopEntry, SettingEntry, ComponentMeta } from '@alilc/lowcode-designer';
|
import { SettingField, isSettingField, SettingTopEntry, SettingEntry, ComponentMeta } from '@alilc/lowcode-designer';
|
||||||
import { createField } from '../field';
|
import { createField } from '../field';
|
||||||
import PopupService, { PopupPipe } from '../popup';
|
import PopupService, { PopupPipe } from '../popup';
|
||||||
import { SkeletonContext } from '../../context';
|
import { SkeletonContext } from '../../context';
|
||||||
// import { Icon } from '@alifd/next';
|
|
||||||
import { intl } from '../../locale';
|
import { intl } from '../../locale';
|
||||||
|
|
||||||
function isStandardComponent(componentMeta: ComponentMeta | null) {
|
function isStandardComponent(componentMeta: ComponentMeta | null) {
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import classNames from 'classnames';
|
|||||||
import { IconArrow } from '../../icons/arrow';
|
import { IconArrow } from '../../icons/arrow';
|
||||||
import { IconExit } from '../../icons/exit';
|
import { IconExit } from '../../icons/exit';
|
||||||
import { Stage as StageWidget } from '../../widget/stage';
|
import { Stage as StageWidget } from '../../widget/stage';
|
||||||
import { isTitleConfig } from '@alilc/lowcode-types';
|
import { isTitleConfig } from '@alilc/lowcode-utils';
|
||||||
|
|
||||||
export const StageDefaultProps = {
|
export const StageDefaultProps = {
|
||||||
current: false,
|
current: false,
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import {
|
|||||||
DockConfig,
|
DockConfig,
|
||||||
PanelConfig,
|
PanelConfig,
|
||||||
WidgetConfig,
|
WidgetConfig,
|
||||||
IWidgetBaseConfig,
|
|
||||||
PanelDockConfig,
|
PanelDockConfig,
|
||||||
DialogDockConfig,
|
DialogDockConfig,
|
||||||
isDockConfig,
|
isDockConfig,
|
||||||
@ -11,7 +10,6 @@ import {
|
|||||||
isPanelConfig,
|
isPanelConfig,
|
||||||
DividerConfig,
|
DividerConfig,
|
||||||
isDividerConfig,
|
isDividerConfig,
|
||||||
IWidgetConfigArea,
|
|
||||||
} from './types';
|
} from './types';
|
||||||
import Panel, { isPanel } from './widget/panel';
|
import Panel, { isPanel } from './widget/panel';
|
||||||
import WidgetContainer from './widget/widget-container';
|
import WidgetContainer from './widget/widget-container';
|
||||||
@ -23,7 +21,12 @@ import { Stage, StageConfig } from './widget/stage';
|
|||||||
import { isValidElement } from 'react';
|
import { isValidElement } from 'react';
|
||||||
import { isPlainObject, uniqueId } from '@alilc/lowcode-utils';
|
import { isPlainObject, uniqueId } from '@alilc/lowcode-utils';
|
||||||
import { Divider } from '@alifd/next';
|
import { Divider } from '@alifd/next';
|
||||||
import { EditorConfig, PluginClassSet } from '@alilc/lowcode-types';
|
import {
|
||||||
|
EditorConfig,
|
||||||
|
PluginClassSet,
|
||||||
|
IWidgetBaseConfig,
|
||||||
|
IWidgetConfigArea,
|
||||||
|
} from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export enum SkeletonEvents {
|
export enum SkeletonEvents {
|
||||||
PANEL_DOCK_ACTIVE = 'skeleton.panel-dock.active',
|
PANEL_DOCK_ACTIVE = 'skeleton.panel-dock.active',
|
||||||
|
|||||||
@ -1,9 +1,5 @@
|
|||||||
import {
|
import { TransformedComponentMetadata } from '@alilc/lowcode-types';
|
||||||
FieldConfig,
|
import { isPlainObject, isJSFunction } from '@alilc/lowcode-utils';
|
||||||
TransformedComponentMetadata,
|
|
||||||
isJSFunction,
|
|
||||||
} from '@alilc/lowcode-types';
|
|
||||||
import { isPlainObject } from '@alilc/lowcode-utils';
|
|
||||||
|
|
||||||
const leadingFnRe = /^function/;
|
const leadingFnRe = /^function/;
|
||||||
const leadingFnNameRe = /^\w+\s*\(/;
|
const leadingFnNameRe = /^\w+\s*\(/;
|
||||||
|
|||||||
@ -1,35 +1,14 @@
|
|||||||
import { ReactElement, ComponentType } from 'react';
|
import { ReactElement, ComponentType } from 'react';
|
||||||
import { TitleContent, IconType, I18nData, TipContent } from '@alilc/lowcode-types';
|
import {
|
||||||
|
TitleContent,
|
||||||
|
IconType,
|
||||||
|
I18nData,
|
||||||
|
TipContent,
|
||||||
|
IWidgetConfigArea,
|
||||||
|
IWidgetBaseConfig,
|
||||||
|
} from '@alilc/lowcode-types';
|
||||||
import { IWidget } from './widget/widget';
|
import { IWidget } from './widget/widget';
|
||||||
|
|
||||||
/**
|
|
||||||
* 所有可能的停靠位置
|
|
||||||
*/
|
|
||||||
export type IWidgetConfigArea =
|
|
||||||
| 'leftArea' | 'left' | 'rightArea'
|
|
||||||
| 'right' | 'topArea' | 'top'
|
|
||||||
| 'toolbar' | 'mainArea' | 'main'
|
|
||||||
| 'center' | 'centerArea' | 'bottomArea'
|
|
||||||
| 'bottom' | 'leftFixedArea'
|
|
||||||
| 'leftFloatArea' | 'stages';
|
|
||||||
|
|
||||||
export interface IWidgetBaseConfig {
|
|
||||||
type: string;
|
|
||||||
name: string;
|
|
||||||
/**
|
|
||||||
* 停靠位置:
|
|
||||||
* - 当 type 为 'Panel' 时自动为 'leftFloatArea';
|
|
||||||
* - 当 type 为 'Widget' 时自动为 'mainArea';
|
|
||||||
* - 其他时候自动为 'leftArea';
|
|
||||||
*/
|
|
||||||
area?: IWidgetConfigArea;
|
|
||||||
props?: Record<string, any>;
|
|
||||||
content?: any;
|
|
||||||
contentProps?: Record<string, any>;
|
|
||||||
// index?: number;
|
|
||||||
[extra: string]: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface WidgetConfig extends IWidgetBaseConfig {
|
export interface WidgetConfig extends IWidgetBaseConfig {
|
||||||
type: 'Widget';
|
type: 'Widget';
|
||||||
props?: {
|
props?: {
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { IconType, TitleContent, isI18nData, TipContent, isTitleConfig } from '@alilc/lowcode-types';
|
import { IconType, TitleContent, TipContent } from '@alilc/lowcode-types';
|
||||||
|
import { isI18nData, isTitleConfig } from '@alilc/lowcode-utils';
|
||||||
import { isValidElement } from 'react';
|
import { isValidElement } from 'react';
|
||||||
|
|
||||||
export function composeTitle(title?: TitleContent, icon?: IconType, tip?: TipContent, tipAsTitle?: boolean, noIcon?: boolean) {
|
export function composeTitle(title?: TitleContent, icon?: IconType, tip?: TipContent, tipAsTitle?: boolean, noIcon?: boolean) {
|
||||||
|
|||||||
@ -33,7 +33,6 @@ import './modules/live-editing';
|
|||||||
import classes from './modules/classes';
|
import classes from './modules/classes';
|
||||||
import symbols from './modules/symbols';
|
import symbols from './modules/symbols';
|
||||||
|
|
||||||
export * from './modules/editor-types';
|
|
||||||
export * from './modules/skeleton-types';
|
export * from './modules/skeleton-types';
|
||||||
export * from './modules/designer-types';
|
export * from './modules/designer-types';
|
||||||
export * from './modules/lowcode-types';
|
export * from './modules/lowcode-types';
|
||||||
|
|||||||
@ -14,6 +14,3 @@ export type ILowCodePluginManager = designerCabin.ILowCodePluginManager;
|
|||||||
export type ILowCodePluginContext = designerCabin.ILowCodePluginContext;
|
export type ILowCodePluginContext = designerCabin.ILowCodePluginContext;
|
||||||
export type IPluginConfigCreator = designerCabin.IPluginConfigCreator;
|
export type IPluginConfigCreator = designerCabin.IPluginConfigCreator;
|
||||||
export type PluginPreference = designerCabin.PluginPreference;
|
export type PluginPreference = designerCabin.PluginPreference;
|
||||||
export type PropsReducerContext = designerCabin.PropsReducerContext;
|
|
||||||
export type DragObjectType = designerCabin.DragObjectType;
|
|
||||||
export type DragNodeDataObject = designerCabin.DragNodeDataObject;
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
import * as editorCabin from '@alilc/lowcode-editor-core';
|
|
||||||
|
|
||||||
export type RegisteredSetter = editorCabin.RegisteredSetter;
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import { EditingTarget, Node as DocNode, SaveHandler, LiveEditing } from '@alilc/lowcode-designer';
|
import { EditingTarget, Node as DocNode, SaveHandler, LiveEditing } from '@alilc/lowcode-designer';
|
||||||
import { isJSExpression } from '@alilc/lowcode-types';
|
import { isJSExpression } from '@alilc/lowcode-utils';
|
||||||
|
|
||||||
function getText(node: DocNode, prop: string) {
|
function getText(node: DocNode, prop: string) {
|
||||||
const p = node.getProp(prop, false);
|
const p = node.getProp(prop, false);
|
||||||
@ -53,8 +53,7 @@ function equalText(v: any, innerText: string) {
|
|||||||
|
|
||||||
export const liveEditingSaveHander: SaveHandler = {
|
export const liveEditingSaveHander: SaveHandler = {
|
||||||
condition: (prop) => {
|
condition: (prop) => {
|
||||||
// const v = prop.getValue();
|
return prop.type === 'expression';
|
||||||
return prop.type === 'expression'; // || isI18nData(v);
|
|
||||||
},
|
},
|
||||||
onSaveContent: (content, prop) => {
|
onSaveContent: (content, prop) => {
|
||||||
const v = prop.getValue();
|
const v = prop.getValue();
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { TitleContent, isI18nData } from '@alilc/lowcode-types';
|
import { TitleContent } from '@alilc/lowcode-types';
|
||||||
|
import { isI18nData } from '@alilc/lowcode-utils';
|
||||||
import { computed, obx, intl, makeObservable, action } from '@alilc/lowcode-editor-core';
|
import { computed, obx, intl, makeObservable, action } from '@alilc/lowcode-editor-core';
|
||||||
import { Node, DocumentModel, isLocationChildrenDetail, LocationChildrenDetail, Designer } from '@alilc/lowcode-designer';
|
import { Node, DocumentModel, isLocationChildrenDetail, LocationChildrenDetail, Designer } from '@alilc/lowcode-designer';
|
||||||
import { Tree } from './tree';
|
import { Tree } from './tree';
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
import { Component, MouseEvent as ReactMouseEvent } from 'react';
|
import { Component, MouseEvent as ReactMouseEvent } from 'react';
|
||||||
import { observer, Editor, globalContext } from '@alilc/lowcode-editor-core';
|
import { observer, Editor, globalContext } from '@alilc/lowcode-editor-core';
|
||||||
import { Node, DragObjectType, isShaken } from '@alilc/lowcode-designer';
|
import { Node, isShaken } from '@alilc/lowcode-designer';
|
||||||
import { isFormEvent, canClickNode } from '@alilc/lowcode-utils';
|
import { isFormEvent, canClickNode } from '@alilc/lowcode-utils';
|
||||||
import { Tree } from '../tree';
|
import { Tree } from '../tree';
|
||||||
import RootTreeNodeView from './root-tree-node';
|
import RootTreeNodeView from './root-tree-node';
|
||||||
|
import { DragObjectType } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
function getTreeNodeIdByEvent(e: ReactMouseEvent, stop: Element): null | string {
|
function getTreeNodeIdByEvent(e: ReactMouseEvent, stop: Element): null | string {
|
||||||
let target: Element | null = e.target as Element;
|
let target: Element | null = e.target as Element;
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import { BuiltinSimulatorRenderer, Component, DocumentModel, Node, NodeInstance } from '@alilc/lowcode-designer';
|
import { BuiltinSimulatorRenderer, Component, DocumentModel, Node, NodeInstance } from '@alilc/lowcode-designer';
|
||||||
import { ComponentSchema, NodeSchema, NpmInfo, RootSchema, TransformStage } from '@alilc/lowcode-types';
|
import { ComponentSchema, NodeSchema, NpmInfo, TransformStage } from '@alilc/lowcode-types';
|
||||||
import { Asset, compatibleLegaoSchema, cursor, isElement, isESModule, isPlainObject, isReactComponent, setNativeSelection } from '@alilc/lowcode-utils';
|
import { Asset, compatibleLegaoSchema, cursor, isElement, isESModule, isPlainObject, isReactComponent, setNativeSelection } from '@alilc/lowcode-utils';
|
||||||
import LowCodeRenderer from '@alilc/lowcode-rax-renderer';
|
import LowCodeRenderer from '@alilc/lowcode-rax-renderer';
|
||||||
import { computed, observable as obx, untracked, makeObservable, configure } from 'mobx';
|
import { computed, observable as obx, makeObservable, configure } from 'mobx';
|
||||||
import DriverUniversal from 'driver-universal';
|
import DriverUniversal from 'driver-universal';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import { createMemoryHistory, MemoryHistory } from 'history';
|
import { createMemoryHistory, MemoryHistory } from 'history';
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
/* eslint-disable react/prop-types */
|
/* eslint-disable react/prop-types */
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { create as createDataSourceEngine } from '@alilc/lowcode-datasource-engine/interpret';
|
import { create as createDataSourceEngine } from '@alilc/lowcode-datasource-engine/interpret';
|
||||||
import { isI18nData, isJSExpression, isJSFunction, NodeSchema, NodeData, JSONValue, CompositeValue } from '@alilc/lowcode-types';
|
import { NodeSchema, NodeData, JSONValue, CompositeValue } from '@alilc/lowcode-types';
|
||||||
|
import { isI18nData, isJSExpression, isJSFunction } from '@alilc/lowcode-utils';
|
||||||
import adapter from '../adapter';
|
import adapter from '../adapter';
|
||||||
import divFactory from '../components/Div';
|
import divFactory from '../components/Div';
|
||||||
import visualDomFactory from '../components/VisualDom';
|
import visualDomFactory from '../components/VisualDom';
|
||||||
@ -29,7 +30,7 @@ import {
|
|||||||
isVariable,
|
isVariable,
|
||||||
isJSSlot,
|
isJSSlot,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
import { IBaseRendererProps, INodeInfo, IBaseRenderComponent, IBaseRendererContext, IGeneralConstructor, IRendererAppHelper, DataSource } from '../types';
|
import { IBaseRendererProps, INodeInfo, IBaseRenderComponent, IBaseRendererContext, IRendererAppHelper, DataSource } from '../types';
|
||||||
import { compWrapper } from '../hoc';
|
import { compWrapper } from '../hoc';
|
||||||
import { IComponentConstruct, leafWrapper } from '../hoc/leaf';
|
import { IComponentConstruct, leafWrapper } from '../hoc/leaf';
|
||||||
import logger from '../utils/logger';
|
import logger from '../utils/logger';
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
/* eslint-disable no-new-func */
|
/* eslint-disable no-new-func */
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
import { isI18nData, RootSchema, NodeSchema, isJSExpression, JSSlot } from '@alilc/lowcode-types';
|
import { RootSchema, NodeSchema, JSSlot } from '@alilc/lowcode-types';
|
||||||
|
import { isI18nData, isJSExpression } from '@alilc/lowcode-utils';
|
||||||
import { isEmpty } from 'lodash';
|
import { isEmpty } from 'lodash';
|
||||||
import IntlMessageFormat from 'intl-messageformat';
|
import IntlMessageFormat from 'intl-messageformat';
|
||||||
import pkg from '../../package.json';
|
import pkg from '../../package.json';
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
/* eslint-disable object-curly-newline */
|
/* eslint-disable object-curly-newline */
|
||||||
import { isJSFunction } from '@alilc/lowcode-types';
|
import { isJSFunction } from '@alilc/lowcode-utils';
|
||||||
import { transformArrayToMap, transformStringToFunction } from './common';
|
import { transformArrayToMap, transformStringToFunction } from './common';
|
||||||
import { jsonp, request, get, post } from './request';
|
import { jsonp, request, get, post } from './request';
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { isJSExpression, JSExpression } from '@alilc/lowcode-types';
|
import { JSExpression } from '@alilc/lowcode-types';
|
||||||
|
import { isJSExpression } from '@alilc/lowcode-utils';
|
||||||
|
|
||||||
// 1.渲染模式下,loop 是数组,则按照数组长度渲染组件
|
// 1.渲染模式下,loop 是数组,则按照数组长度渲染组件
|
||||||
// 2.设计模式下,loop 需要长度大于 0,按照循环模式渲染,防止无法设计的情况
|
// 2.设计模式下,loop 需要长度大于 0,按照循环模式渲染,防止无法设计的情况
|
||||||
|
|||||||
@ -1,16 +1,19 @@
|
|||||||
import { Designer } from '@alilc/lowcode-designer';
|
import { Designer } from '@alilc/lowcode-designer';
|
||||||
import { designerSymbol } from './symbols';
|
import { designerSymbol } from './symbols';
|
||||||
import DropLocation from './drop-location';
|
import DropLocation from './drop-location';
|
||||||
|
import { IPublicModelCanvas } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export default class Canvas {
|
export default class Canvas implements IPublicModelCanvas {
|
||||||
private readonly [designerSymbol]: Designer;
|
private readonly [designerSymbol]: Designer;
|
||||||
|
|
||||||
constructor(designer: Designer) {
|
constructor(designer: Designer) {
|
||||||
this[designerSymbol] = designer;
|
this[designerSymbol] = designer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(designer: Designer) {
|
static create(designer: Designer): IPublicModelCanvas | null {
|
||||||
if (!designer) return null;
|
if (!designer) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new Canvas(designer);
|
return new Canvas(designer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,12 +4,17 @@ import {
|
|||||||
compatibleLegaoSchema as innerCompatibleLegaoSchema,
|
compatibleLegaoSchema as innerCompatibleLegaoSchema,
|
||||||
getNodeSchemaById as innerGetNodeSchemaById,
|
getNodeSchemaById as innerGetNodeSchemaById,
|
||||||
transactionManager,
|
transactionManager,
|
||||||
|
isNodeSchema as innerIsNodeSchema,
|
||||||
} from '@alilc/lowcode-utils';
|
} from '@alilc/lowcode-utils';
|
||||||
import {
|
import {
|
||||||
isNodeSchema as innerIsNodeSchema,
|
|
||||||
NodeSchema,
|
NodeSchema,
|
||||||
TransitionType,
|
TransitionType,
|
||||||
TransformStage as InnerTransitionStage,
|
TransformStage as InnerTransitionStage,
|
||||||
|
IPublicCommonDesignerCabin,
|
||||||
|
IPublicCommonSkeletonCabin,
|
||||||
|
IPublicCommonUtils,
|
||||||
|
IPublicApiCommon,
|
||||||
|
DragObjectType as InnerDragObjectType,
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
import {
|
import {
|
||||||
SettingField as InnerSettingField,
|
SettingField as InnerSettingField,
|
||||||
@ -19,7 +24,6 @@ import {
|
|||||||
isDragNodeDataObject as innerIsDragNodeDataObject,
|
isDragNodeDataObject as innerIsDragNodeDataObject,
|
||||||
isDragNodeObject as innerIsDragNodeObject,
|
isDragNodeObject as innerIsDragNodeObject,
|
||||||
isDragAnyObject as innerIsDragAnyObject,
|
isDragAnyObject as innerIsDragAnyObject,
|
||||||
DragObjectType as InnerDragObjectType,
|
|
||||||
isNode as innerIsNode,
|
isNode as innerIsNode,
|
||||||
isShaken as innerIsShaken,
|
isShaken as innerIsShaken,
|
||||||
contains as innerContains,
|
contains as innerContains,
|
||||||
@ -56,7 +60,7 @@ import {
|
|||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
|
|
||||||
class DesignerCabin {
|
class DesignerCabin implements IPublicCommonDesignerCabin {
|
||||||
private readonly [editorSymbol]: Editor;
|
private readonly [editorSymbol]: Editor;
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
@ -147,7 +151,7 @@ class DesignerCabin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SkeletonCabin {
|
class SkeletonCabin implements IPublicCommonSkeletonCabin {
|
||||||
private readonly [skeletonSymbol]: InnerSkeleton;
|
private readonly [skeletonSymbol]: InnerSkeleton;
|
||||||
|
|
||||||
constructor(skeleton: InnerSkeleton) {
|
constructor(skeleton: InnerSkeleton) {
|
||||||
@ -181,7 +185,7 @@ class SkeletonCabin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Utils {
|
class Utils implements IPublicCommonUtils {
|
||||||
isNodeSchema(data: any): data is NodeSchema {
|
isNodeSchema(data: any): data is NodeSchema {
|
||||||
return innerIsNodeSchema(data);
|
return innerIsNodeSchema(data);
|
||||||
}
|
}
|
||||||
@ -314,7 +318,7 @@ class EditorCabin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default class Common {
|
export default class Common implements IPublicApiCommon {
|
||||||
private readonly __designerCabin: any;
|
private readonly __designerCabin: any;
|
||||||
private readonly __skeletonCabin: any;
|
private readonly __skeletonCabin: any;
|
||||||
private readonly __editorCabin: any;
|
private readonly __editorCabin: any;
|
||||||
|
|||||||
@ -2,19 +2,21 @@ import {
|
|||||||
ComponentMeta as InnerComponentMeta,
|
ComponentMeta as InnerComponentMeta,
|
||||||
ParentalNode,
|
ParentalNode,
|
||||||
} from '@alilc/lowcode-designer';
|
} from '@alilc/lowcode-designer';
|
||||||
import Node from './node';
|
import { NodeData, NodeSchema, IPublicModelComponentMeta, I18nData, IconType, NpmInfo, TransformedComponentMetadata, IPublicModelNode } from '@alilc/lowcode-types';
|
||||||
import { NodeData, NodeSchema } from '@alilc/lowcode-types';
|
|
||||||
import { componentMetaSymbol, nodeSymbol } from './symbols';
|
import { componentMetaSymbol, nodeSymbol } from './symbols';
|
||||||
|
import { ReactElement } from 'react';
|
||||||
|
|
||||||
export default class ComponentMeta {
|
export default class ComponentMeta implements IPublicModelComponentMeta {
|
||||||
private readonly [componentMetaSymbol]: InnerComponentMeta;
|
private readonly [componentMetaSymbol]: InnerComponentMeta;
|
||||||
|
|
||||||
constructor(componentMeta: InnerComponentMeta) {
|
constructor(componentMeta: InnerComponentMeta) {
|
||||||
this[componentMetaSymbol] = componentMeta;
|
this[componentMetaSymbol] = componentMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(componentMeta: InnerComponentMeta | null) {
|
static create(componentMeta: InnerComponentMeta | null): IPublicModelComponentMeta | null {
|
||||||
if (!componentMeta) return null;
|
if (!componentMeta) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new ComponentMeta(componentMeta);
|
return new ComponentMeta(componentMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,28 +54,28 @@ export default class ComponentMeta {
|
|||||||
/**
|
/**
|
||||||
* 元数据配置
|
* 元数据配置
|
||||||
*/
|
*/
|
||||||
get configure() {
|
get configure(): any {
|
||||||
return this[componentMetaSymbol].configure;
|
return this[componentMetaSymbol].configure;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标题
|
* 标题
|
||||||
*/
|
*/
|
||||||
get title() {
|
get title(): string | I18nData | ReactElement {
|
||||||
return this[componentMetaSymbol].title;
|
return this[componentMetaSymbol].title;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 图标
|
* 图标
|
||||||
*/
|
*/
|
||||||
get icon() {
|
get icon(): IconType {
|
||||||
return this[componentMetaSymbol].icon;
|
return this[componentMetaSymbol].icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组件 npm 信息
|
* 组件 npm 信息
|
||||||
*/
|
*/
|
||||||
get npm() {
|
get npm(): NpmInfo {
|
||||||
return this[componentMetaSymbol].npm;
|
return this[componentMetaSymbol].npm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +86,7 @@ export default class ComponentMeta {
|
|||||||
return this[componentMetaSymbol].prototype;
|
return this[componentMetaSymbol].prototype;
|
||||||
}
|
}
|
||||||
|
|
||||||
get availableActions() {
|
get availableActions(): any {
|
||||||
return this[componentMetaSymbol].availableActions;
|
return this[componentMetaSymbol].availableActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +94,7 @@ export default class ComponentMeta {
|
|||||||
* 设置 npm 信息
|
* 设置 npm 信息
|
||||||
* @param npm
|
* @param npm
|
||||||
*/
|
*/
|
||||||
setNpm(npm: any) {
|
setNpm(npm: NpmInfo): void {
|
||||||
this[componentMetaSymbol].setNpm(npm);
|
this[componentMetaSymbol].setNpm(npm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +102,7 @@ export default class ComponentMeta {
|
|||||||
* 获取元数据
|
* 获取元数据
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getMetadata() {
|
getMetadata(): TransformedComponentMetadata {
|
||||||
return this[componentMetaSymbol].getMetadata();
|
return this[componentMetaSymbol].getMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,8 +112,8 @@ export default class ComponentMeta {
|
|||||||
* @param parent
|
* @param parent
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
checkNestingUp(my: Node | NodeData, parent: ParentalNode<NodeSchema>) {
|
checkNestingUp(my: IPublicModelNode | NodeData, parent: ParentalNode<NodeSchema>): boolean {
|
||||||
const curNode = my.isNode ? my[nodeSymbol] : my;
|
const curNode = (my as any).isNode ? (my as any)[nodeSymbol] : my;
|
||||||
return this[componentMetaSymbol].checkNestingUp(curNode as any, parent);
|
return this[componentMetaSymbol].checkNestingUp(curNode as any, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,12 +123,12 @@ export default class ComponentMeta {
|
|||||||
* @param parent
|
* @param parent
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
checkNestingDown(my: Node | NodeData, target: NodeSchema | Node | NodeSchema[]) {
|
checkNestingDown(my: IPublicModelNode | NodeData, target: NodeSchema | IPublicModelNode | NodeSchema[]) {
|
||||||
const curNode = my.isNode ? my[nodeSymbol] : my;
|
const curNode = (my as any)?.isNode ? (my as any)[nodeSymbol] : my;
|
||||||
return this[componentMetaSymbol].checkNestingDown(curNode as any, target[nodeSymbol] || target);
|
return this[componentMetaSymbol].checkNestingDown(curNode as any, (target as any)[nodeSymbol] || target);
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshMetadata() {
|
refreshMetadata(): void {
|
||||||
this[componentMetaSymbol].refreshMetadata();
|
this[componentMetaSymbol].refreshMetadata();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,8 +4,9 @@ import {
|
|||||||
DocumentModel as InnerDocumentModel,
|
DocumentModel as InnerDocumentModel,
|
||||||
} from '@alilc/lowcode-designer';
|
} from '@alilc/lowcode-designer';
|
||||||
import { documentSymbol, detectingSymbol } from './symbols';
|
import { documentSymbol, detectingSymbol } from './symbols';
|
||||||
|
import { IPublicModelDetecting } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export default class Detecting {
|
export default class Detecting implements IPublicModelDetecting {
|
||||||
private readonly [documentSymbol]: InnerDocumentModel;
|
private readonly [documentSymbol]: InnerDocumentModel;
|
||||||
private readonly [detectingSymbol]: InnerDetecting;
|
private readonly [detectingSymbol]: InnerDetecting;
|
||||||
|
|
||||||
|
|||||||
@ -2,16 +2,26 @@ import { Editor } from '@alilc/lowcode-editor-core';
|
|||||||
import {
|
import {
|
||||||
DocumentModel as InnerDocumentModel,
|
DocumentModel as InnerDocumentModel,
|
||||||
Node as InnerNode,
|
Node as InnerNode,
|
||||||
IOnChangeOptions as InnerIOnChangeOptions,
|
|
||||||
DragObject as InnerDragObject,
|
|
||||||
DragNodeObject,
|
|
||||||
DragNodeDataObject,
|
|
||||||
isDragNodeObject,
|
isDragNodeObject,
|
||||||
|
IOnChangeOptions as InnerOnChangeOptions,
|
||||||
} from '@alilc/lowcode-designer';
|
} from '@alilc/lowcode-designer';
|
||||||
import {
|
import {
|
||||||
TransformStage,
|
TransformStage,
|
||||||
RootSchema,
|
RootSchema,
|
||||||
GlobalEvent,
|
GlobalEvent,
|
||||||
|
IPublicModelDocumentModel,
|
||||||
|
IPublicOnChangeOptions,
|
||||||
|
DragObject,
|
||||||
|
DragNodeObject,
|
||||||
|
DragNodeDataObject,
|
||||||
|
IPublicModelNode,
|
||||||
|
IPublicModelSelection,
|
||||||
|
IPublicModelDetecting,
|
||||||
|
IPublicModelHistory,
|
||||||
|
IPublicModelCanvas,
|
||||||
|
IPublicApiProject,
|
||||||
|
IPublicModelModalNodesManager,
|
||||||
|
PropChangeOptions,
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
import Node from './node';
|
import Node from './node';
|
||||||
import Selection from './selection';
|
import Selection from './selection';
|
||||||
@ -23,33 +33,20 @@ import Canvas from './canvas';
|
|||||||
import ModalNodesManager from './modal-nodes-manager';
|
import ModalNodesManager from './modal-nodes-manager';
|
||||||
import { documentSymbol, editorSymbol, nodeSymbol } from './symbols';
|
import { documentSymbol, editorSymbol, nodeSymbol } from './symbols';
|
||||||
|
|
||||||
type IOnChangeOptions = {
|
|
||||||
type: string;
|
|
||||||
node: Node;
|
|
||||||
};
|
|
||||||
|
|
||||||
type PropChangeOptions = {
|
|
||||||
key?: string | number;
|
|
||||||
prop?: Prop;
|
|
||||||
node: Node;
|
|
||||||
newValue: any;
|
|
||||||
oldValue: any;
|
|
||||||
};
|
|
||||||
|
|
||||||
const Events = {
|
const Events = {
|
||||||
IMPORT_SCHEMA: 'shell.document.importSchema',
|
IMPORT_SCHEMA: 'shell.document.importSchema',
|
||||||
};
|
};
|
||||||
|
|
||||||
const shellDocSymbol = Symbol('shellDocSymbol');
|
const shellDocSymbol = Symbol('shellDocSymbol');
|
||||||
|
|
||||||
export default class DocumentModel {
|
export default class DocumentModel implements IPublicModelDocumentModel {
|
||||||
private readonly [documentSymbol]: InnerDocumentModel;
|
private readonly [documentSymbol]: InnerDocumentModel;
|
||||||
private readonly [editorSymbol]: Editor;
|
private readonly [editorSymbol]: Editor;
|
||||||
private _focusNode: Node;
|
private _focusNode: IPublicModelNode | null;
|
||||||
public selection: Selection;
|
selection: IPublicModelSelection;
|
||||||
public detecting: Detecting;
|
detecting: IPublicModelDetecting;
|
||||||
public history: History;
|
history: IPublicModelHistory;
|
||||||
public canvas: Canvas;
|
canvas: IPublicModelCanvas;
|
||||||
|
|
||||||
constructor(document: InnerDocumentModel) {
|
constructor(document: InnerDocumentModel) {
|
||||||
this[documentSymbol] = document;
|
this[documentSymbol] = document;
|
||||||
@ -62,10 +59,14 @@ export default class DocumentModel {
|
|||||||
this._focusNode = Node.create(this[documentSymbol].focusNode);
|
this._focusNode = Node.create(this[documentSymbol].focusNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(document: InnerDocumentModel | undefined | null) {
|
static create(document: InnerDocumentModel | undefined | null): IPublicModelDocumentModel | null {
|
||||||
if (!document) return null;
|
if (!document) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// @ts-ignore 直接返回已挂载的 shell doc 实例
|
// @ts-ignore 直接返回已挂载的 shell doc 实例
|
||||||
if (document[shellDocSymbol]) return document[shellDocSymbol];
|
if (document[shellDocSymbol]) {
|
||||||
|
return (document as any)[shellDocSymbol];
|
||||||
|
}
|
||||||
const shellDoc = new DocumentModel(document);
|
const shellDoc = new DocumentModel(document);
|
||||||
// @ts-ignore 直接返回已挂载的 shell doc 实例
|
// @ts-ignore 直接返回已挂载的 shell doc 实例
|
||||||
document[shellDocSymbol] = shellDoc;
|
document[shellDocSymbol] = shellDoc;
|
||||||
@ -75,7 +76,7 @@ export default class DocumentModel {
|
|||||||
/**
|
/**
|
||||||
* id
|
* id
|
||||||
*/
|
*/
|
||||||
get id() {
|
get id(): string {
|
||||||
return this[documentSymbol].id;
|
return this[documentSymbol].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +88,7 @@ export default class DocumentModel {
|
|||||||
* 获取当前文档所属的 project
|
* 获取当前文档所属的 project
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
get project() {
|
get project(): IPublicApiProject | null {
|
||||||
return Project.create(this[documentSymbol].project);
|
return Project.create(this[documentSymbol].project);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,15 +96,15 @@ export default class DocumentModel {
|
|||||||
* 获取文档的根节点
|
* 获取文档的根节点
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
get root(): Node | null {
|
get root(): IPublicModelNode | null {
|
||||||
return Node.create(this[documentSymbol].getRoot());
|
return Node.create(this[documentSymbol].getRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
get focusNode(): Node {
|
get focusNode(): IPublicModelNode | null {
|
||||||
return this._focusNode || this.root;
|
return this._focusNode || this.root;
|
||||||
}
|
}
|
||||||
|
|
||||||
set focusNode(node: Node) {
|
set focusNode(node: IPublicModelNode | null) {
|
||||||
this._focusNode = node;
|
this._focusNode = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,8 +112,8 @@ export default class DocumentModel {
|
|||||||
* 获取文档下所有节点
|
* 获取文档下所有节点
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
get nodesMap() {
|
get nodesMap(): any {
|
||||||
const map = new Map<string, Node>();
|
const map = new Map<string, IPublicModelNode>();
|
||||||
for (let id of this[documentSymbol].nodesMap.keys()) {
|
for (let id of this[documentSymbol].nodesMap.keys()) {
|
||||||
map.set(id, this.getNodeById(id)!);
|
map.set(id, this.getNodeById(id)!);
|
||||||
}
|
}
|
||||||
@ -122,12 +123,15 @@ export default class DocumentModel {
|
|||||||
/**
|
/**
|
||||||
* 模态节点管理
|
* 模态节点管理
|
||||||
*/
|
*/
|
||||||
get modalNodesManager() {
|
get modalNodesManager(): IPublicModelModalNodesManager | null {
|
||||||
return ModalNodesManager.create(this[documentSymbol].modalNodesManager);
|
return ModalNodesManager.create(this[documentSymbol].modalNodesManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO: 不能直接暴露
|
/**
|
||||||
get dropLocation() {
|
* @TODO: 不能直接暴露
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
get dropLocation(): any {
|
||||||
return this[documentSymbol].dropLocation;
|
return this[documentSymbol].dropLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +140,7 @@ export default class DocumentModel {
|
|||||||
* @param nodeId
|
* @param nodeId
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getNodeById(nodeId: string) {
|
getNodeById(nodeId: string): IPublicModelNode | null {
|
||||||
return Node.create(this[documentSymbol].getNode(nodeId));
|
return Node.create(this[documentSymbol].getNode(nodeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +148,7 @@ export default class DocumentModel {
|
|||||||
* 导入 schema
|
* 导入 schema
|
||||||
* @param schema
|
* @param schema
|
||||||
*/
|
*/
|
||||||
importSchema(schema: RootSchema) {
|
importSchema(schema: RootSchema): void {
|
||||||
this[documentSymbol].import(schema);
|
this[documentSymbol].import(schema);
|
||||||
this[editorSymbol].emit(Events.IMPORT_SCHEMA, schema);
|
this[editorSymbol].emit(Events.IMPORT_SCHEMA, schema);
|
||||||
}
|
}
|
||||||
@ -154,7 +158,7 @@ export default class DocumentModel {
|
|||||||
* @param stage
|
* @param stage
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
exportSchema(stage: TransformStage = TransformStage.Render) {
|
exportSchema(stage: TransformStage = TransformStage.Render): any {
|
||||||
return this[documentSymbol].export(stage);
|
return this[documentSymbol].export(stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,14 +171,14 @@ export default class DocumentModel {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
insertNode(
|
insertNode(
|
||||||
parent: Node,
|
parent: IPublicModelNode,
|
||||||
thing: Node,
|
thing: IPublicModelNode,
|
||||||
at?: number | null | undefined,
|
at?: number | null | undefined,
|
||||||
copy?: boolean | undefined,
|
copy?: boolean | undefined,
|
||||||
) {
|
): IPublicModelNode | null {
|
||||||
const node = this[documentSymbol].insertNode(
|
const node = this[documentSymbol].insertNode(
|
||||||
parent[nodeSymbol] ? parent[nodeSymbol] : parent,
|
(parent as any)[nodeSymbol] ? (parent as any)[nodeSymbol] : parent,
|
||||||
thing?.[nodeSymbol] ? thing[nodeSymbol] : thing,
|
(thing as any)?.[nodeSymbol] ? (thing as any)[nodeSymbol] : thing,
|
||||||
at,
|
at,
|
||||||
copy,
|
copy,
|
||||||
);
|
);
|
||||||
@ -186,7 +190,7 @@ export default class DocumentModel {
|
|||||||
* @param data
|
* @param data
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
createNode(data: any) {
|
createNode(data: any): IPublicModelNode | null {
|
||||||
return Node.create(this[documentSymbol].createNode(data));
|
return Node.create(this[documentSymbol].createNode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +198,7 @@ export default class DocumentModel {
|
|||||||
* 移除指定节点/节点id
|
* 移除指定节点/节点id
|
||||||
* @param idOrNode
|
* @param idOrNode
|
||||||
*/
|
*/
|
||||||
removeNode(idOrNode: string | Node) {
|
removeNode(idOrNode: string | IPublicModelNode): void {
|
||||||
this[documentSymbol].removeNode(idOrNode as any);
|
this[documentSymbol].removeNode(idOrNode as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +207,7 @@ export default class DocumentModel {
|
|||||||
* @param extraComps
|
* @param extraComps
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getComponentsMap(extraComps?: string[]) {
|
getComponentsMap(extraComps?: string[]): any {
|
||||||
return this[documentSymbol].getComponentsMap(extraComps);
|
return this[documentSymbol].getComponentsMap(extraComps);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,13 +217,16 @@ export default class DocumentModel {
|
|||||||
* @param dragObject 拖拽的对象
|
* @param dragObject 拖拽的对象
|
||||||
* @returns boolean 是否可以放置
|
* @returns boolean 是否可以放置
|
||||||
*/
|
*/
|
||||||
checkNesting(dropTarget: Node, dragObject: DragNodeObject | DragNodeDataObject): boolean {
|
checkNesting(
|
||||||
let innerDragObject: InnerDragObject = dragObject;
|
dropTarget: IPublicModelNode,
|
||||||
|
dragObject: DragNodeObject | DragNodeDataObject,
|
||||||
|
): boolean {
|
||||||
|
let innerDragObject: DragObject = dragObject;
|
||||||
if (isDragNodeObject(dragObject)) {
|
if (isDragNodeObject(dragObject)) {
|
||||||
innerDragObject.nodes = innerDragObject.nodes.map((node: Node) => (node[nodeSymbol] || node));
|
innerDragObject.nodes = innerDragObject.nodes.map((node: Node) => (node[nodeSymbol] || node));
|
||||||
}
|
}
|
||||||
return this[documentSymbol].checkNesting(
|
return this[documentSymbol].checkNesting(
|
||||||
(dropTarget[nodeSymbol] || dropTarget) as any,
|
((dropTarget as any)[nodeSymbol] || dropTarget) as any,
|
||||||
innerDragObject as any,
|
innerDragObject as any,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -227,7 +234,7 @@ export default class DocumentModel {
|
|||||||
/**
|
/**
|
||||||
* 当前 document 新增节点事件
|
* 当前 document 新增节点事件
|
||||||
*/
|
*/
|
||||||
onAddNode(fn: (node: Node) => void) {
|
onAddNode(fn: (node: IPublicModelNode) => void): () => void {
|
||||||
return this[documentSymbol].onNodeCreate((node: InnerNode) => {
|
return this[documentSymbol].onNodeCreate((node: InnerNode) => {
|
||||||
fn(Node.create(node)!);
|
fn(Node.create(node)!);
|
||||||
});
|
});
|
||||||
@ -236,7 +243,7 @@ export default class DocumentModel {
|
|||||||
/**
|
/**
|
||||||
* 当前 document 新增节点事件,此时节点已经挂载到 document 上
|
* 当前 document 新增节点事件,此时节点已经挂载到 document 上
|
||||||
*/
|
*/
|
||||||
onMountNode(fn: (payload: { node: Node }) => void) {
|
onMountNode(fn: (payload: { node: IPublicModelNode }) => void): () => void {
|
||||||
this[editorSymbol].on('node.add', fn as any);
|
this[editorSymbol].on('node.add', fn as any);
|
||||||
return () => {
|
return () => {
|
||||||
this[editorSymbol].off('node.add', fn as any);
|
this[editorSymbol].off('node.add', fn as any);
|
||||||
@ -246,7 +253,7 @@ export default class DocumentModel {
|
|||||||
/**
|
/**
|
||||||
* 当前 document 删除节点事件
|
* 当前 document 删除节点事件
|
||||||
*/
|
*/
|
||||||
onRemoveNode(fn: (node: Node) => void) {
|
onRemoveNode(fn: (node: IPublicModelNode) => void): () => void {
|
||||||
return this[documentSymbol].onNodeDestroy((node: InnerNode) => {
|
return this[documentSymbol].onNodeDestroy((node: InnerNode) => {
|
||||||
fn(Node.create(node)!);
|
fn(Node.create(node)!);
|
||||||
});
|
});
|
||||||
@ -255,7 +262,7 @@ export default class DocumentModel {
|
|||||||
/**
|
/**
|
||||||
* 当前 document 的 hover 变更事件
|
* 当前 document 的 hover 变更事件
|
||||||
*/
|
*/
|
||||||
onChangeDetecting(fn: (node: Node) => void) {
|
onChangeDetecting(fn: (node: IPublicModelNode) => void): () => void {
|
||||||
return this[documentSymbol].designer.detecting.onDetectingChange((node: InnerNode) => {
|
return this[documentSymbol].designer.detecting.onDetectingChange((node: InnerNode) => {
|
||||||
fn(Node.create(node)!);
|
fn(Node.create(node)!);
|
||||||
});
|
});
|
||||||
@ -264,7 +271,7 @@ export default class DocumentModel {
|
|||||||
/**
|
/**
|
||||||
* 当前 document 的选中变更事件
|
* 当前 document 的选中变更事件
|
||||||
*/
|
*/
|
||||||
onChangeSelection(fn: (ids: string[]) => void) {
|
onChangeSelection(fn: (ids: string[]) => void): () => void {
|
||||||
return this[documentSymbol].selection.onSelectionChange((ids: string[]) => {
|
return this[documentSymbol].selection.onSelectionChange((ids: string[]) => {
|
||||||
fn(ids);
|
fn(ids);
|
||||||
});
|
});
|
||||||
@ -274,9 +281,9 @@ export default class DocumentModel {
|
|||||||
* 当前 document 的节点显隐状态变更事件
|
* 当前 document 的节点显隐状态变更事件
|
||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
onChangeNodeVisible(fn: (node: Node, visible: boolean) => void) {
|
onChangeNodeVisible(fn: (node: IPublicModelNode, visible: boolean) => void): void {
|
||||||
// TODO: history 变化时需要重新绑定
|
// TODO: history 变化时需要重新绑定
|
||||||
this[documentSymbol].nodesMap.forEach((node) => {
|
this[documentSymbol].nodesMap?.forEach((node) => {
|
||||||
node.onVisibleChange((flag: boolean) => {
|
node.onVisibleChange((flag: boolean) => {
|
||||||
fn(Node.create(node)!, flag);
|
fn(Node.create(node)!, flag);
|
||||||
});
|
});
|
||||||
@ -287,10 +294,10 @@ export default class DocumentModel {
|
|||||||
* 当前 document 的节点 children 变更事件
|
* 当前 document 的节点 children 变更事件
|
||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
onChangeNodeChildren(fn: (info?: IOnChangeOptions) => void) {
|
onChangeNodeChildren(fn: (info?: IPublicOnChangeOptions) => void): void {
|
||||||
// TODO: history 变化时需要重新绑定
|
// TODO: history 变化时需要重新绑定
|
||||||
this[documentSymbol].nodesMap.forEach((node) => {
|
this[documentSymbol].nodesMap?.forEach((node) => {
|
||||||
node.onChildrenChange((info?: InnerIOnChangeOptions) => {
|
node.onChildrenChange((info?: InnerOnChangeOptions) => {
|
||||||
return info
|
return info
|
||||||
? fn({
|
? fn({
|
||||||
type: info.type,
|
type: info.type,
|
||||||
@ -305,7 +312,7 @@ export default class DocumentModel {
|
|||||||
* 当前 document 节点属性修改事件
|
* 当前 document 节点属性修改事件
|
||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
onChangeNodeProp(fn: (info: PropChangeOptions) => void) {
|
onChangeNodeProp(fn: (info: PropChangeOptions) => void): void {
|
||||||
this[editorSymbol].on(
|
this[editorSymbol].on(
|
||||||
GlobalEvent.Node.Prop.InnerChange,
|
GlobalEvent.Node.Prop.InnerChange,
|
||||||
(info: GlobalEvent.Node.Prop.ChangeOptions) => {
|
(info: GlobalEvent.Node.Prop.ChangeOptions) => {
|
||||||
@ -324,7 +331,7 @@ export default class DocumentModel {
|
|||||||
* import schema event
|
* import schema event
|
||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
onImportSchema(fn: (schema: RootSchema) => void) {
|
onImportSchema(fn: (schema: RootSchema) => void): void {
|
||||||
this[editorSymbol].on(Events.IMPORT_SCHEMA, fn as any);
|
this[editorSymbol].on(Events.IMPORT_SCHEMA, fn as any);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,30 +1,34 @@
|
|||||||
import { DragObject as InnerDragObject, DragNodeDataObject } from '@alilc/lowcode-designer';
|
|
||||||
import { dragObjectSymbol } from './symbols';
|
import { dragObjectSymbol } from './symbols';
|
||||||
|
import { IPublicModelDragObject, DragObject as InnerDragObject, DragNodeDataObject } from '@alilc/lowcode-types';
|
||||||
import Node from './node';
|
import Node from './node';
|
||||||
|
|
||||||
export default class DragObject {
|
export default class DragObject implements IPublicModelDragObject {
|
||||||
private readonly [dragObjectSymbol]: InnerDragObject;
|
private readonly [dragObjectSymbol]: InnerDragObject;
|
||||||
|
|
||||||
constructor(dragObject: InnerDragObject) {
|
constructor(dragObject: InnerDragObject) {
|
||||||
this[dragObjectSymbol] = dragObject;
|
this[dragObjectSymbol] = dragObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(dragObject: InnerDragObject) {
|
static create(dragObject: InnerDragObject): IPublicModelDragObject | null {
|
||||||
if (!dragObject) return null;
|
if (!dragObject) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new DragObject(dragObject);
|
return new DragObject(dragObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
get type() {
|
get type(): any {
|
||||||
return this[dragObjectSymbol].type;
|
return this[dragObjectSymbol].type;
|
||||||
}
|
}
|
||||||
|
|
||||||
get nodes() {
|
get nodes(): any {
|
||||||
const { nodes } = this[dragObjectSymbol];
|
const { nodes } = this[dragObjectSymbol];
|
||||||
if (!nodes) return null;
|
if (!nodes) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return nodes.map(Node.create);
|
return nodes.map(Node.create);
|
||||||
}
|
}
|
||||||
|
|
||||||
get data() {
|
get data(): any {
|
||||||
return (this[dragObjectSymbol] as DragNodeDataObject).data;
|
return (this[dragObjectSymbol] as DragNodeDataObject).data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,29 +1,36 @@
|
|||||||
import {
|
import {
|
||||||
Dragon as InnerDragon,
|
Dragon as InnerDragon,
|
||||||
DragObject as InnerDragObject,
|
|
||||||
DragNodeDataObject,
|
|
||||||
LocateEvent as InnerLocateEvent,
|
LocateEvent as InnerLocateEvent,
|
||||||
} from '@alilc/lowcode-designer';
|
} from '@alilc/lowcode-designer';
|
||||||
import { dragonSymbol } from './symbols';
|
import { dragonSymbol } from './symbols';
|
||||||
import LocateEvent from './locate-event';
|
import LocateEvent from './locate-event';
|
||||||
import DragObject from './drag-object';
|
import DragObject from './drag-object';
|
||||||
|
import {
|
||||||
|
IPublicModelDragon,
|
||||||
|
IPublicModelLocateEvent,
|
||||||
|
IPublicModelDragObject,
|
||||||
|
DragObject as InnerDragObject,
|
||||||
|
DragNodeDataObject,
|
||||||
|
} from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export default class Dragon {
|
export default class Dragon implements IPublicModelDragon {
|
||||||
private readonly [dragonSymbol]: InnerDragon;
|
private readonly [dragonSymbol]: InnerDragon;
|
||||||
|
|
||||||
constructor(dragon: InnerDragon) {
|
constructor(dragon: InnerDragon) {
|
||||||
this[dragonSymbol] = dragon;
|
this[dragonSymbol] = dragon;
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(dragon: InnerDragon | null) {
|
static create(dragon: InnerDragon | null): IPublicModelDragon | null {
|
||||||
if (!dragon) return null;
|
if (!dragon) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new Dragon(dragon);
|
return new Dragon(dragon);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* is dragging or not
|
* is dragging or not
|
||||||
*/
|
*/
|
||||||
get dragging() {
|
get dragging(): boolean {
|
||||||
return this[dragonSymbol].dragging;
|
return this[dragonSymbol].dragging;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +39,7 @@ export default class Dragon {
|
|||||||
* @param func
|
* @param func
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
onDragstart(func: (e: LocateEvent) => any) {
|
onDragstart(func: (e: IPublicModelLocateEvent) => any): () => void {
|
||||||
return this[dragonSymbol].onDragstart((e: InnerLocateEvent) => func(LocateEvent.create(e)!));
|
return this[dragonSymbol].onDragstart((e: InnerLocateEvent) => func(LocateEvent.create(e)!));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +48,7 @@ export default class Dragon {
|
|||||||
* @param func
|
* @param func
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
onDrag(func: (e: LocateEvent) => any) {
|
onDrag(func: (e: IPublicModelLocateEvent) => any): () => void {
|
||||||
return this[dragonSymbol].onDrag((e: InnerLocateEvent) => func(LocateEvent.create(e)!));
|
return this[dragonSymbol].onDrag((e: InnerLocateEvent) => func(LocateEvent.create(e)!));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +57,7 @@ export default class Dragon {
|
|||||||
* @param func
|
* @param func
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
onDragend(func: (o: { dragObject: DragObject; copy?: boolean }) => any) {
|
onDragend(func: (o: { dragObject: IPublicModelDragObject; copy?: boolean }) => any): () => void {
|
||||||
return this[dragonSymbol].onDragend(
|
return this[dragonSymbol].onDragend(
|
||||||
(o: { dragObject: InnerDragObject; copy?: boolean }) => func({
|
(o: { dragObject: InnerDragObject; copy?: boolean }) => func({
|
||||||
dragObject: DragObject.create(o.dragObject)!,
|
dragObject: DragObject.create(o.dragObject)!,
|
||||||
@ -64,7 +71,7 @@ export default class Dragon {
|
|||||||
* @param shell 拖拽监听的区域
|
* @param shell 拖拽监听的区域
|
||||||
* @param boost 拖拽转换函数
|
* @param boost 拖拽转换函数
|
||||||
*/
|
*/
|
||||||
from(shell: Element, boost: (e: MouseEvent) => DragNodeDataObject | null) {
|
from(shell: Element, boost: (e: MouseEvent) => DragNodeDataObject | null): any {
|
||||||
return this[dragonSymbol].from(shell, boost);
|
return this[dragonSymbol].from(shell, boost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,16 +3,19 @@ import {
|
|||||||
} from '@alilc/lowcode-designer';
|
} from '@alilc/lowcode-designer';
|
||||||
import { dropLocationSymbol } from './symbols';
|
import { dropLocationSymbol } from './symbols';
|
||||||
import Node from './node';
|
import Node from './node';
|
||||||
|
import { IPublicModelDropLocation } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export default class DropLocation {
|
export default class DropLocation implements IPublicModelDropLocation {
|
||||||
private readonly [dropLocationSymbol]: InnerDropLocation;
|
private readonly [dropLocationSymbol]: InnerDropLocation;
|
||||||
|
|
||||||
constructor(dropLocation: InnerDropLocation) {
|
constructor(dropLocation: InnerDropLocation) {
|
||||||
this[dropLocationSymbol] = dropLocation;
|
this[dropLocationSymbol] = dropLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(dropLocation: InnerDropLocation | null) {
|
static create(dropLocation: InnerDropLocation | null): DropLocation | null {
|
||||||
if (!dropLocation) return null;
|
if (!dropLocation) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new DropLocation(dropLocation);
|
return new DropLocation(dropLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { Editor as InnerEditor, globalContext } from '@alilc/lowcode-editor-core';
|
import { Editor as InnerEditor } from '@alilc/lowcode-editor-core';
|
||||||
import { getLogger } from '@alilc/lowcode-utils';
|
import { getLogger } from '@alilc/lowcode-utils';
|
||||||
import { editorSymbol } from './symbols';
|
import { editorSymbol } from './symbols';
|
||||||
|
import { IPublicApiEvent } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
const logger = getLogger({ level: 'warn', bizName: 'shell:event' });
|
const logger = getLogger({ level: 'warn', bizName: 'shell:event' });
|
||||||
|
|
||||||
@ -8,7 +9,7 @@ type EventOptions = {
|
|||||||
prefix: string;
|
prefix: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class Event {
|
export default class Event implements IPublicApiEvent {
|
||||||
private readonly [editorSymbol]: InnerEditor;
|
private readonly [editorSymbol]: InnerEditor;
|
||||||
private readonly options: EventOptions;
|
private readonly options: EventOptions;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import { History as InnerHistory, DocumentModel as InnerDocumentModel } from '@alilc/lowcode-designer';
|
import { DocumentModel as InnerDocumentModel } from '@alilc/lowcode-designer';
|
||||||
import { historySymbol, documentSymbol } from './symbols';
|
import { historySymbol, documentSymbol } from './symbols';
|
||||||
|
import { IPublicModelHistory } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export default class History {
|
export default class History implements IPublicModelHistory {
|
||||||
private readonly [documentSymbol]: InnerDocumentModel;
|
private readonly [documentSymbol]: InnerDocumentModel;
|
||||||
|
|
||||||
private get [historySymbol]() {
|
private get [historySymbol]() {
|
||||||
@ -16,28 +17,28 @@ export default class History {
|
|||||||
* 历史记录跳转到指定位置
|
* 历史记录跳转到指定位置
|
||||||
* @param cursor
|
* @param cursor
|
||||||
*/
|
*/
|
||||||
go(cursor: number) {
|
go(cursor: number): void {
|
||||||
this[historySymbol].go(cursor);
|
this[historySymbol].go(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 历史记录后退
|
* 历史记录后退
|
||||||
*/
|
*/
|
||||||
back() {
|
back(): void {
|
||||||
this[historySymbol].back();
|
this[historySymbol].back();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 历史记录前进
|
* 历史记录前进
|
||||||
*/
|
*/
|
||||||
forward() {
|
forward(): void {
|
||||||
this[historySymbol].forward();
|
this[historySymbol].forward();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存当前状态
|
* 保存当前状态
|
||||||
*/
|
*/
|
||||||
savePoint() {
|
savePoint(): void {
|
||||||
this[historySymbol].savePoint();
|
this[historySymbol].savePoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ export default class History {
|
|||||||
* 当前是否是「保存点」,即是否有状态变更但未保存
|
* 当前是否是「保存点」,即是否有状态变更但未保存
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
isSavePoint() {
|
isSavePoint(): boolean {
|
||||||
return this[historySymbol].isSavePoint();
|
return this[historySymbol].isSavePoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ export default class History {
|
|||||||
* 获取 state,判断当前是否为「可回退」、「可前进」的状态
|
* 获取 state,判断当前是否为「可回退」、「可前进」的状态
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getState() {
|
getState(): any {
|
||||||
return this[historySymbol].getState();
|
return this[historySymbol].getState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ export default class History {
|
|||||||
* @param func
|
* @param func
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
onChangeState(func: () => any) {
|
onChangeState(func: () => any): () => void {
|
||||||
return this[historySymbol].onStateChange(func);
|
return this[historySymbol].onStateChange(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ export default class History {
|
|||||||
* @param func
|
* @param func
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
onChangeCursor(func: () => any) {
|
onChangeCursor(func: () => any): () => void {
|
||||||
return this[historySymbol].onCursor(func);
|
return this[historySymbol].onCursor(func);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { hotkey, HotkeyCallback } from '@alilc/lowcode-editor-core';
|
import { hotkey } from '@alilc/lowcode-editor-core';
|
||||||
import { Disposable } from '@alilc/lowcode-types';
|
import { Disposable, HotkeyCallback, IPublicApiHotkey } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export default class Hotkey {
|
export default class Hotkey implements IPublicApiHotkey {
|
||||||
get callbacks() {
|
get callbacks() {
|
||||||
return hotkey.callBacks;
|
return hotkey.callBacks;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,48 +1,51 @@
|
|||||||
import { LocateEvent as InnerLocateEvent } from '@alilc/lowcode-designer';
|
import { LocateEvent as InnerLocateEvent } from '@alilc/lowcode-designer';
|
||||||
import { locateEventSymbol } from './symbols';
|
import { locateEventSymbol } from './symbols';
|
||||||
import DragObject from './drag-object';
|
import DragObject from './drag-object';
|
||||||
|
import { IPublicModelLocateEvent, IPublicModelDragObject } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export default class LocateEvent {
|
export default class LocateEvent implements IPublicModelLocateEvent {
|
||||||
private readonly [locateEventSymbol]: InnerLocateEvent;
|
private readonly [locateEventSymbol]: InnerLocateEvent;
|
||||||
|
|
||||||
constructor(locateEvent: InnerLocateEvent) {
|
constructor(locateEvent: InnerLocateEvent) {
|
||||||
this[locateEventSymbol] = locateEvent;
|
this[locateEventSymbol] = locateEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(locateEvent: InnerLocateEvent) {
|
static create(locateEvent: InnerLocateEvent): IPublicModelLocateEvent | null {
|
||||||
if (!locateEvent) return null;
|
if (!locateEvent) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new LocateEvent(locateEvent);
|
return new LocateEvent(locateEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
get type() {
|
get type(): string {
|
||||||
return this[locateEventSymbol].type;
|
return this[locateEventSymbol].type;
|
||||||
}
|
}
|
||||||
|
|
||||||
get globalX() {
|
get globalX(): number {
|
||||||
return this[locateEventSymbol].globalX;
|
return this[locateEventSymbol].globalX;
|
||||||
}
|
}
|
||||||
|
|
||||||
get globalY() {
|
get globalY(): number {
|
||||||
return this[locateEventSymbol].globalY;
|
return this[locateEventSymbol].globalY;
|
||||||
}
|
}
|
||||||
|
|
||||||
get originalEvent() {
|
get originalEvent(): MouseEvent | DragEvent {
|
||||||
return this[locateEventSymbol].originalEvent;
|
return this[locateEventSymbol].originalEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
get target() {
|
get target(): Element | null | undefined {
|
||||||
return this[locateEventSymbol].target;
|
return this[locateEventSymbol].target;
|
||||||
}
|
}
|
||||||
|
|
||||||
get canvasX() {
|
get canvasX(): number | undefined {
|
||||||
return this[locateEventSymbol].canvasX;
|
return this[locateEventSymbol].canvasX;
|
||||||
}
|
}
|
||||||
|
|
||||||
get canvasY() {
|
get canvasY(): number | undefined {
|
||||||
return this[locateEventSymbol].canvasY;
|
return this[locateEventSymbol].canvasY;
|
||||||
}
|
}
|
||||||
|
|
||||||
get dragObject() {
|
get dragObject(): IPublicModelDragObject | null {
|
||||||
return DragObject.create(this[locateEventSymbol].dragObject);
|
return DragObject.create(this[locateEventSymbol].dragObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,7 +2,6 @@ import { Editor } from '@alilc/lowcode-editor-core';
|
|||||||
import {
|
import {
|
||||||
Designer,
|
Designer,
|
||||||
registerMetadataTransducer,
|
registerMetadataTransducer,
|
||||||
MetadataTransducer,
|
|
||||||
getRegisteredMetadataTransducers,
|
getRegisteredMetadataTransducers,
|
||||||
addBuiltinComponentAction,
|
addBuiltinComponentAction,
|
||||||
removeBuiltinComponentAction,
|
removeBuiltinComponentAction,
|
||||||
@ -10,11 +9,17 @@ import {
|
|||||||
isComponentMeta,
|
isComponentMeta,
|
||||||
} from '@alilc/lowcode-designer';
|
} from '@alilc/lowcode-designer';
|
||||||
import { AssetsJson } from '@alilc/lowcode-utils';
|
import { AssetsJson } from '@alilc/lowcode-utils';
|
||||||
import { ComponentAction, ComponentMetadata } from '@alilc/lowcode-types';
|
import {
|
||||||
|
ComponentAction,
|
||||||
|
ComponentMetadata,
|
||||||
|
IPublicApiMaterial,
|
||||||
|
MetadataTransducer,
|
||||||
|
IPublicModelComponentMeta,
|
||||||
|
} from '@alilc/lowcode-types';
|
||||||
import { editorSymbol, designerSymbol } from './symbols';
|
import { editorSymbol, designerSymbol } from './symbols';
|
||||||
import ComponentMeta from './component-meta';
|
import ComponentMeta from './component-meta';
|
||||||
|
|
||||||
export default class Material {
|
export default class Material implements IPublicApiMaterial {
|
||||||
private readonly [editorSymbol]: Editor;
|
private readonly [editorSymbol]: Editor;
|
||||||
private readonly [designerSymbol]: Designer;
|
private readonly [designerSymbol]: Designer;
|
||||||
|
|
||||||
@ -83,8 +88,9 @@ export default class Material {
|
|||||||
* @param componentName
|
* @param componentName
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getComponentMeta(componentName: string) {
|
getComponentMeta(componentName: string): IPublicModelComponentMeta | null {
|
||||||
return ComponentMeta.create(this[designerSymbol].getComponentMeta(componentName));
|
const innerMeta = this[designerSymbol].getComponentMeta(componentName);
|
||||||
|
return ComponentMeta.create(innerMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,8 +115,8 @@ export default class Material {
|
|||||||
* 获取所有已注册的物料元数据
|
* 获取所有已注册的物料元数据
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getComponentMetasMap() {
|
getComponentMetasMap(): Map<string, IPublicModelComponentMeta> {
|
||||||
const map = new Map<string, ComponentMeta>();
|
const map = new Map<string, IPublicModelComponentMeta>();
|
||||||
const originalMap = this[designerSymbol].getComponentMetasMap();
|
const originalMap = this[designerSymbol].getComponentMetasMap();
|
||||||
for (let componentName of originalMap.keys()) {
|
for (let componentName of originalMap.keys()) {
|
||||||
map.set(componentName, this.getComponentMeta(componentName)!);
|
map.set(componentName, this.getComponentMeta(componentName)!);
|
||||||
|
|||||||
@ -1,24 +1,28 @@
|
|||||||
import { ModalNodesManager as InnerModalNodesManager, Node as InnerNode } from '@alilc/lowcode-designer';
|
import { ModalNodesManager as InnerModalNodesManager, Node as InnerNode } from '@alilc/lowcode-designer';
|
||||||
import { NodeSchema, NodeData, TransformStage } from '@alilc/lowcode-types';
|
import { IPublicModelModalNodesManager, IPublicModelNode } from '@alilc/lowcode-types';
|
||||||
import Node from './node';
|
import Node from './node';
|
||||||
import { nodeSymbol, modalNodesManagerSymbol } from './symbols';
|
import { nodeSymbol, modalNodesManagerSymbol } from './symbols';
|
||||||
|
|
||||||
export default class ModalNodesManager {
|
export default class ModalNodesManager implements IPublicModelModalNodesManager {
|
||||||
private readonly [modalNodesManagerSymbol]: InnerModalNodesManager;
|
private readonly [modalNodesManagerSymbol]: InnerModalNodesManager;
|
||||||
|
|
||||||
constructor(modalNodesManager: InnerModalNodesManager) {
|
constructor(modalNodesManager: InnerModalNodesManager) {
|
||||||
this[modalNodesManagerSymbol] = modalNodesManager;
|
this[modalNodesManagerSymbol] = modalNodesManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(modalNodesManager: InnerModalNodesManager | null) {
|
static create(
|
||||||
if (!modalNodesManager) return null;
|
modalNodesManager: InnerModalNodesManager | null,
|
||||||
|
): IPublicModelModalNodesManager | null {
|
||||||
|
if (!modalNodesManager) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new ModalNodesManager(modalNodesManager);
|
return new ModalNodesManager(modalNodesManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置模态节点,触发内部事件
|
* 设置模态节点,触发内部事件
|
||||||
*/
|
*/
|
||||||
setNodes() {
|
setNodes(): void {
|
||||||
this[modalNodesManagerSymbol].setNodes();
|
this[modalNodesManagerSymbol].setNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +30,7 @@ export default class ModalNodesManager {
|
|||||||
* 获取模态节点(们)
|
* 获取模态节点(们)
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getModalNodes() {
|
getModalNodes(): any {
|
||||||
return this[modalNodesManagerSymbol].getModalNodes().map((node) => Node.create(node));
|
return this[modalNodesManagerSymbol].getModalNodes().map((node) => Node.create(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,14 +38,14 @@ export default class ModalNodesManager {
|
|||||||
* 获取当前可见的模态节点
|
* 获取当前可见的模态节点
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getVisibleModalNode() {
|
getVisibleModalNode(): any {
|
||||||
return Node.create(this[modalNodesManagerSymbol].getVisibleModalNode());
|
return Node.create(this[modalNodesManagerSymbol].getVisibleModalNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 隐藏模态节点(们)
|
* 隐藏模态节点(们)
|
||||||
*/
|
*/
|
||||||
hideModalNodes() {
|
hideModalNodes(): void {
|
||||||
this[modalNodesManagerSymbol].hideModalNodes();
|
this[modalNodesManagerSymbol].hideModalNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +53,7 @@ export default class ModalNodesManager {
|
|||||||
* 设置指定节点为可见态
|
* 设置指定节点为可见态
|
||||||
* @param node Node
|
* @param node Node
|
||||||
*/
|
*/
|
||||||
setVisible(node: Node) {
|
setVisible(node: IPublicModelNode): void {
|
||||||
this[modalNodesManagerSymbol].setVisible(node[nodeSymbol]);
|
this[modalNodesManagerSymbol].setVisible(node[nodeSymbol]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +61,7 @@ export default class ModalNodesManager {
|
|||||||
* 设置指定节点为不可见态
|
* 设置指定节点为不可见态
|
||||||
* @param node Node
|
* @param node Node
|
||||||
*/
|
*/
|
||||||
setInvisible(node: Node) {
|
setInvisible(node: IPublicModelNode): void {
|
||||||
this[modalNodesManagerSymbol].setInvisible(node[nodeSymbol]);
|
this[modalNodesManagerSymbol].setInvisible(node[nodeSymbol]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,31 +1,33 @@
|
|||||||
import { NodeChildren as InnerNodeChildren, Node as InnerNode } from '@alilc/lowcode-designer';
|
import { NodeChildren as InnerNodeChildren, Node as InnerNode } from '@alilc/lowcode-designer';
|
||||||
import { NodeSchema, NodeData, TransformStage } from '@alilc/lowcode-types';
|
import { NodeSchema, NodeData, TransformStage, IPublicModelNodeChildren, IPublicModelNode } from '@alilc/lowcode-types';
|
||||||
import Node from './node';
|
import Node from './node';
|
||||||
import { nodeSymbol, nodeChildrenSymbol } from './symbols';
|
import { nodeSymbol, nodeChildrenSymbol } from './symbols';
|
||||||
|
|
||||||
export default class NodeChildren {
|
export default class NodeChildren implements IPublicModelNodeChildren {
|
||||||
private readonly [nodeChildrenSymbol]: InnerNodeChildren;
|
private readonly [nodeChildrenSymbol]: InnerNodeChildren;
|
||||||
|
|
||||||
constructor(nodeChildren: InnerNodeChildren) {
|
constructor(nodeChildren: InnerNodeChildren) {
|
||||||
this[nodeChildrenSymbol] = nodeChildren;
|
this[nodeChildrenSymbol] = nodeChildren;
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(nodeChldren: InnerNodeChildren | null) {
|
static create(nodeChldren: InnerNodeChildren | null): IPublicModelNodeChildren | null {
|
||||||
if (!nodeChldren) return null;
|
if (!nodeChldren) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new NodeChildren(nodeChldren);
|
return new NodeChildren(nodeChldren);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回当前 children 实例所属的节点实例
|
* 返回当前 children 实例所属的节点实例
|
||||||
*/
|
*/
|
||||||
get owner(): Node | null {
|
get owner(): IPublicModelNode | null {
|
||||||
return Node.create(this[nodeChildrenSymbol].owner);
|
return Node.create(this[nodeChildrenSymbol].owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* children 内的节点实例数
|
* children 内的节点实例数
|
||||||
*/
|
*/
|
||||||
get size() {
|
get size(): number {
|
||||||
return this[nodeChildrenSymbol].size;
|
return this[nodeChildrenSymbol].size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,14 +35,14 @@ export default class NodeChildren {
|
|||||||
* 是否为空
|
* 是否为空
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
get isEmpty() {
|
get isEmpty(): boolean {
|
||||||
return this[nodeChildrenSymbol].isEmpty();
|
return this[nodeChildrenSymbol].isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* judge if it is not empty
|
* judge if it is not empty
|
||||||
*/
|
*/
|
||||||
get notEmpty() {
|
get notEmpty(): boolean {
|
||||||
return !this.isEmpty;
|
return !this.isEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,8 +51,8 @@ export default class NodeChildren {
|
|||||||
* @param node
|
* @param node
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
delete(node: Node) {
|
delete(node: IPublicModelNode): boolean {
|
||||||
return this[nodeChildrenSymbol].delete(node[nodeSymbol]);
|
return this[nodeChildrenSymbol].delete((node as any)[nodeSymbol]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,8 +61,8 @@ export default class NodeChildren {
|
|||||||
* @param at 插入下标
|
* @param at 插入下标
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
insert(node: Node, at?: number | null) {
|
insert(node: IPublicModelNode, at?: number | null): void {
|
||||||
return this[nodeChildrenSymbol].insert(node[nodeSymbol], at, true);
|
return this[nodeChildrenSymbol].insert((node as any)[nodeSymbol], at, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,8 +70,8 @@ export default class NodeChildren {
|
|||||||
* @param node
|
* @param node
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
indexOf(node: Node) {
|
indexOf(node: IPublicModelNode): number {
|
||||||
return this[nodeChildrenSymbol].indexOf(node[nodeSymbol]);
|
return this[nodeChildrenSymbol].indexOf((node as any)[nodeSymbol]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,8 +80,8 @@ export default class NodeChildren {
|
|||||||
* @param deleteCount
|
* @param deleteCount
|
||||||
* @param node
|
* @param node
|
||||||
*/
|
*/
|
||||||
splice(start: number, deleteCount: number, node?: Node) {
|
splice(start: number, deleteCount: number, node?: IPublicModelNode): any {
|
||||||
this[nodeChildrenSymbol].splice(start, deleteCount, node?.[nodeSymbol]);
|
this[nodeChildrenSymbol].splice(start, deleteCount, (node as any)?.[nodeSymbol]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,7 +89,7 @@ export default class NodeChildren {
|
|||||||
* @param index
|
* @param index
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
get(index: number) {
|
get(index: number): any {
|
||||||
return Node.create(this[nodeChildrenSymbol].get(index));
|
return Node.create(this[nodeChildrenSymbol].get(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,15 +98,15 @@ export default class NodeChildren {
|
|||||||
* @param node
|
* @param node
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
has(node: Node) {
|
has(node: IPublicModelNode): boolean {
|
||||||
return this[nodeChildrenSymbol].has(node[nodeSymbol]);
|
return this[nodeChildrenSymbol].has((node as any)[nodeSymbol]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类似数组的 forEach
|
* 类似数组的 forEach
|
||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
forEach(fn: (node: Node, index: number) => void) {
|
forEach(fn: (node: IPublicModelNode, index: number) => void): void {
|
||||||
this[nodeChildrenSymbol].forEach((item: InnerNode<NodeSchema>, index: number) => {
|
this[nodeChildrenSymbol].forEach((item: InnerNode<NodeSchema>, index: number) => {
|
||||||
fn(Node.create(item)!, index);
|
fn(Node.create(item)!, index);
|
||||||
});
|
});
|
||||||
@ -114,7 +116,7 @@ export default class NodeChildren {
|
|||||||
* 类似数组的 map
|
* 类似数组的 map
|
||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
map<T>(fn: (node: Node, index: number) => T[]) {
|
map<T>(fn: (node: IPublicModelNode, index: number) => T[]): any[] | null {
|
||||||
return this[nodeChildrenSymbol].map((item: InnerNode<NodeSchema>, index: number) => {
|
return this[nodeChildrenSymbol].map((item: InnerNode<NodeSchema>, index: number) => {
|
||||||
return fn(Node.create(item)!, index);
|
return fn(Node.create(item)!, index);
|
||||||
});
|
});
|
||||||
@ -124,7 +126,7 @@ export default class NodeChildren {
|
|||||||
* 类似数组的 every
|
* 类似数组的 every
|
||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
every(fn: (node: Node, index: number) => boolean) {
|
every(fn: (node: IPublicModelNode, index: number) => boolean): boolean {
|
||||||
return this[nodeChildrenSymbol].every((item: InnerNode<NodeSchema>, index: number) => {
|
return this[nodeChildrenSymbol].every((item: InnerNode<NodeSchema>, index: number) => {
|
||||||
return fn(Node.create(item)!, index);
|
return fn(Node.create(item)!, index);
|
||||||
});
|
});
|
||||||
@ -134,7 +136,7 @@ export default class NodeChildren {
|
|||||||
* 类似数组的 some
|
* 类似数组的 some
|
||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
some(fn: (node: Node, index: number) => boolean) {
|
some(fn: (node: IPublicModelNode, index: number) => boolean): boolean {
|
||||||
return this[nodeChildrenSymbol].some((item: InnerNode<NodeSchema>, index: number) => {
|
return this[nodeChildrenSymbol].some((item: InnerNode<NodeSchema>, index: number) => {
|
||||||
return fn(Node.create(item)!, index);
|
return fn(Node.create(item)!, index);
|
||||||
});
|
});
|
||||||
@ -144,7 +146,7 @@ export default class NodeChildren {
|
|||||||
* 类似数组的 filter
|
* 类似数组的 filter
|
||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
filter(fn: (node: Node, index: number) => boolean) {
|
filter(fn: (node: IPublicModelNode, index: number) => boolean): any {
|
||||||
return this[nodeChildrenSymbol]
|
return this[nodeChildrenSymbol]
|
||||||
.filter((item: InnerNode<NodeSchema>, index: number) => {
|
.filter((item: InnerNode<NodeSchema>, index: number) => {
|
||||||
return fn(Node.create(item)!, index);
|
return fn(Node.create(item)!, index);
|
||||||
@ -156,7 +158,7 @@ export default class NodeChildren {
|
|||||||
* 类似数组的 find
|
* 类似数组的 find
|
||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
find(fn: (node: Node, index: number) => boolean) {
|
find(fn: (node: IPublicModelNode, index: number) => boolean): IPublicModelNode | null {
|
||||||
return Node.create(
|
return Node.create(
|
||||||
this[nodeChildrenSymbol].find((item: InnerNode<NodeSchema>, index: number) => {
|
this[nodeChildrenSymbol].find((item: InnerNode<NodeSchema>, index: number) => {
|
||||||
return fn(Node.create(item)!, index);
|
return fn(Node.create(item)!, index);
|
||||||
@ -168,7 +170,7 @@ export default class NodeChildren {
|
|||||||
* 类似数组的 reduce
|
* 类似数组的 reduce
|
||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
reduce(fn: (acc: any, cur: Node) => any, initialValue: any) {
|
reduce(fn: (acc: any, cur: IPublicModelNode) => any, initialValue: any): void {
|
||||||
return this[nodeChildrenSymbol].reduce((acc: any, cur: InnerNode) => {
|
return this[nodeChildrenSymbol].reduce((acc: any, cur: InnerNode) => {
|
||||||
return fn(acc, Node.create(cur)!);
|
return fn(acc, Node.create(cur)!);
|
||||||
}, initialValue);
|
}, initialValue);
|
||||||
@ -178,7 +180,7 @@ export default class NodeChildren {
|
|||||||
* 导入 schema
|
* 导入 schema
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
importSchema(data?: NodeData | NodeData[]) {
|
importSchema(data?: NodeData | NodeData[]): void {
|
||||||
this[nodeChildrenSymbol].import(data);
|
this[nodeChildrenSymbol].import(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +189,7 @@ export default class NodeChildren {
|
|||||||
* @param stage
|
* @param stage
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
exportSchema(stage: TransformStage = TransformStage.Render) {
|
exportSchema(stage: TransformStage = TransformStage.Render): any {
|
||||||
return this[nodeChildrenSymbol].export(stage);
|
return this[nodeChildrenSymbol].export(stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,9 +200,9 @@ export default class NodeChildren {
|
|||||||
* @param sorter
|
* @param sorter
|
||||||
*/
|
*/
|
||||||
mergeChildren(
|
mergeChildren(
|
||||||
remover: (node: Node, idx: number) => boolean,
|
remover: (node: IPublicModelNode, idx: number) => boolean,
|
||||||
adder: (children: Node[]) => any,
|
adder: (children: IPublicModelNode[]) => any,
|
||||||
sorter: (firstNode: Node, secondNode: Node) => number,
|
sorter: (firstNode: IPublicModelNode, secondNode: IPublicModelNode) => number,
|
||||||
) {
|
) {
|
||||||
if (!sorter) {
|
if (!sorter) {
|
||||||
sorter = () => 0;
|
sorter = () => 0;
|
||||||
|
|||||||
@ -1,9 +1,23 @@
|
|||||||
import {
|
import {
|
||||||
DocumentModel as InnerDocumentModel,
|
DocumentModel as InnerDocumentModel,
|
||||||
Node as InnerNode,
|
Node as InnerNode,
|
||||||
getConvertedExtraKey,
|
|
||||||
} from '@alilc/lowcode-designer';
|
} from '@alilc/lowcode-designer';
|
||||||
import { CompositeValue, NodeSchema, TransformStage } from '@alilc/lowcode-types';
|
import {
|
||||||
|
CompositeValue,
|
||||||
|
NodeSchema,
|
||||||
|
TransformStage,
|
||||||
|
IPublicModelNode,
|
||||||
|
IconType,
|
||||||
|
I18nData,
|
||||||
|
IPublicModelComponentMeta,
|
||||||
|
IPublicModelDocumentModel,
|
||||||
|
IPublicModelNodeChildren,
|
||||||
|
IPublicModelProp,
|
||||||
|
IPublicModelProps,
|
||||||
|
PropsMap,
|
||||||
|
PropsList,
|
||||||
|
IPublicModelSettingTopEntry,
|
||||||
|
} from '@alilc/lowcode-types';
|
||||||
import Prop from './prop';
|
import Prop from './prop';
|
||||||
import Props from './props';
|
import Props from './props';
|
||||||
import DocumentModel from './document-model';
|
import DocumentModel from './document-model';
|
||||||
@ -11,10 +25,11 @@ import NodeChildren from './node-children';
|
|||||||
import ComponentMeta from './component-meta';
|
import ComponentMeta from './component-meta';
|
||||||
import SettingTopEntry from './setting-top-entry';
|
import SettingTopEntry from './setting-top-entry';
|
||||||
import { documentSymbol, nodeSymbol } from './symbols';
|
import { documentSymbol, nodeSymbol } from './symbols';
|
||||||
|
import { ReactElement } from 'react';
|
||||||
|
|
||||||
const shellNodeSymbol = Symbol('shellNodeSymbol');
|
const shellNodeSymbol = Symbol('shellNodeSymbol');
|
||||||
|
|
||||||
export default class Node {
|
export default class Node implements IPublicModelNode {
|
||||||
private readonly [documentSymbol]: InnerDocumentModel;
|
private readonly [documentSymbol]: InnerDocumentModel;
|
||||||
private readonly [nodeSymbol]: InnerNode;
|
private readonly [nodeSymbol]: InnerNode;
|
||||||
|
|
||||||
@ -27,10 +42,14 @@ export default class Node {
|
|||||||
this._id = this[nodeSymbol].id;
|
this._id = this[nodeSymbol].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(node: InnerNode | null | undefined) {
|
static create(node: InnerNode | null | undefined): IPublicModelNode | null {
|
||||||
if (!node) return null;
|
if (!node) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// @ts-ignore 直接返回已挂载的 shell node 实例
|
// @ts-ignore 直接返回已挂载的 shell node 实例
|
||||||
if (node[shellNodeSymbol]) return node[shellNodeSymbol];
|
if (node[shellNodeSymbol]) {
|
||||||
|
return (node as any)[shellNodeSymbol];
|
||||||
|
}
|
||||||
const shellNode = new Node(node);
|
const shellNode = new Node(node);
|
||||||
// @ts-ignore 挂载 shell node 实例
|
// @ts-ignore 挂载 shell node 实例
|
||||||
node[shellNodeSymbol] = shellNode;
|
node[shellNodeSymbol] = shellNode;
|
||||||
@ -54,70 +73,70 @@ export default class Node {
|
|||||||
/**
|
/**
|
||||||
* 节点标题
|
* 节点标题
|
||||||
*/
|
*/
|
||||||
get title() {
|
get title(): string | I18nData | ReactElement {
|
||||||
return this[nodeSymbol].title;
|
return this[nodeSymbol].title;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为「容器型」节点
|
* 是否为「容器型」节点
|
||||||
*/
|
*/
|
||||||
get isContainer() {
|
get isContainer(): boolean {
|
||||||
return this[nodeSymbol].isContainer();
|
return this[nodeSymbol].isContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为根节点
|
* 是否为根节点
|
||||||
*/
|
*/
|
||||||
get isRoot() {
|
get isRoot(): boolean {
|
||||||
return this[nodeSymbol].isRoot();
|
return this[nodeSymbol].isRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为空节点(无 children 或者 children 为空)
|
* 是否为空节点(无 children 或者 children 为空)
|
||||||
*/
|
*/
|
||||||
get isEmpty() {
|
get isEmpty(): boolean {
|
||||||
return this[nodeSymbol].isEmpty();
|
return this[nodeSymbol].isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为 Page 节点
|
* 是否为 Page 节点
|
||||||
*/
|
*/
|
||||||
get isPage() {
|
get isPage(): boolean {
|
||||||
return this[nodeSymbol].isPage();
|
return this[nodeSymbol].isPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为 Component 节点
|
* 是否为 Component 节点
|
||||||
*/
|
*/
|
||||||
get isComponent() {
|
get isComponent(): boolean {
|
||||||
return this[nodeSymbol].isComponent();
|
return this[nodeSymbol].isComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为「模态框」节点
|
* 是否为「模态框」节点
|
||||||
*/
|
*/
|
||||||
get isModal() {
|
get isModal(): boolean {
|
||||||
return this[nodeSymbol].isModal();
|
return this[nodeSymbol].isModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为插槽节点
|
* 是否为插槽节点
|
||||||
*/
|
*/
|
||||||
get isSlot() {
|
get isSlot(): boolean {
|
||||||
return this[nodeSymbol].isSlot();
|
return this[nodeSymbol].isSlot();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为父类/分支节点
|
* 是否为父类/分支节点
|
||||||
*/
|
*/
|
||||||
get isParental() {
|
get isParental(): boolean {
|
||||||
return this[nodeSymbol].isParental();
|
return this[nodeSymbol].isParental();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为叶子节点
|
* 是否为叶子节点
|
||||||
*/
|
*/
|
||||||
get isLeaf() {
|
get isLeaf(): boolean {
|
||||||
return this[nodeSymbol].isLeaf();
|
return this[nodeSymbol].isLeaf();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +148,7 @@ export default class Node {
|
|||||||
/**
|
/**
|
||||||
* 获取当前节点的锁定状态
|
* 获取当前节点的锁定状态
|
||||||
*/
|
*/
|
||||||
get isLocked() {
|
get isLocked(): boolean {
|
||||||
return this[nodeSymbol].isLocked;
|
return this[nodeSymbol].isLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,28 +162,28 @@ export default class Node {
|
|||||||
/**
|
/**
|
||||||
* 图标
|
* 图标
|
||||||
*/
|
*/
|
||||||
get icon() {
|
get icon(): IconType {
|
||||||
return this[nodeSymbol].icon;
|
return this[nodeSymbol].icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 节点所在树的层级深度,根节点深度为 0
|
* 节点所在树的层级深度,根节点深度为 0
|
||||||
*/
|
*/
|
||||||
get zLevel() {
|
get zLevel(): number {
|
||||||
return this[nodeSymbol].zLevel;
|
return this[nodeSymbol].zLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 节点 componentName
|
* 节点 componentName
|
||||||
*/
|
*/
|
||||||
get componentName() {
|
get componentName(): string {
|
||||||
return this[nodeSymbol].componentName;
|
return this[nodeSymbol].componentName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 节点的物料元数据
|
* 节点的物料元数据
|
||||||
*/
|
*/
|
||||||
get componentMeta() {
|
get componentMeta(): IPublicModelComponentMeta | null {
|
||||||
return ComponentMeta.create(this[nodeSymbol].componentMeta);
|
return ComponentMeta.create(this[nodeSymbol].componentMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +191,7 @@ export default class Node {
|
|||||||
* 获取节点所属的文档模型对象
|
* 获取节点所属的文档模型对象
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
get document() {
|
get document(): IPublicModelDocumentModel | null {
|
||||||
return DocumentModel.create(this[documentSymbol]);
|
return DocumentModel.create(this[documentSymbol]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +199,7 @@ export default class Node {
|
|||||||
* 获取当前节点的前一个兄弟节点
|
* 获取当前节点的前一个兄弟节点
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
get prevSibling(): Node | null {
|
get prevSibling(): IPublicModelNode | null {
|
||||||
return Node.create(this[nodeSymbol].prevSibling);
|
return Node.create(this[nodeSymbol].prevSibling);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +207,7 @@ export default class Node {
|
|||||||
* 获取当前节点的后一个兄弟节点
|
* 获取当前节点的后一个兄弟节点
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
get nextSibling(): Node | null {
|
get nextSibling(): IPublicModelNode | null {
|
||||||
return Node.create(this[nodeSymbol].nextSibling);
|
return Node.create(this[nodeSymbol].nextSibling);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +215,7 @@ export default class Node {
|
|||||||
* 获取当前节点的父亲节点
|
* 获取当前节点的父亲节点
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
get parent(): Node | null {
|
get parent(): IPublicModelNode | null {
|
||||||
return Node.create(this[nodeSymbol].parent);
|
return Node.create(this[nodeSymbol].parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,46 +223,46 @@ export default class Node {
|
|||||||
* 获取当前节点的孩子节点模型
|
* 获取当前节点的孩子节点模型
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
get children() {
|
get children(): IPublicModelNodeChildren | null {
|
||||||
return NodeChildren.create(this[nodeSymbol].children);
|
return NodeChildren.create(this[nodeSymbol].children);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 节点上挂载的插槽节点们
|
* 节点上挂载的插槽节点们
|
||||||
*/
|
*/
|
||||||
get slots(): Node[] {
|
get slots(): IPublicModelNode[] {
|
||||||
return this[nodeSymbol].slots.map((node: InnerNode) => Node.create(node)!);
|
return this[nodeSymbol].slots.map((node: InnerNode) => Node.create(node)!);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前节点为插槽节点时,返回节点对应的属性实例
|
* 当前节点为插槽节点时,返回节点对应的属性实例
|
||||||
*/
|
*/
|
||||||
get slotFor() {
|
get slotFor(): IPublicModelProp | null {
|
||||||
return Prop.create(this[nodeSymbol].slotFor);
|
return Prop.create(this[nodeSymbol].slotFor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回节点的属性集
|
* 返回节点的属性集
|
||||||
*/
|
*/
|
||||||
get props() {
|
get props(): IPublicModelProps | null {
|
||||||
return Props.create(this[nodeSymbol].props);
|
return Props.create(this[nodeSymbol].props);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回节点的属性集
|
* 返回节点的属性集
|
||||||
*/
|
*/
|
||||||
get propsData() {
|
get propsData(): PropsMap | PropsList | null {
|
||||||
return this[nodeSymbol].propsData;
|
return this[nodeSymbol].propsData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取符合搭建协议-节点 schema 结构
|
* 获取符合搭建协议 - 节点 schema 结构
|
||||||
*/
|
*/
|
||||||
get schema(): any {
|
get schema(): NodeSchema {
|
||||||
return this[nodeSymbol].schema;
|
return this[nodeSymbol].schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
get settingEntry(): any {
|
get settingEntry(): IPublicModelSettingTopEntry {
|
||||||
return SettingTopEntry.create(this[nodeSymbol].settingEntry as any);
|
return SettingTopEntry.create(this[nodeSymbol].settingEntry as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,6 +275,7 @@ export default class Node {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取节点实例对应的 dom 节点
|
* 获取节点实例对应的 dom 节点
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
getDOMNode() {
|
getDOMNode() {
|
||||||
return this[nodeSymbol].getDOMNode();
|
return this[nodeSymbol].getDOMNode();
|
||||||
@ -268,10 +288,10 @@ export default class Node {
|
|||||||
* @param sorter
|
* @param sorter
|
||||||
*/
|
*/
|
||||||
mergeChildren(
|
mergeChildren(
|
||||||
remover: (node: Node, idx: number) => boolean,
|
remover: (node: IPublicModelNode, idx: number) => boolean,
|
||||||
adder: (children: Node[]) => any,
|
adder: (children: IPublicModelNode[]) => any,
|
||||||
sorter: (firstNode: Node, secondNode: Node) => number,
|
sorter: (firstNode: IPublicModelNode, secondNode: IPublicModelNode) => number,
|
||||||
) {
|
): any {
|
||||||
return this.children?.mergeChildren(remover, adder, sorter);
|
return this.children?.mergeChildren(remover, adder, sorter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +299,7 @@ export default class Node {
|
|||||||
* 返回节点的尺寸、位置信息
|
* 返回节点的尺寸、位置信息
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getRect() {
|
getRect(): DOMRect | null {
|
||||||
return this[nodeSymbol].getRect();
|
return this[nodeSymbol].getRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +307,7 @@ export default class Node {
|
|||||||
* 是否有挂载插槽节点
|
* 是否有挂载插槽节点
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
hasSlots() {
|
hasSlots(): boolean {
|
||||||
return this[nodeSymbol].hasSlots();
|
return this[nodeSymbol].hasSlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,7 +315,7 @@ export default class Node {
|
|||||||
* 是否设定了渲染条件
|
* 是否设定了渲染条件
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
hasCondition() {
|
hasCondition(): boolean {
|
||||||
return this[nodeSymbol].hasCondition();
|
return this[nodeSymbol].hasCondition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,19 +323,19 @@ export default class Node {
|
|||||||
* 是否设定了循环数据
|
* 是否设定了循环数据
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
hasLoop() {
|
hasLoop(): boolean {
|
||||||
return this[nodeSymbol].hasLoop();
|
return this[nodeSymbol].hasLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
getVisible() {
|
getVisible(): boolean {
|
||||||
return this[nodeSymbol].getVisible();
|
return this[nodeSymbol].getVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
setVisible(flag: boolean) {
|
setVisible(flag: boolean): void {
|
||||||
this[nodeSymbol].setVisible(flag);
|
this[nodeSymbol].setVisible(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
isConditionalVisible() {
|
isConditionalVisible(): boolean | undefined {
|
||||||
return this[nodeSymbol].isConditionalVisible();
|
return this[nodeSymbol].isConditionalVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,7 +343,7 @@ export default class Node {
|
|||||||
* 设置节点锁定状态
|
* 设置节点锁定状态
|
||||||
* @param flag
|
* @param flag
|
||||||
*/
|
*/
|
||||||
lock(flag?: boolean) {
|
lock(flag?: boolean): void {
|
||||||
this[nodeSymbol].lock(flag);
|
this[nodeSymbol].lock(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,8 +354,8 @@ export default class Node {
|
|||||||
return this.props;
|
return this.props;
|
||||||
}
|
}
|
||||||
|
|
||||||
contains(node: Node) {
|
contains(node: IPublicModelNode): boolean {
|
||||||
return this[nodeSymbol].contains(node[nodeSymbol]);
|
return this[nodeSymbol].contains((node as any)[nodeSymbol]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -343,7 +363,7 @@ export default class Node {
|
|||||||
* @param path 属性路径,支持 a / a.b / a.0 等格式
|
* @param path 属性路径,支持 a / a.b / a.0 等格式
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getProp(path: string, createIfNone = true): Prop | null {
|
getProp(path: string, createIfNone = true): IPublicModelProp | null {
|
||||||
return Prop.create(this[nodeSymbol].getProp(path, createIfNone));
|
return Prop.create(this[nodeSymbol].getProp(path, createIfNone));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,7 +383,7 @@ export default class Node {
|
|||||||
* @param createIfNone 当没有属性的时候,是否创建一个属性
|
* @param createIfNone 当没有属性的时候,是否创建一个属性
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getExtraProp(path: string, createIfNone?: boolean): Prop | null {
|
getExtraProp(path: string, createIfNone?: boolean): IPublicModelProp | null {
|
||||||
return Prop.create(this[nodeSymbol].getExtraProp(path, createIfNone));
|
return Prop.create(this[nodeSymbol].getExtraProp(path, createIfNone));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +393,7 @@ export default class Node {
|
|||||||
* @param path 属性路径,支持 a / a.b / a.0 等格式
|
* @param path 属性路径,支持 a / a.b / a.0 等格式
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getExtraPropValue(path: string) {
|
getExtraPropValue(path: string): any {
|
||||||
return this.getExtraProp(path)?.getValue();
|
return this.getExtraProp(path)?.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,7 +403,7 @@ export default class Node {
|
|||||||
* @param value 值
|
* @param value 值
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
setPropValue(path: string, value: CompositeValue) {
|
setPropValue(path: string, value: CompositeValue): void {
|
||||||
return this.getProp(path)?.setValue(value);
|
return this.getProp(path)?.setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,7 +413,7 @@ export default class Node {
|
|||||||
* @param value 值
|
* @param value 值
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
setExtraPropValue(path: string, value: CompositeValue) {
|
setExtraPropValue(path: string, value: CompositeValue): void {
|
||||||
return this.getExtraProp(path)?.setValue(value);
|
return this.getExtraProp(path)?.setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,7 +421,7 @@ export default class Node {
|
|||||||
* 导入节点数据
|
* 导入节点数据
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
importSchema(data: NodeSchema) {
|
importSchema(data: NodeSchema): void {
|
||||||
this[nodeSymbol].import(data);
|
this[nodeSymbol].import(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +431,7 @@ export default class Node {
|
|||||||
* @param options
|
* @param options
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
exportSchema(stage: TransformStage = TransformStage.Render, options?: any) {
|
exportSchema(stage: TransformStage = TransformStage.Render, options?: any): NodeSchema {
|
||||||
return this[nodeSymbol].export(stage, options);
|
return this[nodeSymbol].export(stage, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,8 +441,16 @@ export default class Node {
|
|||||||
* @param ref
|
* @param ref
|
||||||
* @param useMutator
|
* @param useMutator
|
||||||
*/
|
*/
|
||||||
insertBefore(node: Node, ref?: Node | undefined, useMutator?: boolean) {
|
insertBefore(
|
||||||
this[nodeSymbol].insertBefore(node[nodeSymbol] || node, ref?.[nodeSymbol], useMutator);
|
node: IPublicModelNode,
|
||||||
|
ref?: IPublicModelNode | undefined,
|
||||||
|
useMutator?: boolean,
|
||||||
|
): void {
|
||||||
|
this[nodeSymbol].insertBefore(
|
||||||
|
(node as any)[nodeSymbol] || node,
|
||||||
|
(ref as any)?.[nodeSymbol],
|
||||||
|
useMutator,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -431,8 +459,16 @@ export default class Node {
|
|||||||
* @param ref
|
* @param ref
|
||||||
* @param useMutator
|
* @param useMutator
|
||||||
*/
|
*/
|
||||||
insertAfter(node: Node, ref?: Node | undefined, useMutator?: boolean) {
|
insertAfter(
|
||||||
this[nodeSymbol].insertAfter(node[nodeSymbol] || node, ref?.[nodeSymbol], useMutator);
|
node: IPublicModelNode,
|
||||||
|
ref?: IPublicModelNode | undefined,
|
||||||
|
useMutator?: boolean,
|
||||||
|
): void {
|
||||||
|
this[nodeSymbol].insertAfter(
|
||||||
|
(node as any)[nodeSymbol] || node,
|
||||||
|
(ref as any)?.[nodeSymbol],
|
||||||
|
useMutator,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -441,22 +477,22 @@ export default class Node {
|
|||||||
* @param data 用作替换的节点对象或者节点描述
|
* @param data 用作替换的节点对象或者节点描述
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
replaceChild(node: Node, data: any) {
|
replaceChild(node: IPublicModelNode, data: any): IPublicModelNode | null {
|
||||||
return Node.create(this[nodeSymbol].replaceChild(node[nodeSymbol], data));
|
return Node.create(this[nodeSymbol].replaceChild((node as any)[nodeSymbol], data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将当前节点替换成指定节点描述
|
* 将当前节点替换成指定节点描述
|
||||||
* @param schema
|
* @param schema
|
||||||
*/
|
*/
|
||||||
replaceWith(schema: NodeSchema) {
|
replaceWith(schema: NodeSchema): any {
|
||||||
this[nodeSymbol].replaceWith(schema);
|
this[nodeSymbol].replaceWith(schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 选中当前节点实例
|
* 选中当前节点实例
|
||||||
*/
|
*/
|
||||||
select() {
|
select(): void {
|
||||||
this[nodeSymbol].select();
|
this[nodeSymbol].select();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,14 +500,14 @@ export default class Node {
|
|||||||
* 设置悬停态
|
* 设置悬停态
|
||||||
* @param flag
|
* @param flag
|
||||||
*/
|
*/
|
||||||
hover(flag = true) {
|
hover(flag = true): void {
|
||||||
this[nodeSymbol].hover(flag);
|
this[nodeSymbol].hover(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除当前节点实例
|
* 删除当前节点实例
|
||||||
*/
|
*/
|
||||||
remove() {
|
remove(): void {
|
||||||
this[nodeSymbol].remove();
|
this[nodeSymbol].remove();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,15 +1,22 @@
|
|||||||
import {
|
import {
|
||||||
BuiltinSimulatorHost,
|
BuiltinSimulatorHost,
|
||||||
Project as InnerProject,
|
Project as InnerProject,
|
||||||
PropsReducer as PropsTransducer,
|
|
||||||
TransformStage,
|
TransformStage,
|
||||||
} from '@alilc/lowcode-designer';
|
} from '@alilc/lowcode-designer';
|
||||||
import { RootSchema, ProjectSchema, IEditor } from '@alilc/lowcode-types';
|
import {
|
||||||
|
RootSchema,
|
||||||
|
ProjectSchema,
|
||||||
|
IEditor,
|
||||||
|
IPublicApiProject,
|
||||||
|
IPublicApiSimulatorHost,
|
||||||
|
IPublicModelDocumentModel,
|
||||||
|
PropsTransducer,
|
||||||
|
} from '@alilc/lowcode-types';
|
||||||
import DocumentModel from './document-model';
|
import DocumentModel from './document-model';
|
||||||
import SimulatorHost from './simulator-host';
|
import SimulatorHost from './simulator-host';
|
||||||
import { editorSymbol, projectSymbol, simulatorHostSymbol, simulatorRendererSymbol, documentSymbol } from './symbols';
|
import { editorSymbol, projectSymbol, simulatorHostSymbol, simulatorRendererSymbol, documentSymbol } from './symbols';
|
||||||
|
|
||||||
export default class Project {
|
export default class Project implements IPublicApiProject {
|
||||||
private readonly [projectSymbol]: InnerProject;
|
private readonly [projectSymbol]: InnerProject;
|
||||||
private readonly [editorSymbol]: IEditor;
|
private readonly [editorSymbol]: IEditor;
|
||||||
private [simulatorHostSymbol]: BuiltinSimulatorHost;
|
private [simulatorHostSymbol]: BuiltinSimulatorHost;
|
||||||
@ -28,7 +35,7 @@ export default class Project {
|
|||||||
* 获取当前的 document
|
* 获取当前的 document
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
get currentDocument(): DocumentModel | null {
|
get currentDocument(): IPublicModelDocumentModel | null {
|
||||||
return this.getCurrentDocument();
|
return this.getCurrentDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,14 +43,14 @@ export default class Project {
|
|||||||
* 获取当前 project 下所有 documents
|
* 获取当前 project 下所有 documents
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
get documents(): DocumentModel[] {
|
get documents(): IPublicModelDocumentModel[] {
|
||||||
return this[projectSymbol].documents.map((doc) => DocumentModel.create(doc)!);
|
return this[projectSymbol].documents.map((doc) => DocumentModel.create(doc)!);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取模拟器的 host
|
* 获取模拟器的 host
|
||||||
*/
|
*/
|
||||||
get simulatorHost() {
|
get simulatorHost(): IPublicApiSimulatorHost | null {
|
||||||
return SimulatorHost.create(this[projectSymbol].simulator as any || this[simulatorHostSymbol]);
|
return SimulatorHost.create(this[projectSymbol].simulator as any || this[simulatorHostSymbol]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +77,7 @@ export default class Project {
|
|||||||
* @param data
|
* @param data
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
createDocument(data?: RootSchema): DocumentModel | null {
|
createDocument(data?: RootSchema): IPublicModelDocumentModel | null {
|
||||||
const doc = this[projectSymbol].createDocument(data);
|
const doc = this[projectSymbol].createDocument(data);
|
||||||
return DocumentModel.create(doc);
|
return DocumentModel.create(doc);
|
||||||
}
|
}
|
||||||
@ -79,8 +86,8 @@ export default class Project {
|
|||||||
* 删除一个 document
|
* 删除一个 document
|
||||||
* @param doc
|
* @param doc
|
||||||
*/
|
*/
|
||||||
removeDocument(doc: DocumentModel) {
|
removeDocument(doc: IPublicModelDocumentModel) {
|
||||||
this[projectSymbol].removeDocument(doc[documentSymbol]);
|
this[projectSymbol].removeDocument((doc as any)[documentSymbol]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,7 +95,7 @@ export default class Project {
|
|||||||
* @param fileName
|
* @param fileName
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getDocumentByFileName(fileName: string): DocumentModel | null {
|
getDocumentByFileName(fileName: string): IPublicModelDocumentModel | null {
|
||||||
return DocumentModel.create(this[projectSymbol].getDocumentByFileName(fileName));
|
return DocumentModel.create(this[projectSymbol].getDocumentByFileName(fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +104,7 @@ export default class Project {
|
|||||||
* @param id
|
* @param id
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getDocumentById(id: string): DocumentModel | null {
|
getDocumentById(id: string): IPublicModelDocumentModel | null {
|
||||||
return DocumentModel.create(this[projectSymbol].getDocument(id));
|
return DocumentModel.create(this[projectSymbol].getDocument(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +120,7 @@ export default class Project {
|
|||||||
* 导入 project
|
* 导入 project
|
||||||
* @param schema 待导入的 project 数据
|
* @param schema 待导入的 project 数据
|
||||||
*/
|
*/
|
||||||
importSchema(schema?: ProjectSchema) {
|
importSchema(schema?: ProjectSchema): void {
|
||||||
this[projectSymbol].load(schema, true);
|
this[projectSymbol].load(schema, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +128,7 @@ export default class Project {
|
|||||||
* 获取当前的 document
|
* 获取当前的 document
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getCurrentDocument(): DocumentModel | null {
|
getCurrentDocument(): IPublicModelDocumentModel | null {
|
||||||
return DocumentModel.create(this[projectSymbol].currentDocument);
|
return DocumentModel.create(this[projectSymbol].currentDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +137,7 @@ export default class Project {
|
|||||||
* @param transducer
|
* @param transducer
|
||||||
* @param stage
|
* @param stage
|
||||||
*/
|
*/
|
||||||
addPropsTransducer(transducer: PropsTransducer, stage: TransformStage) {
|
addPropsTransducer(transducer: PropsTransducer, stage: TransformStage): void {
|
||||||
this[projectSymbol].designer.addPropsReducer(transducer, stage);
|
this[projectSymbol].designer.addPropsReducer(transducer, stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,14 +146,14 @@ export default class Project {
|
|||||||
* @param fn
|
* @param fn
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
onRemoveDocument(fn: (data: { id: string}) => void) {
|
onRemoveDocument(fn: (data: { id: string}) => void): any {
|
||||||
return this[editorSymbol].on('designer.document.remove', (data: { id: string }) => fn(data));
|
return this[editorSymbol].on('designer.document.remove', (data: { id: string }) => fn(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前 project 内的 document 变更事件
|
* 当前 project 内的 document 变更事件
|
||||||
*/
|
*/
|
||||||
onChangeDocument(fn: (doc: DocumentModel) => void) {
|
onChangeDocument(fn: (doc: IPublicModelDocumentModel) => void) {
|
||||||
const offFn = this[projectSymbol].onCurrentDocumentChange((originalDoc) => {
|
const offFn = this[projectSymbol].onCurrentDocumentChange((originalDoc) => {
|
||||||
fn(DocumentModel.create(originalDoc)!);
|
fn(DocumentModel.create(originalDoc)!);
|
||||||
});
|
});
|
||||||
@ -159,7 +166,7 @@ export default class Project {
|
|||||||
/**
|
/**
|
||||||
* 当前 project 的模拟器 ready 事件
|
* 当前 project 的模拟器 ready 事件
|
||||||
*/
|
*/
|
||||||
onSimulatorHostReady(fn: (host: SimulatorHost) => void) {
|
onSimulatorHostReady(fn: (host: IPublicApiSimulatorHost) => void) {
|
||||||
const offFn = this[projectSymbol].onSimulatorReady((simulator: BuiltinSimulatorHost) => {
|
const offFn = this[projectSymbol].onSimulatorReady((simulator: BuiltinSimulatorHost) => {
|
||||||
this[simulatorHostSymbol] = simulator;
|
this[simulatorHostSymbol] = simulator;
|
||||||
fn(SimulatorHost.create(simulator)!);
|
fn(SimulatorHost.create(simulator)!);
|
||||||
|
|||||||
@ -1,65 +1,69 @@
|
|||||||
import { Prop as InnerProp } from '@alilc/lowcode-designer';
|
import { Prop as InnerProp } from '@alilc/lowcode-designer';
|
||||||
import { CompositeValue, TransformStage } from '@alilc/lowcode-types';
|
import { CompositeValue, TransformStage, IPublicModelProp, IPublicModelNode } from '@alilc/lowcode-types';
|
||||||
import { propSymbol } from './symbols';
|
import { propSymbol } from './symbols';
|
||||||
import Node from './node';
|
import Node from './node';
|
||||||
|
|
||||||
export default class Prop {
|
export default class Prop implements IPublicModelProp {
|
||||||
private readonly [propSymbol]: InnerProp;
|
private readonly [propSymbol]: InnerProp;
|
||||||
|
|
||||||
constructor(prop: InnerProp) {
|
constructor(prop: InnerProp) {
|
||||||
this[propSymbol] = prop;
|
this[propSymbol] = prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(prop: InnerProp | undefined | null) {
|
static create(prop: InnerProp | undefined | null): IPublicModelProp | null {
|
||||||
if (!prop) return null;
|
if (!prop) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new Prop(prop);
|
return new Prop(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* id
|
* id
|
||||||
*/
|
*/
|
||||||
get id() {
|
get id(): string {
|
||||||
return this[propSymbol].id;
|
return this[propSymbol].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* key 值
|
* key 值
|
||||||
*/
|
*/
|
||||||
get key() {
|
get key(): string | number | undefined {
|
||||||
return this[propSymbol].key;
|
return this[propSymbol].key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回当前 prop 的路径
|
* 返回当前 prop 的路径
|
||||||
*/
|
*/
|
||||||
get path() {
|
get path(): any[] {
|
||||||
return this[propSymbol].path;
|
return this[propSymbol].path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回所属的节点实例
|
* 返回所属的节点实例
|
||||||
*/
|
*/
|
||||||
get node(): Node | null {
|
get node(): IPublicModelNode | null {
|
||||||
return Node.create(this[propSymbol].getNode());
|
return Node.create(this[propSymbol].getNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the slot node (only if the current prop represents a slot)
|
* return the slot node (only if the current prop represents a slot)
|
||||||
*/
|
*/
|
||||||
get slotNode(): Node | null {
|
get slotNode(): IPublicModelNode | null {
|
||||||
return Node.create(this[propSymbol].slotNode);
|
return Node.create(this[propSymbol].slotNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* judge if it is a prop or not
|
* judge if it is a prop or not
|
||||||
*/
|
*/
|
||||||
get isProp() { return true; }
|
get isProp(): boolean {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置值
|
* 设置值
|
||||||
* @param val
|
* @param val
|
||||||
*/
|
*/
|
||||||
setValue(val: CompositeValue) {
|
setValue(val: CompositeValue): void {
|
||||||
this[propSymbol].setValue(val);
|
this[propSymbol].setValue(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,14 +71,14 @@ export default class Prop {
|
|||||||
* 获取值
|
* 获取值
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getValue() {
|
getValue(): any {
|
||||||
return this[propSymbol].getValue();
|
return this[propSymbol].getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 移除值
|
* 移除值
|
||||||
*/
|
*/
|
||||||
remove() {
|
remove(): void {
|
||||||
this[propSymbol].remove();
|
this[propSymbol].remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,39 +1,41 @@
|
|||||||
import { Props as InnerProps, getConvertedExtraKey } from '@alilc/lowcode-designer';
|
import { Props as InnerProps, getConvertedExtraKey } from '@alilc/lowcode-designer';
|
||||||
import { CompositeValue, TransformStage } from '@alilc/lowcode-types';
|
import { CompositeValue, IPublicModelProps, IPublicModelNode, IPublicModelProp } from '@alilc/lowcode-types';
|
||||||
import { propsSymbol } from './symbols';
|
import { propsSymbol } from './symbols';
|
||||||
import Node from './node';
|
import Node from './node';
|
||||||
import Prop from './prop';
|
import Prop from './prop';
|
||||||
|
|
||||||
export default class Props {
|
export default class Props implements IPublicModelProps {
|
||||||
private readonly [propsSymbol]: InnerProps;
|
private readonly [propsSymbol]: InnerProps;
|
||||||
|
|
||||||
constructor(props: InnerProps) {
|
constructor(props: InnerProps) {
|
||||||
this[propsSymbol] = props;
|
this[propsSymbol] = props;
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(props: InnerProps | undefined | null) {
|
static create(props: InnerProps | undefined | null): IPublicModelProps | null {
|
||||||
if (!props) return null;
|
if (!props) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new Props(props);
|
return new Props(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* id
|
* id
|
||||||
*/
|
*/
|
||||||
get id() {
|
get id(): string {
|
||||||
return this[propsSymbol].id;
|
return this[propsSymbol].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回当前 props 的路径
|
* 返回当前 props 的路径
|
||||||
*/
|
*/
|
||||||
get path() {
|
get path(): any[] {
|
||||||
return this[propsSymbol].path;
|
return this[propsSymbol].path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回所属的 node 实例
|
* 返回所属的 node 实例
|
||||||
*/
|
*/
|
||||||
get node(): Node | null {
|
get node(): IPublicModelNode | null {
|
||||||
return Node.create(this[propsSymbol].getNode());
|
return Node.create(this[propsSymbol].getNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +44,7 @@ export default class Props {
|
|||||||
* @param path 属性路径,支持 a / a.b / a.0 等格式
|
* @param path 属性路径,支持 a / a.b / a.0 等格式
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getProp(path: string): Prop | null {
|
getProp(path: string): IPublicModelProp | null {
|
||||||
return Prop.create(this[propsSymbol].getProp(path));
|
return Prop.create(this[propsSymbol].getProp(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +53,7 @@ export default class Props {
|
|||||||
* @param path 属性路径,支持 a / a.b / a.0 等格式
|
* @param path 属性路径,支持 a / a.b / a.0 等格式
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getPropValue(path: string) {
|
getPropValue(path: string): any {
|
||||||
return this.getProp(path)?.getValue();
|
return this.getProp(path)?.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +63,7 @@ export default class Props {
|
|||||||
* @param path 属性路径,支持 a / a.b / a.0 等格式
|
* @param path 属性路径,支持 a / a.b / a.0 等格式
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getExtraProp(path: string): Prop | null {
|
getExtraProp(path: string): IPublicModelProp | null {
|
||||||
return Prop.create(this[propsSymbol].getProp(getConvertedExtraKey(path)));
|
return Prop.create(this[propsSymbol].getProp(getConvertedExtraKey(path)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +73,7 @@ export default class Props {
|
|||||||
* @param path 属性路径,支持 a / a.b / a.0 等格式
|
* @param path 属性路径,支持 a / a.b / a.0 等格式
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getExtraPropValue(path: string) {
|
getExtraPropValue(path: string): any {
|
||||||
return this.getExtraProp(path)?.getValue();
|
return this.getExtraProp(path)?.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +83,7 @@ export default class Props {
|
|||||||
* @param value 值
|
* @param value 值
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
setPropValue(path: string, value: CompositeValue) {
|
setPropValue(path: string, value: CompositeValue): void {
|
||||||
return this.getProp(path)?.setValue(value);
|
return this.getProp(path)?.setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +93,7 @@ export default class Props {
|
|||||||
* @param value 值
|
* @param value 值
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
setExtraPropValue(path: string, value: CompositeValue) {
|
setExtraPropValue(path: string, value: CompositeValue): void {
|
||||||
return this.getExtraProp(path)?.setValue(value);
|
return this.getExtraProp(path)?.setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +102,7 @@ export default class Props {
|
|||||||
* @param key
|
* @param key
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
has(key: string) {
|
has(key: string): boolean {
|
||||||
return this[propsSymbol].has(key);
|
return this[propsSymbol].has(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +112,7 @@ export default class Props {
|
|||||||
* @param key
|
* @param key
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
add(value: CompositeValue, key?: string | number | undefined) {
|
add(value: CompositeValue, key?: string | number | undefined): any {
|
||||||
return this[propsSymbol].add(value, key);
|
return this[propsSymbol].add(value, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,14 +4,13 @@ import {
|
|||||||
Selection as InnerSelection,
|
Selection as InnerSelection,
|
||||||
} from '@alilc/lowcode-designer';
|
} from '@alilc/lowcode-designer';
|
||||||
import Node from './node';
|
import Node from './node';
|
||||||
import { documentSymbol, selectionSymbol } from './symbols';
|
import { selectionSymbol } from './symbols';
|
||||||
|
import { IPublicModelSelection, IPublicModelNode } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export default class Selection {
|
export default class Selection implements IPublicModelSelection {
|
||||||
private readonly [documentSymbol]: InnerDocumentModel;
|
|
||||||
private readonly [selectionSymbol]: InnerSelection;
|
private readonly [selectionSymbol]: InnerSelection;
|
||||||
|
|
||||||
constructor(document: InnerDocumentModel) {
|
constructor(document: InnerDocumentModel) {
|
||||||
this[documentSymbol] = document;
|
|
||||||
this[selectionSymbol] = document.selection;
|
this[selectionSymbol] = document.selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,15 +24,16 @@ export default class Selection {
|
|||||||
/**
|
/**
|
||||||
* return selected Node instance
|
* return selected Node instance
|
||||||
*/
|
*/
|
||||||
get node(): Node {
|
get node(): IPublicModelNode | null {
|
||||||
return this.getNodes()[0];
|
const nodes = this.getNodes();
|
||||||
|
return nodes && nodes.length > 0 ? nodes[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 选中指定节点(覆盖方式)
|
* 选中指定节点(覆盖方式)
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
select(id: string) {
|
select(id: string): void {
|
||||||
this[selectionSymbol].select(id);
|
this[selectionSymbol].select(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ export default class Selection {
|
|||||||
* 批量选中指定节点们
|
* 批量选中指定节点们
|
||||||
* @param ids
|
* @param ids
|
||||||
*/
|
*/
|
||||||
selectAll(ids: string[]) {
|
selectAll(ids: string[]): void {
|
||||||
this[selectionSymbol].selectAll(ids);
|
this[selectionSymbol].selectAll(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,14 +49,14 @@ export default class Selection {
|
|||||||
* 移除选中的指定节点
|
* 移除选中的指定节点
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
remove(id: string) {
|
remove(id: string): void {
|
||||||
this[selectionSymbol].remove(id);
|
this[selectionSymbol].remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除所有选中节点
|
* 清除所有选中节点
|
||||||
*/
|
*/
|
||||||
clear() {
|
clear(): void {
|
||||||
this[selectionSymbol].clear();
|
this[selectionSymbol].clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ export default class Selection {
|
|||||||
* @param id
|
* @param id
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
has(id: string) {
|
has(id: string): boolean {
|
||||||
return this[selectionSymbol].has(id);
|
return this[selectionSymbol].has(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ export default class Selection {
|
|||||||
* 选中指定节点(增量方式)
|
* 选中指定节点(增量方式)
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
add(id: string) {
|
add(id: string): void {
|
||||||
this[selectionSymbol].add(id);
|
this[selectionSymbol].add(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ export default class Selection {
|
|||||||
* 获取选中的节点实例
|
* 获取选中的节点实例
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getNodes(): Node[] {
|
getNodes(): Array<IPublicModelNode | null> {
|
||||||
return this[selectionSymbol].getNodes().map((node: InnerNode) => Node.create(node));
|
return this[selectionSymbol].getNodes().map((node: InnerNode) => Node.create(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ export default class Selection {
|
|||||||
* getTopNodes() will return [A, B], subA will be removed
|
* getTopNodes() will return [A, B], subA will be removed
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getTopNodes(): Node[] {
|
getTopNodes(): Array<IPublicModelNode | null> {
|
||||||
return this[selectionSymbol].getTopNodes().map((node: InnerNode) => Node.create(node));
|
return this[selectionSymbol].getTopNodes().map((node: InnerNode) => Node.create(node));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import { getSetter, registerSetter, getSettersMap, RegisteredSetter } from '@alilc/lowcode-editor-core';
|
import { getSetter, registerSetter, getSettersMap } from '@alilc/lowcode-editor-core';
|
||||||
import { CustomView } from '@alilc/lowcode-types';
|
import { CustomView, IPublicApiSetters, RegisteredSetter } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export default class Setters {
|
export default class Setters implements IPublicApiSetters {
|
||||||
/**
|
/**
|
||||||
* 获取指定 setter
|
* 获取指定 setter
|
||||||
* @param type
|
* @param type
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getSetter(type: string) {
|
getSetter(type: string): RegisteredSetter | null {
|
||||||
return getSetter(type);
|
return getSetter(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,7 +15,9 @@ export default class Setters {
|
|||||||
* 获取已注册的所有 settersMap
|
* 获取已注册的所有 settersMap
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getSettersMap() {
|
getSettersMap(): Map<string, RegisteredSetter & {
|
||||||
|
type: string;
|
||||||
|
}> {
|
||||||
return getSettersMap();
|
return getSettersMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,106 +1,118 @@
|
|||||||
import { SettingField, ISetValueOptions } from '@alilc/lowcode-designer';
|
import { SettingField, SettingEntry } from '@alilc/lowcode-designer';
|
||||||
import { CompositeValue, FieldConfig, CustomView, isCustomView } from '@alilc/lowcode-types';
|
import {
|
||||||
|
CompositeValue,
|
||||||
|
FieldConfig,
|
||||||
|
CustomView,
|
||||||
|
IPublicModelSettingPropEntry,
|
||||||
|
SetterType,
|
||||||
|
FieldExtraProps,
|
||||||
|
IPublicModelSettingTopEntry,
|
||||||
|
IPublicModelNode,
|
||||||
|
IPublicModelComponentMeta,
|
||||||
|
ISetValueOptions,
|
||||||
|
} from '@alilc/lowcode-types';
|
||||||
import { settingPropEntrySymbol } from './symbols';
|
import { settingPropEntrySymbol } from './symbols';
|
||||||
import Node from './node';
|
import Node from './node';
|
||||||
import SettingTopEntry from './setting-top-entry';
|
import SettingTopEntry from './setting-top-entry';
|
||||||
import ComponentMeta from './component-meta';
|
import ComponentMeta from './component-meta';
|
||||||
|
import { isCustomView } from '@alilc/lowcode-utils';
|
||||||
|
|
||||||
export default class SettingPropEntry {
|
export default class SettingPropEntry implements IPublicModelSettingPropEntry {
|
||||||
private readonly [settingPropEntrySymbol]: SettingField;
|
private readonly [settingPropEntrySymbol]: SettingField;
|
||||||
|
|
||||||
constructor(prop: SettingField) {
|
constructor(prop: SettingField) {
|
||||||
this[settingPropEntrySymbol] = prop;
|
this[settingPropEntrySymbol] = prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(prop: SettingField) {
|
static create(prop: SettingField): IPublicModelSettingPropEntry {
|
||||||
return new SettingPropEntry(prop);
|
return new SettingPropEntry(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设置属性的 isGroup
|
* 获取设置属性的 isGroup
|
||||||
*/
|
*/
|
||||||
get isGroup() {
|
get isGroup(): boolean {
|
||||||
return this[settingPropEntrySymbol].isGroup;
|
return this[settingPropEntrySymbol].isGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设置属性的 id
|
* 获取设置属性的 id
|
||||||
*/
|
*/
|
||||||
get id() {
|
get id(): string {
|
||||||
return this[settingPropEntrySymbol].id;
|
return this[settingPropEntrySymbol].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设置属性的 name
|
* 获取设置属性的 name
|
||||||
*/
|
*/
|
||||||
get name() {
|
get name(): string | number {
|
||||||
return this[settingPropEntrySymbol].name;
|
return this[settingPropEntrySymbol].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设置属性的 key
|
* 获取设置属性的 key
|
||||||
*/
|
*/
|
||||||
get key() {
|
get key(): string | number {
|
||||||
return this[settingPropEntrySymbol].getKey();
|
return this[settingPropEntrySymbol].getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设置属性的 path
|
* 获取设置属性的 path
|
||||||
*/
|
*/
|
||||||
get path() {
|
get path(): any[] {
|
||||||
return this[settingPropEntrySymbol].path;
|
return this[settingPropEntrySymbol].path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设置属性的 title
|
* 获取设置属性的 title
|
||||||
*/
|
*/
|
||||||
get title() {
|
get title(): any {
|
||||||
return this[settingPropEntrySymbol].title;
|
return this[settingPropEntrySymbol].title;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设置属性的 setter
|
* 获取设置属性的 setter
|
||||||
*/
|
*/
|
||||||
get setter() {
|
get setter(): SetterType | null {
|
||||||
return this[settingPropEntrySymbol].setter;
|
return this[settingPropEntrySymbol].setter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设置属性的 expanded
|
* 获取设置属性的 expanded
|
||||||
*/
|
*/
|
||||||
get expanded() {
|
get expanded(): boolean {
|
||||||
return this[settingPropEntrySymbol].expanded;
|
return this[settingPropEntrySymbol].expanded;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设置属性的 extraProps
|
* 获取设置属性的 extraProps
|
||||||
*/
|
*/
|
||||||
get extraProps() {
|
get extraProps(): FieldExtraProps {
|
||||||
return this[settingPropEntrySymbol].extraProps;
|
return this[settingPropEntrySymbol].extraProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
get props() {
|
get props(): IPublicModelSettingTopEntry {
|
||||||
return SettingTopEntry.create(this[settingPropEntrySymbol].props);
|
return SettingTopEntry.create(this[settingPropEntrySymbol].props);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设置属性对应的节点实例
|
* 获取设置属性对应的节点实例
|
||||||
*/
|
*/
|
||||||
get node(): Node | null {
|
get node(): IPublicModelNode | null {
|
||||||
return Node.create(this[settingPropEntrySymbol].getNode());
|
return Node.create(this[settingPropEntrySymbol].getNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设置属性的父设置属性
|
* 获取设置属性的父设置属性
|
||||||
*/
|
*/
|
||||||
get parent(): SettingPropEntry {
|
get parent(): IPublicModelSettingPropEntry {
|
||||||
return SettingPropEntry.create(this[settingPropEntrySymbol].parent as any);
|
return SettingPropEntry.create(this[settingPropEntrySymbol].parent as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取顶级设置属性
|
* 获取顶级设置属性
|
||||||
*/
|
*/
|
||||||
get top(): SettingTopEntry {
|
get top(): IPublicModelSettingTopEntry {
|
||||||
return SettingTopEntry.create(this[settingPropEntrySymbol].top);
|
return SettingTopEntry.create(this[settingPropEntrySymbol].top);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,14 +126,14 @@ export default class SettingPropEntry {
|
|||||||
/**
|
/**
|
||||||
* componentMeta
|
* componentMeta
|
||||||
*/
|
*/
|
||||||
get componentMeta(): ComponentMeta | null {
|
get componentMeta(): IPublicModelComponentMeta | null {
|
||||||
return ComponentMeta.create(this[settingPropEntrySymbol].componentMeta);
|
return ComponentMeta.create(this[settingPropEntrySymbol].componentMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设置属性的 items
|
* 获取设置属性的 items
|
||||||
*/
|
*/
|
||||||
get items(): Array<SettingPropEntry | CustomView> {
|
get items(): Array<IPublicModelSettingPropEntry | CustomView> {
|
||||||
return this[settingPropEntrySymbol].items?.map((item) => {
|
return this[settingPropEntrySymbol].items?.map((item) => {
|
||||||
if (isCustomView(item)) {
|
if (isCustomView(item)) {
|
||||||
return item;
|
return item;
|
||||||
@ -134,7 +146,7 @@ export default class SettingPropEntry {
|
|||||||
* 设置 key 值
|
* 设置 key 值
|
||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
setKey(key: string | number) {
|
setKey(key: string | number): void {
|
||||||
this[settingPropEntrySymbol].setKey(key);
|
this[settingPropEntrySymbol].setKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +168,7 @@ export default class SettingPropEntry {
|
|||||||
* 设置值
|
* 设置值
|
||||||
* @param val 值
|
* @param val 值
|
||||||
*/
|
*/
|
||||||
setValue(val: CompositeValue, extraOptions?: ISetValueOptions) {
|
setValue(val: CompositeValue, extraOptions?: ISetValueOptions): void {
|
||||||
this[settingPropEntrySymbol].setValue(val, false, false, extraOptions);
|
this[settingPropEntrySymbol].setValue(val, false, false, extraOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +177,7 @@ export default class SettingPropEntry {
|
|||||||
* @param propName 子属性名
|
* @param propName 子属性名
|
||||||
* @param value 值
|
* @param value 值
|
||||||
*/
|
*/
|
||||||
setPropValue(propName: string | number, value: any) {
|
setPropValue(propName: string | number, value: any): void {
|
||||||
this[settingPropEntrySymbol].setPropValue(propName, value);
|
this[settingPropEntrySymbol].setPropValue(propName, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +185,7 @@ export default class SettingPropEntry {
|
|||||||
* 清空指定属性值
|
* 清空指定属性值
|
||||||
* @param propName
|
* @param propName
|
||||||
*/
|
*/
|
||||||
clearPropValue(propName: string | number) {
|
clearPropValue(propName: string | number): void {
|
||||||
this[settingPropEntrySymbol].clearPropValue(propName);
|
this[settingPropEntrySymbol].clearPropValue(propName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +193,7 @@ export default class SettingPropEntry {
|
|||||||
* 获取配置的默认值
|
* 获取配置的默认值
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getDefaultValue() {
|
getDefaultValue(): any {
|
||||||
return this[settingPropEntrySymbol].getDefaultValue();
|
return this[settingPropEntrySymbol].getDefaultValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +201,7 @@ export default class SettingPropEntry {
|
|||||||
* 获取值
|
* 获取值
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getValue() {
|
getValue(): any {
|
||||||
return this[settingPropEntrySymbol].getValue();
|
return this[settingPropEntrySymbol].getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,21 +210,21 @@ export default class SettingPropEntry {
|
|||||||
* @param propName 子属性名
|
* @param propName 子属性名
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getPropValue(propName: string | number) {
|
getPropValue(propName: string | number): any {
|
||||||
return this[settingPropEntrySymbol].getPropValue(propName);
|
return this[settingPropEntrySymbol].getPropValue(propName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取顶层附属属性值
|
* 获取顶层附属属性值
|
||||||
*/
|
*/
|
||||||
getExtraPropValue(propName: string) {
|
getExtraPropValue(propName: string): any {
|
||||||
return this[settingPropEntrySymbol].getExtraPropValue(propName);
|
return this[settingPropEntrySymbol].getExtraPropValue(propName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置顶层附属属性值
|
* 设置顶层附属属性值
|
||||||
*/
|
*/
|
||||||
setExtraPropValue(propName: string, value: any) {
|
setExtraPropValue(propName: string, value: any): void {
|
||||||
this[settingPropEntrySymbol].setExtraPropValue(propName, value);
|
this[settingPropEntrySymbol].setExtraPropValue(propName, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +232,7 @@ export default class SettingPropEntry {
|
|||||||
* 获取设置属性集
|
* 获取设置属性集
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getProps() {
|
getProps(): IPublicModelSettingTopEntry {
|
||||||
return SettingTopEntry.create(this[settingPropEntrySymbol].getProps() as SettingEntry) as any;
|
return SettingTopEntry.create(this[settingPropEntrySymbol].getProps() as SettingEntry) as any;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +240,7 @@ export default class SettingPropEntry {
|
|||||||
* 是否绑定了变量
|
* 是否绑定了变量
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
isUseVariable() {
|
isUseVariable(): boolean {
|
||||||
return this[settingPropEntrySymbol].isUseVariable();
|
return this[settingPropEntrySymbol].isUseVariable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +248,7 @@ export default class SettingPropEntry {
|
|||||||
* 设置绑定变量
|
* 设置绑定变量
|
||||||
* @param flag
|
* @param flag
|
||||||
*/
|
*/
|
||||||
setUseVariable(flag: boolean) {
|
setUseVariable(flag: boolean): void {
|
||||||
this[settingPropEntrySymbol].setUseVariable(flag);
|
this[settingPropEntrySymbol].setUseVariable(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +257,7 @@ export default class SettingPropEntry {
|
|||||||
* @param config
|
* @param config
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
createField(config: FieldConfig) {
|
createField(config: FieldConfig): IPublicModelSettingPropEntry {
|
||||||
return SettingPropEntry.create(this[settingPropEntrySymbol].createField(config));
|
return SettingPropEntry.create(this[settingPropEntrySymbol].createField(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,21 +265,21 @@ export default class SettingPropEntry {
|
|||||||
* 获取值,当为变量时,返回 mock
|
* 获取值,当为变量时,返回 mock
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getMockOrValue() {
|
getMockOrValue(): any {
|
||||||
return this[settingPropEntrySymbol].getMockOrValue();
|
return this[settingPropEntrySymbol].getMockOrValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 销毁当前 field 实例
|
* 销毁当前 field 实例
|
||||||
*/
|
*/
|
||||||
purge() {
|
purge(): void {
|
||||||
this[settingPropEntrySymbol].purge();
|
this[settingPropEntrySymbol].purge();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 移除当前 field 实例
|
* 移除当前 field 实例
|
||||||
*/
|
*/
|
||||||
remove() {
|
remove(): void {
|
||||||
this[settingPropEntrySymbol].remove();
|
this[settingPropEntrySymbol].remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +288,7 @@ export default class SettingPropEntry {
|
|||||||
* @param action
|
* @param action
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
onEffect(action: () => void) {
|
onEffect(action: () => void): () => void {
|
||||||
return this[settingPropEntrySymbol].onEffect(action);
|
return this[settingPropEntrySymbol].onEffect(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,22 +2,23 @@ import { SettingEntry } from '@alilc/lowcode-designer';
|
|||||||
import { settingTopEntrySymbol } from './symbols';
|
import { settingTopEntrySymbol } from './symbols';
|
||||||
import Node from './node';
|
import Node from './node';
|
||||||
import SettingPropEntry from './setting-prop-entry';
|
import SettingPropEntry from './setting-prop-entry';
|
||||||
|
import { IPublicModelSettingTopEntry, IPublicModelNode, IPublicModelSettingPropEntry } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export default class SettingTopEntry {
|
export default class SettingTopEntry implements IPublicModelSettingTopEntry {
|
||||||
private readonly [settingTopEntrySymbol]: SettingEntry;
|
private readonly [settingTopEntrySymbol]: SettingEntry;
|
||||||
|
|
||||||
constructor(prop: SettingEntry) {
|
constructor(prop: SettingEntry) {
|
||||||
this[settingTopEntrySymbol] = prop;
|
this[settingTopEntrySymbol] = prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(prop: SettingEntry) {
|
static create(prop: SettingEntry): IPublicModelSettingTopEntry {
|
||||||
return new SettingTopEntry(prop);
|
return new SettingTopEntry(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回所属的节点实例
|
* 返回所属的节点实例
|
||||||
*/
|
*/
|
||||||
get node(): Node | null {
|
get node(): IPublicModelNode | null {
|
||||||
return Node.create(this[settingTopEntrySymbol].getNode());
|
return Node.create(this[settingTopEntrySymbol].getNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ export default class SettingTopEntry {
|
|||||||
* @param propName
|
* @param propName
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
get(propName: string | number) {
|
get(propName: string | number): IPublicModelSettingPropEntry {
|
||||||
return SettingPropEntry.create(this[settingTopEntrySymbol].get(propName) as any);
|
return SettingPropEntry.create(this[settingTopEntrySymbol].get(propName) as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ export default class SettingTopEntry {
|
|||||||
* @param propName
|
* @param propName
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getPropValue(propName: string | number) {
|
getPropValue(propName: string | number): any {
|
||||||
return this[settingTopEntrySymbol].getPropValue(propName);
|
return this[settingTopEntrySymbol].getPropValue(propName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ export default class SettingTopEntry {
|
|||||||
* @param propName
|
* @param propName
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
setPropValue(propName: string | number, value: any) {
|
setPropValue(propName: string | number, value: any): void {
|
||||||
this[settingTopEntrySymbol].setPropValue(propName, value);
|
this[settingTopEntrySymbol].setPropValue(propName, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,16 +2,17 @@ import {
|
|||||||
BuiltinSimulatorHost,
|
BuiltinSimulatorHost,
|
||||||
} from '@alilc/lowcode-designer';
|
} from '@alilc/lowcode-designer';
|
||||||
import { simulatorHostSymbol, nodeSymbol } from './symbols';
|
import { simulatorHostSymbol, nodeSymbol } from './symbols';
|
||||||
|
import { IPublicApiSimulatorHost, IPublicModelNode } from '@alilc/lowcode-types';
|
||||||
import type Node from './node';
|
import type Node from './node';
|
||||||
|
|
||||||
export default class SimulatorHost {
|
export default class SimulatorHost implements IPublicApiSimulatorHost {
|
||||||
private readonly [simulatorHostSymbol]: BuiltinSimulatorHost;
|
private readonly [simulatorHostSymbol]: BuiltinSimulatorHost;
|
||||||
|
|
||||||
constructor(simulator: BuiltinSimulatorHost) {
|
constructor(simulator: BuiltinSimulatorHost) {
|
||||||
this[simulatorHostSymbol] = simulator;
|
this[simulatorHostSymbol] = simulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(host: BuiltinSimulatorHost) {
|
static create(host: BuiltinSimulatorHost): IPublicApiSimulatorHost | null {
|
||||||
if (!host) return null;
|
if (!host) return null;
|
||||||
return new SimulatorHost(host);
|
return new SimulatorHost(host);
|
||||||
}
|
}
|
||||||
@ -19,18 +20,18 @@ export default class SimulatorHost {
|
|||||||
/**
|
/**
|
||||||
* 获取 contentWindow
|
* 获取 contentWindow
|
||||||
*/
|
*/
|
||||||
get contentWindow() {
|
get contentWindow(): Window | undefined {
|
||||||
return this[simulatorHostSymbol].contentWindow;
|
return this[simulatorHostSymbol].contentWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取 contentDocument
|
* 获取 contentDocument
|
||||||
*/
|
*/
|
||||||
get contentDocument() {
|
get contentDocument(): Document | undefined {
|
||||||
return this[simulatorHostSymbol].contentDocument;
|
return this[simulatorHostSymbol].contentDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
get renderer() {
|
get renderer(): any {
|
||||||
return this[simulatorHostSymbol].renderer;
|
return this[simulatorHostSymbol].renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ export default class SimulatorHost {
|
|||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
set(key: string, value: any) {
|
set(key: string, value: any): void {
|
||||||
this[simulatorHostSymbol].set(key, value);
|
this[simulatorHostSymbol].set(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ export default class SimulatorHost {
|
|||||||
* @param key
|
* @param key
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
get(key: string) {
|
get(key: string): any {
|
||||||
return this[simulatorHostSymbol].get(key);
|
return this[simulatorHostSymbol].get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,14 +57,14 @@ export default class SimulatorHost {
|
|||||||
* scroll to specific node
|
* scroll to specific node
|
||||||
* @param node
|
* @param node
|
||||||
*/
|
*/
|
||||||
scrollToNode(node: Node) {
|
scrollToNode(node: IPublicModelNode): void {
|
||||||
this[simulatorHostSymbol].scrollToNode(node[nodeSymbol]);
|
this[simulatorHostSymbol].scrollToNode((node as any)[nodeSymbol]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新渲染画布
|
* 刷新渲染画布
|
||||||
*/
|
*/
|
||||||
rerender() {
|
rerender(): void {
|
||||||
this[simulatorHostSymbol].rerender();
|
this[simulatorHostSymbol].rerender();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
import {
|
import {
|
||||||
Skeleton as InnerSkeleton,
|
Skeleton as InnerSkeleton,
|
||||||
IWidgetBaseConfig,
|
|
||||||
IWidgetConfigArea,
|
|
||||||
SkeletonEvents,
|
SkeletonEvents,
|
||||||
} from '@alilc/lowcode-editor-skeleton';
|
} from '@alilc/lowcode-editor-skeleton';
|
||||||
import { skeletonSymbol } from './symbols';
|
import { skeletonSymbol } from './symbols';
|
||||||
|
import { IPublicApiSkeleton, IWidgetBaseConfig, IWidgetConfigArea } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export default class Skeleton {
|
export default class Skeleton implements IPublicApiSkeleton {
|
||||||
private readonly [skeletonSymbol]: InnerSkeleton;
|
private readonly [skeletonSymbol]: InnerSkeleton;
|
||||||
|
|
||||||
constructor(skeleton: InnerSkeleton) {
|
constructor(skeleton: InnerSkeleton) {
|
||||||
@ -28,11 +27,13 @@ export default class Skeleton {
|
|||||||
* @param config
|
* @param config
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
remove(config: IWidgetBaseConfig) {
|
remove(config: IWidgetBaseConfig): number | undefined {
|
||||||
const { area, name } = config;
|
const { area, name } = config;
|
||||||
const skeleton = this[skeletonSymbol];
|
const skeleton = this[skeletonSymbol];
|
||||||
if (!normalizeArea(area)) return;
|
if (!normalizeArea(area)) {
|
||||||
skeleton[normalizeArea(area)!].container.remove(name);
|
return;
|
||||||
|
}
|
||||||
|
skeleton[normalizeArea(area)!].container?.remove(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
18
packages/types/src/deprecated/index.ts
Normal file
18
packages/types/src/deprecated/index.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
export * from './isActionContentObject';
|
||||||
|
export * from './isCustomView';
|
||||||
|
export * from './isDOMText';
|
||||||
|
export * from './isDynamicSetter';
|
||||||
|
export * from './isI18nData';
|
||||||
|
export * from './isJSBlock';
|
||||||
|
export * from './isJSExpression';
|
||||||
|
export * from './isJSFunction';
|
||||||
|
export * from './isJSSlot';
|
||||||
|
export * from './isLowCodeComponentType';
|
||||||
|
export * from './isNodeSchema';
|
||||||
|
export * from './isPlainObject';
|
||||||
|
export * from './isProCodeComponentType';
|
||||||
|
export * from './isProjectSchema';
|
||||||
|
export * from './isReactClass';
|
||||||
|
export * from './isReactComponent';
|
||||||
|
export * from './isSetterConfig';
|
||||||
|
export * from './isTitleConfig';
|
||||||
8
packages/types/src/deprecated/isActionContentObject.ts
Normal file
8
packages/types/src/deprecated/isActionContentObject.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { ActionContentObject } from '../metadata';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isActionContentObject(obj: any): obj is ActionContentObject {
|
||||||
|
return obj && typeof obj === 'object';
|
||||||
|
}
|
||||||
10
packages/types/src/deprecated/isCustomView.ts
Normal file
10
packages/types/src/deprecated/isCustomView.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { isValidElement } from 'react';
|
||||||
|
import { isReactComponent } from './isReactComponent';
|
||||||
|
import { CustomView } from '../setter-config';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isCustomView(obj: any): obj is CustomView {
|
||||||
|
return obj && (isValidElement(obj) || isReactComponent(obj));
|
||||||
|
}
|
||||||
8
packages/types/src/deprecated/isDOMText.ts
Normal file
8
packages/types/src/deprecated/isDOMText.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { DOMText } from '../schema';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isDOMText(data: any): data is DOMText {
|
||||||
|
return typeof data === 'string';
|
||||||
|
}
|
||||||
9
packages/types/src/deprecated/isDynamicSetter.ts
Normal file
9
packages/types/src/deprecated/isDynamicSetter.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { isReactClass } from './isReactClass';
|
||||||
|
import { DynamicSetter } from '../setter-config';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isDynamicSetter(obj: any): obj is DynamicSetter {
|
||||||
|
return obj && typeof obj === 'function' && !isReactClass(obj);
|
||||||
|
}
|
||||||
8
packages/types/src/deprecated/isI18nData.ts
Normal file
8
packages/types/src/deprecated/isI18nData.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { I18nData } from '../i18n';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isI18nData(obj: any): obj is I18nData {
|
||||||
|
return obj && obj.type === 'i18n';
|
||||||
|
}
|
||||||
8
packages/types/src/deprecated/isJSBlock.ts
Normal file
8
packages/types/src/deprecated/isJSBlock.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { JSBlock } from '../value-type';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isJSBlock(data: any): data is JSBlock {
|
||||||
|
return data && data.type === 'JSBlock';
|
||||||
|
}
|
||||||
8
packages/types/src/deprecated/isJSExpression.ts
Normal file
8
packages/types/src/deprecated/isJSExpression.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { JSExpression } from '../value-type';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isJSExpression(data: any): data is JSExpression {
|
||||||
|
return data && data.type === 'JSExpression' && data.extType !== 'function';
|
||||||
|
}
|
||||||
8
packages/types/src/deprecated/isJSFunction.ts
Normal file
8
packages/types/src/deprecated/isJSFunction.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { JSFunction } from '../value-type';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isJSFunction(x: any): x is JSFunction {
|
||||||
|
return typeof x === 'object' && x && x.type === 'JSFunction';
|
||||||
|
}
|
||||||
8
packages/types/src/deprecated/isJSSlot.ts
Normal file
8
packages/types/src/deprecated/isJSSlot.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { JSSlot } from '../value-type';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isJSSlot(data: any): data is JSSlot {
|
||||||
|
return data && data.type === 'JSSlot';
|
||||||
|
}
|
||||||
9
packages/types/src/deprecated/isLowCodeComponentType.ts
Normal file
9
packages/types/src/deprecated/isLowCodeComponentType.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { isProCodeComponentType } from './isProCodeComponentType';
|
||||||
|
import { ComponentMap, LowCodeComponentType } from '../npm';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isLowCodeComponentType(desc: ComponentMap): desc is LowCodeComponentType {
|
||||||
|
return !isProCodeComponentType(desc);
|
||||||
|
}
|
||||||
8
packages/types/src/deprecated/isNodeSchema.ts
Normal file
8
packages/types/src/deprecated/isNodeSchema.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { NodeSchema } from '../schema';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isNodeSchema(data: any): data is NodeSchema {
|
||||||
|
return data && data.componentName;
|
||||||
|
}
|
||||||
10
packages/types/src/deprecated/isPlainObject.ts
Normal file
10
packages/types/src/deprecated/isPlainObject.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isPlainObject(value: any): value is Record<string, unknown> {
|
||||||
|
if (typeof value !== 'object') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const proto = Object.getPrototypeOf(value);
|
||||||
|
return proto === Object.prototype || proto === null || Object.getPrototypeOf(proto) === null;
|
||||||
|
}
|
||||||
8
packages/types/src/deprecated/isProCodeComponentType.ts
Normal file
8
packages/types/src/deprecated/isProCodeComponentType.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { ComponentMap, ProCodeComponentType } from '../npm';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isProCodeComponentType(desc: ComponentMap): desc is ProCodeComponentType {
|
||||||
|
return 'package' in desc;
|
||||||
|
}
|
||||||
8
packages/types/src/deprecated/isProjectSchema.ts
Normal file
8
packages/types/src/deprecated/isProjectSchema.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { ProjectSchema } from '../schema';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isProjectSchema(data: any): data is ProjectSchema {
|
||||||
|
return data && data.componentsTree;
|
||||||
|
}
|
||||||
8
packages/types/src/deprecated/isReactClass.ts
Normal file
8
packages/types/src/deprecated/isReactClass.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { ComponentClass, Component } from 'react';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isReactClass(obj: any): obj is ComponentClass<any> {
|
||||||
|
return obj && obj.prototype && (obj.prototype.isReactComponent || obj.prototype instanceof Component);
|
||||||
|
}
|
||||||
9
packages/types/src/deprecated/isReactComponent.ts
Normal file
9
packages/types/src/deprecated/isReactComponent.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { ComponentType } from 'react';
|
||||||
|
import { isReactClass } from './isReactClass';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isReactComponent(obj: any): obj is ComponentType<any> {
|
||||||
|
return obj && (isReactClass(obj) || typeof obj === 'function');
|
||||||
|
}
|
||||||
9
packages/types/src/deprecated/isSetterConfig.ts
Normal file
9
packages/types/src/deprecated/isSetterConfig.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { SetterConfig } from '../setter-config';
|
||||||
|
import { isCustomView } from './isCustomView';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isSetterConfig(obj: any): obj is SetterConfig {
|
||||||
|
return obj && typeof obj === 'object' && 'componentName' in obj && !isCustomView(obj);
|
||||||
|
}
|
||||||
10
packages/types/src/deprecated/isTitleConfig.ts
Normal file
10
packages/types/src/deprecated/isTitleConfig.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { isI18nData } from './isI18nData';
|
||||||
|
import { isPlainObject } from './isPlainObject';
|
||||||
|
import { TitleConfig } from '../title';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use same function from '@alilc/lowcode-utils' instead
|
||||||
|
*/
|
||||||
|
export function isTitleConfig(obj: any): obj is TitleConfig {
|
||||||
|
return isPlainObject(obj) && !isI18nData(obj);
|
||||||
|
}
|
||||||
23
packages/types/src/designer.ts
Normal file
23
packages/types/src/designer.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import { IPublicModelNode } from './shell';
|
||||||
|
|
||||||
|
export enum PROP_VALUE_CHANGED_TYPE {
|
||||||
|
/**
|
||||||
|
* normal set value
|
||||||
|
*/
|
||||||
|
SET_VALUE = 'SET_VALUE',
|
||||||
|
/**
|
||||||
|
* value changed caused by sub-prop value change
|
||||||
|
*/
|
||||||
|
SUB_VALUE_CHANGE = 'SUB_VALUE_CHANGE',
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ISetValueOptions {
|
||||||
|
disableMutator?: boolean;
|
||||||
|
type?: PROP_VALUE_CHANGED_TYPE;
|
||||||
|
fromSetHotValue?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IPublicOnChangeOptions {
|
||||||
|
type: string;
|
||||||
|
node: IPublicModelNode;
|
||||||
|
}
|
||||||
29
packages/types/src/dragon.ts
Normal file
29
packages/types/src/dragon.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { NodeSchema } from './schema';
|
||||||
|
import { IPublicModelNode } from './shell';
|
||||||
|
|
||||||
|
export interface DragAnyObject {
|
||||||
|
type: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DragNodeDataObject {
|
||||||
|
type: DragObjectType.NodeData;
|
||||||
|
data: NodeSchema | NodeSchema[];
|
||||||
|
thumbnail?: string;
|
||||||
|
description?: string;
|
||||||
|
[extra: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type DragObject = DragNodeObject | DragNodeDataObject | DragAnyObject;
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-shadow
|
||||||
|
export enum DragObjectType {
|
||||||
|
// eslint-disable-next-line no-shadow
|
||||||
|
Node = 'node',
|
||||||
|
NodeData = 'nodedata',
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DragNodeObject {
|
||||||
|
type: DragObjectType.Node;
|
||||||
|
nodes: (Node | IPublicModelNode)[];
|
||||||
|
}
|
||||||
27
packages/types/src/editor-skeleton.ts
Normal file
27
packages/types/src/editor-skeleton.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* 所有可能的停靠位置
|
||||||
|
*/
|
||||||
|
export type IWidgetConfigArea =
|
||||||
|
| 'leftArea' | 'left' | 'rightArea'
|
||||||
|
| 'right' | 'topArea' | 'top'
|
||||||
|
| 'toolbar' | 'mainArea' | 'main'
|
||||||
|
| 'center' | 'centerArea' | 'bottomArea'
|
||||||
|
| 'bottom' | 'leftFixedArea'
|
||||||
|
| 'leftFloatArea' | 'stages';
|
||||||
|
|
||||||
|
export interface IWidgetBaseConfig {
|
||||||
|
type: string;
|
||||||
|
name: string;
|
||||||
|
/**
|
||||||
|
* 停靠位置:
|
||||||
|
* - 当 type 为 'Panel' 时自动为 'leftFloatArea';
|
||||||
|
* - 当 type 为 'Widget' 时自动为 'mainArea';
|
||||||
|
* - 其他时候自动为 'leftArea';
|
||||||
|
*/
|
||||||
|
area?: IWidgetConfigArea;
|
||||||
|
props?: Record<string, any>;
|
||||||
|
content?: any;
|
||||||
|
contentProps?: Record<string, any>;
|
||||||
|
// index?: number;
|
||||||
|
[extra: string]: any;
|
||||||
|
}
|
||||||
@ -3,6 +3,8 @@ import StrictEventEmitter from 'strict-event-emitter-types';
|
|||||||
import { ReactNode, ComponentType } from 'react';
|
import { ReactNode, ComponentType } from 'react';
|
||||||
import { NpmInfo } from './npm';
|
import { NpmInfo } from './npm';
|
||||||
import * as GlobalEvent from './event';
|
import * as GlobalEvent from './event';
|
||||||
|
import { CustomView } from './setter-config';
|
||||||
|
import { TitleContent } from './title';
|
||||||
|
|
||||||
export type KeyType = (new (...args: any[]) => any) | symbol | string;
|
export type KeyType = (new (...args: any[]) => any) | symbol | string;
|
||||||
export type ClassType = new (...args: any[]) => any;
|
export type ClassType = new (...args: any[]) => any;
|
||||||
@ -197,3 +199,22 @@ export interface PluginStatus {
|
|||||||
export interface PluginStatusSet {
|
export interface PluginStatusSet {
|
||||||
[key: string]: PluginStatus;
|
[key: string]: PluginStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type HotkeyCallback = (e: KeyboardEvent, combo?: string) => any | false;
|
||||||
|
|
||||||
|
export interface RegisteredSetter {
|
||||||
|
component: CustomView;
|
||||||
|
defaultProps?: object;
|
||||||
|
title?: TitleContent;
|
||||||
|
/**
|
||||||
|
* for MixedSetter to check this setter if available
|
||||||
|
*/
|
||||||
|
condition?: (field: any) => boolean;
|
||||||
|
/**
|
||||||
|
* for MixedSetter to manual change to this setter
|
||||||
|
*/
|
||||||
|
initialValue?: any | ((field: any) => any);
|
||||||
|
recommend?: boolean;
|
||||||
|
// 标识是否为动态 setter,默认为 true
|
||||||
|
isDynamic?: boolean;
|
||||||
|
}
|
||||||
@ -6,11 +6,6 @@ export interface I18nData {
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
// type checks
|
|
||||||
export function isI18nData(obj: any): obj is I18nData {
|
|
||||||
return obj && obj.type === 'i18n';
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface I18nMap {
|
export interface I18nMap {
|
||||||
[lang: string]: { [key: string]: string };
|
[lang: string]: { [key: string]: string };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,3 +22,10 @@ export * from './assets';
|
|||||||
export * as GlobalEvent from './event';
|
export * as GlobalEvent from './event';
|
||||||
export * from './disposable';
|
export * from './disposable';
|
||||||
export * from './start-transaction';
|
export * from './start-transaction';
|
||||||
|
export * from './props-transducer';
|
||||||
|
export * from './editor-skeleton';
|
||||||
|
export * from './designer';
|
||||||
|
export * from './dragon';
|
||||||
|
export * from './shell';
|
||||||
|
// TODO: remove this in future versions
|
||||||
|
export * from './deprecated';
|
||||||
|
|||||||
@ -336,10 +336,6 @@ export interface ComponentAction {
|
|||||||
important?: boolean;
|
important?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isActionContentObject(obj: any): obj is ActionContentObject {
|
|
||||||
return obj && typeof obj === 'object';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组件 meta 配置
|
* 组件 meta 配置
|
||||||
*/
|
*/
|
||||||
@ -473,3 +469,17 @@ export interface Callbacks {
|
|||||||
currentNode: any,
|
currentNode: any,
|
||||||
) => void;
|
) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MetadataTransducer {
|
||||||
|
(prev: TransformedComponentMetadata): TransformedComponentMetadata;
|
||||||
|
/**
|
||||||
|
* 0 - 9 system
|
||||||
|
* 10 - 99 builtin-plugin
|
||||||
|
* 100 - app & plugin
|
||||||
|
*/
|
||||||
|
level?: number;
|
||||||
|
/**
|
||||||
|
* use to replace TODO
|
||||||
|
*/
|
||||||
|
id?: string;
|
||||||
|
}
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* npm 源引入完整描述对象
|
* npm 源引入完整描述对象
|
||||||
*/
|
*/
|
||||||
@ -45,13 +46,4 @@ export interface LowCodeComponentType {
|
|||||||
|
|
||||||
export type ProCodeComponentType = NpmInfo;
|
export type ProCodeComponentType = NpmInfo;
|
||||||
export type ComponentMap = ProCodeComponentType | LowCodeComponentType;
|
export type ComponentMap = ProCodeComponentType | LowCodeComponentType;
|
||||||
|
|
||||||
export function isProCodeComponentType(desc: ComponentMap): desc is ProCodeComponentType {
|
|
||||||
return 'package' in desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isLowCodeComponentType(desc: ComponentMap): desc is LowCodeComponentType {
|
|
||||||
return !isProCodeComponentType(desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ComponentsMap = ComponentMap[];
|
export type ComponentsMap = ComponentMap[];
|
||||||
|
|||||||
12
packages/types/src/props-transducer.ts
Normal file
12
packages/types/src/props-transducer.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { TransformStage } from './transform-stage';
|
||||||
|
import { CompositeObject } from './value-type';
|
||||||
|
|
||||||
|
export type PropsReducerContext = {
|
||||||
|
stage: TransformStage;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PropsTransducer = (
|
||||||
|
props: CompositeObject,
|
||||||
|
node: Node,
|
||||||
|
ctx?: PropsReducerContext,
|
||||||
|
) => CompositeObject;
|
||||||
@ -75,11 +75,6 @@ export type PropsList = Array<{
|
|||||||
|
|
||||||
export type NodeData = NodeSchema | JSExpression | DOMText;
|
export type NodeData = NodeSchema | JSExpression | DOMText;
|
||||||
export type NodeDataType = NodeData | NodeData[];
|
export type NodeDataType = NodeData | NodeData[];
|
||||||
|
|
||||||
export function isDOMText(data: any): data is DOMText {
|
|
||||||
return typeof data === 'string';
|
|
||||||
}
|
|
||||||
|
|
||||||
export type DOMText = string;
|
export type DOMText = string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -218,11 +213,3 @@ export interface ProjectSchema {
|
|||||||
*/
|
*/
|
||||||
meta?: Record<string, any>;
|
meta?: Record<string, any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isNodeSchema(data: any): data is NodeSchema {
|
|
||||||
return data && data.componentName;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isProjectSchema(data: any): data is ProjectSchema {
|
|
||||||
return data && data.componentsTree;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,18 +1,9 @@
|
|||||||
import { ComponentClass, Component, ComponentType, ReactElement, isValidElement } from 'react';
|
import { ComponentType, ReactElement } from 'react';
|
||||||
import { TitleContent } from './title';
|
import { TitleContent } from './title';
|
||||||
import { SettingTarget } from './setting-target';
|
import { SettingTarget } from './setting-target';
|
||||||
import { CompositeValue } from './value-type';
|
import { CompositeValue } from './value-type';
|
||||||
|
|
||||||
function isReactClass(obj: any): obj is ComponentClass<any> {
|
|
||||||
return obj && obj.prototype && (obj.prototype.isReactComponent || obj.prototype instanceof Component);
|
|
||||||
}
|
|
||||||
|
|
||||||
function isReactComponent(obj: any): obj is ComponentType<any> {
|
|
||||||
return obj && (isReactClass(obj) || typeof obj === 'function');
|
|
||||||
}
|
|
||||||
|
|
||||||
export type CustomView = ReactElement | ComponentType<any>;
|
export type CustomView = ReactElement | ComponentType<any>;
|
||||||
|
|
||||||
export type DynamicProps = (target: SettingTarget) => Record<string, unknown>;
|
export type DynamicProps = (target: SettingTarget) => Record<string, unknown>;
|
||||||
export type DynamicSetter = (target: SettingTarget) => string | SetterConfig | CustomView;
|
export type DynamicSetter = (target: SettingTarget) => string | SetterConfig | CustomView;
|
||||||
|
|
||||||
@ -63,21 +54,9 @@ export interface SetterConfig {
|
|||||||
* @todo 物料协议推进
|
* @todo 物料协议推进
|
||||||
*/
|
*/
|
||||||
valueType?: CompositeValue[];
|
valueType?: CompositeValue[];
|
||||||
// 标识是否为动态setter,默认为true
|
// 标识是否为动态 setter,默认为 true
|
||||||
isDynamic?: boolean;
|
isDynamic?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if *string* passed must be a registered Setter Name, future support blockSchema
|
// if *string* passed must be a registered Setter Name, future support blockSchema
|
||||||
export type SetterType = SetterConfig | SetterConfig[] | string | CustomView;
|
export type SetterType = SetterConfig | SetterConfig[] | string | CustomView;
|
||||||
|
|
||||||
export function isSetterConfig(obj: any): obj is SetterConfig {
|
|
||||||
return obj && typeof obj === 'object' && 'componentName' in obj && !isCustomView(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isCustomView(obj: any): obj is CustomView {
|
|
||||||
return obj && (isValidElement(obj) || isReactComponent(obj));
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isDynamicSetter(obj: any): obj is DynamicSetter {
|
|
||||||
return obj && typeof obj === 'function' && !isReactClass(obj);
|
|
||||||
}
|
|
||||||
|
|||||||
50
packages/types/src/shell/api/common.ts
Normal file
50
packages/types/src/shell/api/common.ts
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
|
||||||
|
import { Component, ReactNode } from 'react';
|
||||||
|
import { NodeSchema } from '../../schema';
|
||||||
|
import { TransitionType } from '../../start-transaction';
|
||||||
|
|
||||||
|
export interface IPublicCommonUtils {
|
||||||
|
isNodeSchema(data: any): boolean;
|
||||||
|
|
||||||
|
isFormEvent(e: KeyboardEvent | MouseEvent): boolean;
|
||||||
|
|
||||||
|
compatibleLegaoSchema(props: any): any;
|
||||||
|
|
||||||
|
getNodeSchemaById(schema: NodeSchema, nodeId: string): NodeSchema | undefined;
|
||||||
|
|
||||||
|
getConvertedExtraKey(key: string): string;
|
||||||
|
|
||||||
|
getOriginalExtraKey(key: string): string;
|
||||||
|
|
||||||
|
executeTransaction(fn: () => void, type: TransitionType): void;
|
||||||
|
|
||||||
|
createIntl(instance: string | object): {
|
||||||
|
intlNode(id: string, params?: object): ReactNode;
|
||||||
|
intl(id: string, params?: object): string;
|
||||||
|
getLocale(): string;
|
||||||
|
setLocale(locale: string): void;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export interface IPublicCommonSkeletonCabin {
|
||||||
|
get Workbench(): Component;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IPublicCommonDesignerCabin {
|
||||||
|
/**
|
||||||
|
* 是否是 SettingField 实例
|
||||||
|
*
|
||||||
|
* @param {*} obj
|
||||||
|
* @returns {obj is SettingField}
|
||||||
|
* @memberof DesignerCabin
|
||||||
|
*/
|
||||||
|
isSettingField(obj: any): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IPublicApiCommon {
|
||||||
|
|
||||||
|
get utils(): IPublicCommonUtils;
|
||||||
|
|
||||||
|
get designerCabin(): IPublicCommonDesignerCabin;
|
||||||
|
|
||||||
|
get skeletonCabin(): IPublicCommonSkeletonCabin;
|
||||||
|
}
|
||||||
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