amotify 0.3.10 → 0.3.12

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 l,c as f,d as Z,e as H}from"../../chunk-C5N2D3ZX.js";import{Fragment as N,jsx as c,jsxs as V}from"react/jsx-runtime";import{useState as A,useEffect as F,useRef as ne}from"react";import a,{UUID as v}from"jmini";import{Config as oe}from"../../@utils";import{Box as X,Span as ie,FAI as B,Column as q}from"../../atoms";import{Literal as K,Row as M}from"../../mols";import{Button as $}from"../Button";import{Loader as le}from"../Loader";import{Sheet as ae}from"../Sheet";import{OptionalInputWrapper as re,BoxWrapper as se,CoreEffects as z,DefaultBoxishStyles as ue}from"./core";import{InputAutocompleteClasses as L}from"../../@styles/componentClasses";import{InputLabel as ce}from"./Label";import{RightIcon as G}from".";function pe(t){let{value:e,states:i}=t,{required:s,options:d,min:m,max:o}=i;m=m||0,o=o||65535;let n=[],p=e.filter(h=>h!==null).length;return s&&(p||n.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),p<m&&n.push({type:"invalid",label:m+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),p>o&&n.push({type:"invalid",label:o+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!n.filter(({type:h})=>h=="invalid").length,notice:n}}const R={InitOptions:t=>{let e=[];return t.forEach(i=>{if(!i)return;let{type:s,label:d,value:m,searchValue:o}=i,n=o||a.isString(d)&&d||""||a.isString(m)&&m||a.Stringify(m||"")||"";a.isNullish(d)&&(d=String(m)),e.push(f(l({id:v(8)},i),{searchValue:n,type:s||"selector",label:d,value:m}))}),e},FilterSelectableOptions:(t,e,i)=>{let s=t;return i||(s=t.filter(d=>(d==null?void 0:d.type)!="label")),a.scope(()=>{if(!e)return;let d=e.toLower().replace(/ /g,"");s=s.filter(m=>(m.searchValue||"").toLower().replace(/ /g,"").includes(d))}),s},Button:t=>{let{rootStates:e,val_keyword:i,set_keyword:s,val_optionFocused:d,set_optionFocused:m,val_status:o,set_status:n}=t,J=e,{tone:p,required:h,form:O,className:r,multiSelect:u,enableFormSubmit:y,showInitValidation:S,onValidate:g,onValidateDelay:I,onUpdateValue:x,onUpdateValidValue:C,onUserAction:P,value:E="",options:w,leftIndicator:D,rightIndicator:_,leftIcon:de,rightIcon:fe,componentId:me,status_id:Se,wrapStyles:ve,emptySelect:ye,searchInputPlaceholder:he,onSelectedRender:ge,onSelectorRender:Ie,pickerStyles:be,pickerPosition:Oe,onDynamicSearchOptions:_e,onDynamicSearchOptionsDelay:we}=J,T=Z(J,["tone","required","form","className","multiSelect","enableFormSubmit","showInitValidation","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","emptySelect","searchInputPlaceholder","onSelectedRender","onSelectorRender","pickerStyles","pickerPosition","onDynamicSearchOptions","onDynamicSearchOptionsDelay"]),W="SearchInput_"+e.componentId;return F(()=>{var b;if(e.disabled||!o.isPickerOpen||a.isExist(d))return;let k=R.FilterSelectableOptions(t.val_options,i,!1);m(((b=k[0])==null?void 0:b.id)||"")},[i]),F(()=>{if(o.eventType!="init"&&o.eventType!="override"&&e.max==o.rawValue.length){s(""),n(k=>f(l({},k),{eventID:v(8),isPickerOpen:!1}));return}},[o.rawValue]),F(()=>{let k="autocomplete-click-"+e.componentId;if(!o.isPickerOpen){a(document).removeEvent([k]);return}a('[data-input-origin="'+e.componentId+'"]')&&a(document).onEvent("mousedown",U=>{let j=a(U.target),Y=!!a(j).parent("."+L("Core")).length,ee=!!a(j).parent("."+L("Selector")).length;Y||ee||n(te=>f(l({},te),{eventID:v(8),isFocusing:!1,isPickerOpen:!1}))},{eventID:k,passive:!1})},[o.isPickerOpen]),V(N,{children:[c(X,f(l({tabIndex:-1},T),{"data-disabled":e.disabled,"data-show-validation":z.isShowValidation(o,!!S),"data-component-id":o.componentId,"data-input-origin":o.componentId,"data-focus":o.isFocusing||o.isPickerOpen,className:[r,L("Core")].join(" "),onClick:k=>{if(T!=null&&T.onClick&&(T==null||T.onClick(k)),e.disabled)return;let b=document.activeElement;(b==null?void 0:b.id)!=W&&(oe.get().isTouchDevice||a("#"+W).focus()),n(U=>f(l({},U),{eventID:v(8),isPickerOpen:!0,isFocusing:!0}))},onKeyDown:k=>{let b=document.activeElement;(b==null?void 0:b.id)!=W&&(k.preventDefault(),a("#"+W).focus())},children:V(M.Left,{gap:0,children:[c(ie,{"data-input-value-shallow":o.componentId,width:0,overflow:"hidden",opacity:"trans",children:"A"}),V(M.Left,{flexWrap:!0,flexSizing:0,gap:"1/4",verticalAlign:"unset",xcss:{letterSpacing:".5px"},children:[c(R.Selected,l({},t)),c(R.SearchInput,l({},t))]}),o.rawValue.length>1&&c($.Clear,{tabIndex:-1,color:"nega",fontColor:"4.thin",ssSphere:2,onClick:k=>{n(b=>f(l({},b),{eventType:"update",eventID:v(8),rawValue:[]}))},children:c(B.X,{})})]})})),c(R.Picker,l({},t))]})},SearchInput:t=>{let{rootStates:e,val_status:i,set_status:s}=t;if(e.disabled)return null;let d=!!i.isFocusing||!!i.isPickerOpen||!!i.rawValue.length;i.isFocusing||e.multiSelect||i.rawValue.length&&(d=!1);let m=e.searchInputPlaceholder||"\u691C\u7D22...";return c(X,{htmlTag:"input",id:"SearchInput_"+e.componentId,placeholder:m,opacity:d?"max":"trans",transition:"middle",flexSizing:0,fontSize:"inherit",border:"0.trans",backgroundColor:"trans",isRounded:!0,padding:[0,"2/3"],value:t.val_keyword,className:[L("SearchInput"),d&&L("isActive")].join(" "),xcss:{outline:"none",minWidth:12*4},onFocus:o=>{s(n=>f(l({},n),{eventID:v(8),isFocusing:!0,isPickerOpen:!0}))},onBlur:o=>H(void 0,null,function*(){s(n=>f(l({},n),{eventID:v(8),isFocusing:!1}))}),onCompositionStart:o=>{s(n=>f(l({},n),{eventID:v(8),isComposing:!0}))},onCompositionEnd:o=>{s(n=>f(l({},n),{eventID:v(8),isComposing:!1}))},onKeyDown:o=>{let{key:n,metaKey:p,ctrlKey:h}=o,O=p||h;n=="Escape"?s(r=>f(l({},r),{eventID:v(12),isPickerOpen:!1})):n=="Tab"?s(r=>f(l({},r),{eventID:v(8),isFocusing:!1,isPickerOpen:!1})):n==" "?a.scope(()=>{i.isPickerOpen||t.val_keyword||(o.preventDefault(),s(r=>f(l({},r),{eventID:v(8),isPickerOpen:!0})))}):n=="Backspace"?a.scope(()=>{if(t.val_keyword)return;let r=[...t.val_status.rawValue];r.pop(),O&&(r=[]),s(u=>f(l({},u),{rawValue:r,eventType:"update",eventID:v(8),isInspected:!1}))}):n=="Enter"&&a.scope(()=>{if(i.isComposing||(o==null?void 0:o.keyCode)===229)return;if(!i.isPickerOpen){s(y=>f(l({},y),{eventID:v(8),isPickerOpen:!0}));return}if(!t.val_optionFocused)return;let r=t.val_options.find(y=>(y==null?void 0:y.id)==t.val_optionFocused);if(!r)return;let{value:u}=r;s(y=>{let S=[...y.rawValue];return a.scope(()=>{if(u===null)return S=[];y.rawValue.includes(u)?S=S.filter(I=>I!==u):e.multiSelect?S.push(u):S=[u]}),f(l({},y),{rawValue:S,eventType:"update",eventID:v(8),isInspected:!1})}),t.set_optionsModified(!0),t.set_keyword("")}),a.scope(()=>{if(!a.isOneOf(n,"ArrowDown","ArrowUp"))return;if(o.preventDefault(),!i.isPickerOpen){s(g=>f(l({},g),{eventID:v(8),isPickerOpen:!0}));return}let r=n=="ArrowDown"?1:-1,u=R.FilterSelectableOptions(t.val_options,t.val_keyword),y=u.length-1,S=null;a.scope(()=>{var I,x,C,P,E,w,D;let g=u.findIndex(_=>(_==null?void 0:_.id)==t.val_optionFocused);if(g==-1){S=(I=u[0])==null?void 0:I.id;return}if(r==1){if(S=(x=u[0])==null?void 0:x.id,O){S=(C=u[y])==null?void 0:C.id;return}if(g==-1||g==y)return;S=(P=u[g+1])==null?void 0:P.id}else{if(S=(E=u[y])==null?void 0:E.id,O){S=(w=u[0])==null?void 0:w.id;return}if(g==-1||g==0)return;S=(D=u[g-1])==null?void 0:D.id}}),t.set_optionFocused(S)}),e.enableFormSubmit&&z.SubmitForm(o,t.rootStates.form)},onChange:o=>{let p=o.target.value;t.set_keyword(p),t.set_optionFocused(""),p&&s(h=>f(l({},h),{eventID:v(8),isPickerOpen:!0}))}},"searchInput")},Picker:t=>{var n;let{rootStates:e,val_status:i}=t,[s,d]=A("idle");F(()=>{if(!e.onDynamicSearchOptions||!i.isPickerOpen)return;if(t.val_optionsModified)return t.set_optionsModified(!1);if(i.isComposing)return;d("fetch");let p="autocomplete-search-"+e.componentId;t.set_optionFocused(""),a.interval.once(()=>H(void 0,null,function*(){var r;let h=yield e.onDynamicSearchOptions(t.val_keyword);d("idle");let O=R.InitOptions(h||[]);t.set_options(O),t.set_optionFocused(((r=O[0])==null?void 0:r.id)||"")}),e.onDynamicSearchOptionsDelay||500,p)},[t.val_keyword,i.isComposing]),F(()=>{let p=a(`[data-selector-id="${i.componentId}"]`)[0];if(!p)return;let h=a(`[data-autocomplete-input-value="${t.val_optionFocused}"]`)[0];h&&(p.scrollTop=h.offsetTop-24)},[t.val_optionFocused]);let m=R.FilterSelectableOptions(t.val_options,e.onDynamicSearchOptions?"":t.val_keyword,!0),o={};{let p=e.pickerPosition||0;a.isOneOf(p,1,2)?o.bottom="100%":a.isOneOf(p,3,4)&&(o.top="100%"),a.isOneOf(p,1,3)?o.left=0:a.isOneOf(p,2,4)&&(o.right=0)}return i.isPickerOpen?c(X,f(l({position:"absolute",ssZIndex:1e3,padding:"1/3"},o),{xcss:l({minWidth:"75%"},o.xcss),children:c(ae.Body,f(l({className:L("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,tabIndex:-1,boxShadow:"1.normal",overflow:"auto","data-selector-id":i.componentId},e.pickerStyles),{xcss:l({maxHeight:12*24},(n=e.pickerStyles)==null?void 0:n.xcss),children:V(q,{gap:"1/12",padding:[1,0],children:[s=="fetch"&&c(M.Center,{padding:"1/2",children:c(le.Theme.R,{showInitial:!0})}),s!="fetch"&&V(N,{children:[!m.length&&c(K.Mini,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"}),m.map((p,h)=>{if(!p)return null;let{type:O,value:r}=p,u=t.val_optionFocused==p.id,y=i.rawValue.includes(r),S=e.onSelectorRender;return c(q,{"data-autocomplete-input-value":p.id,children:c(S,{option:p,isFocused:u,isSelected:y,onAdd:()=>{t.set_status(g=>{let I=[...g.rawValue];return a.scope(()=>{if(r===null)return I=[];if(g.rawValue.includes(r)){I=I.filter(C=>C!==r);return}e.multiSelect?I.push(r):I=[r]}),f(l({},g),{rawValue:I,eventType:"update",eventID:v(8),isFocusing:e.max!=I.length,isInspected:!1})})},onKeyDown:g=>{let{key:I}=g;I=="Tab"&&(t.set_optionFocused(""),t.set_status(x=>f(l({},x),{eventID:v(8),isPickerOpen:!1,isFocusing:!1})))}})},p.id)})]})]})}))})):null},Selected:t=>{let{rootStates:e,val_status:i,set_status:s,val_optionsDict:d}=t,m=[];return i.rawValue.forEach(o=>{let n=d[a.Stringify(o)];if(!n)return;let p=e.onSelectedRender,h=(n==null?void 0:n.selectedLabel)||(n==null?void 0:n.label);(n==null?void 0:n.value)===null&&(h=""),m.push(c(q,{position:"relative",flexCenter:!0,xcss:{userSelect:"none"},children:c(p,{value:n==null?void 0:n.value,label:h,onRemove:O=>{if(e.disabled)return;let r=[...i.rawValue];r=r.filter(u=>u!==o),s(u=>f(l({},u),{rawValue:r,eventType:"update",eventID:v(8),isInspected:!1,isFocusing:e.max!=r.length,isPickerOpen:!0}))}})},a.Stringify(n==null?void 0:n.value)||v(8)))}),c(N,{children:m})},Core:t=>{var C,P,E;let{value:e}=t,[i,s]=A(!1),[d,m]=A(""),[o,n]=A(t.options),[p,h]=A(((C=t.options.find(w=>{var D;return(w==null?void 0:w.value)===((D=t.value)==null?void 0:D[0])}))==null?void 0:C.id)||((P=t.options[0])==null?void 0:P.id)||""),[O,r]=A({}),[u,y]=A(z.DefaultStatus(t.componentId,e)),S=ne(!1);F(()=>{i||(S.current?n(t.options):S.current=!0)},[a.Stringify((E=t.options)==null?void 0:E.map(w=>w.value))]),F(()=>{if(!o.length)return;let w=[...o],D=l({},O);w.forEach(_=>{(_==null?void 0:_.type)!="label"&&(D[a.Stringify(_==null?void 0:_.value)]=_)}),r(D)},[o]);let g={rootStates:t,val_options:o,set_options:n,val_optionFocused:p,set_optionFocused:h,val_optionsDict:O,set_optionsDict:r,val_optionsModified:i,set_optionsModified:s,val_keyword:d,set_keyword:m,val_status:u,set_status:y},I=!!t.multiSelect;z.CommonEffects({type:I?"autocomplete.multi":"autocomplete.single",states:t,val_status:u,set_status:y,SystemValidation:pe});let x=u.rawValue.length&&u.rawValue[0]!==null||u.isPickerOpen||u.isFocusing;return V(se,{val_status:u,set_status:y,states:t,children:[c(ce,{componentId:t.componentId,fontSize:t.fontSize,required:t.required,label:t.label,isActive:x,val_status:u}),c(R.Button,l({},g))]})}},Q=t=>{let e=l({},t);return e=f(l({value:[],min:0,max:65535,multiSelect:!0,emptySelect:!0,onSelectorRender:i=>{var s;return i.option?((s=i.option)==null?void 0:s.type)=="label"?c(N,{children:i.option.label}):c($.Sub.S,{color:"cloud",tabIndex:-1,backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["2/3",1.5],isActive:i.isFocused,isActiveStyles:{backgroundColor:"cloud"},onClick:i.onAdd,onKeyDown:i.onKeyDown,children:V(M.Left,{gap:"1/2",children:[i.isSelected&&c(B.Check,{fontColor:"theme"}),c(K.Mini,{transition:"short",children:i.option.label})]})}):null},onSelectedRender:i=>V(M.Left,{ssCardBox:!0,borderRadius:"1.tone.primary",fontSize:"1.mini",padding:"1/3",gap:0,children:[c(K,{padding:[0,"1/2"],children:i.label}),c($.Clear,{flexSizing:"none",color:"nega",fontColor:"4.thin",tabIndex:-1,ssSphere:2,onClick:i.onRemove,xcss:{lineHeight:1,aspectRatio:"1/1"},children:c(B.X,{})})]}),pickerPosition:3},e),{xcss:l({cursor:"pointer"},e.xcss)}),e.multiSelect||(e.min=0,e.max=1),e.options=e.options||[],e.emptySelect&&(e.options=[{value:null,label:c(K.Mini,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...e.options]),e.value=a.Arrayify(e.value),e.options=R.InitOptions(e.options),a.isNullish(e.rightIcon)&&(e.rightIcon=c(G,{children:c(B.Search,{})}),e.disabled&&(e.rightIcon=c(G,{fontColor:"5.translucent",children:c(B.Ban,{})}))),e.rightIcon&&(e=l({paddingRight:3},e)),e.leftIcon&&(e=l({paddingLeft:3},e)),c(re,{componentId:e.componentId,children:R.Core,states:ue(e)})};export{Q as Autocomplete,Q as default};
1
+ import{b as l,c as m,d as Z,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 P,useRef as ne}from"react";import a,{UUID as v}from"jmini";import{Config as oe}from"../../@utils";import{Box as X,Span as ie,FAI as B,Column as q}from"../../atoms";import{Literal as K,Row as M}from"../../mols";import{Button as $}from"../Button";import{Loader as le}from"../Loader";import{Sheet as ae}from"../Sheet";import{OptionalInputWrapper as re,BoxWrapper as se,CoreEffects as z,DefaultBoxishStyles as ue}from"./core";import{InputAutocompleteClasses as L}from"../../@styles/componentClasses";import{InputLabel as ce}from"./Label";import{RightIcon as G}from".";function pe(t){let{value:e,states:i}=t,{required:r,options:f,min:S,max:n}=i;S=S||0,n=n||65535;let o=[],c=e.filter(h=>h!==null).length;return r&&(c||o.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),c<S&&o.push({type:"invalid",label:S+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),c>n&&o.push({type:"invalid",label:n+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!o.filter(({type:h})=>h=="invalid").length,notice:o}}const R={InitOptions:t=>{let e=[];return t.forEach(i=>{if(!i)return;let{type:r,label:f,value:S,searchValue:n}=i,o=n||a.isString(f)&&f||""||a.isString(S)&&S||a.Stringify(S||"")||"";a.isNullish(f)&&(f=String(S)),e.push(m(l({id:v(8)},i),{searchValue:o,type:r||"selector",label:f,value:S}))}),e},FilterSelectableOptions:(t,e,i)=>{let r=t;return i||(r=t.filter(f=>(f==null?void 0:f.type)!="label")),a.scope(()=>{if(!e)return;let f=e.toLower().replace(/ /g,"");r=r.filter(S=>(S.searchValue||"").toLower().replace(/ /g,"").includes(f))}),r},Button:t=>{let{rootStates:e,val_keyword:i,set_keyword:r,val_optionFocused:f,set_optionFocused:S,val_status:n,set_status:o}=t,J=e,{tone:c,required:h,form:O,className:u,multiSelect:p,enableFormSubmit:I,showInitValidation:g,onValidate:d,onValidateDelay:y,onUpdateValue:x,onUpdateValidValue:C,onUserAction:F,value:E="",options:w,leftIndicator:D,rightIndicator:_,leftIcon:de,rightIcon:fe,componentId:me,status_id:Se,wrapStyles:ve,emptySelect:ye,searchInputPlaceholder:he,onSelectedRender:ge,onSelectorRender:Ie,pickerStyles:be,pickerPosition:Oe,onDynamicSearchOptions:_e,onDynamicSearchOptionsDelay:we}=J,T=Z(J,["tone","required","form","className","multiSelect","enableFormSubmit","showInitValidation","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","emptySelect","searchInputPlaceholder","onSelectedRender","onSelectorRender","pickerStyles","pickerPosition","onDynamicSearchOptions","onDynamicSearchOptionsDelay"]),W="SearchInput_"+e.componentId;return P(()=>{var b;if(e.disabled||!n.isPickerOpen||a.isExist(f))return;let k=R.FilterSelectableOptions(t.val_options,i,!1);S(((b=k[0])==null?void 0:b.id)||"")},[i]),P(()=>{if(n.eventType!="init"&&n.eventType!="override"&&e.max==n.rawValue.length){r(""),o(k=>m(l({},k),{eventID:v(8),isPickerOpen:!1}));return}},[n.rawValue]),P(()=>{let k="autocomplete-click-"+e.componentId;if(!n.isPickerOpen){a(document).removeEvent([k]);return}a('[data-input-origin="'+e.componentId+'"]')&&a(document).onEvent("mousedown",U=>{let j=a(U.target),Y=!!a(j).parent("."+L("Core")).length,ee=!!a(j).parent("."+L("Selector")).length;Y||ee||o(te=>m(l({},te),{eventID:v(8),isFocusing:!1,isPickerOpen:!1}))},{eventID:k,passive:!1})},[n.isPickerOpen]),V(N,{children:[s(X,m(l({tabIndex:-1},T),{"data-disabled":e.disabled,"data-show-validation":z.isShowValidation(n,!!g),"data-component-id":n.componentId,"data-input-origin":n.componentId,"data-focus":n.isFocusing||n.isPickerOpen,className:[u,L("Core")].join(" "),onClick:k=>{if(T!=null&&T.onClick&&(T==null||T.onClick(k)),e.disabled)return;let b=document.activeElement;(b==null?void 0:b.id)!=W&&(oe.get().isTouchDevice||a("#"+W).focus()),o(U=>m(l({},U),{eventID:v(8),isPickerOpen:!0,isFocusing:!0}))},onKeyDown:k=>{let b=document.activeElement;(b==null?void 0:b.id)!=W&&(k.preventDefault(),a("#"+W).focus())},children:V(M.Left,{gap:0,children:[s(ie,{"data-input-value-shallow":n.componentId,width:0,overflow:"hidden",opacity:"trans",children:"A"}),V(M.Left,{flexWrap:!0,flexSizing:0,gap:"1/4",verticalAlign:"unset",xcss:{letterSpacing:".5px"},children:[s(R.Selected,l({},t)),s(R.SearchInput,l({},t))]}),n.rawValue.length>1&&s($.Clear,{tabIndex:-1,color:"nega",fontColor:"4.thin",ssSphere:2,onClick:k=>{o(b=>m(l({},b),{eventType:"update",eventID:v(8),rawValue:[]}))},children:s(B.X,{})})]})})),s(R.Picker,l({},t))]})},SearchInput:t=>{let{rootStates:e,val_status:i,set_status:r}=t;if(e.disabled)return null;let f=!!i.isFocusing||!!i.isPickerOpen||!!i.rawValue.length;i.isFocusing||e.multiSelect||i.rawValue.length&&(f=!1);let S=e.searchInputPlaceholder||"\u691C\u7D22...";return s(X,{htmlTag:"input",id:"SearchInput_"+e.componentId,placeholder:S,opacity:f?"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"),f&&L("isActive")].join(" "),xcss:{outline:"none",minWidth:12*4},onFocus:n=>{r(o=>m(l({},o),{eventID:v(8),isFocusing:!0,isPickerOpen:!0}))},onBlur:n=>H(void 0,null,function*(){r(o=>m(l({},o),{eventID:v(8),isFocusing:!1}))}),onCompositionStart:n=>{r(o=>m(l({},o),{eventID:v(8),isComposing:!0}))},onCompositionEnd:n=>{r(o=>m(l({},o),{eventID:v(8),isComposing:!1}))},onKeyDown:n=>{let{key:o,metaKey:c,ctrlKey:h}=n,O=c||h;if(o=="Escape")r(u=>m(l({},u),{eventID:v(12),isPickerOpen:!1}));else if(o=="Tab")r(u=>m(l({},u),{eventID:v(8),isFocusing:!1,isPickerOpen:!1}));else if(o==" ")a.scope(()=>{i.isPickerOpen||t.val_keyword||(n.preventDefault(),r(u=>m(l({},u),{eventID:v(8),isPickerOpen:!0})))});else if(o=="Backspace")a.scope(()=>{if(t.val_keyword)return;let u=[...t.val_status.rawValue];u.pop(),O&&(u=[]),r(p=>m(l({},p),{rawValue:u,eventType:"update",eventID:v(8),isInspected:!1}))});else if(o=="Enter"&&a.scope(()=>{if(i.isComposing||(n==null?void 0:n.keyCode)===229)return;if(!i.isPickerOpen){r(d=>m(l({},d),{eventID:v(8),isPickerOpen:!0}));return}if(!t.val_optionFocused)return;let p=t.val_options.find(d=>(d==null?void 0:d.id)==t.val_optionFocused);if(!p)return;let{value:I}=p;if(!i.rawValue.includes(I))return r(d=>{let y=[...d.rawValue];return a.scope(()=>{if(I===null)return y=[];e.multiSelect?y.push(I):y=[I]}),m(l({},d),{rawValue:y,eventType:"update",eventID:v(8),isInspected:!1})}),t.set_optionsModified(!0),t.set_keyword(""),!0})){n.preventDefault();return}a.scope(()=>{if(!a.isOneOf(o,"ArrowDown","ArrowUp"))return;if(n.preventDefault(),!i.isPickerOpen){r(d=>m(l({},d),{eventID:v(8),isPickerOpen:!0}));return}let u=o=="ArrowDown"?1:-1,p=R.FilterSelectableOptions(t.val_options,t.val_keyword),I=p.length-1,g=null;a.scope(()=>{var y,x,C,F,E,w,D;let d=p.findIndex(_=>(_==null?void 0:_.id)==t.val_optionFocused);if(d==-1){g=(y=p[0])==null?void 0:y.id;return}if(u==1){if(g=(x=p[0])==null?void 0:x.id,O){g=(C=p[I])==null?void 0:C.id;return}if(d==-1||d==I)return;g=(F=p[d+1])==null?void 0:F.id}else{if(g=(E=p[I])==null?void 0:E.id,O){g=(w=p[0])==null?void 0:w.id;return}if(d==-1||d==0)return;g=(D=p[d-1])==null?void 0:D.id}}),t.set_optionFocused(g)}),e.enableFormSubmit&&z.SubmitForm(n,t.rootStates.form)},onChange:n=>{let c=n.target.value;t.set_keyword(c),t.set_optionFocused(""),c&&r(h=>m(l({},h),{eventID:v(8),isPickerOpen:!0}))}},"searchInput")},Picker:t=>{var o;let{rootStates:e,val_status:i}=t,[r,f]=A("idle");P(()=>{if(!e.onDynamicSearchOptions||!i.isPickerOpen)return;if(t.val_optionsModified)return t.set_optionsModified(!1);if(i.isComposing)return;f("fetch");let c="autocomplete-search-"+e.componentId;t.set_optionFocused(""),a.interval.once(()=>H(void 0,null,function*(){var u;let h=yield e.onDynamicSearchOptions(t.val_keyword);f("idle");let O=R.InitOptions(h||[]);t.set_options(O),t.set_optionFocused(((u=O[0])==null?void 0:u.id)||"")}),e.onDynamicSearchOptionsDelay||500,c)},[t.val_keyword,i.isComposing]),P(()=>{let c=a(`[data-selector-id="${i.componentId}"]`)[0];if(!c)return;let h=a(`[data-autocomplete-input-value="${t.val_optionFocused}"]`)[0];h&&(c.scrollTop=h.offsetTop-24)},[t.val_optionFocused]);let S=R.FilterSelectableOptions(t.val_options,e.onDynamicSearchOptions?"":t.val_keyword,!0),n={};{let c=e.pickerPosition||0;a.isOneOf(c,1,2)?n.bottom="100%":a.isOneOf(c,3,4)&&(n.top="100%"),a.isOneOf(c,1,3)?n.left=0:a.isOneOf(c,2,4)&&(n.right=0)}return i.isPickerOpen?s(X,m(l({position:"absolute",ssZIndex:1e3,padding:"1/3"},n),{xcss:l({minWidth:"75%"},n.xcss),children:s(ae.Body,m(l({className:L("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,tabIndex:-1,boxShadow:"1.normal",overflow:"auto","data-selector-id":i.componentId},e.pickerStyles),{xcss:l({maxHeight:12*24},(o=e.pickerStyles)==null?void 0:o.xcss),children:V(q,{gap:"1/12",padding:[1,0],children:[r=="fetch"&&s(M.Center,{padding:"1/2",children:s(le.Theme.R,{showInitial:!0})}),r!="fetch"&&V(N,{children:[!S.length&&s(K.Mini,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"}),S.map((c,h)=>{if(!c)return null;let{type:O,value:u}=c,p=t.val_optionFocused==c.id,I=i.rawValue.includes(u),g=e.onSelectorRender;return s(q,{"data-autocomplete-input-value":c.id,children:s(g,{option:c,isFocused:p,isSelected:I,onAdd:()=>{t.set_status(d=>{let y=[...d.rawValue];return a.scope(()=>{if(u===null)return y=[];if(d.rawValue.includes(u)){y=y.filter(C=>C!==u);return}e.multiSelect?y.push(u):y=[u]}),m(l({},d),{rawValue:y,eventType:"update",eventID:v(8),isFocusing:e.max!=y.length,isInspected:!1})})},onKeyDown:d=>{let{key:y}=d;y=="Tab"&&(t.set_optionFocused(""),t.set_status(x=>m(l({},x),{eventID:v(8),isPickerOpen:!1,isFocusing:!1})))}})},c.id)})]})]})}))})):null},Selected:t=>{let{rootStates:e,val_status:i,set_status:r,val_optionsDict:f}=t,S=[];return i.rawValue.forEach(n=>{let o=f[a.Stringify(n)];if(!o)return;let c=e.onSelectedRender,h=(o==null?void 0:o.selectedLabel)||(o==null?void 0:o.label);(o==null?void 0:o.value)===null&&(h=""),S.push(s(q,{position:"relative",flexCenter:!0,xcss:{userSelect:"none"},children:s(c,{value:o==null?void 0:o.value,label:h,onRemove:O=>{if(e.disabled)return;let u=[...i.rawValue];u=u.filter(p=>p!==n),r(p=>m(l({},p),{rawValue:u,eventType:"update",eventID:v(8),isInspected:!1,isFocusing:e.max!=u.length,isPickerOpen:!0}))}})},a.Stringify(o==null?void 0:o.value)||v(8)))}),s(N,{children:S})},Core:t=>{var C,F,E;let{value:e}=t,[i,r]=A(!1),[f,S]=A(""),[n,o]=A(t.options),[c,h]=A(((C=t.options.find(w=>{var D;return(w==null?void 0:w.value)===((D=t.value)==null?void 0:D[0])}))==null?void 0:C.id)||((F=t.options[0])==null?void 0:F.id)||""),[O,u]=A({}),[p,I]=A(z.DefaultStatus(t.componentId,e)),g=ne(!1);P(()=>{i||(g.current?o(t.options):g.current=!0)},[a.Stringify((E=t.options)==null?void 0:E.map(w=>w.value))]),P(()=>{if(!n.length)return;let w=[...n],D=l({},O);w.forEach(_=>{(_==null?void 0:_.type)!="label"&&(D[a.Stringify(_==null?void 0:_.value)]=_)}),u(D)},[n]);let d={rootStates:t,val_options:n,set_options:o,val_optionFocused:c,set_optionFocused:h,val_optionsDict:O,set_optionsDict:u,val_optionsModified:i,set_optionsModified:r,val_keyword:f,set_keyword:S,val_status:p,set_status:I},y=!!t.multiSelect;z.CommonEffects({type:y?"autocomplete.multi":"autocomplete.single",states:t,val_status:p,set_status:I,SystemValidation:pe});let x=p.rawValue.length&&p.rawValue[0]!==null||p.isPickerOpen||p.isFocusing;return V(se,{val_status:p,set_status:I,states:t,children:[s(ce,{componentId:t.componentId,fontSize:t.fontSize,required:t.required,label:t.label,isActive:x,val_status:p}),s(R.Button,l({},d))]})}},Q=t=>{let e=l({},t);return e=m(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(M.Left,{gap:"1/2",children:[i.isSelected&&s(B.Check,{fontColor:"theme"}),s(K.Mini,{transition:"short",children:i.option.label})]})}):null},onSelectedRender:i=>V(M.Left,{ssCardBox:!0,borderRadius:"1.tone.primary",fontSize:"1.mini",padding:"1/3",gap:0,children:[s(K,{padding:[0,"1/2"],children:i.label}),s($.Clear,{flexSizing:"none",color:"nega",fontColor:"4.thin",tabIndex:-1,ssSphere:2,onClick:i.onRemove,xcss:{lineHeight:1,aspectRatio:"1/1"},children:s(B.X,{})})]}),pickerPosition:3},e),{xcss:l({cursor:"pointer"},e.xcss)}),e.multiSelect||(e.min=0,e.max=1),e.options=e.options||[],e.emptySelect&&(e.options=[{value:null,label:s(K.Mini,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...e.options]),e.value=a.Arrayify(e.value),e.options=R.InitOptions(e.options),a.isNullish(e.rightIcon)&&(e.rightIcon=s(G,{children:s(B.Search,{})}),e.disabled&&(e.rightIcon=s(G,{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:R.Core,states:ue(e)})};export{Q as Autocomplete,Q as default};
@@ -1 +1 @@
1
- import{b as c,c as g}from"../../../chunk-C5N2D3ZX.js";import{Fragment as $,jsx as e,jsxs as f}from"react/jsx-runtime";import S,{UUID as O,Time as d,useStore as W}from"jmini";import{useState as D,useEffect as F}from"react";import{Box as M,Grid as J,FAI as B,Column as L,FlexMargin as P}from"../../../atoms";import{Row as C,Literal as y}from"../../../mols";import{Button as x}from"../../Button";import _ from"../../Sheet";import Y from"../Select";import{LeftIcon as X,RightIcon as N}from"..";import{InputTimeClasses as V}from"../../../@styles/componentClasses";import R from"../Drum";const j=t=>{let{restrict:l}=t;return l=="year"?e(p.Year,c({},t)):l=="month"?e(p.Month,c({},t)):l=="week"?"[DEV]":l=="date"?e(p.Date,c({},t)):l=="locale.jp.warekiDate"?e(p.Locale.JP.WarekiDate,c({},t)):l=="clock"?e(p.Clock,c({},t)):l=="period.clock"?e(p.Period.Clock,c({},t)):l=="period.month"?e(p.Period.Month,c({},t)):l=="period.date"?e(p.Period.Date,c({},t)):null},p={YearOptions:t=>{var m,i,n;let l=[],h=(m=t==null?void 0:t.min)!=null?m:1900,r=(i=t==null?void 0:t.max)!=null?i:d().addYear(10).year;for(let a=h;a<=r;a++){let o=[a],[u,s]=S.transformer.wareki(a).value;((n=t.showJPWareki)==null||n)&&(u&&o.push(e(y.Micro,{fontColor:"4.thin",children:u},1)),s&&o.push(f(y.Micro,{fontColor:"4.thin",children:["[",s,"]"]},2))),l[t.reverse?"unshift":"push"]({value:a,label:e(C.Center,{gap:["1/12","1/4"],verticalAlign:"baseline",flexWrap:!0,children:o})})}return l},calendartypeState:()=>{let[t,l]=D(localStorage.getItem("@env/input/time/selector/calendartype")||"calendar");return F(()=>{localStorage.setItem("@env/input/time/selector/calendartype",String(t))},[t]),[t,l]},minutesUnitState:()=>{let[t,l]=D(Number(localStorage.getItem("@env/input/time/selector/clock/minutesUnit")||10));return F(()=>{localStorage.setItem("@env/input/time/selector/clock/minutesUnit",String(t))},[t]),[t,l]},remoteControl:function(t){let{restrict:l,pickerId:h,val_value:r,set_value:m}=t;F(()=>{h&&W.set({[h]:{onClear:()=>{if(l.match(/period\./)){m(i=>g(c({},i),{eventType:"commit",forcus:0,display:d(),from:d(null),to:d(null)}));return}m(i=>g(c({},i),{eventType:"commit",from:d(null)}))},onConfirm:()=>{m(i=>g(c({},i),{eventType:"commit"}))}}})},[])},Year:t=>{let{min:l,max:h}=t,[r,m]=D(S.scope(()=>{let[i]=String(t.defaultValue).split(/\D/);return{eventType:"init",from:d().setYear(Number(i||d().year))}}));return p.remoteControl(g(c({},t),{val_value:r,set_value:m})),F(()=>{t.onValueUpdate({value:String(r.from.year||null),era:"year",eventType:r.eventType})},[r]),f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{flexWrap:!0,children:[f(y.Paragraph,{children:[r.from.year||"----","\u5E74"]}),e(x.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let i=d();m({eventType:"update",from:i})},children:"\u4ECA\u5E74"}),e(P,{})]}),e(M,{borderTop:!0}),e(R,{override:"force",value:r.from.year||null,options:p.YearOptions({min:Number(l)||void 0,max:Number(h)||void 0}),onUpdateValidValue:i=>{m(n=>({eventType:"update",from:n.from.clone().setYear(Number(i))}))}})]})},Month:t=>{let{min:l,max:h}=t,[r,m]=D(S.scope(()=>{let[i,n]=String(t.defaultValue).split(/\D/);(S.isNullish(i)||S.isNullish(n))&&([i,n]=d().toFormat("%Y-%M").split("-"));let a=d(),o=d().setYear(Number(i)||a.year).setMonth(Number(n)||a.month).setDate(1);return{eventType:"init",from:o,display:o}}));return p.remoteControl(g(c({},t),{val_value:r,set_value:m})),F(()=>{t.onValueUpdate({value:r.from.toFormatYM(),era:"year",eventType:r.eventType})},[r]),f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{gap:"1/2",children:[e(y.Paragraph,{children:r.from.toFormatYM("JP")||"----/--"}),e(x.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let i=d();m({eventType:"update",from:i,display:i})},children:"\u4ECA\u6708"}),e(P,{})]}),e(M,{borderTop:!0}),e(p.Parts.DrumSelector,{type:"month",min:l,max:h,value:r.from,onChange:i=>{m(g(c({},r),{eventType:"update",from:i}))}})]})},Date:t=>{let{min:l,max:h}=t,[r,m]=p.calendartypeState(),[i,n]=D(S.scope(()=>{var T;let[a,o,u]=(T=String(t.defaultValue))==null?void 0:T.split(/\D/);(S.isNullish(a)||S.isNullish(o)||S.isNullish(u))&&([a,o,u]=d().toFormat("%Y-%M-%D").split("-"));let s=d(),v=d([Number(a)||s.year,(Number(o)||s.month).zeroEmbed(2),(Number(u)||s.date).zeroEmbed(2)].join("/"));return{eventType:"init",era:"year",display:v,from:v}}));return p.remoteControl(g(c({},t),{val_value:i,set_value:n})),F(()=>{t.onValueUpdate({value:i.from.toFormatYMD(),era:"year",eventType:i.eventType})},[i]),f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{flexWrap:!0,gap:"1/2",children:[e(y.Paragraph,{children:i.from.toFormatYMD("JP")||"----/--/--"}),e(x.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let a=d();n({eventType:"update",era:"year",from:a,display:a})},children:"\u4ECA\u65E5"}),e(P,{}),f(x.Border.S,{padding:["1/6","1/2"],fontColor:"3.blur",fontSize:"0.xs",onClick:()=>{m(a=>a=="calendar"?"drum":"calendar")},children:[r=="calendar"&&"\u30C9\u30E9\u30E0",r=="drum"&&"\u30AB\u30EC\u30F3\u30C0\u30FC","\u8868\u793A"]})]}),e(M,{borderTop:!0}),r=="calendar"&&f($,{children:[f(C.Center,{gap:"1/2",children:[e(Y,{override:"force",emptySelect:!1,value:i.display.year,options:p.YearOptions({reverse:!0}),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,pickerStyles:{xcss:{minWidth:12*12}},onUpdateValidValue:a=>{n(o=>g(c({},o),{eventType:"update",display:o.display.clone().setYear(Number(a))}))},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})})}),e(Y,{override:"force",emptySelect:!1,value:i.display.month,options:(()=>{let a=[];for(let o=1;o<=12;o++)a.push({value:o,label:String(o)+"\u6708"});return a})(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,pickerStyles:{xcss:{minWidth:12*8}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),onUpdateValidValue:a=>{n(o=>g(c({},o),{eventType:"update",display:o.display.clone().setMonth(Number(a))}))}}),e(p.Parts.ShiftButtons,{callback:a=>{n(o=>g(c({},o),{eventType:"update",display:o.display.clone().addMonth(a)}))}})]}),f(L,{children:[e(M,{margin:"auto",xcss:{minWidth:"50%"},UnderBreakPointStyles:{margin:0},children:p.Parts.Calendar({min:l,max:h,onTitleRender:a=>"",targetMonth:i.display,from:i.from,onChange:a=>{n(o=>g(c({},o),{eventType:"update",from:a}))}})}),e(M,{unitHeight:"1/4",isRounded:!0,backgroundColor:"cloud",margin:1,ssHiddenOnBreak:!0}),f(C.Center,{verticalAlign:"unset",ssHiddenOnBreak:!0,children:[e(M,{flexSizing:0,children:p.Parts.Calendar({min:l,max:h,onTitleRender:a=>e(y.Mini,{children:f(C.Center,{gap:"1/2",children:[e(y,{isSemiBoldFont:!0,children:a.toFormatYM("JP")}),e(y,{fontColor:"4.thin",children:"[\u524D\u6708]"})]})}),targetMonth:i.display.clone().addMonth(-1),from:i.from,onChange:a=>{n(o=>g(c({},o),{eventType:"update",from:a}))}})}),e(M,{unitWidth:"1/4",isRounded:!0,backgroundColor:"cloud",margin:1}),e(M,{flexSizing:0,children:p.Parts.Calendar({min:l,max:h,onTitleRender:a=>e(y.Mini,{children:f(C.Center,{gap:"1/2",children:[e(y,{isSemiBoldFont:!0,children:a.toFormatYM("JP")}),e(y,{fontColor:"4.thin",children:"[\u7FCC\u6708]"})]})}),targetMonth:i.display.clone().addMonth(1),from:i.from,onChange:a=>{n(o=>g(c({},o),{eventType:"update",from:a}))}})})]})]})]}),r=="drum"&&e(p.Parts.DrumSelector,{type:"date",min:l,max:h,value:i.from,onChange:a=>{n(g(c({},i),{eventType:"update",from:a}))}})]})},Locale:{JP:{WarekiDate:t=>{var n;let{min:l,max:h}=t,[r,m]=D(S.scope(()=>{var b;let[a,o,u]=(b=String(t.defaultValue))==null?void 0:b.split(/\D/),s=t.era||"year";if(S.isNullish(a)||S.isNullish(o)||S.isNullish(u)){let k=d();s=="heisei"?k.setYear(1989):s=="shouwa"?k.setYear(1926):s=="taisho"?k.setYear(1912):s=="meiji"&&k.setYear(1868),[a,o,u]=k.toFormat("%Y-%M-%D").split("-")}let v=d();return{eventType:"init",from:d([Number(a)||v.year,(Number(o)||v.month).zeroEmbed(2),(Number(u)||v.date).zeroEmbed(2)].join("/"))}}));p.remoteControl(g(c({},t),{val_value:r,set_value:m})),F(()=>{t.onValueUpdate({value:r.from.toFormatYMD(),era:r.from.wareki.toLower(),eventType:r.eventType})},[r]);let i={year:{label:"\u897F\u66A6",min:"1900/01/01",max:"2100/12/31"},reiwa:{label:"\u4EE4\u548C",min:"2019/05/01",max:d().addYear(10).setMonth(12).setDate(31).toFormatYMD()},heisei:{label:"\u5E73\u6210",min:"1989/01/08",max:"2019/04/30"},showa:{label:"\u662D\u548C",min:"1926/12/25",max:"1989/01/07"},taisho:{label:"\u5927\u6B63",min:"1912/07/30",max:"1926/12/24"},meiji:{label:"\u660E\u6CBB",min:"1868/09/08",max:"1912/07/29"}};return f(L,{children:[f(C.Left,{gap:"1/4",flexWrap:!0,children:[f(y.Paragraph,{children:[r.from.warekiLabel,(n=r.from.warekiYear)==null?void 0:n.zeroEmbed(2),"\u5E74",r.from.toFormatMD("JP")]}),e(P,{})]}),e(M,{borderTop:!0}),e(C.Left,{gap:"1/2",flexWrap:!0,children:["reiwa","heisei","showa","taisho","meiji"].map((a,o)=>{let u=i[a];return u?e(x.Border.S,{onClick:()=>{let s=r.from;if(a=="reiwa"||a=="year")s=d();else{let v=d(u.min),T=d(u.max);v.value>r.from.value&&(s=v),r.from.value>T.value&&(s=T)}if(l){let v=d(l);s.value<v.value&&(s=v)}if(h){let v=d(h);v.value<s.value&&(s=v)}m(g(c({},r),{eventType:"update",from:s}))},children:u.label},o):null})}),e(p.Parts.DrumSelector,{type:"locale.jp.warekiDate",min:t.min,max:t.max,value:r.from,onChange:a=>{m(g(c({},r),{eventType:"update",from:a}))}})]})}}},Clock:t=>{let[l,h]=D(S.scope(()=>{let o=String(t.defaultValue).split(/[^\d]/);if(!o[0]){let v=d();o=[v.hours,v.minutes]}let u=Number(o[0]),s=Number(o[1]);return{eventType:"init",from:d().setHours(u).setMinutes(s)}}));p.remoteControl(g(c({},t),{val_value:l,set_value:h})),F(()=>{t.onValueUpdate({value:l.from.toFormatHM(),era:"clock",eventType:l.eventType})},[l]);let[r,m]=p.minutesUnitState(),i=d().setFromFormatHHMM(t.min||"00:00"),n=d().setFromFormatHHMM(t.max||"23:59");const a=(o,u)=>{h(s=>{let v=s.from.clone();return S.isExist(o)&&v.setHours(o),S.isExist(u)&&v.setMinutes(u),v.toFormatHM().toNumber()>n.toFormatHM().toNumber()&&(v=n.clone()),v.toFormatHM().toNumber()<i.toFormatHM().toNumber()&&(v=i.clone()),g(c({},s),{eventType:"update",from:v})})};return f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{gap:"1/2",flexWrap:!0,children:[f(C.Center,{gap:"1/2",children:[e(M,{className:V("ClockBase"),children:e(M,{className:V("ClockUiBase"),flexCenter:!0,children:f(M,{className:V("ClockUi"),backgroundColor:"theme.opa.low",isRounded:!0,position:"relative",children:[e(M,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[V("Needle"),V("hour")].join(" "),xcss:{transform:`rotate(${l.from.hours*30+l.from.minutes/2}deg)`}}),e(M,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[V("Needle"),V("minute")].join(" "),xcss:{transform:`rotate(${l.from.minutes*6}deg)`}})]})})}),f(M,{textAlign:"center",fontHeight:1.2,children:[f(y.Paragraph,{children:[l.from.hours.zeroEmbed(2)," : ",l.from.minutes.zeroEmbed(2)]}),f(y.Mini,{fontColor:"4.thin",children:[l.from.hours>=12&&"PM"||"AM",l.from.hours%12,":",l.from.minutes.zeroEmbed(2)]})]})]}),e(x.Border.XS,{borderRadius:"2.tone.secondary",fontColor:"theme",onClick:()=>{let o=d().setSeconds(0);o.minutes=Math.round(o.minutes/r)*r,a(o.hours,o.minutes)},children:"\u73FE\u6642\u523B"}),e(P,{}),e(Y,{emptySelect:!1,value:r,paddingLeft:3.5,leftIcon:e(X,{left:"2/3",children:"\u5358\u4F4D"}),pickerPosition:4,pickerStyles:{xcss:{minWidth:12*8}},padding:"1/2",options:[{value:10,label:"10\u5206"},{value:5,label:"5\u5206"},{value:1,label:"1\u5206"}],tabIndex:-1,onUpdateValidValue:o=>{m(o||1)}})]}),e(M,{borderTop:!0}),f(C.Center,{gap:"1/2",children:[e(R,{xcss:{maxHeight:12*12},override:"force",options:[{value:0,label:"\u5348\u524D"},{value:12,label:"\u5348\u5F8C"}],value:l.from.hours>=12?12:0,onUpdateValidValue:o=>{let u=l.from.hours%12+o;a(u)}}),e(R,{override:"force",value:l.from.hours,options:Array.from({length:24}).map((o,u)=>{let s=u;return i.hours>s||n.hours<s?null:{value:s,label:s.zeroEmbed(2)}}),onUpdateValidValue:o=>{a(o)}}),e(y,{isSemiBoldFont:!0,children:"\u6642"}),e(R,{override:"force",value:l.from.minutes,options:Array.from({length:60}).map((o,u)=>{let s=u;return s!=59&&(r==5&&s%5!=0||r==10&&s%10!=0)?null:{value:s,label:s.zeroEmbed(2)}}),onUpdateValidValue:o=>{a(void 0,o)}},r),e(y,{isSemiBoldFont:!0,children:"\u5206"})]})]})},Period:{Clock:t=>{let[l,h]=p.minutesUnitState(),[r,m]=D(S.scope(()=>{let[o,u]=S.Arrayify(t.defaultValue),s=d().setFromFormatHHMM(o||"09:00"),v=d().setFromFormatHHMM(u||"18:00");return{eventType:"init",forcus:0,display:s,from:s,to:v}}));p.remoteControl(g(c({},t),{val_value:r,set_value:m})),F(()=>{if(!r.to.value)return;if(r.from.value>r.to.value){m(u=>g(c({},u),{eventType:"update",from:u.to,to:u.from}));return}t.onValueUpdate({value:[r.from.toFormatHM(),r.to.toFormatHM()],era:"clock",eventType:r.eventType})},[r]);let i=d().setFromFormatHHMM(t.min||"00:00"),n=d().setFromFormatHHMM(t.max||"23:59");const a=(o,u,s)=>{m(v=>{let T=v[o].clone();return S.isExist(u)&&T.setHours(u),S.isExist(s)&&T.setMinutes(s),T.toFormatHM().toNumber()>n.toFormatHM().toNumber()&&(T=n.clone()),T.toFormatHM().toNumber()<i.toFormatHM().toNumber()&&(T=i.clone()),g(c({},v),{eventType:"update",[o]:T})})};return f(L,{width:1,xcss:{minWidth:12*24},children:[f(C.Left,{flexWrap:!0,children:[f(C.Left,{gap:"1/2",children:[e(y.Paragraph,{children:r.from.toFormatHM()||"--:--"}),e(y.Mini,{children:"-"}),e(y.Paragraph,{children:r.to.toFormatHM()||"--:--"})]}),e(P,{}),e(Y,{emptySelect:!1,value:l,paddingLeft:3.5,leftIcon:e(X,{left:"2/3",children:"\u5358\u4F4D"}),pickerPosition:4,pickerStyles:{xcss:{minWidth:12*8}},padding:"1/2",options:[{value:10,label:"10\u5206"},{value:5,label:"5\u5206"},{value:1,label:"1\u5206"}],tabIndex:-1,onUpdateValidValue:o=>{h(o||1)}})]}),e(M,{borderBottom:"1.thin"}),e(p.Period.Preset,g(c({},t),{onPreset:(o,u)=>{m({eventType:"update",forcus:0,display:d(o),from:d(o),to:d(u)})}})),f(C.Center,{gap:"1/2",children:[e(R,{override:"force",value:r.from.hours,options:Array.from({length:24}).map((o,u)=>{let s=u;return i.hours>s||n.hours<s?null:{value:s,label:s.zeroEmbed(2)+"\u6642"}}),onUpdateValidValue:o=>{a("from",o)}}),e(R,{override:"force",value:r.from.minutes,options:Array.from({length:60}).map((o,u)=>{let s=u;return s!=59&&(l==5&&s%5!=0||l==10&&s%10!=0)?null:{value:s,label:s.zeroEmbed(2)+"\u5206"}}),onUpdateValidValue:o=>{a("from",void 0,o)}},l+"-from"),e(y,{isSemiBoldFont:!0,children:"~"}),e(R,{override:"force",value:r.to.hours,options:Array.from({length:24}).map((o,u)=>{let s=u;return i.hours>s||n.hours<s?null:{value:s,label:s.zeroEmbed(2)+"\u6642"}}),onUpdateValidValue:o=>{a("to",o)}}),e(R,{override:"force",value:r.to.minutes,options:Array.from({length:60}).map((o,u)=>{let s=u;return s!=59&&(l==5&&s%5!=0||l==10&&s%10!=0)?null:{value:s,label:s.zeroEmbed(2)+"\u5206"}}),onUpdateValidValue:o=>{a("to",void 0,o)}},l+"-to")]})]})},Date:t=>{let{min:l,max:h}=t,[r,m]=D(S.scope(()=>{let[i,n]=S.Arrayify(t.defaultValue),a=d(i||void 0).setFirstOfDay(),o=d(n||null).setFirstOfDay();return{eventType:"init",forcus:0,display:a,from:a,to:o}}));return p.remoteControl(g(c({},t),{val_value:r,set_value:m})),F(()=>{if(!r.to.value)return;if(r.from.value>r.to.value){m(n=>g(c({},n),{eventType:"update",from:n.to,to:n.from}));return}t.onValueUpdate({value:[r.from.toFormatYMD(),r.to.toFormatYMD()],era:"year",eventType:r.eventType})},[r]),f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{gap:"1/2",flexWrap:!0,children:[e(y.Mini,{fontColor:"4.thin",children:"from"}),f(x.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{m(i=>g(c({},i),{forcus:0}))},children:[r.from.toFormatYMD()||"----/--/--",r.forcus==0&&e(p.Parts.PeriodFocusSign,{})]}),e(y.Mini,{fontColor:"4.thin",children:"to"}),f(x.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{m(i=>g(c({},i),{forcus:1}))},children:[r.to.toFormatYMD()||"----/--/--",r.forcus==1&&e(p.Parts.PeriodFocusSign,{})]}),e(P,{}),f(C.Right,{gap:"1/2",marginLeft:"auto",children:[e(Y,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{xcss:{minWidth:12*12}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:p.YearOptions({reverse:!0}),value:r.display.year,onUpdateValidValue:i=>{m(n=>g(c({},n),{eventType:"update",display:n.display.clone().setYear(Number(i))}))}}),e(Y,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{xcss:{minWidth:12*9}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:[{value:1,label:"1\u6708"},{value:2,label:"2\u6708"},{value:3,label:"3\u6708"},{value:4,label:"4\u6708"},{value:5,label:"5\u6708"},{value:6,label:"6\u6708"},{value:7,label:"7\u6708"},{value:8,label:"8\u6708"},{value:9,label:"9\u6708"},{value:10,label:"10\u6708"},{value:11,label:"11\u6708"},{value:12,label:"12\u6708"}],value:r.display.month,onUpdateValidValue:i=>{m(n=>g(c({},n),{eventType:"update",display:n.display.clone().setMonth(Number(i)).setDate(1)}))}}),e(p.Parts.ShiftButtons,{callback:i=>{m(n=>g(c({},n),{eventType:"update",display:n.display.clone().addMonth(i)}))}})]})]}),e(M,{borderBottom:"1.thin"}),e(p.Period.Preset,g(c({},t),{onPreset:(i,n)=>{m({eventType:"update",forcus:0,display:d(i),from:d(i),to:d(n)})}})),e(C.Left,{verticalAlign:"top",flexWrap:!0,gap:2,children:Array.from({length:4}).map((i,n)=>{let a=p.Parts.Calendar({min:l,max:h,targetMonth:r.display.clone().addMonth(n-1),from:r.from,to:r.to,onTitleRender:o=>{let u=o.diff(r.display).months;return e(y.Mini,{ssHiddenOnBreak:!0,children:f(C.Center,{gap:"1/2",children:[e(y,{isSemiBoldFont:!0,children:o.toFormatYM("JP")}),e(y,{fontColor:"4.thin",children:["[\u524D\u6708]","","[\u7FCC\u6708]","[\u7FCC\u3005\u6708]"][u+1]})]})})},onChange:o=>{if(r.forcus==0){m(u=>g(c({},u),{eventType:"update",forcus:1,from:o,to:d(null)}));return}m(u=>g(c({},u),{eventType:"update",to:o}))}});return e(M,{flexSizing:"auto",ssHiddenOnBreak:n!=1,children:a},n)})})]})},Month:t=>{let{min:l,max:h}=t,[r,m]=D(S.scope(()=>{let[i,n]=S.Arrayify(t.defaultValue),a=d(i||void 0).setDate(1).setFirstOfDay(),o=d(n||null).setDate(1).setFirstOfDay();return{eventType:"init",forcus:0,display:a,from:a,to:o}}));return p.remoteControl(g(c({},t),{val_value:r,set_value:m})),F(()=>{if(!r.to.value)return;if(r.from.value>r.to.value){m(n=>g(c({},n),{eventType:"update",from:n.to,to:n.from}));return}t.onValueUpdate({value:[r.from.toFormatYM(),r.to.toFormatYM()],era:"year",eventType:r.eventType})},[r]),f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{gap:"1/2",flexWrap:!0,children:[e(y.Mini,{fontColor:"4.thin",children:"from"}),f(x.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{m(i=>g(c({},i),{forcus:0}))},children:[r.from.toFormatYM("JP")||"----/--",r.forcus==0&&e(p.Parts.PeriodFocusSign,{})]}),e(y.Mini,{fontColor:"4.thin",children:"to"}),f(x.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{m(i=>g(c({},i),{forcus:1}))},children:[r.to.toFormatYM("JP")||"----/--",r.forcus==1&&e(p.Parts.PeriodFocusSign,{})]}),e(P,{}),f(C.Left,{flexWrap:!0,gap:"1/2",marginLeft:"auto",children:[e(Y,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{xcss:{minWidth:12*12}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:p.YearOptions({reverse:!0}),value:r.display.year,onUpdateValidValue:i=>{m(n=>g(c({},n),{eventType:"update",display:n.display.clone().setYear(Number(i))}))}}),e(p.Parts.ShiftButtons,{callback:i=>{m(n=>g(c({},n),{eventType:"update",display:n.display.clone().addYear(i)}))}})]})]}),e(M,{borderBottom:"1.thin"}),e(p.Period.Preset,g(c({},t),{onPreset:(i,n)=>{m({eventType:"update",forcus:0,display:d(i),from:d(i),to:d(n)})}})),e(C.Left,{verticalAlign:"top",flexWrap:!0,gap:2,UnderBreakPointStyles:{gap:1},children:Array.from({length:4}).map((i,n)=>{let a=p.Parts.YearCalendar({min:l,max:h,targetYear:r.display.year+n-1,from:r.from.getFirstDayOfMonth(),to:r.to.getLastDayOfMonth(),onTitleRender:o=>{let u=o-r.display.year;return e(y.Mini,{children:f(C.Left,{gap:"1/2",children:[f(y,{isSemiBoldFont:!0,children:[o,"\u5E74"]}),e(y,{fontColor:"4.thin",children:["[\u524D\u5E74]","","[\u7FCC\u5E74]","[\u7FCC\u3005\u5E74]"][u+1]})]})})},onChange:o=>{if(r.forcus==0){m(u=>g(c({},u),{eventType:"update",forcus:1,from:o,to:d(null)}));return}m(u=>g(c({},u),{eventType:"update",to:o}))}});return e(M,{flexSizing:"auto",ssHiddenOnBreak:n<1||n>2,xcss:{minWidth:"35%"},children:a},n)})})]})},Preset:t=>t.periodPresets?e(C.Right,{gap:"1/2",flexWrap:!0,children:t.periodPresets.map((l,h)=>e(x.Border.S,{padding:["1/4",1],onClick:()=>{t.onPreset(l.from,l.to)},children:l.label},h))}):null},Parts:{ShiftButtons:t=>f(C.Center,{gap:"1/3",fontSize:"1.mini",children:[e(x.Sub,{className:V("LeftButton"),tabIndex:-1,right:0,position:"relative",ssSquare:2.5,onClick:()=>{t.callback(-1)},children:e(B.ChevronLeft,{})}),e(x.Sub,{className:V("RightButton"),tabIndex:-1,left:0,position:"relative",ssSquare:2.5,onClick:()=>{t.callback(1)},children:e(B.ChevronRight,{})})]}),Calendar:t=>{let{targetMonth:l,from:h,to:r,onTitleRender:m=k=>e(y.Mini,{isSemiBoldFont:!0,children:k.toFormatYM("JP")})}=t,i=d();if(!t.targetMonth.validate)return null;let n=l.clone().setDate(1),a=n.getLastDayOfMonth(),o=d(n).addMonth(-1).getLastDayOfMonth().date,u=[],s=[],v=[],T=[];for(var b=0;b<7;b++){let k=b==6,w=b==0;u.push(e(y.Micro,{textAlign:"center",fontColor:k?"googleBlue":w?"googleRed":"inherit",children:S.transformer.weekday.shortJP(b)},b))}for(var b=0;b<n.weekday;b++)s.unshift(e(y.Mini,{fontColor:"4.thin",flexCenter:!0,children:o-b},b));for(var b=1;b<=a.date;b++){let w=l.clone().setDate(b),E=h.isSameDate(w),z=!1,H=!1;r&&r.validate&&(z=w.isInRange(h,r),H=r.isSameDate(w));let G=i.isSameDate(w),U=!1;if(t.min){let I=d(t.min);I&&w.value<I.value&&(U=!0)}if(t.max){let I=d(t.max);I&&I.value<w.value&&(U=!0)}v.push(f(x.Clear.S,{isLocked:U,color:"cloud",border:"1.thin",isActive:E||H||z,isActiveStyles:E||H?{fontColor:"white",backgroundColor:"theme",borderColor:"theme",boxShadow:"0.remark"}:{backgroundColor:"theme.opa.few",fontColor:"theme",borderColor:"0.trans"},xcss:{whiteSpace:"nowrap",minWidth:12*3,minHeight:12*3},flexCenter:!0,ssEffectsOnActive:"shrink",tabIndex:-1,onClick:()=>{t.onChange(w)},children:[b,G&&e(p.Parts.CurrentSign,{})]},w.toFormatYMD()))}for(var b=1;b<7-a.weekday;b++)T.push(e(y.Mini,{flexCenter:!0,fontColor:"4.thin",children:b},b));return f(L,{gap:"1/2",children:[m(l)||"",f(J,{gridCols:7,gap:"1/6",children:[u,s,v,T]})]},l.toFormatYM())},YearCalendar:t=>{let{targetYear:l,from:h,to:r,onTitleRender:m=a=>f(y.Mini,{isSemiBoldFont:!0,children:[a,"\u5E74"]})}=t,i=d(),n=[];for(let a=1;a<=12;a++){let o=d().setYear(t.targetYear).setMonth(a).setDate(1),u=!1;if(t.min){let k=d(t.min).getLastDayOfMonth();k&&o.value<k.value&&(u=!0)}if(t.max){let k=d(t.max).getLastDayOfMonth();k&&k.value<o.value&&(u=!0)}let s=h.year==l&&h.month==o.month,v=!1,T=!1;r&&r.validate&&(v=o.isInRange(h,r),T=r.year==l&&r.month==o.month);let b=i.year==l&&i.month==o.month;n.push(f(x.Clear.S,{isLocked:u,color:"cloud",border:"1.thin",isActive:s||T||v,isActiveStyles:s||T?{fontColor:"white",backgroundColor:"theme",borderColor:"theme",boxShadow:"0.remark"}:{backgroundColor:"theme.opa.few",fontColor:"theme",borderColor:"0.trans"},fontSize:"inherit",ssEffectsOnActive:"shrink",tabIndex:-1,xcss:{whiteSpace:"nowrap",minWidth:12*3,minHeight:12*3},flexCenter:!0,onClick:()=>{t.onChange(o)},children:[f(C.Center,{gap:"1/2",children:[e(y,{children:o.month}),e(y.Mini,{opacity:"middle",children:["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][o.month]})]}),b&&e(p.Parts.CurrentSign,{})]},l+"-"+o.month))}return f(L,{gap:"1/2",children:[m(t.targetYear),e(J,{flexWrap:!0,gridCols:4,gap:"1/6",children:n})]},t.targetYear)},DrumSelector:t=>{let{type:l,min:h,max:r,value:m}=t;const i=(a,o,u)=>{let s=t.value.clone();if(S.isExist(a)&&(s=s.setYear(a)),S.isExist(o)&&(s=s.setMonth(o)),S.isExist(u)&&(s=s.setDate(u)),h){let v=d(h);s.value<v.value&&(s=v)}if(r){let v=d(r);v.value<s.value&&(s=v)}t.onChange(s)};let n=m.getLastDayOfMonth().date;return f(C.Center,{gap:"1/2",children:[e(R,{override:"force",options:p.YearOptions({}),value:m.year,onUpdateValidValue:a=>{i(Number(a))}}),e(y,{isSemiBoldFont:!0,children:"\u5E74"}),e(R,{override:"force",options:Array.from({length:12}).map((a,o)=>{let u=o+1;return{value:u,label:u}}),value:m.month,onUpdateValidValue:a=>{i(void 0,Number(a))}}),e(y,{isSemiBoldFont:!0,children:"\u6708"}),l!="month"&&f($,{children:[e(R,{override:"force",options:Array.from({length:31}).map((a,o)=>{let u=o+1;return u>n?null:{value:u,label:u}}),value:m.date,onUpdateValidValue:a=>{i(void 0,void 0,Number(a))}}),e(y,{isSemiBoldFont:!0,children:"\u65E5"})]})]})},MinMax:t=>{let{restrict:l,min:h,max:r}=t;if(!h&&!r)return null;let m=d(h||null),i=d(r||null),n="",a="";return l=="year"?(n=m.toFormat("%Y\u5E74"),a=i.toFormat("%Y\u5E74")):l.match(/month/)?(n=m.toFormatYM(),a=i.toFormatYM()):l.match(/date/)?(n=m.toFormatYMD(),a=i.toFormatYMD()):l.match(/clock/)&&(m=d().setFromFormatHHMM(h||""),i=d().setFromFormatHHMM(r||""),n=m.toFormatHM(),a=i.toFormatHM()),f(y.Micro,{fontHeight:1.2,children:[n&&f(y,{children:["\u6700\u5C0F: ",n]}),a&&f(y,{children:["\u6700\u5927: ",a]})]})},CurrentSign:()=>e(M,{position:"absolute",bottom:"1/6",left:"50%",width:1,unitHeight:"1/6",backgroundColor:"warn",xcss:{maxWidth:12*2.5,transform:"translateX(-50%)"},isRounded:!0}),PeriodFocusSign:()=>e(M,{position:"absolute",bottom:"1/4",left:"1/2",right:"1/2",backgroundColor:"theme",unitHeight:"1/4",boxShadow:"0.remark",isRounded:!0})}},A=j;A.picker={open:t=>{let l=null,h=null,r="L";t.restrict=="year"&&(r="S"),t.restrict=="month"&&(r="S"),t.restrict=="clock"?r="XS":(t.restrict=="locale.jp.warekiDate"||t.restrict=="period.clock")&&(r="S");let m=t.sheetID||O(),i=t.pickerId||O();_.open("middleCenter",{sheetID:m,size:r,padding:[2,0],closeAtAroundClick:!0,closeAtParentBlur:!1,onClose:()=>{t.onValueUpdate({value:l,era:h,eventType:"commit"})},content:f(L,{gap:"1/2",children:[f(C.Left,{children:[e(P,{}),e(x.Sub.S,{color:"cloud",ssSphere:3,onClick:()=>{_.close(m)},children:e(B.X,{})})]}),e(_.Body,{children:f(L,{borderRadius:"inherit",children:[e(L,{padding:1,children:e(j,{sheetID:m,pickerId:i,restrict:t.restrict,min:t.min,max:t.max,era:t.era,defaultValue:t.defaultValue,onValueUpdate:n=>{t.onValueUpdate(n),l=n.value,h=n.era,n.eventType=="commit"&&_.close(m)}})}),f(C.Left,{padding:1,position:"sticky",ssZIndex:10,bottom:0,gap:"1/2",borderTop:"1.thin",backgroundColor:"layer.0.opa.low",borderBottomLeftRadius:"inherit",borderBottomRightRadius:"inherit",xcss:{backdropFilter:"blur(3px)"},children:[e(x.Clear.S,{color:"cloud",tabIndex:-1,fontColor:"4.thin",borderRadius:"2.tone.secondary",flexSizing:"none",onClick:()=>{var n,a;(a=(n=W.get(i||""))==null?void 0:n.onClear)==null||a.call(n)},children:f(C.Center,{gap:"1/2",children:[e(B.X,{}),e(y.Micro,{children:"\u30EA\u30BB\u30C3\u30C8"})]})}),e(p.Parts.MinMax,{restrict:t.restrict,min:t.min,max:t.max}),e(P,{}),e(x.Prime.S,{tabIndex:-1,xcss:{minWidth:12*6},onClick:()=>{var n,a;(a=(n=W.get(i||""))==null?void 0:n.onConfirm)==null||a.call(n)},children:"\u78BA\u5B9A"})]})]})})]})})},close:t=>{_.close(t)}};export{A as TimeSelector,A as default};
1
+ import{b as c,c as g}from"../../../chunk-C5N2D3ZX.js";import{Fragment as $,jsx as e,jsxs as f}from"react/jsx-runtime";import S,{UUID as O,Time as d,useStore as W}from"jmini";import{useState as D,useEffect as F}from"react";import{Box as M,Grid as J,FAI as B,Column as L,FlexMargin as P}from"../../../atoms";import{Row as C,Literal as y}from"../../../mols";import{Button as x}from"../../Button";import _ from"../../Sheet";import Y from"../Select";import{LeftIcon as X,RightIcon as N}from"..";import{InputTimeClasses as V}from"../../../@styles/componentClasses";import R from"../Drum";const j=t=>{let{restrict:l}=t;return l=="year"?e(p.Year,c({},t)):l=="month"?e(p.Month,c({},t)):l=="week"?"[DEV]":l=="date"?e(p.Date,c({},t)):l=="locale.jp.warekiDate"?e(p.Locale.JP.WarekiDate,c({},t)):l=="clock"?e(p.Clock,c({},t)):l=="period.clock"?e(p.Period.Clock,c({},t)):l=="period.month"?e(p.Period.Month,c({},t)):l=="period.date"?e(p.Period.Date,c({},t)):null},p={YearOptions:t=>{var m,i,n;let l=[],h=(m=t==null?void 0:t.min)!=null?m:1900,o=(i=t==null?void 0:t.max)!=null?i:d().addYear(10).year;for(let a=h;a<=o;a++){let r=[a],[u,s]=S.transformer.wareki(a).value;((n=t.showJPWareki)==null||n)&&(u&&r.push(e(y.Micro,{fontColor:"4.thin",children:u},1)),s&&r.push(f(y.Micro,{fontColor:"4.thin",children:["[",s,"]"]},2))),l[t.reverse?"unshift":"push"]({value:a,label:e(C.Center,{gap:["1/12","1/4"],verticalAlign:"baseline",flexWrap:!0,children:r})})}return l},calendartypeState:()=>{let[t,l]=D(localStorage.getItem("@env/input/time/selector/calendartype")||"calendar");return F(()=>{localStorage.setItem("@env/input/time/selector/calendartype",String(t))},[t]),[t,l]},minutesUnitState:()=>{let[t,l]=D(Number(localStorage.getItem("@env/input/time/selector/clock/minutesUnit")||10));return F(()=>{localStorage.setItem("@env/input/time/selector/clock/minutesUnit",String(t))},[t]),[t,l]},remoteControl:function(t){let{restrict:l,pickerId:h,val_value:o,set_value:m}=t;F(()=>{h&&W.set({[h]:{onClear:()=>{if(l.match(/period\./)){m(i=>g(c({},i),{eventType:"commit",forcus:0,display:d(),from:d(null),to:d(null)}));return}m(i=>g(c({},i),{eventType:"commit",from:d(null)}))},onConfirm:()=>{m(i=>g(c({},i),{eventType:"commit"}))}}})},[])},Year:t=>{let{min:l,max:h}=t,[o,m]=D(S.scope(()=>{let[i]=String(t.defaultValue).split(/\D/);return{eventType:"init",from:d().setYear(Number(i||d().year))}}));return p.remoteControl(g(c({},t),{val_value:o,set_value:m})),F(()=>{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(y.Paragraph,{children:[o.from.year||"----","\u5E74"]}),e(x.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let i=d();m({eventType:"update",from:i})},children:"\u4ECA\u5E74"}),e(P,{})]}),e(M,{borderTop:!0}),e(R,{override:"force",value:o.from.year||null,options:p.YearOptions({min:Number(l)||void 0,max:Number(h)||void 0}),onUpdateValidValue:i=>{m(n=>({eventType:"update",from:n.from.clone().setYear(Number(i))}))}})]})},Month:t=>{let{min:l,max:h}=t,[o,m]=D(S.scope(()=>{let[i,n]=String(t.defaultValue).split(/\D/);(S.isNullish(i)||S.isNullish(n))&&([i,n]=d().toFormat("%Y-%M").split("-"));let a=d(),r=d().setYear(Number(i)||a.year).setMonth(Number(n)||a.month).setDate(1);return{eventType:"init",from:r,display:r}}));return p.remoteControl(g(c({},t),{val_value:o,set_value:m})),F(()=>{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(y.Paragraph,{children:o.from.toFormatYM("JP")||"----/--"}),e(x.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let i=d();m({eventType:"update",from:i,display:i})},children:"\u4ECA\u6708"}),e(P,{})]}),e(M,{borderTop:!0}),e(p.Parts.DrumSelector,{type:"month",min:l,max:h,value:o.from,onChange:i=>{m(g(c({},o),{eventType:"update",from:i}))}})]})},Date:t=>{let{min:l,max:h}=t,[o,m]=p.calendartypeState(),[i,n]=D(S.scope(()=>{var T;let[a,r,u]=(T=String(t.defaultValue))==null?void 0:T.split(/\D/);(S.isNullish(a)||S.isNullish(r)||S.isNullish(u))&&([a,r,u]=d().toFormat("%Y-%M-%D").split("-"));let s=d(),v=d([Number(a)||s.year,(Number(r)||s.month).zeroEmbed(2),(Number(u)||s.date).zeroEmbed(2)].join("/"));return{eventType:"init",era:"year",display:v,from:v}}));return p.remoteControl(g(c({},t),{val_value:i,set_value:n})),F(()=>{t.onValueUpdate({value:i.from.toFormatYMD(),era:"year",eventType:i.eventType})},[i]),f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{flexWrap:!0,gap:"1/2",children:[e(y.Paragraph,{children:i.from.toFormatYMD("JP")||"----/--/--"}),e(x.Border.XS,{fontColor:"theme",borderRadius:"2.tone.secondary",onClick:()=>{let a=d();n({eventType:"update",era:"year",from:a,display:a})},children:"\u4ECA\u65E5"}),e(P,{}),f(x.Border.S,{padding:["1/6","1/2"],fontColor:"3.blur",fontSize:"0.xs",onClick:()=>{m(a=>a=="calendar"?"drum":"calendar")},children:[o=="calendar"&&"\u30C9\u30E9\u30E0",o=="drum"&&"\u30AB\u30EC\u30F3\u30C0\u30FC","\u8868\u793A"]})]}),e(M,{borderTop:!0}),o=="calendar"&&f($,{children:[f(C.Center,{gap:"1/2",children:[e(Y,{override:"force",emptySelect:!1,value:i.display.year,options:p.YearOptions({reverse:!0}),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,pickerStyles:{xcss:{minWidth:12*12}},onUpdateValidValue:a=>{n(r=>g(c({},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(c({},r),{eventType:"update",display:r.display.clone().setMonth(Number(a))}))}}),e(p.Parts.ShiftButtons,{callback:a=>{n(r=>g(c({},r),{eventType:"update",display:r.display.clone().addMonth(a)}))}})]}),f(L,{children:[e(M,{margin:"auto",xcss:{minWidth:"50%"},UnderBreakPointStyles:{margin:0},children:p.Parts.Calendar({min:l,max:h,onTitleRender:a=>"",targetMonth:i.display,from:i.from,onChange:a=>{n(r=>g(c({},r),{eventType:"update",from:a}))}})}),e(M,{unitHeight:"1/4",isRounded:!0,backgroundColor:"cloud",margin:1,ssHiddenOnBreak:!0}),f(C.Center,{verticalAlign:"unset",ssHiddenOnBreak:!0,children:[e(M,{flexSizing:0,children:p.Parts.Calendar({min:l,max:h,onTitleRender:a=>e(y.Mini,{children:f(C.Center,{gap:"1/2",children:[e(y,{isSemiBoldFont:!0,children:a.toFormatYM("JP")}),e(y,{fontColor:"4.thin",children:"[\u524D\u6708]"})]})}),targetMonth:i.display.clone().addMonth(-1),from:i.from,onChange:a=>{n(r=>g(c({},r),{eventType:"update",from:a}))}})}),e(M,{unitWidth:"1/4",isRounded:!0,backgroundColor:"cloud",margin:1}),e(M,{flexSizing:0,children:p.Parts.Calendar({min:l,max:h,onTitleRender:a=>e(y.Mini,{children:f(C.Center,{gap:"1/2",children:[e(y,{isSemiBoldFont:!0,children:a.toFormatYM("JP")}),e(y,{fontColor:"4.thin",children:"[\u7FCC\u6708]"})]})}),targetMonth:i.display.clone().addMonth(1),from:i.from,onChange:a=>{n(r=>g(c({},r),{eventType:"update",from:a}))}})})]})]})]}),o=="drum"&&e(p.Parts.DrumSelector,{type:"date",min:l,max:h,value:i.from,onChange:a=>{n(g(c({},i),{eventType:"update",from:a}))}})]})},Locale:{JP:{WarekiDate:t=>{var n;let{min:l,max:h}=t,[o,m]=D(S.scope(()=>{var b;let[a,r,u]=(b=String(t.defaultValue))==null?void 0:b.split(/\D/),s=t.era||"year";if(S.isNullish(a)||S.isNullish(r)||S.isNullish(u)){let k=d();s=="heisei"?k.setYear(1989):s=="shouwa"?k.setYear(1926):s=="taisho"?k.setYear(1912):s=="meiji"&&k.setYear(1868),[a,r,u]=k.toFormat("%Y-%M-%D").split("-")}let v=d();return{eventType:"init",from:d([Number(a)||v.year,(Number(r)||v.month).zeroEmbed(2),(Number(u)||v.date).zeroEmbed(2)].join("/"))}}));p.remoteControl(g(c({},t),{val_value:o,set_value:m})),F(()=>{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(y.Paragraph,{children:[o.from.warekiLabel,(n=o.from.warekiYear)==null?void 0:n.zeroEmbed(2),"\u5E74",o.from.toFormatMD("JP")]}),e(P,{})]}),e(M,{borderTop:!0}),e(C.Left,{gap:"1/2",flexWrap:!0,children:["reiwa","heisei","showa","taisho","meiji"].map((a,r)=>{let u=i[a];return u?e(x.Border.S,{onClick:()=>{let s=o.from;if(a=="reiwa"||a=="year")s=d();else{let v=d(u.min),T=d(u.max);v.value>o.from.value&&(s=v),o.from.value>T.value&&(s=T)}if(l){let v=d(l);s.value<v.value&&(s=v)}if(h){let v=d(h);v.value<s.value&&(s=v)}m(g(c({},o),{eventType:"update",from:s}))},children:u.label},r):null})}),e(p.Parts.DrumSelector,{type:"locale.jp.warekiDate",min:t.min,max:t.max,value:o.from,onChange:a=>{m(g(c({},o),{eventType:"update",from:a}))}})]})}}},Clock:t=>{let[l,h]=D(S.scope(()=>{let r=String(t.defaultValue).split(/[^\d]/);if(!r[0]){let v=d();r=[v.hours,v.minutes]}let u=Number(r[0]),s=Number(r[1]);return{eventType:"init",from:d().setHours(u).setMinutes(s)}}));p.remoteControl(g(c({},t),{val_value:l,set_value:h})),F(()=>{t.onValueUpdate({value:l.from.toFormatHM(),era:"clock",eventType:l.eventType})},[l]);let[o,m]=p.minutesUnitState(),i=d().setFromFormatHHMM(t.min||"00:00"),n=d().setFromFormatHHMM(t.max||"23:59");const a=(r,u)=>{h(s=>{let v=s.from.clone();return S.isExist(r)&&v.setHours(r),S.isExist(u)&&v.setMinutes(u),v.toFormatHM().toNumber()>n.toFormatHM().toNumber()&&(v=n.clone()),v.toFormatHM().toNumber()<i.toFormatHM().toNumber()&&(v=i.clone()),g(c({},s),{eventType:"update",from:v})})};return f(L,{xcss:{minWidth:12*16},children:[f(C.Left,{gap:"1/2",flexWrap:!0,children:[f(C.Center,{gap:"1/2",children:[e(M,{className:V("ClockBase"),children:e(M,{className:V("ClockUiBase"),flexCenter:!0,children:f(M,{className:V("ClockUi"),backgroundColor:"theme.opa.low",isRounded:!0,position:"relative",children:[e(M,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[V("Needle"),V("hour")].join(" "),xcss:{transform:`rotate(${l.from.hours*30+l.from.minutes/2}deg)`}}),e(M,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[V("Needle"),V("minute")].join(" "),xcss:{transform:`rotate(${l.from.minutes*6}deg)`}})]})})}),f(M,{textAlign:"center",fontHeight:1.2,children:[f(y.Paragraph,{children:[l.from.hours.zeroEmbed(2)," : ",l.from.minutes.zeroEmbed(2)]}),f(y.Mini,{fontColor:"4.thin",children:[l.from.hours>=12&&"PM"||"AM",l.from.hours%12,":",l.from.minutes.zeroEmbed(2)]})]})]}),e(x.Border.XS,{borderRadius:"2.tone.secondary",fontColor:"theme",onClick:()=>{let 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=>{m(r||1)}})]}),e(M,{borderTop:!0}),f(C.Center,{gap:"1/2",children:[e(R,{xcss:{maxHeight:12*12},override:"force",options:[{value:0,label:"\u5348\u524D"},{value:12,label:"\u5348\u5F8C"}],value:l.from.hours>=12?12:0,onUpdateValidValue:r=>{let u=l.from.hours%12+r;a(u)}}),e(R,{override:"force",value:l.from.hours,options:Array.from({length:24}).map((r,u)=>{let s=u;return i.hours>s||n.hours<s?null:{value:s,label:s.zeroEmbed(2)}}),onUpdateValidValue:r=>{a(r)}}),e(y,{isSemiBoldFont:!0,children:"\u6642"}),e(R,{override:"force",value:l.from.minutes,options:Array.from({length:60}).map((r,u)=>{let s=u;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(y,{isSemiBoldFont:!0,children:"\u5206"})]})]})},Period:{Clock:t=>{let[l,h]=p.minutesUnitState(),[o,m]=D(S.scope(()=>{let[r,u]=S.Arrayify(t.defaultValue),s=d().setFromFormatHHMM(r||"09:00"),v=d().setFromFormatHHMM(u||"18:00");return{eventType:"init",forcus:0,display:s,from:s,to:v}}));p.remoteControl(g(c({},t),{val_value:o,set_value:m})),F(()=>{if(!o.to.value)return;if(o.from.value>o.to.value){m(u=>g(c({},u),{eventType:"update",from:u.to,to:u.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,u,s)=>{m(v=>{let T=v[r].clone();return S.isExist(u)&&T.setHours(u),S.isExist(s)&&T.setMinutes(s),T.toFormatHM().toNumber()>n.toFormatHM().toNumber()&&(T=n.clone()),T.toFormatHM().toNumber()<i.toFormatHM().toNumber()&&(T=i.clone()),g(c({},v),{eventType:"update",[r]:T})})};return f(L,{width:1,xcss:{minWidth:12*24},children:[f(C.Left,{flexWrap:!0,children:[f(C.Left,{gap:"1/2",children:[e(y.Paragraph,{children:o.from.toFormatHM()||"--:--"}),e(y.Mini,{children:"-"}),e(y.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=>{h(r||1)}})]}),e(M,{borderBottom:"1.thin"}),e(p.Period.Preset,g(c({},t),{onPreset:(r,u)=>{m({eventType:"update",forcus:0,display:d(r),from:d(r),to:d(u)})}})),f(C.Center,{gap:"1/2",children:[e(R,{override:"force",value:o.from.hours,options:Array.from({length:24}).map((r,u)=>{let s=u;return i.hours>s||n.hours<s?null:{value:s,label:s.zeroEmbed(2)+"\u6642"}}),onUpdateValidValue:r=>{a("from",r)}}),e(R,{override:"force",value:o.from.minutes,options:Array.from({length:60}).map((r,u)=>{let s=u;return s!=59&&(l==5&&s%5!=0||l==10&&s%10!=0)?null:{value:s,label:s.zeroEmbed(2)+"\u5206"}}),onUpdateValidValue:r=>{a("from",void 0,r)}},l+"-from"),e(y,{isSemiBoldFont:!0,children:"~"}),e(R,{override:"force",value:o.to.hours,options:Array.from({length:24}).map((r,u)=>{let s=u;return i.hours>s||n.hours<s?null:{value:s,label:s.zeroEmbed(2)+"\u6642"}}),onUpdateValidValue:r=>{a("to",r)}}),e(R,{override:"force",value:o.to.minutes,options:Array.from({length:60}).map((r,u)=>{let s=u;return s!=59&&(l==5&&s%5!=0||l==10&&s%10!=0)?null:{value:s,label:s.zeroEmbed(2)+"\u5206"}}),onUpdateValidValue:r=>{a("to",void 0,r)}},l+"-to")]})]})},Date:t=>{let{min:l,max:h}=t,[o,m]=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 p.remoteControl(g(c({},t),{val_value:o,set_value:m})),F(()=>{if(!o.to.value)return;if(o.from.value>o.to.value){m(n=>g(c({},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(y.Mini,{fontColor:"4.thin",children:"from"}),f(x.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{m(i=>g(c({},i),{forcus:0}))},children:[o.from.toFormatYMD()||"----/--/--",o.forcus==0&&e(p.Parts.PeriodFocusSign,{})]}),e(y.Mini,{fontColor:"4.thin",children:"to"}),f(x.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{m(i=>g(c({},i),{forcus:1}))},children:[o.to.toFormatYMD()||"----/--/--",o.forcus==1&&e(p.Parts.PeriodFocusSign,{})]}),e(P,{}),f(C.Right,{gap:"1/2",marginLeft:"auto",children:[e(Y,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{xcss:{minWidth:12*12}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:p.YearOptions({reverse:!0}),value:o.display.year,onUpdateValidValue:i=>{m(n=>g(c({},n),{eventType:"update",display:n.display.clone().setYear(Number(i))}))}}),e(Y,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{xcss:{minWidth:12*9}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:[{value:1,label:"1\u6708"},{value:2,label:"2\u6708"},{value:3,label:"3\u6708"},{value:4,label:"4\u6708"},{value:5,label:"5\u6708"},{value:6,label:"6\u6708"},{value:7,label:"7\u6708"},{value:8,label:"8\u6708"},{value:9,label:"9\u6708"},{value:10,label:"10\u6708"},{value:11,label:"11\u6708"},{value:12,label:"12\u6708"}],value:o.display.month,onUpdateValidValue:i=>{m(n=>g(c({},n),{eventType:"update",display:n.display.clone().setMonth(Number(i)).setDate(1)}))}}),e(p.Parts.ShiftButtons,{callback:i=>{m(n=>g(c({},n),{eventType:"update",display:n.display.clone().addMonth(i)}))}})]})]}),e(M,{borderBottom:"1.thin"}),e(p.Period.Preset,g(c({},t),{onPreset:(i,n)=>{m({eventType:"update",forcus:0,display:d(i),from:d(i),to:d(n)})}})),e(C.Left,{verticalAlign:"top",flexWrap:!0,gap:2,children:Array.from({length:4}).map((i,n)=>{let a=p.Parts.Calendar({min:l,max:h,targetMonth:o.display.clone().addMonth(n-1),from:o.from,to:o.to,onTitleRender:r=>{let u=r.diff(o.display).months;return e(y.Mini,{ssHiddenOnBreak:!0,children:f(C.Center,{gap:"1/2",children:[e(y,{isSemiBoldFont:!0,children:r.toFormatYM("JP")}),e(y,{fontColor:"4.thin",children:["[\u524D\u6708]","","[\u7FCC\u6708]","[\u7FCC\u3005\u6708]"][u+1]})]})})},onChange:r=>{if(o.forcus==0){m(u=>g(c({},u),{eventType:"update",forcus:1,from:r,to:d(null)}));return}m(u=>g(c({},u),{eventType:"update",to:r}))}});return e(M,{flexSizing:"auto",ssHiddenOnBreak:n!=1,children:a},n)})})]})},Month:t=>{let{min:l,max:h}=t,[o,m]=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 p.remoteControl(g(c({},t),{val_value:o,set_value:m})),F(()=>{if(!o.to.value)return;if(o.from.value>o.to.value){m(n=>g(c({},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(y.Mini,{fontColor:"4.thin",children:"from"}),f(x.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{m(i=>g(c({},i),{forcus:0}))},children:[o.from.toFormatYM("JP")||"----/--",o.forcus==0&&e(p.Parts.PeriodFocusSign,{})]}),e(y.Mini,{fontColor:"4.thin",children:"to"}),f(x.Sub,{color:"cloud",isSemiBoldFont:!0,fontColor:"inherit",onClick:()=>{m(i=>g(c({},i),{forcus:1}))},children:[o.to.toFormatYM("JP")||"----/--",o.forcus==1&&e(p.Parts.PeriodFocusSign,{})]}),e(P,{}),f(C.Left,{flexWrap:!0,gap:"1/2",marginLeft:"auto",children:[e(Y,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,fontSize:"1.mini",pickerStyles:{xcss:{minWidth:12*12}},rightIcon:e(N,{right:"2/3",children:e(B.AngleDown,{})}),options:p.YearOptions({reverse:!0}),value:o.display.year,onUpdateValidValue:i=>{m(n=>g(c({},n),{eventType:"update",display:n.display.clone().setYear(Number(i))}))}}),e(p.Parts.ShiftButtons,{callback:i=>{m(n=>g(c({},n),{eventType:"update",display:n.display.clone().addYear(i)}))}})]})]}),e(M,{borderBottom:"1.thin"}),e(p.Period.Preset,g(c({},t),{onPreset:(i,n)=>{m({eventType:"update",forcus:0,display:d(i),from:d(i),to:d(n)})}})),e(C.Left,{verticalAlign:"top",flexWrap:!0,gap:2,UnderBreakPointStyles:{gap:1},children:Array.from({length:4}).map((i,n)=>{let a=p.Parts.YearCalendar({min:l,max:h,targetYear:o.display.year+n-1,from:o.from.getFirstDayOfMonth(),to:o.to.getLastDayOfMonth(),onTitleRender:r=>{let u=r-o.display.year;return e(y.Mini,{children:f(C.Left,{gap:"1/2",children:[f(y,{isSemiBoldFont:!0,children:[r,"\u5E74"]}),e(y,{fontColor:"4.thin",children:["[\u524D\u5E74]","","[\u7FCC\u5E74]","[\u7FCC\u3005\u5E74]"][u+1]})]})})},onChange:r=>{if(o.forcus==0){m(u=>g(c({},u),{eventType:"update",forcus:1,from:r,to:d(null)}));return}m(u=>g(c({},u),{eventType:"update",to:r}))}});return e(M,{flexSizing:"auto",ssHiddenOnBreak:n<1||n>2,xcss:{minWidth:"35%"},children:a},n)})})]})},Preset:t=>t.periodPresets?e(C.Right,{gap:"1/2",flexWrap:!0,children:t.periodPresets.map((l,h)=>e(x.Border.S,{padding:["1/4",1],onClick:()=>{t.onPreset(l.from,l.to)},children:l.label},h))}):null},Parts:{ShiftButtons:t=>f(C.Center,{gap:"1/3",fontSize:"1.mini",children:[e(x.Sub,{className:V("LeftButton"),tabIndex:-1,right:0,position:"relative",ssSquare:2.5,onClick:()=>{t.callback(-1)},children:e(B.ChevronLeft,{})}),e(x.Sub,{className:V("RightButton"),tabIndex:-1,left:0,position:"relative",ssSquare:2.5,onClick:()=>{t.callback(1)},children:e(B.ChevronRight,{})})]}),Calendar:t=>{let{targetMonth:l,from:h,to:o,onTitleRender:m=k=>e(y.Mini,{isSemiBoldFont:!0,children:k.toFormatYM("JP")})}=t,i=d();if(!t.targetMonth.validate)return null;let n=l.clone().setDate(1),a=n.getLastDayOfMonth(),r=d(n).addMonth(-1).getLastDayOfMonth().date,u=[],s=[],v=[],T=[];for(var b=0;b<7;b++){let k=b==6,w=b==0;u.push(e(y.Micro,{textAlign:"center",fontColor:k?"googleBlue":w?"googleRed":"inherit",children:S.transformer.weekday.shortJP(b)},b))}for(var b=0;b<n.weekday;b++)s.unshift(e(y.Mini,{fontColor:"4.thin",flexCenter:!0,children:r-b},b));for(var b=1;b<=a.date;b++){let w=l.clone().setDate(b),E=h.isSameDate(w),z=!1,H=!1;o&&o.validate&&(z=w.isInRange(h,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)}v.push(f(x.Clear.S,{isLocked:U,color:"cloud",border:"1.thin",isActive:E||H||z,isActiveStyles:E||H?{fontColor:"white",backgroundColor:"theme",borderColor:"theme",boxShadow:"0.remark"}:{backgroundColor:"theme.opa.few",fontColor:"theme",borderColor:"0.trans"},xcss:{whiteSpace:"nowrap",minWidth:12*3,minHeight:12*3},flexCenter:!0,ssEffectsOnActive:"shrink",tabIndex:-1,onClick:()=>{t.onChange(w)},children:[b,G&&e(p.Parts.CurrentSign,{})]},w.toFormatYMD()))}for(var b=1;b<7-a.weekday;b++)T.push(e(y.Mini,{flexCenter:!0,fontColor:"4.thin",children:b},b));return f(L,{gap:"1/2",children:[m(l)||"",f(J,{gridCols:7,gap:"1/6",children:[u,s,v,T]})]},l.toFormatYM())},YearCalendar:t=>{let{targetYear:l,from:h,to:o,onTitleRender:m=a=>f(y.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),u=!1;if(t.min){let k=d(t.min).getLastDayOfMonth();k&&r.value<k.value&&(u=!0)}if(t.max){let k=d(t.max).getLastDayOfMonth();k&&k.value<r.value&&(u=!0)}let s=h.year==l&&h.month==r.month,v=!1,T=!1;o&&o.validate&&(v=r.isInRange(h,o),T=o.year==l&&o.month==r.month);let b=i.year==l&&i.month==r.month;n.push(f(x.Clear.S,{isLocked:u,color:"cloud",border:"1.thin",isActive:s||T||v,isActiveStyles:s||T?{fontColor:"white",backgroundColor:"theme",borderColor:"theme",boxShadow:"0.remark"}:{backgroundColor:"theme.opa.few",fontColor:"theme",borderColor:"0.trans"},fontSize:"inherit",ssEffectsOnActive:"shrink",tabIndex:-1,xcss:{whiteSpace:"nowrap",minWidth:12*3,minHeight:12*3},flexCenter:!0,onClick:()=>{t.onChange(r)},children:[f(C.Center,{gap:"1/2",children:[e(y,{children:r.month}),e(y.Mini,{opacity:"middle",children:["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][r.month]})]}),b&&e(p.Parts.CurrentSign,{})]},l+"-"+r.month))}return f(L,{gap:"1/2",children:[m(t.targetYear),e(J,{flexWrap:!0,gridCols:4,gap:"1/6",children:n})]},t.targetYear)},DrumSelector:t=>{let{type:l,min:h,max:o,value:m}=t;const i=(a,r,u)=>{let s=t.value.clone();if(S.isExist(a)&&(s=s.setYear(a)),S.isExist(r)&&(s=s.setMonth(r)),S.isExist(u)&&(s=s.setDate(u)),h){let v=d(h);s.value<v.value&&(s=v)}if(o){let v=d(o);v.value<s.value&&(s=v)}t.onChange(s)};let n=m.getLastDayOfMonth().date;return f(C.Center,{gap:"1/2",children:[e(R,{override:"force",options:p.YearOptions({}),value:m.year,onUpdateValidValue:a=>{i(Number(a))}}),e(y,{isSemiBoldFont:!0,children:"\u5E74"}),e(R,{override:"force",options:Array.from({length:12}).map((a,r)=>{let u=r+1;return{value:u,label:u}}),value:m.month,onUpdateValidValue:a=>{i(void 0,Number(a))}}),e(y,{isSemiBoldFont:!0,children:"\u6708"}),l!="month"&&f($,{children:[e(R,{override:"force",options:Array.from({length:31}).map((a,r)=>{let u=r+1;return u>n?null:{value:u,label:u}}),value:m.date,onUpdateValidValue:a=>{i(void 0,void 0,Number(a))}}),e(y,{isSemiBoldFont:!0,children:"\u65E5"})]})]})},MinMax:t=>{let{restrict:l,min:h,max:o}=t;if(!h&&!o)return null;let m=d(h||null),i=d(o||null),n="",a="";return l=="year"?(n=m.toFormat("%Y\u5E74"),a=i.toFormat("%Y\u5E74")):l.match(/month/)?(n=m.toFormatYM(),a=i.toFormatYM()):l.match(/date/)?(n=m.toFormatYMD(),a=i.toFormatYMD()):l.match(/clock/)&&(m=d().setFromFormatHHMM(h||""),i=d().setFromFormatHHMM(o||""),n=m.toFormatHM(),a=i.toFormatHM()),f(y.Micro,{fontHeight:1.2,children:[n&&f(y,{children:["\u6700\u5C0F: ",n]}),a&&f(y,{children:["\u6700\u5927: ",a]})]})},CurrentSign:()=>e(M,{position:"absolute",bottom:"1/6",left:"50%",width:1,unitHeight:"1/6",backgroundColor:"warn",xcss:{maxWidth:12*2.5,transform:"translateX(-50%)"},isRounded:!0}),PeriodFocusSign:()=>e(M,{position:"absolute",bottom:"1/4",left:"1/2",right:"1/2",backgroundColor:"theme",unitHeight:"1/4",boxShadow:"0.remark",isRounded:!0})}},A=j;A.picker={open:t=>{let l=null,h=null,o="init",m="L";t.restrict=="year"&&(m="S"),t.restrict=="month"&&(m="S"),t.restrict=="clock"?m="XS":(t.restrict=="locale.jp.warekiDate"||t.restrict=="period.clock")&&(m="S");let i=t.sheetID||O(),n=t.pickerId||O();_.open("middleCenter",{sheetID:i,size:m,padding:[2,0],closeAtAroundClick:!0,closeAtParentBlur:!1,onClose:()=>{o!="commit"&&t.onValueUpdate({value:l,era:h,eventType:"commit"})},content:f(L,{gap:"1/2",children:[f(C.Left,{children:[e(P,{}),e(x.Sub.S,{color:"cloud",ssSphere:3,onClick:()=>{_.close(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(a),l=a.value,h=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(y.Micro,{children:"\u30EA\u30BB\u30C3\u30C8"})]})}),e(p.Parts.MinMax,{restrict:t.restrict,min:t.min,max:t.max}),e(P,{}),e(x.Prime.S,{tabIndex:-1,xcss:{minWidth:12*6},onClick:()=>{var 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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amotify",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "description": "UI Component for React,NextJS,esbuild",
5
5
  "scripts": {
6
6
  "start": "run-p clean build:*",