@farris/ui-vue 1.3.4 → 1.3.6
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/components/accordion/index.esm.js +16 -16
- package/components/accordion/index.umd.cjs +1 -1
- package/components/avatar/index.esm.js +65 -65
- package/components/avatar/index.umd.cjs +1 -1
- package/components/button-edit/index.esm.js +13 -13
- package/components/button-edit/index.umd.cjs +1 -1
- package/components/calendar/index.esm.js +504 -490
- package/components/calendar/index.umd.cjs +1 -1
- package/components/capsule/index.esm.js +247 -233
- package/components/capsule/index.umd.cjs +1 -1
- package/components/checkbox/index.esm.js +356 -344
- package/components/checkbox/index.umd.cjs +1 -1
- package/components/color-picker/index.esm.js +159 -145
- package/components/color-picker/index.umd.cjs +2 -2
- package/components/combo-list/index.esm.js +127 -128
- package/components/combo-list/index.umd.cjs +1 -1
- package/components/combo-tree/index.esm.js +15 -15
- package/components/combo-tree/index.umd.cjs +1 -1
- package/components/component/index.esm.js +101 -87
- package/components/component/index.umd.cjs +1 -1
- package/components/condition/index.esm.js +9 -7
- package/components/condition/index.umd.cjs +1 -1
- package/components/content-container/index.esm.js +181 -167
- package/components/content-container/index.umd.cjs +1 -1
- package/components/data-grid/index.esm.js +746 -730
- package/components/data-grid/index.umd.cjs +1 -1
- package/components/data-view/index.esm.js +9 -7
- package/components/data-view/index.umd.cjs +1 -1
- package/components/date-picker/index.esm.js +789 -777
- package/components/date-picker/index.umd.cjs +1 -1
- package/components/designer-canvas/index.esm.js +3096 -3069
- package/components/designer-canvas/index.umd.cjs +1 -1
- package/components/dropdown/index.esm.js +257 -243
- package/components/dropdown/index.umd.cjs +2 -2
- package/components/dynamic-form/index.esm.js +322 -306
- package/components/dynamic-form/index.umd.cjs +1 -1
- package/components/dynamic-resolver/index.esm.js +177 -163
- package/components/dynamic-resolver/index.umd.cjs +1 -1
- package/components/event-parameter/index.esm.js +78 -82
- package/components/event-parameter/index.umd.cjs +1 -1
- package/components/events-editor/index.esm.js +501 -487
- package/components/events-editor/index.umd.cjs +1 -1
- package/components/expression-editor/index.esm.js +37 -37
- package/components/expression-editor/index.umd.cjs +1 -1
- package/components/external-container/index.esm.js +487 -472
- package/components/external-container/index.umd.cjs +1 -1
- package/components/field-selector/index.esm.js +440 -433
- package/components/field-selector/index.umd.cjs +1 -1
- package/components/filter-bar/index.esm.js +594 -587
- package/components/filter-bar/index.umd.cjs +1 -1
- package/components/flow-canvas/index.esm.js +2766 -2739
- package/components/flow-canvas/index.umd.cjs +1 -1
- package/components/image-cropper/index.esm.js +402 -388
- package/components/image-cropper/index.umd.cjs +1 -1
- package/components/input-group/index.esm.js +201 -202
- package/components/input-group/index.umd.cjs +1 -1
- package/components/layout/index.esm.js +264 -245
- package/components/layout/index.umd.cjs +1 -1
- package/components/list-nav/index.esm.js +157 -143
- package/components/list-nav/index.umd.cjs +1 -1
- package/components/list-view/index.esm.js +314 -298
- package/components/list-view/index.umd.cjs +1 -1
- package/components/lookup/index.esm.js +862 -843
- package/components/lookup/index.umd.cjs +1 -1
- package/components/mapping-editor/index.esm.js +1031 -1015
- package/components/mapping-editor/index.umd.cjs +1 -1
- package/components/nav/index.esm.js +169 -155
- package/components/nav/index.umd.cjs +2 -2
- package/components/number-range/index.esm.js +150 -137
- package/components/number-range/index.umd.cjs +1 -1
- package/components/number-spinner/index.esm.js +207 -194
- package/components/number-spinner/index.umd.cjs +1 -1
- package/components/order/index.esm.js +427 -414
- package/components/order/index.umd.cjs +1 -1
- package/components/page-footer/index.esm.js +22 -22
- package/components/page-footer/index.umd.cjs +1 -1
- package/components/page-header/index.esm.js +510 -492
- package/components/page-header/index.umd.cjs +1 -1
- package/components/pagination/index.esm.js +192 -178
- package/components/pagination/index.umd.cjs +1 -1
- package/components/progress/index.esm.js +234 -220
- package/components/progress/index.umd.cjs +3 -3
- package/components/property-editor/index.esm.js +288 -277
- package/components/property-editor/index.umd.cjs +2 -2
- package/components/property-panel/index.esm.js +62 -61
- package/components/property-panel/index.umd.cjs +1 -1
- package/components/query-solution/index.esm.js +776 -770
- package/components/query-solution/index.umd.cjs +6 -6
- package/components/radio-button/index.esm.js +64 -64
- package/components/radio-button/index.umd.cjs +1 -1
- package/components/radio-group/index.esm.js +296 -283
- package/components/radio-group/index.umd.cjs +1 -1
- package/components/rate/index.esm.js +222 -208
- package/components/rate/index.umd.cjs +1 -1
- package/components/response-layout/index.esm.js +187 -173
- package/components/response-layout/index.umd.cjs +1 -1
- package/components/response-layout-editor/index.esm.js +554 -542
- package/components/response-layout-editor/index.umd.cjs +1 -1
- package/components/response-toolbar/index.esm.js +483 -469
- package/components/response-toolbar/index.umd.cjs +1 -1
- package/components/schema-selector/index.esm.js +634 -619
- package/components/schema-selector/index.umd.cjs +2 -2
- package/components/search-box/index.esm.js +228 -214
- package/components/search-box/index.umd.cjs +1 -1
- package/components/section/index.esm.js +419 -406
- package/components/section/index.umd.cjs +1 -1
- package/components/smoke-detector/index.esm.js +162 -148
- package/components/smoke-detector/index.umd.cjs +1 -1
- package/components/splitter/index.esm.js +308 -284
- package/components/splitter/index.umd.cjs +1 -1
- package/components/step/index.esm.js +279 -265
- package/components/step/index.umd.cjs +1 -1
- package/components/switch/index.esm.js +183 -170
- package/components/switch/index.umd.cjs +1 -1
- package/components/tabs/index.esm.js +307 -294
- package/components/tabs/index.umd.cjs +1 -1
- package/components/tags/index.esm.js +320 -306
- package/components/tags/index.umd.cjs +1 -1
- package/components/text/index.esm.js +245 -231
- package/components/text/index.umd.cjs +1 -1
- package/components/textarea/index.esm.js +260 -247
- package/components/textarea/index.umd.cjs +1 -1
- package/components/time-picker/index.esm.js +409 -396
- package/components/time-picker/index.umd.cjs +1 -1
- package/components/transfer/index.esm.js +424 -410
- package/components/transfer/index.umd.cjs +1 -1
- package/components/tree-grid/index.esm.js +383 -376
- package/components/tree-grid/index.umd.cjs +1 -1
- package/components/tree-view/index.esm.js +595 -575
- package/components/tree-view/index.umd.cjs +1 -1
- package/components/uploader/index.esm.js +325 -311
- package/components/uploader/index.umd.cjs +2 -2
- package/components/verify-detail/index.esm.js +304 -290
- package/components/verify-detail/index.umd.cjs +1 -1
- package/components/video/index.esm.js +99 -85
- package/components/video/index.umd.cjs +1 -1
- package/components/weather/index.esm.js +947 -933
- package/components/weather/index.umd.cjs +4 -4
- package/farris.all.esm.js +5492 -5470
- package/farris.all.umd.cjs +13 -13
- package/index.css +1 -1
- package/package.json +1 -1
- package/types/condition/src/composition/condition-value/input-group-value.d.ts +1 -1
- package/types/entity-binding-selector/composition/use-entity-tree.d.ts +3 -0
- package/types/entity-binding-selector/composition/use-field-tree.d.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(I,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue"),require("lodash-es")):typeof define=="function"&&define.amd?define(["exports","vue","lodash-es"],i):(I=typeof globalThis<"u"?globalThis:I||self,i(I["image-cropper"]={},I.Vue,I.LodashES))})(this,function(I,i,ie){"use strict";const ge={},me={};function ne(e){const{properties:n,title:s,ignore:p}=e,c=p&&Array.isArray(p),t=Object.keys(n).reduce((d,g)=>((!c||!p.find(w=>w===g))&&(d[g]=n[g].type==="object"&&n[g].properties?ne(n[g]):ie.cloneDeep(n[g].default)),d),{});if(s&&(!c||!p.find(d=>d==="id"))){const d=s.toLowerCase().replace(/-/g,"_");t.id=`${d}_${Math.random().toString().slice(2,6)}`}return t}function ve(e,n={},s){const p=ge[e];if(p){let c=ne(p);const t=me[e];return c=t?t({getSchemaByType:ve},c,n,s):c,c}return null}function Ne(e,n){const s=ne(n);return Object.keys(s).reduce((p,c)=>(p[c]&&ie.isPlainObject(p[c])&&ie.isPlainObject(e[c]||!e[c])?Object.assign(p[c],e[c]||{}):p[c]=e[c],p),s),s}function Ve(e,n){return Object.keys(e).filter(p=>e[p]!=null).reduce((p,c)=>{if(n.has(c)){const t=n.get(c);if(typeof t=="string")p[t]=e[c];else{const d=t(c,e[c],e);Object.assign(p,d)}}else p[c]=e[c];return p},{})}function Se(e,n,s=new Map){const p=Ne(e,n);return Ve(p,s)}function ze(e={}){function n(u,y,v,l){if(typeof v=="number")return l[u].length===v;if(typeof v=="object"){const o=Object.keys(v)[0],T=v[o];if(o==="not")return Number(l[u].length)!==Number(T);if(o==="moreThan")return Number(l[u].length)>=Number(T);if(o==="lessThan")return Number(l[u].length)<=Number(T)}return!1}function s(u,y,v,l){return l[u]&&l[u].propertyValue&&String(l[u].propertyValue.value)===String(v)}const p=new Map([["length",n],["getProperty",s]]);Object.keys(e).reduce((u,y)=>(u.set(y,e[y]),u),p);function c(u,y){const v=u;return typeof y=="number"?[{target:v,operator:"length",param:null,value:Number(y)}]:typeof y=="boolean"?[{target:v,operator:"getProperty",param:u,value:!!y}]:typeof y=="object"?Object.keys(y).map(l=>{if(l==="length")return{target:v,operator:"length",param:null,value:y[l]};const o=l,T=y[l];return{target:v,operator:"getProperty",param:o,value:T}}):[]}function t(u){return Object.keys(u).reduce((v,l)=>{const o=c(l,u[l]);return v.push(...o),v},[])}function d(u,y){if(p.has(u.operator)){const v=p.get(u.operator);return v&&v(u.target,u.param,u.value,y)||!1}return!1}function g(u,y){return t(u).reduce((o,T)=>o&&d(T,y),!0)}function w(u,y){const v=Object.keys(u),l=v.includes("allOf"),o=v.includes("anyOf"),T=l||o,C=(T?u[T?l?"allOf":"anyOf":"allOf"]:[u]).map(k=>g(k,y));return l?!C.includes(!1):C.includes(!0)}return{parseValueSchema:w}}const ke={},Ee={};ze();function Ce(e,n,s=new Map,p=(d,g,w,u)=>g,c={},t=d=>d){return ge[n.title]=n,me[n.title]=p,ke[n.title]=c,Ee[n.title]=t,(d={})=>{const g=Se(d,n,s),w=Object.keys(e).reduce((u,y)=>(u[y]=e[y].default,u),{});return Object.assign(w,g)}}function De(e,n){return{customClass:n.class,customStyle:n.style}}function Be(e,n,s){return n}const $e=new Map([["appearance",De]]),Le={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://farris-design.gitee.io/image-cropper.schema.json",title:"image-cropper",description:"A Farris Component",type:"object",properties:{id:{description:"The unique identifier for image-cropper",type:"string"},type:{description:"The type string of image-cropper",type:"string",default:"image-cropper"},appearance:{description:"",type:"object",properties:{class:{type:"string"},style:{type:"string"}},default:{}},binding:{description:"",type:"object",default:{}},disable:{type:"string",default:!1},editable:{description:"",type:"boolean",default:!0},placeholder:{description:"",type:"string",default:""},readonly:{description:"",type:"boolean",default:!1},require:{description:"",type:"boolean",default:!1},tabindex:{description:"",type:"number",default:-1},visible:{description:"",type:"boolean",default:!0}},required:["id","type"]},Pe={title:"image-cropper",description:"A Farris Component",type:"object",categories:{basic:{description:"Basic Infomation",title:"基本信息",properties:{id:{description:"组件标识",title:"标识",type:"string",readonly:!0},type:{description:"组件类型",title:"控件类型",type:"select",editor:{type:"waiting for modification",enum:[]}}}},behavior:{description:"Basic Infomation",title:"行为",properties:{readonly:{description:"",title:"只读",type:"string"},required:{description:"",title:"必填",type:"boolean"},visible:{description:"",title:"可见",type:"boolean"},placeholder:{description:"",title:"提示文本",type:"string"},tabindex:{description:"",title:"tab索引",type:"number"}}}}},X={format:{type:String,default:"png"},maintainAspectRatio:{type:Boolean,default:!0},transform:{type:Object,default:{scale:0,rotate:0,flipH:!1,flipV:!1}},aspectRatio:{type:Number,default:1},resizeToWidth:{type:Number,default:0},resizeToHeight:{type:Number,default:0},cropperMinWidth:{type:Number,default:0},cropperMinHeight:{type:Number,default:0},canvasRotation:{type:Number,default:0},roundCropper:{type:Boolean,default:!0},onlyScaleDown:{type:Boolean,default:!1},imageQuality:{type:Number,default:92},autoCrop:{type:Boolean,default:!0},backgroundColor:{type:String,default:""},containWithinAspectRatio:{type:Boolean,default:!1},hideResizeSquares:{type:Boolean,default:!1},loadImageErrorText:{type:String,default:"图片加载错误"},alignImage:{type:String,default:"center"},disabled:{type:Boolean,default:!1},imageURL:{type:String,default:"./src/assets/image01.png"},imageChangedEvent:{type:Object,default:null},imageBase64:{type:String,default:""},imageFile:{type:Object,default:null},cropper:{type:Object,default:{x1:-100,y1:-100,x2:1e4,y2:1e4}}},le=Ce(X,Le,$e,Be,Pe);var K=(e=>(e.Move="move",e.Resize="resize",e))(K||{});function We(){function e(c){switch(typeof c=="string"&&(c=n(c)),c){case 2:return{rotate:0,flip:!0};case 3:return{rotate:2,flip:!1};case 4:return{rotate:2,flip:!0};case 5:return{rotate:1,flip:!0};case 6:return{rotate:1,flip:!1};case 7:return{rotate:3,flip:!0};case 8:return{rotate:3,flip:!1};default:return{rotate:0,flip:!1}}}function n(c){const t=new DataView(s(c));if(t.getUint16(0,!1)!==65496)return-2;const d=t.byteLength;let g=2;for(;g<d;){if(t.getUint16(g+2,!1)<=8)return-1;const w=t.getUint16(g,!1);if(g+=2,w===65505){if(t.getUint32(g+=2,!1)!==1165519206)return-1;const u=t.getUint16(g+=6,!1)===18761;g+=t.getUint32(g+4,u);const y=t.getUint16(g,u);g+=2;for(let v=0;v<y;v++)if(t.getUint16(g+v*12,u)===274)return t.getUint16(g+v*12+8,u)}else{if((w&65280)!==65280)break;g+=t.getUint16(g,!1)}}return-1}function s(c){c=c.replace(/^data:([^;]+);base64,/gmi,"");const t=atob(c),d=t.length,g=new Uint8Array(d);for(let w=0;w<d;w++)g[w]=t.charCodeAt(w);return g.buffer}function p(c,t,d){const g=c.width,w=c.height;t=Math.round(t),d=Math.round(d);const u=g/t,y=w/d,v=Math.ceil(u/2),l=Math.ceil(y/2),o=c.getContext("2d");if(o){const T=o.getImageData(0,0,g,w),b=o.createImageData(t,d),{data:B}=T,C=b.data;for(let $=0;$<d;$++)for(let k=0;k<t;k++){const _=(k+$*t)*4,m=$*y;let A=0,f=0,x=0,U=0,q=0,z=0,V=0;const W=Math.floor(k*u),E=Math.floor($*y);let F=Math.ceil((k+1)*u),G=Math.ceil(($+1)*y);F=Math.min(F,g),G=Math.min(G,w);for(let D=E;D<G;D++){const N=Math.abs(m-D)/l,re=k*u,te=N*N;for(let R=W;R<F;R++){const j=Math.abs(re-R)/v,L=Math.sqrt(te+j*j);if(L>=1)continue;A=2*L*L*L-3*L*L+1;const H=4*(R+D*g);V+=A*B[H+3],x+=A,B[H+3]<255&&(A=A*B[H+3]/250),U+=A*B[H],q+=A*B[H+1],z+=A*B[H+2],f+=A}}C[_]=U/f,C[_+1]=q/f,C[_+2]=z/f,C[_+3]=V/x}c.width=t,c.height=d,o.putImageData(b,0,0)}}return{resizeCanvas:p,getTransformationsFromExifData:e}}function Re(e,n,s,p){function c(l,o){e.value.x2=e.value.x1+(e.value.y2-e.value.y1)*s.value,l=Math.max(e.value.x2-n.value.width,0),o=Math.max(0-e.value.y1,0),(l>0||o>0)&&(e.value.x2-=o*s.value>l?o*s.value:l,e.value.y1+=o*s.value>l?o:l/s.value)}function t(l,o){e.value.x2=e.value.x1+(e.value.y2-e.value.y1)*s.value,l=Math.max(e.value.x2-n.value.width,0),o=Math.max(e.value.y2-n.value.height,0),(l>0||o>0)&&(e.value.x2-=o*s.value>l?o*s.value:l,e.value.y2-=o*s.value>l?o:l/s.value)}function d(l,o){e.value.y1=e.value.y2-(e.value.x2-e.value.x1)/s.value,l=Math.max(0-e.value.x1,0),o=Math.max(0-e.value.y1,0),(l>0||o>0)&&(e.value.x1+=o*s.value>l?o*s.value:l,e.value.y1+=o*s.value>l?o:l/s.value)}function g(l,o){e.value.y1=e.value.y2-(e.value.x2-e.value.x1)/s.value,l=Math.max(e.value.x2-n.value.width,0),o=Math.max(0-e.value.y1,0),(l>0||o>0)&&(e.value.x2-=o*s.value>l?o*s.value:l,e.value.y1+=o*s.value>l?o:l/s.value)}function w(l,o){e.value.y2=e.value.y1+(e.value.x2-e.value.x1)/s.value,l=Math.max(e.value.x2-n.value.width,0),o=Math.max(e.value.y2-n.value.height,0),(l>0||o>0)&&(e.value.x2-=o*s.value>l?o*s.value:l,e.value.y2-=o*s.value>l?o:l/s.value)}function u(l,o){e.value.y2=e.value.y1+(e.value.x2-e.value.x1)/s.value,l=Math.max(0-e.value.x1,0),o=Math.max(e.value.y2-n.value.height,0),(l>0||o>0)&&(e.value.x1+=o*s.value>l?o*s.value:l,e.value.y2-=o*s.value>l?o:l/s.value)}function y(){e.value.x2=e.value.x1+(e.value.y2-e.value.y1)*s.value,e.value.y2=e.value.y1+(e.value.x2-e.value.x1)/s.value;const l=Math.max(0-e.value.x1,0),o=Math.max(e.value.x2-n.value.width,0),T=Math.max(e.value.y2-n.value.height,0),b=Math.max(0-e.value.y1,0);(l>0||o>0||T>0||b>0)&&(e.value.x1+=T*s.value>l?T*s.value:l,e.value.x2-=b*s.value>o?b*s.value:o,e.value.y1+=b*s.value>o?b:o/s.value,e.value.y2-=T*s.value>l?T:l/s.value)}function v(){if(n.value.width&&n.value.height)switch(p.position){case"top":c(0,0);break;case"bottom":t(0,0);break;case"topleft":d(0,0);break;case"topright":g(0,0);break;case"right":case"bottomright":w(0,0);break;case"left":case"bottomleft":u(0,0);break;case"center":y();break}}return{checkAspectRatio:v}}function pe(e,n){const{resizeCanvas:s,getTransformationsFromExifData:p}=We(),c=i.inject("NotifyService"),t=i.ref(e.cropper),d=i.ref(e.transform),g=i.ref(e.cropperMinWidth),w=i.ref(e.maintainAspectRatio),u=i.ref(e.aspectRatio),y=i.ref(e.autoCrop),v=i.ref(e.backgroundColor),l=i.ref(e.resizeToWidth),o=i.ref(e.onlyScaleDown),T=i.ref(e.containWithinAspectRatio),b=i.ref(e.canvasRotation),B=i.ref(e.format),C=i.ref(e.imageQuality),$=i.ref(e.resizeToHeight),k=i.ref(e.cropperMinHeight),_=i.ref(""),m=i.ref(!0),A=i.ref(!0);let f,x,U=0,q,z,V;const W=i.ref(null),E=i.ref(""),F=i.ref(""),G=i.ref("0px"),D=i.ref(),N=i.ref({width:100,height:100}),re=K;let te,R=20,j=20,L=!1,H={rotate:0,flip:!1},M={active:!1,type:null,position:null,x1:0,y1:0,x2:0,y2:0,clientX:0,clientY:0};const ye=i.ref(e.imageChangedEvent),oe=i.ref(e.imageURL),Ue=i.ref(e.imageBase64),Oe=i.ref(e.imageFile);function Ie(){F.value="scaleX("+(d.value.scale||1)*(d.value.flipH?-1:1)+")scaleY("+(d.value.scale||1)*(d.value.flipV?-1:1)+")rotate("+(d.value.rotate||0)+"deg)"}function Z(){A.value=!1,D.value=null,_.value="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=",M={active:!1,type:null,position:null,x1:0,y1:0,x2:0,y2:0,clientX:0,clientY:0},N.value={width:0,height:0},f={width:0,height:0},x={width:0,height:0},t.value.x1=-100,t.value.y1=-100,t.value.x2=1e4,t.value.y2=1e4}function Fe(a){return/image\/(png|jpg|jpeg|bmp|gif|tiff|webp)/.test(a)}function qe(){if(b.value+=H.rotate,T.value&&f.width&&f.height){if(b.value%2){const h=f.width*u.value,S=f.height/u.value;return{width:Math.max(f.height,h),height:Math.max(f.width,S)}}const a=f.height*u.value,r=f.width/u.value;return{width:Math.max(f.width,a),height:Math.max(f.height,r)}}return b.value%2?{height:f.width,width:f.height}:{width:f.width,height:f.height}}function Qe(){b.value+=H.rotate;const a=qe(),r=document.createElement("canvas");a.width&&a.height&&(r.width=a.width,r.height=a.height);const h=r.getContext("2d");return f.width&&f.height&&V&&(h==null||h.setTransform(H.flip?-1:1,0,0,1,r.width/2,r.height/2),h==null||h.rotate(Math.PI*(b.value/2)),h==null||h.drawImage(V,-f.width/2,-f.height/2)),r.toDataURL()}function Ge(a){return new Promise(r=>{te=a,_.value=a,D.value=new Image,D.value.onload=()=>{var h,S;x.width=(h=D.value)==null?void 0:h.naturalWidth,x.height=(S=D.value)==null?void 0:S.naturalHeight,r()},D.value.src=te})}function Me(){if(!V||!V.complete||!H)return Promise.reject(new Error("No image loaded"));const a=Qe();return Ge(a)}function se(a){const r=h=>{c.show({showCloseButton:!1,timeout:3e3,animate:"fadeIn",toasts:[{type:"string",title:"提示",msg:"图片上传错误,请重试"}]}),m.value=!1,L=!0,n.emit("loadImageFailed"),V=null,E.value=""};V=new Image,V.onload=()=>{E.value=a,H=p(a),f.width=V==null?void 0:V.naturalWidth,f.height=V==null?void 0:V.naturalHeight,Me().then(()=>{L=!1}).catch(r)},V.onerror=r,V.src=a}function Je(a,r){Fe(r)?(L=!1,se(a)):(c.show({showCloseButton:!1,timeout:3e3,animate:"fadeIn",toasts:[{type:"string",title:"提示",msg:"图片类型不正确,请重试"}]}),m.value=!1,L=!0,n.emit("loadImageFailed"))}function xe(a){const r=new FileReader;r.onload=h=>Je(h.target.result,a.type),r.readAsDataURL(a)}function be(a){const r=new Image;r.onerror=()=>{c.show({showCloseButton:!1,timeout:3e3,animate:"fadeIn",toasts:[{type:"string",title:"提示",msg:"图片加载错误,请重试"}]}),m.value=!1,L=!0,n.emit("loadImageFailed")},r.onload=()=>{L=!1;const h=document.createElement("canvas"),S=h.getContext("2d");h.width=r.width,h.height=r.height,S==null||S.drawImage(r,0,0),se(h.toDataURL())},r.crossOrigin="anonymous",r.src=a}function Ze(){return W.value&&W.value&&W.value.offsetWidth>0}function ue(){if(W.value){const a=W.value;N.value.width=a.offsetWidth,N.value.height=a.offsetHeight,G.value="calc(50% - "+N.value.width/2+"px)"}}function Ye(){D.value&&N.value.width&&(R=g.value>0?Math.max(20,g.value/D.value.width*N.value.width):20)}function Xe(){w.value?j=Math.max(20,R/u.value):k.value>0&&D.value&&N.value.height?j=Math.max(20,k.value/D.value.height*N.value.height):j=20}function ce(){D.value?(Ye(),Xe()):(R=20,j=20)}function Ke(){const a=W.value,r=i.ref({x1:0,x2:0,y1:0,y2:0});if(a&&x.width&&x.height){const h=x.width/a.offsetWidth;r.value={x1:Math.round(t.value.x1*h),y1:Math.round(t.value.y1*h),x2:Math.round(t.value.x2*h),y2:Math.round(t.value.y2*h)},T.value||(r.value.x1=Math.max(r.value.x1,0),r.value.y1=Math.max(r.value.y1,0),r.value.x2=Math.min(r.value.x2,x.width),r.value.y2=Math.min(r.value.y2,x.height))}return r.value}function et(){b.value+=H.rotate;const a=W.value,r=i.ref({x1:0,x2:0,y1:0,y2:0});if(a&&x.height&&x.width&&f.height&&f.width){const h=x.width/a.offsetWidth;let S,P;b.value%2?(S=(x.width-f.height)/2,P=(x.height-f.width)/2):(S=(x.width-f.width)/2,P=(x.height-f.height)/2),r.value={x1:Math.round(t.value.x1*h)-S,y1:Math.round(t.value.y1*h)-P,x2:Math.round(t.value.x2*h)-S,y2:Math.round(t.value.y2*h)-P},T.value||(r.value.x1=Math.max(r.value.x1,0),r.value.y1=Math.max(r.value.y1,0),r.value.x2=Math.min(r.value.x2,x.width),r.value.y2=Math.min(r.value.y2,x.height))}return r.value}function tt(a,r){if(l.value>0){if(!o.value||a>l.value)return l.value/a}else if($.value>0&&(!o.value||r>$.value))return $.value/r;return 1}function at(){return Math.min(1,Math.max(0,C.value/100))}function it(a){return a.toDataURL("image/"+B.value,at())}function nt(){if(W.value&&W.value&&D.value!=null){const a=Ke(),r=a.x2-a.x1,h=a.y2-a.y1,S=document.createElement("canvas");S.width=r,S.height=h;const P=S.getContext("2d");if(P){v.value!=null&&(P.fillStyle=v.value,P.fillRect(0,0,r,h));const Q=(d.value.scale||1)*(d.value.flipH?-1:1),J=(d.value.scale||1)*(d.value.flipV?-1:1);x.width&&x.height&&(P.setTransform(Q,0,0,J,x.width/2,x.height/2),P.translate(-a.x1/Q,-a.y1/J),P.rotate((d.value.rotate||0)*Math.PI/180),P.drawImage(D.value,-x.width/2,-x.height/2));const O={width:r,height:h,imagePosition:a,cropperPosition:{...t.value}};T.value&&(O.offsetImagePosition=et());const Y=tt(r,h);return Y!==1&&(O.width=Math.round(r*Y),O.height=w.value?Math.round(O.width/u.value):Math.round(h*Y),s(S,O.width,O.height)),O.base64=it(S),n.emit("imageCropped",O),O}}return null}function ae(){y.value&&nt()}function we(){const a=W.value;if(a){if(!w.value)t.value.x1=0,t.value.x2=a.offsetWidth,t.value.y1=0,t.value.y2=a.offsetHeight;else if(a.offsetWidth/u.value<a.offsetHeight){t.value.x1=0,t.value.x2=a.offsetWidth;const r=a.offsetWidth/u.value;t.value.y1=(a.offsetHeight-r)/2,t.value.y2=t.value.y1+r}else{t.value.y1=0,t.value.y2=a.offsetHeight;const r=a.offsetHeight*u.value;t.value.x1=(a.offsetWidth-r)/2,t.value.x2=t.value.x1+r}ae(),A.value=!0}}function Te(){U>40?(c.show({showCloseButton:!1,timeout:3e3,animate:"fadeIn",toasts:[{type:"string",title:"提示",msg:"图片加载超时,请重试"}]}),L=!0,m.value=!1,n.emit("loadImageFailed")):Ze()?(L=!1,ue(),ce(),we(),n.emit("cropperReady",{...N.value})):(U++,setTimeout(()=>Te(),50))}function lt(){D.value!=null&&(m.value=!1,n.emit("imageLoaded"),U=0,setTimeout(()=>Te()))}function rt(){const a=W.value;(N.value.width!==(a==null?void 0:a.offsetWidth)||N.value.height!==(a==null?void 0:a.offsetHeight))&&N.value.width&&N.value.height&&a&&(t.value.x1=t.value.x1*a.offsetWidth/N.value.width,t.value.x2=t.value.x2*a.offsetWidth/N.value.width,t.value.y1=t.value.y1*a.offsetHeight/N.value.height,t.value.y2=t.value.y2*a.offsetHeight/N.value.height)}const ot=()=>{rt(),ue(),ce()},Ae=()=>{clearTimeout(z),z=setTimeout(ot,300)};i.onMounted(()=>{window.addEventListener("resize",Ae),oe.value&&(Z(),m.value=!0,be(oe.value))}),i.onUnmounted(()=>{window.removeEventListener("resize",Ae)});function st(){M.active&&(M.active=!1,ae())}function fe(a){return(a.touches&&a.touches[0]?a.touches[0].clientX:a.clientX)||0}function he(a){return(a.touches&&a.touches[0]?a.touches[0].clientY:a.clientY)||0}function ut(a,r,h=null){M&&M.active||(a.preventDefault&&a.preventDefault(),M={active:!0,type:r,position:h,clientX:fe(a),clientY:he(a),...t.value})}function de(a=!1){t.value.x1<0&&(t.value.x2-=a?t.value.x1:0,t.value.x1=0),t.value.y1<0&&(t.value.y2-=a?t.value.y1:0,t.value.y1=0),t.value.x2>N.value.width&&(t.value.x1-=a?t.value.x2-N.value.width:0,t.value.x2=N.value.width),t.value.y2>N.value.height&&(t.value.y1-=a?t.value.y2-N.value.height:0,t.value.y2=N.value.height)}function ct(a){const r=fe(a)-M.clientX,h=he(a)-M.clientY;t.value.x1=M.x1+r,t.value.y1=M.y1+h,t.value.x2=M.x2+r,t.value.y2=M.y2+h}const{checkAspectRatio:ft}=Re(t,N,u,M);function ht(a){const r=fe(a)-M.clientX,h=he(a)-M.clientY;switch(M.position){case"left":t.value.x1=Math.min(M.x1+r,t.value.x2-R);break;case"topleft":t.value.x1=Math.min(M.x1+r,t.value.x2-R),t.value.y1=Math.min(M.y1+h,t.value.y2-j);break;case"top":t.value.y1=Math.min(M.y1+h,t.value.y2-j);break;case"topright":t.value.x2=Math.max(M.x2+r,t.value.x1+R),t.value.y1=Math.min(M.y1+h,t.value.y2-j);break;case"right":t.value.x2=Math.max(M.x2+r,t.value.x1+R);break;case"bottomright":t.value.x2=Math.max(M.x2+r,t.value.x1+R),t.value.y2=Math.max(M.y2+h,t.value.y1+j);break;case"bottom":t.value.y2=Math.max(M.y2+h,t.value.y1+j);break;case"bottomleft":t.value.x1=Math.min(M.x1+r,t.value.x2-R),t.value.y2=Math.max(M.y2+h,t.value.y1+j);break;case"center":const{scale:S}=a,P=Math.abs(M.x2-M.x1)*S,Q=Math.abs(M.y2-M.y1)*S,{x1:J}=t.value,{y1:O}=t.value;t.value.x1=Math.min(M.clientX-P/2,t.value.x2-R),t.value.y1=Math.min(M.clientY-Q/2,t.value.y2-j),t.value.x2=Math.max(M.clientX+P/2,J+R),t.value.y2=Math.max(M.clientY+Q/2,O+j);break}w.value&&ft()}function dt(a){M&&M.active&&(a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault(),clearTimeout(q),q=setTimeout(()=>{M.type===K.Move?(ct(a),de(!0)):M.type===K.Resize&&(ht(a),de(!1))},300))}return i.watch(ye,a=>{Z(),a&&a.target&&a.target.files&&a.target.files.length>0&&(m.value=!0,xe(a.target.files[0]))}),i.watch(oe,a=>{a?(Z(),m.value=!0,be(a)):(c.show({showCloseButton:!1,timeout:3e3,animate:"fadeIn",toasts:[{type:"string",title:"提示",msg:"图片路径为空"}]}),m.value=!1,L=!0)}),i.watch(Ue,a=>{Z(),m.value=!0,se(a)}),i.watch(Oe,a=>{Z(),a&&(m.value=!0,xe(a))}),i.watch(()=>[e.containWithinAspectRatio,e.canvasRotation,e.cropper,e.aspectRatio,e.transform,e.imageChangedEvent],([a,r,h,S,P,Q],[J,O,Y,gt,mt,vt])=>{V&&V.complete&&H&&(a!==J||r!==O)&&Me(),h!==Y&&(ue(),ce(),de(!1),ae()),S!==gt&&A.value&&we(),P!==mt&&(Ie(),ae()),Q!==vt&&(ye.value=Q)}),{uploadError:L,imageVisible:A,backgroundColor:v,sourceImage:W,safeImgDataUrl:_,safeTransformStyle:F,maxSize:N,cropper:t,marginLeft:G,moveTypes:re,isLoading:m,startMove:ut,imageLoadedInView:lt,moveStop:st,moveImg:dt}}const ee=i.defineComponent({name:"FImageCropper",props:X,emits:["imageCropped","imageLoaded","cropperReady","loadImageFailed"],setup(e,n){const s=i.ref(e.alignImage),p=i.ref(e.roundCropper),c=i.ref(e.hideResizeSquares),t=i.ref(e.loadImageErrorText),d=i.ref(e.disabled),g=i.ref(null),{uploadError:w,imageVisible:u,backgroundColor:y,sourceImage:v,safeImgDataUrl:l,safeTransformStyle:o,maxSize:T,cropper:b,marginLeft:B,moveTypes:C,isLoading:$,startMove:k,imageLoadedInView:_,moveStop:m,moveImg:A}=pe(e,n);function f(z){return i.createVNode("span",{class:`farris-image-cropper-resize-bar ${z}`,onMousedown:i.withModifiers(V=>k(V,C.Resize,z),["prevent"])},null)}function x(z){return i.createVNode("div",null,[i.createVNode("span",{class:`farris-image-cropper-resize-bar ${z}`,onMousedown:i.withModifiers(V=>k(V,C.Resize,z),["prevent"])},[i.createVNode("span",{class:"farris-image-cropper-square"},null)]),i.createVNode("span",{class:"farris-image-cropper-resize top"},[i.createVNode("span",{class:"farris-image-cropper-square"},null)])])}const U=["top","right","bottom","left"].map(z=>f(z)),q=["topleft","topright","bottomright","bottomleft"].map(z=>x(z));return()=>i.createVNode("div",{class:["farris-image-cropper-frame",{"farris-image-cropper-disabled":d.value}],style:{"text-align":s.value},onMousemove:i.withModifiers(z=>A(z),["prevent"]),onTouchmove:i.withModifiers(z=>A(z),["prevent"]),onMouseup:i.withModifiers(()=>m(),["prevent"]),onTouchend:i.withModifiers(()=>m(),["prevent"])},[!w&&i.createVNode("div",{ref:g,class:"farris-image-cropper",style:[{background:u.value?y.value:""}]},[l.value&&i.createVNode("img",{title:"farris-source-image",ref:v,class:"farris-source-image",style:[{visibility:u.value?"visible":"hidden"},{transform:o.value}],src:l.value,onLoad:()=>_()},null),T.value&&i.createVNode("div",{class:"farris-image-overlay",style:[{width:`${T.value.width||0}px`},{height:`${T.value.height||0}px`},{"margin-left":s.value==="center"?B.value:""}]},null),u.value&&i.createVNode("div",{class:["farris-image-cropper-wrapper",{"farris-image-cropper-rounded":p.value}],style:[{top:`${b.value.y1}px`},{left:`${b.value.x1}px`},{width:`${b.value.x2-b.value.x1}px`},{height:`${b.value.y2-b.value.y1}px`},{visibility:u.value?"visible":"hidden"},{"margin-left":s.value==="center"?B.value:""}],tabindex:"0"},[i.createVNode("div",{class:"farris-image-cropper-move",onMousedown:i.withModifiers(z=>k(z,C.Move,"topleft"),["prevent"])},null),!c.value&&i.createVNode("div",null,[q,U])])]),$.value&&i.createVNode("div",{class:"farris-image-cropper-loading"},[i.createVNode("div",{class:"farris-image-cropper-loading-spinner"},null)]),w&&i.createVNode("div",{class:"farris-image-cropper-error"},[t.value])])}});function _e(e,n,s){var _;const p="",c="",t=i.ref();function d(){return(n==null?void 0:n.schema.componentType)!=="frame"}function g(){return!1}function w(){return(n==null?void 0:n.schema.componentType)!=="frame"}function u(){return(n==null?void 0:n.schema.componentType)==="frame"}function y(m){if(!m||!m.value)return null;if(m.value.schema&&m.value.schema.type==="component")return m.value;const A=i.ref(m==null?void 0:m.value.parent),f=y(A);return f||null}function v(m=n){const{componentInstance:A,designerItemElementRef:f}=m;return!A||!A.value?null:A.value.canMove?f:v(m.parent)}function l(m){return!!s}function o(){return(n==null?void 0:n.schema.label)||(n==null?void 0:n.schema.title)||(n==null?void 0:n.schema.name)}function T(){}function b(m,A){}function B(m,A){const{componentType:f}=m;let x=ve(f,m,A);const U=f.toLowerCase().replace(/-/g,"_");return x&&!x.id&&x.type===f&&(x.id=`${U}_${Math.random().toString().slice(2,6)}`),x}function C(m){}function $(...m){}function k(){n!=null&&n.schema.contents&&n.schema.contents.map(m=>{var x;let A=m.id;m.type==="component-ref"&&(A=m.component);const f=e.value.querySelector(`#${A}-design-item`);(x=f==null?void 0:f.componentInstance)!=null&&x.value.onRemoveComponent&&f.componentInstance.value.onRemoveComponent()})}return t.value={canMove:d(),canSelectParent:g(),canDelete:w(),canNested:!u(),contents:n==null?void 0:n.schema.contents,elementRef:e,parent:(_=n==null?void 0:n.parent)==null?void 0:_.componentInstance,schema:n==null?void 0:n.schema,styles:p,designerClass:c,canAccepts:l,getBelongedComponentInstance:y,getDraggableDesignItemElement:v,getDraggingDisplayText:o,getPropConfig:$,getDragScopeElement:T,onAcceptMovedChildElement:b,onChildElementMovedOut:C,addNewChildComponentSchema:B,triggerBelongedComponentToMoveWhenMoved:i.ref(!1),triggerBelongedComponentToDeleteWhenDeleted:i.ref(!1),onRemoveComponent:k},t}const je=i.defineComponent({name:"FImageCropperDesign",props:X,emits:["imageCropped","imageLoaded","cropperReady","loadImageFailed"],setup(e,n){const s=i.ref(e.alignImage),p=i.ref(e.roundCropper),c=i.ref(e.hideResizeSquares),t=i.ref(e.loadImageErrorText),d=i.ref(e.disabled),g=i.ref(null),{uploadError:w,imageVisible:u,backgroundColor:y,sourceImage:v,safeImgDataUrl:l,safeTransformStyle:o,maxSize:T,cropper:b,marginLeft:B,moveTypes:C,isLoading:$,startMove:k,imageLoadedInView:_,moveStop:m,moveImg:A}=pe(e,n),f=i.ref(),x=i.inject("design-item-context"),U=_e(f,x);i.onMounted(()=>{f.value.componentInstance=U}),n.expose(U.value);function q(E){return i.createVNode("span",{class:`farris-image-cropper-resize-bar ${E}`,onMousedown:i.withModifiers(F=>k(F,C.Resize,E),["prevent"])},null)}function z(E){return i.createVNode("div",null,[i.createVNode("span",{class:`farris-image-cropper-resize-bar ${E}`,onMousedown:i.withModifiers(F=>k(F,C.Resize,E),["prevent"])},[i.createVNode("span",{class:"farris-image-cropper-square"},null)]),i.createVNode("span",{class:"farris-image-cropper-resize top"},[i.createVNode("span",{class:"farris-image-cropper-square"},null)])])}const V=["top","right","bottom","left"].map(E=>q(E)),W=["topleft","topright","bottomright","bottomleft"].map(E=>z(E));return()=>i.createVNode("div",{ref:f,class:["farris-image-cropper-frame",{"farris-image-cropper-disabled":d.value}],style:{"text-align":s.value},onMousemove:i.withModifiers(E=>A(E),["prevent"]),onTouchmove:i.withModifiers(E=>A(E),["prevent"]),onMouseup:i.withModifiers(()=>m(),["prevent"]),onTouchend:i.withModifiers(()=>m(),["prevent"])},[!w&&i.createVNode("div",{ref:g,class:"farris-image-cropper",style:[{background:u.value?y.value:""}]},[l.value&&i.createVNode("img",{title:"farris-source-image",ref:v,class:"farris-source-image",style:[{visibility:u.value?"visible":"hidden"},{transform:o.value}],src:l.value,onLoad:()=>_()},null),T.value&&i.createVNode("div",{class:"farris-image-overlay",style:[{width:`${T.value.width||0}px`},{height:`${T.value.height||0}px`},{"margin-left":s.value==="center"?B.value:""}]},null),u.value&&i.createVNode("div",{class:["farris-image-cropper-wrapper",{"farris-image-cropper-rounded":p.value}],style:[{top:`${b.value.y1}px`},{left:`${b.value.x1}px`},{width:`${b.value.x2-b.value.x1}px`},{height:`${b.value.y2-b.value.y1}px`},{visibility:u.value?"visible":"hidden"},{"margin-left":s.value==="center"?B.value:""}],tabindex:"0"},[i.createVNode("div",{class:"farris-image-cropper-move",onMousedown:i.withModifiers(E=>k(E,C.Move,"topleft"),["prevent"])},null),!c.value&&i.createVNode("div",null,[W,V])])]),$.value&&i.createVNode("div",{class:"farris-image-cropper-loading"},[i.createVNode("div",{class:"farris-image-cropper-loading-spinner"},null)]),w&&i.createVNode("div",{class:"farris-image-cropper-error"},[t.value])])}}),He={install(e){e.component(ee.name,ee)},register(e,n,s,p){e["image-cropper"]=ee,n["image-cropper"]=le},registerDesigner(e,n,s){e["image-cropper"]=je,n["image-cropper"]=le}};I.ImageCropper=ee,I.default=He,I.imageCropperProps=X,I.propsResolver=le,Object.defineProperties(I,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(I,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue"),require("lodash-es")):typeof define=="function"&&define.amd?define(["exports","vue","lodash-es"],i):(I=typeof globalThis<"u"?globalThis:I||self,i(I["image-cropper"]={},I.Vue,I.LodashES))})(this,function(I,i,X){"use strict";const ge={},me={};function ne(e){const{properties:n,title:r,ignore:g}=e,c=g&&Array.isArray(g),t=Object.keys(n).reduce((f,m)=>((!c||!g.find(w=>w===m))&&(f[m]=n[m].type==="object"&&n[m].properties?ne(n[m]):X.cloneDeep(n[m].default)),f),{});if(r&&(!c||!g.find(f=>f==="id"))){const f=r.toLowerCase().replace(/-/g,"_");t.id=`${f}_${Math.random().toString().slice(2,6)}`}return t}function Ne(e){const{properties:n,title:r,required:g}=e;if(g&&Array.isArray(g)){const c=g.reduce((t,f)=>(t[f]=n[f].type==="object"&&n[f].properties?ne(n[f]):X.cloneDeep(n[f].default),t),{});if(r&&g.find(t=>t==="id")){const t=r.toLowerCase().replace(/-/g,"_");c.id=`${t}_${Math.random().toString().slice(2,6)}`}return c}return{type:r}}function ve(e,n={},r){const g=ge[e];if(g){let c=Ne(g);const t=me[e];return c=t?t({getSchemaByType:ve},c,n,r):c,c}return null}function Ve(e,n){const r=ne(n);return Object.keys(r).reduce((g,c)=>(Object.prototype.hasOwnProperty.call(e,c)&&(g[c]&&X.isPlainObject(g[c])&&X.isPlainObject(e[c]||!e[c])?Object.assign(g[c],e[c]||{}):g[c]=e[c]),g),r),r}function Se(e,n){return Object.keys(e).filter(g=>e[g]!=null).reduce((g,c)=>{if(n.has(c)){const t=n.get(c);if(typeof t=="string")g[t]=e[c];else{const f=t(c,e[c],e);Object.assign(g,f)}}else g[c]=e[c];return g},{})}function ze(e,n,r=new Map){const g=Ve(e,n);return Se(g,r)}function ke(e={}){function n(u,y,p,l){if(typeof p=="number")return l[u].length===p;if(typeof p=="object"){const s=Object.keys(p)[0],T=p[s];if(s==="not")return Number(l[u].length)!==Number(T);if(s==="moreThan")return Number(l[u].length)>=Number(T);if(s==="lessThan")return Number(l[u].length)<=Number(T)}return!1}function r(u,y,p,l){return l[u]&&l[u].propertyValue&&String(l[u].propertyValue.value)===String(p)}const g=new Map([["length",n],["getProperty",r]]);Object.keys(e).reduce((u,y)=>(u.set(y,e[y]),u),g);function c(u,y){const p=u;return typeof y=="number"?[{target:p,operator:"length",param:null,value:Number(y)}]:typeof y=="boolean"?[{target:p,operator:"getProperty",param:u,value:!!y}]:typeof y=="object"?Object.keys(y).map(l=>{if(l==="length")return{target:p,operator:"length",param:null,value:y[l]};const s=l,T=y[l];return{target:p,operator:"getProperty",param:s,value:T}}):[]}function t(u){return Object.keys(u).reduce((p,l)=>{const s=c(l,u[l]);return p.push(...s),p},[])}function f(u,y){if(g.has(u.operator)){const p=g.get(u.operator);return p&&p(u.target,u.param,u.value,y)||!1}return!1}function m(u,y){return t(u).reduce((s,T)=>s&&f(T,y),!0)}function w(u,y){const p=Object.keys(u),l=p.includes("allOf"),s=p.includes("anyOf"),T=l||s,E=(T?u[T?l?"allOf":"anyOf":"allOf"]:[u]).map(k=>m(k,y));return l?!E.includes(!1):E.includes(!0)}return{parseValueSchema:w}}const De={},Ee={};ke();function Ce(e,n,r=new Map,g=(f,m,w,u)=>m,c={},t=f=>f){return ge[n.title]=n,me[n.title]=g,De[n.title]=c,Ee[n.title]=t,(f={})=>{const m=ze(f,n,r),w=Object.keys(e).reduce((u,y)=>(u[y]=e[y].default,u),{});return Object.assign(w,m)}}function Be(e,n){return{customClass:n.class,customStyle:n.style}}function Pe(e,n,r){return n}const $e=new Map([["appearance",Be]]),Le={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://farris-design.gitee.io/image-cropper.schema.json",title:"image-cropper",description:"A Farris Component",type:"object",properties:{id:{description:"The unique identifier for image-cropper",type:"string"},type:{description:"The type string of image-cropper",type:"string",default:"image-cropper"},appearance:{description:"",type:"object",properties:{class:{type:"string"},style:{type:"string"}},default:{}},binding:{description:"",type:"object",default:{}},disable:{type:"string",default:!1},editable:{description:"",type:"boolean",default:!0},placeholder:{description:"",type:"string",default:""},readonly:{description:"",type:"boolean",default:!1},require:{description:"",type:"boolean",default:!1},tabindex:{description:"",type:"number",default:-1},visible:{description:"",type:"boolean",default:!0}},required:["id","type"]},We={title:"image-cropper",description:"A Farris Component",type:"object",categories:{basic:{description:"Basic Infomation",title:"基本信息",properties:{id:{description:"组件标识",title:"标识",type:"string",readonly:!0},type:{description:"组件类型",title:"控件类型",type:"select",editor:{type:"waiting for modification",enum:[]}}}},behavior:{description:"Basic Infomation",title:"行为",properties:{readonly:{description:"",title:"只读",type:"string"},required:{description:"",title:"必填",type:"boolean"},visible:{description:"",title:"可见",type:"boolean"},placeholder:{description:"",title:"提示文本",type:"string"},tabindex:{description:"",title:"tab索引",type:"number"}}}}},K={format:{type:String,default:"png"},maintainAspectRatio:{type:Boolean,default:!0},transform:{type:Object,default:{scale:0,rotate:0,flipH:!1,flipV:!1}},aspectRatio:{type:Number,default:1},resizeToWidth:{type:Number,default:0},resizeToHeight:{type:Number,default:0},cropperMinWidth:{type:Number,default:0},cropperMinHeight:{type:Number,default:0},canvasRotation:{type:Number,default:0},roundCropper:{type:Boolean,default:!0},onlyScaleDown:{type:Boolean,default:!1},imageQuality:{type:Number,default:92},autoCrop:{type:Boolean,default:!0},backgroundColor:{type:String,default:""},containWithinAspectRatio:{type:Boolean,default:!1},hideResizeSquares:{type:Boolean,default:!1},loadImageErrorText:{type:String,default:"图片加载错误"},alignImage:{type:String,default:"center"},disabled:{type:Boolean,default:!1},imageURL:{type:String,default:"./src/assets/image01.png"},imageChangedEvent:{type:Object,default:null},imageBase64:{type:String,default:""},imageFile:{type:Object,default:null},cropper:{type:Object,default:{x1:-100,y1:-100,x2:1e4,y2:1e4}}},le=Ce(K,Le,$e,Pe,We);var ee=(e=>(e.Move="move",e.Resize="resize",e))(ee||{});function _e(){function e(c){switch(typeof c=="string"&&(c=n(c)),c){case 2:return{rotate:0,flip:!0};case 3:return{rotate:2,flip:!1};case 4:return{rotate:2,flip:!0};case 5:return{rotate:1,flip:!0};case 6:return{rotate:1,flip:!1};case 7:return{rotate:3,flip:!0};case 8:return{rotate:3,flip:!1};default:return{rotate:0,flip:!1}}}function n(c){const t=new DataView(r(c));if(t.getUint16(0,!1)!==65496)return-2;const f=t.byteLength;let m=2;for(;m<f;){if(t.getUint16(m+2,!1)<=8)return-1;const w=t.getUint16(m,!1);if(m+=2,w===65505){if(t.getUint32(m+=2,!1)!==1165519206)return-1;const u=t.getUint16(m+=6,!1)===18761;m+=t.getUint32(m+4,u);const y=t.getUint16(m,u);m+=2;for(let p=0;p<y;p++)if(t.getUint16(m+p*12,u)===274)return t.getUint16(m+p*12+8,u)}else{if((w&65280)!==65280)break;m+=t.getUint16(m,!1)}}return-1}function r(c){c=c.replace(/^data:([^;]+);base64,/gmi,"");const t=atob(c),f=t.length,m=new Uint8Array(f);for(let w=0;w<f;w++)m[w]=t.charCodeAt(w);return m.buffer}function g(c,t,f){const m=c.width,w=c.height;t=Math.round(t),f=Math.round(f);const u=m/t,y=w/f,p=Math.ceil(u/2),l=Math.ceil(y/2),s=c.getContext("2d");if(s){const T=s.getImageData(0,0,m,w),b=s.createImageData(t,f),{data:B}=T,E=b.data;for(let P=0;P<f;P++)for(let k=0;k<t;k++){const R=(k+P*t)*4,v=P*y;let A=0,h=0,x=0,U=0,F=0,z=0,V=0;const W=Math.floor(k*u),D=Math.floor(P*y);let q=Math.ceil((k+1)*u),G=Math.ceil((P+1)*y);q=Math.min(q,m),G=Math.min(G,w);for(let C=D;C<G;C++){const N=Math.abs(v-C)/l,re=k*u,ae=N*N;for(let _=W;_<q;_++){const j=Math.abs(re-_)/p,$=Math.sqrt(ae+j*j);if($>=1)continue;A=2*$*$*$-3*$*$+1;const H=4*(_+C*m);V+=A*B[H+3],x+=A,B[H+3]<255&&(A=A*B[H+3]/250),U+=A*B[H],F+=A*B[H+1],z+=A*B[H+2],h+=A}}E[R]=U/h,E[R+1]=F/h,E[R+2]=z/h,E[R+3]=V/x}c.width=t,c.height=f,s.putImageData(b,0,0)}}return{resizeCanvas:g,getTransformationsFromExifData:e}}function Re(e,n,r,g){function c(l,s){e.value.x2=e.value.x1+(e.value.y2-e.value.y1)*r.value,l=Math.max(e.value.x2-n.value.width,0),s=Math.max(0-e.value.y1,0),(l>0||s>0)&&(e.value.x2-=s*r.value>l?s*r.value:l,e.value.y1+=s*r.value>l?s:l/r.value)}function t(l,s){e.value.x2=e.value.x1+(e.value.y2-e.value.y1)*r.value,l=Math.max(e.value.x2-n.value.width,0),s=Math.max(e.value.y2-n.value.height,0),(l>0||s>0)&&(e.value.x2-=s*r.value>l?s*r.value:l,e.value.y2-=s*r.value>l?s:l/r.value)}function f(l,s){e.value.y1=e.value.y2-(e.value.x2-e.value.x1)/r.value,l=Math.max(0-e.value.x1,0),s=Math.max(0-e.value.y1,0),(l>0||s>0)&&(e.value.x1+=s*r.value>l?s*r.value:l,e.value.y1+=s*r.value>l?s:l/r.value)}function m(l,s){e.value.y1=e.value.y2-(e.value.x2-e.value.x1)/r.value,l=Math.max(e.value.x2-n.value.width,0),s=Math.max(0-e.value.y1,0),(l>0||s>0)&&(e.value.x2-=s*r.value>l?s*r.value:l,e.value.y1+=s*r.value>l?s:l/r.value)}function w(l,s){e.value.y2=e.value.y1+(e.value.x2-e.value.x1)/r.value,l=Math.max(e.value.x2-n.value.width,0),s=Math.max(e.value.y2-n.value.height,0),(l>0||s>0)&&(e.value.x2-=s*r.value>l?s*r.value:l,e.value.y2-=s*r.value>l?s:l/r.value)}function u(l,s){e.value.y2=e.value.y1+(e.value.x2-e.value.x1)/r.value,l=Math.max(0-e.value.x1,0),s=Math.max(e.value.y2-n.value.height,0),(l>0||s>0)&&(e.value.x1+=s*r.value>l?s*r.value:l,e.value.y2-=s*r.value>l?s:l/r.value)}function y(){e.value.x2=e.value.x1+(e.value.y2-e.value.y1)*r.value,e.value.y2=e.value.y1+(e.value.x2-e.value.x1)/r.value;const l=Math.max(0-e.value.x1,0),s=Math.max(e.value.x2-n.value.width,0),T=Math.max(e.value.y2-n.value.height,0),b=Math.max(0-e.value.y1,0);(l>0||s>0||T>0||b>0)&&(e.value.x1+=T*r.value>l?T*r.value:l,e.value.x2-=b*r.value>s?b*r.value:s,e.value.y1+=b*r.value>s?b:s/r.value,e.value.y2-=T*r.value>l?T:l/r.value)}function p(){if(n.value.width&&n.value.height)switch(g.position){case"top":c(0,0);break;case"bottom":t(0,0);break;case"topleft":f(0,0);break;case"topright":m(0,0);break;case"right":case"bottomright":w(0,0);break;case"left":case"bottomleft":u(0,0);break;case"center":y();break}}return{checkAspectRatio:p}}function pe(e,n){const{resizeCanvas:r,getTransformationsFromExifData:g}=_e(),c=i.inject("NotifyService"),t=i.ref(e.cropper),f=i.ref(e.transform),m=i.ref(e.cropperMinWidth),w=i.ref(e.maintainAspectRatio),u=i.ref(e.aspectRatio),y=i.ref(e.autoCrop),p=i.ref(e.backgroundColor),l=i.ref(e.resizeToWidth),s=i.ref(e.onlyScaleDown),T=i.ref(e.containWithinAspectRatio),b=i.ref(e.canvasRotation),B=i.ref(e.format),E=i.ref(e.imageQuality),P=i.ref(e.resizeToHeight),k=i.ref(e.cropperMinHeight),R=i.ref(""),v=i.ref(!0),A=i.ref(!0);let h,x,U=0,F,z,V;const W=i.ref(null),D=i.ref(""),q=i.ref(""),G=i.ref("0px"),C=i.ref(),N=i.ref({width:100,height:100}),re=ee;let ae,_=20,j=20,$=!1,H={rotate:0,flip:!1},M={active:!1,type:null,position:null,x1:0,y1:0,x2:0,y2:0,clientX:0,clientY:0};const ye=i.ref(e.imageChangedEvent),oe=i.ref(e.imageURL),Oe=i.ref(e.imageBase64),Ie=i.ref(e.imageFile);function qe(){q.value="scaleX("+(f.value.scale||1)*(f.value.flipH?-1:1)+")scaleY("+(f.value.scale||1)*(f.value.flipV?-1:1)+")rotate("+(f.value.rotate||0)+"deg)"}function Z(){A.value=!1,C.value=null,R.value="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=",M={active:!1,type:null,position:null,x1:0,y1:0,x2:0,y2:0,clientX:0,clientY:0},N.value={width:0,height:0},h={width:0,height:0},x={width:0,height:0},t.value.x1=-100,t.value.y1=-100,t.value.x2=1e4,t.value.y2=1e4}function Fe(a){return/image\/(png|jpg|jpeg|bmp|gif|tiff|webp)/.test(a)}function Qe(){if(b.value+=H.rotate,T.value&&h.width&&h.height){if(b.value%2){const d=h.width*u.value,S=h.height/u.value;return{width:Math.max(h.height,d),height:Math.max(h.width,S)}}const a=h.height*u.value,o=h.width/u.value;return{width:Math.max(h.width,a),height:Math.max(h.height,o)}}return b.value%2?{height:h.width,width:h.height}:{width:h.width,height:h.height}}function Ge(){b.value+=H.rotate;const a=Qe(),o=document.createElement("canvas");a.width&&a.height&&(o.width=a.width,o.height=a.height);const d=o.getContext("2d");return h.width&&h.height&&V&&(d==null||d.setTransform(H.flip?-1:1,0,0,1,o.width/2,o.height/2),d==null||d.rotate(Math.PI*(b.value/2)),d==null||d.drawImage(V,-h.width/2,-h.height/2)),o.toDataURL()}function Je(a){return new Promise(o=>{ae=a,R.value=a,C.value=new Image,C.value.onload=()=>{var d,S;x.width=(d=C.value)==null?void 0:d.naturalWidth,x.height=(S=C.value)==null?void 0:S.naturalHeight,o()},C.value.src=ae})}function Me(){if(!V||!V.complete||!H)return Promise.reject(new Error("No image loaded"));const a=Ge();return Je(a)}function se(a){const o=d=>{c.show({showCloseButton:!1,timeout:3e3,animate:"fadeIn",toasts:[{type:"string",title:"提示",msg:"图片上传错误,请重试"}]}),v.value=!1,$=!0,n.emit("loadImageFailed"),V=null,D.value=""};V=new Image,V.onload=()=>{D.value=a,H=g(a),h.width=V==null?void 0:V.naturalWidth,h.height=V==null?void 0:V.naturalHeight,Me().then(()=>{$=!1}).catch(o)},V.onerror=o,V.src=a}function Ze(a,o){Fe(o)?($=!1,se(a)):(c.show({showCloseButton:!1,timeout:3e3,animate:"fadeIn",toasts:[{type:"string",title:"提示",msg:"图片类型不正确,请重试"}]}),v.value=!1,$=!0,n.emit("loadImageFailed"))}function xe(a){const o=new FileReader;o.onload=d=>Ze(d.target.result,a.type),o.readAsDataURL(a)}function be(a){const o=new Image;o.onerror=()=>{c.show({showCloseButton:!1,timeout:3e3,animate:"fadeIn",toasts:[{type:"string",title:"提示",msg:"图片加载错误,请重试"}]}),v.value=!1,$=!0,n.emit("loadImageFailed")},o.onload=()=>{$=!1;const d=document.createElement("canvas"),S=d.getContext("2d");d.width=o.width,d.height=o.height,S==null||S.drawImage(o,0,0),se(d.toDataURL())},o.crossOrigin="anonymous",o.src=a}function Ye(){return W.value&&W.value&&W.value.offsetWidth>0}function ue(){if(W.value){const a=W.value;N.value.width=a.offsetWidth,N.value.height=a.offsetHeight,G.value="calc(50% - "+N.value.width/2+"px)"}}function Xe(){C.value&&N.value.width&&(_=m.value>0?Math.max(20,m.value/C.value.width*N.value.width):20)}function Ke(){w.value?j=Math.max(20,_/u.value):k.value>0&&C.value&&N.value.height?j=Math.max(20,k.value/C.value.height*N.value.height):j=20}function ce(){C.value?(Xe(),Ke()):(_=20,j=20)}function et(){const a=W.value,o=i.ref({x1:0,x2:0,y1:0,y2:0});if(a&&x.width&&x.height){const d=x.width/a.offsetWidth;o.value={x1:Math.round(t.value.x1*d),y1:Math.round(t.value.y1*d),x2:Math.round(t.value.x2*d),y2:Math.round(t.value.y2*d)},T.value||(o.value.x1=Math.max(o.value.x1,0),o.value.y1=Math.max(o.value.y1,0),o.value.x2=Math.min(o.value.x2,x.width),o.value.y2=Math.min(o.value.y2,x.height))}return o.value}function tt(){b.value+=H.rotate;const a=W.value,o=i.ref({x1:0,x2:0,y1:0,y2:0});if(a&&x.height&&x.width&&h.height&&h.width){const d=x.width/a.offsetWidth;let S,L;b.value%2?(S=(x.width-h.height)/2,L=(x.height-h.width)/2):(S=(x.width-h.width)/2,L=(x.height-h.height)/2),o.value={x1:Math.round(t.value.x1*d)-S,y1:Math.round(t.value.y1*d)-L,x2:Math.round(t.value.x2*d)-S,y2:Math.round(t.value.y2*d)-L},T.value||(o.value.x1=Math.max(o.value.x1,0),o.value.y1=Math.max(o.value.y1,0),o.value.x2=Math.min(o.value.x2,x.width),o.value.y2=Math.min(o.value.y2,x.height))}return o.value}function at(a,o){if(l.value>0){if(!s.value||a>l.value)return l.value/a}else if(P.value>0&&(!s.value||o>P.value))return P.value/o;return 1}function it(){return Math.min(1,Math.max(0,E.value/100))}function nt(a){return a.toDataURL("image/"+B.value,it())}function lt(){if(W.value&&W.value&&C.value!=null){const a=et(),o=a.x2-a.x1,d=a.y2-a.y1,S=document.createElement("canvas");S.width=o,S.height=d;const L=S.getContext("2d");if(L){p.value!=null&&(L.fillStyle=p.value,L.fillRect(0,0,o,d));const Q=(f.value.scale||1)*(f.value.flipH?-1:1),J=(f.value.scale||1)*(f.value.flipV?-1:1);x.width&&x.height&&(L.setTransform(Q,0,0,J,x.width/2,x.height/2),L.translate(-a.x1/Q,-a.y1/J),L.rotate((f.value.rotate||0)*Math.PI/180),L.drawImage(C.value,-x.width/2,-x.height/2));const O={width:o,height:d,imagePosition:a,cropperPosition:{...t.value}};T.value&&(O.offsetImagePosition=tt());const Y=at(o,d);return Y!==1&&(O.width=Math.round(o*Y),O.height=w.value?Math.round(O.width/u.value):Math.round(d*Y),r(S,O.width,O.height)),O.base64=nt(S),n.emit("imageCropped",O),O}}return null}function ie(){y.value&<()}function we(){const a=W.value;if(a){if(!w.value)t.value.x1=0,t.value.x2=a.offsetWidth,t.value.y1=0,t.value.y2=a.offsetHeight;else if(a.offsetWidth/u.value<a.offsetHeight){t.value.x1=0,t.value.x2=a.offsetWidth;const o=a.offsetWidth/u.value;t.value.y1=(a.offsetHeight-o)/2,t.value.y2=t.value.y1+o}else{t.value.y1=0,t.value.y2=a.offsetHeight;const o=a.offsetHeight*u.value;t.value.x1=(a.offsetWidth-o)/2,t.value.x2=t.value.x1+o}ie(),A.value=!0}}function Te(){U>40?(c.show({showCloseButton:!1,timeout:3e3,animate:"fadeIn",toasts:[{type:"string",title:"提示",msg:"图片加载超时,请重试"}]}),$=!0,v.value=!1,n.emit("loadImageFailed")):Ye()?($=!1,ue(),ce(),we(),n.emit("cropperReady",{...N.value})):(U++,setTimeout(()=>Te(),50))}function rt(){C.value!=null&&(v.value=!1,n.emit("imageLoaded"),U=0,setTimeout(()=>Te()))}function ot(){const a=W.value;(N.value.width!==(a==null?void 0:a.offsetWidth)||N.value.height!==(a==null?void 0:a.offsetHeight))&&N.value.width&&N.value.height&&a&&(t.value.x1=t.value.x1*a.offsetWidth/N.value.width,t.value.x2=t.value.x2*a.offsetWidth/N.value.width,t.value.y1=t.value.y1*a.offsetHeight/N.value.height,t.value.y2=t.value.y2*a.offsetHeight/N.value.height)}const st=()=>{ot(),ue(),ce()},Ae=()=>{clearTimeout(z),z=setTimeout(st,300)};i.onMounted(()=>{window.addEventListener("resize",Ae),oe.value&&(Z(),v.value=!0,be(oe.value))}),i.onUnmounted(()=>{window.removeEventListener("resize",Ae)});function ut(){M.active&&(M.active=!1,ie())}function fe(a){return(a.touches&&a.touches[0]?a.touches[0].clientX:a.clientX)||0}function he(a){return(a.touches&&a.touches[0]?a.touches[0].clientY:a.clientY)||0}function ct(a,o,d=null){M&&M.active||(a.preventDefault&&a.preventDefault(),M={active:!0,type:o,position:d,clientX:fe(a),clientY:he(a),...t.value})}function de(a=!1){t.value.x1<0&&(t.value.x2-=a?t.value.x1:0,t.value.x1=0),t.value.y1<0&&(t.value.y2-=a?t.value.y1:0,t.value.y1=0),t.value.x2>N.value.width&&(t.value.x1-=a?t.value.x2-N.value.width:0,t.value.x2=N.value.width),t.value.y2>N.value.height&&(t.value.y1-=a?t.value.y2-N.value.height:0,t.value.y2=N.value.height)}function ft(a){const o=fe(a)-M.clientX,d=he(a)-M.clientY;t.value.x1=M.x1+o,t.value.y1=M.y1+d,t.value.x2=M.x2+o,t.value.y2=M.y2+d}const{checkAspectRatio:ht}=Re(t,N,u,M);function dt(a){const o=fe(a)-M.clientX,d=he(a)-M.clientY;switch(M.position){case"left":t.value.x1=Math.min(M.x1+o,t.value.x2-_);break;case"topleft":t.value.x1=Math.min(M.x1+o,t.value.x2-_),t.value.y1=Math.min(M.y1+d,t.value.y2-j);break;case"top":t.value.y1=Math.min(M.y1+d,t.value.y2-j);break;case"topright":t.value.x2=Math.max(M.x2+o,t.value.x1+_),t.value.y1=Math.min(M.y1+d,t.value.y2-j);break;case"right":t.value.x2=Math.max(M.x2+o,t.value.x1+_);break;case"bottomright":t.value.x2=Math.max(M.x2+o,t.value.x1+_),t.value.y2=Math.max(M.y2+d,t.value.y1+j);break;case"bottom":t.value.y2=Math.max(M.y2+d,t.value.y1+j);break;case"bottomleft":t.value.x1=Math.min(M.x1+o,t.value.x2-_),t.value.y2=Math.max(M.y2+d,t.value.y1+j);break;case"center":const{scale:S}=a,L=Math.abs(M.x2-M.x1)*S,Q=Math.abs(M.y2-M.y1)*S,{x1:J}=t.value,{y1:O}=t.value;t.value.x1=Math.min(M.clientX-L/2,t.value.x2-_),t.value.y1=Math.min(M.clientY-Q/2,t.value.y2-j),t.value.x2=Math.max(M.clientX+L/2,J+_),t.value.y2=Math.max(M.clientY+Q/2,O+j);break}w.value&&ht()}function gt(a){M&&M.active&&(a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault(),clearTimeout(F),F=setTimeout(()=>{M.type===ee.Move?(ft(a),de(!0)):M.type===ee.Resize&&(dt(a),de(!1))},300))}return i.watch(ye,a=>{Z(),a&&a.target&&a.target.files&&a.target.files.length>0&&(v.value=!0,xe(a.target.files[0]))}),i.watch(oe,a=>{a?(Z(),v.value=!0,be(a)):(c.show({showCloseButton:!1,timeout:3e3,animate:"fadeIn",toasts:[{type:"string",title:"提示",msg:"图片路径为空"}]}),v.value=!1,$=!0)}),i.watch(Oe,a=>{Z(),v.value=!0,se(a)}),i.watch(Ie,a=>{Z(),a&&(v.value=!0,xe(a))}),i.watch(()=>[e.containWithinAspectRatio,e.canvasRotation,e.cropper,e.aspectRatio,e.transform,e.imageChangedEvent],([a,o,d,S,L,Q],[J,O,Y,mt,vt,pt])=>{V&&V.complete&&H&&(a!==J||o!==O)&&Me(),d!==Y&&(ue(),ce(),de(!1),ie()),S!==mt&&A.value&&we(),L!==vt&&(qe(),ie()),Q!==pt&&(ye.value=Q)}),{uploadError:$,imageVisible:A,backgroundColor:p,sourceImage:W,safeImgDataUrl:R,safeTransformStyle:q,maxSize:N,cropper:t,marginLeft:G,moveTypes:re,isLoading:v,startMove:ct,imageLoadedInView:rt,moveStop:ut,moveImg:gt}}const te=i.defineComponent({name:"FImageCropper",props:K,emits:["imageCropped","imageLoaded","cropperReady","loadImageFailed"],setup(e,n){const r=i.ref(e.alignImage),g=i.ref(e.roundCropper),c=i.ref(e.hideResizeSquares),t=i.ref(e.loadImageErrorText),f=i.ref(e.disabled),m=i.ref(null),{uploadError:w,imageVisible:u,backgroundColor:y,sourceImage:p,safeImgDataUrl:l,safeTransformStyle:s,maxSize:T,cropper:b,marginLeft:B,moveTypes:E,isLoading:P,startMove:k,imageLoadedInView:R,moveStop:v,moveImg:A}=pe(e,n);function h(z){return i.createVNode("span",{class:`farris-image-cropper-resize-bar ${z}`,onMousedown:i.withModifiers(V=>k(V,E.Resize,z),["prevent"])},null)}function x(z){return i.createVNode("div",null,[i.createVNode("span",{class:`farris-image-cropper-resize-bar ${z}`,onMousedown:i.withModifiers(V=>k(V,E.Resize,z),["prevent"])},[i.createVNode("span",{class:"farris-image-cropper-square"},null)]),i.createVNode("span",{class:"farris-image-cropper-resize top"},[i.createVNode("span",{class:"farris-image-cropper-square"},null)])])}const U=["top","right","bottom","left"].map(z=>h(z)),F=["topleft","topright","bottomright","bottomleft"].map(z=>x(z));return()=>i.createVNode("div",{class:["farris-image-cropper-frame",{"farris-image-cropper-disabled":f.value}],style:{"text-align":r.value},onMousemove:i.withModifiers(z=>A(z),["prevent"]),onTouchmove:i.withModifiers(z=>A(z),["prevent"]),onMouseup:i.withModifiers(()=>v(),["prevent"]),onTouchend:i.withModifiers(()=>v(),["prevent"])},[!w&&i.createVNode("div",{ref:m,class:"farris-image-cropper",style:[{background:u.value?y.value:""}]},[l.value&&i.createVNode("img",{title:"farris-source-image",ref:p,class:"farris-source-image",style:[{visibility:u.value?"visible":"hidden"},{transform:s.value}],src:l.value,onLoad:()=>R()},null),T.value&&i.createVNode("div",{class:"farris-image-overlay",style:[{width:`${T.value.width||0}px`},{height:`${T.value.height||0}px`},{"margin-left":r.value==="center"?B.value:""}]},null),u.value&&i.createVNode("div",{class:["farris-image-cropper-wrapper",{"farris-image-cropper-rounded":g.value}],style:[{top:`${b.value.y1}px`},{left:`${b.value.x1}px`},{width:`${b.value.x2-b.value.x1}px`},{height:`${b.value.y2-b.value.y1}px`},{visibility:u.value?"visible":"hidden"},{"margin-left":r.value==="center"?B.value:""}],tabindex:"0"},[i.createVNode("div",{class:"farris-image-cropper-move",onMousedown:i.withModifiers(z=>k(z,E.Move,"topleft"),["prevent"])},null),!c.value&&i.createVNode("div",null,[F,U])])]),P.value&&i.createVNode("div",{class:"farris-image-cropper-loading"},[i.createVNode("div",{class:"farris-image-cropper-loading-spinner"},null)]),w&&i.createVNode("div",{class:"farris-image-cropper-error"},[t.value])])}});function je(e,n,r){var R;const g="",c="",t=i.ref();function f(){return(n==null?void 0:n.schema.componentType)!=="frame"}function m(){return!1}function w(){return(n==null?void 0:n.schema.componentType)!=="frame"}function u(){return(n==null?void 0:n.schema.componentType)==="frame"}function y(v){if(!v||!v.value)return null;if(v.value.schema&&v.value.schema.type==="component")return v.value;const A=i.ref(v==null?void 0:v.value.parent),h=y(A);return h||null}function p(v=n){const{componentInstance:A,designerItemElementRef:h}=v;return!A||!A.value?null:A.value.canMove?h:p(v.parent)}function l(v){return!!r}function s(){return(n==null?void 0:n.schema.label)||(n==null?void 0:n.schema.title)||(n==null?void 0:n.schema.name)}function T(){}function b(v,A){}function B(v,A){const{componentType:h}=v;let x=ve(h,v,A);const U=h.toLowerCase().replace(/-/g,"_");return x&&!x.id&&x.type===h&&(x.id=`${U}_${Math.random().toString().slice(2,6)}`),x}function E(v){}function P(...v){}function k(){n!=null&&n.schema.contents&&n.schema.contents.map(v=>{var x;let A=v.id;v.type==="component-ref"&&(A=v.component);const h=e.value.querySelector(`#${A}-design-item`);(x=h==null?void 0:h.componentInstance)!=null&&x.value.onRemoveComponent&&h.componentInstance.value.onRemoveComponent()})}return t.value={canMove:f(),canSelectParent:m(),canDelete:w(),canNested:!u(),contents:n==null?void 0:n.schema.contents,elementRef:e,parent:(R=n==null?void 0:n.parent)==null?void 0:R.componentInstance,schema:n==null?void 0:n.schema,styles:g,designerClass:c,canAccepts:l,getBelongedComponentInstance:y,getDraggableDesignItemElement:p,getDraggingDisplayText:s,getPropConfig:P,getDragScopeElement:T,onAcceptMovedChildElement:b,onChildElementMovedOut:E,addNewChildComponentSchema:B,triggerBelongedComponentToMoveWhenMoved:i.ref(!1),triggerBelongedComponentToDeleteWhenDeleted:i.ref(!1),onRemoveComponent:k},t}const He=i.defineComponent({name:"FImageCropperDesign",props:K,emits:["imageCropped","imageLoaded","cropperReady","loadImageFailed"],setup(e,n){const r=i.ref(e.alignImage),g=i.ref(e.roundCropper),c=i.ref(e.hideResizeSquares),t=i.ref(e.loadImageErrorText),f=i.ref(e.disabled),m=i.ref(null),{uploadError:w,imageVisible:u,backgroundColor:y,sourceImage:p,safeImgDataUrl:l,safeTransformStyle:s,maxSize:T,cropper:b,marginLeft:B,moveTypes:E,isLoading:P,startMove:k,imageLoadedInView:R,moveStop:v,moveImg:A}=pe(e,n),h=i.ref(),x=i.inject("design-item-context"),U=je(h,x);i.onMounted(()=>{h.value.componentInstance=U}),n.expose(U.value);function F(D){return i.createVNode("span",{class:`farris-image-cropper-resize-bar ${D}`,onMousedown:i.withModifiers(q=>k(q,E.Resize,D),["prevent"])},null)}function z(D){return i.createVNode("div",null,[i.createVNode("span",{class:`farris-image-cropper-resize-bar ${D}`,onMousedown:i.withModifiers(q=>k(q,E.Resize,D),["prevent"])},[i.createVNode("span",{class:"farris-image-cropper-square"},null)]),i.createVNode("span",{class:"farris-image-cropper-resize top"},[i.createVNode("span",{class:"farris-image-cropper-square"},null)])])}const V=["top","right","bottom","left"].map(D=>F(D)),W=["topleft","topright","bottomright","bottomleft"].map(D=>z(D));return()=>i.createVNode("div",{ref:h,class:["farris-image-cropper-frame",{"farris-image-cropper-disabled":f.value}],style:{"text-align":r.value},onMousemove:i.withModifiers(D=>A(D),["prevent"]),onTouchmove:i.withModifiers(D=>A(D),["prevent"]),onMouseup:i.withModifiers(()=>v(),["prevent"]),onTouchend:i.withModifiers(()=>v(),["prevent"])},[!w&&i.createVNode("div",{ref:m,class:"farris-image-cropper",style:[{background:u.value?y.value:""}]},[l.value&&i.createVNode("img",{title:"farris-source-image",ref:p,class:"farris-source-image",style:[{visibility:u.value?"visible":"hidden"},{transform:s.value}],src:l.value,onLoad:()=>R()},null),T.value&&i.createVNode("div",{class:"farris-image-overlay",style:[{width:`${T.value.width||0}px`},{height:`${T.value.height||0}px`},{"margin-left":r.value==="center"?B.value:""}]},null),u.value&&i.createVNode("div",{class:["farris-image-cropper-wrapper",{"farris-image-cropper-rounded":g.value}],style:[{top:`${b.value.y1}px`},{left:`${b.value.x1}px`},{width:`${b.value.x2-b.value.x1}px`},{height:`${b.value.y2-b.value.y1}px`},{visibility:u.value?"visible":"hidden"},{"margin-left":r.value==="center"?B.value:""}],tabindex:"0"},[i.createVNode("div",{class:"farris-image-cropper-move",onMousedown:i.withModifiers(D=>k(D,E.Move,"topleft"),["prevent"])},null),!c.value&&i.createVNode("div",null,[W,V])])]),P.value&&i.createVNode("div",{class:"farris-image-cropper-loading"},[i.createVNode("div",{class:"farris-image-cropper-loading-spinner"},null)]),w&&i.createVNode("div",{class:"farris-image-cropper-error"},[t.value])])}}),Ue={install(e){e.component(te.name,te)},register(e,n,r,g){e["image-cropper"]=te,n["image-cropper"]=le},registerDesigner(e,n,r){e["image-cropper"]=He,n["image-cropper"]=le}};I.ImageCropper=te,I.default=Ue,I.imageCropperProps=K,I.propsResolver=le,Object.defineProperties(I,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|