amotify 0.2.267 → 0.2.269
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a,c as ke,d as Ne}from"../chunk-C5N2D3ZX.js";import d from"jmini";import{Config as Fe}from".";const e={toConcreteBorderRadius:n=>{let A=Fe.get().roundness|0;return n=="1.tone.primary"?n=[0,2,3,4,5,5][A]:n=="2.tone.secondary"?n=[0,1,2,3,4,5][A]:n=="3.tone.tertiary"&&(n=[0,"1/3","2/3",1,2,3][A]),n},ev:n=>d.is.exist(n),ClassNames:(n,A)=>{var O,Re,Ce,N,Be,Te,_e,Le,we,We;let i=[],{gap:l,display:R,position:C,overflow:P,fontColor:E,fontSize:G,fontWeight:j,fontHeight:g,backgroundColor:q,textAlign:H,textDecoration:M,boxShadow:D,margin:p,marginTop:S,marginRight:o,marginBottom:r,marginLeft:y,padding:f,paddingTop:s,paddingRight:x,paddingBottom:B,paddingLeft:T,top:X,right:J,bottom:Q,left:Y,border:z,borderTop:u,borderRight:v,borderBottom:m,borderLeft:b,borderWidth:Z,borderColor:ee,borderStyle:te,borderRadius:k,borderTopLeftRadius:_,borderTopRightRadius:L,borderBottomLeftRadius:w,borderBottomRightRadius:W,flexSizing:ie,flexWrap:re,flexType:oe,flexChilds:se,flexGrid:ae,horizontalAlign:de,verticalAlign:ne,transition:le,gridCenter:ge,gridCols:pe,maxHeight:he,minHeight:fe,maxWidth:ue,minWidth:ve,width:me,height:be,unitHeight:Se,unitWidth:xe,opacity:ce}=A;{if(e.ev(R)&&i.push("dsp"+R),P){let c=d.flatArray(P);i.push("ovfl-x-"+c[0]),i.push("ovfl-y-"+(c[1]||c[0]))}e.ev(C)&&i.push("ps"+C),e.ev(H)&&i.push("txtalg"+H),e.ev(H)&&i.push("txtdeco"+M),e.ev(E)&&i.push("ftcl"+((O=String(E))==null?void 0:O.replace(/\./g,"_"))),e.ev(G)&&i.push("ftsz"+((Re=String(G))==null?void 0:Re.replace(/\..*/,""))),e.ev(j)&&i.push("ftwgt"+((Ce=String(j))==null?void 0:Ce.replace(/\..*/,""))),e.ev(g)&&i.push("fthgt"+((N=String(g))==null?void 0:N.replace(/\./g,"_"))),e.ev(q)&&i.push("bgc"+((Be=String(q))==null?void 0:Be.replace(/\./g,"_"))),e.ev(D)&&i.push("bs"+D);let U,$,V,I;d.is.exist(p)&&(d.is.array(p)?p.length==2?[U,$,V,I]=[...p,...p]:p.length==4&&([U,$,V,I]=p):U=$=V=I=p,S=S!=null?S:U,o=o!=null?o:$,r=r!=null?r:V,y=y!=null?y:I),e.ev(S)&&i.push("mrgt"+S),e.ev(o)&&i.push("mrgr"+o),e.ev(r)&&i.push("mrgb"+r),e.ev(y)&&i.push("mrgl"+y);let K,t,Ae,ye;d.is.exist(f)&&(d.is.array(f)?f.length==2?[K,t,Ae,ye]=[...f,...f]:f.length==4&&([K,t,Ae,ye]=f):K=t=Ae=ye=f,s=s!=null?s:K,x=x!=null?x:t,B=B!=null?B:Ae,T=T!=null?T:ye),e.ev(s)&&i.push("pdt"+s),e.ev(x)&&i.push("pdr"+x),e.ev(B)&&i.push("pdb"+B),e.ev(T)&&i.push("pdl"+T),e.ev(X)&&i.push("pstt"+X),e.ev(J)&&i.push("pstr"+J),e.ev(Q)&&i.push("pstb"+Q),e.ev(Y)&&i.push("pstl"+Y);{d.is.exist(z)&&(u=u!=null?u:z,v=v!=null?v:z,m=m!=null?m:z,b=b!=null?b:z),d.is.boolean(u)&&(u=["unset","2.normal"][Number(u)]),d.is.boolean(v)&&(v=["unset","2.normal"][Number(v)]),d.is.boolean(m)&&(m=["unset","2.normal"][Number(m)]),d.is.boolean(b)&&(b=["unset","2.normal"][Number(b)]),e.ev(u)&&i.push("b_t_ss"+((Te=String(u))==null?void 0:Te.replace(/\./g,"_"))),e.ev(v)&&i.push("b_r_ss"+((_e=String(v))==null?void 0:_e.replace(/\./g,"_"))),e.ev(m)&&i.push("b_b_ss"+((Le=String(m))==null?void 0:Le.replace(/\./g,"_"))),e.ev(b)&&i.push("b_l_ss"+((we=String(b))==null?void 0:we.replace(/\./g,"_"))),d.is.exist(Z)&&i.push("b_wth"+String(Z)),d.is.exist(ee)&&i.push("b_cl"+((We=String(ee))==null?void 0:We.replace(/\./g,"_"))),d.is.exist(te)&&i.push("b_st"+String(te));{let c,h,F,He;d.is.exist(k)&&(d.is.array(k)?k.length==4&&([c,h,He,F]=k):c=h=F=He=k,_=_!=null?_:c,L=L!=null?L:h,w=w!=null?w:F,W=W!=null?W:He)}e.ev(_)&&i.push("br_tl"+e.toConcreteBorderRadius(_)),e.ev(L)&&i.push("br_tr"+e.toConcreteBorderRadius(L)),e.ev(w)&&i.push("br_bl"+e.toConcreteBorderRadius(w)),e.ev(W)&&i.push("br_br"+e.toConcreteBorderRadius(W))}if(e.ev(ce)&&i.push("op"+ce),d.is.exist(l)){let c,h;d.is.array(l)?(c=l[0],h=l[1]):c=h=l,i.push("gapRow"+c,"gapCol"+h)}e.ev(ie)&&i.push("flsz"+ie),e.ev(re)&&i.push("flwrp"+re),e.ev(oe)&&i.push("fltyp"+oe),e.ev(se)&&i.push("flchld"+se),e.ev(ae)&&i.push("flgrid"+ae),e.ev(ne)&&i.push("flvrt"+ne),e.ev(de)&&i.push("flhrz"+de),e.ev(ge)&&i.push("grcnt"+ge),e.ev(pe)&&i.push("grcol"+pe),e.ev(be)&&i.push("hgt"+be),e.ev(me)&&i.push("wdt"+me),e.ev(Se)&&i.push("unthgt"+Se),e.ev(xe)&&i.push("untwdt"+xe),e.ev(le)&&i.push("trnst"+le),e.ev(he)&&i.push("maxh"+he),e.ev(fe)&&i.push("minh"+fe),e.ev(ue)&&i.push("maxw"+ue),e.ev(ve)&&i.push("minw"+ve)}return i.length?n+i.join(" "+n):""}},Ge=n=>{let y=a({},n),{gradients:i,ssCardBox:l,ssSphere:R,ssSquare:C,ssPushable:P,ssAbsoluteCovered:E,ssHiddenOnBreak:G,ssTextEllipsis:j,flexCenter:g,flexNewLine:q,isLightFont:H,isBoldFont:M,isSemiBoldFont:D,isRounded:p,isSquare:S,freeCSS:f={}}=y,o=Ne(f,[]),r=Ne(y,["gradients","ssCardBox","ssSphere","ssSquare","ssPushable","ssAbsoluteCovered","ssHiddenOnBreak","ssTextEllipsis","flexCenter","flexNewLine","isLightFont","isBoldFont","isSemiBoldFont","isRounded","isSquare","freeCSS"]);if(o=o||{},r=r||{},i){let{deg:s,colors:x}=i;o=ke(a({},o),{background:`linear-gradient(${s}deg,${x.join(",")})`})}if(l){l===!0&&(l="border");let s={backgroundColor:"layer.1",borderRadius:"1.tone.primary",boxShadow:"0.min"};l=="border"?s.border=!0:l=="plain"?(s.backgroundColor="layer.1",s.boxShadow="none"):l=="cloud"?s.backgroundColor="cloud":l=="shadow"&&(s.boxShadow="0.normal"),Fe.get().darkMode=="dim"&&(s.boxShadow="1.normal"),Fe.get().darkMode=="dark"&&(s.boxShadow="1.remark"),o=a(a({},s.freeCSS),o),r=a(a({},s),r)}return R&&(g=g!=null?g:!0,r=a({padding:0,unitWidth:R,unitHeight:R,borderRadius:"sphere",flexSizing:"none"},r)),C&&(g=g!=null?g:!0,r=a({padding:0,unitWidth:C,unitHeight:C,flexSizing:"none"},r)),G&&(r=a({UnderBreakPointStyles:a({display:"none"},r.UnderBreakPointStyles)},r)),P&&(r=a({transition:"middle"},r),r=ke(a({},r),{className:[r.className,"ssPushable"].join(" ")})),E&&(r=a({position:"absolute",top:0,left:0,right:0,bottom:0},r)),j&&(r=a({overflow:"hidden"},r),o=a({whiteSpace:"nowrap",textOverflow:"ellipsis"},o)),q&&(r=a({width:1,flexSizing:"none"},r)),g&&(r=a({display:"flex",horizontalAlign:"center",verticalAlign:"center"},r)),H&&(r.fontWeight="1.light"),D&&(r.fontWeight="3.semiBold"),M&&(r.fontWeight="4.bold"),p&&(r.borderRadius="sphere",d.is.number(p)&&(o.borderRadius=p*12)),S&&(o.aspectRatio="1"),ke(a({},r),{freeCSS:o})},Ue=n=>{let He=Ge(n),{componentId:i,gap:l,display:R,position:C,overflow:P,fontColor:E,fontSize:G,fontWeight:j,fontHeight:g,backgroundColor:q,textAlign:H,textDecoration:M,boxShadow:D,margin:p,marginTop:S,marginRight:o,marginBottom:r,marginLeft:y,padding:f,paddingTop:s,paddingRight:x,paddingBottom:B,paddingLeft:T,top:X,right:J,bottom:Q,left:Y,border:z,borderTop:u,borderRight:v,borderBottom:m,borderLeft:b,borderWidth:Z,borderColor:ee,borderStyle:te,borderRadius:k,borderTopLeftRadius:_,borderTopRightRadius:L,borderBottomLeftRadius:w,borderBottomRightRadius:W,flexSizing:ie,flexWrap:re,flexType:oe,flexChilds:se,flexGrid:ae,horizontalAlign:de,verticalAlign:ne,transition:le,gridCenter:ge,gridCols:pe,maxHeight:he,minHeight:fe,maxWidth:ue,minWidth:ve,width:me,height:be,unitHeight:Se,unitWidth:xe,opacity:ce,ssLastChildLossBorder:O,ssAbsoluteCovered:Re,ssCardBox:Ce,ssEffectsOnActive:N,ssPushable:Be,ssSphere:Te,ssSquare:_e,ssTextEllipsis:Le,isBoldFont:we,isLightFont:We,isSemiBoldFont:U,isRounded:$,flexCenter:V,flexNewLine:I,gradients:K,UnderBreakPointStyles:t={},className:Ae="",freeCSS:ye={}}=He,c=Ne(He,["componentId","gap","display","position","overflow","fontColor","fontSize","fontWeight","fontHeight","backgroundColor","textAlign","textDecoration","boxShadow","margin","marginTop","marginRight","marginBottom","marginLeft","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","top","right","bottom","left","border","borderTop","borderRight","borderBottom","borderLeft","borderWidth","borderColor","borderStyle","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","flexSizing","flexWrap","flexType","flexChilds","flexGrid","horizontalAlign","verticalAlign","transition","gridCenter","gridCols","maxHeight","minHeight","maxWidth","minWidth","width","height","unitHeight","unitWidth","opacity","ssLastChildLossBorder","ssAbsoluteCovered","ssCardBox","ssEffectsOnActive","ssPushable","ssSphere","ssSquare","ssTextEllipsis","isBoldFont","isLightFont","isSemiBoldFont","isRounded","flexCenter","flexNewLine","gradients","UnderBreakPointStyles","className","freeCSS"]),h=a({},c),F=[Ae];if(O&&F.push("ssLastChildLossBorder_"+O),N){N=d.flatArray(N);for(let ze of N){let[Ee,Pe]=ze.split(".");h["data-effect-"+Ee]="1",Pe&&(h["data-effect-tone"]=Pe)}}{let ze=e.ClassNames("amotf_",{gap:l,display:R,position:C,overflow:P,fontColor:E,fontSize:G,fontWeight:j,fontHeight:g,backgroundColor:q,textAlign:H,textDecoration:M,boxShadow:D,margin:p,marginTop:S,marginRight:o,marginBottom:r,marginLeft:y,padding:f,paddingTop:s,paddingRight:x,paddingBottom:B,paddingLeft:T,top:X,right:J,bottom:Q,left:Y,border:z,borderTop:u,borderRight:v,borderBottom:m,borderLeft:b,borderWidth:Z,borderColor:ee,borderStyle:te,borderRadius:k,borderTopLeftRadius:_,borderTopRightRadius:L,borderBottomLeftRadius:w,borderBottomRightRadius:W,flexSizing:ie,flexWrap:re,flexType:oe,flexChilds:se,flexGrid:ae,horizontalAlign:de,verticalAlign:ne,transition:le,gridCenter:ge,gridCols:pe,maxHeight:he,minHeight:fe,maxWidth:ue,minWidth:ve,width:me,height:be,unitHeight:Se,unitWidth:xe,opacity:ce});F.push(ze)}return t&&F.push(e.ClassNames("amotf_bp",t)),ye&&(h.style=a(a({},ye),h.style)),(i||h["data-component-id"])&&(h["data-component-id"]=h["data-component-id"]||i),F.length&&F.join("")&&(h.className=F.join(" ").trim().replace(/%/ig,"P").replace(/\d+px/ig,"PIX").replace(/\s+/ig," ").replace(/\//ig,"_").replace(/\./ig,"-")),h},$e=n=>{let{gap:A,display:i,position:l,overflow:R,fontColor:C,fontSize:P,fontWeight:E,fontHeight:G,backgroundColor:j,textAlign:g,textDecoration:q,boxShadow:H,margin:M,marginTop:D,marginRight:p,marginBottom:S,marginLeft:o,padding:r,paddingTop:y,paddingRight:f,paddingBottom:s,paddingLeft:x,top:B,right:T,bottom:X,left:J,border:Q,borderTop:Y,borderRight:z,borderBottom:u,borderLeft:v,borderWidth:m,borderColor:b,borderStyle:Z,borderRadius:ee,borderTopLeftRadius:te,borderTopRightRadius:k,borderBottomLeftRadius:_,borderBottomRightRadius:L,flexSizing:w,flexWrap:W,flexType:ie,flexChilds:re,flexGrid:oe,horizontalAlign:se,verticalAlign:ae,transition:de,gridCenter:ne,gridCols:le,maxHeight:ge,minHeight:pe,maxWidth:he,minWidth:fe,width:ue,height:ve,unitHeight:me,unitWidth:be,opacity:Se,ssLastChildLossBorder:xe,ssAbsoluteCovered:ce,ssCardBox:O,ssEffectsOnActive:Re,ssPushable:Ce,ssSphere:N,ssSquare:Be,ssTextEllipsis:Te,isBoldFont:_e,isLightFont:Le,isSemiBoldFont:we,isRounded:We,flexCenter:U,flexNewLine:$,gradients:V,UnderBreakPointStyles:I={},freeCSS:K={}}=n,t={};return e.ev(A)&&(t.gap=A),e.ev(i)&&(t.display=i),e.ev(l)&&(t.position=l),e.ev(R)&&(t.overflow=R),e.ev(C)&&(t.fontColor=C),e.ev(P)&&(t.fontSize=P),e.ev(E)&&(t.fontWeight=E),e.ev(G)&&(t.fontHeight=G),e.ev(j)&&(t.backgroundColor=j),e.ev(g)&&(t.textAlign=g),e.ev(q)&&(t.textDecoration=q),e.ev(H)&&(t.boxShadow=H),e.ev(M)&&(t.margin=M),e.ev(D)&&(t.marginTop=D),e.ev(p)&&(t.marginRight=p),e.ev(S)&&(t.marginBottom=S),e.ev(o)&&(t.marginLeft=o),e.ev(r)&&(t.padding=r),e.ev(y)&&(t.paddingTop=y),e.ev(f)&&(t.paddingRight=f),e.ev(s)&&(t.paddingBottom=s),e.ev(x)&&(t.paddingLeft=x),e.ev(B)&&(t.top=B),e.ev(T)&&(t.right=T),e.ev(X)&&(t.bottom=X),e.ev(J)&&(t.left=J),e.ev(Q)&&(t.border=Q),e.ev(Y)&&(t.borderTop=Y),e.ev(z)&&(t.borderRight=z),e.ev(u)&&(t.borderBottom=u),e.ev(v)&&(t.borderLeft=v),e.ev(m)&&(t.borderWidth=m),e.ev(b)&&(t.borderColor=b),e.ev(Z)&&(t.borderStyle=Z),e.ev(ee)&&(t.borderRadius=ee),e.ev(te)&&(t.borderTopLeftRadius=te),e.ev(k)&&(t.borderTopRightRadius=k),e.ev(_)&&(t.borderBottomLeftRadius=_),e.ev(L)&&(t.borderBottomRightRadius=L),e.ev(w)&&(t.flexSizing=w),e.ev(W)&&(t.flexWrap=W),e.ev(ie)&&(t.flexType=ie),e.ev(re)&&(t.flexChilds=re),e.ev(oe)&&(t.flexGrid=oe),e.ev(se)&&(t.horizontalAlign=se),e.ev(ae)&&(t.verticalAlign=ae),e.ev(de)&&(t.transition=de),e.ev(ne)&&(t.gridCenter=ne),e.ev(le)&&(t.gridCols=le),e.ev(ge)&&(t.maxHeight=ge),e.ev(pe)&&(t.minHeight=pe),e.ev(he)&&(t.maxWidth=he),e.ev(fe)&&(t.minWidth=fe),e.ev(ue)&&(t.width=ue),e.ev(ve)&&(t.height=ve),e.ev(me)&&(t.unitHeight=me),e.ev(be)&&(t.unitWidth=be),e.ev(Se)&&(t.opacity=Se),e.ev(xe)&&(t.ssLastChildLossBorder=xe),e.ev(ce)&&(t.ssAbsoluteCovered=ce),e.ev(O)&&(t.ssCardBox=O),e.ev(Re)&&(t.ssEffectsOnActive=Re),e.ev(Ce)&&(t.ssPushable=Ce),e.ev(N)&&(t.ssSphere=N),e.ev(Be)&&(t.ssSquare=Be),e.ev(Te)&&(t.ssTextEllipsis=Te),e.ev(_e)&&(t.isBoldFont=_e),e.ev(Le)&&(t.isLightFont=Le),e.ev(we)&&(t.isSemiBoldFont=we),e.ev(We)&&(t.isRounded=We),e.ev(U)&&(t.flexCenter=U),e.ev($)&&(t.flexNewLine=$),e.ev(V)&&(t.gradients=V),e.ev(K)&&(t.freeCSS=K),e.ev(I)&&(t.UnderBreakPointStyles=I),t};export{$e as ExtractStyles,Ue as GenerateHTMLProps,Ge as ReadStyleSet};
|
|
1
|
+
import{b as a,c as ze,d as Ne}from"../chunk-C5N2D3ZX.js";import d from"jmini";import{Config as Fe}from".";const e={toConcreteBorderRadius:n=>{let A=Fe.get().roundness|0;return n=="1.tone.primary"?n=[0,2,3,4,5,5][A]:n=="2.tone.secondary"?n=[0,1,2,3,4,5][A]:n=="3.tone.tertiary"&&(n=[0,"1/3","2/3",1,2,3][A]),n},ev:n=>d.is.exist(n),ClassNames:(n,A)=>{var O,Re,Ce,N,Be,Te,_e,Le,we,We;let i=[],{gap:l,display:R,position:C,overflow:P,fontColor:E,fontSize:G,fontWeight:j,fontHeight:g,backgroundColor:q,textAlign:H,textDecoration:M,boxShadow:D,margin:p,marginTop:S,marginRight:o,marginBottom:r,marginLeft:y,padding:f,paddingTop:s,paddingRight:x,paddingBottom:B,paddingLeft:T,top:X,right:J,bottom:Q,left:Y,border:z,borderTop:u,borderRight:v,borderBottom:m,borderLeft:b,borderWidth:Z,borderColor:ee,borderStyle:te,borderRadius:k,borderTopLeftRadius:_,borderTopRightRadius:L,borderBottomLeftRadius:w,borderBottomRightRadius:W,flexSizing:ie,flexWrap:re,flexType:oe,flexChilds:se,flexGrid:ae,horizontalAlign:de,verticalAlign:ne,transition:le,gridCenter:ge,gridCols:pe,maxHeight:he,minHeight:fe,maxWidth:ue,minWidth:ve,width:me,height:be,unitHeight:Se,unitWidth:xe,opacity:ce}=A;{if(e.ev(R)&&i.push("dsp"+R),P){let c=d.flatArray(P);i.push("ovfl-x-"+c[0]),i.push("ovfl-y-"+(c[1]||c[0]))}e.ev(C)&&i.push("ps"+C),e.ev(H)&&i.push("txtalg"+H),e.ev(H)&&i.push("txtdeco"+M),e.ev(E)&&i.push("ftcl"+((O=String(E))==null?void 0:O.replace(/\./g,"_"))),e.ev(G)&&i.push("ftsz"+((Re=String(G))==null?void 0:Re.replace(/\..*/,""))),e.ev(j)&&i.push("ftwgt"+((Ce=String(j))==null?void 0:Ce.replace(/\..*/,""))),e.ev(g)&&i.push("fthgt"+((N=String(g))==null?void 0:N.replace(/\./g,"_"))),e.ev(q)&&i.push("bgc"+((Be=String(q))==null?void 0:Be.replace(/\./g,"_"))),e.ev(D)&&i.push("bs"+D);let U,$,V,I;d.is.exist(p)&&(d.is.array(p)?p.length==2?[U,$,V,I]=[...p,...p]:p.length==4&&([U,$,V,I]=p):U=$=V=I=p,S=S!=null?S:U,o=o!=null?o:$,r=r!=null?r:V,y=y!=null?y:I),e.ev(S)&&i.push("mrgt"+S),e.ev(o)&&i.push("mrgr"+o),e.ev(r)&&i.push("mrgb"+r),e.ev(y)&&i.push("mrgl"+y);let K,t,Ae,ye;d.is.exist(f)&&(d.is.array(f)?f.length==2?[K,t,Ae,ye]=[...f,...f]:f.length==4&&([K,t,Ae,ye]=f):K=t=Ae=ye=f,s=s!=null?s:K,x=x!=null?x:t,B=B!=null?B:Ae,T=T!=null?T:ye),e.ev(s)&&i.push("pdt"+s),e.ev(x)&&i.push("pdr"+x),e.ev(B)&&i.push("pdb"+B),e.ev(T)&&i.push("pdl"+T),e.ev(X)&&i.push("pstt"+X),e.ev(J)&&i.push("pstr"+J),e.ev(Q)&&i.push("pstb"+Q),e.ev(Y)&&i.push("pstl"+Y);{d.is.exist(z)&&(u=u!=null?u:z,v=v!=null?v:z,m=m!=null?m:z,b=b!=null?b:z),d.is.boolean(u)&&(u=["unset","2.normal"][Number(u)]),d.is.boolean(v)&&(v=["unset","2.normal"][Number(v)]),d.is.boolean(m)&&(m=["unset","2.normal"][Number(m)]),d.is.boolean(b)&&(b=["unset","2.normal"][Number(b)]),e.ev(u)&&i.push("b_t_ss"+((Te=String(u))==null?void 0:Te.replace(/\./g,"_"))),e.ev(v)&&i.push("b_r_ss"+((_e=String(v))==null?void 0:_e.replace(/\./g,"_"))),e.ev(m)&&i.push("b_b_ss"+((Le=String(m))==null?void 0:Le.replace(/\./g,"_"))),e.ev(b)&&i.push("b_l_ss"+((we=String(b))==null?void 0:we.replace(/\./g,"_"))),d.is.exist(Z)&&i.push("b_wth"+String(Z)),d.is.exist(ee)&&i.push("b_cl"+((We=String(ee))==null?void 0:We.replace(/\./g,"_"))),d.is.exist(te)&&i.push("b_st"+String(te));{let c,h,F,He;d.is.exist(k)&&(d.is.array(k)?k.length==4&&([c,h,He,F]=k):c=h=F=He=k,_=_!=null?_:c,L=L!=null?L:h,w=w!=null?w:F,W=W!=null?W:He)}e.ev(_)&&i.push("br_tl"+e.toConcreteBorderRadius(_)),e.ev(L)&&i.push("br_tr"+e.toConcreteBorderRadius(L)),e.ev(w)&&i.push("br_bl"+e.toConcreteBorderRadius(w)),e.ev(W)&&i.push("br_br"+e.toConcreteBorderRadius(W))}if(e.ev(ce)&&i.push("op"+ce),d.is.exist(l)){let c,h;d.is.array(l)?(c=l[0],h=l[1]):c=h=l,i.push("gapRow"+c,"gapCol"+h)}e.ev(ie)&&i.push("flsz"+ie),e.ev(re)&&i.push("flwrp"+re),e.ev(oe)&&i.push("fltyp"+oe),e.ev(se)&&i.push("flchld"+se),e.ev(ae)&&i.push("flgrid"+ae),e.ev(ne)&&i.push("flvrt"+ne),e.ev(de)&&i.push("flhrz"+de),e.ev(ge)&&i.push("grcnt"+ge),e.ev(pe)&&i.push("grcol"+pe),e.ev(be)&&i.push("hgt"+be),e.ev(me)&&i.push("wdt"+me),e.ev(Se)&&i.push("unthgt"+Se),e.ev(xe)&&i.push("untwdt"+xe),e.ev(le)&&i.push("trnst"+le),e.ev(he)&&i.push("maxh"+he),e.ev(fe)&&i.push("minh"+fe),e.ev(ue)&&i.push("maxw"+ue),e.ev(ve)&&i.push("minw"+ve)}return i.length?n+i.join(" "+n):""}},Ge=n=>{let y=a({},n),{gradients:i,ssCardBox:l,ssSphere:R,ssSquare:C,ssPushable:P,ssAbsoluteCovered:E,ssHiddenOnBreak:G,ssTextEllipsis:j,flexCenter:g,flexNewLine:q,isLightFont:H,isBoldFont:M,isSemiBoldFont:D,isRounded:p,isSquare:S,freeCSS:f={}}=y,o=Ne(f,[]),r=Ne(y,["gradients","ssCardBox","ssSphere","ssSquare","ssPushable","ssAbsoluteCovered","ssHiddenOnBreak","ssTextEllipsis","flexCenter","flexNewLine","isLightFont","isBoldFont","isSemiBoldFont","isRounded","isSquare","freeCSS"]);if(o=o||{},r=r||{},i){let{deg:s,colors:x}=i;o=ze(a({},o),{background:`linear-gradient(${s}deg,${x.join(",")})`})}if(l){l===!0&&(l="border");let s={backgroundColor:"layer.1",borderRadius:"1.tone.primary",boxShadow:"0.min"};l=="border"?s.border=!0:l=="plain"?(s.backgroundColor="layer.1",s.boxShadow="none"):l=="cloud"?s.backgroundColor="cloud":l=="shadow"&&(s.boxShadow="0.normal"),Fe.get().darkMode=="dim"&&(s.boxShadow="1.normal"),Fe.get().darkMode=="dark"&&(s.boxShadow="1.remark"),o=a(a({},s.freeCSS),o),r=a(a({},s),r)}return R&&(g=g!=null?g:!0,r=a({padding:0,unitWidth:R,unitHeight:R,borderRadius:"sphere",flexSizing:"none"},r)),C&&(g=g!=null?g:!0,r=a({padding:0,unitWidth:C,unitHeight:C,flexSizing:"none"},r)),G&&(r=ze(a({},r),{UnderBreakPointStyles:a({display:"none"},r.UnderBreakPointStyles)})),P&&(r=a({transition:"middle"},r),r=ze(a({},r),{className:[r.className,"ssPushable"].join(" ")})),E&&(r=a({position:"absolute",top:0,left:0,right:0,bottom:0},r)),j&&(r=a({overflow:"hidden"},r),o=a({whiteSpace:"nowrap",textOverflow:"ellipsis"},o)),q&&(r=a({width:1,flexSizing:"none"},r)),g&&(r=a({display:"flex",horizontalAlign:"center",verticalAlign:"center"},r)),H&&(r.fontWeight="1.light"),D&&(r.fontWeight="3.semiBold"),M&&(r.fontWeight="4.bold"),p&&(r.borderRadius="sphere",d.is.number(p)&&(o.borderRadius=p*12)),S&&(o.aspectRatio="1"),ze(a({},r),{freeCSS:o})},Ue=n=>{let He=Ge(n),{componentId:i,gap:l,display:R,position:C,overflow:P,fontColor:E,fontSize:G,fontWeight:j,fontHeight:g,backgroundColor:q,textAlign:H,textDecoration:M,boxShadow:D,margin:p,marginTop:S,marginRight:o,marginBottom:r,marginLeft:y,padding:f,paddingTop:s,paddingRight:x,paddingBottom:B,paddingLeft:T,top:X,right:J,bottom:Q,left:Y,border:z,borderTop:u,borderRight:v,borderBottom:m,borderLeft:b,borderWidth:Z,borderColor:ee,borderStyle:te,borderRadius:k,borderTopLeftRadius:_,borderTopRightRadius:L,borderBottomLeftRadius:w,borderBottomRightRadius:W,flexSizing:ie,flexWrap:re,flexType:oe,flexChilds:se,flexGrid:ae,horizontalAlign:de,verticalAlign:ne,transition:le,gridCenter:ge,gridCols:pe,maxHeight:he,minHeight:fe,maxWidth:ue,minWidth:ve,width:me,height:be,unitHeight:Se,unitWidth:xe,opacity:ce,ssLastChildLossBorder:O,ssAbsoluteCovered:Re,ssCardBox:Ce,ssEffectsOnActive:N,ssPushable:Be,ssSphere:Te,ssSquare:_e,ssTextEllipsis:Le,isBoldFont:we,isLightFont:We,isSemiBoldFont:U,isRounded:$,flexCenter:V,flexNewLine:I,gradients:K,UnderBreakPointStyles:t={},className:Ae="",freeCSS:ye={}}=He,c=Ne(He,["componentId","gap","display","position","overflow","fontColor","fontSize","fontWeight","fontHeight","backgroundColor","textAlign","textDecoration","boxShadow","margin","marginTop","marginRight","marginBottom","marginLeft","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","top","right","bottom","left","border","borderTop","borderRight","borderBottom","borderLeft","borderWidth","borderColor","borderStyle","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","flexSizing","flexWrap","flexType","flexChilds","flexGrid","horizontalAlign","verticalAlign","transition","gridCenter","gridCols","maxHeight","minHeight","maxWidth","minWidth","width","height","unitHeight","unitWidth","opacity","ssLastChildLossBorder","ssAbsoluteCovered","ssCardBox","ssEffectsOnActive","ssPushable","ssSphere","ssSquare","ssTextEllipsis","isBoldFont","isLightFont","isSemiBoldFont","isRounded","flexCenter","flexNewLine","gradients","UnderBreakPointStyles","className","freeCSS"]),h=a({},c),F=[Ae];if(O&&F.push("ssLastChildLossBorder_"+O),N){N=d.flatArray(N);for(let ke of N){let[Ee,Pe]=ke.split(".");h["data-effect-"+Ee]="1",Pe&&(h["data-effect-tone"]=Pe)}}{let ke=e.ClassNames("amotf_",{gap:l,display:R,position:C,overflow:P,fontColor:E,fontSize:G,fontWeight:j,fontHeight:g,backgroundColor:q,textAlign:H,textDecoration:M,boxShadow:D,margin:p,marginTop:S,marginRight:o,marginBottom:r,marginLeft:y,padding:f,paddingTop:s,paddingRight:x,paddingBottom:B,paddingLeft:T,top:X,right:J,bottom:Q,left:Y,border:z,borderTop:u,borderRight:v,borderBottom:m,borderLeft:b,borderWidth:Z,borderColor:ee,borderStyle:te,borderRadius:k,borderTopLeftRadius:_,borderTopRightRadius:L,borderBottomLeftRadius:w,borderBottomRightRadius:W,flexSizing:ie,flexWrap:re,flexType:oe,flexChilds:se,flexGrid:ae,horizontalAlign:de,verticalAlign:ne,transition:le,gridCenter:ge,gridCols:pe,maxHeight:he,minHeight:fe,maxWidth:ue,minWidth:ve,width:me,height:be,unitHeight:Se,unitWidth:xe,opacity:ce});F.push(ke)}return t&&F.push(e.ClassNames("amotf_bp",t)),ye&&(h.style=a(a({},ye),h.style)),(i||h["data-component-id"])&&(h["data-component-id"]=h["data-component-id"]||i),F.length&&F.join("")&&(h.className=F.join(" ").trim().replace(/%/ig,"P").replace(/\d+px/ig,"PIX").replace(/\s+/ig," ").replace(/\//ig,"_").replace(/\./ig,"-")),h},$e=n=>{let{gap:A,display:i,position:l,overflow:R,fontColor:C,fontSize:P,fontWeight:E,fontHeight:G,backgroundColor:j,textAlign:g,textDecoration:q,boxShadow:H,margin:M,marginTop:D,marginRight:p,marginBottom:S,marginLeft:o,padding:r,paddingTop:y,paddingRight:f,paddingBottom:s,paddingLeft:x,top:B,right:T,bottom:X,left:J,border:Q,borderTop:Y,borderRight:z,borderBottom:u,borderLeft:v,borderWidth:m,borderColor:b,borderStyle:Z,borderRadius:ee,borderTopLeftRadius:te,borderTopRightRadius:k,borderBottomLeftRadius:_,borderBottomRightRadius:L,flexSizing:w,flexWrap:W,flexType:ie,flexChilds:re,flexGrid:oe,horizontalAlign:se,verticalAlign:ae,transition:de,gridCenter:ne,gridCols:le,maxHeight:ge,minHeight:pe,maxWidth:he,minWidth:fe,width:ue,height:ve,unitHeight:me,unitWidth:be,opacity:Se,ssLastChildLossBorder:xe,ssAbsoluteCovered:ce,ssCardBox:O,ssEffectsOnActive:Re,ssPushable:Ce,ssSphere:N,ssSquare:Be,ssTextEllipsis:Te,isBoldFont:_e,isLightFont:Le,isSemiBoldFont:we,isRounded:We,flexCenter:U,flexNewLine:$,gradients:V,UnderBreakPointStyles:I={},freeCSS:K={}}=n,t={};return e.ev(A)&&(t.gap=A),e.ev(i)&&(t.display=i),e.ev(l)&&(t.position=l),e.ev(R)&&(t.overflow=R),e.ev(C)&&(t.fontColor=C),e.ev(P)&&(t.fontSize=P),e.ev(E)&&(t.fontWeight=E),e.ev(G)&&(t.fontHeight=G),e.ev(j)&&(t.backgroundColor=j),e.ev(g)&&(t.textAlign=g),e.ev(q)&&(t.textDecoration=q),e.ev(H)&&(t.boxShadow=H),e.ev(M)&&(t.margin=M),e.ev(D)&&(t.marginTop=D),e.ev(p)&&(t.marginRight=p),e.ev(S)&&(t.marginBottom=S),e.ev(o)&&(t.marginLeft=o),e.ev(r)&&(t.padding=r),e.ev(y)&&(t.paddingTop=y),e.ev(f)&&(t.paddingRight=f),e.ev(s)&&(t.paddingBottom=s),e.ev(x)&&(t.paddingLeft=x),e.ev(B)&&(t.top=B),e.ev(T)&&(t.right=T),e.ev(X)&&(t.bottom=X),e.ev(J)&&(t.left=J),e.ev(Q)&&(t.border=Q),e.ev(Y)&&(t.borderTop=Y),e.ev(z)&&(t.borderRight=z),e.ev(u)&&(t.borderBottom=u),e.ev(v)&&(t.borderLeft=v),e.ev(m)&&(t.borderWidth=m),e.ev(b)&&(t.borderColor=b),e.ev(Z)&&(t.borderStyle=Z),e.ev(ee)&&(t.borderRadius=ee),e.ev(te)&&(t.borderTopLeftRadius=te),e.ev(k)&&(t.borderTopRightRadius=k),e.ev(_)&&(t.borderBottomLeftRadius=_),e.ev(L)&&(t.borderBottomRightRadius=L),e.ev(w)&&(t.flexSizing=w),e.ev(W)&&(t.flexWrap=W),e.ev(ie)&&(t.flexType=ie),e.ev(re)&&(t.flexChilds=re),e.ev(oe)&&(t.flexGrid=oe),e.ev(se)&&(t.horizontalAlign=se),e.ev(ae)&&(t.verticalAlign=ae),e.ev(de)&&(t.transition=de),e.ev(ne)&&(t.gridCenter=ne),e.ev(le)&&(t.gridCols=le),e.ev(ge)&&(t.maxHeight=ge),e.ev(pe)&&(t.minHeight=pe),e.ev(he)&&(t.maxWidth=he),e.ev(fe)&&(t.minWidth=fe),e.ev(ue)&&(t.width=ue),e.ev(ve)&&(t.height=ve),e.ev(me)&&(t.unitHeight=me),e.ev(be)&&(t.unitWidth=be),e.ev(Se)&&(t.opacity=Se),e.ev(xe)&&(t.ssLastChildLossBorder=xe),e.ev(ce)&&(t.ssAbsoluteCovered=ce),e.ev(O)&&(t.ssCardBox=O),e.ev(Re)&&(t.ssEffectsOnActive=Re),e.ev(Ce)&&(t.ssPushable=Ce),e.ev(N)&&(t.ssSphere=N),e.ev(Be)&&(t.ssSquare=Be),e.ev(Te)&&(t.ssTextEllipsis=Te),e.ev(_e)&&(t.isBoldFont=_e),e.ev(Le)&&(t.isLightFont=Le),e.ev(we)&&(t.isSemiBoldFont=we),e.ev(We)&&(t.isRounded=We),e.ev(U)&&(t.flexCenter=U),e.ev($)&&(t.flexNewLine=$),e.ev(V)&&(t.gradients=V),e.ev(K)&&(t.freeCSS=K),e.ev(I)&&(t.UnderBreakPointStyles=I),t};export{$e as ExtractStyles,Ue as GenerateHTMLProps,Ge as ReadStyleSet};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as l,c as f,d as G,e as H}from"../../chunk-C5N2D3ZX.js";import{Fragment as N,jsx as s,jsxs as V}from"react/jsx-runtime";import{useState as A,useEffect as F,useRef as ne}from"react";import p,{UUID as v}from"jmini";import{Config as oe}from"../../@utils";import{Box as X,Span as ie,FAI as B,Column as q}from"../../atoms";import{Literal as W,Row as K}from"../../mols";import{Button as $}from"../Button";import{Loader as le}from"../Loader";import{Sheet as ae}from"../Sheet";import{OptionalInputWrapper as re,BoxWrapper as se,CoreEffects as z,DefaultBoxishStyles as ue}from"./core";import{InputAutocompleteClasses as L}from"../../@styles/componentClasses";import{InputLabel as ce}from"./Label";import{RightIcon as Q}from".";function pe(t){let{value:e,states:i}=t,{required:r,options:d,min:m,max:o}=i;m=m||0,o=o||65535;let n=[],c=e.filter(h=>h!==null).length;return r&&(c||n.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),c<m&&n.push({type:"invalid",label:m+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),c>o&&n.push({type:"invalid",label:o+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!n.filter(({type:h})=>h=="invalid").length,notice:n}}const C={InitOptions:t=>{let e=[];return t.forEach(i=>{if(!i)return;let{type:r,label:d,value:m,searchValue:o}=i,n=o||p.is.string(d)&&d||""||p.is.string(m)&&m||p.Stringify(m||"")||"";p.is.nullish(d)&&(d=String(m)),e.push(f(l({id:v(8)},i),{searchValue:n,type:r||"selector",label:d,value:m}))}),e},FilterSelectableOptions:(t,e,i)=>{let r=t;return i||(r=t.filter(d=>(d==null?void 0:d.type)!="label")),p.scope(()=>{if(!e)return;let d=e.toLower().replace(/ /g,"");r=r.filter(m=>(m.searchValue||"").toLower().replace(/ /g,"").includes(d))}),r},Button:t=>{let{rootStates:e,val_keyword:i,set_keyword:r,val_optionFocused:d,set_optionFocused:m,val_status:o,set_status:n}=t,J=e,{tone:c,required:h,form:k,className:a,multiSelect:u,enableFormSubmit:y,checkValidationAtFirst:S,onValidate:g,onValidateDelay:I,onUpdateValue:R,onUpdateValidValue:x,onUserAction:P,value:E="",options:w,leftIndicator:O,rightIndicator:_,leftIcon:de,rightIcon:fe,componentId:me,status_id:Se,wrapStyles:ve,emptySelect:ye,searchInputPlaceholder:he,onSelectedRender:ge,onSelectorRender:Ie,pickerStyles:be,pickerPosition:ke,onDynamicSearchOptions:_e,onDynamicSearchOptionsDelay:we}=J,T=G(J,["tone","required","form","className","multiSelect","enableFormSubmit","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","emptySelect","searchInputPlaceholder","onSelectedRender","onSelectorRender","pickerStyles","pickerPosition","onDynamicSearchOptions","onDynamicSearchOptionsDelay"]),M="SearchInput_"+e.componentId;return F(()=>{var b;if(e.disabled||!o.isPickerOpen||p.is.exist(d))return;let D=C.FilterSelectableOptions(t.val_options,i,!1);m(((b=D[0])==null?void 0:b.id)||"")},[i]),F(()=>{if(o.eventType!="init"&&o.eventType!="override"&&e.max==o.rawValue.length){r(""),n(D=>f(l({},D),{eventID:v(8),isPickerOpen:!1}));return}},[o.rawValue]),F(()=>{let D="autocomplete-click-"+e.componentId;if(!o.isPickerOpen){p(document).removeEvent([D]);return}p('[data-input-origin="'+e.componentId+'"]')&&p(document).addEvent({eventID:D,eventType:"mousedown",callback:U=>{let j=p(U.target),Z=!!p(j).parent("."+L("Core")).length,ee=!!p(j).parent("."+L("Selector")).length;Z||ee||n(te=>f(l({},te),{eventID:v(8),isFocusing:!1,isPickerOpen:!1}))},options:{passive:!1}})},[o.isPickerOpen]),V(N,{children:[s(X,f(l({tabIndex:-1},T),{"data-disabled":e.disabled,"data-show-validation":z.isShowValidation(o,!!S),"data-component-id":o.componentId,"data-input-origin":o.componentId,"data-focus":o.isFocusing||o.isPickerOpen,className:[a,L("Core")].join(" "),onClick:D=>{if(T!=null&&T.onClick&&(T==null||T.onClick(D)),e.disabled)return;let b=document.activeElement;(b==null?void 0:b.id)!=M&&(oe.get().isTouchDevice||p("#"+M).focus()),n(U=>f(l({},U),{eventID:v(8),isPickerOpen:!0,isFocusing:!0}))},onKeyDown:D=>{let b=document.activeElement;(b==null?void 0:b.id)!=M&&(D.preventDefault(),p("#"+M).focus())},children:V(K.Left,{gap:0,children:[s(ie,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),V(K.Left,{flexWrap:!0,flexSizing:0,gap:"1/2",verticalAlign:"unset",freeCSS:{letterSpacing:".5px"},children:[s(C.Selected,l({},t)),s(C.SearchInput,l({},t))]}),o.rawValue.length>1&&s($.Clear,{tabIndex:-1,color:"nega",fontColor:"4.thin",ssSphere:2,onClick:D=>{n(b=>f(l({},b),{eventType:"update",eventID:v(8),rawValue:[]}))},children:s(B.X,{})})]})})),s(C.Picker,l({},t))]})},SearchInput:t=>{let{rootStates:e,val_status:i,set_status:r}=t;if(e.disabled)return null;let d=!!i.isFocusing||!!i.isPickerOpen||!!i.rawValue.length;i.isFocusing||e.multiSelect||i.rawValue.length&&(d=!1);let m=e.searchInputPlaceholder||"\u691C\u7D22...";return s(X,{htmlTag:"input",id:"SearchInput_"+e.componentId,"data-input-value-shallow":i.componentId,placeholder:m,opacity:d?"max":"trans",transition:"middle",flexSizing:0,fontSize:"inherit",border:"0.trans",backgroundColor:"trans",isRounded:!0,padding:[0,"2/3"],value:t.val_keyword,className:[L("SearchInput"),d&&L("isActive")].join(" "),freeCSS:{outline:"none",minWidth:12*4},onFocus:o=>{r(n=>f(l({},n),{eventID:v(8),isFocusing:!0,isPickerOpen:!0}))},onBlur:o=>H(void 0,null,function*(){r(n=>f(l({},n),{eventID:v(8),isFocusing:!1}))}),onCompositionStart:o=>{r(n=>f(l({},n),{eventID:v(8),isComposing:!0}))},onCompositionEnd:o=>{r(n=>f(l({},n),{eventID:v(8),isComposing:!1}))},onKeyDown:o=>{let{key:n,metaKey:c,ctrlKey:h}=o,k=c||h;n=="Escape"?r(a=>f(l({},a),{eventID:v(12),isPickerOpen:!1})):n=="Tab"?r(a=>f(l({},a),{eventID:v(8),isFocusing:!1,isPickerOpen:!1})):n==" "?p.scope(()=>{i.isPickerOpen||t.val_keyword||(o.preventDefault(),r(a=>f(l({},a),{eventID:v(8),isPickerOpen:!0})))}):n=="Backspace"?p.scope(()=>{if(t.val_keyword)return;let a=[...t.val_status.rawValue];a.pop(),k&&(a=[]),r(u=>f(l({},u),{rawValue:a,eventType:"update",eventID:v(8),isInspected:!1}))}):n=="Enter"&&p.scope(()=>{if(i.isComposing||(o==null?void 0:o.keyCode)===229)return;if(!i.isPickerOpen){r(y=>f(l({},y),{eventID:v(8),isPickerOpen:!0}));return}if(!t.val_optionFocused)return;let a=t.val_options.find(y=>(y==null?void 0:y.id)==t.val_optionFocused);if(!a)return;let{value:u}=a;r(y=>{let S=[...y.rawValue];return p.scope(()=>{if(u===null)return S=[];y.rawValue.includes(u)?S=S.filter(I=>I!==u):e.multiSelect?S.push(u):S=[u]}),f(l({},y),{rawValue:S,eventType:"update",eventID:v(8),isInspected:!1})}),t.set_optionsModified(!0),t.set_keyword("")}),p.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(n))return;if(o.preventDefault(),!i.isPickerOpen){r(g=>f(l({},g),{eventID:v(8),isPickerOpen:!0}));return}let a=n=="ArrowDown"?1:-1,u=C.FilterSelectableOptions(t.val_options,t.val_keyword),y=u.length-1,S=null;p.scope(()=>{var I,R,x,P,E,w,O;let g=u.findIndex(_=>(_==null?void 0:_.id)==t.val_optionFocused);if(g==-1){S=(I=u[0])==null?void 0:I.id;return}if(a==1){if(S=(R=u[0])==null?void 0:R.id,k){S=(x=u[y])==null?void 0:x.id;return}if(g==-1||g==y)return;S=(P=u[g+1])==null?void 0:P.id}else{if(S=(E=u[y])==null?void 0:E.id,k){S=(w=u[0])==null?void 0:w.id;return}if(g==-1||g==0)return;S=(O=u[g-1])==null?void 0:O.id}}),t.set_optionFocused(S)}),e.enableFormSubmit&&z.SubmitForm(o,t.rootStates.form)},onChange:o=>{let c=o.target.value;t.set_keyword(c),t.set_optionFocused(""),c&&r(h=>f(l({},h),{eventID:v(8),isPickerOpen:!0}))}},"searchInput")},Picker:t=>{var n;let{rootStates:e,val_status:i}=t,[r,d]=A("idle");F(()=>{if(!e.onDynamicSearchOptions||!i.isPickerOpen)return;if(t.val_optionsModified)return t.set_optionsModified(!1);if(i.isComposing)return;d("fetch");let c="autocomplete-search-"+e.componentId;t.set_optionFocused(""),p.interval.once(()=>H(void 0,null,function*(){var a;let h=yield e.onDynamicSearchOptions(t.val_keyword);d("idle");let k=C.InitOptions(h||[]);t.set_options(k),t.set_optionFocused(((a=k[0])==null?void 0:a.id)||"")}),e.onDynamicSearchOptionsDelay||500,c)},[t.val_keyword,i.isComposing]),F(()=>{let c=p(`[data-selector-id="${i.componentId}"]`)[0];if(!c)return;let h=p(`[data-autocomplete-input-value="${t.val_optionFocused}"]`)[0];h&&(c.scrollTop=h.offsetTop-24)},[t.val_optionFocused]);let m=C.FilterSelectableOptions(t.val_options,e.onDynamicSearchOptions?"":t.val_keyword,!0),o={};{let c=e.pickerPosition||0;[1,2].includes(c)?o.bottom="100%":[3,4].includes(c)&&(o.top="100%"),[1,3].includes(c)?o.left=0:[2,4].includes(c)&&(o.right=0)}return i.isPickerOpen?s(X,f(l({position:"absolute",padding:"2/3"},o),{freeCSS:l({minWidth:"75%",zIndex:1e3},o.freeCSS),children:s(ae.Body,f(l({className:L("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,tabIndex:-1,boxShadow:"1.normal",overflow:"auto","data-selector-id":i.componentId},e.pickerStyles),{freeCSS:l({maxHeight:12*24},(n=e.pickerStyles)==null?void 0:n.freeCSS),children:V(q,{gap:"1/12",padding:[1,0],children:[r=="fetch"&&s(K.Center,{padding:"1/2",children:s(le.Theme.R,{showInitial:!0})}),r!="fetch"&&V(N,{children:[!m.length&&s(W.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"}),m.map((c,h)=>{if(!c)return null;let{type:k,value:a}=c,u=t.val_optionFocused==c.id,y=i.rawValue.includes(a),S=e.onSelectorRender;return s(q,{"data-autocomplete-input-value":c.id,children:s(S,{option:c,isFocused:u,isSelected:y,onAdd:()=>{t.set_status(g=>{let I=[...g.rawValue];return p.scope(()=>{if(a===null)return I=[];if(g.rawValue.includes(a)){I=I.filter(x=>x!==a);return}e.multiSelect?I.push(a):I=[a]}),f(l({},g),{rawValue:I,eventType:"update",eventID:v(8),isFocusing:e.max!=I.length,isInspected:!1})})},onKeyDown:g=>{let{key:I}=g;I=="Tab"&&(t.set_optionFocused(""),t.set_status(R=>f(l({},R),{eventID:v(8),isPickerOpen:!1,isFocusing:!1})))}})},c.id)})]})]})}))})):null},Selected:t=>{let{rootStates:e,val_status:i,set_status:r,val_optionsDict:d}=t,m=[];return i.rawValue.forEach(o=>{let n=d[p.Stringify(o)];if(!n)return;let c=e.onSelectedRender,h=(n==null?void 0:n.selectedLabel)||(n==null?void 0:n.label);(n==null?void 0:n.value)===null&&(h=""),m.push(s(q,{position:"relative",flexCenter:!0,freeCSS:{userSelect:"none"},children:s(c,{value:n==null?void 0:n.value,label:h,onRemove:k=>{if(e.disabled)return;let a=[...i.rawValue];a=a.filter(u=>u!==o),r(u=>f(l({},u),{rawValue:a,eventType:"update",eventID:v(8),isInspected:!1,isFocusing:e.max!=a.length,isPickerOpen:!0}))}})},p.Stringify(n==null?void 0:n.value)||v(8)))}),s(N,{children:m})},Core:t=>{var x,P,E;let{value:e}=t,[i,r]=A(!1),[d,m]=A(""),[o,n]=A(t.options),[c,h]=A(((x=t.options.find(w=>{var O;return(w==null?void 0:w.value)===((O=t.value)==null?void 0:O[0])}))==null?void 0:x.id)||((P=t.options[0])==null?void 0:P.id)||""),[k,a]=A({}),[u,y]=A(z.DefaultStatus(t.componentId,e)),S=ne(!1);F(()=>{i||(S.current?n(t.options):S.current=!0)},[p.Stringify((E=t.options)==null?void 0:E.map(w=>w.value))]),F(()=>{if(!o.length)return;let w=[...o],O=l({},k);w.forEach(_=>{(_==null?void 0:_.type)!="label"&&(O[p.Stringify(_==null?void 0:_.value)]=_)}),a(O)},[o]);let g={rootStates:t,val_options:o,set_options:n,val_optionFocused:c,set_optionFocused:h,val_optionsDict:k,set_optionsDict:a,val_optionsModified:i,set_optionsModified:r,val_keyword:d,set_keyword:m,val_status:u,set_status:y},I=!!t.multiSelect;z.CommonEffects({type:I?"autocomplete.multi":"autocomplete.single",states:t,val_status:u,set_status:y,SystemValidation:pe});let R=u.rawValue.length&&u.rawValue[0]!==null||u.isPickerOpen||u.isFocusing;return V(se,{val_status:u,set_status:y,states:t,children:[s(ce,{componentId:t.componentId,fontSize:t.fontSize,required:t.required,label:t.label,isActive:R}),s(C.Button,l({},g))]})}},Y=t=>{let e=l({},t);return e=f(l({value:[],min:0,max:65535,multiSelect:!0,emptySelect:!0,onSelectorRender:i=>{var r;return i.option?((r=i.option)==null?void 0:r.type)=="label"?s(N,{children:i.option.label}):s($.Sub.S,{color:"cloud",tabIndex:-1,backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:[1,1.5],isActive:i.isFocused,isActiveStyles:{backgroundColor:"cloud"},onClick:i.onAdd,onKeyDown:i.onKeyDown,children:V(K.Left,{gap:"1/2",children:[i.isSelected&&s(B.Check,{fontColor:"theme"}),s(W.Supplement,{transition:"short",children:i.option.label})]})}):null},onSelectedRender:i=>V(K.Left,{ssCardBox:!0,borderRadius:"1.tone.primary",fontSize:"1.mini",padding:"1/3",gap:0,children:[s(W,{padding:[0,"1/2"],children:i.label}),s($.Clear,{flexSizing:"none",color:"nega",fontColor:"4.thin",tabIndex:-1,ssSphere:2,onClick:i.onRemove,freeCSS:{lineHeight:1,aspectRatio:"1/1"},children:s(B.X,{})})]}),pickerPosition:3},e),{freeCSS:l({cursor:"pointer"},e.freeCSS)}),e.multiSelect||(e.min=0,e.max=1),e.options=e.options||[],e.emptySelect&&(e.options=[{value:null,label:s(W.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...e.options]),e.value=p.flatArray(e.value),e.options=C.InitOptions(e.options),p.is.nullish(e.rightIcon)&&(e.rightIcon=s(Q,{children:s(B.Search,{})}),e.disabled&&(e.rightIcon=s(Q,{fontColor:"5.translucent",children:s(B.Ban,{})}))),e.rightIcon&&(e=l({paddingRight:3},e)),e.leftIcon&&(e=l({paddingLeft:3},e)),s(re,{componentId:e.componentId,children:C.Core,states:ue(e)})};export{Y as Autocomplete,Y as default};
|
|
1
|
+
import{b as l,c as f,d as G,e as H}from"../../chunk-C5N2D3ZX.js";import{Fragment as N,jsx as s,jsxs as V}from"react/jsx-runtime";import{useState as A,useEffect as F,useRef as ne}from"react";import p,{UUID as v}from"jmini";import{Config as oe}from"../../@utils";import{Box as X,Span as ie,FAI as B,Column as q}from"../../atoms";import{Literal as W,Row as K}from"../../mols";import{Button as $}from"../Button";import{Loader as le}from"../Loader";import{Sheet as ae}from"../Sheet";import{OptionalInputWrapper as re,BoxWrapper as se,CoreEffects as z,DefaultBoxishStyles as ue}from"./core";import{InputAutocompleteClasses as L}from"../../@styles/componentClasses";import{InputLabel as ce}from"./Label";import{RightIcon as Q}from".";function pe(t){let{value:e,states:i}=t,{required:r,options:d,min:m,max:o}=i;m=m||0,o=o||65535;let n=[],c=e.filter(h=>h!==null).length;return r&&(c||n.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),c<m&&n.push({type:"invalid",label:m+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),c>o&&n.push({type:"invalid",label:o+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!n.filter(({type:h})=>h=="invalid").length,notice:n}}const C={InitOptions:t=>{let e=[];return t.forEach(i=>{if(!i)return;let{type:r,label:d,value:m,searchValue:o}=i,n=o||p.is.string(d)&&d||""||p.is.string(m)&&m||p.Stringify(m||"")||"";p.is.nullish(d)&&(d=String(m)),e.push(f(l({id:v(8)},i),{searchValue:n,type:r||"selector",label:d,value:m}))}),e},FilterSelectableOptions:(t,e,i)=>{let r=t;return i||(r=t.filter(d=>(d==null?void 0:d.type)!="label")),p.scope(()=>{if(!e)return;let d=e.toLower().replace(/ /g,"");r=r.filter(m=>(m.searchValue||"").toLower().replace(/ /g,"").includes(d))}),r},Button:t=>{let{rootStates:e,val_keyword:i,set_keyword:r,val_optionFocused:d,set_optionFocused:m,val_status:o,set_status:n}=t,J=e,{tone:c,required:h,form:k,className:a,multiSelect:u,enableFormSubmit:y,checkValidationAtFirst:S,onValidate:g,onValidateDelay:I,onUpdateValue:R,onUpdateValidValue:x,onUserAction:P,value:E="",options:w,leftIndicator:O,rightIndicator:_,leftIcon:de,rightIcon:fe,componentId:me,status_id:Se,wrapStyles:ve,emptySelect:ye,searchInputPlaceholder:he,onSelectedRender:ge,onSelectorRender:Ie,pickerStyles:be,pickerPosition:ke,onDynamicSearchOptions:_e,onDynamicSearchOptionsDelay:we}=J,T=G(J,["tone","required","form","className","multiSelect","enableFormSubmit","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","emptySelect","searchInputPlaceholder","onSelectedRender","onSelectorRender","pickerStyles","pickerPosition","onDynamicSearchOptions","onDynamicSearchOptionsDelay"]),M="SearchInput_"+e.componentId;return F(()=>{var b;if(e.disabled||!o.isPickerOpen||p.is.exist(d))return;let D=C.FilterSelectableOptions(t.val_options,i,!1);m(((b=D[0])==null?void 0:b.id)||"")},[i]),F(()=>{if(o.eventType!="init"&&o.eventType!="override"&&e.max==o.rawValue.length){r(""),n(D=>f(l({},D),{eventID:v(8),isPickerOpen:!1}));return}},[o.rawValue]),F(()=>{let D="autocomplete-click-"+e.componentId;if(!o.isPickerOpen){p(document).removeEvent([D]);return}p('[data-input-origin="'+e.componentId+'"]')&&p(document).addEvent({eventID:D,eventType:"mousedown",callback:U=>{let j=p(U.target),Z=!!p(j).parent("."+L("Core")).length,ee=!!p(j).parent("."+L("Selector")).length;Z||ee||n(te=>f(l({},te),{eventID:v(8),isFocusing:!1,isPickerOpen:!1}))},options:{passive:!1}})},[o.isPickerOpen]),V(N,{children:[s(X,f(l({tabIndex:-1},T),{"data-disabled":e.disabled,"data-show-validation":z.isShowValidation(o,!!S),"data-component-id":o.componentId,"data-input-origin":o.componentId,"data-focus":o.isFocusing||o.isPickerOpen,className:[a,L("Core")].join(" "),onClick:D=>{if(T!=null&&T.onClick&&(T==null||T.onClick(D)),e.disabled)return;let b=document.activeElement;(b==null?void 0:b.id)!=M&&(oe.get().isTouchDevice||p("#"+M).focus()),n(U=>f(l({},U),{eventID:v(8),isPickerOpen:!0,isFocusing:!0}))},onKeyDown:D=>{let b=document.activeElement;(b==null?void 0:b.id)!=M&&(D.preventDefault(),p("#"+M).focus())},children:V(K.Left,{gap:0,children:[s(ie,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),V(K.Left,{flexWrap:!0,flexSizing:0,gap:"1/2",verticalAlign:"unset",freeCSS:{letterSpacing:".5px"},children:[s(C.Selected,l({},t)),s(C.SearchInput,l({},t))]}),o.rawValue.length>1&&s($.Clear,{tabIndex:-1,color:"nega",fontColor:"4.thin",ssSphere:2,onClick:D=>{n(b=>f(l({},b),{eventType:"update",eventID:v(8),rawValue:[]}))},children:s(B.X,{})})]})})),s(C.Picker,l({},t))]})},SearchInput:t=>{let{rootStates:e,val_status:i,set_status:r}=t;if(e.disabled)return null;let d=!!i.isFocusing||!!i.isPickerOpen||!!i.rawValue.length;i.isFocusing||e.multiSelect||i.rawValue.length&&(d=!1);let m=e.searchInputPlaceholder||"\u691C\u7D22...";return s(X,{htmlTag:"input",id:"SearchInput_"+e.componentId,"data-input-value-shallow":i.componentId,placeholder:m,opacity:d?"max":"trans",transition:"middle",flexSizing:0,fontSize:"inherit",border:"0.trans",backgroundColor:"trans",isRounded:!0,padding:[0,"2/3"],value:t.val_keyword,className:[L("SearchInput"),d&&L("isActive")].join(" "),freeCSS:{outline:"none",minWidth:12*4},onFocus:o=>{r(n=>f(l({},n),{eventID:v(8),isFocusing:!0,isPickerOpen:!0}))},onBlur:o=>H(void 0,null,function*(){r(n=>f(l({},n),{eventID:v(8),isFocusing:!1}))}),onCompositionStart:o=>{r(n=>f(l({},n),{eventID:v(8),isComposing:!0}))},onCompositionEnd:o=>{r(n=>f(l({},n),{eventID:v(8),isComposing:!1}))},onKeyDown:o=>{let{key:n,metaKey:c,ctrlKey:h}=o,k=c||h;n=="Escape"?r(a=>f(l({},a),{eventID:v(12),isPickerOpen:!1})):n=="Tab"?r(a=>f(l({},a),{eventID:v(8),isFocusing:!1,isPickerOpen:!1})):n==" "?p.scope(()=>{i.isPickerOpen||t.val_keyword||(o.preventDefault(),r(a=>f(l({},a),{eventID:v(8),isPickerOpen:!0})))}):n=="Backspace"?p.scope(()=>{if(t.val_keyword)return;let a=[...t.val_status.rawValue];a.pop(),k&&(a=[]),r(u=>f(l({},u),{rawValue:a,eventType:"update",eventID:v(8),isInspected:!1}))}):n=="Enter"&&p.scope(()=>{if(i.isComposing||(o==null?void 0:o.keyCode)===229)return;if(!i.isPickerOpen){r(y=>f(l({},y),{eventID:v(8),isPickerOpen:!0}));return}if(!t.val_optionFocused)return;let a=t.val_options.find(y=>(y==null?void 0:y.id)==t.val_optionFocused);if(!a)return;let{value:u}=a;r(y=>{let S=[...y.rawValue];return p.scope(()=>{if(u===null)return S=[];y.rawValue.includes(u)?S=S.filter(I=>I!==u):e.multiSelect?S.push(u):S=[u]}),f(l({},y),{rawValue:S,eventType:"update",eventID:v(8),isInspected:!1})}),t.set_optionsModified(!0),t.set_keyword("")}),p.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(n))return;if(o.preventDefault(),!i.isPickerOpen){r(g=>f(l({},g),{eventID:v(8),isPickerOpen:!0}));return}let a=n=="ArrowDown"?1:-1,u=C.FilterSelectableOptions(t.val_options,t.val_keyword),y=u.length-1,S=null;p.scope(()=>{var I,R,x,P,E,w,O;let g=u.findIndex(_=>(_==null?void 0:_.id)==t.val_optionFocused);if(g==-1){S=(I=u[0])==null?void 0:I.id;return}if(a==1){if(S=(R=u[0])==null?void 0:R.id,k){S=(x=u[y])==null?void 0:x.id;return}if(g==-1||g==y)return;S=(P=u[g+1])==null?void 0:P.id}else{if(S=(E=u[y])==null?void 0:E.id,k){S=(w=u[0])==null?void 0:w.id;return}if(g==-1||g==0)return;S=(O=u[g-1])==null?void 0:O.id}}),t.set_optionFocused(S)}),e.enableFormSubmit&&z.SubmitForm(o,t.rootStates.form)},onChange:o=>{let c=o.target.value;t.set_keyword(c),t.set_optionFocused(""),c&&r(h=>f(l({},h),{eventID:v(8),isPickerOpen:!0}))}},"searchInput")},Picker:t=>{var n;let{rootStates:e,val_status:i}=t,[r,d]=A("idle");F(()=>{if(!e.onDynamicSearchOptions||!i.isPickerOpen)return;if(t.val_optionsModified)return t.set_optionsModified(!1);if(i.isComposing)return;d("fetch");let c="autocomplete-search-"+e.componentId;t.set_optionFocused(""),p.interval.once(()=>H(void 0,null,function*(){var a;let h=yield e.onDynamicSearchOptions(t.val_keyword);d("idle");let k=C.InitOptions(h||[]);t.set_options(k),t.set_optionFocused(((a=k[0])==null?void 0:a.id)||"")}),e.onDynamicSearchOptionsDelay||500,c)},[t.val_keyword,i.isComposing]),F(()=>{let c=p(`[data-selector-id="${i.componentId}"]`)[0];if(!c)return;let h=p(`[data-autocomplete-input-value="${t.val_optionFocused}"]`)[0];h&&(c.scrollTop=h.offsetTop-24)},[t.val_optionFocused]);let m=C.FilterSelectableOptions(t.val_options,e.onDynamicSearchOptions?"":t.val_keyword,!0),o={};{let c=e.pickerPosition||0;[1,2].includes(c)?o.bottom="100%":[3,4].includes(c)&&(o.top="100%"),[1,3].includes(c)?o.left=0:[2,4].includes(c)&&(o.right=0)}return i.isPickerOpen?s(X,f(l({position:"absolute",padding:"1/3"},o),{freeCSS:l({minWidth:"75%",zIndex:1e3},o.freeCSS),children:s(ae.Body,f(l({className:L("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,tabIndex:-1,boxShadow:"1.normal",overflow:"auto","data-selector-id":i.componentId},e.pickerStyles),{freeCSS:l({maxHeight:12*24},(n=e.pickerStyles)==null?void 0:n.freeCSS),children:V(q,{gap:"1/12",padding:[1,0],children:[r=="fetch"&&s(K.Center,{padding:"1/2",children:s(le.Theme.R,{showInitial:!0})}),r!="fetch"&&V(N,{children:[!m.length&&s(W.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"}),m.map((c,h)=>{if(!c)return null;let{type:k,value:a}=c,u=t.val_optionFocused==c.id,y=i.rawValue.includes(a),S=e.onSelectorRender;return s(q,{"data-autocomplete-input-value":c.id,children:s(S,{option:c,isFocused:u,isSelected:y,onAdd:()=>{t.set_status(g=>{let I=[...g.rawValue];return p.scope(()=>{if(a===null)return I=[];if(g.rawValue.includes(a)){I=I.filter(x=>x!==a);return}e.multiSelect?I.push(a):I=[a]}),f(l({},g),{rawValue:I,eventType:"update",eventID:v(8),isFocusing:e.max!=I.length,isInspected:!1})})},onKeyDown:g=>{let{key:I}=g;I=="Tab"&&(t.set_optionFocused(""),t.set_status(R=>f(l({},R),{eventID:v(8),isPickerOpen:!1,isFocusing:!1})))}})},c.id)})]})]})}))})):null},Selected:t=>{let{rootStates:e,val_status:i,set_status:r,val_optionsDict:d}=t,m=[];return i.rawValue.forEach(o=>{let n=d[p.Stringify(o)];if(!n)return;let c=e.onSelectedRender,h=(n==null?void 0:n.selectedLabel)||(n==null?void 0:n.label);(n==null?void 0:n.value)===null&&(h=""),m.push(s(q,{position:"relative",flexCenter:!0,freeCSS:{userSelect:"none"},children:s(c,{value:n==null?void 0:n.value,label:h,onRemove:k=>{if(e.disabled)return;let a=[...i.rawValue];a=a.filter(u=>u!==o),r(u=>f(l({},u),{rawValue:a,eventType:"update",eventID:v(8),isInspected:!1,isFocusing:e.max!=a.length,isPickerOpen:!0}))}})},p.Stringify(n==null?void 0:n.value)||v(8)))}),s(N,{children:m})},Core:t=>{var x,P,E;let{value:e}=t,[i,r]=A(!1),[d,m]=A(""),[o,n]=A(t.options),[c,h]=A(((x=t.options.find(w=>{var O;return(w==null?void 0:w.value)===((O=t.value)==null?void 0:O[0])}))==null?void 0:x.id)||((P=t.options[0])==null?void 0:P.id)||""),[k,a]=A({}),[u,y]=A(z.DefaultStatus(t.componentId,e)),S=ne(!1);F(()=>{i||(S.current?n(t.options):S.current=!0)},[p.Stringify((E=t.options)==null?void 0:E.map(w=>w.value))]),F(()=>{if(!o.length)return;let w=[...o],O=l({},k);w.forEach(_=>{(_==null?void 0:_.type)!="label"&&(O[p.Stringify(_==null?void 0:_.value)]=_)}),a(O)},[o]);let g={rootStates:t,val_options:o,set_options:n,val_optionFocused:c,set_optionFocused:h,val_optionsDict:k,set_optionsDict:a,val_optionsModified:i,set_optionsModified:r,val_keyword:d,set_keyword:m,val_status:u,set_status:y},I=!!t.multiSelect;z.CommonEffects({type:I?"autocomplete.multi":"autocomplete.single",states:t,val_status:u,set_status:y,SystemValidation:pe});let R=u.rawValue.length&&u.rawValue[0]!==null||u.isPickerOpen||u.isFocusing;return V(se,{val_status:u,set_status:y,states:t,children:[s(ce,{componentId:t.componentId,fontSize:t.fontSize,required:t.required,label:t.label,isActive:R}),s(C.Button,l({},g))]})}},Y=t=>{let e=l({},t);return e=f(l({value:[],min:0,max:65535,multiSelect:!0,emptySelect:!0,onSelectorRender:i=>{var r;return i.option?((r=i.option)==null?void 0:r.type)=="label"?s(N,{children:i.option.label}):s($.Sub.S,{color:"cloud",tabIndex:-1,backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["2/3",1.5],isActive:i.isFocused,isActiveStyles:{backgroundColor:"cloud"},onClick:i.onAdd,onKeyDown:i.onKeyDown,children:V(K.Left,{gap:"1/2",children:[i.isSelected&&s(B.Check,{fontColor:"theme"}),s(W.Supplement,{transition:"short",children:i.option.label})]})}):null},onSelectedRender:i=>V(K.Left,{ssCardBox:!0,borderRadius:"1.tone.primary",fontSize:"1.mini",padding:"1/3",gap:0,children:[s(W,{padding:[0,"1/2"],children:i.label}),s($.Clear,{flexSizing:"none",color:"nega",fontColor:"4.thin",tabIndex:-1,ssSphere:2,onClick:i.onRemove,freeCSS:{lineHeight:1,aspectRatio:"1/1"},children:s(B.X,{})})]}),pickerPosition:3},e),{freeCSS:l({cursor:"pointer"},e.freeCSS)}),e.multiSelect||(e.min=0,e.max=1),e.options=e.options||[],e.emptySelect&&(e.options=[{value:null,label:s(W.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...e.options]),e.value=p.flatArray(e.value),e.options=C.InitOptions(e.options),p.is.nullish(e.rightIcon)&&(e.rightIcon=s(Q,{children:s(B.Search,{})}),e.disabled&&(e.rightIcon=s(Q,{fontColor:"5.translucent",children:s(B.Ban,{})}))),e.rightIcon&&(e=l({paddingRight:3},e)),e.leftIcon&&(e=l({paddingLeft:3},e)),s(re,{componentId:e.componentId,children:C.Core,states:ue(e)})};export{Y as Autocomplete,Y as default};
|
package/dist/fn/Input/Select.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a,c,d as U}from"../../chunk-C5N2D3ZX.js";import{Fragment as te,jsx as o,jsxs as h}from"react/jsx-runtime";import y,{UUID as m}from"jmini";import{useState as Y,useEffect as q}from"react";import{Box as V,FAI as Z,Column as ve}from"../../atoms";import{Literal as z,Row as H}from"../../mols";import{Button as Ie}from"../Button";import{Sheet as be}from"../Sheet";import{OptionalInputWrapper as ge,BoxWrapper as ke,CoreEffects as w,DefaultBoxishStyles as he}from"./core";import{InputAutocompleteClasses as F}from"../../@styles/componentClasses";import{InputLabel as Ce}from"./Label";import{RightIcon as Ve}from".";function we(t){let{value:e,states:n}=t,{required:d,options:u}=n,r=[];return d&&e===null&&r.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!r.filter(({type:v})=>v=="invalid").length,notice:r}}const b={FilterSelectableOptions:(t,e)=>{let n=t.rootStates.options;return e||(n=n.filter(d=>(d==null?void 0:d.type)!="label")),n},Button:t=>h(te,{children:[o(b.Native,a({},t)),o(b.Original,a({},t))]}),Placeholder:t=>!t.rootStates.placeholder||t.val_status.rawValue!==null?null:o(V,{position:"absolute",opacity:"middle",fontColor:"3.blur",children:t.rootStates.placeholder||""}),Native:t=>{let{rootStates:e,val_status:n,set_status:d}=t,P=e,{tone:u,required:r,form:v,className:s,label:I,isLabelActive:g,placeholder:R,enableFormSubmit:T,emptySelect:x,checkValidationAtFirst:A,onValidate:L,onValidateDelay:$,onUpdateValue:le,onUpdateValidValue:ae,onUserAction:ne,onKeyDown:W,onChange:N,value:re="",options:M,leftIndicator:ie,rightIndicator:se,leftIcon:oe,rightIcon:ue,componentId:ce,status_id:de,wrapStyles:pe,selectedStyles:fe,selectorStyles:Se,pickerStyles:me,pickerPosition:ye,nativePicker:D}=P,i=U(P,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","onKeyDown","onChange","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","selectedStyles","selectorStyles","pickerStyles","pickerPosition","nativePicker"]);return D?h(V,c(a({htmlTag:"select",tabIndex:0},i),{"data-disabled":e.disabled,"data-show-validation":w.isShowValidation(n,!!A),"data-component-id":n.componentId,"data-input-origin":n.componentId,className:[s,F("Core")].join(" "),onKeyDown:l=>{W&&W(l),T&&w.SubmitForm(l,v)},onChange:l=>{let{value:f}=l.target;d(O=>c(a({},O),{rawValue:f,eventType:"update",eventID:m(12),isInspected:!1,isValidated:!1,notice:[]})),N&&N(l)},children:[!!x&&o("option",{value:"null",children:"\u9078\u629E"}),M.map(l=>y.is.nullish(l==null?void 0:l.value)?null:o("option",{value:l==null?void 0:l.value,children:(l==null?void 0:l.label)||(l==null?void 0:l.value)},String(l==null?void 0:l.value)))]})):null},Original:t=>{let{rootStates:e,val_optionFocused:n,set_optionFocused:d,val_status:u,set_status:r}=t,P=e,{tone:v,required:s,form:I,className:g,label:R,isLabelActive:T,placeholder:x,enableFormSubmit:A,emptySelect:L,checkValidationAtFirst:$,onValidate:le,onValidateDelay:ae,onUpdateValue:ne,onUpdateValidValue:W,onUserAction:N,value:re="",options:M,leftIndicator:ie,rightIndicator:se,leftIcon:oe,rightIcon:ue,componentId:ce,status_id:de,wrapStyles:pe,selectedStyles:fe,selectorStyles:Se,pickerStyles:me,pickerPosition:ye,nativePicker:D}=P,i=U(P,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","selectedStyles","selectorStyles","pickerStyles","pickerPosition","nativePicker"]);return q(()=>{if(D||e.disabled)return;let l="select-click-"+e.componentId;if(u.isPickerOpen){if(!y('[data-input-origin="'+e.componentId+'"]'))return;y(document).addEvent({eventID:l,eventType:"click",callback:O=>{let B=y(O.target),E=!!y(B).parent("."+F("Core")).length;y(B).parent("."+F("Selector")).length||E||r(p=>c(a({},p),{eventID:m(12),isPickerOpen:!1}))}})}else y(document).removeEvent([l])},[u.isPickerOpen]),q(()=>{if(D||u.eventType=="init"||!u.isPickerOpen)return;let l=y('[data-input-origin="'+e.componentId+'"]');l&&l.focus()},[u.rawValue]),D?null:h(te,{children:[o(V,c(a({tabIndex:0},i),{"data-disabled":e.disabled,"data-show-validation":w.isShowValidation(u,!!$),"data-component-id":u.componentId,"data-input-origin":u.componentId,className:[g,F("Core")].join(" "),onFocus:l=>{i!=null&&i.onFocus&&(i==null||i.onFocus(l)),!e.disabled&&r(f=>c(a({},f),{eventID:m(12),isFocusing:!0,isPickerOpen:!0}))},onBlur:l=>{i!=null&&i.onBlur&&(i==null||i.onBlur(l)),r(f=>c(a({},f),{eventID:m(12),isFocusing:!1}))},onClick:l=>{i!=null&&i.onClick&&(i==null||i.onClick(l)),!e.disabled&&r(f=>c(a({},f),{eventID:m(12),isPickerOpen:!0}))},onKeyDown:l=>{let{key:f,metaKey:O,ctrlKey:B}=l,E=O||B;if(i!=null&&i.onKeyDown&&(i==null||i.onKeyDown(l)),A&&w.SubmitForm(l,I),!e.disabled){if(y.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(f))return;if(l.preventDefault(),!u.isPickerOpen){r(k=>c(a({},k),{eventID:m(12),isPickerOpen:!0}));return}let S=f=="ArrowDown"?1:-1,p=b.FilterSelectableOptions(t),_=p.length-1,C=null;y.scope(()=>{var j,J,X,G,Q;let k=p.findIndex(K=>(K==null?void 0:K.id)==n);if(S==1){if(C=(j=p[0])==null?void 0:j.id,E){C=p[_].id;return}if(k==-1||k==_)return;C=(J=p[k+1])==null?void 0:J.id}else{if(C=(X=p[_])==null?void 0:X.id,E){C=(G=p[0])==null?void 0:G.id;return}if(k==-1||k==0)return;C=(Q=p[k-1])==null?void 0:Q.id}}),d(C)}),f=="Escape")r(S=>c(a({},S),{eventID:m(12),isPickerOpen:!1}));else if(f=="Tab")r(S=>c(a({},S),{eventID:m(12),isPickerOpen:!1}));else if(f=="Backspace")r(S=>c(a({},S),{rawValue:null,eventType:"update",eventID:m(12),isInspected:!1}));else if(f==" ")l.preventDefault(),r(S=>c(a({},S),{eventID:m(12),isPickerOpen:!0}));else if(f=="Enter"){if(!u.isPickerOpen){r(p=>c(a({},p),{eventID:m(12),isPickerOpen:!0}));return}l.preventDefault();let S=e.options.find(p=>(p==null?void 0:p.id)==n);if(!S)return;r(p=>c(a({},p),{rawValue:S==null?void 0:S.value,eventType:"update",eventID:m(12),isPickerOpen:!1,isInspected:!1}))}}},children:h(H.Left,{gap:0,children:[o(V,{freeCSS:{width:0},overflow:"hidden",opacity:"trans","data-input-value-shallow":u.componentId,children:"A"}),h(H.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[o(b.Placeholder,a({},t)),o(b.Selected,a({},t))]})]})})),o(b.Picker,a({},t))]})},Picker:t=>{var v;let{rootStates:e,val_status:n,val_optionFocused:d}=t;q(()=>{let s=y(`[data-picker-id="${n.componentId}"]`)[0];if(!s)return;let I=y(`[data-select-input-value="${d}"]`)[0];I&&(s.scrollTop=I.offsetTop-24)},[d]);let u=b.FilterSelectableOptions(t,!0),r={};{let s=e.pickerPosition||0;[1,2].includes(s)?r.bottom="100%":[3,4].includes(s)&&(r.top="100%"),[1,3].includes(s)?r.left=0:[2,4].includes(s)&&(r.right=0)}return n.isPickerOpen?o(V,c(a({position:"absolute",minWidth:1,padding:"2/3"},r),{freeCSS:a({zIndex:1e3},r.freeCSS),children:o(be.Body,c(a({className:F("Selector"),ssCardBox:!0,borderRadius:"2.tone.secondary",boxShadow:"1.normal",overflow:"auto","data-picker-id":n.componentId},e.pickerStyles),{freeCSS:a({minWidth:12*6,maxHeight:12*24},(v=e.pickerStyles)==null?void 0:v.freeCSS),children:h(ve,{gap:"1/12",padding:[1,0],children:[u.map((s,I)=>{if(!s)return null;let{type:g,value:R}=s,T=t.val_optionFocused==s.id,x=t.val_status.rawValue===R;return g=="label"?o(V,{children:s.label||s.value},m()):o(Ie.Sub.S,c(a({"data-select-input-value":s.id,color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1],isActive:x||T,isActiveStyles:T?{backgroundColor:"cloud"}:{backgroundColor:"theme.opa.few",fontColor:"theme"}},e.selectorStyles),{onClick:A=>{t.set_status(L=>c(a({},L),{rawValue:R,eventType:"update",eventID:m(12),isPickerOpen:!1,isInspected:!1}))},children:h(H.Left,{gap:"1/2",children:[x&&o(Z.Check,{fontColor:"theme"}),o(z.Supplement,{transition:"short",flexSizing:0,children:s.label||s.value})]})}),s.id)}),!u.length&&o(z.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]})}))})):null},Selected:t=>{let e=t.rootStates.options.find(n=>y.is.equal(n==null?void 0:n.value,t.val_status.rawValue));return!e||t.val_status.rawValue===null&&(t.rootStates.label||t.rootStates.placeholder)?null:o(V,c(a({},t.rootStates.selectedStyles),{children:(e==null?void 0:e.selectedLabel)||(e==null?void 0:e.label)||(e==null?void 0:e.value)}),String(e==null?void 0:e.value))},Core:t=>{var s,I;let{value:e}=t,[n,d]=Y(w.DefaultStatus(t.componentId,e)),[u,r]=Y(((s=t.options.find(g=>(g==null?void 0:g.value)===t.value))==null?void 0:s.id)||((I=t.options[0])==null?void 0:I.id)||""),v={rootStates:t,val_optionFocused:u,set_optionFocused:r,val_status:n,set_status:d};return w.CommonEffects({type:"select",states:t,val_status:n,set_status:d,SystemValidation:we}),h(ke,{val_status:n,set_status:d,states:t,children:[o(Ce,{componentId:t.componentId,fontSize:t.fontSize,required:t.required,label:t.label,isActive:t.isLabelActive||n.rawValue!==null}),o(b.Button,a({},v))]})}},ee=t=>{var n,d;let e=a({},t);return e=c(a({emptySelect:!0,nativePicker:!1,pickerPosition:3},e),{freeCSS:a({cursor:"pointer"},e.freeCSS)}),e.emptySelect&&(e.options=[{value:null,label:o(z.Supplement,{fontColor:"4.thin",children:"\u672A\u9078\u629E"})},...e.options]),e.value=(n=e.value)!=null?n:null,(d=e.options)==null||d.forEach((u,r)=>{if(!u)return;let{type:v,value:s}=u;e.options[r]=c(a({id:m(12)},u),{value:s,type:v||"selector"})}),y.is.nullish(e.rightIcon)&&(e.rightIcon=o(Ve,{children:o(Z.AngleDown,{})})),o(ge,{componentId:e.componentId,children:b.Core,states:he(e)})};export{ee as Select,ee as default};
|
|
1
|
+
import{b as n,c as u,d as U}from"../../chunk-C5N2D3ZX.js";import{Fragment as te,jsx as o,jsxs as V}from"react/jsx-runtime";import y,{UUID as v}from"jmini";import{useState as Y,useEffect as q}from"react";import{Box as T,FAI as Z,Column as ve}from"../../atoms";import{Literal as H,Row as $}from"../../mols";import{Button as Ie}from"../Button";import{Sheet as be}from"../Sheet";import{OptionalInputWrapper as ge,BoxWrapper as ke,CoreEffects as x,DefaultBoxishStyles as he}from"./core";import{InputAutocompleteClasses as F}from"../../@styles/componentClasses";import{InputLabel as Ce}from"./Label";import{RightIcon as Ve}from".";function we(t){let{value:e,states:a}=t,{required:c,options:d}=a,i=[];return c&&e===null&&i.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!i.filter(({type:I})=>I=="invalid").length,notice:i}}const k={FilterSelectableOptions:(t,e)=>{let a=t.rootStates.options;return e||(a=a.filter(c=>(c==null?void 0:c.type)!="label")),a},Button:t=>V(te,{children:[o(k.Native,n({},t)),o(k.Original,n({},t))]}),Placeholder:t=>!t.rootStates.placeholder||t.val_status.rawValue!==null?null:o(T,{position:"absolute",opacity:"middle",fontColor:"3.blur",children:t.rootStates.placeholder||""}),Native:t=>{let{rootStates:e,val_status:a,set_status:c}=t,P=e,{tone:d,required:i,form:I,className:r,label:b,isLabelActive:S,placeholder:h,enableFormSubmit:g,emptySelect:D,checkValidationAtFirst:R,onValidate:L,onValidateDelay:z,onUpdateValue:le,onUpdateValidValue:ae,onUserAction:ne,onKeyDown:W,onChange:_,value:re="",options:M,leftIndicator:ie,rightIndicator:se,leftIcon:oe,rightIcon:ue,componentId:ce,status_id:de,wrapStyles:pe,selectedStyles:fe,selectorStyles:Se,pickerStyles:me,pickerPosition:ye,nativePicker:A}=P,s=U(P,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","onKeyDown","onChange","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","selectedStyles","selectorStyles","pickerStyles","pickerPosition","nativePicker"]);return A?V(T,u(n({htmlTag:"select",tabIndex:0},s),{"data-disabled":e.disabled,"data-show-validation":x.isShowValidation(a,!!R),"data-component-id":a.componentId,"data-input-origin":a.componentId,className:[r,F("Core")].join(" "),onKeyDown:l=>{W&&W(l),g&&x.SubmitForm(l,I)},onChange:l=>{let{value:f}=l.target;c(O=>u(n({},O),{rawValue:f,eventType:"update",eventID:v(12),isInspected:!1,isValidated:!1,notice:[]})),_&&_(l)},children:[!!D&&o("option",{value:"null",children:"\u9078\u629E"}),M.map(l=>y.is.nullish(l==null?void 0:l.value)?null:o("option",{value:l==null?void 0:l.value,children:(l==null?void 0:l.label)||(l==null?void 0:l.value)},String(l==null?void 0:l.value)))]})):null},Original:t=>{let{rootStates:e,val_optionFocused:a,set_optionFocused:c,val_status:d,set_status:i}=t,P=e,{tone:I,required:r,form:b,className:S,label:h,isLabelActive:g,placeholder:D,enableFormSubmit:R,emptySelect:L,checkValidationAtFirst:z,onValidate:le,onValidateDelay:ae,onUpdateValue:ne,onUpdateValidValue:W,onUserAction:_,value:re="",options:M,leftIndicator:ie,rightIndicator:se,leftIcon:oe,rightIcon:ue,componentId:ce,status_id:de,wrapStyles:pe,selectedStyles:fe,selectorStyles:Se,pickerStyles:me,pickerPosition:ye,nativePicker:A}=P,s=U(P,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","selectedStyles","selectorStyles","pickerStyles","pickerPosition","nativePicker"]);return q(()=>{if(A||e.disabled)return;let l="select-click-"+e.componentId;if(d.isPickerOpen){if(!y('[data-input-origin="'+e.componentId+'"]'))return;y(document).addEvent({eventID:l,eventType:"click",callback:O=>{let B=y(O.target),E=!!y(B).parent("."+F("Core")).length;y(B).parent("."+F("Selector")).length||E||i(p=>u(n({},p),{eventID:v(12),isPickerOpen:!1}))}})}else y(document).removeEvent([l])},[d.isPickerOpen]),A?null:V(te,{children:[o(T,u(n({tabIndex:0},s),{"data-disabled":e.disabled,"data-show-validation":x.isShowValidation(d,!!z),"data-component-id":d.componentId,"data-input-origin":d.componentId,className:[S,F("Core")].join(" "),onFocus:l=>{s!=null&&s.onFocus&&(s==null||s.onFocus(l)),!e.disabled&&i(f=>u(n({},f),{eventID:v(12),isFocusing:!0,isPickerOpen:!0}))},onBlur:l=>{s!=null&&s.onBlur&&(s==null||s.onBlur(l)),i(f=>u(n({},f),{eventID:v(12),isFocusing:!1}))},onClick:l=>{s!=null&&s.onClick&&(s==null||s.onClick(l)),!e.disabled&&i(f=>u(n({},f),{eventID:v(12),isPickerOpen:!0}))},onKeyDown:l=>{let{key:f,metaKey:O,ctrlKey:B}=l,E=O||B;if(s!=null&&s.onKeyDown&&(s==null||s.onKeyDown(l)),R&&x.SubmitForm(l,b),!e.disabled){if(y.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(f))return;if(l.preventDefault(),!d.isPickerOpen){i(C=>u(n({},C),{eventID:v(12),isPickerOpen:!0}));return}let m=f=="ArrowDown"?1:-1,p=k.FilterSelectableOptions(t),N=p.length-1,w=null;y.scope(()=>{var j,J,X,G,Q;let C=p.findIndex(K=>(K==null?void 0:K.id)==a);if(m==1){if(w=(j=p[0])==null?void 0:j.id,E){w=p[N].id;return}if(C==-1||C==N)return;w=(J=p[C+1])==null?void 0:J.id}else{if(w=(X=p[N])==null?void 0:X.id,E){w=(G=p[0])==null?void 0:G.id;return}if(C==-1||C==0)return;w=(Q=p[C-1])==null?void 0:Q.id}}),c(w)}),f=="Escape")i(m=>u(n({},m),{eventID:v(12),isPickerOpen:!1}));else if(f=="Tab")i(m=>u(n({},m),{eventID:v(12),isPickerOpen:!1}));else if(f=="Backspace")i(m=>u(n({},m),{rawValue:null,eventType:"update",eventID:v(12),isInspected:!1}));else if(f==" ")l.preventDefault(),i(m=>u(n({},m),{eventID:v(12),isPickerOpen:!0}));else if(f=="Enter"){if(!d.isPickerOpen){i(p=>u(n({},p),{eventID:v(12),isPickerOpen:!0}));return}l.preventDefault();let m=e.options.find(p=>(p==null?void 0:p.id)==a);if(!m)return;i(p=>u(n({},p),{rawValue:m==null?void 0:m.value,eventType:"update",eventID:v(12),isPickerOpen:!1,isInspected:!1}))}}},children:V($.Left,{gap:0,children:[o(T,{freeCSS:{width:0},overflow:"hidden",opacity:"trans","data-input-value-shallow":d.componentId,children:"A"}),V($.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[o(k.Placeholder,n({},t)),o(k.Selected,n({},t))]})]})})),o(k.Picker,n({},t))]})},Picker:t=>{var I;let{rootStates:e,val_status:a,val_optionFocused:c}=t;q(()=>{if(!a.isPickerOpen||!a.rawValue)return;let r=y(`[data-picker-id="${a.componentId}"]`)[0];if(!r)return;let b=r.position(),S=e.options.find(g=>(g==null?void 0:g.value)===a.rawValue);if(!S)return;let h=y(`[data-select-input-value="${S.id}"]`)[0];h&&(r.scrollTop=h.offsetTop-b.height/2+h.offsetHeight/2)},[a.isPickerOpen]),q(()=>{let r=y(`[data-picker-id="${a.componentId}"]`)[0];if(!r)return;let b=r.position(),S=y(`[data-select-input-value="${c}"]`)[0];S&&(r.scrollTop=S.offsetTop-b.height/2+S.offsetHeight/2)},[c]);let d=k.FilterSelectableOptions(t,!0),i={};{let r=e.pickerPosition||0;[1,2].includes(r)?i.bottom="100%":[3,4].includes(r)&&(i.top="100%"),[1,3].includes(r)?i.left=0:[2,4].includes(r)&&(i.right=0)}return a.isPickerOpen?o(T,u(n({position:"absolute",minWidth:1,padding:"1/3"},i),{freeCSS:n({zIndex:1e3},i.freeCSS),children:o(be.Body,u(n({className:F("Selector"),ssCardBox:!0,borderRadius:"2.tone.secondary",boxShadow:"1.normal",overflow:"auto","data-picker-id":a.componentId},e.pickerStyles),{freeCSS:n({minWidth:12*6,maxHeight:12*24},(I=e.pickerStyles)==null?void 0:I.freeCSS),children:V(ve,{gap:"1/12",padding:[1,0],children:[d.map((r,b)=>{if(!r)return null;let{type:S,value:h}=r,g=t.val_optionFocused==r.id,D=t.val_status.rawValue===h;return S=="label"?o(T,{children:r.label||r.value},v()):o(Ie.Sub.S,u(n({"data-select-input-value":r.id,color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1],isActive:D||g,isActiveStyles:g?{backgroundColor:"cloud"}:{backgroundColor:"theme.opa.few",fontColor:"theme"}},e.selectorStyles),{onClick:R=>{t.set_status(L=>u(n({},L),{rawValue:h,eventType:"update",eventID:v(12),isPickerOpen:!1,isInspected:!1}))},children:V($.Left,{gap:"1/2",children:[D&&o(Z.Check,{fontColor:"theme"}),o(H.Supplement,{transition:"short",flexSizing:0,children:r.label||r.value})]})}),r.id)}),!d.length&&o(H.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]})}))})):null},Selected:t=>{let e=t.rootStates.options.find(a=>y.is.equal(a==null?void 0:a.value,t.val_status.rawValue));return!e||t.val_status.rawValue===null&&(t.rootStates.label||t.rootStates.placeholder)?null:o(T,u(n({},t.rootStates.selectedStyles),{children:(e==null?void 0:e.selectedLabel)||(e==null?void 0:e.label)||(e==null?void 0:e.value)}),String(e==null?void 0:e.value))},Core:t=>{var r,b;let{value:e}=t,[a,c]=Y(x.DefaultStatus(t.componentId,e)),[d,i]=Y(((r=t.options.find(S=>(S==null?void 0:S.value)===t.value))==null?void 0:r.id)||((b=t.options[0])==null?void 0:b.id)||""),I={rootStates:t,val_optionFocused:d,set_optionFocused:i,val_status:a,set_status:c};return x.CommonEffects({type:"select",states:t,val_status:a,set_status:c,SystemValidation:we}),V(ke,{val_status:a,set_status:c,states:t,children:[o(Ce,{componentId:t.componentId,fontSize:t.fontSize,required:t.required,label:t.label,isActive:t.isLabelActive||a.rawValue!==null}),o(k.Button,n({},I))]})}},ee=t=>{var a,c;let e=n({},t);return e=u(n({emptySelect:!0,nativePicker:!1,pickerPosition:3},e),{freeCSS:n({cursor:"pointer"},e.freeCSS)}),e.emptySelect&&(e.options=[{value:null,label:o(H.Supplement,{fontColor:"4.thin",children:"\u672A\u9078\u629E"})},...e.options]),e.value=(a=e.value)!=null?a:null,(c=e.options)==null||c.forEach((d,i)=>{if(!d)return;let{type:I,value:r}=d;e.options[i]=u(n({id:v(12)},d),{value:r,type:I||"selector"})}),y.is.nullish(e.rightIcon)&&(e.rightIcon=o(Ve,{children:o(Z.AngleDown,{})})),o(ge,{componentId:e.componentId,children:k.Core,states:he(e)})};export{ee as Select,ee as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as h,c as v}from"../../../chunk-C5N2D3ZX.js";import{Fragment as W,jsx as e,jsxs as c}from"react/jsx-runtime";import{createElement as q}from"react";import g,{UUID as $,Time as m}from"jmini";import{useState as w,useEffect as D}from"react";import{Box as x,Grid as E,FAI as R,Column as k,FlexMargin as V}from"../../../atoms";import{Row as C,Literal as b}from"../../../mols";import{Button as M}from"../../Button";import I from"../../Sheet";import _ from"../Select";import{LeftIcon as O,RightIcon as N}from"..";import{InputTimeClasses as B}from"../../../@styles/componentClasses";import L from"../Drum";const X=t=>{let{restrict:u}=t;return u=="year"?e(y.Year,h({},t)):u=="month"?e(y.Month.index,h({},t)):u=="week"?"[DEV]":u=="date"?e(y.Date.index,h({},t)):u=="locale.jp.warekiDate"?e(y.Locale.JP.WarekiDate.index,h({},t)):u=="clock"?e(y.Clock.index,h({},t)):u=="period.clock"?e(y.Period.Clock.index,h({},t)):u=="period.month"?e(y.Period.Month.index,h({},t)):u=="period.date"?e(y.Period.Date.index,h({},t)):null},y={YearOptions:t=>{var s,o,n;let u=[],S=(s=t==null?void 0:t.min)!=null?s:1900,r=(o=t==null?void 0:t.max)!=null?o:m().addYear(10).year;for(let l=S;l<=r;l++){let a=[l],[p,i]=g.transformer.wareki(l).value;((n=t.showJPWareki)==null||n)&&(p&&a.push(e(b.Supplement,{fontSize:"0.xs",fontColor:"4.thin",children:p},1)),i&&a.push(c(b.Supplement,{fontSize:"0.xs",fontColor:"4.thin",children:["[",i,"]"]},2))),u.unshift({value:l,label:e(C.Center,{gap:["1/12","1/4"],verticalAlign:"baseline",flexWrap:!0,children:a})})}return u},calendartypeState:()=>{let[t,u]=w(localStorage.getItem("@env/input/time/selector/calendartype")||"calendar");return D(()=>{localStorage.setItem("@env/input/time/selector/calendartype",String(t))},[t]),[t,u]},Year:t=>{let{min:u,max:S}=t,[r,s]=w(g.scope(()=>{let[o]=String(t.defaultValue).split(/\D/);return{eventType:"init",from:m().setYear(Number(o||m().year))}}));return D(()=>{t.onValueUpdate({value:String(r.from.year||null),era:"year",eventType:r.eventType})},[r]),c(k,{freeCSS:{minWidth:12*16},children:[c(C.Left,{flexWrap:!0,children:[c(b.Paragraph,{children:[r.from.year||"----","\u5E74"]}),e(M.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let o=m();s({eventType:"update",from:o})},children:"\u4ECA\u5E74"}),e(V,{})]}),e(x,{borderTop:!0}),e(L,{override:"force",value:r.from.year||null,options:y.YearOptions({min:Number(u)||void 0,max:Number(S)||void 0}),onUpdateValidValue:o=>{s(n=>({eventType:"update",from:n.from.clone().setYear(Number(o))}))}}),e(y.Parts.FooterNav,v(h({},t),{set_value:s,onClear:()=>{s(o=>({eventType:"update",from:m(null)}))}}))]})},Month:{index:t=>{let{min:u,max:S}=t,[r,s]=w(g.scope(()=>{let[o,n]=String(t.defaultValue).split(/\D/);(g.is.nullish(o)||g.is.nullish(n))&&([o,n]=m().toFormat("%Y-%M").split("-"));let l=m(),a=m().setYear(Number(o)||l.year).setMonth(Number(n)||l.month).setDate(1);return{eventType:"init",from:a,display:a}}));return D(()=>{t.onValueUpdate({value:r.from.toFormatYM(),era:"year",eventType:r.eventType})},[r]),c(k,{freeCSS:{minWidth:12*16},children:[c(C.Left,{gap:"1/2",children:[e(b.Paragraph,{children:r.from.toFormatYM("JP")||"----/--"}),e(M.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let o=m();s({eventType:"update",from:o,display:o})},children:"\u4ECA\u6708"}),e(V,{})]}),e(x,{borderTop:!0}),e(y.Parts.DrumSelector,{type:"month",min:u,max:S,value:r.from,onChange:o=>{s(v(h({},r),{eventType:"update",from:o}))}}),e(y.Parts.FooterNav,v(h({},t),{set_value:s,onClear:()=>{s(o=>v(h({},o),{eventType:"commit",from:m(null)}))}}))]})}},Date:{index:t=>{let{min:u,max:S}=t,[r,s]=y.calendartypeState(),[o,n]=w(g.scope(()=>{var f;let[l,a,p]=(f=String(t.defaultValue))==null?void 0:f.split(/\D/);(g.is.nullish(l)||g.is.nullish(a)||g.is.nullish(p))&&([l,a,p]=m().toFormat("%Y-%M-%D").split("-"));let i=m(),d=m([Number(l)||i.year,(Number(a)||i.month).zeroEmbed(2),(Number(p)||i.date).zeroEmbed(2)].join("/"));return{eventType:"init",era:"year",display:d,from:d}}));return D(()=>{t.onValueUpdate({value:o.from.toFormatYMD(),era:"year",eventType:o.eventType})},[o]),c(k,{freeCSS:{minWidth:12*16},children:[c(C.Left,{flexWrap:!0,children:[e(b.Paragraph,{children:o.from.toFormatYMD("JP")||"----/--/--"}),e(M.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let l=m();n({eventType:"update",era:"year",from:l,display:l})},children:"\u4ECA\u65E5"}),e(V,{}),c(M.Border.S,{padding:["1/6","1/2"],fontColor:"3.blur",fontSize:"0.xs",onClick:()=>{s(l=>l=="calendar"?"drum":"calendar")},children:[r=="calendar"&&"\u30C9\u30E9\u30E0",r=="drum"&&"\u30AB\u30EC\u30F3\u30C0\u30FC","\u8868\u793A"]})]}),e(x,{borderTop:!0}),r=="calendar"&&c(W,{children:[c(C.Right,{gap:"1/2",children:[e(_,{override:"force",emptySelect:!1,value:o.display.year,options:y.YearOptions({}),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,pickerStyles:{freeCSS:{minWidth:12*12}},onUpdateValidValue:l=>{n(a=>v(h({},a),{eventType:"update",display:a.display.clone().setYear(Number(l))}))},rightIcon:e(N,{right:"2/3",children:e(R.AngleDown,{})})}),e(_,{override:"force",emptySelect:!1,value:o.display.month,options:(()=>{let l=[];for(let a=1;a<=12;a++)l.push({value:a,label:String(a)+"\u6708"});return l})(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,pickerStyles:{freeCSS:{minWidth:12*8}},rightIcon:e(N,{right:"2/3",children:e(R.AngleDown,{})}),onUpdateValidValue:l=>{n(a=>v(h({},a),{eventType:"update",display:a.display.clone().setMonth(Number(l))}))}}),e(y.Parts.ShiftButtons,{callback:l=>{n(a=>v(h({},a),{eventType:"update",display:a.display.clone().addMonth(l)}))}})]}),e(C.Left,{verticalAlign:"top",flexWrap:!0,children:Array.from({length:4}).map((l,a)=>{let p=y.Parts.Calendar({min:u,max:S,targetMonth:o.display.clone().addMonth(a-1),from:o.from,onChange:i=>{n(d=>v(h({},d),{eventType:"update",from:i}))}});return e(C.Center,{flexSizing:0,ssHiddenOnBreak:a<1||a>2,children:p},a)})})]}),r=="drum"&&e(y.Parts.DrumSelector,{type:"date",min:u,max:S,value:o.from,onChange:l=>{n(v(h({},o),{eventType:"update",from:l}))}}),e(y.Parts.FooterNav,v(h({},t),{set_value:n,onClear:()=>{n(l=>v(h({},l),{eventType:"commit",from:m(null)}))}}))]})}},Locale:{JP:{WarekiDate:{index:t=>{var n;let{min:u,max:S}=t,[r,s]=w(g.scope(()=>{var F;let[l,a,p]=(F=String(t.defaultValue))==null?void 0:F.split(/\D/),i=t.era||"year";if(g.is.nullish(l)||g.is.nullish(a)||g.is.nullish(p)){let T=m();i=="heisei"?T.setYear(1989):i=="shouwa"?T.setYear(1926):i=="taisho"?T.setYear(1912):i=="meiji"&&T.setYear(1868),[l,a,p]=T.toFormat("%Y-%M-%D").split("-")}let d=m();return{eventType:"init",from:m([Number(l)||d.year,(Number(a)||d.month).zeroEmbed(2),(Number(p)||d.date).zeroEmbed(2)].join("/"))}}));D(()=>{t.onValueUpdate({value:r.from.toFormatYMD(),era:r.from.wareki.toLower(),eventType:r.eventType})},[r]);let o={year:{label:"\u897F\u66A6",min:"1900/01/01",max:"2100/12/31"},reiwa:{label:"\u4EE4\u548C",min:"2019/05/01",max:m().addYear(10).setMonth(12).setDate(31).toFormatYMD()},heisei:{label:"\u5E73\u6210",min:"1989/01/08",max:"2019/04/30"},showa:{label:"\u662D\u548C",min:"1926/12/25",max:"1989/01/07"},taisho:{label:"\u5927\u6B63",min:"1912/07/30",max:"1926/12/24"},meiji:{label:"\u660E\u6CBB",min:"1868/09/08",max:"1912/07/29"}};return c(k,{children:[c(C.Left,{gap:"1/4",flexWrap:!0,children:[c(b.Paragraph,{children:[r.from.warekiLabel,(n=r.from.warekiYear)==null?void 0:n.zeroEmbed(2),"\u5E74",r.from.toFormatMD("JP")]}),e(V,{})]}),e(x,{borderTop:!0}),e(C.Left,{gap:"1/2",flexWrap:!0,children:["reiwa","heisei","showa","taisho","meiji"].map((l,a)=>{let p=o[l];return p?e(M.Border.S,{onClick:()=>{let i=r.from;if(l=="reiwa"||l=="year")i=m();else{let d=m(p.min),f=m(p.max);d.value>r.from.value&&(i=d),r.from.value>f.value&&(i=f)}if(u){let d=m(u);i.value<d.value&&(i=d)}if(S){let d=m(S);d.value<i.value&&(i=d)}s(v(h({},r),{eventType:"update",from:i}))},children:p.label},a):null})}),e(y.Parts.DrumSelector,{type:"locale.jp.warekiDate",min:t.min,max:t.max,value:r.from,onChange:l=>{s(v(h({},r),{eventType:"update",from:l}))}}),e(y.Parts.FooterNav,v(h({},t),{set_value:s,onClear:()=>{s({eventType:"commit",from:m(null)})}}))]})}}}},Clock:{index:t=>{let[u,S]=w(g.scope(()=>{let a=String(t.defaultValue).split(/[^\d]/);if(!a[0]){let d=m();a=[d.hours,d.minutes]}let p=Number(a[0]),i=Number(a[1]);return{eventType:"init",from:m().setHours(p).setMinutes(i)}}));D(()=>{t.onValueUpdate({value:u.from.toFormatHM(),era:"clock",eventType:u.eventType})},[u]);let[r,s]=y.Clock.minutesUnitState(),o=m().setFromFormatHHMM(t.min||"00:00"),n=m().setFromFormatHHMM(t.max||"23:59");const l=(a,p)=>{S(i=>{let d=i.from.clone();return g.is.exist(a)&&d.setHours(a),g.is.exist(p)&&d.setMinutes(p),d.toFormatHM().toNumber()>n.toFormatHM().toNumber()&&(d=n.clone()),d.toFormatHM().toNumber()<o.toFormatHM().toNumber()&&(d=o.clone()),v(h({},i),{eventType:"update",from:d})})};return c(k,{freeCSS:{minWidth:12*16},children:[c(C.Left,{gap:"1/2",flexWrap:!0,children:[c(C.Center,{gap:"1/2",children:[e(x,{className:B("ClockBase"),children:e(y.Clock.UI,{val_value:u})}),c(x,{textAlign:"center",fontHeight:1.2,children:[c(b.Paragraph,{children:[u.from.hours.zeroEmbed(2)," : ",u.from.minutes.zeroEmbed(2)]}),c(b.Supplement,{fontColor:"4.thin",children:[u.from.hours>=12&&"PM"||"AM",u.from.hours%12,":",u.from.minutes.zeroEmbed(2)]})]})]}),e(M.Border.XS,{borderRadius:"2.tone.secondary",fontColor:"theme",onClick:()=>{let a=m().setSeconds(0);a.minutes=Math.round(a.minutes/r)*r,l(a.hours,a.minutes)},children:"\u73FE\u6642\u523B"}),e(V,{}),e(_,{emptySelect:!1,value:r,paddingLeft:3.5,leftIcon:e(O,{left:"2/3",children:"\u5358\u4F4D"}),pickerPosition:4,pickerStyles:{freeCSS:{minWidth:12*8}},padding:"1/2",options:[{value:10,label:"10\u5206"},{value:5,label:"5\u5206"},{value:1,label:"1\u5206"}],tabIndex:-1,onUpdateValidValue:a=>{s(a||1)}})]}),e(x,{borderTop:!0}),c(C.Center,{gap:"1/2",children:[e(L,{freeCSS:{maxHeight:12*12},override:"force",options:[{value:0,label:"\u5348\u524D"},{value:12,label:"\u5348\u5F8C"}],value:u.from.hours>=12?12:0,onUpdateValidValue:a=>{let p=u.from.hours%12+a;l(p)}}),e(L,{override:"force",value:u.from.hours,options:Array.from({length:24}).map((a,p)=>{let i=p;return o.hours>i||n.hours<i?null:{value:i,label:i.zeroEmbed(2)}}),onUpdateValidValue:a=>{l(a)}}),e(b,{isSemiBoldFont:!0,children:"\u6642"}),e(L,{override:"force",value:u.from.minutes,options:Array.from({length:60}).map((a,p)=>{let i=p;return i!=59&&(r==5&&i%5!=0||r==10&&i%10!=0)?null:{value:i,label:i.zeroEmbed(2)}}),onUpdateValidValue:a=>{l(void 0,a)}},r),e(b,{isSemiBoldFont:!0,children:"\u5206"})]}),e(y.Parts.FooterNav,v(h({},t),{set_value:S,onClear:()=>{S({eventType:"commit",from:m(null)})}}))]})},minutesUnitState:()=>{let[t,u]=w(Number(localStorage.getItem("@env/input/time/selector/clock/minutesUnit")||10));return D(()=>{localStorage.setItem("@env/input/time/selector/clock/minutesUnit",String(t))},[t]),[t,u]},UI:t=>{let{val_value:u}=t;return e(x,{className:B("ClockUiBase"),flexCenter:!0,children:c(x,{className:B("ClockUi"),backgroundColor:"theme.opa.low",isRounded:!0,position:"relative",children:[e(x,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[B("Needle"),B("hour")].join(" "),freeCSS:{transform:`rotate(${u.from.hours*30+u.from.minutes/2}deg)`}}),e(x,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[B("Needle"),B("minute")].join(" "),freeCSS:{transform:`rotate(${u.from.minutes*6}deg)`}})]})})}},Period:{Clock:{index:t=>{let{min:u,max:S}=t,[r,s]=y.Clock.minutesUnitState(),[o,n]=w(g.scope(()=>{let[i,d]=g.flatArray(t.defaultValue),f=m().setFromFormatHHMM(i||"09:00"),F=m().setFromFormatHHMM(d||"18:00");return{eventType:"init",forcus:0,display:f,from:f,to:F}}));D(()=>{if(!o.to.value)return;if(o.from.value>o.to.value){n(d=>v(h({},d),{eventType:"update",from:d.to,to:d.from}));return}t.onValueUpdate({value:[o.from.toFormatHM(),o.to.toFormatHM()],era:"clock",eventType:o.eventType})},[o]);let l=m().setFromFormatHHMM(t.min||"00:00"),a=m().setFromFormatHHMM(t.max||"23:59");const p=(i,d,f)=>{n(F=>{let T=F[i].clone();return g.is.exist(d)&&T.setHours(d),g.is.exist(f)&&T.setMinutes(f),T.toFormatHM().toNumber()>a.toFormatHM().toNumber()&&(T=a.clone()),T.toFormatHM().toNumber()<l.toFormatHM().toNumber()&&(T=l.clone()),v(h({},F),{eventType:"update",[i]:T})})};return c(k,{width:1,freeCSS:{minWidth:12*24},children:[c(C.Left,{flexWrap:!0,children:[c(C.Left,{gap:"1/2",children:[e(b.Paragraph,{children:o.from.toFormatHM()||"--:--"}),e(b.Supplement,{children:"-"}),e(b.Paragraph,{children:o.to.toFormatHM()||"--:--"})]}),e(V,{}),e(_,{emptySelect:!1,value:r,paddingLeft:3.5,leftIcon:e(O,{left:"2/3",children:"\u5358\u4F4D"}),pickerPosition:4,pickerStyles:{freeCSS:{minWidth:12*8}},padding:"1/2",options:[{value:10,label:"10\u5206"},{value:5,label:"5\u5206"},{value:1,label:"1\u5206"}],tabIndex:-1,onUpdateValidValue:i=>{s(i||1)}})]}),e(x,{borderBottom:"1.thin"}),e(y.Period.Preset,v(h({},t),{onPreset:(i,d)=>{n({eventType:"update",forcus:0,display:m(i),from:m(i),to:m(d)})}})),c(C.Center,{gap:"1/2",children:[e(L,{override:"force",value:o.from.hours,options:Array.from({length:24}).map((i,d)=>{let f=d;return l.hours>f||a.hours<f?null:{value:f,label:f.zeroEmbed(2)+"\u6642"}}),onUpdateValidValue:i=>{p("from",i)}}),e(L,{override:"force",value:o.from.minutes,options:Array.from({length:60}).map((i,d)=>{let f=d;return f!=59&&(r==5&&f%5!=0||r==10&&f%10!=0)?null:{value:f,label:f.zeroEmbed(2)+"\u5206"}}),onUpdateValidValue:i=>{p("from",void 0,i)}},r+"-from"),e(b,{isSemiBoldFont:!0,children:"~"}),e(L,{override:"force",value:o.to.hours,options:Array.from({length:24}).map((i,d)=>{let f=d;return l.hours>f||a.hours<f?null:{value:f,label:f.zeroEmbed(2)+"\u6642"}}),onUpdateValidValue:i=>{p("to",i)}}),e(L,{override:"force",value:o.to.minutes,options:Array.from({length:60}).map((i,d)=>{let f=d;return f!=59&&(r==5&&f%5!=0||r==10&&f%10!=0)?null:{value:f,label:f.zeroEmbed(2)+"\u5206"}}),onUpdateValidValue:i=>{p("to",void 0,i)}},r+"-to")]}),e(y.Parts.FooterNav,v(h({},t),{set_value:n,onClear:()=>{n({eventType:"commit",forcus:0,display:m(),from:m(null),to:m(null)})}}))]})}},Date:{index:t=>{let{min:u,max:S}=t,[r,s]=w(g.scope(()=>{let[o,n]=g.flatArray(t.defaultValue),l=m(o||void 0).setFirstOfDay(),a=m(n||null).setFirstOfDay();return{eventType:"init",forcus:0,display:l,from:l,to:a}}));return D(()=>{if(!r.to.value)return;if(r.from.value>r.to.value){s(n=>v(h({},n),{eventType:"update",from:n.to,to:n.from}));return}t.onValueUpdate({value:[r.from.toFormatYMD(),r.to.toFormatYMD()],era:"year",eventType:r.eventType})},[r]),c(k,{freeCSS:{minWidth:12*16},children:[c(C.Left,{gap:"1/2",flexWrap:!0,children:[e(b.Supplement,{fontColor:"4.thin",children:"from"}),c(M.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{s(o=>v(h({},o),{forcus:0}))},children:[r.from.toFormatYMD()||"----/--/--",r.forcus==0&&e(y.Parts.PeriodFocusSign,{})]}),e(b.Supplement,{fontColor:"4.thin",children:"to"}),c(M.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{s(o=>v(h({},o),{forcus:1}))},children:[r.to.toFormatYMD()||"----/--/--",r.forcus==1&&e(y.Parts.PeriodFocusSign,{})]}),e(V,{}),c(C.Left,{marginLeft:"auto",flexWrap:!0,gap:"1/2",children:[e(_,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{freeCSS:{minWidth:12*12}},rightIcon:e(N,{right:"2/3",children:e(R.AngleDown,{})}),options:y.YearOptions({}),value:r.display.year,onUpdateValidValue:o=>{s(n=>v(h({},n),{eventType:"update",display:n.display.clone().setYear(Number(o))}))}}),e(_,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{freeCSS:{minWidth:12*9}},rightIcon:e(N,{right:"2/3",children:e(R.AngleDown,{})}),options:[{value:1,label:"1\u6708"},{value:2,label:"2\u6708"},{value:3,label:"3\u6708"},{value:4,label:"4\u6708"},{value:5,label:"5\u6708"},{value:6,label:"6\u6708"},{value:7,label:"7\u6708"},{value:8,label:"8\u6708"},{value:9,label:"9\u6708"},{value:10,label:"10\u6708"},{value:11,label:"11\u6708"},{value:12,label:"12\u6708"}],value:r.display.month,onUpdateValidValue:o=>{s(n=>v(h({},n),{eventType:"update",display:n.display.clone().setMonth(Number(o)).setDate(1)}))}}),e(y.Parts.ShiftButtons,{callback:o=>{s(n=>v(h({},n),{eventType:"update",display:n.display.clone().addMonth(o)}))}})]})]}),e(x,{borderBottom:"1.thin"}),e(y.Period.Preset,v(h({},t),{onPreset:(o,n)=>{s({eventType:"update",forcus:0,display:m(o),from:m(o),to:m(n)})}})),e(C.Left,{verticalAlign:"top",flexWrap:!0,children:Array.from({length:4}).map((o,n)=>{let l=y.Parts.Calendar({min:u,max:S,targetMonth:r.display.clone().addMonth(n),from:r.from,to:r.to,onChange:a=>{if(r.forcus==0){s(p=>v(h({},p),{eventType:"update",forcus:1,from:a,to:m(null)}));return}s(p=>v(h({},p),{eventType:"update",to:a}))}});return e(C.Center,{flexSizing:0,ssHiddenOnBreak:n>1,children:l},n)})}),e(y.Parts.FooterNav,v(h({},t),{set_value:s,onClear:()=>{s({eventType:"update",forcus:0,display:m(),from:m(null),to:m(null)})}}))]})}},Month:{index:t=>{let{min:u,max:S}=t,[r,s]=w(g.scope(()=>{let[o,n]=g.flatArray(t.defaultValue),l=m(o||void 0).setDate(1).setFirstOfDay(),a=m(n||null).setDate(1).setFirstOfDay();return{eventType:"init",forcus:0,display:l,from:l,to:a}}));return D(()=>{if(!r.to.value)return;if(r.from.value>r.to.value){s(n=>v(h({},n),{eventType:"update",from:n.to,to:n.from}));return}t.onValueUpdate({value:[r.from.toFormatYM(),r.to.toFormatYM()],era:"year",eventType:r.eventType})},[r]),c(k,{freeCSS:{minWidth:12*16},children:[c(C.Left,{gap:"1/2",flexWrap:!0,children:[e(b.Supplement,{fontColor:"4.thin",children:"from"}),c(M.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{s(o=>v(h({},o),{forcus:0}))},children:[r.from.toFormatYM("JP")||"----/--",r.forcus==0&&e(y.Parts.PeriodFocusSign,{})]}),e(b.Supplement,{fontColor:"4.thin",children:"to"}),c(M.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{s(o=>v(h({},o),{forcus:1}))},children:[r.to.toFormatYM("JP")||"----/--",r.forcus==1&&e(y.Parts.PeriodFocusSign,{})]}),e(V,{}),c(C.Left,{flexWrap:!0,gap:"1/2",marginLeft:"auto",children:[e(_,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{freeCSS:{minWidth:12*12}},rightIcon:e(N,{right:"2/3",children:e(R.AngleDown,{})}),options:y.YearOptions({}),value:r.display.year,onUpdateValidValue:o=>{s(n=>v(h({},n),{eventType:"update",display:n.display.clone().setYear(Number(o))}))}}),e(y.Parts.ShiftButtons,{callback:o=>{s(n=>v(h({},n),{eventType:"update",display:n.display.clone().addYear(o)}))}})]})]}),e(x,{borderBottom:"1.thin"}),e(y.Period.Preset,v(h({},t),{onPreset:(o,n)=>{s({eventType:"update",forcus:0,display:m(o),from:m(o),to:m(n)})}})),e(C.Left,{verticalAlign:"top",flexWrap:!0,children:Array.from({length:4}).map((o,n)=>{let l=y.Parts.MonthCalendar({min:u,max:S,targetYear:r.display.year+n,from:r.from.getFirstDayOfMonth(),to:r.to.getLastDayOfMonth(),onChange:a=>{if(r.forcus==0){s(p=>v(h({},p),{eventType:"update",forcus:1,from:a,to:m(null)}));return}s(p=>v(h({},p),{eventType:"update",to:a}))}});return e(C.Center,{flexSizing:0,ssHiddenOnBreak:n>=2,children:l},n)})}),e(y.Parts.FooterNav,v(h({},t),{set_value:s,onClear:()=>{s({eventType:"update",forcus:0,display:m(),from:m(null),to:m(null)})}}))]})}},Preset:t=>t.periodPresets?e(C.Right,{gap:"1/2",flexWrap:!0,children:t.periodPresets.map((u,S)=>e(M.Border.S,{padding:["1/4",1],onClick:()=>{t.onPreset(u.from,u.to)},children:u.label},S))}):null},Parts:{FooterNav:t=>t.commitFooter?c(W,{children:[e(x,{borderBottom:"1.thin"}),c(C.Separate,{gap:"1/2",children:[c(M.Sub,{color:"cloud",tabIndex:-1,fontSize:"1.mini",borderRadius:"2.tone.secondary",flexSizing:"none",onClick:()=>{t.onClear()},children:[e(R.X,{})," \u30EA\u30BB\u30C3\u30C8"]}),e(M.Prime,{tabIndex:-1,borderRadius:"2.tone.secondary",freeCSS:{minWidth:12*8},onClick:()=>{t.onCommit&&t.onCommit(),t.set_value(u=>v(h({},u),{eventType:"commit"}))},children:"\u6C7A\u5B9A"})]})]}):null,ShiftButtons:t=>c(C.Center,{gap:"1/3",children:[e(M.Sub,{className:B("LeftButton"),tabIndex:-1,right:0,position:"relative",flexCenter:!0,ssSquare:3,onClick:()=>{t.callback(-1)},children:e(R.ChevronLeft,{})}),e(M.Sub,{className:B("RightButton"),tabIndex:-1,left:0,position:"relative",flexCenter:!0,ssSquare:3,onClick:()=>{t.callback(1)},children:e(R.ChevronRight,{})})]}),CalendarCellStyles:{ssSquare:3,borderRadius:"3.tone.tertiary"},Calendar:t=>{var F;let{targetMonth:u,from:S,to:r}=t,s=m();if(!t.targetMonth.validate)return null;let o=u.clone().setDate(1),n=o.getLastDayOfMonth(),l=m(o).addMonth(-1).getLastDayOfMonth().date,a=[],p=[],i=[],d=[];for(var f=0;f<7;f++){let T=f==6,P=f==0;a.push(e(b,{textAlign:"center",fontSize:"0.xs",fontColor:T?"googleBlue":P?"googleRed":"inherit",children:g.transformer.weekday.shortJP(f)},f))}for(var f=0;f<o.weekday;f++)p.unshift(q(x,v(h({fontColor:"4.thin"},y.Parts.CalendarCellStyles),{key:f}),l-f));for(var f=1;f<=n.date;f++){let P=u.clone().setDate(f),j=S.isSameDate(P),U=!1,z=!1;r&&r.validate&&(U=P.isInRange(S,r),z=r.isSameDate(P));let J=s.isSameDate(P),H=!1;if(t.min){let Y=m(t.min);Y&&P.value<Y.value&&(H=!0)}if(t.max){let Y=m(t.max);Y&&Y.value<P.value&&(H=!0)}i.push(c(M.Clear,v(h({isActive:j||z,isActiveStyles:{fontColor:"white",backgroundColor:"theme",boxShadow:"0.remark"}},y.Parts.CalendarCellStyles),{fontColor:U?"theme":"inherit",fontSize:"inherit",padding:0,flexCenter:!0,borderRadius:"2.tone.secondary",ssEffectsOnActive:"shrink",tabIndex:-1,isLocked:H,onClick:()=>{t.onChange(P)},children:[f,U&&e(y.Parts.RangeSign,{}),J&&e(y.Parts.CurrentSign,{})]}),P.toFormatYMD()))}for(var f=1;f<7-n.weekday;f++)d.push(e(x,v(h({fontColor:"4.thin"},y.Parts.CalendarCellStyles),{children:f}),f));return c(k,{gap:"1/2",children:[((F=t.showTitle)!=null?F:!0)&&c(b.Supplement,{isSemiBoldFont:!0,children:[u.year,"\u5E74",u.month,"\u6708"]}),c(E,{gridCols:7,gap:"1/6",children:[a,p,i,d]})]},u.toFormatYM())},DrumSelector:t=>{let{type:u,min:S,max:r,value:s}=t;const o=(l,a,p)=>{let i=t.value.clone();if(g.is.exist(l)&&(i=i.setYear(l)),g.is.exist(a)&&(i=i.setMonth(a)),g.is.exist(p)&&(i=i.setDate(p)),S){let d=m(S);i.value<d.value&&(i=d)}if(r){let d=m(r);d.value<i.value&&(i=d)}t.onChange(i)};let n=s.getLastDayOfMonth().date;return c(C.Center,{gap:"1/2",children:[e(L,{override:"force",options:y.YearOptions({}),value:s.year,onUpdateValidValue:l=>{o(Number(l))}}),e(b,{isSemiBoldFont:!0,children:"\u5E74"}),e(L,{override:"force",options:Array.from({length:12}).map((l,a)=>{let p=a+1;return{value:p,label:p}}),value:s.month,onUpdateValidValue:l=>{o(void 0,Number(l))}}),e(b,{isSemiBoldFont:!0,children:"\u6708"}),u!="month"&&c(W,{children:[e(L,{override:"force",options:Array.from({length:31}).map((l,a)=>{let p=a+1;return p>n?null:{value:p,label:p}}),value:s.date,onUpdateValidValue:l=>{o(void 0,void 0,Number(l))}}),e(b,{isSemiBoldFont:!0,children:"\u65E5"})]})]})},MonthCalendar:t=>{var n;let{targetYear:u,from:S,to:r}=t,s=m(),o=[];for(let l=1;l<=12;l++){let a=m().setYear(t.targetYear).setMonth(l).setDate(1),p=!1;if(t.min){let T=m(t.min).getLastDayOfMonth();T&&a.value<T.value&&(p=!0)}if(t.max){let T=m(t.max).getLastDayOfMonth();T&&T.value<a.value&&(p=!0)}let i=S.year==u&&S.month==a.month,d=!1,f=!1;r&&r.validate&&(d=a.isInRange(S,r),f=r.year==u&&r.month==a.month);let F=s.year==u&&s.month==a.month;o.push(e(k,{gap:"1/12",children:c(M.Clear,{isLocked:p,isActive:i||f,isActiveStyles:{fontColor:"white",backgroundColor:"theme",boxShadow:"0.remark"},fontColor:d?"theme":"inherit",padding:["1/3","2/3"],ssEffectsOnActive:"shrink",onClick:()=>{t.onChange(a)},children:[c(b,{freeCSS:{whiteSpace:"nowrap"},children:[a.month," \u6708"]}),d&&e(y.Parts.RangeSign,{}),F&&e(y.Parts.CurrentSign,{})]})},u+"-"+a.month))}return c(k,{gap:"1/2",children:[((n=t.showTitle)!=null?n:!0)&&c(b.Supplement,{isSemiBoldFont:!0,children:[t.targetYear,"\u5E74"]}),e(E,{gridCols:4,gap:"1/6",children:o})]},t.targetYear)},MinMax:t=>{let{restrict:u,min:S,max:r}=t;if(!S&&!r)return null;let s=m(S||null),o=m(r||null),n="",l="";return u=="year"?(n=s.toFormat("%Y\u5E74"),l=o.toFormat("%Y\u5E74")):u.match(/month/)?(n=s.toFormatYM(),l=o.toFormatYM()):u.match(/date/)?(n=s.toFormatYMD(),l=o.toFormatYMD()):u.match(/clock/)&&(s=m().setFromFormatHHMM(S||""),o=m().setFromFormatHHMM(r||""),n=s.toFormatHM(),l=o.toFormatHM()),c(b.Supplement,{fontHeight:1.2,children:[n&&c(b.Supplement,{children:["[\u6700\u5C0F] ",n]}),l&&c(b.Supplement,{children:["[\u6700\u5927] ",l]})]})},CurrentSign:()=>e(x,{position:"absolute",bottom:"1/6",left:"1/2",right:"1/2",unitHeight:"1/6",backgroundColor:"warn",isRounded:!0}),RangeSign:()=>e(x,{position:"absolute",top:"50%",unitHeight:2,backgroundColor:"theme.opa.low",freeCSS:{left:-1,right:-1,transform:"translateY(-50%)"}}),PeriodFocusSign:()=>e(x,{position:"absolute",bottom:"1/4",left:"1/2",right:"1/2",backgroundColor:"theme",unitHeight:"1/4",boxShadow:"0.remark",isRounded:!0})}},A=X;A.picker={open:t=>{let u=null,S=null,r="L";t.restrict=="year"&&(r="S"),t.restrict=="month"&&(r="S"),t.restrict=="clock"?r="XS":(t.restrict=="locale.jp.warekiDate"||t.restrict=="period.clock")&&(r="S");let s=t.sheetID||$();I.open("middleCenter",{sheetID:s,size:r,padding:0,paddingTop:2,closeAtAroundClick:!0,closeAtParentBlur:!1,onClose:()=>{t.onValueUpdate({value:u,era:S,eventType:"commit"})},content:c(k,{children:[c(C.Left,{children:[e(y.Parts.MinMax,{restrict:t.restrict,min:t.min,max:t.max}),e(V,{}),e(M.Sub.S,{color:"cloud",ssSphere:3,onClick:()=>{I.close(s)},children:e(R.X,{})})]}),e(I.Body,{children:e(k,{padding:1,children:e(X,{sheetID:s,restrict:t.restrict,commitFooter:!0,min:t.min,max:t.max,era:t.era,defaultValue:t.defaultValue,onValueUpdate:o=>{t.onValueUpdate(o),u=o.value,S=o.era,o.eventType=="commit"&&I.close(s)}})})})]})})},close:t=>{I.close(t)}};export{A as TimeSelector,A as default};
|
|
1
|
+
import{b as c,c as S}from"../../../chunk-C5N2D3ZX.js";import{Fragment as A,jsx as e,jsxs as d}from"react/jsx-runtime";import T,{UUID as $,Time as m}from"jmini";import{useState as P,useEffect as w}from"react";import{Box as x,Grid as O,FAI as B,Column as F,FlexMargin as D}from"../../../atoms";import{Row as b,Literal as y}from"../../../mols";import{Button as k}from"../../Button";import I from"../../Sheet";import _ from"../Select";import{LeftIcon as J,RightIcon as N}from"..";import{InputTimeClasses as V}from"../../../@styles/componentClasses";import L from"../Drum";const X=t=>{let{restrict:i}=t;return i=="year"?e(h.Year,c({},t)):i=="month"?e(h.Month.index,c({},t)):i=="week"?"[DEV]":i=="date"?e(h.Date.index,c({},t)):i=="locale.jp.warekiDate"?e(h.Locale.JP.WarekiDate.index,c({},t)):i=="clock"?e(h.Clock.index,c({},t)):i=="period.clock"?e(h.Period.Clock.index,c({},t)):i=="period.month"?e(h.Period.Month.index,c({},t)):i=="period.date"?e(h.Period.Date.index,c({},t)):null},h={YearOptions:t=>{var s,o,l;let i=[],v=(s=t==null?void 0:t.min)!=null?s:1900,r=(o=t==null?void 0:t.max)!=null?o:m().addYear(10).year;for(let n=v;n<=r;n++){let a=[n],[f,u]=T.transformer.wareki(n).value;((l=t.showJPWareki)==null||l)&&(f&&a.push(e(y.Supplement,{fontSize:"0.xs",fontColor:"4.thin",children:f},1)),u&&a.push(d(y.Supplement,{fontSize:"0.xs",fontColor:"4.thin",children:["[",u,"]"]},2))),i[t.reverse?"unshift":"push"]({value:n,label:e(b.Center,{gap:["1/12","1/4"],verticalAlign:"baseline",flexWrap:!0,children:a})})}return i},calendartypeState:()=>{let[t,i]=P(localStorage.getItem("@env/input/time/selector/calendartype")||"calendar");return w(()=>{localStorage.setItem("@env/input/time/selector/calendartype",String(t))},[t]),[t,i]},Year:t=>{let{min:i,max:v}=t,[r,s]=P(T.scope(()=>{let[o]=String(t.defaultValue).split(/\D/);return{eventType:"init",from:m().setYear(Number(o||m().year))}}));return w(()=>{t.onValueUpdate({value:String(r.from.year||null),era:"year",eventType:r.eventType})},[r]),d(F,{freeCSS:{minWidth:12*16},children:[d(b.Left,{flexWrap:!0,children:[d(y.Paragraph,{children:[r.from.year||"----","\u5E74"]}),e(k.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let o=m();s({eventType:"update",from:o})},children:"\u4ECA\u5E74"}),e(D,{})]}),e(x,{borderTop:!0}),e(L,{override:"force",value:r.from.year||null,options:h.YearOptions({min:Number(i)||void 0,max:Number(v)||void 0}),onUpdateValidValue:o=>{s(l=>({eventType:"update",from:l.from.clone().setYear(Number(o))}))}}),e(h.Parts.FooterNav,S(c({},t),{set_value:s,onClear:()=>{s(o=>({eventType:"update",from:m(null)}))}}))]})},Month:{index:t=>{let{min:i,max:v}=t,[r,s]=P(T.scope(()=>{let[o,l]=String(t.defaultValue).split(/\D/);(T.is.nullish(o)||T.is.nullish(l))&&([o,l]=m().toFormat("%Y-%M").split("-"));let n=m(),a=m().setYear(Number(o)||n.year).setMonth(Number(l)||n.month).setDate(1);return{eventType:"init",from:a,display:a}}));return w(()=>{t.onValueUpdate({value:r.from.toFormatYM(),era:"year",eventType:r.eventType})},[r]),d(F,{freeCSS:{minWidth:12*16},children:[d(b.Left,{gap:"1/2",children:[e(y.Paragraph,{children:r.from.toFormatYM("JP")||"----/--"}),e(k.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let o=m();s({eventType:"update",from:o,display:o})},children:"\u4ECA\u6708"}),e(D,{})]}),e(x,{borderTop:!0}),e(h.Parts.DrumSelector,{type:"month",min:i,max:v,value:r.from,onChange:o=>{s(S(c({},r),{eventType:"update",from:o}))}}),e(h.Parts.FooterNav,S(c({},t),{set_value:s,onClear:()=>{s(o=>S(c({},o),{eventType:"commit",from:m(null)}))}}))]})}},Date:{index:t=>{let{min:i,max:v}=t,[r,s]=h.calendartypeState(),[o,l]=P(T.scope(()=>{var g;let[n,a,f]=(g=String(t.defaultValue))==null?void 0:g.split(/\D/);(T.is.nullish(n)||T.is.nullish(a)||T.is.nullish(f))&&([n,a,f]=m().toFormat("%Y-%M-%D").split("-"));let u=m(),p=m([Number(n)||u.year,(Number(a)||u.month).zeroEmbed(2),(Number(f)||u.date).zeroEmbed(2)].join("/"));return{eventType:"init",era:"year",display:p,from:p}}));return w(()=>{t.onValueUpdate({value:o.from.toFormatYMD(),era:"year",eventType:o.eventType})},[o]),d(F,{freeCSS:{minWidth:12*16},children:[d(b.Left,{flexWrap:!0,gap:"1/2",children:[e(y.Paragraph,{children:o.from.toFormatYMD("JP")||"----/--/--"}),e(k.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let n=m();l({eventType:"update",era:"year",from:n,display:n})},children:"\u4ECA\u65E5"}),e(D,{}),d(k.Border.S,{padding:["1/6","1/2"],fontColor:"3.blur",fontSize:"0.xs",onClick:()=>{s(n=>n=="calendar"?"drum":"calendar")},children:[r=="calendar"&&"\u30C9\u30E9\u30E0",r=="drum"&&"\u30AB\u30EC\u30F3\u30C0\u30FC","\u8868\u793A"]})]}),e(x,{borderTop:!0}),r=="calendar"&&d(A,{children:[d(b.Center,{gap:"1/2",children:[e(_,{override:"force",emptySelect:!1,value:o.display.year,options:h.YearOptions({reverse:!0}),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,pickerStyles:{freeCSS:{minWidth:12*12}},onUpdateValidValue:n=>{l(a=>S(c({},a),{eventType:"update",display:a.display.clone().setYear(Number(n))}))},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})})}),e(_,{override:"force",emptySelect:!1,value:o.display.month,options:(()=>{let n=[];for(let a=1;a<=12;a++)n.push({value:a,label:String(a)+"\u6708"});return n})(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,pickerStyles:{freeCSS:{minWidth:12*8}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),onUpdateValidValue:n=>{l(a=>S(c({},a),{eventType:"update",display:a.display.clone().setMonth(Number(n))}))}}),e(h.Parts.ShiftButtons,{callback:n=>{l(a=>S(c({},a),{eventType:"update",display:a.display.clone().addMonth(n)}))}})]}),d(F,{children:[e(x,{margin:"auto",freeCSS:{minWidth:"50%"},UnderBreakPointStyles:{margin:0},children:h.Parts.Calendar({min:i,max:v,onTitleRender:n=>"",targetMonth:o.display,from:o.from,onChange:n=>{l(a=>S(c({},a),{eventType:"update",from:n}))}})}),e(x,{unitHeight:"1/4",isRounded:!0,backgroundColor:"cloud",margin:1,ssHiddenOnBreak:!0}),d(b.Center,{verticalAlign:"unset",ssHiddenOnBreak:!0,children:[e(x,{flexSizing:0,children:h.Parts.Calendar({min:i,max:v,onTitleRender:n=>e(y.Supplement,{children:d(b.Center,{gap:"1/2",children:[e(y,{isSemiBoldFont:!0,children:n.toFormatYM("JP")}),e(y,{fontColor:"4.thin",children:"[\u524D\u6708]"})]})}),targetMonth:o.display.clone().addMonth(-1),from:o.from,onChange:n=>{l(a=>S(c({},a),{eventType:"update",from:n}))}})}),e(x,{unitWidth:"1/4",isRounded:!0,backgroundColor:"cloud",margin:1}),e(x,{flexSizing:0,children:h.Parts.Calendar({min:i,max:v,onTitleRender:n=>e(y.Supplement,{children:d(b.Center,{gap:"1/2",children:[e(y,{isSemiBoldFont:!0,children:n.toFormatYM("JP")}),e(y,{fontColor:"4.thin",children:"[\u7FCC\u6708]"})]})}),targetMonth:o.display.clone().addMonth(1),from:o.from,onChange:n=>{l(a=>S(c({},a),{eventType:"update",from:n}))}})})]})]})]}),r=="drum"&&e(h.Parts.DrumSelector,{type:"date",min:i,max:v,value:o.from,onChange:n=>{l(S(c({},o),{eventType:"update",from:n}))}}),e(h.Parts.FooterNav,S(c({},t),{set_value:l,onClear:()=>{l(n=>S(c({},n),{eventType:"commit",from:m(null)}))}}))]})}},Locale:{JP:{WarekiDate:{index:t=>{var l;let{min:i,max:v}=t,[r,s]=P(T.scope(()=>{var C;let[n,a,f]=(C=String(t.defaultValue))==null?void 0:C.split(/\D/),u=t.era||"year";if(T.is.nullish(n)||T.is.nullish(a)||T.is.nullish(f)){let M=m();u=="heisei"?M.setYear(1989):u=="shouwa"?M.setYear(1926):u=="taisho"?M.setYear(1912):u=="meiji"&&M.setYear(1868),[n,a,f]=M.toFormat("%Y-%M-%D").split("-")}let p=m();return{eventType:"init",from:m([Number(n)||p.year,(Number(a)||p.month).zeroEmbed(2),(Number(f)||p.date).zeroEmbed(2)].join("/"))}}));w(()=>{t.onValueUpdate({value:r.from.toFormatYMD(),era:r.from.wareki.toLower(),eventType:r.eventType})},[r]);let o={year:{label:"\u897F\u66A6",min:"1900/01/01",max:"2100/12/31"},reiwa:{label:"\u4EE4\u548C",min:"2019/05/01",max:m().addYear(10).setMonth(12).setDate(31).toFormatYMD()},heisei:{label:"\u5E73\u6210",min:"1989/01/08",max:"2019/04/30"},showa:{label:"\u662D\u548C",min:"1926/12/25",max:"1989/01/07"},taisho:{label:"\u5927\u6B63",min:"1912/07/30",max:"1926/12/24"},meiji:{label:"\u660E\u6CBB",min:"1868/09/08",max:"1912/07/29"}};return d(F,{children:[d(b.Left,{gap:"1/4",flexWrap:!0,children:[d(y.Paragraph,{children:[r.from.warekiLabel,(l=r.from.warekiYear)==null?void 0:l.zeroEmbed(2),"\u5E74",r.from.toFormatMD("JP")]}),e(D,{})]}),e(x,{borderTop:!0}),e(b.Left,{gap:"1/2",flexWrap:!0,children:["reiwa","heisei","showa","taisho","meiji"].map((n,a)=>{let f=o[n];return f?e(k.Border.S,{onClick:()=>{let u=r.from;if(n=="reiwa"||n=="year")u=m();else{let p=m(f.min),g=m(f.max);p.value>r.from.value&&(u=p),r.from.value>g.value&&(u=g)}if(i){let p=m(i);u.value<p.value&&(u=p)}if(v){let p=m(v);p.value<u.value&&(u=p)}s(S(c({},r),{eventType:"update",from:u}))},children:f.label},a):null})}),e(h.Parts.DrumSelector,{type:"locale.jp.warekiDate",min:t.min,max:t.max,value:r.from,onChange:n=>{s(S(c({},r),{eventType:"update",from:n}))}}),e(h.Parts.FooterNav,S(c({},t),{set_value:s,onClear:()=>{s({eventType:"commit",from:m(null)})}}))]})}}}},Clock:{index:t=>{let[i,v]=P(T.scope(()=>{let a=String(t.defaultValue).split(/[^\d]/);if(!a[0]){let p=m();a=[p.hours,p.minutes]}let f=Number(a[0]),u=Number(a[1]);return{eventType:"init",from:m().setHours(f).setMinutes(u)}}));w(()=>{t.onValueUpdate({value:i.from.toFormatHM(),era:"clock",eventType:i.eventType})},[i]);let[r,s]=h.Clock.minutesUnitState(),o=m().setFromFormatHHMM(t.min||"00:00"),l=m().setFromFormatHHMM(t.max||"23:59");const n=(a,f)=>{v(u=>{let p=u.from.clone();return T.is.exist(a)&&p.setHours(a),T.is.exist(f)&&p.setMinutes(f),p.toFormatHM().toNumber()>l.toFormatHM().toNumber()&&(p=l.clone()),p.toFormatHM().toNumber()<o.toFormatHM().toNumber()&&(p=o.clone()),S(c({},u),{eventType:"update",from:p})})};return d(F,{freeCSS:{minWidth:12*16},children:[d(b.Left,{gap:"1/2",flexWrap:!0,children:[d(b.Center,{gap:"1/2",children:[e(x,{className:V("ClockBase"),children:e(h.Clock.UI,{val_value:i})}),d(x,{textAlign:"center",fontHeight:1.2,children:[d(y.Paragraph,{children:[i.from.hours.zeroEmbed(2)," : ",i.from.minutes.zeroEmbed(2)]}),d(y.Supplement,{fontColor:"4.thin",children:[i.from.hours>=12&&"PM"||"AM",i.from.hours%12,":",i.from.minutes.zeroEmbed(2)]})]})]}),e(k.Border.XS,{borderRadius:"2.tone.secondary",fontColor:"theme",onClick:()=>{let a=m().setSeconds(0);a.minutes=Math.round(a.minutes/r)*r,n(a.hours,a.minutes)},children:"\u73FE\u6642\u523B"}),e(D,{}),e(_,{emptySelect:!1,value:r,paddingLeft:3.5,leftIcon:e(J,{left:"2/3",children:"\u5358\u4F4D"}),pickerPosition:4,pickerStyles:{freeCSS:{minWidth:12*8}},padding:"1/2",options:[{value:10,label:"10\u5206"},{value:5,label:"5\u5206"},{value:1,label:"1\u5206"}],tabIndex:-1,onUpdateValidValue:a=>{s(a||1)}})]}),e(x,{borderTop:!0}),d(b.Center,{gap:"1/2",children:[e(L,{freeCSS:{maxHeight:12*12},override:"force",options:[{value:0,label:"\u5348\u524D"},{value:12,label:"\u5348\u5F8C"}],value:i.from.hours>=12?12:0,onUpdateValidValue:a=>{let f=i.from.hours%12+a;n(f)}}),e(L,{override:"force",value:i.from.hours,options:Array.from({length:24}).map((a,f)=>{let u=f;return o.hours>u||l.hours<u?null:{value:u,label:u.zeroEmbed(2)}}),onUpdateValidValue:a=>{n(a)}}),e(y,{isSemiBoldFont:!0,children:"\u6642"}),e(L,{override:"force",value:i.from.minutes,options:Array.from({length:60}).map((a,f)=>{let u=f;return u!=59&&(r==5&&u%5!=0||r==10&&u%10!=0)?null:{value:u,label:u.zeroEmbed(2)}}),onUpdateValidValue:a=>{n(void 0,a)}},r),e(y,{isSemiBoldFont:!0,children:"\u5206"})]}),e(h.Parts.FooterNav,S(c({},t),{set_value:v,onClear:()=>{v({eventType:"commit",from:m(null)})}}))]})},minutesUnitState:()=>{let[t,i]=P(Number(localStorage.getItem("@env/input/time/selector/clock/minutesUnit")||10));return w(()=>{localStorage.setItem("@env/input/time/selector/clock/minutesUnit",String(t))},[t]),[t,i]},UI:t=>{let{val_value:i}=t;return e(x,{className:V("ClockUiBase"),flexCenter:!0,children:d(x,{className:V("ClockUi"),backgroundColor:"theme.opa.low",isRounded:!0,position:"relative",children:[e(x,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[V("Needle"),V("hour")].join(" "),freeCSS:{transform:`rotate(${i.from.hours*30+i.from.minutes/2}deg)`}}),e(x,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[V("Needle"),V("minute")].join(" "),freeCSS:{transform:`rotate(${i.from.minutes*6}deg)`}})]})})}},Period:{Clock:{index:t=>{let{min:i,max:v}=t,[r,s]=h.Clock.minutesUnitState(),[o,l]=P(T.scope(()=>{let[u,p]=T.flatArray(t.defaultValue),g=m().setFromFormatHHMM(u||"09:00"),C=m().setFromFormatHHMM(p||"18:00");return{eventType:"init",forcus:0,display:g,from:g,to:C}}));w(()=>{if(!o.to.value)return;if(o.from.value>o.to.value){l(p=>S(c({},p),{eventType:"update",from:p.to,to:p.from}));return}t.onValueUpdate({value:[o.from.toFormatHM(),o.to.toFormatHM()],era:"clock",eventType:o.eventType})},[o]);let n=m().setFromFormatHHMM(t.min||"00:00"),a=m().setFromFormatHHMM(t.max||"23:59");const f=(u,p,g)=>{l(C=>{let M=C[u].clone();return T.is.exist(p)&&M.setHours(p),T.is.exist(g)&&M.setMinutes(g),M.toFormatHM().toNumber()>a.toFormatHM().toNumber()&&(M=a.clone()),M.toFormatHM().toNumber()<n.toFormatHM().toNumber()&&(M=n.clone()),S(c({},C),{eventType:"update",[u]:M})})};return d(F,{width:1,freeCSS:{minWidth:12*24},children:[d(b.Left,{flexWrap:!0,children:[d(b.Left,{gap:"1/2",children:[e(y.Paragraph,{children:o.from.toFormatHM()||"--:--"}),e(y.Supplement,{children:"-"}),e(y.Paragraph,{children:o.to.toFormatHM()||"--:--"})]}),e(D,{}),e(_,{emptySelect:!1,value:r,paddingLeft:3.5,leftIcon:e(J,{left:"2/3",children:"\u5358\u4F4D"}),pickerPosition:4,pickerStyles:{freeCSS:{minWidth:12*8}},padding:"1/2",options:[{value:10,label:"10\u5206"},{value:5,label:"5\u5206"},{value:1,label:"1\u5206"}],tabIndex:-1,onUpdateValidValue:u=>{s(u||1)}})]}),e(x,{borderBottom:"1.thin"}),e(h.Period.Preset,S(c({},t),{onPreset:(u,p)=>{l({eventType:"update",forcus:0,display:m(u),from:m(u),to:m(p)})}})),d(b.Center,{gap:"1/2",children:[e(L,{override:"force",value:o.from.hours,options:Array.from({length:24}).map((u,p)=>{let g=p;return n.hours>g||a.hours<g?null:{value:g,label:g.zeroEmbed(2)+"\u6642"}}),onUpdateValidValue:u=>{f("from",u)}}),e(L,{override:"force",value:o.from.minutes,options:Array.from({length:60}).map((u,p)=>{let g=p;return g!=59&&(r==5&&g%5!=0||r==10&&g%10!=0)?null:{value:g,label:g.zeroEmbed(2)+"\u5206"}}),onUpdateValidValue:u=>{f("from",void 0,u)}},r+"-from"),e(y,{isSemiBoldFont:!0,children:"~"}),e(L,{override:"force",value:o.to.hours,options:Array.from({length:24}).map((u,p)=>{let g=p;return n.hours>g||a.hours<g?null:{value:g,label:g.zeroEmbed(2)+"\u6642"}}),onUpdateValidValue:u=>{f("to",u)}}),e(L,{override:"force",value:o.to.minutes,options:Array.from({length:60}).map((u,p)=>{let g=p;return g!=59&&(r==5&&g%5!=0||r==10&&g%10!=0)?null:{value:g,label:g.zeroEmbed(2)+"\u5206"}}),onUpdateValidValue:u=>{f("to",void 0,u)}},r+"-to")]}),e(h.Parts.FooterNav,S(c({},t),{set_value:l,onClear:()=>{l({eventType:"commit",forcus:0,display:m(),from:m(null),to:m(null)})}}))]})}},Date:{index:t=>{let{min:i,max:v}=t,[r,s]=P(T.scope(()=>{let[o,l]=T.flatArray(t.defaultValue),n=m(o||void 0).setFirstOfDay(),a=m(l||null).setFirstOfDay();return{eventType:"init",forcus:0,display:n,from:n,to:a}}));return w(()=>{if(!r.to.value)return;if(r.from.value>r.to.value){s(l=>S(c({},l),{eventType:"update",from:l.to,to:l.from}));return}t.onValueUpdate({value:[r.from.toFormatYMD(),r.to.toFormatYMD()],era:"year",eventType:r.eventType})},[r]),d(F,{freeCSS:{minWidth:12*16},children:[d(b.Left,{gap:"1/2",flexWrap:!0,children:[e(y.Supplement,{fontColor:"4.thin",children:"from"}),d(k.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{s(o=>S(c({},o),{forcus:0}))},children:[r.from.toFormatYMD()||"----/--/--",r.forcus==0&&e(h.Parts.PeriodFocusSign,{})]}),e(y.Supplement,{fontColor:"4.thin",children:"to"}),d(k.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{s(o=>S(c({},o),{forcus:1}))},children:[r.to.toFormatYMD()||"----/--/--",r.forcus==1&&e(h.Parts.PeriodFocusSign,{})]}),e(D,{}),d(b.Right,{gap:"1/2",marginLeft:"auto",children:[e(_,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{freeCSS:{minWidth:12*12}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:h.YearOptions({reverse:!0}),value:r.display.year,onUpdateValidValue:o=>{s(l=>S(c({},l),{eventType:"update",display:l.display.clone().setYear(Number(o))}))}}),e(_,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{freeCSS:{minWidth:12*9}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:[{value:1,label:"1\u6708"},{value:2,label:"2\u6708"},{value:3,label:"3\u6708"},{value:4,label:"4\u6708"},{value:5,label:"5\u6708"},{value:6,label:"6\u6708"},{value:7,label:"7\u6708"},{value:8,label:"8\u6708"},{value:9,label:"9\u6708"},{value:10,label:"10\u6708"},{value:11,label:"11\u6708"},{value:12,label:"12\u6708"}],value:r.display.month,onUpdateValidValue:o=>{s(l=>S(c({},l),{eventType:"update",display:l.display.clone().setMonth(Number(o)).setDate(1)}))}}),e(h.Parts.ShiftButtons,{callback:o=>{s(l=>S(c({},l),{eventType:"update",display:l.display.clone().addMonth(o)}))}})]})]}),e(x,{borderBottom:"1.thin"}),e(h.Period.Preset,S(c({},t),{onPreset:(o,l)=>{s({eventType:"update",forcus:0,display:m(o),from:m(o),to:m(l)})}})),e(b.Left,{verticalAlign:"top",flexWrap:!0,gap:2,children:Array.from({length:4}).map((o,l)=>{let n=h.Parts.Calendar({min:i,max:v,targetMonth:r.display.clone().addMonth(l-1),from:r.from,to:r.to,onTitleRender:a=>{let f=a.diff(r.display).months;return e(y.Supplement,{ssHiddenOnBreak:!0,children:d(b.Center,{gap:"1/2",children:[e(y,{isSemiBoldFont:!0,children:a.toFormatYM("JP")}),e(y,{fontColor:"4.thin",children:["[\u524D\u6708]","","[\u7FCC\u6708]","[\u7FCC\u3005\u6708]"][f+1]})]})})},onChange:a=>{if(r.forcus==0){s(f=>S(c({},f),{eventType:"update",forcus:1,from:a,to:m(null)}));return}s(f=>S(c({},f),{eventType:"update",to:a}))}});return e(x,{flexSizing:"auto",ssHiddenOnBreak:l!=1,children:n},l)})}),e(h.Parts.FooterNav,S(c({},t),{set_value:s,onClear:()=>{s({eventType:"update",forcus:0,display:m(),from:m(null),to:m(null)})}}))]})}},Month:{index:t=>{let{min:i,max:v}=t,[r,s]=P(T.scope(()=>{let[o,l]=T.flatArray(t.defaultValue),n=m(o||void 0).setDate(1).setFirstOfDay(),a=m(l||null).setDate(1).setFirstOfDay();return{eventType:"init",forcus:0,display:n,from:n,to:a}}));return w(()=>{if(!r.to.value)return;if(r.from.value>r.to.value){s(l=>S(c({},l),{eventType:"update",from:l.to,to:l.from}));return}t.onValueUpdate({value:[r.from.toFormatYM(),r.to.toFormatYM()],era:"year",eventType:r.eventType})},[r]),d(F,{freeCSS:{minWidth:12*16},children:[d(b.Left,{gap:"1/2",flexWrap:!0,children:[e(y.Supplement,{fontColor:"4.thin",children:"from"}),d(k.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{s(o=>S(c({},o),{forcus:0}))},children:[r.from.toFormatYM("JP")||"----/--",r.forcus==0&&e(h.Parts.PeriodFocusSign,{})]}),e(y.Supplement,{fontColor:"4.thin",children:"to"}),d(k.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{s(o=>S(c({},o),{forcus:1}))},children:[r.to.toFormatYM("JP")||"----/--",r.forcus==1&&e(h.Parts.PeriodFocusSign,{})]}),e(D,{}),d(b.Left,{flexWrap:!0,gap:"1/2",marginLeft:"auto",children:[e(_,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{freeCSS:{minWidth:12*12}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:h.YearOptions({reverse:!0}),value:r.display.year,onUpdateValidValue:o=>{s(l=>S(c({},l),{eventType:"update",display:l.display.clone().setYear(Number(o))}))}}),e(h.Parts.ShiftButtons,{callback:o=>{s(l=>S(c({},l),{eventType:"update",display:l.display.clone().addYear(o)}))}})]})]}),e(x,{borderBottom:"1.thin"}),e(h.Period.Preset,S(c({},t),{onPreset:(o,l)=>{s({eventType:"update",forcus:0,display:m(o),from:m(o),to:m(l)})}})),e(b.Left,{verticalAlign:"top",flexWrap:!0,gap:2,UnderBreakPointStyles:{gap:1},children:Array.from({length:4}).map((o,l)=>{let n=h.Period.Month.Calendar({min:i,max:v,targetYear:r.display.year+l-1,from:r.from.getFirstDayOfMonth(),to:r.to.getLastDayOfMonth(),onTitleRender:a=>{let f=a-r.display.year;return e(y.Supplement,{children:d(b.Left,{gap:"1/2",children:[d(y,{isSemiBoldFont:!0,children:[a,"\u5E74"]}),e(y,{fontColor:"4.thin",children:["[\u524D\u5E74]","","[\u7FCC\u5E74]","[\u7FCC\u3005\u5E74]"][f+1]})]})})},onChange:a=>{if(r.forcus==0){s(f=>S(c({},f),{eventType:"update",forcus:1,from:a,to:m(null)}));return}s(f=>S(c({},f),{eventType:"update",to:a}))}});return e(x,{flexSizing:"auto",ssHiddenOnBreak:l<1||l>2,freeCSS:{minWidth:"35%"},children:n},l)})}),e(h.Parts.FooterNav,S(c({},t),{set_value:s,onClear:()=>{s({eventType:"update",forcus:0,display:m(),from:m(null),to:m(null)})}}))]})},Calendar:t=>{let{targetYear:i,from:v,to:r,onTitleRender:s=n=>d(y.Supplement,{isSemiBoldFont:!0,children:[n,"\u5E74"]})}=t,o=m(),l=[];for(let n=1;n<=12;n++){let a=m().setYear(t.targetYear).setMonth(n).setDate(1),f=!1;if(t.min){let M=m(t.min).getLastDayOfMonth();M&&a.value<M.value&&(f=!0)}if(t.max){let M=m(t.max).getLastDayOfMonth();M&&M.value<a.value&&(f=!0)}let u=v.year==i&&v.month==a.month,p=!1,g=!1;r&&r.validate&&(p=a.isInRange(v,r),g=r.year==i&&r.month==a.month);let C=o.year==i&&o.month==a.month;l.push(d(k.Clear.S,{isLocked:f,color:"cloud",border:"1.thin",isActive:u||g||p,isActiveStyles:u||g?{fontColor:"white",backgroundColor:"theme",borderColor:"theme",boxShadow:"0.remark"}:{backgroundColor:"theme.opa.few",fontColor:"theme",borderColor:"0.trans"},fontSize:"inherit",ssEffectsOnActive:"shrink",tabIndex:-1,freeCSS:{whiteSpace:"nowrap",minWidth:12*3,minHeight:12*3},flexCenter:!0,onClick:()=>{t.onChange(a)},children:[d(b.Center,{gap:"1/2",children:[e(y,{children:a.month}),e(y.Supplement,{opacity:"middle",children:["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][a.month]})]}),C&&e(h.Parts.CurrentSign,{})]},i+"-"+a.month))}return d(F,{gap:"1/2",children:[s(t.targetYear),e(O,{flexWrap:!0,gridCols:4,gap:"1/6",children:l})]},t.targetYear)}},Preset:t=>t.periodPresets?e(b.Right,{gap:"1/2",flexWrap:!0,children:t.periodPresets.map((i,v)=>e(k.Border.S,{padding:["1/4",1],onClick:()=>{t.onPreset(i.from,i.to)},children:i.label},v))}):null},Parts:{FooterNav:t=>t.commitFooter?d(A,{children:[e(x,{borderBottom:"1.thin"}),d(b.Left,{gap:"1/2",children:[d(k.Sub.S,{color:"cloud",tabIndex:-1,fontSize:"1.mini",borderRadius:"2.tone.secondary",flexSizing:"none",onClick:()=>{t.onClear()},children:[e(B.X,{})," \u30EA\u30BB\u30C3\u30C8"]}),e(h.Parts.MinMax,{restrict:t.restrict,min:t.min,max:t.max}),e(D,{}),e(k.Prime,{tabIndex:-1,borderRadius:"2.tone.secondary",freeCSS:{minWidth:12*8},onClick:()=>{t.onCommit&&t.onCommit(),t.set_value(i=>S(c({},i),{eventType:"commit"}))},children:"\u6C7A\u5B9A"})]})]}):null,ShiftButtons:t=>d(b.Center,{gap:"1/3",fontSize:"1.mini",children:[e(k.Sub,{className:V("LeftButton"),tabIndex:-1,right:0,position:"relative",ssSquare:2.5,onClick:()=>{t.callback(-1)},children:e(B.ChevronLeft,{})}),e(k.Sub,{className:V("RightButton"),tabIndex:-1,left:0,position:"relative",ssSquare:2.5,onClick:()=>{t.callback(1)},children:e(B.ChevronRight,{})})]}),Calendar:t=>{let{targetMonth:i,from:v,to:r,onTitleRender:s=M=>e(y.Supplement,{isSemiBoldFont:!0,children:M.toFormatYM("JP")})}=t,o=m();if(!t.targetMonth.validate)return null;let l=i.clone().setDate(1),n=l.getLastDayOfMonth(),a=m(l).addMonth(-1).getLastDayOfMonth().date,f=[],u=[],p=[],g=[];for(var C=0;C<7;C++){let M=C==6,R=C==0;f.push(e(y,{textAlign:"center",fontSize:"0.xs",fontColor:M?"googleBlue":R?"googleRed":"inherit",children:T.transformer.weekday.shortJP(C)},C))}for(var C=0;C<l.weekday;C++)u.unshift(e(y.Supplement,{fontColor:"4.thin",flexCenter:!0,children:a-C},C));for(var C=1;C<=n.date;C++){let R=i.clone().setDate(C),z=v.isSameDate(R),E=!1,H=!1;r&&r.validate&&(E=R.isInRange(v,r),H=r.isSameDate(R));let j=o.isSameDate(R),U=!1;if(t.min){let Y=m(t.min);Y&&R.value<Y.value&&(U=!0)}if(t.max){let Y=m(t.max);Y&&Y.value<R.value&&(U=!0)}p.push(d(k.Clear.S,{isLocked:U,color:"cloud",border:"1.thin",isActive:z||H||E,isActiveStyles:z||H?{fontColor:"white",backgroundColor:"theme",borderColor:"theme",boxShadow:"0.remark"}:{backgroundColor:"theme.opa.few",fontColor:"theme",borderColor:"0.trans"},freeCSS:{whiteSpace:"nowrap",minWidth:12*3,minHeight:12*3},flexCenter:!0,ssEffectsOnActive:"shrink",tabIndex:-1,onClick:()=>{t.onChange(R)},children:[C,j&&e(h.Parts.CurrentSign,{})]},R.toFormatYMD()))}for(var C=1;C<7-n.weekday;C++)g.push(e(y.Supplement,{flexCenter:!0,fontColor:"4.thin",children:C},C));return d(F,{gap:"1/2",children:[s(i)||"",d(O,{gridCols:7,gap:"1/6",children:[f,u,p,g]})]},i.toFormatYM())},DrumSelector:t=>{let{type:i,min:v,max:r,value:s}=t;const o=(n,a,f)=>{let u=t.value.clone();if(T.is.exist(n)&&(u=u.setYear(n)),T.is.exist(a)&&(u=u.setMonth(a)),T.is.exist(f)&&(u=u.setDate(f)),v){let p=m(v);u.value<p.value&&(u=p)}if(r){let p=m(r);p.value<u.value&&(u=p)}t.onChange(u)};let l=s.getLastDayOfMonth().date;return d(b.Center,{gap:"1/2",children:[e(L,{override:"force",options:h.YearOptions({}),value:s.year,onUpdateValidValue:n=>{o(Number(n))}}),e(y,{isSemiBoldFont:!0,children:"\u5E74"}),e(L,{override:"force",options:Array.from({length:12}).map((n,a)=>{let f=a+1;return{value:f,label:f}}),value:s.month,onUpdateValidValue:n=>{o(void 0,Number(n))}}),e(y,{isSemiBoldFont:!0,children:"\u6708"}),i!="month"&&d(A,{children:[e(L,{override:"force",options:Array.from({length:31}).map((n,a)=>{let f=a+1;return f>l?null:{value:f,label:f}}),value:s.date,onUpdateValidValue:n=>{o(void 0,void 0,Number(n))}}),e(y,{isSemiBoldFont:!0,children:"\u65E5"})]})]})},MinMax:t=>{let{restrict:i,min:v,max:r}=t;if(!v&&!r)return null;let s=m(v||null),o=m(r||null),l="",n="";return i=="year"?(l=s.toFormat("%Y\u5E74"),n=o.toFormat("%Y\u5E74")):i.match(/month/)?(l=s.toFormatYM(),n=o.toFormatYM()):i.match(/date/)?(l=s.toFormatYMD(),n=o.toFormatYMD()):i.match(/clock/)&&(s=m().setFromFormatHHMM(v||""),o=m().setFromFormatHHMM(r||""),l=s.toFormatHM(),n=o.toFormatHM()),d(y.Supplement,{fontHeight:1.2,fontSize:"0.xs",children:[l&&d(y,{children:["\u6700\u5C0F: ",l]}),n&&d(y,{children:["\u6700\u5927: ",n]})]})},CurrentSign:()=>e(x,{position:"absolute",bottom:"1/6",left:"50%",width:1,unitHeight:"1/6",backgroundColor:"warn",freeCSS:{maxWidth:12*2.5,transform:"translateX(-50%)"},isRounded:!0}),PeriodFocusSign:()=>e(x,{position:"absolute",bottom:"1/4",left:"1/2",right:"1/2",backgroundColor:"theme",unitHeight:"1/4",boxShadow:"0.remark",isRounded:!0})}},W=X;W.picker={open:t=>{let i=null,v=null,r="L";t.restrict=="year"&&(r="S"),t.restrict=="month"&&(r="S"),t.restrict=="clock"?r="XS":(t.restrict=="locale.jp.warekiDate"||t.restrict=="period.clock")&&(r="S");let s=t.sheetID||$();I.open("middleCenter",{sheetID:s,size:r,padding:0,paddingTop:2,closeAtAroundClick:!0,closeAtParentBlur:!1,onClose:()=>{t.onValueUpdate({value:i,era:v,eventType:"commit"})},content:d(F,{children:[d(b.Left,{children:[e(D,{}),e(k.Sub.S,{color:"cloud",ssSphere:3,onClick:()=>{I.close(s)},children:e(B.X,{})})]}),e(I.Body,{children:e(F,{padding:1,children:e(X,{sheetID:s,restrict:t.restrict,commitFooter:!0,min:t.min,max:t.max,era:t.era,defaultValue:t.defaultValue,onValueUpdate:o=>{t.onValueUpdate(o),i=o.value,v=o.era,o.eventType=="commit"&&I.close(s)}})})})]})})},close:t=>{I.close(t)}};export{W as TimeSelector,W as default};
|