amotify 0.2.81 → 0.2.83

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.
@@ -29,7 +29,6 @@ declare namespace Autocomplete {
29
29
  (p: SelectorComponentProps<T>): JSX.Element;
30
30
  };
31
31
  SelectorStyles?: StyleTags.PropsNFreeCSS;
32
- SelectorGravityPoint?: number;
33
32
  };
34
33
  type Value<T = any> = T extends infer V ? V : string | number | boolean | KeyValueDict | void | null;
35
34
  type Option<T = Value> = {
@@ -1 +1 @@
1
- import{b as S,c as b,d as Q,e as Y}from"../../chunk-C5N2D3ZX.js";import{Fragment as J,jsx as o,jsxs as E}from"react/jsx-runtime";import{useState as I,useEffect as R,useRef as le}from"react";import c,{UUID as L}from"jmini";import{ExtractStyles as ne}from"../../@utils";import{Box as k,Span as ae,FAI as U,Column as re}from"../../atoms";import{Text as K,Row as q}from"../../mols";import{Button as Z}from"../Button";import{Loader as ie}from"../Loader";import{Sheet as se}from"../Sheet";import{OptionalInputWrapper as ue,BoxWrapper as ce,CoreEffects as P,DefaultBoxishStyles as pe}from"./core";import{InputAutocompleteClasses as W}from"../../@styles/componentClasses";import{InputLabel as de}from"./Label";import{RightIcon as ee}from".";function Se(e){let{value:t,states:n}=e,{required:l,options:m,min:i,max:f}=n;i=i||0,f=f||65535;let a=[],r=t.filter(p=>p!==null).length;return l&&(r||a.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),r<i&&a.push({type:"invalid",label:i+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),r>f&&a.push({type:"invalid",label:f+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!a.filter(({type:p})=>p=="invalid").length,notice:a}}const A={InitOptions:e=>{let t=[];return e.forEach(n=>{let{type:l,label:m,value:i,searchValue:f}=n,a=f||(c.is.string(m)?m:"")||(c.is.string(i)?i:"");t.push(b(S({},n),{searchValue:a,type:l||"selector",value:i}))}),t},FilterSelectableOptions:(e,t)=>{let n=e.val_options;if(t||(n=e.val_options.filter(l=>l.type!="label")),e.val_keyword){let l=e.val_keyword.toLower().replace(/ /g,"");n=n.filter(m=>(m.searchValue||"").toLower().replace(/ /g,"").includes(l))}return n}},F={Shallow:e=>{let{rootStates:t,val_status:n}=e,l=ne(t);return o(k,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:o(K.Description,b(S({className:t.className},l),{position:"absolute",width:1,freeCSS:b(S({},l.freeCSS),{color:"orange"}),"data-id":"shallow_"+n.componentID,children:o(k,{"data-input-value-shallow":n.componentID,children:"A"})}))})},Button:e=>{let{rootStates:t,val_keyword:n,set_keyword:l,val_optionFocused:m,set_optionFocused:i,val_options:f,set_options:a,val_optionsDict:r,set_optionsDict:p,val_preventOpenSelectorOnFocus:s,set_preventOpenSelectorOnFocus:d,val_selectorOpen:u,set_selectorOpen:y,val_status:h,set_status:D,val_validate:_,set_validate:g}=e,$=t,{tone:C,required:w,form:T,className:x,multiSelect:N,enableFormSubmit:B,checkValidationAtFirst:z,onValidate:X,onUpdateValue:G,onUpdateValidValue:H,value:me="",options:fe,leftIndicator:ve,rightIndicator:ye,leftIcon:he,rightIcon:_e,componentID:ge,status_id:Oe,wrapStyles:be,emptySelect:Ie,SearchInput:De,SearchInputPlaceholder:Ce,SelectedComponent:we,SelectorComponent:Ve,SelectorStyles:Te,SelectorGravityPoint:xe,DynamicOptionsOnSearch:ke}=$,O=Q($,["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","SelectorGravityPoint","DynamicOptionsOnSearch"]);return R(()=>{var V,M;if(t.disabled||!u)return;let v=A.FilterSelectableOptions(e);i((M=(V=v[0])==null?void 0:V.value)!=null?M:null)},[n]),R(()=>{h.eventType!="init"&&(t.max==h.dataValue.length?(y(!1),d(!0),setTimeout(()=>{let v=c('[data-input-origin="'+t.componentID+'"]');v&&v.focus()},10)):c("#SearchInput_"+t.componentID).focus())},[h.dataValue]),R(()=>{let v="autocomplete-click-"+t.componentID;if(u){if(!c('[data-input-origin="'+t.componentID+'"]'))return;c("#SearchInput_"+t.componentID).focus(),c(document).addEvent({eventID:v,eventType:"mousedown",callback:M=>{let j=c(M.target),oe=!!c(j).parent("."+W("Core")).length;c(j).parent("."+W("Selector")).length||oe||y(!1)}})}else c(document).removeEvent([v]),l("")},[u]),E(J,{children:[o(k,b(S({tabIndex:0},O),{"data-disabled":t.disabled,"data-show-validation":P.isShowValidation(_,h,!!z),"data-component-id":h.componentID,"data-input-origin":h.componentID,"data-focus":!!u,className:[x,W("Core")].join(" "),onFocus:v=>{if(O!=null&&O.onFocus&&(O==null||O.onFocus(v)),!t.disabled){if(s)return d(!1);y(!0),v.preventDefault()}},onClick:v=>{O!=null&&O.onClick&&(O==null||O.onClick(v)),!t.disabled&&y(!0)},onKeyDown:v=>{let{key:V}=v;B&&P.SubmitForm(v,T),!u&&(V==" "||V=="ArrowDown"||V=="ArrowUp"||V=="Enter")&&y(!0)},children:E(q.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[o(F.Selected,S({},e)),o(ae,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),o(F.SearchInput,S({},e))]})})),u&&o(F.Selector,S({},e))]})},SearchInput:e=>{let{rootStates:t}=e;return t.disabled||!e.val_selectorOpen?null:o(k,{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"},onKeyDown:n=>{let{key:l,metaKey:m,ctrlKey:i}=n,f=m||i;l=="Escape"?(e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0),setTimeout(()=>{let a=c('[data-input-origin="'+t.componentID+'"]');a&&a.focus()},10)):l=="Tab"?e.set_selectorOpen(!1):l==" "?c.scope(()=>{e.val_selectorOpen||e.val_keyword||(n.preventDefault(),e.set_selectorOpen(!0))}):l=="Backspace"?c.scope(()=>{if(e.val_keyword)return;let a=[...e.val_status.dataValue];a.pop(),e.set_status(r=>b(S({},r),{dataValue:a,eventType:"update",eventID:L()}))}):l=="Enter"&&c.scope(()=>{if(!e.val_selectorOpen)return e.set_selectorOpen(!0);let a=e.val_options.find(p=>p.value==e.val_optionFocused);if(!a)return;let{value:r}=a;e.set_status(p=>{let s=[...p.dataValue];return c.scope(()=>{if(r===null)return s=[];p.dataValue.includes(r)?s=s.filter(u=>u!==r):t.multiSelect?s.push(r):s=[r]}),b(S({},p),{dataValue:s,eventType:"update",eventID:L()})}),e.set_keyword(""),e.set_preventDynamicSearchOnKeywordChange(!0)}),c.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(l))return;if(n.preventDefault(),!e.val_selectorOpen)return e.set_selectorOpen(!0);let a=l=="ArrowDown"?1:-1,r=A.FilterSelectableOptions(e),p=r.length-1,s=null;c.scope(()=>{var u,y,h,D,_,g,C,w,T,x;let d=r.findIndex(N=>N.value==e.val_optionFocused);if(d==-1&&(d=0),a==1){if(s=(y=(u=r[0])==null?void 0:u.value)!=null?y:null,f){s=(h=r[p].value)!=null?h:null;return}if(d==-1||d==p)return;s=(_=(D=r[d+1])==null?void 0:D.value)!=null?_:null}else{if(s=(g=r[p].value)!=null?g:null,f){s=(w=(C=r[0])==null?void 0:C.value)!=null?w:null;return}if(d==-1||d==0)return;s=(x=(T=r[d-1])==null?void 0:T.value)!=null?x:null}}),e.set_optionFocused(s)}),t.enableFormSubmit&&P.SubmitForm(n,e.rootStates.form)},onChange:n=>{let m=n.target.value;e.set_keyword(m)}},"searchInput")},Selector:e=>{var r;let[t,n]=I("idle"),[l,m]=I("idle");R(()=>{if(!e.val_selectorOpen||!e.rootStates.DynamicOptionsOnSearch)return;if(e.val_preventDynamicSearchOnKeywordChange)return e.set_preventDynamicSearchOnKeywordChange(!1);if(t=="idle")return n("ok");m("fetch");let p="autocomplete-search-"+e.rootStates.componentID;c.interval.cycle(p,300,()=>Y(void 0,null,function*(){let s=yield e.rootStates.DynamicOptionsOnSearch(e.val_keyword);m("idle");let d=A.InitOptions(s||[]);e.set_options(d)}))},[e.val_keyword]);let i=[],f=A.FilterSelectableOptions(e,!0),a=A.FilterSelectableOptions(e);return f.forEach((p,s)=>{let{type:d,value:u}=p,y=e.val_optionFocused==u,h=e.val_status.dataValue.includes(u),D=e.rootStates.SelectorComponent;i.push(o(D,{option:p,isFocused:y,isSelected:h,addCallback:()=>{e.set_status(_=>{let g=[..._.dataValue];return c.scope(()=>{if(u===null)return g=[];_.dataValue.includes(u)?g=g.filter(w=>w!==u):e.rootStates.multiSelect?g.push(u):g=[u]}),b(S({},_),{dataValue:g,eventType:"update",eventID:L()})})}},c.Stringify(u)||L()))}),a.length||(i=[o(K.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]),l=="fetch"&&(i=[E(q.Left,{padding:1,fontColor:"3.blur",children:[o(ie.Theme.R,{showInitial:!0}),o(K.Supplement,{children:"Loading..."})]},"loader")]),o(k,{position:"absolute",left:0,right:0,top:"100%",padding:"1/3",freeCSS:{zIndex:1e3},children:o(se.Body,b(S({className:W("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,boxShadow:"1.normal",overflow:"auto"},e.rootStates.SelectorStyles),{freeCSS:S({maxHeight:12*24},(r=e.rootStates.SelectorStyles)==null?void 0:r.freeCSS),children:o(re,{gap:0,padding:[1,0],children:i})}))})},Selected:e=>{let{rootStates:t,val_status:n,set_status:l,val_optionsDict:m}=e,i=[];return n.dataValue.forEach(f=>{let a=m[c.Stringify(f)];if(!a)return;let r=t.SelectedComponent,p=a.label;a.value===null&&(p=""),i.push(o(k,{className:W("SelectedCell"),children:o(r,{value:a.value,label:p,removeCallback:s=>{if(s.stopPropagation(),s.preventDefault(),t.disabled)return;let d=[...n.dataValue];d=d.filter(u=>u!==f),l(u=>b(S({},u),{dataValue:d,eventType:"update",eventID:L()}))}})},c.Stringify(a.value)))}),o(J,{children:i})},Core:e=>{var z;let{value:t}=e,[n,l]=I(!1),[m,i]=I(!1),[f,a]=I(!1),[r,p]=I(""),[s,d]=I(e.options),[u,y]=I((z=e.value[0])!=null?z:null),[h,D]=I({}),[_,g]=I(P.DefaultStatus(e.componentID,t)),[C,w]=I({ok:!1,notice:[]}),T=le(!1);R(()=>{T.current?d(e.options):T.current=!0},[e.options]),R(()=>{if(!s.length)return;let X=[...s],G=S({},h);X.forEach(H=>{H.type!="label"&&(G[c.Stringify(H.value)]=H)}),D(G)},[s]);let x={rootStates:e,val_options:s,set_options:d,val_optionFocused:u,set_optionFocused:y,val_optionsDict:h,set_optionsDict:D,val_preventDynamicSearchOnKeywordChange:m,set_preventDynamicSearchOnKeywordChange:i,val_preventOpenSelectorOnFocus:n,set_preventOpenSelectorOnFocus:l,val_selectorOpen:f,set_selectorOpen:a,val_keyword:r,set_keyword:p,val_status:_,set_status:g,val_validate:C,set_validate:w},N=!!e.multiSelect;P.CommonEffects({type:N?"autocomplete.multi":"autocomplete.single",states:e,val_status:_,set_status:g,val_validate:C,set_validate:w,SystemValidation:Se});let B=_.dataValue.length&&_.dataValue[0]!==null;return B=B||f,E(ce,{val_status:_,set_status:g,val_validate:C,states:e,children:[o(de,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:B}),o(F.Shallow,S({},x)),o(F.Button,S({},x))]})}},te=e=>{var n;let t=S({},e);return t=b(S({value:[],min:0,max:65535,multiSelect:!0,SearchInput:!0,emptySelect:!0,SelectorComponent:({option:l,isSelected:m,isFocused:i,addCallback:f})=>l.type=="selector"?o(Z.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1.5],isActive:i,isActiveStyles:{backgroundColor:"cloud"},onClick:a=>{f()},children:E(q.Left,{gap:"1/2",children:[m&&o(U.Check,{fontColor:"theme"}),o(K.Supplement,{transition:"short",children:l.label})]})}):o(J,{children:l.label}),SelectedComponent:({value:l,label:m,removeCallback:i})=>E(q.Left,{ssCardBox:"cloud",borderRadius:"2.tone.secondary",fontSize:"1.mini",padding:"1/2",gap:0,children:[o(k,{padding:[0,"1/4"],children:m}),o(Z.Sub,{flexSizing:"none",color:"cloud",fontColor:"white",backgroundColor:"layer.5",isRounded:!0,padding:"1/4",onClick:i,freeCSS:{lineHeight:1,aspectRatio:"1/1"},children:o(U.Times,{ssSphere:1})})]})},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(K.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=c.flatArray((n=t.value)!=null?n:null),t.options=A.InitOptions(t.options),c.is.nullish(t.rightIcon)&&(t.rightIcon=o(ee,{ssSphere:2,children:o(U.Search,{})}),t.disabled&&(t.rightIcon=o(ee,{ssSphere:2,fontColor:"5.translucent",children:o(U.Ban,{})}))),t.rightIcon&&(t=S({paddingRight:3},t)),t.leftIcon&&(t=S({paddingLeft:3},t)),o(ue,{componentID:t.componentID,children:F.Core,states:pe(t)})};export{te as Autocomplete,te as default};
1
+ import{b as S,c as b,d as Q,e as Y}from"../../chunk-C5N2D3ZX.js";import{Fragment as X,jsx as o,jsxs as E}from"react/jsx-runtime";import{useState as I,useEffect as R,useRef as le}from"react";import c,{UUID as L}from"jmini";import{ExtractStyles as ne}from"../../@utils";import{Box as k,Span as ae,FAI as U,Column as re}from"../../atoms";import{Text as K,Row as q}from"../../mols";import{Button as Z}from"../Button";import{Loader as ie}from"../Loader";import{Sheet as se}from"../Sheet";import{OptionalInputWrapper as ue,BoxWrapper as ce,CoreEffects as P,DefaultBoxishStyles as pe}from"./core";import{InputAutocompleteClasses as W}from"../../@styles/componentClasses";import{InputLabel as de}from"./Label";import{RightIcon as ee}from".";function Se(e){let{value:t,states:n}=e,{required:l,options:m,min:i,max:f}=n;i=i||0,f=f||65535;let a=[],r=t.filter(p=>p!==null).length;return l&&(r||a.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),r<i&&a.push({type:"invalid",label:i+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),r>f&&a.push({type:"invalid",label:f+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!a.filter(({type:p})=>p=="invalid").length,notice:a}}const A={InitOptions:e=>{let t=[];return e.forEach(n=>{let{type:l,label:m,value:i,searchValue:f}=n,a=f||(c.is.string(m)?m:"")||(c.is.string(i)?i:"");t.push(b(S({},n),{searchValue:a,type:l||"selector",value:i}))}),t},FilterSelectableOptions:(e,t)=>{let n=e.val_options;if(t||(n=e.val_options.filter(l=>l.type!="label")),e.val_keyword){let l=e.val_keyword.toLower().replace(/ /g,"");n=n.filter(m=>(m.searchValue||"").toLower().replace(/ /g,"").includes(l))}return n}},F={Shallow:e=>{let{rootStates:t,val_status:n}=e,l=ne(t);return o(k,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:o(K.Description,b(S({className:t.className},l),{position:"absolute",width:1,freeCSS:b(S({},l.freeCSS),{color:"orange"}),"data-id":"shallow_"+n.componentID,children:o(k,{"data-input-value-shallow":n.componentID,children:"A"})}))})},Button:e=>{let{rootStates:t,val_keyword:n,set_keyword:l,val_optionFocused:m,set_optionFocused:i,val_options:f,set_options:a,val_optionsDict:r,set_optionsDict:p,val_preventOpenSelectorOnFocus:s,set_preventOpenSelectorOnFocus:d,val_selectorOpen:u,set_selectorOpen:y,val_status:h,set_status:D,val_validate:_,set_validate:g}=e,G=t,{tone:C,required:w,form:T,className:x,multiSelect:N,enableFormSubmit:B,checkValidationAtFirst:z,onValidate:$,onUpdateValue:J,onUpdateValidValue:H,value:me="",options:fe,leftIndicator:ve,rightIndicator:ye,leftIcon:he,rightIcon:_e,componentID:ge,status_id:Oe,wrapStyles:be,emptySelect:Ie,SearchInput:De,SearchInputPlaceholder:Ce,SelectedComponent:we,SelectorComponent:Ve,SelectorStyles:Te,DynamicOptionsOnSearch:xe}=G,O=Q(G,["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","DynamicOptionsOnSearch"]);return R(()=>{var V,M;if(t.disabled||!u)return;let v=A.FilterSelectableOptions(e);i((M=(V=v[0])==null?void 0:V.value)!=null?M:null)},[n]),R(()=>{h.eventType!="init"&&(t.max==h.dataValue.length?(y(!1),d(!0),setTimeout(()=>{let v=c('[data-input-origin="'+t.componentID+'"]');v&&v.focus()},10)):c("#SearchInput_"+t.componentID).focus())},[h.dataValue]),R(()=>{let v="autocomplete-click-"+t.componentID;if(u){if(!c('[data-input-origin="'+t.componentID+'"]'))return;c("#SearchInput_"+t.componentID).focus(),c(document).addEvent({eventID:v,eventType:"mousedown",callback:M=>{let j=c(M.target),oe=!!c(j).parent("."+W("Core")).length;c(j).parent("."+W("Selector")).length||oe||y(!1)}})}else c(document).removeEvent([v]),l("")},[u]),E(X,{children:[o(k,b(S({tabIndex:0},O),{"data-disabled":t.disabled,"data-show-validation":P.isShowValidation(_,h,!!z),"data-component-id":h.componentID,"data-input-origin":h.componentID,"data-focus":!!u,className:[x,W("Core")].join(" "),onFocus:v=>{if(O!=null&&O.onFocus&&(O==null||O.onFocus(v)),!t.disabled){if(s)return d(!1);y(!0),v.preventDefault()}},onClick:v=>{O!=null&&O.onClick&&(O==null||O.onClick(v)),!t.disabled&&y(!0)},onKeyDown:v=>{let{key:V}=v;B&&P.SubmitForm(v,T),!u&&(V==" "||V=="ArrowDown"||V=="ArrowUp"||V=="Enter")&&y(!0)},children:E(q.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[o(F.Selected,S({},e)),o(ae,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),o(F.SearchInput,S({},e))]})})),u&&o(F.Selector,S({},e))]})},SearchInput:e=>{let{rootStates:t}=e;return t.disabled||!e.val_selectorOpen?null:o(k,{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"},onKeyDown:n=>{let{key:l,metaKey:m,ctrlKey:i}=n,f=m||i;l=="Escape"?(e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0),setTimeout(()=>{let a=c('[data-input-origin="'+t.componentID+'"]');a&&a.focus()},10)):l=="Tab"?e.set_selectorOpen(!1):l==" "?c.scope(()=>{e.val_selectorOpen||e.val_keyword||(n.preventDefault(),e.set_selectorOpen(!0))}):l=="Backspace"?c.scope(()=>{if(e.val_keyword)return;let a=[...e.val_status.dataValue];a.pop(),e.set_status(r=>b(S({},r),{dataValue:a,eventType:"update",eventID:L()}))}):l=="Enter"&&c.scope(()=>{if(!e.val_selectorOpen)return e.set_selectorOpen(!0);let a=e.val_options.find(p=>p.value==e.val_optionFocused);if(!a)return;let{value:r}=a;e.set_status(p=>{let s=[...p.dataValue];return c.scope(()=>{if(r===null)return s=[];p.dataValue.includes(r)?s=s.filter(u=>u!==r):t.multiSelect?s.push(r):s=[r]}),b(S({},p),{dataValue:s,eventType:"update",eventID:L()})}),e.set_keyword(""),e.set_preventDynamicSearchOnKeywordChange(!0)}),c.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(l))return;if(n.preventDefault(),!e.val_selectorOpen)return e.set_selectorOpen(!0);let a=l=="ArrowDown"?1:-1,r=A.FilterSelectableOptions(e),p=r.length-1,s=null;c.scope(()=>{var u,y,h,D,_,g,C,w,T,x;let d=r.findIndex(N=>N.value==e.val_optionFocused);if(d==-1&&(d=0),a==1){if(s=(y=(u=r[0])==null?void 0:u.value)!=null?y:null,f){s=(h=r[p].value)!=null?h:null;return}if(d==-1||d==p)return;s=(_=(D=r[d+1])==null?void 0:D.value)!=null?_:null}else{if(s=(g=r[p].value)!=null?g:null,f){s=(w=(C=r[0])==null?void 0:C.value)!=null?w:null;return}if(d==-1||d==0)return;s=(x=(T=r[d-1])==null?void 0:T.value)!=null?x:null}}),e.set_optionFocused(s)}),t.enableFormSubmit&&P.SubmitForm(n,e.rootStates.form)},onChange:n=>{let m=n.target.value;e.set_keyword(m)}},"searchInput")},Selector:e=>{var r;let[t,n]=I("idle"),[l,m]=I("idle");R(()=>{if(!e.val_selectorOpen||!e.rootStates.DynamicOptionsOnSearch)return;if(e.val_preventDynamicSearchOnKeywordChange)return e.set_preventDynamicSearchOnKeywordChange(!1);if(t=="idle")return n("ok");m("fetch");let p="autocomplete-search-"+e.rootStates.componentID;c.interval.cycle(p,300,()=>Y(void 0,null,function*(){let s=yield e.rootStates.DynamicOptionsOnSearch(e.val_keyword);m("idle");let d=A.InitOptions(s||[]);e.set_options(d)}))},[e.val_keyword]);let i=[],f=A.FilterSelectableOptions(e,!0),a=A.FilterSelectableOptions(e);return f.forEach((p,s)=>{let{type:d,value:u}=p,y=e.val_optionFocused==u,h=e.val_status.dataValue.includes(u),D=e.rootStates.SelectorComponent;i.push(o(D,{option:p,isFocused:y,isSelected:h,addCallback:()=>{e.set_status(_=>{let g=[..._.dataValue];return c.scope(()=>{if(u===null)return g=[];_.dataValue.includes(u)?g=g.filter(w=>w!==u):e.rootStates.multiSelect?g.push(u):g=[u]}),b(S({},_),{dataValue:g,eventType:"update",eventID:L()})})}},c.Stringify(u)||L()))}),a.length||(i=[o(K.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]),l=="fetch"&&(i=[E(q.Left,{padding:1,fontColor:"3.blur",children:[o(ie.Theme.R,{showInitial:!0}),o(K.Supplement,{children:"Loading..."})]},"loader")]),o(k,{position:"absolute",left:0,right:0,top:"100%",padding:"1/3",freeCSS:{zIndex:1e3},children:o(se.Body,b(S({className:W("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,boxShadow:"1.normal",overflow:"auto"},e.rootStates.SelectorStyles),{freeCSS:S({maxHeight:12*24},(r=e.rootStates.SelectorStyles)==null?void 0:r.freeCSS),children:o(re,{gap:0,padding:[1,0],children:i})}))})},Selected:e=>{let{rootStates:t,val_status:n,set_status:l,val_optionsDict:m}=e,i=[];return n.dataValue.forEach(f=>{let a=m[c.Stringify(f)];if(!a)return;let r=t.SelectedComponent,p=a.label;a.value===null&&(p=""),i.push(o(k,{className:W("SelectedCell"),children:o(r,{value:a.value,label:p,removeCallback:s=>{if(s.stopPropagation(),s.preventDefault(),t.disabled)return;let d=[...n.dataValue];d=d.filter(u=>u!==f),l(u=>b(S({},u),{dataValue:d,eventType:"update",eventID:L()}))}})},c.Stringify(a.value)))}),o(X,{children:i})},Core:e=>{var z;let{value:t}=e,[n,l]=I(!1),[m,i]=I(!1),[f,a]=I(!1),[r,p]=I(""),[s,d]=I(e.options),[u,y]=I((z=e.value[0])!=null?z:null),[h,D]=I({}),[_,g]=I(P.DefaultStatus(e.componentID,t)),[C,w]=I({ok:!1,notice:[]}),T=le(!1);R(()=>{T.current?d(e.options):T.current=!0},[e.options]),R(()=>{if(!s.length)return;let $=[...s],J=S({},h);$.forEach(H=>{H.type!="label"&&(J[c.Stringify(H.value)]=H)}),D(J)},[s]);let x={rootStates:e,val_options:s,set_options:d,val_optionFocused:u,set_optionFocused:y,val_optionsDict:h,set_optionsDict:D,val_preventDynamicSearchOnKeywordChange:m,set_preventDynamicSearchOnKeywordChange:i,val_preventOpenSelectorOnFocus:n,set_preventOpenSelectorOnFocus:l,val_selectorOpen:f,set_selectorOpen:a,val_keyword:r,set_keyword:p,val_status:_,set_status:g,val_validate:C,set_validate:w},N=!!e.multiSelect;P.CommonEffects({type:N?"autocomplete.multi":"autocomplete.single",states:e,val_status:_,set_status:g,val_validate:C,set_validate:w,SystemValidation:Se});let B=_.dataValue.length&&_.dataValue[0]!==null;return B=B||f,E(ce,{val_status:_,set_status:g,val_validate:C,states:e,children:[o(de,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:B}),o(F.Shallow,S({},x)),o(F.Button,S({},x))]})}},te=e=>{var n;let t=S({},e);return t=b(S({value:[],min:0,max:65535,multiSelect:!0,SearchInput:!0,emptySelect:!0,SelectorComponent:({option:l,isSelected:m,isFocused:i,addCallback:f})=>l.type=="selector"?o(Z.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1.5],isActive:i,isActiveStyles:{backgroundColor:"cloud"},onClick:a=>{f()},children:E(q.Left,{gap:"1/2",children:[m&&o(U.Check,{fontColor:"theme"}),o(K.Supplement,{transition:"short",children:l.label})]})}):o(X,{children:l.label}),SelectedComponent:({value:l,label:m,removeCallback:i})=>E(q.Left,{ssCardBox:"cloud",borderRadius:"2.tone.secondary",fontSize:"1.mini",padding:"1/2",gap:0,children:[o(k,{padding:[0,"1/4"],children:m}),o(Z.Sub,{flexSizing:"none",color:"cloud",fontColor:"white",backgroundColor:"layer.5",isRounded:!0,padding:"1/4",onClick:i,freeCSS:{lineHeight:1,aspectRatio:"1/1"},children:o(U.Times,{ssSphere:1})})]})},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(K.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=c.flatArray((n=t.value)!=null?n:null),t.options=A.InitOptions(t.options),c.is.nullish(t.rightIcon)&&(t.rightIcon=o(ee,{ssSphere:2,children:o(U.Search,{})}),t.disabled&&(t.rightIcon=o(ee,{ssSphere:2,fontColor:"5.translucent",children:o(U.Ban,{})}))),t.rightIcon&&(t=S({paddingRight:3},t)),t.leftIcon&&(t=S({paddingLeft:3},t)),o(ue,{componentID:t.componentID,children:F.Core,states:pe(t)})};export{te as Autocomplete,te as default};
@@ -1 +1 @@
1
- import{b as n,c as m}from"../../chunk-C5N2D3ZX.js";import{jsx as c,jsxs as y}from"react/jsx-runtime";import{useState as b,useEffect as S}from"react";import r from"jmini";import{Box as d,Span as g}from"../../atoms";import{Row as h}from"../../mols";const A=t=>{if(!t.label)return null;let[s,f]=b({});return S(()=>{let u=r('[data-input-origin="'+t.componentID+'"]'),i=r('[data-input-label="'+t.componentID+'"]'),p=r('[data-input-value-shallow="'+t.componentID+'"]');if(!u[0]||!i[0]||!p[0])return;let l=u.position(),e=p.position();if(t.isActive){let o=e.left-l.left,a=16/e.height;f({opacity:"max",backgroundColor:"layer.1",freeCSS:{transform:`scale(${a}) translate(${o}px,-8px)`}})}else{let o=e.left-l.left,a=e.top-l.top;f({fontSize:t.fontSize||"inherit",opacity:"middle",backgroundColor:"trans",freeCSS:{lineHeight:"inherit",transform:`scale(1) translate(${o}px,${a}px)`}})}i.getAttribute("data-label-init")=="true"&&i.setAttribute("data-label-init","false").await(10).css({transition:".25s"})},[t.isActive]),c(d,m(n({htmlTag:"label","data-input-label":t.componentID,"data-label-init":"true",position:"absolute",left:0,top:0,fontColor:"3.blur",backgroundColor:"trans",borderRadius:"1/3",padding:[0,"1/4"],opacity:"min"},s),{freeCSS:n({zIndex:2,transformOrigin:"top left",pointerEvents:"none",lineHeight:"inherit"},s.freeCSS),children:y(h.Left,{gap:"1/3",children:[t.label,t.required&&c(g,{fontColor:"nega",children:" * "})]})}))};export{A as InputLabel};
1
+ import{b as n,c as m}from"../../chunk-C5N2D3ZX.js";import{jsx as S,jsxs as x}from"react/jsx-runtime";import{useState as b,useEffect as c}from"react";import a from"jmini";import{Box as g,Span as d}from"../../atoms";import{Row as h}from"../../mols";const D=t=>{if(!t.label)return null;let[r,s]=b({});return c(()=>{let f=a('[data-input-origin="'+t.componentID+'"]'),i=a('[data-input-label="'+t.componentID+'"]'),u=a('[data-input-value-shallow="'+t.componentID+'"]');if(!f[0]||!i[0]||!u[0])return;let l=f.position(),e=u.position();if(t.isActive){let o=e.left-l.left,p=14/e.height;s({opacity:"max",backgroundColor:"layer.1",freeCSS:{fontSize:"12px",lineHeight:1,transform:`translate(${o}px,-6px)`}})}else{let o=e.left-l.left,p=e.top-l.top;s({fontSize:t.fontSize||"inherit",opacity:"middle",backgroundColor:"trans",freeCSS:{lineHeight:"inherit",transform:`translate(${o}px,${p}px)`}})}i.getAttribute("data-label-init")=="true"&&i.setAttribute("data-label-init","false").await(10).css({transition:".25s"})},[t.isActive]),S(g,m(n({htmlTag:"label","data-input-label":t.componentID,"data-label-init":"true",position:"absolute",left:0,top:0,fontColor:"3.blur",backgroundColor:"trans",borderRadius:"1/3",padding:[0,"1/4"],opacity:"min"},r),{freeCSS:n({zIndex:2,transformOrigin:"top left",pointerEvents:"none",lineHeight:"inherit"},r.freeCSS),children:x(h.Left,{gap:"1/3",children:[t.label,t.required&&S(d,{fontColor:"nega",children:" * "})]})}))};export{D as InputLabel};
@@ -21,7 +21,6 @@ declare namespace Select {
21
21
  SelectedCellStyles?: StyleTags.PropsNFreeCSS;
22
22
  SelectorCellStyles?: StyleTags.PropsNFreeCSS;
23
23
  SelectorStyles?: StyleTags.PropsNFreeCSS;
24
- SelectorGravityPoint?: number;
25
24
  };
26
25
  type Value<T = any> = T extends infer V ? V : string | number | boolean | KeyValueDict | void | null;
27
26
  type Option<T = Value> = {
@@ -1 +1 @@
1
- import{b as r,c as f,d as X}from"../../chunk-C5N2D3ZX.js";import{Fragment as ee,jsx as l,jsxs as k}from"react/jsx-runtime";import d,{UUID as R}from"jmini";import{useState as D,useEffect as j}from"react";import{ExtractStyles as re}from"../../@utils";import{Box as h,Span as se,FAI as Q,Column as ie}from"../../atoms";import{Text as F,Row as Y}from"../../mols";import{Button as ue}from"../Button";import{Sheet as ce}from"../Sheet";import{OptionalInputWrapper as pe,BoxWrapper as Se,CoreEffects as w,DefaultBoxishStyles as de}from"./core";import{InputAutocompleteClasses as E}from"../../@styles/componentClasses";import{InputLabel as fe}from"./Label";import{RightIcon as me}from".";function ve(e){let{value:t,states:a}=e,{required:o,options:m}=a,i=[];return o&&t===null&&i.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!i.filter(({type:v})=>v=="invalid").length,notice:i}}const L={FilterSelectableOptions:(e,t)=>{let a=e.rootStates.options;return t||(a=a.filter(o=>o.type!="label")),a}},_={Shallow:e=>{let{rootStates:t,val_status:a}=e,o=re(t);return l(h,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:l(F.Description,f(r({className:t.className},o),{position:"absolute",width:1,freeCSS:f(r({},o.freeCSS),{color:"orange"}),children:l(h,{"data-input-value-shallow":a.componentID,children:"A"})}))})},Button:e=>{let{rootStates:t,val_preventOpenSelectorOnFocus:a,set_preventOpenSelectorOnFocus:o,val_optionFocused:m,set_optionFocused:i,val_validate:v,set_validate:T,val_status:p,set_status:b,val_selectorOpen:u,set_selectorOpen:c}=e,N=t,{tone:x,required:A,form:te,className:le,label:ye,isLabelActive:be,placeholder:Ie,enableFormSubmit:ae,emptySelect:ge,checkValidationAtFirst:oe,onValidate:he,onUpdateValue:Ce,onUpdateValidValue:_e,value:xe="",options:De,leftIndicator:Te,rightIndicator:Oe,leftIcon:Ve,rightIcon:Re,componentID:Fe,status_id:we,wrapStyles:Ee,SelectedCellStyles:ke,SelectorCellStyles:Ae,SelectorStyles:Be,SelectorGravityPoint:We}=N,n=X(N,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","wrapStyles","SelectedCellStyles","SelectorCellStyles","SelectorStyles","SelectorGravityPoint"]);return j(()=>{if(t.disabled)return;let s="select-click-"+t.componentID;if(u){if(!d('[data-input-origin="'+t.componentID+'"]'))return;d(document).addEvent({eventID:s,eventType:"click",callback:B=>{let O=d(B.target),V=!!d(O).parent("."+E("Core")).length;d(O).parent("."+E("Selector")).length||V||c(!1)}})}else d(document).removeEvent([s])},[u]),j(()=>{if(p.eventType=="init"||!u)return;let s=d('[data-input-origin="'+t.componentID+'"]');s&&s.focus()},[p.dataValue]),k(ee,{children:[l(h,f(r({tabIndex:0},n),{"data-disabled":t.disabled,"data-show-validation":w.isShowValidation(v,p,!!oe),"data-component-id":p.componentID,"data-input-origin":p.componentID,className:[le,E("Core")].join(" "),onFocus:s=>{if(n!=null&&n.onFocus&&(n==null||n.onFocus(s)),!t.disabled){if(a)return o(!1);c(!0)}},onClick:s=>{n!=null&&n.onClick&&(n==null||n.onClick(s)),!t.disabled&&c(!0)},onKeyDown:s=>{let{key:y,metaKey:B,ctrlKey:O}=s,V=B||O;if(n!=null&&n.onKeyDown&&(n==null||n.onKeyDown(s)),ae&&w.SubmitForm(s,te),!t.disabled){if(d.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(y))return;if(s.preventDefault(),!u)return c(!0);let I=y=="ArrowDown"?1:-1,S=L.FilterSelectableOptions(e),W=S.length-1,g=null;d.scope(()=>{var P,K,q,U,z,H,G,M,$,J;let C=S.findIndex(ne=>ne.value==m);if(I==1){if(g=(K=(P=S[0])==null?void 0:P.value)!=null?K:null,V){g=(q=S[W].value)!=null?q:null;return}if(C==-1||C==W)return;g=(z=(U=S[C+1])==null?void 0:U.value)!=null?z:null}else{if(g=(H=S[W].value)!=null?H:null,V){g=(M=(G=S[0])==null?void 0:G.value)!=null?M:null;return}if(C==-1||C==0)return;g=(J=($=S[C-1])==null?void 0:$.value)!=null?J:null}}),i(g)}),y=="Escape")c(!1);else if(y=="Tab")c(!1);else if(y=="Backspace")b(I=>f(r({},I),{dataValue:null,eventType:"update",eventID:R()}));else if(y==" ")s.preventDefault(),c(!0);else if(y=="Enter"){if(!u)return c(!0);s.preventDefault();let I=t.options.find(S=>S.value==m);if(!I)return;b(S=>f(r({},S),{dataValue:I.value,eventType:"update",eventID:R()})),c(!1)}}},children:k(Y.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(_.Placeholder,r({},e)),l(_.Selected,r({},e)),l(se,{width:0,overflow:"hidden",opacity:"trans",children:"A"})]})})),u&&l(_.Selector,r({},e))]})},Placeholder:e=>!e.rootStates.placeholder||e.val_status.dataValue!==null?null:l(h,{position:"absolute",opacity:"middle",fontColor:"3.blur",children:e.rootStates.placeholder||""}),Selector:e=>{var m;let t=[],a=L.FilterSelectableOptions(e,!0),o=L.FilterSelectableOptions(e);return a.forEach((i,v)=>{let{type:T,value:p}=i,b=e.val_optionFocused==p,u=e.val_status.dataValue===p;if(T=="selector"){t.push(l(ue.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1.5],isActive:u||b,isActiveStyles:b?{backgroundColor:"cloud"}:{backgroundColor:"theme.opa.few",fontColor:"theme"},onClick:c=>{e.set_status(x=>f(r({},x),{dataValue:p,eventType:"update",eventID:R()})),e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0)},children:k(Y.Left,{gap:"1/2",children:[u&&l(Q.Check,{fontColor:"theme"}),l(F.Supplement,{transition:"short",children:i.label})]})},String(p)));return}t.push(l(h,{children:i.label},R()))}),o.length||(t=[l(F.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]),l(h,{position:"absolute",left:0,right:0,top:"100%",padding:"1/3",freeCSS:{zIndex:1e3},children:l(ce.Body,f(r({className:E("Selector"),ssCardBox:!0,borderRadius:"2.tone.secondary",boxShadow:"1.normal",overflow:"auto"},e.rootStates.SelectorStyles),{freeCSS:r({maxHeight:12*24},(m=e.rootStates.SelectorStyles)==null?void 0:m.freeCSS),children:l(ie,{gap:0,padding:[1,0],children:t})}))})},Selected:e=>{let t=[];return e.val_status.dataValue!==null&&d.scope(()=>{let a=e.rootStates.options.find(o=>d.is.equal(o.value,e.val_status.dataValue));a&&t.push(l(h,f(r({},e.rootStates.SelectedCellStyles),{children:a.label}),String(a.value)))}),l(ee,{children:t})},Core:e=>{var A;let{value:t}=e,[a,o]=D(w.DefaultStatus(e.componentID,t)),[m,i]=D(!1),[v,T]=D(!1),[p,b]=D((A=e.value)!=null?A:null),[u,c]=D({ok:!1,notice:[]}),x={rootStates:e,val_preventOpenSelectorOnFocus:m,set_preventOpenSelectorOnFocus:i,val_optionFocused:p,set_optionFocused:b,val_selectorOpen:v,set_selectorOpen:T,val_status:a,set_status:o,val_validate:u,set_validate:c};return w.CommonEffects({type:"select",states:e,val_status:a,set_status:o,val_validate:u,set_validate:c,SystemValidation:ve}),k(Se,{val_status:a,set_status:o,val_validate:u,states:e,children:[l(fe,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:e.isLabelActive||a.dataValue!==null}),l(_.Shallow,r({},x)),l(_.Button,r({},x))]})}},Z=e=>{var a;let t=r({},e);return t=f(r({emptySelect:!0},t),{freeCSS:r({cursor:"pointer"},t.freeCSS)}),t.emptySelect&&(t.options=[{value:null,label:l(F.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=(a=t.value)!=null?a:null,t.options.forEach((o,m)=>{let{type:i,value:v}=o;t.options[m]=f(r({},o),{value:v,type:i||"selector"})}),d.is.nullish(t.rightIcon)&&(t.rightIcon=l(me,{ssSphere:2,children:l(Q.AngleDown,{})})),l(pe,{componentID:t.componentID,children:_.Core,states:de(t)})};export{Z as Select,Z as default};
1
+ import{b as r,c as f,d as j}from"../../chunk-C5N2D3ZX.js";import{Fragment as ee,jsx as l,jsxs as k}from"react/jsx-runtime";import d,{UUID as R}from"jmini";import{useState as D,useEffect as G}from"react";import{ExtractStyles as re}from"../../@utils";import{Box as h,Span as se,FAI as Q,Column as ie}from"../../atoms";import{Text as F,Row as Y}from"../../mols";import{Button as ue}from"../Button";import{Sheet as ce}from"../Sheet";import{OptionalInputWrapper as pe,BoxWrapper as Se,CoreEffects as w,DefaultBoxishStyles as de}from"./core";import{InputAutocompleteClasses as E}from"../../@styles/componentClasses";import{InputLabel as fe}from"./Label";import{RightIcon as me}from".";function ve(e){let{value:t,states:a}=e,{required:o,options:m}=a,i=[];return o&&t===null&&i.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!i.filter(({type:v})=>v=="invalid").length,notice:i}}const L={FilterSelectableOptions:(e,t)=>{let a=e.rootStates.options;return t||(a=a.filter(o=>o.type!="label")),a}},_={Shallow:e=>{let{rootStates:t,val_status:a}=e,o=re(t);return l(h,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:l(F.Description,f(r({className:t.className},o),{position:"absolute",width:1,freeCSS:f(r({},o.freeCSS),{color:"orange"}),children:l(h,{"data-input-value-shallow":a.componentID,children:"A"})}))})},Button:e=>{let{rootStates:t,val_preventOpenSelectorOnFocus:a,set_preventOpenSelectorOnFocus:o,val_optionFocused:m,set_optionFocused:i,val_validate:v,set_validate:T,val_status:p,set_status:b,val_selectorOpen:u,set_selectorOpen:c}=e,N=t,{tone:x,required:A,form:te,className:le,label:ye,isLabelActive:be,placeholder:Ie,enableFormSubmit:ae,emptySelect:ge,checkValidationAtFirst:oe,onValidate:he,onUpdateValue:Ce,onUpdateValidValue:_e,value:xe="",options:De,leftIndicator:Te,rightIndicator:Oe,leftIcon:Ve,rightIcon:Re,componentID:Fe,status_id:we,wrapStyles:Ee,SelectedCellStyles:ke,SelectorCellStyles:Ae,SelectorStyles:Be}=N,n=j(N,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","wrapStyles","SelectedCellStyles","SelectorCellStyles","SelectorStyles"]);return G(()=>{if(t.disabled)return;let s="select-click-"+t.componentID;if(u){if(!d('[data-input-origin="'+t.componentID+'"]'))return;d(document).addEvent({eventID:s,eventType:"click",callback:B=>{let O=d(B.target),V=!!d(O).parent("."+E("Core")).length;d(O).parent("."+E("Selector")).length||V||c(!1)}})}else d(document).removeEvent([s])},[u]),G(()=>{if(p.eventType=="init"||!u)return;let s=d('[data-input-origin="'+t.componentID+'"]');s&&s.focus()},[p.dataValue]),k(ee,{children:[l(h,f(r({tabIndex:0},n),{"data-disabled":t.disabled,"data-show-validation":w.isShowValidation(v,p,!!oe),"data-component-id":p.componentID,"data-input-origin":p.componentID,className:[le,E("Core")].join(" "),onFocus:s=>{if(n!=null&&n.onFocus&&(n==null||n.onFocus(s)),!t.disabled){if(a)return o(!1);c(!0)}},onClick:s=>{n!=null&&n.onClick&&(n==null||n.onClick(s)),!t.disabled&&c(!0)},onKeyDown:s=>{let{key:y,metaKey:B,ctrlKey:O}=s,V=B||O;if(n!=null&&n.onKeyDown&&(n==null||n.onKeyDown(s)),ae&&w.SubmitForm(s,te),!t.disabled){if(d.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(y))return;if(s.preventDefault(),!u)return c(!0);let I=y=="ArrowDown"?1:-1,S=L.FilterSelectableOptions(e),W=S.length-1,g=null;d.scope(()=>{var K,P,q,U,z,H,M,$,J,X;let C=S.findIndex(ne=>ne.value==m);if(I==1){if(g=(P=(K=S[0])==null?void 0:K.value)!=null?P:null,V){g=(q=S[W].value)!=null?q:null;return}if(C==-1||C==W)return;g=(z=(U=S[C+1])==null?void 0:U.value)!=null?z:null}else{if(g=(H=S[W].value)!=null?H:null,V){g=($=(M=S[0])==null?void 0:M.value)!=null?$:null;return}if(C==-1||C==0)return;g=(X=(J=S[C-1])==null?void 0:J.value)!=null?X:null}}),i(g)}),y=="Escape")c(!1);else if(y=="Tab")c(!1);else if(y=="Backspace")b(I=>f(r({},I),{dataValue:null,eventType:"update",eventID:R()}));else if(y==" ")s.preventDefault(),c(!0);else if(y=="Enter"){if(!u)return c(!0);s.preventDefault();let I=t.options.find(S=>S.value==m);if(!I)return;b(S=>f(r({},S),{dataValue:I.value,eventType:"update",eventID:R()})),c(!1)}}},children:k(Y.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(_.Placeholder,r({},e)),l(_.Selected,r({},e)),l(se,{width:0,overflow:"hidden",opacity:"trans",children:"A"})]})})),u&&l(_.Selector,r({},e))]})},Placeholder:e=>!e.rootStates.placeholder||e.val_status.dataValue!==null?null:l(h,{position:"absolute",opacity:"middle",fontColor:"3.blur",children:e.rootStates.placeholder||""}),Selector:e=>{var m;let t=[],a=L.FilterSelectableOptions(e,!0),o=L.FilterSelectableOptions(e);return a.forEach((i,v)=>{let{type:T,value:p}=i,b=e.val_optionFocused==p,u=e.val_status.dataValue===p;if(T=="selector"){t.push(l(ue.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1.5],isActive:u||b,isActiveStyles:b?{backgroundColor:"cloud"}:{backgroundColor:"theme.opa.few",fontColor:"theme"},onClick:c=>{e.set_status(x=>f(r({},x),{dataValue:p,eventType:"update",eventID:R()})),e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0)},children:k(Y.Left,{gap:"1/2",children:[u&&l(Q.Check,{fontColor:"theme"}),l(F.Supplement,{transition:"short",children:i.label})]})},String(p)));return}t.push(l(h,{children:i.label},R()))}),o.length||(t=[l(F.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]),l(h,{position:"absolute",left:0,right:0,top:"100%",padding:"1/3",freeCSS:{zIndex:1e3},children:l(ce.Body,f(r({className:E("Selector"),ssCardBox:!0,borderRadius:"2.tone.secondary",boxShadow:"1.normal",overflow:"auto"},e.rootStates.SelectorStyles),{freeCSS:r({maxHeight:12*24},(m=e.rootStates.SelectorStyles)==null?void 0:m.freeCSS),children:l(ie,{gap:0,padding:[1,0],children:t})}))})},Selected:e=>{let t=[];return e.val_status.dataValue!==null&&d.scope(()=>{let a=e.rootStates.options.find(o=>d.is.equal(o.value,e.val_status.dataValue));a&&t.push(l(h,f(r({},e.rootStates.SelectedCellStyles),{children:a.label}),String(a.value)))}),l(ee,{children:t})},Core:e=>{var A;let{value:t}=e,[a,o]=D(w.DefaultStatus(e.componentID,t)),[m,i]=D(!1),[v,T]=D(!1),[p,b]=D((A=e.value)!=null?A:null),[u,c]=D({ok:!1,notice:[]}),x={rootStates:e,val_preventOpenSelectorOnFocus:m,set_preventOpenSelectorOnFocus:i,val_optionFocused:p,set_optionFocused:b,val_selectorOpen:v,set_selectorOpen:T,val_status:a,set_status:o,val_validate:u,set_validate:c};return w.CommonEffects({type:"select",states:e,val_status:a,set_status:o,val_validate:u,set_validate:c,SystemValidation:ve}),k(Se,{val_status:a,set_status:o,val_validate:u,states:e,children:[l(fe,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:e.isLabelActive||a.dataValue!==null}),l(_.Shallow,r({},x)),l(_.Button,r({},x))]})}},Z=e=>{var a;let t=r({},e);return t=f(r({emptySelect:!0},t),{freeCSS:r({cursor:"pointer"},t.freeCSS)}),t.emptySelect&&(t.options=[{value:null,label:l(F.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=(a=t.value)!=null?a:null,t.options.forEach((o,m)=>{let{type:i,value:v}=o;t.options[m]=f(r({},o),{value:v,type:i||"selector"})}),d.is.nullish(t.rightIcon)&&(t.rightIcon=l(me,{ssSphere:2,children:l(Q.AngleDown,{})})),l(pe,{componentID:t.componentID,children:_.Core,states:de(t)})};export{Z as Select,Z as default};
@@ -1 +1 @@
1
- import{b as r,c as m,d as Y}from"../../chunk-C5N2D3ZX.js";import{Fragment as z,jsx as l,jsxs as x}from"react/jsx-runtime";import D,{UUID as Z}from"jmini";import{useState as ee,useEffect as j}from"react";import{useStore as te,useRefresh as F}from"../../@utils";import{Box as v,Flex as K,FAI as N,Span as le,Column as oe}from"../../atoms";import{Row as E}from"../../mols";import{Button as H}from"../Button";import W from"../Sheet";import L from"../Input";import{faArrowUp as ne}from"@fortawesome/free-solid-svg-icons/faArrowUp";import{faArrowDown as se}from"@fortawesome/free-solid-svg-icons/faArrowDown";import{faArrowRight as ie}from"@fortawesome/free-solid-svg-icons/faArrowRight";import{faFilter as ce}from"@fortawesome/free-solid-svg-icons/faFilter";import R from"./Parts";import de from"./Wrapper";import{DefaultCellSystemAdjustingStyles as V}from"./cellStyling";import{TableClasses as y}from"../../@styles/componentClasses";const I={__memoryID:Z(),Header:t=>{var h,b;let{val_status:e,set_status:n,KeywordFilterRows:u}=r({},t),{order:s,filter:a}=e,[d,g]=s.current,p=[],c=[...e.head];if(e.checker){let o={top:!0,bottom:!e.rows.length,left:!0,right:!e.colLength,rowIndex:0,colIndex:0,isBody:!1,isHeader:!0},i=V(o),f=e.cellStylesCallback?e.cellStylesCallback(o):{};p.push(l(R.TH,m(r(r(r({fontWeight:"2.normal",position:"sticky",top:0,unitWidth:4,padding:0},e.cellStyles),i),f),{freeCSS:m(r(r({},(h=e.cellStyles)==null?void 0:h.freeCSS),f.freeCSS),{zIndex:2}),className:[y("Cell"),e.cellClassName].join(" "),children:l(v,{flexCenter:!0,children:l(L.Checker,{label:null,value:!1,onUpdateValidValue:({value:S})=>{let C=e.rows;C.forEach(O=>{O.checked=S}),n(m(r({},e),{rows:C}))}})})}),-1))}for(let o=0;o<e.colLength;o++){let i=c[o];if(!i)continue;let f=i.children||i.data,S=s.enabled&&s.column[o],C=a.enabled&&a.column[o],O=S?l(N,{fontSize:"1.mini",fontColor:o==d?"1.clear":"5.translucent",icon:o==d?g=="DESC"?se:ne:ie}):null,B=l(z,{});if(C){let _=u.map(P=>{var A;return(A=P[o])==null?void 0:A.data});_=[...new Set(_)].order({direction:"ASC"});let T=a.current[o];if(T){let P=_.filter(w=>!T.includes(w)),A=[];_.forEach(w=>{w&&A.push({value:w,label:l(v,{flexSizing:"auto",children:w})})});let J="BUTTON-"+e.componentID+"-"+o,X=e.componentID+"-"+o,$={sheetID:X,parent:"#"+J,gravityPoint:23,type:"custom",content:x(K,{flexType:"col",border:!0,boxShadow:"3.remark",backgroundColor:"layer.1",borderRadius:1,freeCSS:{minWidth:12*20,maxWidth:12*30},children:[l(oe,{gap:"1/3",overflow:"auto",padding:"2/3",freeCSS:{maxHeight:12*30},children:l(L.Checkbox,{icon:!0,value:P,display:"flex",gap:"1/2",override:"force",options:A,hideInput:!0,name:"DTFilter-col-"+o+"-table-"+e.componentID,onUpdateValidValue:({value:w})=>{let M=_.filter(ae=>!w.includes(ae)),Q=r({},e);Q.filter.current[o]=M,n(Q)}})}),x(E.Separate,{gap:"2/3",padding:"2/3",horizontalAlign:"right",children:[l(H.Border.S,{isRounded:!0,onClick:()=>{W.close(X)},children:"\u9589\u3058\u308B"}),l(H.Prime.S,{color:"theme",isRounded:!0,ssEffectsOnActive:"shrink",onClick:()=>{let w=[];T.length||(w=_);let M=r({},e);M.filter.current[o]=w,n(M)},children:"\u5168\u9078\u629E"})]})]})};W.open($,!1),B=l(v,{className:y("FilterRegion"),children:l(H.Sub.S,{ssSphere:2.5,fontSize:"1.mini",className:y("Filtering_"+!!T.length),id:J,onClick:w=>{w.stopPropagation(),W.open($)},children:l(N,{icon:ce})})})}}let q={top:!0,bottom:!e.rows.length,left:e.checker?!1:o==0,right:o==e.colLength-1,rowIndex:0,colIndex:o,isBody:!1,isHeader:!0},re=V(q),G=e.cellStylesCallback?e.cellStylesCallback(q):{};i=m(r(r(r(r({},e.cellStyles),re),i),G),{ssPushable:S,freeCSS:r(r(r({},(b=e.cellStyles)==null?void 0:b.freeCSS),G.freeCSS),i.freeCSS),className:[y("Cell"),e.cellClassName,i.className].join(" ")}),delete i.orderIndex,p.push(l(R.TH,m(r({fontWeight:"2.normal",position:"sticky",top:0},i),{freeCSS:r({zIndex:2},i.freeCSS),onClick:_=>{if(S){let T=r({},e),P=[o,d===o&&g=="ASC"?"DESC":"ASC"];T.order.current=P,n(T),e.onOrderChanged&&e.onOrderChanged(P)}},children:x(K,{flexType:"row-r",flexWrap:!1,height:1,borderRadius:"inherit",flexCenter:!0,children:[B,x(K,{flexSizing:0,position:"relative",borderRadius:"inherit",gap:"1/2",flexWrap:!1,verticalAlign:"center",horizontalAlign:"center",children:[O,f]})]})}),o))}return l(R.Row,{className:[y("Row"),y("HeadRow")].join(" "),children:p})},Body:t=>{let{val_status:e,PageRows:n}=t,u=[];if(n.forEach((s,a)=>{var p;let d=[...s],g=[];if(e.checker){let c={top:a==0&&!e.head,bottom:a==n.length-1,left:!0,right:!e.colLength,rowIndex:a,colIndex:0,isBody:!0,isHeader:!1},h=V(c),b=e.cellStylesCallback?e.cellStylesCallback(c):{};g.push(l(R.TH,m(r(r(r({unitWidth:4,padding:0,borderRight:!0},e.cellStyles),h),b),{freeCSS:r(r({},(p=e.cellStyles)==null?void 0:p.freeCSS),b.freeCSS),className:[y("Cell"),e.cellClassName].join(" "),children:l(v,{flexCenter:!0,children:l(L.Checker,{label:null,value:s.checked,override:"force",onUpdateValidValue:({value:o})=>{let i=e.rows,f=i.findIndex(S=>D.is.equal(S.rowID,s.rowID));f!=-1&&(i[f].checked=o,t.set_status(S=>m(r({},S),{rows:i})))}})})}),-1))}d.forEach((c,h)=>{var B;if(!c)return;let O=c,{type:b="td"}=O,o=Y(O,["type"]),i={top:a==0&&!e.head,bottom:a==n.length-1,left:e.checker?!1:h==0,right:h==e.colLength-1,rowIndex:a,colIndex:h,isBody:!0,isHeader:!1},f=V(i),S=e.cellStylesCallback?e.cellStylesCallback(i):{};o=m(r(r(r(r({},e.cellStyles),f),o),S),{freeCSS:r(r(r({},(B=e.cellStyles)==null?void 0:B.freeCSS),o.freeCSS),S.freeCSS),className:[y("Cell"),e.cellClassName,o.className].join(" ")}),delete o.orderIndex;let C=R[b=="td"?"TD":"TH"];g.push(l(C,r({},o),h))}),u.push(l(R.Row,{className:[y("Row"),y("BodyRow")].join(" "),children:g,onClick:c=>{e.onRowClick&&e.onRowClick(s.rowID,c)}},a))}),!n.length){let s=l(v,{padding:2,fontColor:"4.thin",textAlign:"center",borderTop:"1.thin",children:"\u30C6\u30FC\u30D6\u30EB\u304C\u3042\u308A\u307E\u305B\u3093"});e.noRecords&&(s=l(z,{children:e.noRecords})),u.push(l(R.Row,{className:[y("Row"),y("BodyRow"),y("DataNotFound")].join(" "),children:l(R.TD,{colSpan:e.colLength,className:y("Cell"),children:s})},"dataNotFound"))}return l(z,{children:u})},Core:t=>{let{val_status:e,set_status:n}=t,{searchKeyword:u,filter:s,order:a,paging:d}=e,g=[...e.rows],p=[...e.rows],c=[...e.rows],h=[...e.rows];if(u&&(p=g.filter(i=>(i.__sys4SearchKey||"").match(new RegExp(u,"i"))?1:0),c=[...p],h=[...p]),s.enabled)for(let i=0;i<e.colLength;i++){let f=s.column[i],S=s.current[i];f&&S&&S.length&&(c=c.filter(C=>!S.includes(C[i].data)),h=[...c])}a.enabled&&(c=c.order({direction:a.current[1],keys:[a.current[0],"orderIndex"]}),h=[...c]);{let{currentPageIndex:i,rowLength:f}=d;h=[...h].splice((i-1)*f,f)}let b=I.__memoryID+"_"+e.tableID,o={rows:{total:g.length,page:h.length,filtered:c.length},val_status:m(r({},e),{paging:m(r({},e.paging),{pageLength:Math.ceil(c.length/e.paging.rowLength)})}),set_status:n};return te.update({[b]:{getRowData:()=>{let i=[...g];return a.enabled&&(i=i.order({direction:a.current[1],keys:[a.current[0],"orderIndex"]})),i.forEach(f=>{f.currentPage=!1,f.filtered=!1}),h.forEach(f=>{let{rowID:S}=f;i.find(C=>D.is.equal(C.rowID,S)).currentPage=!0}),c.forEach(f=>{let{rowID:S}=f;i.find(C=>D.is.equal(C.rowID,S)).filtered=!0}),i}}}),j(()=>{F.release(e.tableID,o)}),l(v,{className:y("TableBase"),children:l(R.Table,{className:y("Table"),children:x(R.Body,{children:[l(I.Header,{val_status:e,set_status:n,KeywordFilterRows:p}),l(I.Body,{val_status:e,set_status:n,PageRows:h})]})})},u)},Propagations:{},DataLeveler:t=>{var e,n;return t=r({},t),t.filter=(e=t.filter)!=null?e:!1,t.filter=Array.from({length:t.colLength}).map((u,s)=>{var a;return D.is.boolean(t.filter)?t.filter:(a=t.filter[s])!=null?a:!1}),t.order=(n=t.order)!=null?n:!0,t.order=Array.from({length:t.colLength}).map((u,s)=>{var a;return D.is.boolean(t.order)?t.order:(a=t.order[s])!=null?a:!0}),t=r({checker:!1,searchKeyword:"",filter:!1,order:!0,defaultOrder:[0,"ASC"]},t),t.rows.forEach((u,s)=>{u.rowID=u.rowID||s;let a=[];u.forEach((d,g)=>{let{data:p,children:c,orderIndex:h}=d;d.orderIndex=D.is.exist(h)?String(h):String(p),d.children=c||String(p),a.push(String(d.data))}),u.__sys4SearchKey=a.join("/")}),l(I.StateManager,r({},t))},StateManager:t=>{let{colLength:e,checker:n=!1,searchKeyword:u="",filter:s,order:a,defaultOrder:d=[0,"ASC"],pageRowLength:g=30}=t,[p]=ee(Z()),c={tableID:t.tableID||p,componentID:p,colLength:e,checker:n,searchKeyword:u,filter:{enabled:s!==!1,column:s,current:Array.from({length:e},()=>[])},order:{enabled:a!==!1,column:a,current:d},paging:{rowLength:g,pageLength:Math.ceil(t.rows.length/g),currentPageIndex:1},head:t.head,rows:t.rows,noRecords:t.noRecords,cellStyles:t.cellStyles||{},cellClassName:t.cellClassName||"",cellStylesCallback:t.cellStylesCallback,onRowClick:t.onRowClick,onOrderChanged:t.onOrderChanged},[h,b]=ee(c);return j(()=>{b(o=>m(r({},o),{rows:c.rows}))},[D.Stringify(c.rows)]),j(()=>{b(o=>m(r({},o),{head:c.head}))},[D.Stringify(c.head)]),l(I.Core,{val_status:h,set_status:b})}},ue={__memoryID:I.__memoryID,getRowData:t=>{let e=te.get(I.__memoryID+"_"+t);if(e!=null&&e.getRowData)return e.getRowData()}},U={SearchInput:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:n,set_status:u}=e;return l(L.TextField,{label:"\u691C\u7D22...",clearButton:!0,padding:"2/3",paddingRight:3,rightIcon:l(L.RightIcon,{ssSphere:2,fontColor:"5.translucent",right:"2/3",children:l(N.Search,{})}),value:n.searchKeyword,onUpdateValidValue:({value:s})=>{t.onChange(s),D.interval.cycle("InputSearchTime",200,()=>{u(a=>m(r({},a),{paging:m(r({},a.paging),{currentPageIndex:1}),filter:m(r({},a.filter),{current:Array.from({length:a.colLength},()=>[])}),searchKeyword:s}))})}})},Info:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:n,set_status:u}=e,s=e.rows.filtered.ratio(e.rows.total)||0;return x(K,{verticalAlign:"baseline",gap:"1/2",fontSize:"1.mini",fontColor:"3.blur",children:[l(le,{fontSize:"4.thirdTitle",fontColor:"theme",children:e.rows.filtered.toLocaleString()}),"/ ",e.rows.total.toLocaleString(),"\u4EF6 (",s,"%)"]})},Paging:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:n,set_status:u}=e,s=[];for(let d=0;d<n.paging.pageLength;d++)s.push({value:d+1,label:(d+1).toString()});const a=d=>{let g=Math.min(Math.max(1,d),n.paging.pageLength),p=r({},n);p.paging.currentPageIndex=g,u(c=>m(r({},c),{paging:m(r({},c.paging),{currentPageIndex:g})}))};return x(E.Center,{children:[x(E.Center,{gap:"1/2",children:[l(L.Select,{label:"\u9805",freeCSS:{minWidth:12*3},emptySelect:!1,padding:["1/3","2/3"],rightIcon:!1,override:"force",value:n.paging.currentPageIndex,options:s,SelectorGravityPoint:24,onUpdateValidValue:({value:d})=>{a(d)}}),"/ ",n.paging.pageLength]}),x(E.Right,{gap:"1/2",children:[l(H.Sub,{ssSphere:3,onClick:()=>{if(n.paging.currentPageIndex==1){a(n.paging.pageLength);return}a(n.paging.currentPageIndex-1)},children:l(N.ChevronLeft,{})}),l(H.Sub,{ssSphere:3,onClick:()=>{if(n.paging.currentPageIndex==n.paging.pageLength){a(1);return}a(n.paging.currentPageIndex+1)},children:l(N.ChevronRight,{})})]})]})},RowLength:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:n,set_status:u}=e,s=n.paging.rowLength,a=0,d=t.lengthSelect.map(g=>(a|=+(g==s),{value:g,label:g.toString()}));return a||d.push({value:s,label:s.toString()}),d=d.order({direction:"ASC",keys:["value"]}),l(E.Center,{gap:"1/2",children:l(L.Select,{label:"\u4EF6\u6570",emptySelect:!1,rightIcon:!1,override:"force",padding:["1/3","2/3"],value:n.paging.rowLength,options:d,SelectorGravityPoint:24,onUpdateValidValue:({value:g})=>{u(p=>m(r({},p),{paging:{rowLength:Number(g),currentPageIndex:1,pageLength:Math.ceil(e.rows.filtered/Number(g))}}))}})})}},ge=t=>l(de,m(r({},t),{type:"data",JSXChildren:I.DataLeveler})),k=ge;k.__memoryID=I.__memoryID,k.getRowData=ue.getRowData,k.Info=U.Info,k.Paging=U.Paging,k.RowLength=U.RowLength,k.SearchInput=U.SearchInput;export{k as Data,k as default};
1
+ import{b as r,c as m,d as Y}from"../../chunk-C5N2D3ZX.js";import{Fragment as z,jsx as l,jsxs as x}from"react/jsx-runtime";import D,{UUID as Z}from"jmini";import{useState as ee,useEffect as U}from"react";import{useStore as te,useRefresh as F}from"../../@utils";import{Box as B,Flex as K,FAI as N,Span as le,Column as oe}from"../../atoms";import{Row as E}from"../../mols";import{Button as H}from"../Button";import j from"../Sheet";import L from"../Input";import{faArrowUp as ne}from"@fortawesome/free-solid-svg-icons/faArrowUp";import{faArrowDown as se}from"@fortawesome/free-solid-svg-icons/faArrowDown";import{faArrowRight as ie}from"@fortawesome/free-solid-svg-icons/faArrowRight";import{faFilter as ce}from"@fortawesome/free-solid-svg-icons/faFilter";import R from"./Parts";import de from"./Wrapper";import{DefaultCellSystemAdjustingStyles as V}from"./cellStyling";import{TableClasses as y}from"../../@styles/componentClasses";const I={__memoryID:Z(),Header:t=>{var h,b;let{val_status:e,set_status:n,KeywordFilterRows:u}=r({},t),{order:s,filter:a}=e,[d,g]=s.current,p=[],c=[...e.head];if(e.checker){let o={top:!0,bottom:!e.rows.length,left:!0,right:!e.colLength,rowIndex:0,colIndex:0,isBody:!1,isHeader:!0},i=V(o),f=e.cellStylesCallback?e.cellStylesCallback(o):{};p.push(l(R.TH,m(r(r(r({fontWeight:"2.normal",position:"sticky",top:0,unitWidth:4,padding:0},e.cellStyles),i),f),{freeCSS:m(r(r({},(h=e.cellStyles)==null?void 0:h.freeCSS),f.freeCSS),{zIndex:2}),className:[y("Cell"),e.cellClassName].join(" "),children:l(B,{flexCenter:!0,children:l(L.Checker,{label:null,value:!1,onUpdateValidValue:({value:S})=>{let C=e.rows;C.forEach(O=>{O.checked=S}),n(m(r({},e),{rows:C}))}})})}),-1))}for(let o=0;o<e.colLength;o++){let i=c[o];if(!i)continue;let f=i.children||i.data,S=s.enabled&&s.column[o],C=a.enabled&&a.column[o],O=S?l(N,{fontSize:"1.mini",fontColor:o==d?"1.clear":"5.translucent",icon:o==d?g=="DESC"?se:ne:ie}):null,v=l(z,{});if(C){let _=u.map(P=>{var A;return(A=P[o])==null?void 0:A.data});_=[...new Set(_)].order({direction:"ASC"});let T=a.current[o];if(T){let P=_.filter(w=>!T.includes(w)),A=[];_.forEach(w=>{w&&A.push({value:w,label:l(B,{flexSizing:"auto",children:w})})});let X="BUTTON-"+e.componentID+"-"+o,$=e.componentID+"-"+o,G={sheetID:$,parent:"#"+X,gravityPoint:23,type:"custom",content:x(K,{flexType:"col",border:!0,boxShadow:"3.remark",backgroundColor:"layer.1",borderRadius:1,freeCSS:{minWidth:12*20,maxWidth:12*30},children:[l(oe,{gap:"1/3",overflow:"auto",padding:"2/3",freeCSS:{maxHeight:12*30},children:l(L.Checkbox,{icon:!0,value:P,display:"flex",gap:"1/2",override:"force",options:A,hideInput:!0,name:"DTFilter-col-"+o+"-table-"+e.componentID,onUpdateValidValue:({value:w})=>{let M=_.filter(ae=>!w.includes(ae)),Q=r({},e);Q.filter.current[o]=M,n(Q)}})}),x(E.Separate,{gap:"2/3",padding:"2/3",horizontalAlign:"right",children:[l(H.Border.S,{isRounded:!0,onClick:()=>{j.close($)},children:"\u9589\u3058\u308B"}),l(H.Prime.S,{color:"theme",isRounded:!0,ssEffectsOnActive:"shrink",onClick:()=>{let w=[];T.length||(w=_);let M=r({},e);M.filter.current[o]=w,n(M)},children:"\u5168\u9078\u629E"})]})]})};j.open(G,!1),v=l(B,{className:y("FilterRegion"),children:l(H.Sub.S,{ssSphere:2.5,fontSize:"1.mini",className:y("Filtering_"+!!T.length),id:X,onClick:w=>{w.stopPropagation(),j.open(G)},children:l(N,{icon:ce})})})}}let q={top:!0,bottom:!e.rows.length,left:e.checker?!1:o==0,right:o==e.colLength-1,rowIndex:0,colIndex:o,isBody:!1,isHeader:!0},re=V(q),J=e.cellStylesCallback?e.cellStylesCallback(q):{};i=m(r(r(r(r({},e.cellStyles),re),i),J),{ssPushable:S,freeCSS:r(r(r({},(b=e.cellStyles)==null?void 0:b.freeCSS),J.freeCSS),i.freeCSS),className:[y("Cell"),e.cellClassName,i.className].join(" ")}),delete i.orderIndex,p.push(l(R.TH,m(r({fontWeight:"2.normal",position:"sticky",top:0},i),{freeCSS:r({zIndex:2},i.freeCSS),onClick:_=>{if(S){let T=r({},e),P=[o,d===o&&g=="ASC"?"DESC":"ASC"];T.order.current=P,n(T),e.onOrderChanged&&e.onOrderChanged(P)}},children:x(K,{flexType:"row-r",flexWrap:!1,height:1,borderRadius:"inherit",flexCenter:!0,children:[v,x(K,{flexSizing:0,position:"relative",borderRadius:"inherit",gap:"1/2",flexWrap:!1,verticalAlign:"center",horizontalAlign:"center",children:[O,f]})]})}),o))}return l(R.Row,{className:[y("Row"),y("HeadRow")].join(" "),children:p})},Body:t=>{let{val_status:e,PageRows:n}=t,u=[];if(n.forEach((s,a)=>{var p;let d=[...s],g=[];if(e.checker){let c={top:a==0&&!e.head,bottom:a==n.length-1,left:!0,right:!e.colLength,rowIndex:a,colIndex:0,isBody:!0,isHeader:!1},h=V(c),b=e.cellStylesCallback?e.cellStylesCallback(c):{};g.push(l(R.TH,m(r(r(r({unitWidth:4,padding:0,borderRight:!0},e.cellStyles),h),b),{freeCSS:r(r({},(p=e.cellStyles)==null?void 0:p.freeCSS),b.freeCSS),className:[y("Cell"),e.cellClassName].join(" "),children:l(B,{flexCenter:!0,children:l(L.Checker,{label:null,value:s.checked,override:"force",onUpdateValidValue:({value:o})=>{let i=e.rows,f=i.findIndex(S=>D.is.equal(S.rowID,s.rowID));f!=-1&&(i[f].checked=o,t.set_status(S=>m(r({},S),{rows:i})))}})})}),-1))}d.forEach((c,h)=>{var v;if(!c)return;let O=c,{type:b="td"}=O,o=Y(O,["type"]),i={top:a==0&&!e.head,bottom:a==n.length-1,left:e.checker?!1:h==0,right:h==e.colLength-1,rowIndex:a,colIndex:h,isBody:!0,isHeader:!1},f=V(i),S=e.cellStylesCallback?e.cellStylesCallback(i):{};o=m(r(r(r(r({},e.cellStyles),f),o),S),{freeCSS:r(r(r({},(v=e.cellStyles)==null?void 0:v.freeCSS),o.freeCSS),S.freeCSS),className:[y("Cell"),e.cellClassName,o.className].join(" ")}),delete o.orderIndex;let C=R[b=="td"?"TD":"TH"];g.push(l(C,r({},o),h))}),u.push(l(R.Row,{className:[y("Row"),y("BodyRow")].join(" "),children:g,onClick:c=>{e.onRowClick&&e.onRowClick(s.rowID,c)}},a))}),!n.length){let s=l(B,{padding:2,fontColor:"4.thin",textAlign:"center",borderTop:"1.thin",children:"\u30C6\u30FC\u30D6\u30EB\u304C\u3042\u308A\u307E\u305B\u3093"});e.noRecords&&(s=l(z,{children:e.noRecords})),u.push(l(R.Row,{className:[y("Row"),y("BodyRow"),y("DataNotFound")].join(" "),children:l(R.TD,{colSpan:e.colLength,className:y("Cell"),children:s})},"dataNotFound"))}return l(z,{children:u})},Core:t=>{let{val_status:e,set_status:n}=t,{searchKeyword:u,filter:s,order:a,paging:d}=e,g=[...e.rows],p=[...e.rows],c=[...e.rows],h=[...e.rows];if(u&&(p=g.filter(i=>(i.__sys4SearchKey||"").match(new RegExp(u,"i"))?1:0),c=[...p],h=[...p]),s.enabled)for(let i=0;i<e.colLength;i++){let f=s.column[i],S=s.current[i];f&&S&&S.length&&(c=c.filter(C=>!S.includes(C[i].data)),h=[...c])}a.enabled&&(c=c.order({direction:a.current[1],keys:[a.current[0],"orderIndex"]}),h=[...c]);{let{currentPageIndex:i,rowLength:f}=d;h=[...h].splice((i-1)*f,f)}let b=I.__memoryID+"_"+e.tableID,o={rows:{total:g.length,page:h.length,filtered:c.length},val_status:m(r({},e),{paging:m(r({},e.paging),{pageLength:Math.ceil(c.length/e.paging.rowLength)})}),set_status:n};return te.update({[b]:{getRowData:()=>{let i=[...g];return a.enabled&&(i=i.order({direction:a.current[1],keys:[a.current[0],"orderIndex"]})),i.forEach(f=>{f.currentPage=!1,f.filtered=!1}),h.forEach(f=>{let{rowID:S}=f;i.find(C=>D.is.equal(C.rowID,S)).currentPage=!0}),c.forEach(f=>{let{rowID:S}=f;i.find(C=>D.is.equal(C.rowID,S)).filtered=!0}),i}}}),U(()=>{F.release(e.tableID,o)}),l(B,{className:y("TableBase"),children:l(R.Table,{className:y("Table"),children:x(R.Body,{children:[l(I.Header,{val_status:e,set_status:n,KeywordFilterRows:p}),l(I.Body,{val_status:e,set_status:n,PageRows:h})]})})},u)},Propagations:{},DataLeveler:t=>{var e,n;return t=r({},t),t.filter=(e=t.filter)!=null?e:!1,t.filter=Array.from({length:t.colLength}).map((u,s)=>{var a;return D.is.boolean(t.filter)?t.filter:(a=t.filter[s])!=null?a:!1}),t.order=(n=t.order)!=null?n:!0,t.order=Array.from({length:t.colLength}).map((u,s)=>{var a;return D.is.boolean(t.order)?t.order:(a=t.order[s])!=null?a:!0}),t=r({checker:!1,searchKeyword:"",filter:!1,order:!0,defaultOrder:[0,"ASC"]},t),t.rows.forEach((u,s)=>{u.rowID=u.rowID||s;let a=[];u.forEach((d,g)=>{let{data:p,children:c,orderIndex:h}=d;d.orderIndex=D.is.exist(h)?String(h):String(p),d.children=c||String(p),a.push(String(d.data))}),u.__sys4SearchKey=a.join("/")}),l(I.StateManager,r({},t))},StateManager:t=>{let{colLength:e,checker:n=!1,searchKeyword:u="",filter:s,order:a,defaultOrder:d=[0,"ASC"],pageRowLength:g=30}=t,[p]=ee(Z()),c={tableID:t.tableID||p,componentID:p,colLength:e,checker:n,searchKeyword:u,filter:{enabled:s!==!1,column:s,current:Array.from({length:e},()=>[])},order:{enabled:a!==!1,column:a,current:d},paging:{rowLength:g,pageLength:Math.ceil(t.rows.length/g),currentPageIndex:1},head:t.head,rows:t.rows,noRecords:t.noRecords,cellStyles:t.cellStyles||{},cellClassName:t.cellClassName||"",cellStylesCallback:t.cellStylesCallback,onRowClick:t.onRowClick,onOrderChanged:t.onOrderChanged},[h,b]=ee(c);return U(()=>{b(o=>m(r({},o),{rows:c.rows}))},[D.Stringify(c.rows)]),U(()=>{b(o=>m(r({},o),{head:c.head}))},[D.Stringify(c.head)]),l(I.Core,{val_status:h,set_status:b})}},ue={__memoryID:I.__memoryID,getRowData:t=>{let e=te.get(I.__memoryID+"_"+t);if(e!=null&&e.getRowData)return e.getRowData()}},W={SearchInput:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:n,set_status:u}=e;return l(L.TextField,{label:"\u691C\u7D22...",clearButton:!0,padding:"2/3",paddingRight:3,rightIcon:l(L.RightIcon,{ssSphere:2,fontColor:"5.translucent",right:"2/3",children:l(N.Search,{})}),value:n.searchKeyword,onUpdateValidValue:({value:s})=>{t.onChange(s),D.interval.cycle("InputSearchTime",200,()=>{u(a=>m(r({},a),{paging:m(r({},a.paging),{currentPageIndex:1}),filter:m(r({},a.filter),{current:Array.from({length:a.colLength},()=>[])}),searchKeyword:s}))})}})},Info:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:n,set_status:u}=e,s=e.rows.filtered.ratio(e.rows.total)||0;return x(K,{verticalAlign:"baseline",gap:"1/2",fontSize:"1.mini",fontColor:"3.blur",children:[l(le,{fontSize:"4.thirdTitle",fontColor:"theme",children:e.rows.filtered.toLocaleString()}),"/ ",e.rows.total.toLocaleString(),"\u4EF6 (",s,"%)"]})},Paging:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:n,set_status:u}=e,s=[];for(let d=0;d<n.paging.pageLength;d++)s.push({value:d+1,label:(d+1).toString()});const a=d=>{let g=Math.min(Math.max(1,d),n.paging.pageLength),p=r({},n);p.paging.currentPageIndex=g,u(c=>m(r({},c),{paging:m(r({},c.paging),{currentPageIndex:g})}))};return x(E.Center,{children:[x(E.Center,{gap:"1/2",children:[l(L.Select,{label:"\u9805",freeCSS:{minWidth:12*3},emptySelect:!1,padding:["1/3","2/3"],rightIcon:!1,override:"force",SelectorStyles:{freeCSS:{minWidth:12*9}},value:n.paging.currentPageIndex,options:s,onUpdateValidValue:({value:d})=>{a(d)}}),"/ ",n.paging.pageLength]}),x(E.Right,{gap:"1/2",children:[l(H.Sub,{ssSphere:3,onClick:()=>{if(n.paging.currentPageIndex==1){a(n.paging.pageLength);return}a(n.paging.currentPageIndex-1)},children:l(N.ChevronLeft,{})}),l(H.Sub,{ssSphere:3,onClick:()=>{if(n.paging.currentPageIndex==n.paging.pageLength){a(1);return}a(n.paging.currentPageIndex+1)},children:l(N.ChevronRight,{})})]})]})},RowLength:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:n,set_status:u}=e,s=n.paging.rowLength,a=0,d=t.lengthSelect.map(g=>(a|=+(g==s),{value:g,label:g.toString()}));return a||d.push({value:s,label:s.toString()}),d=d.order({direction:"ASC",keys:["value"]}),l(E.Center,{gap:"1/2",children:l(L.Select,{label:"\u4EF6\u6570",emptySelect:!1,rightIcon:!1,override:"force",padding:["1/3","2/3"],SelectorStyles:{freeCSS:{minWidth:12*9}},value:n.paging.rowLength,options:d,onUpdateValidValue:({value:g})=>{u(p=>m(r({},p),{paging:{rowLength:Number(g),currentPageIndex:1,pageLength:Math.ceil(e.rows.filtered/Number(g))}}))}})})}},ge=t=>l(de,m(r({},t),{type:"data",JSXChildren:I.DataLeveler})),k=ge;k.__memoryID=I.__memoryID,k.getRowData=ue.getRowData,k.Info=W.Info,k.Paging=W.Paging,k.RowLength=W.RowLength,k.SearchInput=W.SearchInput;export{k as Data,k as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amotify",
3
- "version": "0.2.81",
3
+ "version": "0.2.83",
4
4
  "description": "UI Component for React,NextJS,esbuild",
5
5
  "scripts": {
6
6
  "start": "run-p clean build:*",