diff --git a/packages/code-generator/CHANGELOG.md b/packages/code-generator/CHANGELOG.md index 8ebc3cde2..16d59a80d 100644 --- a/packages/code-generator/CHANGELOG.md +++ b/packages/code-generator/CHANGELOG.md @@ -238,14 +238,11 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Features -<<<<<<< HEAD * code generator main process ([021d6e0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/021d6e0)) * demo schema & complex children type ([a5ee6bd](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/a5ee6bd)) * fix gaps ([32af3d3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/32af3d3)) * project builder fix & publish demo to disk ([26983b3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/26983b3)) -======= * code generator main process ([021d6e0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/021d6e0fe9fb29a8b6c1c5d5f4d06ec71896faa5)) * demo schema & complex children type ([a5ee6bd](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/a5ee6bd55806fc9aea695096ccd4c7f50b8e31c4)) * fix gaps ([32af3d3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/32af3d3a3ca4d5aca15be25e05c840c8ea0cb6ae)) * project builder fix & publish demo to disk ([26983b3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/26983b38c2b0f1d39d79964eb54d8ce60250dd82)) ->>>>>>> df955e1db90ff104cd11160def80113cfd6faccc diff --git a/packages/demo/CHANGELOG.md b/packages/demo/CHANGELOG.md index 241ff0218..145484a81 100644 --- a/packages/demo/CHANGELOG.md +++ b/packages/demo/CHANGELOG.md @@ -7,6 +7,30 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@1.0.6-0...@ali/lowcode-demo@1.0.7-0) (2020-09-02) + +## [0.8.65](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.64...@ali/lowcode-demo@0.8.65) (2020-09-08) + + +**Note:** Version bump only for package @ali/lowcode-demo + + +## [0.8.64](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.63...@ali/lowcode-demo@0.8.64) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-demo + + +## [0.8.63](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.62...@ali/lowcode-demo@0.8.63) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-demo + + +## [0.8.62](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.61...@ali/lowcode-demo@0.8.62) (2020-08-27) **Note:** Version bump only for package @ali/lowcode-demo diff --git a/packages/demo/public/assets.json b/packages/demo/public/assets.json index 24b3061c6..ef8650e05 100644 --- a/packages/demo/public/assets.json +++ b/packages/demo/public/assets.json @@ -13107,30 +13107,6 @@ } ], "componentList": [ - { - "title": "Util", - "children": [ - { - "componentName": "Dropdown", - "title": "下拉菜单", - "icon": "", - "package": "@alifd/next", - "library": "Next", - "snippets": [ - { - "title": "下拉菜单", - "screenshot": "", - "schema": { - "componentName": "Dropdown", - "props": { "trigger": [{ "componentName": "Button", "props": { "type": "primary" }, "children": "确定" }], "triggerType": "click"}, - "children": [{ "componentName": "Menu", "props": { "style": { "width": 200 } }, "children": [{ "componentName": "Menu.Item", "props": {}, "children": "Option 1" }, { "componentName": "Menu.Item", "props": { "disabled": false }, "children": "option 2" }, { "componentName": "Menu.Item", "props": { "disabled": false }, "children": "option 3" }]}] - } - } - ] - } - ], - "icon": "" - }, { "title": "DataDisplay", "children": [ @@ -15388,5 +15364,31 @@ ], "icon": "" } + ], + "bizComponentList": [ + { + "title": "Util", + "children": [ + { + "componentName": "Dropdown", + "title": "下拉菜单", + "icon": "", + "package": "@alifd/next", + "library": "Next", + "snippets": [ + { + "title": "下拉菜单", + "screenshot": "", + "schema": { + "componentName": "Dropdown", + "props": { "trigger": [{ "componentName": "Button", "props": { "type": "primary" }, "children": "确定" }], "triggerType": "click"}, + "children": [{ "componentName": "Menu", "props": { "style": { "width": 200 } }, "children": [{ "componentName": "Menu.Item", "props": {}, "children": "Option 1" }, { "componentName": "Menu.Item", "props": { "disabled": false }, "children": "option 2" }, { "componentName": "Menu.Item", "props": { "disabled": false }, "children": "option 3" }]}] + } + } + ] + } + ], + "icon": "" + } ] } diff --git a/packages/designer/CHANGELOG.md b/packages/designer/CHANGELOG.md index 86d68e285..1aadd8b58 100644 --- a/packages/designer/CHANGELOG.md +++ b/packages/designer/CHANGELOG.md @@ -7,6 +7,26 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@1.0.6-0...@ali/lowcode-designer@1.0.7-0) (2020-09-02) + +## [0.9.55](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.54...@ali/lowcode-designer@0.9.55) (2020-09-08) + + +### Bug Fixes + +* 拖拽时要解除与原来节点的关系 ([7a6bf2c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7a6bf2c)) + + + + + +## [0.9.54](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.53...@ali/lowcode-designer@0.9.54) (2020-09-03) + + +**Note:** Version bump only for package @ali/lowcode-designer + + +## [0.9.53](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.52...@ali/lowcode-designer@0.9.53) (2020-09-03) + **Note:** Version bump only for package @ali/lowcode-designer @@ -29,6 +49,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline +**Note:** Version bump only for package @ali/lowcode-designer ## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@1.0.4-0...@ali/lowcode-designer@1.0.5-0) (2020-08-20) @@ -80,7 +101,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ## [0.9.48](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.47...@ali/lowcode-designer@0.9.48) (2020-08-20) ->>>>>>> master @@ -105,7 +125,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Bug Fixes * support dropObject is data ([809fda7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/809fda7)) ->>>>>>> master @@ -199,7 +218,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ## [0.9.38](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.37...@ali/lowcode-designer@0.9.38) (2020-08-06) ->>>>>>> master ### Bug Fixes diff --git a/packages/designer/src/builtin-simulator/host.ts b/packages/designer/src/builtin-simulator/host.ts index cb5d82395..47878ac2d 100644 --- a/packages/designer/src/builtin-simulator/host.ts +++ b/packages/designer/src/builtin-simulator/host.ts @@ -87,7 +87,7 @@ const defaultRaxSimulatorUrl = (() => { const defaultEnvironment = [ // https://g.alicdn.com/mylib/??react/16.11.0/umd/react.production.min.js,react-dom/16.8.6/umd/react-dom.production.min.js,prop-types/15.7.2/prop-types.min.js - assetItem(AssetType.JSText, 'window.React=parent.React;window.ReactDOM=parent.ReactDOM;', undefined, 'react'), + assetItem(AssetType.JSText, 'window.React=parent.React;window.ReactDOM=parent.ReactDOM;window.__is_simulator_env__=true;', undefined, 'react'), assetItem( AssetType.JSText, 'window.PropTypes=parent.PropTypes;React.PropTypes=parent.PropTypes; window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;', diff --git a/packages/designer/src/document/document-model.ts b/packages/designer/src/document/document-model.ts index 7d8c3978b..cd6628a13 100644 --- a/packages/designer/src/document/document-model.ts +++ b/packages/designer/src/document/document-model.ts @@ -11,7 +11,6 @@ import { History } from './history'; import { TransformStage, ModalNodesManager } from './node'; import { uniqueId } from '@ali/lowcode-utils'; - export type GetDataType = T extends undefined ? NodeType extends { schema: infer R; @@ -281,14 +280,16 @@ export class DocumentModel { /** * 内部方法,请勿调用 */ - internalRemoveAndPurgeNode(node: Node) { + internalRemoveAndPurgeNode(node: Node, useMutator = false) { if (!this.nodes.has(node)) { return; } - this._nodesMap.delete(node.id); + node.remove(useMutator); + } + + unlinkNode(node: Node) { this.nodes.delete(node); - this.selection.remove(node.id); - node.remove(); + this._nodesMap.delete(node.id); } @obx.ref private _dropLocation: DropLocation | null = null; @@ -333,20 +334,23 @@ export class DocumentModel { * 导出 schema 数据 */ get schema(): RootSchema { - return this.rootNode.schema as any; + return this.rootNode?.schema as any; } import(schema: RootSchema, checkId = false) { - // TODO: do purge + // TODO: 暂时用饱和式删除,原因是 Slot 节点并不是树节点,无法正常递归删除 this.nodes.forEach(node => { - this.destroyNode(node); + this.internalRemoveAndPurgeNode(node, true); }); - this.rootNode.import(schema as any, checkId); + // foreachReverse(this.rootNode?.children, (node: Node) => { + // this.internalRemoveAndPurgeNode(node, true); + // }); + this.rootNode?.import(schema as any, checkId); // todo: select added and active track added } export(stage: TransformStage = TransformStage.Serilize) { - return this.rootNode.export(stage); + return this.rootNode?.export(stage); } /** diff --git a/packages/designer/src/document/node/node-children.ts b/packages/designer/src/document/node/node-children.ts index 6d28fbfb0..c326a2021 100644 --- a/packages/designer/src/document/node/node-children.ts +++ b/packages/designer/src/document/node/node-children.ts @@ -4,6 +4,7 @@ import { TransformStage } from './transform-stage'; import { NodeData, isNodeSchema } from '@ali/lowcode-types'; import { shallowEqual } from '@ali/lowcode-utils'; import { EventEmitter } from 'events'; +import { foreachReverse } from '../../utils/tree'; export class NodeChildren { @obx.val private children: Node[]; @@ -14,9 +15,10 @@ export class NodeChildren { this.children = (Array.isArray(data) ? data : [data]).map(child => { return this.owner.document.createNode(child); }); + } - interalInitParent() { + internalInitParent() { this.children.forEach(child => child.internalSetParent(this.owner)); } @@ -56,7 +58,7 @@ export class NodeChildren { } this.children = children; - this.interalInitParent(); + this.internalInitParent(); if (!shallowEqual(children, originChildren)) { this.emitter.emit('change'); } @@ -92,24 +94,58 @@ export class NodeChildren { return this.children.length; } + private purged = false; /** - * 删除一个节点 + * 回收销毁 */ - delete(node: Node, purge = false, useMutator = true): boolean { + purge(useMutator = true) { + if (this.purged) { + return; + } + this.purged = true; + this.children.forEach((child) => { + child.purge(useMutator); + }); + } + + unlinkChild(node: Node) { const i = this.children.indexOf(node); if (i < 0) { return false; } - const deleted = this.children.splice(i, 1)[0]; + this.children.splice(i, 1); + } + /** + * 删除一个节点 + */ + delete(node: Node, purge = false, useMutator = true): boolean { + if (node.isParental()) { + foreachReverse(node.children, (subNode: Node) => { + subNode.remove(useMutator, purge); + }); + } if (purge) { // should set parent null - deleted.internalSetParent(null, useMutator); - deleted.purge(useMutator); + node.internalSetParent(null, useMutator); + try { + node.purge(useMutator); + } catch(err) { + console.error(err); + } } + const document = node.document; + document.unlinkNode(node); + document.selection.remove(node.id); + document.destroyNode(node); this.emitter.emit('change'); + const i = this.children.indexOf(node); if (useMutator) { this.reportModified(node, this.owner, { type: 'remove', removeIndex: i, removeNode: node }); } + if (i < 0) { + return false; + } + this.children.splice(i, 1); return false; } @@ -236,7 +272,6 @@ export class NodeChildren { return fn(child, index); }); } - every(fn: (item: Node, index: number) => any): boolean { return this.children.every((child, index) => fn(child, index)); } @@ -249,6 +284,10 @@ export class NodeChildren { return this.children.filter(fn); } + find(fn: (item: Node, index: number) => Node) { + return this.children.find(fn); + } + mergeChildren(remover: () => any, adder: (children: Node[]) => NodeData[] | null, sorter: () => any) { let changed = false; if (remover) { @@ -291,19 +330,6 @@ export class NodeChildren { }; } - private purged = false; - - /** - * 回收销毁 - */ - purge(useMutator = true) { - if (this.purged) { - return; - } - this.purged = true; - this.children.forEach((child) => child.purge(useMutator)); - } - get [Symbol.toStringTag]() { // 保证向前兼容性 return 'Array'; @@ -329,7 +355,7 @@ export class NodeChildren { try { callbacks?.onSubtreeModified.call(node, owner, options); } catch (e) { - console.error('error when excute experimental.callbacks.onNodeAdd', e); + console.error('error when excute experimental.callbacks.onSubtreeModified', e); } } diff --git a/packages/designer/src/document/node/node.ts b/packages/designer/src/document/node/node.ts index dbc4c9308..68bb0ea24 100644 --- a/packages/designer/src/document/node/node.ts +++ b/packages/designer/src/document/node/node.ts @@ -163,9 +163,12 @@ export class Node { children: isDOMText(children) || isJSExpression(children) ? children : '', }); } else { + // 这里 props 被初始化两次,一次 new,一次 import,new 的实例需要给 propsReducer 的钩子去使用, + // import 是为了使用钩子返回的值,并非完全幂等的操作,部分行为执行两次会有 bug, + // 所以在 props 里会对 new / import 做一些区别化的解析 this.props = new Props(this, props, extras); this._children = new NodeChildren(this as ParentalNode, this.initialChildren(children)); - this._children.interalInitParent(); + this._children.internalInitParent(); this.props.import(this.upgradeProps(this.initProps(props || {})), this.upgradeProps(extras || {})); this.setupAutoruns(); } @@ -268,14 +271,15 @@ export class Node { return; } - if (this._parent) { + // 解除老的父子关系,但不需要真的删除节点 + if (this._parent && !parent) { if (this.isSlot()) { - this._parent.removeSlot(this, false); + this._parent.unlinkSlot(this); } else { - this._parent.children.delete(this, false, useMutator); + this._parent.children.unlinkChild(this); } } - + // 建立新的父子关系 this._parent = parent; if (parent) { this.document.removeWillPurge(this); @@ -309,12 +313,12 @@ export class Node { /** * 移除当前节点 */ - remove(useMutator = true) { + remove(useMutator = true, purge = true) { if (this.parent) { if (this.isSlot()) { - this.parent.removeSlot(this, true); + this.parent.removeSlot(this, purge); } else { - this.parent.children.delete(this, true, useMutator); + this.parent.children.delete(this, purge, useMutator); } } } @@ -658,20 +662,30 @@ export class Node { return comparePosition(this, otherNode); } - /** - * 删除一个Slot节点 - */ - removeSlot(slotNode: Node, purge = false): boolean { + unlinkSlot(slotNode: Node) { const i = this._slots.indexOf(slotNode); if (i < 0) { return false; } - const deleted = this._slots.splice(i, 1)[0]; + this._slots.splice(i, 1); + } + + /** + * 删除一个Slot节点 + */ + removeSlot(slotNode: Node, purge = false): boolean { if (purge) { // should set parent null - deleted.internalSetParent(null); - deleted.purge(); + slotNode?.internalSetParent(null, false); + slotNode?.purge(); } + this.document.unlinkNode(slotNode); + this.document.selection.remove(slotNode.id); + const i = this._slots.indexOf(slotNode); + if (i < 0) { + return false; + } + this._slots.splice(i, 1); return false; } @@ -715,20 +729,10 @@ export class Node { if (this.purged) { return; } - // if (this._parent) { - // // should remove thisNode before purge - // this.remove(useMutator); - // return; - // } this.purged = true; - if (this.isParental()) { - this.children.purge(useMutator); - } this.autoruns?.forEach((dispose) => dispose()); this.props.purge(); - this.document.internalRemoveAndPurgeNode(this); this.document.destroyNode(this); - this.remove(useMutator); } /** diff --git a/packages/designer/src/document/node/props/prop.ts b/packages/designer/src/document/node/props/prop.ts index e21f30f9d..b46a8e6f0 100644 --- a/packages/designer/src/document/node/props/prop.ts +++ b/packages/designer/src/document/node/props/prop.ts @@ -23,6 +23,37 @@ export class Prop implements IPropParent { readonly owner: Node; + private stash: PropStash | undefined; + + /** + * 键值 + */ + @obx key: string | number | undefined; + /** + * 扩展值 + */ + @obx spread: boolean; + + readonly props: Props; + readonly options: any; + + constructor( + public parent: IPropParent, + value: CompositeValue | UNSET = UNSET, + key?: string | number, + spread = false, + options = {}, + ) { + this.owner = parent.owner; + this.props = parent.props; + this.key = key; + this.spread = spread; + this.options = options; + if (value !== UNSET) { + this.setValue(value); + } + } + /** * @see SettingTarget */ @@ -200,7 +231,7 @@ export class Prop implements IPropParent { } else if (Array.isArray(val)) { this._type = 'list'; } else if (isPlainObject(val)) { - if (isJSSlot(val)) { + if (isJSSlot(val) && this.options.propsMode !== 'init') { this.setAsSlot(val); return; } @@ -355,35 +386,6 @@ export class Prop implements IPropParent { return this._maps; } - private stash: PropStash | undefined; - - /** - * 键值 - */ - @obx key: string | number | undefined; - - /** - * 扩展值 - */ - @obx spread: boolean; - - readonly props: Props; - - constructor( - public parent: IPropParent, - value: CompositeValue | UNSET = UNSET, - key?: string | number, - spread = false, - ) { - this.owner = parent.owner; - this.props = parent.props; - if (value !== UNSET) { - this.setValue(value); - } - this.key = key; - this.spread = spread; - } - /** * 获取某个属性 * @param stash 如果不存在,临时获取一个待写入 diff --git a/packages/designer/src/document/node/props/props.ts b/packages/designer/src/document/node/props/props.ts index 0e652ca4e..951e4adb2 100644 --- a/packages/designer/src/document/node/props/props.ts +++ b/packages/designer/src/document/node/props/props.ts @@ -59,9 +59,9 @@ export class Props implements IPropParent { constructor(readonly owner: Node, value?: PropsMap | PropsList | null, extras?: object) { if (Array.isArray(value)) { this.type = 'list'; - this.items = value.map(item => new Prop(this, item.value, item.name, item.spread)); + this.items = value.map(item => new Prop(this, item.value, item.name, item.spread, { propsMode: 'init' })); } else if (value != null) { - this.items = Object.keys(value).map(key => new Prop(this, value[key], key)); + this.items = Object.keys(value).map(key => new Prop(this, value[key], key, false, { propsMode: 'init' })); } if (extras) { Object.keys(extras).forEach(key => { diff --git a/packages/designer/src/utils/tree.ts b/packages/designer/src/utils/tree.ts new file mode 100644 index 000000000..2cd8ff515 --- /dev/null +++ b/packages/designer/src/utils/tree.ts @@ -0,0 +1,7 @@ +import { NodeChildren } from '../document/node/node-children'; + +export function foreachReverse(arr: NodeChildren, fn: Function, context: any = {}) { + for (let i = arr.length - 1; i >= 0; i--) { + fn.call(context, arr.get(i)); + } +} \ No newline at end of file diff --git a/packages/editor-core/CHANGELOG.md b/packages/editor-core/CHANGELOG.md index 74ddda28e..8fdfb9476 100644 --- a/packages/editor-core/CHANGELOG.md +++ b/packages/editor-core/CHANGELOG.md @@ -6,13 +6,19 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@1.0.6-0...@ali/lowcode-editor-core@1.0.7-0) (2020-09-02) - +**Note:** Version bump only for package @ali/lowcode-editor-core + +## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.34...@ali/lowcode-editor-core@1.0.6-0) (2020-09-02) **Note:** Version bump only for package @ali/lowcode-editor-core - -## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.34...@ali/lowcode-editor-core@1.0.6-0) (2020-09-02) + +## [0.8.36](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.35...@ali/lowcode-editor-core@0.8.36) (2020-09-03) + + +## [0.8.35](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.34...@ali/lowcode-editor-core@0.8.35) (2020-09-03) + ### Bug Fixes @@ -45,10 +51,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ->>>>>>> master ## [0.8.32](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.30...@ali/lowcode-editor-core@0.8.32) (2020-08-20) ->>>>>>> master @@ -91,7 +95,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.13.0...@ali/lowcode-editor-core@1.0.0) (2020-08-17) ## [0.8.30](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.29...@ali/lowcode-editor-core@0.8.30) (2020-08-19) ->>>>>>> master diff --git a/packages/editor-preset-general/CHANGELOG.md b/packages/editor-preset-general/CHANGELOG.md index ea6bfd4df..e0ab87e24 100644 --- a/packages/editor-preset-general/CHANGELOG.md +++ b/packages/editor-preset-general/CHANGELOG.md @@ -7,12 +7,28 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@1.0.6-0...@ali/lowcode-editor-preset-general@1.0.7-0) (2020-09-02) +**Note:** Version bump only for package @ali/lowcode-editor-preset-general + +## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.37...@ali/lowcode-editor-preset-general@1.0.6-0) (2020-09-02) + + + +## [0.9.40](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.39...@ali/lowcode-editor-preset-general@0.9.40) (2020-09-08) + **Note:** Version bump only for package @ali/lowcode-editor-preset-general - -## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.37...@ali/lowcode-editor-preset-general@1.0.6-0) (2020-09-02) + +## [0.9.39](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.38...@ali/lowcode-editor-preset-general@0.9.39) (2020-09-03) + + +**Note:** Version bump only for package @ali/lowcode-editor-preset-general + + +## [0.9.38](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.37...@ali/lowcode-editor-preset-general@0.9.38) (2020-09-03) + + ### Bug Fixes @@ -57,10 +73,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-editor-preset-general ->>>>>>> master ## [0.9.33](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.32...@ali/lowcode-editor-preset-general@0.9.33) (2020-08-20) ->>>>>>> master @@ -136,10 +150,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-editor-preset-general ->>>>>>> master ## [0.9.28](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.27...@ali/lowcode-editor-preset-general@0.9.28) (2020-08-14) ->>>>>>> master diff --git a/packages/editor-preset-vision/CHANGELOG.md b/packages/editor-preset-vision/CHANGELOG.md index 86cb46b24..32b810d5e 100644 --- a/packages/editor-preset-vision/CHANGELOG.md +++ b/packages/editor-preset-vision/CHANGELOG.md @@ -6,14 +6,24 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@1.0.6-0...@ali/lowcode-editor-preset-vision@1.0.7-0) (2020-09-02) - - - **Note:** Version bump only for package @ali/lowcode-editor-preset-vision ## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.54...@ali/lowcode-editor-preset-vision@1.0.6-0) (2020-09-02) + +## [0.8.57](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.56...@ali/lowcode-editor-preset-vision@0.8.57) (2020-09-08) + + +### Bug Fixes + +* 移除 isInSimulator 函数 ([6370889](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6370889)) +* 补全 packageName, 否则在组件面板会被隐藏 ([88e5008](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/88e5008)) + + + +## [0.8.56](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.55...@ali/lowcode-editor-preset-vision@0.8.56) (2020-09-03) + ### Bug Fixes @@ -23,6 +33,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline + +## [0.8.55](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.54...@ali/lowcode-editor-preset-vision@0.8.55) (2020-09-03) ## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@1.0.4-0...@ali/lowcode-editor-preset-vision@1.0.5-0) (2020-08-20) @@ -41,7 +53,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ## [1.0.3-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@1.0.2-0...@ali/lowcode-editor-preset-vision@1.0.3-0) (2020-08-20) -======= ## [0.8.54](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.53...@ali/lowcode-editor-preset-vision@0.8.54) (2020-08-27) @@ -104,7 +115,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ->>>>>>> master ## [0.8.49](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.48...@ali/lowcode-editor-preset-vision@0.8.49) (2020-08-19) @@ -170,7 +180,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ## [0.8.44](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.43...@ali/lowcode-editor-preset-vision@0.8.44) (2020-08-14) ->>>>>>> master diff --git a/packages/editor-preset-vision/src/bundle/bundle.ts b/packages/editor-preset-vision/src/bundle/bundle.ts index 841300df0..68fde2ea5 100644 --- a/packages/editor-preset-vision/src/bundle/bundle.ts +++ b/packages/editor-preset-vision/src/bundle/bundle.ts @@ -134,7 +134,7 @@ export default class Bundle { */ if (bundles.length >= 2) { const prototype = bundles[0]; - const metadata = upgradeMetadata(prototype.options); + const metadata = upgradeMetadata({ ...prototype.options, packageName: prototype.packageName }); prototype.meta = designer.createComponentMeta(metadata); const prototypeView = bundles[1]; prototype.setView(prototypeView); diff --git a/packages/editor-preset-vision/src/bundle/prototype.ts b/packages/editor-preset-vision/src/bundle/prototype.ts index 8b318fc2f..b91554240 100644 --- a/packages/editor-preset-vision/src/bundle/prototype.ts +++ b/packages/editor-preset-vision/src/bundle/prototype.ts @@ -1,5 +1,5 @@ import { ComponentType, ReactElement, Component, FunctionComponent } from 'react'; -import { ComponentMetadata, FieldConfig, InitialItem, FilterItem, AutorunItem, isI18nData } from '@ali/lowcode-types'; +import { ComponentMetadata, FieldConfig, InitialItem, FilterItem, AutorunItem } from '@ali/lowcode-types'; import { ComponentMeta, addBuiltinComponentAction, @@ -7,6 +7,7 @@ import { registerMetadataTransducer, TransformStage, } from '@ali/lowcode-designer'; +import { intl } from '@ali/lowcode-editor-core'; import { OldPropConfig, OldPrototypeConfig, @@ -15,7 +16,7 @@ import { upgradePropConfig, upgradeConfigure, } from './upgrade-metadata'; -import { intl } from '@ali/lowcode-editor-core'; + import { designer } from '../editor'; const GlobalPropsConfigure: Array<{ diff --git a/packages/editor-preset-vision/src/editor.ts b/packages/editor-preset-vision/src/editor.ts index a255ded50..96ecf7229 100644 --- a/packages/editor-preset-vision/src/editor.ts +++ b/packages/editor-preset-vision/src/editor.ts @@ -26,21 +26,10 @@ export const designer = new Designer({ editor }); editor.set(Designer, designer); editor.set('designer', designer); -let nodeCache: any = {}; designer.project.onCurrentDocumentChange((doc) => { - nodeCache = {}; - doc.nodesMap.forEach((node) => { - nodeCache[node.id] = node; - }); doc.onRendererReady(() => { bus.emit(VE_EVENTS.VE_PAGE_PAGE_READY); }); - doc.onNodeCreate((node) => { - nodeCache[node.id] = node; - }); - doc.onNodeDestroy((node) => { - delete nodeCache[node.id]; - }); }); interface Variable { @@ -89,6 +78,18 @@ function upgradePropsReducer(props: any) { // 升级 Props designer.addPropsReducer(upgradePropsReducer, TransformStage.Upgrade); +function getCurrentFieldIds() { + const fieldIds: any = []; + const nodesMap = designer?.currentDocument?.nodesMap || new Map(); + nodesMap.forEach((curNode: any) => { + const fieldId = nodesMap?.get(curNode.id)?.getPropValue('fieldId'); + if (fieldId) { + fieldIds.push(fieldId); + } + }); + return fieldIds; +} + // 节点 props 初始化 designer.addPropsReducer((props, node) => { // run initials @@ -96,18 +97,10 @@ designer.addPropsReducer((props, node) => { ...props, }; if (newProps.fieldId) { - const fieldIds: any = []; - Object.keys(nodeCache).forEach(nodeId => { - if (nodeId === node.id) { - return; - } - const fieldId = nodeCache[nodeId].getPropValue('fieldId'); - if (fieldId) { - fieldIds.push(fieldId); - } - }); + const fieldIds = getCurrentFieldIds(); + // 全局的关闭 uniqueIdChecker 信号,在 ve-utils 中实现 - if (fieldIds.indexOf(props.fieldId) >= 0 && !window.__disable_unique_id_checker__) { + if (fieldIds.indexOf(props.fieldId) >= 0 && !(window as any).__disable_unique_id_checker__) { newProps.fieldId = undefined; } } diff --git a/packages/editor-setters/CHANGELOG.md b/packages/editor-setters/CHANGELOG.md index e425a44a4..4a7538d89 100644 --- a/packages/editor-setters/CHANGELOG.md +++ b/packages/editor-setters/CHANGELOG.md @@ -3,16 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.6-0...@ali/lowcode-editor-setters@1.0.7-0) (2020-09-02) +**Note:** Version bump only for package @ali/lowcode-editor-setters + +## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.19...@ali/lowcode-editor-setters@1.0.6-0) (2020-09-02) - + +## [0.9.21](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.20...@ali/lowcode-editor-setters@0.9.21) (2020-09-03) **Note:** Version bump only for package @ali/lowcode-editor-setters - -## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.19...@ali/lowcode-editor-setters@1.0.6-0) (2020-09-02) + +## [0.9.20](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.19...@ali/lowcode-editor-setters@0.9.20) (2020-09-03) + ### Bug Fixes @@ -111,7 +117,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.14.0...@ali/lowcode-editor-setters@1.0.0) (2020-08-17) ## [0.9.16](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.15...@ali/lowcode-editor-setters@0.9.16) (2020-08-19) ->>>>>>> master diff --git a/packages/editor-skeleton/CHANGELOG.md b/packages/editor-skeleton/CHANGELOG.md index 2deae1e92..36147f732 100644 --- a/packages/editor-skeleton/CHANGELOG.md +++ b/packages/editor-skeleton/CHANGELOG.md @@ -6,13 +6,27 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@1.0.6-0...@ali/lowcode-editor-skeleton@1.0.7-0) (2020-09-02) +**Note:** Version bump only for package @ali/lowcode-editor-skeleton + +## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.8.58...@ali/lowcode-editor-skeleton@1.0.6-0) (2020-09-02) + + + +## [0.8.61](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.8.60...@ali/lowcode-editor-skeleton@0.8.61) (2020-09-08) + +**Note:** Version bump only for package @ali/lowcode-editor-skeleton + + +## [0.8.60](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.8.59...@ali/lowcode-editor-skeleton@0.8.60) (2020-09-03) + **Note:** Version bump only for package @ali/lowcode-editor-skeleton - -## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.8.58...@ali/lowcode-editor-skeleton@1.0.6-0) (2020-09-02) + +## [0.8.59](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.8.58...@ali/lowcode-editor-skeleton@0.8.59) (2020-09-03) + ### Bug Fixes @@ -75,10 +89,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-editor-skeleton ->>>>>>> master ## [0.8.54](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.8.53...@ali/lowcode-editor-skeleton@0.8.54) (2020-08-20) ->>>>>>> master diff --git a/packages/material-parser/CHANGELOG.md b/packages/material-parser/CHANGELOG.md index 8c5bf393c..af2ebc4c8 100644 --- a/packages/material-parser/CHANGELOG.md +++ b/packages/material-parser/CHANGELOG.md @@ -202,41 +202,32 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Bug Fixes -<<<<<<< HEAD * 🐛 fix bug of transforming type ([ebbe58d](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ebbe58d)) * 🐛 fix bug of validate schema ([3f97523](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3f97523)) -======= * 🐛 fix bug of transforming type ([ebbe58d](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ebbe58df70f047f4b5fe367ac4b4a08de8a65e5d)) * 🐛 fix bug of validate schema ([3f97523](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3f975232c7cd551bc9c74962095dcc9b127af489)) ->>>>>>> df955e1db90ff104cd11160def80113cfd6faccc ### Code Refactoring -<<<<<<< HEAD * 💡 refactor with react-docgen ([64c9daa](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/64c9daa)) -======= * 💡 refactor with react-docgen ([64c9daa](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/64c9daa1f451fdfeab2777e4beefc5d5e1890ba1)) ->>>>>>> df955e1db90ff104cd11160def80113cfd6faccc ### Features -<<<<<<< HEAD * complete component protocol json schema & validate method ([3df360d](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3df360d)) * immigrate aimake materialin ([44ac85f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/44ac85f)) * import react-docgen to parse propTypes ([6e66168](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6e66168)) * remove -p tslint.json for test ([6d013e1](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6d013e1)) * remove useless codes & modify generator ([dcd1b33](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/dcd1b33)) * support multiple exported components ([db1b6de](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/db1b6de)) -======= * complete component protocol json schema & validate method ([3df360d](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3df360de85d425b2926ea50ff26a8df27ec36a78)) * immigrate aimake materialin ([44ac85f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/44ac85f8a6a35bcd50f2e2b74a022e3cebe3cdef)) * import react-docgen to parse propTypes ([6e66168](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6e661686e4693e69279c496f3be1dd173703c55e)) * remove -p tslint.json for test ([6d013e1](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6d013e18f93bad5647cb9ea0a497336f64e1459a)) * remove useless codes & modify generator ([dcd1b33](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/dcd1b33d3bf8bdf5577dcc980608d9eac8d99372)) * support multiple exported components ([db1b6de](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/db1b6deaca256b0d107fe607de6cd0fc90517a9c)) ->>>>>>> df955e1db90ff104cd11160def80113cfd6faccc ### BREAKING CHANGES diff --git a/packages/plugin-components-pane/CHANGELOG.md b/packages/plugin-components-pane/CHANGELOG.md index b93be3466..d956123ea 100644 --- a/packages/plugin-components-pane/CHANGELOG.md +++ b/packages/plugin-components-pane/CHANGELOG.md @@ -6,13 +6,29 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@1.0.6-0...@ali/lowcode-plugin-components-pane@1.0.7-0) (2020-09-02) +**Note:** Version bump only for package @ali/lowcode-plugin-components-pane + +## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.8.54...@ali/lowcode-plugin-components-pane@1.0.6-0) (2020-09-02) + + +## [0.8.57](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.8.56...@ali/lowcode-plugin-components-pane@0.8.57) (2020-09-08) + **Note:** Version bump only for package @ali/lowcode-plugin-components-pane - -## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.8.54...@ali/lowcode-plugin-components-pane@1.0.6-0) (2020-09-02) + +## [0.8.56](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.8.55...@ali/lowcode-plugin-components-pane@0.8.56) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-plugin-components-pane + + +## [0.8.55](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.8.54...@ali/lowcode-plugin-components-pane@0.8.55) (2020-09-03) + ### Bug Fixes @@ -57,10 +73,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-plugin-components-pane ->>>>>>> master ## [0.8.50](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.8.49...@ali/lowcode-plugin-components-pane@0.8.50) (2020-08-20) ->>>>>>> master @@ -133,10 +147,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-plugin-components-pane ->>>>>>> master ## [0.8.45](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.8.44...@ali/lowcode-plugin-components-pane@0.8.45) (2020-08-14) ->>>>>>> master diff --git a/packages/plugin-components-pane/package.json b/packages/plugin-components-pane/package.json index fd27716b6..9aa7e13b7 100644 --- a/packages/plugin-components-pane/package.json +++ b/packages/plugin-components-pane/package.json @@ -20,10 +20,9 @@ ], "author": "xiayang.xy", "dependencies": { - "@ali/lowcode-designer": "^1.0.7-0", - "@ali/lowcode-editor-core": "^1.0.7-0", - "@ali/lowcode-types": "^1.0.7-0", - "@ali/ve-component-list": "^1.1.1", + "@ali/lowcode-designer": "^1.0.8-0", + "@ali/lowcode-editor-core": "^1.0.8-0", + "@ali/lowcode-types": "^1.0.8-0", "@alifd/next": "^1.19.19", "react": "^16.8.1" }, diff --git a/packages/plugin-components-pane/src/components/base/index.less b/packages/plugin-components-pane/src/components/base/index.less new file mode 100644 index 000000000..d257a0cbe --- /dev/null +++ b/packages/plugin-components-pane/src/components/base/index.less @@ -0,0 +1,116 @@ +@import "~@ali/ve-less-variables/index.less"; + +.ve-component-list { + position: absolute; + top: 45px; + right: 0; + bottom: 0; + left: 0; + .ve-component-list-head { + height: 56px; + padding: 12px; + border-bottom: 1px solid var(--color-line-normal, rgba(31, 56, 88, 0.1)); + .ve-search-control { + width: 256px; + height: 32px; + margin: 0; + } + } + .ve-component-list-body { + display: flex; + height: 100%; + overflow: auto; + .ve-component-list-empty { + width: 100%; + padding: 20px; + text-align: center; + &.kuma-empty-data.normal .kuma-empty-data-icon { + width: 50px; + height: 50px; + background-size: 100% 100%; + display: inline-block; + } + } + .component-description-item-icon-group { + display: flex; + justify-content: flex-start; + align-items: center; + .component-description-item-icon { + margin-left: 4px; + &.tag { + display: flex; + justify-content: center; + align-items: center; + background: rgba(249, 189, 15, 0.1); + color: #ff6f00; + font-size: 12px; + width: 48px; + height: 24px; + } + } + icon { + position: relative; + font-size: 14px; + cursor: pointer; + color: rgba(31, 56, 88, 0.4); + transition: color @transition-duration @transition-ease; + &:hover { + color: rgba(31, 56, 88, 0.6); + } + a { + position: absolute; + left: 0; + top: 0; + display: inline-block; + width: 14px; + height: 14px; + } + } + } + &.small { + height: calc(100% - 56px - 48px); + } + &.medium { + height: calc(100% - 56px); + } + &.large { + height: calc(100% - 48px); + } + } + .ve-component-list-foot { + display: flex; + justify-content: center; + align-items: center; + position: absolute; + bottom: 0; + .btn { + margin-right: 8px; + flex: 1; + &:last-child { + margin-right: 0; + } + } + .kuma-button-primary { + background-color: var(--color-brand, @brand-color-1); + border-color: var(--color-brand, @brand-color-1); + border-radius: @global-border-radius; + color: var(--color-text-reverse, @white-alpha-2); + transition: background-color @transition-duration @transition-ease; + &:hover { + background-color: var(--color-brand-dark, @brand-color-3); + border-color: var(--color-brand-dark, @brand-color-3); + transition: background-color @transition-duration @transition-ease; + } + } + &.exist { + width: 100%; + height: 48px; + border-top: 1px solid var(--color-line-normal, rgba(31, 56, 88, 0.1)); + background: #fff; + padding: 0 12px; + } + } + ::-webkit-scrollbar { + display: none; + } +} diff --git a/packages/plugin-components-pane/src/components/base/index.tsx b/packages/plugin-components-pane/src/components/base/index.tsx new file mode 100644 index 000000000..9c62a26cd --- /dev/null +++ b/packages/plugin-components-pane/src/components/base/index.tsx @@ -0,0 +1,258 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { Search, Box } from '@alifd/next'; +import Button from '../button'; +import Card from '../card'; +import $i18n from '../../i18n/index'; +import { searchComponent, builtinSearchMap } from '../../utils'; +import './index.less'; + +/** + * 配置元素的操作类型 + * Draggable:可拖拽 + * Clickable:可点击 + * All:可拖拽也可点击 + */ +export const AdditiveType = { + Draggable: 'additive-drag', + Clickable: 'additive-click', + All: 'additive', +}; + +class Base extends React.Component { + static propTypes = { + metaData: PropTypes.array, + className: PropTypes.string, + registerAdditive: PropTypes.func, + actions: PropTypes.array, + getComponentInfo: PropTypes.func, + enableSearch: PropTypes.bool, + placeholder: PropTypes.string, + }; + + static defaultProps = { + metaData: [], + registerAdditive: () => {}, + className: '', + renderCustomSnippet: null, + actions: [], + getComponentInfo: null, + enableSearch: false, + enableCard: true, + enableReport: true, + placeholder: '', + }; + + state = { + searchText: '', + currentCard: null, + target: null, + currentCardImage: '', + }; + + shell = null; + isEmpty = false; + mode = 'advance'; + searchMap = {}; + timer = null; + isMouseEnterCard = false; + + + UNSAFE_componentWillMount() { + // TODO get remote search map + this.searchMap = builtinSearchMap; + } + + hasActions() { + const { actions } = this.props; + if (!actions || !Array.isArray(actions) || !actions.length) { + return false; + } + return true; + } + + onSearch(val) { + this.setState({ + searchText: val, + currentCard: null, // 清空卡片 + }); + } + + normalizeBundle(mode) { + const { metaData } = this.props; + const { searchText = '' } = this.state; + const groupList = metaData.filter((comp, index) => { + const { title = '', componentName = '', id = '' } = comp; + if (!id) { + comp.id = `${comp.componentName}_${index}`; + } + const query = searchText.toLowerCase(); + return ( + !![title, componentName].find( + (it) => it.toLowerCase().indexOf(query) > -1 + ) || !!searchComponent(title, query, this.searchMap) + ); + }); + + if (mode === 'simple') { + return groupList; + } + + const bundle = {}; + // 按一定顺序排列 + groupList.forEach((m) => { + const c = m.category || 'Others'; + if (!bundle[c]) { + bundle[c] = []; + } + bundle[c].push(m); + }); + return bundle; + } + + renderEmptyData() { + this.isEmpty = true; + return ( + + +
+
暂无组件,请在物料站点添加
+
+
+ ); + } + + renderHeader() { + const { placeholder } = this.props; + return ( + + ); + } + + renderActions() { + const { actions = [] } = this.props; + if (!this.hasActions()) { + return null; + } + // const len = actions.length; + // TODO:len = 1:只有一个主按钮;len = 2:一个主按钮、一个次按钮;len >=3:一个主按钮、一个次按钮、其余放在按钮组里; + return actions.map((action, idx) => { + return ( + + ); + }); + } + + renderBundle() { + const { metaData } = this.props; + if (!metaData || !Array.isArray(metaData) || !metaData.length) { + return this.renderEmptyData(); + } + const bundle = this.normalizeBundle(this.mode); + if (!Object.keys(bundle).length || (Array.isArray(bundle) && bundle.length === 0)) { + return this.renderEmptyData(); + } + this.isEmpty = false; + return this.getBundle ? this.getBundle(bundle) : this.renderEmptyData(); + } + + renderCard() { + const { currentCard, target, currentCardImage } = this.state; + const { getComponentInfo } = this.props; + + if (!currentCard || !getComponentInfo) return null; + + return ( + { + this.setState({ currentCard: null }); + this.isMouseEnterCard = false; + }} + offset={{ + top: 10, + left: 10, + }} + onMouseEnter={() => { + this.isMouseEnterCard = true; + }} + /> + ); + } + + render() { + const { + enableSearch, + className, + registerAdditive = () => { + + }, + } = this.props; + let bodyExtraClass = ''; + if (this.hasActions() && enableSearch) { + bodyExtraClass = 'small'; + } else if (!this.hasActions() && enableSearch) { + bodyExtraClass = 'medium'; + } else if (this.hasActions() && !enableSearch) { + bodyExtraClass = 'large'; + } else { + bodyExtraClass = ''; + } + + return ( +
+ {enableSearch ? ( +
+ {this.renderHeader()} +
+ ) : null} +
{ + if (this.shell || !shell || this.isEmpty) { + return; + } + if (!this.shell) { + this.shell = shell; + } + registerAdditive(shell); + }} + > + {this.renderBundle()} +
+
+ {this.renderActions()} +
+ {this.renderCard ? this.renderCard() : null} +
+ ); + } +} + +export default Base; diff --git a/packages/plugin-components-pane/src/components/button/index.less b/packages/plugin-components-pane/src/components/button/index.less new file mode 100644 index 000000000..ef62922e6 --- /dev/null +++ b/packages/plugin-components-pane/src/components/button/index.less @@ -0,0 +1,18 @@ +.ve-component-list { + .kuma-button-outline { + border-color: #0079f2; + color: #0079f2; + &:hover { + border-color: #0079f2; + color: #0079f2; + background-color: #f0f7ff; + } + &.kuma-button-danger { + border-color: #f04631; + color: #f04631; + &:hover { + background-color: rgba(240, 70, 49, 0.06); + } + } + } +} diff --git a/packages/plugin-components-pane/src/components/button/index.tsx b/packages/plugin-components-pane/src/components/button/index.tsx new file mode 100644 index 000000000..929915344 --- /dev/null +++ b/packages/plugin-components-pane/src/components/button/index.tsx @@ -0,0 +1,22 @@ +import { Button } from '@ali/vu-uxcore-legao-design'; +import './index.less'; + +const MyButton = (props) => { + const { action, componentPrototype, type, className } = props; + return ( + + ); +}; + +export default MyButton; diff --git a/packages/plugin-components-pane/src/components/card/index.less b/packages/plugin-components-pane/src/components/card/index.less new file mode 100644 index 000000000..00d7960eb --- /dev/null +++ b/packages/plugin-components-pane/src/components/card/index.less @@ -0,0 +1,130 @@ +@import "~@ali/ve-less-variables/index.less"; + +.ve-card-wrapper { + width: 320px; + max-height: 360px; + overflow: auto; + justify-content: center; + + &.ve-card-wrapper-loading { + display: flex; + justify-content: center; + text-align: center; + overflow: hidden; + } + + .ve-card-top { + height: 186px; + background: rgba(31, 56, 88, 0.1); + padding: 16px; + + .ve-card-title { + display: flex; + align-items: center; + padding-bottom: 12px; + position: relative; + height: 31px; + color: rgba(0, 0, 0, 0.8); + + .title { + line-height: 22px; + font-size: 16px; + } + + .version { + margin-left: 8px; + font-size: 12px; + line-height: 22px; + color: rgba(31, 56, 88, 0.4); + } + } + + .ve-card-image-wrapper { + background-color: #fff; + .ve-card-image { + max-width: 100%; + height: 120px; + margin: 0 auto; + display: block; + padding: 10px; + } + } + } + + .ve-card-bottom { + padding: 8px 16px 16px 16px; + .ve-card-description { + user-select: text; + text-align: left; + line-height: 18px; + font-size: 12px; + color: rgba(0, 0, 0, 0.6); + letter-spacing: 0; + line-height: 18px; + width: 280px; + + p { + margin-bottom: 8px; + } + + p:last-child { + margin-bottom: 0; + } + } + + .ve-operation-container { + margin-top: 12px; + position: relative; + .actions { + margin-top: 16px; + } + } + } + + .ve-operation-item { + color: @brand-color-1; + cursor: pointer; + margin-right: 8px; + } + + .ve-operation-delete { + position: absolute; + top: 0; + right: 0; + } + + .ve-card-more-operation { + display: flex; + justify-content: space-between; + > a { + cursor: pointer; + } + } + + .ve-loading-icon { + animation: spining 0.9s infinite linear; + } + .ve-loading-content { + padding: 10px; + text-align: center; + } + + .ve-card-action { + padding: 0 8px !important; + margin-right: 8px; + } +} + +.ve-component-list { + .vu-layer { + border-radius: 4px !important; + .vu-layer-content { + padding-top: 0 !important; + } + } + + .vu-layer .vu-layer-close { + right: 9px !important; + top: 9px !important; + } +} diff --git a/packages/plugin-components-pane/src/components/card/index.tsx b/packages/plugin-components-pane/src/components/card/index.tsx new file mode 100644 index 000000000..c03020ca3 --- /dev/null +++ b/packages/plugin-components-pane/src/components/card/index.tsx @@ -0,0 +1,141 @@ +import React from 'react'; +import Layer from '@ali/vu-layer'; +import { Icon } from '@alifd/next'; +import $i18n from '../../i18n/index'; +import Button from '../button'; +import './index.less'; + +export default class Card extends React.Component { + static propTypes = {}; + + constructor(props) { + super(props); + + this.state = { + isLoading: true, + errorMsg: false, + componentInfo: {}, + }; + } + + componentDidMount() { + if (!this.props.getComponentInfo) return; + this.loadComponentInfo(this.props.componentPrototype); + } + + UNSAFE_componentWillReceiveProps(nextProps) { + if (nextProps.componentPrototype !== this.props.componentPrototype) { + // 延迟执行数据加载和渲染,等 props 更新之后 + this.loadComponentInfo(nextProps.componentPrototype); + } + } + + loadComponentInfo(componentPrototype) { + if (!this.props.getComponentInfo) return; + this.setState({ isLoading: true }); + this.props + .getComponentInfo(componentPrototype) + .then((componentInfo) => { + this.setState({ + componentInfo, + isLoading: false, + }); + }) + .catch((e) => { + this.setState({ errorMsg: e.message }); + console.error(e); + }); + } + + render() { + const { componentPrototype, subTitle, customImage } = this.props; + const { componentInfo } = this.state; + + const loadingContent = this.state.errorMsg ? ( +
+
{this.state.errorMsg}
+
+ ) : ( +
+ +
+ {$i18n.get({ id: 'trunkPaneLoading', dm: '加载中...' })} +
+
+ ); + + const { + title, + version, + image = 'https://img.alicdn.com/tfs/TB1XHG6ehrI8KJjy0FpXXb5hVXa-740-608.png', + desc, + detailUrl, + actions, + } = componentInfo; + + let layerContent = null; + const cardTitle = subTitle && !subTitle.includes(title) ? `${title}(${subTitle})` : title; + + if (this.state.isLoading) { + layerContent = ( +
+ {loadingContent} +
+ ); + } else { + layerContent = ( +
+
+
+ {cardTitle} + {version} +
+
+ {cardTitle} +
+
+
+
+

{desc}

+
+
+ {detailUrl ? ( + + {$i18n.get({ + id: 'trunkPaneDetailedDocumentation', + dm: '详细文档', + })} + + ) : null} +
+ { + actions ? actions.map((action, idx) => { + return ( +
+
+
+
+ ); + } + + return ( + + {layerContent} + + ); + } +} diff --git a/packages/plugin-components-pane/src/components/component-list/index.less b/packages/plugin-components-pane/src/components/component-list/index.less new file mode 100644 index 000000000..62f60096f --- /dev/null +++ b/packages/plugin-components-pane/src/components/component-list/index.less @@ -0,0 +1,117 @@ +@import "~@ali/ve-less-variables/index.less"; + +@text-color-active: #0079f2; + +.ve-component-list { + .ve-component-list-body { + .ve-component-list-sidebar { + flex: 0 0 110px; + width: 110px; + // height: 100%; + padding-top: 11px; + border-right: 1px solid var(--color-line-normal, rgba(31, 56, 88, 0.1)); + overflow: auto; + .ve-component-list-navigator { + .navigator-group { + margin-bottom: 8px; + & > div { + display: flex; + align-items: center; + width: 100%; + } + .navigator-group-head { + padding: 0px 12px; + color: @dark-alpha-2; + .navigator-group-title { + padding: 4px 0; + width: 100%; + line-height: 16px; + font-size: @fontSize-5; + font-weight: 700; + border-bottom: 1px solid + var(--color-line-normal, rgba(31, 56, 88, 0.1)); + } + } + .navigator-group-item { + height: 32px; + padding: 8px 12px; + color: #666666; + cursor: pointer; + .navigator-group-item-title { + font-size: @fontSize-5; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + text-align: left; + } + &:hover { + color: @text-color-active; + } + &.active { + background: rgba(0, 121, 242, 0.1); + color: @text-color-active; + border-right: 2px solid @text-color-active; + } + } + } + } + } + .ve-component-list-content { + flex: 1; + width: 250px; + // height: 100%; + overflow-y: auto; + overflow-x: hidden; + .component-description-list { + padding: 10px 4px; + .component-description-item { + padding-bottom: 24px; + .component-description-item-header { + display: flex; + justify-content: flex-start; + align-items: center; + .component-description-item-title { + font-family: @font-family; + font-size: @fontSize-5; + font-weight: 700; + color: @text-color; + line-height: 20px; + padding-left: 8px; + } + .component-description-item-icon-group { + display: flex; + justify-content: flex-start; + align-items: center; + .component-description-item-icon { + margin-left: 4px; + } + icon { + position: relative; + font-size: 14px; + cursor: pointer; + color: rgba(31, 56, 88, 0.4); + transition: color @transition-duration @transition-ease; + &:hover { + color: rgba(31, 56, 88, 0.6); + } + a { + position: absolute; + left: 0; + top: 0; + display: inline-block; + width: 14px; + height: 14px; + } + } + } + } + .component-description-item-snippets { + display: flex; + justify-content: flex-start; + flex-flow: row wrap; + } + } + } + } + } +} diff --git a/packages/plugin-components-pane/src/components/component-list/index.tsx b/packages/plugin-components-pane/src/components/component-list/index.tsx new file mode 100644 index 000000000..79f0425bc --- /dev/null +++ b/packages/plugin-components-pane/src/components/component-list/index.tsx @@ -0,0 +1,278 @@ +import Base, { AdditiveType } from '../base/index'; +import Snippet from '../snippet'; +import './index.less'; + +// 滚动事件触发灵敏度 +const OFFSET_ACCURCY = 25; + +const categoryMap = { + General: '常用', + Navigation: '导航', + DataEntry: '输入', + DataDisplay: '展示', + Feedback: '反馈', + Util: '工具', + Chart: '图表', + Others: '其他', +}; + +export default class ComponentList extends Base { + static displayName = 'ComponentList'; + + descRefList = new Map(); + navRefList = new Map(); + descHeightList = new Map(); + snippetMap = new Map(); + currentScrollHeight = 0; + scrollFlag = true; + scroll; + scrollTimer; + state = { + selected: '', + searchText: '', + currentCard: null, + currentCardImage: '', + }; + + componentDidMount() { + setTimeout(() => { + this.calDescHeightList(); + + // mock 滚动结束事件 + if (this.scroll) { + this.scroll.addEventListener('scroll', this.handleScrollEnd); + } + }, 20); + const bundle = this.normalizeBundle(); + if (!bundle) { + return; + } + const cats = Object.keys(bundle); + if (cats.length > 0) { + const k = cats[0]; + const comps = bundle[k]; + if (!comps || !Array.isArray(comps) || !comps.length) { + return; + } + this.setState({ selected: comps[0].id }); + } + } + + componentWillUnmount() { + if (this.scroll) { + this.scroll.removeEventListener('scroll', this.handleScrollEnd); + } + } + + handleScrollEnd = () => { + clearTimeout(this.scrollTimer); + this.scrollTimer = setTimeout(() => { + // 滚动结束时归位 + this.scrollFlag = true; + }, 100); + }; + + toggleComponent(id) { + const element = this.descRefList.get(id); + // 切换组件时滚动事件回调不可用 + this.scrollFlag = false; + element.scrollIntoView(); + this.setState({ selected: id }); + } + + handleScroll(e) { + // 清空卡片 + if (this.state.currentCard) { + this.setState({ currentCard: null }); + } + clearTimeout(this.timer); + this.timer = null; + + if (!this.scrollFlag) { + return; + } + const element = e.target; + const { scrollTop } = element; + + // 延迟处理 + if (Math.abs(scrollTop - this.currentScrollHeight) < OFFSET_ACCURCY) { + return; + } + this.currentScrollHeight = scrollTop; + + // 处理导航块滚动高亮效果 + const heightList = [...this.descHeightList.entries()]; + let selected; + // 当在顶部 + if (scrollTop >= 0 && scrollTop < heightList[0][1]) { + selected = heightList[0][0]; + } else if (scrollTop >= heightList[heightList.length - 1][1]) { + // 底部 + selected = heightList[heightList.length - 1][0]; + } else { + // 当在中部 + for (let i = 0; i < heightList.length - 2; i++) { + const height1 = heightList[i][1]; + const height2 = heightList[i + 1][1]; + if (scrollTop > height1 && scrollTop < height2) { + selected = heightList[i + 1][0]; + } + } + } + this.fixSideBarView(selected); + this.setState({ selected }); + } + + // 导航高亮块超出视口时滚动 + fixSideBarView(selected) { + const nav = this.navRefList.get(selected); + if (nav) { + nav.scrollIntoView({ block: 'center' }); + } + } + + calDescHeightList() { + let height = 0; + this.descRefList.forEach((ele, key) => { + if (!ele) { + return; + } + height += ele.clientHeight; + this.descHeightList.set(key, height); + }); + } + + renderNavigator(bundle) { + return ( +
+ {Object.keys(bundle).map((c) => { + const catTitle = categoryMap[c] || c; + const catData = bundle[c]; + return this.renderNavigatorGroup(catTitle, catData); + })} +
+ ); + } + + renderNavigatorGroup(title, metaData) { + const { selected } = this.state; + if (!metaData) { + return null; + } + return ( +
+
+
{title}
+
+ {metaData.map((comp) => ( +
{ + this.navRefList.set(comp.id, item); + }} + onClick={() => this.toggleComponent(comp.id)} + > + {comp.title} +
+ ))} +
+ ); + } + + renderComponentDescriptionList(bundle) { + const { renderCustomSnippet = '', enableCard = true } = this.props; + return ( +
+ {Object.keys(bundle).map((cat) => { + const catData = bundle[cat]; + if (!catData) { + return null; + } + return catData.map((comp) => ( +
{ + this.descRefList.set(comp.id, item); + }} + > +
+ {comp.title ? ( +
+ {comp.title} +
+ ) : null} +
+
+
+ {comp.snippets && + comp.snippets.map((snippet, idx) => ( +
{ + this.snippetMap.set(`${comp.id}-${idx}`, i); + }} + onMouseEnter={() => { + if (!enableCard) { + return; + } + this.timer = setTimeout(() => { + this.setState({ + currentCard: comp, + target: this.snippetMap.get(`${comp.id}-${idx}`), + currentCardImage: snippet.thumbnail, + }); + this.timer = null; + }, 1000); + }} + onMouseLeave={() => { + if (!enableCard) { + return; + } + clearTimeout(this.timer); + this.timer = null; + setTimeout(() => { + if (this.isMouseEnterCard) { + return; + } + this.setState({ currentCard: null }); + }, 200); + }} + > + +
+ ))} +
+
+ )); + })} +
+ ); + } + + getBundle(bundle) { + return [ +
+ {this.renderNavigator(bundle)} +
, +
this.handleScroll(e)} + ref={(scroll) => { this.scroll = scroll; }} + > + {this.renderComponentDescriptionList(bundle)} +
, + ]; + } +} diff --git a/packages/plugin-components-pane/src/components/snippet/index.less b/packages/plugin-components-pane/src/components/snippet/index.less new file mode 100644 index 000000000..6c3809bfa --- /dev/null +++ b/packages/plugin-components-pane/src/components/snippet/index.less @@ -0,0 +1,120 @@ +@import "~@ali/ve-less-variables/index.less"; + +@text-color-active: #0079f2; + +.component-description-item-snippet { + position: relative; + &.small { + width: 64px; + height: 66px; + .snippet-thumbnail { + height: 40px; + img, + .icon { + max-width: 56px; + max-height: 32px; + } + } + } + &.large { + width: 132px; + height: 126px; + .snippet-thumbnail { + height: 100px; + img, + .icon { + max-width: 116px; + max-height: 83px; + } + } + } + margin: 12px 8px 0 8px; + cursor: grab; + .snippet-title { + width: 100%; + padding: 0 4px; + font-size: @fontSize-5; + color: #666666; + text-align: center; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + } + .snippet-thumbnail { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + margin-bottom: 9px; + border-radius: @global-border-radius; + border: 1px dashed #cdd2d9; + transition: border @transition-duration @transition-ease; + img, + .icon { + width: auto; + height: auto; + } + svg { + font-size: 28px; + } + svg * { + fill: rgba(31, 56, 88, 0.6) !important; + } + } + .component-description-item-icon { + &.tag { + display: flex; + justify-content: center; + align-items: center; + background: rgba(249, 189, 15, 0.1); + color: #ff6f00; + font-size: 12px; + border-radius: 3px; + width: 48px; + height: 24px; + } + } + .engine-additive-helper { + &.left-top { + position: absolute; + left: 0; + top: 0; + } + &.right-top { + display: none; + } + icon { + position: relative; + font-size: 14px; + cursor: pointer; + color: rgba(31, 56, 88, 0.4); + transition: color @transition-duration @transition-ease; + &:hover { + color: rgba(31, 56, 88, 0.6); + } + a { + position: absolute; + left: 0; + top: 0; + display: inline-block; + width: 14px; + height: 14px; + } + } + } + &:hover { + .snippet-thumbnail { + border: 2px solid @text-color-active; + transition: border @transition-duration @transition-ease; + } + .right-top { + display: block; + position: absolute; + right: 0; + top: 0; + height: 24px; + display: flex; + align-items: center; + } + } +} diff --git a/packages/plugin-components-pane/src/components/snippet/index.tsx b/packages/plugin-components-pane/src/components/snippet/index.tsx new file mode 100644 index 000000000..a8f299659 --- /dev/null +++ b/packages/plugin-components-pane/src/components/snippet/index.tsx @@ -0,0 +1,46 @@ +import { Fragment } from 'react'; +import { Icon } from '@alifd/next'; +import { AdditiveType } from '../base'; +import './index.less'; + +const Snippet = (props) => { + const { + snippet, + renderCustomSnippet = '', + size = 'small', + actionsInLT, + actionsInRT, + } = props; + const { + thumbnail = 'https://img.alicdn.com/tfs/TB1XHG6ehrI8KJjy0FpXXb5hVXa-740-608.png', + description, + title = '未知', + } = snippet; + const snippetClassName = `component-description-item-snippet ${AdditiveType.All} ${size}`; + return ( +
+ {typeof renderCustomSnippet === 'function' ? ( + renderCustomSnippet(snippet) + ) : ( + +
+ {typeof thumbnail === 'string' && thumbnail.startsWith('http') ? ( + thumbnail + ) : ( + + )} +
+
{description || title}
+
+ {actionsInLT || null} +
+
+ {actionsInRT || null} +
+
+ )} +
+ ); +}; + +export default Snippet; diff --git a/packages/plugin-components-pane/src/i18n/index.ts b/packages/plugin-components-pane/src/i18n/index.ts new file mode 100644 index 000000000..eae0b99e3 --- /dev/null +++ b/packages/plugin-components-pane/src/i18n/index.ts @@ -0,0 +1,45 @@ +const { provideIntl, destroyIntl } = require('@ali/intl-universal'); +const strings = require('./strings'); + +let intl; +const MEDUSA_APP_NAME = 'legao-designer'; +const PSEUDO_LANGUAGE_TAG = 'pd-KV'; +const CURRENT_LANGUAGE = (window.locale || '').replace(/_/, '-') || 'zh-CN'; + +function update(language) { + destroyIntl(); + intl = provideIntl({ + locale: language, + messagesAIO: strings, + }); +} + +function get(id, variable) { + if (!intl) update(); + let string = ''; + let key = ''; + if (typeof id === 'string') { + key = id; + string = intl.formatMessage({ id }, variable); + } + if (typeof id === 'object' && id.dm) { + id.defaultMessage = id.dm; + } + key = id.id; + string = intl.formatMessage(id, variable); + if (CURRENT_LANGUAGE === PSEUDO_LANGUAGE_TAG) { + return `##@@@${key}##${MEDUSA_APP_NAME}@@@##${string}`; + } + return string; +} + +if (PSEUDO_LANGUAGE_TAG === CURRENT_LANGUAGE) { + update('en-US'); +} else { + update(CURRENT_LANGUAGE); +} + +module.exports = { + get, + update, +}; diff --git a/packages/plugin-components-pane/src/i18n/strings/en-US.json b/packages/plugin-components-pane/src/i18n/strings/en-US.json new file mode 100644 index 000000000..f6873f90d --- /dev/null +++ b/packages/plugin-components-pane/src/i18n/strings/en-US.json @@ -0,0 +1,27 @@ +{ + "trunkPaneTheComponentPrototypeView": "The component prototype view does not exist and may be caused by the following reasons:", + "trunkPaneDetailedComponentInformationIs": "Detailed component information is already printed in the Console", + "trunkPaneIsTheComponentRemoved": "Is the component removed because the component cannot find the prototype view?", + "trunkPaneLoading": "Loading...", + "trunkPaneFoundComponentNameRComponentName": "Found component name: {rComponentName} has a problem", + "trunkPaneDetailedDocumentation": "Detailed documentation", + "trunkPaneComponentComponentInfoComponentNameDeletedSuccessfully": "Component {componentInfoComponentName} deleted successfully", + "trunkPaneUpdateComponent": "Update component", + "trunkPaneComponentLibrary": "Component library", + "trunkPaneSearchComponent": "Search component", + "trunkPaneCustomize": "customize", + "trunkPaneTheComponentInQuestion": "The component in question:", + "trunkPaneComponentMarket": "Component market", + "trunkPaneUncategorized": "uncategorized", + "trunkPaneNoSearchResultsYet": "No search results yet", + "trunkPaneAll": "All", + "trunkPaneClickToTheLEGO": "Click ? to the Component Center", + "trunkPaneClickToTroubleshootThe": "Click to troubleshoot the issue", + "trunkPaneComponent": "Component", + "trunkPaneComponentCenter": "Component center", + "trunkPaneClose": "╳ Close", + "trunkPaneDetail": "Detail", + "trunkPaneEdit": "Edit", + "trunkPaneDev": "Dev", + "trunkPaneHelp": "Help" +} diff --git a/packages/plugin-components-pane/src/i18n/strings/index.ts b/packages/plugin-components-pane/src/i18n/strings/index.ts new file mode 100644 index 000000000..9b61c93e1 --- /dev/null +++ b/packages/plugin-components-pane/src/i18n/strings/index.ts @@ -0,0 +1,4 @@ +module.exports = { + 'en-US': require('./en-US.json'), + 'zh-CN': require('./zh-CN.json'), +}; diff --git a/packages/plugin-components-pane/src/i18n/strings/zh-CN.json b/packages/plugin-components-pane/src/i18n/strings/zh-CN.json new file mode 100644 index 000000000..82f52faf1 --- /dev/null +++ b/packages/plugin-components-pane/src/i18n/strings/zh-CN.json @@ -0,0 +1,26 @@ +{ + "trunkPaneAll": "全部", + "trunkPaneFoundComponentNameRComponentName": "发现组件名为:{rComponentName}存在问题", + "trunkPaneNoResultsYet": "暂无结果", + "trunkPaneUpdateComponent": "更新组件", + "trunkPaneClickToTroubleshootThe": "点击排查问题", + "trunkPaneClickToTheLEGO": "点击 ? 前往组件中心", + "trunkPaneComponentLibrary": "组件库", + "trunkPaneComponentCenter": "组件中心", + "trunkPaneDetailedComponentInformationIs": "详细的组件信息已经打印在 Console 中", + "trunkPaneTheComponentPrototypeView": "组件原型视图不存在,可能由以下原因导致:", + "trunkPaneLoading": "加载中...", + "trunkPaneTheComponentInQuestion": "存在问题的组件:", + "trunkPaneIsTheComponentRemoved": "由于该组件找不到原型视图,是否移除组件?", + "trunkPaneDetailedDocumentation": "详细文档", + "trunkPaneUncategorized": "未分类", + "trunkPaneComponentMarket": "组件市场", + "trunkPaneCustomize": "自定义", + "trunkPaneSearchComponent": "搜索组件", + "trunkPaneComponent": "组件", + "trunkPaneClose": "╳ 关闭", + "trunkPaneDetail": "详情", + "trunkPaneEdit": "编辑", + "detrunkPaneDev": "开发版", + "trunkPaneHelp": "帮助" +} diff --git a/packages/plugin-components-pane/src/index.tsx b/packages/plugin-components-pane/src/index.tsx index 40e956a43..0038bd1ce 100644 --- a/packages/plugin-components-pane/src/index.tsx +++ b/packages/plugin-components-pane/src/index.tsx @@ -1,12 +1,15 @@ import { Component, ReactNode } from 'react'; -import ComponentList, { AdditiveType } from '@ali/ve-component-list'; +import { Tab } from '@alifd/next'; +import ComponentList from './components/component-list'; +import { AdditiveType } from './components/base'; import { PluginProps } from '@ali/lowcode-types'; import { Designer } from '@ali/lowcode-designer'; import './index.scss'; export interface IState { - metaData: object[]; + metaData: Record[]; + bizComponents: Record[]; } export default class ComponentListPlugin extends Component { @@ -18,6 +21,7 @@ export default class ComponentListPlugin extends Component super(props); this.state = { metaData: [], + bizComponents: [], }; } @@ -31,7 +35,7 @@ export default class ComponentListPlugin extends Component } transformMetaData(componentList: any): any { - const metaData: object[] = []; + const metaData: Record[] = []; componentList.forEach((category: any, categoryId: number) => { if (Array.isArray(category?.children)) { category.children.forEach((comp: any, compId: number) => { @@ -61,9 +65,11 @@ export default class ComponentListPlugin extends Component const { editor } = this.props; const assets = editor.get('assets') || {}; const metaData = this.transformMetaData(assets.componentList); + const bizComponents = this.transformMetaData(assets.bizComponentList); this.setState({ metaData, + bizComponents, }); }; @@ -92,20 +98,7 @@ export default class ComponentListPlugin extends Component return; } - const click = (e: Event) => { - if ( - (e.target.tagName === 'ICON' - && e.target.parentNode - && e.target.parentNode.classList.contains('engine-additive-helper')) - || e.target.classList.contains('engine-additive-helper') - ) { - return; - } - const snippetId = getSnippetId(e.target, AdditiveType.Clickable); - if (!snippetId || !this.snippetsMap.get(snippetId)) { - - } - }; + const click = (e: Event) => { console.log(e); }; shell.addEventListener('click', click); @@ -126,15 +119,27 @@ export default class ComponentListPlugin extends Component } render(): ReactNode { - const { metaData } = this.state; + const { metaData, bizComponents } = this.state; return (
- this.registerAdditive(shell)} - enableSearch - /> + + + this.registerAdditive(shell)} + enableSearch + /> + + + this.registerAdditive(shell)} + enableSearch + /> + +
); } diff --git a/packages/plugin-components-pane/src/utils.ts b/packages/plugin-components-pane/src/utils.ts new file mode 100644 index 000000000..c8b6cbb64 --- /dev/null +++ b/packages/plugin-components-pane/src/utils.ts @@ -0,0 +1,98 @@ +export const builtinSearchMap = { + 容器: '容器、rongqi、rq、分栏、ColumnsLayout、Columns、layout、grid', + 分栏: '分栏、ColumnsLayout、Columns、layout、grid、容器、rongqi、rq、fl、fenlan', + 卡片: '卡片、card、kapian、kp', + 选项卡: '选项卡、tab、tabs、页签、xuanxiangka、xxk、yeqian、yq', + 按钮: '按钮、button、anniu、an', + 图标: '图标、icon、tubiao、tb', + 标题: '标题、title、biaoti、bt', + 图片: '图片、image、pic、picture、tupian、tp', + Dialog: '对话框、Dialog、弹框、弹出框、duihuakuang、dhk', + Drawer: '抽屉、Drawer、chouti、ct、couti', + 文本: '文本、文字、text、wenzi、wz、wenben', + 链接: '链接、link、lianjie、lj', + 链接块: '链接块、链接、link、lianjie、lj、ljk', + 表单容器: '表单容器、表单、form、biaodan、bd', + 输入框: '输入框、文本框、密码框、input、shurukuang、srk、wenbenkuang、wbk', + 数字输入框: '数字输入框、数字、输入框、Number、NumberPicker、shuzi、sz、srk、shurukuang', + 单选: '单选、radio button、radio、danxuan、dx', + 多选: '复选、复选框、多选、Checkbox、check、fuxuan、fx、dx、duoxuan', + 下拉选择: '下拉选择、Select、选择器、下拉、xiala、xl、xialaxuanze、xlxz', + 开关: '开关、switch、kaiguan、kg', + 日期: '日期选择、date、DatePicker、riqi、riqixuanz、rq、rqxz', + 日期区间: '日期区间、Cascade、date、riqiqujian、rq', + 时间选择框: '时间选择、time、TimePicker、shijian、sj、shijianxuanze、sjxz、xuanzekuang', + 上传图片: '上传图片、upload、上传、shangchuan、sc、tupian', + 上传附件: '上传附件、upload、上传、shangchuan、sc、fujian', + 树形选择: '树形选择、树型选择、树选择、tree、TreeSelect、shu、sxz、shuxingxuanze', + 级联选择: '级联选择、Cascade、Cascadeselect、级联、jilian、jl、jilianxuanze、jlxz', + 地区选择: '地区选择、city、地址、address、地区、diqu、dq、diquxuanze、dqxz', + 国家选择: '国家选择、country、国家、guojia、gj、guojiaxuanze、gjxz', + 评分: '评分、Rate、Rating、星、pingfen、pf', + 明细: '明细、table、表格、表单、form、mingxi、mx', + 穿梭框: '穿梭框、transfer、chuansuokuang、csk', + 人员搜索框: '人员搜索框、employee、人员选择、选人、xuanren、xr、renyuansousuo、ryss', + 筛选: '筛选、pickable、shaixuan、sx', + 金额输入框: '金额输入框、输入框、shurukuang、srk、money、金额、jine、je', + 金额区间: '金额区间、money、金额、jine、je', + 查询: '查询、filter、chaxun、cx', + 表格: '表格、table、biaoge、bg', + 数据文本: '数据文本、Number Info、数据、shuju、sj、shujuwenben、sjwb', + 数据趋势: '数据趋势、Number Trend、数据、shuju、sj、shujuqushi、sjqs', + 勾选框: '勾选框、复选框、check box、gouxuankuang、gxk、fuxuankuang、fxk', + 图片浏览: '图片浏览、图片预览、image、pic、picture、图片、预览、tupianyulan、tupianliulan、tupian、tp、yulan、yl', + 搜索: '搜索、搜索框、查询框、查询、search、sousuo、ss', + 树形控件: '树形控件、树组件、tree、shuzujian、shuxingkongjian、shu、szj、sxkj', + 富文本框: '富文本框、RichText、fuwenben、fwb', + 步骤: '步骤、步骤条、step、steps、buzhoutiao、buzhou、bzt、bz', + 时间轴: '时间轴、时间线、timeline、shijianzhou、shijianxian、sjz、sjx', + 菜单: '菜单、menu、caidan、cd', + 气泡提示: '气泡提示、tip、tips、balloon、气泡、qipao、qp、qipaotishi、qpts', + 面包屑: '面包屑、breadcrumb、crumb、mianbaoxie、mbx', + 日历: '日历、calendar、rili、rl', + 折叠面板: '折叠面板、collapse、折叠、zhedie、zd、zhediemianban、zdmb', + 下拉菜单: '下拉菜单、dropdown、下拉、xiala、xl、xialacaidan、xlcd、菜单、caidan、cd', + 信息提示: '信息提示、message、alert、信息、提示、警示、xinxitishi、xxts、xinxi、xx、tishi、ts、消息、xiaoxi', + 进度指示器: '进度指示器、进度条、progress、jindutiao、jdt、进度、jindu、jd', + 翻页器: '翻页器、分页器、pagination、fanyeqi、fyq、分页、fenye、fy', + 轮播图: '轮播图、图片轮播、slider、轮播、lunbo、lb、lunbotu、lbt', + 底部通栏: '底部通栏、tool bar、通栏、dibutonglan、dbtl、浮动工具条、浮动、工具条、工具、fudong、gongju、toolbar、tool bar、fd、gj', + HTML: 'html', + JSX: 'jsx', + 浮动导航: '浮动导航、nav、floatNav、fudongdaohang、fddh', + Iframe: 'Iframe', + Markdown: 'Markdown', + 区段选择器: '区段选择、滑块选择、区段、滑块、选择、Range、quduan、huakuai、xuanze、qdxz、hkxz、xz', +}; + +/** + * @param {string} title 组件名 + * @param {string} query 搜索词 + * @param {object} map 映射关系 + */ +export function searchComponent(title, query, map = {}) { + if (!title || !query || !map || !map[title]) { + return false; + } + const keys = (map[title] || '').split('、'); + return !!keys.find(key => { + if (!key) { + return false; + } + return key.indexOf(query) > -1; + }); +} + +export function debounce(func, delay) { + let timer; + return function (...args) { + if (timer) { + return; + } + timer = setTimeout(() => { + func.apply(this, args); + clearTimeout(timer); + timer = null; + }, delay); + }; +} diff --git a/packages/plugin-designer/CHANGELOG.md b/packages/plugin-designer/CHANGELOG.md index ebea4766f..32ad8d7ba 100644 --- a/packages/plugin-designer/CHANGELOG.md +++ b/packages/plugin-designer/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.9.55](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.9.54...@ali/lowcode-plugin-designer@0.9.55) (2020-09-08) ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@1.0.6-0...@ali/lowcode-plugin-designer@1.0.7-0) (2020-09-02) @@ -11,6 +13,21 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-plugin-designer + +## [0.9.54](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.9.53...@ali/lowcode-plugin-designer@0.9.54) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-plugin-designer + + +## [0.9.53](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.9.52...@ali/lowcode-plugin-designer@0.9.53) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-plugin-designer ## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.9.52...@ali/lowcode-plugin-designer@1.0.6-0) (2020-09-02) @@ -62,10 +79,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-plugin-designer ->>>>>>> master ## [0.9.48](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.9.47...@ali/lowcode-plugin-designer@0.9.48) (2020-08-20) ->>>>>>> master @@ -138,10 +153,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-plugin-designer ->>>>>>> master ## [0.9.43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.9.42...@ali/lowcode-plugin-designer@0.9.43) (2020-08-14) ->>>>>>> master diff --git a/packages/plugin-event-bind-dialog/CHANGELOG.md b/packages/plugin-event-bind-dialog/CHANGELOG.md index e8a0bb544..57d523051 100644 --- a/packages/plugin-event-bind-dialog/CHANGELOG.md +++ b/packages/plugin-event-bind-dialog/CHANGELOG.md @@ -3,16 +3,23 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-event-bind-dialog@1.0.6-0...@ali/lowcode-plugin-event-bind-dialog@1.0.7-0) (2020-09-02) - +**Note:** Version bump only for package @ali/lowcode-plugin-event-bind-dialog + +## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-event-bind-dialog@0.8.32...@ali/lowcode-plugin-event-bind-dialog@1.0.6-0) (2020-09-02) **Note:** Version bump only for package @ali/lowcode-plugin-event-bind-dialog - -## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-event-bind-dialog@0.8.32...@ali/lowcode-plugin-event-bind-dialog@1.0.6-0) (2020-09-02) + +## [0.8.34](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-event-bind-dialog@0.8.33...@ali/lowcode-plugin-event-bind-dialog@0.8.34) (2020-09-03) + + +## [0.8.33](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-event-bind-dialog@0.8.32...@ali/lowcode-plugin-event-bind-dialog@0.8.33) (2020-09-03) + ### Bug Fixes @@ -31,8 +38,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-event-bind-dialog@1.0.4-0...@ali/lowcode-plugin-event-bind-dialog@1.0.5-0) (2020-08-20) -======= -======= ## [0.8.32](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-event-bind-dialog@0.8.31...@ali/lowcode-plugin-event-bind-dialog@0.8.32) (2020-08-27) @@ -96,7 +101,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-event-bind-dialog@0.13.0...@ali/lowcode-plugin-event-bind-dialog@1.0.0) (2020-08-17) ## [0.8.29](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-event-bind-dialog@0.8.28...@ali/lowcode-plugin-event-bind-dialog@0.8.29) (2020-08-19) ->>>>>>> master diff --git a/packages/plugin-outline-pane/CHANGELOG.md b/packages/plugin-outline-pane/CHANGELOG.md index b1c2f065f..d64662608 100644 --- a/packages/plugin-outline-pane/CHANGELOG.md +++ b/packages/plugin-outline-pane/CHANGELOG.md @@ -7,6 +7,32 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@1.0.6-0...@ali/lowcode-plugin-outline-pane@1.0.7-0) (2020-09-02) + +## [0.8.61](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.8.60...@ali/lowcode-plugin-outline-pane@0.8.61) (2020-09-08) + + + + +**Note:** Version bump only for package @ali/lowcode-plugin-outline-pane + + +## [0.8.60](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.8.59...@ali/lowcode-plugin-outline-pane@0.8.60) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-plugin-outline-pane + + +## [0.8.59](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.8.58...@ali/lowcode-plugin-outline-pane@0.8.59) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-plugin-outline-pane + + +## [0.8.58](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.8.57...@ali/lowcode-plugin-outline-pane@0.8.58) (2020-08-27) **Note:** Version bump only for package @ali/lowcode-plugin-outline-pane @@ -102,10 +128,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-plugin-outline-pane ->>>>>>> master ## [0.8.49](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.8.48...@ali/lowcode-plugin-outline-pane@0.8.49) (2020-08-14) ->>>>>>> master diff --git a/packages/plugin-sample-logo/CHANGELOG.md b/packages/plugin-sample-logo/CHANGELOG.md index 7d2871265..643e13b15 100644 --- a/packages/plugin-sample-logo/CHANGELOG.md +++ b/packages/plugin-sample-logo/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.8.33](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-logo@0.8.32...@ali/lowcode-plugin-sample-logo@0.8.33) (2020-09-03) ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-logo@1.0.6-0...@ali/lowcode-plugin-sample-logo@1.0.7-0) (2020-09-02) @@ -11,6 +13,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-plugin-sample-logo + +## [0.8.32](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-logo@0.8.31...@ali/lowcode-plugin-sample-logo@0.8.32) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-plugin-sample-logo ## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-logo@0.8.31...@ali/lowcode-plugin-sample-logo@1.0.6-0) (2020-09-02) diff --git a/packages/plugin-sample-preview/CHANGELOG.md b/packages/plugin-sample-preview/CHANGELOG.md index cc228c0ad..1ec1da9cc 100644 --- a/packages/plugin-sample-preview/CHANGELOG.md +++ b/packages/plugin-sample-preview/CHANGELOG.md @@ -6,13 +6,27 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@1.0.6-0...@ali/lowcode-plugin-sample-preview@1.0.7-0) (2020-09-02) +**Note:** Version bump only for package @ali/lowcode-plugin-sample-preview + +## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.8.56...@ali/lowcode-plugin-sample-preview@1.0.6-0) (2020-09-02) + + +## [0.8.59](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.8.58...@ali/lowcode-plugin-sample-preview@0.8.59) (2020-09-08) + + +**Note:** Version bump only for package @ali/lowcode-plugin-sample-preview + + +## [0.8.58](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.8.57...@ali/lowcode-plugin-sample-preview@0.8.58) (2020-09-03) + **Note:** Version bump only for package @ali/lowcode-plugin-sample-preview - -## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.8.56...@ali/lowcode-plugin-sample-preview@1.0.6-0) (2020-09-02) + +## [0.8.57](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.8.56...@ali/lowcode-plugin-sample-preview@0.8.57) (2020-09-03) + ### Bug Fixes diff --git a/packages/plugin-source-editor/CHANGELOG.md b/packages/plugin-source-editor/CHANGELOG.md index ca431929e..9bd2f1b72 100644 --- a/packages/plugin-source-editor/CHANGELOG.md +++ b/packages/plugin-source-editor/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.8.31](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-source-editor@0.8.30...@ali/lowcode-plugin-source-editor@0.8.31) (2020-09-03) ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-source-editor@1.0.6-0...@ali/lowcode-plugin-source-editor@1.0.7-0) (2020-09-02) @@ -11,6 +13,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-plugin-source-editor + +## [0.8.30](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-source-editor@0.8.29...@ali/lowcode-plugin-source-editor@0.8.30) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-plugin-source-editor ## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-source-editor@0.8.29...@ali/lowcode-plugin-source-editor@1.0.6-0) (2020-09-02) diff --git a/packages/plugin-source-editor/src/index.tsx b/packages/plugin-source-editor/src/index.tsx index ed9315d76..445f368c4 100644 --- a/packages/plugin-source-editor/src/index.tsx +++ b/packages/plugin-source-editor/src/index.tsx @@ -78,6 +78,8 @@ export default class SourceEditor extends Component<{ this.callEditorEvent('sourceEditor.focusByFunction', params); }); + + // 插件面板关闭事件,监听规则同上 editor.on('skeleton.panel-dock.unactive', (pluginName, dock) => { @@ -86,8 +88,14 @@ export default class SourceEditor extends Component<{ } }); - const schema = editor.get('designer').project.getSchema(); - this.initCode(schema); + // 插件面板打开事件,监听规则同上 + editor.on('skeleton.panel-dock.active',(pluginName,dock)=>{ + if (pluginName == 'sourceEditor'){ + this.initCode(); + } + }) + + this.initCode(); } @@ -127,8 +135,10 @@ export default class SourceEditor extends Component<{ } }; - initCode = (schema) => { - const jsCode = js_beautify(transfrom.schema2Code(schema), { indent_size: 2, indent_empty_lines: true }); + initCode = () => { + const {editor} = this.props; + let schema = editor.get('designer').project.getSchema(); + let jsCode = js_beautify(transfrom.schema2Code(schema), { indent_size: 2, indent_empty_lines: true }); let css; if (schema.componentsTree[0].css) { diff --git a/packages/plugin-undo-redo/CHANGELOG.md b/packages/plugin-undo-redo/CHANGELOG.md index 7e37ae42d..de6aca161 100644 --- a/packages/plugin-undo-redo/CHANGELOG.md +++ b/packages/plugin-undo-redo/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.8.59](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.8.58...@ali/lowcode-plugin-undo-redo@0.8.59) (2020-09-08) ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@1.0.6-0...@ali/lowcode-plugin-undo-redo@1.0.7-0) (2020-09-02) @@ -11,6 +13,21 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-plugin-undo-redo + +## [0.8.58](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.8.57...@ali/lowcode-plugin-undo-redo@0.8.58) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-plugin-undo-redo + + +## [0.8.57](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.8.56...@ali/lowcode-plugin-undo-redo@0.8.57) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-plugin-undo-redo ## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.8.56...@ali/lowcode-plugin-undo-redo@1.0.6-0) (2020-09-02) @@ -136,7 +153,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-plugin-undo-redo ->>>>>>> master ## [0.8.47](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.8.46...@ali/lowcode-plugin-undo-redo@0.8.47) (2020-08-14) diff --git a/packages/plugin-variable-bind-dialog/CHANGELOG.md b/packages/plugin-variable-bind-dialog/CHANGELOG.md index ec96f176e..be8912db0 100644 --- a/packages/plugin-variable-bind-dialog/CHANGELOG.md +++ b/packages/plugin-variable-bind-dialog/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.8.32](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-variable-bind-dialog@0.8.31...@ali/lowcode-plugin-variable-bind-dialog@0.8.32) (2020-09-03) ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-variable-bind-dialog@1.0.6-0...@ali/lowcode-plugin-variable-bind-dialog@1.0.7-0) (2020-09-02) @@ -11,6 +13,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-plugin-variable-bind-dialog + +## [0.8.31](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-variable-bind-dialog@0.8.30...@ali/lowcode-plugin-variable-bind-dialog@0.8.31) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-plugin-variable-bind-dialog ## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-variable-bind-dialog@0.8.30...@ali/lowcode-plugin-variable-bind-dialog@1.0.6-0) (2020-09-02) @@ -41,10 +50,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-plugin-variable-bind-dialog ->>>>>>> master ## [0.8.28](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-variable-bind-dialog@0.8.27...@ali/lowcode-plugin-variable-bind-dialog@0.8.28) (2020-08-20) ->>>>>>> master @@ -87,7 +94,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-variable-bind-dialog@0.13.0...@ali/lowcode-plugin-variable-bind-dialog@1.0.0) (2020-08-17) ## [0.8.27](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-variable-bind-dialog@0.8.26...@ali/lowcode-plugin-variable-bind-dialog@0.8.27) (2020-08-19) ->>>>>>> master diff --git a/packages/plugin-zh-en/CHANGELOG.md b/packages/plugin-zh-en/CHANGELOG.md index 2fb746250..6a920c55a 100644 --- a/packages/plugin-zh-en/CHANGELOG.md +++ b/packages/plugin-zh-en/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.8.36](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-zh-en@0.8.35...@ali/lowcode-plugin-zh-en@0.8.36) (2020-09-03) ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-zh-en@1.0.6-0...@ali/lowcode-plugin-zh-en@1.0.7-0) (2020-09-02) @@ -11,6 +13,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-plugin-zh-en + +## [0.8.35](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-zh-en@0.8.34...@ali/lowcode-plugin-zh-en@0.8.35) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-plugin-zh-en ## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-zh-en@0.8.34...@ali/lowcode-plugin-zh-en@1.0.6-0) (2020-09-02) @@ -86,7 +95,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-zh-en@0.13.0...@ali/lowcode-plugin-zh-en@1.0.0) (2020-08-17) ## [0.8.31](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-zh-en@0.8.30...@ali/lowcode-plugin-zh-en@0.8.31) (2020-08-19) ->>>>>>> master diff --git a/packages/rax-render/CHANGELOG.md b/packages/rax-render/CHANGELOG.md index eb2a037ea..4fb680d27 100644 --- a/packages/rax-render/CHANGELOG.md +++ b/packages/rax-render/CHANGELOG.md @@ -119,7 +119,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ->>>>>>> master ## [0.1.6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-renderer@0.1.5...@ali/lowcode-rax-renderer@0.1.6) (2020-07-22) @@ -188,11 +187,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Features * init rax-render ([7167767](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7167767)) -<<<<<<< HEAD - -======= - ->>>>>>> master && && || diff --git a/packages/rax-simulator-renderer/CHANGELOG.md b/packages/rax-simulator-renderer/CHANGELOG.md index f8dc9f200..ce63b2148 100644 --- a/packages/rax-simulator-renderer/CHANGELOG.md +++ b/packages/rax-simulator-renderer/CHANGELOG.md @@ -3,6 +3,32 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.8.60](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.8.59...@ali/lowcode-rax-simulator-renderer@0.8.60) (2020-09-08) + + + + +**Note:** Version bump only for package @ali/lowcode-rax-simulator-renderer + + +## [0.8.59](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.8.58...@ali/lowcode-rax-simulator-renderer@0.8.59) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-rax-simulator-renderer + + +## [0.8.58](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.8.57...@ali/lowcode-rax-simulator-renderer@0.8.58) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-rax-simulator-renderer + + +## [0.8.57](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.8.56...@ali/lowcode-rax-simulator-renderer@0.8.57) (2020-08-27) ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@1.0.6-0...@ali/lowcode-rax-simulator-renderer@1.0.7-0) (2020-09-02) diff --git a/packages/react-renderer/CHANGELOG.md b/packages/react-renderer/CHANGELOG.md index 9ad93d3e6..a8fa78928 100644 --- a/packages/react-renderer/CHANGELOG.md +++ b/packages/react-renderer/CHANGELOG.md @@ -110,12 +110,10 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Bug Fixes * 修复判断动态 setter 的逻辑 ([d195d7f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/d195d7f)) ->>>>>>> master -<<<<<<< HEAD **Note:** Version bump only for package @ali/lowcode-react-renderer @@ -152,17 +150,12 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-renderer@0.8.17...@ali/lowcode-react-renderer@0.9.0) (2020-08-14) -======= -======= ->>>>>>> master ## [0.8.18](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-renderer@0.8.17...@ali/lowcode-react-renderer@0.8.18) (2020-08-14) ->>>>>>> master ### Bug Fixes -<<<<<<< HEAD * dropdown and menu schema ([ae1d125](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ae1d125)) * parse custom methods function ([87d8b86](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/87d8b86)) @@ -170,11 +163,9 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Features * 🎸 add demo-server ([df35c6a](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/df35c6a)) -======= * remove debugger ([a835dc6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/a835dc6)) * render error样式 ([d601d5e](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/d601d5e)) * 组件缺失占位 ([aff2f34](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/aff2f34)) ->>>>>>> master diff --git a/packages/react-simulator-renderer/CHANGELOG.md b/packages/react-simulator-renderer/CHANGELOG.md index 204b2a3a7..98775cea3 100644 --- a/packages/react-simulator-renderer/CHANGELOG.md +++ b/packages/react-simulator-renderer/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.8.61](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@0.8.60...@ali/lowcode-react-simulator-renderer@0.8.61) (2020-09-08) ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@1.0.6-0...@ali/lowcode-react-simulator-renderer@1.0.7-0) (2020-09-02) @@ -11,6 +13,21 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-react-simulator-renderer + +## [0.8.60](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@0.8.59...@ali/lowcode-react-simulator-renderer@0.8.60) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-react-simulator-renderer + + +## [0.8.59](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@0.8.58...@ali/lowcode-react-simulator-renderer@0.8.59) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-react-simulator-renderer ## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@0.8.58...@ali/lowcode-react-simulator-renderer@1.0.6-0) (2020-09-02) diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index 20914973a..d9994c37e 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -3,6 +3,24 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.8.19](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-types@0.8.18...@ali/lowcode-types@0.8.19) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-types + + +## [0.8.18](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-types@0.8.17...@ali/lowcode-types@0.8.18) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-types + + +## [0.8.17](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-types@0.8.16...@ali/lowcode-types@0.8.17) (2020-08-24) ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-types@1.0.6-0...@ali/lowcode-types@1.0.7-0) (2020-09-02) @@ -99,7 +117,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Bug Fixes * 修复判断动态 setter 的逻辑 ([d195d7f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/d195d7f)) ->>>>>>> master diff --git a/packages/types/src/schema.ts b/packages/types/src/schema.ts index 0356e6c2b..b645c3e7d 100644 --- a/packages/types/src/schema.ts +++ b/packages/types/src/schema.ts @@ -92,4 +92,4 @@ export function isNodeSchema(data: any): data is NodeSchema { export function isProjectSchema(data: any): data is ProjectSchema { return data && data.componentsTree; -} +} \ No newline at end of file diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index e83dfef3d..5f2d87bf7 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.8.22](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-utils@0.8.21...@ali/lowcode-utils@0.8.22) (2020-09-03) ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-utils@1.0.6-0...@ali/lowcode-utils@1.0.7-0) (2020-09-02) @@ -11,6 +13,16 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-utils + +## [0.8.21](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-utils@0.8.20...@ali/lowcode-utils@0.8.21) (2020-09-03) + + + + +**Note:** Version bump only for package @ali/lowcode-utils + + +## [0.8.20](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-utils@0.8.19...@ali/lowcode-utils@0.8.20) (2020-08-27) ## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-utils@0.8.20...@ali/lowcode-utils@1.0.6-0) (2020-09-02) diff --git a/packages/utils/src/env.ts b/packages/utils/src/env.ts new file mode 100644 index 000000000..4770bd46f --- /dev/null +++ b/packages/utils/src/env.ts @@ -0,0 +1,3 @@ +export function isInSimulator() { + return Boolean((window as any).__is_simulator_env__); +} \ No newline at end of file diff --git a/packages/utils/src/is-react.ts b/packages/utils/src/is-react.ts index 2bcfeda78..3b929edea 100644 --- a/packages/utils/src/is-react.ts +++ b/packages/utils/src/is-react.ts @@ -11,8 +11,12 @@ export function acceptsRef(obj: any): boolean { return obj?.prototype?.isReactComponent || (obj.$$typeof && obj.$$typeof === REACT_FORWARD_REF_TYPE); } +function isForwardRefType(obj: any): boolean { + return obj?.$$typeof && obj?.$$typeof === REACT_FORWARD_REF_TYPE; +} + export function isReactComponent(obj: any): obj is ComponentType { - return obj && (isReactClass(obj) || typeof obj === 'function'); + return obj && (isReactClass(obj) || typeof obj === 'function' || isForwardRefType(obj)); } export function wrapReactClass(view: FunctionComponent) {