@armco/imageeditor 0.0.1
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/cjs/Control-chunk.js +3 -0
- package/cjs/Control.js +1 -0
- package/cjs/ImageEditor.js +7 -0
- package/cjs/helper.js +1 -0
- package/es/Control-chunk.js +633 -0
- package/es/Control.js +7 -0
- package/es/ImageEditor.js +370 -0
- package/es/helper.js +40 -0
- package/package.json +79 -0
- package/types/Control.d.ts +7 -0
- package/types/ImageEditor.d.ts +3 -0
- package/types/helper.d.ts +1 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";const v=require("react/jsx-runtime"),h=require("react"),yt=require("react-dom");var D=(t=>(t.POPOVER="popover",t.ANCHOR="anchor",t))(D||{}),q=(t=>(t.LIGHT1="th-light-1",t.DARK1="th-dark-1",t))(q||{}),u=(t=>(t.URL="URL",t.identifier="identifier",t.svgString="svgString",t.b64="b64",t.raw="raw",t))(u||{}),H=(t=>(t.JPEG="image/jpeg",t.PNG="image/png",t.GIF="image/gif",t.WEBP="image/webp",t.SVG="image/svg+xml",t.TIFF="image/tiff",t.BMP="image/bmp",t.ICON="image/x-icon",t))(H||{}),W=(t=>(t.POPOVER="popover",t.ANCHOR="anchor",t))(W||{}),F=(t=>(t.FADEINOUT="fade",t.EXPANDSHRINK="expand-shrink",t))(F||{}),ot=(t=>(t.TOPLEFT="top-left",t.TOPRIGHT="top-right",t.TOPCENTER="top-center",t.RIGHTTOP="right-top",t.RIGHTBOTTOM="right-bottom",t.RIGHTCENTER="right-center",t.BOTTOMLEFT="bottom-left",t.BOTTOMRIGHT="bottom-right",t.BOTTOMCENTER="bottom-center",t.LEFTTOP="left-top",t.LEFTBOTTOM="left-bottom",t.LEFTCENTER="left-center",t.BOTTOM="bottom",t.RIGHT="right",t.LEFT="left",t.TOP="top",t.AUTO="auto",t))(ot||{}),C=(t=>(t.HOVER="hover",t.CLICK="click",t))(C||{}),f=(t=>(t.TOPLEFT="top-left",t.TOPRIGHT="top-right",t.TOPCENTER="top-center",t.RIGHTTOP="right-top",t.RIGHTBOTTOM="right-bottom",t.RIGHTCENTER="right-center",t.BOTTOMLEFT="bottom-left",t.BOTTOMRIGHT="bottom-right",t.BOTTOMCENTER="bottom-center",t.LEFTTOP="left-top",t.LEFTBOTTOM="left-bottom",t.LEFTCENTER="left-center",t.BOTTOM="bottom",t.RIGHT="right",t.LEFT="left",t.TOP="top",t.AUTO="auto",t))(f||{});const Ot=window.getComputedStyle(document.documentElement),E=parseFloat(Ot.fontSize),B=7;function kt(t){if(t){const e=document.querySelector(".ar-Editor__frame");if(e)return e.contentDocument}return document}function rt(t){if(t){const e=document.querySelector(".ar-Editor__frame");if(e)return e.contentWindow}return window}function xt(t,e,o,r){const a=rt(r)||window;if({bottom:e.top+e.height+o.height>a.innerHeight,right:e.left+e.width+o.width>a.innerWidth,left:e.left-o.width<0,top:e.top-o.height<0}[t])return!1;if(t==="left"||t==="right"){if(E>e.top||E>e.bottom)return!1}else if(E>e.left||E>e.right)return!1;return t}function Ct(t,e,o,r,a){const i={[f.BOTTOM]:{top:e.top+e.height+(r?0:B)+(a||0),left:e.left+(e.width-o.width)/2},[f.RIGHT]:{top:e.top+(e.height-o.height)/2,left:e.left+e.width+(r?0:B)},[f.LEFT]:{top:e.top+(e.height-o.height)/2,left:e.left-o.width-(r?0:B)},[f.TOP]:{top:e.top-o.height-(r?0:B)-(a||0),left:e.left+(e.width-o.width)/2}};let{left:n,top:c}=i[t];return t===f.BOTTOM||t===f.TOP?(n<0&&(n=E),n+o.width>window.innerWidth&&(n=`calc(100% - ${o.width}px - ${E}px)`)):(c<0&&(c=E),c+o.height>window.innerHeight&&(c=`calc(100% - ${o.height}px - ${E}px)`)),{left:n,top:c}}function Et(t,e,o,r){if(o&&o!==f.AUTO)return o;const a=[f.BOTTOM,f.RIGHT,f.LEFT,f.TOP];for(const i of a)if(xt(i,t,e,r))return i;return f.BOTTOM}function Rt(t,e,o,r,a,i,n){const c=rt(i)||window;t=a?{left:a[0],x:a[0],top:a[1],y:a[1],height:0,width:0,right:c.screen.width-a[0],bottom:c.screen.height-a[1],toJSON:()=>{}}:t;const s=Et(t,e,o,i),{left:l,top:d}=Ct(s,t,e,r,n);return{leftTop:{top:(""+d).startsWith("calc")?d:d+"px",left:(""+l).startsWith("calc")?l:l+"px"},position:s}}const St=t=>{const{children:e,classes:o,container:r,demo:a,styles:i}=t,[n,c]=h.useState();return h.useEffect(()=>(c(r||document.createElement("div")),()=>c(null)),[r]),h.useEffect(()=>{if(n){const s=kt(a);if(s){const l=s.getElementById("root");l&&l.appendChild(n)}return()=>{if(s){const l=s.getElementById("root");l&&l.removeChild(n)}}}},[n,a]),h.useEffect(()=>{n&&(o&&(n.className=o),n.classList.contains("ar-Portal")||n.classList.add("ar-Portal"),i&&Object.assign(n.style,i))},[o,i,n]),n?yt.createPortal(e,n):null};let Lt=!1;const It={left:"right",right:"left",top:"bottom",bottom:"top"},Pt={left:"135",right:"-45",top:"-135",bottom:"45"},$t=t=>{const{classes:e,children:o,closeOnSelfClick:r,contentClasses:a,contentMatchAnchorWidth:i,demo:n,disabled:c,hideMarker:s,invertBg:l,isOpen:d,isRaw:g,onAnchorClick:O,onClose:b,popAtPointer:A,position:G=ot.AUTO,preserveMarkerSpace:K,stretch:pt,topOffset:X,trigger:R=C.CLICK,animation:j,updateTriggers:ut,wrapText:gt,...mt}=t,w=h.useMemo(()=>j&&!Array.isArray(j)?[j]:j,[j]),I=h.useRef(null),k=h.useRef(null),[x,P]=h.useState(),[ft,vt]=h.useState(),[S,wt]=h.useState(),[J,Z]=h.useState(),[$,V]=h.useState(),U=h.useRef(),Y=h.useRef(0),Q=h.useCallback(()=>{if(!I.current||!k.current)return;const p=I.current.getBoundingClientRect();i&&(k.current.style.width=p.width+"px");const m=k.current.getBoundingClientRect();w&&w.length>0&&w.indexOf(F.EXPANDSHRINK)>-1&&(m.width=Math.floor(m.width*1.25),m.height=Math.floor(m.height*1.25));const{leftTop:T,position:y}=Rt(p,m,G,s&&!K,A&&R===C.CLICK?U.current:null,n,X);vt(T),wt(y)},[i,n,s,A,G,K,X,R,w]);let z,tt;return h.Children.forEach(o,p=>{var m,T;((m=p==null?void 0:p.props)==null?void 0:m.slot)===W.ANCHOR&&(tt=p),((T=p==null?void 0:p.props)==null?void 0:T.slot)===W.POPOVER&&(z=p)}),h.useEffect(()=>{d!==void 0&&(P(d),d&&!$&&V(!0))},[d,$]),h.useEffect(()=>{var p;let m=T=>{I.current&&!I.current.contains(T.target)&&k.current&&!k.current.contains(T.target)&&(P(!1),b&&b())};if(R===C.CLICK&&x){document.addEventListener("mousedown",m);const T=document.querySelector("iframe");return T&&((p=T.contentWindow)==null||p.document.addEventListener("mousedown",m)),()=>{var y;document.removeEventListener("click",m);const M=document.querySelector("iframe");M&&((y=M.contentWindow)==null||y.document.removeEventListener("click",m))}}},[R,x,b]),h.useEffect(()=>{$&&x&&(Q(),Z(!0))},[x,$,Q,...ut||[]]),h.useEffect(()=>{if(!s&&k.current&&J&&S){const p=k.current,m=I.current.getBoundingClientRect(),T=It[S],y=p.getBoundingClientRect();w&&w.length>0&&w.indexOf(F.EXPANDSHRINK)>-1&&(y.width=Math.floor(y.width*1.25),y.height=Math.floor(y.height*1.25));const M=S==="top"||S==="bottom";let et=m[M?"width":"height"]/2-7;const Tt=m.left-y.left+et,bt=m.top-y.top+et;p.style.setProperty("--marker-transform",`rotate(${Pt[S]}deg)`),p.style.setProperty(`--marker-${T}`,"-0.35rem"),p.style.setProperty(`--marker-${S}`,"initial"),p.style.setProperty(`--marker-${M?"left":"top"}`,(M?Tt:bt)+"px"),Z(!1)}},[J,k,s,S,U,w]),v.jsxs(v.Fragment,{children:[v.jsx("span",{className:`ar-Popover__anchor${e?" "+e:""}${pt?" w-100":""}`,onMouseDown:p=>{U.current=[p.clientX,p.clientY],Date.now()-Y.current<500||(Y.current=Date.now(),R===C.CLICK&&!Lt&&!c&&(!$&&V(!0),(d===void 0||d)&&setTimeout(()=>P(!x),0)),x&&b&&b(),O&&O(!x))},ref:I,onMouseEnter:()=>{R===C.HOVER&&!c&&(V(!0),setTimeout(()=>P(!0),0))},onMouseLeave:()=>{R===C.HOVER&&!c&&(setTimeout(()=>P(!1),0),b&&b())},...mt,children:tt}),z&&$&&v.jsx(St,{classes:`position-fixed popover-container${x?" z-3000":" invisible"}`,demo:n,styles:ft||{},children:v.jsx("div",{className:`ar-Popover__content${l?" invert-bg":""}${gt?" wrap":""}${G?" "+G:""} ${a}${w&&w.length>0?" transition "+(w==null?void 0:w.join(" ")):""} ${x?" show":""}${s?" hide-marker":""}${g?"":" p-1 border-radius l2 f25"}`,onClick:()=>r&&P(!1),ref:k,children:z})})]})},nt=t=>{const{children:e,demo:o,...r}=t,[a,i]=h.useState();return v.jsx($t,{contentClasses:"overflow-auto",trigger:C.HOVER,onAnchorClick:()=>{i(!1),setTimeout(()=>i(void 0),10)},animation:[F.EXPANDSHRINK,F.FADEINOUT],demo:o,isOpen:a,hideMarker:!0,preserveMarkerSpace:!0,wrapText:!0,...r,children:e})},st=new DOMParser,L=st.parseFromString(`<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect width="20" height="20" x="2" y="2" fill="none" stroke="#000" stroke-width="2"rx="2"></rect>
|
|
3
|
+
</svg>`,H.SVG).querySelector("svg"),Mt=/^[a-zA-Z]{2,3}[./][a-zA-Z0-9]+$/,Nt=t=>typeof t=="object"?u.raw:t.startsWith("data:image/svg+xml;base64,")?u.b64:t.startsWith("<svg")?u.svgString:t.startsWith("http://")||t.startsWith("https://")?u.URL:Mt.test(t)?u.identifier:u.b64,_=t=>{try{const e=st.parseFromString(t,H.SVG).querySelector("svg");return console.warn("Parsed item isn't an svg"),e===null?L:e}catch(e){return console.warn("Error parsing SVG string:",e),L}},At=t=>{try{const e=atob(t);return _(e)}catch(e){return console.error("Error decoding base64 SVG string:",e),L}},jt=t=>{const e=o=>{const r=Array.from(o.children).map(e),a=Array.from(o.attributes).reduce((i,n)=>(i[n.name]=n.value,i),{});return h.createElement(o.tagName,a,...r)};return e(t)},Ht=(t,e)=>{const{attributes:o,theme:r}=t,{colors:a}=o||{},{strokeColor:i,toggleStrokeColor:n,hoverStrokeColor:c,darkStrokeColor:s,darkToggleStrokeColor:l,darkHoverStrokeColor:d}=a||{},{hovered:g,toggled:O}=e;return r===q.DARK1?g&&d?d:O&&l?l:s:g&&c?c:O&&n?n:i},Ft=(t,e)=>{const{attributes:o,theme:r}=t,{colors:a}=o||{},{fillColor:i,toggleFillColor:n,hoverFillColor:c,darkFillColor:s,darkToggleFillColor:l,darkHoverFillColor:d}=a||{},{hovered:g,toggled:O}=e;return r===q.DARK1?g&&d?d:O&&l?l:s:g&&c?c:O&&n?n:i},Gt=(t,e,o)=>{if(!(t instanceof SVGSVGElement))return;const{attributes:r,hoverShadow:a}=e,{strokeWidth:i,styles:n}=r||{},c=((r==null?void 0:r.classes)||"")+(a?" hover-shadow p-1":""),s=Ft(e,o),l=Ht(e,o),d=(r==null?void 0:r.height)||(typeof(n==null?void 0:n.height)=="number"?typeof(n==null?void 0:n.height)+"px":typeof(n==null?void 0:n.height))||(r==null?void 0:r.size)||"1rem",g=(r==null?void 0:r.width)||(typeof(n==null?void 0:n.width)=="number"?typeof(n==null?void 0:n.width)+"px":typeof(n==null?void 0:n.width))||(r==null?void 0:r.size)||"1rem";s&&t.setAttribute("fill",s),l&&t.setAttribute("stroke",l),i&&t.setAttribute("stroke-width",i),t.setAttribute("width",g),t.setAttribute("height",d),t.setAttribute("class",`ar-Icon${c?" "+c:""}`),n&&Object.assign(t.style,n)};(function(){try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(".ar-Icon{transition:all .3s}.ar-Icon:hover.hover-shadow{box-shadow:0 4px 8px var(--ar-shadow)}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();const Bt={development:"http://localhost:5000/api",production:"https://api.armco.tech"},it={development:"http://localhost:5001/api",production:"https://static.armco.tech"};`${it[process.env.NODE_ENV]}`;class at{constructor(e,o,r){this.message=e,this.status=o,this.extras=r}}const Dt=10;async function Vt(t,e,o){const r=lt(t,e);return o={method:"GET",mode:"cors",credentials:"include",...o},ct(r,o)}async function Ut(t,e,o){let r=lt(t,e);const a=process.env.NODE_ENV||"development",i=r.startsWith("http")?"":it[a];return r=i?i+r:r,o={method:"GET",mode:"cors",credentials:"include",...o},ct(r,o)}async function ct(t,e){const o=process.env.NODE_ENV||"development",r=t.startsWith("http")?"":Bt[o],a=e==null?void 0:e.extras;t=r?r+t:t,e.headers||(e.headers={}),e.toggleLoader&&e.toggleLoader({[t]:!0}),e.headers.Origin=window.location.protocol+"//"+window.location.host;const i=await fetch(t,e),{ok:n,status:c,headers:s}=i;if(n){if(s.get("content-type")){if(s.get("content-type").indexOf("application/json")!==-1){const g=await i.json();return e.toggleLoader&&e.toggleLoader({[t]:!1}),{status:c,body:g,headers:s}}else if(s.get("content-type").indexOf("application/zip")!==-1||s.get("content-type").indexOf("image/png")!==-1||s.get("content-type").indexOf("application/pdf")!==-1||s.get("content-type").indexOf("video/mp4")!==-1||s.get("content-type").indexOf("image/gif")!==-1){const g=await i.blob();return e.toggleLoader&&e.toggleLoader({[t]:!1}),{status:c,body:g,headers:s}}}const d=await i.text();return e.toggleLoader&&e.toggleLoader({[t]:!1}),{status:c,body:d,headers:s}}const l=await i.json();throw e.toggleLoader&&e.toggleLoader({[t]:!1}),console.log(l),new at(l.error||l.message,c,a)}function lt(t,e){if(!e)return t||"";const o=Object.keys(e).length;return t&&o?Object.keys(e).filter(r=>e[r]!==void 0).reduce((r,a,i)=>r.concat(`${encodeURIComponent(a)}=${encodeURIComponent(e[a]).replace(/'/g,"%27")}`+(i<o-1?"&":"")),t+"?"):""}async function zt(t,e={}){let{retryDescriptor:o=[1,3,5],maxAttempts:r=5,onRetry:a,onSuccess:i,onFailure:n}=e;r=Math.min(r,Dt);let c=0;const s=async()=>{try{const l=await t();return i&&i(),l}catch(l){if(c<Math.min(o.length,r)){const d=o[c]*1e3;return c++,a&&a(c,d),console.warn(`Retrying in ${d/1e3} seconds...`),await new Promise(g=>setTimeout(g,d)),s()}else{const d=new at("Max retries reached",500,l);throw n&&n(d),d}}};return s()}var dt=(t=>(t.LIGHT1="th-light-1",t.DARK1="th-dark-1",t))(dt||{});function Wt(){let t=!1;return function(e){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(e.substr(0,4)))&&(t=!0)}(navigator.userAgent||navigator.vendor||"opera"in window&&window.opera),t}h.createContext({slotted:[]});const _t=h.createContext({theme:dt.DARK1,drawerState:{collapsed:Wt()},notify:()=>{},setDrawerState:()=>{},setLeftPanelContent:()=>{},setLoggedIn:()=>{},setModalState:()=>{},setRightPanelContent:()=>{},setTheme:()=>{},setUser:()=>{}}),qt=()=>{const t=h.useContext(_t);if(!t)throw new Error("useTheme must be used within an ArProvider");return{theme:t.theme,setTheme:t.setTheme}},Kt=t=>e=>{const{theme:o,setTheme:r}=qt();return v.jsx(t,{...e,theme:o,setTheme:r})},N={};class Xt extends h.Component{constructor(e){super(e),this.parseIconDescriptor=o=>{var r,a,i;const n=typeof o=="object"&&"source"in o,c=n&&!!u[o.type];let s=n?o.source:o;const l=c?o.type:Nt(s);let d;if(l===u.identifier||l===u.URL){s=s;const g=l===u.URL?s:s.replace(/./g,"/"),O=()=>(l===u.URL?Vt:Ut)(g);if(N[s])N[s].icon?this.setState({juice:N[s].icon??L,type:l}):(r=N[s].promise)==null||r.then(b=>this.handleIconResponse(b,s,l));else{const b=zt(O).then(A=>(this.handleIconResponse(A,s,l),A));N[s]={promise:b}}}else{switch(l){case u.b64:d=At(s);break;case u.raw:d=v.jsx("img",{src:s,alt:"ar-icon",className:`ar-Icon ${(a=this.props.attributes)==null?void 0:a.classes}${this.props.hoverShadow?" hover-shadow p-1":""}`,style:(i=this.props.attributes)==null?void 0:i.styles});break;case u.svgString:d=_(s);break;default:console.error("Unsupported icon type."),d=L}d&&this.setState({juice:d,type:l})}},this.handleMouseEnter=()=>{var o,r;this.setState({hovered:!0}),(r=(o=this.props.events)==null?void 0:o.onMouseEnter)==null||r.call(o)},this.handleMouseLeave=()=>{var o,r;this.setState({hovered:!1}),(r=(o=this.props.events)==null?void 0:o.onMouseLeave)==null||r.call(o)},this.state={hovered:!1,toggled:e.toggled||!1,juice:L,type:u.svgString},this.parseIconDescriptor=this.parseIconDescriptor.bind(this),this.handleIconResponse=this.handleIconResponse.bind(this)}componentDidMount(){this.props.icon&&this.parseIconDescriptor(this.props.icon)}componentDidUpdate(e){if(JSON.stringify(e.attributes)!==JSON.stringify(this.props.attributes)){const{juice:o}=this.state;o&&Gt(o,this.props,this.state)}}handleIconResponse(e,o,r){var a,i;const n=e.headers.get("content-type");let c;r===u.identifier||n!=null&&n.includes(H.SVG)?c=_(e.body):n&&Object.values(H).findIndex(s=>n.includes(s))>-1?c=v.jsx("img",{src:o,alt:"ar-icon",className:`ar-Icon ${(a=this.props.attributes)==null?void 0:a.classes}${this.props.hoverShadow?" hover-shadow p-1":""}`,style:(i=this.props.attributes)==null?void 0:i.styles}):(console.error("Unsupported content type."),c=L),c&&this.setState({juice:c,type:r}),N[o].icon=c}render(){var e;const{juice:o,type:r}=this.state;return o?r===u.raw?o:h.cloneElement(jt(o),{onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,onClick:(e=this.props.events)==null?void 0:e.onClick,onClickCapture:()=>this.setState({toggled:!this.state.toggled})}):null}}const ht=Kt(Xt),Jt=({icon:t,handler:e,tooltip:o})=>v.jsxs(nt,{children:[v.jsx("span",{className:"mx-3 p-1 cursor-pointer",slot:D.ANCHOR,children:v.jsx(ht,{icon:t,attributes:{colors:{fillColor:"#ffffff99"},classes:"cursor-pointer",size:"2rem"},events:{onClick:e}})}),v.jsx("span",{slot:D.POPOVER,children:o})]});exports.B=ht;exports.Control=Jt;exports.L=D;exports.v=nt;
|
package/cjs/Control.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require("react/jsx-runtime");const r=require("./Control-chunk.js");require("react");require("react-dom");module.exports=r.Control;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode('.ar-Image{transition:all .3s}.ar-Image.fill{object-fit:cover}.ar-Image.fill.preserveAspectRatio{object-fit:contain}.ar-Slider input[type=range]{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;cursor:pointer}.ar-Slider input[type=range]:hover+.ar-Slider__bubble{opacity:1}.ar-Slider input[type=range]:focus{outline:none}.ar-Slider input[type=range]::-webkit-slider-runnable-track{background-color:#053a5f;border-radius:.2rem;height:.2rem}.ar-Slider input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;margin-top:-6.5px;transition:outline .5s;background-color:var(--ar-bg-slider-track);height:1rem;width:1rem;border-radius:50%}.ar-Slider input[type=range]::-webkit-slider-thumb:hover{border:5px solid var(--ar-bg-slider-track)}.ar-Slider input[type=range]:focus::-webkit-slider-thumb{border:1px solid #053a5f}.ar-Slider input[type=range]::-moz-range-track{background-color:#053a5f;border-radius:.2rem;height:.2rem}.ar-Slider input[type=range]::-moz-range-thumb{border:none;border-radius:0;background-color:var(--ar-bg-slider-track);height:1rem;width:1rem}.ar-Slider input[type=range]:focus::-moz-range-thumb{border:1px solid #053a5f}.ar-Slider .ar-Slider__bubble{background:#454545;color:#fff;padding:4px 12px;border-radius:4px;left:50%;bottom:-1.5rem;transform:translate(-50%);opacity:0;transition:opacity .3s}.ar-Slider .ar-Slider__bubble:after{content:"";position:absolute;width:4px;height:4px;transform:rotate(45deg);background:#454545;top:-2px;left:50%}.ar-Slider .ar-Slider__manual-input{width:2rem}.ar-ImageEditor .ar-ImageEditor__image-container{max-width:60vw;max-height:75vh}.ar-ImageEditor .ar-ImageEditor__editor-controls{transition:background-color .5s,box-shadow .5s ease-in-out;background-color:var(--ar-bg-tertiary-faded-2);border-radius:2rem}.ar-ImageEditor .ar-ImageEditor__editor-controls:hover{background-color:var(--ar-bg-tertiary-faded)}.ar-ImageEditor .ar-ImageEditor__editor-controls .ar-ImageEditor__download-button{width:2rem;height:2rem;display:inline-block}.ar-ImageEditor .ar-ImageEditor__editor-controls .ar-ImageEditor__download-button:hover{background-color:var(--ar-bg-tertiary-faded-2)}.ar-ImageEditor .ar-ImageEditor__editor-controls .ar-ImageEditor__commit-button{width:2rem;height:2rem;display:inline-block}.ar-ImageEditor .ar-ImageEditor__editor-controls .ar-ImageEditor__commit-button.is-dirty:hover{background-color:var(--ar-bg-tertiary-faded-2)}.ar-ImageEditor .ar-ImageEditor__controls{bottom:0}.ar-ImageEditor .ar-ImageEditor__controls .ar-ImageEditor__controls-container{transition:background-color .5s,box-shadow .5s,max-height .5s ease-in-out;background-color:var(--ar-bg-tertiary-faded-2);max-height:3.2rem;overflow:hidden}.ar-ImageEditor .ar-ImageEditor__controls .ar-ImageEditor__controls-container:hover{background-color:var(--ar-bg-tertiary-faded)}.ar-ImageEditor .ar-ImageEditor__controls .ar-ImageEditor__controls-container.expanded{max-height:20rem}.ar-Portal{z-index:2001;white-space:nowrap}.ar-Popover__anchor:focus-visible{outline:none}:root{--marker-transform: rotate(45deg);--marker-top: -.4rem;--marker-left: 10%;--marker-right: unset;--marker-bottom: unset}:root .ar-Popover__content{box-shadow:0 4px 8px -2px #091e4240,0 0 1px #091e424f;z-index:2002;background-color:var(--ar-bg);white-space:nowrap;position:relative;border:1px solid var(--ar-color-border)}:root .ar-Popover__content>*{position:relative}:root .ar-Popover__content.invert-bg{background-color:var(--ar-bg-invert-1)}:root .ar-Popover__content.wrap{white-space:wrap}:root .ar-Popover__content:not(.hide-marker):before{content:"";background-color:var(--ar-bg);position:absolute;height:.7rem;width:.7rem;border-width:1px;border-style:solid;border-color:var(--ar-color-border) transparent transparent var(--ar-color-border);transform:var(--marker-transform);top:var(--marker-top);left:var(--marker-left);right:var(--marker-right);bottom:var(--marker-bottom)}:root .ar-Popover__content.invert-bg:not(.hide-marker):before{background-color:var(--ar-bg-invert-1)}:root .ar-Popover__content.transition{transition:width .15s ease-in-out,height .15s ease-in-out,opacity .3s ease-in-out,transform .15s ease-in-out}:root .ar-Popover__content.transition.expand-shrink{transform:scale(.8)}:root .ar-Popover__content.transition.show{transform:scale(1)}@media (min-width: 576px){:root .ar-Popover__content{max-width:25vw}}:root .ar-List__item{line-height:1.5rem}:root .ar-List__item:hover{background-color:var(--ar-color-font);color:var(--ar-color-font-invert);cursor:pointer}')),document.head.appendChild(r)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
2
|
+
"use strict";const t=require("react/jsx-runtime"),h=require("react"),p=require("./Control-chunk.js"),B=require("./helper.js");require("react-dom");const z=s=>new URL(s).hostname,F=s=>{const d=z(s);return d==="localhost"||d==="armco.tech"?"use-credentials":"anonymous"},L=h.forwardRef((s,d)=>{const{alt:f,blur:c,brightness:b,classes:n,contrast:m,customBgZIndex:r,demo:N,fill:x,flipHorizontal:y,flipVertical:j,grayscale:C,image:i,isBackground:u,opacity:R,preserveAspectRatio:_,rotateBy:e,saturate:o,scale:l,sepia:v,style:g,title:$}=s,a={};l!==void 0&&(a.transform=`scale(${l})`),y&&(a.transform=`scaleX(-${l!==void 0?l:1})`),j&&(a.transform=(a.transform?a.transform+" ":"")+`scaleY(-${l!==void 0?l:1})`),e&&(a.transform=(a.transform?a.transform+" ":"")+`rotate(${e}deg)`),R&&(a.opacity=R),b&&(a.filter=`brightness(${b})`),m&&(a.filter=(a.filter?a.filter+" ":"")+`contrast(${m})`),o&&(a.filter=(a.filter?a.filter+" ":"")+`saturate(${o})`),c&&(a.filter=(a.filter?a.filter+" ":"")+`blur(${c}px)`),C&&(a.filter=(a.filter?a.filter+" ":"")+`grayscale(${C})`),v&&(a.filter=(a.filter?a.filter+" ":"")+`sepia(${v})`),u&&r&&(a.zIndex=`${r} !important`);const I=N?i||"https://picsum.photos/200/300":i;return t.jsx("img",{ref:d,className:`ar-Image
|
|
3
|
+
${x&&!u?" fill w-100 h-100":""}
|
|
4
|
+
${_&&!u?" preserveAspectRatio":""}
|
|
5
|
+
${u?" position-absolute top-0 start-0 h-100 w-100":""}
|
|
6
|
+
${n?" "+n:""}
|
|
7
|
+
`,crossOrigin:F(I),src:I,alt:f||"ar-image-placeholder",title:$,style:{...a,...g||{}}})});function O(s,d){const f=+s.value,c=+(s.min?s.min:0),b=+(s.max?s.max:100),n=Number((f-c)*100/(b-c));d.innerHTML=""+f;const m=-(n/100*16)+8;d.style.left=`calc(${n}% + ${m}px)`}const k=s=>{const{assistiveContent:d,classes:f,containerClasses:c,focussed:b,id:n,label:m,name:r,size:N,onBlur:x,onChange:y,onFocus:j,precision:C,type:i,value:u,withManual:R,..._}=s,e=h.useRef(null),o=h.useRef(null),[l,v]=h.useState();return h.useEffect(()=>{e.current&&o.current&&O(e.current,o.current),e.current&&e.current.addEventListener("input",()=>{e.current&&o.current&&O(e.current,o.current)})},[]),h.useEffect(()=>{u!==l&&v(u)},[u]),t.jsx("div",{className:`ar-Slider w-100${c?" "+c:""}`,children:t.jsxs("div",{className:"ar-Slider__control flex-v-center position-relative justify-content-between",children:[m&&t.jsx("label",{className:"me-3",htmlFor:n,children:t.jsx("strong",{children:m})}),t.jsxs("div",{className:"ar-Slider__slider-bar flex-center",children:[t.jsx("div",{className:"d-inline-block me-2",children:_.min}),t.jsxs("div",{className:"position-relative",children:[t.jsx("input",{ref:e,id:n,name:r||n,type:"range",className:`ar-TextInput__input h-100 py-2${f?" "+f:""}`,onChange:g=>{v(g.target.value),y&&y(g)},onFocus:j,onBlur:x,value:l,step:C,..._}),l&&t.jsx("output",{ref:o,className:"ar-Slider__bubble position-absolute",htmlFor:n})]}),t.jsx("div",{className:"d-inline-block ms-2",children:_.max}),R&&t.jsx("input",{className:"ar-Slider__manual-input",type:"text",value:l,onChange:g=>{v(g.target.value),y&&y(g)},title:"Maunal Value"})]})]})})};let E={rotateBy:0,brightness:1,contrast:1,saturate:1,grayscale:0,blur:0,sepia:0,opacity:1,scale:1};const S=s=>(s%360+360)%360,w=22.5,A=s=>{const{image:d,imageState:f,onChange:c,onCommit:b,viewOnly:n}=s;E={...E,...f};const m=h.useRef(null),[r,N]=h.useState({...E}),[x,y]=h.useState(),[j,C]=h.useState(),i=(e,o)=>{const l={...r,[e]:o},{rotateBy:v,...g}=l,{rotateBy:$,...a}=E;v!==void 0&&$!==void 0&&C(JSON.stringify(g)!==JSON.stringify(a)||S(v)!==S($)),N(l),c&&c(l)},u=[{icon:"tb.TbFlipHorizontal",handler:()=>i("flipHorizontal",!r.flipHorizontal),tooltip:"Flip Horizontal"},{icon:"tb.TbFlipVertical",handler:()=>i("flipVertical",!r.flipVertical),tooltip:"Flip Vertical"},{icon:"ai.AiOutlineRotateLeft",handler:()=>i("rotateBy",r.rotateBy-w),tooltip:"Rotate Left"},{icon:"ai.AiOutlineRotateRight",handler:()=>i("rotateBy",r.rotateBy+w),tooltip:"Rotate Right"},{icon:"fi.FiZoomIn",handler:()=>i("scale",(r.scale+1)%10),tooltip:"Zoom In"},{icon:"fi.FiZoomOut",handler:()=>i("scale",(r.scale-1<0?0:r.scale-1)%10),tooltip:"Zoom Out"},{icon:x?"md.MdOutlineExpandLess":"md.MdOutlineExpandMore",handler:()=>y(!x),tooltip:x?"Hide Advanced Controls":"Show Advanced Controls"}],R=[{icon:"fi.FiZoomIn",handler:()=>N({...r,scale:(r.scale+1)%10}),tooltip:"Zoom In"},{icon:"fi.FiZoomOut",handler:()=>N({...r,scale:(r.scale-1<0?0:r.scale-1)%10}),tooltip:"Zoom Out"}],_=[[{label:"Brightness",min:0,max:5,precision:.1,handler:e=>i("brightness",+e.target.value)},{label:"Contrast",min:0,max:5,precision:.1,handler:e=>i("contrast",+e.target.value)}],[{label:"Saturation",min:0,max:10,precision:.2,handler:e=>i("saturate",+e.target.value)},{label:"Grayscale",min:0,max:1,precision:.05,handler:e=>i("grayscale",+e.target.value)}],[{label:"Blur",min:0,max:20,handler:e=>i("blur",+e.target.value)},{label:"Sepia",min:0,max:1,precision:.05,handler:e=>i("sepia",+e.target.value)}],[{label:"Opacity",min:0,max:1,precision:.05,handler:e=>i("opacity",+e.target.value)},{label:"Scale",min:0,max:10,precision:.2,handler:e=>i("scale",+e.target.value)}]];return t.jsxs("div",{className:"ar-ImageEditor d-flex flex-column h-100 overflow-auto flex-center position-relative",children:[!n&&t.jsxs("div",{className:"ar-ImageEditor__editor-controls position-absolute p-1 top-0 end-0 hover-shadow-dark",children:[t.jsxs(p.v,{children:[t.jsx("span",{className:"ar-ImageEditor__download-button cursor-pointer border-radius-50 p-1 me-2",slot:p.L.ANCHOR,children:t.jsx(p.B,{icon:"md/MdDownload",attributes:{colors:{fillColor:"#232323cc"},size:"1.5rem"},events:{onClick:()=>B.downloadEditedImage(m.current)}})}),t.jsx("span",{slot:p.L.POPOVER,children:"Download"})]}),t.jsxs(p.v,{children:[t.jsx("span",{className:`ar-ImageEditor__commit-button border-radius-50 p-1${j?" cursor-pointer is-dirty":""}`,slot:p.L.ANCHOR,children:t.jsx(p.B,{icon:"io5.IoCheckmarkCircleSharp",slot:p.L.ANCHOR,attributes:{colors:{fillColor:j?"#008000":"#00800077"},size:"1.5rem"},events:{onClick:()=>j&&b&&b(r)}})}),t.jsx("span",{slot:p.L.POPOVER,children:j?"Save":"Edit image to save"})]})]}),t.jsx("div",{className:"ar-ImageEditor__image-container mb-4",children:t.jsx(L,{ref:m,image:d,fill:!0,preserveAspectRatio:!0,...r})}),t.jsx("div",{className:"ar-ImageEditor__controls py-3 flex-center z-1 position-absolute",children:t.jsxs("div",{className:`ar-ImageEditor__controls-container border-radius prominent hover-shadow-dark${x?" expanded":""}`,children:[t.jsx("div",{className:`ar-ImageEditor__basic-controls px-3 py-2 ${x?"border-bottom":""}`,children:(n?R:u).map(e=>t.jsx(p.Control,{...e}))}),!n&&t.jsx("div",{className:"ar-ImageEditor__advanced-controls mt-2 px-3",children:_.map(e=>t.jsx("div",{className:"row pb-3 border-bottom",children:e.map(o=>t.jsx("div",{className:"col-6",children:t.jsx(k,{label:o.label,min:o.min,max:o.max,onChange:o.handler,precision:o.precision})}))}))})]})})]})};module.exports=A;
|
package/cjs/helper.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react");require("react/jsx-runtime");const r=window.getComputedStyle(document.documentElement);parseFloat(r.fontSize);function c(t,a){const e=document.createElement("a");e.href=typeof t=="string"?t:window.URL.createObjectURL(t),e.download=a||"edited-image.png",document.body.appendChild(e),e.click(),document.body.removeChild(e)}const i=t=>{if(t){const a=document.createElement("canvas");a.width=t.naturalWidth,a.height=t.naturalHeight;const e=a.getContext("2d");if(!e)return;const s=t.style.filter,o=t.style.opacity,n=t.style.transform;e.filter=s!==""?s:"",e.globalAlpha=o!==""?parseFloat(o):1,n&&n!=="none"&&h(e,n,a),e.drawImage(t,0,0),c(a.toDataURL())}},h=(t,a,e)=>{const s=a.match(/rotate\((\d+(?:\.\d+)?)deg\)/);if(s){const d=parseFloat(s[1])*(Math.PI/180);t.translate(e.width/2,e.height/2),t.rotate(d),t.translate(-e.width/2,-e.height/2)}const o=a.match(/scale\((\d+(?:\.\d+)?)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(o){const l=parseFloat(o[1]),d=o[2]?parseFloat(o[2]):l;t.scale(l,d)}const n=a.match(/translate\((\d+px)(?:,\s*(\d+px))?\)/);if(n){const l=parseFloat(n[1]),d=n[2]?parseFloat(n[2]):0;t.translate(l,d)}};exports.downloadEditedImage=i;
|
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
import { jsxs as nt, Fragment as kt, jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { useState as L, useEffect as S, useMemo as Ct, useRef as D, useCallback as Et, Children as Rt, createElement as xt, createContext as it, useContext as Lt, Component as St, cloneElement as It } from "react";
|
|
3
|
+
import Pt from "react-dom";
|
|
4
|
+
var _ = /* @__PURE__ */ ((t) => (t.POPOVER = "popover", t.ANCHOR = "anchor", t))(_ || {}), X = /* @__PURE__ */ ((t) => (t.LIGHT1 = "th-light-1", t.DARK1 = "th-dark-1", t))(X || {}), p = /* @__PURE__ */ ((t) => (t.URL = "URL", t.identifier = "identifier", t.svgString = "svgString", t.b64 = "b64", t.raw = "raw", t))(p || {}), G = /* @__PURE__ */ ((t) => (t.JPEG = "image/jpeg", t.PNG = "image/png", t.GIF = "image/gif", t.WEBP = "image/webp", t.SVG = "image/svg+xml", t.TIFF = "image/tiff", t.BMP = "image/bmp", t.ICON = "image/x-icon", t))(G || {}), K = /* @__PURE__ */ ((t) => (t.POPOVER = "popover", t.ANCHOR = "anchor", t))(K || {}), B = /* @__PURE__ */ ((t) => (t.FADEINOUT = "fade", t.EXPANDSHRINK = "expand-shrink", t))(B || {}), st = /* @__PURE__ */ ((t) => (t.TOPLEFT = "top-left", t.TOPRIGHT = "top-right", t.TOPCENTER = "top-center", t.RIGHTTOP = "right-top", t.RIGHTBOTTOM = "right-bottom", t.RIGHTCENTER = "right-center", t.BOTTOMLEFT = "bottom-left", t.BOTTOMRIGHT = "bottom-right", t.BOTTOMCENTER = "bottom-center", t.LEFTTOP = "left-top", t.LEFTBOTTOM = "left-bottom", t.LEFTCENTER = "left-center", t.BOTTOM = "bottom", t.RIGHT = "right", t.LEFT = "left", t.TOP = "top", t.AUTO = "auto", t))(st || {}), C = /* @__PURE__ */ ((t) => (t.HOVER = "hover", t.CLICK = "click", t))(C || {}), m = /* @__PURE__ */ ((t) => (t.TOPLEFT = "top-left", t.TOPRIGHT = "top-right", t.TOPCENTER = "top-center", t.RIGHTTOP = "right-top", t.RIGHTBOTTOM = "right-bottom", t.RIGHTCENTER = "right-center", t.BOTTOMLEFT = "bottom-left", t.BOTTOMRIGHT = "bottom-right", t.BOTTOMCENTER = "bottom-center", t.LEFTTOP = "left-top", t.LEFTBOTTOM = "left-bottom", t.LEFTCENTER = "left-center", t.BOTTOM = "bottom", t.RIGHT = "right", t.LEFT = "left", t.TOP = "top", t.AUTO = "auto", t))(m || {});
|
|
5
|
+
const $t = window.getComputedStyle(document.documentElement), E = parseFloat($t.fontSize), V = 7;
|
|
6
|
+
function Mt(t) {
|
|
7
|
+
if (t) {
|
|
8
|
+
const e = document.querySelector(".ar-Editor__frame");
|
|
9
|
+
if (e)
|
|
10
|
+
return e.contentDocument;
|
|
11
|
+
}
|
|
12
|
+
return document;
|
|
13
|
+
}
|
|
14
|
+
function at(t) {
|
|
15
|
+
if (t) {
|
|
16
|
+
const e = document.querySelector(".ar-Editor__frame");
|
|
17
|
+
if (e)
|
|
18
|
+
return e.contentWindow;
|
|
19
|
+
}
|
|
20
|
+
return window;
|
|
21
|
+
}
|
|
22
|
+
function Nt(t, e, o, r) {
|
|
23
|
+
const a = at(r) || window;
|
|
24
|
+
if ({
|
|
25
|
+
bottom: e.top + e.height + o.height > a.innerHeight,
|
|
26
|
+
right: e.left + e.width + o.width > a.innerWidth,
|
|
27
|
+
left: e.left - o.width < 0,
|
|
28
|
+
top: e.top - o.height < 0
|
|
29
|
+
}[t])
|
|
30
|
+
return !1;
|
|
31
|
+
if (t === "left" || t === "right") {
|
|
32
|
+
if (E > e.top || E > e.bottom)
|
|
33
|
+
return !1;
|
|
34
|
+
} else if (E > e.left || E > e.right)
|
|
35
|
+
return !1;
|
|
36
|
+
return t;
|
|
37
|
+
}
|
|
38
|
+
function At(t, e, o, r, a) {
|
|
39
|
+
const s = {
|
|
40
|
+
[m.BOTTOM]: {
|
|
41
|
+
top: e.top + e.height + (r ? 0 : V) + (a || 0),
|
|
42
|
+
left: e.left + (e.width - o.width) / 2
|
|
43
|
+
},
|
|
44
|
+
[m.RIGHT]: {
|
|
45
|
+
top: e.top + (e.height - o.height) / 2,
|
|
46
|
+
left: e.left + e.width + (r ? 0 : V)
|
|
47
|
+
},
|
|
48
|
+
[m.LEFT]: {
|
|
49
|
+
top: e.top + (e.height - o.height) / 2,
|
|
50
|
+
left: e.left - o.width - (r ? 0 : V)
|
|
51
|
+
},
|
|
52
|
+
[m.TOP]: {
|
|
53
|
+
top: e.top - o.height - (r ? 0 : V) - (a || 0),
|
|
54
|
+
left: e.left + (e.width - o.width) / 2
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
let { left: n, top: c } = s[t];
|
|
58
|
+
return t === m.BOTTOM || t === m.TOP ? (n < 0 && (n = E), n + o.width > window.innerWidth && (n = `calc(100% - ${o.width}px - ${E}px)`)) : (c < 0 && (c = E), c + o.height > window.innerHeight && (c = `calc(100% - ${o.height}px - ${E}px)`)), { left: n, top: c };
|
|
59
|
+
}
|
|
60
|
+
function Ht(t, e, o, r) {
|
|
61
|
+
if (o && o !== m.AUTO)
|
|
62
|
+
return o;
|
|
63
|
+
const a = [
|
|
64
|
+
m.BOTTOM,
|
|
65
|
+
m.RIGHT,
|
|
66
|
+
m.LEFT,
|
|
67
|
+
m.TOP
|
|
68
|
+
];
|
|
69
|
+
for (const s of a)
|
|
70
|
+
if (Nt(s, t, e, r))
|
|
71
|
+
return s;
|
|
72
|
+
return m.BOTTOM;
|
|
73
|
+
}
|
|
74
|
+
function Ft(t, e, o, r, a, s, n) {
|
|
75
|
+
const c = at(s) || window;
|
|
76
|
+
t = a ? {
|
|
77
|
+
left: a[0],
|
|
78
|
+
x: a[0],
|
|
79
|
+
top: a[1],
|
|
80
|
+
y: a[1],
|
|
81
|
+
height: 0,
|
|
82
|
+
width: 0,
|
|
83
|
+
right: c.screen.width - a[0],
|
|
84
|
+
bottom: c.screen.height - a[1],
|
|
85
|
+
toJSON: () => {
|
|
86
|
+
}
|
|
87
|
+
} : t;
|
|
88
|
+
const i = Ht(
|
|
89
|
+
t,
|
|
90
|
+
e,
|
|
91
|
+
o,
|
|
92
|
+
s
|
|
93
|
+
), { left: l, top: d } = At(
|
|
94
|
+
i,
|
|
95
|
+
t,
|
|
96
|
+
e,
|
|
97
|
+
r,
|
|
98
|
+
n
|
|
99
|
+
);
|
|
100
|
+
return {
|
|
101
|
+
leftTop: {
|
|
102
|
+
top: ("" + d).startsWith("calc") ? d : d + "px",
|
|
103
|
+
left: ("" + l).startsWith("calc") ? l : l + "px"
|
|
104
|
+
},
|
|
105
|
+
position: i
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const Gt = (t) => {
|
|
109
|
+
const { children: e, classes: o, container: r, demo: a, styles: s } = t, [n, c] = L();
|
|
110
|
+
return S(() => (c(r || document.createElement("div")), () => c(null)), [r]), S(() => {
|
|
111
|
+
if (n) {
|
|
112
|
+
const i = Mt(a);
|
|
113
|
+
if (i) {
|
|
114
|
+
const l = i.getElementById("root");
|
|
115
|
+
l && l.appendChild(n);
|
|
116
|
+
}
|
|
117
|
+
return () => {
|
|
118
|
+
if (i) {
|
|
119
|
+
const l = i.getElementById("root");
|
|
120
|
+
l && l.removeChild(n);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}, [n, a]), S(() => {
|
|
125
|
+
n && (o && (n.className = o), n.classList.contains("ar-Portal") || n.classList.add("ar-Portal"), s && Object.assign(n.style, s));
|
|
126
|
+
}, [o, s, n]), n ? Pt.createPortal(e, n) : null;
|
|
127
|
+
};
|
|
128
|
+
let Bt = !1;
|
|
129
|
+
const jt = {
|
|
130
|
+
left: "right",
|
|
131
|
+
right: "left",
|
|
132
|
+
top: "bottom",
|
|
133
|
+
bottom: "top"
|
|
134
|
+
}, Dt = {
|
|
135
|
+
left: "135",
|
|
136
|
+
right: "-45",
|
|
137
|
+
top: "-135",
|
|
138
|
+
bottom: "45"
|
|
139
|
+
}, Vt = (t) => {
|
|
140
|
+
const {
|
|
141
|
+
classes: e,
|
|
142
|
+
children: o,
|
|
143
|
+
closeOnSelfClick: r,
|
|
144
|
+
contentClasses: a,
|
|
145
|
+
contentMatchAnchorWidth: s,
|
|
146
|
+
demo: n,
|
|
147
|
+
disabled: c,
|
|
148
|
+
hideMarker: i,
|
|
149
|
+
invertBg: l,
|
|
150
|
+
isOpen: d,
|
|
151
|
+
isRaw: u,
|
|
152
|
+
onAnchorClick: b,
|
|
153
|
+
onClose: w,
|
|
154
|
+
popAtPointer: H,
|
|
155
|
+
position: j = st.AUTO,
|
|
156
|
+
preserveMarkerSpace: J,
|
|
157
|
+
stretch: gt,
|
|
158
|
+
topOffset: Z,
|
|
159
|
+
trigger: R = C.CLICK,
|
|
160
|
+
animation: F,
|
|
161
|
+
updateTriggers: mt,
|
|
162
|
+
wrapText: ft,
|
|
163
|
+
...vt
|
|
164
|
+
} = t, f = Ct(
|
|
165
|
+
() => F && !Array.isArray(F) ? [F] : F,
|
|
166
|
+
[F]
|
|
167
|
+
), P = D(null), O = D(null), [k, $] = L(), [wt, Tt] = L(), [x, bt] = L(), [Y, Q] = L(), [M, U] = L(), z = D(), tt = D(0), et = Et(() => {
|
|
168
|
+
if (!P.current || !O.current)
|
|
169
|
+
return;
|
|
170
|
+
const h = P.current.getBoundingClientRect();
|
|
171
|
+
s && (O.current.style.width = h.width + "px");
|
|
172
|
+
const g = O.current.getBoundingClientRect();
|
|
173
|
+
f && f.length > 0 && f.indexOf(B.EXPANDSHRINK) > -1 && (g.width = Math.floor(g.width * 1.25), g.height = Math.floor(g.height * 1.25));
|
|
174
|
+
const { leftTop: v, position: T } = Ft(
|
|
175
|
+
h,
|
|
176
|
+
g,
|
|
177
|
+
j,
|
|
178
|
+
i && !J,
|
|
179
|
+
H && R === C.CLICK ? z.current : null,
|
|
180
|
+
n,
|
|
181
|
+
Z
|
|
182
|
+
);
|
|
183
|
+
Tt(v), bt(T);
|
|
184
|
+
}, [
|
|
185
|
+
s,
|
|
186
|
+
n,
|
|
187
|
+
i,
|
|
188
|
+
H,
|
|
189
|
+
j,
|
|
190
|
+
J,
|
|
191
|
+
Z,
|
|
192
|
+
R,
|
|
193
|
+
f
|
|
194
|
+
]);
|
|
195
|
+
let W, ot;
|
|
196
|
+
return Rt.forEach(o, (h) => {
|
|
197
|
+
var g, v;
|
|
198
|
+
((g = h == null ? void 0 : h.props) == null ? void 0 : g.slot) === K.ANCHOR && (ot = h), ((v = h == null ? void 0 : h.props) == null ? void 0 : v.slot) === K.POPOVER && (W = h);
|
|
199
|
+
}), S(() => {
|
|
200
|
+
d !== void 0 && ($(d), d && !M && U(!0));
|
|
201
|
+
}, [d, M]), S(() => {
|
|
202
|
+
var h;
|
|
203
|
+
let g = (v) => {
|
|
204
|
+
P.current && !P.current.contains(v.target) && O.current && !O.current.contains(v.target) && ($(!1), w && w());
|
|
205
|
+
};
|
|
206
|
+
if (R === C.CLICK && k) {
|
|
207
|
+
document.addEventListener("mousedown", g);
|
|
208
|
+
const v = document.querySelector("iframe");
|
|
209
|
+
return v && ((h = v.contentWindow) == null || h.document.addEventListener("mousedown", g)), () => {
|
|
210
|
+
var T;
|
|
211
|
+
document.removeEventListener("click", g);
|
|
212
|
+
const N = document.querySelector("iframe");
|
|
213
|
+
N && ((T = N.contentWindow) == null || T.document.removeEventListener("click", g));
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}, [R, k, w]), S(() => {
|
|
217
|
+
M && k && (et(), Q(!0));
|
|
218
|
+
}, [
|
|
219
|
+
k,
|
|
220
|
+
M,
|
|
221
|
+
et,
|
|
222
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
223
|
+
...mt || []
|
|
224
|
+
]), S(() => {
|
|
225
|
+
if (!i && O.current && Y && x) {
|
|
226
|
+
const h = O.current, g = P.current.getBoundingClientRect(), v = jt[x], T = h.getBoundingClientRect();
|
|
227
|
+
f && f.length > 0 && f.indexOf(B.EXPANDSHRINK) > -1 && (T.width = Math.floor(T.width * 1.25), T.height = Math.floor(T.height * 1.25));
|
|
228
|
+
const N = x === "top" || x === "bottom";
|
|
229
|
+
let rt = g[N ? "width" : "height"] / 2 - 7;
|
|
230
|
+
const yt = g.left - T.left + rt, Ot = g.top - T.top + rt;
|
|
231
|
+
h.style.setProperty(
|
|
232
|
+
"--marker-transform",
|
|
233
|
+
`rotate(${Dt[x]}deg)`
|
|
234
|
+
), h.style.setProperty(
|
|
235
|
+
`--marker-${v}`,
|
|
236
|
+
"-0.35rem"
|
|
237
|
+
), h.style.setProperty(
|
|
238
|
+
`--marker-${x}`,
|
|
239
|
+
"initial"
|
|
240
|
+
), h.style.setProperty(
|
|
241
|
+
`--marker-${N ? "left" : "top"}`,
|
|
242
|
+
(N ? yt : Ot) + "px"
|
|
243
|
+
), Q(!1);
|
|
244
|
+
}
|
|
245
|
+
}, [
|
|
246
|
+
Y,
|
|
247
|
+
O,
|
|
248
|
+
i,
|
|
249
|
+
x,
|
|
250
|
+
z,
|
|
251
|
+
f
|
|
252
|
+
]), /* @__PURE__ */ nt(kt, { children: [
|
|
253
|
+
/* @__PURE__ */ y(
|
|
254
|
+
"span",
|
|
255
|
+
{
|
|
256
|
+
className: `ar-Popover__anchor${e ? " " + e : ""}${gt ? " w-100" : ""}`,
|
|
257
|
+
onMouseDown: (h) => {
|
|
258
|
+
z.current = [h.clientX, h.clientY], Date.now() - tt.current < 500 || (tt.current = Date.now(), R === C.CLICK && !Bt && !c && (!M && U(!0), (d === void 0 || d) && setTimeout(() => $(!k), 0)), k && w && w(), b && b(!k));
|
|
259
|
+
},
|
|
260
|
+
ref: P,
|
|
261
|
+
onMouseEnter: () => {
|
|
262
|
+
R === C.HOVER && !c && (U(!0), setTimeout(() => $(!0), 0));
|
|
263
|
+
},
|
|
264
|
+
onMouseLeave: () => {
|
|
265
|
+
R === C.HOVER && !c && (setTimeout(() => $(!1), 0), w && w());
|
|
266
|
+
},
|
|
267
|
+
...vt,
|
|
268
|
+
children: ot
|
|
269
|
+
}
|
|
270
|
+
),
|
|
271
|
+
W && M && /* @__PURE__ */ y(
|
|
272
|
+
Gt,
|
|
273
|
+
{
|
|
274
|
+
classes: `position-fixed popover-container${k ? " z-3000" : " invisible"}`,
|
|
275
|
+
demo: n,
|
|
276
|
+
styles: wt || {},
|
|
277
|
+
children: /* @__PURE__ */ y(
|
|
278
|
+
"div",
|
|
279
|
+
{
|
|
280
|
+
className: `ar-Popover__content${l ? " invert-bg" : ""}${ft ? " wrap" : ""}${j ? " " + j : ""} ${a}${f && f.length > 0 ? " transition " + (f == null ? void 0 : f.join(" ")) : ""} ${k ? " show" : ""}${i ? " hide-marker" : ""}${u ? "" : " p-1 border-radius l2 f25"}`,
|
|
281
|
+
onClick: () => r && $(!1),
|
|
282
|
+
ref: O,
|
|
283
|
+
children: W
|
|
284
|
+
}
|
|
285
|
+
)
|
|
286
|
+
}
|
|
287
|
+
)
|
|
288
|
+
] });
|
|
289
|
+
}, Ut = (t) => {
|
|
290
|
+
const { children: e, demo: o, ...r } = t, [a, s] = L();
|
|
291
|
+
return /* @__PURE__ */ y(
|
|
292
|
+
Vt,
|
|
293
|
+
{
|
|
294
|
+
contentClasses: "overflow-auto",
|
|
295
|
+
trigger: C.HOVER,
|
|
296
|
+
onAnchorClick: () => {
|
|
297
|
+
s(!1), setTimeout(() => s(void 0), 10);
|
|
298
|
+
},
|
|
299
|
+
animation: [
|
|
300
|
+
B.EXPANDSHRINK,
|
|
301
|
+
B.FADEINOUT
|
|
302
|
+
],
|
|
303
|
+
demo: o,
|
|
304
|
+
isOpen: a,
|
|
305
|
+
hideMarker: !0,
|
|
306
|
+
preserveMarkerSpace: !0,
|
|
307
|
+
wrapText: !0,
|
|
308
|
+
...r,
|
|
309
|
+
children: e
|
|
310
|
+
}
|
|
311
|
+
);
|
|
312
|
+
}, ct = new DOMParser(), I = ct.parseFromString(
|
|
313
|
+
`<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">
|
|
314
|
+
<rect width="20" height="20" x="2" y="2" fill="none" stroke="#000" stroke-width="2"rx="2"></rect>
|
|
315
|
+
</svg>`,
|
|
316
|
+
G.SVG
|
|
317
|
+
).querySelector("svg"), zt = /^[a-zA-Z]{2,3}[./][a-zA-Z0-9]+$/, Wt = (t) => typeof t == "object" ? p.raw : t.startsWith("data:image/svg+xml;base64,") ? p.b64 : t.startsWith("<svg") ? p.svgString : t.startsWith("http://") || t.startsWith("https://") ? p.URL : zt.test(t) ? p.identifier : p.b64, q = (t) => {
|
|
318
|
+
try {
|
|
319
|
+
const e = ct.parseFromString(t, G.SVG).querySelector("svg");
|
|
320
|
+
return console.warn("Parsed item isn't an svg"), e === null ? I : e;
|
|
321
|
+
} catch (e) {
|
|
322
|
+
return console.warn("Error parsing SVG string:", e), I;
|
|
323
|
+
}
|
|
324
|
+
}, _t = (t) => {
|
|
325
|
+
try {
|
|
326
|
+
const e = atob(t);
|
|
327
|
+
return q(e);
|
|
328
|
+
} catch (e) {
|
|
329
|
+
return console.error("Error decoding base64 SVG string:", e), I;
|
|
330
|
+
}
|
|
331
|
+
}, Kt = (t) => {
|
|
332
|
+
const e = (o) => {
|
|
333
|
+
const r = Array.from(o.children).map(e), a = Array.from(o.attributes).reduce((s, n) => (s[n.name] = n.value, s), {});
|
|
334
|
+
return xt(o.tagName, a, ...r);
|
|
335
|
+
};
|
|
336
|
+
return e(t);
|
|
337
|
+
}, qt = (t, e) => {
|
|
338
|
+
const { attributes: o, theme: r } = t, { colors: a } = o || {}, {
|
|
339
|
+
strokeColor: s,
|
|
340
|
+
toggleStrokeColor: n,
|
|
341
|
+
hoverStrokeColor: c,
|
|
342
|
+
darkStrokeColor: i,
|
|
343
|
+
darkToggleStrokeColor: l,
|
|
344
|
+
darkHoverStrokeColor: d
|
|
345
|
+
} = a || {}, { hovered: u, toggled: b } = e;
|
|
346
|
+
return r === X.DARK1 ? u && d ? d : b && l ? l : i : u && c ? c : b && n ? n : s;
|
|
347
|
+
}, Xt = (t, e) => {
|
|
348
|
+
const { attributes: o, theme: r } = t, { colors: a } = o || {}, {
|
|
349
|
+
fillColor: s,
|
|
350
|
+
toggleFillColor: n,
|
|
351
|
+
hoverFillColor: c,
|
|
352
|
+
darkFillColor: i,
|
|
353
|
+
darkToggleFillColor: l,
|
|
354
|
+
darkHoverFillColor: d
|
|
355
|
+
} = a || {}, { hovered: u, toggled: b } = e;
|
|
356
|
+
return r === X.DARK1 ? u && d ? d : b && l ? l : i : u && c ? c : b && n ? n : s;
|
|
357
|
+
}, Jt = (t, e, o) => {
|
|
358
|
+
if (!(t instanceof SVGSVGElement))
|
|
359
|
+
return;
|
|
360
|
+
const { attributes: r, hoverShadow: a } = e, { strokeWidth: s, styles: n } = r || {}, c = ((r == null ? void 0 : r.classes) || "") + (a ? " hover-shadow p-1" : ""), i = Xt(e, o), l = qt(e, o), d = (r == null ? void 0 : r.height) || (typeof (n == null ? void 0 : n.height) == "number" ? typeof (n == null ? void 0 : n.height) + "px" : typeof (n == null ? void 0 : n.height)) || (r == null ? void 0 : r.size) || "1rem", u = (r == null ? void 0 : r.width) || (typeof (n == null ? void 0 : n.width) == "number" ? typeof (n == null ? void 0 : n.width) + "px" : typeof (n == null ? void 0 : n.width)) || (r == null ? void 0 : r.size) || "1rem";
|
|
361
|
+
i && t.setAttribute("fill", i), l && t.setAttribute("stroke", l), s && t.setAttribute("stroke-width", s), t.setAttribute("width", u), t.setAttribute("height", d), t.setAttribute("class", `ar-Icon${c ? " " + c : ""}`), n && Object.assign(t.style, n);
|
|
362
|
+
};
|
|
363
|
+
(function() {
|
|
364
|
+
try {
|
|
365
|
+
if (typeof document < "u") {
|
|
366
|
+
var t = document.createElement("style");
|
|
367
|
+
t.appendChild(document.createTextNode(".ar-Icon{transition:all .3s}.ar-Icon:hover.hover-shadow{box-shadow:0 4px 8px var(--ar-shadow)}")), document.head.appendChild(t);
|
|
368
|
+
}
|
|
369
|
+
} catch (e) {
|
|
370
|
+
console.error("vite-plugin-css-injected-by-js", e);
|
|
371
|
+
}
|
|
372
|
+
})();
|
|
373
|
+
const Zt = {
|
|
374
|
+
development: "http://localhost:5000/api",
|
|
375
|
+
production: "https://api.armco.tech"
|
|
376
|
+
}, lt = {
|
|
377
|
+
development: "http://localhost:5001/api",
|
|
378
|
+
production: "https://static.armco.tech"
|
|
379
|
+
};
|
|
380
|
+
`${lt[process.env.NODE_ENV]}`;
|
|
381
|
+
class dt {
|
|
382
|
+
constructor(e, o, r) {
|
|
383
|
+
this.message = e, this.status = o, this.extras = r;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
const Yt = 10;
|
|
387
|
+
async function Qt(t, e, o) {
|
|
388
|
+
const r = pt(t, e);
|
|
389
|
+
return o = {
|
|
390
|
+
method: "GET",
|
|
391
|
+
mode: "cors",
|
|
392
|
+
credentials: "include",
|
|
393
|
+
...o
|
|
394
|
+
}, ht(r, o);
|
|
395
|
+
}
|
|
396
|
+
async function te(t, e, o) {
|
|
397
|
+
let r = pt(t, e);
|
|
398
|
+
const a = process.env.NODE_ENV || "development", s = r.startsWith("http") ? "" : lt[a];
|
|
399
|
+
return r = s ? s + r : r, o = {
|
|
400
|
+
method: "GET",
|
|
401
|
+
mode: "cors",
|
|
402
|
+
credentials: "include",
|
|
403
|
+
...o
|
|
404
|
+
}, ht(r, o);
|
|
405
|
+
}
|
|
406
|
+
async function ht(t, e) {
|
|
407
|
+
const o = process.env.NODE_ENV || "development", r = t.startsWith("http") ? "" : Zt[o], a = e == null ? void 0 : e.extras;
|
|
408
|
+
t = r ? r + t : t, e.headers || (e.headers = {}), e.toggleLoader && e.toggleLoader({ [t]: !0 }), e.headers.Origin = window.location.protocol + "//" + window.location.host;
|
|
409
|
+
const s = await fetch(t, e), { ok: n, status: c, headers: i } = s;
|
|
410
|
+
if (n) {
|
|
411
|
+
if (i.get("content-type")) {
|
|
412
|
+
if (i.get("content-type").indexOf("application/json") !== -1) {
|
|
413
|
+
const u = await s.json();
|
|
414
|
+
return e.toggleLoader && e.toggleLoader({ [t]: !1 }), { status: c, body: u, headers: i };
|
|
415
|
+
} else if (i.get("content-type").indexOf("application/zip") !== -1 || i.get("content-type").indexOf("image/png") !== -1 || i.get("content-type").indexOf("application/pdf") !== -1 || i.get("content-type").indexOf("video/mp4") !== -1 || i.get("content-type").indexOf("image/gif") !== -1) {
|
|
416
|
+
const u = await s.blob();
|
|
417
|
+
return e.toggleLoader && e.toggleLoader({ [t]: !1 }), { status: c, body: u, headers: i };
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
const d = await s.text();
|
|
421
|
+
return e.toggleLoader && e.toggleLoader({ [t]: !1 }), { status: c, body: d, headers: i };
|
|
422
|
+
}
|
|
423
|
+
const l = await s.json();
|
|
424
|
+
throw e.toggleLoader && e.toggleLoader({ [t]: !1 }), console.log(l), new dt(l.error || l.message, c, a);
|
|
425
|
+
}
|
|
426
|
+
function pt(t, e) {
|
|
427
|
+
if (!e)
|
|
428
|
+
return t || "";
|
|
429
|
+
const o = Object.keys(e).length;
|
|
430
|
+
return t && o ? Object.keys(e).filter((r) => e[r] !== void 0).reduce(
|
|
431
|
+
(r, a, s) => r.concat(
|
|
432
|
+
`${encodeURIComponent(a)}=${encodeURIComponent(
|
|
433
|
+
e[a]
|
|
434
|
+
).replace(/'/g, "%27")}` + (s < o - 1 ? "&" : "")
|
|
435
|
+
),
|
|
436
|
+
t + "?"
|
|
437
|
+
) : "";
|
|
438
|
+
}
|
|
439
|
+
async function ee(t, e = {}) {
|
|
440
|
+
let {
|
|
441
|
+
retryDescriptor: o = [1, 3, 5],
|
|
442
|
+
maxAttempts: r = 5,
|
|
443
|
+
onRetry: a,
|
|
444
|
+
onSuccess: s,
|
|
445
|
+
onFailure: n
|
|
446
|
+
} = e;
|
|
447
|
+
r = Math.min(r, Yt);
|
|
448
|
+
let c = 0;
|
|
449
|
+
const i = async () => {
|
|
450
|
+
try {
|
|
451
|
+
const l = await t();
|
|
452
|
+
return s && s(), l;
|
|
453
|
+
} catch (l) {
|
|
454
|
+
if (c < Math.min(o.length, r)) {
|
|
455
|
+
const d = o[c] * 1e3;
|
|
456
|
+
return c++, a && a(c, d), console.warn(`Retrying in ${d / 1e3} seconds...`), await new Promise((u) => setTimeout(u, d)), i();
|
|
457
|
+
} else {
|
|
458
|
+
const d = new dt(
|
|
459
|
+
"Max retries reached",
|
|
460
|
+
500,
|
|
461
|
+
l
|
|
462
|
+
);
|
|
463
|
+
throw n && n(d), d;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
return i();
|
|
468
|
+
}
|
|
469
|
+
var ut = /* @__PURE__ */ ((t) => (t.LIGHT1 = "th-light-1", t.DARK1 = "th-dark-1", t))(ut || {});
|
|
470
|
+
function oe() {
|
|
471
|
+
let t = !1;
|
|
472
|
+
return function(e) {
|
|
473
|
+
(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(
|
|
474
|
+
e
|
|
475
|
+
) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(
|
|
476
|
+
e.substr(0, 4)
|
|
477
|
+
)) && (t = !0);
|
|
478
|
+
}(
|
|
479
|
+
navigator.userAgent || navigator.vendor || "opera" in window && window.opera
|
|
480
|
+
), t;
|
|
481
|
+
}
|
|
482
|
+
it({ slotted: [] });
|
|
483
|
+
const re = it({
|
|
484
|
+
theme: ut.DARK1,
|
|
485
|
+
drawerState: { collapsed: oe() },
|
|
486
|
+
notify: () => {
|
|
487
|
+
},
|
|
488
|
+
setDrawerState: () => {
|
|
489
|
+
},
|
|
490
|
+
setLeftPanelContent: () => {
|
|
491
|
+
},
|
|
492
|
+
setLoggedIn: () => {
|
|
493
|
+
},
|
|
494
|
+
setModalState: () => {
|
|
495
|
+
},
|
|
496
|
+
setRightPanelContent: () => {
|
|
497
|
+
},
|
|
498
|
+
setTheme: () => {
|
|
499
|
+
},
|
|
500
|
+
setUser: () => {
|
|
501
|
+
}
|
|
502
|
+
}), ne = () => {
|
|
503
|
+
const t = Lt(re);
|
|
504
|
+
if (!t)
|
|
505
|
+
throw new Error("useTheme must be used within an ArProvider");
|
|
506
|
+
return { theme: t.theme, setTheme: t.setTheme };
|
|
507
|
+
}, ie = (t) => (e) => {
|
|
508
|
+
const { theme: o, setTheme: r } = ne();
|
|
509
|
+
return /* @__PURE__ */ y(t, { ...e, theme: o, setTheme: r });
|
|
510
|
+
}, A = {};
|
|
511
|
+
class se extends St {
|
|
512
|
+
constructor(e) {
|
|
513
|
+
super(e), this.parseIconDescriptor = (o) => {
|
|
514
|
+
var r, a, s;
|
|
515
|
+
const n = typeof o == "object" && "source" in o, c = n && !!p[o.type];
|
|
516
|
+
let i = n ? o.source : o;
|
|
517
|
+
const l = c ? o.type : Wt(i);
|
|
518
|
+
let d;
|
|
519
|
+
if (l === p.identifier || l === p.URL) {
|
|
520
|
+
i = i;
|
|
521
|
+
const u = l === p.URL ? i : i.replace(/./g, "/"), b = () => (l === p.URL ? Qt : te)(u);
|
|
522
|
+
if (A[i])
|
|
523
|
+
A[i].icon ? this.setState({
|
|
524
|
+
juice: A[i].icon ?? I,
|
|
525
|
+
type: l
|
|
526
|
+
}) : (r = A[i].promise) == null || r.then(
|
|
527
|
+
(w) => this.handleIconResponse(w, i, l)
|
|
528
|
+
);
|
|
529
|
+
else {
|
|
530
|
+
const w = ee(b).then((H) => (this.handleIconResponse(H, i, l), H));
|
|
531
|
+
A[i] = { promise: w };
|
|
532
|
+
}
|
|
533
|
+
} else {
|
|
534
|
+
switch (l) {
|
|
535
|
+
case p.b64:
|
|
536
|
+
d = _t(i);
|
|
537
|
+
break;
|
|
538
|
+
case p.raw:
|
|
539
|
+
d = /* @__PURE__ */ y(
|
|
540
|
+
"img",
|
|
541
|
+
{
|
|
542
|
+
src: i,
|
|
543
|
+
alt: "ar-icon",
|
|
544
|
+
className: `ar-Icon ${(a = this.props.attributes) == null ? void 0 : a.classes}${this.props.hoverShadow ? " hover-shadow p-1" : ""}`,
|
|
545
|
+
style: (s = this.props.attributes) == null ? void 0 : s.styles
|
|
546
|
+
}
|
|
547
|
+
);
|
|
548
|
+
break;
|
|
549
|
+
case p.svgString:
|
|
550
|
+
d = q(i);
|
|
551
|
+
break;
|
|
552
|
+
default:
|
|
553
|
+
console.error("Unsupported icon type."), d = I;
|
|
554
|
+
}
|
|
555
|
+
d && this.setState({ juice: d, type: l });
|
|
556
|
+
}
|
|
557
|
+
}, this.handleMouseEnter = () => {
|
|
558
|
+
var o, r;
|
|
559
|
+
this.setState({ hovered: !0 }), (r = (o = this.props.events) == null ? void 0 : o.onMouseEnter) == null || r.call(o);
|
|
560
|
+
}, this.handleMouseLeave = () => {
|
|
561
|
+
var o, r;
|
|
562
|
+
this.setState({ hovered: !1 }), (r = (o = this.props.events) == null ? void 0 : o.onMouseLeave) == null || r.call(o);
|
|
563
|
+
}, this.state = {
|
|
564
|
+
hovered: !1,
|
|
565
|
+
toggled: e.toggled || !1,
|
|
566
|
+
juice: I,
|
|
567
|
+
type: p.svgString
|
|
568
|
+
}, this.parseIconDescriptor = this.parseIconDescriptor.bind(this), this.handleIconResponse = this.handleIconResponse.bind(this);
|
|
569
|
+
}
|
|
570
|
+
componentDidMount() {
|
|
571
|
+
this.props.icon && this.parseIconDescriptor(this.props.icon);
|
|
572
|
+
}
|
|
573
|
+
componentDidUpdate(e) {
|
|
574
|
+
if (JSON.stringify(e.attributes) !== JSON.stringify(this.props.attributes)) {
|
|
575
|
+
const { juice: o } = this.state;
|
|
576
|
+
o && Jt(o, this.props, this.state);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
handleIconResponse(e, o, r) {
|
|
580
|
+
var a, s;
|
|
581
|
+
const n = e.headers.get("content-type");
|
|
582
|
+
let c;
|
|
583
|
+
r === p.identifier || n != null && n.includes(G.SVG) ? c = q(e.body) : n && Object.values(G).findIndex(
|
|
584
|
+
(i) => n.includes(i)
|
|
585
|
+
) > -1 ? c = /* @__PURE__ */ y(
|
|
586
|
+
"img",
|
|
587
|
+
{
|
|
588
|
+
src: o,
|
|
589
|
+
alt: "ar-icon",
|
|
590
|
+
className: `ar-Icon ${(a = this.props.attributes) == null ? void 0 : a.classes}${this.props.hoverShadow ? " hover-shadow p-1" : ""}`,
|
|
591
|
+
style: (s = this.props.attributes) == null ? void 0 : s.styles
|
|
592
|
+
}
|
|
593
|
+
) : (console.error("Unsupported content type."), c = I), c && this.setState({ juice: c, type: r }), A[o].icon = c;
|
|
594
|
+
}
|
|
595
|
+
render() {
|
|
596
|
+
var e;
|
|
597
|
+
const { juice: o, type: r } = this.state;
|
|
598
|
+
return o ? r === p.raw ? o : It(
|
|
599
|
+
Kt(o),
|
|
600
|
+
{
|
|
601
|
+
onMouseEnter: this.handleMouseEnter,
|
|
602
|
+
onMouseLeave: this.handleMouseLeave,
|
|
603
|
+
onClick: (e = this.props.events) == null ? void 0 : e.onClick,
|
|
604
|
+
onClickCapture: () => this.setState({ toggled: !this.state.toggled })
|
|
605
|
+
}
|
|
606
|
+
) : null;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
const ae = ie(se), he = ({
|
|
610
|
+
icon: t,
|
|
611
|
+
handler: e,
|
|
612
|
+
tooltip: o
|
|
613
|
+
}) => /* @__PURE__ */ nt(Ut, { children: [
|
|
614
|
+
/* @__PURE__ */ y("span", { className: "mx-3 p-1 cursor-pointer", slot: _.ANCHOR, children: /* @__PURE__ */ y(
|
|
615
|
+
ae,
|
|
616
|
+
{
|
|
617
|
+
icon: t,
|
|
618
|
+
attributes: {
|
|
619
|
+
colors: { fillColor: "#ffffff99" },
|
|
620
|
+
classes: "cursor-pointer",
|
|
621
|
+
size: "2rem"
|
|
622
|
+
},
|
|
623
|
+
events: { onClick: e }
|
|
624
|
+
}
|
|
625
|
+
) }),
|
|
626
|
+
/* @__PURE__ */ y("span", { slot: _.POPOVER, children: o })
|
|
627
|
+
] });
|
|
628
|
+
export {
|
|
629
|
+
ae as B,
|
|
630
|
+
he as C,
|
|
631
|
+
_ as L,
|
|
632
|
+
Ut as v
|
|
633
|
+
};
|
package/es/Control.js
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode('.ar-Image{transition:all .3s}.ar-Image.fill{object-fit:cover}.ar-Image.fill.preserveAspectRatio{object-fit:contain}.ar-Slider input[type=range]{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;cursor:pointer}.ar-Slider input[type=range]:hover+.ar-Slider__bubble{opacity:1}.ar-Slider input[type=range]:focus{outline:none}.ar-Slider input[type=range]::-webkit-slider-runnable-track{background-color:#053a5f;border-radius:.2rem;height:.2rem}.ar-Slider input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;margin-top:-6.5px;transition:outline .5s;background-color:var(--ar-bg-slider-track);height:1rem;width:1rem;border-radius:50%}.ar-Slider input[type=range]::-webkit-slider-thumb:hover{border:5px solid var(--ar-bg-slider-track)}.ar-Slider input[type=range]:focus::-webkit-slider-thumb{border:1px solid #053a5f}.ar-Slider input[type=range]::-moz-range-track{background-color:#053a5f;border-radius:.2rem;height:.2rem}.ar-Slider input[type=range]::-moz-range-thumb{border:none;border-radius:0;background-color:var(--ar-bg-slider-track);height:1rem;width:1rem}.ar-Slider input[type=range]:focus::-moz-range-thumb{border:1px solid #053a5f}.ar-Slider .ar-Slider__bubble{background:#454545;color:#fff;padding:4px 12px;border-radius:4px;left:50%;bottom:-1.5rem;transform:translate(-50%);opacity:0;transition:opacity .3s}.ar-Slider .ar-Slider__bubble:after{content:"";position:absolute;width:4px;height:4px;transform:rotate(45deg);background:#454545;top:-2px;left:50%}.ar-Slider .ar-Slider__manual-input{width:2rem}.ar-ImageEditor .ar-ImageEditor__image-container{max-width:60vw;max-height:75vh}.ar-ImageEditor .ar-ImageEditor__editor-controls{transition:background-color .5s,box-shadow .5s ease-in-out;background-color:var(--ar-bg-tertiary-faded-2);border-radius:2rem}.ar-ImageEditor .ar-ImageEditor__editor-controls:hover{background-color:var(--ar-bg-tertiary-faded)}.ar-ImageEditor .ar-ImageEditor__editor-controls .ar-ImageEditor__download-button{width:2rem;height:2rem;display:inline-block}.ar-ImageEditor .ar-ImageEditor__editor-controls .ar-ImageEditor__download-button:hover{background-color:var(--ar-bg-tertiary-faded-2)}.ar-ImageEditor .ar-ImageEditor__editor-controls .ar-ImageEditor__commit-button{width:2rem;height:2rem;display:inline-block}.ar-ImageEditor .ar-ImageEditor__editor-controls .ar-ImageEditor__commit-button.is-dirty:hover{background-color:var(--ar-bg-tertiary-faded-2)}.ar-ImageEditor .ar-ImageEditor__controls{bottom:0}.ar-ImageEditor .ar-ImageEditor__controls .ar-ImageEditor__controls-container{transition:background-color .5s,box-shadow .5s,max-height .5s ease-in-out;background-color:var(--ar-bg-tertiary-faded-2);max-height:3.2rem;overflow:hidden}.ar-ImageEditor .ar-ImageEditor__controls .ar-ImageEditor__controls-container:hover{background-color:var(--ar-bg-tertiary-faded)}.ar-ImageEditor .ar-ImageEditor__controls .ar-ImageEditor__controls-container.expanded{max-height:20rem}.ar-Portal{z-index:2001;white-space:nowrap}.ar-Popover__anchor:focus-visible{outline:none}:root{--marker-transform: rotate(45deg);--marker-top: -.4rem;--marker-left: 10%;--marker-right: unset;--marker-bottom: unset}:root .ar-Popover__content{box-shadow:0 4px 8px -2px #091e4240,0 0 1px #091e424f;z-index:2002;background-color:var(--ar-bg);white-space:nowrap;position:relative;border:1px solid var(--ar-color-border)}:root .ar-Popover__content>*{position:relative}:root .ar-Popover__content.invert-bg{background-color:var(--ar-bg-invert-1)}:root .ar-Popover__content.wrap{white-space:wrap}:root .ar-Popover__content:not(.hide-marker):before{content:"";background-color:var(--ar-bg);position:absolute;height:.7rem;width:.7rem;border-width:1px;border-style:solid;border-color:var(--ar-color-border) transparent transparent var(--ar-color-border);transform:var(--marker-transform);top:var(--marker-top);left:var(--marker-left);right:var(--marker-right);bottom:var(--marker-bottom)}:root .ar-Popover__content.invert-bg:not(.hide-marker):before{background-color:var(--ar-bg-invert-1)}:root .ar-Popover__content.transition{transition:width .15s ease-in-out,height .15s ease-in-out,opacity .3s ease-in-out,transform .15s ease-in-out}:root .ar-Popover__content.transition.expand-shrink{transform:scale(.8)}:root .ar-Popover__content.transition.show{transform:scale(1)}@media (min-width: 576px){:root .ar-Popover__content{max-width:25vw}}:root .ar-List__item{line-height:1.5rem}:root .ar-List__item:hover{background-color:var(--ar-color-font);color:var(--ar-color-font-invert);cursor:pointer}')),document.head.appendChild(r)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
2
|
+
import { jsx as a, jsxs as x } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as L, useRef as w, useState as R, useEffect as B } from "react";
|
|
4
|
+
import { v as z, L as I, B as F, C as V } from "./Control-chunk.js";
|
|
5
|
+
import { downloadEditedImage as Z } from "./helper.js";
|
|
6
|
+
import "react-dom";
|
|
7
|
+
const M = (o) => new URL(o).hostname, D = (o) => {
|
|
8
|
+
const d = M(o);
|
|
9
|
+
return d === "localhost" || d === "armco.tech" ? "use-credentials" : "anonymous";
|
|
10
|
+
}, P = L(
|
|
11
|
+
(o, d) => {
|
|
12
|
+
const {
|
|
13
|
+
alt: u,
|
|
14
|
+
blur: c,
|
|
15
|
+
brightness: v,
|
|
16
|
+
classes: s,
|
|
17
|
+
contrast: m,
|
|
18
|
+
customBgZIndex: r,
|
|
19
|
+
demo: N,
|
|
20
|
+
fill: h,
|
|
21
|
+
flipHorizontal: b,
|
|
22
|
+
flipVertical: y,
|
|
23
|
+
grayscale: C,
|
|
24
|
+
image: i,
|
|
25
|
+
isBackground: p,
|
|
26
|
+
opacity: $,
|
|
27
|
+
preserveAspectRatio: _,
|
|
28
|
+
rotateBy: e,
|
|
29
|
+
saturate: l,
|
|
30
|
+
scale: n,
|
|
31
|
+
sepia: f,
|
|
32
|
+
style: g,
|
|
33
|
+
title: O
|
|
34
|
+
} = o, t = {};
|
|
35
|
+
n !== void 0 && (t.transform = `scale(${n})`), b && (t.transform = `scaleX(-${n !== void 0 ? n : 1})`), y && (t.transform = (t.transform ? t.transform + " " : "") + `scaleY(-${n !== void 0 ? n : 1})`), e && (t.transform = (t.transform ? t.transform + " " : "") + `rotate(${e}deg)`), $ && (t.opacity = $), v && (t.filter = `brightness(${v})`), m && (t.filter = (t.filter ? t.filter + " " : "") + `contrast(${m})`), l && (t.filter = (t.filter ? t.filter + " " : "") + `saturate(${l})`), c && (t.filter = (t.filter ? t.filter + " " : "") + `blur(${c}px)`), C && (t.filter = (t.filter ? t.filter + " " : "") + `grayscale(${C})`), f && (t.filter = (t.filter ? t.filter + " " : "") + `sepia(${f})`), p && r && (t.zIndex = `${r} !important`);
|
|
36
|
+
const S = N ? i || "https://picsum.photos/200/300" : i;
|
|
37
|
+
return /* @__PURE__ */ a(
|
|
38
|
+
"img",
|
|
39
|
+
{
|
|
40
|
+
ref: d,
|
|
41
|
+
className: `ar-Image
|
|
42
|
+
${h && !p ? " fill w-100 h-100" : ""}
|
|
43
|
+
${_ && !p ? " preserveAspectRatio" : ""}
|
|
44
|
+
${p ? " position-absolute top-0 start-0 h-100 w-100" : ""}
|
|
45
|
+
${s ? " " + s : ""}
|
|
46
|
+
`,
|
|
47
|
+
crossOrigin: D(S),
|
|
48
|
+
src: S,
|
|
49
|
+
alt: u || "ar-image-placeholder",
|
|
50
|
+
title: O,
|
|
51
|
+
style: { ...t, ...g || {} }
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
function k(o, d) {
|
|
57
|
+
const u = +o.value, c = +(o.min ? o.min : 0), v = +(o.max ? o.max : 100), s = Number((u - c) * 100 / (v - c));
|
|
58
|
+
d.innerHTML = "" + u;
|
|
59
|
+
const m = -(s / 100 * 16) + 8;
|
|
60
|
+
d.style.left = `calc(${s}% + ${m}px)`;
|
|
61
|
+
}
|
|
62
|
+
const T = (o) => {
|
|
63
|
+
const {
|
|
64
|
+
assistiveContent: d,
|
|
65
|
+
classes: u,
|
|
66
|
+
containerClasses: c,
|
|
67
|
+
focussed: v,
|
|
68
|
+
id: s,
|
|
69
|
+
label: m,
|
|
70
|
+
name: r,
|
|
71
|
+
size: N,
|
|
72
|
+
onBlur: h,
|
|
73
|
+
onChange: b,
|
|
74
|
+
onFocus: y,
|
|
75
|
+
precision: C,
|
|
76
|
+
type: i,
|
|
77
|
+
value: p,
|
|
78
|
+
withManual: $,
|
|
79
|
+
..._
|
|
80
|
+
} = o, e = w(null), l = w(null), [n, f] = R();
|
|
81
|
+
return B(() => {
|
|
82
|
+
e.current && l.current && k(e.current, l.current), e.current && e.current.addEventListener("input", () => {
|
|
83
|
+
e.current && l.current && k(e.current, l.current);
|
|
84
|
+
});
|
|
85
|
+
}, []), B(() => {
|
|
86
|
+
p !== n && f(p);
|
|
87
|
+
}, [p]), /* @__PURE__ */ a(
|
|
88
|
+
"div",
|
|
89
|
+
{
|
|
90
|
+
className: `ar-Slider w-100${c ? " " + c : ""}`,
|
|
91
|
+
children: /* @__PURE__ */ x("div", { className: "ar-Slider__control flex-v-center position-relative justify-content-between", children: [
|
|
92
|
+
m && /* @__PURE__ */ a("label", { className: "me-3", htmlFor: s, children: /* @__PURE__ */ a("strong", { children: m }) }),
|
|
93
|
+
/* @__PURE__ */ x("div", { className: "ar-Slider__slider-bar flex-center", children: [
|
|
94
|
+
/* @__PURE__ */ a("div", { className: "d-inline-block me-2", children: _.min }),
|
|
95
|
+
/* @__PURE__ */ x("div", { className: "position-relative", children: [
|
|
96
|
+
/* @__PURE__ */ a(
|
|
97
|
+
"input",
|
|
98
|
+
{
|
|
99
|
+
ref: e,
|
|
100
|
+
id: s,
|
|
101
|
+
name: r || s,
|
|
102
|
+
type: "range",
|
|
103
|
+
className: `ar-TextInput__input h-100 py-2${u ? " " + u : ""}`,
|
|
104
|
+
onChange: (g) => {
|
|
105
|
+
f(g.target.value), b && b(g);
|
|
106
|
+
},
|
|
107
|
+
onFocus: y,
|
|
108
|
+
onBlur: h,
|
|
109
|
+
value: n,
|
|
110
|
+
step: C,
|
|
111
|
+
..._
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
n && /* @__PURE__ */ a(
|
|
115
|
+
"output",
|
|
116
|
+
{
|
|
117
|
+
ref: l,
|
|
118
|
+
className: "ar-Slider__bubble position-absolute",
|
|
119
|
+
htmlFor: s
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
] }),
|
|
123
|
+
/* @__PURE__ */ a("div", { className: "d-inline-block ms-2", children: _.max }),
|
|
124
|
+
$ && /* @__PURE__ */ a(
|
|
125
|
+
"input",
|
|
126
|
+
{
|
|
127
|
+
className: "ar-Slider__manual-input",
|
|
128
|
+
type: "text",
|
|
129
|
+
value: n,
|
|
130
|
+
onChange: (g) => {
|
|
131
|
+
f(g.target.value), b && b(g);
|
|
132
|
+
},
|
|
133
|
+
title: "Maunal Value"
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
] })
|
|
137
|
+
] })
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
let E = {
|
|
142
|
+
rotateBy: 0,
|
|
143
|
+
brightness: 1,
|
|
144
|
+
contrast: 1,
|
|
145
|
+
saturate: 1,
|
|
146
|
+
grayscale: 0,
|
|
147
|
+
blur: 0,
|
|
148
|
+
sepia: 0,
|
|
149
|
+
opacity: 1,
|
|
150
|
+
scale: 1
|
|
151
|
+
};
|
|
152
|
+
const A = (o) => (o % 360 + 360) % 360, H = 22.5, Y = (o) => {
|
|
153
|
+
const { image: d, imageState: u, onChange: c, onCommit: v, viewOnly: s } = o;
|
|
154
|
+
E = {
|
|
155
|
+
...E,
|
|
156
|
+
...u
|
|
157
|
+
};
|
|
158
|
+
const m = w(null), [r, N] = R({ ...E }), [h, b] = R(), [y, C] = R(), i = (e, l) => {
|
|
159
|
+
const n = { ...r, [e]: l }, { rotateBy: f, ...g } = n, { rotateBy: O, ...t } = E;
|
|
160
|
+
f !== void 0 && O !== void 0 && C(
|
|
161
|
+
JSON.stringify(g) !== JSON.stringify(t) || A(f) !== A(O)
|
|
162
|
+
), N(n), c && c(n);
|
|
163
|
+
}, p = [
|
|
164
|
+
{
|
|
165
|
+
icon: "tb.TbFlipHorizontal",
|
|
166
|
+
handler: () => i("flipHorizontal", !r.flipHorizontal),
|
|
167
|
+
tooltip: "Flip Horizontal"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
icon: "tb.TbFlipVertical",
|
|
171
|
+
handler: () => i("flipVertical", !r.flipVertical),
|
|
172
|
+
tooltip: "Flip Vertical"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
icon: "ai.AiOutlineRotateLeft",
|
|
176
|
+
handler: () => i("rotateBy", r.rotateBy - H),
|
|
177
|
+
tooltip: "Rotate Left"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
icon: "ai.AiOutlineRotateRight",
|
|
181
|
+
handler: () => i("rotateBy", r.rotateBy + H),
|
|
182
|
+
tooltip: "Rotate Right"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
icon: "fi.FiZoomIn",
|
|
186
|
+
handler: () => i("scale", (r.scale + 1) % 10),
|
|
187
|
+
tooltip: "Zoom In"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
icon: "fi.FiZoomOut",
|
|
191
|
+
handler: () => i(
|
|
192
|
+
"scale",
|
|
193
|
+
(r.scale - 1 < 0 ? 0 : r.scale - 1) % 10
|
|
194
|
+
),
|
|
195
|
+
tooltip: "Zoom Out"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
icon: h ? "md.MdOutlineExpandLess" : "md.MdOutlineExpandMore",
|
|
199
|
+
handler: () => b(!h),
|
|
200
|
+
tooltip: h ? "Hide Advanced Controls" : "Show Advanced Controls"
|
|
201
|
+
}
|
|
202
|
+
], $ = [
|
|
203
|
+
{
|
|
204
|
+
icon: "fi.FiZoomIn",
|
|
205
|
+
handler: () => N({ ...r, scale: (r.scale + 1) % 10 }),
|
|
206
|
+
tooltip: "Zoom In"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
icon: "fi.FiZoomOut",
|
|
210
|
+
handler: () => N({
|
|
211
|
+
...r,
|
|
212
|
+
scale: (r.scale - 1 < 0 ? 0 : r.scale - 1) % 10
|
|
213
|
+
}),
|
|
214
|
+
tooltip: "Zoom Out"
|
|
215
|
+
}
|
|
216
|
+
], _ = [
|
|
217
|
+
[
|
|
218
|
+
{
|
|
219
|
+
label: "Brightness",
|
|
220
|
+
min: 0,
|
|
221
|
+
max: 5,
|
|
222
|
+
precision: 0.1,
|
|
223
|
+
handler: (e) => i("brightness", +e.target.value)
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
label: "Contrast",
|
|
227
|
+
min: 0,
|
|
228
|
+
max: 5,
|
|
229
|
+
precision: 0.1,
|
|
230
|
+
handler: (e) => i("contrast", +e.target.value)
|
|
231
|
+
}
|
|
232
|
+
],
|
|
233
|
+
[
|
|
234
|
+
{
|
|
235
|
+
label: "Saturation",
|
|
236
|
+
min: 0,
|
|
237
|
+
max: 10,
|
|
238
|
+
precision: 0.2,
|
|
239
|
+
handler: (e) => i("saturate", +e.target.value)
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
label: "Grayscale",
|
|
243
|
+
min: 0,
|
|
244
|
+
max: 1,
|
|
245
|
+
precision: 0.05,
|
|
246
|
+
handler: (e) => i("grayscale", +e.target.value)
|
|
247
|
+
}
|
|
248
|
+
],
|
|
249
|
+
[
|
|
250
|
+
{
|
|
251
|
+
label: "Blur",
|
|
252
|
+
min: 0,
|
|
253
|
+
max: 20,
|
|
254
|
+
handler: (e) => i("blur", +e.target.value)
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
label: "Sepia",
|
|
258
|
+
min: 0,
|
|
259
|
+
max: 1,
|
|
260
|
+
precision: 0.05,
|
|
261
|
+
handler: (e) => i("sepia", +e.target.value)
|
|
262
|
+
}
|
|
263
|
+
],
|
|
264
|
+
[
|
|
265
|
+
{
|
|
266
|
+
label: "Opacity",
|
|
267
|
+
min: 0,
|
|
268
|
+
max: 1,
|
|
269
|
+
precision: 0.05,
|
|
270
|
+
handler: (e) => i("opacity", +e.target.value)
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
label: "Scale",
|
|
274
|
+
min: 0,
|
|
275
|
+
max: 10,
|
|
276
|
+
precision: 0.2,
|
|
277
|
+
handler: (e) => i("scale", +e.target.value)
|
|
278
|
+
}
|
|
279
|
+
]
|
|
280
|
+
];
|
|
281
|
+
return /* @__PURE__ */ x("div", { className: "ar-ImageEditor d-flex flex-column h-100 overflow-auto flex-center position-relative", children: [
|
|
282
|
+
!s && /* @__PURE__ */ x("div", { className: "ar-ImageEditor__editor-controls position-absolute p-1 top-0 end-0 hover-shadow-dark", children: [
|
|
283
|
+
/* @__PURE__ */ x(z, { children: [
|
|
284
|
+
/* @__PURE__ */ a(
|
|
285
|
+
"span",
|
|
286
|
+
{
|
|
287
|
+
className: "ar-ImageEditor__download-button cursor-pointer border-radius-50 p-1 me-2",
|
|
288
|
+
slot: I.ANCHOR,
|
|
289
|
+
children: /* @__PURE__ */ a(
|
|
290
|
+
F,
|
|
291
|
+
{
|
|
292
|
+
icon: "md/MdDownload",
|
|
293
|
+
attributes: {
|
|
294
|
+
colors: { fillColor: "#232323cc" },
|
|
295
|
+
size: "1.5rem"
|
|
296
|
+
},
|
|
297
|
+
events: {
|
|
298
|
+
onClick: () => Z(m.current)
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
)
|
|
302
|
+
}
|
|
303
|
+
),
|
|
304
|
+
/* @__PURE__ */ a("span", { slot: I.POPOVER, children: "Download" })
|
|
305
|
+
] }),
|
|
306
|
+
/* @__PURE__ */ x(z, { children: [
|
|
307
|
+
/* @__PURE__ */ a(
|
|
308
|
+
"span",
|
|
309
|
+
{
|
|
310
|
+
className: `ar-ImageEditor__commit-button border-radius-50 p-1${y ? " cursor-pointer is-dirty" : ""}`,
|
|
311
|
+
slot: I.ANCHOR,
|
|
312
|
+
children: /* @__PURE__ */ a(
|
|
313
|
+
F,
|
|
314
|
+
{
|
|
315
|
+
icon: "io5.IoCheckmarkCircleSharp",
|
|
316
|
+
slot: I.ANCHOR,
|
|
317
|
+
attributes: {
|
|
318
|
+
colors: { fillColor: y ? "#008000" : "#00800077" },
|
|
319
|
+
size: "1.5rem"
|
|
320
|
+
},
|
|
321
|
+
events: {
|
|
322
|
+
onClick: () => y && v && v(r)
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
)
|
|
326
|
+
}
|
|
327
|
+
),
|
|
328
|
+
/* @__PURE__ */ a("span", { slot: I.POPOVER, children: y ? "Save" : "Edit image to save" })
|
|
329
|
+
] })
|
|
330
|
+
] }),
|
|
331
|
+
/* @__PURE__ */ a("div", { className: "ar-ImageEditor__image-container mb-4", children: /* @__PURE__ */ a(
|
|
332
|
+
P,
|
|
333
|
+
{
|
|
334
|
+
ref: m,
|
|
335
|
+
image: d,
|
|
336
|
+
fill: !0,
|
|
337
|
+
preserveAspectRatio: !0,
|
|
338
|
+
...r
|
|
339
|
+
}
|
|
340
|
+
) }),
|
|
341
|
+
/* @__PURE__ */ a("div", { className: "ar-ImageEditor__controls py-3 flex-center z-1 position-absolute", children: /* @__PURE__ */ x(
|
|
342
|
+
"div",
|
|
343
|
+
{
|
|
344
|
+
className: `ar-ImageEditor__controls-container border-radius prominent hover-shadow-dark${h ? " expanded" : ""}`,
|
|
345
|
+
children: [
|
|
346
|
+
/* @__PURE__ */ a(
|
|
347
|
+
"div",
|
|
348
|
+
{
|
|
349
|
+
className: `ar-ImageEditor__basic-controls px-3 py-2 ${h ? "border-bottom" : ""}`,
|
|
350
|
+
children: (s ? $ : p).map((e) => /* @__PURE__ */ a(V, { ...e }))
|
|
351
|
+
}
|
|
352
|
+
),
|
|
353
|
+
!s && /* @__PURE__ */ a("div", { className: "ar-ImageEditor__advanced-controls mt-2 px-3", children: _.map((e) => /* @__PURE__ */ a("div", { className: "row pb-3 border-bottom", children: e.map((l) => /* @__PURE__ */ a("div", { className: "col-6", children: /* @__PURE__ */ a(
|
|
354
|
+
T,
|
|
355
|
+
{
|
|
356
|
+
label: l.label,
|
|
357
|
+
min: l.min,
|
|
358
|
+
max: l.max,
|
|
359
|
+
onChange: l.handler,
|
|
360
|
+
precision: l.precision
|
|
361
|
+
}
|
|
362
|
+
) })) })) })
|
|
363
|
+
]
|
|
364
|
+
}
|
|
365
|
+
) })
|
|
366
|
+
] });
|
|
367
|
+
};
|
|
368
|
+
export {
|
|
369
|
+
Y as default
|
|
370
|
+
};
|
package/es/helper.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
import "react/jsx-runtime";
|
|
3
|
+
const d = window.getComputedStyle(document.documentElement);
|
|
4
|
+
parseFloat(d.fontSize);
|
|
5
|
+
function r(t, a) {
|
|
6
|
+
const e = document.createElement("a");
|
|
7
|
+
e.href = typeof t == "string" ? t : window.URL.createObjectURL(t), e.download = a || "edited-image.png", document.body.appendChild(e), e.click(), document.body.removeChild(e);
|
|
8
|
+
}
|
|
9
|
+
const f = (t) => {
|
|
10
|
+
if (t) {
|
|
11
|
+
const a = document.createElement("canvas");
|
|
12
|
+
a.width = t.naturalWidth, a.height = t.naturalHeight;
|
|
13
|
+
const e = a.getContext("2d");
|
|
14
|
+
if (!e)
|
|
15
|
+
return;
|
|
16
|
+
const s = t.style.filter, o = t.style.opacity, n = t.style.transform;
|
|
17
|
+
e.filter = s !== "" ? s : "", e.globalAlpha = o !== "" ? parseFloat(o) : 1, n && n !== "none" && i(e, n, a), e.drawImage(t, 0, 0), r(a.toDataURL());
|
|
18
|
+
}
|
|
19
|
+
}, i = (t, a, e) => {
|
|
20
|
+
const s = a.match(/rotate\((\d+(?:\.\d+)?)deg\)/);
|
|
21
|
+
if (s) {
|
|
22
|
+
const c = parseFloat(s[1]) * (Math.PI / 180);
|
|
23
|
+
t.translate(e.width / 2, e.height / 2), t.rotate(c), t.translate(-e.width / 2, -e.height / 2);
|
|
24
|
+
}
|
|
25
|
+
const o = a.match(
|
|
26
|
+
/scale\((\d+(?:\.\d+)?)(?:,\s*(\d+(?:\.\d+)?))?\)/
|
|
27
|
+
);
|
|
28
|
+
if (o) {
|
|
29
|
+
const l = parseFloat(o[1]), c = o[2] ? parseFloat(o[2]) : l;
|
|
30
|
+
t.scale(l, c);
|
|
31
|
+
}
|
|
32
|
+
const n = a.match(/translate\((\d+px)(?:,\s*(\d+px))?\)/);
|
|
33
|
+
if (n) {
|
|
34
|
+
const l = parseFloat(n[1]), c = n[2] ? parseFloat(n[2]) : 0;
|
|
35
|
+
t.translate(l, c);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
f as downloadEditedImage
|
|
40
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@armco/imageeditor",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "cjs/ImageEditor.js",
|
|
6
|
+
"module": "es/ImageEditor.js",
|
|
7
|
+
"types": "types/ImageEditor.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"*": "rm -rf build && tsc && vite build",
|
|
10
|
+
"test": "vitest",
|
|
11
|
+
"format": "prettier --write .",
|
|
12
|
+
"lint": "eslint .",
|
|
13
|
+
"publish:sh": "./publish.sh",
|
|
14
|
+
"publish:local": "./publish-local.sh"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@armco/icon": "^0.0.3",
|
|
18
|
+
"@armco/shared-components": "^0.0.50",
|
|
19
|
+
"@armco/utils": "^0.0.16",
|
|
20
|
+
"@types/node": "^22.5.5",
|
|
21
|
+
"react": ">16.8.0",
|
|
22
|
+
"react-dom": ">16.8.0",
|
|
23
|
+
"vite-plugin-dts": "^4.2.1"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@testing-library/dom": "^9.2.0",
|
|
27
|
+
"@testing-library/jest-dom": "^5.11.4",
|
|
28
|
+
"@testing-library/react": "^14.0.0",
|
|
29
|
+
"@testing-library/user-event": "^14.2.5",
|
|
30
|
+
"@types/react": "^18.0.15",
|
|
31
|
+
"@types/react-dom": "^18.0.6",
|
|
32
|
+
"@types/testing-library__jest-dom": "^5.14.5",
|
|
33
|
+
"@vitejs/plugin-react": "^4.3.1",
|
|
34
|
+
"eslint": "^8.0.0",
|
|
35
|
+
"eslint-config-react-app": "^7.0.1",
|
|
36
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
37
|
+
"jsdom": "^21.1.0",
|
|
38
|
+
"prettier": "^2.7.1",
|
|
39
|
+
"prettier-config-nick": "^1.0.2",
|
|
40
|
+
"sass": "^1.63.4",
|
|
41
|
+
"typescript": "^5.0.2",
|
|
42
|
+
"vite": "^4.0.0",
|
|
43
|
+
"vite-plugin-css-injected-by-js": "^3.5.1",
|
|
44
|
+
"vitest": "^0.30.1"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"react": ">16.8.0",
|
|
48
|
+
"react-dom": ">16.8.0"
|
|
49
|
+
},
|
|
50
|
+
"eslintConfig": {
|
|
51
|
+
"extends": [
|
|
52
|
+
"react-app",
|
|
53
|
+
"react-app/jest"
|
|
54
|
+
],
|
|
55
|
+
"plugins": [
|
|
56
|
+
"prettier"
|
|
57
|
+
],
|
|
58
|
+
"rules": {
|
|
59
|
+
"prettier/prettier": "error",
|
|
60
|
+
"react/jsx-no-target-blank": "off"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"prettier": "prettier-config-nick",
|
|
64
|
+
"repository": {
|
|
65
|
+
"type": "git",
|
|
66
|
+
"url": "git+https://github.com/ReStruct-Corporate-Advantage/imageeditor.git"
|
|
67
|
+
},
|
|
68
|
+
"keywords": [
|
|
69
|
+
"components",
|
|
70
|
+
"atomic",
|
|
71
|
+
"building-blocks",
|
|
72
|
+
"foundation"
|
|
73
|
+
],
|
|
74
|
+
"license": "ISC",
|
|
75
|
+
"bugs": {
|
|
76
|
+
"url": "https://github.com/ReStruct-Corporate-Advantage/imageeditor/issues"
|
|
77
|
+
},
|
|
78
|
+
"homepage": "https://github.com/ReStruct-Corporate-Advantage/imageeditor#readme"
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const downloadEditedImage: (image: HTMLImageElement | null) => void;
|