mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-06-11 09:52:33 +00:00
Compare commits
7 Commits
main
...
v1.1.5-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
568302820c | ||
|
|
4111f6eecb | ||
|
|
a05a36b06c | ||
|
|
dfa1fcda12 | ||
|
|
cf993af632 | ||
|
|
0c92794ac5 | ||
|
|
237b1bed31 |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-engine-docs",
|
||||
"version": "1.0.21",
|
||||
"version": "1.0.22",
|
||||
"description": "低代码引擎版本化文档",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"lerna": "4.0.0",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"npmClient": "yarn",
|
||||
"useWorkspaces": true,
|
||||
"packages": [
|
||||
|
||||
@ -16,6 +16,7 @@ const jestConfig = {
|
||||
// testMatch: ['**/prop.test.ts'],
|
||||
// testMatch: ['(/tests?/.*(test))\\.[jt]s$'],
|
||||
// testMatch: ['**/document/node/node.add.test.ts'],
|
||||
// testMatch: ['**/setting-field.test.ts'],
|
||||
transformIgnorePatterns: [
|
||||
`/node_modules/(?!${esModules})/`,
|
||||
],
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-designer",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"description": "Designer for Ali LowCode Engine",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
@ -15,9 +15,9 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@alilc/lowcode-editor-core": "1.1.4",
|
||||
"@alilc/lowcode-types": "1.1.4",
|
||||
"@alilc/lowcode-utils": "1.1.4",
|
||||
"@alilc/lowcode-editor-core": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-types": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-utils": "1.1.5-beta.2",
|
||||
"classnames": "^2.2.6",
|
||||
"react": "^16",
|
||||
"react-dom": "^16.7.0",
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { makeObservable, obx, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core';
|
||||
import { IPublicModelDetecting } from '@alilc/lowcode-types';
|
||||
import { IDocumentModel } from '../document/document-model';
|
||||
import { INode } from '../document/node/node';
|
||||
import type { IDocumentModel } from '../document/document-model';
|
||||
import type { INode } from '../document/node/node';
|
||||
|
||||
const DETECTING_CHANGE_EVENT = 'detectingChange';
|
||||
export interface IDetecting extends Omit< IPublicModelDetecting<INode>,
|
||||
export interface IDetecting extends Omit<IPublicModelDetecting<INode>,
|
||||
'capture' |
|
||||
'release' |
|
||||
'leave'
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { IDocumentModel, INode } from '../document';
|
||||
import type { IDocumentModel, INode } from '../document';
|
||||
import { ILocateEvent } from './dragon';
|
||||
import {
|
||||
IPublicModelDropLocation,
|
||||
@ -98,7 +98,7 @@ function isDocument(elem: any): elem is Document {
|
||||
export function getWindow(elem: Element | Document): Window {
|
||||
return (isDocument(elem) ? elem : elem.ownerDocument!).defaultView!;
|
||||
}
|
||||
export interface IDropLocation extends Omit< IPublicModelDropLocation, 'target' | 'clone' > {
|
||||
export interface IDropLocation extends Omit<IPublicModelDropLocation, 'target' | 'clone'> {
|
||||
|
||||
readonly source: string;
|
||||
|
||||
|
||||
@ -6,11 +6,13 @@ import {
|
||||
IPublicTypeFieldExtraProps,
|
||||
IPublicTypeFieldConfig,
|
||||
IPublicTypeCustomView,
|
||||
IPublicTypeSetValueOptions,
|
||||
IPublicTypeDisposable,
|
||||
IPublicModelSettingField,
|
||||
IBaseModelSettingField,
|
||||
} from '@alilc/lowcode-types';
|
||||
import type {
|
||||
IPublicTypeSetValueOptions,
|
||||
} from '@alilc/lowcode-types';
|
||||
import { Transducer } from './utils';
|
||||
import { ISettingPropEntry, SettingPropEntry } from './setting-prop-entry';
|
||||
import { computed, obx, makeObservable, action, untracked, intl } from '@alilc/lowcode-editor-core';
|
||||
@ -31,10 +33,10 @@ function getSettingFieldCollectorKey(parent: ISettingTopEntry | ISettingField, c
|
||||
}
|
||||
|
||||
export interface ISettingField extends ISettingPropEntry, Omit<IBaseModelSettingField<
|
||||
ISettingTopEntry,
|
||||
ISettingField,
|
||||
IComponentMeta,
|
||||
INode
|
||||
ISettingTopEntry,
|
||||
ISettingField,
|
||||
IComponentMeta,
|
||||
INode
|
||||
>, 'setValue' | 'key' | 'node'> {
|
||||
get items(): Array<ISettingField | IPublicTypeCustomView>;
|
||||
|
||||
|
||||
@ -3,16 +3,16 @@ import { GlobalEvent, IPublicApiSetters, IPublicModelEditor, IPublicModelSetting
|
||||
import { uniqueId, isJSExpression } from '@alilc/lowcode-utils';
|
||||
import { ISettingEntry } from './setting-entry-type';
|
||||
import { INode } from '../../document';
|
||||
import { IComponentMeta } from '../../component-meta';
|
||||
import type { IComponentMeta } from '../../component-meta';
|
||||
import { IDesigner } from '../designer';
|
||||
import { ISettingTopEntry } from './setting-top-entry';
|
||||
import { ISettingField, isSettingField } from './setting-field';
|
||||
|
||||
export interface ISettingPropEntry extends ISettingEntry {
|
||||
get props(): ISettingTopEntry;
|
||||
|
||||
readonly isGroup: boolean;
|
||||
|
||||
get props(): ISettingTopEntry;
|
||||
|
||||
get name(): string | number | undefined;
|
||||
|
||||
valueChange(options: IPublicTypeSetValueOptions): void;
|
||||
@ -75,7 +75,7 @@ export class SettingPropEntry implements ISettingPropEntry {
|
||||
|
||||
@computed get path() {
|
||||
const path = this.parent.path.slice();
|
||||
if (this.type === 'field' && this.name) {
|
||||
if (this.type === 'field' && this.name?.toString()) {
|
||||
path.push(this.name);
|
||||
}
|
||||
return path;
|
||||
@ -191,7 +191,7 @@ export class SettingPropEntry implements ISettingPropEntry {
|
||||
*/
|
||||
getValue(): any {
|
||||
let val: any;
|
||||
if (this.type === 'field' && this.name) {
|
||||
if (this.type === 'field' && this.name?.toString()) {
|
||||
val = this.parent.getPropValue(this.name);
|
||||
}
|
||||
const { getValue } = this.extraProps;
|
||||
@ -209,7 +209,7 @@ export class SettingPropEntry implements ISettingPropEntry {
|
||||
setValue(val: any, isHotValue?: boolean, force?: boolean, extraOptions?: IPublicTypeSetValueOptions) {
|
||||
const oldValue = this.getValue();
|
||||
if (this.type === 'field') {
|
||||
this.name && this.parent.setPropValue(this.name, val);
|
||||
this.name?.toString() && this.parent.setPropValue(this.name, val);
|
||||
}
|
||||
|
||||
const { setValue } = this.extraProps;
|
||||
@ -233,7 +233,7 @@ export class SettingPropEntry implements ISettingPropEntry {
|
||||
*/
|
||||
clearValue() {
|
||||
if (this.type === 'field') {
|
||||
this.name && this.parent.clearPropValue(this.name);
|
||||
this.name?.toString() && this.parent.clearPropValue(this.name);
|
||||
}
|
||||
const { setValue } = this.extraProps;
|
||||
if (setValue) {
|
||||
@ -395,6 +395,6 @@ export class SettingPropEntry implements ISettingPropEntry {
|
||||
}
|
||||
|
||||
internalToShellField(): IPublicModelSettingField {
|
||||
return this.designer!.shellModelFactory.createSettingField(this);;
|
||||
return this.designer!.shellModelFactory.createSettingField(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ import { computed, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor
|
||||
import { ISettingEntry } from './setting-entry-type';
|
||||
import { ISettingField, SettingField } from './setting-field';
|
||||
import { INode } from '../../document';
|
||||
import { IComponentMeta } from '../../component-meta';
|
||||
import type { IComponentMeta } from '../../component-meta';
|
||||
import { IDesigner } from '../designer';
|
||||
import { Setters } from '@alilc/lowcode-shell';
|
||||
|
||||
|
||||
@ -11,7 +11,6 @@ import {
|
||||
import {
|
||||
IPublicTypeNodeData,
|
||||
IPublicTypeNodeSchema,
|
||||
IPublicTypeRootSchema,
|
||||
IPublicTypePageSchema,
|
||||
IPublicTypeComponentsMap,
|
||||
IPublicTypeDragNodeObject,
|
||||
@ -21,7 +20,10 @@ import {
|
||||
IPublicTypeOnChangeOptions,
|
||||
IPublicTypeDisposable,
|
||||
} from '@alilc/lowcode-types';
|
||||
import {
|
||||
import type {
|
||||
IPublicTypeRootSchema,
|
||||
} from '@alilc/lowcode-types';
|
||||
import type {
|
||||
IDropLocation,
|
||||
} from '@alilc/lowcode-designer';
|
||||
import {
|
||||
@ -37,9 +39,10 @@ import {
|
||||
} from '@alilc/lowcode-utils';
|
||||
import { IProject } from '../project';
|
||||
import { ISimulatorHost } from '../simulator';
|
||||
import { IComponentMeta } from '../component-meta';
|
||||
import type { IComponentMeta } from '../component-meta';
|
||||
import { IDesigner, IHistory } from '../designer';
|
||||
import { insertChildren, insertChild, IRootNode, INode } from './node/node';
|
||||
import { insertChildren, insertChild, IRootNode } from './node/node';
|
||||
import type { INode } from './node/node';
|
||||
import { Selection, ISelection } from './selection';
|
||||
import { History } from './history';
|
||||
import { IModalNodesManager, ModalNodesManager, Node } from './node';
|
||||
@ -49,11 +52,11 @@ export type GetDataType<T, NodeType> = T extends undefined
|
||||
? NodeType extends {
|
||||
schema: infer R;
|
||||
}
|
||||
? R
|
||||
: any
|
||||
? R
|
||||
: any
|
||||
: T;
|
||||
|
||||
export interface IDocumentModel extends Omit< IPublicModelDocumentModel<
|
||||
export interface IDocumentModel extends Omit<IPublicModelDocumentModel<
|
||||
ISelection,
|
||||
IHistory,
|
||||
INode,
|
||||
@ -656,9 +659,9 @@ export class DocumentModel implements IDocumentModel {
|
||||
}
|
||||
|
||||
checkNesting(
|
||||
dropTarget: INode,
|
||||
dragObject: IPublicTypeDragNodeObject | IPublicTypeNodeSchema | INode | IPublicTypeDragNodeDataObject,
|
||||
): boolean {
|
||||
dropTarget: INode,
|
||||
dragObject: IPublicTypeDragNodeObject | IPublicTypeNodeSchema | INode | IPublicTypeDragNodeDataObject,
|
||||
): boolean {
|
||||
let items: Array<INode | IPublicTypeNodeSchema>;
|
||||
if (isDragNodeDataObject(dragObject)) {
|
||||
items = Array.isArray(dragObject.data) ? dragObject.data : [dragObject.data];
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { obx, computed, makeObservable } from '@alilc/lowcode-editor-core';
|
||||
import { uniqueId } from '@alilc/lowcode-utils';
|
||||
import { IPublicTypeTitleContent, IPublicModelExclusiveGroup } from '@alilc/lowcode-types';
|
||||
import { INode } from './node';
|
||||
import type { INode } from './node';
|
||||
import { intl } from '../../locale';
|
||||
|
||||
export interface IExclusiveGroup extends IPublicModelExclusiveGroup<INode> {
|
||||
|
||||
@ -21,11 +21,12 @@ import {
|
||||
import { compatStage, isDOMText, isJSExpression, isNode, isNodeSchema } from '@alilc/lowcode-utils';
|
||||
import { ISettingTopEntry } from '@alilc/lowcode-designer';
|
||||
import { Props, getConvertedExtraKey, IProps } from './props/props';
|
||||
import { IDocumentModel } from '../document-model';
|
||||
import type { IDocumentModel } from '../document-model';
|
||||
import { NodeChildren, INodeChildren } from './node-children';
|
||||
import { IProp, Prop } from './props/prop';
|
||||
import { IComponentMeta } from '../../component-meta';
|
||||
import { ExclusiveGroup, IExclusiveGroup, isExclusiveGroup } from './exclusive-group';
|
||||
import type { IComponentMeta } from '../../component-meta';
|
||||
import { ExclusiveGroup, isExclusiveGroup } from './exclusive-group';
|
||||
import type { IExclusiveGroup } from './exclusive-group';
|
||||
import { includeSlot, removeSlot } from '../../utils/slot';
|
||||
import { foreachReverse } from '../../utils/tree';
|
||||
import { NodeRemoveOptions, EDITOR_EVENT } from '../../types';
|
||||
@ -154,7 +155,7 @@ export interface IBaseNode<Schema extends IPublicTypeNodeSchema = IPublicTypeNod
|
||||
|
||||
getChildren(): INodeChildren | null;
|
||||
|
||||
clearPropValue(path: string): void;
|
||||
clearPropValue(path: string | number): void;
|
||||
|
||||
setProps(props?: IPublicTypePropsMap | IPublicTypePropsList | Props | null): void;
|
||||
|
||||
@ -1095,7 +1096,7 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
|
||||
condition(this) !== false :
|
||||
condition !== false;
|
||||
})
|
||||
.map((action: IPublicTypeComponentAction) => action.name) || [];
|
||||
.map((action: IPublicTypeComponentAction) => action.name) || [];
|
||||
|
||||
return availableActions.indexOf(actionName) >= 0;
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import { untracked, computed, obx, engineConfig, action, makeObservable, mobx, runInAction } from '@alilc/lowcode-editor-core';
|
||||
import { IPublicTypeCompositeValue, GlobalEvent, IPublicTypeJSSlot, IPublicTypeSlotSchema, IPublicEnumTransformStage, IPublicModelProp } from '@alilc/lowcode-types';
|
||||
import { GlobalEvent, IPublicEnumTransformStage } from '@alilc/lowcode-types';
|
||||
import type { IPublicTypeCompositeValue, IPublicTypeJSSlot, IPublicTypeSlotSchema, IPublicModelProp } from '@alilc/lowcode-types';
|
||||
import { uniqueId, isPlainObject, hasOwnProperty, compatStage, isJSExpression, isJSSlot, isNodeSchema } from '@alilc/lowcode-utils';
|
||||
import { valueToSource } from './value-to-source';
|
||||
import { IProps, IPropParent } from './props';
|
||||
import { IPropParent } from './props';
|
||||
import type { IProps } from './props';
|
||||
import { ISlotNode, INode } from '../node';
|
||||
// import { TransformStage } from '../transform-stage';
|
||||
|
||||
@ -13,13 +15,14 @@ export type UNSET = typeof UNSET;
|
||||
|
||||
export interface IProp extends Omit<IPublicModelProp<
|
||||
INode
|
||||
>, 'exportSchema' | 'node' > {
|
||||
>, 'exportSchema' | 'node'>, IPropParent {
|
||||
key: string | number | undefined;
|
||||
|
||||
readonly props: IProps;
|
||||
|
||||
readonly owner: INode;
|
||||
|
||||
delete(prop: Prop): void;
|
||||
delete(prop: IProp): void;
|
||||
|
||||
export(stage: IPublicEnumTransformStage): IPublicTypeCompositeValue;
|
||||
|
||||
@ -35,7 +38,15 @@ export interface IProp extends Omit<IPublicModelProp<
|
||||
|
||||
isUnset(): boolean;
|
||||
|
||||
key: string | number | undefined;
|
||||
purge(): void;
|
||||
|
||||
setupItems(): IProp[] | null;
|
||||
|
||||
get type(): ValueTypes;
|
||||
|
||||
get size(): number;
|
||||
|
||||
get code(): string;
|
||||
}
|
||||
|
||||
export type ValueTypes = 'unset' | 'literal' | 'map' | 'list' | 'expression' | 'slot';
|
||||
@ -125,15 +136,15 @@ export class Prop implements IProp, IPropParent {
|
||||
this._code = code;
|
||||
}
|
||||
|
||||
private _slotNode?: INode;
|
||||
private _slotNode?: INode | null;
|
||||
|
||||
get slotNode(): INode | null {
|
||||
return this._slotNode || null;
|
||||
}
|
||||
|
||||
@obx.shallow private _items: Prop[] | null = null;
|
||||
@obx.shallow private _items: IProp[] | null = null;
|
||||
|
||||
@obx.shallow private _maps: Map<string | number, Prop> | null = null;
|
||||
@obx.shallow private _maps: Map<string | number, IProp> | null = null;
|
||||
|
||||
/**
|
||||
* 作为 _maps 的一层缓存机制,主要是复用部分已存在的 Prop,保持响应式关系,比如:
|
||||
@ -141,15 +152,15 @@ export class Prop implements IProp, IPropParent {
|
||||
* 导致假如外部有 mobx reaction(常见于 observer),此时响应式链路会被打断,
|
||||
* 因为 reaction 监听的是原 Prop(a) 的 _value,而不是新 Prop(a) 的 _value。
|
||||
*/
|
||||
private _prevMaps: Map<string | number, Prop> | null = null;
|
||||
private _prevMaps: Map<string | number, IProp> | null = null;
|
||||
|
||||
/**
|
||||
* 构造 items 属性,同时构造 maps 属性
|
||||
*/
|
||||
private get items(): Prop[] | null {
|
||||
private get items(): IProp[] | null {
|
||||
if (this._items) return this._items;
|
||||
return runInAction(() => {
|
||||
let items: Prop[] | null = null;
|
||||
let items: IProp[] | null = null;
|
||||
if (this._type === 'list') {
|
||||
const data = this._value;
|
||||
data.forEach((item: any, idx: number) => {
|
||||
@ -159,10 +170,10 @@ export class Prop implements IProp, IPropParent {
|
||||
this._maps = null;
|
||||
} else if (this._type === 'map') {
|
||||
const data = this._value;
|
||||
const maps = new Map<string, Prop>();
|
||||
const maps = new Map<string, IProp>();
|
||||
const keys = Object.keys(data);
|
||||
for (const key of keys) {
|
||||
let prop: Prop;
|
||||
let prop: IProp;
|
||||
if (this._prevMaps?.has(key)) {
|
||||
prop = this._prevMaps.get(key)!;
|
||||
prop.setValue(data[key]);
|
||||
@ -183,7 +194,7 @@ export class Prop implements IProp, IPropParent {
|
||||
});
|
||||
}
|
||||
|
||||
@computed private get maps(): Map<string | number, Prop> | null {
|
||||
@computed private get maps(): Map<string | number, IProp> | null {
|
||||
if (!this.items) {
|
||||
return null;
|
||||
}
|
||||
@ -433,7 +444,7 @@ export class Prop implements IProp, IPropParent {
|
||||
this._slotNode.import(slotSchema);
|
||||
} else {
|
||||
const { owner } = this.props;
|
||||
this._slotNode = owner.document.createNode<ISlotNode>(slotSchema);
|
||||
this._slotNode = owner.document?.createNode<ISlotNode>(slotSchema);
|
||||
if (this._slotNode) {
|
||||
owner.addSlot(this._slotNode);
|
||||
this._slotNode.internalSetSlotFor(this);
|
||||
@ -464,7 +475,7 @@ export class Prop implements IProp, IPropParent {
|
||||
/**
|
||||
* @returns 0: the same 1: maybe & like 2: not the same
|
||||
*/
|
||||
compare(other: Prop | null): number {
|
||||
compare(other: IProp | null): number {
|
||||
if (!other || other.isUnset()) {
|
||||
return this.isUnset() ? 0 : 2;
|
||||
}
|
||||
@ -488,7 +499,7 @@ export class Prop implements IProp, IPropParent {
|
||||
* @param createIfNone 当没有的时候,是否创建一个
|
||||
*/
|
||||
@action
|
||||
get(path: string | number, createIfNone = true): Prop | null {
|
||||
get(path: string | number, createIfNone = true): IProp | null {
|
||||
const type = this._type;
|
||||
if (type !== 'map' && type !== 'list' && type !== 'unset' && !createIfNone) {
|
||||
return null;
|
||||
@ -547,7 +558,7 @@ export class Prop implements IProp, IPropParent {
|
||||
* 删除项
|
||||
*/
|
||||
@action
|
||||
delete(prop: Prop): void {
|
||||
delete(prop: IProp): void {
|
||||
/* istanbul ignore else */
|
||||
if (this._items) {
|
||||
const i = this._items.indexOf(prop);
|
||||
@ -581,7 +592,7 @@ export class Prop implements IProp, IPropParent {
|
||||
* @param force 强制
|
||||
*/
|
||||
@action
|
||||
add(value: IPublicTypeCompositeValue, force = false): Prop | null {
|
||||
add(value: IPublicTypeCompositeValue, force = false): IProp | null {
|
||||
const type = this._type;
|
||||
if (type !== 'list' && type !== 'unset' && !force) {
|
||||
return null;
|
||||
@ -687,7 +698,7 @@ export class Prop implements IProp, IPropParent {
|
||||
/**
|
||||
* 迭代器
|
||||
*/
|
||||
[Symbol.iterator](): { next(): { value: Prop } } {
|
||||
[Symbol.iterator](): { next(): { value: IProp } } {
|
||||
let index = 0;
|
||||
const { items } = this;
|
||||
const length = items?.length || 0;
|
||||
@ -711,7 +722,7 @@ export class Prop implements IProp, IPropParent {
|
||||
* 遍历
|
||||
*/
|
||||
@action
|
||||
forEach(fn: (item: Prop, key: number | string | undefined) => void): void {
|
||||
forEach(fn: (item: IProp, key: number | string | undefined) => void): void {
|
||||
const { items } = this;
|
||||
if (!items) {
|
||||
return;
|
||||
@ -726,7 +737,7 @@ export class Prop implements IProp, IPropParent {
|
||||
* 遍历
|
||||
*/
|
||||
@action
|
||||
map<T>(fn: (item: Prop, key: number | string | undefined) => T): T[] | null {
|
||||
map<T>(fn: (item: IProp, key: number | string | undefined) => T): T[] | null {
|
||||
const { items } = this;
|
||||
if (!items) {
|
||||
return null;
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { computed, makeObservable, obx, action } from '@alilc/lowcode-editor-core';
|
||||
import { IPublicTypePropsMap, IPublicTypePropsList, IPublicTypeCompositeValue, IPublicEnumTransformStage, IBaseModelProps } from '@alilc/lowcode-types';
|
||||
import { IPublicTypePropsList, IPublicTypeCompositeValue, IPublicEnumTransformStage, IBaseModelProps } from '@alilc/lowcode-types';
|
||||
import type { IPublicTypePropsMap } from '@alilc/lowcode-types';
|
||||
import { uniqueId, compatStage } from '@alilc/lowcode-utils';
|
||||
import { Prop, IProp, UNSET } from './prop';
|
||||
import { Prop, UNSET } from './prop';
|
||||
import type { IProp } from './prop';
|
||||
import { INode } from '../node';
|
||||
// import { TransformStage } from '../transform-stage';
|
||||
|
||||
@ -26,23 +28,23 @@ export function getOriginalExtraKey(key: string): string {
|
||||
|
||||
export interface IPropParent {
|
||||
|
||||
readonly props: Props;
|
||||
readonly props: IProps;
|
||||
|
||||
readonly owner: INode;
|
||||
|
||||
get path(): string[];
|
||||
|
||||
delete(prop: Prop): void;
|
||||
delete(prop: IProp): void;
|
||||
}
|
||||
|
||||
export interface IProps extends Omit<IBaseModelProps<IProp>, | 'getExtraProp' | 'getExtraPropValue' | 'setExtraPropValue' | 'node'> {
|
||||
export interface IProps extends Omit<IBaseModelProps<IProp>, | 'getExtraProp' | 'getExtraPropValue' | 'setExtraPropValue' | 'node'>, IPropParent {
|
||||
|
||||
/**
|
||||
* 获取 props 对应的 node
|
||||
*/
|
||||
getNode(): INode;
|
||||
|
||||
get(path: string, createIfNone?: boolean): Prop | null;
|
||||
get(path: string, createIfNone?: boolean): IProp | null;
|
||||
|
||||
export(stage?: IPublicEnumTransformStage): {
|
||||
props?: IPublicTypePropsMap | IPublicTypePropsList;
|
||||
@ -53,7 +55,7 @@ export interface IProps extends Omit<IBaseModelProps<IProp>, | 'getExtraProp' |
|
||||
|
||||
purge(): void;
|
||||
|
||||
query(path: string, createIfNone: boolean): Prop | null;
|
||||
query(path: string, createIfNone: boolean): IProp | null;
|
||||
|
||||
import(value?: IPublicTypePropsMap | IPublicTypePropsList | null, extras?: ExtrasObject): void;
|
||||
}
|
||||
@ -61,7 +63,7 @@ export interface IProps extends Omit<IBaseModelProps<IProp>, | 'getExtraProp' |
|
||||
export class Props implements IProps, IPropParent {
|
||||
readonly id = uniqueId('props');
|
||||
|
||||
@obx.shallow private items: Prop[] = [];
|
||||
@obx.shallow private items: IProp[] = [];
|
||||
|
||||
@computed private get maps(): Map<string, Prop> {
|
||||
const maps = new Map();
|
||||
@ -77,7 +79,7 @@ export class Props implements IProps, IPropParent {
|
||||
|
||||
readonly path = [];
|
||||
|
||||
get props(): Props {
|
||||
get props(): IProps {
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -228,7 +230,7 @@ export class Props implements IProps, IPropParent {
|
||||
* @param createIfNone 当没有的时候,是否创建一个
|
||||
*/
|
||||
@action
|
||||
query(path: string, createIfNone = true): Prop | null {
|
||||
query(path: string, createIfNone = true): IProp | null {
|
||||
return this.get(path, createIfNone);
|
||||
}
|
||||
|
||||
@ -237,7 +239,7 @@ export class Props implements IProps, IPropParent {
|
||||
* @param createIfNone 当没有的时候,是否创建一个
|
||||
*/
|
||||
@action
|
||||
get(path: string, createIfNone = false): Prop | null {
|
||||
get(path: string, createIfNone = false): IProp | null {
|
||||
let entry = path;
|
||||
let nest = '';
|
||||
const i = path.indexOf('.');
|
||||
@ -265,7 +267,7 @@ export class Props implements IProps, IPropParent {
|
||||
* 删除项
|
||||
*/
|
||||
@action
|
||||
delete(prop: Prop): void {
|
||||
delete(prop: IProp): void {
|
||||
const i = this.items.indexOf(prop);
|
||||
if (i > -1) {
|
||||
this.items.splice(i, 1);
|
||||
@ -297,7 +299,7 @@ export class Props implements IProps, IPropParent {
|
||||
key?: string | number,
|
||||
spread = false,
|
||||
options: any = {},
|
||||
): Prop {
|
||||
): IProp {
|
||||
const prop = new Prop(this, value, key, spread, options);
|
||||
this.items.push(prop);
|
||||
return prop;
|
||||
@ -313,7 +315,7 @@ export class Props implements IProps, IPropParent {
|
||||
/**
|
||||
* 迭代器
|
||||
*/
|
||||
[Symbol.iterator](): { next(): { value: Prop } } {
|
||||
[Symbol.iterator](): { next(): { value: IProp } } {
|
||||
let index = 0;
|
||||
const { items } = this;
|
||||
const length = items.length || 0;
|
||||
@ -337,7 +339,7 @@ export class Props implements IProps, IPropParent {
|
||||
* 遍历
|
||||
*/
|
||||
@action
|
||||
forEach(fn: (item: Prop, key: number | string | undefined) => void): void {
|
||||
forEach(fn: (item: IProp, key: number | string | undefined) => void): void {
|
||||
this.items.forEach((item) => {
|
||||
return fn(item, item.key);
|
||||
});
|
||||
@ -347,14 +349,14 @@ export class Props implements IProps, IPropParent {
|
||||
* 遍历
|
||||
*/
|
||||
@action
|
||||
map<T>(fn: (item: Prop, key: number | string | undefined) => T): T[] | null {
|
||||
map<T>(fn: (item: IProp, key: number | string | undefined) => T): T[] | null {
|
||||
return this.items.map((item) => {
|
||||
return fn(item, item.key);
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
filter(fn: (item: Prop, key: number | string | undefined) => boolean) {
|
||||
filter(fn: (item: IProp, key: number | string | undefined) => boolean) {
|
||||
return this.items.filter((item) => {
|
||||
return fn(item, item.key);
|
||||
});
|
||||
@ -377,7 +379,7 @@ export class Props implements IProps, IPropParent {
|
||||
* @param createIfNone 当没有的时候,是否创建一个
|
||||
*/
|
||||
@action
|
||||
getProp(path: string, createIfNone = true): Prop | null {
|
||||
getProp(path: string, createIfNone = true): IProp | null {
|
||||
return this.query(path, createIfNone) || null;
|
||||
}
|
||||
|
||||
|
||||
@ -1,17 +1,20 @@
|
||||
import { obx, computed, makeObservable, action, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core';
|
||||
import { IDesigner } from '../designer';
|
||||
import { DocumentModel, IDocumentModel, isDocumentModel } from '../document';
|
||||
import { DocumentModel, isDocumentModel } from '../document';
|
||||
import type { IDocumentModel } from "../document";
|
||||
import {
|
||||
IPublicTypeProjectSchema,
|
||||
IPublicTypeRootSchema,
|
||||
IPublicTypeComponentsMap,
|
||||
IPublicEnumTransformStage,
|
||||
IBaseApiProject,
|
||||
} from '@alilc/lowcode-types';
|
||||
import type {
|
||||
IPublicTypeProjectSchema,
|
||||
IPublicTypeRootSchema,
|
||||
} from '@alilc/lowcode-types';
|
||||
import { isLowCodeComponentType, isProCodeComponentType } from '@alilc/lowcode-utils';
|
||||
import { ISimulatorHost } from '../simulator';
|
||||
|
||||
export interface IProject extends Omit< IBaseApiProject<
|
||||
export interface IProject extends Omit<IBaseApiProject<
|
||||
IDocumentModel
|
||||
>,
|
||||
'simulatorHost' |
|
||||
@ -146,7 +149,7 @@ export class Project implements IProject {
|
||||
return this.documents.reduce<IPublicTypeComponentsMap>((
|
||||
componentsMap: IPublicTypeComponentsMap,
|
||||
curDoc: IDocumentModel,
|
||||
): IPublicTypeComponentsMap => {
|
||||
): IPublicTypeComponentsMap => {
|
||||
const curComponentsMap = curDoc.getComponentsMap();
|
||||
if (Array.isArray(curComponentsMap)) {
|
||||
curComponentsMap.forEach((item) => {
|
||||
@ -178,8 +181,8 @@ export class Project implements IProject {
|
||||
* 获取项目整体 schema
|
||||
*/
|
||||
getSchema(
|
||||
stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Save,
|
||||
): IPublicTypeProjectSchema {
|
||||
stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Save,
|
||||
): IPublicTypeProjectSchema {
|
||||
return {
|
||||
...this.data,
|
||||
componentsMap: this.getComponentsMap(),
|
||||
|
||||
@ -65,8 +65,8 @@ describe('setting-field 测试', () => {
|
||||
|
||||
it('常规方法', () => {
|
||||
// 普通 field
|
||||
const settingEntry = mockNode.settingEntry as SettingTopEntry;
|
||||
const field = settingEntry.get('behavior') as SettingField;
|
||||
const settingEntry = mockNode.settingEntry;
|
||||
const field = settingEntry.get('behavior');
|
||||
expect(field.title).toBe('默认状态');
|
||||
expect(field.expanded).toBeTruthy();
|
||||
field.setExpanded(false);
|
||||
@ -103,24 +103,24 @@ describe('setting-field 测试', () => {
|
||||
expect(nonExistingField.setter).toBeNull();
|
||||
|
||||
// group 类型的 field
|
||||
const groupField = settingEntry.get('groupkgzzeo41') as SettingField;
|
||||
const groupField = settingEntry.get('groupkgzzeo41');
|
||||
expect(groupField.items).toEqual([]);
|
||||
|
||||
// 有子节点的 field
|
||||
const objField = settingEntry.get('obj') as SettingField;
|
||||
const objField = settingEntry.get('obj');
|
||||
expect(objField.items).toHaveLength(3);
|
||||
expect(objField.getItems()).toHaveLength(3);
|
||||
expect(objField.getItems(x => x.name === 'a')).toHaveLength(1);
|
||||
objField.purge();
|
||||
expect(objField.items).toHaveLength(0);
|
||||
const objAField = settingEntry.get('obj.a') as SettingField;
|
||||
const objAField = settingEntry.get('obj.a');
|
||||
expect(objAField.setter).toBe('StringSetter');
|
||||
});
|
||||
|
||||
it('setValue / getValue / setHotValue / getHotValue', () => {
|
||||
// 获取已有的 prop
|
||||
const settingEntry = mockNode.settingEntry as SettingTopEntry;
|
||||
const field = settingEntry.get('behavior') as SettingField;
|
||||
const field = settingEntry.get('behavior');
|
||||
|
||||
// 会读取 extraProps.defaultValue
|
||||
expect(field.getHotValue()).toBe('NORMAL');
|
||||
@ -140,11 +140,37 @@ describe('setting-field 测试', () => {
|
||||
|
||||
// dirty fix list setter
|
||||
field.setHotValue([{ __sid__: 1 }]);
|
||||
|
||||
// 数组的 field
|
||||
const arrField = settingEntry.get('arr');
|
||||
const subArrField = arrField.createField({
|
||||
name: 0,
|
||||
title: 'sub',
|
||||
});
|
||||
const subArrField02 = arrField.createField({
|
||||
name: 1,
|
||||
title: 'sub',
|
||||
});
|
||||
const subArrField03 = arrField.createField({
|
||||
name: '2',
|
||||
title: 'sub',
|
||||
});
|
||||
subArrField.setValue({name: '1'});
|
||||
expect(subArrField.path).toEqual(['arr', 0]);
|
||||
expect(subArrField02.path).toEqual(['arr', 1]);
|
||||
subArrField02.setValue({name: '2'});
|
||||
expect(subArrField.getValue()).toEqual({name: '1'});
|
||||
expect(arrField.getHotValue()).toEqual([{name: '1'}, {name: '2'}]);
|
||||
subArrField.clearValue();
|
||||
expect(subArrField.getValue()).toBeUndefined();
|
||||
expect(arrField.getHotValue()).toEqual([undefined, {name: '2'}]);
|
||||
subArrField03.setValue({name: '3'});
|
||||
expect(arrField.getHotValue()).toEqual([undefined, {name: '2'}, {name: '3'}]);
|
||||
});
|
||||
|
||||
it('onEffect', async () => {
|
||||
const settingEntry = mockNode.settingEntry as SettingTopEntry;
|
||||
const field = settingEntry.get('behavior') as SettingField;
|
||||
const field = settingEntry.get('behavior');
|
||||
|
||||
const mockFn = jest.fn();
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-editor-core",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"description": "Core Api for Ali lowCode engine",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
@ -14,8 +14,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@alifd/next": "^1.19.16",
|
||||
"@alilc/lowcode-types": "1.1.4",
|
||||
"@alilc/lowcode-utils": "1.1.4",
|
||||
"@alilc/lowcode-types": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-utils": "1.1.5-beta.2",
|
||||
"classnames": "^2.2.6",
|
||||
"debug": "^4.1.1",
|
||||
"intl-messageformat": "^9.3.1",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-editor-skeleton",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"description": "alibaba lowcode editor skeleton",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
@ -18,10 +18,10 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"@alifd/next": "^1.20.12",
|
||||
"@alilc/lowcode-designer": "1.1.4",
|
||||
"@alilc/lowcode-editor-core": "1.1.4",
|
||||
"@alilc/lowcode-types": "1.1.4",
|
||||
"@alilc/lowcode-utils": "1.1.4",
|
||||
"@alilc/lowcode-designer": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-editor-core": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-types": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-utils": "1.1.5-beta.2",
|
||||
"classnames": "^2.2.6",
|
||||
"react": "^16.8.1",
|
||||
"react-dom": "^16.8.1"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-engine",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"description": "An enterprise-class low-code technology stack with scale-out design / 一套面向扩展设计的企业级低代码技术体系",
|
||||
"main": "lib/engine-core.js",
|
||||
"module": "es/engine-core.js",
|
||||
@ -19,15 +19,15 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@alifd/next": "^1.19.12",
|
||||
"@alilc/lowcode-designer": "1.1.4",
|
||||
"@alilc/lowcode-editor-core": "1.1.4",
|
||||
"@alilc/lowcode-editor-skeleton": "1.1.4",
|
||||
"@alilc/lowcode-designer": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-editor-core": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-editor-skeleton": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-engine-ext": "^1.0.0",
|
||||
"@alilc/lowcode-plugin-designer": "1.1.4",
|
||||
"@alilc/lowcode-plugin-outline-pane": "1.1.4",
|
||||
"@alilc/lowcode-shell": "1.1.4",
|
||||
"@alilc/lowcode-utils": "1.1.4",
|
||||
"@alilc/lowcode-workspace": "1.1.4",
|
||||
"@alilc/lowcode-plugin-designer": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-plugin-outline-pane": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-shell": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-utils": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-workspace": "1.1.5-beta.2",
|
||||
"react": "^16.8.1",
|
||||
"react-dom": "^16.8.1"
|
||||
},
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-ignitor",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"description": "点火器,bootstrap lce project",
|
||||
"main": "lib/index.js",
|
||||
"private": true,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-plugin-designer",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"description": "alibaba lowcode editor designer plugin",
|
||||
"files": [
|
||||
"es",
|
||||
@ -18,9 +18,9 @@
|
||||
],
|
||||
"author": "xiayang.xy",
|
||||
"dependencies": {
|
||||
"@alilc/lowcode-designer": "1.1.4",
|
||||
"@alilc/lowcode-editor-core": "1.1.4",
|
||||
"@alilc/lowcode-utils": "1.1.4",
|
||||
"@alilc/lowcode-designer": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-editor-core": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-utils": "1.1.5-beta.2",
|
||||
"react": "^16.8.1",
|
||||
"react-dom": "^16.8.1"
|
||||
},
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-plugin-outline-pane",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"description": "Outline pane for Ali lowCode engine",
|
||||
"files": [
|
||||
"es",
|
||||
@ -13,10 +13,10 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@alifd/next": "^1.19.16",
|
||||
"@alilc/lowcode-designer": "1.1.4",
|
||||
"@alilc/lowcode-editor-core": "1.1.4",
|
||||
"@alilc/lowcode-types": "1.1.4",
|
||||
"@alilc/lowcode-utils": "1.1.4",
|
||||
"@alilc/lowcode-designer": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-editor-core": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-types": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-utils": "1.1.5-beta.2",
|
||||
"classnames": "^2.2.6",
|
||||
"react": "^16",
|
||||
"react-dom": "^16.7.0",
|
||||
|
||||
@ -41,43 +41,22 @@ export default class TreeNode {
|
||||
readonly pluginContext: IPublicModelPluginContext;
|
||||
event = new EventEmitter();
|
||||
|
||||
onFilterResultChanged(fn: () => void): IPublicTypeDisposable {
|
||||
this.event.on(EVENT_NAMES.filterResultChanged, fn);
|
||||
return () => {
|
||||
this.event.off(EVENT_NAMES.filterResultChanged, fn);
|
||||
}
|
||||
};
|
||||
onExpandedChanged(fn: (expanded: boolean) => void): IPublicTypeDisposable {
|
||||
this.event.on(EVENT_NAMES.expandedChanged, fn);
|
||||
return () => {
|
||||
this.event.off(EVENT_NAMES.expandedChanged, fn);
|
||||
}
|
||||
};
|
||||
onHiddenChanged(fn: (hidden: boolean) => void): IPublicTypeDisposable {
|
||||
this.event.on(EVENT_NAMES.hiddenChanged, fn);
|
||||
return () => {
|
||||
this.event.off(EVENT_NAMES.hiddenChanged, fn);
|
||||
}
|
||||
};
|
||||
onLockedChanged(fn: (locked: boolean) => void): IPublicTypeDisposable {
|
||||
this.event.on(EVENT_NAMES.lockedChanged, fn);
|
||||
return () => {
|
||||
this.event.off(EVENT_NAMES.lockedChanged, fn);
|
||||
}
|
||||
};
|
||||
onTitleLabelChanged(fn: (treeNode: TreeNode) => void): IPublicTypeDisposable {
|
||||
this.event.on(EVENT_NAMES.titleLabelChanged, fn);
|
||||
private _node: IPublicModelNode;
|
||||
|
||||
return () => {
|
||||
this.event.off(EVENT_NAMES.titleLabelChanged, fn);
|
||||
}
|
||||
readonly tree: Tree;
|
||||
|
||||
private _filterResult: FilterResult = {
|
||||
filterWorking: false,
|
||||
matchChild: false,
|
||||
matchSelf: false,
|
||||
keywords: '',
|
||||
};
|
||||
onExpandableChanged(fn: (expandable: boolean) => void): IPublicTypeDisposable {
|
||||
this.event.on(EVENT_NAMES.expandableChanged, fn);
|
||||
return () => {
|
||||
this.event.off(EVENT_NAMES.expandableChanged, fn);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认为折叠状态
|
||||
* 在初始化根节点时,设置为展开状态
|
||||
*/
|
||||
private _expanded = false;
|
||||
|
||||
get id(): string {
|
||||
return this.node.id;
|
||||
@ -91,11 +70,8 @@ export default class TreeNode {
|
||||
return this.hasChildren() || this.hasSlots() || this.dropDetail?.index != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发 onExpandableChanged 回调
|
||||
*/
|
||||
notifyExpandableChanged(): void {
|
||||
this.event.emit(EVENT_NAMES.expandableChanged, this.expandable);
|
||||
get expanded(): boolean {
|
||||
return this.isRoot(true) || (this.expandable && this._expanded);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,47 +86,6 @@ export default class TreeNode {
|
||||
return this.node.zLevel;
|
||||
}
|
||||
|
||||
isRoot(includeOriginalRoot = false) {
|
||||
const rootNode = this.pluginContext.project.getCurrentDocument()?.root;
|
||||
return this.tree.root === this || (includeOriginalRoot && rootNode === this.node);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是响应投放区
|
||||
*/
|
||||
isResponseDropping(): boolean {
|
||||
const loc = this.pluginContext.project.getCurrentDocument()?.dropLocation;
|
||||
if (!loc) {
|
||||
return false;
|
||||
}
|
||||
return loc.target?.id === this.id;
|
||||
}
|
||||
|
||||
isFocusingNode(): boolean {
|
||||
const loc = this.pluginContext.project.getCurrentDocument()?.dropLocation;
|
||||
if (!loc) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
isLocationChildrenDetail(loc.detail) && loc.detail.focus?.type === 'node' && loc.detail?.focus?.node.id === this.id
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认为折叠状态
|
||||
* 在初始化根节点时,设置为展开状态
|
||||
*/
|
||||
private _expanded = false;
|
||||
|
||||
get expanded(): boolean {
|
||||
return this.isRoot(true) || (this.expandable && this._expanded);
|
||||
}
|
||||
|
||||
setExpanded(value: boolean) {
|
||||
this._expanded = value;
|
||||
this.event.emit(EVENT_NAMES.expandedChanged, value);
|
||||
}
|
||||
|
||||
get detecting() {
|
||||
const doc = this.pluginContext.project.currentDocument;
|
||||
return !!(doc?.isDetectingNode(this.node));
|
||||
@ -164,23 +99,10 @@ export default class TreeNode {
|
||||
return !cv;
|
||||
}
|
||||
|
||||
setHidden(flag: boolean) {
|
||||
if (this.node.conditionGroup) {
|
||||
return;
|
||||
}
|
||||
this.node.visible = !flag;
|
||||
this.event.emit(EVENT_NAMES.hiddenChanged, flag);
|
||||
}
|
||||
|
||||
get locked(): boolean {
|
||||
return this.node.isLocked;
|
||||
}
|
||||
|
||||
setLocked(flag: boolean) {
|
||||
this.node.lock(flag);
|
||||
this.event.emit(EVENT_NAMES.lockedChanged, flag);
|
||||
}
|
||||
|
||||
get selected(): boolean {
|
||||
// TODO: check is dragging
|
||||
const selection = this.pluginContext.project.getCurrentDocument()?.selection;
|
||||
@ -213,19 +135,6 @@ export default class TreeNode {
|
||||
return this.node.componentName;
|
||||
}
|
||||
|
||||
setTitleLabel(label: string) {
|
||||
const origLabel = this.titleLabel;
|
||||
if (label === origLabel) {
|
||||
return;
|
||||
}
|
||||
if (label === '') {
|
||||
this.node.getExtraProp('title', false)?.remove();
|
||||
} else {
|
||||
this.node.getExtraProp('title', true)?.setValue(label);
|
||||
}
|
||||
this.event.emit(EVENT_NAMES.titleLabelChanged, this);
|
||||
}
|
||||
|
||||
get icon() {
|
||||
return this.node.componentMeta?.icon;
|
||||
}
|
||||
@ -247,6 +156,123 @@ export default class TreeNode {
|
||||
return this.node.children?.map((node) => this.tree.getTreeNode(node)) || null;
|
||||
}
|
||||
|
||||
get node(): IPublicModelNode {
|
||||
return this._node;
|
||||
}
|
||||
|
||||
constructor(tree: Tree, node: IPublicModelNode, pluginContext: IPublicModelPluginContext) {
|
||||
this.tree = tree;
|
||||
this.pluginContext = pluginContext;
|
||||
this._node = node;
|
||||
}
|
||||
|
||||
setLocked(flag: boolean) {
|
||||
this.node.lock(flag);
|
||||
this.event.emit(EVENT_NAMES.lockedChanged, flag);
|
||||
}
|
||||
|
||||
onFilterResultChanged(fn: () => void): IPublicTypeDisposable {
|
||||
this.event.on(EVENT_NAMES.filterResultChanged, fn);
|
||||
return () => {
|
||||
this.event.off(EVENT_NAMES.filterResultChanged, fn);
|
||||
};
|
||||
}
|
||||
onExpandedChanged(fn: (expanded: boolean) => void): IPublicTypeDisposable {
|
||||
this.event.on(EVENT_NAMES.expandedChanged, fn);
|
||||
return () => {
|
||||
this.event.off(EVENT_NAMES.expandedChanged, fn);
|
||||
};
|
||||
}
|
||||
onHiddenChanged(fn: (hidden: boolean) => void): IPublicTypeDisposable {
|
||||
this.event.on(EVENT_NAMES.hiddenChanged, fn);
|
||||
return () => {
|
||||
this.event.off(EVENT_NAMES.hiddenChanged, fn);
|
||||
};
|
||||
}
|
||||
onLockedChanged(fn: (locked: boolean) => void): IPublicTypeDisposable {
|
||||
this.event.on(EVENT_NAMES.lockedChanged, fn);
|
||||
return () => {
|
||||
this.event.off(EVENT_NAMES.lockedChanged, fn);
|
||||
};
|
||||
}
|
||||
|
||||
onTitleLabelChanged(fn: (treeNode: TreeNode) => void): IPublicTypeDisposable {
|
||||
this.event.on(EVENT_NAMES.titleLabelChanged, fn);
|
||||
|
||||
return () => {
|
||||
this.event.off(EVENT_NAMES.titleLabelChanged, fn);
|
||||
};
|
||||
}
|
||||
onExpandableChanged(fn: (expandable: boolean) => void): IPublicTypeDisposable {
|
||||
this.event.on(EVENT_NAMES.expandableChanged, fn);
|
||||
return () => {
|
||||
this.event.off(EVENT_NAMES.expandableChanged, fn);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发 onExpandableChanged 回调
|
||||
*/
|
||||
notifyExpandableChanged(): void {
|
||||
this.event.emit(EVENT_NAMES.expandableChanged, this.expandable);
|
||||
}
|
||||
|
||||
notifyTitleLabelChanged(): void {
|
||||
this.event.emit(EVENT_NAMES.titleLabelChanged, this.title);
|
||||
}
|
||||
|
||||
setHidden(flag: boolean) {
|
||||
if (this.node.conditionGroup) {
|
||||
return;
|
||||
}
|
||||
this.node.visible = !flag;
|
||||
this.event.emit(EVENT_NAMES.hiddenChanged, flag);
|
||||
}
|
||||
|
||||
isFocusingNode(): boolean {
|
||||
const loc = this.pluginContext.project.getCurrentDocument()?.dropLocation;
|
||||
if (!loc) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
isLocationChildrenDetail(loc.detail) && loc.detail.focus?.type === 'node' && loc.detail?.focus?.node.id === this.id
|
||||
);
|
||||
}
|
||||
|
||||
setExpanded(value: boolean) {
|
||||
this._expanded = value;
|
||||
this.event.emit(EVENT_NAMES.expandedChanged, value);
|
||||
}
|
||||
|
||||
isRoot(includeOriginalRoot = false) {
|
||||
const rootNode = this.pluginContext.project.getCurrentDocument()?.root;
|
||||
return this.tree.root === this || (includeOriginalRoot && rootNode === this.node);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是响应投放区
|
||||
*/
|
||||
isResponseDropping(): boolean {
|
||||
const loc = this.pluginContext.project.getCurrentDocument()?.dropLocation;
|
||||
if (!loc) {
|
||||
return false;
|
||||
}
|
||||
return loc.target?.id === this.id;
|
||||
}
|
||||
|
||||
setTitleLabel(label: string) {
|
||||
const origLabel = this.titleLabel;
|
||||
if (label === origLabel) {
|
||||
return;
|
||||
}
|
||||
if (label === '') {
|
||||
this.node.getExtraProp('title', false)?.remove();
|
||||
} else {
|
||||
this.node.getExtraProp('title', true)?.setValue(label);
|
||||
}
|
||||
this.event.emit(EVENT_NAMES.titleLabelChanged, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是容器,允许子节点拖入
|
||||
*/
|
||||
@ -298,39 +324,18 @@ export default class TreeNode {
|
||||
}
|
||||
}
|
||||
|
||||
private _node: IPublicModelNode;
|
||||
|
||||
get node(): IPublicModelNode {
|
||||
return this._node;
|
||||
}
|
||||
|
||||
readonly tree: Tree;
|
||||
|
||||
constructor(tree: Tree, node: IPublicModelNode, pluginContext: IPublicModelPluginContext) {
|
||||
this.tree = tree;
|
||||
this.pluginContext = pluginContext;
|
||||
this._node = node;
|
||||
}
|
||||
|
||||
setNode(node: IPublicModelNode) {
|
||||
if (this._node !== node) {
|
||||
this._node = node;
|
||||
}
|
||||
}
|
||||
|
||||
private _filterResult: FilterResult = {
|
||||
filterWorking: false,
|
||||
matchChild: false,
|
||||
matchSelf: false,
|
||||
keywords: '',
|
||||
};
|
||||
|
||||
get filterReult(): FilterResult {
|
||||
return this._filterResult;
|
||||
}
|
||||
|
||||
setFilterReult(val: FilterResult) {
|
||||
this._filterResult = val;
|
||||
this.event.emit(EVENT_NAMES.filterResultChanged)
|
||||
this.event.emit(EVENT_NAMES.filterResultChanged);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import TreeNode from './tree-node';
|
||||
import { IPublicModelNode, IPublicModelPluginContext } from '@alilc/lowcode-types';
|
||||
import { IPublicModelNode, IPublicModelPluginContext, IPublicTypePropChangeOptions } from '@alilc/lowcode-types';
|
||||
|
||||
export class Tree {
|
||||
private treeNodesMap = new Map<string, TreeNode>();
|
||||
@ -25,6 +25,14 @@ export class Tree {
|
||||
const treeNode = this.getTreeNodeById(node.id);
|
||||
treeNode?.notifyExpandableChanged();
|
||||
});
|
||||
|
||||
doc?.onChangeNodeProp((info: IPublicTypePropChangeOptions) => {
|
||||
const { node, key } = info;
|
||||
if (key === '___title___') {
|
||||
const treeNode = this.getTreeNodeById(node.id);
|
||||
treeNode?.notifyTitleLabelChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setNodeSelected(nodeId: string): void {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-rax-renderer",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"description": "Rax renderer for Ali lowCode engine",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
@ -30,8 +30,8 @@
|
||||
"build": "build-scripts build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@alilc/lowcode-renderer-core": "1.1.4",
|
||||
"@alilc/lowcode-utils": "1.1.4",
|
||||
"@alilc/lowcode-renderer-core": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-utils": "1.1.5-beta.2",
|
||||
"rax-find-dom-node": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-rax-simulator-renderer",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"description": "rax simulator renderer for alibaba lowcode designer",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
@ -13,10 +13,10 @@
|
||||
"build:umd": "build-scripts build --config build.umd.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@alilc/lowcode-designer": "1.1.4",
|
||||
"@alilc/lowcode-rax-renderer": "1.1.4",
|
||||
"@alilc/lowcode-types": "1.1.4",
|
||||
"@alilc/lowcode-utils": "1.1.4",
|
||||
"@alilc/lowcode-designer": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-rax-renderer": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-types": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-utils": "1.1.5-beta.2",
|
||||
"classnames": "^2.2.6",
|
||||
"driver-universal": "^3.1.3",
|
||||
"history": "^5.0.0",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-react-renderer",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"description": "react renderer for ali lowcode engine",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
@ -22,7 +22,7 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"@alifd/next": "^1.21.16",
|
||||
"@alilc/lowcode-renderer-core": "1.1.4"
|
||||
"@alilc/lowcode-renderer-core": "1.1.5-beta.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@alib/build-scripts": "^0.1.18",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-react-simulator-renderer",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"description": "react simulator renderer for alibaba lowcode designer",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
@ -17,10 +17,10 @@
|
||||
"test:cov": "build-scripts test --config build.test.json --jest-coverage"
|
||||
},
|
||||
"dependencies": {
|
||||
"@alilc/lowcode-designer": "1.1.4",
|
||||
"@alilc/lowcode-react-renderer": "1.1.4",
|
||||
"@alilc/lowcode-types": "1.1.4",
|
||||
"@alilc/lowcode-utils": "1.1.4",
|
||||
"@alilc/lowcode-designer": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-react-renderer": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-types": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-utils": "1.1.5-beta.2",
|
||||
"classnames": "^2.2.6",
|
||||
"mobx": "^6.3.0",
|
||||
"mobx-react": "^7.2.0",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-renderer-core",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"description": "renderer core",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
@ -16,8 +16,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@alilc/lowcode-datasource-engine": "^1.0.0",
|
||||
"@alilc/lowcode-types": "1.1.4",
|
||||
"@alilc/lowcode-utils": "1.1.4",
|
||||
"@alilc/lowcode-types": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-utils": "1.1.5-beta.2",
|
||||
"classnames": "^2.2.6",
|
||||
"debug": "^4.1.1",
|
||||
"fetch-jsonp": "^1.1.3",
|
||||
@ -32,7 +32,7 @@
|
||||
"devDependencies": {
|
||||
"@alib/build-scripts": "^0.1.18",
|
||||
"@alifd/next": "^1.26.0",
|
||||
"@alilc/lowcode-designer": "1.1.4",
|
||||
"@alilc/lowcode-designer": "1.1.5-beta.2",
|
||||
"@babel/plugin-transform-typescript": "^7.16.8",
|
||||
"@testing-library/react": "^11.2.2",
|
||||
"@types/classnames": "^2.2.11",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-shell",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"description": "Shell Layer for AliLowCodeEngine",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
@ -15,12 +15,12 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@alilc/lowcode-designer": "1.1.4",
|
||||
"@alilc/lowcode-editor-core": "1.1.4",
|
||||
"@alilc/lowcode-editor-skeleton": "1.1.4",
|
||||
"@alilc/lowcode-types": "1.1.4",
|
||||
"@alilc/lowcode-utils": "1.1.4",
|
||||
"@alilc/lowcode-workspace": "1.1.4",
|
||||
"@alilc/lowcode-designer": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-editor-core": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-editor-skeleton": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-types": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-utils": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-workspace": "1.1.5-beta.2",
|
||||
"classnames": "^2.2.6",
|
||||
"enzyme": "^3.11.0",
|
||||
"enzyme-adapter-react-16": "^1.15.5",
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { IExclusiveGroup } from '@alilc/lowcode-designer';
|
||||
import type { IExclusiveGroup } from '@alilc/lowcode-designer';
|
||||
import { IPublicModelExclusiveGroup, IPublicModelNode } from '@alilc/lowcode-types';
|
||||
import { conditionGroupSymbol, nodeSymbol } from '../symbols';
|
||||
import { Node } from './node';
|
||||
@ -39,4 +39,4 @@ export class ConditionGroup implements IPublicModelExclusiveGroup {
|
||||
shellConditionGroup[conditionGroupSymbol] = shellConditionGroup;
|
||||
return shellConditionGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { IDocumentModel as InnerDocumentModel, IHistory as InnerHistory } from '@alilc/lowcode-designer';
|
||||
import type { IDocumentModel as InnerDocumentModel, IHistory as InnerHistory } from '@alilc/lowcode-designer';
|
||||
import { historySymbol, documentSymbol } from '../symbols';
|
||||
import { IPublicModelHistory, IPublicTypeDisposable } from '@alilc/lowcode-types';
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-types",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"description": "Types for Ali lowCode engine",
|
||||
"files": [
|
||||
"es",
|
||||
|
||||
@ -108,7 +108,7 @@ export interface IPublicModelDocumentModel<
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
createNode(data: IPublicTypeNodeSchema): Node | null;
|
||||
createNode<T = Node>(data: IPublicTypeNodeSchema): T | null;
|
||||
|
||||
/**
|
||||
* 移除指定节点/节点id
|
||||
|
||||
@ -299,7 +299,7 @@ export interface IBaseModelNode<
|
||||
* @param path 属性路径,支持 a / a.b / a.0 等格式
|
||||
* @param createIfNone 如果不存在,是否新建,默认为 true
|
||||
*/
|
||||
getProp(path: string, createIfNone?: boolean): Prop | null;
|
||||
getProp(path: string | number, createIfNone?: boolean): Prop | null;
|
||||
|
||||
/**
|
||||
* 获取指定 path 的属性模型实例值
|
||||
@ -336,7 +336,7 @@ export interface IBaseModelNode<
|
||||
* @param path 属性路径,支持 a / a.b / a.0 等格式
|
||||
* @param value 值
|
||||
*/
|
||||
setPropValue(path: string, value: IPublicTypeCompositeValue): void;
|
||||
setPropValue(path: string | number, value: IPublicTypeCompositeValue): void;
|
||||
|
||||
/**
|
||||
* 设置指定 path 的属性模型实例值
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { IPublicTypeNodeData } from './node-data';
|
||||
import { IPublicTypeNodeSchema } from './node-schema';
|
||||
|
||||
/**
|
||||
@ -13,5 +14,5 @@ export interface IPublicTypeSlotSchema extends IPublicTypeNodeSchema {
|
||||
slotName?: string;
|
||||
slotParams?: string[];
|
||||
};
|
||||
children?: IPublicTypeNodeSchema[];
|
||||
children?: IPublicTypeNodeData[] | IPublicTypeNodeData;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-utils",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"description": "Utils for Ali lowCode engine",
|
||||
"files": [
|
||||
"lib",
|
||||
@ -14,7 +14,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@alifd/next": "^1.19.16",
|
||||
"@alilc/lowcode-types": "1.1.4",
|
||||
"@alilc/lowcode-types": "1.1.5-beta.2",
|
||||
"lodash": "^4.17.21",
|
||||
"mobx": "^6.3.0",
|
||||
"react": "^16"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-workspace",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-beta.2",
|
||||
"description": "Shell Layer for AliLowCodeEngine",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
@ -15,11 +15,11 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@alilc/lowcode-designer": "1.1.4",
|
||||
"@alilc/lowcode-editor-core": "1.1.4",
|
||||
"@alilc/lowcode-editor-skeleton": "1.1.4",
|
||||
"@alilc/lowcode-types": "1.1.4",
|
||||
"@alilc/lowcode-utils": "1.1.4",
|
||||
"@alilc/lowcode-designer": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-editor-core": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-editor-skeleton": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-types": "1.1.5-beta.2",
|
||||
"@alilc/lowcode-utils": "1.1.5-beta.2",
|
||||
"classnames": "^2.2.6",
|
||||
"enzyme": "^3.11.0",
|
||||
"enzyme-adapter-react-16": "^1.15.5",
|
||||
|
||||
@ -2,7 +2,8 @@ import { IDesigner, ILowCodePluginManager, LowCodePluginManager } from '@alilc/l
|
||||
import { createModuleEventBus, Editor, IEventBus, makeObservable, obx } from '@alilc/lowcode-editor-core';
|
||||
import { IPublicApiPlugins, IPublicApiWorkspace, IPublicResourceList, IPublicTypeResourceType, IShellModelFactory } from '@alilc/lowcode-types';
|
||||
import { BasicContext } from './context/base-context';
|
||||
import { EditorWindow, IEditorWindow } from './window';
|
||||
import { EditorWindow } from './window';
|
||||
import type { IEditorWindow } from './window';
|
||||
import { IResource, Resource } from './resource';
|
||||
import { IResourceType, ResourceType } from './resource-type';
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user