amotify 0.2.240 → 0.2.242
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/@styles/componentClasses/index.css +1 -1
- package/dist/@styles/componentClasses/index.js +1 -1
- package/dist/@styles/index.css +1 -1
- package/dist/@styles/index.js +1 -1
- package/dist/@styles/style.css +1 -1
- package/dist/@styles/style.js +1 -1
- 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
|
@@ -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};
|