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