amotify 0.2.135 → 0.2.136

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.
@@ -2,7 +2,7 @@
2
2
  import { ReactElement } from '../../@declares';
3
3
  import { InputTypes } from '.';
4
4
  declare namespace TextField {
5
- type Restrict = 'text' | 'katakana' | 'hankaku.katakana' | 'number' | 'number.zeroStart' | 'digitNumber' | 'tel' | 'email' | 'url' | 'fileName' | 'password' | 'postal' | 'creditCard' | 'concealed';
5
+ type Restrict = 'text' | 'katakana' | 'hankaku.katakana' | 'number' | 'digitNumber' | 'tel' | 'email' | 'url' | 'fileName' | 'password' | 'postal' | 'creditCard' | 'concealed';
6
6
  type Input<T = string, Element = HTMLInputElement> = InputTypes.CoreInput<T> & React.DOMAttributes<Element> & {
7
7
  label?: ReactElement;
8
8
  isLabelActive?: boolean;
@@ -11,6 +11,8 @@ declare namespace TextField {
11
11
  tabIndex?: number;
12
12
  id?: string;
13
13
  disabled?: boolean;
14
+ allowDecimals?: boolean | number;
15
+ allowZeroStart?: boolean;
14
16
  restrict?: Restrict;
15
17
  minRows?: number;
16
18
  maxRows?: number;
@@ -1,3 +1,3 @@
1
- import{b as l,c as s,d as q,e as ae}from"../../chunk-C5N2D3ZX.js";import{Fragment as le,jsx as o,jsxs as $}from"react/jsx-runtime";import w,{UUID as _,useStore as Ie}from"jmini";import{useState as L,useEffect as J}from"react";import{$$fromRoot as ve,ExtractStyles as Se}from"../../@utils";import{Box as V,FAI as Te}from"../../atoms";import{Text as Y}from"../../mols";import{Tips as ie,Button as Ce}from"..";import{faEye as Re}from"@fortawesome/free-solid-svg-icons/faEye";import{OptionalInputWrapper as ye,BoxWrapper as we,CoreEffects as M,DefaultBoxishStyles as Ve}from"./core";import{InputLabel as De}from"./Label";import{LeftIcon as ke,RightIcon as ne}from".";const Fe={number:{reg:/^-?[0-9\.]+$/g,exist:!0,reason:"\u534A\u89D2\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},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"},digitNumber:{reg:/^-?[0-9\.]+$/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:$(le,{children:[o(V,{children:"\u25CB\u25CB\u25CB\u25CB@\u25CB\u25CB\u25CB\u25CB.\u25CB\u25CB\u25CB\u306E\u5F62\u5F0F\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),o(V,{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:$(le,{children:[o(V,{children:"0\u304B\u3089\u59CB\u307E\u308B\u756A\u53F7\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"}),o(V,{children:"9~12\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),o(V,{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"}},D={setSelection:e=>{let{id:a,restrict:r,val_status:t}=e,n=ve("#"+a)[0];if(n&&t.prevValue&&t.formatValue){let{formatValue:u,prevValue:c,caretFrom:i,caretTo:m}=t;if(r=="creditCard")u.length>=c.length&&i%5==0&&(i++,m++),n.setSelectionRange(i,m);else if(r=="postal")u.length==5&&c.length==3&&(i++,m++),n.setSelectionRange(i,m);else if(r=="digitNumber"){let h=u.length-c.length;h==2&&(i++,m++),h==-2&&(i--,m--),n.setSelectionRange(i,m)}}},Validation:{System:e=>{let{value:a,states:r}=e,{restrict:t="text",maxLength:n,multiline:u,required:c}=r,i=[];if(u||(n=n||255),w.is.exist(n)&&a.length>=Number(n)&&i.push({type:"invalid",label:n+"\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),a){let m=D.Validation.Text(a,t);m.ok||i.push({type:"invalid",label:m.body})}else c&&i.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"});return{ok:!i.filter(({type:m})=>m=="invalid").length,notice:i}},Text:(e,a)=>{let r={ok:!0,body:""};return(()=>{let t=Fe[a];if(!t)return;let n=t.reason;if(t){let u=!!(+!!e.match(t.reg)^+!t.exist);r={ok:u,body:u?"":n}}})(),r},DataLeveling:e=>{let{restrict:a,value:r=""}=e,t=String(r),n=!1;if(["tel","number","digitNumber","test","postal","creditCard"].includes(a)&&(t=t.zen2hanNumber()),a=="katakana",a=="hankaku.katakana",["postal","creditCard"].includes(a)&&(t=t.removeLetters()),["number","number.zeroStart","digitNumber"].includes(a)){let c=t[0]=="0";if(t){if(t!="-")if(t=="0-")t="-";else{t[0]=="-"&&(n=!0),t=t.replace(/[^0-9\.]/ig,"");let i=Number(t);i===0&&(n=!1),n&&(i=-1*i),w.is.exist(e.min)&&(i=Math.max(i,Number(e.min))),w.is.exist(e.max)&&(i=Math.min(i,Number(e.max))),t=String(Math.abs(i))}c&&t!="0"&&a=="number.zeroStart"&&(t="0"+t)}}let u=t;if(a=="digitNumber"){if(t&&t!="-"){let c=[];for(let i=t.length-1;i>=0;i--){c.unshift(t[i]);let m=t.length-1-i+1;i!=0&&m%3==0&&c.unshift(",")}u=c.join("")}}else a=="postal"?t.length>=4&&(u=t.clip(0,3)+"-"+t.clip(3)):a=="creditCard"&&(u=t.replace(/.{4}(?=.)/g,"$& "));return["number","digitNumber"].includes(a)&&n&&(t="-"+t,u="-"+u),{formatValue:u,dataValue:t}}}},G={Shallow:e=>{let{rootStates:a,val_status:r}=e,t=r.dataValue||"";J(()=>{w.scope(()=>ae(void 0,null,function*(){if(!a.multiline)return;let h=w('[data-input-origin="'+r.componentID+'"]'),b=w('[data-input-shallow="'+r.componentID+'"]'),k=w('[data-input-min-height-value-shallow="'+r.componentID+'"]'),T=w('[data-input-max-height-value-shallow="'+r.componentID+'"]');if(!h[0]||!b[0]||!k[0]||!T[0])return;let d=b.position(),C=k.position(),A=T.position(),R=0;a.autoHeight&&(R=d.height),R=Math.max(R,C.height),R=Math.min(R,A.height),h[0].style.height=R+"px"}))},[t]);let n=t||"";(!!t.match(/\n$/)||!t)&&(n+="T");let c="",i="";if(a.multiline){let h=a.minRows||1,b=a.maxRows||100;c=`
2
- T`.repeat(h-1),i=`
3
- T`.repeat(b-1)}let m=Se(a);return $(V,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:[o(Y.Description,s(l({className:a.className},m),{position:"absolute",width:1,freeCSS:s(l({},m.freeCSS),{color:"orange"}),"data-input-shallow":r.componentID,children:o(V,{"data-input-value-shallow":r.componentID,children:n})})),o(Y.Description,s(l({className:a.className},m),{position:"absolute",left:0,freeCSS:s(l({},m.freeCSS),{backgroundColor:"transparent",color:"blue"}),"data-input-min-height-value-shallow":r.componentID,children:c})),o(Y.Description,s(l({className:a.className},m),{position:"absolute",right:0,freeCSS:s(l({},m.freeCSS),{backgroundColor:"transparent",color:"red"}),"data-input-max-height-value-shallow":r.componentID,children:i}))]})},InputBox:e=>{let{rootStates:a,val_validate:r,set_validate:t,val_status:n,set_status:u,val_focus:c,set_focus:i,val_isComposing:m,set_isComposing:h}=e;if(a.multiline)return null;let ee=a,{componentID:b,tone:k,required:T,restrict:d="text",form:C,autoComplete:A="off",autoCapitalize:R="off",minRows:oe,maxRows:re,multiline:X,autoHeight:se,enableFormSubmit:U,clearButton:P=!1,checkValidationAtFirst:B,onChange:K,onKeyDown:W,onValidate:ue,onUpdateValue:me,onUpdateValidValue:pe,value:ce="",leftIndicator:de,rightIndicator:fe,leftIcon:ge,rightIcon:x,maxLength:xe,min:E,max:I,label:j,isLabelActive:Q,wrapStyles:_e}=ee,p=q(ee,["componentID","tone","required","restrict","form","autoComplete","autoCapitalize","minRows","maxRows","multiline","autoHeight","enableFormSubmit","clearButton","checkValidationAtFirst","onChange","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","maxLength","min","max","label","isLabelActive","wrapStyles"]),he=d=="password"||d=="concealed"?"password":"text",be=["number","digitNumber","creditCard"].includes(d)?"numeric":d=="email"?"email":"text";return o(V,s(l({htmlTag:"input",type:he,inputMode:be,"data-disabled":a.disabled,"data-show-validation":M.isShowValidation(r,n,!!B),"data-component-id":n.componentID,"data-input-origin":n.componentID,value:n.formatValue,autoComplete:A,autoCapitalize:R,onKeyDown:f=>{let{key:v,target:F}=f;{let y=F,{selectionStart:N,selectionEnd:H}=y,z=Number(N),te=Number(H),Z=n.formatValue[Number(z)],O=n.formatValue[Number(z)-1];v=="Delete"&&(d=="creditCard"&&Z==" "||d=="postal"&&Z=="-"||d=="digitNumber"&&Z==",")&&(y.setSelectionRange(z+1,te+1),f.preventDefault()),v=="Backspace"&&(d=="creditCard"&&O==" "||d=="postal"&&O=="-"||d=="digitNumber"&&O==",")&&(y.setSelectionRange(z-1,te-1),f.preventDefault()),v=="Enter"||v=="Tab"}if(["number","digitNumber","creditCard"].includes(d)&&v=="Clear"&&u(y=>s(l({},y),{dataValue:"",formatValue:"",eventType:"update",eventID:_()})),["number","digitNumber"].includes(d)&&["ArrowUp","ArrowDown"].includes(v)){let y=+(v=="ArrowUp")*2-1,N=String(Number(n.dataValue)+y);r.ok&&t({ok:!1,notice:[]}),u(H=>s(l(l({},H),D.Validation.DataLeveling({min:E,max:I,restrict:d,value:N})),{eventType:"update",eventID:_()})),f.preventDefault()}W&&W(f),U&&M.SubmitForm(f,C)},onChange:f=>{let{value:v,selectionStart:F,selectionEnd:y}=f.target,N=D.Validation.DataLeveling({min:E,max:I,restrict:d,value:v});m&&(N.formatValue=v),N.formatValue!=n.formatValue&&(r.ok&&t({ok:!1,notice:[]}),u(H=>s(l(l({},H),N),{prevValue:n.formatValue,eventType:"update",eventID:_(),caretFrom:Number(F),caretTo:Number(y)})),K&&K(f))},width:1},p),{onFocus:f=>{p!=null&&p.onFocus&&(p==null||p.onFocus(f)),i(!0)},onBlur:f=>{p!=null&&p.onBlur&&(p==null||p.onBlur(f)),i(!1)},onCompositionStart:f=>{p!=null&&p.onCompositionStart&&(p==null||p.onCompositionStart(f)),h(!0)},onCompositionEnd:f=>{if(p!=null&&p.onCompositionEnd&&(p==null||p.onCompositionEnd(f)),d=="text")return;let v=D.Validation.DataLeveling({min:E,max:I,restrict:d,value:n.formatValue});u(F=>s(l(l({},F),v),{prevValue:F.formatValue,eventType:"update",eventID:_(),caretFrom:Number(F.formatValue.length+1),caretTo:Number(F.formatValue.length+1)})),h(!1)}}))},TextAreaBox:e=>{let{rootStates:a,val_focus:r,set_focus:t,val_validate:n,set_validate:u,val_status:c,set_status:i,isShallow:m}=e,E=a,{componentID:h,tone:b,required:k,form:T,label:d,isLabelActive:C,minRows:A,maxRows:R,multiline:oe,autoHeight:re,enableFormSubmit:X,maxLength:se,checkValidationAtFirst:U,onChange:P,onKeyDown:B,onValidate:K,onUpdateValue:W,onUpdateValidValue:ue,value:me="",leftIndicator:pe,rightIndicator:ce,leftIcon:de,rightIcon:fe,wrapStyles:ge}=E,x=q(E,["componentID","tone","required","form","label","isLabelActive","minRows","maxRows","multiline","autoHeight","enableFormSubmit","maxLength","checkValidationAtFirst","onChange","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","wrapStyles"]);return!a.multiline?null:o(V,s(l({htmlTag:"textarea","data-show-validation":M.isShowValidation(n,c,!!U),"data-input-origin":c.componentID,"data-component-id":c.componentID,value:c.dataValue,width:1},x),{onFocus:I=>{x!=null&&x.onFocus&&(x==null||x.onFocus(I)),t(!0)},onBlur:I=>{x!=null&&x.onBlur&&(x==null||x.onBlur(I)),t(!1)},onKeyDown:I=>{B&&B(I),X&&M.SubmitForm(I,T)},onChange:I=>{let{value:j}=I.target;n.ok&&u({ok:!1,notice:[]}),i(Q=>s(l({},Q),{dataValue:j,eventType:"update",eventID:_()})),P&&P(I)}}))}},Ne=e=>{let{componentID:a,restrict:r="text",value:t="",min:n,max:u}=e,[c,i]=L(!1),[m,h]=L(!1),[b,k]=L(s(l({componentID:a},D.Validation.DataLeveling({min:n,max:u,restrict:r,value:t})),{prevValue:"",eventType:"init",eventID:_(),caretFrom:null,caretTo:null})),[T,d]=L({ok:!1,notice:[]}),C={rootStates:e,val_focus:c,set_focus:i,val_isComposing:m,set_isComposing:h,val_status:b,set_status:k,val_validate:T,set_validate:d};return M.CommonEffects({type:"textfield",states:e,val_status:b,set_status:k,val_validate:T,set_validate:d,SystemValidation:D.Validation.System,ExtraOverrideStates:l({},D.Validation.DataLeveling({min:n,max:u,restrict:r,value:t}))}),J(()=>{D.setSelection({id:e.id,restrict:r,val_status:b})},[b]),$(we,{val_status:b,set_status:k,val_validate:T,states:C.rootStates,children:[o(De,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:e.isLabelActive||c||!!b.dataValue}),o(G.Shallow,l({},C)),o(G.InputBox,l({},C)),o(G.TextAreaBox,l({},C))]})},S=e=>(e=l({autoHeight:!0,restrict:"text",fontSize:"inherit"},e),e.multiline?(e.minRows=e.minRows||5,e.maxRows=e.maxRows||20):(e.minRows=1,e.maxRows=1),o(ye,{componentID:e.componentID,children:Ne,states:Ve(e)})),g=S;g.Validate=D.Validation.Text,g.Katakana=e=>o(S,s(l({},e),{restrict:"katakana",multiline:!1,autoHeight:!1})),g.HankakuKatakana=e=>o(S,s(l({},e),{restrict:"hankaku.katakana",multiline:!1,autoHeight:!1})),g.CreditCard=e=>o(S,s(l({},e),{restrict:"creditCard",multiline:!1,autoHeight:!1})),g.Tel=e=>o(S,s(l({},e),{restrict:"tel",multiline:!1,autoHeight:!1})),g.Number=e=>o(S,s(l({},e),{restrict:"number",multiline:!1,autoHeight:!1})),g.DigitNumber=e=>o(S,s(l({},e),{restrict:"digitNumber",multiline:!1,autoHeight:!1})),g.Email=e=>o(S,s(l({},e),{restrict:"email",multiline:!1,autoHeight:!1})),g.Url=e=>o(S,s(l({},e),{restrict:"url",multiline:!1,autoHeight:!1})),g.Postal=e=>{let[a]=L(_());return J(()=>()=>{Ie.delete(a)},[]),o(S,s(l({label:"\u90F5\u4FBF\u756A\u53F7"},e),{restrict:"postal",multiline:!1,autoHeight:!1,leftIcon:o(ke,{ssSphere:2,fontColor:"4.thin",children:"\u3012"})}))},g.Password=e=>o(S,s(l({label:"\u30D1\u30B9\u30EF\u30FC\u30C9",rightIcon:o(ne,{ssSphere:2,padding:0,freeCSS:{pointerEvents:"all"},children:o(Ce.Sub,{ssSphere:2,borderRadius:"3.tone.tertiary",fontColor:"theme",flexCenter:!0,height:1,ssEffectsOnActive:["expand"],onMouseOver:a=>{ie.open(a.currentTarget,"\u30C6\u30AD\u30B9\u30C8\u3092\u8868\u793A",24)},onMouseLeave:ie.abort,tabIndex:-1,onClick:a=>{w(a.target).parent().parent().find("input").callback(r=>{let t=r[0];t.type=t.type==="password"?"text":"password"})},children:o(Te,{icon:Re})})}),restrict:"password"},e),{multiline:!1,autoHeight:!1})),g.Concealed=e=>o(g.Password,s(l({label:"\u79D8\u5BC6\u9375"},e),{restrict:"concealed"})),g.Money={JPY:e=>o(g.DigitNumber,s(l({rightIcon:o(ne,{ssSphere:2,fontColor:"4.thin",children:"\u5186"})},e),{multiline:!1,autoHeight:!1}))};export{g as TextField,Ne as TextInput,g as default};
1
+ import{b as l,c as m,d as Y,e as te}from"../../chunk-C5N2D3ZX.js";import{Fragment as le,jsx as n,jsxs as K}from"react/jsx-runtime";import b,{UUID as H,useStore as Ie}from"jmini";import{useState as Z,useEffect as G}from"react";import{$$fromRoot as ve,ExtractStyles as Te}from"../../@utils";import{Box as F,FAI as Ce}from"../../atoms";import{Text as X}from"../../mols";import{Tips as ae,Button as we}from"..";import{faEye as Re}from"@fortawesome/free-solid-svg-icons/faEye";import{OptionalInputWrapper as ye,BoxWrapper as Ve,CoreEffects as U,DefaultBoxishStyles as De}from"./core";import{InputLabel as ke}from"./Label";import{LeftIcon as Ne,RightIcon as ie}from".";const Fe={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:K(le,{children:[n(F,{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(F,{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:K(le,{children:[n(F,{children:"0\u304B\u3089\u59CB\u307E\u308B\u756A\u53F7\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"}),n(F,{children:"9~12\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),n(F,{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"}},R={setSelection:e=>{let{id:a,restrict:o,val_status:r}=e,i=ve("#"+a)[0];if(i&&r.prevValue&&r.formatValue){let{formatValue:t,prevValue:d,caretFrom:u,caretTo:s}=r;if(o=="creditCard")t.length>=d.length&&u%5==0&&(u++,s++),i.setSelectionRange(u,s);else if(o=="postal")t.length==5&&d.length==3&&(u++,s++),i.setSelectionRange(u,s);else if(o=="digitNumber"){let g=t.length-d.length;g==2&&(u++,s++),g==-2&&(u--,s--),i.setSelectionRange(u,s)}}},Validation:{System:e=>{let{value:a,states:o}=e,{restrict:r="text",maxLength:i,multiline:t,required:d}=o,u=[];if(t||(i=i||255),b.is.exist(i)&&a.length>=Number(i)&&u.push({type:"invalid",label:i+"\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),a){let s=R.Validation.Text(a,r);s.ok||u.push({type:"invalid",label:s.body})}else d&&u.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"});return{ok:!u.filter(({type:s})=>s=="invalid").length,notice:u}},Text:(e,a)=>{let o={ok:!0,body:""};return(()=>{let r=Fe[a];if(!r)return;let i=r.reason;if(r){let t=!!(+!!e.match(r.reg)^+!r.exist);o={ok:t,body:t?"":i}}})(),o},DataLeveling:e=>{let{restrict:a,allowDecimals:o,allowZeroStart:r,value:i=""}=e,t=String(i);["tel","number","digitNumber","test","postal","creditCard"].includes(a)&&(t=t.zen2hanNumber()),a=="katakana",a=="hankaku.katakana",["postal","creditCard"].includes(a)&&(t=t.removeLetters()),b.scope(()=>{if(!["number","digitNumber"].includes(a))return;t=t.replace(/(\.\d+)\..*/g,"$1").replace(/\.+/g,".").replace(/[^0-9.-]/g,"");let u=Number(t)<0||t[0]=="-";t=t.replace(/[^0-9.]/g,""),u&&(t="-"+t),o||(t=t.replace(/\.\d?/g,"")),b.scope(()=>{a=="number"&&(r||(t=t.replace(/^0(\d+)/g,"$1").replace(/^-0(\d+)/g,"-$1")))}),b.scope(()=>{let s=t.slice(-1);t&&s!="."&&s!="-"&&(b.is.exist(e.min)&&(t=String(Math.max(Number(t),Number(e.min)))),b.is.exist(e.max)&&(t=String(Math.min(Number(t),Number(e.max)))))}),b.scope(()=>{if(!t||t=="-"||a!="digitNumber")return;let s=Number(t)<0,g=String(Math.abs(Math.round(Number(t)))),T=t.split("."),V=[];for(let f=g.length-1;f>=0;f--){V.unshift(g[f]);let c=g.length-1-f+1;f!=0&&c%3==0&&V.unshift(",")}t=V.join(""),s&&(t="-"+t),(T==null?void 0:T.length)==2&&(t+="."+T[1]||"")})});let d=t;return a=="digitNumber"||(a=="postal"?t.length>=4&&(d=t.clip(0,3)+"-"+t.clip(3)):a=="creditCard"&&(d=t.replace(/.{4}(?=.)/g,"$& "))),{formatValue:d,dataValue:t}}},Shallow:e=>{let{rootStates:a,val_status:o}=e,r=o.dataValue||"";G(()=>{b.scope(()=>te(void 0,null,function*(){if(!a.multiline)return;let g=b('[data-input-origin="'+o.componentID+'"]'),T=b('[data-input-shallow="'+o.componentID+'"]'),V=b('[data-input-min-height-value-shallow="'+o.componentID+'"]'),f=b('[data-input-max-height-value-shallow="'+o.componentID+'"]');if(!g[0]||!T[0]||!V[0]||!f[0])return;let c=T.position(),_=V.position(),M=f.position(),S=0;a.autoHeight&&(S=c.height),S=Math.max(S,_.height),S=Math.min(S,M.height),g[0].style.height=S+"px"}))},[r]);let i=r||"";(!!r.match(/\n$/)||!r)&&(i+="T");let d="",u="";if(a.multiline){let g=a.minRows||1,T=a.maxRows||100;d=`
2
+ T`.repeat(g-1),u=`
3
+ T`.repeat(T-1)}let s=Te(a);return K(F,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:[n(X.Description,m(l({className:a.className},s),{position:"absolute",width:1,freeCSS:m(l({},s.freeCSS),{color:"orange"}),"data-input-shallow":o.componentID,children:n(F,{"data-input-value-shallow":o.componentID,children:i})})),n(X.Description,m(l({className:a.className},s),{position:"absolute",left:0,freeCSS:m(l({},s.freeCSS),{backgroundColor:"transparent",color:"blue"}),"data-input-min-height-value-shallow":o.componentID,children:d})),n(X.Description,m(l({className:a.className},s),{position:"absolute",right:0,freeCSS:m(l({},s.freeCSS),{backgroundColor:"transparent",color:"red"}),"data-input-max-height-value-shallow":o.componentID,children:u}))]})},InputBox:e=>{let{rootStates:a,val_validate:o,set_validate:r,val_status:i,set_status:t,val_focus:d,set_focus:u,val_isComposing:s,set_isComposing:g}=e;if(a.multiline)return null;let ee=a,{componentID:T,tone:V,required:f,restrict:c="text",form:_,autoComplete:M="off",autoCapitalize:S="off",minRows:ne,maxRows:oe,multiline:re,autoHeight:se,enableFormSubmit:W,clearButton:ue=!1,allowDecimals:$,allowZeroStart:L,checkValidationAtFirst:P,onChange:O,onKeyDown:q,onValidate:me,onUpdateValue:ce,onUpdateValidValue:pe,value:de="",leftIndicator:fe,rightIndicator:ge,leftIcon:xe,rightIcon:I,maxLength:he,min:B,max:C,label:j,isLabelActive:Q,wrapStyles:Ee}=ee,p=Y(ee,["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","wrapStyles"]),be=c=="password"||c=="concealed"?"password":"text",Se=["number","digitNumber","creditCard"].includes(c)?"numeric":c=="email"?"email":"text";return n(F,m(l({htmlTag:"input",type:be,inputMode:Se,"data-disabled":a.disabled,"data-show-validation":U.isShowValidation(o,i,!!P),"data-component-id":i.componentID,"data-input-origin":i.componentID,value:i.formatValue,autoComplete:M,autoCapitalize:S,onKeyDown:x=>{let{key:w,target:E}=x;{let D=E,{selectionStart:k,selectionEnd:v}=D,A=Number(k),z=Number(v),N=i.formatValue[Number(A)],J=i.formatValue[Number(A)-1];w=="Delete"&&(c=="creditCard"&&N==" "||c=="postal"&&N=="-"||c=="digitNumber"&&N==",")&&(D.setSelectionRange(A+1,z+1),x.preventDefault()),w=="Backspace"&&(c=="creditCard"&&J==" "||c=="postal"&&J=="-"||c=="digitNumber"&&J==",")&&(D.setSelectionRange(A-1,z-1),x.preventDefault()),w=="Enter"||w=="Tab"}b.scope(()=>{["number","digitNumber","creditCard"].includes(c)&&w=="Clear"&&t(D=>m(l({},D),{dataValue:"",formatValue:"",eventType:"update",eventID:H()}))}),b.scope(()=>{var z;if(!["number","digitNumber"].includes(c)||!["ArrowUp","ArrowDown"].includes(w))return;let D=+(w=="ArrowUp")*2-1,k=i.dataValue.slice(-1),v=i.dataValue,A=((z=i.dataValue.split(".")[1])==null?void 0:z.length)||0;if(!k)v+="0";else if(k=="-")v+="0";else if(k==".")v+="0";else if(A){let N=Number(k)+D;v=v.slice(0,-1),N<0?v+="9":N>9?v+="0":v+=String(N)}else v=String(Number(i.dataValue.replace(/,/g,""))+D);o.ok&&r({ok:!1,notice:[]}),t(N=>m(l(l({},N),R.Validation.DataLeveling({allowDecimals:$,allowZeroStart:L,min:B,max:C,restrict:c,value:v})),{eventType:"update",eventID:H()})),x.preventDefault()}),q&&q(x),W&&U.SubmitForm(x,_)},onChange:x=>{let{value:w,selectionStart:E,selectionEnd:D}=x.target,k=R.Validation.DataLeveling({allowDecimals:$,allowZeroStart:L,min:B,max:C,restrict:c,value:w});s&&(k.formatValue=w),k.formatValue!=i.formatValue&&(o.ok&&r({ok:!1,notice:[]}),t(v=>m(l(l({},v),k),{prevValue:i.formatValue,eventType:"update",eventID:H(),caretFrom:Number(E),caretTo:Number(D)})),O&&O(x))},width:1},p),{onFocus:x=>{p!=null&&p.onFocus&&(p==null||p.onFocus(x)),u(!0)},onBlur:x=>{p!=null&&p.onBlur&&(p==null||p.onBlur(x)),u(!1)},onCompositionStart:x=>{p!=null&&p.onCompositionStart&&(p==null||p.onCompositionStart(x)),g(!0)},onCompositionEnd:x=>{if(p!=null&&p.onCompositionEnd&&(p==null||p.onCompositionEnd(x)),c=="text")return;let w=R.Validation.DataLeveling({allowDecimals:$,allowZeroStart:L,min:B,max:C,restrict:c,value:i.formatValue});t(E=>m(l(l({},E),w),{prevValue:E.formatValue,eventType:"update",eventID:H(),caretFrom:Number(E.formatValue.length+1),caretTo:Number(E.formatValue.length+1)})),g(!1)}}))},TextAreaBox:e=>{let{rootStates:a,val_focus:o,set_focus:r,val_validate:i,set_validate:t,val_status:d,set_status:u,isShallow:s}=e,B=a,{componentID:g,tone:T,required:V,form:f,label:c,isLabelActive:_,minRows:M,maxRows:S,multiline:ne,autoHeight:oe,allowDecimals:re,allowZeroStart:se,enableFormSubmit:W,maxLength:ue,checkValidationAtFirst:$,onChange:L,onKeyDown:P,onValidate:O,onUpdateValue:q,onUpdateValidValue:me,value:ce="",leftIndicator:pe,rightIndicator:de,leftIcon:fe,rightIcon:ge,wrapStyles:xe}=B,I=Y(B,["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","wrapStyles"]);return!a.multiline?null:n(F,m(l({htmlTag:"textarea","data-show-validation":U.isShowValidation(i,d,!!$),"data-input-origin":d.componentID,"data-component-id":d.componentID,value:d.dataValue,width:1},I),{onFocus:C=>{I!=null&&I.onFocus&&(I==null||I.onFocus(C)),r(!0)},onBlur:C=>{I!=null&&I.onBlur&&(I==null||I.onBlur(C)),r(!1)},onKeyDown:C=>{P&&P(C),W&&U.SubmitForm(C,f)},onChange:C=>{let{value:j}=C.target;i.ok&&t({ok:!1,notice:[]}),u(Q=>m(l({},Q),{dataValue:j,eventType:"update",eventID:H()})),L&&L(C)}}))}},_e=e=>{let{componentID:a,restrict:o="text",value:r="",min:i,max:t,allowDecimals:d,allowZeroStart:u}=e,[s,g]=Z(!1),[T,V]=Z(!1),[f,c]=Z(m(l({componentID:a},R.Validation.DataLeveling({allowDecimals:d,allowZeroStart:u,min:i,max:t,restrict:o,value:r})),{prevValue:"",eventType:"init",eventID:H(),caretFrom:null,caretTo:null})),[_,M]=Z({ok:!1,notice:[]}),S={rootStates:e,val_focus:s,set_focus:g,val_isComposing:T,set_isComposing:V,val_status:f,set_status:c,val_validate:_,set_validate:M};return U.CommonEffects({type:"textfield",states:e,val_status:f,set_status:c,val_validate:_,set_validate:M,SystemValidation:R.Validation.System,ExtraOverrideStates:l({},R.Validation.DataLeveling({allowDecimals:d,allowZeroStart:u,min:i,max:t,restrict:o,value:r}))}),G(()=>{R.setSelection({id:e.id,restrict:o,val_status:f})},[f]),K(Ve,{val_status:f,set_status:c,val_validate:_,states:S.rootStates,children:[n(ke,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:e.isLabelActive||s||!!f.dataValue}),n(R.Shallow,l({},S)),n(R.InputBox,l({},S)),n(R.TextAreaBox,l({},S))]})},y=e=>(e=l({autoHeight:!0,restrict:"text",fontSize:"inherit"},e),e.multiline?(e.minRows=e.minRows||5,e.maxRows=e.maxRows||20):(e.minRows=1,e.maxRows=1),n(ye,{componentID:e.componentID,children:_e,states:De(e)})),h=y;h.Validate=R.Validation.Text,h.Katakana=e=>n(y,m(l({},e),{restrict:"katakana",multiline:!1,autoHeight:!1})),h.HankakuKatakana=e=>n(y,m(l({},e),{restrict:"hankaku.katakana",multiline:!1,autoHeight:!1})),h.CreditCard=e=>n(y,m(l({},e),{restrict:"creditCard",multiline:!1,autoHeight:!1})),h.Tel=e=>n(y,m(l({},e),{restrict:"tel",multiline:!1,autoHeight:!1})),h.Number=e=>n(y,m(l({},e),{restrict:"number",multiline:!1,autoHeight:!1})),h.DigitNumber=e=>n(y,m(l({},e),{restrict:"digitNumber",multiline:!1,autoHeight:!1})),h.Email=e=>n(y,m(l({},e),{restrict:"email",multiline:!1,autoHeight:!1})),h.Url=e=>n(y,m(l({},e),{restrict:"url",multiline:!1,autoHeight:!1})),h.Postal=e=>{let[a]=Z(H());return G(()=>()=>{Ie.delete(a)},[]),n(y,m(l({label:"\u90F5\u4FBF\u756A\u53F7"},e),{restrict:"postal",multiline:!1,autoHeight:!1,leftIcon:n(Ne,{ssSphere:2,fontColor:"4.thin",children:"\u3012"})}))},h.Password=e=>n(y,m(l({label:"\u30D1\u30B9\u30EF\u30FC\u30C9",rightIcon:n(ie,{ssSphere:2,padding:0,freeCSS:{pointerEvents:"all"},children:n(we.Sub,{ssSphere:2,borderRadius:"3.tone.tertiary",fontColor:"theme",flexCenter:!0,height:1,ssEffectsOnActive:["expand"],onMouseOver:a=>{ae.open(a.currentTarget,"\u30C6\u30AD\u30B9\u30C8\u3092\u8868\u793A",24)},onMouseLeave:ae.abort,tabIndex:-1,onClick:a=>{b(a.target).parent().parent().find("input").callback(o=>{let r=o[0];r.type=r.type==="password"?"text":"password"})},children:n(Ce,{icon:Re})})}),restrict:"password"},e),{multiline:!1,autoHeight:!1})),h.Concealed=e=>n(h.Password,m(l({label:"\u79D8\u5BC6\u9375"},e),{restrict:"concealed"})),h.Money={JPY:e=>n(h.DigitNumber,m(l({rightIcon:n(ie,{ssSphere:2,fontColor:"4.thin",children:"\u5186"})},e),{multiline:!1,autoHeight:!1}))};export{h as TextField,_e as TextInput,h as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amotify",
3
- "version": "0.2.135",
3
+ "version": "0.2.136",
4
4
  "description": "UI Component for React,NextJS,esbuild",
5
5
  "scripts": {
6
6
  "start": "run-p clean build:*",