amotify 0.1.31 → 0.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@declaration/_.js +1 -1
- package/dist/@styles/componentClasses/_.css +68 -65
- package/dist/@styles/componentClasses/_.js +39 -39
- package/dist/@styles/index.css +68 -65
- package/dist/@styles/index.js +39 -39
- package/dist/@styles/init.css +1 -1
- package/dist/@styles/style.css +68 -65
- package/dist/@styles/style.js +39 -39
- package/dist/@styles/var.css +1 -1
- package/dist/@utils/GenerateClassName.js +470 -1
- package/dist/@utils/LaunchReactApp.js +78 -1
- package/dist/@utils/_.js +12 -1
- package/dist/@utils/collectForm.js +96 -1
- package/dist/@utils/color.js +103 -1
- package/dist/@utils/config.js +101 -1
- package/dist/@utils/fin.js +39 -1
- package/dist/@utils/getElement.js +13 -1
- package/dist/@utils/jsminEx.js +172 -1
- package/dist/@utils/pageTransit.js +33 -1
- package/dist/@utils/useRecycle.js +44 -1
- package/dist/@utils/useStore.js +54 -1
- package/dist/atoms/Box.js +20 -1
- package/dist/atoms/FAI.js +148 -1
- package/dist/atoms/Flex.js +34 -1
- package/dist/atoms/Grid.js +17 -1
- package/dist/atoms/Img.js +65 -1
- package/dist/atoms/Logo.js +359 -51
- package/dist/atoms/P.js +20 -1
- package/dist/atoms/Placeholder.js +44 -1
- package/dist/atoms/Span.js +20 -1
- package/dist/atoms/_.js +9 -1
- package/dist/chunk-JJ3PEWPN.js +60 -0
- package/dist/fn/Button.js +316 -1
- package/dist/fn/Cropper.js +1009 -1
- package/dist/fn/Effect/Fade.js +88 -1
- package/dist/fn/Effect/Pudding.js +22 -1
- package/dist/fn/Effect/Ripple.js +117 -3
- package/dist/fn/Effect/_.js +14 -1
- package/dist/fn/Input/AutoHeightText.js +112 -1
- package/dist/fn/Input/Checker.js +36 -1
- package/dist/fn/Input/Chips/Selector.js +472 -1
- package/dist/fn/Input/Chips/_.js +349 -1
- package/dist/fn/Input/Contenteditable.js +160 -1
- package/dist/fn/Input/DigitCharacters.js +275 -1
- package/dist/fn/Input/Filer.js +619 -1
- package/dist/fn/Input/Hidden.js +48 -1
- package/dist/fn/Input/List.js +450 -1
- package/dist/fn/Input/Parts.js +121 -1
- package/dist/fn/Input/Plain.js +12 -1
- package/dist/fn/Input/RichSelect.js +279 -1
- package/dist/fn/Input/Search.js +53 -1
- package/dist/fn/Input/Segmented.js +245 -1
- package/dist/fn/Input/Select.js +278 -1
- package/dist/fn/Input/Slider.js +538 -1
- package/dist/fn/Input/Switch.js +221 -1
- package/dist/fn/Input/Text.js +626 -1
- package/dist/fn/Input/TextArea.js +151 -1
- package/dist/fn/Input/Time/Picker.js +1457 -1
- package/dist/fn/Input/Time/_.js +867 -1
- package/dist/fn/Input/_.js +48 -1
- package/dist/fn/Input/core.js +626 -1
- package/dist/fn/Layout/PageNotFound.js +90 -1
- package/dist/fn/Layout/PageRouter.js +87 -1
- package/dist/fn/Layout/PageViewController.js +29 -1
- package/dist/fn/Layout/Plate.js +37 -1
- package/dist/fn/Layout/RootViewController.js +315 -1
- package/dist/fn/Layout/SwipeView.js +348 -1
- package/dist/fn/Layout/TabBar.js +72 -1
- package/dist/fn/Layout/_.js +22 -1
- package/dist/fn/Loader/_.js +104 -1
- package/dist/fn/Loader/corner.js +85 -1
- package/dist/fn/Loader/mini.js +125 -1
- package/dist/fn/Loader/top.js +73 -1
- package/dist/fn/Sheet.js +1101 -1
- package/dist/fn/Snackbar.js +216 -1
- package/dist/fn/Table/Data.js +974 -1
- package/dist/fn/Table/Drag.js +435 -1
- package/dist/fn/Table/Normal.js +136 -1
- package/dist/fn/Table/Parts.js +41 -1
- package/dist/fn/Table/Wrapper.js +60 -1
- package/dist/fn/Table/_.js +16 -1
- package/dist/fn/Table/cellStyling.js +51 -1
- package/dist/fn/Tooltips.js +58 -1
- package/dist/fn/_.js +10 -1
- package/dist/index.js +20 -1
- package/dist/mols/Accordion.js +152 -1
- package/dist/mols/Column.js +16 -1
- package/dist/mols/LinkifyText.js +42 -1
- package/dist/mols/List.js +42 -1
- package/dist/mols/Row.js +47 -1
- package/dist/mols/Text.js +67 -1
- package/dist/mols/_.js +6 -1
- package/dist/temps/_.js +1 -1
- package/dist/temps/designBook.js +3639 -20
- package/package.json +1 -1
package/dist/fn/Input/Time/_.js
CHANGED
|
@@ -1 +1,867 @@
|
|
|
1
|
-
import{a as Y,b as o,c as _,d as H}from"../../../chunk-VY3566IV.js";import{Fragment as ke,jsx as T,jsxs as Z}from"react/jsx-runtime";import{useState as W,useEffect as X,useRef as re}from"react";import{$$ as b,$$fromRoot as ie,Config as z,useStore as O}from"../../../@utils/_";import ae from"../../../atoms/Box";import ne from"../../../atoms/FAI";import q from"../../Button";import G from"../../Tooltips";import{faClock as le}from"@fortawesome/free-solid-svg-icons/faClock";import{faCalendarAlt as oe}from"@fortawesome/free-solid-svg-icons/faCalendarAlt";import{Wrapper as se,BoxWrapper as ue,SubmitForm as pe,CommonEffects as me,DefaultStyles as ce}from"../core";import de from"../Hidden";import fe from"../Select";import he from"../Parts";import ge from"./Picker";const A=" ~ ",ye={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+A.length,length:4},{type:"month",from:15+A.length,length:2},{type:"date",from:18+A.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+A.length,length:4},{type:"month",from:13+A.length,length:2,region:3}],sets:2},dateWareki:{defaultValue:"----\u5E74--\u6708--\u65E5",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"dateWareki",from:0,length:4,region:5},{type:"month",from:5,length:2,region:3},{type:"date",from:8,length:2,region:3}],sets:1}},P=e=>{let{restrict:l,value:v,era:t}=e,D=b.flatArray(v||""),{defaultValue:h,format:d,ranges:m,sets:i}=ye[l],u=[],n=l=="clock"?":":"/";for(let a=0;a<D.length;a++)D[a]=String(D[a]).replace(/\D/ig,n);for(let a=0;a<i;a++){let c=D[a]||"";if(!c.match(d))D[a]="",u.push(h);else{let x=h;c.split(/\D/).forEach((S,R)=>{if(R==0&&l=="dateWareki"){let g=Number(S);t!="year"&&(g>=2019?t=="reiwa"?g-=2018:t=="heisei"&&(g=31):g>=1989?t=="heisei"?g-=1988:t=="shouwa"&&(g=64):g>=1926?t=="shouwa"?g-=1925:t=="taisho"&&(g=15):g>=1912?t=="taisho"?g-=1911:t=="meiji"&&(g=45):g>=1868&&(g-=1867)),S=g.zeroEmbed(4)}x=x.replace(new RegExp("------------------".slice(0,S.length)),S)}),u.push(x)}}return{formatValue:u.join(A),dataValue:["dates","months"].includes(l)?D:D[0],ranges:m}};function ve(e){let{params:l}=e,{restrict:v,min:t,max:D,required:h}=l,d=[],m=b.flatArray(e.value),i={empty:!1,escalated:1,filled:!0,correct:!0,prohibited:!1};(()=>{let u=v=="clock"?":":"/";for(let n=0;n<m.length;n++)m[n]=String(m[n]).replace(/\D/ig,u);for(let n=0;n<m.length;n++){let a=m[n],c=m[n-1];a.removeLetters()||(i.empty=!0),n>0&&(i.escalated&=+(a>=c))}i.escalated&&(i.empty||(v.match(/clock/)?m.forEach(n=>{let[a,c]=n.split(/\D+/);!a||!c?i.filled=!1:(Number(a)>23||Number(c)>59)&&(i.correct=!1)}):v.match(/date/)?m.forEach(n=>{let[a,c,x]=n.split(/\D+/);if(!a||!c||!x)i.filled=!1;else{let S=b.Time(n);(!S.validate||n!=S.toFormatYMD())&&(i.correct=!1)}}):v.match(/week/)?m.forEach(n=>{let[a,c]=n.split(/\D+/);if(!a||!c)i.filled=!1;else{let x=b.Time(a+"/01/01").weekday,R=b.Time(a+"/01/0"+(7-x+1)).addWeek(Number(c)-1);a!=String(R.year)&&(i.correct=!1)}}):v.match(/month/)?m.forEach(n=>{let[a,c]=n.split(/\D+/);!a||!c?i.filled=!1:b.Time([a,c,"01"].join("/")).validate||(i.correct=!1)}):v.match(/year/),i.filled&&i.correct&&m.forEach(n=>{{let a=Number(String(n).replace(/\D/ig,""));if(t&&Number(String(t).replace(/\D/ig,""))>a&&(i.prohibited=!0),D){let c=Number(String(D).replace(/\D/ig,""));a>c&&(i.prohibited=!0)}}})))})();{let{empty:u,escalated:n,filled:a,correct:c,prohibited:x}=i;u&&h&&(d=[{type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}]),n||d.push({type:"invalid",label:"\u6642\u7CFB\u5217\u3092\u6B63\u3057\u304F\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),c||d.push({type:"invalid",label:"\u7121\u52B9\u306A\u5024\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u3059"}),a||d.push({type:"invalid",label:"\u6700\u5F8C\u307E\u3067\u5024\u3092\u57CB\u3081\u3066\u304F\u3060\u3055\u3044"}),x&&d.push({type:"invalid",label:Z(ke,{children:[T(ae,{children:"\u5165\u529B\u7BC4\u56F2\u304C\u5236\u9650\u3055\u308C\u3066\u3044\u307E\u3059"}),"[",t||"\u4E0B\u9650\u7121\u3057","] ~ [",D||"\u4E0A\u9650\u7121\u3057","]"]})})}return{ok:!d.filter(({type:u})=>u=="invalid").length,notice:d}}const Q={picker:{launch:e=>{let l=e.tipsID||b.uuid.gen();G.open(_(o({gravityPoint:e.gravityPoint||24,padding:"1/2",tipsID:l},e),{close_option:o({aroundClick:!0,parentBlur:!1},e.close_option),content:T(ge,{restrict:e.restrict,min:e.min,max:e.max,era:e.era,defaultValue:e.defaultValue,tipsID:l,onValueUpdate:(v,t)=>{e.onValueUpdate(v,t)}})}))},remove:e=>{G.close(e)}}},De=e=>{let U=e,{tone:l,required:v,restrict:t="clock",componentID:D,era:h,form:d,name:m,min:i,max:u,className:n,enableFormSubmit:a,checkValidationAtFirst:c,onKeyDown:x,onValidate:S,onUpdateValue:R,onUpdateValidValue:g,value:$="",leftIndicator:J,rightIndicator:F}=U,f=H(U,["tone","required","restrict","componentID","era","form","name","min","max","className","enableFormSubmit","checkValidationAtFirst","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator"]),[r,C]=W(h),[s,V]=W(_(o({componentID:e.componentID||""},P({restrict:t,value:$,era:r})),{eventType:"init",eventID:b.uuid.gen()})),[y,M]=W({ok:!1,notice:[]}),[I,k]=W({active:!1,index:0,prevIndex:-1});me({type:"time",params:e,val_status:s,set_status:V,val_validate:y,set_validate:M,DefaultValidation:ve,onUpdateValue:R,onUpdateValidValue:g,ExtraOverrideParams:o({},P({restrict:t,value:$,era:r}))});const E=re(!1);return X(()=>{if(E.current){V(o(o({},s),P({restrict:t,value:s.dataValue,era:r})));let p=O.get("refreshEra_"+s.componentID);p&&p.refreshEra(r)}else E.current=!0},[r]),O.update({key:s.componentID,value:{openPicker:()=>{e.disabled||Q.picker.launch({parent:"#Picker-"+s.componentID,tipsID:"PickerTips-"+s.componentID,restrict:t,min:i,max:u,defaultValue:s.dataValue,era:r,onValueUpdate:(p,w)=>{V(_(o(o({},s),P({restrict:t,value:p,era:w})),{eventType:"update",eventID:b.uuid.gen()})),C(w)}})},resetEra:p=>{C(p),V(_(o(o({},s),P({restrict:t,value:"",era:r})),{eventType:"update",eventID:b.uuid.gen()}))}}}),X(()=>{let{index:p,active:w}=I;if(w){p=Math.max(p,0),p=Math.min(p,s.ranges.length-1);let{from:B,length:L}=s.ranges[p],j=ie("#"+e.id)[0];j&&j.setSelectionRange(B,B+L)}},[I]),Z(ue,{val_status:s,set_status:V,val_validate:y,params:e,children:[T(de,{name:m,"data-input-type":"time","data-form":d,"data-validation":y.ok,componentID:s.componentID,"data-value":JSON.stringify(["dates","months"].includes(t)?!s.dataValue[0]||!s.dataValue[1]?null:s.dataValue:s.dataValue||null)}),z.get().isTouchDevice?T(q.Button.Plain,{className:n,freeCSS:{textAlign:"left"},children:s.formatValue,onClick:p=>{let w=O.get(s.componentID);w&&w.openPicker(),p.stopPropagation()}}):T("input",o({type:"text",inputMode:"numeric","data-input-type":"time","data-form-name":d,value:s.formatValue,className:n,tabIndex:z.get().isTouchDevice?-1:0,onKeyDown:p=>{Ie({restrict:t,event:p,val_era:r,val_status:s,set_status:V,val_focus:I,set_focus:k}),x&&x(p),a&&pe(p)},onKeyUp:p=>{p.key=="Tab"&&k(_(o({},I),{active:!0}))},onClick:p=>{let w=p.target.selectionEnd,B=0;s.ranges.forEach((L,j)=>{let{from:K,length:ee,region:te}=L;K<=w&&w<=K+(te||ee)&&(B=j)}),k(_(o({},I),{active:!0,index:B})),p.preventDefault()},onChange:()=>{}},f))]})},Ie=e=>{let{val_era:l,restrict:v,event:t,val_status:D,set_status:h,val_focus:d,set_focus:m}=e,{key:i,shiftKey:u,ctrlKey:n,metaKey:a}=t,c=n||a,{selectionStart:x,selectionEnd:S}=t.target,{index:R,prevIndex:g}=d,{ranges:$,formatValue:J}=D,F=$.length-1;if(["Tab","ArrowLeft","ArrowRight"].includes(i)){let f=0;if(i=="Tab"){let r=+!u*2-1;if(f=d.index+r,f<0||f>F)return}else{let r=i=="ArrowLeft"?-1:i=="ArrowRight"?1:0;c||x==0&&S==String(D.formatValue).length?f=r==1?F:0:f=Math.max(0,Math.min(R+r,F))}m(_(o({},d),{index:f,prevIndex:R})),t.preventDefault()}if(["Backspace","ArrowUp","ArrowDown","0","1","2","3","4","5","6","7","8","9"].includes(i)){t.preventDefault();let f=R;f=Math.max(f,0),f=Math.min(f,F);let{type:r,from:C,length:s}=$[f],V=J.slice(C,C+s),y;if(i=="Backspace")y="------".slice(0,s);else if(["ArrowUp","ArrowDown"].includes(i)){let M=i=="ArrowUp"?1:-1;V=V|0,y=V+M;let[I,k,E]=r=="dateWareki"?l=="year"?[0,2999,4]:l=="reiwa"?[1,2999,4]:l=="heisei"?[1,31,4]:l=="shouwa"?[1,64,4]:l=="taisho"?[1,15,4]:l=="meiji"?[1,45,4]:[0,0,0]:r=="minute"?[0,59,2]:r=="hour"?[0,23,2]:r=="date"?[1,31,2]:r=="week"?[1,53,2]:r=="month"?[1,12,2]:r=="year"?[0,2999,4]:[0,0,0];y>k?y=I:y<I&&(y=k),y=Number(y).zeroEmbed(E)}else if(["0","1","2","3","4","5","6","7","8","9"].includes(i)){let M=V|0,I=i,k=`${M}${I}`;if(g!=R&&g>=0&&(M=0,k="0"+I),r=="year"||r=="dateWareki"&&l=="year")Number(k)>1e4?y=I:y=k,(y|0)>1e3&&f++;else if(["hour","minute","date","week","month"].includes(r)||r=="dateWareki"&&l!="year"){let E=r=="dateWareki"?l=="reiwa"?100:l=="heisei"?31:l=="shouwa"?64:l=="taisho"?15:l=="meiji"?45:0:r=="minute"?59:r=="hour"?23:r=="date"?31:r=="week"?53:r=="month"?12:0;y=(k|0)>E?I:k,(Number(I)>Number(String(E)[0])||V=="0000".slice(0,String(E).length)&&(k!="0000".slice(0,String(E).length)||["minute","hour"].includes(r)&&g==R)||(k|0)>=Y(10,String(E).length-1))&&f++}r=="year"||r=="dateWareki"?y=(y|0).zeroEmbed(4):y=(y|0).zeroEmbed(2)}{let M=String(J).partReplace(C,String(y)),I=M.split(A).map(k=>k.replace(/(^\D|\D$)/,"").split(/\D+/).join(v=="clock"?":":"/").replace(/(^\D|\D$)/,""));if(v=="dateWareki"){let k=I[0].split(/\D/),[E,U,p]=k;k.length==3&&E&&(I=[[Number(E)-1+Number({year:1,reiwa:2019,heisei:1989,shouwa:1926,taisho:1912,meiji:1868}[l]),U,p].join("/")])}f=Math.max(f,0),f=Math.min(f,F),h(_(o({},D),{dataValue:["dates","months"].includes(v)?I:I[0],formatValue:M,eventType:"update",eventID:b.uuid.gen()})),m(_(o({},d),{index:f,prevIndex:d.index}))}}},N={Origin:e=>{e=o({},e);let[l]=W(e.componentID||b.uuid.gen());if(e.componentID=l,b.is.nullish(e.rightIndicator)){let v=(e.restrict||"").match(/clock/)?le:oe;e.rightIndicator=T(he.RightIndicator,{padding:0,children:T(q.Button.Sub.R,{color:"cloud",border:"unset",padding:[0,1],fontColor:"theme",borderRadius:"inherit",backgroundColor:"inherit",flexCenter:!0,height:1,ssEffectsOnActive:["ripple.cloud"],tabIndex:-1,id:"Picker-"+e.componentID,onClick:()=>{let t=O.get(e.componentID);t&&t.openPicker()},children:T(ne,{icon:v})})})}return T(se,{componentID:e.componentID,children:De,params:ce.Boxish(e)})},Clock:e=>T(N.Origin,o({restrict:"clock",era:"clock"},e)),Date:e=>T(N.Origin,o({restrict:"date"},e)),Week:e=>T(N.Origin,o({restrict:"week"},e)),Month:e=>T(N.Origin,o({restrict:"month"},e)),Year:e=>T(N.Origin,o({restrict:"year"},e)),DateWareki:e=>{e=o({},e);let[l]=W(e.componentID||b.uuid.gen());e.componentID=l;let{defaultEra:v="wareki"}=e,[t,D]=W((()=>{let h="year";if(v=="wareki"&&(h="reiwa",e.value)){let[d,m,i]=e.value.split(/\D/);if(d&&m&&i){let u=Number(d);u>=2019?(u-=2019,h="reiwa"):u>=1989?(u-=1989,h="heisei"):u>=1926?(u-=1926,h="shouwa"):u>=1912?(u-=1912,h="taisho"):u>=1868&&(u-=1868,h="meiji"),u+=1}}return h})());return X(()=>{O.set({key:"refreshEra_"+l,value:{refreshEra:h=>{D(h)}}})},[]),T(N.Origin,_(o({restrict:"dateWareki",leftIndicator:T(fe,{enableUnSelected:!1,value:t,tone:e.tone,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:({value:h,eventType:d})=>{D(h);let m=O.get(e.componentID);m&&m.resetEra&&m.resetEra(h)}})},e),{era:t}))},Periods:{Date:e=>T(N.Origin,o({restrict:"dates"},e)),Month:e=>T(N.Origin,o({restrict:"months"},e))},fn:Q};export{N as Time,N as default};
|
|
1
|
+
import {
|
|
2
|
+
__objRest,
|
|
3
|
+
__pow,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues
|
|
6
|
+
} from "../../../chunk-JJ3PEWPN.js";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import {
|
|
9
|
+
useState,
|
|
10
|
+
useEffect,
|
|
11
|
+
useRef
|
|
12
|
+
} from "react";
|
|
13
|
+
import {
|
|
14
|
+
$$,
|
|
15
|
+
$$fromRoot,
|
|
16
|
+
Config,
|
|
17
|
+
useStore
|
|
18
|
+
} from "../../../@utils/_";
|
|
19
|
+
import Box from "../../../atoms/Box";
|
|
20
|
+
import FAI from "../../../atoms/FAI";
|
|
21
|
+
import Button from "../../Button";
|
|
22
|
+
import Tooltips from "../../Tooltips";
|
|
23
|
+
import { faClock } from "@fortawesome/free-solid-svg-icons/faClock";
|
|
24
|
+
import { faCalendarAlt } from "@fortawesome/free-solid-svg-icons/faCalendarAlt";
|
|
25
|
+
import {
|
|
26
|
+
Wrapper,
|
|
27
|
+
BoxWrapper,
|
|
28
|
+
SubmitForm,
|
|
29
|
+
CommonEffects,
|
|
30
|
+
DefaultStyles
|
|
31
|
+
} from "../core";
|
|
32
|
+
import Hidden from "../Hidden";
|
|
33
|
+
import Select from "../Select";
|
|
34
|
+
import Parts from "../Parts";
|
|
35
|
+
import Picker from "./Picker";
|
|
36
|
+
const PeriodMargin = " ~ ";
|
|
37
|
+
const TimeFormatDatas = {
|
|
38
|
+
clock: {
|
|
39
|
+
defaultValue: "--:--",
|
|
40
|
+
format: /^\d{2}\D\d{2}$/,
|
|
41
|
+
ranges: [
|
|
42
|
+
{ type: "hour", from: 0, length: 2 },
|
|
43
|
+
{ type: "minute", from: 3, length: 2 }
|
|
44
|
+
],
|
|
45
|
+
sets: 1
|
|
46
|
+
},
|
|
47
|
+
date: {
|
|
48
|
+
defaultValue: "----/--/--",
|
|
49
|
+
format: /^\d{4}\D\d{2}\D\d{2}$/,
|
|
50
|
+
ranges: [
|
|
51
|
+
{ type: "year", from: 0, length: 4 },
|
|
52
|
+
{ type: "month", from: 5, length: 2 },
|
|
53
|
+
{ type: "date", from: 8, length: 2 }
|
|
54
|
+
],
|
|
55
|
+
sets: 1
|
|
56
|
+
},
|
|
57
|
+
week: {
|
|
58
|
+
defaultValue: "----\u5E74\u7B2C--\u9031",
|
|
59
|
+
format: /^\d{4}\D\d{2}$/,
|
|
60
|
+
ranges: [
|
|
61
|
+
{ type: "year", from: 0, length: 4, region: 6 },
|
|
62
|
+
{ type: "week", from: 6, length: 2, region: 3 }
|
|
63
|
+
],
|
|
64
|
+
sets: 1
|
|
65
|
+
},
|
|
66
|
+
month: {
|
|
67
|
+
defaultValue: "----\u5E74--\u6708",
|
|
68
|
+
format: /^\d{4}\D\d{2}$/,
|
|
69
|
+
ranges: [
|
|
70
|
+
{ type: "year", from: 0, length: 4 },
|
|
71
|
+
{ type: "month", from: 5, length: 2, region: 3 }
|
|
72
|
+
],
|
|
73
|
+
sets: 1
|
|
74
|
+
},
|
|
75
|
+
year: {
|
|
76
|
+
defaultValue: "----\u5E74",
|
|
77
|
+
format: /^\d{4}$/,
|
|
78
|
+
ranges: [
|
|
79
|
+
{ type: "year", from: 0, length: 4, region: 5 }
|
|
80
|
+
],
|
|
81
|
+
sets: 1
|
|
82
|
+
},
|
|
83
|
+
dates: {
|
|
84
|
+
defaultValue: "----/--/--",
|
|
85
|
+
format: /^\d{4}\D\d{2}\D\d{2}$/,
|
|
86
|
+
ranges: [
|
|
87
|
+
{ type: "year", from: 0, length: 4 },
|
|
88
|
+
{ type: "month", from: 5, length: 2 },
|
|
89
|
+
{ type: "date", from: 8, length: 2, region: 5 },
|
|
90
|
+
{ type: "year", from: 10 + PeriodMargin.length, length: 4 },
|
|
91
|
+
{ type: "month", from: 15 + PeriodMargin.length, length: 2 },
|
|
92
|
+
{ type: "date", from: 18 + PeriodMargin.length, length: 2 }
|
|
93
|
+
],
|
|
94
|
+
sets: 2
|
|
95
|
+
},
|
|
96
|
+
months: {
|
|
97
|
+
defaultValue: "----\u5E74--\u6708",
|
|
98
|
+
format: /^\d{4}\D\d{2}$/,
|
|
99
|
+
ranges: [
|
|
100
|
+
{ type: "year", from: 0, length: 4 },
|
|
101
|
+
{ type: "month", from: 5, length: 2, region: 6 },
|
|
102
|
+
{ type: "year", from: 8 + PeriodMargin.length, length: 4 },
|
|
103
|
+
{ type: "month", from: 13 + PeriodMargin.length, length: 2, region: 3 }
|
|
104
|
+
],
|
|
105
|
+
sets: 2
|
|
106
|
+
},
|
|
107
|
+
dateWareki: {
|
|
108
|
+
defaultValue: "----\u5E74--\u6708--\u65E5",
|
|
109
|
+
format: /^\d{4}\D\d{2}\D\d{2}$/,
|
|
110
|
+
ranges: [
|
|
111
|
+
{ type: "dateWareki", from: 0, length: 4, region: 5 },
|
|
112
|
+
{ type: "month", from: 5, length: 2, region: 3 },
|
|
113
|
+
{ type: "date", from: 8, length: 2, region: 3 }
|
|
114
|
+
],
|
|
115
|
+
sets: 1
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const DataLeveling = (params) => {
|
|
119
|
+
let {
|
|
120
|
+
restrict,
|
|
121
|
+
value,
|
|
122
|
+
era
|
|
123
|
+
} = params;
|
|
124
|
+
let dataValue = $$.flatArray(value || "");
|
|
125
|
+
let {
|
|
126
|
+
defaultValue,
|
|
127
|
+
format,
|
|
128
|
+
ranges,
|
|
129
|
+
sets
|
|
130
|
+
} = TimeFormatDatas[restrict];
|
|
131
|
+
let formatValues = [];
|
|
132
|
+
let separateStr = restrict == "clock" ? ":" : "/";
|
|
133
|
+
for (let index = 0; index < dataValue.length; index++) {
|
|
134
|
+
dataValue[index] = String(dataValue[index]).replace(/\D/ig, separateStr);
|
|
135
|
+
}
|
|
136
|
+
for (let index = 0; index < sets; index++) {
|
|
137
|
+
let val = dataValue[index] || "";
|
|
138
|
+
if (!val.match(format)) {
|
|
139
|
+
dataValue[index] = "";
|
|
140
|
+
formatValues.push(defaultValue);
|
|
141
|
+
} else {
|
|
142
|
+
let _value = defaultValue;
|
|
143
|
+
val.split(/\D/).forEach((v, i) => {
|
|
144
|
+
if (i == 0 && restrict == "dateWareki") {
|
|
145
|
+
let Year = Number(v);
|
|
146
|
+
if (era != "year") {
|
|
147
|
+
if (Year >= 2019) {
|
|
148
|
+
if (era == "reiwa")
|
|
149
|
+
Year -= 2019 - 1;
|
|
150
|
+
else if (era == "heisei")
|
|
151
|
+
Year = 31;
|
|
152
|
+
} else if (Year >= 1989) {
|
|
153
|
+
if (era == "heisei")
|
|
154
|
+
Year -= 1989 - 1;
|
|
155
|
+
else if (era == "shouwa")
|
|
156
|
+
Year = 64;
|
|
157
|
+
} else if (Year >= 1926) {
|
|
158
|
+
if (era == "shouwa")
|
|
159
|
+
Year -= 1926 - 1;
|
|
160
|
+
else if (era == "taisho")
|
|
161
|
+
Year = 15;
|
|
162
|
+
} else if (Year >= 1912) {
|
|
163
|
+
if (era == "taisho")
|
|
164
|
+
Year -= 1912 - 1;
|
|
165
|
+
else if (era == "meiji")
|
|
166
|
+
Year = 45;
|
|
167
|
+
} else if (Year >= 1868)
|
|
168
|
+
Year -= 1868 - 1;
|
|
169
|
+
}
|
|
170
|
+
v = Year.zeroEmbed(4);
|
|
171
|
+
}
|
|
172
|
+
_value = _value.replace(new RegExp("------------------".slice(0, v.length)), v);
|
|
173
|
+
});
|
|
174
|
+
formatValues.push(_value);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
formatValue: formatValues.join(PeriodMargin),
|
|
179
|
+
dataValue: ["dates", "months"].includes(restrict) ? dataValue : dataValue[0],
|
|
180
|
+
ranges
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
function DefaultValidation(props) {
|
|
184
|
+
let {
|
|
185
|
+
params
|
|
186
|
+
} = props;
|
|
187
|
+
let {
|
|
188
|
+
restrict,
|
|
189
|
+
min,
|
|
190
|
+
max,
|
|
191
|
+
required
|
|
192
|
+
} = params;
|
|
193
|
+
let notice = [];
|
|
194
|
+
let values = $$.flatArray(props.value);
|
|
195
|
+
let validate = {
|
|
196
|
+
empty: false,
|
|
197
|
+
escalated: 1,
|
|
198
|
+
filled: true,
|
|
199
|
+
correct: true,
|
|
200
|
+
prohibited: false
|
|
201
|
+
};
|
|
202
|
+
(() => {
|
|
203
|
+
let separateStr = restrict == "clock" ? ":" : "/";
|
|
204
|
+
for (let index = 0; index < values.length; index++) {
|
|
205
|
+
values[index] = String(values[index]).replace(/\D/ig, separateStr);
|
|
206
|
+
}
|
|
207
|
+
for (let index = 0; index < values.length; index++) {
|
|
208
|
+
let value = values[index];
|
|
209
|
+
let prevValue = values[index - 1];
|
|
210
|
+
if (!value.removeLetters())
|
|
211
|
+
validate.empty = true;
|
|
212
|
+
if (index > 0)
|
|
213
|
+
validate.escalated &= Number(value >= prevValue);
|
|
214
|
+
}
|
|
215
|
+
if (!validate.escalated)
|
|
216
|
+
return;
|
|
217
|
+
if (validate.empty)
|
|
218
|
+
return;
|
|
219
|
+
if (restrict.match(/clock/)) {
|
|
220
|
+
values.forEach((value) => {
|
|
221
|
+
let [hour, minute] = value.split(/\D+/);
|
|
222
|
+
if (!hour || !minute) {
|
|
223
|
+
validate.filled = false;
|
|
224
|
+
} else if (Number(hour) > 23 || Number(minute) > 59) {
|
|
225
|
+
validate.correct = false;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
} else if (restrict.match(/date/)) {
|
|
229
|
+
values.forEach((value) => {
|
|
230
|
+
let [year, month, day] = value.split(/\D+/);
|
|
231
|
+
if (!year || !month || !day) {
|
|
232
|
+
validate.filled = false;
|
|
233
|
+
} else {
|
|
234
|
+
let Time2 = $$.Time(value);
|
|
235
|
+
if (!Time2.validate || value != Time2.toFormatYMD()) {
|
|
236
|
+
validate.correct = false;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
} else if (restrict.match(/week/)) {
|
|
241
|
+
values.forEach((value) => {
|
|
242
|
+
let [year, week] = value.split(/\D+/);
|
|
243
|
+
if (!year || !week) {
|
|
244
|
+
validate.filled = false;
|
|
245
|
+
} else {
|
|
246
|
+
let yearFirstDay = $$.Time(year + "/01/01").weekday;
|
|
247
|
+
let yearFirstWeek0Day = $$.Time(year + "/01/0" + (7 - yearFirstDay + 1));
|
|
248
|
+
let yearValueWeek0Day = yearFirstWeek0Day.addWeek(Number(week) - 1);
|
|
249
|
+
if (year != String(yearValueWeek0Day.year)) {
|
|
250
|
+
validate.correct = false;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
} else if (restrict.match(/month/)) {
|
|
255
|
+
values.forEach((value) => {
|
|
256
|
+
let [year, month] = value.split(/\D+/);
|
|
257
|
+
if (!year || !month) {
|
|
258
|
+
validate.filled = false;
|
|
259
|
+
} else {
|
|
260
|
+
let date = $$.Time([year, month, "01"].join("/"));
|
|
261
|
+
if (!date.validate)
|
|
262
|
+
validate.correct = false;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
} else if (restrict.match(/year/)) {
|
|
266
|
+
}
|
|
267
|
+
if (validate.filled && validate.correct) {
|
|
268
|
+
values.forEach((value) => {
|
|
269
|
+
{
|
|
270
|
+
let VAL = Number(String(value).replace(/\D/ig, ""));
|
|
271
|
+
if (min) {
|
|
272
|
+
let MIN = Number(String(min).replace(/\D/ig, ""));
|
|
273
|
+
if (MIN > VAL)
|
|
274
|
+
validate.prohibited = true;
|
|
275
|
+
}
|
|
276
|
+
if (max) {
|
|
277
|
+
let MAX = Number(String(max).replace(/\D/ig, ""));
|
|
278
|
+
if (VAL > MAX)
|
|
279
|
+
validate.prohibited = true;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
})();
|
|
285
|
+
{
|
|
286
|
+
let {
|
|
287
|
+
empty,
|
|
288
|
+
escalated,
|
|
289
|
+
filled,
|
|
290
|
+
correct,
|
|
291
|
+
prohibited
|
|
292
|
+
} = validate;
|
|
293
|
+
if (empty && required) {
|
|
294
|
+
notice = [
|
|
295
|
+
{ type: "invalid", label: "\u5FC5\u9808\u9805\u76EE\u3067\u3059" }
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
if (!escalated) {
|
|
299
|
+
notice.push({ type: "invalid", label: "\u6642\u7CFB\u5217\u3092\u6B63\u3057\u304F\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044" });
|
|
300
|
+
}
|
|
301
|
+
if (!correct) {
|
|
302
|
+
notice.push({ type: "invalid", label: "\u7121\u52B9\u306A\u5024\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u3059" });
|
|
303
|
+
}
|
|
304
|
+
if (!filled) {
|
|
305
|
+
notice.push({ type: "invalid", label: "\u6700\u5F8C\u307E\u3067\u5024\u3092\u57CB\u3081\u3066\u304F\u3060\u3055\u3044" });
|
|
306
|
+
}
|
|
307
|
+
if (prohibited) {
|
|
308
|
+
notice.push({
|
|
309
|
+
type: "invalid",
|
|
310
|
+
label: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
311
|
+
/* @__PURE__ */ jsx(Box, { children: "\u5165\u529B\u7BC4\u56F2\u304C\u5236\u9650\u3055\u308C\u3066\u3044\u307E\u3059" }),
|
|
312
|
+
"[",
|
|
313
|
+
min || "\u4E0B\u9650\u7121\u3057",
|
|
314
|
+
"] ~ [",
|
|
315
|
+
max || "\u4E0A\u9650\u7121\u3057",
|
|
316
|
+
"]"
|
|
317
|
+
] })
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return {
|
|
322
|
+
ok: !notice.filter(({ type }) => type == "invalid").length,
|
|
323
|
+
notice
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
const FNs = {
|
|
327
|
+
picker: {
|
|
328
|
+
launch: (params) => {
|
|
329
|
+
let tipsID = params.tipsID || $$.uuid.gen();
|
|
330
|
+
Tooltips.open(__spreadProps(__spreadValues({
|
|
331
|
+
gravityPoint: params.gravityPoint || 24,
|
|
332
|
+
padding: "1/2",
|
|
333
|
+
tipsID
|
|
334
|
+
}, params), {
|
|
335
|
+
close_option: __spreadValues({
|
|
336
|
+
aroundClick: true,
|
|
337
|
+
parentBlur: false
|
|
338
|
+
}, params.close_option),
|
|
339
|
+
content: /* @__PURE__ */ jsx(
|
|
340
|
+
Picker,
|
|
341
|
+
{
|
|
342
|
+
restrict: params.restrict,
|
|
343
|
+
min: params.min,
|
|
344
|
+
max: params.max,
|
|
345
|
+
era: params.era,
|
|
346
|
+
defaultValue: params.defaultValue,
|
|
347
|
+
tipsID,
|
|
348
|
+
onValueUpdate: (value, era) => {
|
|
349
|
+
params.onValueUpdate(value, era);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
)
|
|
353
|
+
}));
|
|
354
|
+
},
|
|
355
|
+
remove: (tipsID) => {
|
|
356
|
+
Tooltips.close(tipsID);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
const Component = (params) => {
|
|
361
|
+
let _a = params, {
|
|
362
|
+
tone,
|
|
363
|
+
required,
|
|
364
|
+
restrict = "clock",
|
|
365
|
+
componentID,
|
|
366
|
+
era,
|
|
367
|
+
form,
|
|
368
|
+
name,
|
|
369
|
+
min,
|
|
370
|
+
max,
|
|
371
|
+
className,
|
|
372
|
+
enableFormSubmit,
|
|
373
|
+
checkValidationAtFirst,
|
|
374
|
+
onKeyDown,
|
|
375
|
+
onValidate,
|
|
376
|
+
onUpdateValue,
|
|
377
|
+
onUpdateValidValue,
|
|
378
|
+
value = "",
|
|
379
|
+
leftIndicator,
|
|
380
|
+
rightIndicator
|
|
381
|
+
} = _a, others = __objRest(_a, [
|
|
382
|
+
"tone",
|
|
383
|
+
"required",
|
|
384
|
+
"restrict",
|
|
385
|
+
"componentID",
|
|
386
|
+
"era",
|
|
387
|
+
"form",
|
|
388
|
+
"name",
|
|
389
|
+
"min",
|
|
390
|
+
"max",
|
|
391
|
+
"className",
|
|
392
|
+
"enableFormSubmit",
|
|
393
|
+
"checkValidationAtFirst",
|
|
394
|
+
"onKeyDown",
|
|
395
|
+
"onValidate",
|
|
396
|
+
"onUpdateValue",
|
|
397
|
+
"onUpdateValidValue",
|
|
398
|
+
"value",
|
|
399
|
+
"leftIndicator",
|
|
400
|
+
"rightIndicator"
|
|
401
|
+
]);
|
|
402
|
+
let [val_era, set_era] = useState(era);
|
|
403
|
+
let [val_status, set_status] = useState(__spreadProps(__spreadValues({
|
|
404
|
+
componentID: params.componentID || ""
|
|
405
|
+
}, DataLeveling({
|
|
406
|
+
restrict,
|
|
407
|
+
value,
|
|
408
|
+
era: val_era
|
|
409
|
+
})), {
|
|
410
|
+
eventType: "init",
|
|
411
|
+
eventID: $$.uuid.gen()
|
|
412
|
+
}));
|
|
413
|
+
let [val_validate, set_validate] = useState({
|
|
414
|
+
ok: false,
|
|
415
|
+
notice: []
|
|
416
|
+
});
|
|
417
|
+
let [val_focus, set_focus] = useState({
|
|
418
|
+
active: false,
|
|
419
|
+
index: 0,
|
|
420
|
+
prevIndex: -1
|
|
421
|
+
});
|
|
422
|
+
CommonEffects({
|
|
423
|
+
type: "time",
|
|
424
|
+
params,
|
|
425
|
+
val_status,
|
|
426
|
+
set_status,
|
|
427
|
+
val_validate,
|
|
428
|
+
set_validate,
|
|
429
|
+
DefaultValidation,
|
|
430
|
+
onUpdateValue,
|
|
431
|
+
onUpdateValidValue,
|
|
432
|
+
ExtraOverrideParams: __spreadValues({}, DataLeveling({
|
|
433
|
+
restrict,
|
|
434
|
+
value,
|
|
435
|
+
era: val_era
|
|
436
|
+
}))
|
|
437
|
+
});
|
|
438
|
+
const mounted = useRef(false);
|
|
439
|
+
useEffect(() => {
|
|
440
|
+
if (mounted.current) {
|
|
441
|
+
set_status(__spreadValues(__spreadValues({}, val_status), DataLeveling({
|
|
442
|
+
restrict,
|
|
443
|
+
value: val_status.dataValue,
|
|
444
|
+
era: val_era
|
|
445
|
+
})));
|
|
446
|
+
let ParentComponent = useStore.get("refreshEra_" + val_status.componentID);
|
|
447
|
+
ParentComponent && ParentComponent.refreshEra(val_era);
|
|
448
|
+
} else {
|
|
449
|
+
mounted.current = true;
|
|
450
|
+
}
|
|
451
|
+
}, [val_era]);
|
|
452
|
+
useStore.update({
|
|
453
|
+
key: val_status.componentID,
|
|
454
|
+
value: {
|
|
455
|
+
openPicker: () => {
|
|
456
|
+
if (params.disabled)
|
|
457
|
+
return;
|
|
458
|
+
FNs.picker.launch({
|
|
459
|
+
parent: "#Picker-" + val_status.componentID,
|
|
460
|
+
tipsID: "PickerTips-" + val_status.componentID,
|
|
461
|
+
restrict,
|
|
462
|
+
min,
|
|
463
|
+
max,
|
|
464
|
+
defaultValue: val_status.dataValue,
|
|
465
|
+
era: val_era,
|
|
466
|
+
onValueUpdate: (value2, era2) => {
|
|
467
|
+
set_status(__spreadProps(__spreadValues(__spreadValues({}, val_status), DataLeveling({
|
|
468
|
+
restrict,
|
|
469
|
+
value: value2,
|
|
470
|
+
era: era2
|
|
471
|
+
})), {
|
|
472
|
+
eventType: "update",
|
|
473
|
+
eventID: $$.uuid.gen()
|
|
474
|
+
}));
|
|
475
|
+
set_era(era2);
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
},
|
|
479
|
+
resetEra: (era2) => {
|
|
480
|
+
set_era(era2);
|
|
481
|
+
set_status(__spreadProps(__spreadValues(__spreadValues({}, val_status), DataLeveling({
|
|
482
|
+
restrict,
|
|
483
|
+
value: "",
|
|
484
|
+
era: val_era
|
|
485
|
+
})), {
|
|
486
|
+
eventType: "update",
|
|
487
|
+
eventID: $$.uuid.gen()
|
|
488
|
+
}));
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
useEffect(() => {
|
|
493
|
+
let { index, active } = val_focus;
|
|
494
|
+
if (active) {
|
|
495
|
+
index = Math.max(index, 0);
|
|
496
|
+
index = Math.min(index, val_status.ranges.length - 1);
|
|
497
|
+
let { from, length } = val_status.ranges[index];
|
|
498
|
+
let input = $$fromRoot("#" + params.id)[0];
|
|
499
|
+
input && input.setSelectionRange(from, from + length);
|
|
500
|
+
}
|
|
501
|
+
}, [val_focus]);
|
|
502
|
+
return /* @__PURE__ */ jsxs(
|
|
503
|
+
BoxWrapper,
|
|
504
|
+
{
|
|
505
|
+
val_status,
|
|
506
|
+
set_status,
|
|
507
|
+
val_validate,
|
|
508
|
+
params,
|
|
509
|
+
children: [
|
|
510
|
+
/* @__PURE__ */ jsx(
|
|
511
|
+
Hidden,
|
|
512
|
+
{
|
|
513
|
+
name,
|
|
514
|
+
"data-input-type": "time",
|
|
515
|
+
"data-form": form,
|
|
516
|
+
"data-validation": val_validate.ok,
|
|
517
|
+
componentID: val_status.componentID,
|
|
518
|
+
"data-value": JSON.stringify(
|
|
519
|
+
["dates", "months"].includes(restrict) ? !val_status.dataValue[0] || !val_status.dataValue[1] ? null : val_status.dataValue : val_status.dataValue || null
|
|
520
|
+
)
|
|
521
|
+
}
|
|
522
|
+
),
|
|
523
|
+
Config.get().isTouchDevice ? /* @__PURE__ */ jsx(
|
|
524
|
+
Button.Button.Plain,
|
|
525
|
+
{
|
|
526
|
+
className,
|
|
527
|
+
freeCSS: {
|
|
528
|
+
textAlign: "left"
|
|
529
|
+
},
|
|
530
|
+
children: val_status.formatValue,
|
|
531
|
+
onClick: (event) => {
|
|
532
|
+
let component = useStore.get(val_status.componentID);
|
|
533
|
+
if (component)
|
|
534
|
+
component.openPicker();
|
|
535
|
+
event.stopPropagation();
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
) : /* @__PURE__ */ jsx(
|
|
539
|
+
"input",
|
|
540
|
+
__spreadValues({
|
|
541
|
+
type: "text",
|
|
542
|
+
inputMode: "numeric",
|
|
543
|
+
"data-input-type": "time",
|
|
544
|
+
"data-form-name": form,
|
|
545
|
+
value: val_status.formatValue,
|
|
546
|
+
className,
|
|
547
|
+
tabIndex: Config.get().isTouchDevice ? -1 : 0,
|
|
548
|
+
onKeyDown: (event) => {
|
|
549
|
+
KeyDownEvent({
|
|
550
|
+
restrict,
|
|
551
|
+
event,
|
|
552
|
+
val_era,
|
|
553
|
+
val_status,
|
|
554
|
+
set_status,
|
|
555
|
+
val_focus,
|
|
556
|
+
set_focus
|
|
557
|
+
});
|
|
558
|
+
if (onKeyDown)
|
|
559
|
+
onKeyDown(event);
|
|
560
|
+
if (enableFormSubmit)
|
|
561
|
+
SubmitForm(event);
|
|
562
|
+
},
|
|
563
|
+
onKeyUp: (event) => {
|
|
564
|
+
if (event.key == "Tab")
|
|
565
|
+
set_focus(__spreadProps(__spreadValues({}, val_focus), {
|
|
566
|
+
active: true
|
|
567
|
+
}));
|
|
568
|
+
},
|
|
569
|
+
onClick: (event) => {
|
|
570
|
+
let caretTo = event.target.selectionEnd;
|
|
571
|
+
let Index = 0;
|
|
572
|
+
val_status.ranges.forEach((range, index) => {
|
|
573
|
+
let { from, length, region } = range;
|
|
574
|
+
if (from <= caretTo && caretTo <= from + (region || length)) {
|
|
575
|
+
Index = index;
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
set_focus(__spreadProps(__spreadValues({}, val_focus), {
|
|
579
|
+
active: true,
|
|
580
|
+
index: Index
|
|
581
|
+
}));
|
|
582
|
+
event.preventDefault();
|
|
583
|
+
},
|
|
584
|
+
onChange: () => {
|
|
585
|
+
}
|
|
586
|
+
}, others)
|
|
587
|
+
)
|
|
588
|
+
]
|
|
589
|
+
}
|
|
590
|
+
);
|
|
591
|
+
};
|
|
592
|
+
const KeyDownEvent = (props) => {
|
|
593
|
+
let {
|
|
594
|
+
val_era,
|
|
595
|
+
restrict,
|
|
596
|
+
event,
|
|
597
|
+
val_status,
|
|
598
|
+
set_status,
|
|
599
|
+
val_focus,
|
|
600
|
+
set_focus
|
|
601
|
+
} = props;
|
|
602
|
+
let { key, shiftKey, ctrlKey, metaKey } = event;
|
|
603
|
+
let auxKey = ctrlKey || metaKey;
|
|
604
|
+
let {
|
|
605
|
+
selectionStart: caretFrom,
|
|
606
|
+
selectionEnd: caretTo
|
|
607
|
+
} = event.target;
|
|
608
|
+
let {
|
|
609
|
+
index: currentFocusIndex,
|
|
610
|
+
prevIndex: prevFocusIndex
|
|
611
|
+
} = val_focus;
|
|
612
|
+
let {
|
|
613
|
+
ranges,
|
|
614
|
+
formatValue
|
|
615
|
+
} = val_status;
|
|
616
|
+
let maxFocusIndex = ranges.length - 1;
|
|
617
|
+
if (["Tab", "ArrowLeft", "ArrowRight"].includes(key)) {
|
|
618
|
+
let nextFocusIndex = 0;
|
|
619
|
+
if (key == "Tab") {
|
|
620
|
+
let direction = Number(!shiftKey) * 2 - 1;
|
|
621
|
+
nextFocusIndex = val_focus.index + direction;
|
|
622
|
+
if (nextFocusIndex < 0 || nextFocusIndex > maxFocusIndex)
|
|
623
|
+
return;
|
|
624
|
+
} else {
|
|
625
|
+
let direction = key == "ArrowLeft" ? -1 : key == "ArrowRight" ? 1 : 0;
|
|
626
|
+
if (auxKey) {
|
|
627
|
+
nextFocusIndex = direction == 1 ? maxFocusIndex : 0;
|
|
628
|
+
} else {
|
|
629
|
+
if (caretFrom == 0 && caretTo == String(val_status.formatValue).length) {
|
|
630
|
+
nextFocusIndex = direction == 1 ? maxFocusIndex : 0;
|
|
631
|
+
} else {
|
|
632
|
+
nextFocusIndex = Math.max(0, Math.min(currentFocusIndex + direction, maxFocusIndex));
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
set_focus(__spreadProps(__spreadValues({}, val_focus), {
|
|
637
|
+
index: nextFocusIndex,
|
|
638
|
+
prevIndex: currentFocusIndex
|
|
639
|
+
}));
|
|
640
|
+
event.preventDefault();
|
|
641
|
+
}
|
|
642
|
+
if (["Backspace", "ArrowUp", "ArrowDown", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"].includes(key)) {
|
|
643
|
+
event.preventDefault();
|
|
644
|
+
let nextFocusIndex = currentFocusIndex;
|
|
645
|
+
nextFocusIndex = Math.max(nextFocusIndex, 0);
|
|
646
|
+
nextFocusIndex = Math.min(nextFocusIndex, maxFocusIndex);
|
|
647
|
+
let {
|
|
648
|
+
type,
|
|
649
|
+
from,
|
|
650
|
+
length
|
|
651
|
+
} = ranges[nextFocusIndex];
|
|
652
|
+
let prevValue = formatValue.slice(from, from + length);
|
|
653
|
+
let partsValue;
|
|
654
|
+
if (key == "Backspace") {
|
|
655
|
+
partsValue = "------".slice(0, length);
|
|
656
|
+
} else if (["ArrowUp", "ArrowDown"].includes(key)) {
|
|
657
|
+
let direction = key == "ArrowUp" ? 1 : -1;
|
|
658
|
+
prevValue = prevValue | 0;
|
|
659
|
+
partsValue = prevValue + direction;
|
|
660
|
+
let [min, max, range] = type == "dateWareki" ? val_era == "year" ? [0, 2999, 4] : val_era == "reiwa" ? [1, 2999, 4] : val_era == "heisei" ? [1, 31, 4] : val_era == "shouwa" ? [1, 64, 4] : val_era == "taisho" ? [1, 15, 4] : val_era == "meiji" ? [1, 45, 4] : [0, 0, 0] : type == "minute" ? [0, 59, 2] : type == "hour" ? [0, 23, 2] : type == "date" ? [1, 31, 2] : type == "week" ? [1, 53, 2] : type == "month" ? [1, 12, 2] : type == "year" ? [0, 2999, 4] : [0, 0, 0];
|
|
661
|
+
if (partsValue > max)
|
|
662
|
+
partsValue = min;
|
|
663
|
+
else if (partsValue < min)
|
|
664
|
+
partsValue = max;
|
|
665
|
+
partsValue = Number(partsValue).zeroEmbed(range);
|
|
666
|
+
} else if (["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"].includes(key)) {
|
|
667
|
+
let prev = prevValue | 0;
|
|
668
|
+
let add = key;
|
|
669
|
+
let compound = `${prev}${add}`;
|
|
670
|
+
if (prevFocusIndex != currentFocusIndex && prevFocusIndex >= 0) {
|
|
671
|
+
prev = 0, compound = "0" + add;
|
|
672
|
+
}
|
|
673
|
+
if (type == "year" || type == "dateWareki" && val_era == "year") {
|
|
674
|
+
if (Number(compound) > 1e4)
|
|
675
|
+
partsValue = add;
|
|
676
|
+
else
|
|
677
|
+
partsValue = compound;
|
|
678
|
+
if ((partsValue | 0) > 1e3)
|
|
679
|
+
nextFocusIndex++;
|
|
680
|
+
} else if (["hour", "minute", "date", "week", "month"].includes(type) || type == "dateWareki" && val_era != "year") {
|
|
681
|
+
let base = type == "dateWareki" ? val_era == "reiwa" ? 100 : val_era == "heisei" ? 31 : val_era == "shouwa" ? 64 : val_era == "taisho" ? 15 : val_era == "meiji" ? 45 : 0 : type == "minute" ? 59 : type == "hour" ? 23 : type == "date" ? 31 : type == "week" ? 53 : type == "month" ? 12 : 0;
|
|
682
|
+
partsValue = (compound | 0) > base ? add : compound;
|
|
683
|
+
if (Number(add) > Number(String(base)[0]) || prevValue == "0000".slice(0, String(base).length) && (compound != "0000".slice(0, String(base).length) || ["minute", "hour"].includes(type) && prevFocusIndex == currentFocusIndex) || (compound | 0) >= __pow(10, String(base).length - 1))
|
|
684
|
+
nextFocusIndex++;
|
|
685
|
+
}
|
|
686
|
+
if (type == "year" || type == "dateWareki")
|
|
687
|
+
partsValue = (partsValue | 0).zeroEmbed(4);
|
|
688
|
+
else
|
|
689
|
+
partsValue = (partsValue | 0).zeroEmbed(2);
|
|
690
|
+
}
|
|
691
|
+
{
|
|
692
|
+
let nextFormatValue = String(formatValue).partReplace(from, String(partsValue));
|
|
693
|
+
let nextDataValue = nextFormatValue.split(PeriodMargin).map((value) => {
|
|
694
|
+
return value.replace(/(^\D|\D$)/, "").split(/\D+/).join(restrict == "clock" ? ":" : "/").replace(/(^\D|\D$)/, "");
|
|
695
|
+
});
|
|
696
|
+
if (restrict == "dateWareki") {
|
|
697
|
+
let v = nextDataValue[0].split(/\D/);
|
|
698
|
+
let [year, month, day] = v;
|
|
699
|
+
if (v.length == 3 && year) {
|
|
700
|
+
let yearYear = Number(year) - 1 + Number(
|
|
701
|
+
{
|
|
702
|
+
year: 1,
|
|
703
|
+
reiwa: 2019,
|
|
704
|
+
heisei: 1989,
|
|
705
|
+
shouwa: 1926,
|
|
706
|
+
taisho: 1912,
|
|
707
|
+
meiji: 1868
|
|
708
|
+
}[val_era]
|
|
709
|
+
);
|
|
710
|
+
nextDataValue = [[yearYear, month, day].join("/")];
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
nextFocusIndex = Math.max(nextFocusIndex, 0);
|
|
714
|
+
nextFocusIndex = Math.min(nextFocusIndex, maxFocusIndex);
|
|
715
|
+
set_status(__spreadProps(__spreadValues({}, val_status), {
|
|
716
|
+
dataValue: ["dates", "months"].includes(restrict) ? nextDataValue : nextDataValue[0],
|
|
717
|
+
formatValue: nextFormatValue,
|
|
718
|
+
eventType: "update",
|
|
719
|
+
eventID: $$.uuid.gen()
|
|
720
|
+
}));
|
|
721
|
+
set_focus(__spreadProps(__spreadValues({}, val_focus), {
|
|
722
|
+
index: nextFocusIndex,
|
|
723
|
+
prevIndex: val_focus.index
|
|
724
|
+
}));
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
};
|
|
728
|
+
const Time = {
|
|
729
|
+
Origin: (rawParams) => {
|
|
730
|
+
rawParams = __spreadValues({}, rawParams);
|
|
731
|
+
let [val_componentID] = useState(rawParams.componentID || $$.uuid.gen());
|
|
732
|
+
rawParams.componentID = val_componentID;
|
|
733
|
+
if ($$.is.nullish(rawParams.rightIndicator)) {
|
|
734
|
+
let icon = (rawParams.restrict || "").match(/clock/) ? faClock : faCalendarAlt;
|
|
735
|
+
rawParams.rightIndicator = /* @__PURE__ */ jsx(
|
|
736
|
+
Parts.RightIndicator,
|
|
737
|
+
{
|
|
738
|
+
padding: 0,
|
|
739
|
+
children: /* @__PURE__ */ jsx(
|
|
740
|
+
Button.Button.Sub.R,
|
|
741
|
+
{
|
|
742
|
+
color: "cloud",
|
|
743
|
+
border: "unset",
|
|
744
|
+
padding: [0, 1],
|
|
745
|
+
fontColor: "theme",
|
|
746
|
+
borderRadius: "inherit",
|
|
747
|
+
backgroundColor: "inherit",
|
|
748
|
+
flexCenter: true,
|
|
749
|
+
height: 1,
|
|
750
|
+
ssEffectsOnActive: ["ripple.cloud"],
|
|
751
|
+
tabIndex: -1,
|
|
752
|
+
id: "Picker-" + rawParams.componentID,
|
|
753
|
+
onClick: () => {
|
|
754
|
+
let component = useStore.get(rawParams.componentID);
|
|
755
|
+
if (component)
|
|
756
|
+
component.openPicker();
|
|
757
|
+
},
|
|
758
|
+
children: /* @__PURE__ */ jsx(FAI, { icon })
|
|
759
|
+
}
|
|
760
|
+
)
|
|
761
|
+
}
|
|
762
|
+
);
|
|
763
|
+
}
|
|
764
|
+
return /* @__PURE__ */ jsx(
|
|
765
|
+
Wrapper,
|
|
766
|
+
{
|
|
767
|
+
componentID: rawParams.componentID,
|
|
768
|
+
children: Component,
|
|
769
|
+
params: DefaultStyles.Boxish(rawParams)
|
|
770
|
+
}
|
|
771
|
+
);
|
|
772
|
+
},
|
|
773
|
+
Clock: (props) => /* @__PURE__ */ jsx(Time.Origin, __spreadValues({ restrict: "clock", era: "clock" }, props)),
|
|
774
|
+
Date: (props) => /* @__PURE__ */ jsx(Time.Origin, __spreadValues({ restrict: "date" }, props)),
|
|
775
|
+
Week: (props) => /* @__PURE__ */ jsx(Time.Origin, __spreadValues({ restrict: "week" }, props)),
|
|
776
|
+
Month: (props) => /* @__PURE__ */ jsx(Time.Origin, __spreadValues({ restrict: "month" }, props)),
|
|
777
|
+
Year: (props) => /* @__PURE__ */ jsx(Time.Origin, __spreadValues({ restrict: "year" }, props)),
|
|
778
|
+
DateWareki: (params) => {
|
|
779
|
+
params = __spreadValues({}, params);
|
|
780
|
+
let [val_componentID] = useState(params.componentID || $$.uuid.gen());
|
|
781
|
+
params.componentID = val_componentID;
|
|
782
|
+
let {
|
|
783
|
+
defaultEra = "wareki"
|
|
784
|
+
} = params;
|
|
785
|
+
let [val_era, set_era] = useState((() => {
|
|
786
|
+
let era = "year";
|
|
787
|
+
if (defaultEra == "wareki") {
|
|
788
|
+
era = "reiwa";
|
|
789
|
+
if (params.value) {
|
|
790
|
+
let [year, month, date] = params.value.split(/\D/);
|
|
791
|
+
if (year && month && date) {
|
|
792
|
+
let Year = Number(year);
|
|
793
|
+
if (Year >= 2019) {
|
|
794
|
+
Year -= 2019, era = "reiwa";
|
|
795
|
+
} else if (Year >= 1989) {
|
|
796
|
+
Year -= 1989, era = "heisei";
|
|
797
|
+
} else if (Year >= 1926) {
|
|
798
|
+
Year -= 1926, era = "shouwa";
|
|
799
|
+
} else if (Year >= 1912) {
|
|
800
|
+
Year -= 1912, era = "taisho";
|
|
801
|
+
} else if (Year >= 1868) {
|
|
802
|
+
Year -= 1868, era = "meiji";
|
|
803
|
+
}
|
|
804
|
+
Year += 1;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
return era;
|
|
809
|
+
})());
|
|
810
|
+
useEffect(() => {
|
|
811
|
+
useStore.set({
|
|
812
|
+
key: "refreshEra_" + val_componentID,
|
|
813
|
+
value: {
|
|
814
|
+
refreshEra: (value) => {
|
|
815
|
+
set_era(value);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
}, []);
|
|
820
|
+
return /* @__PURE__ */ jsx(
|
|
821
|
+
Time.Origin,
|
|
822
|
+
__spreadProps(__spreadValues({
|
|
823
|
+
restrict: "dateWareki",
|
|
824
|
+
leftIndicator: /* @__PURE__ */ jsx(
|
|
825
|
+
Select,
|
|
826
|
+
{
|
|
827
|
+
enableUnSelected: false,
|
|
828
|
+
value: val_era,
|
|
829
|
+
tone: params.tone,
|
|
830
|
+
override: "force",
|
|
831
|
+
flexCenter: true,
|
|
832
|
+
borderTopRightRadius: "2/3",
|
|
833
|
+
borderBottomRightRadius: "2/3",
|
|
834
|
+
height: 1,
|
|
835
|
+
freeCSS: {
|
|
836
|
+
whiteSpace: "nowrap"
|
|
837
|
+
},
|
|
838
|
+
options: [
|
|
839
|
+
{ value: "year", label: "\u897F\u66A6" },
|
|
840
|
+
{ value: "reiwa", label: "\u4EE4\u548C" },
|
|
841
|
+
{ value: "heisei", label: "\u5E73\u6210" },
|
|
842
|
+
{ value: "shouwa", label: "\u662D\u548C" },
|
|
843
|
+
{ value: "taisho", label: "\u5927\u6B63" },
|
|
844
|
+
{ value: "meiji", label: "\u660E\u6CBB" }
|
|
845
|
+
],
|
|
846
|
+
onUpdateValidValue: ({ value, eventType }) => {
|
|
847
|
+
set_era(value);
|
|
848
|
+
let component = useStore.get(params.componentID);
|
|
849
|
+
component && component.resetEra && component.resetEra(value);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
)
|
|
853
|
+
}, params), {
|
|
854
|
+
era: val_era
|
|
855
|
+
})
|
|
856
|
+
);
|
|
857
|
+
},
|
|
858
|
+
Periods: {
|
|
859
|
+
Date: (props) => /* @__PURE__ */ jsx(Time.Origin, __spreadValues({ restrict: "dates" }, props)),
|
|
860
|
+
Month: (props) => /* @__PURE__ */ jsx(Time.Origin, __spreadValues({ restrict: "months" }, props))
|
|
861
|
+
},
|
|
862
|
+
fn: FNs
|
|
863
|
+
};
|
|
864
|
+
export {
|
|
865
|
+
Time,
|
|
866
|
+
Time as default
|
|
867
|
+
};
|