@berviantoleo/react-multi-crop 0.40.4 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.41.0](https://github.com/berviantoleo/react-multi-crop/compare/@berviantoleo/react-multi-crop@0.40.4...@berviantoleo/react-multi-crop@0.41.0) (2025-01-11)
7
+
8
+ ### Features
9
+
10
+ - add tabIndex ([#3409](https://github.com/berviantoleo/react-multi-crop/issues/3409)) ([d283615](https://github.com/berviantoleo/react-multi-crop/commit/d2836155d80425a4faa669eeddd735d054f65623))
11
+
6
12
  ## [0.40.4](https://github.com/berviantoleo/react-multi-crop/compare/@berviantoleo/react-multi-crop@0.40.3...@berviantoleo/react-multi-crop@0.40.4) (2025-01-03)
7
13
 
8
14
  **Note:** Version bump only for package @berviantoleo/react-multi-crop
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("react"),e=require("fabric"),r=require("uuid");function o(t){return o="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},o(t)}var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},i(t,e)};function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}"function"==typeof SuppressedError&&SuppressedError;var a=function(t){function e(e){var r=t.call(this,e)||this;return r.id=null,r.objectId="",e&&(r.id=e.id,r.objectId=e.objectId),r}return n(e,t),e}(e.fabric.Rect);function c(e){var r=e.children,o=e.height,i=e.width,n=e.row,a=void 0!==n&&n;return t.createElement("div",{style:{display:"flex",flexDirection:a?"row":"column",gap:"10px",height:o,width:i}},r)}function l(e){var r=e.addButton,o=e.addNew,i=e.deleteButton,n=e.deleteShapes,a=e.discardActiveObject,l=e.discardButton;return t.createElement(c,null,t.createElement("div",null,r&&t.cloneElement(r,{onClick:o})),t.createElement("div",null,i&&t.cloneElement(i,{onClick:n})),t.createElement("div",null,l&&t.cloneElement(l,{onClick:a})))}var s=function(i){function s(t){var e=i.call(this,t)||this;return e.REGEXP_ORIGINS=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i,e.state={canvas:null,initial:!0},e.keyboardHandler=e.keyboardHandler.bind(e),e.addNew=e.addNew.bind(e),e.deleteShapes=e.deleteShapes.bind(e),e.discardActiveObject=e.discardActiveObject.bind(e),e}return n(s,i),s.prototype.componentDidMount=function(){this.state.canvas||this.initialCanvas()},s.prototype.componentDidUpdate=function(t){var e=this.state.canvas;if(e){var r=this.props,o=r.zoomLevel,i=r.activeObject,n=r.height,a=r.width,c=r.borderColor,l=r.cornerColor,s=r.cornerSize,d=r.transparentCorners,p=r.cropBackgroundColor,u=r.cropBackgroundOpacity,h=r.record,v=r.disableZoom,g=void 0!==v&&v,y=t.zoomLevel,f=t.activeObject,b=t.height,C=t.width,m=t.borderColor,O=t.cornerColor,k=t.cornerSize,w=t.transparentCorners,S=t.cropBackgroundColor,B=t.cropBackgroundOpacity,j=t.record,A=!1;if(y!==o&&o&&o>0&&(e.setZoom(o),A=!0),f!==i&&i){var I=e.getObjects().filter((function(t){return t.objectId===i}));e.discardActiveObject();for(var z=0,E=I;z<E.length;z++){var H=E[z];e.setActiveObject(H)}A=!0}if(e.off("mouse:wheel"),!g){var x=this.zoom.bind(this);e.on("mouse:wheel",x)}if(n&&n!==b&&(e.setHeight(n),A=!0),a&&a!==C&&(e.setWidth(a),A=!0),c!==m||l!==O||s!==k||d!==w||p!==S||u!==B){var D={borderColor:c,cornerColor:l,cornerSize:s,transparentCorners:d,cropBackgroundColor:p,cropBackgroundOpacity:u};this.updateCropAttributes(e,D),A=!0}var R=j;if(Array.isArray(R.clippings)&&h&&Array.isArray(null==h?void 0:h.clippings)){var P=h.clippings.filter((function(t){var e,r,o,i,n,a,c,l,s,d,p,u,h=R.clippings.find((function(e){return e.id===t.id||e.objectId&&e.objectId===t.objectId}));return!!h&&((null===(e=t.style)||void 0===e?void 0:e.borderColor)!==(null===(r=h.style)||void 0===r?void 0:r.borderColor)||(null===(o=t.style)||void 0===o?void 0:o.cornerColor)!==(null===(i=h.style)||void 0===i?void 0:i.cornerColor)||(null===(n=t.style)||void 0===n?void 0:n.cornerSize)!==(null===(a=h.style)||void 0===a?void 0:a.cornerSize)||(null===(c=t.style)||void 0===c?void 0:c.transparentCorners)!==(null===(l=h.style)||void 0===l?void 0:l.transparentCorners)||(null===(s=t.style)||void 0===s?void 0:s.cropBackgroundColor)!==(null===(d=h.style)||void 0===d?void 0:d.cropBackgroundColor)||(null===(p=t.style)||void 0===p?void 0:p.cropBackgroundOpacity)!==(null===(u=h.style)||void 0===u?void 0:u.cropBackgroundOpacity))})),X=e.getObjects("rect");if(Array.isArray(X)&&X.length>0){var Y=0;P.forEach((function(t){var e,r,o,i,n,a,c=X.find((function(e){var r=e;return r.id===t.id||r.objectId===t.objectId}));c&&(c.borderColor=null===(e=t.style)||void 0===e?void 0:e.borderColor,c.cornerColor=null===(r=t.style)||void 0===r?void 0:r.cornerColor,c.cornerSize=null===(o=t.style)||void 0===o?void 0:o.cornerSize,c.transparentCorners=null===(i=t.style)||void 0===i?void 0:i.transparentCorners,c.opacity=null===(n=t.style)||void 0===n?void 0:n.cropBackgroundOpacity,c.set("fill",null===(a=t.style)||void 0===a?void 0:a.cropBackgroundColor),Y+=1)})),Y>0&&(A=!0)}}A&&e.requestRenderAll()}},s.prototype.updateCropAttributes=function(t,e){var r=t.getObjects("rect");Array.isArray(r)&&r.length>0&&r.forEach((function(t){t.borderColor=e.borderColor,t.cornerColor=e.cornerColor,t.cornerSize=e.cornerSize,t.transparentCorners=e.transparentCorners,t.opacity=e.cropBackgroundOpacity,t.set("fill",e.cropBackgroundColor)}))},s.prototype.changeImage=function(){var t=this.state.canvas;t&&(t.backgroundImage||this.initialImage())},s.prototype.loadImage=function(t){var e=this.state,r=e.initial,o=e.canvas;if(o&&o.width&&o.height&&t.height&&t.width){var i=this.props.zoomLevel,n=t.height/t.width,a=o.width*n;o.setHeight(a),i?o.setZoom(i):o.setZoom(o.width/t.width),o.setBackgroundImage(t,o.renderAll.bind(o)),r&&this.setState({initial:!1},this.initialObjects.bind(this))}},s.prototype.isCrossOriginURL=function(t){var e=t.match(this.REGEXP_ORIGINS);return null!==e&&(e[1]!==window.location.protocol||e[2]!==window.location.hostname||e[3]!==window.location.port)},s.prototype.initialImage=function(){var t=this.props.image,r=this.loadImage.bind(this);if("string"==typeof t){var o={};this.isCrossOriginURL(t)&&(o.crossOrigin="Anonymous"),e.fabric.Image.fromURL(t,r,o)}},s.prototype.initialObjects=function(){var t=this.state.canvas;if(t){var e=this.props,r=e.record,i=e.readonly,n=e.borderColor,a=e.cornerColor,c=e.cornerSize,l=e.transparentCorners,s=e.cropBackgroundColor,d=e.cropBackgroundOpacity;if(r){var p=r.clippings;if(Array.isArray(p)&&p.length>0&&"object"===o(p[0])){for(var u={borderColor:n,cornerColor:a,cornerSize:c,transparentCorners:l,cropBackgroundColor:s,cropBackgroundOpacity:d},h=0,v=0,g=p;v<g.length;v++){var y=g[v];y.style&&(y.style.cropBackgroundColor&&(u.cropBackgroundColor=y.style.cropBackgroundColor),y.style.cropBackgroundOpacity&&(u.cropBackgroundOpacity=y.style.cropBackgroundOpacity),y.style.borderColor&&(u.borderColor=y.style.borderColor),y.style.cornerColor&&(u.cornerColor=y.style.cornerColor),y.style.cornerSize&&(u.cornerSize=y.style.cornerSize),y.style.transparentCorners&&(u.transparentCorners=y.style.transparentCorners));var f=this.createObject(t,y,u,i||!1);f&&(t.add(f),h+=1)}h>0&&this.setOutput()}}else console.log("Not have any record. Skipped.")}},s.prototype.zoom=function(t){var e=this.state.canvas;if(e){var r=t.e.deltaY,o=e.getZoom();(o*=Math.pow(.999,r))>20&&(o=20),o<.01&&(o=.01),e.setZoom(o),t.e.preventDefault(),t.e.stopPropagation();var i=this.props.zoomChanged;i&&i(o)}},s.prototype.mouseHover=function(t){var e=this.props.onHover,r=this.shapetoStructureData.bind(this),o=t.target;o&&"rect"===o.type&&e&&e(r(o))},s.prototype.mouseOut=function(t){var e=this.props.onHover,r=t.target;r&&"rect"===r.type&&e&&e(null)},s.prototype.selectionHandler=function(t){var e=this.props.onSelect,r=this.shapetoStructureData.bind(this),o=t.selected;if(Array.isArray(o)&&0!=o.length){var i=o[0];if(i&&"rect"===i.type&&e)e(r(i))}},s.prototype.selectionClearHandler=function(){var t=this.props.onSelect;t&&t(null)},s.prototype.initialCanvas=function(){var t=this.props,r=t.id,o=t.width,i=t.height,n=t.readonly,a=new e.fabric.Canvas(r||"canvas",{width:o,height:i});if(n){a.selectionKey=void 0;var c=this.mouseHover.bind(this),l=this.mouseOut.bind(this);a.on("mouse:over",c),a.on("mouse:out",l)}else{var s=this.doubleClickEvent.bind(this),d=this.setOutput.bind(this);a.on("mouse:dblclick",s),a.on("object:modified",d)}var p=this.selectionHandler.bind(this),u=this.selectionClearHandler.bind(this);a.on("selection:created",p),a.on("selection:updated",p),a.on("selection:cleared",u),a.on("mouse:down",(function(t){var e=t.e;!0===e.altKey&&(this.isDragging=!0,this.selection=!1,this.lastPosX=e.clientX,this.lastPosY=e.clientY)})),a.on("mouse:move",(function(t){if(this.isDragging){var e=t.e,r=this.viewportTransform;r[4]+=e.clientX-this.lastPosX,r[5]+=e.clientY-this.lastPosY,this.requestRenderAll(),this.lastPosX=e.clientX,this.lastPosY=e.clientY}})),a.on("mouse:up",(function(){this.setViewportTransform(this.viewportTransform),this.isDragging=!1,this.selection=!0})),this.setState({canvas:a},this.initialImage.bind(this))},s.prototype.addNew=function(){var t=this.state.canvas;if(t){var e=this.props,r={borderColor:e.borderColor,cornerColor:e.cornerColor,cornerSize:e.cornerSize,transparentCorners:e.transparentCorners,cropBackgroundColor:e.cropBackgroundColor,cropBackgroundOpacity:e.cropBackgroundOpacity},o=this.createObject(t,{id:null,rect:{x1:0,y1:0,x2:.2,y2:.2}},r,!1);o&&(t.add(o),this.setOutput())}},s.prototype.doubleClickEvent=function(t){var e=this.state.canvas;if(e){var r=this.props,o=r.readonly,i=r.borderColor,n=r.cornerColor,a=r.cornerSize,c=r.transparentCorners,l=r.cropBackgroundColor,s=r.cropBackgroundOpacity;if(t&&t.target){var d=t.target.left,p=t.target.top,u=t.target.width,h=t.target.height,v={left:d+50,top:p+50,width:u*t.target.scaleX,height:h*t.target.scaleY,borderColor:i,cornerColor:n,cornerSize:a,transparentCorners:c,cropBackgroundColor:l,cropBackgroundOpacity:s},g=this.createObjectByAttribute(null,v,o||!1);e.add(g),e.discardActiveObject(),e.setActiveObject(g),e.requestRenderAll(),this.setOutput()}else if(t&&t.pointer){v={left:d=t.absolutePointer.x,top:t.absolutePointer.y,width:100,height:100,borderColor:i,cornerColor:n,cornerSize:a,transparentCorners:c,cropBackgroundColor:l,cropBackgroundOpacity:s},g=this.createObjectByAttribute(null,v,o||!1);e.add(g),e.discardActiveObject(),e.setActiveObject(g),e.requestRenderAll(),this.setOutput()}}},s.prototype.createObjectByAttribute=function(t,e,o){var i=new a({left:e.left,top:e.top,width:e.width,height:e.height,borderColor:e.borderColor,cornerColor:e.cornerColor,cornerSize:e.cornerSize,transparentCorners:e.transparentCorners,fill:e.cropBackgroundColor,opacity:e.cropBackgroundOpacity,id:t,strokeWidth:0,strokeUniform:!0,lockRotation:!0,lockMovementX:o,lockMovementY:o,lockScalingX:o,lockScalingY:o,objectId:r.v4()});return i.setControlsVisibility({mtr:!1}),i},s.prototype.convertLeftTop=function(t){var e,r,o,i;return void 0===t.left||void 0===t.top||void 0===(null===(e=t.group)||void 0===e?void 0:e.left)||void 0===(null===(r=t.group)||void 0===r?void 0:r.top)||void 0===(null===(o=t.group)||void 0===o?void 0:o.width)||void 0===(null===(i=t.group)||void 0===i?void 0:i.height)?{left:0,top:0}:{left:t.left+t.group.left+t.group.width/2,top:t.top+t.group.top+t.group.height/2}},s.prototype.shapetoStructureData=function(t){var r=this.state.canvas;if(!r||!r.backgroundImage)return null;var o=r.backgroundImage;if(!(o instanceof e.fabric.Image))return null;if(void 0===t.left||void 0===t.top||void 0===t.width||void 0===t.height||void 0===t.scaleX||void 0===t.scaleY||void 0===o.width||void 0===o.height)return null;var i=this.props,n=i.includeDataUrl,a=i.includeHtmlCanvas,c=t.group?this.convertLeftTop(t):{left:t.left,top:t.top},l=c.left/o.width,s=c.top/o.height,d=(c.left+t.width*t.scaleX)/o.width,p=(c.top+t.height*t.scaleY)/o.height,u={x1:l,y1:s,x2:d,y2:p},h={id:t.id,objectId:t.objectId,rect:JSON.stringify(u)};if(n){var v=null;try{v=o.toDataURL({height:t.getScaledHeight(),width:t.getScaledWidth(),left:c.left,top:c.top,format:"jpeg"})}catch(t){console.error(t)}h.dataUrl=v}if(a){var g=null;try{g=o.toCanvasElement({height:t.getScaledHeight(),width:t.getScaledWidth(),left:c.left,top:c.top})}catch(t){console.error(t)}h.canvasElement=g}var y=o.width,f=o.height,b=l*y,C=d*y,m=s*f,O=p*f,k={x:b,y:m,x2:C,y2:O,w:C-b,h:O-m,boundX:y,boundY:f};return h.crop=JSON.stringify(k),h.deletedAt="-1",h},s.prototype.deleteShapes=function(){var t=this.props.readonly,e=this.state.canvas;e&&!t&&(e.getActiveObjects().forEach((function(t){e.remove(t)})),this.setOutput())},s.prototype.setOutput=function(){var t=this.state.canvas;if(t){var e=this.shapetoStructureData.bind(this),r=[];t.getObjects("rect").forEach((function(t){var o=e(t);o&&r.push(o)}));var o=this.props.input;o&&o.onChange(r)}},s.prototype.createObject=function(t,r,o,i){if(!t||!t.backgroundImage)return null;var n,a=t.backgroundImage;if(!(a instanceof e.fabric.Image))return null;if(!a.width||!a.height)return null;n="string"==typeof r.rect?JSON.parse(r.rect):r.rect;var c=a.width*n.x1,l=a.height*n.y1,s={left:c,top:l,width:a.width*n.x2-c,height:a.height*n.y2-l,borderColor:o.borderColor,cornerColor:o.cornerColor,cornerSize:o.cornerSize,transparentCorners:o.transparentCorners,cropBackgroundColor:o.cropBackgroundColor,cropBackgroundOpacity:o.cropBackgroundOpacity};return this.createObjectByAttribute(r.id,s,i)},s.prototype.discardActiveObject=function(){var t=this.state.canvas;t?(t.discardActiveObject(),t.requestRenderAll()):console.log("Canvas not defined")},s.prototype.keyboardHandler=function(t){if(!t.defaultPrevented){var e=!1,r=t.key||t.keyCode;"Delete"!==r&&46!==r||(this.deleteShapes(),e=!0),e&&t.preventDefault()}},s.prototype.render=function(){var e=this.props,r=e.addButton,o=e.deleteButton,i=e.discardButton,n=e.height,a=e.id,s=e.readonly,d=e.showButton,p=e.style,u=e.width;return t.createElement("div",{id:"canvas-wrapper",style:p},t.createElement(c,{row:!0,width:u,height:n},t.createElement("div",{onKeyDown:s?void 0:this.keyboardHandler,tabIndex:0},t.createElement("canvas",{id:a,height:n,style:{border:"0px solid #aaa"},width:u})),d&&!s&&t.createElement(l,{addButton:r,addNew:this.addNew,deleteButton:o,deleteShapes:this.deleteShapes,discardActiveObject:this.discardActiveObject,discardButton:i})))},s.defaultProps={borderColor:"black",cornerColor:"black",cornerSize:13,cropBackgroundColor:"yellow",cropBackgroundOpacity:.5,disableZoom:!1,height:800,id:"canvas",image:void 0,includeDataUrl:!1,includeHtmlCanvas:!1,input:void 0,readonly:!1,record:{clippings:[]},showButton:!1,transparentCorners:!0,width:800,zoomChanged:void 0},s}(t.Component);exports.CustomFabricRect=a,exports.ReactMultiCrop=s;
1
+ "use strict";var t=require("react"),e=require("fabric"),r=require("uuid");function o(t){return o="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},o(t)}var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},i(t,e)};function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}"function"==typeof SuppressedError&&SuppressedError;var a=function(t){function e(e){var r=t.call(this,e)||this;return r.id=null,r.objectId="",e&&(r.id=e.id,r.objectId=e.objectId),r}return n(e,t),e}(e.fabric.Rect);function c(e){var r=e.children,o=e.height,i=e.width,n=e.row,a=void 0!==n&&n;return t.createElement("div",{style:{display:"flex",flexDirection:a?"row":"column",gap:"10px",height:o,width:i}},r)}function l(e){var r=e.addButton,o=e.addNew,i=e.deleteButton,n=e.deleteShapes,a=e.discardActiveObject,l=e.discardButton;return t.createElement(c,null,t.createElement("div",null,r&&t.cloneElement(r,{onClick:o})),t.createElement("div",null,i&&t.cloneElement(i,{onClick:n})),t.createElement("div",null,l&&t.cloneElement(l,{onClick:a})))}var s=function(i){function s(t){var e=i.call(this,t)||this;return e.REGEXP_ORIGINS=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i,e.state={canvas:null,initial:!0},e.keyboardHandler=e.keyboardHandler.bind(e),e.addNew=e.addNew.bind(e),e.deleteShapes=e.deleteShapes.bind(e),e.discardActiveObject=e.discardActiveObject.bind(e),e}return n(s,i),s.prototype.componentDidMount=function(){this.state.canvas||this.initialCanvas()},s.prototype.componentDidUpdate=function(t){var e=this.state.canvas;if(e){var r=this.props,o=r.zoomLevel,i=r.activeObject,n=r.height,a=r.width,c=r.borderColor,l=r.cornerColor,s=r.cornerSize,d=r.transparentCorners,p=r.cropBackgroundColor,u=r.cropBackgroundOpacity,h=r.record,v=r.disableZoom,g=void 0!==v&&v,y=t.zoomLevel,f=t.activeObject,b=t.height,C=t.width,m=t.borderColor,O=t.cornerColor,k=t.cornerSize,w=t.transparentCorners,S=t.cropBackgroundColor,B=t.cropBackgroundOpacity,j=t.record,A=!1;if(y!==o&&o&&o>0&&(e.setZoom(o),A=!0),f!==i&&i){var I=e.getObjects().filter((function(t){return t.objectId===i}));e.discardActiveObject();for(var z=0,E=I;z<E.length;z++){var x=E[z];e.setActiveObject(x)}A=!0}if(e.off("mouse:wheel"),!g){var H=this.zoom.bind(this);e.on("mouse:wheel",H)}if(n&&n!==b&&(e.setHeight(n),A=!0),a&&a!==C&&(e.setWidth(a),A=!0),c!==m||l!==O||s!==k||d!==w||p!==S||u!==B){var D={borderColor:c,cornerColor:l,cornerSize:s,transparentCorners:d,cropBackgroundColor:p,cropBackgroundOpacity:u};this.updateCropAttributes(e,D),A=!0}var R=j;if(Array.isArray(R.clippings)&&h&&Array.isArray(null==h?void 0:h.clippings)){var P=h.clippings.filter((function(t){var e,r,o,i,n,a,c,l,s,d,p,u,h=R.clippings.find((function(e){return e.id===t.id||e.objectId&&e.objectId===t.objectId}));return!!h&&((null===(e=t.style)||void 0===e?void 0:e.borderColor)!==(null===(r=h.style)||void 0===r?void 0:r.borderColor)||(null===(o=t.style)||void 0===o?void 0:o.cornerColor)!==(null===(i=h.style)||void 0===i?void 0:i.cornerColor)||(null===(n=t.style)||void 0===n?void 0:n.cornerSize)!==(null===(a=h.style)||void 0===a?void 0:a.cornerSize)||(null===(c=t.style)||void 0===c?void 0:c.transparentCorners)!==(null===(l=h.style)||void 0===l?void 0:l.transparentCorners)||(null===(s=t.style)||void 0===s?void 0:s.cropBackgroundColor)!==(null===(d=h.style)||void 0===d?void 0:d.cropBackgroundColor)||(null===(p=t.style)||void 0===p?void 0:p.cropBackgroundOpacity)!==(null===(u=h.style)||void 0===u?void 0:u.cropBackgroundOpacity))})),X=e.getObjects("rect");if(Array.isArray(X)&&X.length>0){var Y=0;P.forEach((function(t){var e,r,o,i,n,a,c=X.find((function(e){var r=e;return r.id===t.id||r.objectId===t.objectId}));c&&(c.borderColor=null===(e=t.style)||void 0===e?void 0:e.borderColor,c.cornerColor=null===(r=t.style)||void 0===r?void 0:r.cornerColor,c.cornerSize=null===(o=t.style)||void 0===o?void 0:o.cornerSize,c.transparentCorners=null===(i=t.style)||void 0===i?void 0:i.transparentCorners,c.opacity=null===(n=t.style)||void 0===n?void 0:n.cropBackgroundOpacity,c.set("fill",null===(a=t.style)||void 0===a?void 0:a.cropBackgroundColor),Y+=1)})),Y>0&&(A=!0)}}A&&e.requestRenderAll()}},s.prototype.updateCropAttributes=function(t,e){var r=t.getObjects("rect");Array.isArray(r)&&r.length>0&&r.forEach((function(t){t.borderColor=e.borderColor,t.cornerColor=e.cornerColor,t.cornerSize=e.cornerSize,t.transparentCorners=e.transparentCorners,t.opacity=e.cropBackgroundOpacity,t.set("fill",e.cropBackgroundColor)}))},s.prototype.changeImage=function(){var t=this.state.canvas;t&&(t.backgroundImage||this.initialImage())},s.prototype.loadImage=function(t){var e=this.state,r=e.initial,o=e.canvas;if(o&&o.width&&o.height&&t.height&&t.width){var i=this.props.zoomLevel,n=t.height/t.width,a=o.width*n;o.setHeight(a),i?o.setZoom(i):o.setZoom(o.width/t.width),o.setBackgroundImage(t,o.renderAll.bind(o)),r&&this.setState({initial:!1},this.initialObjects.bind(this))}},s.prototype.isCrossOriginURL=function(t){var e=t.match(this.REGEXP_ORIGINS);return null!==e&&(e[1]!==window.location.protocol||e[2]!==window.location.hostname||e[3]!==window.location.port)},s.prototype.initialImage=function(){var t=this.props.image,r=this.loadImage.bind(this);if("string"==typeof t){var o={};this.isCrossOriginURL(t)&&(o.crossOrigin="Anonymous"),e.fabric.Image.fromURL(t,r,o)}},s.prototype.initialObjects=function(){var t=this.state.canvas;if(t){var e=this.props,r=e.record,i=e.readonly,n=e.borderColor,a=e.cornerColor,c=e.cornerSize,l=e.transparentCorners,s=e.cropBackgroundColor,d=e.cropBackgroundOpacity;if(r){var p=r.clippings;if(Array.isArray(p)&&p.length>0&&"object"===o(p[0])){for(var u={borderColor:n,cornerColor:a,cornerSize:c,transparentCorners:l,cropBackgroundColor:s,cropBackgroundOpacity:d},h=0,v=0,g=p;v<g.length;v++){var y=g[v];y.style&&(y.style.cropBackgroundColor&&(u.cropBackgroundColor=y.style.cropBackgroundColor),y.style.cropBackgroundOpacity&&(u.cropBackgroundOpacity=y.style.cropBackgroundOpacity),y.style.borderColor&&(u.borderColor=y.style.borderColor),y.style.cornerColor&&(u.cornerColor=y.style.cornerColor),y.style.cornerSize&&(u.cornerSize=y.style.cornerSize),y.style.transparentCorners&&(u.transparentCorners=y.style.transparentCorners));var f=this.createObject(t,y,u,i||!1);f&&(t.add(f),h+=1)}h>0&&this.setOutput()}}else console.log("Not have any record. Skipped.")}},s.prototype.zoom=function(t){var e=this.state.canvas;if(e){var r=t.e.deltaY,o=e.getZoom();(o*=Math.pow(.999,r))>20&&(o=20),o<.01&&(o=.01),e.setZoom(o),t.e.preventDefault(),t.e.stopPropagation();var i=this.props.zoomChanged;i&&i(o)}},s.prototype.mouseHover=function(t){var e=this.props.onHover,r=this.shapetoStructureData.bind(this),o=t.target;o&&"rect"===o.type&&e&&e(r(o))},s.prototype.mouseOut=function(t){var e=this.props.onHover,r=t.target;r&&"rect"===r.type&&e&&e(null)},s.prototype.selectionHandler=function(t){var e=this.props.onSelect,r=this.shapetoStructureData.bind(this),o=t.selected;if(Array.isArray(o)&&0!=o.length){var i=o[0];if(i&&"rect"===i.type&&e)e(r(i))}},s.prototype.selectionClearHandler=function(){var t=this.props.onSelect;t&&t(null)},s.prototype.initialCanvas=function(){var t=this.props,r=t.id,o=t.width,i=t.height,n=t.readonly,a=new e.fabric.Canvas(r||"canvas",{width:o,height:i});if(n){a.selectionKey=void 0;var c=this.mouseHover.bind(this),l=this.mouseOut.bind(this);a.on("mouse:over",c),a.on("mouse:out",l)}else{var s=this.doubleClickEvent.bind(this),d=this.setOutput.bind(this);a.on("mouse:dblclick",s),a.on("object:modified",d)}var p=this.selectionHandler.bind(this),u=this.selectionClearHandler.bind(this);a.on("selection:created",p),a.on("selection:updated",p),a.on("selection:cleared",u),a.on("mouse:down",(function(t){var e=t.e;!0===e.altKey&&(this.isDragging=!0,this.selection=!1,this.lastPosX=e.clientX,this.lastPosY=e.clientY)})),a.on("mouse:move",(function(t){if(this.isDragging){var e=t.e,r=this.viewportTransform;r[4]+=e.clientX-this.lastPosX,r[5]+=e.clientY-this.lastPosY,this.requestRenderAll(),this.lastPosX=e.clientX,this.lastPosY=e.clientY}})),a.on("mouse:up",(function(){this.setViewportTransform(this.viewportTransform),this.isDragging=!1,this.selection=!0})),this.setState({canvas:a},this.initialImage.bind(this))},s.prototype.addNew=function(){var t=this.state.canvas;if(t){var e=this.props,r={borderColor:e.borderColor,cornerColor:e.cornerColor,cornerSize:e.cornerSize,transparentCorners:e.transparentCorners,cropBackgroundColor:e.cropBackgroundColor,cropBackgroundOpacity:e.cropBackgroundOpacity},o=this.createObject(t,{id:null,rect:{x1:0,y1:0,x2:.2,y2:.2}},r,!1);o&&(t.add(o),this.setOutput())}},s.prototype.doubleClickEvent=function(t){var e=this.state.canvas;if(e){var r=this.props,o=r.readonly,i=r.borderColor,n=r.cornerColor,a=r.cornerSize,c=r.transparentCorners,l=r.cropBackgroundColor,s=r.cropBackgroundOpacity;if(t&&t.target){var d=t.target.left,p=t.target.top,u=t.target.width,h=t.target.height,v={left:d+50,top:p+50,width:u*t.target.scaleX,height:h*t.target.scaleY,borderColor:i,cornerColor:n,cornerSize:a,transparentCorners:c,cropBackgroundColor:l,cropBackgroundOpacity:s},g=this.createObjectByAttribute(null,v,o||!1);e.add(g),e.discardActiveObject(),e.setActiveObject(g),e.requestRenderAll(),this.setOutput()}else if(t&&t.pointer){v={left:d=t.absolutePointer.x,top:t.absolutePointer.y,width:100,height:100,borderColor:i,cornerColor:n,cornerSize:a,transparentCorners:c,cropBackgroundColor:l,cropBackgroundOpacity:s},g=this.createObjectByAttribute(null,v,o||!1);e.add(g),e.discardActiveObject(),e.setActiveObject(g),e.requestRenderAll(),this.setOutput()}}},s.prototype.createObjectByAttribute=function(t,e,o){var i=new a({left:e.left,top:e.top,width:e.width,height:e.height,borderColor:e.borderColor,cornerColor:e.cornerColor,cornerSize:e.cornerSize,transparentCorners:e.transparentCorners,fill:e.cropBackgroundColor,opacity:e.cropBackgroundOpacity,id:t,strokeWidth:0,strokeUniform:!0,lockRotation:!0,lockMovementX:o,lockMovementY:o,lockScalingX:o,lockScalingY:o,objectId:r.v4()});return i.setControlsVisibility({mtr:!1}),i},s.prototype.convertLeftTop=function(t){var e,r,o,i;return void 0===t.left||void 0===t.top||void 0===(null===(e=t.group)||void 0===e?void 0:e.left)||void 0===(null===(r=t.group)||void 0===r?void 0:r.top)||void 0===(null===(o=t.group)||void 0===o?void 0:o.width)||void 0===(null===(i=t.group)||void 0===i?void 0:i.height)?{left:0,top:0}:{left:t.left+t.group.left+t.group.width/2,top:t.top+t.group.top+t.group.height/2}},s.prototype.shapetoStructureData=function(t){var r=this.state.canvas;if(!r||!r.backgroundImage)return null;var o=r.backgroundImage;if(!(o instanceof e.fabric.Image))return null;if(void 0===t.left||void 0===t.top||void 0===t.width||void 0===t.height||void 0===t.scaleX||void 0===t.scaleY||void 0===o.width||void 0===o.height)return null;var i=this.props,n=i.includeDataUrl,a=i.includeHtmlCanvas,c=t.group?this.convertLeftTop(t):{left:t.left,top:t.top},l=c.left/o.width,s=c.top/o.height,d=(c.left+t.width*t.scaleX)/o.width,p=(c.top+t.height*t.scaleY)/o.height,u={x1:l,y1:s,x2:d,y2:p},h={id:t.id,objectId:t.objectId,rect:JSON.stringify(u)};if(n){var v=null;try{v=o.toDataURL({height:t.getScaledHeight(),width:t.getScaledWidth(),left:c.left,top:c.top,format:"jpeg"})}catch(t){console.error(t)}h.dataUrl=v}if(a){var g=null;try{g=o.toCanvasElement({height:t.getScaledHeight(),width:t.getScaledWidth(),left:c.left,top:c.top})}catch(t){console.error(t)}h.canvasElement=g}var y=o.width,f=o.height,b=l*y,C=d*y,m=s*f,O=p*f,k={x:b,y:m,x2:C,y2:O,w:C-b,h:O-m,boundX:y,boundY:f};return h.crop=JSON.stringify(k),h.deletedAt="-1",h},s.prototype.deleteShapes=function(){var t=this.props.readonly,e=this.state.canvas;e&&!t&&(e.getActiveObjects().forEach((function(t){e.remove(t)})),this.setOutput())},s.prototype.setOutput=function(){var t=this.state.canvas;if(t){var e=this.shapetoStructureData.bind(this),r=[];t.getObjects("rect").forEach((function(t){var o=e(t);o&&r.push(o)}));var o=this.props.input;o&&o.onChange(r)}},s.prototype.createObject=function(t,r,o,i){if(!t||!t.backgroundImage)return null;var n,a=t.backgroundImage;if(!(a instanceof e.fabric.Image))return null;if(!a.width||!a.height)return null;n="string"==typeof r.rect?JSON.parse(r.rect):r.rect;var c=a.width*n.x1,l=a.height*n.y1,s={left:c,top:l,width:a.width*n.x2-c,height:a.height*n.y2-l,borderColor:o.borderColor,cornerColor:o.cornerColor,cornerSize:o.cornerSize,transparentCorners:o.transparentCorners,cropBackgroundColor:o.cropBackgroundColor,cropBackgroundOpacity:o.cropBackgroundOpacity};return this.createObjectByAttribute(r.id,s,i)},s.prototype.discardActiveObject=function(){var t=this.state.canvas;t?(t.discardActiveObject(),t.requestRenderAll()):console.log("Canvas not defined")},s.prototype.keyboardHandler=function(t){if(!t.defaultPrevented){var e=!1,r=t.key||t.keyCode;"Delete"!==r&&46!==r||(this.deleteShapes(),e=!0),e&&t.preventDefault()}},s.prototype.render=function(){var e=this.props,r=e.addButton,o=e.deleteButton,i=e.discardButton,n=e.height,a=e.id,s=e.readonly,d=e.showButton,p=e.style,u=e.width,h=e.tabIndex;return t.createElement("div",{id:"canvas-wrapper",style:p},t.createElement(c,{row:!0,width:u,height:n},t.createElement("div",{onKeyDown:s?void 0:this.keyboardHandler,tabIndex:null!=h?h:0},t.createElement("canvas",{id:a,height:n,style:{border:"0px solid #aaa"},width:u})),d&&!s&&t.createElement(l,{addButton:r,addNew:this.addNew,deleteButton:o,deleteShapes:this.deleteShapes,discardActiveObject:this.discardActiveObject,discardButton:i})))},s.defaultProps={borderColor:"black",cornerColor:"black",cornerSize:13,cropBackgroundColor:"yellow",cropBackgroundOpacity:.5,disableZoom:!1,height:800,id:"canvas",image:void 0,includeDataUrl:!1,includeHtmlCanvas:!1,input:void 0,readonly:!1,record:{clippings:[]},showButton:!1,transparentCorners:!0,width:800,zoomChanged:void 0},s}(t.Component);exports.CustomFabricRect=a,exports.ReactMultiCrop=s;
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- import t,{Component as o}from"react";import{fabric as r}from"fabric";import{v4 as e}from"uuid";function i(t){return i="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},i(t)}var n=function(t,o){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,o){t.__proto__=o}||function(t,o){for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(t[r]=o[r])},n(t,o)};function a(t,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function r(){this.constructor=t}n(t,o),t.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}"function"==typeof SuppressedError&&SuppressedError;var c=function(t){function o(o){var r=t.call(this,o)||this;return r.id=null,r.objectId="",o&&(r.id=o.id,r.objectId=o.objectId),r}return a(o,t),o}(r.Rect);function l(o){var r=o.children,e=o.height,i=o.width,n=o.row,a=void 0!==n&&n;return t.createElement("div",{style:{display:"flex",flexDirection:a?"row":"column",gap:"10px",height:e,width:i}},r)}function s(o){var r=o.addButton,e=o.addNew,i=o.deleteButton,n=o.deleteShapes,a=o.discardActiveObject,c=o.discardButton;return t.createElement(l,null,t.createElement("div",null,r&&t.cloneElement(r,{onClick:e})),t.createElement("div",null,i&&t.cloneElement(i,{onClick:n})),t.createElement("div",null,c&&t.cloneElement(c,{onClick:a})))}var d=function(o){function n(t){var r=o.call(this,t)||this;return r.REGEXP_ORIGINS=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i,r.state={canvas:null,initial:!0},r.keyboardHandler=r.keyboardHandler.bind(r),r.addNew=r.addNew.bind(r),r.deleteShapes=r.deleteShapes.bind(r),r.discardActiveObject=r.discardActiveObject.bind(r),r}return a(n,o),n.prototype.componentDidMount=function(){this.state.canvas||this.initialCanvas()},n.prototype.componentDidUpdate=function(t){var o=this.state.canvas;if(o){var r=this.props,e=r.zoomLevel,i=r.activeObject,n=r.height,a=r.width,c=r.borderColor,l=r.cornerColor,s=r.cornerSize,d=r.transparentCorners,p=r.cropBackgroundColor,u=r.cropBackgroundOpacity,h=r.record,v=r.disableZoom,g=void 0!==v&&v,y=t.zoomLevel,f=t.activeObject,b=t.height,C=t.width,m=t.borderColor,O=t.cornerColor,k=t.cornerSize,w=t.transparentCorners,S=t.cropBackgroundColor,B=t.cropBackgroundOpacity,j=t.record,A=!1;if(y!==e&&e&&e>0&&(o.setZoom(e),A=!0),f!==i&&i){var I=o.getObjects().filter((function(t){return t.objectId===i}));o.discardActiveObject();for(var z=0,E=I;z<E.length;z++){var H=E[z];o.setActiveObject(H)}A=!0}if(o.off("mouse:wheel"),!g){var D=this.zoom.bind(this);o.on("mouse:wheel",D)}if(n&&n!==b&&(o.setHeight(n),A=!0),a&&a!==C&&(o.setWidth(a),A=!0),c!==m||l!==O||s!==k||d!==w||p!==S||u!==B){var x={borderColor:c,cornerColor:l,cornerSize:s,transparentCorners:d,cropBackgroundColor:p,cropBackgroundOpacity:u};this.updateCropAttributes(o,x),A=!0}var P=j;if(Array.isArray(P.clippings)&&h&&Array.isArray(null==h?void 0:h.clippings)){var R=h.clippings.filter((function(t){var o,r,e,i,n,a,c,l,s,d,p,u,h=P.clippings.find((function(o){return o.id===t.id||o.objectId&&o.objectId===t.objectId}));return!!h&&((null===(o=t.style)||void 0===o?void 0:o.borderColor)!==(null===(r=h.style)||void 0===r?void 0:r.borderColor)||(null===(e=t.style)||void 0===e?void 0:e.cornerColor)!==(null===(i=h.style)||void 0===i?void 0:i.cornerColor)||(null===(n=t.style)||void 0===n?void 0:n.cornerSize)!==(null===(a=h.style)||void 0===a?void 0:a.cornerSize)||(null===(c=t.style)||void 0===c?void 0:c.transparentCorners)!==(null===(l=h.style)||void 0===l?void 0:l.transparentCorners)||(null===(s=t.style)||void 0===s?void 0:s.cropBackgroundColor)!==(null===(d=h.style)||void 0===d?void 0:d.cropBackgroundColor)||(null===(p=t.style)||void 0===p?void 0:p.cropBackgroundOpacity)!==(null===(u=h.style)||void 0===u?void 0:u.cropBackgroundOpacity))})),X=o.getObjects("rect");if(Array.isArray(X)&&X.length>0){var Y=0;R.forEach((function(t){var o,r,e,i,n,a,c=X.find((function(o){var r=o;return r.id===t.id||r.objectId===t.objectId}));c&&(c.borderColor=null===(o=t.style)||void 0===o?void 0:o.borderColor,c.cornerColor=null===(r=t.style)||void 0===r?void 0:r.cornerColor,c.cornerSize=null===(e=t.style)||void 0===e?void 0:e.cornerSize,c.transparentCorners=null===(i=t.style)||void 0===i?void 0:i.transparentCorners,c.opacity=null===(n=t.style)||void 0===n?void 0:n.cropBackgroundOpacity,c.set("fill",null===(a=t.style)||void 0===a?void 0:a.cropBackgroundColor),Y+=1)})),Y>0&&(A=!0)}}A&&o.requestRenderAll()}},n.prototype.updateCropAttributes=function(t,o){var r=t.getObjects("rect");Array.isArray(r)&&r.length>0&&r.forEach((function(t){t.borderColor=o.borderColor,t.cornerColor=o.cornerColor,t.cornerSize=o.cornerSize,t.transparentCorners=o.transparentCorners,t.opacity=o.cropBackgroundOpacity,t.set("fill",o.cropBackgroundColor)}))},n.prototype.changeImage=function(){var t=this.state.canvas;t&&(t.backgroundImage||this.initialImage())},n.prototype.loadImage=function(t){var o=this.state,r=o.initial,e=o.canvas;if(e&&e.width&&e.height&&t.height&&t.width){var i=this.props.zoomLevel,n=t.height/t.width,a=e.width*n;e.setHeight(a),i?e.setZoom(i):e.setZoom(e.width/t.width),e.setBackgroundImage(t,e.renderAll.bind(e)),r&&this.setState({initial:!1},this.initialObjects.bind(this))}},n.prototype.isCrossOriginURL=function(t){var o=t.match(this.REGEXP_ORIGINS);return null!==o&&(o[1]!==window.location.protocol||o[2]!==window.location.hostname||o[3]!==window.location.port)},n.prototype.initialImage=function(){var t=this.props.image,o=this.loadImage.bind(this);if("string"==typeof t){var e={};this.isCrossOriginURL(t)&&(e.crossOrigin="Anonymous"),r.Image.fromURL(t,o,e)}},n.prototype.initialObjects=function(){var t=this.state.canvas;if(t){var o=this.props,r=o.record,e=o.readonly,n=o.borderColor,a=o.cornerColor,c=o.cornerSize,l=o.transparentCorners,s=o.cropBackgroundColor,d=o.cropBackgroundOpacity;if(r){var p=r.clippings;if(Array.isArray(p)&&p.length>0&&"object"===i(p[0])){for(var u={borderColor:n,cornerColor:a,cornerSize:c,transparentCorners:l,cropBackgroundColor:s,cropBackgroundOpacity:d},h=0,v=0,g=p;v<g.length;v++){var y=g[v];y.style&&(y.style.cropBackgroundColor&&(u.cropBackgroundColor=y.style.cropBackgroundColor),y.style.cropBackgroundOpacity&&(u.cropBackgroundOpacity=y.style.cropBackgroundOpacity),y.style.borderColor&&(u.borderColor=y.style.borderColor),y.style.cornerColor&&(u.cornerColor=y.style.cornerColor),y.style.cornerSize&&(u.cornerSize=y.style.cornerSize),y.style.transparentCorners&&(u.transparentCorners=y.style.transparentCorners));var f=this.createObject(t,y,u,e||!1);f&&(t.add(f),h+=1)}h>0&&this.setOutput()}}else console.log("Not have any record. Skipped.")}},n.prototype.zoom=function(t){var o=this.state.canvas;if(o){var r=t.e.deltaY,e=o.getZoom();(e*=Math.pow(.999,r))>20&&(e=20),e<.01&&(e=.01),o.setZoom(e),t.e.preventDefault(),t.e.stopPropagation();var i=this.props.zoomChanged;i&&i(e)}},n.prototype.mouseHover=function(t){var o=this.props.onHover,r=this.shapetoStructureData.bind(this),e=t.target;e&&"rect"===e.type&&o&&o(r(e))},n.prototype.mouseOut=function(t){var o=this.props.onHover,r=t.target;r&&"rect"===r.type&&o&&o(null)},n.prototype.selectionHandler=function(t){var o=this.props.onSelect,r=this.shapetoStructureData.bind(this),e=t.selected;if(Array.isArray(e)&&0!=e.length){var i=e[0];if(i&&"rect"===i.type&&o)o(r(i))}},n.prototype.selectionClearHandler=function(){var t=this.props.onSelect;t&&t(null)},n.prototype.initialCanvas=function(){var t=this.props,o=t.id,e=t.width,i=t.height,n=t.readonly,a=new r.Canvas(o||"canvas",{width:e,height:i});if(n){a.selectionKey=void 0;var c=this.mouseHover.bind(this),l=this.mouseOut.bind(this);a.on("mouse:over",c),a.on("mouse:out",l)}else{var s=this.doubleClickEvent.bind(this),d=this.setOutput.bind(this);a.on("mouse:dblclick",s),a.on("object:modified",d)}var p=this.selectionHandler.bind(this),u=this.selectionClearHandler.bind(this);a.on("selection:created",p),a.on("selection:updated",p),a.on("selection:cleared",u),a.on("mouse:down",(function(t){var o=t.e;!0===o.altKey&&(this.isDragging=!0,this.selection=!1,this.lastPosX=o.clientX,this.lastPosY=o.clientY)})),a.on("mouse:move",(function(t){if(this.isDragging){var o=t.e,r=this.viewportTransform;r[4]+=o.clientX-this.lastPosX,r[5]+=o.clientY-this.lastPosY,this.requestRenderAll(),this.lastPosX=o.clientX,this.lastPosY=o.clientY}})),a.on("mouse:up",(function(){this.setViewportTransform(this.viewportTransform),this.isDragging=!1,this.selection=!0})),this.setState({canvas:a},this.initialImage.bind(this))},n.prototype.addNew=function(){var t=this.state.canvas;if(t){var o=this.props,r={borderColor:o.borderColor,cornerColor:o.cornerColor,cornerSize:o.cornerSize,transparentCorners:o.transparentCorners,cropBackgroundColor:o.cropBackgroundColor,cropBackgroundOpacity:o.cropBackgroundOpacity},e=this.createObject(t,{id:null,rect:{x1:0,y1:0,x2:.2,y2:.2}},r,!1);e&&(t.add(e),this.setOutput())}},n.prototype.doubleClickEvent=function(t){var o=this.state.canvas;if(o){var r=this.props,e=r.readonly,i=r.borderColor,n=r.cornerColor,a=r.cornerSize,c=r.transparentCorners,l=r.cropBackgroundColor,s=r.cropBackgroundOpacity;if(t&&t.target){var d=t.target.left,p=t.target.top,u=t.target.width,h=t.target.height,v={left:d+50,top:p+50,width:u*t.target.scaleX,height:h*t.target.scaleY,borderColor:i,cornerColor:n,cornerSize:a,transparentCorners:c,cropBackgroundColor:l,cropBackgroundOpacity:s},g=this.createObjectByAttribute(null,v,e||!1);o.add(g),o.discardActiveObject(),o.setActiveObject(g),o.requestRenderAll(),this.setOutput()}else if(t&&t.pointer){v={left:d=t.absolutePointer.x,top:t.absolutePointer.y,width:100,height:100,borderColor:i,cornerColor:n,cornerSize:a,transparentCorners:c,cropBackgroundColor:l,cropBackgroundOpacity:s},g=this.createObjectByAttribute(null,v,e||!1);o.add(g),o.discardActiveObject(),o.setActiveObject(g),o.requestRenderAll(),this.setOutput()}}},n.prototype.createObjectByAttribute=function(t,o,r){var i=new c({left:o.left,top:o.top,width:o.width,height:o.height,borderColor:o.borderColor,cornerColor:o.cornerColor,cornerSize:o.cornerSize,transparentCorners:o.transparentCorners,fill:o.cropBackgroundColor,opacity:o.cropBackgroundOpacity,id:t,strokeWidth:0,strokeUniform:!0,lockRotation:!0,lockMovementX:r,lockMovementY:r,lockScalingX:r,lockScalingY:r,objectId:e()});return i.setControlsVisibility({mtr:!1}),i},n.prototype.convertLeftTop=function(t){var o,r,e,i;return void 0===t.left||void 0===t.top||void 0===(null===(o=t.group)||void 0===o?void 0:o.left)||void 0===(null===(r=t.group)||void 0===r?void 0:r.top)||void 0===(null===(e=t.group)||void 0===e?void 0:e.width)||void 0===(null===(i=t.group)||void 0===i?void 0:i.height)?{left:0,top:0}:{left:t.left+t.group.left+t.group.width/2,top:t.top+t.group.top+t.group.height/2}},n.prototype.shapetoStructureData=function(t){var o=this.state.canvas;if(!o||!o.backgroundImage)return null;var e=o.backgroundImage;if(!(e instanceof r.Image))return null;if(void 0===t.left||void 0===t.top||void 0===t.width||void 0===t.height||void 0===t.scaleX||void 0===t.scaleY||void 0===e.width||void 0===e.height)return null;var i=this.props,n=i.includeDataUrl,a=i.includeHtmlCanvas,c=t.group?this.convertLeftTop(t):{left:t.left,top:t.top},l=c.left/e.width,s=c.top/e.height,d=(c.left+t.width*t.scaleX)/e.width,p=(c.top+t.height*t.scaleY)/e.height,u={x1:l,y1:s,x2:d,y2:p},h={id:t.id,objectId:t.objectId,rect:JSON.stringify(u)};if(n){var v=null;try{v=e.toDataURL({height:t.getScaledHeight(),width:t.getScaledWidth(),left:c.left,top:c.top,format:"jpeg"})}catch(t){console.error(t)}h.dataUrl=v}if(a){var g=null;try{g=e.toCanvasElement({height:t.getScaledHeight(),width:t.getScaledWidth(),left:c.left,top:c.top})}catch(t){console.error(t)}h.canvasElement=g}var y=e.width,f=e.height,b=l*y,C=d*y,m=s*f,O=p*f,k={x:b,y:m,x2:C,y2:O,w:C-b,h:O-m,boundX:y,boundY:f};return h.crop=JSON.stringify(k),h.deletedAt="-1",h},n.prototype.deleteShapes=function(){var t=this.props.readonly,o=this.state.canvas;o&&!t&&(o.getActiveObjects().forEach((function(t){o.remove(t)})),this.setOutput())},n.prototype.setOutput=function(){var t=this.state.canvas;if(t){var o=this.shapetoStructureData.bind(this),r=[];t.getObjects("rect").forEach((function(t){var e=o(t);e&&r.push(e)}));var e=this.props.input;e&&e.onChange(r)}},n.prototype.createObject=function(t,o,e,i){if(!t||!t.backgroundImage)return null;var n,a=t.backgroundImage;if(!(a instanceof r.Image))return null;if(!a.width||!a.height)return null;n="string"==typeof o.rect?JSON.parse(o.rect):o.rect;var c=a.width*n.x1,l=a.height*n.y1,s={left:c,top:l,width:a.width*n.x2-c,height:a.height*n.y2-l,borderColor:e.borderColor,cornerColor:e.cornerColor,cornerSize:e.cornerSize,transparentCorners:e.transparentCorners,cropBackgroundColor:e.cropBackgroundColor,cropBackgroundOpacity:e.cropBackgroundOpacity};return this.createObjectByAttribute(o.id,s,i)},n.prototype.discardActiveObject=function(){var t=this.state.canvas;t?(t.discardActiveObject(),t.requestRenderAll()):console.log("Canvas not defined")},n.prototype.keyboardHandler=function(t){if(!t.defaultPrevented){var o=!1,r=t.key||t.keyCode;"Delete"!==r&&46!==r||(this.deleteShapes(),o=!0),o&&t.preventDefault()}},n.prototype.render=function(){var o=this.props,r=o.addButton,e=o.deleteButton,i=o.discardButton,n=o.height,a=o.id,c=o.readonly,d=o.showButton,p=o.style,u=o.width;return t.createElement("div",{id:"canvas-wrapper",style:p},t.createElement(l,{row:!0,width:u,height:n},t.createElement("div",{onKeyDown:c?void 0:this.keyboardHandler,tabIndex:0},t.createElement("canvas",{id:a,height:n,style:{border:"0px solid #aaa"},width:u})),d&&!c&&t.createElement(s,{addButton:r,addNew:this.addNew,deleteButton:e,deleteShapes:this.deleteShapes,discardActiveObject:this.discardActiveObject,discardButton:i})))},n.defaultProps={borderColor:"black",cornerColor:"black",cornerSize:13,cropBackgroundColor:"yellow",cropBackgroundOpacity:.5,disableZoom:!1,height:800,id:"canvas",image:void 0,includeDataUrl:!1,includeHtmlCanvas:!1,input:void 0,readonly:!1,record:{clippings:[]},showButton:!1,transparentCorners:!0,width:800,zoomChanged:void 0},n}(o);export{c as CustomFabricRect,d as ReactMultiCrop};
1
+ import t,{Component as o}from"react";import{fabric as e}from"fabric";import{v4 as r}from"uuid";function i(t){return i="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},i(t)}var n=function(t,o){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,o){t.__proto__=o}||function(t,o){for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&(t[e]=o[e])},n(t,o)};function a(t,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function e(){this.constructor=t}n(t,o),t.prototype=null===o?Object.create(o):(e.prototype=o.prototype,new e)}"function"==typeof SuppressedError&&SuppressedError;var c=function(t){function o(o){var e=t.call(this,o)||this;return e.id=null,e.objectId="",o&&(e.id=o.id,e.objectId=o.objectId),e}return a(o,t),o}(e.Rect);function l(o){var e=o.children,r=o.height,i=o.width,n=o.row,a=void 0!==n&&n;return t.createElement("div",{style:{display:"flex",flexDirection:a?"row":"column",gap:"10px",height:r,width:i}},e)}function s(o){var e=o.addButton,r=o.addNew,i=o.deleteButton,n=o.deleteShapes,a=o.discardActiveObject,c=o.discardButton;return t.createElement(l,null,t.createElement("div",null,e&&t.cloneElement(e,{onClick:r})),t.createElement("div",null,i&&t.cloneElement(i,{onClick:n})),t.createElement("div",null,c&&t.cloneElement(c,{onClick:a})))}var d=function(o){function n(t){var e=o.call(this,t)||this;return e.REGEXP_ORIGINS=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i,e.state={canvas:null,initial:!0},e.keyboardHandler=e.keyboardHandler.bind(e),e.addNew=e.addNew.bind(e),e.deleteShapes=e.deleteShapes.bind(e),e.discardActiveObject=e.discardActiveObject.bind(e),e}return a(n,o),n.prototype.componentDidMount=function(){this.state.canvas||this.initialCanvas()},n.prototype.componentDidUpdate=function(t){var o=this.state.canvas;if(o){var e=this.props,r=e.zoomLevel,i=e.activeObject,n=e.height,a=e.width,c=e.borderColor,l=e.cornerColor,s=e.cornerSize,d=e.transparentCorners,p=e.cropBackgroundColor,u=e.cropBackgroundOpacity,h=e.record,v=e.disableZoom,g=void 0!==v&&v,y=t.zoomLevel,f=t.activeObject,b=t.height,C=t.width,m=t.borderColor,O=t.cornerColor,k=t.cornerSize,w=t.transparentCorners,S=t.cropBackgroundColor,B=t.cropBackgroundOpacity,j=t.record,A=!1;if(y!==r&&r&&r>0&&(o.setZoom(r),A=!0),f!==i&&i){var I=o.getObjects().filter((function(t){return t.objectId===i}));o.discardActiveObject();for(var z=0,E=I;z<E.length;z++){var H=E[z];o.setActiveObject(H)}A=!0}if(o.off("mouse:wheel"),!g){var x=this.zoom.bind(this);o.on("mouse:wheel",x)}if(n&&n!==b&&(o.setHeight(n),A=!0),a&&a!==C&&(o.setWidth(a),A=!0),c!==m||l!==O||s!==k||d!==w||p!==S||u!==B){var D={borderColor:c,cornerColor:l,cornerSize:s,transparentCorners:d,cropBackgroundColor:p,cropBackgroundOpacity:u};this.updateCropAttributes(o,D),A=!0}var P=j;if(Array.isArray(P.clippings)&&h&&Array.isArray(null==h?void 0:h.clippings)){var R=h.clippings.filter((function(t){var o,e,r,i,n,a,c,l,s,d,p,u,h=P.clippings.find((function(o){return o.id===t.id||o.objectId&&o.objectId===t.objectId}));return!!h&&((null===(o=t.style)||void 0===o?void 0:o.borderColor)!==(null===(e=h.style)||void 0===e?void 0:e.borderColor)||(null===(r=t.style)||void 0===r?void 0:r.cornerColor)!==(null===(i=h.style)||void 0===i?void 0:i.cornerColor)||(null===(n=t.style)||void 0===n?void 0:n.cornerSize)!==(null===(a=h.style)||void 0===a?void 0:a.cornerSize)||(null===(c=t.style)||void 0===c?void 0:c.transparentCorners)!==(null===(l=h.style)||void 0===l?void 0:l.transparentCorners)||(null===(s=t.style)||void 0===s?void 0:s.cropBackgroundColor)!==(null===(d=h.style)||void 0===d?void 0:d.cropBackgroundColor)||(null===(p=t.style)||void 0===p?void 0:p.cropBackgroundOpacity)!==(null===(u=h.style)||void 0===u?void 0:u.cropBackgroundOpacity))})),X=o.getObjects("rect");if(Array.isArray(X)&&X.length>0){var Y=0;R.forEach((function(t){var o,e,r,i,n,a,c=X.find((function(o){var e=o;return e.id===t.id||e.objectId===t.objectId}));c&&(c.borderColor=null===(o=t.style)||void 0===o?void 0:o.borderColor,c.cornerColor=null===(e=t.style)||void 0===e?void 0:e.cornerColor,c.cornerSize=null===(r=t.style)||void 0===r?void 0:r.cornerSize,c.transparentCorners=null===(i=t.style)||void 0===i?void 0:i.transparentCorners,c.opacity=null===(n=t.style)||void 0===n?void 0:n.cropBackgroundOpacity,c.set("fill",null===(a=t.style)||void 0===a?void 0:a.cropBackgroundColor),Y+=1)})),Y>0&&(A=!0)}}A&&o.requestRenderAll()}},n.prototype.updateCropAttributes=function(t,o){var e=t.getObjects("rect");Array.isArray(e)&&e.length>0&&e.forEach((function(t){t.borderColor=o.borderColor,t.cornerColor=o.cornerColor,t.cornerSize=o.cornerSize,t.transparentCorners=o.transparentCorners,t.opacity=o.cropBackgroundOpacity,t.set("fill",o.cropBackgroundColor)}))},n.prototype.changeImage=function(){var t=this.state.canvas;t&&(t.backgroundImage||this.initialImage())},n.prototype.loadImage=function(t){var o=this.state,e=o.initial,r=o.canvas;if(r&&r.width&&r.height&&t.height&&t.width){var i=this.props.zoomLevel,n=t.height/t.width,a=r.width*n;r.setHeight(a),i?r.setZoom(i):r.setZoom(r.width/t.width),r.setBackgroundImage(t,r.renderAll.bind(r)),e&&this.setState({initial:!1},this.initialObjects.bind(this))}},n.prototype.isCrossOriginURL=function(t){var o=t.match(this.REGEXP_ORIGINS);return null!==o&&(o[1]!==window.location.protocol||o[2]!==window.location.hostname||o[3]!==window.location.port)},n.prototype.initialImage=function(){var t=this.props.image,o=this.loadImage.bind(this);if("string"==typeof t){var r={};this.isCrossOriginURL(t)&&(r.crossOrigin="Anonymous"),e.Image.fromURL(t,o,r)}},n.prototype.initialObjects=function(){var t=this.state.canvas;if(t){var o=this.props,e=o.record,r=o.readonly,n=o.borderColor,a=o.cornerColor,c=o.cornerSize,l=o.transparentCorners,s=o.cropBackgroundColor,d=o.cropBackgroundOpacity;if(e){var p=e.clippings;if(Array.isArray(p)&&p.length>0&&"object"===i(p[0])){for(var u={borderColor:n,cornerColor:a,cornerSize:c,transparentCorners:l,cropBackgroundColor:s,cropBackgroundOpacity:d},h=0,v=0,g=p;v<g.length;v++){var y=g[v];y.style&&(y.style.cropBackgroundColor&&(u.cropBackgroundColor=y.style.cropBackgroundColor),y.style.cropBackgroundOpacity&&(u.cropBackgroundOpacity=y.style.cropBackgroundOpacity),y.style.borderColor&&(u.borderColor=y.style.borderColor),y.style.cornerColor&&(u.cornerColor=y.style.cornerColor),y.style.cornerSize&&(u.cornerSize=y.style.cornerSize),y.style.transparentCorners&&(u.transparentCorners=y.style.transparentCorners));var f=this.createObject(t,y,u,r||!1);f&&(t.add(f),h+=1)}h>0&&this.setOutput()}}else console.log("Not have any record. Skipped.")}},n.prototype.zoom=function(t){var o=this.state.canvas;if(o){var e=t.e.deltaY,r=o.getZoom();(r*=Math.pow(.999,e))>20&&(r=20),r<.01&&(r=.01),o.setZoom(r),t.e.preventDefault(),t.e.stopPropagation();var i=this.props.zoomChanged;i&&i(r)}},n.prototype.mouseHover=function(t){var o=this.props.onHover,e=this.shapetoStructureData.bind(this),r=t.target;r&&"rect"===r.type&&o&&o(e(r))},n.prototype.mouseOut=function(t){var o=this.props.onHover,e=t.target;e&&"rect"===e.type&&o&&o(null)},n.prototype.selectionHandler=function(t){var o=this.props.onSelect,e=this.shapetoStructureData.bind(this),r=t.selected;if(Array.isArray(r)&&0!=r.length){var i=r[0];if(i&&"rect"===i.type&&o)o(e(i))}},n.prototype.selectionClearHandler=function(){var t=this.props.onSelect;t&&t(null)},n.prototype.initialCanvas=function(){var t=this.props,o=t.id,r=t.width,i=t.height,n=t.readonly,a=new e.Canvas(o||"canvas",{width:r,height:i});if(n){a.selectionKey=void 0;var c=this.mouseHover.bind(this),l=this.mouseOut.bind(this);a.on("mouse:over",c),a.on("mouse:out",l)}else{var s=this.doubleClickEvent.bind(this),d=this.setOutput.bind(this);a.on("mouse:dblclick",s),a.on("object:modified",d)}var p=this.selectionHandler.bind(this),u=this.selectionClearHandler.bind(this);a.on("selection:created",p),a.on("selection:updated",p),a.on("selection:cleared",u),a.on("mouse:down",(function(t){var o=t.e;!0===o.altKey&&(this.isDragging=!0,this.selection=!1,this.lastPosX=o.clientX,this.lastPosY=o.clientY)})),a.on("mouse:move",(function(t){if(this.isDragging){var o=t.e,e=this.viewportTransform;e[4]+=o.clientX-this.lastPosX,e[5]+=o.clientY-this.lastPosY,this.requestRenderAll(),this.lastPosX=o.clientX,this.lastPosY=o.clientY}})),a.on("mouse:up",(function(){this.setViewportTransform(this.viewportTransform),this.isDragging=!1,this.selection=!0})),this.setState({canvas:a},this.initialImage.bind(this))},n.prototype.addNew=function(){var t=this.state.canvas;if(t){var o=this.props,e={borderColor:o.borderColor,cornerColor:o.cornerColor,cornerSize:o.cornerSize,transparentCorners:o.transparentCorners,cropBackgroundColor:o.cropBackgroundColor,cropBackgroundOpacity:o.cropBackgroundOpacity},r=this.createObject(t,{id:null,rect:{x1:0,y1:0,x2:.2,y2:.2}},e,!1);r&&(t.add(r),this.setOutput())}},n.prototype.doubleClickEvent=function(t){var o=this.state.canvas;if(o){var e=this.props,r=e.readonly,i=e.borderColor,n=e.cornerColor,a=e.cornerSize,c=e.transparentCorners,l=e.cropBackgroundColor,s=e.cropBackgroundOpacity;if(t&&t.target){var d=t.target.left,p=t.target.top,u=t.target.width,h=t.target.height,v={left:d+50,top:p+50,width:u*t.target.scaleX,height:h*t.target.scaleY,borderColor:i,cornerColor:n,cornerSize:a,transparentCorners:c,cropBackgroundColor:l,cropBackgroundOpacity:s},g=this.createObjectByAttribute(null,v,r||!1);o.add(g),o.discardActiveObject(),o.setActiveObject(g),o.requestRenderAll(),this.setOutput()}else if(t&&t.pointer){v={left:d=t.absolutePointer.x,top:t.absolutePointer.y,width:100,height:100,borderColor:i,cornerColor:n,cornerSize:a,transparentCorners:c,cropBackgroundColor:l,cropBackgroundOpacity:s},g=this.createObjectByAttribute(null,v,r||!1);o.add(g),o.discardActiveObject(),o.setActiveObject(g),o.requestRenderAll(),this.setOutput()}}},n.prototype.createObjectByAttribute=function(t,o,e){var i=new c({left:o.left,top:o.top,width:o.width,height:o.height,borderColor:o.borderColor,cornerColor:o.cornerColor,cornerSize:o.cornerSize,transparentCorners:o.transparentCorners,fill:o.cropBackgroundColor,opacity:o.cropBackgroundOpacity,id:t,strokeWidth:0,strokeUniform:!0,lockRotation:!0,lockMovementX:e,lockMovementY:e,lockScalingX:e,lockScalingY:e,objectId:r()});return i.setControlsVisibility({mtr:!1}),i},n.prototype.convertLeftTop=function(t){var o,e,r,i;return void 0===t.left||void 0===t.top||void 0===(null===(o=t.group)||void 0===o?void 0:o.left)||void 0===(null===(e=t.group)||void 0===e?void 0:e.top)||void 0===(null===(r=t.group)||void 0===r?void 0:r.width)||void 0===(null===(i=t.group)||void 0===i?void 0:i.height)?{left:0,top:0}:{left:t.left+t.group.left+t.group.width/2,top:t.top+t.group.top+t.group.height/2}},n.prototype.shapetoStructureData=function(t){var o=this.state.canvas;if(!o||!o.backgroundImage)return null;var r=o.backgroundImage;if(!(r instanceof e.Image))return null;if(void 0===t.left||void 0===t.top||void 0===t.width||void 0===t.height||void 0===t.scaleX||void 0===t.scaleY||void 0===r.width||void 0===r.height)return null;var i=this.props,n=i.includeDataUrl,a=i.includeHtmlCanvas,c=t.group?this.convertLeftTop(t):{left:t.left,top:t.top},l=c.left/r.width,s=c.top/r.height,d=(c.left+t.width*t.scaleX)/r.width,p=(c.top+t.height*t.scaleY)/r.height,u={x1:l,y1:s,x2:d,y2:p},h={id:t.id,objectId:t.objectId,rect:JSON.stringify(u)};if(n){var v=null;try{v=r.toDataURL({height:t.getScaledHeight(),width:t.getScaledWidth(),left:c.left,top:c.top,format:"jpeg"})}catch(t){console.error(t)}h.dataUrl=v}if(a){var g=null;try{g=r.toCanvasElement({height:t.getScaledHeight(),width:t.getScaledWidth(),left:c.left,top:c.top})}catch(t){console.error(t)}h.canvasElement=g}var y=r.width,f=r.height,b=l*y,C=d*y,m=s*f,O=p*f,k={x:b,y:m,x2:C,y2:O,w:C-b,h:O-m,boundX:y,boundY:f};return h.crop=JSON.stringify(k),h.deletedAt="-1",h},n.prototype.deleteShapes=function(){var t=this.props.readonly,o=this.state.canvas;o&&!t&&(o.getActiveObjects().forEach((function(t){o.remove(t)})),this.setOutput())},n.prototype.setOutput=function(){var t=this.state.canvas;if(t){var o=this.shapetoStructureData.bind(this),e=[];t.getObjects("rect").forEach((function(t){var r=o(t);r&&e.push(r)}));var r=this.props.input;r&&r.onChange(e)}},n.prototype.createObject=function(t,o,r,i){if(!t||!t.backgroundImage)return null;var n,a=t.backgroundImage;if(!(a instanceof e.Image))return null;if(!a.width||!a.height)return null;n="string"==typeof o.rect?JSON.parse(o.rect):o.rect;var c=a.width*n.x1,l=a.height*n.y1,s={left:c,top:l,width:a.width*n.x2-c,height:a.height*n.y2-l,borderColor:r.borderColor,cornerColor:r.cornerColor,cornerSize:r.cornerSize,transparentCorners:r.transparentCorners,cropBackgroundColor:r.cropBackgroundColor,cropBackgroundOpacity:r.cropBackgroundOpacity};return this.createObjectByAttribute(o.id,s,i)},n.prototype.discardActiveObject=function(){var t=this.state.canvas;t?(t.discardActiveObject(),t.requestRenderAll()):console.log("Canvas not defined")},n.prototype.keyboardHandler=function(t){if(!t.defaultPrevented){var o=!1,e=t.key||t.keyCode;"Delete"!==e&&46!==e||(this.deleteShapes(),o=!0),o&&t.preventDefault()}},n.prototype.render=function(){var o=this.props,e=o.addButton,r=o.deleteButton,i=o.discardButton,n=o.height,a=o.id,c=o.readonly,d=o.showButton,p=o.style,u=o.width,h=o.tabIndex;return t.createElement("div",{id:"canvas-wrapper",style:p},t.createElement(l,{row:!0,width:u,height:n},t.createElement("div",{onKeyDown:c?void 0:this.keyboardHandler,tabIndex:null!=h?h:0},t.createElement("canvas",{id:a,height:n,style:{border:"0px solid #aaa"},width:u})),d&&!c&&t.createElement(s,{addButton:e,addNew:this.addNew,deleteButton:r,deleteShapes:this.deleteShapes,discardActiveObject:this.discardActiveObject,discardButton:i})))},n.defaultProps={borderColor:"black",cornerColor:"black",cornerSize:13,cropBackgroundColor:"yellow",cropBackgroundOpacity:.5,disableZoom:!1,height:800,id:"canvas",image:void 0,includeDataUrl:!1,includeHtmlCanvas:!1,input:void 0,readonly:!1,record:{clippings:[]},showButton:!1,transparentCorners:!0,width:800,zoomChanged:void 0},n}(o);export{c as CustomFabricRect,d as ReactMultiCrop};
@@ -53,6 +53,7 @@ export interface IReactMultiCropProps {
53
53
  record?: IRecordProps;
54
54
  height?: number;
55
55
  width?: number;
56
+ tabIndex?: number;
56
57
  zoomChanged?(value: number): void;
57
58
  zoomLevel?: number;
58
59
  /** @deprecated use borderColor in record */
package/package.json CHANGED
@@ -76,6 +76,6 @@
76
76
  "uuid": "^11.0.3"
77
77
  },
78
78
  "license": "MIT",
79
- "version": "0.40.4",
80
- "gitHead": "211c44d8228f1735df14c00a716b3aa1d58cb9d7"
79
+ "version": "0.41.0",
80
+ "gitHead": "ce10b6c1b9a78a1037bf361047b9fa0fe3ca2c78"
81
81
  }