amotify 0.2.95 → 0.2.96
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/dist/fn/Cropper.js +1 -1
- package/dist/fn/Input/Autocomplete.js +1 -1
- package/dist/fn/Input/core.js +1 -1
- package/dist/fn/RootViewController.js +1 -1
- package/dist/fn/Snackbar.js +1 -1
- package/dist/fn/SwipeView.js +1 -1
- package/dist/fn/Table/Data.js +1 -1
- package/dist/fn/Tips.js +1 -1
- package/package.json +2 -2
package/dist/fn/Cropper.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as H,c as G,e as z}from"../chunk-C5N2D3ZX.js";import{Fragment as ie,jsx as o,jsxs as f}from"react/jsx-runtime";import S,{UUID as J,useStore as X}from"jmini";import{$$fromRoot as K}from"../@utils";import{useState as N,useEffect as O}from"react";import{Box as B,FAI as M,Column as k}from"../atoms";import{Row as I,Text as F}from"../mols";import{Button as P}from"./Button";import A from"./Sheet";import V from"./Loader";import q from"./Input";import{faPalette as Q}from"@fortawesome/free-solid-svg-icons/faPalette";import{faBarsStaggered as ee}from"@fortawesome/free-solid-svg-icons/faBarsStaggered";import{faRotateLeft as te}from"@fortawesome/free-solid-svg-icons/faRotateLeft";import{faRotateRight as ae}from"@fortawesome/free-solid-svg-icons/faRotateRight";import{CropperClasses as U}from"../@styles/componentClasses";import Y from"./Tooltips";class re{constructor(t){this.set_scale=t.set_scale,this.val_file=t.val_file,this.develops=t.develops,this.use=t.use,this.componentID=t.componentID,this.scale={current:t.scale.default,default:t.scale.default,min:t.scale.min,max:t.scale.max};let n=t.canvas;this.Canvas={elm:n,ctx:n.getContext("2d")};let i=t.picture.image,{width:e,height:a}=i,r=e/a;this.Picture={elm:i,originDataUrl:i.src,aspect:r,revisedAspect:1,rotate:t.picture.rotate,grayScale:t.picture.grayScale,tone:t.picture.tone},this.pst={frame:{x:0,y:0,w:0,h:0,aspect:1},outImage:{x:0,y:0,w:0,h:0},imageX:e/2,imageY:a/2,centerX:0,centerY:0},this.dragEffectInfo={origin:{x:0,y:0},frameExpandRate:{x:0,y:0}},this.pinchEffectInfo={origin:{x:0,y:0,scale:this.scale.current}},this.frameSizing(),this.modifyImage()}frameSizing(){let t=this.Canvas.elm,n=this.Picture.elm,i=0,e=0;if(this.use=="square"){let s=t.width/3*2,l=t.height/3*2;i=Math.min(s,l),e=i}else this.use=="wallpaper.horizontal"?(i=t.width*(7/9),e=i/3):this.use=="wallpaper.vertical"&&(e=t.height*(7/9),i=e/2);let{width:a,height:r}=n,p=(t.width-i)/2,u=(t.height-e)/2,C=i/e;this.pst={frame:{x:p,y:u,w:i,h:e,aspect:C},outImage:{x:0,y:0,w:0,h:0},imageX:a/2,imageY:r/2,centerX:t.width/2,centerY:t.height/2}}dragEffect(t){let{eventType:n,x:i,y:e}=t;if(n=="start"){let a=this.Canvas.elm.position();this.dragEffectInfo={origin:{x:i,y:e},frameExpandRate:{x:this.Canvas.elm.width/a.width,y:this.Canvas.elm.height/a.height}}}else{let{origin:a,frameExpandRate:r}=this.dragEffectInfo,p=a.x-i,u=a.y-e,C=this.scale.current*this.Picture.revisedAspect/100,s=p/C*r.x,l=u/C*r.y;n=="move"?this.drawImage(this.pst.imageX+s,this.pst.imageY+l):n=="end"&&this.drawImage(this.pst.imageX+=s,this.pst.imageY+=l)}}pinchEffect(t){let{eventType:n,event:i}=t,{x:e,y:a}=S.getCursor(i.touches[0]),{x:r,y:p}=S.getCursor(i.touches[1]),u=r-e,C=p-a;if(n=="start")this.pinchEffectInfo.origin={x:u,y:C,scale:this.scale.current};else if(n=="move"){let{origin:s}=this.pinchEffectInfo,l=Math.sqrt(Math.pow(s.x,2)+Math.pow(s.y,2)),y=Math.sqrt(Math.pow(u,2)+Math.pow(C,2))/l,v=Number(s.scale*y);this.set_scale(v)}}updateScale(t){let n=t;n=Math.max(n,this.scale.min),n=Math.min(n,this.scale.max),this.scale.current=n,this.drawImage()}updateFilter(t){this.Picture.grayScale=t.grayScale,this.Picture.tone=t.tone,this.Picture.rotate=t.rotate,this.modifyImage()}modifyImage(){return z(this,null,function*(){let{grayScale:t,tone:n,rotate:i}=this.Picture;const e=document.createElement("canvas");let a=e.getContext("2d"),r=yield S.ImageLoader(this.Picture.originDataUrl),p=r.width,u=r.height;(i==90||i==270)&&(p=r.height,u=r.width),e.width=p,e.height=u,t&&(a.filter="grayscale("+t+"%)"),i&&(a.translate(p/2,u/2),a.rotate(i*Math.PI/180),[90,270].includes(i)?a.translate(-u/2,-p/2):a.translate(-p/2,-u/2)),a.drawImage(r,0,0,r.width,r.height);let C=a.getImageData(0,0,e.width,e.height),s=C.data;{t/=100;let v=[[255,255,255],[255,200,100],[170,170,255],[240,200,145],[128,255,255],[255,128,255],[255,255,128],[128,158,169],[128,112,162],[50,192,87],[246,100,140]][n],x=v[0]/255,b=v[1]/255,c=v[2]/255;for(let m=0;m<u;m++)for(let h=0;h<p;h++){var l=(m*p+h)*4;if(t){let R=.3*s[l]+.59*s[l+1]+.11*s[l+2];for(var g=0;g<3;g++){let T=s[l+g];s[l+g]=T+(R-T)*t}}s[l]*=x,s[l+1]*=b,s[l+2]*=c}}a.putImageData(C,0,0);let y=e.toDataURL("image/jpeg");{let v=yield S.ImageLoader(y),{width:x,height:b}=v,c=x/b;this.Picture=G(H({},this.Picture),{elm:v,aspect:c,revisedAspect:this.pst.frame.aspect>c?this.pst.frame.w/x:this.pst.frame.h/b})}this.drawImage()})}drawImage(t,n){let{use:i,Canvas:{ctx:e,elm:a},pst:{frame:r}}=this,p=t||this.pst.imageX,u=n||this.pst.imageY;{let C=this.scale.current/100,s=this.Picture.revisedAspect*C,l=this.pst.centerX-p*s,g=this.pst.centerY-u*s,y=this.Picture.elm.width*s,v=this.Picture.elm.height*s;{let x=this.pst.frame.x+this.pst.frame.w-y,b=this.pst.frame.x,c=this.pst.frame.y+this.pst.frame.h-v,m=this.pst.frame.y,h=0;l<x&&(h=l-x),l>b&&(h=l-b);let R=0;g<c&&(R=g-c),g>m&&(R=g-m),this.dragEffectInfo.origin.x+=h/2/this.dragEffectInfo.frameExpandRate.x,this.dragEffectInfo.origin.y+=R/2/this.dragEffectInfo.frameExpandRate.y,l=Math.min(Math.max(l,x),b),g=Math.min(Math.max(g,c),m)}this.pst.outImage={x:l,y:g,w:y,h:v},e.clearRect(0,0,this.Canvas.elm.width,this.Canvas.elm.height),e.drawImage(this.Picture.elm,0,0,this.Picture.elm.width,this.Picture.elm.height,l,g,y,v)}{if(i=="square"){e.fillStyle="rgba( 20,24,20,.3 )",e.beginPath();let l=a.width/3*2,g=a.height/3*2,y=Math.min(l,g),v=Math.max(l,g);e.arc(a.width/2,a.height/2,v,0,Math.PI*2,!0),e.arc(a.width/2,a.height/2,y/2,0,Math.PI*2,!1),e.closePath(),e.fill()}else(i=="wallpaper.horizontal"||i=="wallpaper.vertical")&&(e.fillStyle="rgba( 20,24,20,.3 )");e.beginPath(),e.moveTo(0,0),e.lineTo(a.width,0),e.lineTo(a.width,a.height),e.lineTo(0,a.height),e.lineTo(0,0),e.closePath(),e.lineTo(r.x,r.y),e.lineTo(r.x,r.y+r.h),e.lineTo(r.x+r.w,r.y+r.h),e.lineTo(r.x+r.w,r.y),e.lineTo(r.x,r.y),e.fill();let s=S(document.body).getStyleProperty("--color-theme-hsl");e.lineWidth=4,e.strokeStyle=`hsla( ${s},1 )`,e.strokeRect(r.x,r.y,r.w,r.h)}}export(){return z(this,null,function*(){let{Canvas:t,develops:n,Picture:i,pst:{outImage:e,frame:a}}=this,r=e.w/i.elm.width,p=e.h/i.elm.height,u=(a.x-e.x)/r,C=(a.x-e.x+a.w)/r,s=(a.y-e.y)/p,l=(a.y-e.y+a.h)/p,g=Array.from({length:n.length}),y="image/jpeg";for(let v=0;v<n.length;v++){let{size:x,maxSize:b}=n[v];b=b||{S:1024*20,R:1024*100,L:1024*350}[x];let c={S:140,R:600,L:1200}[x],m=c;this.use=="wallpaper.horizontal"?m=c/3:this.use=="wallpaper.vertical"&&(m=c*2);let h=document.createElement("canvas");h.width=c,h.height=m;let R=h.getContext("2d");if(!R)return;R.clearRect(0,0,c,m),R.drawImage(this.Picture.elm,u,s,C-u,l-s,0,0,c,m);let T=h.toDataURL(y),w=yield T.toBlob(y);if(!w)return;if(w.size>=b){let L=b/w.size;if(T=h.toDataURL(y,L*.92),w=yield T.toBlob(y),!w)return}let W=new File([w],this.val_file.name,{type:y});g[v]=W}return g})}}const Z={Core:d=>{let{val_file:t,options:n,finishedCallback:i,abortCallback:e}=d,{use:a,develops:r=[]}=n,[p]=N(J());const u={scale:{default:120,min:100,max:400},rotate:0,grayScale:0,tone:0};let[C,s]=N(u.scale.default),[l,g]=N(u.rotate),[y,v]=N(u.grayScale),[x,b]=N(u.tone);return O(()=>{let c="CropperResize";return S(window).addEvent({eventType:"resize",eventID:c,callback:()=>{S.cycle(()=>{var L;let m=K("#Canvas-"+p)[0];if(!m)return;let h=(L=X.get(p))==null?void 0:L.Instance;if(!h)return;let R=m.position(),T=R.width/R.height;m.width=2400,m.height=2400/T;let{width:w,height:W}=m;h.pst.centerX=w/2,h.pst.centerY=W/2,h.frameSizing(),h.modifyImage()},250,"CropperResize").once()}}),()=>{S(window).removeEvent(c)}},[]),O(()=>{X.set({[p]:{}}),z(void 0,null,function*(){V.fn.corner.active(),yield S.pending(()=>{},400);let{target:c}=yield t.convert();if(!c)return;let m=c.result,h=K("#Canvas-"+p)[0];if(!h)return;let R=h.position(),T=R.width/R.height;h.width=2400,h.height=2400/T;let w=new re({set_scale:s,val_file:t,develops:r,use:a,scale:u.scale,componentID:p,canvas:h,picture:{image:yield S.ImageLoader(m),grayScale:u.grayScale,tone:u.tone,rotate:u.rotate}});X.set({[p]:{Instance:w}});const W=function(E){if(E.preventDefault(),E.touches&&E.touches.length>1)w.pinchEffect({eventType:"start",event:E}),S(document).addEvent({eventType:"touchmove",eventID:"CropperEffectMove",options:{passive:!1},callback:D=>{D.preventDefault(),w.pinchEffect({eventType:"move",event:D})}}).addEvent({eventType:"touchend",eventID:"CropperEffectEnd",options:{passive:!1},callback:j});else{w.dragEffect(H({eventType:"start"},S.getCursor(E)));let{type:D}=E;S(document).addEvent({eventType:D=="touchstart"?"touchmove":"mousemove",eventID:"CropperEffectMove",options:{passive:!1},callback:_=>{L("move",_)}}).addEvent({eventType:D=="touchstart"?"touchend":"mouseup",eventID:"CropperEffectEnd",options:{passive:!1},callback:_=>{L("end",_),j(_)}})}},L=function(E,D){D.preventDefault(),w.dragEffect(H({eventType:E},S.getCursor(D)))},j=function(E){E.preventDefault(),S(document).removeEvent(["CropperEffectMove","CropperEffectEnd"])};S(h).removeEvent(["CropperMouseWheel","CropperTouchStart","CropperMouseDown"]).addEvent({eventID:"CropperMouseWheel",eventType:"wheel",callback:E=>{E.preventDefault();let D=Number(E.wheelDelta*.04),_=w.scale.current+D;_=Math.max(_,w.scale.min),_=Math.min(_,w.scale.max),s(_)},options:{passive:!1}}).addEvent({eventType:"touchstart",eventID:"CropperTouchStart",callback:W,options:{passive:!1}}).addEvent({eventType:"mousedown",eventID:"CropperMouseDown",callback:W,options:{passive:!1}}),setTimeout(()=>{V.fn.corner.stop()},1e3)})},[t.id]),O(()=>{var m;let c=(m=X.get(p))==null?void 0:m.Instance;c&&c.updateScale(C)},[C]),O(()=>{var m;let c=(m=X.get(p))==null?void 0:m.Instance;c&&c.updateFilter({grayScale:y,tone:x,rotate:l})},[y,x,l]),o(A.Body,{borderRadius:0,height:"viewHeight",width:"viewWidth",children:f(k,{className:[U("Wrap"),U("Use_"+a)].join(" "),gap:0,height:1,position:"relative",overflow:"hidden",borderRadius:"inherit",children:[o(B,{flexSizing:0,overflow:"hidden",position:"relative",backgroundColor:"black",flexCenter:!0,freeCSS:{zIndex:1},children:o("canvas",{style:{width:"100%",height:"100%"},width:2400,height:2400,className:U("Canvas"),id:"Canvas-"+p})}),f(I.Separate,{borderTop:!0,flexSizing:"none",backgroundColor:"layer.1",padding:1,verticalAlign:"unset",UnderBreakPointStyles:{flexType:"col"},children:[o(Z.SettingRegion,{DefaultOptions:u,val_scale:C,set_scale:s,val_tone:x,set_tone:b,val_grayScale:y,set_grayScale:v,val_rotate:l,set_rotate:g}),f(I.Right,{flexSizing:"none",children:[o(P.Border,{isRounded:!0,onClick:()=>{e()},children:"\u9589\u3058\u308B"}),o(P,{isRounded:!0,boxShadow:"3.remark",onClick:()=>z(void 0,null,function*(){var h;let c=(h=X.get(p))==null?void 0:h.Instance;if(!c)return;V.fn.mini.active("CropperExportation");let m=yield c.export();setTimeout(()=>{V.fn.mini.stop("CropperExportation"),i(m)},3e3)}),children:f(I.Center,{gap:"1/2",children:[o(V.White.R,{loaderID:"CropperExportation"}),"\u6C7A\u5B9A"]})})]})]})]})})},SettingRegion:d=>{let t=["","\u6696\u8272","\u5BD2\u8272","\u30BB\u30D4\u30A2","\u30B7\u30A2\u30F3","\u30DE\u30BC\u30F3\u30BF","\u30A4\u30A8\u30ED\u30FC","\u30AA\u30EA\u30B8\u30CA\u30EB1","\u30AA\u30EA\u30B8\u30CA\u30EB2","\u30AA\u30EA\u30B8\u30CA\u30EB3","\u30AA\u30EA\u30B8\u30CA\u30EB4"],n=i=>t[i]||"\u306A\u3057";return f(I.Left,{verticalAlign:"unset",flexWrap:!0,children:[f(k,{gap:"1/3",children:[o(F.Supplement,{children:"Rotate"}),f(I.Left,{flexChilds:"even",gap:"1/6",children:[o(P.Border.S,{isRounded:!0,borderTopRightRadius:0,borderBottomRightRadius:0,onClick:()=>{let i=d.val_rotate-90;i<0&&(i+=360),d.set_rotate(i)},children:f(I.Center,{gap:"1/4",children:["90\xB0",o(M,{icon:te})]})}),o(P.Border.S,{isRounded:!0,borderTopLeftRadius:0,borderBottomLeftRadius:0,onClick:()=>{d.set_rotate((d.val_rotate+90)%360)},children:f(I.Center,{gap:"1/4",children:[o(M,{icon:ae}),"90\xB0"]})})]})]}),f(k,{gap:"1/3",freeCSS:{minWidth:12*6},children:[o(F.Supplement,{children:"Zoom"}),f(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:i=>{let e="CropperZoomEdit";Y.open({tipsID:e,gravityPoint:3,event:i,closeAtParentBlur:!1,freeCSS:{minWidth:12*26},content:o(A.Body,{children:f(k,{padding:1.5,children:[f(I.Separate,{children:[o(F.Paragraph,{children:f(I.Center,{gap:"1/2",children:[o(M.Search,{fontColor:"5.translucent"}),"Zoom"]})}),o(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(e)},children:o(M.Times,{})})]}),o(B,{borderBottom:!0,opacity:"low"}),o(q.Slider,{override:"force",value:d.val_scale-100,min:d.DefaultOptions.scale.min-100,max:d.DefaultOptions.scale.max-100,step:25,onUpdateValidValue:({eventType:a,value:r})=>{S.cycle(()=>{d.set_scale(r+100)},250,"Cropper.UpdateScale").once()},legends:{enable:!0,custom:a=>"x"+Math.round(100+a)/100}})]})})})},children:[d.val_scale.rate(1,0),"%"]})]}),f(k,{gap:"1/3",freeCSS:{minWidth:12*6},children:[o(F.Supplement,{children:"GrayScale"}),f(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:i=>{let e="CropperGrayScaleEdit";Y.open({tipsID:e,gravityPoint:3,event:i,closeAtParentBlur:!1,freeCSS:{minWidth:12*26},content:o(A.Body,{children:f(k,{padding:1.5,children:[f(I.Separate,{children:[o(F.Paragraph,{children:f(I.Center,{gap:"1/2",children:[o(M,{icon:Q,fontColor:"5.translucent"}),"Gray Scale"]})}),o(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(e)},children:o(M.Times,{})})]}),o(B,{borderBottom:!0,opacity:"low"}),o(q.Slider,{value:d.val_grayScale,min:0,max:100,step:10,onUpdateValidValue:({value:a})=>{S.cycle(()=>{d.set_grayScale(a)},250,"Cropper.GrayScale").once()},legends:{enable:!0,custom:a=>a+"%"}})]})})})},children:[d.val_grayScale.rate(1,0),"%"]})]}),f(k,{gap:"1/3",freeCSS:{minWidth:12*6},children:[o(F.Supplement,{children:"Tone"}),o(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:i=>{let e="CropperToneEdit";Y.open({tipsID:e,gravityPoint:3,event:i,closeAtParentBlur:!1,freeCSS:{minWidth:12*26,maxWidth:12*24},content:()=>{let a=[];for(let r=1;r<=10;r++)a.push({value:r,label:f(ie,{children:[o(B,{ssSphere:1,className:[U("ToneBall"),U("ToneBall_"+r)].join(" ")}),o(B,{textAlign:"left",flexSizing:0,children:n(r)})]})});return o(A.Body,{children:f(k,{padding:1.5,children:[f(I.Separate,{children:[o(F.Paragraph,{children:f(I.Center,{gap:"1/2",children:[o(M,{icon:ee,fontColor:"5.translucent"}),"Tone"]})}),o(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(e)},children:o(M.Times,{})})]}),o(B,{borderBottom:!0,opacity:"low"}),o(q.Radio.Normal,{value:d.val_tone,gap:"1/2",cellStyles:{fontColor:"3.blur"},options:[{value:0,label:o(B,{flexSizing:0,textAlign:"center",children:"\u306A\u3057"})},...a],onUpdateValidValue:({value:r})=>{d.set_tone(r)}})]})})}})},children:f(I.Center,{gap:"1/2",children:[o(B,{boxShadow:"2.remark",ssSphere:1,className:[U("ToneBall"),U("ToneBall_"+d.val_tone)].join(" ")}),n(d.val_tone)]})})]})]})}},$={openDialogNEdit:d=>z(void 0,null,function*(){let t=yield q.Filer.fn.openDialog({accept:"image",multiple:!1});$.openEditor(H({imageFile:t[0]},d))}),openEditor:d=>z(void 0,null,function*(){let t="CropperImage";A.open({sheetID:t,type:"normal.middleCenter",size:"MAX",padding:0,margin:0,freeCSS:{maxWidth:"100vw"},content:o(Z.Core,{val_file:d.imageFile,options:d,finishedCallback:n=>{A.close(t),d.onProcessFinished(n)},abortCallback:()=>{A.close(t)}}),closeAtEscapeKeyDown:!1})})};export{$ as Cropper,$ as default};
|
|
1
|
+
import{b as H,c as G,e as z}from"../chunk-C5N2D3ZX.js";import{Fragment as ie,jsx as o,jsxs as f}from"react/jsx-runtime";import S,{UUID as J,useStore as X}from"jmini";import{$$fromRoot as K}from"../@utils";import{useState as N,useEffect as O}from"react";import{Box as B,FAI as M,Column as k}from"../atoms";import{Row as I,Text as F}from"../mols";import{Button as P}from"./Button";import A from"./Sheet";import V from"./Loader";import q from"./Input";import{faPalette as Q}from"@fortawesome/free-solid-svg-icons/faPalette";import{faBarsStaggered as ee}from"@fortawesome/free-solid-svg-icons/faBarsStaggered";import{faRotateLeft as te}from"@fortawesome/free-solid-svg-icons/faRotateLeft";import{faRotateRight as ae}from"@fortawesome/free-solid-svg-icons/faRotateRight";import{CropperClasses as U}from"../@styles/componentClasses";import Y from"./Tooltips";class re{constructor(t){this.set_scale=t.set_scale,this.val_file=t.val_file,this.develops=t.develops,this.use=t.use,this.componentID=t.componentID,this.scale={current:t.scale.default,default:t.scale.default,min:t.scale.min,max:t.scale.max};let n=t.canvas;this.Canvas={elm:n,ctx:n.getContext("2d")};let i=t.picture.image,{width:e,height:a}=i,r=e/a;this.Picture={elm:i,originDataUrl:i.src,aspect:r,revisedAspect:1,rotate:t.picture.rotate,grayScale:t.picture.grayScale,tone:t.picture.tone},this.pst={frame:{x:0,y:0,w:0,h:0,aspect:1},outImage:{x:0,y:0,w:0,h:0},imageX:e/2,imageY:a/2,centerX:0,centerY:0},this.dragEffectInfo={origin:{x:0,y:0},frameExpandRate:{x:0,y:0}},this.pinchEffectInfo={origin:{x:0,y:0,scale:this.scale.current}},this.frameSizing(),this.modifyImage()}frameSizing(){let t=this.Canvas.elm,n=this.Picture.elm,i=0,e=0;if(this.use=="square"){let s=t.width/3*2,l=t.height/3*2;i=Math.min(s,l),e=i}else this.use=="wallpaper.horizontal"?(i=t.width*(7/9),e=i/3):this.use=="wallpaper.vertical"&&(e=t.height*(7/9),i=e/2);let{width:a,height:r}=n,p=(t.width-i)/2,u=(t.height-e)/2,C=i/e;this.pst={frame:{x:p,y:u,w:i,h:e,aspect:C},outImage:{x:0,y:0,w:0,h:0},imageX:a/2,imageY:r/2,centerX:t.width/2,centerY:t.height/2}}dragEffect(t){let{eventType:n,x:i,y:e}=t;if(n=="start"){let a=this.Canvas.elm.position();this.dragEffectInfo={origin:{x:i,y:e},frameExpandRate:{x:this.Canvas.elm.width/a.width,y:this.Canvas.elm.height/a.height}}}else{let{origin:a,frameExpandRate:r}=this.dragEffectInfo,p=a.x-i,u=a.y-e,C=this.scale.current*this.Picture.revisedAspect/100,s=p/C*r.x,l=u/C*r.y;n=="move"?this.drawImage(this.pst.imageX+s,this.pst.imageY+l):n=="end"&&this.drawImage(this.pst.imageX+=s,this.pst.imageY+=l)}}pinchEffect(t){let{eventType:n,event:i}=t,{x:e,y:a}=S.getCursor(i.touches[0]),{x:r,y:p}=S.getCursor(i.touches[1]),u=r-e,C=p-a;if(n=="start")this.pinchEffectInfo.origin={x:u,y:C,scale:this.scale.current};else if(n=="move"){let{origin:s}=this.pinchEffectInfo,l=Math.sqrt(Math.pow(s.x,2)+Math.pow(s.y,2)),y=Math.sqrt(Math.pow(u,2)+Math.pow(C,2))/l,v=Number(s.scale*y);this.set_scale(v)}}updateScale(t){let n=t;n=Math.max(n,this.scale.min),n=Math.min(n,this.scale.max),this.scale.current=n,this.drawImage()}updateFilter(t){this.Picture.grayScale=t.grayScale,this.Picture.tone=t.tone,this.Picture.rotate=t.rotate,this.modifyImage()}modifyImage(){return z(this,null,function*(){let{grayScale:t,tone:n,rotate:i}=this.Picture;const e=document.createElement("canvas");let a=e.getContext("2d"),r=yield S.ImageLoader(this.Picture.originDataUrl),p=r.width,u=r.height;(i==90||i==270)&&(p=r.height,u=r.width),e.width=p,e.height=u,t&&(a.filter="grayscale("+t+"%)"),i&&(a.translate(p/2,u/2),a.rotate(i*Math.PI/180),[90,270].includes(i)?a.translate(-u/2,-p/2):a.translate(-p/2,-u/2)),a.drawImage(r,0,0,r.width,r.height);let C=a.getImageData(0,0,e.width,e.height),s=C.data;{t/=100;let v=[[255,255,255],[255,200,100],[170,170,255],[240,200,145],[128,255,255],[255,128,255],[255,255,128],[128,158,169],[128,112,162],[50,192,87],[246,100,140]][n],x=v[0]/255,b=v[1]/255,c=v[2]/255;for(let m=0;m<u;m++)for(let h=0;h<p;h++){var l=(m*p+h)*4;if(t){let R=.3*s[l]+.59*s[l+1]+.11*s[l+2];for(var g=0;g<3;g++){let T=s[l+g];s[l+g]=T+(R-T)*t}}s[l]*=x,s[l+1]*=b,s[l+2]*=c}}a.putImageData(C,0,0);let y=e.toDataURL("image/jpeg");{let v=yield S.ImageLoader(y),{width:x,height:b}=v,c=x/b;this.Picture=G(H({},this.Picture),{elm:v,aspect:c,revisedAspect:this.pst.frame.aspect>c?this.pst.frame.w/x:this.pst.frame.h/b})}this.drawImage()})}drawImage(t,n){let{use:i,Canvas:{ctx:e,elm:a},pst:{frame:r}}=this,p=t||this.pst.imageX,u=n||this.pst.imageY;{let C=this.scale.current/100,s=this.Picture.revisedAspect*C,l=this.pst.centerX-p*s,g=this.pst.centerY-u*s,y=this.Picture.elm.width*s,v=this.Picture.elm.height*s;{let x=this.pst.frame.x+this.pst.frame.w-y,b=this.pst.frame.x,c=this.pst.frame.y+this.pst.frame.h-v,m=this.pst.frame.y,h=0;l<x&&(h=l-x),l>b&&(h=l-b);let R=0;g<c&&(R=g-c),g>m&&(R=g-m),this.dragEffectInfo.origin.x+=h/2/this.dragEffectInfo.frameExpandRate.x,this.dragEffectInfo.origin.y+=R/2/this.dragEffectInfo.frameExpandRate.y,l=Math.min(Math.max(l,x),b),g=Math.min(Math.max(g,c),m)}this.pst.outImage={x:l,y:g,w:y,h:v},e.clearRect(0,0,this.Canvas.elm.width,this.Canvas.elm.height),e.drawImage(this.Picture.elm,0,0,this.Picture.elm.width,this.Picture.elm.height,l,g,y,v)}{if(i=="square"){e.fillStyle="rgba( 20,24,20,.3 )",e.beginPath();let l=a.width/3*2,g=a.height/3*2,y=Math.min(l,g),v=Math.max(l,g);e.arc(a.width/2,a.height/2,v,0,Math.PI*2,!0),e.arc(a.width/2,a.height/2,y/2,0,Math.PI*2,!1),e.closePath(),e.fill()}else(i=="wallpaper.horizontal"||i=="wallpaper.vertical")&&(e.fillStyle="rgba( 20,24,20,.3 )");e.beginPath(),e.moveTo(0,0),e.lineTo(a.width,0),e.lineTo(a.width,a.height),e.lineTo(0,a.height),e.lineTo(0,0),e.closePath(),e.lineTo(r.x,r.y),e.lineTo(r.x,r.y+r.h),e.lineTo(r.x+r.w,r.y+r.h),e.lineTo(r.x+r.w,r.y),e.lineTo(r.x,r.y),e.fill();let s=S(document.body).getStyleProperty("--color-theme-hsl");e.lineWidth=4,e.strokeStyle=`hsla( ${s},1 )`,e.strokeRect(r.x,r.y,r.w,r.h)}}export(){return z(this,null,function*(){let{Canvas:t,develops:n,Picture:i,pst:{outImage:e,frame:a}}=this,r=e.w/i.elm.width,p=e.h/i.elm.height,u=(a.x-e.x)/r,C=(a.x-e.x+a.w)/r,s=(a.y-e.y)/p,l=(a.y-e.y+a.h)/p,g=Array.from({length:n.length}),y="image/jpeg";for(let v=0;v<n.length;v++){let{size:x,maxSize:b}=n[v];b=b||{S:1024*20,R:1024*100,L:1024*350}[x];let c={S:140,R:600,L:1200}[x],m=c;this.use=="wallpaper.horizontal"?m=c/3:this.use=="wallpaper.vertical"&&(m=c*2);let h=document.createElement("canvas");h.width=c,h.height=m;let R=h.getContext("2d");if(!R)return;R.clearRect(0,0,c,m),R.drawImage(this.Picture.elm,u,s,C-u,l-s,0,0,c,m);let T=h.toDataURL(y),w=yield T.toBlob(y);if(!w)return;if(w.size>=b){let L=b/w.size;if(T=h.toDataURL(y,L*.92),w=yield T.toBlob(y),!w)return}let W=new File([w],this.val_file.name,{type:y});g[v]=W}return g})}}const Z={Core:d=>{let{val_file:t,options:n,finishedCallback:i,abortCallback:e}=d,{use:a,develops:r=[]}=n,[p]=N(J());const u={scale:{default:120,min:100,max:400},rotate:0,grayScale:0,tone:0};let[C,s]=N(u.scale.default),[l,g]=N(u.rotate),[y,v]=N(u.grayScale),[x,b]=N(u.tone);return O(()=>{let c="CropperResize";return S(window).addEvent({eventType:"resize",eventID:c,callback:()=>{S.interval(()=>{var L;let m=K("#Canvas-"+p)[0];if(!m)return;let h=(L=X.get(p))==null?void 0:L.Instance;if(!h)return;let R=m.position(),T=R.width/R.height;m.width=2400,m.height=2400/T;let{width:w,height:W}=m;h.pst.centerX=w/2,h.pst.centerY=W/2,h.frameSizing(),h.modifyImage()},250,"CropperResize").once()}}),()=>{S(window).removeEvent(c)}},[]),O(()=>{X.set({[p]:{}}),z(void 0,null,function*(){V.fn.corner.active(),yield S.pending(()=>{},400);let{target:c}=yield t.convert();if(!c)return;let m=c.result,h=K("#Canvas-"+p)[0];if(!h)return;let R=h.position(),T=R.width/R.height;h.width=2400,h.height=2400/T;let w=new re({set_scale:s,val_file:t,develops:r,use:a,scale:u.scale,componentID:p,canvas:h,picture:{image:yield S.ImageLoader(m),grayScale:u.grayScale,tone:u.tone,rotate:u.rotate}});X.set({[p]:{Instance:w}});const W=function(E){if(E.preventDefault(),E.touches&&E.touches.length>1)w.pinchEffect({eventType:"start",event:E}),S(document).addEvent({eventType:"touchmove",eventID:"CropperEffectMove",options:{passive:!1},callback:D=>{D.preventDefault(),w.pinchEffect({eventType:"move",event:D})}}).addEvent({eventType:"touchend",eventID:"CropperEffectEnd",options:{passive:!1},callback:j});else{w.dragEffect(H({eventType:"start"},S.getCursor(E)));let{type:D}=E;S(document).addEvent({eventType:D=="touchstart"?"touchmove":"mousemove",eventID:"CropperEffectMove",options:{passive:!1},callback:_=>{L("move",_)}}).addEvent({eventType:D=="touchstart"?"touchend":"mouseup",eventID:"CropperEffectEnd",options:{passive:!1},callback:_=>{L("end",_),j(_)}})}},L=function(E,D){D.preventDefault(),w.dragEffect(H({eventType:E},S.getCursor(D)))},j=function(E){E.preventDefault(),S(document).removeEvent(["CropperEffectMove","CropperEffectEnd"])};S(h).removeEvent(["CropperMouseWheel","CropperTouchStart","CropperMouseDown"]).addEvent({eventID:"CropperMouseWheel",eventType:"wheel",callback:E=>{E.preventDefault();let D=Number(E.wheelDelta*.04),_=w.scale.current+D;_=Math.max(_,w.scale.min),_=Math.min(_,w.scale.max),s(_)},options:{passive:!1}}).addEvent({eventType:"touchstart",eventID:"CropperTouchStart",callback:W,options:{passive:!1}}).addEvent({eventType:"mousedown",eventID:"CropperMouseDown",callback:W,options:{passive:!1}}),setTimeout(()=>{V.fn.corner.stop()},1e3)})},[t.id]),O(()=>{var m;let c=(m=X.get(p))==null?void 0:m.Instance;c&&c.updateScale(C)},[C]),O(()=>{var m;let c=(m=X.get(p))==null?void 0:m.Instance;c&&c.updateFilter({grayScale:y,tone:x,rotate:l})},[y,x,l]),o(A.Body,{borderRadius:0,height:"viewHeight",width:"viewWidth",children:f(k,{className:[U("Wrap"),U("Use_"+a)].join(" "),gap:0,height:1,position:"relative",overflow:"hidden",borderRadius:"inherit",children:[o(B,{flexSizing:0,overflow:"hidden",position:"relative",backgroundColor:"black",flexCenter:!0,freeCSS:{zIndex:1},children:o("canvas",{style:{width:"100%",height:"100%"},width:2400,height:2400,className:U("Canvas"),id:"Canvas-"+p})}),f(I.Separate,{borderTop:!0,flexSizing:"none",backgroundColor:"layer.1",padding:1,verticalAlign:"unset",UnderBreakPointStyles:{flexType:"col"},children:[o(Z.SettingRegion,{DefaultOptions:u,val_scale:C,set_scale:s,val_tone:x,set_tone:b,val_grayScale:y,set_grayScale:v,val_rotate:l,set_rotate:g}),f(I.Right,{flexSizing:"none",children:[o(P.Border,{isRounded:!0,onClick:()=>{e()},children:"\u9589\u3058\u308B"}),o(P,{isRounded:!0,boxShadow:"3.remark",onClick:()=>z(void 0,null,function*(){var h;let c=(h=X.get(p))==null?void 0:h.Instance;if(!c)return;V.fn.mini.active("CropperExportation");let m=yield c.export();setTimeout(()=>{V.fn.mini.stop("CropperExportation"),i(m)},3e3)}),children:f(I.Center,{gap:"1/2",children:[o(V.White.R,{loaderID:"CropperExportation"}),"\u6C7A\u5B9A"]})})]})]})]})})},SettingRegion:d=>{let t=["","\u6696\u8272","\u5BD2\u8272","\u30BB\u30D4\u30A2","\u30B7\u30A2\u30F3","\u30DE\u30BC\u30F3\u30BF","\u30A4\u30A8\u30ED\u30FC","\u30AA\u30EA\u30B8\u30CA\u30EB1","\u30AA\u30EA\u30B8\u30CA\u30EB2","\u30AA\u30EA\u30B8\u30CA\u30EB3","\u30AA\u30EA\u30B8\u30CA\u30EB4"],n=i=>t[i]||"\u306A\u3057";return f(I.Left,{verticalAlign:"unset",flexWrap:!0,children:[f(k,{gap:"1/3",children:[o(F.Supplement,{children:"Rotate"}),f(I.Left,{flexChilds:"even",gap:"1/6",children:[o(P.Border.S,{isRounded:!0,borderTopRightRadius:0,borderBottomRightRadius:0,onClick:()=>{let i=d.val_rotate-90;i<0&&(i+=360),d.set_rotate(i)},children:f(I.Center,{gap:"1/4",children:["90\xB0",o(M,{icon:te})]})}),o(P.Border.S,{isRounded:!0,borderTopLeftRadius:0,borderBottomLeftRadius:0,onClick:()=>{d.set_rotate((d.val_rotate+90)%360)},children:f(I.Center,{gap:"1/4",children:[o(M,{icon:ae}),"90\xB0"]})})]})]}),f(k,{gap:"1/3",freeCSS:{minWidth:12*6},children:[o(F.Supplement,{children:"Zoom"}),f(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:i=>{let e="CropperZoomEdit";Y.open({tipsID:e,gravityPoint:3,event:i,closeAtParentBlur:!1,freeCSS:{minWidth:12*26},content:o(A.Body,{children:f(k,{padding:1.5,children:[f(I.Separate,{children:[o(F.Paragraph,{children:f(I.Center,{gap:"1/2",children:[o(M.Search,{fontColor:"5.translucent"}),"Zoom"]})}),o(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(e)},children:o(M.Times,{})})]}),o(B,{borderBottom:!0,opacity:"low"}),o(q.Slider,{override:"force",value:d.val_scale-100,min:d.DefaultOptions.scale.min-100,max:d.DefaultOptions.scale.max-100,step:25,onUpdateValidValue:({eventType:a,value:r})=>{S.interval(()=>{d.set_scale(r+100)},250,"Cropper.UpdateScale").once()},legends:{enable:!0,custom:a=>"x"+Math.round(100+a)/100}})]})})})},children:[d.val_scale.rate(1,0),"%"]})]}),f(k,{gap:"1/3",freeCSS:{minWidth:12*6},children:[o(F.Supplement,{children:"GrayScale"}),f(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:i=>{let e="CropperGrayScaleEdit";Y.open({tipsID:e,gravityPoint:3,event:i,closeAtParentBlur:!1,freeCSS:{minWidth:12*26},content:o(A.Body,{children:f(k,{padding:1.5,children:[f(I.Separate,{children:[o(F.Paragraph,{children:f(I.Center,{gap:"1/2",children:[o(M,{icon:Q,fontColor:"5.translucent"}),"Gray Scale"]})}),o(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(e)},children:o(M.Times,{})})]}),o(B,{borderBottom:!0,opacity:"low"}),o(q.Slider,{value:d.val_grayScale,min:0,max:100,step:10,onUpdateValidValue:({value:a})=>{S.interval(()=>{d.set_grayScale(a)},250,"Cropper.GrayScale").once()},legends:{enable:!0,custom:a=>a+"%"}})]})})})},children:[d.val_grayScale.rate(1,0),"%"]})]}),f(k,{gap:"1/3",freeCSS:{minWidth:12*6},children:[o(F.Supplement,{children:"Tone"}),o(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:i=>{let e="CropperToneEdit";Y.open({tipsID:e,gravityPoint:3,event:i,closeAtParentBlur:!1,freeCSS:{minWidth:12*26,maxWidth:12*24},content:()=>{let a=[];for(let r=1;r<=10;r++)a.push({value:r,label:f(ie,{children:[o(B,{ssSphere:1,className:[U("ToneBall"),U("ToneBall_"+r)].join(" ")}),o(B,{textAlign:"left",flexSizing:0,children:n(r)})]})});return o(A.Body,{children:f(k,{padding:1.5,children:[f(I.Separate,{children:[o(F.Paragraph,{children:f(I.Center,{gap:"1/2",children:[o(M,{icon:ee,fontColor:"5.translucent"}),"Tone"]})}),o(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(e)},children:o(M.Times,{})})]}),o(B,{borderBottom:!0,opacity:"low"}),o(q.Radio.Normal,{value:d.val_tone,gap:"1/2",cellStyles:{fontColor:"3.blur"},options:[{value:0,label:o(B,{flexSizing:0,textAlign:"center",children:"\u306A\u3057"})},...a],onUpdateValidValue:({value:r})=>{d.set_tone(r)}})]})})}})},children:f(I.Center,{gap:"1/2",children:[o(B,{boxShadow:"2.remark",ssSphere:1,className:[U("ToneBall"),U("ToneBall_"+d.val_tone)].join(" ")}),n(d.val_tone)]})})]})]})}},$={openDialogNEdit:d=>z(void 0,null,function*(){let t=yield q.Filer.fn.openDialog({accept:"image",multiple:!1});$.openEditor(H({imageFile:t[0]},d))}),openEditor:d=>z(void 0,null,function*(){let t="CropperImage";A.open({sheetID:t,type:"normal.middleCenter",size:"MAX",padding:0,margin:0,freeCSS:{maxWidth:"100vw"},content:o(Z.Core,{val_file:d.imageFile,options:d,finishedCallback:n=>{A.close(t),d.onProcessFinished(n)},abortCallback:()=>{A.close(t)}}),closeAtEscapeKeyDown:!1})})};export{$ as Cropper,$ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as c,c as O,d as Q,e as Y}from"../../chunk-C5N2D3ZX.js";import{Fragment as X,jsx as l,jsxs as E}from"react/jsx-runtime";import{useState as D,useEffect as R,useRef as le}from"react";import u,{UUID as L}from"jmini";import{ExtractStyles as ae}from"../../@utils";import{Box as x,Span as ne,FAI as M,Column as re}from"../../atoms";import{Text as P,Row as q}from"../../mols";import{Button as Z}from"../Button";import{Loader as ie}from"../Loader";import{Sheet as se}from"../Sheet";import{OptionalInputWrapper as ue,BoxWrapper as ce,CoreEffects as K,DefaultBoxishStyles as pe}from"./core";import{InputAutocompleteClasses as W}from"../../@styles/componentClasses";import{InputLabel as de}from"./Label";import{RightIcon as ee}from".";function Se(e){let{value:t,states:n}=e,{required:a,options:S,min:s,max:f}=n;s=s||0,f=f||65535;let r=[],o=t.filter(p=>p!==null).length;return a&&(o||r.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),o<s&&r.push({type:"invalid",label:s+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),o>f&&r.push({type:"invalid",label:f+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!r.filter(({type:p})=>p=="invalid").length,notice:r}}const A={InitOptions:e=>{let t=[];return e.forEach(n=>{let{type:a,label:S,value:s,searchValue:f}=n,r=f||(u.is.string(S)?S:"")||(u.is.string(s)?s:"");t.push(O(c({},n),{searchValue:r,type:a||"selector",value:s}))}),t},FilterSelectableOptions:(e,t)=>{let n=e.val_options;if(t||(n=e.val_options.filter(a=>a.type!="label")),e.val_keyword){let a=e.val_keyword.toLower().replace(/ /g,"");n=n.filter(S=>(S.searchValue||"").toLower().replace(/ /g,"").includes(a))}return n}},F={Shallow:e=>{let{rootStates:t,val_status:n}=e,a=ae(t);return l(x,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:l(P.Description,O(c({className:t.className},a),{position:"absolute",width:1,freeCSS:O(c({},a.freeCSS),{color:"orange"}),"data-id":"shallow_"+n.componentID,children:l(x,{"data-input-value-shallow":n.componentID,children:"A"})}))})},Button:e=>{let{rootStates:t,val_keyword:n,set_keyword:a,val_optionFocused:S,set_optionFocused:s,val_options:f,set_options:r,val_optionsDict:o,set_optionsDict:p,val_preventOpenSelectorOnFocus:i,set_preventOpenSelectorOnFocus:d,val_selectorOpen:v,set_selectorOpen:m,val_status:h,set_status:w,val_validate:b,set_validate:I}=e,j=t,{tone:_,required:V,form:C,className:k,multiSelect:N,enableFormSubmit:B,checkValidationAtFirst:z,onValidate:$,onUpdateValue:J,onUpdateValidValue:U,value:me="",options:fe,leftIndicator:ve,rightIndicator:ye,leftIcon:he,rightIcon:_e,componentID:ge,status_id:be,wrapStyles:Oe,emptySelect:Ie,SearchInput:De,SearchInputPlaceholder:Ce,SelectedComponent:we,SelectorComponent:Te,SelectorStyles:Ve,SelectorPosition:ke,DynamicOptionsOnSearch:xe}=j,g=Q(j,["tone","required","form","className","multiSelect","enableFormSubmit","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","wrapStyles","emptySelect","SearchInput","SearchInputPlaceholder","SelectedComponent","SelectorComponent","SelectorStyles","SelectorPosition","DynamicOptionsOnSearch"]);return R(()=>{var T,H;if(t.disabled||!v)return;let y=A.FilterSelectableOptions(e);s((H=(T=y[0])==null?void 0:T.value)!=null?H:null)},[n]),R(()=>{h.eventType!="init"&&(t.max==h.dataValue.length?(m(!1),d(!0),setTimeout(()=>{let y=u('[data-input-origin="'+t.componentID+'"]');y&&y.focus()},10)):u("#SearchInput_"+t.componentID).focus())},[h.dataValue]),R(()=>{let y="autocomplete-click-"+t.componentID;if(v){if(!u('[data-input-origin="'+t.componentID+'"]'))return;u("#SearchInput_"+t.componentID).focus(),u(document).addEvent({eventID:y,eventType:"mousedown",callback:H=>{let G=u(H.target),oe=!!u(G).parent("."+W("Core")).length;u(G).parent("."+W("Selector")).length||oe||m(!1)}})}else u(document).removeEvent([y]),a("")},[v]),E(X,{children:[l(x,O(c({tabIndex:0},g),{"data-disabled":t.disabled,"data-show-validation":K.isShowValidation(b,h,!!z),"data-component-id":h.componentID,"data-input-origin":h.componentID,"data-focus":!!v,className:[k,W("Core")].join(" "),onFocus:y=>{if(g!=null&&g.onFocus&&(g==null||g.onFocus(y)),!t.disabled){if(i)return d(!1);m(!0),y.preventDefault()}},onClick:y=>{g!=null&&g.onClick&&(g==null||g.onClick(y)),!t.disabled&&m(!0)},onKeyDown:y=>{let{key:T}=y;B&&K.SubmitForm(y,C),!v&&(T==" "||T=="ArrowDown"||T=="ArrowUp"||T=="Enter")&&m(!0)},children:E(q.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(F.Selected,c({},e)),l(ne,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),l(F.SearchInput,c({},e))]})})),v&&l(F.Selector,c({},e))]})},SearchInput:e=>{let{rootStates:t}=e;return t.disabled||!e.val_selectorOpen?null:l(x,{id:"SearchInput_"+t.componentID,placeholder:t.SearchInputPlaceholder||"\u691C\u7D22...",opacity:e.val_selectorOpen?"max":"trans",transition:"middle",flexSizing:0,htmlTag:"input",border:"unset",backgroundColor:"trans",value:e.val_keyword,freeCSS:{outline:"none"},onKeyDown:n=>{let{key:a,metaKey:S,ctrlKey:s}=n,f=S||s;a=="Escape"?(e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0),setTimeout(()=>{let r=u('[data-input-origin="'+t.componentID+'"]');r&&r.focus()},10)):a=="Tab"?e.set_selectorOpen(!1):a==" "?u.scope(()=>{e.val_selectorOpen||e.val_keyword||(n.preventDefault(),e.set_selectorOpen(!0))}):a=="Backspace"?u.scope(()=>{if(e.val_keyword)return;let r=[...e.val_status.dataValue];r.pop(),e.set_status(o=>O(c({},o),{dataValue:r,eventType:"update",eventID:L()}))}):a=="Enter"&&u.scope(()=>{if(!e.val_selectorOpen)return e.set_selectorOpen(!0);let r=e.val_options.find(p=>p.value==e.val_optionFocused);if(!r)return;let{value:o}=r;e.set_status(p=>{let i=[...p.dataValue];return u.scope(()=>{if(o===null)return i=[];p.dataValue.includes(o)?i=i.filter(v=>v!==o):t.multiSelect?i.push(o):i=[o]}),O(c({},p),{dataValue:i,eventType:"update",eventID:L()})}),e.set_keyword(""),e.set_preventDynamicSearchOnKeywordChange(!0)}),u.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(a))return;if(n.preventDefault(),!e.val_selectorOpen)return e.set_selectorOpen(!0);let r=a=="ArrowDown"?1:-1,o=A.FilterSelectableOptions(e),p=o.length-1,i=null;u.scope(()=>{var v,m,h,w,b,I,_,V,C,k;let d=o.findIndex(N=>N.value==e.val_optionFocused);if(d==-1&&(d=0),r==1){if(i=(m=(v=o[0])==null?void 0:v.value)!=null?m:null,f){i=(h=o[p].value)!=null?h:null;return}if(d==-1||d==p)return;i=(b=(w=o[d+1])==null?void 0:w.value)!=null?b:null}else{if(i=(I=o[p].value)!=null?I:null,f){i=(V=(_=o[0])==null?void 0:_.value)!=null?V:null;return}if(d==-1||d==0)return;i=(k=(C=o[d-1])==null?void 0:C.value)!=null?k:null}}),e.set_optionFocused(i)}),t.enableFormSubmit&&K.SubmitForm(n,e.rootStates.form)},onChange:n=>{let S=n.target.value;e.set_keyword(S)}},"searchInput")},Selector:e=>{var p;let[t,n]=D("idle"),[a,S]=D("idle");R(()=>{if(!e.val_selectorOpen||!e.rootStates.DynamicOptionsOnSearch)return;if(e.val_preventDynamicSearchOnKeywordChange)return e.set_preventDynamicSearchOnKeywordChange(!1);if(t=="idle")return n("ok");S("fetch");let i="autocomplete-search-"+e.rootStates.componentID;u.cycle(()=>Y(void 0,null,function*(){let d=yield e.rootStates.DynamicOptionsOnSearch(e.val_keyword);S("idle");let v=A.InitOptions(d||[]);e.set_options(v)}),300,i).once()},[e.val_keyword]);let s=[],f=A.FilterSelectableOptions(e,!0),r=A.FilterSelectableOptions(e);f.forEach((i,d)=>{let{type:v,value:m}=i,h=e.val_optionFocused==m,w=e.val_status.dataValue.includes(m),b=e.rootStates.SelectorComponent;s.push(l(b,{option:i,isFocused:h,isSelected:w,addCallback:()=>{e.set_status(I=>{let _=[...I.dataValue];return u.scope(()=>{if(m===null)return _=[];I.dataValue.includes(m)?_=_.filter(C=>C!==m):e.rootStates.multiSelect?_.push(m):_=[m]}),O(c({},I),{dataValue:_,eventType:"update",eventID:L()})})}},u.Stringify(m)||L()))}),r.length||(s=[l(P.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]),a=="fetch"&&(s=[E(q.Left,{padding:1,fontColor:"3.blur",children:[l(ie.Theme.R,{showInitial:!0}),l(P.Supplement,{children:"Loading..."})]},"loader")]);let o={position:"absolute",minWidth:1,freeCSS:{zIndex:1e3}};switch(e.rootStates.SelectorPosition){case 1:o.bottom="100%",o.left=0,o.paddingBottom="1/3";break;case 2:o.bottom="100%",o.right=0,o.paddingBottom="1/3";break;case 3:o.top="100%",o.left=0,o.paddingTop="1/3";break;case 4:o.top="100%",o.right=0,o.paddingTop="1/3";break;default:break}return l(x,O(c({},o),{children:l(se.Body,O(c({className:W("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,boxShadow:"1.normal",overflow:"auto"},e.rootStates.SelectorStyles),{freeCSS:c({maxHeight:12*24},(p=e.rootStates.SelectorStyles)==null?void 0:p.freeCSS),children:l(re,{gap:"1/12",padding:[1,0],children:s})}))}))},Selected:e=>{let{rootStates:t,val_status:n,set_status:a,val_optionsDict:S}=e,s=[];return n.dataValue.forEach(f=>{let r=S[u.Stringify(f)];if(!r)return;let o=t.SelectedComponent,p=r.label;r.value===null&&(p=""),s.push(l(x,{className:W("SelectedCell"),children:l(o,{value:r.value,label:p,removeCallback:i=>{if(i.stopPropagation(),i.preventDefault(),t.disabled)return;let d=[...n.dataValue];d=d.filter(v=>v!==f),a(v=>O(c({},v),{dataValue:d,eventType:"update",eventID:L()}))}})},u.Stringify(r.value)))}),l(X,{children:s})},Core:e=>{var z;let{value:t}=e,[n,a]=D(!1),[S,s]=D(!1),[f,r]=D(!1),[o,p]=D(""),[i,d]=D(e.options),[v,m]=D((z=e.value[0])!=null?z:null),[h,w]=D({}),[b,I]=D(K.DefaultStatus(e.componentID,t)),[_,V]=D({ok:!1,notice:[]}),C=le(!1);R(()=>{C.current?d(e.options):C.current=!0},[e.options]),R(()=>{if(!i.length)return;let $=[...i],J=c({},h);$.forEach(U=>{U.type!="label"&&(J[u.Stringify(U.value)]=U)}),w(J)},[i]);let k={rootStates:e,val_options:i,set_options:d,val_optionFocused:v,set_optionFocused:m,val_optionsDict:h,set_optionsDict:w,val_preventDynamicSearchOnKeywordChange:S,set_preventDynamicSearchOnKeywordChange:s,val_preventOpenSelectorOnFocus:n,set_preventOpenSelectorOnFocus:a,val_selectorOpen:f,set_selectorOpen:r,val_keyword:o,set_keyword:p,val_status:b,set_status:I,val_validate:_,set_validate:V},N=!!e.multiSelect;K.CommonEffects({type:N?"autocomplete.multi":"autocomplete.single",states:e,val_status:b,set_status:I,val_validate:_,set_validate:V,SystemValidation:Se});let B=b.dataValue.length&&b.dataValue[0]!==null;return B=B||f,E(ce,{val_status:b,set_status:I,val_validate:_,states:e,children:[l(de,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:B}),l(F.Shallow,c({},k)),l(F.Button,c({},k))]})}},te=e=>{var n;let t=c({},e);return t=O(c({value:[],min:0,max:65535,multiSelect:!0,SearchInput:!0,emptySelect:!0,SelectorComponent:({option:a,isSelected:S,isFocused:s,addCallback:f})=>a.type=="selector"?l(Z.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1.5],isActive:s,isActiveStyles:{backgroundColor:"cloud"},onClick:r=>{f()},children:E(q.Left,{gap:"1/2",children:[S&&l(M.Check,{fontColor:"theme"}),l(P.Supplement,{transition:"short",children:a.label})]})}):l(X,{children:a.label}),SelectedComponent:({value:a,label:S,removeCallback:s})=>E(q.Left,{ssCardBox:"cloud",borderRadius:"2.tone.secondary",fontSize:"1.mini",padding:"1/2",gap:0,children:[l(x,{padding:[0,"1/4"],children:S}),l(Z.Sub,{flexSizing:"none",color:"cloud",fontColor:"white",backgroundColor:"layer.5",isRounded:!0,padding:"1/4",onClick:s,freeCSS:{lineHeight:1,aspectRatio:"1/1"},children:l(M.Times,{ssSphere:1})})]}),SelectorPosition:3},t),{freeCSS:c({cursor:"pointer"},t.freeCSS)}),t.multiSelect||(t.min=0,t.max=1),t.options=t.options||[],t.emptySelect&&(t.options=[{value:null,label:l(P.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=u.flatArray((n=t.value)!=null?n:null),t.options=A.InitOptions(t.options),u.is.nullish(t.rightIcon)&&(t.rightIcon=l(ee,{ssSphere:2,children:l(M.Search,{})}),t.disabled&&(t.rightIcon=l(ee,{ssSphere:2,fontColor:"5.translucent",children:l(M.Ban,{})}))),t.rightIcon&&(t=c({paddingRight:3},t)),t.leftIcon&&(t=c({paddingLeft:3},t)),l(ue,{componentID:t.componentID,children:F.Core,states:pe(t)})};export{te as Autocomplete,te as default};
|
|
1
|
+
import{b as c,c as O,d as Q,e as Y}from"../../chunk-C5N2D3ZX.js";import{Fragment as X,jsx as l,jsxs as E}from"react/jsx-runtime";import{useState as D,useEffect as R,useRef as le}from"react";import u,{UUID as L}from"jmini";import{ExtractStyles as ae}from"../../@utils";import{Box as x,Span as ne,FAI as M,Column as re}from"../../atoms";import{Text as P,Row as q}from"../../mols";import{Button as Z}from"../Button";import{Loader as ie}from"../Loader";import{Sheet as se}from"../Sheet";import{OptionalInputWrapper as ue,BoxWrapper as ce,CoreEffects as K,DefaultBoxishStyles as pe}from"./core";import{InputAutocompleteClasses as W}from"../../@styles/componentClasses";import{InputLabel as de}from"./Label";import{RightIcon as ee}from".";function Se(e){let{value:t,states:n}=e,{required:a,options:S,min:s,max:f}=n;s=s||0,f=f||65535;let r=[],o=t.filter(p=>p!==null).length;return a&&(o||r.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),o<s&&r.push({type:"invalid",label:s+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),o>f&&r.push({type:"invalid",label:f+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!r.filter(({type:p})=>p=="invalid").length,notice:r}}const A={InitOptions:e=>{let t=[];return e.forEach(n=>{let{type:a,label:S,value:s,searchValue:f}=n,r=f||(u.is.string(S)?S:"")||(u.is.string(s)?s:"");t.push(O(c({},n),{searchValue:r,type:a||"selector",value:s}))}),t},FilterSelectableOptions:(e,t)=>{let n=e.val_options;if(t||(n=e.val_options.filter(a=>a.type!="label")),e.val_keyword){let a=e.val_keyword.toLower().replace(/ /g,"");n=n.filter(S=>(S.searchValue||"").toLower().replace(/ /g,"").includes(a))}return n}},F={Shallow:e=>{let{rootStates:t,val_status:n}=e,a=ae(t);return l(x,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:l(P.Description,O(c({className:t.className},a),{position:"absolute",width:1,freeCSS:O(c({},a.freeCSS),{color:"orange"}),"data-id":"shallow_"+n.componentID,children:l(x,{"data-input-value-shallow":n.componentID,children:"A"})}))})},Button:e=>{let{rootStates:t,val_keyword:n,set_keyword:a,val_optionFocused:S,set_optionFocused:s,val_options:f,set_options:r,val_optionsDict:o,set_optionsDict:p,val_preventOpenSelectorOnFocus:i,set_preventOpenSelectorOnFocus:d,val_selectorOpen:v,set_selectorOpen:m,val_status:h,set_status:w,val_validate:b,set_validate:I}=e,j=t,{tone:_,required:V,form:C,className:k,multiSelect:N,enableFormSubmit:B,checkValidationAtFirst:z,onValidate:$,onUpdateValue:J,onUpdateValidValue:U,value:me="",options:fe,leftIndicator:ve,rightIndicator:ye,leftIcon:he,rightIcon:_e,componentID:ge,status_id:be,wrapStyles:Oe,emptySelect:Ie,SearchInput:De,SearchInputPlaceholder:Ce,SelectedComponent:we,SelectorComponent:Te,SelectorStyles:Ve,SelectorPosition:ke,DynamicOptionsOnSearch:xe}=j,g=Q(j,["tone","required","form","className","multiSelect","enableFormSubmit","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","wrapStyles","emptySelect","SearchInput","SearchInputPlaceholder","SelectedComponent","SelectorComponent","SelectorStyles","SelectorPosition","DynamicOptionsOnSearch"]);return R(()=>{var T,H;if(t.disabled||!v)return;let y=A.FilterSelectableOptions(e);s((H=(T=y[0])==null?void 0:T.value)!=null?H:null)},[n]),R(()=>{h.eventType!="init"&&(t.max==h.dataValue.length?(m(!1),d(!0),setTimeout(()=>{let y=u('[data-input-origin="'+t.componentID+'"]');y&&y.focus()},10)):u("#SearchInput_"+t.componentID).focus())},[h.dataValue]),R(()=>{let y="autocomplete-click-"+t.componentID;if(v){if(!u('[data-input-origin="'+t.componentID+'"]'))return;u("#SearchInput_"+t.componentID).focus(),u(document).addEvent({eventID:y,eventType:"mousedown",callback:H=>{let G=u(H.target),oe=!!u(G).parent("."+W("Core")).length;u(G).parent("."+W("Selector")).length||oe||m(!1)}})}else u(document).removeEvent([y]),a("")},[v]),E(X,{children:[l(x,O(c({tabIndex:0},g),{"data-disabled":t.disabled,"data-show-validation":K.isShowValidation(b,h,!!z),"data-component-id":h.componentID,"data-input-origin":h.componentID,"data-focus":!!v,className:[k,W("Core")].join(" "),onFocus:y=>{if(g!=null&&g.onFocus&&(g==null||g.onFocus(y)),!t.disabled){if(i)return d(!1);m(!0),y.preventDefault()}},onClick:y=>{g!=null&&g.onClick&&(g==null||g.onClick(y)),!t.disabled&&m(!0)},onKeyDown:y=>{let{key:T}=y;B&&K.SubmitForm(y,C),!v&&(T==" "||T=="ArrowDown"||T=="ArrowUp"||T=="Enter")&&m(!0)},children:E(q.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(F.Selected,c({},e)),l(ne,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),l(F.SearchInput,c({},e))]})})),v&&l(F.Selector,c({},e))]})},SearchInput:e=>{let{rootStates:t}=e;return t.disabled||!e.val_selectorOpen?null:l(x,{id:"SearchInput_"+t.componentID,placeholder:t.SearchInputPlaceholder||"\u691C\u7D22...",opacity:e.val_selectorOpen?"max":"trans",transition:"middle",flexSizing:0,htmlTag:"input",border:"unset",backgroundColor:"trans",value:e.val_keyword,freeCSS:{outline:"none"},onKeyDown:n=>{let{key:a,metaKey:S,ctrlKey:s}=n,f=S||s;a=="Escape"?(e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0),setTimeout(()=>{let r=u('[data-input-origin="'+t.componentID+'"]');r&&r.focus()},10)):a=="Tab"?e.set_selectorOpen(!1):a==" "?u.scope(()=>{e.val_selectorOpen||e.val_keyword||(n.preventDefault(),e.set_selectorOpen(!0))}):a=="Backspace"?u.scope(()=>{if(e.val_keyword)return;let r=[...e.val_status.dataValue];r.pop(),e.set_status(o=>O(c({},o),{dataValue:r,eventType:"update",eventID:L()}))}):a=="Enter"&&u.scope(()=>{if(!e.val_selectorOpen)return e.set_selectorOpen(!0);let r=e.val_options.find(p=>p.value==e.val_optionFocused);if(!r)return;let{value:o}=r;e.set_status(p=>{let i=[...p.dataValue];return u.scope(()=>{if(o===null)return i=[];p.dataValue.includes(o)?i=i.filter(v=>v!==o):t.multiSelect?i.push(o):i=[o]}),O(c({},p),{dataValue:i,eventType:"update",eventID:L()})}),e.set_keyword(""),e.set_preventDynamicSearchOnKeywordChange(!0)}),u.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(a))return;if(n.preventDefault(),!e.val_selectorOpen)return e.set_selectorOpen(!0);let r=a=="ArrowDown"?1:-1,o=A.FilterSelectableOptions(e),p=o.length-1,i=null;u.scope(()=>{var v,m,h,w,b,I,_,V,C,k;let d=o.findIndex(N=>N.value==e.val_optionFocused);if(d==-1&&(d=0),r==1){if(i=(m=(v=o[0])==null?void 0:v.value)!=null?m:null,f){i=(h=o[p].value)!=null?h:null;return}if(d==-1||d==p)return;i=(b=(w=o[d+1])==null?void 0:w.value)!=null?b:null}else{if(i=(I=o[p].value)!=null?I:null,f){i=(V=(_=o[0])==null?void 0:_.value)!=null?V:null;return}if(d==-1||d==0)return;i=(k=(C=o[d-1])==null?void 0:C.value)!=null?k:null}}),e.set_optionFocused(i)}),t.enableFormSubmit&&K.SubmitForm(n,e.rootStates.form)},onChange:n=>{let S=n.target.value;e.set_keyword(S)}},"searchInput")},Selector:e=>{var p;let[t,n]=D("idle"),[a,S]=D("idle");R(()=>{if(!e.val_selectorOpen||!e.rootStates.DynamicOptionsOnSearch)return;if(e.val_preventDynamicSearchOnKeywordChange)return e.set_preventDynamicSearchOnKeywordChange(!1);if(t=="idle")return n("ok");S("fetch");let i="autocomplete-search-"+e.rootStates.componentID;u.interval(()=>Y(void 0,null,function*(){let d=yield e.rootStates.DynamicOptionsOnSearch(e.val_keyword);S("idle");let v=A.InitOptions(d||[]);e.set_options(v)}),300,i).once()},[e.val_keyword]);let s=[],f=A.FilterSelectableOptions(e,!0),r=A.FilterSelectableOptions(e);f.forEach((i,d)=>{let{type:v,value:m}=i,h=e.val_optionFocused==m,w=e.val_status.dataValue.includes(m),b=e.rootStates.SelectorComponent;s.push(l(b,{option:i,isFocused:h,isSelected:w,addCallback:()=>{e.set_status(I=>{let _=[...I.dataValue];return u.scope(()=>{if(m===null)return _=[];I.dataValue.includes(m)?_=_.filter(C=>C!==m):e.rootStates.multiSelect?_.push(m):_=[m]}),O(c({},I),{dataValue:_,eventType:"update",eventID:L()})})}},u.Stringify(m)||L()))}),r.length||(s=[l(P.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]),a=="fetch"&&(s=[E(q.Left,{padding:1,fontColor:"3.blur",children:[l(ie.Theme.R,{showInitial:!0}),l(P.Supplement,{children:"Loading..."})]},"loader")]);let o={position:"absolute",minWidth:1,freeCSS:{zIndex:1e3}};switch(e.rootStates.SelectorPosition){case 1:o.bottom="100%",o.left=0,o.paddingBottom="1/3";break;case 2:o.bottom="100%",o.right=0,o.paddingBottom="1/3";break;case 3:o.top="100%",o.left=0,o.paddingTop="1/3";break;case 4:o.top="100%",o.right=0,o.paddingTop="1/3";break;default:break}return l(x,O(c({},o),{children:l(se.Body,O(c({className:W("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,boxShadow:"1.normal",overflow:"auto"},e.rootStates.SelectorStyles),{freeCSS:c({maxHeight:12*24},(p=e.rootStates.SelectorStyles)==null?void 0:p.freeCSS),children:l(re,{gap:"1/12",padding:[1,0],children:s})}))}))},Selected:e=>{let{rootStates:t,val_status:n,set_status:a,val_optionsDict:S}=e,s=[];return n.dataValue.forEach(f=>{let r=S[u.Stringify(f)];if(!r)return;let o=t.SelectedComponent,p=r.label;r.value===null&&(p=""),s.push(l(x,{className:W("SelectedCell"),children:l(o,{value:r.value,label:p,removeCallback:i=>{if(i.stopPropagation(),i.preventDefault(),t.disabled)return;let d=[...n.dataValue];d=d.filter(v=>v!==f),a(v=>O(c({},v),{dataValue:d,eventType:"update",eventID:L()}))}})},u.Stringify(r.value)))}),l(X,{children:s})},Core:e=>{var z;let{value:t}=e,[n,a]=D(!1),[S,s]=D(!1),[f,r]=D(!1),[o,p]=D(""),[i,d]=D(e.options),[v,m]=D((z=e.value[0])!=null?z:null),[h,w]=D({}),[b,I]=D(K.DefaultStatus(e.componentID,t)),[_,V]=D({ok:!1,notice:[]}),C=le(!1);R(()=>{C.current?d(e.options):C.current=!0},[e.options]),R(()=>{if(!i.length)return;let $=[...i],J=c({},h);$.forEach(U=>{U.type!="label"&&(J[u.Stringify(U.value)]=U)}),w(J)},[i]);let k={rootStates:e,val_options:i,set_options:d,val_optionFocused:v,set_optionFocused:m,val_optionsDict:h,set_optionsDict:w,val_preventDynamicSearchOnKeywordChange:S,set_preventDynamicSearchOnKeywordChange:s,val_preventOpenSelectorOnFocus:n,set_preventOpenSelectorOnFocus:a,val_selectorOpen:f,set_selectorOpen:r,val_keyword:o,set_keyword:p,val_status:b,set_status:I,val_validate:_,set_validate:V},N=!!e.multiSelect;K.CommonEffects({type:N?"autocomplete.multi":"autocomplete.single",states:e,val_status:b,set_status:I,val_validate:_,set_validate:V,SystemValidation:Se});let B=b.dataValue.length&&b.dataValue[0]!==null;return B=B||f,E(ce,{val_status:b,set_status:I,val_validate:_,states:e,children:[l(de,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:B}),l(F.Shallow,c({},k)),l(F.Button,c({},k))]})}},te=e=>{var n;let t=c({},e);return t=O(c({value:[],min:0,max:65535,multiSelect:!0,SearchInput:!0,emptySelect:!0,SelectorComponent:({option:a,isSelected:S,isFocused:s,addCallback:f})=>a.type=="selector"?l(Z.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1.5],isActive:s,isActiveStyles:{backgroundColor:"cloud"},onClick:r=>{f()},children:E(q.Left,{gap:"1/2",children:[S&&l(M.Check,{fontColor:"theme"}),l(P.Supplement,{transition:"short",children:a.label})]})}):l(X,{children:a.label}),SelectedComponent:({value:a,label:S,removeCallback:s})=>E(q.Left,{ssCardBox:"cloud",borderRadius:"2.tone.secondary",fontSize:"1.mini",padding:"1/2",gap:0,children:[l(x,{padding:[0,"1/4"],children:S}),l(Z.Sub,{flexSizing:"none",color:"cloud",fontColor:"white",backgroundColor:"layer.5",isRounded:!0,padding:"1/4",onClick:s,freeCSS:{lineHeight:1,aspectRatio:"1/1"},children:l(M.Times,{ssSphere:1})})]}),SelectorPosition:3},t),{freeCSS:c({cursor:"pointer"},t.freeCSS)}),t.multiSelect||(t.min=0,t.max=1),t.options=t.options||[],t.emptySelect&&(t.options=[{value:null,label:l(P.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=u.flatArray((n=t.value)!=null?n:null),t.options=A.InitOptions(t.options),u.is.nullish(t.rightIcon)&&(t.rightIcon=l(ee,{ssSphere:2,children:l(M.Search,{})}),t.disabled&&(t.rightIcon=l(ee,{ssSphere:2,fontColor:"5.translucent",children:l(M.Ban,{})}))),t.rightIcon&&(t=c({paddingRight:3},t)),t.leftIcon&&(t=c({paddingLeft:3},t)),l(ue,{componentID:t.componentID,children:F.Core,states:pe(t)})};export{te as Autocomplete,te as default};
|
package/dist/fn/Input/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as o,c as d,e as b}from"../../chunk-C5N2D3ZX.js";import{jsx as p,jsxs as h}from"react/jsx-runtime";import{useState as x,useEffect as g}from"react";import c,{UUID as y,useStore as v}from"jmini";import{$$fromRoot as k,Config as B}from"../../@utils";import{InputClasses as _}from"../../@styles/componentClasses";import{Box as E,Flex as w,FAI as T,Column as N}from"../../atoms";import{Row as D,Text as F}from"../../mols";import{Button as W}from"../Button";import R from"../Tooltips";const
|
|
1
|
+
import{b as o,c as d,e as b}from"../../chunk-C5N2D3ZX.js";import{jsx as p,jsxs as h}from"react/jsx-runtime";import{useState as x,useEffect as g}from"react";import c,{UUID as y,useStore as v}from"jmini";import{$$fromRoot as k,Config as B}from"../../@utils";import{InputClasses as _}from"../../@styles/componentClasses";import{Box as E,Flex as w,FAI as T,Column as N}from"../../atoms";import{Row as D,Text as F}from"../../mols";import{Button as W}from"../Button";import R from"../Tooltips";const et=t=>{let[n]=x(t.componentID||y());t=o({},t),t.states=d(o({enableFormSubmit:!0,status_id:y(),override:"never",form:"",id:y(),"aria-label":"Input-"+n},t.states),{componentID:n});let{children:e}=t;return p(e,o({},t.states))},at=t=>{let{children:n,val_status:e,val_validate:a,states:i}=t,{leftIcon:l,wrapStyles:s}=i;return e.eventType=="init"&&!i.checkValidationAtFirst&&(a.notice=[]),h(D.Center,d(o({position:"relative",verticalAlign:"unset",gap:0},s),{className:_("Wrapper"),"data-notice-uid":e.componentID,children:[p(C.Notice,{notice:a.notice,val_status:e}),i.leftIndicator,h(w,{position:"relative",flexSizing:"auto",children:[n,l,p(C.RightIcon,o({},t)),p(C.ClearButton,o({},t))]}),i.rightIndicator]}))},C={ClearButton:t=>!t.states.clearButton||!t.val_status.dataValue?null:p(W.Normal,{ssSphere:2,flexCenter:!0,fontColor:"5.translucent",ssEffectsOnActive:["ripple.theme"],position:"absolute",right:1,top:"50%",freeCSS:{zIndex:3,transform:"translateY(-50%)"},onClick:()=>{t.set_status(n=>d(o({},n),{dataValue:"",formatValue:"",eventType:"update",eventID:y()}))},children:p(T.Times,{})}),RightIcon:t=>t.states.clearButton&&t.val_status.dataValue?null:t.states.rightIcon,Notice:t=>{let{notice:n,val_status:e}=t,{componentID:a}=e,i="NoticeTimer-"+a,l="NoticeTimerClose-"+a,s="notice-tips-"+a;return g(()=>{c.interval(()=>{if(!n.length){R.close(s);return}R.open({tipsID:s,parent:`[data-notice-uid="${a}"]`,gravityPoint:22,padding:[1,0],closeAtParentBlur:!1,content:h(R.Body,{padding:["1/2","2/3"],fontSize:"1.mini",position:"relative",children:[p(E,{position:"absolute",unitHeight:1,unitWidth:1,left:1,backgroundColor:"dark",freeCSS:{zIndex:1,transform:"rotate(45deg)",top:-6}}),p(N,{backgroundColor:"inherit",gap:"1/3",position:"relative",freeCSS:{zIndex:2},children:n.map((I,S)=>{let{type:r,label:u}=I,f=r=="invalid"?T.Times:r=="warn"?T.Exclamation:T.Check;return h(D.Left,{gap:0,borderRadius:"2.tone.secondary",children:[p(f,{flexCenter:!0,fontSize:"2.normal",fontColor:{invalid:"nega",warn:"warn",valid:"posi"}[r]}),p(F.Supplement,{fontSize:"0.xs",fontColor:"white",children:u})]},S+"-"+c.Stringify(I))})})]})})},350,i).once(),c.interval(()=>{R.close(s)},6e3,l).once()},[n]),null}},z={DefaultStatus:(t,n)=>({componentID:t,dataValue:n,eventType:"init",eventID:y()}),CommonEffects:function(t){let{type:n,states:e,val_status:a,set_status:i,val_validate:l,set_validate:s,SystemValidation:I}=t;e=o({},e);let{componentID:S}=a;g(()=>(v.update({[S]:{ResolveRefresh:null,Refresh:()=>new Promise((r,u)=>{v.get(S).ResolveRefresh=r,i(f=>d(o({},f),{eventType:"refresh",eventID:y()}))}),GenNotice:r=>{let{ok:u,notice:f}=r;s({ok:u,notice:f})}}}),()=>{v.delete(S)}),[]),c.scope(()=>{let{override:r}=e;if(r=="never"||r=="beforeModified"&&!["init","override"].includes(a.eventType))return;let u=v.get(a.componentID);u&&(e.value!=a.dataValue&&e.status_id!=u.status_id&&i(f=>d(o(d(o({},f),{dataValue:e.value}),t.ExtraOverrideStates),{eventType:"override",eventID:y()})),u.status_id=e.status_id)}),g(()=>{z.ValidationCheck({val_status:a,set_validate:s,SystemValidation:I,states:e})},[a.eventID,a.dataValue]),g(()=>(c.scope(()=>{let{componentID:r,eventType:u,dataValue:f}=a,m=f;if(n=="autocomplete.single"||n=="list.radio"?m=m[0]:e.isChecker&&(m=!!m[0]),e.form=e.form||"testForm",e.name&&e.form&&v.update({[["form-data",e.form].join("-")]:{[e.name]:{componentID:r,type:n,value:m,validation:l.ok}}}),u=="refresh"){let V=v.get(r);V&&V.ResolveRefresh&&V.ResolveRefresh(null)}else u=="update"&&(e.onUpdateValue&&e.onUpdateValue({componentID:r,value:m,eventType:u}),c.scope(()=>{l.ok&&e.onUpdateValidValue&&e.onUpdateValidValue({componentID:r,value:m,eventType:u})}))}),()=>{v.update({[["form-data",e.form].join("-")]:{[e.name]:null}})}),[l])},ValidationCheck:t=>{let{states:n}=t,e="ValidationTimer-"+t.val_status.componentID;c.interval.abort(e);let a=t.SystemValidation({value:t.val_status.dataValue,states:n});if(!a.ok){t.set_validate(a);return}let i=a.notice;const l=()=>b(void 0,null,function*(){if(!n.onValidate)return;let s=yield n.onValidate({value:t.val_status.dataValue,eventType:t.val_status.eventType,props:t});t.set_validate({ok:s.ok,notice:[...i,...s.notice]})});if(n.onValidate){if(t.val_status.eventType=="refresh"){l();return}c.interval(l,450,e).once();return}t.set_validate({ok:!0,notice:i})},SubmitForm:(t,n)=>{let e=!1;if(!n)return e;let a=k(`[data-form-submit-button="${n}"]`)[0];if(!a)return e;let i=a.dataset.sdfike||"",l=t.key,s=t.ctrlKey||t.metaKey;return c.scope(()=>{i.includes("enter")&&(l!="Enter"||t.nativeEvent.isComposing||B.get().browserIs=="safari"&&t.keyCode==229)||((l=="Enter"&&(i.includes("enter")||i.includes("auxEnter")&&s)||l==" "&&i.includes("space"))&&(a.click(),t.preventDefault()),e=!0)}),e},isShowValidation:(t,n,e)=>{let a=t.ok;return!e&&n.eventType=="init"&&(a=!0),a}},nt=function(t){t=o({tone:"border"},t);let n=c.scope(()=>{if(t.tone=="plain")return{};let a={padding:"3/4",transition:"middle",flexSizing:"auto",boxShadow:"0.min"};return t.tone=="border"?a=d(o({},a),{border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"}):t.tone=="cloud"?a=d(o({},a),{border:"1.thin",borderRadius:"2.tone.secondary",backgroundColor:"cloud"}):t.tone=="bottomBorder"&&(a=d(o({},a),{borderRadius:0,border:"unset",borderBottom:!0,backgroundColor:"cloud"})),a});return d(o(o(o(o(o(o({fontColor:"2.normal"},n),!!t.rightIcon&&{paddingRight:3}),!!t.leftIcon&&{paddingLeft:3}),!!t.leftIndicator&&{borderTopLeftRadius:"2/3",borderBottomLeftRadius:"2/3",marginLeft:"1/4"}),!!t.rightIndicator&&{borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",marginRight:"1/4"}),t),{freeCSS:o({letterSpacing:"1px",resize:"none"},t.freeCSS),className:[_("Input"),t.className].join(" ")})};export{at as BoxWrapper,z as CoreEffects,nt as DefaultBoxishStyles,et as OptionalInputWrapper};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as s,c as h,d as
|
|
1
|
+
import{b as s,c as h,d as y}from"../chunk-C5N2D3ZX.js";import{jsx as g,jsxs as B}from"react/jsx-runtime";import{useState as x,useEffect as N}from"react";import a,{UUID as R}from"jmini";import{$$fromRoot as c,Config as w,pageRouter as F}from"../@utils";import{Box as S,Flex as C,Column as P}from"../atoms";import{Button as H}from"./Button";import{LayoutClasses as f}from"../@styles/componentClasses";const d={Base:t=>{let n=t,{topNavigation:o,sideNavigation:e,footerNavigation:i,children:l,className:r}=n,u=y(n,["topNavigation","sideNavigation","footerNavigation","children","className"]);N(()=>{d.fn.updateCSSProperty.reset(),setTimeout(()=>{d.fn.updateCSSProperty.reset()},100);let p="ResizeCB",m="RemovePageEventCB";return a(window).addEvent({eventType:"resize",eventID:p,callback:()=>{w.get().screen.isPhonepoint()||a.interval(()=>{d.fn.updateCSSProperty.reset()},300,"__RVC_calcHeights").once()}}),()=>{a(window).removeEvent(m),a(window).removeEvent(p)}},[]);let v=l;return B(P,h(s({className:[r,f("RootViewController")].join(" "),backgroundColor:"layer.1",gap:0,minHeight:"viewHeight"},u),{children:[o,B(C,{className:f("Body"),flexWrap:!1,position:"relative",flexSizing:0,children:[e,g(S,{className:f("Content"),position:"relative",flexSizing:0,width:0,UnderBreakPointStyles:{width:"auto"},children:v})]}),i]}))},TopNavigation:t=>{let r=t,{className:o,children:e}=r,i=y(r,["className","children"]),[l]=x(R());return N(()=>{d.fn.updateCSSProperty.topNav()},[]),g(C,h(s({"data-id":l,flexSizing:"none",flexType:"col",position:"sticky",top:0,backgroundColor:"layer.1"},i),{id:"__RVC_TopNavigation",className:[o,f("TopNav")].join(" "),children:e}),l)},SideNavigation:t=>{let i=t,{className:o=""}=i,e=y(i,["className"]);return N(()=>{d.fn.updateCSSProperty.sideNav()},[]),g(S,h(s({className:[o,f("SideNav")].join(" "),flexSizing:"none",minHeight:"sideNavigationHeight"},e),{id:"__RVC_SideNavigation"}))},FooterNavigation:t=>{let r=t,{className:o="",baseStyles:e}=r,i=y(r,["className","baseStyles"]),[l]=x(R());return N(()=>{d.fn.updateCSSProperty.footer()},[]),g(C,h(s({"data-id":l,borderTop:!0,position:"sticky",bottom:0,overflow:"auto",backgroundColor:"layer.1",paddingBottom:"safeAreaBottom"},e),{id:"__RVC_FooterNavigation",className:[f("FooterNav"),o].join(" "),children:g(C,s({gap:1,flexWrap:!1,padding:"2/3",margin:"auto"},i))}))},Comps:{Button:t=>{let v=t,{isActive:o,uri:e,uriGroup:i}=v,l=y(v,["isActive","uri","uriGroup"]),r=a.flatArray(i),u=location.pathname;{let n=!1;if(a.is.exist(e)&&a.is.string(e)){let p=[location.origin,e.replace(/\//,"")].join("/");n=u==new URL(p).pathname}if(!n&&r.length)for(let p of r)a.is.nullish(p)||u.match(new RegExp(p))&&(n=!0);o=o!=null?o:n}return g(H.Clear,s({isActive:o,isActiveStyles:{fontColor:"theme",backgroundColor:"cloud"},onClick:n=>{a.is.exist(e)&&a.is.string(e)&&F.push(e,n.ctrlKey||n.metaKey)},color:"cloud",padding:["3/4",1],display:"flex",gap:"1/2",fontColor:"inherit",width:1,flexSizing:"none",flexWrap:!1,ssEffectsOnActive:"ripple.cloud",verticalAlign:"center",textAlign:"left",isSemiBoldFont:!0},l))},Bar:t=>g(S,s({flexSizing:"none",backgroundColor:"layer.4.opa.middle",unitHeight:"1/3",margin:["2/3",1],isRounded:!0},t)),Title:t=>g(S,s({fontSize:"3.paragraph",isSemiBoldFont:!0,padding:[0,1]},t))},fn:{updateCSSProperty:{topNav:()=>{let t=a(document.body),o=c("#__RVC_TopNavigation"),e=o.position().height||0,i=e;o.getStyleProperty("position")!="sticky"&&(i=0),t.setStyleProperty("--topNavHeight",e+"px").setStyleProperty("--topBase",i+"px")},footer:()=>{let t=a(document.body),e=c("#__RVC_FooterNavigation").position().height||0;t.setStyleProperty("--footerNavHeight",e+"px")},sideNav:()=>{let t=a(document.body),e=c("#__RVC_SideNavigation").position().width||0;t.setStyleProperty("--sideNavWidth",e+"px")},reset:()=>{let t=a(document.body),o=c("#__RVC_TopNavigation"),e=c("#__RVC_FooterNavigation"),i=c("#__RVC_SideNavigation"),l=o.position().height||0,r=l,u=e.position().height||0,v=i.position().width||0;o.getStyleProperty("position")!="sticky"&&(r=0);let n=window.innerHeight,p=window.innerWidth,m=n-l-u,_=p-v;t.setStyleProperty("--topNavHeight",l+"px").setStyleProperty("--topBase",r+"px").setStyleProperty("--footerNavHeight",u+"px").setStyleProperty("--viewHeight",n+"px").setStyleProperty("--sideNavHeight",m+"px").setStyleProperty("--contentHeight",m+"px").setStyleProperty("--contentWidth",_+"px")}}}};export{d as RootViewController,d as default};
|
package/dist/fn/Snackbar.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as c,c as m,d as v}from"../chunk-C5N2D3ZX.js";import{Fragment as R,jsx as r,jsxs as _}from"react/jsx-runtime";import{createElement as M}from"react";import x,{UUID as f,useStore as p}from"jmini";import{Config as C,$$fromRoot as
|
|
1
|
+
import{b as c,c as m,d as v}from"../chunk-C5N2D3ZX.js";import{Fragment as R,jsx as r,jsxs as _}from"react/jsx-runtime";import{createElement as M}from"react";import x,{UUID as f,useStore as p}from"jmini";import{Config as C,$$fromRoot as E}from"../@utils";import{useState as k,useEffect as S}from"react";import{Box as w,Flex as y,FAI as A}from"../atoms";import{Row as T}from"../mols";import{Button as F}from"./Button";import{SnackbarClasses as I}from"../@styles/componentClasses";const u={add:function(s){let t=p.get("Snackbar-"+C.get().sessionUID);return t&&t.add(s),this},remove:function(s){let t=p.get("Snackbar-"+C.get().sessionUID);return t&&t.remove(s),this},Wrapper:()=>r(B.Wrapper,{})},B={Cell:s=>{let b=s,{snackID:t,secondsToClose:o,componentID:g=f(),children:i,customChildren:e}=b,a=v(b,["snackID","secondsToClose","componentID","children","customChildren"]),[n]=k(g),[l,d]=k(s.secondsToClose||10);S(()=>{let D=E('[data-component-id="'+n+'"]');setTimeout(()=>{D.addClass(I("FadeIn"))},10),p.set({["Snackbar-"+t]:{remove:()=>{D.addClass(I("FadeOut"))}}})},[]),S(()=>{x.interval(()=>{l<=0||d(l-1)},1e3,"Snackbar-"+n).once(),l===0&&u.remove(t)},[l]);let h=r(R,{});return e?h=r(e,{close:()=>{u.remove(t)}}):h=_(T.Separate,{verticalAlign:"top",children:[r(w,{padding:["1/4",0],flexSizing:0,children:x.is.function(i)?r(i,{}):i}),r(F.Clear,{color:"layer",backgroundColor:"layer.4.opa.low",fontColor:"white",ssSphere:2.5,onClick:()=>{u.remove(t)},children:r(A.Times,{})})]}),r(w,m(c({className:I("Cell"),componentID:n,onMouseOver:()=>{d(-1)},onMouseOut:()=>{d(o||10)},opacity:"trans",width:1,padding:"2/3",marginBottom:1,borderRadius:"1.tone.primary",fontColor:"white",boxShadow:"1.remark",backgroundColor:"dark",transition:"middle"},a),{children:h}))},Wrapper:()=>{let[s,t]=k(f()),[o,g]=k([]);S(()=>{p.set({["Snackbar-"+C.get().sessionUID]:{add:e=>{e.snackID=e.snackID||f();let a=o.findIndex(n=>n.snackID==e.snackID);if(a==-1)o.unshift(m(c({},e),{snackID:e.snackID}));else{let n=[...o];n[a]=m(c({},e),{snackID:e.snackID}),o=n}t(f())},remove:e=>{let a=p.get("Snackbar-"+e);a&&a.remove&&(a.remove(),setTimeout(()=>{let n=o.findIndex(d=>d.snackID==e);if(n==-1)return;let l=[...o];l.splice(n,1),g(l)},210))}}})},[o.length]);let i=o.map(e=>M(B.Cell,m(c({},e),{key:e.snackID})));return r(y,{className:["AMOTIFY_be",I("Wrapper")].join(" "),position:"fixed",right:0,bottom:0,paddingLeft:0,paddingRight:1,paddingBottom:"safeAreaBottom",verticalAlign:"bottom",overflow:"auto",UnderBreakPointStyles:{left:0,paddingLeft:1,width:"auto"},children:i})}};export{u as Snackbar,u as default};
|
package/dist/fn/SwipeView.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as S,c as T,d as D}from"../chunk-C5N2D3ZX.js";import{jsx as I}from"react/jsx-runtime";import c,{UUID as N}from"jmini";import{useState as k,useEffect as L,useRef as X}from"react";import{$$fromRoot as h}from"../@utils";import{Box as R,Flex as j}from"../atoms";import{LayoutClasses as a}from"../@styles/componentClasses";const _=t=>{let C=t,{options:{onSlideCallback:e,visibilitySurroundSlide:u=!0,autoSwipems:d=0,loop:i=!1,disableMousedrag:r=!1,disableTouch:o=!1}={},wrapper:s=n=>n,slides:f=[],slideIndex:B}=C,E=D(C,["options","wrapper","slides","slideIndex"]),[x]=k(N()),[p,y]=k({eventType:"init",index:t.slideIndex});const g=X(!1);L(()=>{y({eventType:"usr",index:t.slideIndex}),g.current||(g.current=!0)},[t.slideIndex]),L(()=>{let n=p.index+(i?1:0),m=[-1,f.length].includes(p.index);m||e&&setTimeout(()=>{e(p.index)},300);let b=h("#Swiper-"+x);if(p.eventType=="adjustLoop")b.await(250).css({transition:"0s",transform:l.TrasformString(n)}).children().removeClass(a("Display")).parent().children(n).addClass([a("Display"),a("LoopAdjusting")]).await(100).removeClass(a("LoopAdjusting"));else if(p.eventType=="sys")b.await(250).css({transform:l.TrasformString(n)}).children().removeClass(a("Display")).parent().children(n).addClass(a("Display"));else if(b.children().removeClass(a("Display")).parent().children(n).addClass(a("Display")).parent().css({transition:"0.3s",transform:l.TrasformString(n)}).await(250).css({transition:"0s"}),m){let v=p.index==-1?f.length-1:0;y({eventType:"adjustLoop",index:v})}d&&!m&&c.interval(()=>{let v=p.index+1;!i&&v>f.length-1&&(v=0),y({eventType:"usr",index:v})},d-(p.eventType=="sys"?310:0),"SwipeTimer-"+x).once()},[p]);let w=f.map((n,m)=>I(R,{flexSizing:"none",width:1,height:0,className:a("Child"),children:s(n)},m));i&&(w.push(w[0]),w.unshift(w[w.length-2]));let M={x:0,y:0,process:!1,effectStartAt:0,id:x,loop:i,index:p.index,minIndex:i?-1:0,maxIndex:f.length+(i?1:-1),width:0,set_event:y},A=p.index+(i?1:0);return I(R,T(S({overflow:"hidden",position:"relative"},E),{className:[E.className,a("SwipeView")].join(" "),freeCSS:S({zIndex:1},E.freeCSS),"data-swipe-id":x,onMouseDown:n=>{r||n.buttons==1&&l.EffectStart(n,M)},onTouchStart:n=>{var m;o||((m=n.touches)==null?void 0:m.length)==1&&l.EffectStart(n,M)},children:I(j,{flexWrap:!1,gap:1,transition:"long",className:[a("Rail"),a("ShowOther_"+u)].join(" "),id:"Swiper-"+x,freeCSS:S({},g.current?{}:{transform:l.TrasformString(A)}),children:w})}))},l={TrasformString:t=>`translateX( calc( ${-100*t}% - ${12*t}px ) )`,EffectStart:(t,e)=>{let{x:u,y:d}=c.getCursor(t),i=t.currentTarget,r=t.target;if(["SELECT","BUTTON","LABEL","INPUT"].includes(r.tagName))return;e=T(S({},e),{x:u-e.x+window.scrollX,y:d-e.y+window.scrollY,effectStartAt:new Date().getTime(),width:h("#Swiper-"+e.id).position().width});let{swipeId:o}=i.dataset;o==e.id&&c(document).addEvent({eventID:"SwipeMouseMove",eventType:"mousemove",callback:s=>{l.EffectCheck(s,e)},options:{passive:!1}}).addEvent({eventID:"SwipeTouchMove",eventType:"touchmove",callback:s=>{l.EffectCheck(s,e)},options:{passive:!1}}).addEvent({eventID:"SwipeMouseUp",eventType:"mouseup",callback:s=>{l.EffectEnd(s,e)},options:{passive:!1}}).addEvent({eventID:"SwipeTouchEnd",eventType:"touchend",callback:s=>{l.EffectEnd(s,e)},options:{passive:!1}})},EffectCheck:(t,e)=>{if(e.process)return;let{x:u,y:d}=c.getCursor(t),i=Math.abs(u-e.x+window.scrollX),r=Math.abs(d-e.y+window.scrollY);if(!(t.touches&&t.touches.length>1)&&!(r+i<15))if(r>i/2)c(document).removeEvent(["SwipeMouseMove","SwipeTouchMove"]);else{e.process=!0;let o=e.index+(e.loop?1:0);h("#Swiper-"+e.id).children(o-1).addClass(a("Display")),c(document).addEvent({eventID:"SwipeCheckMouseMove",eventType:"mousemove",callback:s=>{l.EffectMove(s,e)},options:{passive:!1}}).addEvent({eventID:"SwipeCheckTouchMove",eventType:"touchmove",callback:s=>{l.EffectMove(s,e)},options:{passive:!1}}),t.preventDefault();return}},EffectMove:(t,e)=>{if(t.touches&&t.touches.length>1)return;let{x:u}=c.getCursor(t),d=u-e.x+window.scrollX,r=e.index+(e.loop?1:0)-d/e.width;if(r<0)r/=2;else if(r>e.maxIndex){let o=r-e.maxIndex;r=e.maxIndex+o/2}h("#Swiper-"+e.id).css({transition:"0s",transform:l.TrasformString(r)}),t.preventDefault()},EffectEnd:(t,e)=>{if(e.process){let d=c.getCursor(t).x-e.x+window.scrollX,i=new Date().getTime(),r=i-e.effectStartAt,o=e.index+(e.loop?1:0),s=0;r<400?s=o-(+(d>0)*2-1):s=Math.round(o-d/e.width),s=Math.max(Math.min(s,e.maxIndex),e.minIndex),e.process=!1,o===s?(e.effectStartAt=i,h("#Swiper-"+e.id).css({transition:".2s",transform:l.TrasformString(s)}).await(310).css({transition:"0s"}).children().removeClass(a("Display")).parent().children(o).addClass(a("Display"))):e.set_event({eventType:"usr",index:s+e.minIndex})}c(document).removeEvent(["SwipeMouseMove","SwipeTouchMove","SwipeCheckMouseMove","SwipeCheckTouchMove","SwipeMouseUp","SwipeTouchEnd"])}},V=t=>I(_,T(S({},t),{slideIndex:Math.max(Math.min(t.slideIndex,t.slides.length-1),0)}));export{V as SwipeView,V as default};
|
package/dist/fn/Table/Data.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as r,c as m,d as Y}from"../../chunk-C5N2D3ZX.js";import{Fragment as z,jsx as l,jsxs as x}from"react/jsx-runtime";import D,{UUID as Z,useStore as ee}from"jmini";import{useState as te,useEffect as W}from"react";import{useRefresh as F}from"../../@utils";import{Box as B,Flex as K,FAI as N,Span as le,Column as oe}from"../../atoms";import{Row as E}from"../../mols";import{Button as H}from"../Button";import j from"../Sheet";import L from"../Input";import{faArrowUp as ne}from"@fortawesome/free-solid-svg-icons/faArrowUp";import{faArrowDown as se}from"@fortawesome/free-solid-svg-icons/faArrowDown";import{faArrowRight as ie}from"@fortawesome/free-solid-svg-icons/faArrowRight";import{faFilter as ce}from"@fortawesome/free-solid-svg-icons/faFilter";import R from"./Parts";import de from"./Wrapper";import{DefaultCellSystemAdjustingStyles as V}from"./cellStyling";import{TableClasses as y}from"../../@styles/componentClasses";const I={__memoryID:Z(),Header:t=>{var h,b;let{val_status:e,set_status:n,KeywordFilterRows:u}=r({},t),{order:s,filter:a}=e,[d,g]=s.current,p=[],c=[...e.head];if(e.checker){let o={top:!0,bottom:!e.rows.length,left:!0,right:!e.colLength,rowIndex:0,colIndex:0,isBody:!1,isHeader:!0},i=V(o),f=e.cellStylesCallback?e.cellStylesCallback(o):{};p.push(l(R.TH,m(r(r(r({fontWeight:"2.normal",position:"sticky",top:0,unitWidth:4,padding:0},e.cellStyles),i),f),{freeCSS:m(r(r({},(h=e.cellStyles)==null?void 0:h.freeCSS),f.freeCSS),{zIndex:2}),className:[y("Cell"),e.cellClassName].join(" "),children:l(B,{flexCenter:!0,children:l(L.Checker,{label:null,value:!1,onUpdateValidValue:({value:S})=>{let C=e.rows;C.forEach(O=>{O.checked=S}),n(m(r({},e),{rows:C}))}})})}),-1))}for(let o=0;o<e.colLength;o++){let i=c[o];if(!i)continue;let f=i.children||i.data,S=s.enabled&&s.column[o],C=a.enabled&&a.column[o],O=S?l(N,{fontSize:"1.mini",fontColor:o==d?"1.clear":"5.translucent",icon:o==d?g=="DESC"?se:ne:ie}):null,v=l(z,{});if(C){let _=u.map(P=>{var A;return(A=P[o])==null?void 0:A.data});_=[...new Set(_)].order({direction:"ASC"});let T=a.current[o];if(T){let P=_.filter(w=>!T.includes(w)),A=[];_.forEach(w=>{w&&A.push({value:w,label:l(B,{flexSizing:"auto",children:w})})});let X="BUTTON-"+e.componentID+"-"+o,$=e.componentID+"-"+o,G={sheetID:$,parent:"#"+X,gravityPoint:23,type:"custom",content:x(K,{flexType:"col",border:!0,boxShadow:"3.remark",backgroundColor:"layer.1",borderRadius:1,freeCSS:{minWidth:12*20,maxWidth:12*30},children:[l(oe,{gap:"1/3",overflow:"auto",padding:"2/3",freeCSS:{maxHeight:12*30},children:l(L.Checkbox,{icon:!0,value:P,display:"flex",gap:"1/2",override:"force",options:A,hideInput:!0,name:"DTFilter-col-"+o+"-table-"+e.componentID,onUpdateValidValue:({value:w})=>{let M=_.filter(ae=>!w.includes(ae)),Q=r({},e);Q.filter.current[o]=M,n(Q)}})}),x(E.Separate,{gap:"2/3",padding:"2/3",horizontalAlign:"right",children:[l(H.Border.S,{isRounded:!0,onClick:()=>{j.close($)},children:"\u9589\u3058\u308B"}),l(H.Prime.S,{color:"theme",isRounded:!0,ssEffectsOnActive:"shrink",onClick:()=>{let w=[];T.length||(w=_);let M=r({},e);M.filter.current[o]=w,n(M)},children:"\u5168\u9078\u629E"})]})]})};j.open(G,!1),v=l(B,{className:y("FilterRegion"),children:l(H.Sub.S,{ssSphere:2.5,fontSize:"1.mini",className:y("Filtering_"+!!T.length),id:X,onClick:w=>{w.stopPropagation(),j.open(G)},children:l(N,{icon:ce})})})}}let q={top:!0,bottom:!e.rows.length,left:e.checker?!1:o==0,right:o==e.colLength-1,rowIndex:0,colIndex:o,isBody:!1,isHeader:!0},re=V(q),J=e.cellStylesCallback?e.cellStylesCallback(q):{};i=m(r(r(r(r({},e.cellStyles),re),i),J),{ssPushable:S,freeCSS:r(r(r({},(b=e.cellStyles)==null?void 0:b.freeCSS),J.freeCSS),i.freeCSS),className:[y("Cell"),e.cellClassName,i.className].join(" ")}),delete i.orderIndex,p.push(l(R.TH,m(r({fontWeight:"2.normal",position:"sticky",top:0},i),{freeCSS:r({zIndex:2},i.freeCSS),onClick:_=>{if(S){let T=r({},e),P=[o,d===o&&g=="ASC"?"DESC":"ASC"];T.order.current=P,n(T),e.onOrderChanged&&e.onOrderChanged(P)}},children:x(K,{flexType:"row-r",flexWrap:!1,height:1,borderRadius:"inherit",flexCenter:!0,children:[v,x(K,{flexSizing:0,position:"relative",borderRadius:"inherit",gap:"1/2",flexWrap:!1,verticalAlign:"center",horizontalAlign:"center",children:[O,f]})]})}),o))}return l(R.Row,{className:[y("Row"),y("HeadRow")].join(" "),children:p})},Body:t=>{let{val_status:e,PageRows:n}=t,u=[];if(n.forEach((s,a)=>{var p;let d=[...s],g=[];if(e.checker){let c={top:a==0&&!e.head,bottom:a==n.length-1,left:!0,right:!e.colLength,rowIndex:a,colIndex:0,isBody:!0,isHeader:!1},h=V(c),b=e.cellStylesCallback?e.cellStylesCallback(c):{};g.push(l(R.TH,m(r(r(r({unitWidth:4,padding:0,borderRight:!0},e.cellStyles),h),b),{freeCSS:r(r({},(p=e.cellStyles)==null?void 0:p.freeCSS),b.freeCSS),className:[y("Cell"),e.cellClassName].join(" "),children:l(B,{flexCenter:!0,children:l(L.Checker,{label:null,value:s.checked,override:"force",onUpdateValidValue:({value:o})=>{let i=e.rows,f=i.findIndex(S=>D.is.equal(S.rowID,s.rowID));f!=-1&&(i[f].checked=o,t.set_status(S=>m(r({},S),{rows:i})))}})})}),-1))}d.forEach((c,h)=>{var v;if(!c)return;let O=c,{type:b="td"}=O,o=Y(O,["type"]),i={top:a==0&&!e.head,bottom:a==n.length-1,left:e.checker?!1:h==0,right:h==e.colLength-1,rowIndex:a,colIndex:h,isBody:!0,isHeader:!1},f=V(i),S=e.cellStylesCallback?e.cellStylesCallback(i):{};o=m(r(r(r(r({},e.cellStyles),f),o),S),{freeCSS:r(r(r({},(v=e.cellStyles)==null?void 0:v.freeCSS),o.freeCSS),S.freeCSS),className:[y("Cell"),e.cellClassName,o.className].join(" ")}),delete o.orderIndex;let C=R[b=="td"?"TD":"TH"];g.push(l(C,r({},o),h))}),u.push(l(R.Row,{className:[y("Row"),y("BodyRow")].join(" "),children:g,onClick:c=>{e.onRowClick&&e.onRowClick(s.rowID,c)}},a))}),!n.length){let s=l(B,{padding:2,fontColor:"4.thin",textAlign:"center",borderTop:"1.thin",children:"\u30C6\u30FC\u30D6\u30EB\u304C\u3042\u308A\u307E\u305B\u3093"});e.noRecords&&(s=l(z,{children:e.noRecords})),u.push(l(R.Row,{className:[y("Row"),y("BodyRow"),y("DataNotFound")].join(" "),children:l(R.TD,{colSpan:e.colLength,className:y("Cell"),children:s})},"dataNotFound"))}return l(z,{children:u})},Core:t=>{let{val_status:e,set_status:n}=t,{searchKeyword:u,filter:s,order:a,paging:d}=e,g=[...e.rows],p=[...e.rows],c=[...e.rows],h=[...e.rows];if(u&&(p=g.filter(i=>(i.__sys4SearchKey||"").match(new RegExp(u,"i"))?1:0),c=[...p],h=[...p]),s.enabled)for(let i=0;i<e.colLength;i++){let f=s.column[i],S=s.current[i];f&&S&&S.length&&(c=c.filter(C=>!S.includes(C[i].data)),h=[...c])}a.enabled&&(c=c.order({direction:a.current[1],keys:[a.current[0],"orderIndex"]}),h=[...c]);{let{currentPageIndex:i,rowLength:f}=d;h=[...h].splice((i-1)*f,f)}let b=I.__memoryID+"_"+e.tableID,o={rows:{total:g.length,page:h.length,filtered:c.length},val_status:m(r({},e),{paging:m(r({},e.paging),{pageLength:Math.ceil(c.length/e.paging.rowLength)})}),set_status:n};return ee.update({[b]:{getRowData:()=>{let i=[...g];return a.enabled&&(i=i.order({direction:a.current[1],keys:[a.current[0],"orderIndex"]})),i.forEach(f=>{f.currentPage=!1,f.filtered=!1}),h.forEach(f=>{let{rowID:S}=f;i.find(C=>D.is.equal(C.rowID,S)).currentPage=!0}),c.forEach(f=>{let{rowID:S}=f;i.find(C=>D.is.equal(C.rowID,S)).filtered=!0}),i}}}),W(()=>{F.release(e.tableID,o)}),l(B,{className:y("TableBase"),children:l(R.Table,{className:y("Table"),children:x(R.Body,{children:[l(I.Header,{val_status:e,set_status:n,KeywordFilterRows:p}),l(I.Body,{val_status:e,set_status:n,PageRows:h})]})})},u)},Propagations:{},DataLeveler:t=>{var e,n;return t=r({},t),t.filter=(e=t.filter)!=null?e:!1,t.filter=Array.from({length:t.colLength}).map((u,s)=>{var a;return D.is.boolean(t.filter)?t.filter:(a=t.filter[s])!=null?a:!1}),t.order=(n=t.order)!=null?n:!0,t.order=Array.from({length:t.colLength}).map((u,s)=>{var a;return D.is.boolean(t.order)?t.order:(a=t.order[s])!=null?a:!0}),t=r({checker:!1,searchKeyword:"",filter:!1,order:!0,defaultOrder:[0,"ASC"]},t),t.rows.forEach((u,s)=>{u.rowID=u.rowID||s;let a=[];u.forEach((d,g)=>{let{data:p,children:c,orderIndex:h}=d;d.orderIndex=D.is.exist(h)?String(h):String(p),d.children=c||String(p),a.push(String(d.data))}),u.__sys4SearchKey=a.join("/")}),l(I.StateManager,r({},t))},StateManager:t=>{let{colLength:e,checker:n=!1,searchKeyword:u="",filter:s,order:a,defaultOrder:d=[0,"ASC"],pageRowLength:g=30}=t,[p]=te(Z()),c={tableID:t.tableID||p,componentID:p,colLength:e,checker:n,searchKeyword:u,filter:{enabled:s!==!1,column:s,current:Array.from({length:e},()=>[])},order:{enabled:a!==!1,column:a,current:d},paging:{rowLength:g,pageLength:Math.ceil(t.rows.length/g),currentPageIndex:1},head:t.head,rows:t.rows,noRecords:t.noRecords,cellStyles:t.cellStyles||{},cellClassName:t.cellClassName||"",cellStylesCallback:t.cellStylesCallback,onRowClick:t.onRowClick,onOrderChanged:t.onOrderChanged},[h,b]=te(c);return W(()=>{b(o=>m(r({},o),{rows:c.rows}))},[D.Stringify(c.rows)]),W(()=>{b(o=>m(r({},o),{head:c.head}))},[D.Stringify(c.head)]),l(I.Core,{val_status:h,set_status:b})}},ue={__memoryID:I.__memoryID,getRowData:t=>{let e=ee.get(I.__memoryID+"_"+t);if(e!=null&&e.getRowData)return e.getRowData()}},U={SearchInput:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:n,set_status:u}=e;return l(L.TextField,{label:"\u691C\u7D22...",clearButton:!0,padding:"2/3",paddingRight:3,rightIcon:l(L.RightIcon,{ssSphere:2,fontColor:"5.translucent",right:"2/3",children:l(N.Search,{})}),value:n.searchKeyword,onUpdateValidValue:({value:s})=>{t.onChange(s),D.cycle(()=>{u(a=>m(r({},a),{paging:m(r({},a.paging),{currentPageIndex:1}),filter:m(r({},a.filter),{current:Array.from({length:a.colLength},()=>[])}),searchKeyword:s}))},200,"InputSearchTime").once()}})},Info:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:n,set_status:u}=e,s=e.rows.filtered.ratio(e.rows.total)||0;return x(K,{verticalAlign:"baseline",gap:"1/2",fontSize:"1.mini",fontColor:"3.blur",children:[l(le,{fontSize:"4.thirdTitle",fontColor:"theme",children:e.rows.filtered.toLocaleString()}),"/ ",e.rows.total.toLocaleString(),"\u4EF6 (",s,"%)"]})},Paging:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:n,set_status:u}=e,s=[];for(let d=0;d<n.paging.pageLength;d++)s.push({value:d+1,label:(d+1).toString()});const a=d=>{let g=Math.min(Math.max(1,d),n.paging.pageLength),p=r({},n);p.paging.currentPageIndex=g,u(c=>m(r({},c),{paging:m(r({},c.paging),{currentPageIndex:g})}))};return x(E.Center,{children:[x(E.Center,{gap:"1/2",children:[l(L.Select,{label:"\u9805",freeCSS:{minWidth:12*3},emptySelect:!1,padding:["1/3","2/3"],rightIcon:!1,override:"force",value:n.paging.currentPageIndex,options:s,onUpdateValidValue:({value:d})=>{a(d)}}),"/ ",n.paging.pageLength]}),x(E.Right,{gap:"1/2",children:[l(H.Sub,{ssSphere:3,onClick:()=>{if(n.paging.currentPageIndex==1){a(n.paging.pageLength);return}a(n.paging.currentPageIndex-1)},children:l(N.ChevronLeft,{})}),l(H.Sub,{ssSphere:3,onClick:()=>{if(n.paging.currentPageIndex==n.paging.pageLength){a(1);return}a(n.paging.currentPageIndex+1)},children:l(N.ChevronRight,{})})]})]})},RowLength:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:n,set_status:u}=e,s=n.paging.rowLength,a=0,d=t.lengthSelect.map(g=>(a|=+(g==s),{value:g,label:g.toString()}));return a||d.push({value:s,label:s.toString()}),d=d.order({direction:"ASC",keys:["value"]}),l(E.Center,{gap:"1/2",children:l(L.Select,{label:"\u4EF6\u6570",emptySelect:!1,rightIcon:!1,override:"force",padding:["1/3","2/3"],SelectorStyles:{freeCSS:{minWidth:12*9}},SelectorPosition:4,value:n.paging.rowLength,options:d,onUpdateValidValue:({value:g})=>{u(p=>m(r({},p),{paging:{rowLength:Number(g),currentPageIndex:1,pageLength:Math.ceil(e.rows.filtered/Number(g))}}))}})})}},ge=t=>l(de,m(r({},t),{type:"data",JSXChildren:I.DataLeveler})),k=ge;k.__memoryID=I.__memoryID,k.getRowData=ue.getRowData,k.Info=U.Info,k.Paging=U.Paging,k.RowLength=U.RowLength,k.SearchInput=U.SearchInput;export{k as Data,k as default};
|
|
1
|
+
import{b as r,c as m,d as Y}from"../../chunk-C5N2D3ZX.js";import{Fragment as z,jsx as l,jsxs as x}from"react/jsx-runtime";import D,{UUID as Z,useStore as ee}from"jmini";import{useState as te,useEffect as W}from"react";import{useRefresh as F}from"../../@utils";import{Box as B,Flex as K,FAI as N,Span as le,Column as oe}from"../../atoms";import{Row as E}from"../../mols";import{Button as H}from"../Button";import j from"../Sheet";import L from"../Input";import{faArrowUp as ne}from"@fortawesome/free-solid-svg-icons/faArrowUp";import{faArrowDown as se}from"@fortawesome/free-solid-svg-icons/faArrowDown";import{faArrowRight as ie}from"@fortawesome/free-solid-svg-icons/faArrowRight";import{faFilter as ce}from"@fortawesome/free-solid-svg-icons/faFilter";import R from"./Parts";import de from"./Wrapper";import{DefaultCellSystemAdjustingStyles as V}from"./cellStyling";import{TableClasses as y}from"../../@styles/componentClasses";const I={__memoryID:Z(),Header:t=>{var h,b;let{val_status:e,set_status:n,KeywordFilterRows:u}=r({},t),{order:s,filter:a}=e,[d,g]=s.current,p=[],c=[...e.head];if(e.checker){let o={top:!0,bottom:!e.rows.length,left:!0,right:!e.colLength,rowIndex:0,colIndex:0,isBody:!1,isHeader:!0},i=V(o),f=e.cellStylesCallback?e.cellStylesCallback(o):{};p.push(l(R.TH,m(r(r(r({fontWeight:"2.normal",position:"sticky",top:0,unitWidth:4,padding:0},e.cellStyles),i),f),{freeCSS:m(r(r({},(h=e.cellStyles)==null?void 0:h.freeCSS),f.freeCSS),{zIndex:2}),className:[y("Cell"),e.cellClassName].join(" "),children:l(B,{flexCenter:!0,children:l(L.Checker,{label:null,value:!1,onUpdateValidValue:({value:S})=>{let C=e.rows;C.forEach(O=>{O.checked=S}),n(m(r({},e),{rows:C}))}})})}),-1))}for(let o=0;o<e.colLength;o++){let i=c[o];if(!i)continue;let f=i.children||i.data,S=s.enabled&&s.column[o],C=a.enabled&&a.column[o],O=S?l(N,{fontSize:"1.mini",fontColor:o==d?"1.clear":"5.translucent",icon:o==d?g=="DESC"?se:ne:ie}):null,v=l(z,{});if(C){let _=u.map(P=>{var A;return(A=P[o])==null?void 0:A.data});_=[...new Set(_)].order({direction:"ASC"});let T=a.current[o];if(T){let P=_.filter(w=>!T.includes(w)),A=[];_.forEach(w=>{w&&A.push({value:w,label:l(B,{flexSizing:"auto",children:w})})});let X="BUTTON-"+e.componentID+"-"+o,$=e.componentID+"-"+o,G={sheetID:$,parent:"#"+X,gravityPoint:23,type:"custom",content:x(K,{flexType:"col",border:!0,boxShadow:"3.remark",backgroundColor:"layer.1",borderRadius:1,freeCSS:{minWidth:12*20,maxWidth:12*30},children:[l(oe,{gap:"1/3",overflow:"auto",padding:"2/3",freeCSS:{maxHeight:12*30},children:l(L.Checkbox,{icon:!0,value:P,display:"flex",gap:"1/2",override:"force",options:A,hideInput:!0,name:"DTFilter-col-"+o+"-table-"+e.componentID,onUpdateValidValue:({value:w})=>{let M=_.filter(ae=>!w.includes(ae)),Q=r({},e);Q.filter.current[o]=M,n(Q)}})}),x(E.Separate,{gap:"2/3",padding:"2/3",horizontalAlign:"right",children:[l(H.Border.S,{isRounded:!0,onClick:()=>{j.close($)},children:"\u9589\u3058\u308B"}),l(H.Prime.S,{color:"theme",isRounded:!0,ssEffectsOnActive:"shrink",onClick:()=>{let w=[];T.length||(w=_);let M=r({},e);M.filter.current[o]=w,n(M)},children:"\u5168\u9078\u629E"})]})]})};j.open(G,!1),v=l(B,{className:y("FilterRegion"),children:l(H.Sub.S,{ssSphere:2.5,fontSize:"1.mini",className:y("Filtering_"+!!T.length),id:X,onClick:w=>{w.stopPropagation(),j.open(G)},children:l(N,{icon:ce})})})}}let q={top:!0,bottom:!e.rows.length,left:e.checker?!1:o==0,right:o==e.colLength-1,rowIndex:0,colIndex:o,isBody:!1,isHeader:!0},re=V(q),J=e.cellStylesCallback?e.cellStylesCallback(q):{};i=m(r(r(r(r({},e.cellStyles),re),i),J),{ssPushable:S,freeCSS:r(r(r({},(b=e.cellStyles)==null?void 0:b.freeCSS),J.freeCSS),i.freeCSS),className:[y("Cell"),e.cellClassName,i.className].join(" ")}),delete i.orderIndex,p.push(l(R.TH,m(r({fontWeight:"2.normal",position:"sticky",top:0},i),{freeCSS:r({zIndex:2},i.freeCSS),onClick:_=>{if(S){let T=r({},e),P=[o,d===o&&g=="ASC"?"DESC":"ASC"];T.order.current=P,n(T),e.onOrderChanged&&e.onOrderChanged(P)}},children:x(K,{flexType:"row-r",flexWrap:!1,height:1,borderRadius:"inherit",flexCenter:!0,children:[v,x(K,{flexSizing:0,position:"relative",borderRadius:"inherit",gap:"1/2",flexWrap:!1,verticalAlign:"center",horizontalAlign:"center",children:[O,f]})]})}),o))}return l(R.Row,{className:[y("Row"),y("HeadRow")].join(" "),children:p})},Body:t=>{let{val_status:e,PageRows:n}=t,u=[];if(n.forEach((s,a)=>{var p;let d=[...s],g=[];if(e.checker){let c={top:a==0&&!e.head,bottom:a==n.length-1,left:!0,right:!e.colLength,rowIndex:a,colIndex:0,isBody:!0,isHeader:!1},h=V(c),b=e.cellStylesCallback?e.cellStylesCallback(c):{};g.push(l(R.TH,m(r(r(r({unitWidth:4,padding:0,borderRight:!0},e.cellStyles),h),b),{freeCSS:r(r({},(p=e.cellStyles)==null?void 0:p.freeCSS),b.freeCSS),className:[y("Cell"),e.cellClassName].join(" "),children:l(B,{flexCenter:!0,children:l(L.Checker,{label:null,value:s.checked,override:"force",onUpdateValidValue:({value:o})=>{let i=e.rows,f=i.findIndex(S=>D.is.equal(S.rowID,s.rowID));f!=-1&&(i[f].checked=o,t.set_status(S=>m(r({},S),{rows:i})))}})})}),-1))}d.forEach((c,h)=>{var v;if(!c)return;let O=c,{type:b="td"}=O,o=Y(O,["type"]),i={top:a==0&&!e.head,bottom:a==n.length-1,left:e.checker?!1:h==0,right:h==e.colLength-1,rowIndex:a,colIndex:h,isBody:!0,isHeader:!1},f=V(i),S=e.cellStylesCallback?e.cellStylesCallback(i):{};o=m(r(r(r(r({},e.cellStyles),f),o),S),{freeCSS:r(r(r({},(v=e.cellStyles)==null?void 0:v.freeCSS),o.freeCSS),S.freeCSS),className:[y("Cell"),e.cellClassName,o.className].join(" ")}),delete o.orderIndex;let C=R[b=="td"?"TD":"TH"];g.push(l(C,r({},o),h))}),u.push(l(R.Row,{className:[y("Row"),y("BodyRow")].join(" "),children:g,onClick:c=>{e.onRowClick&&e.onRowClick(s.rowID,c)}},a))}),!n.length){let s=l(B,{padding:2,fontColor:"4.thin",textAlign:"center",borderTop:"1.thin",children:"\u30C6\u30FC\u30D6\u30EB\u304C\u3042\u308A\u307E\u305B\u3093"});e.noRecords&&(s=l(z,{children:e.noRecords})),u.push(l(R.Row,{className:[y("Row"),y("BodyRow"),y("DataNotFound")].join(" "),children:l(R.TD,{colSpan:e.colLength,className:y("Cell"),children:s})},"dataNotFound"))}return l(z,{children:u})},Core:t=>{let{val_status:e,set_status:n}=t,{searchKeyword:u,filter:s,order:a,paging:d}=e,g=[...e.rows],p=[...e.rows],c=[...e.rows],h=[...e.rows];if(u&&(p=g.filter(i=>(i.__sys4SearchKey||"").match(new RegExp(u,"i"))?1:0),c=[...p],h=[...p]),s.enabled)for(let i=0;i<e.colLength;i++){let f=s.column[i],S=s.current[i];f&&S&&S.length&&(c=c.filter(C=>!S.includes(C[i].data)),h=[...c])}a.enabled&&(c=c.order({direction:a.current[1],keys:[a.current[0],"orderIndex"]}),h=[...c]);{let{currentPageIndex:i,rowLength:f}=d;h=[...h].splice((i-1)*f,f)}let b=I.__memoryID+"_"+e.tableID,o={rows:{total:g.length,page:h.length,filtered:c.length},val_status:m(r({},e),{paging:m(r({},e.paging),{pageLength:Math.ceil(c.length/e.paging.rowLength)})}),set_status:n};return ee.update({[b]:{getRowData:()=>{let i=[...g];return a.enabled&&(i=i.order({direction:a.current[1],keys:[a.current[0],"orderIndex"]})),i.forEach(f=>{f.currentPage=!1,f.filtered=!1}),h.forEach(f=>{let{rowID:S}=f;i.find(C=>D.is.equal(C.rowID,S)).currentPage=!0}),c.forEach(f=>{let{rowID:S}=f;i.find(C=>D.is.equal(C.rowID,S)).filtered=!0}),i}}}),W(()=>{F.release(e.tableID,o)}),l(B,{className:y("TableBase"),children:l(R.Table,{className:y("Table"),children:x(R.Body,{children:[l(I.Header,{val_status:e,set_status:n,KeywordFilterRows:p}),l(I.Body,{val_status:e,set_status:n,PageRows:h})]})})},u)},Propagations:{},DataLeveler:t=>{var e,n;return t=r({},t),t.filter=(e=t.filter)!=null?e:!1,t.filter=Array.from({length:t.colLength}).map((u,s)=>{var a;return D.is.boolean(t.filter)?t.filter:(a=t.filter[s])!=null?a:!1}),t.order=(n=t.order)!=null?n:!0,t.order=Array.from({length:t.colLength}).map((u,s)=>{var a;return D.is.boolean(t.order)?t.order:(a=t.order[s])!=null?a:!0}),t=r({checker:!1,searchKeyword:"",filter:!1,order:!0,defaultOrder:[0,"ASC"]},t),t.rows.forEach((u,s)=>{u.rowID=u.rowID||s;let a=[];u.forEach((d,g)=>{let{data:p,children:c,orderIndex:h}=d;d.orderIndex=D.is.exist(h)?String(h):String(p),d.children=c||String(p),a.push(String(d.data))}),u.__sys4SearchKey=a.join("/")}),l(I.StateManager,r({},t))},StateManager:t=>{let{colLength:e,checker:n=!1,searchKeyword:u="",filter:s,order:a,defaultOrder:d=[0,"ASC"],pageRowLength:g=30}=t,[p]=te(Z()),c={tableID:t.tableID||p,componentID:p,colLength:e,checker:n,searchKeyword:u,filter:{enabled:s!==!1,column:s,current:Array.from({length:e},()=>[])},order:{enabled:a!==!1,column:a,current:d},paging:{rowLength:g,pageLength:Math.ceil(t.rows.length/g),currentPageIndex:1},head:t.head,rows:t.rows,noRecords:t.noRecords,cellStyles:t.cellStyles||{},cellClassName:t.cellClassName||"",cellStylesCallback:t.cellStylesCallback,onRowClick:t.onRowClick,onOrderChanged:t.onOrderChanged},[h,b]=te(c);return W(()=>{b(o=>m(r({},o),{rows:c.rows}))},[D.Stringify(c.rows)]),W(()=>{b(o=>m(r({},o),{head:c.head}))},[D.Stringify(c.head)]),l(I.Core,{val_status:h,set_status:b})}},ue={__memoryID:I.__memoryID,getRowData:t=>{let e=ee.get(I.__memoryID+"_"+t);if(e!=null&&e.getRowData)return e.getRowData()}},U={SearchInput:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:n,set_status:u}=e;return l(L.TextField,{label:"\u691C\u7D22...",clearButton:!0,padding:"2/3",paddingRight:3,rightIcon:l(L.RightIcon,{ssSphere:2,fontColor:"5.translucent",right:"2/3",children:l(N.Search,{})}),value:n.searchKeyword,onUpdateValidValue:({value:s})=>{t.onChange(s),D.interval(()=>{u(a=>m(r({},a),{paging:m(r({},a.paging),{currentPageIndex:1}),filter:m(r({},a.filter),{current:Array.from({length:a.colLength},()=>[])}),searchKeyword:s}))},200,"InputSearchTime").once()}})},Info:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:n,set_status:u}=e,s=e.rows.filtered.ratio(e.rows.total)||0;return x(K,{verticalAlign:"baseline",gap:"1/2",fontSize:"1.mini",fontColor:"3.blur",children:[l(le,{fontSize:"4.thirdTitle",fontColor:"theme",children:e.rows.filtered.toLocaleString()}),"/ ",e.rows.total.toLocaleString(),"\u4EF6 (",s,"%)"]})},Paging:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:n,set_status:u}=e,s=[];for(let d=0;d<n.paging.pageLength;d++)s.push({value:d+1,label:(d+1).toString()});const a=d=>{let g=Math.min(Math.max(1,d),n.paging.pageLength),p=r({},n);p.paging.currentPageIndex=g,u(c=>m(r({},c),{paging:m(r({},c.paging),{currentPageIndex:g})}))};return x(E.Center,{children:[x(E.Center,{gap:"1/2",children:[l(L.Select,{label:"\u9805",freeCSS:{minWidth:12*3},emptySelect:!1,padding:["1/3","2/3"],rightIcon:!1,override:"force",value:n.paging.currentPageIndex,options:s,onUpdateValidValue:({value:d})=>{a(d)}}),"/ ",n.paging.pageLength]}),x(E.Right,{gap:"1/2",children:[l(H.Sub,{ssSphere:3,onClick:()=>{if(n.paging.currentPageIndex==1){a(n.paging.pageLength);return}a(n.paging.currentPageIndex-1)},children:l(N.ChevronLeft,{})}),l(H.Sub,{ssSphere:3,onClick:()=>{if(n.paging.currentPageIndex==n.paging.pageLength){a(1);return}a(n.paging.currentPageIndex+1)},children:l(N.ChevronRight,{})})]})]})},RowLength:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:n,set_status:u}=e,s=n.paging.rowLength,a=0,d=t.lengthSelect.map(g=>(a|=+(g==s),{value:g,label:g.toString()}));return a||d.push({value:s,label:s.toString()}),d=d.order({direction:"ASC",keys:["value"]}),l(E.Center,{gap:"1/2",children:l(L.Select,{label:"\u4EF6\u6570",emptySelect:!1,rightIcon:!1,override:"force",padding:["1/3","2/3"],SelectorStyles:{freeCSS:{minWidth:12*9}},SelectorPosition:4,value:n.paging.rowLength,options:d,onUpdateValidValue:({value:g})=>{u(p=>m(r({},p),{paging:{rowLength:Number(g),currentPageIndex:1,pageLength:Math.ceil(e.rows.filtered/Number(g))}}))}})})}},ge=t=>l(de,m(r({},t),{type:"data",JSXChildren:I.DataLeveler})),k=ge;k.__memoryID=I.__memoryID,k.getRowData=ue.getRowData,k.Info=U.Info,k.Paging=U.Paging,k.RowLength=U.RowLength,k.SearchInput=U.SearchInput;export{k as Data,k as default};
|
package/dist/fn/Tips.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunk-C5N2D3ZX.js";import{jsx as n}from"react/jsx-runtime";import i,{UUID as
|
|
1
|
+
import"../chunk-C5N2D3ZX.js";import{jsx as n}from"react/jsx-runtime";import i,{UUID as a}from"jmini";import{Text as m}from"../mols";import{Tooltips as e}from".";const t={uid:a(),open:(o,p,r=24,d=.35)=>{o&&i.interval(()=>{e.open({tipsID:t.uid,parent:o,gravityPoint:r||24,padding:"1/2",content:n(e.Body,{padding:"1/2",borderRadius:"3.tone.tertiary",children:n(m.Supplement,{children:p})})})},d*1e3,t.uid).once()},abort:()=>{i.interval.abort(t.uid),e.close(t.uid)}};export{t as Tips};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amotify",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.96",
|
|
4
4
|
"description": "UI Component for React,NextJS,esbuild",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "run-p clean build:*",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@fortawesome/free-regular-svg-icons": "^6.5.2",
|
|
90
90
|
"@fortawesome/free-solid-svg-icons": "^6.6.0",
|
|
91
91
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
92
|
-
"jmini": "^0.0.
|
|
92
|
+
"jmini": "^0.0.20",
|
|
93
93
|
"react": "^18.3.1"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|