amotify 0.2.173 → 0.2.175
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.
|
@@ -31,83 +31,6 @@ import { faChevronRight } from '@fortawesome/free-solid-svg-icons/faChevronRight
|
|
|
31
31
|
|
|
32
32
|
const Dashboard = () => {
|
|
33
33
|
useEffect( () => {
|
|
34
|
-
// return
|
|
35
|
-
let sheetID = 'passwordChangeSheet'
|
|
36
|
-
let formName = 'passwordChangeForm'
|
|
37
|
-
|
|
38
|
-
Sheet.open( 'topCenter',{
|
|
39
|
-
sheetID,
|
|
40
|
-
size: 'S',
|
|
41
|
-
content: () => {
|
|
42
|
-
// Hkvwtxky73n84
|
|
43
|
-
return <Sheet.Body>
|
|
44
|
-
<Column padding={ 2 } gap={ 2 }>
|
|
45
|
-
<Column>
|
|
46
|
-
<Row.Separate>
|
|
47
|
-
<Literal isSemiBoldFont>パスワードを変更</Literal>
|
|
48
|
-
<Button.Sub
|
|
49
|
-
ssSphere={ 3 }
|
|
50
|
-
color='cloud'
|
|
51
|
-
onClick={ () => {
|
|
52
|
-
Sheet.close( sheetID )
|
|
53
|
-
} }
|
|
54
|
-
>
|
|
55
|
-
<FAI.X />
|
|
56
|
-
</Button.Sub>
|
|
57
|
-
</Row.Separate>
|
|
58
|
-
<Box>
|
|
59
|
-
<Literal.Supplement fontColor='nega'>
|
|
60
|
-
※送信後サインアウトされます。
|
|
61
|
-
</Literal.Supplement>
|
|
62
|
-
</Box>
|
|
63
|
-
</Column>
|
|
64
|
-
|
|
65
|
-
<Column gap={ 1.5 }>
|
|
66
|
-
<Input.TextField.Password
|
|
67
|
-
label='現在のパスワード'
|
|
68
|
-
required
|
|
69
|
-
form={ formName }
|
|
70
|
-
name='currentPassword'
|
|
71
|
-
/>
|
|
72
|
-
<Input.TextField.Password
|
|
73
|
-
label='新しいパスワード'
|
|
74
|
-
required
|
|
75
|
-
form={ formName }
|
|
76
|
-
name='newPassword'
|
|
77
|
-
id='newPassword'
|
|
78
|
-
/>
|
|
79
|
-
<Input.TextField.Password
|
|
80
|
-
label='新しいパスワード(確認)'
|
|
81
|
-
required
|
|
82
|
-
form={ formName }
|
|
83
|
-
name='newPasswordConfirm'
|
|
84
|
-
onValidate={ async value => {
|
|
85
|
-
let newPassword = $$( '#newPassword' ).getAttribute( 'value' )
|
|
86
|
-
if ( value != newPassword ) {
|
|
87
|
-
return {
|
|
88
|
-
ok: false,notice: [ { type: 'invalid',label: 'パスワードが一致しません' } ]
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return { ok: true,notice: [] }
|
|
92
|
-
} }
|
|
93
|
-
/>
|
|
94
|
-
</Column>
|
|
95
|
-
<Row.Right>
|
|
96
|
-
<Button.Prime
|
|
97
|
-
submitOption={ {
|
|
98
|
-
formName,
|
|
99
|
-
callback: ( form ) => {
|
|
100
|
-
console.log( form )
|
|
101
|
-
}
|
|
102
|
-
} }
|
|
103
|
-
>
|
|
104
|
-
<Literal>変更する</Literal>
|
|
105
|
-
</Button.Prime>
|
|
106
|
-
</Row.Right>
|
|
107
|
-
</Column>
|
|
108
|
-
</Sheet.Body>
|
|
109
|
-
}
|
|
110
|
-
} )
|
|
111
34
|
},[] )
|
|
112
35
|
|
|
113
36
|
|
|
@@ -117,16 +40,14 @@ const Dashboard = () => {
|
|
|
117
40
|
>
|
|
118
41
|
|
|
119
42
|
<Column gap={ 3 }>
|
|
120
|
-
<Input.TextField.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
label='現在のパスワード'
|
|
127
|
-
required
|
|
128
|
-
name='postalCode'
|
|
43
|
+
<Input.TextField.DigitNumber
|
|
44
|
+
allowDecimals={ 4 }
|
|
45
|
+
value={ 1.234 }
|
|
46
|
+
onUpdateValidValue={ value => {
|
|
47
|
+
console.log( value )
|
|
48
|
+
} }
|
|
129
49
|
/>
|
|
50
|
+
|
|
130
51
|
<Button.Prime
|
|
131
52
|
onClick={ () => {
|
|
132
53
|
console.log( 'Hvfasd' )
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{b as l,c as p,d as j,e as ne}from"../../chunk-C5N2D3ZX.js";import{Fragment as ue,jsx as
|
|
1
|
+
import{b as l,c as p,d as j,e as ne}from"../../chunk-C5N2D3ZX.js";import{Fragment as ue,jsx as o,jsxs as W}from"react/jsx-runtime";import S,{UUID as B,useStore as oe}from"jmini";import{useState as U,useEffect as Q}from"react";import{$$fromRoot as Ie,ExtractStyles as Te}from"../../@utils";import{Box as D,FAI as ve}from"../../atoms";import{Literal as ee}from"../../mols";import{Tips as re,Button as Re}from"..";import{faEye as ye}from"@fortawesome/free-solid-svg-icons/faEye";import{OptionalInputWrapper as Ce,BoxWrapper as we,CoreEffects as P,DefaultBoxishStyles as Ve}from"./core";import{InputLabel as ke}from"./Label";import{LeftIcon as Ne,RightIcon as se}from".";const Fe={katakana:{reg:/^[ァ-ヶー ヲ-゚ ]*$/g,exist:!0,reason:"\u30AB\u30BF\u30AB\u30CA\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},"hankaku.katakana":{reg:/^[ヲ-゚ ]*$/g,exist:!0,reason:"\u534A\u89D2\u30AB\u30BF\u30AB\u30CA\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},number:{reg:/^-?[0-9\.]{0,}[0-9]{1,}$/g,exist:!0,reason:"\u534A\u89D2\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},digitNumber:{reg:/^-?[0-9\,\.]{0,}[0-9]{1,}$/g,exist:!0,reason:"\u534A\u89D2\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},fileName:{reg:/[¥\/:*\?\"\'\|\.\s\n\r\<\>]/g,exist:!1,reason:"\u7A7A\u767D\u307E\u305F\u306F\u4E00\u90E8\u306E\u7279\u6B8A\u6587\u5B57\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093"},creditCard:{reg:/^\d{14,16}$/g,exist:!0,reason:"14~16\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},email:{reg:/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]+\.[A-Za-z0-9]+$/,exist:!0,reason:W(ue,{children:[o(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"}),o(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:W(ue,{children:[o(D,{children:"0\u304B\u3089\u59CB\u307E\u308B\u756A\u53F7\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"}),o(D,{children:"9~12\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),o(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"}},C={setSelection:t=>{let{id:a,restrict:r,val_status:s}=t,i=Ie("#"+a)[0];if(i&&s.prevValue&&s.formatValue){let{formatValue:e,prevValue:u,caretFrom:d,caretTo:n}=s;if(r=="creditCard")e.length>=u.length&&d%5==0&&(d++,n++),i.setSelectionRange(d,n);else if(r=="postal")e.length==5&&u.length==3&&(d++,n++),i.setSelectionRange(d,n);else if(r=="digitNumber"){let m=e.length-u.length;m==2&&(d++,n++),m==-2&&(d--,n--),i.setSelectionRange(d,n)}}},Validation:{System:t=>{let{value:a,states:r}=t,{restrict:s="text",defaultValidation:i,maxLength:e,multiline:u,required:d}=r,n=[];if(u||(e=e||255),S.is.exist(e)&&a.length>=Number(e)&&n.push({type:"invalid",label:e+"\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),a){let m=C.Validation.Text(a,s,i);m.ok||n.push({type:"invalid",label:m.body})}else d&&n.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"});return{ok:!n.filter(({type:m})=>m=="invalid").length,notice:n}},Text:(t,a,r)=>{let s={ok:!0,body:""};return(()=>{let i=r||Fe[a];if(!i)return;let e=i.reason;if(i){let u=!!(+!!t.match(i.reg)^+!i.exist);s={ok:u,body:u?"":e}}})(),s},DataLeveling:t=>{let{restrict:a,allowDecimals:r,allowZeroStart:s,value:i=""}=t,e=String(i);["tel","number","digitNumber","test","postal","creditCard"].includes(a)&&(e=e.zen2hanNumber()),a=="katakana",a=="hankaku.katakana",["postal","creditCard"].includes(a)&&(e=e.removeLetters()),S.scope(()=>{if(!["number","digitNumber"].includes(a))return;e=e.replace(/(\.\d+)\..*/g,"$1").replace(/\.+/g,".").replace(/[^0-9.-]/g,"");let d=Number(e)<0||e[0]=="-";if(e=e.replace(/[^0-9.]/g,""),d&&(e="-"+e),r){let n=Number(r);e=e.replace(/(\.\d{0,})\..*/g,"$1").replace(/\.(\d{0,})/g,(m,b)=>b.length>n?"."+b.slice(0,n):m)}else e=e.replace(/\.\d?/g,"");S.scope(()=>{a=="number"&&(s||(e=e.replace(/^0(\d+)/g,"$1").replace(/^-0(\d+)/g,"-$1")))}),S.scope(()=>{let n=e.slice(-1);e&&n!="."&&n!="-"&&(S.is.exist(t.min)&&(e=String(Math.max(Number(e),Number(t.min)))),S.is.exist(t.max)&&(e=String(Math.min(Number(e),Number(t.max)))))}),S.scope(()=>{if(!e||e=="-"||a!="digitNumber")return;let n=Number(e)<0,m=String(Math.abs(Math.round(Number(e)))),b=e.split("."),R=[];for(let g=m.length-1;g>=0;g--){R.unshift(m[g]);let F=m.length-1-g+1;g!=0&&F%3==0&&R.unshift(",")}e=R.join(""),n&&(e="-"+e),(b==null?void 0:b.length)==2&&(e+="."+b[1]||"")})});let u=e;return a=="digitNumber"||(a=="postal"?e.length>=4&&(u=e.clip(0,3)+"-"+e.clip(3)):a=="creditCard"&&(u=e.replace(/.{4}(?=.)/g,"$& "))),e=e.replace(/,/g,""),{formatValue:u,dataValue:e}}},Shallow:t=>{let{rootStates:a,val_status:r}=t,s=r.dataValue||"";Q(()=>{S.scope(()=>ne(void 0,null,function*(){if(!a.multiline)return;let m=S('[data-input-origin="'+r.componentId+'"]'),b=S('[data-input-shallow="'+r.componentId+'"]'),R=S('[data-input-min-height-value-shallow="'+r.componentId+'"]'),g=S('[data-input-max-height-value-shallow="'+r.componentId+'"]');if(!m[0]||!b[0]||!R[0]||!g[0])return;let F=b.position(),E=R.position(),f=g.position(),w=0;a.autoHeight&&(w=F.height),w=Math.max(w,E.height),w=Math.min(w,f.height),m[0].style.height=w+"px"}))},[s]);let i=s||"";(!!s.match(/\n$/)||!s)&&(i+="T");let u="",d="";if(a.multiline){let m=a.minRows||1,b=a.maxRows||100;u=`
|
|
2
2
|
T`.repeat(m-1),d=`
|
|
3
|
-
T`.repeat(
|
|
3
|
+
T`.repeat(b-1)}let n=Te(a);return W(D,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:[o(ee.Description,p(l({className:a.className},n),{position:"absolute",width:1,freeCSS:p(l({},n.freeCSS),{color:"orange"}),"data-input-shallow":r.componentId,children:o(D,{"data-input-value-shallow":r.componentId,children:i})})),o(ee.Description,p(l({className:a.className},n),{position:"absolute",left:0,freeCSS:p(l({},n.freeCSS),{backgroundColor:"transparent",color:"blue"}),"data-input-min-height-value-shallow":r.componentId,children:u})),o(ee.Description,p(l({className:a.className},n),{position:"absolute",right:0,freeCSS:p(l({},n.freeCSS),{backgroundColor:"transparent",color:"red"}),"data-input-max-height-value-shallow":r.componentId,children:d}))]})},InputBox:t=>{let{rootStates:a,val_validate:r,set_validate:s,val_status:i,set_status:e,val_inputType:u,set_inputType:d,val_focus:n,set_focus:m,val_isComposing:b,set_isComposing:R}=t;if(a.multiline)return null;let le=a,{componentId:g,tone:F,required:E,restrict:f="text",form:w,autoComplete:$="off",autoCapitalize:H="off",minRows:pe,maxRows:ce,multiline:te,autoHeight:me,enableFormSubmit:O,clearButton:q=!1,allowDecimals:M,allowZeroStart:K,checkValidationAtFirst:ae,onChange:J,onKeyDown:Y,onValidate:de,onUpdateValue:fe,onUpdateValidValue:ge,value:be="",leftIndicator:he,rightIndicator:xe,leftIcon:I,rightIcon:Se,maxLength:G,min:v,max:z,label:ie,isLabelActive:De,defaultValidation:Le,wrapStyles:Ee}=le,c=j(le,["componentId","tone","required","restrict","form","autoComplete","autoCapitalize","minRows","maxRows","multiline","autoHeight","enableFormSubmit","clearButton","allowDecimals","allowZeroStart","checkValidationAtFirst","onChange","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","maxLength","min","max","label","isLabelActive","defaultValidation","wrapStyles"]);return o(D,p(l({htmlTag:"input",type:u,inputMode:["number","digitNumber","creditCard"].includes(f)?"numeric":f=="email"?"email":"text","data-disabled":a.disabled,"data-show-validation":P.isShowValidation(r,i,!!ae),"data-component-id":i.componentId,"data-input-origin":i.componentId,value:i.formatValue,autoComplete:$,autoCapitalize:H,onKeyDown:h=>{let{key:y,target:L}=h;{let k=L,{selectionStart:N,selectionEnd:T}=k,A=Number(N),Z=Number(T),_=i.formatValue[Number(A)],X=i.formatValue[Number(A)-1];y=="Delete"&&(f=="creditCard"&&_==" "||f=="postal"&&_=="-"||f=="digitNumber"&&_==",")&&(k.setSelectionRange(A+1,Z+1),h.preventDefault()),y=="Backspace"&&(f=="creditCard"&&X==" "||f=="postal"&&X=="-"||f=="digitNumber"&&X==",")&&(k.setSelectionRange(A-1,Z-1),h.preventDefault()),y=="Enter"||y=="Tab"}S.scope(()=>{["number","digitNumber","creditCard"].includes(f)&&y=="Clear"&&e(k=>p(l({},k),{dataValue:"",formatValue:"",eventType:"update",eventID:B()}))}),S.scope(()=>{var Z;if(!["number","digitNumber"].includes(f)||!["ArrowUp","ArrowDown"].includes(y))return;let k=+(y=="ArrowUp")*2-1,N=i.dataValue.slice(-1),T=i.dataValue,A=((Z=i.dataValue.split(".")[1])==null?void 0:Z.length)||0;if(!N)T+="0";else if(N=="-")T+="0";else if(N==".")T+="0";else if(A){let _=Number(N)+k;T=T.slice(0,-1),_<0?T+="9":_>9?T+="0":T+=String(_)}else T=String(Number(i.dataValue.replace(/,/g,""))+k);r.ok&&s({ok:!1,notice:[]}),e(_=>p(l(l({},_),C.Validation.DataLeveling({allowDecimals:M,allowZeroStart:K,min:v,max:z,restrict:f,value:T})),{eventType:"update",eventID:B()})),h.preventDefault()}),Y&&Y(h),O&&P.SubmitForm(h,w)},onChange:h=>{let{value:y,selectionStart:L,selectionEnd:k}=h.target,N=C.Validation.DataLeveling({allowDecimals:M,allowZeroStart:K,min:v,max:z,restrict:f,value:y});b&&(N.formatValue=y),N.formatValue!=i.formatValue&&(r.ok&&s({ok:!1,notice:[]}),e(T=>p(l(l({},T),N),{prevValue:i.formatValue,eventType:"update",eventID:B(),caretFrom:Number(L),caretTo:Number(k)})),J&&J(h))},width:1},c),{onFocus:h=>{c!=null&&c.onFocus&&(c==null||c.onFocus(h)),m(!0)},onBlur:h=>{c!=null&&c.onBlur&&(c==null||c.onBlur(h)),m(!1)},onCompositionStart:h=>{c!=null&&c.onCompositionStart&&(c==null||c.onCompositionStart(h)),R(!0)},onCompositionEnd:h=>{if(c!=null&&c.onCompositionEnd&&(c==null||c.onCompositionEnd(h)),f=="text")return;let y=C.Validation.DataLeveling({allowDecimals:M,allowZeroStart:K,min:v,max:z,restrict:f,value:i.formatValue});e(L=>p(l(l({},L),y),{prevValue:L.formatValue,eventType:"update",eventID:B(),caretFrom:Number(L.formatValue.length+1),caretTo:Number(L.formatValue.length+1)})),R(!1)}}))},TextAreaBox:t=>{let{rootStates:a,val_focus:r,set_focus:s,val_validate:i,set_validate:e,val_status:u,set_status:d,isShallow:n}=t,G=a,{componentId:m,tone:b,required:R,form:g,label:F,isLabelActive:E,minRows:f,maxRows:w,multiline:$,autoHeight:H,allowDecimals:pe,allowZeroStart:ce,enableFormSubmit:te,maxLength:me,checkValidationAtFirst:O,onChange:q,onKeyDown:M,onValidate:K,onUpdateValue:ae,onUpdateValidValue:J,value:Y="",leftIndicator:de,rightIndicator:fe,leftIcon:ge,rightIcon:be,defaultValidation:he,wrapStyles:xe}=G,I=j(G,["componentId","tone","required","form","label","isLabelActive","minRows","maxRows","multiline","autoHeight","allowDecimals","allowZeroStart","enableFormSubmit","maxLength","checkValidationAtFirst","onChange","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","defaultValidation","wrapStyles"]);return!a.multiline?null:o(D,p(l({htmlTag:"textarea","data-show-validation":P.isShowValidation(i,u,!!O),"data-input-origin":u.componentId,"data-component-id":u.componentId,value:u.dataValue,width:1},I),{onFocus:v=>{I!=null&&I.onFocus&&(I==null||I.onFocus(v)),s(!0)},onBlur:v=>{I!=null&&I.onBlur&&(I==null||I.onBlur(v)),s(!1)},onKeyDown:v=>{M&&M(v),te&&P.SubmitForm(v,g)},onChange:v=>{let{value:z}=v.target;i.ok&&e({ok:!1,notice:[]}),d(ie=>p(l({},ie),{dataValue:z,eventType:"update",eventID:B()})),q&&q(v)}}))}},_e=t=>{let{componentId:a,restrict:r="text",value:s="",min:i,max:e,allowDecimals:u,allowZeroStart:d}=t,[n,m]=U(!1),[b,R]=U(!1),[g,F]=U(p(l({componentId:a},C.Validation.DataLeveling({allowDecimals:u,allowZeroStart:d,min:i,max:e,restrict:r,value:s})),{prevValue:"",eventType:"init",eventID:B(),caretFrom:null,caretTo:null})),[E,f]=U({ok:!1,notice:[]}),[w,$]=U(["password","concealed"].includes(r)&&"password"||"text");Q(()=>{oe.set({[a+":set_inputType"]:$})},[]);let H={rootStates:t,val_focus:n,set_focus:m,val_inputType:w,set_inputType:$,val_isComposing:b,set_isComposing:R,val_status:g,set_status:F,val_validate:E,set_validate:f};return P.CommonEffects({type:"textfield",states:t,val_status:g,set_status:F,val_validate:E,set_validate:f,SystemValidation:C.Validation.System,ExtraOverrideStates:l({},C.Validation.DataLeveling({allowDecimals:u,allowZeroStart:d,min:i,max:e,restrict:r,value:s}))}),Q(()=>{C.setSelection({id:t.id,restrict:r,val_status:g})},[g]),W(we,{val_status:g,set_status:F,val_validate:E,states:H.rootStates,children:[o(ke,{componentId:t.componentId,fontSize:t.fontSize,required:t.required,label:t.label,isActive:t.isLabelActive||n||!!g.dataValue}),o(C.Shallow,l({},H)),o(C.InputBox,l({},H)),o(C.TextAreaBox,l({},H))]})},V=t=>(t=l({autoHeight:!0,restrict:"text",fontSize:"inherit"},t),t.multiline?(t.minRows=t.minRows||5,t.maxRows=t.maxRows||20):(t.minRows=1,t.maxRows=1),o(Ce,{componentId:t.componentId,children:_e,states:Ve(t)})),x=V;x.Validate=C.Validation.Text,x.Katakana=t=>o(V,p(l({},t),{restrict:"katakana",multiline:!1,autoHeight:!1})),x.HankakuKatakana=t=>o(V,p(l({},t),{restrict:"hankaku.katakana",multiline:!1,autoHeight:!1})),x.CreditCard=t=>o(V,p(l({},t),{restrict:"creditCard",multiline:!1,autoHeight:!1})),x.Tel=t=>o(V,p(l({},t),{restrict:"tel",multiline:!1,autoHeight:!1})),x.Number=t=>o(V,p(l({},t),{restrict:"number",multiline:!1,autoHeight:!1})),x.DigitNumber=t=>o(V,p(l({},t),{restrict:"digitNumber",multiline:!1,autoHeight:!1})),x.Email=t=>o(V,p(l({},t),{restrict:"email",multiline:!1,autoHeight:!1})),x.Url=t=>o(V,p(l({},t),{restrict:"url",multiline:!1,autoHeight:!1})),x.Postal=t=>o(V,p(l({label:"\u90F5\u4FBF\u756A\u53F7"},t),{restrict:"postal",multiline:!1,autoHeight:!1,leftIcon:o(Ne,{ssSphere:2,fontColor:"4.thin",children:"\u3012"})})),x.Password=t=>o(V,p(l({label:"\u30D1\u30B9\u30EF\u30FC\u30C9",rightIcon:o(se,{ssSphere:2,padding:0,freeCSS:{pointerEvents:"all"},children:o(Re.Sub,{ssSphere:2,borderRadius:"3.tone.tertiary",fontColor:"theme",flexCenter:!0,height:1,ssEffectsOnActive:["expand"],onMouseOver:a=>{re.open(a.currentTarget,"\u30C6\u30AD\u30B9\u30C8\u3092\u8868\u793A",24)},onMouseLeave:re.abort,tabIndex:-1,onClick:a=>{S(a.target).parent().parent().find("input").callback(r=>{let s=r[0];if(!s)return;let i=s.dataset.componentId;if(!i)return;let e=oe.get(i+":set_inputType");e&&e(u=>u==="password"&&"text"||"password")})},children:o(ve,{icon:ye})})}),restrict:"password"},t),{multiline:!1,autoHeight:!1})),x.Concealed=t=>o(x.Password,p(l({label:"\u79D8\u5BC6\u9375"},t),{restrict:"concealed"})),x.Money={JPY:t=>o(x.DigitNumber,p(l({rightIcon:o(se,{ssSphere:2,fontColor:"4.thin",children:"\u5186"})},t),{multiline:!1,autoHeight:!1}))};export{x as TextField,_e as TextInput,x as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as p,c as x}from"../../../chunk-C5N2D3ZX.js";import{Fragment as $,jsx as a,jsxs as f}from"react/jsx-runtime";import{createElement as q}from"react";import D,{UUID as O,Time as S}from"jmini";import{useState as A,useEffect as F,useRef as H}from"react";import{Box as k,Flex as w,Grid as W,FAI as T,Column as V}from"../../../atoms";import{Row as N,Literal as G}from"../../../mols";import{Button as C}from"../../Button";import X from"../../Sheet";import M from"../Select";import{Radio as L}from"../List";import{RightIcon as B}from"..";import{InputTimeClasses as y}from"../../../@styles/componentClasses";let _=i=>{var t,r;let e=[],d=Number((t=i==null?void 0:i.min)!=null?t:1900),o=Number((r=i==null?void 0:i.max)!=null?r:S().addYear(10).year);for(let m=d;m<=o;m++)e.unshift({value:m,label:[m,...D.transformer.wareki(m).value].join(" -")});return e};const j=i=>{let{restrict:e,era:d="year",defaultValue:o=""}=i;i=p({},i),i.sheetID=i.sheetID||O();const t=H(!1);let[r,m]=A((()=>{var n,s;if(e=="clock"){let l=String(o).split(/[^\d]/);l[0]||(l=[0,0]);let u=Number(l[0]),c=Number(l[1]);return{modifiedType:"init",hour:u,minutes:c}}else if(e=="date"){let[l,u,c]=(n=String(o))==null?void 0:n.split(/\D/);return(D.is.nullish(l)||D.is.nullish(u)||D.is.nullish(c))&&([l,u,c]=S().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",year:Number(l),month:Number(u),date:Number(c)}}else if(e!="week"){if(e=="month"){let[l,u]=String(o).split(/\D/);return(D.is.nullish(l)||D.is.nullish(u))&&([l,u]=S().toFormat("%Y-%M").split("-")),{modifiedType:"init",year:Number(l),month:Number(u)}}else if(e=="year"){let[l]=String(o).split(/\D/);return D.is.nullish(l)&&([l]=S().toFormat("%Y").split("-")),{modifiedType:"init",year:Number(l)}}else if(e=="dateWareki"){let[l,u,c]=(s=String(o))==null?void 0:s.split(/\D/);return(D.is.nullish(l)||D.is.nullish(u)||D.is.nullish(c))&&([l,u,c]=S().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",era:d||"year",year:Number(l),month:Number(u),date:Number(c)}}}return{}})());F(()=>{if(t.current){if(r.modifiedType=="update"){let n="",s=d||"year";if(e=="clock"){let{hour:l,minutes:u}=r;n=[l.zeroEmbed(2),u.zeroEmbed(2)].join("/")}else if(e=="date"){let{year:l,month:u,date:c}=r;n=[l,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}else if(e!="week"){if(e=="month"){let{year:l,month:u}=r;n=[l,u.zeroEmbed(2)].join("/")}else if(e=="year"){let{year:l}=r;n=String(l)}else if(e=="dateWareki"){let{year:l,month:u,date:c,era:v}=r;s=v,n=[l,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}}i.onValueUpdate(n,s)}}else t.current=!0},[r]);let h=x(p({},i),{val_value:r,set_value:m});return a(k,{backgroundColor:"layer.1",borderRadius:"2.tone.secondary",boxShadow:"1.remark",children:a(k,{className:y(e.toCapital()+"Base"),children:e=="clock"?a(g.Clock.index,p({},h)):e=="date"?a(g.Date.index,p({},h)):e=="week"?"":e=="month"?a(g.Month.index,p({},h)):e=="year"?a(g.Year.index,p({},h)):e=="dates"||e=="months"?"":e=="dateWareki"?a(g.DateWareki.index,p({},h)):a($,{})})})},g={Clock:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,[h,n]=A(r.hour>12?2:1),[s,l]=A(Number(localStorage.getItem("timePickerUnit")||5));F(()=>{localStorage.setItem("timePickerUnit",String(s))},[s]);let{hour:u,minutes:c}=r;return f(V,{padding:1,children:[f(w,{flexType:"row",flexWrap:!1,gap:1,className:y("Body"),children:[f(V,{className:y("DesignSide"),flexSizing:0,children:[a(k,{className:y("ClockUiBase"),padding:[1,"2/3"],flexCenter:!0,children:f(k,{className:y("ClockUi"),backgroundColor:"theme.opa.low",isRounded:!0,position:"relative",children:[a(k,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[y("Needle"),y("hour")].join(" "),freeCSS:{transform:`rotate(${u*30+c/2}deg)`}}),a(k,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[y("Needle"),y("minute")].join(" "),freeCSS:{transform:`rotate(${c*6}deg)`}})]})}),a(L,{icon:!0,value:[h],options:[{value:1,label:"AM"},{value:2,label:"PM"}],flexType:"col",gap:"1/2",tabIndex:-1,onUpdateValidValue:v=>{let I=r.hour%12+(v==2?12:0);n(v),m({modifiedType:"update",hour:I,minutes:r.minutes})}}),a(k,{borderTop:!0,margin:[0,1]}),a(L,{icon:!0,value:[s],options:[{value:1,label:"/ 1\u5206"},{value:2,label:"/ 2\u5206"},{value:5,label:"/ 5\u5206"}],flexType:"col",gap:"1/2",tabIndex:-1,onUpdateValidValue:v=>{l(v)}})]}),f(V,{children:[f(k,{flexCenter:!0,isSemiBoldFont:!0,fontSize:"3.paragraph",children:[r.hour.zeroEmbed(2)," : ",r.minutes.zeroEmbed(2)]}),f(w,{flexWrap:!1,ssCardBox:!0,flexChilds:"even",padding:["1/3",0],freeCSS:{minWidth:12*12},children:[a(V,{gap:0,overflow:"auto",padding:"2/3",borderRight:!0,freeCSS:{maxHeight:12*22},children:g.Clock.Hours({onClick:v=>{let R=v+(h==2?12:0);m({modifiedType:"update",hour:R,minutes:r.minutes})},min:e,max:d,ampm:h})}),a(V,{gap:0,overflow:"auto",padding:"2/3",freeCSS:{maxHeight:12*22},children:g.Clock.Minutes({onClick:v=>{m({modifiedType:"update",hour:r.hour,minutes:v})},min:e,max:d,unit:s})})]})]})]}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},Hours:i=>{let e=[];for(let d=0;d<12;d++){let o=i.ampm==2?d+12:d,t=!1;{let r=Number(String(o*100).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>r&&(t=!0),i.max){let m=Number(String(i.max).replace(/\D/ig,""));r>m&&(t=!0)}}e.push(a(C.Normal,{isLocked:t,borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(d)},children:o.zeroEmbed(2)},d))}return e},Minutes:i=>{let e=[];for(let d=0;d<60/i.unit;d++){let o=d*i.unit;e.push(a(C.Normal,{borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(o)},children:o.zeroEmbed(2)},o))}return e}},Date:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h,month:n,date:s}=r;return f(V,{padding:1,children:[f(N.Separate,{flexWrap:!0,children:[f(w,{verticalAlign:"bottom",horizontalAlign:"left",gap:"2/3",flexWrap:!1,children:[a(M,{override:"force",emptySelect:!1,value:h,options:_(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,SelectorStyles:{freeCSS:{minWidth:12*12}},onUpdateValidValue:l=>{m({modifiedType:"update",year:Number(l),month:n,date:s})},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})})}),a(M,{override:"force",emptySelect:!1,value:n,options:(()=>{let l=[];for(let u=1;u<=12;u++)l.push({value:u,label:String(u)+"\u6708"});return l})(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,SelectorStyles:{freeCSS:{minWidth:12*8}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),onUpdateValidValue:l=>{m({modifiedType:"update",year:h,month:Number(l),date:s})}})]}),a(g.Variables.ShiftButtons,{callback:l=>{let u=n+l,c=h;u<=0&&(c--,u=12),u>12&&(c++,u=1),m({modifiedType:"update",year:c,month:u,date:r.date})}})]}),a(k,{borderTop:!0}),a(k,{children:g.Date.MonthCalendar({min:e,max:d,year:r.year,month:r.month,current:[r.year,r.month,r.date],callback:l=>{let[u,c,v]=l;m({modifiedType:"update",year:u,month:c,date:v})}})}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},MonthCalendar:i=>{let{min:e,max:d,year:o,month:t,current:r,callback:m}=i,h=S(),n=S([o,t.zeroEmbed(2),"01"].join("/")),s=n.getLastDayOfTheMonth(),l=S(n).addMonth(-1).getLastDayOfTheMonth().date,u=[],c=[],v=[],R=[],I={padding:0,unitWidth:3,unitHeight:3,flexCenter:!0,borderRadius:"3.tone.tertiary"};for(var b=0;b<7;b++)u.push(a(k,x(p({className:[y("CalendarDay"),y("Legend")].join(" ")},I),{children:["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][b]}),b));for(var b=0;b<n.weekday;b++)c.unshift(q(k,x(p({className:[y("CalendarDay"),y("Dummy")].join(" "),fontColor:"4.thin"},I),{key:b}),l-b));for(var b=1;b<=s.date;b++){let E=b,Y=o==h.year&&t==h.month&&b==h.date,P=!1;{let z=Number(String([o,t.zeroEmbed(2),b.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>z&&(P=!0),i.max){let U=Number(String(i.max).replace(/\D/ig,""));z>U&&(P=!0)}}v.push(a(C.Clear,x(p({className:[y("CalendarDay"),y("isToday_"+Y)].join(" ")},I),{fontColor:"1.clear",padding:0,flexCenter:!0,isRounded:!0,ssEffectsOnActive:"shrink",onClick:()=>{m([o,t,E])},tabIndex:-1,isLocked:P,children:b}),E))}for(var b=1;b<7-s.weekday;b++)R.push(a(k,x(p({className:[y("CalendarDay"),y("Dummy")].join(" "),fontColor:"4.thin"},I),{children:b}),b));return f(W,{gridCols:7,gap:"1/6",children:[u,c,v,R]})}},Month:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h,month:n}=r;return f(V,{padding:1,children:[f(N.Separate,{gap:0,children:[a(N.Center,{verticalAlign:"bottom",gap:"2/3",children:a(M,{emptySelect:!1,value:h,options:_(),override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,SelectorStyles:{freeCSS:{minWidth:12*12}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),onUpdateValidValue:s=>{m({modifiedType:"update",year:Number(s),month:n})}})}),a(g.Variables.ShiftButtons,{callback:s=>{let l=Math.min(Math.max(h+s,1900),2100);m({modifiedType:"update",year:l,month:n})}})]}),a(k,{borderTop:!0}),g.Month.Months({min:e,max:d,year:r.year,callback:s=>{let[l,u]=s;m({modifiedType:"update",year:l,month:u})}}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},Months:i=>{let{year:e,callback:d}=i,o=S(),t=[];for(let r=1;r<=12;r++){let m=e==o.year&&r==o.month,h=!1;{let s=Number(String([e,r.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>s&&(h=!0),i.max){let l=Number(String(i.max).replace(/\D/ig,""));s>l&&(h=!0)}}let n=[y("Cell"),m?y("isThisMonth"):""].join(" ");t.push(f(C.Clear,{className:n,isLocked:h,fontColor:"2.normal",padding:["1/3",1],ssEffectsOnActive:"shrink",onClick:()=>{d([e,r])},children:[r," \u6708"]},e+"-"+r))}return a(W,{gridCols:4,gap:"2/3",children:t})}},Year:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h}=r;return f(V,{padding:1,children:[a(M,{emptySelect:!1,paddingRight:1,fontSize:"1.mini",value:h||S().year,override:"force",SelectorStyles:{freeCSS:{minWidth:12*12}},options:_({min:e,max:d}),onUpdateValidValue:n=>{m({modifiedType:"update",year:Number(n)})}}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o,onSubmit:()=>{m({modifiedType:"update",year:Number(h||S().year)})}})]})}},DateWareki:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{era:h,year:n,month:s,date:l}=r,u={val_value:r,set_value:m};return f(k,{children:[f(N.Left,{borderBottom:!0,gap:0,verticalAlign:"unset",children:[a(g.DateWareki.EraSelect,p({},u)),a(k,{borderRight:!0}),a(g.DateWareki.Calendar,p({},u))]}),a(N.Right,{padding:1,children:a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})})]})},EraSelect:i=>{let{val_value:e,set_value:d}=i,o={padding:["1/2",1.5],fontColor:"3.blur"},t={backgroundColor:"cloud",fontColor:"2.normal",isSemiBoldFont:!0};return f(V,{padding:1,gap:0,children:[a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="year",onClick:()=>{let r=S();d({modifiedType:"update",era:"year",year:r.year,month:r.month,date:r.date})},children:"\u897F\u66A6"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="reiwa",onClick:()=>{let r=S();d({modifiedType:"update",era:"reiwa",year:r.year,month:r.month,date:r.date})},children:"\u4EE4\u548C"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="heisei",onClick:()=>{d({modifiedType:"update",era:"heisei",year:2019,month:1,date:1})},children:"\u5E73\u6210"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="shouwa",onClick:()=>{d({modifiedType:"update",era:"shouwa",year:1989,month:1,date:1})},children:"\u662D\u548C"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="taisho",onClick:()=>{d({modifiedType:"update",era:"taisho",year:1926,month:1,date:1})},children:"\u5927\u6B63"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="meiji",onClick:()=>{d({modifiedType:"update",era:"meiji",year:1912,month:1,date:1})},children:"\u660E\u6CBB"}))]})},Calendar:i=>{let{val_value:e,set_value:d}=i,o=[];if(e.era=="year"){let t=S().year+10;for(let r=1900;r<t;r++)o.unshift({value:r,label:r+"\u5E74"})}else if(e.era=="reiwa"){let t=S().year-2018;for(let r=1;r<=t+10;r++)o.unshift({value:2019+r-1,label:"\u4EE4\u548C"+(r==1?"\u5143":r)+"\u5E74"})}else if(e.era=="heisei")for(let t=1;t<=31;t++)o.unshift({value:1989+t-1,label:"\u5E73\u6210"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="shouwa")for(let t=1;t<=64;t++)o.unshift({value:1926+t-1,label:"\u662D\u548C"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="taisho")for(let t=1;t<=15;t++)o.unshift({value:1912+t-1,label:"\u5927\u6B63"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="meiji")for(let t=1;t<=45;t++)o.unshift({value:1868+t-1,label:"\u660E\u6CBB"+(t==1?"\u5143":t)+"\u5E74"});return f(V,{padding:1,children:[f(N.Separate,{children:[a(M,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,fontSize:"1.mini",SelectorStyles:{freeCSS:{minWidth:12*12}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),options:o,value:e.year,onUpdateValidValue:t=>{d(r=>x(p({},r),{modifiedType:"update",year:Number(t)}))}}),f(N.Center,{gap:"1/3",children:[a(M,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,fontSize:"1.mini",SelectorStyles:{freeCSS:{minWidth:12*9}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(T.AngleDown,{})}),options:[{value:1,label:"1\u6708"},{value:2,label:"2\u6708"},{value:3,label:"3\u6708"},{value:4,label:"4\u6708"},{value:5,label:"5\u6708"},{value:6,label:"6\u6708"},{value:7,label:"7\u6708"},{value:8,label:"8\u6708"},{value:9,label:"9\u6708"},{value:10,label:"10\u6708"},{value:11,label:"11\u6708"},{value:12,label:"12\u6708"}],value:e.month,onUpdateValidValue:t=>{d({modifiedType:"update",era:e.era,year:e.year,month:Number(t),date:1})}}),a(C.Clear.S,{ssSphere:2.5,onClick:()=>{let t=e.month-1;d({modifiedType:"update",era:e.era,year:t==0?e.year-1:e.year,month:t==0?12:t,date:1})},children:a(T.ChevronLeft,{})}),a(C.Clear.S,{ssSphere:2.5,onClick:()=>{let t=e.month+1;d({modifiedType:"update",era:e.era,year:t==13?e.year+1:e.year,month:t==13?1:t,date:1})},children:a(T.ChevronRight,{})})]})]}),a(g.DateWareki.MonthCell,p({},i))]},e.era)},MonthCell:i=>{let{val_value:e,set_value:d}=i,o=S([e.year.zeroEmbed(4),e.month.zeroEmbed(2),e.date.zeroEmbed(2)].join("/"));if(!o.validate)return;let t=o.getFirstDayOfTheMonth().weekday,r=o.getLastDayOfTheMonth(),m=[];for(let n=0;n<7;n++)m.push(a(G.Supplement,{flexCenter:!0,fontColor:n==0?"googleRed":n==6?"googleBlue":"3.blur",children:D.transformer.weekday.shortJP(n)},"legend-"+n));for(let n=0;n<t;n++){let s=S(o).getFirstDayOfTheMonth().addDate(n-t);m.push(a(C.Sub,{color:"cloud",ssSquare:3,opacity:"middle",onClick:l=>{l.preventDefault(),l.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"lastMonth-"+n))}let h=S();for(let n=1;n<=r.date;n++){let s=S(o).setDate(n),l=h.diff(s).dates==0;m.push(a(C.Clear,{ssSquare:3,fontColor:"2.normal",className:[y("CalendarDay"),y("isToday_"+l)].join(" "),onClick:()=>{d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"currentMonth-"+n))}for(let n=0;n<7-r.weekday-1;n++){let s=S(o).addMonth(1).setDate(1).addDate(n);m.push(a(C.Sub,{color:"cloud",ssSquare:3,opacity:"middle",onClick:l=>{l.preventDefault(),l.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"nextMonth-"+n))}return a(W,{gridCols:7,gap:"1/4",children:m})}},Variables:{Footer:i=>f(w,{flexWrap:!1,gap:1,flexChilds:"even",freeCSS:{whiteSpace:"nowrap"},children:[f(C.Sub.S,{color:"cloud",tabIndex:-1,isRounded:!0,onClick:()=>{i.onValueUpdate("")},flexSizing:"none",children:[a(T.X,{})," \u524A\u9664"]}),a(C.Prime.S,{tabIndex:-1,isRounded:!0,flexSizing:"auto",freeCSS:{minWidth:12*6},onClick:()=>{i.onSubmit&&i.onSubmit(),X.close(i.sheetID)},children:"\u6C7A\u5B9A"})]}),ShiftButtons:i=>f(w,{gap:"1/3",flexWrap:!1,children:[a(C.Clear,x(p({className:y("LeftButton"),tabIndex:-1,right:0},g.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(-1)},children:a(T.ChevronLeft,{})})),a(C.Clear,x(p({className:y("RightButton"),tabIndex:-1,left:0},g.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(1)},children:a(T.ChevronRight,{})}))]}),ShiftButtonStyles:{position:"relative",flexCenter:!0,ssSphere:2.5}}};export{j as Picker,j as default};
|
|
1
|
+
import{b as p,c as x}from"../../../chunk-C5N2D3ZX.js";import{Fragment as $,jsx as a,jsxs as f}from"react/jsx-runtime";import{createElement as q}from"react";import D,{UUID as O,Time as S}from"jmini";import{useState as A,useEffect as F,useRef as H}from"react";import{Box as k,Flex as w,Grid as W,FAI as V,Column as T}from"../../../atoms";import{Row as N,Literal as G}from"../../../mols";import{Button as C}from"../../Button";import X from"../../Sheet";import M from"../Select";import{Radio as L}from"../List";import{RightIcon as B}from"..";import{InputTimeClasses as y}from"../../../@styles/componentClasses";let _=i=>{var t,r;let e=[],d=Number((t=i==null?void 0:i.min)!=null?t:1900),o=Number((r=i==null?void 0:i.max)!=null?r:S().addYear(10).year);for(let m=d;m<=o;m++)e.unshift({value:m,label:[m,...D.transformer.wareki(m).value].join(" -")});return e};const j=i=>{let{restrict:e,era:d="year",defaultValue:o=""}=i;i=p({},i),i.sheetID=i.sheetID||O();const t=H(!1);let[r,m]=A((()=>{var n,s;if(e=="clock"){let l=String(o).split(/[^\d]/);l[0]||(l=[0,0]);let u=Number(l[0]),c=Number(l[1]);return{modifiedType:"init",hour:u,minutes:c}}else if(e=="date"){let[l,u,c]=(n=String(o))==null?void 0:n.split(/\D/);return(D.is.nullish(l)||D.is.nullish(u)||D.is.nullish(c))&&([l,u,c]=S().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",year:Number(l),month:Number(u),date:Number(c)}}else if(e!="week"){if(e=="month"){let[l,u]=String(o).split(/\D/);return(D.is.nullish(l)||D.is.nullish(u))&&([l,u]=S().toFormat("%Y-%M").split("-")),{modifiedType:"init",year:Number(l),month:Number(u)}}else if(e=="year"){let[l]=String(o).split(/\D/);return D.is.nullish(l)&&([l]=S().toFormat("%Y").split("-")),{modifiedType:"init",year:Number(l)}}else if(e=="dateWareki"){let[l,u,c]=(s=String(o))==null?void 0:s.split(/\D/);return(D.is.nullish(l)||D.is.nullish(u)||D.is.nullish(c))&&([l,u,c]=S().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",era:d||"year",year:Number(l),month:Number(u),date:Number(c)}}}return{}})());F(()=>{if(t.current){if(r.modifiedType=="update"){let n="",s=d||"year";if(e=="clock"){let{hour:l,minutes:u}=r;n=[l.zeroEmbed(2),u.zeroEmbed(2)].join("/")}else if(e=="date"){let{year:l,month:u,date:c}=r;n=[l,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}else if(e!="week"){if(e=="month"){let{year:l,month:u}=r;n=[l,u.zeroEmbed(2)].join("/")}else if(e=="year"){let{year:l}=r;n=String(l)}else if(e=="dateWareki"){let{year:l,month:u,date:c,era:v}=r;s=v,n=[l,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}}i.onValueUpdate(n,s)}}else t.current=!0},[r]);let h=x(p({},i),{val_value:r,set_value:m});return a(k,{backgroundColor:"layer.1",borderRadius:"2.tone.secondary",boxShadow:"1.remark",children:a(k,{className:y(e.toCapital()+"Base"),children:e=="clock"?a(g.Clock.index,p({},h)):e=="date"?a(g.Date.index,p({},h)):e=="week"?"":e=="month"?a(g.Month.index,p({},h)):e=="year"?a(g.Year.index,p({},h)):e=="dates"||e=="months"?"":e=="dateWareki"?a(g.DateWareki.index,p({},h)):a($,{})})})},g={Clock:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,[h,n]=A(r.hour>12?2:1),[s,l]=A(Number(localStorage.getItem("timePickerUnit")||5));F(()=>{localStorage.setItem("timePickerUnit",String(s))},[s]);let{hour:u,minutes:c}=r;return f(T,{padding:1,children:[f(w,{flexType:"row",flexWrap:!1,gap:1,className:y("Body"),children:[f(T,{className:y("DesignSide"),flexSizing:0,children:[a(k,{className:y("ClockUiBase"),padding:[1,"2/3"],flexCenter:!0,children:f(k,{className:y("ClockUi"),backgroundColor:"theme.opa.low",isRounded:!0,position:"relative",children:[a(k,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[y("Needle"),y("hour")].join(" "),freeCSS:{transform:`rotate(${u*30+c/2}deg)`}}),a(k,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[y("Needle"),y("minute")].join(" "),freeCSS:{transform:`rotate(${c*6}deg)`}})]})}),a(L,{icon:!0,value:[h],options:[{value:1,label:"AM"},{value:2,label:"PM"}],flexType:"col",gap:"1/2",tabIndex:-1,onUpdateValidValue:v=>{let I=r.hour%12+(v==2?12:0);n(v),m({modifiedType:"update",hour:I,minutes:r.minutes})}}),a(k,{borderTop:!0,margin:[0,1]}),a(L,{icon:!0,value:[s],options:[{value:1,label:"/ 1\u5206"},{value:2,label:"/ 2\u5206"},{value:5,label:"/ 5\u5206"}],flexType:"col",gap:"1/2",tabIndex:-1,onUpdateValidValue:v=>{l(v)}})]}),f(T,{children:[f(k,{flexCenter:!0,isSemiBoldFont:!0,fontSize:"3.paragraph",children:[r.hour.zeroEmbed(2)," : ",r.minutes.zeroEmbed(2)]}),f(w,{flexWrap:!1,ssCardBox:!0,flexChilds:"even",padding:["1/3",0],freeCSS:{minWidth:12*12},children:[a(T,{gap:0,overflow:"auto",padding:"2/3",borderRight:!0,freeCSS:{maxHeight:12*22},children:g.Clock.Hours({onClick:v=>{let R=v+(h==2?12:0);m({modifiedType:"update",hour:R,minutes:r.minutes})},min:e,max:d,ampm:h})}),a(T,{gap:0,overflow:"auto",padding:"2/3",freeCSS:{maxHeight:12*22},children:g.Clock.Minutes({onClick:v=>{m({modifiedType:"update",hour:r.hour,minutes:v})},min:e,max:d,unit:s})})]})]})]}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},Hours:i=>{let e=[];for(let d=0;d<12;d++){let o=i.ampm==2?d+12:d,t=!1;{let r=Number(String(o*100).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>r&&(t=!0),i.max){let m=Number(String(i.max).replace(/\D/ig,""));r>m&&(t=!0)}}e.push(a(C.Normal,{isLocked:t,borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(d)},children:o.zeroEmbed(2)},d))}return e},Minutes:i=>{let e=[];for(let d=0;d<60/i.unit;d++){let o=d*i.unit;e.push(a(C.Normal,{borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(o)},children:o.zeroEmbed(2)},o))}return e}},Date:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h,month:n,date:s}=r;return f(T,{padding:1,children:[f(N.Separate,{flexWrap:!0,children:[f(w,{verticalAlign:"bottom",horizontalAlign:"left",gap:"2/3",flexWrap:!1,children:[a(M,{override:"force",emptySelect:!1,value:h,options:_(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,SelectorStyles:{freeCSS:{minWidth:12*12}},onUpdateValidValue:l=>{m({modifiedType:"update",year:Number(l),month:n,date:s})},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(V.AngleDown,{})})}),a(M,{override:"force",emptySelect:!1,value:n,options:(()=>{let l=[];for(let u=1;u<=12;u++)l.push({value:u,label:String(u)+"\u6708"});return l})(),fontSize:"1.mini",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,SelectorStyles:{freeCSS:{minWidth:12*8}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(V.AngleDown,{})}),onUpdateValidValue:l=>{m({modifiedType:"update",year:h,month:Number(l),date:s})}})]}),a(g.Variables.ShiftButtons,{callback:l=>{let u=n+l,c=h;u<=0&&(c--,u=12),u>12&&(c++,u=1),m({modifiedType:"update",year:c,month:u,date:r.date})}})]}),a(k,{borderTop:!0}),a(k,{children:g.Date.MonthCalendar({min:e,max:d,year:r.year,month:r.month,current:[r.year,r.month,r.date],callback:l=>{let[u,c,v]=l;m({modifiedType:"update",year:u,month:c,date:v})}})}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},MonthCalendar:i=>{let{min:e,max:d,year:o,month:t,current:r,callback:m}=i,h=S(),n=S([o,t.zeroEmbed(2),"01"].join("/")),s=n.getLastDayOfMonth(),l=S(n).addMonth(-1).getLastDayOfMonth().date,u=[],c=[],v=[],R=[],I={padding:0,unitWidth:3,unitHeight:3,flexCenter:!0,borderRadius:"3.tone.tertiary"};for(var b=0;b<7;b++)u.push(a(k,x(p({className:[y("CalendarDay"),y("Legend")].join(" ")},I),{children:["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][b]}),b));for(var b=0;b<n.weekday;b++)c.unshift(q(k,x(p({className:[y("CalendarDay"),y("Dummy")].join(" "),fontColor:"4.thin"},I),{key:b}),l-b));for(var b=1;b<=s.date;b++){let E=b,Y=o==h.year&&t==h.month&&b==h.date,P=!1;{let z=Number(String([o,t.zeroEmbed(2),b.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>z&&(P=!0),i.max){let U=Number(String(i.max).replace(/\D/ig,""));z>U&&(P=!0)}}v.push(a(C.Clear,x(p({className:[y("CalendarDay"),y("isToday_"+Y)].join(" ")},I),{fontColor:"1.clear",padding:0,flexCenter:!0,isRounded:!0,ssEffectsOnActive:"shrink",onClick:()=>{m([o,t,E])},tabIndex:-1,isLocked:P,children:b}),E))}for(var b=1;b<7-s.weekday;b++)R.push(a(k,x(p({className:[y("CalendarDay"),y("Dummy")].join(" "),fontColor:"4.thin"},I),{children:b}),b));return f(W,{gridCols:7,gap:"1/6",children:[u,c,v,R]})}},Month:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h,month:n}=r;return f(T,{padding:1,children:[f(N.Separate,{gap:0,children:[a(N.Center,{verticalAlign:"bottom",gap:"2/3",children:a(M,{emptySelect:!1,value:h,options:_(),override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,SelectorStyles:{freeCSS:{minWidth:12*12}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(V.AngleDown,{})}),onUpdateValidValue:s=>{m({modifiedType:"update",year:Number(s),month:n})}})}),a(g.Variables.ShiftButtons,{callback:s=>{let l=Math.min(Math.max(h+s,1900),2100);m({modifiedType:"update",year:l,month:n})}})]}),a(k,{borderTop:!0}),g.Month.Months({min:e,max:d,year:r.year,callback:s=>{let[l,u]=s;m({modifiedType:"update",year:l,month:u})}}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})]})},Months:i=>{let{year:e,callback:d}=i,o=S(),t=[];for(let r=1;r<=12;r++){let m=e==o.year&&r==o.month,h=!1;{let s=Number(String([e,r.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>s&&(h=!0),i.max){let l=Number(String(i.max).replace(/\D/ig,""));s>l&&(h=!0)}}let n=[y("Cell"),m?y("isThisMonth"):""].join(" ");t.push(f(C.Clear,{className:n,isLocked:h,fontColor:"2.normal",padding:["1/3",1],ssEffectsOnActive:"shrink",onClick:()=>{d([e,r])},children:[r," \u6708"]},e+"-"+r))}return a(W,{gridCols:4,gap:"2/3",children:t})}},Year:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{year:h}=r;return f(T,{padding:1,children:[a(M,{emptySelect:!1,paddingRight:1,fontSize:"1.mini",value:h||S().year,override:"force",SelectorStyles:{freeCSS:{minWidth:12*12}},options:_({min:e,max:d}),onUpdateValidValue:n=>{m({modifiedType:"update",year:Number(n)})}}),a(g.Variables.Footer,{sheetID:t,onValueUpdate:o,onSubmit:()=>{m({modifiedType:"update",year:Number(h||S().year)})}})]})}},DateWareki:{index:i=>{let{min:e,max:d,onValueUpdate:o,sheetID:t,val_value:r,set_value:m}=i,{era:h,year:n,month:s,date:l}=r,u={val_value:r,set_value:m};return f(k,{children:[f(N.Left,{borderBottom:!0,gap:0,verticalAlign:"unset",children:[a(g.DateWareki.EraSelect,p({},u)),a(k,{borderRight:!0}),a(g.DateWareki.Calendar,p({},u))]}),a(N.Right,{padding:1,children:a(g.Variables.Footer,{sheetID:t,onValueUpdate:o})})]})},EraSelect:i=>{let{val_value:e,set_value:d}=i,o={padding:["1/2",1.5],fontColor:"3.blur"},t={backgroundColor:"cloud",fontColor:"2.normal",isSemiBoldFont:!0};return f(T,{padding:1,gap:0,children:[a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="year",onClick:()=>{let r=S();d({modifiedType:"update",era:"year",year:r.year,month:r.month,date:r.date})},children:"\u897F\u66A6"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="reiwa",onClick:()=>{let r=S();d({modifiedType:"update",era:"reiwa",year:r.year,month:r.month,date:r.date})},children:"\u4EE4\u548C"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="heisei",onClick:()=>{d({modifiedType:"update",era:"heisei",year:2019,month:1,date:1})},children:"\u5E73\u6210"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="shouwa",onClick:()=>{d({modifiedType:"update",era:"shouwa",year:1989,month:1,date:1})},children:"\u662D\u548C"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="taisho",onClick:()=>{d({modifiedType:"update",era:"taisho",year:1926,month:1,date:1})},children:"\u5927\u6B63"})),a(C.Clear,x(p({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="meiji",onClick:()=>{d({modifiedType:"update",era:"meiji",year:1912,month:1,date:1})},children:"\u660E\u6CBB"}))]})},Calendar:i=>{let{val_value:e,set_value:d}=i,o=[];if(e.era=="year"){let t=S().year+10;for(let r=1900;r<t;r++)o.unshift({value:r,label:r+"\u5E74"})}else if(e.era=="reiwa"){let t=S().year-2018;for(let r=1;r<=t+10;r++)o.unshift({value:2019+r-1,label:"\u4EE4\u548C"+(r==1?"\u5143":r)+"\u5E74"})}else if(e.era=="heisei")for(let t=1;t<=31;t++)o.unshift({value:1989+t-1,label:"\u5E73\u6210"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="shouwa")for(let t=1;t<=64;t++)o.unshift({value:1926+t-1,label:"\u662D\u548C"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="taisho")for(let t=1;t<=15;t++)o.unshift({value:1912+t-1,label:"\u5927\u6B63"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="meiji")for(let t=1;t<=45;t++)o.unshift({value:1868+t-1,label:"\u660E\u6CBB"+(t==1?"\u5143":t)+"\u5E74"});return f(T,{padding:1,children:[f(N.Separate,{children:[a(M,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,fontSize:"1.mini",SelectorStyles:{freeCSS:{minWidth:12*12}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(V.AngleDown,{})}),options:o,value:e.year,onUpdateValidValue:t=>{d(r=>x(p({},r),{modifiedType:"update",year:Number(t)}))}}),f(N.Center,{gap:"1/3",children:[a(M,{emptySelect:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:1,fontSize:"1.mini",SelectorStyles:{freeCSS:{minWidth:12*9}},rightIcon:a(B,{ssSphere:2,right:"1/3",children:a(V.AngleDown,{})}),options:[{value:1,label:"1\u6708"},{value:2,label:"2\u6708"},{value:3,label:"3\u6708"},{value:4,label:"4\u6708"},{value:5,label:"5\u6708"},{value:6,label:"6\u6708"},{value:7,label:"7\u6708"},{value:8,label:"8\u6708"},{value:9,label:"9\u6708"},{value:10,label:"10\u6708"},{value:11,label:"11\u6708"},{value:12,label:"12\u6708"}],value:e.month,onUpdateValidValue:t=>{d({modifiedType:"update",era:e.era,year:e.year,month:Number(t),date:1})}}),a(C.Clear.S,{ssSphere:2.5,onClick:()=>{let t=e.month-1;d({modifiedType:"update",era:e.era,year:t==0?e.year-1:e.year,month:t==0?12:t,date:1})},children:a(V.ChevronLeft,{})}),a(C.Clear.S,{ssSphere:2.5,onClick:()=>{let t=e.month+1;d({modifiedType:"update",era:e.era,year:t==13?e.year+1:e.year,month:t==13?1:t,date:1})},children:a(V.ChevronRight,{})})]})]}),a(g.DateWareki.MonthCell,p({},i))]},e.era)},MonthCell:i=>{let{val_value:e,set_value:d}=i,o=S([e.year.zeroEmbed(4),e.month.zeroEmbed(2),e.date.zeroEmbed(2)].join("/"));if(!o.validate)return;let t=o.getFirstDayOfMonth().weekday,r=o.getLastDayOfMonth(),m=[];for(let n=0;n<7;n++)m.push(a(G.Supplement,{flexCenter:!0,fontColor:n==0?"googleRed":n==6?"googleBlue":"3.blur",children:D.transformer.weekday.shortJP(n)},"legend-"+n));for(let n=0;n<t;n++){let s=S(o).getFirstDayOfMonth().addDate(n-t);m.push(a(C.Sub,{color:"cloud",ssSquare:3,opacity:"middle",onClick:l=>{l.preventDefault(),l.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"lastMonth-"+n))}let h=S();for(let n=1;n<=r.date;n++){let s=S(o).setDate(n),l=h.diff(s).dates==0;m.push(a(C.Clear,{ssSquare:3,fontColor:"2.normal",className:[y("CalendarDay"),y("isToday_"+l)].join(" "),onClick:()=>{d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"currentMonth-"+n))}for(let n=0;n<7-r.weekday-1;n++){let s=S(o).addMonth(1).setDate(1).addDate(n);m.push(a(C.Sub,{color:"cloud",ssSquare:3,opacity:"middle",onClick:l=>{l.preventDefault(),l.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"nextMonth-"+n))}return a(W,{gridCols:7,gap:"1/4",children:m})}},Variables:{Footer:i=>f(w,{flexWrap:!1,gap:1,flexChilds:"even",freeCSS:{whiteSpace:"nowrap"},children:[f(C.Sub.S,{color:"cloud",tabIndex:-1,isRounded:!0,onClick:()=>{i.onValueUpdate("")},flexSizing:"none",children:[a(V.X,{})," \u524A\u9664"]}),a(C.Prime.S,{tabIndex:-1,isRounded:!0,flexSizing:"auto",freeCSS:{minWidth:12*6},onClick:()=>{i.onSubmit&&i.onSubmit(),X.close(i.sheetID)},children:"\u6C7A\u5B9A"})]}),ShiftButtons:i=>f(w,{gap:"1/3",flexWrap:!1,children:[a(C.Clear,x(p({className:y("LeftButton"),tabIndex:-1,right:0},g.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(-1)},children:a(V.ChevronLeft,{})})),a(C.Clear,x(p({className:y("RightButton"),tabIndex:-1,left:0},g.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(1)},children:a(V.ChevronRight,{})}))]}),ShiftButtonStyles:{position:"relative",flexCenter:!0,ssSphere:2.5}}};export{j as Picker,j as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amotify",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.175",
|
|
4
4
|
"description": "UI Component for React,NextJS,esbuild",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "run-p clean build:*",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@fortawesome/free-solid-svg-icons": "^6.7.2",
|
|
91
91
|
"@fortawesome/react-fontawesome": "^0.2.2",
|
|
92
92
|
"dotenv": "^17.0.1",
|
|
93
|
-
"jmini": "^0.0.
|
|
93
|
+
"jmini": "^0.0.81",
|
|
94
94
|
"react": "^18.3.1"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|