amotify 0.2.187 → 0.2.189
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,6 +1,6 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import $$,{ UUID,Filer } from 'jmini'
|
|
3
|
+
import $$,{ UUID,Filer,Time } from 'jmini'
|
|
4
4
|
import React,{
|
|
5
5
|
useState,
|
|
6
6
|
useEffect
|
|
@@ -2784,16 +2784,21 @@ let DesignBook = () => {
|
|
|
2784
2784
|
// />
|
|
2785
2785
|
// </Column>
|
|
2786
2786
|
|
|
2787
|
-
return <
|
|
2787
|
+
return <Plate
|
|
2788
2788
|
padding={ 3 }
|
|
2789
|
+
size="XS"
|
|
2789
2790
|
>
|
|
2790
|
-
<
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2791
|
+
<Column>
|
|
2792
|
+
<Input.Time.Date
|
|
2793
|
+
value={ Time().toFormatYMD() }
|
|
2794
|
+
name='time.dateWareki'
|
|
2795
|
+
onUpdateValidValue={ value => {
|
|
2796
|
+
console.log( value )
|
|
2797
|
+
} }
|
|
2798
|
+
/>
|
|
2799
|
+
</Column>
|
|
2795
2800
|
|
|
2796
|
-
</
|
|
2801
|
+
</Plate>
|
|
2797
2802
|
|
|
2798
2803
|
return <>
|
|
2799
2804
|
{ Array.from( { length: 10 } ).map( ( _,index ) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as S,c as O,d as Y,e as Z}from"../../chunk-C5N2D3ZX.js";import{Fragment as J,jsx as l,jsxs as L}from"react/jsx-runtime";import{useState as I,useEffect as R,useRef as re}from"react";import u,{UUID as F}from"jmini";import{ExtractStyles as ie}from"../../@utils";import{Box as x,Span as se,FAI as M,Column as ee}from"../../atoms";import{Literal as P,Row as q}from"../../mols";import{Button as te}from"../Button";import{Loader as ce}from"../Loader";import{Sheet as ue}from"../Sheet";import{OptionalInputWrapper as pe,BoxWrapper as de,CoreEffects as K,DefaultBoxishStyles as Se}from"./core";import{InputAutocompleteClasses as W}from"../../@styles/componentClasses";import{InputLabel as me}from"./Label";import{RightIcon as oe}from".";function fe(e){let{value:t,states:c}=e,{required:p,options:n,min:r,max:m}=c;r=r||0,m=m||65535;let o=[],h=t.filter(i=>i!==null).length;return p&&(h||o.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),h<r&&o.push({type:"invalid",label:r+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),h>m&&o.push({type:"invalid",label:m+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!o.filter(({type:i})=>i=="invalid").length,notice:o}}const N={InitOptions:e=>{let t=[];return e.forEach(c=>{if(!c)return;let{type:p,label:n,value:r,searchValue:m}=c,o=m||u.is.string(n)&&n||""||u.is.string(r)&&r||u.Stringify(r||"")||"";u.is.nullish(n)&&(n=String(r)),t.push(O(S({id:F()},c),{searchValue:o,type:p||"selector",label:n,value:r}))}),t},FilterSelectableOptions:(e,t,c)=>{let p=e;return c||(p=e.filter(n=>(n==null?void 0:n.type)!="label")),u.scope(()=>{if(!t)return;let n=t.toLower().replace(/ /g,"");p=p.filter(r=>(r.searchValue||"").toLower().replace(/ /g,"").includes(n))}),p}},E={Shallow:e=>{let{rootStates:t,val_status:c}=e,p=ie(t);return l(x,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:l(P.Description,O(S({className:t.className},p),{position:"absolute",width:1,freeCSS:O(S({},p.freeCSS),{color:"orange"}),"data-id":"shallow_"+c.componentId,children:l(x,{"data-input-value-shallow":c.componentId,children:"A"})}))})},Button:e=>{let{rootStates:t,val_keyword:c,set_keyword:p,val_optionFocused:n,set_optionFocused:r,val_options:m,set_options:o,val_optionsDict:h,set_optionsDict:i,val_preventOpenSelectorOnFocus:s,set_preventOpenSelectorOnFocus:d,val_selectorOpen:a,set_selectorOpen:f,val_status:v,set_status:C,val_validate:g,set_validate:_}=e,G=t,{tone:D,required:w,form:V,className:z,multiSelect:j,enableFormSubmit:B,checkValidationAtFirst:U,onValidate:X,onValidateDelay:H,onUpdateValue:A,onUpdateValidValue:k,value:ve="",options:ye,leftIndicator:he,rightIndicator:ge,leftIcon:_e,rightIcon:be,componentId:Oe,status_id:Ie,wrapStyles:Ce,emptySelect:De,SearchInput:we,SearchInputPlaceholder:Ve,SelectedComponent:ke,SelectorComponent:Te,SelectorStyles:Re,SelectorPosition:xe,DynamicOptionsOnSearch:Ae,DynamicOptionsOnSearchDelay:Fe}=G,b=Y(G,["tone","required","form","className","multiSelect","enableFormSubmit","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","emptySelect","SearchInput","SearchInputPlaceholder","SelectedComponent","SelectorComponent","SelectorStyles","SelectorPosition","DynamicOptionsOnSearch","DynamicOptionsOnSearchDelay"]);return R(()=>{var T;if(t.disabled||!a)return;let y=N.FilterSelectableOptions(e.val_options,c,!1);r(((T=y[0])==null?void 0:T.id)||"")},[c]),R(()=>{v.eventType!="init"&&(t.max==v.dataValue.length?(f(!1),d(!0),setTimeout(()=>{let y=u('[data-input-origin="'+t.componentId+'"]');y&&y.focus()},10)):u("#SearchInput_"+t.componentId).focus())},[v.dataValue]),R(()=>{let y="autocomplete-click-"+t.componentId;if(a){if(!u('[data-input-origin="'+t.componentId+'"]'))return;u("#SearchInput_"+t.componentId).focus(),u(document).addEvent({eventID:y,eventType:"mousedown",callback:$=>{let Q=u($.target),le=!!u(Q).parent("."+W("Core")).length,ne=!!u(Q).parent("."+W("Selector")).length;le||ne||(f(!1),$.preventDefault(),$.stopPropagation())},options:{passive:!1}})}else u(document).removeEvent([y]),p("")},[a]),L(J,{children:[l(x,O(S({tabIndex:0},b),{"data-disabled":t.disabled,"data-show-validation":K.isShowValidation(g,v,!!U),"data-component-id":v.componentId,"data-input-origin":v.componentId,"data-focus":!!a,className:[z,W("Core")].join(" "),onFocus:y=>{if(b!=null&&b.onFocus&&(b==null||b.onFocus(y)),!t.disabled){if(s)return d(!1);f(!0),y.preventDefault()}},onClick:y=>{b!=null&&b.onClick&&(b==null||b.onClick(y)),!t.disabled&&f(!0)},onKeyDown:y=>{let{key:T}=y;B&&K.SubmitForm(y,V),!a&&(T==" "||T=="ArrowDown"||T=="ArrowUp"||T=="Enter")&&f(!0)},children:L(q.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(E.Selected,S({},e)),l(se,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),l(E.SearchInput,S({},e))]})})),a&&l(E.Selector,S({},e))]})},SearchInput:e=>{let{rootStates:t}=e,[c,p]=I(!1);return t.disabled||!e.val_selectorOpen?null:l(x,{id:"SearchInput_"+t.componentId,placeholder:t.SearchInputPlaceholder||"\u691C\u7D22...",opacity:e.val_selectorOpen?"max":"trans",transition:"middle",flexSizing:0,htmlTag:"input",border:"unset",backgroundColor:"trans",value:e.val_keyword,freeCSS:{outline:"none"},onCompositionStart:n=>{t.onCompositionStart&&t.onCompositionStart(n),p(!0)},onCompositionEnd:n=>{t.onCompositionEnd&&t.onCompositionEnd(n),p(!1)},onKeyDown:n=>{let{key:r,metaKey:m,ctrlKey:o}=n,h=m||o;r=="Escape"?(e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0),setTimeout(()=>{let i=u('[data-input-origin="'+t.componentId+'"]');i&&i.focus()},10)):r=="Tab"?e.set_selectorOpen(!1):r==" "?u.scope(()=>{e.val_selectorOpen||e.val_keyword||(n.preventDefault(),e.set_selectorOpen(!0))}):r=="Backspace"?u.scope(()=>{if(e.val_keyword)return;let i=[...e.val_status.dataValue];i.pop(),e.set_status(s=>O(S({},s),{dataValue:i,eventType:"update",eventID:F()}))}):r=="Enter"&&u.scope(()=>{if(c)return;if(!e.val_selectorOpen)return e.set_selectorOpen(!0);let i=e.val_options.find(d=>(d==null?void 0:d.id)==e.val_optionFocused);if(!i)return;let{value:s}=i;e.set_status(d=>{let a=[...d.dataValue];return u.scope(()=>{if(s===null)return a=[];d.dataValue.includes(s)?a=a.filter(v=>v!==s):t.multiSelect?a.push(s):a=[s]}),O(S({},d),{dataValue:a,eventType:"update",eventID:F()})}),e.set_keyword(""),e.set_preventDynamicSearchOnKeywordChange(!0)}),u.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(r))return;if(n.preventDefault(),!e.val_selectorOpen)return e.set_selectorOpen(!0);let i=r=="ArrowDown"?1:-1,s=N.FilterSelectableOptions(e.val_options),d=s.length-1,a=null;u.scope(()=>{var v,C,g,_,D,w;let f=s.findIndex(V=>(V==null?void 0:V.id)==e.val_optionFocused);if(f==-1&&(f=0),i==1){if(a=(v=s[0])==null?void 0:v.id,h){a=(C=s[d])==null?void 0:C.id;return}if(f==-1||f==d)return;a=(g=s[f+1])==null?void 0:g.id}else{if(a=(_=s[d])==null?void 0:_.id,h){a=(D=s[0])==null?void 0:D.id;return}if(f==-1||f==0)return;a=(w=s[f-1])==null?void 0:w.id}}),e.set_optionFocused(a)}),t.enableFormSubmit&&K.SubmitForm(n,e.rootStates.form)},onChange:n=>{let m=n.target.value;e.set_keyword(m)}},"searchInput")},Selector:e=>{var h;let[t,c]=I("idle"),[p,n]=I("idle");R(()=>{if(!e.val_selectorOpen||!e.rootStates.DynamicOptionsOnSearch)return;if(e.val_preventDynamicSearchOnKeywordChange)return e.set_preventDynamicSearchOnKeywordChange(!1);if(t=="idle")return c("ok");n("fetch");let i="autocomplete-search-"+e.rootStates.componentId;u.interval.once(()=>Z(void 0,null,function*(){var a;let s=yield e.rootStates.DynamicOptionsOnSearch(e.val_keyword);n("idle");let d=N.InitOptions(s||[]);e.set_options(d),e.set_optionFocused(((a=d[0])==null?void 0:a.id)||"")}),e.rootStates.DynamicOptionsOnSearchDelay||300,i)},[e.val_keyword]),R(()=>{let i=u(`[data-selector-id="${e.val_status.componentId}"]`)[0];if(!i)return;let s=u(`[data-autocomplete-input-value="${e.val_optionFocused}"]`)[0];s&&(i.scrollTop=s.offsetTop-24)},[e.val_optionFocused]);let r=[],m=N.FilterSelectableOptions(e.val_options,e.rootStates.DynamicOptionsOnSearch?"":e.val_keyword,!0);m.forEach((i,s)=>{if(!i)return;let{type:d,value:a}=i,f=e.val_optionFocused==i.id,v=e.val_status.dataValue.includes(a),C=e.rootStates.SelectorComponent;r.push(l(ee,{"data-autocomplete-input-value":i.id,children:l(C,{option:i,isFocused:f,isSelected:v,addCallback:()=>{e.set_status(g=>{let _=[...g.dataValue];return u.scope(()=>{if(a===null)return _=[];g.dataValue.includes(a)?_=_.filter(w=>w!==a):e.rootStates.multiSelect?_.push(a):_=[a]}),O(S({},g),{dataValue:_,eventType:"update",eventID:F()})})}})},i.id))}),m.length||(r=[l(P.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]),p=="fetch"&&(r=[L(q.Left,{padding:1,fontColor:"3.blur",children:[l(ce.Theme.R,{showInitial:!0}),l(P.Supplement,{children:"Loading..."})]},"loader")]);let o={position:"absolute",minWidth:1,freeCSS:{zIndex:1e3}};switch(e.rootStates.SelectorPosition){case 1:o.bottom="100%",o.left=0,o.paddingBottom="1/3";break;case 2:o.bottom="100%",o.right=0,o.paddingBottom="1/3";break;case 3:o.top="100%",o.left=0,o.paddingTop="1/3";break;case 4:o.top="100%",o.right=0,o.paddingTop="1/3";break;default:break}return l(x,O(S({},o),{children:l(ue.Body,O(S({className:W("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,boxShadow:"1.normal",overflow:"auto","data-selector-id":e.val_status.componentId},e.rootStates.SelectorStyles),{freeCSS:S({maxHeight:12*24},(h=e.rootStates.SelectorStyles)==null?void 0:h.freeCSS),children:l(ee,{gap:"1/12",padding:[1,0],children:r})}))}))},Selected:e=>{let{rootStates:t,val_status:c,set_status:p,val_optionsDict:n}=e,r=[];return c.dataValue.forEach(m=>{let o=n[u.Stringify(m)];if(!o)return;let h=t.SelectedComponent,i=o.label;(o==null?void 0:o.value)===null&&(i=""),r.push(l(x,{className:W("SelectedCell"),children:l(h,{value:o==null?void 0:o.value,label:i,removeCallback:s=>{if(s.stopPropagation(),s.preventDefault(),t.disabled)return;let d=[...c.dataValue];d=d.filter(a=>a!==m),p(a=>O(S({},a),{dataValue:d,eventType:"update",eventID:F()}))}})},u.Stringify(o==null?void 0:o.value)||F()))}),l(J,{children:r})},Core:e=>{var U,X;let{value:t}=e,[c,p]=I(!1),[n,r]=I(!1),[m,o]=I(!1),[h,i]=I(""),[s,d]=I(e.options),[a,f]=I(((U=e.options.find(H=>{var A;return H.value===((A=e.value)==null?void 0:A[0])}))==null?void 0:U.id)||((X=e.options[0])==null?void 0:X.id)||""),[v,C]=I({}),[g,_]=I(K.DefaultStatus(e.componentId,t)),[D,w]=I({ok:!1,notice:[]}),V=re(!1);R(()=>{V.current?d(e.options):V.current=!0},[e.options]),R(()=>{if(!s.length)return;let H=[...s],A=S({},v);H.forEach(k=>{(k==null?void 0:k.type)!="label"&&(A[u.Stringify(k==null?void 0:k.value)]=k)}),C(A)},[s]);let z={rootStates:e,val_options:s,set_options:d,val_optionFocused:a,set_optionFocused:f,val_optionsDict:v,set_optionsDict:C,val_preventDynamicSearchOnKeywordChange:n,set_preventDynamicSearchOnKeywordChange:r,val_preventOpenSelectorOnFocus:c,set_preventOpenSelectorOnFocus:p,val_selectorOpen:m,set_selectorOpen:o,val_keyword:h,set_keyword:i,val_status:g,set_status:_,val_validate:D,set_validate:w},j=!!e.multiSelect;K.CommonEffects({type:j?"autocomplete.multi":"autocomplete.single",states:e,val_status:g,set_status:_,val_validate:D,set_validate:w,SystemValidation:fe});let B=g.dataValue.length&&g.dataValue[0]!==null;return B=B||m,L(de,{val_status:g,set_status:_,val_validate:D,states:e,children:[l(me,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:B}),l(E.Shallow,S({},z)),l(E.Button,S({},z))]})}},ae=e=>{let t=S({},e);return t=O(S({value:[],min:0,max:65535,multiSelect:!0,SearchInput:!0,emptySelect:!0,SelectorComponent:({option:c,isSelected:p,isFocused:n,addCallback:r})=>c?(c==null?void 0:c.type)=="label"?l(J,{children:c.label}):l(te.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1.5],isActive:n,isActiveStyles:{backgroundColor:"cloud"},onClick:m=>{r()},children:L(q.Left,{gap:"1/2",children:[p&&l(M.Check,{fontColor:"theme"}),l(P.Supplement,{transition:"short",children:c.label})]})}):null,SelectedComponent:({value:c,label:p,removeCallback:n})=>L(q.Left,{ssCardBox:"cloud",borderRadius:"2.tone.secondary",fontSize:"1.mini",padding:"1/2",gap:0,children:[l(x,{padding:[0,"1/4"],children:p}),l(te.Sub,{flexSizing:"none",color:"cloud",fontColor:"white",backgroundColor:"layer.5",isRounded:!0,padding:"1/4",onClick:n,freeCSS:{lineHeight:1,aspectRatio:"1/1"},children:l(M.X,{ssSphere:1})})]}),SelectorPosition:3},t),{freeCSS:S({cursor:"pointer"},t.freeCSS)}),t.multiSelect||(t.min=0,t.max=1),t.options=t.options||[],t.emptySelect&&(t.options=[{value:null,label:l(P.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=u.flatArray(t.value),t.options=N.InitOptions(t.options),u.is.nullish(t.rightIcon)&&(t.rightIcon=l(oe,{ssSphere:2,children:l(M.Search,{})}),t.disabled&&(t.rightIcon=l(oe,{ssSphere:2,fontColor:"5.translucent",children:l(M.Ban,{})}))),t.rightIcon&&(t=S({paddingRight:3},t)),t.leftIcon&&(t=S({paddingLeft:3},t)),l(pe,{componentId:t.componentId,children:E.Core,states:Se(t)})};export{ae as Autocomplete,ae as default};
|
|
1
|
+
import{b as S,c as O,d as Y,e as Z}from"../../chunk-C5N2D3ZX.js";import{Fragment as J,jsx as l,jsxs as A}from"react/jsx-runtime";import{useState as I,useEffect as R,useRef as re}from"react";import u,{UUID as E}from"jmini";import{ExtractStyles as ie}from"../../@utils";import{Box as x,Span as se,FAI as q,Column as ee}from"../../atoms";import{Literal as P,Row as K}from"../../mols";import{Button as te}from"../Button";import{Loader as ce}from"../Loader";import{Sheet as ue}from"../Sheet";import{OptionalInputWrapper as pe,BoxWrapper as de,CoreEffects as W,DefaultBoxishStyles as Se}from"./core";import{InputAutocompleteClasses as z}from"../../@styles/componentClasses";import{InputLabel as me}from"./Label";import{RightIcon as oe}from".";function fe(e){let{value:t,states:c}=e,{required:p,options:n,min:r,max:m}=c;r=r||0,m=m||65535;let o=[],h=t.filter(i=>i!==null).length;return p&&(h||o.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),h<r&&o.push({type:"invalid",label:r+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),h>m&&o.push({type:"invalid",label:m+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!o.filter(({type:i})=>i=="invalid").length,notice:o}}const N={InitOptions:e=>{let t=[];return e.forEach(c=>{if(!c)return;let{type:p,label:n,value:r,searchValue:m}=c,o=m||u.is.string(n)&&n||""||u.is.string(r)&&r||u.Stringify(r||"")||"";u.is.nullish(n)&&(n=String(r)),t.push(O(S({id:E()},c),{searchValue:o,type:p||"selector",label:n,value:r}))}),t},FilterSelectableOptions:(e,t,c)=>{let p=e;return c||(p=e.filter(n=>(n==null?void 0:n.type)!="label")),u.scope(()=>{if(!t)return;let n=t.toLower().replace(/ /g,"");p=p.filter(r=>(r.searchValue||"").toLower().replace(/ /g,"").includes(n))}),p}},L={Shallow:e=>{let{rootStates:t,val_status:c}=e,p=ie(t);return l(x,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:l(P.Description,O(S({className:t.className},p),{position:"absolute",width:1,freeCSS:O(S({},p.freeCSS),{color:"orange"}),"data-id":"shallow_"+c.componentId,children:l(x,{"data-input-value-shallow":c.componentId,children:"A"})}))})},Button:e=>{let{rootStates:t,val_keyword:c,set_keyword:p,val_optionFocused:n,set_optionFocused:r,val_options:m,set_options:o,val_optionsDict:h,set_optionsDict:i,val_preventOpenSelectorOnFocus:s,set_preventOpenSelectorOnFocus:d,val_selectorOpen:a,set_selectorOpen:f,val_status:v,set_status:C,val_validate:g,set_validate:_}=e,G=t,{tone:D,required:w,form:V,className:U,multiSelect:j,enableFormSubmit:B,checkValidationAtFirst:H,onValidate:X,onValidateDelay:M,onUpdateValue:F,onUpdateValidValue:k,value:ve="",options:ye,leftIndicator:he,rightIndicator:ge,leftIcon:_e,rightIcon:be,componentId:Oe,status_id:Ie,wrapStyles:Ce,emptySelect:De,SearchInput:we,SearchInputPlaceholder:Ve,SelectedComponent:ke,SelectorComponent:Te,SelectorStyles:Re,SelectorPosition:xe,DynamicOptionsOnSearch:Ae,DynamicOptionsOnSearchDelay:Fe}=G,b=Y(G,["tone","required","form","className","multiSelect","enableFormSubmit","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","emptySelect","SearchInput","SearchInputPlaceholder","SelectedComponent","SelectorComponent","SelectorStyles","SelectorPosition","DynamicOptionsOnSearch","DynamicOptionsOnSearchDelay"]);return R(()=>{var T;if(t.disabled||!a)return;let y=N.FilterSelectableOptions(e.val_options,c,!1);r(((T=y[0])==null?void 0:T.id)||"")},[c]),R(()=>{v.eventType!="init"&&(t.max==v.dataValue.length?(f(!1),d(!0),setTimeout(()=>{let y=u('[data-input-origin="'+t.componentId+'"]');y&&y.focus()},10)):u("#SearchInput_"+t.componentId).focus())},[v.dataValue]),R(()=>{let y="autocomplete-click-"+t.componentId;if(a){if(!u('[data-input-origin="'+t.componentId+'"]'))return;u("#SearchInput_"+t.componentId).focus(),u(document).addEvent({eventID:y,eventType:"mousedown",callback:$=>{let Q=u($.target),le=!!u(Q).parent("."+z("Core")).length,ne=!!u(Q).parent("."+z("Selector")).length;le||ne||(f(!1),$.preventDefault(),$.stopPropagation())},options:{passive:!1}})}else u(document).removeEvent([y]),p("")},[a]),A(J,{children:[l(x,O(S({tabIndex:0},b),{"data-disabled":t.disabled,"data-show-validation":W.isShowValidation(g,v,!!H),"data-component-id":v.componentId,"data-input-origin":v.componentId,"data-focus":!!a,className:[U,z("Core")].join(" "),onFocus:y=>{if(b!=null&&b.onFocus&&(b==null||b.onFocus(y)),!t.disabled){if(s)return d(!1);f(!0),y.preventDefault()}},onClick:y=>{b!=null&&b.onClick&&(b==null||b.onClick(y)),!t.disabled&&f(!0)},onKeyDown:y=>{let{key:T}=y;B&&W.SubmitForm(y,V),!a&&(T==" "||T=="ArrowDown"||T=="ArrowUp"||T=="Enter")&&f(!0)},children:A(K.Left,{gap:0,children:[l(se,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),A(K.Left,{flexWrap:!0,flexSizing:0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(L.Selected,S({},e)),l(L.SearchInput,S({},e))]})]})})),a&&l(L.Selector,S({},e))]})},SearchInput:e=>{let{rootStates:t}=e,[c,p]=I(!1);return t.disabled||!e.val_selectorOpen?null:l(x,{id:"SearchInput_"+t.componentId,placeholder:t.SearchInputPlaceholder||"\u691C\u7D22...",opacity:e.val_selectorOpen?"max":"trans",transition:"middle",flexSizing:0,htmlTag:"input",border:"unset",backgroundColor:"trans",value:e.val_keyword,freeCSS:{outline:"none"},onCompositionStart:n=>{t.onCompositionStart&&t.onCompositionStart(n),p(!0)},onCompositionEnd:n=>{t.onCompositionEnd&&t.onCompositionEnd(n),p(!1)},onKeyDown:n=>{let{key:r,metaKey:m,ctrlKey:o}=n,h=m||o;r=="Escape"?(e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0),setTimeout(()=>{let i=u('[data-input-origin="'+t.componentId+'"]');i&&i.focus()},10)):r=="Tab"?e.set_selectorOpen(!1):r==" "?u.scope(()=>{e.val_selectorOpen||e.val_keyword||(n.preventDefault(),e.set_selectorOpen(!0))}):r=="Backspace"?u.scope(()=>{if(e.val_keyword)return;let i=[...e.val_status.dataValue];i.pop(),e.set_status(s=>O(S({},s),{dataValue:i,eventType:"update",eventID:E()}))}):r=="Enter"&&u.scope(()=>{if(c)return;if(!e.val_selectorOpen)return e.set_selectorOpen(!0);let i=e.val_options.find(d=>(d==null?void 0:d.id)==e.val_optionFocused);if(!i)return;let{value:s}=i;e.set_status(d=>{let a=[...d.dataValue];return u.scope(()=>{if(s===null)return a=[];d.dataValue.includes(s)?a=a.filter(v=>v!==s):t.multiSelect?a.push(s):a=[s]}),O(S({},d),{dataValue:a,eventType:"update",eventID:E()})}),e.set_keyword(""),e.set_preventDynamicSearchOnKeywordChange(!0)}),u.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(r))return;if(n.preventDefault(),!e.val_selectorOpen)return e.set_selectorOpen(!0);let i=r=="ArrowDown"?1:-1,s=N.FilterSelectableOptions(e.val_options),d=s.length-1,a=null;u.scope(()=>{var v,C,g,_,D,w;let f=s.findIndex(V=>(V==null?void 0:V.id)==e.val_optionFocused);if(f==-1&&(f=0),i==1){if(a=(v=s[0])==null?void 0:v.id,h){a=(C=s[d])==null?void 0:C.id;return}if(f==-1||f==d)return;a=(g=s[f+1])==null?void 0:g.id}else{if(a=(_=s[d])==null?void 0:_.id,h){a=(D=s[0])==null?void 0:D.id;return}if(f==-1||f==0)return;a=(w=s[f-1])==null?void 0:w.id}}),e.set_optionFocused(a)}),t.enableFormSubmit&&W.SubmitForm(n,e.rootStates.form)},onChange:n=>{let m=n.target.value;e.set_keyword(m)}},"searchInput")},Selector:e=>{var h;let[t,c]=I("idle"),[p,n]=I("idle");R(()=>{if(!e.val_selectorOpen||!e.rootStates.DynamicOptionsOnSearch)return;if(e.val_preventDynamicSearchOnKeywordChange)return e.set_preventDynamicSearchOnKeywordChange(!1);if(t=="idle")return c("ok");n("fetch");let i="autocomplete-search-"+e.rootStates.componentId;u.interval.once(()=>Z(void 0,null,function*(){var a;let s=yield e.rootStates.DynamicOptionsOnSearch(e.val_keyword);n("idle");let d=N.InitOptions(s||[]);e.set_options(d),e.set_optionFocused(((a=d[0])==null?void 0:a.id)||"")}),e.rootStates.DynamicOptionsOnSearchDelay||300,i)},[e.val_keyword]),R(()=>{let i=u(`[data-selector-id="${e.val_status.componentId}"]`)[0];if(!i)return;let s=u(`[data-autocomplete-input-value="${e.val_optionFocused}"]`)[0];s&&(i.scrollTop=s.offsetTop-24)},[e.val_optionFocused]);let r=[],m=N.FilterSelectableOptions(e.val_options,e.rootStates.DynamicOptionsOnSearch?"":e.val_keyword,!0);m.forEach((i,s)=>{if(!i)return;let{type:d,value:a}=i,f=e.val_optionFocused==i.id,v=e.val_status.dataValue.includes(a),C=e.rootStates.SelectorComponent;r.push(l(ee,{"data-autocomplete-input-value":i.id,children:l(C,{option:i,isFocused:f,isSelected:v,addCallback:()=>{e.set_status(g=>{let _=[...g.dataValue];return u.scope(()=>{if(a===null)return _=[];g.dataValue.includes(a)?_=_.filter(w=>w!==a):e.rootStates.multiSelect?_.push(a):_=[a]}),O(S({},g),{dataValue:_,eventType:"update",eventID:E()})})}})},i.id))}),m.length||(r=[l(P.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]),p=="fetch"&&(r=[A(K.Left,{padding:1,fontColor:"3.blur",children:[l(ce.Theme.R,{showInitial:!0}),l(P.Supplement,{children:"Loading..."})]},"loader")]);let o={position:"absolute",minWidth:1,freeCSS:{zIndex:1e3}};switch(e.rootStates.SelectorPosition){case 1:o.bottom="100%",o.left=0,o.paddingBottom="1/3";break;case 2:o.bottom="100%",o.right=0,o.paddingBottom="1/3";break;case 3:o.top="100%",o.left=0,o.paddingTop="1/3";break;case 4:o.top="100%",o.right=0,o.paddingTop="1/3";break;default:break}return l(x,O(S({},o),{children:l(ue.Body,O(S({className:z("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,boxShadow:"1.normal",overflow:"auto","data-selector-id":e.val_status.componentId},e.rootStates.SelectorStyles),{freeCSS:S({maxHeight:12*24},(h=e.rootStates.SelectorStyles)==null?void 0:h.freeCSS),children:l(ee,{gap:"1/12",padding:[1,0],children:r})}))}))},Selected:e=>{let{rootStates:t,val_status:c,set_status:p,val_optionsDict:n}=e,r=[];return c.dataValue.forEach(m=>{let o=n[u.Stringify(m)];if(!o)return;let h=t.SelectedComponent,i=o.label;(o==null?void 0:o.value)===null&&(i=""),r.push(l(x,{className:z("SelectedCell"),children:l(h,{value:o==null?void 0:o.value,label:i,removeCallback:s=>{if(s.stopPropagation(),s.preventDefault(),t.disabled)return;let d=[...c.dataValue];d=d.filter(a=>a!==m),p(a=>O(S({},a),{dataValue:d,eventType:"update",eventID:E()}))}})},u.Stringify(o==null?void 0:o.value)||E()))}),l(J,{children:r})},Core:e=>{var H,X;let{value:t}=e,[c,p]=I(!1),[n,r]=I(!1),[m,o]=I(!1),[h,i]=I(""),[s,d]=I(e.options),[a,f]=I(((H=e.options.find(M=>{var F;return M.value===((F=e.value)==null?void 0:F[0])}))==null?void 0:H.id)||((X=e.options[0])==null?void 0:X.id)||""),[v,C]=I({}),[g,_]=I(W.DefaultStatus(e.componentId,t)),[D,w]=I({ok:!1,notice:[]}),V=re(!1);R(()=>{V.current?d(e.options):V.current=!0},[e.options]),R(()=>{if(!s.length)return;let M=[...s],F=S({},v);M.forEach(k=>{(k==null?void 0:k.type)!="label"&&(F[u.Stringify(k==null?void 0:k.value)]=k)}),C(F)},[s]);let U={rootStates:e,val_options:s,set_options:d,val_optionFocused:a,set_optionFocused:f,val_optionsDict:v,set_optionsDict:C,val_preventDynamicSearchOnKeywordChange:n,set_preventDynamicSearchOnKeywordChange:r,val_preventOpenSelectorOnFocus:c,set_preventOpenSelectorOnFocus:p,val_selectorOpen:m,set_selectorOpen:o,val_keyword:h,set_keyword:i,val_status:g,set_status:_,val_validate:D,set_validate:w},j=!!e.multiSelect;W.CommonEffects({type:j?"autocomplete.multi":"autocomplete.single",states:e,val_status:g,set_status:_,val_validate:D,set_validate:w,SystemValidation:fe});let B=g.dataValue.length&&g.dataValue[0]!==null;return B=B||m,A(de,{val_status:g,set_status:_,val_validate:D,states:e,children:[l(me,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:B}),l(L.Shallow,S({},U)),l(L.Button,S({},U))]})}},ae=e=>{let t=S({},e);return t=O(S({value:[],min:0,max:65535,multiSelect:!0,SearchInput:!0,emptySelect:!0,SelectorComponent:({option:c,isSelected:p,isFocused:n,addCallback:r})=>c?(c==null?void 0:c.type)=="label"?l(J,{children:c.label}):l(te.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1.5],isActive:n,isActiveStyles:{backgroundColor:"cloud"},onClick:m=>{r()},children:A(K.Left,{gap:"1/2",children:[p&&l(q.Check,{fontColor:"theme"}),l(P.Supplement,{transition:"short",children:c.label})]})}):null,SelectedComponent:({value:c,label:p,removeCallback:n})=>A(K.Left,{ssCardBox:"cloud",borderRadius:"2.tone.secondary",fontSize:"1.mini",padding:"1/2",gap:0,children:[l(x,{padding:[0,"1/4"],children:p}),l(te.Sub,{flexSizing:"none",color:"cloud",fontColor:"white",backgroundColor:"layer.5",isRounded:!0,padding:"1/4",onClick:n,freeCSS:{lineHeight:1,aspectRatio:"1/1"},children:l(q.X,{ssSphere:1})})]}),SelectorPosition:3},t),{freeCSS:S({cursor:"pointer"},t.freeCSS)}),t.multiSelect||(t.min=0,t.max=1),t.options=t.options||[],t.emptySelect&&(t.options=[{value:null,label:l(P.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=u.flatArray(t.value),t.options=N.InitOptions(t.options),u.is.nullish(t.rightIcon)&&(t.rightIcon=l(oe,{ssSphere:2,children:l(q.Search,{})}),t.disabled&&(t.rightIcon=l(oe,{ssSphere:2,fontColor:"5.translucent",children:l(q.Ban,{})}))),t.rightIcon&&(t=S({paddingRight:3},t)),t.leftIcon&&(t=S({paddingLeft:3},t)),l(pe,{componentId:t.componentId,children:L.Core,states:Se(t)})};export{ae as Autocomplete,ae as default};
|
package/dist/fn/Input/Select.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as n,c as f,d as H}from"../../chunk-C5N2D3ZX.js";import{Fragment as j,jsx as a,jsxs as O}from"react/jsx-runtime";import u,{UUID as D}from"jmini";import{useState as A,useEffect as $}from"react";import{ExtractStyles as _e}from"../../@utils";import{Box as C,Span as Ve,FAI as te,Column as Oe}from"../../atoms";import{Literal as W,Row as le}from"../../mols";import{Button as Te}from"../Button";import{Sheet as xe}from"../Sheet";import{OptionalInputWrapper as Fe,BoxWrapper as we,CoreEffects as k,DefaultBoxishStyles as De}from"./core";import{InputAutocompleteClasses as B}from"../../@styles/componentClasses";import{InputLabel as ke}from"./Label";import{RightIcon as Re}from".";function Ae(e){let{value:t,states:l}=e,{required:o,options:i}=l,m=[];return o&&t===null&&m.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!m.filter(({type:p})=>p=="invalid").length,notice:m}}const ae={FilterSelectableOptions:(e,t)=>{let l=e.rootStates.options;return t||(l=l.filter(o=>(o==null?void 0:o.type)!="label")),l}},_={Shallow:e=>{let{rootStates:t,val_status:l}=e,o=_e(t);return a(C,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:a(W.Description,f(n({className:t.className},o),{position:"absolute",width:1,freeCSS:f(n({},o.freeCSS),{color:"orange"}),children:a(C,{"data-input-value-shallow":l.componentId,children:"A"})}))})},Button:e=>O(j,{children:[a(_.LegacySelector,n({},e)),a(_.Original,n({},e))]}),Placeholder:e=>!e.rootStates.placeholder||e.val_status.dataValue!==null?null:a(C,{position:"absolute",opacity:"middle",fontColor:"3.blur",children:e.rootStates.placeholder||""}),Original:e=>{let{rootStates:t,val_preventOpenSelectorOnFocus:l,set_preventOpenSelectorOnFocus:o,val_optionFocused:i,set_optionFocused:m,val_validate:p,set_validate:b,val_status:d,set_status:I,val_selectorOpen:v,set_selectorOpen:S}=e,U=t,{tone:E,required:L,form:T,className:R,label:ne,isLabelActive:re,placeholder:se,enableFormSubmit:P,emptySelect:J,checkValidationAtFirst:M,onValidate:ie,onValidateDelay:ce,onUpdateValue:ue,onUpdateValidValue:de,value:N="",options:K,leftIndicator:pe,rightIndicator:X,leftIcon:Se,rightIcon:fe,componentId:me,status_id:ye,wrapStyles:ve,SelectedCellStyles:ge,SelectorCellStyles:be,SelectorMode:Ie,SelectorStyles:he,SelectorPosition:Ce}=U,r=H(U,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","SelectedCellStyles","SelectorCellStyles","SelectorMode","SelectorStyles","SelectorPosition"]);return $(()=>{if(e.rootStates.SelectorMode!="original"||t.disabled)return;let c="select-click-"+t.componentId;if(v){if(!u('[data-input-origin="'+t.componentId+'"]'))return;u(document).addEvent({eventID:c,eventType:"click",callback:s=>{let x=u(s.target),F=!!u(x).parent("."+B("Core")).length;u(x).parent("."+B("Selector")).length||F||S(!1)}})}else u(document).removeEvent([c])},[v]),$(()=>{if(e.rootStates.SelectorMode!="original"||d.eventType=="init"||!v)return;let c=u('[data-input-origin="'+t.componentId+'"]');c&&c.focus()},[d.dataValue]),e.rootStates.SelectorMode!="original"?null:O(j,{children:[a(C,f(n({tabIndex:0},r),{"data-disabled":t.disabled,"data-show-validation":k.isShowValidation(p,d,!!M),"data-component-id":d.componentId,"data-input-origin":d.componentId,className:[R,B("Core")].join(" "),onFocus:c=>{if(r!=null&&r.onFocus&&(r==null||r.onFocus(c)),!t.disabled){if(l)return o(!1);S(!0)}},onClick:c=>{r!=null&&r.onClick&&(r==null||r.onClick(c)),!t.disabled&&S(!0)},onKeyDown:c=>{let{key:g,metaKey:s,ctrlKey:x}=c,F=s||x;if(r!=null&&r.onKeyDown&&(r==null||r.onKeyDown(c)),P&&k.SubmitForm(c,T),!t.disabled){if(u.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(g))return;if(c.preventDefault(),!v)return S(!0);let h=g=="ArrowDown"?1:-1,y=ae.FilterSelectableOptions(e),q=y.length-1,V=null;u.scope(()=>{var G,Q,Y,Z,ee;let w=y.findIndex(z=>(z==null?void 0:z.id)==i);if(h==1){if(V=(G=y[0])==null?void 0:G.id,F){V=y[q].id;return}if(w==-1||w==q)return;V=(Q=y[w+1])==null?void 0:Q.id}else{if(V=(Y=y[q])==null?void 0:Y.id,F){V=(Z=y[0])==null?void 0:Z.id;return}if(w==-1||w==0)return;V=(ee=y[w-1])==null?void 0:ee.id}}),m(V)}),g=="Escape")S(!1);else if(g=="Tab")S(!1);else if(g=="Backspace")I(h=>f(n({},h),{dataValue:null,eventType:"update",eventID:D()}));else if(g==" ")c.preventDefault(),S(!0);else if(g=="Enter"){if(!v)return S(!0);c.preventDefault();let h=t.options.find(y=>(y==null?void 0:y.id)==i);if(!h)return;I(y=>f(n({},y),{dataValue:h==null?void 0:h.value,eventType:"update",eventID:D()})),S(!1)}}},children:O(le.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[a(_.Placeholder,n({},e)),a(_.Selected,n({},e)),a(Ve,{width:0,overflow:"hidden",opacity:"trans",children:"A"})]})})),v&&a(_.Selector,n({},e))]})},LegacySelector:e=>{let{rootStates:t,val_preventOpenSelectorOnFocus:l,set_preventOpenSelectorOnFocus:o,val_optionFocused:i,set_optionFocused:m,val_validate:p,set_validate:b,val_status:d,set_status:I,val_selectorOpen:v,set_selectorOpen:S}=e,g=t,{tone:E,required:L,form:T,className:R,label:ne,isLabelActive:re,placeholder:se,enableFormSubmit:P,emptySelect:J,checkValidationAtFirst:M,onValidate:ie,onValidateDelay:ce,onUpdateValue:ue,onUpdateValidValue:de,onKeyDown:N,onChange:K,value:pe="",options:X,leftIndicator:Se,rightIndicator:fe,leftIcon:me,rightIcon:ye,componentId:ve,status_id:ge,wrapStyles:be,SelectedCellStyles:Ie,SelectorCellStyles:he,SelectorMode:Ce,SelectorStyles:r,SelectorPosition:U}=g,c=H(g,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onKeyDown","onChange","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","SelectedCellStyles","SelectorCellStyles","SelectorMode","SelectorStyles","SelectorPosition"]);return e.rootStates.SelectorMode!="legacy"?null:O(C,f(n({htmlTag:"select",tabIndex:0},c),{"data-disabled":t.disabled,"data-show-validation":k.isShowValidation(p,d,!!M),"data-component-id":d.componentId,"data-input-origin":d.componentId,className:[R,B("Core")].join(" "),onKeyDown:s=>{N&&N(s),P&&k.SubmitForm(s,T)},onChange:s=>{let{value:x}=s.target;p.ok&&b({ok:!1,notice:[]}),I(F=>f(n({},F),{dataValue:x,eventType:"update",eventID:D()})),K&&K(s)},children:[!!J&&a("option",{value:"null",children:"\u9078\u629E"}),X.map(s=>u.is.nullish(s==null?void 0:s.value)?null:a("option",{value:s==null?void 0:s.value,children:s.label},String(s==null?void 0:s.value)))]}))},Selector:e=>{var o;$(()=>{let i=u(`[data-selector-id="${e.val_status.componentId}"]`)[0];if(!i)return;let m=u(`[data-select-input-value="${e.val_optionFocused}"]`)[0];m&&(i.scrollTop=m.offsetTop-24)},[e.val_optionFocused]);let t=ae.FilterSelectableOptions(e,!0),l={position:"absolute",minWidth:1,freeCSS:{zIndex:1e3}};switch(e.rootStates.SelectorPosition){case 1:l.bottom="100%",l.left=0,l.paddingBottom="1/3";break;case 2:l.bottom="100%",l.right=0,l.paddingBottom="1/3";break;case 3:l.top="100%",l.left=0,l.paddingTop="1/3";break;case 4:l.top="100%",l.right=0,l.paddingTop="1/3";break;default:break}return a(C,f(n({},l),{children:a(xe.Body,f(n({className:B("Selector"),ssCardBox:!0,borderRadius:"2.tone.secondary",boxShadow:"1.normal",overflow:"auto","data-selector-id":e.val_status.componentId},e.rootStates.SelectorStyles),{freeCSS:n({minWidth:12*6,maxHeight:12*24},(o=e.rootStates.SelectorStyles)==null?void 0:o.freeCSS),children:O(Oe,{gap:"1/12",padding:[1,0],children:[t.map((i,m)=>{if(!i)return null;let{type:p,value:b}=i,d=e.val_optionFocused==i.id,I=e.val_status.dataValue===b;return p=="label"?a(C,{children:i.label},D()):a(Te.Sub.S,f(n({"data-select-input-value":i.id,color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1],isActive:I||d,isActiveStyles:d?{backgroundColor:"cloud"}:{backgroundColor:"theme.opa.few",fontColor:"theme"}},e.rootStates.SelectorCellStyles),{onClick:v=>{e.set_status(S=>f(n({},S),{dataValue:b,eventType:"update",eventID:D()})),e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0)},children:O(le.Left,{gap:"1/2",children:[I&&a(te.Check,{fontColor:"theme"}),a(W.Supplement,{transition:"short",flexSizing:0,children:i.label})]})}),i.id)}),!t.length&&a(W.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]})}))}))},Selected:e=>{let t=[];return e.val_status.dataValue!==null&&u.scope(()=>{let l=e.rootStates.options.find(o=>u.is.equal(o==null?void 0:o.value,e.val_status.dataValue));l&&t.push(a(C,f(n({},e.rootStates.SelectedCellStyles),{children:l.label}),String(l==null?void 0:l.value)))}),a(j,{children:t})},Core:e=>{var L,T;let{value:t}=e,[l,o]=A(k.DefaultStatus(e.componentId,t)),[i,m]=A(!1),[p,b]=A(!1),[d,I]=A(((L=e.options.find(R=>R.value===e.value))==null?void 0:L.id)||((T=e.options[0])==null?void 0:T.id)||""),[v,S]=A({ok:!1,notice:[]}),E={rootStates:e,val_preventOpenSelectorOnFocus:i,set_preventOpenSelectorOnFocus:m,val_optionFocused:d,set_optionFocused:I,val_selectorOpen:p,set_selectorOpen:b,val_status:l,set_status:o,val_validate:v,set_validate:S};return k.CommonEffects({type:"select",states:e,val_status:l,set_status:o,val_validate:v,set_validate:S,SystemValidation:Ae}),O(we,{val_status:l,set_status:o,val_validate:v,states:e,children:[a(ke,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:e.isLabelActive||l.dataValue!==null}),a(_.Shallow,n({},E)),a(_.Button,n({},E))]})}},oe=e=>{var l;let t=n({},e);return t=f(n({emptySelect:!0,SelectorMode:"original",SelectorPosition:3},t),{freeCSS:n({cursor:"pointer"},t.freeCSS)}),t.emptySelect&&(t.options=[{value:null,label:a(W.Supplement,{fontColor:"4.thin",children:"\u672A\u9078\u629E"})},...t.options]),t.value=(l=t.value)!=null?l:null,t.options.forEach((o,i)=>{if(!o)return;let{type:m,value:p,searchValue:b}=o,d=b||u.is.string(p)&&p||u.Stringify(p||"")||"";t.options[i]=f(n({id:D()},o),{value:p,searchValue:d,type:m||"selector"})}),u.is.nullish(t.rightIcon)&&(t.rightIcon=a(Re,{ssSphere:2,children:a(te.AngleDown,{})})),a(Fe,{componentId:t.componentId,children:_.Core,states:De(t)})};export{oe as Select,oe as default};
|
|
1
|
+
import{b as n,c as f,d as H}from"../../chunk-C5N2D3ZX.js";import{Fragment as J,jsx as a,jsxs as V}from"react/jsx-runtime";import u,{UUID as D}from"jmini";import{useState as A,useEffect as $}from"react";import{ExtractStyles as _e}from"../../@utils";import{Box as C,Span as Ve,FAI as le,Column as Oe}from"../../atoms";import{Literal as W,Row as j}from"../../mols";import{Button as Te}from"../Button";import{Sheet as xe}from"../Sheet";import{OptionalInputWrapper as Fe,BoxWrapper as we,CoreEffects as R,DefaultBoxishStyles as De}from"./core";import{InputAutocompleteClasses as B}from"../../@styles/componentClasses";import{InputLabel as Re}from"./Label";import{RightIcon as ke}from".";function Ae(e){let{value:t,states:l}=e,{required:o,options:i}=l,m=[];return o&&t===null&&m.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!m.filter(({type:p})=>p=="invalid").length,notice:m}}const ae={FilterSelectableOptions:(e,t)=>{let l=e.rootStates.options;return t||(l=l.filter(o=>(o==null?void 0:o.type)!="label")),l}},_={Shallow:e=>{let{rootStates:t,val_status:l}=e,o=_e(t);return a(C,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:a(W.Description,f(n({className:t.className},o),{position:"absolute",width:1,freeCSS:f(n({},o.freeCSS),{color:"orange"}),children:a(C,{"data-input-value-shallow":l.componentId,children:"A"})}))})},Button:e=>V(J,{children:[a(_.LegacySelector,n({},e)),a(_.Original,n({},e))]}),Placeholder:e=>!e.rootStates.placeholder||e.val_status.dataValue!==null?null:a(C,{position:"absolute",opacity:"middle",fontColor:"3.blur",children:e.rootStates.placeholder||""}),Original:e=>{let{rootStates:t,val_preventOpenSelectorOnFocus:l,set_preventOpenSelectorOnFocus:o,val_optionFocused:i,set_optionFocused:m,val_validate:p,set_validate:b,val_status:d,set_status:I,val_selectorOpen:v,set_selectorOpen:S}=e,U=t,{tone:E,required:L,form:T,className:k,label:ne,isLabelActive:re,placeholder:se,enableFormSubmit:P,emptySelect:X,checkValidationAtFirst:M,onValidate:ie,onValidateDelay:ce,onUpdateValue:ue,onUpdateValidValue:de,value:N="",options:K,leftIndicator:pe,rightIndicator:G,leftIcon:Se,rightIcon:fe,componentId:me,status_id:ye,wrapStyles:ve,SelectedCellStyles:ge,SelectorCellStyles:be,SelectorMode:Ie,SelectorStyles:he,SelectorPosition:Ce}=U,r=H(U,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","SelectedCellStyles","SelectorCellStyles","SelectorMode","SelectorStyles","SelectorPosition"]);return $(()=>{if(e.rootStates.SelectorMode!="original"||t.disabled)return;let c="select-click-"+t.componentId;if(v){if(!u('[data-input-origin="'+t.componentId+'"]'))return;u(document).addEvent({eventID:c,eventType:"click",callback:s=>{let x=u(s.target),F=!!u(x).parent("."+B("Core")).length;u(x).parent("."+B("Selector")).length||F||S(!1)}})}else u(document).removeEvent([c])},[v]),$(()=>{if(e.rootStates.SelectorMode!="original"||d.eventType=="init"||!v)return;let c=u('[data-input-origin="'+t.componentId+'"]');c&&c.focus()},[d.dataValue]),e.rootStates.SelectorMode!="original"?null:V(J,{children:[a(C,f(n({tabIndex:0},r),{"data-disabled":t.disabled,"data-show-validation":R.isShowValidation(p,d,!!M),"data-component-id":d.componentId,"data-input-origin":d.componentId,className:[k,B("Core")].join(" "),onFocus:c=>{if(r!=null&&r.onFocus&&(r==null||r.onFocus(c)),!t.disabled){if(l)return o(!1);S(!0)}},onClick:c=>{r!=null&&r.onClick&&(r==null||r.onClick(c)),!t.disabled&&S(!0)},onKeyDown:c=>{let{key:g,metaKey:s,ctrlKey:x}=c,F=s||x;if(r!=null&&r.onKeyDown&&(r==null||r.onKeyDown(c)),P&&R.SubmitForm(c,T),!t.disabled){if(u.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(g))return;if(c.preventDefault(),!v)return S(!0);let h=g=="ArrowDown"?1:-1,y=ae.FilterSelectableOptions(e),q=y.length-1,O=null;u.scope(()=>{var Q,Y,Z,ee,te;let w=y.findIndex(z=>(z==null?void 0:z.id)==i);if(h==1){if(O=(Q=y[0])==null?void 0:Q.id,F){O=y[q].id;return}if(w==-1||w==q)return;O=(Y=y[w+1])==null?void 0:Y.id}else{if(O=(Z=y[q])==null?void 0:Z.id,F){O=(ee=y[0])==null?void 0:ee.id;return}if(w==-1||w==0)return;O=(te=y[w-1])==null?void 0:te.id}}),m(O)}),g=="Escape")S(!1);else if(g=="Tab")S(!1);else if(g=="Backspace")I(h=>f(n({},h),{dataValue:null,eventType:"update",eventID:D()}));else if(g==" ")c.preventDefault(),S(!0);else if(g=="Enter"){if(!v)return S(!0);c.preventDefault();let h=t.options.find(y=>(y==null?void 0:y.id)==i);if(!h)return;I(y=>f(n({},y),{dataValue:h==null?void 0:h.value,eventType:"update",eventID:D()})),S(!1)}}},children:V(j.Left,{gap:0,children:[a(Ve,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),V(j.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[a(_.Placeholder,n({},e)),a(_.Selected,n({},e))]})]})})),v&&a(_.Selector,n({},e))]})},LegacySelector:e=>{let{rootStates:t,val_preventOpenSelectorOnFocus:l,set_preventOpenSelectorOnFocus:o,val_optionFocused:i,set_optionFocused:m,val_validate:p,set_validate:b,val_status:d,set_status:I,val_selectorOpen:v,set_selectorOpen:S}=e,g=t,{tone:E,required:L,form:T,className:k,label:ne,isLabelActive:re,placeholder:se,enableFormSubmit:P,emptySelect:X,checkValidationAtFirst:M,onValidate:ie,onValidateDelay:ce,onUpdateValue:ue,onUpdateValidValue:de,onKeyDown:N,onChange:K,value:pe="",options:G,leftIndicator:Se,rightIndicator:fe,leftIcon:me,rightIcon:ye,componentId:ve,status_id:ge,wrapStyles:be,SelectedCellStyles:Ie,SelectorCellStyles:he,SelectorMode:Ce,SelectorStyles:r,SelectorPosition:U}=g,c=H(g,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onKeyDown","onChange","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","SelectedCellStyles","SelectorCellStyles","SelectorMode","SelectorStyles","SelectorPosition"]);return e.rootStates.SelectorMode!="legacy"?null:V(C,f(n({htmlTag:"select",tabIndex:0},c),{"data-disabled":t.disabled,"data-show-validation":R.isShowValidation(p,d,!!M),"data-component-id":d.componentId,"data-input-origin":d.componentId,className:[k,B("Core")].join(" "),onKeyDown:s=>{N&&N(s),P&&R.SubmitForm(s,T)},onChange:s=>{let{value:x}=s.target;p.ok&&b({ok:!1,notice:[]}),I(F=>f(n({},F),{dataValue:x,eventType:"update",eventID:D()})),K&&K(s)},children:[!!X&&a("option",{value:"null",children:"\u9078\u629E"}),G.map(s=>u.is.nullish(s==null?void 0:s.value)?null:a("option",{value:s==null?void 0:s.value,children:s.label},String(s==null?void 0:s.value)))]}))},Selector:e=>{var o;$(()=>{let i=u(`[data-selector-id="${e.val_status.componentId}"]`)[0];if(!i)return;let m=u(`[data-select-input-value="${e.val_optionFocused}"]`)[0];m&&(i.scrollTop=m.offsetTop-24)},[e.val_optionFocused]);let t=ae.FilterSelectableOptions(e,!0),l={position:"absolute",minWidth:1,freeCSS:{zIndex:1e3}};switch(e.rootStates.SelectorPosition){case 1:l.bottom="100%",l.left=0,l.paddingBottom="1/3";break;case 2:l.bottom="100%",l.right=0,l.paddingBottom="1/3";break;case 3:l.top="100%",l.left=0,l.paddingTop="1/3";break;case 4:l.top="100%",l.right=0,l.paddingTop="1/3";break;default:break}return a(C,f(n({},l),{children:a(xe.Body,f(n({className:B("Selector"),ssCardBox:!0,borderRadius:"2.tone.secondary",boxShadow:"1.normal",overflow:"auto","data-selector-id":e.val_status.componentId},e.rootStates.SelectorStyles),{freeCSS:n({minWidth:12*6,maxHeight:12*24},(o=e.rootStates.SelectorStyles)==null?void 0:o.freeCSS),children:V(Oe,{gap:"1/12",padding:[1,0],children:[t.map((i,m)=>{if(!i)return null;let{type:p,value:b}=i,d=e.val_optionFocused==i.id,I=e.val_status.dataValue===b;return p=="label"?a(C,{children:i.label},D()):a(Te.Sub.S,f(n({"data-select-input-value":i.id,color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1],isActive:I||d,isActiveStyles:d?{backgroundColor:"cloud"}:{backgroundColor:"theme.opa.few",fontColor:"theme"}},e.rootStates.SelectorCellStyles),{onClick:v=>{e.set_status(S=>f(n({},S),{dataValue:b,eventType:"update",eventID:D()})),e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0)},children:V(j.Left,{gap:"1/2",children:[I&&a(le.Check,{fontColor:"theme"}),a(W.Supplement,{transition:"short",flexSizing:0,children:i.label})]})}),i.id)}),!t.length&&a(W.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]})}))}))},Selected:e=>{let t=[];return e.val_status.dataValue!==null&&u.scope(()=>{let l=e.rootStates.options.find(o=>u.is.equal(o==null?void 0:o.value,e.val_status.dataValue));l&&t.push(a(C,f(n({},e.rootStates.SelectedCellStyles),{children:l.label}),String(l==null?void 0:l.value)))}),a(J,{children:t})},Core:e=>{var L,T;let{value:t}=e,[l,o]=A(R.DefaultStatus(e.componentId,t)),[i,m]=A(!1),[p,b]=A(!1),[d,I]=A(((L=e.options.find(k=>k.value===e.value))==null?void 0:L.id)||((T=e.options[0])==null?void 0:T.id)||""),[v,S]=A({ok:!1,notice:[]}),E={rootStates:e,val_preventOpenSelectorOnFocus:i,set_preventOpenSelectorOnFocus:m,val_optionFocused:d,set_optionFocused:I,val_selectorOpen:p,set_selectorOpen:b,val_status:l,set_status:o,val_validate:v,set_validate:S};return R.CommonEffects({type:"select",states:e,val_status:l,set_status:o,val_validate:v,set_validate:S,SystemValidation:Ae}),V(we,{val_status:l,set_status:o,val_validate:v,states:e,children:[a(Re,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:e.isLabelActive||l.dataValue!==null}),a(_.Shallow,n({},E)),a(_.Button,n({},E))]})}},oe=e=>{var l;let t=n({},e);return t=f(n({emptySelect:!0,SelectorMode:"original",SelectorPosition:3},t),{freeCSS:n({cursor:"pointer"},t.freeCSS)}),t.emptySelect&&(t.options=[{value:null,label:a(W.Supplement,{fontColor:"4.thin",children:"\u672A\u9078\u629E"})},...t.options]),t.value=(l=t.value)!=null?l:null,t.options.forEach((o,i)=>{if(!o)return;let{type:m,value:p,searchValue:b}=o,d=b||u.is.string(p)&&p||u.Stringify(p||"")||"";t.options[i]=f(n({id:D()},o),{value:p,searchValue:d,type:m||"selector"})}),u.is.nullish(t.rightIcon)&&(t.rightIcon=a(ke,{ssSphere:2,children:a(le.AngleDown,{})})),a(Fe,{componentId:t.componentId,children:_.Core,states:De(t)})};export{oe as Select,oe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as p,c as x}from"../../../chunk-C5N2D3ZX.js";import{Fragment as $,jsx as a,jsxs as f}from"react/jsx-runtime";import{createElement as q}from"react";import D,{UUID as O,Time as S}from"jmini";import{useState as A,useEffect as F,useRef as H}from"react";import{Box as k,Flex as w,Grid as W,FAI as V,Column as T}from"../../../atoms";import{Row as N,Literal as G}from"../../../mols";import{Button as C}from"../../Button";import X from"../../Sheet";import M from"../Select";import{Radio as L}from"../List";import{RightIcon as B}from"..";import{InputTimeClasses as y}from"../../../@styles/componentClasses";let _=i=>{var t,r;let e=[],d=Number((t=i==null?void 0:i.min)!=null?t:1900),o=Number((r=i==null?void 0:i.max)!=null?r:S().addYear(10).year);for(let m=d;m<=o;m++)e.unshift({value:m,label:[m,...D.transformer.wareki(m).value].join(" -")});return e};const j=i=>{let{restrict:e,era:d="year",defaultValue:o=""}=i;i=p({},i),i.sheetID=i.sheetID||O();const t=H(!1);let[r,m]=A((()=>{var n,s;if(e=="clock"){let l=String(o).split(/[^\d]/);l[0]||(l=[0,0]);let u=Number(l[0]),c=Number(l[1]);return{modifiedType:"init",hour:u,minutes:c}}else if(e=="date"){let[l,u,c]=(n=String(o))==null?void 0:n.split(/\D/);return(D.is.nullish(l)||D.is.nullish(u)||D.is.nullish(c))&&([l,u,c]=S().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",year:Number(l),month:Number(u),date:Number(c)}}else if(e!="week"){if(e=="month"){let[l,u]=String(o).split(/\D/);return(D.is.nullish(l)||D.is.nullish(u))&&([l,u]=S().toFormat("%Y-%M").split("-")),{modifiedType:"init",year:Number(l),month:Number(u)}}else if(e=="year"){let[l]=String(o).split(/\D/);return D.is.nullish(l)&&([l]=S().toFormat("%Y").split("-")),{modifiedType:"init",year:Number(l)}}else if(e=="dateWareki"){let[l,u,c]=(s=String(o))==null?void 0:s.split(/\D/);return(D.is.nullish(l)||D.is.nullish(u)||D.is.nullish(c))&&([l,u,c]=S().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",era:d||"year",year:Number(l),month:Number(u),date:Number(c)}}}return{}})());F(()=>{if(t.current){if(r.modifiedType=="update"){let n="",s=d||"year";if(e=="clock"){let{hour:l,minutes:u}=r;n=[l.zeroEmbed(2),u.zeroEmbed(2)].join("/")}else if(e=="date"){let{year:l,month:u,date:c}=r;n=[l,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}else if(e!="week"){if(e=="month"){let{year:l,month:u}=r;n=[l,u.zeroEmbed(2)].join("/")}else if(e=="year"){let{year:l}=r;n=String(l)}else if(e=="dateWareki"){let{year:l,month:u,date:c,era:v}=r;s=v,n=[l,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}}i.onValueUpdate(n,s)}}else t.current=!0},[r]);let h=x(p({},i),{val_value:r,set_value:m});return a(k,{backgroundColor:"layer.1",borderRadius:"2.tone.secondary",boxShadow:"1.remark",children:a(k,{className:y(e.toCapital()+"Base"),children:e=="clock"?a(g.Clock.index,p({},h)):e=="date"?a(g.Date.index,p({},h)):e=="week"?"":e=="month"?a(g.Month.index,p({},h)):e=="year"?a(g.Year.index,p({},h)):e=="dates"||e=="months"?"":e=="dateWareki"?a(g.DateWareki.index,p({},h)):a($,{})})})},g={Clock:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,[h,n]=A(r.hour>12?2:1),[s,l]=A(Number(localStorage.getItem("timePickerUnit")||5));F(()=>{localStorage.setItem("timePickerUnit",String(s))},[s]);let{hour:u,minutes:c}=r;return f(T,{padding:1,children:[f(w,{flexType:"row",flexWrap:!1,gap:1,className:y("Body"),children:[f(T,{className:y("DesignSide"),flexSizing:0,children:[a(k,{className:y("ClockUiBase"),padding:[1,"2/3"],flexCenter:!0,children:f(k,{className:y("ClockUi"),backgroundColor:"theme.opa.low",isRounded:!0,position:"relative",children:[a(k,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[y("Needle"),y("hour")].join(" "),freeCSS:{transform:`rotate(${u*30+c/2}deg)`}}),a(k,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[y("Needle"),y("minute")].join(" "),freeCSS:{transform:`rotate(${c*6}deg)`}})]})}),a(L,{icon:!0,value:[h],options:[{value:1,label:"AM"},{value:2,label:"PM"}],flexType:"col",gap:"1/2",tabIndex:-1,onUpdateValidValue:v=>{let I=r.hour%12+(v==2?12:0);n(v),m({modifiedType:"update",hour:I,minutes:r.minutes})}}),a(k,{borderTop:!0,margin:[0,1]}),a(L,{icon:!0,value:[s],options:[{value:1,label:"/ 1\u5206"},{value:2,label:"/ 2\u5206"},{value:5,label:"/ 5\u5206"}],flexType:"col",gap:"1/2",tabIndex:-1,onUpdateValidValue:v=>{l(v)}})]}),f(T,{children:[f(k,{flexCenter:!0,isSemiBoldFont:!0,fontSize:"3.paragraph",children:[r.hour.zeroEmbed(2)," : ",r.minutes.zeroEmbed(2)]}),f(w,{flexWrap:!1,ssCardBox:!0,flexChilds:"even",padding:["1/3",0],freeCSS:{minWidth:12*12},children:[a(T,{gap:0,overflow:"auto",padding:"2/3",borderRight:!0,freeCSS:{maxHeight:12*22},children:g.Clock.Hours({onClick:v=>{let R=v+(h==2?12:0);m({modifiedType:"update",hour:R,minutes:r.minutes})},min:e,max:d,ampm:h})}),a(T,{gap:0,overflow:"auto",padding:"2/3",freeCSS:{maxHeight:12*22},children:g.Clock.Minutes({onClick:v=>{m({modifiedType:"update",hour:r.hour,minutes:v})},min:e,max:d,unit:s})})]})]})]}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},Hours:i=>{let e=[];for(let d=0;d<12;d++){let o=i.ampm==2?d+12:d,t=!1;{let r=Number(String(o*100).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>r&&(t=!0),i.max){let m=Number(String(i.max).replace(/\D/ig,""));r>m&&(t=!0)}}e.push(a(C.Normal,{isLocked:t,borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(d)},children:o.zeroEmbed(2)},d))}return e},Minutes:i=>{let e=[];for(let d=0;d<60/i.unit;d++){let o=d*i.unit;e.push(a(C.Normal,{borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(o)},children:o.zeroEmbed(2)},o))}return e}},Date:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h,month:n,date:s}=r;return f(T,{padding:1,children:[f(N.Separate,{flexWrap:!0,children:[f(w,{verticalAlign:"bottom",horizontalAlign:"left",gap:"2/3",flexWrap:!1,children:[a(M,{override:"force",emptySelect:!1,value:h,options:_(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,SelectorStyles:{freeCSS:{minWidth:12*12}},onUpdateValidValue:l=>{m({modifiedType:"update",year:Number(l),month:n,date:s})},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(V.AngleDown,{})})}),a(M,{override:"force",emptySelect:!1,value:n,options:(()=>{let l=[];for(let u=1;u<=12;u++)l.push({value:u,label:String(u)+"\u6708"});return l})(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,SelectorStyles:{freeCSS:{minWidth:12*8}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(V.AngleDown,{})}),onUpdateValidValue:l=>{m({modifiedType:"update",year:h,month:Number(l),date:s})}})]}),a(g.Variables.ShiftButtons,{callback:l=>{let u=n+l,c=h;u<=0&&(c--,u=12),u>12&&(c++,u=1),m({modifiedType:"update",year:c,month:u,date:r.date})}})]}),a(k,{borderTop:!0}),a(k,{children:g.Date.MonthCalendar({min:e,max:d,year:r.year,month:r.month,current:[r.year,r.month,r.date],callback:l=>{let[u,c,v]=l;m({modifiedType:"update",year:u,month:c,date:v})}})}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},MonthCalendar:i=>{let{min:e,max:d,year:o,month:t,current:r,callback:m}=i,h=S(),n=S([o,t.zeroEmbed(2),"01"].join("/")),s=n.getLastDayOfMonth(),l=S(n).addMonth(-1).getLastDayOfMonth().date,u=[],c=[],v=[],R=[],I={padding:0,unitWidth:3,unitHeight:3,flexCenter:!0,borderRadius:"3.tone.tertiary"};for(var b=0;b<7;b++)u.push(a(k,x(p({className:[y("CalendarDay"),y("Legend")].join(" ")},I),{children:["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][b]}),b));for(var b=0;b<n.weekday;b++)c.unshift(q(k,x(p({className:[y("CalendarDay"),y("Dummy")].join(" "),fontColor:"4.thin"},I),{key:b}),l-b));for(var b=1;b<=s.date;b++){let E=b,Y=o==h.year&&t==h.month&&b==h.date,P=!1;{let z=Number(String([o,t.zeroEmbed(2),b.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>z&&(P=!0),i.max){let U=Number(String(i.max).replace(/\D/ig,""));z>U&&(P=!0)}}v.push(a(C.Clear,x(p({className:[y("CalendarDay"),y("isToday_"+Y)].join(" ")},I),{fontColor:"1.clear",padding:0,flexCenter:!0,isRounded:!0,ssEffectsOnActive:"shrink",onClick:()=>{m([o,t,E])},tabIndex:-1,isLocked:P,children:b}),E))}for(var b=1;b<7-s.weekday;b++)R.push(a(k,x(p({className:[y("CalendarDay"),y("Dummy")].join(" "),fontColor:"4.thin"},I),{children:b}),b));return f(W,{gridCols:7,gap:"1/6",children:[u,c,v,R]})}},Month:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h,month:n}=r;return f(T,{padding:1,children:[f(N.Separate,{gap:0,children:[a(N.Center,{verticalAlign:"bottom",gap:"2/3",children:a(M,{emptySelect:!1,value:h,options:_(),override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,SelectorStyles:{freeCSS:{minWidth:12*12}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(V.AngleDown,{})}),onUpdateValidValue:s=>{m({modifiedType:"update",year:Number(s),month:n})}})}),a(g.Variables.ShiftButtons,{callback:s=>{let l=Math.min(Math.max(h+s,1900),2100);m({modifiedType:"update",year:l,month:n})}})]}),a(k,{borderTop:!0}),g.Month.Months({min:e,max:d,year:r.year,callback:s=>{let[l,u]=s;m({modifiedType:"update",year:l,month:u})}}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},Months:i=>{let{year:e,callback:d}=i,o=S(),t=[];for(let r=1;r<=12;r++){let m=e==o.year&&r==o.month,h=!1;{let s=Number(String([e,r.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>s&&(h=!0),i.max){let l=Number(String(i.max).replace(/\D/ig,""));s>l&&(h=!0)}}let n=[y("Cell"),m?y("isThisMonth"):""].join(" ");t.push(f(C.Clear,{className:n,isLocked:h,fontColor:"2.normal",padding:["1/3",1],ssEffectsOnActive:"shrink",onClick:()=>{d([e,r])},children:[r," \u6708"]},e+"-"+r))}return a(W,{gridCols:4,gap:"2/3",children:t})}},Year:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h}=r;return f(T,{padding:1,children:[a(M,{emptySelect:!1,paddingRight:1,fontSize:"1.mini",value:h||S().year,override:"force",SelectorStyles:{freeCSS:{minWidth:12*12}},options:_({min:e,max:d}),onUpdateValidValue:n=>{m({modifiedType:"update",year:Number(n)})}}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o,onSubmit:()=>{m({modifiedType:"update",year:Number(h||S().year)})}})]})}},DateWareki:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{era:h,year:n,month:s,date:l}=r,u={val_value:r,set_value:m};return f(k,{children:[f(N.Left,{borderBottom:!0,gap:0,verticalAlign:"unset",children:[a(g.DateWareki.EraSelect,p({},u)),a(k,{borderRight:!0}),a(g.DateWareki.Calendar,p({},u))]}),a(N.Right,{padding:1,children:a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})})]})},EraSelect:i=>{let{val_value:e,set_value:d}=i,o={padding:["1/2",1.5],fontColor:"3.blur"},t={backgroundColor:"cloud",fontColor:"2.normal",isSemiBoldFont:!0};return f(T,{padding:1,gap:0,children:[a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="year",onClick:()=>{let r=S();d({modifiedType:"update",era:"year",year:r.year,month:r.month,date:r.date})},children:"\u897F\u66A6"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="reiwa",onClick:()=>{let r=S();d({modifiedType:"update",era:"reiwa",year:r.year,month:r.month,date:r.date})},children:"\u4EE4\u548C"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="heisei",onClick:()=>{d({modifiedType:"update",era:"heisei",year:2019,month:1,date:1})},children:"\u5E73\u6210"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="shouwa",onClick:()=>{d({modifiedType:"update",era:"shouwa",year:1989,month:1,date:1})},children:"\u662D\u548C"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="taisho",onClick:()=>{d({modifiedType:"update",era:"taisho",year:1926,month:1,date:1})},children:"\u5927\u6B63"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="meiji",onClick:()=>{d({modifiedType:"update",era:"meiji",year:1912,month:1,date:1})},children:"\u660E\u6CBB"}))]})},Calendar:i=>{let{val_value:e,set_value:d}=i,o=[];if(e.era=="year"){let t=S().year+10;for(let r=1900;r<t;r++)o.unshift({value:r,label:r+"\u5E74"})}else if(e.era=="reiwa"){let t=S().year-2018;for(let r=1;r<=t+10;r++)o.unshift({value:2019+r-1,label:"\u4EE4\u548C"+(r==1?"\u5143":r)+"\u5E74"})}else if(e.era=="heisei")for(let t=1;t<=31;t++)o.unshift({value:1989+t-1,label:"\u5E73\u6210"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="shouwa")for(let t=1;t<=64;t++)o.unshift({value:1926+t-1,label:"\u662D\u548C"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="taisho")for(let t=1;t<=15;t++)o.unshift({value:1912+t-1,label:"\u5927\u6B63"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="meiji")for(let t=1;t<=45;t++)o.unshift({value:1868+t-1,label:"\u660E\u6CBB"+(t==1?"\u5143":t)+"\u5E74"});return f(T,{padding:1,children:[f(N.Separate,{children:[a(M,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,fontSize:"1.mini",SelectorStyles:{freeCSS:{minWidth:12*12}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(V.AngleDown,{})}),options:o,value:e.year,onUpdateValidValue:t=>{d(r=>x(p({},r),{modifiedType:"update",year:Number(t)}))}}),f(N.Center,{gap:"1/3",children:[a(M,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,fontSize:"1.mini",SelectorStyles:{freeCSS:{minWidth:12*9}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(V.AngleDown,{})}),options:[{value:1,label:"1\u6708"},{value:2,label:"2\u6708"},{value:3,label:"3\u6708"},{value:4,label:"4\u6708"},{value:5,label:"5\u6708"},{value:6,label:"6\u6708"},{value:7,label:"7\u6708"},{value:8,label:"8\u6708"},{value:9,label:"9\u6708"},{value:10,label:"10\u6708"},{value:11,label:"11\u6708"},{value:12,label:"12\u6708"}],value:e.month,onUpdateValidValue:t=>{d({modifiedType:"update",era:e.era,year:e.year,month:Number(t),date:1})}}),a(C.Clear.S,{ssSphere:2.5,onClick:()=>{let t=e.month-1;d({modifiedType:"update",era:e.era,year:t==0?e.year-1:e.year,month:t==0?12:t,date:1})},children:a(V.ChevronLeft,{})}),a(C.Clear.S,{ssSphere:2.5,onClick:()=>{let t=e.month+1;d({modifiedType:"update",era:e.era,year:t==13?e.year+1:e.year,month:t==13?1:t,date:1})},children:a(V.ChevronRight,{})})]})]}),a(g.DateWareki.MonthCell,p({},i))]},e.era)},MonthCell:i=>{let{val_value:e,set_value:d}=i,o=S([e.year.zeroEmbed(4),e.month.zeroEmbed(2),e.date.zeroEmbed(2)].join("/"));if(!o.validate)return;let t=o.getFirstDayOfMonth().weekday,r=o.getLastDayOfMonth(),m=[];for(let n=0;n<7;n++)m.push(a(G.Supplement,{flexCenter:!0,fontColor:n==0?"googleRed":n==6?"googleBlue":"3.blur",children:D.transformer.weekday.shortJP(n)},"legend-"+n));for(let n=0;n<t;n++){let s=S(o).getFirstDayOfMonth().addDate(n-t);m.push(a(C.Sub,{color:"cloud",ssSquare:3,opacity:"middle",onClick:l=>{l.preventDefault(),l.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"lastMonth-"+n))}let h=S();for(let n=1;n<=r.date;n++){let s=S(o).setDate(n),l=h.diff(s).dates==0;m.push(a(C.Clear,{ssSquare:3,fontColor:"2.normal",className:[y("CalendarDay"),y("isToday_"+l)].join(" "),onClick:()=>{d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"currentMonth-"+n))}for(let n=0;n<7-r.weekday-1;n++){let s=S(o).addMonth(1).setDate(1).addDate(n);m.push(a(C.Sub,{color:"cloud",ssSquare:3,opacity:"middle",onClick:l=>{l.preventDefault(),l.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"nextMonth-"+n))}return a(W,{gridCols:7,gap:"1/4",children:m})}},Variables:{Footer:i=>f(w,{flexWrap:!1,gap:1,flexChilds:"even",freeCSS:{whiteSpace:"nowrap"},children:[f(C.Sub.S,{color:"cloud",tabIndex:-1,isRounded:!0,onClick:()=>{i.onValueUpdate("")},flexSizing:"none",children:[a(V.X,{})," \u524A\u9664"]}),a(C.Prime.S,{tabIndex:-1,isRounded:!0,flexSizing:"auto",freeCSS:{minWidth:12*6},onClick:()=>{i.onSubmit&&i.onSubmit(),X.close(i.sheetID)},children:"\u6C7A\u5B9A"})]}),ShiftButtons:i=>f(w,{gap:"1/3",flexWrap:!1,children:[a(C.Clear,x(p({className:y("LeftButton"),tabIndex:-1,right:0},g.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(-1)},children:a(V.ChevronLeft,{})})),a(C.Clear,x(p({className:y("RightButton"),tabIndex:-1,left:0},g.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(1)},children:a(V.ChevronRight,{})}))]}),ShiftButtonStyles:{position:"relative",flexCenter:!0,ssSphere:2.5}}};export{j as Picker,j as default};
|
|
1
|
+
import{b as p,c as x}from"../../../chunk-C5N2D3ZX.js";import{Fragment as $,jsx as a,jsxs as f}from"react/jsx-runtime";import{createElement as q}from"react";import D,{UUID as O,Time as S}from"jmini";import{useState as A,useEffect as F,useRef as H}from"react";import{Box as k,Flex as w,Grid as W,FAI as V,Column as T}from"../../../atoms";import{Row as N,Literal as G}from"../../../mols";import{Button as C}from"../../Button";import X from"../../Sheet";import M from"../Select";import{Radio as L}from"../List";import{RightIcon as B}from"..";import{InputTimeClasses as y}from"../../../@styles/componentClasses";let _=i=>{var t,r;let e=[],d=Number((t=i==null?void 0:i.min)!=null?t:1900),o=Number((r=i==null?void 0:i.max)!=null?r:S().addYear(10).year);for(let m=d;m<=o;m++)e.unshift({value:m,label:[m,...D.transformer.wareki(m).value].join(" -")});return e};const j=i=>{let{restrict:e,era:d="year",defaultValue:o=""}=i;i=p({},i),i.sheetID=i.sheetID||O();const t=H(!1);let[r,m]=A((()=>{var n,s;if(e=="clock"){let l=String(o).split(/[^\d]/);l[0]||(l=[0,0]);let u=Number(l[0]),c=Number(l[1]);return{modifiedType:"init",hour:u,minutes:c}}else if(e=="date"){let[l,u,c]=(n=String(o))==null?void 0:n.split(/\D/);return(D.is.nullish(l)||D.is.nullish(u)||D.is.nullish(c))&&([l,u,c]=S().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",year:Number(l),month:Number(u),date:Number(c)}}else if(e!="week"){if(e=="month"){let[l,u]=String(o).split(/\D/);return(D.is.nullish(l)||D.is.nullish(u))&&([l,u]=S().toFormat("%Y-%M").split("-")),{modifiedType:"init",year:Number(l),month:Number(u)}}else if(e=="year"){let[l]=String(o).split(/\D/);return D.is.nullish(l)&&([l]=S().toFormat("%Y").split("-")),{modifiedType:"init",year:Number(l)}}else if(e=="dateWareki"){let[l,u,c]=(s=String(o))==null?void 0:s.split(/\D/);return(D.is.nullish(l)||D.is.nullish(u)||D.is.nullish(c))&&([l,u,c]=S().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",era:d||"year",year:Number(l),month:Number(u),date:Number(c)}}}return{}})());F(()=>{if(t.current){if(r.modifiedType=="update"){let n="",s=d||"year";if(e=="clock"){let{hour:l,minutes:u}=r;n=[l.zeroEmbed(2),u.zeroEmbed(2)].join("/")}else if(e=="date"){let{year:l,month:u,date:c}=r;n=[l,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}else if(e!="week"){if(e=="month"){let{year:l,month:u}=r;n=[l,u.zeroEmbed(2)].join("/")}else if(e=="year"){let{year:l}=r;n=String(l)}else if(e=="dateWareki"){let{year:l,month:u,date:c,era:v}=r;s=v,n=[l,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}}i.onValueUpdate(n,s)}}else t.current=!0},[r]);let h=x(p({},i),{val_value:r,set_value:m});return a(k,{backgroundColor:"layer.1",borderRadius:"2.tone.secondary",boxShadow:"1.remark",children:a(k,{className:y(e.toCapital()+"Base"),children:e=="clock"?a(g.Clock.index,p({},h)):e=="date"?a(g.Date.index,p({},h)):e=="week"?"":e=="month"?a(g.Month.index,p({},h)):e=="year"?a(g.Year.index,p({},h)):e=="dates"||e=="months"?"":e=="dateWareki"?a(g.DateWareki.index,p({},h)):a($,{})})})},g={Clock:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,[h,n]=A(r.hour>12?2:1),[s,l]=A(Number(localStorage.getItem("timePickerUnit")||5));F(()=>{localStorage.setItem("timePickerUnit",String(s))},[s]);let{hour:u,minutes:c}=r;return f(T,{padding:1,children:[f(w,{flexType:"row",flexWrap:!1,gap:1,className:y("Body"),children:[f(T,{className:y("DesignSide"),flexSizing:0,children:[a(k,{className:y("ClockUiBase"),padding:[1,"2/3"],flexCenter:!0,children:f(k,{className:y("ClockUi"),backgroundColor:"theme.opa.low",isRounded:!0,position:"relative",children:[a(k,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[y("Needle"),y("hour")].join(" "),freeCSS:{transform:`rotate(${u*30+c/2}deg)`}}),a(k,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[y("Needle"),y("minute")].join(" "),freeCSS:{transform:`rotate(${c*6}deg)`}})]})}),a(L,{icon:!0,value:[h],options:[{value:1,label:"AM"},{value:2,label:"PM"}],flexType:"col",gap:"1/2",tabIndex:-1,onUpdateValidValue:v=>{let I=r.hour%12+(v==2?12:0);n(v),m({modifiedType:"update",hour:I,minutes:r.minutes})}}),a(k,{borderTop:!0,margin:[0,1]}),a(L,{icon:!0,value:[s],options:[{value:1,label:"/ 1\u5206"},{value:2,label:"/ 2\u5206"},{value:5,label:"/ 5\u5206"}],flexType:"col",gap:"1/2",tabIndex:-1,onUpdateValidValue:v=>{l(v)}})]}),f(T,{children:[f(k,{flexCenter:!0,isSemiBoldFont:!0,fontSize:"3.paragraph",children:[r.hour.zeroEmbed(2)," : ",r.minutes.zeroEmbed(2)]}),f(w,{flexWrap:!1,ssCardBox:!0,flexChilds:"even",padding:["1/3",0],freeCSS:{minWidth:12*12},children:[a(T,{gap:0,overflow:"auto",padding:"2/3",borderRight:!0,freeCSS:{maxHeight:12*22},children:g.Clock.Hours({onClick:v=>{let R=v+(h==2?12:0);m({modifiedType:"update",hour:R,minutes:r.minutes})},min:e,max:d,ampm:h})}),a(T,{gap:0,overflow:"auto",padding:"2/3",freeCSS:{maxHeight:12*22},children:g.Clock.Minutes({onClick:v=>{m({modifiedType:"update",hour:r.hour,minutes:v})},min:e,max:d,unit:s})})]})]})]}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},Hours:i=>{let e=[];for(let d=0;d<12;d++){let o=i.ampm==2?d+12:d,t=!1;{let r=Number(String(o*100).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>r&&(t=!0),i.max){let m=Number(String(i.max).replace(/\D/ig,""));r>m&&(t=!0)}}e.push(a(C.Normal,{isLocked:t,borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(d)},children:o.zeroEmbed(2)},d))}return e},Minutes:i=>{let e=[];for(let d=0;d<60/i.unit;d++){let o=d*i.unit;e.push(a(C.Normal,{borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(o)},children:o.zeroEmbed(2)},o))}return e}},Date:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h,month:n,date:s}=r;return f(T,{padding:1,children:[f(N.Separate,{flexWrap:!0,children:[f(w,{verticalAlign:"bottom",horizontalAlign:"left",gap:"2/3",flexWrap:!1,children:[a(M,{override:"force",emptySelect:!1,value:h,options:_(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:1.5,SelectorStyles:{freeCSS:{minWidth:12*12}},onUpdateValidValue:l=>{m({modifiedType:"update",year:Number(l),month:n,date:s})},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(V.AngleDown,{})})}),a(M,{override:"force",emptySelect:!1,value:n,options:(()=>{let l=[];for(let u=1;u<=12;u++)l.push({value:u,label:String(u)+"\u6708"});return l})(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:1.5,SelectorStyles:{freeCSS:{minWidth:12*8}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(V.AngleDown,{})}),onUpdateValidValue:l=>{m({modifiedType:"update",year:h,month:Number(l),date:s})}})]}),a(g.Variables.ShiftButtons,{callback:l=>{let u=n+l,c=h;u<=0&&(c--,u=12),u>12&&(c++,u=1),m({modifiedType:"update",year:c,month:u,date:r.date})}})]}),a(k,{borderTop:!0}),a(k,{children:g.Date.MonthCalendar({min:e,max:d,year:r.year,month:r.month,current:[r.year,r.month,r.date],callback:l=>{let[u,c,v]=l;m({modifiedType:"update",year:u,month:c,date:v})}})}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},MonthCalendar:i=>{let{min:e,max:d,year:o,month:t,current:r,callback:m}=i,h=S(),n=S([o,t.zeroEmbed(2),"01"].join("/")),s=n.getLastDayOfMonth(),l=S(n).addMonth(-1).getLastDayOfMonth().date,u=[],c=[],v=[],R=[],I={padding:0,unitWidth:3,unitHeight:3,flexCenter:!0,borderRadius:"3.tone.tertiary"};for(var b=0;b<7;b++)u.push(a(k,x(p({className:[y("CalendarDay"),y("Legend")].join(" ")},I),{children:["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][b]}),b));for(var b=0;b<n.weekday;b++)c.unshift(q(k,x(p({className:[y("CalendarDay"),y("Dummy")].join(" "),fontColor:"4.thin"},I),{key:b}),l-b));for(var b=1;b<=s.date;b++){let E=b,Y=o==h.year&&t==h.month&&b==h.date,P=!1;{let z=Number(String([o,t.zeroEmbed(2),b.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>z&&(P=!0),i.max){let U=Number(String(i.max).replace(/\D/ig,""));z>U&&(P=!0)}}v.push(a(C.Clear,x(p({className:[y("CalendarDay"),y("isToday_"+Y)].join(" ")},I),{fontColor:"1.clear",padding:0,flexCenter:!0,isRounded:!0,ssEffectsOnActive:"shrink",onClick:()=>{m([o,t,E])},tabIndex:-1,isLocked:P,children:b}),E))}for(var b=1;b<7-s.weekday;b++)R.push(a(k,x(p({className:[y("CalendarDay"),y("Dummy")].join(" "),fontColor:"4.thin"},I),{children:b}),b));return f(W,{gridCols:7,gap:"1/6",children:[u,c,v,R]})}},Month:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h,month:n}=r;return f(T,{padding:1,children:[f(N.Separate,{gap:0,children:[a(N.Center,{verticalAlign:"bottom",gap:"2/3",children:a(M,{emptySelect:!1,value:h,options:_(),override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1.5,SelectorStyles:{freeCSS:{minWidth:12*12}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(V.AngleDown,{})}),onUpdateValidValue:s=>{m({modifiedType:"update",year:Number(s),month:n})}})}),a(g.Variables.ShiftButtons,{callback:s=>{let l=Math.min(Math.max(h+s,1900),2100);m({modifiedType:"update",year:l,month:n})}})]}),a(k,{borderTop:!0}),g.Month.Months({min:e,max:d,year:r.year,callback:s=>{let[l,u]=s;m({modifiedType:"update",year:l,month:u})}}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},Months:i=>{let{year:e,callback:d}=i,o=S(),t=[];for(let r=1;r<=12;r++){let m=e==o.year&&r==o.month,h=!1;{let s=Number(String([e,r.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>s&&(h=!0),i.max){let l=Number(String(i.max).replace(/\D/ig,""));s>l&&(h=!0)}}let n=[y("Cell"),m?y("isThisMonth"):""].join(" ");t.push(f(C.Clear,{className:n,isLocked:h,fontColor:"2.normal",padding:["1/3",1],ssEffectsOnActive:"shrink",onClick:()=>{d([e,r])},children:[r," \u6708"]},e+"-"+r))}return a(W,{gridCols:4,gap:"2/3",children:t})}},Year:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h}=r;return f(T,{padding:1,children:[a(M,{emptySelect:!1,paddingRight:1.5,fontSize:"1.mini",value:h||S().year,override:"force",SelectorStyles:{freeCSS:{minWidth:12*12}},options:_({min:e,max:d}),onUpdateValidValue:n=>{m({modifiedType:"update",year:Number(n)})}}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o,onSubmit:()=>{m({modifiedType:"update",year:Number(h||S().year)})}})]})}},DateWareki:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{era:h,year:n,month:s,date:l}=r,u={val_value:r,set_value:m};return f(k,{children:[f(N.Left,{borderBottom:!0,gap:0,verticalAlign:"unset",children:[a(g.DateWareki.EraSelect,p({},u)),a(k,{borderRight:!0}),a(g.DateWareki.Calendar,p({},u))]}),a(N.Right,{padding:1,children:a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})})]})},EraSelect:i=>{let{val_value:e,set_value:d}=i,o={padding:["1/2",1.5],fontColor:"3.blur"},t={backgroundColor:"cloud",fontColor:"2.normal",isSemiBoldFont:!0};return f(T,{padding:1,gap:0,children:[a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="year",onClick:()=>{let r=S();d({modifiedType:"update",era:"year",year:r.year,month:r.month,date:r.date})},children:"\u897F\u66A6"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="reiwa",onClick:()=>{let r=S();d({modifiedType:"update",era:"reiwa",year:r.year,month:r.month,date:r.date})},children:"\u4EE4\u548C"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="heisei",onClick:()=>{d({modifiedType:"update",era:"heisei",year:2019,month:1,date:1})},children:"\u5E73\u6210"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="shouwa",onClick:()=>{d({modifiedType:"update",era:"shouwa",year:1989,month:1,date:1})},children:"\u662D\u548C"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="taisho",onClick:()=>{d({modifiedType:"update",era:"taisho",year:1926,month:1,date:1})},children:"\u5927\u6B63"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="meiji",onClick:()=>{d({modifiedType:"update",era:"meiji",year:1912,month:1,date:1})},children:"\u660E\u6CBB"}))]})},Calendar:i=>{let{val_value:e,set_value:d}=i,o=[];if(e.era=="year"){let t=S().year+10;for(let r=1900;r<t;r++)o.unshift({value:r,label:r+"\u5E74"})}else if(e.era=="reiwa"){let t=S().year-2018;for(let r=1;r<=t+10;r++)o.unshift({value:2019+r-1,label:"\u4EE4\u548C"+(r==1?"\u5143":r)+"\u5E74"})}else if(e.era=="heisei")for(let t=1;t<=31;t++)o.unshift({value:1989+t-1,label:"\u5E73\u6210"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="shouwa")for(let t=1;t<=64;t++)o.unshift({value:1926+t-1,label:"\u662D\u548C"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="taisho")for(let t=1;t<=15;t++)o.unshift({value:1912+t-1,label:"\u5927\u6B63"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="meiji")for(let t=1;t<=45;t++)o.unshift({value:1868+t-1,label:"\u660E\u6CBB"+(t==1?"\u5143":t)+"\u5E74"});return f(T,{padding:1,children:[f(N.Separate,{children:[a(M,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1.5,fontSize:"1.mini",SelectorStyles:{freeCSS:{minWidth:12*12}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(V.AngleDown,{})}),options:o,value:e.year,onUpdateValidValue:t=>{d(r=>x(p({},r),{modifiedType:"update",year:Number(t)}))}}),f(N.Center,{gap:"1/3",children:[a(M,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1.5,fontSize:"1.mini",SelectorStyles:{freeCSS:{minWidth:12*9}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(V.AngleDown,{})}),options:[{value:1,label:"1\u6708"},{value:2,label:"2\u6708"},{value:3,label:"3\u6708"},{value:4,label:"4\u6708"},{value:5,label:"5\u6708"},{value:6,label:"6\u6708"},{value:7,label:"7\u6708"},{value:8,label:"8\u6708"},{value:9,label:"9\u6708"},{value:10,label:"10\u6708"},{value:11,label:"11\u6708"},{value:12,label:"12\u6708"}],value:e.month,onUpdateValidValue:t=>{d({modifiedType:"update",era:e.era,year:e.year,month:Number(t),date:1})}}),a(C.Clear.S,{ssSphere:2.5,onClick:()=>{let t=e.month-1;d({modifiedType:"update",era:e.era,year:t==0?e.year-1:e.year,month:t==0?12:t,date:1})},children:a(V.ChevronLeft,{})}),a(C.Clear.S,{ssSphere:2.5,onClick:()=>{let t=e.month+1;d({modifiedType:"update",era:e.era,year:t==13?e.year+1:e.year,month:t==13?1:t,date:1})},children:a(V.ChevronRight,{})})]})]}),a(g.DateWareki.MonthCell,p({},i))]},e.era)},MonthCell:i=>{let{val_value:e,set_value:d}=i,o=S([e.year.zeroEmbed(4),e.month.zeroEmbed(2),e.date.zeroEmbed(2)].join("/"));if(!o.validate)return;let t=o.getFirstDayOfMonth().weekday,r=o.getLastDayOfMonth(),m=[];for(let n=0;n<7;n++)m.push(a(G.Supplement,{flexCenter:!0,fontColor:n==0?"googleRed":n==6?"googleBlue":"3.blur",children:D.transformer.weekday.shortJP(n)},"legend-"+n));for(let n=0;n<t;n++){let s=S(o).getFirstDayOfMonth().addDate(n-t);m.push(a(C.Sub,{color:"cloud",ssSquare:3,opacity:"middle",onClick:l=>{l.preventDefault(),l.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"lastMonth-"+n))}let h=S();for(let n=1;n<=r.date;n++){let s=S(o).setDate(n),l=h.diff(s).dates==0;m.push(a(C.Clear,{ssSquare:3,fontColor:"2.normal",className:[y("CalendarDay"),y("isToday_"+l)].join(" "),onClick:()=>{d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"currentMonth-"+n))}for(let n=0;n<7-r.weekday-1;n++){let s=S(o).addMonth(1).setDate(1).addDate(n);m.push(a(C.Sub,{color:"cloud",ssSquare:3,opacity:"middle",onClick:l=>{l.preventDefault(),l.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"nextMonth-"+n))}return a(W,{gridCols:7,gap:"1/4",children:m})}},Variables:{Footer:i=>f(w,{flexWrap:!1,gap:1,flexChilds:"even",freeCSS:{whiteSpace:"nowrap"},children:[f(C.Sub.S,{color:"cloud",tabIndex:-1,isRounded:!0,onClick:()=>{i.onValueUpdate("")},flexSizing:"none",children:[a(V.X,{})," \u524A\u9664"]}),a(C.Prime.S,{tabIndex:-1,isRounded:!0,flexSizing:"auto",freeCSS:{minWidth:12*6},onClick:()=>{i.onSubmit&&i.onSubmit(),X.close(i.sheetID)},children:"\u6C7A\u5B9A"})]}),ShiftButtons:i=>f(w,{gap:"1/3",flexWrap:!1,children:[a(C.Clear,x(p({className:y("LeftButton"),tabIndex:-1,right:0},g.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(-1)},children:a(V.ChevronLeft,{})})),a(C.Clear,x(p({className:y("RightButton"),tabIndex:-1,left:0},g.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(1)},children:a(V.ChevronRight,{})}))]}),ShiftButtonStyles:{position:"relative",flexCenter:!0,ssSphere:2.5}}};export{j as Picker,j as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amotify",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.189",
|
|
4
4
|
"description": "UI Component for React,NextJS,esbuild",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "run-p clean build:*",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@fortawesome/free-solid-svg-icons": "^6.7.2",
|
|
91
91
|
"@fortawesome/react-fontawesome": "^0.2.2",
|
|
92
92
|
"dotenv": "^17.0.1",
|
|
93
|
-
"jmini": "^0.0.
|
|
93
|
+
"jmini": "^0.0.89",
|
|
94
94
|
"react": "^18.3.1"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|