amotify 0.2.142 → 0.2.143

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.
@@ -34,7 +34,7 @@ declare namespace Autocomplete {
34
34
  type Value<T = any> = T extends infer V ? V : string | number | boolean | KeyValueDict | void | null;
35
35
  type Option<T = Value> = {
36
36
  type?: 'selector';
37
- label: ReactElement;
37
+ label?: ReactElement;
38
38
  value: T;
39
39
  searchValue?: string;
40
40
  } | {
@@ -1 +1 @@
1
- import{b as S,c as O,d as Q,e as Y}from"../../chunk-C5N2D3ZX.js";import{Fragment as X,jsx as o,jsxs as P}from"react/jsx-runtime";import{useState as I,useEffect as E,useRef as ne}from"react";import c,{UUID as W}from"jmini";import{ExtractStyles as ae}from"../../@utils";import{Box as R,Span as re,FAI as M,Column as ie}from"../../atoms";import{Text as N,Row as q}from"../../mols";import{Button as Z}from"../Button";import{Loader as se}from"../Loader";import{Sheet as ue}from"../Sheet";import{OptionalInputWrapper as ce,BoxWrapper as pe,CoreEffects as z,DefaultBoxishStyles as de}from"./core";import{InputAutocompleteClasses as U}from"../../@styles/componentClasses";import{InputLabel as Se}from"./Label";import{RightIcon as ee}from".";function me(e){let{value:t,states:s}=e,{required:u,options:r,min:l,max:f}=s;l=l||0,f=f||65535;let v=[],p=t.filter(d=>d!==null).length;return u&&(p||v.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),p<l&&v.push({type:"invalid",label:l+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),p>f&&v.push({type:"invalid",label:f+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!v.filter(({type:d})=>d=="invalid").length,notice:v}}const B={InitOptions:e=>{let t=[];return e.forEach(s=>{let{type:u,label:r,value:l,searchValue:f}=s,v=f||(c.is.string(r)?r:"")||(c.is.string(l)?l:"");t.push(O(S({},s),{searchValue:v,type:u||"selector",value:l}))}),t},FilterSelectableOptions:(e,t)=>{let s=e.val_options;if(t||(s=e.val_options.filter(u=>u.type!="label")),e.val_keyword){let u=e.val_keyword.toLower().replace(/ /g,"");s=s.filter(r=>(r.searchValue||"").toLower().replace(/ /g,"").includes(u))}return s}},L={Shallow:e=>{let{rootStates:t,val_status:s}=e,u=ae(t);return o(R,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:o(N.Description,O(S({className:t.className},u),{position:"absolute",width:1,freeCSS:O(S({},u.freeCSS),{color:"orange"}),"data-id":"shallow_"+s.componentID,children:o(R,{"data-input-value-shallow":s.componentID,children:"A"})}))})},Button:e=>{let{rootStates:t,val_keyword:s,set_keyword:u,val_optionFocused:r,set_optionFocused:l,val_options:f,set_options:v,val_optionsDict:p,set_optionsDict:d,val_preventOpenSelectorOnFocus:n,set_preventOpenSelectorOnFocus:m,val_selectorOpen:a,set_selectorOpen:i,val_status:y,set_status:w,val_validate:b,set_validate:C}=e,j=t,{tone:_,required:k,form:D,className:x,multiSelect:K,enableFormSubmit:T,checkValidationAtFirst:A,onValidate:$,onUpdateValue:J,onUpdateValidValue:H,value:fe="",options:ve,leftIndicator:ye,rightIndicator:he,leftIcon:_e,rightIcon:ge,componentID:be,status_id:Oe,wrapStyles:Ie,emptySelect:Ce,SearchInput:De,SearchInputPlaceholder:we,SelectedComponent:Te,SelectorComponent:Ve,SelectorStyles:ke,SelectorPosition:xe,DynamicOptionsOnSearch:Re}=j,g=Q(j,["tone","required","form","className","multiSelect","enableFormSubmit","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","wrapStyles","emptySelect","SearchInput","SearchInputPlaceholder","SelectedComponent","SelectorComponent","SelectorStyles","SelectorPosition","DynamicOptionsOnSearch"]);return E(()=>{var V,F;if(t.disabled||!a)return;let h=B.FilterSelectableOptions(e);l((F=(V=h[0])==null?void 0:V.value)!=null?F:null)},[s]),E(()=>{y.eventType!="init"&&(t.max==y.dataValue.length?(i(!1),m(!0),setTimeout(()=>{let h=c('[data-input-origin="'+t.componentID+'"]');h&&h.focus()},10)):c("#SearchInput_"+t.componentID).focus())},[y.dataValue]),E(()=>{let h="autocomplete-click-"+t.componentID;if(a){if(!c('[data-input-origin="'+t.componentID+'"]'))return;c("#SearchInput_"+t.componentID).focus(),c(document).addEvent({eventID:h,eventType:"mousedown",callback:F=>{let G=c(F.target),oe=!!c(G).parent("."+U("Core")).length,le=!!c(G).parent("."+U("Selector")).length;oe||le||(i(!1),F.preventDefault(),F.stopPropagation())}})}else c(document).removeEvent([h]),u("")},[a]),P(X,{children:[o(R,O(S({tabIndex:0},g),{"data-disabled":t.disabled,"data-show-validation":z.isShowValidation(b,y,!!A),"data-component-id":y.componentID,"data-input-origin":y.componentID,"data-focus":!!a,className:[x,U("Core")].join(" "),onFocus:h=>{if(g!=null&&g.onFocus&&(g==null||g.onFocus(h)),!t.disabled){if(n)return m(!1);i(!0),h.preventDefault()}},onClick:h=>{g!=null&&g.onClick&&(g==null||g.onClick(h)),!t.disabled&&i(!0)},onKeyDown:h=>{let{key:V}=h;T&&z.SubmitForm(h,D),!a&&(V==" "||V=="ArrowDown"||V=="ArrowUp"||V=="Enter")&&i(!0)},children:P(q.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[o(L.Selected,S({},e)),o(re,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),o(L.SearchInput,S({},e))]})})),a&&o(L.Selector,S({},e))]})},SearchInput:e=>{let{rootStates:t}=e,[s,u]=I(!1);return t.disabled||!e.val_selectorOpen?null:o(R,{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:r=>{t.onCompositionStart&&t.onCompositionStart(r),u(!0)},onCompositionEnd:r=>{t.onCompositionEnd&&t.onCompositionEnd(r),u(!1)},onKeyDown:r=>{let{key:l,metaKey:f,ctrlKey:v}=r,p=f||v;l=="Escape"?(e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0),setTimeout(()=>{let d=c('[data-input-origin="'+t.componentID+'"]');d&&d.focus()},10)):l=="Tab"?e.set_selectorOpen(!1):l==" "?c.scope(()=>{e.val_selectorOpen||e.val_keyword||(r.preventDefault(),e.set_selectorOpen(!0))}):l=="Backspace"?c.scope(()=>{if(e.val_keyword)return;let d=[...e.val_status.dataValue];d.pop(),e.set_status(n=>O(S({},n),{dataValue:d,eventType:"update",eventID:W()}))}):l=="Enter"&&c.scope(()=>{if(s)return;if(!e.val_selectorOpen)return e.set_selectorOpen(!0);let d=e.val_options.find(m=>m.value==e.val_optionFocused);if(!d)return;let{value:n}=d;e.set_status(m=>{let a=[...m.dataValue];return c.scope(()=>{if(n===null)return a=[];m.dataValue.includes(n)?a=a.filter(y=>y!==n):t.multiSelect?a.push(n):a=[n]}),O(S({},m),{dataValue:a,eventType:"update",eventID:W()})}),e.set_keyword(""),e.set_preventDynamicSearchOnKeywordChange(!0)}),c.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(l))return;if(r.preventDefault(),!e.val_selectorOpen)return e.set_selectorOpen(!0);let d=l=="ArrowDown"?1:-1,n=B.FilterSelectableOptions(e),m=n.length-1,a=null;c.scope(()=>{var y,w,b,C,_,k,D,x,K,T;let i=n.findIndex(A=>A.value==e.val_optionFocused);if(i==-1&&(i=0),d==1){if(a=(w=(y=n[0])==null?void 0:y.value)!=null?w:null,p){a=(b=n[m].value)!=null?b:null;return}if(i==-1||i==m)return;a=(_=(C=n[i+1])==null?void 0:C.value)!=null?_:null}else{if(a=(k=n[m].value)!=null?k:null,p){a=(x=(D=n[0])==null?void 0:D.value)!=null?x:null;return}if(i==-1||i==0)return;a=(T=(K=n[i-1])==null?void 0:K.value)!=null?T:null}}),e.set_optionFocused(a)}),t.enableFormSubmit&&z.SubmitForm(r,e.rootStates.form)},onChange:r=>{let f=r.target.value;e.set_keyword(f)}},"searchInput")},Selector:e=>{var d;let[t,s]=I("idle"),[u,r]=I("idle");E(()=>{if(!e.val_selectorOpen||!e.rootStates.DynamicOptionsOnSearch)return;if(e.val_preventDynamicSearchOnKeywordChange)return e.set_preventDynamicSearchOnKeywordChange(!1);if(t=="idle")return s("ok");r("fetch");let n="autocomplete-search-"+e.rootStates.componentID;c.interval.once(()=>Y(void 0,null,function*(){let m=yield e.rootStates.DynamicOptionsOnSearch(e.val_keyword);r("idle");let a=B.InitOptions(m||[]);e.set_options(a)}),300,n)},[e.val_keyword]);let l=[],f=B.FilterSelectableOptions(e,!0),v=B.FilterSelectableOptions(e);f.forEach((n,m)=>{let{type:a,value:i}=n,y=e.val_optionFocused==i,w=e.val_status.dataValue.includes(i),b=e.rootStates.SelectorComponent;l.push(o(b,{option:n,isFocused:y,isSelected:w,addCallback:()=>{e.set_status(C=>{let _=[...C.dataValue];return c.scope(()=>{if(i===null)return _=[];C.dataValue.includes(i)?_=_.filter(D=>D!==i):e.rootStates.multiSelect?_.push(i):_=[i]}),O(S({},C),{dataValue:_,eventType:"update",eventID:W()})})}},c.Stringify(i)||W()))}),v.length||(l=[o(N.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]),u=="fetch"&&(l=[P(q.Left,{padding:1,fontColor:"3.blur",children:[o(se.Theme.R,{showInitial:!0}),o(N.Supplement,{children:"Loading..."})]},"loader")]);let p={position:"absolute",minWidth:1,freeCSS:{zIndex:1e3}};switch(e.rootStates.SelectorPosition){case 1:p.bottom="100%",p.left=0,p.paddingBottom="1/3";break;case 2:p.bottom="100%",p.right=0,p.paddingBottom="1/3";break;case 3:p.top="100%",p.left=0,p.paddingTop="1/3";break;case 4:p.top="100%",p.right=0,p.paddingTop="1/3";break;default:break}return o(R,O(S({},p),{children:o(ue.Body,O(S({className:U("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,boxShadow:"1.normal",overflow:"auto"},e.rootStates.SelectorStyles),{freeCSS:S({maxHeight:12*24},(d=e.rootStates.SelectorStyles)==null?void 0:d.freeCSS),children:o(ie,{gap:"1/12",padding:[1,0],children:l})}))}))},Selected:e=>{let{rootStates:t,val_status:s,set_status:u,val_optionsDict:r}=e,l=[];return s.dataValue.forEach(f=>{let v=r[c.Stringify(f)];if(!v)return;let p=t.SelectedComponent,d=v.label;v.value===null&&(d=""),l.push(o(R,{className:U("SelectedCell"),children:o(p,{value:v.value,label:d,removeCallback:n=>{if(n.stopPropagation(),n.preventDefault(),t.disabled)return;let m=[...s.dataValue];m=m.filter(a=>a!==f),u(a=>O(S({},a),{dataValue:m,eventType:"update",eventID:W()}))}})},c.Stringify(v.value)))}),o(X,{children:l})},Core:e=>{var A;let{value:t}=e,[s,u]=I(!1),[r,l]=I(!1),[f,v]=I(!1),[p,d]=I(""),[n,m]=I(e.options),[a,i]=I((A=e.value[0])!=null?A:null),[y,w]=I({}),[b,C]=I(z.DefaultStatus(e.componentID,t)),[_,k]=I({ok:!1,notice:[]}),D=ne(!1);E(()=>{D.current?m(e.options):D.current=!0},[e.options]),E(()=>{if(!n.length)return;let $=[...n],J=S({},y);$.forEach(H=>{H.type!="label"&&(J[c.Stringify(H.value)]=H)}),w(J)},[n]);let x={rootStates:e,val_options:n,set_options:m,val_optionFocused:a,set_optionFocused:i,val_optionsDict:y,set_optionsDict:w,val_preventDynamicSearchOnKeywordChange:r,set_preventDynamicSearchOnKeywordChange:l,val_preventOpenSelectorOnFocus:s,set_preventOpenSelectorOnFocus:u,val_selectorOpen:f,set_selectorOpen:v,val_keyword:p,set_keyword:d,val_status:b,set_status:C,val_validate:_,set_validate:k},K=!!e.multiSelect;z.CommonEffects({type:K?"autocomplete.multi":"autocomplete.single",states:e,val_status:b,set_status:C,val_validate:_,set_validate:k,SystemValidation:me});let T=b.dataValue.length&&b.dataValue[0]!==null;return T=T||f,P(pe,{val_status:b,set_status:C,val_validate:_,states:e,children:[o(Se,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:T}),o(L.Shallow,S({},x)),o(L.Button,S({},x))]})}},te=e=>{var s;let t=S({},e);return t=O(S({value:[],min:0,max:65535,multiSelect:!0,SearchInput:!0,emptySelect:!0,SelectorComponent:({option:u,isSelected:r,isFocused:l,addCallback:f})=>u.type=="selector"?o(Z.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1.5],isActive:l,isActiveStyles:{backgroundColor:"cloud"},onClick:v=>{f()},children:P(q.Left,{gap:"1/2",children:[r&&o(M.Check,{fontColor:"theme"}),o(N.Supplement,{transition:"short",children:u.label})]})}):o(X,{children:u.label}),SelectedComponent:({value:u,label:r,removeCallback:l})=>P(q.Left,{ssCardBox:"cloud",borderRadius:"2.tone.secondary",fontSize:"1.mini",padding:"1/2",gap:0,children:[o(R,{padding:[0,"1/4"],children:r}),o(Z.Sub,{flexSizing:"none",color:"cloud",fontColor:"white",backgroundColor:"layer.5",isRounded:!0,padding:"1/4",onClick:l,freeCSS:{lineHeight:1,aspectRatio:"1/1"},children:o(M.Times,{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:o(N.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=c.flatArray((s=t.value)!=null?s:null),t.options=B.InitOptions(t.options),c.is.nullish(t.rightIcon)&&(t.rightIcon=o(ee,{ssSphere:2,children:o(M.Search,{})}),t.disabled&&(t.rightIcon=o(ee,{ssSphere:2,fontColor:"5.translucent",children:o(M.Ban,{})}))),t.rightIcon&&(t=S({paddingRight:3},t)),t.leftIcon&&(t=S({paddingLeft:3},t)),o(ce,{componentID:t.componentID,children:L.Core,states:de(t)})};export{te as Autocomplete,te as default};
1
+ import{b as S,c as O,d as Q,e as Y}from"../../chunk-C5N2D3ZX.js";import{Fragment as X,jsx as l,jsxs as P}from"react/jsx-runtime";import{useState as I,useEffect as E,useRef as ne}from"react";import s,{UUID as W}from"jmini";import{ExtractStyles as ae}from"../../@utils";import{Box as R,Span as re,FAI as M,Column as ie}from"../../atoms";import{Text as N,Row as q}from"../../mols";import{Button as Z}from"../Button";import{Loader as se}from"../Loader";import{Sheet as ue}from"../Sheet";import{OptionalInputWrapper as ce,BoxWrapper as pe,CoreEffects as z,DefaultBoxishStyles as de}from"./core";import{InputAutocompleteClasses as U}from"../../@styles/componentClasses";import{InputLabel as Se}from"./Label";import{RightIcon as ee}from".";function me(e){let{value:t,states:u}=e,{required:c,options:n,min:o,max:f}=u;o=o||0,f=f||65535;let v=[],p=t.filter(d=>d!==null).length;return c&&(p||v.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),p<o&&v.push({type:"invalid",label:o+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),p>f&&v.push({type:"invalid",label:f+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!v.filter(({type:d})=>d=="invalid").length,notice:v}}const B={InitOptions:e=>{let t=[];return e.forEach(u=>{let{type:c,label:n,value:o,searchValue:f}=u,v=f||(s.is.string(n)?n:"")||(s.is.string(o)?o:"");s.is.nullish(n)&&(n=String(o)),t.push(O(S({},u),{searchValue:v,type:c||"selector",label:n,value:o}))}),t},FilterSelectableOptions:(e,t)=>{let u=e.val_options;if(t||(u=e.val_options.filter(c=>c.type!="label")),e.val_keyword){let c=e.val_keyword.toLower().replace(/ /g,"");u=u.filter(n=>(n.searchValue||"").toLower().replace(/ /g,"").includes(c))}return u}},L={Shallow:e=>{let{rootStates:t,val_status:u}=e,c=ae(t);return l(R,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:l(N.Description,O(S({className:t.className},c),{position:"absolute",width:1,freeCSS:O(S({},c.freeCSS),{color:"orange"}),"data-id":"shallow_"+u.componentID,children:l(R,{"data-input-value-shallow":u.componentID,children:"A"})}))})},Button:e=>{let{rootStates:t,val_keyword:u,set_keyword:c,val_optionFocused:n,set_optionFocused:o,val_options:f,set_options:v,val_optionsDict:p,set_optionsDict:d,val_preventOpenSelectorOnFocus:a,set_preventOpenSelectorOnFocus:m,val_selectorOpen:r,set_selectorOpen:i,val_status:y,set_status:w,val_validate:b,set_validate:C}=e,j=t,{tone:_,required:k,form:D,className:x,multiSelect:K,enableFormSubmit:T,checkValidationAtFirst:A,onValidate:$,onUpdateValue:J,onUpdateValidValue:H,value:fe="",options:ve,leftIndicator:ye,rightIndicator:he,leftIcon:_e,rightIcon:ge,componentID:be,status_id:Oe,wrapStyles:Ie,emptySelect:Ce,SearchInput:De,SearchInputPlaceholder:we,SelectedComponent:Te,SelectorComponent:Ve,SelectorStyles:ke,SelectorPosition:xe,DynamicOptionsOnSearch:Re}=j,g=Q(j,["tone","required","form","className","multiSelect","enableFormSubmit","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","wrapStyles","emptySelect","SearchInput","SearchInputPlaceholder","SelectedComponent","SelectorComponent","SelectorStyles","SelectorPosition","DynamicOptionsOnSearch"]);return E(()=>{var V,F;if(t.disabled||!r)return;let h=B.FilterSelectableOptions(e);o((F=(V=h[0])==null?void 0:V.value)!=null?F:null)},[u]),E(()=>{y.eventType!="init"&&(t.max==y.dataValue.length?(i(!1),m(!0),setTimeout(()=>{let h=s('[data-input-origin="'+t.componentID+'"]');h&&h.focus()},10)):s("#SearchInput_"+t.componentID).focus())},[y.dataValue]),E(()=>{let h="autocomplete-click-"+t.componentID;if(r){if(!s('[data-input-origin="'+t.componentID+'"]'))return;s("#SearchInput_"+t.componentID).focus(),s(document).addEvent({eventID:h,eventType:"mousedown",callback:F=>{let G=s(F.target),oe=!!s(G).parent("."+U("Core")).length,le=!!s(G).parent("."+U("Selector")).length;oe||le||(i(!1),F.preventDefault(),F.stopPropagation())}})}else s(document).removeEvent([h]),c("")},[r]),P(X,{children:[l(R,O(S({tabIndex:0},g),{"data-disabled":t.disabled,"data-show-validation":z.isShowValidation(b,y,!!A),"data-component-id":y.componentID,"data-input-origin":y.componentID,"data-focus":!!r,className:[x,U("Core")].join(" "),onFocus:h=>{if(g!=null&&g.onFocus&&(g==null||g.onFocus(h)),!t.disabled){if(a)return m(!1);i(!0),h.preventDefault()}},onClick:h=>{g!=null&&g.onClick&&(g==null||g.onClick(h)),!t.disabled&&i(!0)},onKeyDown:h=>{let{key:V}=h;T&&z.SubmitForm(h,D),!r&&(V==" "||V=="ArrowDown"||V=="ArrowUp"||V=="Enter")&&i(!0)},children:P(q.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(L.Selected,S({},e)),l(re,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),l(L.SearchInput,S({},e))]})})),r&&l(L.Selector,S({},e))]})},SearchInput:e=>{let{rootStates:t}=e,[u,c]=I(!1);return t.disabled||!e.val_selectorOpen?null:l(R,{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),c(!0)},onCompositionEnd:n=>{t.onCompositionEnd&&t.onCompositionEnd(n),c(!1)},onKeyDown:n=>{let{key:o,metaKey:f,ctrlKey:v}=n,p=f||v;o=="Escape"?(e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0),setTimeout(()=>{let d=s('[data-input-origin="'+t.componentID+'"]');d&&d.focus()},10)):o=="Tab"?e.set_selectorOpen(!1):o==" "?s.scope(()=>{e.val_selectorOpen||e.val_keyword||(n.preventDefault(),e.set_selectorOpen(!0))}):o=="Backspace"?s.scope(()=>{if(e.val_keyword)return;let d=[...e.val_status.dataValue];d.pop(),e.set_status(a=>O(S({},a),{dataValue:d,eventType:"update",eventID:W()}))}):o=="Enter"&&s.scope(()=>{if(u)return;if(!e.val_selectorOpen)return e.set_selectorOpen(!0);let d=e.val_options.find(m=>m.value==e.val_optionFocused);if(!d)return;let{value:a}=d;e.set_status(m=>{let r=[...m.dataValue];return s.scope(()=>{if(a===null)return r=[];m.dataValue.includes(a)?r=r.filter(y=>y!==a):t.multiSelect?r.push(a):r=[a]}),O(S({},m),{dataValue:r,eventType:"update",eventID:W()})}),e.set_keyword(""),e.set_preventDynamicSearchOnKeywordChange(!0)}),s.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(o))return;if(n.preventDefault(),!e.val_selectorOpen)return e.set_selectorOpen(!0);let d=o=="ArrowDown"?1:-1,a=B.FilterSelectableOptions(e),m=a.length-1,r=null;s.scope(()=>{var y,w,b,C,_,k,D,x,K,T;let i=a.findIndex(A=>A.value==e.val_optionFocused);if(i==-1&&(i=0),d==1){if(r=(w=(y=a[0])==null?void 0:y.value)!=null?w:null,p){r=(b=a[m].value)!=null?b:null;return}if(i==-1||i==m)return;r=(_=(C=a[i+1])==null?void 0:C.value)!=null?_:null}else{if(r=(k=a[m].value)!=null?k:null,p){r=(x=(D=a[0])==null?void 0:D.value)!=null?x:null;return}if(i==-1||i==0)return;r=(T=(K=a[i-1])==null?void 0:K.value)!=null?T:null}}),e.set_optionFocused(r)}),t.enableFormSubmit&&z.SubmitForm(n,e.rootStates.form)},onChange:n=>{let f=n.target.value;e.set_keyword(f)}},"searchInput")},Selector:e=>{var d;let[t,u]=I("idle"),[c,n]=I("idle");E(()=>{if(!e.val_selectorOpen||!e.rootStates.DynamicOptionsOnSearch)return;if(e.val_preventDynamicSearchOnKeywordChange)return e.set_preventDynamicSearchOnKeywordChange(!1);if(t=="idle")return u("ok");n("fetch");let a="autocomplete-search-"+e.rootStates.componentID;s.interval.once(()=>Y(void 0,null,function*(){let m=yield e.rootStates.DynamicOptionsOnSearch(e.val_keyword);n("idle");let r=B.InitOptions(m||[]);e.set_options(r)}),300,a)},[e.val_keyword]);let o=[],f=B.FilterSelectableOptions(e,!0),v=B.FilterSelectableOptions(e);f.forEach((a,m)=>{let{type:r,value:i}=a,y=e.val_optionFocused==i,w=e.val_status.dataValue.includes(i),b=e.rootStates.SelectorComponent;o.push(l(b,{option:a,isFocused:y,isSelected:w,addCallback:()=>{e.set_status(C=>{let _=[...C.dataValue];return s.scope(()=>{if(i===null)return _=[];C.dataValue.includes(i)?_=_.filter(D=>D!==i):e.rootStates.multiSelect?_.push(i):_=[i]}),O(S({},C),{dataValue:_,eventType:"update",eventID:W()})})}},s.Stringify(i)||W()))}),v.length||(o=[l(N.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]),c=="fetch"&&(o=[P(q.Left,{padding:1,fontColor:"3.blur",children:[l(se.Theme.R,{showInitial:!0}),l(N.Supplement,{children:"Loading..."})]},"loader")]);let p={position:"absolute",minWidth:1,freeCSS:{zIndex:1e3}};switch(e.rootStates.SelectorPosition){case 1:p.bottom="100%",p.left=0,p.paddingBottom="1/3";break;case 2:p.bottom="100%",p.right=0,p.paddingBottom="1/3";break;case 3:p.top="100%",p.left=0,p.paddingTop="1/3";break;case 4:p.top="100%",p.right=0,p.paddingTop="1/3";break;default:break}return l(R,O(S({},p),{children:l(ue.Body,O(S({className:U("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,boxShadow:"1.normal",overflow:"auto"},e.rootStates.SelectorStyles),{freeCSS:S({maxHeight:12*24},(d=e.rootStates.SelectorStyles)==null?void 0:d.freeCSS),children:l(ie,{gap:"1/12",padding:[1,0],children:o})}))}))},Selected:e=>{let{rootStates:t,val_status:u,set_status:c,val_optionsDict:n}=e,o=[];return u.dataValue.forEach(f=>{let v=n[s.Stringify(f)];if(!v)return;let p=t.SelectedComponent,d=v.label;v.value===null&&(d=""),o.push(l(R,{className:U("SelectedCell"),children:l(p,{value:v.value,label:d,removeCallback:a=>{if(a.stopPropagation(),a.preventDefault(),t.disabled)return;let m=[...u.dataValue];m=m.filter(r=>r!==f),c(r=>O(S({},r),{dataValue:m,eventType:"update",eventID:W()}))}})},s.Stringify(v.value)))}),l(X,{children:o})},Core:e=>{var A;let{value:t}=e,[u,c]=I(!1),[n,o]=I(!1),[f,v]=I(!1),[p,d]=I(""),[a,m]=I(e.options),[r,i]=I((A=e.value[0])!=null?A:null),[y,w]=I({}),[b,C]=I(z.DefaultStatus(e.componentID,t)),[_,k]=I({ok:!1,notice:[]}),D=ne(!1);E(()=>{D.current?m(e.options):D.current=!0},[e.options]),E(()=>{if(!a.length)return;let $=[...a],J=S({},y);$.forEach(H=>{H.type!="label"&&(J[s.Stringify(H.value)]=H)}),w(J)},[a]);let x={rootStates:e,val_options:a,set_options:m,val_optionFocused:r,set_optionFocused:i,val_optionsDict:y,set_optionsDict:w,val_preventDynamicSearchOnKeywordChange:n,set_preventDynamicSearchOnKeywordChange:o,val_preventOpenSelectorOnFocus:u,set_preventOpenSelectorOnFocus:c,val_selectorOpen:f,set_selectorOpen:v,val_keyword:p,set_keyword:d,val_status:b,set_status:C,val_validate:_,set_validate:k},K=!!e.multiSelect;z.CommonEffects({type:K?"autocomplete.multi":"autocomplete.single",states:e,val_status:b,set_status:C,val_validate:_,set_validate:k,SystemValidation:me});let T=b.dataValue.length&&b.dataValue[0]!==null;return T=T||f,P(pe,{val_status:b,set_status:C,val_validate:_,states:e,children:[l(Se,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:T}),l(L.Shallow,S({},x)),l(L.Button,S({},x))]})}},te=e=>{var u;let t=S({},e);return t=O(S({value:[],min:0,max:65535,multiSelect:!0,SearchInput:!0,emptySelect:!0,SelectorComponent:({option:c,isSelected:n,isFocused:o,addCallback:f})=>c.type=="selector"?l(Z.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1.5],isActive:o,isActiveStyles:{backgroundColor:"cloud"},onClick:v=>{f()},children:P(q.Left,{gap:"1/2",children:[n&&l(M.Check,{fontColor:"theme"}),l(N.Supplement,{transition:"short",children:c.label})]})}):l(X,{children:c.label}),SelectedComponent:({value:c,label:n,removeCallback:o})=>P(q.Left,{ssCardBox:"cloud",borderRadius:"2.tone.secondary",fontSize:"1.mini",padding:"1/2",gap:0,children:[l(R,{padding:[0,"1/4"],children:n}),l(Z.Sub,{flexSizing:"none",color:"cloud",fontColor:"white",backgroundColor:"layer.5",isRounded:!0,padding:"1/4",onClick:o,freeCSS:{lineHeight:1,aspectRatio:"1/1"},children:l(M.Times,{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(N.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=s.flatArray((u=t.value)!=null?u:null),t.options=B.InitOptions(t.options),s.is.nullish(t.rightIcon)&&(t.rightIcon=l(ee,{ssSphere:2,children:l(M.Search,{})}),t.disabled&&(t.rightIcon=l(ee,{ssSphere:2,fontColor:"5.translucent",children:l(M.Ban,{})}))),t.rightIcon&&(t=S({paddingRight:3},t)),t.leftIcon&&(t=S({paddingLeft:3},t)),l(ce,{componentID:t.componentID,children:L.Core,states:de(t)})};export{te as Autocomplete,te as default};
@@ -37,7 +37,7 @@ declare namespace List {
37
37
  type Value<T = any> = T extends infer V ? V : string | number | boolean | KeyValueDict | void | null;
38
38
  type Option<T = Value> = {
39
39
  value: T;
40
- label: ReactElement;
40
+ label?: ReactElement;
41
41
  disabled?: boolean;
42
42
  className?: string;
43
43
  checkedStyles?: StyleTags.PropsNFreeCSS;
@@ -1 +1 @@
1
- import{b as o,c as m,d as B}from"../../chunk-C5N2D3ZX.js";import{jsx as a}from"react/jsx-runtime";import f,{UUID as w}from"jmini";import{useState as ae}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 M}from"./core";import{InputListClasses as T}from"../../@styles/componentClasses";function Ce(t){let{value:l,states:i}=t,{type:e,required:d,min:n,max:p}=i;n=n||0,p=p||65535;let s=[],S=l.length;return d&&(S||e=="radio"&&s.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),S<n&&s.push({type:"invalid",label:n+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),S>p&&s.push({type:"invalid",label:p+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!s.filter(({type:k})=>k=="invalid").length,notice:s}}const h={OptionalListWrapper:t=>{let{value:l,options:i=[]}=t,e=f.is.exist(l)?f.flatArray(l):[],d=[];return e.forEach(n=>{i.findIndex(s=>f.is.equal(s.value,n))!=-1&&d.push(n)}),a(h.Core,m(o({},t),{value:d,options:i}))},Core:t=>{let D=t,{type:l,tone:i,required:e,componentID:d="",form:n,override:p,icon:s,iconType:S,iconSize:k,iconPosition:P,iconColor:V,CustomIcon:X,enableFormSubmit:A,checkValidationAtFirst:$,onValidate:W,onUpdateValue:v,onUpdateValidValue:U,value:_,options:K,className:x,cellStyles:q,cellClassName:H,cellCheckedStyles:j,cellCheckedClassName:G,min:Q,max:Y,hideInput:E,freeCSS:u,wrapStyles:N}=D,b=B(D,["type","tone","required","componentID","form","override","icon","iconType","iconSize","iconPosition","iconColor","CustomIcon","enableFormSubmit","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","value","options","className","cellStyles","cellClassName","cellCheckedStyles","cellCheckedClassName","min","max","hideInput","freeCSS","wrapStyles"]),[L,C]=ae(M.DefaultStatus(d,_)),[O,Z]=ae({ok:!1,notice:[]});return M.CommonEffects({type:"list."+l,states:t,val_status:L,set_status:C,val_validate:O,set_validate:Z,SystemValidation:Ce}),a(pe,{val_status:L,set_status:C,val_validate:O,states:t,children:a(h.List,{rootStates:t,val_status:L,set_status:C})})},List:t=>{let{rootStates:l,val_status:i,set_status:e}=t,{componentID:d,type:n,tone:p,icon:s,iconSize:S,iconColor:k,isChecker:P,options:V,name:X,form:A,tabIndex:$,hideInput:W,disabled:v,className:U,cellStyles:_,cellClassName:K="",cellCheckedStyles:x,cellCheckedClassName:q="",enableFormSubmit:H}=l,{dataValue:j}=i,G=l.CustomIcon,Q=V.map((Y,E)=>{let le=Y,{value:u,label:N,disabled:b,className:L="",checkedStyles:C,checkedClassName:O="",freeCSS:Z}=le,D=B(le,["value","label","disabled","className","checkedStyles","checkedClassName","freeCSS"]),ee=w(),R=j.findIndex(r=>r===u)!=-1,y=o(o({},_),D),z=[T("Label"),K,L];R&&(y=m(o(o(o({},y),x),C),{freeCSS:o(o(o({},y==null?void 0:y.freeCSS),x==null?void 0:x.freeCSS),C==null?void 0:C.freeCSS)}),z=[...z,q,O]);const te=()=>{if(v||b)return;let r=[];if(n=="radio")r=[u];else if(n=="checkbox"||P)if(!R)r=[...i.dataValue,u];else{let c=[...i.dataValue];c.splice(i.dataValue.findIndex(F=>F==u),1),r=c}e(c=>m(o({},c),{dataValue:r,eventType:"update",eventID:w()}))};let oe=[a(de,{position:"relative",freeCSS:{zIndex:2},flexSizing:0,children:f.is.string(N)?a(I,{children:N}):N},"content")];return s&&oe[l.iconPosition=="right"?"push":"unshift"](a(G,{isChecked:R,iconSize:S,iconColor:k,toggle:te},"icon")),[a(I,{htmlTag:"input",type:n=="radio"?"radio":"checkbox",className:T("Input"),name:"RadioCheckbox-"+X,"data-list-index":d+"-"+E,id:ee,value:String(u),disabled:v||b,checked:R,onFocus:r=>{b||n=="radio"&&(i.dataValue.length||e(c=>m(o({},c),{dataValue:[u],eventType:"update",eventID:w()})))},onChange:()=>{te()},onKeyDown:r=>{let{key:c,shiftKey:F}=r;if((n=="checkbox"||t.rootStates.isChecker)&&c!="Tab"){if(c.match(/Arrow/)){r.preventDefault();let ie=["ArrowLeft","ArrowUp"].includes(c)?-1:1,g=E+ie;g<0?g=V.length-1:g>=V.length&&(g=0),ne(`input[data-list-index="${d}-${g}"]`).focus()}}H&&M.SubmitForm(r,A)},tabIndex:$},"List-"+f.Stringify(u)),a(I,m(o({htmlTag:"label","data-disabled":v||b,htmlFor:ee,className:z.join(" "),tabIndex:-1,display:"flex",verticalAlign:"center",flexWrap:!1},y),{children:oe}),"ListTrigger-"+f.Stringify(u))]});return a(re,{flexSizing:"auto",style:l.style,freeCSS:o({},l.freeCSS),className:[U,T("CellBase"),T("HideInput_"+W),T("IconIndicator_"+!!s),T("Tone_"+p)].join(" "),children:Q})},_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,m(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,m(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)"}})})}))},J=t=>{t=t||"checkbox";const l=e=>(e=m(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),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=J("radio"),Se=J("checkbox"),ye=J();export{Se as Checkbox,ye as List,he as Radio};
1
+ import{b as o,c as d,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 I,Flex as re,FAI as ce,Span as ue}from"../../atoms";import{Button as de}from"../Button";import{OptionalInputWrapper as me,BoxWrapper as pe,CoreEffects as M}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:g})=>g=="invalid").length,notice:r}}const h={InitOptions:t=>{let l=[];return t.forEach(i=>{let{label:e,value:s}=i;S.is.nullish(e)&&(e=String(s)),l.push(d(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,d(o({},t),{value:s,options:i}))},Core:t=>{let D=t,{type:l,tone:i,required:e,componentID:s="",form:n,override:p,icon:r,iconType:y,iconSize:g,iconPosition:P,iconColor:V,CustomIcon:X,enableFormSubmit:A,checkValidationAtFirst:$,onValidate:W,onUpdateValue:v,onUpdateValidValue:H,value:_,options:U,className:b,cellStyles:K,cellClassName:q,cellCheckedStyles:j,cellCheckedClassName:G,min:Q,max:Y,hideInput:E,freeCSS:m,wrapStyles:N}=D,x=B(D,["type","tone","required","componentID","form","override","icon","iconType","iconSize","iconPosition","iconColor","CustomIcon","enableFormSubmit","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","value","options","className","cellStyles","cellClassName","cellCheckedStyles","cellCheckedClassName","min","max","hideInput","freeCSS","wrapStyles"]),[L,C]=ie(M.DefaultStatus(s,_)),[O,Z]=ie({ok:!1,notice:[]});return M.CommonEffects({type:"list."+l,states:t,val_status:L,set_status:C,val_validate:O,set_validate:Z,SystemValidation:Ce}),a(pe,{val_status:L,set_status:C,val_validate:O,states:t,children:a(h.List,{rootStates:t,val_status:L,set_status:C})})},List:t=>{let{rootStates:l,val_status:i,set_status:e}=t,{componentID:s,type:n,tone:p,icon:r,iconSize:y,iconColor:g,isChecker:P,options:V,name:X,form:A,tabIndex:$,hideInput:W,disabled:v,className:H,cellStyles:_,cellClassName:U="",cellCheckedStyles:b,cellCheckedClassName:K="",enableFormSubmit:q}=l,{dataValue:j}=i,G=l.CustomIcon,Q=V.map((Y,E)=>{let le=Y,{value:m,label:N,disabled:x,className:L="",checkedStyles:C,checkedClassName:O="",freeCSS:Z}=le,D=B(le,["value","label","disabled","className","checkedStyles","checkedClassName","freeCSS"]),ee=w(),R=j.findIndex(c=>c===m)!=-1,f=o(o({},_),D),z=[T("Label"),U,L];R&&(f=d(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)}),z=[...z,K,O]);const te=()=>{if(v||x)return;let c=[];if(n=="radio")c=[m];else if(n=="checkbox"||P)if(!R)c=[...i.dataValue,m];else{let u=[...i.dataValue];u.splice(i.dataValue.findIndex(F=>F==m),1),c=u}e(u=>d(o({},u),{dataValue:c,eventType:"update",eventID:w()}))};let oe=[a(ue,{position:"relative",freeCSS:{zIndex:2},flexSizing:0,children:S.is.string(N)?a(I,{children:N}):N},"content")];return r&&oe[l.iconPosition=="right"?"push":"unshift"](a(G,{isChecked:R,iconSize:y,iconColor:g,toggle:te},"icon")),[a(I,{htmlTag:"input",type:n=="radio"?"radio":"checkbox",className:T("Input"),name:"RadioCheckbox-"+X,"data-list-index":s+"-"+E,id:ee,value:String(m),disabled:v||x,checked:R,onFocus:c=>{x||n=="radio"&&(i.dataValue.length||e(u=>d(o({},u),{dataValue:[m],eventType:"update",eventID:w()})))},onChange:()=>{te()},onKeyDown:c=>{let{key:u,shiftKey:F}=c;if((n=="checkbox"||t.rootStates.isChecker)&&u!="Tab"){if(u.match(/Arrow/)){c.preventDefault();let ae=["ArrowLeft","ArrowUp"].includes(u)?-1:1,k=E+ae;k<0?k=V.length-1:k>=V.length&&(k=0),ne(`input[data-list-index="${s}-${k}"]`).focus()}}q&&M.SubmitForm(c,A)},tabIndex:$},"List-"+S.Stringify(m)),a(I,d(o({htmlTag:"label","data-disabled":v||x,htmlFor:ee,className:z.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:[H,T("CellBase"),T("HideInput_"+W),T("IconIndicator_"+!!r),T("Tone_"+p)].join(" "),children:Q})},_Icon:t=>{let l=1.5;return t.iconSize=="small"?l=1.2:t.iconSize=="large"&&(l=2),a(de.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,d(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,d(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)"}})})}))},J=t=>{t=t||"checkbox";const l=e=>(e=d(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=J("radio"),Se=J("checkbox"),ye=J();export{Se as Checkbox,ye as List,he as Radio};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amotify",
3
- "version": "0.2.142",
3
+ "version": "0.2.143",
4
4
  "description": "UI Component for React,NextJS,esbuild",
5
5
  "scripts": {
6
6
  "start": "run-p clean build:*",