amotify 0.2.166 → 0.2.168
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/demo/esbuild/designBook.tsx +63 -68
- package/demo/esbuild/public/index.js +67 -67
- package/dist/atoms/Img.js +1 -1
- package/dist/fn/Cropper.js +1 -1
- package/dist/fn/Input/Time/index.js +1 -1
- package/dist/fn/Sheet.d.ts +43 -43
- package/dist/fn/Sheet.js +1 -1
- package/dist/fn/Table/Data.js +1 -1
- package/dist/fn/Tooltips.js +1 -1
- package/package.json +2 -2
package/dist/atoms/Img.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as e,c as s,d as i}from"../chunk-C5N2D3ZX.js";import{jsx as I}from"react/jsx-runtime";import c from"./Box";import{Sheet as f}from"../fn";import{ImgClasses as m}from"../@styles/componentClasses";const l=p=>{let a=p,{src:n="",alt:g="",showExpand:t}=a,o=i(a,["src","alt","showExpand"]);return I(c,s(e({htmlTag:"img",src:n,alt:g},o),{className:[m("Img"),m("ShowExpand_"+!!t),o.className].join(" "),onPointerDown:r=>{o.onPointerDown&&o.onPointerDown(r),t&&r.stopPropagation()},onClick:r=>{o.onClick&&o.onClick(r),t&&(r.stopPropagation(),f.image({},t!=!0?t:n))},freeCSS:e({cursor:t?"zoom-in":"inherit"},o.freeCSS)}))};export{l as Img,l as default};
|
package/dist/fn/Cropper.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as H,c as K,e as F}from"../chunk-C5N2D3ZX.js";import{jsx as i,jsxs as f}from"react/jsx-runtime";import y,{UUID as J,useStore as X}from"jmini";import{$$fromRoot as Z}from"../@utils";import{useState as N,useEffect as O}from"react";import{Box as B,FAI as L,Column as M}from"../atoms";import{Row as R,Literal as A}from"../mols";import{Button as P}from"./Button";import U from"./Sheet";import V from"./Loader";import $ 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 W}from"../@styles/componentClasses";import Y from"./Tooltips";class re{constructor(a){this.set_scale=a.set_scale,this.val_file=a.val_file,this.develops=a.develops;{let[c,m]=y.is.array(a.use)&&a.use||a.use.split(":").map(o=>Number(o)),g=c/m;this.usage={w:c,h:m,aspect:g}}this.componentID=a.componentID,this.scale={current:a.scale.default,default:a.scale.default,min:a.scale.min,max:a.scale.max};let s=a.canvas;this.Canvas={elm:s,ctx:s.getContext("2d")};let e=a.picture.image,{width:r,height:t}=e,n=r/t;this.Picture={elm:e,originDataUrl:e.src,aspect:n,revisedAspect:1,rotate:a.picture.rotate,grayScale:a.picture.grayScale,tone:a.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:r/2,imageY:t/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 a=this.Canvas.elm,s=this.Picture.elm,e=0,r=0;if(this.usage.aspect==1){let o=a.width*.6666666666666666,l=a.height*(2/3);r=e=Math.min(o,l)}else this.usage.aspect>1?(e=a.width*(8/10),r=e/this.usage.aspect):(r=a.height*(8/10),e=r*this.usage.aspect);let{width:t,height:n}=s,c=(a.width-e)/2,m=(a.height-r)/2,g=e/r;this.pst={frame:{x:c,y:m,w:e,h:r,aspect:g},outImage:{x:0,y:0,w:0,h:0},imageX:t/2,imageY:n/2,centerX:a.width/2,centerY:a.height/2}}dragEffect(a){let{eventType:s,x:e,y:r}=a;if(s=="start"){let t=this.Canvas.elm.position();this.dragEffectInfo={origin:{x:e,y:r},frameExpandRate:{x:this.Canvas.elm.width/t.width,y:this.Canvas.elm.height/t.height}}}else{let{origin:t,frameExpandRate:n}=this.dragEffectInfo,c=t.x-e,m=t.y-r,g=this.scale.current*this.Picture.revisedAspect/100,o=c/g*n.x,l=m/g*n.y;s=="move"?this.drawImage(this.pst.imageX+o,this.pst.imageY+l):s=="end"&&this.drawImage(this.pst.imageX+=o,this.pst.imageY+=l)}}pinchEffect(a){let{eventType:s,event:e}=a,{x:r,y:t}=y.getCursor(e.touches[0]),{x:n,y:c}=y.getCursor(e.touches[1]),m=n-r,g=c-t;if(s=="start")this.pinchEffectInfo.origin={x:m,y:g,scale:this.scale.current};else if(s=="move"){let{origin:o}=this.pinchEffectInfo,l=Math.sqrt(Math.pow(o.x,2)+Math.pow(o.y,2)),v=Math.sqrt(Math.pow(m,2)+Math.pow(g,2))/l,C=Number(o.scale*v);this.set_scale(C)}}updateScale(a){let s=a;s=Math.max(s,this.scale.min),s=Math.min(s,this.scale.max),this.scale.current=s,this.drawImage()}updateFilter(a){this.Picture.grayScale=a.grayScale,this.Picture.tone=a.tone,this.Picture.rotate=a.rotate,this.modifyImage()}modifyImage(){return F(this,null,function*(){let{grayScale:a,tone:s,rotate:e}=this.Picture;const r=document.createElement("canvas");let t=r.getContext("2d"),n=yield y.ImageLoader(this.Picture.originDataUrl),c=n.width,m=n.height;(e==90||e==270)&&(c=n.height,m=n.width),r.width=c,r.height=m,a&&(t.filter="grayscale("+a+"%)"),e&&(t.translate(c/2,m/2),t.rotate(e*Math.PI/180),[90,270].includes(e)?t.translate(-m/2,-c/2):t.translate(-c/2,-m/2)),t.drawImage(n,0,0,n.width,n.height);let g=t.getImageData(0,0,r.width,r.height),o=g.data;{a/=100;let C=[[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]][s],w=C[0]/255,x=C[1]/255,p=C[2]/255;for(let h=0;h<m;h++)for(let u=0;u<c;u++){var l=(h*c+u)*4;if(a){let E=.3*o[l]+.59*o[l+1]+.11*o[l+2];for(var S=0;S<3;S++){let D=o[l+S];o[l+S]=D+(E-D)*a}}o[l]*=w,o[l+1]*=x,o[l+2]*=p}}t.putImageData(g,0,0);let v=r.toDataURL("image/jpeg");{let C=yield y.ImageLoader(v),{width:w,height:x}=C,p=w/x;this.Picture=K(H({},this.Picture),{elm:C,aspect:p,revisedAspect:this.pst.frame.aspect>p?this.pst.frame.w/w:this.pst.frame.h/x})}this.drawImage()})}drawImage(a,s){let{Canvas:{ctx:e,elm:r},pst:{frame:t}}=this,n=a||this.pst.imageX,c=s||this.pst.imageY;{let m=this.scale.current/100,g=this.Picture.revisedAspect*m,o=this.pst.centerX-n*g,l=this.pst.centerY-c*g,S=this.Picture.elm.width*g,v=this.Picture.elm.height*g;{let C=this.pst.frame.x+this.pst.frame.w-S,w=this.pst.frame.x,x=this.pst.frame.y+this.pst.frame.h-v,p=this.pst.frame.y,h=0;o<C&&(h=o-C),o>w&&(h=o-w);let u=0;l<x&&(u=l-x),l>p&&(u=l-p),this.dragEffectInfo.origin.x+=h/2/this.dragEffectInfo.frameExpandRate.x,this.dragEffectInfo.origin.y+=u/2/this.dragEffectInfo.frameExpandRate.y,o=Math.min(Math.max(o,C),w),l=Math.min(Math.max(l,x),p)}this.pst.outImage={x:o,y:l,w:S,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,o,l,S,v)}{if(this.usage.aspect==1){e.fillStyle="rgba( 20,24,20,.3 )",e.beginPath();let o=r.width/3*2,l=r.height/3*2,S=Math.min(o,l),v=Math.max(o,l);e.arc(r.width/2,r.height/2,v*1.41,0,Math.PI*2,!0),e.arc(r.width/2,r.height/2,S/2,0,Math.PI*2,!1),e.closePath(),e.fill()}else e.fillStyle="rgba( 20,24,20,.3 )";e.beginPath(),e.moveTo(0,0),e.lineTo(r.width,0),e.lineTo(r.width,r.height),e.lineTo(0,r.height),e.lineTo(0,0),e.closePath(),e.lineTo(t.x,t.y),e.lineTo(t.x,t.y+t.h),e.lineTo(t.x+t.w,t.y+t.h),e.lineTo(t.x+t.w,t.y),e.lineTo(t.x,t.y),e.fill();let g=y(document.body).getStyleProperty("--color-theme-hsl");e.lineWidth=4,e.strokeStyle=`hsla( ${g},1 )`,e.strokeRect(t.x,t.y,t.w,t.h)}}export(){return F(this,null,function*(){let{Canvas:a,develops:s,Picture:e,pst:{outImage:r,frame:t}}=this,n=r.w/e.elm.width,c=r.h/e.elm.height,m=(t.x-r.x)/n,g=(t.x-r.x+t.w)/n,o=(t.y-r.y)/c,l=(t.y-r.y+t.h)/c,S=Array.from({length:s.length}),v="image/jpeg";for(let C=0;C<s.length;C++){let{size:w,maxSize:x}=s[C];x=x||{S:1024*20,R:1024*100,L:1024*350}[w];let p={S:140,R:600,L:1200}[w],h=p;this.usage.aspect>1?h=p/this.usage.aspect:p=h*this.usage.aspect;let u=document.createElement("canvas");u.width=p,u.height=h;let E=u.getContext("2d");if(!E)return;E.clearRect(0,0,p,h),E.drawImage(this.Picture.elm,m,o,g-m,l-o,0,0,p,h);let D=u.toDataURL(v),b=yield D.toBlob(v);if(!b)return;if(b.size>=x){let k=x/b.size;if(D=u.toDataURL(v,k*.92),b=yield D.toBlob(v),!b)return}let z=new File([b],this.val_file.name,{type:v});S[C]=z}return S})}}const q={Core:d=>{let{val_file:a,options:s,finishedCallback:e,abortCallback:r}=d,{use:t,develops:n=[]}=s,[c]=N(J());const m={scale:{default:120,min:100,max:400},rotate:0,grayScale:0,tone:0};let[g,o]=N(m.scale.default),[l,S]=N(m.rotate),[v,C]=N(m.grayScale),[w,x]=N(m.tone);return O(()=>{let p="CropperResize";return y(window).addEvent({eventType:"resize",eventID:p,callback:()=>{y.interval.once(()=>{var k;let h=Z("#Canvas-"+c)[0];if(!h)return;let u=(k=X.get(c))==null?void 0:k.Instance;if(!u)return;let E=h.position(),D=E.width/E.height;h.width=2400,h.height=2400/D;let{width:b,height:z}=h;u.pst.centerX=b/2,u.pst.centerY=z/2,u.frameSizing(),u.modifyImage()},250,"CropperResize")}}),()=>{y(window).removeEvent(p)}},[]),O(()=>{X.set({[c]:{}}),F(void 0,null,function*(){V.fn.corner.active(),yield y.pending(()=>{},400);let{target:p}=yield a.convert();if(!p)return;let h=p.result,u=Z("#Canvas-"+c)[0];if(!u)return;let E=u.position(),D=E.width/E.height;u.width=2400,u.height=2400/D;let b=new re({set_scale:o,val_file:a,develops:n,use:t,scale:m.scale,componentID:c,canvas:u,picture:{image:yield y.ImageLoader(h),grayScale:m.grayScale,tone:m.tone,rotate:m.rotate}});X.set({[c]:{Instance:b}});const z=function(I){if(I.preventDefault(),I.touches&&I.touches.length>1)b.pinchEffect({eventType:"start",event:I}),y(document).addEvent({eventType:"touchmove",eventID:"CropperEffectMove",options:{passive:!1},callback:_=>{_.preventDefault(),b.pinchEffect({eventType:"move",event:_})}}).addEvent({eventType:"touchend",eventID:"CropperEffectEnd",options:{passive:!1},callback:G});else{b.dragEffect(H({eventType:"start"},y.getCursor(I)));let{type:_}=I;y(document).addEvent({eventType:_=="touchstart"?"touchmove":"mousemove",eventID:"CropperEffectMove",options:{passive:!1},callback:T=>{k("move",T)}}).addEvent({eventType:_=="touchstart"?"touchend":"mouseup",eventID:"CropperEffectEnd",options:{passive:!1},callback:T=>{k("end",T),G(T)}})}},k=function(I,_){_.preventDefault(),b.dragEffect(H({eventType:I},y.getCursor(_)))},G=function(I){I.preventDefault(),y(document).removeEvent(["CropperEffectMove","CropperEffectEnd"])};y(u).removeEvent(["CropperMouseWheel","CropperTouchStart","CropperMouseDown"]).addEvent({eventID:"CropperMouseWheel",eventType:"wheel",callback:I=>{I.preventDefault();let _=Number(I.wheelDelta*.04),T=b.scale.current+_;T=Math.max(T,b.scale.min),T=Math.min(T,b.scale.max),o(T)},options:{passive:!1}}).addEvent({eventType:"touchstart",eventID:"CropperTouchStart",callback:z,options:{passive:!1}}).addEvent({eventType:"mousedown",eventID:"CropperMouseDown",callback:z,options:{passive:!1}}),setTimeout(()=>{V.fn.corner.stop()},1e3)})},[a.id]),O(()=>{var h;let p=(h=X.get(c))==null?void 0:h.Instance;p&&p.updateScale(g)},[g]),O(()=>{var h;let p=(h=X.get(c))==null?void 0:h.Instance;p&&p.updateFilter({grayScale:v,tone:w,rotate:l})},[v,w,l]),i(U.Body,{borderRadius:0,height:"viewHeight",width:"viewWidth",children:f(M,{className:[W("Wrap"),W("Use_"+t)].join(" "),gap:0,height:1,position:"relative",overflow:"hidden",borderRadius:"inherit",children:[i(B,{flexSizing:0,overflow:"hidden",position:"relative",backgroundColor:"black",flexCenter:!0,freeCSS:{zIndex:1},children:i("canvas",{style:{width:"100%",height:"100%"},width:2400,height:2400,className:W("Canvas"),id:"Canvas-"+c})}),f(R.Separate,{borderTop:!0,flexSizing:"none",backgroundColor:"layer.1",padding:1,verticalAlign:"unset",UnderBreakPointStyles:{flexType:"col"},children:[i(q.SettingRegion,{DefaultOptions:m,val_scale:g,set_scale:o,val_tone:w,set_tone:x,val_grayScale:v,set_grayScale:C,val_rotate:l,set_rotate:S}),f(R.Right,{flexSizing:"none",children:[i(P.Border,{isRounded:!0,onClick:()=>{r()},children:"\u9589\u3058\u308B"}),i(P,{isRounded:!0,boxShadow:"3.remark",onClick:()=>F(void 0,null,function*(){var u;let p=(u=X.get(c))==null?void 0:u.Instance;if(!p)return;V.fn.mini.active("CropperExportation");let h=yield p.export();setTimeout(()=>{V.fn.mini.stop("CropperExportation"),e(h)},3e3)}),children:f(R.Center,{gap:"1/2",children:[i(V.White.R,{loaderID:"CropperExportation"}),"\u6C7A\u5B9A"]})})]})]})]})})},SettingRegion:d=>{let a=["","\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"],s=e=>a[e]||"\u306A\u3057";return f(R.Left,{verticalAlign:"unset",flexWrap:!0,children:[f(M,{gap:"1/3",children:[i(A.Supplement,{children:"Rotate"}),f(R.Left,{flexChilds:"even",gap:"1/6",children:[i(P.Border.S,{isRounded:!0,borderTopRightRadius:0,borderBottomRightRadius:0,onClick:()=>{let e=d.val_rotate-90;e<0&&(e+=360),d.set_rotate(e)},children:f(R.Center,{gap:"1/4",children:["90\xB0",i(L,{icon:te})]})}),i(P.Border.S,{isRounded:!0,borderTopLeftRadius:0,borderBottomLeftRadius:0,onClick:()=>{d.set_rotate((d.val_rotate+90)%360)},children:f(R.Center,{gap:"1/4",children:[i(L,{icon:ae}),"90\xB0"]})})]})]}),f(M,{gap:"1/3",freeCSS:{minWidth:12*6},children:[i(A.Supplement,{children:"Zoom"}),f(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:e=>{let r="CropperZoomEdit";Y.open({tipsID:r,gravityPoint:3,event:e,closeAtParentBlur:!1,freeCSS:{minWidth:12*26},content:i(U.Body,{children:f(M,{padding:1.5,children:[f(R.Separate,{children:[i(A.Paragraph,{children:f(R.Center,{gap:"1/2",children:[i(L.Search,{fontColor:"5.translucent"}),"Zoom"]})}),i(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(r)},children:i(L.Times,{})})]}),i(B,{borderBottom:!0,opacity:"low"}),i($.Slider,{override:"force",value:d.val_scale-100,min:d.DefaultOptions.scale.min-100,max:d.DefaultOptions.scale.max-100,step:25,onUpdateValidValue:(t,n)=>{y.interval.once(()=>{d.set_scale(t+100)},250,"Cropper.UpdateScale")},legends:{enable:!0,custom:t=>"x"+Math.round(100+t)/100}})]})})})},children:[d.val_scale.rate(1,0),"%"]})]}),f(M,{gap:"1/3",freeCSS:{minWidth:12*6},children:[i(A.Supplement,{children:"GrayScale"}),f(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:e=>{let r="CropperGrayScaleEdit";Y.open({tipsID:r,gravityPoint:3,event:e,closeAtParentBlur:!1,freeCSS:{minWidth:12*26},content:i(U.Body,{children:f(M,{padding:1.5,children:[f(R.Separate,{children:[i(A.Paragraph,{children:f(R.Center,{gap:"1/2",children:[i(L,{icon:Q,fontColor:"5.translucent"}),"Gray Scale"]})}),i(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(r)},children:i(L.Times,{})})]}),i(B,{borderBottom:!0,opacity:"low"}),i($.Slider,{value:d.val_grayScale,min:0,max:100,step:10,onUpdateValidValue:t=>{y.interval.once(()=>{d.set_grayScale(t)},250,"Cropper.GrayScale")},legends:{enable:!0,custom:t=>t+"%"}})]})})})},children:[d.val_grayScale.rate(1,0),"%"]})]}),f(M,{gap:"1/3",freeCSS:{minWidth:12*6},children:[i(A.Supplement,{children:"Tone"}),i(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:e=>{let r="CropperToneEdit";Y.open({tipsID:r,gravityPoint:3,event:e,closeAtParentBlur:!1,freeCSS:{minWidth:12*26,maxWidth:12*24},content:()=>{let t=[];for(let n=1;n<=10;n++)t.push({value:n,label:f(R.Left,{gap:"1/3",children:[i(B,{ssSphere:1,className:[W("ToneBall"),W("ToneBall_"+n)].join(" ")}),i(B,{textAlign:"left",flexSizing:0,children:s(n)})]})});return i(U.Body,{children:f(M,{padding:1.5,children:[f(R.Separate,{children:[i(A.Paragraph,{children:f(R.Center,{gap:"1/2",children:[i(L,{icon:ee,fontColor:"5.translucent"}),"Tone"]})}),i(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(r)},children:i(L.Times,{})})]}),i(B,{borderBottom:!0,opacity:"low"}),i($.Radio.Normal,{value:d.val_tone,gap:"1/2",cellStyles:{fontColor:"3.blur"},options:[{value:0,label:i(B,{flexSizing:0,textAlign:"center",children:"\u306A\u3057"})},...t],onUpdateValidValue:n=>{d.set_tone(n)}})]})})}})},children:f(R.Center,{gap:"1/2",children:[i(B,{boxShadow:"2.remark",ssSphere:1,className:[W("ToneBall"),W("ToneBall_"+d.val_tone)].join(" ")}),s(d.val_tone)]})})]})]})}},j={openDialogNEdit:d=>F(void 0,null,function*(){let a=yield $.Filer.fn.openDialog({accept:"image",multiple:!1});j.openEditor(H({imageFile:a[0]},d))}),openEditor:d=>F(void 0,null,function*(){let a="CropperImage";U.open({sheetID:a,type:"normal.middleCenter",size:"MAX",padding:0,margin:0,freeCSS:{maxWidth:"100%"},content:i(q.Core,{val_file:d.imageFile,options:d,finishedCallback:s=>{U.close(a),d.onProcessFinished(s)},abortCallback:()=>{U.close(a)}}),closeAtEscapeKeyDown:!1})})};export{j as Cropper,j as default};
|
|
1
|
+
import{b as H,c as K,e as F}from"../chunk-C5N2D3ZX.js";import{jsx as i,jsxs as f}from"react/jsx-runtime";import y,{UUID as J,useStore as X}from"jmini";import{$$fromRoot as Z}from"../@utils";import{useState as N,useEffect as O}from"react";import{Box as B,FAI as L,Column as M}from"../atoms";import{Row as R,Literal as A}from"../mols";import{Button as P}from"./Button";import U from"./Sheet";import V from"./Loader";import $ 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 W}from"../@styles/componentClasses";import Y from"./Tooltips";class re{constructor(a){this.set_scale=a.set_scale,this.val_file=a.val_file,this.develops=a.develops;{let[c,m]=y.is.array(a.use)&&a.use||a.use.split(":").map(o=>Number(o)),g=c/m;this.usage={w:c,h:m,aspect:g}}this.componentID=a.componentID,this.scale={current:a.scale.default,default:a.scale.default,min:a.scale.min,max:a.scale.max};let s=a.canvas;this.Canvas={elm:s,ctx:s.getContext("2d")};let e=a.picture.image,{width:r,height:t}=e,n=r/t;this.Picture={elm:e,originDataUrl:e.src,aspect:n,revisedAspect:1,rotate:a.picture.rotate,grayScale:a.picture.grayScale,tone:a.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:r/2,imageY:t/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 a=this.Canvas.elm,s=this.Picture.elm,e=0,r=0;if(this.usage.aspect==1){let o=a.width*.6666666666666666,l=a.height*(2/3);r=e=Math.min(o,l)}else this.usage.aspect>1?(e=a.width*(8/10),r=e/this.usage.aspect):(r=a.height*(8/10),e=r*this.usage.aspect);let{width:t,height:n}=s,c=(a.width-e)/2,m=(a.height-r)/2,g=e/r;this.pst={frame:{x:c,y:m,w:e,h:r,aspect:g},outImage:{x:0,y:0,w:0,h:0},imageX:t/2,imageY:n/2,centerX:a.width/2,centerY:a.height/2}}dragEffect(a){let{eventType:s,x:e,y:r}=a;if(s=="start"){let t=this.Canvas.elm.position();this.dragEffectInfo={origin:{x:e,y:r},frameExpandRate:{x:this.Canvas.elm.width/t.width,y:this.Canvas.elm.height/t.height}}}else{let{origin:t,frameExpandRate:n}=this.dragEffectInfo,c=t.x-e,m=t.y-r,g=this.scale.current*this.Picture.revisedAspect/100,o=c/g*n.x,l=m/g*n.y;s=="move"?this.drawImage(this.pst.imageX+o,this.pst.imageY+l):s=="end"&&this.drawImage(this.pst.imageX+=o,this.pst.imageY+=l)}}pinchEffect(a){let{eventType:s,event:e}=a,{x:r,y:t}=y.getCursor(e.touches[0]),{x:n,y:c}=y.getCursor(e.touches[1]),m=n-r,g=c-t;if(s=="start")this.pinchEffectInfo.origin={x:m,y:g,scale:this.scale.current};else if(s=="move"){let{origin:o}=this.pinchEffectInfo,l=Math.sqrt(Math.pow(o.x,2)+Math.pow(o.y,2)),v=Math.sqrt(Math.pow(m,2)+Math.pow(g,2))/l,C=Number(o.scale*v);this.set_scale(C)}}updateScale(a){let s=a;s=Math.max(s,this.scale.min),s=Math.min(s,this.scale.max),this.scale.current=s,this.drawImage()}updateFilter(a){this.Picture.grayScale=a.grayScale,this.Picture.tone=a.tone,this.Picture.rotate=a.rotate,this.modifyImage()}modifyImage(){return F(this,null,function*(){let{grayScale:a,tone:s,rotate:e}=this.Picture;const r=document.createElement("canvas");let t=r.getContext("2d"),n=yield y.ImageLoader(this.Picture.originDataUrl),c=n.width,m=n.height;(e==90||e==270)&&(c=n.height,m=n.width),r.width=c,r.height=m,a&&(t.filter="grayscale("+a+"%)"),e&&(t.translate(c/2,m/2),t.rotate(e*Math.PI/180),[90,270].includes(e)?t.translate(-m/2,-c/2):t.translate(-c/2,-m/2)),t.drawImage(n,0,0,n.width,n.height);let g=t.getImageData(0,0,r.width,r.height),o=g.data;{a/=100;let C=[[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]][s],w=C[0]/255,x=C[1]/255,p=C[2]/255;for(let h=0;h<m;h++)for(let u=0;u<c;u++){var l=(h*c+u)*4;if(a){let E=.3*o[l]+.59*o[l+1]+.11*o[l+2];for(var S=0;S<3;S++){let D=o[l+S];o[l+S]=D+(E-D)*a}}o[l]*=w,o[l+1]*=x,o[l+2]*=p}}t.putImageData(g,0,0);let v=r.toDataURL("image/jpeg");{let C=yield y.ImageLoader(v),{width:w,height:x}=C,p=w/x;this.Picture=K(H({},this.Picture),{elm:C,aspect:p,revisedAspect:this.pst.frame.aspect>p?this.pst.frame.w/w:this.pst.frame.h/x})}this.drawImage()})}drawImage(a,s){let{Canvas:{ctx:e,elm:r},pst:{frame:t}}=this,n=a||this.pst.imageX,c=s||this.pst.imageY;{let m=this.scale.current/100,g=this.Picture.revisedAspect*m,o=this.pst.centerX-n*g,l=this.pst.centerY-c*g,S=this.Picture.elm.width*g,v=this.Picture.elm.height*g;{let C=this.pst.frame.x+this.pst.frame.w-S,w=this.pst.frame.x,x=this.pst.frame.y+this.pst.frame.h-v,p=this.pst.frame.y,h=0;o<C&&(h=o-C),o>w&&(h=o-w);let u=0;l<x&&(u=l-x),l>p&&(u=l-p),this.dragEffectInfo.origin.x+=h/2/this.dragEffectInfo.frameExpandRate.x,this.dragEffectInfo.origin.y+=u/2/this.dragEffectInfo.frameExpandRate.y,o=Math.min(Math.max(o,C),w),l=Math.min(Math.max(l,x),p)}this.pst.outImage={x:o,y:l,w:S,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,o,l,S,v)}{if(this.usage.aspect==1){e.fillStyle="rgba( 20,24,20,.3 )",e.beginPath();let o=r.width/3*2,l=r.height/3*2,S=Math.min(o,l),v=Math.max(o,l);e.arc(r.width/2,r.height/2,v*1.41,0,Math.PI*2,!0),e.arc(r.width/2,r.height/2,S/2,0,Math.PI*2,!1),e.closePath(),e.fill()}else e.fillStyle="rgba( 20,24,20,.3 )";e.beginPath(),e.moveTo(0,0),e.lineTo(r.width,0),e.lineTo(r.width,r.height),e.lineTo(0,r.height),e.lineTo(0,0),e.closePath(),e.lineTo(t.x,t.y),e.lineTo(t.x,t.y+t.h),e.lineTo(t.x+t.w,t.y+t.h),e.lineTo(t.x+t.w,t.y),e.lineTo(t.x,t.y),e.fill();let g=y(document.body).getStyleProperty("--color-theme-hsl");e.lineWidth=4,e.strokeStyle=`hsla( ${g},1 )`,e.strokeRect(t.x,t.y,t.w,t.h)}}export(){return F(this,null,function*(){let{Canvas:a,develops:s,Picture:e,pst:{outImage:r,frame:t}}=this,n=r.w/e.elm.width,c=r.h/e.elm.height,m=(t.x-r.x)/n,g=(t.x-r.x+t.w)/n,o=(t.y-r.y)/c,l=(t.y-r.y+t.h)/c,S=Array.from({length:s.length}),v="image/jpeg";for(let C=0;C<s.length;C++){let{size:w,maxSize:x}=s[C];x=x||{S:1024*20,R:1024*100,L:1024*350}[w];let p={S:140,R:600,L:1200}[w],h=p;this.usage.aspect>1?h=p/this.usage.aspect:p=h*this.usage.aspect;let u=document.createElement("canvas");u.width=p,u.height=h;let E=u.getContext("2d");if(!E)return;E.clearRect(0,0,p,h),E.drawImage(this.Picture.elm,m,o,g-m,l-o,0,0,p,h);let D=u.toDataURL(v),b=yield D.toBlob(v);if(!b)return;if(b.size>=x){let k=x/b.size;if(D=u.toDataURL(v,k*.92),b=yield D.toBlob(v),!b)return}let z=new File([b],this.val_file.name,{type:v});S[C]=z}return S})}}const q={Core:d=>{let{val_file:a,options:s,finishedCallback:e,abortCallback:r}=d,{use:t,develops:n=[]}=s,[c]=N(J());const m={scale:{default:120,min:100,max:400},rotate:0,grayScale:0,tone:0};let[g,o]=N(m.scale.default),[l,S]=N(m.rotate),[v,C]=N(m.grayScale),[w,x]=N(m.tone);return O(()=>{let p="CropperResize";return y(window).addEvent({eventType:"resize",eventID:p,callback:()=>{y.interval.once(()=>{var k;let h=Z("#Canvas-"+c)[0];if(!h)return;let u=(k=X.get(c))==null?void 0:k.Instance;if(!u)return;let E=h.position(),D=E.width/E.height;h.width=2400,h.height=2400/D;let{width:b,height:z}=h;u.pst.centerX=b/2,u.pst.centerY=z/2,u.frameSizing(),u.modifyImage()},250,"CropperResize")}}),()=>{y(window).removeEvent(p)}},[]),O(()=>{X.set({[c]:{}}),F(void 0,null,function*(){V.fn.corner.active(),yield y.pending(()=>{},400);let{target:p}=yield a.convert();if(!p)return;let h=p.result,u=Z("#Canvas-"+c)[0];if(!u)return;let E=u.position(),D=E.width/E.height;u.width=2400,u.height=2400/D;let b=new re({set_scale:o,val_file:a,develops:n,use:t,scale:m.scale,componentID:c,canvas:u,picture:{image:yield y.ImageLoader(h),grayScale:m.grayScale,tone:m.tone,rotate:m.rotate}});X.set({[c]:{Instance:b}});const z=function(I){if(I.preventDefault(),I.touches&&I.touches.length>1)b.pinchEffect({eventType:"start",event:I}),y(document).addEvent({eventType:"touchmove",eventID:"CropperEffectMove",options:{passive:!1},callback:_=>{_.preventDefault(),b.pinchEffect({eventType:"move",event:_})}}).addEvent({eventType:"touchend",eventID:"CropperEffectEnd",options:{passive:!1},callback:G});else{b.dragEffect(H({eventType:"start"},y.getCursor(I)));let{type:_}=I;y(document).addEvent({eventType:_=="touchstart"?"touchmove":"mousemove",eventID:"CropperEffectMove",options:{passive:!1},callback:T=>{k("move",T)}}).addEvent({eventType:_=="touchstart"?"touchend":"mouseup",eventID:"CropperEffectEnd",options:{passive:!1},callback:T=>{k("end",T),G(T)}})}},k=function(I,_){_.preventDefault(),b.dragEffect(H({eventType:I},y.getCursor(_)))},G=function(I){I.preventDefault(),y(document).removeEvent(["CropperEffectMove","CropperEffectEnd"])};y(u).removeEvent(["CropperMouseWheel","CropperTouchStart","CropperMouseDown"]).addEvent({eventID:"CropperMouseWheel",eventType:"wheel",callback:I=>{I.preventDefault();let _=Number(I.wheelDelta*.04),T=b.scale.current+_;T=Math.max(T,b.scale.min),T=Math.min(T,b.scale.max),o(T)},options:{passive:!1}}).addEvent({eventType:"touchstart",eventID:"CropperTouchStart",callback:z,options:{passive:!1}}).addEvent({eventType:"mousedown",eventID:"CropperMouseDown",callback:z,options:{passive:!1}}),setTimeout(()=>{V.fn.corner.stop()},1e3)})},[a.id]),O(()=>{var h;let p=(h=X.get(c))==null?void 0:h.Instance;p&&p.updateScale(g)},[g]),O(()=>{var h;let p=(h=X.get(c))==null?void 0:h.Instance;p&&p.updateFilter({grayScale:v,tone:w,rotate:l})},[v,w,l]),i(U.Body,{borderRadius:0,height:"viewHeight",width:"viewWidth",children:f(M,{className:[W("Wrap"),W("Use_"+t)].join(" "),gap:0,height:1,position:"relative",overflow:"hidden",borderRadius:"inherit",children:[i(B,{flexSizing:0,overflow:"hidden",position:"relative",backgroundColor:"black",flexCenter:!0,freeCSS:{zIndex:1},children:i("canvas",{style:{width:"100%",height:"100%"},width:2400,height:2400,className:W("Canvas"),id:"Canvas-"+c})}),f(R.Separate,{borderTop:!0,flexSizing:"none",backgroundColor:"layer.1",padding:1,verticalAlign:"unset",UnderBreakPointStyles:{flexType:"col"},children:[i(q.SettingRegion,{DefaultOptions:m,val_scale:g,set_scale:o,val_tone:w,set_tone:x,val_grayScale:v,set_grayScale:C,val_rotate:l,set_rotate:S}),f(R.Right,{flexSizing:"none",children:[i(P.Border,{isRounded:!0,onClick:()=>{r()},children:"\u9589\u3058\u308B"}),i(P,{isRounded:!0,boxShadow:"3.remark",onClick:()=>F(void 0,null,function*(){var u;let p=(u=X.get(c))==null?void 0:u.Instance;if(!p)return;V.fn.mini.active("CropperExportation");let h=yield p.export();setTimeout(()=>{V.fn.mini.stop("CropperExportation"),e(h)},3e3)}),children:f(R.Center,{gap:"1/2",children:[i(V.White.R,{loaderID:"CropperExportation"}),"\u6C7A\u5B9A"]})})]})]})]})})},SettingRegion:d=>{let a=["","\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"],s=e=>a[e]||"\u306A\u3057";return f(R.Left,{verticalAlign:"unset",flexWrap:!0,children:[f(M,{gap:"1/3",children:[i(A.Supplement,{children:"Rotate"}),f(R.Left,{flexChilds:"even",gap:"1/6",children:[i(P.Border.S,{isRounded:!0,borderTopRightRadius:0,borderBottomRightRadius:0,onClick:()=>{let e=d.val_rotate-90;e<0&&(e+=360),d.set_rotate(e)},children:f(R.Center,{gap:"1/4",children:["90\xB0",i(L,{icon:te})]})}),i(P.Border.S,{isRounded:!0,borderTopLeftRadius:0,borderBottomLeftRadius:0,onClick:()=>{d.set_rotate((d.val_rotate+90)%360)},children:f(R.Center,{gap:"1/4",children:[i(L,{icon:ae}),"90\xB0"]})})]})]}),f(M,{gap:"1/3",freeCSS:{minWidth:12*6},children:[i(A.Supplement,{children:"Zoom"}),f(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:e=>{let r="CropperZoomEdit";Y.open({tipsID:r,gravityPoint:3,event:e,closeAtParentBlur:!1,freeCSS:{minWidth:12*26},content:i(U.Body,{children:f(M,{padding:1.5,children:[f(R.Separate,{children:[i(A.Paragraph,{children:f(R.Center,{gap:"1/2",children:[i(L.Search,{fontColor:"5.translucent"}),"Zoom"]})}),i(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(r)},children:i(L.Times,{})})]}),i(B,{borderBottom:!0,opacity:"low"}),i($.Slider,{override:"force",value:d.val_scale-100,min:d.DefaultOptions.scale.min-100,max:d.DefaultOptions.scale.max-100,step:25,onUpdateValidValue:(t,n)=>{y.interval.once(()=>{d.set_scale(t+100)},250,"Cropper.UpdateScale")},legends:{enable:!0,custom:t=>"x"+Math.round(100+t)/100}})]})})})},children:[d.val_scale.rate(1,0),"%"]})]}),f(M,{gap:"1/3",freeCSS:{minWidth:12*6},children:[i(A.Supplement,{children:"GrayScale"}),f(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:e=>{let r="CropperGrayScaleEdit";Y.open({tipsID:r,gravityPoint:3,event:e,closeAtParentBlur:!1,freeCSS:{minWidth:12*26},content:i(U.Body,{children:f(M,{padding:1.5,children:[f(R.Separate,{children:[i(A.Paragraph,{children:f(R.Center,{gap:"1/2",children:[i(L,{icon:Q,fontColor:"5.translucent"}),"Gray Scale"]})}),i(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(r)},children:i(L.Times,{})})]}),i(B,{borderBottom:!0,opacity:"low"}),i($.Slider,{value:d.val_grayScale,min:0,max:100,step:10,onUpdateValidValue:t=>{y.interval.once(()=>{d.set_grayScale(t)},250,"Cropper.GrayScale")},legends:{enable:!0,custom:t=>t+"%"}})]})})})},children:[d.val_grayScale.rate(1,0),"%"]})]}),f(M,{gap:"1/3",freeCSS:{minWidth:12*6},children:[i(A.Supplement,{children:"Tone"}),i(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:e=>{let r="CropperToneEdit";Y.open({tipsID:r,gravityPoint:3,event:e,closeAtParentBlur:!1,freeCSS:{minWidth:12*26,maxWidth:12*24},content:()=>{let t=[];for(let n=1;n<=10;n++)t.push({value:n,label:f(R.Left,{gap:"1/3",children:[i(B,{ssSphere:1,className:[W("ToneBall"),W("ToneBall_"+n)].join(" ")}),i(B,{textAlign:"left",flexSizing:0,children:s(n)})]})});return i(U.Body,{children:f(M,{padding:1.5,children:[f(R.Separate,{children:[i(A.Paragraph,{children:f(R.Center,{gap:"1/2",children:[i(L,{icon:ee,fontColor:"5.translucent"}),"Tone"]})}),i(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(r)},children:i(L.Times,{})})]}),i(B,{borderBottom:!0,opacity:"low"}),i($.Radio.Normal,{value:d.val_tone,gap:"1/2",cellStyles:{fontColor:"3.blur"},options:[{value:0,label:i(B,{flexSizing:0,textAlign:"center",children:"\u306A\u3057"})},...t],onUpdateValidValue:n=>{d.set_tone(n)}})]})})}})},children:f(R.Center,{gap:"1/2",children:[i(B,{boxShadow:"2.remark",ssSphere:1,className:[W("ToneBall"),W("ToneBall_"+d.val_tone)].join(" ")}),s(d.val_tone)]})})]})]})}},j={openDialogNEdit:d=>F(void 0,null,function*(){let a=yield $.Filer.fn.openDialog({accept:"image",multiple:!1});j.openEditor(H({imageFile:a[0]},d))}),openEditor:d=>F(void 0,null,function*(){let a="CropperImage";U.open("middleCenter",{sheetID:a,size:"MAX",padding:0,margin:0,freeCSS:{maxWidth:"100%"},content:i(q.Core,{val_file:d.imageFile,options:d,finishedCallback:s=>{U.close(a),d.onProcessFinished(s)},abortCallback:()=>{U.close(a)}}),closeAtEscapeKeyDown:!1})})};export{j as Cropper,j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ae,b as l,c as k,d as q}from"../../../chunk-C5N2D3ZX.js";import{Fragment as _e,jsx as y,jsxs as oe}from"react/jsx-runtime";import G,{UUID as N,useStore as L}from"jmini";import*as K from"jmini";import{useState as W,useEffect as Q,useRef as ce}from"react";import{$$fromRoot as pe,Config as re,ExtractStyles as ue}from"../../../@utils";import{Box as X,FAI as de}from"../../../atoms";import{Literal as fe,Row as he}from"../../../mols";import{Button as ie}from"../../Button";import ge from"../../Tooltips";import ye from"../../Sheet";import{faClock as De}from"@fortawesome/free-solid-svg-icons/faClock";import{faCalendarAlt as ve}from"@fortawesome/free-solid-svg-icons/faCalendarAlt";import{OptionalInputWrapper as Ie,BoxWrapper as Se,CoreEffects as z,DefaultBoxishStyles as Te}from"../core";import{RightIcon as be}from"..";import xe from"../Select";import{InputLabel as ke}from"../Label";import Ee from"./Picker";const F=" ~ ",we={clock:{defaultValue:"--:--",format:/^\d{2}\D\d{2}$/,ranges:[{type:"hour",from:0,length:2},{type:"minute",from:3,length:2}],sets:1},date:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2}],sets:1},week:{defaultValue:"----\u5E74\u7B2C--\u9031",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4,region:6},{type:"week",from:6,length:2,region:3}],sets:1},month:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:3}],sets:1},year:{defaultValue:"----\u5E74",format:/^\d{4}$/,ranges:[{type:"year",from:0,length:4,region:5}],sets:1},dates:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2,region:5},{type:"year",from:10+F.length,length:4},{type:"month",from:15+F.length,length:2},{type:"date",from:18+F.length,length:2}],sets:2},months:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:6},{type:"year",from:8+F.length,length:4},{type:"month",from:13+F.length,length:2,region:3}],sets:2},dateWareki:{defaultValue:"----\u5E74--\u6708--\u65E5",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"dateWareki",from:0,length:4,region:5},{type:"month",from:5,length:2,region:3},{type:"date",from:8,length:2,region:3}],sets:1}},O={PeriodMargin:" ~ ",DataLeveling:e=>{let{restrict:t,value:D,era:a}=e,d=G.flatArray(D||""),{defaultValue:f,format:h,ranges:v,sets:r}=we[t],m=[],o=t=="clock"&&":"||"/";for(let i=0;i<d.length;i++)d[i]=String(d[i]).replace(/\D/ig,o);for(let i=0;i<r;i++){let u=d[i]||"";if(!u.match(h))d[i]="",m.push(f);else{let x=f;u.split(/\D/).forEach((E,R)=>{if(R==0&&t=="dateWareki"){let S=Number(E);a!="year"&&(S>=2019?a=="reiwa"?S-=2018:a=="heisei"&&(S=31):S>=1989?a=="heisei"?S-=1988:a=="shouwa"&&(S=64):S>=1926?a=="shouwa"?S-=1925:a=="taisho"&&(S=15):S>=1912?a=="taisho"?S-=1911:a=="meiji"&&(S=45):S>=1868&&(S-=1867)),E=S.zeroEmbed(4)}x=x.replace(new RegExp("------------------".slice(0,E.length)),E)}),m.push(x)}}return{formatValue:m.join(F),dataValue:["dates","months"].includes(t)?d:d[0],ranges:v}},SystemValidation:e=>{let{states:t}=e,{restrict:D,min:a,max:d,required:f}=t,h=[],v=G.flatArray(e.value),r={empty:!1,escalated:1,filled:!0,correct:!0,prohibited:!1};(()=>{let m=D=="clock"&&":"||"/";for(let o=0;o<v.length;o++)v[o]=String(v[o]).replace(/\D/ig,m);for(let o=0;o<v.length;o++){let i=v[o],u=v[o-1];i.removeLetters()||(r.empty=!0),o>0&&(r.escalated&=+(i>=u))}r.escalated&&(r.empty||(D.match(/clock/)?v.forEach(o=>{let[i,u]=o.split(/\D+/);!i||!u?r.filled=!1:(Number(i)>23||Number(u)>59)&&(r.correct=!1)}):D.match(/date/)?v.forEach(o=>{let[i,u,x]=o.split(/\D+/);if(!i||!u||!x)r.filled=!1;else{let E=K.Time(o);(!E.validate||o!=E.toFormatYMD())&&(r.correct=!1)}}):D.match(/week/)?v.forEach(o=>{let[i,u]=o.split(/\D+/);if(!i||!u)r.filled=!1;else{let x=K.Time(i+"/01/01").weekday,R=K.Time(i+"/01/0"+(7-x+1)).addWeek(Number(u)-1);i!=String(R.year)&&(r.correct=!1)}}):D.match(/month/)?v.forEach(o=>{let[i,u]=o.split(/\D+/);!i||!u?r.filled=!1:K.Time([i,u,"01"].join("/")).validate||(r.correct=!1)}):D.match(/year/),r.filled&&r.correct&&v.forEach(o=>{{let i=Number(String(o).replace(/\D/ig,""));if(a&&Number(String(a).replace(/\D/ig,""))>i&&(r.prohibited=!0),d){let u=Number(String(d).replace(/\D/ig,""));i>u&&(r.prohibited=!0)}}})))})();{let{empty:m,escalated:o,filled:i,correct:u,prohibited:x}=r;m&&f&&(h=[{type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}]),o||h.push({type:"invalid",label:"\u6642\u7CFB\u5217\u3092\u6B63\u3057\u304F\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),u||h.push({type:"invalid",label:"\u7121\u52B9\u306A\u5024\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u3059"}),i||h.push({type:"invalid",label:"\u6700\u5F8C\u307E\u3067\u5024\u3092\u57CB\u3081\u3066\u304F\u3060\u3055\u3044"}),x&&h.push({type:"invalid",label:oe(_e,{children:[y(X,{children:"\u5165\u529B\u7BC4\u56F2\u304C\u5236\u9650\u3055\u308C\u3066\u3044\u307E\u3059"}),"[",a||"\u4E0B\u9650\u7121\u3057","] ~ [",d||"\u4E0A\u9650\u7121\u3057","]"]})})}return{ok:!h.filter(({type:m})=>m=="invalid").length,notice:h}},KeyDownEvent:e=>{let{val_era:t,restrict:D,event:a,val_status:d,set_status:f,val_focus:h,set_focus:v}=e,{key:r,shiftKey:m,ctrlKey:o,metaKey:i}=a,u=o||i,{selectionStart:x,selectionEnd:E}=a.target,{index:R,prevIndex:S}=h,{ranges:$,formatValue:H}=d,C=$.length-1;if(["Tab","ArrowLeft","ArrowRight"].includes(r)){let I=0;if(r=="Tab"){let s=+!m*2-1;if(I=h.index+s,I<0||I>C)return}else{let s=r=="ArrowLeft"?-1:r=="ArrowRight"?1:0;u||x==0&&E==String(d.formatValue).length?I=s==1?C:0:I=Math.max(0,Math.min(R+s,C))}v(s=>k(l({},s),{index:I,prevIndex:R})),a.preventDefault()}if(["Backspace","ArrowUp","ArrowDown","0","1","2","3","4","5","6","7","8","9"].includes(r)){a.preventDefault();let I=R;I=Math.max(I,0),I=Math.min(I,C);let{type:s,from:B,length:Y}=$[I],_=H.slice(B,B+Y),p;if(r=="Backspace")p="------".slice(0,Y);else if(["ArrowUp","ArrowDown"].includes(r)){let w=r=="ArrowUp"?1:-1;_=_|0,p=_+w;let[n,c,T]=s=="dateWareki"?t=="year"?[0,2999,4]:t=="reiwa"?[1,2999,4]:t=="heisei"?[1,31,4]:t=="shouwa"?[1,64,4]:t=="taisho"?[1,15,4]:t=="meiji"?[1,45,4]:[0,0,0]:s=="minute"?[0,59,2]:s=="hour"?[0,23,2]:s=="date"?[1,31,2]:s=="week"?[1,53,2]:s=="month"?[1,12,2]:s=="year"?[0,2999,4]:[0,0,0];p>c?p=n:p<n&&(p=c),p=Number(p).zeroEmbed(T)}else if(["0","1","2","3","4","5","6","7","8","9"].includes(r)){let w=_|0,n=r,c=`${w}${n}`;if(S!=R&&(w=0,c="0"+n),s=="year"||s=="dateWareki"&&t=="year")Number(c)>1e4?p=n:p=c,(p|0)>1e3&&I++;else if(["hour","minute","date","week","month"].includes(s)||s=="dateWareki"&&t!="year"){let T=s=="dateWareki"?t=="reiwa"?100:t=="heisei"?31:t=="shouwa"?64:t=="taisho"?15:t=="meiji"?45:0:s=="minute"?59:s=="hour"?23:s=="date"?31:s=="week"?53:s=="month"?12:0;p=(c|0)>T?n:c,(Number(n)>Number(String(T)[0])||_=="0000".slice(0,String(T).length)&&(c!="0000".slice(0,String(T).length)||["minute","hour"].includes(s)&&S==R)||(c|0)>=ae(10,String(T).length-1))&&I++}s=="year"||s=="dateWareki"?p=(p|0).zeroEmbed(4):p=(p|0).zeroEmbed(2)}{let w=String(H).partReplace(B,String(p)),n=w.split(F).map(c=>c.replace(/(^\D|\D$)/,"").split(/\D+/).join(D=="clock"&&":"||"/").replace(/(^\D|\D$)/,""));if(D=="dateWareki"){let c=n[0].split(/\D/),[T,j,P]=c;c.length==3&&T&&(n=[[Number(T)-1+Number({year:1,reiwa:2019,heisei:1989,shouwa:1926,taisho:1912,meiji:1868}[t]),j,P].join("/")])}I=Math.max(I,0),I=Math.min(I,C),f(c=>k(l({},c),{dataValue:["dates","months"].includes(D)?n:n[0],formatValue:w,eventType:"update",eventID:N()})),v(c=>k(l({},c),{index:I,prevIndex:c.index}))}}}},ne={picker:{launch:e=>{let t=e.sheetID||N(),m=e,{onValueUpdate:D,min:a,max:d,era:f,restrict:h,defaultValue:v}=m,r=q(m,["onValueUpdate","min","max","era","restrict","defaultValue"]);ye.open(k(l({sheetID:t,type:"normal.middleCenter",size:"S",padding:0,closeAtAroundClick:!0,closeAtParentBlur:!1},r),{content:y(he.Center,{children:y(Ee,{restrict:h,min:a,max:d,era:f,defaultValue:v,sheetID:t,onValueUpdate:(o,i)=>{D(o,i)}})})}))},remove:e=>{ge.close(e)}}},Re={Shallow:e=>{let{rootStates:t,val_status:D}=e,a=ue(t);return y(X,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:y(fe.Description,k(l({className:t.className},a),{position:"absolute",width:1,freeCSS:k(l({},a.freeCSS),{color:"orange"}),children:y(X,{"data-input-value-shallow":D.componentID,children:"A"})}))})}},Ve=e=>{let ee=e,{tone:t,required:D,restrict:a="clock",componentID:d,era:f,form:h,name:v,min:r,max:m,className:o,enableFormSubmit:i,checkValidationAtFirst:u,onKeyDown:x,onValidate:E,onUpdateValue:R,onUpdateValidValue:S,value:$="",leftIndicator:H,rightIndicator:C,leftIcon:I,rightIcon:s,freeCSS:B,wrapStyles:Y}=ee,_=q(ee,["tone","required","restrict","componentID","era","form","name","min","max","className","enableFormSubmit","checkValidationAtFirst","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","freeCSS","wrapStyles"]),[p,w]=W(f),[n,c]=W(k(l({componentID:e.componentID||""},O.DataLeveling({restrict:a,value:$,era:p})),{eventType:"init",eventID:N()})),[T,j]=W({ok:!1,notice:[]}),[P,U]=W({active:!1,index:0,prevIndex:-1}),le={rootStates:e,val_status:n,set_status:c,val_validate:T,set_validate:j,val_era:p,set_era:w,val_focus:P,set_focus:U};z.CommonEffects({type:"time",states:e,val_status:n,set_status:c,val_validate:T,set_validate:j,SystemValidation:O.SystemValidation,ExtraOverrideStates:l({},O.DataLeveling({restrict:a,value:$,era:p}))});const Z=ce(!1);return Q(()=>{if(Z.current){c(b=>l(l({},b),O.DataLeveling({restrict:a,value:b.dataValue,era:p})));let g=L.get("refreshEra_"+n.componentID);g&&g.refreshEra(p)}else Z.current=!0},[p]),L.update({[n.componentID]:{openPicker:g=>{e.disabled||ne.picker.launch({parent:g,sheetID:"PickerTips-"+n.componentID,restrict:a,min:r,max:m,defaultValue:n.dataValue,era:p,onValueUpdate:(b,A)=>{c(M=>k(l(l({},M),O.DataLeveling({restrict:a,value:b,era:A})),{eventType:"update",eventID:N()})),w(A)}})},resetEra:g=>{w(g),c(b=>k(l(l({},b),O.DataLeveling({restrict:a,value:"",era:p})),{eventType:"update",eventID:N()}))}}}),Q(()=>{let{index:g,active:b}=P;if(b){g=Math.max(g,0),g=Math.min(g,n.ranges.length-1);let{from:A,length:M}=n.ranges[g],J=pe("#"+e.id)[0];J&&J.setSelectionRange(A,A+M)}},[P]),oe(Se,{val_status:n,set_status:c,val_validate:T,states:e,children:[y(Re.Shallow,l({},le)),y(ke,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:!0}),re.get().isTouchDevice?y(ie.Plain,k(l({"data-show-validation":z.isShowValidation(T,n,!!u),"data-component-id":n.componentID,"data-input-origin":n.componentID,"data-disabled":e.disabled,className:o,freeCSS:{textAlign:"left"}},_),{children:n.formatValue,onClick:g=>{let b=L.get(n.componentID);b&&b.openPicker(`[data-input-origin="${n.componentID}"]`),g.stopPropagation()}})):y(X,l({htmlTag:"input",type:"text",inputMode:"numeric","data-show-validation":z.isShowValidation(T,n,!!u),"data-input-origin":n.componentID,"data-disabled":e.disabled,value:n.formatValue,className:o,tabIndex:re.get().isTouchDevice?-1:0,onKeyDown:g=>{O.KeyDownEvent({restrict:a,event:g,val_era:p,val_status:n,set_status:c,val_focus:P,set_focus:U}),x&&x(g),i&&z.SubmitForm(g,h)},onKeyUp:g=>{g.key=="Tab"&&U(b=>k(l({},b),{active:!0}))},onClick:g=>{let b=g.target.selectionEnd,A=0;n.ranges.forEach((M,J)=>{let{from:te,length:se,region:me}=M;te<=b&&b<=te+(me||se)&&(A=J)}),U(M=>k(l({},M),{active:!0,index:A})),g.preventDefault()},onChange:()=>{}},_))]})},V={Origin:e=>{let t=l({fontSize:"inherit",width:1},e),[D]=W(e.componentID||N());if(t.componentID=D,G.is.nullish(t.rightIcon)){let a=(e.restrict||"").match(/clock/)?De:ve;t.rightIcon=y(be,{ssSphere:2,freeCSS:{pointerEvents:"all"},children:y(ie.Sub,{color:"cloud",border:"unset",ssSphere:2,fontColor:"theme",boxShadow:"0.normal",borderRadius:"3.tone.tertiary",flexCenter:!0,ssEffectsOnActive:"push",tabIndex:-1,id:"Picker-"+t.componentID,onClick:()=>{let d=L.get(t.componentID);d&&d.openPicker("#Picker-"+t.componentID)},children:y(de,{icon:a})})})}return y(Ie,{componentID:t.componentID,children:Ve,states:Te(t)})},Clock:e=>y(V.Origin,l({restrict:"clock",era:"clock"},e)),Date:e=>y(V.Origin,l({restrict:"date"},e)),Week:e=>y(V.Origin,l({restrict:"week"},e)),Month:e=>y(V.Origin,l({restrict:"month"},e)),Year:e=>y(V.Origin,l({restrict:"year"},e)),DateWareki:e=>{e=l({},e);let[t]=W(e.componentID||N());e.componentID=t;let{defaultEra:D="wareki"}=e,[a,d]=W((()=>{let f="year";if(D=="wareki"&&(f="reiwa",e.value)){let[h,v,r]=e.value.split(/\D/);if(h&&v&&r){let m=Number(h);m>=2019?(m-=2019,f="reiwa"):m>=1989?(m-=1989,f="heisei"):m>=1926?(m-=1926,f="shouwa"):m>=1912?(m-=1912,f="taisho"):m>=1868&&(m-=1868,f="meiji"),m+=1}}return f})());return Q(()=>{L.set({["refreshEra_"+t]:{refreshEra:f=>{d(f)}}})},[]),y(V.Origin,k(l({restrict:"dateWareki",leftIndicator:y(xe,{label:"\u5143\u53F7",emptySelect:!1,value:a,tone:e.tone||"border",override:"force",flexCenter:!0,borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",height:1,freeCSS:{whiteSpace:"nowrap"},options:[{value:"year",label:"\u897F\u66A6"},{value:"reiwa",label:"\u4EE4\u548C"},{value:"heisei",label:"\u5E73\u6210"},{value:"shouwa",label:"\u662D\u548C"},{value:"taisho",label:"\u5927\u6B63"},{value:"meiji",label:"\u660E\u6CBB"}],onUpdateValidValue:f=>{d(f);let h=L.get(e.componentID);h&&h.resetEra&&h.resetEra(f)}})},e),{era:a}))},Periods:{Date:e=>y(V.Origin,l({restrict:"dates"},e)),Month:e=>y(V.Origin,l({restrict:"months"},e))},fn:ne};export{V as Time,V as default};
|
|
1
|
+
import{a as ae,b as l,c as k,d as q}from"../../../chunk-C5N2D3ZX.js";import{Fragment as _e,jsx as y,jsxs as oe}from"react/jsx-runtime";import G,{UUID as N,useStore as L}from"jmini";import*as K from"jmini";import{useState as W,useEffect as Q,useRef as ce}from"react";import{$$fromRoot as pe,Config as re,ExtractStyles as ue}from"../../../@utils";import{Box as X,FAI as de}from"../../../atoms";import{Literal as fe,Row as he}from"../../../mols";import{Button as ie}from"../../Button";import ge from"../../Tooltips";import ye from"../../Sheet";import{faClock as De}from"@fortawesome/free-solid-svg-icons/faClock";import{faCalendarAlt as ve}from"@fortawesome/free-solid-svg-icons/faCalendarAlt";import{OptionalInputWrapper as Ie,BoxWrapper as Se,CoreEffects as z,DefaultBoxishStyles as Te}from"../core";import{RightIcon as be}from"..";import xe from"../Select";import{InputLabel as ke}from"../Label";import Ee from"./Picker";const F=" ~ ",we={clock:{defaultValue:"--:--",format:/^\d{2}\D\d{2}$/,ranges:[{type:"hour",from:0,length:2},{type:"minute",from:3,length:2}],sets:1},date:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2}],sets:1},week:{defaultValue:"----\u5E74\u7B2C--\u9031",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4,region:6},{type:"week",from:6,length:2,region:3}],sets:1},month:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:3}],sets:1},year:{defaultValue:"----\u5E74",format:/^\d{4}$/,ranges:[{type:"year",from:0,length:4,region:5}],sets:1},dates:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2,region:5},{type:"year",from:10+F.length,length:4},{type:"month",from:15+F.length,length:2},{type:"date",from:18+F.length,length:2}],sets:2},months:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:6},{type:"year",from:8+F.length,length:4},{type:"month",from:13+F.length,length:2,region:3}],sets:2},dateWareki:{defaultValue:"----\u5E74--\u6708--\u65E5",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"dateWareki",from:0,length:4,region:5},{type:"month",from:5,length:2,region:3},{type:"date",from:8,length:2,region:3}],sets:1}},O={PeriodMargin:" ~ ",DataLeveling:e=>{let{restrict:t,value:D,era:a}=e,d=G.flatArray(D||""),{defaultValue:f,format:h,ranges:v,sets:r}=we[t],m=[],o=t=="clock"&&":"||"/";for(let i=0;i<d.length;i++)d[i]=String(d[i]).replace(/\D/ig,o);for(let i=0;i<r;i++){let u=d[i]||"";if(!u.match(h))d[i]="",m.push(f);else{let x=f;u.split(/\D/).forEach((E,R)=>{if(R==0&&t=="dateWareki"){let S=Number(E);a!="year"&&(S>=2019?a=="reiwa"?S-=2018:a=="heisei"&&(S=31):S>=1989?a=="heisei"?S-=1988:a=="shouwa"&&(S=64):S>=1926?a=="shouwa"?S-=1925:a=="taisho"&&(S=15):S>=1912?a=="taisho"?S-=1911:a=="meiji"&&(S=45):S>=1868&&(S-=1867)),E=S.zeroEmbed(4)}x=x.replace(new RegExp("------------------".slice(0,E.length)),E)}),m.push(x)}}return{formatValue:m.join(F),dataValue:["dates","months"].includes(t)?d:d[0],ranges:v}},SystemValidation:e=>{let{states:t}=e,{restrict:D,min:a,max:d,required:f}=t,h=[],v=G.flatArray(e.value),r={empty:!1,escalated:1,filled:!0,correct:!0,prohibited:!1};(()=>{let m=D=="clock"&&":"||"/";for(let o=0;o<v.length;o++)v[o]=String(v[o]).replace(/\D/ig,m);for(let o=0;o<v.length;o++){let i=v[o],u=v[o-1];i.removeLetters()||(r.empty=!0),o>0&&(r.escalated&=+(i>=u))}r.escalated&&(r.empty||(D.match(/clock/)?v.forEach(o=>{let[i,u]=o.split(/\D+/);!i||!u?r.filled=!1:(Number(i)>23||Number(u)>59)&&(r.correct=!1)}):D.match(/date/)?v.forEach(o=>{let[i,u,x]=o.split(/\D+/);if(!i||!u||!x)r.filled=!1;else{let E=K.Time(o);(!E.validate||o!=E.toFormatYMD())&&(r.correct=!1)}}):D.match(/week/)?v.forEach(o=>{let[i,u]=o.split(/\D+/);if(!i||!u)r.filled=!1;else{let x=K.Time(i+"/01/01").weekday,R=K.Time(i+"/01/0"+(7-x+1)).addWeek(Number(u)-1);i!=String(R.year)&&(r.correct=!1)}}):D.match(/month/)?v.forEach(o=>{let[i,u]=o.split(/\D+/);!i||!u?r.filled=!1:K.Time([i,u,"01"].join("/")).validate||(r.correct=!1)}):D.match(/year/),r.filled&&r.correct&&v.forEach(o=>{{let i=Number(String(o).replace(/\D/ig,""));if(a&&Number(String(a).replace(/\D/ig,""))>i&&(r.prohibited=!0),d){let u=Number(String(d).replace(/\D/ig,""));i>u&&(r.prohibited=!0)}}})))})();{let{empty:m,escalated:o,filled:i,correct:u,prohibited:x}=r;m&&f&&(h=[{type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}]),o||h.push({type:"invalid",label:"\u6642\u7CFB\u5217\u3092\u6B63\u3057\u304F\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),u||h.push({type:"invalid",label:"\u7121\u52B9\u306A\u5024\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u3059"}),i||h.push({type:"invalid",label:"\u6700\u5F8C\u307E\u3067\u5024\u3092\u57CB\u3081\u3066\u304F\u3060\u3055\u3044"}),x&&h.push({type:"invalid",label:oe(_e,{children:[y(X,{children:"\u5165\u529B\u7BC4\u56F2\u304C\u5236\u9650\u3055\u308C\u3066\u3044\u307E\u3059"}),"[",a||"\u4E0B\u9650\u7121\u3057","] ~ [",d||"\u4E0A\u9650\u7121\u3057","]"]})})}return{ok:!h.filter(({type:m})=>m=="invalid").length,notice:h}},KeyDownEvent:e=>{let{val_era:t,restrict:D,event:a,val_status:d,set_status:f,val_focus:h,set_focus:v}=e,{key:r,shiftKey:m,ctrlKey:o,metaKey:i}=a,u=o||i,{selectionStart:x,selectionEnd:E}=a.target,{index:R,prevIndex:S}=h,{ranges:$,formatValue:H}=d,C=$.length-1;if(["Tab","ArrowLeft","ArrowRight"].includes(r)){let I=0;if(r=="Tab"){let s=+!m*2-1;if(I=h.index+s,I<0||I>C)return}else{let s=r=="ArrowLeft"?-1:r=="ArrowRight"?1:0;u||x==0&&E==String(d.formatValue).length?I=s==1?C:0:I=Math.max(0,Math.min(R+s,C))}v(s=>k(l({},s),{index:I,prevIndex:R})),a.preventDefault()}if(["Backspace","ArrowUp","ArrowDown","0","1","2","3","4","5","6","7","8","9"].includes(r)){a.preventDefault();let I=R;I=Math.max(I,0),I=Math.min(I,C);let{type:s,from:B,length:Y}=$[I],_=H.slice(B,B+Y),p;if(r=="Backspace")p="------".slice(0,Y);else if(["ArrowUp","ArrowDown"].includes(r)){let w=r=="ArrowUp"?1:-1;_=_|0,p=_+w;let[n,c,T]=s=="dateWareki"?t=="year"?[0,2999,4]:t=="reiwa"?[1,2999,4]:t=="heisei"?[1,31,4]:t=="shouwa"?[1,64,4]:t=="taisho"?[1,15,4]:t=="meiji"?[1,45,4]:[0,0,0]:s=="minute"?[0,59,2]:s=="hour"?[0,23,2]:s=="date"?[1,31,2]:s=="week"?[1,53,2]:s=="month"?[1,12,2]:s=="year"?[0,2999,4]:[0,0,0];p>c?p=n:p<n&&(p=c),p=Number(p).zeroEmbed(T)}else if(["0","1","2","3","4","5","6","7","8","9"].includes(r)){let w=_|0,n=r,c=`${w}${n}`;if(S!=R&&(w=0,c="0"+n),s=="year"||s=="dateWareki"&&t=="year")Number(c)>1e4?p=n:p=c,(p|0)>1e3&&I++;else if(["hour","minute","date","week","month"].includes(s)||s=="dateWareki"&&t!="year"){let T=s=="dateWareki"?t=="reiwa"?100:t=="heisei"?31:t=="shouwa"?64:t=="taisho"?15:t=="meiji"?45:0:s=="minute"?59:s=="hour"?23:s=="date"?31:s=="week"?53:s=="month"?12:0;p=(c|0)>T?n:c,(Number(n)>Number(String(T)[0])||_=="0000".slice(0,String(T).length)&&(c!="0000".slice(0,String(T).length)||["minute","hour"].includes(s)&&S==R)||(c|0)>=ae(10,String(T).length-1))&&I++}s=="year"||s=="dateWareki"?p=(p|0).zeroEmbed(4):p=(p|0).zeroEmbed(2)}{let w=String(H).partReplace(B,String(p)),n=w.split(F).map(c=>c.replace(/(^\D|\D$)/,"").split(/\D+/).join(D=="clock"&&":"||"/").replace(/(^\D|\D$)/,""));if(D=="dateWareki"){let c=n[0].split(/\D/),[T,j,P]=c;c.length==3&&T&&(n=[[Number(T)-1+Number({year:1,reiwa:2019,heisei:1989,shouwa:1926,taisho:1912,meiji:1868}[t]),j,P].join("/")])}I=Math.max(I,0),I=Math.min(I,C),f(c=>k(l({},c),{dataValue:["dates","months"].includes(D)?n:n[0],formatValue:w,eventType:"update",eventID:N()})),v(c=>k(l({},c),{index:I,prevIndex:c.index}))}}}},ne={picker:{launch:e=>{let t=e.sheetID||N(),m=e,{onValueUpdate:D,min:a,max:d,era:f,restrict:h,defaultValue:v}=m,r=q(m,["onValueUpdate","min","max","era","restrict","defaultValue"]);ye.open("middleCenter",k(l({sheetID:t,size:"S",padding:0,closeAtAroundClick:!0,closeAtParentBlur:!1},r),{content:y(he.Center,{children:y(Ee,{restrict:h,min:a,max:d,era:f,defaultValue:v,sheetID:t,onValueUpdate:(o,i)=>{D(o,i)}})})}))},remove:e=>{ge.close(e)}}},Re={Shallow:e=>{let{rootStates:t,val_status:D}=e,a=ue(t);return y(X,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:y(fe.Description,k(l({className:t.className},a),{position:"absolute",width:1,freeCSS:k(l({},a.freeCSS),{color:"orange"}),children:y(X,{"data-input-value-shallow":D.componentID,children:"A"})}))})}},Ve=e=>{let ee=e,{tone:t,required:D,restrict:a="clock",componentID:d,era:f,form:h,name:v,min:r,max:m,className:o,enableFormSubmit:i,checkValidationAtFirst:u,onKeyDown:x,onValidate:E,onUpdateValue:R,onUpdateValidValue:S,value:$="",leftIndicator:H,rightIndicator:C,leftIcon:I,rightIcon:s,freeCSS:B,wrapStyles:Y}=ee,_=q(ee,["tone","required","restrict","componentID","era","form","name","min","max","className","enableFormSubmit","checkValidationAtFirst","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","freeCSS","wrapStyles"]),[p,w]=W(f),[n,c]=W(k(l({componentID:e.componentID||""},O.DataLeveling({restrict:a,value:$,era:p})),{eventType:"init",eventID:N()})),[T,j]=W({ok:!1,notice:[]}),[P,U]=W({active:!1,index:0,prevIndex:-1}),le={rootStates:e,val_status:n,set_status:c,val_validate:T,set_validate:j,val_era:p,set_era:w,val_focus:P,set_focus:U};z.CommonEffects({type:"time",states:e,val_status:n,set_status:c,val_validate:T,set_validate:j,SystemValidation:O.SystemValidation,ExtraOverrideStates:l({},O.DataLeveling({restrict:a,value:$,era:p}))});const Z=ce(!1);return Q(()=>{if(Z.current){c(b=>l(l({},b),O.DataLeveling({restrict:a,value:b.dataValue,era:p})));let g=L.get("refreshEra_"+n.componentID);g&&g.refreshEra(p)}else Z.current=!0},[p]),L.update({[n.componentID]:{openPicker:g=>{e.disabled||ne.picker.launch({parent:g,sheetID:"PickerTips-"+n.componentID,restrict:a,min:r,max:m,defaultValue:n.dataValue,era:p,onValueUpdate:(b,A)=>{c(M=>k(l(l({},M),O.DataLeveling({restrict:a,value:b,era:A})),{eventType:"update",eventID:N()})),w(A)}})},resetEra:g=>{w(g),c(b=>k(l(l({},b),O.DataLeveling({restrict:a,value:"",era:p})),{eventType:"update",eventID:N()}))}}}),Q(()=>{let{index:g,active:b}=P;if(b){g=Math.max(g,0),g=Math.min(g,n.ranges.length-1);let{from:A,length:M}=n.ranges[g],J=pe("#"+e.id)[0];J&&J.setSelectionRange(A,A+M)}},[P]),oe(Se,{val_status:n,set_status:c,val_validate:T,states:e,children:[y(Re.Shallow,l({},le)),y(ke,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:!0}),re.get().isTouchDevice?y(ie.Plain,k(l({"data-show-validation":z.isShowValidation(T,n,!!u),"data-component-id":n.componentID,"data-input-origin":n.componentID,"data-disabled":e.disabled,className:o,freeCSS:{textAlign:"left"}},_),{children:n.formatValue,onClick:g=>{let b=L.get(n.componentID);b&&b.openPicker(`[data-input-origin="${n.componentID}"]`),g.stopPropagation()}})):y(X,l({htmlTag:"input",type:"text",inputMode:"numeric","data-show-validation":z.isShowValidation(T,n,!!u),"data-input-origin":n.componentID,"data-disabled":e.disabled,value:n.formatValue,className:o,tabIndex:re.get().isTouchDevice?-1:0,onKeyDown:g=>{O.KeyDownEvent({restrict:a,event:g,val_era:p,val_status:n,set_status:c,val_focus:P,set_focus:U}),x&&x(g),i&&z.SubmitForm(g,h)},onKeyUp:g=>{g.key=="Tab"&&U(b=>k(l({},b),{active:!0}))},onClick:g=>{let b=g.target.selectionEnd,A=0;n.ranges.forEach((M,J)=>{let{from:te,length:se,region:me}=M;te<=b&&b<=te+(me||se)&&(A=J)}),U(M=>k(l({},M),{active:!0,index:A})),g.preventDefault()},onChange:()=>{}},_))]})},V={Origin:e=>{let t=l({fontSize:"inherit",width:1},e),[D]=W(e.componentID||N());if(t.componentID=D,G.is.nullish(t.rightIcon)){let a=(e.restrict||"").match(/clock/)?De:ve;t.rightIcon=y(be,{ssSphere:2,freeCSS:{pointerEvents:"all"},children:y(ie.Sub,{color:"cloud",border:"unset",ssSphere:2,fontColor:"theme",boxShadow:"0.normal",borderRadius:"3.tone.tertiary",flexCenter:!0,ssEffectsOnActive:"push",tabIndex:-1,id:"Picker-"+t.componentID,onClick:()=>{let d=L.get(t.componentID);d&&d.openPicker("#Picker-"+t.componentID)},children:y(de,{icon:a})})})}return y(Ie,{componentID:t.componentID,children:Ve,states:Te(t)})},Clock:e=>y(V.Origin,l({restrict:"clock",era:"clock"},e)),Date:e=>y(V.Origin,l({restrict:"date"},e)),Week:e=>y(V.Origin,l({restrict:"week"},e)),Month:e=>y(V.Origin,l({restrict:"month"},e)),Year:e=>y(V.Origin,l({restrict:"year"},e)),DateWareki:e=>{e=l({},e);let[t]=W(e.componentID||N());e.componentID=t;let{defaultEra:D="wareki"}=e,[a,d]=W((()=>{let f="year";if(D=="wareki"&&(f="reiwa",e.value)){let[h,v,r]=e.value.split(/\D/);if(h&&v&&r){let m=Number(h);m>=2019?(m-=2019,f="reiwa"):m>=1989?(m-=1989,f="heisei"):m>=1926?(m-=1926,f="shouwa"):m>=1912?(m-=1912,f="taisho"):m>=1868&&(m-=1868,f="meiji"),m+=1}}return f})());return Q(()=>{L.set({["refreshEra_"+t]:{refreshEra:f=>{d(f)}}})},[]),y(V.Origin,k(l({restrict:"dateWareki",leftIndicator:y(xe,{label:"\u5143\u53F7",emptySelect:!1,value:a,tone:e.tone||"border",override:"force",flexCenter:!0,borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",height:1,freeCSS:{whiteSpace:"nowrap"},options:[{value:"year",label:"\u897F\u66A6"},{value:"reiwa",label:"\u4EE4\u548C"},{value:"heisei",label:"\u5E73\u6210"},{value:"shouwa",label:"\u662D\u548C"},{value:"taisho",label:"\u5927\u6B63"},{value:"meiji",label:"\u660E\u6CBB"}],onUpdateValidValue:f=>{d(f);let h=L.get(e.componentID);h&&h.resetEra&&h.resetEra(f)}})},e),{era:a}))},Periods:{Date:e=>y(V.Origin,l({restrict:"dates"},e)),Month:e=>y(V.Origin,l({restrict:"months"},e))},fn:ne};export{V as Time,V as default};
|
package/dist/fn/Sheet.d.ts
CHANGED
|
@@ -5,14 +5,15 @@ import { Box } from '../atoms';
|
|
|
5
5
|
declare namespace Sheet {
|
|
6
6
|
type Methods = {
|
|
7
7
|
Wrapper(): JSX.Element;
|
|
8
|
-
Element(p: Omit<
|
|
8
|
+
Element<T extends keyof TypesInput>(type: T, p: Omit<TypesInput[T], 'content'> & {
|
|
9
9
|
isOpen: boolean;
|
|
10
10
|
children: ReactElement;
|
|
11
11
|
}): ReactElement;
|
|
12
|
-
|
|
12
|
+
image(params: Omit<UniInput, 'content'>, src: string | string[]): void;
|
|
13
|
+
open<T extends keyof TypesInput>(type: T, params: TypesInput[T], defaultOpen?: boolean | 'inherit'): void;
|
|
13
14
|
resize(p: {
|
|
14
15
|
sheetID: string;
|
|
15
|
-
size:
|
|
16
|
+
size: Sizes;
|
|
16
17
|
}): void;
|
|
17
18
|
customSheet: {
|
|
18
19
|
reposition(sheetID: string): void;
|
|
@@ -22,10 +23,11 @@ declare namespace Sheet {
|
|
|
22
23
|
closeAll(pageTransit?: boolean): void;
|
|
23
24
|
Body: React.FC<Box.DefaultInput>;
|
|
24
25
|
};
|
|
25
|
-
type Input = Normal | Edge | Custom | Image | Bottom.Input;
|
|
26
26
|
type UniInput = {
|
|
27
|
+
type?: keyof TypesInput;
|
|
27
28
|
sheetID?: string;
|
|
28
|
-
size?:
|
|
29
|
+
size?: Sizes;
|
|
30
|
+
content: Content;
|
|
29
31
|
sheetGroups?: string | string[];
|
|
30
32
|
backgroundEffect?: boolean;
|
|
31
33
|
overwrap?: boolean;
|
|
@@ -34,7 +36,40 @@ declare namespace Sheet {
|
|
|
34
36
|
openAfter?(): void;
|
|
35
37
|
closeAfter?(): void;
|
|
36
38
|
} & StyleTags.BasicElement & CloseOptions;
|
|
37
|
-
type
|
|
39
|
+
type Input = UniInput & (Input.Custom | Input.Bottom);
|
|
40
|
+
type TypesInput = {
|
|
41
|
+
'topLeft': UniInput;
|
|
42
|
+
'topCenter': UniInput;
|
|
43
|
+
'topRight': UniInput;
|
|
44
|
+
'middleLeft': UniInput;
|
|
45
|
+
'middleCenter': UniInput;
|
|
46
|
+
'middleRight': UniInput;
|
|
47
|
+
'bottomLeft': UniInput;
|
|
48
|
+
'bottomCenter': UniInput;
|
|
49
|
+
'bottomRight': UniInput;
|
|
50
|
+
'drawer.left': UniInput;
|
|
51
|
+
'drawer.right': UniInput;
|
|
52
|
+
'drawer.bottom': Input.Bottom;
|
|
53
|
+
'custom': Input.Custom;
|
|
54
|
+
};
|
|
55
|
+
namespace Input {
|
|
56
|
+
type Custom = UniInput & {
|
|
57
|
+
resize?: boolean;
|
|
58
|
+
nextToCursor?: boolean;
|
|
59
|
+
gravityPoint?: number;
|
|
60
|
+
} & ({
|
|
61
|
+
event: any;
|
|
62
|
+
parent?: $$.Args;
|
|
63
|
+
} | {
|
|
64
|
+
event?: any;
|
|
65
|
+
parent: $$.Args;
|
|
66
|
+
});
|
|
67
|
+
type Bottom = UniInput & {
|
|
68
|
+
sizeChanged?(size: Sizes): void;
|
|
69
|
+
baseStyles?: StyleTags.States;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
type Sizes = 'S' | 'R' | 'L' | '2L' | '3L' | 'MAX';
|
|
38
73
|
type Content = ReactElement | (() => JSX.Element);
|
|
39
74
|
type CloseOptions = {
|
|
40
75
|
closeAtPageTransit?: boolean;
|
|
@@ -43,48 +78,13 @@ declare namespace Sheet {
|
|
|
43
78
|
closeAtParentBlur?: boolean;
|
|
44
79
|
closeAtSwipeDown?: boolean;
|
|
45
80
|
};
|
|
46
|
-
type
|
|
47
|
-
type Normal = UniInput & {
|
|
48
|
-
type: Sheet;
|
|
49
|
-
content: Content;
|
|
50
|
-
};
|
|
51
|
-
type Edge = UniInput & {
|
|
52
|
-
type: Sheet;
|
|
53
|
-
content: Content;
|
|
54
|
-
};
|
|
55
|
-
type Custom = UniInput & {
|
|
56
|
-
type: 'custom';
|
|
57
|
-
content: Content;
|
|
58
|
-
resize?: boolean;
|
|
59
|
-
nextToCursor?: boolean;
|
|
60
|
-
gravityPoint?: number;
|
|
61
|
-
} & ({
|
|
62
|
-
event: any;
|
|
63
|
-
parent?: $$.Args;
|
|
64
|
-
} | {
|
|
65
|
-
event?: any;
|
|
66
|
-
parent: $$.Args;
|
|
67
|
-
});
|
|
68
|
-
type Image = UniInput & {
|
|
69
|
-
type: 'image';
|
|
70
|
-
src: string | string[];
|
|
71
|
-
};
|
|
72
|
-
namespace Bottom {
|
|
73
|
-
type Sizes = 'S' | 'R' | 'L';
|
|
74
|
-
type Input = UniInput & {
|
|
75
|
-
type: 'drawer.bottom';
|
|
76
|
-
content: Content;
|
|
77
|
-
size: Sizes;
|
|
78
|
-
sizeChanged?(size: Sizes): void;
|
|
79
|
-
baseStyles?: StyleTags.States;
|
|
80
|
-
};
|
|
81
|
-
}
|
|
81
|
+
type Type = 'topLeft' | 'topCenter' | 'topRight' | 'middleLeft' | 'middleCenter' | 'middleRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight' | 'drawer.left' | 'drawer.right' | 'drawer.bottom' | 'custom';
|
|
82
82
|
type CoreProps = {
|
|
83
83
|
sheetID: string;
|
|
84
84
|
isOpen: boolean;
|
|
85
85
|
created_at: Time.Chains;
|
|
86
86
|
};
|
|
87
|
-
type SheetContent = Sheet.Input
|
|
87
|
+
type SheetContent = CoreProps & Sheet.Input;
|
|
88
88
|
type WrapperStates = {
|
|
89
89
|
val_sheets: SheetContent[];
|
|
90
90
|
set_sheets: React.Dispatch<React.SetStateAction<SheetContent[]>>;
|
package/dist/fn/Sheet.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as g,c as T,d as G}from"../chunk-C5N2D3ZX.js";import{jsx as c,jsxs as $}from"react/jsx-runtime";import f,{UUID as Z,Time as le,useStore as E}from"jmini";import{useState as L,useEffect as X,useRef as pe}from"react";import{$$fromRoot as j,Config as K}from"../@utils";import{Box as k,Flex as he,Img as ie,FAI as ae,Column as oe}from"../atoms";import{Row as re}from"../mols";import{Button as se}from"./Button";import ce from"./Input";import{SheetClasses as d}from"../@styles/componentClasses";import ue from"./Effect";const R={currentIndex:0,openQueue:{},getSessionStates:()=>{let t=E.get("sessionStates-"+K.get().sessionUID);return t||null},getNewSheetStates:t=>{var a;let e=T(g({sheetGroups:t.sheetGroups||[],backgroundEffect:!0,overwrap:t.type=="custom",hold_state:!1,closeAtPageTransit:!0,closeAtEscapeKeyDown:!0,closeAtAroundClick:t.type=="custom"},t),{sheetID:t.sheetID||Z(),isOpen:!0,created_at:le()});if(e.type=="custom"){let l=e;l.parent=l.parent||((a=l==null?void 0:l.event)==null?void 0:a.currentTarget),e=l}return e}},J={Wrapper:()=>{let[t,e]=L([]),a={val_sheets:t,set_sheets:e},l="sessionStates-"+K.get().sessionUID;E.set({[l]:a}),X(()=>{let n="Sheet-"+K.get().sessionUID;E.set({[n]:{add:(u,r)=>{let p=E.get(n);if(!p)return;let s=R.getNewSheetStates(u);if(R.openQueue[s.sheetID])return;if(R.openQueue[s.sheetID]=!0,r!="inherit"&&(s.isOpen=r!=null?r:!0),!!p.find(s.sheetID)){e(C=>{let b=[...C],w=b.findIndex(M=>M.sheetID==s.sheetID);return w==-1||(b[w]=s),b}),delete R.openQueue[s.sheetID];return}e(C=>[s,...C])},find:u=>{let r=R.getSessionStates();if(!r)return null;let{val_sheets:p}=r;return p.find(s=>s.sheetID==u)}}}),f(K.get().appRoot).addEvent({eventType:"keyup",eventID:"SheetEvent.keyUp",callback:function(u){let{key:r,metaKey:p}=u;if(r=="Escape"||r==","&&p){let s=R.getSessionStates();if(!s)return;let{val_sheets:S}=s,C=S.filter(w=>w.isOpen);if(!C.length)return;let b=C.reduce((w,M)=>w.created_at.value>M.created_at.value?w:M);_.close(b.sheetID,r)}}}).addEvent({eventType:"click",eventID:"SheetEvent.Click",callback:function(u){let r=R.getSessionStates();if(!r)return;let{val_sheets:p}=r,s=u.target;if(!s||s!=null&&s.closest("."+d("CustomSheet")))return;let S=p.filter(C=>C.type=="custom");S.length&&S.forEach(C=>{let{parent:b}=C;if(!C.closeAtAroundClick)return;let w=j(b)[0];b!==s&&w!==s&&(f(w).find(s).length||_.close(C.sheetID))})}})},[]);let v=t.map(n=>c(J.Core,T(g({},a),{val_sheet:n,patch_sheet:u=>{e(r=>{let p=[...r],s=p.findIndex(S=>S.sheetID==n.sheetID);return s==-1||(p[s]=g(g({},p[s]),u)),p})},delete_sheet:()=>{e(u=>{let r=[...u],p=r.findIndex(s=>s.sheetID==n.sheetID);return p==-1||r.splice(p,1),r})}}),n.sheetID));return c(k,{className:["AMOTIFY_be",d("Wrapper")].join(" "),children:v})},Core:t=>{let{val_sheet:e,patch_sheet:a}=t,[l,v]=L(R.currentIndex+2),[n]=L(Z()),u=e.type!="custom"&&!e.overwrap;X(()=>{R.currentIndex++,f.scope(()=>{if(!e.closeAtParentBlur)return;let S=f(e.parent);S[0]&&S.addEvent({eventID:"SheetClosation-"+e.sheetID,eventType:"mouseout",callback:()=>{S.removeEvent("SheetClosation-"+e.sheetID),a({isOpen:!1})}})}),E.set({[e.sheetID]:{resize:S=>{if(e.type=="drawer.bottom"){let C=E.get(n);C&&C.resize&&C.resize(S)}else(e.type.includes("normal")||e.type.includes("drawer"))&&a({size:S})},close:S=>{a({isOpen:!1})},open:()=>{a({isOpen:!0})}}})},[]),X(()=>{f.scope(()=>{let S=j("#"+n);if(e.isOpen){e.hold_state&&v(R.currentIndex+1),S.await(10).removeClass(d("Hide")).await(10).addClass(d("Open")).callback(()=>{delete R.openQueue[e.sheetID],e.openAfter&&e.openAfter()});return}S.await(10).removeClass(d("Open")).await(251).addClass(d("Hide")).callback(()=>{if(e.closeAfter&&e.closeAfter(),u&&K.get().browserIs!="safari"&&f(K.get().appRoot).focus(),e.hold_state)return a({isOpen:!1});t.delete_sheet()})})},[e.isOpen]);let[r,p]=e.type.split("."),s=J.Types[{"normal.topLeft":"Normal","normal.topCenter":"Normal","normal.topRight":"Normal","normal.middleLeft":"Normal","normal.middleCenter":"Normal","normal.middleRight":"Normal","normal.bottomLeft":"Normal","normal.bottomCenter":"Normal","normal.bottomRight":"Normal",image:"Normal","drawer.left":"Edge","drawer.right":"Edge","drawer.bottom":"Bottom",custom:"Custom"}[e.type]];return c(k,{className:[d("Wrap"),d("Tcate_"+r),d("Tpos_"+p),d("isMainSheet_"+u)].join(" "),width:1,ssAbsoluteCovered:!0,freeCSS:{zIndex:l},id:n,children:$(oe,{className:d("Content"),gap:0,height:"viewHeight",overflow:"auto",transition:"middle",children:[!!u&&c(J.TapSensor,{sheetID:e.sheetID,delegateAroundClick:e.closeAtAroundClick}),c(s,g({componentID:n},e))]})},n)},Types:{Normal:t=>{let H=t,{sheetID:e,sheetGroups:a,bodyScrolls:l,content:v,className:n="",type:u,size:r="R",freeCSS:p,openAfter:s,closeAfter:S,closeAtAroundClick:C,closeAtEscapeKeyDown:b,closeAtPageTransit:w,closeAtParentBlur:M,closeAtSwipeDown:Y,hold_state:q,overwrap:ee,isOpen:te,backgroundEffect:W}=H,U=G(H,["sheetID","sheetGroups","bodyScrolls","content","className","type","size","freeCSS","openAfter","closeAfter","closeAtAroundClick","closeAtEscapeKeyDown","closeAtPageTransit","closeAtParentBlur","closeAtSwipeDown","hold_state","overwrap","isOpen","backgroundEffect"]),[F,D]=u.split("."),I={},A=[];return D.match(/top/)?(A.push("top"),I.marginBottom="auto"):D.match(/middle/)?(A.push("center"),I.marginTop="auto",I.marginBottom="auto"):D.match(/bottom/)&&(A.push("bottom"),I.marginTop="auto"),D.match(/left/i)?(A.push("left"),I.marginRight="auto"):D.match(/center/i)?(A.push("center"),I.marginLeft="auto",I.marginRight="auto"):D.match(/right/i)&&(A.push("right"),I.marginLeft="auto"),c(k,T(g(g({className:[d("BB"),n].join(" "),padding:1,transition:"long",opacity:"trans"},U),I),{freeCSS:g({width:{S:"26rem",R:"36rem",L:"44rem","2L":"60rem","3L":"72rem",MAX:"100%"}[r],maxWidth:"96vw",transformOrigin:A.join(" ")},p),children:f.is.function(v)?c(v,{}):v}))},Edge:t=>{let U=t,{sheetID:e,sheetGroups:a,bodyScrolls:l,type:v,content:n,className:u="",size:r="R",openAfter:p,closeAfter:s,closeAtAroundClick:S,closeAtEscapeKeyDown:C,closeAtPageTransit:b,closeAtParentBlur:w,closeAtSwipeDown:M,hold_state:Y,overwrap:q,isOpen:ee,backgroundEffect:te}=U,W=G(U,["sheetID","sheetGroups","bodyScrolls","type","content","className","size","openAfter","closeAfter","closeAtAroundClick","closeAtEscapeKeyDown","closeAtPageTransit","closeAtParentBlur","closeAtSwipeDown","hold_state","overwrap","isOpen","backgroundEffect"]);return c(k,T(g(T(g({className:[d("BB"),u].join(" ")},v=="drawer.right"?{marginLeft:"auto"}:v=="drawer.left"?{marginRight:"auto"}:{}),{opacity:"trans",transition:"long",position:"relative",backgroundColor:"layer.1",flexSizing:"none",minHeight:"viewHeight",boxShadow:"3.remark"}),W),{freeCSS:g({width:{S:"20rem",R:"27rem",L:"32rem","2L":"40rem","3L":"58rem",MAX:"100vw"}[r],maxWidth:"96vw"},W.freeCSS),children:f.is.function(n)?c(n,{}):n}))},Bottom:t=>{let V=t,{componentID:e,sheetID:a,sheetGroups:l,bodyScrolls:v,content:n,size:u="R",sizeChanged:r,baseStyles:p,openAfter:s,closeAfter:S,closeAtAroundClick:C,closeAtEscapeKeyDown:b,closeAtPageTransit:w,closeAtParentBlur:M,closeAtSwipeDown:Y=!0,hold_state:q,overwrap:ee,isOpen:te,backgroundEffect:W}=V,U=G(V,["componentID","sheetID","sheetGroups","bodyScrolls","content","size","sizeChanged","baseStyles","openAfter","closeAfter","closeAtAroundClick","closeAtEscapeKeyDown","closeAtPageTransit","closeAtParentBlur","closeAtSwipeDown","hold_state","overwrap","isOpen","backgroundEffect"]),F=f.getScreenSize(),D=[0,.2,.6,.95],I={ZERO:0,S:1,R:2,L:3},[A,H]=L(u),[x,B]=L({process:!1,processStart:0,originY:0,originValue:0,viewHeight:0,value:D[I[u]]});E.update({[e]:{val_edit:x,resize:y=>{let m=D[I[y]];B(h=>T(g({},h),{value:m})),H(y)}}});const z={Start:y=>{f(document).addEvent({eventID:"BottomSheetMouseMove",eventType:"mousemove",callback:z.Move,options:{passive:!1}}).addEvent({eventID:"BottomSheetTouchMove",eventType:"touchmove",callback:z.Move,options:{passive:!1}}).addEvent({eventID:"BottomSheetMouseUp",eventType:"mouseup",callback:z.End}).addEvent({eventID:"BottomSheetTouchEnd",eventType:"touchend",callback:z.End});let m=f.getCursor(y),h=T(g({},x),{process:!0,processStart:new Date().getTime(),originY:m.y,originValue:x.value,viewHeight:f.getScreenSize().height});E.update({[e]:{val_edit:h}}),B(h)},Move:y=>{var O;let m=(O=E.get(e))==null?void 0:O.val_edit;if(!m.process)return;let N=(f.getCursor(y).y-m.originY)/m.viewHeight,o=m.originValue-N;if(o>.95)o=.95+(o-.95)*.5;else if(o<.2){let P=.2-o;P-=.1,o=.1+(.1-P)*.5}return B(T(g({},m),{value:o})),y.preventDefault(),y.stopPropagation(),!1},End:y=>{var o;let m=(o=E.get(e))==null?void 0:o.val_edit;if(!m.process)return;f(document).removeEvent(["BottomSheetMouseMove","BottomSheetTouchMove","BottomSheetMouseUp","BottomSheetTouchEnd"]);let h=0;if(m.value<.1||(m.value<.5?h=1:m.value>.75?h=3:h=2),new Date().getTime()-m.processStart<300){let O=f.getCursor(y).y-m.originY;if(Math.abs(O)>=20){let P=+(O<0)*2-1;h+=P,h=Math.min(Math.max(h,0),D.length-1)}}h==0&&(Y||(h=1)),H(["ZERO","S","R","L"][h]),B(T(g({},m),{value:D[h],process:!1}))}},Q=pe(!1);return X(()=>{Q.current?A=="ZERO"?Y&&_.close(a):setTimeout(()=>{t.sizeChanged&&t.sizeChanged(A)},250):Q.current=!0},[A]),c(k,{className:d("BB"),margin:[0,"auto"],marginTop:"auto",opacity:"trans",width:1,transition:"long",freeCSS:g({maxWidth:12*60,height:F.height*x.value},x.process?{transition:"0s"}:{}),children:$(oe,T(g({gap:0,flexSizing:"none",borderTopLeftRadius:"1.tone.primary",borderTopRightRadius:"1.tone.primary",borderBottom:"unset",boxShadow:"3.remark",position:"relative",overflow:"hidden",height:1},p),{children:[$(re.Separate,{padding:1,backgroundColor:"layer.1",position:"relative",freeCSS:{userSelect:"none"},children:[c(k,{ssSphere:2.5}),c(re.Center,{onPointerDown:z.Start,flexSizing:0,padding:"2/3",ssPushable:!0,isRounded:!0,freeCSS:{cursor:"grab",userSelect:"none"},children:c(k,{unitWidth:6,unitHeight:"1/2",backgroundColor:"layer.4",isRounded:!0,className:d("DragBar")})}),c(se.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{_.close(a)},children:c(ae.Times,{})})]}),c(k,T(g({backgroundColor:"layer.1",flexSizing:0,overflow:"auto"},U),{children:f.is.function(n)?c(n,{}):n}))]}))})},Custom:t=>{let V=t,{sheetID:e,sheetGroups:a,bodyScrolls:l,event:v,parent:n,nextToCursor:u,gravityPoint:r=22,content:p,closeAtAroundClick:s,closeAtEscapeKeyDown:S,closeAtPageTransit:C,closeAtParentBlur:b,closeAtSwipeDown:w,hold_state:M,openAfter:Y,closeAfter:q,overwrap:ee,isOpen:te,resize:W,backgroundEffect:U}=V,F=G(V,["sheetID","sheetGroups","bodyScrolls","event","parent","nextToCursor","gravityPoint","content","closeAtAroundClick","closeAtEscapeKeyDown","closeAtPageTransit","closeAtParentBlur","closeAtSwipeDown","hold_state","openAfter","closeAfter","overwrap","isOpen","resize","backgroundEffect"]),[D]=L(Z()),I=f.is.element(n)||f.is.jmini(n)?f(n):j(n),A='[data-sheet-id="'+D+'"]',H='[data-sheet-content="'+D+'"]';r=r;let x=r%5||5,B=Math.ceil(r/5);const z={Init:()=>{if(u&&v){let i=f.getScreenSize(),ne=f.getCursor(v);return{top:ne.y-i.pageYOffset,left:ne.x-i.pageXOffset}}let y={};if(!I||!I[0])return y;let{top:m,right:h,bottom:N,left:o,height:O,width:P}=I.position();return[1,2].includes(x)?y.left=o:x==3?y.left=o+P/2:[4,5].includes(x)&&(y.left=h),r<=10?y.top=m:r<=15?y.top=m+O/2:r<=25&&(y.top=N),y},Adjust:()=>{let y=j(A).position(),m=j(H).position(),h=I.position(),N=f.getScreenSize(),o={};for(let i in m)o[i]=m[i];if(f.scope(()=>{if(t.nextToCursor)return;let i=0;B==1?i=h.top-o.bottom:B==2?i=h.top-o.top:B==3?i=h.top-o.top+(h.height-o.height)/2:B==4?i=h.bottom-o.bottom:B==5&&(i=h.bottom-o.top),o.top+=i,o.bottom+=i}),f.scope(()=>{if(t.nextToCursor)return;let i=0;x==1?i=h.left-o.right:x==2?i=h.left-o.left:x==3?i=h.left-o.left+(h.width-o.width)/2:x==4?i=h.right-o.right:x==5&&(i=h.right-o.left),o.left+=i,o.right+=i}),o.top<0){let i=-o.top;o.top+=i,o.bottom+=i}if(o.bottom>N.height){let i=o.bottom-N.height;o.top-=i,o.bottom-=i}if(o.left<0){let i=-o.left;o.left+=i,o.right+=i}if(o.right>N.width){let i=o.right-N.width;o.left-=i,o.right-=i}let O=o.top-m.top,P=o.left-m.left;f(A).css({top:y.top+O+"px",left:y.left+P+"px"})}};let[Q]=L(z.Init());return X(()=>{j(A).await(10).addClass(d("Open")).await(200).callback(()=>{(W==null||W)&&z.Adjust()}),E.update({["customSheet-"+t.sheetID]:{reposition:()=>{z.Adjust()}}})},[]),I[0]?c(k,{className:[d("BB"),d("CustomSheet")].join(" "),"data-sheet-id":D,transition:"long",position:"absolute",width:0,height:0,opacity:"trans",flexCenter:!0,freeCSS:Q,children:c(he,{position:"absolute",className:[d("GPT"),d("GPT_"+r),d("Col_"+x),d("Row_"+B)].join(" "),children:c(k,T(g({"data-sheet-content":D,flexSizing:"none",maxHeight:"viewHeight"},F),{freeCSS:g({maxWidth:"98vw"},F.freeCSS),children:f.is.function(p)?c(p,{}):p}))})}):null}},TapSensor:t=>c(k,{className:d("TapSensor"),children:c(se.Plain,{className:d("TapContent"),onClick:e=>{var a;(a=t.delegateAroundClick)!=null&&a&&_.close(t.sheetID)},freeCSS:{cursor:"default",pointerEvents:"all"}})})},_={Wrapper:()=>c(J.Wrapper,{}),Element:t=>{let v=t,{isOpen:e,children:a}=v,l=G(v,["isOpen","children"]);return X(()=>{if(e){_.open(T(g({},l),{content:a}));return}l.sheetID&&_.close(l.sheetID)},[e]),null},open:(t,e)=>{if(t.sheetID=(t.sheetID||"").replace(/\./g,"-"),t.type=="image"){let v=t.sheetID||Z(),l=t,{type:n,src:u}=l,r=G(l,["type","src"]);_.open(T(g({type:"normal.topCenter",size:"MAX",backgroundColor:"trans",height:"viewHeight"},r),{sheetID:v,freeCSS:{maxWidth:"96vw",transformOrigin:"top"},content:()=>{let[p]=L(f.flatArray(u)),[s,S]=L(0),C=[];return p.forEach((b,w)=>{C.push({value:w,label:c(ie,{src:f.flatArray(b)[0],width:"auto",height:1,borderRadius:"3.tone.tertiary",freeCSS:{maxWidth:12*6,maxHeight:12*3}})})}),$(oe,{gap:0,height:1,position:"relative",children:[$(re.Separate,{position:"absolute",top:0,left:0,right:0,padding:[1,2],freeCSS:{zIndex:2},children:[c(ce.Radio,{icon:!1,value:s,override:"force",horizontalAlign:"center",onUpdateValidValue:b=>{S(b)},cellStyles:{border:!0,borderWidth:2,padding:"1/3",paddingRight:"1/3",boxShadow:"2.normal",gap:0},cellCheckedStyles:{borderColor:"theme"},options:C}),c(se.Sub.S,{color:"cloud",ssSphere:3,onClick:()=>{_.close(v)},children:c(ae.Times,{})})]}),c(ue.FadeIn,{flexCenter:!0,flexSizing:0,overflow:"auto",children:c(ie,{width:"auto",height:"auto",maxWidth:1,maxHeight:1,src:p[s]})},s)]})}}));return}let a=E.get("Sheet-"+K.get().sessionUID);a&&a.add(t,e)},resize:t=>{t.sheetID=(t.sheetID||"").replace(/\./g,"-");let e=E.get(t.sheetID);e&&e.resize&&e.resize(t.size)},customSheet:{reposition:t=>{let e=E.get("customSheet-"+t);e&&e.reposition&&e.reposition()}},close:function(t,e,a){let l=R.getSessionStates();if(!l)return;let{val_sheets:v}=l;t=t==null?void 0:t.replace(/\./g,"-");let n=v.find(r=>r.sheetID==t);if(!n||e=="Escape"&&!n.closeAtEscapeKeyDown)return;let u=E.get(n.sheetID);u&&u.close&&u.close(a)},closeGroup:t=>{let e=R.getSessionStates();if(!e)return;let{val_sheets:a}=e;t=(t||"").replace(/\./g,"-");for(let l of a)l.sheetGroups&&l.sheetGroups==t&&_.close(l.sheetID)},closeAll:t=>{let e=R.getSessionStates();if(!e)return;let{val_sheets:a}=e;for(let l of a)t&&!l.closeAtPageTransit||_.close(l.sheetID,"pageTransit",!0)},Body:t=>c(k,g({className:d("BaseBody"),backgroundColor:"layer.1",borderRadius:"1.tone.primary",position:"relative",boxShadow:"3.remark",transition:"long"},t))};export{_ as Sheet,_ as default};
|
|
1
|
+
import{b as g,c as w,d as G}from"../chunk-C5N2D3ZX.js";import{jsx as c,jsxs as $}from"react/jsx-runtime";import f,{UUID as J,Time as le,useStore as A}from"jmini";import{useState as U,useEffect as X,useRef as pe}from"react";import{$$fromRoot as j,Config as K}from"../@utils";import{Box as k,Flex as ue,Img as ie,FAI as ae,Column as oe}from"../atoms";import{Row as re}from"../mols";import{Button as se}from"./Button";import he from"./Input";import{SheetClasses as m}from"../@styles/componentClasses";import ce from"./Effect";const T={currentIndex:0,openQueue:{},getSessionStates:()=>{let t=A.get("sessionStates-"+K.get().sessionUID);return t||null},getNewSheetStates:t=>{var l;let e=w(g({sheetGroups:t.sheetGroups||[],backgroundEffect:!0,overwrap:t.type=="custom",hold_state:!1,closeAtPageTransit:!0,closeAtEscapeKeyDown:!0,closeAtAroundClick:t.type=="custom"},t),{sheetID:t.sheetID||J(),isOpen:!0,created_at:le()});if(e.type=="custom"){let u=e;u.parent=u.parent||((l=u==null?void 0:u.event)==null?void 0:l.currentTarget),e=u}return e}},Y={Wrapper:()=>{let[t,e]=U([]),l={val_sheets:t,set_sheets:e},u="sessionStates-"+K.get().sessionUID;A.set({[u]:l}),X(()=>{let n="Sheet-"+K.get().sessionUID;A.set({[n]:{add:(a,r)=>{let s=A.get(n);if(!s)return;let i=T.getNewSheetStates(a);if(T.openQueue[i.sheetID])return;if(T.openQueue[i.sheetID]=!0,r!="inherit"&&(i.isOpen=r!=null?r:!0),!!s.find(i.sheetID)){e(y=>{let R=[...y],D=R.findIndex(N=>N.sheetID==i.sheetID);return D==-1||(R[D]=i),R}),delete T.openQueue[i.sheetID];return}e(y=>[i,...y])},find:a=>{let r=T.getSessionStates();if(!r)return null;let{val_sheets:s}=r;return s.find(i=>i.sheetID==a)}}}),f(K.get().appRoot).addEvent({eventType:"keyup",eventID:"SheetEvent.keyUp",callback:function(a){let{key:r,metaKey:s}=a;if(r=="Escape"||r==","&&s){let i=T.getSessionStates();if(!i)return;let{val_sheets:I}=i,y=I.filter(D=>D.isOpen);if(!y.length)return;let R=y.reduce((D,N)=>D.created_at.value>N.created_at.value?D:N);E.close(R.sheetID,r)}}}).addEvent({eventType:"click",eventID:"SheetEvent.Click",callback:function(a){let r=T.getSessionStates();if(!r)return;let{val_sheets:s}=r,i=a.target;if(!i||i!=null&&i.closest("."+m("CustomSheet")))return;let I=s.filter(y=>y.type=="custom");I.length&&I.forEach(y=>{let{parent:R}=y;if(!y.closeAtAroundClick)return;let D=j(R)[0];R!==i&&D!==i&&(f(D).find(i).length||E.close(y.sheetID))})}})},[]);let S=t.map(n=>c(Y.Core,w(g({},l),{val_sheet:n,patch_sheet:a=>{e(r=>{let s=[...r],i=s.findIndex(I=>I.sheetID==n.sheetID);return i==-1||(s[i]=g(g({},s[i]),a)),s})},delete_sheet:()=>{e(a=>{let r=[...a],s=r.findIndex(i=>i.sheetID==n.sheetID);return s==-1||r.splice(s,1),r})}}),n.sheetID));return c(k,{className:["AMOTIFY_be",m("Wrapper")].join(" "),children:S})},sheetCategory:t=>t=="custom"?"custom":t.startsWith("drawer")?"drawer":"normal",sheetPosition:t=>t=="drawer.left"?"left":t=="drawer.right"?"right":t=="drawer.bottom"?"bottom":"",Core:t=>{let{val_sheet:e,patch_sheet:l}=t,[u,S]=U(T.currentIndex+2),[n]=U(J()),a=e.type!="custom"&&!e.overwrap;X(()=>{T.currentIndex++,f.scope(()=>{if(!e.closeAtParentBlur)return;let s=f(e.parent);s[0]&&s.addEvent({eventID:"SheetClosation-"+e.sheetID,eventType:"mouseout",callback:()=>{s.removeEvent("SheetClosation-"+e.sheetID),l({isOpen:!1})}})}),A.set({[e.sheetID]:{resize:s=>{if(e.type=="drawer.bottom"){let i=A.get(n);i&&i.resize&&i.resize(s)}else(e.type.includes("normal")||e.type.includes("drawer"))&&l({size:s})},close:s=>{l({isOpen:!1})},open:()=>{l({isOpen:!0})}}})},[]),X(()=>{f.scope(()=>{let s=j("#"+n);if(e.isOpen){e.hold_state&&S(T.currentIndex+1),s.await(10).removeClass(m("Hide")).await(10).addClass(m("Open")).callback(()=>{delete T.openQueue[e.sheetID],e.openAfter&&e.openAfter()});return}s.await(10).removeClass(m("Open")).await(251).addClass(m("Hide")).callback(()=>{if(e.closeAfter&&e.closeAfter(),a&&K.get().browserIs!="safari"&&f(K.get().appRoot).focus(),e.hold_state)return l({isOpen:!1});t.delete_sheet()})})},[e.isOpen]);let r=Y.Types[{topLeft:"Normal",topCenter:"Normal",topRight:"Normal",middleLeft:"Normal",middleCenter:"Normal",middleRight:"Normal",bottomLeft:"Normal",bottomCenter:"Normal",bottomRight:"Normal","drawer.left":"Edge","drawer.right":"Edge","drawer.bottom":"Bottom",custom:"Custom"}[e.type]];return c(k,{className:[m("Wrap"),m("Tcate_"+Y.sheetCategory(e.type)),m("Tpos_"+Y.sheetPosition(e.type)),m("isMainSheet_"+a)].join(" "),width:1,ssAbsoluteCovered:!0,freeCSS:{zIndex:u},id:n,children:$(oe,{className:m("Content"),gap:0,height:"viewHeight",overflow:"auto",transition:"middle",children:[!!a&&c(Y.TapSensor,{sheetID:e.sheetID,delegateAroundClick:e.closeAtAroundClick}),c(r,g({componentID:n},e))]})},n)},Types:{Normal:t=>{let _=t,{sheetID:e,sheetGroups:l,bodyScrolls:u,content:S,className:n="",type:a,size:r="R",freeCSS:s,openAfter:i,closeAfter:I,closeAtAroundClick:y,closeAtEscapeKeyDown:R,closeAtPageTransit:D,closeAtParentBlur:N,closeAtSwipeDown:F,hold_state:q,overwrap:ee,isOpen:te,backgroundEffect:M}=_,W=G(_,["sheetID","sheetGroups","bodyScrolls","content","className","type","size","freeCSS","openAfter","closeAfter","closeAtAroundClick","closeAtEscapeKeyDown","closeAtPageTransit","closeAtParentBlur","closeAtSwipeDown","hold_state","overwrap","isOpen","backgroundEffect"]),x={},v=[];return a.match(/top/)?(v.push("top"),x.marginBottom="auto"):a.match(/middle/)?(v.push("center"),x.marginTop="auto",x.marginBottom="auto"):a.match(/bottom/)&&(v.push("bottom"),x.marginTop="auto"),a.match(/left/i)?(v.push("left"),x.marginRight="auto"):a.match(/center/i)?(v.push("center"),x.marginLeft="auto",x.marginRight="auto"):a.match(/right/i)&&(v.push("right"),x.marginLeft="auto"),c(k,w(g(g({className:[m("BB"),n].join(" "),padding:1,transition:"long",opacity:"trans"},W),x),{freeCSS:g({width:{S:"26rem",R:"36rem",L:"44rem","2L":"60rem","3L":"72rem",MAX:"100%"}[r],maxWidth:"96vw",transformOrigin:v.join(" ")},s),children:f.is.function(S)?c(S,{}):S}))},Edge:t=>{let W=t,{sheetID:e,sheetGroups:l,bodyScrolls:u,type:S,content:n,className:a="",size:r="R",openAfter:s,closeAfter:i,closeAtAroundClick:I,closeAtEscapeKeyDown:y,closeAtPageTransit:R,closeAtParentBlur:D,closeAtSwipeDown:N,hold_state:F,overwrap:q,isOpen:ee,backgroundEffect:te}=W,M=G(W,["sheetID","sheetGroups","bodyScrolls","type","content","className","size","openAfter","closeAfter","closeAtAroundClick","closeAtEscapeKeyDown","closeAtPageTransit","closeAtParentBlur","closeAtSwipeDown","hold_state","overwrap","isOpen","backgroundEffect"]);return c(k,w(g(w(g({className:[m("BB"),a].join(" ")},S=="drawer.right"?{marginLeft:"auto"}:S=="drawer.left"?{marginRight:"auto"}:{}),{opacity:"trans",transition:"long",position:"relative",backgroundColor:"layer.1",flexSizing:"none",minHeight:"viewHeight",boxShadow:"3.remark"}),M),{freeCSS:g({width:{S:"20rem",R:"27rem",L:"32rem","2L":"40rem","3L":"58rem",MAX:"100vw"}[r],maxWidth:"96vw"},M.freeCSS),children:f.is.function(n)?c(n,{}):n}))},Bottom:t=>{let V=t,{componentID:e,sheetID:l,sheetGroups:u,bodyScrolls:S,content:n,size:a="R",sizeChanged:r,baseStyles:s,openAfter:i,closeAfter:I,closeAtAroundClick:y,closeAtEscapeKeyDown:R,closeAtPageTransit:D,closeAtParentBlur:N,closeAtSwipeDown:F=!0,hold_state:q,overwrap:ee,isOpen:te,backgroundEffect:M}=V,W=G(V,["componentID","sheetID","sheetGroups","bodyScrolls","content","size","sizeChanged","baseStyles","openAfter","closeAfter","closeAtAroundClick","closeAtEscapeKeyDown","closeAtPageTransit","closeAtParentBlur","closeAtSwipeDown","hold_state","overwrap","isOpen","backgroundEffect"]),x=f.getScreenSize(),v=[0,.2,.6,.95],_={ZERO:0,S:1,R:2,L:3,"2L":3,"3L":3,MAX:3},[H,Q]=U(a),[b,B]=U({process:!1,processStart:0,originY:0,originValue:0,viewHeight:0,value:v[_[a]]});A.update({[e]:{val_edit:b,resize:C=>{let d=v[_[C]];B(h=>w(g({},h),{value:d})),Q(C)}}});const z={Start:C=>{f(document).addEvent({eventID:"BottomSheetMouseMove",eventType:"mousemove",callback:z.Move,options:{passive:!1}}).addEvent({eventID:"BottomSheetTouchMove",eventType:"touchmove",callback:z.Move,options:{passive:!1}}).addEvent({eventID:"BottomSheetMouseUp",eventType:"mouseup",callback:z.End}).addEvent({eventID:"BottomSheetTouchEnd",eventType:"touchend",callback:z.End});let d=f.getCursor(C),h=w(g({},b),{process:!0,processStart:new Date().getTime(),originY:d.y,originValue:b.value,viewHeight:f.getScreenSize().height});A.update({[e]:{val_edit:h}}),B(h)},Move:C=>{var P;let d=(P=A.get(e))==null?void 0:P.val_edit;if(!d.process)return;let O=(f.getCursor(C).y-d.originY)/d.viewHeight,o=d.originValue-O;if(o>.95)o=.95+(o-.95)*.5;else if(o<.2){let L=.2-o;L-=.1,o=.1+(.1-L)*.5}return B(w(g({},d),{value:o})),C.preventDefault(),C.stopPropagation(),!1},End:C=>{var o;let d=(o=A.get(e))==null?void 0:o.val_edit;if(!d.process)return;f(document).removeEvent(["BottomSheetMouseMove","BottomSheetTouchMove","BottomSheetMouseUp","BottomSheetTouchEnd"]);let h=0;if(d.value<.1||(d.value<.5?h=1:d.value>.75?h=3:h=2),new Date().getTime()-d.processStart<300){let P=f.getCursor(C).y-d.originY;if(Math.abs(P)>=20){let L=+(P<0)*2-1;h+=L,h=Math.min(Math.max(h,0),v.length-1)}}h==0&&(F||(h=1)),Q(["ZERO","S","R","L"][h]),B(w(g({},d),{value:v[h],process:!1}))}},Z=pe(!1);return X(()=>{Z.current?H=="ZERO"?F&&E.close(l):setTimeout(()=>{t.sizeChanged&&t.sizeChanged(H)},250):Z.current=!0},[H]),c(k,{className:m("BB"),margin:[0,"auto"],marginTop:"auto",opacity:"trans",width:1,transition:"long",freeCSS:g({maxWidth:12*60,height:x.height*b.value},b.process?{transition:"0s"}:{}),children:$(oe,w(g({gap:0,flexSizing:"none",borderTopLeftRadius:"1.tone.primary",borderTopRightRadius:"1.tone.primary",borderBottom:"unset",boxShadow:"3.remark",position:"relative",overflow:"hidden",height:1},s),{children:[$(re.Separate,{padding:1,backgroundColor:"layer.1",position:"relative",freeCSS:{userSelect:"none"},children:[c(k,{ssSphere:2.5}),c(re.Center,{onPointerDown:z.Start,flexSizing:0,padding:"2/3",ssPushable:!0,isRounded:!0,freeCSS:{cursor:"grab",userSelect:"none"},children:c(k,{unitWidth:6,unitHeight:"1/2",backgroundColor:"layer.4",isRounded:!0,className:m("DragBar")})}),c(se.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{E.close(l)},children:c(ae.Times,{})})]}),c(k,w(g({backgroundColor:"layer.1",flexSizing:0,overflow:"auto"},W),{children:f.is.function(n)?c(n,{}):n}))]}))})},Custom:t=>{let V=t,{sheetID:e,sheetGroups:l,bodyScrolls:u,event:S,parent:n,nextToCursor:a,gravityPoint:r=22,content:s,closeAtAroundClick:i,closeAtEscapeKeyDown:I,closeAtPageTransit:y,closeAtParentBlur:R,closeAtSwipeDown:D,hold_state:N,openAfter:F,closeAfter:q,overwrap:ee,isOpen:te,resize:M,backgroundEffect:W}=V,x=G(V,["sheetID","sheetGroups","bodyScrolls","event","parent","nextToCursor","gravityPoint","content","closeAtAroundClick","closeAtEscapeKeyDown","closeAtPageTransit","closeAtParentBlur","closeAtSwipeDown","hold_state","openAfter","closeAfter","overwrap","isOpen","resize","backgroundEffect"]),[v]=U(J()),_=f.is.element(n)||f.is.jmini(n)?f(n):j(n),H='[data-sheet-id="'+v+'"]',Q='[data-sheet-content="'+v+'"]';r=r;let b=r%5||5,B=Math.ceil(r/5);const z={Init:()=>{if(a&&S){let p=f.getScreenSize(),ne=f.getCursor(S);return{top:ne.y-p.pageYOffset,left:ne.x-p.pageXOffset}}let C={};if(!_||!_[0])return C;let{top:d,right:h,bottom:O,left:o,height:P,width:L}=_.position();return[1,2].includes(b)?C.left=o:b==3?C.left=o+L/2:[4,5].includes(b)&&(C.left=h),r<=10?C.top=d:r<=15?C.top=d+P/2:r<=25&&(C.top=O),C},Adjust:()=>{let C=j(H).position(),d=j(Q).position(),h=_.position(),O=f.getScreenSize(),o={};for(let p in d)o[p]=d[p];if(f.scope(()=>{if(t.nextToCursor)return;let p=0;B==1?p=h.top-o.bottom:B==2?p=h.top-o.top:B==3?p=h.top-o.top+(h.height-o.height)/2:B==4?p=h.bottom-o.bottom:B==5&&(p=h.bottom-o.top),o.top+=p,o.bottom+=p}),f.scope(()=>{if(t.nextToCursor)return;let p=0;b==1?p=h.left-o.right:b==2?p=h.left-o.left:b==3?p=h.left-o.left+(h.width-o.width)/2:b==4?p=h.right-o.right:b==5&&(p=h.right-o.left),o.left+=p,o.right+=p}),o.top<0){let p=-o.top;o.top+=p,o.bottom+=p}if(o.bottom>O.height){let p=o.bottom-O.height;o.top-=p,o.bottom-=p}if(o.left<0){let p=-o.left;o.left+=p,o.right+=p}if(o.right>O.width){let p=o.right-O.width;o.left-=p,o.right-=p}let P=o.top-d.top,L=o.left-d.left;f(H).css({top:C.top+P+"px",left:C.left+L+"px"})}};let[Z]=U(z.Init());return X(()=>{j(H).await(10).addClass(m("Open")).await(200).callback(()=>{(M==null||M)&&z.Adjust()}),A.update({["customSheet-"+t.sheetID]:{reposition:()=>{z.Adjust()}}})},[]),_[0]?c(k,{className:[m("BB"),m("CustomSheet")].join(" "),"data-sheet-id":v,transition:"long",position:"absolute",width:0,height:0,opacity:"trans",flexCenter:!0,freeCSS:Z,children:c(ue,{position:"absolute",className:[m("GPT"),m("GPT_"+r),m("Col_"+b),m("Row_"+B)].join(" "),children:c(k,w(g({"data-sheet-content":v,flexSizing:"none",maxHeight:"viewHeight"},x),{freeCSS:g({maxWidth:"98vw"},x.freeCSS),children:f.is.function(s)?c(s,{}):s}))})}):null}},TapSensor:t=>c(k,{className:m("TapSensor"),children:c(se.Plain,{className:m("TapContent"),onClick:e=>{var l;(l=t.delegateAroundClick)!=null&&l&&E.close(t.sheetID)},freeCSS:{cursor:"default",pointerEvents:"all"}})})},E={Wrapper:()=>c(Y.Wrapper,{}),Element:(t,e)=>{let n=e,{isOpen:l,children:u}=n,S=G(n,["isOpen","children"]);return e.type=t,X(()=>{if(l){E.open(t,w(g({},S),{content:u}));return}S.sheetID&&E.close(S.sheetID)},[l]),null},image:(t,e)=>{let l=t.sheetID||J(),n=t,{type:u}=n,S=G(n,["type"]);E.open(u||"topCenter",w(g({size:"MAX",backgroundColor:"trans",height:"viewHeight"},S),{sheetID:l,freeCSS:{maxWidth:"96vw",transformOrigin:"top"},content:()=>{let[a]=U(f.flatArray(e)),[r,s]=U(0),i=[];return a.forEach((I,y)=>{i.push({value:y,label:c(ie,{src:f.flatArray(I)[0],width:"auto",height:1,borderRadius:"3.tone.tertiary",freeCSS:{maxWidth:12*6,maxHeight:12*3}})})}),$(oe,{gap:0,height:1,position:"relative",children:[$(re.Separate,{position:"absolute",top:0,left:0,right:0,padding:[1,2],freeCSS:{zIndex:2},children:[c(he.Radio,{icon:!1,value:r,override:"force",horizontalAlign:"center",onUpdateValidValue:I=>{s(I)},cellStyles:{border:!0,borderWidth:2,padding:"1/3",paddingRight:"1/3",boxShadow:"2.normal",gap:0},cellCheckedStyles:{borderColor:"theme"},options:i}),c(se.Sub.S,{color:"cloud",ssSphere:3,onClick:()=>{E.close(l)},children:c(ae.Times,{})})]}),c(ce.FadeIn,{flexCenter:!0,flexSizing:0,overflow:"auto",children:c(ie,{width:"auto",height:"auto",maxWidth:1,maxHeight:1,src:a[r]})},r)]})}}))},open:(t,e,l)=>{e.sheetID=(e.sheetID||"").replace(/\./g,"-"),e.type=t;let u=A.get("Sheet-"+K.get().sessionUID);u&&u.add(e,l)},resize:t=>{t.sheetID=(t.sheetID||"").replace(/\./g,"-");let e=A.get(t.sheetID);e&&e.resize&&e.resize(t.size)},customSheet:{reposition:t=>{let e=A.get("customSheet-"+t);e&&e.reposition&&e.reposition()}},close:function(t,e,l){let u=T.getSessionStates();if(!u)return;let{val_sheets:S}=u;t=t==null?void 0:t.replace(/\./g,"-");let n=S.find(r=>r.sheetID==t);if(!n||e=="Escape"&&!n.closeAtEscapeKeyDown)return;let a=A.get(n.sheetID);a&&a.close&&a.close(l)},closeGroup:t=>{let e=T.getSessionStates();if(!e)return;let{val_sheets:l}=e;t=(t||"").replace(/\./g,"-");for(let u of l)u.sheetGroups&&u.sheetGroups==t&&E.close(u.sheetID)},closeAll:t=>{let e=T.getSessionStates();if(!e)return;let{val_sheets:l}=e;for(let u of l)t&&!u.closeAtPageTransit||E.close(u.sheetID,"pageTransit",!0)},Body:t=>c(k,g({className:m("BaseBody"),backgroundColor:"layer.1",borderRadius:"1.tone.primary",position:"relative",boxShadow:"3.remark",transition:"long"},t))};export{E as Sheet,E as default};
|
package/dist/fn/Table/Data.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as r,c as y,d as G}from"../../chunk-C5N2D3ZX.js";import{Fragment as j,jsx as l,jsxs as x}from"react/jsx-runtime";import D,{UUID as Q,useStore as Y}from"jmini";import{useState as Z,useEffect as U}from"react";import{useRefresh as F}from"../../@utils";import{Box as B,Flex as M,FAI as N,Span as le,Column as oe}from"../../atoms";import{Row as E}from"../../mols";import{Button as H}from"../Button";import ee from"../Sheet";import P 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 C}from"../../@styles/componentClasses";const I={__memoryID:Q(),Header:t=>{var u,w;let{val_status:e,set_status:i,KeywordFilterRows:h}=r({},t),{order:s,filter:a}=e,[g,p]=s.current,S=[],c=[...e.head];if(e.checker){let n={top:!0,bottom:!e.rows.length,left:!0,right:!e.colLength,rowIndex:0,colIndex:0,isBody:!1,isHeader:!0},o=V(n),d=e.cellStylesCallback?e.cellStylesCallback(n):{};S.push(l(R.TH,y(r(r(r({fontWeight:"2.normal",position:"sticky",top:0,unitWidth:4,padding:0},e.cellStyles),o),d),{freeCSS:y(r(r({},(u=e.cellStyles)==null?void 0:u.freeCSS),d.freeCSS),{zIndex:2}),className:[C("Cell"),e.cellClassName].join(" "),children:l(B,{flexCenter:!0,children:l(P.Checker,{label:"",value:!1,onUpdateValidValue:f=>{let m=e.rows;m.forEach(L=>{L.checked=f}),i(y(r({},e),{rows:m}))}})})}),-1))}for(let n=0;n<e.colLength;n++){let o=c[n];if(!o)continue;let d=o.children||o.data,f=s.enabled&&s.column[n],m=a.enabled&&a.column[n],L=f?l(N,{fontSize:"1.mini",fontColor:n==g?"1.clear":"5.translucent",icon:n==g?p=="DESC"?se:ne:ie}):null,A=l(j,{});if(m){let _=h.map(O=>{var v;return(v=O[n])==null?void 0:v.data});_=[...new Set(_)].toASC();let T=a.current[n];if(T){let O=_.filter(b=>!T.includes(b)),v=[];_.forEach(b=>{b&&v.push({value:b,label:l(B,{flexSizing:"auto",children:b})})});let J="BUTTON-"+e.componentID+"-"+n,X=e.componentID+"-"+n,re={sheetID:X,parent:"#"+J,gravityPoint:23,type:"custom",content:x(M,{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(P.Checkbox,{icon:!0,value:O,display:"flex",gap:"2/3",override:"force",options:v,hideInput:!0,name:"DTFilter-col-"+n+"-table-"+e.componentID,onUpdateValidValue:b=>{let K=_.filter(ae=>!b.includes(ae)),$=r({},e);$.filter.current[n]=K,i($)}})}),x(E.Separate,{gap:"2/3",padding:"2/3",horizontalAlign:"right",children:[l(H.Border.S,{isRounded:!0,onClick:()=>{ee.close(X)},children:"\u9589\u3058\u308B"}),l(H.Prime.S,{color:"theme",isRounded:!0,ssEffectsOnActive:"shrink",onClick:()=>{let b=[];T.length||(b=_);let K=r({},e);K.filter.current[n]=b,i(K)},children:"\u5168\u9078\u629E"})]})]})};A=l(B,{className:C("FilterRegion"),children:l(H.Sub.S,{ssSphere:2.5,fontSize:"1.mini",className:C("Filtering_"+!!T.length),id:J,onClick:b=>{b.stopPropagation(),ee.open(re)},children:l(N,{icon:ce})})})}}let z={top:!0,bottom:!e.rows.length,left:e.checker?!1:n==0,right:n==e.colLength-1,rowIndex:0,colIndex:n,isBody:!1,isHeader:!0},te=V(z),q=e.cellStylesCallback?e.cellStylesCallback(z):{};o=y(r(r(r(r({},e.cellStyles),te),o),q),{ssPushable:f,freeCSS:r(r(r({},(w=e.cellStyles)==null?void 0:w.freeCSS),q.freeCSS),o.freeCSS),className:[C("Cell"),e.cellClassName,o.className].join(" ")}),delete o.orderIndex,S.push(l(R.TH,y(r({fontWeight:"2.normal",position:"sticky",top:0},o),{freeCSS:r({zIndex:2},o.freeCSS),onClick:_=>{if(f){let T=r({},e),O=[n,g===n?p=="ASC"?"DESC":"ASC":s.priority];T.order.current=O,i(T),e.onOrderChanged&&e.onOrderChanged(O)}},children:x(M,{flexType:"row-r",flexWrap:!1,height:1,borderRadius:"inherit",flexCenter:!0,children:[A,x(M,{flexSizing:0,position:"relative",borderRadius:"inherit",gap:"1/2",flexWrap:!1,verticalAlign:"center",horizontalAlign:"center",children:[L,d]})]})}),n))}return l(R.Row,{className:[C("Row"),C("HeadRow")].join(" "),children:S})},Body:t=>{let{val_status:e,PageRows:i}=t,h=[];if(i.forEach((s,a)=>{var S;let g=[...s],p=[];if(e.checker){let c={top:a==0&&!e.head,bottom:a==i.length-1,left:!0,right:!e.colLength,rowIndex:a,colIndex:0,isBody:!0,isHeader:!1},u=V(c),w=e.cellStylesCallback?e.cellStylesCallback(c):{};p.push(l(R.TH,y(r(r(r({unitWidth:4,padding:0,borderRight:!0},e.cellStyles),u),w),{freeCSS:r(r({},(S=e.cellStyles)==null?void 0:S.freeCSS),w.freeCSS),className:[C("Cell"),e.cellClassName].join(" "),children:l(B,{flexCenter:!0,children:l(P.Checker,{label:"",value:s.checked,override:"force",onUpdateValidValue:n=>{let o=e.rows,d=o.findIndex(f=>D.is.equal(f.rowID,s.rowID));d!=-1&&(o[d].checked=n,t.set_status(f=>y(r({},f),{rows:o})))}})})}),-1))}g.forEach((c,u)=>{var A;if(!c)return;let L=c,{type:w="td"}=L,n=G(L,["type"]),o={top:a==0&&!e.head,bottom:a==i.length-1,left:e.checker?!1:u==0,right:u==e.colLength-1,rowIndex:a,colIndex:u,isBody:!0,isHeader:!1},d=V(o),f=e.cellStylesCallback?e.cellStylesCallback(o):{};n=y(r(r(r(r({},e.cellStyles),d),n),f),{freeCSS:r(r(r({},(A=e.cellStyles)==null?void 0:A.freeCSS),n.freeCSS),f.freeCSS),className:[C("Cell"),e.cellClassName,n.className].join(" ")}),delete n.orderIndex;let m=R[w=="td"?"TD":"TH"];p.push(l(m,r({},n),u))}),h.push(l(R.Row,{className:[C("Row"),C("BodyRow")].join(" "),children:p,onClick:c=>{e.onRowClick&&e.onRowClick(s.rowID,c)}},a))}),!i.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(j,{children:e.noRecords})),h.push(l(R.Row,{className:[C("Row"),C("BodyRow"),C("DataNotFound")].join(" "),children:l(R.TD,{colSpan:e.colLength,className:C("Cell"),children:s})},"dataNotFound"))}return l(j,{children:h})},Core:t=>{let{val_status:e,set_status:i}=t,{searchKeyword:h,filter:s,order:a,paging:g}=e,p=[...e.rows],S=[...e.rows],c=[...e.rows],u=[...e.rows];if(h&&(S=p.filter(o=>(o.__sys4SearchKey||"").match(new RegExp(String(h).escapeRegExChar(),"i"))?1:0),c=[...S],u=[...S]),s.enabled)for(let o=0;o<e.colLength;o++){let d=s.column[o],f=s.current[o];d&&f&&f.length&&(c=c.filter(m=>!f.includes(m[o].data)),u=[...c])}a.enabled&&(a.current[1]=="ASC"?c=c.toASC([a.current[0],"orderIndex"]):c=c.toDESC([a.current[0],"orderIndex"]),u=[...c]);{let{currentPageIndex:o,rowLength:d}=g;u=[...u].splice((o-1)*d,d)}let w=I.__memoryID+"_"+e.tableID,n={rows:{total:p.length,page:u.length,filtered:c.length},val_status:y(r({},e),{paging:y(r({},e.paging),{pageLength:Math.ceil(c.length/e.paging.rowLength)})}),set_status:i};return Y.update({[w]:{getRowData:()=>{let o=[...p];return a.enabled&&(a.current[1]=="ASC"?o=o.toASC([a.current[0],"orderIndex"]):o=o.toDESC([a.current[0],"orderIndex"])),o.forEach(d=>{d.currentPage=!1,d.filtered=!1}),u.forEach(d=>{let{rowID:f}=d;o.find(m=>D.is.equal(m.rowID,f)).currentPage=!0}),c.forEach(d=>{let{rowID:f}=d;o.find(m=>D.is.equal(m.rowID,f)).filtered=!0}),o}}}),U(()=>{F.release(e.tableID,n)}),l(B,{className:C("TableBase"),children:l(R.Table,{className:C("Table"),children:x(R.Body,{children:[l(I.Header,{val_status:e,set_status:i,KeywordFilterRows:S}),l(I.Body,{val_status:e,set_status:i,PageRows:u})]})})},h)},Propagations:{},DataLeveler:t=>{var e,i;return t=r({},t),t.filter=(e=t.filter)!=null?e:!1,t.filter=Array.from({length:t.colLength}).map((h,s)=>{var a;return D.is.boolean(t.filter)?t.filter:(a=t.filter[s])!=null?a:!1}),t.order=(i=t.order)!=null?i:!0,t.orderPriority=t.orderPriority||"ASC",t.order=Array.from({length:t.colLength}).map((h,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((h,s)=>{h.rowID=h.rowID||s;let a=[];h.forEach((g,p)=>{let{data:S,children:c,orderIndex:u}=g;g.orderIndex=D.is.exist(u)?String(u):String(S),g.children=c||String(S),a.push(String(g.data))}),h.__sys4SearchKey=a.join("/")}),l(I.StateManager,r({},t))},StateManager:t=>{let{colLength:e,checker:i=!1,searchKeyword:h="",filter:s,order:a,orderPriority:g="ASC",defaultOrder:p=[0,g],pageRowLength:S=30}=t,[c]=Z(Q()),u={tableID:t.tableID||c,componentID:c,colLength:e,checker:i,searchKeyword:h,filter:{enabled:s!==!1,column:s,current:Array.from({length:e},()=>[])},order:{enabled:a!==!1,column:a,current:p,priority:t.orderPriority},paging:{rowLength:S,pageLength:Math.ceil(t.rows.length/S),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},[w,n]=Z(u);const o=()=>{const d=new WeakSet;return(f,m)=>{if(typeof m=="object"&&m!==null){if(d.has(m))return"[Circular Reference]";if(f=="children")return"[React Element]";d.add(m)}return m}};return U(()=>{n(d=>y(r({},d),{rows:u.rows}))},[D.Stringify(u.rows,o())]),U(()=>{n(d=>y(r({},d),{head:u.head}))},[D.Stringify(u.head,o())]),l(I.Core,{val_status:w,set_status:n})}},ue={__memoryID:I.__memoryID,getRowData:t=>{let e=Y.get(I.__memoryID+"_"+t);if(e!=null&&e.getRowData)return e.getRowData()}},W={SearchInput:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:i,set_status:h}=e;return l(P.TextField,{label:"\u691C\u7D22...",clearButton:!0,padding:"2/3",paddingRight:3,rightIcon:l(P.RightIcon,{ssSphere:2,fontColor:"5.translucent",right:"2/3",children:l(N.Search,{})}),value:i.searchKeyword,onUpdateValidValue:s=>{t.onChange(s),D.interval.once(()=>{h(a=>y(r({},a),{paging:y(r({},a.paging),{currentPageIndex:1}),filter:y(r({},a.filter),{current:Array.from({length:a.colLength},()=>[])}),searchKeyword:s}))},200,"InputSearchTime")}})},Info:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:i,set_status:h}=e,s=e.rows.filtered.ratio(e.rows.total)||0;return x(M,{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:i,set_status:h}=e,s=[];for(let g=0;g<i.paging.pageLength;g++)s.push({value:g+1,label:(g+1).toString()});const a=g=>{let p=Math.min(Math.max(1,g),i.paging.pageLength),S=r({},i);S.paging.currentPageIndex=p,h(c=>y(r({},c),{paging:y(r({},c.paging),{currentPageIndex:p})}))};return x(E.Center,{children:[x(E.Center,{gap:"1/2",children:[l(P.Select,{label:"\u9805",freeCSS:{minWidth:12*3},emptySelect:!1,padding:["1/3","2/3"],rightIcon:!1,override:"force",value:i.paging.currentPageIndex,options:s,onUpdateValidValue:g=>{a(g)}}),"/ ",i.paging.pageLength]}),x(E.Right,{gap:"1/2",children:[l(H.Sub,{ssSphere:3,onClick:()=>{if(i.paging.currentPageIndex==1){a(i.paging.pageLength);return}a(i.paging.currentPageIndex-1)},children:l(N.ChevronLeft,{})}),l(H.Sub,{ssSphere:3,onClick:()=>{if(i.paging.currentPageIndex==i.paging.pageLength){a(1);return}a(i.paging.currentPageIndex+1)},children:l(N.ChevronRight,{})})]})]})},RowLength:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:i,set_status:h}=e,s=i.paging.rowLength,a=0,g=t.lengthSelect.map(p=>(a|=+(p==s),{value:p,label:p.toString()}));return a||g.push({value:s,label:s.toString()}),l(E.Center,{gap:"1/2",children:l(P.Select,{label:"\u4EF6\u6570",emptySelect:!1,rightIcon:!1,override:"force",padding:["1/3","2/3"],SelectorStyles:{freeCSS:{minWidth:12*9}},SelectorPosition:4,value:i.paging.rowLength,options:g.toASC("value"),onUpdateValidValue:p=>{h(S=>y(r({},S),{paging:{rowLength:Number(p),currentPageIndex:1,pageLength:Math.ceil(e.rows.filtered/Number(p))}}))}})})}},ge=t=>l(de,y(r({},t),{type:"data",JSXChildren:I.DataLeveler})),k=ge;k.__memoryID=I.__memoryID,k.getRowData=ue.getRowData,k.Info=W.Info,k.Paging=W.Paging,k.RowLength=W.RowLength,k.SearchInput=W.SearchInput;export{k as Data,k as default};
|
|
1
|
+
import{b as r,c as y,d as G}from"../../chunk-C5N2D3ZX.js";import{Fragment as j,jsx as l,jsxs as x}from"react/jsx-runtime";import D,{UUID as Q,useStore as Y}from"jmini";import{useState as Z,useEffect as U}from"react";import{useRefresh as F}from"../../@utils";import{Box as B,Flex as M,FAI as N,Span as le,Column as oe}from"../../atoms";import{Row as E}from"../../mols";import{Button as H}from"../Button";import ee from"../Sheet";import P 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 C}from"../../@styles/componentClasses";const I={__memoryID:Q(),Header:t=>{var u,w;let{val_status:e,set_status:i,KeywordFilterRows:h}=r({},t),{order:s,filter:a}=e,[g,p]=s.current,S=[],c=[...e.head];if(e.checker){let n={top:!0,bottom:!e.rows.length,left:!0,right:!e.colLength,rowIndex:0,colIndex:0,isBody:!1,isHeader:!0},o=V(n),d=e.cellStylesCallback?e.cellStylesCallback(n):{};S.push(l(R.TH,y(r(r(r({fontWeight:"2.normal",position:"sticky",top:0,unitWidth:4,padding:0},e.cellStyles),o),d),{freeCSS:y(r(r({},(u=e.cellStyles)==null?void 0:u.freeCSS),d.freeCSS),{zIndex:2}),className:[C("Cell"),e.cellClassName].join(" "),children:l(B,{flexCenter:!0,children:l(P.Checker,{label:"",value:!1,onUpdateValidValue:f=>{let m=e.rows;m.forEach(L=>{L.checked=f}),i(y(r({},e),{rows:m}))}})})}),-1))}for(let n=0;n<e.colLength;n++){let o=c[n];if(!o)continue;let d=o.children||o.data,f=s.enabled&&s.column[n],m=a.enabled&&a.column[n],L=f?l(N,{fontSize:"1.mini",fontColor:n==g?"1.clear":"5.translucent",icon:n==g?p=="DESC"?se:ne:ie}):null,A=l(j,{});if(m){let _=h.map(O=>{var v;return(v=O[n])==null?void 0:v.data});_=[...new Set(_)].toASC();let T=a.current[n];if(T){let O=_.filter(b=>!T.includes(b)),v=[];_.forEach(b=>{b&&v.push({value:b,label:l(B,{flexSizing:"auto",children:b})})});let J="BUTTON-"+e.componentID+"-"+n,X=e.componentID+"-"+n,re={sheetID:X,parent:"#"+J,gravityPoint:23,content:x(M,{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(P.Checkbox,{icon:!0,value:O,display:"flex",gap:"2/3",override:"force",options:v,hideInput:!0,name:"DTFilter-col-"+n+"-table-"+e.componentID,onUpdateValidValue:b=>{let K=_.filter(ae=>!b.includes(ae)),$=r({},e);$.filter.current[n]=K,i($)}})}),x(E.Separate,{gap:"2/3",padding:"2/3",horizontalAlign:"right",children:[l(H.Border.S,{isRounded:!0,onClick:()=>{ee.close(X)},children:"\u9589\u3058\u308B"}),l(H.Prime.S,{color:"theme",isRounded:!0,ssEffectsOnActive:"shrink",onClick:()=>{let b=[];T.length||(b=_);let K=r({},e);K.filter.current[n]=b,i(K)},children:"\u5168\u9078\u629E"})]})]})};A=l(B,{className:C("FilterRegion"),children:l(H.Sub.S,{ssSphere:2.5,fontSize:"1.mini",className:C("Filtering_"+!!T.length),id:J,onClick:b=>{b.stopPropagation(),ee.open("custom",re)},children:l(N,{icon:ce})})})}}let z={top:!0,bottom:!e.rows.length,left:e.checker?!1:n==0,right:n==e.colLength-1,rowIndex:0,colIndex:n,isBody:!1,isHeader:!0},te=V(z),q=e.cellStylesCallback?e.cellStylesCallback(z):{};o=y(r(r(r(r({},e.cellStyles),te),o),q),{ssPushable:f,freeCSS:r(r(r({},(w=e.cellStyles)==null?void 0:w.freeCSS),q.freeCSS),o.freeCSS),className:[C("Cell"),e.cellClassName,o.className].join(" ")}),delete o.orderIndex,S.push(l(R.TH,y(r({fontWeight:"2.normal",position:"sticky",top:0},o),{freeCSS:r({zIndex:2},o.freeCSS),onClick:_=>{if(f){let T=r({},e),O=[n,g===n?p=="ASC"?"DESC":"ASC":s.priority];T.order.current=O,i(T),e.onOrderChanged&&e.onOrderChanged(O)}},children:x(M,{flexType:"row-r",flexWrap:!1,height:1,borderRadius:"inherit",flexCenter:!0,children:[A,x(M,{flexSizing:0,position:"relative",borderRadius:"inherit",gap:"1/2",flexWrap:!1,verticalAlign:"center",horizontalAlign:"center",children:[L,d]})]})}),n))}return l(R.Row,{className:[C("Row"),C("HeadRow")].join(" "),children:S})},Body:t=>{let{val_status:e,PageRows:i}=t,h=[];if(i.forEach((s,a)=>{var S;let g=[...s],p=[];if(e.checker){let c={top:a==0&&!e.head,bottom:a==i.length-1,left:!0,right:!e.colLength,rowIndex:a,colIndex:0,isBody:!0,isHeader:!1},u=V(c),w=e.cellStylesCallback?e.cellStylesCallback(c):{};p.push(l(R.TH,y(r(r(r({unitWidth:4,padding:0,borderRight:!0},e.cellStyles),u),w),{freeCSS:r(r({},(S=e.cellStyles)==null?void 0:S.freeCSS),w.freeCSS),className:[C("Cell"),e.cellClassName].join(" "),children:l(B,{flexCenter:!0,children:l(P.Checker,{label:"",value:s.checked,override:"force",onUpdateValidValue:n=>{let o=e.rows,d=o.findIndex(f=>D.is.equal(f.rowID,s.rowID));d!=-1&&(o[d].checked=n,t.set_status(f=>y(r({},f),{rows:o})))}})})}),-1))}g.forEach((c,u)=>{var A;if(!c)return;let L=c,{type:w="td"}=L,n=G(L,["type"]),o={top:a==0&&!e.head,bottom:a==i.length-1,left:e.checker?!1:u==0,right:u==e.colLength-1,rowIndex:a,colIndex:u,isBody:!0,isHeader:!1},d=V(o),f=e.cellStylesCallback?e.cellStylesCallback(o):{};n=y(r(r(r(r({},e.cellStyles),d),n),f),{freeCSS:r(r(r({},(A=e.cellStyles)==null?void 0:A.freeCSS),n.freeCSS),f.freeCSS),className:[C("Cell"),e.cellClassName,n.className].join(" ")}),delete n.orderIndex;let m=R[w=="td"?"TD":"TH"];p.push(l(m,r({},n),u))}),h.push(l(R.Row,{className:[C("Row"),C("BodyRow")].join(" "),children:p,onClick:c=>{e.onRowClick&&e.onRowClick(s.rowID,c)}},a))}),!i.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(j,{children:e.noRecords})),h.push(l(R.Row,{className:[C("Row"),C("BodyRow"),C("DataNotFound")].join(" "),children:l(R.TD,{colSpan:e.colLength,className:C("Cell"),children:s})},"dataNotFound"))}return l(j,{children:h})},Core:t=>{let{val_status:e,set_status:i}=t,{searchKeyword:h,filter:s,order:a,paging:g}=e,p=[...e.rows],S=[...e.rows],c=[...e.rows],u=[...e.rows];if(h&&(S=p.filter(o=>(o.__sys4SearchKey||"").match(new RegExp(String(h).escapeRegExChar(),"i"))?1:0),c=[...S],u=[...S]),s.enabled)for(let o=0;o<e.colLength;o++){let d=s.column[o],f=s.current[o];d&&f&&f.length&&(c=c.filter(m=>!f.includes(m[o].data)),u=[...c])}a.enabled&&(a.current[1]=="ASC"?c=c.toASC(a.current[0]+"[orderIndex]"):c=c.toDESC(a.current[0]+"[orderIndex]"),u=[...c]);{let{currentPageIndex:o,rowLength:d}=g;u=[...u].splice((o-1)*d,d)}let w=I.__memoryID+"_"+e.tableID,n={rows:{total:p.length,page:u.length,filtered:c.length},val_status:y(r({},e),{paging:y(r({},e.paging),{pageLength:Math.ceil(c.length/e.paging.rowLength)})}),set_status:i};return Y.update({[w]:{getRowData:()=>{let o=[...p];return a.enabled&&(a.current[1]=="ASC"?o=o.toASC(a.current[0]+"[orderIndex]"):o=o.toDESC(a.current[0]+"[orderIndex]")),o.forEach(d=>{d.currentPage=!1,d.filtered=!1}),u.forEach(d=>{let{rowID:f}=d;o.find(m=>D.is.equal(m.rowID,f)).currentPage=!0}),c.forEach(d=>{let{rowID:f}=d;o.find(m=>D.is.equal(m.rowID,f)).filtered=!0}),o}}}),U(()=>{F.release(e.tableID,n)}),l(B,{className:C("TableBase"),children:l(R.Table,{className:C("Table"),children:x(R.Body,{children:[l(I.Header,{val_status:e,set_status:i,KeywordFilterRows:S}),l(I.Body,{val_status:e,set_status:i,PageRows:u})]})})},h)},Propagations:{},DataLeveler:t=>{var e,i;return t=r({},t),t.filter=(e=t.filter)!=null?e:!1,t.filter=Array.from({length:t.colLength}).map((h,s)=>{var a;return D.is.boolean(t.filter)?t.filter:(a=t.filter[s])!=null?a:!1}),t.order=(i=t.order)!=null?i:!0,t.orderPriority=t.orderPriority||"ASC",t.order=Array.from({length:t.colLength}).map((h,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((h,s)=>{h.rowID=h.rowID||s;let a=[];h.forEach((g,p)=>{let{data:S,children:c,orderIndex:u}=g;g.orderIndex=D.is.exist(u)?String(u):String(S),g.children=c||String(S),a.push(String(g.data))}),h.__sys4SearchKey=a.join("/")}),l(I.StateManager,r({},t))},StateManager:t=>{let{colLength:e,checker:i=!1,searchKeyword:h="",filter:s,order:a,orderPriority:g="ASC",defaultOrder:p=[0,g],pageRowLength:S=30}=t,[c]=Z(Q()),u={tableID:t.tableID||c,componentID:c,colLength:e,checker:i,searchKeyword:h,filter:{enabled:s!==!1,column:s,current:Array.from({length:e},()=>[])},order:{enabled:a!==!1,column:a,current:p,priority:t.orderPriority},paging:{rowLength:S,pageLength:Math.ceil(t.rows.length/S),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},[w,n]=Z(u);const o=()=>{const d=new WeakSet;return(f,m)=>{if(typeof m=="object"&&m!==null){if(d.has(m))return"[Circular Reference]";if(f=="children")return"[React Element]";d.add(m)}return m}};return U(()=>{n(d=>y(r({},d),{rows:u.rows}))},[D.Stringify(u.rows,o())]),U(()=>{n(d=>y(r({},d),{head:u.head}))},[D.Stringify(u.head,o())]),l(I.Core,{val_status:w,set_status:n})}},ue={__memoryID:I.__memoryID,getRowData:t=>{let e=Y.get(I.__memoryID+"_"+t);if(e!=null&&e.getRowData)return e.getRowData()}},W={SearchInput:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:i,set_status:h}=e;return l(P.TextField,{label:"\u691C\u7D22...",clearButton:!0,padding:"2/3",paddingRight:3,rightIcon:l(P.RightIcon,{ssSphere:2,fontColor:"5.translucent",right:"2/3",children:l(N.Search,{})}),value:i.searchKeyword,onUpdateValidValue:s=>{t.onChange(s),D.interval.once(()=>{h(a=>y(r({},a),{paging:y(r({},a.paging),{currentPageIndex:1}),filter:y(r({},a.filter),{current:Array.from({length:a.colLength},()=>[])}),searchKeyword:s}))},200,"InputSearchTime")}})},Info:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:i,set_status:h}=e,s=e.rows.filtered.ratio(e.rows.total)||0;return x(M,{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:i,set_status:h}=e,s=[];for(let g=0;g<i.paging.pageLength;g++)s.push({value:g+1,label:(g+1).toString()});const a=g=>{let p=Math.min(Math.max(1,g),i.paging.pageLength),S=r({},i);S.paging.currentPageIndex=p,h(c=>y(r({},c),{paging:y(r({},c.paging),{currentPageIndex:p})}))};return x(E.Center,{children:[x(E.Center,{gap:"1/2",children:[l(P.Select,{label:"\u9805",freeCSS:{minWidth:12*3},emptySelect:!1,padding:["1/3","2/3"],rightIcon:!1,override:"force",value:i.paging.currentPageIndex,options:s,onUpdateValidValue:g=>{a(g)}}),"/ ",i.paging.pageLength]}),x(E.Right,{gap:"1/2",children:[l(H.Sub,{ssSphere:3,onClick:()=>{if(i.paging.currentPageIndex==1){a(i.paging.pageLength);return}a(i.paging.currentPageIndex-1)},children:l(N.ChevronLeft,{})}),l(H.Sub,{ssSphere:3,onClick:()=>{if(i.paging.currentPageIndex==i.paging.pageLength){a(1);return}a(i.paging.currentPageIndex+1)},children:l(N.ChevronRight,{})})]})]})},RowLength:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:i,set_status:h}=e,s=i.paging.rowLength,a=0,g=t.lengthSelect.map(p=>(a|=+(p==s),{value:p,label:p.toString()}));return a||g.push({value:s,label:s.toString()}),l(E.Center,{gap:"1/2",children:l(P.Select,{label:"\u4EF6\u6570",emptySelect:!1,rightIcon:!1,override:"force",padding:["1/3","2/3"],SelectorStyles:{freeCSS:{minWidth:12*9}},SelectorPosition:4,value:i.paging.rowLength,options:g.toASC("value"),onUpdateValidValue:p=>{h(S=>y(r({},S),{paging:{rowLength:Number(p),currentPageIndex:1,pageLength:Math.ceil(e.rows.filtered/Number(p))}}))}})})}},ge=t=>l(de,y(r({},t),{type:"data",JSXChildren:I.DataLeveler})),k=ge;k.__memoryID=I.__memoryID,k.getRowData=ue.getRowData,k.Info=W.Info,k.Paging=W.Paging,k.RowLength=W.RowLength,k.SearchInput=W.SearchInput;export{k as Data,k as default};
|
package/dist/fn/Tooltips.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e,
|
|
1
|
+
import{b as e,d as r}from"../chunk-C5N2D3ZX.js";import{jsx as d}from"react/jsx-runtime";import{UUID as n}from"jmini";import{Box as c}from"../atoms";import t from"./Sheet";const p={__memoryID:n(),open:o=>{let s=o,{tipsID:l=n(),tipsGroups:i=[]}=s,a=r(s,["tipsID","tipsGroups"]);t.open("custom",e({sheetID:l,sheetGroups:["tooltips",...i],closeAtAroundClick:!0,closeAtParentBlur:!0,closeAtEscapeKeyDown:!0,closeAtPageTransit:!0},a))},close:o=>{o&&t.close(o)},closeALL:()=>{t.closeGroup("tooltips")},Body:o=>d(c,e({padding:"1/2",backgroundColor:"dark",borderRadius:"2.tone.secondary",fontColor:"white",boxShadow:"0.normal"},o))};export{p as Tooltips,p as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amotify",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.168",
|
|
4
4
|
"description": "UI Component for React,NextJS,esbuild",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "run-p clean build:*",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@fortawesome/free-solid-svg-icons": "^6.6.0",
|
|
91
91
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
92
92
|
"dotenv": "^16.4.6",
|
|
93
|
-
"jmini": "^0.0.
|
|
93
|
+
"jmini": "^0.0.70",
|
|
94
94
|
"react": "^18.3.1"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|