amotify
Version:
UI Component for React,NextJS,esbuild
2 lines (1 loc) • 27.5 kB
JavaScript
import{b as p,c as g}from"../../../chunk-C5N2D3ZX.js";import{Fragment as $,jsx as e,jsxs as f}from"react/jsx-runtime";import S,{UUID as O,Time as d,useStore as W}from"jmini";import{useState as D,useEffect as R}from"react";import{Box as T,Grid as J,FAI as B,Column as L,FlexMargin as P}from"../../../atoms";import{Row as C,Literal as h}from"../../../mols";import{Button as x}from"../../Button";import _ from"../../Sheet";import Y from"../Select";import{LeftIcon as X,RightIcon as N}from"..";import{InputTimeClasses as V}from"../../../@styles/componentClasses";import F from"../Drum";const j=t=>{let{restrict:l}=t;return l=="year"?e(y.Year,p({},t)):l=="month"?e(y.Month,p({},t)):l=="week"?"[DEV]":l=="date"?e(y.Date,p({},t)):l=="locale.jp.warekiDate"?e(y.Locale.JP.WarekiDate,p({},t)):l=="clock"?e(y.Clock,p({},t)):l=="period.clock"?e(y.Period.Clock,p({},t)):l=="period.month"?e(y.Period.Month,p({},t)):l=="period.date"?e(y.Period.Date,p({},t)):null},y={YearOptions:t=>{var u,i,n;let l=[],v=(u=t==null?void 0:t.min)!=null?u:1900,o=(i=t==null?void 0:t.max)!=null?i:d().addYear(10).year;for(let a=v;a<=o;a++){let r=[a],[m,s]=S.transformer.wareki(a).value;((n=t.showJPWareki)==null||n)&&(m&&r.push(e(h.Micro,{fontColor:"4.thin",children:m},1)),s&&r.push(f(h.Micro,{fontColor:"4.thin",children:["[",s,"]"]},2))),l[t.reverse?"unshift":"push"]({value:a,label:e(C.Center,{gap:["1/12","1/4"],verticalAlign:"baseline",flexWrap:!0,children:r})})}return l},calendartypeState:()=>{let[t,l]=D(localStorage.getItem("@env/input/time/selector/calendartype")||"calendar");return R(()=>{localStorage.setItem("@env/input/time/selector/calendartype",String(t))},[t]),[t,l]},minutesUnitState:()=>{let[t,l]=D(Number(localStorage.getItem("@env/input/time/selector/clock/minutesUnit")||10));return R(()=>{localStorage.setItem("@env/input/time/selector/clock/minutesUnit",String(t))},[t]),[t,l]},remoteControl:function(t){let{restrict:l,pickerId:v,val_value:o,set_value:u}=t;R(()=>{v&&W.set({[v]:{onClear:()=>{if(l.match(/period\./)){u(i=>g(p({},i),{eventType:"commit",forcus:0,display:d(),from:d(null),to:d(null)}));return}u(i=>g(p({},i),{eventType:"commit",from:d(null)}))},onConfirm:()=>{u(i=>g(p({},i),{eventType:"commit"}))}}})},[])},Year:t=>{let{min:l,max:v}=t,[o,u]=D(S.scope(()=>{let[i]=String(t.defaultValue).split(/\D/);return{eventType:"init",from:d().setYear(Number(i||d().year))}}));return y.remoteControl(g(p({},t),{val_value:o,set_value:u})),R(()=>{t.onValueUpdate({value:String(o.from.year||null),era:"year",eventType:o.eventType})},[o]),f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{flexWrap:!0,children:[f(h.Paragraph,{children:[o.from.year||"----","\u5E74"]}),e(x.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let i=d();u({eventType:"update",from:i})},children:"\u4ECA\u5E74"}),e(P,{})]}),e(T,{borderTop:!0}),e(F,{override:"force",value:o.from.year||null,options:y.YearOptions({min:Number(l)||void 0,max:Number(v)||void 0}),onUpdateValidValue:i=>{u(n=>({eventType:"update",from:n.from.clone().setYear(Number(i))}))}})]})},Month:t=>{let{min:l,max:v}=t,[o,u]=D(S.scope(()=>{let[i,n]=String(t.defaultValue).split(/\D/);(S.isNullish(i)||S.isNullish(n))&&([i,n]=d().toFormat("%Y-%M").split("-"));let a=d(),r=d().setYear(Number(i)||a.year).setMonth(Number(n)||a.month).setDate(1);return{eventType:"init",from:r,display:r}}));return y.remoteControl(g(p({},t),{val_value:o,set_value:u})),R(()=>{t.onValueUpdate({value:o.from.toFormatYM(),era:"year",eventType:o.eventType})},[o]),f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{gap:"1/2",children:[e(h.Paragraph,{children:o.from.toFormatYM("JP")||"----/--"}),e(x.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let i=d();u({eventType:"update",from:i,display:i})},children:"\u4ECA\u6708"}),e(P,{})]}),e(T,{borderTop:!0}),e(y.Parts.DrumSelector,{type:"month",min:l,max:v,value:o.from,onChange:i=>{u(g(p({},o),{eventType:"update",from:i}))}})]})},Date:t=>{let{min:l,max:v}=t,[o,u]=y.calendartypeState(),[i,n]=D(S.scope(()=>{var b;let[a,r,m]=(b=String(t.defaultValue))==null?void 0:b.split(/\D/);(S.isNullish(a)||S.isNullish(r)||S.isNullish(m))&&([a,r,m]=d().toFormat("%Y-%M-%D").split("-"));let s=d(),c=d([Number(a)||s.year,(Number(r)||s.month).zeroEmbed(2),(Number(m)||s.date).zeroEmbed(2)].join("/"));return{eventType:"init",era:"year",display:c,from:c}}));return y.remoteControl(g(p({},t),{val_value:i,set_value:n})),R(()=>{t.onValueUpdate({value:i.from.toFormatYMD(),era:"year",eventType:i.eventType})},[i]),f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{flexWrap:!0,gap:"1/2",children:[e(h.Paragraph,{children:i.from.toFormatYMD("JP")||"----/--/--"}),e(x.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let a=d();n({eventType:"update",era:"year",from:a,display:a})},children:"\u4ECA\u65E5"}),e(P,{}),f(x.Border.S,{padding:["1/6","1/2"],fontColor:"3.blur",fontSize:"0.xs",onClick:()=>{u(a=>a=="calendar"?"drum":"calendar")},children:[o=="calendar"&&"\u30C9\u30E9\u30E0",o=="drum"&&"\u30AB\u30EC\u30F3\u30C0\u30FC","\u8868\u793A"]})]}),e(T,{borderTop:!0}),o=="calendar"&&f($,{children:[f(C.Center,{gap:"1/2",children:[e(Y,{override:"force",emptySelect:!1,value:i.display.year,options:y.YearOptions({reverse:!0}),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,pickerStyles:{xcss:{minWidth:12*12}},onUpdateValidValue:a=>{n(r=>g(p({},r),{eventType:"update",display:r.display.clone().setYear(Number(a))}))},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})})}),e(Y,{override:"force",emptySelect:!1,value:i.display.month,options:(()=>{let a=[];for(let r=1;r<=12;r++)a.push({value:r,label:String(r)+"\u6708"});return a})(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,pickerStyles:{xcss:{minWidth:12*8}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),onUpdateValidValue:a=>{n(r=>g(p({},r),{eventType:"update",display:r.display.clone().setMonth(Number(a))}))}}),e(y.Parts.ShiftButtons,{callback:a=>{n(r=>g(p({},r),{eventType:"update",display:r.display.clone().addMonth(a)}))}})]}),f(L,{children:[e(T,{margin:"auto",xcss:{minWidth:"50%"},UnderBreakPointStyles:{margin:0},children:y.Parts.Calendar({min:l,max:v,onTitleRender:a=>"",targetMonth:i.display,from:i.from,onChange:a=>{n(r=>g(p({},r),{eventType:"update",from:a}))}})}),e(T,{unitHeight:"1/4",isRounded:!0,backgroundColor:"cloud",margin:1,ssHiddenOnBreak:!0}),f(C.Center,{verticalAlign:"unset",ssHiddenOnBreak:!0,children:[e(T,{flexSizing:0,children:y.Parts.Calendar({min:l,max:v,onTitleRender:a=>e(h.Mini,{children:f(C.Center,{gap:"1/2",children:[e(h,{isSemiBoldFont:!0,children:a.toFormatYM("JP")}),e(h,{fontColor:"4.thin",children:"[\u524D\u6708]"})]})}),targetMonth:i.display.clone().addMonth(-1),from:i.from,onChange:a=>{n(r=>g(p({},r),{eventType:"update",from:a}))}})}),e(T,{unitWidth:"1/4",isRounded:!0,backgroundColor:"cloud",margin:1}),e(T,{flexSizing:0,children:y.Parts.Calendar({min:l,max:v,onTitleRender:a=>e(h.Mini,{children:f(C.Center,{gap:"1/2",children:[e(h,{isSemiBoldFont:!0,children:a.toFormatYM("JP")}),e(h,{fontColor:"4.thin",children:"[\u7FCC\u6708]"})]})}),targetMonth:i.display.clone().addMonth(1),from:i.from,onChange:a=>{n(r=>g(p({},r),{eventType:"update",from:a}))}})})]})]})]}),o=="drum"&&e(y.Parts.DrumSelector,{type:"date",min:l,max:v,value:i.from,onChange:a=>{n(g(p({},i),{eventType:"update",from:a}))}})]})},Locale:{JP:{WarekiDate:t=>{var n;let{min:l,max:v}=t,[o,u]=D(S.scope(()=>{var M;let[a,r,m]=(M=String(t.defaultValue))==null?void 0:M.split(/\D/),s=t.era||"year";if(S.isNullish(a)||S.isNullish(r)||S.isNullish(m)){let k=d();s=="heisei"?k.setYear(1989):s=="shouwa"?k.setYear(1926):s=="taisho"?k.setYear(1912):s=="meiji"&&k.setYear(1868),[a,r,m]=k.toFormat("%Y-%M-%D").split("-")}let c=d();return{eventType:"init",from:d([Number(a)||c.year,(Number(r)||c.month).zeroEmbed(2),(Number(m)||c.date).zeroEmbed(2)].join("/"))}}));y.remoteControl(g(p({},t),{val_value:o,set_value:u})),R(()=>{t.onValueUpdate({value:o.from.toFormatYMD(),era:o.from.wareki.toLower(),eventType:o.eventType})},[o]);let i={year:{label:"\u897F\u66A6",min:"1900/01/01",max:"2100/12/31"},reiwa:{label:"\u4EE4\u548C",min:"2019/05/01",max:d().addYear(10).setMonth(12).setDate(31).toFormatYMD()},heisei:{label:"\u5E73\u6210",min:"1989/01/08",max:"2019/04/30"},showa:{label:"\u662D\u548C",min:"1926/12/25",max:"1989/01/07"},taisho:{label:"\u5927\u6B63",min:"1912/07/30",max:"1926/12/24"},meiji:{label:"\u660E\u6CBB",min:"1868/09/08",max:"1912/07/29"}};return f(L,{children:[f(C.Left,{gap:"1/4",flexWrap:!0,children:[f(h.Paragraph,{children:[o.from.warekiLabel,(n=o.from.warekiYear)==null?void 0:n.zeroEmbed(2),"\u5E74",o.from.toFormatMD("JP")]}),e(P,{})]}),e(T,{borderTop:!0}),e(C.Left,{gap:"1/2",flexWrap:!0,children:["reiwa","heisei","showa","taisho","meiji"].map((a,r)=>{let m=i[a];return m?e(x.Border.S,{onClick:()=>{let s=o.from;if(a=="reiwa"||a=="year")s=d();else{let c=d(m.min),b=d(m.max);c.value>o.from.value&&(s=c),o.from.value>b.value&&(s=b)}if(l){let c=d(l);s.value<c.value&&(s=c)}if(v){let c=d(v);c.value<s.value&&(s=c)}u(g(p({},o),{eventType:"update",from:s}))},children:m.label},r):null})}),e(y.Parts.DrumSelector,{type:"locale.jp.warekiDate",min:t.min,max:t.max,value:o.from,onChange:a=>{u(g(p({},o),{eventType:"update",from:a}))}})]})}}},Clock:t=>{let[l,v]=D(S.scope(()=>{let r=String(t.defaultValue).split(/[^\d]/);if(!r[0]){let c=d();r=[c.hours,c.minutes]}let m=Number(r[0]),s=Number(r[1]);return{eventType:"init",from:d().setHours(m).setMinutes(s)}}));y.remoteControl(g(p({},t),{val_value:l,set_value:v})),R(()=>{t.onValueUpdate({value:l.from.toFormatHM(),era:"clock",eventType:l.eventType})},[l]);let[o,u]=y.minutesUnitState(),i=d().setFromFormatHHMM(t.min||"00:00"),n=d().setFromFormatHHMM(t.max||"23:59");const a=(r,m)=>{v(s=>{let c=s.from.clone();return S.isExist(r)&&c.setHours(r),S.isExist(m)&&c.setMinutes(m),c.toFormatHM().toNumber()>n.toFormatHM().toNumber()&&(c=n.clone()),c.toFormatHM().toNumber()<i.toFormatHM().toNumber()&&(c=i.clone()),g(p({},s),{eventType:"update",from:c})})};return f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{gap:"1/2",flexWrap:!0,children:[f(C.Center,{gap:"1/2",children:[e(T,{className:V("ClockBase"),children:e(T,{className:V("ClockUiBase"),flexCenter:!0,children:f(T,{className:V("ClockUi"),backgroundColor:"theme.opa.low",isRounded:!0,position:"relative",children:[e(T,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[V("Needle"),V("hour")].join(" "),xcss:{transform:`rotate(${l.from.hours*30+l.from.minutes/2}deg)`}}),e(T,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[V("Needle"),V("minute")].join(" "),xcss:{transform:`rotate(${l.from.minutes*6}deg)`}})]})})}),f(T,{textAlign:"center",fontHeight:1.2,children:[f(h.Paragraph,{children:[l.from.hours.zeroEmbed(2)," : ",l.from.minutes.zeroEmbed(2)]}),f(h.Mini,{fontColor:"4.thin",children:[l.from.hours>=12&&"PM"||"AM",l.from.hours%12,":",l.from.minutes.zeroEmbed(2)]})]})]}),e(x.Border.XS,{borderRadius:"2.tone.secondary",fontColor:"theme",onClick:()=>{let r=d().setSeconds(0);r.minutes=Math.round(r.minutes/o)*o,a(r.hours,r.minutes)},children:"\u73FE\u6642\u523B"}),e(P,{}),e(Y,{emptySelect:!1,value:o,paddingLeft:3.5,leftIcon:e(X,{left:"2/3",children:"\u5358\u4F4D"}),pickerPosition:4,pickerStyles:{xcss:{minWidth:12*8}},padding:"1/2",options:[{value:10,label:"10\u5206"},{value:5,label:"5\u5206"},{value:1,label:"1\u5206"}],tabIndex:-1,onUpdateValidValue:r=>{u(r||1)}})]}),e(T,{borderTop:!0}),f(C.Center,{gap:"1/2",children:[e(F,{xcss:{maxHeight:12*12},override:"force",options:[{value:0,label:"\u5348\u524D"},{value:12,label:"\u5348\u5F8C"}],value:l.from.hours>=12?12:0,onUpdateValidValue:r=>{let m=l.from.hours%12+r;a(m)}}),e(F,{override:"force",value:l.from.hours,options:Array.from({length:24}).map((r,m)=>{let s=m;return i.hours>s||n.hours<s?null:{value:s,label:s.zeroEmbed(2)}}),onUpdateValidValue:r=>{a(r)}}),e(h,{isSemiBoldFont:!0,children:"\u6642"}),e(F,{override:"force",value:l.from.minutes,options:Array.from({length:60}).map((r,m)=>{let s=m;return s!=59&&(o==5&&s%5!=0||o==10&&s%10!=0)?null:{value:s,label:s.zeroEmbed(2)}}),onUpdateValidValue:r=>{a(void 0,r)}},o),e(h,{isSemiBoldFont:!0,children:"\u5206"})]})]})},Period:{Clock:t=>{let[l,v]=y.minutesUnitState(),[o,u]=D(S.scope(()=>{let[r,m]=S.Arrayify(t.defaultValue),s=d().setFromFormatHHMM(r||"09:00"),c=d().setFromFormatHHMM(m||"18:00");return{eventType:"init",forcus:0,display:s,from:s,to:c}}));y.remoteControl(g(p({},t),{val_value:o,set_value:u})),R(()=>{if(!o.to.value)return;if(o.from.value>o.to.value){u(m=>g(p({},m),{eventType:"update",from:m.to,to:m.from}));return}t.onValueUpdate({value:[o.from.toFormatHM(),o.to.toFormatHM()],era:"clock",eventType:o.eventType})},[o]);let i=d().setFromFormatHHMM(t.min||"00:00"),n=d().setFromFormatHHMM(t.max||"23:59");const a=(r,m,s)=>{u(c=>{let b=c[r].clone();return S.isExist(m)&&b.setHours(m),S.isExist(s)&&b.setMinutes(s),b.toFormatHM().toNumber()>n.toFormatHM().toNumber()&&(b=n.clone()),b.toFormatHM().toNumber()<i.toFormatHM().toNumber()&&(b=i.clone()),g(p({},c),{eventType:"update",[r]:b})})};return f(L,{width:1,xcss:{minWidth:12*24},children:[f(C.Left,{flexWrap:!0,children:[f(C.Left,{gap:"1/2",children:[e(h.Paragraph,{children:o.from.toFormatHM()||"--:--"}),e(h.Mini,{children:"-"}),e(h.Paragraph,{children:o.to.toFormatHM()||"--:--"})]}),e(P,{}),e(Y,{emptySelect:!1,value:l,paddingLeft:3.5,leftIcon:e(X,{left:"2/3",children:"\u5358\u4F4D"}),pickerPosition:4,pickerStyles:{xcss:{minWidth:12*8}},padding:"1/2",options:[{value:10,label:"10\u5206"},{value:5,label:"5\u5206"},{value:1,label:"1\u5206"}],tabIndex:-1,onUpdateValidValue:r=>{v(r||1)}})]}),e(T,{borderBottom:"1.thin"}),e(y.Period.Preset,g(p({},t),{onPreset:(r,m)=>{u({eventType:"update",forcus:0,display:d(r),from:d(r),to:d(m)})}})),f(C.Center,{gap:"1/2",children:[e(F,{override:"force",value:o.from.hours,options:Array.from({length:24}).map((r,m)=>{let s=m;return i.hours>s||n.hours<s?null:{value:s,label:s.zeroEmbed(2)+"\u6642"}}),onUpdateValidValue:r=>{a("from",r)}}),e(F,{override:"force",value:o.from.minutes,options:Array.from({length:60}).map((r,m)=>{let s=m;return s!=59&&(l==5&&s%5!=0||l==10&&s%10!=0)?null:{value:s,label:s.zeroEmbed(2)+"\u5206"}}),onUpdateValidValue:r=>{a("from",void 0,r)}},l+"-from"),e(h,{isSemiBoldFont:!0,children:"~"}),e(F,{override:"force",value:o.to.hours,options:Array.from({length:24}).map((r,m)=>{let s=m;return i.hours>s||n.hours<s?null:{value:s,label:s.zeroEmbed(2)+"\u6642"}}),onUpdateValidValue:r=>{a("to",r)}}),e(F,{override:"force",value:o.to.minutes,options:Array.from({length:60}).map((r,m)=>{let s=m;return s!=59&&(l==5&&s%5!=0||l==10&&s%10!=0)?null:{value:s,label:s.zeroEmbed(2)+"\u5206"}}),onUpdateValidValue:r=>{a("to",void 0,r)}},l+"-to")]})]})},Date:t=>{let{min:l,max:v}=t,[o,u]=D(S.scope(()=>{let[i,n]=S.Arrayify(t.defaultValue),a=d(i||void 0).setFirstOfDay(),r=d(n||null).setFirstOfDay();return{eventType:"init",forcus:0,display:a,from:a,to:r}}));return y.remoteControl(g(p({},t),{val_value:o,set_value:u})),R(()=>{if(!o.to.value)return;if(o.from.value>o.to.value){u(n=>g(p({},n),{eventType:"update",from:n.to,to:n.from}));return}t.onValueUpdate({value:[o.from.toFormatYMD(),o.to.toFormatYMD()],era:"year",eventType:o.eventType})},[o]),f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{gap:"1/2",flexWrap:!0,children:[e(h.Mini,{fontColor:"4.thin",children:"from"}),f(x.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{u(i=>g(p({},i),{forcus:0}))},children:[o.from.toFormatYMD()||"----/--/--",o.forcus==0&&e(y.Parts.PeriodFocusSign,{})]}),e(h.Mini,{fontColor:"4.thin",children:"to"}),f(x.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{u(i=>g(p({},i),{forcus:1}))},children:[o.to.toFormatYMD()||"----/--/--",o.forcus==1&&e(y.Parts.PeriodFocusSign,{})]}),e(P,{}),f(C.Right,{gap:"1/2",marginLeft:"auto",children:[e(Y,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{xcss:{minWidth:12*12}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:y.YearOptions({reverse:!0}),value:o.display.year,onUpdateValidValue:i=>{u(n=>g(p({},n),{eventType:"update",display:n.display.clone().setYear(Number(i))}))}}),e(Y,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{xcss:{minWidth:12*9}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:[{value:1,label:"1\u6708"},{value:2,label:"2\u6708"},{value:3,label:"3\u6708"},{value:4,label:"4\u6708"},{value:5,label:"5\u6708"},{value:6,label:"6\u6708"},{value:7,label:"7\u6708"},{value:8,label:"8\u6708"},{value:9,label:"9\u6708"},{value:10,label:"10\u6708"},{value:11,label:"11\u6708"},{value:12,label:"12\u6708"}],value:o.display.month,onUpdateValidValue:i=>{u(n=>g(p({},n),{eventType:"update",display:n.display.clone().setMonth(Number(i)).setDate(1)}))}}),e(y.Parts.ShiftButtons,{callback:i=>{u(n=>g(p({},n),{eventType:"update",display:n.display.clone().addMonth(i)}))}})]})]}),e(T,{borderBottom:"1.thin"}),e(y.Period.Preset,g(p({},t),{onPreset:(i,n)=>{u({eventType:"update",forcus:0,display:d(i),from:d(i),to:d(n)})}})),e(C.Left,{verticalAlign:"top",flexWrap:!0,gap:2,children:Array.from({length:4}).map((i,n)=>{let a=y.Parts.Calendar({min:l,max:v,targetMonth:o.display.clone().addMonth(n-1),from:o.from,to:o.to,onTitleRender:r=>{let m=r.diff(o.display).months;return e(h.Mini,{ssHiddenOnBreak:!0,children:f(C.Center,{gap:"1/2",children:[e(h,{isSemiBoldFont:!0,children:r.toFormatYM("JP")}),e(h,{fontColor:"4.thin",children:["[\u524D\u6708]","","[\u7FCC\u6708]","[\u7FCC\u3005\u6708]"][m+1]})]})})},onChange:r=>{if(o.forcus==0){u(m=>g(p({},m),{eventType:"update",forcus:1,from:r,to:d(null)}));return}u(m=>g(p({},m),{eventType:"update",to:r}))}});return e(T,{flexSizing:"auto",ssHiddenOnBreak:n!=1,children:a},n)})})]})},Month:t=>{let{min:l,max:v}=t,[o,u]=D(S.scope(()=>{let[i,n]=S.Arrayify(t.defaultValue),a=d(i||void 0).setDate(1).setFirstOfDay(),r=d(n||null).setDate(1).setFirstOfDay();return{eventType:"init",forcus:0,display:a,from:a,to:r}}));return y.remoteControl(g(p({},t),{val_value:o,set_value:u})),R(()=>{if(!o.to.value)return;if(o.from.value>o.to.value){u(n=>g(p({},n),{eventType:"update",from:n.to,to:n.from}));return}t.onValueUpdate({value:[o.from.toFormatYM(),o.to.toFormatYM()],era:"year",eventType:o.eventType})},[o]),f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{gap:"1/2",flexWrap:!0,children:[e(h.Mini,{fontColor:"4.thin",children:"from"}),f(x.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{u(i=>g(p({},i),{forcus:0}))},children:[o.from.toFormatYM("JP")||"----/--",o.forcus==0&&e(y.Parts.PeriodFocusSign,{})]}),e(h.Mini,{fontColor:"4.thin",children:"to"}),f(x.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{u(i=>g(p({},i),{forcus:1}))},children:[o.to.toFormatYM("JP")||"----/--",o.forcus==1&&e(y.Parts.PeriodFocusSign,{})]}),e(P,{}),f(C.Left,{flexWrap:!0,gap:"1/2",marginLeft:"auto",children:[e(Y,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{xcss:{minWidth:12*12}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:y.YearOptions({reverse:!0}),value:o.display.year,onUpdateValidValue:i=>{u(n=>g(p({},n),{eventType:"update",display:n.display.clone().setYear(Number(i))}))}}),e(y.Parts.ShiftButtons,{callback:i=>{u(n=>g(p({},n),{eventType:"update",display:n.display.clone().addYear(i)}))}})]})]}),e(T,{borderBottom:"1.thin"}),e(y.Period.Preset,g(p({},t),{onPreset:(i,n)=>{u({eventType:"update",forcus:0,display:d(i),from:d(i),to:d(n)})}})),e(C.Left,{verticalAlign:"top",flexWrap:!0,gap:2,UnderBreakPointStyles:{gap:1},children:Array.from({length:4}).map((i,n)=>{let a=y.Parts.YearCalendar({min:l,max:v,targetYear:o.display.year+n-1,from:o.from.getFirstDayOfMonth(),to:o.to.getLastDayOfMonth(),onTitleRender:r=>{let m=r-o.display.year;return e(h.Mini,{children:f(C.Left,{gap:"1/2",children:[f(h,{isSemiBoldFont:!0,children:[r,"\u5E74"]}),e(h,{fontColor:"4.thin",children:["[\u524D\u5E74]","","[\u7FCC\u5E74]","[\u7FCC\u3005\u5E74]"][m+1]})]})})},onChange:r=>{if(o.forcus==0){u(m=>g(p({},m),{eventType:"update",forcus:1,from:r,to:d(null)}));return}u(m=>g(p({},m),{eventType:"update",to:r}))}});return e(T,{flexSizing:"auto",ssHiddenOnBreak:n<1||n>2,xcss:{minWidth:"35%"},children:a},n)})})]})},Preset:t=>t.periodPresets?e(C.Right,{gap:"1/2",flexWrap:!0,children:t.periodPresets.map((l,v)=>e(x.Border.S,{padding:["1/4",1],onClick:()=>{t.onPreset(l.from,l.to)},children:l.label},v))}):null},Parts:{ShiftButtons:t=>f(C.Center,{gap:"1/3",fontSize:"1.mini",children:[e(x.Sub,{className:V("LeftButton"),tabIndex:-1,right:0,position:"relative",ssSquare:2.5,onClick:()=>{t.callback(-1)},children:e(B.ChevronLeft,{})}),e(x.Sub,{className:V("RightButton"),tabIndex:-1,left:0,position:"relative",ssSquare:2.5,onClick:()=>{t.callback(1)},children:e(B.ChevronRight,{})})]}),Calendar:t=>{let{targetMonth:l,from:v,to:o,onTitleRender:u=k=>e(h.Mini,{isSemiBoldFont:!0,children:k.toFormatYM("JP")})}=t,i=d();if(!t.targetMonth.validate)return null;let n=l.clone().setDate(1),a=n.getLastDayOfMonth(),r=d(n).addMonth(-1).getLastDayOfMonth().date,m=[],s=[],c=[],b=[];for(var M=0;M<7;M++){let k=M==6,w=M==0;m.push(e(h.Micro,{textAlign:"center",fontColor:k?"googleBlue":w?"googleRed":"inherit",children:S.transformer.weekday.shortJP(M)},M))}for(var M=0;M<n.weekday;M++)s.unshift(e(h.Mini,{fontColor:"4.thin",flexCenter:!0,children:r-M},M));for(var M=1;M<=a.date;M++){let w=l.clone().setDate(M),E=v.isSameDate(w),z=!1,H=!1;o&&o.validate&&(z=w.isInRange(v,o),H=o.isSameDate(w));let G=i.isSameDate(w),U=!1;if(t.min){let I=d(t.min);I&&w.value<I.value&&(U=!0)}if(t.max){let I=d(t.max);I&&I.value<w.value&&(U=!0)}c.push(f(x.Clear.S,{isLocked:U,color:"cloud",border:"1.thin",isActive:E||H||z,isActiveStyles:E||H?{fontColor:"white",backgroundColor:"theme",borderColor:"theme",boxShadow:"0.remark"}:{backgroundColor:"theme.opa.few",fontColor:"theme",borderColor:"0.trans"},xcss:{whiteSpace:"nowrap",minWidth:12*3,minHeight:12*3},flexCenter:!0,ssEffectsOnActive:"shrink",tabIndex:-1,onClick:()=>{t.onChange(w)},children:[M,G&&e(y.Parts.CurrentSign,{})]},w.toFormatYMD()))}for(var M=1;M<7-a.weekday;M++)b.push(e(h.Mini,{flexCenter:!0,fontColor:"4.thin",children:M},M));return f(L,{gap:"1/2",children:[u(l)||"",f(J,{gridCols:7,gap:"1/6",children:[m,s,c,b]})]},l.toFormatYM())},YearCalendar:t=>{let{targetYear:l,from:v,to:o,onTitleRender:u=a=>f(h.Mini,{isSemiBoldFont:!0,children:[a,"\u5E74"]})}=t,i=d(),n=[];for(let a=1;a<=12;a++){let r=d().setYear(t.targetYear).setMonth(a).setDate(1),m=!1;if(t.min){let k=d(t.min).getLastDayOfMonth();k&&r.value<k.value&&(m=!0)}if(t.max){let k=d(t.max).getLastDayOfMonth();k&&k.value<r.value&&(m=!0)}let s=v.year==l&&v.month==r.month,c=!1,b=!1;o&&o.validate&&(c=r.isInRange(v,o),b=o.year==l&&o.month==r.month);let M=i.year==l&&i.month==r.month;n.push(f(x.Clear.S,{isLocked:m,color:"cloud",border:"1.thin",isActive:s||b||c,isActiveStyles:s||b?{fontColor:"white",backgroundColor:"theme",borderColor:"theme",boxShadow:"0.remark"}:{backgroundColor:"theme.opa.few",fontColor:"theme",borderColor:"0.trans"},fontSize:"inherit",ssEffectsOnActive:"shrink",tabIndex:-1,xcss:{whiteSpace:"nowrap",minWidth:12*3,minHeight:12*3},flexCenter:!0,onClick:()=>{t.onChange(r)},children:[f(C.Center,{gap:"1/2",children:[e(h,{children:r.month}),e(h.Mini,{opacity:"middle",children:["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][r.month]})]}),M&&e(y.Parts.CurrentSign,{})]},l+"-"+r.month))}return f(L,{gap:"1/2",children:[u(t.targetYear),e(J,{flexWrap:!0,gridCols:4,gap:"1/6",children:n})]},t.targetYear)},DrumSelector:t=>{let{type:l,min:v,max:o,value:u}=t;const i=(r,m,s)=>{let c=t.value.clone();if(S.isExist(r)&&(c=c.setYear(r)),S.isExist(m)&&(c=c.setMonth(m)),S.isExist(s)&&(c=c.setDate(s)),v){let b=d(v);c.value<b.value&&(c=b)}if(o){let b=d(o);b.value<c.value&&(c=b)}t.onChange(c)};let n=u.getFirstDayOfMonth(),a=u.getLastDayOfMonth().date;return f(C.Center,{gap:"1/2",children:[e(F,{override:"force",options:y.YearOptions({}),value:u.year,onUpdateValidValue:r=>{i(Number(r))}}),e(h,{isSemiBoldFont:!0,children:"\u5E74"}),e(F,{override:"force",options:Array.from({length:12}).map((r,m)=>{let s=m+1;return{value:s,label:s}}),value:u.month,onUpdateValidValue:r=>{i(void 0,Number(r))}}),e(h,{isSemiBoldFont:!0,children:"\u6708"}),l!="month"&&f($,{children:[e(F,{override:"force",options:Array.from({length:31}).map((r,m)=>{let s=m+1,c=(n.weekday+m)%7;return s>a?null:{value:s,label:f(C.Right,{gap:"1/4",children:[e(h,{children:s}),f(h.Micro,{fontColor:c==0?"googleRed":c==6?"googleBlue":"4.thin",children:["(",S.transformer.weekday.shortJP(c),")"]})]})}}),value:u.date,onUpdateValidValue:r=>{i(void 0,void 0,Number(r))}},[u.year,u.month].join("-")),e(h,{isSemiBoldFont:!0,children:"\u65E5"})]})]})},MinMax:t=>{let{restrict:l,min:v,max:o}=t;if(!v&&!o)return null;let u=d(v||null),i=d(o||null),n="",a="";return l=="year"?(n=u.toFormat("%Y\u5E74"),a=i.toFormat("%Y\u5E74")):l.match(/month/)?(n=u.toFormatYM(),a=i.toFormatYM()):l.match(/date/)?(n=u.toFormatYMD(),a=i.toFormatYMD()):l.match(/clock/)&&(u=d().setFromFormatHHMM(v||""),i=d().setFromFormatHHMM(o||""),n=u.toFormatHM(),a=i.toFormatHM()),f(h.Micro,{fontHeight:1.2,children:[n&&f(h,{children:["\u6700\u5C0F: ",n]}),a&&f(h,{children:["\u6700\u5927: ",a]})]})},CurrentSign:()=>e(T,{position:"absolute",bottom:"1/6",left:"50%",width:1,unitHeight:"1/6",backgroundColor:"warn",xcss:{maxWidth:12*2.5,transform:"translateX(-50%)"},isRounded:!0}),PeriodFocusSign:()=>e(T,{position:"absolute",bottom:"1/4",left:"1/2",right:"1/2",backgroundColor:"theme",unitHeight:"1/4",boxShadow:"0.remark",isRounded:!0})}},A=j;A.picker={open:t=>{let l=null,v=null,o="init",u="L";t.restrict=="year"&&(u="S"),t.restrict=="month"&&(u="S"),t.restrict=="clock"?u="XS":(t.restrict=="locale.jp.warekiDate"||t.restrict=="period.clock")&&(u="S");let i=t.sheetID||O(),n=t.pickerId||O();_.open("middleCenter",{sheetID:i,size:u,padding:[2,0],closeAtAroundClick:!0,closeAtParentBlur:!1,onClose:()=>{o!="commit"&&t.onValueUpdate({value:l,era:v,eventType:"commit"})},content:f(L,{gap:"1/2",children:[f(C.Left,{children:[e(P,{}),e(x.Sub.S,{color:"cloud",ssSphere:3,onClick:()=>{_.close(i)},children:e(B.X,{})})]}),e(_.Body,{children:f(L,{borderRadius:"inherit",children:[e(L,{padding:1,children:e(j,{sheetID:i,pickerId:n,restrict:t.restrict,min:t.min,max:t.max,era:t.era,defaultValue:t.defaultValue,onValueUpdate:a=>{t.onValueUpdate&&t.onValueUpdate(a),l=a.value,v=a.era,o=a.eventType,a.eventType=="commit"&&_.close(i)}})}),f(C.Left,{padding:1,position:"sticky",ssZIndex:10,bottom:0,gap:"1/2",borderTop:"1.thin",backgroundColor:"layer.0.opa.low",borderBottomLeftRadius:"inherit",borderBottomRightRadius:"inherit",xcss:{backdropFilter:"blur(3px)"},children:[e(x.Clear.S,{color:"cloud",tabIndex:-1,fontColor:"4.thin",borderRadius:"2.tone.secondary",flexSizing:"none",onClick:()=>{var a,r;(r=(a=W.get(n||""))==null?void 0:a.onClear)==null||r.call(a)},children:f(C.Center,{gap:"1/2",children:[e(B.X,{}),e(h.Micro,{children:"\u30EA\u30BB\u30C3\u30C8"})]})}),e(y.Parts.MinMax,{restrict:t.restrict,min:t.min,max:t.max}),e(P,{}),e(x.Prime.S,{tabIndex:-1,xcss:{minWidth:12*6},onClick:()=>{var a,r;(r=(a=W.get(n||""))==null?void 0:a.onConfirm)==null||r.call(a)},children:"\u78BA\u5B9A"})]})]})})]})})},close:t=>{_.close(t)}};export{A as TimeSelector,A as default};