amotify 0.2.152 → 0.2.154
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demo/esbuild/app.tsx +0 -7
- package/demo/esbuild/designBook.tsx +107 -109
- package/dist/fn/Cropper.js +1 -1
- package/dist/fn/Input/Autocomplete.js +1 -1
- package/dist/fn/Input/Select.js +1 -1
- package/dist/fn/Input/TextField.js +2 -2
- package/dist/fn/Input/Time/Picker.js +1 -1
- package/dist/fn/Input/Time/index.js +1 -1
- package/dist/fn/Input/core.js +1 -1
- package/dist/fn/PageNotFound.js +1 -1
- package/dist/fn/Tips.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/mols/{Text.d.ts → Literal.d.ts} +3 -3
- package/dist/mols/Literal.js +1 -0
- package/dist/mols/index.d.ts +1 -1
- package/dist/mols/index.js +1 -1
- package/package.json +1 -1
- package/dist/mols/Text.js +0 -1
package/dist/fn/Cropper.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as H,c as G,e as z}from"../chunk-C5N2D3ZX.js";import{jsx as o,jsxs as f}from"react/jsx-runtime";import S,{UUID as J,useStore as X}from"jmini";import{$$fromRoot as K}from"../@utils";import{useState as N,useEffect as O}from"react";import{Box as B,FAI as M,Column as L}from"../atoms";import{Row as I,Text as F}from"../mols";import{Button as P}from"./Button";import A from"./Sheet";import V from"./Loader";import q from"./Input";import{faPalette as Q}from"@fortawesome/free-solid-svg-icons/faPalette";import{faBarsStaggered as ee}from"@fortawesome/free-solid-svg-icons/faBarsStaggered";import{faRotateLeft as te}from"@fortawesome/free-solid-svg-icons/faRotateLeft";import{faRotateRight as ae}from"@fortawesome/free-solid-svg-icons/faRotateRight";import{CropperClasses as U}from"../@styles/componentClasses";import Y from"./Tooltips";class re{constructor(t){this.set_scale=t.set_scale,this.val_file=t.val_file,this.develops=t.develops,this.use=t.use,this.componentID=t.componentID,this.scale={current:t.scale.default,default:t.scale.default,min:t.scale.min,max:t.scale.max};let n=t.canvas;this.Canvas={elm:n,ctx:n.getContext("2d")};let i=t.picture.image,{width:e,height:a}=i,r=e/a;this.Picture={elm:i,originDataUrl:i.src,aspect:r,revisedAspect:1,rotate:t.picture.rotate,grayScale:t.picture.grayScale,tone:t.picture.tone},this.pst={frame:{x:0,y:0,w:0,h:0,aspect:1},outImage:{x:0,y:0,w:0,h:0},imageX:e/2,imageY:a/2,centerX:0,centerY:0},this.dragEffectInfo={origin:{x:0,y:0},frameExpandRate:{x:0,y:0}},this.pinchEffectInfo={origin:{x:0,y:0,scale:this.scale.current}},this.frameSizing(),this.modifyImage()}frameSizing(){let t=this.Canvas.elm,n=this.Picture.elm,i=0,e=0;if(this.use=="square"){let s=t.width/3*2,l=t.height/3*2;i=Math.min(s,l),e=i}else this.use=="wallpaper.horizontal"?(i=t.width*(7/9),e=i/3):this.use=="wallpaper.vertical"&&(e=t.height*(7/9),i=e/2);let{width:a,height:r}=n,p=(t.width-i)/2,u=(t.height-e)/2,C=i/e;this.pst={frame:{x:p,y:u,w:i,h:e,aspect:C},outImage:{x:0,y:0,w:0,h:0},imageX:a/2,imageY:r/2,centerX:t.width/2,centerY:t.height/2}}dragEffect(t){let{eventType:n,x:i,y:e}=t;if(n=="start"){let a=this.Canvas.elm.position();this.dragEffectInfo={origin:{x:i,y:e},frameExpandRate:{x:this.Canvas.elm.width/a.width,y:this.Canvas.elm.height/a.height}}}else{let{origin:a,frameExpandRate:r}=this.dragEffectInfo,p=a.x-i,u=a.y-e,C=this.scale.current*this.Picture.revisedAspect/100,s=p/C*r.x,l=u/C*r.y;n=="move"?this.drawImage(this.pst.imageX+s,this.pst.imageY+l):n=="end"&&this.drawImage(this.pst.imageX+=s,this.pst.imageY+=l)}}pinchEffect(t){let{eventType:n,event:i}=t,{x:e,y:a}=S.getCursor(i.touches[0]),{x:r,y:p}=S.getCursor(i.touches[1]),u=r-e,C=p-a;if(n=="start")this.pinchEffectInfo.origin={x:u,y:C,scale:this.scale.current};else if(n=="move"){let{origin:s}=this.pinchEffectInfo,l=Math.sqrt(Math.pow(s.x,2)+Math.pow(s.y,2)),y=Math.sqrt(Math.pow(u,2)+Math.pow(C,2))/l,v=Number(s.scale*y);this.set_scale(v)}}updateScale(t){let n=t;n=Math.max(n,this.scale.min),n=Math.min(n,this.scale.max),this.scale.current=n,this.drawImage()}updateFilter(t){this.Picture.grayScale=t.grayScale,this.Picture.tone=t.tone,this.Picture.rotate=t.rotate,this.modifyImage()}modifyImage(){return z(this,null,function*(){let{grayScale:t,tone:n,rotate:i}=this.Picture;const e=document.createElement("canvas");let a=e.getContext("2d"),r=yield S.ImageLoader(this.Picture.originDataUrl),p=r.width,u=r.height;(i==90||i==270)&&(p=r.height,u=r.width),e.width=p,e.height=u,t&&(a.filter="grayscale("+t+"%)"),i&&(a.translate(p/2,u/2),a.rotate(i*Math.PI/180),[90,270].includes(i)?a.translate(-u/2,-p/2):a.translate(-p/2,-u/2)),a.drawImage(r,0,0,r.width,r.height);let C=a.getImageData(0,0,e.width,e.height),s=C.data;{t/=100;let v=[[255,255,255],[255,200,100],[170,170,255],[240,200,145],[128,255,255],[255,128,255],[255,255,128],[128,158,169],[128,112,162],[50,192,87],[246,100,140]][n],x=v[0]/255,b=v[1]/255,c=v[2]/255;for(let m=0;m<u;m++)for(let h=0;h<p;h++){var l=(m*p+h)*4;if(t){let R=.3*s[l]+.59*s[l+1]+.11*s[l+2];for(var g=0;g<3;g++){let T=s[l+g];s[l+g]=T+(R-T)*t}}s[l]*=x,s[l+1]*=b,s[l+2]*=c}}a.putImageData(C,0,0);let y=e.toDataURL("image/jpeg");{let v=yield S.ImageLoader(y),{width:x,height:b}=v,c=x/b;this.Picture=G(H({},this.Picture),{elm:v,aspect:c,revisedAspect:this.pst.frame.aspect>c?this.pst.frame.w/x:this.pst.frame.h/b})}this.drawImage()})}drawImage(t,n){let{use:i,Canvas:{ctx:e,elm:a},pst:{frame:r}}=this,p=t||this.pst.imageX,u=n||this.pst.imageY;{let C=this.scale.current/100,s=this.Picture.revisedAspect*C,l=this.pst.centerX-p*s,g=this.pst.centerY-u*s,y=this.Picture.elm.width*s,v=this.Picture.elm.height*s;{let x=this.pst.frame.x+this.pst.frame.w-y,b=this.pst.frame.x,c=this.pst.frame.y+this.pst.frame.h-v,m=this.pst.frame.y,h=0;l<x&&(h=l-x),l>b&&(h=l-b);let R=0;g<c&&(R=g-c),g>m&&(R=g-m),this.dragEffectInfo.origin.x+=h/2/this.dragEffectInfo.frameExpandRate.x,this.dragEffectInfo.origin.y+=R/2/this.dragEffectInfo.frameExpandRate.y,l=Math.min(Math.max(l,x),b),g=Math.min(Math.max(g,c),m)}this.pst.outImage={x:l,y:g,w:y,h:v},e.clearRect(0,0,this.Canvas.elm.width,this.Canvas.elm.height),e.drawImage(this.Picture.elm,0,0,this.Picture.elm.width,this.Picture.elm.height,l,g,y,v)}{if(i=="square"){e.fillStyle="rgba( 20,24,20,.3 )",e.beginPath();let l=a.width/3*2,g=a.height/3*2,y=Math.min(l,g),v=Math.max(l,g);e.arc(a.width/2,a.height/2,v,0,Math.PI*2,!0),e.arc(a.width/2,a.height/2,y/2,0,Math.PI*2,!1),e.closePath(),e.fill()}else(i=="wallpaper.horizontal"||i=="wallpaper.vertical")&&(e.fillStyle="rgba( 20,24,20,.3 )");e.beginPath(),e.moveTo(0,0),e.lineTo(a.width,0),e.lineTo(a.width,a.height),e.lineTo(0,a.height),e.lineTo(0,0),e.closePath(),e.lineTo(r.x,r.y),e.lineTo(r.x,r.y+r.h),e.lineTo(r.x+r.w,r.y+r.h),e.lineTo(r.x+r.w,r.y),e.lineTo(r.x,r.y),e.fill();let s=S(document.body).getStyleProperty("--color-theme-hsl");e.lineWidth=4,e.strokeStyle=`hsla( ${s},1 )`,e.strokeRect(r.x,r.y,r.w,r.h)}}export(){return z(this,null,function*(){let{Canvas:t,develops:n,Picture:i,pst:{outImage:e,frame:a}}=this,r=e.w/i.elm.width,p=e.h/i.elm.height,u=(a.x-e.x)/r,C=(a.x-e.x+a.w)/r,s=(a.y-e.y)/p,l=(a.y-e.y+a.h)/p,g=Array.from({length:n.length}),y="image/jpeg";for(let v=0;v<n.length;v++){let{size:x,maxSize:b}=n[v];b=b||{S:1024*20,R:1024*100,L:1024*350}[x];let c={S:140,R:600,L:1200}[x],m=c;this.use=="wallpaper.horizontal"?m=c/3:this.use=="wallpaper.vertical"&&(m=c*2);let h=document.createElement("canvas");h.width=c,h.height=m;let R=h.getContext("2d");if(!R)return;R.clearRect(0,0,c,m),R.drawImage(this.Picture.elm,u,s,C-u,l-s,0,0,c,m);let T=h.toDataURL(y),w=yield T.toBlob(y);if(!w)return;if(w.size>=b){let k=b/w.size;if(T=h.toDataURL(y,k*.92),w=yield T.toBlob(y),!w)return}let W=new File([w],this.val_file.name,{type:y});g[v]=W}return g})}}const Z={Core:d=>{let{val_file:t,options:n,finishedCallback:i,abortCallback:e}=d,{use:a,develops:r=[]}=n,[p]=N(J());const u={scale:{default:120,min:100,max:400},rotate:0,grayScale:0,tone:0};let[C,s]=N(u.scale.default),[l,g]=N(u.rotate),[y,v]=N(u.grayScale),[x,b]=N(u.tone);return O(()=>{let c="CropperResize";return S(window).addEvent({eventType:"resize",eventID:c,callback:()=>{S.interval.once(()=>{var k;let m=K("#Canvas-"+p)[0];if(!m)return;let h=(k=X.get(p))==null?void 0:k.Instance;if(!h)return;let R=m.position(),T=R.width/R.height;m.width=2400,m.height=2400/T;let{width:w,height:W}=m;h.pst.centerX=w/2,h.pst.centerY=W/2,h.frameSizing(),h.modifyImage()},250,"CropperResize")}}),()=>{S(window).removeEvent(c)}},[]),O(()=>{X.set({[p]:{}}),z(void 0,null,function*(){V.fn.corner.active(),yield S.pending(()=>{},400);let{target:c}=yield t.convert();if(!c)return;let m=c.result,h=K("#Canvas-"+p)[0];if(!h)return;let R=h.position(),T=R.width/R.height;h.width=2400,h.height=2400/T;let w=new re({set_scale:s,val_file:t,develops:r,use:a,scale:u.scale,componentID:p,canvas:h,picture:{image:yield S.ImageLoader(m),grayScale:u.grayScale,tone:u.tone,rotate:u.rotate}});X.set({[p]:{Instance:w}});const W=function(E){if(E.preventDefault(),E.touches&&E.touches.length>1)w.pinchEffect({eventType:"start",event:E}),S(document).addEvent({eventType:"touchmove",eventID:"CropperEffectMove",options:{passive:!1},callback:D=>{D.preventDefault(),w.pinchEffect({eventType:"move",event:D})}}).addEvent({eventType:"touchend",eventID:"CropperEffectEnd",options:{passive:!1},callback:j});else{w.dragEffect(H({eventType:"start"},S.getCursor(E)));let{type:D}=E;S(document).addEvent({eventType:D=="touchstart"?"touchmove":"mousemove",eventID:"CropperEffectMove",options:{passive:!1},callback:_=>{k("move",_)}}).addEvent({eventType:D=="touchstart"?"touchend":"mouseup",eventID:"CropperEffectEnd",options:{passive:!1},callback:_=>{k("end",_),j(_)}})}},k=function(E,D){D.preventDefault(),w.dragEffect(H({eventType:E},S.getCursor(D)))},j=function(E){E.preventDefault(),S(document).removeEvent(["CropperEffectMove","CropperEffectEnd"])};S(h).removeEvent(["CropperMouseWheel","CropperTouchStart","CropperMouseDown"]).addEvent({eventID:"CropperMouseWheel",eventType:"wheel",callback:E=>{E.preventDefault();let D=Number(E.wheelDelta*.04),_=w.scale.current+D;_=Math.max(_,w.scale.min),_=Math.min(_,w.scale.max),s(_)},options:{passive:!1}}).addEvent({eventType:"touchstart",eventID:"CropperTouchStart",callback:W,options:{passive:!1}}).addEvent({eventType:"mousedown",eventID:"CropperMouseDown",callback:W,options:{passive:!1}}),setTimeout(()=>{V.fn.corner.stop()},1e3)})},[t.id]),O(()=>{var m;let c=(m=X.get(p))==null?void 0:m.Instance;c&&c.updateScale(C)},[C]),O(()=>{var m;let c=(m=X.get(p))==null?void 0:m.Instance;c&&c.updateFilter({grayScale:y,tone:x,rotate:l})},[y,x,l]),o(A.Body,{borderRadius:0,height:"viewHeight",width:"viewWidth",children:f(L,{className:[U("Wrap"),U("Use_"+a)].join(" "),gap:0,height:1,position:"relative",overflow:"hidden",borderRadius:"inherit",children:[o(B,{flexSizing:0,overflow:"hidden",position:"relative",backgroundColor:"black",flexCenter:!0,freeCSS:{zIndex:1},children:o("canvas",{style:{width:"100%",height:"100%"},width:2400,height:2400,className:U("Canvas"),id:"Canvas-"+p})}),f(I.Separate,{borderTop:!0,flexSizing:"none",backgroundColor:"layer.1",padding:1,verticalAlign:"unset",UnderBreakPointStyles:{flexType:"col"},children:[o(Z.SettingRegion,{DefaultOptions:u,val_scale:C,set_scale:s,val_tone:x,set_tone:b,val_grayScale:y,set_grayScale:v,val_rotate:l,set_rotate:g}),f(I.Right,{flexSizing:"none",children:[o(P.Border,{isRounded:!0,onClick:()=>{e()},children:"\u9589\u3058\u308B"}),o(P,{isRounded:!0,boxShadow:"3.remark",onClick:()=>z(void 0,null,function*(){var h;let c=(h=X.get(p))==null?void 0:h.Instance;if(!c)return;V.fn.mini.active("CropperExportation");let m=yield c.export();setTimeout(()=>{V.fn.mini.stop("CropperExportation"),i(m)},3e3)}),children:f(I.Center,{gap:"1/2",children:[o(V.White.R,{loaderID:"CropperExportation"}),"\u6C7A\u5B9A"]})})]})]})]})})},SettingRegion:d=>{let t=["","\u6696\u8272","\u5BD2\u8272","\u30BB\u30D4\u30A2","\u30B7\u30A2\u30F3","\u30DE\u30BC\u30F3\u30BF","\u30A4\u30A8\u30ED\u30FC","\u30AA\u30EA\u30B8\u30CA\u30EB1","\u30AA\u30EA\u30B8\u30CA\u30EB2","\u30AA\u30EA\u30B8\u30CA\u30EB3","\u30AA\u30EA\u30B8\u30CA\u30EB4"],n=i=>t[i]||"\u306A\u3057";return f(I.Left,{verticalAlign:"unset",flexWrap:!0,children:[f(L,{gap:"1/3",children:[o(F.Supplement,{children:"Rotate"}),f(I.Left,{flexChilds:"even",gap:"1/6",children:[o(P.Border.S,{isRounded:!0,borderTopRightRadius:0,borderBottomRightRadius:0,onClick:()=>{let i=d.val_rotate-90;i<0&&(i+=360),d.set_rotate(i)},children:f(I.Center,{gap:"1/4",children:["90\xB0",o(M,{icon:te})]})}),o(P.Border.S,{isRounded:!0,borderTopLeftRadius:0,borderBottomLeftRadius:0,onClick:()=>{d.set_rotate((d.val_rotate+90)%360)},children:f(I.Center,{gap:"1/4",children:[o(M,{icon:ae}),"90\xB0"]})})]})]}),f(L,{gap:"1/3",freeCSS:{minWidth:12*6},children:[o(F.Supplement,{children:"Zoom"}),f(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:i=>{let e="CropperZoomEdit";Y.open({tipsID:e,gravityPoint:3,event:i,closeAtParentBlur:!1,freeCSS:{minWidth:12*26},content:o(A.Body,{children:f(L,{padding:1.5,children:[f(I.Separate,{children:[o(F.Paragraph,{children:f(I.Center,{gap:"1/2",children:[o(M.Search,{fontColor:"5.translucent"}),"Zoom"]})}),o(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(e)},children:o(M.Times,{})})]}),o(B,{borderBottom:!0,opacity:"low"}),o(q.Slider,{override:"force",value:d.val_scale-100,min:d.DefaultOptions.scale.min-100,max:d.DefaultOptions.scale.max-100,step:25,onUpdateValidValue:(a,r)=>{S.interval.once(()=>{d.set_scale(a+100)},250,"Cropper.UpdateScale")},legends:{enable:!0,custom:a=>"x"+Math.round(100+a)/100}})]})})})},children:[d.val_scale.rate(1,0),"%"]})]}),f(L,{gap:"1/3",freeCSS:{minWidth:12*6},children:[o(F.Supplement,{children:"GrayScale"}),f(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:i=>{let e="CropperGrayScaleEdit";Y.open({tipsID:e,gravityPoint:3,event:i,closeAtParentBlur:!1,freeCSS:{minWidth:12*26},content:o(A.Body,{children:f(L,{padding:1.5,children:[f(I.Separate,{children:[o(F.Paragraph,{children:f(I.Center,{gap:"1/2",children:[o(M,{icon:Q,fontColor:"5.translucent"}),"Gray Scale"]})}),o(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(e)},children:o(M.Times,{})})]}),o(B,{borderBottom:!0,opacity:"low"}),o(q.Slider,{value:d.val_grayScale,min:0,max:100,step:10,onUpdateValidValue:a=>{S.interval.once(()=>{d.set_grayScale(a)},250,"Cropper.GrayScale")},legends:{enable:!0,custom:a=>a+"%"}})]})})})},children:[d.val_grayScale.rate(1,0),"%"]})]}),f(L,{gap:"1/3",freeCSS:{minWidth:12*6},children:[o(F.Supplement,{children:"Tone"}),o(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:i=>{let e="CropperToneEdit";Y.open({tipsID:e,gravityPoint:3,event:i,closeAtParentBlur:!1,freeCSS:{minWidth:12*26,maxWidth:12*24},content:()=>{let a=[];for(let r=1;r<=10;r++)a.push({value:r,label:f(I.Left,{gap:"1/3",children:[o(B,{ssSphere:1,className:[U("ToneBall"),U("ToneBall_"+r)].join(" ")}),o(B,{textAlign:"left",flexSizing:0,children:n(r)})]})});return o(A.Body,{children:f(L,{padding:1.5,children:[f(I.Separate,{children:[o(F.Paragraph,{children:f(I.Center,{gap:"1/2",children:[o(M,{icon:ee,fontColor:"5.translucent"}),"Tone"]})}),o(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(e)},children:o(M.Times,{})})]}),o(B,{borderBottom:!0,opacity:"low"}),o(q.Radio.Normal,{value:d.val_tone,gap:"1/2",cellStyles:{fontColor:"3.blur"},options:[{value:0,label:o(B,{flexSizing:0,textAlign:"center",children:"\u306A\u3057"})},...a],onUpdateValidValue:r=>{d.set_tone(r)}})]})})}})},children:f(I.Center,{gap:"1/2",children:[o(B,{boxShadow:"2.remark",ssSphere:1,className:[U("ToneBall"),U("ToneBall_"+d.val_tone)].join(" ")}),n(d.val_tone)]})})]})]})}},$={openDialogNEdit:d=>z(void 0,null,function*(){let t=yield q.Filer.fn.openDialog({accept:"image",multiple:!1});$.openEditor(H({imageFile:t[0]},d))}),openEditor:d=>z(void 0,null,function*(){let t="CropperImage";A.open({sheetID:t,type:"normal.middleCenter",size:"MAX",padding:0,margin:0,freeCSS:{maxWidth:"100%"},content:o(Z.Core,{val_file:d.imageFile,options:d,finishedCallback:n=>{A.close(t),d.onProcessFinished(n)},abortCallback:()=>{A.close(t)}}),closeAtEscapeKeyDown:!1})})};export{$ as Cropper,$ as default};
|
|
1
|
+
import{b as H,c as G,e as z}from"../chunk-C5N2D3ZX.js";import{jsx as o,jsxs as f}from"react/jsx-runtime";import S,{UUID as J,useStore as X}from"jmini";import{$$fromRoot as K}from"../@utils";import{useState as N,useEffect as O}from"react";import{Box as B,FAI as L,Column as M}from"../atoms";import{Row as I,Literal as F}from"../mols";import{Button as P}from"./Button";import A from"./Sheet";import V from"./Loader";import q from"./Input";import{faPalette as Q}from"@fortawesome/free-solid-svg-icons/faPalette";import{faBarsStaggered as ee}from"@fortawesome/free-solid-svg-icons/faBarsStaggered";import{faRotateLeft as te}from"@fortawesome/free-solid-svg-icons/faRotateLeft";import{faRotateRight as ae}from"@fortawesome/free-solid-svg-icons/faRotateRight";import{CropperClasses as U}from"../@styles/componentClasses";import Y from"./Tooltips";class re{constructor(t){this.set_scale=t.set_scale,this.val_file=t.val_file,this.develops=t.develops,this.use=t.use,this.componentID=t.componentID,this.scale={current:t.scale.default,default:t.scale.default,min:t.scale.min,max:t.scale.max};let n=t.canvas;this.Canvas={elm:n,ctx:n.getContext("2d")};let i=t.picture.image,{width:e,height:a}=i,r=e/a;this.Picture={elm:i,originDataUrl:i.src,aspect:r,revisedAspect:1,rotate:t.picture.rotate,grayScale:t.picture.grayScale,tone:t.picture.tone},this.pst={frame:{x:0,y:0,w:0,h:0,aspect:1},outImage:{x:0,y:0,w:0,h:0},imageX:e/2,imageY:a/2,centerX:0,centerY:0},this.dragEffectInfo={origin:{x:0,y:0},frameExpandRate:{x:0,y:0}},this.pinchEffectInfo={origin:{x:0,y:0,scale:this.scale.current}},this.frameSizing(),this.modifyImage()}frameSizing(){let t=this.Canvas.elm,n=this.Picture.elm,i=0,e=0;if(this.use=="square"){let s=t.width/3*2,l=t.height/3*2;i=Math.min(s,l),e=i}else this.use=="wallpaper.horizontal"?(i=t.width*(7/9),e=i/3):this.use=="wallpaper.vertical"&&(e=t.height*(7/9),i=e/2);let{width:a,height:r}=n,p=(t.width-i)/2,u=(t.height-e)/2,C=i/e;this.pst={frame:{x:p,y:u,w:i,h:e,aspect:C},outImage:{x:0,y:0,w:0,h:0},imageX:a/2,imageY:r/2,centerX:t.width/2,centerY:t.height/2}}dragEffect(t){let{eventType:n,x:i,y:e}=t;if(n=="start"){let a=this.Canvas.elm.position();this.dragEffectInfo={origin:{x:i,y:e},frameExpandRate:{x:this.Canvas.elm.width/a.width,y:this.Canvas.elm.height/a.height}}}else{let{origin:a,frameExpandRate:r}=this.dragEffectInfo,p=a.x-i,u=a.y-e,C=this.scale.current*this.Picture.revisedAspect/100,s=p/C*r.x,l=u/C*r.y;n=="move"?this.drawImage(this.pst.imageX+s,this.pst.imageY+l):n=="end"&&this.drawImage(this.pst.imageX+=s,this.pst.imageY+=l)}}pinchEffect(t){let{eventType:n,event:i}=t,{x:e,y:a}=S.getCursor(i.touches[0]),{x:r,y:p}=S.getCursor(i.touches[1]),u=r-e,C=p-a;if(n=="start")this.pinchEffectInfo.origin={x:u,y:C,scale:this.scale.current};else if(n=="move"){let{origin:s}=this.pinchEffectInfo,l=Math.sqrt(Math.pow(s.x,2)+Math.pow(s.y,2)),y=Math.sqrt(Math.pow(u,2)+Math.pow(C,2))/l,v=Number(s.scale*y);this.set_scale(v)}}updateScale(t){let n=t;n=Math.max(n,this.scale.min),n=Math.min(n,this.scale.max),this.scale.current=n,this.drawImage()}updateFilter(t){this.Picture.grayScale=t.grayScale,this.Picture.tone=t.tone,this.Picture.rotate=t.rotate,this.modifyImage()}modifyImage(){return z(this,null,function*(){let{grayScale:t,tone:n,rotate:i}=this.Picture;const e=document.createElement("canvas");let a=e.getContext("2d"),r=yield S.ImageLoader(this.Picture.originDataUrl),p=r.width,u=r.height;(i==90||i==270)&&(p=r.height,u=r.width),e.width=p,e.height=u,t&&(a.filter="grayscale("+t+"%)"),i&&(a.translate(p/2,u/2),a.rotate(i*Math.PI/180),[90,270].includes(i)?a.translate(-u/2,-p/2):a.translate(-p/2,-u/2)),a.drawImage(r,0,0,r.width,r.height);let C=a.getImageData(0,0,e.width,e.height),s=C.data;{t/=100;let v=[[255,255,255],[255,200,100],[170,170,255],[240,200,145],[128,255,255],[255,128,255],[255,255,128],[128,158,169],[128,112,162],[50,192,87],[246,100,140]][n],b=v[0]/255,x=v[1]/255,c=v[2]/255;for(let m=0;m<u;m++)for(let h=0;h<p;h++){var l=(m*p+h)*4;if(t){let R=.3*s[l]+.59*s[l+1]+.11*s[l+2];for(var g=0;g<3;g++){let D=s[l+g];s[l+g]=D+(R-D)*t}}s[l]*=b,s[l+1]*=x,s[l+2]*=c}}a.putImageData(C,0,0);let y=e.toDataURL("image/jpeg");{let v=yield S.ImageLoader(y),{width:b,height:x}=v,c=b/x;this.Picture=G(H({},this.Picture),{elm:v,aspect:c,revisedAspect:this.pst.frame.aspect>c?this.pst.frame.w/b:this.pst.frame.h/x})}this.drawImage()})}drawImage(t,n){let{use:i,Canvas:{ctx:e,elm:a},pst:{frame:r}}=this,p=t||this.pst.imageX,u=n||this.pst.imageY;{let C=this.scale.current/100,s=this.Picture.revisedAspect*C,l=this.pst.centerX-p*s,g=this.pst.centerY-u*s,y=this.Picture.elm.width*s,v=this.Picture.elm.height*s;{let b=this.pst.frame.x+this.pst.frame.w-y,x=this.pst.frame.x,c=this.pst.frame.y+this.pst.frame.h-v,m=this.pst.frame.y,h=0;l<b&&(h=l-b),l>x&&(h=l-x);let R=0;g<c&&(R=g-c),g>m&&(R=g-m),this.dragEffectInfo.origin.x+=h/2/this.dragEffectInfo.frameExpandRate.x,this.dragEffectInfo.origin.y+=R/2/this.dragEffectInfo.frameExpandRate.y,l=Math.min(Math.max(l,b),x),g=Math.min(Math.max(g,c),m)}this.pst.outImage={x:l,y:g,w:y,h:v},e.clearRect(0,0,this.Canvas.elm.width,this.Canvas.elm.height),e.drawImage(this.Picture.elm,0,0,this.Picture.elm.width,this.Picture.elm.height,l,g,y,v)}{if(i=="square"){e.fillStyle="rgba( 20,24,20,.3 )",e.beginPath();let l=a.width/3*2,g=a.height/3*2,y=Math.min(l,g),v=Math.max(l,g);e.arc(a.width/2,a.height/2,v,0,Math.PI*2,!0),e.arc(a.width/2,a.height/2,y/2,0,Math.PI*2,!1),e.closePath(),e.fill()}else(i=="wallpaper.horizontal"||i=="wallpaper.vertical")&&(e.fillStyle="rgba( 20,24,20,.3 )");e.beginPath(),e.moveTo(0,0),e.lineTo(a.width,0),e.lineTo(a.width,a.height),e.lineTo(0,a.height),e.lineTo(0,0),e.closePath(),e.lineTo(r.x,r.y),e.lineTo(r.x,r.y+r.h),e.lineTo(r.x+r.w,r.y+r.h),e.lineTo(r.x+r.w,r.y),e.lineTo(r.x,r.y),e.fill();let s=S(document.body).getStyleProperty("--color-theme-hsl");e.lineWidth=4,e.strokeStyle=`hsla( ${s},1 )`,e.strokeRect(r.x,r.y,r.w,r.h)}}export(){return z(this,null,function*(){let{Canvas:t,develops:n,Picture:i,pst:{outImage:e,frame:a}}=this,r=e.w/i.elm.width,p=e.h/i.elm.height,u=(a.x-e.x)/r,C=(a.x-e.x+a.w)/r,s=(a.y-e.y)/p,l=(a.y-e.y+a.h)/p,g=Array.from({length:n.length}),y="image/jpeg";for(let v=0;v<n.length;v++){let{size:b,maxSize:x}=n[v];x=x||{S:1024*20,R:1024*100,L:1024*350}[b];let c={S:140,R:600,L:1200}[b],m=c;this.use=="wallpaper.horizontal"?m=c/3:this.use=="wallpaper.vertical"&&(m=c*2);let h=document.createElement("canvas");h.width=c,h.height=m;let R=h.getContext("2d");if(!R)return;R.clearRect(0,0,c,m),R.drawImage(this.Picture.elm,u,s,C-u,l-s,0,0,c,m);let D=h.toDataURL(y),w=yield D.toBlob(y);if(!w)return;if(w.size>=x){let k=x/w.size;if(D=h.toDataURL(y,k*.92),w=yield D.toBlob(y),!w)return}let W=new File([w],this.val_file.name,{type:y});g[v]=W}return g})}}const Z={Core:d=>{let{val_file:t,options:n,finishedCallback:i,abortCallback:e}=d,{use:a,develops:r=[]}=n,[p]=N(J());const u={scale:{default:120,min:100,max:400},rotate:0,grayScale:0,tone:0};let[C,s]=N(u.scale.default),[l,g]=N(u.rotate),[y,v]=N(u.grayScale),[b,x]=N(u.tone);return O(()=>{let c="CropperResize";return S(window).addEvent({eventType:"resize",eventID:c,callback:()=>{S.interval.once(()=>{var k;let m=K("#Canvas-"+p)[0];if(!m)return;let h=(k=X.get(p))==null?void 0:k.Instance;if(!h)return;let R=m.position(),D=R.width/R.height;m.width=2400,m.height=2400/D;let{width:w,height:W}=m;h.pst.centerX=w/2,h.pst.centerY=W/2,h.frameSizing(),h.modifyImage()},250,"CropperResize")}}),()=>{S(window).removeEvent(c)}},[]),O(()=>{X.set({[p]:{}}),z(void 0,null,function*(){V.fn.corner.active(),yield S.pending(()=>{},400);let{target:c}=yield t.convert();if(!c)return;let m=c.result,h=K("#Canvas-"+p)[0];if(!h)return;let R=h.position(),D=R.width/R.height;h.width=2400,h.height=2400/D;let w=new re({set_scale:s,val_file:t,develops:r,use:a,scale:u.scale,componentID:p,canvas:h,picture:{image:yield S.ImageLoader(m),grayScale:u.grayScale,tone:u.tone,rotate:u.rotate}});X.set({[p]:{Instance:w}});const W=function(E){if(E.preventDefault(),E.touches&&E.touches.length>1)w.pinchEffect({eventType:"start",event:E}),S(document).addEvent({eventType:"touchmove",eventID:"CropperEffectMove",options:{passive:!1},callback:_=>{_.preventDefault(),w.pinchEffect({eventType:"move",event:_})}}).addEvent({eventType:"touchend",eventID:"CropperEffectEnd",options:{passive:!1},callback:j});else{w.dragEffect(H({eventType:"start"},S.getCursor(E)));let{type:_}=E;S(document).addEvent({eventType:_=="touchstart"?"touchmove":"mousemove",eventID:"CropperEffectMove",options:{passive:!1},callback:T=>{k("move",T)}}).addEvent({eventType:_=="touchstart"?"touchend":"mouseup",eventID:"CropperEffectEnd",options:{passive:!1},callback:T=>{k("end",T),j(T)}})}},k=function(E,_){_.preventDefault(),w.dragEffect(H({eventType:E},S.getCursor(_)))},j=function(E){E.preventDefault(),S(document).removeEvent(["CropperEffectMove","CropperEffectEnd"])};S(h).removeEvent(["CropperMouseWheel","CropperTouchStart","CropperMouseDown"]).addEvent({eventID:"CropperMouseWheel",eventType:"wheel",callback:E=>{E.preventDefault();let _=Number(E.wheelDelta*.04),T=w.scale.current+_;T=Math.max(T,w.scale.min),T=Math.min(T,w.scale.max),s(T)},options:{passive:!1}}).addEvent({eventType:"touchstart",eventID:"CropperTouchStart",callback:W,options:{passive:!1}}).addEvent({eventType:"mousedown",eventID:"CropperMouseDown",callback:W,options:{passive:!1}}),setTimeout(()=>{V.fn.corner.stop()},1e3)})},[t.id]),O(()=>{var m;let c=(m=X.get(p))==null?void 0:m.Instance;c&&c.updateScale(C)},[C]),O(()=>{var m;let c=(m=X.get(p))==null?void 0:m.Instance;c&&c.updateFilter({grayScale:y,tone:b,rotate:l})},[y,b,l]),o(A.Body,{borderRadius:0,height:"viewHeight",width:"viewWidth",children:f(M,{className:[U("Wrap"),U("Use_"+a)].join(" "),gap:0,height:1,position:"relative",overflow:"hidden",borderRadius:"inherit",children:[o(B,{flexSizing:0,overflow:"hidden",position:"relative",backgroundColor:"black",flexCenter:!0,freeCSS:{zIndex:1},children:o("canvas",{style:{width:"100%",height:"100%"},width:2400,height:2400,className:U("Canvas"),id:"Canvas-"+p})}),f(I.Separate,{borderTop:!0,flexSizing:"none",backgroundColor:"layer.1",padding:1,verticalAlign:"unset",UnderBreakPointStyles:{flexType:"col"},children:[o(Z.SettingRegion,{DefaultOptions:u,val_scale:C,set_scale:s,val_tone:b,set_tone:x,val_grayScale:y,set_grayScale:v,val_rotate:l,set_rotate:g}),f(I.Right,{flexSizing:"none",children:[o(P.Border,{isRounded:!0,onClick:()=>{e()},children:"\u9589\u3058\u308B"}),o(P,{isRounded:!0,boxShadow:"3.remark",onClick:()=>z(void 0,null,function*(){var h;let c=(h=X.get(p))==null?void 0:h.Instance;if(!c)return;V.fn.mini.active("CropperExportation");let m=yield c.export();setTimeout(()=>{V.fn.mini.stop("CropperExportation"),i(m)},3e3)}),children:f(I.Center,{gap:"1/2",children:[o(V.White.R,{loaderID:"CropperExportation"}),"\u6C7A\u5B9A"]})})]})]})]})})},SettingRegion:d=>{let t=["","\u6696\u8272","\u5BD2\u8272","\u30BB\u30D4\u30A2","\u30B7\u30A2\u30F3","\u30DE\u30BC\u30F3\u30BF","\u30A4\u30A8\u30ED\u30FC","\u30AA\u30EA\u30B8\u30CA\u30EB1","\u30AA\u30EA\u30B8\u30CA\u30EB2","\u30AA\u30EA\u30B8\u30CA\u30EB3","\u30AA\u30EA\u30B8\u30CA\u30EB4"],n=i=>t[i]||"\u306A\u3057";return f(I.Left,{verticalAlign:"unset",flexWrap:!0,children:[f(M,{gap:"1/3",children:[o(F.Supplement,{children:"Rotate"}),f(I.Left,{flexChilds:"even",gap:"1/6",children:[o(P.Border.S,{isRounded:!0,borderTopRightRadius:0,borderBottomRightRadius:0,onClick:()=>{let i=d.val_rotate-90;i<0&&(i+=360),d.set_rotate(i)},children:f(I.Center,{gap:"1/4",children:["90\xB0",o(L,{icon:te})]})}),o(P.Border.S,{isRounded:!0,borderTopLeftRadius:0,borderBottomLeftRadius:0,onClick:()=>{d.set_rotate((d.val_rotate+90)%360)},children:f(I.Center,{gap:"1/4",children:[o(L,{icon:ae}),"90\xB0"]})})]})]}),f(M,{gap:"1/3",freeCSS:{minWidth:12*6},children:[o(F.Supplement,{children:"Zoom"}),f(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:i=>{let e="CropperZoomEdit";Y.open({tipsID:e,gravityPoint:3,event:i,closeAtParentBlur:!1,freeCSS:{minWidth:12*26},content:o(A.Body,{children:f(M,{padding:1.5,children:[f(I.Separate,{children:[o(F.Paragraph,{children:f(I.Center,{gap:"1/2",children:[o(L.Search,{fontColor:"5.translucent"}),"Zoom"]})}),o(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(e)},children:o(L.Times,{})})]}),o(B,{borderBottom:!0,opacity:"low"}),o(q.Slider,{override:"force",value:d.val_scale-100,min:d.DefaultOptions.scale.min-100,max:d.DefaultOptions.scale.max-100,step:25,onUpdateValidValue:(a,r)=>{S.interval.once(()=>{d.set_scale(a+100)},250,"Cropper.UpdateScale")},legends:{enable:!0,custom:a=>"x"+Math.round(100+a)/100}})]})})})},children:[d.val_scale.rate(1,0),"%"]})]}),f(M,{gap:"1/3",freeCSS:{minWidth:12*6},children:[o(F.Supplement,{children:"GrayScale"}),f(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:i=>{let e="CropperGrayScaleEdit";Y.open({tipsID:e,gravityPoint:3,event:i,closeAtParentBlur:!1,freeCSS:{minWidth:12*26},content:o(A.Body,{children:f(M,{padding:1.5,children:[f(I.Separate,{children:[o(F.Paragraph,{children:f(I.Center,{gap:"1/2",children:[o(L,{icon:Q,fontColor:"5.translucent"}),"Gray Scale"]})}),o(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(e)},children:o(L.Times,{})})]}),o(B,{borderBottom:!0,opacity:"low"}),o(q.Slider,{value:d.val_grayScale,min:0,max:100,step:10,onUpdateValidValue:a=>{S.interval.once(()=>{d.set_grayScale(a)},250,"Cropper.GrayScale")},legends:{enable:!0,custom:a=>a+"%"}})]})})})},children:[d.val_grayScale.rate(1,0),"%"]})]}),f(M,{gap:"1/3",freeCSS:{minWidth:12*6},children:[o(F.Supplement,{children:"Tone"}),o(P.Border.S,{flexCenter:!0,isRounded:!0,flexSizing:0,onClick:i=>{let e="CropperToneEdit";Y.open({tipsID:e,gravityPoint:3,event:i,closeAtParentBlur:!1,freeCSS:{minWidth:12*26,maxWidth:12*24},content:()=>{let a=[];for(let r=1;r<=10;r++)a.push({value:r,label:f(I.Left,{gap:"1/3",children:[o(B,{ssSphere:1,className:[U("ToneBall"),U("ToneBall_"+r)].join(" ")}),o(B,{textAlign:"left",flexSizing:0,children:n(r)})]})});return o(A.Body,{children:f(M,{padding:1.5,children:[f(I.Separate,{children:[o(F.Paragraph,{children:f(I.Center,{gap:"1/2",children:[o(L,{icon:ee,fontColor:"5.translucent"}),"Tone"]})}),o(P.Sub,{color:"cloud",ssSphere:2.5,onClick:()=>{Y.close(e)},children:o(L.Times,{})})]}),o(B,{borderBottom:!0,opacity:"low"}),o(q.Radio.Normal,{value:d.val_tone,gap:"1/2",cellStyles:{fontColor:"3.blur"},options:[{value:0,label:o(B,{flexSizing:0,textAlign:"center",children:"\u306A\u3057"})},...a],onUpdateValidValue:r=>{d.set_tone(r)}})]})})}})},children:f(I.Center,{gap:"1/2",children:[o(B,{boxShadow:"2.remark",ssSphere:1,className:[U("ToneBall"),U("ToneBall_"+d.val_tone)].join(" ")}),n(d.val_tone)]})})]})]})}},$={openDialogNEdit:d=>z(void 0,null,function*(){let t=yield q.Filer.fn.openDialog({accept:"image",multiple:!1});$.openEditor(H({imageFile:t[0]},d))}),openEditor:d=>z(void 0,null,function*(){let t="CropperImage";A.open({sheetID:t,type:"normal.middleCenter",size:"MAX",padding:0,margin:0,freeCSS:{maxWidth:"100%"},content:o(Z.Core,{val_file:d.imageFile,options:d,finishedCallback:n=>{A.close(t),d.onProcessFinished(n)},abortCallback:()=>{A.close(t)}}),closeAtEscapeKeyDown:!1})})};export{$ as Cropper,$ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as S,c as O,d as Q,e as Y}from"../../chunk-C5N2D3ZX.js";import{Fragment as X,jsx as l,jsxs as P}from"react/jsx-runtime";import{useState as I,useEffect as E,useRef as ne}from"react";import s,{UUID as W}from"jmini";import{ExtractStyles as ae}from"../../@utils";import{Box as R,Span as re,FAI as M,Column as ie}from"../../atoms";import{Text as N,Row as q}from"../../mols";import{Button as Z}from"../Button";import{Loader as se}from"../Loader";import{Sheet as ue}from"../Sheet";import{OptionalInputWrapper as ce,BoxWrapper as pe,CoreEffects as z,DefaultBoxishStyles as de}from"./core";import{InputAutocompleteClasses as U}from"../../@styles/componentClasses";import{InputLabel as Se}from"./Label";import{RightIcon as ee}from".";function me(e){let{value:t,states:u}=e,{required:c,options:n,min:o,max:f}=u;o=o||0,f=f||65535;let v=[],p=t.filter(d=>d!==null).length;return c&&(p||v.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),p<o&&v.push({type:"invalid",label:o+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),p>f&&v.push({type:"invalid",label:f+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!v.filter(({type:d})=>d=="invalid").length,notice:v}}const B={InitOptions:e=>{let t=[];return e.forEach(u=>{let{type:c,label:n,value:o,searchValue:f}=u,v=f||(s.is.string(n)?n:"")||(s.is.string(o)?o:"");s.is.nullish(n)&&(n=String(o)),t.push(O(S({},u),{searchValue:v,type:c||"selector",label:n,value:o}))}),t},FilterSelectableOptions:(e,t)=>{let u=e.val_options;if(t||(u=e.val_options.filter(c=>c.type!="label")),e.val_keyword){let c=e.val_keyword.toLower().replace(/ /g,"");u=u.filter(n=>(n.searchValue||"").toLower().replace(/ /g,"").includes(c))}return u}},L={Shallow:e=>{let{rootStates:t,val_status:u}=e,c=ae(t);return l(R,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:l(N.Description,O(S({className:t.className},c),{position:"absolute",width:1,freeCSS:O(S({},c.freeCSS),{color:"orange"}),"data-id":"shallow_"+u.componentID,children:l(R,{"data-input-value-shallow":u.componentID,children:"A"})}))})},Button:e=>{let{rootStates:t,val_keyword:u,set_keyword:c,val_optionFocused:n,set_optionFocused:o,val_options:f,set_options:v,val_optionsDict:p,set_optionsDict:d,val_preventOpenSelectorOnFocus:a,set_preventOpenSelectorOnFocus:m,val_selectorOpen:r,set_selectorOpen:i,val_status:y,set_status:w,val_validate:b,set_validate:C}=e,j=t,{tone:_,required:k,form:D,className:x,multiSelect:K,enableFormSubmit:T,checkValidationAtFirst:A,onValidate:$,onUpdateValue:J,onUpdateValidValue:H,value:fe="",options:ve,leftIndicator:ye,rightIndicator:he,leftIcon:_e,rightIcon:ge,componentID:be,status_id:Oe,wrapStyles:Ie,emptySelect:Ce,SearchInput:De,SearchInputPlaceholder:we,SelectedComponent:Te,SelectorComponent:Ve,SelectorStyles:ke,SelectorPosition:xe,DynamicOptionsOnSearch:Re}=j,g=Q(j,["tone","required","form","className","multiSelect","enableFormSubmit","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","wrapStyles","emptySelect","SearchInput","SearchInputPlaceholder","SelectedComponent","SelectorComponent","SelectorStyles","SelectorPosition","DynamicOptionsOnSearch"]);return E(()=>{var V,F;if(t.disabled||!r)return;let h=B.FilterSelectableOptions(e);o((F=(V=h[0])==null?void 0:V.value)!=null?F:null)},[u]),E(()=>{y.eventType!="init"&&(t.max==y.dataValue.length?(i(!1),m(!0),setTimeout(()=>{let h=s('[data-input-origin="'+t.componentID+'"]');h&&h.focus()},10)):s("#SearchInput_"+t.componentID).focus())},[y.dataValue]),E(()=>{let h="autocomplete-click-"+t.componentID;if(r){if(!s('[data-input-origin="'+t.componentID+'"]'))return;s("#SearchInput_"+t.componentID).focus(),s(document).addEvent({eventID:h,eventType:"mousedown",callback:F=>{let G=s(F.target),oe=!!s(G).parent("."+U("Core")).length,le=!!s(G).parent("."+U("Selector")).length;oe||le||(i(!1),F.preventDefault(),F.stopPropagation())}})}else s(document).removeEvent([h]),c("")},[r]),P(X,{children:[l(R,O(S({tabIndex:0},g),{"data-disabled":t.disabled,"data-show-validation":z.isShowValidation(b,y,!!A),"data-component-id":y.componentID,"data-input-origin":y.componentID,"data-focus":!!r,className:[x,U("Core")].join(" "),onFocus:h=>{if(g!=null&&g.onFocus&&(g==null||g.onFocus(h)),!t.disabled){if(a)return m(!1);i(!0),h.preventDefault()}},onClick:h=>{g!=null&&g.onClick&&(g==null||g.onClick(h)),!t.disabled&&i(!0)},onKeyDown:h=>{let{key:V}=h;T&&z.SubmitForm(h,D),!r&&(V==" "||V=="ArrowDown"||V=="ArrowUp"||V=="Enter")&&i(!0)},children:P(q.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(L.Selected,S({},e)),l(re,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),l(L.SearchInput,S({},e))]})})),r&&l(L.Selector,S({},e))]})},SearchInput:e=>{let{rootStates:t}=e,[u,c]=I(!1);return t.disabled||!e.val_selectorOpen?null:l(R,{id:"SearchInput_"+t.componentID,placeholder:t.SearchInputPlaceholder||"\u691C\u7D22...",opacity:e.val_selectorOpen?"max":"trans",transition:"middle",flexSizing:0,htmlTag:"input",border:"unset",backgroundColor:"trans",value:e.val_keyword,freeCSS:{outline:"none"},onCompositionStart:n=>{t.onCompositionStart&&t.onCompositionStart(n),c(!0)},onCompositionEnd:n=>{t.onCompositionEnd&&t.onCompositionEnd(n),c(!1)},onKeyDown:n=>{let{key:o,metaKey:f,ctrlKey:v}=n,p=f||v;o=="Escape"?(e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0),setTimeout(()=>{let d=s('[data-input-origin="'+t.componentID+'"]');d&&d.focus()},10)):o=="Tab"?e.set_selectorOpen(!1):o==" "?s.scope(()=>{e.val_selectorOpen||e.val_keyword||(n.preventDefault(),e.set_selectorOpen(!0))}):o=="Backspace"?s.scope(()=>{if(e.val_keyword)return;let d=[...e.val_status.dataValue];d.pop(),e.set_status(a=>O(S({},a),{dataValue:d,eventType:"update",eventID:W()}))}):o=="Enter"&&s.scope(()=>{if(u)return;if(!e.val_selectorOpen)return e.set_selectorOpen(!0);let d=e.val_options.find(m=>m.value==e.val_optionFocused);if(!d)return;let{value:a}=d;e.set_status(m=>{let r=[...m.dataValue];return s.scope(()=>{if(a===null)return r=[];m.dataValue.includes(a)?r=r.filter(y=>y!==a):t.multiSelect?r.push(a):r=[a]}),O(S({},m),{dataValue:r,eventType:"update",eventID:W()})}),e.set_keyword(""),e.set_preventDynamicSearchOnKeywordChange(!0)}),s.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(o))return;if(n.preventDefault(),!e.val_selectorOpen)return e.set_selectorOpen(!0);let d=o=="ArrowDown"?1:-1,a=B.FilterSelectableOptions(e),m=a.length-1,r=null;s.scope(()=>{var y,w,b,C,_,k,D,x,K,T;let i=a.findIndex(A=>A.value==e.val_optionFocused);if(i==-1&&(i=0),d==1){if(r=(w=(y=a[0])==null?void 0:y.value)!=null?w:null,p){r=(b=a[m].value)!=null?b:null;return}if(i==-1||i==m)return;r=(_=(C=a[i+1])==null?void 0:C.value)!=null?_:null}else{if(r=(k=a[m].value)!=null?k:null,p){r=(x=(D=a[0])==null?void 0:D.value)!=null?x:null;return}if(i==-1||i==0)return;r=(T=(K=a[i-1])==null?void 0:K.value)!=null?T:null}}),e.set_optionFocused(r)}),t.enableFormSubmit&&z.SubmitForm(n,e.rootStates.form)},onChange:n=>{let f=n.target.value;e.set_keyword(f)}},"searchInput")},Selector:e=>{var d;let[t,u]=I("idle"),[c,n]=I("idle");E(()=>{if(!e.val_selectorOpen||!e.rootStates.DynamicOptionsOnSearch)return;if(e.val_preventDynamicSearchOnKeywordChange)return e.set_preventDynamicSearchOnKeywordChange(!1);if(t=="idle")return u("ok");n("fetch");let a="autocomplete-search-"+e.rootStates.componentID;s.interval.once(()=>Y(void 0,null,function*(){let m=yield e.rootStates.DynamicOptionsOnSearch(e.val_keyword);n("idle");let r=B.InitOptions(m||[]);e.set_options(r)}),300,a)},[e.val_keyword]);let o=[],f=B.FilterSelectableOptions(e,!0),v=B.FilterSelectableOptions(e);f.forEach((a,m)=>{let{type:r,value:i}=a,y=e.val_optionFocused==i,w=e.val_status.dataValue.includes(i),b=e.rootStates.SelectorComponent;o.push(l(b,{option:a,isFocused:y,isSelected:w,addCallback:()=>{e.set_status(C=>{let _=[...C.dataValue];return s.scope(()=>{if(i===null)return _=[];C.dataValue.includes(i)?_=_.filter(D=>D!==i):e.rootStates.multiSelect?_.push(i):_=[i]}),O(S({},C),{dataValue:_,eventType:"update",eventID:W()})})}},s.Stringify(i)||W()))}),v.length||(o=[l(N.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]),c=="fetch"&&(o=[P(q.Left,{padding:1,fontColor:"3.blur",children:[l(se.Theme.R,{showInitial:!0}),l(N.Supplement,{children:"Loading..."})]},"loader")]);let p={position:"absolute",minWidth:1,freeCSS:{zIndex:1e3}};switch(e.rootStates.SelectorPosition){case 1:p.bottom="100%",p.left=0,p.paddingBottom="1/3";break;case 2:p.bottom="100%",p.right=0,p.paddingBottom="1/3";break;case 3:p.top="100%",p.left=0,p.paddingTop="1/3";break;case 4:p.top="100%",p.right=0,p.paddingTop="1/3";break;default:break}return l(R,O(S({},p),{children:l(ue.Body,O(S({className:U("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,boxShadow:"1.normal",overflow:"auto"},e.rootStates.SelectorStyles),{freeCSS:S({maxHeight:12*24},(d=e.rootStates.SelectorStyles)==null?void 0:d.freeCSS),children:l(ie,{gap:"1/12",padding:[1,0],children:o})}))}))},Selected:e=>{let{rootStates:t,val_status:u,set_status:c,val_optionsDict:n}=e,o=[];return u.dataValue.forEach(f=>{let v=n[s.Stringify(f)];if(!v)return;let p=t.SelectedComponent,d=v.label;v.value===null&&(d=""),o.push(l(R,{className:U("SelectedCell"),children:l(p,{value:v.value,label:d,removeCallback:a=>{if(a.stopPropagation(),a.preventDefault(),t.disabled)return;let m=[...u.dataValue];m=m.filter(r=>r!==f),c(r=>O(S({},r),{dataValue:m,eventType:"update",eventID:W()}))}})},s.Stringify(v.value)))}),l(X,{children:o})},Core:e=>{var A;let{value:t}=e,[u,c]=I(!1),[n,o]=I(!1),[f,v]=I(!1),[p,d]=I(""),[a,m]=I(e.options),[r,i]=I((A=e.value[0])!=null?A:null),[y,w]=I({}),[b,C]=I(z.DefaultStatus(e.componentID,t)),[_,k]=I({ok:!1,notice:[]}),D=ne(!1);E(()=>{D.current?m(e.options):D.current=!0},[e.options]),E(()=>{if(!a.length)return;let $=[...a],J=S({},y);$.forEach(H=>{H.type!="label"&&(J[s.Stringify(H.value)]=H)}),w(J)},[a]);let x={rootStates:e,val_options:a,set_options:m,val_optionFocused:r,set_optionFocused:i,val_optionsDict:y,set_optionsDict:w,val_preventDynamicSearchOnKeywordChange:n,set_preventDynamicSearchOnKeywordChange:o,val_preventOpenSelectorOnFocus:u,set_preventOpenSelectorOnFocus:c,val_selectorOpen:f,set_selectorOpen:v,val_keyword:p,set_keyword:d,val_status:b,set_status:C,val_validate:_,set_validate:k},K=!!e.multiSelect;z.CommonEffects({type:K?"autocomplete.multi":"autocomplete.single",states:e,val_status:b,set_status:C,val_validate:_,set_validate:k,SystemValidation:me});let T=b.dataValue.length&&b.dataValue[0]!==null;return T=T||f,P(pe,{val_status:b,set_status:C,val_validate:_,states:e,children:[l(Se,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:T}),l(L.Shallow,S({},x)),l(L.Button,S({},x))]})}},te=e=>{var u;let t=S({},e);return t=O(S({value:[],min:0,max:65535,multiSelect:!0,SearchInput:!0,emptySelect:!0,SelectorComponent:({option:c,isSelected:n,isFocused:o,addCallback:f})=>c.type=="selector"?l(Z.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1.5],isActive:o,isActiveStyles:{backgroundColor:"cloud"},onClick:v=>{f()},children:P(q.Left,{gap:"1/2",children:[n&&l(M.Check,{fontColor:"theme"}),l(N.Supplement,{transition:"short",children:c.label})]})}):l(X,{children:c.label}),SelectedComponent:({value:c,label:n,removeCallback:o})=>P(q.Left,{ssCardBox:"cloud",borderRadius:"2.tone.secondary",fontSize:"1.mini",padding:"1/2",gap:0,children:[l(R,{padding:[0,"1/4"],children:n}),l(Z.Sub,{flexSizing:"none",color:"cloud",fontColor:"white",backgroundColor:"layer.5",isRounded:!0,padding:"1/4",onClick:o,freeCSS:{lineHeight:1,aspectRatio:"1/1"},children:l(M.Times,{ssSphere:1})})]}),SelectorPosition:3},t),{freeCSS:S({cursor:"pointer"},t.freeCSS)}),t.multiSelect||(t.min=0,t.max=1),t.options=t.options||[],t.emptySelect&&(t.options=[{value:null,label:l(N.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=s.flatArray((u=t.value)!=null?u:null),t.options=B.InitOptions(t.options),s.is.nullish(t.rightIcon)&&(t.rightIcon=l(ee,{ssSphere:2,children:l(M.Search,{})}),t.disabled&&(t.rightIcon=l(ee,{ssSphere:2,fontColor:"5.translucent",children:l(M.Ban,{})}))),t.rightIcon&&(t=S({paddingRight:3},t)),t.leftIcon&&(t=S({paddingLeft:3},t)),l(ce,{componentID:t.componentID,children:L.Core,states:de(t)})};export{te as Autocomplete,te as default};
|
|
1
|
+
import{b as S,c as O,d as Q,e as Y}from"../../chunk-C5N2D3ZX.js";import{Fragment as X,jsx as l,jsxs as P}from"react/jsx-runtime";import{useState as I,useEffect as E,useRef as ne}from"react";import s,{UUID as W}from"jmini";import{ExtractStyles as ae}from"../../@utils";import{Box as x,Span as re,FAI as M,Column as ie}from"../../atoms";import{Literal as N,Row as q}from"../../mols";import{Button as Z}from"../Button";import{Loader as se}from"../Loader";import{Sheet as ue}from"../Sheet";import{OptionalInputWrapper as ce,BoxWrapper as pe,CoreEffects as z,DefaultBoxishStyles as de}from"./core";import{InputAutocompleteClasses as U}from"../../@styles/componentClasses";import{InputLabel as Se}from"./Label";import{RightIcon as ee}from".";function me(e){let{value:t,states:u}=e,{required:c,options:n,min:o,max:f}=u;o=o||0,f=f||65535;let v=[],p=t.filter(d=>d!==null).length;return c&&(p||v.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),p<o&&v.push({type:"invalid",label:o+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),p>f&&v.push({type:"invalid",label:f+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!v.filter(({type:d})=>d=="invalid").length,notice:v}}const L={InitOptions:e=>{let t=[];return e.forEach(u=>{let{type:c,label:n,value:o,searchValue:f}=u,v=f||(s.is.string(n)?n:"")||(s.is.string(o)?o:"");s.is.nullish(n)&&(n=String(o)),t.push(O(S({},u),{searchValue:v,type:c||"selector",label:n,value:o}))}),t},FilterSelectableOptions:(e,t)=>{let u=e.val_options;if(t||(u=e.val_options.filter(c=>c.type!="label")),e.val_keyword){let c=e.val_keyword.toLower().replace(/ /g,"");u=u.filter(n=>(n.searchValue||"").toLower().replace(/ /g,"").includes(c))}return u}},B={Shallow:e=>{let{rootStates:t,val_status:u}=e,c=ae(t);return l(x,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:l(N.Description,O(S({className:t.className},c),{position:"absolute",width:1,freeCSS:O(S({},c.freeCSS),{color:"orange"}),"data-id":"shallow_"+u.componentID,children:l(x,{"data-input-value-shallow":u.componentID,children:"A"})}))})},Button:e=>{let{rootStates:t,val_keyword:u,set_keyword:c,val_optionFocused:n,set_optionFocused:o,val_options:f,set_options:v,val_optionsDict:p,set_optionsDict:d,val_preventOpenSelectorOnFocus:a,set_preventOpenSelectorOnFocus:m,val_selectorOpen:r,set_selectorOpen:i,val_status:y,set_status:w,val_validate:b,set_validate:C}=e,j=t,{tone:_,required:T,form:D,className:R,multiSelect:K,enableFormSubmit:V,checkValidationAtFirst:A,onValidate:$,onUpdateValue:J,onUpdateValidValue:H,value:fe="",options:ve,leftIndicator:ye,rightIndicator:he,leftIcon:_e,rightIcon:ge,componentID:be,status_id:Oe,wrapStyles:Ie,emptySelect:Ce,SearchInput:De,SearchInputPlaceholder:we,SelectedComponent:Ve,SelectorComponent:ke,SelectorStyles:Te,SelectorPosition:Re,DynamicOptionsOnSearch:xe}=j,g=Q(j,["tone","required","form","className","multiSelect","enableFormSubmit","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","wrapStyles","emptySelect","SearchInput","SearchInputPlaceholder","SelectedComponent","SelectorComponent","SelectorStyles","SelectorPosition","DynamicOptionsOnSearch"]);return E(()=>{var k,F;if(t.disabled||!r)return;let h=L.FilterSelectableOptions(e);o((F=(k=h[0])==null?void 0:k.value)!=null?F:null)},[u]),E(()=>{y.eventType!="init"&&(t.max==y.dataValue.length?(i(!1),m(!0),setTimeout(()=>{let h=s('[data-input-origin="'+t.componentID+'"]');h&&h.focus()},10)):s("#SearchInput_"+t.componentID).focus())},[y.dataValue]),E(()=>{let h="autocomplete-click-"+t.componentID;if(r){if(!s('[data-input-origin="'+t.componentID+'"]'))return;s("#SearchInput_"+t.componentID).focus(),s(document).addEvent({eventID:h,eventType:"mousedown",callback:F=>{let G=s(F.target),oe=!!s(G).parent("."+U("Core")).length,le=!!s(G).parent("."+U("Selector")).length;oe||le||(i(!1),F.preventDefault(),F.stopPropagation())}})}else s(document).removeEvent([h]),c("")},[r]),P(X,{children:[l(x,O(S({tabIndex:0},g),{"data-disabled":t.disabled,"data-show-validation":z.isShowValidation(b,y,!!A),"data-component-id":y.componentID,"data-input-origin":y.componentID,"data-focus":!!r,className:[R,U("Core")].join(" "),onFocus:h=>{if(g!=null&&g.onFocus&&(g==null||g.onFocus(h)),!t.disabled){if(a)return m(!1);i(!0),h.preventDefault()}},onClick:h=>{g!=null&&g.onClick&&(g==null||g.onClick(h)),!t.disabled&&i(!0)},onKeyDown:h=>{let{key:k}=h;V&&z.SubmitForm(h,D),!r&&(k==" "||k=="ArrowDown"||k=="ArrowUp"||k=="Enter")&&i(!0)},children:P(q.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(B.Selected,S({},e)),l(re,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),l(B.SearchInput,S({},e))]})})),r&&l(B.Selector,S({},e))]})},SearchInput:e=>{let{rootStates:t}=e,[u,c]=I(!1);return t.disabled||!e.val_selectorOpen?null:l(x,{id:"SearchInput_"+t.componentID,placeholder:t.SearchInputPlaceholder||"\u691C\u7D22...",opacity:e.val_selectorOpen?"max":"trans",transition:"middle",flexSizing:0,htmlTag:"input",border:"unset",backgroundColor:"trans",value:e.val_keyword,freeCSS:{outline:"none"},onCompositionStart:n=>{t.onCompositionStart&&t.onCompositionStart(n),c(!0)},onCompositionEnd:n=>{t.onCompositionEnd&&t.onCompositionEnd(n),c(!1)},onKeyDown:n=>{let{key:o,metaKey:f,ctrlKey:v}=n,p=f||v;o=="Escape"?(e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0),setTimeout(()=>{let d=s('[data-input-origin="'+t.componentID+'"]');d&&d.focus()},10)):o=="Tab"?e.set_selectorOpen(!1):o==" "?s.scope(()=>{e.val_selectorOpen||e.val_keyword||(n.preventDefault(),e.set_selectorOpen(!0))}):o=="Backspace"?s.scope(()=>{if(e.val_keyword)return;let d=[...e.val_status.dataValue];d.pop(),e.set_status(a=>O(S({},a),{dataValue:d,eventType:"update",eventID:W()}))}):o=="Enter"&&s.scope(()=>{if(u)return;if(!e.val_selectorOpen)return e.set_selectorOpen(!0);let d=e.val_options.find(m=>m.value==e.val_optionFocused);if(!d)return;let{value:a}=d;e.set_status(m=>{let r=[...m.dataValue];return s.scope(()=>{if(a===null)return r=[];m.dataValue.includes(a)?r=r.filter(y=>y!==a):t.multiSelect?r.push(a):r=[a]}),O(S({},m),{dataValue:r,eventType:"update",eventID:W()})}),e.set_keyword(""),e.set_preventDynamicSearchOnKeywordChange(!0)}),s.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(o))return;if(n.preventDefault(),!e.val_selectorOpen)return e.set_selectorOpen(!0);let d=o=="ArrowDown"?1:-1,a=L.FilterSelectableOptions(e),m=a.length-1,r=null;s.scope(()=>{var y,w,b,C,_,T,D,R,K,V;let i=a.findIndex(A=>A.value==e.val_optionFocused);if(i==-1&&(i=0),d==1){if(r=(w=(y=a[0])==null?void 0:y.value)!=null?w:null,p){r=(b=a[m].value)!=null?b:null;return}if(i==-1||i==m)return;r=(_=(C=a[i+1])==null?void 0:C.value)!=null?_:null}else{if(r=(T=a[m].value)!=null?T:null,p){r=(R=(D=a[0])==null?void 0:D.value)!=null?R:null;return}if(i==-1||i==0)return;r=(V=(K=a[i-1])==null?void 0:K.value)!=null?V:null}}),e.set_optionFocused(r)}),t.enableFormSubmit&&z.SubmitForm(n,e.rootStates.form)},onChange:n=>{let f=n.target.value;e.set_keyword(f)}},"searchInput")},Selector:e=>{var d;let[t,u]=I("idle"),[c,n]=I("idle");E(()=>{if(!e.val_selectorOpen||!e.rootStates.DynamicOptionsOnSearch)return;if(e.val_preventDynamicSearchOnKeywordChange)return e.set_preventDynamicSearchOnKeywordChange(!1);if(t=="idle")return u("ok");n("fetch");let a="autocomplete-search-"+e.rootStates.componentID;s.interval.once(()=>Y(void 0,null,function*(){let m=yield e.rootStates.DynamicOptionsOnSearch(e.val_keyword);n("idle");let r=L.InitOptions(m||[]);e.set_options(r)}),300,a)},[e.val_keyword]);let o=[],f=L.FilterSelectableOptions(e,!0),v=L.FilterSelectableOptions(e);f.forEach((a,m)=>{let{type:r,value:i}=a,y=e.val_optionFocused==i,w=e.val_status.dataValue.includes(i),b=e.rootStates.SelectorComponent;o.push(l(b,{option:a,isFocused:y,isSelected:w,addCallback:()=>{e.set_status(C=>{let _=[...C.dataValue];return s.scope(()=>{if(i===null)return _=[];C.dataValue.includes(i)?_=_.filter(D=>D!==i):e.rootStates.multiSelect?_.push(i):_=[i]}),O(S({},C),{dataValue:_,eventType:"update",eventID:W()})})}},s.Stringify(i)||W()))}),v.length||(o=[l(N.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]),c=="fetch"&&(o=[P(q.Left,{padding:1,fontColor:"3.blur",children:[l(se.Theme.R,{showInitial:!0}),l(N.Supplement,{children:"Loading..."})]},"loader")]);let p={position:"absolute",minWidth:1,freeCSS:{zIndex:1e3}};switch(e.rootStates.SelectorPosition){case 1:p.bottom="100%",p.left=0,p.paddingBottom="1/3";break;case 2:p.bottom="100%",p.right=0,p.paddingBottom="1/3";break;case 3:p.top="100%",p.left=0,p.paddingTop="1/3";break;case 4:p.top="100%",p.right=0,p.paddingTop="1/3";break;default:break}return l(x,O(S({},p),{children:l(ue.Body,O(S({className:U("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,boxShadow:"1.normal",overflow:"auto"},e.rootStates.SelectorStyles),{freeCSS:S({maxHeight:12*24},(d=e.rootStates.SelectorStyles)==null?void 0:d.freeCSS),children:l(ie,{gap:"1/12",padding:[1,0],children:o})}))}))},Selected:e=>{let{rootStates:t,val_status:u,set_status:c,val_optionsDict:n}=e,o=[];return u.dataValue.forEach(f=>{let v=n[s.Stringify(f)];if(!v)return;let p=t.SelectedComponent,d=v.label;v.value===null&&(d=""),o.push(l(x,{className:U("SelectedCell"),children:l(p,{value:v.value,label:d,removeCallback:a=>{if(a.stopPropagation(),a.preventDefault(),t.disabled)return;let m=[...u.dataValue];m=m.filter(r=>r!==f),c(r=>O(S({},r),{dataValue:m,eventType:"update",eventID:W()}))}})},s.Stringify(v.value)))}),l(X,{children:o})},Core:e=>{var A;let{value:t}=e,[u,c]=I(!1),[n,o]=I(!1),[f,v]=I(!1),[p,d]=I(""),[a,m]=I(e.options),[r,i]=I((A=e.value[0])!=null?A:null),[y,w]=I({}),[b,C]=I(z.DefaultStatus(e.componentID,t)),[_,T]=I({ok:!1,notice:[]}),D=ne(!1);E(()=>{D.current?m(e.options):D.current=!0},[e.options]),E(()=>{if(!a.length)return;let $=[...a],J=S({},y);$.forEach(H=>{H.type!="label"&&(J[s.Stringify(H.value)]=H)}),w(J)},[a]);let R={rootStates:e,val_options:a,set_options:m,val_optionFocused:r,set_optionFocused:i,val_optionsDict:y,set_optionsDict:w,val_preventDynamicSearchOnKeywordChange:n,set_preventDynamicSearchOnKeywordChange:o,val_preventOpenSelectorOnFocus:u,set_preventOpenSelectorOnFocus:c,val_selectorOpen:f,set_selectorOpen:v,val_keyword:p,set_keyword:d,val_status:b,set_status:C,val_validate:_,set_validate:T},K=!!e.multiSelect;z.CommonEffects({type:K?"autocomplete.multi":"autocomplete.single",states:e,val_status:b,set_status:C,val_validate:_,set_validate:T,SystemValidation:me});let V=b.dataValue.length&&b.dataValue[0]!==null;return V=V||f,P(pe,{val_status:b,set_status:C,val_validate:_,states:e,children:[l(Se,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:V}),l(B.Shallow,S({},R)),l(B.Button,S({},R))]})}},te=e=>{var u;let t=S({},e);return t=O(S({value:[],min:0,max:65535,multiSelect:!0,SearchInput:!0,emptySelect:!0,SelectorComponent:({option:c,isSelected:n,isFocused:o,addCallback:f})=>c.type=="selector"?l(Z.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1.5],isActive:o,isActiveStyles:{backgroundColor:"cloud"},onClick:v=>{f()},children:P(q.Left,{gap:"1/2",children:[n&&l(M.Check,{fontColor:"theme"}),l(N.Supplement,{transition:"short",children:c.label})]})}):l(X,{children:c.label}),SelectedComponent:({value:c,label:n,removeCallback:o})=>P(q.Left,{ssCardBox:"cloud",borderRadius:"2.tone.secondary",fontSize:"1.mini",padding:"1/2",gap:0,children:[l(x,{padding:[0,"1/4"],children:n}),l(Z.Sub,{flexSizing:"none",color:"cloud",fontColor:"white",backgroundColor:"layer.5",isRounded:!0,padding:"1/4",onClick:o,freeCSS:{lineHeight:1,aspectRatio:"1/1"},children:l(M.Times,{ssSphere:1})})]}),SelectorPosition:3},t),{freeCSS:S({cursor:"pointer"},t.freeCSS)}),t.multiSelect||(t.min=0,t.max=1),t.options=t.options||[],t.emptySelect&&(t.options=[{value:null,label:l(N.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=s.flatArray((u=t.value)!=null?u:null),t.options=L.InitOptions(t.options),s.is.nullish(t.rightIcon)&&(t.rightIcon=l(ee,{ssSphere:2,children:l(M.Search,{})}),t.disabled&&(t.rightIcon=l(ee,{ssSphere:2,fontColor:"5.translucent",children:l(M.Ban,{})}))),t.rightIcon&&(t=S({paddingRight:3},t)),t.leftIcon&&(t=S({paddingLeft:3},t)),l(ce,{componentID:t.componentID,children:B.Core,states:de(t)})};export{te as Autocomplete,te as default};
|
package/dist/fn/Input/Select.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a,c,d as z}from"../../chunk-C5N2D3ZX.js";import{Fragment as $,jsx as l,jsxs as F}from"react/jsx-runtime";import v,{UUID as k}from"jmini";import{useState as A,useEffect as ne}from"react";import{ExtractStyles as xe}from"../../@utils";import{Box as I,Span as Ve,FAI as re,Column as Fe}from"../../atoms";import{Text as B,Row as se}from"../../mols";import{Button as we}from"../Button";import{Sheet as Re}from"../Sheet";import{OptionalInputWrapper as ke,BoxWrapper as Ae,CoreEffects as V,DefaultBoxishStyles as Ee}from"./core";import{InputAutocompleteClasses as E}from"../../@styles/componentClasses";import{InputLabel as Be}from"./Label";import{RightIcon as We}from".";function Le(e){let{value:t,states:o}=e,{required:r,options:n}=o,f=[];return r&&t===null&&f.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!f.filter(({type:p})=>p=="invalid").length,notice:f}}const H={FilterSelectableOptions:(e,t)=>{let o=e.rootStates.options;return t||(o=o.filter(r=>r.type!="label")),o}},h={Shallow:e=>{let{rootStates:t,val_status:o}=e,r=xe(t);return l(I,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:l(B.Description,c(a({className:t.className},r),{position:"absolute",width:1,freeCSS:c(a({},r.freeCSS),{color:"orange"}),children:l(I,{"data-input-value-shallow":o.componentID,children:"A"})}))})},Button:e=>F($,{children:[l(h.LegacySelector,a({},e)),l(h.Original,a({},e))]}),Placeholder:e=>!e.rootStates.placeholder||e.val_status.dataValue!==null?null:l(I,{position:"absolute",opacity:"middle",fontColor:"3.blur",children:e.rootStates.placeholder||""}),Original:e=>{let{rootStates:t,val_preventOpenSelectorOnFocus:o,set_preventOpenSelectorOnFocus:r,val_optionFocused:n,set_optionFocused:f,val_validate:p,set_validate:w,val_status:m,set_status:b,val_selectorOpen:S,set_selectorOpen:u}=e,U=t,{tone:R,required:D,form:W,className:L,label:ue,isLabelActive:ce,placeholder:pe,enableFormSubmit:P,emptySelect:j,checkValidationAtFirst:M,onValidate:Se,onUpdateValue:de,onUpdateValidValue:fe,value:N="",options:K,leftIndicator:me,rightIndicator:J,leftIcon:ve,rightIcon:ye,componentID:be,status_id:ge,wrapStyles:Ie,SelectedCellStyles:he,SelectorCellStyles:Ce,SelectorMode:_e,SelectorStyles:De,SelectorPosition:Oe}=U,s=z(U,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","wrapStyles","SelectedCellStyles","SelectorCellStyles","SelectorMode","SelectorStyles","SelectorPosition"]);return ne(()=>{if(e.rootStates.SelectorMode!="original"||t.disabled)return;let i="select-click-"+t.componentID;if(S){if(!v('[data-input-origin="'+t.componentID+'"]'))return;v(document).addEvent({eventID:i,eventType:"click",callback:d=>{let O=v(d.target),T=!!v(O).parent("."+E("Core")).length;v(O).parent("."+E("Selector")).length||T||u(!1)}})}else v(document).removeEvent([i])},[S]),ne(()=>{if(e.rootStates.SelectorMode!="original"||m.eventType=="init"||!S)return;let i=v('[data-input-origin="'+t.componentID+'"]');i&&i.focus()},[m.dataValue]),e.rootStates.SelectorMode!="original"?null:F($,{children:[l(I,c(a({tabIndex:0},s),{"data-disabled":t.disabled,"data-show-validation":V.isShowValidation(p,m,!!M),"data-component-id":m.componentID,"data-input-origin":m.componentID,className:[L,E("Core")].join(" "),onFocus:i=>{if(s!=null&&s.onFocus&&(s==null||s.onFocus(i)),!t.disabled){if(o)return r(!1);u(!0)}},onClick:i=>{s!=null&&s.onClick&&(s==null||s.onClick(i)),!t.disabled&&u(!0)},onKeyDown:i=>{let{key:g,metaKey:d,ctrlKey:O}=i,T=d||O;if(s!=null&&s.onKeyDown&&(s==null||s.onKeyDown(i)),P&&V.SubmitForm(i,W),!t.disabled){if(v.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(g))return;if(i.preventDefault(),!S)return u(!0);let C=g=="ArrowDown"?1:-1,y=H.FilterSelectableOptions(e),q=y.length-1,_=null;v.scope(()=>{var X,G,Q,Y,Z,ee,te,le,ae,oe;let x=y.findIndex(Te=>Te.value==n);if(C==1){if(_=(G=(X=y[0])==null?void 0:X.value)!=null?G:null,T){_=(Q=y[q].value)!=null?Q:null;return}if(x==-1||x==q)return;_=(Z=(Y=y[x+1])==null?void 0:Y.value)!=null?Z:null}else{if(_=(ee=y[q].value)!=null?ee:null,T){_=(le=(te=y[0])==null?void 0:te.value)!=null?le:null;return}if(x==-1||x==0)return;_=(oe=(ae=y[x-1])==null?void 0:ae.value)!=null?oe:null}}),f(_)}),g=="Escape")u(!1);else if(g=="Tab")u(!1);else if(g=="Backspace")b(C=>c(a({},C),{dataValue:null,eventType:"update",eventID:k()}));else if(g==" ")i.preventDefault(),u(!0);else if(g=="Enter"){if(!S)return u(!0);i.preventDefault();let C=t.options.find(y=>y.value==n);if(!C)return;b(y=>c(a({},y),{dataValue:C.value,eventType:"update",eventID:k()})),u(!1)}}},children:F(se.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(h.Placeholder,a({},e)),l(h.Selected,a({},e)),l(Ve,{width:0,overflow:"hidden",opacity:"trans",children:"A"})]})})),S&&l(h.Selector,a({},e))]})},LegacySelector:e=>{let{rootStates:t,val_preventOpenSelectorOnFocus:o,set_preventOpenSelectorOnFocus:r,val_optionFocused:n,set_optionFocused:f,val_validate:p,set_validate:w,val_status:m,set_status:b,val_selectorOpen:S,set_selectorOpen:u}=e,g=t,{tone:R,required:D,form:W,className:L,label:ue,isLabelActive:ce,placeholder:pe,enableFormSubmit:P,emptySelect:j,checkValidationAtFirst:M,onValidate:Se,onUpdateValue:de,onUpdateValidValue:fe,onKeyDown:N,onChange:K,value:me="",options:J,leftIndicator:ve,rightIndicator:ye,leftIcon:be,rightIcon:ge,componentID:Ie,status_id:he,wrapStyles:Ce,SelectedCellStyles:_e,SelectorCellStyles:De,SelectorMode:Oe,SelectorStyles:s,SelectorPosition:U}=g,i=z(g,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","onKeyDown","onChange","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","wrapStyles","SelectedCellStyles","SelectorCellStyles","SelectorMode","SelectorStyles","SelectorPosition"]);return e.rootStates.SelectorMode!="legacy"?null:F(I,c(a({htmlTag:"select",tabIndex:0},i),{"data-disabled":t.disabled,"data-show-validation":V.isShowValidation(p,m,!!M),"data-component-id":m.componentID,"data-input-origin":m.componentID,className:[L,E("Core")].join(" "),onKeyDown:d=>{N&&N(d),P&&V.SubmitForm(d,W)},onChange:d=>{let{value:O}=d.target;p.ok&&w({ok:!1,notice:[]}),b(T=>c(a({},T),{dataValue:O,eventType:"update",eventID:k()})),K&&K(d)},children:[!!j&&l("option",{value:"null",children:"\u9078\u629E"}),J.map(d=>v.is.nullish(d.value)?null:l("option",{value:d.value,children:d.label},String(d.value)))]}))},Selector:e=>{var f;let t=[],o=H.FilterSelectableOptions(e,!0),r=H.FilterSelectableOptions(e);o.forEach((p,w)=>{let{type:m,value:b}=p,S=e.val_optionFocused==b,u=e.val_status.dataValue===b;if(m=="selector"){t.push(l(we.Sub.S,c(a({color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1],isActive:u||S,isActiveStyles:S?{backgroundColor:"cloud"}:{backgroundColor:"theme.opa.few",fontColor:"theme"}},e.rootStates.SelectorCellStyles),{onClick:R=>{e.set_status(D=>c(a({},D),{dataValue:b,eventType:"update",eventID:k()})),e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0)},children:F(se.Left,{gap:"1/2",children:[u&&l(re.Check,{fontColor:"theme"}),l(B.Supplement,{transition:"short",flexSizing:0,children:p.label})]})}),String(b)));return}t.push(l(I,{children:p.label},k()))}),r.length||(t=[l(B.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]);let n={position:"absolute",minWidth:1,freeCSS:{zIndex:1e3}};switch(e.rootStates.SelectorPosition){case 1:n.bottom="100%",n.left=0,n.paddingBottom="1/3";break;case 2:n.bottom="100%",n.right=0,n.paddingBottom="1/3";break;case 3:n.top="100%",n.left=0,n.paddingTop="1/3";break;case 4:n.top="100%",n.right=0,n.paddingTop="1/3";break;default:break}return l(I,c(a({},n),{children:l(Re.Body,c(a({className:E("Selector"),ssCardBox:!0,borderRadius:"2.tone.secondary",boxShadow:"1.normal",overflow:"auto"},e.rootStates.SelectorStyles),{freeCSS:a({minWidth:12*6,maxHeight:12*24},(f=e.rootStates.SelectorStyles)==null?void 0:f.freeCSS),children:l(Fe,{gap:"1/12",padding:[1,0],children:t})}))}))},Selected:e=>{let t=[];return e.val_status.dataValue!==null&&v.scope(()=>{let o=e.rootStates.options.find(r=>v.is.equal(r.value,e.val_status.dataValue));o&&t.push(l(I,c(a({},e.rootStates.SelectedCellStyles),{children:o.label}),String(o.value)))}),l($,{children:t})},Core:e=>{var D;let{value:t}=e,[o,r]=A(V.DefaultStatus(e.componentID,t)),[n,f]=A(!1),[p,w]=A(!1),[m,b]=A((D=e.value)!=null?D:null),[S,u]=A({ok:!1,notice:[]}),R={rootStates:e,val_preventOpenSelectorOnFocus:n,set_preventOpenSelectorOnFocus:f,val_optionFocused:m,set_optionFocused:b,val_selectorOpen:p,set_selectorOpen:w,val_status:o,set_status:r,val_validate:S,set_validate:u};return V.CommonEffects({type:"select",states:e,val_status:o,set_status:r,val_validate:S,set_validate:u,SystemValidation:Le}),F(Ae,{val_status:o,set_status:r,val_validate:S,states:e,children:[l(Be,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:e.isLabelActive||o.dataValue!==null}),l(h.Shallow,a({},R)),l(h.Button,a({},R))]})}},ie=e=>{var o;let t=a({},e);return t=c(a({emptySelect:!0,SelectorMode:"original",SelectorPosition:3},t),{freeCSS:a({cursor:"pointer"},t.freeCSS)}),t.emptySelect&&(t.options=[{value:null,label:l(B.Supplement,{fontColor:"4.thin",children:"\u672A\u9078\u629E"})},...t.options]),t.value=(o=t.value)!=null?o:null,t.options.forEach((r,n)=>{let{type:f,value:p}=r;t.options[n]=c(a({},r),{value:p,type:f||"selector"})}),v.is.nullish(t.rightIcon)&&(t.rightIcon=l(We,{ssSphere:2,children:l(re.AngleDown,{})})),l(ke,{componentID:t.componentID,children:h.Core,states:Ee(t)})};export{ie as Select,ie as default};
|
|
1
|
+
import{b as a,c,d as z}from"../../chunk-C5N2D3ZX.js";import{Fragment as $,jsx as l,jsxs as F}from"react/jsx-runtime";import v,{UUID as k}from"jmini";import{useState as A,useEffect as ne}from"react";import{ExtractStyles as Te}from"../../@utils";import{Box as I,Span as xe,FAI as re,Column as Fe}from"../../atoms";import{Literal as B,Row as ie}from"../../mols";import{Button as we}from"../Button";import{Sheet as Re}from"../Sheet";import{OptionalInputWrapper as ke,BoxWrapper as Ae,CoreEffects as x,DefaultBoxishStyles as Ee}from"./core";import{InputAutocompleteClasses as E}from"../../@styles/componentClasses";import{InputLabel as Be}from"./Label";import{RightIcon as Le}from".";function We(e){let{value:t,states:o}=e,{required:r,options:n}=o,f=[];return r&&t===null&&f.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!f.filter(({type:p})=>p=="invalid").length,notice:f}}const H={FilterSelectableOptions:(e,t)=>{let o=e.rootStates.options;return t||(o=o.filter(r=>r.type!="label")),o}},h={Shallow:e=>{let{rootStates:t,val_status:o}=e,r=Te(t);return l(I,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:l(B.Description,c(a({className:t.className},r),{position:"absolute",width:1,freeCSS:c(a({},r.freeCSS),{color:"orange"}),children:l(I,{"data-input-value-shallow":o.componentID,children:"A"})}))})},Button:e=>F($,{children:[l(h.LegacySelector,a({},e)),l(h.Original,a({},e))]}),Placeholder:e=>!e.rootStates.placeholder||e.val_status.dataValue!==null?null:l(I,{position:"absolute",opacity:"middle",fontColor:"3.blur",children:e.rootStates.placeholder||""}),Original:e=>{let{rootStates:t,val_preventOpenSelectorOnFocus:o,set_preventOpenSelectorOnFocus:r,val_optionFocused:n,set_optionFocused:f,val_validate:p,set_validate:w,val_status:m,set_status:b,val_selectorOpen:S,set_selectorOpen:u}=e,U=t,{tone:R,required:D,form:L,className:W,label:ue,isLabelActive:ce,placeholder:pe,enableFormSubmit:P,emptySelect:j,checkValidationAtFirst:M,onValidate:Se,onUpdateValue:de,onUpdateValidValue:fe,value:N="",options:K,leftIndicator:me,rightIndicator:J,leftIcon:ve,rightIcon:ye,componentID:be,status_id:ge,wrapStyles:Ie,SelectedCellStyles:he,SelectorCellStyles:Ce,SelectorMode:_e,SelectorStyles:De,SelectorPosition:Oe}=U,i=z(U,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","wrapStyles","SelectedCellStyles","SelectorCellStyles","SelectorMode","SelectorStyles","SelectorPosition"]);return ne(()=>{if(e.rootStates.SelectorMode!="original"||t.disabled)return;let s="select-click-"+t.componentID;if(S){if(!v('[data-input-origin="'+t.componentID+'"]'))return;v(document).addEvent({eventID:s,eventType:"click",callback:d=>{let O=v(d.target),V=!!v(O).parent("."+E("Core")).length;v(O).parent("."+E("Selector")).length||V||u(!1)}})}else v(document).removeEvent([s])},[S]),ne(()=>{if(e.rootStates.SelectorMode!="original"||m.eventType=="init"||!S)return;let s=v('[data-input-origin="'+t.componentID+'"]');s&&s.focus()},[m.dataValue]),e.rootStates.SelectorMode!="original"?null:F($,{children:[l(I,c(a({tabIndex:0},i),{"data-disabled":t.disabled,"data-show-validation":x.isShowValidation(p,m,!!M),"data-component-id":m.componentID,"data-input-origin":m.componentID,className:[W,E("Core")].join(" "),onFocus:s=>{if(i!=null&&i.onFocus&&(i==null||i.onFocus(s)),!t.disabled){if(o)return r(!1);u(!0)}},onClick:s=>{i!=null&&i.onClick&&(i==null||i.onClick(s)),!t.disabled&&u(!0)},onKeyDown:s=>{let{key:g,metaKey:d,ctrlKey:O}=s,V=d||O;if(i!=null&&i.onKeyDown&&(i==null||i.onKeyDown(s)),P&&x.SubmitForm(s,L),!t.disabled){if(v.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(g))return;if(s.preventDefault(),!S)return u(!0);let C=g=="ArrowDown"?1:-1,y=H.FilterSelectableOptions(e),q=y.length-1,_=null;v.scope(()=>{var X,G,Q,Y,Z,ee,te,le,ae,oe;let T=y.findIndex(Ve=>Ve.value==n);if(C==1){if(_=(G=(X=y[0])==null?void 0:X.value)!=null?G:null,V){_=(Q=y[q].value)!=null?Q:null;return}if(T==-1||T==q)return;_=(Z=(Y=y[T+1])==null?void 0:Y.value)!=null?Z:null}else{if(_=(ee=y[q].value)!=null?ee:null,V){_=(le=(te=y[0])==null?void 0:te.value)!=null?le:null;return}if(T==-1||T==0)return;_=(oe=(ae=y[T-1])==null?void 0:ae.value)!=null?oe:null}}),f(_)}),g=="Escape")u(!1);else if(g=="Tab")u(!1);else if(g=="Backspace")b(C=>c(a({},C),{dataValue:null,eventType:"update",eventID:k()}));else if(g==" ")s.preventDefault(),u(!0);else if(g=="Enter"){if(!S)return u(!0);s.preventDefault();let C=t.options.find(y=>y.value==n);if(!C)return;b(y=>c(a({},y),{dataValue:C.value,eventType:"update",eventID:k()})),u(!1)}}},children:F(ie.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(h.Placeholder,a({},e)),l(h.Selected,a({},e)),l(xe,{width:0,overflow:"hidden",opacity:"trans",children:"A"})]})})),S&&l(h.Selector,a({},e))]})},LegacySelector:e=>{let{rootStates:t,val_preventOpenSelectorOnFocus:o,set_preventOpenSelectorOnFocus:r,val_optionFocused:n,set_optionFocused:f,val_validate:p,set_validate:w,val_status:m,set_status:b,val_selectorOpen:S,set_selectorOpen:u}=e,g=t,{tone:R,required:D,form:L,className:W,label:ue,isLabelActive:ce,placeholder:pe,enableFormSubmit:P,emptySelect:j,checkValidationAtFirst:M,onValidate:Se,onUpdateValue:de,onUpdateValidValue:fe,onKeyDown:N,onChange:K,value:me="",options:J,leftIndicator:ve,rightIndicator:ye,leftIcon:be,rightIcon:ge,componentID:Ie,status_id:he,wrapStyles:Ce,SelectedCellStyles:_e,SelectorCellStyles:De,SelectorMode:Oe,SelectorStyles:i,SelectorPosition:U}=g,s=z(g,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","onKeyDown","onChange","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","wrapStyles","SelectedCellStyles","SelectorCellStyles","SelectorMode","SelectorStyles","SelectorPosition"]);return e.rootStates.SelectorMode!="legacy"?null:F(I,c(a({htmlTag:"select",tabIndex:0},s),{"data-disabled":t.disabled,"data-show-validation":x.isShowValidation(p,m,!!M),"data-component-id":m.componentID,"data-input-origin":m.componentID,className:[W,E("Core")].join(" "),onKeyDown:d=>{N&&N(d),P&&x.SubmitForm(d,L)},onChange:d=>{let{value:O}=d.target;p.ok&&w({ok:!1,notice:[]}),b(V=>c(a({},V),{dataValue:O,eventType:"update",eventID:k()})),K&&K(d)},children:[!!j&&l("option",{value:"null",children:"\u9078\u629E"}),J.map(d=>v.is.nullish(d.value)?null:l("option",{value:d.value,children:d.label},String(d.value)))]}))},Selector:e=>{var f;let t=[],o=H.FilterSelectableOptions(e,!0),r=H.FilterSelectableOptions(e);o.forEach((p,w)=>{let{type:m,value:b}=p,S=e.val_optionFocused==b,u=e.val_status.dataValue===b;if(m=="selector"){t.push(l(we.Sub.S,c(a({color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1],isActive:u||S,isActiveStyles:S?{backgroundColor:"cloud"}:{backgroundColor:"theme.opa.few",fontColor:"theme"}},e.rootStates.SelectorCellStyles),{onClick:R=>{e.set_status(D=>c(a({},D),{dataValue:b,eventType:"update",eventID:k()})),e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0)},children:F(ie.Left,{gap:"1/2",children:[u&&l(re.Check,{fontColor:"theme"}),l(B.Supplement,{transition:"short",flexSizing:0,children:p.label})]})}),String(b)));return}t.push(l(I,{children:p.label},k()))}),r.length||(t=[l(B.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]);let n={position:"absolute",minWidth:1,freeCSS:{zIndex:1e3}};switch(e.rootStates.SelectorPosition){case 1:n.bottom="100%",n.left=0,n.paddingBottom="1/3";break;case 2:n.bottom="100%",n.right=0,n.paddingBottom="1/3";break;case 3:n.top="100%",n.left=0,n.paddingTop="1/3";break;case 4:n.top="100%",n.right=0,n.paddingTop="1/3";break;default:break}return l(I,c(a({},n),{children:l(Re.Body,c(a({className:E("Selector"),ssCardBox:!0,borderRadius:"2.tone.secondary",boxShadow:"1.normal",overflow:"auto"},e.rootStates.SelectorStyles),{freeCSS:a({minWidth:12*6,maxHeight:12*24},(f=e.rootStates.SelectorStyles)==null?void 0:f.freeCSS),children:l(Fe,{gap:"1/12",padding:[1,0],children:t})}))}))},Selected:e=>{let t=[];return e.val_status.dataValue!==null&&v.scope(()=>{let o=e.rootStates.options.find(r=>v.is.equal(r.value,e.val_status.dataValue));o&&t.push(l(I,c(a({},e.rootStates.SelectedCellStyles),{children:o.label}),String(o.value)))}),l($,{children:t})},Core:e=>{var D;let{value:t}=e,[o,r]=A(x.DefaultStatus(e.componentID,t)),[n,f]=A(!1),[p,w]=A(!1),[m,b]=A((D=e.value)!=null?D:null),[S,u]=A({ok:!1,notice:[]}),R={rootStates:e,val_preventOpenSelectorOnFocus:n,set_preventOpenSelectorOnFocus:f,val_optionFocused:m,set_optionFocused:b,val_selectorOpen:p,set_selectorOpen:w,val_status:o,set_status:r,val_validate:S,set_validate:u};return x.CommonEffects({type:"select",states:e,val_status:o,set_status:r,val_validate:S,set_validate:u,SystemValidation:We}),F(Ae,{val_status:o,set_status:r,val_validate:S,states:e,children:[l(Be,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:e.isLabelActive||o.dataValue!==null}),l(h.Shallow,a({},R)),l(h.Button,a({},R))]})}},se=e=>{var o;let t=a({},e);return t=c(a({emptySelect:!0,SelectorMode:"original",SelectorPosition:3},t),{freeCSS:a({cursor:"pointer"},t.freeCSS)}),t.emptySelect&&(t.options=[{value:null,label:l(B.Supplement,{fontColor:"4.thin",children:"\u672A\u9078\u629E"})},...t.options]),t.value=(o=t.value)!=null?o:null,t.options.forEach((r,n)=>{let{type:f,value:p}=r;t.options[n]=c(a({},r),{value:p,type:f||"selector"})}),v.is.nullish(t.rightIcon)&&(t.rightIcon=l(Le,{ssSphere:2,children:l(re.AngleDown,{})})),l(ke,{componentID:t.componentID,children:h.Core,states:Ee(t)})};export{se as Select,se as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{b as l,c as m,d as Y,e as te}from"../../chunk-C5N2D3ZX.js";import{Fragment as le,jsx as n,jsxs as K}from"react/jsx-runtime";import b,{UUID as
|
|
1
|
+
import{b as l,c as m,d as Y,e as te}from"../../chunk-C5N2D3ZX.js";import{Fragment as le,jsx as n,jsxs as K}from"react/jsx-runtime";import b,{UUID as M,useStore as Ie}from"jmini";import{useState as Z,useEffect as G}from"react";import{$$fromRoot as ve,ExtractStyles as Ce}from"../../@utils";import{Box as F,FAI as Te}from"../../atoms";import{Literal as X}from"../../mols";import{Tips as ae,Button as we}from"..";import{faEye as Re}from"@fortawesome/free-solid-svg-icons/faEye";import{OptionalInputWrapper as ye,BoxWrapper as Ve,CoreEffects as U,DefaultBoxishStyles as De}from"./core";import{InputLabel as ke}from"./Label";import{LeftIcon as Ne,RightIcon as ie}from".";const Fe={katakana:{reg:/^[ァ-ヶー ヲ-゚ ]*$/g,exist:!0,reason:"\u30AB\u30BF\u30AB\u30CA\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},"hankaku.katakana":{reg:/^[ヲ-゚ ]*$/g,exist:!0,reason:"\u534A\u89D2\u30AB\u30BF\u30AB\u30CA\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},number:{reg:/^-?[0-9\.]{0,}[0-9]{1,}$/g,exist:!0,reason:"\u534A\u89D2\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},digitNumber:{reg:/^-?[0-9\,\.]{0,}[0-9]{1,}$/g,exist:!0,reason:"\u534A\u89D2\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},fileName:{reg:/[¥\/:*\?\"\'\|\.\s\n\r\<\>]/g,exist:!1,reason:"\u7A7A\u767D\u307E\u305F\u306F\u4E00\u90E8\u306E\u7279\u6B8A\u6587\u5B57\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093"},creditCard:{reg:/^\d{14,16}$/g,exist:!0,reason:"14~16\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},email:{reg:/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]+\.[A-Za-z0-9]+$/,exist:!0,reason:K(le,{children:[n(F,{children:"\u25CB\u25CB\u25CB\u25CB@\u25CB\u25CB\u25CB\u25CB.\u25CB\u25CB\u25CB\u306E\u5F62\u5F0F\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),n(F,{children:"\u6700\u5F8C\u306E\u6587\u5B57\u306B.(\u30C9\u30C3\u30C8)\u3092\u5165\u308C\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"})]})},password:{reg:/^(?=[^A-Z]*[A-Z])(?=[^a-z]*[a-z])(?=[^0-9]*[0-9]).{8,}$/,exist:!0,reason:"8\u6587\u5B57\u4EE5\u4E0A\u3001\u534A\u89D2\u82F1\u6570\u5927\u5C0F\u6587\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},tel:{reg:/.*$/g,exist:!0,reason:K(le,{children:[n(F,{children:"0\u304B\u3089\u59CB\u307E\u308B\u756A\u53F7\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"}),n(F,{children:"9~12\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),n(F,{children:"\u6570\u5B57\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"})]})},url:{reg:/^https?:\/\/[^\n\s]+(\.|\:)[^\n\s\.\:]+$/,exist:!0,reason:"URL\u5F62\u5F0F : http(s)://\u25EF\u25EF\u25EF\u25EF"},postal:{reg:/^\d{7}$/g,exist:!0,reason:"7\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}},R={setSelection:e=>{let{id:a,restrict:o,val_status:r}=e,i=ve("#"+a)[0];if(i&&r.prevValue&&r.formatValue){let{formatValue:t,prevValue:d,caretFrom:u,caretTo:s}=r;if(o=="creditCard")t.length>=d.length&&u%5==0&&(u++,s++),i.setSelectionRange(u,s);else if(o=="postal")t.length==5&&d.length==3&&(u++,s++),i.setSelectionRange(u,s);else if(o=="digitNumber"){let g=t.length-d.length;g==2&&(u++,s++),g==-2&&(u--,s--),i.setSelectionRange(u,s)}}},Validation:{System:e=>{let{value:a,states:o}=e,{restrict:r="text",maxLength:i,multiline:t,required:d}=o,u=[];if(t||(i=i||255),b.is.exist(i)&&a.length>=Number(i)&&u.push({type:"invalid",label:i+"\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),a){let s=R.Validation.Text(a,r);s.ok||u.push({type:"invalid",label:s.body})}else d&&u.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"});return{ok:!u.filter(({type:s})=>s=="invalid").length,notice:u}},Text:(e,a)=>{let o={ok:!0,body:""};return(()=>{let r=Fe[a];if(!r)return;let i=r.reason;if(r){let t=!!(+!!e.match(r.reg)^+!r.exist);o={ok:t,body:t?"":i}}})(),o},DataLeveling:e=>{let{restrict:a,allowDecimals:o,allowZeroStart:r,value:i=""}=e,t=String(i);["tel","number","digitNumber","test","postal","creditCard"].includes(a)&&(t=t.zen2hanNumber()),a=="katakana",a=="hankaku.katakana",["postal","creditCard"].includes(a)&&(t=t.removeLetters()),b.scope(()=>{if(!["number","digitNumber"].includes(a))return;t=t.replace(/(\.\d+)\..*/g,"$1").replace(/\.+/g,".").replace(/[^0-9.-]/g,"");let u=Number(t)<0||t[0]=="-";t=t.replace(/[^0-9.]/g,""),u&&(t="-"+t),o||(t=t.replace(/\.\d?/g,"")),b.scope(()=>{a=="number"&&(r||(t=t.replace(/^0(\d+)/g,"$1").replace(/^-0(\d+)/g,"-$1")))}),b.scope(()=>{let s=t.slice(-1);t&&s!="."&&s!="-"&&(b.is.exist(e.min)&&(t=String(Math.max(Number(t),Number(e.min)))),b.is.exist(e.max)&&(t=String(Math.min(Number(t),Number(e.max)))))}),b.scope(()=>{if(!t||t=="-"||a!="digitNumber")return;let s=Number(t)<0,g=String(Math.abs(Math.round(Number(t)))),C=t.split("."),V=[];for(let f=g.length-1;f>=0;f--){V.unshift(g[f]);let c=g.length-1-f+1;f!=0&&c%3==0&&V.unshift(",")}t=V.join(""),s&&(t="-"+t),(C==null?void 0:C.length)==2&&(t+="."+C[1]||"")})});let d=t;return a=="digitNumber"||(a=="postal"?t.length>=4&&(d=t.clip(0,3)+"-"+t.clip(3)):a=="creditCard"&&(d=t.replace(/.{4}(?=.)/g,"$& "))),t=t.replace(/,/g,""),{formatValue:d,dataValue:t}}},Shallow:e=>{let{rootStates:a,val_status:o}=e,r=o.dataValue||"";G(()=>{b.scope(()=>te(void 0,null,function*(){if(!a.multiline)return;let g=b('[data-input-origin="'+o.componentID+'"]'),C=b('[data-input-shallow="'+o.componentID+'"]'),V=b('[data-input-min-height-value-shallow="'+o.componentID+'"]'),f=b('[data-input-max-height-value-shallow="'+o.componentID+'"]');if(!g[0]||!C[0]||!V[0]||!f[0])return;let c=C.position(),_=V.position(),L=f.position(),S=0;a.autoHeight&&(S=c.height),S=Math.max(S,_.height),S=Math.min(S,L.height),g[0].style.height=S+"px"}))},[r]);let i=r||"";(!!r.match(/\n$/)||!r)&&(i+="T");let d="",u="";if(a.multiline){let g=a.minRows||1,C=a.maxRows||100;d=`
|
|
2
2
|
T`.repeat(g-1),u=`
|
|
3
|
-
T`.repeat(
|
|
3
|
+
T`.repeat(C-1)}let s=Ce(a);return K(F,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:[n(X.Description,m(l({className:a.className},s),{position:"absolute",width:1,freeCSS:m(l({},s.freeCSS),{color:"orange"}),"data-input-shallow":o.componentID,children:n(F,{"data-input-value-shallow":o.componentID,children:i})})),n(X.Description,m(l({className:a.className},s),{position:"absolute",left:0,freeCSS:m(l({},s.freeCSS),{backgroundColor:"transparent",color:"blue"}),"data-input-min-height-value-shallow":o.componentID,children:d})),n(X.Description,m(l({className:a.className},s),{position:"absolute",right:0,freeCSS:m(l({},s.freeCSS),{backgroundColor:"transparent",color:"red"}),"data-input-max-height-value-shallow":o.componentID,children:u}))]})},InputBox:e=>{let{rootStates:a,val_validate:o,set_validate:r,val_status:i,set_status:t,val_focus:d,set_focus:u,val_isComposing:s,set_isComposing:g}=e;if(a.multiline)return null;let ee=a,{componentID:C,tone:V,required:f,restrict:c="text",form:_,autoComplete:L="off",autoCapitalize:S="off",minRows:ne,maxRows:oe,multiline:re,autoHeight:se,enableFormSubmit:W,clearButton:ue=!1,allowDecimals:$,allowZeroStart:H,checkValidationAtFirst:P,onChange:O,onKeyDown:q,onValidate:me,onUpdateValue:ce,onUpdateValidValue:pe,value:de="",leftIndicator:fe,rightIndicator:ge,leftIcon:he,rightIcon:I,maxLength:xe,min:B,max:T,label:j,isLabelActive:Q,wrapStyles:Ee}=ee,p=Y(ee,["componentID","tone","required","restrict","form","autoComplete","autoCapitalize","minRows","maxRows","multiline","autoHeight","enableFormSubmit","clearButton","allowDecimals","allowZeroStart","checkValidationAtFirst","onChange","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","maxLength","min","max","label","isLabelActive","wrapStyles"]),be=c=="password"||c=="concealed"?"password":"text",Se=["number","digitNumber","creditCard"].includes(c)?"numeric":c=="email"?"email":"text";return n(F,m(l({htmlTag:"input",type:be,inputMode:Se,"data-disabled":a.disabled,"data-show-validation":U.isShowValidation(o,i,!!P),"data-component-id":i.componentID,"data-input-origin":i.componentID,value:i.formatValue,autoComplete:L,autoCapitalize:S,onKeyDown:h=>{let{key:w,target:E}=h;{let D=E,{selectionStart:k,selectionEnd:v}=D,A=Number(k),z=Number(v),N=i.formatValue[Number(A)],J=i.formatValue[Number(A)-1];w=="Delete"&&(c=="creditCard"&&N==" "||c=="postal"&&N=="-"||c=="digitNumber"&&N==",")&&(D.setSelectionRange(A+1,z+1),h.preventDefault()),w=="Backspace"&&(c=="creditCard"&&J==" "||c=="postal"&&J=="-"||c=="digitNumber"&&J==",")&&(D.setSelectionRange(A-1,z-1),h.preventDefault()),w=="Enter"||w=="Tab"}b.scope(()=>{["number","digitNumber","creditCard"].includes(c)&&w=="Clear"&&t(D=>m(l({},D),{dataValue:"",formatValue:"",eventType:"update",eventID:M()}))}),b.scope(()=>{var z;if(!["number","digitNumber"].includes(c)||!["ArrowUp","ArrowDown"].includes(w))return;let D=+(w=="ArrowUp")*2-1,k=i.dataValue.slice(-1),v=i.dataValue,A=((z=i.dataValue.split(".")[1])==null?void 0:z.length)||0;if(!k)v+="0";else if(k=="-")v+="0";else if(k==".")v+="0";else if(A){let N=Number(k)+D;v=v.slice(0,-1),N<0?v+="9":N>9?v+="0":v+=String(N)}else v=String(Number(i.dataValue.replace(/,/g,""))+D);o.ok&&r({ok:!1,notice:[]}),t(N=>m(l(l({},N),R.Validation.DataLeveling({allowDecimals:$,allowZeroStart:H,min:B,max:T,restrict:c,value:v})),{eventType:"update",eventID:M()})),h.preventDefault()}),q&&q(h),W&&U.SubmitForm(h,_)},onChange:h=>{let{value:w,selectionStart:E,selectionEnd:D}=h.target,k=R.Validation.DataLeveling({allowDecimals:$,allowZeroStart:H,min:B,max:T,restrict:c,value:w});s&&(k.formatValue=w),k.formatValue!=i.formatValue&&(o.ok&&r({ok:!1,notice:[]}),t(v=>m(l(l({},v),k),{prevValue:i.formatValue,eventType:"update",eventID:M(),caretFrom:Number(E),caretTo:Number(D)})),O&&O(h))},width:1},p),{onFocus:h=>{p!=null&&p.onFocus&&(p==null||p.onFocus(h)),u(!0)},onBlur:h=>{p!=null&&p.onBlur&&(p==null||p.onBlur(h)),u(!1)},onCompositionStart:h=>{p!=null&&p.onCompositionStart&&(p==null||p.onCompositionStart(h)),g(!0)},onCompositionEnd:h=>{if(p!=null&&p.onCompositionEnd&&(p==null||p.onCompositionEnd(h)),c=="text")return;let w=R.Validation.DataLeveling({allowDecimals:$,allowZeroStart:H,min:B,max:T,restrict:c,value:i.formatValue});t(E=>m(l(l({},E),w),{prevValue:E.formatValue,eventType:"update",eventID:M(),caretFrom:Number(E.formatValue.length+1),caretTo:Number(E.formatValue.length+1)})),g(!1)}}))},TextAreaBox:e=>{let{rootStates:a,val_focus:o,set_focus:r,val_validate:i,set_validate:t,val_status:d,set_status:u,isShallow:s}=e,B=a,{componentID:g,tone:C,required:V,form:f,label:c,isLabelActive:_,minRows:L,maxRows:S,multiline:ne,autoHeight:oe,allowDecimals:re,allowZeroStart:se,enableFormSubmit:W,maxLength:ue,checkValidationAtFirst:$,onChange:H,onKeyDown:P,onValidate:O,onUpdateValue:q,onUpdateValidValue:me,value:ce="",leftIndicator:pe,rightIndicator:de,leftIcon:fe,rightIcon:ge,wrapStyles:he}=B,I=Y(B,["componentID","tone","required","form","label","isLabelActive","minRows","maxRows","multiline","autoHeight","allowDecimals","allowZeroStart","enableFormSubmit","maxLength","checkValidationAtFirst","onChange","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","wrapStyles"]);return!a.multiline?null:n(F,m(l({htmlTag:"textarea","data-show-validation":U.isShowValidation(i,d,!!$),"data-input-origin":d.componentID,"data-component-id":d.componentID,value:d.dataValue,width:1},I),{onFocus:T=>{I!=null&&I.onFocus&&(I==null||I.onFocus(T)),r(!0)},onBlur:T=>{I!=null&&I.onBlur&&(I==null||I.onBlur(T)),r(!1)},onKeyDown:T=>{P&&P(T),W&&U.SubmitForm(T,f)},onChange:T=>{let{value:j}=T.target;i.ok&&t({ok:!1,notice:[]}),u(Q=>m(l({},Q),{dataValue:j,eventType:"update",eventID:M()})),H&&H(T)}}))}},_e=e=>{let{componentID:a,restrict:o="text",value:r="",min:i,max:t,allowDecimals:d,allowZeroStart:u}=e,[s,g]=Z(!1),[C,V]=Z(!1),[f,c]=Z(m(l({componentID:a},R.Validation.DataLeveling({allowDecimals:d,allowZeroStart:u,min:i,max:t,restrict:o,value:r})),{prevValue:"",eventType:"init",eventID:M(),caretFrom:null,caretTo:null})),[_,L]=Z({ok:!1,notice:[]}),S={rootStates:e,val_focus:s,set_focus:g,val_isComposing:C,set_isComposing:V,val_status:f,set_status:c,val_validate:_,set_validate:L};return U.CommonEffects({type:"textfield",states:e,val_status:f,set_status:c,val_validate:_,set_validate:L,SystemValidation:R.Validation.System,ExtraOverrideStates:l({},R.Validation.DataLeveling({allowDecimals:d,allowZeroStart:u,min:i,max:t,restrict:o,value:r}))}),G(()=>{R.setSelection({id:e.id,restrict:o,val_status:f})},[f]),K(Ve,{val_status:f,set_status:c,val_validate:_,states:S.rootStates,children:[n(ke,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:e.isLabelActive||s||!!f.dataValue}),n(R.Shallow,l({},S)),n(R.InputBox,l({},S)),n(R.TextAreaBox,l({},S))]})},y=e=>(e=l({autoHeight:!0,restrict:"text",fontSize:"inherit"},e),e.multiline?(e.minRows=e.minRows||5,e.maxRows=e.maxRows||20):(e.minRows=1,e.maxRows=1),n(ye,{componentID:e.componentID,children:_e,states:De(e)})),x=y;x.Validate=R.Validation.Text,x.Katakana=e=>n(y,m(l({},e),{restrict:"katakana",multiline:!1,autoHeight:!1})),x.HankakuKatakana=e=>n(y,m(l({},e),{restrict:"hankaku.katakana",multiline:!1,autoHeight:!1})),x.CreditCard=e=>n(y,m(l({},e),{restrict:"creditCard",multiline:!1,autoHeight:!1})),x.Tel=e=>n(y,m(l({},e),{restrict:"tel",multiline:!1,autoHeight:!1})),x.Number=e=>n(y,m(l({},e),{restrict:"number",multiline:!1,autoHeight:!1})),x.DigitNumber=e=>n(y,m(l({},e),{restrict:"digitNumber",multiline:!1,autoHeight:!1})),x.Email=e=>n(y,m(l({},e),{restrict:"email",multiline:!1,autoHeight:!1})),x.Url=e=>n(y,m(l({},e),{restrict:"url",multiline:!1,autoHeight:!1})),x.Postal=e=>{let[a]=Z(M());return G(()=>()=>{Ie.delete(a)},[]),n(y,m(l({label:"\u90F5\u4FBF\u756A\u53F7"},e),{restrict:"postal",multiline:!1,autoHeight:!1,leftIcon:n(Ne,{ssSphere:2,fontColor:"4.thin",children:"\u3012"})}))},x.Password=e=>n(y,m(l({label:"\u30D1\u30B9\u30EF\u30FC\u30C9",rightIcon:n(ie,{ssSphere:2,padding:0,freeCSS:{pointerEvents:"all"},children:n(we.Sub,{ssSphere:2,borderRadius:"3.tone.tertiary",fontColor:"theme",flexCenter:!0,height:1,ssEffectsOnActive:["expand"],onMouseOver:a=>{ae.open(a.currentTarget,"\u30C6\u30AD\u30B9\u30C8\u3092\u8868\u793A",24)},onMouseLeave:ae.abort,tabIndex:-1,onClick:a=>{b(a.target).parent().parent().find("input").callback(o=>{let r=o[0];r.type=r.type==="password"?"text":"password"})},children:n(Te,{icon:Re})})}),restrict:"password"},e),{multiline:!1,autoHeight:!1})),x.Concealed=e=>n(x.Password,m(l({label:"\u79D8\u5BC6\u9375"},e),{restrict:"concealed"})),x.Money={JPY:e=>n(x.DigitNumber,m(l({rightIcon:n(ie,{ssSphere:2,fontColor:"4.thin",children:"\u5186"})},e),{multiline:!1,autoHeight:!1}))};export{x as TextField,_e as TextInput,x as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as p,c as x}from"../../../chunk-C5N2D3ZX.js";import{Fragment as q,jsx as a,jsxs as f}from"react/jsx-runtime";import{createElement as X}from"react";import D,{UUID as O,Time as S}from"jmini";import{useState as A,useEffect as F,useRef as H}from"react";import{Box as k,Flex as w,Grid as W,FAI as T,Column as V}from"../../../atoms";import{Row as N,Text as G}from"../../../mols";import{Button as C}from"../../Button";import $ from"../../Sheet";import M from"../Select";import{Radio as j}from"../List";import{RightIcon as B}from"..";import{InputTimeClasses as y}from"../../../@styles/componentClasses";let _=i=>{var t,r;let e=[],d=Number((t=i==null?void 0:i.min)!=null?t:1900),o=Number((r=i==null?void 0:i.max)!=null?r:S().addYear(10).year);for(let m=d;m<=o;m++)e.unshift({value:m,label:[m,...D.transformer.wareki(m).value].join(" -")});return e};const L=i=>{let{restrict:e,era:d="year",defaultValue:o=""}=i;i=p({},i),i.sheetID=i.sheetID||O();const t=H(!1);let[r,m]=A((()=>{var n,s;if(e=="clock"){let l=String(o).split(/[^\d]/);l[0]||(l=[0,0]);let u=Number(l[0]),c=Number(l[1]);return{modifiedType:"init",hour:u,minutes:c}}else if(e=="date"){let[l,u,c]=(n=String(o))==null?void 0:n.split(/\D/);return(D.is.nullish(l)||D.is.nullish(u)||D.is.nullish(c))&&([l,u,c]=S().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",year:Number(l),month:Number(u),date:Number(c)}}else if(e!="week"){if(e=="month"){let[l,u]=String(o).split(/\D/);return(D.is.nullish(l)||D.is.nullish(u))&&([l,u]=S().toFormat("%Y-%M").split("-")),{modifiedType:"init",year:Number(l),month:Number(u)}}else if(e=="year"){let[l]=String(o).split(/\D/);return D.is.nullish(l)&&([l]=S().toFormat("%Y").split("-")),{modifiedType:"init",year:Number(l)}}else if(e=="dateWareki"){let[l,u,c]=(s=String(o))==null?void 0:s.split(/\D/);return(D.is.nullish(l)||D.is.nullish(u)||D.is.nullish(c))&&([l,u,c]=S().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",era:d||"year",year:Number(l),month:Number(u),date:Number(c)}}}return{}})());F(()=>{if(t.current){if(r.modifiedType=="update"){let n="",s=d||"year";if(e=="clock"){let{hour:l,minutes:u}=r;n=[l.zeroEmbed(2),u.zeroEmbed(2)].join("/")}else if(e=="date"){let{year:l,month:u,date:c}=r;n=[l,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}else if(e!="week"){if(e=="month"){let{year:l,month:u}=r;n=[l,u.zeroEmbed(2)].join("/")}else if(e=="year"){let{year:l}=r;n=String(l)}else if(e=="dateWareki"){let{year:l,month:u,date:c,era:v}=r;s=v,n=[l,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}}i.onValueUpdate(n,s)}}else t.current=!0},[r]);let h=x(p({},i),{val_value:r,set_value:m});return a(k,{backgroundColor:"layer.1",borderRadius:"2.tone.secondary",boxShadow:"1.remark",children:a(k,{className:y(e.toCapital()+"Base"),children:e=="clock"?a(g.Clock.index,p({},h)):e=="date"?a(g.Date.index,p({},h)):e=="week"?"":e=="month"?a(g.Month.index,p({},h)):e=="year"?a(g.Year.index,p({},h)):e=="dates"||e=="months"?"":e=="dateWareki"?a(g.DateWareki.index,p({},h)):a(q,{})})})},g={Clock:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,[h,n]=A(r.hour>12?2:1),[s,l]=A(Number(localStorage.getItem("timePickerUnit")||5));F(()=>{localStorage.setItem("timePickerUnit",String(s))},[s]);let{hour:u,minutes:c}=r;return f(V,{padding:1,children:[f(w,{flexType:"row",flexWrap:!1,gap:1,className:y("Body"),children:[f(V,{className:y("DesignSide"),flexSizing:0,children:[a(k,{className:y("ClockUiBase"),padding:[1,"2/3"],flexCenter:!0,children:f(k,{className:y("ClockUi"),backgroundColor:"theme.opa.low",isRounded:!0,position:"relative",children:[a(k,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[y("Needle"),y("hour")].join(" "),freeCSS:{transform:`rotate(${u*30+c/2}deg)`}}),a(k,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[y("Needle"),y("minute")].join(" "),freeCSS:{transform:`rotate(${c*6}deg)`}})]})}),a(j,{icon:!0,value:[h],options:[{value:1,label:"AM"},{value:2,label:"PM"}],flexType:"col",gap:"1/2",tabIndex:-1,onUpdateValidValue:v=>{let I=r.hour%12+(v==2?12:0);n(v),m({modifiedType:"update",hour:I,minutes:r.minutes})}}),a(k,{borderTop:!0,margin:[0,1]}),a(j,{icon:!0,value:[s],options:[{value:1,label:"/ 1\u5206"},{value:2,label:"/ 2\u5206"},{value:5,label:"/ 5\u5206"}],flexType:"col",gap:"1/2",tabIndex:-1,onUpdateValidValue:v=>{l(v)}})]}),f(V,{children:[f(k,{flexCenter:!0,isSemiBoldFont:!0,fontSize:"3.paragraph",children:[r.hour.zeroEmbed(2)," : ",r.minutes.zeroEmbed(2)]}),f(w,{flexWrap:!1,ssCardBox:!0,flexChilds:"even",padding:["1/3",0],freeCSS:{minWidth:12*12},children:[a(V,{gap:0,overflow:"auto",padding:"2/3",borderRight:!0,freeCSS:{maxHeight:12*22},children:g.Clock.Hours({onClick:v=>{let R=v+(h==2?12:0);m({modifiedType:"update",hour:R,minutes:r.minutes})},min:e,max:d,ampm:h})}),a(V,{gap:0,overflow:"auto",padding:"2/3",freeCSS:{maxHeight:12*22},children:g.Clock.Minutes({onClick:v=>{m({modifiedType:"update",hour:r.hour,minutes:v})},min:e,max:d,unit:s})})]})]})]}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},Hours:i=>{let e=[];for(let d=0;d<12;d++){let o=i.ampm==2?d+12:d,t=!1;{let r=Number(String(o*100).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>r&&(t=!0),i.max){let m=Number(String(i.max).replace(/\D/ig,""));r>m&&(t=!0)}}e.push(a(C.Normal,{isLocked:t,borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(d)},children:o.zeroEmbed(2)},d))}return e},Minutes:i=>{let e=[];for(let d=0;d<60/i.unit;d++){let o=d*i.unit;e.push(a(C.Normal,{borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(o)},children:o.zeroEmbed(2)},o))}return e}},Date:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h,month:n,date:s}=r;return f(V,{padding:1,children:[f(N.Separate,{flexWrap:!0,children:[f(w,{verticalAlign:"bottom",horizontalAlign:"left",gap:"2/3",flexWrap:!1,children:[a(M,{override:"force",emptySelect:!1,value:h,options:_(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,SelectorStyles:{freeCSS:{minWidth:12*12}},onUpdateValidValue:l=>{m({modifiedType:"update",year:Number(l),month:n,date:s})},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})})}),a(M,{override:"force",emptySelect:!1,value:n,options:(()=>{let l=[];for(let u=1;u<=12;u++)l.push({value:u,label:String(u)+"\u6708"});return l})(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,SelectorStyles:{freeCSS:{minWidth:12*8}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),onUpdateValidValue:l=>{m({modifiedType:"update",year:h,month:Number(l),date:s})}})]}),a(g.Variables.ShiftButtons,{callback:l=>{let u=n+l,c=h;u<=0&&(c--,u=12),u>12&&(c++,u=1),m({modifiedType:"update",year:c,month:u,date:r.date})}})]}),a(k,{borderTop:!0}),a(k,{children:g.Date.MonthCalendar({min:e,max:d,year:r.year,month:r.month,current:[r.year,r.month,r.date],callback:l=>{let[u,c,v]=l;m({modifiedType:"update",year:u,month:c,date:v})}})}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},MonthCalendar:i=>{let{min:e,max:d,year:o,month:t,current:r,callback:m}=i,h=S(),n=S([o,t.zeroEmbed(2),"01"].join("/")),s=n.getLastDayOfTheMonth(),l=S(n).addMonth(-1).getLastDayOfTheMonth().date,u=[],c=[],v=[],R=[],I={padding:0,unitWidth:3,unitHeight:3,flexCenter:!0,borderRadius:"3.tone.tertiary"};for(var b=0;b<7;b++)u.push(a(k,x(p({className:[y("CalendarDay"),y("Legend")].join(" ")},I),{children:["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][b]}),b));for(var b=0;b<n.weekday;b++)c.unshift(X(k,x(p({className:[y("CalendarDay"),y("Dummy")].join(" "),fontColor:"4.thin"},I),{key:b}),l-b));for(var b=1;b<=s.date;b++){let E=b,Y=o==h.year&&t==h.month&&b==h.date,P=!1;{let z=Number(String([o,t.zeroEmbed(2),b.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>z&&(P=!0),i.max){let U=Number(String(i.max).replace(/\D/ig,""));z>U&&(P=!0)}}v.push(a(C.Clear,x(p({className:[y("CalendarDay"),y("isToday_"+Y)].join(" ")},I),{fontColor:"1.clear",padding:0,flexCenter:!0,isRounded:!0,ssEffectsOnActive:"shrink",onClick:()=>{m([o,t,E])},tabIndex:-1,isLocked:P,children:b}),E))}for(var b=1;b<7-s.weekday;b++)R.push(a(k,x(p({className:[y("CalendarDay"),y("Dummy")].join(" "),fontColor:"4.thin"},I),{children:b}),b));return f(W,{gridCols:7,gap:"1/6",children:[u,c,v,R]})}},Month:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h,month:n}=r;return f(V,{padding:1,children:[f(N.Separate,{gap:0,children:[a(N.Center,{verticalAlign:"bottom",gap:"2/3",children:a(M,{emptySelect:!1,value:h,options:_(),override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,SelectorStyles:{freeCSS:{minWidth:12*12}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),onUpdateValidValue:s=>{m({modifiedType:"update",year:Number(s),month:n})}})}),a(g.Variables.ShiftButtons,{callback:s=>{let l=Math.min(Math.max(h+s,1900),2100);m({modifiedType:"update",year:l,month:n})}})]}),a(k,{borderTop:!0}),g.Month.Months({min:e,max:d,year:r.year,callback:s=>{let[l,u]=s;m({modifiedType:"update",year:l,month:u})}}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},Months:i=>{let{year:e,callback:d}=i,o=S(),t=[];for(let r=1;r<=12;r++){let m=e==o.year&&r==o.month,h=!1;{let s=Number(String([e,r.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>s&&(h=!0),i.max){let l=Number(String(i.max).replace(/\D/ig,""));s>l&&(h=!0)}}let n=[y("Cell"),m?y("isThisMonth"):""].join(" ");t.push(f(C.Clear,{className:n,isLocked:h,fontColor:"2.normal",padding:["1/3",1],ssEffectsOnActive:"shrink",onClick:()=>{d([e,r])},children:[r," \u6708"]},e+"-"+r))}return a(W,{gridCols:4,gap:"2/3",children:t})}},Year:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h}=r;return f(V,{padding:1,children:[a(M,{emptySelect:!1,paddingRight:1,fontSize:"1.mini",value:h||S().year,override:"force",SelectorStyles:{freeCSS:{minWidth:12*12}},options:_({min:e,max:d}),onUpdateValidValue:n=>{m({modifiedType:"update",year:Number(n)})}}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o,onSubmit:()=>{m({modifiedType:"update",year:Number(h||S().year)})}})]})}},DateWareki:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{era:h,year:n,month:s,date:l}=r,u={val_value:r,set_value:m};return f(k,{children:[f(N.Left,{borderBottom:!0,gap:0,verticalAlign:"unset",children:[a(g.DateWareki.EraSelect,p({},u)),a(k,{borderRight:!0}),a(g.DateWareki.Calendar,p({},u))]}),a(N.Right,{padding:1,children:a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})})]})},EraSelect:i=>{let{val_value:e,set_value:d}=i,o={padding:["1/2",1.5],fontColor:"3.blur"},t={backgroundColor:"cloud",fontColor:"2.normal",isSemiBoldFont:!0};return f(V,{padding:1,gap:0,children:[a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="year",onClick:()=>{let r=S();d({modifiedType:"update",era:"year",year:r.year,month:r.month,date:r.date})},children:"\u897F\u66A6"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="reiwa",onClick:()=>{let r=S();d({modifiedType:"update",era:"reiwa",year:r.year,month:r.month,date:r.date})},children:"\u4EE4\u548C"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="heisei",onClick:()=>{d({modifiedType:"update",era:"heisei",year:2019,month:1,date:1})},children:"\u5E73\u6210"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="shouwa",onClick:()=>{d({modifiedType:"update",era:"shouwa",year:1989,month:1,date:1})},children:"\u662D\u548C"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="taisho",onClick:()=>{d({modifiedType:"update",era:"taisho",year:1926,month:1,date:1})},children:"\u5927\u6B63"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="meiji",onClick:()=>{d({modifiedType:"update",era:"meiji",year:1912,month:1,date:1})},children:"\u660E\u6CBB"}))]})},Calendar:i=>{let{val_value:e,set_value:d}=i,o=[];if(e.era=="year"){let t=S().year+10;for(let r=1900;r<t;r++)o.unshift({value:r,label:r+"\u5E74"})}else if(e.era=="reiwa"){let t=S().year-2018;for(let r=1;r<=t+10;r++)o.unshift({value:2019+r-1,label:"\u4EE4\u548C"+(r==1?"\u5143":r)+"\u5E74"})}else if(e.era=="heisei")for(let t=1;t<=31;t++)o.unshift({value:1989+t-1,label:"\u5E73\u6210"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="shouwa")for(let t=1;t<=64;t++)o.unshift({value:1926+t-1,label:"\u662D\u548C"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="taisho")for(let t=1;t<=15;t++)o.unshift({value:1912+t-1,label:"\u5927\u6B63"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="meiji")for(let t=1;t<=45;t++)o.unshift({value:1868+t-1,label:"\u660E\u6CBB"+(t==1?"\u5143":t)+"\u5E74"});return f(V,{padding:1,children:[f(N.Separate,{children:[a(M,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,fontSize:"1.mini",SelectorStyles:{freeCSS:{minWidth:12*12}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),options:o,value:e.year,onUpdateValidValue:t=>{d(r=>x(p({},r),{modifiedType:"update",year:Number(t)}))}}),f(N.Center,{gap:"1/3",children:[a(M,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,fontSize:"1.mini",SelectorStyles:{freeCSS:{minWidth:12*9}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.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:e.month,onUpdateValidValue:t=>{d({modifiedType:"update",era:e.era,year:e.year,month:Number(t),date:1})}}),a(C.Clear.S,{ssSphere:2.5,onClick:()=>{let t=e.month-1;d({modifiedType:"update",era:e.era,year:t==0?e.year-1:e.year,month:t==0?12:t,date:1})},children:a(T.ChevronLeft,{})}),a(C.Clear.S,{ssSphere:2.5,onClick:()=>{let t=e.month+1;d({modifiedType:"update",era:e.era,year:t==13?e.year+1:e.year,month:t==13?1:t,date:1})},children:a(T.ChevronRight,{})})]})]}),a(g.DateWareki.MonthCell,p({},i))]},e.era)},MonthCell:i=>{let{val_value:e,set_value:d}=i,o=S([e.year.zeroEmbed(4),e.month.zeroEmbed(2),e.date.zeroEmbed(2)].join("/"));if(!o.validate)return;let t=o.getFirstDayOfTheMonth().weekday,r=o.getLastDayOfTheMonth(),m=[];for(let n=0;n<7;n++)m.push(a(G.Supplement,{flexCenter:!0,fontColor:n==0?"googleRed":n==6?"googleBlue":"3.blur",children:D.transformer.weekday.shortJP(n)},"legend-"+n));for(let n=0;n<t;n++){let s=S(o).getFirstDayOfTheMonth().addDate(n-t);m.push(a(C.Sub,{color:"cloud",ssSquare:3,opacity:"middle",onClick:l=>{l.preventDefault(),l.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"lastMonth-"+n))}let h=S();for(let n=1;n<=r.date;n++){let s=S(o).setDate(n),l=h.diff(s).dates==0;m.push(a(C.Clear,{ssSquare:3,fontColor:"2.normal",className:[y("CalendarDay"),y("isToday_"+l)].join(" "),onClick:()=>{d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"currentMonth-"+n))}for(let n=0;n<7-r.weekday-1;n++){let s=S(o).addMonth(1).setDate(1).addDate(n);m.push(a(C.Sub,{color:"cloud",ssSquare:3,opacity:"middle",onClick:l=>{l.preventDefault(),l.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"nextMonth-"+n))}return a(W,{gridCols:7,gap:"1/4",children:m})}},Variables:{Footer:i=>f(w,{flexWrap:!1,gap:1,flexChilds:"even",freeCSS:{whiteSpace:"nowrap"},children:[f(C.Sub.S,{color:"cloud",tabIndex:-1,isRounded:!0,onClick:()=>{i.onValueUpdate("")},flexSizing:"none",children:[a(T.Times,{})," \u524A\u9664"]}),a(C.Prime.S,{tabIndex:-1,isRounded:!0,flexSizing:"auto",freeCSS:{minWidth:12*6},onClick:()=>{i.onSubmit&&i.onSubmit(),$.close(i.sheetID)},children:"\u6C7A\u5B9A"})]}),ShiftButtons:i=>f(w,{gap:"1/3",flexWrap:!1,children:[a(C.Clear,x(p({className:y("LeftButton"),tabIndex:-1,right:0},g.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(-1)},children:a(T.ChevronLeft,{})})),a(C.Clear,x(p({className:y("RightButton"),tabIndex:-1,left:0},g.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(1)},children:a(T.ChevronRight,{})}))]}),ShiftButtonStyles:{position:"relative",flexCenter:!0,ssSphere:2.5}}};export{L as Picker,L as default};
|
|
1
|
+
import{b as p,c as x}from"../../../chunk-C5N2D3ZX.js";import{Fragment as q,jsx as a,jsxs as f}from"react/jsx-runtime";import{createElement as X}from"react";import D,{UUID as O,Time as S}from"jmini";import{useState as A,useEffect as F,useRef as H}from"react";import{Box as k,Flex as w,Grid as W,FAI as T,Column as V}from"../../../atoms";import{Row as N,Literal as G}from"../../../mols";import{Button as C}from"../../Button";import $ from"../../Sheet";import M from"../Select";import{Radio as L}from"../List";import{RightIcon as B}from"..";import{InputTimeClasses as y}from"../../../@styles/componentClasses";let _=i=>{var t,r;let e=[],d=Number((t=i==null?void 0:i.min)!=null?t:1900),o=Number((r=i==null?void 0:i.max)!=null?r:S().addYear(10).year);for(let m=d;m<=o;m++)e.unshift({value:m,label:[m,...D.transformer.wareki(m).value].join(" -")});return e};const j=i=>{let{restrict:e,era:d="year",defaultValue:o=""}=i;i=p({},i),i.sheetID=i.sheetID||O();const t=H(!1);let[r,m]=A((()=>{var n,s;if(e=="clock"){let l=String(o).split(/[^\d]/);l[0]||(l=[0,0]);let u=Number(l[0]),c=Number(l[1]);return{modifiedType:"init",hour:u,minutes:c}}else if(e=="date"){let[l,u,c]=(n=String(o))==null?void 0:n.split(/\D/);return(D.is.nullish(l)||D.is.nullish(u)||D.is.nullish(c))&&([l,u,c]=S().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",year:Number(l),month:Number(u),date:Number(c)}}else if(e!="week"){if(e=="month"){let[l,u]=String(o).split(/\D/);return(D.is.nullish(l)||D.is.nullish(u))&&([l,u]=S().toFormat("%Y-%M").split("-")),{modifiedType:"init",year:Number(l),month:Number(u)}}else if(e=="year"){let[l]=String(o).split(/\D/);return D.is.nullish(l)&&([l]=S().toFormat("%Y").split("-")),{modifiedType:"init",year:Number(l)}}else if(e=="dateWareki"){let[l,u,c]=(s=String(o))==null?void 0:s.split(/\D/);return(D.is.nullish(l)||D.is.nullish(u)||D.is.nullish(c))&&([l,u,c]=S().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",era:d||"year",year:Number(l),month:Number(u),date:Number(c)}}}return{}})());F(()=>{if(t.current){if(r.modifiedType=="update"){let n="",s=d||"year";if(e=="clock"){let{hour:l,minutes:u}=r;n=[l.zeroEmbed(2),u.zeroEmbed(2)].join("/")}else if(e=="date"){let{year:l,month:u,date:c}=r;n=[l,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}else if(e!="week"){if(e=="month"){let{year:l,month:u}=r;n=[l,u.zeroEmbed(2)].join("/")}else if(e=="year"){let{year:l}=r;n=String(l)}else if(e=="dateWareki"){let{year:l,month:u,date:c,era:v}=r;s=v,n=[l,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}}i.onValueUpdate(n,s)}}else t.current=!0},[r]);let h=x(p({},i),{val_value:r,set_value:m});return a(k,{backgroundColor:"layer.1",borderRadius:"2.tone.secondary",boxShadow:"1.remark",children:a(k,{className:y(e.toCapital()+"Base"),children:e=="clock"?a(g.Clock.index,p({},h)):e=="date"?a(g.Date.index,p({},h)):e=="week"?"":e=="month"?a(g.Month.index,p({},h)):e=="year"?a(g.Year.index,p({},h)):e=="dates"||e=="months"?"":e=="dateWareki"?a(g.DateWareki.index,p({},h)):a(q,{})})})},g={Clock:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,[h,n]=A(r.hour>12?2:1),[s,l]=A(Number(localStorage.getItem("timePickerUnit")||5));F(()=>{localStorage.setItem("timePickerUnit",String(s))},[s]);let{hour:u,minutes:c}=r;return f(V,{padding:1,children:[f(w,{flexType:"row",flexWrap:!1,gap:1,className:y("Body"),children:[f(V,{className:y("DesignSide"),flexSizing:0,children:[a(k,{className:y("ClockUiBase"),padding:[1,"2/3"],flexCenter:!0,children:f(k,{className:y("ClockUi"),backgroundColor:"theme.opa.low",isRounded:!0,position:"relative",children:[a(k,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[y("Needle"),y("hour")].join(" "),freeCSS:{transform:`rotate(${u*30+c/2}deg)`}}),a(k,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[y("Needle"),y("minute")].join(" "),freeCSS:{transform:`rotate(${c*6}deg)`}})]})}),a(L,{icon:!0,value:[h],options:[{value:1,label:"AM"},{value:2,label:"PM"}],flexType:"col",gap:"1/2",tabIndex:-1,onUpdateValidValue:v=>{let I=r.hour%12+(v==2?12:0);n(v),m({modifiedType:"update",hour:I,minutes:r.minutes})}}),a(k,{borderTop:!0,margin:[0,1]}),a(L,{icon:!0,value:[s],options:[{value:1,label:"/ 1\u5206"},{value:2,label:"/ 2\u5206"},{value:5,label:"/ 5\u5206"}],flexType:"col",gap:"1/2",tabIndex:-1,onUpdateValidValue:v=>{l(v)}})]}),f(V,{children:[f(k,{flexCenter:!0,isSemiBoldFont:!0,fontSize:"3.paragraph",children:[r.hour.zeroEmbed(2)," : ",r.minutes.zeroEmbed(2)]}),f(w,{flexWrap:!1,ssCardBox:!0,flexChilds:"even",padding:["1/3",0],freeCSS:{minWidth:12*12},children:[a(V,{gap:0,overflow:"auto",padding:"2/3",borderRight:!0,freeCSS:{maxHeight:12*22},children:g.Clock.Hours({onClick:v=>{let R=v+(h==2?12:0);m({modifiedType:"update",hour:R,minutes:r.minutes})},min:e,max:d,ampm:h})}),a(V,{gap:0,overflow:"auto",padding:"2/3",freeCSS:{maxHeight:12*22},children:g.Clock.Minutes({onClick:v=>{m({modifiedType:"update",hour:r.hour,minutes:v})},min:e,max:d,unit:s})})]})]})]}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},Hours:i=>{let e=[];for(let d=0;d<12;d++){let o=i.ampm==2?d+12:d,t=!1;{let r=Number(String(o*100).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>r&&(t=!0),i.max){let m=Number(String(i.max).replace(/\D/ig,""));r>m&&(t=!0)}}e.push(a(C.Normal,{isLocked:t,borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(d)},children:o.zeroEmbed(2)},d))}return e},Minutes:i=>{let e=[];for(let d=0;d<60/i.unit;d++){let o=d*i.unit;e.push(a(C.Normal,{borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(o)},children:o.zeroEmbed(2)},o))}return e}},Date:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h,month:n,date:s}=r;return f(V,{padding:1,children:[f(N.Separate,{flexWrap:!0,children:[f(w,{verticalAlign:"bottom",horizontalAlign:"left",gap:"2/3",flexWrap:!1,children:[a(M,{override:"force",emptySelect:!1,value:h,options:_(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,SelectorStyles:{freeCSS:{minWidth:12*12}},onUpdateValidValue:l=>{m({modifiedType:"update",year:Number(l),month:n,date:s})},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})})}),a(M,{override:"force",emptySelect:!1,value:n,options:(()=>{let l=[];for(let u=1;u<=12;u++)l.push({value:u,label:String(u)+"\u6708"});return l})(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,SelectorStyles:{freeCSS:{minWidth:12*8}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),onUpdateValidValue:l=>{m({modifiedType:"update",year:h,month:Number(l),date:s})}})]}),a(g.Variables.ShiftButtons,{callback:l=>{let u=n+l,c=h;u<=0&&(c--,u=12),u>12&&(c++,u=1),m({modifiedType:"update",year:c,month:u,date:r.date})}})]}),a(k,{borderTop:!0}),a(k,{children:g.Date.MonthCalendar({min:e,max:d,year:r.year,month:r.month,current:[r.year,r.month,r.date],callback:l=>{let[u,c,v]=l;m({modifiedType:"update",year:u,month:c,date:v})}})}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},MonthCalendar:i=>{let{min:e,max:d,year:o,month:t,current:r,callback:m}=i,h=S(),n=S([o,t.zeroEmbed(2),"01"].join("/")),s=n.getLastDayOfTheMonth(),l=S(n).addMonth(-1).getLastDayOfTheMonth().date,u=[],c=[],v=[],R=[],I={padding:0,unitWidth:3,unitHeight:3,flexCenter:!0,borderRadius:"3.tone.tertiary"};for(var b=0;b<7;b++)u.push(a(k,x(p({className:[y("CalendarDay"),y("Legend")].join(" ")},I),{children:["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][b]}),b));for(var b=0;b<n.weekday;b++)c.unshift(X(k,x(p({className:[y("CalendarDay"),y("Dummy")].join(" "),fontColor:"4.thin"},I),{key:b}),l-b));for(var b=1;b<=s.date;b++){let E=b,Y=o==h.year&&t==h.month&&b==h.date,P=!1;{let z=Number(String([o,t.zeroEmbed(2),b.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>z&&(P=!0),i.max){let U=Number(String(i.max).replace(/\D/ig,""));z>U&&(P=!0)}}v.push(a(C.Clear,x(p({className:[y("CalendarDay"),y("isToday_"+Y)].join(" ")},I),{fontColor:"1.clear",padding:0,flexCenter:!0,isRounded:!0,ssEffectsOnActive:"shrink",onClick:()=>{m([o,t,E])},tabIndex:-1,isLocked:P,children:b}),E))}for(var b=1;b<7-s.weekday;b++)R.push(a(k,x(p({className:[y("CalendarDay"),y("Dummy")].join(" "),fontColor:"4.thin"},I),{children:b}),b));return f(W,{gridCols:7,gap:"1/6",children:[u,c,v,R]})}},Month:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h,month:n}=r;return f(V,{padding:1,children:[f(N.Separate,{gap:0,children:[a(N.Center,{verticalAlign:"bottom",gap:"2/3",children:a(M,{emptySelect:!1,value:h,options:_(),override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,SelectorStyles:{freeCSS:{minWidth:12*12}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),onUpdateValidValue:s=>{m({modifiedType:"update",year:Number(s),month:n})}})}),a(g.Variables.ShiftButtons,{callback:s=>{let l=Math.min(Math.max(h+s,1900),2100);m({modifiedType:"update",year:l,month:n})}})]}),a(k,{borderTop:!0}),g.Month.Months({min:e,max:d,year:r.year,callback:s=>{let[l,u]=s;m({modifiedType:"update",year:l,month:u})}}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},Months:i=>{let{year:e,callback:d}=i,o=S(),t=[];for(let r=1;r<=12;r++){let m=e==o.year&&r==o.month,h=!1;{let s=Number(String([e,r.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>s&&(h=!0),i.max){let l=Number(String(i.max).replace(/\D/ig,""));s>l&&(h=!0)}}let n=[y("Cell"),m?y("isThisMonth"):""].join(" ");t.push(f(C.Clear,{className:n,isLocked:h,fontColor:"2.normal",padding:["1/3",1],ssEffectsOnActive:"shrink",onClick:()=>{d([e,r])},children:[r," \u6708"]},e+"-"+r))}return a(W,{gridCols:4,gap:"2/3",children:t})}},Year:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h}=r;return f(V,{padding:1,children:[a(M,{emptySelect:!1,paddingRight:1,fontSize:"1.mini",value:h||S().year,override:"force",SelectorStyles:{freeCSS:{minWidth:12*12}},options:_({min:e,max:d}),onUpdateValidValue:n=>{m({modifiedType:"update",year:Number(n)})}}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o,onSubmit:()=>{m({modifiedType:"update",year:Number(h||S().year)})}})]})}},DateWareki:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{era:h,year:n,month:s,date:l}=r,u={val_value:r,set_value:m};return f(k,{children:[f(N.Left,{borderBottom:!0,gap:0,verticalAlign:"unset",children:[a(g.DateWareki.EraSelect,p({},u)),a(k,{borderRight:!0}),a(g.DateWareki.Calendar,p({},u))]}),a(N.Right,{padding:1,children:a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})})]})},EraSelect:i=>{let{val_value:e,set_value:d}=i,o={padding:["1/2",1.5],fontColor:"3.blur"},t={backgroundColor:"cloud",fontColor:"2.normal",isSemiBoldFont:!0};return f(V,{padding:1,gap:0,children:[a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="year",onClick:()=>{let r=S();d({modifiedType:"update",era:"year",year:r.year,month:r.month,date:r.date})},children:"\u897F\u66A6"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="reiwa",onClick:()=>{let r=S();d({modifiedType:"update",era:"reiwa",year:r.year,month:r.month,date:r.date})},children:"\u4EE4\u548C"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="heisei",onClick:()=>{d({modifiedType:"update",era:"heisei",year:2019,month:1,date:1})},children:"\u5E73\u6210"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="shouwa",onClick:()=>{d({modifiedType:"update",era:"shouwa",year:1989,month:1,date:1})},children:"\u662D\u548C"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="taisho",onClick:()=>{d({modifiedType:"update",era:"taisho",year:1926,month:1,date:1})},children:"\u5927\u6B63"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="meiji",onClick:()=>{d({modifiedType:"update",era:"meiji",year:1912,month:1,date:1})},children:"\u660E\u6CBB"}))]})},Calendar:i=>{let{val_value:e,set_value:d}=i,o=[];if(e.era=="year"){let t=S().year+10;for(let r=1900;r<t;r++)o.unshift({value:r,label:r+"\u5E74"})}else if(e.era=="reiwa"){let t=S().year-2018;for(let r=1;r<=t+10;r++)o.unshift({value:2019+r-1,label:"\u4EE4\u548C"+(r==1?"\u5143":r)+"\u5E74"})}else if(e.era=="heisei")for(let t=1;t<=31;t++)o.unshift({value:1989+t-1,label:"\u5E73\u6210"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="shouwa")for(let t=1;t<=64;t++)o.unshift({value:1926+t-1,label:"\u662D\u548C"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="taisho")for(let t=1;t<=15;t++)o.unshift({value:1912+t-1,label:"\u5927\u6B63"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="meiji")for(let t=1;t<=45;t++)o.unshift({value:1868+t-1,label:"\u660E\u6CBB"+(t==1?"\u5143":t)+"\u5E74"});return f(V,{padding:1,children:[f(N.Separate,{children:[a(M,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,fontSize:"1.mini",SelectorStyles:{freeCSS:{minWidth:12*12}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),options:o,value:e.year,onUpdateValidValue:t=>{d(r=>x(p({},r),{modifiedType:"update",year:Number(t)}))}}),f(N.Center,{gap:"1/3",children:[a(M,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,fontSize:"1.mini",SelectorStyles:{freeCSS:{minWidth:12*9}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.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:e.month,onUpdateValidValue:t=>{d({modifiedType:"update",era:e.era,year:e.year,month:Number(t),date:1})}}),a(C.Clear.S,{ssSphere:2.5,onClick:()=>{let t=e.month-1;d({modifiedType:"update",era:e.era,year:t==0?e.year-1:e.year,month:t==0?12:t,date:1})},children:a(T.ChevronLeft,{})}),a(C.Clear.S,{ssSphere:2.5,onClick:()=>{let t=e.month+1;d({modifiedType:"update",era:e.era,year:t==13?e.year+1:e.year,month:t==13?1:t,date:1})},children:a(T.ChevronRight,{})})]})]}),a(g.DateWareki.MonthCell,p({},i))]},e.era)},MonthCell:i=>{let{val_value:e,set_value:d}=i,o=S([e.year.zeroEmbed(4),e.month.zeroEmbed(2),e.date.zeroEmbed(2)].join("/"));if(!o.validate)return;let t=o.getFirstDayOfTheMonth().weekday,r=o.getLastDayOfTheMonth(),m=[];for(let n=0;n<7;n++)m.push(a(G.Supplement,{flexCenter:!0,fontColor:n==0?"googleRed":n==6?"googleBlue":"3.blur",children:D.transformer.weekday.shortJP(n)},"legend-"+n));for(let n=0;n<t;n++){let s=S(o).getFirstDayOfTheMonth().addDate(n-t);m.push(a(C.Sub,{color:"cloud",ssSquare:3,opacity:"middle",onClick:l=>{l.preventDefault(),l.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"lastMonth-"+n))}let h=S();for(let n=1;n<=r.date;n++){let s=S(o).setDate(n),l=h.diff(s).dates==0;m.push(a(C.Clear,{ssSquare:3,fontColor:"2.normal",className:[y("CalendarDay"),y("isToday_"+l)].join(" "),onClick:()=>{d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"currentMonth-"+n))}for(let n=0;n<7-r.weekday-1;n++){let s=S(o).addMonth(1).setDate(1).addDate(n);m.push(a(C.Sub,{color:"cloud",ssSquare:3,opacity:"middle",onClick:l=>{l.preventDefault(),l.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"nextMonth-"+n))}return a(W,{gridCols:7,gap:"1/4",children:m})}},Variables:{Footer:i=>f(w,{flexWrap:!1,gap:1,flexChilds:"even",freeCSS:{whiteSpace:"nowrap"},children:[f(C.Sub.S,{color:"cloud",tabIndex:-1,isRounded:!0,onClick:()=>{i.onValueUpdate("")},flexSizing:"none",children:[a(T.Times,{})," \u524A\u9664"]}),a(C.Prime.S,{tabIndex:-1,isRounded:!0,flexSizing:"auto",freeCSS:{minWidth:12*6},onClick:()=>{i.onSubmit&&i.onSubmit(),$.close(i.sheetID)},children:"\u6C7A\u5B9A"})]}),ShiftButtons:i=>f(w,{gap:"1/3",flexWrap:!1,children:[a(C.Clear,x(p({className:y("LeftButton"),tabIndex:-1,right:0},g.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(-1)},children:a(T.ChevronLeft,{})})),a(C.Clear,x(p({className:y("RightButton"),tabIndex:-1,left:0},g.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(1)},children:a(T.ChevronRight,{})}))]}),ShiftButtonStyles:{position:"relative",flexCenter:!0,ssSphere:2.5}}};export{j as Picker,j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ae,b as l,c as k,d as q}from"../../../chunk-C5N2D3ZX.js";import{Fragment as _e,jsx as y,jsxs as oe}from"react/jsx-runtime";import G,{UUID as N,useStore as L}from"jmini";import*as K from"jmini";import{useState as W,useEffect as Q,useRef as ce}from"react";import{$$fromRoot as pe,Config as re,ExtractStyles as ue}from"../../../@utils";import{Box as X,FAI as de}from"../../../atoms";import{Text as fe,Row as he}from"../../../mols";import{Button as ie}from"../../Button";import ge from"../../Tooltips";import ye from"../../Sheet";import{faClock as De}from"@fortawesome/free-solid-svg-icons/faClock";import{faCalendarAlt as ve}from"@fortawesome/free-solid-svg-icons/faCalendarAlt";import{OptionalInputWrapper as Ie,BoxWrapper as Se,CoreEffects as z,DefaultBoxishStyles as Te}from"../core";import{RightIcon as xe}from"..";import be from"../Select";import{InputLabel as ke}from"../Label";import Ee from"./Picker";const F=" ~ ",we={clock:{defaultValue:"--:--",format:/^\d{2}\D\d{2}$/,ranges:[{type:"hour",from:0,length:2},{type:"minute",from:3,length:2}],sets:1},date:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2}],sets:1},week:{defaultValue:"----\u5E74\u7B2C--\u9031",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4,region:6},{type:"week",from:6,length:2,region:3}],sets:1},month:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:3}],sets:1},year:{defaultValue:"----\u5E74",format:/^\d{4}$/,ranges:[{type:"year",from:0,length:4,region:5}],sets:1},dates:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2,region:5},{type:"year",from:10+F.length,length:4},{type:"month",from:15+F.length,length:2},{type:"date",from:18+F.length,length:2}],sets:2},months:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:6},{type:"year",from:8+F.length,length:4},{type:"month",from:13+F.length,length:2,region:3}],sets:2},dateWareki:{defaultValue:"----\u5E74--\u6708--\u65E5",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"dateWareki",from:0,length:4,region:5},{type:"month",from:5,length:2,region:3},{type:"date",from:8,length:2,region:3}],sets:1}},O={PeriodMargin:" ~ ",DataLeveling:e=>{let{restrict:t,value:D,era:a}=e,d=G.flatArray(D||""),{defaultValue:f,format:h,ranges:v,sets:r}=we[t],m=[],o=t=="clock"?":":"/";for(let i=0;i<d.length;i++)d[i]=String(d[i]).replace(/\D/ig,o);for(let i=0;i<r;i++){let u=d[i]||"";if(!u.match(h))d[i]="",m.push(f);else{let b=f;u.split(/\D/).forEach((E,R)=>{if(R==0&&t=="dateWareki"){let S=Number(E);a!="year"&&(S>=2019?a=="reiwa"?S-=2018:a=="heisei"&&(S=31):S>=1989?a=="heisei"?S-=1988:a=="shouwa"&&(S=64):S>=1926?a=="shouwa"?S-=1925:a=="taisho"&&(S=15):S>=1912?a=="taisho"?S-=1911:a=="meiji"&&(S=45):S>=1868&&(S-=1867)),E=S.zeroEmbed(4)}b=b.replace(new RegExp("------------------".slice(0,E.length)),E)}),m.push(b)}}return{formatValue:m.join(F),dataValue:["dates","months"].includes(t)?d:d[0],ranges:v}},SystemValidation:e=>{let{states:t}=e,{restrict:D,min:a,max:d,required:f}=t,h=[],v=G.flatArray(e.value),r={empty:!1,escalated:1,filled:!0,correct:!0,prohibited:!1};(()=>{let m=D=="clock"?":":"/";for(let o=0;o<v.length;o++)v[o]=String(v[o]).replace(/\D/ig,m);for(let o=0;o<v.length;o++){let i=v[o],u=v[o-1];i.removeLetters()||(r.empty=!0),o>0&&(r.escalated&=+(i>=u))}r.escalated&&(r.empty||(D.match(/clock/)?v.forEach(o=>{let[i,u]=o.split(/\D+/);!i||!u?r.filled=!1:(Number(i)>23||Number(u)>59)&&(r.correct=!1)}):D.match(/date/)?v.forEach(o=>{let[i,u,b]=o.split(/\D+/);if(!i||!u||!b)r.filled=!1;else{let E=K.Time(o);(!E.validate||o!=E.toFormatYMD())&&(r.correct=!1)}}):D.match(/week/)?v.forEach(o=>{let[i,u]=o.split(/\D+/);if(!i||!u)r.filled=!1;else{let b=K.Time(i+"/01/01").weekday,R=K.Time(i+"/01/0"+(7-b+1)).addWeek(Number(u)-1);i!=String(R.year)&&(r.correct=!1)}}):D.match(/month/)?v.forEach(o=>{let[i,u]=o.split(/\D+/);!i||!u?r.filled=!1:K.Time([i,u,"01"].join("/")).validate||(r.correct=!1)}):D.match(/year/),r.filled&&r.correct&&v.forEach(o=>{{let i=Number(String(o).replace(/\D/ig,""));if(a&&Number(String(a).replace(/\D/ig,""))>i&&(r.prohibited=!0),d){let u=Number(String(d).replace(/\D/ig,""));i>u&&(r.prohibited=!0)}}})))})();{let{empty:m,escalated:o,filled:i,correct:u,prohibited:b}=r;m&&f&&(h=[{type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}]),o||h.push({type:"invalid",label:"\u6642\u7CFB\u5217\u3092\u6B63\u3057\u304F\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),u||h.push({type:"invalid",label:"\u7121\u52B9\u306A\u5024\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u3059"}),i||h.push({type:"invalid",label:"\u6700\u5F8C\u307E\u3067\u5024\u3092\u57CB\u3081\u3066\u304F\u3060\u3055\u3044"}),b&&h.push({type:"invalid",label:oe(_e,{children:[y(X,{children:"\u5165\u529B\u7BC4\u56F2\u304C\u5236\u9650\u3055\u308C\u3066\u3044\u307E\u3059"}),"[",a||"\u4E0B\u9650\u7121\u3057","] ~ [",d||"\u4E0A\u9650\u7121\u3057","]"]})})}return{ok:!h.filter(({type:m})=>m=="invalid").length,notice:h}},KeyDownEvent:e=>{let{val_era:t,restrict:D,event:a,val_status:d,set_status:f,val_focus:h,set_focus:v}=e,{key:r,shiftKey:m,ctrlKey:o,metaKey:i}=a,u=o||i,{selectionStart:b,selectionEnd:E}=a.target,{index:R,prevIndex:S}=h,{ranges:$,formatValue:H}=d,C=$.length-1;if(["Tab","ArrowLeft","ArrowRight"].includes(r)){let I=0;if(r=="Tab"){let s=+!m*2-1;if(I=h.index+s,I<0||I>C)return}else{let s=r=="ArrowLeft"?-1:r=="ArrowRight"?1:0;u||b==0&&E==String(d.formatValue).length?I=s==1?C:0:I=Math.max(0,Math.min(R+s,C))}v(s=>k(l({},s),{index:I,prevIndex:R})),a.preventDefault()}if(["Backspace","ArrowUp","ArrowDown","0","1","2","3","4","5","6","7","8","9"].includes(r)){a.preventDefault();let I=R;I=Math.max(I,0),I=Math.min(I,C);let{type:s,from:B,length:Y}=$[I],_=H.slice(B,B+Y),p;if(r=="Backspace")p="------".slice(0,Y);else if(["ArrowUp","ArrowDown"].includes(r)){let w=r=="ArrowUp"?1:-1;_=_|0,p=_+w;let[n,c,T]=s=="dateWareki"?t=="year"?[0,2999,4]:t=="reiwa"?[1,2999,4]:t=="heisei"?[1,31,4]:t=="shouwa"?[1,64,4]:t=="taisho"?[1,15,4]:t=="meiji"?[1,45,4]:[0,0,0]:s=="minute"?[0,59,2]:s=="hour"?[0,23,2]:s=="date"?[1,31,2]:s=="week"?[1,53,2]:s=="month"?[1,12,2]:s=="year"?[0,2999,4]:[0,0,0];p>c?p=n:p<n&&(p=c),p=Number(p).zeroEmbed(T)}else if(["0","1","2","3","4","5","6","7","8","9"].includes(r)){let w=_|0,n=r,c=`${w}${n}`;if(S!=R&&(w=0,c="0"+n),s=="year"||s=="dateWareki"&&t=="year")Number(c)>1e4?p=n:p=c,(p|0)>1e3&&I++;else if(["hour","minute","date","week","month"].includes(s)||s=="dateWareki"&&t!="year"){let T=s=="dateWareki"?t=="reiwa"?100:t=="heisei"?31:t=="shouwa"?64:t=="taisho"?15:t=="meiji"?45:0:s=="minute"?59:s=="hour"?23:s=="date"?31:s=="week"?53:s=="month"?12:0;p=(c|0)>T?n:c,(Number(n)>Number(String(T)[0])||_=="0000".slice(0,String(T).length)&&(c!="0000".slice(0,String(T).length)||["minute","hour"].includes(s)&&S==R)||(c|0)>=ae(10,String(T).length-1))&&I++}s=="year"||s=="dateWareki"?p=(p|0).zeroEmbed(4):p=(p|0).zeroEmbed(2)}{let w=String(H).partReplace(B,String(p)),n=w.split(F).map(c=>c.replace(/(^\D|\D$)/,"").split(/\D+/).join(D=="clock"?":":"/").replace(/(^\D|\D$)/,""));if(D=="dateWareki"){let c=n[0].split(/\D/),[T,j,P]=c;c.length==3&&T&&(n=[[Number(T)-1+Number({year:1,reiwa:2019,heisei:1989,shouwa:1926,taisho:1912,meiji:1868}[t]),j,P].join("/")])}I=Math.max(I,0),I=Math.min(I,C),f(c=>k(l({},c),{dataValue:["dates","months"].includes(D)?n:n[0],formatValue:w,eventType:"update",eventID:N()})),v(c=>k(l({},c),{index:I,prevIndex:c.index}))}}}},ne={picker:{launch:e=>{let t=e.sheetID||N(),m=e,{onValueUpdate:D,min:a,max:d,era:f,restrict:h,defaultValue:v}=m,r=q(m,["onValueUpdate","min","max","era","restrict","defaultValue"]);ye.open(k(l({sheetID:t,type:"normal.middleCenter",size:"S",padding:0,closeAtAroundClick:!0,closeAtParentBlur:!1},r),{content:y(he.Center,{children:y(Ee,{restrict:h,min:a,max:d,era:f,defaultValue:v,sheetID:t,onValueUpdate:(o,i)=>{D(o,i)}})})}))},remove:e=>{ge.close(e)}}},Re={Shallow:e=>{let{rootStates:t,val_status:D}=e,a=ue(t);return y(X,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:y(fe.Description,k(l({className:t.className},a),{position:"absolute",width:1,freeCSS:k(l({},a.freeCSS),{color:"orange"}),children:y(X,{"data-input-value-shallow":D.componentID,children:"A"})}))})}},Ve=e=>{let ee=e,{tone:t,required:D,restrict:a="clock",componentID:d,era:f,form:h,name:v,min:r,max:m,className:o,enableFormSubmit:i,checkValidationAtFirst:u,onKeyDown:b,onValidate:E,onUpdateValue:R,onUpdateValidValue:S,value:$="",leftIndicator:H,rightIndicator:C,leftIcon:I,rightIcon:s,freeCSS:B,wrapStyles:Y}=ee,_=q(ee,["tone","required","restrict","componentID","era","form","name","min","max","className","enableFormSubmit","checkValidationAtFirst","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","freeCSS","wrapStyles"]),[p,w]=W(f),[n,c]=W(k(l({componentID:e.componentID||""},O.DataLeveling({restrict:a,value:$,era:p})),{eventType:"init",eventID:N()})),[T,j]=W({ok:!1,notice:[]}),[P,U]=W({active:!1,index:0,prevIndex:-1}),le={rootStates:e,val_status:n,set_status:c,val_validate:T,set_validate:j,val_era:p,set_era:w,val_focus:P,set_focus:U};z.CommonEffects({type:"time",states:e,val_status:n,set_status:c,val_validate:T,set_validate:j,SystemValidation:O.SystemValidation,ExtraOverrideStates:l({},O.DataLeveling({restrict:a,value:$,era:p}))});const Z=ce(!1);return Q(()=>{if(Z.current){c(x=>l(l({},x),O.DataLeveling({restrict:a,value:x.dataValue,era:p})));let g=L.get("refreshEra_"+n.componentID);g&&g.refreshEra(p)}else Z.current=!0},[p]),L.update({[n.componentID]:{openPicker:g=>{e.disabled||ne.picker.launch({parent:g,sheetID:"PickerTips-"+n.componentID,restrict:a,min:r,max:m,defaultValue:n.dataValue,era:p,onValueUpdate:(x,A)=>{c(M=>k(l(l({},M),O.DataLeveling({restrict:a,value:x,era:A})),{eventType:"update",eventID:N()})),w(A)}})},resetEra:g=>{w(g),c(x=>k(l(l({},x),O.DataLeveling({restrict:a,value:"",era:p})),{eventType:"update",eventID:N()}))}}}),Q(()=>{let{index:g,active:x}=P;if(x){g=Math.max(g,0),g=Math.min(g,n.ranges.length-1);let{from:A,length:M}=n.ranges[g],J=pe("#"+e.id)[0];J&&J.setSelectionRange(A,A+M)}},[P]),oe(Se,{val_status:n,set_status:c,val_validate:T,states:e,children:[y(Re.Shallow,l({},le)),y(ke,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:!0}),re.get().isTouchDevice?y(ie.Plain,k(l({"data-show-validation":z.isShowValidation(T,n,!!u),"data-component-id":n.componentID,"data-input-origin":n.componentID,"data-disabled":e.disabled,className:o,freeCSS:{textAlign:"left"}},_),{children:n.formatValue,onClick:g=>{let x=L.get(n.componentID);x&&x.openPicker(`[data-input-origin="${n.componentID}"]`),g.stopPropagation()}})):y(X,l({htmlTag:"input",type:"text",inputMode:"numeric","data-show-validation":z.isShowValidation(T,n,!!u),"data-input-origin":n.componentID,"data-disabled":e.disabled,value:n.formatValue,className:o,tabIndex:re.get().isTouchDevice?-1:0,onKeyDown:g=>{O.KeyDownEvent({restrict:a,event:g,val_era:p,val_status:n,set_status:c,val_focus:P,set_focus:U}),b&&b(g),i&&z.SubmitForm(g,h)},onKeyUp:g=>{g.key=="Tab"&&U(x=>k(l({},x),{active:!0}))},onClick:g=>{let x=g.target.selectionEnd,A=0;n.ranges.forEach((M,J)=>{let{from:te,length:se,region:me}=M;te<=x&&x<=te+(me||se)&&(A=J)}),U(M=>k(l({},M),{active:!0,index:A})),g.preventDefault()},onChange:()=>{}},_))]})},V={Origin:e=>{let t=l({fontSize:"inherit",width:1},e),[D]=W(e.componentID||N());if(t.componentID=D,G.is.nullish(t.rightIcon)){let a=(e.restrict||"").match(/clock/)?De:ve;t.rightIcon=y(xe,{ssSphere:2,freeCSS:{pointerEvents:"all"},children:y(ie.Sub,{color:"cloud",border:"unset",ssSphere:2,fontColor:"theme",boxShadow:"0.normal",borderRadius:"3.tone.tertiary",flexCenter:!0,ssEffectsOnActive:"push",tabIndex:-1,id:"Picker-"+t.componentID,onClick:()=>{let d=L.get(t.componentID);d&&d.openPicker("#Picker-"+t.componentID)},children:y(de,{icon:a})})})}return y(Ie,{componentID:t.componentID,children:Ve,states:Te(t)})},Clock:e=>y(V.Origin,l({restrict:"clock",era:"clock"},e)),Date:e=>y(V.Origin,l({restrict:"date"},e)),Week:e=>y(V.Origin,l({restrict:"week"},e)),Month:e=>y(V.Origin,l({restrict:"month"},e)),Year:e=>y(V.Origin,l({restrict:"year"},e)),DateWareki:e=>{e=l({},e);let[t]=W(e.componentID||N());e.componentID=t;let{defaultEra:D="wareki"}=e,[a,d]=W((()=>{let f="year";if(D=="wareki"&&(f="reiwa",e.value)){let[h,v,r]=e.value.split(/\D/);if(h&&v&&r){let m=Number(h);m>=2019?(m-=2019,f="reiwa"):m>=1989?(m-=1989,f="heisei"):m>=1926?(m-=1926,f="shouwa"):m>=1912?(m-=1912,f="taisho"):m>=1868&&(m-=1868,f="meiji"),m+=1}}return f})());return Q(()=>{L.set({["refreshEra_"+t]:{refreshEra:f=>{d(f)}}})},[]),y(V.Origin,k(l({restrict:"dateWareki",leftIndicator:y(be,{label:"\u5143\u53F7",emptySelect:!1,value:a,tone:e.tone||"border",override:"force",flexCenter:!0,borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",height:1,freeCSS:{whiteSpace:"nowrap"},options:[{value:"year",label:"\u897F\u66A6"},{value:"reiwa",label:"\u4EE4\u548C"},{value:"heisei",label:"\u5E73\u6210"},{value:"shouwa",label:"\u662D\u548C"},{value:"taisho",label:"\u5927\u6B63"},{value:"meiji",label:"\u660E\u6CBB"}],onUpdateValidValue:f=>{d(f);let h=L.get(e.componentID);h&&h.resetEra&&h.resetEra(f)}})},e),{era:a}))},Periods:{Date:e=>y(V.Origin,l({restrict:"dates"},e)),Month:e=>y(V.Origin,l({restrict:"months"},e))},fn:ne};export{V as Time,V as default};
|
|
1
|
+
import{a as ae,b as l,c as k,d as q}from"../../../chunk-C5N2D3ZX.js";import{Fragment as _e,jsx as y,jsxs as oe}from"react/jsx-runtime";import G,{UUID as N,useStore as L}from"jmini";import*as K from"jmini";import{useState as W,useEffect as Q,useRef as ce}from"react";import{$$fromRoot as pe,Config as re,ExtractStyles as ue}from"../../../@utils";import{Box as X,FAI as de}from"../../../atoms";import{Literal as fe,Row as he}from"../../../mols";import{Button as ie}from"../../Button";import ge from"../../Tooltips";import ye from"../../Sheet";import{faClock as De}from"@fortawesome/free-solid-svg-icons/faClock";import{faCalendarAlt as ve}from"@fortawesome/free-solid-svg-icons/faCalendarAlt";import{OptionalInputWrapper as Ie,BoxWrapper as Se,CoreEffects as z,DefaultBoxishStyles as Te}from"../core";import{RightIcon as be}from"..";import xe from"../Select";import{InputLabel as ke}from"../Label";import Ee from"./Picker";const F=" ~ ",we={clock:{defaultValue:"--:--",format:/^\d{2}\D\d{2}$/,ranges:[{type:"hour",from:0,length:2},{type:"minute",from:3,length:2}],sets:1},date:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2}],sets:1},week:{defaultValue:"----\u5E74\u7B2C--\u9031",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4,region:6},{type:"week",from:6,length:2,region:3}],sets:1},month:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:3}],sets:1},year:{defaultValue:"----\u5E74",format:/^\d{4}$/,ranges:[{type:"year",from:0,length:4,region:5}],sets:1},dates:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2,region:5},{type:"year",from:10+F.length,length:4},{type:"month",from:15+F.length,length:2},{type:"date",from:18+F.length,length:2}],sets:2},months:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:6},{type:"year",from:8+F.length,length:4},{type:"month",from:13+F.length,length:2,region:3}],sets:2},dateWareki:{defaultValue:"----\u5E74--\u6708--\u65E5",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"dateWareki",from:0,length:4,region:5},{type:"month",from:5,length:2,region:3},{type:"date",from:8,length:2,region:3}],sets:1}},O={PeriodMargin:" ~ ",DataLeveling:e=>{let{restrict:t,value:D,era:a}=e,d=G.flatArray(D||""),{defaultValue:f,format:h,ranges:v,sets:r}=we[t],m=[],o=t=="clock"?":":"/";for(let i=0;i<d.length;i++)d[i]=String(d[i]).replace(/\D/ig,o);for(let i=0;i<r;i++){let u=d[i]||"";if(!u.match(h))d[i]="",m.push(f);else{let x=f;u.split(/\D/).forEach((E,R)=>{if(R==0&&t=="dateWareki"){let S=Number(E);a!="year"&&(S>=2019?a=="reiwa"?S-=2018:a=="heisei"&&(S=31):S>=1989?a=="heisei"?S-=1988:a=="shouwa"&&(S=64):S>=1926?a=="shouwa"?S-=1925:a=="taisho"&&(S=15):S>=1912?a=="taisho"?S-=1911:a=="meiji"&&(S=45):S>=1868&&(S-=1867)),E=S.zeroEmbed(4)}x=x.replace(new RegExp("------------------".slice(0,E.length)),E)}),m.push(x)}}return{formatValue:m.join(F),dataValue:["dates","months"].includes(t)?d:d[0],ranges:v}},SystemValidation:e=>{let{states:t}=e,{restrict:D,min:a,max:d,required:f}=t,h=[],v=G.flatArray(e.value),r={empty:!1,escalated:1,filled:!0,correct:!0,prohibited:!1};(()=>{let m=D=="clock"?":":"/";for(let o=0;o<v.length;o++)v[o]=String(v[o]).replace(/\D/ig,m);for(let o=0;o<v.length;o++){let i=v[o],u=v[o-1];i.removeLetters()||(r.empty=!0),o>0&&(r.escalated&=+(i>=u))}r.escalated&&(r.empty||(D.match(/clock/)?v.forEach(o=>{let[i,u]=o.split(/\D+/);!i||!u?r.filled=!1:(Number(i)>23||Number(u)>59)&&(r.correct=!1)}):D.match(/date/)?v.forEach(o=>{let[i,u,x]=o.split(/\D+/);if(!i||!u||!x)r.filled=!1;else{let E=K.Time(o);(!E.validate||o!=E.toFormatYMD())&&(r.correct=!1)}}):D.match(/week/)?v.forEach(o=>{let[i,u]=o.split(/\D+/);if(!i||!u)r.filled=!1;else{let x=K.Time(i+"/01/01").weekday,R=K.Time(i+"/01/0"+(7-x+1)).addWeek(Number(u)-1);i!=String(R.year)&&(r.correct=!1)}}):D.match(/month/)?v.forEach(o=>{let[i,u]=o.split(/\D+/);!i||!u?r.filled=!1:K.Time([i,u,"01"].join("/")).validate||(r.correct=!1)}):D.match(/year/),r.filled&&r.correct&&v.forEach(o=>{{let i=Number(String(o).replace(/\D/ig,""));if(a&&Number(String(a).replace(/\D/ig,""))>i&&(r.prohibited=!0),d){let u=Number(String(d).replace(/\D/ig,""));i>u&&(r.prohibited=!0)}}})))})();{let{empty:m,escalated:o,filled:i,correct:u,prohibited:x}=r;m&&f&&(h=[{type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}]),o||h.push({type:"invalid",label:"\u6642\u7CFB\u5217\u3092\u6B63\u3057\u304F\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),u||h.push({type:"invalid",label:"\u7121\u52B9\u306A\u5024\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u3059"}),i||h.push({type:"invalid",label:"\u6700\u5F8C\u307E\u3067\u5024\u3092\u57CB\u3081\u3066\u304F\u3060\u3055\u3044"}),x&&h.push({type:"invalid",label:oe(_e,{children:[y(X,{children:"\u5165\u529B\u7BC4\u56F2\u304C\u5236\u9650\u3055\u308C\u3066\u3044\u307E\u3059"}),"[",a||"\u4E0B\u9650\u7121\u3057","] ~ [",d||"\u4E0A\u9650\u7121\u3057","]"]})})}return{ok:!h.filter(({type:m})=>m=="invalid").length,notice:h}},KeyDownEvent:e=>{let{val_era:t,restrict:D,event:a,val_status:d,set_status:f,val_focus:h,set_focus:v}=e,{key:r,shiftKey:m,ctrlKey:o,metaKey:i}=a,u=o||i,{selectionStart:x,selectionEnd:E}=a.target,{index:R,prevIndex:S}=h,{ranges:$,formatValue:H}=d,C=$.length-1;if(["Tab","ArrowLeft","ArrowRight"].includes(r)){let I=0;if(r=="Tab"){let s=+!m*2-1;if(I=h.index+s,I<0||I>C)return}else{let s=r=="ArrowLeft"?-1:r=="ArrowRight"?1:0;u||x==0&&E==String(d.formatValue).length?I=s==1?C:0:I=Math.max(0,Math.min(R+s,C))}v(s=>k(l({},s),{index:I,prevIndex:R})),a.preventDefault()}if(["Backspace","ArrowUp","ArrowDown","0","1","2","3","4","5","6","7","8","9"].includes(r)){a.preventDefault();let I=R;I=Math.max(I,0),I=Math.min(I,C);let{type:s,from:B,length:Y}=$[I],_=H.slice(B,B+Y),p;if(r=="Backspace")p="------".slice(0,Y);else if(["ArrowUp","ArrowDown"].includes(r)){let w=r=="ArrowUp"?1:-1;_=_|0,p=_+w;let[n,c,T]=s=="dateWareki"?t=="year"?[0,2999,4]:t=="reiwa"?[1,2999,4]:t=="heisei"?[1,31,4]:t=="shouwa"?[1,64,4]:t=="taisho"?[1,15,4]:t=="meiji"?[1,45,4]:[0,0,0]:s=="minute"?[0,59,2]:s=="hour"?[0,23,2]:s=="date"?[1,31,2]:s=="week"?[1,53,2]:s=="month"?[1,12,2]:s=="year"?[0,2999,4]:[0,0,0];p>c?p=n:p<n&&(p=c),p=Number(p).zeroEmbed(T)}else if(["0","1","2","3","4","5","6","7","8","9"].includes(r)){let w=_|0,n=r,c=`${w}${n}`;if(S!=R&&(w=0,c="0"+n),s=="year"||s=="dateWareki"&&t=="year")Number(c)>1e4?p=n:p=c,(p|0)>1e3&&I++;else if(["hour","minute","date","week","month"].includes(s)||s=="dateWareki"&&t!="year"){let T=s=="dateWareki"?t=="reiwa"?100:t=="heisei"?31:t=="shouwa"?64:t=="taisho"?15:t=="meiji"?45:0:s=="minute"?59:s=="hour"?23:s=="date"?31:s=="week"?53:s=="month"?12:0;p=(c|0)>T?n:c,(Number(n)>Number(String(T)[0])||_=="0000".slice(0,String(T).length)&&(c!="0000".slice(0,String(T).length)||["minute","hour"].includes(s)&&S==R)||(c|0)>=ae(10,String(T).length-1))&&I++}s=="year"||s=="dateWareki"?p=(p|0).zeroEmbed(4):p=(p|0).zeroEmbed(2)}{let w=String(H).partReplace(B,String(p)),n=w.split(F).map(c=>c.replace(/(^\D|\D$)/,"").split(/\D+/).join(D=="clock"?":":"/").replace(/(^\D|\D$)/,""));if(D=="dateWareki"){let c=n[0].split(/\D/),[T,j,P]=c;c.length==3&&T&&(n=[[Number(T)-1+Number({year:1,reiwa:2019,heisei:1989,shouwa:1926,taisho:1912,meiji:1868}[t]),j,P].join("/")])}I=Math.max(I,0),I=Math.min(I,C),f(c=>k(l({},c),{dataValue:["dates","months"].includes(D)?n:n[0],formatValue:w,eventType:"update",eventID:N()})),v(c=>k(l({},c),{index:I,prevIndex:c.index}))}}}},ne={picker:{launch:e=>{let t=e.sheetID||N(),m=e,{onValueUpdate:D,min:a,max:d,era:f,restrict:h,defaultValue:v}=m,r=q(m,["onValueUpdate","min","max","era","restrict","defaultValue"]);ye.open(k(l({sheetID:t,type:"normal.middleCenter",size:"S",padding:0,closeAtAroundClick:!0,closeAtParentBlur:!1},r),{content:y(he.Center,{children:y(Ee,{restrict:h,min:a,max:d,era:f,defaultValue:v,sheetID:t,onValueUpdate:(o,i)=>{D(o,i)}})})}))},remove:e=>{ge.close(e)}}},Re={Shallow:e=>{let{rootStates:t,val_status:D}=e,a=ue(t);return y(X,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:y(fe.Description,k(l({className:t.className},a),{position:"absolute",width:1,freeCSS:k(l({},a.freeCSS),{color:"orange"}),children:y(X,{"data-input-value-shallow":D.componentID,children:"A"})}))})}},Ve=e=>{let ee=e,{tone:t,required:D,restrict:a="clock",componentID:d,era:f,form:h,name:v,min:r,max:m,className:o,enableFormSubmit:i,checkValidationAtFirst:u,onKeyDown:x,onValidate:E,onUpdateValue:R,onUpdateValidValue:S,value:$="",leftIndicator:H,rightIndicator:C,leftIcon:I,rightIcon:s,freeCSS:B,wrapStyles:Y}=ee,_=q(ee,["tone","required","restrict","componentID","era","form","name","min","max","className","enableFormSubmit","checkValidationAtFirst","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","freeCSS","wrapStyles"]),[p,w]=W(f),[n,c]=W(k(l({componentID:e.componentID||""},O.DataLeveling({restrict:a,value:$,era:p})),{eventType:"init",eventID:N()})),[T,j]=W({ok:!1,notice:[]}),[P,U]=W({active:!1,index:0,prevIndex:-1}),le={rootStates:e,val_status:n,set_status:c,val_validate:T,set_validate:j,val_era:p,set_era:w,val_focus:P,set_focus:U};z.CommonEffects({type:"time",states:e,val_status:n,set_status:c,val_validate:T,set_validate:j,SystemValidation:O.SystemValidation,ExtraOverrideStates:l({},O.DataLeveling({restrict:a,value:$,era:p}))});const Z=ce(!1);return Q(()=>{if(Z.current){c(b=>l(l({},b),O.DataLeveling({restrict:a,value:b.dataValue,era:p})));let g=L.get("refreshEra_"+n.componentID);g&&g.refreshEra(p)}else Z.current=!0},[p]),L.update({[n.componentID]:{openPicker:g=>{e.disabled||ne.picker.launch({parent:g,sheetID:"PickerTips-"+n.componentID,restrict:a,min:r,max:m,defaultValue:n.dataValue,era:p,onValueUpdate:(b,A)=>{c(M=>k(l(l({},M),O.DataLeveling({restrict:a,value:b,era:A})),{eventType:"update",eventID:N()})),w(A)}})},resetEra:g=>{w(g),c(b=>k(l(l({},b),O.DataLeveling({restrict:a,value:"",era:p})),{eventType:"update",eventID:N()}))}}}),Q(()=>{let{index:g,active:b}=P;if(b){g=Math.max(g,0),g=Math.min(g,n.ranges.length-1);let{from:A,length:M}=n.ranges[g],J=pe("#"+e.id)[0];J&&J.setSelectionRange(A,A+M)}},[P]),oe(Se,{val_status:n,set_status:c,val_validate:T,states:e,children:[y(Re.Shallow,l({},le)),y(ke,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:!0}),re.get().isTouchDevice?y(ie.Plain,k(l({"data-show-validation":z.isShowValidation(T,n,!!u),"data-component-id":n.componentID,"data-input-origin":n.componentID,"data-disabled":e.disabled,className:o,freeCSS:{textAlign:"left"}},_),{children:n.formatValue,onClick:g=>{let b=L.get(n.componentID);b&&b.openPicker(`[data-input-origin="${n.componentID}"]`),g.stopPropagation()}})):y(X,l({htmlTag:"input",type:"text",inputMode:"numeric","data-show-validation":z.isShowValidation(T,n,!!u),"data-input-origin":n.componentID,"data-disabled":e.disabled,value:n.formatValue,className:o,tabIndex:re.get().isTouchDevice?-1:0,onKeyDown:g=>{O.KeyDownEvent({restrict:a,event:g,val_era:p,val_status:n,set_status:c,val_focus:P,set_focus:U}),x&&x(g),i&&z.SubmitForm(g,h)},onKeyUp:g=>{g.key=="Tab"&&U(b=>k(l({},b),{active:!0}))},onClick:g=>{let b=g.target.selectionEnd,A=0;n.ranges.forEach((M,J)=>{let{from:te,length:se,region:me}=M;te<=b&&b<=te+(me||se)&&(A=J)}),U(M=>k(l({},M),{active:!0,index:A})),g.preventDefault()},onChange:()=>{}},_))]})},V={Origin:e=>{let t=l({fontSize:"inherit",width:1},e),[D]=W(e.componentID||N());if(t.componentID=D,G.is.nullish(t.rightIcon)){let a=(e.restrict||"").match(/clock/)?De:ve;t.rightIcon=y(be,{ssSphere:2,freeCSS:{pointerEvents:"all"},children:y(ie.Sub,{color:"cloud",border:"unset",ssSphere:2,fontColor:"theme",boxShadow:"0.normal",borderRadius:"3.tone.tertiary",flexCenter:!0,ssEffectsOnActive:"push",tabIndex:-1,id:"Picker-"+t.componentID,onClick:()=>{let d=L.get(t.componentID);d&&d.openPicker("#Picker-"+t.componentID)},children:y(de,{icon:a})})})}return y(Ie,{componentID:t.componentID,children:Ve,states:Te(t)})},Clock:e=>y(V.Origin,l({restrict:"clock",era:"clock"},e)),Date:e=>y(V.Origin,l({restrict:"date"},e)),Week:e=>y(V.Origin,l({restrict:"week"},e)),Month:e=>y(V.Origin,l({restrict:"month"},e)),Year:e=>y(V.Origin,l({restrict:"year"},e)),DateWareki:e=>{e=l({},e);let[t]=W(e.componentID||N());e.componentID=t;let{defaultEra:D="wareki"}=e,[a,d]=W((()=>{let f="year";if(D=="wareki"&&(f="reiwa",e.value)){let[h,v,r]=e.value.split(/\D/);if(h&&v&&r){let m=Number(h);m>=2019?(m-=2019,f="reiwa"):m>=1989?(m-=1989,f="heisei"):m>=1926?(m-=1926,f="shouwa"):m>=1912?(m-=1912,f="taisho"):m>=1868&&(m-=1868,f="meiji"),m+=1}}return f})());return Q(()=>{L.set({["refreshEra_"+t]:{refreshEra:f=>{d(f)}}})},[]),y(V.Origin,k(l({restrict:"dateWareki",leftIndicator:y(xe,{label:"\u5143\u53F7",emptySelect:!1,value:a,tone:e.tone||"border",override:"force",flexCenter:!0,borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",height:1,freeCSS:{whiteSpace:"nowrap"},options:[{value:"year",label:"\u897F\u66A6"},{value:"reiwa",label:"\u4EE4\u548C"},{value:"heisei",label:"\u5E73\u6210"},{value:"shouwa",label:"\u662D\u548C"},{value:"taisho",label:"\u5927\u6B63"},{value:"meiji",label:"\u660E\u6CBB"}],onUpdateValidValue:f=>{d(f);let h=L.get(e.componentID);h&&h.resetEra&&h.resetEra(f)}})},e),{era:a}))},Periods:{Date:e=>y(V.Origin,l({restrict:"dates"},e)),Month:e=>y(V.Origin,l({restrict:"months"},e))},fn:ne};export{V as Time,V as default};
|
package/dist/fn/Input/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as o,c as d,e as b}from"../../chunk-C5N2D3ZX.js";import{jsx as p,jsxs as
|
|
1
|
+
import{b as o,c as d,e as b}from"../../chunk-C5N2D3ZX.js";import{jsx as p,jsxs as T}from"react/jsx-runtime";import{useState as x,useEffect as g}from"react";import c,{UUID as y,useStore as v}from"jmini";import{$$fromRoot as k,Config as B}from"../../@utils";import{InputClasses as _}from"../../@styles/componentClasses";import{Box as E,Flex as w,FAI as R,Column as N}from"../../atoms";import{Row as D,Literal as F}from"../../mols";import{Button as L}from"../Button";import h from"../Tooltips";const et=t=>{let[n]=x(t.componentID||y());t=o({},t),t.states=d(o({enableFormSubmit:!0,status_id:y(),override:"never",form:"",id:y(),"aria-label":"Input-"+n},t.states),{componentID:n});let{children:e}=t;return p(e,o({},t.states))},at=t=>{let{children:n,val_status:e,val_validate:a,states:i}=t,{leftIcon:l,wrapStyles:s}=i;return e.eventType=="init"&&!i.checkValidationAtFirst&&(a.notice=[]),T(D.Center,d(o({position:"relative",verticalAlign:"unset",gap:0},s),{className:_("Wrapper"),"data-notice-uid":e.componentID,children:[p(C.Notice,{notice:a.notice,val_status:e}),i.leftIndicator,T(w,{position:"relative",flexSizing:"auto",children:[n,l,p(C.RightIcon,o({},t)),p(C.ClearButton,o({},t))]}),i.rightIndicator]}))},C={ClearButton:t=>!t.states.clearButton||!t.val_status.dataValue?null:p(L.Normal,{ssSphere:2,flexCenter:!0,fontColor:"5.translucent",ssEffectsOnActive:["ripple.theme"],position:"absolute",right:1,top:"50%",freeCSS:{zIndex:3,transform:"translateY(-50%)"},onClick:()=>{t.set_status(n=>d(o({},n),{dataValue:"",formatValue:"",eventType:"update",eventID:y()}))},children:p(R.Times,{})}),RightIcon:t=>t.states.clearButton&&t.val_status.dataValue?null:t.states.rightIcon,Notice:t=>{let{notice:n,val_status:e}=t,{componentID:a}=e,i="NoticeTimer-"+a,l="NoticeTimerClose-"+a,s="notice-tips-"+a;return g(()=>{c.interval.once(()=>{if(!n.length){h.close(s);return}h.open({tipsID:s,parent:`[data-notice-uid="${a}"]`,gravityPoint:22,padding:[1,0],closeAtParentBlur:!1,content:T(h.Body,{padding:["1/2","2/3"],fontSize:"1.mini",position:"relative",children:[p(E,{position:"absolute",unitHeight:1,unitWidth:1,left:1,backgroundColor:"dark",freeCSS:{zIndex:1,transform:"rotate(45deg)",top:-6}}),p(N,{backgroundColor:"inherit",gap:"1/3",position:"relative",freeCSS:{zIndex:2},children:n.map((I,S)=>{let{type:r,label:u}=I,f=r=="invalid"?R.Times:r=="warn"?R.Exclamation:R.Check;return T(D.Left,{gap:0,borderRadius:"2.tone.secondary",children:[p(f,{flexCenter:!0,fontSize:"2.normal",fontColor:{invalid:"nega",warn:"warn",valid:"posi"}[r]}),p(F.Supplement,{fontSize:"0.xs",fontColor:"white",children:u})]},S+"-"+c.Stringify(I))})})]})})},350,i),c.interval.once(()=>{h.close(s)},6e3,l)},[n]),null}},W={DefaultStatus:(t,n)=>({componentID:t,dataValue:n,eventType:"init",eventID:y()}),CommonEffects:function(t){let{type:n,states:e,val_status:a,set_status:i,val_validate:l,set_validate:s,SystemValidation:I}=t;e=o({},e);let{componentID:S}=a;g(()=>(v.update({[S]:{ResolveRefresh:null,Refresh:()=>new Promise((r,u)=>{v.get(S).ResolveRefresh=r,i(f=>d(o({},f),{eventType:"refresh",eventID:y()}))}),GenNotice:r=>{let{ok:u,notice:f}=r;s({ok:u,notice:f})}}}),()=>{v.delete(S)}),[]),c.scope(()=>{let{override:r}=e;if(r=="never"||r=="beforeModified"&&!["init","override"].includes(a.eventType))return;let u=v.get(a.componentID);u&&(e.value!=a.dataValue&&e.status_id!=u.status_id&&i(f=>d(o(d(o({},f),{dataValue:e.value}),t.ExtraOverrideStates),{eventType:"override",eventID:y()})),u.status_id=e.status_id)}),g(()=>{W.ValidationCheck({val_status:a,set_validate:s,SystemValidation:I,states:e})},[a.eventID,a.dataValue]),g(()=>(c.scope(()=>{let{componentID:r,eventType:u,dataValue:f}=a,m=f;if(n=="autocomplete.single"||n=="list.radio"?m=m[0]:e.isChecker&&(m=!!m[0]),e.form=e.form||"testForm",e.name&&e.form&&v.update({[["form-data",e.form].join("-")]:{[e.name]:{componentID:r,type:n,value:m,validation:l.ok}}}),u=="refresh"){let V=v.get(r);V&&V.ResolveRefresh&&V.ResolveRefresh(null)}else u=="update"&&(e.onUpdateValue&&e.onUpdateValue(m,u,r),c.scope(()=>{l.ok&&e.onUpdateValidValue&&e.onUpdateValidValue(m,u,r)}))}),()=>{v.update({[["form-data",e.form].join("-")]:{[e.name]:null}})}),[l])},ValidationCheck:t=>{let{states:n}=t,e="ValidationTimer-"+t.val_status.componentID;c.interval.abort(e);let a=t.SystemValidation({value:t.val_status.dataValue,states:n});if(!a.ok){t.set_validate(a);return}let i=a.notice;const l=()=>b(void 0,null,function*(){if(!n.onValidate)return;let s=yield n.onValidate(t.val_status.dataValue,t.val_status.eventType,t);t.set_validate({ok:s.ok,notice:[...i,...s.notice]})});if(n.onValidate){if(t.val_status.eventType=="refresh"){l();return}c.interval.once(l,450,e);return}t.set_validate({ok:!0,notice:i})},SubmitForm:(t,n)=>{let e=!1;if(!n)return e;let a=k(`[data-form-submit-button="${n}"]`)[0];if(!a)return e;let i=a.dataset.sdfike||"",l=t.key,s=t.ctrlKey||t.metaKey;return c.scope(()=>{i.includes("enter")&&(l!="Enter"||t.nativeEvent.isComposing||B.get().browserIs=="safari"&&t.keyCode==229)||((l=="Enter"&&(i.includes("enter")||i.includes("auxEnter")&&s)||l==" "&&i.includes("space"))&&(a.click(),t.preventDefault()),e=!0)}),e},isShowValidation:(t,n,e)=>{let a=t.ok;return!e&&n.eventType=="init"&&(a=!0),a}},nt=function(t){t=o({tone:"border"},t);let n=c.scope(()=>{if(t.tone=="plain")return{};let a={padding:"3/4",transition:"middle",flexSizing:"auto",boxShadow:"0.min"};return t.tone=="border"?a=d(o({},a),{border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"}):t.tone=="cloud"?a=d(o({},a),{border:"1.thin",borderRadius:"2.tone.secondary",backgroundColor:"cloud"}):t.tone=="bottomBorder"&&(a=d(o({},a),{borderRadius:0,border:"unset",borderBottom:!0,backgroundColor:"cloud"})),a});return d(o(o(o(o(o(o({fontColor:"2.normal"},n),!!t.rightIcon&&{paddingRight:3}),!!t.leftIcon&&{paddingLeft:3}),!!t.leftIndicator&&{borderTopLeftRadius:"2/3",borderBottomLeftRadius:"2/3",marginLeft:"1/4"}),!!t.rightIndicator&&{borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",marginRight:"1/4"}),t),{freeCSS:o({letterSpacing:"1px",resize:"none"},t.freeCSS),className:[_("Input"),t.className].join(" ")})};export{at as BoxWrapper,W as CoreEffects,nt as DefaultBoxishStyles,et as OptionalInputWrapper};
|
package/dist/fn/PageNotFound.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunk-C5N2D3ZX.js";import{jsx as o,jsxs as e}from"react/jsx-runtime";import{Box as
|
|
1
|
+
import"../chunk-C5N2D3ZX.js";import{jsx as o,jsxs as e}from"react/jsx-runtime";import{Box as r,FAI as d,Column as a}from"../atoms";import{Row as m,Literal as t}from"../mols";import{Anchor as i}from"./Button";const l=()=>{let{href:n}=location;return o(m.Center,{padding:[4,1],children:e(a,{ssCardBox:!0,gap:2,padding:[3,2],textAlign:"center",width:1,freeCSS:{maxWidth:12*30},children:[o(d.LinkSlash,{fontColor:"theme",freeCSS:{fontSize:"3rem"}}),e(r,{children:[o(t.Paragraph,{children:"\u3053\u306E\u30DA\u30FC\u30B8\u306F\u3054\u5229\u7528\u3044\u305F\u3060\u3051\u307E\u305B\u3093\u3002"}),o(t.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"})]}),e(a,{children:[e(t,{textAlign:"left",ssCardBox:"cloud",isSemiBoldFont:!0,padding:1,children:["\u30FB\u30EA\u30F3\u30AF\u304C\u6B63\u3057\u3044\u304B",o(r,{margin:["1/2",0],borderBottom:!0}),"\u30FB\u30EA\u30F3\u30AF\u306E\u6709\u52B9\u671F\u9650",o(r,{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};
|
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{
|
|
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 e}from".";const t={uid:a(),open:(o,r,p=24,d=.35)=>{o&&i.interval.once(()=>{e.open({tipsID:t.uid,parent:o,gravityPoint:p||24,padding:"1/2",content:n(e.Body,{padding:"1/2",borderRadius:"3.tone.tertiary",children:n(m.Supplement,{children:r})})})},d*1e3,t.uid)},abort:()=>{i.interval.abort(t.uid),e.close(t.uid)}};export{t as Tips};
|
package/dist/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ declare const amotify: {
|
|
|
45
45
|
List: import("react").FC<mols.List.Input>;
|
|
46
46
|
ListItem: mols.ListItem.Methods;
|
|
47
47
|
Row: mols.Row.Methods;
|
|
48
|
-
|
|
48
|
+
Literal: mols.Literal.Methods;
|
|
49
49
|
Span: import("react").FC<atoms.Span.Input>;
|
|
50
50
|
P: import("react").FC<atoms.P.Input>;
|
|
51
51
|
Grid: import("react").FC<atoms.Box.DefaultInput>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { StyleTags, ReactElement } from '../@declares';
|
|
3
3
|
import { Box, Span } from '../atoms';
|
|
4
|
-
declare namespace
|
|
4
|
+
declare namespace Literal {
|
|
5
5
|
type Input = StyleTags.BasicElement & {
|
|
6
6
|
children?: ReactElement;
|
|
7
7
|
} & React.HTMLAttributes<HTMLDivElement>;
|
|
@@ -21,5 +21,5 @@ declare namespace Text {
|
|
|
21
21
|
}
|
|
22
22
|
type Methods = Methods.Component & Methods.FNs;
|
|
23
23
|
}
|
|
24
|
-
declare const
|
|
25
|
-
export {
|
|
24
|
+
declare const Literal: Literal.Methods;
|
|
25
|
+
export { Literal, Literal as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as e,c as n}from"../chunk-C5N2D3ZX.js";import{jsx as a}from"react/jsx-runtime";import{Box as i,Span as l}from"../atoms";const p=t=>a(i,e({},t)),o=p;o.Title=t=>a(p,e({fontSize:"6.title",fontWeight:"3.semiBold"},t)),o.SubTitle=t=>a(p,e({fontSize:"5.subTitle",fontWeight:"3.semiBold"},t)),o.ThirdTitle=t=>a(p,e({fontSize:"4.thirdTitle",fontWeight:"3.semiBold"},t)),o.Paragraph=t=>a(p,e({fontSize:"3.paragraph",fontWeight:"3.semiBold"},t)),o.Description=t=>a(p,n(e({},t),{freeCSS:e({whiteSpace:"pre-wrap"},t.freeCSS)})),o.Supplement=t=>a(p,e({fontSize:"1.mini"},t)),o.NowrapSpan=t=>a(l,n(e({},t),{freeCSS:e({whiteSpace:"nowrap"},t.freeCSS)}));export{o as Literal,o as default};
|
package/dist/mols/index.d.ts
CHANGED