@berviantoleo/react-multi-crop 0.31.13 → 0.33.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,13 +3,21 @@
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.31.13](https://github.com/berviantoleo/react-multi-crop/compare/@berviantoleo/react-multi-crop@0.31.12...@berviantoleo/react-multi-crop@0.31.13) (2023-07-18)
6
+ # [0.33.0](https://github.com/berviantoleo/react-multi-crop/compare/@berviantoleo/react-multi-crop@0.32.0...@berviantoleo/react-multi-crop@0.33.0) (2023-08-12)
7
7
 
8
- **Note:** Version bump only for package @berviantoleo/react-multi-crop
8
+ ### Features
9
+
10
+ - Initial Vagrant - Ready to dev ([#2092](https://github.com/berviantoleo/react-multi-crop/issues/2092)) ([0ff7c6c](https://github.com/berviantoleo/react-multi-crop/commit/0ff7c6c6c0907fd941db8b802dce5b42e0bcaf88))
9
11
 
12
+ # [0.32.0](https://github.com/berviantoleo/react-multi-crop/compare/@berviantoleo/react-multi-crop@0.31.13...@berviantoleo/react-multi-crop@0.32.0) (2023-08-06)
10
13
 
14
+ ### Features
15
+
16
+ - update deps ([#2065](https://github.com/berviantoleo/react-multi-crop/issues/2065)) ([8347e08](https://github.com/berviantoleo/react-multi-crop/commit/8347e080842888f98d088814dc544c1483c376d7))
11
17
 
18
+ ## [0.31.13](https://github.com/berviantoleo/react-multi-crop/compare/@berviantoleo/react-multi-crop@0.31.12...@berviantoleo/react-multi-crop@0.31.13) (2023-07-18)
12
19
 
20
+ **Note:** Version bump only for package @berviantoleo/react-multi-crop
13
21
 
14
22
  ## [0.31.12](https://github.com/berviantoleo/react-multi-crop/compare/@berviantoleo/react-multi-crop@0.31.11...@berviantoleo/react-multi-crop@0.31.12) (2023-06-21)
15
23
 
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("react"),e=require("fabric"),o=require("uuid");function r(t){return r="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},r(t)}var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},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 o(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var a=function(t){function e(e){var o=t.call(this,e)||this;return o.id=null,o.objectId="",e&&(o.id=e.id,o.objectId=e.objectId),o}return n(e,t),e}(e.fabric.Rect);function c(e){var o=e.children,r=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:r,width:i}},o)}function l(e){var o=e.addButton,r=e.addNew,i=e.deleteButton,n=e.deleteShapes,a=e.discardActiveObject,l=e.discardButton;return t.createElement(c,null,t.createElement("div",null,o&&t.cloneElement(o,{onClick:r})),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 o=this.props,r=o.zoomLevel,i=o.activeObject,n=o.height,a=o.width,c=o.borderColor,l=o.cornerColor,s=o.cornerSize,d=o.transparentCorners,p=o.cropBackgroundColor,u=o.cropBackgroundOpacity,h=o.record,v=o.disableZoom,g=void 0!==v&&v,f=t.zoomLevel,y=t.activeObject,b=t.height,C=t.width,m=t.borderColor,w=t.cornerColor,O=t.cornerSize,k=t.transparentCorners,S=t.cropBackgroundColor,B=t.cropBackgroundOpacity,j=t.record,A=!1;if(f!==r&&r&&r>0&&(e.setZoom(r),A=!0),y!==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!==w||s!==O||d!==k||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,o,r,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===(o=h.style)||void 0===o?void 0:o.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=e.getObjects("rect");if(Array.isArray(X)&&X.length>0){var Y=0;P.forEach((function(t){var e,o,r,i,n,a,c=X.find((function(e){var o=e;return o.id===t.id||o.objectId===t.objectId}));c&&(c.borderColor=null===(e=t.style)||void 0===e?void 0:e.borderColor,c.cornerColor=null===(o=t.style)||void 0===o?void 0:o.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&&e.requestRenderAll()}},s.prototype.updateCropAttributes=function(t,e){var o=t.getObjects("rect");Array.isArray(o)&&o.length>0&&o.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,o=e.initial,r=e.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)),o&&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,o=this.loadImage.bind(this);if("string"==typeof t){var r={};this.isCrossOriginURL(t)&&(r.crossOrigin="Anonymous"),e.fabric.Image.fromURL(t,o,r)}},s.prototype.initialObjects=function(){var t=this.state.canvas;if(t){var e=this.props,o=e.record,i=e.readonly,n=e.borderColor,a=e.cornerColor,c=e.cornerSize,l=e.transparentCorners,s=e.cropBackgroundColor,d=e.cropBackgroundOpacity;if(o){var p=o.clippings;if(Array.isArray(p)&&p.length>0&&"object"===r(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 f=g[v],y=this.createObject(t,f,u,i||!1);y&&(t.add(y),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 o=t.e.deltaY,r=e.getZoom();(r*=Math.pow(.999,o))>20&&(r=20),r<.01&&(r=.01),e.setZoom(r),t.e.preventDefault(),t.e.stopPropagation();var i=this.props.zoomChanged;i&&i(r)}},s.prototype.mouseHover=function(t){var e=this.props.onHover,o=this.shapetoStructureData.bind(this),r=t.target;r&&"rect"===r.type&&e&&e(o(r))},s.prototype.mouseOut=function(t){var e=this.props.onHover,o=t.target;o&&"rect"===o.type&&e&&e(null)},s.prototype.selectionHandler=function(t){var e=this.props.onSelect,o=this.shapetoStructureData.bind(this),r=t.selected;if(Array.isArray(r)&&0!=r.length){var i=r[0];if(i&&"rect"===i.type&&e)e(o(i))}},s.prototype.selectionClearHandler=function(){var t=this.props.onSelect;t&&t(null)},s.prototype.initialCanvas=function(){var t=this.props,o=t.id,r=t.width,i=t.height,n=t.readonly,a=new e.fabric.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 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,o=this.viewportTransform;o[4]+=e.clientX-this.lastPosX,o[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,o={borderColor:e.borderColor,cornerColor:e.cornerColor,cornerSize:e.cornerSize,transparentCorners:e.transparentCorners,cropBackgroundColor:e.cropBackgroundColor,cropBackgroundOpacity:e.cropBackgroundOpacity},r=this.createObject(t,{id:null,rect:{x1:0,y1:0,x2:.2,y2:.2}},o,!1);r&&(t.add(r),this.setOutput())}},s.prototype.doubleClickEvent=function(t){var e=this.state.canvas;if(e){var o=this.props,r=o.readonly,i=o.borderColor,n=o.cornerColor,a=o.cornerSize,c=o.transparentCorners,l=o.cropBackgroundColor,s=o.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);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,r||!1);e.add(g),e.discardActiveObject(),e.setActiveObject(g),e.requestRenderAll(),this.setOutput()}}},s.prototype.createObjectByAttribute=function(t,e,r){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:r,lockMovementY:r,lockScalingX:r,lockScalingY:r,objectId:o.v4()});return i.setControlsVisibility({mtr:!1}),i},s.prototype.convertLeftTop=function(t){var e,o,r,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===(o=t.group)||void 0===o?void 0:o.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}},s.prototype.shapetoStructureData=function(t){var o=this.state.canvas;if(!o||!o.backgroundImage)return null;var r=o.backgroundImage;if(!(r 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===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 f=r.width,y=r.height,b=l*f,C=d*f,m=s*y,w=p*y,O={x:b,y:m,x2:C,y2:w,w:C-b,h:w-m,boundX:f,boundY:y};return h.crop=JSON.stringify(O),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),o=[];t.getObjects("rect").forEach((function(t){var r=e(t);r&&o.push(r)}));var r=this.props.input;r&&r.onChange(o)}},s.prototype.createObject=function(t,o,r,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 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)},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,o=t.key||t.keyCode;"Delete"!==o&&46!==o||(this.deleteShapes(),e=!0),e&&t.preventDefault()}},s.prototype.render=function(){var e=this.props,o=e.addButton,r=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:o,addNew:this.addNew,deleteButton:r,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"),o=require("uuid");function r(t){return r="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},r(t)}var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},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 o(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}"function"==typeof SuppressedError&&SuppressedError;var a=function(t){function e(e){var o=t.call(this,e)||this;return o.id=null,o.objectId="",e&&(o.id=e.id,o.objectId=e.objectId),o}return n(e,t),e}(e.fabric.Rect);function c(e){var o=e.children,r=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:r,width:i}},o)}function l(e){var o=e.addButton,r=e.addNew,i=e.deleteButton,n=e.deleteShapes,a=e.discardActiveObject,l=e.discardButton;return t.createElement(c,null,t.createElement("div",null,o&&t.cloneElement(o,{onClick:r})),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 o=this.props,r=o.zoomLevel,i=o.activeObject,n=o.height,a=o.width,c=o.borderColor,l=o.cornerColor,s=o.cornerSize,d=o.transparentCorners,p=o.cropBackgroundColor,u=o.cropBackgroundOpacity,h=o.record,v=o.disableZoom,g=void 0!==v&&v,f=t.zoomLevel,y=t.activeObject,b=t.height,C=t.width,m=t.borderColor,w=t.cornerColor,O=t.cornerSize,k=t.transparentCorners,S=t.cropBackgroundColor,B=t.cropBackgroundOpacity,j=t.record,A=!1;if(f!==r&&r&&r>0&&(e.setZoom(r),A=!0),y!==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!==w||s!==O||d!==k||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,o,r,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===(o=h.style)||void 0===o?void 0:o.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=e.getObjects("rect");if(Array.isArray(X)&&X.length>0){var Y=0;P.forEach((function(t){var e,o,r,i,n,a,c=X.find((function(e){var o=e;return o.id===t.id||o.objectId===t.objectId}));c&&(c.borderColor=null===(e=t.style)||void 0===e?void 0:e.borderColor,c.cornerColor=null===(o=t.style)||void 0===o?void 0:o.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&&e.requestRenderAll()}},s.prototype.updateCropAttributes=function(t,e){var o=t.getObjects("rect");Array.isArray(o)&&o.length>0&&o.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,o=e.initial,r=e.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)),o&&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,o=this.loadImage.bind(this);if("string"==typeof t){var r={};this.isCrossOriginURL(t)&&(r.crossOrigin="Anonymous"),e.fabric.Image.fromURL(t,o,r)}},s.prototype.initialObjects=function(){var t=this.state.canvas;if(t){var e=this.props,o=e.record,i=e.readonly,n=e.borderColor,a=e.cornerColor,c=e.cornerSize,l=e.transparentCorners,s=e.cropBackgroundColor,d=e.cropBackgroundOpacity;if(o){var p=o.clippings;if(Array.isArray(p)&&p.length>0&&"object"===r(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 f=g[v],y=this.createObject(t,f,u,i||!1);y&&(t.add(y),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 o=t.e.deltaY,r=e.getZoom();(r*=Math.pow(.999,o))>20&&(r=20),r<.01&&(r=.01),e.setZoom(r),t.e.preventDefault(),t.e.stopPropagation();var i=this.props.zoomChanged;i&&i(r)}},s.prototype.mouseHover=function(t){var e=this.props.onHover,o=this.shapetoStructureData.bind(this),r=t.target;r&&"rect"===r.type&&e&&e(o(r))},s.prototype.mouseOut=function(t){var e=this.props.onHover,o=t.target;o&&"rect"===o.type&&e&&e(null)},s.prototype.selectionHandler=function(t){var e=this.props.onSelect,o=this.shapetoStructureData.bind(this),r=t.selected;if(Array.isArray(r)&&0!=r.length){var i=r[0];if(i&&"rect"===i.type&&e)e(o(i))}},s.prototype.selectionClearHandler=function(){var t=this.props.onSelect;t&&t(null)},s.prototype.initialCanvas=function(){var t=this.props,o=t.id,r=t.width,i=t.height,n=t.readonly,a=new e.fabric.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 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,o=this.viewportTransform;o[4]+=e.clientX-this.lastPosX,o[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,o={borderColor:e.borderColor,cornerColor:e.cornerColor,cornerSize:e.cornerSize,transparentCorners:e.transparentCorners,cropBackgroundColor:e.cropBackgroundColor,cropBackgroundOpacity:e.cropBackgroundOpacity},r=this.createObject(t,{id:null,rect:{x1:0,y1:0,x2:.2,y2:.2}},o,!1);r&&(t.add(r),this.setOutput())}},s.prototype.doubleClickEvent=function(t){var e=this.state.canvas;if(e){var o=this.props,r=o.readonly,i=o.borderColor,n=o.cornerColor,a=o.cornerSize,c=o.transparentCorners,l=o.cropBackgroundColor,s=o.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);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,r||!1);e.add(g),e.discardActiveObject(),e.setActiveObject(g),e.requestRenderAll(),this.setOutput()}}},s.prototype.createObjectByAttribute=function(t,e,r){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:r,lockMovementY:r,lockScalingX:r,lockScalingY:r,objectId:o.v4()});return i.setControlsVisibility({mtr:!1}),i},s.prototype.convertLeftTop=function(t){var e,o,r,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===(o=t.group)||void 0===o?void 0:o.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}},s.prototype.shapetoStructureData=function(t){var o=this.state.canvas;if(!o||!o.backgroundImage)return null;var r=o.backgroundImage;if(!(r 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===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 f=r.width,y=r.height,b=l*f,C=d*f,m=s*y,w=p*y,O={x:b,y:m,x2:C,y2:w,w:C-b,h:w-m,boundX:f,boundY:y};return h.crop=JSON.stringify(O),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),o=[];t.getObjects("rect").forEach((function(t){var r=e(t);r&&o.push(r)}));var r=this.props.input;r&&r.onChange(o)}},s.prototype.createObject=function(t,o,r,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 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)},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,o=t.key||t.keyCode;"Delete"!==o&&46!==o||(this.deleteShapes(),e=!0),e&&t.preventDefault()}},s.prototype.render=function(){var e=this.props,o=e.addButton,r=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:o,addNew:this.addNew,deleteButton:r,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 e}from"react";import{fabric as o}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,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},n(t,e)};function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var c=function(t){function e(e){var o=t.call(this,e)||this;return o.id=null,o.objectId="",e&&(o.id=e.id,o.objectId=e.objectId),o}return a(e,t),e}(o.Rect);function l(e){var o=e.children,r=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:r,width:i}},o)}function s(e){var o=e.addButton,r=e.addNew,i=e.deleteButton,n=e.deleteShapes,a=e.discardActiveObject,c=e.discardButton;return t.createElement(l,null,t.createElement("div",null,o&&t.cloneElement(o,{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(e){function n(t){var o=e.call(this,t)||this;return o.REGEXP_ORIGINS=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i,o.state={canvas:null,initial:!0},o.keyboardHandler=o.keyboardHandler.bind(o),o.addNew=o.addNew.bind(o),o.deleteShapes=o.deleteShapes.bind(o),o.discardActiveObject=o.discardActiveObject.bind(o),o}return a(n,e),n.prototype.componentDidMount=function(){this.state.canvas||this.initialCanvas()},n.prototype.componentDidUpdate=function(t){var e=this.state.canvas;if(e){var o=this.props,r=o.zoomLevel,i=o.activeObject,n=o.height,a=o.width,c=o.borderColor,l=o.cornerColor,s=o.cornerSize,d=o.transparentCorners,p=o.cropBackgroundColor,u=o.cropBackgroundOpacity,h=o.record,v=o.disableZoom,g=void 0!==v&&v,f=t.zoomLevel,y=t.activeObject,b=t.height,C=t.width,m=t.borderColor,w=t.cornerColor,O=t.cornerSize,k=t.transparentCorners,S=t.cropBackgroundColor,B=t.cropBackgroundOpacity,j=t.record,A=!1;if(f!==r&&r&&r>0&&(e.setZoom(r),A=!0),y!==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 D=this.zoom.bind(this);e.on("mouse:wheel",D)}if(n&&n!==b&&(e.setHeight(n),A=!0),a&&a!==C&&(e.setWidth(a),A=!0),c!==m||l!==w||s!==O||d!==k||p!==S||u!==B){var x={borderColor:c,cornerColor:l,cornerSize:s,transparentCorners:d,cropBackgroundColor:p,cropBackgroundOpacity:u};this.updateCropAttributes(e,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 e,o,r,i,n,a,c,l,s,d,p,u,h=P.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===(o=h.style)||void 0===o?void 0:o.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=e.getObjects("rect");if(Array.isArray(X)&&X.length>0){var Y=0;R.forEach((function(t){var e,o,r,i,n,a,c=X.find((function(e){var o=e;return o.id===t.id||o.objectId===t.objectId}));c&&(c.borderColor=null===(e=t.style)||void 0===e?void 0:e.borderColor,c.cornerColor=null===(o=t.style)||void 0===o?void 0:o.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&&e.requestRenderAll()}},n.prototype.updateCropAttributes=function(t,e){var o=t.getObjects("rect");Array.isArray(o)&&o.length>0&&o.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)}))},n.prototype.changeImage=function(){var t=this.state.canvas;t&&(t.backgroundImage||this.initialImage())},n.prototype.loadImage=function(t){var e=this.state,o=e.initial,r=e.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)),o&&this.setState({initial:!1},this.initialObjects.bind(this))}},n.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)},n.prototype.initialImage=function(){var t=this.props.image,e=this.loadImage.bind(this);if("string"==typeof t){var r={};this.isCrossOriginURL(t)&&(r.crossOrigin="Anonymous"),o.Image.fromURL(t,e,r)}},n.prototype.initialObjects=function(){var t=this.state.canvas;if(t){var e=this.props,o=e.record,r=e.readonly,n=e.borderColor,a=e.cornerColor,c=e.cornerSize,l=e.transparentCorners,s=e.cropBackgroundColor,d=e.cropBackgroundOpacity;if(o){var p=o.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 f=g[v],y=this.createObject(t,f,u,r||!1);y&&(t.add(y),h+=1)}h>0&&this.setOutput()}}else console.log("Not have any record. Skipped.")}},n.prototype.zoom=function(t){var e=this.state.canvas;if(e){var o=t.e.deltaY,r=e.getZoom();(r*=Math.pow(.999,o))>20&&(r=20),r<.01&&(r=.01),e.setZoom(r),t.e.preventDefault(),t.e.stopPropagation();var i=this.props.zoomChanged;i&&i(r)}},n.prototype.mouseHover=function(t){var e=this.props.onHover,o=this.shapetoStructureData.bind(this),r=t.target;r&&"rect"===r.type&&e&&e(o(r))},n.prototype.mouseOut=function(t){var e=this.props.onHover,o=t.target;o&&"rect"===o.type&&e&&e(null)},n.prototype.selectionHandler=function(t){var e=this.props.onSelect,o=this.shapetoStructureData.bind(this),r=t.selected;if(Array.isArray(r)&&0!=r.length){var i=r[0];if(i&&"rect"===i.type&&e)e(o(i))}},n.prototype.selectionClearHandler=function(){var t=this.props.onSelect;t&&t(null)},n.prototype.initialCanvas=function(){var t=this.props,e=t.id,r=t.width,i=t.height,n=t.readonly,a=new o.Canvas(e||"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 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,o=this.viewportTransform;o[4]+=e.clientX-this.lastPosX,o[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))},n.prototype.addNew=function(){var t=this.state.canvas;if(t){var e=this.props,o={borderColor:e.borderColor,cornerColor:e.cornerColor,cornerSize:e.cornerSize,transparentCorners:e.transparentCorners,cropBackgroundColor:e.cropBackgroundColor,cropBackgroundOpacity:e.cropBackgroundOpacity},r=this.createObject(t,{id:null,rect:{x1:0,y1:0,x2:.2,y2:.2}},o,!1);r&&(t.add(r),this.setOutput())}},n.prototype.doubleClickEvent=function(t){var e=this.state.canvas;if(e){var o=this.props,r=o.readonly,i=o.borderColor,n=o.cornerColor,a=o.cornerSize,c=o.transparentCorners,l=o.cropBackgroundColor,s=o.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);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,r||!1);e.add(g),e.discardActiveObject(),e.setActiveObject(g),e.requestRenderAll(),this.setOutput()}}},n.prototype.createObjectByAttribute=function(t,e,o){var i=new c({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()});return i.setControlsVisibility({mtr:!1}),i},n.prototype.convertLeftTop=function(t){var e,o,r,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===(o=t.group)||void 0===o?void 0:o.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 e=this.state.canvas;if(!e||!e.backgroundImage)return null;var r=e.backgroundImage;if(!(r instanceof o.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 f=r.width,y=r.height,b=l*f,C=d*f,m=s*y,w=p*y,O={x:b,y:m,x2:C,y2:w,w:C-b,h:w-m,boundX:f,boundY:y};return h.crop=JSON.stringify(O),h.deletedAt="-1",h},n.prototype.deleteShapes=function(){var t=this.props.readonly,e=this.state.canvas;e&&!t&&(e.getActiveObjects().forEach((function(t){e.remove(t)})),this.setOutput())},n.prototype.setOutput=function(){var t=this.state.canvas;if(t){var e=this.shapetoStructureData.bind(this),o=[];t.getObjects("rect").forEach((function(t){var r=e(t);r&&o.push(r)}));var r=this.props.input;r&&r.onChange(o)}},n.prototype.createObject=function(t,e,r,i){if(!t||!t.backgroundImage)return null;var n,a=t.backgroundImage;if(!(a instanceof o.Image))return null;if(!a.width||!a.height)return null;n="string"==typeof e.rect?JSON.parse(e.rect):e.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(e.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 e=!1,o=t.key||t.keyCode;"Delete"!==o&&46!==o||(this.deleteShapes(),e=!0),e&&t.preventDefault()}},n.prototype.render=function(){var e=this.props,o=e.addButton,r=e.deleteButton,i=e.discardButton,n=e.height,a=e.id,c=e.readonly,d=e.showButton,p=e.style,u=e.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:o,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}(e);export{c as CustomFabricRect,d as ReactMultiCrop};
1
+ import t,{Component as e}from"react";import{fabric as o}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,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},n(t,e)};function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}"function"==typeof SuppressedError&&SuppressedError;var c=function(t){function e(e){var o=t.call(this,e)||this;return o.id=null,o.objectId="",e&&(o.id=e.id,o.objectId=e.objectId),o}return a(e,t),e}(o.Rect);function l(e){var o=e.children,r=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:r,width:i}},o)}function s(e){var o=e.addButton,r=e.addNew,i=e.deleteButton,n=e.deleteShapes,a=e.discardActiveObject,c=e.discardButton;return t.createElement(l,null,t.createElement("div",null,o&&t.cloneElement(o,{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(e){function n(t){var o=e.call(this,t)||this;return o.REGEXP_ORIGINS=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i,o.state={canvas:null,initial:!0},o.keyboardHandler=o.keyboardHandler.bind(o),o.addNew=o.addNew.bind(o),o.deleteShapes=o.deleteShapes.bind(o),o.discardActiveObject=o.discardActiveObject.bind(o),o}return a(n,e),n.prototype.componentDidMount=function(){this.state.canvas||this.initialCanvas()},n.prototype.componentDidUpdate=function(t){var e=this.state.canvas;if(e){var o=this.props,r=o.zoomLevel,i=o.activeObject,n=o.height,a=o.width,c=o.borderColor,l=o.cornerColor,s=o.cornerSize,d=o.transparentCorners,p=o.cropBackgroundColor,u=o.cropBackgroundOpacity,h=o.record,v=o.disableZoom,g=void 0!==v&&v,f=t.zoomLevel,y=t.activeObject,b=t.height,C=t.width,m=t.borderColor,w=t.cornerColor,O=t.cornerSize,k=t.transparentCorners,S=t.cropBackgroundColor,B=t.cropBackgroundOpacity,j=t.record,A=!1;if(f!==r&&r&&r>0&&(e.setZoom(r),A=!0),y!==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 D=this.zoom.bind(this);e.on("mouse:wheel",D)}if(n&&n!==b&&(e.setHeight(n),A=!0),a&&a!==C&&(e.setWidth(a),A=!0),c!==m||l!==w||s!==O||d!==k||p!==S||u!==B){var x={borderColor:c,cornerColor:l,cornerSize:s,transparentCorners:d,cropBackgroundColor:p,cropBackgroundOpacity:u};this.updateCropAttributes(e,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 e,o,r,i,n,a,c,l,s,d,p,u,h=P.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===(o=h.style)||void 0===o?void 0:o.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=e.getObjects("rect");if(Array.isArray(X)&&X.length>0){var Y=0;R.forEach((function(t){var e,o,r,i,n,a,c=X.find((function(e){var o=e;return o.id===t.id||o.objectId===t.objectId}));c&&(c.borderColor=null===(e=t.style)||void 0===e?void 0:e.borderColor,c.cornerColor=null===(o=t.style)||void 0===o?void 0:o.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&&e.requestRenderAll()}},n.prototype.updateCropAttributes=function(t,e){var o=t.getObjects("rect");Array.isArray(o)&&o.length>0&&o.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)}))},n.prototype.changeImage=function(){var t=this.state.canvas;t&&(t.backgroundImage||this.initialImage())},n.prototype.loadImage=function(t){var e=this.state,o=e.initial,r=e.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)),o&&this.setState({initial:!1},this.initialObjects.bind(this))}},n.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)},n.prototype.initialImage=function(){var t=this.props.image,e=this.loadImage.bind(this);if("string"==typeof t){var r={};this.isCrossOriginURL(t)&&(r.crossOrigin="Anonymous"),o.Image.fromURL(t,e,r)}},n.prototype.initialObjects=function(){var t=this.state.canvas;if(t){var e=this.props,o=e.record,r=e.readonly,n=e.borderColor,a=e.cornerColor,c=e.cornerSize,l=e.transparentCorners,s=e.cropBackgroundColor,d=e.cropBackgroundOpacity;if(o){var p=o.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 f=g[v],y=this.createObject(t,f,u,r||!1);y&&(t.add(y),h+=1)}h>0&&this.setOutput()}}else console.log("Not have any record. Skipped.")}},n.prototype.zoom=function(t){var e=this.state.canvas;if(e){var o=t.e.deltaY,r=e.getZoom();(r*=Math.pow(.999,o))>20&&(r=20),r<.01&&(r=.01),e.setZoom(r),t.e.preventDefault(),t.e.stopPropagation();var i=this.props.zoomChanged;i&&i(r)}},n.prototype.mouseHover=function(t){var e=this.props.onHover,o=this.shapetoStructureData.bind(this),r=t.target;r&&"rect"===r.type&&e&&e(o(r))},n.prototype.mouseOut=function(t){var e=this.props.onHover,o=t.target;o&&"rect"===o.type&&e&&e(null)},n.prototype.selectionHandler=function(t){var e=this.props.onSelect,o=this.shapetoStructureData.bind(this),r=t.selected;if(Array.isArray(r)&&0!=r.length){var i=r[0];if(i&&"rect"===i.type&&e)e(o(i))}},n.prototype.selectionClearHandler=function(){var t=this.props.onSelect;t&&t(null)},n.prototype.initialCanvas=function(){var t=this.props,e=t.id,r=t.width,i=t.height,n=t.readonly,a=new o.Canvas(e||"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 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,o=this.viewportTransform;o[4]+=e.clientX-this.lastPosX,o[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))},n.prototype.addNew=function(){var t=this.state.canvas;if(t){var e=this.props,o={borderColor:e.borderColor,cornerColor:e.cornerColor,cornerSize:e.cornerSize,transparentCorners:e.transparentCorners,cropBackgroundColor:e.cropBackgroundColor,cropBackgroundOpacity:e.cropBackgroundOpacity},r=this.createObject(t,{id:null,rect:{x1:0,y1:0,x2:.2,y2:.2}},o,!1);r&&(t.add(r),this.setOutput())}},n.prototype.doubleClickEvent=function(t){var e=this.state.canvas;if(e){var o=this.props,r=o.readonly,i=o.borderColor,n=o.cornerColor,a=o.cornerSize,c=o.transparentCorners,l=o.cropBackgroundColor,s=o.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);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,r||!1);e.add(g),e.discardActiveObject(),e.setActiveObject(g),e.requestRenderAll(),this.setOutput()}}},n.prototype.createObjectByAttribute=function(t,e,o){var i=new c({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()});return i.setControlsVisibility({mtr:!1}),i},n.prototype.convertLeftTop=function(t){var e,o,r,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===(o=t.group)||void 0===o?void 0:o.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 e=this.state.canvas;if(!e||!e.backgroundImage)return null;var r=e.backgroundImage;if(!(r instanceof o.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 f=r.width,y=r.height,b=l*f,C=d*f,m=s*y,w=p*y,O={x:b,y:m,x2:C,y2:w,w:C-b,h:w-m,boundX:f,boundY:y};return h.crop=JSON.stringify(O),h.deletedAt="-1",h},n.prototype.deleteShapes=function(){var t=this.props.readonly,e=this.state.canvas;e&&!t&&(e.getActiveObjects().forEach((function(t){e.remove(t)})),this.setOutput())},n.prototype.setOutput=function(){var t=this.state.canvas;if(t){var e=this.shapetoStructureData.bind(this),o=[];t.getObjects("rect").forEach((function(t){var r=e(t);r&&o.push(r)}));var r=this.props.input;r&&r.onChange(o)}},n.prototype.createObject=function(t,e,r,i){if(!t||!t.backgroundImage)return null;var n,a=t.backgroundImage;if(!(a instanceof o.Image))return null;if(!a.width||!a.height)return null;n="string"==typeof e.rect?JSON.parse(e.rect):e.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(e.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 e=!1,o=t.key||t.keyCode;"Delete"!==o&&46!==o||(this.deleteShapes(),e=!0),e&&t.preventDefault()}},n.prototype.render=function(){var e=this.props,o=e.addButton,r=e.deleteButton,i=e.discardButton,n=e.height,a=e.id,c=e.readonly,d=e.showButton,p=e.style,u=e.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:o,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}(e);export{c as CustomFabricRect,d as ReactMultiCrop};
package/package.json CHANGED
@@ -25,42 +25,42 @@
25
25
  "url": "https://github.com/berviantoleo"
26
26
  },
27
27
  "devDependencies": {
28
- "@babel/cli": "^7.22.9",
29
- "@babel/core": "^7.22.9",
28
+ "@babel/cli": "^7.22.10",
29
+ "@babel/core": "^7.22.10",
30
30
  "@babel/plugin-proposal-class-properties": "^7.18.6",
31
- "@babel/plugin-transform-runtime": "^7.22.9",
32
- "@babel/preset-env": "^7.22.9",
31
+ "@babel/plugin-transform-runtime": "^7.22.10",
32
+ "@babel/preset-env": "^7.22.10",
33
33
  "@babel/preset-react": "^7.22.5",
34
34
  "@babel/preset-typescript": "^7.22.5",
35
- "@babel/runtime": "^7.22.6",
35
+ "@babel/runtime": "^7.22.10",
36
36
  "@rollup/plugin-babel": "^6.0.3",
37
37
  "@rollup/plugin-node-resolve": "^15.1.0",
38
- "@storybook/addon-essentials": "^7.0.27",
39
- "@storybook/addon-links": "^7.0.27",
40
- "@storybook/addon-storysource": "^7.0.27",
41
- "@storybook/addons": "^7.0.27",
42
- "@storybook/react": "^7.0.27",
43
- "@storybook/react-webpack5": "7.0.27",
44
- "@storybook/source-loader": "^7.0.27",
45
- "@testing-library/jest-dom": "^5.16.5",
38
+ "@storybook/addon-essentials": "^7.2.3",
39
+ "@storybook/addon-links": "^7.2.3",
40
+ "@storybook/addon-storysource": "^7.2.3",
41
+ "@storybook/addons": "^7.2.3",
42
+ "@storybook/react": "^7.2.3",
43
+ "@storybook/react-webpack5": "7.2.3",
44
+ "@storybook/source-loader": "^7.2.3",
45
+ "@testing-library/jest-dom": "^5.17.0",
46
46
  "@testing-library/react": "^14.0.0",
47
47
  "@types/fabric": "^5.3.3",
48
48
  "@types/jest": "^29.5.3",
49
49
  "@types/uuid": "^9.0.2",
50
- "babel-jest": "^29.6.1",
50
+ "babel-jest": "^29.6.2",
51
51
  "babel-loader": "^9.1.3",
52
52
  "clsx": "^2.0.0",
53
- "jest": "^29.6.1",
54
- "jest-environment-jsdom": "^29.6.1",
53
+ "jest": "^29.6.2",
54
+ "jest-environment-jsdom": "^29.6.2",
55
55
  "node-sass": "^9.0.0",
56
56
  "react-test-renderer": "^18.2.0",
57
- "rollup": "^3.26.3",
57
+ "rollup": "^3.28.0",
58
58
  "rollup-plugin-delete": "^2.0.0",
59
59
  "rollup-plugin-peer-deps-external": "^2.2.4",
60
60
  "rollup-plugin-sizes": "^1.0.5",
61
61
  "rollup-plugin-terser": "^7.0.2",
62
62
  "rollup-plugin-typescript2": "^0.35.0",
63
- "storybook": "7.0.27",
63
+ "storybook": "7.2.3",
64
64
  "ts-jest": "^29.1.1"
65
65
  },
66
66
  "peerDependencies": {
@@ -76,6 +76,6 @@
76
76
  "uuid": "^9.0.0"
77
77
  },
78
78
  "license": "MIT",
79
- "version": "0.31.13",
80
- "gitHead": "4d03fa0b68cde0b077f939ff4dbfea9b837fab56"
79
+ "version": "0.33.0",
80
+ "gitHead": "2bd4259d87858fb79ecb66e46d53035e5f1ccc07"
81
81
  }