@chief-editor/flow
Version:
Old核心数据流
1 lines • 1.58 kB
JavaScript
var __extends=this&&this.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();import{BaseBrick}from"@chief-editor/base";import{NestWatcher}from"@co-hooks/nest-watcher";import{getObjectProperty}from"@co-hooks/util";var FlowBrick=function(t){function e(e,r){var o=t.call(this,r)||this;return o.board=e,o}return __extends(e,t),e.prototype.getByExpression=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=[];t.forEach((function(t){"string"==typeof t?r.push.apply(r,NestWatcher.splitKey(t)):r.push(String(t))}));var o=r.shift()||"",n=/^\$/.test(o)?o.slice(1):o,i=this;switch(n){case"context":return getObjectProperty(i.getOwnerContext().getContext(r[0],!0),r,1);case"hooks":return i.getOwnerContext().getHook(r[0]);case"root":return getObjectProperty(i.getOwnerModel().getRootModel().getModelInfo(!0),r)}if(/^model(\d+)?/.test(n)){var c=+RegExp.$1||1,s=i.getOwnerModel();return c>1&&(s=s.getParentModel(c-1)),getObjectProperty(s.getModelInfo(!0),r)}},e.prototype.getOwnerBoard=function(){return this.board},e.prototype.getOwnerTemplate=function(){return this.board.getOwnerTemplate()},e.prototype.getOwnerModel=function(){return this.board.getOwnerModel()},e.prototype.getOwnerContext=function(){return this.getOwnerModel().getOwnerContext()},e}(BaseBrick);export{FlowBrick};