@armco/imageeditor 0.0.3 → 0.0.5
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 +1 -1
- package/cjs/Control.js +1 -1
- package/cjs/ImageEditor.js +2 -7
- package/cjs/helper.js +1 -1
- package/es/Control-chunk.js +16 -325
- package/es/Control.js +3 -4
- package/es/ImageEditor.js +82 -213
- package/es/helper.js +22 -29
- package/package.json +7 -6
package/cjs/Control-chunk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const s=require("react/jsx-runtime"),t=require("@armco/shared-components/Tooltip"),c=require("@armco/icon");var o=(r=>(r.POPOVER="popover",r.ANCHOR="anchor",r))(o||{});const i=({icon:r,handler:e,tooltip:n})=>s.jsxs(t,{children:[s.jsx("span",{className:"mx-3 p-1 cursor-pointer",slot:o.ANCHOR,children:s.jsx(c,{icon:r,attributes:{colors:{fillColor:"#ffffff99"},classes:"cursor-pointer",size:"2rem"},events:{onClick:e}})}),s.jsx("span",{slot:o.POPOVER,children:n})]});exports.Control=i;exports.L=o;
|
package/cjs/Control.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("react/jsx-runtime");const r=require("./Control-chunk.js");require("@armco/
|
|
1
|
+
"use strict";require("react/jsx-runtime");const r=require("./Control-chunk.js");require("@armco/shared-components/Tooltip");require("@armco/icon");module.exports=r.Control;
|
package/cjs/ImageEditor.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode(
|
|
2
|
-
"use strict";const t=require("react/jsx-runtime"),
|
|
3
|
-
${f&&!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:L(E),src:E,alt:h||"ar-image-placeholder",title:R,style:{...a,...v||{}}})});function S(s,d){const h=+s.value,c=+(s.min?s.min:0),g=+(s.max?s.max:100),n=Number((h-c)*100/(g-c));d.innerHTML=""+h;const m=-(n/100*16)+8;d.style.left=`calc(${n}% + ${m}px)`}const A=s=>{const{assistiveContent:d,classes:h,containerClasses:c,focussed:g,id:n,label:m,name:r,size:N,onBlur:f,onChange:b,onFocus:y,precision:C,type:i,value:u,withManual:I,..._}=s,e=p.useRef(null),o=p.useRef(null),[l,x]=p.useState();return p.useEffect(()=>{e.current&&o.current&&S(e.current,o.current),e.current&&e.current.addEventListener("input",()=>{e.current&&o.current&&S(e.current,o.current)})},[]),p.useEffect(()=>{u!==l&&x(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${h?" "+h:""}`,onChange:v=>{x(v.target.value),b&&b(v)},onFocus:y,onBlur:f,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}),I&&t.jsx("input",{className:"ar-Slider__manual-input",type:"text",value:l,onChange:v=>{x(v.target.value),b&&b(v)},title:"Maunal Value"})]})]})})};let $={rotateBy:0,brightness:1,contrast:1,saturate:1,grayscale:0,blur:0,sepia:0,opacity:1,scale:1};const w=s=>(s%360+360)%360,B=22.5,H=s=>{const{image:d,imageState:h,onChange:c,onCommit:g,viewOnly:n}=s;$={...$,...h};const m=p.useRef(null),[r,N]=p.useState({...$}),[f,b]=p.useState(),[y,C]=p.useState(),i=(e,o)=>{const l={...r,[e]:o},{rotateBy:x,...v}=l,{rotateBy:R,...a}=$;x!==void 0&&R!==void 0&&C(JSON.stringify(v)!==JSON.stringify(a)||w(x)!==w(R)),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-B),tooltip:"Rotate Left"},{icon:"ai.AiOutlineRotateRight",handler:()=>i("rotateBy",r.rotateBy+B),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:f?"md.MdOutlineExpandLess":"md.MdOutlineExpandMore",handler:()=>b(!f),tooltip:f?"Hide Advanced Controls":"Show Advanced Controls"}],I=[{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(j.v,{children:[t.jsx("span",{className:"ar-ImageEditor__download-button cursor-pointer border-radius-50 p-1 me-2",slot:j.L.ANCHOR,children:t.jsx(O,{icon:"md/MdDownload",attributes:{colors:{fillColor:"#232323cc"},size:"1.5rem"},events:{onClick:()=>z.downloadEditedImage(m.current)}})}),t.jsx("span",{slot:j.L.POPOVER,children:"Download"})]}),t.jsxs(j.v,{children:[t.jsx("span",{className:`ar-ImageEditor__commit-button border-radius-50 p-1${y?" cursor-pointer is-dirty":""}`,slot:j.L.ANCHOR,children:t.jsx(O,{icon:"io5.IoCheckmarkCircleSharp",slot:j.L.ANCHOR,attributes:{colors:{fillColor:y?"#008000":"#00800077"},size:"1.5rem"},events:{onClick:()=>y&&g&&g(r)}})}),t.jsx("span",{slot:j.L.POPOVER,children:y?"Save":"Edit image to save"})]})]}),t.jsx("div",{className:"ar-ImageEditor__image-container mb-4",children:t.jsx(k,{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${f?" expanded":""}`,children:[t.jsx("div",{className:`ar-ImageEditor__basic-controls px-3 py-2 ${f?"border-bottom":""}`,children:(n?I:u).map(e=>t.jsx(j.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(A,{label:o.label,min:o.min,max:o.max,onChange:o.handler,precision:o.precision})}))}))})]})})]})};module.exports=H;
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode(".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}")),document.head.appendChild(r)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
2
|
+
"use strict";const t=require("react/jsx-runtime"),s=require("react"),r=require("./Control-chunk.js"),f=require("@armco/icon"),q=require("@armco/shared-components/Image"),y=require("@armco/shared-components/Tooltip"),z=require("@armco/shared-components/Slider"),A=require("./helper.js");require("@armco/utils/domHelper");let c={rotateBy:0,brightness:1,contrast:1,saturate:1,grayscale:0,blur:0,sepia:0,opacity:1,scale:1};const C=d=>(d%360+360)%360,j=22.5,F=d=>{const{image:O,imageState:E,onChange:h,onCommit:x,viewOnly:m}=d;c={...c,...E};const g=s.useRef(null),[o,p]=s.useState({...c}),[n,I]=s.useState(),[l,R]=s.useState(),a=(e,i)=>{const u={...o,[e]:i},{rotateBy:b,...w}=u,{rotateBy:v,...B}=c;b!==void 0&&v!==void 0&&R(JSON.stringify(w)!==JSON.stringify(B)||C(b)!==C(v)),p(u),h&&h(u)},_=[{icon:"tb.TbFlipHorizontal",handler:()=>a("flipHorizontal",!o.flipHorizontal),tooltip:"Flip Horizontal"},{icon:"tb.TbFlipVertical",handler:()=>a("flipVertical",!o.flipVertical),tooltip:"Flip Vertical"},{icon:"ai.AiOutlineRotateLeft",handler:()=>a("rotateBy",o.rotateBy-j),tooltip:"Rotate Left"},{icon:"ai.AiOutlineRotateRight",handler:()=>a("rotateBy",o.rotateBy+j),tooltip:"Rotate Right"},{icon:"fi.FiZoomIn",handler:()=>a("scale",(o.scale+1)%10),tooltip:"Zoom In"},{icon:"fi.FiZoomOut",handler:()=>a("scale",(o.scale-1<0?0:o.scale-1)%10),tooltip:"Zoom Out"},{icon:n?"md.MdOutlineExpandLess":"md.MdOutlineExpandMore",handler:()=>I(!n),tooltip:n?"Hide Advanced Controls":"Show Advanced Controls"}],N=[{icon:"fi.FiZoomIn",handler:()=>p({...o,scale:(o.scale+1)%10}),tooltip:"Zoom In"},{icon:"fi.FiZoomOut",handler:()=>p({...o,scale:(o.scale-1<0?0:o.scale-1)%10}),tooltip:"Zoom Out"}],S=[[{label:"Brightness",min:0,max:5,precision:.1,handler:e=>a("brightness",+e.target.value)},{label:"Contrast",min:0,max:5,precision:.1,handler:e=>a("contrast",+e.target.value)}],[{label:"Saturation",min:0,max:10,precision:.2,handler:e=>a("saturate",+e.target.value)},{label:"Grayscale",min:0,max:1,precision:.05,handler:e=>a("grayscale",+e.target.value)}],[{label:"Blur",min:0,max:20,handler:e=>a("blur",+e.target.value)},{label:"Sepia",min:0,max:1,precision:.05,handler:e=>a("sepia",+e.target.value)}],[{label:"Opacity",min:0,max:1,precision:.05,handler:e=>a("opacity",+e.target.value)},{label:"Scale",min:0,max:10,precision:.2,handler:e=>a("scale",+e.target.value)}]];return t.jsxs("div",{className:"ar-ImageEditor d-flex flex-column h-100 overflow-auto flex-center position-relative",children:[!m&&t.jsxs("div",{className:"ar-ImageEditor__editor-controls position-absolute p-1 top-0 end-0 hover-shadow-dark",children:[t.jsxs(y,{children:[t.jsx("span",{className:"ar-ImageEditor__download-button cursor-pointer border-radius-50 p-1 me-2",slot:r.L.ANCHOR,children:t.jsx(f,{icon:"md/MdDownload",attributes:{colors:{fillColor:"#232323cc"},size:"1.5rem"},events:{onClick:()=>A.downloadEditedImage(g.current)}})}),t.jsx("span",{slot:r.L.POPOVER,children:"Download"})]}),t.jsxs(y,{children:[t.jsx("span",{className:`ar-ImageEditor__commit-button border-radius-50 p-1${l?" cursor-pointer is-dirty":""}`,slot:r.L.ANCHOR,children:t.jsx(f,{icon:"io5.IoCheckmarkCircleSharp",slot:r.L.ANCHOR,attributes:{colors:{fillColor:l?"#008000":"#00800077"},size:"1.5rem"},events:{onClick:()=>l&&x&&x(o)}})}),t.jsx("span",{slot:r.L.POPOVER,children:l?"Save":"Edit image to save"})]})]}),t.jsx("div",{className:"ar-ImageEditor__image-container mb-4",children:t.jsx(q,{ref:g,image:O,fill:!0,preserveAspectRatio:!0,...o})}),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${n?" expanded":""}`,children:[t.jsx("div",{className:`ar-ImageEditor__basic-controls px-3 py-2 ${n?"border-bottom":""}`,children:(m?N:_).map(e=>t.jsx(r.Control,{...e}))}),!m&&t.jsx("div",{className:"ar-ImageEditor__advanced-controls mt-2 px-3",children:S.map(e=>t.jsx("div",{className:"row pb-3 border-bottom",children:e.map(i=>t.jsx("div",{className:"col-6",children:t.jsx(z,{label:i.label,min:i.min,max:i.max,onChange:i.handler,precision:i.precision})}))}))})]})})]})};module.exports=F;
|
package/cjs/helper.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@armco/utils/domHelper"),d=t=>{if(t){const e=document.createElement("canvas");e.width=t.naturalWidth,e.height=t.naturalHeight;const a=e.getContext("2d");if(!a)return;const n=t.style.filter,s=t.style.opacity,o=t.style.transform;a.filter=n!==""?n:"",a.globalAlpha=s!==""?parseFloat(s):1,o&&o!=="none"&&i(a,o,e),a.drawImage(t,0,0),c.download(e.toDataURL())}},i=(t,e,a)=>{const n=e.match(/rotate\((\d+(?:\.\d+)?)deg\)/);if(n){const r=parseFloat(n[1])*(Math.PI/180);t.translate(a.width/2,a.height/2),t.rotate(r),t.translate(-a.width/2,-a.height/2)}const s=e.match(/scale\((\d+(?:\.\d+)?)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(s){const l=parseFloat(s[1]),r=s[2]?parseFloat(s[2]):l;t.scale(l,r)}const o=e.match(/translate\((\d+px)(?:,\s*(\d+px))?\)/);if(o){const l=parseFloat(o[1]),r=o[2]?parseFloat(o[2]):0;t.translate(l,r)}};exports.downloadEditedImage=d;
|
package/es/Control-chunk.js
CHANGED
|
@@ -1,336 +1,27 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
return document;
|
|
14
|
-
}
|
|
15
|
-
function Z(t) {
|
|
16
|
-
if (t) {
|
|
17
|
-
const e = document.querySelector(".ar-Editor__frame");
|
|
18
|
-
if (e)
|
|
19
|
-
return e.contentWindow;
|
|
20
|
-
}
|
|
21
|
-
return window;
|
|
22
|
-
}
|
|
23
|
-
function gt(t, e, o, l) {
|
|
24
|
-
const n = Z(l) || window;
|
|
25
|
-
if ({
|
|
26
|
-
bottom: e.top + e.height + o.height > n.innerHeight,
|
|
27
|
-
right: e.left + e.width + o.width > n.innerWidth,
|
|
28
|
-
left: e.left - o.width < 0,
|
|
29
|
-
top: e.top - o.height < 0
|
|
30
|
-
}[t])
|
|
31
|
-
return !1;
|
|
32
|
-
if (t === "left" || t === "right") {
|
|
33
|
-
if (w > e.top || w > e.bottom)
|
|
34
|
-
return !1;
|
|
35
|
-
} else if (w > e.left || w > e.right)
|
|
36
|
-
return !1;
|
|
37
|
-
return t;
|
|
38
|
-
}
|
|
39
|
-
function Et(t, e, o, l, n) {
|
|
40
|
-
const c = {
|
|
41
|
-
[d.BOTTOM]: {
|
|
42
|
-
top: e.top + e.height + (l ? 0 : A) + (n || 0),
|
|
43
|
-
left: e.left + (e.width - o.width) / 2
|
|
44
|
-
},
|
|
45
|
-
[d.RIGHT]: {
|
|
46
|
-
top: e.top + (e.height - o.height) / 2,
|
|
47
|
-
left: e.left + e.width + (l ? 0 : A)
|
|
48
|
-
},
|
|
49
|
-
[d.LEFT]: {
|
|
50
|
-
top: e.top + (e.height - o.height) / 2,
|
|
51
|
-
left: e.left - o.width - (l ? 0 : A)
|
|
52
|
-
},
|
|
53
|
-
[d.TOP]: {
|
|
54
|
-
top: e.top - o.height - (l ? 0 : A) - (n || 0),
|
|
55
|
-
left: e.left + (e.width - o.width) / 2
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
let { left: r, top: h } = c[t];
|
|
59
|
-
return t === d.BOTTOM || t === d.TOP ? (r < 0 && (r = w), r + o.width > window.innerWidth && (r = `calc(100% - ${o.width}px - ${w}px)`)) : (h < 0 && (h = w), h + o.height > window.innerHeight && (h = `calc(100% - ${o.height}px - ${w}px)`)), { left: r, top: h };
|
|
60
|
-
}
|
|
61
|
-
function wt(t, e, o, l) {
|
|
62
|
-
if (o && o !== d.AUTO)
|
|
63
|
-
return o;
|
|
64
|
-
const n = [
|
|
65
|
-
d.BOTTOM,
|
|
66
|
-
d.RIGHT,
|
|
67
|
-
d.LEFT,
|
|
68
|
-
d.TOP
|
|
69
|
-
];
|
|
70
|
-
for (const c of n)
|
|
71
|
-
if (gt(c, t, e, l))
|
|
72
|
-
return c;
|
|
73
|
-
return d.BOTTOM;
|
|
74
|
-
}
|
|
75
|
-
function Rt(t, e, o, l, n, c, r) {
|
|
76
|
-
const h = Z(c) || window;
|
|
77
|
-
t = n ? {
|
|
78
|
-
left: n[0],
|
|
79
|
-
x: n[0],
|
|
80
|
-
top: n[1],
|
|
81
|
-
y: n[1],
|
|
82
|
-
height: 0,
|
|
83
|
-
width: 0,
|
|
84
|
-
right: h.screen.width - n[0],
|
|
85
|
-
bottom: h.screen.height - n[1],
|
|
86
|
-
toJSON: () => {
|
|
87
|
-
}
|
|
88
|
-
} : t;
|
|
89
|
-
const a = wt(
|
|
90
|
-
t,
|
|
91
|
-
e,
|
|
92
|
-
o,
|
|
93
|
-
c
|
|
94
|
-
), { left: f, top: m } = Et(
|
|
95
|
-
a,
|
|
96
|
-
t,
|
|
97
|
-
e,
|
|
98
|
-
l,
|
|
99
|
-
r
|
|
100
|
-
);
|
|
101
|
-
return {
|
|
102
|
-
leftTop: {
|
|
103
|
-
top: ("" + m).startsWith("calc") ? m : m + "px",
|
|
104
|
-
left: ("" + f).startsWith("calc") ? f : f + "px"
|
|
105
|
-
},
|
|
106
|
-
position: a
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
const Ct = (t) => {
|
|
110
|
-
const { children: e, classes: o, container: l, demo: n, styles: c } = t, [r, h] = v();
|
|
111
|
-
return L(() => (h(l || document.createElement("div")), () => h(null)), [l]), L(() => {
|
|
112
|
-
if (r) {
|
|
113
|
-
const a = Ot(n);
|
|
114
|
-
if (a) {
|
|
115
|
-
const f = a.getElementById("root");
|
|
116
|
-
f && f.appendChild(r);
|
|
117
|
-
}
|
|
118
|
-
return () => {
|
|
119
|
-
if (a) {
|
|
120
|
-
const f = a.getElementById("root");
|
|
121
|
-
f && f.removeChild(r);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
}, [r, n]), L(() => {
|
|
126
|
-
r && (o && (r.className = o), r.classList.contains("ar-Portal") || r.classList.add("ar-Portal"), c && Object.assign(r.style, c));
|
|
127
|
-
}, [o, c, r]), r ? ft.createPortal(e, r) : null;
|
|
128
|
-
};
|
|
129
|
-
let Pt = !1;
|
|
130
|
-
const vt = {
|
|
131
|
-
left: "right",
|
|
132
|
-
right: "left",
|
|
133
|
-
top: "bottom",
|
|
134
|
-
bottom: "top"
|
|
135
|
-
}, Lt = {
|
|
136
|
-
left: "135",
|
|
137
|
-
right: "-45",
|
|
138
|
-
top: "-135",
|
|
139
|
-
bottom: "45"
|
|
140
|
-
}, Ht = (t) => {
|
|
141
|
-
const {
|
|
142
|
-
classes: e,
|
|
143
|
-
children: o,
|
|
144
|
-
closeOnSelfClick: l,
|
|
145
|
-
contentClasses: n,
|
|
146
|
-
contentMatchAnchorWidth: c,
|
|
147
|
-
demo: r,
|
|
148
|
-
disabled: h,
|
|
149
|
-
hideMarker: a,
|
|
150
|
-
invertBg: f,
|
|
151
|
-
isOpen: m,
|
|
152
|
-
isRaw: tt,
|
|
153
|
-
onAnchorClick: _,
|
|
154
|
-
onClose: R,
|
|
155
|
-
popAtPointer: K,
|
|
156
|
-
position: y = Q.AUTO,
|
|
157
|
-
preserveMarkerSpace: V,
|
|
158
|
-
stretch: et,
|
|
159
|
-
topOffset: W,
|
|
160
|
-
trigger: C = E.CLICK,
|
|
161
|
-
animation: $,
|
|
162
|
-
updateTriggers: ot,
|
|
163
|
-
wrapText: rt,
|
|
164
|
-
...nt
|
|
165
|
-
} = t, u = dt(
|
|
166
|
-
() => $ && !Array.isArray($) ? [$] : $,
|
|
167
|
-
[$]
|
|
168
|
-
), I = x(null), O = x(null), [g, M] = v(), [it, lt] = v(), [P, ct] = v(), [U, X] = v(), [b, k] = v(), F = x(), q = x(0), j = ut(() => {
|
|
169
|
-
if (!I.current || !O.current)
|
|
170
|
-
return;
|
|
171
|
-
const i = I.current.getBoundingClientRect();
|
|
172
|
-
c && (O.current.style.width = i.width + "px");
|
|
173
|
-
const s = O.current.getBoundingClientRect();
|
|
174
|
-
u && u.length > 0 && u.indexOf(B.EXPANDSHRINK) > -1 && (s.width = Math.floor(s.width * 1.25), s.height = Math.floor(s.height * 1.25));
|
|
175
|
-
const { leftTop: T, position: p } = Rt(
|
|
176
|
-
i,
|
|
177
|
-
s,
|
|
178
|
-
y,
|
|
179
|
-
a && !V,
|
|
180
|
-
K && C === E.CLICK ? F.current : null,
|
|
181
|
-
r,
|
|
182
|
-
W
|
|
183
|
-
);
|
|
184
|
-
lt(T), ct(p);
|
|
185
|
-
}, [
|
|
186
|
-
c,
|
|
187
|
-
r,
|
|
188
|
-
a,
|
|
189
|
-
K,
|
|
190
|
-
y,
|
|
191
|
-
V,
|
|
192
|
-
W,
|
|
193
|
-
C,
|
|
194
|
-
u
|
|
195
|
-
]);
|
|
196
|
-
let S, z;
|
|
197
|
-
return Tt.forEach(o, (i) => {
|
|
198
|
-
var s, T;
|
|
199
|
-
((s = i == null ? void 0 : i.props) == null ? void 0 : s.slot) === D.ANCHOR && (z = i), ((T = i == null ? void 0 : i.props) == null ? void 0 : T.slot) === D.POPOVER && (S = i);
|
|
200
|
-
}), L(() => {
|
|
201
|
-
m !== void 0 && (M(m), m && !b && k(!0));
|
|
202
|
-
}, [m, b]), L(() => {
|
|
203
|
-
var i;
|
|
204
|
-
let s = (T) => {
|
|
205
|
-
I.current && !I.current.contains(T.target) && O.current && !O.current.contains(T.target) && (M(!1), R && R());
|
|
206
|
-
};
|
|
207
|
-
if (C === E.CLICK && g) {
|
|
208
|
-
document.addEventListener("mousedown", s);
|
|
209
|
-
const T = document.querySelector("iframe");
|
|
210
|
-
return T && ((i = T.contentWindow) == null || i.document.addEventListener("mousedown", s)), () => {
|
|
211
|
-
var p;
|
|
212
|
-
document.removeEventListener("click", s);
|
|
213
|
-
const N = document.querySelector("iframe");
|
|
214
|
-
N && ((p = N.contentWindow) == null || p.document.removeEventListener("click", s));
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
}, [C, g, R]), L(() => {
|
|
218
|
-
b && g && (j(), X(!0));
|
|
219
|
-
}, [
|
|
220
|
-
g,
|
|
221
|
-
b,
|
|
222
|
-
j,
|
|
223
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
224
|
-
...ot || []
|
|
225
|
-
]), L(() => {
|
|
226
|
-
if (!a && O.current && U && P) {
|
|
227
|
-
const i = O.current, s = I.current.getBoundingClientRect(), T = vt[P], p = i.getBoundingClientRect();
|
|
228
|
-
u && u.length > 0 && u.indexOf(B.EXPANDSHRINK) > -1 && (p.width = Math.floor(p.width * 1.25), p.height = Math.floor(p.height * 1.25));
|
|
229
|
-
const N = P === "top" || P === "bottom";
|
|
230
|
-
let J = s[N ? "width" : "height"] / 2 - 7;
|
|
231
|
-
const st = s.left - p.left + J, ht = s.top - p.top + J;
|
|
232
|
-
i.style.setProperty(
|
|
233
|
-
"--marker-transform",
|
|
234
|
-
`rotate(${Lt[P]}deg)`
|
|
235
|
-
), i.style.setProperty(
|
|
236
|
-
`--marker-${T}`,
|
|
237
|
-
"-0.35rem"
|
|
238
|
-
), i.style.setProperty(
|
|
239
|
-
`--marker-${P}`,
|
|
240
|
-
"initial"
|
|
241
|
-
), i.style.setProperty(
|
|
242
|
-
`--marker-${N ? "left" : "top"}`,
|
|
243
|
-
(N ? st : ht) + "px"
|
|
244
|
-
), X(!1);
|
|
245
|
-
}
|
|
246
|
-
}, [
|
|
247
|
-
U,
|
|
248
|
-
O,
|
|
249
|
-
a,
|
|
250
|
-
P,
|
|
251
|
-
F,
|
|
252
|
-
u
|
|
253
|
-
]), /* @__PURE__ */ Y(at, { children: [
|
|
254
|
-
/* @__PURE__ */ H(
|
|
255
|
-
"span",
|
|
256
|
-
{
|
|
257
|
-
className: `ar-Popover__anchor${e ? " " + e : ""}${et ? " w-100" : ""}`,
|
|
258
|
-
onMouseDown: (i) => {
|
|
259
|
-
F.current = [i.clientX, i.clientY], Date.now() - q.current < 500 || (q.current = Date.now(), C === E.CLICK && !Pt && !h && (!b && k(!0), (m === void 0 || m) && setTimeout(() => M(!g), 0)), g && R && R(), _ && _(!g));
|
|
260
|
-
},
|
|
261
|
-
ref: I,
|
|
262
|
-
onMouseEnter: () => {
|
|
263
|
-
C === E.HOVER && !h && (k(!0), setTimeout(() => M(!0), 0));
|
|
264
|
-
},
|
|
265
|
-
onMouseLeave: () => {
|
|
266
|
-
C === E.HOVER && !h && (setTimeout(() => M(!1), 0), R && R());
|
|
267
|
-
},
|
|
268
|
-
...nt,
|
|
269
|
-
children: z
|
|
270
|
-
}
|
|
271
|
-
),
|
|
272
|
-
S && b && /* @__PURE__ */ H(
|
|
273
|
-
Ct,
|
|
274
|
-
{
|
|
275
|
-
classes: `position-fixed popover-container${g ? " z-3000" : " invisible"}`,
|
|
276
|
-
demo: r,
|
|
277
|
-
styles: it || {},
|
|
278
|
-
children: /* @__PURE__ */ H(
|
|
279
|
-
"div",
|
|
280
|
-
{
|
|
281
|
-
className: `ar-Popover__content${f ? " invert-bg" : ""}${rt ? " wrap" : ""}${y ? " " + y : ""} ${n}${u && u.length > 0 ? " transition " + (u == null ? void 0 : u.join(" ")) : ""} ${g ? " show" : ""}${a ? " hide-marker" : ""}${tt ? "" : " p-1 border-radius l2 f25"}`,
|
|
282
|
-
onClick: () => l && M(!1),
|
|
283
|
-
ref: O,
|
|
284
|
-
children: S
|
|
285
|
-
}
|
|
286
|
-
)
|
|
287
|
-
}
|
|
288
|
-
)
|
|
289
|
-
] });
|
|
290
|
-
}, It = (t) => {
|
|
291
|
-
const { children: e, demo: o, ...l } = t, [n, c] = v();
|
|
292
|
-
return /* @__PURE__ */ H(
|
|
293
|
-
Ht,
|
|
294
|
-
{
|
|
295
|
-
contentClasses: "overflow-auto",
|
|
296
|
-
trigger: E.HOVER,
|
|
297
|
-
onAnchorClick: () => {
|
|
298
|
-
c(!1), setTimeout(() => c(void 0), 10);
|
|
299
|
-
},
|
|
300
|
-
animation: [
|
|
301
|
-
B.EXPANDSHRINK,
|
|
302
|
-
B.FADEINOUT
|
|
303
|
-
],
|
|
304
|
-
demo: o,
|
|
305
|
-
isOpen: n,
|
|
306
|
-
hideMarker: !0,
|
|
307
|
-
preserveMarkerSpace: !0,
|
|
308
|
-
wrapText: !0,
|
|
309
|
-
...l,
|
|
310
|
-
children: e
|
|
311
|
-
}
|
|
312
|
-
);
|
|
313
|
-
}, Bt = ({
|
|
314
|
-
icon: t,
|
|
315
|
-
handler: e,
|
|
316
|
-
tooltip: o
|
|
317
|
-
}) => /* @__PURE__ */ Y(It, { children: [
|
|
318
|
-
/* @__PURE__ */ H("span", { className: "mx-3 p-1 cursor-pointer", slot: G.ANCHOR, children: /* @__PURE__ */ H(
|
|
319
|
-
pt,
|
|
1
|
+
import { jsxs as l, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import n from "@armco/shared-components/Tooltip";
|
|
3
|
+
import i from "@armco/icon";
|
|
4
|
+
var s = /* @__PURE__ */ ((o) => (o.POPOVER = "popover", o.ANCHOR = "anchor", o))(s || {});
|
|
5
|
+
const a = ({
|
|
6
|
+
icon: o,
|
|
7
|
+
handler: t,
|
|
8
|
+
tooltip: e
|
|
9
|
+
}) => /* @__PURE__ */ l(n, { children: [
|
|
10
|
+
/* @__PURE__ */ r("span", { className: "mx-3 p-1 cursor-pointer", slot: s.ANCHOR, children: /* @__PURE__ */ r(
|
|
11
|
+
i,
|
|
320
12
|
{
|
|
321
|
-
icon:
|
|
13
|
+
icon: o,
|
|
322
14
|
attributes: {
|
|
323
15
|
colors: { fillColor: "#ffffff99" },
|
|
324
16
|
classes: "cursor-pointer",
|
|
325
17
|
size: "2rem"
|
|
326
18
|
},
|
|
327
|
-
events: { onClick:
|
|
19
|
+
events: { onClick: t }
|
|
328
20
|
}
|
|
329
21
|
) }),
|
|
330
|
-
/* @__PURE__ */
|
|
22
|
+
/* @__PURE__ */ r("span", { slot: s.POPOVER, children: e })
|
|
331
23
|
] });
|
|
332
24
|
export {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
It as v
|
|
25
|
+
a as C,
|
|
26
|
+
s as L
|
|
336
27
|
};
|
package/es/Control.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
|
-
import { C as
|
|
2
|
+
import { C as i } from "./Control-chunk.js";
|
|
3
|
+
import "@armco/shared-components/Tooltip";
|
|
3
4
|
import "@armco/icon";
|
|
4
|
-
import "react";
|
|
5
|
-
import "react-dom";
|
|
6
5
|
export {
|
|
7
|
-
|
|
6
|
+
i as default
|
|
8
7
|
};
|
package/es/ImageEditor.js
CHANGED
|
@@ -1,145 +1,14 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode(
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import "
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
(i, d) => {
|
|
13
|
-
const {
|
|
14
|
-
alt: u,
|
|
15
|
-
blur: c,
|
|
16
|
-
brightness: v,
|
|
17
|
-
classes: s,
|
|
18
|
-
contrast: m,
|
|
19
|
-
customBgZIndex: r,
|
|
20
|
-
demo: N,
|
|
21
|
-
fill: h,
|
|
22
|
-
flipHorizontal: b,
|
|
23
|
-
flipVertical: y,
|
|
24
|
-
grayscale: C,
|
|
25
|
-
image: o,
|
|
26
|
-
isBackground: p,
|
|
27
|
-
opacity: $,
|
|
28
|
-
preserveAspectRatio: _,
|
|
29
|
-
rotateBy: e,
|
|
30
|
-
saturate: l,
|
|
31
|
-
scale: n,
|
|
32
|
-
sepia: f,
|
|
33
|
-
style: g,
|
|
34
|
-
title: O
|
|
35
|
-
} = i, t = {};
|
|
36
|
-
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`);
|
|
37
|
-
const S = N ? o || "https://picsum.photos/200/300" : o;
|
|
38
|
-
return /* @__PURE__ */ a(
|
|
39
|
-
"img",
|
|
40
|
-
{
|
|
41
|
-
ref: d,
|
|
42
|
-
className: `ar-Image
|
|
43
|
-
${h && !p ? " fill w-100 h-100" : ""}
|
|
44
|
-
${_ && !p ? " preserveAspectRatio" : ""}
|
|
45
|
-
${p ? " position-absolute top-0 start-0 h-100 w-100" : ""}
|
|
46
|
-
${s ? " " + s : ""}
|
|
47
|
-
`,
|
|
48
|
-
crossOrigin: D(S),
|
|
49
|
-
src: S,
|
|
50
|
-
alt: u || "ar-image-placeholder",
|
|
51
|
-
title: O,
|
|
52
|
-
style: { ...t, ...g || {} }
|
|
53
|
-
}
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
function k(i, d) {
|
|
58
|
-
const u = +i.value, c = +(i.min ? i.min : 0), v = +(i.max ? i.max : 100), s = Number((u - c) * 100 / (v - c));
|
|
59
|
-
d.innerHTML = "" + u;
|
|
60
|
-
const m = -(s / 100 * 16) + 8;
|
|
61
|
-
d.style.left = `calc(${s}% + ${m}px)`;
|
|
62
|
-
}
|
|
63
|
-
const T = (i) => {
|
|
64
|
-
const {
|
|
65
|
-
assistiveContent: d,
|
|
66
|
-
classes: u,
|
|
67
|
-
containerClasses: c,
|
|
68
|
-
focussed: v,
|
|
69
|
-
id: s,
|
|
70
|
-
label: m,
|
|
71
|
-
name: r,
|
|
72
|
-
size: N,
|
|
73
|
-
onBlur: h,
|
|
74
|
-
onChange: b,
|
|
75
|
-
onFocus: y,
|
|
76
|
-
precision: C,
|
|
77
|
-
type: o,
|
|
78
|
-
value: p,
|
|
79
|
-
withManual: $,
|
|
80
|
-
..._
|
|
81
|
-
} = i, e = w(null), l = w(null), [n, f] = R();
|
|
82
|
-
return B(() => {
|
|
83
|
-
e.current && l.current && k(e.current, l.current), e.current && e.current.addEventListener("input", () => {
|
|
84
|
-
e.current && l.current && k(e.current, l.current);
|
|
85
|
-
});
|
|
86
|
-
}, []), B(() => {
|
|
87
|
-
p !== n && f(p);
|
|
88
|
-
}, [p]), /* @__PURE__ */ a(
|
|
89
|
-
"div",
|
|
90
|
-
{
|
|
91
|
-
className: `ar-Slider w-100${c ? " " + c : ""}`,
|
|
92
|
-
children: /* @__PURE__ */ x("div", { className: "ar-Slider__control flex-v-center position-relative justify-content-between", children: [
|
|
93
|
-
m && /* @__PURE__ */ a("label", { className: "me-3", htmlFor: s, children: /* @__PURE__ */ a("strong", { children: m }) }),
|
|
94
|
-
/* @__PURE__ */ x("div", { className: "ar-Slider__slider-bar flex-center", children: [
|
|
95
|
-
/* @__PURE__ */ a("div", { className: "d-inline-block me-2", children: _.min }),
|
|
96
|
-
/* @__PURE__ */ x("div", { className: "position-relative", children: [
|
|
97
|
-
/* @__PURE__ */ a(
|
|
98
|
-
"input",
|
|
99
|
-
{
|
|
100
|
-
ref: e,
|
|
101
|
-
id: s,
|
|
102
|
-
name: r || s,
|
|
103
|
-
type: "range",
|
|
104
|
-
className: `ar-TextInput__input h-100 py-2${u ? " " + u : ""}`,
|
|
105
|
-
onChange: (g) => {
|
|
106
|
-
f(g.target.value), b && b(g);
|
|
107
|
-
},
|
|
108
|
-
onFocus: y,
|
|
109
|
-
onBlur: h,
|
|
110
|
-
value: n,
|
|
111
|
-
step: C,
|
|
112
|
-
..._
|
|
113
|
-
}
|
|
114
|
-
),
|
|
115
|
-
n && /* @__PURE__ */ a(
|
|
116
|
-
"output",
|
|
117
|
-
{
|
|
118
|
-
ref: l,
|
|
119
|
-
className: "ar-Slider__bubble position-absolute",
|
|
120
|
-
htmlFor: s
|
|
121
|
-
}
|
|
122
|
-
)
|
|
123
|
-
] }),
|
|
124
|
-
/* @__PURE__ */ a("div", { className: "d-inline-block ms-2", children: _.max }),
|
|
125
|
-
$ && /* @__PURE__ */ a(
|
|
126
|
-
"input",
|
|
127
|
-
{
|
|
128
|
-
className: "ar-Slider__manual-input",
|
|
129
|
-
type: "text",
|
|
130
|
-
value: n,
|
|
131
|
-
onChange: (g) => {
|
|
132
|
-
f(g.target.value), b && b(g);
|
|
133
|
-
},
|
|
134
|
-
title: "Maunal Value"
|
|
135
|
-
}
|
|
136
|
-
)
|
|
137
|
-
] })
|
|
138
|
-
] })
|
|
139
|
-
}
|
|
140
|
-
);
|
|
141
|
-
};
|
|
142
|
-
let E = {
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode(".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}")),document.head.appendChild(r)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
2
|
+
import { jsxs as l, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as F, useState as u } from "react";
|
|
4
|
+
import { L as n, C as H } from "./Control-chunk.js";
|
|
5
|
+
import y from "@armco/icon";
|
|
6
|
+
import Z from "@armco/shared-components/Image";
|
|
7
|
+
import C from "@armco/shared-components/Tooltip";
|
|
8
|
+
import k from "@armco/shared-components/Slider";
|
|
9
|
+
import { downloadEditedImage as V } from "./helper.js";
|
|
10
|
+
import "@armco/utils/domHelper";
|
|
11
|
+
let c = {
|
|
143
12
|
rotateBy: 0,
|
|
144
13
|
brightness: 1,
|
|
145
14
|
contrast: 1,
|
|
@@ -150,85 +19,85 @@ let E = {
|
|
|
150
19
|
opacity: 1,
|
|
151
20
|
scale: 1
|
|
152
21
|
};
|
|
153
|
-
const
|
|
154
|
-
const { image:
|
|
155
|
-
|
|
156
|
-
...
|
|
157
|
-
...
|
|
22
|
+
const O = (d) => (d % 360 + 360) % 360, E = 22.5, q = (d) => {
|
|
23
|
+
const { image: I, imageState: R, onChange: g, onCommit: b, viewOnly: m } = d;
|
|
24
|
+
c = {
|
|
25
|
+
...c,
|
|
26
|
+
...R
|
|
158
27
|
};
|
|
159
|
-
const
|
|
160
|
-
const
|
|
161
|
-
f !== void 0 &&
|
|
162
|
-
JSON.stringify(
|
|
163
|
-
),
|
|
164
|
-
},
|
|
28
|
+
const v = F(null), [o, p] = u({ ...c }), [r, _] = u(), [s, N] = u(), a = (e, i) => {
|
|
29
|
+
const h = { ...o, [e]: i }, { rotateBy: f, ...z } = h, { rotateBy: x, ...A } = c;
|
|
30
|
+
f !== void 0 && x !== void 0 && N(
|
|
31
|
+
JSON.stringify(z) !== JSON.stringify(A) || O(f) !== O(x)
|
|
32
|
+
), p(h), g && g(h);
|
|
33
|
+
}, S = [
|
|
165
34
|
{
|
|
166
35
|
icon: "tb.TbFlipHorizontal",
|
|
167
|
-
handler: () =>
|
|
36
|
+
handler: () => a("flipHorizontal", !o.flipHorizontal),
|
|
168
37
|
tooltip: "Flip Horizontal"
|
|
169
38
|
},
|
|
170
39
|
{
|
|
171
40
|
icon: "tb.TbFlipVertical",
|
|
172
|
-
handler: () =>
|
|
41
|
+
handler: () => a("flipVertical", !o.flipVertical),
|
|
173
42
|
tooltip: "Flip Vertical"
|
|
174
43
|
},
|
|
175
44
|
{
|
|
176
45
|
icon: "ai.AiOutlineRotateLeft",
|
|
177
|
-
handler: () =>
|
|
46
|
+
handler: () => a("rotateBy", o.rotateBy - E),
|
|
178
47
|
tooltip: "Rotate Left"
|
|
179
48
|
},
|
|
180
49
|
{
|
|
181
50
|
icon: "ai.AiOutlineRotateRight",
|
|
182
|
-
handler: () =>
|
|
51
|
+
handler: () => a("rotateBy", o.rotateBy + E),
|
|
183
52
|
tooltip: "Rotate Right"
|
|
184
53
|
},
|
|
185
54
|
{
|
|
186
55
|
icon: "fi.FiZoomIn",
|
|
187
|
-
handler: () =>
|
|
56
|
+
handler: () => a("scale", (o.scale + 1) % 10),
|
|
188
57
|
tooltip: "Zoom In"
|
|
189
58
|
},
|
|
190
59
|
{
|
|
191
60
|
icon: "fi.FiZoomOut",
|
|
192
|
-
handler: () =>
|
|
61
|
+
handler: () => a(
|
|
193
62
|
"scale",
|
|
194
|
-
(
|
|
63
|
+
(o.scale - 1 < 0 ? 0 : o.scale - 1) % 10
|
|
195
64
|
),
|
|
196
65
|
tooltip: "Zoom Out"
|
|
197
66
|
},
|
|
198
67
|
{
|
|
199
|
-
icon:
|
|
200
|
-
handler: () =>
|
|
201
|
-
tooltip:
|
|
68
|
+
icon: r ? "md.MdOutlineExpandLess" : "md.MdOutlineExpandMore",
|
|
69
|
+
handler: () => _(!r),
|
|
70
|
+
tooltip: r ? "Hide Advanced Controls" : "Show Advanced Controls"
|
|
202
71
|
}
|
|
203
|
-
],
|
|
72
|
+
], w = [
|
|
204
73
|
{
|
|
205
74
|
icon: "fi.FiZoomIn",
|
|
206
|
-
handler: () =>
|
|
75
|
+
handler: () => p({ ...o, scale: (o.scale + 1) % 10 }),
|
|
207
76
|
tooltip: "Zoom In"
|
|
208
77
|
},
|
|
209
78
|
{
|
|
210
79
|
icon: "fi.FiZoomOut",
|
|
211
|
-
handler: () =>
|
|
212
|
-
...
|
|
213
|
-
scale: (
|
|
80
|
+
handler: () => p({
|
|
81
|
+
...o,
|
|
82
|
+
scale: (o.scale - 1 < 0 ? 0 : o.scale - 1) % 10
|
|
214
83
|
}),
|
|
215
84
|
tooltip: "Zoom Out"
|
|
216
85
|
}
|
|
217
|
-
],
|
|
86
|
+
], B = [
|
|
218
87
|
[
|
|
219
88
|
{
|
|
220
89
|
label: "Brightness",
|
|
221
90
|
min: 0,
|
|
222
91
|
max: 5,
|
|
223
92
|
precision: 0.1,
|
|
224
|
-
handler: (e) =>
|
|
93
|
+
handler: (e) => a("brightness", +e.target.value)
|
|
225
94
|
},
|
|
226
95
|
{
|
|
227
96
|
label: "Contrast",
|
|
228
97
|
min: 0,
|
|
229
98
|
max: 5,
|
|
230
99
|
precision: 0.1,
|
|
231
|
-
handler: (e) =>
|
|
100
|
+
handler: (e) => a("contrast", +e.target.value)
|
|
232
101
|
}
|
|
233
102
|
],
|
|
234
103
|
[
|
|
@@ -237,14 +106,14 @@ const A = (i) => (i % 360 + 360) % 360, H = 22.5, q = (i) => {
|
|
|
237
106
|
min: 0,
|
|
238
107
|
max: 10,
|
|
239
108
|
precision: 0.2,
|
|
240
|
-
handler: (e) =>
|
|
109
|
+
handler: (e) => a("saturate", +e.target.value)
|
|
241
110
|
},
|
|
242
111
|
{
|
|
243
112
|
label: "Grayscale",
|
|
244
113
|
min: 0,
|
|
245
114
|
max: 1,
|
|
246
115
|
precision: 0.05,
|
|
247
|
-
handler: (e) =>
|
|
116
|
+
handler: (e) => a("grayscale", +e.target.value)
|
|
248
117
|
}
|
|
249
118
|
],
|
|
250
119
|
[
|
|
@@ -252,14 +121,14 @@ const A = (i) => (i % 360 + 360) % 360, H = 22.5, q = (i) => {
|
|
|
252
121
|
label: "Blur",
|
|
253
122
|
min: 0,
|
|
254
123
|
max: 20,
|
|
255
|
-
handler: (e) =>
|
|
124
|
+
handler: (e) => a("blur", +e.target.value)
|
|
256
125
|
},
|
|
257
126
|
{
|
|
258
127
|
label: "Sepia",
|
|
259
128
|
min: 0,
|
|
260
129
|
max: 1,
|
|
261
130
|
precision: 0.05,
|
|
262
|
-
handler: (e) =>
|
|
131
|
+
handler: (e) => a("sepia", +e.target.value)
|
|
263
132
|
}
|
|
264
133
|
],
|
|
265
134
|
[
|
|
@@ -268,27 +137,27 @@ const A = (i) => (i % 360 + 360) % 360, H = 22.5, q = (i) => {
|
|
|
268
137
|
min: 0,
|
|
269
138
|
max: 1,
|
|
270
139
|
precision: 0.05,
|
|
271
|
-
handler: (e) =>
|
|
140
|
+
handler: (e) => a("opacity", +e.target.value)
|
|
272
141
|
},
|
|
273
142
|
{
|
|
274
143
|
label: "Scale",
|
|
275
144
|
min: 0,
|
|
276
145
|
max: 10,
|
|
277
146
|
precision: 0.2,
|
|
278
|
-
handler: (e) =>
|
|
147
|
+
handler: (e) => a("scale", +e.target.value)
|
|
279
148
|
}
|
|
280
149
|
]
|
|
281
150
|
];
|
|
282
|
-
return /* @__PURE__ */
|
|
283
|
-
!
|
|
284
|
-
/* @__PURE__ */
|
|
285
|
-
/* @__PURE__ */
|
|
151
|
+
return /* @__PURE__ */ l("div", { className: "ar-ImageEditor d-flex flex-column h-100 overflow-auto flex-center position-relative", children: [
|
|
152
|
+
!m && /* @__PURE__ */ l("div", { className: "ar-ImageEditor__editor-controls position-absolute p-1 top-0 end-0 hover-shadow-dark", children: [
|
|
153
|
+
/* @__PURE__ */ l(C, { children: [
|
|
154
|
+
/* @__PURE__ */ t(
|
|
286
155
|
"span",
|
|
287
156
|
{
|
|
288
157
|
className: "ar-ImageEditor__download-button cursor-pointer border-radius-50 p-1 me-2",
|
|
289
|
-
slot:
|
|
290
|
-
children: /* @__PURE__ */
|
|
291
|
-
|
|
158
|
+
slot: n.ANCHOR,
|
|
159
|
+
children: /* @__PURE__ */ t(
|
|
160
|
+
y,
|
|
292
161
|
{
|
|
293
162
|
icon: "md/MdDownload",
|
|
294
163
|
attributes: {
|
|
@@ -296,69 +165,69 @@ const A = (i) => (i % 360 + 360) % 360, H = 22.5, q = (i) => {
|
|
|
296
165
|
size: "1.5rem"
|
|
297
166
|
},
|
|
298
167
|
events: {
|
|
299
|
-
onClick: () =>
|
|
168
|
+
onClick: () => V(v.current)
|
|
300
169
|
}
|
|
301
170
|
}
|
|
302
171
|
)
|
|
303
172
|
}
|
|
304
173
|
),
|
|
305
|
-
/* @__PURE__ */
|
|
174
|
+
/* @__PURE__ */ t("span", { slot: n.POPOVER, children: "Download" })
|
|
306
175
|
] }),
|
|
307
|
-
/* @__PURE__ */
|
|
308
|
-
/* @__PURE__ */
|
|
176
|
+
/* @__PURE__ */ l(C, { children: [
|
|
177
|
+
/* @__PURE__ */ t(
|
|
309
178
|
"span",
|
|
310
179
|
{
|
|
311
|
-
className: `ar-ImageEditor__commit-button border-radius-50 p-1${
|
|
312
|
-
slot:
|
|
313
|
-
children: /* @__PURE__ */
|
|
314
|
-
|
|
180
|
+
className: `ar-ImageEditor__commit-button border-radius-50 p-1${s ? " cursor-pointer is-dirty" : ""}`,
|
|
181
|
+
slot: n.ANCHOR,
|
|
182
|
+
children: /* @__PURE__ */ t(
|
|
183
|
+
y,
|
|
315
184
|
{
|
|
316
185
|
icon: "io5.IoCheckmarkCircleSharp",
|
|
317
|
-
slot:
|
|
186
|
+
slot: n.ANCHOR,
|
|
318
187
|
attributes: {
|
|
319
|
-
colors: { fillColor:
|
|
188
|
+
colors: { fillColor: s ? "#008000" : "#00800077" },
|
|
320
189
|
size: "1.5rem"
|
|
321
190
|
},
|
|
322
191
|
events: {
|
|
323
|
-
onClick: () =>
|
|
192
|
+
onClick: () => s && b && b(o)
|
|
324
193
|
}
|
|
325
194
|
}
|
|
326
195
|
)
|
|
327
196
|
}
|
|
328
197
|
),
|
|
329
|
-
/* @__PURE__ */
|
|
198
|
+
/* @__PURE__ */ t("span", { slot: n.POPOVER, children: s ? "Save" : "Edit image to save" })
|
|
330
199
|
] })
|
|
331
200
|
] }),
|
|
332
|
-
/* @__PURE__ */
|
|
333
|
-
|
|
201
|
+
/* @__PURE__ */ t("div", { className: "ar-ImageEditor__image-container mb-4", children: /* @__PURE__ */ t(
|
|
202
|
+
Z,
|
|
334
203
|
{
|
|
335
|
-
ref:
|
|
336
|
-
image:
|
|
204
|
+
ref: v,
|
|
205
|
+
image: I,
|
|
337
206
|
fill: !0,
|
|
338
207
|
preserveAspectRatio: !0,
|
|
339
|
-
...
|
|
208
|
+
...o
|
|
340
209
|
}
|
|
341
210
|
) }),
|
|
342
|
-
/* @__PURE__ */
|
|
211
|
+
/* @__PURE__ */ t("div", { className: "ar-ImageEditor__controls py-3 flex-center z-1 position-absolute", children: /* @__PURE__ */ l(
|
|
343
212
|
"div",
|
|
344
213
|
{
|
|
345
|
-
className: `ar-ImageEditor__controls-container border-radius prominent hover-shadow-dark${
|
|
214
|
+
className: `ar-ImageEditor__controls-container border-radius prominent hover-shadow-dark${r ? " expanded" : ""}`,
|
|
346
215
|
children: [
|
|
347
|
-
/* @__PURE__ */
|
|
216
|
+
/* @__PURE__ */ t(
|
|
348
217
|
"div",
|
|
349
218
|
{
|
|
350
|
-
className: `ar-ImageEditor__basic-controls px-3 py-2 ${
|
|
351
|
-
children: (
|
|
219
|
+
className: `ar-ImageEditor__basic-controls px-3 py-2 ${r ? "border-bottom" : ""}`,
|
|
220
|
+
children: (m ? w : S).map((e) => /* @__PURE__ */ t(H, { ...e }))
|
|
352
221
|
}
|
|
353
222
|
),
|
|
354
|
-
!
|
|
355
|
-
|
|
223
|
+
!m && /* @__PURE__ */ t("div", { className: "ar-ImageEditor__advanced-controls mt-2 px-3", children: B.map((e) => /* @__PURE__ */ t("div", { className: "row pb-3 border-bottom", children: e.map((i) => /* @__PURE__ */ t("div", { className: "col-6", children: /* @__PURE__ */ t(
|
|
224
|
+
k,
|
|
356
225
|
{
|
|
357
|
-
label:
|
|
358
|
-
min:
|
|
359
|
-
max:
|
|
360
|
-
onChange:
|
|
361
|
-
precision:
|
|
226
|
+
label: i.label,
|
|
227
|
+
min: i.min,
|
|
228
|
+
max: i.max,
|
|
229
|
+
onChange: i.handler,
|
|
230
|
+
precision: i.precision
|
|
362
231
|
}
|
|
363
232
|
) })) })) })
|
|
364
233
|
]
|
package/es/helper.js
CHANGED
|
@@ -1,40 +1,33 @@
|
|
|
1
|
-
import "
|
|
2
|
-
|
|
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) => {
|
|
1
|
+
import { download as c } from "@armco/utils/domHelper";
|
|
2
|
+
const i = (t) => {
|
|
10
3
|
if (t) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
if (!
|
|
4
|
+
const e = document.createElement("canvas");
|
|
5
|
+
e.width = t.naturalWidth, e.height = t.naturalHeight;
|
|
6
|
+
const a = e.getContext("2d");
|
|
7
|
+
if (!a)
|
|
15
8
|
return;
|
|
16
|
-
const
|
|
17
|
-
|
|
9
|
+
const o = t.style.filter, n = t.style.opacity, s = t.style.transform;
|
|
10
|
+
a.filter = o !== "" ? o : "", a.globalAlpha = n !== "" ? parseFloat(n) : 1, s && s !== "none" && d(a, s, e), a.drawImage(t, 0, 0), c(e.toDataURL());
|
|
18
11
|
}
|
|
19
|
-
},
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
23
|
-
t.translate(
|
|
12
|
+
}, d = (t, e, a) => {
|
|
13
|
+
const o = e.match(/rotate\((\d+(?:\.\d+)?)deg\)/);
|
|
14
|
+
if (o) {
|
|
15
|
+
const r = parseFloat(o[1]) * (Math.PI / 180);
|
|
16
|
+
t.translate(a.width / 2, a.height / 2), t.rotate(r), t.translate(-a.width / 2, -a.height / 2);
|
|
24
17
|
}
|
|
25
|
-
const
|
|
18
|
+
const n = e.match(
|
|
26
19
|
/scale\((\d+(?:\.\d+)?)(?:,\s*(\d+(?:\.\d+)?))?\)/
|
|
27
20
|
);
|
|
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
21
|
if (n) {
|
|
34
|
-
const l = parseFloat(n[1]),
|
|
35
|
-
t.
|
|
22
|
+
const l = parseFloat(n[1]), r = n[2] ? parseFloat(n[2]) : l;
|
|
23
|
+
t.scale(l, r);
|
|
24
|
+
}
|
|
25
|
+
const s = e.match(/translate\((\d+px)(?:,\s*(\d+px))?\)/);
|
|
26
|
+
if (s) {
|
|
27
|
+
const l = parseFloat(s[1]), r = s[2] ? parseFloat(s[2]) : 0;
|
|
28
|
+
t.translate(l, r);
|
|
36
29
|
}
|
|
37
30
|
};
|
|
38
31
|
export {
|
|
39
|
-
|
|
32
|
+
i as downloadEditedImage
|
|
40
33
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@armco/imageeditor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "cjs/ImageEditor.js",
|
|
6
6
|
"module": "es/ImageEditor.js",
|
|
@@ -14,13 +14,12 @@
|
|
|
14
14
|
"publish:local": "./publish-local.sh"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@armco/icon": "^0.0.
|
|
18
|
-
"@armco/shared-components": "^0.0.
|
|
19
|
-
"@armco/utils": "^0.0.
|
|
17
|
+
"@armco/icon": "^0.0.5",
|
|
18
|
+
"@armco/shared-components": "^0.0.52",
|
|
19
|
+
"@armco/utils": "^0.0.17",
|
|
20
20
|
"@types/node": "^22.5.5",
|
|
21
21
|
"react": ">16.8.0",
|
|
22
|
-
"react-dom": ">16.8.0"
|
|
23
|
-
"vite-plugin-dts": "^4.2.1"
|
|
22
|
+
"react-dom": ">16.8.0"
|
|
24
23
|
},
|
|
25
24
|
"devDependencies": {
|
|
26
25
|
"@testing-library/dom": "^9.2.0",
|
|
@@ -41,6 +40,8 @@
|
|
|
41
40
|
"typescript": "^5.0.2",
|
|
42
41
|
"vite": "^4.0.0",
|
|
43
42
|
"vite-plugin-css-injected-by-js": "^3.5.1",
|
|
43
|
+
"vite-plugin-dts": "^4.2.2",
|
|
44
|
+
"vite-plugin-externalize-deps": "^0.8.0",
|
|
44
45
|
"vitest": "^0.30.1"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|