amotify 0.2.83 → 0.2.85
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.
- package/demo/esbuild/app.tsx +100 -6
- package/demo/esbuild/public/index.js +40 -40
- package/dist/fn/Input/Autocomplete.d.ts +1 -0
- package/dist/fn/Input/Autocomplete.js +1 -1
- package/dist/fn/Input/Label.js +1 -1
- package/dist/fn/Input/List.d.ts +3 -0
- package/dist/fn/Input/List.js +1 -1
- package/dist/fn/Input/Select.d.ts +1 -0
- package/dist/fn/Input/Select.js +1 -1
- package/dist/fn/Input/Time/Picker.js +1 -1
- package/dist/fn/Sheet.js +1 -1
- package/dist/fn/Table/Data.js +1 -1
- package/package.json +1 -1
|
@@ -29,6 +29,7 @@ declare namespace Autocomplete {
|
|
|
29
29
|
(p: SelectorComponentProps<T>): JSX.Element;
|
|
30
30
|
};
|
|
31
31
|
SelectorStyles?: StyleTags.PropsNFreeCSS;
|
|
32
|
+
SelectorPosition?: 1 | 2 | 3 | 4;
|
|
32
33
|
};
|
|
33
34
|
type Value<T = any> = T extends infer V ? V : string | number | boolean | KeyValueDict | void | null;
|
|
34
35
|
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 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
|
+
import{b as c,c as O,d as Q,e as Y}from"../../chunk-C5N2D3ZX.js";import{Fragment as X,jsx as l,jsxs as E}from"react/jsx-runtime";import{useState as D,useEffect as R,useRef as le}from"react";import u,{UUID as L}from"jmini";import{ExtractStyles as ae}from"../../@utils";import{Box as x,Span as ne,FAI as U,Column as re}from"../../atoms";import{Text as P,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 K,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:a,options:S,min:s,max:f}=n;s=s||0,f=f||65535;let r=[],o=t.filter(p=>p!==null).length;return a&&(o||r.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),o<s&&r.push({type:"invalid",label:s+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),o>f&&r.push({type:"invalid",label:f+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!r.filter(({type:p})=>p=="invalid").length,notice:r}}const A={InitOptions:e=>{let t=[];return e.forEach(n=>{let{type:a,label:S,value:s,searchValue:f}=n,r=f||(u.is.string(S)?S:"")||(u.is.string(s)?s:"");t.push(O(c({},n),{searchValue:r,type:a||"selector",value:s}))}),t},FilterSelectableOptions:(e,t)=>{let n=e.val_options;if(t||(n=e.val_options.filter(a=>a.type!="label")),e.val_keyword){let a=e.val_keyword.toLower().replace(/ /g,"");n=n.filter(S=>(S.searchValue||"").toLower().replace(/ /g,"").includes(a))}return n}},F={Shallow:e=>{let{rootStates:t,val_status:n}=e,a=ae(t);return l(x,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:l(P.Description,O(c({className:t.className},a),{position:"absolute",width:1,freeCSS:O(c({},a.freeCSS),{color:"orange"}),"data-id":"shallow_"+n.componentID,children:l(x,{"data-input-value-shallow":n.componentID,children:"A"})}))})},Button:e=>{let{rootStates:t,val_keyword:n,set_keyword:a,val_optionFocused:S,set_optionFocused:s,val_options:f,set_options:r,val_optionsDict:o,set_optionsDict:p,val_preventOpenSelectorOnFocus:i,set_preventOpenSelectorOnFocus:d,val_selectorOpen:v,set_selectorOpen:m,val_status:h,set_status:w,val_validate:b,set_validate:I}=e,G=t,{tone:_,required:V,form:C,className:k,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:be,wrapStyles:Oe,emptySelect:Ie,SearchInput:De,SearchInputPlaceholder:Ce,SelectedComponent:we,SelectorComponent:Te,SelectorStyles:Ve,SelectorPosition:ke,DynamicOptionsOnSearch:xe}=G,g=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","SelectorPosition","DynamicOptionsOnSearch"]);return R(()=>{var T,M;if(t.disabled||!v)return;let y=A.FilterSelectableOptions(e);s((M=(T=y[0])==null?void 0:T.value)!=null?M:null)},[n]),R(()=>{h.eventType!="init"&&(t.max==h.dataValue.length?(m(!1),d(!0),setTimeout(()=>{let y=u('[data-input-origin="'+t.componentID+'"]');y&&y.focus()},10)):u("#SearchInput_"+t.componentID).focus())},[h.dataValue]),R(()=>{let y="autocomplete-click-"+t.componentID;if(v){if(!u('[data-input-origin="'+t.componentID+'"]'))return;u("#SearchInput_"+t.componentID).focus(),u(document).addEvent({eventID:y,eventType:"mousedown",callback:M=>{let j=u(M.target),oe=!!u(j).parent("."+W("Core")).length;u(j).parent("."+W("Selector")).length||oe||m(!1)}})}else u(document).removeEvent([y]),a("")},[v]),E(X,{children:[l(x,O(c({tabIndex:0},g),{"data-disabled":t.disabled,"data-show-validation":K.isShowValidation(b,h,!!z),"data-component-id":h.componentID,"data-input-origin":h.componentID,"data-focus":!!v,className:[k,W("Core")].join(" "),onFocus:y=>{if(g!=null&&g.onFocus&&(g==null||g.onFocus(y)),!t.disabled){if(i)return d(!1);m(!0),y.preventDefault()}},onClick:y=>{g!=null&&g.onClick&&(g==null||g.onClick(y)),!t.disabled&&m(!0)},onKeyDown:y=>{let{key:T}=y;B&&K.SubmitForm(y,C),!v&&(T==" "||T=="ArrowDown"||T=="ArrowUp"||T=="Enter")&&m(!0)},children:E(q.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(F.Selected,c({},e)),l(ne,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),l(F.SearchInput,c({},e))]})})),v&&l(F.Selector,c({},e))]})},SearchInput:e=>{let{rootStates:t}=e;return t.disabled||!e.val_selectorOpen?null:l(x,{id:"SearchInput_"+t.componentID,placeholder:t.SearchInputPlaceholder||"\u691C\u7D22...",opacity:e.val_selectorOpen?"max":"trans",transition:"middle",flexSizing:0,htmlTag:"input",border:"unset",backgroundColor:"trans",value:e.val_keyword,freeCSS:{outline:"none"},onKeyDown:n=>{let{key:a,metaKey:S,ctrlKey:s}=n,f=S||s;a=="Escape"?(e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0),setTimeout(()=>{let r=u('[data-input-origin="'+t.componentID+'"]');r&&r.focus()},10)):a=="Tab"?e.set_selectorOpen(!1):a==" "?u.scope(()=>{e.val_selectorOpen||e.val_keyword||(n.preventDefault(),e.set_selectorOpen(!0))}):a=="Backspace"?u.scope(()=>{if(e.val_keyword)return;let r=[...e.val_status.dataValue];r.pop(),e.set_status(o=>O(c({},o),{dataValue:r,eventType:"update",eventID:L()}))}):a=="Enter"&&u.scope(()=>{if(!e.val_selectorOpen)return e.set_selectorOpen(!0);let r=e.val_options.find(p=>p.value==e.val_optionFocused);if(!r)return;let{value:o}=r;e.set_status(p=>{let i=[...p.dataValue];return u.scope(()=>{if(o===null)return i=[];p.dataValue.includes(o)?i=i.filter(v=>v!==o):t.multiSelect?i.push(o):i=[o]}),O(c({},p),{dataValue:i,eventType:"update",eventID:L()})}),e.set_keyword(""),e.set_preventDynamicSearchOnKeywordChange(!0)}),u.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(a))return;if(n.preventDefault(),!e.val_selectorOpen)return e.set_selectorOpen(!0);let r=a=="ArrowDown"?1:-1,o=A.FilterSelectableOptions(e),p=o.length-1,i=null;u.scope(()=>{var v,m,h,w,b,I,_,V,C,k;let d=o.findIndex(N=>N.value==e.val_optionFocused);if(d==-1&&(d=0),r==1){if(i=(m=(v=o[0])==null?void 0:v.value)!=null?m:null,f){i=(h=o[p].value)!=null?h:null;return}if(d==-1||d==p)return;i=(b=(w=o[d+1])==null?void 0:w.value)!=null?b:null}else{if(i=(I=o[p].value)!=null?I:null,f){i=(V=(_=o[0])==null?void 0:_.value)!=null?V:null;return}if(d==-1||d==0)return;i=(k=(C=o[d-1])==null?void 0:C.value)!=null?k:null}}),e.set_optionFocused(i)}),t.enableFormSubmit&&K.SubmitForm(n,e.rootStates.form)},onChange:n=>{let S=n.target.value;e.set_keyword(S)}},"searchInput")},Selector:e=>{var p;let[t,n]=D("idle"),[a,S]=D("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");S("fetch");let i="autocomplete-search-"+e.rootStates.componentID;u.interval.cycle(i,300,()=>Y(void 0,null,function*(){let d=yield e.rootStates.DynamicOptionsOnSearch(e.val_keyword);S("idle");let v=A.InitOptions(d||[]);e.set_options(v)}))},[e.val_keyword]);let s=[],f=A.FilterSelectableOptions(e,!0),r=A.FilterSelectableOptions(e);f.forEach((i,d)=>{let{type:v,value:m}=i,h=e.val_optionFocused==m,w=e.val_status.dataValue.includes(m),b=e.rootStates.SelectorComponent;s.push(l(b,{option:i,isFocused:h,isSelected:w,addCallback:()=>{e.set_status(I=>{let _=[...I.dataValue];return u.scope(()=>{if(m===null)return _=[];I.dataValue.includes(m)?_=_.filter(C=>C!==m):e.rootStates.multiSelect?_.push(m):_=[m]}),O(c({},I),{dataValue:_,eventType:"update",eventID:L()})})}},u.Stringify(m)||L()))}),r.length||(s=[l(P.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]),a=="fetch"&&(s=[E(q.Left,{padding:1,fontColor:"3.blur",children:[l(ie.Theme.R,{showInitial:!0}),l(P.Supplement,{children:"Loading..."})]},"loader")]);let o={position:"absolute",minWidth:1,freeCSS:{zIndex:1e3}};switch(e.rootStates.SelectorPosition){case 1:o.bottom="100%",o.left=0,o.paddingBottom="1/3";break;case 2:o.bottom="100%",o.right=0,o.paddingBottom="1/3";break;case 3:o.top="100%",o.left=0,o.paddingTop="1/3";break;case 4:o.top="100%",o.right=0,o.paddingTop="1/3";break;default:break}return l(x,O(c({},o),{children:l(se.Body,O(c({className:W("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,boxShadow:"1.normal",overflow:"auto"},e.rootStates.SelectorStyles),{freeCSS:c({maxHeight:12*24},(p=e.rootStates.SelectorStyles)==null?void 0:p.freeCSS),children:l(re,{gap:"1/12",padding:[1,0],children:s})}))}))},Selected:e=>{let{rootStates:t,val_status:n,set_status:a,val_optionsDict:S}=e,s=[];return n.dataValue.forEach(f=>{let r=S[u.Stringify(f)];if(!r)return;let o=t.SelectedComponent,p=r.label;r.value===null&&(p=""),s.push(l(x,{className:W("SelectedCell"),children:l(o,{value:r.value,label:p,removeCallback:i=>{if(i.stopPropagation(),i.preventDefault(),t.disabled)return;let d=[...n.dataValue];d=d.filter(v=>v!==f),a(v=>O(c({},v),{dataValue:d,eventType:"update",eventID:L()}))}})},u.Stringify(r.value)))}),l(X,{children:s})},Core:e=>{var z;let{value:t}=e,[n,a]=D(!1),[S,s]=D(!1),[f,r]=D(!1),[o,p]=D(""),[i,d]=D(e.options),[v,m]=D((z=e.value[0])!=null?z:null),[h,w]=D({}),[b,I]=D(K.DefaultStatus(e.componentID,t)),[_,V]=D({ok:!1,notice:[]}),C=le(!1);R(()=>{C.current?d(e.options):C.current=!0},[e.options]),R(()=>{if(!i.length)return;let $=[...i],J=c({},h);$.forEach(H=>{H.type!="label"&&(J[u.Stringify(H.value)]=H)}),w(J)},[i]);let k={rootStates:e,val_options:i,set_options:d,val_optionFocused:v,set_optionFocused:m,val_optionsDict:h,set_optionsDict:w,val_preventDynamicSearchOnKeywordChange:S,set_preventDynamicSearchOnKeywordChange:s,val_preventOpenSelectorOnFocus:n,set_preventOpenSelectorOnFocus:a,val_selectorOpen:f,set_selectorOpen:r,val_keyword:o,set_keyword:p,val_status:b,set_status:I,val_validate:_,set_validate:V},N=!!e.multiSelect;K.CommonEffects({type:N?"autocomplete.multi":"autocomplete.single",states:e,val_status:b,set_status:I,val_validate:_,set_validate:V,SystemValidation:Se});let B=b.dataValue.length&&b.dataValue[0]!==null;return B=B||f,E(ce,{val_status:b,set_status:I,val_validate:_,states:e,children:[l(de,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:B}),l(F.Shallow,c({},k)),l(F.Button,c({},k))]})}},te=e=>{var n;let t=c({},e);return t=O(c({value:[],min:0,max:65535,multiSelect:!0,SearchInput:!0,emptySelect:!0,SelectorComponent:({option:a,isSelected:S,isFocused:s,addCallback:f})=>a.type=="selector"?l(Z.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1.5],isActive:s,isActiveStyles:{backgroundColor:"cloud"},onClick:r=>{f()},children:E(q.Left,{gap:"1/2",children:[S&&l(U.Check,{fontColor:"theme"}),l(P.Supplement,{transition:"short",children:a.label})]})}):l(X,{children:a.label}),SelectedComponent:({value:a,label:S,removeCallback:s})=>E(q.Left,{ssCardBox:"cloud",borderRadius:"2.tone.secondary",fontSize:"1.mini",padding:"1/2",gap:0,children:[l(x,{padding:[0,"1/4"],children:S}),l(Z.Sub,{flexSizing:"none",color:"cloud",fontColor:"white",backgroundColor:"layer.5",isRounded:!0,padding:"1/4",onClick:s,freeCSS:{lineHeight:1,aspectRatio:"1/1"},children:l(U.Times,{ssSphere:1})})]}),SelectorPosition:3},t),{freeCSS:c({cursor:"pointer"},t.freeCSS)}),t.multiSelect||(t.min=0,t.max=1),t.options=t.options||[],t.emptySelect&&(t.options=[{value:null,label:l(P.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=u.flatArray((n=t.value)!=null?n:null),t.options=A.InitOptions(t.options),u.is.nullish(t.rightIcon)&&(t.rightIcon=l(ee,{ssSphere:2,children:l(U.Search,{})}),t.disabled&&(t.rightIcon=l(ee,{ssSphere:2,fontColor:"5.translucent",children:l(U.Ban,{})}))),t.rightIcon&&(t=c({paddingRight:3},t)),t.leftIcon&&(t=c({paddingLeft:3},t)),l(ue,{componentID:t.componentID,children:F.Core,states:pe(t)})};export{te as Autocomplete,te as default};
|
package/dist/fn/Input/Label.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as n,c as
|
|
1
|
+
import{b as n,c as p}from"../../chunk-C5N2D3ZX.js";import{jsx as m,jsxs as x}from"react/jsx-runtime";import{useState as b,useEffect as c}from"react";import a from"jmini";import{Box as d,Span as g}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+'"]'),e=a('[data-input-label="'+t.componentID+'"]'),u=a('[data-input-value-shallow="'+t.componentID+'"]');if(!f[0]||!e[0]||!u[0])return;let i=f.position(),o=u.position();if(t.isActive){let l=o.left-i.left;s({opacity:"max",backgroundColor:"layer.1",freeCSS:{fontSize:"12px",lineHeight:1,transform:`translate(${l}px,-6px)`}})}else{let l=o.left-i.left,S=o.top-i.top;s({fontSize:t.fontSize||"inherit",opacity:"middle",backgroundColor:"trans",freeCSS:{lineHeight:"inherit",transform:`translate(${l}px,${S}px)`}})}e.getAttribute("data-label-init")=="true"&&e.setAttribute("data-label-init","false").await(10).css({transition:".25s"})},[t.isActive]),m(d,p(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&&m(g,{fontColor:"nega",children:" * "})]})}))};export{D as InputLabel};
|
package/dist/fn/Input/List.d.ts
CHANGED
|
@@ -6,11 +6,13 @@ declare namespace List {
|
|
|
6
6
|
type Type = 'radio' | 'checkbox';
|
|
7
7
|
type IconType = Type;
|
|
8
8
|
type Tone = 'normal' | 'border' | 'cloud' | 'plain';
|
|
9
|
+
type Sizes = 'small' | 'regular' | 'large';
|
|
9
10
|
type Input<T = Value> = InputTypes.CoreInput<T> & {
|
|
10
11
|
type?: Type;
|
|
11
12
|
tone?: Tone;
|
|
12
13
|
icon?: boolean;
|
|
13
14
|
iconType?: IconType;
|
|
15
|
+
iconSize?: Sizes;
|
|
14
16
|
isChecker?: boolean;
|
|
15
17
|
CustomIcon?: React.FC<CustomIconInput>;
|
|
16
18
|
tabIndex?: number;
|
|
@@ -41,6 +43,7 @@ declare namespace List {
|
|
|
41
43
|
} & StyleTags.States;
|
|
42
44
|
type CustomIconInput = {
|
|
43
45
|
isChecked: boolean;
|
|
46
|
+
iconSize: Sizes;
|
|
44
47
|
toggle: () => void;
|
|
45
48
|
};
|
|
46
49
|
type CoreStates = {
|
package/dist/fn/Input/List.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as l,c as
|
|
1
|
+
import{b as l,c as m,d as w}from"../../chunk-C5N2D3ZX.js";import{jsx as n,jsxs as Se}from"react/jsx-runtime";import I,{UUID as M}from"jmini";import{useState as te}from"react";import{$$fromRoot as ne,GenerateHTMLProps as ie}from"../../@utils";import{Box as b,Flex as se,FAI as re,Span as ce}from"../../atoms";import{Button as de}from"../Button";import{OptionalInputWrapper as ue,BoxWrapper as me,CoreEffects as A}from"./core";import{InputListClasses as x}from"../../@styles/componentClasses";function Ce(t){let{value:o,states:a}=t,{type:e,required:d,min:i,max:C}=a;i=i||0,C=C||65535;let s=[],f=o.length;return d&&(f||e=="radio"&&s.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),f<i&&s.push({type:"invalid",label:i+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),f>C&&s.push({type:"invalid",label:C+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!s.filter(({type:v})=>v=="invalid").length,notice:s}}const S={OptionalListWrapper:t=>{let{value:o,options:a=[]}=t,e=I.is.exist(o)?I.flatArray(o):[],d=[];return e.forEach(i=>{a.findIndex(s=>I.is.equal(s.value,i))!=-1&&d.push(i)}),n(S.Core,m(l({},t),{value:d,options:a}))},Core:t=>{let F=t,{type:o,tone:a,required:e,componentID:d="",form:i,override:C,icon:s,iconType:f,iconSize:v,CustomIcon:V,enableFormSubmit:O,checkValidationAtFirst:$,onValidate:J,onUpdateValue:W,onUpdateValidValue:L,value:D,options:X,className:U,cellStyles:g,cellClassName:K,cellCheckedStyles:q,cellCheckedClassName:H,min:j,max:G,hideInput:Q,freeCSS:_,wrapStyles:u}=F,N=w(F,["type","tone","required","componentID","form","override","icon","iconType","iconSize","CustomIcon","enableFormSubmit","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","value","options","className","cellStyles","cellClassName","cellCheckedStyles","cellCheckedClassName","min","max","hideInput","freeCSS","wrapStyles"]),[h,k]=te(A.DefaultStatus(d,D)),[p,z]=te({ok:!1,notice:[]});return A.CommonEffects({type:"list."+o,states:t,val_status:h,set_status:k,val_validate:p,set_validate:z,SystemValidation:Ce}),n(me,{val_status:h,set_status:k,val_validate:p,states:t,children:n(S.List,{rootStates:t,val_status:h,set_status:k})})},List:t=>{let{rootStates:o,val_status:a,set_status:e}=t,{componentID:d,type:i,tone:C,icon:s,iconSize:f,isChecker:v,options:V,name:O,form:$,tabIndex:J,hideInput:W,disabled:L,className:D,cellStyles:X,cellClassName:U="",cellCheckedStyles:g,cellCheckedClassName:K="",enableFormSubmit:q}=o,{dataValue:H}=a,j=o.CustomIcon,G=V.map((Q,_)=>{let ee=Q,{value:u,label:N,disabled:h,className:k="",checkedStyles:p,checkedClassName:z="",freeCSS:F}=ee,oe=w(ee,["value","label","disabled","className","checkedStyles","checkedClassName","freeCSS"]),Y=M(),R=H.findIndex(r=>r===u)!=-1,y=l(l({},X),oe),B=[x("Label"),U,k];R&&(y=m(l(l(l({},y),g),p),{freeCSS:l(l(l({},y==null?void 0:y.freeCSS),g==null?void 0:g.freeCSS),p==null?void 0:p.freeCSS)}),B=[...B,K,z]);const Z=()=>{if(L||h)return;let r=[];if(i=="radio")r=[u];else if(i=="checkbox"||v)if(!R)r=[...a.dataValue,u];else{let c=[...a.dataValue];c.splice(a.dataValue.findIndex(E=>E==u),1),r=c}e(c=>m(l({},c),{dataValue:r,eventType:"update",eventID:M()}))};return[n(b,{htmlTag:"input",type:i=="radio"?"radio":"checkbox",className:x("Input"),name:"RadioCheckbox-"+O,"data-list-index":d+"-"+_,id:Y,value:String(u),disabled:L||h,checked:R,onFocus:r=>{h||i=="radio"&&(a.dataValue.length||e(c=>m(l({},c),{dataValue:[u],eventType:"update",eventID:M()})))},onChange:()=>{Z()},onKeyDown:r=>{let{key:c,shiftKey:E}=r;if((i=="checkbox"||t.rootStates.isChecker)&&c!="Tab"){if(c.match(/Arrow/)){r.preventDefault();let ae=["ArrowLeft","ArrowUp"].includes(c)?-1:1,T=_+ae;T<0?T=V.length-1:T>=V.length&&(T=0),ne(`input[data-list-index="${d}-${T}"]`).focus()}}q&&A.SubmitForm(r,$)},tabIndex:J},"List-"+I.Stringify(u)),Se(b,m(l({htmlTag:"label","data-disabled":L||h,htmlFor:Y,className:B.join(" "),tabIndex:-1,display:"flex",verticalAlign:"center",flexWrap:!1},y),{children:[s&&n(j,{isChecked:R,iconSize:f,toggle:()=>{Z()}}),n(ce,{position:"relative",freeCSS:{zIndex:2},children:I.is.string(N)?n(b,{children:N}):N})]}),"ListTrigger-"+I.Stringify(u))]});return n(se,{flexSizing:"auto",style:o.style,freeCSS:l({},o.freeCSS),className:[D,x("CellBase"),x("HideInput_"+W),x("IconIndicator_"+!!s),x("Tone_"+C)].join(" "),children:G})},_Icon:t=>{let o=1.5;return t.iconSize=="small"?o=1.2:t.iconSize=="large"&&(o=2),n(de.Normal,{ssPushable:!0,color:"cloud",tabIndex:-1,ssEffectsOnActive:"ripple.cloud",ssSphere:2,freeCSS:{transform:`scale(${o})`},onClick:a=>{a.preventDefault(),a.stopPropagation(),t.toggle()},children:t.children})},RadioIcon:t=>n(S._Icon,m(l({type:"radio"},t),{children:n(b,{flexCenter:!0,isRounded:!0,borderColor:t.isChecked?"theme":"3.thick",position:"relative",transition:"middle",border:"3.thick",freeCSS:{width:"50%",height:"50%"},children:n(b,{position:"absolute",transition:"middle",isRounded:!0,backgroundColor:t.isChecked?"theme":"trans",opacity:t.isChecked?"max":"trans",freeCSS:{width:"60%",height:"60%",transform:t.isChecked?"scale(1)":"scale(.6)"}})})})),CheckboxIcon:t=>n(S._Icon,m(l({type:"checkbox"},t),{children:n(b,{flexCenter:!0,border:"3.thick",borderColor:t.isChecked?"theme":"3.thick",backgroundColor:t.isChecked?"theme":"trans",position:"relative",transition:"middle",fontColor:"white",freeCSS:{borderRadius:"25%",padding:"4%",width:"50%",height:"50%"},children:n(re.Check,{transition:"middle",opacity:t.isChecked?"max":"trans",freeCSS:{zIndex:8,width:"100%",height:"100%"}})})}))},P=t=>{t=t||"checkbox";const o=e=>(e=m(l({gap:"1/2",icon:!0,iconSize:"regular",iconType:t=="radio"?"radio":"checkbox"},e),{type:t,cellStyles:l({gap:"1/6",position:"relative",borderRadius:"2.tone.secondary",transition:"middle"},e.cellStyles)}),e.CustomIcon||(e.iconType=="radio"?e.CustomIcon=S.RadioIcon:e.iconType=="checkbox"&&(e.CustomIcon=S.CheckboxIcon)),e.iconSize=="small"?e.cellStyles.gap=0:e.iconSize=="large"&&(e.cellStyles.gap="1/2"),e.tone=="normal"?(e.cellStyles=l({padding:["1/4",1],border:"1.thin",isRounded:!0,backgroundColor:"layer.1"},e.cellStyles),e.cellCheckedStyles=l({borderColor:"theme",fontColor:"theme",boxShadow:"1.normal"},e.cellCheckedStyles)):e.tone=="border"?(e.cellStyles=l({paddingRight:1,border:"1.thin",isRounded:!0,backgroundColor:"layer.1"},e.cellStyles),e.cellCheckedStyles=l({borderColor:"theme",fontColor:"theme"},e.cellCheckedStyles)):e.tone=="cloud"&&(e.cellStyles=l({paddingRight:1,isRounded:!0,border:"1.thin",backgroundColor:"layer.2"},e.cellStyles),e.cellCheckedStyles=l({backgroundColor:"cloud",fontColor:"theme"},e.cellCheckedStyles)),e=ie(e),n(ue,{componentID:e.componentID,children:S.OptionalListWrapper,states:e})),a=o;return a.Normal=e=>n(o,l({type:t,tone:"normal",icon:!1},e)),a.Border=e=>n(o,l({type:t,tone:"border"},e)),a.Cloud=e=>n(o,l({type:t,tone:"cloud"},e)),a.Vivid=e=>n(o,l({type:t,tone:"normal",icon:!1,cellCheckedStyles:{backgroundColor:"theme",fontColor:"white"}},e)),a.Simple=e=>n(o,l({type:t,tone:"plain",icon:!1,cellCheckedStyles:{fontColor:"theme"}},e)),a},he=P("checkbox"),pe=P("radio"),le=P();export{he as Checkbox,le as List,pe as Radio,le as default};
|
|
@@ -21,6 +21,7 @@ declare namespace Select {
|
|
|
21
21
|
SelectedCellStyles?: StyleTags.PropsNFreeCSS;
|
|
22
22
|
SelectorCellStyles?: StyleTags.PropsNFreeCSS;
|
|
23
23
|
SelectorStyles?: StyleTags.PropsNFreeCSS;
|
|
24
|
+
SelectorPosition?: 1 | 2 | 3 | 4;
|
|
24
25
|
};
|
|
25
26
|
type Value<T = any> = T extends infer V ? V : string | number | boolean | KeyValueDict | void | null;
|
|
26
27
|
type Option<T = Value> = {
|
package/dist/fn/Input/Select.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as n,c as d,d as j}from"../../chunk-C5N2D3ZX.js";import{Fragment as ee,jsx as l,jsxs as E}from"react/jsx-runtime";import f,{UUID as R}from"jmini";import{useState as x,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 k,DefaultBoxishStyles as de}from"./core";import{InputAutocompleteClasses as w}from"../../@styles/componentClasses";import{InputLabel as fe}from"./Label";import{RightIcon as me}from".";function ve(e){let{value:t,states:a}=e,{required:r,options:o}=a,p=[];return r&&t===null&&p.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!p.filter(({type:m})=>m=="invalid").length,notice:p}}const P={FilterSelectableOptions:(e,t)=>{let a=e.rootStates.options;return t||(a=a.filter(r=>r.type!="label")),a}},T={Shallow:e=>{let{rootStates:t,val_status:a}=e,r=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,d(n({className:t.className},r),{position:"absolute",width:1,freeCSS:d(n({},r.freeCSS),{color:"orange"}),children:l(h,{"data-input-value-shallow":a.componentID,children:"A"})}))})},Button:e=>{let{rootStates:t,val_preventOpenSelectorOnFocus:a,set_preventOpenSelectorOnFocus:r,val_optionFocused:o,set_optionFocused:p,val_validate:m,set_validate:A,val_status:v,set_status:y,val_selectorOpen:c,set_selectorOpen:u}=e,L=t,{tone:D,required:_,form:te,className:le,label:ye,isLabelActive:be,placeholder:Ie,enableFormSubmit:ae,emptySelect:ge,checkValidationAtFirst:oe,onValidate:he,onUpdateValue:Ce,onUpdateValidValue:Te,value:_e="",options:xe,leftIndicator:De,rightIndicator:Oe,leftIcon:Ve,rightIcon:Re,componentID:Fe,status_id:ke,wrapStyles:we,SelectedCellStyles:Ee,SelectorCellStyles:Ae,SelectorStyles:Be,SelectorPosition:We}=L,s=j(L,["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","SelectorPosition"]);return G(()=>{if(t.disabled)return;let i="select-click-"+t.componentID;if(c){if(!f('[data-input-origin="'+t.componentID+'"]'))return;f(document).addEvent({eventID:i,eventType:"click",callback:B=>{let O=f(B.target),V=!!f(O).parent("."+w("Core")).length;f(O).parent("."+w("Selector")).length||V||u(!1)}})}else f(document).removeEvent([i])},[c]),G(()=>{if(v.eventType=="init"||!c)return;let i=f('[data-input-origin="'+t.componentID+'"]');i&&i.focus()},[v.dataValue]),E(ee,{children:[l(h,d(n({tabIndex:0},s),{"data-disabled":t.disabled,"data-show-validation":k.isShowValidation(m,v,!!oe),"data-component-id":v.componentID,"data-input-origin":v.componentID,className:[le,w("Core")].join(" "),onFocus:i=>{if(s!=null&&s.onFocus&&(s==null||s.onFocus(i)),!t.disabled){if(a)return r(!1);u(!0)}},onClick:i=>{s!=null&&s.onClick&&(s==null||s.onClick(i)),!t.disabled&&u(!0)},onKeyDown:i=>{let{key:b,metaKey:B,ctrlKey:O}=i,V=B||O;if(s!=null&&s.onKeyDown&&(s==null||s.onKeyDown(i)),ae&&k.SubmitForm(i,te),!t.disabled){if(f.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(b))return;if(i.preventDefault(),!c)return u(!0);let I=b=="ArrowDown"?1:-1,S=P.FilterSelectableOptions(e),W=S.length-1,g=null;f.scope(()=>{var N,K,q,U,z,H,M,$,J,X;let C=S.findIndex(ne=>ne.value==o);if(I==1){if(g=(K=(N=S[0])==null?void 0:N.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=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}}),p(g)}),b=="Escape")u(!1);else if(b=="Tab")u(!1);else if(b=="Backspace")y(I=>d(n({},I),{dataValue:null,eventType:"update",eventID:R()}));else if(b==" ")i.preventDefault(),u(!0);else if(b=="Enter"){if(!c)return u(!0);i.preventDefault();let I=t.options.find(S=>S.value==o);if(!I)return;y(S=>d(n({},S),{dataValue:I.value,eventType:"update",eventID:R()})),u(!1)}}},children:E(Y.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(T.Placeholder,n({},e)),l(T.Selected,n({},e)),l(se,{width:0,overflow:"hidden",opacity:"trans",children:"A"})]})})),c&&l(T.Selector,n({},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 p;let t=[],a=P.FilterSelectableOptions(e,!0),r=P.FilterSelectableOptions(e);a.forEach((m,A)=>{let{type:v,value:y}=m,c=e.val_optionFocused==y,u=e.val_status.dataValue===y;if(v=="selector"){t.push(l(ue.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1],isActive:u||c,isActiveStyles:c?{backgroundColor:"cloud"}:{backgroundColor:"theme.opa.few",fontColor:"theme"},onClick:D=>{e.set_status(_=>d(n({},_),{dataValue:y,eventType:"update",eventID:R()})),e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0)},children:E(Y.Left,{gap:"1/2",children:[u&&l(Q.Check,{fontColor:"theme"}),l(F.Supplement,{transition:"short",children:m.label})]})},String(y)));return}t.push(l(h,{children:m.label},R()))}),r.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")]);let o={position:"absolute",minWidth:1,freeCSS:{zIndex:1e3}};switch(e.rootStates.SelectorPosition){case 1:o.bottom="100%",o.left=0,o.paddingBottom="1/3";break;case 2:o.bottom="100%",o.right=0,o.paddingBottom="1/3";break;case 3:o.top="100%",o.left=0,o.paddingTop="1/3";break;case 4:o.top="100%",o.right=0,o.paddingTop="1/3";break;default:break}return l(h,d(n({},o),{children:l(ce.Body,d(n({className:w("Selector"),ssCardBox:!0,borderRadius:"2.tone.secondary",boxShadow:"1.normal",overflow:"auto"},e.rootStates.SelectorStyles),{freeCSS:n({minWidth:12*6,maxHeight:12*24},(p=e.rootStates.SelectorStyles)==null?void 0:p.freeCSS),children:l(ie,{gap:"1/12",padding:[1,0],children:t})}))}))},Selected:e=>{let t=[];return e.val_status.dataValue!==null&&f.scope(()=>{let a=e.rootStates.options.find(r=>f.is.equal(r.value,e.val_status.dataValue));a&&t.push(l(h,d(n({},e.rootStates.SelectedCellStyles),{children:a.label}),String(a.value)))}),l(ee,{children:t})},Core:e=>{var _;let{value:t}=e,[a,r]=x(k.DefaultStatus(e.componentID,t)),[o,p]=x(!1),[m,A]=x(!1),[v,y]=x((_=e.value)!=null?_:null),[c,u]=x({ok:!1,notice:[]}),D={rootStates:e,val_preventOpenSelectorOnFocus:o,set_preventOpenSelectorOnFocus:p,val_optionFocused:v,set_optionFocused:y,val_selectorOpen:m,set_selectorOpen:A,val_status:a,set_status:r,val_validate:c,set_validate:u};return k.CommonEffects({type:"select",states:e,val_status:a,set_status:r,val_validate:c,set_validate:u,SystemValidation:ve}),E(Se,{val_status:a,set_status:r,val_validate:c,states:e,children:[l(fe,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:e.isLabelActive||a.dataValue!==null}),l(T.Shallow,n({},D)),l(T.Button,n({},D))]})}},Z=e=>{var a;let t=n({},e);return t=d(n({emptySelect:!0,SelectorPosition:3},t),{freeCSS:n({cursor:"pointer"},t.freeCSS)}),t.emptySelect&&(t.options=[{value:null,label:l(F.Supplement,{fontColor:"4.thin",children:"\u672A\u9078\u629E"})},...t.options]),t.value=(a=t.value)!=null?a:null,t.options.forEach((r,o)=>{let{type:p,value:m}=r;t.options[o]=d(n({},r),{value:m,type:p||"selector"})}),f.is.nullish(t.rightIcon)&&(t.rightIcon=l(me,{ssSphere:2,children:l(Q.AngleDown,{})})),l(pe,{componentID:t.componentID,children:T.Core,states:de(t)})};export{Z as Select,Z as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as p,c as x}from"../../../chunk-C5N2D3ZX.js";import{Fragment as q,jsx as a,jsxs as f}from"react/jsx-runtime";import{createElement as X}from"react";import D,{UUID as O,Time as S}from"jmini";import{useState as A,useEffect as F,useRef as H}from"react";import{Box as k,Flex as w,Grid as W,FAI as T,Column as V}from"../../../atoms";import{Row as N,Text as G}from"../../../mols";import{Button as C}from"../../Button";import $ from"../../Sheet";import M from"../Select";import{Radio as j}from"../List";import{RightIcon as B}from"..";import{InputTimeClasses as y}from"../../../@styles/componentClasses";let _=i=>{var t,r;let e=[],d=Number((t=i==null?void 0:i.min)!=null?t:1900),o=Number((r=i==null?void 0:i.max)!=null?r:S().addYear(10).year);for(let m=d;m<=o;m++)e.unshift({value:m,label:[m,...D.transformer.wareki(m).value].join(" -")});return e};const L=i=>{let{restrict:e,era:d="year",defaultValue:o=""}=i;i=p({},i),i.sheetID=i.sheetID||O();const t=H(!1);let[r,m]=A((()=>{var n,s;if(e=="clock"){let l=String(o).split(/[^\d]/);l[0]||(l=[0,0]);let u=Number(l[0]),c=Number(l[1]);return{modifiedType:"init",hour:u,minutes:c}}else if(e=="date"){let[l,u,c]=(n=String(o))==null?void 0:n.split(/\D/);return(D.is.nullish(l)||D.is.nullish(u)||D.is.nullish(c))&&([l,u,c]=S().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",year:Number(l),month:Number(u),date:Number(c)}}else if(e!="week"){if(e=="month"){let[l,u]=String(o).split(/\D/);return(D.is.nullish(l)||D.is.nullish(u))&&([l,u]=S().toFormat("%Y-%M").split("-")),{modifiedType:"init",year:Number(l),month:Number(u)}}else if(e=="year"){let[l]=String(o).split(/\D/);return D.is.nullish(l)&&([l]=S().toFormat("%Y").split("-")),{modifiedType:"init",year:Number(l)}}else if(e=="dateWareki"){let[l,u,c]=(s=String(o))==null?void 0:s.split(/\D/);return(D.is.nullish(l)||D.is.nullish(u)||D.is.nullish(c))&&([l,u,c]=S().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",era:d||"year",year:Number(l),month:Number(u),date:Number(c)}}}return{}})());F(()=>{if(t.current){if(r.modifiedType=="update"){let n="",s=d||"year";if(e=="clock"){let{hour:l,minutes:u}=r;n=[l.zeroEmbed(2),u.zeroEmbed(2)].join("/")}else if(e=="date"){let{year:l,month:u,date:c}=r;n=[l,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}else if(e!="week"){if(e=="month"){let{year:l,month:u}=r;n=[l,u.zeroEmbed(2)].join("/")}else if(e=="year"){let{year:l}=r;n=String(l)}else if(e=="dateWareki"){let{year:l,month:u,date:c,era:v}=r;s=v,n=[l,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}}i.onValueUpdate(n,s)}}else t.current=!0},[r]);let h=x(p({},i),{val_value:r,set_value:m});return a(k,{backgroundColor:"layer.1",borderRadius:"2.tone.secondary",boxShadow:"1.remark",children:a(k,{className:y(e.toCapital()+"Base"),children:e=="clock"?a(g.Clock.index,p({},h)):e=="date"?a(g.Date.index,p({},h)):e=="week"?"":e=="month"?a(g.Month.index,p({},h)):e=="year"?a(g.Year.index,p({},h)):e=="dates"||e=="months"?"":e=="dateWareki"?a(g.DateWareki.index,p({},h)):a(q,{})})})},g={Clock:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,[h,n]=A(r.hour>12?2:1),[s,l]=A(Number(localStorage.getItem("timePickerUnit")||5));F(()=>{localStorage.setItem("timePickerUnit",String(s))},[s]);let{hour:u,minutes:c}=r;return f(V,{padding:1,children:[f(w,{flexType:"row",flexWrap:!1,gap:1,className:y("Body"),children:[f(V,{className:y("DesignSide"),flexSizing:0,children:[a(k,{className:y("ClockUiBase"),padding:[1,"2/3"],flexCenter:!0,children:f(k,{className:y("ClockUi"),backgroundColor:"theme.opa.low",isRounded:!0,position:"relative",children:[a(k,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[y("Needle"),y("hour")].join(" "),freeCSS:{transform:`rotate(${u*30+c/2}deg)`}}),a(k,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[y("Needle"),y("minute")].join(" "),freeCSS:{transform:`rotate(${c*6}deg)`}})]})}),a(j,{icon:!0,value:[h],options:[{value:1,label:"AM"},{value:2,label:"PM"}],flexType:"col",gap:0,tabIndex:-1,onUpdateValidValue:({value:v})=>{let I=r.hour%12+(v==2?12:0);n(v),m({modifiedType:"update",hour:I,minutes:r.minutes})}}),a(k,{borderTop:!0,margin:[0,1]}),a(j,{icon:!0,value:[s],options:[{value:1,label:"/ 1\u5206"},{value:2,label:"/ 2\u5206"},{value:5,label:"/ 5\u5206"}],flexType:"col",gap:0,tabIndex:-1,onUpdateValidValue:({value:v})=>{l(v)}})]}),f(V,{children:[f(k,{flexCenter:!0,isSemiBoldFont:!0,fontSize:"3.paragraph",children:[r.hour.zeroEmbed(2)," : ",r.minutes.zeroEmbed(2)]}),f(w,{flexWrap:!1,ssCardBox:!0,flexChilds:"even",padding:["1/3",0],freeCSS:{minWidth:12*12},children:[a(V,{gap:0,overflow:"auto",padding:"2/3",borderRight:!0,freeCSS:{maxHeight:12*22},children:g.Clock.Hours({onClick:v=>{let R=v+(h==2?12:0);m({modifiedType:"update",hour:R,minutes:r.minutes})},min:e,max:d,ampm:h})}),a(V,{gap:0,overflow:"auto",padding:"2/3",freeCSS:{maxHeight:12*22},children:g.Clock.Minutes({onClick:v=>{m({modifiedType:"update",hour:r.hour,minutes:v})},min:e,max:d,unit:s})})]})]})]}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},Hours:i=>{let e=[];for(let d=0;d<12;d++){let o=i.ampm==2?d+12:d,t=!1;{let r=Number(String(o*100).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>r&&(t=!0),i.max){let m=Number(String(i.max).replace(/\D/ig,""));r>m&&(t=!0)}}e.push(a(C.Normal,{isLocked:t,borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(d)},children:o.zeroEmbed(2)},d))}return e},Minutes:i=>{let e=[];for(let d=0;d<60/i.unit;d++){let o=d*i.unit;e.push(a(C.Normal,{borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(o)},children:o.zeroEmbed(2)},o))}return e}},Date:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h,month:n,date:s}=r;return f(V,{padding:1,children:[f(N.Separate,{flexWrap:!0,children:[f(w,{verticalAlign:"bottom",horizontalAlign:"left",gap:"2/3",flexWrap:!1,children:[a(M,{override:"force",emptySelect:!1,value:h,options:_(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,SelectorStyles:{freeCSS:{minWidth:12*12}},onUpdateValidValue:({value:l})=>{m({modifiedType:"update",year:Number(l),month:n,date:s})},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})})}),a(M,{override:"force",emptySelect:!1,value:n,options:(()=>{let l=[];for(let u=1;u<=12;u++)l.push({value:u,label:String(u)+"\u6708"});return l})(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,SelectorStyles:{freeCSS:{minWidth:12*8}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),onUpdateValidValue:({value:l})=>{m({modifiedType:"update",year:h,month:Number(l),date:s})}})]}),a(g.Variables.ShiftButtons,{callback:l=>{let u=n+l,c=h;u<=0&&(c--,u=12),u>12&&(c++,u=1),m({modifiedType:"update",year:c,month:u,date:r.date})}})]}),a(k,{borderTop:!0}),a(k,{children:g.Date.MonthCalendar({min:e,max:d,year:r.year,month:r.month,current:[r.year,r.month,r.date],callback:l=>{let[u,c,v]=l;m({modifiedType:"update",year:u,month:c,date:v})}})}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},MonthCalendar:i=>{let{min:e,max:d,year:o,month:t,current:r,callback:m}=i,h=S(),n=S([o,t.zeroEmbed(2),"01"].join("/")),s=n.getLastDayOfTheMonth(),l=S(n).addMonth(-1).getLastDayOfTheMonth().date,u=[],c=[],v=[],R=[],I={padding:0,unitWidth:3,unitHeight:3,flexCenter:!0,borderRadius:"3.tone.tertiary"};for(var b=0;b<7;b++)u.push(a(k,x(p({className:[y("CalendarDay"),y("Legend")].join(" ")},I),{children:["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][b]}),b));for(var b=0;b<n.weekday;b++)c.unshift(X(k,x(p({className:[y("CalendarDay"),y("Dummy")].join(" "),fontColor:"4.thin"},I),{key:b}),l-b));for(var b=1;b<=s.date;b++){let E=b,Y=o==h.year&&t==h.month&&b==h.date,P=!1;{let z=Number(String([o,t.zeroEmbed(2),b.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>z&&(P=!0),i.max){let U=Number(String(i.max).replace(/\D/ig,""));z>U&&(P=!0)}}v.push(a(C.Clear,x(p({className:[y("CalendarDay"),y("isToday_"+Y)].join(" ")},I),{fontColor:"1.clear",padding:0,flexCenter:!0,isRounded:!0,ssEffectsOnActive:"shrink",onClick:()=>{m([o,t,E])},tabIndex:-1,isLocked:P,children:b}),E))}for(var b=1;b<7-s.weekday;b++)R.push(a(k,x(p({className:[y("CalendarDay"),y("Dummy")].join(" "),fontColor:"4.thin"},I),{children:b}),b));return f(W,{gridCols:7,gap:"1/6",children:[u,c,v,R]})}},Month:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h,month:n}=r;return f(V,{padding:1,children:[f(N.Separate,{gap:0,children:[a(N.Center,{verticalAlign:"bottom",gap:"2/3",children:a(M,{emptySelect:!1,value:h,options:_(),override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,SelectorStyles:{freeCSS:{minWidth:12*12}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),onUpdateValidValue:({value:s})=>{m({modifiedType:"update",year:Number(s),month:n})}})}),a(g.Variables.ShiftButtons,{callback:s=>{let l=Math.min(Math.max(h+s,1900),2100);m({modifiedType:"update",year:l,month:n})}})]}),a(k,{borderTop:!0}),g.Month.Months({min:e,max:d,year:r.year,callback:s=>{let[l,u]=s;m({modifiedType:"update",year:l,month:u})}}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},Months:i=>{let{year:e,callback:d}=i,o=S(),t=[];for(let r=1;r<=12;r++){let m=e==o.year&&r==o.month,h=!1;{let s=Number(String([e,r.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>s&&(h=!0),i.max){let l=Number(String(i.max).replace(/\D/ig,""));s>l&&(h=!0)}}let n=[y("Cell"),m?y("isThisMonth"):""].join(" ");t.push(f(C.Clear,{className:n,isLocked:h,fontColor:"2.normal",padding:["1/3",1],ssEffectsOnActive:"shrink",onClick:()=>{d([e,r])},children:[r," \u6708"]},e+"-"+r))}return a(W,{gridCols:4,gap:"2/3",children:t})}},Year:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h}=r;return f(V,{padding:1,children:[a(M,{emptySelect:!1,paddingRight:1,fontSize:"1.mini",value:h||S().year,override:"force",SelectorStyles:{freeCSS:{minWidth:12*12}},options:_({min:e,max:d}),onUpdateValidValue:({value:n})=>{m({modifiedType:"update",year:Number(n)})}}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o,onSubmit:()=>{m({modifiedType:"update",year:Number(h||S().year)})}})]})}},DateWareki:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{era:h,year:n,month:s,date:l}=r,u={val_value:r,set_value:m};return f(k,{children:[f(N.Left,{borderBottom:!0,gap:0,verticalAlign:"unset",children:[a(g.DateWareki.EraSelect,p({},u)),a(k,{borderRight:!0}),a(g.DateWareki.Calendar,p({},u))]}),a(N.Right,{padding:1,children:a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})})]})},EraSelect:i=>{let{val_value:e,set_value:d}=i,o={padding:["1/2",1.5],fontColor:"3.blur"},t={backgroundColor:"cloud",fontColor:"2.normal",isSemiBoldFont:!0};return f(V,{padding:1,gap:0,children:[a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="year",onClick:()=>{let r=S();d({modifiedType:"update",era:"year",year:r.year,month:r.month,date:r.date})},children:"\u897F\u66A6"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="reiwa",onClick:()=>{let r=S();d({modifiedType:"update",era:"reiwa",year:r.year,month:r.month,date:r.date})},children:"\u4EE4\u548C"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="heisei",onClick:()=>{d({modifiedType:"update",era:"heisei",year:2019,month:1,date:1})},children:"\u5E73\u6210"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="shouwa",onClick:()=>{d({modifiedType:"update",era:"shouwa",year:1989,month:1,date:1})},children:"\u662D\u548C"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="taisho",onClick:()=>{d({modifiedType:"update",era:"taisho",year:1926,month:1,date:1})},children:"\u5927\u6B63"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="meiji",onClick:()=>{d({modifiedType:"update",era:"meiji",year:1912,month:1,date:1})},children:"\u660E\u6CBB"}))]})},Calendar:i=>{let{val_value:e,set_value:d}=i,o=[];if(e.era=="year"){let t=S().year+10;for(let r=1900;r<t;r++)o.unshift({value:r,label:r+"\u5E74"})}else if(e.era=="reiwa"){let t=S().year-2018;for(let r=1;r<=t+10;r++)o.unshift({value:2019+r-1,label:"\u4EE4\u548C"+(r==1?"\u5143":r)+"\u5E74"})}else if(e.era=="heisei")for(let t=1;t<=31;t++)o.unshift({value:1989+t-1,label:"\u5E73\u6210"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="shouwa")for(let t=1;t<=64;t++)o.unshift({value:1926+t-1,label:"\u662D\u548C"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="taisho")for(let t=1;t<=15;t++)o.unshift({value:1912+t-1,label:"\u5927\u6B63"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="meiji")for(let t=1;t<=45;t++)o.unshift({value:1868+t-1,label:"\u660E\u6CBB"+(t==1?"\u5143":t)+"\u5E74"});return f(V,{padding:1,children:[f(N.Separate,{children:[a(M,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,fontSize:"1.mini",SelectorStyles:{freeCSS:{minWidth:12*12}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),options:o,value:e.year,onUpdateValidValue:({value:t})=>{d(r=>x(p({},r),{modifiedType:"update",year:Number(t)}))}}),f(N.Center,{gap:"1/3",children:[a(M,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,fontSize:"1.mini",SelectorStyles:{freeCSS:{minWidth:12*9}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),options:[{value:1,label:"1\u6708"},{value:2,label:"2\u6708"},{value:3,label:"3\u6708"},{value:4,label:"4\u6708"},{value:5,label:"5\u6708"},{value:6,label:"6\u6708"},{value:7,label:"7\u6708"},{value:8,label:"8\u6708"},{value:9,label:"9\u6708"},{value:10,label:"10\u6708"},{value:11,label:"11\u6708"},{value:12,label:"12\u6708"}],value:e.month,onUpdateValidValue:({value:t})=>{d({modifiedType:"update",era:e.era,year:e.year,month:Number(t),date:1})}}),a(C.Clear.S,{ssSphere:2.5,onClick:()=>{let t=e.month-1;d({modifiedType:"update",era:e.era,year:t==0?e.year-1:e.year,month:t==0?12:t,date:1})},children:a(T.ChevronLeft,{})}),a(C.Clear.S,{ssSphere:2.5,onClick:()=>{let t=e.month+1;d({modifiedType:"update",era:e.era,year:t==13?e.year+1:e.year,month:t==13?1:t,date:1})},children:a(T.ChevronRight,{})})]})]}),a(g.DateWareki.MonthCell,p({},i))]},e.era)},MonthCell:i=>{let{val_value:e,set_value:d}=i,o=S([e.year.zeroEmbed(4),e.month.zeroEmbed(2),e.date.zeroEmbed(2)].join("/"));if(!o.validate)return;let t=o.getFirstDayOfTheMonth().weekday,r=o.getLastDayOfTheMonth(),m=[];for(let n=0;n<7;n++)m.push(a(G.Supplement,{flexCenter:!0,fontColor:n==0?"googleRed":n==6?"googleBlue":"3.blur",children:D.transformer.weekday.shortJP(n)},"legend-"+n));for(let n=0;n<t;n++){let s=S(o).getFirstDayOfTheMonth().addDate(n-t);m.push(a(C.Sub,{color:"cloud",ssSquare:3,opacity:"middle",onClick:l=>{l.preventDefault(),l.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"lastMonth-"+n))}let h=S();for(let n=1;n<=r.date;n++){let s=S(o).setDate(n),l=h.diff(s).dates==0;m.push(a(C.Clear,{ssSquare:3,fontColor:"2.normal",className:[y("CalendarDay"),y("isToday_"+l)].join(" "),onClick:()=>{d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"currentMonth-"+n))}for(let n=0;n<7-r.weekday-1;n++){let s=S(o).addMonth(1).setDate(1).addDate(n);m.push(a(C.Sub,{color:"cloud",ssSquare:3,opacity:"middle",onClick:l=>{l.preventDefault(),l.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"nextMonth-"+n))}return a(W,{gridCols:7,gap:"1/4",children:m})}},Variables:{Footer:i=>f(w,{flexWrap:!1,gap:1,flexChilds:"even",freeCSS:{whiteSpace:"nowrap"},children:[f(C.Sub.S,{tabIndex:-1,isRounded:!0,onClick:()=>{i.onValueUpdate("")},flexSizing:"none",children:[a(T.Times,{})," \u524A\u9664"]}),a(C.Prime.S,{tabIndex:-1,isRounded:!0,flexSizing:"auto",freeCSS:{minWidth:12*6},onClick:()=>{i.onSubmit&&i.onSubmit(),$.close(i.sheetID)},children:"\u6C7A\u5B9A"})]}),ShiftButtons:i=>f(w,{gap:"1/3",flexWrap:!1,children:[a(C.Clear,x(p({className:y("LeftButton"),tabIndex:-1,right:0},g.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(-1)},children:a(T.ChevronLeft,{})})),a(C.Clear,x(p({className:y("RightButton"),tabIndex:-1,left:0},g.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(1)},children:a(T.ChevronRight,{})}))]}),ShiftButtonStyles:{position:"relative",flexCenter:!0,ssSphere:2.5}}};export{L as Picker,L as default};
|
|
1
|
+
import{b as p,c as x}from"../../../chunk-C5N2D3ZX.js";import{Fragment as q,jsx as a,jsxs as f}from"react/jsx-runtime";import{createElement as X}from"react";import D,{UUID as O,Time as S}from"jmini";import{useState as A,useEffect as F,useRef as H}from"react";import{Box as k,Flex as w,Grid as W,FAI as T,Column as V}from"../../../atoms";import{Row as N,Text as G}from"../../../mols";import{Button as C}from"../../Button";import $ from"../../Sheet";import M from"../Select";import{Radio as j}from"../List";import{RightIcon as B}from"..";import{InputTimeClasses as y}from"../../../@styles/componentClasses";let _=i=>{var t,r;let e=[],d=Number((t=i==null?void 0:i.min)!=null?t:1900),o=Number((r=i==null?void 0:i.max)!=null?r:S().addYear(10).year);for(let m=d;m<=o;m++)e.unshift({value:m,label:[m,...D.transformer.wareki(m).value].join(" -")});return e};const L=i=>{let{restrict:e,era:d="year",defaultValue:o=""}=i;i=p({},i),i.sheetID=i.sheetID||O();const t=H(!1);let[r,m]=A((()=>{var n,s;if(e=="clock"){let l=String(o).split(/[^\d]/);l[0]||(l=[0,0]);let u=Number(l[0]),c=Number(l[1]);return{modifiedType:"init",hour:u,minutes:c}}else if(e=="date"){let[l,u,c]=(n=String(o))==null?void 0:n.split(/\D/);return(D.is.nullish(l)||D.is.nullish(u)||D.is.nullish(c))&&([l,u,c]=S().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",year:Number(l),month:Number(u),date:Number(c)}}else if(e!="week"){if(e=="month"){let[l,u]=String(o).split(/\D/);return(D.is.nullish(l)||D.is.nullish(u))&&([l,u]=S().toFormat("%Y-%M").split("-")),{modifiedType:"init",year:Number(l),month:Number(u)}}else if(e=="year"){let[l]=String(o).split(/\D/);return D.is.nullish(l)&&([l]=S().toFormat("%Y").split("-")),{modifiedType:"init",year:Number(l)}}else if(e=="dateWareki"){let[l,u,c]=(s=String(o))==null?void 0:s.split(/\D/);return(D.is.nullish(l)||D.is.nullish(u)||D.is.nullish(c))&&([l,u,c]=S().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",era:d||"year",year:Number(l),month:Number(u),date:Number(c)}}}return{}})());F(()=>{if(t.current){if(r.modifiedType=="update"){let n="",s=d||"year";if(e=="clock"){let{hour:l,minutes:u}=r;n=[l.zeroEmbed(2),u.zeroEmbed(2)].join("/")}else if(e=="date"){let{year:l,month:u,date:c}=r;n=[l,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}else if(e!="week"){if(e=="month"){let{year:l,month:u}=r;n=[l,u.zeroEmbed(2)].join("/")}else if(e=="year"){let{year:l}=r;n=String(l)}else if(e=="dateWareki"){let{year:l,month:u,date:c,era:v}=r;s=v,n=[l,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}}i.onValueUpdate(n,s)}}else t.current=!0},[r]);let h=x(p({},i),{val_value:r,set_value:m});return a(k,{backgroundColor:"layer.1",borderRadius:"2.tone.secondary",boxShadow:"1.remark",children:a(k,{className:y(e.toCapital()+"Base"),children:e=="clock"?a(g.Clock.index,p({},h)):e=="date"?a(g.Date.index,p({},h)):e=="week"?"":e=="month"?a(g.Month.index,p({},h)):e=="year"?a(g.Year.index,p({},h)):e=="dates"||e=="months"?"":e=="dateWareki"?a(g.DateWareki.index,p({},h)):a(q,{})})})},g={Clock:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,[h,n]=A(r.hour>12?2:1),[s,l]=A(Number(localStorage.getItem("timePickerUnit")||5));F(()=>{localStorage.setItem("timePickerUnit",String(s))},[s]);let{hour:u,minutes:c}=r;return f(V,{padding:1,children:[f(w,{flexType:"row",flexWrap:!1,gap:1,className:y("Body"),children:[f(V,{className:y("DesignSide"),flexSizing:0,children:[a(k,{className:y("ClockUiBase"),padding:[1,"2/3"],flexCenter:!0,children:f(k,{className:y("ClockUi"),backgroundColor:"theme.opa.low",isRounded:!0,position:"relative",children:[a(k,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[y("Needle"),y("hour")].join(" "),freeCSS:{transform:`rotate(${u*30+c/2}deg)`}}),a(k,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[y("Needle"),y("minute")].join(" "),freeCSS:{transform:`rotate(${c*6}deg)`}})]})}),a(j,{icon:!0,value:[h],options:[{value:1,label:"AM"},{value:2,label:"PM"}],flexType:"col",gap:"1/2",tabIndex:-1,onUpdateValidValue:({value:v})=>{let I=r.hour%12+(v==2?12:0);n(v),m({modifiedType:"update",hour:I,minutes:r.minutes})}}),a(k,{borderTop:!0,margin:[0,1]}),a(j,{icon:!0,value:[s],options:[{value:1,label:"/ 1\u5206"},{value:2,label:"/ 2\u5206"},{value:5,label:"/ 5\u5206"}],flexType:"col",gap:"1/2",tabIndex:-1,onUpdateValidValue:({value:v})=>{l(v)}})]}),f(V,{children:[f(k,{flexCenter:!0,isSemiBoldFont:!0,fontSize:"3.paragraph",children:[r.hour.zeroEmbed(2)," : ",r.minutes.zeroEmbed(2)]}),f(w,{flexWrap:!1,ssCardBox:!0,flexChilds:"even",padding:["1/3",0],freeCSS:{minWidth:12*12},children:[a(V,{gap:0,overflow:"auto",padding:"2/3",borderRight:!0,freeCSS:{maxHeight:12*22},children:g.Clock.Hours({onClick:v=>{let R=v+(h==2?12:0);m({modifiedType:"update",hour:R,minutes:r.minutes})},min:e,max:d,ampm:h})}),a(V,{gap:0,overflow:"auto",padding:"2/3",freeCSS:{maxHeight:12*22},children:g.Clock.Minutes({onClick:v=>{m({modifiedType:"update",hour:r.hour,minutes:v})},min:e,max:d,unit:s})})]})]})]}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},Hours:i=>{let e=[];for(let d=0;d<12;d++){let o=i.ampm==2?d+12:d,t=!1;{let r=Number(String(o*100).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>r&&(t=!0),i.max){let m=Number(String(i.max).replace(/\D/ig,""));r>m&&(t=!0)}}e.push(a(C.Normal,{isLocked:t,borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(d)},children:o.zeroEmbed(2)},d))}return e},Minutes:i=>{let e=[];for(let d=0;d<60/i.unit;d++){let o=d*i.unit;e.push(a(C.Normal,{borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(o)},children:o.zeroEmbed(2)},o))}return e}},Date:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h,month:n,date:s}=r;return f(V,{padding:1,children:[f(N.Separate,{flexWrap:!0,children:[f(w,{verticalAlign:"bottom",horizontalAlign:"left",gap:"2/3",flexWrap:!1,children:[a(M,{override:"force",emptySelect:!1,value:h,options:_(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,SelectorStyles:{freeCSS:{minWidth:12*12}},onUpdateValidValue:({value:l})=>{m({modifiedType:"update",year:Number(l),month:n,date:s})},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})})}),a(M,{override:"force",emptySelect:!1,value:n,options:(()=>{let l=[];for(let u=1;u<=12;u++)l.push({value:u,label:String(u)+"\u6708"});return l})(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,SelectorStyles:{freeCSS:{minWidth:12*8}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),onUpdateValidValue:({value:l})=>{m({modifiedType:"update",year:h,month:Number(l),date:s})}})]}),a(g.Variables.ShiftButtons,{callback:l=>{let u=n+l,c=h;u<=0&&(c--,u=12),u>12&&(c++,u=1),m({modifiedType:"update",year:c,month:u,date:r.date})}})]}),a(k,{borderTop:!0}),a(k,{children:g.Date.MonthCalendar({min:e,max:d,year:r.year,month:r.month,current:[r.year,r.month,r.date],callback:l=>{let[u,c,v]=l;m({modifiedType:"update",year:u,month:c,date:v})}})}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},MonthCalendar:i=>{let{min:e,max:d,year:o,month:t,current:r,callback:m}=i,h=S(),n=S([o,t.zeroEmbed(2),"01"].join("/")),s=n.getLastDayOfTheMonth(),l=S(n).addMonth(-1).getLastDayOfTheMonth().date,u=[],c=[],v=[],R=[],I={padding:0,unitWidth:3,unitHeight:3,flexCenter:!0,borderRadius:"3.tone.tertiary"};for(var b=0;b<7;b++)u.push(a(k,x(p({className:[y("CalendarDay"),y("Legend")].join(" ")},I),{children:["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][b]}),b));for(var b=0;b<n.weekday;b++)c.unshift(X(k,x(p({className:[y("CalendarDay"),y("Dummy")].join(" "),fontColor:"4.thin"},I),{key:b}),l-b));for(var b=1;b<=s.date;b++){let E=b,Y=o==h.year&&t==h.month&&b==h.date,P=!1;{let z=Number(String([o,t.zeroEmbed(2),b.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>z&&(P=!0),i.max){let U=Number(String(i.max).replace(/\D/ig,""));z>U&&(P=!0)}}v.push(a(C.Clear,x(p({className:[y("CalendarDay"),y("isToday_"+Y)].join(" ")},I),{fontColor:"1.clear",padding:0,flexCenter:!0,isRounded:!0,ssEffectsOnActive:"shrink",onClick:()=>{m([o,t,E])},tabIndex:-1,isLocked:P,children:b}),E))}for(var b=1;b<7-s.weekday;b++)R.push(a(k,x(p({className:[y("CalendarDay"),y("Dummy")].join(" "),fontColor:"4.thin"},I),{children:b}),b));return f(W,{gridCols:7,gap:"1/6",children:[u,c,v,R]})}},Month:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h,month:n}=r;return f(V,{padding:1,children:[f(N.Separate,{gap:0,children:[a(N.Center,{verticalAlign:"bottom",gap:"2/3",children:a(M,{emptySelect:!1,value:h,options:_(),override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,SelectorStyles:{freeCSS:{minWidth:12*12}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),onUpdateValidValue:({value:s})=>{m({modifiedType:"update",year:Number(s),month:n})}})}),a(g.Variables.ShiftButtons,{callback:s=>{let l=Math.min(Math.max(h+s,1900),2100);m({modifiedType:"update",year:l,month:n})}})]}),a(k,{borderTop:!0}),g.Month.Months({min:e,max:d,year:r.year,callback:s=>{let[l,u]=s;m({modifiedType:"update",year:l,month:u})}}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},Months:i=>{let{year:e,callback:d}=i,o=S(),t=[];for(let r=1;r<=12;r++){let m=e==o.year&&r==o.month,h=!1;{let s=Number(String([e,r.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>s&&(h=!0),i.max){let l=Number(String(i.max).replace(/\D/ig,""));s>l&&(h=!0)}}let n=[y("Cell"),m?y("isThisMonth"):""].join(" ");t.push(f(C.Clear,{className:n,isLocked:h,fontColor:"2.normal",padding:["1/3",1],ssEffectsOnActive:"shrink",onClick:()=>{d([e,r])},children:[r," \u6708"]},e+"-"+r))}return a(W,{gridCols:4,gap:"2/3",children:t})}},Year:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h}=r;return f(V,{padding:1,children:[a(M,{emptySelect:!1,paddingRight:1,fontSize:"1.mini",value:h||S().year,override:"force",SelectorStyles:{freeCSS:{minWidth:12*12}},options:_({min:e,max:d}),onUpdateValidValue:({value:n})=>{m({modifiedType:"update",year:Number(n)})}}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o,onSubmit:()=>{m({modifiedType:"update",year:Number(h||S().year)})}})]})}},DateWareki:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{era:h,year:n,month:s,date:l}=r,u={val_value:r,set_value:m};return f(k,{children:[f(N.Left,{borderBottom:!0,gap:0,verticalAlign:"unset",children:[a(g.DateWareki.EraSelect,p({},u)),a(k,{borderRight:!0}),a(g.DateWareki.Calendar,p({},u))]}),a(N.Right,{padding:1,children:a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})})]})},EraSelect:i=>{let{val_value:e,set_value:d}=i,o={padding:["1/2",1.5],fontColor:"3.blur"},t={backgroundColor:"cloud",fontColor:"2.normal",isSemiBoldFont:!0};return f(V,{padding:1,gap:0,children:[a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="year",onClick:()=>{let r=S();d({modifiedType:"update",era:"year",year:r.year,month:r.month,date:r.date})},children:"\u897F\u66A6"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="reiwa",onClick:()=>{let r=S();d({modifiedType:"update",era:"reiwa",year:r.year,month:r.month,date:r.date})},children:"\u4EE4\u548C"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="heisei",onClick:()=>{d({modifiedType:"update",era:"heisei",year:2019,month:1,date:1})},children:"\u5E73\u6210"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="shouwa",onClick:()=>{d({modifiedType:"update",era:"shouwa",year:1989,month:1,date:1})},children:"\u662D\u548C"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="taisho",onClick:()=>{d({modifiedType:"update",era:"taisho",year:1926,month:1,date:1})},children:"\u5927\u6B63"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="meiji",onClick:()=>{d({modifiedType:"update",era:"meiji",year:1912,month:1,date:1})},children:"\u660E\u6CBB"}))]})},Calendar:i=>{let{val_value:e,set_value:d}=i,o=[];if(e.era=="year"){let t=S().year+10;for(let r=1900;r<t;r++)o.unshift({value:r,label:r+"\u5E74"})}else if(e.era=="reiwa"){let t=S().year-2018;for(let r=1;r<=t+10;r++)o.unshift({value:2019+r-1,label:"\u4EE4\u548C"+(r==1?"\u5143":r)+"\u5E74"})}else if(e.era=="heisei")for(let t=1;t<=31;t++)o.unshift({value:1989+t-1,label:"\u5E73\u6210"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="shouwa")for(let t=1;t<=64;t++)o.unshift({value:1926+t-1,label:"\u662D\u548C"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="taisho")for(let t=1;t<=15;t++)o.unshift({value:1912+t-1,label:"\u5927\u6B63"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="meiji")for(let t=1;t<=45;t++)o.unshift({value:1868+t-1,label:"\u660E\u6CBB"+(t==1?"\u5143":t)+"\u5E74"});return f(V,{padding:1,children:[f(N.Separate,{children:[a(M,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,fontSize:"1.mini",SelectorStyles:{freeCSS:{minWidth:12*12}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),options:o,value:e.year,onUpdateValidValue:({value:t})=>{d(r=>x(p({},r),{modifiedType:"update",year:Number(t)}))}}),f(N.Center,{gap:"1/3",children:[a(M,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,fontSize:"1.mini",SelectorStyles:{freeCSS:{minWidth:12*9}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),options:[{value:1,label:"1\u6708"},{value:2,label:"2\u6708"},{value:3,label:"3\u6708"},{value:4,label:"4\u6708"},{value:5,label:"5\u6708"},{value:6,label:"6\u6708"},{value:7,label:"7\u6708"},{value:8,label:"8\u6708"},{value:9,label:"9\u6708"},{value:10,label:"10\u6708"},{value:11,label:"11\u6708"},{value:12,label:"12\u6708"}],value:e.month,onUpdateValidValue:({value:t})=>{d({modifiedType:"update",era:e.era,year:e.year,month:Number(t),date:1})}}),a(C.Clear.S,{ssSphere:2.5,onClick:()=>{let t=e.month-1;d({modifiedType:"update",era:e.era,year:t==0?e.year-1:e.year,month:t==0?12:t,date:1})},children:a(T.ChevronLeft,{})}),a(C.Clear.S,{ssSphere:2.5,onClick:()=>{let t=e.month+1;d({modifiedType:"update",era:e.era,year:t==13?e.year+1:e.year,month:t==13?1:t,date:1})},children:a(T.ChevronRight,{})})]})]}),a(g.DateWareki.MonthCell,p({},i))]},e.era)},MonthCell:i=>{let{val_value:e,set_value:d}=i,o=S([e.year.zeroEmbed(4),e.month.zeroEmbed(2),e.date.zeroEmbed(2)].join("/"));if(!o.validate)return;let t=o.getFirstDayOfTheMonth().weekday,r=o.getLastDayOfTheMonth(),m=[];for(let n=0;n<7;n++)m.push(a(G.Supplement,{flexCenter:!0,fontColor:n==0?"googleRed":n==6?"googleBlue":"3.blur",children:D.transformer.weekday.shortJP(n)},"legend-"+n));for(let n=0;n<t;n++){let s=S(o).getFirstDayOfTheMonth().addDate(n-t);m.push(a(C.Sub,{color:"cloud",ssSquare:3,opacity:"middle",onClick:l=>{l.preventDefault(),l.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"lastMonth-"+n))}let h=S();for(let n=1;n<=r.date;n++){let s=S(o).setDate(n),l=h.diff(s).dates==0;m.push(a(C.Clear,{ssSquare:3,fontColor:"2.normal",className:[y("CalendarDay"),y("isToday_"+l)].join(" "),onClick:()=>{d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"currentMonth-"+n))}for(let n=0;n<7-r.weekday-1;n++){let s=S(o).addMonth(1).setDate(1).addDate(n);m.push(a(C.Sub,{color:"cloud",ssSquare:3,opacity:"middle",onClick:l=>{l.preventDefault(),l.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"nextMonth-"+n))}return a(W,{gridCols:7,gap:"1/4",children:m})}},Variables:{Footer:i=>f(w,{flexWrap:!1,gap:1,flexChilds:"even",freeCSS:{whiteSpace:"nowrap"},children:[f(C.Sub.S,{tabIndex:-1,isRounded:!0,onClick:()=>{i.onValueUpdate("")},flexSizing:"none",children:[a(T.Times,{})," \u524A\u9664"]}),a(C.Prime.S,{tabIndex:-1,isRounded:!0,flexSizing:"auto",freeCSS:{minWidth:12*6},onClick:()=>{i.onSubmit&&i.onSubmit(),$.close(i.sheetID)},children:"\u6C7A\u5B9A"})]}),ShiftButtons:i=>f(w,{gap:"1/3",flexWrap:!1,children:[a(C.Clear,x(p({className:y("LeftButton"),tabIndex:-1,right:0},g.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(-1)},children:a(T.ChevronLeft,{})})),a(C.Clear,x(p({className:y("RightButton"),tabIndex:-1,left:0},g.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(1)},children:a(T.ChevronRight,{})}))]}),ShiftButtonStyles:{position:"relative",flexCenter:!0,ssSphere:2.5}}};export{L as Picker,L as default};
|
package/dist/fn/Sheet.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as C,c as R,d as X}from"../chunk-C5N2D3ZX.js";import{jsx as u,jsxs as F}from"react/jsx-runtime";import h,{UUID as J,Time as ae}from"jmini";import{useState as z,useEffect as G,useRef as le}from"react";import{$$fromRoot as Y,Config as K,useStore as T}from"../@utils";import{Box as E,Flex as pe,Img as ne,FAI as ce,Column as re}from"../atoms";import{Row as Q}from"../mols";import{Button as ie}from"./Button";import he from"./SwipeView";import ue from"./Input";import{SheetClasses as m}from"../@styles/componentClasses";const O={currentIndex:0,mainSheetIDs:{},getSessionStates:()=>{let t=T.get("sessionStates-"+K.get().sessionUID);return t||null},getNewSheetStates:t=>{var d;let e=R(C({sheetGroups:t.sheetGroups||[],backgroundEffect:!0,overwrap:t.type=="custom",hold_state:!1,closeAtPageTransit:!0,closeAtEscapeKeyDown:!0,closeAtAroundClick:t.type=="custom"},t),{sheetID:t.sheetID||J(),isOpen:!0,created_at:ae()});if(e.type=="custom"){let l=e;l.parent=l.parent||((d=l==null?void 0:l.event)==null?void 0:d.currentTarget),e=l}return e}},q={Wrapper:()=>{let[t,e]=z(!1),[d,l]=z([]),v={val_sheets:d,set_sheets:l};T.set({["sessionStates-"+K.get().sessionUID]:v}),G(()=>{T.set({["Sheet-"+K.get().sessionUID]:{add:(n,r)=>{let a=T.get("Sheet-"+K.get().sessionUID);if(!a)return;let s=O.getNewSheetStates(n);if(s.isOpen=r!=null?r:!0,!!a.find(s.sheetID)){l(g=>{let w=[...g],y=w.findIndex(k=>k.sheetID==s.sheetID);return y==-1||(w[y]=s),w});return}l(g=>[s,...g])},find:n=>{let r=O.getSessionStates();if(!r)return null;let{val_sheets:a}=r;return a.find(s=>s.sheetID==n)}}}),h(K.get().appRoot).addEvent({eventType:"keyup",eventID:"SheetEvent.keyUp",callback:function(n){let{key:r,metaKey:a}=n;if(r=="Escape"||r==","&&a){let s=O.getSessionStates();if(!s)return;let{val_sheets:p}=s,g=p.filter(y=>y.isOpen);if(!g.length)return;let w=g.reduce((y,k)=>y.created_at.value>k.created_at.value?y:k);N.close(w.sheetID,r)}}}).addEvent({eventType:"click",eventID:"SheetEvent.Click",callback:function(n){let r=O.getSessionStates();if(!r)return;let{val_sheets:a}=r,s=n.target;if(!s||s!=null&&s.closest("."+m("CustomSheet")))return;let p=a.filter(g=>g.type=="custom");p.length&&p.forEach(g=>{let{parent:w}=g;if(!g.closeAtAroundClick)return;let y=Y(w)[0];w!==s&&y!==s&&(h(y).find(s).length||N.close(g.sheetID))})}})},[]),G(()=>{let n=d.filter(r=>r.backgroundEffect&&r.isOpen&&!r.overwrap&&r.type!="custom");e(!!n.length)},[d]),G(()=>{let n=Y(".AMOTIFY_be_root");if(t){let a=h("html").position(),s=32/a.height,p=32/a.width;n.addClass(m("BodyEffect")).css({transform:`scale(${1-p},${1-s})`})}else n.css({transform:"scale(1)"}).removeClass(m("BodyEffect"))},[t]);let f=d.map(n=>u(q.Core,R(C({},v),{val_sheet:n,patch_sheet:r=>{l(a=>{let s=[...a],p=s.findIndex(g=>g.sheetID==n.sheetID);return p==-1||(s[p]=C(C({},s[p]),r)),s})},delete_sheet:()=>{l(r=>{let a=[...r],s=a.findIndex(p=>p.sheetID==n.sheetID);return s==-1||a.splice(s,1),a})}}),n.sheetID));return u(E,{className:["AMOTIFY_be",m("Wrapper")].join(" "),children:f})},Core:t=>{let{val_sheet:e,patch_sheet:d}=t,[l,v]=z(O.currentIndex+1),[f]=z(J()),n=e.type!="custom"&&!e.overwrap;G(()=>{O.currentIndex++,h.scope(()=>{if(!e.closeAtParentBlur)return;let p=h(e.parent);p[0]&&p.addEvent({eventID:"SheetClosation-"+e.sheetID,eventType:"mouseout",callback:()=>{p.removeEvent("SheetClosation-"+e.sheetID),d({isOpen:!1})}})}),T.set({[e.sheetID]:{resize:p=>{if(e.type=="drawer.bottom"){let g=T.get(f);g&&g.resize&&g.resize(p)}else(e.type.includes("normal")||e.type.includes("drawer"))&&d({size:p})},close:p=>{d({isOpen:!1})},open:()=>{d({isOpen:!0})}}})},[]),G(()=>{h.scope(()=>{let p=Y("#"+f);if(e.isOpen){e.hold_state&&v(O.currentIndex+1),p.await(10).removeClass(m("Hide")).await(10).addClass(m("Open")).callback(()=>{e.openAfter&&e.openAfter()});return}p.await(10).removeClass(m("Open")).await(251).addClass(m("Hide")).callback(()=>{if(e.closeAfter&&e.closeAfter(),n&&h(K.get().appRoot).focus(),e.hold_state)return d({isOpen:!1});t.delete_sheet()})})},[e.isOpen]);let[r,a]=e.type.split("."),s=q.Types[{"normal.topLeft":"Normal","normal.topCenter":"Normal","normal.topRight":"Normal","normal.middleLeft":"Normal","normal.middleCenter":"Normal","normal.middleRight":"Normal","normal.bottomLeft":"Normal","normal.bottomCenter":"Normal","normal.bottomRight":"Normal",image:"Normal","drawer.left":"Edge","drawer.right":"Edge","drawer.bottom":"Bottom",custom:"Custom"}[e.type]];return u(E,{className:[m("Wrap"),m("Tcate_"+r),m("Tpos_"+a),m("isMainSheet_"+n)].join(" "),width:1,height:0,ssAbsoluteCovered:!0,freeCSS:{zIndex:l},id:f,children:F(re,{className:m("Content"),gap:0,height:"viewHeight",overflow:"auto",transition:"middle",children:[!!n&&u(q.TapSensor,{sheetID:e.sheetID,delegateAroundClick:e.closeAtAroundClick}),u(s,C({componentID:f},e))]})},f)},Types:{Normal:t=>{let H=t,{sheetID:e,sheetGroups:d,bodyScrolls:l,content:v,className:f="",type:n,size:r="R",freeCSS:a,openAfter:s,closeAfter:p,closeAtAroundClick:g,closeAtEscapeKeyDown:w,closeAtPageTransit:y,closeAtParentBlur:k,closeAtSwipeDown:j,hold_state:ee,overwrap:te,isOpen:oe,backgroundEffect:W}=H,U=X(H,["sheetID","sheetGroups","bodyScrolls","content","className","type","size","freeCSS","openAfter","closeAfter","closeAtAroundClick","closeAtEscapeKeyDown","closeAtPageTransit","closeAtParentBlur","closeAtSwipeDown","hold_state","overwrap","isOpen","backgroundEffect"]),[$,A]=n.split("."),I={},D=[];return A.match(/top/)?(D.push("top"),I.marginBottom="auto"):A.match(/middle/)?(D.push("center"),I.marginTop="auto",I.marginBottom="auto"):A.match(/bottom/)&&(D.push("bottom"),I.marginTop="auto"),A.match(/left/i)?(D.push("left"),I.marginRight="auto"):A.match(/center/i)?(D.push("center"),I.marginLeft="auto",I.marginRight="auto"):A.match(/right/i)&&(D.push("right"),I.marginLeft="auto"),u(E,R(C(C({className:[m("BB"),f].join(" "),padding:1,transition:"long",opacity:"trans"},U),I),{freeCSS:C({width:{S:"26rem",R:"36rem",L:"44rem","2L":"60rem","3L":"72rem",MAX:"100vw"}[r],maxWidth:"96vw",transformOrigin:D.join(" ")},a),children:h.is.function(v)?u(v,{}):v}))},Edge:t=>{let U=t,{sheetID:e,sheetGroups:d,bodyScrolls:l,type:v,content:f,className:n="",size:r="R",openAfter:a,closeAfter:s,closeAtAroundClick:p,closeAtEscapeKeyDown:g,closeAtPageTransit:w,closeAtParentBlur:y,closeAtSwipeDown:k,hold_state:j,overwrap:ee,isOpen:te,backgroundEffect:oe}=U,W=X(U,["sheetID","sheetGroups","bodyScrolls","type","content","className","size","openAfter","closeAfter","closeAtAroundClick","closeAtEscapeKeyDown","closeAtPageTransit","closeAtParentBlur","closeAtSwipeDown","hold_state","overwrap","isOpen","backgroundEffect"]);return u(E,R(C(R(C({className:[m("BB"),n].join(" ")},v=="drawer.right"?{marginLeft:"auto"}:v=="drawer.left"?{marginRight:"auto"}:{}),{opacity:"trans",transition:"long",position:"relative",backgroundColor:"layer.1",flexSizing:"none",minHeight:"viewHeight",boxShadow:"3.remark"}),W),{freeCSS:C({width:{S:"20rem",R:"27rem",L:"32rem","2L":"40rem","3L":"58rem",MAX:"100vw"}[r],maxWidth:"96vw"},W.freeCSS),children:h.is.function(f)?u(f,{}):f}))},Bottom:t=>{let V=t,{componentID:e,sheetID:d,sheetGroups:l,bodyScrolls:v,content:f,size:n="R",sizeChanged:r,baseStyles:a,openAfter:s,closeAfter:p,closeAtAroundClick:g,closeAtEscapeKeyDown:w,closeAtPageTransit:y,closeAtParentBlur:k,closeAtSwipeDown:j=!0,hold_state:ee,overwrap:te,isOpen:oe,backgroundEffect:W}=V,U=X(V,["componentID","sheetID","sheetGroups","bodyScrolls","content","size","sizeChanged","baseStyles","openAfter","closeAfter","closeAtAroundClick","closeAtEscapeKeyDown","closeAtPageTransit","closeAtParentBlur","closeAtSwipeDown","hold_state","overwrap","isOpen","backgroundEffect"]),$=h.getScreenSize(),A=[0,.2,.6,.95],I={ZERO:0,S:1,R:2,L:3},[D,H]=z(n),[x,B]=z({process:!1,processStart:0,originY:0,originValue:0,viewHeight:0,value:A[I[n]]});T.update({[e]:{val_edit:x,resize:b=>{let S=A[I[b]];B(c=>R(C({},c),{value:S})),H(b)}}});const _={Start:b=>{h(document).addEvent({eventID:"BottomSheetMouseMove",eventType:"mousemove",callback:_.Move}).addEvent({eventID:"BottomSheetTouchMove",eventType:"touchmove",callback:_.Move}).addEvent({eventID:"BottomSheetMouseUp",eventType:"mouseup",callback:_.End}).addEvent({eventID:"BottomSheetTouchEnd",eventType:"touchend",callback:_.End});let S=h.getCursor(b),c=R(C({},x),{process:!0,processStart:new Date().getTime(),originY:S.y,originValue:x.value,viewHeight:h.getScreenSize().height});T.update({[e]:{val_edit:c}}),B(c)},Move:b=>{var P;let S=(P=T.get(e))==null?void 0:P.val_edit;if(!S.process)return;let L=(h.getCursor(b).y-S.originY)/S.viewHeight,o=S.originValue-L;if(o>.95)o=.95+(o-.95)*.5;else if(o<.2){let M=.2-o;M-=.1,o=.1+(.1-M)*.5}B(R(C({},S),{value:o}))},End:b=>{var o;let S=(o=T.get(e))==null?void 0:o.val_edit;if(!S.process)return;h(document).removeEvent(["BottomSheetMouseMove","BottomSheetTouchMove","BottomSheetMouseUp","BottomSheetTouchEnd"]);let c=0;if(S.value<.1||(S.value<.5?c=1:S.value>.75?c=3:c=2),new Date().getTime()-S.processStart<300){let P=h.getCursor(b).y-S.originY;if(Math.abs(P)>=20){let M=+(P<0)*2-1;c+=M,c=Math.min(Math.max(c,0),A.length-1)}}c==0&&(j||(c=1)),H(["ZERO","S","R","L"][c]),B(R(C({},S),{value:A[c],process:!1}))}},Z=le(!1);return G(()=>{Z.current?D=="ZERO"?j&&N.close(d):setTimeout(()=>{t.sizeChanged&&t.sizeChanged(D)},250):Z.current=!0},[D]),u(E,{className:m("BB"),margin:[0,"auto"],marginTop:"auto",opacity:"trans",width:1,transition:"long",freeCSS:C({maxWidth:12*60,height:$.height*x.value},x.process?{transition:"0s"}:{}),children:F(re,R(C({gap:0,flexSizing:"none",borderTopLeftRadius:"1.tone.primary",borderTopRightRadius:"1.tone.primary",border:!0,borderBottom:"unset",boxShadow:"3.remark",position:"relative",overflow:"hidden",height:1},a),{children:[u(Q.Separate,{padding:"1/2",backgroundColor:"layer.1",position:"relative",freeCSS:{userSelect:"none"},children:u(Q.Center,{onMouseDown:_.Start,onTouchStart:_.Start,flexSizing:0,padding:"2/3",ssPushable:!0,isRounded:!0,freeCSS:{cursor:"grab",userSelect:"none"},children:u(E,{unitWidth:6,unitHeight:"1/2",backgroundColor:"layer.4",isRounded:!0,className:m("DragBar")})})}),u(E,R(C({backgroundColor:"layer.1",flexSizing:0,overflow:"auto"},U),{children:h.is.function(f)?u(f,{}):f}))]}))})},Custom:t=>{let V=t,{sheetID:e,sheetGroups:d,bodyScrolls:l,event:v,parent:f,nextToCursor:n,gravityPoint:r=22,content:a,closeAtAroundClick:s,closeAtEscapeKeyDown:p,closeAtPageTransit:g,closeAtParentBlur:w,closeAtSwipeDown:y,hold_state:k,openAfter:j,closeAfter:ee,overwrap:te,isOpen:oe,resize:W,backgroundEffect:U}=V,$=X(V,["sheetID","sheetGroups","bodyScrolls","event","parent","nextToCursor","gravityPoint","content","closeAtAroundClick","closeAtEscapeKeyDown","closeAtPageTransit","closeAtParentBlur","closeAtSwipeDown","hold_state","openAfter","closeAfter","overwrap","isOpen","resize","backgroundEffect"]),[A]=z(J()),I=h.is.element(f)||h.is.jmini(f)?h(f):Y(f),D='[data-sheet-id="'+A+'"]',H='[data-sheet-content="'+A+'"]';r=r;let x=r%5||5,B=Math.ceil(r/5);const _={Init:()=>{if(n&&v){let i=h.getScreenSize(),se=h.getCursor(v);return{top:se.y-i.pageYOffset,left:se.x-i.pageXOffset}}let b={};if(!I||!I[0])return b;let{top:S,right:c,bottom:L,left:o,height:P,width:M}=I.position();return[1,2].includes(x)?b.left=o:x==3?b.left=o+M/2:[4,5].includes(x)&&(b.left=c),r<=10?b.top=S:r<=15?b.top=S+P/2:r<=25&&(b.top=L),b},Adjust:()=>{let b=Y(D).position(),S=Y(H).position(),c=I.position(),L=h.getScreenSize(),o={};for(let i in S)o[i]=S[i];if(h.scope(()=>{if(t.nextToCursor)return;let i=0;B==1?i=c.top-o.bottom:B==2?i=c.top-o.top:B==3?i=c.top-o.top+(c.height-o.height)/2:B==4?i=c.bottom-o.bottom:B==5&&(i=c.bottom-o.top),o.top+=i,o.bottom+=i}),h.scope(()=>{if(t.nextToCursor)return;let i=0;x==1?i=c.left-o.right:x==2?i=c.left-o.left:x==3?i=c.left-o.left+(c.width-o.width)/2:x==4?i=c.right-o.right:x==5&&(i=c.right-o.left),o.left+=i,o.right+=i}),o.top<0){let i=-o.top;o.top+=i,o.bottom+=i}if(o.bottom>L.height){let i=o.bottom-L.height;o.top-=i,o.bottom-=i}if(o.left<0){let i=-o.left;o.left+=i,o.right+=i}if(o.right>L.width){let i=o.right-L.width;o.left-=i,o.right-=i}let P=o.top-S.top,M=o.left-S.left;h(D).css({top:b.top+P+"px",left:b.left+M+"px"})}};let[Z]=z(_.Init());return G(()=>{Y(D).await(10).addClass(m("Open")).await(200).callback(()=>{(W==null||W)&&_.Adjust()}),T.update({["customSheet-"+t.sheetID]:{reposition:()=>{_.Adjust()}}})},[]),I[0]?u(E,{className:[m("BB"),m("CustomSheet")].join(" "),"data-sheet-id":A,transition:"long",position:"absolute",width:0,height:0,opacity:"trans",flexCenter:!0,freeCSS:Z,children:u(pe,{position:"absolute",className:[m("GPT"),m("GPT_"+r),m("Col_"+x),m("Row_"+B)].join(" "),children:u(E,R(C({"data-sheet-content":A,flexSizing:"none",maxHeight:"viewHeight"},$),{freeCSS:C({maxWidth:"98vw"},$.freeCSS),children:h.is.function(a)?u(a,{}):a}))})}):null}},TapSensor:t=>u(E,{className:m("TapSensor"),children:u(ie.Plain,{className:m("TapContent"),onClick:()=>{var e;(e=t.delegateAroundClick)!=null&&e&&N.close(t.sheetID)},freeCSS:{cursor:"default",pointerEvents:"all"}})})},N={Wrapper:()=>u(q.Wrapper,{}),open:(t,e)=>{if(t.sheetID=(t.sheetID||"").replace(/\./g,"-"),t.type=="image"){let v=t.sheetID||J(),l=t,{type:f,src:n}=l,r=X(l,["type","src"]);N.open(R(C({type:"normal.topCenter",backgroundColor:"trans"},r),{sheetID:v,freeCSS:{maxWidth:"96vw",transformOrigin:"top"},content:()=>{let[a]=z(h.flatArray(n)),[s,p]=z(0),g=[],w=[];return a.forEach((y,k)=>{g.push({value:k,label:u(ne,{src:h.flatArray(y)[0],width:"auto",height:1,freeCSS:{maxWidth:12*6,maxHeight:12*3}})}),w.push(u(ne,{width:1,height:"auto",src:h.flatArray(y)[0]}))}),F(re,{gap:0,children:[F(Q.Separate,{gap:2,padding:1,backgroundColor:"layer.1",borderTopLeftRadius:"1.tone.primary",borderTopRightRadius:"1.tone.primary",children:[u(ue.Radio.Border,{icon:!1,value:s,override:"force",horizontalAlign:"center",onUpdateValidValue:({value:y})=>{p(y)},cellStyles:{borderWidth:2,padding:"1/3"},options:g}),u(ie.Border.S,{color:"cloud",isRounded:!0,onClick:()=>{N.close(v)},children:F(Q.Center,{gap:"1/3",children:["\u9589\u3058\u308B",u(ce.Times,{})]})})]}),u(he,{slideIndex:s,options:{loop:a.length>1,onSlideCallback:y=>{p(y)}},slides:w,wrapper:y=>u(E,{borderBottomLeftRadius:"1.tone.primary",borderBottomRightRadius:"1.tone.primary",children:y})})]})}}));return}let d=T.get("Sheet-"+K.get().sessionUID);d&&d.add(t,e)},resize:t=>{t.sheetID=(t.sheetID||"").replace(/\./g,"-");let e=T.get(t.sheetID);e&&e.resize&&e.resize(t.size)},customSheet:{reposition:t=>{let e=T.get("customSheet-"+t);e&&e.reposition&&e.reposition()}},close:function(t,e,d){let l=O.getSessionStates();if(!l)return;let{val_sheets:v}=l;t=t==null?void 0:t.replace(/\./g,"-");let f=v.find(r=>r.sheetID==t);if(!f||e=="Escape"&&!f.closeAtEscapeKeyDown)return;let n=T.get(f.sheetID);n&&n.close&&n.close(d)},closeGroup:t=>{let e=O.getSessionStates();if(!e)return;let{val_sheets:d}=e;t=(t||"").replace(/\./g,"-");for(let l of d)l.sheetGroups&&l.sheetGroups==t&&N.close(l.sheetID)},closeAll:t=>{let e=O.getSessionStates();if(!e)return;let{val_sheets:d}=e;for(let l of d)t&&!l.closeAtPageTransit||N.close(l.sheetID,"pageTransit",!0)},Body:t=>u(E,C({className:m("BaseBody"),backgroundColor:"layer.1",borderRadius:"1.tone.primary",position:"relative",boxShadow:"3.remark",transition:"long"},t))};export{N as Sheet,N as default};
|
|
1
|
+
import{b as C,c as R,d as X}from"../chunk-C5N2D3ZX.js";import{jsx as u,jsxs as F}from"react/jsx-runtime";import h,{UUID as J,Time as ae}from"jmini";import{useState as z,useEffect as G,useRef as le}from"react";import{$$fromRoot as Y,Config as K,useStore as T}from"../@utils";import{Box as E,Flex as pe,Img as ne,FAI as ce,Column as re}from"../atoms";import{Row as Q}from"../mols";import{Button as ie}from"./Button";import he from"./SwipeView";import ue from"./Input";import{SheetClasses as m}from"../@styles/componentClasses";const O={currentIndex:0,mainSheetIDs:{},getSessionStates:()=>{let t=T.get("sessionStates-"+K.get().sessionUID);return t||null},getNewSheetStates:t=>{var d;let e=R(C({sheetGroups:t.sheetGroups||[],backgroundEffect:!0,overwrap:t.type=="custom",hold_state:!1,closeAtPageTransit:!0,closeAtEscapeKeyDown:!0,closeAtAroundClick:t.type=="custom"},t),{sheetID:t.sheetID||J(),isOpen:!0,created_at:ae()});if(e.type=="custom"){let l=e;l.parent=l.parent||((d=l==null?void 0:l.event)==null?void 0:d.currentTarget),e=l}return e}},q={Wrapper:()=>{let[t,e]=z(!1),[d,l]=z([]),v={val_sheets:d,set_sheets:l};T.set({["sessionStates-"+K.get().sessionUID]:v}),G(()=>{T.set({["Sheet-"+K.get().sessionUID]:{add:(n,r)=>{let a=T.get("Sheet-"+K.get().sessionUID);if(!a)return;let s=O.getNewSheetStates(n);if(s.isOpen=r!=null?r:!0,!!a.find(s.sheetID)){l(g=>{let w=[...g],y=w.findIndex(k=>k.sheetID==s.sheetID);return y==-1||(w[y]=s),w});return}l(g=>[s,...g])},find:n=>{let r=O.getSessionStates();if(!r)return null;let{val_sheets:a}=r;return a.find(s=>s.sheetID==n)}}}),h(K.get().appRoot).addEvent({eventType:"keyup",eventID:"SheetEvent.keyUp",callback:function(n){let{key:r,metaKey:a}=n;if(r=="Escape"||r==","&&a){let s=O.getSessionStates();if(!s)return;let{val_sheets:p}=s,g=p.filter(y=>y.isOpen);if(!g.length)return;let w=g.reduce((y,k)=>y.created_at.value>k.created_at.value?y:k);N.close(w.sheetID,r)}}}).addEvent({eventType:"click",eventID:"SheetEvent.Click",callback:function(n){let r=O.getSessionStates();if(!r)return;let{val_sheets:a}=r,s=n.target;if(!s||s!=null&&s.closest("."+m("CustomSheet")))return;let p=a.filter(g=>g.type=="custom");p.length&&p.forEach(g=>{let{parent:w}=g;if(!g.closeAtAroundClick)return;let y=Y(w)[0];w!==s&&y!==s&&(h(y).find(s).length||N.close(g.sheetID))})}})},[]),G(()=>{let n=d.filter(r=>r.backgroundEffect&&r.isOpen&&!r.overwrap&&r.type!="custom");e(!!n.length)},[d]),G(()=>{let n=Y(".AMOTIFY_be_root");if(t){let a=h("html").position(),s=32/a.height,p=32/a.width;n.addClass(m("BodyEffect")).css({transform:`scale(${1-p},${1-s})`})}else n.css({transform:"scale(1)"}).removeClass(m("BodyEffect"))},[t]);let f=d.map(n=>u(q.Core,R(C({},v),{val_sheet:n,patch_sheet:r=>{l(a=>{let s=[...a],p=s.findIndex(g=>g.sheetID==n.sheetID);return p==-1||(s[p]=C(C({},s[p]),r)),s})},delete_sheet:()=>{l(r=>{let a=[...r],s=a.findIndex(p=>p.sheetID==n.sheetID);return s==-1||a.splice(s,1),a})}}),n.sheetID));return u(E,{className:["AMOTIFY_be",m("Wrapper")].join(" "),children:f})},Core:t=>{let{val_sheet:e,patch_sheet:d}=t,[l,v]=z(O.currentIndex+2),[f]=z(J()),n=e.type!="custom"&&!e.overwrap;G(()=>{O.currentIndex++,h.scope(()=>{if(!e.closeAtParentBlur)return;let p=h(e.parent);p[0]&&p.addEvent({eventID:"SheetClosation-"+e.sheetID,eventType:"mouseout",callback:()=>{p.removeEvent("SheetClosation-"+e.sheetID),d({isOpen:!1})}})}),T.set({[e.sheetID]:{resize:p=>{if(e.type=="drawer.bottom"){let g=T.get(f);g&&g.resize&&g.resize(p)}else(e.type.includes("normal")||e.type.includes("drawer"))&&d({size:p})},close:p=>{d({isOpen:!1})},open:()=>{d({isOpen:!0})}}})},[]),G(()=>{h.scope(()=>{let p=Y("#"+f);if(e.isOpen){e.hold_state&&v(O.currentIndex+1),p.await(10).removeClass(m("Hide")).await(10).addClass(m("Open")).callback(()=>{e.openAfter&&e.openAfter()});return}p.await(10).removeClass(m("Open")).await(251).addClass(m("Hide")).callback(()=>{if(e.closeAfter&&e.closeAfter(),n&&h(K.get().appRoot).focus(),e.hold_state)return d({isOpen:!1});t.delete_sheet()})})},[e.isOpen]);let[r,a]=e.type.split("."),s=q.Types[{"normal.topLeft":"Normal","normal.topCenter":"Normal","normal.topRight":"Normal","normal.middleLeft":"Normal","normal.middleCenter":"Normal","normal.middleRight":"Normal","normal.bottomLeft":"Normal","normal.bottomCenter":"Normal","normal.bottomRight":"Normal",image:"Normal","drawer.left":"Edge","drawer.right":"Edge","drawer.bottom":"Bottom",custom:"Custom"}[e.type]];return u(E,{className:[m("Wrap"),m("Tcate_"+r),m("Tpos_"+a),m("isMainSheet_"+n)].join(" "),width:1,height:0,ssAbsoluteCovered:!0,freeCSS:{zIndex:l},id:f,children:F(re,{className:m("Content"),gap:0,height:"viewHeight",overflow:"auto",transition:"middle",children:[!!n&&u(q.TapSensor,{sheetID:e.sheetID,delegateAroundClick:e.closeAtAroundClick}),u(s,C({componentID:f},e))]})},f)},Types:{Normal:t=>{let H=t,{sheetID:e,sheetGroups:d,bodyScrolls:l,content:v,className:f="",type:n,size:r="R",freeCSS:a,openAfter:s,closeAfter:p,closeAtAroundClick:g,closeAtEscapeKeyDown:w,closeAtPageTransit:y,closeAtParentBlur:k,closeAtSwipeDown:j,hold_state:ee,overwrap:te,isOpen:oe,backgroundEffect:W}=H,U=X(H,["sheetID","sheetGroups","bodyScrolls","content","className","type","size","freeCSS","openAfter","closeAfter","closeAtAroundClick","closeAtEscapeKeyDown","closeAtPageTransit","closeAtParentBlur","closeAtSwipeDown","hold_state","overwrap","isOpen","backgroundEffect"]),[$,A]=n.split("."),I={},D=[];return A.match(/top/)?(D.push("top"),I.marginBottom="auto"):A.match(/middle/)?(D.push("center"),I.marginTop="auto",I.marginBottom="auto"):A.match(/bottom/)&&(D.push("bottom"),I.marginTop="auto"),A.match(/left/i)?(D.push("left"),I.marginRight="auto"):A.match(/center/i)?(D.push("center"),I.marginLeft="auto",I.marginRight="auto"):A.match(/right/i)&&(D.push("right"),I.marginLeft="auto"),u(E,R(C(C({className:[m("BB"),f].join(" "),padding:1,transition:"long",opacity:"trans"},U),I),{freeCSS:C({width:{S:"26rem",R:"36rem",L:"44rem","2L":"60rem","3L":"72rem",MAX:"100vw"}[r],maxWidth:"96vw",transformOrigin:D.join(" ")},a),children:h.is.function(v)?u(v,{}):v}))},Edge:t=>{let U=t,{sheetID:e,sheetGroups:d,bodyScrolls:l,type:v,content:f,className:n="",size:r="R",openAfter:a,closeAfter:s,closeAtAroundClick:p,closeAtEscapeKeyDown:g,closeAtPageTransit:w,closeAtParentBlur:y,closeAtSwipeDown:k,hold_state:j,overwrap:ee,isOpen:te,backgroundEffect:oe}=U,W=X(U,["sheetID","sheetGroups","bodyScrolls","type","content","className","size","openAfter","closeAfter","closeAtAroundClick","closeAtEscapeKeyDown","closeAtPageTransit","closeAtParentBlur","closeAtSwipeDown","hold_state","overwrap","isOpen","backgroundEffect"]);return u(E,R(C(R(C({className:[m("BB"),n].join(" ")},v=="drawer.right"?{marginLeft:"auto"}:v=="drawer.left"?{marginRight:"auto"}:{}),{opacity:"trans",transition:"long",position:"relative",backgroundColor:"layer.1",flexSizing:"none",minHeight:"viewHeight",boxShadow:"3.remark"}),W),{freeCSS:C({width:{S:"20rem",R:"27rem",L:"32rem","2L":"40rem","3L":"58rem",MAX:"100vw"}[r],maxWidth:"96vw"},W.freeCSS),children:h.is.function(f)?u(f,{}):f}))},Bottom:t=>{let V=t,{componentID:e,sheetID:d,sheetGroups:l,bodyScrolls:v,content:f,size:n="R",sizeChanged:r,baseStyles:a,openAfter:s,closeAfter:p,closeAtAroundClick:g,closeAtEscapeKeyDown:w,closeAtPageTransit:y,closeAtParentBlur:k,closeAtSwipeDown:j=!0,hold_state:ee,overwrap:te,isOpen:oe,backgroundEffect:W}=V,U=X(V,["componentID","sheetID","sheetGroups","bodyScrolls","content","size","sizeChanged","baseStyles","openAfter","closeAfter","closeAtAroundClick","closeAtEscapeKeyDown","closeAtPageTransit","closeAtParentBlur","closeAtSwipeDown","hold_state","overwrap","isOpen","backgroundEffect"]),$=h.getScreenSize(),A=[0,.2,.6,.95],I={ZERO:0,S:1,R:2,L:3},[D,H]=z(n),[x,B]=z({process:!1,processStart:0,originY:0,originValue:0,viewHeight:0,value:A[I[n]]});T.update({[e]:{val_edit:x,resize:b=>{let S=A[I[b]];B(c=>R(C({},c),{value:S})),H(b)}}});const _={Start:b=>{h(document).addEvent({eventID:"BottomSheetMouseMove",eventType:"mousemove",callback:_.Move}).addEvent({eventID:"BottomSheetTouchMove",eventType:"touchmove",callback:_.Move}).addEvent({eventID:"BottomSheetMouseUp",eventType:"mouseup",callback:_.End}).addEvent({eventID:"BottomSheetTouchEnd",eventType:"touchend",callback:_.End});let S=h.getCursor(b),c=R(C({},x),{process:!0,processStart:new Date().getTime(),originY:S.y,originValue:x.value,viewHeight:h.getScreenSize().height});T.update({[e]:{val_edit:c}}),B(c)},Move:b=>{var P;let S=(P=T.get(e))==null?void 0:P.val_edit;if(!S.process)return;let L=(h.getCursor(b).y-S.originY)/S.viewHeight,o=S.originValue-L;if(o>.95)o=.95+(o-.95)*.5;else if(o<.2){let M=.2-o;M-=.1,o=.1+(.1-M)*.5}B(R(C({},S),{value:o}))},End:b=>{var o;let S=(o=T.get(e))==null?void 0:o.val_edit;if(!S.process)return;h(document).removeEvent(["BottomSheetMouseMove","BottomSheetTouchMove","BottomSheetMouseUp","BottomSheetTouchEnd"]);let c=0;if(S.value<.1||(S.value<.5?c=1:S.value>.75?c=3:c=2),new Date().getTime()-S.processStart<300){let P=h.getCursor(b).y-S.originY;if(Math.abs(P)>=20){let M=+(P<0)*2-1;c+=M,c=Math.min(Math.max(c,0),A.length-1)}}c==0&&(j||(c=1)),H(["ZERO","S","R","L"][c]),B(R(C({},S),{value:A[c],process:!1}))}},Z=le(!1);return G(()=>{Z.current?D=="ZERO"?j&&N.close(d):setTimeout(()=>{t.sizeChanged&&t.sizeChanged(D)},250):Z.current=!0},[D]),u(E,{className:m("BB"),margin:[0,"auto"],marginTop:"auto",opacity:"trans",width:1,transition:"long",freeCSS:C({maxWidth:12*60,height:$.height*x.value},x.process?{transition:"0s"}:{}),children:F(re,R(C({gap:0,flexSizing:"none",borderTopLeftRadius:"1.tone.primary",borderTopRightRadius:"1.tone.primary",border:!0,borderBottom:"unset",boxShadow:"3.remark",position:"relative",overflow:"hidden",height:1},a),{children:[u(Q.Separate,{padding:"1/2",backgroundColor:"layer.1",position:"relative",freeCSS:{userSelect:"none"},children:u(Q.Center,{onMouseDown:_.Start,onTouchStart:_.Start,flexSizing:0,padding:"2/3",ssPushable:!0,isRounded:!0,freeCSS:{cursor:"grab",userSelect:"none"},children:u(E,{unitWidth:6,unitHeight:"1/2",backgroundColor:"layer.4",isRounded:!0,className:m("DragBar")})})}),u(E,R(C({backgroundColor:"layer.1",flexSizing:0,overflow:"auto"},U),{children:h.is.function(f)?u(f,{}):f}))]}))})},Custom:t=>{let V=t,{sheetID:e,sheetGroups:d,bodyScrolls:l,event:v,parent:f,nextToCursor:n,gravityPoint:r=22,content:a,closeAtAroundClick:s,closeAtEscapeKeyDown:p,closeAtPageTransit:g,closeAtParentBlur:w,closeAtSwipeDown:y,hold_state:k,openAfter:j,closeAfter:ee,overwrap:te,isOpen:oe,resize:W,backgroundEffect:U}=V,$=X(V,["sheetID","sheetGroups","bodyScrolls","event","parent","nextToCursor","gravityPoint","content","closeAtAroundClick","closeAtEscapeKeyDown","closeAtPageTransit","closeAtParentBlur","closeAtSwipeDown","hold_state","openAfter","closeAfter","overwrap","isOpen","resize","backgroundEffect"]),[A]=z(J()),I=h.is.element(f)||h.is.jmini(f)?h(f):Y(f),D='[data-sheet-id="'+A+'"]',H='[data-sheet-content="'+A+'"]';r=r;let x=r%5||5,B=Math.ceil(r/5);const _={Init:()=>{if(n&&v){let i=h.getScreenSize(),se=h.getCursor(v);return{top:se.y-i.pageYOffset,left:se.x-i.pageXOffset}}let b={};if(!I||!I[0])return b;let{top:S,right:c,bottom:L,left:o,height:P,width:M}=I.position();return[1,2].includes(x)?b.left=o:x==3?b.left=o+M/2:[4,5].includes(x)&&(b.left=c),r<=10?b.top=S:r<=15?b.top=S+P/2:r<=25&&(b.top=L),b},Adjust:()=>{let b=Y(D).position(),S=Y(H).position(),c=I.position(),L=h.getScreenSize(),o={};for(let i in S)o[i]=S[i];if(h.scope(()=>{if(t.nextToCursor)return;let i=0;B==1?i=c.top-o.bottom:B==2?i=c.top-o.top:B==3?i=c.top-o.top+(c.height-o.height)/2:B==4?i=c.bottom-o.bottom:B==5&&(i=c.bottom-o.top),o.top+=i,o.bottom+=i}),h.scope(()=>{if(t.nextToCursor)return;let i=0;x==1?i=c.left-o.right:x==2?i=c.left-o.left:x==3?i=c.left-o.left+(c.width-o.width)/2:x==4?i=c.right-o.right:x==5&&(i=c.right-o.left),o.left+=i,o.right+=i}),o.top<0){let i=-o.top;o.top+=i,o.bottom+=i}if(o.bottom>L.height){let i=o.bottom-L.height;o.top-=i,o.bottom-=i}if(o.left<0){let i=-o.left;o.left+=i,o.right+=i}if(o.right>L.width){let i=o.right-L.width;o.left-=i,o.right-=i}let P=o.top-S.top,M=o.left-S.left;h(D).css({top:b.top+P+"px",left:b.left+M+"px"})}};let[Z]=z(_.Init());return G(()=>{Y(D).await(10).addClass(m("Open")).await(200).callback(()=>{(W==null||W)&&_.Adjust()}),T.update({["customSheet-"+t.sheetID]:{reposition:()=>{_.Adjust()}}})},[]),I[0]?u(E,{className:[m("BB"),m("CustomSheet")].join(" "),"data-sheet-id":A,transition:"long",position:"absolute",width:0,height:0,opacity:"trans",flexCenter:!0,freeCSS:Z,children:u(pe,{position:"absolute",className:[m("GPT"),m("GPT_"+r),m("Col_"+x),m("Row_"+B)].join(" "),children:u(E,R(C({"data-sheet-content":A,flexSizing:"none",maxHeight:"viewHeight"},$),{freeCSS:C({maxWidth:"98vw"},$.freeCSS),children:h.is.function(a)?u(a,{}):a}))})}):null}},TapSensor:t=>u(E,{className:m("TapSensor"),children:u(ie.Plain,{className:m("TapContent"),onClick:()=>{var e;(e=t.delegateAroundClick)!=null&&e&&N.close(t.sheetID)},freeCSS:{cursor:"default",pointerEvents:"all"}})})},N={Wrapper:()=>u(q.Wrapper,{}),open:(t,e)=>{if(t.sheetID=(t.sheetID||"").replace(/\./g,"-"),t.type=="image"){let v=t.sheetID||J(),l=t,{type:f,src:n}=l,r=X(l,["type","src"]);N.open(R(C({type:"normal.topCenter",backgroundColor:"trans"},r),{sheetID:v,freeCSS:{maxWidth:"96vw",transformOrigin:"top"},content:()=>{let[a]=z(h.flatArray(n)),[s,p]=z(0),g=[],w=[];return a.forEach((y,k)=>{g.push({value:k,label:u(ne,{src:h.flatArray(y)[0],width:"auto",height:1,freeCSS:{maxWidth:12*6,maxHeight:12*3}})}),w.push(u(ne,{width:1,height:"auto",src:h.flatArray(y)[0]}))}),F(re,{gap:0,children:[F(Q.Separate,{gap:2,padding:1,backgroundColor:"layer.1",borderTopLeftRadius:"1.tone.primary",borderTopRightRadius:"1.tone.primary",children:[u(ue.Radio.Border,{icon:!1,value:s,override:"force",horizontalAlign:"center",onUpdateValidValue:({value:y})=>{p(y)},cellStyles:{borderWidth:2,padding:"1/3"},options:g}),u(ie.Border.S,{color:"cloud",isRounded:!0,onClick:()=>{N.close(v)},children:F(Q.Center,{gap:"1/3",children:["\u9589\u3058\u308B",u(ce.Times,{})]})})]}),u(he,{slideIndex:s,options:{loop:a.length>1,onSlideCallback:y=>{p(y)}},slides:w,wrapper:y=>u(E,{borderBottomLeftRadius:"1.tone.primary",borderBottomRightRadius:"1.tone.primary",children:y})})]})}}));return}let d=T.get("Sheet-"+K.get().sessionUID);d&&d.add(t,e)},resize:t=>{t.sheetID=(t.sheetID||"").replace(/\./g,"-");let e=T.get(t.sheetID);e&&e.resize&&e.resize(t.size)},customSheet:{reposition:t=>{let e=T.get("customSheet-"+t);e&&e.reposition&&e.reposition()}},close:function(t,e,d){let l=O.getSessionStates();if(!l)return;let{val_sheets:v}=l;t=t==null?void 0:t.replace(/\./g,"-");let f=v.find(r=>r.sheetID==t);if(!f||e=="Escape"&&!f.closeAtEscapeKeyDown)return;let n=T.get(f.sheetID);n&&n.close&&n.close(d)},closeGroup:t=>{let e=O.getSessionStates();if(!e)return;let{val_sheets:d}=e;t=(t||"").replace(/\./g,"-");for(let l of d)l.sheetGroups&&l.sheetGroups==t&&N.close(l.sheetID)},closeAll:t=>{let e=O.getSessionStates();if(!e)return;let{val_sheets:d}=e;for(let l of d)t&&!l.closeAtPageTransit||N.close(l.sheetID,"pageTransit",!0)},Body:t=>u(E,C({className:m("BaseBody"),backgroundColor:"layer.1",borderRadius:"1.tone.primary",position:"relative",boxShadow:"3.remark",transition:"long"},t))};export{N as Sheet,N as default};
|
package/dist/fn/Table/Data.js
CHANGED
|
@@ -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 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};
|
|
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 W}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}}}),W(()=>{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 W(()=>{b(o=>m(r({},o),{rows:c.rows}))},[D.Stringify(c.rows)]),W(()=>{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,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}},SelectorPosition:4,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=U.Info,k.Paging=U.Paging,k.RowLength=U.RowLength,k.SearchInput=U.SearchInput;export{k as Data,k as default};
|