amotify 0.2.259 → 0.2.260
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 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 F,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(F,{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(F,{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(F,{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,SelectorStyles:{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,SelectorStyles:{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 k;let[l,a,p]=(k=String(t.defaultValue))==null?void 0:k.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(F,{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(F,{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"}),SelectorPosition:4,SelectorStyles:{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:"update",from:m().setFirstOfDay()})}}))]})},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"),k=m().setFromFormatHHMM(d||"18:00");return{eventType:"init",forcus:0,display:f,from:f,to:k}}));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(k=>{let T=k[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({},k),{eventType:"update",[i]:T})})};return c(F,{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"}),SelectorPosition:4,SelectorStyles:{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:"update",forcus:0,display:m(),from:m().setFromFormatHHMM("09:00"),to:m().setFromFormatHHMM("17:59")})}}))]})}},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(F,{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",SelectorStyles:{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",SelectorStyles:{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(F,{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",SelectorStyles:{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 k;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),H=!1,z=!1;r&&r.validate&&(H=P.isInRange(S,r),z=r.isSameDate(P));let J=s.isSameDate(P),U=!1;if(t.min){let Y=m(t.min);Y&&P.value<Y.value&&(U=!0)}if(t.max){let Y=m(t.max);Y&&Y.value<P.value&&(U=!0)}i.push(c(M.Clear,v(h({isActive:j||z,isActiveStyles:{fontColor:"white",backgroundColor:"theme",boxShadow:"0.remark"}},y.Parts.CalendarCellStyles),{fontColor:H?"theme":"inherit",fontSize:"inherit",padding:0,flexCenter:!0,borderRadius:"2.tone.secondary",ssEffectsOnActive:"shrink",tabIndex:-1,isLocked:U,onClick:()=>{t.onChange(P)},children:[f,H&&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(F,{gap:"1/2",children:[((k=t.showTitle)!=null?k:!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 k=s.year==u&&s.month==a.month;o.push(e(F,{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,{}),k&&e(y.Parts.CurrentSign,{})]})},u+"-"+a.month))}return c(F,{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(F,{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(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),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 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,SelectorStyles:{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,SelectorStyles:{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"}),SelectorPosition:4,SelectorStyles:{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"}),SelectorPosition:4,SelectorStyles:{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",SelectorStyles:{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",SelectorStyles:{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",SelectorStyles:{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};
|