amotify 0.2.141 → 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
|
|
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};
|
package/dist/fn/Input/List.d.ts
CHANGED
|
@@ -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
|
|
40
|
+
label?: ReactElement;
|
|
41
41
|
disabled?: boolean;
|
|
42
42
|
className?: string;
|
|
43
43
|
checkedStyles?: StyleTags.PropsNFreeCSS;
|
package/dist/fn/Input/List.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as o,c as
|
|
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as s,c as h,d as y}from"../chunk-C5N2D3ZX.js";import{jsx as g,jsxs as B}from"react/jsx-runtime";import{useState as x,useEffect as N}from"react";import a,{UUID as R}from"jmini";import{$$fromRoot as c,Config as w,pageRouter as F}from"../@utils";import{Box as S,Flex as C,Column as P}from"../atoms";import{Button as H}from"./Button";import{LayoutClasses as f}from"../@styles/componentClasses";const d={Base:t=>{let n=t,{topNavigation:o,sideNavigation:e,footerNavigation:i,children:l,className:r}=n,u=y(n,["topNavigation","sideNavigation","footerNavigation","children","className"]);N(()=>{d.fn.updateCSSProperty.reset(),setTimeout(()=>{d.fn.updateCSSProperty.reset()},100);let p="ResizeCB",m="RemovePageEventCB";return a(window).addEvent({eventType:"resize",eventID:p,callback:()=>{w.get().screen.isPhonepoint()||a.interval.once(()=>{d.fn.updateCSSProperty.reset()},300,"__RVC_calcHeights")}}),()=>{a(window).removeEvent(m),a(window).removeEvent(p)}},[]);let v=l;return B(P,h(s({className:[r,f("RootViewController")].join(" "),backgroundColor:"layer.1",gap:0,minHeight:"viewHeight"},u),{children:[o,B(C,{className:f("Body"),flexWrap:!1,position:"relative",flexSizing:0,children:[e,g(S,{className:f("Content"),position:"relative",flexSizing:0,width:0,children:v})]}),i]}))},TopNavigation:t=>{let r=t,{className:o,children:e}=r,i=y(r,["className","children"]),[l]=x(R());return N(()=>{d.fn.updateCSSProperty.topNav()},[]),g(C,h(s({"data-id":l,flexSizing:"none",flexType:"col",position:"sticky",top:0,backgroundColor:"layer.1"},i),{id:"__RVC_TopNavigation",className:[o,f("TopNav")].join(" "),children:e}),l)},SideNavigation:t=>{let i=t,{className:o=""}=i,e=y(i,["className"]);return N(()=>{d.fn.updateCSSProperty.sideNav()},[]),g(S,h(s({className:[o,f("SideNav")].join(" "),flexSizing:"none",minHeight:"sideNavigationHeight"},e),{id:"__RVC_SideNavigation"}))},FooterNavigation:t=>{let r=t,{className:o="",baseStyles:e}=r,i=y(r,["className","baseStyles"]),[l]=x(R());return N(()=>{d.fn.updateCSSProperty.footer()},[]),g(C,h(s({"data-id":l,borderTop:!0,position:"sticky",bottom:0,overflow:"auto",backgroundColor:"layer.1",paddingBottom:"safeAreaBottom"},e),{id:"__RVC_FooterNavigation",className:[f("FooterNav"),o].join(" "),children:g(C,s({gap:1,flexWrap:!1,padding:"2/3",margin:"auto",width:1},i))}))},Comps:{Button:t=>{let v=t,{isActive:o,uri:e,uriGroup:i}=v,l=y(v,["isActive","uri","uriGroup"]),r=a.flatArray(i),u=location.pathname;{let n=!1;if(a.is.exist(e)&&a.is.string(e)){let p=[location.origin,e.replace(/\//,"")].join("/");n=u==new URL(p).pathname}if(!n&&r.length)for(let p of r)a.is.nullish(p)||u.match(new RegExp(p))&&(n=!0);o=o!=null?o:n}return g(H.Clear,s({isActive:o,isActiveStyles:{fontColor:"theme",backgroundColor:"cloud"},onClick:n=>{a.is.exist(e)&&a.is.string(e)&&F.push(e,n.ctrlKey||n.metaKey)},color:"cloud",padding:["3/4",1],display:"flex",gap:"1/2",fontColor:"inherit",width:1,flexSizing:"none",flexWrap:!1,ssEffectsOnActive:"ripple.cloud",verticalAlign:"center",textAlign:"left",isSemiBoldFont:!0},l))},Bar:t=>g(S,s({flexSizing:"none",backgroundColor:"layer.4.opa.middle",unitHeight:"1/3",margin:["2/3",1],isRounded:!0},t)),Title:t=>g(S,s({fontSize:"3.paragraph",isSemiBoldFont:!0,padding:[0,1]},t))},fn:{updateCSSProperty:{topNav:()=>{let t=a(document.body),o=c("#__RVC_TopNavigation"),e=o.position().height||0,i=e;o.getStyleProperty("position")!="sticky"&&(i=0),t.setStyleProperty("--topNavHeight",e+"px").setStyleProperty("--topBase",i+"px")},footer:()=>{let t=a(document.body),e=c("#__RVC_FooterNavigation").position().height||0;t.setStyleProperty("--footerNavHeight",e+"px")},sideNav:()=>{let t=a(document.body),e=c("#__RVC_SideNavigation").position().width||0;t.setStyleProperty("--sideNavWidth",e+"px")},reset:()=>{let t=a(document.body),o=c("#__RVC_TopNavigation"),e=c("#__RVC_FooterNavigation"),i=c("#__RVC_SideNavigation"),l=o.position().height||0,r=l,u=e.position().height||0,v=i.position().width||0;o.getStyleProperty("position")!="sticky"&&(r=0);let n=window.innerHeight,p=window.innerWidth,m=n-l-u,_=p-v;t.setStyleProperty("--topNavHeight",l+"px").setStyleProperty("--topBase",r+"px").setStyleProperty("--footerNavHeight",u+"px").setStyleProperty("--viewHeight",n+"px").setStyleProperty("--sideNavHeight",m+"px").setStyleProperty("--contentHeight",m+"px").setStyleProperty("--contentWidth",_+"px")}}}};export{d as RootViewController,d as default};
|
|
1
|
+
import{b as s,c as h,d as y}from"../chunk-C5N2D3ZX.js";import{jsx as g,jsxs as B}from"react/jsx-runtime";import{useState as x,useEffect as N}from"react";import a,{UUID as R}from"jmini";import{$$fromRoot as c,Config as w,pageRouter as F}from"../@utils";import{Box as S,Flex as C,Column as P}from"../atoms";import{Button as H}from"./Button";import{LayoutClasses as f}from"../@styles/componentClasses";const d={Base:t=>{let n=t,{topNavigation:o,sideNavigation:e,footerNavigation:i,children:l,className:r}=n,u=y(n,["topNavigation","sideNavigation","footerNavigation","children","className"]);N(()=>{d.fn.updateCSSProperty.reset(),setTimeout(()=>{d.fn.updateCSSProperty.reset()},100);let p="ResizeCB",m="RemovePageEventCB";return a(window).addEvent({eventType:"resize",eventID:p,callback:()=>{w.get().screen.isPhonepoint()||a.interval.once(()=>{d.fn.updateCSSProperty.reset()},300,"__RVC_calcHeights")}}),()=>{a(window).removeEvent(m),a(window).removeEvent(p)}},[]);let v=l;return B(P,h(s({className:[r,f("RootViewController")].join(" "),backgroundColor:"layer.1",gap:0,minHeight:"viewHeight"},u),{children:[o,B(C,{className:f("Body"),flexWrap:!1,position:"relative",flexSizing:0,children:[e,g(S,{className:f("Content"),position:"relative",flexSizing:0,width:0,children:v})]}),i]}))},TopNavigation:t=>{let r=t,{className:o,children:e}=r,i=y(r,["className","children"]),[l]=x(R());return N(()=>{d.fn.updateCSSProperty.topNav()},[]),g(C,h(s({"data-id":l,flexSizing:"none",flexType:"col",position:"sticky",top:0,backgroundColor:"layer.1"},i),{id:"__RVC_TopNavigation",className:[o,f("TopNav")].join(" "),children:e}),l)},SideNavigation:t=>{let i=t,{className:o=""}=i,e=y(i,["className"]);return N(()=>{d.fn.updateCSSProperty.sideNav()},[]),g(S,h(s({className:[o,f("SideNav")].join(" "),flexSizing:"none",minHeight:"sideNavigationHeight"},e),{id:"__RVC_SideNavigation"}))},FooterNavigation:t=>{let r=t,{className:o="",baseStyles:e}=r,i=y(r,["className","baseStyles"]),[l]=x(R());return N(()=>{d.fn.updateCSSProperty.footer()},[]),g(C,h(s({"data-id":l,borderTop:!0,position:"sticky",bottom:0,overflow:"auto",backgroundColor:"layer.1",paddingBottom:"safeAreaBottom"},e),{id:"__RVC_FooterNavigation",className:[f("FooterNav"),o].join(" "),children:g(C,s({gap:1,flexWrap:!1,padding:"2/3",margin:"auto",width:1},i))}))},Comps:{Button:t=>{let v=t,{isActive:o,uri:e,uriGroup:i}=v,l=y(v,["isActive","uri","uriGroup"]),r=a.flatArray(i),u=location.pathname;{let n=!1;if(a.is.exist(e)&&a.is.string(e)){let p=[location.origin,e.replace(/\//,"")].join("/");n=u==new URL(p).pathname}if(!n&&r.length)for(let p of r)a.is.nullish(p)||u.match(new RegExp(String(p).escapeRegExChar()))&&(n=!0);o=o!=null?o:n}return g(H.Clear,s({isActive:o,isActiveStyles:{fontColor:"theme",backgroundColor:"cloud"},onClick:n=>{a.is.exist(e)&&a.is.string(e)&&F.push(e,n.ctrlKey||n.metaKey)},color:"cloud",padding:["3/4",1],display:"flex",gap:"1/2",fontColor:"inherit",width:1,flexSizing:"none",flexWrap:!1,ssEffectsOnActive:"ripple.cloud",verticalAlign:"center",textAlign:"left",isSemiBoldFont:!0},l))},Bar:t=>g(S,s({flexSizing:"none",backgroundColor:"layer.4.opa.middle",unitHeight:"1/3",margin:["2/3",1],isRounded:!0},t)),Title:t=>g(S,s({fontSize:"3.paragraph",isSemiBoldFont:!0,padding:[0,1]},t))},fn:{updateCSSProperty:{topNav:()=>{let t=a(document.body),o=c("#__RVC_TopNavigation"),e=o.position().height||0,i=e;o.getStyleProperty("position")!="sticky"&&(i=0),t.setStyleProperty("--topNavHeight",e+"px").setStyleProperty("--topBase",i+"px")},footer:()=>{let t=a(document.body),e=c("#__RVC_FooterNavigation").position().height||0;t.setStyleProperty("--footerNavHeight",e+"px")},sideNav:()=>{let t=a(document.body),e=c("#__RVC_SideNavigation").position().width||0;t.setStyleProperty("--sideNavWidth",e+"px")},reset:()=>{let t=a(document.body),o=c("#__RVC_TopNavigation"),e=c("#__RVC_FooterNavigation"),i=c("#__RVC_SideNavigation"),l=o.position().height||0,r=l,u=e.position().height||0,v=i.position().width||0;o.getStyleProperty("position")!="sticky"&&(r=0);let n=window.innerHeight,p=window.innerWidth,m=n-l-u,_=p-v;t.setStyleProperty("--topNavHeight",l+"px").setStyleProperty("--topBase",r+"px").setStyleProperty("--footerNavHeight",u+"px").setStyleProperty("--viewHeight",n+"px").setStyleProperty("--sideNavHeight",m+"px").setStyleProperty("--contentHeight",m+"px").setStyleProperty("--contentWidth",_+"px")}}}};export{d as RootViewController,d as default};
|
package/dist/fn/Table/Data.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as r,c as m,d as G}from"../../chunk-C5N2D3ZX.js";import{Fragment as W,jsx as l,jsxs as x}from"react/jsx-runtime";import D,{UUID as Q,useStore as Y}from"jmini";import{useState as Z,useEffect as U}from"react";import{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 ee 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 ue from"./Wrapper";import{DefaultCellSystemAdjustingStyles as j}from"./cellStyling";import{TableClasses as y}from"../../@styles/componentClasses";const I={__memoryID:Q(),Header:t=>{var h,b;let{val_status:e,set_status:s,KeywordFilterRows:d}=r({},t),{order:i,filter:a}=e,[u,g]=i.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},n=j(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),n),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:S=>{let C=e.rows;C.forEach(O=>{O.checked=S}),s(m(r({},e),{rows:C}))}})})}),-1))}for(let o=0;o<e.colLength;o++){let n=c[o];if(!n)continue;let f=n.children||n.data,S=i.enabled&&i.column[o],C=a.enabled&&a.column[o],O=S?l(N,{fontSize:"1.mini",fontColor:o==u?"1.clear":"5.translucent",icon:o==u?g=="DESC"?se:ne:ie}):null,v=l(W,{});if(C){let _=d.map(P=>{var A;return(A=P[o])==null?void 0:A.data});_=[...new Set(_)].toASC();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 J="BUTTON-"+e.componentID+"-"+o,X=e.componentID+"-"+o,re={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:"2/3",override:"force",options:A,hideInput:!0,name:"DTFilter-col-"+o+"-table-"+e.componentID,onUpdateValidValue:w=>{let M=_.filter(ae=>!w.includes(ae)),$=r({},e);$.filter.current[o]=M,s($)}})}),x(E.Separate,{gap:"2/3",padding:"2/3",horizontalAlign:"right",children:[l(H.Border.S,{isRounded:!0,onClick:()=>{ee.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,s(M)},children:"\u5168\u9078\u629E"})]})]})};v=l(B,{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(),ee.open(re)},children:l(N,{icon:ce})})})}}let z={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},te=j(z),q=e.cellStylesCallback?e.cellStylesCallback(z):{};n=m(r(r(r(r({},e.cellStyles),te),n),q),{ssPushable:S,freeCSS:r(r(r({},(b=e.cellStyles)==null?void 0:b.freeCSS),q.freeCSS),n.freeCSS),className:[y("Cell"),e.cellClassName,n.className].join(" ")}),delete n.orderIndex,p.push(l(R.TH,m(r({fontWeight:"2.normal",position:"sticky",top:0},n),{freeCSS:r({zIndex:2},n.freeCSS),onClick:_=>{if(S){let T=r({},e),P=[o,u===o&&g=="ASC"?"DESC":"ASC"];T.order.current=P,s(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:s}=t,d=[];if(s.forEach((i,a)=>{var p;let u=[...i],g=[];if(e.checker){let c={top:a==0&&!e.head,bottom:a==s.length-1,left:!0,right:!e.colLength,rowIndex:a,colIndex:0,isBody:!0,isHeader:!1},h=j(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:i.checked,override:"force",onUpdateValidValue:o=>{let n=e.rows,f=n.findIndex(S=>D.is.equal(S.rowID,i.rowID));f!=-1&&(n[f].checked=o,t.set_status(S=>m(r({},S),{rows:n})))}})})}),-1))}u.forEach((c,h)=>{var v;if(!c)return;let O=c,{type:b="td"}=O,o=G(O,["type"]),n={top:a==0&&!e.head,bottom:a==s.length-1,left:e.checker?!1:h==0,right:h==e.colLength-1,rowIndex:a,colIndex:h,isBody:!0,isHeader:!1},f=j(n),S=e.cellStylesCallback?e.cellStylesCallback(n):{};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))}),d.push(l(R.Row,{className:[y("Row"),y("BodyRow")].join(" "),children:g,onClick:c=>{e.onRowClick&&e.onRowClick(i.rowID,c)}},a))}),!s.length){let i=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&&(i=l(W,{children:e.noRecords})),d.push(l(R.Row,{className:[y("Row"),y("BodyRow"),y("DataNotFound")].join(" "),children:l(R.TD,{colSpan:e.colLength,className:y("Cell"),children:i})},"dataNotFound"))}return l(W,{children:d})},Core:t=>{let{val_status:e,set_status:s}=t,{searchKeyword:d,filter:i,order:a,paging:u}=e,g=[...e.rows],p=[...e.rows],c=[...e.rows],h=[...e.rows];if(d&&(p=g.filter(n=>(n.__sys4SearchKey||"").match(new RegExp(d,"i"))?1:0),c=[...p],h=[...p]),i.enabled)for(let n=0;n<e.colLength;n++){let f=i.column[n],S=i.current[n];f&&S&&S.length&&(c=c.filter(C=>!S.includes(C[n].data)),h=[...c])}a.enabled&&(a.current[1]=="ASC"?c=c.toASC([a.current[0],"orderIndex"].join(".")):c=c.toDESC([a.current[0],"orderIndex"].join(".")),h=[...c]);{let{currentPageIndex:n,rowLength:f}=u;h=[...h].splice((n-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:s};return Y.update({[b]:{getRowData:()=>{let n=[...g];return a.enabled&&(a.current[1]=="ASC"?n=n.toASC([a.current[0],"orderIndex"].join(".")):n=n.toDESC([a.current[0],"orderIndex"].join("."))),n.forEach(f=>{f.currentPage=!1,f.filtered=!1}),h.forEach(f=>{let{rowID:S}=f;n.find(C=>D.is.equal(C.rowID,S)).currentPage=!0}),c.forEach(f=>{let{rowID:S}=f;n.find(C=>D.is.equal(C.rowID,S)).filtered=!0}),n}}}),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:s,KeywordFilterRows:p}),l(I.Body,{val_status:e,set_status:s,PageRows:h})]})})},d)},Propagations:{},DataLeveler:t=>{var e,s;return t=r({},t),t.filter=(e=t.filter)!=null?e:!1,t.filter=Array.from({length:t.colLength}).map((d,i)=>{var a;return D.is.boolean(t.filter)?t.filter:(a=t.filter[i])!=null?a:!1}),t.order=(s=t.order)!=null?s:!0,t.order=Array.from({length:t.colLength}).map((d,i)=>{var a;return D.is.boolean(t.order)?t.order:(a=t.order[i])!=null?a:!0}),t=r({checker:!1,searchKeyword:"",filter:!1,order:!0,defaultOrder:[0,"ASC"]},t),t.rows.forEach((d,i)=>{d.rowID=d.rowID||i;let a=[];d.forEach((u,g)=>{let{data:p,children:c,orderIndex:h}=u;u.orderIndex=D.is.exist(h)?String(h):String(p),u.children=c||String(p),a.push(String(u.data))}),d.__sys4SearchKey=a.join("/")}),l(I.StateManager,r({},t))},StateManager:t=>{let{colLength:e,checker:s=!1,searchKeyword:d="",filter:i,order:a,defaultOrder:u=[0,"ASC"],pageRowLength:g=30}=t,[p]=Z(Q()),c={tableID:t.tableID||p,componentID:p,colLength:e,checker:s,searchKeyword:d,filter:{enabled:i!==!1,column:i,current:Array.from({length:e},()=>[])},order:{enabled:a!==!1,column:a,current:u},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]=Z(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})}},de={__memoryID:I.__memoryID,getRowData:t=>{let e=Y.get(I.__memoryID+"_"+t);if(e!=null&&e.getRowData)return e.getRowData()}},V={SearchInput:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:s,set_status:d}=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:s.searchKeyword,onUpdateValidValue:i=>{t.onChange(i),D.interval.once(()=>{d(a=>m(r({},a),{paging:m(r({},a.paging),{currentPageIndex:1}),filter:m(r({},a.filter),{current:Array.from({length:a.colLength},()=>[])}),searchKeyword:i}))},200,"InputSearchTime")}})},Info:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:s,set_status:d}=e,i=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 (",i,"%)"]})},Paging:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:s,set_status:d}=e,i=[];for(let u=0;u<s.paging.pageLength;u++)i.push({value:u+1,label:(u+1).toString()});const a=u=>{let g=Math.min(Math.max(1,u),s.paging.pageLength),p=r({},s);p.paging.currentPageIndex=g,d(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:s.paging.currentPageIndex,options:i,onUpdateValidValue:u=>{a(u)}}),"/ ",s.paging.pageLength]}),x(E.Right,{gap:"1/2",children:[l(H.Sub,{ssSphere:3,onClick:()=>{if(s.paging.currentPageIndex==1){a(s.paging.pageLength);return}a(s.paging.currentPageIndex-1)},children:l(N.ChevronLeft,{})}),l(H.Sub,{ssSphere:3,onClick:()=>{if(s.paging.currentPageIndex==s.paging.pageLength){a(1);return}a(s.paging.currentPageIndex+1)},children:l(N.ChevronRight,{})})]})]})},RowLength:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:s,set_status:d}=e,i=s.paging.rowLength,a=0,u=t.lengthSelect.map(g=>(a|=+(g==i),{value:g,label:g.toString()}));return a||u.push({value:i,label:i.toString()}),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}},SelectorPosition:4,value:s.paging.rowLength,options:u.toASC("value"),onUpdateValidValue:g=>{d(p=>m(r({},p),{paging:{rowLength:Number(g),currentPageIndex:1,pageLength:Math.ceil(e.rows.filtered/Number(g))}}))}})})}},ge=t=>l(ue,m(r({},t),{type:"data",JSXChildren:I.DataLeveler})),k=ge;k.__memoryID=I.__memoryID,k.getRowData=de.getRowData,k.Info=V.Info,k.Paging=V.Paging,k.RowLength=V.RowLength,k.SearchInput=V.SearchInput;export{k as Data,k as default};
|
|
1
|
+
import{b as r,c as m,d as G}from"../../chunk-C5N2D3ZX.js";import{Fragment as W,jsx as l,jsxs as x}from"react/jsx-runtime";import D,{UUID as Q,useStore as Y}from"jmini";import{useState as Z,useEffect as U}from"react";import{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 ee 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 ue from"./Wrapper";import{DefaultCellSystemAdjustingStyles as j}from"./cellStyling";import{TableClasses as y}from"../../@styles/componentClasses";const I={__memoryID:Q(),Header:t=>{var h,b;let{val_status:e,set_status:s,KeywordFilterRows:d}=r({},t),{order:i,filter:a}=e,[u,g]=i.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},n=j(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),n),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:S=>{let C=e.rows;C.forEach(O=>{O.checked=S}),s(m(r({},e),{rows:C}))}})})}),-1))}for(let o=0;o<e.colLength;o++){let n=c[o];if(!n)continue;let f=n.children||n.data,S=i.enabled&&i.column[o],C=a.enabled&&a.column[o],O=S?l(N,{fontSize:"1.mini",fontColor:o==u?"1.clear":"5.translucent",icon:o==u?g=="DESC"?se:ne:ie}):null,v=l(W,{});if(C){let _=d.map(P=>{var A;return(A=P[o])==null?void 0:A.data});_=[...new Set(_)].toASC();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 J="BUTTON-"+e.componentID+"-"+o,X=e.componentID+"-"+o,re={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:"2/3",override:"force",options:A,hideInput:!0,name:"DTFilter-col-"+o+"-table-"+e.componentID,onUpdateValidValue:w=>{let M=_.filter(ae=>!w.includes(ae)),$=r({},e);$.filter.current[o]=M,s($)}})}),x(E.Separate,{gap:"2/3",padding:"2/3",horizontalAlign:"right",children:[l(H.Border.S,{isRounded:!0,onClick:()=>{ee.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,s(M)},children:"\u5168\u9078\u629E"})]})]})};v=l(B,{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(),ee.open(re)},children:l(N,{icon:ce})})})}}let z={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},te=j(z),q=e.cellStylesCallback?e.cellStylesCallback(z):{};n=m(r(r(r(r({},e.cellStyles),te),n),q),{ssPushable:S,freeCSS:r(r(r({},(b=e.cellStyles)==null?void 0:b.freeCSS),q.freeCSS),n.freeCSS),className:[y("Cell"),e.cellClassName,n.className].join(" ")}),delete n.orderIndex,p.push(l(R.TH,m(r({fontWeight:"2.normal",position:"sticky",top:0},n),{freeCSS:r({zIndex:2},n.freeCSS),onClick:_=>{if(S){let T=r({},e),P=[o,u===o&&g=="ASC"?"DESC":"ASC"];T.order.current=P,s(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:s}=t,d=[];if(s.forEach((i,a)=>{var p;let u=[...i],g=[];if(e.checker){let c={top:a==0&&!e.head,bottom:a==s.length-1,left:!0,right:!e.colLength,rowIndex:a,colIndex:0,isBody:!0,isHeader:!1},h=j(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:i.checked,override:"force",onUpdateValidValue:o=>{let n=e.rows,f=n.findIndex(S=>D.is.equal(S.rowID,i.rowID));f!=-1&&(n[f].checked=o,t.set_status(S=>m(r({},S),{rows:n})))}})})}),-1))}u.forEach((c,h)=>{var v;if(!c)return;let O=c,{type:b="td"}=O,o=G(O,["type"]),n={top:a==0&&!e.head,bottom:a==s.length-1,left:e.checker?!1:h==0,right:h==e.colLength-1,rowIndex:a,colIndex:h,isBody:!0,isHeader:!1},f=j(n),S=e.cellStylesCallback?e.cellStylesCallback(n):{};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))}),d.push(l(R.Row,{className:[y("Row"),y("BodyRow")].join(" "),children:g,onClick:c=>{e.onRowClick&&e.onRowClick(i.rowID,c)}},a))}),!s.length){let i=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&&(i=l(W,{children:e.noRecords})),d.push(l(R.Row,{className:[y("Row"),y("BodyRow"),y("DataNotFound")].join(" "),children:l(R.TD,{colSpan:e.colLength,className:y("Cell"),children:i})},"dataNotFound"))}return l(W,{children:d})},Core:t=>{let{val_status:e,set_status:s}=t,{searchKeyword:d,filter:i,order:a,paging:u}=e,g=[...e.rows],p=[...e.rows],c=[...e.rows],h=[...e.rows];if(d&&(p=g.filter(n=>(n.__sys4SearchKey||"").match(new RegExp(String(d).escapeRegExChar(),"i"))?1:0),c=[...p],h=[...p]),i.enabled)for(let n=0;n<e.colLength;n++){let f=i.column[n],S=i.current[n];f&&S&&S.length&&(c=c.filter(C=>!S.includes(C[n].data)),h=[...c])}a.enabled&&(a.current[1]=="ASC"?c=c.toASC([a.current[0],"orderIndex"].join(".")):c=c.toDESC([a.current[0],"orderIndex"].join(".")),h=[...c]);{let{currentPageIndex:n,rowLength:f}=u;h=[...h].splice((n-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:s};return Y.update({[b]:{getRowData:()=>{let n=[...g];return a.enabled&&(a.current[1]=="ASC"?n=n.toASC([a.current[0],"orderIndex"].join(".")):n=n.toDESC([a.current[0],"orderIndex"].join("."))),n.forEach(f=>{f.currentPage=!1,f.filtered=!1}),h.forEach(f=>{let{rowID:S}=f;n.find(C=>D.is.equal(C.rowID,S)).currentPage=!0}),c.forEach(f=>{let{rowID:S}=f;n.find(C=>D.is.equal(C.rowID,S)).filtered=!0}),n}}}),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:s,KeywordFilterRows:p}),l(I.Body,{val_status:e,set_status:s,PageRows:h})]})})},d)},Propagations:{},DataLeveler:t=>{var e,s;return t=r({},t),t.filter=(e=t.filter)!=null?e:!1,t.filter=Array.from({length:t.colLength}).map((d,i)=>{var a;return D.is.boolean(t.filter)?t.filter:(a=t.filter[i])!=null?a:!1}),t.order=(s=t.order)!=null?s:!0,t.order=Array.from({length:t.colLength}).map((d,i)=>{var a;return D.is.boolean(t.order)?t.order:(a=t.order[i])!=null?a:!0}),t=r({checker:!1,searchKeyword:"",filter:!1,order:!0,defaultOrder:[0,"ASC"]},t),t.rows.forEach((d,i)=>{d.rowID=d.rowID||i;let a=[];d.forEach((u,g)=>{let{data:p,children:c,orderIndex:h}=u;u.orderIndex=D.is.exist(h)?String(h):String(p),u.children=c||String(p),a.push(String(u.data))}),d.__sys4SearchKey=a.join("/")}),l(I.StateManager,r({},t))},StateManager:t=>{let{colLength:e,checker:s=!1,searchKeyword:d="",filter:i,order:a,defaultOrder:u=[0,"ASC"],pageRowLength:g=30}=t,[p]=Z(Q()),c={tableID:t.tableID||p,componentID:p,colLength:e,checker:s,searchKeyword:d,filter:{enabled:i!==!1,column:i,current:Array.from({length:e},()=>[])},order:{enabled:a!==!1,column:a,current:u},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]=Z(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})}},de={__memoryID:I.__memoryID,getRowData:t=>{let e=Y.get(I.__memoryID+"_"+t);if(e!=null&&e.getRowData)return e.getRowData()}},V={SearchInput:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:s,set_status:d}=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:s.searchKeyword,onUpdateValidValue:i=>{t.onChange(i),D.interval.once(()=>{d(a=>m(r({},a),{paging:m(r({},a.paging),{currentPageIndex:1}),filter:m(r({},a.filter),{current:Array.from({length:a.colLength},()=>[])}),searchKeyword:i}))},200,"InputSearchTime")}})},Info:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:s,set_status:d}=e,i=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 (",i,"%)"]})},Paging:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:s,set_status:d}=e,i=[];for(let u=0;u<s.paging.pageLength;u++)i.push({value:u+1,label:(u+1).toString()});const a=u=>{let g=Math.min(Math.max(1,u),s.paging.pageLength),p=r({},s);p.paging.currentPageIndex=g,d(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:s.paging.currentPageIndex,options:i,onUpdateValidValue:u=>{a(u)}}),"/ ",s.paging.pageLength]}),x(E.Right,{gap:"1/2",children:[l(H.Sub,{ssSphere:3,onClick:()=>{if(s.paging.currentPageIndex==1){a(s.paging.pageLength);return}a(s.paging.currentPageIndex-1)},children:l(N.ChevronLeft,{})}),l(H.Sub,{ssSphere:3,onClick:()=>{if(s.paging.currentPageIndex==s.paging.pageLength){a(1);return}a(s.paging.currentPageIndex+1)},children:l(N.ChevronRight,{})})]})]})},RowLength:t=>{let e=F.catch(t.tableID);if(!e)return null;let{val_status:s,set_status:d}=e,i=s.paging.rowLength,a=0,u=t.lengthSelect.map(g=>(a|=+(g==i),{value:g,label:g.toString()}));return a||u.push({value:i,label:i.toString()}),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}},SelectorPosition:4,value:s.paging.rowLength,options:u.toASC("value"),onUpdateValidValue:g=>{d(p=>m(r({},p),{paging:{rowLength:Number(g),currentPageIndex:1,pageLength:Math.ceil(e.rows.filtered/Number(g))}}))}})})}},ge=t=>l(ue,m(r({},t),{type:"data",JSXChildren:I.DataLeveler})),k=ge;k.__memoryID=I.__memoryID,k.getRowData=de.getRowData,k.Info=V.Info,k.Paging=V.Paging,k.RowLength=V.RowLength,k.SearchInput=V.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.
|
|
3
|
+
"version": "0.2.143",
|
|
4
4
|
"description": "UI Component for React,NextJS,esbuild",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "run-p clean build:*",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@fortawesome/free-solid-svg-icons": "^6.6.0",
|
|
91
91
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
92
92
|
"dotenv": "^16.4.6",
|
|
93
|
-
"jmini": "^0.0.
|
|
93
|
+
"jmini": "^0.0.34",
|
|
94
94
|
"react": "^18.3.1"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|