amotify 0.2.197 → 0.2.198

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.
@@ -1354,7 +1354,7 @@ text5`}
1354
1354
  freeCSS={ {
1355
1355
  minHeight: 12 * 6
1356
1356
  } }
1357
- onUpdateValidValue={ ( args ) => {
1357
+ onUpdateValidValue={ args => {
1358
1358
  console.log( args )
1359
1359
  } }
1360
1360
  />
@@ -2784,41 +2784,25 @@ let DesignBook = () => {
2784
2784
  // />
2785
2785
  // </Column>
2786
2786
 
2787
- let array = [
2788
- '西暦',
2789
- '和暦',
2790
- '中華民国',
2791
- 'イスラム暦',
2792
- ]
2793
-
2794
- let [ val_value,set_value ] = useState( "" )
2795
-
2796
2787
  return <Plate
2797
2788
  padding={ 3 }
2798
2789
  size="XS"
2799
2790
  >
2800
2791
  <Column>
2801
- <Box
2802
- fontColor='posi'
2803
- isSemiBoldFont
2804
- >
2805
- Positive
2806
- </Box>
2807
- <Box
2808
- backgroundColor='posi'
2809
- unitHeight={ '1/2' }
2810
- isRounded
2811
- />
2812
- <Box
2813
- fontColor='nega'
2814
- isSemiBoldFont
2815
- >
2816
- Negative
2817
- </Box>
2818
- <Box
2819
- backgroundColor='nega'
2820
- unitHeight={ '1/2' }
2821
- isRounded
2792
+ <Input.TextField
2793
+ multiline
2794
+ // value={ 'AAAA' }
2795
+ // options={ [
2796
+ // { value: "AAAA",label: "AAAA" },
2797
+ // { value: "BBBB",label: "BBBB" },
2798
+ // { value: "CCCC",label: "CCCC" }
2799
+ // ] }
2800
+ onUpdateValidValue={ ( ...args ) => {
2801
+ // console.log( args )
2802
+ } }
2803
+ onUserAction={ ( value,opt ) => {
2804
+ console.log( value,opt )
2805
+ } }
2822
2806
  />
2823
2807
  </Column>
2824
2808
  </Plate>
@@ -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 A}from"react/jsx-runtime";import{useState as I,useEffect as R,useRef as re}from"react";import u,{UUID as L}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 K,Row as W}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 z,DefaultBoxishStyles as Se}from"./core";import{InputAutocompleteClasses as N}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 U={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:L()},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}},B={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(K.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:H,multiSelect:j,enableFormSubmit:P,checkValidationAtFirst:M,onValidate:X,onValidateDelay:F,onUpdateValue:E,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=U.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("."+N("Core")).length,ne=!!u(Q).parent("."+N("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":z.isShowValidation(g,v,!!M),"data-component-id":v.componentId,"data-input-origin":v.componentId,"data-focus":!!a,className:[H,N("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;P&&z.SubmitForm(y,V),!a&&(T==" "||T=="ArrowDown"||T=="ArrowUp"||T=="Enter")&&f(!0)},children:A(W.Left,{gap:0,children:[l(se,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),A(W.Left,{flexWrap:!0,flexSizing:0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(B.Selected,S({},e)),l(B.SearchInput,S({},e))]})]})})),a&&l(B.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:L()}))}):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:L()})}),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=U.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&&z.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=U.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=U.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:L()})})}})},i.id))}),m.length||(r=[l(K.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(W.Left,{padding:1,fontColor:"3.blur",children:[l(ce.Theme.R,{showInitial:!0}),l(K.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:N("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:N("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:L()}))}})},u.Stringify(o==null?void 0:o.value)||L()))}),l(J,{children:r})},Core:e=>{var M,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(((M=e.options.find(F=>{var E;return(F==null?void 0:F.value)===((E=e.value)==null?void 0:E[0])}))==null?void 0:M.id)||((X=e.options[0])==null?void 0:X.id)||""),[v,C]=I({}),[g,_]=I(z.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 F=[...s],E=S({},v);F.forEach(k=>{(k==null?void 0:k.type)!="label"&&(E[u.Stringify(k==null?void 0:k.value)]=k)}),C(E)},[s]);let H={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;z.CommonEffects({type:j?"autocomplete.multi":"autocomplete.single",states:e,val_status:g,set_status:_,val_validate:D,set_validate:w,SystemValidation:fe});let P=g.dataValue.length&&g.dataValue[0]!==null;return P=P||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:P}),l(B.Shallow,S({},H)),l(B.Button,S({},H))]})}},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(W.Left,{gap:"1/2",children:[p&&l(q.Check,{fontColor:"theme"}),l(K.Supplement,{transition:"short",children:c.label})]})}):null,SelectedComponent:({value:c,label:p,removeCallback:n})=>A(W.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(K.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=u.flatArray(t.value),t.options=U.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:B.Core,states:Se(t)})};export{ae as Autocomplete,ae as default};
1
+ import{b as d,c as _,d as Y,e as Z}from"../../chunk-C5N2D3ZX.js";import{Fragment as J,jsx as a,jsxs as F}from"react/jsx-runtime";import{useState as D,useEffect as x,useRef as ie}from"react";import p,{UUID as w}from"jmini";import{ExtractStyles as re}from"../../@utils";import{Box as A,Span as se,FAI as q,Column as ee}from"../../atoms";import{Literal as K,Row as W}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 z,DefaultBoxishStyles as Se}from"./core";import{InputAutocompleteClasses as N}from"../../@styles/componentClasses";import{InputLabel as me}from"./Label";import{RightIcon as oe}from".";function fe(e){let{value:t,states:u}=e,{required:S,options:l,min:i,max:f}=u;i=i||0,f=f||65535;let o=[],b=t.filter(r=>r!==null).length;return S&&(b||o.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),b<i&&o.push({type:"invalid",label:i+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),b>f&&o.push({type:"invalid",label:f+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!o.filter(({type:r})=>r=="invalid").length,notice:o}}const U={InitOptions:e=>{let t=[];return e.forEach(u=>{if(!u)return;let{type:S,label:l,value:i,searchValue:f}=u,o=f||p.is.string(l)&&l||""||p.is.string(i)&&i||p.Stringify(i||"")||"";p.is.nullish(l)&&(l=String(i)),t.push(_(d({id:w()},u),{searchValue:o,type:S||"selector",label:l,value:i}))}),t},FilterSelectableOptions:(e,t,u)=>{let S=e;return u||(S=e.filter(l=>(l==null?void 0:l.type)!="label")),p.scope(()=>{if(!t)return;let l=t.toLower().replace(/ /g,"");S=S.filter(i=>(i.searchValue||"").toLower().replace(/ /g,"").includes(l))}),S}},L={Shallow:e=>{let{rootStates:t,val_status:u}=e,S=re(t);return a(A,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:a(K.Description,_(d({className:t.className},S),{position:"absolute",width:1,freeCSS:_(d({},S.freeCSS),{color:"orange"}),"data-id":"shallow_"+u.componentId,children:a(A,{"data-input-value-shallow":u.componentId,children:"A"})}))})},Button:e=>{let{rootStates:t,val_keyword:u,set_keyword:S,val_optionFocused:l,set_optionFocused:i,val_options:f,set_options:o,val_optionsDict:b,set_optionsDict:r,val_preventOpenSelectorOnFocus:s,set_preventOpenSelectorOnFocus:m,val_selectorOpen:n,set_selectorOpen:v,val_status:g,set_status:C,val_validate:O,set_validate:I}=e,G=t,{tone:T,required:V,form:k,className:H,multiSelect:j,enableFormSubmit:P,checkValidationAtFirst:M,onValidate:X,onValidateDelay:E,onUpdateValue:B,onUpdateValidValue:R,onUserAction:ve,value:ye="",options:ge,leftIndicator:he,rightIndicator:_e,leftIcon:be,rightIcon:Oe,componentId:Ie,status_id:Ce,wrapStyles:De,emptySelect:we,SearchInput:Te,SearchInputPlaceholder:Ve,SelectedComponent:ke,SelectorComponent:Re,SelectorStyles:xe,SelectorPosition:Ae,DynamicOptionsOnSearch:Fe,DynamicOptionsOnSearchDelay:Ee}=G,c=Y(G,["tone","required","form","className","multiSelect","enableFormSubmit","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","emptySelect","SearchInput","SearchInputPlaceholder","SelectedComponent","SelectorComponent","SelectorStyles","SelectorPosition","DynamicOptionsOnSearch","DynamicOptionsOnSearchDelay"]);return x(()=>{var h;if(t.disabled||!n)return;let y=U.FilterSelectableOptions(e.val_options,u,!1);i(((h=y[0])==null?void 0:h.id)||"")},[u]),x(()=>{g.eventType!="init"&&(t.max==g.dataValue.length?(v(!1),m(!0),setTimeout(()=>{let y=p('[data-input-origin="'+t.componentId+'"]');y&&y.focus()},10)):p("#SearchInput_"+t.componentId).focus())},[g.dataValue]),x(()=>{let y="autocomplete-click-"+t.componentId;if(n){if(!p('[data-input-origin="'+t.componentId+'"]'))return;p("#SearchInput_"+t.componentId).focus(),p(document).addEvent({eventID:y,eventType:"mousedown",callback:$=>{let Q=p($.target),ae=!!p(Q).parent("."+N("Core")).length,le=!!p(Q).parent("."+N("Selector")).length;ae||le||(v(!1),$.preventDefault(),$.stopPropagation())},options:{passive:!1}})}else p(document).removeEvent([y]),S("")},[n]),F(J,{children:[a(A,_(d({tabIndex:0},c),{"data-disabled":t.disabled,"data-show-validation":z.isShowValidation(O,g,!!M),"data-component-id":g.componentId,"data-input-origin":g.componentId,"data-focus":!!n,className:[H,N("Core")].join(" "),onFocus:y=>{if(c!=null&&c.onFocus&&(c==null||c.onFocus(y)),C(h=>_(d({},h),{eventID:w(),eventType:"focus.start",isFocusing:!0})),!t.disabled){if(s)return m(!1);v(!0),y.preventDefault()}},onBlur:y=>{c!=null&&c.onBlur&&(c==null||c.onBlur(y)),C(h=>_(d({},h),{eventID:w(),eventType:"focus.end",isFocusing:!1}))},onCompositionStart:y=>{c!=null&&c.onCompositionStart&&(c==null||c.onCompositionStart(y)),C(h=>_(d({},h),{eventID:w(),eventType:"composing.start",isComposing:!0}))},onCompositionEnd:y=>{c!=null&&c.onCompositionEnd&&(c==null||c.onCompositionEnd(y)),C(h=>_(d({},h),{eventID:w(),eventType:"composing.end",isComposing:!1}))},onClick:y=>{c!=null&&c.onClick&&(c==null||c.onClick(y)),!t.disabled&&v(!0)},onKeyDown:y=>{let{key:h}=y;P&&z.SubmitForm(y,k),!n&&(h==" "||h=="ArrowDown"||h=="ArrowUp"||h=="Enter")&&v(!0)},children:F(W.Left,{gap:0,children:[a(se,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),F(W.Left,{flexWrap:!0,flexSizing:0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[a(L.Selected,d({},e)),a(L.SearchInput,d({},e))]})]})})),n&&a(L.Selector,d({},e))]})},SearchInput:e=>{let{rootStates:t}=e,[u,S]=D(!1);return t.disabled||!e.val_selectorOpen?null:a(A,{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:l=>{t.onCompositionStart&&t.onCompositionStart(l),S(!0)},onCompositionEnd:l=>{t.onCompositionEnd&&t.onCompositionEnd(l),S(!1)},onKeyDown:l=>{let{key:i,metaKey:f,ctrlKey:o}=l,b=f||o;i=="Escape"?(e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0),setTimeout(()=>{let r=p('[data-input-origin="'+t.componentId+'"]');r&&r.focus()},10)):i=="Tab"?e.set_selectorOpen(!1):i==" "?p.scope(()=>{e.val_selectorOpen||e.val_keyword||(l.preventDefault(),e.set_selectorOpen(!0))}):i=="Backspace"?p.scope(()=>{if(e.val_keyword)return;let r=[...e.val_status.dataValue];r.pop(),e.set_status(s=>_(d({},s),{dataValue:r,eventType:"update",eventID:w()}))}):i=="Enter"&&p.scope(()=>{if(u)return;if(!e.val_selectorOpen)return e.set_selectorOpen(!0);let r=e.val_options.find(m=>(m==null?void 0:m.id)==e.val_optionFocused);if(!r)return;let{value:s}=r;e.set_status(m=>{let n=[...m.dataValue];return p.scope(()=>{if(s===null)return n=[];m.dataValue.includes(s)?n=n.filter(g=>g!==s):t.multiSelect?n.push(s):n=[s]}),_(d({},m),{dataValue:n,eventType:"update",eventID:w()})}),e.set_keyword(""),e.set_preventDynamicSearchOnKeywordChange(!0)}),p.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(i))return;if(l.preventDefault(),!e.val_selectorOpen)return e.set_selectorOpen(!0);let r=i=="ArrowDown"?1:-1,s=U.FilterSelectableOptions(e.val_options),m=s.length-1,n=null;p.scope(()=>{var g,C,O,I,T,V;let v=s.findIndex(k=>(k==null?void 0:k.id)==e.val_optionFocused);if(v==-1&&(v=0),r==1){if(n=(g=s[0])==null?void 0:g.id,b){n=(C=s[m])==null?void 0:C.id;return}if(v==-1||v==m)return;n=(O=s[v+1])==null?void 0:O.id}else{if(n=(I=s[m])==null?void 0:I.id,b){n=(T=s[0])==null?void 0:T.id;return}if(v==-1||v==0)return;n=(V=s[v-1])==null?void 0:V.id}}),e.set_optionFocused(n)}),t.enableFormSubmit&&z.SubmitForm(l,e.rootStates.form)},onChange:l=>{let f=l.target.value;e.set_keyword(f)}},"searchInput")},Selector:e=>{var b;let[t,u]=D("idle"),[S,l]=D("idle");x(()=>{if(!e.val_selectorOpen||!e.rootStates.DynamicOptionsOnSearch)return;if(e.val_preventDynamicSearchOnKeywordChange)return e.set_preventDynamicSearchOnKeywordChange(!1);if(t=="idle")return u("ok");l("fetch");let r="autocomplete-search-"+e.rootStates.componentId;p.interval.once(()=>Z(void 0,null,function*(){var n;let s=yield e.rootStates.DynamicOptionsOnSearch(e.val_keyword);l("idle");let m=U.InitOptions(s||[]);e.set_options(m),e.set_optionFocused(((n=m[0])==null?void 0:n.id)||"")}),e.rootStates.DynamicOptionsOnSearchDelay||300,r)},[e.val_keyword]),x(()=>{let r=p(`[data-selector-id="${e.val_status.componentId}"]`)[0];if(!r)return;let s=p(`[data-autocomplete-input-value="${e.val_optionFocused}"]`)[0];s&&(r.scrollTop=s.offsetTop-24)},[e.val_optionFocused]);let i=[],f=U.FilterSelectableOptions(e.val_options,e.rootStates.DynamicOptionsOnSearch?"":e.val_keyword,!0);f.forEach((r,s)=>{if(!r)return;let{type:m,value:n}=r,v=e.val_optionFocused==r.id,g=e.val_status.dataValue.includes(n),C=e.rootStates.SelectorComponent;i.push(a(ee,{"data-autocomplete-input-value":r.id,children:a(C,{option:r,isFocused:v,isSelected:g,addCallback:()=>{e.set_status(O=>{let I=[...O.dataValue];return p.scope(()=>{if(n===null)return I=[];O.dataValue.includes(n)?I=I.filter(V=>V!==n):e.rootStates.multiSelect?I.push(n):I=[n]}),_(d({},O),{dataValue:I,eventType:"update",eventID:w()})})}})},r.id))}),f.length||(i=[a(K.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]),S=="fetch"&&(i=[F(W.Left,{padding:1,fontColor:"3.blur",children:[a(ce.Theme.R,{showInitial:!0}),a(K.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 a(A,_(d({},o),{children:a(ue.Body,_(d({className:N("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,boxShadow:"1.normal",overflow:"auto","data-selector-id":e.val_status.componentId},e.rootStates.SelectorStyles),{freeCSS:d({maxHeight:12*24},(b=e.rootStates.SelectorStyles)==null?void 0:b.freeCSS),children:a(ee,{gap:"1/12",padding:[1,0],children:i})}))}))},Selected:e=>{let{rootStates:t,val_status:u,set_status:S,val_optionsDict:l}=e,i=[];return u.dataValue.forEach(f=>{let o=l[p.Stringify(f)];if(!o)return;let b=t.SelectedComponent,r=o.label;(o==null?void 0:o.value)===null&&(r=""),i.push(a(A,{className:N("SelectedCell"),children:a(b,{value:o==null?void 0:o.value,label:r,removeCallback:s=>{if(s.stopPropagation(),s.preventDefault(),t.disabled)return;let m=[...u.dataValue];m=m.filter(n=>n!==f),S(n=>_(d({},n),{dataValue:m,eventType:"update",eventID:w()}))}})},p.Stringify(o==null?void 0:o.value)||w()))}),a(J,{children:i})},Core:e=>{var M,X;let{value:t}=e,[u,S]=D(!1),[l,i]=D(!1),[f,o]=D(!1),[b,r]=D(""),[s,m]=D(e.options),[n,v]=D(((M=e.options.find(E=>{var B;return(E==null?void 0:E.value)===((B=e.value)==null?void 0:B[0])}))==null?void 0:M.id)||((X=e.options[0])==null?void 0:X.id)||""),[g,C]=D({}),[O,I]=D(z.DefaultStatus(e.componentId,t)),[T,V]=D({ok:!1,notice:[]}),k=ie(!1);x(()=>{k.current?m(e.options):k.current=!0},[e.options]),x(()=>{if(!s.length)return;let E=[...s],B=d({},g);E.forEach(R=>{(R==null?void 0:R.type)!="label"&&(B[p.Stringify(R==null?void 0:R.value)]=R)}),C(B)},[s]);let H={rootStates:e,val_options:s,set_options:m,val_optionFocused:n,set_optionFocused:v,val_optionsDict:g,set_optionsDict:C,val_preventDynamicSearchOnKeywordChange:l,set_preventDynamicSearchOnKeywordChange:i,val_preventOpenSelectorOnFocus:u,set_preventOpenSelectorOnFocus:S,val_selectorOpen:f,set_selectorOpen:o,val_keyword:b,set_keyword:r,val_status:O,set_status:I,val_validate:T,set_validate:V},j=!!e.multiSelect;z.CommonEffects({type:j?"autocomplete.multi":"autocomplete.single",states:e,val_status:O,set_status:I,val_validate:T,set_validate:V,SystemValidation:fe});let P=O.dataValue.length&&O.dataValue[0]!==null;return P=P||f,F(de,{val_status:O,set_status:I,val_validate:T,states:e,children:[a(me,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:P}),a(L.Shallow,d({},H)),a(L.Button,d({},H))]})}},ne=e=>{let t=d({},e);return t=_(d({value:[],min:0,max:65535,multiSelect:!0,SearchInput:!0,emptySelect:!0,SelectorComponent:({option:u,isSelected:S,isFocused:l,addCallback:i})=>u?(u==null?void 0:u.type)=="label"?a(J,{children:u.label}):a(te.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1.5],isActive:l,isActiveStyles:{backgroundColor:"cloud"},onClick:f=>{i()},children:F(W.Left,{gap:"1/2",children:[S&&a(q.Check,{fontColor:"theme"}),a(K.Supplement,{transition:"short",children:u.label})]})}):null,SelectedComponent:({value:u,label:S,removeCallback:l})=>F(W.Left,{ssCardBox:"cloud",borderRadius:"2.tone.secondary",fontSize:"1.mini",padding:"1/2",gap:0,children:[a(A,{padding:[0,"1/4"],children:S}),a(te.Sub,{flexSizing:"none",color:"cloud",fontColor:"white",backgroundColor:"layer.5",isRounded:!0,padding:"1/4",onClick:l,freeCSS:{lineHeight:1,aspectRatio:"1/1"},children:a(q.X,{ssSphere:1})})]}),SelectorPosition:3},t),{freeCSS:d({cursor:"pointer"},t.freeCSS)}),t.multiSelect||(t.min=0,t.max=1),t.options=t.options||[],t.emptySelect&&(t.options=[{value:null,label:a(K.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=p.flatArray(t.value),t.options=U.InitOptions(t.options),p.is.nullish(t.rightIcon)&&(t.rightIcon=a(oe,{ssSphere:2,children:a(q.Search,{})}),t.disabled&&(t.rightIcon=a(oe,{ssSphere:2,fontColor:"5.translucent",children:a(q.Ban,{})}))),t.rightIcon&&(t=d({paddingRight:3},t)),t.leftIcon&&(t=d({paddingLeft:3},t)),a(pe,{componentId:t.componentId,children:L.Core,states:Se(t)})};export{ne as Autocomplete,ne as default};
@@ -1 +1 @@
1
- import{b as e,c as r,d as h}from"../../chunk-C5N2D3ZX.js";import{jsx as m}from"react/jsx-runtime";import{UUID as D}from"jmini";import{useState as v}from"react";import x from"../../atoms/Box";import{OptionalInputWrapper as _,BoxWrapper as k,CoreEffects as p,DefaultBoxishStyles as F}from"./core";import{InputSwitchClasses as R}from"../../@styles/componentClasses";function w(t){let{value:n,states:d}=t,{required:s}=d,o=[];return s&&!n&&o.push({type:"invalid",label:"ON\u306B\u306A\u3063\u3066\u3044\u307E\u305B\u3093"}),{ok:!o.filter(({type:c})=>c=="invalid").length,notice:o}}const B=t=>{let y=t,{componentId:n,required:d,form:s,enableFormSubmit:o,checkValidationAtFirst:c,onChange:I,onKeyDown:f,onValidate:E,onValidateDelay:U,onUpdateValue:W,onUpdateValidValue:H,value:g=""}=y,S=h(y,["componentId","required","form","enableFormSubmit","checkValidationAtFirst","onChange","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","value"]),[l,i]=v(p.DefaultStatus(t.componentId||"",g)),[u,C]=v({ok:!1,notice:[]});return p.CommonEffects({type:"color",states:t,val_status:l,set_status:i,val_validate:u,set_validate:C,SystemValidation:w}),m(k,{val_status:l,set_status:i,val_validate:u,states:t,children:m(x,e({htmlTag:"input",type:"color","data-component-id":l.componentId,value:l.dataValue,className:R("Input"),onKeyDown:a=>{f&&f(a),o&&p.SubmitForm(a,s)},onChange:a=>{let{value:T}=a.target;u.ok&&C({ok:!1,notice:[]}),i(b=>r(e({},b),{dataValue:T,eventType:"update",eventID:D()})),I&&I(a)}},S))})},V=t=>{let n=r(e(r(e({},F(t)),{backgroundColor:"cloud",unitHeight:3}),t),{freeCSS:e({minWidth:108},t.freeCSS)});return m(_,{componentId:t.componentId,children:B,states:n})};export{V as Color,V as default};
1
+ import{b as a,c as n,d as V}from"../../chunk-C5N2D3ZX.js";import{jsx as I}from"react/jsx-runtime";import{UUID as m}from"jmini";import{useState as S}from"react";import h from"../../atoms/Box";import{OptionalInputWrapper as x,BoxWrapper as B,CoreEffects as c,DefaultBoxishStyles as _}from"./core";import{InputSwitchClasses as k}from"../../@styles/componentClasses";function R(e){let{value:i,states:f}=e,{required:p}=f,l=[];return p&&!i&&l.push({type:"invalid",label:"ON\u306B\u306A\u3063\u3066\u3044\u307E\u305B\u3093"}),{ok:!l.filter(({type:C})=>C=="invalid").length,notice:l}}const U=e=>{let T=e,{componentId:i,required:f,form:p,enableFormSubmit:l,checkValidationAtFirst:C,onChange:y,onKeyDown:v,onValidate:w,onValidateDelay:E,onUpdateValue:W,onUpdateValidValue:A,onUserAction:H,value:D=""}=T,t=V(T,["componentId","required","form","enableFormSubmit","checkValidationAtFirst","onChange","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value"]),[r,u]=S(c.DefaultStatus(e.componentId||"",D)),[d,g]=S({ok:!1,notice:[]});return c.CommonEffects({type:"color",states:e,val_status:r,set_status:u,val_validate:d,set_validate:g,SystemValidation:R}),I(B,{val_status:r,set_status:u,val_validate:d,states:e,children:I(h,a({htmlTag:"input",type:"color","data-component-id":r.componentId,value:r.dataValue,className:k("Input"),onKeyDown:o=>{v&&v(o),l&&c.SubmitForm(o,p)},onChange:o=>{let{value:s}=o.target;d.ok&&g({ok:!1,notice:[]}),u(F=>n(a({},F),{dataValue:s,eventType:"update",eventID:m()})),y&&y(o)},onFocus:o=>{t!=null&&t.onFocus&&(t==null||t.onFocus(o)),u(s=>n(a({},s),{eventID:m(),eventType:"focus.start",isFocusing:!0}))},onBlur:o=>{t!=null&&t.onBlur&&(t==null||t.onBlur(o)),u(s=>n(a({},s),{eventID:m(),eventType:"focus.end",isFocusing:!1}))}},t))})},b=e=>{let i=n(a(n(a({},_(e)),{backgroundColor:"cloud",unitHeight:3}),e),{freeCSS:a({minWidth:108},e.freeCSS)});return I(x,{componentId:e.componentId,children:U,states:i})};export{b as Color,b as default};
@@ -1 +1 @@
1
- import{b as o,c as r,d as b}from"../../chunk-C5N2D3ZX.js";import{jsx as u}from"react/jsx-runtime";import{UUID as g}from"jmini";import{useState as h}from"react";import{OptionalInputWrapper as w,BoxWrapper as _,CoreEffects as s,DefaultBoxishStyles as B}from"./core";import{Box as k}from"../../atoms";function F(t){let{value:e,states:c}=t,{required:m}=c,n=[];return m&&!e&&n.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!n.filter(({type:p})=>p=="invalid").length,notice:n}}const H=t=>{let T=t,{componentId:e,tone:c,required:m,form:n,value:p,enableFormSubmit:S,checkValidationAtFirst:C,onInput:f,onKeyDown:I,onValidate:L,onValidateDelay:M,onUpdateValue:U,onUpdateValidValue:W,children:E="",leftIndicator:q,rightIndicator:A,leftIcon:K,rightIcon:G,freeCSS:N,wrapStyles:O}=T,V=b(T,["componentId","tone","required","form","value","enableFormSubmit","checkValidationAtFirst","onInput","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","children","leftIndicator","rightIndicator","leftIcon","rightIcon","freeCSS","wrapStyles"]),[i,d]=h(s.DefaultStatus(e,p)),[l,y]=h({ok:!1,notice:[]});return s.CommonEffects({type:"contenteditable",states:t,val_status:i,set_status:d,val_validate:l,set_validate:y,SystemValidation:F}),u(_,{val_status:i,set_status:d,val_validate:l,states:t,children:u(k,r(o({contentEditable:!0,"data-show-validation":s.isShowValidation(l,i,!!C),"data-component-id":i.componentId,onKeyDown:a=>{I&&I(a),S&&s.SubmitForm(a,n)},onInput:a=>{let R=a.currentTarget,{innerHTML:P,innerText:x}=R;l.ok&&y({ok:!1,notice:[]}),d(D=>r(o({},D),{dataValue:x,eventType:"update",eventID:g()})),f&&f(a)}},V),{children:E}))})},v=t=>{t=r(o({rows:5},t),{freeCSS:o({whiteSpace:"pre-wrap"},t.freeCSS)});let e=B(t);return u(w,{componentId:t.componentId,children:H,states:e})};export{v as Contenteditable,v as default};
1
+ import{b as o,c as r,d as b}from"../../chunk-C5N2D3ZX.js";import{jsx as u}from"react/jsx-runtime";import{UUID as g}from"jmini";import{useState as h}from"react";import{OptionalInputWrapper as w,BoxWrapper as _,CoreEffects as s,DefaultBoxishStyles as B}from"./core";import{Box as k}from"../../atoms";function F(t){let{value:e,states:c}=t,{required:m}=c,n=[];return m&&!e&&n.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!n.filter(({type:p})=>p=="invalid").length,notice:n}}const H=t=>{let T=t,{componentId:e,tone:c,required:m,form:n,value:p,enableFormSubmit:S,checkValidationAtFirst:C,onInput:f,onKeyDown:I,onValidate:L,onValidateDelay:M,onUpdateValue:U,onUpdateValidValue:A,onUserAction:W,children:E="",leftIndicator:q,rightIndicator:K,leftIcon:G,rightIcon:N,freeCSS:O,wrapStyles:P}=T,V=b(T,["componentId","tone","required","form","value","enableFormSubmit","checkValidationAtFirst","onInput","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","children","leftIndicator","rightIndicator","leftIcon","rightIcon","freeCSS","wrapStyles"]),[i,d]=h(s.DefaultStatus(e,p)),[l,y]=h({ok:!1,notice:[]});return s.CommonEffects({type:"contenteditable",states:t,val_status:i,set_status:d,val_validate:l,set_validate:y,SystemValidation:F}),u(_,{val_status:i,set_status:d,val_validate:l,states:t,children:u(k,r(o({contentEditable:!0,"data-show-validation":s.isShowValidation(l,i,!!C),"data-component-id":i.componentId,onKeyDown:a=>{I&&I(a),S&&s.SubmitForm(a,n)},onInput:a=>{let R=a.currentTarget,{innerHTML:z,innerText:x}=R;l.ok&&y({ok:!1,notice:[]}),d(D=>r(o({},D),{dataValue:x,eventType:"update",eventID:g()})),f&&f(a)}},V),{children:E}))})},v=t=>{t=r(o({rows:5},t),{freeCSS:o({whiteSpace:"pre-wrap"},t.freeCSS)});let e=B(t);return u(w,{componentId:t.componentId,children:H,states:e})};export{v as Contenteditable,v as default};
@@ -1 +1 @@
1
- import{b as t,c as p,d as V}from"../../chunk-C5N2D3ZX.js";import{jsx as I}from"react/jsx-runtime";import{useState as F}from"react";import B,{UUID as S}from"jmini";import{$$fromRoot as K,GenerateHTMLProps as W}from"../../@utils";import{OptionalInputWrapper as U,BoxWrapper as $,CoreEffects as w,DefaultBoxishStyles as P}from"./core";import{Flex as q}from"../../atoms";import{InputClasses as R}from"../../@styles/componentClasses";function j(e){let{value:a,states:l}=e,{required:u,numericOnly:o=!1,digits:c}=l,r=[];return u&&!a&&r.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),a&&(o&&a.match(/\D/)&&r.push({type:"invalid",label:"\u6570\u5B57\u306E\u307F\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),a.length!=c&&r.push({type:"warn",label:"\u6700\u5F8C\u307E\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"})),{ok:!r.filter(({type:f})=>f=="invalid"||f=="warn").length,notice:r}}const z=(e,a="")=>{let l=String(a),u=[];for(let o=0;o<e;o++)u[o]=l[o]||"";return{formatValue:u,dataValue:l}},A=(e="")=>{let a=e,l=a.join("");return{formatValue:a,dataValue:l}},G=e=>{let v=e,{tone:a,required:l,form:u,name:o,className:c="",digits:r,numericOnly:h=!1,enableFormSubmit:f,checkValidationAtFirst:J,onChange:Q,onKeyDown:X,onValidate:Y,onValidateDelay:Z,onUpdateValue:ee,onUpdateValidValue:te,value:N="",override:ae,freeCSS:ne,wrapStyles:ie,combineInput:re,componentId:le,listStyles:_}=v,oe=V(v,["tone","required","form","name","className","digits","numericOnly","enableFormSubmit","checkValidationAtFirst","onChange","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","value","override","freeCSS","wrapStyles","combineInput","componentId","listStyles"]),[s,y]=F(p(t({componentId:e.componentId||""},z(r,N)),{eventType:"init",eventID:S()})),[D,k]=F({ok:!1,notice:[]});w.CommonEffects({type:"textfield",states:e,val_status:s,set_status:y,val_validate:D,set_validate:k,SystemValidation:j});let b=[];for(let n=0;n<r;n++){let E=s.formatValue[n],H={},x=c;e.combineInput&&(x=[c,R("DigitCharacterCell"),R("Combined")].join(" ")),b.push(I("input",{type:"text",inputMode:h?"numeric":e.inputMode||"text",value:E,id:"Digit-"+n+"-"+s.componentId,className:x,style:t(t({},e.style),H),onKeyDown:C=>{let{key:g,code:L}=C;if(g=="Tab")return;C.preventDefault();let m=null;if(g=="Backspace"){let i=s.formatValue;i[n]="",y(d=>p(t(t({},d),A(i)),{eventType:"update",eventID:S()})),m=n-1}else if(["ArrowLeft","ArrowRight"].includes(g)){let i=+(g=="ArrowRight")*2-1;m=n+i}else f&&w.SubmitForm(C,u),(()=>{let i=L.match(/^(Key(.)|Digit(\d)|Numpad(\d))/);if(!i)return;let d=i[2]||i[3]||i[4];if(h&&!d.match(/\d/)||!d)return;let T=s.formatValue;T[n]=d,y(O=>p(t(t({},O),A(T)),{eventType:"update",eventID:S()})),m=n+1})();B.is.exist(m)&&K("#Digit-"+m+"-"+s.componentId).focus()},onChange:()=>{}},n))}return I($,{val_status:s,set_status:y,val_validate:D,states:e,children:I(q,p(t({gap:"1/2",flexChilds:"even",flexWrap:!1,flexSizing:"auto"},_),{children:b}))})},M=e=>{e=t({},e),e=t({textAlign:"center",width:0},e),e.combineInput&&(e=p(t({textAlign:"center",width:0},e),{freeCSS:t({minWidth:12*2,marginRight:-1},e.freeCSS),listStyles:t({borderRadius:"2.tone.secondary",border:"unset",gap:0},e.listStyles)}));let a=W(P(e));return I(U,{componentId:e.componentId,children:G,states:a})};export{M as DigitCharacters,M as default};
1
+ import{b as t,c as s,d as V}from"../../chunk-C5N2D3ZX.js";import{jsx as D}from"react/jsx-runtime";import{useState as w}from"react";import K,{UUID as I}from"jmini";import{$$fromRoot as U,GenerateHTMLProps as W}from"../../@utils";import{OptionalInputWrapper as $,BoxWrapper as P,CoreEffects as R,DefaultBoxishStyles as q}from"./core";import{Flex as j}from"../../atoms";import{InputClasses as A}from"../../@styles/componentClasses";function z(e){let{value:a,states:u}=e,{required:d,numericOnly:p=!1,digits:C}=u,l=[];return d&&!a&&l.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),a&&(p&&a.match(/\D/)&&l.push({type:"invalid",label:"\u6570\u5B57\u306E\u307F\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),a.length!=C&&l.push({type:"warn",label:"\u6700\u5F8C\u307E\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"})),{ok:!l.filter(({type:S})=>S=="invalid"||S=="warn").length,notice:l}}const G=(e,a="")=>{let u=String(a),d=[];for(let p=0;p<e;p++)d[p]=u[p]||"";return{formatValue:d,dataValue:u}},B=(e="")=>{let a=e,u=a.join("");return{formatValue:a,dataValue:u}},J=e=>{let b=e,{tone:a,required:u,form:d,name:p,className:C="",digits:l,numericOnly:v=!1,enableFormSubmit:S,checkValidationAtFirst:Q,onChange:X,onKeyDown:Y,onValidate:Z,onValidateDelay:ee,onUpdateValue:te,onUpdateValidValue:ae,onUserAction:ne,value:N="",override:ie,freeCSS:re,wrapStyles:le,combineInput:oe,componentId:se,listStyles:_}=b,n=V(b,["tone","required","form","name","className","digits","numericOnly","enableFormSubmit","checkValidationAtFirst","onChange","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","override","freeCSS","wrapStyles","combineInput","componentId","listStyles"]),[m,f]=w(s(t({componentId:e.componentId||""},G(l,N)),{eventType:"init",eventID:I()})),[h,k]=w({ok:!1,notice:[]});R.CommonEffects({type:"textfield",states:e,val_status:m,set_status:f,val_validate:h,set_validate:k,SystemValidation:z});let T=[];for(let i=0;i<l;i++){let E=m.formatValue[i],H={},x=C;e.combineInput&&(x=[C,A("DigitCharacterCell"),A("Combined")].join(" ")),T.push(D("input",{type:"text",inputMode:v?"numeric":e.inputMode||"text",value:E,id:"Digit-"+i+"-"+m.componentId,className:x,style:t(t({},e.style),H),onKeyDown:c=>{let{key:o,code:L}=c;if(o=="Tab")return;c.preventDefault();let y=null;if(o=="Backspace"){let r=m.formatValue;r[i]="",f(g=>s(t(t({},g),B(r)),{eventType:"update",eventID:I()})),y=i-1}else if(["ArrowLeft","ArrowRight"].includes(o)){let r=+(o=="ArrowRight")*2-1;y=i+r}else S&&R.SubmitForm(c,d),(()=>{let r=L.match(/^(Key(.)|Digit(\d)|Numpad(\d))/);if(!r)return;let g=r[2]||r[3]||r[4];if(v&&!g.match(/\d/)||!g)return;let F=m.formatValue;F[i]=g,f(O=>s(t(t({},O),B(F)),{eventType:"update",eventID:I()})),y=i+1})();K.is.exist(y)&&U("#Digit-"+y+"-"+m.componentId).focus()},onChange:()=>{},onFocus:c=>{n!=null&&n.onFocus&&(n==null||n.onFocus(c)),f(o=>s(t({},o),{eventID:I(),eventType:"focus.start",isFocusing:!0}))},onBlur:c=>{n!=null&&n.onBlur&&(n==null||n.onBlur(c)),f(o=>s(t({},o),{eventID:I(),eventType:"focus.end",isFocusing:!1}))}},i))}return D(P,{val_status:m,set_status:f,val_validate:h,states:e,children:D(j,s(t({gap:"1/2",flexChilds:"even",flexWrap:!1,flexSizing:"auto"},_),{children:T}))})},M=e=>{e=t({},e),e=t({textAlign:"center",width:0},e),e.combineInput&&(e=s(t({textAlign:"center",width:0},e),{freeCSS:t({minWidth:12*2,marginRight:-1},e.freeCSS),listStyles:t({borderRadius:"2.tone.secondary",border:"unset",gap:0},e.listStyles)}));let a=W(q(e));return D($,{componentId:e.componentId,children:J,states:a})};export{M as DigitCharacters,M as default};
@@ -1 +1 @@
1
- import{b as s,c as u,d as G,e as O}from"../../chunk-C5N2D3ZX.js";import{Fragment as le,jsx as l,jsxs as p}from"react/jsx-runtime";import{useState as U,useEffect as Q}from"react";import se,{UUID as T,useStore as Y}from"jmini";import{$$fromRoot as D,ExtractStyles as re}from"../../@utils";import{Box as d,FAI as P,Flex as L,Column as ee}from"../../atoms";import{Row as pe}from"../../mols";import{Button as W}from"../Button";import H from"../Snackbar";import{OptionalInputWrapper as ue,BoxWrapper as me,CoreEffects as te,DefaultBoxishStyles as ce}from"./core";import de from"./TextField";import{InputFilerClasses as f}from"../../@styles/componentClasses";import{faCloudArrowUp as fe}from"@fortawesome/free-solid-svg-icons/faCloudArrowUp";function ge(e){let{value:t,states:n}=e,{required:m}=n,a=[];return m&&!t.length&&a.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!a.filter(({type:c})=>c=="invalid").length,notice:a}}const ae={List:e=>{let{rootStates:t,val_status:n,set_status:m}=e;if(t.useSystemOnly)return null;let a=t.limit-(n.dataValue||[]).length,c=(n.dataValue||[]).map((r,g)=>l(ae.ListCell,u(s({},e),{index:g,val_file:r}),r.name));return a>0&&c.push(l(d,u(s({htmlTag:"label"},t.cellStyles),{className:[t.cellClassName,f("AddButton")].join(" "),"data-component-id":n.componentId,htmlFor:t.id,tabIndex:t.tabIndex,onKeyDown:r=>{let{key:g}=r;t.tabIndex!=-1&&[" ","Enter"].includes(g)&&D("#"+t.id).click()},children:p(pe.Center,{padding:["1/3",0],children:[l(d,{isRounded:!0,className:f("AddIcon"),children:l(P,{icon:fe,className:f("Icon"),fontColor:"theme",fontSize:"4.thirdTitle",backgroundColor:"theme.opa.low",ssSphere:3,padding:"1/2"})}),p(d,{children:[p(d,{fontColor:"theme",fontSize:"2.normal",isSemiBoldFont:!0,children:["\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E(",a,")"]}),l(d,{fontColor:"4.thin",fontSize:"0.xs",isSemiBoldFont:!0,children:"\u30D5\u30A1\u30A4\u30EB\u3092\u30C9\u30ED\u30C3\u30D7"})]})]})}),"AddButton")),l(ee,u(s({flexSizing:"auto"},re(t)),{className:t.className,children:c}))},ListCell:e=>{let{index:t,rootStates:n,val_file:m,val_status:a,set_status:c}=e,{name:r,size:g,type:o}=m,[F,B]=U(!1),w=T(),q=g.rank(),[K,_]=r.replace(/\s/,"").replace(/(.*)\.(.*)$/,"$1 $2").split(" "),i="\u30D5\u30A1\u30A4\u30EB";return o.match(/image/)?i=o.replace(/image\//,""):o.match(/pdf/)?i="PDF":o.match(/csv/)?i="CSV":o.match(/spreadsheet/)?i="SpreadSheet":o.match(/presentation/)?i="PowerPoint":o.match(/word/)?i="Word":o.match(/zip/)?i="Zip":o.match(/powerpoint/)?i="PowerPoint":o.match(/html/)?i="HTML":o.match(/js/)?i="JavaScript":o.match(/css/)?i="CSS":o.match(/text\/plain/)&&(i="\u30C6\u30AD\u30B9\u30C8"),Q(()=>{F&&setTimeout(()=>{D("#"+w).focus()},100)},[F]),p(L,u(s({verticalAlign:"center",flexWrap:!1,gap:1,className:n.cellClassName},n.cellStyles),{children:[l(P.File,{fontSize:"4.thirdTitle",fontColor:"4.thin"}),p(d,{flexSizing:0,children:[l(d,{children:l(L,{verticalAlign:"center",gap:"2/3",flexWrap:!1,className:f("FileName"),children:F?l(le,{children:p(ee,{flexSizing:0,gap:"1/2",children:[p(L,{gap:"2/3",verticalAlign:"center",children:[l(de,{tone:"border",wrapStyles:{flexSizing:"auto"},restrict:"fileName",name:"name",required:!0,id:w,form:"form-"+w,enableFormSubmit:!0,value:K,onKeyDown:C=>{let{key:N}=C;N=="Escape"&&B(!1)}}),p(d,{children:[". ",_]})]}),p(L,{gap:"2/3",horizontalAlign:"right",flexWrap:!1,children:[l(W.Sub,{padding:["2/3",1],onClick:()=>{B(!1)},children:"\u9589\u3058\u308B"}),l(W,{padding:["2/3",1],submitOption:{formName:"form-"+w,callback:C=>O(void 0,null,function*(){let{name:N}=C,b=[...a.dataValue],A=b[t],J=A.id;if(!A)return;let{target:M}=yield A.convert();if(!M)return;let E=yield String(M.result).toBlob(m.type);if(!E)return;let y=new File([E],N+"."+_,{type:A.type});y.id=J,b[t]=y,c(x=>u(s({},x),{dataValue:b,eventType:"update",eventID:T()})),B(!1)})},children:"\u6C7A\u5B9A"})]})]})}):p(le,{children:[r,!!n.isNameEditable&&l(W.Clear,{ssSphere:2.5,flexSizing:"none",fontColor:"4.thin",padding:"1/3",ssEffectsOnActive:"expand",color:"cloud",onClick:()=>{B(!0)},children:l(P.Pen,{})})]})})}),!F&&p(d,{fontSize:"1.mini",fontColor:"4.thin",flexSizing:0,children:[i,"\u30D5\u30A1\u30A4\u30EB / ",q,"B"]})]}),l(W.Sub,{color:"cloud",fontColor:"4.thin",ssSphere:3,onClick:()=>{let C=[...a.dataValue];C[t]&&(C.splice(t,1),c(b=>u(s({},b),{dataValue:C,eventType:"update",eventID:T()})))},children:l(P.X,{})})]}))}},ye=e=>{let Z=e,{tone:t,required:n,form:m,isNameEditable:a,useSystemOnly:c,accept:r="*",limit:g=1,checkValidationAtFirst:o,onChange:F,onValidate:B,onValidateDelay:w,onUpdateValue:q,onUpdateValidValue:K,value:_=[],className:i,cellStyles:C,cellClassName:N,componentId:b,status_id:A,enableFormSubmit:J,freeCSS:M,wrapStyles:ne}=Z,E=G(Z,["tone","required","form","isNameEditable","useSystemOnly","accept","limit","checkValidationAtFirst","onChange","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","value","className","cellStyles","cellClassName","componentId","status_id","enableFormSubmit","freeCSS","wrapStyles"]),[y,x]=U(te.DefaultStatus(e.componentId||"",_)),[X,oe]=U({ok:!1,notice:[]}),ie={rootStates:e,val_status:y,set_status:x};Q(()=>{Y.set({["AddFiles-"+y.componentId]:v=>{x(V=>{let I=V.dataValue,k=[];for(var S=0;S<(v==null?void 0:v.length);S++){let h=v[S],{type:z,name:R}=h;if(S+1+I.length>g){H.add({componentId:R,secondsToClose:12e3,children:`\u30D5\u30A1\u30A4\u30EB\u9078\u629E\u4E0A\u9650\u3092\u8D85\u3048\u305F\u305F\u3081\u3001${R}}\u306F\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3002`,backgroundColor:"nega"});continue}if(r&&r=="image"&&!z.match(/image/)){H.add({componentId:R,secondsToClose:12e3,children:`\u30D5\u30A1\u30A4\u30EB\u5F62\u5F0F\u304C\u7570\u306A\u308B\u305F\u3081\u3001${R} \u306F\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3002`,backgroundColor:"nega"});continue}k.push(h)}return u(s({},V),{dataValue:[...I,...k],eventType:"update",eventID:T()})})}})},[]),te.CommonEffects({type:"file",states:e,val_status:y,set_status:x,val_validate:X,set_validate:oe,SystemValidation:ge});let $="";return r&&(r=="image"?$="image/png,image/jpeg":$=r),p(me,{val_status:y,set_status:x,val_validate:X,states:e,children:[l(d,u(s({htmlTag:"input",type:"file",className:f("Input"),"data-component-id":y.componentId,accept:$,multiple:g!=1,onChange:v=>O(void 0,null,function*(){F&&F(v);let V=v.target,I=V.files,k=[];for(var S=0;S<(I==null?void 0:I.length);S++){let h=I[S],z=h.name;if(h.id=T(),S+1+y.dataValue.length>g){H.add({componentId:z,secondsToClose:12e3,children:`\u30D5\u30A1\u30A4\u30EB\u767B\u9332\u6570\u3092\u8D85\u3048\u305F\u305F\u3081\u3001${z}}\u306F\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002`,backgroundColor:"nega"});continue}k.push(h)}x(h=>u(s({},h),{dataValue:[...h.dataValue,...k],eventType:"update",eventID:T()})),V.value=""})},E),{opacity:"low",tabIndex:-1,value:""})),l(ae.List,s({},ie))]})},j=e=>(e=u(s({limit:1,isNameEditable:!0,useSystemOnly:!1,tone:"border",value:[]},e),{override:"force",cellStyles:s(s({},ce({tone:e.tone||"border"})),e.cellStyles)}),l(ue,{componentId:e.componentId,children:ye,states:e}));j.fn={openDialog:e=>{let{multiple:t,accept:n}=e;return new Promise(m=>{const a=document.createElement("input");a.type="file",a.multiple=t!=null?t:!0,n&&(n=="image"?a.accept="image/png,image/jpeg,image/webp":a.accept=n),a.onchange=c=>{m(c.target.files)},a.click()})}},typeof window!="undefined"&&window.document&&se(document).addEvent({eventType:"dragover",callback:e=>{e.preventDefault(),D("."+f("AddButton")).addClass(f("Draggable"))},options:{passive:!1}}).addEvent({eventType:"drop",callback:e=>{e.preventDefault(),D("."+f("AddButton")).removeClass(f("Draggable"));let t=e.dataTransfer.files;if(t.length){let n=e.target;if(D(n).hasClass(f("AddButton"))){let{componentId:m}=n.dataset,a=Y.get("AddFiles-"+m);a&&a(t)}}},options:{passive:!1}});export{j as Filer,j as default};
1
+ import{b as s,c as u,d as Q,e as U}from"../../chunk-C5N2D3ZX.js";import{Fragment as ne,jsx as l,jsxs as p}from"react/jsx-runtime";import{useState as H,useEffect as Y}from"react";import re,{UUID as b,useStore as ee}from"jmini";import{$$fromRoot as D,ExtractStyles as pe}from"../../@utils";import{Box as d,FAI as R,Flex as P,Column as te}from"../../atoms";import{Row as ue}from"../../mols";import{Button as L}from"../Button";import j from"../Snackbar";import{OptionalInputWrapper as ce,BoxWrapper as me,CoreEffects as ae,DefaultBoxishStyles as de}from"./core";import fe from"./TextField";import{InputFilerClasses as f}from"../../@styles/componentClasses";import{faCloudArrowUp as ge}from"@fortawesome/free-solid-svg-icons/faCloudArrowUp";function ye(e){let{value:t,states:n}=e,{required:c}=n,a=[];return c&&!t.length&&a.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!a.filter(({type:m})=>m=="invalid").length,notice:a}}const le={List:e=>{let{rootStates:t,val_status:n,set_status:c}=e;if(t.useSystemOnly)return null;let a=t.limit-(n.dataValue||[]).length,m=(n.dataValue||[]).map((r,g)=>l(le.ListCell,u(s({},e),{index:g,val_file:r}),r.name));return a>0&&m.push(l(d,u(s({htmlTag:"label"},t.cellStyles),{className:[t.cellClassName,f("AddButton")].join(" "),"data-component-id":n.componentId,htmlFor:t.id,tabIndex:t.tabIndex,onKeyDown:r=>{let{key:g}=r;t.tabIndex!=-1&&[" ","Enter"].includes(g)&&D("#"+t.id).click()},children:p(ue.Center,{padding:["1/3",0],children:[l(d,{isRounded:!0,className:f("AddIcon"),children:l(R,{icon:ge,className:f("Icon"),fontColor:"theme",fontSize:"4.thirdTitle",backgroundColor:"theme.opa.low",ssSphere:3,padding:"1/2"})}),p(d,{children:[p(d,{fontColor:"theme",fontSize:"2.normal",isSemiBoldFont:!0,children:["\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E(",a,")"]}),l(d,{fontColor:"4.thin",fontSize:"0.xs",isSemiBoldFont:!0,children:"\u30D5\u30A1\u30A4\u30EB\u3092\u30C9\u30ED\u30C3\u30D7"})]})]})}),"AddButton")),l(te,u(s({flexSizing:"auto"},pe(t)),{className:t.className,children:m}))},ListCell:e=>{let{index:t,rootStates:n,val_file:c,val_status:a,set_status:m}=e,{name:r,size:g,type:i}=c,[F,T]=H(!1),B=b(),K=g.rank(),[J,W]=r.replace(/\s/,"").replace(/(.*)\.(.*)$/,"$1 $2").split(" "),o="\u30D5\u30A1\u30A4\u30EB";return i.match(/image/)?o=i.replace(/image\//,""):i.match(/pdf/)?o="PDF":i.match(/csv/)?o="CSV":i.match(/spreadsheet/)?o="SpreadSheet":i.match(/presentation/)?o="PowerPoint":i.match(/word/)?o="Word":i.match(/zip/)?o="Zip":i.match(/powerpoint/)?o="PowerPoint":i.match(/html/)?o="HTML":i.match(/js/)?o="JavaScript":i.match(/css/)?o="CSS":i.match(/text\/plain/)&&(o="\u30C6\u30AD\u30B9\u30C8"),Y(()=>{F&&setTimeout(()=>{D("#"+B).focus()},100)},[F]),p(P,u(s({verticalAlign:"center",flexWrap:!1,gap:1,className:n.cellClassName},n.cellStyles),{children:[l(R.File,{fontSize:"4.thirdTitle",fontColor:"4.thin"}),p(d,{flexSizing:0,children:[l(d,{children:l(P,{verticalAlign:"center",gap:"2/3",flexWrap:!1,className:f("FileName"),children:F?l(ne,{children:p(te,{flexSizing:0,gap:"1/2",children:[p(P,{gap:"2/3",verticalAlign:"center",children:[l(fe,{tone:"border",wrapStyles:{flexSizing:"auto"},restrict:"fileName",name:"name",required:!0,id:B,form:"form-"+B,enableFormSubmit:!0,value:J,onKeyDown:h=>{let{key:w}=h;w=="Escape"&&T(!1)}}),p(d,{children:[". ",W]})]}),p(P,{gap:"2/3",horizontalAlign:"right",flexWrap:!1,children:[l(L.Sub,{padding:["2/3",1],onClick:()=>{T(!1)},children:"\u9589\u3058\u308B"}),l(L,{padding:["2/3",1],submitOption:{formName:"form-"+B,callback:h=>U(void 0,null,function*(){let{name:w}=h,I=[...a.dataValue],N=I[t],X=N.id;if(!N)return;let{target:M}=yield N.convert();if(!M)return;let $=yield String(M.result).toBlob(c.type);if(!$)return;let _=new File([$],w+"."+W,{type:N.type});_.id=X,I[t]=_,m(C=>u(s({},C),{dataValue:I,eventType:"update",eventID:b()})),T(!1)})},children:"\u6C7A\u5B9A"})]})]})}):p(ne,{children:[r,!!n.isNameEditable&&l(L.Clear,{ssSphere:2.5,flexSizing:"none",fontColor:"4.thin",padding:"1/3",ssEffectsOnActive:"expand",color:"cloud",onClick:()=>{T(!0)},children:l(R.Pen,{})})]})})}),!F&&p(d,{fontSize:"1.mini",fontColor:"4.thin",flexSizing:0,children:[o,"\u30D5\u30A1\u30A4\u30EB / ",K,"B"]})]}),l(L.Sub,{color:"cloud",fontColor:"4.thin",ssSphere:3,onClick:()=>{let h=[...a.dataValue];h[t]&&(h.splice(t,1),m(I=>u(s({},I),{dataValue:h,eventType:"update",eventID:b()})))},children:l(R.X,{})})]}))}},Se=e=>{let G=e,{tone:t,required:n,form:c,isNameEditable:a,useSystemOnly:m,accept:r="*",limit:g=1,checkValidationAtFirst:i,onChange:F,onValidate:T,onValidateDelay:B,onUpdateValue:K,onUpdateValidValue:J,onUserAction:W,value:o=[],className:h,cellStyles:w,cellClassName:I,componentId:N,status_id:X,enableFormSubmit:M,freeCSS:oe,wrapStyles:$}=G,_=Q(G,["tone","required","form","isNameEditable","useSystemOnly","accept","limit","checkValidationAtFirst","onChange","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","className","cellStyles","cellClassName","componentId","status_id","enableFormSubmit","freeCSS","wrapStyles"]),[C,A]=H(ae.DefaultStatus(e.componentId||"",o)),[Z,ie]=H({ok:!1,notice:[]}),se={rootStates:e,val_status:C,set_status:A};Y(()=>{ee.set({["AddFiles-"+C.componentId]:x=>{A(V=>{let v=V.dataValue,k=[];for(var y=0;y<(x==null?void 0:x.length);y++){let S=x[y],{type:E,name:z}=S;if(y+1+v.length>g){j.add({componentId:z,secondsToClose:12e3,children:`\u30D5\u30A1\u30A4\u30EB\u9078\u629E\u4E0A\u9650\u3092\u8D85\u3048\u305F\u305F\u3081\u3001${z}}\u306F\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3002`,backgroundColor:"nega"});continue}if(r&&r=="image"&&!E.match(/image/)){j.add({componentId:z,secondsToClose:12e3,children:`\u30D5\u30A1\u30A4\u30EB\u5F62\u5F0F\u304C\u7570\u306A\u308B\u305F\u3081\u3001${z} \u306F\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3002`,backgroundColor:"nega"});continue}k.push(S)}return u(s({},V),{dataValue:[...v,...k],eventType:"update",eventID:b()})})}})},[]),ae.CommonEffects({type:"file",states:e,val_status:C,set_status:A,val_validate:Z,set_validate:ie,SystemValidation:ye});let O="";return r&&(r=="image"?O="image/png,image/jpeg":O=r),p(me,{val_status:C,set_status:A,val_validate:Z,states:e,children:[l(d,u(s({htmlTag:"input",type:"file",className:f("Input"),"data-component-id":C.componentId,accept:O,multiple:g!=1,onChange:x=>U(void 0,null,function*(){F&&F(x);let V=x.target,v=V.files,k=[];for(var y=0;y<(v==null?void 0:v.length);y++){let S=v[y],E=S.name;if(S.id=b(),y+1+C.dataValue.length>g){j.add({componentId:E,secondsToClose:12e3,children:`\u30D5\u30A1\u30A4\u30EB\u767B\u9332\u6570\u3092\u8D85\u3048\u305F\u305F\u3081\u3001${E}}\u306F\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002`,backgroundColor:"nega"});continue}k.push(S)}A(S=>u(s({},S),{dataValue:[...S.dataValue,...k],eventType:"update",eventID:b()})),V.value=""})},_),{opacity:"low",tabIndex:-1,value:""})),l(le.List,s({},se))]})},q=e=>(e=u(s({limit:1,isNameEditable:!0,useSystemOnly:!1,tone:"border",value:[]},e),{override:"force",cellStyles:s(s({},de({tone:e.tone||"border"})),e.cellStyles)}),l(ce,{componentId:e.componentId,children:Se,states:e}));q.fn={openDialog:e=>{let{multiple:t,accept:n}=e;return new Promise(c=>{const a=document.createElement("input");a.type="file",a.multiple=t!=null?t:!0,n&&(n=="image"?a.accept="image/png,image/jpeg,image/webp":a.accept=n),a.onchange=m=>{c(m.target.files)},a.click()})}},typeof window!="undefined"&&window.document&&re(document).addEvent({eventType:"dragover",callback:e=>{e.preventDefault(),D("."+f("AddButton")).addClass(f("Draggable"))},options:{passive:!1}}).addEvent({eventType:"drop",callback:e=>{e.preventDefault(),D("."+f("AddButton")).removeClass(f("Draggable"));let t=e.dataTransfer.files;if(t.length){let n=e.target;if(D(n).hasClass(f("AddButton"))){let{componentId:c}=n.dataset,a=ee.get("AddFiles-"+c);a&&a(t)}}},options:{passive:!1}});export{q as Filer,q as default};
@@ -1 +1 @@
1
- import{b as o,c as u,d as w}from"../../chunk-C5N2D3ZX.js";import{jsx as a}from"react/jsx-runtime";import S,{UUID as M}from"jmini";import{useState as ie}from"react";import{$$fromRoot as ne,GenerateHTMLProps as se}from"../../@utils";import{Box as I,Flex as re,FAI as ce,Span as de}from"../../atoms";import{Button as ue}from"../Button";import{OptionalInputWrapper as me,BoxWrapper as pe,CoreEffects as J}from"./core";import{InputListClasses as T}from"../../@styles/componentClasses";function Ce(t){let{value:l,states:i}=t,{type:e,required:s,min:n,max:p}=i;n=n||0,p=p||65535;let r=[],y=l.length;return s&&(y||e=="radio"&&r.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),y<n&&r.push({type:"invalid",label:n+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),y>p&&r.push({type:"invalid",label:p+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!r.filter(({type:V})=>V=="invalid").length,notice:r}}const h={InitOptions:t=>{let l=[];return t.forEach(i=>{if(!i)return;let{label:e,value:s}=i;S.is.nullish(e)&&(e=String(s)),l.push(u(o({},i),{label:e,value:s}))}),l},OptionalListWrapper:t=>{let{value:l,options:i=[]}=t,e=S.is.exist(l)?S.flatArray(l):[],s=[];return e.forEach(n=>{i.findIndex(r=>S.is.equal(r.value,n))!=-1&&s.push(n)}),a(h.Core,u(o({},t),{value:s,options:i}))},Core:t=>{let k=t,{type:l,tone:i,required:e,componentId:s="",form:n,override:p,icon:r,iconType:y,iconSize:V,iconPosition:X,iconColor:v,CustomIcon:A,enableFormSubmit:$,checkValidationAtFirst:W,onValidate:H,onValidateDelay:N,onUpdateValue:U,onUpdateValidValue:K,value:_,options:b,className:q,cellStyles:j,cellClassName:G,cellCheckedStyles:Q,cellCheckedClassName:Y,min:Z,max:E,hideInput:m,freeCSS:O,wrapStyles:x}=k,ee=w(k,["type","tone","required","componentId","form","override","icon","iconType","iconSize","iconPosition","iconColor","CustomIcon","enableFormSubmit","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","value","options","className","cellStyles","cellClassName","cellCheckedStyles","cellCheckedClassName","min","max","hideInput","freeCSS","wrapStyles"]),[C,L]=ie(J.DefaultStatus(s,_)),[D,z]=ie({ok:!1,notice:[]});return J.CommonEffects({type:"list."+l,states:t,val_status:C,set_status:L,val_validate:D,set_validate:z,SystemValidation:Ce}),a(pe,{val_status:C,set_status:L,val_validate:D,states:t,children:a(h.List,{rootStates:t,val_status:C,set_status:L})})},List:t=>{let{rootStates:l,val_status:i,set_status:e}=t,{componentId:s,type:n,tone:p,icon:r,iconSize:y,iconColor:V,isChecker:X,options:v,name:A,form:$,tabIndex:W,hideInput:H,disabled:N,className:U,cellStyles:K,cellClassName:_="",cellCheckedStyles:b,cellCheckedClassName:q="",enableFormSubmit:j}=l,{dataValue:G}=i,Q=l.CustomIcon,Y=v.map((Z,E)=>{let le=Z,{value:m,label:O,disabled:x,className:ee="",checkedStyles:C,checkedClassName:L="",freeCSS:D}=le,z=w(le,["value","label","disabled","className","checkedStyles","checkedClassName","freeCSS"]),k=M(),R=G.findIndex(c=>c===m)!=-1,f=o(o({},K),z),F=[T("Label"),_,ee];R&&(f=u(o(o(o({},f),b),C),{freeCSS:o(o(o({},f==null?void 0:f.freeCSS),b==null?void 0:b.freeCSS),C==null?void 0:C.freeCSS)}),F=[...F,q,L]);const te=()=>{if(N||x)return;let c=[];if(n=="radio")c=[m];else if(n=="checkbox"||X)if(!R)c=[...i.dataValue,m];else{let d=[...i.dataValue];d.splice(i.dataValue.findIndex(B=>B==m),1),c=d}e(d=>u(o({},d),{dataValue:c,eventType:"update",eventID:M()}))};let oe=[a(de,{position:"relative",freeCSS:{zIndex:2},flexSizing:0,children:S.is.string(O)?a(I,{children:O}):O},"content")];return r&&oe[l.iconPosition=="right"?"push":"unshift"](a(Q,{isChecked:R,iconSize:y,iconColor:V,toggle:te},"icon")),[a(I,{htmlTag:"input",type:n=="radio"?"radio":"checkbox",className:T("Input"),name:"RadioCheckbox-"+A,"data-list-index":s+"-"+E,id:k,value:String(m),disabled:N||x,checked:R,onFocus:c=>{x||n=="radio"&&(i.dataValue.length||e(d=>u(o({},d),{dataValue:[m],eventType:"update",eventID:M()})))},onChange:()=>{te()},onKeyDown:c=>{let{key:d,shiftKey:B}=c;if((n=="checkbox"||t.rootStates.isChecker)&&d!="Tab"){if(d.match(/Arrow/)){c.preventDefault();let ae=["ArrowLeft","ArrowUp"].includes(d)?-1:1,g=E+ae;g<0?g=v.length-1:g>=v.length&&(g=0),ne(`input[data-list-index="${s}-${g}"]`).focus()}}j&&J.SubmitForm(c,$)},tabIndex:W},"List-"+S.Stringify(m)),a(I,u(o({htmlTag:"label","data-disabled":N||x,htmlFor:k,className:F.join(" "),tabIndex:-1,display:"flex",verticalAlign:"center",flexWrap:!1},f),{children:oe}),"ListTrigger-"+S.Stringify(m))]});return a(re,{flexSizing:"auto",style:l.style,freeCSS:o({},l.freeCSS),className:[U,T("CellBase"),T("HideInput_"+H),T("IconIndicator_"+!!r),T("Tone_"+p)].join(" "),children:Y})},_Icon:t=>{let l=1.5;return t.iconSize=="small"?l=1.2:t.iconSize=="large"&&(l=2),a(ue.Normal,{ssPushable:!0,color:"cloud",tabIndex:-1,ssEffectsOnActive:"ripple.cloud",ssSphere:2,freeCSS:{transform:`scale(${l})`},onClick:i=>{i.preventDefault(),i.stopPropagation(),t.toggle()},children:t.children})},RadioIcon:t=>a(h._Icon,u(o({type:"radio"},t),{children:a(I,{flexCenter:!0,isRounded:!0,border:t.isChecked?"0.trans":"3.thick",borderColor:t.isChecked?t.iconColor:"3.thick",position:"relative",transition:"middle",freeCSS:{width:"50%",height:"50%"},children:a(I,{position:"absolute",transition:"middle",isRounded:!0,backgroundColor:t.iconColor,opacity:t.isChecked?"max":"trans",freeCSS:{width:"60%",height:"60%",transform:t.isChecked?"scale(1)":"scale(.4)"}})})})),CheckboxIcon:t=>a(h._Icon,u(o({type:"checkbox"},t),{children:a(I,{flexCenter:!0,boxShadow:t.isChecked?"0.remark":"none",border:t.isChecked?"0.trans":"3.thick",backgroundColor:t.isChecked?t.iconColor:"trans",position:"relative",transition:"middle",fontColor:"white",freeCSS:{borderRadius:"25%",padding:"4%",width:"50%",height:"50%"},children:a(ce.Check,{transition:"middle",opacity:t.isChecked?"max":"trans",freeCSS:{zIndex:8,width:"100%",height:"100%",transform:t.isChecked?"scale(1)":"scale(.5)"}})})}))},P=t=>{t=t||"checkbox";const l=e=>(e=u(o({gap:1,icon:!0,iconSize:"regular",iconType:t=="radio"?"radio":"checkbox",iconPosition:"left",iconColor:"theme"},e),{type:t,cellStyles:o({gap:"1/6",position:"relative",borderRadius:"2.tone.secondary",transition:"middle"},e.cellStyles)}),e.CustomIcon||(e.iconType=="radio"?e.CustomIcon=h.RadioIcon:e.iconType=="checkbox"&&(e.CustomIcon=h.CheckboxIcon)),e.iconSize=="small"?e.cellStyles.gap=0:e.iconSize=="large"&&(e.cellStyles.gap="1/2"),e.tone=="normal"?(e.cellStyles=o({padding:["1/4",1],border:"1.thin",backgroundColor:"layer.1"},e.cellStyles),e.cellCheckedStyles=o({borderColor:"theme",fontColor:"theme",boxShadow:"1.normal"},e.cellCheckedStyles)):e.tone=="border"?(e.cellStyles=o({border:"1.thin",backgroundColor:"layer.1",padding:["1/2",1,"1/2","1/2"]},e.cellStyles),e.cellCheckedStyles=o({borderColor:"theme",fontColor:"theme"},e.cellCheckedStyles)):e.tone=="cloud"&&(e.cellStyles=o({border:"1.thin",backgroundColor:"layer.2",padding:["1/2",1,"1/2","1/2"]},e.cellStyles),e.cellCheckedStyles=o({backgroundColor:"cloud",fontColor:"theme"},e.cellCheckedStyles)),e=se(e),e.options=h.InitOptions(e.options),a(me,{componentId:e.componentId,children:h.OptionalListWrapper,states:e})),i=l;return i.Normal=e=>a(l,o({type:t,tone:"normal",icon:!1},e)),i.Border=e=>a(l,o({type:t,tone:"border"},e)),i.Cloud=e=>a(l,o({type:t,tone:"cloud"},e)),i.Vivid=e=>a(l,o({type:t,tone:"normal",icon:!1,cellCheckedStyles:{backgroundColor:"theme",fontColor:"white"}},e)),i.Simple=e=>a(l,o({type:t,tone:"plain",icon:!1,cellCheckedStyles:{fontColor:"theme"}},e)),i},he=P("radio"),Se=P("checkbox"),ye=P();export{Se as Checkbox,ye as List,he as Radio};
1
+ import{b as o,c as u,d as B}from"../../chunk-C5N2D3ZX.js";import{jsx as a}from"react/jsx-runtime";import S,{UUID as w}from"jmini";import{useState as ie}from"react";import{$$fromRoot as ne,GenerateHTMLProps as se}from"../../@utils";import{Box as T,Flex as re,FAI as ce,Span as de}from"../../atoms";import{Button as ue}from"../Button";import{OptionalInputWrapper as me,BoxWrapper as pe,CoreEffects as M}from"./core";import{InputListClasses as b}from"../../@styles/componentClasses";function Ce(t){let{value:l,states:i}=t,{type:e,required:s,min:n,max:p}=i;n=n||0,p=p||65535;let r=[],y=l.length;return s&&(y||e=="radio"&&r.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),y<n&&r.push({type:"invalid",label:n+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),y>p&&r.push({type:"invalid",label:p+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!r.filter(({type:V})=>V=="invalid").length,notice:r}}const C={InitOptions:t=>{let l=[];return t.forEach(i=>{if(!i)return;let{label:e,value:s}=i;S.is.nullish(e)&&(e=String(s)),l.push(u(o({},i),{label:e,value:s}))}),l},OptionalListWrapper:t=>{let{value:l,options:i=[]}=t,e=S.is.exist(l)?S.flatArray(l):[],s=[];return e.forEach(n=>{i.findIndex(r=>S.is.equal(r.value,n))!=-1&&s.push(n)}),a(C.Core,u(o({},t),{value:s,options:i}))},Core:t=>{let h=t,{type:l,tone:i,required:e,componentId:s="",form:n,override:p,icon:r,iconType:y,iconSize:V,iconPosition:P,iconColor:v,CustomIcon:X,enableFormSubmit:A,checkValidationAtFirst:$,onValidate:U,onValidateDelay:N,onUpdateValue:W,onUpdateValidValue:H,onUserAction:K,value:f,options:q,className:j,cellStyles:G,cellClassName:Q,cellCheckedStyles:Y,cellCheckedClassName:Z,min:D,max:m,hideInput:O,freeCSS:x,wrapStyles:ee}=h,L=B(h,["type","tone","required","componentId","form","override","icon","iconType","iconSize","iconPosition","iconColor","CustomIcon","enableFormSubmit","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","className","cellStyles","cellClassName","cellCheckedStyles","cellCheckedClassName","min","max","hideInput","freeCSS","wrapStyles"]),[k,R]=ie(M.DefaultStatus(s,f)),[_,E]=ie({ok:!1,notice:[]});return M.CommonEffects({type:"list."+l,states:t,val_status:k,set_status:R,val_validate:_,set_validate:E,SystemValidation:Ce}),a(pe,{val_status:k,set_status:R,val_validate:_,states:t,children:a(C.List,{rootStates:t,val_status:k,set_status:R})})},List:t=>{let{rootStates:l,val_status:i,set_status:e}=t,{componentId:s,type:n,tone:p,icon:r,iconSize:y,iconColor:V,isChecker:P,options:v,name:X,form:A,tabIndex:$,hideInput:U,disabled:N,className:W,cellStyles:H,cellClassName:K="",cellCheckedStyles:f,cellCheckedClassName:q="",enableFormSubmit:j}=l,{dataValue:G}=i,Q=l.CustomIcon,Y=v.map((Z,D)=>{let le=Z,{value:m,label:O,disabled:x,className:ee="",checkedStyles:L,checkedClassName:k="",freeCSS:R}=le,_=B(le,["value","label","disabled","className","checkedStyles","checkedClassName","freeCSS"]),E=w(),h=G.findIndex(c=>c===m)!=-1,I=o(o({},H),_),z=[b("Label"),K,ee];h&&(I=u(o(o(o({},I),f),L),{freeCSS:o(o(o({},I==null?void 0:I.freeCSS),f==null?void 0:f.freeCSS),L==null?void 0:L.freeCSS)}),z=[...z,q,k]);const te=()=>{if(N||x)return;let c=[];if(n=="radio")c=[m];else if(n=="checkbox"||P)if(!h)c=[...i.dataValue,m];else{let d=[...i.dataValue];d.splice(i.dataValue.findIndex(F=>F==m),1),c=d}e(d=>u(o({},d),{dataValue:c,eventType:"update",eventID:w()}))};let oe=[a(de,{position:"relative",freeCSS:{zIndex:2},flexSizing:0,children:S.is.string(O)?a(T,{children:O}):O},"content")];return r&&oe[l.iconPosition=="right"?"push":"unshift"](a(Q,{isChecked:h,iconSize:y,iconColor:V,toggle:te},"icon")),[a(T,{htmlTag:"input",type:n=="radio"?"radio":"checkbox",className:b("Input"),name:"RadioCheckbox-"+X,"data-list-index":s+"-"+D,id:E,value:String(m),disabled:N||x,checked:h,onFocus:c=>{x||n=="radio"&&(i.dataValue.length||e(d=>u(o({},d),{dataValue:[m],eventType:"update",eventID:w()})))},onChange:()=>{te()},onKeyDown:c=>{let{key:d,shiftKey:F}=c;if((n=="checkbox"||t.rootStates.isChecker)&&d!="Tab"){if(d.match(/Arrow/)){c.preventDefault();let ae=["ArrowLeft","ArrowUp"].includes(d)?-1:1,g=D+ae;g<0?g=v.length-1:g>=v.length&&(g=0),ne(`input[data-list-index="${s}-${g}"]`).focus()}}j&&M.SubmitForm(c,A)},tabIndex:$},"List-"+S.Stringify(m)),a(T,u(o({htmlTag:"label","data-disabled":N||x,htmlFor:E,className:z.join(" "),tabIndex:-1,display:"flex",verticalAlign:"center",flexWrap:!1},I),{children:oe}),"ListTrigger-"+S.Stringify(m))]});return a(re,{flexSizing:"auto",style:l.style,freeCSS:o({},l.freeCSS),className:[W,b("CellBase"),b("HideInput_"+U),b("IconIndicator_"+!!r),b("Tone_"+p)].join(" "),children:Y})},_Icon:t=>{let l=1.5;return t.iconSize=="small"?l=1.2:t.iconSize=="large"&&(l=2),a(ue.Normal,{ssPushable:!0,color:"cloud",tabIndex:-1,ssEffectsOnActive:"ripple.cloud",ssSphere:2,freeCSS:{transform:`scale(${l})`},onClick:i=>{i.preventDefault(),i.stopPropagation(),t.toggle()},children:t.children})},RadioIcon:t=>a(C._Icon,u(o({type:"radio"},t),{children:a(T,{flexCenter:!0,isRounded:!0,border:t.isChecked?"0.trans":"3.thick",borderColor:t.isChecked?t.iconColor:"3.thick",position:"relative",transition:"middle",freeCSS:{width:"50%",height:"50%"},children:a(T,{position:"absolute",transition:"middle",isRounded:!0,backgroundColor:t.iconColor,opacity:t.isChecked?"max":"trans",freeCSS:{width:"60%",height:"60%",transform:t.isChecked?"scale(1)":"scale(.4)"}})})})),CheckboxIcon:t=>a(C._Icon,u(o({type:"checkbox"},t),{children:a(T,{flexCenter:!0,boxShadow:t.isChecked?"0.remark":"none",border:t.isChecked?"0.trans":"3.thick",backgroundColor:t.isChecked?t.iconColor:"trans",position:"relative",transition:"middle",fontColor:"white",freeCSS:{borderRadius:"25%",padding:"4%",width:"50%",height:"50%"},children:a(ce.Check,{transition:"middle",opacity:t.isChecked?"max":"trans",freeCSS:{zIndex:8,width:"100%",height:"100%",transform:t.isChecked?"scale(1)":"scale(.5)"}})})}))},J=t=>{t=t||"checkbox";const l=e=>(e=u(o({gap:1,icon:!0,iconSize:"regular",iconType:t=="radio"?"radio":"checkbox",iconPosition:"left",iconColor:"theme"},e),{type:t,cellStyles:o({gap:"1/6",position:"relative",borderRadius:"2.tone.secondary",transition:"middle"},e.cellStyles)}),e.CustomIcon||(e.iconType=="radio"?e.CustomIcon=C.RadioIcon:e.iconType=="checkbox"&&(e.CustomIcon=C.CheckboxIcon)),e.iconSize=="small"?e.cellStyles.gap=0:e.iconSize=="large"&&(e.cellStyles.gap="1/2"),e.tone=="normal"?(e.cellStyles=o({padding:["1/4",1],border:"1.thin",backgroundColor:"layer.1"},e.cellStyles),e.cellCheckedStyles=o({borderColor:"theme",fontColor:"theme",boxShadow:"1.normal"},e.cellCheckedStyles)):e.tone=="border"?(e.cellStyles=o({border:"1.thin",backgroundColor:"layer.1",padding:["1/2",1,"1/2","1/2"]},e.cellStyles),e.cellCheckedStyles=o({borderColor:"theme",fontColor:"theme"},e.cellCheckedStyles)):e.tone=="cloud"&&(e.cellStyles=o({border:"1.thin",backgroundColor:"layer.2",padding:["1/2",1,"1/2","1/2"]},e.cellStyles),e.cellCheckedStyles=o({backgroundColor:"cloud",fontColor:"theme"},e.cellCheckedStyles)),e=se(e),e.options=C.InitOptions(e.options),a(me,{componentId:e.componentId,children:C.OptionalListWrapper,states:e})),i=l;return i.Normal=e=>a(l,o({type:t,tone:"normal",icon:!1},e)),i.Border=e=>a(l,o({type:t,tone:"border"},e)),i.Cloud=e=>a(l,o({type:t,tone:"cloud"},e)),i.Vivid=e=>a(l,o({type:t,tone:"normal",icon:!1,cellCheckedStyles:{backgroundColor:"theme",fontColor:"white"}},e)),i.Simple=e=>a(l,o({type:t,tone:"plain",icon:!1,cellCheckedStyles:{fontColor:"theme"}},e)),i},he=J("radio"),Se=J("checkbox"),ye=J();export{Se as Checkbox,ye as List,he as Radio};
@@ -1 +1 @@
1
- import{b as e,c as n,d as C}from"../../chunk-C5N2D3ZX.js";import{jsx as r}from"react/jsx-runtime";import{UUID as x}from"jmini";import{useState as a}from"react";import{Radio as w}from"./List";import{InputSegmentedClasses as u}from"../../@styles/componentClasses";const E=t=>{let i=t,{__sys_segmented_type:o,tone:B,value:d,options:S,onUpdateValue:h,onUpdateValidValue:p,enableFormSubmit:M,checkValidationAtFirst:R,cellStyles:g,cellClassName:_,cellCheckedClassName:b,cellCheckedStyles:f,freeCSS:k,wrapStyles:J}=i,I=C(i,["__sys_segmented_type","tone","value","options","onUpdateValue","onUpdateValidValue","enableFormSubmit","checkValidationAtFirst","cellStyles","cellClassName","cellCheckedClassName","cellCheckedStyles","freeCSS","wrapStyles"]),[T]=a(x()),[c,V]=a(d),[v,m]=a(c);return c!=d&&(V(d),m(d)),r(w,n(e({options:S,value:v,componentId:T,icon:!1,flexWrap:!1,borderRadius:"2.tone.secondary",position:"relative"},I),{freeCSS:e({whiteSpace:"nowrap"},k),cellStyles:e({flexCenter:!0,ssEffectsOnActive:"push"},g),cellCheckedStyles:e({},f),cellClassName:[_,u("Label"),u("Tone_"+o.replace(/\./ig,""))].join(" "),cellCheckedClassName:[b,u("Checked")].join(" "),tone:"custom",onUpdateValue:h,onUpdateValidValue:(...y)=>{p&&p(...y),o=="bottomline"&&m(y[0])}}))},s=t=>{let{__sys_segmented_type:o}=t;return o=o||"plain",o=="plain"&&(t=n(e({padding:"1/3",gap:"1/3",ssCardBox:!0},t),{cellStyles:e({padding:["1/2","3/4"],borderRadius:"inherit",position:"relative"},t.cellStyles),cellCheckedStyles:e({backgroundColor:"theme",boxShadow:"1.normal",fontColor:"white"},t.cellCheckedStyles)})),r(E,e({__sys_segmented_type:"plain"},t))},l=s;l.Cloud=t=>{let o=n(e({__sys_segmented_type:"cloud",padding:"1/3",gap:"1/3",backgroundColor:"cloud"},t),{cellStyles:e({padding:"3/4",borderRadius:"inherit",position:"relative"},t.cellStyles),cellCheckedStyles:e({boxShadow:"1.normal",backgroundColor:"theme",fontColor:"white"},t.cellCheckedStyles)});return r(s,e({},o))},l.CloudTheme=t=>{let o=e({backgroundColor:"theme.opa.few",fontColor:"theme",__sys_segmented_type:"cloud.theme"},t);return r(l.Cloud,e({},o))},l.CloudMono=t=>{let o=n(e({fontColor:"3.blur",__sys_segmented_type:"cloud.mono"},t),{cellCheckedStyles:e({backgroundColor:"layer.1",fontColor:"1.clear"},t.cellCheckedStyles)});return r(l.Cloud,e({},o))},l.Border=t=>{let o=n(e({backgroundColor:"layer.1",border:"2.normal",overflow:"hidden",gap:0,fontColor:"3.blur",ssLastChildLossBorder:"right",boxShadow:"0.min",__sys_segmented_type:"border"},t),{cellStyles:e({padding:["3/4",1],borderRadius:0,borderRight:"2.normal"},t.cellStyles),cellCheckedStyles:e({backgroundColor:"theme.opa.few",fontColor:"theme"},t.cellCheckedStyles)});return r(s,e({},o))},l.BorderVivid=t=>{let o=n(e({border:!0,borderColor:"theme",__sys_segmented_type:"border.vivid"},t),{cellStyles:e({borderRight:!0,borderColor:"theme"},t.cellStyles),cellCheckedStyles:e({backgroundColor:"theme",fontColor:"white"},t.cellCheckedStyles)});return r(l.Border,e({},o))},l.Bottomline=t=>{let o=n(e({__sys_segmented_type:"bottomline",gap:0,fontColor:"3.blur"},t),{cellStyles:e({ssEffectsOnActive:"ripple.theme",borderRadius:0,padding:1},t.cellStyles),cellCheckedStyles:e({fontColor:"theme"},t.cellCheckedStyles)});return r(s,e({},o))};export{l as Segmented,l as default};
1
+ import{b as e,c as n,d as C}from"../../chunk-C5N2D3ZX.js";import{jsx as r}from"react/jsx-runtime";import{UUID as w}from"jmini";import{useState as a}from"react";import{Radio as E}from"./List";import{InputSegmentedClasses as u}from"../../@styles/componentClasses";const B=t=>{let m=t,{__sys_segmented_type:o,tone:M,value:d,options:S,onUpdateValue:h,onUpdateValidValue:c,onUserAction:g,enableFormSubmit:R,checkValidationAtFirst:U,cellStyles:_,cellClassName:b,cellCheckedClassName:f,cellCheckedStyles:k,freeCSS:I,wrapStyles:J}=m,T=C(m,["__sys_segmented_type","tone","value","options","onUpdateValue","onUpdateValidValue","onUserAction","enableFormSubmit","checkValidationAtFirst","cellStyles","cellClassName","cellCheckedClassName","cellCheckedStyles","freeCSS","wrapStyles"]),[V]=a(w()),[p,v]=a(d),[x,i]=a(p);return p!=d&&(v(d),i(d)),r(E,n(e({options:S,value:x,componentId:V,icon:!1,flexWrap:!1,borderRadius:"2.tone.secondary",position:"relative"},T),{freeCSS:e({whiteSpace:"nowrap"},I),cellStyles:e({flexCenter:!0,ssEffectsOnActive:"push"},_),cellCheckedStyles:e({},k),cellClassName:[b,u("Label"),u("Tone_"+o.replace(/\./ig,""))].join(" "),cellCheckedClassName:[f,u("Checked")].join(" "),tone:"custom",onUpdateValue:h,onUpdateValidValue:(...y)=>{c&&c(...y),o=="bottomline"&&i(y[0])},onUserAction:g}))},s=t=>{let{__sys_segmented_type:o}=t;return o=o||"plain",o=="plain"&&(t=n(e({padding:"1/3",gap:"1/3",ssCardBox:!0},t),{cellStyles:e({padding:["1/2","3/4"],borderRadius:"inherit",position:"relative"},t.cellStyles),cellCheckedStyles:e({backgroundColor:"theme",boxShadow:"1.normal",fontColor:"white"},t.cellCheckedStyles)})),r(B,e({__sys_segmented_type:"plain"},t))},l=s;l.Cloud=t=>{let o=n(e({__sys_segmented_type:"cloud",padding:"1/3",gap:"1/3",backgroundColor:"cloud"},t),{cellStyles:e({padding:"3/4",borderRadius:"inherit",position:"relative"},t.cellStyles),cellCheckedStyles:e({boxShadow:"1.normal",backgroundColor:"theme",fontColor:"white"},t.cellCheckedStyles)});return r(s,e({},o))},l.CloudTheme=t=>{let o=e({backgroundColor:"theme.opa.few",fontColor:"theme",__sys_segmented_type:"cloud.theme"},t);return r(l.Cloud,e({},o))},l.CloudMono=t=>{let o=n(e({fontColor:"3.blur",__sys_segmented_type:"cloud.mono"},t),{cellCheckedStyles:e({backgroundColor:"layer.1",fontColor:"1.clear"},t.cellCheckedStyles)});return r(l.Cloud,e({},o))},l.Border=t=>{let o=n(e({backgroundColor:"layer.1",border:"2.normal",overflow:"hidden",gap:0,fontColor:"3.blur",ssLastChildLossBorder:"right",boxShadow:"0.min",__sys_segmented_type:"border"},t),{cellStyles:e({padding:["3/4",1],borderRadius:0,borderRight:"2.normal"},t.cellStyles),cellCheckedStyles:e({backgroundColor:"theme.opa.few",fontColor:"theme"},t.cellCheckedStyles)});return r(s,e({},o))},l.BorderVivid=t=>{let o=n(e({border:!0,borderColor:"theme",__sys_segmented_type:"border.vivid"},t),{cellStyles:e({borderRight:!0,borderColor:"theme"},t.cellStyles),cellCheckedStyles:e({backgroundColor:"theme",fontColor:"white"},t.cellCheckedStyles)});return r(l.Border,e({},o))},l.Bottomline=t=>{let o=n(e({__sys_segmented_type:"bottomline",gap:0,fontColor:"3.blur"},t),{cellStyles:e({ssEffectsOnActive:"ripple.theme",borderRadius:0,padding:1},t.cellStyles),cellCheckedStyles:e({fontColor:"theme"},t.cellCheckedStyles)});return r(s,e({},o))};export{l as Segmented,l as default};
@@ -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 V}from"react/jsx-runtime";import u,{UUID as R}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 k,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:x,className:O,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 F=u(s.target),w=!!u(F).parent("."+B("Core")).length;u(F).parent("."+B("Selector")).length||w||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":k.isShowValidation(p,d,!!M),"data-component-id":d.componentId,"data-input-origin":d.componentId,className:[O,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:F}=c,w=s||F;if(r!=null&&r.onKeyDown&&(r==null||r.onKeyDown(c)),P&&k.SubmitForm(c,x),!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,T=null;u.scope(()=>{var Q,Y,Z,ee,te;let D=y.findIndex(z=>(z==null?void 0:z.id)==i);if(h==1){if(T=(Q=y[0])==null?void 0:Q.id,w){T=y[q].id;return}if(D==-1||D==q)return;T=(Y=y[D+1])==null?void 0:Y.id}else{if(T=(Z=y[q])==null?void 0:Z.id,w){T=(ee=y[0])==null?void 0:ee.id;return}if(D==-1||D==0)return;T=(te=y[D-1])==null?void 0:te.id}}),m(T)}),g=="Escape")S(!1);else if(g=="Tab")S(!1);else if(g=="Backspace")I(h=>f(n({},h),{dataValue:null,eventType:"update",eventID:R()}));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:R()})),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:x,className:O,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":k.isShowValidation(p,d,!!M),"data-component-id":d.componentId,"data-input-origin":d.componentId,className:[O,B("Core")].join(" "),onKeyDown:s=>{N&&N(s),P&&k.SubmitForm(s,x)},onChange:s=>{let{value:F}=s.target;p.ok&&b({ok:!1,notice:[]}),I(w=>f(n({},w),{dataValue:F,eventType:"update",eventID:R()})),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},R()):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:R()})),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,x;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(O=>(O==null?void 0:O.value)===e.value))==null?void 0:L.id)||((x=e.options[0])==null?void 0:x.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}),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:R()},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
+ import{b as o,c as u,d as H}from"../../chunk-C5N2D3ZX.js";import{Fragment as J,jsx as a,jsxs as T}from"react/jsx-runtime";import d,{UUID as C}from"jmini";import{useState as A,useEffect as $}from"react";import{ExtractStyles as Ve}from"../../@utils";import{Box as _,Span as Te,FAI as le,Column as Oe}from"../../atoms";import{Literal as W,Row as j}from"../../mols";import{Button as Fe}from"../Button";import{Sheet as xe}from"../Sheet";import{OptionalInputWrapper as De,BoxWrapper as we,CoreEffects as k,DefaultBoxishStyles as Re}from"./core";import{InputAutocompleteClasses as B}from"../../@styles/componentClasses";import{InputLabel as ke}from"./Label";import{RightIcon as Ae}from".";function Be(e){let{value:t,states:l}=e,{required:n,options:c}=l,y=[];return n&&t===null&&y.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!y.filter(({type:S})=>S=="invalid").length,notice:y}}const ae={FilterSelectableOptions:(e,t)=>{let l=e.rootStates.options;return t||(l=l.filter(n=>(n==null?void 0:n.type)!="label")),l}},V={Shallow:e=>{let{rootStates:t,val_status:l}=e,n=Ve(t);return a(_,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:a(W.Description,u(o({className:t.className},n),{position:"absolute",width:1,freeCSS:u(o({},n.freeCSS),{color:"orange"}),children:a(_,{"data-input-value-shallow":l.componentId,children:"A"})}))})},Button:e=>T(J,{children:[a(V.LegacySelector,o({},e)),a(V.Original,o({},e))]}),Placeholder:e=>!e.rootStates.placeholder||e.val_status.dataValue!==null?null:a(_,{position:"absolute",opacity:"middle",fontColor:"3.blur",children:e.rootStates.placeholder||""}),Original:e=>{let{rootStates:t,val_preventOpenSelectorOnFocus:l,set_preventOpenSelectorOnFocus:n,val_optionFocused:c,set_optionFocused:y,val_validate:S,set_validate:I,val_status:p,set_status:b,val_selectorOpen:g,set_selectorOpen:f}=e,U=t,{tone:E,required:L,form:x,className:O,label:ne,isLabelActive:re,placeholder:se,enableFormSubmit:P,emptySelect:X,checkValidationAtFirst:M,onValidate:ie,onValidateDelay:ce,onUpdateValue:ue,onUpdateValidValue:de,onUserAction:pe,value:N="",options:K,leftIndicator:Se,rightIndicator:G,leftIcon:fe,rightIcon:me,componentId:ye,status_id:ve,wrapStyles:ge,SelectedCellStyles:be,SelectorCellStyles:Ie,SelectorMode:he,SelectorStyles:Ce,SelectorPosition:_e}=U,r=H(U,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","SelectedCellStyles","SelectorCellStyles","SelectorMode","SelectorStyles","SelectorPosition"]);return $(()=>{if(e.rootStates.SelectorMode!="original"||t.disabled)return;let s="select-click-"+t.componentId;if(g){if(!d('[data-input-origin="'+t.componentId+'"]'))return;d(document).addEvent({eventID:s,eventType:"click",callback:i=>{let D=d(i.target),w=!!d(D).parent("."+B("Core")).length;d(D).parent("."+B("Selector")).length||w||f(!1)}})}else d(document).removeEvent([s])},[g]),$(()=>{if(e.rootStates.SelectorMode!="original"||p.eventType=="init"||!g)return;let s=d('[data-input-origin="'+t.componentId+'"]');s&&s.focus()},[p.dataValue]),e.rootStates.SelectorMode!="original"?null:T(J,{children:[a(_,u(o({tabIndex:0},r),{"data-disabled":t.disabled,"data-show-validation":k.isShowValidation(S,p,!!M),"data-component-id":p.componentId,"data-input-origin":p.componentId,className:[O,B("Core")].join(" "),onFocus:s=>{if(r!=null&&r.onFocus&&(r==null||r.onFocus(s)),b(m=>u(o({},m),{eventID:C(),eventType:"focus.start",isFocusing:!0})),!t.disabled){if(l)return n(!1);f(!0)}},onBlur:s=>{r!=null&&r.onBlur&&(r==null||r.onBlur(s)),b(m=>u(o({},m),{eventID:C(),eventType:"focus.end",isFocusing:!1}))},onClick:s=>{r!=null&&r.onClick&&(r==null||r.onClick(s)),!t.disabled&&f(!0)},onKeyDown:s=>{let{key:m,metaKey:i,ctrlKey:D}=s,w=i||D;if(r!=null&&r.onKeyDown&&(r==null||r.onKeyDown(s)),P&&k.SubmitForm(s,x),!t.disabled){if(d.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(m))return;if(s.preventDefault(),!g)return f(!0);let h=m=="ArrowDown"?1:-1,v=ae.FilterSelectableOptions(e),q=v.length-1,F=null;d.scope(()=>{var Q,Y,Z,ee,te;let R=v.findIndex(z=>(z==null?void 0:z.id)==c);if(h==1){if(F=(Q=v[0])==null?void 0:Q.id,w){F=v[q].id;return}if(R==-1||R==q)return;F=(Y=v[R+1])==null?void 0:Y.id}else{if(F=(Z=v[q])==null?void 0:Z.id,w){F=(ee=v[0])==null?void 0:ee.id;return}if(R==-1||R==0)return;F=(te=v[R-1])==null?void 0:te.id}}),y(F)}),m=="Escape")f(!1);else if(m=="Tab")f(!1);else if(m=="Backspace")b(h=>u(o({},h),{dataValue:null,eventType:"update",eventID:C()}));else if(m==" ")s.preventDefault(),f(!0);else if(m=="Enter"){if(!g)return f(!0);s.preventDefault();let h=t.options.find(v=>(v==null?void 0:v.id)==c);if(!h)return;b(v=>u(o({},v),{dataValue:h==null?void 0:h.value,eventType:"update",eventID:C()})),f(!1)}}},children:T(j.Left,{gap:0,children:[a(Te,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),T(j.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[a(V.Placeholder,o({},e)),a(V.Selected,o({},e))]})]})})),g&&a(V.Selector,o({},e))]})},LegacySelector:e=>{let{rootStates:t,val_preventOpenSelectorOnFocus:l,set_preventOpenSelectorOnFocus:n,val_optionFocused:c,set_optionFocused:y,val_validate:S,set_validate:I,val_status:p,set_status:b,val_selectorOpen:g,set_selectorOpen:f}=e,m=t,{tone:E,required:L,form:x,className:O,label:ne,isLabelActive:re,placeholder:se,enableFormSubmit:P,emptySelect:X,checkValidationAtFirst:M,onValidate:ie,onValidateDelay:ce,onUpdateValue:ue,onUpdateValidValue:de,onUserAction:pe,onKeyDown:N,onChange:K,value:Se="",options:G,leftIndicator:fe,rightIndicator:me,leftIcon:ye,rightIcon:ve,componentId:ge,status_id:be,wrapStyles:Ie,SelectedCellStyles:he,SelectorCellStyles:Ce,SelectorMode:_e,SelectorStyles:r,SelectorPosition:U}=m,s=H(m,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","onKeyDown","onChange","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","SelectedCellStyles","SelectorCellStyles","SelectorMode","SelectorStyles","SelectorPosition"]);return e.rootStates.SelectorMode!="legacy"?null:T(_,u(o({htmlTag:"select",tabIndex:0},s),{"data-disabled":t.disabled,"data-show-validation":k.isShowValidation(S,p,!!M),"data-component-id":p.componentId,"data-input-origin":p.componentId,className:[O,B("Core")].join(" "),onKeyDown:i=>{N&&N(i),P&&k.SubmitForm(i,x)},onChange:i=>{let{value:D}=i.target;S.ok&&I({ok:!1,notice:[]}),b(w=>u(o({},w),{dataValue:D,eventType:"update",eventID:C()})),K&&K(i)},children:[!!X&&a("option",{value:"null",children:"\u9078\u629E"}),G.map(i=>d.is.nullish(i==null?void 0:i.value)?null:a("option",{value:i==null?void 0:i.value,children:i.label},String(i==null?void 0:i.value)))]}))},Selector:e=>{var n;$(()=>{let c=d(`[data-selector-id="${e.val_status.componentId}"]`)[0];if(!c)return;let y=d(`[data-select-input-value="${e.val_optionFocused}"]`)[0];y&&(c.scrollTop=y.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(_,u(o({},l),{children:a(xe.Body,u(o({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:o({minWidth:12*6,maxHeight:12*24},(n=e.rootStates.SelectorStyles)==null?void 0:n.freeCSS),children:T(Oe,{gap:"1/12",padding:[1,0],children:[t.map((c,y)=>{if(!c)return null;let{type:S,value:I}=c,p=e.val_optionFocused==c.id,b=e.val_status.dataValue===I;return S=="label"?a(_,{children:c.label},C()):a(Fe.Sub.S,u(o({"data-select-input-value":c.id,color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1],isActive:b||p,isActiveStyles:p?{backgroundColor:"cloud"}:{backgroundColor:"theme.opa.few",fontColor:"theme"}},e.rootStates.SelectorCellStyles),{onClick:g=>{e.set_status(f=>u(o({},f),{dataValue:I,eventType:"update",eventID:C()})),e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0)},children:T(j.Left,{gap:"1/2",children:[b&&a(le.Check,{fontColor:"theme"}),a(W.Supplement,{transition:"short",flexSizing:0,children:c.label})]})}),c.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&&d.scope(()=>{let l=e.rootStates.options.find(n=>d.is.equal(n==null?void 0:n.value,e.val_status.dataValue));l&&t.push(a(_,u(o({},e.rootStates.SelectedCellStyles),{children:l.label}),String(l==null?void 0:l.value)))}),a(J,{children:t})},Core:e=>{var L,x;let{value:t}=e,[l,n]=A(k.DefaultStatus(e.componentId,t)),[c,y]=A(!1),[S,I]=A(!1),[p,b]=A(((L=e.options.find(O=>(O==null?void 0:O.value)===e.value))==null?void 0:L.id)||((x=e.options[0])==null?void 0:x.id)||""),[g,f]=A({ok:!1,notice:[]}),E={rootStates:e,val_preventOpenSelectorOnFocus:c,set_preventOpenSelectorOnFocus:y,val_optionFocused:p,set_optionFocused:b,val_selectorOpen:S,set_selectorOpen:I,val_status:l,set_status:n,val_validate:g,set_validate:f};return k.CommonEffects({type:"select",states:e,val_status:l,set_status:n,val_validate:g,set_validate:f,SystemValidation:Be}),T(we,{val_status:l,set_status:n,val_validate:g,states:e,children:[a(ke,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:e.isLabelActive||l.dataValue!==null}),a(V.Shallow,o({},E)),a(V.Button,o({},E))]})}},oe=e=>{var l;let t=o({},e);return t=u(o({emptySelect:!0,SelectorMode:"original",SelectorPosition:3},t),{freeCSS:o({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((n,c)=>{if(!n)return;let{type:y,value:S,searchValue:I}=n,p=I||d.is.string(S)&&S||d.Stringify(S||"")||"";t.options[c]=u(o({id:C()},n),{value:S,searchValue:p,type:y||"selector"})}),d.is.nullish(t.rightIcon)&&(t.rightIcon=a(Ae,{ssSphere:2,children:a(le.AngleDown,{})})),a(De,{componentId:t.componentId,children:V.Core,states:Re(t)})};export{oe as Select,oe as default};
@@ -1 +1 @@
1
- import{b as h,c as I,d as k}from"../../chunk-C5N2D3ZX.js";import{jsx as p,jsxs as W}from"react/jsx-runtime";import L,{UUID as E}from"jmini";import{useState as B,useEffect as P}from"react";import{$$fromRoot as D,GenerateHTMLProps as $}from"../../@utils";import{Box as x,Flex as A,Column as q}from"../../atoms";import{Button as O}from"../Button";import{OptionalInputWrapper as G,BoxWrapper as X,CoreEffects as F}from"./core";import{InputSliderClasses as c}from"../../@styles/componentClasses";function j(t){let{value:e,states:n}=t,{required:s}=n,o=[];return s&&!e&&o.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!o.filter(({type:i})=>i=="invalid").length,notice:o}}const z=t=>{let{value:e,val_status:n}=t,{min:s,max:o,step:i}=n;e=Math.max(e,s),e=Math.min(e,o);let a=e/o*o;return a=Math.round(a/i),{stepValue:a*i,stepIndex:a,positionLeft:a*i/o*100+"%"}},N={IndicatorLabels:t=>{let{componentId:e,min:n,max:s,step:o,customLegends:i}=t,r=[],a=Math.round(n/o),d=Math.round(s/o),S=d-a+1;for(var u=a;u<=d;u++){let l=u*o;l=Math.max(l,n),l=Math.min(l,s);let f=l/s*100+"%";r.push(p(x,{className:c("Label"),id:"Legend-"+e+"-"+u,display:u==a||u==d?"flex":"none",position:"absolute",top:0,unitHeight:1,unitWidth:1.5,transition:"middle",fontColor:"1.clear",verticalAlign:"center",horizontalAlign:"center",freeCSS:{left:f,whiteSpace:"nowrap",textAlign:"center"},children:i?i(l):l.rank()},l))}return P(()=>{const l=()=>{let f=D("#Labels-"+e),{width:v}=f.position(),C=Math.round(v/50)-1,g=Math.round(S/C);for(let m=a+1;m<d;m++)D("#Legend-"+e+"-"+m).css({display:m%g==0?"flex":"none"})};return L(window).addEvent({eventID:"SliderResizeCallback-"+e,eventType:"resize",callback:()=>{l()}}),l(),()=>{L(window).removeEvent("SliderResizeCallback-"+e)}},[]),p(A,{className:c("Labels"),verticalAlign:"center",horizontalAlign:"between",fontSize:"0.xs",position:"relative",unitHeight:1,id:"Labels-"+e,children:p(x,{position:"absolute",top:0,left:0,bottom:0,freeCSS:{right:12*1.5},children:r})})},Rail:t=>{let{val_status:e,set_status:n,DotData:s,form:o,enableFormSubmit:i}=t,{componentId:r}=e;return W(A,{className:c("Rail"),position:"relative",paddingLeft:"1/2",unitHeight:1.5,verticalAlign:"center",freeCSS:{zIndex:1,cursor:"pointer"},onPointerDown:a=>{t.rootStates.disabled||(a.stopPropagation(),y.Effects.Start(a,{val_status:e,set_status:n,DotData:s}))},children:[p(x,{className:c("Bar"),backgroundColor:"layer.4",position:"relative",borderRadius:"1.tone.primary",transition:"middle",flexSizing:"none",unitHeight:"2/3",width:1,id:r+"_Bar",children:p(x,{className:c("BarColor"),position:"relative",height:1,width:0,left:0,transition:"long",borderRadius:"inherit",backgroundColor:t.color,opacity:"middle",overflow:"hidden",freeCSS:{width:s.positionLeft},id:r+"_BarColor"})}),p(x,{className:c("BallWrap"),position:"absolute",top:0,left:0,bottom:0,freeCSS:{right:12*1.5},children:p(O.Plain,{className:c("Ball"),position:"absolute",boxShadow:"1.remark",backgroundColor:t.color,top:0,left:0,ssSquare:1.5,borderRadius:"1.tone.primary",freeCSS:{zIndex:2,left:s.positionLeft},id:r+"_Ball",onKeyDown:a=>{y.KeyDownEvent({event:a,val_status:e,set_status:n,DotData:s}),i&&F.SubmitForm(a,o)}})})]})}},y={Effects:{Start:(t,e)=>{L(document).addEvent({eventID:"SliderMouseMove",eventType:"mousemove",callback:n=>{y.Effects.Move(n,e)},options:{passive:!1}}).addEvent({eventID:"SliderTouchMove",eventType:"touchmove",callback:n=>{y.Effects.Move(n,e)},options:{passive:!1}}).addEvent({eventID:"SliderMouseUp",eventType:"mouseup",callback:()=>{y.Effects.End()}}).addEvent({eventID:"SliderTouchEnd",eventType:"touchend",callback:()=>{y.Effects.End()}})},Move:(t,e)=>{let n=L.getCursor(t).x,{val_status:s,set_status:o}=e,{componentId:i,min:r,max:a}=s,d=D("#"+i+"_Ball"),S=D("#"+i+"_Bar"),u=D("#"+i+"_BarColor"),{width:l,left:f}=S.position(),v=(n-f)/l;v=Math.max(v,0),v=Math.min(v,1);let C=v*a,g=z({value:C,val_status:s}),m=g.positionLeft,w=g.stepValue;return d.css({left:m}),u.css({width:m}),o(R=>{let T=R.dataValue;return w==T?R:I(h({},R),{dataValue:w,eventType:"update",eventID:E()})}),t.preventDefault(),t.stopPropagation(),!1},End:()=>{L(document).removeEvent(["SliderMouseMove","SliderTouchMove","SliderMouseUp","SliderTouchEnd"])}},KeyDownEvent:t=>{let{event:e,val_status:n,set_status:s}=t,{min:o,max:i,step:r}=n,{key:a,metaKey:d,ctrlKey:S}=e,u=S||d,l=n.dataValue;a.match(/Arrow/)&&(e.preventDefault(),a.match(/Left|Up/)?u?l=o:l-=r:a.match(/Right|Down/)&&(u?l=i:l+=r),l=Math.max(Math.min(l,i),o),s(f=>I(h({},f),{dataValue:l,eventType:"update",eventID:E()})))}},J=t=>{let V=t,{color:e="theme",required:n,form:s="",legends:{enable:o=!0,custom:i,showAlways:r=!1}={},min:a,max:d,step:S,enableFormSubmit:u,checkValidationAtFirst:l,onValidate:f,onValidateDelay:v,onUpdateValue:C,onUpdateValidValue:g,value:m="",className:w,wrapStyles:R}=V,T=k(V,["color","required","form","legends","min","max","step","enableFormSubmit","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","value","className","wrapStyles"]),[b,_]=B({componentId:t.componentId||"",dataValue:m,min:a,max:d,step:S,eventType:"init",eventID:E()}),[M,K]=B({ok:!1,notice:[]});F.CommonEffects({type:"slider",states:t,val_status:b,set_status:_,val_validate:M,set_validate:K,SystemValidation:j});let U=z({value:b.dataValue,val_status:b});return p(X,{val_status:b,set_status:_,val_validate:M,states:t,children:W(q,I(h({gap:"1/2",flexSizing:"auto"},T),{className:[c("Wrap"),w,c("ShowLegendsAlways_"+r)].join(" "),children:[p(N.Rail,{rootStates:t,color:e,val_status:b,set_status:_,DotData:U,form:s,enableFormSubmit:u}),!!o&&p(N.IndicatorLabels,{componentId:b.componentId,min:a,max:d,step:S,customLegends:i})]}))})},H=t=>{let e=I(h({},t),{freeCSS:h({minWidth:120},t.freeCSS)});return p(G,{componentId:t.componentId,children:J,states:$(e)})};export{H as Slider,H as default};
1
+ import{b,c as h,d as B}from"../../chunk-C5N2D3ZX.js";import{jsx as p,jsxs as U}from"react/jsx-runtime";import L,{UUID as x}from"jmini";import{useState as k,useEffect as $}from"react";import{$$fromRoot as C,GenerateHTMLProps as q}from"../../@utils";import{Box as w,Flex as A,Column as O}from"../../atoms";import{Button as G}from"../Button";import{OptionalInputWrapper as X,BoxWrapper as j,CoreEffects as F}from"./core";import{InputSliderClasses as m}from"../../@styles/componentClasses";function J(t){let{value:e,states:o}=t,{required:s}=o,n=[];return s&&!e&&n.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!n.filter(({type:i})=>i=="invalid").length,notice:n}}const z=t=>{let{value:e,val_status:o}=t,{min:s,max:n,step:i}=o;e=Math.max(e,s),e=Math.min(e,n);let a=e/n*n;return a=Math.round(a/i),{stepValue:a*i,stepIndex:a,positionLeft:a*i/n*100+"%"}},N={IndicatorLabels:t=>{let{componentId:e,min:o,max:s,step:n,customLegends:i}=t,u=[],a=Math.round(o/n),r=Math.round(s/n),c=r-a+1;for(var d=a;d<=r;d++){let l=d*n;l=Math.max(l,o),l=Math.min(l,s);let S=l/s*100+"%";u.push(p(w,{className:m("Label"),id:"Legend-"+e+"-"+d,display:d==a||d==r?"flex":"none",position:"absolute",top:0,unitHeight:1,unitWidth:1.5,transition:"middle",fontColor:"1.clear",verticalAlign:"center",horizontalAlign:"center",freeCSS:{left:S,whiteSpace:"nowrap",textAlign:"center"},children:i?i(l):l.rank()},l))}return $(()=>{const l=()=>{let S=C("#Labels-"+e),{width:f}=S.position(),T=Math.round(f/50)-1,I=Math.round(c/T);for(let v=a+1;v<r;v++)C("#Legend-"+e+"-"+v).css({display:v%I==0?"flex":"none"})};return L(window).addEvent({eventID:"SliderResizeCallback-"+e,eventType:"resize",callback:()=>{l()}}),l(),()=>{L(window).removeEvent("SliderResizeCallback-"+e)}},[]),p(A,{className:m("Labels"),verticalAlign:"center",horizontalAlign:"between",fontSize:"0.xs",position:"relative",unitHeight:1,id:"Labels-"+e,children:p(w,{position:"absolute",top:0,left:0,bottom:0,freeCSS:{right:12*1.5},children:u})})},Rail:t=>{let{val_status:e,set_status:o,DotData:s,form:n,enableFormSubmit:i}=t,{componentId:u}=e;return U(A,{className:m("Rail"),position:"relative",paddingLeft:"1/2",unitHeight:1.5,verticalAlign:"center",freeCSS:{zIndex:1,cursor:"pointer"},onPointerDown:a=>{t.rootStates.disabled||(a.stopPropagation(),g.Effects.Start(a,{val_status:e,set_status:o,DotData:s}))},children:[p(w,{className:m("Bar"),backgroundColor:"layer.4",position:"relative",borderRadius:"1.tone.primary",transition:"middle",flexSizing:"none",unitHeight:"2/3",width:1,id:u+"_Bar",children:p(w,{className:m("BarColor"),position:"relative",height:1,width:0,left:0,transition:"long",borderRadius:"inherit",backgroundColor:t.color,opacity:"middle",overflow:"hidden",freeCSS:{width:s.positionLeft},id:u+"_BarColor"})}),p(w,{className:m("BallWrap"),position:"absolute",top:0,left:0,bottom:0,freeCSS:{right:12*1.5},children:p(G.Plain,{className:m("Ball"),position:"absolute",boxShadow:"1.remark",backgroundColor:t.color,top:0,left:0,ssSquare:1.5,borderRadius:"1.tone.primary",freeCSS:{zIndex:2,left:s.positionLeft},id:u+"_Ball",onKeyDown:a=>{g.KeyDownEvent({event:a,val_status:e,set_status:o,DotData:s}),i&&F.SubmitForm(a,n)},onFocus:a=>{o(r=>h(b({},r),{eventID:x(),eventType:"focus.start",isFocusing:!0}))},onBlur:a=>{o(r=>h(b({},r),{eventID:x(),eventType:"focus.end",isFocusing:!1}))}})})]})}},g={Effects:{Start:(t,e)=>{L(document).addEvent({eventID:"SliderMouseMove",eventType:"mousemove",callback:o=>{g.Effects.Move(o,e)},options:{passive:!1}}).addEvent({eventID:"SliderTouchMove",eventType:"touchmove",callback:o=>{g.Effects.Move(o,e)},options:{passive:!1}}).addEvent({eventID:"SliderMouseUp",eventType:"mouseup",callback:()=>{g.Effects.End()}}).addEvent({eventID:"SliderTouchEnd",eventType:"touchend",callback:()=>{g.Effects.End()}})},Move:(t,e)=>{let o=L.getCursor(t).x,{val_status:s,set_status:n}=e,{componentId:i,min:u,max:a}=s,r=C("#"+i+"_Ball"),c=C("#"+i+"_Bar"),d=C("#"+i+"_BarColor"),{width:l,left:S}=c.position(),f=(o-S)/l;f=Math.max(f,0),f=Math.min(f,1);let T=f*a,I=z({value:T,val_status:s}),v=I.positionLeft,R=I.stepValue;return r.css({left:v}),d.css({width:v}),n(D=>{let E=D.dataValue;return R==E?D:h(b({},D),{dataValue:R,eventType:"update",eventID:x()})}),t.preventDefault(),t.stopPropagation(),!1},End:()=>{L(document).removeEvent(["SliderMouseMove","SliderTouchMove","SliderMouseUp","SliderTouchEnd"])}},KeyDownEvent:t=>{let{event:e,val_status:o,set_status:s}=t,{min:n,max:i,step:u}=o,{key:a,metaKey:r,ctrlKey:c}=e,d=c||r,l=o.dataValue;a.match(/Arrow/)&&(e.preventDefault(),a.match(/Left|Up/)?d?l=n:l-=u:a.match(/Right|Down/)&&(d?l=i:l+=u),l=Math.max(Math.min(l,i),n),s(S=>h(b({},S),{dataValue:l,eventType:"update",eventID:x()})))}},Q=t=>{let V=t,{color:e="theme",required:o,form:s="",legends:{enable:n=!0,custom:i,showAlways:u=!1}={},min:a,max:r,step:c,enableFormSubmit:d,checkValidationAtFirst:l,onValidate:S,onValidateDelay:f,onUpdateValue:T,onUpdateValidValue:I,onUserAction:v,value:R="",className:D,wrapStyles:E}=V,W=B(V,["color","required","form","legends","min","max","step","enableFormSubmit","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","className","wrapStyles"]),[y,_]=k({componentId:t.componentId||"",dataValue:R,min:a,max:r,step:c,eventType:"init",eventID:x()}),[M,K]=k({ok:!1,notice:[]});F.CommonEffects({type:"slider",states:t,val_status:y,set_status:_,val_validate:M,set_validate:K,SystemValidation:J});let P=z({value:y.dataValue,val_status:y});return p(j,{val_status:y,set_status:_,val_validate:M,states:t,children:U(O,h(b({gap:"1/2",flexSizing:"auto"},W),{className:[m("Wrap"),D,m("ShowLegendsAlways_"+u)].join(" "),children:[p(N.Rail,{rootStates:t,color:e,val_status:y,set_status:_,DotData:P,form:s,enableFormSubmit:d}),!!n&&p(N.IndicatorLabels,{componentId:y.componentId,min:a,max:r,step:c,customLegends:i})]}))})},H=t=>{let e=h(b({},t),{freeCSS:b({minWidth:120},t.freeCSS)});return p(X,{componentId:t.componentId,children:Q,states:q(e)})};export{H as Slider,H as default};
@@ -1 +1 @@
1
- import{b as a,c as i,d as k}from"../../chunk-C5N2D3ZX.js";import{jsx as t,jsxs as N}from"react/jsx-runtime";import{UUID as F}from"jmini";import{useState as M}from"react";import c from"../../atoms/Box";import{Row as U}from"../../mols";import{Label as W}from"../Button";import{OptionalInputWrapper as A,BoxWrapper as P,CoreEffects as D}from"./core";import{InputSwitchClasses as f}from"../../@styles/componentClasses";function H(e){let{value:o,states:n}=e,{required:R}=n,l=[];return R&&!o&&l.push({type:"invalid",label:"ON\u306B\u306A\u3063\u3066\u3044\u307E\u305B\u3093"}),{ok:!l.filter(({type:m})=>m=="invalid").length,notice:l}}const O=e=>{let V=e,{componentId:o,color:n="posi",required:R,form:l,id:m,enableFormSubmit:z,checkValidationAtFirst:q,onChange:w,onKeyDown:x,onValidate:K,onValidateDelay:$,onUpdateValue:G,onUpdateValidValue:J,size:C="regular",value:B="",icon:v="",isApply:s=!1}=V,E=k(V,["componentId","color","required","form","id","enableFormSubmit","checkValidationAtFirst","onChange","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","size","value","icon","isApply"]),[r,S]=M({componentId:e.componentId||"",dataValue:B,eventType:"init",eventID:F()}),[b,T]=M({ok:!1,notice:[]}),p=!!r.dataValue;D.CommonEffects({type:"switch",states:e,val_status:r,set_status:S,val_validate:b,set_validate:T,SystemValidation:H});let h="middle",g=5,I=3;return s&&(I=4),N(P,{val_status:r,set_status:S,val_validate:b,states:e,children:[t(c,a({htmlTag:"input",type:"checkbox","data-component-id":r.componentId,checked:r.dataValue,className:f("Input"),id:m,onKeyDown:d=>{x&&x(d),z&&D.SubmitForm(d,l)},onChange:d=>{let{checked:L}=d.target;b.ok&&T({ok:!1,notice:[]}),S(_=>i(a({},_),{dataValue:L,eventType:"update",eventID:F()})),w&&w(d)}},E)),t(W.Plain,{tabIndex:-1,htmlFor:m,padding:"1/4",transition:h,borderRadius:"1.tone.primary",className:f("Label"),children:t(c,i(a({},s?{padding:"1/4",isRounded:!0,backgroundColor:p?n:"layer.3"}:{}),{children:N(U.Center,{unitHeight:C=="small"?2:C=="regular"?2.5:C=="large"?3:0,position:"relative",freeCSS:{aspectRatio:(g+I)/g},children:[!s&&t(c,{position:"absolute",backgroundColor:p?n:"layer.5",isRounded:!0,transition:h,width:1,opacity:"middle",className:f("Bar"),freeCSS:{height:"40%"}}),t(c,{position:"absolute",top:0,backgroundColor:!s&&p?n:"white",transition:h,isRounded:!0,flexCenter:!0,boxShadow:"1.remark",className:f("Dot"),freeCSS:{height:"100%",aspectRatio:"1",left:p?`calc(${I.ratio(g+I)}%)`:0},children:v&&t(c,{transition:h,flexCenter:!0,fontColor:p?s?n:"white":"6.clear",children:v})})]})}))})]})},y=e=>{let o=a({},e);return o.value=!!o.value,o.color=o.color||"theme",t(A,{componentId:o.componentId,children:O,states:o})},u=y;u.S=e=>t(y,i(a({},e),{size:"small"})),u.R=e=>t(y,i(a({},e),{size:"regular"})),u.L=e=>t(y,i(a({},e),{size:"large"}));export{u as Switch,u as default};
1
+ import{b as o,c as l,d as D}from"../../chunk-C5N2D3ZX.js";import{jsx as a,jsxs as z}from"react/jsx-runtime";import{UUID as S}from"jmini";import{useState as M}from"react";import I from"../../atoms/Box";import{Row as U}from"../../mols";import{Label as A}from"../Button";import{OptionalInputWrapper as W,BoxWrapper as P,CoreEffects as N}from"./core";import{InputSwitchClasses as g}from"../../@styles/componentClasses";function H(e){let{value:n,states:s}=e,{required:x}=s,r=[];return x&&!n&&r.push({type:"invalid",label:"ON\u306B\u306A\u3063\u3066\u3044\u307E\u305B\u3093"}),{ok:!r.filter(({type:h})=>h=="invalid").length,notice:r}}const O=e=>{let B=e,{componentId:n,color:s="posi",required:x,form:r,id:h,enableFormSubmit:E,checkValidationAtFirst:q,onChange:F,onKeyDown:T,onValidate:K,onValidateDelay:$,onUpdateValue:G,onUpdateValidValue:J,onUserAction:Q,size:v="regular",value:L="",icon:V="",isApply:p=!1}=B,t=D(B,["componentId","color","required","form","id","enableFormSubmit","checkValidationAtFirst","onChange","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","size","value","icon","isApply"]),[u,c]=M({componentId:e.componentId||"",dataValue:L,eventType:"init",eventID:S()}),[R,k]=M({ok:!1,notice:[]}),d=!!u.dataValue;N.CommonEffects({type:"switch",states:e,val_status:u,set_status:c,val_validate:R,set_validate:k,SystemValidation:H});let y="middle",w=5,C=3;return p&&(C=4),z(P,{val_status:u,set_status:c,val_validate:R,states:e,children:[a(I,l(o({htmlTag:"input",type:"checkbox","data-component-id":u.componentId,checked:u.dataValue,className:g("Input"),id:h,onKeyDown:i=>{T&&T(i),E&&N.SubmitForm(i,r)},onChange:i=>{let{checked:m}=i.target;R.ok&&k({ok:!1,notice:[]}),c(_=>l(o({},_),{dataValue:m,eventType:"update",eventID:S()})),F&&F(i)}},t),{onFocus:i=>{t!=null&&t.onFocus&&(t==null||t.onFocus(i)),c(m=>l(o({},m),{eventID:S(),eventType:"focus.start",isFocusing:!0}))},onBlur:i=>{t!=null&&t.onBlur&&(t==null||t.onBlur(i)),c(m=>l(o({},m),{eventID:S(),eventType:"focus.end",isFocusing:!1}))}})),a(A.Plain,{tabIndex:-1,htmlFor:h,padding:"1/4",transition:y,borderRadius:"1.tone.primary",className:g("Label"),children:a(I,l(o({},p?{padding:"1/4",isRounded:!0,backgroundColor:d?s:"layer.3"}:{}),{children:z(U.Center,{unitHeight:v=="small"?2:v=="regular"?2.5:v=="large"?3:0,position:"relative",freeCSS:{aspectRatio:(w+C)/w},children:[!p&&a(I,{position:"absolute",backgroundColor:d?s:"layer.5",isRounded:!0,transition:y,width:1,opacity:"middle",className:g("Bar"),freeCSS:{height:"40%"}}),a(I,{position:"absolute",top:0,backgroundColor:!p&&d?s:"white",transition:y,isRounded:!0,flexCenter:!0,boxShadow:"1.remark",className:g("Dot"),freeCSS:{height:"100%",aspectRatio:"1",left:d?`calc(${C.ratio(w+C)}%)`:0},children:V&&a(I,{transition:y,flexCenter:!0,fontColor:d?p?s:"white":"6.clear",children:V})})]})}))})]})},b=e=>{let n=o({},e);return n.value=!!n.value,n.color=n.color||"theme",a(W,{componentId:n.componentId,children:O,states:n})},f=b;f.S=e=>a(b,l(o({},e),{size:"small"})),f.R=e=>a(b,l(o({},e),{size:"regular"})),f.L=e=>a(b,l(o({},e),{size:"large"}));export{f as Switch,f as default};
@@ -37,10 +37,6 @@ declare namespace TextField {
37
37
  };
38
38
  type WrapperStates = {
39
39
  rootStates: Input;
40
- val_focus: boolean;
41
- set_focus: React.Dispatch<React.SetStateAction<boolean>>;
42
- val_isComposing: boolean;
43
- set_isComposing: React.Dispatch<React.SetStateAction<boolean>>;
44
40
  val_status: InputTypes.Status.Text;
45
41
  set_status: React.Dispatch<React.SetStateAction<InputTypes.Status.Text>>;
46
42
  val_inputType: React.HTMLInputTypeAttribute;
@@ -1,3 +1,3 @@
1
- import{b as l,c,d as ne,e as de}from"../../chunk-C5N2D3ZX.js";import{Fragment as xe,jsx as n,jsxs as Y}from"react/jsx-runtime";import b,{UUID as M,useStore as fe}from"jmini";import{useState as K,useEffect as oe}from"react";import{$$fromRoot as Ne,ExtractStyles as _e}from"../../@utils";import{Box as k,FAI as De}from"../../atoms";import{Literal as re}from"../../mols";import{Tips as ge,Button as Le}from"..";import{faEye as Ee}from"@fortawesome/free-solid-svg-icons/faEye";import{OptionalInputWrapper as He,BoxWrapper as Ae,CoreEffects as W,DefaultBoxishStyles as Be}from"./core";import{InputLabel as Me}from"./Label";import{LeftIcon as $e,RightIcon as be}from".";const ze={katakana:{reg:/^[ァ-ヶー  ヲ-゚  ]*$/g,exist:!0,reason:"\u30AB\u30BF\u30AB\u30CA\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},"hankaku.katakana":{reg:/^[ヲ-゚  ]*$/g,exist:!0,reason:"\u534A\u89D2\u30AB\u30BF\u30AB\u30CA\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},number:{reg:/^-?[0-9\.]{0,}[0-9]{1,}$/g,exist:!0,reason:"\u534A\u89D2\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},digitNumber:{reg:/^-?[0-9\,\.]{0,}[0-9]{1,}$/g,exist:!0,reason:"\u534A\u89D2\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},fileName:{reg:/[¥\/:*\?\"\'\|\.\s\n\r\<\>]/g,exist:!1,reason:"\u7A7A\u767D\u307E\u305F\u306F\u4E00\u90E8\u306E\u7279\u6B8A\u6587\u5B57\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093"},creditCard:{reg:/^\d{14,16}$/g,exist:!0,reason:"14~16\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},email:{reg:/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]+\.[A-Za-z0-9]+$/,exist:!0,reason:Y(xe,{children:[n(k,{children:"\u25CB\u25CB\u25CB\u25CB@\u25CB\u25CB\u25CB\u25CB.\u25CB\u25CB\u25CB\u306E\u5F62\u5F0F\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),n(k,{children:"\u6700\u5F8C\u306E\u6587\u5B57\u306B.(\u30C9\u30C3\u30C8)\u3092\u5165\u308C\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"})]})},password:{reg:/^(?=[^A-Z]*[A-Z])(?=[^a-z]*[a-z])(?=[^0-9]*[0-9]).{8,}$/,exist:!0,reason:"8\u6587\u5B57\u4EE5\u4E0A\u3001\u534A\u89D2\u82F1\u6570\u5927\u5C0F\u6587\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},tel:{reg:/.*$/g,exist:!0,reason:Y(xe,{children:[n(k,{children:"0\u304B\u3089\u59CB\u307E\u308B\u756A\u53F7\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"}),n(k,{children:"9~12\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),n(k,{children:"\u6570\u5B57\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"})]})},url:{reg:/^https?:\/\/[^\n\s]+(\.|\:)[^\n\s\.\:]+$/,exist:!0,reason:"URL\u5F62\u5F0F : http(s)://\u25EF\u25EF\u25EF\u25EF"},postal:{reg:/^\d{7}$/g,exist:!0,reason:"7\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}},y={setSelection:t=>{let{id:a,restrict:o,val_status:s}=t,i=Ne("#"+a)[0];if(i&&s.prevValue&&s.formatValue){let{formatValue:e,prevValue:u,caretFrom:d,caretTo:r}=s;if(o=="creditCard")e.length>=u.length&&d%5==0&&(d++,r++),i.setSelectionRange(d,r);else if(o=="postal")e.length==5&&u.length==3&&(d++,r++),i.setSelectionRange(d,r);else if(o=="digitNumber"){let p=e.length-u.length;p==2&&(d++,r++),p==-2&&(d--,r--),i.setSelectionRange(d,r)}}},Validation:{System:t=>{let{value:a,states:o}=t,{restrict:s="text",defaultValidation:i,maxLength:e,multiline:u,required:d}=o,r=[];if(u||(e=e||255),b.is.exist(e)&&a.length>=Number(e)&&r.push({type:"invalid",label:e+"\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),a){let p=y.Validation.Text(a,s,i);p.ok||r.push({type:"invalid",label:p.body})}else d&&r.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"});return{ok:!r.filter(({type:p})=>p=="invalid").length,notice:r}},Text:(t,a,o)=>{let s={ok:!0,body:""};return(()=>{let i=o||ze[a];if(!i)return;let e=i.reason;if(i){let u=!!(+!!t.match(i.reg)^+!i.exist);s={ok:u,body:u?"":e}}})(),s},DataLeveling:t=>{let{restrict:a,allowDecimals:o,allowZeroStart:s,value:i=""}=t,e=String(i);["tel","number","digitNumber","postal","creditCard"].includes(a)&&(e=e.zen2hanNumber()),a=="katakana",a=="hankaku.katakana",["postal","creditCard"].includes(a)&&(e=e.removeLetters()),b.scope(()=>{if(!["number","digitNumber"].includes(a))return;e=e.replace(/(\.\d+)\..*/g,"$1").replace(/\.+/g,".").replace(/[^0-9.-]/g,"");let d=Number(e)<0||e[0]=="-";e=e.replace(/[^0-9.]/g,""),d&&(e="-"+e);let r=Number(o);o?e=e.replace(/(\.\d{0,})\..*/g,"$1").replace(/\.(\d{0,})/g,(p,g)=>g.length>r?"."+g.slice(0,r):p):e=e.replace(/\.\d?/g,""),b.scope(()=>{a=="number"&&(s||(e=e.replace(/^0(\d+)/g,"$1").replace(/^-0(\d+)/g,"-$1")))}),b.scope(()=>{let p=e.slice(-1);if(!e||p=="."||p=="-")return;let{min:g,max:S}=t;b.is.exist(g)&&b.is.number(g)&&Number(e)<Number(g)&&(e=String(g.toFixed(r))),b.is.exist(S)&&b.is.number(S)&&Number(e)>Number(S)&&(e=String(S.toFixed(r)))}),b.scope(()=>{if(!e||e=="-"||a!="digitNumber")return;let p=e.slice(-1),[g,S]=e.split(".");e=g.replace(/\B(?=(\d{3})+(?!\d))/g,","),S&&(e+="."+S),p=="."&&(e+=".")})});let u=e;return a=="digitNumber"||(a=="postal"?e.length>=4&&(u=e.clip(0,3)+"-"+e.clip(3)):a=="creditCard"&&(u=e.replace(/.{4}(?=.)/g,"$& "))),e=e.replace(/,/g,""),{formatValue:u,dataValue:e}}},Shallow:t=>{let{rootStates:a,val_status:o}=t,s=o.dataValue||"";oe(()=>{b.scope(()=>de(void 0,null,function*(){if(!a.multiline)return;let p=b('[data-input-origin="'+o.componentId+'"]'),g=b('[data-input-shallow="'+o.componentId+'"]'),S=b('[data-input-min-height-value-shallow="'+o.componentId+'"]'),T=b('[data-input-max-height-value-shallow="'+o.componentId+'"]');if(!p[0]||!g[0]||!S[0]||!T[0])return;let F=g.position(),D=S.position(),f=T.position(),C=0;a.autoHeight&&(C=F.height),C=Math.max(C,D.height),C=Math.min(C,f.height),p[0].style.height=C+"px"}))},[s]);let i=s||"";(!!s.match(/\n$/)||!s)&&(i+="T");let u="",d="";if(a.multiline){let p=a.minRows||1,g=a.maxRows||100;u=`
2
- T`.repeat(p-1),d=`
3
- T`.repeat(g-1)}let r=_e(a);return Y(k,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:[n(re.Description,c(l({className:a.className},r),{position:"absolute",width:1,freeCSS:c(l({},r.freeCSS),{color:"orange"}),"data-input-shallow":o.componentId,children:n(k,{"data-input-value-shallow":o.componentId,children:i})})),n(re.Description,c(l({className:a.className},r),{position:"absolute",left:0,freeCSS:c(l({},r.freeCSS),{backgroundColor:"transparent",color:"blue"}),"data-input-min-height-value-shallow":o.componentId,children:u})),n(re.Description,c(l({className:a.className},r),{position:"absolute",right:0,freeCSS:c(l({},r.freeCSS),{backgroundColor:"transparent",color:"red"}),"data-input-max-height-value-shallow":o.componentId,children:d}))]})},InputBox:t=>{let{rootStates:a,val_validate:o,set_validate:s,val_status:i,set_status:e,val_inputType:u,set_inputType:d,val_focus:r,set_focus:p,val_isComposing:g,set_isComposing:S}=t;if(a.multiline)return null;let pe=a,{componentId:T,tone:F,required:D,restrict:f="text",form:C,autoComplete:$="off",autoCapitalize:L="off",minRows:G,maxRows:he,multiline:se,autoHeight:Se,enableFormSubmit:X,clearButton:Q=!1,allowDecimals:A,allowZeroStart:O,checkValidationAtFirst:ue,onChange:j,onKeyDown:ee,onValidate:Ie,onValidateDelay:ve,onUpdateValue:Te,onUpdateValidValue:Re,value:ye="",leftIndicator:Ce,rightIndicator:we,leftIcon:I,rightIcon:Ve,maxLength:te,min:v,max:z,label:ce,isLabelActive:Ze,defaultValidation:Ue,wrapStyles:Ke}=pe,m=ne(pe,["componentId","tone","required","restrict","form","autoComplete","autoCapitalize","minRows","maxRows","multiline","autoHeight","enableFormSubmit","clearButton","allowDecimals","allowZeroStart","checkValidationAtFirst","onChange","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","maxLength","min","max","label","isLabelActive","defaultValidation","wrapStyles"]);return n(k,c(l({htmlTag:"input",type:u,inputMode:["number","digitNumber","creditCard"].includes(f)?"numeric":f=="email"?"email":"text","data-disabled":a.disabled,"data-show-validation":W.isShowValidation(o,i,!!ue),"data-component-id":i.componentId,"data-input-origin":i.componentId,value:i.formatValue,autoComplete:$,autoCapitalize:L,onKeyDown:x=>{let{key:R,target:N}=x,B=N,{selectionStart:P,selectionEnd:ae}=B,q=Number(P),Z=Number(ae);{let E=i.formatValue[Number(q)],H=i.formatValue[Number(q)-1];R=="Delete"&&(f=="creditCard"&&E==" "||f=="postal"&&E=="-"||f=="digitNumber"&&E==",")&&(B.setSelectionRange(q+1,Z+1),x.preventDefault()),R=="Backspace"&&(f=="creditCard"&&H==" "||f=="postal"&&H=="-"||f=="digitNumber"&&H==",")&&(B.setSelectionRange(q-1,Z-1),x.preventDefault()),R=="Enter"||R=="Tab"}b.scope(()=>{["number","digitNumber","creditCard"].includes(f)&&R=="Clear"&&e(E=>c(l({},E),{dataValue:"",formatValue:"",eventType:"update",eventID:M()}))}),b.scope(()=>{if(!["number","digitNumber"].includes(f)||!["ArrowUp","ArrowDown"].includes(R))return;let E=+(R=="ArrowUp")*2-1,H=i.dataValue.slice(-1),me=i.formatValue[Z-1],_=Z-1,V=String(i.formatValue),ie=i.dataValue.split(".")[1],ke=(ie==null?void 0:ie.length)||0;b.scope(()=>{if(!H){V="0";return}if(H=="-"){V+="0";return}if(H=="."){V+="0";return}if(Z==0)return;let le=String(V).slice(0,_).match(/\./),Fe=String(V).slice(_),J=String(Fe.toNumber().toFixed(0)).length;me=="."&&(J=1,_=V.split(".")[0].length-1),me==","&&(J+=1,_--),le&&(J=-1*(ke-J));let U=V[_].toNumber()+E;U<0?U=9:U>=10&&(U=0),V=V.partReplace(_,String(U)),setTimeout(()=>{B.setSelectionRange(_+1,_+1)},1)}),o.ok&&s({ok:!1,notice:[]}),e(le=>c(l(l({},le),y.Validation.DataLeveling({allowDecimals:A,allowZeroStart:O,min:v,max:z,restrict:f,value:V})),{eventType:"update",eventID:M()})),x.preventDefault()}),ee&&ee(x),X&&W.SubmitForm(x,C)},onChange:x=>{let{value:R,selectionStart:N,selectionEnd:B}=x.target,P=y.Validation.DataLeveling({allowDecimals:A,allowZeroStart:O,min:v,max:z,restrict:f,value:R});g&&(P.formatValue=R),P.formatValue!=i.formatValue&&(o.ok&&s({ok:!1,notice:[]}),e(ae=>c(l(l({},ae),P),{prevValue:i.formatValue,eventType:"update",eventID:M(),caretFrom:Number(N),caretTo:Number(B)})),j&&j(x))},width:1},m),{onFocus:x=>{m!=null&&m.onFocus&&(m==null||m.onFocus(x)),p(!0)},onBlur:x=>{m!=null&&m.onBlur&&(m==null||m.onBlur(x)),p(!1)},onCompositionStart:x=>{m!=null&&m.onCompositionStart&&(m==null||m.onCompositionStart(x)),S(!0)},onCompositionEnd:x=>{if(m!=null&&m.onCompositionEnd&&(m==null||m.onCompositionEnd(x)),f=="text")return;let R=y.Validation.DataLeveling({allowDecimals:A,allowZeroStart:O,min:v,max:z,restrict:f,value:i.formatValue});e(N=>c(l(l({},N),R),{prevValue:N.formatValue,eventType:"update",eventID:M(),caretFrom:Number(N.formatValue.length+1),caretTo:Number(N.formatValue.length+1)})),S(!1)}}))},TextAreaBox:t=>{let{rootStates:a,val_focus:o,set_focus:s,val_validate:i,set_validate:e,val_status:u,set_status:d,isShallow:r}=t,te=a,{componentId:p,tone:g,required:S,form:T,label:F,isLabelActive:D,minRows:f,maxRows:C,multiline:$,autoHeight:L,allowDecimals:G,allowZeroStart:he,enableFormSubmit:se,maxLength:Se,checkValidationAtFirst:X,onChange:Q,onKeyDown:A,onValidate:O,onValidateDelay:ue,onUpdateValue:j,onUpdateValidValue:ee,value:Ie="",leftIndicator:ve,rightIndicator:Te,leftIcon:Re,rightIcon:ye,defaultValidation:Ce,wrapStyles:we}=te,I=ne(te,["componentId","tone","required","form","label","isLabelActive","minRows","maxRows","multiline","autoHeight","allowDecimals","allowZeroStart","enableFormSubmit","maxLength","checkValidationAtFirst","onChange","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","defaultValidation","wrapStyles"]);return!a.multiline?null:n(k,c(l({htmlTag:"textarea","data-show-validation":W.isShowValidation(i,u,!!X),"data-input-origin":u.componentId,"data-component-id":u.componentId,value:u.dataValue,width:1},I),{onFocus:v=>{I!=null&&I.onFocus&&(I==null||I.onFocus(v)),s(!0)},onBlur:v=>{I!=null&&I.onBlur&&(I==null||I.onBlur(v)),s(!1)},onKeyDown:v=>{A&&A(v),se&&W.SubmitForm(v,T)},onChange:v=>{let{value:z}=v.target;i.ok&&e({ok:!1,notice:[]}),d(ce=>c(l({},ce),{dataValue:z,eventType:"update",eventID:M()})),Q&&Q(v)}}))}},Pe=t=>{let{componentId:a,restrict:o="text",value:s="",min:i,max:e,allowDecimals:u,allowZeroStart:d}=t,[r,p]=K(!1),[g,S]=K(!1),[T,F]=K({componentId:a,formatValue:"",dataValue:"",prevValue:"",eventType:"init",eventID:M(),caretFrom:null,caretTo:null}),[D,f]=K({ok:!1,notice:[]}),[C,$]=K(["password","concealed"].includes(o)&&"password"||"text");oe(()=>{F(G=>l(l({},G),y.Validation.DataLeveling({allowDecimals:u,allowZeroStart:d,min:i,max:e,restrict:o,value:s}))),fe.set({[a+":set_inputType"]:$})},[]);let L={rootStates:t,val_focus:r,set_focus:p,val_inputType:C,set_inputType:$,val_isComposing:g,set_isComposing:S,val_status:T,set_status:F,val_validate:D,set_validate:f};return W.CommonEffects({type:"textfield",states:t,val_status:T,set_status:F,val_validate:D,set_validate:f,SystemValidation:y.Validation.System,ExtraOverrideStates:()=>y.Validation.DataLeveling({allowDecimals:u,allowZeroStart:d,min:i,max:e,restrict:o,value:s})}),oe(()=>{y.setSelection({id:t.id,restrict:o,val_status:T})},[T]),Y(Ae,{val_status:T,set_status:F,val_validate:D,states:L.rootStates,children:[n(Me,{componentId:t.componentId,fontSize:t.fontSize,required:t.required,label:t.label,isActive:t.isLabelActive||r||!!T.dataValue}),n(y.Shallow,l({},L)),n(y.InputBox,l({},L)),n(y.TextAreaBox,l({},L))]})},w=t=>(t=l({autoHeight:!0,restrict:"text",fontSize:"inherit"},t),t.multiline?(t.minRows=t.minRows||5,t.maxRows=t.maxRows||20):(t.minRows=1,t.maxRows=1),n(He,{componentId:t.componentId,children:Pe,states:Be(t)})),h=w;h.Validate=y.Validation.Text,h.Katakana=t=>n(w,c(l({},t),{restrict:"katakana",multiline:!1,autoHeight:!1})),h.HankakuKatakana=t=>n(w,c(l({},t),{restrict:"hankaku.katakana",multiline:!1,autoHeight:!1})),h.CreditCard=t=>n(w,c(l({},t),{restrict:"creditCard",multiline:!1,autoHeight:!1})),h.Tel=t=>n(w,c(l({},t),{restrict:"tel",multiline:!1,autoHeight:!1})),h.Number=t=>n(w,c(l({},t),{restrict:"number",multiline:!1,autoHeight:!1})),h.DigitNumber=t=>n(w,c(l({},t),{restrict:"digitNumber",multiline:!1,autoHeight:!1})),h.Email=t=>n(w,c(l({},t),{restrict:"email",multiline:!1,autoHeight:!1})),h.Url=t=>n(w,c(l({},t),{restrict:"url",multiline:!1,autoHeight:!1})),h.Postal=t=>n(w,c(l({label:"\u90F5\u4FBF\u756A\u53F7"},t),{restrict:"postal",multiline:!1,autoHeight:!1,leftIcon:n($e,{ssSphere:2,fontColor:"4.thin",children:"\u3012"})})),h.Password=t=>n(w,c(l({label:"\u30D1\u30B9\u30EF\u30FC\u30C9",rightIcon:n(be,{ssSphere:2,padding:0,freeCSS:{pointerEvents:"all"},children:n(Le.Sub,{ssSphere:2,borderRadius:"3.tone.tertiary",fontColor:"theme",flexCenter:!0,height:1,ssEffectsOnActive:["expand"],onMouseOver:a=>{ge.open(a.currentTarget,"\u30C6\u30AD\u30B9\u30C8\u3092\u8868\u793A",24)},onMouseLeave:ge.abort,tabIndex:-1,onClick:a=>{b(a.target).parent().parent().find("input").callback(o=>{let s=o[0];if(!s)return;let i=s.dataset.componentId;if(!i)return;let e=fe.get(i+":set_inputType");e&&e(u=>u==="password"&&"text"||"password")})},children:n(De,{icon:Ee})})}),restrict:"password"},t),{multiline:!1,autoHeight:!1})),h.Concealed=t=>n(h.Password,c(l({label:"\u79D8\u5BC6\u9375"},t),{restrict:"concealed"})),h.Money={JPY:t=>n(h.DigitNumber,c(l({rightIcon:n(be,{ssSphere:2,fontColor:"4.thin",children:"\u5186"})},t),{multiline:!1,autoHeight:!1}))};export{h as TextField,Pe as TextInput,h as default};
1
+ import{b as i,c as r,d as ae,e as ue}from"../../chunk-C5N2D3ZX.js";import{Fragment as de,jsx as s,jsxs as Y}from"react/jsx-runtime";import h,{UUID as T,useStore as pe}from"jmini";import{useState as ie,useEffect as ne}from"react";import{$$fromRoot as ke,ExtractStyles as De}from"../../@utils";import{Box as k,FAI as Ne}from"../../atoms";import{Literal as le}from"../../mols";import{Tips as ce,Button as Ee}from"..";import{faEye as Le}from"@fortawesome/free-solid-svg-icons/faEye";import{OptionalInputWrapper as _e,BoxWrapper as He,CoreEffects as K,DefaultBoxishStyles as Ae}from"./core";import{InputLabel as Be}from"./Label";import{LeftIcon as Me,RightIcon as me}from".";const $e={katakana:{reg:/^[ァ-ヶー  ヲ-゚  ]*$/g,exist:!0,reason:"\u30AB\u30BF\u30AB\u30CA\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},"hankaku.katakana":{reg:/^[ヲ-゚  ]*$/g,exist:!0,reason:"\u534A\u89D2\u30AB\u30BF\u30AB\u30CA\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},number:{reg:/^-?[0-9\.]{0,}[0-9]{1,}$/g,exist:!0,reason:"\u534A\u89D2\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},digitNumber:{reg:/^-?[0-9\,\.]{0,}[0-9]{1,}$/g,exist:!0,reason:"\u534A\u89D2\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},fileName:{reg:/[¥\/:*\?\"\'\|\.\s\n\r\<\>]/g,exist:!1,reason:"\u7A7A\u767D\u307E\u305F\u306F\u4E00\u90E8\u306E\u7279\u6B8A\u6587\u5B57\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093"},creditCard:{reg:/^\d{14,16}$/g,exist:!0,reason:"14~16\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},email:{reg:/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]+\.[A-Za-z0-9]+$/,exist:!0,reason:Y(de,{children:[s(k,{children:"\u25CB\u25CB\u25CB\u25CB@\u25CB\u25CB\u25CB\u25CB.\u25CB\u25CB\u25CB\u306E\u5F62\u5F0F\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),s(k,{children:"\u6700\u5F8C\u306E\u6587\u5B57\u306B.(\u30C9\u30C3\u30C8)\u3092\u5165\u308C\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"})]})},password:{reg:/^(?=[^A-Z]*[A-Z])(?=[^a-z]*[a-z])(?=[^0-9]*[0-9]).{8,}$/,exist:!0,reason:"8\u6587\u5B57\u4EE5\u4E0A\u3001\u534A\u89D2\u82F1\u6570\u5927\u5C0F\u6587\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},tel:{reg:/.*$/g,exist:!0,reason:Y(de,{children:[s(k,{children:"0\u304B\u3089\u59CB\u307E\u308B\u756A\u53F7\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"}),s(k,{children:"9~12\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),s(k,{children:"\u6570\u5B57\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"})]})},url:{reg:/^https?:\/\/[^\n\s]+(\.|\:)[^\n\s\.\:]+$/,exist:!0,reason:"URL\u5F62\u5F0F : http(s)://\u25EF\u25EF\u25EF\u25EF"},postal:{reg:/^\d{7}$/g,exist:!0,reason:"7\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}},y={setSelection:t=>{let{id:n,restrict:o,val_status:p}=t,a=ke("#"+n)[0];if(a&&p.prevValue&&p.formatValue){let{formatValue:e,prevValue:f,caretFrom:b,caretTo:l}=p;if(o=="creditCard")e.length>=f.length&&b%5==0&&(b++,l++),a.setSelectionRange(b,l);else if(o=="postal")e.length==5&&f.length==3&&(b++,l++),a.setSelectionRange(b,l);else if(o=="digitNumber"){let c=e.length-f.length;c==2&&(b++,l++),c==-2&&(b--,l--),a.setSelectionRange(b,l)}}},Validation:{System:t=>{let{value:n,states:o}=t,{restrict:p="text",defaultValidation:a,maxLength:e,multiline:f,required:b}=o,l=[];if(f||(e=e||255),h.is.exist(e)&&n.length>=Number(e)&&l.push({type:"invalid",label:e+"\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),n){let c=y.Validation.Text(n,p,a);c.ok||l.push({type:"invalid",label:c.body})}else b&&l.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"});return{ok:!l.filter(({type:c})=>c=="invalid").length,notice:l}},Text:(t,n,o)=>{let p={ok:!0,body:""};return(()=>{let a=o||$e[n];if(!a)return;let e=a.reason;if(a){let f=!!(+!!t.match(a.reg)^+!a.exist);p={ok:f,body:f?"":e}}})(),p},DataLeveling:t=>{let{restrict:n,allowDecimals:o,allowZeroStart:p,value:a=""}=t,e=String(a);["tel","number","digitNumber","postal","creditCard"].includes(n)&&(e=e.zen2hanNumber()),n=="katakana",n=="hankaku.katakana",["postal","creditCard"].includes(n)&&(e=e.removeLetters()),h.scope(()=>{if(!["number","digitNumber"].includes(n))return;e=e.replace(/(\.\d+)\..*/g,"$1").replace(/\.+/g,".").replace(/[^0-9.-]/g,"");let b=Number(e)<0||e[0]=="-";e=e.replace(/[^0-9.]/g,""),b&&(e="-"+e);let l=Number(o);o?e=e.replace(/(\.\d{0,})\..*/g,"$1").replace(/\.(\d{0,})/g,(c,g)=>g.length>l?"."+g.slice(0,l):c):e=e.replace(/\.\d?/g,""),h.scope(()=>{n=="number"&&(p||(e=e.replace(/^0(\d+)/g,"$1").replace(/^-0(\d+)/g,"-$1")))}),h.scope(()=>{let c=e.slice(-1);if(!e||c=="."||c=="-")return;let{min:g,max:u}=t;h.is.exist(g)&&h.is.number(g)&&Number(e)<Number(g)&&(e=String(g.toFixed(l))),h.is.exist(u)&&h.is.number(u)&&Number(e)>Number(u)&&(e=String(u.toFixed(l)))}),h.scope(()=>{if(!e||e=="-"||n!="digitNumber")return;let c=e.slice(-1),[g,u]=e.split(".");e=g.replace(/\B(?=(\d{3})+(?!\d))/g,","),u&&(e+="."+u),c=="."&&(e+=".")})});let f=e;return n=="digitNumber"||(n=="postal"?e.length>=4&&(f=e.clip(0,3)+"-"+e.clip(3)):n=="creditCard"&&(f=e.replace(/.{4}(?=.)/g,"$& "))),e=e.replace(/,/g,""),{formatValue:f,dataValue:e}}},Shallow:t=>{let{rootStates:n,val_status:o}=t,p=o.dataValue||"";ne(()=>{h.scope(()=>ue(void 0,null,function*(){if(!n.multiline)return;let c=h('[data-input-origin="'+o.componentId+'"]'),g=h('[data-input-shallow="'+o.componentId+'"]'),u=h('[data-input-min-height-value-shallow="'+o.componentId+'"]'),E=h('[data-input-max-height-value-shallow="'+o.componentId+'"]');if(!c[0]||!g[0]||!u[0]||!E[0])return;let L=g.position(),F=u.position(),$=E.position(),D=0;n.autoHeight&&(D=L.height),D=Math.max(D,F.height),D=Math.min(D,$.height),c[0].style.height=D+"px"}))},[p]);let a=p||"";(!!p.match(/\n$/)||!p)&&(a+="T");let f="",b="";if(n.multiline){let c=n.minRows||1,g=n.maxRows||100;f=`
2
+ T`.repeat(c-1),b=`
3
+ T`.repeat(g-1)}let l=De(n);return Y(k,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:[s(le.Description,r(i({className:n.className},l),{position:"absolute",width:1,freeCSS:r(i({},l.freeCSS),{color:"orange"}),"data-input-shallow":o.componentId,children:s(k,{"data-input-value-shallow":o.componentId,children:a})})),s(le.Description,r(i({className:n.className},l),{position:"absolute",left:0,freeCSS:r(i({},l.freeCSS),{backgroundColor:"transparent",color:"blue"}),"data-input-min-height-value-shallow":o.componentId,children:f})),s(le.Description,r(i({className:n.className},l),{position:"absolute",right:0,freeCSS:r(i({},l.freeCSS),{backgroundColor:"transparent",color:"red"}),"data-input-max-height-value-shallow":o.componentId,children:b}))]})},InputBox:t=>{let{rootStates:n,val_validate:o,set_validate:p,val_status:a,set_status:e,val_inputType:f,set_inputType:b}=t;if(n.multiline)return null;let re=n,{componentId:l,tone:c,required:g,restrict:u="text",form:E,autoComplete:L="off",autoCapitalize:F="off",minRows:$,maxRows:D,multiline:fe,autoHeight:ge,enableFormSubmit:G,clearButton:be=!1,allowDecimals:z,allowZeroStart:A,checkValidationAtFirst:W,onChange:X,onKeyDown:Q,onValidate:xe,onValidateDelay:he,onUpdateValue:Ie,onUpdateValidValue:ve,onUserAction:Se,value:Te="",leftIndicator:ye,rightIndicator:Ce,leftIcon:Re,rightIcon:we,maxLength:m,min:O,max:B,label:S,isLabelActive:R,defaultValidation:oe,wrapStyles:Pe}=re,d=ae(re,["componentId","tone","required","restrict","form","autoComplete","autoCapitalize","minRows","maxRows","multiline","autoHeight","enableFormSubmit","clearButton","allowDecimals","allowZeroStart","checkValidationAtFirst","onChange","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","leftIndicator","rightIndicator","leftIcon","rightIcon","maxLength","min","max","label","isLabelActive","defaultValidation","wrapStyles"]);return s(k,r(i({htmlTag:"input",type:f,inputMode:["number","digitNumber","creditCard"].includes(u)?"numeric":u=="email"?"email":"text","data-disabled":n.disabled,"data-show-validation":K.isShowValidation(o,a,!!W),"data-component-id":a.componentId,"data-input-origin":a.componentId,value:a.formatValue,autoComplete:L,autoCapitalize:F,onKeyDown:I=>{let{key:x,target:w}=I,M=w,{selectionStart:P,selectionEnd:j}=M,q=Number(P),U=Number(j);{let _=a.formatValue[Number(q)],H=a.formatValue[Number(q)-1];x=="Delete"&&(u=="creditCard"&&_==" "||u=="postal"&&_=="-"||u=="digitNumber"&&_==",")&&(M.setSelectionRange(q+1,U+1),I.preventDefault()),x=="Backspace"&&(u=="creditCard"&&H==" "||u=="postal"&&H=="-"||u=="digitNumber"&&H==",")&&(M.setSelectionRange(q-1,U-1),I.preventDefault()),x=="Enter"||x=="Tab"}h.scope(()=>{["number","digitNumber","creditCard"].includes(u)&&x=="Clear"&&e(_=>r(i({},_),{dataValue:"",formatValue:"",eventType:"update",eventID:T(),isFocusing:!0}))}),h.scope(()=>{if(!["number","digitNumber"].includes(u)||!["ArrowUp","ArrowDown"].includes(x))return;let _=+(x=="ArrowUp")*2-1,H=a.dataValue.slice(-1),se=a.formatValue[U-1],N=U-1,V=String(a.formatValue),ee=a.dataValue.split(".")[1],Ve=(ee==null?void 0:ee.length)||0;h.scope(()=>{if(!H){V="0";return}if(H=="-"){V+="0";return}if(H=="."){V+="0";return}if(U==0)return;let te=String(V).slice(0,N).match(/\./),Fe=String(V).slice(N),J=String(Fe.toNumber().toFixed(0)).length;se=="."&&(J=1,N=V.split(".")[0].length-1),se==","&&(J+=1,N--),te&&(J=-1*(Ve-J));let Z=V[N].toNumber()+_;Z<0?Z=9:Z>=10&&(Z=0),V=V.partReplace(N,String(Z)),setTimeout(()=>{M.setSelectionRange(N+1,N+1)},1)}),o.ok&&p({ok:!1,notice:[]}),e(te=>r(i(i({},te),y.Validation.DataLeveling({allowDecimals:z,allowZeroStart:A,min:O,max:B,restrict:u,value:V})),{eventType:"update",eventID:T(),isFocusing:!0})),I.preventDefault()}),Q&&Q(I),G&&K.SubmitForm(I,E)},onChange:I=>{let{value:x,selectionStart:w,selectionEnd:M}=I.target,P=y.Validation.DataLeveling({allowDecimals:z,allowZeroStart:A,min:O,max:B,restrict:u,value:x});a.isComposing&&(P.formatValue=x),P.formatValue!=a.formatValue&&(o.ok&&p({ok:!1,notice:[]}),e(j=>r(i(i({},j),P),{prevValue:a.formatValue,eventType:"update",eventID:T(),caretFrom:Number(w),caretTo:Number(M),isFocusing:!0})),X&&X(I))},width:1},d),{onFocus:I=>{d!=null&&d.onFocus&&(d==null||d.onFocus(I)),e(x=>r(i({},x),{eventID:T(),eventType:"focus.start",isFocusing:!0}))},onBlur:I=>{d!=null&&d.onBlur&&(d==null||d.onBlur(I)),e(x=>r(i({},x),{eventID:T(),eventType:"focus.end",isFocusing:!1}))},onCompositionStart:I=>{d!=null&&d.onCompositionStart&&(d==null||d.onCompositionStart(I)),e(x=>r(i({},x),{eventID:T(),eventType:"composing.start",isComposing:!0}))},onCompositionEnd:I=>{if(d!=null&&d.onCompositionEnd&&(d==null||d.onCompositionEnd(I)),u=="text"){e(w=>r(i({},w),{eventID:T(),eventType:"composing.end",isComposing:!1}));return}let x=y.Validation.DataLeveling({allowDecimals:z,allowZeroStart:A,min:O,max:B,restrict:u,value:a.formatValue});e(w=>r(i(i({},w),x),{prevValue:w.formatValue,eventType:"update",eventID:T(),caretFrom:Number(w.formatValue.length+1),caretTo:Number(w.formatValue.length+1),isComposing:!1}))}}))},TextAreaBox:t=>{let{rootStates:n,val_validate:o,set_validate:p,val_status:a,set_status:e,isShallow:f}=t,B=n,{componentId:b,tone:l,required:c,form:g,label:u,isLabelActive:E,minRows:L,maxRows:F,multiline:$,autoHeight:D,allowDecimals:fe,allowZeroStart:ge,enableFormSubmit:G,maxLength:be,checkValidationAtFirst:z,onChange:A,onKeyDown:W,onValidate:X,onValidateDelay:Q,onUpdateValue:xe,onUpdateValidValue:he,onUserAction:Ie,value:ve="",leftIndicator:Se,rightIndicator:Te,leftIcon:ye,rightIcon:Ce,defaultValidation:Re,wrapStyles:we}=B,m=ae(B,["componentId","tone","required","form","label","isLabelActive","minRows","maxRows","multiline","autoHeight","allowDecimals","allowZeroStart","enableFormSubmit","maxLength","checkValidationAtFirst","onChange","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","leftIndicator","rightIndicator","leftIcon","rightIcon","defaultValidation","wrapStyles"]);return!n.multiline?null:s(k,r(i({htmlTag:"textarea","data-show-validation":K.isShowValidation(o,a,!!z),"data-input-origin":a.componentId,"data-component-id":a.componentId,value:a.dataValue,width:1},m),{onFocus:S=>{m!=null&&m.onFocus&&(m==null||m.onFocus(S)),e(R=>r(i({},R),{eventID:T(),eventType:"focus.start",isFocusing:!0}))},onBlur:S=>{m!=null&&m.onBlur&&(m==null||m.onBlur(S)),e(R=>r(i({},R),{eventID:T(),eventType:"focus.end",isFocusing:!1}))},onCompositionStart:S=>{m!=null&&m.onCompositionStart&&(m==null||m.onCompositionStart(S)),e(R=>r(i({},R),{eventID:T(),eventType:"composing.start",isComposing:!0}))},onCompositionEnd:S=>{m!=null&&m.onCompositionEnd&&(m==null||m.onCompositionEnd(S)),e(R=>r(i({},R),{eventID:T(),eventType:"composing.end",isComposing:!1}))},onKeyDown:S=>{W&&W(S),G&&K.SubmitForm(S,g)},onChange:S=>{let{value:R}=S.target;o.ok&&p({ok:!1,notice:[]}),e(oe=>r(i({},oe),{dataValue:R,eventType:"update",eventID:T(),isFocusing:!0})),A&&A(S)}}))}},ze=t=>{let{componentId:n,restrict:o="text",value:p="",min:a,max:e,allowDecimals:f,allowZeroStart:b}=t,[l,c]=ie({componentId:n,formatValue:"",dataValue:"",prevValue:"",eventType:"init",eventID:T(),caretFrom:null,caretTo:null}),[g,u]=ie({ok:!1,notice:[]}),[E,L]=ie(["password","concealed"].includes(o)&&"password"||"text");ne(()=>{c($=>i(i({},$),y.Validation.DataLeveling({allowDecimals:f,allowZeroStart:b,min:a,max:e,restrict:o,value:p}))),pe.set({[n+":set_inputType"]:L})},[]);let F={rootStates:t,val_inputType:E,set_inputType:L,val_status:l,set_status:c,val_validate:g,set_validate:u};return K.CommonEffects({type:"textfield",states:t,val_status:l,set_status:c,val_validate:g,set_validate:u,SystemValidation:y.Validation.System,ExtraOverrideStates:()=>y.Validation.DataLeveling({allowDecimals:f,allowZeroStart:b,min:a,max:e,restrict:o,value:p})}),ne(()=>{y.setSelection({id:t.id,restrict:o,val_status:l})},[l]),Y(He,{val_status:l,set_status:c,val_validate:g,states:F.rootStates,children:[s(Be,{componentId:t.componentId,fontSize:t.fontSize,required:t.required,label:t.label,isActive:t.isLabelActive||!!l.isFocusing||!!l.dataValue}),s(y.Shallow,i({},F)),s(y.InputBox,i({},F)),s(y.TextAreaBox,i({},F))]})},C=t=>(t=i({autoHeight:!0,restrict:"text",fontSize:"inherit"},t),t.multiline?(t.minRows=t.minRows||5,t.maxRows=t.maxRows||20):(t.minRows=1,t.maxRows=1),s(_e,{componentId:t.componentId,children:ze,states:Ae(t)})),v=C;v.Validate=y.Validation.Text,v.Katakana=t=>s(C,r(i({},t),{restrict:"katakana",multiline:!1,autoHeight:!1})),v.HankakuKatakana=t=>s(C,r(i({},t),{restrict:"hankaku.katakana",multiline:!1,autoHeight:!1})),v.CreditCard=t=>s(C,r(i({},t),{restrict:"creditCard",multiline:!1,autoHeight:!1})),v.Tel=t=>s(C,r(i({},t),{restrict:"tel",multiline:!1,autoHeight:!1})),v.Number=t=>s(C,r(i({},t),{restrict:"number",multiline:!1,autoHeight:!1})),v.DigitNumber=t=>s(C,r(i({},t),{restrict:"digitNumber",multiline:!1,autoHeight:!1})),v.Email=t=>s(C,r(i({},t),{restrict:"email",multiline:!1,autoHeight:!1})),v.Url=t=>s(C,r(i({},t),{restrict:"url",multiline:!1,autoHeight:!1})),v.Postal=t=>s(C,r(i({label:"\u90F5\u4FBF\u756A\u53F7"},t),{restrict:"postal",multiline:!1,autoHeight:!1,leftIcon:s(Me,{ssSphere:2,fontColor:"4.thin",children:"\u3012"})})),v.Password=t=>s(C,r(i({label:"\u30D1\u30B9\u30EF\u30FC\u30C9",rightIcon:s(me,{ssSphere:2,padding:0,freeCSS:{pointerEvents:"all"},children:s(Ee.Sub,{ssSphere:2,borderRadius:"3.tone.tertiary",fontColor:"theme",flexCenter:!0,height:1,ssEffectsOnActive:["expand"],onMouseOver:n=>{ce.open(n.currentTarget,"\u30C6\u30AD\u30B9\u30C8\u3092\u8868\u793A",24)},onMouseLeave:ce.abort,tabIndex:-1,onClick:n=>{h(n.target).parent().parent().find("input").callback(o=>{let p=o[0];if(!p)return;let a=p.dataset.componentId;if(!a)return;let e=pe.get(a+":set_inputType");e&&e(f=>f==="password"&&"text"||"password")})},children:s(Ne,{icon:Le})})}),restrict:"password"},t),{multiline:!1,autoHeight:!1})),v.Concealed=t=>s(v.Password,r(i({label:"\u79D8\u5BC6\u9375"},t),{restrict:"concealed"})),v.Money={JPY:t=>s(v.DigitNumber,r(i({rightIcon:s(me,{ssSphere:2,fontColor:"4.thin",children:"\u5186"})},t),{multiline:!1,autoHeight:!1}))};export{v as TextField,ze as TextInput,v as default};
@@ -1 +1 @@
1
- import{a as re,b as s,c as E,d as X}from"../../../chunk-C5N2D3ZX.js";import{Fragment as Ae,jsx as d,jsxs as le}from"react/jsx-runtime";import Z,{UUID as N,useStore as L}from"jmini";import*as z from"jmini";import{useState as W,useEffect as H,useRef as ce}from"react";import{$$fromRoot as ue,Config as ie,ExtractStyles as de}from"../../../@utils";import{Box as Y,FAI as fe}from"../../../atoms";import{Literal as he,Row as ge}from"../../../mols";import{Button as ne}from"../../Button";import ye from"../../Tooltips";import ve from"../../Sheet";import{faClock as Ie}from"@fortawesome/free-solid-svg-icons/faClock";import{faCalendarAlt as Se}from"@fortawesome/free-solid-svg-icons/faCalendarAlt";import{OptionalInputWrapper as Te,BoxWrapper as De,CoreEffects as q,DefaultBoxishStyles as be}from"../core";import{RightIcon as xe}from"..";import ke from"../Select";import{InputLabel as Ee}from"../Label";import we from"./Picker";const F=" ~ ",Ve={clock:{defaultValue:"--:--",format:/^\d{2}\D\d{2}$/,ranges:[{type:"hour",from:0,length:2},{type:"minute",from:3,length:2}],sets:1},date:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2}],sets:1},week:{defaultValue:"----\u5E74\u7B2C--\u9031",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4,region:6},{type:"week",from:6,length:2,region:3}],sets:1},month:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:3}],sets:1},year:{defaultValue:"----\u5E74",format:/^\d{4}$/,ranges:[{type:"year",from:0,length:4,region:5}],sets:1},dates:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2,region:5},{type:"year",from:10+F.length,length:4},{type:"month",from:15+F.length,length:2},{type:"date",from:18+F.length,length:2}],sets:2},months:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:6},{type:"year",from:8+F.length,length:4},{type:"month",from:13+F.length,length:2,region:3}],sets:2},dateWareki:{defaultValue:"----\u5E74--\u6708--\u65E5",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"dateWareki",from:0,length:4,region:5},{type:"month",from:5,length:2,region:3},{type:"date",from:8,length:2,region:3}],sets:1}},O={PeriodMargin:" ~ ",DataLeveling:e=>{let{restrict:i,value:f,era:n}=e,u=Z.flatArray(f||""),{defaultValue:k,format:y,ranges:l,sets:a}=Ve[i],S=[],o=i=="clock"&&":"||"/";for(let t=0;t<u.length;t++)u[t]=String(u[t]).replace(/\D/ig,o);for(let t=0;t<a;t++){let p=u[t]||"";if(!p.match(y))u[t]="",S.push(k);else{let x=k;p.split(/\D/).forEach((w,V)=>{if(V==0&&i=="dateWareki"){let v=Number(w);n!="year"&&(v>=2019?n=="reiwa"?v-=2018:n=="heisei"&&(v=31):v>=1989?n=="heisei"?v-=1988:n=="shouwa"&&(v=64):v>=1926?n=="shouwa"?v-=1925:n=="taisho"&&(v=15):v>=1912?n=="taisho"?v-=1911:n=="meiji"&&(v=45):v>=1868&&(v-=1867)),w=v.zeroEmbed(4)}x=x.replace(new RegExp("------------------".slice(0,w.length)),w)}),S.push(x)}}return{formatValue:S.join(F),dataValue:["dates","months"].includes(i)?u:u[0],ranges:l}},SystemValidation:e=>{let{states:i}=e,{restrict:f,min:n,max:u,required:k}=i,y=[],l=Z.flatArray(e.value),a={empty:!1,escalated:1,filled:!0,correct:!0,prohibited:!1};(()=>{let S=f=="clock"&&":"||"/";for(let o=0;o<l.length;o++)l[o]=String(l[o]).replace(/\D/ig,S);for(let o=0;o<l.length;o++){let t=l[o],p=l[o-1];t.removeLetters()||(a.empty=!0),o>0&&(a.escalated&=+(t>=p))}a.escalated&&(a.empty||(f.match(/clock/)?l.forEach(o=>{let[t,p]=o.split(/\D+/);!t||!p?a.filled=!1:(Number(t)>23||Number(p)>59)&&(a.correct=!1)}):f.match(/date/)?l.forEach(o=>{let[t,p,x]=o.split(/\D+/);if(!t||!p||!x)a.filled=!1;else{let w=z.Time(o);(!w.validate||o!=w.toFormatYMD())&&(a.correct=!1)}}):f.match(/week/)?l.forEach(o=>{let[t,p]=o.split(/\D+/);if(!t||!p)a.filled=!1;else{let x=z.Time(t+"/01/01").weekday,V=z.Time(t+"/01/0"+(7-x+1)).addWeek(Number(p)-1);t!=String(V.year)&&(a.correct=!1)}}):f.match(/month/)?l.forEach(o=>{let[t,p]=o.split(/\D+/);!t||!p?a.filled=!1:z.Time([t,p,"01"].join("/")).validate||(a.correct=!1)}):f.match(/year/),a.filled&&a.correct&&l.forEach(o=>{{let t=Number(String(o).replace(/\D/ig,""));if(n&&Number(String(n).replace(/\D/ig,""))>t&&(a.prohibited=!0),u){let p=Number(String(u).replace(/\D/ig,""));t>p&&(a.prohibited=!0)}}})))})();{let{empty:S,escalated:o,filled:t,correct:p,prohibited:x}=a;S&&k&&(y=[{type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}]),o||y.push({type:"invalid",label:"\u6642\u7CFB\u5217\u3092\u6B63\u3057\u304F\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),p||y.push({type:"invalid",label:"\u7121\u52B9\u306A\u5024\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u3059"}),t||y.push({type:"invalid",label:"\u6700\u5F8C\u307E\u3067\u5024\u3092\u57CB\u3081\u3066\u304F\u3060\u3055\u3044"}),x&&y.push({type:"invalid",label:le(Ae,{children:[d(Y,{children:"\u5165\u529B\u7BC4\u56F2\u304C\u5236\u9650\u3055\u308C\u3066\u3044\u307E\u3059"}),"[",n||"\u4E0B\u9650\u7121\u3057","] ~ [",u||"\u4E0A\u9650\u7121\u3057","]"]})})}return{ok:!y.filter(({type:S})=>S=="invalid").length,notice:y}},KeyDownEvent:e=>{let{val_era:i,restrict:f,event:n,val_status:u,set_status:k,val_focus:y,set_focus:l}=e,{key:a,shiftKey:S,ctrlKey:o,metaKey:t}=n,p=o||t,{selectionStart:x,selectionEnd:w}=n.target,{index:V,prevIndex:v}=y,{ranges:G,formatValue:$}=u,A=G.length-1;if(["Tab","ArrowLeft","ArrowRight"].includes(a)){let h=0;if(a=="Tab"){let m=+!S*2-1;if(h=y.index+m,h<0||h>A)return}else{let m=a=="ArrowLeft"?-1:a=="ArrowRight"?1:0;p||x==0&&w==String(u.formatValue).length?h=m==1?A:0:h=Math.max(0,Math.min(V+m,A))}l(m=>E(s({},m),{index:h,prevIndex:V})),n.preventDefault()}if(["Backspace","ArrowUp","ArrowDown","0","1","2","3","4","5","6","7","8","9"].includes(a)){n.preventDefault();let h=V;h=Math.max(h,0),h=Math.min(h,A);let{type:m,from:U,length:Q}=G[h],P=$.slice(U,U+Q),g;if(a=="Backspace")g="------".slice(0,Q);else if(["ArrowUp","ArrowDown"].includes(a)){let T=a=="ArrowUp"?1:-1;P=P|0,g=P+T;let[D,r,I]=m=="dateWareki"?i=="year"?[0,2999,4]:i=="reiwa"?[1,2999,4]:i=="heisei"?[1,31,4]:i=="shouwa"?[1,64,4]:i=="taisho"?[1,15,4]:i=="meiji"?[1,45,4]:[0,0,0]:m=="minute"?[0,59,2]:m=="hour"?[0,23,2]:m=="date"?[1,31,2]:m=="week"?[1,53,2]:m=="month"?[1,12,2]:m=="year"?[0,2999,4]:[0,0,0];g>r?g=D:g<D&&(g=r),g=Number(g).zeroEmbed(I)}else if(["0","1","2","3","4","5","6","7","8","9"].includes(a)){let T=P|0,D=a,r=`${T}${D}`;if(v!=V&&(T=0,r="0"+D),m=="year"||m=="dateWareki"&&i=="year")Number(r)>1e4?g=D:g=r,(g|0)>1e3&&h++;else if(["hour","minute","date","week","month"].includes(m)||m=="dateWareki"&&i!="year"){let I=m=="dateWareki"?i=="reiwa"?100:i=="heisei"?31:i=="shouwa"?64:i=="taisho"?15:i=="meiji"?45:0:m=="minute"?59:m=="hour"?23:m=="date"?31:m=="week"?53:m=="month"?12:0;g=(r|0)>I?D:r,(Number(D)>Number(String(I)[0])||P=="0000".slice(0,String(I).length)&&(r!="0000".slice(0,String(I).length)||["minute","hour"].includes(m)&&v==V)||(r|0)>=re(10,String(I).length-1))&&h++}m=="year"||m=="dateWareki"?g=(g|0).zeroEmbed(4):g=(g|0).zeroEmbed(2)}{let T=String($).partReplace(U,String(g)),D=T.split(F).map(r=>r.replace(/(^\D|\D$)/,"").split(/\D+/).join(f=="clock"&&":"||"/").replace(/(^\D|\D$)/,""));if(f=="dateWareki"){let r=D[0].split(/\D/),[I,C,j]=r;r.length==3&&I&&(D=[[Number(I)-1+Number({year:1,reiwa:2019,heisei:1989,shouwa:1926,taisho:1912,meiji:1868}[i]),C,j].join("/")])}h=Math.max(h,0),h=Math.min(h,A),k(r=>E(s({},r),{dataValue:["dates","months"].includes(f)?D:D[0],formatValue:T,eventType:"update",eventID:N()})),l(r=>E(s({},r),{index:h,prevIndex:r.index}))}}}},oe={picker:{launch:e=>{let i=e.sheetID||N(),S=e,{onValueUpdate:f,min:n,max:u,era:k,restrict:y,defaultValue:l}=S,a=X(S,["onValueUpdate","min","max","era","restrict","defaultValue"]);ve.open("middleCenter",E(s({sheetID:i,size:"S",padding:0,closeAtAroundClick:!0,closeAtParentBlur:!1},a),{content:d(ge.Center,{children:d(we,{restrict:y,min:n,max:u,era:k,defaultValue:l,sheetID:i,onValueUpdate:(o,t)=>{f(o,t)}})})}))},remove:e=>{ye.close(e)}}},Re={Shallow:e=>{let{rootStates:i,val_status:f}=e,n=de(i);return d(Y,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:d(he.Description,E(s({className:i.className},n),{position:"absolute",width:1,freeCSS:E(s({},n.freeCSS),{color:"orange"}),children:d(Y,{"data-input-value-shallow":f.componentId,children:"A"})}))})}},_e=e=>{let te=e,{tone:i,required:f,restrict:n="clock",componentId:u,era:k,form:y,name:l,min:a,max:S,className:o,enableFormSubmit:t,checkValidationAtFirst:p,onKeyDown:x,onValidate:w,onUpdateValue:V,onUpdateValidValue:v,onValidateDelay:G,value:$="",leftIndicator:A,rightIndicator:h,leftIcon:m,rightIcon:U,freeCSS:Q,wrapStyles:P}=te,g=X(te,["tone","required","restrict","componentId","era","form","name","min","max","className","enableFormSubmit","checkValidationAtFirst","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","onValidateDelay","value","leftIndicator","rightIndicator","leftIcon","rightIcon","freeCSS","wrapStyles"]),[T,D]=W(k),[r,I]=W({componentId:e.componentId||"",formatValue:"",dataValue:"",ranges:[],eventType:"init",eventID:N()}),[C,j]=W({ok:!1,notice:[]}),[B,J]=W({active:!1,index:0,prevIndex:-1}),se={rootStates:e,val_status:r,set_status:I,val_validate:C,set_validate:j,val_era:T,set_era:D,val_focus:B,set_focus:J};q.CommonEffects({type:"time",states:e,val_status:r,set_status:I,val_validate:C,set_validate:j,SystemValidation:O.SystemValidation,ExtraOverrideStates:()=>O.DataLeveling({restrict:n,value:$,era:T})}),H(()=>{I(c=>s(s({},c),O.DataLeveling({restrict:n,value:$,era:T})))},[]);const ee=ce(!1);return H(()=>{if(ee.current){I(b=>s(s({},b),O.DataLeveling({restrict:n,value:b.dataValue,era:T})));let c=L.get("refreshEra_"+r.componentId);c&&c.refreshEra(T)}else ee.current=!0},[T]),L.update({[r.componentId]:{openPicker:c=>{e.disabled||oe.picker.launch({parent:c,sheetID:"PickerTips-"+r.componentId,restrict:n,min:a,max:S,defaultValue:r.dataValue,era:T,onValueUpdate:(b,_)=>{I(M=>E(s(s({},M),O.DataLeveling({restrict:n,value:b,era:_})),{eventType:"update",eventID:N()})),D(_)}})},resetEra:c=>{D(c),I(b=>E(s(s({},b),O.DataLeveling({restrict:n,value:"",era:T})),{eventType:"update",eventID:N()}))}}}),H(()=>{let{index:c,active:b}=B;if(b){c=Math.max(c,0),c=Math.min(c,r.ranges.length-1);let{from:_,length:M}=r.ranges[c],K=ue("#"+e.id)[0];K&&K.setSelectionRange(_,_+M)}},[B]),le(De,{val_status:r,set_status:I,val_validate:C,states:e,children:[d(Re.Shallow,s({},se)),d(Ee,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:!0}),ie.get().isTouchDevice?d(ne.Plain,E(s({"data-show-validation":q.isShowValidation(C,r,!!p),"data-component-id":r.componentId,"data-input-origin":r.componentId,"data-disabled":e.disabled,className:o,freeCSS:{textAlign:"left"}},g),{children:r.formatValue,onClick:c=>{let b=L.get(r.componentId);b&&b.openPicker(`[data-input-origin="${r.componentId}"]`),c.stopPropagation()}})):d(Y,s({htmlTag:"input",type:"text",inputMode:"numeric","data-show-validation":q.isShowValidation(C,r,!!p),"data-input-origin":r.componentId,"data-disabled":e.disabled,value:r.formatValue,className:o,tabIndex:ie.get().isTouchDevice?-1:0,onKeyDown:c=>{O.KeyDownEvent({restrict:n,event:c,val_era:T,val_status:r,set_status:I,val_focus:B,set_focus:J}),x&&x(c),t&&q.SubmitForm(c,y)},onKeyUp:c=>{c.key=="Tab"&&J(b=>E(s({},b),{active:!0}))},onClick:c=>{let b=c.target.selectionEnd,_=0;r.ranges.forEach((M,K)=>{let{from:ae,length:me,region:pe}=M;ae<=b&&b<=ae+(pe||me)&&(_=K)}),J(M=>E(s({},M),{active:!0,index:_})),c.preventDefault()},onChange:()=>{}},g))]})},R={Origin:e=>{let i=s({fontSize:"inherit",width:1},e),[f]=W(e.componentId||N());if(i.componentId=f,Z.is.nullish(i.rightIcon)){let n=(e.restrict||"").match(/clock/)?Ie:Se;i.rightIcon=d(xe,{ssSphere:2,freeCSS:{pointerEvents:"all"},children:d(ne.Sub,{color:"cloud",border:"unset",ssSphere:2,fontColor:"theme",boxShadow:"0.normal",borderRadius:"3.tone.tertiary",flexCenter:!0,ssEffectsOnActive:"push",tabIndex:-1,id:"Picker-"+i.componentId,onClick:()=>{let u=L.get(i.componentId);u&&u.openPicker("#Picker-"+i.componentId)},children:d(fe,{icon:n})})})}return d(Te,{componentId:i.componentId,children:_e,states:be(i)})},Clock:e=>d(R.Origin,s({restrict:"clock",era:"clock"},e)),Date:e=>d(R.Origin,s({restrict:"date"},e)),Week:e=>d(R.Origin,s({restrict:"week"},e)),Month:e=>d(R.Origin,s({restrict:"month"},e)),Year:e=>d(R.Origin,s({restrict:"year"},e)),DateWareki:e=>{e=s({},e);let[i]=W(e.componentId||N());e.componentId=i;let y=e,{defaultEra:f="wareki"}=y,n=X(y,["defaultEra"]),[u,k]=W((()=>{let l="year";if(f=="wareki"&&(l="reiwa",e.value)){let[a,S,o]=e.value.split(/\D/);if(a&&S&&o){let t=Number(a);t>=2019?(t-=2019,l="reiwa"):t>=1989?(t-=1989,l="heisei"):t>=1926?(t-=1926,l="shouwa"):t>=1912?(t-=1912,l="taisho"):t>=1868&&(t-=1868,l="meiji"),t+=1}}return l})());return H(()=>{L.set({["refreshEra_"+i]:{refreshEra:l=>{k(l)}}})},[]),d(R.Origin,E(s({restrict:"dateWareki",leftIndicator:d(ke,{label:"\u5143\u53F7",emptySelect:!1,value:u,tone:e.tone||"border",override:"force",flexCenter:!0,borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",height:1,freeCSS:{whiteSpace:"nowrap"},options:[{value:"year",label:"\u897F\u66A6"},{value:"reiwa",label:"\u4EE4\u548C"},{value:"heisei",label:"\u5E73\u6210"},{value:"shouwa",label:"\u662D\u548C"},{value:"taisho",label:"\u5927\u6B63"},{value:"meiji",label:"\u660E\u6CBB"}],onUpdateValidValue:l=>{k(l);let a=L.get(e.componentId);a&&a.resetEra&&a.resetEra(l)}})},n),{era:u}))},Periods:{Date:e=>d(R.Origin,s({restrict:"dates"},e)),Month:e=>d(R.Origin,s({restrict:"months"},e))},fn:oe};export{R as Time,R as default};
1
+ import{a as ie,b as s,c as k,d as K}from"../../../chunk-C5N2D3ZX.js";import{Fragment as Ce,jsx as h,jsxs as se}from"react/jsx-runtime";import ee,{UUID as W,useStore as $}from"jmini";import*as X from"jmini";import{useState as F,useEffect as z,useRef as ue}from"react";import{$$fromRoot as de,Config as ne,ExtractStyles as fe}from"../../../@utils";import{Box as H,FAI as he}from"../../../atoms";import{Literal as ge,Row as ye}from"../../../mols";import{Button as oe}from"../../Button";import ve from"../../Tooltips";import Ie from"../../Sheet";import{faClock as Se}from"@fortawesome/free-solid-svg-icons/faClock";import{faCalendarAlt as Te}from"@fortawesome/free-solid-svg-icons/faCalendarAlt";import{OptionalInputWrapper as De,BoxWrapper as be,CoreEffects as Y,DefaultBoxishStyles as xe}from"../core";import{RightIcon as ke}from"..";import Ee from"../Select";import{InputLabel as we}from"../Label";import Ve from"./Picker";const O=" ~ ",Re={clock:{defaultValue:"--:--",format:/^\d{2}\D\d{2}$/,ranges:[{type:"hour",from:0,length:2},{type:"minute",from:3,length:2}],sets:1},date:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2}],sets:1},week:{defaultValue:"----\u5E74\u7B2C--\u9031",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4,region:6},{type:"week",from:6,length:2,region:3}],sets:1},month:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:3}],sets:1},year:{defaultValue:"----\u5E74",format:/^\d{4}$/,ranges:[{type:"year",from:0,length:4,region:5}],sets:1},dates:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2,region:5},{type:"year",from:10+O.length,length:4},{type:"month",from:15+O.length,length:2},{type:"date",from:18+O.length,length:2}],sets:2},months:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:6},{type:"year",from:8+O.length,length:4},{type:"month",from:13+O.length,length:2,region:3}],sets:2},dateWareki:{defaultValue:"----\u5E74--\u6708--\u65E5",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"dateWareki",from:0,length:4,region:5},{type:"month",from:5,length:2,region:3},{type:"date",from:8,length:2,region:3}],sets:1}},P={PeriodMargin:" ~ ",DataLeveling:e=>{let{restrict:r,value:g,era:i}=e,d=ee.flatArray(g||""),{defaultValue:x,format:v,ranges:o,sets:a}=Re[r],S=[],n=r=="clock"&&":"||"/";for(let t=0;t<d.length;t++)d[t]=String(d[t]).replace(/\D/ig,n);for(let t=0;t<a;t++){let p=d[t]||"";if(!p.match(v))d[t]="",S.push(x);else{let b=x;p.split(/\D/).forEach((E,w)=>{if(w==0&&r=="dateWareki"){let I=Number(E);i!="year"&&(I>=2019?i=="reiwa"?I-=2018:i=="heisei"&&(I=31):I>=1989?i=="heisei"?I-=1988:i=="shouwa"&&(I=64):I>=1926?i=="shouwa"?I-=1925:i=="taisho"&&(I=15):I>=1912?i=="taisho"?I-=1911:i=="meiji"&&(I=45):I>=1868&&(I-=1867)),E=I.zeroEmbed(4)}b=b.replace(new RegExp("------------------".slice(0,E.length)),E)}),S.push(b)}}return{formatValue:S.join(O),dataValue:["dates","months"].includes(r)?d:d[0],ranges:o}},SystemValidation:e=>{let{states:r}=e,{restrict:g,min:i,max:d,required:x}=r,v=[],o=ee.flatArray(e.value),a={empty:!1,escalated:1,filled:!0,correct:!0,prohibited:!1};(()=>{let S=g=="clock"&&":"||"/";for(let n=0;n<o.length;n++)o[n]=String(o[n]).replace(/\D/ig,S);for(let n=0;n<o.length;n++){let t=o[n],p=o[n-1];t.removeLetters()||(a.empty=!0),n>0&&(a.escalated&=+(t>=p))}a.escalated&&(a.empty||(g.match(/clock/)?o.forEach(n=>{let[t,p]=n.split(/\D+/);!t||!p?a.filled=!1:(Number(t)>23||Number(p)>59)&&(a.correct=!1)}):g.match(/date/)?o.forEach(n=>{let[t,p,b]=n.split(/\D+/);if(!t||!p||!b)a.filled=!1;else{let E=X.Time(n);(!E.validate||n!=E.toFormatYMD())&&(a.correct=!1)}}):g.match(/week/)?o.forEach(n=>{let[t,p]=n.split(/\D+/);if(!t||!p)a.filled=!1;else{let b=X.Time(t+"/01/01").weekday,w=X.Time(t+"/01/0"+(7-b+1)).addWeek(Number(p)-1);t!=String(w.year)&&(a.correct=!1)}}):g.match(/month/)?o.forEach(n=>{let[t,p]=n.split(/\D+/);!t||!p?a.filled=!1:X.Time([t,p,"01"].join("/")).validate||(a.correct=!1)}):g.match(/year/),a.filled&&a.correct&&o.forEach(n=>{{let t=Number(String(n).replace(/\D/ig,""));if(i&&Number(String(i).replace(/\D/ig,""))>t&&(a.prohibited=!0),d){let p=Number(String(d).replace(/\D/ig,""));t>p&&(a.prohibited=!0)}}})))})();{let{empty:S,escalated:n,filled:t,correct:p,prohibited:b}=a;S&&x&&(v=[{type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}]),n||v.push({type:"invalid",label:"\u6642\u7CFB\u5217\u3092\u6B63\u3057\u304F\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),p||v.push({type:"invalid",label:"\u7121\u52B9\u306A\u5024\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u3059"}),t||v.push({type:"invalid",label:"\u6700\u5F8C\u307E\u3067\u5024\u3092\u57CB\u3081\u3066\u304F\u3060\u3055\u3044"}),b&&v.push({type:"invalid",label:se(Ce,{children:[h(H,{children:"\u5165\u529B\u7BC4\u56F2\u304C\u5236\u9650\u3055\u308C\u3066\u3044\u307E\u3059"}),"[",i||"\u4E0B\u9650\u7121\u3057","] ~ [",d||"\u4E0A\u9650\u7121\u3057","]"]})})}return{ok:!v.filter(({type:S})=>S=="invalid").length,notice:v}},KeyDownEvent:e=>{let{val_era:r,restrict:g,event:i,val_status:d,set_status:x,val_focus:v,set_focus:o}=e,{key:a,shiftKey:S,ctrlKey:n,metaKey:t}=i,p=n||t,{selectionStart:b,selectionEnd:E}=i.target,{index:w,prevIndex:I}=v,{ranges:q,formatValue:G}=d,A=q.length-1;if(["Tab","ArrowLeft","ArrowRight"].includes(a)){let y=0;if(a=="Tab"){let m=+!S*2-1;if(y=v.index+m,y<0||y>A)return}else{let m=a=="ArrowLeft"?-1:a=="ArrowRight"?1:0;p||b==0&&E==String(d.formatValue).length?y=m==1?A:0:y=Math.max(0,Math.min(w+m,A))}o(m=>k(s({},m),{index:y,prevIndex:w})),i.preventDefault()}if(["Backspace","ArrowUp","ArrowDown","0","1","2","3","4","5","6","7","8","9"].includes(a)){i.preventDefault();let y=w;y=Math.max(y,0),y=Math.min(y,A);let{type:m,from:B,length:Q}=q[y],L=G.slice(B,B+Q),T;if(a=="Backspace")T="------".slice(0,Q);else if(["ArrowUp","ArrowDown"].includes(a)){let V=a=="ArrowUp"?1:-1;L=L|0,T=L+V;let[f,u,l]=m=="dateWareki"?r=="year"?[0,2999,4]:r=="reiwa"?[1,2999,4]:r=="heisei"?[1,31,4]:r=="shouwa"?[1,64,4]:r=="taisho"?[1,15,4]:r=="meiji"?[1,45,4]:[0,0,0]:m=="minute"?[0,59,2]:m=="hour"?[0,23,2]:m=="date"?[1,31,2]:m=="week"?[1,53,2]:m=="month"?[1,12,2]:m=="year"?[0,2999,4]:[0,0,0];T>u?T=f:T<f&&(T=u),T=Number(T).zeroEmbed(l)}else if(["0","1","2","3","4","5","6","7","8","9"].includes(a)){let V=L|0,f=a,u=`${V}${f}`;if(I!=w&&(V=0,u="0"+f),m=="year"||m=="dateWareki"&&r=="year")Number(u)>1e4?T=f:T=u,(T|0)>1e3&&y++;else if(["hour","minute","date","week","month"].includes(m)||m=="dateWareki"&&r!="year"){let l=m=="dateWareki"?r=="reiwa"?100:r=="heisei"?31:r=="shouwa"?64:r=="taisho"?15:r=="meiji"?45:0:m=="minute"?59:m=="hour"?23:m=="date"?31:m=="week"?53:m=="month"?12:0;T=(u|0)>l?f:u,(Number(f)>Number(String(l)[0])||L=="0000".slice(0,String(l).length)&&(u!="0000".slice(0,String(l).length)||["minute","hour"].includes(m)&&I==w)||(u|0)>=ie(10,String(l).length-1))&&y++}m=="year"||m=="dateWareki"?T=(T|0).zeroEmbed(4):T=(T|0).zeroEmbed(2)}{let V=String(G).partReplace(B,String(T)),f=V.split(O).map(u=>u.replace(/(^\D|\D$)/,"").split(/\D+/).join(g=="clock"&&":"||"/").replace(/(^\D|\D$)/,""));if(g=="dateWareki"){let u=f[0].split(/\D/),[l,R,M]=u;u.length==3&&l&&(f=[[Number(l)-1+Number({year:1,reiwa:2019,heisei:1989,shouwa:1926,taisho:1912,meiji:1868}[r]),R,M].join("/")])}y=Math.max(y,0),y=Math.min(y,A),x(u=>k(s({},u),{dataValue:["dates","months"].includes(g)?f:f[0],formatValue:V,eventType:"update",eventID:W()})),o(u=>k(s({},u),{index:y,prevIndex:u.index}))}}}},le={picker:{launch:e=>{let r=e.sheetID||W(),S=e,{onValueUpdate:g,min:i,max:d,era:x,restrict:v,defaultValue:o}=S,a=K(S,["onValueUpdate","min","max","era","restrict","defaultValue"]);Ie.open("middleCenter",k(s({sheetID:r,size:"S",padding:0,closeAtAroundClick:!0,closeAtParentBlur:!1},a),{content:h(ye.Center,{children:h(Ve,{restrict:v,min:i,max:d,era:x,defaultValue:o,sheetID:r,onValueUpdate:(n,t)=>{g(n,t)}})})}))},remove:e=>{ve.close(e)}}},_e={Shallow:e=>{let{rootStates:r,val_status:g}=e,i=fe(r);return h(H,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:h(ge.Description,k(s({className:r.className},i),{position:"absolute",width:1,freeCSS:k(s({},i.freeCSS),{color:"orange"}),children:h(H,{"data-input-value-shallow":g.componentId,children:"A"})}))})}},Ae=e=>{let ae=e,{tone:r,required:g,restrict:i="clock",componentId:d,era:x,form:v,name:o,min:a,max:S,className:n,enableFormSubmit:t,checkValidationAtFirst:p,onKeyDown:b,onValidate:E,onValidateDelay:w,onUpdateValue:I,onUpdateValidValue:q,onUserAction:G,value:A="",leftIndicator:y,rightIndicator:m,leftIcon:B,rightIcon:Q,freeCSS:L,wrapStyles:T}=ae,V=K(ae,["tone","required","restrict","componentId","era","form","name","min","max","className","enableFormSubmit","checkValidationAtFirst","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","leftIndicator","rightIndicator","leftIcon","rightIcon","freeCSS","wrapStyles"]),[f,u]=F(x),[l,R]=F({componentId:e.componentId||"",formatValue:"",dataValue:"",ranges:[],eventType:"init",eventID:W()}),[M,Z]=F({ok:!1,notice:[]}),[U,j]=F({active:!1,index:0,prevIndex:-1}),me={rootStates:e,val_status:l,set_status:R,val_validate:M,set_validate:Z,val_era:f,set_era:u,val_focus:U,set_focus:j};Y.CommonEffects({type:"time",states:e,val_status:l,set_status:R,val_validate:M,set_validate:Z,SystemValidation:P.SystemValidation,ExtraOverrideStates:()=>P.DataLeveling({restrict:i,value:A,era:f})}),z(()=>{R(c=>s(s({},c),P.DataLeveling({restrict:i,value:A,era:f})))},[]);const te=ue(!1);return z(()=>{if(te.current){R(D=>s(s({},D),P.DataLeveling({restrict:i,value:D.dataValue,era:f})));let c=$.get("refreshEra_"+l.componentId);c&&c.refreshEra(f)}else te.current=!0},[f]),$.update({[l.componentId]:{openPicker:c=>{e.disabled||le.picker.launch({parent:c,sheetID:"PickerTips-"+l.componentId,restrict:i,min:a,max:S,defaultValue:l.dataValue,era:f,onValueUpdate:(D,C)=>{R(N=>k(s(s({},N),P.DataLeveling({restrict:i,value:D,era:C})),{eventType:"update",eventID:W()})),u(C)}})},resetEra:c=>{u(c),R(D=>k(s(s({},D),P.DataLeveling({restrict:i,value:"",era:f})),{eventType:"update",eventID:W()}))}}}),z(()=>{let{index:c,active:D}=U;if(D){c=Math.max(c,0),c=Math.min(c,l.ranges.length-1);let{from:C,length:N}=l.ranges[c],J=de("#"+e.id)[0];J&&J.setSelectionRange(C,C+N)}},[U]),se(be,{val_status:l,set_status:R,val_validate:M,states:e,children:[h(_e.Shallow,s({},me)),h(we,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:!0}),ne.get().isTouchDevice?h(oe.Plain,k(s({"data-show-validation":Y.isShowValidation(M,l,!!p),"data-component-id":l.componentId,"data-input-origin":l.componentId,"data-disabled":e.disabled,className:n,freeCSS:{textAlign:"left"}},V),{children:l.formatValue,onClick:c=>{let D=$.get(l.componentId);D&&D.openPicker(`[data-input-origin="${l.componentId}"]`),c.stopPropagation()}})):h(H,s({htmlTag:"input",type:"text",inputMode:"numeric","data-show-validation":Y.isShowValidation(M,l,!!p),"data-input-origin":l.componentId,"data-disabled":e.disabled,value:l.formatValue,className:n,tabIndex:ne.get().isTouchDevice?-1:0,onKeyDown:c=>{P.KeyDownEvent({restrict:i,event:c,val_era:f,val_status:l,set_status:R,val_focus:U,set_focus:j}),b&&b(c),t&&Y.SubmitForm(c,v)},onKeyUp:c=>{c.key=="Tab"&&j(D=>k(s({},D),{active:!0}))},onClick:c=>{let D=c.target.selectionEnd,C=0;l.ranges.forEach((N,J)=>{let{from:re,length:pe,region:ce}=N;re<=D&&D<=re+(ce||pe)&&(C=J)}),j(N=>k(s({},N),{active:!0,index:C})),c.preventDefault()},onChange:()=>{}},V))]})},_={Origin:e=>{let r=s({fontSize:"inherit",width:1},e),[g]=F(e.componentId||W());if(r.componentId=g,ee.is.nullish(r.rightIcon)){let i=(e.restrict||"").match(/clock/)?Se:Te;r.rightIcon=h(ke,{ssSphere:2,freeCSS:{pointerEvents:"all"},children:h(oe.Sub,{color:"cloud",border:"unset",ssSphere:2,fontColor:"theme",boxShadow:"0.normal",borderRadius:"3.tone.tertiary",flexCenter:!0,ssEffectsOnActive:"push",tabIndex:-1,id:"Picker-"+r.componentId,onClick:()=>{let d=$.get(r.componentId);d&&d.openPicker("#Picker-"+r.componentId)},children:h(he,{icon:i})})})}return h(De,{componentId:r.componentId,children:Ae,states:xe(r)})},Clock:e=>h(_.Origin,s({restrict:"clock",era:"clock"},e)),Date:e=>h(_.Origin,s({restrict:"date"},e)),Week:e=>h(_.Origin,s({restrict:"week"},e)),Month:e=>h(_.Origin,s({restrict:"month"},e)),Year:e=>h(_.Origin,s({restrict:"year"},e)),DateWareki:e=>{e=s({},e);let[r]=F(e.componentId||W());e.componentId=r;let v=e,{defaultEra:g="wareki"}=v,i=K(v,["defaultEra"]),[d,x]=F((()=>{let o="year";if(g=="wareki"&&(o="reiwa",e.value)){let[a,S,n]=e.value.split(/\D/);if(a&&S&&n){let t=Number(a);t>=2019?(t-=2019,o="reiwa"):t>=1989?(t-=1989,o="heisei"):t>=1926?(t-=1926,o="shouwa"):t>=1912?(t-=1912,o="taisho"):t>=1868&&(t-=1868,o="meiji"),t+=1}}return o})());return z(()=>{$.set({["refreshEra_"+r]:{refreshEra:o=>{x(o)}}})},[]),h(_.Origin,k(s({restrict:"dateWareki",leftIndicator:h(Ee,{label:"\u5143\u53F7",emptySelect:!1,value:d,tone:e.tone||"border",override:"force",flexCenter:!0,borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",height:1,freeCSS:{whiteSpace:"nowrap"},options:[{value:"year",label:"\u897F\u66A6"},{value:"reiwa",label:"\u4EE4\u548C"},{value:"heisei",label:"\u5E73\u6210"},{value:"shouwa",label:"\u662D\u548C"},{value:"taisho",label:"\u5927\u6B63"},{value:"meiji",label:"\u660E\u6CBB"}],onUpdateValidValue:o=>{x(o);let a=$.get(e.componentId);a&&a.resetEra&&a.resetEra(o)}})},i),{era:d}))},Periods:{Date:e=>h(_.Origin,s({restrict:"dates"},e)),Month:e=>h(_.Origin,s({restrict:"months"},e))},fn:le};export{_ as Time,_ as default};
@@ -1 +1 @@
1
- import{b as o,c as d,e as b}from"../../chunk-C5N2D3ZX.js";import{jsx as p,jsxs as V}from"react/jsx-runtime";import{useState as k,useEffect as g}from"react";import c,{UUID as y,useStore as v}from"jmini";import{$$fromRoot as D,Config as B}from"../../@utils";import{InputClasses as _}from"../../@styles/componentClasses";import{Box as E,Flex as w,FAI as R,Column as N}from"../../atoms";import{Row as x,Literal as F}from"../../mols";import{Button as L}from"../Button";import h from"../Tooltips";const et=t=>{let[n]=k(t.componentId||y());t=o({},t),t.states=d(o({enableFormSubmit:!0,status_id:y(),override:"never",form:"",id:y(),"aria-label":"Input-"+n},t.states),{componentId:n});let{children:e}=t;return p(e,o({},t.states))},at=t=>{let{children:n,val_status:e,val_validate:a,states:i}=t,{leftIcon:l,wrapStyles:s}=i;return e.eventType=="init"&&!i.checkValidationAtFirst&&(a.notice=[]),V(x.Center,d(o({position:"relative",verticalAlign:"unset",gap:0},s),{className:_("Wrapper"),"data-notice-uid":e.componentId,children:[p(C.Notice,{notice:a.notice,val_status:e}),i.leftIndicator,V(w,{position:"relative",flexSizing:"auto",children:[n,l,p(C.RightIcon,o({},t)),p(C.ClearButton,o({},t))]}),i.rightIndicator]}))},C={ClearButton:t=>!t.states.clearButton||!t.val_status.dataValue?null:p(L.Normal,{ssSphere:2,flexCenter:!0,fontColor:"5.translucent",ssEffectsOnActive:["ripple.theme"],position:"absolute",right:1,top:"50%",freeCSS:{zIndex:3,transform:"translateY(-50%)"},onClick:()=>{t.set_status(n=>d(o({},n),{dataValue:"",formatValue:"",eventType:"update",eventID:y()}))},children:p(R.X,{})}),RightIcon:t=>t.states.clearButton&&t.val_status.dataValue?null:t.states.rightIcon,Notice:t=>{let{notice:n,val_status:e}=t,{componentId:a}=e,i="NoticeTimer-"+a,l="NoticeTimerClose-"+a,s="notice-tips-"+a;return g(()=>{c.interval.once(()=>{if(!n.length){h.close(s);return}h.open({tipsID:s,parent:`[data-notice-uid="${a}"]`,gravityPoint:22,padding:[1,0],closeAtParentBlur:!1,content:V(h.Body,{padding:["1/2","2/3"],fontSize:"1.mini",position:"relative",children:[p(E,{position:"absolute",unitHeight:1,unitWidth:1,left:1,backgroundColor:"dark",freeCSS:{zIndex:1,transform:"rotate(45deg)",top:-6}}),p(N,{backgroundColor:"inherit",gap:"1/3",position:"relative",freeCSS:{zIndex:2},children:n.map((I,S)=>{let{type:r,label:u}=I,f=r=="invalid"?R.X:r=="warn"?R.Exclamation:R.Check;return V(x.Left,{gap:0,borderRadius:"2.tone.secondary",children:[p(f,{flexCenter:!0,fontSize:"2.normal",fontColor:{invalid:"nega",warn:"warn",valid:"posi"}[r]}),p(F.Supplement,{fontSize:"0.xs",fontColor:"white",children:u})]},S+"-"+c.Stringify(I))})})]})})},350,i),c.interval.once(()=>{h.close(s)},6e3,l)},[n]),null}},W={DefaultStatus:(t,n)=>({componentId:t,dataValue:n,eventType:"init",eventID:y()}),CommonEffects:function(t){let{type:n,states:e,val_status:a,set_status:i,val_validate:l,set_validate:s,SystemValidation:I}=t;e=o({},e);let{componentId:S}=a;g(()=>(v.update({[S]:{ResolveRefresh:null,Refresh:()=>new Promise((r,u)=>{v.get(S).ResolveRefresh=r,i(f=>d(o({},f),{eventType:"refresh",eventID:y()}))}),GenNotice:r=>{let{ok:u,notice:f}=r;s({ok:u,notice:f})}}}),()=>{v.delete(S)}),[]),c.scope(()=>{let{override:r}=e;if(r=="never"||r=="beforeModified"&&!["init","override"].includes(a.eventType))return;let u=v.get(a.componentId);u&&(e.value!=a.dataValue&&e.status_id!=u.status_id&&i(f=>d(o(d(o({},f),{dataValue:e.value}),t.ExtraOverrideStates&&t.ExtraOverrideStates()),{eventType:"override",eventID:y()})),u.status_id=e.status_id)}),g(()=>{W.ValidationCheck({val_status:a,set_validate:s,SystemValidation:I,states:e})},[a.eventID,a.dataValue]),g(()=>(c.scope(()=>{let{componentId:r,eventType:u,dataValue:f}=a,m=f;if(n=="autocomplete.single"||n=="list.radio"?m=m[0]:e.isChecker&&(m=!!m[0]),e.form=e.form||"testForm",e.name&&e.form&&v.update({[["form-data",e.form].join("-")]:{[e.name]:{componentId:r,type:n,value:m,validation:l.ok}}}),u=="refresh"){let T=v.get(r);T&&T.ResolveRefresh&&T.ResolveRefresh(null)}else u=="update"&&(e.onUpdateValue&&e.onUpdateValue(m,u,r),c.scope(()=>{l.ok&&e.onUpdateValidValue&&e.onUpdateValidValue(m,u,r)}))}),()=>{v.update({[["form-data",e.form].join("-")]:{[e.name]:null}})}),[l])},ValidationCheck:t=>{let{states:n}=t,e="ValidationTimer-"+t.val_status.componentId;c.interval.abort(e);let a=t.SystemValidation({value:t.val_status.dataValue,states:n});if(!a.ok){t.set_validate(a);return}let i=a.notice;const l=()=>b(void 0,null,function*(){if(!n.onValidate)return;let s=yield n.onValidate(t.val_status.dataValue,t.val_status.eventType,t);t.set_validate({ok:s.ok,notice:[...i,...s.notice]})});if(n.onValidate){if(t.val_status.eventType=="refresh"){l();return}c.interval.once(l,n.onValidateDelay||500,e);return}t.set_validate({ok:!0,notice:i})},SubmitForm:(t,n)=>{let e=!1;if(!n)return e;let a=D(`[data-form-submit-button="${n}"]`)[0];if(!a)return e;let i=a.dataset.sdfike||"",l=t.key,s=t.ctrlKey||t.metaKey;return c.scope(()=>{i.includes("enter")&&(l!="Enter"||t.nativeEvent.isComposing||B.get().browserIs=="safari"&&t.keyCode==229)||((l=="Enter"&&(i.includes("enter")||i.includes("auxEnter")&&s)||l==" "&&i.includes("space"))&&(a.click(),t.preventDefault()),e=!0)}),e},isShowValidation:(t,n,e)=>{let a=t.ok;return!e&&n.eventType=="init"&&(a=!0),a}},nt=function(t){t=o({tone:"border"},t);let n=c.scope(()=>{if(t.tone=="plain")return{};let a={padding:"3/4",transition:"middle",flexSizing:"auto",boxShadow:"0.min"};return t.tone=="border"?a=d(o({},a),{border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"}):t.tone=="cloud"?a=d(o({},a),{border:"1.thin",borderRadius:"2.tone.secondary",backgroundColor:"cloud"}):t.tone=="bottomBorder"&&(a=d(o({},a),{borderRadius:0,border:"unset",borderBottom:!0,backgroundColor:"cloud"})),a});return d(o(o(o(o(o(o({fontColor:"2.normal"},n),!!t.rightIcon&&{paddingRight:3}),!!t.leftIcon&&{paddingLeft:3}),!!t.leftIndicator&&{borderTopLeftRadius:"2/3",borderBottomLeftRadius:"2/3",marginLeft:"1/4"}),!!t.rightIndicator&&{borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",marginRight:"1/4"}),t),{freeCSS:o({letterSpacing:"1px",resize:"none"},t.freeCSS),className:[_("Input"),t.className].join(" ")})};export{at as BoxWrapper,W as CoreEffects,nt as DefaultBoxishStyles,et as OptionalInputWrapper};
1
+ import{b as o,c as d,e as b}from"../../chunk-C5N2D3ZX.js";import{jsx as f,jsxs as V}from"react/jsx-runtime";import{useState as k,useEffect as g}from"react";import p,{UUID as y,useStore as v}from"jmini";import{$$fromRoot as D,Config as B}from"../../@utils";import{InputClasses as _}from"../../@styles/componentClasses";import{Box as E,Flex as w,FAI as R,Column as N}from"../../atoms";import{Row as x,Literal as F}from"../../mols";import{Button as A}from"../Button";import h from"../Tooltips";const et=t=>{let[n]=k(t.componentId||y());t=o({},t),t.states=d(o({enableFormSubmit:!0,status_id:y(),override:"never",form:"",id:y(),"aria-label":"Input-"+n},t.states),{componentId:n});let{children:e}=t;return f(e,o({},t.states))},at=t=>{let{children:n,val_status:e,val_validate:a,states:i}=t,{leftIcon:l,wrapStyles:u}=i;return e.eventType=="init"&&!i.checkValidationAtFirst&&(a.notice=[]),V(x.Center,d(o({position:"relative",verticalAlign:"unset",gap:0},u),{className:_("Wrapper"),"data-notice-uid":e.componentId,children:[f(T.Notice,{notice:a.notice,val_status:e}),i.leftIndicator,V(w,{position:"relative",flexSizing:"auto",children:[n,l,f(T.RightIcon,o({},t)),f(T.ClearButton,o({},t))]}),i.rightIndicator]}))},T={ClearButton:t=>!t.states.clearButton||!t.val_status.dataValue?null:f(A.Normal,{ssSphere:2,flexCenter:!0,fontColor:"5.translucent",ssEffectsOnActive:["ripple.theme"],position:"absolute",right:1,top:"50%",freeCSS:{zIndex:3,transform:"translateY(-50%)"},onClick:()=>{t.set_status(n=>d(o({},n),{dataValue:"",formatValue:"",eventType:"update",eventID:y()}))},children:f(R.X,{})}),RightIcon:t=>t.states.clearButton&&t.val_status.dataValue?null:t.states.rightIcon,Notice:t=>{let{notice:n,val_status:e}=t,{componentId:a}=e,i="NoticeTimer-"+a,l="NoticeTimerClose-"+a,u="notice-tips-"+a;return g(()=>{p.interval.once(()=>{if(!n.length){h.close(u);return}h.open({tipsID:u,parent:`[data-notice-uid="${a}"]`,gravityPoint:22,padding:[1,0],closeAtParentBlur:!1,content:V(h.Body,{padding:["1/2","2/3"],fontSize:"1.mini",position:"relative",children:[f(E,{position:"absolute",unitHeight:1,unitWidth:1,left:1,backgroundColor:"dark",freeCSS:{zIndex:1,transform:"rotate(45deg)",top:-6}}),f(N,{backgroundColor:"inherit",gap:"1/3",position:"relative",freeCSS:{zIndex:2},children:n.map((I,S)=>{let{type:r,label:s}=I,m=r=="invalid"?R.X:r=="warn"?R.Exclamation:R.Check;return V(x.Left,{gap:0,borderRadius:"2.tone.secondary",children:[f(m,{flexCenter:!0,fontSize:"2.normal",fontColor:{invalid:"nega",warn:"warn",valid:"posi"}[r]}),f(F.Supplement,{fontSize:"0.xs",fontColor:"white",children:s})]},S+"-"+p.Stringify(I))})})]})})},350,i),p.interval.once(()=>{h.close(u)},6e3,l)},[n]),null}},L={DefaultStatus:(t,n)=>({componentId:t,dataValue:n,eventType:"init",eventID:y()}),CommonEffects:function(t){let{type:n,states:e,val_status:a,set_status:i,val_validate:l,set_validate:u,SystemValidation:I}=t;e=o({},e);let{componentId:S}=a;g(()=>(v.update({[S]:{ResolveRefresh:null,Refresh:()=>new Promise((r,s)=>{v.get(S).ResolveRefresh=r,i(m=>d(o({},m),{eventType:"refresh",eventID:y()}))}),GenNotice:r=>{let{ok:s,notice:m}=r;u({ok:s,notice:m})}}}),()=>{v.delete(S)}),[]),p.scope(()=>{let{override:r}=e;if(r=="never"||r=="beforeModified"&&!["init","override"].includes(a.eventType))return;let s=v.get(a.componentId);s&&(e.value!=a.dataValue&&e.status_id!=s.status_id&&i(m=>d(o(d(o({},m),{dataValue:e.value}),t.ExtraOverrideStates&&t.ExtraOverrideStates()),{eventType:"override",eventID:y()})),s.status_id=e.status_id)}),g(()=>{L.ValidationCheck({val_status:a,set_validate:u,SystemValidation:I,states:e})},[a.eventID,a.dataValue]),g(()=>(p.scope(()=>{let{componentId:r,eventType:s,dataValue:m}=a,c=m;if(n=="autocomplete.single"||n=="list.radio"?c=c[0]:e.isChecker&&(c=!!c[0]),e.form=e.form||"testForm",e.name&&e.form&&v.update({[["form-data",e.form].join("-")]:{[e.name]:{componentId:r,type:n,value:c,validation:l.ok}}}),e.onUserAction&&e.onUserAction(c,{eventType:s,componentId:r,isValidated:!!l.ok,isComposing:!!a.isComposing,isFocusing:!!a.isFocusing}),s=="refresh"){let C=v.get(r);C&&C.ResolveRefresh&&C.ResolveRefresh(null)}else s=="update"&&(e.onUpdateValue&&e.onUpdateValue(c,s,r),p.scope(()=>{l.ok&&e.onUpdateValidValue&&e.onUpdateValidValue(c,s,r)}))}),()=>{v.update({[["form-data",e.form].join("-")]:{[e.name]:null}})}),[l])},ValidationCheck:t=>{let{states:n}=t,e="ValidationTimer-"+t.val_status.componentId;p.interval.abort(e);let a=t.SystemValidation({value:t.val_status.dataValue,states:n});if(!a.ok){t.set_validate(a);return}let i=a.notice;const l=()=>b(void 0,null,function*(){if(!n.onValidate)return;let u=yield n.onValidate(t.val_status.dataValue,t.val_status.eventType,t);t.set_validate({ok:u.ok,notice:[...i,...u.notice]})});if(n.onValidate){if(t.val_status.eventType=="refresh"){l();return}p.interval.once(l,n.onValidateDelay||500,e);return}t.set_validate({ok:!0,notice:i})},SubmitForm:(t,n)=>{let e=!1;if(!n)return e;let a=D(`[data-form-submit-button="${n}"]`)[0];if(!a)return e;let i=a.dataset.sdfike||"",l=t.key,u=t.ctrlKey||t.metaKey;return p.scope(()=>{i.includes("enter")&&(l!="Enter"||t.nativeEvent.isComposing||B.get().browserIs=="safari"&&t.keyCode==229)||((l=="Enter"&&(i.includes("enter")||i.includes("auxEnter")&&u)||l==" "&&i.includes("space"))&&(a.click(),t.preventDefault()),e=!0)}),e},isShowValidation:(t,n,e)=>{let a=t.ok;return!e&&n.eventType=="init"&&(a=!0),a}},nt=function(t){t=o({tone:"border"},t);let n=p.scope(()=>{if(t.tone=="plain")return{};let a={padding:"3/4",transition:"middle",flexSizing:"auto",boxShadow:"0.min"};return t.tone=="border"?a=d(o({},a),{border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"}):t.tone=="cloud"?a=d(o({},a),{border:"1.thin",borderRadius:"2.tone.secondary",backgroundColor:"cloud"}):t.tone=="bottomBorder"&&(a=d(o({},a),{borderRadius:0,border:"unset",borderBottom:!0,backgroundColor:"cloud"})),a});return d(o(o(o(o(o(o({fontColor:"2.normal"},n),!!t.rightIcon&&{paddingRight:3}),!!t.leftIcon&&{paddingLeft:3}),!!t.leftIndicator&&{borderTopLeftRadius:"2/3",borderBottomLeftRadius:"2/3",marginLeft:"1/4"}),!!t.rightIndicator&&{borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",marginRight:"1/4"}),t),{freeCSS:o({letterSpacing:"1px",resize:"none"},t.freeCSS),className:[_("Input"),t.className].join(" ")})};export{at as BoxWrapper,L as CoreEffects,nt as DefaultBoxishStyles,et as OptionalInputWrapper};
@@ -4,6 +4,13 @@ export declare namespace InputTypes {
4
4
  type BoxTone = 'border' | 'cloud' | 'bottomBorder' | 'plain';
5
5
  type Type = 'hidden' | 'textfield' | 'textfield.multiline' | 'select' | 'list.radio' | 'list.checkbox' | 'autocomplete.single' | 'autocomplete.multi' | 'time' | 'switch' | 'slider' | 'file' | 'contenteditable' | 'color' | '';
6
6
  type OnUpdateValue<T = any> = (value: T, eventType: Validation.EventType, componentId: string) => void;
7
+ type OnUserAction<T = any> = (value: T, option: {
8
+ eventType?: Validation.EventType;
9
+ componentId?: string;
10
+ isValidated?: boolean;
11
+ isComposing?: boolean;
12
+ isFocusing?: boolean;
13
+ }) => void;
7
14
  type UniInput<T = any> = {
8
15
  'data-type'?: T;
9
16
  name?: string;
@@ -18,13 +25,14 @@ export declare namespace InputTypes {
18
25
  onValidateDelay?: number;
19
26
  onUpdateValue?: OnUpdateValue<T>;
20
27
  onUpdateValidValue?: OnUpdateValue<T>;
28
+ onUserAction?: OnUserAction<T>;
21
29
  };
22
30
  type CoreInput<T = any> = UniInput<T> & StyleTags.States & {
23
31
  className?: string;
24
32
  wrapStyles?: StyleTags.States;
25
33
  };
26
34
  namespace Validation {
27
- type EventType = 'init' | 'update' | 'override' | 'refresh';
35
+ type EventType = 'init' | 'update' | 'override' | 'refresh' | "composing.start" | "composing.end" | "focus.start" | "focus.end";
28
36
  type Notice = {
29
37
  type: 'valid' | 'invalid' | 'warn';
30
38
  label: ReactElement;
@@ -45,6 +53,8 @@ export declare namespace InputTypes {
45
53
  dataValue: T;
46
54
  eventType: Validation.EventType;
47
55
  eventID: string;
56
+ isFocusing?: boolean;
57
+ isComposing?: boolean;
48
58
  };
49
59
  type Text = Plain & {
50
60
  formatValue: any;
@@ -1 +1 @@
1
- import"../../chunk-C5N2D3ZX.js";import*as t from"./Parts";export*from"./Parts";import i from"./Plain";import a from"./Hidden";import p from"./TextField";import m from"./Contenteditable";import l from"./DigitCharacters";import n from"./Time";import d from"./Select";import x from"./Autocomplete";import*as r from"./List";import c from"./Search";import s from"./Filer";import y from"./Slider";import f from"./Switch";import T from"./Checker";import g from"./Segmented";import S from"./Color";import b from"./CollectForm";var o;(e=>(e.Plain=i,e.Hidden=a,e.TextField=p,e.Contenteditable=m,e.DigitCharacters=l,e.Time=n,e.Select=d,e.Autocomplete=x,e.List=r.List,e.Radio=r.Radio,e.Checkbox=r.Checkbox,e.Checker=T,e.Search=c,e.Filer=s,e.Slider=y,e.Switch=f,e.Segmented=g,e.Color=S,e.LeftIcon=t.LeftIcon,e.RightIcon=t.RightIcon,e.LeftIndicator=t.LeftIndicator,e.RightIndicator=t.RightIndicator,e.RequiredSign=t.RequiredSign,e.RequiredShortSign=t.RequiredShortSign,e.OmitSign=t.OmitSign,e.CollectForm=b))(o||(o={}));export{o as Input,o as default};
1
+ import"../../chunk-C5N2D3ZX.js";import*as t from"./Parts";export*from"./Parts";import i from"./Plain";import a from"./Hidden";import p from"./TextField";import m from"./Contenteditable";import n from"./DigitCharacters";import l from"./Time";import s from"./Select";import d from"./Autocomplete";import*as r from"./List";import c from"./Search";import x from"./Filer";import y from"./Slider";import f from"./Switch";import T from"./Checker";import g from"./Segmented";import S from"./Color";import b from"./CollectForm";var o;(e=>(e.Plain=i,e.Hidden=a,e.TextField=p,e.Contenteditable=m,e.DigitCharacters=n,e.Time=l,e.Select=s,e.Autocomplete=d,e.List=r.List,e.Radio=r.Radio,e.Checkbox=r.Checkbox,e.Checker=T,e.Search=c,e.Filer=x,e.Slider=y,e.Switch=f,e.Segmented=g,e.Color=S,e.LeftIcon=t.LeftIcon,e.RightIcon=t.RightIcon,e.LeftIndicator=t.LeftIndicator,e.RightIndicator=t.RightIndicator,e.RequiredSign=t.RequiredSign,e.RequiredShortSign=t.RequiredShortSign,e.OmitSign=t.OmitSign,e.CollectForm=b))(o||(o={}));export{o as Input,o as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amotify",
3
- "version": "0.2.197",
3
+ "version": "0.2.198",
4
4
  "description": "UI Component for React,NextJS,esbuild",
5
5
  "scripts": {
6
6
  "start": "run-p clean build:*",