amotify 0.2.175 → 0.2.177
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demo/esbuild/app.tsx +10 -76
- package/demo/esbuild/public/index.js +192 -390
- package/demo/next/package.json +2 -2
- package/demo/next/src/app/(router)/page.tsx +12 -4
- package/dist/fn/Input/TextField.js +3 -3
- package/dist/fn/Input/Time/index.js +1 -1
- package/dist/fn/Input/core.d.ts +1 -1
- package/dist/fn/Input/core.js +1 -1
- package/package.json +2 -2
package/demo/next/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"cross-env": "^7.0.3",
|
|
13
13
|
"dotenv": "^16.4.5",
|
|
14
14
|
"express": "^4.19.2",
|
|
15
|
-
"jmini": "^0.0.
|
|
15
|
+
"jmini": "^0.0.82",
|
|
16
16
|
"next": "^15.3.4",
|
|
17
17
|
"node-cron": "^4.1.1",
|
|
18
18
|
"nodemon": "^3.1.4",
|
|
@@ -35,4 +35,4 @@
|
|
|
35
35
|
"eslint-config-next": "14.2.5",
|
|
36
36
|
"typescript": "^5"
|
|
37
37
|
}
|
|
38
|
-
}
|
|
38
|
+
}
|
|
@@ -33,18 +33,26 @@ const Dashboard = () => {
|
|
|
33
33
|
useEffect( () => {
|
|
34
34
|
},[] )
|
|
35
35
|
|
|
36
|
-
|
|
37
36
|
return <Plate
|
|
38
37
|
size='L'
|
|
39
38
|
padding={ 2 }
|
|
40
39
|
>
|
|
41
40
|
|
|
42
41
|
<Column gap={ 3 }>
|
|
42
|
+
{/* <Input.Time.DateWareki
|
|
43
|
+
value={ '15:00' }
|
|
44
|
+
onUpdateValidValue={ value => {
|
|
45
|
+
console.log( 'Time Value',value )
|
|
46
|
+
} }
|
|
47
|
+
/> */}
|
|
43
48
|
<Input.TextField.DigitNumber
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
multiline
|
|
50
|
+
allowDecimals={ 5 }
|
|
51
|
+
value={ -200.22 }
|
|
52
|
+
// min={ 1 }
|
|
53
|
+
// max={ 1000.5 }
|
|
46
54
|
onUpdateValidValue={ value => {
|
|
47
|
-
console.log( value )
|
|
55
|
+
console.log( "value",value )
|
|
48
56
|
} }
|
|
49
57
|
/>
|
|
50
58
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{b as l,c
|
|
2
|
-
T`.repeat(
|
|
3
|
-
T`.repeat(
|
|
1
|
+
import{b as l,c,d as ne,e as de}from"../../chunk-C5N2D3ZX.js";import{Fragment as xe,jsx as n,jsxs as Y}from"react/jsx-runtime";import b,{UUID as M,useStore as fe}from"jmini";import{useState as K,useEffect as oe}from"react";import{$$fromRoot as Fe,ExtractStyles as Ne}from"../../@utils";import{Box as k,FAI as _e}from"../../atoms";import{Literal as re}from"../../mols";import{Tips as ge,Button as De}from"..";import{faEye as Le}from"@fortawesome/free-solid-svg-icons/faEye";import{OptionalInputWrapper as Ee,BoxWrapper as He,CoreEffects as W,DefaultBoxishStyles as Ae}from"./core";import{InputLabel as Be}from"./Label";import{LeftIcon as Me,RightIcon as be}from".";const $e={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:Y(xe,{children:[n(k,{children:"\u25CB\u25CB\u25CB\u25CB@\u25CB\u25CB\u25CB\u25CB.\u25CB\u25CB\u25CB\u306E\u5F62\u5F0F\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),n(k,{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:Y(xe,{children:[n(k,{children:"0\u304B\u3089\u59CB\u307E\u308B\u756A\u53F7\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"}),n(k,{children:"9~12\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),n(k,{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"}},y={setSelection:t=>{let{id:a,restrict:o,val_status:s}=t,i=Fe("#"+a)[0];if(i&&s.prevValue&&s.formatValue){let{formatValue:e,prevValue:u,caretFrom:d,caretTo:r}=s;if(o=="creditCard")e.length>=u.length&&d%5==0&&(d++,r++),i.setSelectionRange(d,r);else if(o=="postal")e.length==5&&u.length==3&&(d++,r++),i.setSelectionRange(d,r);else if(o=="digitNumber"){let p=e.length-u.length;p==2&&(d++,r++),p==-2&&(d--,r--),i.setSelectionRange(d,r)}}},Validation:{System:t=>{let{value:a,states:o}=t,{restrict:s="text",defaultValidation:i,maxLength:e,multiline:u,required:d}=o,r=[];if(u||(e=e||255),b.is.exist(e)&&a.length>=Number(e)&&r.push({type:"invalid",label:e+"\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),a){let p=y.Validation.Text(a,s,i);p.ok||r.push({type:"invalid",label:p.body})}else d&&r.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"});return{ok:!r.filter(({type:p})=>p=="invalid").length,notice:r}},Text:(t,a,o)=>{let s={ok:!0,body:""};return(()=>{let i=o||$e[a];if(!i)return;let e=i.reason;if(i){let u=!!(+!!t.match(i.reg)^+!i.exist);s={ok:u,body:u?"":e}}})(),s},DataLeveling:t=>{let{restrict:a,allowDecimals:o,allowZeroStart:s,value:i=""}=t,e=String(i);["tel","number","digitNumber","postal","creditCard"].includes(a)&&(e=e.zen2hanNumber()),a=="katakana",a=="hankaku.katakana",["postal","creditCard"].includes(a)&&(e=e.removeLetters()),b.scope(()=>{if(!["number","digitNumber"].includes(a))return;e=e.replace(/(\.\d+)\..*/g,"$1").replace(/\.+/g,".").replace(/[^0-9.-]/g,"");let d=Number(e)<0||e[0]=="-";e=e.replace(/[^0-9.]/g,""),d&&(e="-"+e);let r=Number(o);o?e=e.replace(/(\.\d{0,})\..*/g,"$1").replace(/\.(\d{0,})/g,(p,g)=>g.length>r?"."+g.slice(0,r):p):e=e.replace(/\.\d?/g,""),b.scope(()=>{a=="number"&&(s||(e=e.replace(/^0(\d+)/g,"$1").replace(/^-0(\d+)/g,"-$1")))}),b.scope(()=>{let p=e.slice(-1);if(!e||p=="."||p=="-")return;let{min:g,max:S}=t;b.is.exist(g)&&b.is.number(g)&&Number(e)<Number(g)&&(e=String(g.toFixed(r))),b.is.exist(S)&&b.is.number(S)&&Number(e)>Number(S)&&(e=String(S.toFixed(r)))}),b.scope(()=>{if(!e||e=="-"||a!="digitNumber")return;let p=e.slice(-1),[g,S]=e.split(".");e=g.replace(/\B(?=(\d{3})+(?!\d))/g,","),S&&(e+="."+S),p=="."&&(e+=".")})});let u=e;return a=="digitNumber"||(a=="postal"?e.length>=4&&(u=e.clip(0,3)+"-"+e.clip(3)):a=="creditCard"&&(u=e.replace(/.{4}(?=.)/g,"$& "))),e=e.replace(/,/g,""),{formatValue:u,dataValue:e}}},Shallow:t=>{let{rootStates:a,val_status:o}=t,s=o.dataValue||"";oe(()=>{b.scope(()=>de(void 0,null,function*(){if(!a.multiline)return;let p=b('[data-input-origin="'+o.componentId+'"]'),g=b('[data-input-shallow="'+o.componentId+'"]'),S=b('[data-input-min-height-value-shallow="'+o.componentId+'"]'),T=b('[data-input-max-height-value-shallow="'+o.componentId+'"]');if(!p[0]||!g[0]||!S[0]||!T[0])return;let F=g.position(),D=S.position(),f=T.position(),C=0;a.autoHeight&&(C=F.height),C=Math.max(C,D.height),C=Math.min(C,f.height),p[0].style.height=C+"px"}))},[s]);let i=s||"";(!!s.match(/\n$/)||!s)&&(i+="T");let u="",d="";if(a.multiline){let p=a.minRows||1,g=a.maxRows||100;u=`
|
|
2
|
+
T`.repeat(p-1),d=`
|
|
3
|
+
T`.repeat(g-1)}let r=Ne(a);return Y(k,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:[n(re.Description,c(l({className:a.className},r),{position:"absolute",width:1,freeCSS:c(l({},r.freeCSS),{color:"orange"}),"data-input-shallow":o.componentId,children:n(k,{"data-input-value-shallow":o.componentId,children:i})})),n(re.Description,c(l({className:a.className},r),{position:"absolute",left:0,freeCSS:c(l({},r.freeCSS),{backgroundColor:"transparent",color:"blue"}),"data-input-min-height-value-shallow":o.componentId,children:u})),n(re.Description,c(l({className:a.className},r),{position:"absolute",right:0,freeCSS:c(l({},r.freeCSS),{backgroundColor:"transparent",color:"red"}),"data-input-max-height-value-shallow":o.componentId,children:d}))]})},InputBox:t=>{let{rootStates:a,val_validate:o,set_validate:s,val_status:i,set_status:e,val_inputType:u,set_inputType:d,val_focus:r,set_focus:p,val_isComposing:g,set_isComposing:S}=t;if(a.multiline)return null;let pe=a,{componentId:T,tone:F,required:D,restrict:f="text",form:C,autoComplete:$="off",autoCapitalize:L="off",minRows:G,maxRows:he,multiline:se,autoHeight:Se,enableFormSubmit:X,clearButton:Q=!1,allowDecimals:A,allowZeroStart:O,checkValidationAtFirst:ue,onChange:j,onKeyDown:ee,onValidate:Ie,onUpdateValue:ve,onUpdateValidValue:Te,value:Re="",leftIndicator:ye,rightIndicator:Ce,leftIcon:I,rightIcon:we,maxLength:te,min:v,max:z,label:ce,isLabelActive:Pe,defaultValidation:Ze,wrapStyles:Ue}=pe,m=ne(pe,["componentId","tone","required","restrict","form","autoComplete","autoCapitalize","minRows","maxRows","multiline","autoHeight","enableFormSubmit","clearButton","allowDecimals","allowZeroStart","checkValidationAtFirst","onChange","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","maxLength","min","max","label","isLabelActive","defaultValidation","wrapStyles"]);return n(k,c(l({htmlTag:"input",type:u,inputMode:["number","digitNumber","creditCard"].includes(f)?"numeric":f=="email"?"email":"text","data-disabled":a.disabled,"data-show-validation":W.isShowValidation(o,i,!!ue),"data-component-id":i.componentId,"data-input-origin":i.componentId,value:i.formatValue,autoComplete:$,autoCapitalize:L,onKeyDown:x=>{let{key:R,target:N}=x,B=N,{selectionStart:P,selectionEnd:ae}=B,q=Number(P),Z=Number(ae);{let E=i.formatValue[Number(q)],H=i.formatValue[Number(q)-1];R=="Delete"&&(f=="creditCard"&&E==" "||f=="postal"&&E=="-"||f=="digitNumber"&&E==",")&&(B.setSelectionRange(q+1,Z+1),x.preventDefault()),R=="Backspace"&&(f=="creditCard"&&H==" "||f=="postal"&&H=="-"||f=="digitNumber"&&H==",")&&(B.setSelectionRange(q-1,Z-1),x.preventDefault()),R=="Enter"||R=="Tab"}b.scope(()=>{["number","digitNumber","creditCard"].includes(f)&&R=="Clear"&&e(E=>c(l({},E),{dataValue:"",formatValue:"",eventType:"update",eventID:M()}))}),b.scope(()=>{if(!["number","digitNumber"].includes(f)||!["ArrowUp","ArrowDown"].includes(R))return;let E=+(R=="ArrowUp")*2-1,H=i.dataValue.slice(-1),me=i.formatValue[Z-1],_=Z-1,V=String(i.formatValue),ie=i.dataValue.split(".")[1],Ve=(ie==null?void 0:ie.length)||0;b.scope(()=>{if(!H){V="0";return}if(H=="-"){V+="0";return}if(H=="."){V+="0";return}if(Z==0)return;let le=String(V).slice(0,_).match(/\./),ke=String(V).slice(_),J=String(ke.toNumber().toFixed(0)).length;me=="."&&(J=1,_=V.split(".")[0].length-1),me==","&&(J+=1,_--),le&&(J=-1*(Ve-J));let U=V[_].toNumber()+E;U<0?U=9:U>=10&&(U=0),V=V.partReplace(_,String(U)),setTimeout(()=>{B.setSelectionRange(_+1,_+1)},1)}),o.ok&&s({ok:!1,notice:[]}),e(le=>c(l(l({},le),y.Validation.DataLeveling({allowDecimals:A,allowZeroStart:O,min:v,max:z,restrict:f,value:V})),{eventType:"update",eventID:M()})),x.preventDefault()}),ee&&ee(x),X&&W.SubmitForm(x,C)},onChange:x=>{let{value:R,selectionStart:N,selectionEnd:B}=x.target,P=y.Validation.DataLeveling({allowDecimals:A,allowZeroStart:O,min:v,max:z,restrict:f,value:R});g&&(P.formatValue=R),P.formatValue!=i.formatValue&&(o.ok&&s({ok:!1,notice:[]}),e(ae=>c(l(l({},ae),P),{prevValue:i.formatValue,eventType:"update",eventID:M(),caretFrom:Number(N),caretTo:Number(B)})),j&&j(x))},width:1},m),{onFocus:x=>{m!=null&&m.onFocus&&(m==null||m.onFocus(x)),p(!0)},onBlur:x=>{m!=null&&m.onBlur&&(m==null||m.onBlur(x)),p(!1)},onCompositionStart:x=>{m!=null&&m.onCompositionStart&&(m==null||m.onCompositionStart(x)),S(!0)},onCompositionEnd:x=>{if(m!=null&&m.onCompositionEnd&&(m==null||m.onCompositionEnd(x)),f=="text")return;let R=y.Validation.DataLeveling({allowDecimals:A,allowZeroStart:O,min:v,max:z,restrict:f,value:i.formatValue});e(N=>c(l(l({},N),R),{prevValue:N.formatValue,eventType:"update",eventID:M(),caretFrom:Number(N.formatValue.length+1),caretTo:Number(N.formatValue.length+1)})),S(!1)}}))},TextAreaBox:t=>{let{rootStates:a,val_focus:o,set_focus:s,val_validate:i,set_validate:e,val_status:u,set_status:d,isShallow:r}=t,te=a,{componentId:p,tone:g,required:S,form:T,label:F,isLabelActive:D,minRows:f,maxRows:C,multiline:$,autoHeight:L,allowDecimals:G,allowZeroStart:he,enableFormSubmit:se,maxLength:Se,checkValidationAtFirst:X,onChange:Q,onKeyDown:A,onValidate:O,onUpdateValue:ue,onUpdateValidValue:j,value:ee="",leftIndicator:Ie,rightIndicator:ve,leftIcon:Te,rightIcon:Re,defaultValidation:ye,wrapStyles:Ce}=te,I=ne(te,["componentId","tone","required","form","label","isLabelActive","minRows","maxRows","multiline","autoHeight","allowDecimals","allowZeroStart","enableFormSubmit","maxLength","checkValidationAtFirst","onChange","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","defaultValidation","wrapStyles"]);return!a.multiline?null:n(k,c(l({htmlTag:"textarea","data-show-validation":W.isShowValidation(i,u,!!X),"data-input-origin":u.componentId,"data-component-id":u.componentId,value:u.dataValue,width:1},I),{onFocus:v=>{I!=null&&I.onFocus&&(I==null||I.onFocus(v)),s(!0)},onBlur:v=>{I!=null&&I.onBlur&&(I==null||I.onBlur(v)),s(!1)},onKeyDown:v=>{A&&A(v),se&&W.SubmitForm(v,T)},onChange:v=>{let{value:z}=v.target;i.ok&&e({ok:!1,notice:[]}),d(ce=>c(l({},ce),{dataValue:z,eventType:"update",eventID:M()})),Q&&Q(v)}}))}},ze=t=>{let{componentId:a,restrict:o="text",value:s="",min:i,max:e,allowDecimals:u,allowZeroStart:d}=t,[r,p]=K(!1),[g,S]=K(!1),[T,F]=K({componentId:a,formatValue:"",dataValue:"",prevValue:"",eventType:"init",eventID:M(),caretFrom:null,caretTo:null}),[D,f]=K({ok:!1,notice:[]}),[C,$]=K(["password","concealed"].includes(o)&&"password"||"text");oe(()=>{F(G=>l(l({},G),y.Validation.DataLeveling({allowDecimals:u,allowZeroStart:d,min:i,max:e,restrict:o,value:s}))),fe.set({[a+":set_inputType"]:$})},[]);let L={rootStates:t,val_focus:r,set_focus:p,val_inputType:C,set_inputType:$,val_isComposing:g,set_isComposing:S,val_status:T,set_status:F,val_validate:D,set_validate:f};return W.CommonEffects({type:"textfield",states:t,val_status:T,set_status:F,val_validate:D,set_validate:f,SystemValidation:y.Validation.System,ExtraOverrideStates:()=>y.Validation.DataLeveling({allowDecimals:u,allowZeroStart:d,min:i,max:e,restrict:o,value:s})}),oe(()=>{y.setSelection({id:t.id,restrict:o,val_status:T})},[T]),Y(He,{val_status:T,set_status:F,val_validate:D,states:L.rootStates,children:[n(Be,{componentId:t.componentId,fontSize:t.fontSize,required:t.required,label:t.label,isActive:t.isLabelActive||r||!!T.dataValue}),n(y.Shallow,l({},L)),n(y.InputBox,l({},L)),n(y.TextAreaBox,l({},L))]})},w=t=>(t=l({autoHeight:!0,restrict:"text",fontSize:"inherit"},t),t.multiline?(t.minRows=t.minRows||5,t.maxRows=t.maxRows||20):(t.minRows=1,t.maxRows=1),n(Ee,{componentId:t.componentId,children:ze,states:Ae(t)})),h=w;h.Validate=y.Validation.Text,h.Katakana=t=>n(w,c(l({},t),{restrict:"katakana",multiline:!1,autoHeight:!1})),h.HankakuKatakana=t=>n(w,c(l({},t),{restrict:"hankaku.katakana",multiline:!1,autoHeight:!1})),h.CreditCard=t=>n(w,c(l({},t),{restrict:"creditCard",multiline:!1,autoHeight:!1})),h.Tel=t=>n(w,c(l({},t),{restrict:"tel",multiline:!1,autoHeight:!1})),h.Number=t=>n(w,c(l({},t),{restrict:"number",multiline:!1,autoHeight:!1})),h.DigitNumber=t=>n(w,c(l({},t),{restrict:"digitNumber",multiline:!1,autoHeight:!1})),h.Email=t=>n(w,c(l({},t),{restrict:"email",multiline:!1,autoHeight:!1})),h.Url=t=>n(w,c(l({},t),{restrict:"url",multiline:!1,autoHeight:!1})),h.Postal=t=>n(w,c(l({label:"\u90F5\u4FBF\u756A\u53F7"},t),{restrict:"postal",multiline:!1,autoHeight:!1,leftIcon:n(Me,{ssSphere:2,fontColor:"4.thin",children:"\u3012"})})),h.Password=t=>n(w,c(l({label:"\u30D1\u30B9\u30EF\u30FC\u30C9",rightIcon:n(be,{ssSphere:2,padding:0,freeCSS:{pointerEvents:"all"},children:n(De.Sub,{ssSphere:2,borderRadius:"3.tone.tertiary",fontColor:"theme",flexCenter:!0,height:1,ssEffectsOnActive:["expand"],onMouseOver:a=>{ge.open(a.currentTarget,"\u30C6\u30AD\u30B9\u30C8\u3092\u8868\u793A",24)},onMouseLeave:ge.abort,tabIndex:-1,onClick:a=>{b(a.target).parent().parent().find("input").callback(o=>{let s=o[0];if(!s)return;let i=s.dataset.componentId;if(!i)return;let e=fe.get(i+":set_inputType");e&&e(u=>u==="password"&&"text"||"password")})},children:n(_e,{icon:Le})})}),restrict:"password"},t),{multiline:!1,autoHeight:!1})),h.Concealed=t=>n(h.Password,c(l({label:"\u79D8\u5BC6\u9375"},t),{restrict:"concealed"})),h.Money={JPY:t=>n(h.DigitNumber,c(l({rightIcon:n(be,{ssSphere:2,fontColor:"4.thin",children:"\u5186"})},t),{multiline:!1,autoHeight:!1}))};export{h as TextField,ze as TextInput,h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ae,b as l,c as k,d as q}from"../../../chunk-C5N2D3ZX.js";import{Fragment as _e,jsx as y,jsxs as oe}from"react/jsx-runtime";import G,{UUID as N,useStore as L}from"jmini";import*as K from"jmini";import{useState as W,useEffect as Q,useRef as ce}from"react";import{$$fromRoot as pe,Config as re,ExtractStyles as de}from"../../../@utils";import{Box as X,FAI as ue}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 ve}from"@fortawesome/free-solid-svg-icons/faClock";import{faCalendarAlt as Ie}from"@fortawesome/free-solid-svg-icons/faCalendarAlt";import{OptionalInputWrapper as Se,BoxWrapper as Te,CoreEffects as z,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 F=" ~ ",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+F.length,length:4},{type:"month",from:15+F.length,length:2},{type:"date",from:18+F.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+F.length,length:4},{type:"month",from:13+F.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}},O={PeriodMargin:" ~ ",DataLeveling:e=>{let{restrict:t,value:v,era:a}=e,u=G.flatArray(v||""),{defaultValue:f,format:h,ranges:I,sets:r}=we[t],m=[],o=t=="clock"&&":"||"/";for(let i=0;i<u.length;i++)u[i]=String(u[i]).replace(/\D/ig,o);for(let i=0;i<r;i++){let d=u[i]||"";if(!d.match(h))u[i]="",m.push(f);else{let x=f;d.split(/\D/).forEach((E,R)=>{if(R==0&&t=="dateWareki"){let T=Number(E);a!="year"&&(T>=2019?a=="reiwa"?T-=2018:a=="heisei"&&(T=31):T>=1989?a=="heisei"?T-=1988:a=="shouwa"&&(T=64):T>=1926?a=="shouwa"?T-=1925:a=="taisho"&&(T=15):T>=1912?a=="taisho"?T-=1911:a=="meiji"&&(T=45):T>=1868&&(T-=1867)),E=T.zeroEmbed(4)}x=x.replace(new RegExp("------------------".slice(0,E.length)),E)}),m.push(x)}}return{formatValue:m.join(F),dataValue:["dates","months"].includes(t)?u:u[0],ranges:I}},SystemValidation:e=>{let{states:t}=e,{restrict:v,min:a,max:u,required:f}=t,h=[],I=G.flatArray(e.value),r={empty:!1,escalated:1,filled:!0,correct:!0,prohibited:!1};(()=>{let m=v=="clock"&&":"||"/";for(let o=0;o<I.length;o++)I[o]=String(I[o]).replace(/\D/ig,m);for(let o=0;o<I.length;o++){let i=I[o],d=I[o-1];i.removeLetters()||(r.empty=!0),o>0&&(r.escalated&=+(i>=d))}r.escalated&&(r.empty||(v.match(/clock/)?I.forEach(o=>{let[i,d]=o.split(/\D+/);!i||!d?r.filled=!1:(Number(i)>23||Number(d)>59)&&(r.correct=!1)}):v.match(/date/)?I.forEach(o=>{let[i,d,x]=o.split(/\D+/);if(!i||!d||!x)r.filled=!1;else{let E=K.Time(o);(!E.validate||o!=E.toFormatYMD())&&(r.correct=!1)}}):v.match(/week/)?I.forEach(o=>{let[i,d]=o.split(/\D+/);if(!i||!d)r.filled=!1;else{let x=K.Time(i+"/01/01").weekday,R=K.Time(i+"/01/0"+(7-x+1)).addWeek(Number(d)-1);i!=String(R.year)&&(r.correct=!1)}}):v.match(/month/)?I.forEach(o=>{let[i,d]=o.split(/\D+/);!i||!d?r.filled=!1:K.Time([i,d,"01"].join("/")).validate||(r.correct=!1)}):v.match(/year/),r.filled&&r.correct&&I.forEach(o=>{{let i=Number(String(o).replace(/\D/ig,""));if(a&&Number(String(a).replace(/\D/ig,""))>i&&(r.prohibited=!0),u){let d=Number(String(u).replace(/\D/ig,""));i>d&&(r.prohibited=!0)}}})))})();{let{empty:m,escalated:o,filled:i,correct:d,prohibited:x}=r;m&&f&&(h=[{type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}]),o||h.push({type:"invalid",label:"\u6642\u7CFB\u5217\u3092\u6B63\u3057\u304F\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),d||h.push({type:"invalid",label:"\u7121\u52B9\u306A\u5024\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u3059"}),i||h.push({type:"invalid",label:"\u6700\u5F8C\u307E\u3067\u5024\u3092\u57CB\u3081\u3066\u304F\u3060\u3055\u3044"}),x&&h.push({type:"invalid",label:oe(_e,{children:[y(X,{children:"\u5165\u529B\u7BC4\u56F2\u304C\u5236\u9650\u3055\u308C\u3066\u3044\u307E\u3059"}),"[",a||"\u4E0B\u9650\u7121\u3057","] ~ [",u||"\u4E0A\u9650\u7121\u3057","]"]})})}return{ok:!h.filter(({type:m})=>m=="invalid").length,notice:h}},KeyDownEvent:e=>{let{val_era:t,restrict:v,event:a,val_status:u,set_status:f,val_focus:h,set_focus:I}=e,{key:r,shiftKey:m,ctrlKey:o,metaKey:i}=a,d=o||i,{selectionStart:x,selectionEnd:E}=a.target,{index:R,prevIndex:T}=h,{ranges:$,formatValue:H}=u,C=$.length-1;if(["Tab","ArrowLeft","ArrowRight"].includes(r)){let S=0;if(r=="Tab"){let s=+!m*2-1;if(S=h.index+s,S<0||S>C)return}else{let s=r=="ArrowLeft"?-1:r=="ArrowRight"?1:0;d||x==0&&E==String(u.formatValue).length?S=s==1?C:0:S=Math.max(0,Math.min(R+s,C))}I(s=>k(l({},s),{index:S,prevIndex:R})),a.preventDefault()}if(["Backspace","ArrowUp","ArrowDown","0","1","2","3","4","5","6","7","8","9"].includes(r)){a.preventDefault();let S=R;S=Math.max(S,0),S=Math.min(S,C);let{type:s,from:U,length:Y}=$[S],_=H.slice(U,U+Y),p;if(r=="Backspace")p="------".slice(0,Y);else if(["ArrowUp","ArrowDown"].includes(r)){let w=r=="ArrowUp"?1:-1;_=_|0,p=_+w;let[n,c,D]=s=="dateWareki"?t=="year"?[0,2999,4]:t=="reiwa"?[1,2999,4]:t=="heisei"?[1,31,4]:t=="shouwa"?[1,64,4]:t=="taisho"?[1,15,4]:t=="meiji"?[1,45,4]:[0,0,0]:s=="minute"?[0,59,2]:s=="hour"?[0,23,2]:s=="date"?[1,31,2]:s=="week"?[1,53,2]:s=="month"?[1,12,2]:s=="year"?[0,2999,4]:[0,0,0];p>c?p=n:p<n&&(p=c),p=Number(p).zeroEmbed(D)}else if(["0","1","2","3","4","5","6","7","8","9"].includes(r)){let w=_|0,n=r,c=`${w}${n}`;if(T!=R&&(w=0,c="0"+n),s=="year"||s=="dateWareki"&&t=="year")Number(c)>1e4?p=n:p=c,(p|0)>1e3&&S++;else if(["hour","minute","date","week","month"].includes(s)||s=="dateWareki"&&t!="year"){let D=s=="dateWareki"?t=="reiwa"?100:t=="heisei"?31:t=="shouwa"?64:t=="taisho"?15:t=="meiji"?45:0:s=="minute"?59:s=="hour"?23:s=="date"?31:s=="week"?53:s=="month"?12:0;p=(c|0)>D?n:c,(Number(n)>Number(String(D)[0])||_=="0000".slice(0,String(D).length)&&(c!="0000".slice(0,String(D).length)||["minute","hour"].includes(s)&&T==R)||(c|0)>=ae(10,String(D).length-1))&&S++}s=="year"||s=="dateWareki"?p=(p|0).zeroEmbed(4):p=(p|0).zeroEmbed(2)}{let w=String(H).partReplace(U,String(p)),n=w.split(F).map(c=>c.replace(/(^\D|\D$)/,"").split(/\D+/).join(v=="clock"&&":"||"/").replace(/(^\D|\D$)/,""));if(v=="dateWareki"){let c=n[0].split(/\D/),[D,j,P]=c;c.length==3&&D&&(n=[[Number(D)-1+Number({year:1,reiwa:2019,heisei:1989,shouwa:1926,taisho:1912,meiji:1868}[t]),j,P].join("/")])}S=Math.max(S,0),S=Math.min(S,C),f(c=>k(l({},c),{dataValue:["dates","months"].includes(v)?n:n[0],formatValue:w,eventType:"update",eventID:N()})),I(c=>k(l({},c),{index:S,prevIndex:c.index}))}}}},ne={picker:{launch:e=>{let t=e.sheetID||N(),m=e,{onValueUpdate:v,min:a,max:u,era:f,restrict:h,defaultValue:I}=m,r=q(m,["onValueUpdate","min","max","era","restrict","defaultValue"]);ye.open("middleCenter",k(l({sheetID:t,size:"S",padding:0,closeAtAroundClick:!0,closeAtParentBlur:!1},r),{content:y(he.Center,{children:y(Ee,{restrict:h,min:a,max:u,era:f,defaultValue:I,sheetID:t,onValueUpdate:(o,i)=>{v(o,i)}})})}))},remove:e=>{ge.close(e)}}},Re={Shallow:e=>{let{rootStates:t,val_status:v}=e,a=de(t);return y(X,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:y(fe.Description,k(l({className:t.className},a),{position:"absolute",width:1,freeCSS:k(l({},a.freeCSS),{color:"orange"}),children:y(X,{"data-input-value-shallow":v.componentId,children:"A"})}))})}},Ve=e=>{let ee=e,{tone:t,required:v,restrict:a="clock",componentId:u,era:f,form:h,name:I,min:r,max:m,className:o,enableFormSubmit:i,checkValidationAtFirst:d,onKeyDown:x,onValidate:E,onUpdateValue:R,onUpdateValidValue:T,value:$="",leftIndicator:H,rightIndicator:C,leftIcon:S,rightIcon:s,freeCSS:U,wrapStyles:Y}=ee,_=q(ee,["tone","required","restrict","componentId","era","form","name","min","max","className","enableFormSubmit","checkValidationAtFirst","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","freeCSS","wrapStyles"]),[p,w]=W(f),[n,c]=W(k(l({componentId:e.componentId||""},O.DataLeveling({restrict:a,value:$,era:p})),{eventType:"init",eventID:N()})),[D,j]=W({ok:!1,notice:[]}),[P,B]=W({active:!1,index:0,prevIndex:-1}),le={rootStates:e,val_status:n,set_status:c,val_validate:D,set_validate:j,val_era:p,set_era:w,val_focus:P,set_focus:B};z.CommonEffects({type:"time",states:e,val_status:n,set_status:c,val_validate:D,set_validate:j,SystemValidation:O.SystemValidation,ExtraOverrideStates:l({},O.DataLeveling({restrict:a,value:$,era:p}))});const Z=ce(!1);return Q(()=>{if(Z.current){c(b=>l(l({},b),O.DataLeveling({restrict:a,value:b.dataValue,era:p})));let g=L.get("refreshEra_"+n.componentId);g&&g.refreshEra(p)}else Z.current=!0},[p]),L.update({[n.componentId]:{openPicker:g=>{e.disabled||ne.picker.launch({parent:g,sheetID:"PickerTips-"+n.componentId,restrict:a,min:r,max:m,defaultValue:n.dataValue,era:p,onValueUpdate:(b,A)=>{c(M=>k(l(l({},M),O.DataLeveling({restrict:a,value:b,era:A})),{eventType:"update",eventID:N()})),w(A)}})},resetEra:g=>{w(g),c(b=>k(l(l({},b),O.DataLeveling({restrict:a,value:"",era:p})),{eventType:"update",eventID:N()}))}}}),Q(()=>{let{index:g,active:b}=P;if(b){g=Math.max(g,0),g=Math.min(g,n.ranges.length-1);let{from:A,length:M}=n.ranges[g],J=pe("#"+e.id)[0];J&&J.setSelectionRange(A,A+M)}},[P]),oe(Te,{val_status:n,set_status:c,val_validate:D,states:e,children:[y(Re.Shallow,l({},le)),y(ke,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:!0}),re.get().isTouchDevice?y(ie.Plain,k(l({"data-show-validation":z.isShowValidation(D,n,!!d),"data-component-id":n.componentId,"data-input-origin":n.componentId,"data-disabled":e.disabled,className:o,freeCSS:{textAlign:"left"}},_),{children:n.formatValue,onClick:g=>{let b=L.get(n.componentId);b&&b.openPicker(`[data-input-origin="${n.componentId}"]`),g.stopPropagation()}})):y(X,l({htmlTag:"input",type:"text",inputMode:"numeric","data-show-validation":z.isShowValidation(D,n,!!d),"data-input-origin":n.componentId,"data-disabled":e.disabled,value:n.formatValue,className:o,tabIndex:re.get().isTouchDevice?-1:0,onKeyDown:g=>{O.KeyDownEvent({restrict:a,event:g,val_era:p,val_status:n,set_status:c,val_focus:P,set_focus:B}),x&&x(g),i&&z.SubmitForm(g,h)},onKeyUp:g=>{g.key=="Tab"&&B(b=>k(l({},b),{active:!0}))},onClick:g=>{let b=g.target.selectionEnd,A=0;n.ranges.forEach((M,J)=>{let{from:te,length:se,region:me}=M;te<=b&&b<=te+(me||se)&&(A=J)}),B(M=>k(l({},M),{active:!0,index:A})),g.preventDefault()},onChange:()=>{}},_))]})},V={Origin:e=>{let t=l({fontSize:"inherit",width:1},e),[v]=W(e.componentId||N());if(t.componentId=v,G.is.nullish(t.rightIcon)){let a=(e.restrict||"").match(/clock/)?ve:Ie;t.rightIcon=y(be,{ssSphere:2,freeCSS:{pointerEvents:"all"},children:y(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-"+t.componentId,onClick:()=>{let u=L.get(t.componentId);u&&u.openPicker("#Picker-"+t.componentId)},children:y(ue,{icon:a})})})}return y(Se,{componentId:t.componentId,children:Ve,states:De(t)})},Clock:e=>y(V.Origin,l({restrict:"clock",era:"clock"},e)),Date:e=>y(V.Origin,l({restrict:"date"},e)),Week:e=>y(V.Origin,l({restrict:"week"},e)),Month:e=>y(V.Origin,l({restrict:"month"},e)),Year:e=>y(V.Origin,l({restrict:"year"},e)),DateWareki:e=>{e=l({},e);let[t]=W(e.componentId||N());e.componentId=t;let{defaultEra:v="wareki"}=e,[a,u]=W((()=>{let f="year";if(v=="wareki"&&(f="reiwa",e.value)){let[h,I,r]=e.value.split(/\D/);if(h&&I&&r){let m=Number(h);m>=2019?(m-=2019,f="reiwa"):m>=1989?(m-=1989,f="heisei"):m>=1926?(m-=1926,f="shouwa"):m>=1912?(m-=1912,f="taisho"):m>=1868&&(m-=1868,f="meiji"),m+=1}}return f})());return Q(()=>{L.set({["refreshEra_"+t]:{refreshEra:f=>{u(f)}}})},[]),y(V.Origin,k(l({restrict:"dateWareki",leftIndicator:y(xe,{label:"\u5143\u53F7",emptySelect:!1,value:a,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:f=>{u(f);let h=L.get(e.componentId);h&&h.resetEra&&h.resetEra(f)}})},e),{era:a}))},Periods:{Date:e=>y(V.Origin,l({restrict:"dates"},e)),Month:e=>y(V.Origin,l({restrict:"months"},e))},fn:ne};export{V as Time,V as default};
|
|
1
|
+
import{a as ae,b as l,c as k,d as G}from"../../../chunk-C5N2D3ZX.js";import{Fragment as _e,jsx as y,jsxs as oe}from"react/jsx-runtime";import Q,{UUID as N,useStore as L}from"jmini";import*as K from"jmini";import{useState as W,useEffect as X,useRef as pe}from"react";import{$$fromRoot as ce,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 ve}from"@fortawesome/free-solid-svg-icons/faClock";import{faCalendarAlt as Ie}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 F=" ~ ",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+F.length,length:4},{type:"month",from:15+F.length,length:2},{type:"date",from:18+F.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+F.length,length:4},{type:"month",from:13+F.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}},O={PeriodMargin:" ~ ",DataLeveling:e=>{let{restrict:t,value:v,era:a}=e,f=Q.flatArray(v||""),{defaultValue:h,format:g,ranges:I,sets:r}=we[t],p=[],o=t=="clock"&&":"||"/";for(let i=0;i<f.length;i++)f[i]=String(f[i]).replace(/\D/ig,o);for(let i=0;i<r;i++){let u=f[i]||"";if(!u.match(g))f[i]="",p.push(h);else{let x=h;u.split(/\D/).forEach((E,V)=>{if(V==0&&t=="dateWareki"){let T=Number(E);a!="year"&&(T>=2019?a=="reiwa"?T-=2018:a=="heisei"&&(T=31):T>=1989?a=="heisei"?T-=1988:a=="shouwa"&&(T=64):T>=1926?a=="shouwa"?T-=1925:a=="taisho"&&(T=15):T>=1912?a=="taisho"?T-=1911:a=="meiji"&&(T=45):T>=1868&&(T-=1867)),E=T.zeroEmbed(4)}x=x.replace(new RegExp("------------------".slice(0,E.length)),E)}),p.push(x)}}return{formatValue:p.join(F),dataValue:["dates","months"].includes(t)?f:f[0],ranges:I}},SystemValidation:e=>{let{states:t}=e,{restrict:v,min:a,max:f,required:h}=t,g=[],I=Q.flatArray(e.value),r={empty:!1,escalated:1,filled:!0,correct:!0,prohibited:!1};(()=>{let p=v=="clock"&&":"||"/";for(let o=0;o<I.length;o++)I[o]=String(I[o]).replace(/\D/ig,p);for(let o=0;o<I.length;o++){let i=I[o],u=I[o-1];i.removeLetters()||(r.empty=!0),o>0&&(r.escalated&=+(i>=u))}r.escalated&&(r.empty||(v.match(/clock/)?I.forEach(o=>{let[i,u]=o.split(/\D+/);!i||!u?r.filled=!1:(Number(i)>23||Number(u)>59)&&(r.correct=!1)}):v.match(/date/)?I.forEach(o=>{let[i,u,x]=o.split(/\D+/);if(!i||!u||!x)r.filled=!1;else{let E=K.Time(o);(!E.validate||o!=E.toFormatYMD())&&(r.correct=!1)}}):v.match(/week/)?I.forEach(o=>{let[i,u]=o.split(/\D+/);if(!i||!u)r.filled=!1;else{let x=K.Time(i+"/01/01").weekday,V=K.Time(i+"/01/0"+(7-x+1)).addWeek(Number(u)-1);i!=String(V.year)&&(r.correct=!1)}}):v.match(/month/)?I.forEach(o=>{let[i,u]=o.split(/\D+/);!i||!u?r.filled=!1:K.Time([i,u,"01"].join("/")).validate||(r.correct=!1)}):v.match(/year/),r.filled&&r.correct&&I.forEach(o=>{{let i=Number(String(o).replace(/\D/ig,""));if(a&&Number(String(a).replace(/\D/ig,""))>i&&(r.prohibited=!0),f){let u=Number(String(f).replace(/\D/ig,""));i>u&&(r.prohibited=!0)}}})))})();{let{empty:p,escalated:o,filled:i,correct:u,prohibited:x}=r;p&&h&&(g=[{type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}]),o||g.push({type:"invalid",label:"\u6642\u7CFB\u5217\u3092\u6B63\u3057\u304F\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),u||g.push({type:"invalid",label:"\u7121\u52B9\u306A\u5024\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u3059"}),i||g.push({type:"invalid",label:"\u6700\u5F8C\u307E\u3067\u5024\u3092\u57CB\u3081\u3066\u304F\u3060\u3055\u3044"}),x&&g.push({type:"invalid",label:oe(_e,{children:[y(z,{children:"\u5165\u529B\u7BC4\u56F2\u304C\u5236\u9650\u3055\u308C\u3066\u3044\u307E\u3059"}),"[",a||"\u4E0B\u9650\u7121\u3057","] ~ [",f||"\u4E0A\u9650\u7121\u3057","]"]})})}return{ok:!g.filter(({type:p})=>p=="invalid").length,notice:g}},KeyDownEvent:e=>{let{val_era:t,restrict:v,event:a,val_status:f,set_status:h,val_focus:g,set_focus:I}=e,{key:r,shiftKey:p,ctrlKey:o,metaKey:i}=a,u=o||i,{selectionStart:x,selectionEnd:E}=a.target,{index:V,prevIndex:T}=g,{ranges:$,formatValue:Y}=f,C=$.length-1;if(["Tab","ArrowLeft","ArrowRight"].includes(r)){let S=0;if(r=="Tab"){let s=+!p*2-1;if(S=g.index+s,S<0||S>C)return}else{let s=r=="ArrowLeft"?-1:r=="ArrowRight"?1:0;u||x==0&&E==String(f.formatValue).length?S=s==1?C:0:S=Math.max(0,Math.min(V+s,C))}I(s=>k(l({},s),{index:S,prevIndex:V})),a.preventDefault()}if(["Backspace","ArrowUp","ArrowDown","0","1","2","3","4","5","6","7","8","9"].includes(r)){a.preventDefault();let S=V;S=Math.max(S,0),S=Math.min(S,C);let{type:s,from:U,length:q}=$[S],_=Y.slice(U,U+q),c;if(r=="Backspace")c="------".slice(0,q);else if(["ArrowUp","ArrowDown"].includes(r)){let w=r=="ArrowUp"?1:-1;_=_|0,c=_+w;let[n,m,D]=s=="dateWareki"?t=="year"?[0,2999,4]:t=="reiwa"?[1,2999,4]:t=="heisei"?[1,31,4]:t=="shouwa"?[1,64,4]:t=="taisho"?[1,15,4]:t=="meiji"?[1,45,4]:[0,0,0]:s=="minute"?[0,59,2]:s=="hour"?[0,23,2]:s=="date"?[1,31,2]:s=="week"?[1,53,2]:s=="month"?[1,12,2]:s=="year"?[0,2999,4]:[0,0,0];c>m?c=n:c<n&&(c=m),c=Number(c).zeroEmbed(D)}else if(["0","1","2","3","4","5","6","7","8","9"].includes(r)){let w=_|0,n=r,m=`${w}${n}`;if(T!=V&&(w=0,m="0"+n),s=="year"||s=="dateWareki"&&t=="year")Number(m)>1e4?c=n:c=m,(c|0)>1e3&&S++;else if(["hour","minute","date","week","month"].includes(s)||s=="dateWareki"&&t!="year"){let D=s=="dateWareki"?t=="reiwa"?100:t=="heisei"?31:t=="shouwa"?64:t=="taisho"?15:t=="meiji"?45:0:s=="minute"?59:s=="hour"?23:s=="date"?31:s=="week"?53:s=="month"?12:0;c=(m|0)>D?n:m,(Number(n)>Number(String(D)[0])||_=="0000".slice(0,String(D).length)&&(m!="0000".slice(0,String(D).length)||["minute","hour"].includes(s)&&T==V)||(m|0)>=ae(10,String(D).length-1))&&S++}s=="year"||s=="dateWareki"?c=(c|0).zeroEmbed(4):c=(c|0).zeroEmbed(2)}{let w=String(Y).partReplace(U,String(c)),n=w.split(F).map(m=>m.replace(/(^\D|\D$)/,"").split(/\D+/).join(v=="clock"&&":"||"/").replace(/(^\D|\D$)/,""));if(v=="dateWareki"){let m=n[0].split(/\D/),[D,j,P]=m;m.length==3&&D&&(n=[[Number(D)-1+Number({year:1,reiwa:2019,heisei:1989,shouwa:1926,taisho:1912,meiji:1868}[t]),j,P].join("/")])}S=Math.max(S,0),S=Math.min(S,C),h(m=>k(l({},m),{dataValue:["dates","months"].includes(v)?n:n[0],formatValue:w,eventType:"update",eventID:N()})),I(m=>k(l({},m),{index:S,prevIndex:m.index}))}}}},ne={picker:{launch:e=>{let t=e.sheetID||N(),p=e,{onValueUpdate:v,min:a,max:f,era:h,restrict:g,defaultValue:I}=p,r=G(p,["onValueUpdate","min","max","era","restrict","defaultValue"]);ye.open("middleCenter",k(l({sheetID:t,size:"S",padding:0,closeAtAroundClick:!0,closeAtParentBlur:!1},r),{content:y(he.Center,{children:y(Ee,{restrict:g,min:a,max:f,era:h,defaultValue:I,sheetID:t,onValueUpdate:(o,i)=>{v(o,i)}})})}))},remove:e=>{ge.close(e)}}},Ve={Shallow:e=>{let{rootStates:t,val_status:v}=e,a=ue(t);return y(z,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:y(fe.Description,k(l({className:t.className},a),{position:"absolute",width:1,freeCSS:k(l({},a.freeCSS),{color:"orange"}),children:y(z,{"data-input-value-shallow":v.componentId,children:"A"})}))})}},Re=e=>{let ee=e,{tone:t,required:v,restrict:a="clock",componentId:f,era:h,form:g,name:I,min:r,max:p,className:o,enableFormSubmit:i,checkValidationAtFirst:u,onKeyDown:x,onValidate:E,onUpdateValue:V,onUpdateValidValue:T,value:$="",leftIndicator:Y,rightIndicator:C,leftIcon:S,rightIcon:s,freeCSS:U,wrapStyles:q}=ee,_=G(ee,["tone","required","restrict","componentId","era","form","name","min","max","className","enableFormSubmit","checkValidationAtFirst","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","freeCSS","wrapStyles"]),[c,w]=W(h),[n,m]=W({componentId:e.componentId||"",formatValue:"",dataValue:"",ranges:[],eventType:"init",eventID:N()}),[D,j]=W({ok:!1,notice:[]}),[P,B]=W({active:!1,index:0,prevIndex:-1}),le={rootStates:e,val_status:n,set_status:m,val_validate:D,set_validate:j,val_era:c,set_era:w,val_focus:P,set_focus:B};H.CommonEffects({type:"time",states:e,val_status:n,set_status:m,val_validate:D,set_validate:j,SystemValidation:O.SystemValidation,ExtraOverrideStates:()=>O.DataLeveling({restrict:a,value:$,era:c})}),X(()=>{m(d=>l(l({},d),O.DataLeveling({restrict:a,value:$,era:c})))},[]);const Z=pe(!1);return X(()=>{if(Z.current){m(b=>l(l({},b),O.DataLeveling({restrict:a,value:b.dataValue,era:c})));let d=L.get("refreshEra_"+n.componentId);d&&d.refreshEra(c)}else Z.current=!0},[c]),L.update({[n.componentId]:{openPicker:d=>{e.disabled||ne.picker.launch({parent:d,sheetID:"PickerTips-"+n.componentId,restrict:a,min:r,max:p,defaultValue:n.dataValue,era:c,onValueUpdate:(b,A)=>{m(M=>k(l(l({},M),O.DataLeveling({restrict:a,value:b,era:A})),{eventType:"update",eventID:N()})),w(A)}})},resetEra:d=>{w(d),m(b=>k(l(l({},b),O.DataLeveling({restrict:a,value:"",era:c})),{eventType:"update",eventID:N()}))}}}),X(()=>{let{index:d,active:b}=P;if(b){d=Math.max(d,0),d=Math.min(d,n.ranges.length-1);let{from:A,length:M}=n.ranges[d],J=ce("#"+e.id)[0];J&&J.setSelectionRange(A,A+M)}},[P]),oe(Te,{val_status:n,set_status:m,val_validate:D,states:e,children:[y(Ve.Shallow,l({},le)),y(ke,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:!0}),re.get().isTouchDevice?y(ie.Plain,k(l({"data-show-validation":H.isShowValidation(D,n,!!u),"data-component-id":n.componentId,"data-input-origin":n.componentId,"data-disabled":e.disabled,className:o,freeCSS:{textAlign:"left"}},_),{children:n.formatValue,onClick:d=>{let b=L.get(n.componentId);b&&b.openPicker(`[data-input-origin="${n.componentId}"]`),d.stopPropagation()}})):y(z,l({htmlTag:"input",type:"text",inputMode:"numeric","data-show-validation":H.isShowValidation(D,n,!!u),"data-input-origin":n.componentId,"data-disabled":e.disabled,value:n.formatValue,className:o,tabIndex:re.get().isTouchDevice?-1:0,onKeyDown:d=>{O.KeyDownEvent({restrict:a,event:d,val_era:c,val_status:n,set_status:m,val_focus:P,set_focus:B}),x&&x(d),i&&H.SubmitForm(d,g)},onKeyUp:d=>{d.key=="Tab"&&B(b=>k(l({},b),{active:!0}))},onClick:d=>{let b=d.target.selectionEnd,A=0;n.ranges.forEach((M,J)=>{let{from:te,length:se,region:me}=M;te<=b&&b<=te+(me||se)&&(A=J)}),B(M=>k(l({},M),{active:!0,index:A})),d.preventDefault()},onChange:()=>{}},_))]})},R={Origin:e=>{let t=l({fontSize:"inherit",width:1},e),[v]=W(e.componentId||N());if(t.componentId=v,Q.is.nullish(t.rightIcon)){let a=(e.restrict||"").match(/clock/)?ve:Ie;t.rightIcon=y(be,{ssSphere:2,freeCSS:{pointerEvents:"all"},children:y(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-"+t.componentId,onClick:()=>{let f=L.get(t.componentId);f&&f.openPicker("#Picker-"+t.componentId)},children:y(de,{icon:a})})})}return y(Se,{componentId:t.componentId,children:Re,states:De(t)})},Clock:e=>y(R.Origin,l({restrict:"clock",era:"clock"},e)),Date:e=>y(R.Origin,l({restrict:"date"},e)),Week:e=>y(R.Origin,l({restrict:"week"},e)),Month:e=>y(R.Origin,l({restrict:"month"},e)),Year:e=>y(R.Origin,l({restrict:"year"},e)),DateWareki:e=>{e=l({},e);let[t]=W(e.componentId||N());e.componentId=t;let{defaultEra:v="wareki"}=e,[a,f]=W((()=>{let h="year";if(v=="wareki"&&(h="reiwa",e.value)){let[g,I,r]=e.value.split(/\D/);if(g&&I&&r){let p=Number(g);p>=2019?(p-=2019,h="reiwa"):p>=1989?(p-=1989,h="heisei"):p>=1926?(p-=1926,h="shouwa"):p>=1912?(p-=1912,h="taisho"):p>=1868&&(p-=1868,h="meiji"),p+=1}}return h})());return X(()=>{L.set({["refreshEra_"+t]:{refreshEra:h=>{f(h)}}})},[]),y(R.Origin,k(l({restrict:"dateWareki",leftIndicator:y(xe,{label:"\u5143\u53F7",emptySelect:!1,value:a,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:h=>{f(h);let g=L.get(e.componentId);g&&g.resetEra&&g.resetEra(h)}})},e),{era:a}))},Periods:{Date:e=>y(R.Origin,l({restrict:"dates"},e)),Month:e=>y(R.Origin,l({restrict:"months"},e))},fn:ne};export{R as Time,R as default};
|
package/dist/fn/Input/core.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare const CoreEffects: {
|
|
|
30
30
|
val_validate: InputTypes.Validation.Result;
|
|
31
31
|
set_validate: React.Dispatch<React.SetStateAction<InputTypes.Validation.Result>>;
|
|
32
32
|
SystemValidation: InputTypes.Validation.System;
|
|
33
|
-
ExtraOverrideStates?: KeyValueDict;
|
|
33
|
+
ExtraOverrideStates?: () => KeyValueDict;
|
|
34
34
|
}) => void;
|
|
35
35
|
ValidationCheck: (p: {
|
|
36
36
|
val_status: InputTypes.Status.Plain;
|
package/dist/fn/Input/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as o,c as d,e as b}from"../../chunk-C5N2D3ZX.js";import{jsx as p,jsxs as V}from"react/jsx-runtime";import{useState as k,useEffect as g}from"react";import c,{UUID as y,useStore as v}from"jmini";import{$$fromRoot as B,Config as D}from"../../@utils";import{InputClasses as _}from"../../@styles/componentClasses";import{Box as E,Flex as w,FAI as R,Column as N}from"../../atoms";import{Row as x,Literal as F}from"../../mols";import{Button as L}from"../Button";import h from"../Tooltips";const et=t=>{let[n]=k(t.componentId||y());t=o({},t),t.states=d(o({enableFormSubmit:!0,status_id:y(),override:"never",form:"",id:y(),"aria-label":"Input-"+n},t.states),{componentId:n});let{children:e}=t;return p(e,o({},t.states))},at=t=>{let{children:n,val_status:e,val_validate:a,states:i}=t,{leftIcon:l,wrapStyles:s}=i;return e.eventType=="init"&&!i.checkValidationAtFirst&&(a.notice=[]),V(x.Center,d(o({position:"relative",verticalAlign:"unset",gap:0},s),{className:_("Wrapper"),"data-notice-uid":e.componentId,children:[p(C.Notice,{notice:a.notice,val_status:e}),i.leftIndicator,V(w,{position:"relative",flexSizing:"auto",children:[n,l,p(C.RightIcon,o({},t)),p(C.ClearButton,o({},t))]}),i.rightIndicator]}))},C={ClearButton:t=>!t.states.clearButton||!t.val_status.dataValue?null:p(L.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(n=>d(o({},n),{dataValue:"",formatValue:"",eventType:"update",eventID:y()}))},children:p(R.X,{})}),RightIcon:t=>t.states.clearButton&&t.val_status.dataValue?null:t.states.rightIcon,Notice:t=>{let{notice:n,val_status:e}=t,{componentId:a}=e,i="NoticeTimer-"+a,l="NoticeTimerClose-"+a,s="notice-tips-"+a;return g(()=>{c.interval.once(()=>{if(!n.length){h.close(s);return}h.open({tipsID:s,parent:`[data-notice-uid="${a}"]`,gravityPoint:22,padding:[1,0],closeAtParentBlur:!1,content:V(h.Body,{padding:["1/2","2/3"],fontSize:"1.mini",position:"relative",children:[p(E,{position:"absolute",unitHeight:1,unitWidth:1,left:1,backgroundColor:"dark",freeCSS:{zIndex:1,transform:"rotate(45deg)",top:-6}}),p(N,{backgroundColor:"inherit",gap:"1/3",position:"relative",freeCSS:{zIndex:2},children:n.map((I,S)=>{let{type:r,label:u}=I,f=r=="invalid"?R.X:r=="warn"?R.Exclamation:R.Check;return V(x.Left,{gap:0,borderRadius:"2.tone.secondary",children:[p(f,{flexCenter:!0,fontSize:"2.normal",fontColor:{invalid:"nega",warn:"warn",valid:"posi"}[r]}),p(F.Supplement,{fontSize:"0.xs",fontColor:"white",children:u})]},S+"-"+c.Stringify(I))})})]})})},350,i),c.interval.once(()=>{h.close(s)},6e3,l)},[n]),null}},W={DefaultStatus:(t,n)=>({componentId:t,dataValue:n,eventType:"init",eventID:y()}),CommonEffects:function(t){let{type:n,states:e,val_status:a,set_status:i,val_validate:l,set_validate:s,SystemValidation:I}=t;e=o({},e);let{componentId:S}=a;g(()=>(v.update({[S]:{ResolveRefresh:null,Refresh:()=>new Promise((r,u)=>{v.get(S).ResolveRefresh=r,i(f=>d(o({},f),{eventType:"refresh",eventID:y()}))}),GenNotice:r=>{let{ok:u,notice:f}=r;s({ok:u,notice:f})}}}),()=>{v.delete(S)}),[]),c.scope(()=>{let{override:r}=e;if(r=="never"||r=="beforeModified"&&!["init","override"].includes(a.eventType))return;let u=v.get(a.componentId);u&&(e.value!=a.dataValue&&e.status_id!=u.status_id&&i(f=>d(o(d(o({},f),{dataValue:e.value}),t.ExtraOverrideStates),{eventType:"override",eventID:y()})),u.status_id=e.status_id)}),g(()=>{W.ValidationCheck({val_status:a,set_validate:s,SystemValidation:I,states:e})},[a.eventID,a.dataValue]),g(()=>(c.scope(()=>{let{componentId:r,eventType:u,dataValue:f}=a,m=f;if(n=="autocomplete.single"||n=="list.radio"?m=m[0]:e.isChecker&&(m=!!m[0]),e.form=e.form||"testForm",e.name&&e.form&&v.update({[["form-data",e.form].join("-")]:{[e.name]:{componentId:r,type:n,value:m,validation:l.ok}}}),u=="refresh"){let T=v.get(r);T&&T.ResolveRefresh&&T.ResolveRefresh(null)}else u=="update"&&(e.onUpdateValue&&e.onUpdateValue(m,u,r),c.scope(()=>{l.ok&&e.onUpdateValidValue&&e.onUpdateValidValue(m,u,r)}))}),()=>{v.update({[["form-data",e.form].join("-")]:{[e.name]:null}})}),[l])},ValidationCheck:t=>{let{states:n}=t,e="ValidationTimer-"+t.val_status.componentId;c.interval.abort(e);let a=t.SystemValidation({value:t.val_status.dataValue,states:n});if(!a.ok){t.set_validate(a);return}let i=a.notice;const l=()=>b(void 0,null,function*(){if(!n.onValidate)return;let s=yield n.onValidate(t.val_status.dataValue,t.val_status.eventType,t);t.set_validate({ok:s.ok,notice:[...i,...s.notice]})});if(n.onValidate){if(t.val_status.eventType=="refresh"){l();return}c.interval.once(l,450,e);return}t.set_validate({ok:!0,notice:i})},SubmitForm:(t,n)=>{let e=!1;if(!n)return e;let a=B(`[data-form-submit-button="${n}"]`)[0];if(!a)return e;let i=a.dataset.sdfike||"",l=t.key,s=t.ctrlKey||t.metaKey;return c.scope(()=>{i.includes("enter")&&(l!="Enter"||t.nativeEvent.isComposing||D.get().browserIs=="safari"&&t.keyCode==229)||((l=="Enter"&&(i.includes("enter")||i.includes("auxEnter")&&s)||l==" "&&i.includes("space"))&&(a.click(),t.preventDefault()),e=!0)}),e},isShowValidation:(t,n,e)=>{let a=t.ok;return!e&&n.eventType=="init"&&(a=!0),a}},nt=function(t){t=o({tone:"border"},t);let n=c.scope(()=>{if(t.tone=="plain")return{};let a={padding:"3/4",transition:"middle",flexSizing:"auto",boxShadow:"0.min"};return t.tone=="border"?a=d(o({},a),{border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"}):t.tone=="cloud"?a=d(o({},a),{border:"1.thin",borderRadius:"2.tone.secondary",backgroundColor:"cloud"}):t.tone=="bottomBorder"&&(a=d(o({},a),{borderRadius:0,border:"unset",borderBottom:!0,backgroundColor:"cloud"})),a});return d(o(o(o(o(o(o({fontColor:"2.normal"},n),!!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:o({letterSpacing:"1px",resize:"none"},t.freeCSS),className:[_("Input"),t.className].join(" ")})};export{at as BoxWrapper,W as CoreEffects,nt as DefaultBoxishStyles,et as OptionalInputWrapper};
|
|
1
|
+
import{b as o,c as d,e as b}from"../../chunk-C5N2D3ZX.js";import{jsx as p,jsxs as V}from"react/jsx-runtime";import{useState as k,useEffect as g}from"react";import c,{UUID as y,useStore as v}from"jmini";import{$$fromRoot as B,Config as D}from"../../@utils";import{InputClasses as _}from"../../@styles/componentClasses";import{Box as E,Flex as w,FAI as R,Column as N}from"../../atoms";import{Row as x,Literal as F}from"../../mols";import{Button as L}from"../Button";import h from"../Tooltips";const et=t=>{let[n]=k(t.componentId||y());t=o({},t),t.states=d(o({enableFormSubmit:!0,status_id:y(),override:"never",form:"",id:y(),"aria-label":"Input-"+n},t.states),{componentId:n});let{children:e}=t;return p(e,o({},t.states))},at=t=>{let{children:n,val_status:e,val_validate:a,states:i}=t,{leftIcon:l,wrapStyles:s}=i;return e.eventType=="init"&&!i.checkValidationAtFirst&&(a.notice=[]),V(x.Center,d(o({position:"relative",verticalAlign:"unset",gap:0},s),{className:_("Wrapper"),"data-notice-uid":e.componentId,children:[p(C.Notice,{notice:a.notice,val_status:e}),i.leftIndicator,V(w,{position:"relative",flexSizing:"auto",children:[n,l,p(C.RightIcon,o({},t)),p(C.ClearButton,o({},t))]}),i.rightIndicator]}))},C={ClearButton:t=>!t.states.clearButton||!t.val_status.dataValue?null:p(L.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(n=>d(o({},n),{dataValue:"",formatValue:"",eventType:"update",eventID:y()}))},children:p(R.X,{})}),RightIcon:t=>t.states.clearButton&&t.val_status.dataValue?null:t.states.rightIcon,Notice:t=>{let{notice:n,val_status:e}=t,{componentId:a}=e,i="NoticeTimer-"+a,l="NoticeTimerClose-"+a,s="notice-tips-"+a;return g(()=>{c.interval.once(()=>{if(!n.length){h.close(s);return}h.open({tipsID:s,parent:`[data-notice-uid="${a}"]`,gravityPoint:22,padding:[1,0],closeAtParentBlur:!1,content:V(h.Body,{padding:["1/2","2/3"],fontSize:"1.mini",position:"relative",children:[p(E,{position:"absolute",unitHeight:1,unitWidth:1,left:1,backgroundColor:"dark",freeCSS:{zIndex:1,transform:"rotate(45deg)",top:-6}}),p(N,{backgroundColor:"inherit",gap:"1/3",position:"relative",freeCSS:{zIndex:2},children:n.map((I,S)=>{let{type:r,label:u}=I,f=r=="invalid"?R.X:r=="warn"?R.Exclamation:R.Check;return V(x.Left,{gap:0,borderRadius:"2.tone.secondary",children:[p(f,{flexCenter:!0,fontSize:"2.normal",fontColor:{invalid:"nega",warn:"warn",valid:"posi"}[r]}),p(F.Supplement,{fontSize:"0.xs",fontColor:"white",children:u})]},S+"-"+c.Stringify(I))})})]})})},350,i),c.interval.once(()=>{h.close(s)},6e3,l)},[n]),null}},W={DefaultStatus:(t,n)=>({componentId:t,dataValue:n,eventType:"init",eventID:y()}),CommonEffects:function(t){let{type:n,states:e,val_status:a,set_status:i,val_validate:l,set_validate:s,SystemValidation:I}=t;e=o({},e);let{componentId:S}=a;g(()=>(v.update({[S]:{ResolveRefresh:null,Refresh:()=>new Promise((r,u)=>{v.get(S).ResolveRefresh=r,i(f=>d(o({},f),{eventType:"refresh",eventID:y()}))}),GenNotice:r=>{let{ok:u,notice:f}=r;s({ok:u,notice:f})}}}),()=>{v.delete(S)}),[]),c.scope(()=>{let{override:r}=e;if(r=="never"||r=="beforeModified"&&!["init","override"].includes(a.eventType))return;let u=v.get(a.componentId);u&&(e.value!=a.dataValue&&e.status_id!=u.status_id&&i(f=>d(o(d(o({},f),{dataValue:e.value}),t.ExtraOverrideStates&&t.ExtraOverrideStates()),{eventType:"override",eventID:y()})),u.status_id=e.status_id)}),g(()=>{W.ValidationCheck({val_status:a,set_validate:s,SystemValidation:I,states:e})},[a.eventID,a.dataValue]),g(()=>(c.scope(()=>{let{componentId:r,eventType:u,dataValue:f}=a,m=f;if(n=="autocomplete.single"||n=="list.radio"?m=m[0]:e.isChecker&&(m=!!m[0]),e.form=e.form||"testForm",e.name&&e.form&&v.update({[["form-data",e.form].join("-")]:{[e.name]:{componentId:r,type:n,value:m,validation:l.ok}}}),u=="refresh"){let T=v.get(r);T&&T.ResolveRefresh&&T.ResolveRefresh(null)}else u=="update"&&(e.onUpdateValue&&e.onUpdateValue(m,u,r),c.scope(()=>{l.ok&&e.onUpdateValidValue&&e.onUpdateValidValue(m,u,r)}))}),()=>{v.update({[["form-data",e.form].join("-")]:{[e.name]:null}})}),[l])},ValidationCheck:t=>{let{states:n}=t,e="ValidationTimer-"+t.val_status.componentId;c.interval.abort(e);let a=t.SystemValidation({value:t.val_status.dataValue,states:n});if(!a.ok){t.set_validate(a);return}let i=a.notice;const l=()=>b(void 0,null,function*(){if(!n.onValidate)return;let s=yield n.onValidate(t.val_status.dataValue,t.val_status.eventType,t);t.set_validate({ok:s.ok,notice:[...i,...s.notice]})});if(n.onValidate){if(t.val_status.eventType=="refresh"){l();return}c.interval.once(l,450,e);return}t.set_validate({ok:!0,notice:i})},SubmitForm:(t,n)=>{let e=!1;if(!n)return e;let a=B(`[data-form-submit-button="${n}"]`)[0];if(!a)return e;let i=a.dataset.sdfike||"",l=t.key,s=t.ctrlKey||t.metaKey;return c.scope(()=>{i.includes("enter")&&(l!="Enter"||t.nativeEvent.isComposing||D.get().browserIs=="safari"&&t.keyCode==229)||((l=="Enter"&&(i.includes("enter")||i.includes("auxEnter")&&s)||l==" "&&i.includes("space"))&&(a.click(),t.preventDefault()),e=!0)}),e},isShowValidation:(t,n,e)=>{let a=t.ok;return!e&&n.eventType=="init"&&(a=!0),a}},nt=function(t){t=o({tone:"border"},t);let n=c.scope(()=>{if(t.tone=="plain")return{};let a={padding:"3/4",transition:"middle",flexSizing:"auto",boxShadow:"0.min"};return t.tone=="border"?a=d(o({},a),{border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"}):t.tone=="cloud"?a=d(o({},a),{border:"1.thin",borderRadius:"2.tone.secondary",backgroundColor:"cloud"}):t.tone=="bottomBorder"&&(a=d(o({},a),{borderRadius:0,border:"unset",borderBottom:!0,backgroundColor:"cloud"})),a});return d(o(o(o(o(o(o({fontColor:"2.normal"},n),!!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:o({letterSpacing:"1px",resize:"none"},t.freeCSS),className:[_("Input"),t.className].join(" ")})};export{at as BoxWrapper,W as CoreEffects,nt as DefaultBoxishStyles,et as OptionalInputWrapper};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amotify",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.177",
|
|
4
4
|
"description": "UI Component for React,NextJS,esbuild",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "run-p clean build:*",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@fortawesome/free-solid-svg-icons": "^6.7.2",
|
|
91
91
|
"@fortawesome/react-fontawesome": "^0.2.2",
|
|
92
92
|
"dotenv": "^17.0.1",
|
|
93
|
-
"jmini": "^0.0.
|
|
93
|
+
"jmini": "^0.0.82",
|
|
94
94
|
"react": "^18.3.1"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|