Compare commits

...

7 Commits

Author SHA1 Message Date
JackLian
568302820c chore(release): publish 1.1.5-beta.2 2023-03-24 16:34:37 +08:00
liujuping
4111f6eecb fix: fix the problem that the props value appears when the name is 0 2023-03-24 16:29:40 +08:00
liujuping
a05a36b06c feat: update props ts defined 2023-03-24 16:29:40 +08:00
liujuping
dfa1fcda12 fix: fix cant change the panel tree item title with prop api 2023-03-24 16:29:40 +08:00
Justin-lu
cf993af632 fix: ts interface error 2023-03-24 16:29:39 +08:00
JackLian
0c92794ac5 chore(docs): publish 1.0.22 2023-03-24 16:29:39 +08:00
JackLian
237b1bed31 chore(release): publish 1.1.5-beta.0 2023-03-24 08:36:56 +08:00
39 changed files with 359 additions and 295 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-engine-docs", "name": "@alilc/lowcode-engine-docs",
"version": "1.0.21", "version": "1.0.22",
"description": "低代码引擎版本化文档", "description": "低代码引擎版本化文档",
"license": "MIT", "license": "MIT",
"files": [ "files": [

View File

@ -1,6 +1,6 @@
{ {
"lerna": "4.0.0", "lerna": "4.0.0",
"version": "1.1.4", "version": "1.1.5-beta.2",
"npmClient": "yarn", "npmClient": "yarn",
"useWorkspaces": true, "useWorkspaces": true,
"packages": [ "packages": [

View File

@ -16,6 +16,7 @@ const jestConfig = {
// testMatch: ['**/prop.test.ts'], // testMatch: ['**/prop.test.ts'],
// testMatch: ['(/tests?/.*(test))\\.[jt]s$'], // testMatch: ['(/tests?/.*(test))\\.[jt]s$'],
// testMatch: ['**/document/node/node.add.test.ts'], // testMatch: ['**/document/node/node.add.test.ts'],
// testMatch: ['**/setting-field.test.ts'],
transformIgnorePatterns: [ transformIgnorePatterns: [
`/node_modules/(?!${esModules})/`, `/node_modules/(?!${esModules})/`,
], ],

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-designer", "name": "@alilc/lowcode-designer",
"version": "1.1.4", "version": "1.1.5-beta.2",
"description": "Designer for Ali LowCode Engine", "description": "Designer for Ali LowCode Engine",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -15,9 +15,9 @@
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@alilc/lowcode-editor-core": "1.1.4", "@alilc/lowcode-editor-core": "1.1.5-beta.2",
"@alilc/lowcode-types": "1.1.4", "@alilc/lowcode-types": "1.1.5-beta.2",
"@alilc/lowcode-utils": "1.1.4", "@alilc/lowcode-utils": "1.1.5-beta.2",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"react": "^16", "react": "^16",
"react-dom": "^16.7.0", "react-dom": "^16.7.0",

View File

@ -1,10 +1,10 @@
import { makeObservable, obx, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core'; import { makeObservable, obx, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core';
import { IPublicModelDetecting } from '@alilc/lowcode-types'; import { IPublicModelDetecting } from '@alilc/lowcode-types';
import { IDocumentModel } from '../document/document-model'; import type { IDocumentModel } from '../document/document-model';
import { INode } from '../document/node/node'; import type { INode } from '../document/node/node';
const DETECTING_CHANGE_EVENT = 'detectingChange'; const DETECTING_CHANGE_EVENT = 'detectingChange';
export interface IDetecting extends Omit< IPublicModelDetecting<INode>, export interface IDetecting extends Omit<IPublicModelDetecting<INode>,
'capture' | 'capture' |
'release' | 'release' |
'leave' 'leave'

View File

@ -1,4 +1,4 @@
import { IDocumentModel, INode } from '../document'; import type { IDocumentModel, INode } from '../document';
import { ILocateEvent } from './dragon'; import { ILocateEvent } from './dragon';
import { import {
IPublicModelDropLocation, IPublicModelDropLocation,
@ -98,7 +98,7 @@ function isDocument(elem: any): elem is Document {
export function getWindow(elem: Element | Document): Window { export function getWindow(elem: Element | Document): Window {
return (isDocument(elem) ? elem : elem.ownerDocument!).defaultView!; 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; readonly source: string;

View File

@ -6,11 +6,13 @@ import {
IPublicTypeFieldExtraProps, IPublicTypeFieldExtraProps,
IPublicTypeFieldConfig, IPublicTypeFieldConfig,
IPublicTypeCustomView, IPublicTypeCustomView,
IPublicTypeSetValueOptions,
IPublicTypeDisposable, IPublicTypeDisposable,
IPublicModelSettingField, IPublicModelSettingField,
IBaseModelSettingField, IBaseModelSettingField,
} from '@alilc/lowcode-types'; } from '@alilc/lowcode-types';
import type {
IPublicTypeSetValueOptions,
} from '@alilc/lowcode-types';
import { Transducer } from './utils'; import { Transducer } from './utils';
import { ISettingPropEntry, SettingPropEntry } from './setting-prop-entry'; import { ISettingPropEntry, SettingPropEntry } from './setting-prop-entry';
import { computed, obx, makeObservable, action, untracked, intl } from '@alilc/lowcode-editor-core'; 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< export interface ISettingField extends ISettingPropEntry, Omit<IBaseModelSettingField<
ISettingTopEntry, ISettingTopEntry,
ISettingField, ISettingField,
IComponentMeta, IComponentMeta,
INode INode
>, 'setValue' | 'key' | 'node'> { >, 'setValue' | 'key' | 'node'> {
get items(): Array<ISettingField | IPublicTypeCustomView>; get items(): Array<ISettingField | IPublicTypeCustomView>;

View File

@ -3,16 +3,16 @@ import { GlobalEvent, IPublicApiSetters, IPublicModelEditor, IPublicModelSetting
import { uniqueId, isJSExpression } from '@alilc/lowcode-utils'; import { uniqueId, isJSExpression } from '@alilc/lowcode-utils';
import { ISettingEntry } from './setting-entry-type'; import { ISettingEntry } from './setting-entry-type';
import { INode } from '../../document'; import { INode } from '../../document';
import { IComponentMeta } from '../../component-meta'; import type { IComponentMeta } from '../../component-meta';
import { IDesigner } from '../designer'; import { IDesigner } from '../designer';
import { ISettingTopEntry } from './setting-top-entry'; import { ISettingTopEntry } from './setting-top-entry';
import { ISettingField, isSettingField } from './setting-field'; import { ISettingField, isSettingField } from './setting-field';
export interface ISettingPropEntry extends ISettingEntry { export interface ISettingPropEntry extends ISettingEntry {
get props(): ISettingTopEntry;
readonly isGroup: boolean; readonly isGroup: boolean;
get props(): ISettingTopEntry;
get name(): string | number | undefined; get name(): string | number | undefined;
valueChange(options: IPublicTypeSetValueOptions): void; valueChange(options: IPublicTypeSetValueOptions): void;
@ -75,7 +75,7 @@ export class SettingPropEntry implements ISettingPropEntry {
@computed get path() { @computed get path() {
const path = this.parent.path.slice(); const path = this.parent.path.slice();
if (this.type === 'field' && this.name) { if (this.type === 'field' && this.name?.toString()) {
path.push(this.name); path.push(this.name);
} }
return path; return path;
@ -191,7 +191,7 @@ export class SettingPropEntry implements ISettingPropEntry {
*/ */
getValue(): any { getValue(): any {
let val: any; let val: any;
if (this.type === 'field' && this.name) { if (this.type === 'field' && this.name?.toString()) {
val = this.parent.getPropValue(this.name); val = this.parent.getPropValue(this.name);
} }
const { getValue } = this.extraProps; const { getValue } = this.extraProps;
@ -209,7 +209,7 @@ export class SettingPropEntry implements ISettingPropEntry {
setValue(val: any, isHotValue?: boolean, force?: boolean, extraOptions?: IPublicTypeSetValueOptions) { setValue(val: any, isHotValue?: boolean, force?: boolean, extraOptions?: IPublicTypeSetValueOptions) {
const oldValue = this.getValue(); const oldValue = this.getValue();
if (this.type === 'field') { 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; const { setValue } = this.extraProps;
@ -233,7 +233,7 @@ export class SettingPropEntry implements ISettingPropEntry {
*/ */
clearValue() { clearValue() {
if (this.type === 'field') { if (this.type === 'field') {
this.name && this.parent.clearPropValue(this.name); this.name?.toString() && this.parent.clearPropValue(this.name);
} }
const { setValue } = this.extraProps; const { setValue } = this.extraProps;
if (setValue) { if (setValue) {
@ -395,6 +395,6 @@ export class SettingPropEntry implements ISettingPropEntry {
} }
internalToShellField(): IPublicModelSettingField { internalToShellField(): IPublicModelSettingField {
return this.designer!.shellModelFactory.createSettingField(this);; return this.designer!.shellModelFactory.createSettingField(this);
} }
} }

View File

@ -4,7 +4,7 @@ import { computed, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor
import { ISettingEntry } from './setting-entry-type'; import { ISettingEntry } from './setting-entry-type';
import { ISettingField, SettingField } from './setting-field'; import { ISettingField, SettingField } from './setting-field';
import { INode } from '../../document'; import { INode } from '../../document';
import { IComponentMeta } from '../../component-meta'; import type { IComponentMeta } from '../../component-meta';
import { IDesigner } from '../designer'; import { IDesigner } from '../designer';
import { Setters } from '@alilc/lowcode-shell'; import { Setters } from '@alilc/lowcode-shell';

View File

@ -11,7 +11,6 @@ import {
import { import {
IPublicTypeNodeData, IPublicTypeNodeData,
IPublicTypeNodeSchema, IPublicTypeNodeSchema,
IPublicTypeRootSchema,
IPublicTypePageSchema, IPublicTypePageSchema,
IPublicTypeComponentsMap, IPublicTypeComponentsMap,
IPublicTypeDragNodeObject, IPublicTypeDragNodeObject,
@ -21,7 +20,10 @@ import {
IPublicTypeOnChangeOptions, IPublicTypeOnChangeOptions,
IPublicTypeDisposable, IPublicTypeDisposable,
} from '@alilc/lowcode-types'; } from '@alilc/lowcode-types';
import { import type {
IPublicTypeRootSchema,
} from '@alilc/lowcode-types';
import type {
IDropLocation, IDropLocation,
} from '@alilc/lowcode-designer'; } from '@alilc/lowcode-designer';
import { import {
@ -37,9 +39,10 @@ import {
} from '@alilc/lowcode-utils'; } from '@alilc/lowcode-utils';
import { IProject } from '../project'; import { IProject } from '../project';
import { ISimulatorHost } from '../simulator'; import { ISimulatorHost } from '../simulator';
import { IComponentMeta } from '../component-meta'; import type { IComponentMeta } from '../component-meta';
import { IDesigner, IHistory } from '../designer'; 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 { Selection, ISelection } from './selection';
import { History } from './history'; import { History } from './history';
import { IModalNodesManager, ModalNodesManager, Node } from './node'; import { IModalNodesManager, ModalNodesManager, Node } from './node';
@ -49,11 +52,11 @@ export type GetDataType<T, NodeType> = T extends undefined
? NodeType extends { ? NodeType extends {
schema: infer R; schema: infer R;
} }
? R ? R
: any : any
: T; : T;
export interface IDocumentModel extends Omit< IPublicModelDocumentModel< export interface IDocumentModel extends Omit<IPublicModelDocumentModel<
ISelection, ISelection,
IHistory, IHistory,
INode, INode,
@ -656,9 +659,9 @@ export class DocumentModel implements IDocumentModel {
} }
checkNesting( checkNesting(
dropTarget: INode, dropTarget: INode,
dragObject: IPublicTypeDragNodeObject | IPublicTypeNodeSchema | INode | IPublicTypeDragNodeDataObject, dragObject: IPublicTypeDragNodeObject | IPublicTypeNodeSchema | INode | IPublicTypeDragNodeDataObject,
): boolean { ): boolean {
let items: Array<INode | IPublicTypeNodeSchema>; let items: Array<INode | IPublicTypeNodeSchema>;
if (isDragNodeDataObject(dragObject)) { if (isDragNodeDataObject(dragObject)) {
items = Array.isArray(dragObject.data) ? dragObject.data : [dragObject.data]; items = Array.isArray(dragObject.data) ? dragObject.data : [dragObject.data];

View File

@ -1,7 +1,7 @@
import { obx, computed, makeObservable } from '@alilc/lowcode-editor-core'; import { obx, computed, makeObservable } from '@alilc/lowcode-editor-core';
import { uniqueId } from '@alilc/lowcode-utils'; import { uniqueId } from '@alilc/lowcode-utils';
import { IPublicTypeTitleContent, IPublicModelExclusiveGroup } from '@alilc/lowcode-types'; import { IPublicTypeTitleContent, IPublicModelExclusiveGroup } from '@alilc/lowcode-types';
import { INode } from './node'; import type { INode } from './node';
import { intl } from '../../locale'; import { intl } from '../../locale';
export interface IExclusiveGroup extends IPublicModelExclusiveGroup<INode> { export interface IExclusiveGroup extends IPublicModelExclusiveGroup<INode> {

View File

@ -21,11 +21,12 @@ import {
import { compatStage, isDOMText, isJSExpression, isNode, isNodeSchema } from '@alilc/lowcode-utils'; import { compatStage, isDOMText, isJSExpression, isNode, isNodeSchema } from '@alilc/lowcode-utils';
import { ISettingTopEntry } from '@alilc/lowcode-designer'; import { ISettingTopEntry } from '@alilc/lowcode-designer';
import { Props, getConvertedExtraKey, IProps } from './props/props'; 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 { NodeChildren, INodeChildren } from './node-children';
import { IProp, Prop } from './props/prop'; import { IProp, Prop } from './props/prop';
import { IComponentMeta } from '../../component-meta'; import type { IComponentMeta } from '../../component-meta';
import { ExclusiveGroup, IExclusiveGroup, isExclusiveGroup } from './exclusive-group'; import { ExclusiveGroup, isExclusiveGroup } from './exclusive-group';
import type { IExclusiveGroup } from './exclusive-group';
import { includeSlot, removeSlot } from '../../utils/slot'; import { includeSlot, removeSlot } from '../../utils/slot';
import { foreachReverse } from '../../utils/tree'; import { foreachReverse } from '../../utils/tree';
import { NodeRemoveOptions, EDITOR_EVENT } from '../../types'; import { NodeRemoveOptions, EDITOR_EVENT } from '../../types';
@ -154,7 +155,7 @@ export interface IBaseNode<Schema extends IPublicTypeNodeSchema = IPublicTypeNod
getChildren(): INodeChildren | null; getChildren(): INodeChildren | null;
clearPropValue(path: string): void; clearPropValue(path: string | number): void;
setProps(props?: IPublicTypePropsMap | IPublicTypePropsList | Props | null): void; setProps(props?: IPublicTypePropsMap | IPublicTypePropsList | Props | null): void;
@ -1095,7 +1096,7 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
condition(this) !== false : condition(this) !== false :
condition !== false; condition !== false;
}) })
.map((action: IPublicTypeComponentAction) => action.name) || []; .map((action: IPublicTypeComponentAction) => action.name) || [];
return availableActions.indexOf(actionName) >= 0; return availableActions.indexOf(actionName) >= 0;
} }

View File

@ -1,8 +1,10 @@
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 { 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 { uniqueId, isPlainObject, hasOwnProperty, compatStage, isJSExpression, isJSSlot, isNodeSchema } from '@alilc/lowcode-utils';
import { valueToSource } from './value-to-source'; 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 { ISlotNode, INode } from '../node';
// import { TransformStage } from '../transform-stage'; // import { TransformStage } from '../transform-stage';
@ -13,13 +15,14 @@ export type UNSET = typeof UNSET;
export interface IProp extends Omit<IPublicModelProp< export interface IProp extends Omit<IPublicModelProp<
INode INode
>, 'exportSchema' | 'node' > { >, 'exportSchema' | 'node'>, IPropParent {
key: string | number | undefined;
readonly props: IProps; readonly props: IProps;
readonly owner: INode; readonly owner: INode;
delete(prop: Prop): void; delete(prop: IProp): void;
export(stage: IPublicEnumTransformStage): IPublicTypeCompositeValue; export(stage: IPublicEnumTransformStage): IPublicTypeCompositeValue;
@ -35,7 +38,15 @@ export interface IProp extends Omit<IPublicModelProp<
isUnset(): boolean; 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'; export type ValueTypes = 'unset' | 'literal' | 'map' | 'list' | 'expression' | 'slot';
@ -125,15 +136,15 @@ export class Prop implements IProp, IPropParent {
this._code = code; this._code = code;
} }
private _slotNode?: INode; private _slotNode?: INode | null;
get slotNode(): INode | null { get slotNode(): INode | null {
return this._slotNode || 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 * _maps Prop
@ -141,15 +152,15 @@ export class Prop implements IProp, IPropParent {
* mobx reaction observer * mobx reaction observer
* reaction Prop(a) _value Prop(a) _value * 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 * items maps
*/ */
private get items(): Prop[] | null { private get items(): IProp[] | null {
if (this._items) return this._items; if (this._items) return this._items;
return runInAction(() => { return runInAction(() => {
let items: Prop[] | null = null; let items: IProp[] | null = null;
if (this._type === 'list') { if (this._type === 'list') {
const data = this._value; const data = this._value;
data.forEach((item: any, idx: number) => { data.forEach((item: any, idx: number) => {
@ -159,10 +170,10 @@ export class Prop implements IProp, IPropParent {
this._maps = null; this._maps = null;
} else if (this._type === 'map') { } else if (this._type === 'map') {
const data = this._value; const data = this._value;
const maps = new Map<string, Prop>(); const maps = new Map<string, IProp>();
const keys = Object.keys(data); const keys = Object.keys(data);
for (const key of keys) { for (const key of keys) {
let prop: Prop; let prop: IProp;
if (this._prevMaps?.has(key)) { if (this._prevMaps?.has(key)) {
prop = this._prevMaps.get(key)!; prop = this._prevMaps.get(key)!;
prop.setValue(data[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) { if (!this.items) {
return null; return null;
} }
@ -433,7 +444,7 @@ export class Prop implements IProp, IPropParent {
this._slotNode.import(slotSchema); this._slotNode.import(slotSchema);
} else { } else {
const { owner } = this.props; const { owner } = this.props;
this._slotNode = owner.document.createNode<ISlotNode>(slotSchema); this._slotNode = owner.document?.createNode<ISlotNode>(slotSchema);
if (this._slotNode) { if (this._slotNode) {
owner.addSlot(this._slotNode); owner.addSlot(this._slotNode);
this._slotNode.internalSetSlotFor(this); 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 * @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()) { if (!other || other.isUnset()) {
return this.isUnset() ? 0 : 2; return this.isUnset() ? 0 : 2;
} }
@ -488,7 +499,7 @@ export class Prop implements IProp, IPropParent {
* @param createIfNone * @param createIfNone
*/ */
@action @action
get(path: string | number, createIfNone = true): Prop | null { get(path: string | number, createIfNone = true): IProp | null {
const type = this._type; const type = this._type;
if (type !== 'map' && type !== 'list' && type !== 'unset' && !createIfNone) { if (type !== 'map' && type !== 'list' && type !== 'unset' && !createIfNone) {
return null; return null;
@ -547,7 +558,7 @@ export class Prop implements IProp, IPropParent {
* *
*/ */
@action @action
delete(prop: Prop): void { delete(prop: IProp): void {
/* istanbul ignore else */ /* istanbul ignore else */
if (this._items) { if (this._items) {
const i = this._items.indexOf(prop); const i = this._items.indexOf(prop);
@ -581,7 +592,7 @@ export class Prop implements IProp, IPropParent {
* @param force * @param force
*/ */
@action @action
add(value: IPublicTypeCompositeValue, force = false): Prop | null { add(value: IPublicTypeCompositeValue, force = false): IProp | null {
const type = this._type; const type = this._type;
if (type !== 'list' && type !== 'unset' && !force) { if (type !== 'list' && type !== 'unset' && !force) {
return null; 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; let index = 0;
const { items } = this; const { items } = this;
const length = items?.length || 0; const length = items?.length || 0;
@ -711,7 +722,7 @@ export class Prop implements IProp, IPropParent {
* *
*/ */
@action @action
forEach(fn: (item: Prop, key: number | string | undefined) => void): void { forEach(fn: (item: IProp, key: number | string | undefined) => void): void {
const { items } = this; const { items } = this;
if (!items) { if (!items) {
return; return;
@ -726,7 +737,7 @@ export class Prop implements IProp, IPropParent {
* *
*/ */
@action @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; const { items } = this;
if (!items) { if (!items) {
return null; return null;

View File

@ -1,7 +1,9 @@
import { computed, makeObservable, obx, action } from '@alilc/lowcode-editor-core'; 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 { 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 { INode } from '../node';
// import { TransformStage } from '../transform-stage'; // import { TransformStage } from '../transform-stage';
@ -26,23 +28,23 @@ export function getOriginalExtraKey(key: string): string {
export interface IPropParent { export interface IPropParent {
readonly props: Props; readonly props: IProps;
readonly owner: INode; readonly owner: INode;
get path(): string[]; 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 * props node
*/ */
getNode(): INode; getNode(): INode;
get(path: string, createIfNone?: boolean): Prop | null; get(path: string, createIfNone?: boolean): IProp | null;
export(stage?: IPublicEnumTransformStage): { export(stage?: IPublicEnumTransformStage): {
props?: IPublicTypePropsMap | IPublicTypePropsList; props?: IPublicTypePropsMap | IPublicTypePropsList;
@ -53,7 +55,7 @@ export interface IProps extends Omit<IBaseModelProps<IProp>, | 'getExtraProp' |
purge(): void; purge(): void;
query(path: string, createIfNone: boolean): Prop | null; query(path: string, createIfNone: boolean): IProp | null;
import(value?: IPublicTypePropsMap | IPublicTypePropsList | null, extras?: ExtrasObject): void; 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 { export class Props implements IProps, IPropParent {
readonly id = uniqueId('props'); readonly id = uniqueId('props');
@obx.shallow private items: Prop[] = []; @obx.shallow private items: IProp[] = [];
@computed private get maps(): Map<string, Prop> { @computed private get maps(): Map<string, Prop> {
const maps = new Map(); const maps = new Map();
@ -77,7 +79,7 @@ export class Props implements IProps, IPropParent {
readonly path = []; readonly path = [];
get props(): Props { get props(): IProps {
return this; return this;
} }
@ -228,7 +230,7 @@ export class Props implements IProps, IPropParent {
* @param createIfNone * @param createIfNone
*/ */
@action @action
query(path: string, createIfNone = true): Prop | null { query(path: string, createIfNone = true): IProp | null {
return this.get(path, createIfNone); return this.get(path, createIfNone);
} }
@ -237,7 +239,7 @@ export class Props implements IProps, IPropParent {
* @param createIfNone * @param createIfNone
*/ */
@action @action
get(path: string, createIfNone = false): Prop | null { get(path: string, createIfNone = false): IProp | null {
let entry = path; let entry = path;
let nest = ''; let nest = '';
const i = path.indexOf('.'); const i = path.indexOf('.');
@ -265,7 +267,7 @@ export class Props implements IProps, IPropParent {
* *
*/ */
@action @action
delete(prop: Prop): void { delete(prop: IProp): void {
const i = this.items.indexOf(prop); const i = this.items.indexOf(prop);
if (i > -1) { if (i > -1) {
this.items.splice(i, 1); this.items.splice(i, 1);
@ -297,7 +299,7 @@ export class Props implements IProps, IPropParent {
key?: string | number, key?: string | number,
spread = false, spread = false,
options: any = {}, options: any = {},
): Prop { ): IProp {
const prop = new Prop(this, value, key, spread, options); const prop = new Prop(this, value, key, spread, options);
this.items.push(prop); this.items.push(prop);
return 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; let index = 0;
const { items } = this; const { items } = this;
const length = items.length || 0; const length = items.length || 0;
@ -337,7 +339,7 @@ export class Props implements IProps, IPropParent {
* *
*/ */
@action @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) => { this.items.forEach((item) => {
return fn(item, item.key); return fn(item, item.key);
}); });
@ -347,14 +349,14 @@ export class Props implements IProps, IPropParent {
* *
*/ */
@action @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 this.items.map((item) => {
return fn(item, item.key); return fn(item, item.key);
}); });
} }
@action @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 this.items.filter((item) => {
return fn(item, item.key); return fn(item, item.key);
}); });
@ -377,7 +379,7 @@ export class Props implements IProps, IPropParent {
* @param createIfNone * @param createIfNone
*/ */
@action @action
getProp(path: string, createIfNone = true): Prop | null { getProp(path: string, createIfNone = true): IProp | null {
return this.query(path, createIfNone) || null; return this.query(path, createIfNone) || null;
} }

View File

@ -1,17 +1,20 @@
import { obx, computed, makeObservable, action, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core'; import { obx, computed, makeObservable, action, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core';
import { IDesigner } from '../designer'; import { IDesigner } from '../designer';
import { DocumentModel, IDocumentModel, isDocumentModel } from '../document'; import { DocumentModel, isDocumentModel } from '../document';
import type { IDocumentModel } from "../document";
import { import {
IPublicTypeProjectSchema,
IPublicTypeRootSchema,
IPublicTypeComponentsMap, IPublicTypeComponentsMap,
IPublicEnumTransformStage, IPublicEnumTransformStage,
IBaseApiProject, IBaseApiProject,
} from '@alilc/lowcode-types'; } from '@alilc/lowcode-types';
import type {
IPublicTypeProjectSchema,
IPublicTypeRootSchema,
} from '@alilc/lowcode-types';
import { isLowCodeComponentType, isProCodeComponentType } from '@alilc/lowcode-utils'; import { isLowCodeComponentType, isProCodeComponentType } from '@alilc/lowcode-utils';
import { ISimulatorHost } from '../simulator'; import { ISimulatorHost } from '../simulator';
export interface IProject extends Omit< IBaseApiProject< export interface IProject extends Omit<IBaseApiProject<
IDocumentModel IDocumentModel
>, >,
'simulatorHost' | 'simulatorHost' |
@ -146,7 +149,7 @@ export class Project implements IProject {
return this.documents.reduce<IPublicTypeComponentsMap>(( return this.documents.reduce<IPublicTypeComponentsMap>((
componentsMap: IPublicTypeComponentsMap, componentsMap: IPublicTypeComponentsMap,
curDoc: IDocumentModel, curDoc: IDocumentModel,
): IPublicTypeComponentsMap => { ): IPublicTypeComponentsMap => {
const curComponentsMap = curDoc.getComponentsMap(); const curComponentsMap = curDoc.getComponentsMap();
if (Array.isArray(curComponentsMap)) { if (Array.isArray(curComponentsMap)) {
curComponentsMap.forEach((item) => { curComponentsMap.forEach((item) => {
@ -178,8 +181,8 @@ export class Project implements IProject {
* schema * schema
*/ */
getSchema( getSchema(
stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Save, stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Save,
): IPublicTypeProjectSchema { ): IPublicTypeProjectSchema {
return { return {
...this.data, ...this.data,
componentsMap: this.getComponentsMap(), componentsMap: this.getComponentsMap(),

View File

@ -65,8 +65,8 @@ describe('setting-field 测试', () => {
it('常规方法', () => { it('常规方法', () => {
// 普通 field // 普通 field
const settingEntry = mockNode.settingEntry as SettingTopEntry; const settingEntry = mockNode.settingEntry;
const field = settingEntry.get('behavior') as SettingField; const field = settingEntry.get('behavior');
expect(field.title).toBe('默认状态'); expect(field.title).toBe('默认状态');
expect(field.expanded).toBeTruthy(); expect(field.expanded).toBeTruthy();
field.setExpanded(false); field.setExpanded(false);
@ -103,24 +103,24 @@ describe('setting-field 测试', () => {
expect(nonExistingField.setter).toBeNull(); expect(nonExistingField.setter).toBeNull();
// group 类型的 field // group 类型的 field
const groupField = settingEntry.get('groupkgzzeo41') as SettingField; const groupField = settingEntry.get('groupkgzzeo41');
expect(groupField.items).toEqual([]); expect(groupField.items).toEqual([]);
// 有子节点的 field // 有子节点的 field
const objField = settingEntry.get('obj') as SettingField; const objField = settingEntry.get('obj');
expect(objField.items).toHaveLength(3); expect(objField.items).toHaveLength(3);
expect(objField.getItems()).toHaveLength(3); expect(objField.getItems()).toHaveLength(3);
expect(objField.getItems(x => x.name === 'a')).toHaveLength(1); expect(objField.getItems(x => x.name === 'a')).toHaveLength(1);
objField.purge(); objField.purge();
expect(objField.items).toHaveLength(0); expect(objField.items).toHaveLength(0);
const objAField = settingEntry.get('obj.a') as SettingField; const objAField = settingEntry.get('obj.a');
expect(objAField.setter).toBe('StringSetter'); expect(objAField.setter).toBe('StringSetter');
}); });
it('setValue / getValue / setHotValue / getHotValue', () => { it('setValue / getValue / setHotValue / getHotValue', () => {
// 获取已有的 prop // 获取已有的 prop
const settingEntry = mockNode.settingEntry as SettingTopEntry; const settingEntry = mockNode.settingEntry as SettingTopEntry;
const field = settingEntry.get('behavior') as SettingField; const field = settingEntry.get('behavior');
// 会读取 extraProps.defaultValue // 会读取 extraProps.defaultValue
expect(field.getHotValue()).toBe('NORMAL'); expect(field.getHotValue()).toBe('NORMAL');
@ -140,11 +140,37 @@ describe('setting-field 测试', () => {
// dirty fix list setter // dirty fix list setter
field.setHotValue([{ __sid__: 1 }]); 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 () => { it('onEffect', async () => {
const settingEntry = mockNode.settingEntry as SettingTopEntry; const settingEntry = mockNode.settingEntry as SettingTopEntry;
const field = settingEntry.get('behavior') as SettingField; const field = settingEntry.get('behavior');
const mockFn = jest.fn(); const mockFn = jest.fn();

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-editor-core", "name": "@alilc/lowcode-editor-core",
"version": "1.1.4", "version": "1.1.5-beta.2",
"description": "Core Api for Ali lowCode engine", "description": "Core Api for Ali lowCode engine",
"license": "MIT", "license": "MIT",
"main": "lib/index.js", "main": "lib/index.js",
@ -14,8 +14,8 @@
}, },
"dependencies": { "dependencies": {
"@alifd/next": "^1.19.16", "@alifd/next": "^1.19.16",
"@alilc/lowcode-types": "1.1.4", "@alilc/lowcode-types": "1.1.5-beta.2",
"@alilc/lowcode-utils": "1.1.4", "@alilc/lowcode-utils": "1.1.5-beta.2",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"debug": "^4.1.1", "debug": "^4.1.1",
"intl-messageformat": "^9.3.1", "intl-messageformat": "^9.3.1",

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-editor-skeleton", "name": "@alilc/lowcode-editor-skeleton",
"version": "1.1.4", "version": "1.1.5-beta.2",
"description": "alibaba lowcode editor skeleton", "description": "alibaba lowcode editor skeleton",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -18,10 +18,10 @@
], ],
"dependencies": { "dependencies": {
"@alifd/next": "^1.20.12", "@alifd/next": "^1.20.12",
"@alilc/lowcode-designer": "1.1.4", "@alilc/lowcode-designer": "1.1.5-beta.2",
"@alilc/lowcode-editor-core": "1.1.4", "@alilc/lowcode-editor-core": "1.1.5-beta.2",
"@alilc/lowcode-types": "1.1.4", "@alilc/lowcode-types": "1.1.5-beta.2",
"@alilc/lowcode-utils": "1.1.4", "@alilc/lowcode-utils": "1.1.5-beta.2",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"react": "^16.8.1", "react": "^16.8.1",
"react-dom": "^16.8.1" "react-dom": "^16.8.1"

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-engine", "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 / 一套面向扩展设计的企业级低代码技术体系", "description": "An enterprise-class low-code technology stack with scale-out design / 一套面向扩展设计的企业级低代码技术体系",
"main": "lib/engine-core.js", "main": "lib/engine-core.js",
"module": "es/engine-core.js", "module": "es/engine-core.js",
@ -19,15 +19,15 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@alifd/next": "^1.19.12", "@alifd/next": "^1.19.12",
"@alilc/lowcode-designer": "1.1.4", "@alilc/lowcode-designer": "1.1.5-beta.2",
"@alilc/lowcode-editor-core": "1.1.4", "@alilc/lowcode-editor-core": "1.1.5-beta.2",
"@alilc/lowcode-editor-skeleton": "1.1.4", "@alilc/lowcode-editor-skeleton": "1.1.5-beta.2",
"@alilc/lowcode-engine-ext": "^1.0.0", "@alilc/lowcode-engine-ext": "^1.0.0",
"@alilc/lowcode-plugin-designer": "1.1.4", "@alilc/lowcode-plugin-designer": "1.1.5-beta.2",
"@alilc/lowcode-plugin-outline-pane": "1.1.4", "@alilc/lowcode-plugin-outline-pane": "1.1.5-beta.2",
"@alilc/lowcode-shell": "1.1.4", "@alilc/lowcode-shell": "1.1.5-beta.2",
"@alilc/lowcode-utils": "1.1.4", "@alilc/lowcode-utils": "1.1.5-beta.2",
"@alilc/lowcode-workspace": "1.1.4", "@alilc/lowcode-workspace": "1.1.5-beta.2",
"react": "^16.8.1", "react": "^16.8.1",
"react-dom": "^16.8.1" "react-dom": "^16.8.1"
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-ignitor", "name": "@alilc/lowcode-ignitor",
"version": "1.1.4", "version": "1.1.5-beta.2",
"description": "点火器bootstrap lce project", "description": "点火器bootstrap lce project",
"main": "lib/index.js", "main": "lib/index.js",
"private": true, "private": true,

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-plugin-designer", "name": "@alilc/lowcode-plugin-designer",
"version": "1.1.4", "version": "1.1.5-beta.2",
"description": "alibaba lowcode editor designer plugin", "description": "alibaba lowcode editor designer plugin",
"files": [ "files": [
"es", "es",
@ -18,9 +18,9 @@
], ],
"author": "xiayang.xy", "author": "xiayang.xy",
"dependencies": { "dependencies": {
"@alilc/lowcode-designer": "1.1.4", "@alilc/lowcode-designer": "1.1.5-beta.2",
"@alilc/lowcode-editor-core": "1.1.4", "@alilc/lowcode-editor-core": "1.1.5-beta.2",
"@alilc/lowcode-utils": "1.1.4", "@alilc/lowcode-utils": "1.1.5-beta.2",
"react": "^16.8.1", "react": "^16.8.1",
"react-dom": "^16.8.1" "react-dom": "^16.8.1"
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-plugin-outline-pane", "name": "@alilc/lowcode-plugin-outline-pane",
"version": "1.1.4", "version": "1.1.5-beta.2",
"description": "Outline pane for Ali lowCode engine", "description": "Outline pane for Ali lowCode engine",
"files": [ "files": [
"es", "es",
@ -13,10 +13,10 @@
}, },
"dependencies": { "dependencies": {
"@alifd/next": "^1.19.16", "@alifd/next": "^1.19.16",
"@alilc/lowcode-designer": "1.1.4", "@alilc/lowcode-designer": "1.1.5-beta.2",
"@alilc/lowcode-editor-core": "1.1.4", "@alilc/lowcode-editor-core": "1.1.5-beta.2",
"@alilc/lowcode-types": "1.1.4", "@alilc/lowcode-types": "1.1.5-beta.2",
"@alilc/lowcode-utils": "1.1.4", "@alilc/lowcode-utils": "1.1.5-beta.2",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"react": "^16", "react": "^16",
"react-dom": "^16.7.0", "react-dom": "^16.7.0",

View File

@ -41,43 +41,22 @@ export default class TreeNode {
readonly pluginContext: IPublicModelPluginContext; readonly pluginContext: IPublicModelPluginContext;
event = new EventEmitter(); event = new EventEmitter();
onFilterResultChanged(fn: () => void): IPublicTypeDisposable { private _node: IPublicModelNode;
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 () => { readonly tree: Tree;
this.event.off(EVENT_NAMES.titleLabelChanged, fn);
} 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 { get id(): string {
return this.node.id; return this.node.id;
@ -91,11 +70,8 @@ export default class TreeNode {
return this.hasChildren() || this.hasSlots() || this.dropDetail?.index != null; return this.hasChildren() || this.hasSlots() || this.dropDetail?.index != null;
} }
/** get expanded(): boolean {
* onExpandableChanged return this.isRoot(true) || (this.expandable && this._expanded);
*/
notifyExpandableChanged(): void {
this.event.emit(EVENT_NAMES.expandableChanged, this.expandable);
} }
/** /**
@ -110,47 +86,6 @@ export default class TreeNode {
return this.node.zLevel; 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() { get detecting() {
const doc = this.pluginContext.project.currentDocument; const doc = this.pluginContext.project.currentDocument;
return !!(doc?.isDetectingNode(this.node)); return !!(doc?.isDetectingNode(this.node));
@ -164,23 +99,10 @@ export default class TreeNode {
return !cv; return !cv;
} }
setHidden(flag: boolean) {
if (this.node.conditionGroup) {
return;
}
this.node.visible = !flag;
this.event.emit(EVENT_NAMES.hiddenChanged, flag);
}
get locked(): boolean { get locked(): boolean {
return this.node.isLocked; return this.node.isLocked;
} }
setLocked(flag: boolean) {
this.node.lock(flag);
this.event.emit(EVENT_NAMES.lockedChanged, flag);
}
get selected(): boolean { get selected(): boolean {
// TODO: check is dragging // TODO: check is dragging
const selection = this.pluginContext.project.getCurrentDocument()?.selection; const selection = this.pluginContext.project.getCurrentDocument()?.selection;
@ -213,19 +135,6 @@ export default class TreeNode {
return this.node.componentName; 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() { get icon() {
return this.node.componentMeta?.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; 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) { setNode(node: IPublicModelNode) {
if (this._node !== node) { if (this._node !== node) {
this._node = node; this._node = node;
} }
} }
private _filterResult: FilterResult = {
filterWorking: false,
matchChild: false,
matchSelf: false,
keywords: '',
};
get filterReult(): FilterResult { get filterReult(): FilterResult {
return this._filterResult; return this._filterResult;
} }
setFilterReult(val: FilterResult) { setFilterReult(val: FilterResult) {
this._filterResult = val; this._filterResult = val;
this.event.emit(EVENT_NAMES.filterResultChanged) this.event.emit(EVENT_NAMES.filterResultChanged);
} }
} }

View File

@ -1,5 +1,5 @@
import TreeNode from './tree-node'; import TreeNode from './tree-node';
import { IPublicModelNode, IPublicModelPluginContext } from '@alilc/lowcode-types'; import { IPublicModelNode, IPublicModelPluginContext, IPublicTypePropChangeOptions } from '@alilc/lowcode-types';
export class Tree { export class Tree {
private treeNodesMap = new Map<string, TreeNode>(); private treeNodesMap = new Map<string, TreeNode>();
@ -25,6 +25,14 @@ export class Tree {
const treeNode = this.getTreeNodeById(node.id); const treeNode = this.getTreeNodeById(node.id);
treeNode?.notifyExpandableChanged(); 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 { setNodeSelected(nodeId: string): void {

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-rax-renderer", "name": "@alilc/lowcode-rax-renderer",
"version": "1.1.4", "version": "1.1.5-beta.2",
"description": "Rax renderer for Ali lowCode engine", "description": "Rax renderer for Ali lowCode engine",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -30,8 +30,8 @@
"build": "build-scripts build" "build": "build-scripts build"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-renderer-core": "1.1.4", "@alilc/lowcode-renderer-core": "1.1.5-beta.2",
"@alilc/lowcode-utils": "1.1.4", "@alilc/lowcode-utils": "1.1.5-beta.2",
"rax-find-dom-node": "^1.0.1" "rax-find-dom-node": "^1.0.1"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-rax-simulator-renderer", "name": "@alilc/lowcode-rax-simulator-renderer",
"version": "1.1.4", "version": "1.1.5-beta.2",
"description": "rax simulator renderer for alibaba lowcode designer", "description": "rax simulator renderer for alibaba lowcode designer",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -13,10 +13,10 @@
"build:umd": "build-scripts build --config build.umd.json" "build:umd": "build-scripts build --config build.umd.json"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-designer": "1.1.4", "@alilc/lowcode-designer": "1.1.5-beta.2",
"@alilc/lowcode-rax-renderer": "1.1.4", "@alilc/lowcode-rax-renderer": "1.1.5-beta.2",
"@alilc/lowcode-types": "1.1.4", "@alilc/lowcode-types": "1.1.5-beta.2",
"@alilc/lowcode-utils": "1.1.4", "@alilc/lowcode-utils": "1.1.5-beta.2",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"driver-universal": "^3.1.3", "driver-universal": "^3.1.3",
"history": "^5.0.0", "history": "^5.0.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-react-renderer", "name": "@alilc/lowcode-react-renderer",
"version": "1.1.4", "version": "1.1.5-beta.2",
"description": "react renderer for ali lowcode engine", "description": "react renderer for ali lowcode engine",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -22,7 +22,7 @@
], ],
"dependencies": { "dependencies": {
"@alifd/next": "^1.21.16", "@alifd/next": "^1.21.16",
"@alilc/lowcode-renderer-core": "1.1.4" "@alilc/lowcode-renderer-core": "1.1.5-beta.2"
}, },
"devDependencies": { "devDependencies": {
"@alib/build-scripts": "^0.1.18", "@alib/build-scripts": "^0.1.18",

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-react-simulator-renderer", "name": "@alilc/lowcode-react-simulator-renderer",
"version": "1.1.4", "version": "1.1.5-beta.2",
"description": "react simulator renderer for alibaba lowcode designer", "description": "react simulator renderer for alibaba lowcode designer",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -17,10 +17,10 @@
"test:cov": "build-scripts test --config build.test.json --jest-coverage" "test:cov": "build-scripts test --config build.test.json --jest-coverage"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-designer": "1.1.4", "@alilc/lowcode-designer": "1.1.5-beta.2",
"@alilc/lowcode-react-renderer": "1.1.4", "@alilc/lowcode-react-renderer": "1.1.5-beta.2",
"@alilc/lowcode-types": "1.1.4", "@alilc/lowcode-types": "1.1.5-beta.2",
"@alilc/lowcode-utils": "1.1.4", "@alilc/lowcode-utils": "1.1.5-beta.2",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"mobx": "^6.3.0", "mobx": "^6.3.0",
"mobx-react": "^7.2.0", "mobx-react": "^7.2.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-renderer-core", "name": "@alilc/lowcode-renderer-core",
"version": "1.1.4", "version": "1.1.5-beta.2",
"description": "renderer core", "description": "renderer core",
"license": "MIT", "license": "MIT",
"main": "lib/index.js", "main": "lib/index.js",
@ -16,8 +16,8 @@
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-datasource-engine": "^1.0.0", "@alilc/lowcode-datasource-engine": "^1.0.0",
"@alilc/lowcode-types": "1.1.4", "@alilc/lowcode-types": "1.1.5-beta.2",
"@alilc/lowcode-utils": "1.1.4", "@alilc/lowcode-utils": "1.1.5-beta.2",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"debug": "^4.1.1", "debug": "^4.1.1",
"fetch-jsonp": "^1.1.3", "fetch-jsonp": "^1.1.3",
@ -32,7 +32,7 @@
"devDependencies": { "devDependencies": {
"@alib/build-scripts": "^0.1.18", "@alib/build-scripts": "^0.1.18",
"@alifd/next": "^1.26.0", "@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", "@babel/plugin-transform-typescript": "^7.16.8",
"@testing-library/react": "^11.2.2", "@testing-library/react": "^11.2.2",
"@types/classnames": "^2.2.11", "@types/classnames": "^2.2.11",

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-shell", "name": "@alilc/lowcode-shell",
"version": "1.1.4", "version": "1.1.5-beta.2",
"description": "Shell Layer for AliLowCodeEngine", "description": "Shell Layer for AliLowCodeEngine",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -15,12 +15,12 @@
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@alilc/lowcode-designer": "1.1.4", "@alilc/lowcode-designer": "1.1.5-beta.2",
"@alilc/lowcode-editor-core": "1.1.4", "@alilc/lowcode-editor-core": "1.1.5-beta.2",
"@alilc/lowcode-editor-skeleton": "1.1.4", "@alilc/lowcode-editor-skeleton": "1.1.5-beta.2",
"@alilc/lowcode-types": "1.1.4", "@alilc/lowcode-types": "1.1.5-beta.2",
"@alilc/lowcode-utils": "1.1.4", "@alilc/lowcode-utils": "1.1.5-beta.2",
"@alilc/lowcode-workspace": "1.1.4", "@alilc/lowcode-workspace": "1.1.5-beta.2",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"enzyme": "^3.11.0", "enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5", "enzyme-adapter-react-16": "^1.15.5",

View File

@ -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 { IPublicModelExclusiveGroup, IPublicModelNode } from '@alilc/lowcode-types';
import { conditionGroupSymbol, nodeSymbol } from '../symbols'; import { conditionGroupSymbol, nodeSymbol } from '../symbols';
import { Node } from './node'; import { Node } from './node';

View File

@ -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 { historySymbol, documentSymbol } from '../symbols';
import { IPublicModelHistory, IPublicTypeDisposable } from '@alilc/lowcode-types'; import { IPublicModelHistory, IPublicTypeDisposable } from '@alilc/lowcode-types';

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-types", "name": "@alilc/lowcode-types",
"version": "1.1.4", "version": "1.1.5-beta.2",
"description": "Types for Ali lowCode engine", "description": "Types for Ali lowCode engine",
"files": [ "files": [
"es", "es",

View File

@ -108,7 +108,7 @@ export interface IPublicModelDocumentModel<
* @param data * @param data
* @returns * @returns
*/ */
createNode(data: IPublicTypeNodeSchema): Node | null; createNode<T = Node>(data: IPublicTypeNodeSchema): T | null;
/** /**
* /id * /id

View File

@ -299,7 +299,7 @@ export interface IBaseModelNode<
* @param path a / a.b / a.0 * @param path a / a.b / a.0
* @param createIfNone true * @param createIfNone true
*/ */
getProp(path: string, createIfNone?: boolean): Prop | null; getProp(path: string | number, createIfNone?: boolean): Prop | null;
/** /**
* path * path
@ -336,7 +336,7 @@ export interface IBaseModelNode<
* @param path a / a.b / a.0 * @param path a / a.b / a.0
* @param value * @param value
*/ */
setPropValue(path: string, value: IPublicTypeCompositeValue): void; setPropValue(path: string | number, value: IPublicTypeCompositeValue): void;
/** /**
* path * path

View File

@ -1,3 +1,4 @@
import { IPublicTypeNodeData } from './node-data';
import { IPublicTypeNodeSchema } from './node-schema'; import { IPublicTypeNodeSchema } from './node-schema';
/** /**
@ -13,5 +14,5 @@ export interface IPublicTypeSlotSchema extends IPublicTypeNodeSchema {
slotName?: string; slotName?: string;
slotParams?: string[]; slotParams?: string[];
}; };
children?: IPublicTypeNodeSchema[]; children?: IPublicTypeNodeData[] | IPublicTypeNodeData;
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-utils", "name": "@alilc/lowcode-utils",
"version": "1.1.4", "version": "1.1.5-beta.2",
"description": "Utils for Ali lowCode engine", "description": "Utils for Ali lowCode engine",
"files": [ "files": [
"lib", "lib",
@ -14,7 +14,7 @@
}, },
"dependencies": { "dependencies": {
"@alifd/next": "^1.19.16", "@alifd/next": "^1.19.16",
"@alilc/lowcode-types": "1.1.4", "@alilc/lowcode-types": "1.1.5-beta.2",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mobx": "^6.3.0", "mobx": "^6.3.0",
"react": "^16" "react": "^16"

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-workspace", "name": "@alilc/lowcode-workspace",
"version": "1.1.4", "version": "1.1.5-beta.2",
"description": "Shell Layer for AliLowCodeEngine", "description": "Shell Layer for AliLowCodeEngine",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -15,11 +15,11 @@
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@alilc/lowcode-designer": "1.1.4", "@alilc/lowcode-designer": "1.1.5-beta.2",
"@alilc/lowcode-editor-core": "1.1.4", "@alilc/lowcode-editor-core": "1.1.5-beta.2",
"@alilc/lowcode-editor-skeleton": "1.1.4", "@alilc/lowcode-editor-skeleton": "1.1.5-beta.2",
"@alilc/lowcode-types": "1.1.4", "@alilc/lowcode-types": "1.1.5-beta.2",
"@alilc/lowcode-utils": "1.1.4", "@alilc/lowcode-utils": "1.1.5-beta.2",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"enzyme": "^3.11.0", "enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5", "enzyme-adapter-react-16": "^1.15.5",

View File

@ -2,7 +2,8 @@ import { IDesigner, ILowCodePluginManager, LowCodePluginManager } from '@alilc/l
import { createModuleEventBus, Editor, IEventBus, makeObservable, obx } from '@alilc/lowcode-editor-core'; import { createModuleEventBus, Editor, IEventBus, makeObservable, obx } from '@alilc/lowcode-editor-core';
import { IPublicApiPlugins, IPublicApiWorkspace, IPublicResourceList, IPublicTypeResourceType, IShellModelFactory } from '@alilc/lowcode-types'; import { IPublicApiPlugins, IPublicApiWorkspace, IPublicResourceList, IPublicTypeResourceType, IShellModelFactory } from '@alilc/lowcode-types';
import { BasicContext } from './context/base-context'; 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 { IResource, Resource } from './resource';
import { IResourceType, ResourceType } from './resource-type'; import { IResourceType, ResourceType } from './resource-type';