amotify 0.2.208 → 0.2.209
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/next/next.config.ts +1 -0
- package/demo/next/src/app/(router)/page.tsx +60 -8
- package/dist/fn/Input/CollectForm.js +1 -1
- 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 -0
- package/dist/fn/Input/core.js +1 -1
- package/dist/fn/Input/index.d.ts +1 -0
- package/dist/fn/Input/index.js +1 -1
- package/package.json +1 -1
package/demo/next/next.config.ts
CHANGED
|
@@ -82,13 +82,22 @@ const SheetContent = () => {
|
|
|
82
82
|
|
|
83
83
|
let Page = () => {
|
|
84
84
|
let [ val_selected,set_selected ] = useState<any>( 0 )
|
|
85
|
-
let [ val_value,set_value ] = useState( '' )
|
|
85
|
+
let [ val_value,set_value ] = useState( 'df' )
|
|
86
86
|
let [ val_caret,set_caret ] = useState<any>( [ 0,0 ] )
|
|
87
87
|
|
|
88
88
|
let [ val_refresh,set_refresh ] = useState( UUID() )
|
|
89
89
|
let [ val_replyText,set_replyText ] = useState( '' )
|
|
90
90
|
|
|
91
91
|
useEffect( () => {
|
|
92
|
+
$$.scope( async () => {
|
|
93
|
+
return
|
|
94
|
+
let form = await Input.CollectForm( 'form_test' )
|
|
95
|
+
console.log(
|
|
96
|
+
'[form]',
|
|
97
|
+
form,form.data
|
|
98
|
+
)
|
|
99
|
+
} )
|
|
100
|
+
|
|
92
101
|
// setTimeout( () => {
|
|
93
102
|
// set_selected( 'B' )
|
|
94
103
|
// set_value( 'BBB' )
|
|
@@ -111,21 +120,64 @@ let Page = () => {
|
|
|
111
120
|
<Input.TextField
|
|
112
121
|
form='form_test'
|
|
113
122
|
name='testInput'
|
|
114
|
-
|
|
123
|
+
override='force'
|
|
115
124
|
value={ val_value }
|
|
116
125
|
required
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
126
|
+
// onValidate={ async () => {
|
|
127
|
+
// await $$.pending( () => { },1000 )
|
|
128
|
+
|
|
129
|
+
// return { ok: true,notice: [] }
|
|
130
|
+
// } }
|
|
131
|
+
onUserAction={ ( value,opt ) => {
|
|
132
|
+
// console.log(
|
|
133
|
+
// '[onUserAction]',value,opt
|
|
134
|
+
// )
|
|
135
|
+
// set_value( value )
|
|
121
136
|
} }
|
|
122
|
-
|
|
137
|
+
onUpdateValue={ ( value,opt ) => {
|
|
123
138
|
// console.log(
|
|
124
|
-
// '[
|
|
139
|
+
// '[onUpdateValue]',value,opt
|
|
140
|
+
// )
|
|
141
|
+
// set_value( value )
|
|
142
|
+
} }
|
|
143
|
+
onUpdateValidValue={ ( value,opt ) => {
|
|
144
|
+
// console.log(
|
|
145
|
+
// '[onUpdateValidValue]',value,opt
|
|
125
146
|
// )
|
|
126
147
|
// set_value( value )
|
|
127
148
|
} }
|
|
128
149
|
/>
|
|
150
|
+
|
|
151
|
+
{/* <Input.Time.DateWareki
|
|
152
|
+
form='form_test'
|
|
153
|
+
name='dateInput'
|
|
154
|
+
override='force'
|
|
155
|
+
value={ "2025/09/12" }
|
|
156
|
+
required
|
|
157
|
+
// onValidate={ async () => {
|
|
158
|
+
// await $$.pending( () => { },1000 )
|
|
159
|
+
|
|
160
|
+
// return { ok: true,notice: [] }
|
|
161
|
+
// } }
|
|
162
|
+
onUserAction={ ( value,opt ) => {
|
|
163
|
+
// console.log(
|
|
164
|
+
// '[onUserAction]',value,opt
|
|
165
|
+
// )
|
|
166
|
+
// set_value( value )
|
|
167
|
+
} }
|
|
168
|
+
onUpdateValue={ ( value,opt ) => {
|
|
169
|
+
// console.log(
|
|
170
|
+
// '[onUpdateValue]',value,opt
|
|
171
|
+
// )
|
|
172
|
+
// set_value( value )
|
|
173
|
+
} }
|
|
174
|
+
onUpdateValidValue={ ( value,opt ) => {
|
|
175
|
+
// console.log(
|
|
176
|
+
// '[onUpdateValidValue]',value,opt
|
|
177
|
+
// )
|
|
178
|
+
// set_value( value )
|
|
179
|
+
} }
|
|
180
|
+
/> */}
|
|
129
181
|
</Box>
|
|
130
182
|
<Button.Prime
|
|
131
183
|
submitOption={ {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as
|
|
1
|
+
import{e as r}from"../../chunk-C5N2D3ZX.js";import u,{useStore as t}from"jmini";const p=o=>r(void 0,null,function*(){let i={},n="form-process-"+o;if(t.get(n))return console.log("[CollectForm] already processing..."),{valid:!1,data:{}};t.set({[n]:!0});let s=1;return yield u.pending(()=>{},100),yield u.scope(()=>r(void 0,null,function*(){let m=document.activeElement;m&&m.blur();let c=t.get(["form-data",o].join("-"));if(c){for(let[l,a]of Object.entries(c)){if(!a)continue;let e=t.get(a.componentId);e&&e.Refresh&&(yield e.Refresh())}{let l=t.get(["form-data",o].join("-"));if(!l)return;for(let[a,e]of Object.entries(l))e&&(s&=Number(e.validation),i[a]=e.value)}}})),console.log("fvsdafv"),t.set({[n]:!1}),{valid:!!s,data:i}});export{p as CollectForm,p as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{b as i,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 T,useStore as pe}from"jmini";import{useState as ie,useEffect as ne}from"react";import{$$fromRoot as ke,ExtractStyles as De}from"../../@utils";import{Box as k,FAI as Ne}from"../../atoms";import{Literal as le}from"../../mols";import{Tips as ce,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(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"}),s(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(de,{children:[s(k,{children:"0\u304B\u3089\u59CB\u307E\u308B\u756A\u53F7\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"}),s(k,{children:"9~12\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),s(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"}},C={setSelection:t=>{let{id:n,restrict:
|
|
2
|
-
T`.repeat(c-1),
|
|
3
|
-
T`.repeat(g-1)}let l=De(n);return Y(k,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:[s(le.Description,r(i({className:n.className},l),{position:"absolute",width:1,freeCSS:r(i({},l.freeCSS),{color:"orange"}),"data-input-shallow":o.componentId,children:s(k,{"data-input-value-shallow":o.componentId,children:a})})),s(le.Description,r(i({className:n.className},l),{position:"absolute",left:0,freeCSS:r(i({},l.freeCSS),{backgroundColor:"transparent",color:"blue"}),"data-input-min-height-value-shallow":o.componentId,children:f})),s(le.Description,r(i({className:n.className},l),{position:"absolute",right:0,freeCSS:r(i({},l.freeCSS),{backgroundColor:"transparent",color:"red"}),"data-input-max-height-value-shallow":o.componentId,children:x}))]})},InputBox:t=>{let{rootStates:n,val_validate:o,set_validate:p,val_status:a,set_status:e,val_inputType:f,set_inputType:x}=t;if(n.multiline)return null;let re=n,{componentId:l,tone:c,required:g,restrict:u="text",form:E,autoComplete:L="off",autoCapitalize:F="off",minRows:$,maxRows:D,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(k,r(i({htmlTag:"input",type:f,inputMode:["number","digitNumber","creditCard"].includes(u)?"numeric":u=="email"?"email":"text","data-disabled":n.disabled,"data-show-validation":K.isShowValidation(o,a,!!W),"data-component-id":a.componentId,"data-input-origin":a.componentId,value:a.formatValue,autoComplete:L,autoCapitalize:F,onKeyDown:I=>{let{key:h,target:w}=I,M=w,{selectionStart:P,selectionEnd:j}=M,q=Number(P),U=Number(j);{let _=a.formatValue[Number(q)],H=a.formatValue[Number(q)-1];h=="Delete"&&(u=="creditCard"&&_==" "||u=="postal"&&_=="-"||u=="digitNumber"&&_==",")&&(M.setSelectionRange(q+1,U+1),I.preventDefault()),h=="Backspace"&&(u=="creditCard"&&H==" "||u=="postal"&&H=="-"||u=="digitNumber"&&H==",")&&(M.setSelectionRange(q-1,U-1),I.preventDefault()),h=="Enter"||h=="Tab"}b.scope(()=>{["number","digitNumber","creditCard"].includes(u)&&h=="Clear"&&e(_=>r(i({},_),{dataValue:"",formatValue:"",eventType:"update",eventID:T(),isFocusing:!0}))}),b.scope(()=>{if(!["number","digitNumber"].includes(u)||!["ArrowUp","ArrowDown"].includes(h))return;let _=+(h=="ArrowUp")*2-1,H=a.dataValue.slice(-1),se=a.formatValue[U-1],N=U-1,V=String(a.formatValue),ee=a.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(U==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 Z=V[N].toNumber()+_;Z<0?Z=9:Z>=10&&(Z=0),V=V.partReplace(N,String(Z)),setTimeout(()=>{M.setSelectionRange(N+1,N+1)},1)}),o.ok&&p({ok:!1,notice:[]}),e(te=>r(i(i({},te),C.Validation.DataLeveling({allowDecimals:z,allowZeroStart:A,min:O,max:B,restrict:u,value:V})),{eventType:"update",eventID:T(),isFocusing:!0})),I.preventDefault()}),Q&&Q(I),G&&K.SubmitForm(I,E)},onChange:I=>{let{value:h,selectionStart:w,selectionEnd:M}=I.target,P=C.Validation.DataLeveling({allowDecimals:z,allowZeroStart:A,min:O,max:B,restrict:u,value:h});a.isComposing&&(P.formatValue=h),P.formatValue!=a.formatValue&&(o.ok&&p({ok:!1,notice:[]}),e(j=>r(i(i({},j),P),{prevValue:a.formatValue,eventType:"update",eventID:T(),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(i({},h),{eventID:T(),isFocusing:!0}))},onBlur:I=>{d!=null&&d.onBlur&&(d==null||d.onBlur(I)),e(h=>r(i({},h),{eventID:T(),isFocusing:!1}))},onCompositionStart:I=>{d!=null&&d.onCompositionStart&&(d==null||d.onCompositionStart(I)),e(h=>r(i({},h),{eventID:T(),isComposing:!0}))},onCompositionEnd:I=>{if(d!=null&&d.onCompositionEnd&&(d==null||d.onCompositionEnd(I)),u=="text"){b.interval.once(()=>{e(w=>r(i({},w),{isComposing:!1}))},100,"input.textfield.composing.end");return}let h=C.Validation.DataLeveling({allowDecimals:z,allowZeroStart:A,min:O,max:B,restrict:u,value:a.formatValue});e(w=>r(i(i({},w),h),{prevValue:w.formatValue,eventType:"update",eventID:T(),caretFrom:Number(w.formatValue.length+1),caretTo:Number(w.formatValue.length+1),isComposing:!1}))}}))},TextAreaBox:t=>{let{rootStates:n,val_validate:o,set_validate:p,val_status:a,set_status:e,isShallow:f}=t,B=n,{componentId:x,tone:l,required:c,form:g,label:u,isLabelActive:E,minRows:L,maxRows:F,multiline:$,autoHeight:D,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!n.multiline?null:s(k,r(i({htmlTag:"textarea","data-show-validation":K.isShowValidation(o,a,!!z),"data-input-origin":a.componentId,"data-component-id":a.componentId,value:a.dataValue,width:1},m),{onFocus:v=>{m!=null&&m.onFocus&&(m==null||m.onFocus(v)),e(y=>r(i({},y),{eventID:T(),isFocusing:!0}))},onBlur:v=>{m!=null&&m.onBlur&&(m==null||m.onBlur(v)),e(y=>r(i({},y),{eventID:T(),isFocusing:!1}))},onCompositionStart:v=>{m!=null&&m.onCompositionStart&&(m==null||m.onCompositionStart(v)),e(y=>r(i({},y),{eventID:T(),isComposing:!0}))},onCompositionEnd:v=>{m!=null&&m.onCompositionEnd&&(m==null||m.onCompositionEnd(v)),b.interval.once(()=>{e(y=>r(i({},y),{eventID:T(),isComposing:!1}))},100,"input.textfield.composing.end")},onKeyDown:v=>{W&&W(v),G&&K.SubmitForm(v,g)},onChange:v=>{let{value:y}=v.target;o.ok&&p({ok:!1,notice:[]}),e(oe=>r(i({},oe),{dataValue:y,eventType:"update",eventID:T(),isFocusing:!0})),A&&A(v)}}))}},ze=t=>{let{componentId:n,restrict:o="text",value:p="",min:a,max:e,allowDecimals:f,allowZeroStart:x}=t,[l,c]=ie({componentId:n,formatValue:"",dataValue:"",prevValue:"",eventType:"init",eventID:T(),caretFrom:null,caretTo:null}),[g,u]=ie({ok:!1,notice:[]}),[E,L]=ie(["password","concealed"].includes(o)&&"password"||"text");ne(()=>{c($=>i(i({},$),C.Validation.DataLeveling({allowDecimals:f,allowZeroStart:x,min:a,max:e,restrict:o,value:p}))),pe.set({[n+":set_inputType"]:L})},[]);let F={rootStates:t,val_inputType:E,set_inputType:L,val_status:l,set_status:c,val_validate:g,set_validate:u};return K.CommonEffects({type:"textfield",states:t,val_status:l,set_status:c,val_validate:g,set_validate:u,SystemValidation:C.Validation.System,ExtraOverrideStates:()=>C.Validation.DataLeveling({allowDecimals:f,allowZeroStart:x,min:a,max:e,restrict:o,value:p})}),ne(()=>{C.setSelection({id:t.id,restrict:o,val_status:l})},[l]),Y(He,{val_status:l,set_status:c,val_validate:g,states:F.rootStates,children:[s(Be,{componentId:t.componentId,fontSize:t.fontSize,required:t.required,label:t.label,isActive:t.isLabelActive||!!l.isFocusing||!!l.dataValue}),s(C.Shallow,i({},F)),s(C.InputBox,i({},F)),s(C.TextAreaBox,i({},F))]})},R=t=>(t=i({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),s(_e,{componentId:t.componentId,children:ze,states:Ae(t)})),S=R;S.Validate=C.Validation.Text,S.Katakana=t=>s(R,r(i({},t),{restrict:"katakana",multiline:!1,autoHeight:!1})),S.HankakuKatakana=t=>s(R,r(i({},t),{restrict:"hankaku.katakana",multiline:!1,autoHeight:!1})),S.CreditCard=t=>s(R,r(i({},t),{restrict:"creditCard",multiline:!1,autoHeight:!1})),S.Tel=t=>s(R,r(i({},t),{restrict:"tel",multiline:!1,autoHeight:!1})),S.Number=t=>s(R,r(i({},t),{restrict:"number",multiline:!1,autoHeight:!1})),S.DigitNumber=t=>s(R,r(i({},t),{restrict:"digitNumber",multiline:!1,autoHeight:!1})),S.Email=t=>s(R,r(i({},t),{restrict:"email",multiline:!1,autoHeight:!1})),S.Url=t=>s(R,r(i({},t),{restrict:"url",multiline:!1,autoHeight:!1})),S.Postal=t=>s(R,r(i({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(i({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:n=>{ce.open(n.currentTarget,"\u30C6\u30AD\u30B9\u30C8\u3092\u8868\u793A",24)},onMouseLeave:ce.abort,tabIndex:-1,onClick:n=>{b(n.target).parent().parent().find("input").callback(o=>{let p=o[0];if(!p)return;let a=p.dataset.componentId;if(!a)return;let e=pe.get(a+":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(i({label:"\u79D8\u5BC6\u9375"},t),{restrict:"concealed"})),S.Money={JPY:t=>s(S.DigitNumber,r(i({rightIcon:s(me,{ssSphere:2,fontColor:"4.thin",children:"\u5186"})},t),{multiline:!1,autoHeight:!1}))};export{S as TextField,ze as TextInput,S as default};
|
|
1
|
+
import{b as i,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 T,useStore as pe}from"jmini";import{useState as ie,useEffect as ne}from"react";import{$$fromRoot as ke,ExtractStyles as De}from"../../@utils";import{Box as k,FAI as Ne}from"../../atoms";import{Literal as le}from"../../mols";import{Tips as ce,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(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"}),s(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(de,{children:[s(k,{children:"0\u304B\u3089\u59CB\u307E\u308B\u756A\u53F7\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"}),s(k,{children:"9~12\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),s(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"}},C={setSelection:t=>{let{id:n,restrict:l,val_status:p}=t,a=ke("#"+n)[0];if(a&&p.prevValue&&p.formatValue){let{formatValue:e,prevValue:f,caretFrom:g,caretTo:o}=p;if(l=="creditCard")e.length>=f.length&&g%5==0&&(g++,o++),a.setSelectionRange(g,o);else if(l=="postal")e.length==5&&f.length==3&&(g++,o++),a.setSelectionRange(g,o);else if(l=="digitNumber"){let c=e.length-f.length;c==2&&(g++,o++),c==-2&&(g--,o--),a.setSelectionRange(g,o)}}},Validation:{System:t=>{let{value:n,states:l}=t,{restrict:p="text",defaultValidation:a,maxLength:e,multiline:f,required:g}=l,o=[];if(f||(e=e||255),b.is.exist(e)&&n.length>=Number(e)&&o.push({type:"invalid",label:e+"\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),n){let c=C.Validation.Text(n,p,a);c.ok||o.push({type:"invalid",label:c.body})}else g&&o.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"});return{ok:!o.filter(({type:c})=>c=="invalid").length,notice:o}},Text:(t,n,l)=>{let p={ok:!0,body:""};return(()=>{let a=l||$e[n];if(!a)return;let e=a.reason;if(a){let f=!!(+!!t.match(a.reg)^+!a.exist);p={ok:f,body:f?"":e}}})(),p},DataLeveling:t=>{let{restrict:n,allowDecimals:l,allowZeroStart:p,value:a=""}=t,e=String(a);["tel","number","digitNumber","postal","creditCard"].includes(n)&&(e=e.zen2hanNumber()),n=="katakana",n=="hankaku.katakana",["postal","creditCard"].includes(n)&&(e=e.removeLetters()),b.scope(()=>{if(!["number","digitNumber"].includes(n))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,(c,x)=>x.length>o?"."+x.slice(0,o):c):e=e.replace(/\.\d?/g,""),b.scope(()=>{n=="number"&&(p||(e=e.replace(/^0(\d+)/g,"$1").replace(/^-0(\d+)/g,"-$1")))}),b.scope(()=>{let c=e.slice(-1);if(!e||c=="."||c=="-")return;let{min:x,max:u}=t;b.is.exist(x)&&b.is.number(x)&&Number(e)<Number(x)&&(e=String(x.toFixed(o))),b.is.exist(u)&&b.is.number(u)&&Number(e)>Number(u)&&(e=String(u.toFixed(o)))}),b.scope(()=>{if(!e||e=="-"||n!="digitNumber")return;let c=e.slice(-1),[x,u]=e.split(".");e=x.replace(/\B(?=(\d{3})+(?!\d))/g,","),u&&(e+="."+u),c=="."&&(e+=".")})});let f=e;return n=="digitNumber"||(n=="postal"?e.length>=4&&(f=e.clip(0,3)+"-"+e.clip(3)):n=="creditCard"&&(f=e.replace(/.{4}(?=.)/g,"$& "))),e=e.replace(/,/g,""),{formatValue:f,dataValue:e}}},Shallow:t=>{let{rootStates:n,val_status:l}=t,p=l.dataValue||"";ne(()=>{b.scope(()=>ue(void 0,null,function*(){if(!n.multiline)return;let c=b('[data-input-origin="'+l.componentId+'"]'),x=b('[data-input-shallow="'+l.componentId+'"]'),u=b('[data-input-min-height-value-shallow="'+l.componentId+'"]'),E=b('[data-input-max-height-value-shallow="'+l.componentId+'"]');if(!c[0]||!x[0]||!u[0]||!E[0])return;let L=x.position(),F=u.position(),$=E.position(),D=0;n.autoHeight&&(D=L.height),D=Math.max(D,F.height),D=Math.min(D,$.height),c[0].style.height=D+"px"}))},[p]);let a=p||"";(!!p.match(/\n$/)||!p)&&(a+="T");let f="",g="";if(n.multiline){let c=n.minRows||1,x=n.maxRows||100;f=`
|
|
2
|
+
T`.repeat(c-1),g=`
|
|
3
|
+
T`.repeat(x-1)}let o=De(n);return Y(k,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:[s(le.Description,r(i({className:n.className},o),{position:"absolute",width:1,freeCSS:r(i({},o.freeCSS),{color:"orange"}),"data-input-shallow":l.componentId,children:s(k,{"data-input-value-shallow":l.componentId,children:a})})),s(le.Description,r(i({className:n.className},o),{position:"absolute",left:0,freeCSS:r(i({},o.freeCSS),{backgroundColor:"transparent",color:"blue"}),"data-input-min-height-value-shallow":l.componentId,children:f})),s(le.Description,r(i({className:n.className},o),{position:"absolute",right:0,freeCSS:r(i({},o.freeCSS),{backgroundColor:"transparent",color:"red"}),"data-input-max-height-value-shallow":l.componentId,children:g}))]})},InputBox:t=>{let{rootStates:n,val_validate:l,set_validate:p,val_status:a,set_status:e,val_inputType:f,set_inputType:g}=t;if(n.multiline)return null;let re=n,{componentId:o,tone:c,required:x,restrict:u="text",form:E,autoComplete:L="off",autoCapitalize:F="off",minRows:$,maxRows:D,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(k,r(i({htmlTag:"input",type:f,inputMode:["number","digitNumber","creditCard"].includes(u)?"numeric":u=="email"?"email":"text","data-disabled":n.disabled,"data-show-validation":K.isShowValidation(l,a,!!W),"data-component-id":a.componentId,"data-input-origin":a.componentId,value:a.formatValue,autoComplete:L,autoCapitalize:F,onKeyDown:I=>{let{key:h,target:w}=I,M=w,{selectionStart:P,selectionEnd:j}=M,q=Number(P),U=Number(j);{let _=a.formatValue[Number(q)],H=a.formatValue[Number(q)-1];h=="Delete"&&(u=="creditCard"&&_==" "||u=="postal"&&_=="-"||u=="digitNumber"&&_==",")&&(M.setSelectionRange(q+1,U+1),I.preventDefault()),h=="Backspace"&&(u=="creditCard"&&H==" "||u=="postal"&&H=="-"||u=="digitNumber"&&H==",")&&(M.setSelectionRange(q-1,U-1),I.preventDefault()),h=="Enter"||h=="Tab"}b.scope(()=>{["number","digitNumber","creditCard"].includes(u)&&h=="Clear"&&e(_=>r(i({},_),{dataValue:"",formatValue:"",eventType:"update",eventID:T(),isFocusing:!0}))}),b.scope(()=>{if(!["number","digitNumber"].includes(u)||!["ArrowUp","ArrowDown"].includes(h))return;let _=+(h=="ArrowUp")*2-1,H=a.dataValue.slice(-1),se=a.formatValue[U-1],N=U-1,V=String(a.formatValue),ee=a.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(U==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 Z=V[N].toNumber()+_;Z<0?Z=9:Z>=10&&(Z=0),V=V.partReplace(N,String(Z)),setTimeout(()=>{M.setSelectionRange(N+1,N+1)},1)}),l.ok&&p({ok:!1,notice:[]}),e(te=>r(i(i({},te),C.Validation.DataLeveling({allowDecimals:z,allowZeroStart:A,min:O,max:B,restrict:u,value:V})),{eventType:"update",eventID:T(),isFocusing:!0})),I.preventDefault()}),Q&&Q(I),G&&K.SubmitForm(I,E)},onChange:I=>{let{value:h,selectionStart:w,selectionEnd:M}=I.target,P=C.Validation.DataLeveling({allowDecimals:z,allowZeroStart:A,min:O,max:B,restrict:u,value:h});a.isComposing&&(P.formatValue=h),P.formatValue!=a.formatValue&&(l.ok&&p({ok:!1,notice:[]}),e(j=>r(i(i({},j),P),{prevValue:a.formatValue,eventType:"update",eventID:T(),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(i({},h),{eventID:T(),isFocusing:!0}))},onBlur:I=>{d!=null&&d.onBlur&&(d==null||d.onBlur(I)),e(h=>r(i({},h),{eventID:T(),isFocusing:!1}))},onCompositionStart:I=>{d!=null&&d.onCompositionStart&&(d==null||d.onCompositionStart(I)),e(h=>r(i({},h),{eventID:T(),isComposing:!0}))},onCompositionEnd:I=>{if(d!=null&&d.onCompositionEnd&&(d==null||d.onCompositionEnd(I)),u=="text"){b.interval.once(()=>{e(w=>r(i({},w),{isComposing:!1}))},100,"input.textfield.composing.end");return}let h=C.Validation.DataLeveling({allowDecimals:z,allowZeroStart:A,min:O,max:B,restrict:u,value:a.formatValue});e(w=>r(i(i({},w),h),{prevValue:w.formatValue,eventType:"update",eventID:T(),caretFrom:Number(w.formatValue.length+1),caretTo:Number(w.formatValue.length+1),isComposing:!1}))}}))},TextAreaBox:t=>{let{rootStates:n,val_validate:l,set_validate:p,val_status:a,set_status:e,isShallow:f}=t,B=n,{componentId:g,tone:o,required:c,form:x,label:u,isLabelActive:E,minRows:L,maxRows:F,multiline:$,autoHeight:D,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!n.multiline?null:s(k,r(i({htmlTag:"textarea","data-show-validation":K.isShowValidation(l,a,!!z),"data-input-origin":a.componentId,"data-component-id":a.componentId,value:a.dataValue,width:1},m),{onFocus:v=>{m!=null&&m.onFocus&&(m==null||m.onFocus(v)),e(y=>r(i({},y),{eventID:T(),isFocusing:!0}))},onBlur:v=>{m!=null&&m.onBlur&&(m==null||m.onBlur(v)),e(y=>r(i({},y),{eventID:T(),isFocusing:!1}))},onCompositionStart:v=>{m!=null&&m.onCompositionStart&&(m==null||m.onCompositionStart(v)),e(y=>r(i({},y),{eventID:T(),isComposing:!0}))},onCompositionEnd:v=>{m!=null&&m.onCompositionEnd&&(m==null||m.onCompositionEnd(v)),b.interval.once(()=>{e(y=>r(i({},y),{eventID:T(),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&&p({ok:!1,notice:[]}),e(oe=>r(i({},oe),{dataValue:y,eventType:"update",eventID:T(),isFocusing:!0})),A&&A(v)}}))}},ze=t=>{let{componentId:n,restrict:l="text",value:p="",min:a,max:e,allowDecimals:f,allowZeroStart:g}=t,[o,c]=ie(r(i({componentId:n},C.Validation.DataLeveling({allowDecimals:f,allowZeroStart:g,min:a,max:e,restrict:l,value:p})),{prevValue:"",eventType:"init",eventID:T(),caretFrom:null,caretTo:null})),[x,u]=ie({ok:!1,notice:[]}),[E,L]=ie(["password","concealed"].includes(l)&&"password"||"text");ne(()=>{c($=>i(i({},$),C.Validation.DataLeveling({allowDecimals:f,allowZeroStart:g,min:a,max:e,restrict:l,value:p}))),pe.set({[n+":set_inputType"]:L})},[]);let F={rootStates:t,val_inputType:E,set_inputType:L,val_status:o,set_status:c,val_validate:x,set_validate:u};return K.CommonEffects({type:"textfield",states:t,val_status:o,set_status:c,val_validate:x,set_validate:u,SystemValidation:C.Validation.System,ExtraOverrideStates:()=>C.Validation.DataLeveling({allowDecimals:f,allowZeroStart:g,min:a,max:e,restrict:l,value:p})}),ne(()=>{C.setSelection({id:t.id,restrict:l,val_status:o})},[o]),Y(He,{val_status:o,set_status:c,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(C.Shallow,i({},F)),s(C.InputBox,i({},F)),s(C.TextAreaBox,i({},F))]})},R=t=>(t=i({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),s(_e,{componentId:t.componentId,children:ze,states:Ae(t)})),S=R;S.Validate=C.Validation.Text,S.Katakana=t=>s(R,r(i({},t),{restrict:"katakana",multiline:!1,autoHeight:!1})),S.HankakuKatakana=t=>s(R,r(i({},t),{restrict:"hankaku.katakana",multiline:!1,autoHeight:!1})),S.CreditCard=t=>s(R,r(i({},t),{restrict:"creditCard",multiline:!1,autoHeight:!1})),S.Tel=t=>s(R,r(i({},t),{restrict:"tel",multiline:!1,autoHeight:!1})),S.Number=t=>s(R,r(i({},t),{restrict:"number",multiline:!1,autoHeight:!1})),S.DigitNumber=t=>s(R,r(i({},t),{restrict:"digitNumber",multiline:!1,autoHeight:!1})),S.Email=t=>s(R,r(i({},t),{restrict:"email",multiline:!1,autoHeight:!1})),S.Url=t=>s(R,r(i({},t),{restrict:"url",multiline:!1,autoHeight:!1})),S.Postal=t=>s(R,r(i({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(i({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:n=>{ce.open(n.currentTarget,"\u30C6\u30AD\u30B9\u30C8\u3092\u8868\u793A",24)},onMouseLeave:ce.abort,tabIndex:-1,onClick:n=>{b(n.target).parent().parent().find("input").callback(l=>{let p=l[0];if(!p)return;let a=p.dataset.componentId;if(!a)return;let e=pe.get(a+":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(i({label:"\u79D8\u5BC6\u9375"},t),{restrict:"concealed"})),S.Money={JPY:t=>s(S.DigitNumber,r(i({rightIcon:s(me,{ssSphere:2,fontColor:"4.thin",children:"\u5186"})},t),{multiline:!1,autoHeight:!1}))};export{S as TextField,ze as TextInput,S as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ie,b as s,c as w,d as K}from"../../../chunk-C5N2D3ZX.js";import{Fragment as Ae,jsx as h,jsxs as se}from"react/jsx-runtime";import ee,{UUID as W,useStore as B}from"jmini";import*as X from"jmini";import{useState as F,useEffect as z,useRef as ue}from"react";import{$$fromRoot as de,Config as ne,ExtractStyles as fe}from"../../../@utils";import{Box as H,FAI as he}from"../../../atoms";import{Literal as ge,Row as ye}from"../../../mols";import{Button as oe}from"../../Button";import ve from"../../Tooltips";import Ie from"../../Sheet";import{faClock as Se}from"@fortawesome/free-solid-svg-icons/faClock";import{faCalendarAlt as Te}from"@fortawesome/free-solid-svg-icons/faCalendarAlt";import{OptionalInputWrapper as De,BoxWrapper as be,CoreEffects as Y,DefaultBoxishStyles as xe}from"../core";import{RightIcon as ke}from"..";import Ee from"../Select";import{InputLabel as we}from"../Label";import Ve from"./Picker";const O=" ~ ",Re={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+O.length,length:4},{type:"month",from:15+O.length,length:2},{type:"date",from:18+O.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+O.length,length:4},{type:"month",from:13+O.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}},P={PeriodMargin:" ~ ",DataLeveling:e=>{let{restrict:r,value:g,era:n}=e,d=ee.flatArray(g||""),{defaultValue:k,format:v,ranges:o,sets:a}=Re[r],S=[],i=r=="clock"&&":"||"/";for(let t=0;t<d.length;t++)d[t]=String(d[t]).replace(/\D/ig,i);for(let t=0;t<a;t++){let p=d[t]||"";if(!p.match(v))d[t]="",S.push(k);else{let T=k;p.split(/\D/).forEach((x,E)=>{if(E==0&&r=="dateWareki"){let I=Number(x);n!="year"&&(I>=2019?n=="reiwa"?I-=2018:n=="heisei"&&(I=31):I>=1989?n=="heisei"?I-=1988:n=="shouwa"&&(I=64):I>=1926?n=="shouwa"?I-=1925:n=="taisho"&&(I=15):I>=1912?n=="taisho"?I-=1911:n=="meiji"&&(I=45):I>=1868&&(I-=1867)),x=I.zeroEmbed(4)}T=T.replace(new RegExp("------------------".slice(0,x.length)),x)}),S.push(T)}}return{formatValue:S.join(O),dataValue:["dates","months"].includes(r)?d:d[0],ranges:o}},SystemValidation:e=>{let{states:r}=e,{restrict:g,min:n,max:d,required:k}=r,v=[],o=ee.flatArray(e.value),a={empty:!1,escalated:1,filled:!0,correct:!0,prohibited:!1};(()=>{let S=g=="clock"&&":"||"/";for(let i=0;i<o.length;i++)o[i]=String(o[i]).replace(/\D/ig,S);for(let i=0;i<o.length;i++){let t=o[i],p=o[i-1];t.removeLetters()||(a.empty=!0),i>0&&(a.escalated&=+(t>=p))}a.escalated&&(a.empty||(g.match(/clock/)?o.forEach(i=>{let[t,p]=i.split(/\D+/);!t||!p?a.filled=!1:(Number(t)>23||Number(p)>59)&&(a.correct=!1)}):g.match(/date/)?o.forEach(i=>{let[t,p,T]=i.split(/\D+/);if(!t||!p||!T)a.filled=!1;else{let x=X.Time(i);(!x.validate||i!=x.toFormatYMD())&&(a.correct=!1)}}):g.match(/week/)?o.forEach(i=>{let[t,p]=i.split(/\D+/);if(!t||!p)a.filled=!1;else{let T=X.Time(t+"/01/01").weekday,E=X.Time(t+"/01/0"+(7-T+1)).addWeek(Number(p)-1);t!=String(E.year)&&(a.correct=!1)}}):g.match(/month/)?o.forEach(i=>{let[t,p]=i.split(/\D+/);!t||!p?a.filled=!1:X.Time([t,p,"01"].join("/")).validate||(a.correct=!1)}):g.match(/year/),a.filled&&a.correct&&o.forEach(i=>{{let t=Number(String(i).replace(/\D/ig,""));if(n&&Number(String(n).replace(/\D/ig,""))>t&&(a.prohibited=!0),d){let p=Number(String(d).replace(/\D/ig,""));t>p&&(a.prohibited=!0)}}})))})();{let{empty:S,escalated:i,filled:t,correct:p,prohibited:T}=a;S&&k&&(v=[{type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}]),i||v.push({type:"invalid",label:"\u6642\u7CFB\u5217\u3092\u6B63\u3057\u304F\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),p||v.push({type:"invalid",label:"\u7121\u52B9\u306A\u5024\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u3059"}),t||v.push({type:"invalid",label:"\u6700\u5F8C\u307E\u3067\u5024\u3092\u57CB\u3081\u3066\u304F\u3060\u3055\u3044"}),T&&v.push({type:"invalid",label:se(Ae,{children:[h(H,{children:"\u5165\u529B\u7BC4\u56F2\u304C\u5236\u9650\u3055\u308C\u3066\u3044\u307E\u3059"}),"[",n||"\u4E0B\u9650\u7121\u3057","] ~ [",d||"\u4E0A\u9650\u7121\u3057","]"]})})}return{ok:!v.filter(({type:S})=>S=="invalid").length,notice:v}},KeyDownEvent:e=>{let{val_era:r,restrict:g,event:n,val_status:d,set_status:k,val_focus:v,set_focus:o}=e,{key:a,shiftKey:S,ctrlKey:i,metaKey:t}=n,p=i||t,{selectionStart:T,selectionEnd:x}=n.target,{index:E,prevIndex:I}=v,{ranges:q,formatValue:G}=d,C=q.length-1;if(["Tab","ArrowLeft","ArrowRight"].includes(a)){let y=0;if(a=="Tab"){let m=+!S*2-1;if(y=v.index+m,y<0||y>C)return}else{let m=a=="ArrowLeft"?-1:a=="ArrowRight"?1:0;p||T==0&&x==String(d.formatValue).length?y=m==1?C:0:y=Math.max(0,Math.min(E+m,C))}o(m=>w(s({},m),{index:y,prevIndex:E})),n.preventDefault()}if(["Backspace","ArrowUp","ArrowDown","0","1","2","3","4","5","6","7","8","9"].includes(a)){n.preventDefault();let y=E;y=Math.max(y,0),y=Math.min(y,C);let{type:m,from:U,length:Q}=q[y],L=G.slice(U,U+Q),D;if(a=="Backspace")D="------".slice(0,Q);else if(["ArrowUp","ArrowDown"].includes(a)){let V=a=="ArrowUp"?1:-1;L=L|0,D=L+V;let[f,u,l]=m=="dateWareki"?r=="year"?[0,2999,4]:r=="reiwa"?[1,2999,4]:r=="heisei"?[1,31,4]:r=="shouwa"?[1,64,4]:r=="taisho"?[1,15,4]:r=="meiji"?[1,45,4]:[0,0,0]:m=="minute"?[0,59,2]:m=="hour"?[0,23,2]:m=="date"?[1,31,2]:m=="week"?[1,53,2]:m=="month"?[1,12,2]:m=="year"?[0,2999,4]:[0,0,0];D>u?D=f:D<f&&(D=u),D=Number(D).zeroEmbed(l)}else if(["0","1","2","3","4","5","6","7","8","9"].includes(a)){let V=L|0,f=a,u=`${V}${f}`;if(I!=E&&(V=0,u="0"+f),m=="year"||m=="dateWareki"&&r=="year")Number(u)>1e4?D=f:D=u,(D|0)>1e3&&y++;else if(["hour","minute","date","week","month"].includes(m)||m=="dateWareki"&&r!="year"){let l=m=="dateWareki"?r=="reiwa"?100:r=="heisei"?31:r=="shouwa"?64:r=="taisho"?15:r=="meiji"?45:0:m=="minute"?59:m=="hour"?23:m=="date"?31:m=="week"?53:m=="month"?12:0;D=(u|0)>l?f:u,(Number(f)>Number(String(l)[0])||L=="0000".slice(0,String(l).length)&&(u!="0000".slice(0,String(l).length)||["minute","hour"].includes(m)&&I==E)||(u|0)>=ie(10,String(l).length-1))&&y++}m=="year"||m=="dateWareki"?D=(D|0).zeroEmbed(4):D=(D|0).zeroEmbed(2)}{let V=String(G).partReplace(U,String(D)),f=V.split(O).map(u=>u.replace(/(^\D|\D$)/,"").split(/\D+/).join(g=="clock"&&":"||"/").replace(/(^\D|\D$)/,""));if(g=="dateWareki"){let u=f[0].split(/\D/),[l,R,M]=u;u.length==3&&l&&(f=[[Number(l)-1+Number({year:1,reiwa:2019,heisei:1989,shouwa:1926,taisho:1912,meiji:1868}[r]),R,M].join("/")])}y=Math.max(y,0),y=Math.min(y,C),k(u=>w(s({},u),{dataValue:["dates","months"].includes(g)?f:f[0],formatValue:V,eventType:"update",eventID:W()})),o(u=>w(s({},u),{index:y,prevIndex:u.index}))}}}},le={picker:{launch:e=>{let r=e.sheetID||W(),p=e,{onValueUpdate:g,min:n,max:d,era:k,restrict:v,defaultValue:o}=p,a=K(p,["onValueUpdate","min","max","era","restrict","defaultValue"]),S=!1,i=null,t=null;Ie.open("middleCenter",w(s({sheetID:r,size:"S",padding:0,closeAtAroundClick:!0,closeAtParentBlur:!1,onClose:()=>{S&&g(i,t,!0)}},a),{content:h(ye.Center,{children:h(Ve,{restrict:v,min:n,max:d,era:k,defaultValue:o,sheetID:r,onValueUpdate:(T,x,E)=>{g(T,x,E),S=!E,i=T,t=x}})})}))},remove:e=>{ve.close(e)}}},_e={Shallow:e=>{let{rootStates:r,val_status:g}=e,n=fe(r);return h(H,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:h(ge.Description,w(s({className:r.className},n),{position:"absolute",width:1,freeCSS:w(s({},n.freeCSS),{color:"orange"}),children:h(H,{"data-input-value-shallow":g.componentId,children:"A"})}))})}},Ce=e=>{let ae=e,{tone:r,required:g,restrict:n="clock",componentId:d,era:k,form:v,name:o,min:a,max:S,className:i,enableFormSubmit:t,checkValidationAtFirst:p,onKeyDown:T,onValidate:x,onValidateDelay:E,onUpdateValue:I,onUpdateValidValue:q,onUserAction:G,value:C="",leftIndicator:y,rightIndicator:m,leftIcon:U,rightIcon:Q,freeCSS:L,wrapStyles:D}=ae,V=K(ae,["tone","required","restrict","componentId","era","form","name","min","max","className","enableFormSubmit","checkValidationAtFirst","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","leftIndicator","rightIndicator","leftIcon","rightIcon","freeCSS","wrapStyles"]),[f,u]=F(k),[l,R]=F({componentId:e.componentId||"",formatValue:"",dataValue:"",ranges:[],eventType:"init",eventID:W()}),[M,Z]=F({ok:!1,notice:[]}),[j,J]=F({active:!1,index:0,prevIndex:-1}),me={rootStates:e,val_status:l,set_status:R,val_validate:M,set_validate:Z,val_era:f,set_era:u,val_focus:j,set_focus:J};Y.CommonEffects({type:"time",states:e,val_status:l,set_status:R,val_validate:M,set_validate:Z,SystemValidation:P.SystemValidation,ExtraOverrideStates:()=>P.DataLeveling({restrict:n,value:C,era:f})}),z(()=>{R(c=>s(s({},c),P.DataLeveling({restrict:n,value:C,era:f})))},[]);const te=ue(!1);return z(()=>{if(te.current){R(b=>s(s({},b),P.DataLeveling({restrict:n,value:b.dataValue,era:f})));let c=B.get("refreshEra_"+l.componentId);c&&c.refreshEra(f)}else te.current=!0},[f]),B.update({[l.componentId]:{openPicker:c=>{e.disabled||le.picker.launch({parent:c,sheetID:"PickerTips-"+l.componentId,restrict:n,min:a,max:S,defaultValue:l.dataValue,era:f,onValueUpdate:(b,A,N)=>{N&&(R($=>w(s(s({},$),P.DataLeveling({restrict:n,value:b,era:A})),{eventType:"update",eventID:W()})),u(A))}})},resetEra:c=>{u(c),R(b=>w(s(s({},b),P.DataLeveling({restrict:n,value:"",era:f})),{eventType:"update",eventID:W()}))}}}),z(()=>{let{index:c,active:b}=j;if(b){c=Math.max(c,0),c=Math.min(c,l.ranges.length-1);let{from:A,length:N}=l.ranges[c],$=de("#"+e.id)[0];$&&$.setSelectionRange(A,A+N)}},[j]),se(be,{val_status:l,set_status:R,val_validate:M,states:e,children:[h(_e.Shallow,s({},me)),h(we,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:!0}),ne.get().isTouchDevice?h(oe.Plain,w(s({"data-show-validation":Y.isShowValidation(M,l,!!p),"data-component-id":l.componentId,"data-input-origin":l.componentId,"data-disabled":e.disabled,className:i,freeCSS:{textAlign:"left"}},V),{children:l.formatValue,onClick:c=>{let b=B.get(l.componentId);b&&b.openPicker(`[data-input-origin="${l.componentId}"]`),c.stopPropagation()}})):h(H,s({htmlTag:"input",type:"text",inputMode:"numeric","data-show-validation":Y.isShowValidation(M,l,!!p),"data-input-origin":l.componentId,"data-disabled":e.disabled,value:l.formatValue,className:i,tabIndex:ne.get().isTouchDevice?-1:0,onKeyDown:c=>{P.KeyDownEvent({restrict:n,event:c,val_era:f,val_status:l,set_status:R,val_focus:j,set_focus:J}),T&&T(c),t&&Y.SubmitForm(c,v)},onKeyUp:c=>{c.key=="Tab"&&J(b=>w(s({},b),{active:!0}))},onClick:c=>{let b=c.target.selectionEnd,A=0;l.ranges.forEach((N,$)=>{let{from:re,length:pe,region:ce}=N;re<=b&&b<=re+(ce||pe)&&(A=$)}),J(N=>w(s({},N),{active:!0,index:A})),c.preventDefault()},onChange:()=>{}},V))]})},_={Origin:e=>{let r=s({fontSize:"inherit",width:1},e),[g]=F(e.componentId||W());if(r.componentId=g,ee.is.nullish(r.rightIcon)){let n=(e.restrict||"").match(/clock/)?Se:Te;r.rightIcon=h(ke,{ssSphere:2,freeCSS:{pointerEvents:"all"},children:h(oe.Sub,{color:"cloud",border:"unset",ssSphere:2,fontColor:"theme",boxShadow:"0.normal",borderRadius:"3.tone.tertiary",flexCenter:!0,ssEffectsOnActive:"push",tabIndex:-1,id:"Picker-"+r.componentId,onClick:()=>{let d=B.get(r.componentId);d&&d.openPicker("#Picker-"+r.componentId)},children:h(he,{icon:n})})})}return h(De,{componentId:r.componentId,children:Ce,states:xe(r)})},Clock:e=>h(_.Origin,s({restrict:"clock",era:"clock"},e)),Date:e=>h(_.Origin,s({restrict:"date"},e)),Week:e=>h(_.Origin,s({restrict:"week"},e)),Month:e=>h(_.Origin,s({restrict:"month"},e)),Year:e=>h(_.Origin,s({restrict:"year"},e)),DateWareki:e=>{e=s({},e);let[r]=F(e.componentId||W());e.componentId=r;let v=e,{defaultEra:g="wareki"}=v,n=K(v,["defaultEra"]),[d,k]=F((()=>{let o="year";if(g=="wareki"&&(o="reiwa",e.value)){let[a,S,i]=e.value.split(/\D/);if(a&&S&&i){let t=Number(a);t>=2019?(t-=2019,o="reiwa"):t>=1989?(t-=1989,o="heisei"):t>=1926?(t-=1926,o="shouwa"):t>=1912?(t-=1912,o="taisho"):t>=1868&&(t-=1868,o="meiji"),t+=1}}return o})());return z(()=>{B.set({["refreshEra_"+r]:{refreshEra:o=>{k(o)}}})},[]),h(_.Origin,w(s({restrict:"dateWareki",leftIndicator:h(Ee,{label:"\u5143\u53F7",emptySelect:!1,value:d,tone:e.tone||"border",override:"force",flexCenter:!0,borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",height:1,freeCSS:{whiteSpace:"nowrap"},options:[{value:"year",label:"\u897F\u66A6"},{value:"reiwa",label:"\u4EE4\u548C"},{value:"heisei",label:"\u5E73\u6210"},{value:"shouwa",label:"\u662D\u548C"},{value:"taisho",label:"\u5927\u6B63"},{value:"meiji",label:"\u660E\u6CBB"}],onUpdateValidValue:o=>{k(o);let a=B.get(e.componentId);a&&a.resetEra&&a.resetEra(o)}})},n),{era:d}))},Periods:{Date:e=>h(_.Origin,s({restrict:"dates"},e)),Month:e=>h(_.Origin,s({restrict:"months"},e))},fn:le};export{_ as Time,_ as default};
|
|
1
|
+
import{a as ie,b as s,c as k,d as K}from"../../../chunk-C5N2D3ZX.js";import{Fragment as Ae,jsx as h,jsxs as se}from"react/jsx-runtime";import ee,{UUID as F,useStore as B}from"jmini";import*as X from"jmini";import{useState as O,useEffect as z,useRef as ue}from"react";import{$$fromRoot as de,Config as ne,ExtractStyles as fe}from"../../../@utils";import{Box as H,FAI as he}from"../../../atoms";import{Literal as ge,Row as ye}from"../../../mols";import{Button as oe}from"../../Button";import ve from"../../Tooltips";import Ie from"../../Sheet";import{faClock as Se}from"@fortawesome/free-solid-svg-icons/faClock";import{faCalendarAlt as Te}from"@fortawesome/free-solid-svg-icons/faCalendarAlt";import{OptionalInputWrapper as De,BoxWrapper as be,CoreEffects as Y,DefaultBoxishStyles as xe}from"../core";import{RightIcon as ke}from"..";import Ee from"../Select";import{InputLabel as we}from"../Label";import Ve from"./Picker";const P=" ~ ",Re={clock:{defaultValue:"--:--",format:/^\d{2}\D\d{2}$/,ranges:[{type:"hour",from:0,length:2},{type:"minute",from:3,length:2}],sets:1},date:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2}],sets:1},week:{defaultValue:"----\u5E74\u7B2C--\u9031",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4,region:6},{type:"week",from:6,length:2,region:3}],sets:1},month:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:3}],sets:1},year:{defaultValue:"----\u5E74",format:/^\d{4}$/,ranges:[{type:"year",from:0,length:4,region:5}],sets:1},dates:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2,region:5},{type:"year",from:10+P.length,length:4},{type:"month",from:15+P.length,length:2},{type:"date",from:18+P.length,length:2}],sets:2},months:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:6},{type:"year",from:8+P.length,length:4},{type:"month",from:13+P.length,length:2,region:3}],sets:2},dateWareki:{defaultValue:"----\u5E74--\u6708--\u65E5",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"dateWareki",from:0,length:4,region:5},{type:"month",from:5,length:2,region:3},{type:"date",from:8,length:2,region:3}],sets:1}},M={PeriodMargin:" ~ ",DataLeveling:e=>{let{restrict:r,value:g,era:i}=e,f=ee.flatArray(g||""),{defaultValue:E,format:v,ranges:o,sets:a}=Re[r],S=[],n=r=="clock"&&":"||"/";for(let t=0;t<f.length;t++)f[t]=String(f[t]).replace(/\D/ig,n);for(let t=0;t<a;t++){let p=f[t]||"";if(!p.match(v))f[t]="",S.push(E);else{let T=E;p.split(/\D/).forEach((x,w)=>{if(w==0&&r=="dateWareki"){let I=Number(x);i!="year"&&(I>=2019?i=="reiwa"?I-=2018:i=="heisei"&&(I=31):I>=1989?i=="heisei"?I-=1988:i=="shouwa"&&(I=64):I>=1926?i=="shouwa"?I-=1925:i=="taisho"&&(I=15):I>=1912?i=="taisho"?I-=1911:i=="meiji"&&(I=45):I>=1868&&(I-=1867)),x=I.zeroEmbed(4)}T=T.replace(new RegExp("------------------".slice(0,x.length)),x)}),S.push(T)}}return{formatValue:S.join(P),dataValue:["dates","months"].includes(r)?f:f[0],ranges:o}},SystemValidation:e=>{let{states:r}=e,{restrict:g,min:i,max:f,required:E}=r,v=[],o=ee.flatArray(e.value),a={empty:!1,escalated:1,filled:!0,correct:!0,prohibited:!1};(()=>{let S=g=="clock"&&":"||"/";for(let n=0;n<o.length;n++)o[n]=String(o[n]).replace(/\D/ig,S);for(let n=0;n<o.length;n++){let t=o[n],p=o[n-1];t.removeLetters()||(a.empty=!0),n>0&&(a.escalated&=+(t>=p))}a.escalated&&(a.empty||(g.match(/clock/)?o.forEach(n=>{let[t,p]=n.split(/\D+/);!t||!p?a.filled=!1:(Number(t)>23||Number(p)>59)&&(a.correct=!1)}):g.match(/date/)?o.forEach(n=>{let[t,p,T]=n.split(/\D+/);if(!t||!p||!T)a.filled=!1;else{let x=X.Time(n);(!x.validate||n!=x.toFormatYMD())&&(a.correct=!1)}}):g.match(/week/)?o.forEach(n=>{let[t,p]=n.split(/\D+/);if(!t||!p)a.filled=!1;else{let T=X.Time(t+"/01/01").weekday,w=X.Time(t+"/01/0"+(7-T+1)).addWeek(Number(p)-1);t!=String(w.year)&&(a.correct=!1)}}):g.match(/month/)?o.forEach(n=>{let[t,p]=n.split(/\D+/);!t||!p?a.filled=!1:X.Time([t,p,"01"].join("/")).validate||(a.correct=!1)}):g.match(/year/),a.filled&&a.correct&&o.forEach(n=>{{let t=Number(String(n).replace(/\D/ig,""));if(i&&Number(String(i).replace(/\D/ig,""))>t&&(a.prohibited=!0),f){let p=Number(String(f).replace(/\D/ig,""));t>p&&(a.prohibited=!0)}}})))})();{let{empty:S,escalated:n,filled:t,correct:p,prohibited:T}=a;S&&E&&(v=[{type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}]),n||v.push({type:"invalid",label:"\u6642\u7CFB\u5217\u3092\u6B63\u3057\u304F\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),p||v.push({type:"invalid",label:"\u7121\u52B9\u306A\u5024\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u3059"}),t||v.push({type:"invalid",label:"\u6700\u5F8C\u307E\u3067\u5024\u3092\u57CB\u3081\u3066\u304F\u3060\u3055\u3044"}),T&&v.push({type:"invalid",label:se(Ae,{children:[h(H,{children:"\u5165\u529B\u7BC4\u56F2\u304C\u5236\u9650\u3055\u308C\u3066\u3044\u307E\u3059"}),"[",i||"\u4E0B\u9650\u7121\u3057","] ~ [",f||"\u4E0A\u9650\u7121\u3057","]"]})})}return{ok:!v.filter(({type:S})=>S=="invalid").length,notice:v}},KeyDownEvent:e=>{let{val_era:r,restrict:g,event:i,val_status:f,set_status:E,val_focus:v,set_focus:o}=e,{key:a,shiftKey:S,ctrlKey:n,metaKey:t}=i,p=n||t,{selectionStart:T,selectionEnd:x}=i.target,{index:w,prevIndex:I}=v,{ranges:q,formatValue:G}=f,V=q.length-1;if(["Tab","ArrowLeft","ArrowRight"].includes(a)){let y=0;if(a=="Tab"){let m=+!S*2-1;if(y=v.index+m,y<0||y>V)return}else{let m=a=="ArrowLeft"?-1:a=="ArrowRight"?1:0;p||T==0&&x==String(f.formatValue).length?y=m==1?V:0:y=Math.max(0,Math.min(w+m,V))}o(m=>k(s({},m),{index:y,prevIndex:w})),i.preventDefault()}if(["Backspace","ArrowUp","ArrowDown","0","1","2","3","4","5","6","7","8","9"].includes(a)){i.preventDefault();let y=w;y=Math.max(y,0),y=Math.min(y,V);let{type:m,from:U,length:Q}=q[y],L=G.slice(U,U+Q),D;if(a=="Backspace")D="------".slice(0,Q);else if(["ArrowUp","ArrowDown"].includes(a)){let R=a=="ArrowUp"?1:-1;L=L|0,D=L+R;let[u,d,l]=m=="dateWareki"?r=="year"?[0,2999,4]:r=="reiwa"?[1,2999,4]:r=="heisei"?[1,31,4]:r=="shouwa"?[1,64,4]:r=="taisho"?[1,15,4]:r=="meiji"?[1,45,4]:[0,0,0]:m=="minute"?[0,59,2]:m=="hour"?[0,23,2]:m=="date"?[1,31,2]:m=="week"?[1,53,2]:m=="month"?[1,12,2]:m=="year"?[0,2999,4]:[0,0,0];D>d?D=u:D<u&&(D=d),D=Number(D).zeroEmbed(l)}else if(["0","1","2","3","4","5","6","7","8","9"].includes(a)){let R=L|0,u=a,d=`${R}${u}`;if(I!=w&&(R=0,d="0"+u),m=="year"||m=="dateWareki"&&r=="year")Number(d)>1e4?D=u:D=d,(D|0)>1e3&&y++;else if(["hour","minute","date","week","month"].includes(m)||m=="dateWareki"&&r!="year"){let l=m=="dateWareki"?r=="reiwa"?100:r=="heisei"?31:r=="shouwa"?64:r=="taisho"?15:r=="meiji"?45:0:m=="minute"?59:m=="hour"?23:m=="date"?31:m=="week"?53:m=="month"?12:0;D=(d|0)>l?u:d,(Number(u)>Number(String(l)[0])||L=="0000".slice(0,String(l).length)&&(d!="0000".slice(0,String(l).length)||["minute","hour"].includes(m)&&I==w)||(d|0)>=ie(10,String(l).length-1))&&y++}m=="year"||m=="dateWareki"?D=(D|0).zeroEmbed(4):D=(D|0).zeroEmbed(2)}{let R=String(G).partReplace(U,String(D)),u=R.split(P).map(d=>d.replace(/(^\D|\D$)/,"").split(/\D+/).join(g=="clock"&&":"||"/").replace(/(^\D|\D$)/,""));if(g=="dateWareki"){let d=u[0].split(/\D/),[l,_,N]=d;d.length==3&&l&&(u=[[Number(l)-1+Number({year:1,reiwa:2019,heisei:1989,shouwa:1926,taisho:1912,meiji:1868}[r]),_,N].join("/")])}y=Math.max(y,0),y=Math.min(y,V),E(d=>k(s({},d),{dataValue:["dates","months"].includes(g)?u:u[0],formatValue:R,eventType:"update",eventID:F()})),o(d=>k(s({},d),{index:y,prevIndex:d.index}))}}}},le={picker:{launch:e=>{let r=e.sheetID||F(),p=e,{onValueUpdate:g,min:i,max:f,era:E,restrict:v,defaultValue:o}=p,a=K(p,["onValueUpdate","min","max","era","restrict","defaultValue"]),S=!1,n=null,t=null;Ie.open("middleCenter",k(s({sheetID:r,size:"S",padding:0,closeAtAroundClick:!0,closeAtParentBlur:!1,onClose:()=>{S&&g(n,t,!0)}},a),{content:h(ye.Center,{children:h(Ve,{restrict:v,min:i,max:f,era:E,defaultValue:o,sheetID:r,onValueUpdate:(T,x,w)=>{g(T,x,w),S=!w,n=T,t=x}})})}))},remove:e=>{ve.close(e)}}},_e={Shallow:e=>{let{rootStates:r,val_status:g}=e,i=fe(r);return h(H,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:h(ge.Description,k(s({className:r.className},i),{position:"absolute",width:1,freeCSS:k(s({},i.freeCSS),{color:"orange"}),children:h(H,{"data-input-value-shallow":g.componentId,children:"A"})}))})}},Ce=e=>{let ae=e,{tone:r,required:g,restrict:i="clock",componentId:f,era:E,form:v,name:o,min:a,max:S,className:n,enableFormSubmit:t,checkValidationAtFirst:p,onKeyDown:T,onValidate:x,onValidateDelay:w,onUpdateValue:I,onUpdateValidValue:q,onUserAction:G,value:V="",leftIndicator:y,rightIndicator:m,leftIcon:U,rightIcon:Q,freeCSS:L,wrapStyles:D}=ae,R=K(ae,["tone","required","restrict","componentId","era","form","name","min","max","className","enableFormSubmit","checkValidationAtFirst","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","leftIndicator","rightIndicator","leftIcon","rightIcon","freeCSS","wrapStyles"]),[u,d]=O(E),[l,_]=O(k(s({componentId:e.componentId||""},M.DataLeveling({restrict:i,value:V,era:u})),{ranges:[],eventType:"init",eventID:F()})),[N,Z]=O({ok:!1,notice:[]}),[j,J]=O({active:!1,index:0,prevIndex:-1}),me={rootStates:e,val_status:l,set_status:_,val_validate:N,set_validate:Z,val_era:u,set_era:d,val_focus:j,set_focus:J};Y.CommonEffects({type:"time",states:e,val_status:l,set_status:_,val_validate:N,set_validate:Z,SystemValidation:M.SystemValidation,ExtraOverrideStates:()=>M.DataLeveling({restrict:i,value:V,era:u})}),z(()=>{_(c=>s(s({},c),M.DataLeveling({restrict:i,value:V,era:u})))},[]);const te=ue(!1);return z(()=>{if(te.current){_(b=>s(s({},b),M.DataLeveling({restrict:i,value:b.dataValue,era:u})));let c=B.get("refreshEra_"+l.componentId);c&&c.refreshEra(u)}else te.current=!0},[u]),B.update({[l.componentId]:{openPicker:c=>{e.disabled||le.picker.launch({parent:c,sheetID:"PickerTips-"+l.componentId,restrict:i,min:a,max:S,defaultValue:l.dataValue,era:u,onValueUpdate:(b,A,W)=>{W&&(_($=>k(s(s({},$),M.DataLeveling({restrict:i,value:b,era:A})),{eventType:"update",eventID:F()})),d(A))}})},resetEra:c=>{d(c),_(b=>k(s(s({},b),M.DataLeveling({restrict:i,value:"",era:u})),{eventType:"update",eventID:F()}))}}}),z(()=>{let{index:c,active:b}=j;if(b){c=Math.max(c,0),c=Math.min(c,l.ranges.length-1);let{from:A,length:W}=l.ranges[c],$=de("#"+e.id)[0];$&&$.setSelectionRange(A,A+W)}},[j]),se(be,{val_status:l,set_status:_,val_validate:N,states:e,children:[h(_e.Shallow,s({},me)),h(we,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:!0}),ne.get().isTouchDevice?h(oe.Plain,k(s({"data-show-validation":Y.isShowValidation(N,l,!!p),"data-component-id":l.componentId,"data-input-origin":l.componentId,"data-disabled":e.disabled,className:n,freeCSS:{textAlign:"left"}},R),{children:l.formatValue,onClick:c=>{let b=B.get(l.componentId);b&&b.openPicker(`[data-input-origin="${l.componentId}"]`),c.stopPropagation()}})):h(H,s({htmlTag:"input",type:"text",inputMode:"numeric","data-show-validation":Y.isShowValidation(N,l,!!p),"data-input-origin":l.componentId,"data-disabled":e.disabled,value:l.formatValue,className:n,tabIndex:ne.get().isTouchDevice?-1:0,onKeyDown:c=>{M.KeyDownEvent({restrict:i,event:c,val_era:u,val_status:l,set_status:_,val_focus:j,set_focus:J}),T&&T(c),t&&Y.SubmitForm(c,v)},onKeyUp:c=>{c.key=="Tab"&&J(b=>k(s({},b),{active:!0}))},onClick:c=>{let b=c.target.selectionEnd,A=0;l.ranges.forEach((W,$)=>{let{from:re,length:pe,region:ce}=W;re<=b&&b<=re+(ce||pe)&&(A=$)}),J(W=>k(s({},W),{active:!0,index:A})),c.preventDefault()},onChange:()=>{}},R))]})},C={Origin:e=>{let r=s({fontSize:"inherit",width:1},e),[g]=O(e.componentId||F());if(r.componentId=g,ee.is.nullish(r.rightIcon)){let i=(e.restrict||"").match(/clock/)?Se:Te;r.rightIcon=h(ke,{ssSphere:2,freeCSS:{pointerEvents:"all"},children:h(oe.Sub,{color:"cloud",border:"unset",ssSphere:2,fontColor:"theme",boxShadow:"0.normal",borderRadius:"3.tone.tertiary",flexCenter:!0,ssEffectsOnActive:"push",tabIndex:-1,id:"Picker-"+r.componentId,onClick:()=>{let f=B.get(r.componentId);f&&f.openPicker("#Picker-"+r.componentId)},children:h(he,{icon:i})})})}return h(De,{componentId:r.componentId,children:Ce,states:xe(r)})},Clock:e=>h(C.Origin,s({restrict:"clock",era:"clock"},e)),Date:e=>h(C.Origin,s({restrict:"date"},e)),Week:e=>h(C.Origin,s({restrict:"week"},e)),Month:e=>h(C.Origin,s({restrict:"month"},e)),Year:e=>h(C.Origin,s({restrict:"year"},e)),DateWareki:e=>{e=s({},e);let[r]=O(e.componentId||F());e.componentId=r;let v=e,{defaultEra:g="wareki"}=v,i=K(v,["defaultEra"]),[f,E]=O((()=>{let o="year";if(g=="wareki"&&(o="reiwa",e.value)){let[a,S,n]=e.value.split(/\D/);if(a&&S&&n){let t=Number(a);t>=2019?(t-=2019,o="reiwa"):t>=1989?(t-=1989,o="heisei"):t>=1926?(t-=1926,o="shouwa"):t>=1912?(t-=1912,o="taisho"):t>=1868&&(t-=1868,o="meiji"),t+=1}}return o})());return z(()=>{B.set({["refreshEra_"+r]:{refreshEra:o=>{E(o)}}})},[]),h(C.Origin,k(s({restrict:"dateWareki",leftIndicator:h(Ee,{label:"\u5143\u53F7",emptySelect:!1,value:f,tone:e.tone||"border",override:"force",flexCenter:!0,borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",height:1,freeCSS:{whiteSpace:"nowrap"},options:[{value:"year",label:"\u897F\u66A6"},{value:"reiwa",label:"\u4EE4\u548C"},{value:"heisei",label:"\u5E73\u6210"},{value:"shouwa",label:"\u662D\u548C"},{value:"taisho",label:"\u5927\u6B63"},{value:"meiji",label:"\u660E\u6CBB"}],onUpdateValidValue:o=>{E(o);let a=B.get(e.componentId);a&&a.resetEra&&a.resetEra(o)}})},i),{era:f}))},Periods:{Date:e=>h(C.Origin,s({restrict:"dates"},e)),Month:e=>h(C.Origin,s({restrict:"months"},e))},fn:le};export{C as Time,C as default};
|
package/dist/fn/Input/core.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare const CoreEffects: {
|
|
|
34
34
|
}) => void;
|
|
35
35
|
ValidationCheck: (p: {
|
|
36
36
|
val_status: InputTypes.Status.Plain;
|
|
37
|
+
set_status: React.Dispatch<React.SetStateAction<InputTypes.Status.Plain>>;
|
|
37
38
|
SystemValidation: InputTypes.Validation.System;
|
|
38
39
|
states: any;
|
|
39
40
|
set_validate: React.Dispatch<React.SetStateAction<InputTypes.Validation.Result>>;
|
package/dist/fn/Input/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as n,c as u,e as _}from"../../chunk-C5N2D3ZX.js";import{jsx as p,jsxs as R}from"react/jsx-runtime";import{useState as x,useEffect as S}from"react";import m,{UUID as v,useStore as g}from"jmini";import{$$fromRoot as D}from"../../@utils";import{InputClasses as b}from"../../@styles/componentClasses";import{Box as B,Flex as E,FAI as V,Column as F}from"../../atoms";import{Row as k,Literal as N}from"../../mols";import{Button as w}from"../Button";import C from"../Tooltips";const et=t=>{let[i]=x(t.componentId||v());t=n({},t),t.states=u(n({enableFormSubmit:!0,status_id:v(),override:"never",form:"",id:v(),"aria-label":"Input-"+i},t.states),{componentId:i});let{children:a}=t;return p(a,n({},t.states))},at=t=>{let{children:i,val_status:a,val_validate:e,states:s}=t,{leftIcon:r,wrapStyles:o}=s;return s.checkValidationAtFirst||a.eventType=="init"&&(e.notice=[]),R(k.Center,u(n({position:"relative",verticalAlign:"unset",gap:0},o),{className:b("Wrapper"),"data-notice-uid":a.componentId,children:[p(T.Notice,{notice:e.notice,val_status:a}),s.leftIndicator,R(E,{position:"relative",flexSizing:"auto",children:[i,r,p(T.RightIcon,n({},t)),p(T.ClearButton,n({},t))]}),s.rightIndicator]}))},T={ClearButton:t=>!t.states.clearButton||!t.val_status.dataValue?null:p(w.Normal,{ssSphere:2,flexCenter:!0,fontColor:"5.translucent",ssEffectsOnActive:["ripple.theme"],position:"absolute",right:1,top:"50%",freeCSS:{zIndex:3,transform:"translateY(-50%)"},onClick:()=>{t.set_status(i=>u(n({},i),{dataValue:"",formatValue:"",eventType:"update",eventID:v()}))},children:p(V.X,{})}),RightIcon:t=>t.states.clearButton&&t.val_status.dataValue?null:t.states.rightIcon,Notice:t=>{let{notice:i,val_status:a}=t,{componentId:e}=a,s="NoticeTimer-"+e,r="NoticeTimerClose-"+e,o="notice-tips-"+e;return S(()=>{m.interval.once(()=>{if(!i.length){C.close(o);return}C.open({tipsID:o,parent:`[data-notice-uid="${e}"]`,gravityPoint:24,padding:[1,0],closeAtParentBlur:!1,content:R(C.Body,{padding:["1/2","2/3"],fontSize:"1.mini",position:"relative",children:[p(B,{position:"absolute",unitHeight:1,unitWidth:1,right:1,backgroundColor:"dark",freeCSS:{zIndex:1,transform:"rotate(45deg)",top:-6}}),p(F,{backgroundColor:"inherit",gap:"1/3",position:"relative",freeCSS:{zIndex:2},children:i.map((y,I)=>{let{type:l,label:d}=y,f=l=="invalid"?V.Exclamation:l=="warn"?V.Exclamation:V.Check;return R(k.Left,{gap:0,borderRadius:"2.tone.secondary",children:[p(f,{flexCenter:!0,fontSize:"2.normal",fontColor:{invalid:"nega",warn:"warn",valid:"posi"}[l]}),p(N.Supplement,{fontSize:"0.xs",fontColor:"white",children:d})]},I+"-"+m.Stringify(y))})})]})})},350,s),m.interval.once(()=>{C.close(o)},6e3,r)},[i]),null}},A={DefaultStatus:(t,i)=>({componentId:t,dataValue:i,eventType:"init",eventID:v()}),CommonEffects:function(t){let{type:i,states:a,val_status:e,set_status:s,val_validate:r,set_validate:o,SystemValidation:y}=t;a=n({},a);let{componentId:I}=e;S(()=>(g.update({[I]:{ResolveRefresh:null,Refresh:()=>new Promise((l,d)=>{g.get(I).ResolveRefresh=l,s(f=>u(n({},f),{isValidating:!0,eventType:"refresh",eventID:v()}))}),GenNotice:l=>{let{ok:d,notice:f}=l;o({ok:d,notice:f})}}}),()=>{g.delete(I)}),[]),m.scope(()=>{let{override:l}=a;if(l=="never"||l=="beforeModified"&&!["init","override"].includes(e.eventType)||e.isComposing)return;let d=g.get(e.componentId);if(d){if(a.value==e.dataValue){d.status_id=a.status_id;return}a.status_id!=d.status_id&&s(f=>u(n(u(n({},f),{dataValue:a.value}),t.ExtraOverrideStates&&t.ExtraOverrideStates()),{eventType:"override",eventID:v()}))}}),S(()=>{A.ValidationCheck({val_status:e,set_status:s,set_validate:o,SystemValidation:y,states:a})},[e.eventID,e.dataValue]);{let{componentId:l,eventType:d,dataValue:f}=e,c=f;i=="autocomplete.single"||i=="list.radio"?c=c[0]:a.isChecker&&(c=!!c[0]),S(()=>(m.scope(()=>{if(a.form=a.form||"testForm",a.name&&a.form&&g.update({[["form-data",a.form].join("-")]:{[a.name]:{componentId:l,type:i,value:c,validation:r.ok}}}),e.isValidating||d!="refresh")return;let h=g.get(l);h&&h.ResolveRefresh&&h.ResolveRefresh(null)}),()=>{g.update({[["form-data",a.form].join("-")]:{[a.name]:null}})}),[e,r]),S(()=>{a.onUserAction&&a.onUserAction(c,{eventType:d,componentId:l,isValidated:!!r.ok,isComposing:!!e.isComposing,isFocusing:!!e.isFocusing})},[e]),S(()=>{d=="update"&&(a.onUpdateValue&&a.onUpdateValue(c,{eventType:d,componentId:l,isValidated:!!r.ok,isComposing:!!e.isComposing,isFocusing:!!e.isFocusing}),a.onUpdateValidValue&&r.ok&&a.onUpdateValidValue(c,{eventType:d,componentId:l,isValidated:!!r.ok,isComposing:!!e.isComposing,isFocusing:!!e.isFocusing}))},[r.ok,e.dataValue])}},ValidationCheck:t=>{let{states:i}=t,a="ValidationTimer-"+t.val_status.componentId;m.interval.abort(a),t.set_status(o=>u(n({},o),{isValidating:!0}));let e=t.SystemValidation({value:t.val_status.dataValue,states:i});if(!e.ok){t.set_validate(e),t.set_status(o=>u(n({},o),{isValidating:!1}));return}let s=e.notice;const r=()=>_(void 0,null,function*(){if(!i.onValidate)return;let o=yield i.onValidate(t.val_status.dataValue,t.val_status.eventType,t);t.set_validate({ok:o.ok,notice:[...s,...o.notice]}),t.set_status(y=>u(n({},y),{isValidating:!1}))});if(i.onValidate){if(t.val_status.eventType=="refresh"){r();return}m.interval.once(r,i.onValidateDelay||500,a);return}t.set_validate({ok:!0,notice:s}),t.set_status(o=>u(n({},o),{isValidating:!1}))},SubmitForm:(t,i)=>{let a=!1;if(!i)return a;let e=D(`[data-form-submit-button="${i}"]`)[0];if(!e)return a;let s=e.dataset.sdfike||"",r=t.key,o=t.ctrlKey||t.metaKey;return m.scope(()=>{s.includes("enter")&&(r!="Enter"||t.nativeEvent.isComposing||(t==null?void 0:t.keyCode)==229)||((r=="Enter"&&(s.includes("enter")||s.includes("auxEnter")&&o)||r==" "&&s.includes("space"))&&(e.click(),t.preventDefault()),a=!0)}),a},isShowValidation:(t,i,a)=>{let e=t.ok;return!a&&i.eventType=="init"?!0:e}},it=function(t){t=n({tone:"border"},t);let i=m.scope(()=>{if(t.tone=="plain")return{};let e={padding:1,transition:"middle",flexSizing:"auto",boxShadow:"0.min"};return t.tone=="border"?e=u(n({},e),{border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"}):t.tone=="cloud"?e=u(n({},e),{border:"1.thin",borderRadius:"2.tone.secondary",backgroundColor:"cloud"}):t.tone=="bottomBorder"&&(e=u(n({},e),{borderRadius:0,border:"unset",borderBottom:!0,backgroundColor:"cloud"})),e});return u(n(n(n(n(n(n({fontColor:"2.normal"},i),!!t.rightIcon&&{paddingRight:3}),!!t.leftIcon&&{paddingLeft:3}),!!t.leftIndicator&&{borderTopLeftRadius:"2/3",borderBottomLeftRadius:"2/3",marginLeft:"1/4"}),!!t.rightIndicator&&{borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",marginRight:"1/4"}),t),{freeCSS:n({letterSpacing:"1px",resize:"none"},t.freeCSS),className:[b("Input"),t.className].join(" ")})};export{at as BoxWrapper,A as CoreEffects,it as DefaultBoxishStyles,et as OptionalInputWrapper};
|
package/dist/fn/Input/index.d.ts
CHANGED
package/dist/fn/Input/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../../chunk-C5N2D3ZX.js";import*as t from"./Parts";export*from"./Parts";import i from"./Plain";import a from"./Hidden";import p from"./TextField";import
|
|
1
|
+
import"../../chunk-C5N2D3ZX.js";import*as t from"./Parts";export*from"./Parts";import i from"./Plain";import a from"./Hidden";import p from"./TextField";import n from"./Contenteditable";import m from"./DigitCharacters";import l from"./Time";import d from"./Select";import s from"./Autocomplete";import*as r from"./List";import c from"./Search";import x from"./Filer";import y from"./Slider";import T from"./Switch";import f from"./Checker";import g from"./Segmented";import b from"./Color";import S from"./CollectForm";var o;(e=>(e.Plain=i,e.Hidden=a,e.TextField=p,e.Contenteditable=n,e.DigitCharacters=m,e.Time=l,e.Select=d,e.Autocomplete=s,e.List=r.List,e.Radio=r.Radio,e.Checkbox=r.Checkbox,e.Checker=f,e.Search=c,e.Filer=x,e.Slider=y,e.Switch=T,e.Segmented=g,e.Color=b,e.LeftIcon=t.LeftIcon,e.RightIcon=t.RightIcon,e.LeftIndicator=t.LeftIndicator,e.RightIndicator=t.RightIndicator,e.RequiredSign=t.RequiredSign,e.RequiredShortSign=t.RequiredShortSign,e.OmitSign=t.OmitSign,e.CollectForm=S))(o||(o={}));export{o as Input,o as default};
|