amotify 0.2.231 → 0.2.233

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.
@@ -2732,9 +2732,9 @@ const UserConfig = () => {
2732
2732
  }
2733
2733
 
2734
2734
  let DesignBook = () => {
2735
- let [ val_tabIndex,set_tabIndex ] = useState( Number( $$.queryParams.get().ti ) || 0 )
2735
+ let [ val_tabIndex,set_tabIndex ] = useState( Number( $$.url.search.get().ti ) || 0 )
2736
2736
  useEffect( () => {
2737
- $$.queryParams.set( { 'ti': String( val_tabIndex ) } )
2737
+ $$.url.search.set( { 'ti': String( val_tabIndex ) } )
2738
2738
  },[ val_tabIndex ] )
2739
2739
 
2740
2740
  // let [ val_refresh,set_refresh ] = useState( UUID() )
@@ -12,7 +12,7 @@
12
12
  "cross-env": "^7.0.3",
13
13
  "dotenv": "^16.4.5",
14
14
  "express": "^4.19.2",
15
- "jmini": "^0.0.98",
15
+ "jmini": "^0.0.102",
16
16
  "next": "^15.3.4",
17
17
  "node-cron": "^4.1.1",
18
18
  "nodemon": "^3.1.4",
@@ -2750,9 +2750,9 @@ const UserConfig = () => {
2750
2750
  }
2751
2751
 
2752
2752
  let DesignBook = () => {
2753
- let [ val_tabIndex,set_tabIndex ] = useState( Number( $$.queryParams.get().ti ) || 0 )
2753
+ let [ val_tabIndex,set_tabIndex ] = useState( Number( $$.url.search.get().ti ) || 0 )
2754
2754
  useEffect( () => {
2755
- $$.queryParams.set( { 'ti': String( val_tabIndex ) } )
2755
+ $$.url.search.set( { 'ti': String( val_tabIndex ) } )
2756
2756
  },[ val_tabIndex ] )
2757
2757
 
2758
2758
  // let [ val_refresh,set_refresh ] = useState( UUID() )
@@ -133,80 +133,27 @@ let Page = () => {
133
133
  val_value { val_value || "null" }
134
134
  </Literal>
135
135
 
136
- <Input.TextField.Money.JPY
137
- override='force'
136
+ <Input.Time.Date
137
+ form='test_form'
138
+ name='testing'
138
139
  value={ val_value || void 0 }
139
- // options={ [
140
- // { value: select1,label: "option1" },
141
- // { value: select2,label: "option2" },
142
- // { value: select3,label: "option3" }
143
- // ] }
144
- onUserAction={ ( value,event ) => {
145
- console.log( event )
146
- set_data( $$.Stringify( event ) )
147
- set_value( value || '' )
140
+ onUserAction={ async ( value,opt ) => {
141
+ console.log(
142
+ value,opt
143
+ )
148
144
  } }
149
145
  />
150
146
  <Literal.Description>
151
147
  { $$.Stringify( val_data ) }
152
148
  </Literal.Description>
153
- {/* <Column>
154
- <Input.Checker
155
- override='force'
156
- label='checker1'
157
- name='checker1'
158
- // options={ [
159
- // { label: 'checker1',value: true }
160
- // ] }
161
- value={ !!val_checked1 }
162
- onUpdateValidValue={ value => {
163
- set_checked1( !!value )
164
- } }
165
- />
166
- <Input.Checker
167
- override='force'
168
- label='checker2'
169
- name='checker2'
170
- // options={ [
171
- // { label: 'checker2',value: true }
172
- // ] }
173
- value={ !!val_checked2 }
174
- onUpdateValidValue={ value => {
175
- set_checked2( !!value )
176
- } }
177
- />
178
- </Column> */}
179
149
  </Box>
180
150
 
181
151
  <Button.Prime
182
- // submitOption={ {
183
- // formName: 'form_test',
184
- // callback: form => {
185
- // console.log( form )
186
- // }
187
- // } }
188
- onClick={ event => {
189
- let sheetID = 'sheet1'
190
- Sheet.open( 'topCenter',{
191
- // closeAtAroundClick: true,
192
- sheetID,
193
- padding: 4,
194
- content: () => {
195
- return <Sheet.Body>
196
- <Column padding={ 2 }>
197
- <Button.Sub
198
- onClick={ () => {
199
- Sheet.close( sheetID )
200
- } }
201
- >
202
- <FAI.X />
203
- </Button.Sub>
204
-
205
- { Array.from( { length: 100 } ).map( ( _,i ) => <Literal key={ i }>Item { i + 1 }</Literal> ) }
206
- </Column>
207
- </Sheet.Body>
208
- }
209
- } )
152
+ submitOption={ {
153
+ formName: 'test_form',
154
+ callback: form => {
155
+ console.log( form )
156
+ }
210
157
  } }
211
158
  >
212
159
  Submit
@@ -255,4 +202,5 @@ let Page = () => {
255
202
  }
256
203
 
257
204
  import dynamic from 'next/dynamic'
205
+ import { ok } from 'assert'
258
206
  export default dynamic( () => Promise.resolve( Page ),{ ssr: false } )
@@ -1 +1 @@
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:a,value:g,era:i}=e,f=ee.flatArray(g||""),{defaultValue:E,format:v,ranges:o,sets:r}=Re[a],S=[],n=a=="clock"&&":"||"/";for(let t=0;t<f.length;t++)f[t]=String(f[t]).replace(/\D/ig,n);for(let t=0;t<r;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&&a=="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(a)?f:f[0],ranges:o}},SystemValidation:e=>{let{states:a}=e,{restrict:g,min:i,max:f,required:E}=a,v=[],o=ee.flatArray(e.value),r={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()||(r.empty=!0),n>0&&(r.escalated&=+(t>=p))}r.escalated&&(r.empty||(g.match(/clock/)?o.forEach(n=>{let[t,p]=n.split(/\D+/);!t||!p?r.filled=!1:(Number(t)>23||Number(p)>59)&&(r.correct=!1)}):g.match(/date/)?o.forEach(n=>{let[t,p,T]=n.split(/\D+/);if(!t||!p||!T)r.filled=!1;else{let x=X.Time(n);(!x.validate||n!=x.toFormatYMD())&&(r.correct=!1)}}):g.match(/week/)?o.forEach(n=>{let[t,p]=n.split(/\D+/);if(!t||!p)r.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)&&(r.correct=!1)}}):g.match(/month/)?o.forEach(n=>{let[t,p]=n.split(/\D+/);!t||!p?r.filled=!1:X.Time([t,p,"01"].join("/")).validate||(r.correct=!1)}):g.match(/year/),r.filled&&r.correct&&o.forEach(n=>{{let t=Number(String(n).replace(/\D/ig,""));if(i&&Number(String(i).replace(/\D/ig,""))>t&&(r.prohibited=!0),f){let p=Number(String(f).replace(/\D/ig,""));t>p&&(r.prohibited=!0)}}})))})();{let{empty:S,escalated:n,filled:t,correct:p,prohibited:T}=r;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:a,restrict:g,event:i,val_status:f,set_status:E,val_focus:v,set_focus:o}=e,{key:r,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(r)){let y=0;if(r=="Tab"){let m=+!S*2-1;if(y=v.index+m,y<0||y>V)return}else{let m=r=="ArrowLeft"?-1:r=="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(r)){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(r=="Backspace")D="------".slice(0,Q);else if(["ArrowUp","ArrowDown"].includes(r)){let R=r=="ArrowUp"?1:-1;L=L|0,D=L+R;let[u,d,l]=m=="dateWareki"?a=="year"?[0,2999,4]:a=="reiwa"?[1,2999,4]:a=="heisei"?[1,31,4]:a=="shouwa"?[1,64,4]:a=="taisho"?[1,15,4]:a=="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(r)){let R=L|0,u=r,d=`${R}${u}`;if(I!=w&&(R=0,d="0"+u),m=="year"||m=="dateWareki"&&a=="year")Number(d)>1e4?D=u:D=d,(D|0)>1e3&&y++;else if(["hour","minute","date","week","month"].includes(m)||m=="dateWareki"&&a!="year"){let l=m=="dateWareki"?a=="reiwa"?100:a=="heisei"?31:a=="shouwa"?64:a=="taisho"?15:a=="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}[a]),_,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 a=e.sheetID||F(),p=e,{onValueUpdate:g,min:i,max:f,era:E,restrict:v,defaultValue:o}=p,r=K(p,["onValueUpdate","min","max","era","restrict","defaultValue"]),S=!1,n=null,t=null;Ie.open("middleCenter",k(s({sheetID:a,size:"S",padding:0,closeAtAroundClick:!0,closeAtParentBlur:!1,onClose:()=>{S&&g(n,t,!0)}},r),{content:h(ye.Center,{children:h(Ve,{restrict:v,min:i,max:f,era:E,defaultValue:o,sheetID:a,onValueUpdate:(T,x,w)=>{g(T,x,w),S=!w,n=T,t=x}})})}))},remove:e=>{ve.close(e)}}},_e={Shallow:e=>{let{rootStates:a,val_status:g}=e,i=fe(a);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:a.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:a,required:g,restrict:i="clock",componentId:f,era:E,form:v,name:o,min:r,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:r,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 a=s({fontSize:"inherit",width:1,value:""},e);a.value=a.value||"";let[g]=O(e.componentId||F());if(a.componentId=g,ee.is.nullish(a.rightIcon)){let i=(e.restrict||"").match(/clock/)?Se:Te;a.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-"+a.componentId,onClick:()=>{let f=B.get(a.componentId);f&&f.openPicker("#Picker-"+a.componentId)},children:h(he,{icon:i})})})}return h(De,{componentId:a.componentId,children:Ce,states:xe(a)})},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[a]=O(e.componentId||F());e.componentId=a;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[r,S,n]=e.value.split(/\D/);if(r&&S&&n){let t=Number(r);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_"+a]:{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 r=B.get(e.componentId);r&&r.resetEra&&r.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};
1
+ import{a as ie,b as o,c as b,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 O,useStore as U}from"jmini";import*as X from"jmini";import{useState as P,useEffect as z,useRef as pe}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 L=" ~ ",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+L.length,length:4},{type:"month",from:15+L.length,length:2},{type:"date",from:18+L.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+L.length,length:4},{type:"month",from:13+L.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}},F={PeriodMargin:" ~ ",DataLeveling:e=>{let{restrict:a,value:g,era:i}=e,f=ee.flatArray(g||""),{defaultValue:E,format:v,ranges:l,sets:r}=Re[a],S=[],n=a=="clock"&&":"||"/";for(let t=0;t<f.length;t++)f[t]=String(f[t]).replace(/\D/ig,n);for(let t=0;t<r;t++){let u=f[t]||"";if(!u.match(v))f[t]="",S.push(E);else{let T=E;u.split(/\D/).forEach((k,w)=>{if(w==0&&a=="dateWareki"){let I=Number(k);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)),k=I.zeroEmbed(4)}T=T.replace(new RegExp("------------------".slice(0,k.length)),k)}),S.push(T)}}return{formatValue:S.join(L),dataValue:["dates","months"].includes(a)?f:f[0],ranges:l}},SystemValidation:e=>{let{states:a}=e,{restrict:g,min:i,max:f,required:E}=a,v=[],l=ee.flatArray(e.value),r={empty:!1,escalated:1,filled:!0,correct:!0,prohibited:!1};(()=>{let S=g=="clock"&&":"||"/";for(let n=0;n<l.length;n++)l[n]=String(l[n]).replace(/\D/ig,S);for(let n=0;n<l.length;n++){let t=l[n],u=l[n-1];t.removeLetters()||(r.empty=!0),n>0&&(r.escalated&=+(t>=u))}r.escalated&&(r.empty||(g.match(/clock/)?l.forEach(n=>{let[t,u]=n.split(/\D+/);!t||!u?r.filled=!1:(Number(t)>23||Number(u)>59)&&(r.correct=!1)}):g.match(/date/)?l.forEach(n=>{let[t,u,T]=n.split(/\D+/);if(!t||!u||!T)r.filled=!1;else{let k=X.Time(n);(!k.validate||n!=k.toFormatYMD())&&(r.correct=!1)}}):g.match(/week/)?l.forEach(n=>{let[t,u]=n.split(/\D+/);if(!t||!u)r.filled=!1;else{let T=X.Time(t+"/01/01").weekday,w=X.Time(t+"/01/0"+(7-T+1)).addWeek(Number(u)-1);t!=String(w.year)&&(r.correct=!1)}}):g.match(/month/)?l.forEach(n=>{let[t,u]=n.split(/\D+/);!t||!u?r.filled=!1:X.Time([t,u,"01"].join("/")).validate||(r.correct=!1)}):g.match(/year/),r.filled&&r.correct&&l.forEach(n=>{{let t=Number(String(n).replace(/\D/ig,""));if(i&&Number(String(i).replace(/\D/ig,""))>t&&(r.prohibited=!0),f){let u=Number(String(f).replace(/\D/ig,""));t>u&&(r.prohibited=!0)}}})))})();{let{empty:S,escalated:n,filled:t,correct:u,prohibited:T}=r;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"}),u||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:a,restrict:g,event:i,val_status:f,set_status:E,val_focus:v,set_focus:l}=e,{key:r,shiftKey:S,ctrlKey:n,metaKey:t}=i,u=n||t,{selectionStart:T,selectionEnd:k}=i.target,{index:w,prevIndex:I}=v,{ranges:q,formatValue:G}=f,R=q.length-1;if(["Tab","ArrowLeft","ArrowRight"].includes(r)){let y=0;if(r=="Tab"){let c=+!S*2-1;if(y=v.index+c,y<0||y>R)return}else{let c=r=="ArrowLeft"?-1:r=="ArrowRight"?1:0;u||T==0&&k==String(f.formatValue).length?y=c==1?R:0:y=Math.max(0,Math.min(w+c,R))}l(c=>b(o({},c),{index:y,prevIndex:w})),i.preventDefault()}if(["Backspace","ArrowUp","ArrowDown","0","1","2","3","4","5","6","7","8","9"].includes(r)){i.preventDefault();let y=w;y=Math.max(y,0),y=Math.min(y,R);let{type:c,from:j,length:Q}=q[y],$=G.slice(j,j+Q),D;if(r=="Backspace")D="------".slice(0,Q);else if(["ArrowUp","ArrowDown"].includes(r)){let _=r=="ArrowUp"?1:-1;$=$|0,D=$+_;let[p,d,s]=c=="dateWareki"?a=="year"?[0,2999,4]:a=="reiwa"?[1,2999,4]:a=="heisei"?[1,31,4]:a=="shouwa"?[1,64,4]:a=="taisho"?[1,15,4]:a=="meiji"?[1,45,4]:[0,0,0]:c=="minute"?[0,59,2]:c=="hour"?[0,23,2]:c=="date"?[1,31,2]:c=="week"?[1,53,2]:c=="month"?[1,12,2]:c=="year"?[0,2999,4]:[0,0,0];D>d?D=p:D<p&&(D=d),D=Number(D).zeroEmbed(s)}else if(["0","1","2","3","4","5","6","7","8","9"].includes(r)){let _=$|0,p=r,d=`${_}${p}`;if(I!=w&&(_=0,d="0"+p),c=="year"||c=="dateWareki"&&a=="year")Number(d)>1e4?D=p:D=d,(D|0)>1e3&&y++;else if(["hour","minute","date","week","month"].includes(c)||c=="dateWareki"&&a!="year"){let s=c=="dateWareki"?a=="reiwa"?100:a=="heisei"?31:a=="shouwa"?64:a=="taisho"?15:a=="meiji"?45:0:c=="minute"?59:c=="hour"?23:c=="date"?31:c=="week"?53:c=="month"?12:0;D=(d|0)>s?p:d,(Number(p)>Number(String(s)[0])||$=="0000".slice(0,String(s).length)&&(d!="0000".slice(0,String(s).length)||["minute","hour"].includes(c)&&I==w)||(d|0)>=ie(10,String(s).length-1))&&y++}c=="year"||c=="dateWareki"?D=(D|0).zeroEmbed(4):D=(D|0).zeroEmbed(2)}{let _=String(G).partReplace(j,String(D)),p=_.split(L).map(d=>d.replace(/(^\D|\D$)/,"").split(/\D+/).join(g=="clock"&&":"||"/").replace(/(^\D|\D$)/,""));if(g=="dateWareki"){let d=p[0].split(/\D/),[s,V,M]=d;d.length==3&&s&&(p=[[Number(s)-1+Number({year:1,reiwa:2019,heisei:1989,shouwa:1926,taisho:1912,meiji:1868}[a]),V,M].join("/")])}y=Math.max(y,0),y=Math.min(y,R),E(d=>b(o({},d),{dataValue:["dates","months"].includes(g)?p:p[0],formatValue:_,eventType:"update",eventID:O()})),l(d=>b(o({},d),{index:y,prevIndex:d.index}))}}}},le={picker:{launch:e=>{let a=e.sheetID||O(),u=e,{onValueUpdate:g,min:i,max:f,era:E,restrict:v,defaultValue:l}=u,r=K(u,["onValueUpdate","min","max","era","restrict","defaultValue"]),S=!1,n=null,t=null;Ie.open("middleCenter",b(o({sheetID:a,size:"S",padding:0,closeAtAroundClick:!0,closeAtParentBlur:!1,onClose:()=>{S&&g(n,t,!0)}},r),{content:h(ye.Center,{children:h(Ve,{restrict:v,min:i,max:f,era:E,defaultValue:l,sheetID:a,onValueUpdate:(T,k,w)=>{g(T,k,w),S=!w,n=T,t=k}})})}))},remove:e=>{ve.close(e)}}},_e={Shallow:e=>{let{rootStates:a,val_status:g}=e,i=fe(a);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,b(o({className:a.className},i),{position:"absolute",width:1,freeCSS:b(o({},i.freeCSS),{color:"orange"}),children:h(H,{"data-input-value-shallow":g.componentId,children:"A"})}))})}},Ce=e=>{let ae=e,{tone:a,required:g,restrict:i="clock",componentId:f,era:E,form:v,name:l,min:r,max:S,className:n,enableFormSubmit:t,checkValidationAtFirst:u,onKeyDown:T,onValidate:k,onValidateDelay:w,onUpdateValue:I,onUpdateValidValue:q,onUserAction:G,value:R="",leftIndicator:y,rightIndicator:c,leftIcon:j,rightIcon:Q,freeCSS:$,wrapStyles:D}=ae,_=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"]),[p,d]=P(E),[s,V]=P(b(o({componentId:e.componentId||""},F.DataLeveling({restrict:i,value:R,era:p})),{ranges:[],eventType:"init",eventID:O()})),[M,Z]=P({ok:!1,notice:[]}),[J,N]=P({active:!1,index:0,prevIndex:-1}),me={rootStates:e,val_status:s,set_status:V,val_validate:M,set_validate:Z,val_era:p,set_era:d,val_focus:J,set_focus:N};Y.CommonEffects({type:"time",states:e,val_status:s,set_status:V,val_validate:M,set_validate:Z,SystemValidation:F.SystemValidation,ExtraOverrideStates:()=>F.DataLeveling({restrict:i,value:R,era:p})}),z(()=>{V(m=>o(o({},m),F.DataLeveling({restrict:i,value:R,era:p})))},[]);const te=pe(!1);return z(()=>{if(te.current){V(x=>o(o({},x),F.DataLeveling({restrict:i,value:x.dataValue,era:p})));let m=U.get("refreshEra_"+s.componentId);m&&m.refreshEra(p)}else te.current=!0},[p]),U.update({[s.componentId]:{openPicker:m=>{e.disabled||le.picker.launch({parent:m,sheetID:"PickerTips-"+s.componentId,restrict:i,min:r,max:S,defaultValue:s.dataValue,era:p,onValueUpdate:(x,C,W)=>{W&&(V(B=>b(o(o({},B),F.DataLeveling({restrict:i,value:x,era:C})),{eventType:"update",eventID:O()})),d(C))}})},resetEra:m=>{d(m),V(x=>b(o(o({},x),F.DataLeveling({restrict:i,value:"",era:p})),{eventType:"update",eventID:O()}))}}}),z(()=>{let{index:m,active:x}=J;if(x){m=Math.max(m,0),m=Math.min(m,s.ranges.length-1);let{from:C,length:W}=s.ranges[m],B=de("#"+e.id)[0];B&&B.setSelectionRange(C,C+W)}V(C=>b(o({},C),{isFocusing:x}))},[J]),se(be,{val_status:s,set_status:V,val_validate:M,states:e,children:[h(_e.Shallow,o({},me)),h(we,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:!0}),ne.get().isTouchDevice?h(oe.Plain,b(o({"data-show-validation":Y.isShowValidation(M,s,!!u),"data-component-id":s.componentId,"data-input-origin":s.componentId,"data-disabled":e.disabled,className:n,freeCSS:{textAlign:"left"}},_),{children:s.formatValue,onClick:m=>{let x=U.get(s.componentId);x&&x.openPicker(`[data-input-origin="${s.componentId}"]`),m.stopPropagation()},onFocus:()=>{N(m=>b(o({},m),{active:!0}))},onBlur:()=>{N(m=>b(o({},m),{active:!1}))}})):h(H,o({htmlTag:"input",type:"text",inputMode:"numeric","data-show-validation":Y.isShowValidation(M,s,!!u),"data-input-origin":s.componentId,"data-disabled":e.disabled,value:s.formatValue,className:n,tabIndex:ne.get().isTouchDevice?-1:0,onKeyDown:m=>{F.KeyDownEvent({restrict:i,event:m,val_era:p,val_status:s,set_status:V,val_focus:J,set_focus:N}),T&&T(m),t&&Y.SubmitForm(m,v)},onKeyUp:m=>{m.key=="Tab"&&N(x=>b(o({},x),{active:!0}))},onClick:m=>{let x=m.target.selectionEnd,C=0;s.ranges.forEach((W,B)=>{let{from:re,length:ce,region:ue}=W;re<=x&&x<=re+(ue||ce)&&(C=B)}),N(W=>b(o({},W),{active:!0,index:C})),m.preventDefault()},onBlur:()=>{N(m=>b(o({},m),{active:!1}))},onChange:()=>{}},_))]})},A={Origin:e=>{let a=o({fontSize:"inherit",width:1,value:""},e);a.value=a.value||"";let[g]=P(e.componentId||O());if(a.componentId=g,ee.is.nullish(a.rightIcon)){let i=(e.restrict||"").match(/clock/)?Se:Te;a.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-"+a.componentId,onClick:()=>{let f=U.get(a.componentId);f&&f.openPicker("#Picker-"+a.componentId)},children:h(he,{icon:i})})})}return h(De,{componentId:a.componentId,children:Ce,states:xe(a)})},Clock:e=>h(A.Origin,o({restrict:"clock",era:"clock"},e)),Date:e=>h(A.Origin,o({restrict:"date"},e)),Week:e=>h(A.Origin,o({restrict:"week"},e)),Month:e=>h(A.Origin,o({restrict:"month"},e)),Year:e=>h(A.Origin,o({restrict:"year"},e)),DateWareki:e=>{e=o({},e);let[a]=P(e.componentId||O());e.componentId=a;let v=e,{defaultEra:g="wareki"}=v,i=K(v,["defaultEra"]),[f,E]=P((()=>{let l="year";if(g=="wareki"&&(l="reiwa",e.value)){let[r,S,n]=e.value.split(/\D/);if(r&&S&&n){let t=Number(r);t>=2019?(t-=2019,l="reiwa"):t>=1989?(t-=1989,l="heisei"):t>=1926?(t-=1926,l="shouwa"):t>=1912?(t-=1912,l="taisho"):t>=1868&&(t-=1868,l="meiji"),t+=1}}return l})());return z(()=>{U.set({["refreshEra_"+a]:{refreshEra:l=>{E(l)}}})},[]),h(A.Origin,b(o({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:l=>{E(l);let r=U.get(e.componentId);r&&r.resetEra&&r.resetEra(l)}})},i),{era:f}))},Periods:{Date:e=>h(A.Origin,o({restrict:"dates"},e)),Month:e=>h(A.Origin,o({restrict:"months"},e))},fn:le};export{A as Time,A as default};
@@ -1 +1 @@
1
- import{b as n,c as d,e as _}from"../../chunk-C5N2D3ZX.js";import{jsx as m,jsxs as h}from"react/jsx-runtime";import{useState as x,useEffect as S}from"react";import p,{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 C,Column as F}from"../../atoms";import{Row as k,Literal as N}from"../../mols";import{Button as w}from"../Button";import R from"../Tooltips";const et=t=>{let[i]=x(t.componentId||v());t=n({},t),t.states=d(n({enableFormSubmit:!0,status_id:v(),override:"never",form:"",id:v(),"aria-label":"Input-"+i},t.states),{componentId:i});let{children:a}=t;return m(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=[]),h(k.Center,d(n({position:"relative",verticalAlign:"unset",gap:0},o),{className:b("Wrapper"),"data-notice-uid":a.componentId,children:[m(T.Notice,{notice:e.notice,val_status:a}),s.leftIndicator,h(E,{position:"relative",flexSizing:"auto",children:[i,r,m(T.RightIcon,n({},t)),m(T.ClearButton,n({},t))]}),s.rightIndicator]}))},T={ClearButton:t=>!t.states.clearButton||!t.val_status.dataValue?null:m(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=>d(n({},i),{dataValue:"",formatValue:"",eventType:"update",eventID:v()}))},children:m(C.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(()=>{p.interval.once(()=>{if(!i.length){R.close(o);return}R.open({tipsID:o,parent:`[data-notice-uid="${e}"]`,gravityPoint:24,padding:[1,0],closeAtParentBlur:!1,content:h(R.Body,{padding:["1/2","2/3"],fontSize:"1.mini",position:"relative",children:[m(B,{position:"absolute",unitHeight:1,unitWidth:1,right:1,backgroundColor:"dark",freeCSS:{zIndex:1,transform:"rotate(45deg)",top:-6}}),m(F,{backgroundColor:"inherit",gap:"1/3",position:"relative",freeCSS:{zIndex:2},children:i.map((y,I)=>{let{type:l,label:u}=y,f=l=="invalid"?C.Exclamation:l=="warn"?C.Exclamation:C.Check;return h(k.Left,{gap:0,borderRadius:"2.tone.secondary",children:[m(f,{flexCenter:!0,fontSize:"2.normal",fontColor:{invalid:"nega",warn:"warn",valid:"posi"}[l]}),m(N.Supplement,{fontSize:"0.xs",fontColor:"white",children:u})]},I+"-"+p.Stringify(y))})})]})})},350,s),p.interval.once(()=>{R.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,u)=>{g.get(I).ResolveRefresh=l,s(f=>d(n({},f),{isValidating:!0,eventType:"refresh",eventID:v()}))}),GenNotice:l=>{let{ok:u,notice:f}=l;o({ok:u,notice:f})}}}),()=>{g.delete(I)}),[]),p.scope(()=>{let{override:l}=a;if(l=="never"||l=="beforeModified"&&!["init","override"].includes(e.eventType)||e.isComposing)return;let u=g.get(e.componentId);if(!u)return;if(p.is.equal(a.value,e.dataValue)){u.status_id=a.status_id;return}let f=p.SortifyObject(a.value),c=p.SortifyObject(e.dataValue);if(f&&c&&p.is.equal(f,c)){u.status_id=a.status_id;return}a.status_id!=u.status_id&&s(V=>d(n(d(n({},V),{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:u,dataValue:f}=e,c=f;i=="autocomplete.single"||i=="list.radio"?c=c[0]:a.isChecker&&(c=!!c[0]),S(()=>(p.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||u!="refresh")return;let V=g.get(l);V&&V.ResolveRefresh&&V.ResolveRefresh(null)}),()=>{g.update({[["form-data",a.form].join("-")]:{[a.name]:null}})}),[e,r]),S(()=>{a.onUserAction&&a.onUserAction(c,{eventType:u,componentId:l,isValidated:!!r.ok,isComposing:!!e.isComposing,isFocusing:!!e.isFocusing})},[e]),S(()=>{u=="update"&&(a.onUpdateValue&&a.onUpdateValue(c,{eventType:u,componentId:l,isValidated:!!r.ok,isComposing:!!e.isComposing,isFocusing:!!e.isFocusing}),a.onUpdateValidValue&&r.ok&&a.onUpdateValidValue(c,{eventType:u,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;p.interval.abort(a),t.set_status(o=>d(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=>d(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=>d(n({},y),{isValidating:!1}))});if(i.onValidate){if(t.val_status.eventType=="refresh"){r();return}p.interval.once(r,i.onValidateDelay||500,a);return}t.set_validate({ok:!0,notice:s}),t.set_status(o=>d(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 p.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=p.scope(()=>{if(t.tone=="plain")return{};let e={padding:1,transition:"middle",flexSizing:"auto",boxShadow:"0.min"};return t.tone=="border"?e=d(n({},e),{border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"}):t.tone=="cloud"?e=d(n({},e),{border:"1.thin",borderRadius:"2.tone.secondary",backgroundColor:"cloud"}):t.tone=="bottomBorder"&&(e=d(n({},e),{borderRadius:0,border:"unset",borderBottom:!0,backgroundColor:"cloud"})),e});return d(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};
1
+ import{b as n,c as d,e as _}from"../../chunk-C5N2D3ZX.js";import{jsx as m,jsxs as h}from"react/jsx-runtime";import{useState as x,useEffect as S}from"react";import p,{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 C,Column as F}from"../../atoms";import{Row as k,Literal as N}from"../../mols";import{Button as w}from"../Button";import R from"../Tooltips";const et=t=>{let[i]=x(t.componentId||v());t=n({},t),t.states=d(n({enableFormSubmit:!0,status_id:v(),override:"never",form:"",id:v(),"aria-label":"Input-"+i},t.states),{componentId:i});let{children:a}=t;return m(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=[]),h(k.Center,d(n({position:"relative",verticalAlign:"unset",gap:0},o),{className:b("Wrapper"),"data-notice-uid":a.componentId,children:[m(T.Notice,{notice:e.notice,val_status:a}),s.leftIndicator,h(E,{position:"relative",flexSizing:"auto",children:[i,r,m(T.RightIcon,n({},t)),m(T.ClearButton,n({},t))]}),s.rightIndicator]}))},T={ClearButton:t=>!t.states.clearButton||!t.val_status.dataValue?null:m(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=>d(n({},i),{dataValue:"",formatValue:"",eventType:"update",eventID:v()}))},children:m(C.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(()=>{p.interval.once(()=>{if(!i.length){R.close(o);return}R.open({tipsID:o,parent:`[data-notice-uid="${e}"]`,gravityPoint:24,padding:[1,0],closeAtParentBlur:!1,content:h(R.Body,{padding:["1/2","2/3"],fontSize:"1.mini",position:"relative",children:[m(B,{position:"absolute",unitHeight:1,unitWidth:1,right:1,backgroundColor:"dark",freeCSS:{zIndex:1,transform:"rotate(45deg)",top:-6}}),m(F,{backgroundColor:"inherit",gap:"1/3",position:"relative",freeCSS:{zIndex:2},children:i.map((y,I)=>{let{type:l,label:u}=y,f=l=="invalid"?C.Exclamation:l=="warn"?C.Exclamation:C.Check;return h(k.Left,{gap:0,borderRadius:"2.tone.secondary",children:[m(f,{flexCenter:!0,fontSize:"2.normal",fontColor:{invalid:"nega",warn:"warn",valid:"posi"}[l]}),m(N.Supplement,{fontSize:"0.xs",fontColor:"white",children:u})]},I+"-"+p.Stringify(y))})})]})})},350,s),p.interval.once(()=>{R.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,u)=>{g.get(I).ResolveRefresh=l,s(f=>d(n({},f),{isValidating:!0,eventType:"refresh",eventID:v()}))}),GenNotice:l=>{let{ok:u,notice:f}=l;o({ok:u,notice:f})}}}),()=>{g.delete(I)}),[]),p.scope(()=>{let{override:l}=a;if(l=="never"||l=="beforeModified"&&!["init","override"].includes(e.eventType)||e.isComposing)return;let u=g.get(e.componentId);if(!u)return;if(p.is.equal(a.value,e.dataValue)){u.status_id=a.status_id;return}let f=p.SortifyObject(a.value),c=p.SortifyObject(e.dataValue);if(f&&c&&p.is.equal(f,c)){u.status_id=a.status_id;return}a.status_id!=u.status_id&&s(V=>d(n(d(n({},V),{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:u,dataValue:f}=e,c=f;i=="autocomplete.single"||i=="list.radio"?c=c[0]:a.isChecker&&(c=!!c[0]),S(()=>(p.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||u!="refresh")return;let V=g.get(l);V&&V.ResolveRefresh&&V.ResolveRefresh(null)}),()=>{g.update({[["form-data",a.form].join("-")]:{[a.name]:null}})}),[e,r]),S(()=>{a.onUserAction&&a.onUserAction(c,{eventType:u,componentId:l,isValidated:!!r.ok,isComposing:!!e.isComposing,isFocusing:!!e.isFocusing})},[e]),S(()=>{u=="update"&&(a.onUpdateValue&&a.onUpdateValue(c,{eventType:u,componentId:l,isValidated:!!r.ok,isComposing:!!e.isComposing,isFocusing:!!e.isFocusing}),a.onUpdateValidValue&&r.ok&&a.onUpdateValidValue(c,{eventType:u,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;p.interval.abort(a),t.set_status(o=>d(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=>d(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.val_status);t.set_validate({ok:o.ok,notice:[...s,...o.notice]}),t.set_status(y=>d(n({},y),{isValidating:!1}))});if(i.onValidate){if(t.val_status.eventType=="refresh"){r();return}p.interval.once(r,i.onValidateDelay||500,a);return}t.set_validate({ok:!0,notice:s}),t.set_status(o=>d(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 p.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=p.scope(()=>{if(t.tone=="plain")return{};let e={padding:1,transition:"middle",flexSizing:"auto",boxShadow:"0.min"};return t.tone=="border"?e=d(n({},e),{border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"}):t.tone=="cloud"?e=d(n({},e),{border:"1.thin",borderRadius:"2.tone.secondary",backgroundColor:"cloud"}):t.tone=="bottomBorder"&&(e=d(n({},e),{borderRadius:0,border:"unset",borderBottom:!0,backgroundColor:"cloud"})),e});return d(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};
@@ -1,4 +1,3 @@
1
- import { KeyValueDict } from 'jmini';
2
1
  import { ReactElement, StyleTags } from '../../@declares';
3
2
  export declare namespace InputTypes {
4
3
  type BoxTone = 'border' | 'cloud' | 'bottomBorder' | 'plain';
@@ -51,7 +50,7 @@ export declare namespace InputTypes {
51
50
  value: any;
52
51
  states: any;
53
52
  }) => Result;
54
- type OnValidate<T = any> = (value: T, eventType: EventType, props: KeyValueDict) => Promise<Result>;
53
+ type OnValidate<T = any> = (value: T, eventType: EventType, opt: Status.Plain) => Promise<Result>;
55
54
  }
56
55
  namespace Status {
57
56
  type Plain<T = any> = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amotify",
3
- "version": "0.2.231",
3
+ "version": "0.2.233",
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.100",
93
+ "jmini": "^0.0.102",
94
94
  "react": "^18.3.1"
95
95
  },
96
96
  "devDependencies": {