amotify 0.2.307 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -135,15 +135,15 @@ There are a variety of ways in which web fonts impact performance`}
135
135
  </Column>
136
136
  <Column ssCardBox padding={ 1.5 }>
137
137
  <Box>[size:Mini]</Box>
138
- <Literal.Supplement>
138
+ <Literal.Mini>
139
139
  Copyright © Ministry of Finance Japan. All Rights Reserved.
140
- </Literal.Supplement>
140
+ </Literal.Mini>
141
141
  </Column>
142
142
  <Column ssCardBox padding={ 1.5 }>
143
143
  <Box>[size:Micro]</Box>
144
- <Literal.Supplement fontSize='0.xs'>
144
+ <Literal.Micro>
145
145
  Copyright © Ministry of Finance Japan. All Rights Reserved.
146
- </Literal.Supplement>
146
+ </Literal.Micro>
147
147
  </Column>
148
148
  </Column>
149
149
  </Box>
@@ -1547,7 +1547,7 @@ text5`}
1547
1547
  { value: 2,label: 'Option2' },
1548
1548
  { value: 3,label: 'Option3' },
1549
1549
  ] }
1550
- CustomIcon={ p => {
1550
+ onIconRender={ p => {
1551
1551
  return <Button.Normal.S
1552
1552
  ssPushable
1553
1553
  color='cloud'
@@ -2693,7 +2693,7 @@ const UserConfig = () => {
2693
2693
  } }
2694
2694
  />
2695
2695
  </Box>
2696
- <Literal.Supplement
2696
+ <Literal.Mini
2697
2697
  display='none'
2698
2698
  ssTextEllipsis
2699
2699
  xcss={ {
@@ -2701,7 +2701,7 @@ const UserConfig = () => {
2701
2701
  } }
2702
2702
  >
2703
2703
  { isSelected && <FAI.Check /> } { key.toCapital() }
2704
- </Literal.Supplement>
2704
+ </Literal.Mini>
2705
2705
  </Column>
2706
2706
  </Button.Clear>
2707
2707
  } ) }
@@ -1 +1 @@
1
- import{b as K,c as ne,e as V}from"../chunk-C5N2D3ZX.js";import{Fragment as Ce,jsx as o,jsxs as p}from"react/jsx-runtime";import v,{Filer as he,UUID as me,useStore as q}from"jmini";import{$$fromRoot as le}from"../@utils";import{useState as X,useEffect as ee}from"react";import{Box as A,FAI as H,Column as J,FlexMargin as pe}from"../atoms";import{Row as B,Literal as w}from"../mols";import{Button as W}from"./Button";import N from"./Sheet";import te from"./Loader";import ae from"./Input";import{faPalette as ue}from"@fortawesome/free-solid-svg-icons/faPalette";import{faBarsStaggered as fe}from"@fortawesome/free-solid-svg-icons/faBarsStaggered";import{faRotateLeft as ge}from"@fortawesome/free-solid-svg-icons/faRotateLeft";import{faRotateRight as de}from"@fortawesome/free-solid-svg-icons/faRotateRight";import{CropperClasses as O}from"../@styles/componentClasses";import j from"./Tooltips";class ve{constructor(e){this.set_scale=e.set_scale,this.val_file=e.val_file,this.develops=e.develops;{let[h,l]=v.isArray(e.use)&&e.use||e.use.split(":").map(r=>Number(r)),m=h/l;this.usage={w:h,h:l,aspect:m}}this.componentId=e.componentId;let c=e.canvas,t=e.picture.image;this.Canvas={elm:c,ctx:c.getContext("2d")};let{width:a,height:i}=t,n=a/i;this.Picture={elm:t,originDataUrl:t.src,aspect:n,revisedAspect:1,rotate:e.picture.rotate,grayScale:e.picture.grayScale,tone:e.picture.tone},this.scale={current:e.scale.default,default:e.scale.default,min:e.scale.min,max:e.scale.max},this.usage.aspect<this.Picture.aspect?this.scale.min=100/n*this.usage.aspect:this.scale.min=100*n/this.usage.aspect,this.pst={frame:{x:0,y:0,w:0,h:0,aspect:1},outImage:{x:0,y:0,w:0,h:0},imageX:a/2,imageY:i/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 e=this.Canvas.elm,c=this.Picture.elm,t=0,a=0;{if(this.usage.aspect==1){let s=e.width*.6666666666666666,C=e.height*(2/3);a=t=Math.min(s,C)}else this.usage.aspect>1?(t=e.width*.9,a=t/this.usage.aspect):(a=e.height*.9,t=a*this.usage.aspect);let r=.85;a>e.height*r&&(a=e.height*r,t=a*this.usage.aspect),t>e.width*r&&(t=e.width*r,a=t/this.usage.aspect)}let{width:i,height:n}=c,h=(e.width-t)/2,l=(e.height-a)/2,m=t/a;this.pst={frame:{x:h,y:l,w:t,h:a,aspect:m},outImage:{x:0,y:0,w:0,h:0},imageX:i/2,imageY:n/2,centerX:e.width/2,centerY:e.height/2}}dragEffect(e){let{eventType:c,x:t,y:a}=e;if(c=="start"){let i=this.Canvas.elm.position();this.dragEffectInfo={origin:{x:t,y:a},frameExpandRate:{x:this.Canvas.elm.width/i.width,y:this.Canvas.elm.height/i.height}}}else{let{origin:i,frameExpandRate:n}=this.dragEffectInfo,h=i.x-t,l=i.y-a,m=this.scale.current*this.Picture.revisedAspect/100,r=h/m*n.x,s=l/m*n.y;c=="move"?this.drawImage(this.pst.imageX+r,this.pst.imageY+s):c=="end"&&this.drawImage(this.pst.imageX+=r,this.pst.imageY+=s)}}pinchEffect(e){let{eventType:c,event:t}=e,{x:a,y:i}=v.getCursor(t.touches[0]),{x:n,y:h}=v.getCursor(t.touches[1]),l=n-a,m=h-i;if(c=="start")this.pinchEffectInfo.origin={x:l,y:m,scale:this.scale.current};else if(c=="move"){let{origin:r}=this.pinchEffectInfo,s=Math.sqrt(Math.pow(r.x,2)+Math.pow(r.y,2)),S=Math.sqrt(Math.pow(l,2)+Math.pow(m,2))/s,g=Number(r.scale*S);this.set_scale(g)}}updateScale(e){let c=e;c=Math.max(c,this.scale.min),c=Math.min(c,this.scale.max),this.scale.current=c,this.drawImage()}updateFilter(e){this.Picture.grayScale=e.grayScale,this.Picture.tone=e.tone,this.Picture.rotate=e.rotate,this.modifyImage()}modifyImage(){return V(this,null,function*(){let{grayScale:e,tone:c,rotate:t}=this.Picture;const a=document.createElement("canvas");let i=a.getContext("2d"),n=yield v.ImageLoader(this.Picture.originDataUrl),h=n.width,l=n.height;(t==90||t==270)&&(h=n.height,l=n.width),a.width=h,a.height=l,e&&(i.filter="grayscale("+e+"%)"),t&&(i.translate(h/2,l/2),i.rotate(t*Math.PI/180),v.isOneOf(t,90,270)?i.translate(-l/2,-h/2):i.translate(-h/2,-l/2)),i.drawImage(n,0,0,n.width,n.height);let m=i.getImageData(0,0,a.width,a.height),r=m.data;{e/=100;let g=[[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]][c],x=g[0]/255,d=g[1]/255,R=g[2]/255;for(let b=0;b<l;b++)for(let y=0;y<h;y++){var s=(b*h+y)*4;if(e){let D=.3*r[s]+.59*r[s+1]+.11*r[s+2];for(var C=0;C<3;C++){let E=r[s+C];r[s+C]=E+(D-E)*e}}r[s]*=x,r[s+1]*=d,r[s+2]*=R}}i.putImageData(m,0,0);let S=a.toDataURL("image/jpeg");{let g=yield v.ImageLoader(S),{width:x,height:d}=g,R=x/d;this.Picture=ne(K({},this.Picture),{elm:g,aspect:R,revisedAspect:this.pst.frame.aspect>R?this.pst.frame.w/x:this.pst.frame.h/d})}this.drawImage()})}drawImage(e,c){let{Canvas:{ctx:t,elm:a},pst:{frame:i}}=this;t.clearRect(0,0,this.Canvas.elm.width,this.Canvas.elm.height);let n=e||this.pst.imageX,h=c||this.pst.imageY;{let l=this.scale.current/100,m=this.Picture.revisedAspect*l,r=this.pst.centerX-n*m,s=this.pst.centerY-h*m,C=this.Picture.elm.width*m,S=this.Picture.elm.height*m,g=0,x=0;this.usage.aspect<this.Picture.aspect?(g=C,x=g/this.usage.aspect):(x=S,g=x*this.usage.aspect);{let d=this.pst.frame.x-(C-g)/2,R=this.pst.frame.x+this.pst.frame.w-(C+g)/2,b=this.pst.frame.y-(S-x)/2,y=this.pst.frame.y+this.pst.frame.h-(S+x)/2,D=0;r<R&&(D=r-R),r>d&&(D=r-d);let E=0;s<y&&(E=s-y),s>b&&(E=s-b),this.dragEffectInfo.origin.x+=D/2/this.dragEffectInfo.frameExpandRate.x,this.dragEffectInfo.origin.y+=E/2/this.dragEffectInfo.frameExpandRate.y,r=Math.min(Math.max(r,R),d),s=Math.min(Math.max(s,y),b)}this.pst.outImage={x:r,y:s,w:C,h:S};{let d=1;t.lineWidth=d,t.strokeStyle="#ffffff66",t.strokeRect(r+(C-g)/2-d,s+(S-x)/2-d,g+d*2,x+d*2)}t.drawImage(this.Picture.elm,0,0,this.Picture.elm.width,this.Picture.elm.height,r,s,C,S)}{if(this.usage.aspect==1){t.fillStyle="rgba( 20,24,20,.5 )",t.beginPath();let l=a.width/3*2,m=a.height/3*2,r=Math.min(l,m),s=Math.max(l,m);t.arc(a.width/2,a.height/2,s*1.41,0,Math.PI*2,!0),t.arc(a.width/2,a.height/2,r/2,0,Math.PI*2,!1),t.closePath(),t.fill()}else t.fillStyle="rgba( 20,24,20,.5 )";{let m=v(document.body).getStyleProperty("--color-theme-hsl"),r=2;t.lineWidth=r,t.strokeStyle=`hsla( ${m},1 )`,t.strokeRect(i.x-r,i.y-r,i.w+r*2,i.h+r*2)}}}export(){return V(this,null,function*(){let{Canvas:e,develops:c,Picture:t,pst:{outImage:a,frame:i}}=this,n=a.w/t.elm.width,h=a.h/t.elm.height,l=(i.x-a.x)/n,m=i.w/n,r=(i.y-a.y)/h,s=i.h/h,C=Array.from({length:c.length}),S="image/jpeg";for(let g=0;g<c.length;g++){let{size:x,maxSize:d}=c[g];d=d||{S:1024*20,R:1024*100,L:1024*350}[x];let R={S:140,R:600,L:1200}[x],b=document.createElement("canvas");b.width=m,b.height=s;let y=document.createElement("canvas");y.width=R,y.height=R/this.usage.aspect;let D=b.getContext("2d");if(!D)return;let E=y.getContext("2d");if(!E)return;D.clearRect(0,0,b.width,b.height),D.drawImage(this.Picture.elm,l,r,m,s,0,0,m,s),E.fillStyle="black",E.drawImage(b,0,0,b.width,b.height,0,0,y.width,y.height);let Z=y.toDataURL(S),z=yield Z.toBlob(S);if(!z)return;if(z.size>=d){let ie=d/z.size;if(Z=y.toDataURL(S,ie*.92),z=yield Z.toBlob(S),!z)return}let re=new File([z],this.val_file.name,{type:S});C[g]=re}return C})}}const se={Core:u=>{let{val_file:e,options:c,finishedCallback:t,abortCallback:a}=u,{use:i,develops:n=[]}=c,[h]=X(me());const l={scale:{default:120,min:50,max:300},rotate:0,grayScale:0,tone:0};let m=2048*2048,r=1024,[s,C]=X("init"),[S,g]=X(""),[x,d]=X(l.scale.default),[R,b]=X(l.rotate),[y,D]=X(l.grayScale),[E,Z]=X(l.tone),[z,re]=X(-1),[ie,ce]=X(-1);return ee(()=>{let f="CropperResize";return v(window).onEvent("resize",()=>{v.interval.once(()=>{var $;let I=le("#Canvas-"+h)[0];if(!I)return;let P=($=q.get(h))==null?void 0:$.Instance;if(!P)return;let F=I.position(),U=F.width/F.height,Y=r,k=Y/U;if(Y*k>m){let G=Y*k/m;Y=Math.floor(Y/Math.sqrt(G)),k=Math.floor(k/Math.sqrt(G))}I.width=r,I.height=k;let{width:L,height:Q}=I;P.pst.centerX=L/2,P.pst.centerY=Q/2,P.frameSizing(),P.modifyImage()},250,"CropperResize")},{eventID:f}),()=>{v(window).removeEvent(f)}},[]),ee(()=>{q.set({[h]:{}}),V(void 0,null,function*(){try{let f=le("#Canvas-"+h)[0];if(!f)return;let I=f.position(),P=I.width/I.height,F=r,U=F/P;if(F*U>m){let _=F*U/m;F=Math.floor(F/Math.sqrt(_)),U=Math.floor(U/Math.sqrt(_))}f.width=F,f.height=U;let Y=he(e),k=yield v.ImageLoader(yield Y.toObjectURL());re(k.width),ce(k.height);let L=new ve({set_scale:d,val_file:e,develops:n,use:i,scale:l.scale,componentId:h,canvas:f,picture:{image:k,grayScale:l.grayScale,tone:l.tone,rotate:l.rotate}});q.set({[h]:{Instance:L}});const Q=function(_){if(_.preventDefault(),_.touches&&_.touches.length>1)L.pinchEffect({eventType:"start",event:_}),v(document).onEvent("touchmove",M=>{M.preventDefault(),L.pinchEffect({eventType:"move",event:M})},{eventID:"CropperEffectMove",passive:!1}).onEvent("touchend",G,{eventID:"CropperEffectEnd",passive:!1});else{L.dragEffect(K({eventType:"start"},v.getCursor(_)));let{type:M}=_;v(document).onEvent(M=="touchstart"?"touchmove":"mousemove",T=>{$("move",T)},{eventID:"CropperEffectMove",passive:!1}).onEvent(M=="touchstart"?"touchend":"mouseup",T=>{$("end",T),G(T)},{eventID:"CropperEffectEnd",passive:!1})}},$=function(_,M){M.preventDefault(),L.dragEffect(K({eventType:_},v.getCursor(M)))},G=function(_){_.preventDefault(),v(document).removeEvent(["CropperEffectMove","CropperEffectEnd"])};v(f).removeEvent(["CropperMouseWheel","CropperTouchStart","CropperMouseDown"]).onEvent("wheel",_=>{_.preventDefault();let M=Number(_.wheelDelta*.04),T=L.scale.current+M;T=Math.max(T,L.scale.min),T=Math.min(T,L.scale.max),d(T)},{eventID:"CropperMouseWheel",passive:!1}).onEvent("touchstart",Q,{eventID:"CropperTouchStart",passive:!1}).onEvent("mousedown",Q,{eventID:"CropperMouseDown",passive:!1}),yield v.pending(1e3),C("ok")}catch(f){C("error"),g((f==null?void 0:f.message)||v.Stringify(f)),console.error(f)}})},[e.id]),ee(()=>{var I;let f=(I=q.get(h))==null?void 0:I.Instance;f&&f.updateScale(x)},[x]),ee(()=>{var I;let f=(I=q.get(h))==null?void 0:I.Instance;f&&f.updateFilter({grayScale:y,tone:E,rotate:R})},[y,E,R]),o(N.Body,{borderRadius:0,height:"viewHeight",width:"viewWidth",children:p(J,{className:[O("Wrap"),O("Use_"+i)].join(" "),gap:0,height:1,position:"relative",overflow:"hidden",borderRadius:"inherit",children:[p(A,{position:"absolute",ssZIndex:2,top:"50%",left:"50%",flexCenter:!0,xcss:{transform:"translate( -50%,-50% )",pointerEvents:"none"},children:[s=="init"&&o(te.Theme.XL,{showInitial:!0}),s=="error"&&p(w.Supplement,{fontColor:"nega",children:["\u753B\u50CF\u306E\u8AAD\u307F\u8FBC\u307F\u306B\u5931\u6557\u3057\u307E\u3057\u305F",o(w.Description,{children:S})]})]}),p(A,{flexSizing:0,overflow:"hidden",ssZIndex:1,flexCenter:!0,paddingBottom:6,xcss:{backgroundColor:"#000f0f"},children:[o("canvas",{style:{width:"100%",height:"100%"},width:r,height:r,className:O("Canvas"),id:"Canvas-"+h}),o(w.Supplement,{position:"absolute",bottom:1,left:1,right:1,ssCardBox:"plain",boxShadow:"0.max",padding:1,backgroundColor:"layer.0.opa.few",xcss:{backdropFilter:"blur(6px)"},children:p(J,{gap:"1/2",children:[p(B.Left,{gap:"1/2",flexWrap:!0,fontColor:"white",fontSize:"0.xs",fontHeight:1.2,children:[p(w,{children:["[",e.type,"]"]}),o(w,{children:e.name}),p(w,{children:[z,"px x ",ie,"px"]}),p(w,{children:["[",e.size.rank(),"B]"]})]}),p(B.Left,{gap:"1/2",verticalAlign:"unset",flexWrap:!0,children:[o(se.SettingRegion,{DefaultOptions:l,val_scale:x,set_scale:d,val_tone:E,set_tone:Z,val_grayScale:y,set_grayScale:D,val_rotate:R,set_rotate:b}),o(pe,{}),o(W.Border.S,{onClick:()=>{a()},children:"\u9589\u3058\u308B"}),o(W.Prime.S,{boxShadow:"3.remark",onClick:()=>V(void 0,null,function*(){var P;let f=(P=q.get(h))==null?void 0:P.Instance;if(!f)return;te.fn.mini.active("CropperExportation");let I=yield f.export();setTimeout(()=>{te.fn.mini.stop("CropperExportation"),t(I)},1e3)}),children:p(B.Center,{gap:"1/2",children:[o(te.White.R,{loaderID:"CropperExportation"}),"\u6C7A\u5B9A"]})})]})]})})]})]})})},SettingRegion:u=>{let e=["","\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"],c=t=>e[t]||"\u306A\u3057";return p(Ce,{children:[p(B.Center,{gap:"1/6",children:[p(W.Border.S,{flexCenter:!0,gap:"1/4",border:"unset",borderTopRightRadius:0,borderBottomRightRadius:0,onClick:()=>{let t=u.val_rotate-90;t<0&&(t+=360),u.set_rotate(t)},children:[o(w,{children:"90\xB0"}),o(H,{icon:ge,fontColor:"4.thin"})]}),p(W.Border.S,{flexCenter:!0,gap:"1/4",border:"unset",borderTopLeftRadius:0,borderBottomLeftRadius:0,onClick:()=>{u.set_rotate((u.val_rotate+90)%360)},children:[o(H,{icon:de,fontColor:"4.thin"}),o(w,{children:"90\xB0"})]})]}),p(W.Border.S,{flexCenter:!0,gap:"1/2",border:"unset",onClick:t=>{let a="CropperZoomEdit";j.open({tipsID:a,gravityPoint:3,event:t,closeAtParentBlur:!1,xcss:{minWidth:12*26},content:o(N.Body,{children:p(J,{padding:1.5,children:[p(B.Separate,{children:[o(w.Paragraph,{children:p(B.Center,{gap:"1/2",children:[o(H.Search,{fontColor:"5.translucent"}),"Zoom"]})}),o(W.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{j.close(a)},children:o(H.X,{})})]}),o(A,{borderBottom:!0,opacity:"low"}),o(ae.Slider,{override:"force",value:u.val_scale-u.DefaultOptions.scale.min,min:u.DefaultOptions.scale.min-100,max:u.DefaultOptions.scale.max-100,step:25,onUpdateValidValue:(i,n)=>{v.interval.once(()=>{u.set_scale(i+100)},250,"Cropper.UpdateScale")},onLegendRender:i=>"x"+Math.round(100+i)/100})]})})})},children:[o(w.Supplement,{fontSize:"0.xs",fontColor:"4.thin",children:"Zoom"}),p(w,{unitWidth:4,children:[u.val_scale.rate(1,0),"%"]})]}),p(W.Border.S,{flexCenter:!0,gap:"1/2",border:"unset",onClick:t=>{let a="CropperGrayScaleEdit";j.open({tipsID:a,gravityPoint:3,event:t,closeAtParentBlur:!1,xcss:{minWidth:12*26},content:o(N.Body,{children:p(J,{padding:1.5,children:[p(B.Separate,{children:[o(w.Paragraph,{children:p(B.Center,{gap:"1/2",children:[o(H,{icon:ue,fontColor:"5.translucent"}),"Gray Scale"]})}),o(W.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{j.close(a)},children:o(H.X,{})})]}),o(A,{borderBottom:!0,opacity:"low"}),o(ae.Slider,{value:u.val_grayScale,min:0,max:100,step:10,onUpdateValidValue:i=>{v.interval.once(()=>{u.set_grayScale(i)},250,"Cropper.GrayScale")},onLegendRender:i=>i+"%"})]})})})},children:[o(w.Supplement,{fontSize:"0.xs",fontColor:"4.thin",children:"GrayScale"}),p(w,{children:[u.val_grayScale.rate(1,0),"%"]})]}),p(W.Border.S,{flexCenter:!0,gap:"1/2",border:"unset",onClick:t=>{let a="CropperToneEdit";j.open({tipsID:a,gravityPoint:3,event:t,closeAtParentBlur:!1,xcss:{minWidth:12*26,maxWidth:12*24},content:()=>{let i=[];for(let n=1;n<=10;n++)i.push({value:n,label:p(B.Left,{gap:"1/3",children:[o(A,{ssSphere:1,className:[O("ToneBall"),O("ToneBall_"+n)].join(" ")}),o(A,{textAlign:"left",flexSizing:0,children:c(n)})]})});return o(N.Body,{children:p(J,{padding:1.5,children:[p(B.Separate,{children:[o(w.Paragraph,{children:p(B.Center,{gap:"1/2",children:[o(H,{icon:fe,fontColor:"5.translucent"}),"Tone"]})}),o(W.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{j.close(a)},children:o(H.X,{})})]}),o(A,{borderBottom:!0,opacity:"low"}),o(ae.Radio.Normal,{value:u.val_tone,gap:"1/2",cellStyles:{fontColor:"3.blur"},options:[{value:0,label:o(A,{flexSizing:0,textAlign:"center",children:"\u306A\u3057"})},...i],onUpdateValidValue:n=>{u.set_tone(n)}})]})})}})},children:[o(w.Supplement,{fontSize:"0.xs",fontColor:"4.thin",children:"Tone"}),o(A,{boxShadow:"2.remark",ssSphere:1,className:[O("ToneBall"),O("ToneBall_"+u.val_tone)].join(" ")}),c(u.val_tone)]})]})}},oe={openDialogNEdit:u=>{ae.Filer.fn.openDialog({accept:"image",multiple:!1,onChange:e=>{oe.openEditor(K({imageFile:e[0]},u))}})},openEditor:u=>V(void 0,null,function*(){let e="CropperImage";N.open("middleCenter",{sheetID:e,size:"MAX",padding:0,margin:0,xcss:{maxWidth:"100%"},content:o(se.Core,{val_file:u.imageFile,options:u,finishedCallback:c=>{N.close(e),u.onProcessFinished(c)},abortCallback:()=>{N.close(e)}}),closeAtEscapeKeyDown:!1})})};export{oe as Cropper,oe as default};
1
+ import{b as K,c as ne,e as V}from"../chunk-C5N2D3ZX.js";import{Fragment as Ce,jsx as o,jsxs as p}from"react/jsx-runtime";import v,{Filer as he,UUID as me,useStore as q}from"jmini";import{$$fromRoot as le}from"../@utils";import{useState as X,useEffect as ee}from"react";import{Box as A,FAI as z,Column as J,FlexMargin as pe}from"../atoms";import{Row as M,Literal as w}from"../mols";import{Button as W}from"./Button";import N from"./Sheet";import te from"./Loader";import ae from"./Input";import{faPalette as ue}from"@fortawesome/free-solid-svg-icons/faPalette";import{faBarsStaggered as ge}from"@fortawesome/free-solid-svg-icons/faBarsStaggered";import{faRotateLeft as fe}from"@fortawesome/free-solid-svg-icons/faRotateLeft";import{faRotateRight as de}from"@fortawesome/free-solid-svg-icons/faRotateRight";import{CropperClasses as O}from"../@styles/componentClasses";import j from"./Tooltips";class ve{constructor(e){this.set_scale=e.set_scale,this.val_file=e.val_file,this.develops=e.develops;{let[h,l]=v.isArray(e.use)&&e.use||e.use.split(":").map(r=>Number(r)),m=h/l;this.usage={w:h,h:l,aspect:m}}this.componentId=e.componentId;let c=e.canvas,t=e.picture.image;this.Canvas={elm:c,ctx:c.getContext("2d")};let{width:a,height:i}=t,n=a/i;this.Picture={elm:t,originDataUrl:t.src,aspect:n,revisedAspect:1,rotate:e.picture.rotate,grayScale:e.picture.grayScale,tone:e.picture.tone},this.scale={current:e.scale.default,default:e.scale.default,min:e.scale.min,max:e.scale.max},this.usage.aspect<this.Picture.aspect?this.scale.min=100/n*this.usage.aspect:this.scale.min=100*n/this.usage.aspect,this.pst={frame:{x:0,y:0,w:0,h:0,aspect:1},outImage:{x:0,y:0,w:0,h:0},imageX:a/2,imageY:i/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 e=this.Canvas.elm,c=this.Picture.elm,t=0,a=0;{if(this.usage.aspect==1){let s=e.width*.6666666666666666,C=e.height*(2/3);a=t=Math.min(s,C)}else this.usage.aspect>1?(t=e.width*.9,a=t/this.usage.aspect):(a=e.height*.9,t=a*this.usage.aspect);let r=.85;a>e.height*r&&(a=e.height*r,t=a*this.usage.aspect),t>e.width*r&&(t=e.width*r,a=t/this.usage.aspect)}let{width:i,height:n}=c,h=(e.width-t)/2,l=(e.height-a)/2,m=t/a;this.pst={frame:{x:h,y:l,w:t,h:a,aspect:m},outImage:{x:0,y:0,w:0,h:0},imageX:i/2,imageY:n/2,centerX:e.width/2,centerY:e.height/2}}dragEffect(e){let{eventType:c,x:t,y:a}=e;if(c=="start"){let i=this.Canvas.elm.position();this.dragEffectInfo={origin:{x:t,y:a},frameExpandRate:{x:this.Canvas.elm.width/i.width,y:this.Canvas.elm.height/i.height}}}else{let{origin:i,frameExpandRate:n}=this.dragEffectInfo,h=i.x-t,l=i.y-a,m=this.scale.current*this.Picture.revisedAspect/100,r=h/m*n.x,s=l/m*n.y;c=="move"?this.drawImage(this.pst.imageX+r,this.pst.imageY+s):c=="end"&&this.drawImage(this.pst.imageX+=r,this.pst.imageY+=s)}}pinchEffect(e){let{eventType:c,event:t}=e,{x:a,y:i}=v.getCursor(t.touches[0]),{x:n,y:h}=v.getCursor(t.touches[1]),l=n-a,m=h-i;if(c=="start")this.pinchEffectInfo.origin={x:l,y:m,scale:this.scale.current};else if(c=="move"){let{origin:r}=this.pinchEffectInfo,s=Math.sqrt(Math.pow(r.x,2)+Math.pow(r.y,2)),x=Math.sqrt(Math.pow(l,2)+Math.pow(m,2))/s,f=Number(r.scale*x);this.set_scale(f)}}updateScale(e){let c=e;c=Math.max(c,this.scale.min),c=Math.min(c,this.scale.max),this.scale.current=c,this.drawImage()}updateFilter(e){this.Picture.grayScale=e.grayScale,this.Picture.tone=e.tone,this.Picture.rotate=e.rotate,this.modifyImage()}modifyImage(){return V(this,null,function*(){let{grayScale:e,tone:c,rotate:t}=this.Picture;const a=document.createElement("canvas");let i=a.getContext("2d"),n=yield v.ImageLoader(this.Picture.originDataUrl),h=n.width,l=n.height;(t==90||t==270)&&(h=n.height,l=n.width),a.width=h,a.height=l,e&&(i.filter="grayscale("+e+"%)"),t&&(i.translate(h/2,l/2),i.rotate(t*Math.PI/180),v.isOneOf(t,90,270)?i.translate(-l/2,-h/2):i.translate(-h/2,-l/2)),i.drawImage(n,0,0,n.width,n.height);let m=i.getImageData(0,0,a.width,a.height),r=m.data;{e/=100;let f=[[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]][c],y=f[0]/255,d=f[1]/255,R=f[2]/255;for(let S=0;S<l;S++)for(let b=0;b<h;b++){var s=(S*h+b)*4;if(e){let D=.3*r[s]+.59*r[s+1]+.11*r[s+2];for(var C=0;C<3;C++){let E=r[s+C];r[s+C]=E+(D-E)*e}}r[s]*=y,r[s+1]*=d,r[s+2]*=R}}i.putImageData(m,0,0);let x=a.toDataURL("image/jpeg");{let f=yield v.ImageLoader(x),{width:y,height:d}=f,R=y/d;this.Picture=ne(K({},this.Picture),{elm:f,aspect:R,revisedAspect:this.pst.frame.aspect>R?this.pst.frame.w/y:this.pst.frame.h/d})}this.drawImage()})}drawImage(e,c){let{Canvas:{ctx:t,elm:a},pst:{frame:i}}=this;t.clearRect(0,0,this.Canvas.elm.width,this.Canvas.elm.height);let n=e||this.pst.imageX,h=c||this.pst.imageY;{let l=this.scale.current/100,m=this.Picture.revisedAspect*l,r=this.pst.centerX-n*m,s=this.pst.centerY-h*m,C=this.Picture.elm.width*m,x=this.Picture.elm.height*m,f=0,y=0;this.usage.aspect<this.Picture.aspect?(f=C,y=f/this.usage.aspect):(y=x,f=y*this.usage.aspect);{let d=this.pst.frame.x-(C-f)/2,R=this.pst.frame.x+this.pst.frame.w-(C+f)/2,S=this.pst.frame.y-(x-y)/2,b=this.pst.frame.y+this.pst.frame.h-(x+y)/2,D=0;r<R&&(D=r-R),r>d&&(D=r-d);let E=0;s<b&&(E=s-b),s>S&&(E=s-S),this.dragEffectInfo.origin.x+=D/2/this.dragEffectInfo.frameExpandRate.x,this.dragEffectInfo.origin.y+=E/2/this.dragEffectInfo.frameExpandRate.y,r=Math.min(Math.max(r,R),d),s=Math.min(Math.max(s,b),S)}this.pst.outImage={x:r,y:s,w:C,h:x};{let d=1;t.lineWidth=d,t.strokeStyle="#ffffff66",t.strokeRect(r+(C-f)/2-d,s+(x-y)/2-d,f+d*2,y+d*2)}t.drawImage(this.Picture.elm,0,0,this.Picture.elm.width,this.Picture.elm.height,r,s,C,x)}{if(this.usage.aspect==1){t.fillStyle="rgba( 20,24,20,.5 )",t.beginPath();let l=a.width/3*2,m=a.height/3*2,r=Math.min(l,m),s=Math.max(l,m);t.arc(a.width/2,a.height/2,s*1.41,0,Math.PI*2,!0),t.arc(a.width/2,a.height/2,r/2,0,Math.PI*2,!1),t.closePath(),t.fill()}else t.fillStyle="rgba( 20,24,20,.5 )";{let m=v(document.body).getStyleProperty("--color-theme-hsl"),r=2;t.lineWidth=r,t.strokeStyle=`hsla( ${m},1 )`,t.strokeRect(i.x-r,i.y-r,i.w+r*2,i.h+r*2)}}}export(){return V(this,null,function*(){let{Canvas:e,develops:c,Picture:t,pst:{outImage:a,frame:i}}=this,n=a.w/t.elm.width,h=a.h/t.elm.height,l=(i.x-a.x)/n,m=i.w/n,r=(i.y-a.y)/h,s=i.h/h,C=Array.from({length:c.length}),x="image/jpeg";for(let f=0;f<c.length;f++){let{size:y,maxSize:d}=c[f];d=d||{S:1024*20,R:1024*100,L:1024*350}[y];let R={S:140,R:600,L:1200}[y],S=document.createElement("canvas");S.width=m,S.height=s;let b=document.createElement("canvas");b.width=R,b.height=R/this.usage.aspect;let D=S.getContext("2d");if(!D)return;let E=b.getContext("2d");if(!E)return;D.clearRect(0,0,S.width,S.height),D.drawImage(this.Picture.elm,l,r,m,s,0,0,m,s),E.fillStyle="black",E.drawImage(S,0,0,S.width,S.height,0,0,b.width,b.height);let Z=b.toDataURL(x),H=yield Z.toBlob(x);if(!H)return;if(H.size>=d){let ie=d/H.size;if(Z=b.toDataURL(x,ie*.92),H=yield Z.toBlob(x),!H)return}let re=new File([H],this.val_file.name,{type:x});C[f]=re}return C})}}const se={Core:u=>{let{val_file:e,options:c,finishedCallback:t,abortCallback:a}=u,{use:i,develops:n=[]}=c,[h]=X(me());const l={scale:{default:120,min:50,max:300},rotate:0,grayScale:0,tone:0};let m=2048*2048,r=1024,[s,C]=X("init"),[x,f]=X(""),[y,d]=X(l.scale.default),[R,S]=X(l.rotate),[b,D]=X(l.grayScale),[E,Z]=X(l.tone),[H,re]=X(-1),[ie,ce]=X(-1);return ee(()=>{let g="CropperResize";return v(window).onEvent("resize",()=>{v.interval.once(()=>{var $;let I=le("#Canvas-"+h)[0];if(!I)return;let B=($=q.get(h))==null?void 0:$.Instance;if(!B)return;let F=I.position(),U=F.width/F.height,Y=r,k=Y/U;if(Y*k>m){let G=Y*k/m;Y=Math.floor(Y/Math.sqrt(G)),k=Math.floor(k/Math.sqrt(G))}I.width=r,I.height=k;let{width:P,height:Q}=I;B.pst.centerX=P/2,B.pst.centerY=Q/2,B.frameSizing(),B.modifyImage()},250,"CropperResize")},{eventID:g}),()=>{v(window).removeEvent(g)}},[]),ee(()=>{q.set({[h]:{}}),V(void 0,null,function*(){try{let g=le("#Canvas-"+h)[0];if(!g)return;let I=g.position(),B=I.width/I.height,F=r,U=F/B;if(F*U>m){let _=F*U/m;F=Math.floor(F/Math.sqrt(_)),U=Math.floor(U/Math.sqrt(_))}g.width=F,g.height=U;let Y=he(e),k=yield v.ImageLoader(yield Y.toObjectURL());re(k.width),ce(k.height);let P=new ve({set_scale:d,val_file:e,develops:n,use:i,scale:l.scale,componentId:h,canvas:g,picture:{image:k,grayScale:l.grayScale,tone:l.tone,rotate:l.rotate}});q.set({[h]:{Instance:P}});const Q=function(_){if(_.preventDefault(),_.touches&&_.touches.length>1)P.pinchEffect({eventType:"start",event:_}),v(document).onEvent("touchmove",L=>{L.preventDefault(),P.pinchEffect({eventType:"move",event:L})},{eventID:"CropperEffectMove",passive:!1}).onEvent("touchend",G,{eventID:"CropperEffectEnd",passive:!1});else{P.dragEffect(K({eventType:"start"},v.getCursor(_)));let{type:L}=_;v(document).onEvent(L=="touchstart"?"touchmove":"mousemove",T=>{$("move",T)},{eventID:"CropperEffectMove",passive:!1}).onEvent(L=="touchstart"?"touchend":"mouseup",T=>{$("end",T),G(T)},{eventID:"CropperEffectEnd",passive:!1})}},$=function(_,L){L.preventDefault(),P.dragEffect(K({eventType:_},v.getCursor(L)))},G=function(_){_.preventDefault(),v(document).removeEvent(["CropperEffectMove","CropperEffectEnd"])};v(g).removeEvent(["CropperMouseWheel","CropperTouchStart","CropperMouseDown"]).onEvent("wheel",_=>{_.preventDefault();let L=Number(_.wheelDelta*.04),T=P.scale.current+L;T=Math.max(T,P.scale.min),T=Math.min(T,P.scale.max),d(T)},{eventID:"CropperMouseWheel",passive:!1}).onEvent("touchstart",Q,{eventID:"CropperTouchStart",passive:!1}).onEvent("mousedown",Q,{eventID:"CropperMouseDown",passive:!1}),yield v.pending(1e3),C("ok")}catch(g){C("error"),f((g==null?void 0:g.message)||v.Stringify(g)),console.error(g)}})},[e.id]),ee(()=>{var I;let g=(I=q.get(h))==null?void 0:I.Instance;g&&g.updateScale(y)},[y]),ee(()=>{var I;let g=(I=q.get(h))==null?void 0:I.Instance;g&&g.updateFilter({grayScale:b,tone:E,rotate:R})},[b,E,R]),o(N.Body,{borderRadius:0,height:"viewHeight",width:"viewWidth",children:p(J,{className:[O("Wrap"),O("Use_"+i)].join(" "),gap:0,height:1,position:"relative",overflow:"hidden",borderRadius:"inherit",children:[p(A,{position:"absolute",ssZIndex:2,top:"50%",left:"50%",flexCenter:!0,xcss:{transform:"translate( -50%,-50% )",pointerEvents:"none"},children:[s=="init"&&o(te.Theme.XL,{showInitial:!0}),s=="error"&&p(w.Mini,{fontColor:"nega",children:["\u753B\u50CF\u306E\u8AAD\u307F\u8FBC\u307F\u306B\u5931\u6557\u3057\u307E\u3057\u305F",o(w.Description,{children:x})]})]}),p(A,{flexSizing:0,overflow:"hidden",ssZIndex:1,flexCenter:!0,paddingBottom:6,xcss:{backgroundColor:"#000f0f"},children:[o("canvas",{style:{width:"100%",height:"100%"},width:r,height:r,className:O("Canvas"),id:"Canvas-"+h}),o(w.Mini,{position:"absolute",bottom:1,left:1,right:1,ssCardBox:"plain",boxShadow:"0.max",padding:1,backgroundColor:"layer.0.opa.few",xcss:{backdropFilter:"blur(6px)"},children:p(J,{gap:"1/2",children:[p(M.Left,{gap:"1/2",flexWrap:!0,fontColor:"white",fontSize:"0.xs",fontHeight:1.2,children:[p(w,{children:["[",e.type,"]"]}),o(w,{children:e.name}),p(w,{children:[H,"px x ",ie,"px"]}),p(w,{children:["[",e.size.rank(),"B]"]})]}),p(M.Left,{gap:"1/2",verticalAlign:"unset",flexWrap:!0,children:[o(se.SettingRegion,{DefaultOptions:l,val_scale:y,set_scale:d,val_tone:E,set_tone:Z,val_grayScale:b,set_grayScale:D,val_rotate:R,set_rotate:S}),o(pe,{}),o(W.Border.S,{onClick:()=>{a()},children:"\u9589\u3058\u308B"}),o(W.Prime.S,{boxShadow:"3.remark",onClick:()=>V(void 0,null,function*(){var B;let g=(B=q.get(h))==null?void 0:B.Instance;if(!g)return;te.fn.mini.active("CropperExportation");let I=yield g.export();setTimeout(()=>{te.fn.mini.stop("CropperExportation"),t(I)},1e3)}),children:p(M.Center,{gap:"1/2",children:[o(te.White.R,{loaderID:"CropperExportation"}),"\u6C7A\u5B9A"]})})]})]})})]})]})})},SettingRegion:u=>{let e=["","\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"],c=t=>e[t]||"\u306A\u3057";return p(Ce,{children:[p(M.Center,{gap:"1/6",children:[p(W.Border.S,{flexCenter:!0,gap:"1/4",border:"unset",borderTopRightRadius:0,borderBottomRightRadius:0,onClick:()=>{let t=u.val_rotate-90;t<0&&(t+=360),u.set_rotate(t)},children:[o(w,{children:"90\xB0"}),o(z,{icon:fe,fontColor:"4.thin"})]}),p(W.Border.S,{flexCenter:!0,gap:"1/4",border:"unset",borderTopLeftRadius:0,borderBottomLeftRadius:0,onClick:()=>{u.set_rotate((u.val_rotate+90)%360)},children:[o(z,{icon:de,fontColor:"4.thin"}),o(w,{children:"90\xB0"})]})]}),p(W.Border.S,{flexCenter:!0,gap:"1/2",border:"unset",onClick:t=>{let a="CropperZoomEdit";j.open({tipsID:a,gravityPoint:3,event:t,closeAtParentBlur:!1,xcss:{minWidth:12*26},content:o(N.Body,{children:p(J,{padding:1.5,children:[p(M.Separate,{children:[o(w.Paragraph,{children:p(M.Center,{gap:"1/2",children:[o(z.Search,{fontColor:"5.translucent"}),"Zoom"]})}),o(W.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{j.close(a)},children:o(z.X,{})})]}),o(A,{borderBottom:!0,opacity:"low"}),o(ae.Slider,{override:"force",value:u.val_scale-u.DefaultOptions.scale.min,min:u.DefaultOptions.scale.min-100,max:u.DefaultOptions.scale.max-100,step:25,onUpdateValidValue:(i,n)=>{v.interval.once(()=>{u.set_scale(i+100)},250,"Cropper.UpdateScale")},onLegendRender:i=>"x"+Math.round(100+i)/100})]})})})},children:[o(w.Micro,{fontColor:"4.thin",children:"Zoom"}),p(w,{unitWidth:4,children:[u.val_scale.rate(1,0),"%"]})]}),p(W.Border.S,{flexCenter:!0,gap:"1/2",border:"unset",onClick:t=>{let a="CropperGrayScaleEdit";j.open({tipsID:a,gravityPoint:3,event:t,closeAtParentBlur:!1,xcss:{minWidth:12*26},content:o(N.Body,{children:p(J,{padding:1.5,children:[p(M.Separate,{children:[o(w.Paragraph,{children:p(M.Center,{gap:"1/2",children:[o(z,{icon:ue,fontColor:"5.translucent"}),"Gray Scale"]})}),o(W.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{j.close(a)},children:o(z.X,{})})]}),o(A,{borderBottom:!0,opacity:"low"}),o(ae.Slider,{value:u.val_grayScale,min:0,max:100,step:10,onUpdateValidValue:i=>{v.interval.once(()=>{u.set_grayScale(i)},250,"Cropper.GrayScale")},onLegendRender:i=>i+"%"})]})})})},children:[o(w.Micro,{fontColor:"4.thin",children:"GrayScale"}),p(w,{children:[u.val_grayScale.rate(1,0),"%"]})]}),p(W.Border.S,{flexCenter:!0,gap:"1/2",border:"unset",onClick:t=>{let a="CropperToneEdit";j.open({tipsID:a,gravityPoint:3,event:t,closeAtParentBlur:!1,xcss:{minWidth:12*26,maxWidth:12*24},content:()=>{let i=[];for(let n=1;n<=10;n++)i.push({value:n,label:p(M.Left,{gap:"1/3",children:[o(A,{ssSphere:1,className:[O("ToneBall"),O("ToneBall_"+n)].join(" ")}),o(A,{textAlign:"left",flexSizing:0,children:c(n)})]})});return o(N.Body,{children:p(J,{padding:1.5,children:[p(M.Separate,{children:[o(w.Paragraph,{children:p(M.Center,{gap:"1/2",children:[o(z,{icon:ge,fontColor:"5.translucent"}),"Tone"]})}),o(W.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{j.close(a)},children:o(z.X,{})})]}),o(A,{borderBottom:!0,opacity:"low"}),o(ae.Radio.Normal,{value:u.val_tone,gap:"1/2",cellStyles:{fontColor:"3.blur"},options:[{value:0,label:o(A,{flexSizing:0,textAlign:"center",children:"\u306A\u3057"})},...i],onUpdateValidValue:n=>{u.set_tone(n)}})]})})}})},children:[o(w.Micro,{fontColor:"4.thin",children:"Tone"}),o(A,{boxShadow:"2.remark",ssSphere:1,className:[O("ToneBall"),O("ToneBall_"+u.val_tone)].join(" ")}),c(u.val_tone)]})]})}},oe={openDialogNEdit:u=>{ae.Filer.fn.openDialog({accept:"image",multiple:!1,onChange:e=>{oe.openEditor(K({imageFile:e[0]},u))}})},openEditor:u=>V(void 0,null,function*(){let e="CropperImage";N.open("middleCenter",{sheetID:e,size:"MAX",padding:0,margin:0,xcss:{maxWidth:"100%"},content:o(se.Core,{val_file:u.imageFile,options:u,finishedCallback:c=>{N.close(e),u.onProcessFinished(c)},abortCallback:()=>{N.close(e)}}),closeAtEscapeKeyDown:!1})})};export{oe as Cropper,oe as default};
@@ -136,6 +136,7 @@ declare namespace DataGrid {
136
136
  }>;
137
137
  Info: React.FC<{
138
138
  datagridID: string;
139
+ totalCount?: number;
139
140
  }>;
140
141
  Paging: React.FC<{
141
142
  datagridID: string;
@@ -1 +1 @@
1
- import{b as a,c as p,d as q,e as ue}from"../../chunk-C5N2D3ZX.js";import{Fragment as Be,jsx as o,jsxs as U}from"react/jsx-runtime";import f,{useStore as le,UUID as se}from"jmini";import fe,{useState as Re,useEffect as ne}from"react";import{ExtractStyles as $,GenerateHTMLProps as Ie,dragEffect as ce,useRemote as ae}from"../../@utils";import{faArrowUp as xe}from"@fortawesome/free-solid-svg-icons/faArrowUp";import{faUpDown as Te}from"@fortawesome/free-solid-svg-icons/faUpDown";import{Box as k,Flex as we,FAI as G,Span as De}from"../../atoms";import{Literal as ye,Row as V,MarkerPen as me}from"../../mols";import{Button as ie}from"../Button";import H from"../Input";import{TableClasses as ke}from"../../@styles/componentClasses";import{faGripVertical as be}from"@fortawesome/free-solid-svg-icons/faGripVertical";import{Tips as Se}from"../Tips";const u={reservedKeys:["row_id","columnIdx","isSelected","isFilterMatched","isVisible","draggerIndex","onRowClick"],toSafetyHeader:t=>{let e=!!t.some(l=>l.draggable);return(t==null?void 0:t.map((l,d)=>{var n;return f.isRecord(l)||(l={key:l}),e&&(l.sortable=0,l.filterable=!1),l.columnIdx=(n=l.columnIdx)!=null?n:d,l}).toASC("columnIdx"))||[]},toSafetyBody:t=>t==null?void 0:t.map((e,r)=>{var d;let l={};return Object.entries(e).forEach(([n,s])=>{var m,c;if(f.isOneOf(n,...u.reservedKeys))return;let i=s;f.isNullish(i)||(f.isRecord(i)||(i={data:i}),i.sortKey=(c=(m=i.sortKey)!=null?m:String(i.data))!=null?c:"",l[n]=i)}),l=p(a({},l),{row_id:(d=e.row_id)!=null?d:r,onRowClick:e.onRowClick,isSelected:!!e.isSelected,isFilterMatched:!0,isVisible:!0,draggerIndex:r}),l}),toSafetyData:t=>{var l,d,n;let{header:e=[]}=t,r={datagridID:t.datagridID||se(),sessionID:se(),body:u.toSafetyBody(t.body||[]),filter:{keyword:t.defaultSearchKey||"",current:[]},sort:{col:-1,dir:1},paging:{rows:t.maxRows||100,total:1,current:1},draggable:!!e.some(s=>s.draggable)};{let s=(l=e==null?void 0:e.filter(i=>i.defSort))==null?void 0:l[0];s&&(r.sort.col=(d=e.indexOf(s))!=null?d:-1,r.sort.dir=(n=s==null?void 0:s.sortable)!=null?n:1)}return r.draggable&&(r.filter.keyword="",r.sort.col=-1,r.sort.dir=0),u.updateRowMeta(r,t)},updateRowMeta:(t,e)=>{let r=a({},t);if(r.sort.col>=0&&r.sort.dir){let l=e.header[r.sort.col].key;r.sort.dir==1?r.body.toASC(l+".sortKey"):r.body.toDESC(l+".sortKey")}{let l=String(r.filter.keyword)||"";r.body.forEach(d=>{if(d.isFilterMatched=!0,!l)return;let n=e.header.some(s=>{var c;let i=d[s.key];return!i||!i.sortKey?!1:!!((c=String(i.sortKey||i.data))!=null&&c.match(new RegExp(l.escapeRegExChar(),"i")))});d.isFilterMatched=n})}{let l=r.paging.rows;r.paging.total=Math.ceil(r.body.filter(i=>i.isFilterMatched).length/l);let d=l*(r.paging.current-1),n=d+l,s=0;r.body.forEach(i=>{i.isVisible=!1,i.isFilterMatched&&(i.isVisible=s>=d&&s<n,s++)})}return r.draggable&&r.body.toASC("draggerIndex"),r},index:t=>{var c,S,I,P;let[e,r]=Re(()=>u.toSafetyData(t));ne(()=>{le.set({["reset-"+e.datagridID]:()=>{r(u.toSafetyData(t))},["refresh-"+e.datagridID]:()=>{r(g=>u.updateRowMeta(p(a({},g),{body:u.toSafetyBody(t.body)}),t))}})},[t]),ne(()=>{le.set({["rows-"+e.datagridID]:e.body}),ae.bridge(e.datagridID,{val_config:e,remoteUpdate:{paging:g=>{r(y=>u.updateRowMeta(p(a({},y),{paging:p(a({},y.paging),{current:Math.max(1,Math.min(y.paging.total,g))})}),t))},maxRow:g=>{r(y=>u.updateRowMeta(p(a({},y),{paging:p(a({},y.paging),{rows:g,current:1})}),t))},searchKey:g=>{e.draggable||f.interval.once(()=>{r(y=>{let C=p(a({},y),{paging:p(a({},y.paging),{current:1}),filter:p(a({},y.filter),{keyword:String(g||"").trim()})});return u.updateRowMeta(C,t)})},300,"InputSearchTime")}}})},[e]);const l=fe.useRef(!1);ne(()=>{if(t.onSelected){if(!l.current){l.current=!0;return}t.onSelected(e.body.filter(g=>g.isSelected))}},[(c=e==null?void 0:e.body)==null?void 0:c.filter(g=>g.isSelected).length]);const d=fe.useRef(!1);ne(()=>{if(t.onSorted){if(!d.current){d.current=!0;return}t.onSorted(e.sort.col,e.sort.dir)}},[(S=e==null?void 0:e.sort)==null?void 0:S.col,(I=e==null?void 0:e.sort)==null?void 0:I.dir]);let n={input:t,val_config:e,set_config:r},{className:s,style:i}=Ie(t),m=(P=t.colLength)!=null?P:t.header.length;return o(k,{className:s,style:i,children:o(T.Table,{className:ke("DataGrid"),borderRadius:"inherit",children:U(T.Body,{children:[o(u.Header,a({},n)),o(u.Body,a({},n)),o(u.Footer,a({},n))]})},[m,...t.header.map(g=>g.key),e.sessionID].join("."))})},Checker:t=>o(k,{flexCenter:!0,onClick:e=>{e.stopPropagation()},children:o(H.Checker,p(a({wrapStyles:{display:"inlineBlock"},cellStyles:{gap:0}},t),{label:!1}))}),Header:t=>{var m;let{input:e,val_config:r,set_config:l}=t;if(e.headerless)return null;let d="datagrid-dragger-"+r.datagridID,n=["datagrid",r.datagridID,""].join("-"),s=1+r.body.filter(c=>c.isVisible).length+ +!!e.footer,i=(m=e.colLength)!=null?m:e.header.length;return o(ce.DropArea,p(a({jsxElement:T.Row,id:n},e.rowStyles),{dragInfo:{type:d,id:n,idx:0,marker:"bottom"},children:e.header.toASC("columnIdx").map((c,S)=>{var Y,Z,ee,te,B,_;let[I,P]=$(c),X=P,{isTH:g,key:y,label:C,onLabelRender:K,columnIdx:w,checkable:v,draggable:O,defSort:J,sortable:N,filterable:j,isHidden:E}=X,D=q(X,["isTH","key","label","onLabelRender","columnIdx","checkable","draggable","defSort","sortable","filterable","isHidden"]);if(E)return null;let h={rowIdx:0,colIdx:S,topIdx:0,leftIdx:S,rightIdx:i-S-1,bottomIdx:s-1,isHeader:!0,isBody:!1,isFooter:!1},x=O,z=N!=0,F=S==r.sort.col,W=f.deepMerge(f.deepCopy(e.cellStyles),ge(h,{}),(Y=e.cellStyles)==null?void 0:Y.onHeader,!h.leftIdx&&((Z=e.cellStyles)==null?void 0:Z.onLeft),!h.rightIdx&&((ee=e.cellStyles)==null?void 0:ee.onRight),!h.topIdx&&((te=e.cellStyles)==null?void 0:te.onTop),!h.bottomIdx&&((B=e.cellStyles)==null?void 0:B.onBottom),I);e.onCellStyles&&(W=e.onCellStyles(h,W||{}));let A=[],Q=[];if(x&&A.push(o(ie.Clear.S,{ssSphere:2,fontColor:"theme",onMouseOver:b=>{Se.open(b.currentTarget,U(ye.Supplement,{children:[o(G,{icon:be}),"\u30C9\u30E9\u30C3\u30B0\u3067\u5217\u306E\u9806\u756A\u3092\u5909\u66F4"]}),22)},onMouseLeave:b=>Se.abort(),onClick:b=>{b.stopPropagation()},children:o(G.QuestionCircle,{})},"drag")),v){let b=o(u.Checker,{value:r.body.every(R=>R.isSelected),onUpdateValue:R=>{l(L=>{let M=a({},L);return M.body.forEach(re=>{re.isFilterMatched&&(re.isSelected=!!R)}),M})}},"check");v=="left"?A.push(b):Q.push(b)}return z&&A.push(o(G,{fontSize:"1.mini",fontColor:"theme",opacity:F?"max":"low",transition:"middle",xcss:{transform:F&&r.sort.dir==-1?"rotate(180deg)":"none"},icon:F?xe:Te},"sort")),o(T.Cell,p(a(a({isTH:!!g,ssPushable:!!N},$(W||{})[0]),D),{className:[e.cellClassName,D.className].join(" "),onClick:b=>{D.onClick&&D.onClick(b),e.onCellClick&&e.onCellClick(h,b),z&&l(R=>{let L=a({},R);return L.sort={col:S,dir:F?R.sort.dir*-1:N},u.updateRowMeta(L,e)})},children:U(V.Left,{gap:"1/4",height:1,children:[A,(_=K==null?void 0:K(y))!=null?_:o(k,{flexSizing:0,children:C!=null?C:y}),Q]})}),[S,c.key].join("/"))})}))},Body:t=>{var i,m;let{input:e,val_config:r,set_config:l}=t,d=r.body.filter(c=>c.isVisible),n=+!e.headerless+d.length+ +!!e.footer,s=(i=e.colLength)!=null?i:e.header.length;return d.length?o(Be,{children:d.map((c,S)=>{let I=S;e.headerless||(I+=1);let P="datagrid-dragger-"+r.datagridID,g=["datagrid",r.datagridID,c.row_id].join("-");return o(ce.DropArea,p(a({jsxElement:T.Row,id:g,ssPushable:!!e.onRowClick||!!c.onRowClick},e.rowStyles),{onClick:y=>{c.onRowClick&&c.onRowClick(y),e.onRowClick&&e.onRowClick(c,y)},dragInfo:{type:P,id:g,idx:S+1,disabled:!r.draggable,marker:"bottom"},children:e.header.toASC("columnIdx").map((y,C)=>{var Q,X,Y,Z,ee,te;let K=y.draggable,w=c[y.key];if(!w)return null;let[v,O]=$(w),A=O,{isTH:J,sortKey:N,data:j,label:E,onLabelRender:D}=A,h=q(A,["isTH","sortKey","data","label","onLabelRender"]),x={rowIdx:I,colIdx:C,topIdx:I,leftIdx:C,rightIdx:s-C-1,bottomIdx:n-I-1,isHeader:!1,isBody:!0,isFooter:!1},z=f.deepMerge(f.deepCopy(e.cellStyles),ge(x,{}),(Q=e.cellStyles)==null?void 0:Q.onBody,!x.leftIdx&&((X=e.cellStyles)==null?void 0:X.onLeft),!x.rightIdx&&((Y=e.cellStyles)==null?void 0:Y.onRight),!x.topIdx&&((Z=e.cellStyles)==null?void 0:Z.onTop),!x.bottomIdx&&((ee=e.cellStyles)==null?void 0:ee.onBottom),v);e.onCellStyles&&(z=e.onCellStyles(x,z||{}));let F=[],W=[];if(K&&F.push(o(ie.Clear.S,{tabIndex:-1,isRounded:!0,ssSphere:2.5,fontColor:"6.clear",onPointerDown:B=>{let _=f("#"+g)[0],b=_.cloneNode(!0);b.style.width=_.offsetWidth+"px",ce.Start(P,{dragElement:b,startEvent:B,originId:g,horizontal:!1},R=>ue(void 0,null,function*(){if(!R.onDropArea)return;let L=S,M=Number(R.idx);if(f.isNullish(M)||M==-1||(M>L&&M--,L==M)||!R.end)return;let re=r.paging.rows*(r.paging.current-1);L+=re,M+=re;let oe=[...r.body||[]],he=oe.splice(L,1)[0];oe.splice(M,0,he),oe.forEach((de,Ce)=>{de.draggerIndex=Ce+1}),e.onDragged&&e.onDragged(oe),l(de=>p(a({},de),{body:oe}))}))},children:o(V.Center,{gap:"1/4",children:o(G,{icon:be})})},"drag")),y.checkable){let B=o(u.Checker,{override:"force",value:!!c.isSelected,onUpdateValue:_=>{l(b=>p(a({},b),{body:b.body.map(R=>(R.row_id==c.row_id&&(R.isSelected=!!_),R))}))}},"check");y.checkable=="left"?F.push(B):W.push(B)}return o(T.Cell,p(a(a({isTH:!!J},$(z||{})[0]),h),{className:[e.cellClassName,h.className].join(" "),onClick:B=>{h.onClick&&h.onClick(B),e.onCellClick&&e.onCellClick(x,B)},children:U(V.Left,{gap:"1/4",height:1,children:[F,(te=D==null?void 0:D(j))!=null?te:o(k,{flexSizing:0,children:me(E!=null?E:String(j),r.filter.keyword)}),W]})}),[C,y.key].join("/"))})}),[c.row_id,I].join("."))})}):o(T.Row,p(a({},e.rowStyles),{children:o(T.Cell,{colSpan:s,padding:1,children:(m=e.onNoRecordsRender)==null?void 0:m.call(e)})}))},Footer:t=>{var s;let{input:e,val_config:r,set_config:l}=t;if(!e.footer)return null;let d=+!e.headerless+r.body.filter(i=>i.isVisible).length+1,n=(s=e.colLength)!=null?s:e.header.length;return o(T.Row,p(a({},e.rowStyles),{children:e.header.toASC("columnIdx").map((i,m)=>{var J,N,j,E,D,h;let c=e.footer[i.key];if(!c)return null;f.isRecord(c)||(c={data:c});let[S,I]=$(c),O=I,{isTH:P,data:g,label:y,onLabelRender:C}=O,K=q(O,["isTH","data","label","onLabelRender"]),w={rowIdx:d-1,colIdx:m,topIdx:d-1,leftIdx:m,rightIdx:n-m-1,bottomIdx:0,isHeader:!1,isBody:!1,isFooter:!0},v=f.deepMerge(f.deepCopy(e.cellStyles),ge(w,{}),(J=e.cellStyles)==null?void 0:J.onBody,!w.leftIdx&&((N=e.cellStyles)==null?void 0:N.onLeft),!w.rightIdx&&((j=e.cellStyles)==null?void 0:j.onRight),!w.topIdx&&((E=e.cellStyles)==null?void 0:E.onTop),!w.bottomIdx&&((D=e.cellStyles)==null?void 0:D.onBottom),S);return e.onCellStyles&&(v=e.onCellStyles(w,v||{})),o(T.Cell,p(a(a({isTH:!!P},$(v||{})[0]),K),{className:[e.cellClassName,K.className].join(" "),onClick:x=>{K.onClick&&K.onClick(x),e.onCellClick&&e.onCellClick(w,x)},children:o(k,{flexSizing:0,children:(h=C==null?void 0:C(g))!=null?h:me(y!=null?y:String(g),r.filter.keyword)})}),[m,i.key].join("/"))})}))}},ge=(t,e)=>{let r=a({},e);return t.topIdx||(r.borderTop="unset"),t.bottomIdx||(r.borderBottom="unset"),t.rightIdx||(r.borderRight="unset"),t.leftIdx||(r.borderLeft="unset"),t.topIdx||(t.leftIdx||(r.borderTopLeftRadius="inherit"),t.rightIdx||(r.borderTopRightRadius="inherit")),t.bottomIdx||(t.leftIdx||(r.borderBottomLeftRadius="inherit"),t.rightIdx||(r.borderBottomRightRadius="inherit")),r},Ke=t=>(t=a({datagridID:se(),tone:"border",maxRows:100,onNoRecordsRender:()=>o(V.Center,{children:o(ye.Supplement,{fontColor:"4.thin",children:"(\u30C7\u30FC\u30BF\u306A\u3057)"})})},t),t.rowStyles=a({backgroundColor:"layer.0"},t.rowStyles),t.cellStyles=a(p(a({},f.scope(()=>{if(!t.tone)return{};let e={};return f.isOneOf(t.tone,"border","border.horizontal")&&(e.borderBottom="2.normal"),f.isOneOf(t.tone,"border","border.vertical")&&(e.borderRight="2.normal"),e})),{position:"relative",padding:"1/3",transition:"short"}),t.cellStyles),t.tone&&(t=a({border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"},t)),t.header=u.toSafetyHeader(t.header||[]),t.header.forEach((e,r)=>{var l;e.sortable=(l=e.sortable)!=null?l:1,e.checkable===!0&&(e.checkable="left")}),o(u.index,a({},t))),pe={getBodyRows:t=>le.get("rows-"+t)||[],toSafetyBody:u.toSafetyBody,reset:t=>{var e;(e=le.get("reset-"+t))==null||e()},refreshBody:t=>{var e;(e=le.get("refresh-"+t))==null||e()},reservedKeys:u.reservedKeys,Table:t=>o(k,p(a({htmlTag:"table",borderRadius:"inherit"},t),{border:t.border})),Head:t=>o(k,a({htmlTag:"thead",borderRadius:"inherit"},t)),Body:t=>o(k,a({htmlTag:"tbody",borderRadius:"inherit"},t)),Row:t=>o(k,a({htmlTag:"tr",borderRadius:"inherit"},t)),TH:t=>o(k,a({htmlTag:"th"},t)),TD:t=>o(k,a({htmlTag:"td"},t)),Cell:t=>{let l=t,{isTH:e}=l,r=q(l,["isTH"]);return e?o(pe.TH,a({},r)):o(pe.TD,a({},r))},RightIndicator:{data:"",label:o(V.Right,{children:o(G.AngleRight,{fontColor:"theme",fontSize:"3.paragraph"})})},SearchInput:t=>{let n=t,{datagridID:e}=n,r=q(n,["datagridID"]),l=ae.catch(t.datagridID);if(!l)return console.warn("[DataGrid] SearchInput must be used inside DataGrid."),null;let{val_config:d}=l;return o(H.TextField,p(a({label:"\u691C\u7D22...",clearButton:!0,padding:["1/2","2/3"],rightIcon:o(H.RightIcon,{ssSphere:2,fontColor:"5.translucent",right:"2/3",children:o(G.Search,{})}),value:d.filter.keyword},r),{onUpdateValidValue:(...s)=>{r.onUpdateValidValue&&r.onUpdateValidValue(...s),l.remoteUpdate.searchKey(s[0])}}))},Info:t=>{let e=ae.catch(t.datagridID);if(!e)return null;let{val_config:r}=e,l=r.body.length,d=r.body.filter(s=>s.isFilterMatched).length,n=d.ratio(l)||0;return U(we,{verticalAlign:"baseline",gap:"1/2",fontSize:"1.mini",fontColor:"3.blur",children:[o(De,{fontSize:"4.thirdTitle",fontColor:"theme",children:d.toLocaleString()}),"/ ",l.toLocaleString(),"\u4EF6 (",n,"%)"]})},Paging:t=>{let e=ae.catch(t.datagridID);if(!e)return null;let{val_config:r}=e,l=[];for(let n=0;n<r.paging.total;n++)l.push({value:n+1,label:(n+1).toString()});const d=n=>{let s=Math.min(Math.max(1,n),r.paging.total),i=a({},r);i.paging.current=s,e.remoteUpdate.paging(s)};return o(H.Select,{emptySelect:!1,padding:["1/3","2/3"],override:"force",gap:0,leftIcon:o(H.LeftIcon,{xcss:{left:2,pointerEvents:"all"},children:o(ie.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(r.paging.current==1){d(r.paging.total);return}d(r.paging.current-1)},children:o(G.ChevronLeft,{})})}),rightIcon:o(H.RightIcon,{xcss:{right:2,pointerEvents:"all"},children:o(ie.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(r.paging.current==r.paging.total){d(1);return}d(r.paging.current+1)},children:o(G.ChevronRight,{})})}),options:l.map(n=>({value:n.value||0,label:U(V.Left,{gap:"1/3",verticalAlign:"baseline",children:[n.label,U(ye,{fontColor:"4.thin",fontSize:"0.xs",children:["/ ",r.paging.total]})]})})),value:r.paging.current,onUpdateValidValue:n=>{d(n)}})},RowCount:t=>{let e=ae.catch(t.datagridID);if(!e)return null;let{val_config:r}=e,l=r.body.filter(i=>i.isFilterMatched).length,d=r.paging.rows,n=0,s=t.options.map(i=>(n|=+(i==d),{value:i,label:i.toString()}));return n||s.push({value:d,label:d.toString()}),o(V.Center,{gap:"1/2",children:o(H.Select,{emptySelect:!1,override:"force",padding:"1/3",paddingLeft:3,paddingRight:2,pickerStyles:{xcss:{minWidth:12*9}},pickerPosition:4,leftIcon:o(H.LeftIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{left:6},children:"\u8868\u793A"}),rightIcon:o(H.RightIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{right:6},children:"\u4EF6"}),value:r.paging.rows,options:s.toASC("value"),onUpdateValidValue:i=>{e.remoteUpdate.maxRow(Number(i))}})})}},T=Object.assign(Ke,pe);export{T as DataGrid,T as default,ge as onDefaultCellStyles};
1
+ import{b as a,c as p,d as q,e as ue}from"../../chunk-C5N2D3ZX.js";import{Fragment as Me,jsx as o,jsxs as U}from"react/jsx-runtime";import f,{useStore as le,UUID as se}from"jmini";import fe,{useState as Re,useEffect as ne}from"react";import{ExtractStyles as $,GenerateHTMLProps as Ie,dragEffect as ce,useRemote as ae}from"../../@utils";import{faArrowUp as xe}from"@fortawesome/free-solid-svg-icons/faArrowUp";import{faUpDown as Te}from"@fortawesome/free-solid-svg-icons/faUpDown";import{Box as k,Flex as we,FAI as G,Span as De}from"../../atoms";import{Literal as ye,Row as V,MarkerPen as me}from"../../mols";import{Button as ie}from"../Button";import H from"../Input";import{TableClasses as ke}from"../../@styles/componentClasses";import{faGripVertical as be}from"@fortawesome/free-solid-svg-icons/faGripVertical";import{Tips as he}from"../Tips";const u={reservedKeys:["row_id","columnIdx","isSelected","isFilterMatched","isVisible","draggerIndex","onRowClick"],toSafetyHeader:t=>{let e=!!t.some(l=>l.draggable);return(t==null?void 0:t.map((l,d)=>{var n;return f.isRecord(l)||(l={key:l}),e&&(l.sortable=0,l.filterable=!1),l.columnIdx=(n=l.columnIdx)!=null?n:d,l}).toASC("columnIdx"))||[]},toSafetyBody:t=>t==null?void 0:t.map((e,r)=>{var d;let l={};return Object.entries(e).forEach(([n,s])=>{var m,c;if(f.isOneOf(n,...u.reservedKeys))return;let i=s;f.isNullish(i)||(f.isRecord(i)||(i={data:i}),i.sortKey=(c=(m=i.sortKey)!=null?m:String(i.data))!=null?c:"",l[n]=i)}),l=p(a({},l),{row_id:(d=e.row_id)!=null?d:r,onRowClick:e.onRowClick,isSelected:!!e.isSelected,isFilterMatched:!0,isVisible:!0,draggerIndex:r}),l}),toSafetyData:t=>{var l,d,n;let{header:e=[]}=t,r={datagridID:t.datagridID||se(),sessionID:se(),body:u.toSafetyBody(t.body||[]),filter:{keyword:t.defaultSearchKey||"",current:[]},sort:{col:-1,dir:1},paging:{rows:t.maxRows||100,total:1,current:1},draggable:!!e.some(s=>s.draggable)};{let s=(l=e==null?void 0:e.filter(i=>i.defSort))==null?void 0:l[0];s&&(r.sort.col=(d=e.indexOf(s))!=null?d:-1,r.sort.dir=(n=s==null?void 0:s.sortable)!=null?n:1)}return r.draggable&&(r.filter.keyword="",r.sort.col=-1,r.sort.dir=0),u.updateRowMeta(r,t)},updateRowMeta:(t,e)=>{let r=a({},t);if(r.sort.col>=0&&r.sort.dir){let l=e.header[r.sort.col].key;r.sort.dir==1?r.body.toASC(l+".sortKey"):r.body.toDESC(l+".sortKey")}{let l=String(r.filter.keyword)||"";r.body.forEach(d=>{if(d.isFilterMatched=!0,!l)return;let n=e.header.some(s=>{var c;let i=d[s.key];return!i||!i.sortKey?!1:!!((c=String(i.sortKey||i.data))!=null&&c.match(new RegExp(l.escapeRegExChar(),"i")))});d.isFilterMatched=n})}{let l=r.paging.rows;r.paging.total=Math.ceil(r.body.filter(i=>i.isFilterMatched).length/l);let d=l*(r.paging.current-1),n=d+l,s=0;r.body.forEach(i=>{i.isVisible=!1,i.isFilterMatched&&(i.isVisible=s>=d&&s<n,s++)})}return r.draggable&&r.body.toASC("draggerIndex"),r},index:t=>{var c,h,I,P;let[e,r]=Re(()=>u.toSafetyData(t));ne(()=>{le.set({["reset-"+e.datagridID]:()=>{r(u.toSafetyData(t))},["refresh-"+e.datagridID]:()=>{r(g=>u.updateRowMeta(p(a({},g),{body:u.toSafetyBody(t.body)}),t))}})},[t]),ne(()=>{le.set({["rows-"+e.datagridID]:e.body}),ae.bridge(e.datagridID,{val_config:e,remoteUpdate:{paging:g=>{r(y=>u.updateRowMeta(p(a({},y),{paging:p(a({},y.paging),{current:Math.max(1,Math.min(y.paging.total,g))})}),t))},maxRow:g=>{r(y=>u.updateRowMeta(p(a({},y),{paging:p(a({},y.paging),{rows:g,current:1})}),t))},searchKey:g=>{e.draggable||f.interval.once(()=>{r(y=>{let C=p(a({},y),{paging:p(a({},y.paging),{current:1}),filter:p(a({},y.filter),{keyword:String(g||"").trim()})});return u.updateRowMeta(C,t)})},300,"InputSearchTime")}}})},[e]);const l=fe.useRef(!1);ne(()=>{if(t.onSelected){if(!l.current){l.current=!0;return}t.onSelected(e.body.filter(g=>g.isSelected))}},[(c=e==null?void 0:e.body)==null?void 0:c.filter(g=>g.isSelected).length]);const d=fe.useRef(!1);ne(()=>{if(t.onSorted){if(!d.current){d.current=!0;return}t.onSorted(e.sort.col,e.sort.dir)}},[(h=e==null?void 0:e.sort)==null?void 0:h.col,(I=e==null?void 0:e.sort)==null?void 0:I.dir]);let n={input:t,val_config:e,set_config:r},{className:s,style:i}=Ie(t),m=(P=t.colLength)!=null?P:t.header.length;return o(k,{className:s,style:i,children:o(T.Table,{className:ke("DataGrid"),borderRadius:"inherit",children:U(T.Body,{children:[o(u.Header,a({},n)),o(u.Body,a({},n)),o(u.Footer,a({},n))]})},[m,...t.header.map(g=>g.key),e.sessionID].join("."))})},Checker:t=>o(k,{flexCenter:!0,onClick:e=>{e.stopPropagation()},children:o(H.Checker,p(a({wrapStyles:{display:"inlineBlock"},cellStyles:{gap:0}},t),{label:!1}))}),Header:t=>{var m;let{input:e,val_config:r,set_config:l}=t;if(e.headerless)return null;let d="datagrid-dragger-"+r.datagridID,n=["datagrid",r.datagridID,""].join("-"),s=1+r.body.filter(c=>c.isVisible).length+ +!!e.footer,i=(m=e.colLength)!=null?m:e.header.length;return o(ce.DropArea,p(a({jsxElement:T.Row,id:n},e.rowStyles),{dragInfo:{type:d,id:n,idx:0,marker:"bottom"},children:e.header.toASC("columnIdx").map((c,h)=>{var Y,Z,ee,te,M,_;let[I,P]=$(c),X=P,{isTH:g,key:y,label:C,onLabelRender:K,columnIdx:w,checkable:v,draggable:O,defSort:J,sortable:N,filterable:j,isHidden:E}=X,D=q(X,["isTH","key","label","onLabelRender","columnIdx","checkable","draggable","defSort","sortable","filterable","isHidden"]);if(E)return null;let S={rowIdx:0,colIdx:h,topIdx:0,leftIdx:h,rightIdx:i-h-1,bottomIdx:s-1,isHeader:!0,isBody:!1,isFooter:!1},x=O,z=N!=0,F=h==r.sort.col,W=f.deepMerge(f.deepCopy(e.cellStyles),ge(S,{}),(Y=e.cellStyles)==null?void 0:Y.onHeader,!S.leftIdx&&((Z=e.cellStyles)==null?void 0:Z.onLeft),!S.rightIdx&&((ee=e.cellStyles)==null?void 0:ee.onRight),!S.topIdx&&((te=e.cellStyles)==null?void 0:te.onTop),!S.bottomIdx&&((M=e.cellStyles)==null?void 0:M.onBottom),I);e.onCellStyles&&(W=e.onCellStyles(S,W||{}));let A=[],Q=[];if(x&&A.push(o(ie.Clear.S,{ssSphere:2,fontColor:"theme",onMouseOver:b=>{he.open(b.currentTarget,U(ye.Mini,{children:[o(G,{icon:be}),"\u30C9\u30E9\u30C3\u30B0\u3067\u5217\u306E\u9806\u756A\u3092\u5909\u66F4"]}),22)},onMouseLeave:b=>he.abort(),onClick:b=>{b.stopPropagation()},children:o(G.QuestionCircle,{})},"drag")),v){let b=o(u.Checker,{value:r.body.every(R=>R.isSelected),onUpdateValue:R=>{l(L=>{let B=a({},L);return B.body.forEach(re=>{re.isFilterMatched&&(re.isSelected=!!R)}),B})}},"check");v=="left"?A.push(b):Q.push(b)}return z&&A.push(o(G,{fontSize:"1.mini",fontColor:"theme",opacity:F?"max":"low",transition:"middle",xcss:{transform:F&&r.sort.dir==-1?"rotate(180deg)":"none"},icon:F?xe:Te},"sort")),o(T.Cell,p(a(a({isTH:!!g,ssPushable:!!N},$(W||{})[0]),D),{className:[e.cellClassName,D.className].join(" "),onClick:b=>{D.onClick&&D.onClick(b),e.onCellClick&&e.onCellClick(S,b),z&&l(R=>{let L=a({},R);return L.sort={col:h,dir:F?R.sort.dir*-1:N},u.updateRowMeta(L,e)})},children:U(V.Left,{gap:"1/3",height:1,children:[A,(_=K==null?void 0:K(y))!=null?_:o(k,{flexSizing:0,children:C!=null?C:y}),Q]})}),[h,c.key].join("/"))})}))},Body:t=>{var i,m;let{input:e,val_config:r,set_config:l}=t,d=r.body.filter(c=>c.isVisible),n=+!e.headerless+d.length+ +!!e.footer,s=(i=e.colLength)!=null?i:e.header.length;return d.length?o(Me,{children:d.map((c,h)=>{let I=h;e.headerless||(I+=1);let P="datagrid-dragger-"+r.datagridID,g=["datagrid",r.datagridID,c.row_id].join("-");return o(ce.DropArea,p(a({jsxElement:T.Row,id:g,ssPushable:!!e.onRowClick||!!c.onRowClick},e.rowStyles),{onClick:y=>{c.onRowClick&&c.onRowClick(y),e.onRowClick&&e.onRowClick(c,y)},dragInfo:{type:P,id:g,idx:h+1,disabled:!r.draggable,marker:"bottom"},children:e.header.toASC("columnIdx").map((y,C)=>{var Q,X,Y,Z,ee,te;let K=y.draggable,w=c[y.key];if(!w)return null;let[v,O]=$(w),A=O,{isTH:J,sortKey:N,data:j,label:E,onLabelRender:D}=A,S=q(A,["isTH","sortKey","data","label","onLabelRender"]),x={rowIdx:I,colIdx:C,topIdx:I,leftIdx:C,rightIdx:s-C-1,bottomIdx:n-I-1,isHeader:!1,isBody:!0,isFooter:!1},z=f.deepMerge(f.deepCopy(e.cellStyles),ge(x,{}),(Q=e.cellStyles)==null?void 0:Q.onBody,!x.leftIdx&&((X=e.cellStyles)==null?void 0:X.onLeft),!x.rightIdx&&((Y=e.cellStyles)==null?void 0:Y.onRight),!x.topIdx&&((Z=e.cellStyles)==null?void 0:Z.onTop),!x.bottomIdx&&((ee=e.cellStyles)==null?void 0:ee.onBottom),v);e.onCellStyles&&(z=e.onCellStyles(x,z||{}));let F=[],W=[];if(K&&F.push(o(ie.Clear.S,{tabIndex:-1,isRounded:!0,ssSphere:2.5,fontColor:"6.clear",onPointerDown:M=>{let _=f("#"+g)[0],b=_.cloneNode(!0);b.style.width=_.offsetWidth+"px",ce.Start(P,{dragElement:b,startEvent:M,originId:g,horizontal:!1},R=>ue(void 0,null,function*(){if(!R.onDropArea)return;let L=h,B=Number(R.idx);if(f.isNullish(B)||B==-1||(B>L&&B--,L==B)||!R.end)return;let re=r.paging.rows*(r.paging.current-1);L+=re,B+=re;let oe=[...r.body||[]],Se=oe.splice(L,1)[0];oe.splice(B,0,Se),oe.forEach((de,Ce)=>{de.draggerIndex=Ce+1}),e.onDragged&&e.onDragged(oe),l(de=>p(a({},de),{body:oe}))}))},children:o(V.Center,{gap:"1/4",children:o(G,{icon:be})})},"drag")),y.checkable){let M=o(u.Checker,{override:"force",value:!!c.isSelected,onUpdateValue:_=>{l(b=>p(a({},b),{body:b.body.map(R=>(R.row_id==c.row_id&&(R.isSelected=!!_),R))}))}},"check");y.checkable=="left"?F.push(M):W.push(M)}return o(T.Cell,p(a(a({isTH:!!J},$(z||{})[0]),S),{className:[e.cellClassName,S.className].join(" "),onClick:M=>{S.onClick&&S.onClick(M),e.onCellClick&&e.onCellClick(x,M)},children:U(V.Left,{gap:"1/3",height:1,children:[F,(te=D==null?void 0:D(j))!=null?te:o(k,{flexSizing:0,children:me(E!=null?E:String(j),r.filter.keyword)}),W]})}),[C,y.key].join("/"))})}),[c.row_id,I].join("."))})}):o(T.Row,p(a({},e.rowStyles),{children:o(T.Cell,{colSpan:s,padding:1,children:(m=e.onNoRecordsRender)==null?void 0:m.call(e)})}))},Footer:t=>{var s;let{input:e,val_config:r,set_config:l}=t;if(!e.footer)return null;let d=+!e.headerless+r.body.filter(i=>i.isVisible).length+1,n=(s=e.colLength)!=null?s:e.header.length;return o(T.Row,p(a({},e.rowStyles),{children:e.header.toASC("columnIdx").map((i,m)=>{var J,N,j,E,D,S;let c=e.footer[i.key];if(!c)return null;f.isRecord(c)||(c={data:c});let[h,I]=$(c),O=I,{isTH:P,data:g,label:y,onLabelRender:C}=O,K=q(O,["isTH","data","label","onLabelRender"]),w={rowIdx:d-1,colIdx:m,topIdx:d-1,leftIdx:m,rightIdx:n-m-1,bottomIdx:0,isHeader:!1,isBody:!1,isFooter:!0},v=f.deepMerge(f.deepCopy(e.cellStyles),ge(w,{}),(J=e.cellStyles)==null?void 0:J.onBody,!w.leftIdx&&((N=e.cellStyles)==null?void 0:N.onLeft),!w.rightIdx&&((j=e.cellStyles)==null?void 0:j.onRight),!w.topIdx&&((E=e.cellStyles)==null?void 0:E.onTop),!w.bottomIdx&&((D=e.cellStyles)==null?void 0:D.onBottom),h);return e.onCellStyles&&(v=e.onCellStyles(w,v||{})),o(T.Cell,p(a(a({isTH:!!P},$(v||{})[0]),K),{className:[e.cellClassName,K.className].join(" "),onClick:x=>{K.onClick&&K.onClick(x),e.onCellClick&&e.onCellClick(w,x)},children:o(k,{flexSizing:0,children:(S=C==null?void 0:C(g))!=null?S:me(y!=null?y:String(g),r.filter.keyword)})}),[m,i.key].join("/"))})}))}},ge=(t,e)=>{let r=a({},e);return t.topIdx||(r.borderTop="unset"),t.bottomIdx||(r.borderBottom="unset"),t.rightIdx||(r.borderRight="unset"),t.leftIdx||(r.borderLeft="unset"),t.topIdx||(t.leftIdx||(r.borderTopLeftRadius="inherit"),t.rightIdx||(r.borderTopRightRadius="inherit")),t.bottomIdx||(t.leftIdx||(r.borderBottomLeftRadius="inherit"),t.rightIdx||(r.borderBottomRightRadius="inherit")),r},Ke=t=>(t=a({datagridID:se(),tone:"border",maxRows:100,onNoRecordsRender:()=>o(V.Center,{children:o(ye.Mini,{fontColor:"4.thin",children:"(\u30C7\u30FC\u30BF\u306A\u3057)"})})},t),t.rowStyles=a({backgroundColor:"layer.0"},t.rowStyles),t.cellStyles=a(p(a({},f.scope(()=>{if(!t.tone)return{};let e={};return f.isOneOf(t.tone,"border","border.horizontal")&&(e.borderBottom="2.normal"),f.isOneOf(t.tone,"border","border.vertical")&&(e.borderRight="2.normal"),e})),{position:"relative",padding:"1/3",transition:"short"}),t.cellStyles),t.tone&&(t=a({border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"},t)),t.header=u.toSafetyHeader(t.header||[]),t.header.forEach((e,r)=>{var l;e.sortable=(l=e.sortable)!=null?l:1,e.checkable===!0&&(e.checkable="left")}),o(u.index,a({},t))),pe={getBodyRows:t=>le.get("rows-"+t)||[],toSafetyBody:u.toSafetyBody,reset:t=>{var e;(e=le.get("reset-"+t))==null||e()},refreshBody:t=>{var e;(e=le.get("refresh-"+t))==null||e()},reservedKeys:u.reservedKeys,Table:t=>o(k,p(a({htmlTag:"table",borderRadius:"inherit"},t),{border:t.border})),Head:t=>o(k,a({htmlTag:"thead",borderRadius:"inherit"},t)),Body:t=>o(k,a({htmlTag:"tbody",borderRadius:"inherit"},t)),Row:t=>o(k,a({htmlTag:"tr",borderRadius:"inherit"},t)),TH:t=>o(k,a({htmlTag:"th"},t)),TD:t=>o(k,a({htmlTag:"td"},t)),Cell:t=>{let l=t,{isTH:e}=l,r=q(l,["isTH"]);return e?o(pe.TH,a({},r)):o(pe.TD,a({},r))},RightIndicator:{data:"",label:o(V.Right,{children:o(G.AngleRight,{fontColor:"theme",fontSize:"3.paragraph"})})},SearchInput:t=>{let n=t,{datagridID:e}=n,r=q(n,["datagridID"]),l=ae.catch(t.datagridID);if(!l)return console.warn("[DataGrid] SearchInput must be used inside DataGrid."),null;let{val_config:d}=l;return o(H.TextField,p(a({label:"\u691C\u7D22...",clearButton:!0,padding:["1/2","2/3"],rightIcon:o(H.RightIcon,{ssSphere:2,fontColor:"5.translucent",right:"2/3",children:o(G.Search,{})}),value:d.filter.keyword},r),{onUpdateValidValue:(...s)=>{r.onUpdateValidValue&&r.onUpdateValidValue(...s),l.remoteUpdate.searchKey(s[0])}}))},Info:t=>{let e=ae.catch(t.datagridID);if(!e)return null;let{val_config:r}=e,l=t.totalCount||r.body.length,d=r.body.filter(s=>s.isFilterMatched).length,n=d.ratio(l,1)||0;return U(we,{verticalAlign:"baseline",gap:"1/2",fontSize:"1.mini",fontColor:"3.blur",children:[o(De,{fontSize:"4.thirdTitle",fontColor:"theme",children:d.toLocaleString()}),"/ ",l.toLocaleString(),"\u4EF6 (",n,"%)"]})},Paging:t=>{let e=ae.catch(t.datagridID);if(!e)return null;let{val_config:r}=e,l=[];for(let n=0;n<r.paging.total;n++)l.push({value:n+1,label:(n+1).toString()});const d=n=>{let s=Math.min(Math.max(1,n),r.paging.total),i=a({},r);i.paging.current=s,e.remoteUpdate.paging(s)};return o(H.Select,{emptySelect:!1,padding:["1/3","2/3"],override:"force",gap:0,leftIcon:o(H.LeftIcon,{xcss:{left:2,pointerEvents:"all"},children:o(ie.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(r.paging.current==1){d(r.paging.total);return}d(r.paging.current-1)},children:o(G.ChevronLeft,{})})}),rightIcon:o(H.RightIcon,{xcss:{right:2,pointerEvents:"all"},children:o(ie.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(r.paging.current==r.paging.total){d(1);return}d(r.paging.current+1)},children:o(G.ChevronRight,{})})}),options:l.map(n=>({value:n.value||0,label:U(V.Left,{gap:"1/3",verticalAlign:"baseline",children:[n.label,U(ye.Micro,{fontColor:"4.thin",children:["/ ",r.paging.total]})]})})),value:r.paging.current,onUpdateValidValue:n=>{d(n)}})},RowCount:t=>{let e=ae.catch(t.datagridID);if(!e)return null;let{val_config:r}=e,l=r.body.filter(i=>i.isFilterMatched).length,d=r.paging.rows,n=0,s=t.options.map(i=>(n|=+(i==d),{value:i,label:i.toString()}));return n||s.push({value:d,label:d.toString()}),o(V.Center,{gap:"1/2",children:o(H.Select,{emptySelect:!1,override:"force",padding:"1/3",paddingLeft:3,paddingRight:2,pickerStyles:{xcss:{minWidth:12*9}},pickerPosition:4,leftIcon:o(H.LeftIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{left:6},children:"\u8868\u793A"}),rightIcon:o(H.RightIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{right:6},children:"\u4EF6"}),value:r.paging.rows,options:s.toASC("value"),onUpdateValidValue:i=>{e.remoteUpdate.maxRow(Number(i))}})})}},T=Object.assign(Ke,pe);export{T as DataGrid,T as default,ge as onDefaultCellStyles};
@@ -1 +1 @@
1
- import{b as l,c as f,d as Z,e as H}from"../../chunk-C5N2D3ZX.js";import{Fragment as N,jsx as c,jsxs as V}from"react/jsx-runtime";import{useState as A,useEffect as F,useRef as ne}from"react";import a,{UUID as v}from"jmini";import{Config as oe}from"../../@utils";import{Box as X,Span as ie,FAI as B,Column as q}from"../../atoms";import{Literal as K,Row as M}from"../../mols";import{Button as $}from"../Button";import{Loader as le}from"../Loader";import{Sheet as ae}from"../Sheet";import{OptionalInputWrapper as re,BoxWrapper as se,CoreEffects as z,DefaultBoxishStyles as ue}from"./core";import{InputAutocompleteClasses as L}from"../../@styles/componentClasses";import{InputLabel as ce}from"./Label";import{RightIcon as G}from".";function pe(t){let{value:e,states:i}=t,{required:s,options:d,min:m,max:o}=i;m=m||0,o=o||65535;let n=[],p=e.filter(h=>h!==null).length;return s&&(p||n.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),p<m&&n.push({type:"invalid",label:m+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),p>o&&n.push({type:"invalid",label:o+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!n.filter(({type:h})=>h=="invalid").length,notice:n}}const R={InitOptions:t=>{let e=[];return t.forEach(i=>{if(!i)return;let{type:s,label:d,value:m,searchValue:o}=i,n=o||a.isString(d)&&d||""||a.isString(m)&&m||a.Stringify(m||"")||"";a.isNullish(d)&&(d=String(m)),e.push(f(l({id:v(8)},i),{searchValue:n,type:s||"selector",label:d,value:m}))}),e},FilterSelectableOptions:(t,e,i)=>{let s=t;return i||(s=t.filter(d=>(d==null?void 0:d.type)!="label")),a.scope(()=>{if(!e)return;let d=e.toLower().replace(/ /g,"");s=s.filter(m=>(m.searchValue||"").toLower().replace(/ /g,"").includes(d))}),s},Button:t=>{let{rootStates:e,val_keyword:i,set_keyword:s,val_optionFocused:d,set_optionFocused:m,val_status:o,set_status:n}=t,J=e,{tone:p,required:h,form:O,className:r,multiSelect:u,enableFormSubmit:y,showInitValidation:S,onValidate:g,onValidateDelay:I,onUpdateValue:x,onUpdateValidValue:C,onUserAction:P,value:E="",options:w,leftIndicator:D,rightIndicator:_,leftIcon:de,rightIcon:fe,componentId:me,status_id:Se,wrapStyles:ve,emptySelect:ye,searchInputPlaceholder:he,onSelectedRender:ge,onSelectorRender:Ie,pickerStyles:be,pickerPosition:Oe,onDynamicSearchOptions:_e,onDynamicSearchOptionsDelay:we}=J,T=Z(J,["tone","required","form","className","multiSelect","enableFormSubmit","showInitValidation","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","emptySelect","searchInputPlaceholder","onSelectedRender","onSelectorRender","pickerStyles","pickerPosition","onDynamicSearchOptions","onDynamicSearchOptionsDelay"]),W="SearchInput_"+e.componentId;return F(()=>{var b;if(e.disabled||!o.isPickerOpen||a.isExist(d))return;let k=R.FilterSelectableOptions(t.val_options,i,!1);m(((b=k[0])==null?void 0:b.id)||"")},[i]),F(()=>{if(o.eventType!="init"&&o.eventType!="override"&&e.max==o.rawValue.length){s(""),n(k=>f(l({},k),{eventID:v(8),isPickerOpen:!1}));return}},[o.rawValue]),F(()=>{let k="autocomplete-click-"+e.componentId;if(!o.isPickerOpen){a(document).removeEvent([k]);return}a('[data-input-origin="'+e.componentId+'"]')&&a(document).onEvent("mousedown",U=>{let j=a(U.target),Y=!!a(j).parent("."+L("Core")).length,ee=!!a(j).parent("."+L("Selector")).length;Y||ee||n(te=>f(l({},te),{eventID:v(8),isFocusing:!1,isPickerOpen:!1}))},{eventID:k,passive:!1})},[o.isPickerOpen]),V(N,{children:[c(X,f(l({tabIndex:-1},T),{"data-disabled":e.disabled,"data-show-validation":z.isShowValidation(o,!!S),"data-component-id":o.componentId,"data-input-origin":o.componentId,"data-focus":o.isFocusing||o.isPickerOpen,className:[r,L("Core")].join(" "),onClick:k=>{if(T!=null&&T.onClick&&(T==null||T.onClick(k)),e.disabled)return;let b=document.activeElement;(b==null?void 0:b.id)!=W&&(oe.get().isTouchDevice||a("#"+W).focus()),n(U=>f(l({},U),{eventID:v(8),isPickerOpen:!0,isFocusing:!0}))},onKeyDown:k=>{let b=document.activeElement;(b==null?void 0:b.id)!=W&&(k.preventDefault(),a("#"+W).focus())},children:V(M.Left,{gap:0,children:[c(ie,{"data-input-value-shallow":o.componentId,width:0,overflow:"hidden",opacity:"trans",children:"A"}),V(M.Left,{flexWrap:!0,flexSizing:0,gap:"1/4",verticalAlign:"unset",xcss:{letterSpacing:".5px"},children:[c(R.Selected,l({},t)),c(R.SearchInput,l({},t))]}),o.rawValue.length>1&&c($.Clear,{tabIndex:-1,color:"nega",fontColor:"4.thin",ssSphere:2,onClick:k=>{n(b=>f(l({},b),{eventType:"update",eventID:v(8),rawValue:[]}))},children:c(B.X,{})})]})})),c(R.Picker,l({},t))]})},SearchInput:t=>{let{rootStates:e,val_status:i,set_status:s}=t;if(e.disabled)return null;let d=!!i.isFocusing||!!i.isPickerOpen||!!i.rawValue.length;i.isFocusing||e.multiSelect||i.rawValue.length&&(d=!1);let m=e.searchInputPlaceholder||"\u691C\u7D22...";return c(X,{htmlTag:"input",id:"SearchInput_"+e.componentId,placeholder:m,opacity:d?"max":"trans",transition:"middle",flexSizing:0,fontSize:"inherit",border:"0.trans",backgroundColor:"trans",isRounded:!0,padding:[0,"2/3"],value:t.val_keyword,className:[L("SearchInput"),d&&L("isActive")].join(" "),xcss:{outline:"none",minWidth:12*4},onFocus:o=>{s(n=>f(l({},n),{eventID:v(8),isFocusing:!0,isPickerOpen:!0}))},onBlur:o=>H(void 0,null,function*(){s(n=>f(l({},n),{eventID:v(8),isFocusing:!1}))}),onCompositionStart:o=>{s(n=>f(l({},n),{eventID:v(8),isComposing:!0}))},onCompositionEnd:o=>{s(n=>f(l({},n),{eventID:v(8),isComposing:!1}))},onKeyDown:o=>{let{key:n,metaKey:p,ctrlKey:h}=o,O=p||h;n=="Escape"?s(r=>f(l({},r),{eventID:v(12),isPickerOpen:!1})):n=="Tab"?s(r=>f(l({},r),{eventID:v(8),isFocusing:!1,isPickerOpen:!1})):n==" "?a.scope(()=>{i.isPickerOpen||t.val_keyword||(o.preventDefault(),s(r=>f(l({},r),{eventID:v(8),isPickerOpen:!0})))}):n=="Backspace"?a.scope(()=>{if(t.val_keyword)return;let r=[...t.val_status.rawValue];r.pop(),O&&(r=[]),s(u=>f(l({},u),{rawValue:r,eventType:"update",eventID:v(8),isInspected:!1}))}):n=="Enter"&&a.scope(()=>{if(i.isComposing||(o==null?void 0:o.keyCode)===229)return;if(!i.isPickerOpen){s(y=>f(l({},y),{eventID:v(8),isPickerOpen:!0}));return}if(!t.val_optionFocused)return;let r=t.val_options.find(y=>(y==null?void 0:y.id)==t.val_optionFocused);if(!r)return;let{value:u}=r;s(y=>{let S=[...y.rawValue];return a.scope(()=>{if(u===null)return S=[];y.rawValue.includes(u)?S=S.filter(I=>I!==u):e.multiSelect?S.push(u):S=[u]}),f(l({},y),{rawValue:S,eventType:"update",eventID:v(8),isInspected:!1})}),t.set_optionsModified(!0),t.set_keyword("")}),a.scope(()=>{if(!a.isOneOf(n,"ArrowDown","ArrowUp"))return;if(o.preventDefault(),!i.isPickerOpen){s(g=>f(l({},g),{eventID:v(8),isPickerOpen:!0}));return}let r=n=="ArrowDown"?1:-1,u=R.FilterSelectableOptions(t.val_options,t.val_keyword),y=u.length-1,S=null;a.scope(()=>{var I,x,C,P,E,w,D;let g=u.findIndex(_=>(_==null?void 0:_.id)==t.val_optionFocused);if(g==-1){S=(I=u[0])==null?void 0:I.id;return}if(r==1){if(S=(x=u[0])==null?void 0:x.id,O){S=(C=u[y])==null?void 0:C.id;return}if(g==-1||g==y)return;S=(P=u[g+1])==null?void 0:P.id}else{if(S=(E=u[y])==null?void 0:E.id,O){S=(w=u[0])==null?void 0:w.id;return}if(g==-1||g==0)return;S=(D=u[g-1])==null?void 0:D.id}}),t.set_optionFocused(S)}),e.enableFormSubmit&&z.SubmitForm(o,t.rootStates.form)},onChange:o=>{let p=o.target.value;t.set_keyword(p),t.set_optionFocused(""),p&&s(h=>f(l({},h),{eventID:v(8),isPickerOpen:!0}))}},"searchInput")},Picker:t=>{var n;let{rootStates:e,val_status:i}=t,[s,d]=A("idle");F(()=>{if(!e.onDynamicSearchOptions||!i.isPickerOpen)return;if(t.val_optionsModified)return t.set_optionsModified(!1);if(i.isComposing)return;d("fetch");let p="autocomplete-search-"+e.componentId;t.set_optionFocused(""),a.interval.once(()=>H(void 0,null,function*(){var r;let h=yield e.onDynamicSearchOptions(t.val_keyword);d("idle");let O=R.InitOptions(h||[]);t.set_options(O),t.set_optionFocused(((r=O[0])==null?void 0:r.id)||"")}),e.onDynamicSearchOptionsDelay||500,p)},[t.val_keyword,i.isComposing]),F(()=>{let p=a(`[data-selector-id="${i.componentId}"]`)[0];if(!p)return;let h=a(`[data-autocomplete-input-value="${t.val_optionFocused}"]`)[0];h&&(p.scrollTop=h.offsetTop-24)},[t.val_optionFocused]);let m=R.FilterSelectableOptions(t.val_options,e.onDynamicSearchOptions?"":t.val_keyword,!0),o={};{let p=e.pickerPosition||0;a.isOneOf(p,1,2)?o.bottom="100%":a.isOneOf(p,3,4)&&(o.top="100%"),a.isOneOf(p,1,3)?o.left=0:a.isOneOf(p,2,4)&&(o.right=0)}return i.isPickerOpen?c(X,f(l({position:"absolute",ssZIndex:1e3,padding:"1/3"},o),{xcss:l({minWidth:"75%"},o.xcss),children:c(ae.Body,f(l({className:L("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,tabIndex:-1,boxShadow:"1.normal",overflow:"auto","data-selector-id":i.componentId},e.pickerStyles),{xcss:l({maxHeight:12*24},(n=e.pickerStyles)==null?void 0:n.xcss),children:V(q,{gap:"1/12",padding:[1,0],children:[s=="fetch"&&c(M.Center,{padding:"1/2",children:c(le.Theme.R,{showInitial:!0})}),s!="fetch"&&V(N,{children:[!m.length&&c(K.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"}),m.map((p,h)=>{if(!p)return null;let{type:O,value:r}=p,u=t.val_optionFocused==p.id,y=i.rawValue.includes(r),S=e.onSelectorRender;return c(q,{"data-autocomplete-input-value":p.id,children:c(S,{option:p,isFocused:u,isSelected:y,onAdd:()=>{t.set_status(g=>{let I=[...g.rawValue];return a.scope(()=>{if(r===null)return I=[];if(g.rawValue.includes(r)){I=I.filter(C=>C!==r);return}e.multiSelect?I.push(r):I=[r]}),f(l({},g),{rawValue:I,eventType:"update",eventID:v(8),isFocusing:e.max!=I.length,isInspected:!1})})},onKeyDown:g=>{let{key:I}=g;I=="Tab"&&(t.set_optionFocused(""),t.set_status(x=>f(l({},x),{eventID:v(8),isPickerOpen:!1,isFocusing:!1})))}})},p.id)})]})]})}))})):null},Selected:t=>{let{rootStates:e,val_status:i,set_status:s,val_optionsDict:d}=t,m=[];return i.rawValue.forEach(o=>{let n=d[a.Stringify(o)];if(!n)return;let p=e.onSelectedRender,h=(n==null?void 0:n.selectedLabel)||(n==null?void 0:n.label);(n==null?void 0:n.value)===null&&(h=""),m.push(c(q,{position:"relative",flexCenter:!0,xcss:{userSelect:"none"},children:c(p,{value:n==null?void 0:n.value,label:h,onRemove:O=>{if(e.disabled)return;let r=[...i.rawValue];r=r.filter(u=>u!==o),s(u=>f(l({},u),{rawValue:r,eventType:"update",eventID:v(8),isInspected:!1,isFocusing:e.max!=r.length,isPickerOpen:!0}))}})},a.Stringify(n==null?void 0:n.value)||v(8)))}),c(N,{children:m})},Core:t=>{var C,P,E;let{value:e}=t,[i,s]=A(!1),[d,m]=A(""),[o,n]=A(t.options),[p,h]=A(((C=t.options.find(w=>{var D;return(w==null?void 0:w.value)===((D=t.value)==null?void 0:D[0])}))==null?void 0:C.id)||((P=t.options[0])==null?void 0:P.id)||""),[O,r]=A({}),[u,y]=A(z.DefaultStatus(t.componentId,e)),S=ne(!1);F(()=>{i||(S.current?n(t.options):S.current=!0)},[a.Stringify((E=t.options)==null?void 0:E.map(w=>w.value))]),F(()=>{if(!o.length)return;let w=[...o],D=l({},O);w.forEach(_=>{(_==null?void 0:_.type)!="label"&&(D[a.Stringify(_==null?void 0:_.value)]=_)}),r(D)},[o]);let g={rootStates:t,val_options:o,set_options:n,val_optionFocused:p,set_optionFocused:h,val_optionsDict:O,set_optionsDict:r,val_optionsModified:i,set_optionsModified:s,val_keyword:d,set_keyword:m,val_status:u,set_status:y},I=!!t.multiSelect;z.CommonEffects({type:I?"autocomplete.multi":"autocomplete.single",states:t,val_status:u,set_status:y,SystemValidation:pe});let x=u.rawValue.length&&u.rawValue[0]!==null||u.isPickerOpen||u.isFocusing;return V(se,{val_status:u,set_status:y,states:t,children:[c(ce,{componentId:t.componentId,fontSize:t.fontSize,required:t.required,label:t.label,isActive:x,val_status:u}),c(R.Button,l({},g))]})}},Q=t=>{let e=l({},t);return e=f(l({value:[],min:0,max:65535,multiSelect:!0,emptySelect:!0,onSelectorRender:i=>{var s;return i.option?((s=i.option)==null?void 0:s.type)=="label"?c(N,{children:i.option.label}):c($.Sub.S,{color:"cloud",tabIndex:-1,backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["2/3",1.5],isActive:i.isFocused,isActiveStyles:{backgroundColor:"cloud"},onClick:i.onAdd,onKeyDown:i.onKeyDown,children:V(M.Left,{gap:"1/2",children:[i.isSelected&&c(B.Check,{fontColor:"theme"}),c(K.Supplement,{transition:"short",children:i.option.label})]})}):null},onSelectedRender:i=>V(M.Left,{ssCardBox:!0,borderRadius:"1.tone.primary",fontSize:"1.mini",padding:"1/3",gap:0,children:[c(K,{padding:[0,"1/2"],children:i.label}),c($.Clear,{flexSizing:"none",color:"nega",fontColor:"4.thin",tabIndex:-1,ssSphere:2,onClick:i.onRemove,xcss:{lineHeight:1,aspectRatio:"1/1"},children:c(B.X,{})})]}),pickerPosition:3},e),{xcss:l({cursor:"pointer"},e.xcss)}),e.multiSelect||(e.min=0,e.max=1),e.options=e.options||[],e.emptySelect&&(e.options=[{value:null,label:c(K.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...e.options]),e.value=a.Arrayify(e.value),e.options=R.InitOptions(e.options),a.isNullish(e.rightIcon)&&(e.rightIcon=c(G,{children:c(B.Search,{})}),e.disabled&&(e.rightIcon=c(G,{fontColor:"5.translucent",children:c(B.Ban,{})}))),e.rightIcon&&(e=l({paddingRight:3},e)),e.leftIcon&&(e=l({paddingLeft:3},e)),c(re,{componentId:e.componentId,children:R.Core,states:ue(e)})};export{Q as Autocomplete,Q as default};
1
+ import{b as l,c as f,d as Z,e as H}from"../../chunk-C5N2D3ZX.js";import{Fragment as N,jsx as c,jsxs as V}from"react/jsx-runtime";import{useState as A,useEffect as F,useRef as ne}from"react";import a,{UUID as v}from"jmini";import{Config as oe}from"../../@utils";import{Box as X,Span as ie,FAI as B,Column as q}from"../../atoms";import{Literal as K,Row as M}from"../../mols";import{Button as $}from"../Button";import{Loader as le}from"../Loader";import{Sheet as ae}from"../Sheet";import{OptionalInputWrapper as re,BoxWrapper as se,CoreEffects as z,DefaultBoxishStyles as ue}from"./core";import{InputAutocompleteClasses as L}from"../../@styles/componentClasses";import{InputLabel as ce}from"./Label";import{RightIcon as G}from".";function pe(t){let{value:e,states:i}=t,{required:s,options:d,min:m,max:o}=i;m=m||0,o=o||65535;let n=[],p=e.filter(h=>h!==null).length;return s&&(p||n.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),p<m&&n.push({type:"invalid",label:m+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),p>o&&n.push({type:"invalid",label:o+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!n.filter(({type:h})=>h=="invalid").length,notice:n}}const R={InitOptions:t=>{let e=[];return t.forEach(i=>{if(!i)return;let{type:s,label:d,value:m,searchValue:o}=i,n=o||a.isString(d)&&d||""||a.isString(m)&&m||a.Stringify(m||"")||"";a.isNullish(d)&&(d=String(m)),e.push(f(l({id:v(8)},i),{searchValue:n,type:s||"selector",label:d,value:m}))}),e},FilterSelectableOptions:(t,e,i)=>{let s=t;return i||(s=t.filter(d=>(d==null?void 0:d.type)!="label")),a.scope(()=>{if(!e)return;let d=e.toLower().replace(/ /g,"");s=s.filter(m=>(m.searchValue||"").toLower().replace(/ /g,"").includes(d))}),s},Button:t=>{let{rootStates:e,val_keyword:i,set_keyword:s,val_optionFocused:d,set_optionFocused:m,val_status:o,set_status:n}=t,J=e,{tone:p,required:h,form:O,className:r,multiSelect:u,enableFormSubmit:y,showInitValidation:S,onValidate:g,onValidateDelay:I,onUpdateValue:x,onUpdateValidValue:C,onUserAction:P,value:E="",options:w,leftIndicator:D,rightIndicator:_,leftIcon:de,rightIcon:fe,componentId:me,status_id:Se,wrapStyles:ve,emptySelect:ye,searchInputPlaceholder:he,onSelectedRender:ge,onSelectorRender:Ie,pickerStyles:be,pickerPosition:Oe,onDynamicSearchOptions:_e,onDynamicSearchOptionsDelay:we}=J,T=Z(J,["tone","required","form","className","multiSelect","enableFormSubmit","showInitValidation","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","emptySelect","searchInputPlaceholder","onSelectedRender","onSelectorRender","pickerStyles","pickerPosition","onDynamicSearchOptions","onDynamicSearchOptionsDelay"]),W="SearchInput_"+e.componentId;return F(()=>{var b;if(e.disabled||!o.isPickerOpen||a.isExist(d))return;let k=R.FilterSelectableOptions(t.val_options,i,!1);m(((b=k[0])==null?void 0:b.id)||"")},[i]),F(()=>{if(o.eventType!="init"&&o.eventType!="override"&&e.max==o.rawValue.length){s(""),n(k=>f(l({},k),{eventID:v(8),isPickerOpen:!1}));return}},[o.rawValue]),F(()=>{let k="autocomplete-click-"+e.componentId;if(!o.isPickerOpen){a(document).removeEvent([k]);return}a('[data-input-origin="'+e.componentId+'"]')&&a(document).onEvent("mousedown",U=>{let j=a(U.target),Y=!!a(j).parent("."+L("Core")).length,ee=!!a(j).parent("."+L("Selector")).length;Y||ee||n(te=>f(l({},te),{eventID:v(8),isFocusing:!1,isPickerOpen:!1}))},{eventID:k,passive:!1})},[o.isPickerOpen]),V(N,{children:[c(X,f(l({tabIndex:-1},T),{"data-disabled":e.disabled,"data-show-validation":z.isShowValidation(o,!!S),"data-component-id":o.componentId,"data-input-origin":o.componentId,"data-focus":o.isFocusing||o.isPickerOpen,className:[r,L("Core")].join(" "),onClick:k=>{if(T!=null&&T.onClick&&(T==null||T.onClick(k)),e.disabled)return;let b=document.activeElement;(b==null?void 0:b.id)!=W&&(oe.get().isTouchDevice||a("#"+W).focus()),n(U=>f(l({},U),{eventID:v(8),isPickerOpen:!0,isFocusing:!0}))},onKeyDown:k=>{let b=document.activeElement;(b==null?void 0:b.id)!=W&&(k.preventDefault(),a("#"+W).focus())},children:V(M.Left,{gap:0,children:[c(ie,{"data-input-value-shallow":o.componentId,width:0,overflow:"hidden",opacity:"trans",children:"A"}),V(M.Left,{flexWrap:!0,flexSizing:0,gap:"1/4",verticalAlign:"unset",xcss:{letterSpacing:".5px"},children:[c(R.Selected,l({},t)),c(R.SearchInput,l({},t))]}),o.rawValue.length>1&&c($.Clear,{tabIndex:-1,color:"nega",fontColor:"4.thin",ssSphere:2,onClick:k=>{n(b=>f(l({},b),{eventType:"update",eventID:v(8),rawValue:[]}))},children:c(B.X,{})})]})})),c(R.Picker,l({},t))]})},SearchInput:t=>{let{rootStates:e,val_status:i,set_status:s}=t;if(e.disabled)return null;let d=!!i.isFocusing||!!i.isPickerOpen||!!i.rawValue.length;i.isFocusing||e.multiSelect||i.rawValue.length&&(d=!1);let m=e.searchInputPlaceholder||"\u691C\u7D22...";return c(X,{htmlTag:"input",id:"SearchInput_"+e.componentId,placeholder:m,opacity:d?"max":"trans",transition:"middle",flexSizing:0,fontSize:"inherit",border:"0.trans",backgroundColor:"trans",isRounded:!0,padding:[0,"2/3"],value:t.val_keyword,className:[L("SearchInput"),d&&L("isActive")].join(" "),xcss:{outline:"none",minWidth:12*4},onFocus:o=>{s(n=>f(l({},n),{eventID:v(8),isFocusing:!0,isPickerOpen:!0}))},onBlur:o=>H(void 0,null,function*(){s(n=>f(l({},n),{eventID:v(8),isFocusing:!1}))}),onCompositionStart:o=>{s(n=>f(l({},n),{eventID:v(8),isComposing:!0}))},onCompositionEnd:o=>{s(n=>f(l({},n),{eventID:v(8),isComposing:!1}))},onKeyDown:o=>{let{key:n,metaKey:p,ctrlKey:h}=o,O=p||h;n=="Escape"?s(r=>f(l({},r),{eventID:v(12),isPickerOpen:!1})):n=="Tab"?s(r=>f(l({},r),{eventID:v(8),isFocusing:!1,isPickerOpen:!1})):n==" "?a.scope(()=>{i.isPickerOpen||t.val_keyword||(o.preventDefault(),s(r=>f(l({},r),{eventID:v(8),isPickerOpen:!0})))}):n=="Backspace"?a.scope(()=>{if(t.val_keyword)return;let r=[...t.val_status.rawValue];r.pop(),O&&(r=[]),s(u=>f(l({},u),{rawValue:r,eventType:"update",eventID:v(8),isInspected:!1}))}):n=="Enter"&&a.scope(()=>{if(i.isComposing||(o==null?void 0:o.keyCode)===229)return;if(!i.isPickerOpen){s(y=>f(l({},y),{eventID:v(8),isPickerOpen:!0}));return}if(!t.val_optionFocused)return;let r=t.val_options.find(y=>(y==null?void 0:y.id)==t.val_optionFocused);if(!r)return;let{value:u}=r;s(y=>{let S=[...y.rawValue];return a.scope(()=>{if(u===null)return S=[];y.rawValue.includes(u)?S=S.filter(I=>I!==u):e.multiSelect?S.push(u):S=[u]}),f(l({},y),{rawValue:S,eventType:"update",eventID:v(8),isInspected:!1})}),t.set_optionsModified(!0),t.set_keyword("")}),a.scope(()=>{if(!a.isOneOf(n,"ArrowDown","ArrowUp"))return;if(o.preventDefault(),!i.isPickerOpen){s(g=>f(l({},g),{eventID:v(8),isPickerOpen:!0}));return}let r=n=="ArrowDown"?1:-1,u=R.FilterSelectableOptions(t.val_options,t.val_keyword),y=u.length-1,S=null;a.scope(()=>{var I,x,C,P,E,w,D;let g=u.findIndex(_=>(_==null?void 0:_.id)==t.val_optionFocused);if(g==-1){S=(I=u[0])==null?void 0:I.id;return}if(r==1){if(S=(x=u[0])==null?void 0:x.id,O){S=(C=u[y])==null?void 0:C.id;return}if(g==-1||g==y)return;S=(P=u[g+1])==null?void 0:P.id}else{if(S=(E=u[y])==null?void 0:E.id,O){S=(w=u[0])==null?void 0:w.id;return}if(g==-1||g==0)return;S=(D=u[g-1])==null?void 0:D.id}}),t.set_optionFocused(S)}),e.enableFormSubmit&&z.SubmitForm(o,t.rootStates.form)},onChange:o=>{let p=o.target.value;t.set_keyword(p),t.set_optionFocused(""),p&&s(h=>f(l({},h),{eventID:v(8),isPickerOpen:!0}))}},"searchInput")},Picker:t=>{var n;let{rootStates:e,val_status:i}=t,[s,d]=A("idle");F(()=>{if(!e.onDynamicSearchOptions||!i.isPickerOpen)return;if(t.val_optionsModified)return t.set_optionsModified(!1);if(i.isComposing)return;d("fetch");let p="autocomplete-search-"+e.componentId;t.set_optionFocused(""),a.interval.once(()=>H(void 0,null,function*(){var r;let h=yield e.onDynamicSearchOptions(t.val_keyword);d("idle");let O=R.InitOptions(h||[]);t.set_options(O),t.set_optionFocused(((r=O[0])==null?void 0:r.id)||"")}),e.onDynamicSearchOptionsDelay||500,p)},[t.val_keyword,i.isComposing]),F(()=>{let p=a(`[data-selector-id="${i.componentId}"]`)[0];if(!p)return;let h=a(`[data-autocomplete-input-value="${t.val_optionFocused}"]`)[0];h&&(p.scrollTop=h.offsetTop-24)},[t.val_optionFocused]);let m=R.FilterSelectableOptions(t.val_options,e.onDynamicSearchOptions?"":t.val_keyword,!0),o={};{let p=e.pickerPosition||0;a.isOneOf(p,1,2)?o.bottom="100%":a.isOneOf(p,3,4)&&(o.top="100%"),a.isOneOf(p,1,3)?o.left=0:a.isOneOf(p,2,4)&&(o.right=0)}return i.isPickerOpen?c(X,f(l({position:"absolute",ssZIndex:1e3,padding:"1/3"},o),{xcss:l({minWidth:"75%"},o.xcss),children:c(ae.Body,f(l({className:L("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,tabIndex:-1,boxShadow:"1.normal",overflow:"auto","data-selector-id":i.componentId},e.pickerStyles),{xcss:l({maxHeight:12*24},(n=e.pickerStyles)==null?void 0:n.xcss),children:V(q,{gap:"1/12",padding:[1,0],children:[s=="fetch"&&c(M.Center,{padding:"1/2",children:c(le.Theme.R,{showInitial:!0})}),s!="fetch"&&V(N,{children:[!m.length&&c(K.Mini,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"}),m.map((p,h)=>{if(!p)return null;let{type:O,value:r}=p,u=t.val_optionFocused==p.id,y=i.rawValue.includes(r),S=e.onSelectorRender;return c(q,{"data-autocomplete-input-value":p.id,children:c(S,{option:p,isFocused:u,isSelected:y,onAdd:()=>{t.set_status(g=>{let I=[...g.rawValue];return a.scope(()=>{if(r===null)return I=[];if(g.rawValue.includes(r)){I=I.filter(C=>C!==r);return}e.multiSelect?I.push(r):I=[r]}),f(l({},g),{rawValue:I,eventType:"update",eventID:v(8),isFocusing:e.max!=I.length,isInspected:!1})})},onKeyDown:g=>{let{key:I}=g;I=="Tab"&&(t.set_optionFocused(""),t.set_status(x=>f(l({},x),{eventID:v(8),isPickerOpen:!1,isFocusing:!1})))}})},p.id)})]})]})}))})):null},Selected:t=>{let{rootStates:e,val_status:i,set_status:s,val_optionsDict:d}=t,m=[];return i.rawValue.forEach(o=>{let n=d[a.Stringify(o)];if(!n)return;let p=e.onSelectedRender,h=(n==null?void 0:n.selectedLabel)||(n==null?void 0:n.label);(n==null?void 0:n.value)===null&&(h=""),m.push(c(q,{position:"relative",flexCenter:!0,xcss:{userSelect:"none"},children:c(p,{value:n==null?void 0:n.value,label:h,onRemove:O=>{if(e.disabled)return;let r=[...i.rawValue];r=r.filter(u=>u!==o),s(u=>f(l({},u),{rawValue:r,eventType:"update",eventID:v(8),isInspected:!1,isFocusing:e.max!=r.length,isPickerOpen:!0}))}})},a.Stringify(n==null?void 0:n.value)||v(8)))}),c(N,{children:m})},Core:t=>{var C,P,E;let{value:e}=t,[i,s]=A(!1),[d,m]=A(""),[o,n]=A(t.options),[p,h]=A(((C=t.options.find(w=>{var D;return(w==null?void 0:w.value)===((D=t.value)==null?void 0:D[0])}))==null?void 0:C.id)||((P=t.options[0])==null?void 0:P.id)||""),[O,r]=A({}),[u,y]=A(z.DefaultStatus(t.componentId,e)),S=ne(!1);F(()=>{i||(S.current?n(t.options):S.current=!0)},[a.Stringify((E=t.options)==null?void 0:E.map(w=>w.value))]),F(()=>{if(!o.length)return;let w=[...o],D=l({},O);w.forEach(_=>{(_==null?void 0:_.type)!="label"&&(D[a.Stringify(_==null?void 0:_.value)]=_)}),r(D)},[o]);let g={rootStates:t,val_options:o,set_options:n,val_optionFocused:p,set_optionFocused:h,val_optionsDict:O,set_optionsDict:r,val_optionsModified:i,set_optionsModified:s,val_keyword:d,set_keyword:m,val_status:u,set_status:y},I=!!t.multiSelect;z.CommonEffects({type:I?"autocomplete.multi":"autocomplete.single",states:t,val_status:u,set_status:y,SystemValidation:pe});let x=u.rawValue.length&&u.rawValue[0]!==null||u.isPickerOpen||u.isFocusing;return V(se,{val_status:u,set_status:y,states:t,children:[c(ce,{componentId:t.componentId,fontSize:t.fontSize,required:t.required,label:t.label,isActive:x,val_status:u}),c(R.Button,l({},g))]})}},Q=t=>{let e=l({},t);return e=f(l({value:[],min:0,max:65535,multiSelect:!0,emptySelect:!0,onSelectorRender:i=>{var s;return i.option?((s=i.option)==null?void 0:s.type)=="label"?c(N,{children:i.option.label}):c($.Sub.S,{color:"cloud",tabIndex:-1,backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["2/3",1.5],isActive:i.isFocused,isActiveStyles:{backgroundColor:"cloud"},onClick:i.onAdd,onKeyDown:i.onKeyDown,children:V(M.Left,{gap:"1/2",children:[i.isSelected&&c(B.Check,{fontColor:"theme"}),c(K.Mini,{transition:"short",children:i.option.label})]})}):null},onSelectedRender:i=>V(M.Left,{ssCardBox:!0,borderRadius:"1.tone.primary",fontSize:"1.mini",padding:"1/3",gap:0,children:[c(K,{padding:[0,"1/2"],children:i.label}),c($.Clear,{flexSizing:"none",color:"nega",fontColor:"4.thin",tabIndex:-1,ssSphere:2,onClick:i.onRemove,xcss:{lineHeight:1,aspectRatio:"1/1"},children:c(B.X,{})})]}),pickerPosition:3},e),{xcss:l({cursor:"pointer"},e.xcss)}),e.multiSelect||(e.min=0,e.max=1),e.options=e.options||[],e.emptySelect&&(e.options=[{value:null,label:c(K.Mini,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...e.options]),e.value=a.Arrayify(e.value),e.options=R.InitOptions(e.options),a.isNullish(e.rightIcon)&&(e.rightIcon=c(G,{children:c(B.Search,{})}),e.disabled&&(e.rightIcon=c(G,{fontColor:"5.translucent",children:c(B.Ban,{})}))),e.rightIcon&&(e=l({paddingRight:3},e)),e.leftIcon&&(e=l({paddingLeft:3},e)),c(re,{componentId:e.componentId,children:R.Core,states:ue(e)})};export{Q as Autocomplete,Q as default};
@@ -1 +1 @@
1
- import{b as r,c as f,d as G,e as H}from"../../chunk-C5N2D3ZX.js";import{Fragment as ne,jsx as n,jsxs as m}from"react/jsx-runtime";import{useState as Q,useEffect as Y}from"react";import z,{UUID as b,useStore as ee}from"jmini";import{$$fromRoot as _,ExtractStyles as se}from"../../@utils";import{Box as S,FAI as R,Flex as L,Column as te}from"../../atoms";import{Row as re}from"../../mols";import{Button as W}from"../Button";import j from"../Snackbar";import{OptionalInputWrapper as pe,BoxWrapper as ue,CoreEffects as le,DefaultBoxishStyles as me}from"./core";import ce from"./TextField";import{InputFilerClasses as y}from"../../@styles/componentClasses";import{faCloudArrowUp as de}from"@fortawesome/free-solid-svg-icons/faCloudArrowUp";function fe(e){let{value:t,states:o}=e,{required:c}=o,l=[];return c&&!t.length&&l.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!l.filter(({type:u})=>u=="invalid").length,notice:l}}const ae={List:e=>{let{rootStates:t,val_status:o,set_status:c}=e;if(t.useSystemOnly)return null;let l=t.limit-(o.rawValue||[]).length,u=(o.rawValue||[]).map((p,a)=>n(ae.ListCell,f(r({},e),{index:a,val_file:p}),p.name));l>0&&u.push(n(S,f(r({htmlTag:"label"},t.cellStyles),{className:[t.cellClassName,y("AddButton")].join(" "),"data-component-id":o.componentId,htmlFor:t.id,tabIndex:t.tabIndex,onKeyDown:p=>{let{key:a}=p;t.tabIndex!=-1&&z.isOneOf(a," ","Enter")&&_("#"+t.id).click()},children:m(re.Center,{padding:["1/3",0],children:[n(S,{isRounded:!0,className:y("AddIcon"),children:n(R,{icon:de,className:y("Icon"),fontColor:"theme",fontSize:"4.thirdTitle",backgroundColor:"theme.opa.low",ssSphere:3,padding:"1/2"})}),m(S,{children:[m(S,{fontColor:"theme",fontSize:"2.normal",isSemiBoldFont:!0,children:["\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E(",l,")"]}),n(S,{fontColor:"4.thin",fontSize:"0.xs",isSemiBoldFont:!0,children:"\u30D5\u30A1\u30A4\u30EB\u3092\u30C9\u30ED\u30C3\u30D7"})]})]})}),"AddButton"));let[i]=se(t);return n(te,f(r({flexSizing:"auto"},i),{className:t.className,children:u}))},ListCell:e=>{let{index:t,rootStates:o,val_file:c,val_status:l,set_status:u}=e,{name:i,size:p,type:a}=c,[d,v]=Q(!1),I=b(),J=p.rank(),[K,M]=i.replace(/\s/g,"_").replace(/(.*)\.(.*)$/,"$1 $2").split(" "),s="\u30D5\u30A1\u30A4\u30EB";return a.match(/image/)?s=a.replace(/image\//,""):a.match(/pdf/)?s="PDF":a.match(/csv/)?s="CSV":a.match(/spreadsheet/)?s="SpreadSheet":a.match(/presentation/)?s="PowerPoint":a.match(/word/)?s="Word":a.match(/zip/)?s="Zip":a.match(/powerpoint/)?s="PowerPoint":a.match(/html/)?s="HTML":a.match(/js/)?s="JavaScript":a.match(/css/)?s="CSS":a.match(/text\/plain/)&&(s="\u30C6\u30AD\u30B9\u30C8"),Y(()=>{d&&setTimeout(()=>{_("#"+I).focus()},100)},[d]),m(L,f(r({verticalAlign:"center",flexWrap:!1,gap:1,className:o.cellClassName},o.cellStyles),{children:[n(R.File,{fontSize:"4.thirdTitle",fontColor:"4.thin"}),m(S,{flexSizing:0,children:[n(S,{children:n(L,{verticalAlign:"center",gap:"2/3",flexWrap:!1,className:y("FileName"),children:d?n(ne,{children:m(te,{flexSizing:0,gap:"1/2",children:[m(L,{gap:"2/3",verticalAlign:"center",children:[n(ce,{tone:"border",wrapStyles:{flexSizing:"auto"},restrict:"fileName",name:"name",required:!0,id:I,form:"form-"+I,enableFormSubmit:!0,value:K,onKeyDown:F=>{let{key:B}=F;B=="Escape"&&v(!1)}}),m(S,{children:[". ",M]})]}),m(L,{gap:"2/3",horizontalAlign:"right",flexWrap:!1,children:[n(W.Sub.S,{padding:["2/3",1],onClick:()=>{v(!1)},children:"\u9589\u3058\u308B"}),n(W.Prime.S,{padding:["2/3",1],onFormSubmit:["form-"+I,F=>H(void 0,null,function*(){let{name:B}=F.body,w=[...l.rawValue],N=w[t],X=N.id;if(!N)return;let P=yield String(yield N.convert("dataURL")).toBlob(c.type);if(!P)return;let $=new File([P],B+"."+M,{type:N.type});$.id=X,w[t]=$,u(O=>f(r({},O),{rawValue:w,eventType:"update",eventID:b(12),isInspected:!1})),v(!1)})],children:"\u6C7A\u5B9A"})]})]})}):m(ne,{children:[i,!!o.isNameEditable&&n(W.Clear,{ssSphere:2.5,flexSizing:"none",fontColor:"4.thin",padding:"1/3",ssEffectsOnActive:"expand",color:"cloud",onClick:()=>{v(!0)},children:n(R.Pen,{})})]})})}),!d&&m(S,{fontSize:"1.mini",fontColor:"4.thin",flexSizing:0,children:[s,"\u30D5\u30A1\u30A4\u30EB / ",J,"B"]})]}),n(W.Sub,{color:"cloud",fontColor:"4.thin",ssSphere:3,onClick:()=>{let F=[...l.rawValue];F[t]&&(F.splice(t,1),u(w=>f(r({},w),{rawValue:F,eventType:"update",eventID:b(12),isInspected:!1})))},children:n(R.X,{})})]}))}},ge=e=>{let Z=e,{tone:t,required:o,form:c,isNameEditable:l,useSystemOnly:u,accept:i="*",limit:p=1,showInitValidation:a,onChange:d,onValidate:v,onValidateDelay:I,onUpdateValue:J,onUpdateValidValue:K,onUserAction:M,value:s=[],className:F,cellStyles:B,cellClassName:w,componentId:N,status_id:X,enableFormSubmit:oe,xcss:P,wrapStyles:$}=Z,O=G(Z,["tone","required","form","isNameEditable","useSystemOnly","accept","limit","showInitValidation","onChange","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","className","cellStyles","cellClassName","componentId","status_id","enableFormSubmit","xcss","wrapStyles"]),[T,A]=Q(le.DefaultStatus(e.componentId||"",s)),ie={rootStates:e,val_status:T,set_status:A};Y(()=>{ee.set({["AddFiles-"+T.componentId]:x=>{A(D=>{let C=D.rawValue,V=[];for(var g=0;g<(x==null?void 0:x.length);g++){let h=x[g],{type:k,name:E}=h;if(g+1+C.length>p){j.add({componentId:E,secondsToClose:12e3,children:`\u30D5\u30A1\u30A4\u30EB\u9078\u629E\u4E0A\u9650\u3092\u8D85\u3048\u305F\u305F\u3081\u3001${E}}\u306F\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3002`,backgroundColor:"nega"});continue}if(i&&i=="image"&&!k.match(/image/)){j.add({componentId:E,secondsToClose:12e3,children:`\u30D5\u30A1\u30A4\u30EB\u5F62\u5F0F\u304C\u7570\u306A\u308B\u305F\u3081\u3001${E} \u306F\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3002`,backgroundColor:"nega"});continue}V.push(h)}return f(r({},D),{rawValue:[...C,...V],eventType:"update",eventID:b(12),isInspected:!1})})}})},[]),le.CommonEffects({type:"file",states:e,val_status:T,set_status:A,SystemValidation:fe});let U="";return i&&(i=="image"?U="image/png,image/jpeg":U=i),m(ue,{val_status:T,set_status:A,states:e,children:[n(S,f(r({htmlTag:"input",type:"file",className:y("Input"),"data-component-id":T.componentId,accept:U,multiple:p!=1,onChange:x=>H(void 0,null,function*(){d&&d(x);let D=x.target,C=D.files,V=[];for(var g=0;g<(C==null?void 0:C.length);g++){if(!C[g])continue;let h=C[g].clone(),k=h.name;if(h.id=b(),g+1+T.rawValue.length>p){j.add({componentId:k,secondsToClose:12e3,children:`\u30D5\u30A1\u30A4\u30EB\u767B\u9332\u6570\u3092\u8D85\u3048\u305F\u305F\u3081\u3001${k}}\u306F\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002`,backgroundColor:"nega"});continue}V.push(h)}A(h=>f(r({},h),{rawValue:[...h.rawValue,...V],eventType:"update",eventID:b(12),isInspected:!1})),D.value=""})},O),{opacity:"low",tabIndex:-1,value:""})),n(ae.List,r({},ie))]})},q=e=>(e=f(r({limit:1,isNameEditable:!0,useSystemOnly:!1,tone:"border",value:[]},e),{override:"force",cellStyles:r(r({},me({tone:e.tone||"border"})),e.cellStyles)}),n(pe,{componentId:e.componentId,children:ge,states:e}));q.fn={openDialog:e=>{let{multiple:t,accept:o}=e,c=b();const l=document.createElement("input");l.type="file",l.multiple=!!t,l.value="",l.id=c,o&&(o=="image"?l.accept="image/png,image/jpeg,image/jpg,image/webp":l.accept=o),z("body").append(l),l.onchange=u=>{var a;let i=((a=u==null?void 0:u.target)==null?void 0:a.files)||[];if(!(i!=null&&i.length))return;let p=[];for(let d=0;d<i.length;d++){let I=i[d].clone();p.push(I)}e.onChange(p),z("#"+c).remove()},l.click()}},typeof window!="undefined"&&window.document&&z(document).onEvent("dragover",e=>{e.preventDefault(),_("."+y("AddButton")).addClass(y("Draggable"))},{passive:!1}).onEvent("drop",e=>{e.preventDefault(),_("."+y("AddButton")).removeClass(y("Draggable"));let t=e.dataTransfer.files;if(t.length){let o=e.target;if(_(o).hasClass(y("AddButton"))){let{componentId:c}=o.dataset,l=ee.get("AddFiles-"+c);l&&l(t)}}},{passive:!1});export{q as Filer,q as default};
1
+ import{b as r,c as f,d as G,e as H}from"../../chunk-C5N2D3ZX.js";import{Fragment as ne,jsx as n,jsxs as m}from"react/jsx-runtime";import{useState as Q,useEffect as Y}from"react";import z,{UUID as b,useStore as ee}from"jmini";import{$$fromRoot as _,ExtractStyles as se}from"../../@utils";import{Box as h,FAI as L,Flex as R,Column as te}from"../../atoms";import{Literal as re,Row as pe}from"../../mols";import{Button as M}from"../Button";import j from"../Snackbar";import{OptionalInputWrapper as ue,BoxWrapper as me,CoreEffects as le,DefaultBoxishStyles as ce}from"./core";import de from"./TextField";import{InputFilerClasses as y}from"../../@styles/componentClasses";import{faCloudArrowUp as fe}from"@fortawesome/free-solid-svg-icons/faCloudArrowUp";function ge(e){let{value:t,states:o}=e,{required:c}=o,l=[];return c&&!t.length&&l.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!l.filter(({type:u})=>u=="invalid").length,notice:l}}const ae={List:e=>{let{rootStates:t,val_status:o,set_status:c}=e;if(t.useSystemOnly)return null;let l=t.limit-(o.rawValue||[]).length,u=(o.rawValue||[]).map((p,a)=>n(ae.ListCell,f(r({},e),{index:a,val_file:p}),p.name));l>0&&u.push(n(h,f(r({htmlTag:"label"},t.cellStyles),{className:[t.cellClassName,y("AddButton")].join(" "),"data-component-id":o.componentId,htmlFor:t.id,tabIndex:t.tabIndex,onKeyDown:p=>{let{key:a}=p;t.tabIndex!=-1&&z.isOneOf(a," ","Enter")&&_("#"+t.id).click()},children:m(pe.Center,{padding:["1/3",0],children:[n(h,{isRounded:!0,className:y("AddIcon"),children:n(L,{icon:fe,className:y("Icon"),fontColor:"theme",fontSize:"4.thirdTitle",backgroundColor:"theme.opa.low",ssSphere:3,padding:"1/2"})}),m(h,{children:[m(h,{fontColor:"theme",fontSize:"2.normal",isSemiBoldFont:!0,children:["\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E(",l,")"]}),n(re.Micro,{fontColor:"4.thin",isSemiBoldFont:!0,children:"\u30D5\u30A1\u30A4\u30EB\u3092\u30C9\u30ED\u30C3\u30D7"})]})]})}),"AddButton"));let[i]=se(t);return n(te,f(r({flexSizing:"auto"},i),{className:t.className,children:u}))},ListCell:e=>{let{index:t,rootStates:o,val_file:c,val_status:l,set_status:u}=e,{name:i,size:p,type:a}=c,[d,v]=Q(!1),I=b(),J=p.rank(),[K,W]=i.replace(/\s/g,"_").replace(/(.*)\.(.*)$/,"$1 $2").split(" "),s="\u30D5\u30A1\u30A4\u30EB";return a.match(/image/)?s=a.replace(/image\//,""):a.match(/pdf/)?s="PDF":a.match(/csv/)?s="CSV":a.match(/spreadsheet/)?s="SpreadSheet":a.match(/presentation/)?s="PowerPoint":a.match(/word/)?s="Word":a.match(/zip/)?s="Zip":a.match(/powerpoint/)?s="PowerPoint":a.match(/html/)?s="HTML":a.match(/js/)?s="JavaScript":a.match(/css/)?s="CSS":a.match(/text\/plain/)&&(s="\u30C6\u30AD\u30B9\u30C8"),Y(()=>{d&&setTimeout(()=>{_("#"+I).focus()},100)},[d]),m(R,f(r({verticalAlign:"center",flexWrap:!1,gap:1,className:o.cellClassName},o.cellStyles),{children:[n(L.File,{fontSize:"4.thirdTitle",fontColor:"4.thin"}),m(h,{flexSizing:0,children:[n(h,{children:n(R,{verticalAlign:"center",gap:"2/3",flexWrap:!1,className:y("FileName"),children:d?n(ne,{children:m(te,{flexSizing:0,gap:"1/2",children:[m(R,{gap:"2/3",verticalAlign:"center",children:[n(de,{tone:"border",wrapStyles:{flexSizing:"auto"},restrict:"fileName",name:"name",required:!0,id:I,form:"form-"+I,enableFormSubmit:!0,value:K,onKeyDown:F=>{let{key:B}=F;B=="Escape"&&v(!1)}}),m(h,{children:[". ",W]})]}),m(R,{gap:"2/3",horizontalAlign:"right",flexWrap:!1,children:[n(M.Sub.S,{padding:["2/3",1],onClick:()=>{v(!1)},children:"\u9589\u3058\u308B"}),n(M.Prime.S,{padding:["2/3",1],onFormSubmit:["form-"+I,F=>H(void 0,null,function*(){let{name:B}=F.body,w=[...l.rawValue],N=w[t],X=N.id;if(!N)return;let P=yield String(yield N.convert("dataURL")).toBlob(c.type);if(!P)return;let $=new File([P],B+"."+W,{type:N.type});$.id=X,w[t]=$,u(O=>f(r({},O),{rawValue:w,eventType:"update",eventID:b(12),isInspected:!1})),v(!1)})],children:"\u6C7A\u5B9A"})]})]})}):m(ne,{children:[i,!!o.isNameEditable&&n(M.Clear,{ssSphere:2.5,flexSizing:"none",fontColor:"4.thin",padding:"1/3",ssEffectsOnActive:"expand",color:"cloud",onClick:()=>{v(!0)},children:n(L.Pen,{})})]})})}),!d&&m(h,{fontSize:"1.mini",fontColor:"4.thin",flexSizing:0,children:[s,"\u30D5\u30A1\u30A4\u30EB / ",J,"B"]})]}),n(M.Sub,{color:"cloud",fontColor:"4.thin",ssSphere:3,onClick:()=>{let F=[...l.rawValue];F[t]&&(F.splice(t,1),u(w=>f(r({},w),{rawValue:F,eventType:"update",eventID:b(12),isInspected:!1})))},children:n(L.X,{})})]}))}},ye=e=>{let Z=e,{tone:t,required:o,form:c,isNameEditable:l,useSystemOnly:u,accept:i="*",limit:p=1,showInitValidation:a,onChange:d,onValidate:v,onValidateDelay:I,onUpdateValue:J,onUpdateValidValue:K,onUserAction:W,value:s=[],className:F,cellStyles:B,cellClassName:w,componentId:N,status_id:X,enableFormSubmit:oe,xcss:P,wrapStyles:$}=Z,O=G(Z,["tone","required","form","isNameEditable","useSystemOnly","accept","limit","showInitValidation","onChange","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","className","cellStyles","cellClassName","componentId","status_id","enableFormSubmit","xcss","wrapStyles"]),[T,A]=Q(le.DefaultStatus(e.componentId||"",s)),ie={rootStates:e,val_status:T,set_status:A};Y(()=>{ee.set({["AddFiles-"+T.componentId]:x=>{A(D=>{let C=D.rawValue,V=[];for(var g=0;g<(x==null?void 0:x.length);g++){let S=x[g],{type:k,name:E}=S;if(g+1+C.length>p){j.add({componentId:E,secondsToClose:12e3,children:`\u30D5\u30A1\u30A4\u30EB\u9078\u629E\u4E0A\u9650\u3092\u8D85\u3048\u305F\u305F\u3081\u3001${E}}\u306F\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3002`,backgroundColor:"nega"});continue}if(i&&i=="image"&&!k.match(/image/)){j.add({componentId:E,secondsToClose:12e3,children:`\u30D5\u30A1\u30A4\u30EB\u5F62\u5F0F\u304C\u7570\u306A\u308B\u305F\u3081\u3001${E} \u306F\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3002`,backgroundColor:"nega"});continue}V.push(S)}return f(r({},D),{rawValue:[...C,...V],eventType:"update",eventID:b(12),isInspected:!1})})}})},[]),le.CommonEffects({type:"file",states:e,val_status:T,set_status:A,SystemValidation:ge});let U="";return i&&(i=="image"?U="image/png,image/jpeg":U=i),m(me,{val_status:T,set_status:A,states:e,children:[n(h,f(r({htmlTag:"input",type:"file",className:y("Input"),"data-component-id":T.componentId,accept:U,multiple:p!=1,onChange:x=>H(void 0,null,function*(){d&&d(x);let D=x.target,C=D.files,V=[];for(var g=0;g<(C==null?void 0:C.length);g++){if(!C[g])continue;let S=C[g].clone(),k=S.name;if(S.id=b(),g+1+T.rawValue.length>p){j.add({componentId:k,secondsToClose:12e3,children:`\u30D5\u30A1\u30A4\u30EB\u767B\u9332\u6570\u3092\u8D85\u3048\u305F\u305F\u3081\u3001${k}}\u306F\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002`,backgroundColor:"nega"});continue}V.push(S)}A(S=>f(r({},S),{rawValue:[...S.rawValue,...V],eventType:"update",eventID:b(12),isInspected:!1})),D.value=""})},O),{opacity:"low",tabIndex:-1,value:""})),n(ae.List,r({},ie))]})},q=e=>(e=f(r({limit:1,isNameEditable:!0,useSystemOnly:!1,tone:"border",value:[]},e),{override:"force",cellStyles:r(r({},ce({tone:e.tone||"border"})),e.cellStyles)}),n(ue,{componentId:e.componentId,children:ye,states:e}));q.fn={openDialog:e=>{let{multiple:t,accept:o}=e,c=b();const l=document.createElement("input");l.type="file",l.multiple=!!t,l.value="",l.id=c,o&&(o=="image"?l.accept="image/png,image/jpeg,image/jpg,image/webp":l.accept=o),z("body").append(l),l.onchange=u=>{var a;let i=((a=u==null?void 0:u.target)==null?void 0:a.files)||[];if(!(i!=null&&i.length))return;let p=[];for(let d=0;d<i.length;d++){let I=i[d].clone();p.push(I)}e.onChange(p),z("#"+c).remove()},l.click()}},typeof window!="undefined"&&window.document&&z(document).onEvent("dragover",e=>{e.preventDefault(),_("."+y("AddButton")).addClass(y("Draggable"))},{passive:!1}).onEvent("drop",e=>{e.preventDefault(),_("."+y("AddButton")).removeClass(y("Draggable"));let t=e.dataTransfer.files;if(t.length){let o=e.target;if(_(o).hasClass(y("AddButton"))){let{componentId:c}=o.dataset,l=ee.get("AddFiles-"+c);l&&l(t)}}},{passive:!1});export{q as Filer,q as default};
@@ -1 +1 @@
1
- import{b as n,c as u,d as K}from"../../chunk-C5N2D3ZX.js";import{Fragment as te,jsx as o,jsxs as w}from"react/jsx-runtime";import c,{UUID as v}from"jmini";import{useState as Q,useEffect as q}from"react";import{Box as V,FAI as Y,Column as ve}from"../../atoms";import{Literal as H,Row as $}from"../../mols";import{Button as Ie}from"../Button";import{Sheet as be}from"../Sheet";import{OptionalInputWrapper as ge,BoxWrapper as ke,CoreEffects as P,DefaultBoxishStyles as he}from"./core";import{InputAutocompleteClasses as R}from"../../@styles/componentClasses";import{InputLabel as Oe}from"./Label";import{RightIcon as we}from".";function xe(t){let{value:e,states:a}=t,{required:d,options:p}=a,s=[];return d&&e===null&&s.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!s.filter(({type:I})=>I=="invalid").length,notice:s}}const k={FilterSelectableOptions:(t,e)=>{let a=t.rootStates.options;return e||(a=a.filter(d=>(d==null?void 0:d.type)!="label")),a},Button:t=>w(te,{children:[o(k.Native,n({},t)),o(k.Original,n({},t))]}),Placeholder:t=>!t.rootStates.placeholder||t.val_status.rawValue!==null?null:o(V,{position:"absolute",opacity:"middle",fontColor:"3.blur",children:t.rootStates.placeholder||""}),Native:t=>{let{rootStates:e,val_status:a,set_status:d}=t,T=e,{tone:p,required:s,form:I,className:r,label:b,isLabelActive:m,placeholder:h,enableFormSubmit:g,emptySelect:D,showInitValidation:B,onValidate:L,onValidateDelay:z,onUpdateValue:le,onUpdateValidValue:ae,onUserAction:ne,onKeyDown:W,onChange:_,value:re="",options:M,leftIndicator:ie,rightIndicator:se,leftIcon:oe,rightIcon:ue,componentId:ce,status_id:de,wrapStyles:pe,selectedStyles:fe,selectorStyles:Se,pickerStyles:me,pickerPosition:ye,nativePicker:E}=T,i=K(T,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","showInitValidation","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","onKeyDown","onChange","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","selectedStyles","selectorStyles","pickerStyles","pickerPosition","nativePicker"]);return E?w(V,u(n({htmlTag:"select",tabIndex:0},i),{"data-disabled":e.disabled,"data-show-validation":P.isShowValidation(a,!!B),"data-component-id":a.componentId,"data-input-origin":a.componentId,className:[r,R("Core")].join(" "),onKeyDown:l=>{W&&W(l),g&&P.SubmitForm(l,I)},onChange:l=>{let{value:S}=l.target;d(C=>u(n({},C),{rawValue:S,eventType:"update",eventID:v(12),isInspected:!1,isValidated:!1,notice:[]})),_&&_(l)},children:[!!D&&o("option",{value:"null",children:"\u9078\u629E"}),M.map(l=>c.isNullish(l==null?void 0:l.value)?null:o("option",{value:l==null?void 0:l.value,children:(l==null?void 0:l.label)||(l==null?void 0:l.value)},String(l==null?void 0:l.value)))]})):null},Original:t=>{let{rootStates:e,val_optionFocused:a,set_optionFocused:d,val_status:p,set_status:s}=t,T=e,{tone:I,required:r,form:b,className:m,label:h,isLabelActive:g,placeholder:D,enableFormSubmit:B,emptySelect:L,showInitValidation:z,onValidate:le,onValidateDelay:ae,onUpdateValue:ne,onUpdateValidValue:W,onUserAction:_,value:re="",options:M,leftIndicator:ie,rightIndicator:se,leftIcon:oe,rightIcon:ue,componentId:ce,status_id:de,wrapStyles:pe,selectedStyles:fe,selectorStyles:Se,pickerStyles:me,pickerPosition:ye,nativePicker:E}=T,i=K(T,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","showInitValidation","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","selectedStyles","selectorStyles","pickerStyles","pickerPosition","nativePicker"]);return q(()=>{if(E||e.disabled)return;let l="select-click-"+e.componentId;if(p.isPickerOpen){if(!c('[data-input-origin="'+e.componentId+'"]'))return;c(document).onEvent("click",C=>{let F=c(C.target),A=!!c(F).parent("."+R("Core")).length;c(F).parent("."+R("Selector")).length||A||s(f=>u(n({},f),{eventID:v(12),isPickerOpen:!1}))},{eventID:l})}else c(document).removeEvent([l])},[p.isPickerOpen]),E?null:w(te,{children:[o(V,u(n({tabIndex:0},i),{"data-disabled":e.disabled,"data-show-validation":P.isShowValidation(p,!!z),"data-component-id":p.componentId,"data-input-origin":p.componentId,className:[m,R("Core")].join(" "),onFocus:l=>{i!=null&&i.onFocus&&(i==null||i.onFocus(l)),!e.disabled&&s(S=>u(n({},S),{eventID:v(12),isFocusing:!0,isPickerOpen:!0}))},onBlur:l=>{i!=null&&i.onBlur&&(i==null||i.onBlur(l)),s(S=>u(n({},S),{eventID:v(12),isFocusing:!1}))},onClick:l=>{i!=null&&i.onClick&&(i==null||i.onClick(l)),!e.disabled&&s(S=>u(n({},S),{eventID:v(12),isPickerOpen:!0}))},onKeyDown:l=>{let{key:S,metaKey:C,ctrlKey:F}=l,A=C||F;if(i!=null&&i.onKeyDown&&(i==null||i.onKeyDown(l)),B&&P.SubmitForm(l,b),!e.disabled){if(c.scope(()=>{if(!c.isOneOf(S,"ArrowDown","ArrowUp"))return;if(l.preventDefault(),!p.isPickerOpen){s(O=>u(n({},O),{eventID:v(12),isPickerOpen:!0}));return}let y=S=="ArrowDown"?1:-1,f=k.FilterSelectableOptions(t),N=f.length-1,x=null;c.scope(()=>{var j,J,X,Z,G;let O=f.findIndex(U=>(U==null?void 0:U.id)==a);if(y==1){if(x=(j=f[0])==null?void 0:j.id,A){x=f[N].id;return}if(O==-1||O==N)return;x=(J=f[O+1])==null?void 0:J.id}else{if(x=(X=f[N])==null?void 0:X.id,A){x=(Z=f[0])==null?void 0:Z.id;return}if(O==-1||O==0)return;x=(G=f[O-1])==null?void 0:G.id}}),d(x)}),S=="Escape")s(y=>u(n({},y),{eventID:v(12),isPickerOpen:!1}));else if(S=="Tab")s(y=>u(n({},y),{eventID:v(12),isPickerOpen:!1}));else if(S=="Backspace")s(y=>u(n({},y),{rawValue:null,eventType:"update",eventID:v(12),isInspected:!1}));else if(S==" ")l.preventDefault(),s(y=>u(n({},y),{eventID:v(12),isPickerOpen:!0}));else if(S=="Enter"){if(!p.isPickerOpen){s(f=>u(n({},f),{eventID:v(12),isPickerOpen:!0}));return}l.preventDefault();let y=e.options.find(f=>(f==null?void 0:f.id)==a);if(!y)return;s(f=>u(n({},f),{rawValue:y==null?void 0:y.value,eventType:"update",eventID:v(12),isPickerOpen:!1,isInspected:!1}))}}},children:w($.Left,{gap:0,children:[o(V,{xcss:{width:0},overflow:"hidden",opacity:"trans","data-input-value-shallow":p.componentId,children:"A"}),w($.Left,{flexWrap:!0,gap:"1/3",xcss:{letterSpacing:".5px"},children:[o(k.Placeholder,n({},t)),o(k.Selected,n({},t))]})]})})),o(k.Picker,n({},t))]})},Picker:t=>{var I;let{rootStates:e,val_status:a,val_optionFocused:d}=t;q(()=>{if(!a.isPickerOpen||!a.rawValue)return;let r=c(`[data-picker-id="${a.componentId}"]`)[0];if(!r)return;let b=r.position(),m=e.options.find(g=>(g==null?void 0:g.value)===a.rawValue);if(!m)return;let h=c(`[data-select-input-value="${m.id}"]`)[0];h&&(r.scrollTop=h.offsetTop-b.height/2+h.offsetHeight/2)},[a.isPickerOpen]),q(()=>{let r=c(`[data-picker-id="${a.componentId}"]`)[0];if(!r)return;let b=r.position(),m=c(`[data-select-input-value="${d}"]`)[0];m&&(r.scrollTop=m.offsetTop-b.height/2+m.offsetHeight/2)},[d]);let p=k.FilterSelectableOptions(t,!0),s={};{let r=e.pickerPosition||0;c.isOneOf(r,1,2)?s.bottom="100%":c.isOneOf(r,3,4)&&(s.top="100%"),c.isOneOf(r,1,3)?s.left=0:c.isOneOf(r,2,4)&&(s.right=0)}return a.isPickerOpen?o(V,u(n({position:"absolute",ssZIndex:1e3,minWidth:1,padding:"1/3"},s),{children:o(be.Body,u(n({className:R("Selector"),ssCardBox:!0,borderRadius:"2.tone.secondary",boxShadow:"1.normal",overflow:"auto","data-picker-id":a.componentId},e.pickerStyles),{xcss:n({minWidth:12*6,maxHeight:12*24},(I=e.pickerStyles)==null?void 0:I.xcss),children:w(ve,{gap:"1/12",padding:[1,0],children:[p.map((r,b)=>{if(!r)return null;let{type:m,value:h}=r,g=t.val_optionFocused==r.id,D=t.val_status.rawValue===h;return m=="label"?o(V,{children:r.label||r.value},v()):o(Ie.Sub.S,u(n({"data-select-input-value":r.id,color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1],isActive:D||g,isActiveStyles:g?{backgroundColor:"cloud"}:{backgroundColor:"theme.opa.few",fontColor:"theme"}},e.selectorStyles),{onClick:B=>{t.set_status(L=>u(n({},L),{rawValue:h,eventType:"update",eventID:v(12),isPickerOpen:!1,isInspected:!1}))},children:w($.Left,{gap:"1/2",children:[D&&o(Y.Check,{fontColor:"theme"}),o(H.Supplement,{transition:"short",flexSizing:0,children:r.label||r.value})]})}),r.id)}),!p.length&&o(H.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]})}))})):null},Selected:t=>{let e=t.rootStates.options.find(a=>c.isEqual(a==null?void 0:a.value,t.val_status.rawValue));return!e||t.val_status.rawValue===null&&(t.rootStates.label||t.rootStates.placeholder)?null:o(V,u(n({},t.rootStates.selectedStyles),{children:(e==null?void 0:e.selectedLabel)||(e==null?void 0:e.label)||(e==null?void 0:e.value)}),String(e==null?void 0:e.value))},Core:t=>{var r,b;let{value:e}=t,[a,d]=Q(P.DefaultStatus(t.componentId,e)),[p,s]=Q(((r=t.options.find(m=>(m==null?void 0:m.value)===t.value))==null?void 0:r.id)||((b=t.options[0])==null?void 0:b.id)||""),I={rootStates:t,val_optionFocused:p,set_optionFocused:s,val_status:a,set_status:d};return P.CommonEffects({type:"select",states:t,val_status:a,set_status:d,SystemValidation:xe}),w(ke,{val_status:a,set_status:d,states:t,children:[o(Oe,{componentId:t.componentId,fontSize:t.fontSize,required:t.required,label:t.label,isActive:t.isLabelActive||a.rawValue!==null,val_status:a}),o(k.Button,n({},I))]})}},ee=t=>{var a,d;let e=n({},t);return e=u(n({emptySelect:!0,nativePicker:!1,pickerPosition:3},e),{xcss:n({cursor:"pointer"},e.xcss)}),e.emptySelect&&(e.options=[{value:null,label:o(H.Supplement,{fontColor:"4.thin",children:"\u672A\u9078\u629E"})},...e.options]),e.value=(a=e.value)!=null?a:null,(d=e.options)==null||d.forEach((p,s)=>{if(!p)return;let{type:I,value:r}=p;e.options[s]=u(n({id:v(12)},p),{value:r,type:I||"selector"})}),c.isNullish(e.rightIcon)&&(e.rightIcon=o(we,{children:o(Y.AngleDown,{})})),o(ge,{componentId:e.componentId,children:k.Core,states:he(e)})};export{ee as Select,ee as default};
1
+ import{b as n,c as u,d as U}from"../../chunk-C5N2D3ZX.js";import{Fragment as te,jsx as o,jsxs as w}from"react/jsx-runtime";import c,{UUID as v}from"jmini";import{useState as Q,useEffect as K}from"react";import{Box as V,FAI as Y,Column as ve}from"../../atoms";import{Literal as q,Row as H}from"../../mols";import{Button as Ie}from"../Button";import{Sheet as be}from"../Sheet";import{OptionalInputWrapper as ge,BoxWrapper as ke,CoreEffects as P,DefaultBoxishStyles as he}from"./core";import{InputAutocompleteClasses as R}from"../../@styles/componentClasses";import{InputLabel as Oe}from"./Label";import{RightIcon as we}from".";function xe(t){let{value:e,states:a}=t,{required:d,options:p}=a,s=[];return d&&e===null&&s.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!s.filter(({type:I})=>I=="invalid").length,notice:s}}const k={FilterSelectableOptions:(t,e)=>{let a=t.rootStates.options;return e||(a=a.filter(d=>(d==null?void 0:d.type)!="label")),a},Button:t=>w(te,{children:[o(k.Native,n({},t)),o(k.Original,n({},t))]}),Placeholder:t=>!t.rootStates.placeholder||t.val_status.rawValue!==null?null:o(V,{position:"absolute",opacity:"middle",fontColor:"3.blur",children:t.rootStates.placeholder||""}),Native:t=>{let{rootStates:e,val_status:a,set_status:d}=t,T=e,{tone:p,required:s,form:I,className:i,label:b,isLabelActive:m,placeholder:h,enableFormSubmit:g,emptySelect:D,showInitValidation:B,onValidate:L,onValidateDelay:$,onUpdateValue:le,onUpdateValidValue:ae,onUserAction:ne,onKeyDown:W,onChange:_,value:ie="",options:z,leftIndicator:re,rightIndicator:se,leftIcon:oe,rightIcon:ue,componentId:ce,status_id:de,wrapStyles:pe,selectedStyles:fe,selectorStyles:Se,pickerStyles:me,pickerPosition:ye,nativePicker:E}=T,r=U(T,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","showInitValidation","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","onKeyDown","onChange","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","selectedStyles","selectorStyles","pickerStyles","pickerPosition","nativePicker"]);return E?w(V,u(n({htmlTag:"select",tabIndex:0},r),{"data-disabled":e.disabled,"data-show-validation":P.isShowValidation(a,!!B),"data-component-id":a.componentId,"data-input-origin":a.componentId,className:[i,R("Core")].join(" "),onKeyDown:l=>{W&&W(l),g&&P.SubmitForm(l,I)},onChange:l=>{let{value:S}=l.target;d(C=>u(n({},C),{rawValue:S,eventType:"update",eventID:v(12),isInspected:!1,isValidated:!1,notice:[]})),_&&_(l)},children:[!!D&&o("option",{value:"null",children:"\u9078\u629E"}),z.map(l=>c.isNullish(l==null?void 0:l.value)?null:o("option",{value:l==null?void 0:l.value,children:(l==null?void 0:l.label)||(l==null?void 0:l.value)},String(l==null?void 0:l.value)))]})):null},Original:t=>{let{rootStates:e,val_optionFocused:a,set_optionFocused:d,val_status:p,set_status:s}=t,T=e,{tone:I,required:i,form:b,className:m,label:h,isLabelActive:g,placeholder:D,enableFormSubmit:B,emptySelect:L,showInitValidation:$,onValidate:le,onValidateDelay:ae,onUpdateValue:ne,onUpdateValidValue:W,onUserAction:_,value:ie="",options:z,leftIndicator:re,rightIndicator:se,leftIcon:oe,rightIcon:ue,componentId:ce,status_id:de,wrapStyles:pe,selectedStyles:fe,selectorStyles:Se,pickerStyles:me,pickerPosition:ye,nativePicker:E}=T,r=U(T,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","showInitValidation","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","selectedStyles","selectorStyles","pickerStyles","pickerPosition","nativePicker"]);return K(()=>{if(E||e.disabled)return;let l="select-click-"+e.componentId;if(p.isPickerOpen){if(!c('[data-input-origin="'+e.componentId+'"]'))return;c(document).onEvent("click",C=>{let F=c(C.target),A=!!c(F).parent("."+R("Core")).length;c(F).parent("."+R("Selector")).length||A||s(f=>u(n({},f),{eventID:v(12),isPickerOpen:!1}))},{eventID:l})}else c(document).removeEvent([l])},[p.isPickerOpen]),E?null:w(te,{children:[o(V,u(n({tabIndex:0},r),{"data-disabled":e.disabled,"data-show-validation":P.isShowValidation(p,!!$),"data-component-id":p.componentId,"data-input-origin":p.componentId,className:[m,R("Core")].join(" "),onFocus:l=>{r!=null&&r.onFocus&&(r==null||r.onFocus(l)),!e.disabled&&s(S=>u(n({},S),{eventID:v(12),isFocusing:!0,isPickerOpen:!0}))},onBlur:l=>{r!=null&&r.onBlur&&(r==null||r.onBlur(l)),s(S=>u(n({},S),{eventID:v(12),isFocusing:!1}))},onClick:l=>{r!=null&&r.onClick&&(r==null||r.onClick(l)),!e.disabled&&s(S=>u(n({},S),{eventID:v(12),isPickerOpen:!0}))},onKeyDown:l=>{let{key:S,metaKey:C,ctrlKey:F}=l,A=C||F;if(r!=null&&r.onKeyDown&&(r==null||r.onKeyDown(l)),B&&P.SubmitForm(l,b),!e.disabled){if(c.scope(()=>{if(!c.isOneOf(S,"ArrowDown","ArrowUp"))return;if(l.preventDefault(),!p.isPickerOpen){s(O=>u(n({},O),{eventID:v(12),isPickerOpen:!0}));return}let y=S=="ArrowDown"?1:-1,f=k.FilterSelectableOptions(t),N=f.length-1,x=null;c.scope(()=>{var j,J,X,Z,G;let O=f.findIndex(M=>(M==null?void 0:M.id)==a);if(y==1){if(x=(j=f[0])==null?void 0:j.id,A){x=f[N].id;return}if(O==-1||O==N)return;x=(J=f[O+1])==null?void 0:J.id}else{if(x=(X=f[N])==null?void 0:X.id,A){x=(Z=f[0])==null?void 0:Z.id;return}if(O==-1||O==0)return;x=(G=f[O-1])==null?void 0:G.id}}),d(x)}),S=="Escape")s(y=>u(n({},y),{eventID:v(12),isPickerOpen:!1}));else if(S=="Tab")s(y=>u(n({},y),{eventID:v(12),isPickerOpen:!1}));else if(S=="Backspace")s(y=>u(n({},y),{rawValue:null,eventType:"update",eventID:v(12),isInspected:!1}));else if(S==" ")l.preventDefault(),s(y=>u(n({},y),{eventID:v(12),isPickerOpen:!0}));else if(S=="Enter"){if(!p.isPickerOpen){s(f=>u(n({},f),{eventID:v(12),isPickerOpen:!0}));return}l.preventDefault();let y=e.options.find(f=>(f==null?void 0:f.id)==a);if(!y)return;s(f=>u(n({},f),{rawValue:y==null?void 0:y.value,eventType:"update",eventID:v(12),isPickerOpen:!1,isInspected:!1}))}}},children:w(H.Left,{gap:0,children:[o(V,{xcss:{width:0},overflow:"hidden",opacity:"trans","data-input-value-shallow":p.componentId,children:"A"}),w(H.Left,{flexWrap:!0,gap:"1/3",xcss:{letterSpacing:".5px"},children:[o(k.Placeholder,n({},t)),o(k.Selected,n({},t))]})]})})),o(k.Picker,n({},t))]})},Picker:t=>{var I;let{rootStates:e,val_status:a,val_optionFocused:d}=t;K(()=>{if(!a.isPickerOpen||!a.rawValue)return;let i=c(`[data-picker-id="${a.componentId}"]`)[0];if(!i)return;let b=i.position(),m=e.options.find(g=>(g==null?void 0:g.value)===a.rawValue);if(!m)return;let h=c(`[data-select-input-value="${m.id}"]`)[0];h&&(i.scrollTop=h.offsetTop-b.height/2+h.offsetHeight/2)},[a.isPickerOpen]),K(()=>{let i=c(`[data-picker-id="${a.componentId}"]`)[0];if(!i)return;let b=i.position(),m=c(`[data-select-input-value="${d}"]`)[0];m&&(i.scrollTop=m.offsetTop-b.height/2+m.offsetHeight/2)},[d]);let p=k.FilterSelectableOptions(t,!0),s={};{let i=e.pickerPosition||0;c.isOneOf(i,1,2)?s.bottom="100%":c.isOneOf(i,3,4)&&(s.top="100%"),c.isOneOf(i,1,3)?s.left=0:c.isOneOf(i,2,4)&&(s.right=0)}return a.isPickerOpen?o(V,u(n({position:"absolute",ssZIndex:1e3,minWidth:1,padding:"1/3"},s),{children:o(be.Body,u(n({className:R("Selector"),ssCardBox:!0,borderRadius:"2.tone.secondary",boxShadow:"1.normal",overflow:"auto","data-picker-id":a.componentId},e.pickerStyles),{xcss:n({minWidth:12*6,maxHeight:12*24},(I=e.pickerStyles)==null?void 0:I.xcss),children:w(ve,{gap:"1/12",padding:[1,0],children:[p.map((i,b)=>{if(!i)return null;let{type:m,value:h}=i,g=t.val_optionFocused==i.id,D=t.val_status.rawValue===h;return m=="label"?o(V,{children:i.label||i.value},v()):o(Ie.Sub.S,u(n({"data-select-input-value":i.id,color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1],isActive:D||g,isActiveStyles:g?{backgroundColor:"cloud"}:{backgroundColor:"theme.opa.few",fontColor:"theme"}},e.selectorStyles),{onClick:B=>{t.set_status(L=>u(n({},L),{rawValue:h,eventType:"update",eventID:v(12),isPickerOpen:!1,isInspected:!1}))},children:w(H.Left,{gap:"1/2",children:[D&&o(Y.Check,{fontColor:"theme"}),o(q.Mini,{transition:"short",flexSizing:0,children:i.label||i.value})]})}),i.id)}),!p.length&&o(q.Mini,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]})}))})):null},Selected:t=>{let e=t.rootStates.options.find(a=>c.isEqual(a==null?void 0:a.value,t.val_status.rawValue));return!e||t.val_status.rawValue===null&&(t.rootStates.label||t.rootStates.placeholder)?null:o(V,u(n({},t.rootStates.selectedStyles),{children:(e==null?void 0:e.selectedLabel)||(e==null?void 0:e.label)||(e==null?void 0:e.value)}),String(e==null?void 0:e.value))},Core:t=>{var i,b;let{value:e}=t,[a,d]=Q(P.DefaultStatus(t.componentId,e)),[p,s]=Q(((i=t.options.find(m=>(m==null?void 0:m.value)===t.value))==null?void 0:i.id)||((b=t.options[0])==null?void 0:b.id)||""),I={rootStates:t,val_optionFocused:p,set_optionFocused:s,val_status:a,set_status:d};return P.CommonEffects({type:"select",states:t,val_status:a,set_status:d,SystemValidation:xe}),w(ke,{val_status:a,set_status:d,states:t,children:[o(Oe,{componentId:t.componentId,fontSize:t.fontSize,required:t.required,label:t.label,isActive:t.isLabelActive||a.rawValue!==null,val_status:a}),o(k.Button,n({},I))]})}},ee=t=>{var a,d;let e=n({},t);return e=u(n({emptySelect:!0,nativePicker:!1,pickerPosition:3},e),{xcss:n({cursor:"pointer"},e.xcss)}),e.emptySelect&&(e.options=[{value:null,label:o(q.Mini,{fontColor:"4.thin",children:"\u672A\u9078\u629E"})},...e.options]),e.value=(a=e.value)!=null?a:null,(d=e.options)==null||d.forEach((p,s)=>{if(!p)return;let{type:I,value:i}=p;e.options[s]=u(n({id:v(12)},p),{value:i,type:I||"selector"})}),c.isNullish(e.rightIcon)&&(e.rightIcon=o(we,{children:o(Y.AngleDown,{})})),o(ge,{componentId:e.componentId,children:k.Core,states:he(e)})};export{ee as Select,ee as default};
@@ -1 +1 @@
1
- import{b as d,c as h,d as F,e as P}from"../../chunk-C5N2D3ZX.js";import{Fragment as ee,jsx as m,jsxs as C}from"react/jsx-runtime";import x,{UUID as E}from"jmini";import{useState as W,useEffect as K}from"react";import{$$fromRoot as _,GenerateHTMLProps as $}from"../../@utils";import{Box as b,Flex as q,Column as z}from"../../atoms";import{Literal as O}from"../../mols";import{Button as Y}from"../Button";import{OptionalInputWrapper as G,BoxWrapper as j,CoreEffects as X}from"./core";import{InputSliderClasses as V}from"../../@styles/componentClasses";function Q(e){let{value:n,states:t}=e,{required:o}=t,a=[],[l,r]=x.Arrayify(n);return o&&!l&&!r&&a.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!a.filter(({type:i})=>i=="invalid").length,notice:a}}const f={getOffsetLeft:e=>{let{trackMin:n,min:t,max:o,value:a}=e,l=(a-(n!=null?n:t))/(o-(n!=null?n:t));return Math.min(l,1)*100},normalize:e=>{let{min:n,max:t,step:o,value:a}=e;a=Math.max(a,n),a=Math.min(a,t);let l=Math.round(a/o)*o;return{value:l,offsetLeft:f.getOffsetLeft(h(d({},e),{value:l}))}},Effects:{Start:(e,n)=>{let t=x.getCursor(e).x,{val_status:o}=n,{componentId:a}=o,l=_("#"+a+"_Bar"),{width:r,left:i}=l.position(),c=(t-i)/r;c=Math.max(c,0),c=Math.min(c,1);let u=c*o.max;x(document).onEvent("mousemove",p=>{f.Effects.Move(p,n,u)},{eventID:"SliderMouseMove",passive:!1}).onEvent("touchmove",p=>{f.Effects.Move(p,n,u)},{eventID:"SliderTouchMove",passive:!1}).onEvent("mouseup",()=>{f.Effects.End()},{eventID:"SliderMouseUp"}).onEvent("touchend",()=>{f.Effects.End()},{eventID:"SliderTouchEnd"})},Move:(e,n,t)=>{var I;let o=x.getCursor(e).x,{val_status:a}=n,{componentId:l}=a,r=_("#"+l+"_Bar"),{width:i,left:c}=r.position(),u=(o-c)/i;u=Math.max(u,0),u=Math.min(u,1);let p=(I=a.trackMin)!=null?I:a.min,v=u*(a.max-p)+p,S=f.normalize(h(d({},a),{value:v})).value,s=Math.round(v-t);return n.onChange(S,s),e.preventDefault(),e.stopPropagation(),!1},End:()=>{x(document).removeEvent(["SliderMouseMove","SliderTouchMove","SliderMouseUp","SliderTouchEnd"])}},Rail:e=>{let{rootStates:n,val_status:t,set_status:o}=e,{componentId:a}=t,l=2;n.size=="small"?l=1.5:n.size=="large"&&(l=2.5);let r=[f.normalize(h(d({},t),{value:t.safeValue[0]})),f.normalize(h(d({},t),{value:t.safeValue[1]||0}))];const i=(c,u)=>{let{min:p,max:v,step:g}=t;c=Math.max(Math.min(c,v),p),o(S=>{let s=d({},S);return s.safeValue[u]==c?s:(s.safeValue[u]=c,t.ranged&&s.safeValue[0]>s.safeValue[1]&&(s.safeValue=[s.safeValue[1],s.safeValue[0]]),h(d({},s),{rawValue:s.ranged?s.safeValue:s.safeValue[0],eventType:"update",eventID:E(12),isInspected:!1}))})};return m(z,{padding:[1,"1/2"],onPointerDown:c=>{e.rootStates.disabled||(c.stopPropagation(),!t.ranged&&f.Effects.Start(c,{val_status:t,onChange:u=>{i(u,0)}}))},children:C(b,{className:V("Bar"),height:0,position:"relative",transition:"middle",flexSizing:"none",id:a+"_Bar",children:[m(b,{position:"absolute",isRounded:!0,backgroundColor:"cloud",xcss:{top:-2*l,left:-2*l,right:-2*l,bottom:-2*l}}),m(f.Range,{rootStates:n,val_status:t,set_status:o,formatData:r,onUpdateValue:i}),m(f.DiscreteScale,{rootStates:n,val_status:t}),m(f.Edge,{focusIndex:0,rootStates:n,val_status:t,set_status:o,formatData:r[0],onUpdateValue:i}),t.ranged&&m(f.Edge,{focusIndex:1,rootStates:n,val_status:t,set_status:o,formatData:r[1],onUpdateValue:i})]})})},DiscreteScale:e=>{let{rootStates:n,val_status:t}=e;if(!n.discreteScale)return null;let{trackMin:o,min:a,max:l,step:r}=t,i=Math.round(a/r),u=Math.round(l/r)-i+1,p=0,v=t.safeValue[0]||0;return t.ranged&&(p=t.safeValue[0]||0,v=t.safeValue[1]||0),m(ee,{children:Array.from({length:u},(g,S)=>S+i).map(g=>{let S=g*r;S=Math.max(S,a),S=Math.min(S,l);let s=f.getOffsetLeft(h(d({},t),{value:S}))+"%",I=x.isInRange(S,p,v);return m(z,{gap:0,position:"absolute",verticalAlign:"center",horizontalAlign:"center",width:0,height:0,transition:"middle",fontColor:"1.clear",xcss:{pointerEvents:"none",top:"50%",left:s,transform:"translateY(-50%)"},children:m(b,{isRounded:!0,backgroundColor:I?"layer.0":"gray",ssSphere:"1/4"})},S)})})},Range:e=>{let{rootStates:n,formatData:t,val_status:o}=e,a=2;return n.size=="small"?a=1.5:n.size=="large"&&(a=2.5),C(b,{className:V("Range"),position:"absolute",transition:"middle",xcss:d({cursor:"pointer",top:"50%",transform:"translateY(-50%)"},o.ranged?{left:t[0].offsetLeft+"%",width:t[1].offsetLeft-t[0].offsetLeft+"%"}:{left:0,width:(t[0].offsetLeft||0)+"%"}),onPointerDown:l=>{if(!e.rootStates.disabled){if(l.stopPropagation(),o.ranged){let[r,i]=o.safeValue;l.stopPropagation(),f.Effects.Start(l,{val_status:o,onChange:(c,u)=>{e.set_status(p=>{let v=p.safeValue,g=d({},p);return g.safeValue=[f.normalize(h(d({},o),{value:r+u})).value,f.normalize(h(d({},o),{value:i+u})).value],g.safeValue[0]==v[0]&&g.safeValue[1]==v[1]?h(d({},p),{eventType:"update",eventID:E(12)}):h(d({},g),{rawValue:g.ranged?g.safeValue:g.safeValue[0],eventType:"update",eventID:E(12),isInspected:!1})})}});return}f.Effects.Start(l,{val_status:o,onChange:r=>{e.onUpdateValue(r,0)}})}},children:[m(b,{className:V("Field"),transition:"middle",position:"absolute",isRounded:!0,backgroundColor:n.color,xcss:{top:-6*a,bottom:-6*a,left:-6*a,right:-6*a}}),m(b,{className:V("Child"),transition:"middle",position:"absolute",isRounded:!0,backgroundColor:n.color,xcss:{pointerEvents:"none",top:-2*a,left:-2*a,right:-2*a,bottom:-2*a}})]})},Edge:e=>{let{formatData:n,rootStates:t,val_status:o,set_status:a}=e,l=2;return t.size=="small"?l=1.5:t.size=="large"&&(l=2.5),C(Y.Plain,{className:V("Edge"),position:"absolute",transition:"middle",height:0,width:0,flexCenter:!0,xcss:{left:n.offsetLeft+"%"},onPointerDown:r=>{e.rootStates.disabled||e.focusIndex==1&&!o.ranged||(r.stopPropagation(),f.Effects.Start(r,{val_status:o,onChange:i=>{e.onUpdateValue(i,e.focusIndex)}}))},onKeyDown:r=>{t.enableFormSubmit&&X.SubmitForm(r,t.form);let{min:i,max:c,step:u}=o,{key:p,metaKey:v,ctrlKey:g}=r,S=g||v,s=o.safeValue[e.focusIndex];if(!p.match(/Arrow/))return;r.preventDefault(),p.match(/Left|Up/)?S?s=i:s-=u:p.match(/Right|Down/)&&(S?s=c:s+=u);let I=f.normalize(h(d({},o),{value:s}));e.onUpdateValue(I.value,e.focusIndex)},onFocus:r=>{a(i=>h(d({},i),{eventID:E(12),isFocusing:!0}))},onBlur:r=>{a(i=>h(d({},i),{eventID:E(12),isFocusing:!1}))},children:[m(b,{className:V("EdgeChild"),transition:"middle",position:"absolute",backgroundColor:t.color,isRounded:!0,opacity:"trans",xcss:{pointerEvents:"all",top:-12*l,bottom:-12*l,left:-12*l,right:-12*l}}),m(b,{transition:"long",boxShadow:"1.remark",fontSize:"0.xs",backgroundColor:!o.ranged||e.focusIndex==1?t.color:"layer.0",ssSphere:l,xcss:{pointerEvents:"all"}})]})},Legends:e=>{var g;let{val_status:n,rootStates:t}=e,{trackMin:o,min:a,max:l,step:r}=n,[i]=W(E()),c=(g=t.legends)!=null?g:!0,u=Math.round(a/r),p=Math.round(l/r),v=p-u+1;return K(()=>{if(!c)return;const S=()=>P(void 0,null,function*(){yield x.pending(100);let s=_("#"+i),I=_("#"+i+"-"+a),T=s.position().width-I.position().left,B=12*4,k=Math.round(T/B),U=Math.max(1,Math.floor(v/k));for(let y=u;y<=p;y++){let D=y*r,A=y==u||y==p||y%U==0;_("#"+i+"-"+D).css({display:A?"flex":"none"})}});return x(window).onEvent("resize",S,{eventID:"SliderResizeCB-"+i}),S(),()=>{x(window).removeEvent("SliderResizeCB-"+i)}},[]),c?C(q,{fontSize:"0.xs",position:"relative",padding:[0,"1/2"],id:i,xcss:{pointerEvents:"none",userSelect:"none"},children:[C(z,{gap:0,unitWidth:0,opacity:"trans",children:[m(b,{unitHeight:"1/2"}),m(O.Supplement,{fontHeight:1.2,children:"A"})]}),Array.from({length:v},(S,s)=>s+u).map(S=>{let s=S*r;s=Math.max(s,a),s=Math.min(s,l);let I=f.getOffsetLeft(h(d({},n),{value:s}))+"%";return C(z,{gap:0,id:i+"-"+s,className:V("Legend"),position:"relative",verticalAlign:"center",unitWidth:0,display:"none",transition:"middle",fontColor:"1.clear",textAlign:"center",xcss:{left:I,whiteSpace:"nowrap"},children:[m(b,{isRounded:!0,backgroundColor:"mono.positive",opacity:"low",unitWidth:"1/12",unitHeight:"1/2"}),m(O.Supplement,{fontHeight:1.2,fontSize:"0.xs",children:t.onLegendRender?t.onLegendRender(s):s.rank()})]},s)})]}):null},index:e=>{let N=e,{color:n="theme",required:t,form:o="",discreteScale:a,size:l,ranged:r,legends:i,onLegendRender:c,trackMin:u,min:p,max:v,step:g,enableFormSubmit:S,showInitValidation:s,onValidate:I,onValidateDelay:T,onUpdateValue:B,onUpdateValidValue:k,onUserAction:U,value:y=0,className:D,wrapStyles:A}=N,J=F(N,["color","required","form","discreteScale","size","ranged","legends","onLegendRender","trackMin","min","max","step","enableFormSubmit","showInitValidation","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","className","wrapStyles"]),[L,w]=W({componentId:e.componentId||"",rawValue:y,safeValue:x.Arrayify(y),ranged:!!r,trackMin:Math.min(u!=null?u:p,p),min:p,max:v,step:g,eventType:"init",eventID:E(12)});return X.CommonEffects({type:"slider",states:e,val_status:L,set_status:w,SystemValidation:Q,ExtraOverrideStates:H=>({safeValue:x.Arrayify(H)})}),m(j,{val_status:L,set_status:w,states:e,children:C(z,h(d({gap:0,padding:[0,"1/2"],flexSizing:"auto"},J),{className:[D,V("Wrap")].join(" "),children:[m(f.Rail,{rootStates:e,val_status:L,set_status:w}),m(f.Legends,{rootStates:e,val_status:L})]}))})}},M=e=>{let n=h(d({color:"theme",size:"medium",discreteScale:!0},e),{xcss:d({minWidth:120},e.xcss)});return m(G,{componentId:e.componentId,children:f.index,states:$(n)})},R=M;R.Small=e=>m(M,d({size:"small"},e)),R.Medium=e=>m(M,d({size:"medium"},e)),R.Large=e=>m(M,d({size:"large"},e));const Z=e=>m(M,d({ranged:!0},e));R.Range=Z,R.Range.Small=e=>m(M,d({ranged:!0,size:"small"},e)),R.Range.Medium=e=>m(M,d({ranged:!0,size:"medium"},e)),R.Range.Large=e=>m(M,d({ranged:!0,size:"large"},e));export{R as Slider,R as default};
1
+ import{b as d,c as h,d as F,e as P}from"../../chunk-C5N2D3ZX.js";import{Fragment as ee,jsx as m,jsxs as C}from"react/jsx-runtime";import x,{UUID as E}from"jmini";import{useState as W,useEffect as K}from"react";import{$$fromRoot as _,GenerateHTMLProps as $}from"../../@utils";import{Box as b,Flex as q,Column as z}from"../../atoms";import{Literal as O}from"../../mols";import{Button as Y}from"../Button";import{OptionalInputWrapper as G,BoxWrapper as j,CoreEffects as X}from"./core";import{InputSliderClasses as M}from"../../@styles/componentClasses";function Q(e){let{value:n,states:t}=e,{required:l}=t,a=[],[o,r]=x.Arrayify(n);return l&&!o&&!r&&a.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!a.filter(({type:i})=>i=="invalid").length,notice:a}}const f={getOffsetLeft:e=>{let{trackMin:n,min:t,max:l,value:a}=e,o=(a-(n!=null?n:t))/(l-(n!=null?n:t));return Math.min(o,1)*100},normalize:e=>{let{min:n,max:t,step:l,value:a}=e;a=Math.max(a,n),a=Math.min(a,t);let o=Math.round(a/l)*l;return{value:o,offsetLeft:f.getOffsetLeft(h(d({},e),{value:o}))}},Effects:{Start:(e,n)=>{let t=x.getCursor(e).x,{val_status:l}=n,{componentId:a}=l,o=_("#"+a+"_Bar"),{width:r,left:i}=o.position(),c=(t-i)/r;c=Math.max(c,0),c=Math.min(c,1);let u=c*l.max;x(document).onEvent("mousemove",p=>{f.Effects.Move(p,n,u)},{eventID:"SliderMouseMove",passive:!1}).onEvent("touchmove",p=>{f.Effects.Move(p,n,u)},{eventID:"SliderTouchMove",passive:!1}).onEvent("mouseup",()=>{f.Effects.End()},{eventID:"SliderMouseUp"}).onEvent("touchend",()=>{f.Effects.End()},{eventID:"SliderTouchEnd"})},Move:(e,n,t)=>{var I;let l=x.getCursor(e).x,{val_status:a}=n,{componentId:o}=a,r=_("#"+o+"_Bar"),{width:i,left:c}=r.position(),u=(l-c)/i;u=Math.max(u,0),u=Math.min(u,1);let p=(I=a.trackMin)!=null?I:a.min,v=u*(a.max-p)+p,S=f.normalize(h(d({},a),{value:v})).value,s=Math.round(v-t);return n.onChange(S,s),e.preventDefault(),e.stopPropagation(),!1},End:()=>{x(document).removeEvent(["SliderMouseMove","SliderTouchMove","SliderMouseUp","SliderTouchEnd"])}},Rail:e=>{let{rootStates:n,val_status:t,set_status:l}=e,{componentId:a}=t,o=2;n.size=="small"?o=1.5:n.size=="large"&&(o=2.5);let r=[f.normalize(h(d({},t),{value:t.safeValue[0]})),f.normalize(h(d({},t),{value:t.safeValue[1]||0}))];const i=(c,u)=>{let{min:p,max:v,step:g}=t;c=Math.max(Math.min(c,v),p),l(S=>{let s=d({},S);return s.safeValue[u]==c?s:(s.safeValue[u]=c,t.ranged&&s.safeValue[0]>s.safeValue[1]&&(s.safeValue=[s.safeValue[1],s.safeValue[0]]),h(d({},s),{rawValue:s.ranged?s.safeValue:s.safeValue[0],eventType:"update",eventID:E(12),isInspected:!1}))})};return m(z,{padding:[1,"1/2"],onPointerDown:c=>{e.rootStates.disabled||(c.stopPropagation(),!t.ranged&&f.Effects.Start(c,{val_status:t,onChange:u=>{i(u,0)}}))},children:C(b,{className:M("Bar"),height:0,position:"relative",transition:"middle",flexSizing:"none",id:a+"_Bar",children:[m(b,{position:"absolute",isRounded:!0,backgroundColor:"cloud",xcss:{top:-2*o,left:-2*o,right:-2*o,bottom:-2*o}}),m(f.Range,{rootStates:n,val_status:t,set_status:l,formatData:r,onUpdateValue:i}),m(f.DiscreteScale,{rootStates:n,val_status:t}),m(f.Edge,{focusIndex:0,rootStates:n,val_status:t,set_status:l,formatData:r[0],onUpdateValue:i}),t.ranged&&m(f.Edge,{focusIndex:1,rootStates:n,val_status:t,set_status:l,formatData:r[1],onUpdateValue:i})]})})},DiscreteScale:e=>{let{rootStates:n,val_status:t}=e;if(!n.discreteScale)return null;let{trackMin:l,min:a,max:o,step:r}=t,i=Math.round(a/r),u=Math.round(o/r)-i+1,p=0,v=t.safeValue[0]||0;return t.ranged&&(p=t.safeValue[0]||0,v=t.safeValue[1]||0),m(ee,{children:Array.from({length:u},(g,S)=>S+i).map(g=>{let S=g*r;S=Math.max(S,a),S=Math.min(S,o);let s=f.getOffsetLeft(h(d({},t),{value:S}))+"%",I=x.isInRange(S,p,v);return m(z,{gap:0,position:"absolute",verticalAlign:"center",horizontalAlign:"center",width:0,height:0,transition:"middle",fontColor:"1.clear",xcss:{pointerEvents:"none",top:"50%",left:s,transform:"translateY(-50%)"},children:m(b,{isRounded:!0,backgroundColor:I?"layer.0":"gray",ssSphere:"1/4"})},S)})})},Range:e=>{let{rootStates:n,formatData:t,val_status:l}=e,a=2;return n.size=="small"?a=1.5:n.size=="large"&&(a=2.5),C(b,{className:M("Range"),position:"absolute",transition:"middle",xcss:d({cursor:"pointer",top:"50%",transform:"translateY(-50%)"},l.ranged?{left:t[0].offsetLeft+"%",width:t[1].offsetLeft-t[0].offsetLeft+"%"}:{left:0,width:(t[0].offsetLeft||0)+"%"}),onPointerDown:o=>{if(!e.rootStates.disabled){if(o.stopPropagation(),l.ranged){let[r,i]=l.safeValue;o.stopPropagation(),f.Effects.Start(o,{val_status:l,onChange:(c,u)=>{e.set_status(p=>{let v=p.safeValue,g=d({},p);return g.safeValue=[f.normalize(h(d({},l),{value:r+u})).value,f.normalize(h(d({},l),{value:i+u})).value],g.safeValue[0]==v[0]&&g.safeValue[1]==v[1]?h(d({},p),{eventType:"update",eventID:E(12)}):h(d({},g),{rawValue:g.ranged?g.safeValue:g.safeValue[0],eventType:"update",eventID:E(12),isInspected:!1})})}});return}f.Effects.Start(o,{val_status:l,onChange:r=>{e.onUpdateValue(r,0)}})}},children:[m(b,{className:M("Field"),transition:"middle",position:"absolute",isRounded:!0,backgroundColor:n.color,xcss:{top:-6*a,bottom:-6*a,left:-6*a,right:-6*a}}),m(b,{className:M("Child"),transition:"middle",position:"absolute",isRounded:!0,backgroundColor:n.color,xcss:{pointerEvents:"none",top:-2*a,left:-2*a,right:-2*a,bottom:-2*a}})]})},Edge:e=>{let{formatData:n,rootStates:t,val_status:l,set_status:a}=e,o=2;return t.size=="small"?o=1.5:t.size=="large"&&(o=2.5),C(Y.Plain,{className:M("Edge"),position:"absolute",transition:"middle",height:0,width:0,flexCenter:!0,xcss:{left:n.offsetLeft+"%"},onPointerDown:r=>{e.rootStates.disabled||e.focusIndex==1&&!l.ranged||(r.stopPropagation(),f.Effects.Start(r,{val_status:l,onChange:i=>{e.onUpdateValue(i,e.focusIndex)}}))},onKeyDown:r=>{t.enableFormSubmit&&X.SubmitForm(r,t.form);let{min:i,max:c,step:u}=l,{key:p,metaKey:v,ctrlKey:g}=r,S=g||v,s=l.safeValue[e.focusIndex];if(!p.match(/Arrow/))return;r.preventDefault(),p.match(/Left|Up/)?S?s=i:s-=u:p.match(/Right|Down/)&&(S?s=c:s+=u);let I=f.normalize(h(d({},l),{value:s}));e.onUpdateValue(I.value,e.focusIndex)},onFocus:r=>{a(i=>h(d({},i),{eventID:E(12),isFocusing:!0}))},onBlur:r=>{a(i=>h(d({},i),{eventID:E(12),isFocusing:!1}))},children:[m(b,{className:M("EdgeChild"),transition:"middle",position:"absolute",backgroundColor:t.color,isRounded:!0,opacity:"trans",xcss:{pointerEvents:"all",top:-12*o,bottom:-12*o,left:-12*o,right:-12*o}}),m(b,{transition:"long",boxShadow:"1.remark",fontSize:"0.xs",backgroundColor:!l.ranged||e.focusIndex==1?t.color:"layer.0",ssSphere:o,xcss:{pointerEvents:"all"}})]})},Legends:e=>{var g;let{val_status:n,rootStates:t}=e,{trackMin:l,min:a,max:o,step:r}=n,[i]=W(E()),c=(g=t.legends)!=null?g:!0,u=Math.round(a/r),p=Math.round(o/r),v=p-u+1;return K(()=>{if(!c)return;const S=()=>P(void 0,null,function*(){yield x.pending(100);let s=_("#"+i),I=_("#"+i+"-"+a),T=s.position().width-I.position().left,B=12*4,k=Math.round(T/B),U=Math.max(1,Math.floor(v/k));for(let y=u;y<=p;y++){let D=y*r,A=y==u||y==p||y%U==0;_("#"+i+"-"+D).css({display:A?"flex":"none"})}});return x(window).onEvent("resize",S,{eventID:"SliderResizeCB-"+i}),S(),()=>{x(window).removeEvent("SliderResizeCB-"+i)}},[]),c?C(q,{fontSize:"0.xs",position:"relative",padding:[0,"1/2"],id:i,xcss:{pointerEvents:"none",userSelect:"none"},children:[C(z,{gap:0,unitWidth:0,opacity:"trans",children:[m(b,{unitHeight:"1/2"}),m(O.Mini,{fontHeight:1.2,children:"A"})]}),Array.from({length:v},(S,s)=>s+u).map(S=>{let s=S*r;s=Math.max(s,a),s=Math.min(s,o);let I=f.getOffsetLeft(h(d({},n),{value:s}))+"%";return C(z,{gap:0,id:i+"-"+s,className:M("Legend"),position:"relative",verticalAlign:"center",unitWidth:0,display:"none",transition:"middle",fontColor:"1.clear",textAlign:"center",xcss:{left:I,whiteSpace:"nowrap"},children:[m(b,{isRounded:!0,backgroundColor:"mono.positive",opacity:"low",unitWidth:"1/12",unitHeight:"1/2"}),m(O.Micro,{fontHeight:1.2,children:t.onLegendRender?t.onLegendRender(s):s.rank()})]},s)})]}):null},index:e=>{let N=e,{color:n="theme",required:t,form:l="",discreteScale:a,size:o,ranged:r,legends:i,onLegendRender:c,trackMin:u,min:p,max:v,step:g,enableFormSubmit:S,showInitValidation:s,onValidate:I,onValidateDelay:T,onUpdateValue:B,onUpdateValidValue:k,onUserAction:U,value:y=0,className:D,wrapStyles:A}=N,J=F(N,["color","required","form","discreteScale","size","ranged","legends","onLegendRender","trackMin","min","max","step","enableFormSubmit","showInitValidation","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","className","wrapStyles"]),[L,w]=W({componentId:e.componentId||"",rawValue:y,safeValue:x.Arrayify(y),ranged:!!r,trackMin:Math.min(u!=null?u:p,p),min:p,max:v,step:g,eventType:"init",eventID:E(12)});return X.CommonEffects({type:"slider",states:e,val_status:L,set_status:w,SystemValidation:Q,ExtraOverrideStates:H=>({safeValue:x.Arrayify(H)})}),m(j,{val_status:L,set_status:w,states:e,children:C(z,h(d({gap:0,padding:[0,"1/2"],flexSizing:"auto"},J),{className:[D,M("Wrap")].join(" "),children:[m(f.Rail,{rootStates:e,val_status:L,set_status:w}),m(f.Legends,{rootStates:e,val_status:L})]}))})}},V=e=>{let n=h(d({color:"theme",size:"medium",discreteScale:!0},e),{xcss:d({minWidth:120},e.xcss)});return m(G,{componentId:e.componentId,children:f.index,states:$(n)})},R=V;R.Small=e=>m(V,d({size:"small"},e)),R.Medium=e=>m(V,d({size:"medium"},e)),R.Large=e=>m(V,d({size:"large"},e));const Z=e=>m(V,d({ranged:!0},e));R.Range=Z,R.Range.Small=e=>m(V,d({ranged:!0,size:"small"},e)),R.Range.Medium=e=>m(V,d({ranged:!0,size:"medium"},e)),R.Range.Large=e=>m(V,d({ranged:!0,size:"large"},e));export{R as Slider,R as default};
@@ -1 +1 @@
1
- import{b as p,c as S}from"../../../chunk-C5N2D3ZX.js";import{Fragment as $,jsx as e,jsxs as f}from"react/jsx-runtime";import C,{UUID as O,Time as d,useStore as W}from"jmini";import{useState as D,useEffect as F}from"react";import{Box as x,Grid as J,FAI as B,Column as L,FlexMargin as P}from"../../../atoms";import{Row as g,Literal as y}from"../../../mols";import{Button as M}from"../../Button";import _ from"../../Sheet";import Y from"../Select";import{LeftIcon as X,RightIcon as N}from"..";import{InputTimeClasses as V}from"../../../@styles/componentClasses";import R from"../Drum";const j=t=>{let{restrict:i}=t;return i=="year"?e(c.Year,p({},t)):i=="month"?e(c.Month,p({},t)):i=="week"?"[DEV]":i=="date"?e(c.Date,p({},t)):i=="locale.jp.warekiDate"?e(c.Locale.JP.WarekiDate,p({},t)):i=="clock"?e(c.Clock,p({},t)):i=="period.clock"?e(c.Period.Clock,p({},t)):i=="period.month"?e(c.Period.Month,p({},t)):i=="period.date"?e(c.Period.Date,p({},t)):null},c={YearOptions:t=>{var m,n,l;let i=[],h=(m=t==null?void 0:t.min)!=null?m:1900,r=(n=t==null?void 0:t.max)!=null?n:d().addYear(10).year;for(let a=h;a<=r;a++){let o=[a],[s,u]=C.transformer.wareki(a).value;((l=t.showJPWareki)==null||l)&&(s&&o.push(e(y.Supplement,{fontSize:"0.xs",fontColor:"4.thin",children:s},1)),u&&o.push(f(y.Supplement,{fontSize:"0.xs",fontColor:"4.thin",children:["[",u,"]"]},2))),i[t.reverse?"unshift":"push"]({value:a,label:e(g.Center,{gap:["1/12","1/4"],verticalAlign:"baseline",flexWrap:!0,children:o})})}return i},calendartypeState:()=>{let[t,i]=D(localStorage.getItem("@env/input/time/selector/calendartype")||"calendar");return F(()=>{localStorage.setItem("@env/input/time/selector/calendartype",String(t))},[t]),[t,i]},minutesUnitState:()=>{let[t,i]=D(Number(localStorage.getItem("@env/input/time/selector/clock/minutesUnit")||10));return F(()=>{localStorage.setItem("@env/input/time/selector/clock/minutesUnit",String(t))},[t]),[t,i]},remoteControl:function(t){let{restrict:i,pickerId:h,val_value:r,set_value:m}=t;F(()=>{h&&W.set({[h]:{onClear:()=>{if(i.match(/period\./)){m(n=>S(p({},n),{eventType:"commit",forcus:0,display:d(),from:d(null),to:d(null)}));return}m(n=>S(p({},n),{eventType:"commit",from:d(null)}))},onConfirm:()=>{m(n=>S(p({},n),{eventType:"commit"}))}}})},[])},Year:t=>{let{min:i,max:h}=t,[r,m]=D(C.scope(()=>{let[n]=String(t.defaultValue).split(/\D/);return{eventType:"init",from:d().setYear(Number(n||d().year))}}));return c.remoteControl(S(p({},t),{val_value:r,set_value:m})),F(()=>{t.onValueUpdate({value:String(r.from.year||null),era:"year",eventType:r.eventType})},[r]),f(L,{xcss:{minWidth:12*16},children:[f(g.Left,{flexWrap:!0,children:[f(y.Paragraph,{children:[r.from.year||"----","\u5E74"]}),e(M.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let n=d();m({eventType:"update",from:n})},children:"\u4ECA\u5E74"}),e(P,{})]}),e(x,{borderTop:!0}),e(R,{override:"force",value:r.from.year||null,options:c.YearOptions({min:Number(i)||void 0,max:Number(h)||void 0}),onUpdateValidValue:n=>{m(l=>({eventType:"update",from:l.from.clone().setYear(Number(n))}))}})]})},Month:t=>{let{min:i,max:h}=t,[r,m]=D(C.scope(()=>{let[n,l]=String(t.defaultValue).split(/\D/);(C.isNullish(n)||C.isNullish(l))&&([n,l]=d().toFormat("%Y-%M").split("-"));let a=d(),o=d().setYear(Number(n)||a.year).setMonth(Number(l)||a.month).setDate(1);return{eventType:"init",from:o,display:o}}));return c.remoteControl(S(p({},t),{val_value:r,set_value:m})),F(()=>{t.onValueUpdate({value:r.from.toFormatYM(),era:"year",eventType:r.eventType})},[r]),f(L,{xcss:{minWidth:12*16},children:[f(g.Left,{gap:"1/2",children:[e(y.Paragraph,{children:r.from.toFormatYM("JP")||"----/--"}),e(M.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let n=d();m({eventType:"update",from:n,display:n})},children:"\u4ECA\u6708"}),e(P,{})]}),e(x,{borderTop:!0}),e(c.Parts.DrumSelector,{type:"month",min:i,max:h,value:r.from,onChange:n=>{m(S(p({},r),{eventType:"update",from:n}))}})]})},Date:t=>{let{min:i,max:h}=t,[r,m]=c.calendartypeState(),[n,l]=D(C.scope(()=>{var T;let[a,o,s]=(T=String(t.defaultValue))==null?void 0:T.split(/\D/);(C.isNullish(a)||C.isNullish(o)||C.isNullish(s))&&([a,o,s]=d().toFormat("%Y-%M-%D").split("-"));let u=d(),v=d([Number(a)||u.year,(Number(o)||u.month).zeroEmbed(2),(Number(s)||u.date).zeroEmbed(2)].join("/"));return{eventType:"init",era:"year",display:v,from:v}}));return c.remoteControl(S(p({},t),{val_value:n,set_value:l})),F(()=>{t.onValueUpdate({value:n.from.toFormatYMD(),era:"year",eventType:n.eventType})},[n]),f(L,{xcss:{minWidth:12*16},children:[f(g.Left,{flexWrap:!0,gap:"1/2",children:[e(y.Paragraph,{children:n.from.toFormatYMD("JP")||"----/--/--"}),e(M.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let a=d();l({eventType:"update",era:"year",from:a,display:a})},children:"\u4ECA\u65E5"}),e(P,{}),f(M.Border.S,{padding:["1/6","1/2"],fontColor:"3.blur",fontSize:"0.xs",onClick:()=>{m(a=>a=="calendar"?"drum":"calendar")},children:[r=="calendar"&&"\u30C9\u30E9\u30E0",r=="drum"&&"\u30AB\u30EC\u30F3\u30C0\u30FC","\u8868\u793A"]})]}),e(x,{borderTop:!0}),r=="calendar"&&f($,{children:[f(g.Center,{gap:"1/2",children:[e(Y,{override:"force",emptySelect:!1,value:n.display.year,options:c.YearOptions({reverse:!0}),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,pickerStyles:{xcss:{minWidth:12*12}},onUpdateValidValue:a=>{l(o=>S(p({},o),{eventType:"update",display:o.display.clone().setYear(Number(a))}))},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})})}),e(Y,{override:"force",emptySelect:!1,value:n.display.month,options:(()=>{let a=[];for(let o=1;o<=12;o++)a.push({value:o,label:String(o)+"\u6708"});return a})(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,pickerStyles:{xcss:{minWidth:12*8}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),onUpdateValidValue:a=>{l(o=>S(p({},o),{eventType:"update",display:o.display.clone().setMonth(Number(a))}))}}),e(c.Parts.ShiftButtons,{callback:a=>{l(o=>S(p({},o),{eventType:"update",display:o.display.clone().addMonth(a)}))}})]}),f(L,{children:[e(x,{margin:"auto",xcss:{minWidth:"50%"},UnderBreakPointStyles:{margin:0},children:c.Parts.Calendar({min:i,max:h,onTitleRender:a=>"",targetMonth:n.display,from:n.from,onChange:a=>{l(o=>S(p({},o),{eventType:"update",from:a}))}})}),e(x,{unitHeight:"1/4",isRounded:!0,backgroundColor:"cloud",margin:1,ssHiddenOnBreak:!0}),f(g.Center,{verticalAlign:"unset",ssHiddenOnBreak:!0,children:[e(x,{flexSizing:0,children:c.Parts.Calendar({min:i,max:h,onTitleRender:a=>e(y.Supplement,{children:f(g.Center,{gap:"1/2",children:[e(y,{isSemiBoldFont:!0,children:a.toFormatYM("JP")}),e(y,{fontColor:"4.thin",children:"[\u524D\u6708]"})]})}),targetMonth:n.display.clone().addMonth(-1),from:n.from,onChange:a=>{l(o=>S(p({},o),{eventType:"update",from:a}))}})}),e(x,{unitWidth:"1/4",isRounded:!0,backgroundColor:"cloud",margin:1}),e(x,{flexSizing:0,children:c.Parts.Calendar({min:i,max:h,onTitleRender:a=>e(y.Supplement,{children:f(g.Center,{gap:"1/2",children:[e(y,{isSemiBoldFont:!0,children:a.toFormatYM("JP")}),e(y,{fontColor:"4.thin",children:"[\u7FCC\u6708]"})]})}),targetMonth:n.display.clone().addMonth(1),from:n.from,onChange:a=>{l(o=>S(p({},o),{eventType:"update",from:a}))}})})]})]})]}),r=="drum"&&e(c.Parts.DrumSelector,{type:"date",min:i,max:h,value:n.from,onChange:a=>{l(S(p({},n),{eventType:"update",from:a}))}})]})},Locale:{JP:{WarekiDate:t=>{var l;let{min:i,max:h}=t,[r,m]=D(C.scope(()=>{var b;let[a,o,s]=(b=String(t.defaultValue))==null?void 0:b.split(/\D/),u=t.era||"year";if(C.isNullish(a)||C.isNullish(o)||C.isNullish(s)){let k=d();u=="heisei"?k.setYear(1989):u=="shouwa"?k.setYear(1926):u=="taisho"?k.setYear(1912):u=="meiji"&&k.setYear(1868),[a,o,s]=k.toFormat("%Y-%M-%D").split("-")}let v=d();return{eventType:"init",from:d([Number(a)||v.year,(Number(o)||v.month).zeroEmbed(2),(Number(s)||v.date).zeroEmbed(2)].join("/"))}}));c.remoteControl(S(p({},t),{val_value:r,set_value:m})),F(()=>{t.onValueUpdate({value:r.from.toFormatYMD(),era:r.from.wareki.toLower(),eventType:r.eventType})},[r]);let n={year:{label:"\u897F\u66A6",min:"1900/01/01",max:"2100/12/31"},reiwa:{label:"\u4EE4\u548C",min:"2019/05/01",max:d().addYear(10).setMonth(12).setDate(31).toFormatYMD()},heisei:{label:"\u5E73\u6210",min:"1989/01/08",max:"2019/04/30"},showa:{label:"\u662D\u548C",min:"1926/12/25",max:"1989/01/07"},taisho:{label:"\u5927\u6B63",min:"1912/07/30",max:"1926/12/24"},meiji:{label:"\u660E\u6CBB",min:"1868/09/08",max:"1912/07/29"}};return f(L,{children:[f(g.Left,{gap:"1/4",flexWrap:!0,children:[f(y.Paragraph,{children:[r.from.warekiLabel,(l=r.from.warekiYear)==null?void 0:l.zeroEmbed(2),"\u5E74",r.from.toFormatMD("JP")]}),e(P,{})]}),e(x,{borderTop:!0}),e(g.Left,{gap:"1/2",flexWrap:!0,children:["reiwa","heisei","showa","taisho","meiji"].map((a,o)=>{let s=n[a];return s?e(M.Border.S,{onClick:()=>{let u=r.from;if(a=="reiwa"||a=="year")u=d();else{let v=d(s.min),T=d(s.max);v.value>r.from.value&&(u=v),r.from.value>T.value&&(u=T)}if(i){let v=d(i);u.value<v.value&&(u=v)}if(h){let v=d(h);v.value<u.value&&(u=v)}m(S(p({},r),{eventType:"update",from:u}))},children:s.label},o):null})}),e(c.Parts.DrumSelector,{type:"locale.jp.warekiDate",min:t.min,max:t.max,value:r.from,onChange:a=>{m(S(p({},r),{eventType:"update",from:a}))}})]})}}},Clock:t=>{let[i,h]=D(C.scope(()=>{let o=String(t.defaultValue).split(/[^\d]/);if(!o[0]){let v=d();o=[v.hours,v.minutes]}let s=Number(o[0]),u=Number(o[1]);return{eventType:"init",from:d().setHours(s).setMinutes(u)}}));c.remoteControl(S(p({},t),{val_value:i,set_value:h})),F(()=>{t.onValueUpdate({value:i.from.toFormatHM(),era:"clock",eventType:i.eventType})},[i]);let[r,m]=c.minutesUnitState(),n=d().setFromFormatHHMM(t.min||"00:00"),l=d().setFromFormatHHMM(t.max||"23:59");const a=(o,s)=>{h(u=>{let v=u.from.clone();return C.isExist(o)&&v.setHours(o),C.isExist(s)&&v.setMinutes(s),v.toFormatHM().toNumber()>l.toFormatHM().toNumber()&&(v=l.clone()),v.toFormatHM().toNumber()<n.toFormatHM().toNumber()&&(v=n.clone()),S(p({},u),{eventType:"update",from:v})})};return f(L,{xcss:{minWidth:12*16},children:[f(g.Left,{gap:"1/2",flexWrap:!0,children:[f(g.Center,{gap:"1/2",children:[e(x,{className:V("ClockBase"),children:e(x,{className:V("ClockUiBase"),flexCenter:!0,children:f(x,{className:V("ClockUi"),backgroundColor:"theme.opa.low",isRounded:!0,position:"relative",children:[e(x,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[V("Needle"),V("hour")].join(" "),xcss:{transform:`rotate(${i.from.hours*30+i.from.minutes/2}deg)`}}),e(x,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[V("Needle"),V("minute")].join(" "),xcss:{transform:`rotate(${i.from.minutes*6}deg)`}})]})})}),f(x,{textAlign:"center",fontHeight:1.2,children:[f(y.Paragraph,{children:[i.from.hours.zeroEmbed(2)," : ",i.from.minutes.zeroEmbed(2)]}),f(y.Supplement,{fontColor:"4.thin",children:[i.from.hours>=12&&"PM"||"AM",i.from.hours%12,":",i.from.minutes.zeroEmbed(2)]})]})]}),e(M.Border.XS,{borderRadius:"2.tone.secondary",fontColor:"theme",onClick:()=>{let o=d().setSeconds(0);o.minutes=Math.round(o.minutes/r)*r,a(o.hours,o.minutes)},children:"\u73FE\u6642\u523B"}),e(P,{}),e(Y,{emptySelect:!1,value:r,paddingLeft:3.5,leftIcon:e(X,{left:"2/3",children:"\u5358\u4F4D"}),pickerPosition:4,pickerStyles:{xcss:{minWidth:12*8}},padding:"1/2",options:[{value:10,label:"10\u5206"},{value:5,label:"5\u5206"},{value:1,label:"1\u5206"}],tabIndex:-1,onUpdateValidValue:o=>{m(o||1)}})]}),e(x,{borderTop:!0}),f(g.Center,{gap:"1/2",children:[e(R,{xcss:{maxHeight:12*12},override:"force",options:[{value:0,label:"\u5348\u524D"},{value:12,label:"\u5348\u5F8C"}],value:i.from.hours>=12?12:0,onUpdateValidValue:o=>{let s=i.from.hours%12+o;a(s)}}),e(R,{override:"force",value:i.from.hours,options:Array.from({length:24}).map((o,s)=>{let u=s;return n.hours>u||l.hours<u?null:{value:u,label:u.zeroEmbed(2)}}),onUpdateValidValue:o=>{a(o)}}),e(y,{isSemiBoldFont:!0,children:"\u6642"}),e(R,{override:"force",value:i.from.minutes,options:Array.from({length:60}).map((o,s)=>{let u=s;return u!=59&&(r==5&&u%5!=0||r==10&&u%10!=0)?null:{value:u,label:u.zeroEmbed(2)}}),onUpdateValidValue:o=>{a(void 0,o)}},r),e(y,{isSemiBoldFont:!0,children:"\u5206"})]})]})},Period:{Clock:t=>{let[i,h]=c.minutesUnitState(),[r,m]=D(C.scope(()=>{let[o,s]=C.Arrayify(t.defaultValue),u=d().setFromFormatHHMM(o||"09:00"),v=d().setFromFormatHHMM(s||"18:00");return{eventType:"init",forcus:0,display:u,from:u,to:v}}));c.remoteControl(S(p({},t),{val_value:r,set_value:m})),F(()=>{if(!r.to.value)return;if(r.from.value>r.to.value){m(s=>S(p({},s),{eventType:"update",from:s.to,to:s.from}));return}t.onValueUpdate({value:[r.from.toFormatHM(),r.to.toFormatHM()],era:"clock",eventType:r.eventType})},[r]);let n=d().setFromFormatHHMM(t.min||"00:00"),l=d().setFromFormatHHMM(t.max||"23:59");const a=(o,s,u)=>{m(v=>{let T=v[o].clone();return C.isExist(s)&&T.setHours(s),C.isExist(u)&&T.setMinutes(u),T.toFormatHM().toNumber()>l.toFormatHM().toNumber()&&(T=l.clone()),T.toFormatHM().toNumber()<n.toFormatHM().toNumber()&&(T=n.clone()),S(p({},v),{eventType:"update",[o]:T})})};return f(L,{width:1,xcss:{minWidth:12*24},children:[f(g.Left,{flexWrap:!0,children:[f(g.Left,{gap:"1/2",children:[e(y.Paragraph,{children:r.from.toFormatHM()||"--:--"}),e(y.Supplement,{children:"-"}),e(y.Paragraph,{children:r.to.toFormatHM()||"--:--"})]}),e(P,{}),e(Y,{emptySelect:!1,value:i,paddingLeft:3.5,leftIcon:e(X,{left:"2/3",children:"\u5358\u4F4D"}),pickerPosition:4,pickerStyles:{xcss:{minWidth:12*8}},padding:"1/2",options:[{value:10,label:"10\u5206"},{value:5,label:"5\u5206"},{value:1,label:"1\u5206"}],tabIndex:-1,onUpdateValidValue:o=>{h(o||1)}})]}),e(x,{borderBottom:"1.thin"}),e(c.Period.Preset,S(p({},t),{onPreset:(o,s)=>{m({eventType:"update",forcus:0,display:d(o),from:d(o),to:d(s)})}})),f(g.Center,{gap:"1/2",children:[e(R,{override:"force",value:r.from.hours,options:Array.from({length:24}).map((o,s)=>{let u=s;return n.hours>u||l.hours<u?null:{value:u,label:u.zeroEmbed(2)+"\u6642"}}),onUpdateValidValue:o=>{a("from",o)}}),e(R,{override:"force",value:r.from.minutes,options:Array.from({length:60}).map((o,s)=>{let u=s;return u!=59&&(i==5&&u%5!=0||i==10&&u%10!=0)?null:{value:u,label:u.zeroEmbed(2)+"\u5206"}}),onUpdateValidValue:o=>{a("from",void 0,o)}},i+"-from"),e(y,{isSemiBoldFont:!0,children:"~"}),e(R,{override:"force",value:r.to.hours,options:Array.from({length:24}).map((o,s)=>{let u=s;return n.hours>u||l.hours<u?null:{value:u,label:u.zeroEmbed(2)+"\u6642"}}),onUpdateValidValue:o=>{a("to",o)}}),e(R,{override:"force",value:r.to.minutes,options:Array.from({length:60}).map((o,s)=>{let u=s;return u!=59&&(i==5&&u%5!=0||i==10&&u%10!=0)?null:{value:u,label:u.zeroEmbed(2)+"\u5206"}}),onUpdateValidValue:o=>{a("to",void 0,o)}},i+"-to")]})]})},Date:t=>{let{min:i,max:h}=t,[r,m]=D(C.scope(()=>{let[n,l]=C.Arrayify(t.defaultValue),a=d(n||void 0).setFirstOfDay(),o=d(l||null).setFirstOfDay();return{eventType:"init",forcus:0,display:a,from:a,to:o}}));return c.remoteControl(S(p({},t),{val_value:r,set_value:m})),F(()=>{if(!r.to.value)return;if(r.from.value>r.to.value){m(l=>S(p({},l),{eventType:"update",from:l.to,to:l.from}));return}t.onValueUpdate({value:[r.from.toFormatYMD(),r.to.toFormatYMD()],era:"year",eventType:r.eventType})},[r]),f(L,{xcss:{minWidth:12*16},children:[f(g.Left,{gap:"1/2",flexWrap:!0,children:[e(y.Supplement,{fontColor:"4.thin",children:"from"}),f(M.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{m(n=>S(p({},n),{forcus:0}))},children:[r.from.toFormatYMD()||"----/--/--",r.forcus==0&&e(c.Parts.PeriodFocusSign,{})]}),e(y.Supplement,{fontColor:"4.thin",children:"to"}),f(M.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{m(n=>S(p({},n),{forcus:1}))},children:[r.to.toFormatYMD()||"----/--/--",r.forcus==1&&e(c.Parts.PeriodFocusSign,{})]}),e(P,{}),f(g.Right,{gap:"1/2",marginLeft:"auto",children:[e(Y,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{xcss:{minWidth:12*12}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:c.YearOptions({reverse:!0}),value:r.display.year,onUpdateValidValue:n=>{m(l=>S(p({},l),{eventType:"update",display:l.display.clone().setYear(Number(n))}))}}),e(Y,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{xcss:{minWidth:12*9}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:[{value:1,label:"1\u6708"},{value:2,label:"2\u6708"},{value:3,label:"3\u6708"},{value:4,label:"4\u6708"},{value:5,label:"5\u6708"},{value:6,label:"6\u6708"},{value:7,label:"7\u6708"},{value:8,label:"8\u6708"},{value:9,label:"9\u6708"},{value:10,label:"10\u6708"},{value:11,label:"11\u6708"},{value:12,label:"12\u6708"}],value:r.display.month,onUpdateValidValue:n=>{m(l=>S(p({},l),{eventType:"update",display:l.display.clone().setMonth(Number(n)).setDate(1)}))}}),e(c.Parts.ShiftButtons,{callback:n=>{m(l=>S(p({},l),{eventType:"update",display:l.display.clone().addMonth(n)}))}})]})]}),e(x,{borderBottom:"1.thin"}),e(c.Period.Preset,S(p({},t),{onPreset:(n,l)=>{m({eventType:"update",forcus:0,display:d(n),from:d(n),to:d(l)})}})),e(g.Left,{verticalAlign:"top",flexWrap:!0,gap:2,children:Array.from({length:4}).map((n,l)=>{let a=c.Parts.Calendar({min:i,max:h,targetMonth:r.display.clone().addMonth(l-1),from:r.from,to:r.to,onTitleRender:o=>{let s=o.diff(r.display).months;return e(y.Supplement,{ssHiddenOnBreak:!0,children:f(g.Center,{gap:"1/2",children:[e(y,{isSemiBoldFont:!0,children:o.toFormatYM("JP")}),e(y,{fontColor:"4.thin",children:["[\u524D\u6708]","","[\u7FCC\u6708]","[\u7FCC\u3005\u6708]"][s+1]})]})})},onChange:o=>{if(r.forcus==0){m(s=>S(p({},s),{eventType:"update",forcus:1,from:o,to:d(null)}));return}m(s=>S(p({},s),{eventType:"update",to:o}))}});return e(x,{flexSizing:"auto",ssHiddenOnBreak:l!=1,children:a},l)})})]})},Month:t=>{let{min:i,max:h}=t,[r,m]=D(C.scope(()=>{let[n,l]=C.Arrayify(t.defaultValue),a=d(n||void 0).setDate(1).setFirstOfDay(),o=d(l||null).setDate(1).setFirstOfDay();return{eventType:"init",forcus:0,display:a,from:a,to:o}}));return c.remoteControl(S(p({},t),{val_value:r,set_value:m})),F(()=>{if(!r.to.value)return;if(r.from.value>r.to.value){m(l=>S(p({},l),{eventType:"update",from:l.to,to:l.from}));return}t.onValueUpdate({value:[r.from.toFormatYM(),r.to.toFormatYM()],era:"year",eventType:r.eventType})},[r]),f(L,{xcss:{minWidth:12*16},children:[f(g.Left,{gap:"1/2",flexWrap:!0,children:[e(y.Supplement,{fontColor:"4.thin",children:"from"}),f(M.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{m(n=>S(p({},n),{forcus:0}))},children:[r.from.toFormatYM("JP")||"----/--",r.forcus==0&&e(c.Parts.PeriodFocusSign,{})]}),e(y.Supplement,{fontColor:"4.thin",children:"to"}),f(M.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{m(n=>S(p({},n),{forcus:1}))},children:[r.to.toFormatYM("JP")||"----/--",r.forcus==1&&e(c.Parts.PeriodFocusSign,{})]}),e(P,{}),f(g.Left,{flexWrap:!0,gap:"1/2",marginLeft:"auto",children:[e(Y,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{xcss:{minWidth:12*12}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:c.YearOptions({reverse:!0}),value:r.display.year,onUpdateValidValue:n=>{m(l=>S(p({},l),{eventType:"update",display:l.display.clone().setYear(Number(n))}))}}),e(c.Parts.ShiftButtons,{callback:n=>{m(l=>S(p({},l),{eventType:"update",display:l.display.clone().addYear(n)}))}})]})]}),e(x,{borderBottom:"1.thin"}),e(c.Period.Preset,S(p({},t),{onPreset:(n,l)=>{m({eventType:"update",forcus:0,display:d(n),from:d(n),to:d(l)})}})),e(g.Left,{verticalAlign:"top",flexWrap:!0,gap:2,UnderBreakPointStyles:{gap:1},children:Array.from({length:4}).map((n,l)=>{let a=c.Parts.YearCalendar({min:i,max:h,targetYear:r.display.year+l-1,from:r.from.getFirstDayOfMonth(),to:r.to.getLastDayOfMonth(),onTitleRender:o=>{let s=o-r.display.year;return e(y.Supplement,{children:f(g.Left,{gap:"1/2",children:[f(y,{isSemiBoldFont:!0,children:[o,"\u5E74"]}),e(y,{fontColor:"4.thin",children:["[\u524D\u5E74]","","[\u7FCC\u5E74]","[\u7FCC\u3005\u5E74]"][s+1]})]})})},onChange:o=>{if(r.forcus==0){m(s=>S(p({},s),{eventType:"update",forcus:1,from:o,to:d(null)}));return}m(s=>S(p({},s),{eventType:"update",to:o}))}});return e(x,{flexSizing:"auto",ssHiddenOnBreak:l<1||l>2,xcss:{minWidth:"35%"},children:a},l)})})]})},Preset:t=>t.periodPresets?e(g.Right,{gap:"1/2",flexWrap:!0,children:t.periodPresets.map((i,h)=>e(M.Border.S,{padding:["1/4",1],onClick:()=>{t.onPreset(i.from,i.to)},children:i.label},h))}):null},Parts:{ShiftButtons:t=>f(g.Center,{gap:"1/3",fontSize:"1.mini",children:[e(M.Sub,{className:V("LeftButton"),tabIndex:-1,right:0,position:"relative",ssSquare:2.5,onClick:()=>{t.callback(-1)},children:e(B.ChevronLeft,{})}),e(M.Sub,{className:V("RightButton"),tabIndex:-1,left:0,position:"relative",ssSquare:2.5,onClick:()=>{t.callback(1)},children:e(B.ChevronRight,{})})]}),Calendar:t=>{let{targetMonth:i,from:h,to:r,onTitleRender:m=k=>e(y.Supplement,{isSemiBoldFont:!0,children:k.toFormatYM("JP")})}=t,n=d();if(!t.targetMonth.validate)return null;let l=i.clone().setDate(1),a=l.getLastDayOfMonth(),o=d(l).addMonth(-1).getLastDayOfMonth().date,s=[],u=[],v=[],T=[];for(var b=0;b<7;b++){let k=b==6,w=b==0;s.push(e(y,{textAlign:"center",fontSize:"0.xs",fontColor:k?"googleBlue":w?"googleRed":"inherit",children:C.transformer.weekday.shortJP(b)},b))}for(var b=0;b<l.weekday;b++)u.unshift(e(y.Supplement,{fontColor:"4.thin",flexCenter:!0,children:o-b},b));for(var b=1;b<=a.date;b++){let w=i.clone().setDate(b),E=h.isSameDate(w),z=!1,H=!1;r&&r.validate&&(z=w.isInRange(h,r),H=r.isSameDate(w));let G=n.isSameDate(w),U=!1;if(t.min){let I=d(t.min);I&&w.value<I.value&&(U=!0)}if(t.max){let I=d(t.max);I&&I.value<w.value&&(U=!0)}v.push(f(M.Clear.S,{isLocked:U,color:"cloud",border:"1.thin",isActive:E||H||z,isActiveStyles:E||H?{fontColor:"white",backgroundColor:"theme",borderColor:"theme",boxShadow:"0.remark"}:{backgroundColor:"theme.opa.few",fontColor:"theme",borderColor:"0.trans"},xcss:{whiteSpace:"nowrap",minWidth:12*3,minHeight:12*3},flexCenter:!0,ssEffectsOnActive:"shrink",tabIndex:-1,onClick:()=>{t.onChange(w)},children:[b,G&&e(c.Parts.CurrentSign,{})]},w.toFormatYMD()))}for(var b=1;b<7-a.weekday;b++)T.push(e(y.Supplement,{flexCenter:!0,fontColor:"4.thin",children:b},b));return f(L,{gap:"1/2",children:[m(i)||"",f(J,{gridCols:7,gap:"1/6",children:[s,u,v,T]})]},i.toFormatYM())},YearCalendar:t=>{let{targetYear:i,from:h,to:r,onTitleRender:m=a=>f(y.Supplement,{isSemiBoldFont:!0,children:[a,"\u5E74"]})}=t,n=d(),l=[];for(let a=1;a<=12;a++){let o=d().setYear(t.targetYear).setMonth(a).setDate(1),s=!1;if(t.min){let k=d(t.min).getLastDayOfMonth();k&&o.value<k.value&&(s=!0)}if(t.max){let k=d(t.max).getLastDayOfMonth();k&&k.value<o.value&&(s=!0)}let u=h.year==i&&h.month==o.month,v=!1,T=!1;r&&r.validate&&(v=o.isInRange(h,r),T=r.year==i&&r.month==o.month);let b=n.year==i&&n.month==o.month;l.push(f(M.Clear.S,{isLocked:s,color:"cloud",border:"1.thin",isActive:u||T||v,isActiveStyles:u||T?{fontColor:"white",backgroundColor:"theme",borderColor:"theme",boxShadow:"0.remark"}:{backgroundColor:"theme.opa.few",fontColor:"theme",borderColor:"0.trans"},fontSize:"inherit",ssEffectsOnActive:"shrink",tabIndex:-1,xcss:{whiteSpace:"nowrap",minWidth:12*3,minHeight:12*3},flexCenter:!0,onClick:()=>{t.onChange(o)},children:[f(g.Center,{gap:"1/2",children:[e(y,{children:o.month}),e(y.Supplement,{opacity:"middle",children:["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][o.month]})]}),b&&e(c.Parts.CurrentSign,{})]},i+"-"+o.month))}return f(L,{gap:"1/2",children:[m(t.targetYear),e(J,{flexWrap:!0,gridCols:4,gap:"1/6",children:l})]},t.targetYear)},DrumSelector:t=>{let{type:i,min:h,max:r,value:m}=t;const n=(a,o,s)=>{let u=t.value.clone();if(C.isExist(a)&&(u=u.setYear(a)),C.isExist(o)&&(u=u.setMonth(o)),C.isExist(s)&&(u=u.setDate(s)),h){let v=d(h);u.value<v.value&&(u=v)}if(r){let v=d(r);v.value<u.value&&(u=v)}t.onChange(u)};let l=m.getLastDayOfMonth().date;return f(g.Center,{gap:"1/2",children:[e(R,{override:"force",options:c.YearOptions({}),value:m.year,onUpdateValidValue:a=>{n(Number(a))}}),e(y,{isSemiBoldFont:!0,children:"\u5E74"}),e(R,{override:"force",options:Array.from({length:12}).map((a,o)=>{let s=o+1;return{value:s,label:s}}),value:m.month,onUpdateValidValue:a=>{n(void 0,Number(a))}}),e(y,{isSemiBoldFont:!0,children:"\u6708"}),i!="month"&&f($,{children:[e(R,{override:"force",options:Array.from({length:31}).map((a,o)=>{let s=o+1;return s>l?null:{value:s,label:s}}),value:m.date,onUpdateValidValue:a=>{n(void 0,void 0,Number(a))}}),e(y,{isSemiBoldFont:!0,children:"\u65E5"})]})]})},MinMax:t=>{let{restrict:i,min:h,max:r}=t;if(!h&&!r)return null;let m=d(h||null),n=d(r||null),l="",a="";return i=="year"?(l=m.toFormat("%Y\u5E74"),a=n.toFormat("%Y\u5E74")):i.match(/month/)?(l=m.toFormatYM(),a=n.toFormatYM()):i.match(/date/)?(l=m.toFormatYMD(),a=n.toFormatYMD()):i.match(/clock/)&&(m=d().setFromFormatHHMM(h||""),n=d().setFromFormatHHMM(r||""),l=m.toFormatHM(),a=n.toFormatHM()),f(y.Supplement,{fontHeight:1.2,fontSize:"0.xs",children:[l&&f(y,{children:["\u6700\u5C0F: ",l]}),a&&f(y,{children:["\u6700\u5927: ",a]})]})},CurrentSign:()=>e(x,{position:"absolute",bottom:"1/6",left:"50%",width:1,unitHeight:"1/6",backgroundColor:"warn",xcss:{maxWidth:12*2.5,transform:"translateX(-50%)"},isRounded:!0}),PeriodFocusSign:()=>e(x,{position:"absolute",bottom:"1/4",left:"1/2",right:"1/2",backgroundColor:"theme",unitHeight:"1/4",boxShadow:"0.remark",isRounded:!0})}},A=j;A.picker={open:t=>{let i=null,h=null,r="L";t.restrict=="year"&&(r="S"),t.restrict=="month"&&(r="S"),t.restrict=="clock"?r="XS":(t.restrict=="locale.jp.warekiDate"||t.restrict=="period.clock")&&(r="S");let m=t.sheetID||O(),n=t.pickerId||O();_.open("middleCenter",{sheetID:m,size:r,padding:[2,0],closeAtAroundClick:!0,closeAtParentBlur:!1,onClose:()=>{t.onValueUpdate({value:i,era:h,eventType:"commit"})},content:f(L,{gap:"1/2",children:[f(g.Left,{children:[e(P,{}),e(M.Sub.S,{color:"cloud",ssSphere:3,onClick:()=>{_.close(m)},children:e(B.X,{})})]}),e(_.Body,{children:f(L,{borderRadius:"inherit",children:[e(L,{padding:1,children:e(j,{sheetID:m,pickerId:n,restrict:t.restrict,min:t.min,max:t.max,era:t.era,defaultValue:t.defaultValue,onValueUpdate:l=>{t.onValueUpdate(l),i=l.value,h=l.era,l.eventType=="commit"&&_.close(m)}})}),f(g.Left,{padding:1,position:"sticky",ssZIndex:10,bottom:0,gap:"1/2",borderTop:"1.thin",backgroundColor:"layer.0.opa.low",borderBottomLeftRadius:"inherit",borderBottomRightRadius:"inherit",xcss:{backdropFilter:"blur(3px)"},children:[e(M.Clear.S,{color:"cloud",tabIndex:-1,fontColor:"4.thin",borderRadius:"2.tone.secondary",flexSizing:"none",onClick:()=>{var l,a;(a=(l=W.get(n||""))==null?void 0:l.onClear)==null||a.call(l)},children:f(g.Center,{gap:"1/2",children:[e(B.X,{}),e(y,{fontSize:"0.xs",children:"\u30EA\u30BB\u30C3\u30C8"})]})}),e(c.Parts.MinMax,{restrict:t.restrict,min:t.min,max:t.max}),e(P,{}),e(M.Prime.S,{tabIndex:-1,xcss:{minWidth:12*6},onClick:()=>{var l,a;(a=(l=W.get(n||""))==null?void 0:l.onConfirm)==null||a.call(l)},children:"\u78BA\u5B9A"})]})]})})]})})},close:t=>{_.close(t)}};export{A as TimeSelector,A as default};
1
+ import{b as c,c as g}from"../../../chunk-C5N2D3ZX.js";import{Fragment as $,jsx as e,jsxs as f}from"react/jsx-runtime";import S,{UUID as O,Time as d,useStore as W}from"jmini";import{useState as D,useEffect as F}from"react";import{Box as M,Grid as J,FAI as B,Column as L,FlexMargin as P}from"../../../atoms";import{Row as C,Literal as y}from"../../../mols";import{Button as x}from"../../Button";import _ from"../../Sheet";import Y from"../Select";import{LeftIcon as X,RightIcon as N}from"..";import{InputTimeClasses as V}from"../../../@styles/componentClasses";import R from"../Drum";const j=t=>{let{restrict:l}=t;return l=="year"?e(p.Year,c({},t)):l=="month"?e(p.Month,c({},t)):l=="week"?"[DEV]":l=="date"?e(p.Date,c({},t)):l=="locale.jp.warekiDate"?e(p.Locale.JP.WarekiDate,c({},t)):l=="clock"?e(p.Clock,c({},t)):l=="period.clock"?e(p.Period.Clock,c({},t)):l=="period.month"?e(p.Period.Month,c({},t)):l=="period.date"?e(p.Period.Date,c({},t)):null},p={YearOptions:t=>{var m,i,n;let l=[],h=(m=t==null?void 0:t.min)!=null?m:1900,r=(i=t==null?void 0:t.max)!=null?i:d().addYear(10).year;for(let a=h;a<=r;a++){let o=[a],[u,s]=S.transformer.wareki(a).value;((n=t.showJPWareki)==null||n)&&(u&&o.push(e(y.Micro,{fontColor:"4.thin",children:u},1)),s&&o.push(f(y.Micro,{fontColor:"4.thin",children:["[",s,"]"]},2))),l[t.reverse?"unshift":"push"]({value:a,label:e(C.Center,{gap:["1/12","1/4"],verticalAlign:"baseline",flexWrap:!0,children:o})})}return l},calendartypeState:()=>{let[t,l]=D(localStorage.getItem("@env/input/time/selector/calendartype")||"calendar");return F(()=>{localStorage.setItem("@env/input/time/selector/calendartype",String(t))},[t]),[t,l]},minutesUnitState:()=>{let[t,l]=D(Number(localStorage.getItem("@env/input/time/selector/clock/minutesUnit")||10));return F(()=>{localStorage.setItem("@env/input/time/selector/clock/minutesUnit",String(t))},[t]),[t,l]},remoteControl:function(t){let{restrict:l,pickerId:h,val_value:r,set_value:m}=t;F(()=>{h&&W.set({[h]:{onClear:()=>{if(l.match(/period\./)){m(i=>g(c({},i),{eventType:"commit",forcus:0,display:d(),from:d(null),to:d(null)}));return}m(i=>g(c({},i),{eventType:"commit",from:d(null)}))},onConfirm:()=>{m(i=>g(c({},i),{eventType:"commit"}))}}})},[])},Year:t=>{let{min:l,max:h}=t,[r,m]=D(S.scope(()=>{let[i]=String(t.defaultValue).split(/\D/);return{eventType:"init",from:d().setYear(Number(i||d().year))}}));return p.remoteControl(g(c({},t),{val_value:r,set_value:m})),F(()=>{t.onValueUpdate({value:String(r.from.year||null),era:"year",eventType:r.eventType})},[r]),f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{flexWrap:!0,children:[f(y.Paragraph,{children:[r.from.year||"----","\u5E74"]}),e(x.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let i=d();m({eventType:"update",from:i})},children:"\u4ECA\u5E74"}),e(P,{})]}),e(M,{borderTop:!0}),e(R,{override:"force",value:r.from.year||null,options:p.YearOptions({min:Number(l)||void 0,max:Number(h)||void 0}),onUpdateValidValue:i=>{m(n=>({eventType:"update",from:n.from.clone().setYear(Number(i))}))}})]})},Month:t=>{let{min:l,max:h}=t,[r,m]=D(S.scope(()=>{let[i,n]=String(t.defaultValue).split(/\D/);(S.isNullish(i)||S.isNullish(n))&&([i,n]=d().toFormat("%Y-%M").split("-"));let a=d(),o=d().setYear(Number(i)||a.year).setMonth(Number(n)||a.month).setDate(1);return{eventType:"init",from:o,display:o}}));return p.remoteControl(g(c({},t),{val_value:r,set_value:m})),F(()=>{t.onValueUpdate({value:r.from.toFormatYM(),era:"year",eventType:r.eventType})},[r]),f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{gap:"1/2",children:[e(y.Paragraph,{children:r.from.toFormatYM("JP")||"----/--"}),e(x.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let i=d();m({eventType:"update",from:i,display:i})},children:"\u4ECA\u6708"}),e(P,{})]}),e(M,{borderTop:!0}),e(p.Parts.DrumSelector,{type:"month",min:l,max:h,value:r.from,onChange:i=>{m(g(c({},r),{eventType:"update",from:i}))}})]})},Date:t=>{let{min:l,max:h}=t,[r,m]=p.calendartypeState(),[i,n]=D(S.scope(()=>{var T;let[a,o,u]=(T=String(t.defaultValue))==null?void 0:T.split(/\D/);(S.isNullish(a)||S.isNullish(o)||S.isNullish(u))&&([a,o,u]=d().toFormat("%Y-%M-%D").split("-"));let s=d(),v=d([Number(a)||s.year,(Number(o)||s.month).zeroEmbed(2),(Number(u)||s.date).zeroEmbed(2)].join("/"));return{eventType:"init",era:"year",display:v,from:v}}));return p.remoteControl(g(c({},t),{val_value:i,set_value:n})),F(()=>{t.onValueUpdate({value:i.from.toFormatYMD(),era:"year",eventType:i.eventType})},[i]),f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{flexWrap:!0,gap:"1/2",children:[e(y.Paragraph,{children:i.from.toFormatYMD("JP")||"----/--/--"}),e(x.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let a=d();n({eventType:"update",era:"year",from:a,display:a})},children:"\u4ECA\u65E5"}),e(P,{}),f(x.Border.S,{padding:["1/6","1/2"],fontColor:"3.blur",fontSize:"0.xs",onClick:()=>{m(a=>a=="calendar"?"drum":"calendar")},children:[r=="calendar"&&"\u30C9\u30E9\u30E0",r=="drum"&&"\u30AB\u30EC\u30F3\u30C0\u30FC","\u8868\u793A"]})]}),e(M,{borderTop:!0}),r=="calendar"&&f($,{children:[f(C.Center,{gap:"1/2",children:[e(Y,{override:"force",emptySelect:!1,value:i.display.year,options:p.YearOptions({reverse:!0}),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,pickerStyles:{xcss:{minWidth:12*12}},onUpdateValidValue:a=>{n(o=>g(c({},o),{eventType:"update",display:o.display.clone().setYear(Number(a))}))},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})})}),e(Y,{override:"force",emptySelect:!1,value:i.display.month,options:(()=>{let a=[];for(let o=1;o<=12;o++)a.push({value:o,label:String(o)+"\u6708"});return a})(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,pickerStyles:{xcss:{minWidth:12*8}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),onUpdateValidValue:a=>{n(o=>g(c({},o),{eventType:"update",display:o.display.clone().setMonth(Number(a))}))}}),e(p.Parts.ShiftButtons,{callback:a=>{n(o=>g(c({},o),{eventType:"update",display:o.display.clone().addMonth(a)}))}})]}),f(L,{children:[e(M,{margin:"auto",xcss:{minWidth:"50%"},UnderBreakPointStyles:{margin:0},children:p.Parts.Calendar({min:l,max:h,onTitleRender:a=>"",targetMonth:i.display,from:i.from,onChange:a=>{n(o=>g(c({},o),{eventType:"update",from:a}))}})}),e(M,{unitHeight:"1/4",isRounded:!0,backgroundColor:"cloud",margin:1,ssHiddenOnBreak:!0}),f(C.Center,{verticalAlign:"unset",ssHiddenOnBreak:!0,children:[e(M,{flexSizing:0,children:p.Parts.Calendar({min:l,max:h,onTitleRender:a=>e(y.Mini,{children:f(C.Center,{gap:"1/2",children:[e(y,{isSemiBoldFont:!0,children:a.toFormatYM("JP")}),e(y,{fontColor:"4.thin",children:"[\u524D\u6708]"})]})}),targetMonth:i.display.clone().addMonth(-1),from:i.from,onChange:a=>{n(o=>g(c({},o),{eventType:"update",from:a}))}})}),e(M,{unitWidth:"1/4",isRounded:!0,backgroundColor:"cloud",margin:1}),e(M,{flexSizing:0,children:p.Parts.Calendar({min:l,max:h,onTitleRender:a=>e(y.Mini,{children:f(C.Center,{gap:"1/2",children:[e(y,{isSemiBoldFont:!0,children:a.toFormatYM("JP")}),e(y,{fontColor:"4.thin",children:"[\u7FCC\u6708]"})]})}),targetMonth:i.display.clone().addMonth(1),from:i.from,onChange:a=>{n(o=>g(c({},o),{eventType:"update",from:a}))}})})]})]})]}),r=="drum"&&e(p.Parts.DrumSelector,{type:"date",min:l,max:h,value:i.from,onChange:a=>{n(g(c({},i),{eventType:"update",from:a}))}})]})},Locale:{JP:{WarekiDate:t=>{var n;let{min:l,max:h}=t,[r,m]=D(S.scope(()=>{var b;let[a,o,u]=(b=String(t.defaultValue))==null?void 0:b.split(/\D/),s=t.era||"year";if(S.isNullish(a)||S.isNullish(o)||S.isNullish(u)){let k=d();s=="heisei"?k.setYear(1989):s=="shouwa"?k.setYear(1926):s=="taisho"?k.setYear(1912):s=="meiji"&&k.setYear(1868),[a,o,u]=k.toFormat("%Y-%M-%D").split("-")}let v=d();return{eventType:"init",from:d([Number(a)||v.year,(Number(o)||v.month).zeroEmbed(2),(Number(u)||v.date).zeroEmbed(2)].join("/"))}}));p.remoteControl(g(c({},t),{val_value:r,set_value:m})),F(()=>{t.onValueUpdate({value:r.from.toFormatYMD(),era:r.from.wareki.toLower(),eventType:r.eventType})},[r]);let i={year:{label:"\u897F\u66A6",min:"1900/01/01",max:"2100/12/31"},reiwa:{label:"\u4EE4\u548C",min:"2019/05/01",max:d().addYear(10).setMonth(12).setDate(31).toFormatYMD()},heisei:{label:"\u5E73\u6210",min:"1989/01/08",max:"2019/04/30"},showa:{label:"\u662D\u548C",min:"1926/12/25",max:"1989/01/07"},taisho:{label:"\u5927\u6B63",min:"1912/07/30",max:"1926/12/24"},meiji:{label:"\u660E\u6CBB",min:"1868/09/08",max:"1912/07/29"}};return f(L,{children:[f(C.Left,{gap:"1/4",flexWrap:!0,children:[f(y.Paragraph,{children:[r.from.warekiLabel,(n=r.from.warekiYear)==null?void 0:n.zeroEmbed(2),"\u5E74",r.from.toFormatMD("JP")]}),e(P,{})]}),e(M,{borderTop:!0}),e(C.Left,{gap:"1/2",flexWrap:!0,children:["reiwa","heisei","showa","taisho","meiji"].map((a,o)=>{let u=i[a];return u?e(x.Border.S,{onClick:()=>{let s=r.from;if(a=="reiwa"||a=="year")s=d();else{let v=d(u.min),T=d(u.max);v.value>r.from.value&&(s=v),r.from.value>T.value&&(s=T)}if(l){let v=d(l);s.value<v.value&&(s=v)}if(h){let v=d(h);v.value<s.value&&(s=v)}m(g(c({},r),{eventType:"update",from:s}))},children:u.label},o):null})}),e(p.Parts.DrumSelector,{type:"locale.jp.warekiDate",min:t.min,max:t.max,value:r.from,onChange:a=>{m(g(c({},r),{eventType:"update",from:a}))}})]})}}},Clock:t=>{let[l,h]=D(S.scope(()=>{let o=String(t.defaultValue).split(/[^\d]/);if(!o[0]){let v=d();o=[v.hours,v.minutes]}let u=Number(o[0]),s=Number(o[1]);return{eventType:"init",from:d().setHours(u).setMinutes(s)}}));p.remoteControl(g(c({},t),{val_value:l,set_value:h})),F(()=>{t.onValueUpdate({value:l.from.toFormatHM(),era:"clock",eventType:l.eventType})},[l]);let[r,m]=p.minutesUnitState(),i=d().setFromFormatHHMM(t.min||"00:00"),n=d().setFromFormatHHMM(t.max||"23:59");const a=(o,u)=>{h(s=>{let v=s.from.clone();return S.isExist(o)&&v.setHours(o),S.isExist(u)&&v.setMinutes(u),v.toFormatHM().toNumber()>n.toFormatHM().toNumber()&&(v=n.clone()),v.toFormatHM().toNumber()<i.toFormatHM().toNumber()&&(v=i.clone()),g(c({},s),{eventType:"update",from:v})})};return f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{gap:"1/2",flexWrap:!0,children:[f(C.Center,{gap:"1/2",children:[e(M,{className:V("ClockBase"),children:e(M,{className:V("ClockUiBase"),flexCenter:!0,children:f(M,{className:V("ClockUi"),backgroundColor:"theme.opa.low",isRounded:!0,position:"relative",children:[e(M,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[V("Needle"),V("hour")].join(" "),xcss:{transform:`rotate(${l.from.hours*30+l.from.minutes/2}deg)`}}),e(M,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[V("Needle"),V("minute")].join(" "),xcss:{transform:`rotate(${l.from.minutes*6}deg)`}})]})})}),f(M,{textAlign:"center",fontHeight:1.2,children:[f(y.Paragraph,{children:[l.from.hours.zeroEmbed(2)," : ",l.from.minutes.zeroEmbed(2)]}),f(y.Mini,{fontColor:"4.thin",children:[l.from.hours>=12&&"PM"||"AM",l.from.hours%12,":",l.from.minutes.zeroEmbed(2)]})]})]}),e(x.Border.XS,{borderRadius:"2.tone.secondary",fontColor:"theme",onClick:()=>{let o=d().setSeconds(0);o.minutes=Math.round(o.minutes/r)*r,a(o.hours,o.minutes)},children:"\u73FE\u6642\u523B"}),e(P,{}),e(Y,{emptySelect:!1,value:r,paddingLeft:3.5,leftIcon:e(X,{left:"2/3",children:"\u5358\u4F4D"}),pickerPosition:4,pickerStyles:{xcss:{minWidth:12*8}},padding:"1/2",options:[{value:10,label:"10\u5206"},{value:5,label:"5\u5206"},{value:1,label:"1\u5206"}],tabIndex:-1,onUpdateValidValue:o=>{m(o||1)}})]}),e(M,{borderTop:!0}),f(C.Center,{gap:"1/2",children:[e(R,{xcss:{maxHeight:12*12},override:"force",options:[{value:0,label:"\u5348\u524D"},{value:12,label:"\u5348\u5F8C"}],value:l.from.hours>=12?12:0,onUpdateValidValue:o=>{let u=l.from.hours%12+o;a(u)}}),e(R,{override:"force",value:l.from.hours,options:Array.from({length:24}).map((o,u)=>{let s=u;return i.hours>s||n.hours<s?null:{value:s,label:s.zeroEmbed(2)}}),onUpdateValidValue:o=>{a(o)}}),e(y,{isSemiBoldFont:!0,children:"\u6642"}),e(R,{override:"force",value:l.from.minutes,options:Array.from({length:60}).map((o,u)=>{let s=u;return s!=59&&(r==5&&s%5!=0||r==10&&s%10!=0)?null:{value:s,label:s.zeroEmbed(2)}}),onUpdateValidValue:o=>{a(void 0,o)}},r),e(y,{isSemiBoldFont:!0,children:"\u5206"})]})]})},Period:{Clock:t=>{let[l,h]=p.minutesUnitState(),[r,m]=D(S.scope(()=>{let[o,u]=S.Arrayify(t.defaultValue),s=d().setFromFormatHHMM(o||"09:00"),v=d().setFromFormatHHMM(u||"18:00");return{eventType:"init",forcus:0,display:s,from:s,to:v}}));p.remoteControl(g(c({},t),{val_value:r,set_value:m})),F(()=>{if(!r.to.value)return;if(r.from.value>r.to.value){m(u=>g(c({},u),{eventType:"update",from:u.to,to:u.from}));return}t.onValueUpdate({value:[r.from.toFormatHM(),r.to.toFormatHM()],era:"clock",eventType:r.eventType})},[r]);let i=d().setFromFormatHHMM(t.min||"00:00"),n=d().setFromFormatHHMM(t.max||"23:59");const a=(o,u,s)=>{m(v=>{let T=v[o].clone();return S.isExist(u)&&T.setHours(u),S.isExist(s)&&T.setMinutes(s),T.toFormatHM().toNumber()>n.toFormatHM().toNumber()&&(T=n.clone()),T.toFormatHM().toNumber()<i.toFormatHM().toNumber()&&(T=i.clone()),g(c({},v),{eventType:"update",[o]:T})})};return f(L,{width:1,xcss:{minWidth:12*24},children:[f(C.Left,{flexWrap:!0,children:[f(C.Left,{gap:"1/2",children:[e(y.Paragraph,{children:r.from.toFormatHM()||"--:--"}),e(y.Mini,{children:"-"}),e(y.Paragraph,{children:r.to.toFormatHM()||"--:--"})]}),e(P,{}),e(Y,{emptySelect:!1,value:l,paddingLeft:3.5,leftIcon:e(X,{left:"2/3",children:"\u5358\u4F4D"}),pickerPosition:4,pickerStyles:{xcss:{minWidth:12*8}},padding:"1/2",options:[{value:10,label:"10\u5206"},{value:5,label:"5\u5206"},{value:1,label:"1\u5206"}],tabIndex:-1,onUpdateValidValue:o=>{h(o||1)}})]}),e(M,{borderBottom:"1.thin"}),e(p.Period.Preset,g(c({},t),{onPreset:(o,u)=>{m({eventType:"update",forcus:0,display:d(o),from:d(o),to:d(u)})}})),f(C.Center,{gap:"1/2",children:[e(R,{override:"force",value:r.from.hours,options:Array.from({length:24}).map((o,u)=>{let s=u;return i.hours>s||n.hours<s?null:{value:s,label:s.zeroEmbed(2)+"\u6642"}}),onUpdateValidValue:o=>{a("from",o)}}),e(R,{override:"force",value:r.from.minutes,options:Array.from({length:60}).map((o,u)=>{let s=u;return s!=59&&(l==5&&s%5!=0||l==10&&s%10!=0)?null:{value:s,label:s.zeroEmbed(2)+"\u5206"}}),onUpdateValidValue:o=>{a("from",void 0,o)}},l+"-from"),e(y,{isSemiBoldFont:!0,children:"~"}),e(R,{override:"force",value:r.to.hours,options:Array.from({length:24}).map((o,u)=>{let s=u;return i.hours>s||n.hours<s?null:{value:s,label:s.zeroEmbed(2)+"\u6642"}}),onUpdateValidValue:o=>{a("to",o)}}),e(R,{override:"force",value:r.to.minutes,options:Array.from({length:60}).map((o,u)=>{let s=u;return s!=59&&(l==5&&s%5!=0||l==10&&s%10!=0)?null:{value:s,label:s.zeroEmbed(2)+"\u5206"}}),onUpdateValidValue:o=>{a("to",void 0,o)}},l+"-to")]})]})},Date:t=>{let{min:l,max:h}=t,[r,m]=D(S.scope(()=>{let[i,n]=S.Arrayify(t.defaultValue),a=d(i||void 0).setFirstOfDay(),o=d(n||null).setFirstOfDay();return{eventType:"init",forcus:0,display:a,from:a,to:o}}));return p.remoteControl(g(c({},t),{val_value:r,set_value:m})),F(()=>{if(!r.to.value)return;if(r.from.value>r.to.value){m(n=>g(c({},n),{eventType:"update",from:n.to,to:n.from}));return}t.onValueUpdate({value:[r.from.toFormatYMD(),r.to.toFormatYMD()],era:"year",eventType:r.eventType})},[r]),f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{gap:"1/2",flexWrap:!0,children:[e(y.Mini,{fontColor:"4.thin",children:"from"}),f(x.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{m(i=>g(c({},i),{forcus:0}))},children:[r.from.toFormatYMD()||"----/--/--",r.forcus==0&&e(p.Parts.PeriodFocusSign,{})]}),e(y.Mini,{fontColor:"4.thin",children:"to"}),f(x.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{m(i=>g(c({},i),{forcus:1}))},children:[r.to.toFormatYMD()||"----/--/--",r.forcus==1&&e(p.Parts.PeriodFocusSign,{})]}),e(P,{}),f(C.Right,{gap:"1/2",marginLeft:"auto",children:[e(Y,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{xcss:{minWidth:12*12}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:p.YearOptions({reverse:!0}),value:r.display.year,onUpdateValidValue:i=>{m(n=>g(c({},n),{eventType:"update",display:n.display.clone().setYear(Number(i))}))}}),e(Y,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{xcss:{minWidth:12*9}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:[{value:1,label:"1\u6708"},{value:2,label:"2\u6708"},{value:3,label:"3\u6708"},{value:4,label:"4\u6708"},{value:5,label:"5\u6708"},{value:6,label:"6\u6708"},{value:7,label:"7\u6708"},{value:8,label:"8\u6708"},{value:9,label:"9\u6708"},{value:10,label:"10\u6708"},{value:11,label:"11\u6708"},{value:12,label:"12\u6708"}],value:r.display.month,onUpdateValidValue:i=>{m(n=>g(c({},n),{eventType:"update",display:n.display.clone().setMonth(Number(i)).setDate(1)}))}}),e(p.Parts.ShiftButtons,{callback:i=>{m(n=>g(c({},n),{eventType:"update",display:n.display.clone().addMonth(i)}))}})]})]}),e(M,{borderBottom:"1.thin"}),e(p.Period.Preset,g(c({},t),{onPreset:(i,n)=>{m({eventType:"update",forcus:0,display:d(i),from:d(i),to:d(n)})}})),e(C.Left,{verticalAlign:"top",flexWrap:!0,gap:2,children:Array.from({length:4}).map((i,n)=>{let a=p.Parts.Calendar({min:l,max:h,targetMonth:r.display.clone().addMonth(n-1),from:r.from,to:r.to,onTitleRender:o=>{let u=o.diff(r.display).months;return e(y.Mini,{ssHiddenOnBreak:!0,children:f(C.Center,{gap:"1/2",children:[e(y,{isSemiBoldFont:!0,children:o.toFormatYM("JP")}),e(y,{fontColor:"4.thin",children:["[\u524D\u6708]","","[\u7FCC\u6708]","[\u7FCC\u3005\u6708]"][u+1]})]})})},onChange:o=>{if(r.forcus==0){m(u=>g(c({},u),{eventType:"update",forcus:1,from:o,to:d(null)}));return}m(u=>g(c({},u),{eventType:"update",to:o}))}});return e(M,{flexSizing:"auto",ssHiddenOnBreak:n!=1,children:a},n)})})]})},Month:t=>{let{min:l,max:h}=t,[r,m]=D(S.scope(()=>{let[i,n]=S.Arrayify(t.defaultValue),a=d(i||void 0).setDate(1).setFirstOfDay(),o=d(n||null).setDate(1).setFirstOfDay();return{eventType:"init",forcus:0,display:a,from:a,to:o}}));return p.remoteControl(g(c({},t),{val_value:r,set_value:m})),F(()=>{if(!r.to.value)return;if(r.from.value>r.to.value){m(n=>g(c({},n),{eventType:"update",from:n.to,to:n.from}));return}t.onValueUpdate({value:[r.from.toFormatYM(),r.to.toFormatYM()],era:"year",eventType:r.eventType})},[r]),f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{gap:"1/2",flexWrap:!0,children:[e(y.Mini,{fontColor:"4.thin",children:"from"}),f(x.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{m(i=>g(c({},i),{forcus:0}))},children:[r.from.toFormatYM("JP")||"----/--",r.forcus==0&&e(p.Parts.PeriodFocusSign,{})]}),e(y.Mini,{fontColor:"4.thin",children:"to"}),f(x.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{m(i=>g(c({},i),{forcus:1}))},children:[r.to.toFormatYM("JP")||"----/--",r.forcus==1&&e(p.Parts.PeriodFocusSign,{})]}),e(P,{}),f(C.Left,{flexWrap:!0,gap:"1/2",marginLeft:"auto",children:[e(Y,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{xcss:{minWidth:12*12}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:p.YearOptions({reverse:!0}),value:r.display.year,onUpdateValidValue:i=>{m(n=>g(c({},n),{eventType:"update",display:n.display.clone().setYear(Number(i))}))}}),e(p.Parts.ShiftButtons,{callback:i=>{m(n=>g(c({},n),{eventType:"update",display:n.display.clone().addYear(i)}))}})]})]}),e(M,{borderBottom:"1.thin"}),e(p.Period.Preset,g(c({},t),{onPreset:(i,n)=>{m({eventType:"update",forcus:0,display:d(i),from:d(i),to:d(n)})}})),e(C.Left,{verticalAlign:"top",flexWrap:!0,gap:2,UnderBreakPointStyles:{gap:1},children:Array.from({length:4}).map((i,n)=>{let a=p.Parts.YearCalendar({min:l,max:h,targetYear:r.display.year+n-1,from:r.from.getFirstDayOfMonth(),to:r.to.getLastDayOfMonth(),onTitleRender:o=>{let u=o-r.display.year;return e(y.Mini,{children:f(C.Left,{gap:"1/2",children:[f(y,{isSemiBoldFont:!0,children:[o,"\u5E74"]}),e(y,{fontColor:"4.thin",children:["[\u524D\u5E74]","","[\u7FCC\u5E74]","[\u7FCC\u3005\u5E74]"][u+1]})]})})},onChange:o=>{if(r.forcus==0){m(u=>g(c({},u),{eventType:"update",forcus:1,from:o,to:d(null)}));return}m(u=>g(c({},u),{eventType:"update",to:o}))}});return e(M,{flexSizing:"auto",ssHiddenOnBreak:n<1||n>2,xcss:{minWidth:"35%"},children:a},n)})})]})},Preset:t=>t.periodPresets?e(C.Right,{gap:"1/2",flexWrap:!0,children:t.periodPresets.map((l,h)=>e(x.Border.S,{padding:["1/4",1],onClick:()=>{t.onPreset(l.from,l.to)},children:l.label},h))}):null},Parts:{ShiftButtons:t=>f(C.Center,{gap:"1/3",fontSize:"1.mini",children:[e(x.Sub,{className:V("LeftButton"),tabIndex:-1,right:0,position:"relative",ssSquare:2.5,onClick:()=>{t.callback(-1)},children:e(B.ChevronLeft,{})}),e(x.Sub,{className:V("RightButton"),tabIndex:-1,left:0,position:"relative",ssSquare:2.5,onClick:()=>{t.callback(1)},children:e(B.ChevronRight,{})})]}),Calendar:t=>{let{targetMonth:l,from:h,to:r,onTitleRender:m=k=>e(y.Mini,{isSemiBoldFont:!0,children:k.toFormatYM("JP")})}=t,i=d();if(!t.targetMonth.validate)return null;let n=l.clone().setDate(1),a=n.getLastDayOfMonth(),o=d(n).addMonth(-1).getLastDayOfMonth().date,u=[],s=[],v=[],T=[];for(var b=0;b<7;b++){let k=b==6,w=b==0;u.push(e(y.Micro,{textAlign:"center",fontColor:k?"googleBlue":w?"googleRed":"inherit",children:S.transformer.weekday.shortJP(b)},b))}for(var b=0;b<n.weekday;b++)s.unshift(e(y.Mini,{fontColor:"4.thin",flexCenter:!0,children:o-b},b));for(var b=1;b<=a.date;b++){let w=l.clone().setDate(b),E=h.isSameDate(w),z=!1,H=!1;r&&r.validate&&(z=w.isInRange(h,r),H=r.isSameDate(w));let G=i.isSameDate(w),U=!1;if(t.min){let I=d(t.min);I&&w.value<I.value&&(U=!0)}if(t.max){let I=d(t.max);I&&I.value<w.value&&(U=!0)}v.push(f(x.Clear.S,{isLocked:U,color:"cloud",border:"1.thin",isActive:E||H||z,isActiveStyles:E||H?{fontColor:"white",backgroundColor:"theme",borderColor:"theme",boxShadow:"0.remark"}:{backgroundColor:"theme.opa.few",fontColor:"theme",borderColor:"0.trans"},xcss:{whiteSpace:"nowrap",minWidth:12*3,minHeight:12*3},flexCenter:!0,ssEffectsOnActive:"shrink",tabIndex:-1,onClick:()=>{t.onChange(w)},children:[b,G&&e(p.Parts.CurrentSign,{})]},w.toFormatYMD()))}for(var b=1;b<7-a.weekday;b++)T.push(e(y.Mini,{flexCenter:!0,fontColor:"4.thin",children:b},b));return f(L,{gap:"1/2",children:[m(l)||"",f(J,{gridCols:7,gap:"1/6",children:[u,s,v,T]})]},l.toFormatYM())},YearCalendar:t=>{let{targetYear:l,from:h,to:r,onTitleRender:m=a=>f(y.Mini,{isSemiBoldFont:!0,children:[a,"\u5E74"]})}=t,i=d(),n=[];for(let a=1;a<=12;a++){let o=d().setYear(t.targetYear).setMonth(a).setDate(1),u=!1;if(t.min){let k=d(t.min).getLastDayOfMonth();k&&o.value<k.value&&(u=!0)}if(t.max){let k=d(t.max).getLastDayOfMonth();k&&k.value<o.value&&(u=!0)}let s=h.year==l&&h.month==o.month,v=!1,T=!1;r&&r.validate&&(v=o.isInRange(h,r),T=r.year==l&&r.month==o.month);let b=i.year==l&&i.month==o.month;n.push(f(x.Clear.S,{isLocked:u,color:"cloud",border:"1.thin",isActive:s||T||v,isActiveStyles:s||T?{fontColor:"white",backgroundColor:"theme",borderColor:"theme",boxShadow:"0.remark"}:{backgroundColor:"theme.opa.few",fontColor:"theme",borderColor:"0.trans"},fontSize:"inherit",ssEffectsOnActive:"shrink",tabIndex:-1,xcss:{whiteSpace:"nowrap",minWidth:12*3,minHeight:12*3},flexCenter:!0,onClick:()=>{t.onChange(o)},children:[f(C.Center,{gap:"1/2",children:[e(y,{children:o.month}),e(y.Mini,{opacity:"middle",children:["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][o.month]})]}),b&&e(p.Parts.CurrentSign,{})]},l+"-"+o.month))}return f(L,{gap:"1/2",children:[m(t.targetYear),e(J,{flexWrap:!0,gridCols:4,gap:"1/6",children:n})]},t.targetYear)},DrumSelector:t=>{let{type:l,min:h,max:r,value:m}=t;const i=(a,o,u)=>{let s=t.value.clone();if(S.isExist(a)&&(s=s.setYear(a)),S.isExist(o)&&(s=s.setMonth(o)),S.isExist(u)&&(s=s.setDate(u)),h){let v=d(h);s.value<v.value&&(s=v)}if(r){let v=d(r);v.value<s.value&&(s=v)}t.onChange(s)};let n=m.getLastDayOfMonth().date;return f(C.Center,{gap:"1/2",children:[e(R,{override:"force",options:p.YearOptions({}),value:m.year,onUpdateValidValue:a=>{i(Number(a))}}),e(y,{isSemiBoldFont:!0,children:"\u5E74"}),e(R,{override:"force",options:Array.from({length:12}).map((a,o)=>{let u=o+1;return{value:u,label:u}}),value:m.month,onUpdateValidValue:a=>{i(void 0,Number(a))}}),e(y,{isSemiBoldFont:!0,children:"\u6708"}),l!="month"&&f($,{children:[e(R,{override:"force",options:Array.from({length:31}).map((a,o)=>{let u=o+1;return u>n?null:{value:u,label:u}}),value:m.date,onUpdateValidValue:a=>{i(void 0,void 0,Number(a))}}),e(y,{isSemiBoldFont:!0,children:"\u65E5"})]})]})},MinMax:t=>{let{restrict:l,min:h,max:r}=t;if(!h&&!r)return null;let m=d(h||null),i=d(r||null),n="",a="";return l=="year"?(n=m.toFormat("%Y\u5E74"),a=i.toFormat("%Y\u5E74")):l.match(/month/)?(n=m.toFormatYM(),a=i.toFormatYM()):l.match(/date/)?(n=m.toFormatYMD(),a=i.toFormatYMD()):l.match(/clock/)&&(m=d().setFromFormatHHMM(h||""),i=d().setFromFormatHHMM(r||""),n=m.toFormatHM(),a=i.toFormatHM()),f(y.Micro,{fontHeight:1.2,children:[n&&f(y,{children:["\u6700\u5C0F: ",n]}),a&&f(y,{children:["\u6700\u5927: ",a]})]})},CurrentSign:()=>e(M,{position:"absolute",bottom:"1/6",left:"50%",width:1,unitHeight:"1/6",backgroundColor:"warn",xcss:{maxWidth:12*2.5,transform:"translateX(-50%)"},isRounded:!0}),PeriodFocusSign:()=>e(M,{position:"absolute",bottom:"1/4",left:"1/2",right:"1/2",backgroundColor:"theme",unitHeight:"1/4",boxShadow:"0.remark",isRounded:!0})}},A=j;A.picker={open:t=>{let l=null,h=null,r="L";t.restrict=="year"&&(r="S"),t.restrict=="month"&&(r="S"),t.restrict=="clock"?r="XS":(t.restrict=="locale.jp.warekiDate"||t.restrict=="period.clock")&&(r="S");let m=t.sheetID||O(),i=t.pickerId||O();_.open("middleCenter",{sheetID:m,size:r,padding:[2,0],closeAtAroundClick:!0,closeAtParentBlur:!1,onClose:()=>{t.onValueUpdate({value:l,era:h,eventType:"commit"})},content:f(L,{gap:"1/2",children:[f(C.Left,{children:[e(P,{}),e(x.Sub.S,{color:"cloud",ssSphere:3,onClick:()=>{_.close(m)},children:e(B.X,{})})]}),e(_.Body,{children:f(L,{borderRadius:"inherit",children:[e(L,{padding:1,children:e(j,{sheetID:m,pickerId:i,restrict:t.restrict,min:t.min,max:t.max,era:t.era,defaultValue:t.defaultValue,onValueUpdate:n=>{t.onValueUpdate(n),l=n.value,h=n.era,n.eventType=="commit"&&_.close(m)}})}),f(C.Left,{padding:1,position:"sticky",ssZIndex:10,bottom:0,gap:"1/2",borderTop:"1.thin",backgroundColor:"layer.0.opa.low",borderBottomLeftRadius:"inherit",borderBottomRightRadius:"inherit",xcss:{backdropFilter:"blur(3px)"},children:[e(x.Clear.S,{color:"cloud",tabIndex:-1,fontColor:"4.thin",borderRadius:"2.tone.secondary",flexSizing:"none",onClick:()=>{var n,a;(a=(n=W.get(i||""))==null?void 0:n.onClear)==null||a.call(n)},children:f(C.Center,{gap:"1/2",children:[e(B.X,{}),e(y.Micro,{children:"\u30EA\u30BB\u30C3\u30C8"})]})}),e(p.Parts.MinMax,{restrict:t.restrict,min:t.min,max:t.max}),e(P,{}),e(x.Prime.S,{tabIndex:-1,xcss:{minWidth:12*6},onClick:()=>{var n,a;(a=(n=W.get(i||""))==null?void 0:n.onConfirm)==null||a.call(n)},children:"\u78BA\u5B9A"})]})]})})]})})},close:t=>{_.close(t)}};export{A as TimeSelector,A as default};
@@ -1 +1 @@
1
- import{b as i,c as l,e as T}from"../../chunk-C5N2D3ZX.js";import{jsx as y,jsxs as h}from"react/jsx-runtime";import{useState as w,useEffect as S}from"react";import u,{UUID as m,useStore as v}from"jmini";import{$$fromRoot as k}from"../../@utils";import{InputClasses as b}from"../../@styles/componentClasses";import{Box as E,Flex as B,FAI as g,Column as D}from"../../atoms";import{Row as _,Literal as O}from"../../mols";import{Button as A}from"../Button";import V from"../Tooltips";const te=e=>{let[n]=w(e.componentId||m(12));e=i({},e),e.states=l(i({enableFormSubmit:!0,status_id:m(8),override:"never",form:"",id:m(),"aria-label":"Input-"+n},e.states),{componentId:n});let{children:a}=e;return y(a,i({},e.states))},ae=e=>{let{children:n,val_status:a,states:t}=e,{leftIcon:s,wrapStyles:f}=t,r=a.notice||[];return t.showInitValidation||a.eventType=="init"&&(r=[]),h(_.Center,l(i({position:"relative",verticalAlign:"unset",gap:0},f),{className:b("Wrapper"),"data-notice-uid":a.componentId,children:[y(x.Notice,{notice:r,val_status:a}),t.leftIndicator,h(B,{position:"relative",flexSizing:"auto",children:[n,s,y(x.RightIcon,i({},e)),y(x.ClearButton,i({},e))]}),t.rightIndicator]}))},x={ClearButton:e=>!e.states.clearButton||!e.val_status.rawValue?null:y(A.Normal,{ssSphere:2,flexCenter:!0,fontColor:"5.translucent",ssEffectsOnActive:["ripple.theme"],position:"absolute",ssZIndex:3,right:"2/3",top:"50%",xcss:{transform:"translateY(-50%)"},onClick:()=>{e.set_status(n=>l(i({},n),{rawValue:"",safeValue:"",eventType:"update",eventID:m(12),isInspected:!1}))},children:y(g.X,{})}),RightIcon:e=>e.states.clearButton&&e.val_status.rawValue?null:e.states.rightIcon,Notice:e=>{let{notice:n,val_status:a}=e,{componentId:t}=a,s="NoticeTimer-"+t,f="NoticeTimerClose-"+t,r="notice-tips-"+t;return S(()=>{u.interval.once(()=>{if(!(n!=null&&n.length)){V.close(r);return}V.open({tipsID:r,parent:`[data-notice-uid="${t}"]`,gravityPoint:24,padding:[1,0],closeAtParentBlur:!1,content:h(V.Body,{padding:["1/2","2/3"],fontSize:"1.mini",position:"relative",children:[y(E,{position:"absolute",unitHeight:1,unitWidth:1,right:1,backgroundColor:"dark",ssZIndex:1,xcss:{transform:"rotate(45deg)",top:-6}}),y(D,{backgroundColor:"inherit",gap:"1/3",ssZIndex:2,children:n.map((d,p)=>{let{type:o,label:c}=d,I=o=="invalid"?g.Exclamation:o=="warn"?g.Exclamation:g.Check;return h(_.Left,{gap:0,borderRadius:"2.tone.secondary",children:[y(I,{flexCenter:!0,fontSize:"2.normal",fontColor:{invalid:"nega",warn:"warn",valid:"posi"}[o]}),y(O.Supplement,{fontSize:"0.xs",fontColor:"white",children:c})]},p+"-"+u.Stringify(d))})})]})})},350,s),u.interval.once(()=>{V.close(r)},6e3,f)},[n]),null}},F={DefaultStatus:(e,n)=>({componentId:e,rawValue:n,eventType:"init",eventID:m(12)}),CommonEffects:function(e){let{type:n,states:a,val_status:t,set_status:s,SystemValidation:f}=e;a=i({},a);let{componentId:r}=t;S(()=>(v.update({[`input_alias:id:${a.id}`]:{componentId:r},[`input_alias:name:${a.name}`]:{componentId:r},[r]:{ResolveRefresh:null,remoteUpdate:d=>{s(p=>l(i({},p),{isInspected:!1,isValidated:!1,rawValue:d,status_id:m(8),eventType:"update.remote",eventID:m(12)}))},Refresh:()=>new Promise((d,p)=>{v.get(r).ResolveRefresh=d,s(o=>l(i({},o),{isInspected:!1,eventType:"refresh",eventID:m(12)}))})}}),()=>{v.delete(r)}),[]),S(()=>{F.ValidationCheck({val_status:t,set_status:s,SystemValidation:f,states:a})},[t.eventID,t.rawValue]),u.scope(()=>{let{override:d}=a;if(t.eventType=="update.remote"){s(R=>l(i(i({},R),e.ExtraOverrideStates&&e.ExtraOverrideStates(t.rawValue)),{eventType:"override",eventID:m(12),isInspected:!1,isValidated:!1}));return}if(d=="never"||d=="beforeModified"&&!u.isOneOf(t.eventType,"init","override")||t.isComposing)return;let p=v.get(t.componentId);if(!p)return;let o=a.value,c=t.rawValue;if(e.ExtraOverrideStates&&(o=e.ExtraOverrideStates(o).rawValue||o),u.isEqual(o,c)){p.status_id=a.status_id;return}let I=u.SortifyObject(o),C=u.SortifyObject(c);if(I&&C&&u.isEqual(I,C)){p.status_id=a.status_id;return}a.status_id!=p.status_id&&(t.eventType=="update"&&!t.isInspected||s(R=>l(i(l(i({},R),{rawValue:o}),e.ExtraOverrideStates&&e.ExtraOverrideStates(o)),{eventType:"override",eventID:m(12),isInspected:!1,isValidated:!1})))});{let{componentId:d,eventType:p}=t,o={eventType:p,componentId:d,isInspected:!!t.isInspected,isValidated:!!t.isValidated,isComposing:!!t.isComposing,isFocusing:!!t.isFocusing,isPickerOpen:!!t.isPickerOpen},c=t.rawValue;n=="autocomplete.single"?c=u.Arrayify(c)[0]:n=="list.radio"?c=u.Arrayify(c)[0]:a.isChecker&&(c=!!u.Arrayify(c)[0]),S(()=>(u.scope(()=>{if(a.form=a.form||"testForm",a.name&&a.form&&v.update({[["form-data",a.form].join("-")]:{[a.name]:{componentId:d,type:n,value:c,validation:t.isValidated}}}),!t.isInspected||p!="refresh")return;let I=v.get(d);I&&I.ResolveRefresh&&I.ResolveRefresh(null)}),()=>{v.update({[["form-data",a.form].join("-")]:{[a.name]:null}})}),[t]),S(()=>{a.onUserAction&&a.onUserAction(c,o)},[t]),S(()=>{t.isInspected&&p=="update"&&(a.onUpdateValue&&a.onUpdateValue(c,o),t.isValidated&&a.onUpdateValidValue&&a.onUpdateValidValue(c,o))},[t.isValidated,t.isInspected,t.rawValue])}},ValidationCheck:e=>{let{states:n}=e;if(e.val_status.isInspected)return;let a="ValidationTimer-"+e.val_status.componentId;u.interval.abort(a),e.set_status(r=>l(i({},r),{isInspected:!1,isValidated:!1}));let t=e.SystemValidation({value:e.val_status.rawValue,states:n});if(!t.ok){e.set_status(r=>l(i({},r),{isInspected:!0,isValidated:!!t.ok,notice:t.notice||[]}));return}let s=t.notice||[];const f=()=>T(void 0,null,function*(){if(!n.onValidate)return;let r=yield n.onValidate(e.val_status.rawValue,e.val_status.eventType,e.val_status);e.set_status(d=>l(i({},d),{isInspected:!0,isValidated:!!r.ok,notice:[...s,...r.notice||[]]}))});if(n.onValidate){if(e.val_status.eventType=="refresh"){f();return}u.interval.once(f,n.onValidateDelay||400,a);return}e.set_status(r=>l(i({},r),{eventID:m(12),isInspected:!0,isValidated:!0,notice:s}))},SubmitForm:(e,n)=>{let a=!1;if(!n)return a;let t=k(`[data-form-submit-button="${n}"]`)[0];if(!t)return a;let s=t.dataset.sdfike||"",f=e.key,r=e.ctrlKey||e.metaKey;return u.scope(()=>{s.includes("enter")&&(f!="Enter"||e.nativeEvent.isComposing||(e==null?void 0:e.keyCode)==229)||((f=="Enter"&&(s.includes("enter")||s.includes("auxEnter")&&r)||f==" "&&s.includes("space"))&&(t.click(),e.preventDefault()),a=!0)}),a},isShowValidation:(e,n)=>{let a=e.isValidated;return!n&&e.eventType=="init"?!0:a}},ne=function(e){e=i({tone:"border"},e);let n=u.scope(()=>{if(e.tone=="plain")return{};let t={padding:1,transition:"long",flexSizing:"auto",boxShadow:"0.min"};return e.tone=="border"?t=l(i({},t),{border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"}):e.tone=="cloud"?t=l(i({},t),{border:"1.thin",borderRadius:"2.tone.secondary",backgroundColor:"cloud"}):e.tone=="bottomBorder"&&(t=l(i({},t),{borderRadius:0,border:"unset",borderBottom:!0,backgroundColor:"cloud"})),t});return l(i(i(i(i(i(i({fontColor:"2.normal"},n),!!e.rightIcon&&{paddingRight:3}),!!e.leftIcon&&{paddingLeft:3}),!!e.leftIndicator&&{borderTopLeftRadius:"2/3",borderBottomLeftRadius:"2/3",marginLeft:"1/4"}),!!e.rightIndicator&&{borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",marginRight:"1/4"}),e),{xcss:i({letterSpacing:"1px",resize:"none"},e.xcss),className:[b("Input"),e.className].join(" ")})};export{ae as BoxWrapper,F as CoreEffects,ne as DefaultBoxishStyles,te as OptionalInputWrapper};
1
+ import{b as i,c as l,e as T}from"../../chunk-C5N2D3ZX.js";import{jsx as y,jsxs as h}from"react/jsx-runtime";import{useState as w,useEffect as S}from"react";import u,{UUID as m,useStore as v}from"jmini";import{$$fromRoot as k}from"../../@utils";import{InputClasses as b}from"../../@styles/componentClasses";import{Box as E,Flex as B,FAI as g,Column as D}from"../../atoms";import{Row as _,Literal as O}from"../../mols";import{Button as A}from"../Button";import V from"../Tooltips";const te=e=>{let[n]=w(e.componentId||m(12));e=i({},e),e.states=l(i({enableFormSubmit:!0,status_id:m(8),override:"never",form:"",id:m(),"aria-label":"Input-"+n},e.states),{componentId:n});let{children:a}=e;return y(a,i({},e.states))},ae=e=>{let{children:n,val_status:a,states:t}=e,{leftIcon:s,wrapStyles:f}=t,r=a.notice||[];return t.showInitValidation||a.eventType=="init"&&(r=[]),h(_.Center,l(i({position:"relative",verticalAlign:"unset",gap:0},f),{className:b("Wrapper"),"data-notice-uid":a.componentId,children:[y(C.Notice,{notice:r,val_status:a}),t.leftIndicator,h(B,{position:"relative",flexSizing:"auto",children:[n,s,y(C.RightIcon,i({},e)),y(C.ClearButton,i({},e))]}),t.rightIndicator]}))},C={ClearButton:e=>!e.states.clearButton||!e.val_status.rawValue?null:y(A.Normal,{ssSphere:2,flexCenter:!0,fontColor:"5.translucent",ssEffectsOnActive:["ripple.theme"],position:"absolute",ssZIndex:3,right:"2/3",top:"50%",xcss:{transform:"translateY(-50%)"},onClick:()=>{e.set_status(n=>l(i({},n),{rawValue:"",safeValue:"",eventType:"update",eventID:m(12),isInspected:!1}))},children:y(g.X,{})}),RightIcon:e=>e.states.clearButton&&e.val_status.rawValue?null:e.states.rightIcon,Notice:e=>{let{notice:n,val_status:a}=e,{componentId:t}=a,s="NoticeTimer-"+t,f="NoticeTimerClose-"+t,r="notice-tips-"+t;return S(()=>{u.interval.once(()=>{if(!(n!=null&&n.length)){V.close(r);return}V.open({tipsID:r,parent:`[data-notice-uid="${t}"]`,gravityPoint:24,padding:[1,0],closeAtParentBlur:!1,content:h(V.Body,{padding:["1/2","2/3"],fontSize:"1.mini",position:"relative",children:[y(E,{position:"absolute",unitHeight:1,unitWidth:1,right:1,backgroundColor:"dark",ssZIndex:1,xcss:{transform:"rotate(45deg)",top:-6}}),y(D,{backgroundColor:"inherit",gap:"1/3",ssZIndex:2,children:n.map((d,p)=>{let{type:o,label:c}=d,I=o=="invalid"?g.Exclamation:o=="warn"?g.Exclamation:g.Check;return h(_.Left,{gap:0,borderRadius:"2.tone.secondary",children:[y(I,{flexCenter:!0,fontSize:"2.normal",fontColor:{invalid:"nega",warn:"warn",valid:"posi"}[o]}),y(O.Micro,{fontColor:"white",children:c})]},p+"-"+u.Stringify(d))})})]})})},350,s),u.interval.once(()=>{V.close(r)},6e3,f)},[n]),null}},F={DefaultStatus:(e,n)=>({componentId:e,rawValue:n,eventType:"init",eventID:m(12)}),CommonEffects:function(e){let{type:n,states:a,val_status:t,set_status:s,SystemValidation:f}=e;a=i({},a);let{componentId:r}=t;S(()=>(v.update({[`input_alias:id:${a.id}`]:{componentId:r},[`input_alias:name:${a.name}`]:{componentId:r},[r]:{ResolveRefresh:null,remoteUpdate:d=>{s(p=>l(i({},p),{isInspected:!1,isValidated:!1,rawValue:d,status_id:m(8),eventType:"update.remote",eventID:m(12)}))},Refresh:()=>new Promise((d,p)=>{v.get(r).ResolveRefresh=d,s(o=>l(i({},o),{isInspected:!1,eventType:"refresh",eventID:m(12)}))})}}),()=>{v.delete(r)}),[]),S(()=>{F.ValidationCheck({val_status:t,set_status:s,SystemValidation:f,states:a})},[t.eventID,t.rawValue]),u.scope(()=>{let{override:d}=a;if(t.eventType=="update.remote"){s(R=>l(i(i({},R),e.ExtraOverrideStates&&e.ExtraOverrideStates(t.rawValue)),{eventType:"override",eventID:m(12),isInspected:!1,isValidated:!1}));return}if(d=="never"||d=="beforeModified"&&!u.isOneOf(t.eventType,"init","override")||t.isComposing)return;let p=v.get(t.componentId);if(!p)return;let o=a.value,c=t.rawValue;if(e.ExtraOverrideStates&&(o=e.ExtraOverrideStates(o).rawValue||o),u.isEqual(o,c)){p.status_id=a.status_id;return}let I=u.SortifyObject(o),x=u.SortifyObject(c);if(I&&x&&u.isEqual(I,x)){p.status_id=a.status_id;return}a.status_id!=p.status_id&&(t.eventType=="update"&&!t.isInspected||s(R=>l(i(l(i({},R),{rawValue:o}),e.ExtraOverrideStates&&e.ExtraOverrideStates(o)),{eventType:"override",eventID:m(12),isInspected:!1,isValidated:!1})))});{let{componentId:d,eventType:p}=t,o={eventType:p,componentId:d,isInspected:!!t.isInspected,isValidated:!!t.isValidated,isComposing:!!t.isComposing,isFocusing:!!t.isFocusing,isPickerOpen:!!t.isPickerOpen},c=t.rawValue;n=="autocomplete.single"?c=u.Arrayify(c)[0]:n=="list.radio"?c=u.Arrayify(c)[0]:a.isChecker&&(c=!!u.Arrayify(c)[0]),S(()=>(u.scope(()=>{if(a.form=a.form||"testForm",a.name&&a.form&&v.update({[["form-data",a.form].join("-")]:{[a.name]:{componentId:d,type:n,value:c,validation:t.isValidated}}}),!t.isInspected||p!="refresh")return;let I=v.get(d);I&&I.ResolveRefresh&&I.ResolveRefresh(null)}),()=>{v.update({[["form-data",a.form].join("-")]:{[a.name]:null}})}),[t]),S(()=>{a.onUserAction&&a.onUserAction(c,o)},[t]),S(()=>{t.isInspected&&p=="update"&&(a.onUpdateValue&&a.onUpdateValue(c,o),t.isValidated&&a.onUpdateValidValue&&a.onUpdateValidValue(c,o))},[t.isValidated,t.isInspected,t.rawValue])}},ValidationCheck:e=>{let{states:n}=e;if(e.val_status.isInspected)return;let a="ValidationTimer-"+e.val_status.componentId;u.interval.abort(a),e.set_status(r=>l(i({},r),{isInspected:!1,isValidated:!1}));let t=e.SystemValidation({value:e.val_status.rawValue,states:n});if(!t.ok){e.set_status(r=>l(i({},r),{isInspected:!0,isValidated:!!t.ok,notice:t.notice||[]}));return}let s=t.notice||[];const f=()=>T(void 0,null,function*(){if(!n.onValidate)return;let r=yield n.onValidate(e.val_status.rawValue,e.val_status.eventType,e.val_status);e.set_status(d=>l(i({},d),{isInspected:!0,isValidated:!!r.ok,notice:[...s,...r.notice||[]]}))});if(n.onValidate){if(e.val_status.eventType=="refresh"){f();return}u.interval.once(f,n.onValidateDelay||400,a);return}e.set_status(r=>l(i({},r),{eventID:m(12),isInspected:!0,isValidated:!0,notice:s}))},SubmitForm:(e,n)=>{let a=!1;if(!n)return a;let t=k(`[data-form-submit-button="${n}"]`)[0];if(!t)return a;let s=t.dataset.sdfike||"",f=e.key,r=e.ctrlKey||e.metaKey;return u.scope(()=>{s.includes("enter")&&(f!="Enter"||e.nativeEvent.isComposing||(e==null?void 0:e.keyCode)==229)||((f=="Enter"&&(s.includes("enter")||s.includes("auxEnter")&&r)||f==" "&&s.includes("space"))&&(t.click(),e.preventDefault()),a=!0)}),a},isShowValidation:(e,n)=>{let a=e.isValidated;return!n&&e.eventType=="init"?!0:a}},ne=function(e){e=i({tone:"border"},e);let n=u.scope(()=>{if(e.tone=="plain")return{};let t={padding:1,transition:"long",flexSizing:"auto",boxShadow:"0.min"};return e.tone=="border"?t=l(i({},t),{border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"}):e.tone=="cloud"?t=l(i({},t),{border:"1.thin",borderRadius:"2.tone.secondary",backgroundColor:"cloud"}):e.tone=="bottomBorder"&&(t=l(i({},t),{borderRadius:0,border:"unset",borderBottom:!0,backgroundColor:"cloud"})),t});return l(i(i(i(i(i(i({fontColor:"2.normal"},n),!!e.rightIcon&&{paddingRight:3}),!!e.leftIcon&&{paddingLeft:3}),!!e.leftIndicator&&{borderTopLeftRadius:"2/3",borderBottomLeftRadius:"2/3",marginLeft:"1/4"}),!!e.rightIndicator&&{borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",marginRight:"1/4"}),e),{xcss:i({letterSpacing:"1px",resize:"none"},e.xcss),className:[b("Input"),e.className].join(" ")})};export{ae as BoxWrapper,F as CoreEffects,ne as DefaultBoxishStyles,te as OptionalInputWrapper};
@@ -1 +1 @@
1
- import"../chunk-C5N2D3ZX.js";import{jsx as o,jsxs as r}from"react/jsx-runtime";import{Box as t,FAI as d,Column as a}from"../atoms";import{Row as m,Literal as e}from"../mols";import{Anchor as i}from"./Button";const l=()=>{let{href:n}=location;return o(m.Center,{padding:[4,1],children:r(a,{ssCardBox:!0,gap:2,padding:[3,2],textAlign:"center",width:1,xcss:{maxWidth:12*30},children:[o(d.LinkSlash,{fontColor:"theme",xcss:{fontSize:"3rem"}}),r(t,{children:[o(e.Paragraph,{children:"\u3053\u306E\u30DA\u30FC\u30B8\u306F\u3054\u5229\u7528\u3044\u305F\u3060\u3051\u307E\u305B\u3093\u3002"}),o(e.Supplement,{fontColor:"3.blur",children:"\u5165\u529B\u3055\u308C\u305F\u30EA\u30F3\u30AF\u306E\u30DA\u30FC\u30B8\u306F\u5B58\u5728\u3057\u307E\u305B\u3093\u3067\u3057\u305F\u3002"})]}),r(a,{children:[r(e,{textAlign:"left",ssCardBox:"cloud",isSemiBoldFont:!0,padding:1,children:["\u30FB\u30EA\u30F3\u30AF\u304C\u6B63\u3057\u3044\u304B",o(t,{margin:["1/2",0],borderBottom:!0}),"\u30FB\u30EA\u30F3\u30AF\u306E\u6709\u52B9\u671F\u9650",o(t,{margin:["1/2",0],borderBottom:!0}),"\u30FB\u30A2\u30AF\u30BB\u30B9\u6A29\u9650\u7B49\u304C\u6B63\u3057\u3044\u304B"]}),"\u306A\u3069\u3092\u3082\u3046\u4E00\u5EA6\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002"]}),o(i.Link,{newTab:!0,href:n,children:n}),o(i.BorderToFill,{href:"/",width:1,children:"\u30DB\u30FC\u30E0\u306B\u623B\u308B"})]})})};export{l as PageNotFound,l as default};
1
+ import"../chunk-C5N2D3ZX.js";import{jsx as o,jsxs as r}from"react/jsx-runtime";import{Box as t,FAI as d,Column as a}from"../atoms";import{Row as m,Literal as e}from"../mols";import{Anchor as i}from"./Button";const l=()=>{let{href:n}=location;return o(m.Center,{padding:[4,1],children:r(a,{ssCardBox:!0,gap:2,padding:[3,2],textAlign:"center",width:1,xcss:{maxWidth:12*30},children:[o(d.LinkSlash,{fontColor:"theme",xcss:{fontSize:"3rem"}}),r(t,{children:[o(e.Paragraph,{children:"\u3053\u306E\u30DA\u30FC\u30B8\u306F\u3054\u5229\u7528\u3044\u305F\u3060\u3051\u307E\u305B\u3093\u3002"}),o(e.Mini,{fontColor:"3.blur",children:"\u5165\u529B\u3055\u308C\u305F\u30EA\u30F3\u30AF\u306E\u30DA\u30FC\u30B8\u306F\u5B58\u5728\u3057\u307E\u305B\u3093\u3067\u3057\u305F\u3002"})]}),r(a,{children:[r(e,{textAlign:"left",ssCardBox:"cloud",isSemiBoldFont:!0,padding:1,children:["\u30FB\u30EA\u30F3\u30AF\u304C\u6B63\u3057\u3044\u304B",o(t,{margin:["1/2",0],borderBottom:!0}),"\u30FB\u30EA\u30F3\u30AF\u306E\u6709\u52B9\u671F\u9650",o(t,{margin:["1/2",0],borderBottom:!0}),"\u30FB\u30A2\u30AF\u30BB\u30B9\u6A29\u9650\u7B49\u304C\u6B63\u3057\u3044\u304B"]}),"\u306A\u3069\u3092\u3082\u3046\u4E00\u5EA6\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002"]}),o(i.Link,{newTab:!0,href:n,children:n}),o(i.BorderToFill,{href:"/",width:1,children:"\u30DB\u30FC\u30E0\u306B\u623B\u308B"})]})})};export{l as PageNotFound,l as default};
@@ -1 +1 @@
1
- import{b as r,c as m,d as $}from"../../chunk-C5N2D3ZX.js";import{Fragment as z,jsx as a,jsxs as _}from"react/jsx-runtime";import D,{UUID as G,useStore as Q}from"jmini";import{useState as Y,useEffect as W}from"react";import{useRemote as E}from"../../@utils";import{Box as B,Flex as K,FAI as N,Span as le,Column as oe}from"../../atoms";import{Literal as ne,Row as j}from"../../mols";import{Button as F}from"../Button";import ee from"../Sheet";import I from"../Input";import{faArrowUp as se}from"@fortawesome/free-solid-svg-icons/faArrowUp";import{faArrowDown as ie}from"@fortawesome/free-solid-svg-icons/faArrowDown";import{faArrowRight as ce}from"@fortawesome/free-solid-svg-icons/faArrowRight";import{faFilter as de}from"@fortawesome/free-solid-svg-icons/faFilter";import R from"./Parts";import ue from"./Wrapper";import{DefaultCellSystemAdjustingStyles as M}from"./cellStyling";import{TableClasses as b}from"../../@styles/componentClasses";const x={__memoryID:G(),Header:t=>{var g,w;let{val_status:e,set_status:i,KeywordFilterRows:h}=r({},t),{order:s,filter:l}=e,[d,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=M(n),u=e.cellStylesCallback?e.cellStylesCallback(n):{};S.push(a(R.TH,m(r(r(r({fontWeight:"2.normal",position:"sticky",ssZIndex:2,top:0,unitWidth:4,padding:0},e.cellStyles),o),u),{xcss:r(r({},(g=e.cellStyles)==null?void 0:g.xcss),u.xcss),className:[b("Cell"),e.cellClassName].join(" "),children:a(B,{flexCenter:!0,children:a(I.Checker,{label:"",value:!1,onUpdateValidValue:f=>{let y=e.rows;y.forEach(T=>{T.checked=f}),i(m(r({},e),{rows:y}))}})})}),-1))}for(let n=0;n<e.colLength;n++){let o=c[n];if(!o)continue;let u=o.children||o.data,f=s.enabled&&s.column[n],y=l.enabled&&l.column[n],T=f?a(N,{fontSize:"1.mini",fontColor:n==d?"1.clear":"5.translucent",icon:n==d?p=="DESC"?ie:se:ce}):null,v=a(z,{});if(y){let L=h.map(O=>{var A;return(A=O[n])==null?void 0:A.data});L=[...new Set(L)].toASC();let P=l.current[n];if(P){let O=L.filter(C=>!P.includes(C)),A=[];L.forEach(C=>{C&&A.push({value:C,label:a(B,{flexSizing:"auto",children:C})})});let J="BUTTON-"+e.componentId+"-"+n,X=e.componentId+"-"+n,re={sheetID:X,parent:"#"+J,gravityPoint:23,content:_(K,{flexType:"col",border:!0,boxShadow:"3.remark",backgroundColor:"layer.1",borderRadius:1,xcss:{minWidth:12*20,maxWidth:12*30},children:[a(oe,{gap:"1/3",overflow:"auto",padding:"2/3",xcss:{maxHeight:12*30},children:a(I.Checkbox,{icon:!0,value:O,display:"flex",gap:"2/3",override:"force",options:A,hideInput:!0,name:"DTFilter-col-"+n+"-table-"+e.componentId,onUpdateValidValue:C=>{let H=L.filter(ae=>!C.includes(ae)),Z=r({},e);Z.filter.current[n]=H,i(Z)}})}),_(j.Separate,{gap:"2/3",padding:"2/3",horizontalAlign:"right",children:[a(F.Border.S,{isRounded:!0,onClick:()=>{ee.close(X)},children:"\u9589\u3058\u308B"}),a(F.Prime.S,{color:"theme",isRounded:!0,ssEffectsOnActive:"shrink",onClick:()=>{let C=[];P.length||(C=L);let H=r({},e);H.filter.current[n]=C,i(H)},children:"\u5168\u9078\u629E"})]})]})};v=a(B,{className:b("FilterRegion"),children:a(F.Sub.S,{ssSphere:2.5,fontSize:"1.mini",className:b("Filtering_"+!!P.length),id:J,onClick:C=>{C.stopPropagation(),ee.open("custom",re)},children:a(N,{icon:de})})})}}let U={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=M(U),q=e.cellStylesCallback?e.cellStylesCallback(U):{};o=m(r(r(r(r({},e.cellStyles),te),o),q),{ssPushable:f,xcss:r(r(r({},(w=e.cellStyles)==null?void 0:w.xcss),q.xcss),o.xcss),className:[b("Cell"),e.cellClassName,o.className].join(" ")}),delete o.orderIndex,S.push(a(R.TH,m(r({fontWeight:"2.normal",position:"sticky",ssZIndex:2,top:0},o),{onClick:L=>{if(f){let P=r({},e),O=[n,d===n?p=="ASC"?"DESC":"ASC":s.priority];P.order.current=O,i(P),e.onOrderChanged&&e.onOrderChanged(O)}},children:_(K,{flexType:"row-r",flexWrap:!1,height:1,borderRadius:"inherit",flexCenter:!0,children:[v,_(K,{flexSizing:0,position:"relative",borderRadius:"inherit",gap:"1/2",flexWrap:!1,verticalAlign:"center",horizontalAlign:"center",children:[T,u]})]})}),n))}return a(R.Row,{className:[b("Row"),b("HeadRow")].join(" "),children:S})},Body:t=>{let{val_status:e,PageRows:i}=t,h=[];if(i.forEach((s,l)=>{var S;let d=[...s],p=[];if(e.checker){let c={top:l==0&&!e.head,bottom:l==i.length-1,left:!0,right:!e.colLength,rowIndex:l,colIndex:0,isBody:!0,isHeader:!1},g=M(c),w=e.cellStylesCallback?e.cellStylesCallback(c):{};p.push(a(R.TH,m(r(r(r({unitWidth:4,padding:0,borderRight:!0},e.cellStyles),g),w),{xcss:r(r({},(S=e.cellStyles)==null?void 0:S.xcss),w.xcss),className:[b("Cell"),e.cellClassName].join(" "),children:a(B,{flexCenter:!0,children:a(I.Checker,{label:"",value:s.checked,override:"force",onUpdateValidValue:n=>{let o=e.rows,u=o.findIndex(f=>D.isEqual(f.rowID,s.rowID));u!=-1&&(o[u].checked=n,t.set_status(f=>m(r({},f),{rows:o})))}})})}),-1))}d.forEach((c,g)=>{var v;if(!c)return;let T=c,{type:w="td"}=T,n=$(T,["type"]),o={top:l==0&&!e.head,bottom:l==i.length-1,left:e.checker?!1:g==0,right:g==e.colLength-1,rowIndex:l,colIndex:g,isBody:!0,isHeader:!1},u=M(o),f=e.cellStylesCallback?e.cellStylesCallback(o):{};n=m(r(r(r(r({},e.cellStyles),u),n),f),{xcss:r(r(r({},(v=e.cellStyles)==null?void 0:v.xcss),n.xcss),f.xcss),className:[b("Cell"),e.cellClassName,n.className].join(" ")}),delete n.orderIndex;let y=R[w=="td"?"TD":"TH"];p.push(a(y,r({},n),g))}),h.push(a(R.Row,{className:[b("Row"),b("BodyRow")].join(" "),children:p,onClick:c=>{e.onRowClick&&e.onRowClick(s.rowID,c)}},l))}),!i.length){let s=a(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=a(z,{children:e.noRecords})),h.push(a(R.Row,{className:[b("Row"),b("BodyRow"),b("DataNotFound")].join(" "),children:a(R.TD,{colSpan:e.colLength,className:b("Cell"),children:s})},"dataNotFound"))}return a(z,{children:h})},Core:t=>{let{val_status:e,set_status:i}=t,{searchKeyword:h,filter:s,order:l,paging:d}=e,p=[...e.rows],S=[...e.rows],c=[...e.rows],g=[...e.rows];if(h&&(S=p.filter(o=>(o.__sys4SearchKey||"").match(new RegExp(String(h).escapeRegExChar(),"i"))?1:0),c=[...S],g=[...S]),s.enabled)for(let o=0;o<e.colLength;o++){let u=s.column[o],f=s.current[o];u&&f&&f.length&&(c=c.filter(y=>!f.includes(y[o].data)),g=[...c])}l.enabled&&(l.current[1]=="ASC"?c=c.toASC(l.current[0]+"[orderIndex]"):c=c.toDESC(l.current[0]+"[orderIndex]"),g=[...c]);{let{currentPageIndex:o,rowLength:u}=d;g=[...g].splice((o-1)*u,u)}let w=x.__memoryID+"_"+e.tableID,n={rows:{total:p.length,page:g.length,filtered:c.length},val_status:m(r({},e),{paging:m(r({},e.paging),{pageLength:Math.ceil(c.length/e.paging.rowLength)})}),set_status:i};return Q.update({[w]:{getRowData:()=>{let o=[...p];return l.enabled&&(l.current[1]=="ASC"?o=o.toASC(l.current[0]+"[orderIndex]"):o=o.toDESC(l.current[0]+"[orderIndex]")),o.forEach(u=>{u.currentPage=!1,u.filtered=!1}),g.forEach(u=>{let{rowID:f}=u;o.find(y=>D.isEqual(y.rowID,f)).currentPage=!0}),c.forEach(u=>{let{rowID:f}=u;o.find(y=>D.isEqual(y.rowID,f)).filtered=!0}),o}}}),W(()=>{E.bridge(e.tableID,n)}),a(B,{className:b("TableBase"),children:a(R.Table,{className:b("Table"),children:_(R.Body,{children:[a(x.Header,{val_status:e,set_status:i,KeywordFilterRows:S}),a(x.Body,{val_status:e,set_status:i,PageRows:g})]})})},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 l;return D.isBoolean(t.filter)?t.filter:(l=t.filter[s])!=null?l:!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 l;return D.isBoolean(t.order)?t.order:(l=t.order[s])!=null?l:!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 l=[];h.forEach((d,p)=>{let{data:S,children:c,orderIndex:g}=d;d.orderIndex=D.isExist(g)?String(g):String(S),d.children=c||String(S),l.push(String(d.data))}),h.__sys4SearchKey=l.join("/")}),a(x.StateManager,r({},t))},StateManager:t=>{let{colLength:e,checker:i=!1,searchKeyword:h="",filter:s,order:l,orderPriority:d="ASC",defaultOrder:p=[0,d],pageRowLength:S=30}=t,[c]=Y(G()),g={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:l!==!1,column:l,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]=Y(g);const o=()=>{const u=new WeakSet;return(f,y)=>{if(typeof y=="object"&&y!==null){if(u.has(y))return"[Circular Reference]";if(f=="children")return"[React Element]";u.add(y)}return y}};return W(()=>{n(u=>m(r({},u),{rows:g.rows}))},[D.Stringify(g.rows,o())]),W(()=>{n(u=>m(r({},u),{head:g.head}))},[D.Stringify(g.head,o())]),a(x.Core,{val_status:w,set_status:n})}},ge={__memoryID:x.__memoryID,getRowData:t=>{let e=Q.get(x.__memoryID+"_"+t);if(e!=null&&e.getRowData)return e.getRowData()}},V={SearchInput:t=>{let e=E.catch(t.tableID);if(!e)return null;let{val_status:i,set_status:h}=e;return a(I.TextField,{label:"\u691C\u7D22...",clearButton:!0,padding:"2/3",paddingRight:3,rightIcon:a(I.RightIcon,{ssSphere:2,fontColor:"5.translucent",right:"2/3",children:a(N.Search,{})}),value:i.searchKeyword,onUpdateValidValue:s=>{t.onChange(s),D.interval.once(()=>{h(l=>m(r({},l),{paging:m(r({},l.paging),{currentPageIndex:1}),filter:m(r({},l.filter),{current:Array.from({length:l.colLength},()=>[])}),searchKeyword:s}))},200,"InputSearchTime")}})},Info:t=>{let e=E.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 _(K,{verticalAlign:"baseline",gap:"1/2",fontSize:"1.mini",fontColor:"3.blur",children:[a(le,{fontSize:"4.thirdTitle",fontColor:"theme",children:e.rows.filtered.toLocaleString()}),"/ ",e.rows.total.toLocaleString(),"\u4EF6 (",s,"%)"]})},Paging:t=>{let e=E.catch(t.tableID);if(!e)return null;let{val_status:i,set_status:h}=e,s=[];for(let d=0;d<i.paging.pageLength;d++)s.push({value:d+1,label:(d+1).toString()});const l=d=>{let p=Math.min(Math.max(1,d),i.paging.pageLength),S=r({},i);S.paging.currentPageIndex=p,h(c=>m(r({},c),{paging:m(r({},c.paging),{currentPageIndex:p})}))};return a(I.Select,{emptySelect:!1,padding:["1/3","2/3"],override:"force",gap:0,leftIcon:a(I.LeftIcon,{xcss:{left:2,pointerEvents:"all"},children:a(F.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(i.paging.currentPageIndex==1){l(i.paging.pageLength);return}l(i.paging.currentPageIndex-1)},children:a(N.ChevronLeft,{})})}),rightIcon:a(I.RightIcon,{xcss:{right:2,pointerEvents:"all"},children:a(F.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(i.paging.currentPageIndex==i.paging.pageLength){l(1);return}l(i.paging.currentPageIndex+1)},children:a(N.ChevronRight,{})})}),options:s.map(d=>({value:d.value,label:_(j.Left,{gap:"1/3",verticalAlign:"baseline",children:[d.label,_(ne,{fontColor:"4.thin",fontSize:"0.xs",children:["/ ",i.paging.pageLength]})]})})),value:i.paging.currentPageIndex,onUpdateValidValue:d=>{l(d)}})},RowLength:t=>{let e=E.catch(t.tableID);if(!e)return null;let{val_status:i,set_status:h}=e,s=i.paging.rowLength,l=0,d=t.lengthSelect.map(p=>(l|=+(p==s),{value:p,label:p.toString()}));return l||d.push({value:s,label:s.toString()}),a(j.Center,{gap:"1/2",children:a(I.Select,{emptySelect:!1,override:"force",padding:"1/3",paddingLeft:3,paddingRight:2,pickerStyles:{xcss:{minWidth:12*9}},pickerPosition:4,value:i.paging.rowLength,leftIcon:a(I.LeftIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{left:6},children:"\u8868\u793A"}),rightIcon:a(I.RightIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{right:6},children:"\u4EF6"}),options:d.toASC("value"),onUpdateValidValue:p=>{h(S=>m(r({},S),{paging:{rowLength:Number(p),currentPageIndex:1,pageLength:Math.ceil(e.rows.filtered/Number(p))}}))}})})}},he=t=>a(ue,m(r({},t),{type:"data",JSXChildren:x.DataLeveler})),k=he;k.__memoryID=x.__memoryID,k.getRowData=ge.getRowData,k.Info=V.Info,k.Paging=V.Paging,k.RowLength=V.RowLength,k.SearchInput=V.SearchInput;export{k as Data,k as default};
1
+ import{b as r,c as S,d as $}from"../../chunk-C5N2D3ZX.js";import{Fragment as U,jsx as a,jsxs as _}from"react/jsx-runtime";import D,{UUID as G,useStore as Q}from"jmini";import{useState as Y,useEffect as W}from"react";import{useRemote as E}from"../../@utils";import{Box as B,Flex as M,FAI as N,Span as le,Column as oe}from"../../atoms";import{Literal as ne,Row as j}from"../../mols";import{Button as F}from"../Button";import ee from"../Sheet";import I from"../Input";import{faArrowUp as se}from"@fortawesome/free-solid-svg-icons/faArrowUp";import{faArrowDown as ie}from"@fortawesome/free-solid-svg-icons/faArrowDown";import{faArrowRight as ce}from"@fortawesome/free-solid-svg-icons/faArrowRight";import{faFilter as de}from"@fortawesome/free-solid-svg-icons/faFilter";import R from"./Parts";import ue from"./Wrapper";import{DefaultCellSystemAdjustingStyles as K}from"./cellStyling";import{TableClasses as b}from"../../@styles/componentClasses";const x={__memoryID:G(),Header:t=>{var g,w;let{val_status:e,set_status:i,KeywordFilterRows:h}=r({},t),{order:s,filter:l}=e,[d,p]=s.current,m=[],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=K(n),u=e.cellStylesCallback?e.cellStylesCallback(n):{};m.push(a(R.TH,S(r(r(r({fontWeight:"2.normal",position:"sticky",ssZIndex:2,top:0,unitWidth:4,padding:0},e.cellStyles),o),u),{xcss:r(r({},(g=e.cellStyles)==null?void 0:g.xcss),u.xcss),className:[b("Cell"),e.cellClassName].join(" "),children:a(B,{flexCenter:!0,children:a(I.Checker,{label:"",value:!1,onUpdateValidValue:f=>{let y=e.rows;y.forEach(T=>{T.checked=f}),i(S(r({},e),{rows:y}))}})})}),-1))}for(let n=0;n<e.colLength;n++){let o=c[n];if(!o)continue;let u=o.children||o.data,f=s.enabled&&s.column[n],y=l.enabled&&l.column[n],T=f?a(N,{fontSize:"1.mini",fontColor:n==d?"1.clear":"5.translucent",icon:n==d?p=="DESC"?ie:se:ce}):null,v=a(U,{});if(y){let L=h.map(O=>{var A;return(A=O[n])==null?void 0:A.data});L=[...new Set(L)].toASC();let P=l.current[n];if(P){let O=L.filter(C=>!P.includes(C)),A=[];L.forEach(C=>{C&&A.push({value:C,label:a(B,{flexSizing:"auto",children:C})})});let J="BUTTON-"+e.componentId+"-"+n,X=e.componentId+"-"+n,re={sheetID:X,parent:"#"+J,gravityPoint:23,content:_(M,{flexType:"col",border:!0,boxShadow:"3.remark",backgroundColor:"layer.1",borderRadius:1,xcss:{minWidth:12*20,maxWidth:12*30},children:[a(oe,{gap:"1/3",overflow:"auto",padding:"2/3",xcss:{maxHeight:12*30},children:a(I.Checkbox,{icon:!0,value:O,display:"flex",gap:"2/3",override:"force",options:A,hideInput:!0,name:"DTFilter-col-"+n+"-table-"+e.componentId,onUpdateValidValue:C=>{let H=L.filter(ae=>!C.includes(ae)),Z=r({},e);Z.filter.current[n]=H,i(Z)}})}),_(j.Separate,{gap:"2/3",padding:"2/3",horizontalAlign:"right",children:[a(F.Border.S,{isRounded:!0,onClick:()=>{ee.close(X)},children:"\u9589\u3058\u308B"}),a(F.Prime.S,{color:"theme",isRounded:!0,ssEffectsOnActive:"shrink",onClick:()=>{let C=[];P.length||(C=L);let H=r({},e);H.filter.current[n]=C,i(H)},children:"\u5168\u9078\u629E"})]})]})};v=a(B,{className:b("FilterRegion"),children:a(F.Sub.S,{ssSphere:2.5,fontSize:"1.mini",className:b("Filtering_"+!!P.length),id:J,onClick:C=>{C.stopPropagation(),ee.open("custom",re)},children:a(N,{icon:de})})})}}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=K(z),q=e.cellStylesCallback?e.cellStylesCallback(z):{};o=S(r(r(r(r({},e.cellStyles),te),o),q),{ssPushable:f,xcss:r(r(r({},(w=e.cellStyles)==null?void 0:w.xcss),q.xcss),o.xcss),className:[b("Cell"),e.cellClassName,o.className].join(" ")}),delete o.orderIndex,m.push(a(R.TH,S(r({fontWeight:"2.normal",position:"sticky",ssZIndex:2,top:0},o),{onClick:L=>{if(f){let P=r({},e),O=[n,d===n?p=="ASC"?"DESC":"ASC":s.priority];P.order.current=O,i(P),e.onOrderChanged&&e.onOrderChanged(O)}},children:_(M,{flexType:"row-r",flexWrap:!1,height:1,borderRadius:"inherit",flexCenter:!0,children:[v,_(M,{flexSizing:0,position:"relative",borderRadius:"inherit",gap:"1/2",flexWrap:!1,verticalAlign:"center",horizontalAlign:"center",children:[T,u]})]})}),n))}return a(R.Row,{className:[b("Row"),b("HeadRow")].join(" "),children:m})},Body:t=>{let{val_status:e,PageRows:i}=t,h=[];if(i.forEach((s,l)=>{var m;let d=[...s],p=[];if(e.checker){let c={top:l==0&&!e.head,bottom:l==i.length-1,left:!0,right:!e.colLength,rowIndex:l,colIndex:0,isBody:!0,isHeader:!1},g=K(c),w=e.cellStylesCallback?e.cellStylesCallback(c):{};p.push(a(R.TH,S(r(r(r({unitWidth:4,padding:0,borderRight:!0},e.cellStyles),g),w),{xcss:r(r({},(m=e.cellStyles)==null?void 0:m.xcss),w.xcss),className:[b("Cell"),e.cellClassName].join(" "),children:a(B,{flexCenter:!0,children:a(I.Checker,{label:"",value:s.checked,override:"force",onUpdateValidValue:n=>{let o=e.rows,u=o.findIndex(f=>D.isEqual(f.rowID,s.rowID));u!=-1&&(o[u].checked=n,t.set_status(f=>S(r({},f),{rows:o})))}})})}),-1))}d.forEach((c,g)=>{var v;if(!c)return;let T=c,{type:w="td"}=T,n=$(T,["type"]),o={top:l==0&&!e.head,bottom:l==i.length-1,left:e.checker?!1:g==0,right:g==e.colLength-1,rowIndex:l,colIndex:g,isBody:!0,isHeader:!1},u=K(o),f=e.cellStylesCallback?e.cellStylesCallback(o):{};n=S(r(r(r(r({},e.cellStyles),u),n),f),{xcss:r(r(r({},(v=e.cellStyles)==null?void 0:v.xcss),n.xcss),f.xcss),className:[b("Cell"),e.cellClassName,n.className].join(" ")}),delete n.orderIndex;let y=R[w=="td"?"TD":"TH"];p.push(a(y,r({},n),g))}),h.push(a(R.Row,{className:[b("Row"),b("BodyRow")].join(" "),children:p,onClick:c=>{e.onRowClick&&e.onRowClick(s.rowID,c)}},l))}),!i.length){let s=a(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=a(U,{children:e.noRecords})),h.push(a(R.Row,{className:[b("Row"),b("BodyRow"),b("DataNotFound")].join(" "),children:a(R.TD,{colSpan:e.colLength,className:b("Cell"),children:s})},"dataNotFound"))}return a(U,{children:h})},Core:t=>{let{val_status:e,set_status:i}=t,{searchKeyword:h,filter:s,order:l,paging:d}=e,p=[...e.rows],m=[...e.rows],c=[...e.rows],g=[...e.rows];if(h&&(m=p.filter(o=>(o.__sys4SearchKey||"").match(new RegExp(String(h).escapeRegExChar(),"i"))?1:0),c=[...m],g=[...m]),s.enabled)for(let o=0;o<e.colLength;o++){let u=s.column[o],f=s.current[o];u&&f&&f.length&&(c=c.filter(y=>!f.includes(y[o].data)),g=[...c])}l.enabled&&(l.current[1]=="ASC"?c=c.toASC(l.current[0]+"[orderIndex]"):c=c.toDESC(l.current[0]+"[orderIndex]"),g=[...c]);{let{currentPageIndex:o,rowLength:u}=d;g=[...g].splice((o-1)*u,u)}let w=x.__memoryID+"_"+e.tableID,n={rows:{total:p.length,page:g.length,filtered:c.length},val_status:S(r({},e),{paging:S(r({},e.paging),{pageLength:Math.ceil(c.length/e.paging.rowLength)})}),set_status:i};return Q.update({[w]:{getRowData:()=>{let o=[...p];return l.enabled&&(l.current[1]=="ASC"?o=o.toASC(l.current[0]+"[orderIndex]"):o=o.toDESC(l.current[0]+"[orderIndex]")),o.forEach(u=>{u.currentPage=!1,u.filtered=!1}),g.forEach(u=>{let{rowID:f}=u;o.find(y=>D.isEqual(y.rowID,f)).currentPage=!0}),c.forEach(u=>{let{rowID:f}=u;o.find(y=>D.isEqual(y.rowID,f)).filtered=!0}),o}}}),W(()=>{E.bridge(e.tableID,n)}),a(B,{className:b("TableBase"),children:a(R.Table,{className:b("Table"),children:_(R.Body,{children:[a(x.Header,{val_status:e,set_status:i,KeywordFilterRows:m}),a(x.Body,{val_status:e,set_status:i,PageRows:g})]})})},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 l;return D.isBoolean(t.filter)?t.filter:(l=t.filter[s])!=null?l:!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 l;return D.isBoolean(t.order)?t.order:(l=t.order[s])!=null?l:!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 l=[];h.forEach((d,p)=>{let{data:m,children:c,orderIndex:g}=d;d.orderIndex=D.isExist(g)?String(g):String(m),d.children=c||String(m),l.push(String(d.data))}),h.__sys4SearchKey=l.join("/")}),a(x.StateManager,r({},t))},StateManager:t=>{let{colLength:e,checker:i=!1,searchKeyword:h="",filter:s,order:l,orderPriority:d="ASC",defaultOrder:p=[0,d],pageRowLength:m=30}=t,[c]=Y(G()),g={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:l!==!1,column:l,current:p,priority:t.orderPriority},paging:{rowLength:m,pageLength:Math.ceil(t.rows.length/m),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]=Y(g);const o=()=>{const u=new WeakSet;return(f,y)=>{if(typeof y=="object"&&y!==null){if(u.has(y))return"[Circular Reference]";if(f=="children")return"[React Element]";u.add(y)}return y}};return W(()=>{n(u=>S(r({},u),{rows:g.rows}))},[D.Stringify(g.rows,o())]),W(()=>{n(u=>S(r({},u),{head:g.head}))},[D.Stringify(g.head,o())]),a(x.Core,{val_status:w,set_status:n})}},ge={__memoryID:x.__memoryID,getRowData:t=>{let e=Q.get(x.__memoryID+"_"+t);if(e!=null&&e.getRowData)return e.getRowData()}},V={SearchInput:t=>{let e=E.catch(t.tableID);if(!e)return null;let{val_status:i,set_status:h}=e;return a(I.TextField,{label:"\u691C\u7D22...",clearButton:!0,padding:"2/3",paddingRight:3,rightIcon:a(I.RightIcon,{ssSphere:2,fontColor:"5.translucent",right:"2/3",children:a(N.Search,{})}),value:i.searchKeyword,onUpdateValidValue:s=>{t.onChange(s),D.interval.once(()=>{h(l=>S(r({},l),{paging:S(r({},l.paging),{currentPageIndex:1}),filter:S(r({},l.filter),{current:Array.from({length:l.colLength},()=>[])}),searchKeyword:s}))},200,"InputSearchTime")}})},Info:t=>{let e=E.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 _(M,{verticalAlign:"baseline",gap:"1/2",fontSize:"1.mini",fontColor:"3.blur",children:[a(le,{fontSize:"4.thirdTitle",fontColor:"theme",children:e.rows.filtered.toLocaleString()}),"/ ",e.rows.total.toLocaleString(),"\u4EF6 (",s,"%)"]})},Paging:t=>{let e=E.catch(t.tableID);if(!e)return null;let{val_status:i,set_status:h}=e,s=[];for(let d=0;d<i.paging.pageLength;d++)s.push({value:d+1,label:(d+1).toString()});const l=d=>{let p=Math.min(Math.max(1,d),i.paging.pageLength),m=r({},i);m.paging.currentPageIndex=p,h(c=>S(r({},c),{paging:S(r({},c.paging),{currentPageIndex:p})}))};return a(I.Select,{emptySelect:!1,padding:["1/3","2/3"],override:"force",gap:0,leftIcon:a(I.LeftIcon,{xcss:{left:2,pointerEvents:"all"},children:a(F.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(i.paging.currentPageIndex==1){l(i.paging.pageLength);return}l(i.paging.currentPageIndex-1)},children:a(N.ChevronLeft,{})})}),rightIcon:a(I.RightIcon,{xcss:{right:2,pointerEvents:"all"},children:a(F.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(i.paging.currentPageIndex==i.paging.pageLength){l(1);return}l(i.paging.currentPageIndex+1)},children:a(N.ChevronRight,{})})}),options:s.map(d=>({value:d.value,label:_(j.Left,{gap:"1/3",verticalAlign:"baseline",children:[d.label,_(ne.Micro,{fontColor:"4.thin",children:["/ ",i.paging.pageLength]})]})})),value:i.paging.currentPageIndex,onUpdateValidValue:d=>{l(d)}})},RowLength:t=>{let e=E.catch(t.tableID);if(!e)return null;let{val_status:i,set_status:h}=e,s=i.paging.rowLength,l=0,d=t.lengthSelect.map(p=>(l|=+(p==s),{value:p,label:p.toString()}));return l||d.push({value:s,label:s.toString()}),a(j.Center,{gap:"1/2",children:a(I.Select,{emptySelect:!1,override:"force",padding:"1/3",paddingLeft:3,paddingRight:2,pickerStyles:{xcss:{minWidth:12*9}},pickerPosition:4,value:i.paging.rowLength,leftIcon:a(I.LeftIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{left:6},children:"\u8868\u793A"}),rightIcon:a(I.RightIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{right:6},children:"\u4EF6"}),options:d.toASC("value"),onUpdateValidValue:p=>{h(m=>S(r({},m),{paging:{rowLength:Number(p),currentPageIndex:1,pageLength:Math.ceil(e.rows.filtered/Number(p))}}))}})})}},he=t=>a(ue,S(r({},t),{type:"data",JSXChildren:x.DataLeveler})),k=he;k.__memoryID=x.__memoryID,k.getRowData=ge.getRowData,k.Info=V.Info,k.Paging=V.Paging,k.RowLength=V.RowLength,k.SearchInput=V.SearchInput;export{k as Data,k as default};
package/dist/fn/Tips.js CHANGED
@@ -1 +1 @@
1
- import"../chunk-C5N2D3ZX.js";import{jsx as n}from"react/jsx-runtime";import i,{UUID as a}from"jmini";import{Literal as m}from"../mols";import{Tooltips as o}from".";const t={uid:a(),open:(e,r,p=24,d=.35)=>{e&&i.interval.once(()=>{o.open({tipsID:t.uid,parent:e,gravityPoint:p||24,padding:"1/2",content:n(o.Body,{padding:"1/2",borderRadius:"3.tone.tertiary",children:n(m.Supplement,{children:r})})})},d*1e3,t.uid)},abort:()=>{i.interval.abort(t.uid),o.close(t.uid)}};export{t as Tips};
1
+ import"../chunk-C5N2D3ZX.js";import{jsx as n}from"react/jsx-runtime";import e,{UUID as a}from"jmini";import{Literal as m}from"../mols";import{Tooltips as t}from".";const o={uid:a(),open:(i,r,p=24,d=.35)=>{i&&e.interval.once(()=>{t.open({tipsID:o.uid,parent:i,gravityPoint:p||24,padding:"1/2",content:n(t.Body,{padding:"1/2",borderRadius:"3.tone.tertiary",children:n(m.Mini,{children:r})})})},d*1e3,o.uid)},abort:()=>{e.interval.abort(o.uid),t.close(o.uid)}};export{o as Tips};
@@ -16,7 +16,8 @@ declare namespace Literal {
16
16
  ThirdTitle: React.FC<Box.DefaultInput>;
17
17
  Paragraph: React.FC<Box.DefaultInput>;
18
18
  Description: React.FC<Box.DefaultInput>;
19
- Supplement: React.FC<Box.DefaultInput>;
19
+ Mini: React.FC<Box.DefaultInput>;
20
+ Micro: React.FC<Box.DefaultInput>;
20
21
  };
21
22
  }
22
23
  type Methods = Methods.Component & Methods.FNs;
@@ -1 +1 @@
1
- import{b as e,c as n}from"../chunk-C5N2D3ZX.js";import{jsx as p}from"react/jsx-runtime";import{Box as i,Span as l}from"../atoms";const a=t=>p(i,e({},t)),o=a;o.Title=t=>p(a,e({fontSize:"6.title",fontWeight:"3.semiBold"},t)),o.SubTitle=t=>p(a,e({fontSize:"5.subTitle",fontWeight:"3.semiBold"},t)),o.ThirdTitle=t=>p(a,e({fontSize:"4.thirdTitle",fontWeight:"3.semiBold"},t)),o.Paragraph=t=>p(a,e({fontSize:"3.paragraph",fontWeight:"3.semiBold"},t)),o.Description=t=>p(a,n(e({},t),{xcss:e({whiteSpace:"pre-wrap"},t.xcss)})),o.Supplement=t=>p(a,e({fontSize:"1.mini"},t)),o.NowrapSpan=t=>p(l,n(e({},t),{xcss:e({whiteSpace:"nowrap"},t.xcss)}));export{o as Literal,o as default};
1
+ import{b as e,c as p}from"../chunk-C5N2D3ZX.js";import{jsx as a}from"react/jsx-runtime";import{Box as i,Span as l}from"../atoms";const n=t=>a(i,e({},t)),o=n;o.Title=t=>a(n,e({fontSize:"6.title",fontWeight:"3.semiBold"},t)),o.SubTitle=t=>a(n,e({fontSize:"5.subTitle",fontWeight:"3.semiBold"},t)),o.ThirdTitle=t=>a(n,e({fontSize:"4.thirdTitle",fontWeight:"3.semiBold"},t)),o.Paragraph=t=>a(n,e({fontSize:"3.paragraph",fontWeight:"3.semiBold"},t)),o.Description=t=>a(n,p(e({},t),{xcss:e({whiteSpace:"pre-wrap"},t.xcss)})),o.Mini=t=>a(n,e({fontSize:"1.mini"},t)),o.Micro=t=>a(n,e({fontSize:"0.xs"},t)),o.NowrapSpan=t=>a(l,p(e({},t),{xcss:e({whiteSpace:"nowrap"},t.xcss)}));export{o as Literal,o as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amotify",
3
- "version": "0.2.307",
3
+ "version": "0.3.1",
4
4
  "description": "UI Component for React,NextJS,esbuild",
5
5
  "scripts": {
6
6
  "start": "run-p clean build:*",