@chief-editor/base
Advanced tools
Comparing version 0.2.7 to 0.2.8
@@ -1,1 +0,7 @@ | ||
export var BindType;!function(N){N[N.VAR=0]="VAR",N[N.EXPRESSION=1]="EXPRESSION",N[N.FUNC=2]="FUNC",N[N.CONST=3]="CONST"}(BindType||(BindType={})); | ||
export var BindType; | ||
(function (BindType) { | ||
BindType[BindType["VAR"] = 0] = "VAR"; | ||
BindType[BindType["EXPRESSION"] = 1] = "EXPRESSION"; | ||
BindType[BindType["FUNC"] = 2] = "FUNC"; | ||
BindType[BindType["CONST"] = 3] = "CONST"; | ||
})(BindType || (BindType = {})); |
@@ -1,1 +0,19 @@ | ||
export var DatasourceType;!function(e){e.LOCAL="local",e.REMOTE="remote",e.BIND="bind",e.DIY="diy"}(DatasourceType||(DatasourceType={}));export var DatasourceMethodType;!function(e){e.GET="get",e.POST="post",e.PUT="put",e.DELETE="delete"}(DatasourceMethodType||(DatasourceMethodType={}));export var DatasourceContentType;!function(e){e.FormData="form",e.JSON="json"}(DatasourceContentType||(DatasourceContentType={})); | ||
export var DatasourceType; | ||
(function (DatasourceType) { | ||
DatasourceType["LOCAL"] = "local"; | ||
DatasourceType["REMOTE"] = "remote"; | ||
DatasourceType["BIND"] = "bind"; | ||
DatasourceType["DIY"] = "diy"; | ||
})(DatasourceType || (DatasourceType = {})); | ||
export var DatasourceMethodType; | ||
(function (DatasourceMethodType) { | ||
DatasourceMethodType["GET"] = "get"; | ||
DatasourceMethodType["POST"] = "post"; | ||
DatasourceMethodType["PUT"] = "put"; | ||
DatasourceMethodType["DELETE"] = "delete"; | ||
})(DatasourceMethodType || (DatasourceMethodType = {})); | ||
export var DatasourceContentType; | ||
(function (DatasourceContentType) { | ||
DatasourceContentType["FormData"] = "form"; | ||
DatasourceContentType["JSON"] = "json"; | ||
})(DatasourceContentType || (DatasourceContentType = {})); |
@@ -1,1 +0,15 @@ | ||
export var ALL_HOOK_POS=["onLoaded","onDispose","onBeforeRefreshBrick","onAfterRefreshBrick","onBeforeValidate","onAfterValidate","onBeforeGetDatasource","onAfterGetDatasource","onCheckValidateValue","onBeforeChange","onAfterChange","onValueChange","onCatchErrorInfo"]; | ||
export var ALL_HOOK_POS = [ | ||
'onLoaded', | ||
'onDispose', | ||
'onBeforeRefreshBrick', | ||
'onAfterRefreshBrick', | ||
'onBeforeValidate', | ||
'onAfterValidate', | ||
'onBeforeGetDatasource', | ||
'onAfterGetDatasource', | ||
'onCheckValidateValue', | ||
'onBeforeChange', | ||
'onAfterChange', | ||
'onValueChange', | ||
'onCatchErrorInfo' | ||
]; |
@@ -1,1 +0,20 @@ | ||
export var ValidateType;!function(e){e.ARRAY="array",e.EMAIL="email",e.URL="url",e.DATE="date",e.NUMBER="number",e.DIGITS="digits"}(ValidateType||(ValidateType={}));export var ValidateRule;!function(e){e.TYPE="type",e.MAX_COUNT="maxCount",e.MIN_COUNT="minCount",e.MAX_LENGTH="maxLength",e.MIN_LENGTH="minLength",e.REGEXP="regexp",e.REQUIRED="required",e.FUNC="func"}(ValidateRule||(ValidateRule={})); | ||
export var ValidateType; | ||
(function (ValidateType) { | ||
ValidateType["ARRAY"] = "array"; | ||
ValidateType["EMAIL"] = "email"; | ||
ValidateType["URL"] = "url"; | ||
ValidateType["DATE"] = "date"; | ||
ValidateType["NUMBER"] = "number"; | ||
ValidateType["DIGITS"] = "digits"; | ||
})(ValidateType || (ValidateType = {})); | ||
export var ValidateRule; | ||
(function (ValidateRule) { | ||
ValidateRule["TYPE"] = "type"; | ||
ValidateRule["MAX_COUNT"] = "maxCount"; | ||
ValidateRule["MIN_COUNT"] = "minCount"; | ||
ValidateRule["MAX_LENGTH"] = "maxLength"; | ||
ValidateRule["MIN_LENGTH"] = "minLength"; | ||
ValidateRule["REGEXP"] = "regexp"; | ||
ValidateRule["REQUIRED"] = "required"; | ||
ValidateRule["FUNC"] = "func"; | ||
})(ValidateRule || (ValidateRule = {})); |
@@ -1,1 +0,8 @@ | ||
export var WatcherType;!function(A){A[A.REFRESH=0]="REFRESH",A[A.VALIDATE=1]="VALIDATE",A[A.CHECK_VALUE=2]="CHECK_VALUE",A[A.LOAD_DATASOURCE=3]="LOAD_DATASOURCE",A[A.FUNC=4]="FUNC"}(WatcherType||(WatcherType={})); | ||
export var WatcherType; | ||
(function (WatcherType) { | ||
WatcherType[WatcherType["REFRESH"] = 0] = "REFRESH"; | ||
WatcherType[WatcherType["VALIDATE"] = 1] = "VALIDATE"; | ||
WatcherType[WatcherType["CHECK_VALUE"] = 2] = "CHECK_VALUE"; | ||
WatcherType[WatcherType["LOAD_DATASOURCE"] = 3] = "LOAD_DATASOURCE"; | ||
WatcherType[WatcherType["FUNC"] = 4] = "FUNC"; | ||
})(WatcherType || (WatcherType = {})); |
@@ -1,1 +0,15 @@ | ||
export*from"./lib/BaseTemplate";export*from"./lib/BaseBoard";export*from"./lib/BaseBrick";export*from"./lib/EditableBaseBrick";export*from"./lib/BasePlugin";export*from"./lib/Mask";export*from"./lib/Canvas";export*from"./lib/HotKey";export*from"./types/Node";export*from"./types/Diff";export*from"./config/datasource";export*from"./config/hooks";export*from"./config/watcher";export*from"./config/bind";export*from"./config/validate"; | ||
export * from './lib/BaseTemplate'; | ||
export * from './lib/BaseBoard'; | ||
export * from './lib/BaseBrick'; | ||
export * from './lib/EditableBaseBrick'; | ||
export * from './lib/BasePlugin'; | ||
export * from './lib/Mask'; | ||
export * from './lib/Canvas'; | ||
export * from './lib/HotKey'; | ||
export * from './types/Node'; | ||
export * from './types/Diff'; | ||
export * from './config/datasource'; | ||
export * from './config/hooks'; | ||
export * from './config/watcher'; | ||
export * from './config/bind'; | ||
export * from './config/validate'; |
@@ -1,1 +0,47 @@ | ||
function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var o=0;o<t.length;o++){var i=t[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function _createClass(e,t,o){return t&&_defineProperties(e.prototype,t),o&&_defineProperties(e,o),e}import{DomNode}from"@co-hooks/dom-node";import{guid}from"@co-hooks/util";import{FloatType}from"../types/Node";export var BaseBoard=function(){function e(t,o){var i=this;_classCallCheck(this,e),this.floatType=FloatType.NONE,this.isDispose=!1;var r=o.type,n=o.id,s=o.floatType,a=o.bricks;this.owner=t,this.type=r,this.id=n||guid(),this.floatType=s||FloatType.NONE,this.repeat=!1,this.node=new DomNode({type:r,floatType:this.floatType,boardId:this.id,repeat:!1}),a.forEach((function(e){return i.node.appendChild(i.owner.createBrick(e,i))}))}return _createClass(e,[{key:"getBoardData",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],o=this.id,i=this.type,r=this.floatType;return{id:t?"":o,type:i,floatType:r,bricks:this.node.getChildNodes().map((function(o){return e.owner.getBrickByNode(o).getBrickData(t)}))}}},{key:"getNode",value:function(){return this.node}},{key:"dispose",value:function(){var e=this;this.isDispose||(this.isDispose=!0,this.node.getChildNodes().forEach((function(t){return e.owner.disposeNode(t)})))}}]),e}(); | ||
import { DomNode } from '@co-hooks/dom-node'; | ||
import { guid } from '@co-hooks/util'; | ||
import { FloatType } from '../types/Node'; | ||
var BaseBoard = (function () { | ||
function BaseBoard(owner, config) { | ||
var _this = this; | ||
this.floatType = FloatType.NONE; | ||
this.isDispose = false; | ||
var type = config.type, id = config.id, floatType = config.floatType, bricks = config.bricks; | ||
this.owner = owner; | ||
this.type = type; | ||
this.id = id || guid(); | ||
this.floatType = floatType || FloatType.NONE; | ||
this.repeat = false; | ||
this.node = new DomNode({ | ||
type: type, | ||
floatType: this.floatType, | ||
boardId: this.id, | ||
repeat: false | ||
}); | ||
bricks.forEach(function (brick) { return _this.node.appendChild(_this.owner.createBrick(brick, _this)); }); | ||
} | ||
BaseBoard.prototype.getBoardData = function (cleanId) { | ||
var _this = this; | ||
if (cleanId === void 0) { cleanId = false; } | ||
var _a = this, id = _a.id, type = _a.type, floatType = _a.floatType; | ||
return { | ||
id: cleanId ? '' : id, | ||
type: type, | ||
floatType: floatType, | ||
bricks: this.node.getChildNodes().map(function (node) { return _this.owner.getBrickByNode(node).getBrickData(cleanId); }) | ||
}; | ||
}; | ||
BaseBoard.prototype.getNode = function () { | ||
return this.node; | ||
}; | ||
BaseBoard.prototype.dispose = function () { | ||
var _this = this; | ||
if (this.isDispose) { | ||
return; | ||
} | ||
this.isDispose = true; | ||
this.node.getChildNodes().forEach(function (node) { return _this.owner.disposeNode(node); }); | ||
}; | ||
return BaseBoard; | ||
}()); | ||
export { BaseBoard }; |
@@ -1,1 +0,189 @@ | ||
function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _objectWithoutProperties(e,t){if(null==e)return{};var r,o,n=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)r=i[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,o,n={},i=Object.keys(e);for(o=0;o<i.length;o++)r=i[o],t.indexOf(r)>=0||(n[r]=e[r]);return n}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}function _possibleConstructorReturn(e,t){return!t||"object"!==_typeof(t)&&"function"!=typeof t?_assertThisInitialized(e):t}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}import{DomNode}from"@co-hooks/dom-node";import{Emitter}from"@co-hooks/emitter";import{clone,guid,shallowMerge}from"@co-hooks/util";import{FloatType,NodeType}from"../types/Node";export var BaseBrick=function(e){function t(e){var r;_classCallCheck(this,t),(r=_possibleConstructorReturn(this,_getPrototypeOf(t).call(this))).parts={},r.isDispose=!1;var o=e.owner,n=e.data,i=e.id;r.owner=o,r.data=n;var a=n.type,s=n.info,c=s.field,u=s.label,l=new DomNode({type:NodeType.BRICK,brickId:i,brickType:a,field:c});return r.updateBrickInstance({id:i,creator:guid(),label:u,readonly:!c,brickType:a,node:l},!0),r}return _inherits(t,Emitter),_createClass(t,[{key:"getInstance",value:function(){return{id:this.id,creator:this.id,label:this.label,field:this.field,readonly:this.readonly,value:this.value,datasource:this.datasource,staticDatasource:this.staticDatasource,display:this.display,config:this.config,styles:this.styles,validateInfo:this.validateInfo,validating:this.validating,manual:this.manual,ready:this.ready,loading:this.loading,brickType:this.brickType,layout:this.layout,node:this.node}}},{key:"getPart",value:function(e){return this.parts[e]||null}},{key:"getNode",value:function(){return this.node}},{key:"getNodePath",value:function(){for(var e=[{type:NodeType.BRICK,id:this.id}],t=this.node.parentNode;t;){var r=t.getValue();e.unshift({type:r.type,id:r.type===NodeType.STREAM||r.type===NodeType.LAYER?r.boardId:r.type===NodeType.BRICK?r.brickId:""}),t=t.parentNode}return e}},{key:"getNodeIndex",value:function(){var e=this.node.parentNode;return e?e.getIndex(this.node):-1}},{key:"getBoardType",value:function(){var e=this.node.parentNode;return null==e?NodeType.STREAM:this.owner.getBoardByNode(e).type}},{key:"isFloat",value:function(){var e=this.node.parentNode;if(null==e)return!1;var t=this.owner.getBoardByNode(e);return t.type===NodeType.STREAM&&t.floatType!==FloatType.NONE}},{key:"refreshBrick",value:function(){this.emit("repaint")}},{key:"getBrickData",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=clone(this.data),n=this.owner;if(null==o||null==n)throw new Error("call method `initEditorBrickInstance` first");if(t&&delete o.id,!Object.keys(this.parts).length)return o;var i={};return Object.keys(this.parts).forEach((function(o){var a=n.getBoardByNode(e.parts[o]).getBoardData(t),s=a.bricks,c=_objectWithoutProperties(a,["bricks"]);i[o]=_objectSpread({bricks:r?[]:s},c)})),_objectSpread({},o,{parts:i})}},{key:"dispose",value:function(){var e=this;this.isDispose||(this.isDispose=!0,Object.keys(this.parts).forEach((function(t){return e.disposePartBoard(t)})),this.owner.disposeNode(this.node))}},{key:"createPartBoard",value:function(e,t){return this.parts[e]=this.owner.createBoard(_objectSpread({},t,{id:"".concat(this.id,"_").concat(e)}))}},{key:"disposePartBoard",value:function(e){null!=this.parts[e]&&(this.owner.disposeNode(this.parts[e]),delete this.parts[e])}},{key:"updateBrickInstance",value:function(e,t){Object.assign(this,shallowMerge({},e)),t||this.refreshBrick()}}]),t}(); | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
import { DomNode } from '@co-hooks/dom-node'; | ||
import { Emitter } from '@co-hooks/emitter'; | ||
import { clone, guid, shallowMerge } from '@co-hooks/util'; | ||
import { FloatType, NodeType } from '../types/Node'; | ||
var BaseBrick = (function (_super) { | ||
__extends(BaseBrick, _super); | ||
function BaseBrick(options) { | ||
var _this = _super.call(this) || this; | ||
_this.parts = {}; | ||
_this.isDispose = false; | ||
var owner = options.owner, data = options.data, id = options.id; | ||
_this.owner = owner; | ||
_this.data = data; | ||
var type = data.type, _a = data.info, field = _a.field, label = _a.label; | ||
var node = new DomNode({ | ||
type: NodeType.BRICK, | ||
brickId: id, | ||
brickType: type, | ||
field: field | ||
}); | ||
_this.updateBrickInstance({ | ||
id: id, | ||
creator: guid(), | ||
label: label, | ||
readonly: !field, | ||
brickType: type, | ||
node: node | ||
}, true); | ||
return _this; | ||
} | ||
BaseBrick.prototype.getInstance = function () { | ||
return { | ||
id: this.id, | ||
creator: this.id, | ||
label: this.label, | ||
field: this.field, | ||
readonly: this.readonly, | ||
value: this.value, | ||
datasource: this.datasource, | ||
staticDatasource: this.staticDatasource, | ||
display: this.display, | ||
config: this.config, | ||
styles: this.styles, | ||
validateInfo: this.validateInfo, | ||
validating: this.validating, | ||
manual: this.manual, | ||
ready: this.ready, | ||
loading: this.loading, | ||
brickType: this.brickType, | ||
layout: this.layout, | ||
node: this.node | ||
}; | ||
}; | ||
BaseBrick.prototype.getPart = function (name) { | ||
return this.parts[name] || null; | ||
}; | ||
BaseBrick.prototype.getNode = function () { | ||
return this.node; | ||
}; | ||
BaseBrick.prototype.getNodePath = function () { | ||
var res = [{ | ||
type: NodeType.BRICK, | ||
id: this.id | ||
}]; | ||
var parent = this.node.parentNode; | ||
while (parent) { | ||
var nodeValue = parent.getValue(); | ||
res.unshift({ | ||
type: nodeValue.type, | ||
id: nodeValue.type === NodeType.STREAM || nodeValue.type === NodeType.LAYER | ||
? nodeValue.boardId | ||
: nodeValue.type === NodeType.BRICK | ||
? nodeValue.brickId | ||
: '' | ||
}); | ||
parent = parent.parentNode; | ||
} | ||
return res; | ||
}; | ||
BaseBrick.prototype.getNodeIndex = function () { | ||
var parent = this.node.parentNode; | ||
if (parent) { | ||
return parent.getIndex(this.node); | ||
} | ||
return -1; | ||
}; | ||
BaseBrick.prototype.getBoardType = function () { | ||
var node = this.node.parentNode; | ||
if (node == null) { | ||
return NodeType.STREAM; | ||
} | ||
var board = this.owner.getBoardByNode(node); | ||
return board.type; | ||
}; | ||
BaseBrick.prototype.isFloat = function () { | ||
var node = this.node.parentNode; | ||
if (node == null) { | ||
return false; | ||
} | ||
var board = this.owner.getBoardByNode(node); | ||
return board.type === NodeType.STREAM && board.floatType !== FloatType.NONE; | ||
}; | ||
BaseBrick.prototype.refreshBrick = function () { | ||
this.emit('repaint'); | ||
}; | ||
BaseBrick.prototype.getBrickData = function (cleanBrickId, cleanPartBricks) { | ||
var _this = this; | ||
if (cleanBrickId === void 0) { cleanBrickId = false; } | ||
if (cleanPartBricks === void 0) { cleanPartBricks = false; } | ||
var data = clone(this.data); | ||
var template = this.owner; | ||
if (data == null || template == null) { | ||
throw new Error('call method `initEditorBrickInstance` first'); | ||
} | ||
if (cleanBrickId) { | ||
delete data.id; | ||
} | ||
if (!Object.keys(this.parts).length) { | ||
return data; | ||
} | ||
var parts = {}; | ||
Object.keys(this.parts).forEach(function (key) { | ||
var _a = template.getBoardByNode(_this.parts[key]).getBoardData(cleanBrickId), bricks = _a.bricks, extra = __rest(_a, ["bricks"]); | ||
parts[key] = __assign({ bricks: cleanPartBricks ? [] : bricks }, extra); | ||
}); | ||
return __assign(__assign({}, data), { parts: parts }); | ||
}; | ||
BaseBrick.prototype.dispose = function () { | ||
var _this = this; | ||
if (this.isDispose) { | ||
return; | ||
} | ||
this.isDispose = true; | ||
Object.keys(this.parts).forEach(function (key) { return _this.disposePartBoard(key); }); | ||
this.owner.disposeNode(this.node); | ||
}; | ||
BaseBrick.prototype.createPartBoard = function (part, config) { | ||
return this.parts[part] = this.owner.createBoard(__assign(__assign({}, config), { id: this.id + "_" + part })); | ||
}; | ||
BaseBrick.prototype.disposePartBoard = function (part) { | ||
if (this.parts[part] != null) { | ||
this.owner.disposeNode(this.parts[part]); | ||
delete this.parts[part]; | ||
} | ||
}; | ||
BaseBrick.prototype.updateBrickInstance = function (instance, isSilent) { | ||
Object.assign(this, shallowMerge({}, instance)); | ||
if (!isSilent) { | ||
this.refreshBrick(); | ||
} | ||
}; | ||
return BaseBrick; | ||
}(Emitter)); | ||
export { BaseBrick }; |
@@ -1,1 +0,47 @@ | ||
function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _objectWithoutProperties(e,t){if(null==e)return{};var r,o,n=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)r=i[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,o,n={},i=Object.keys(e);for(o=0;o<i.length;o++)r=i[o],t.indexOf(r)>=0||(n[r]=e[r]);return n}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}import{Canvas}from"./Canvas";import{Mask}from"./Mask";import{HotKey}from"./HotKey";export var BasePlugin=function(){function e(t,r){_classCallCheck(this,e),this.hotKey=new HotKey;var o=r.canvas,n=void 0===o?{}:o,i=r.hotKey,a=void 0===i?[]:i,s=n.zoom,u=void 0===s?100:s,c=_objectWithoutProperties(n,["zoom"]);this.root=t,this.canvas=new Canvas(u,c),this.hotKey=new HotKey,this.mask=new Mask(this.hotKey),this.initHotKey(a)}return _createClass(e,[{key:"getCanvas",value:function(){return this.canvas}},{key:"getMask",value:function(){return this.mask}},{key:"getHotKey",value:function(){return this.hotKey}},{key:"initHotKey",value:function(e){var t=this;e.forEach((function(e){var r=e.key,o=e.eventType,n=e.handler;t.hotKey.registerHotKey(r,_defineProperty({},o||"keydown",(function(e,r){return n(t.root,e,r)})))}))}}]),e}(); | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
import { Canvas } from './Canvas'; | ||
import { Mask } from './Mask'; | ||
import { HotKey } from './HotKey'; | ||
var BasePlugin = (function () { | ||
function BasePlugin(root, config) { | ||
this.hotKey = new HotKey(); | ||
var _a = config.canvas, canvas = _a === void 0 ? {} : _a, _b = config.hotKey, hotKey = _b === void 0 ? [] : _b; | ||
var _c = canvas.zoom, zoom = _c === void 0 ? 100 : _c, extra = __rest(canvas, ["zoom"]); | ||
this.root = root; | ||
this.canvas = new Canvas(zoom, extra); | ||
this.hotKey = new HotKey(); | ||
this.mask = new Mask(this.hotKey); | ||
this.initHotKey(hotKey); | ||
} | ||
BasePlugin.prototype.getCanvas = function () { | ||
return this.canvas; | ||
}; | ||
BasePlugin.prototype.getMask = function () { | ||
return this.mask; | ||
}; | ||
BasePlugin.prototype.getHotKey = function () { | ||
return this.hotKey; | ||
}; | ||
BasePlugin.prototype.initHotKey = function (hotKeyList) { | ||
var _this = this; | ||
hotKeyList.forEach(function (item) { | ||
var _a; | ||
var key = item.key, eventType = item.eventType, handler = item.handler; | ||
_this.hotKey.registerHotKey(key, (_a = {}, | ||
_a[eventType || 'keydown'] = function (e, hotKey) { return handler(_this.root, e, hotKey); }, | ||
_a)); | ||
}); | ||
}; | ||
return BasePlugin; | ||
}()); | ||
export { BasePlugin }; |
@@ -1,1 +0,128 @@ | ||
function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){_defineProperty(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function _defineProperty(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}import{guid}from"@co-hooks/util";import{NodeType}from"../types/Node";export var BaseTemplate=function(){function e(r){_classCallCheck(this,e),this.boardMap={},this.brickMap={},this.isDisposed=!1,this.id=r||guid()}return _createClass(e,[{key:"getTemplateData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return{id:e?void 0:this.id,board:this.getRootBoard().getBoardData(e)}}},{key:"getNode",value:function(){if(null==this.node)throw new Error("call `init` first");return this.node}},{key:"getBoard",value:function(e){var r=this.boardMap[e];if(!r)throw new Error("board is not exist, id = ".concat(e));return r}},{key:"getBoardByNode",value:function(e){var r=e.getValue();if(r.type!==NodeType.STREAM&&r.type!==NodeType.LAYER)throw new Error("node is not a board node, type = ".concat(r.type));return this.getBoard(r.boardId)}},{key:"getRootBoard",value:function(){if(null==this.node)throw new Error("call `init` first");return this.getBoard("root")}},{key:"getBrickByNode",value:function(e){var r=e.getValue();if(r.type!==NodeType.BRICK)throw new Error("node is not a brick node, type = "+r.type);return this.getBrick(r.brickId)}},{key:"getBrick",value:function(e){var r=this.brickMap[e];if(!r)throw new Error("Brick: ".concat(e," is not under current template"));return r}},{key:"getBrickMap",value:function(){return this.brickMap}},{key:"dispose",value:function(){var e=this;this.isDisposed||(this.isDisposed=!0,Object.values(this.boardMap).forEach((function(r){r.dispose(),delete e.boardMap[r.id]})),Object.values(this.brickMap).forEach((function(r){r.dispose(),delete e.brickMap[r.id]})))}},{key:"createBoard",value:function(e){var r=this.innerCreateBoard(e);return this.boardMap[r.id]=r,r.getNode()}},{key:"createBrick",value:function(e,r){var t=this.innerCreateBrick(e,r);return this.brickMap[t.id]=t,t.getNode()}},{key:"disposeNode",value:function(e){if(this.node===e)throw new Error("rootBoard can not be removed.");var r=e.getValue();if(r.type===NodeType.BRICK){var t=this.brickMap[r.brickId];if(null==t)return;delete this.brickMap[r.brickId],t.dispose()}else if(r.type===NodeType.LAYER||r.type===NodeType.STREAM){var o=this.boardMap[r.boardId];if(null==o)return;o.dispose(),delete this.boardMap[r.boardId]}e.remove()}},{key:"init",value:function(e){var r=this.createBoard(_objectSpread({},e,{id:"root"}));if(!r)throw new Error("create root board fail.");this.node=r}}]),e}(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
import { guid } from '@co-hooks/util'; | ||
import { NodeType } from '../types/Node'; | ||
var BaseTemplate = (function () { | ||
function BaseTemplate(id) { | ||
this.boardMap = {}; | ||
this.brickMap = {}; | ||
this.isDisposed = false; | ||
this.id = id || guid(); | ||
} | ||
BaseTemplate.prototype.getTemplateData = function (cleanId) { | ||
if (cleanId === void 0) { cleanId = false; } | ||
return { | ||
id: cleanId ? undefined : this.id, | ||
board: this.getRootBoard().getBoardData(cleanId) | ||
}; | ||
}; | ||
BaseTemplate.prototype.getNode = function () { | ||
if (this.node == null) { | ||
throw new Error('call `init` first'); | ||
} | ||
return this.node; | ||
}; | ||
BaseTemplate.prototype.getBoard = function (id) { | ||
var board = this.boardMap[id]; | ||
if (!board) { | ||
throw new Error("board is not exist, id = " + id); | ||
} | ||
return board; | ||
}; | ||
BaseTemplate.prototype.getBoardByNode = function (node) { | ||
var value = node.getValue(); | ||
if (value.type !== NodeType.STREAM && value.type !== NodeType.LAYER) { | ||
throw new Error("node is not a board node, type = " + value.type); | ||
} | ||
return this.getBoard(value.boardId); | ||
}; | ||
BaseTemplate.prototype.getRootBoard = function () { | ||
if (this.node == null) { | ||
throw new Error('call `init` first'); | ||
} | ||
return this.getBoard('root'); | ||
}; | ||
BaseTemplate.prototype.getBrickByNode = function (node) { | ||
var value = node.getValue(); | ||
if (value.type !== NodeType.BRICK) { | ||
throw new Error('node is not a brick node, type = ' + value.type); | ||
} | ||
return this.getBrick(value.brickId); | ||
}; | ||
BaseTemplate.prototype.getBrick = function (brickId) { | ||
var brick = this.brickMap[brickId]; | ||
if (!brick) { | ||
throw new Error("Brick: " + brickId + " is not under current template"); | ||
} | ||
return brick; | ||
}; | ||
BaseTemplate.prototype.getBrickMap = function () { | ||
return this.brickMap; | ||
}; | ||
BaseTemplate.prototype.dispose = function () { | ||
var _this = this; | ||
if (this.isDisposed) { | ||
return; | ||
} | ||
this.isDisposed = true; | ||
Object.values(this.boardMap).forEach(function (board) { | ||
board.dispose(); | ||
delete _this.boardMap[board.id]; | ||
}); | ||
Object.values(this.brickMap).forEach(function (brick) { | ||
brick.dispose(); | ||
delete _this.brickMap[brick.id]; | ||
}); | ||
}; | ||
BaseTemplate.prototype.createBoard = function (config) { | ||
var board = this.innerCreateBoard(config); | ||
this.boardMap[board.id] = board; | ||
return board.getNode(); | ||
}; | ||
BaseTemplate.prototype.createBrick = function (config, board) { | ||
var brick = this.innerCreateBrick(config, board); | ||
this.brickMap[brick.id] = brick; | ||
return brick.getNode(); | ||
}; | ||
BaseTemplate.prototype.disposeNode = function (node) { | ||
if (this.node === node) { | ||
throw new Error('rootBoard can not be removed.'); | ||
} | ||
var info = node.getValue(); | ||
if (info.type === NodeType.BRICK) { | ||
var brick = this.brickMap[info.brickId]; | ||
if (brick == null) { | ||
return; | ||
} | ||
delete this.brickMap[info.brickId]; | ||
brick.dispose(); | ||
} | ||
else if (info.type === NodeType.LAYER || info.type === NodeType.STREAM) { | ||
var board = this.boardMap[info.boardId]; | ||
if (board == null) { | ||
return; | ||
} | ||
board.dispose(); | ||
delete this.boardMap[info.boardId]; | ||
} | ||
node.remove(); | ||
}; | ||
BaseTemplate.prototype.init = function (board) { | ||
var node = this.createBoard(__assign(__assign({}, board), { id: 'root' })); | ||
if (!node) { | ||
throw new Error('create root board fail.'); | ||
} | ||
this.node = node; | ||
}; | ||
return BaseTemplate; | ||
}()); | ||
export { BaseTemplate }; |
@@ -1,1 +0,85 @@ | ||
function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _classCallCheck(t,o){if(!(t instanceof o))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,o){for(var e=0;e<o.length;e++){var n=o[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _createClass(t,o,e){return o&&_defineProperties(t.prototype,o),e&&_defineProperties(t,e),t}function _possibleConstructorReturn(t,o){return!o||"object"!==_typeof(o)&&"function"!=typeof o?_assertThisInitialized(t):o}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _getPrototypeOf(t){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function _inherits(t,o){if("function"!=typeof o&&null!==o)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(o&&o.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),o&&_setPrototypeOf(t,o)}function _setPrototypeOf(t,o){return(_setPrototypeOf=Object.setPrototypeOf||function(t,o){return t.__proto__=o,t})(t,o)}import{Emitter}from"@co-hooks/emitter";var MIN_ZOOM_PERCENT=50,MAX_ZOOM_PERCENT=200;export function getDefaultCanvasPosition(t){return{x:0,y:0,zoom:t}}export var Canvas=function(t){function o(t,e){var n;return _classCallCheck(this,o),(n=_possibleConstructorReturn(this,_getPrototypeOf(o).call(this))).minZoom=MIN_ZOOM_PERCENT,n.maxZoom=MAX_ZOOM_PERCENT,n.zoomStep=10,n.position=getDefaultCanvasPosition(t||100),n.updateCanvasConfig(e),n}return _inherits(o,Emitter),_createClass(o,[{key:"updateCanvasConfig",value:function(t){var o=t.minZoom,e=void 0===o?MIN_ZOOM_PERCENT:o,n=t.maxZoom,i=void 0===n?MAX_ZOOM_PERCENT:n,r=t.zoomStep,s=void 0===r?10:r;this.minZoom=e,this.maxZoom=i,this.zoomStep=s}},{key:"setCanvasPosition",value:function(t){var o=t.x,e=t.y,n=t.zoom,i=this.getCanvasPosition();null==o&&(o=i.x),null==e&&(e=i.y),null==n&&(n=i.zoom),n=Math.max(this.minZoom,Math.min(this.maxZoom,n)),this.position={x:o,y:e,zoom:n},this.emit("position-change",this.getCanvasPosition())}},{key:"getCanvasPosition",value:function(){return this.position}},{key:"increaseZoom",value:function(){var t=this.getCanvasPosition();this.setCanvasPosition({zoom:t.zoom+this.zoomStep})}},{key:"decreaseZoom",value:function(){var t=this.getCanvasPosition();this.setCanvasPosition({zoom:t.zoom-this.zoomStep})}},{key:"move",value:function(t,o){var e=this.getCanvasPosition();this.setCanvasPosition({x:e.x+t,y:e.y+o})}}]),o}(); | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
import { Emitter } from '@co-hooks/emitter'; | ||
var MIN_ZOOM_PERCENT = 50; | ||
var MAX_ZOOM_PERCENT = 200; | ||
export function getDefaultCanvasPosition(zoom) { | ||
return { | ||
x: 0, | ||
y: 0, | ||
zoom: zoom | ||
}; | ||
} | ||
var Canvas = (function (_super) { | ||
__extends(Canvas, _super); | ||
function Canvas(defaultZoom, config) { | ||
var _this = _super.call(this) || this; | ||
_this.minZoom = MIN_ZOOM_PERCENT; | ||
_this.maxZoom = MAX_ZOOM_PERCENT; | ||
_this.zoomStep = 10; | ||
_this.position = getDefaultCanvasPosition(defaultZoom || 100); | ||
_this.updateCanvasConfig(config); | ||
return _this; | ||
} | ||
Canvas.prototype.updateCanvasConfig = function (config) { | ||
var _a = config.minZoom, minZoom = _a === void 0 ? MIN_ZOOM_PERCENT : _a, _b = config.maxZoom, maxZoom = _b === void 0 ? MAX_ZOOM_PERCENT : _b, _c = config.zoomStep, zoomStep = _c === void 0 ? 10 : _c; | ||
this.minZoom = minZoom; | ||
this.maxZoom = maxZoom; | ||
this.zoomStep = zoomStep; | ||
}; | ||
Canvas.prototype.setCanvasPosition = function (pos) { | ||
var x = pos.x, y = pos.y, zoom = pos.zoom; | ||
var oldPosition = this.getCanvasPosition(); | ||
if (x == null) { | ||
x = oldPosition.x; | ||
} | ||
if (y == null) { | ||
y = oldPosition.y; | ||
} | ||
if (zoom == null) { | ||
zoom = oldPosition.zoom; | ||
} | ||
zoom = Math.max(this.minZoom, Math.min(this.maxZoom, zoom)); | ||
this.position = { | ||
x: x, | ||
y: y, | ||
zoom: zoom | ||
}; | ||
this.emit('position-change', this.getCanvasPosition()); | ||
}; | ||
Canvas.prototype.getCanvasPosition = function () { | ||
return this.position; | ||
}; | ||
Canvas.prototype.increaseZoom = function () { | ||
var position = this.getCanvasPosition(); | ||
this.setCanvasPosition({ | ||
zoom: position.zoom + this.zoomStep | ||
}); | ||
}; | ||
Canvas.prototype.decreaseZoom = function () { | ||
var position = this.getCanvasPosition(); | ||
this.setCanvasPosition({ | ||
zoom: position.zoom - this.zoomStep | ||
}); | ||
}; | ||
Canvas.prototype.move = function (deltaX, deltaY) { | ||
var position = this.getCanvasPosition(); | ||
this.setCanvasPosition({ | ||
x: position.x + deltaX, | ||
y: position.y + deltaY | ||
}); | ||
}; | ||
return Canvas; | ||
}(Emitter)); | ||
export { Canvas }; |
@@ -1,1 +0,116 @@ | ||
function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function _createClass(t,e,r){return e&&_defineProperties(t.prototype,e),r&&_defineProperties(t,r),t}function _possibleConstructorReturn(t,e){return!e||"object"!==_typeof(e)&&"function"!=typeof e?_assertThisInitialized(t):e}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _getPrototypeOf(t){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return(_setPrototypeOf=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}import{guid,setObjectProperty}from"@co-hooks/util";import{DiffType}from"../types/Diff";import{BaseBrick}from"./BaseBrick";export var EditableBaseBrick=function(t){function e(t){var r;_classCallCheck(this,e),(r=_possibleConstructorReturn(this,_getPrototypeOf(e).call(this,{id:t.data.id||guid(),owner:t.owner,data:t.data}))).status=DiffType.NONE;var o=t.config;return r.brickConfig=o,r.mockData=t.config.mockData,r.updateInstanceFromData(!0),r.initPart(),r}return _inherits(e,BaseBrick),_createClass(e,[{key:"setValue",value:function(t,e,r){if(null==this.brickConfig||null==this.data)throw new Error("call method `initEditorBrickInstance` first");this.getEditorBrickConfig().setValueToBrickData(this.data,t),this.updateInstanceFromData()}},{key:"getDatasource",value:function(){}},{key:"dispatchEvent",value:function(t,e){}},{key:"setBrickDataProperties",value:function(t){var e=this,r=t.every((function(t){var r=t.path,o=t.value,a=setObjectProperty(e.data,o,r.split("."));return a||console.warn("Brick: ".concat(e.brickType," set properties ").concat(r," = ").concat(o," fail")),a}));return this.updateInstanceFromData(),r}},{key:"setData",value:function(t){this.data=t,t.id=this.id,this.updateInstanceFromData()}},{key:"isContainer",value:function(){return this.getEditorBrickConfig().isContainer||!1}},{key:"getEditorBrickConfig",value:function(){return this.brickConfig}},{key:"updateInstanceFromData",value:function(t){var e=this.data,r=this.brickConfig;if(null==r||null==e)throw new Error("call method `initEditorBrickInstance` first");var o=e.info,a=o.field,i=o.label,n=e.type,c=e.styles,s=e.layout,u=void 0===s?r.getDefaultLayout():s;this.updateBrickInstance({label:i||n,field:a,readonly:!a,value:r.getValueFromBrickData(e),datasource:r.getDatasourceFromBrickData(e),staticDatasource:r.getDatasourceFromBrickData(e),display:r.getDisplayFromBrickData(e),config:e.config,styles:c,validateInfo:getDefaultValidateInfo(),layout:u,loading:!1,validating:!1,manual:!0,ready:!0},t)}},{key:"initPart",value:function(){var t=this,e=this.data,r=e.parts;r&&(delete e.parts,Object.keys(r).forEach((function(e){t.node.appendChild(t.createPartBoard(e,r[e]))})))}}]),e}();export function getDefaultValidateInfo(){return{catchable:!1,needValidate:!1,partial:!1,valid:!0,error:"",children:[]}} | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
import { guid, setObjectProperty } from '@co-hooks/util'; | ||
import { DiffType } from '../types/Diff'; | ||
import { BaseBrick } from './BaseBrick'; | ||
var EditableBaseBrick = (function (_super) { | ||
__extends(EditableBaseBrick, _super); | ||
function EditableBaseBrick(options) { | ||
var _this = _super.call(this, { | ||
id: options.data.id || guid(), | ||
owner: options.owner, | ||
data: options.data | ||
}) || this; | ||
_this.status = DiffType.NONE; | ||
var config = options.config; | ||
_this.brickConfig = config; | ||
_this.mockData = options.config.mockData; | ||
_this.updateInstanceFromData(true); | ||
_this.initPart(); | ||
return _this; | ||
} | ||
EditableBaseBrick.prototype.setValue = function (value, manual, isSilent) { | ||
if (this.brickConfig == null || this.data == null) { | ||
throw new Error('call method `initEditorBrickInstance` first'); | ||
} | ||
this.getEditorBrickConfig().setValueToBrickData(this.data, value); | ||
this.updateInstanceFromData(); | ||
}; | ||
EditableBaseBrick.prototype.getDatasource = function () { | ||
}; | ||
EditableBaseBrick.prototype.dispatchEvent = function (name, e) { | ||
}; | ||
EditableBaseBrick.prototype.setBrickDataProperties = function (properties) { | ||
var _this = this; | ||
var res = properties.every(function (_a) { | ||
var path = _a.path, value = _a.value; | ||
var success = setObjectProperty(_this.data, value, path.split('.')); | ||
if (!success) { | ||
console.warn("Brick: " + _this.brickType + " set properties " + path + " = " + value + " fail"); | ||
} | ||
return success; | ||
}); | ||
this.updateInstanceFromData(); | ||
return res; | ||
}; | ||
EditableBaseBrick.prototype.setData = function (data) { | ||
this.data = data; | ||
data.id = this.id; | ||
this.updateInstanceFromData(); | ||
}; | ||
EditableBaseBrick.prototype.isContainer = function () { | ||
return this.getEditorBrickConfig().isContainer || false; | ||
}; | ||
EditableBaseBrick.prototype.getEditorBrickConfig = function () { | ||
return this.brickConfig; | ||
}; | ||
EditableBaseBrick.prototype.updateInstanceFromData = function (isSilent) { | ||
var _a = this, data = _a.data, brickConfig = _a.brickConfig; | ||
if (brickConfig == null || data == null) { | ||
throw new Error('call method `initEditorBrickInstance` first'); | ||
} | ||
var _b = data.info, field = _b.field, label = _b.label, type = data.type, styles = data.styles, _c = data.layout, layout = _c === void 0 ? brickConfig.getDefaultLayout() : _c; | ||
this.updateBrickInstance({ | ||
label: label || type, | ||
field: field, | ||
readonly: !field, | ||
value: brickConfig.getValueFromBrickData(data), | ||
datasource: brickConfig.getDatasourceFromBrickData(data), | ||
staticDatasource: brickConfig.getDatasourceFromBrickData(data), | ||
display: brickConfig.getDisplayFromBrickData(data), | ||
config: data.config, | ||
styles: styles, | ||
validateInfo: getDefaultValidateInfo(), | ||
layout: layout, | ||
loading: false, | ||
validating: false, | ||
manual: true, | ||
ready: true | ||
}, isSilent); | ||
}; | ||
EditableBaseBrick.prototype.initPart = function () { | ||
var _this = this; | ||
var data = this.data; | ||
var parts = data.parts; | ||
if (!parts) { | ||
return; | ||
} | ||
delete data.parts; | ||
Object.keys(parts).forEach(function (key) { | ||
_this.node.appendChild(_this.createPartBoard(key, parts[key])); | ||
}); | ||
}; | ||
return EditableBaseBrick; | ||
}(BaseBrick)); | ||
export { EditableBaseBrick }; | ||
export function getDefaultValidateInfo() { | ||
return { | ||
catchable: false, | ||
needValidate: false, | ||
partial: false, | ||
valid: true, | ||
error: '', | ||
children: [] | ||
}; | ||
} |
@@ -1,1 +0,106 @@ | ||
function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}function _possibleConstructorReturn(e,t){return!t||"object"!==_typeof(t)&&"function"!=typeof t?_assertThisInitialized(e):t}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}import EventEmitter from"events";import{HotKey as RcHotKey}from"@co-hooks/hotkey";var IS_MAC=["Mac68K","MacPPC","Macintosh","MacIntel"].indexOf(navigator.platform)>=0,HOT_KEY_ALAIS={command:IS_MAC?"command":"ctrl",alt:IS_MAC?"option":"alt",delete:"backspace"};export var HotKey=function(e){function t(){var e;return _classCallCheck(this,t),(e=_possibleConstructorReturn(this,_getPrototypeOf(t).call(this))).listener=new RcHotKey,e.funcKeyState={},e.setMaxListeners(0),e}return _inherits(t,EventEmitter),_createClass(t,[{key:"registerHotKey",value:function(e,t){var n=t.keydown,o=t.keyup,r=t.keypress,i=t.latest;this.register(e,n,o,r,i)}},{key:"unregisterHotKey",value:function(e,t){var n=t.keydown,o=t.keyup,r=t.keypress;this.unregister(e,n,o,r)}},{key:"registerFuncKey",value:function(e){var t=this,n=HOT_KEY_ALAIS[e]||e;if(!this.funcKeyState[n]){var o={keydown:function(){t.funcKeyState[n]&&t.emit("".concat(e,"-change"),t.funcKeyState[n].state=!0)},keyup:function(){t.funcKeyState[n]&&t.emit("".concat(e,"-change"),t.funcKeyState[n].state=!1)},state:!1};this.funcKeyState[n]=o,this.register(n,o.keydown,o.keyup)}}},{key:"unregisterFuncKey",value:function(e){e=HOT_KEY_ALAIS[e]||e;var t=this.funcKeyState[e];if(t){var n=t.keydown,o=t.keyup;delete this.funcKeyState[e],this.unregister(e,n,o)}}},{key:"isFuncKeyDown",value:function(e){e=HOT_KEY_ALAIS[e]||e;var t=this.funcKeyState[e];return!!t&&t.state}},{key:"register",value:function(e,t,n,o){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4];null!=t&&this.listener.addHotKeys([e],t,"keydown",!r),null!=n&&this.listener.addHotKeys([e],n,"keyup",!r),null!=o&&this.listener.addHotKeys([e],o,"keypress",!r)}},{key:"unregister",value:function(e,t,n,o){null!=t&&this.listener.removeHotKeys([e],t,"keydown"),null!=n&&this.listener.removeHotKeys([e],n,"keyup"),null!=o&&this.listener.removeHotKeys([e],o,"keypress")}}]),t}();HotKey.IS_MAC=IS_MAC,HotKey.HOT_KEY_ALAIS=HOT_KEY_ALAIS; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
import EventEmitter from 'events'; | ||
import { HotKey as RcHotKey } from '@co-hooks/hotkey'; | ||
var IS_MAC = ['Mac68K', 'MacPPC', 'Macintosh', 'MacIntel'].indexOf(navigator.platform) >= 0; | ||
var HOT_KEY_ALAIS = { | ||
command: IS_MAC ? 'command' : 'ctrl', | ||
alt: IS_MAC ? 'option' : 'alt', | ||
delete: 'backspace' | ||
}; | ||
var HotKey = (function (_super) { | ||
__extends(HotKey, _super); | ||
function HotKey() { | ||
var _this = _super.call(this) || this; | ||
_this.listener = new RcHotKey(); | ||
_this.funcKeyState = {}; | ||
_this.setMaxListeners(0); | ||
return _this; | ||
} | ||
HotKey.prototype.registerHotKey = function (key, options) { | ||
var keydown = options.keydown, keyup = options.keyup, keypress = options.keypress, latest = options.latest; | ||
this.register(key, keydown, keyup, keypress, latest); | ||
}; | ||
HotKey.prototype.unregisterHotKey = function (key, options) { | ||
var keydown = options.keydown, keyup = options.keyup, keypress = options.keypress; | ||
this.unregister(key, keydown, keyup, keypress); | ||
}; | ||
HotKey.prototype.registerFuncKey = function (key) { | ||
var _this = this; | ||
var bindkey = HOT_KEY_ALAIS[key] || key; | ||
if (this.funcKeyState[bindkey]) { | ||
return; | ||
} | ||
var funcKeyItem = { | ||
keydown: function () { | ||
if (_this.funcKeyState[bindkey]) { | ||
_this.emit(key + "-change", _this.funcKeyState[bindkey].state = true); | ||
} | ||
}, | ||
keyup: function () { | ||
if (_this.funcKeyState[bindkey]) { | ||
_this.emit(key + "-change", _this.funcKeyState[bindkey].state = false); | ||
} | ||
}, | ||
state: false | ||
}; | ||
this.funcKeyState[bindkey] = funcKeyItem; | ||
this.register(bindkey, funcKeyItem.keydown, funcKeyItem.keyup); | ||
}; | ||
HotKey.prototype.unregisterFuncKey = function (key) { | ||
key = HOT_KEY_ALAIS[key] || key; | ||
var funcKeyStateInfo = this.funcKeyState[key]; | ||
if (!funcKeyStateInfo) { | ||
return; | ||
} | ||
var keydown = funcKeyStateInfo.keydown, keyup = funcKeyStateInfo.keyup; | ||
delete this.funcKeyState[key]; | ||
this.unregister(key, keydown, keyup); | ||
}; | ||
HotKey.prototype.isFuncKeyDown = function (key) { | ||
key = HOT_KEY_ALAIS[key] || key; | ||
var funcKeyStateInfo = this.funcKeyState[key]; | ||
if (!funcKeyStateInfo) { | ||
return false; | ||
} | ||
return funcKeyStateInfo.state; | ||
}; | ||
HotKey.prototype.register = function (key, keydown, keyup, keypress, latest) { | ||
if (latest === void 0) { latest = false; } | ||
if (keydown != null) { | ||
this.listener.addHotKeys([key], keydown, 'keydown', !latest); | ||
} | ||
if (keyup != null) { | ||
this.listener.addHotKeys([key], keyup, 'keyup', !latest); | ||
} | ||
if (keypress != null) { | ||
this.listener.addHotKeys([key], keypress, 'keypress', !latest); | ||
} | ||
}; | ||
HotKey.prototype.unregister = function (key, keydown, keyup, keypress) { | ||
if (keydown != null) { | ||
this.listener.removeHotKeys([key], keydown, 'keydown'); | ||
} | ||
if (keyup != null) { | ||
this.listener.removeHotKeys([key], keyup, 'keyup'); | ||
} | ||
if (keypress != null) { | ||
this.listener.removeHotKeys([key], keypress, 'keypress'); | ||
} | ||
}; | ||
HotKey.IS_MAC = IS_MAC; | ||
HotKey.HOT_KEY_ALAIS = HOT_KEY_ALAIS; | ||
return HotKey; | ||
}(EventEmitter)); | ||
export { HotKey }; |
@@ -1,1 +0,83 @@ | ||
function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _createClass(t,e,o){return e&&_defineProperties(t.prototype,e),o&&_defineProperties(t,o),t}function _possibleConstructorReturn(t,e){return!e||"object"!==_typeof(e)&&"function"!=typeof e?_assertThisInitialized(t):e}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _getPrototypeOf(t){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return(_setPrototypeOf=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}import{Emitter}from"@co-hooks/emitter";export var Mask=function(t){function e(t){var o;return _classCallCheck(this,e),(o=_possibleConstructorReturn(this,_getPrototypeOf(e).call(this))).activeKey="",o.op={},o.hotkey=t,o}return _inherits(e,Emitter),_createClass(e,[{key:"register",value:function(t,e){var o=this,n=e.onDragStart,r=e.onDragging,i=e.onDragEnd,a=e.onClick;if(t in this.op)throw new Error("register duplicate op '".concat(t,"'"));this.op[t]={key:t,onDragStart:n,onDragging:r,onDragEnd:i,onClick:a,handler:function(e){o.activeKey=e?t:"",o.emit("change",o.activeKey)}},this.hotkey.registerFuncKey(t),this.hotkey.addListener(t+"-change",this.op[t].handler)}},{key:"unregister",value:function(t){if(t in this.op){var e=this.op[t].handler;this.hotkey.unregisterFuncKey(t),this.hotkey.removeListener(t+"-change",e),delete this.op[t]}}},{key:"onDragStart",value:function(t){if(this.activeKey){var e=this.op[this.activeKey].onDragStart;e&&e(t)}}},{key:"onDragging",value:function(t){if(this.activeKey){var e=this.op[this.activeKey].onDragging;e&&e(t)}}},{key:"onDragEnd",value:function(t){if(this.activeKey){var e=this.op[this.activeKey].onDragEnd;e&&e(t)}}},{key:"onClick",value:function(t){if(this.activeKey){var e=this.op[this.activeKey].onClick;e&&e(t)}}}]),e}(); | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
import { Emitter } from '@co-hooks/emitter'; | ||
var Mask = (function (_super) { | ||
__extends(Mask, _super); | ||
function Mask(hotkey) { | ||
var _this = _super.call(this) || this; | ||
_this.activeKey = ''; | ||
_this.op = {}; | ||
_this.hotkey = hotkey; | ||
return _this; | ||
} | ||
Mask.prototype.register = function (key, options) { | ||
var _this = this; | ||
var onDragStart = options.onDragStart, onDragging = options.onDragging, onDragEnd = options.onDragEnd, onClick = options.onClick; | ||
if (key in this.op) { | ||
throw new Error("register duplicate op '" + key + "'"); | ||
} | ||
this.op[key] = { | ||
key: key, | ||
onDragStart: onDragStart, | ||
onDragging: onDragging, | ||
onDragEnd: onDragEnd, | ||
onClick: onClick, | ||
handler: function (state) { | ||
_this.activeKey = state ? key : ''; | ||
_this.emit('change', _this.activeKey); | ||
} | ||
}; | ||
this.hotkey.registerFuncKey(key); | ||
this.hotkey.addListener(key + '-change', this.op[key].handler); | ||
}; | ||
Mask.prototype.unregister = function (key) { | ||
if (!(key in this.op)) { | ||
return; | ||
} | ||
var handler = this.op[key].handler; | ||
this.hotkey.unregisterFuncKey(key); | ||
this.hotkey.removeListener(key + '-change', handler); | ||
delete this.op[key]; | ||
}; | ||
Mask.prototype.onDragStart = function (e) { | ||
if (!this.activeKey) { | ||
return; | ||
} | ||
var onDragStart = this.op[this.activeKey].onDragStart; | ||
onDragStart && onDragStart(e); | ||
}; | ||
Mask.prototype.onDragging = function (e) { | ||
if (!this.activeKey) { | ||
return; | ||
} | ||
var onDragging = this.op[this.activeKey].onDragging; | ||
onDragging && onDragging(e); | ||
}; | ||
Mask.prototype.onDragEnd = function (e) { | ||
if (!this.activeKey) { | ||
return; | ||
} | ||
var onDragEnd = this.op[this.activeKey].onDragEnd; | ||
onDragEnd && onDragEnd(e); | ||
}; | ||
Mask.prototype.onClick = function (e) { | ||
if (!this.activeKey) { | ||
return; | ||
} | ||
var onClick = this.op[this.activeKey].onClick; | ||
onClick && onClick(e); | ||
}; | ||
return Mask; | ||
}(Emitter)); | ||
export { Mask }; |
@@ -1,1 +0,24 @@ | ||
export var PropConflictType;!function(D){D.NONE="NONE",D.DOUBLE_EDIT="DOUBLE_EDIT"}(PropConflictType||(PropConflictType={}));export var DiffType;!function(D){D.NONE="NONE",D.ADD="ADD",D.REMOVE="REMOVE",D.MOVE="MOVE",D.EDIT="EDIT",D.EDIT_ITEM="EDIT_ITEM"}(DiffType||(DiffType={}));export var DataType;!function(D){D.DIFF="DIFF",D.MERGE="MERGE"}(DataType||(DataType={}));export var PropDiffId;!function(D){D.BIND="prop",D.DEFAULT="__diff_id__"}(PropDiffId||(PropDiffId={})); | ||
export var PropConflictType; | ||
(function (PropConflictType) { | ||
PropConflictType["NONE"] = "NONE"; | ||
PropConflictType["DOUBLE_EDIT"] = "DOUBLE_EDIT"; | ||
})(PropConflictType || (PropConflictType = {})); | ||
export var DiffType; | ||
(function (DiffType) { | ||
DiffType["NONE"] = "NONE"; | ||
DiffType["ADD"] = "ADD"; | ||
DiffType["REMOVE"] = "REMOVE"; | ||
DiffType["MOVE"] = "MOVE"; | ||
DiffType["EDIT"] = "EDIT"; | ||
DiffType["EDIT_ITEM"] = "EDIT_ITEM"; | ||
})(DiffType || (DiffType = {})); | ||
export var DataType; | ||
(function (DataType) { | ||
DataType["DIFF"] = "DIFF"; | ||
DataType["MERGE"] = "MERGE"; | ||
})(DataType || (DataType = {})); | ||
export var PropDiffId; | ||
(function (PropDiffId) { | ||
PropDiffId["BIND"] = "prop"; | ||
PropDiffId["DEFAULT"] = "__diff_id__"; | ||
})(PropDiffId || (PropDiffId = {})); |
@@ -1,1 +0,14 @@ | ||
export var FloatType;!function(e){e.LEFT="left",e.RIGHT="right",e.NONE="none"}(FloatType||(FloatType={}));export var NodeType;!function(e){e.STREAM="Stream",e.ROOT="root",e.TEMPLATE="template",e.LAYER="layer",e.BRICK="brick"}(NodeType||(NodeType={})); | ||
export var FloatType; | ||
(function (FloatType) { | ||
FloatType["LEFT"] = "left"; | ||
FloatType["RIGHT"] = "right"; | ||
FloatType["NONE"] = "none"; | ||
})(FloatType || (FloatType = {})); | ||
export var NodeType; | ||
(function (NodeType) { | ||
NodeType["STREAM"] = "Stream"; | ||
NodeType["ROOT"] = "root"; | ||
NodeType["TEMPLATE"] = "template"; | ||
NodeType["LAYER"] = "layer"; | ||
NodeType["BRICK"] = "brick"; | ||
})(NodeType || (NodeType = {})); |
@@ -1,1 +0,9 @@ | ||
"use strict";var BindType;Object.defineProperty(exports,"__esModule",{value:!0}),exports.BindType=void 0,exports.BindType=BindType,function(e){e[e.VAR=0]="VAR",e[e.EXPRESSION=1]="EXPRESSION",e[e.FUNC=2]="FUNC",e[e.CONST=3]="CONST"}(BindType||(exports.BindType=BindType={})); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var BindType; | ||
(function (BindType) { | ||
BindType[BindType["VAR"] = 0] = "VAR"; | ||
BindType[BindType["EXPRESSION"] = 1] = "EXPRESSION"; | ||
BindType[BindType["FUNC"] = 2] = "FUNC"; | ||
BindType[BindType["CONST"] = 3] = "CONST"; | ||
})(BindType = exports.BindType || (exports.BindType = {})); |
@@ -1,1 +0,21 @@ | ||
"use strict";var DatasourceType,DatasourceMethodType,DatasourceContentType;Object.defineProperty(exports,"__esModule",{value:!0}),exports.DatasourceContentType=exports.DatasourceMethodType=exports.DatasourceType=void 0,exports.DatasourceType=DatasourceType,function(e){e.LOCAL="local",e.REMOTE="remote",e.BIND="bind",e.DIY="diy"}(DatasourceType||(exports.DatasourceType=DatasourceType={})),exports.DatasourceMethodType=DatasourceMethodType,function(e){e.GET="get",e.POST="post",e.PUT="put",e.DELETE="delete"}(DatasourceMethodType||(exports.DatasourceMethodType=DatasourceMethodType={})),exports.DatasourceContentType=DatasourceContentType,function(e){e.FormData="form",e.JSON="json"}(DatasourceContentType||(exports.DatasourceContentType=DatasourceContentType={})); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var DatasourceType; | ||
(function (DatasourceType) { | ||
DatasourceType["LOCAL"] = "local"; | ||
DatasourceType["REMOTE"] = "remote"; | ||
DatasourceType["BIND"] = "bind"; | ||
DatasourceType["DIY"] = "diy"; | ||
})(DatasourceType = exports.DatasourceType || (exports.DatasourceType = {})); | ||
var DatasourceMethodType; | ||
(function (DatasourceMethodType) { | ||
DatasourceMethodType["GET"] = "get"; | ||
DatasourceMethodType["POST"] = "post"; | ||
DatasourceMethodType["PUT"] = "put"; | ||
DatasourceMethodType["DELETE"] = "delete"; | ||
})(DatasourceMethodType = exports.DatasourceMethodType || (exports.DatasourceMethodType = {})); | ||
var DatasourceContentType; | ||
(function (DatasourceContentType) { | ||
DatasourceContentType["FormData"] = "form"; | ||
DatasourceContentType["JSON"] = "json"; | ||
})(DatasourceContentType = exports.DatasourceContentType || (exports.DatasourceContentType = {})); |
@@ -1,1 +0,2 @@ | ||
"use strict"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -1,1 +0,17 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ALL_HOOK_POS=void 0;var ALL_HOOK_POS=["onLoaded","onDispose","onBeforeRefreshBrick","onAfterRefreshBrick","onBeforeValidate","onAfterValidate","onBeforeGetDatasource","onAfterGetDatasource","onCheckValidateValue","onBeforeChange","onAfterChange","onValueChange","onCatchErrorInfo"];exports.ALL_HOOK_POS=ALL_HOOK_POS; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ALL_HOOK_POS = [ | ||
'onLoaded', | ||
'onDispose', | ||
'onBeforeRefreshBrick', | ||
'onAfterRefreshBrick', | ||
'onBeforeValidate', | ||
'onAfterValidate', | ||
'onBeforeGetDatasource', | ||
'onAfterGetDatasource', | ||
'onCheckValidateValue', | ||
'onBeforeChange', | ||
'onAfterChange', | ||
'onValueChange', | ||
'onCatchErrorInfo' | ||
]; |
@@ -1,1 +0,2 @@ | ||
"use strict"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -1,1 +0,2 @@ | ||
"use strict"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -1,1 +0,22 @@ | ||
"use strict";var ValidateType,ValidateRule;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ValidateRule=exports.ValidateType=void 0,exports.ValidateType=ValidateType,function(e){e.ARRAY="array",e.EMAIL="email",e.URL="url",e.DATE="date",e.NUMBER="number",e.DIGITS="digits"}(ValidateType||(exports.ValidateType=ValidateType={})),exports.ValidateRule=ValidateRule,function(e){e.TYPE="type",e.MAX_COUNT="maxCount",e.MIN_COUNT="minCount",e.MAX_LENGTH="maxLength",e.MIN_LENGTH="minLength",e.REGEXP="regexp",e.REQUIRED="required",e.FUNC="func"}(ValidateRule||(exports.ValidateRule=ValidateRule={})); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var ValidateType; | ||
(function (ValidateType) { | ||
ValidateType["ARRAY"] = "array"; | ||
ValidateType["EMAIL"] = "email"; | ||
ValidateType["URL"] = "url"; | ||
ValidateType["DATE"] = "date"; | ||
ValidateType["NUMBER"] = "number"; | ||
ValidateType["DIGITS"] = "digits"; | ||
})(ValidateType = exports.ValidateType || (exports.ValidateType = {})); | ||
var ValidateRule; | ||
(function (ValidateRule) { | ||
ValidateRule["TYPE"] = "type"; | ||
ValidateRule["MAX_COUNT"] = "maxCount"; | ||
ValidateRule["MIN_COUNT"] = "minCount"; | ||
ValidateRule["MAX_LENGTH"] = "maxLength"; | ||
ValidateRule["MIN_LENGTH"] = "minLength"; | ||
ValidateRule["REGEXP"] = "regexp"; | ||
ValidateRule["REQUIRED"] = "required"; | ||
ValidateRule["FUNC"] = "func"; | ||
})(ValidateRule = exports.ValidateRule || (exports.ValidateRule = {})); |
@@ -1,1 +0,10 @@ | ||
"use strict";var WatcherType;Object.defineProperty(exports,"__esModule",{value:!0}),exports.WatcherType=void 0,exports.WatcherType=WatcherType,function(e){e[e.REFRESH=0]="REFRESH",e[e.VALIDATE=1]="VALIDATE",e[e.CHECK_VALUE=2]="CHECK_VALUE",e[e.LOAD_DATASOURCE=3]="LOAD_DATASOURCE",e[e.FUNC=4]="FUNC"}(WatcherType||(exports.WatcherType=WatcherType={})); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var WatcherType; | ||
(function (WatcherType) { | ||
WatcherType[WatcherType["REFRESH"] = 0] = "REFRESH"; | ||
WatcherType[WatcherType["VALIDATE"] = 1] = "VALIDATE"; | ||
WatcherType[WatcherType["CHECK_VALUE"] = 2] = "CHECK_VALUE"; | ||
WatcherType[WatcherType["LOAD_DATASOURCE"] = 3] = "LOAD_DATASOURCE"; | ||
WatcherType[WatcherType["FUNC"] = 4] = "FUNC"; | ||
})(WatcherType = exports.WatcherType || (exports.WatcherType = {})); |
@@ -1,1 +0,20 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _BaseTemplate=require("./lib/BaseTemplate");Object.keys(_BaseTemplate).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _BaseTemplate[e]}})}));var _BaseBoard=require("./lib/BaseBoard");Object.keys(_BaseBoard).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _BaseBoard[e]}})}));var _BaseBrick=require("./lib/BaseBrick");Object.keys(_BaseBrick).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _BaseBrick[e]}})}));var _EditableBaseBrick=require("./lib/EditableBaseBrick");Object.keys(_EditableBaseBrick).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _EditableBaseBrick[e]}})}));var _BasePlugin=require("./lib/BasePlugin");Object.keys(_BasePlugin).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _BasePlugin[e]}})}));var _Mask=require("./lib/Mask");Object.keys(_Mask).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _Mask[e]}})}));var _Canvas=require("./lib/Canvas");Object.keys(_Canvas).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _Canvas[e]}})}));var _HotKey=require("./lib/HotKey");Object.keys(_HotKey).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _HotKey[e]}})}));var _Node=require("./types/Node");Object.keys(_Node).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _Node[e]}})}));var _Diff=require("./types/Diff");Object.keys(_Diff).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _Diff[e]}})}));var _datasource=require("./config/datasource");Object.keys(_datasource).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _datasource[e]}})}));var _hooks=require("./config/hooks");Object.keys(_hooks).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _hooks[e]}})}));var _watcher=require("./config/watcher");Object.keys(_watcher).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _watcher[e]}})}));var _bind=require("./config/bind");Object.keys(_bind).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _bind[e]}})}));var _validate=require("./config/validate");Object.keys(_validate).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _validate[e]}})})); | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./lib/BaseTemplate")); | ||
__export(require("./lib/BaseBoard")); | ||
__export(require("./lib/BaseBrick")); | ||
__export(require("./lib/EditableBaseBrick")); | ||
__export(require("./lib/BasePlugin")); | ||
__export(require("./lib/Mask")); | ||
__export(require("./lib/Canvas")); | ||
__export(require("./lib/HotKey")); | ||
__export(require("./types/Node")); | ||
__export(require("./types/Diff")); | ||
__export(require("./config/datasource")); | ||
__export(require("./config/hooks")); | ||
__export(require("./config/watcher")); | ||
__export(require("./config/bind")); | ||
__export(require("./config/validate")); |
@@ -1,1 +0,49 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseBoard=void 0;var _domNode=require("@co-hooks/dom-node"),_util=require("@co-hooks/util"),_Node=require("../types/Node");function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var o=0;o<t.length;o++){var i=t[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function _createClass(e,t,o){return t&&_defineProperties(e.prototype,t),o&&_defineProperties(e,o),e}var BaseBoard=function(){function e(t,o){var i=this;_classCallCheck(this,e),this.floatType=_Node.FloatType.NONE,this.isDispose=!1;var r=o.type,s=o.id,a=o.floatType,n=o.bricks;this.owner=t,this.type=r,this.id=s||(0,_util.guid)(),this.floatType=a||_Node.FloatType.NONE,this.repeat=!1,this.node=new _domNode.DomNode({type:r,floatType:this.floatType,boardId:this.id,repeat:!1}),n.forEach((function(e){return i.node.appendChild(i.owner.createBrick(e,i))}))}return _createClass(e,[{key:"getBoardData",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],o=this.id,i=this.type,r=this.floatType;return{id:t?"":o,type:i,floatType:r,bricks:this.node.getChildNodes().map((function(o){return e.owner.getBrickByNode(o).getBrickData(t)}))}}},{key:"getNode",value:function(){return this.node}},{key:"dispose",value:function(){var e=this;this.isDispose||(this.isDispose=!0,this.node.getChildNodes().forEach((function(t){return e.owner.disposeNode(t)})))}}]),e}();exports.BaseBoard=BaseBoard; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var dom_node_1 = require("@co-hooks/dom-node"); | ||
var util_1 = require("@co-hooks/util"); | ||
var Node_1 = require("../types/Node"); | ||
var BaseBoard = (function () { | ||
function BaseBoard(owner, config) { | ||
var _this = this; | ||
this.floatType = Node_1.FloatType.NONE; | ||
this.isDispose = false; | ||
var type = config.type, id = config.id, floatType = config.floatType, bricks = config.bricks; | ||
this.owner = owner; | ||
this.type = type; | ||
this.id = id || util_1.guid(); | ||
this.floatType = floatType || Node_1.FloatType.NONE; | ||
this.repeat = false; | ||
this.node = new dom_node_1.DomNode({ | ||
type: type, | ||
floatType: this.floatType, | ||
boardId: this.id, | ||
repeat: false | ||
}); | ||
bricks.forEach(function (brick) { return _this.node.appendChild(_this.owner.createBrick(brick, _this)); }); | ||
} | ||
BaseBoard.prototype.getBoardData = function (cleanId) { | ||
var _this = this; | ||
if (cleanId === void 0) { cleanId = false; } | ||
var _a = this, id = _a.id, type = _a.type, floatType = _a.floatType; | ||
return { | ||
id: cleanId ? '' : id, | ||
type: type, | ||
floatType: floatType, | ||
bricks: this.node.getChildNodes().map(function (node) { return _this.owner.getBrickByNode(node).getBrickData(cleanId); }) | ||
}; | ||
}; | ||
BaseBoard.prototype.getNode = function () { | ||
return this.node; | ||
}; | ||
BaseBoard.prototype.dispose = function () { | ||
var _this = this; | ||
if (this.isDispose) { | ||
return; | ||
} | ||
this.isDispose = true; | ||
this.node.getChildNodes().forEach(function (node) { return _this.owner.disposeNode(node); }); | ||
}; | ||
return BaseBoard; | ||
}()); | ||
exports.BaseBoard = BaseBoard; |
@@ -1,1 +0,191 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseBrick=void 0;var _domNode=require("@co-hooks/dom-node"),_emitter=require("@co-hooks/emitter"),_util=require("@co-hooks/util"),_Node=require("../types/Node");function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _objectWithoutProperties(e,t){if(null==e)return{};var r,o,i=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(o=0;o<n.length;o++)r=n[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,o,i={},n=Object.keys(e);for(o=0;o<n.length;o++)r=n[o],t.indexOf(r)>=0||(i[r]=e[r]);return i}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}function _possibleConstructorReturn(e,t){return!t||"object"!==_typeof(t)&&"function"!=typeof t?_assertThisInitialized(e):t}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var BaseBrick=function(e){function t(e){var r;_classCallCheck(this,t),(r=_possibleConstructorReturn(this,_getPrototypeOf(t).call(this))).parts={},r.isDispose=!1;var o=e.owner,i=e.data,n=e.id;r.owner=o,r.data=i;var s=i.type,a=i.info,c=a.field,u=a.label,l=new _domNode.DomNode({type:_Node.NodeType.BRICK,brickId:n,brickType:s,field:c});return r.updateBrickInstance({id:n,creator:(0,_util.guid)(),label:u,readonly:!c,brickType:s,node:l},!0),r}return _inherits(t,_emitter.Emitter),_createClass(t,[{key:"getInstance",value:function(){return{id:this.id,creator:this.id,label:this.label,field:this.field,readonly:this.readonly,value:this.value,datasource:this.datasource,staticDatasource:this.staticDatasource,display:this.display,config:this.config,styles:this.styles,validateInfo:this.validateInfo,validating:this.validating,manual:this.manual,ready:this.ready,loading:this.loading,brickType:this.brickType,layout:this.layout,node:this.node}}},{key:"getPart",value:function(e){return this.parts[e]||null}},{key:"getNode",value:function(){return this.node}},{key:"getNodePath",value:function(){for(var e=[{type:_Node.NodeType.BRICK,id:this.id}],t=this.node.parentNode;t;){var r=t.getValue();e.unshift({type:r.type,id:r.type===_Node.NodeType.STREAM||r.type===_Node.NodeType.LAYER?r.boardId:r.type===_Node.NodeType.BRICK?r.brickId:""}),t=t.parentNode}return e}},{key:"getNodeIndex",value:function(){var e=this.node.parentNode;return e?e.getIndex(this.node):-1}},{key:"getBoardType",value:function(){var e=this.node.parentNode;return null==e?_Node.NodeType.STREAM:this.owner.getBoardByNode(e).type}},{key:"isFloat",value:function(){var e=this.node.parentNode;if(null==e)return!1;var t=this.owner.getBoardByNode(e);return t.type===_Node.NodeType.STREAM&&t.floatType!==_Node.FloatType.NONE}},{key:"refreshBrick",value:function(){this.emit("repaint")}},{key:"getBrickData",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=(0,_util.clone)(this.data),i=this.owner;if(null==o||null==i)throw new Error("call method `initEditorBrickInstance` first");if(t&&delete o.id,!Object.keys(this.parts).length)return o;var n={};return Object.keys(this.parts).forEach((function(o){var s=i.getBoardByNode(e.parts[o]).getBoardData(t),a=s.bricks,c=_objectWithoutProperties(s,["bricks"]);n[o]=_objectSpread({bricks:r?[]:a},c)})),_objectSpread({},o,{parts:n})}},{key:"dispose",value:function(){var e=this;this.isDispose||(this.isDispose=!0,Object.keys(this.parts).forEach((function(t){return e.disposePartBoard(t)})),this.owner.disposeNode(this.node))}},{key:"createPartBoard",value:function(e,t){return this.parts[e]=this.owner.createBoard(_objectSpread({},t,{id:"".concat(this.id,"_").concat(e)}))}},{key:"disposePartBoard",value:function(e){null!=this.parts[e]&&(this.owner.disposeNode(this.parts[e]),delete this.parts[e])}},{key:"updateBrickInstance",value:function(e,t){Object.assign(this,(0,_util.shallowMerge)({},e)),t||this.refreshBrick()}}]),t}();exports.BaseBrick=BaseBrick; | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var dom_node_1 = require("@co-hooks/dom-node"); | ||
var emitter_1 = require("@co-hooks/emitter"); | ||
var util_1 = require("@co-hooks/util"); | ||
var Node_1 = require("../types/Node"); | ||
var BaseBrick = (function (_super) { | ||
__extends(BaseBrick, _super); | ||
function BaseBrick(options) { | ||
var _this = _super.call(this) || this; | ||
_this.parts = {}; | ||
_this.isDispose = false; | ||
var owner = options.owner, data = options.data, id = options.id; | ||
_this.owner = owner; | ||
_this.data = data; | ||
var type = data.type, _a = data.info, field = _a.field, label = _a.label; | ||
var node = new dom_node_1.DomNode({ | ||
type: Node_1.NodeType.BRICK, | ||
brickId: id, | ||
brickType: type, | ||
field: field | ||
}); | ||
_this.updateBrickInstance({ | ||
id: id, | ||
creator: util_1.guid(), | ||
label: label, | ||
readonly: !field, | ||
brickType: type, | ||
node: node | ||
}, true); | ||
return _this; | ||
} | ||
BaseBrick.prototype.getInstance = function () { | ||
return { | ||
id: this.id, | ||
creator: this.id, | ||
label: this.label, | ||
field: this.field, | ||
readonly: this.readonly, | ||
value: this.value, | ||
datasource: this.datasource, | ||
staticDatasource: this.staticDatasource, | ||
display: this.display, | ||
config: this.config, | ||
styles: this.styles, | ||
validateInfo: this.validateInfo, | ||
validating: this.validating, | ||
manual: this.manual, | ||
ready: this.ready, | ||
loading: this.loading, | ||
brickType: this.brickType, | ||
layout: this.layout, | ||
node: this.node | ||
}; | ||
}; | ||
BaseBrick.prototype.getPart = function (name) { | ||
return this.parts[name] || null; | ||
}; | ||
BaseBrick.prototype.getNode = function () { | ||
return this.node; | ||
}; | ||
BaseBrick.prototype.getNodePath = function () { | ||
var res = [{ | ||
type: Node_1.NodeType.BRICK, | ||
id: this.id | ||
}]; | ||
var parent = this.node.parentNode; | ||
while (parent) { | ||
var nodeValue = parent.getValue(); | ||
res.unshift({ | ||
type: nodeValue.type, | ||
id: nodeValue.type === Node_1.NodeType.STREAM || nodeValue.type === Node_1.NodeType.LAYER | ||
? nodeValue.boardId | ||
: nodeValue.type === Node_1.NodeType.BRICK | ||
? nodeValue.brickId | ||
: '' | ||
}); | ||
parent = parent.parentNode; | ||
} | ||
return res; | ||
}; | ||
BaseBrick.prototype.getNodeIndex = function () { | ||
var parent = this.node.parentNode; | ||
if (parent) { | ||
return parent.getIndex(this.node); | ||
} | ||
return -1; | ||
}; | ||
BaseBrick.prototype.getBoardType = function () { | ||
var node = this.node.parentNode; | ||
if (node == null) { | ||
return Node_1.NodeType.STREAM; | ||
} | ||
var board = this.owner.getBoardByNode(node); | ||
return board.type; | ||
}; | ||
BaseBrick.prototype.isFloat = function () { | ||
var node = this.node.parentNode; | ||
if (node == null) { | ||
return false; | ||
} | ||
var board = this.owner.getBoardByNode(node); | ||
return board.type === Node_1.NodeType.STREAM && board.floatType !== Node_1.FloatType.NONE; | ||
}; | ||
BaseBrick.prototype.refreshBrick = function () { | ||
this.emit('repaint'); | ||
}; | ||
BaseBrick.prototype.getBrickData = function (cleanBrickId, cleanPartBricks) { | ||
var _this = this; | ||
if (cleanBrickId === void 0) { cleanBrickId = false; } | ||
if (cleanPartBricks === void 0) { cleanPartBricks = false; } | ||
var data = util_1.clone(this.data); | ||
var template = this.owner; | ||
if (data == null || template == null) { | ||
throw new Error('call method `initEditorBrickInstance` first'); | ||
} | ||
if (cleanBrickId) { | ||
delete data.id; | ||
} | ||
if (!Object.keys(this.parts).length) { | ||
return data; | ||
} | ||
var parts = {}; | ||
Object.keys(this.parts).forEach(function (key) { | ||
var _a = template.getBoardByNode(_this.parts[key]).getBoardData(cleanBrickId), bricks = _a.bricks, extra = __rest(_a, ["bricks"]); | ||
parts[key] = __assign({ bricks: cleanPartBricks ? [] : bricks }, extra); | ||
}); | ||
return __assign(__assign({}, data), { parts: parts }); | ||
}; | ||
BaseBrick.prototype.dispose = function () { | ||
var _this = this; | ||
if (this.isDispose) { | ||
return; | ||
} | ||
this.isDispose = true; | ||
Object.keys(this.parts).forEach(function (key) { return _this.disposePartBoard(key); }); | ||
this.owner.disposeNode(this.node); | ||
}; | ||
BaseBrick.prototype.createPartBoard = function (part, config) { | ||
return this.parts[part] = this.owner.createBoard(__assign(__assign({}, config), { id: this.id + "_" + part })); | ||
}; | ||
BaseBrick.prototype.disposePartBoard = function (part) { | ||
if (this.parts[part] != null) { | ||
this.owner.disposeNode(this.parts[part]); | ||
delete this.parts[part]; | ||
} | ||
}; | ||
BaseBrick.prototype.updateBrickInstance = function (instance, isSilent) { | ||
Object.assign(this, util_1.shallowMerge({}, instance)); | ||
if (!isSilent) { | ||
this.refreshBrick(); | ||
} | ||
}; | ||
return BaseBrick; | ||
}(emitter_1.Emitter)); | ||
exports.BaseBrick = BaseBrick; |
@@ -1,1 +0,49 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BasePlugin=void 0;var _Canvas=require("./Canvas"),_Mask=require("./Mask"),_HotKey=require("./HotKey");function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _objectWithoutProperties(e,t){if(null==e)return{};var r,n,o=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}var BasePlugin=function(){function e(t,r){_classCallCheck(this,e),this.hotKey=new _HotKey.HotKey;var n=r.canvas,o=void 0===n?{}:n,i=r.hotKey,a=void 0===i?[]:i,s=o.zoom,u=void 0===s?100:s,c=_objectWithoutProperties(o,["zoom"]);this.root=t,this.canvas=new _Canvas.Canvas(u,c),this.hotKey=new _HotKey.HotKey,this.mask=new _Mask.Mask(this.hotKey),this.initHotKey(a)}return _createClass(e,[{key:"getCanvas",value:function(){return this.canvas}},{key:"getMask",value:function(){return this.mask}},{key:"getHotKey",value:function(){return this.hotKey}},{key:"initHotKey",value:function(e){var t=this;e.forEach((function(e){var r=e.key,n=e.eventType,o=e.handler;t.hotKey.registerHotKey(r,_defineProperty({},n||"keydown",(function(e,r){return o(t.root,e,r)})))}))}}]),e}();exports.BasePlugin=BasePlugin; | ||
"use strict"; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Canvas_1 = require("./Canvas"); | ||
var Mask_1 = require("./Mask"); | ||
var HotKey_1 = require("./HotKey"); | ||
var BasePlugin = (function () { | ||
function BasePlugin(root, config) { | ||
this.hotKey = new HotKey_1.HotKey(); | ||
var _a = config.canvas, canvas = _a === void 0 ? {} : _a, _b = config.hotKey, hotKey = _b === void 0 ? [] : _b; | ||
var _c = canvas.zoom, zoom = _c === void 0 ? 100 : _c, extra = __rest(canvas, ["zoom"]); | ||
this.root = root; | ||
this.canvas = new Canvas_1.Canvas(zoom, extra); | ||
this.hotKey = new HotKey_1.HotKey(); | ||
this.mask = new Mask_1.Mask(this.hotKey); | ||
this.initHotKey(hotKey); | ||
} | ||
BasePlugin.prototype.getCanvas = function () { | ||
return this.canvas; | ||
}; | ||
BasePlugin.prototype.getMask = function () { | ||
return this.mask; | ||
}; | ||
BasePlugin.prototype.getHotKey = function () { | ||
return this.hotKey; | ||
}; | ||
BasePlugin.prototype.initHotKey = function (hotKeyList) { | ||
var _this = this; | ||
hotKeyList.forEach(function (item) { | ||
var _a; | ||
var key = item.key, eventType = item.eventType, handler = item.handler; | ||
_this.hotKey.registerHotKey(key, (_a = {}, | ||
_a[eventType || 'keydown'] = function (e, hotKey) { return handler(_this.root, e, hotKey); }, | ||
_a)); | ||
}); | ||
}; | ||
return BasePlugin; | ||
}()); | ||
exports.BasePlugin = BasePlugin; |
@@ -1,1 +0,130 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseTemplate=void 0;var _util=require("@co-hooks/util"),_Node=require("../types/Node");function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){_defineProperty(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function _defineProperty(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}var BaseTemplate=function(){function e(r){_classCallCheck(this,e),this.boardMap={},this.brickMap={},this.isDisposed=!1,this.id=r||(0,_util.guid)()}return _createClass(e,[{key:"getTemplateData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return{id:e?void 0:this.id,board:this.getRootBoard().getBoardData(e)}}},{key:"getNode",value:function(){if(null==this.node)throw new Error("call `init` first");return this.node}},{key:"getBoard",value:function(e){var r=this.boardMap[e];if(!r)throw new Error("board is not exist, id = ".concat(e));return r}},{key:"getBoardByNode",value:function(e){var r=e.getValue();if(r.type!==_Node.NodeType.STREAM&&r.type!==_Node.NodeType.LAYER)throw new Error("node is not a board node, type = ".concat(r.type));return this.getBoard(r.boardId)}},{key:"getRootBoard",value:function(){if(null==this.node)throw new Error("call `init` first");return this.getBoard("root")}},{key:"getBrickByNode",value:function(e){var r=e.getValue();if(r.type!==_Node.NodeType.BRICK)throw new Error("node is not a brick node, type = "+r.type);return this.getBrick(r.brickId)}},{key:"getBrick",value:function(e){var r=this.brickMap[e];if(!r)throw new Error("Brick: ".concat(e," is not under current template"));return r}},{key:"getBrickMap",value:function(){return this.brickMap}},{key:"dispose",value:function(){var e=this;this.isDisposed||(this.isDisposed=!0,Object.values(this.boardMap).forEach((function(r){r.dispose(),delete e.boardMap[r.id]})),Object.values(this.brickMap).forEach((function(r){r.dispose(),delete e.brickMap[r.id]})))}},{key:"createBoard",value:function(e){var r=this.innerCreateBoard(e);return this.boardMap[r.id]=r,r.getNode()}},{key:"createBrick",value:function(e,r){var t=this.innerCreateBrick(e,r);return this.brickMap[t.id]=t,t.getNode()}},{key:"disposeNode",value:function(e){if(this.node===e)throw new Error("rootBoard can not be removed.");var r=e.getValue();if(r.type===_Node.NodeType.BRICK){var t=this.brickMap[r.brickId];if(null==t)return;delete this.brickMap[r.brickId],t.dispose()}else if(r.type===_Node.NodeType.LAYER||r.type===_Node.NodeType.STREAM){var o=this.boardMap[r.boardId];if(null==o)return;o.dispose(),delete this.boardMap[r.boardId]}e.remove()}},{key:"init",value:function(e){var r=this.createBoard(_objectSpread({},e,{id:"root"}));if(!r)throw new Error("create root board fail.");this.node=r}}]),e}();exports.BaseTemplate=BaseTemplate; | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var util_1 = require("@co-hooks/util"); | ||
var Node_1 = require("../types/Node"); | ||
var BaseTemplate = (function () { | ||
function BaseTemplate(id) { | ||
this.boardMap = {}; | ||
this.brickMap = {}; | ||
this.isDisposed = false; | ||
this.id = id || util_1.guid(); | ||
} | ||
BaseTemplate.prototype.getTemplateData = function (cleanId) { | ||
if (cleanId === void 0) { cleanId = false; } | ||
return { | ||
id: cleanId ? undefined : this.id, | ||
board: this.getRootBoard().getBoardData(cleanId) | ||
}; | ||
}; | ||
BaseTemplate.prototype.getNode = function () { | ||
if (this.node == null) { | ||
throw new Error('call `init` first'); | ||
} | ||
return this.node; | ||
}; | ||
BaseTemplate.prototype.getBoard = function (id) { | ||
var board = this.boardMap[id]; | ||
if (!board) { | ||
throw new Error("board is not exist, id = " + id); | ||
} | ||
return board; | ||
}; | ||
BaseTemplate.prototype.getBoardByNode = function (node) { | ||
var value = node.getValue(); | ||
if (value.type !== Node_1.NodeType.STREAM && value.type !== Node_1.NodeType.LAYER) { | ||
throw new Error("node is not a board node, type = " + value.type); | ||
} | ||
return this.getBoard(value.boardId); | ||
}; | ||
BaseTemplate.prototype.getRootBoard = function () { | ||
if (this.node == null) { | ||
throw new Error('call `init` first'); | ||
} | ||
return this.getBoard('root'); | ||
}; | ||
BaseTemplate.prototype.getBrickByNode = function (node) { | ||
var value = node.getValue(); | ||
if (value.type !== Node_1.NodeType.BRICK) { | ||
throw new Error('node is not a brick node, type = ' + value.type); | ||
} | ||
return this.getBrick(value.brickId); | ||
}; | ||
BaseTemplate.prototype.getBrick = function (brickId) { | ||
var brick = this.brickMap[brickId]; | ||
if (!brick) { | ||
throw new Error("Brick: " + brickId + " is not under current template"); | ||
} | ||
return brick; | ||
}; | ||
BaseTemplate.prototype.getBrickMap = function () { | ||
return this.brickMap; | ||
}; | ||
BaseTemplate.prototype.dispose = function () { | ||
var _this = this; | ||
if (this.isDisposed) { | ||
return; | ||
} | ||
this.isDisposed = true; | ||
Object.values(this.boardMap).forEach(function (board) { | ||
board.dispose(); | ||
delete _this.boardMap[board.id]; | ||
}); | ||
Object.values(this.brickMap).forEach(function (brick) { | ||
brick.dispose(); | ||
delete _this.brickMap[brick.id]; | ||
}); | ||
}; | ||
BaseTemplate.prototype.createBoard = function (config) { | ||
var board = this.innerCreateBoard(config); | ||
this.boardMap[board.id] = board; | ||
return board.getNode(); | ||
}; | ||
BaseTemplate.prototype.createBrick = function (config, board) { | ||
var brick = this.innerCreateBrick(config, board); | ||
this.brickMap[brick.id] = brick; | ||
return brick.getNode(); | ||
}; | ||
BaseTemplate.prototype.disposeNode = function (node) { | ||
if (this.node === node) { | ||
throw new Error('rootBoard can not be removed.'); | ||
} | ||
var info = node.getValue(); | ||
if (info.type === Node_1.NodeType.BRICK) { | ||
var brick = this.brickMap[info.brickId]; | ||
if (brick == null) { | ||
return; | ||
} | ||
delete this.brickMap[info.brickId]; | ||
brick.dispose(); | ||
} | ||
else if (info.type === Node_1.NodeType.LAYER || info.type === Node_1.NodeType.STREAM) { | ||
var board = this.boardMap[info.boardId]; | ||
if (board == null) { | ||
return; | ||
} | ||
board.dispose(); | ||
delete this.boardMap[info.boardId]; | ||
} | ||
node.remove(); | ||
}; | ||
BaseTemplate.prototype.init = function (board) { | ||
var node = this.createBoard(__assign(__assign({}, board), { id: 'root' })); | ||
if (!node) { | ||
throw new Error('create root board fail.'); | ||
} | ||
this.node = node; | ||
}; | ||
return BaseTemplate; | ||
}()); | ||
exports.BaseTemplate = BaseTemplate; |
@@ -1,1 +0,88 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getDefaultCanvasPosition=getDefaultCanvasPosition,exports.Canvas=void 0;var _emitter=require("@co-hooks/emitter");function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _classCallCheck(t,o){if(!(t instanceof o))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,o){for(var e=0;e<o.length;e++){var n=o[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _createClass(t,o,e){return o&&_defineProperties(t.prototype,o),e&&_defineProperties(t,e),t}function _possibleConstructorReturn(t,o){return!o||"object"!==_typeof(o)&&"function"!=typeof o?_assertThisInitialized(t):o}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _getPrototypeOf(t){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function _inherits(t,o){if("function"!=typeof o&&null!==o)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(o&&o.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),o&&_setPrototypeOf(t,o)}function _setPrototypeOf(t,o){return(_setPrototypeOf=Object.setPrototypeOf||function(t,o){return t.__proto__=o,t})(t,o)}var MIN_ZOOM_PERCENT=50,MAX_ZOOM_PERCENT=200;function getDefaultCanvasPosition(t){return{x:0,y:0,zoom:t}}var Canvas=function(t){function o(t,e){var n;return _classCallCheck(this,o),(n=_possibleConstructorReturn(this,_getPrototypeOf(o).call(this))).minZoom=MIN_ZOOM_PERCENT,n.maxZoom=MAX_ZOOM_PERCENT,n.zoomStep=10,n.position=getDefaultCanvasPosition(t||100),n.updateCanvasConfig(e),n}return _inherits(o,_emitter.Emitter),_createClass(o,[{key:"updateCanvasConfig",value:function(t){var o=t.minZoom,e=void 0===o?MIN_ZOOM_PERCENT:o,n=t.maxZoom,i=void 0===n?MAX_ZOOM_PERCENT:n,r=t.zoomStep,s=void 0===r?10:r;this.minZoom=e,this.maxZoom=i,this.zoomStep=s}},{key:"setCanvasPosition",value:function(t){var o=t.x,e=t.y,n=t.zoom,i=this.getCanvasPosition();null==o&&(o=i.x),null==e&&(e=i.y),null==n&&(n=i.zoom),n=Math.max(this.minZoom,Math.min(this.maxZoom,n)),this.position={x:o,y:e,zoom:n},this.emit("position-change",this.getCanvasPosition())}},{key:"getCanvasPosition",value:function(){return this.position}},{key:"increaseZoom",value:function(){var t=this.getCanvasPosition();this.setCanvasPosition({zoom:t.zoom+this.zoomStep})}},{key:"decreaseZoom",value:function(){var t=this.getCanvasPosition();this.setCanvasPosition({zoom:t.zoom-this.zoomStep})}},{key:"move",value:function(t,o){var e=this.getCanvasPosition();this.setCanvasPosition({x:e.x+t,y:e.y+o})}}]),o}();exports.Canvas=Canvas; | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var emitter_1 = require("@co-hooks/emitter"); | ||
var MIN_ZOOM_PERCENT = 50; | ||
var MAX_ZOOM_PERCENT = 200; | ||
function getDefaultCanvasPosition(zoom) { | ||
return { | ||
x: 0, | ||
y: 0, | ||
zoom: zoom | ||
}; | ||
} | ||
exports.getDefaultCanvasPosition = getDefaultCanvasPosition; | ||
var Canvas = (function (_super) { | ||
__extends(Canvas, _super); | ||
function Canvas(defaultZoom, config) { | ||
var _this = _super.call(this) || this; | ||
_this.minZoom = MIN_ZOOM_PERCENT; | ||
_this.maxZoom = MAX_ZOOM_PERCENT; | ||
_this.zoomStep = 10; | ||
_this.position = getDefaultCanvasPosition(defaultZoom || 100); | ||
_this.updateCanvasConfig(config); | ||
return _this; | ||
} | ||
Canvas.prototype.updateCanvasConfig = function (config) { | ||
var _a = config.minZoom, minZoom = _a === void 0 ? MIN_ZOOM_PERCENT : _a, _b = config.maxZoom, maxZoom = _b === void 0 ? MAX_ZOOM_PERCENT : _b, _c = config.zoomStep, zoomStep = _c === void 0 ? 10 : _c; | ||
this.minZoom = minZoom; | ||
this.maxZoom = maxZoom; | ||
this.zoomStep = zoomStep; | ||
}; | ||
Canvas.prototype.setCanvasPosition = function (pos) { | ||
var x = pos.x, y = pos.y, zoom = pos.zoom; | ||
var oldPosition = this.getCanvasPosition(); | ||
if (x == null) { | ||
x = oldPosition.x; | ||
} | ||
if (y == null) { | ||
y = oldPosition.y; | ||
} | ||
if (zoom == null) { | ||
zoom = oldPosition.zoom; | ||
} | ||
zoom = Math.max(this.minZoom, Math.min(this.maxZoom, zoom)); | ||
this.position = { | ||
x: x, | ||
y: y, | ||
zoom: zoom | ||
}; | ||
this.emit('position-change', this.getCanvasPosition()); | ||
}; | ||
Canvas.prototype.getCanvasPosition = function () { | ||
return this.position; | ||
}; | ||
Canvas.prototype.increaseZoom = function () { | ||
var position = this.getCanvasPosition(); | ||
this.setCanvasPosition({ | ||
zoom: position.zoom + this.zoomStep | ||
}); | ||
}; | ||
Canvas.prototype.decreaseZoom = function () { | ||
var position = this.getCanvasPosition(); | ||
this.setCanvasPosition({ | ||
zoom: position.zoom - this.zoomStep | ||
}); | ||
}; | ||
Canvas.prototype.move = function (deltaX, deltaY) { | ||
var position = this.getCanvasPosition(); | ||
this.setCanvasPosition({ | ||
x: position.x + deltaX, | ||
y: position.y + deltaY | ||
}); | ||
}; | ||
return Canvas; | ||
}(emitter_1.Emitter)); | ||
exports.Canvas = Canvas; |
@@ -1,1 +0,119 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getDefaultValidateInfo=getDefaultValidateInfo,exports.EditableBaseBrick=void 0;var _util=require("@co-hooks/util"),_Diff=require("../types/Diff"),_BaseBrick2=require("./BaseBrick");function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var r=0;r<e.length;r++){var a=e[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function _createClass(t,e,r){return e&&_defineProperties(t.prototype,e),r&&_defineProperties(t,r),t}function _possibleConstructorReturn(t,e){return!e||"object"!==_typeof(e)&&"function"!=typeof e?_assertThisInitialized(t):e}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _getPrototypeOf(t){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return(_setPrototypeOf=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var EditableBaseBrick=function(t){function e(t){var r;_classCallCheck(this,e),(r=_possibleConstructorReturn(this,_getPrototypeOf(e).call(this,{id:t.data.id||(0,_util.guid)(),owner:t.owner,data:t.data}))).status=_Diff.DiffType.NONE;var a=t.config;return r.brickConfig=a,r.mockData=t.config.mockData,r.updateInstanceFromData(!0),r.initPart(),r}return _inherits(e,_BaseBrick2.BaseBrick),_createClass(e,[{key:"setValue",value:function(t,e,r){if(null==this.brickConfig||null==this.data)throw new Error("call method `initEditorBrickInstance` first");this.getEditorBrickConfig().setValueToBrickData(this.data,t),this.updateInstanceFromData()}},{key:"getDatasource",value:function(){}},{key:"dispatchEvent",value:function(t,e){}},{key:"setBrickDataProperties",value:function(t){var e=this,r=t.every((function(t){var r=t.path,a=t.value,i=(0,_util.setObjectProperty)(e.data,a,r.split("."));return i||console.warn("Brick: ".concat(e.brickType," set properties ").concat(r," = ").concat(a," fail")),i}));return this.updateInstanceFromData(),r}},{key:"setData",value:function(t){this.data=t,t.id=this.id,this.updateInstanceFromData()}},{key:"isContainer",value:function(){return this.getEditorBrickConfig().isContainer||!1}},{key:"getEditorBrickConfig",value:function(){return this.brickConfig}},{key:"updateInstanceFromData",value:function(t){var e=this.data,r=this.brickConfig;if(null==r||null==e)throw new Error("call method `initEditorBrickInstance` first");var a=e.info,i=a.field,o=a.label,n=e.type,c=e.styles,s=e.layout,u=void 0===s?r.getDefaultLayout():s;this.updateBrickInstance({label:o||n,field:i,readonly:!i,value:r.getValueFromBrickData(e),datasource:r.getDatasourceFromBrickData(e),staticDatasource:r.getDatasourceFromBrickData(e),display:r.getDisplayFromBrickData(e),config:e.config,styles:c,validateInfo:getDefaultValidateInfo(),layout:u,loading:!1,validating:!1,manual:!0,ready:!0},t)}},{key:"initPart",value:function(){var t=this,e=this.data,r=e.parts;r&&(delete e.parts,Object.keys(r).forEach((function(e){t.node.appendChild(t.createPartBoard(e,r[e]))})))}}]),e}();function getDefaultValidateInfo(){return{catchable:!1,needValidate:!1,partial:!1,valid:!0,error:"",children:[]}}exports.EditableBaseBrick=EditableBaseBrick; | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var util_1 = require("@co-hooks/util"); | ||
var Diff_1 = require("../types/Diff"); | ||
var BaseBrick_1 = require("./BaseBrick"); | ||
var EditableBaseBrick = (function (_super) { | ||
__extends(EditableBaseBrick, _super); | ||
function EditableBaseBrick(options) { | ||
var _this = _super.call(this, { | ||
id: options.data.id || util_1.guid(), | ||
owner: options.owner, | ||
data: options.data | ||
}) || this; | ||
_this.status = Diff_1.DiffType.NONE; | ||
var config = options.config; | ||
_this.brickConfig = config; | ||
_this.mockData = options.config.mockData; | ||
_this.updateInstanceFromData(true); | ||
_this.initPart(); | ||
return _this; | ||
} | ||
EditableBaseBrick.prototype.setValue = function (value, manual, isSilent) { | ||
if (this.brickConfig == null || this.data == null) { | ||
throw new Error('call method `initEditorBrickInstance` first'); | ||
} | ||
this.getEditorBrickConfig().setValueToBrickData(this.data, value); | ||
this.updateInstanceFromData(); | ||
}; | ||
EditableBaseBrick.prototype.getDatasource = function () { | ||
}; | ||
EditableBaseBrick.prototype.dispatchEvent = function (name, e) { | ||
}; | ||
EditableBaseBrick.prototype.setBrickDataProperties = function (properties) { | ||
var _this = this; | ||
var res = properties.every(function (_a) { | ||
var path = _a.path, value = _a.value; | ||
var success = util_1.setObjectProperty(_this.data, value, path.split('.')); | ||
if (!success) { | ||
console.warn("Brick: " + _this.brickType + " set properties " + path + " = " + value + " fail"); | ||
} | ||
return success; | ||
}); | ||
this.updateInstanceFromData(); | ||
return res; | ||
}; | ||
EditableBaseBrick.prototype.setData = function (data) { | ||
this.data = data; | ||
data.id = this.id; | ||
this.updateInstanceFromData(); | ||
}; | ||
EditableBaseBrick.prototype.isContainer = function () { | ||
return this.getEditorBrickConfig().isContainer || false; | ||
}; | ||
EditableBaseBrick.prototype.getEditorBrickConfig = function () { | ||
return this.brickConfig; | ||
}; | ||
EditableBaseBrick.prototype.updateInstanceFromData = function (isSilent) { | ||
var _a = this, data = _a.data, brickConfig = _a.brickConfig; | ||
if (brickConfig == null || data == null) { | ||
throw new Error('call method `initEditorBrickInstance` first'); | ||
} | ||
var _b = data.info, field = _b.field, label = _b.label, type = data.type, styles = data.styles, _c = data.layout, layout = _c === void 0 ? brickConfig.getDefaultLayout() : _c; | ||
this.updateBrickInstance({ | ||
label: label || type, | ||
field: field, | ||
readonly: !field, | ||
value: brickConfig.getValueFromBrickData(data), | ||
datasource: brickConfig.getDatasourceFromBrickData(data), | ||
staticDatasource: brickConfig.getDatasourceFromBrickData(data), | ||
display: brickConfig.getDisplayFromBrickData(data), | ||
config: data.config, | ||
styles: styles, | ||
validateInfo: getDefaultValidateInfo(), | ||
layout: layout, | ||
loading: false, | ||
validating: false, | ||
manual: true, | ||
ready: true | ||
}, isSilent); | ||
}; | ||
EditableBaseBrick.prototype.initPart = function () { | ||
var _this = this; | ||
var data = this.data; | ||
var parts = data.parts; | ||
if (!parts) { | ||
return; | ||
} | ||
delete data.parts; | ||
Object.keys(parts).forEach(function (key) { | ||
_this.node.appendChild(_this.createPartBoard(key, parts[key])); | ||
}); | ||
}; | ||
return EditableBaseBrick; | ||
}(BaseBrick_1.BaseBrick)); | ||
exports.EditableBaseBrick = EditableBaseBrick; | ||
function getDefaultValidateInfo() { | ||
return { | ||
catchable: false, | ||
needValidate: false, | ||
partial: false, | ||
valid: true, | ||
error: '', | ||
children: [] | ||
}; | ||
} | ||
exports.getDefaultValidateInfo = getDefaultValidateInfo; |
@@ -1,1 +0,111 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HotKey=void 0;var _events=_interopRequireDefault(require("events")),_hotkey=require("@co-hooks/hotkey");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}function _possibleConstructorReturn(e,t){return!t||"object"!==_typeof(t)&&"function"!=typeof t?_assertThisInitialized(e):t}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var IS_MAC=["Mac68K","MacPPC","Macintosh","MacIntel"].indexOf(navigator.platform)>=0,HOT_KEY_ALAIS={command:IS_MAC?"command":"ctrl",alt:IS_MAC?"option":"alt",delete:"backspace"},HotKey=function(e){function t(){var e;return _classCallCheck(this,t),(e=_possibleConstructorReturn(this,_getPrototypeOf(t).call(this))).listener=new _hotkey.HotKey,e.funcKeyState={},e.setMaxListeners(0),e}return _inherits(t,_events.default),_createClass(t,[{key:"registerHotKey",value:function(e,t){var n=t.keydown,o=t.keyup,r=t.keypress,i=t.latest;this.register(e,n,o,r,i)}},{key:"unregisterHotKey",value:function(e,t){var n=t.keydown,o=t.keyup,r=t.keypress;this.unregister(e,n,o,r)}},{key:"registerFuncKey",value:function(e){var t=this,n=HOT_KEY_ALAIS[e]||e;if(!this.funcKeyState[n]){var o={keydown:function(){t.funcKeyState[n]&&t.emit("".concat(e,"-change"),t.funcKeyState[n].state=!0)},keyup:function(){t.funcKeyState[n]&&t.emit("".concat(e,"-change"),t.funcKeyState[n].state=!1)},state:!1};this.funcKeyState[n]=o,this.register(n,o.keydown,o.keyup)}}},{key:"unregisterFuncKey",value:function(e){e=HOT_KEY_ALAIS[e]||e;var t=this.funcKeyState[e];if(t){var n=t.keydown,o=t.keyup;delete this.funcKeyState[e],this.unregister(e,n,o)}}},{key:"isFuncKeyDown",value:function(e){e=HOT_KEY_ALAIS[e]||e;var t=this.funcKeyState[e];return!!t&&t.state}},{key:"register",value:function(e,t,n,o){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4];null!=t&&this.listener.addHotKeys([e],t,"keydown",!r),null!=n&&this.listener.addHotKeys([e],n,"keyup",!r),null!=o&&this.listener.addHotKeys([e],o,"keypress",!r)}},{key:"unregister",value:function(e,t,n,o){null!=t&&this.listener.removeHotKeys([e],t,"keydown"),null!=n&&this.listener.removeHotKeys([e],n,"keyup"),null!=o&&this.listener.removeHotKeys([e],o,"keypress")}}]),t}();exports.HotKey=HotKey,HotKey.IS_MAC=IS_MAC,HotKey.HOT_KEY_ALAIS=HOT_KEY_ALAIS; | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var events_1 = __importDefault(require("events")); | ||
var hotkey_1 = require("@co-hooks/hotkey"); | ||
var IS_MAC = ['Mac68K', 'MacPPC', 'Macintosh', 'MacIntel'].indexOf(navigator.platform) >= 0; | ||
var HOT_KEY_ALAIS = { | ||
command: IS_MAC ? 'command' : 'ctrl', | ||
alt: IS_MAC ? 'option' : 'alt', | ||
delete: 'backspace' | ||
}; | ||
var HotKey = (function (_super) { | ||
__extends(HotKey, _super); | ||
function HotKey() { | ||
var _this = _super.call(this) || this; | ||
_this.listener = new hotkey_1.HotKey(); | ||
_this.funcKeyState = {}; | ||
_this.setMaxListeners(0); | ||
return _this; | ||
} | ||
HotKey.prototype.registerHotKey = function (key, options) { | ||
var keydown = options.keydown, keyup = options.keyup, keypress = options.keypress, latest = options.latest; | ||
this.register(key, keydown, keyup, keypress, latest); | ||
}; | ||
HotKey.prototype.unregisterHotKey = function (key, options) { | ||
var keydown = options.keydown, keyup = options.keyup, keypress = options.keypress; | ||
this.unregister(key, keydown, keyup, keypress); | ||
}; | ||
HotKey.prototype.registerFuncKey = function (key) { | ||
var _this = this; | ||
var bindkey = HOT_KEY_ALAIS[key] || key; | ||
if (this.funcKeyState[bindkey]) { | ||
return; | ||
} | ||
var funcKeyItem = { | ||
keydown: function () { | ||
if (_this.funcKeyState[bindkey]) { | ||
_this.emit(key + "-change", _this.funcKeyState[bindkey].state = true); | ||
} | ||
}, | ||
keyup: function () { | ||
if (_this.funcKeyState[bindkey]) { | ||
_this.emit(key + "-change", _this.funcKeyState[bindkey].state = false); | ||
} | ||
}, | ||
state: false | ||
}; | ||
this.funcKeyState[bindkey] = funcKeyItem; | ||
this.register(bindkey, funcKeyItem.keydown, funcKeyItem.keyup); | ||
}; | ||
HotKey.prototype.unregisterFuncKey = function (key) { | ||
key = HOT_KEY_ALAIS[key] || key; | ||
var funcKeyStateInfo = this.funcKeyState[key]; | ||
if (!funcKeyStateInfo) { | ||
return; | ||
} | ||
var keydown = funcKeyStateInfo.keydown, keyup = funcKeyStateInfo.keyup; | ||
delete this.funcKeyState[key]; | ||
this.unregister(key, keydown, keyup); | ||
}; | ||
HotKey.prototype.isFuncKeyDown = function (key) { | ||
key = HOT_KEY_ALAIS[key] || key; | ||
var funcKeyStateInfo = this.funcKeyState[key]; | ||
if (!funcKeyStateInfo) { | ||
return false; | ||
} | ||
return funcKeyStateInfo.state; | ||
}; | ||
HotKey.prototype.register = function (key, keydown, keyup, keypress, latest) { | ||
if (latest === void 0) { latest = false; } | ||
if (keydown != null) { | ||
this.listener.addHotKeys([key], keydown, 'keydown', !latest); | ||
} | ||
if (keyup != null) { | ||
this.listener.addHotKeys([key], keyup, 'keyup', !latest); | ||
} | ||
if (keypress != null) { | ||
this.listener.addHotKeys([key], keypress, 'keypress', !latest); | ||
} | ||
}; | ||
HotKey.prototype.unregister = function (key, keydown, keyup, keypress) { | ||
if (keydown != null) { | ||
this.listener.removeHotKeys([key], keydown, 'keydown'); | ||
} | ||
if (keyup != null) { | ||
this.listener.removeHotKeys([key], keyup, 'keyup'); | ||
} | ||
if (keypress != null) { | ||
this.listener.removeHotKeys([key], keypress, 'keypress'); | ||
} | ||
}; | ||
HotKey.IS_MAC = IS_MAC; | ||
HotKey.HOT_KEY_ALAIS = HOT_KEY_ALAIS; | ||
return HotKey; | ||
}(events_1.default)); | ||
exports.HotKey = HotKey; |
@@ -1,1 +0,85 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Mask=void 0;var _emitter=require("@co-hooks/emitter");function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass(e,t,o){return t&&_defineProperties(e.prototype,t),o&&_defineProperties(e,o),e}function _possibleConstructorReturn(e,t){return!t||"object"!==_typeof(t)&&"function"!=typeof t?_assertThisInitialized(e):t}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Mask=function(e){function t(e){var o;return _classCallCheck(this,t),(o=_possibleConstructorReturn(this,_getPrototypeOf(t).call(this))).activeKey="",o.op={},o.hotkey=e,o}return _inherits(t,_emitter.Emitter),_createClass(t,[{key:"register",value:function(e,t){var o=this,r=t.onDragStart,n=t.onDragging,i=t.onDragEnd,a=t.onClick;if(e in this.op)throw new Error("register duplicate op '".concat(e,"'"));this.op[e]={key:e,onDragStart:r,onDragging:n,onDragEnd:i,onClick:a,handler:function(t){o.activeKey=t?e:"",o.emit("change",o.activeKey)}},this.hotkey.registerFuncKey(e),this.hotkey.addListener(e+"-change",this.op[e].handler)}},{key:"unregister",value:function(e){if(e in this.op){var t=this.op[e].handler;this.hotkey.unregisterFuncKey(e),this.hotkey.removeListener(e+"-change",t),delete this.op[e]}}},{key:"onDragStart",value:function(e){if(this.activeKey){var t=this.op[this.activeKey].onDragStart;t&&t(e)}}},{key:"onDragging",value:function(e){if(this.activeKey){var t=this.op[this.activeKey].onDragging;t&&t(e)}}},{key:"onDragEnd",value:function(e){if(this.activeKey){var t=this.op[this.activeKey].onDragEnd;t&&t(e)}}},{key:"onClick",value:function(e){if(this.activeKey){var t=this.op[this.activeKey].onClick;t&&t(e)}}}]),t}();exports.Mask=Mask; | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var emitter_1 = require("@co-hooks/emitter"); | ||
var Mask = (function (_super) { | ||
__extends(Mask, _super); | ||
function Mask(hotkey) { | ||
var _this = _super.call(this) || this; | ||
_this.activeKey = ''; | ||
_this.op = {}; | ||
_this.hotkey = hotkey; | ||
return _this; | ||
} | ||
Mask.prototype.register = function (key, options) { | ||
var _this = this; | ||
var onDragStart = options.onDragStart, onDragging = options.onDragging, onDragEnd = options.onDragEnd, onClick = options.onClick; | ||
if (key in this.op) { | ||
throw new Error("register duplicate op '" + key + "'"); | ||
} | ||
this.op[key] = { | ||
key: key, | ||
onDragStart: onDragStart, | ||
onDragging: onDragging, | ||
onDragEnd: onDragEnd, | ||
onClick: onClick, | ||
handler: function (state) { | ||
_this.activeKey = state ? key : ''; | ||
_this.emit('change', _this.activeKey); | ||
} | ||
}; | ||
this.hotkey.registerFuncKey(key); | ||
this.hotkey.addListener(key + '-change', this.op[key].handler); | ||
}; | ||
Mask.prototype.unregister = function (key) { | ||
if (!(key in this.op)) { | ||
return; | ||
} | ||
var handler = this.op[key].handler; | ||
this.hotkey.unregisterFuncKey(key); | ||
this.hotkey.removeListener(key + '-change', handler); | ||
delete this.op[key]; | ||
}; | ||
Mask.prototype.onDragStart = function (e) { | ||
if (!this.activeKey) { | ||
return; | ||
} | ||
var onDragStart = this.op[this.activeKey].onDragStart; | ||
onDragStart && onDragStart(e); | ||
}; | ||
Mask.prototype.onDragging = function (e) { | ||
if (!this.activeKey) { | ||
return; | ||
} | ||
var onDragging = this.op[this.activeKey].onDragging; | ||
onDragging && onDragging(e); | ||
}; | ||
Mask.prototype.onDragEnd = function (e) { | ||
if (!this.activeKey) { | ||
return; | ||
} | ||
var onDragEnd = this.op[this.activeKey].onDragEnd; | ||
onDragEnd && onDragEnd(e); | ||
}; | ||
Mask.prototype.onClick = function (e) { | ||
if (!this.activeKey) { | ||
return; | ||
} | ||
var onClick = this.op[this.activeKey].onClick; | ||
onClick && onClick(e); | ||
}; | ||
return Mask; | ||
}(emitter_1.Emitter)); | ||
exports.Mask = Mask; |
@@ -1,1 +0,2 @@ | ||
"use strict"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -1,1 +0,2 @@ | ||
"use strict"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -1,1 +0,26 @@ | ||
"use strict";var PropConflictType,DiffType,DataType,PropDiffId;Object.defineProperty(exports,"__esModule",{value:!0}),exports.PropDiffId=exports.DataType=exports.DiffType=exports.PropConflictType=void 0,exports.PropConflictType=PropConflictType,function(p){p.NONE="NONE",p.DOUBLE_EDIT="DOUBLE_EDIT"}(PropConflictType||(exports.PropConflictType=PropConflictType={})),exports.DiffType=DiffType,function(p){p.NONE="NONE",p.ADD="ADD",p.REMOVE="REMOVE",p.MOVE="MOVE",p.EDIT="EDIT",p.EDIT_ITEM="EDIT_ITEM"}(DiffType||(exports.DiffType=DiffType={})),exports.DataType=DataType,function(p){p.DIFF="DIFF",p.MERGE="MERGE"}(DataType||(exports.DataType=DataType={})),exports.PropDiffId=PropDiffId,function(p){p.BIND="prop",p.DEFAULT="__diff_id__"}(PropDiffId||(exports.PropDiffId=PropDiffId={})); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var PropConflictType; | ||
(function (PropConflictType) { | ||
PropConflictType["NONE"] = "NONE"; | ||
PropConflictType["DOUBLE_EDIT"] = "DOUBLE_EDIT"; | ||
})(PropConflictType = exports.PropConflictType || (exports.PropConflictType = {})); | ||
var DiffType; | ||
(function (DiffType) { | ||
DiffType["NONE"] = "NONE"; | ||
DiffType["ADD"] = "ADD"; | ||
DiffType["REMOVE"] = "REMOVE"; | ||
DiffType["MOVE"] = "MOVE"; | ||
DiffType["EDIT"] = "EDIT"; | ||
DiffType["EDIT_ITEM"] = "EDIT_ITEM"; | ||
})(DiffType = exports.DiffType || (exports.DiffType = {})); | ||
var DataType; | ||
(function (DataType) { | ||
DataType["DIFF"] = "DIFF"; | ||
DataType["MERGE"] = "MERGE"; | ||
})(DataType = exports.DataType || (exports.DataType = {})); | ||
var PropDiffId; | ||
(function (PropDiffId) { | ||
PropDiffId["BIND"] = "prop"; | ||
PropDiffId["DEFAULT"] = "__diff_id__"; | ||
})(PropDiffId = exports.PropDiffId || (exports.PropDiffId = {})); |
@@ -1,1 +0,2 @@ | ||
"use strict"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -1,1 +0,16 @@ | ||
"use strict";var FloatType,NodeType;Object.defineProperty(exports,"__esModule",{value:!0}),exports.NodeType=exports.FloatType=void 0,exports.FloatType=FloatType,function(e){e.LEFT="left",e.RIGHT="right",e.NONE="none"}(FloatType||(exports.FloatType=FloatType={})),exports.NodeType=NodeType,function(e){e.STREAM="Stream",e.ROOT="root",e.TEMPLATE="template",e.LAYER="layer",e.BRICK="brick"}(NodeType||(exports.NodeType=NodeType={})); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var FloatType; | ||
(function (FloatType) { | ||
FloatType["LEFT"] = "left"; | ||
FloatType["RIGHT"] = "right"; | ||
FloatType["NONE"] = "none"; | ||
})(FloatType = exports.FloatType || (exports.FloatType = {})); | ||
var NodeType; | ||
(function (NodeType) { | ||
NodeType["STREAM"] = "Stream"; | ||
NodeType["ROOT"] = "root"; | ||
NodeType["TEMPLATE"] = "template"; | ||
NodeType["LAYER"] = "layer"; | ||
NodeType["BRICK"] = "brick"; | ||
})(NodeType = exports.NodeType || (exports.NodeType = {})); |
@@ -1,1 +0,2 @@ | ||
"use strict"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
{ | ||
"name": "@chief-editor/base", | ||
"description": "FlowEditor Base Class", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"author": "Yu Zong<liuxuanzy@qq.com>", | ||
@@ -34,3 +34,3 @@ "contributors": [ | ||
}, | ||
"gitHead": "409ce4870bc8652641c52b8510faff85de0add96" | ||
"gitHead": "941b8b0a792d8286f5e293c9cf0385dd8a94ae79" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
132013
3428
2
0