amotify 0.2.229 → 0.2.230
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.
|
@@ -96,6 +96,7 @@ let Page = () => {
|
|
|
96
96
|
// let [ val_value,set_value ] = useState( 'DFF' )
|
|
97
97
|
|
|
98
98
|
let [ val_value,set_value ] = useState( '' )
|
|
99
|
+
let [ val_data,set_data ] = useState<any>( null )
|
|
99
100
|
|
|
100
101
|
let [ val_checked1,set_checked1 ] = useState( false )
|
|
101
102
|
let [ val_checked2,set_checked2 ] = useState( true )
|
|
@@ -132,7 +133,7 @@ let Page = () => {
|
|
|
132
133
|
val_value { val_value || "null" }
|
|
133
134
|
</Literal>
|
|
134
135
|
|
|
135
|
-
<Input.TextField
|
|
136
|
+
<Input.TextField.Money.JPY
|
|
136
137
|
override='force'
|
|
137
138
|
value={ val_value || void 0 }
|
|
138
139
|
// options={ [
|
|
@@ -140,10 +141,15 @@ let Page = () => {
|
|
|
140
141
|
// { value: select2,label: "option2" },
|
|
141
142
|
// { value: select3,label: "option3" }
|
|
142
143
|
// ] }
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
onUserAction={ ( value,event ) => {
|
|
145
|
+
console.log( event )
|
|
146
|
+
set_data( $$.Stringify( event ) )
|
|
147
|
+
set_value( value || '' )
|
|
145
148
|
} }
|
|
146
149
|
/>
|
|
150
|
+
<Literal.Description>
|
|
151
|
+
{ $$.Stringify( val_data ) }
|
|
152
|
+
</Literal.Description>
|
|
147
153
|
{/* <Column>
|
|
148
154
|
<Input.Checker
|
|
149
155
|
override='force'
|
|
@@ -244,72 +250,6 @@ let Page = () => {
|
|
|
244
250
|
>
|
|
245
251
|
Image Picker
|
|
246
252
|
</Button.Prime>
|
|
247
|
-
|
|
248
|
-
<Grid.Layout
|
|
249
|
-
gap={ 1 }
|
|
250
|
-
gridTemplateColumns={ 'repeat(3,1fr)' }
|
|
251
|
-
gridTemplateRows={ 'repeat(2,auto)' }
|
|
252
|
-
gridChildTemplates={ [
|
|
253
|
-
[ 0,0 ],
|
|
254
|
-
[ 0,0 ],
|
|
255
|
-
[ 0,'span 2' ],
|
|
256
|
-
|
|
257
|
-
[ 0,0 ],
|
|
258
|
-
[ 0,0 ],
|
|
259
|
-
|
|
260
|
-
[ 0,'span 2' ],
|
|
261
|
-
[ 0,0 ],
|
|
262
|
-
[ 0,0 ],
|
|
263
|
-
[ 0,0 ],
|
|
264
|
-
[ 0,0 ],
|
|
265
|
-
] }
|
|
266
|
-
>
|
|
267
|
-
{
|
|
268
|
-
Array.from( { length: 16 } )
|
|
269
|
-
.map( ( _,i ) => {
|
|
270
|
-
return <Box
|
|
271
|
-
key={ i }
|
|
272
|
-
ssCardBox
|
|
273
|
-
position='relative'
|
|
274
|
-
flexCenter
|
|
275
|
-
>
|
|
276
|
-
<Img
|
|
277
|
-
showExpand
|
|
278
|
-
src={ imgaeUrl }
|
|
279
|
-
/>
|
|
280
|
-
<Literal.Paragraph
|
|
281
|
-
position='absolute'
|
|
282
|
-
bottom={ 1 }
|
|
283
|
-
left={ 1 }
|
|
284
|
-
ssSphere={ 3 }
|
|
285
|
-
backgroundColor='posi'
|
|
286
|
-
>
|
|
287
|
-
{ i + 1 }
|
|
288
|
-
</Literal.Paragraph>
|
|
289
|
-
</Box>
|
|
290
|
-
} )
|
|
291
|
-
}
|
|
292
|
-
</Grid.Layout>
|
|
293
|
-
|
|
294
|
-
{/* <Box
|
|
295
|
-
backgroundColor='cloud'
|
|
296
|
-
unitWidth={ 4 }
|
|
297
|
-
freeCSS={ {
|
|
298
|
-
height: '150vh',
|
|
299
|
-
} }
|
|
300
|
-
>
|
|
301
|
-
asdf
|
|
302
|
-
</Box> */}
|
|
303
|
-
|
|
304
|
-
<Img
|
|
305
|
-
showExpand
|
|
306
|
-
src={ imgaeUrl }
|
|
307
|
-
/>
|
|
308
|
-
|
|
309
|
-
{ val_dataurl && <Img
|
|
310
|
-
showExpand
|
|
311
|
-
src={ val_dataurl }
|
|
312
|
-
/> }
|
|
313
253
|
</Column>
|
|
314
254
|
</Plate>
|
|
315
255
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{b as n,c as r,d as ae,e as ue}from"../../chunk-C5N2D3ZX.js";import{Fragment as de,jsx as s,jsxs as Y}from"react/jsx-runtime";import b,{UUID as C,useStore as ce}from"jmini";import{useState as ie,useEffect as ne}from"react";import{$$fromRoot as De,ExtractStyles as ke}from"../../@utils";import{Box as D,FAI as Ne}from"../../atoms";import{Literal as le}from"../../mols";import{Tips as
|
|
2
|
-
T`.repeat(
|
|
3
|
-
T`.repeat(x-1)}let o=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,r(n({className:a.className},o),{position:"absolute",width:1,freeCSS:r(n({},o.freeCSS),{color:"orange"}),"data-input-shallow":l.componentId,children:s(D,{"data-input-value-shallow":l.componentId,children:i})})),s(le.Description,r(n({className:a.className},o),{position:"absolute",left:0,freeCSS:r(n({},o.freeCSS),{backgroundColor:"transparent",color:"blue"}),"data-input-min-height-value-shallow":l.componentId,children:f})),s(le.Description,r(n({className:a.className},o),{position:"absolute",right:0,freeCSS:r(n({},o.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:c,val_status:i,set_status:e,val_inputType:f,set_inputType:g}=t;if(a.multiline)return null;let re=a,{componentId:o,tone:m,required:x,restrict:u="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:he,onUpdateValue:Ie,onUpdateValidValue:Se,onUserAction:ve,value:Te="",leftIndicator:Ce,rightIndicator:Re,leftIcon:ye,rightIcon:we,maxLength:p,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,r(n({htmlTag:"input",type:f,inputMode:["number","digitNumber","creditCard"].includes(u)?"numeric":u=="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:I=>{let{key:h,target:w}=I,M=w,{selectionStart:P,selectionEnd:j}=M,q=Number(P),Z=Number(j);{let _=i.formatValue[Number(q)],H=i.formatValue[Number(q)-1];h=="Delete"&&(u=="creditCard"&&_==" "||u=="postal"&&_=="-"||u=="digitNumber"&&_==",")&&(M.setSelectionRange(q+1,Z+1),I.preventDefault()),h=="Backspace"&&(u=="creditCard"&&H==" "||u=="postal"&&H=="-"||u=="digitNumber"&&H==",")&&(M.setSelectionRange(q-1,Z-1),I.preventDefault()),h=="Enter"||h=="Tab"}b.scope(()=>{["number","digitNumber","creditCard"].includes(u)&&h=="Clear"&&e(_=>r(n({},_),{dataValue:"",formatValue:"",eventType:"update",eventID:C(),isFocusing:!0}))}),b.scope(()=>{if(!["number","digitNumber"].includes(u)||!["ArrowUp","ArrowDown"].includes(h))return;let _=+(h=="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&&c({ok:!1,notice:[]}),e(te=>r(n(n({},te),T.Validation.DataLeveling({allowDecimals:z,allowZeroStart:A,min:O,max:B,restrict:u,value:V})),{eventType:"update",eventID:C(),isFocusing:!0})),I.preventDefault()}),Q&&Q(I),G&&K.SubmitForm(I,E)},onChange:I=>{let{value:h,selectionStart:w,selectionEnd:M}=I.target,P=T.Validation.DataLeveling({allowDecimals:z,allowZeroStart:A,min:O,max:B,restrict:u,value:h});i.isComposing&&(P.formatValue=h),P.formatValue!=i.formatValue&&(l.ok&&c({ok:!1,notice:[]}),e(j=>r(n(n({},j),P),{prevValue:i.formatValue,eventType:"update",eventID:C(),caretFrom:Number(w),caretTo:Number(M),isFocusing:!0})),X&&X(I))},width:1},d),{onFocus:I=>{d!=null&&d.onFocus&&(d==null||d.onFocus(I)),e(h=>r(n({},h),{eventID:C(),isFocusing:!0}))},onBlur:I=>{d!=null&&d.onBlur&&(d==null||d.onBlur(I)),e(h=>r(n({},h),{eventID:C(),isFocusing:!1}))},onCompositionStart:I=>{d!=null&&d.onCompositionStart&&(d==null||d.onCompositionStart(I)),e(h=>r(n({},h),{eventID:C(),isComposing:!0}))},onCompositionEnd:I=>{if(d!=null&&d.onCompositionEnd&&(d==null||d.onCompositionEnd(I)),u=="text"){b.interval.once(()=>{e(w=>r(n({},w),{isComposing:!1}))},100,"input.textfield.composing.end");return}let h=T.Validation.DataLeveling({allowDecimals:z,allowZeroStart:A,min:O,max:B,restrict:u,value:i.formatValue});e(w=>r(n(n({},w),h),{prevValue:w.formatValue,eventType:"update",eventID:C(),caretFrom:Number(w.formatValue.length+1),caretTo:Number(w.formatValue.length+1),isComposing:!1}))}}))},TextAreaBox:t=>{let{rootStates:a,val_validate:l,set_validate:c,val_status:i,set_status:e,isShallow:f}=t,B=a,{componentId:g,tone:o,required:m,form:x,label:u,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:he,onUserAction:Ie,value:Se="",leftIndicator:ve,rightIndicator:Te,leftIcon:Ce,rightIcon:Re,defaultValidation:ye,wrapStyles:we}=B,p=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,r(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},p),{onFocus:v=>{p!=null&&p.onFocus&&(p==null||p.onFocus(v)),e(y=>r(n({},y),{eventID:C(),isFocusing:!0}))},onBlur:v=>{p!=null&&p.onBlur&&(p==null||p.onBlur(v)),e(y=>r(n({},y),{eventID:C(),isFocusing:!1}))},onCompositionStart:v=>{p!=null&&p.onCompositionStart&&(p==null||p.onCompositionStart(v)),e(y=>r(n({},y),{eventID:C(),isComposing:!0}))},onCompositionEnd:v=>{p!=null&&p.onCompositionEnd&&(p==null||p.onCompositionEnd(v)),b.interval.once(()=>{e(y=>r(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&&c({ok:!1,notice:[]}),e(oe=>r(n({},oe),{dataValue:y,eventType:"update",eventID:C(),isFocusing:!0})),A&&A(v)}}))}},ze=t=>{let{componentId:a,restrict:l="text",value:c="",min:i,max:e,allowDecimals:f,allowZeroStart:g}=t,[o,m]=ie(r(n({componentId:a},T.Validation.DataLeveling({allowDecimals:f,allowZeroStart:g,min:i,max:e,restrict:l,value:c})),{prevValue:"",eventType:"init",eventID:C(),caretFrom:null,caretTo:null})),[x,u]=ie({ok:!1,notice:[]}),[E,L]=ie(["password","concealed"].includes(l)&&"password"||"text");ne(()=>{m($=>n(n({},$),T.Validation.DataLeveling({allowDecimals:f,allowZeroStart:g,min:i,max:e,restrict:l,value:c}))),ce.set({[a+":set_inputType"]:L})},[]);let F={rootStates:t,val_inputType:E,set_inputType:L,val_status:o,set_status:m,val_validate:x,set_validate:u};return K.CommonEffects({type:"textfield",states:t,val_status:o,set_status:m,val_validate:x,set_validate:u,SystemValidation:T.Validation.System,ExtraOverrideStates:()=>T.Validation.DataLeveling({allowDecimals:f,allowZeroStart:g,min:i,max:e,restrict:l,value:c})}),ne(()=>{T.setSelection({id:t.id,restrict:l,val_status:o})},[o]),Y(He,{val_status:o,set_status:m,val_validate:x,states:F.rootStates,children:[s(Be,{componentId:t.componentId,fontSize:t.fontSize,required:t.required,label:t.label,isActive:t.isLabelActive||!!o.isFocusing||!!o.dataValue}),s(T.Shallow,n({},F)),s(T.InputBox,n({},F)),s(T.TextAreaBox,n({},F))]})},R=t=>(t=n({autoHeight:!0,restrict:"text",fontSize:"inherit",value:""},t),t.value=T.Validation.DataLeveling({allowDecimals:t.allowDecimals,allowZeroStart:t.allowZeroStart,min:t.min,max:t.max,restrict:t.restrict||"text",value:t.value||""}).dataValue||"",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,r(n({},t),{restrict:"katakana",multiline:!1,autoHeight:!1})),S.HankakuKatakana=t=>s(R,r(n({},t),{restrict:"hankaku.katakana",multiline:!1,autoHeight:!1})),S.CreditCard=t=>s(R,r(n({},t),{restrict:"creditCard",multiline:!1,autoHeight:!1})),S.Tel=t=>s(R,r(n({},t),{restrict:"tel",multiline:!1,autoHeight:!1})),S.Number=t=>s(R,r(n({},t),{restrict:"number",multiline:!1,autoHeight:!1})),S.DigitNumber=t=>s(R,r(n({},t),{restrict:"digitNumber",multiline:!1,autoHeight:!1})),S.Email=t=>s(R,r(n({},t),{restrict:"email",multiline:!1,autoHeight:!1})),S.Url=t=>s(R,r(n({},t),{restrict:"url",multiline:!1,autoHeight:!1})),S.Postal=t=>s(R,r(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,r(n({label:"\u30D1\u30B9\u30EF\u30FC\u30C9",rightIcon:s(pe,{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=>{me.open(a.currentTarget,"\u30C6\u30AD\u30B9\u30C8\u3092\u8868\u793A",24)},onMouseLeave:me.abort,tabIndex:-1,onClick:a=>{b(a.target).parent().parent().find("input").callback(l=>{let c=l[0];if(!c)return;let i=c.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,r(n({label:"\u79D8\u5BC6\u9375"},t),{restrict:"concealed"})),S.Money={JPY:t=>s(S.DigitNumber,r(n({rightIcon:s(pe,{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 r,d as ae,e as ue}from"../../chunk-C5N2D3ZX.js";import{Fragment as de,jsx as s,jsxs as Y}from"react/jsx-runtime";import b,{UUID as C,useStore as ce}from"jmini";import{useState as ie,useEffect as ne}from"react";import{$$fromRoot as De,ExtractStyles as ke}from"../../@utils";import{Box as D,FAI as Ne}from"../../atoms";import{Literal as le}from"../../mols";import{Tips as pe,Button as Ee}from"..";import{faEye as Le}from"@fortawesome/free-solid-svg-icons/faEye";import{OptionalInputWrapper as _e,BoxWrapper as He,CoreEffects as K,DefaultBoxishStyles as Ae}from"./core";import{InputLabel as Be}from"./Label";import{LeftIcon as Me,RightIcon as me}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(de,{children:[s(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"}),s(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:Y(de,{children:[s(D,{children:"0\u304B\u3089\u59CB\u307E\u308B\u756A\u53F7\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"}),s(D,{children:"9~12\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),s(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"}},T={setSelection:t=>{let{id:a,restrict:l,val_status:u}=t,i=De("#"+a)[0];if(!i||!u.prevValue||!u.formatValue||!u.isFocusing||!u.isComposing)return;let{formatValue:e,prevValue:f,caretFrom:g,caretTo:o}=u;if(l=="creditCard")e.length>=f.length&&g%5==0&&(g++,o++),i.setSelectionRange(g,o);else if(l=="postal")e.length==5&&f.length==3&&(g++,o++),i.setSelectionRange(g,o);else if(l=="digitNumber"){let p=e.length-f.length;p==2&&(g++,o++),p==-2&&(g--,o--),i.setSelectionRange(g,o)}},Validation:{System:t=>{let{value:a,states:l}=t,{restrict:u="text",defaultValidation:i,maxLength:e,multiline:f,required:g}=l,o=[];if(f||(e=e||255),b.is.exist(e)&&a.length>=Number(e)&&o.push({type:"invalid",label:e+"\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),a){let p=T.Validation.Text(a,u,i);p.ok||o.push({type:"invalid",label:p.body})}else g&&o.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"});return{ok:!o.filter(({type:p})=>p=="invalid").length,notice:o}},Text:(t,a,l)=>{let u={ok:!0,body:""};return(()=>{let i=l||$e[a];if(!i)return;let e=i.reason;if(i){let f=!!(+!!t.match(i.reg)^+!i.exist);u={ok:f,body:f?"":e}}})(),u},DataLeveling:t=>{let{restrict:a,allowDecimals:l,allowZeroStart:u,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 g=Number(e)<0||e[0]=="-";e=e.replace(/[^0-9.]/g,""),g&&(e="-"+e);let o=Number(l);l?e=e.replace(/(\.\d{0,})\..*/g,"$1").replace(/\.(\d{0,})/g,(p,x)=>x.length>o?"."+x.slice(0,o):p):e=e.replace(/\.\d?/g,""),b.scope(()=>{a=="number"&&(u||(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:x,max:c}=t;b.is.exist(x)&&b.is.number(x)&&Number(e)<Number(x)&&(e=String(x.toFixed(o))),b.is.exist(c)&&b.is.number(c)&&Number(e)>Number(c)&&(e=String(c.toFixed(o)))}),b.scope(()=>{if(!e||e=="-"||a!="digitNumber")return;let p=e.slice(-1),[x,c]=e.split(".");e=x.replace(/\B(?=(\d{3})+(?!\d))/g,","),c&&(e+="."+c),p=="."&&(e+=".")})});let f=e;return a=="digitNumber"||(a=="postal"?e.length>=4&&(f=e.clip(0,3)+"-"+e.clip(3)):a=="creditCard"&&(f=e.replace(/.{4}(?=.)/g,"$& "))),(a=="digitNumber"||a=="number")&&(e=e.replace(/,/g,"")),{formatValue:f,dataValue:e}}},Shallow:t=>{let{rootStates:a,val_status:l}=t,u=l.dataValue||"";ne(()=>{b.scope(()=>ue(void 0,null,function*(){if(!a.multiline)return;let p=b('[data-input-origin="'+l.componentId+'"]'),x=b('[data-input-shallow="'+l.componentId+'"]'),c=b('[data-input-min-height-value-shallow="'+l.componentId+'"]'),E=b('[data-input-max-height-value-shallow="'+l.componentId+'"]');if(!p[0]||!x[0]||!c[0]||!E[0])return;let L=x.position(),F=c.position(),$=E.position(),k=0;a.autoHeight&&(k=L.height),k=Math.max(k,F.height),k=Math.min(k,$.height),p[0].style.height=k+"px"}))},[u]);let i=u||"";(!!u.match(/\n$/)||!u)&&(i+="T");let f="",g="";if(a.multiline){let p=a.minRows||1,x=a.maxRows||100;f=`
|
|
2
|
+
T`.repeat(p-1),g=`
|
|
3
|
+
T`.repeat(x-1)}let o=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,r(n({className:a.className},o),{position:"absolute",width:1,freeCSS:r(n({},o.freeCSS),{color:"orange"}),"data-input-shallow":l.componentId,children:s(D,{"data-input-value-shallow":l.componentId,children:i})})),s(le.Description,r(n({className:a.className},o),{position:"absolute",left:0,freeCSS:r(n({},o.freeCSS),{backgroundColor:"transparent",color:"blue"}),"data-input-min-height-value-shallow":l.componentId,children:f})),s(le.Description,r(n({className:a.className},o),{position:"absolute",right:0,freeCSS:r(n({},o.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:o,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:he,onUpdateValue:Ie,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,r(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:I=>{let{key:h,target:w}=I,M=w,{selectionStart:P,selectionEnd:j}=M,q=Number(P),Z=Number(j);{let _=i.formatValue[Number(q)],H=i.formatValue[Number(q)-1];h=="Delete"&&(c=="creditCard"&&_==" "||c=="postal"&&_=="-"||c=="digitNumber"&&_==",")&&(M.setSelectionRange(q+1,Z+1),I.preventDefault()),h=="Backspace"&&(c=="creditCard"&&H==" "||c=="postal"&&H=="-"||c=="digitNumber"&&H==",")&&(M.setSelectionRange(q-1,Z-1),I.preventDefault()),h=="Enter"||h=="Tab"}b.scope(()=>{["number","digitNumber","creditCard"].includes(c)&&h=="Clear"&&e(_=>r(n({},_),{dataValue:"",formatValue:"",eventType:"update",eventID:C(),isFocusing:!0}))}),b.scope(()=>{if(!["number","digitNumber"].includes(c)||!["ArrowUp","ArrowDown"].includes(h))return;let _=+(h=="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=>r(n(n({},te),T.Validation.DataLeveling({allowDecimals:z,allowZeroStart:A,min:O,max:B,restrict:c,value:V})),{eventType:"update",eventID:C(),isFocusing:!0})),I.preventDefault()}),Q&&Q(I),G&&K.SubmitForm(I,E)},onChange:I=>{let{value:h,selectionStart:w,selectionEnd:M}=I.target,P=T.Validation.DataLeveling({allowDecimals:z,allowZeroStart:A,min:O,max:B,restrict:c,value:h});i.isComposing&&(P.formatValue=h),P.formatValue!=i.formatValue&&(l.ok&&u({ok:!1,notice:[]}),e(j=>r(n(n({},j),P),{prevValue:i.formatValue,eventType:"update",eventID:C(),caretFrom:Number(w),caretTo:Number(M),isFocusing:!0})),X&&X(I))},width:1},d),{onFocus:I=>{d!=null&&d.onFocus&&(d==null||d.onFocus(I)),e(h=>r(n({},h),{eventID:C(),isFocusing:!0}))},onBlur:I=>{d!=null&&d.onBlur&&(d==null||d.onBlur(I)),e(h=>r(n({},h),{eventID:C(),isFocusing:!1}))},onCompositionStart:I=>{d!=null&&d.onCompositionStart&&(d==null||d.onCompositionStart(I)),e(h=>r(n({},h),{eventID:C(),isComposing:!0}))},onCompositionEnd:I=>{if(d!=null&&d.onCompositionEnd&&(d==null||d.onCompositionEnd(I)),c=="text"){b.interval.once(()=>{e(w=>r(n({},w),{isComposing:!1}))},100,"input.textfield.composing.end");return}let h=T.Validation.DataLeveling({allowDecimals:z,allowZeroStart:A,min:O,max:B,restrict:c,value:i.formatValue});e(w=>r(n(n({},w),h),{prevValue:w.formatValue,eventType:"update",eventID:C(),caretFrom:Number(w.formatValue.length+1),caretTo:Number(w.formatValue.length+1),isComposing:!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:o,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:he,onUserAction:Ie,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,r(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=>r(n({},y),{eventID:C(),isFocusing:!0}))},onBlur:v=>{m!=null&&m.onBlur&&(m==null||m.onBlur(v)),e(y=>r(n({},y),{eventID:C(),isFocusing:!1}))},onCompositionStart:v=>{m!=null&&m.onCompositionStart&&(m==null||m.onCompositionStart(v)),e(y=>r(n({},y),{eventID:C(),isComposing:!0}))},onCompositionEnd:v=>{m!=null&&m.onCompositionEnd&&(m==null||m.onCompositionEnd(v)),b.interval.once(()=>{e(y=>r(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=>r(n({},oe),{dataValue:y,eventType:"update",eventID:C(),isFocusing:!0})),A&&A(v)}}))}},ze=t=>{let{componentId:a,restrict:l="text",value:u="",min:i,max:e,allowDecimals:f,allowZeroStart:g}=t,[o,p]=ie(r(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($=>n(n({},$),T.Validation.DataLeveling({allowDecimals:f,allowZeroStart:g,min:i,max:e,restrict:l,value:u}))),ce.set({[a+":set_inputType"]:L})},[]);let F={rootStates:t,val_inputType:E,set_inputType:L,val_status:o,set_status:p,val_validate:x,set_validate:c};return K.CommonEffects({type:"textfield",states:t,val_status:o,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:o})},[o]),Y(He,{val_status:o,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||!!o.isFocusing||!!o.dataValue}),s(T.Shallow,n({},F)),s(T.InputBox,n({},F)),s(T.TextAreaBox,n({},F))]})},R=t=>(t=n({autoHeight:!0,restrict:"text",fontSize:"inherit",value:""},t),t.value=T.Validation.DataLeveling({allowDecimals:t.allowDecimals,allowZeroStart:t.allowZeroStart,min:t.min,max:t.max,restrict:t.restrict||"text",value:t.value||""}).dataValue||"",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,r(n({},t),{restrict:"katakana",multiline:!1,autoHeight:!1})),S.HankakuKatakana=t=>s(R,r(n({},t),{restrict:"hankaku.katakana",multiline:!1,autoHeight:!1})),S.CreditCard=t=>s(R,r(n({},t),{restrict:"creditCard",multiline:!1,autoHeight:!1})),S.Tel=t=>s(R,r(n({},t),{restrict:"tel",multiline:!1,autoHeight:!1})),S.Number=t=>s(R,r(n({},t),{restrict:"number",multiline:!1,autoHeight:!1})),S.DigitNumber=t=>s(R,r(n({},t),{restrict:"digitNumber",multiline:!1,autoHeight:!1})),S.Email=t=>s(R,r(n({},t),{restrict:"email",multiline:!1,autoHeight:!1})),S.Url=t=>s(R,r(n({},t),{restrict:"url",multiline:!1,autoHeight:!1})),S.Postal=t=>s(R,r(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,r(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,r(n({label:"\u79D8\u5BC6\u9375"},t),{restrict:"concealed"})),S.Money={JPY:t=>s(S.DigitNumber,r(n({rightIcon:s(me,{fontColor:"4.thin",children:"\u5186"})},t),{multiline:!1,autoHeight:!1}))};export{S as TextField,ze as TextInput,S as default};
|