amotify 0.2.23 → 0.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demo/esbuild/public/index.css +1 -1
- package/demo/esbuild/public/index.js +94 -94
- package/dist/@declares/property.d.ts +1 -2
- package/dist/@styles/componentClasses/index.css +1 -1
- package/dist/@styles/componentClasses/index.js +1 -1
- package/dist/@styles/index.css +1 -1
- package/dist/@styles/index.js +1 -1
- package/dist/@styles/style.css +1 -1
- package/dist/@styles/style.js +1 -1
- package/dist/@utils/GenerateClassName.d.ts +10 -5
- package/dist/@utils/GenerateClassName.js +1 -1
- package/dist/atoms/Box.js +1 -1
- package/dist/atoms/FAI.js +1 -1
- package/dist/atoms/Flex.js +1 -1
- package/dist/atoms/Grid.js +1 -1
- package/dist/atoms/Img.js +1 -1
- package/dist/atoms/Logo.js +4 -4
- package/dist/atoms/P.js +1 -1
- package/dist/atoms/Placeholder.js +1 -1
- package/dist/atoms/Span.js +1 -1
- package/dist/fn/Button.js +1 -1
- package/dist/fn/Cropper.d.ts +3 -0
- package/dist/fn/Cropper.js +1 -1
- package/dist/fn/Effect/Fade.js +1 -1
- package/dist/fn/Input/AutoHeightText.js +1 -1
- package/dist/fn/Input/Checker.d.ts +2 -2
- package/dist/fn/Input/Checker.js +1 -1
- package/dist/fn/Input/Chips/Selector.js +1 -1
- package/dist/fn/Input/Chips/index.js +1 -1
- package/dist/fn/Input/Contenteditable.js +1 -1
- package/dist/fn/Input/DigitCharacters.js +1 -1
- package/dist/fn/Input/Filer.js +1 -1
- package/dist/fn/Input/List.js +1 -1
- package/dist/fn/Input/Parts.js +1 -1
- package/dist/fn/Input/Plain.js +1 -1
- package/dist/fn/Input/RichSelect.js +1 -1
- package/dist/fn/Input/Search.js +1 -1
- package/dist/fn/Input/Segmented.js +1 -1
- package/dist/fn/Input/Select.js +1 -1
- package/dist/fn/Input/Slider.js +1 -1
- package/dist/fn/Input/Switch.js +1 -1
- package/dist/fn/Input/Text.js +1 -1
- package/dist/fn/Input/TextArea.js +1 -1
- package/dist/fn/Input/Time/Picker.js +1 -1
- package/dist/fn/Input/Time/index.js +1 -1
- package/dist/fn/Input/core.d.ts +3 -3
- package/dist/fn/Input/core.js +1 -1
- package/dist/fn/Input/index.d.ts +3 -3
- package/dist/fn/Loader/corner.js +1 -1
- package/dist/fn/Loader/mini.js +1 -1
- package/dist/fn/PageNotFound.js +1 -1
- package/dist/fn/Plate.js +1 -1
- package/dist/fn/RootViewController.js +1 -1
- package/dist/fn/Sheet.js +1 -1
- package/dist/fn/Snackbar.js +1 -1
- package/dist/fn/SwipeView.js +1 -1
- package/dist/fn/TabBar.js +1 -1
- package/dist/fn/Table/Data.js +1 -1
- package/dist/fn/Table/Drag.js +1 -1
- package/dist/fn/Table/Normal.js +1 -1
- package/dist/fn/Table/Parts.js +1 -1
- package/dist/fn/Table/Wrapper.js +1 -1
- package/dist/fn/Tooltips.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/mols/Accordion.js +1 -1
- package/dist/mols/Column.js +1 -1
- package/dist/mols/List.js +1 -1
- package/dist/mols/Row.js +1 -1
- package/dist/mols/Text.js +1 -1
- package/dist/temps/designBook.js +20 -20
- package/package.json +2 -2
package/dist/fn/Input/Filer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as v,c as b,d as Q,e as $}from"../../chunk-C5N2D3ZX.js";import{Fragment as te,jsx as n,jsxs as r}from"react/jsx-runtime";import{useState as j,useEffect as le}from"react";import S from"@mingoo/jsmin";import{$$fromRoot as P,useStore as X,GenerateHTMLProps as ne}from"../../@utils";import F from"../../atoms/Box";import L from"../../atoms/FAI";import M from"../../atoms/Flex";import Y from"../../mols/Column";import ie from"../../mols/Row";import W from"../Button";import H from"../Snackbar";import{Wrapper as oe,BoxWrapper as se,CommonEffects as re,DefaultStyles as pe}from"./core";import ue from"./Text";import{InputFilerClasses as c}from"../../@styles/componentClasses";import{faCloudArrowUp as me}from"@fortawesome/free-solid-svg-icons/faCloudArrowUp";function de(e){let{value:t,states:a}=e,{required:s}=a,l=[];return s&&!t.length&&l.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!l.filter(({type:p})=>p=="invalid").length,notice:l}}const ee={List:e=>{let{files:t,states:a,val_status:s,set_status:l}=e,p=(a.limit||1)-s.dataValue.length,m=t.map((u,B)=>n(ee.Cell,{index:B,file:u,className:a.cellClassName,val_status:s,set_status:l,fileNameEdit:a.fileNameEdit},u.name));return p>0&&m.push(n("label",{className:[a.cellClassName,c("AddButton")].join(" "),"data-component-id":s.componentID,htmlFor:a.id,tabIndex:a.tabIndex,onKeyDown:u=>{let{key:B}=u;a.tabIndex!=-1&&[" ","Enter"].includes(B)&&P("#"+a.id).click()},children:r(ie.Center,{padding:["1/3",0],children:[n(F,{isRounded:!0,className:c("AddIcon"),children:n(L,{icon:me,className:c("Icon"),fontColor:"theme",fontSize:"4.thirdTitle",backgroundColor:"theme.opa.low",ssSphere:3,padding:"1/2"})}),r(F,{children:[r(F,{fontColor:"theme",fontSize:"2.normal",isSemiBoldFont:!0,children:["\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E(",p,")"]}),n(F,{fontColor:"4.thin",fontSize:"0.xs",isSemiBoldFont:!0,children:"\u30D5\u30A1\u30A4\u30EB\u3092\u30C9\u30ED\u30C3\u30D7"})]})]})},"AddButton")),n(Y,{flexSizing:"auto",className:a.className,children:m})},Cell:e=>{let{index:t,file:a,className:s,val_status:l,set_status:p,fileNameEdit:m=!0}=e,{name:u,size:B,type:i}=a,[A,N]=j(!1),T=S.uuid.gen(),V=B.rank(),[K,O]=u.replace(/\s/,"").replace(/(.*)\.(.*)$/,"$1 $2").split(" "),o="\u30D5\u30A1\u30A4\u30EB";return i.match(/image/)?o=i.replace(/image\//,""):i.match(/pdf/)?o="PDF":i.match(/csv/)?o="CSV":i.match(/spreadsheet/)?o="SpreadSheet":i.match(/presentation/)?o="PowerPoint":i.match(/word/)?o="Word":i.match(/zip/)?o="Zip":i.match(/powerpoint/)?o="PowerPoint":i.match(/html/)?o="HTML":i.match(/js/)?o="JavaScript":i.match(/css/)?o="CSS":i.match(/text\/plain/)&&(o="\u30C6\u30AD\u30B9\u30C8"),le(()=>{A&&setTimeout(()=>{P("#"+T).focus()},100)},[A]),r(M,{verticalAlign:"center",flexWrap:!1,gap:1,className:s,children:[n(L.File,{fontSize:"4.thirdTitle",fontColor:"4.thin"}),r(F,{flexSizing:0,children:[n(F,{children:n(M,{verticalAlign:"center",gap:"2/3",flexWrap:!1,className:c("FileName"),children:A?n(te,{children:r(Y,{flexSizing:0,gap:"1/2",children:[r(M,{gap:"2/3",verticalAlign:"center",children:[n(ue.Normal,{tone:"border",wrapStyles:{flexSizing:"auto"},restrict:"fileName",name:"name",required:!0,id:T,form:"form-"+T,enableFormSubmit:!0,value:K,onKeyDown:g=>{let{key:_}=g;_=="Escape"&&N(!1)}}),r(F,{children:[". ",O]})]}),r(M,{gap:"2/3",horizontalAlign:"right",flexWrap:!1,children:[n(W.Button.Sub.R,{padding:["2/3",1],onClick:()=>{N(!1)},children:"\u9589\u3058\u308B"}),n(W.Button.Prime.R,{padding:["2/3",1],submitOption:{formName:"form-"+T,callback:g=>$(void 0,null,function*(){let{name:_}=g,D=[...l.dataValue],k=D[t],G=k.id;if(!k)return;let{target:z}=yield k.convert();if(!z)return;let d=yield String(z.result).toBlob(a.type);if(!d)return;let y=new File([d],_+"."+O,{type:k.type});y.id=G,D[t]=y,p(R=>b(v({},R),{dataValue:D,eventType:"update",eventID:S.uuid.gen()})),N(!1)})},children:"\u6C7A\u5B9A"})]})]})}):r(te,{children:[u,!!m&&n(W.Button.Clear.R,{ssSphere:2.5,flexSizing:"none",fontColor:"4.thin",padding:"1/3",ssEffectsOnActive:"expand",color:"cloud",onClick:()=>{N(!0)},children:n(L.Pen,{})})]})})}),!A&&r(F,{fontSize:"1.mini",fontColor:"4.thin",flexSizing:0,children:[o,"\u30D5\u30A1\u30A4\u30EB / ",V,"B"]})]}),n(W.Button.Sub.R,{color:"cloud",fontColor:"4.thin",ssSphere:3,onClick:()=>{let g=[...l.dataValue];g[t]&&(g.splice(t,1),p(D=>b(v({},D),{dataValue:g,eventType:"update",eventID:S.uuid.gen()})))},children:n(L.Times,{})})]})}},ce=e=>{let Z=e,{tone:t,required:a,form:s,fileNameEdit:l=!0,systemOnly:p=!1,accept:m="*",limit:u=1,checkValidationAtFirst:B,onChange:i,onValidate:A,onUpdateValue:N,onUpdateValidValue:T,value:V=[],className:K,cellStyles:O,cellClassName:o,componentID:g,status_id:_,enableFormSubmit:D,freeCSS:k,wrapStyles:G}=Z,z=Q(Z,["tone","required","form","fileNameEdit","systemOnly","accept","limit","checkValidationAtFirst","onChange","onValidate","onUpdateValue","onUpdateValidValue","value","className","cellStyles","cellClassName","componentID","status_id","enableFormSubmit","freeCSS","wrapStyles"]),J={componentID:e.componentID||"",dataValue:V,eventType:"init",eventID:S.uuid.gen()},[d,y]=j(J),[R,ae]=j({ok:!1,notice:[]});re({type:"file",states:e,val_status:d,set_status:y,val_validate:R,set_validate:ae,DefaultValidation:de,onUpdateValue:N,onUpdateValidValue:T,ExtraOverrideStates:{dataValue:V,formatValue:V},ExtraStoreStates:{AddFiles:w=>$(void 0,null,function*(){let E=X.get(d.componentID).Files,I=[];for(var C=0;C<(w==null?void 0:w.length);C++){let f=w[C],{type:h,name:x}=f;if(C+1+E.length>u){H.add({componentID:x,secondsToClose:12e3,children:`\u30D5\u30A1\u30A4\u30EB\u9078\u629E\u4E0A\u9650\u3092\u8D85\u3048\u305F\u305F\u3081\u3001${x}}\u306F\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3002`,backgroundColor:"nega"});continue}if(m&&m=="image"&&!h.match(/image/)){H.add({componentID:x,secondsToClose:12e3,children:`\u30D5\u30A1\u30A4\u30EB\u5F62\u5F0F\u304C\u7570\u306A\u308B\u305F\u3081\u3001${x} \u306F\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3002`,backgroundColor:"nega"});continue}I.push(f)}y(f=>b(v({},f),{dataValue:[...E,...I],eventType:"update",eventID:S.uuid.gen()}))})}});let U="";return m&&(m=="image"?U="image/png,image/jpeg":U=m),r(se,{val_status:d,set_status:y,val_validate:R,states:e,children:[n("input",b(v({type:"file",className:c("Input"),"data-form":s,"data-input-type":"file","data-component-id":d.componentID,"data-validation":R.ok,accept:U,multiple:u!=1,onChange:w=>$(void 0,null,function*(){let E=w.target,I=E.files,C=[];for(var f=0;f<(I==null?void 0:I.length);f++){let h=I[f],x=h.name;if(h.id=S.uuid.gen(),f+1+d.dataValue.length>u){H.add({componentID:x,secondsToClose:12e3,children:`\u30D5\u30A1\u30A4\u30EB\u767B\u9332\u6570\u3092\u8D85\u3048\u305F\u305F\u3081\u3001${x}}\u306F\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002`,backgroundColor:"nega"});continue}C.push(h)}y(h=>b(v({},h),{dataValue:[...h.dataValue,...C],eventType:"update",eventID:S.uuid.gen()})),E.value=""})},z),{tabIndex:-1,value:""})),!p&&n(ee.List,{files:d.dataValue,states:e,val_status:d,set_status:y})]})};typeof window!="undefined"&&window.document&&S(document).addEvent({eventType:"dragover",callback:e=>{e.preventDefault(),P("."+c("AddButton")).addClass(c("Draggable"))},options:{passive:!1}}).addEvent({eventType:"drop",callback:e=>{e.preventDefault(),P("."+c("AddButton")).removeClass(c("Draggable"));let t=e.dataTransfer.files;if(t.length){let a=e.target;if(P(a).hasClass(c("AddButton"))){let{componentId:s}=a.dataset,l=X.get(s);l&&l.AddFiles&&l.AddFiles(t)}}},options:{passive:!1}});const q=e=>{e=v({},e),e.override="force";let t=ne(e);return t.cellClassName=[t.cellClassName,pe.Boxish(b(v({},t.cellStyles),{tone:t.tone})).className].join(" "),n(oe,{componentID:e.componentID,children:ce,states:t})};q.fn={openDialog:e=>{let{multiple:t,accept:a}=e;return new Promise(s=>{const l=document.createElement("input");l.type="file",l.multiple=t!=null?t:!0,a&&(a=="image"?l.accept="image/png,image/jpeg":l.accept=a),l.onchange=p=>{s(p.target.files)},l.click()})}};export{q as Filer,q as default};
|
package/dist/fn/Input/List.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as t,c as
|
|
1
|
+
import{b as t,c as d,d as w}from"../../chunk-C5N2D3ZX.js";import{jsx as n,jsxs as le}from"react/jsx-runtime";import{useState as Z}from"react";import I from"@mingoo/jsmin";import{$$fromRoot as ie}from"../../@utils";import D from"../../atoms/Box";import se from"../../atoms/Flex";import oe from"../../atoms/FAI";import re from"../Button";import{BoxWrapper as ce,SubmitForm as ue,CommonEffects as de,DefaultStyles as pe,Wrapper as fe}from"./core";import me from"./Hidden";import{InputListClasses as o}from"../../@styles/componentClasses";function ye(e){let{value:l,states:r}=e,{type:S,required:p,minSelect:a=0}=r,i=[];return p&&(l.length||S=="radio"&&i.push({type:"invalid",label:"\u9078\u629E\u3055\u308C\u3066\u3044\u307E\u305B\u3093"})),a&&l.length<a&&i.push({type:"invalid",label:`${a}\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044`}),{ok:!i.filter(({type:c})=>c=="invalid").length,notice:i}}const Se=e=>{let{value:l,options:r=[]}=e,S=I.is.exist(l)?I.flatArray(l):[],p=r.map(i=>{let{value:c,label:C}=i;return d(t({},i),{value:JSON.stringify(c),label:C})}),a=[];return S.forEach(i=>{let c=JSON.stringify(i);p.findIndex(N=>N.value==c)!=-1&&a.push(c)}),n(P.Core,d(t({},e),{value:a,options:p}))},P={Core:e=>{let k=e,{type:l,tone:r,required:S,componentID:p="",form:a,override:i,icon:c,iconType:C,enableFormSubmit:N,defaultActiveStyling:W,checkValidationAtFirst:j,onValidate:z,onUpdateValue:R,onUpdateValidValue:_,value:F,options:U,leftIndicator:b,rightIndicator:q,className:H,cellStyles:A,cellClassName:K,cellCheckedStyles:G,cellCheckedClassName:M,minSelect:Q,hideInput:E,freeCSS:g,wrapStyles:T}=k,x=w(k,["type","tone","required","componentID","form","override","icon","iconType","enableFormSubmit","defaultActiveStyling","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","className","cellStyles","cellClassName","cellCheckedStyles","cellCheckedClassName","minSelect","hideInput","freeCSS","wrapStyles"]),O={componentID:p,dataValue:F,eventType:"init",eventID:I.uuid.gen()},[u,v]=Z(O),[L,B]=Z({ok:!1,notice:[]});return de({type:"list",states:e,val_status:u,set_status:v,val_validate:L,set_validate:B,onUpdateValue:R,onUpdateValidValue:_,DefaultValidation:ye}),le(ce,{val_status:u,set_status:v,val_validate:L,states:e,children:[n(me,d(t({"data-value":JSON.stringify(u.dataValue),form:a,"data-input-type":l,"data-validation":L.ok},x),{componentID:u.componentID})),n(P.List,{states:e,val_status:u,set_status:v})]})},List:e=>{let{states:l,val_status:r,set_status:S}=e,{componentID:p,type:a,tone:i,icon:c=!0,options:C,name:N,form:W,tabIndex:j,hideInput:z,disabled:R,className:_,cellStyles:F,cellClassName:U="",cellCheckedStyles:b,cellCheckedClassName:q="",enableFormSubmit:H,defaultActiveStyling:A=!0}=l,{dataValue:K}=r,G=c?n(D,{flexSizing:"none",children:l.iconType=="radio"?n(P.RadioIcon,{}):l.iconType=="checkbox"?n(P.CheckboxIcon,{}):null}):null,M=C.map((Q,E)=>{let Y=Q,{value:g,label:T,disabled:x=R,className:O="",checkedStyles:u,checkedClassName:v="",freeCSS:L}=Y,B=w(Y,["value","label","disabled","className","checkedStyles","checkedClassName","freeCSS"]),k=I.uuid.gen(),X=K.findIndex(f=>f===g)!=-1,h=t(t({},F),B),$=[o("Label"),o("defaultActiveStyling_"+!!A),U,O];return X&&(h=d(t(t(t({},h),b),u),{freeCSS:t(t(t({},h==null?void 0:h.freeCSS),b==null?void 0:b.freeCSS),u==null?void 0:u.freeCSS)}),$=[...$,q,v]),[n("input",{type:a=="radio"?"radio":"checkbox",className:[o("Input"),o("defaultActiveStyling_"+!!A)].join(" "),name:"RadioCheckbox-"+N,"data-list-index":p+"-"+E,id:k,value:String(g),"data-form-name":W,disabled:x,checked:X,onFocus:f=>{if(x||a!="radio"||r.dataValue.length)return;let{value:m,checked:V}=f.target,y=[m];S(s=>d(t({},s),{dataValue:y,eventType:"update",eventID:I.uuid.gen()}))},onChange:f=>{if(x)return;let{value:m,checked:V}=f.target,y=[];if(a=="radio")y=[m];else if(a=="checkbox"||a=="checker")if(V)y=[...r.dataValue,m];else{let s=[...r.dataValue];s.splice(r.dataValue.findIndex(ne=>ne==m),1),y=s}S(s=>d(t({},s),{dataValue:y,eventType:"update",eventID:I.uuid.gen()}))},onKeyDown:f=>{let{key:m,shiftKey:V}=f;if((a=="checkbox"||a=="checker")&&m!="Tab"){if(m.match(/Arrow/)){f.preventDefault();let y=["ArrowLeft","ArrowUp"].includes(m)?-1:1,s=E+y;s<0?s=C.length-1:s>=C.length&&(s=0),ie(`input[data-list-index="${p}-${s}"]`).focus()}}H&&ue(f)},tabIndex:j},"List-"+JSON.stringify(g)),le(re.Label.Plain,d(t({htmlFor:k,className:$.join(" "),tabIndex:-1,display:"flex",ssEffectsOnActive:!1,verticalAlign:"center",gap:"1/3",flexWrap:!1},h),{children:[G,I.is.string(T)?n(D,{children:T}):T]}),"ListTrigger-"+JSON.stringify(g))]});return n(se,{flexSizing:"auto",style:l.style,freeCSS:t({},l.freeCSS),className:[_,o("CellBase"),o("HideInput_"+z),o("IconIndicator_"+!!c),o("Tone_"+i)].join(" "),children:M})},RadioIcon:()=>n(D,{className:o("Icon"),backgroundColor:"layer.1",border:!0,transition:"middle",position:"relative",borderRadius:"sphere",flexCenter:!0}),CheckboxIcon:()=>n(D,{className:[o("Icon"),o("CheckboxIcon")].join(" "),borderRadius:"3.tone.tertiary",backgroundColor:"layer.1",border:!0,transition:"middle",fontColor:"white",position:"relative",flexCenter:!0,children:n(oe.Check,{className:o("I"),transition:"middle",opacity:"trans",freeCSS:{zIndex:8}})})},J=e=>{e=t({},e);let l=pe.ListCell(e);return n(fe,{componentID:e.componentID,children:Se,states:l})},ee=e=>n(J,d(t({iconType:"radio",tone:e.tone},e),{type:"radio"})),te=e=>n(J,d(t({iconType:"checkbox",tone:e.tone},e),{type:"checkbox"})),ae={Plain:J,Radio:ee,Checkbox:te};export{te as Checkbox,ae as List,ee as Radio,ae as default};
|
package/dist/fn/Input/Parts.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as t,c as
|
|
1
|
+
import{b as t,c as n,d as p}from"../../chunk-C5N2D3ZX.js";import{jsx as i}from"react/jsx-runtime";import c from"../../atoms/Box";import s from"../../atoms/Span";import{DefaultStyles as a}from"./core";const u={RequiredSign:e=>i(s,t({children:"\u5FC5\u9808",fontColor:"white",fontSize:"0.xs",padding:["1/4","1/3"],backgroundColor:"nega",borderRadius:"3.tone.tertiary"},e)),RequiredShortSign:e=>i(s,t({children:"*",fontColor:"nega",padding:["1/4","1/3"],borderRadius:"3.tone.tertiary"},e)),OmitSign:e=>i(s,t({children:"\u7701\u7565\u53EF",fontColor:"white",fontSize:"0.xs",padding:["1/4","1/3"],borderRadius:"3.tone.tertiary",backgroundColor:"layer.6"},e)),LeftIndicator:e=>{let r=e,{tone:d}=r,o=p(r,["tone"]);return i(c,t(n(t({},a.Indicator(d)),{borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3"}),o))},RightIndicator:e=>{let r=e,{tone:d}=r,o=p(r,["tone"]);return i(c,t(n(t({},a.Indicator(d)),{borderTopLeftRadius:"2/3",borderBottomLeftRadius:"2/3"}),o))},RightIcon:e=>{let r=e,{tone:d="border"}=r,o=p(r,["tone"]);return i(c,n(t(n(t({},a.IndicatorIcon),{right:"3/4"}),o),{freeCSS:t(t({zIndex:6,pointerEvents:"none"},a.IndicatorIcon.freeCSS),o.freeCSS)}))},LeftIcon:e=>{let r=e,{tone:d="border"}=r,o=p(r,["tone"]);return i(c,n(t(n(t({},a.IndicatorIcon),{left:"3/4"}),o),{freeCSS:t(t({zIndex:6,pointerEvents:"none"},a.IndicatorIcon.freeCSS),o.freeCSS)}))}};export{u as Parts,u as default};
|
package/dist/fn/Input/Plain.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as t}from"../../chunk-C5N2D3ZX.js";import{jsx as n}from"react/jsx-runtime";import{
|
|
1
|
+
import{b as t}from"../../chunk-C5N2D3ZX.js";import{jsx as n}from"react/jsx-runtime";import{GenerateHTMLProps as a}from"../../@utils";const e=p=>n("input",t({},a(p)));export{e as _Plain,e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as t,c as
|
|
1
|
+
import{b as t,c as n,d as N}from"../../chunk-C5N2D3ZX.js";import{jsx as a}from"react/jsx-runtime";import{useState as R}from"react";import c from"@mingoo/jsmin";import K from"../../atoms/Box";import q from"../../atoms/FAI";import M from"../../mols/Column";import $ from"../Button";import _ from"../Tooltips";import{Wrapper as j,BoxWrapper as z,CommonEffects as G,DefaultStyles as Q}from"./core";import X from"./Parts";import{InputRichSelectClasses as Y,InputClasses as Z}from"../../@styles/componentClasses";function ee(e){let{value:l,states:I}=e,{required:u,options:o}=I,i=[];return u&&(!o.length||o.length&&c.is.nullish(JSON.parse(l)))&&i.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!i.filter(({type:p})=>p=="invalid").length,notice:i}}const te=e=>{let E=e,{tone:l,required:I,form:u,className:o,enableFormSubmit:i,enableUnSelected:p,checkValidationAtFirst:b,onChange:g,onKeyDown:C,onValidate:V,onUpdateValue:d,onUpdateValidValue:S,value:y="",options:D,placeholder:F,leftIndicator:ae,rightIndicator:ne,leftIcon:oe,rightIcon:ie,componentID:re,status_id:ue,wrapStyles:se,cellStyles:k,sheetStyles:m,rightIconStyles:ce,gravityPoint:A}=E,w=N(E,["tone","required","form","className","enableFormSubmit","enableUnSelected","checkValidationAtFirst","onChange","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","options","placeholder","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","wrapStyles","cellStyles","sheetStyles","rightIconStyles","gravityPoint"]),L={componentID:e.componentID||"",dataValue:y,eventType:"init",eventID:c.uuid.gen()},[T]=R(c.uuid.gen()),[r,h]=R(L),[v,H]=R({ok:!1,notice:[]});G({type:"richSelect",states:e,val_status:r,set_status:h,ExtraOverrideStates:{dataValue:y,formatValue:y},val_validate:v,set_validate:H,DefaultValidation:ee,onUpdateValue:d,onUpdateValidValue:S});let x=a(K,{fontColor:"4.thin",textAlign:"left",children:F||"\u9078\u629E"});if(r.dataValue){let s=D.find(f=>f.type=="button"&&f.value==r.dataValue);s&&(x=s.selectedLabel||s.label)}return a(z,{val_status:r,set_status:h,val_validate:v,states:e,children:a("button",n(t({},w),{"data-form":u,"data-validation":v.ok,"data-component-id":r.componentID,"data-value":r.dataValue,"data-input-type":"richSelect",className:[o,Y("SelectLegend"),Z("InputCover")].join(" "),onClick:s=>{_.open({tipsID:T,parent:s.currentTarget,gravityPoint:A||13,close_option:{parentBlur:!1},content:()=>{let f=D.map(J=>{let{type:U,value:P,label:B}=J;return U=="button"?a($.Button.Clear.R,n(t({color:"cloud",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:0},k),{onClick:()=>{h(W=>n(t({},W),{dataValue:P,eventType:"update",eventID:c.uuid.gen()})),_.close(T)},children:B}),String(P)):B});return a(M,n(t({ssCardBox:!0,padding:[1,0],gap:0,overflow:"auto"},m),{freeCSS:t({minWidth:12*20,maxHeight:"90vh"},m==null?void 0:m.freeCSS),children:f}))}})},children:x}))})},le=e=>{let{value:l=null,placeholder:I,options:u=[]}=e,o=0,i=JSON.stringify(l),p=u.map(g=>{let{type:C,value:V}=g,d=JSON.stringify(V),S=d==i;return o|=Number(S),n(t({},g),{type:C||"button",value:d})});o||(l=null);let b=JSON.stringify(l);return a(te,n(t({},e),{value:b,options:p}))},O=e=>{e=t({},e),c.is.nullish(e.rightIcon)&&(e.rightIcon=a(X.RightIcon,n(t({flexType:"col"},e.rightIconStyles),{children:a(q.AngleDown,{})}))),e.rightIcon&&(e=t({paddingRight:3},e)),e.leftIcon&&(e=t({paddingLeft:3},e));let l=Q.Boxish(e);return delete l.rightIconStyles,a(j,{componentID:e.componentID,children:le,states:l})};export{O as RichSelect,O as default};
|
package/dist/fn/Input/Search.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as e}from"../../chunk-C5N2D3ZX.js";import{jsx as t,jsxs as p}from"react/jsx-runtime";import r from"../../atoms/Box";import n from"../../atoms/FAI";import i from"../../mols/Row";import f from"../../mols/Column";import{faAngleUp as l}from"@fortawesome/free-solid-svg-icons/faAngleUp";import{faAngleDown as u}from"@fortawesome/free-solid-svg-icons/faAngleDown";import c from"./Chips";import d from"./Parts";const m=a=>t(c,e({AddButtonComponent:o=>o.selected.length?null:t(r,{children:"\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),SelectedCellComponent:o=>t(r,{width:1,textAlign:"left",children:p(i.Separate,{children:[o.label,o.defaultRemoveButton]})}),rightIcon:t(d.LeftIcon,{children:p(f,{gap:0,children:[t(n,{icon:l}),t(n,{icon:u,freeCSS:{marginTop:-6}})]})}),limit:1,paddingLeft:3},a));export{m as Search,m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as o,c as l,d as S}from"../../chunk-C5N2D3ZX.js";import{jsx as t}from"react/jsx-runtime";import R from"@mingoo/jsmin";import{useState as d}from"react";import x from"./List";import{InputSegmentedClasses as s}from"../../@styles/componentClasses";const r=e=>{let h=e,{tone:E,appearance:c,value:n,options:y,onUpdateValue:f,onUpdateValidValue:u,enableFormSubmit:V,checkValidationAtFirst:J,defaultActiveStyling:T,rightIndicator:X,cellStyles:b,cellClassName:p,cellCheckedClassName:g,cellCheckedStyles:k,freeCSS:B,wrapStyles:A}=h,I=S(h,["tone","appearance","value","options","onUpdateValue","onUpdateValidValue","enableFormSubmit","checkValidationAtFirst","defaultActiveStyling","rightIndicator","cellStyles","cellClassName","cellCheckedClassName","cellCheckedStyles","freeCSS","wrapStyles"]),[v]=d(R.uuid.gen()),[i,L]=d(n),[w,C]=d(i);return i!=n&&(L(n),C(n)),t(x.Radio,l(o({defaultActiveStyling:!1,options:y,value:w,componentID:v,icon:!1,flexWrap:!1,borderRadius:"2.tone.secondary",position:"relative"},I),{freeCSS:o({whiteSpace:"nowrap"},B),cellStyles:o({flexCenter:!0,ssPushable:!0,boxShadow:"none"},b),cellClassName:[p,s("Label"),s("Tone_"+c)].join(" "),cellCheckedStyles:o({isSemiBoldFont:!0},k),cellCheckedClassName:[g,s("Checked")].join(" "),tone:"custom",onUpdateValue:f,onUpdateValidValue:m=>{u&&u(m),c=="BottomLine"&&C(m.value[0])}}))},a={Auto:e=>(e=o({},e),e=l(o({padding:"1/3",gap:"1/3",ssCardBox:!0},e),{cellStyles:o({borderRadius:"inherit",position:"relative"},e.cellStyles),cellCheckedStyles:o({backgroundColor:"theme",fontColor:"white"},e.cellCheckedStyles)}),t(r,o({appearance:e.tone||"Auto"},e))),Normal:e=>(e=o({},e),e=l(o({border:!0,borderColor:"theme",overflow:"hidden",gap:0,ssLastChildLossBorder:"right",fontColor:"3.blur"},e),{cellStyles:o({borderRadius:0,borderRight:!0,borderColor:"theme"},e.cellStyles),cellCheckedStyles:o({backgroundColor:"theme",fontColor:"white"},e.cellCheckedStyles)}),e.tone="ThemeBorder",t(r,o({appearance:"Border"},e))),Cloud:e=>(e=o({},e),e=l(o({padding:"1/3",gap:"1/3",backgroundColor:"cloud"},e),{cellStyles:o({borderRadius:"inherit",position:"relative"},e.cellStyles),cellCheckedStyles:o({backgroundColor:"theme",fontColor:"white"},e.cellCheckedStyles)}),t(r,o({appearance:e.tone||"Cloud"},e))),Cloud2:e=>(e=o({},e),e.tone="WhiteCloud",t(a.Cloud,l(o({fontColor:"3.blur"},e),{cellCheckedStyles:o({fontColor:"1.clear"},e.cellCheckedStyles)}))),Cloud3:e=>(e=o({},e),e.tone="ThemeCloud",t(a.Cloud,l(o({backgroundColor:"theme.opa.few",fontColor:"theme"},e),{cellStyles:o({},e.cellStyles)}))),Border:e=>(e=o({},e),e=l(o({backgroundColor:"layer.1",border:"2.normal",overflow:"hidden",gap:0,ssLastChildLossBorder:"right",boxShadow:"0.min"},e),{cellStyles:o({borderRadius:0,borderRight:"2.normal"},e.cellStyles),cellCheckedStyles:o({backgroundColor:"theme.opa.few",fontColor:"theme"},e.cellCheckedStyles)}),t(r,o({appearance:e.tone||"Border"},e))),Border2:e=>(e=o({},e),e=l(o({border:!0,borderColor:"theme",overflow:"hidden",gap:0,ssLastChildLossBorder:"right",boxShadow:"0.min",fontColor:"3.blur"},e),{cellStyles:o({borderRadius:0,borderRight:!0,borderColor:"theme"},e.cellStyles),cellCheckedStyles:o({backgroundColor:"theme",fontColor:"white"},e.cellCheckedStyles)}),e.tone="ThemeBorder",t(r,o({appearance:"Border"},e))),BottomLine:e=>(e=o({},e),e=l(o({gap:0,fontColor:"3.blur"},e),{cellStyles:o({ssEffectsOnActive:"ripple.theme",borderRadius:0,padding:1},e.cellStyles),cellCheckedStyles:o({fontColor:"theme"},e.cellCheckedStyles)}),t(r,o({appearance:"BottomLine"},e)))};export{a as Segmented,a as default};
|
package/dist/fn/Input/Select.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as n,c as p,d as O}from"../../chunk-C5N2D3ZX.js";import{Fragment as G,jsx as t,jsxs as z}from"react/jsx-runtime";import{useState as T}from"react";import y from"@mingoo/jsmin";import E from"../../atoms/Box";import J from"../../atoms/FAI";import{Wrapper as L,BoxWrapper as U,SubmitForm as K,CommonEffects as W,DefaultStyles as q}from"./core";import M from"./Parts";import{InputClasses as $,InputSelectClasses as N}from"../../@styles/componentClasses";function H(e){let{value:l,states:d}=e,{required:r,options:a}=d,o=[];return r&&(!a.length||a.length&&y.is.nullish(JSON.parse(l)))&&o.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!o.filter(({type:c})=>c=="invalid").length,notice:o}}const _={Core:e=>{var R;let C=e,{tone:l,required:d,form:r,className:a,enableFormSubmit:o,enableUnSelected:c,checkValidationAtFirst:f,onChange:s,onKeyDown:m,onValidate:b,onUpdateValue:I,onUpdateValidValue:g,value:h="",options:B,placeholder:F,leftIndicator:Q,rightIndicator:X,leftIcon:Y,rightIcon:Z,componentID:ee,status_id:te,freeCSS:le,wrapStyles:ae,rightIconStyles:ne}=C,P=O(C,["tone","required","form","className","enableFormSubmit","enableUnSelected","checkValidationAtFirst","onChange","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","options","placeholder","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","freeCSS","wrapStyles","rightIconStyles"]),w={componentID:e.componentID||"",dataValue:h,eventType:"init",eventID:y.uuid.gen()},[u,v]=T(w),[S,D]=T({ok:!1,notice:[]});W({type:"select",states:e,val_status:u,set_status:v,ExtraOverrideStates:{dataValue:h,formatValue:h},val_validate:S,set_validate:D,DefaultValidation:H,onUpdateValue:I,onUpdateValidValue:g});let x=t(E,{fontColor:"4.thin",textAlign:"left",children:F||"\u9078\u629E"});if(u.dataValue){let i=B.find(V=>V.value==u.dataValue);i&&(x=(R=i.displayLabel)!=null?R:i.label)}return t(U,{val_status:u,set_status:v,val_validate:S,states:e,children:z(E,{className:[a,N("SelectLegend"),$("InputCover")].join(" "),children:[x,t("select",p(n({"data-form":r,"data-input-type":"select","data-validation":S.ok,"data-component-id":u.componentID,"data-value":u.dataValue,value:u.dataValue,onKeyDown:i=>{m&&m(i),o&&K(i)},onChange:i=>{let{value:V}=i.target;S.ok&&D({ok:!1,notice:[]}),v(A=>p(n({},A),{dataValue:V,eventType:"update",eventID:y.uuid.gen()})),s&&s(i)}},P),{className:N("Select"),children:t(_.Options,n({},e))}))]})})},Options:e=>{let{options:l=[],placeholder:d="\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044",enableUnSelected:r=!0}=e,a=l.map(o=>{let{value:c,label:f}=o,s=String(c);return t("option",{value:s,children:f},s)});return r&&a.unshift(t("option",{value:JSON.stringify(null),children:d},0)),t(G,{children:a})}},j=e=>{let{value:l=null,placeholder:d,options:r=[]}=e,a=0,o=JSON.stringify(l),c=r.map(s=>{let{value:m,label:b}=s,I=JSON.stringify(m),g=I==o;return a|=Number(g),p(n({},s),{value:I,label:b})});a||(l=null);let f=JSON.stringify(l);return t(_.Core,p(n({},e),{value:f,options:c}))},k=e=>{e=n({},e),y.is.nullish(e.rightIcon)&&(e.rightIcon=t(M.RightIcon,p(n({flexType:"col"},e.rightIconStyles),{children:t(J.AngleDown,{})}))),e.rightIcon&&(e=n({paddingRight:3},e)),e.leftIcon&&(e=n({paddingLeft:3},e));let l=q.Boxish(e);return delete e.rightIconStyles,t(L,{componentID:e.componentID,children:j,states:l})};export{k as Select,k as default};
|
package/dist/fn/Input/Slider.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as I,c as
|
|
1
|
+
import{b as I,c as T,d as A}from"../../chunk-C5N2D3ZX.js";import{jsx as d,jsxs as M}from"react/jsx-runtime";import{useState as F,useEffect as O}from"react";import c from"@mingoo/jsmin";import{$$fromRoot as L,useStore as E,GenerateHTMLProps as G}from"../../@utils";import x from"../../atoms/Box";import z from"../../atoms/Flex";import X from"../../mols/Column";import j from"../Button";import{Wrapper as J,BoxWrapper as Q,SubmitForm as Y,CommonEffects as Z}from"./core";import ee from"./Hidden";import{InputSliderClasses as v}from"../../@styles/componentClasses";function te(a){let{value:e,states:o}=a,{required:n}=o,s=[];return n&&!e&&s.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!s.filter(({type:i})=>i=="invalid").length,notice:s}}const N=a=>{let{value:e,val_status:o}=a,{min:n,max:s,step:i}=o;e=Math.max(e,n),e=Math.min(e,s);let t=e/s*s;return t=Math.round(t/i),{stepValue:t*i,stepIndex:t,positionLeft:t*i/s*100+"%"}},H={IndicatorLabels:a=>{let{componentID:e,min:o,max:n,step:s,customLegends:i}=a,r=[],t=Math.round(o/s),p=Math.round(n/s),f=p-t+1;for(var u=t;u<=p;u++){let l=u*s;l=Math.max(l,o),l=Math.min(l,n);let S=l/n*100+"%";r.push(d(x,{className:v("Label"),id:"Legend-"+e+"-"+u,display:u==t||u==p?"flex":"none",position:"absolute",top:0,unitHeight:1,unitWidth:1.5,transition:"middle",fontColor:"1.clear",verticalAlign:"center",horizontalAlign:"center",freeCSS:{left:S,whiteSpace:"nowrap",textAlign:"center"},children:i?i(l):l.rank()},l))}return O(()=>{const l=()=>{let S=L("#Labels-"+e),{width:h}=S.position(),C=Math.round(h/50)-1,y=Math.round(f/C);for(let m=t+1;m<p;m++)L("#Legend-"+e+"-"+m).css({display:m%y==0?"flex":"none"})};return c(window).addEvent({eventID:"SliderResizeCallback-"+e,eventType:"resize",callback:()=>{l()}}),l(),()=>{c(window).removeEvent("SliderResizeCallback-"+e)}},[]),d(z,{className:v("Labels"),verticalAlign:"center",horizontalAlign:"between",fontSize:"0.xs",position:"relative",unitHeight:1,id:"Labels-"+e,children:d(x,{position:"absolute",top:0,left:0,bottom:0,freeCSS:{right:12*1.5},children:r})})},Rail:a=>{let{val_status:e,set_status:o,DotData:n,form:s,enableFormSubmit:i}=a,{componentID:r}=e;return M(z,{className:v("Rail"),position:"relative",paddingLeft:"1/2",unitHeight:1.5,verticalAlign:"center",freeCSS:{minWidth:"10rem",zIndex:1,cursor:"pointer"},onMouseDown:t=>{t.stopPropagation(),g.Effects.Start(t,{val_status:e,set_status:o,DotData:n})},onTouchStart:t=>{t.stopPropagation(),g.Effects.Start(t,{val_status:e,set_status:o,DotData:n})},children:[d(x,{className:v("Bar"),backgroundColor:"layer.4",position:"relative",borderRadius:"sphere",transition:"middle",flexSizing:"none",unitHeight:"2/3",width:1,id:r+"_Bar",children:d(x,{className:v("BarColor"),position:"relative",height:1,width:0,left:0,transition:"long",borderRadius:"inherit",backgroundColor:a.color,opacity:"middle",overflow:"hidden",freeCSS:{width:n.positionLeft},id:r+"_BarColor"})}),d(x,{className:v("BallWrap"),position:"absolute",top:0,left:0,bottom:0,freeCSS:{right:12*1.5},children:d(j.Button.Plain,{className:v("Ball"),position:"absolute",backgroundColor:a.color,top:0,left:0,ssSphere:1.5,freeCSS:{zIndex:2,left:n.positionLeft},"data-form-name":s,id:r+"_Ball",onKeyDown:t=>{g.KeyDownEvent({event:t,val_status:e,set_status:o,DotData:n}),i&&Y(t)}})})]})}},g={Effects:{Start:(a,e)=>{c(document).addEvent({eventID:"SliderMouseMove",eventType:"mousemove",callback:o=>{g.Effects.Move(o,e)},options:{passive:!1}}).addEvent({eventID:"SliderTouchMove",eventType:"touchmove",callback:o=>{g.Effects.Move(o,e)},options:{passive:!1}}).addEvent({eventID:"SliderMouseUp",eventType:"mouseup",callback:()=>{g.Effects.End()}}).addEvent({eventID:"SliderTouchEnd",eventType:"touchend",callback:()=>{g.Effects.End()}})},Move:(a,e)=>{let o=c.getCursor(a).x,{val_status:n,set_status:s}=e,{componentID:i,min:r,max:t}=n,p=L("#"+i+"_Ball"),f=L("#"+i+"_Bar"),u=L("#"+i+"_BarColor"),{width:l,left:S}=f.position(),h=(o-S)/l;h=Math.max(h,0),h=Math.min(h,1);let C=h*t,y=N({value:C,val_status:n}),m=y.positionLeft,D=y.stepValue;p.css({left:m}),u.css({width:m});let{prevValue:V}=E.get(i);return D!=V&&(E.update({[i]:{prevValue:D}}),s(B=>T(I({},B),{dataValue:D,eventType:"update",eventID:c.uuid.gen()}))),a.preventDefault(),a.stopPropagation(),!1},End:()=>{c(document).removeEvent(["SliderMouseMove","SliderTouchMove","SliderMouseUp","SliderTouchEnd"])}},KeyDownEvent:a=>{let{event:e,val_status:o,set_status:n}=a,{min:s,max:i,step:r}=o,{key:t,metaKey:p,ctrlKey:f}=e,u=f||p,l=o.dataValue;t.match(/Arrow/)&&(e.preventDefault(),t.match(/Left|Up/)?u?l=s:l-=r:t.match(/Right|Down/)&&(u?l=i:l+=r),l=Math.max(Math.min(l,i),s),E.update({[o.componentID]:{prevValue:l}}),n(S=>T(I({},S),{dataValue:l,eventType:"update",eventID:c.uuid.gen()})))}},ae=a=>{let k=a,{color:e="theme",required:o,form:n="",legends:{enable:s=!0,custom:i,showAlways:r=!1}={},min:t,max:p,step:f,enableFormSubmit:u,checkValidationAtFirst:l,onChange:S,onKeyDown:h,onValidate:C,onUpdateValue:y,onUpdateValidValue:m,value:D="",className:V,freeCSS:B,wrapStyles:le}=k,W=A(k,["color","required","form","legends","min","max","step","enableFormSubmit","checkValidationAtFirst","onChange","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","className","freeCSS","wrapStyles"]),P={componentID:a.componentID||"",dataValue:D,min:t,max:p,step:f,eventType:"init",eventID:c.uuid.gen()},[b,w]=F(P),[_,U]=F({ok:!1,notice:[]});Z({states:a,val_status:b,set_status:w,val_validate:_,set_validate:U,onUpdateValue:y,onUpdateValidValue:m,DefaultValidation:te,ExtraOverrideStates:{dataValue:D},ExtraStoreStates:{prevValue:b.dataValue,setValueByForeign:$=>{w(q=>T(I({},q),{dataValue:$,eventType:"update",eventID:c.uuid.gen()}))}}});let R=N({value:b.dataValue,val_status:b});return M(Q,{val_status:b,set_status:w,val_validate:_,states:a,children:[d(ee,I({value:R.stepValue,form:n,"data-value":R.stepValue,"data-validation":_.ok,"data-input-type":"slider"},W)),M(X,{gap:"1/2",flexSizing:"auto",className:[v("Wrap"),V,v("ShowLegendsAlways_"+r)].join(" "),children:[d(H.Rail,{color:e,val_status:b,set_status:w,DotData:R,form:n,enableFormSubmit:u}),!!s&&d(H.IndicatorLabels,{componentID:b.componentID,min:t,max:p,step:f,customLegends:i})]})]})},K=a=>(a=I({},a),d(J,{componentID:a.componentID,children:ae,states:G(a)}));export{K as Slider,K as default};
|
package/dist/fn/Input/Switch.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as l,c as
|
|
1
|
+
import{b as l,c as f,d as V}from"../../chunk-C5N2D3ZX.js";import{jsx as t,jsxs as D}from"react/jsx-runtime";import{useState as g}from"react";import k from"@mingoo/jsmin";import d from"../../atoms/Box";import N from"../../mols/Row";import L from"../Button";import{Wrapper as q,BoxWrapper as H,SubmitForm as O,CommonEffects as P}from"./core";import{InputSwitchClasses as m}from"../../@styles/componentClasses";function U(e){let{value:I,states:a}=e,{required:y}=a,i=[];return y&&!I&&i.push({type:"invalid",label:"ON\u306B\u306A\u3063\u3066\u3044\u307E\u305B\u3093"}),{ok:!i.filter(({type:r})=>r=="invalid").length,notice:i}}const W=e=>{let S=e,{componentID:I,color:a="posi",required:y,form:i,id:r,enableFormSubmit:R,checkValidationAtFirst:A,onChange:b,onKeyDown:v,onValidate:K,onUpdateValue:T,onUpdateValidValue:B,value:c="",icon:C="",appearance:s="material"}=S,_=V(S,["componentID","color","required","form","id","enableFormSubmit","checkValidationAtFirst","onChange","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","icon","appearance"]),E={componentID:e.componentID||"",dataValue:c,eventType:"init",eventID:k.uuid.gen()},[o,h]=g(E),[p,w]=g({ok:!1,notice:[]}),u=!!o.dataValue;return P({states:e,val_status:o,set_status:h,val_validate:p,set_validate:w,DefaultValidation:U,onUpdateValue:T,onUpdateValidValue:B,ExtraOverrideStates:{dataValue:c,formatValue:c}}),D(H,{val_status:o,set_status:h,val_validate:p,states:e,children:[t("input",l({type:"checkbox","data-form":i,"data-input-type":"switch","data-validation":p.ok,"data-component-id":o.componentID,"data-value":o.dataValue,checked:o.dataValue,className:m("Input"),id:r,onKeyDown:n=>{v&&v(n),R&&O(n)},onChange:n=>{p.ok&&w({ok:!1,notice:[]}),h(F=>f(l({},F),{dataValue:n.target.checked,eventType:"update",eventID:k.uuid.gen()})),b&&b(n)}},_)),t(L.Label.Plain,{tabIndex:-1,htmlFor:r,padding:"1/3",transition:"middle",borderRadius:"1.tone.primary",className:m("Label"),children:t(d,f(l({},s=="applely"?{padding:"1/4",isRounded:!0,backgroundColor:u?a:"layer.5"}:{}),{children:D(N.Center,{unitHeight:2.5,position:"relative",freeCSS:{width:12*4.5},children:[s=="material"&&t(d,{position:"absolute",backgroundColor:u?a:"layer.5",borderRadius:"sphere",unitHeight:1,transition:"middle",width:1,opacity:"middle",className:m("Bar")}),t(d,{position:"absolute",top:0,left:0,backgroundColor:s=="material"&&u?a:"white",transition:"middle",ssSphere:2.5,boxShadow:"1.remark",className:m("Dot"),children:C&&t(d,{transition:"middle",ssSquare:2,flexCenter:!0,fontColor:s=="applely"&&u?a:"white",children:C})})]})}))})]})},x=e=>(e=l({},e),e.color=e.color||"theme",t(q,{componentID:e.componentID,children:W,states:e}));export{x as Switch,x as default};
|
package/dist/fn/Input/Text.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as o,c as I,d as P}from"../../chunk-C5N2D3ZX.js";import{Fragment as W,jsx as i,jsxs as q}from"react/jsx-runtime";import{useState as R,useEffect as F}from"react";import x from"@mingoo/jsmin";import{$$fromRoot as ae,useStore as re}from"../../@utils";import T from"../../atoms/Box";import U from"../../atoms/FAI";import Z from"../Button";import D from"../Tooltips";import{faEye as K}from"@fortawesome/free-solid-svg-icons/faEye";import{Wrapper as ne,BoxWrapper as ie,SubmitForm as oe,CommonEffects as le,DefaultStyles as se}from"./core";import B from"./Parts";const ue={number:{reg:/^-?[0-9\.]+$/g,exist:!0,reason:"\u534A\u89D2\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},katakana:{reg:/^[ァ-ヶー ヲ-゚ ]*$/g,exist:!0,reason:"\u30AB\u30BF\u30AB\u30CA\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},"hankaku.katakana":{reg:/^[ヲ-゚ ]*$/g,exist:!0,reason:"\u534A\u89D2\u30AB\u30BF\u30AB\u30CA\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},digitNumber:{reg:/^-?[0-9\.]+$/g,exist:!0,reason:"\u534A\u89D2\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},fileName:{reg:/[¥\/:*\?\"\'\|\.\s\n\r\<\>]/g,exist:!1,reason:"\u7A7A\u767D\u307E\u305F\u306F\u4E00\u90E8\u306E\u7279\u6B8A\u6587\u5B57\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093"},creditCard:{reg:/^\d{14,16}$/g,exist:!0,reason:"14~16\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},email:{reg:/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]+\.[A-Za-z0-9]+$/,exist:!0,reason:q(W,{children:[i(T,{children:"\u25CB\u25CB\u25CB\u25CB@\u25CB\u25CB\u25CB\u25CB.\u25CB\u25CB\u25CB\u306E\u5F62\u5F0F\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),i(T,{children:"\u6700\u5F8C\u306E\u6587\u5B57\u306B.(\u30C9\u30C3\u30C8)\u3092\u5165\u308C\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"})]})},password:{reg:/^(?=[^A-Z]*[A-Z])(?=[^a-z]*[a-z])(?=[^0-9]*[0-9]).{8,}$/,exist:!0,reason:"8\u6587\u5B57\u4EE5\u4E0A\u3001\u534A\u89D2\u82F1\u6570\u5927\u5C0F\u6587\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},tel:{reg:/.*$/g,exist:!0,reason:q(W,{children:[i(T,{children:"0\u304B\u3089\u59CB\u307E\u308B\u756A\u53F7\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"}),i(T,{children:"9~12\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),i(T,{children:"\u6570\u5B57\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"})]})},url:{reg:/^https?:\/\/[^\n\s]+(\.|\:)[^\n\s\.\:]+$/,exist:!0,reason:"URL\u5F62\u5F0F : http(s)://\u25EF\u25EF\u25EF\u25EF"},postal:{reg:/^\d{7}$/g,exist:!0,reason:"7\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}},V=t=>{let{restrict:r,value:u=""}=t,e=String(u),a=!1;if(["tel","number","digitNumber","test","postal","creditCard"].includes(r)&&(e=e.zen2hanNumber()),r=="katakana"&&(e=e.replace(/[^ァ-ヶー ヲ-゚ ]/ig,"")),r=="hankaku.katakana"&&(e=e.replace(/[^ヲ-゚ ]/ig,"")),["postal","creditCard"].includes(r)&&(e=e.removeLetters()),["number","number.zeroStart","digitNumber"].includes(r)){let s=e[0]=="0";if(e){if(e!="-")if(e=="0-")e="-";else{e[0]=="-"&&(a=!0),e=e.replace(/[^0-9\.]/ig,"");let n=Number(e);n===0&&(a=!1),a&&(n=-1*n),x.is.exist(t.min)&&(n=Math.max(n,Number(t.min))),x.is.exist(t.max)&&(n=Math.min(n,Number(t.max))),e=String(Math.abs(n))}s&&e!="0"&&r=="number.zeroStart"&&(e="0"+e)}}let l=e;if(r=="digitNumber"){if(e&&e!="-"){let s=[];for(let n=e.length-1;n>=0;n--){s.unshift(e[n]);let g=e.length-1-n+1;n!=0&&g%3==0&&s.unshift(",")}l=s.join("")}}else r=="postal"?e.length>=4&&(l=e.clip(0,3)+"-"+e.clip(3)):r=="creditCard"&&(l=e.replace(/.{4}(?=.)/g,"$& "));return["number","digitNumber"].includes(r)&&a&&(e="-"+e,l="-"+l),{formatValue:l,dataValue:e}},me=t=>{let{id:r,restrict:u,val_status:e}=t,a=ae("#"+r)[0];if(a&&e.prevValue&&e.formatValue){let{formatValue:l,prevValue:s,caretFrom:n,caretTo:g}=e;if(u=="creditCard")l.length>=s.length&&n%5==0&&(n++,g++),a.setSelectionRange(n,g);else if(u=="postal")l.length==5&&s.length==3&&(n++,g++),a.setSelectionRange(n,g);else if(u=="digitNumber"){let w=l.length-s.length;w==2&&(n++,g++),w==-2&&(n--,g--),a.setSelectionRange(n,g)}}},H=(t,r)=>{let u={ok:!0,body:""};return(()=>{let e=ue[r];if(!e)return;let a=e.reason;if(e){let l=!!(+!!t.match(e.reg)^+!e.exist);u={ok:l,body:l?"":a}}})(),u};function pe(t){let{value:r,states:u}=t,{restrict:e="text",maxLength:a=255,required:l}=u,s=[];if(x.is.exist(a)&&r.length>=Number(a)&&s.push({type:"invalid",label:a+"\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),r){let n=H(r,e);n.ok||s.push({type:"invalid",label:n.body})}else l&&s.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"});return{ok:!s.filter(({type:n})=>n=="invalid").length,notice:s}}const de=t=>{let O=t,{componentID:r,tone:u,required:e,restrict:a="text",form:l,autoComplete:s="off",autoCapitalize:n="off",enableFormSubmit:g,clearButton:w=!1,checkValidationAtFirst:ce,onChange:M,onKeyDown:$,onValidate:fe,onUpdateValue:Y,onUpdateValidValue:j,value:z="",leftIndicator:ge,rightIndicator:xe,leftIcon:be,rightIcon:ye,maxLength:he,min:k,max:v,styles:Ie,freeCSS:Ne,wrapStyles:ke}=O,p=P(O,["componentID","tone","required","restrict","form","autoComplete","autoCapitalize","enableFormSubmit","clearButton","checkValidationAtFirst","onChange","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","maxLength","min","max","styles","freeCSS","wrapStyles"]),G=a=="password"||a=="concealed"?"password":"text",Q=["number","digitNumber","creditCard"].includes(a)?"numeric":a=="email"?"email":"text",ee=I(o({componentID:r},V({min:k,max:v,restrict:a,value:z})),{prevValue:"",eventType:"init",eventID:x.uuid.gen(),caretFrom:null,caretTo:null}),[te,X]=R(!1),[d,N]=R(ee),[C,_]=R({ok:!1,notice:[]});return le({states:t,val_status:d,set_status:N,val_validate:C,set_validate:_,DefaultValidation:pe,onUpdateValue:Y,onUpdateValidValue:j,ExtraOverrideStates:o({},V({min:k,max:v,restrict:a,value:z}))}),F(()=>{me({id:t.id,restrict:a,val_status:d})},[d]),i(ie,{val_status:d,set_status:N,val_validate:C,states:t,children:i("input",I(o({type:G,inputMode:Q,"data-form":l,"data-input-type":"text","data-validation":C.ok,"data-value":d.dataValue,"data-component-id":d.componentID,value:d.formatValue,autoComplete:s,autoCapitalize:n,onKeyDown:c=>{let{key:f,target:y}=c;{let b=y,{selectionStart:h,selectionEnd:S}=b,E=Number(h),L=Number(S),A=d.formatValue[Number(E)],J=d.formatValue[Number(E)-1];f=="Delete"&&(a=="creditCard"&&A==" "||a=="postal"&&A=="-"||a=="digitNumber"&&A==",")&&(b.setSelectionRange(E+1,L+1),c.preventDefault()),f=="Backspace"&&(a=="creditCard"&&J==" "||a=="postal"&&J=="-"||a=="digitNumber"&&J==",")&&(b.setSelectionRange(E-1,L-1),c.preventDefault()),f=="Enter"||f=="Tab"}if(["number","digitNumber","creditCard"].includes(a)&&f=="Clear"&&N(b=>I(o({},b),{dataValue:"",formatValue:"",eventType:"update",eventID:x.uuid.gen()})),["number","digitNumber"].includes(a)&&["ArrowUp","ArrowDown"].includes(f)){let b=+(f=="ArrowUp")*2-1,h=String(Number(d.dataValue)+b);C.ok&&_({ok:!1,notice:[]}),N(S=>I(o(o({},S),V({min:k,max:v,restrict:a,value:h})),{eventType:"update",eventID:x.uuid.gen()})),c.preventDefault()}$&&$(c),g&&oe(c)},onChange:c=>{let{value:f,selectionStart:y,selectionEnd:b}=c.target,h=V({min:k,max:v,restrict:a,value:f});te&&(h.formatValue=f),h.formatValue!=d.formatValue&&(C.ok&&_({ok:!1,notice:[]}),N(S=>I(o(o({},S),h),{prevValue:d.formatValue,eventType:"update",eventID:x.uuid.gen(),caretFrom:Number(y),caretTo:Number(b)})),M&&M(c))}},p),{onCompositionStart:c=>{p!=null&&p.onCompositionStart&&(p==null||p.onCompositionStart(c)),X(!0)},onCompositionEnd:c=>{if(p!=null&&p.onCompositionEnd&&(p==null||p.onCompositionEnd(c)),a=="text")return;let f=V({min:k,max:v,restrict:a,value:d.formatValue});N(y=>I(o(o({},y),f),{prevValue:y.formatValue,eventType:"update",eventID:x.uuid.gen(),caretFrom:Number(y.formatValue.length+1),caretTo:Number(y.formatValue.length+1)})),X(!1)}}))})},m={Validate:H,Normal:t=>(t=o({},t),t.rightIcon&&(t.styles=o({paddingRight:3},t.styles)),t.leftIcon&&(t.styles=o({paddingLeft:3},t.styles)),i(ne,{componentID:t.componentID,children:de,states:se.Boxish(t)})),Katakana:t=>i(m.Normal,o({restrict:"katakana"},t)),HankakuKatakana:t=>i(m.Normal,o({restrict:"hankaku.katakana"},t)),CreditCard:t=>i(m.Normal,o({restrict:"creditCard"},t)),Tel:t=>i(m.Normal,o({restrict:"tel",placeholder:"xxx-xxxx-xxxx"},t)),Number:t=>i(m.Normal,o({restrict:"number"},t)),DigitNumber:t=>i(m.Normal,o({restrict:"digitNumber"},t)),Email:t=>i(m.Normal,o({restrict:"email"},t)),Url:t=>i(m.Normal,o({restrict:"url"},t)),Postal:t=>{let[r]=R(x.uuid.gen());return F(()=>()=>{re.delete(r)},[]),i(m.Normal,o({restrict:"postal",placeholder:"\u90F5\u4FBF\u756A\u53F7",leftIndicator:i(B.LeftIndicator,{children:"\u3012"})},t))},Password:t=>i(m.Normal,o({restrict:"password",placeholder:"\u30D1\u30B9\u30EF\u30FC\u30C9\u3092\u5165\u529B",rightIndicator:i(B.RightIndicator,{styles:{padding:0},children:i(Z.Button.Normal.R,{styles:{padding:[0,1],fontColor:"theme",borderRadius:"inherit",backgroundColor:"inherit",flexCenter:!0,height:1,ssEffectsOnActive:["expand"]},onMouseOver:r=>{D.open({parent:r.currentTarget,gravityPoint:24,styles:{padding:[1,0]},content:i(D.Comps.Body,{children:"\u30D1\u30B9\u30EF\u30FC\u30C9\u3092\u8868\u793A"})})},tabIndex:-1,onClick:r=>{x(r.target).parent().parent().find("input").callback(u=>{let e=u[0];e.type=e.type==="password"?"text":"password"})},children:i(U,{icon:K})})})},t)),Concealed:t=>i(m.Normal,o({restrict:"concealed",placeholder:"\u79D8\u5BC6\u9375\u3092\u5165\u529B",rightIndicator:i(B.RightIndicator,{styles:{padding:0},children:i(Z.Button.Normal.R,{styles:{padding:[0,1],fontColor:"theme",borderRadius:"inherit",backgroundColor:"inherit",flexCenter:!0,height:1,ssEffectsOnActive:["expand"]},onMouseOver:r=>{D.open({parent:r.currentTarget,gravityPoint:24,styles:{padding:[1,0]},content:i(D.Comps.Body,{children:"\u5024\u3092\u8868\u793A"})})},tabIndex:-1,onClick:r=>{x(r.target).parent().parent().parent().find("input").callback(u=>{let e=u[0];e.type=e.type==="password"?"text":"password"})},children:i(U,{icon:K})})})},t)),Money:{JPY:t=>i(m.DigitNumber,o({placeholder:"\u91D1\u984D\u3092\u5165\u529B",rightIndicator:i(B.RightIndicator,{children:"\u5186"})},t))}};export{m as Text,de as TextInput,m as default};
|
|
1
|
+
import{b as o,c as y,d as P}from"../../chunk-C5N2D3ZX.js";import{Fragment as W,jsx as i,jsxs as q}from"react/jsx-runtime";import{useState as R,useEffect as F}from"react";import x from"@mingoo/jsmin";import{$$fromRoot as ae,useStore as re}from"../../@utils";import T from"../../atoms/Box";import U from"../../atoms/FAI";import Z from"../Button";import D from"../Tooltips";import{faEye as K}from"@fortawesome/free-solid-svg-icons/faEye";import{Wrapper as ne,BoxWrapper as ie,SubmitForm as oe,CommonEffects as le,DefaultStyles as ue}from"./core";import B from"./Parts";const se={number:{reg:/^-?[0-9\.]+$/g,exist:!0,reason:"\u534A\u89D2\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},katakana:{reg:/^[ァ-ヶー ヲ-゚ ]*$/g,exist:!0,reason:"\u30AB\u30BF\u30AB\u30CA\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},"hankaku.katakana":{reg:/^[ヲ-゚ ]*$/g,exist:!0,reason:"\u534A\u89D2\u30AB\u30BF\u30AB\u30CA\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},digitNumber:{reg:/^-?[0-9\.]+$/g,exist:!0,reason:"\u534A\u89D2\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},fileName:{reg:/[¥\/:*\?\"\'\|\.\s\n\r\<\>]/g,exist:!1,reason:"\u7A7A\u767D\u307E\u305F\u306F\u4E00\u90E8\u306E\u7279\u6B8A\u6587\u5B57\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093"},creditCard:{reg:/^\d{14,16}$/g,exist:!0,reason:"14~16\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},email:{reg:/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]+\.[A-Za-z0-9]+$/,exist:!0,reason:q(W,{children:[i(T,{children:"\u25CB\u25CB\u25CB\u25CB@\u25CB\u25CB\u25CB\u25CB.\u25CB\u25CB\u25CB\u306E\u5F62\u5F0F\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),i(T,{children:"\u6700\u5F8C\u306E\u6587\u5B57\u306B.(\u30C9\u30C3\u30C8)\u3092\u5165\u308C\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"})]})},password:{reg:/^(?=[^A-Z]*[A-Z])(?=[^a-z]*[a-z])(?=[^0-9]*[0-9]).{8,}$/,exist:!0,reason:"8\u6587\u5B57\u4EE5\u4E0A\u3001\u534A\u89D2\u82F1\u6570\u5927\u5C0F\u6587\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},tel:{reg:/.*$/g,exist:!0,reason:q(W,{children:[i(T,{children:"0\u304B\u3089\u59CB\u307E\u308B\u756A\u53F7\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"}),i(T,{children:"9~12\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),i(T,{children:"\u6570\u5B57\u306E\u307F\u5165\u529B\u53EF\u80FD\u3067\u3059"})]})},url:{reg:/^https?:\/\/[^\n\s]+(\.|\:)[^\n\s\.\:]+$/,exist:!0,reason:"URL\u5F62\u5F0F : http(s)://\u25EF\u25EF\u25EF\u25EF"},postal:{reg:/^\d{7}$/g,exist:!0,reason:"7\u6841\u306E\u6570\u5B57\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}},V=t=>{let{restrict:r,value:s=""}=t,e=String(s),a=!1;if(["tel","number","digitNumber","test","postal","creditCard"].includes(r)&&(e=e.zen2hanNumber()),r=="katakana"&&(e=e.replace(/[^ァ-ヶー ヲ-゚ ]/ig,"")),r=="hankaku.katakana"&&(e=e.replace(/[^ヲ-゚ ]/ig,"")),["postal","creditCard"].includes(r)&&(e=e.removeLetters()),["number","number.zeroStart","digitNumber"].includes(r)){let u=e[0]=="0";if(e){if(e!="-")if(e=="0-")e="-";else{e[0]=="-"&&(a=!0),e=e.replace(/[^0-9\.]/ig,"");let n=Number(e);n===0&&(a=!1),a&&(n=-1*n),x.is.exist(t.min)&&(n=Math.max(n,Number(t.min))),x.is.exist(t.max)&&(n=Math.min(n,Number(t.max))),e=String(Math.abs(n))}u&&e!="0"&&r=="number.zeroStart"&&(e="0"+e)}}let l=e;if(r=="digitNumber"){if(e&&e!="-"){let u=[];for(let n=e.length-1;n>=0;n--){u.unshift(e[n]);let g=e.length-1-n+1;n!=0&&g%3==0&&u.unshift(",")}l=u.join("")}}else r=="postal"?e.length>=4&&(l=e.clip(0,3)+"-"+e.clip(3)):r=="creditCard"&&(l=e.replace(/.{4}(?=.)/g,"$& "));return["number","digitNumber"].includes(r)&&a&&(e="-"+e,l="-"+l),{formatValue:l,dataValue:e}},me=t=>{let{id:r,restrict:s,val_status:e}=t,a=ae("#"+r)[0];if(a&&e.prevValue&&e.formatValue){let{formatValue:l,prevValue:u,caretFrom:n,caretTo:g}=e;if(s=="creditCard")l.length>=u.length&&n%5==0&&(n++,g++),a.setSelectionRange(n,g);else if(s=="postal")l.length==5&&u.length==3&&(n++,g++),a.setSelectionRange(n,g);else if(s=="digitNumber"){let w=l.length-u.length;w==2&&(n++,g++),w==-2&&(n--,g--),a.setSelectionRange(n,g)}}},H=(t,r)=>{let s={ok:!0,body:""};return(()=>{let e=se[r];if(!e)return;let a=e.reason;if(e){let l=!!(+!!t.match(e.reg)^+!e.exist);s={ok:l,body:l?"":a}}})(),s};function pe(t){let{value:r,states:s}=t,{restrict:e="text",maxLength:a=255,required:l}=s,u=[];if(x.is.exist(a)&&r.length>=Number(a)&&u.push({type:"invalid",label:a+"\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),r){let n=H(r,e);n.ok||u.push({type:"invalid",label:n.body})}else l&&u.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"});return{ok:!u.filter(({type:n})=>n=="invalid").length,notice:u}}const de=t=>{let O=t,{componentID:r,tone:s,required:e,restrict:a="text",form:l,autoComplete:u="off",autoCapitalize:n="off",enableFormSubmit:g,clearButton:w=!1,checkValidationAtFirst:ce,onChange:M,onKeyDown:$,onValidate:fe,onUpdateValue:Y,onUpdateValidValue:j,value:z="",leftIndicator:ge,rightIndicator:xe,leftIcon:be,rightIcon:he,maxLength:Ie,min:k,max:v,freeCSS:ye,wrapStyles:Ne}=O,p=P(O,["componentID","tone","required","restrict","form","autoComplete","autoCapitalize","enableFormSubmit","clearButton","checkValidationAtFirst","onChange","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","maxLength","min","max","freeCSS","wrapStyles"]),G=a=="password"||a=="concealed"?"password":"text",Q=["number","digitNumber","creditCard"].includes(a)?"numeric":a=="email"?"email":"text",ee=y(o({componentID:r},V({min:k,max:v,restrict:a,value:z})),{prevValue:"",eventType:"init",eventID:x.uuid.gen(),caretFrom:null,caretTo:null}),[te,X]=R(!1),[d,N]=R(ee),[C,_]=R({ok:!1,notice:[]});return le({states:t,val_status:d,set_status:N,val_validate:C,set_validate:_,DefaultValidation:pe,onUpdateValue:Y,onUpdateValidValue:j,ExtraOverrideStates:o({},V({min:k,max:v,restrict:a,value:z}))}),F(()=>{me({id:t.id,restrict:a,val_status:d})},[d]),i(ie,{val_status:d,set_status:N,val_validate:C,states:t,children:i("input",y(o({type:G,inputMode:Q,"data-form":l,"data-input-type":"text","data-validation":C.ok,"data-value":d.dataValue,"data-component-id":d.componentID,value:d.formatValue,autoComplete:u,autoCapitalize:n,onKeyDown:c=>{let{key:f,target:h}=c;{let b=h,{selectionStart:I,selectionEnd:S}=b,E=Number(I),L=Number(S),A=d.formatValue[Number(E)],J=d.formatValue[Number(E)-1];f=="Delete"&&(a=="creditCard"&&A==" "||a=="postal"&&A=="-"||a=="digitNumber"&&A==",")&&(b.setSelectionRange(E+1,L+1),c.preventDefault()),f=="Backspace"&&(a=="creditCard"&&J==" "||a=="postal"&&J=="-"||a=="digitNumber"&&J==",")&&(b.setSelectionRange(E-1,L-1),c.preventDefault()),f=="Enter"||f=="Tab"}if(["number","digitNumber","creditCard"].includes(a)&&f=="Clear"&&N(b=>y(o({},b),{dataValue:"",formatValue:"",eventType:"update",eventID:x.uuid.gen()})),["number","digitNumber"].includes(a)&&["ArrowUp","ArrowDown"].includes(f)){let b=+(f=="ArrowUp")*2-1,I=String(Number(d.dataValue)+b);C.ok&&_({ok:!1,notice:[]}),N(S=>y(o(o({},S),V({min:k,max:v,restrict:a,value:I})),{eventType:"update",eventID:x.uuid.gen()})),c.preventDefault()}$&&$(c),g&&oe(c)},onChange:c=>{let{value:f,selectionStart:h,selectionEnd:b}=c.target,I=V({min:k,max:v,restrict:a,value:f});te&&(I.formatValue=f),I.formatValue!=d.formatValue&&(C.ok&&_({ok:!1,notice:[]}),N(S=>y(o(o({},S),I),{prevValue:d.formatValue,eventType:"update",eventID:x.uuid.gen(),caretFrom:Number(h),caretTo:Number(b)})),M&&M(c))}},p),{onCompositionStart:c=>{p!=null&&p.onCompositionStart&&(p==null||p.onCompositionStart(c)),X(!0)},onCompositionEnd:c=>{if(p!=null&&p.onCompositionEnd&&(p==null||p.onCompositionEnd(c)),a=="text")return;let f=V({min:k,max:v,restrict:a,value:d.formatValue});N(h=>y(o(o({},h),f),{prevValue:h.formatValue,eventType:"update",eventID:x.uuid.gen(),caretFrom:Number(h.formatValue.length+1),caretTo:Number(h.formatValue.length+1)})),X(!1)}}))})},m={Validate:H,Normal:t=>(t=o({},t),t.rightIcon&&(t=o({paddingRight:3},t)),t.leftIcon&&(t=o({paddingLeft:3},t)),i(ne,{componentID:t.componentID,children:de,states:ue.Boxish(t)})),Katakana:t=>i(m.Normal,o({restrict:"katakana"},t)),HankakuKatakana:t=>i(m.Normal,o({restrict:"hankaku.katakana"},t)),CreditCard:t=>i(m.Normal,o({restrict:"creditCard"},t)),Tel:t=>i(m.Normal,o({restrict:"tel",placeholder:"xxx-xxxx-xxxx"},t)),Number:t=>i(m.Normal,o({restrict:"number"},t)),DigitNumber:t=>i(m.Normal,o({restrict:"digitNumber"},t)),Email:t=>i(m.Normal,o({restrict:"email"},t)),Url:t=>i(m.Normal,o({restrict:"url"},t)),Postal:t=>{let[r]=R(x.uuid.gen());return F(()=>()=>{re.delete(r)},[]),i(m.Normal,o({restrict:"postal",placeholder:"\u90F5\u4FBF\u756A\u53F7",leftIndicator:i(B.LeftIndicator,{children:"\u3012"})},t))},Password:t=>i(m.Normal,o({restrict:"password",placeholder:"\u30D1\u30B9\u30EF\u30FC\u30C9\u3092\u5165\u529B",rightIndicator:i(B.RightIndicator,{padding:0,children:i(Z.Button.Normal.R,{padding:[0,1],fontColor:"theme",borderRadius:"inherit",backgroundColor:"inherit",flexCenter:!0,height:1,ssEffectsOnActive:["expand"],onMouseOver:r=>{D.open({parent:r.currentTarget,gravityPoint:24,padding:[1,0],content:i(D.Comps.Body,{children:"\u30D1\u30B9\u30EF\u30FC\u30C9\u3092\u8868\u793A"})})},tabIndex:-1,onClick:r=>{x(r.target).parent().parent().find("input").callback(s=>{let e=s[0];e.type=e.type==="password"?"text":"password"})},children:i(U,{icon:K})})})},t)),Concealed:t=>i(m.Normal,o({restrict:"concealed",placeholder:"\u79D8\u5BC6\u9375\u3092\u5165\u529B",rightIndicator:i(B.RightIndicator,{padding:0,children:i(Z.Button.Normal.R,{padding:[0,1],fontColor:"theme",borderRadius:"inherit",backgroundColor:"inherit",flexCenter:!0,height:1,ssEffectsOnActive:["expand"],onMouseOver:r=>{D.open({parent:r.currentTarget,gravityPoint:24,padding:[1,0],content:i(D.Comps.Body,{children:"\u5024\u3092\u8868\u793A"})})},tabIndex:-1,onClick:r=>{x(r.target).parent().parent().parent().find("input").callback(s=>{let e=s[0];e.type=e.type==="password"?"text":"password"})},children:i(U,{icon:K})})})},t)),Money:{JPY:t=>i(m.DigitNumber,o({placeholder:"\u91D1\u984D\u3092\u5165\u529B",rightIndicator:i(B.RightIndicator,{children:"\u5186"})},t))}};export{m as Text,de as TextInput,m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a,c as
|
|
1
|
+
import{b as a,c as T,d as v}from"../../chunk-C5N2D3ZX.js";import{jsx as u}from"react/jsx-runtime";import{useState as y}from"react";import g from"@mingoo/jsmin";import{Wrapper as E,BoxWrapper as _,SubmitForm as C,CommonEffects as k,DefaultStyles as w}from"./core";function F(t){let{value:e,states:d}=t,{required:p}=d,n=[];return p&&!e&&n.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!n.filter(({type:r})=>r=="invalid").length,notice:n}}const B=t=>{let I=t,{componentID:e,tone:d,required:p,form:n,enableFormSubmit:r,checkValidationAtFirst:L,onChange:c,onKeyDown:f,onValidate:W,onUpdateValue:h,onUpdateValidValue:V,value:D="",leftIndicator:q,rightIndicator:H,leftIcon:K,rightIcon:M,freeCSS:U,wrapStyles:$}=I,R=v(I,["componentID","tone","required","form","enableFormSubmit","checkValidationAtFirst","onChange","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","leftIcon","rightIcon","freeCSS","wrapStyles"]),b={componentID:e,dataValue:D,eventType:"init",eventID:g.uuid.gen()},[o,s]=y(b),[i,m]=y({ok:!1,notice:[]});return k({states:t,val_status:o,set_status:s,val_validate:i,set_validate:m,onUpdateValue:h,onUpdateValidValue:V,DefaultValidation:F}),u(_,{val_status:o,set_status:s,val_validate:i,states:t,children:u("textarea",a({"data-form":n,"data-input-type":"textarea","data-validation":i.ok,"data-value":o.dataValue,"data-component-id":o.componentID,value:o.dataValue,onKeyDown:l=>{f&&f(l),r&&C(l)},onChange:l=>{let{value:A}=l.target;i.ok&&m({ok:!1,notice:[]}),s(S=>T(a({},S),{dataValue:A,eventType:"update",eventID:g.uuid.gen()})),c&&c(l)}},R))})},x=t=>{t=a({},t),t.rightIcon&&(t=a({paddingRight:3},t)),t.leftIcon&&(t=a({paddingLeft:3},t));let e=w.Boxish(t);return e.rows=e.rows||5,u(E,{componentID:t.componentID,children:B,states:e})};export{x as TextArea,x as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as v,c as M}from"../../../chunk-C5N2D3ZX.js";import{Fragment as H,jsx as r,jsxs as h}from"react/jsx-runtime";import{useState as I,useEffect as W,useRef as j}from"react";import y from"@mingoo/jsmin";import C from"../../../atoms/Box";import V from"../../../atoms/FAI";import B from"../../../atoms/Flex";import w from"../../../atoms/Grid";import N from"../../../mols/Row";import x from"../../../mols/Column";import Y from"../../../mols/Text";import k from"../../Button";import O from"../../Tooltips";import D from"../Select";import{List as z}from"../List";import{InputTimeClasses as b}from"../../../@styles/componentClasses";let A=l=>{var t,a;let e=[],s=Number((t=l==null?void 0:l.min)!=null?t:1900),i=Number((a=l==null?void 0:l.max)!=null?a:y.Time().addYear(10).year);for(let m=s;m<=i;m++)e.unshift({value:m,label:[m,...y.transformer.wareki(m).value].join(" - ")});return e};const F=l=>{let{restrict:e,era:s="year",defaultValue:i=""}=l;l=v({},l),l.tipsID=l.tipsID||y.uuid.gen();const t=j(!1);let[a,m]=I((()=>{var d,p;if(e=="clock"){let o=String(i).split(/[^\d]/);o[0]||(o=[0,0]);let u=Number(o[0]),c=Number(o[1]);return{modifiedType:"init",hour:u,minutes:c}}else if(e=="date"){let[o,u,c]=(d=String(i))==null?void 0:d.split(/\D/);return(y.is.nullish(o)||y.is.nullish(u)||y.is.nullish(c))&&([o,u,c]=y.Time().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",year:Number(o),month:Number(u),date:Number(c)}}else if(e!="week"){if(e=="month"){let[o,u]=String(i).split(/\D/);return(y.is.nullish(o)||y.is.nullish(u))&&([o,u]=y.Time().toFormat("%Y-%M").split("-")),{modifiedType:"init",year:Number(o),month:Number(u)}}else if(e=="year"){let[o]=String(i).split(/\D/);return y.is.nullish(o)&&([o]=y.Time().toFormat("%Y").split("-")),{modifiedType:"init",year:Number(o)}}else if(e=="dateWareki"){let[o,u,c]=(p=String(i))==null?void 0:p.split(/\D/);return(y.is.nullish(o)||y.is.nullish(u)||y.is.nullish(c))&&([o,u,c]=y.Time().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",era:s||"year",year:Number(o),month:Number(u),date:Number(c)}}}return{}})());W(()=>{if(t.current){if(a.modifiedType=="update"){let d="",p=s||"year";if(e=="clock"){let{hour:o,minutes:u}=a;d=[o.zeroEmbed(2),u.zeroEmbed(2)].join("/")}else if(e=="date"){let{year:o,month:u,date:c}=a;d=[o,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}else if(e!="week"){if(e=="month"){let{year:o,month:u}=a;d=[o,u.zeroEmbed(2)].join("/")}else if(e=="year"){let{year:o}=a;d=String(o)}else if(e=="dateWareki"){let{year:o,month:u,date:c,era:S}=a;p=S,d=[o,u.zeroEmbed(2),c.zeroEmbed(2)].join("/")}}l.onValueUpdate(d,p)}}else t.current=!0},[a]);let n=M(v({},l),{val_value:a,set_value:m});return r(C,{styles:{backgroundColor:"layer.1",borderRadius:"2.tone.secondary",boxShadow:"1.remark",border:!0,overflow:"hidden"},children:r(C,{styles:{overflow:"auto"},className:b(e.toCapital()+"Base"),children:e=="clock"?r(g.Clock.index,v({},n)):e=="date"?r(g.Date.index,v({},n)):e=="week"?"":e=="month"?r(g.Month.index,v({},n)):e=="year"?r(g.Year.index,v({},n)):e=="dates"||e=="months"?"":e=="dateWareki"?r(g.DateWareki.index,v({},n)):r(H,{})})})},g={Clock:{index:l=>{let{min:e,max:s,onValueUpdate:i,tipsID:t,val_value:a,set_value:m}=l,[n,d]=I(a.hour>12?2:1),[p,o]=I(Number(localStorage.getItem("timePickerUnit")||5));W(()=>{localStorage.setItem("timePickerUnit",String(p))},[p]);let{hour:u,minutes:c}=a;return h(x,{styles:{padding:1},children:[h(B,{styles:{flexType:"row",flexWrap:!1,gap:1},className:b("Body"),children:[h(x,{className:b("DesignSide"),styles:{flexSizing:0},children:[r(C,{className:b("ClockUiBase"),styles:{padding:[1,"2/3"],flexCenter:!0},children:h(C,{className:b("ClockUi"),styles:{backgroundColor:"theme.opa.low",isRounded:!0,position:"relative"},children:[r(C,{styles:{position:"absolute",backgroundColor:"theme",unitWidth:"1/12"},className:[b("Needle"),b("hour")].join(" "),freeCSS:{transform:`rotate(${u*30+c/2}deg)`}}),r(C,{styles:{position:"absolute",backgroundColor:"theme",unitWidth:"1/12"},className:[b("Needle"),b("minute")].join(" "),freeCSS:{transform:`rotate(${c*6}deg)`}})]})}),r(z.Radio,{tone:"plain",icon:!0,value:[n],options:[{value:1,label:"AM"},{value:2,label:"PM"}],styles:{flexType:"col",gap:0},cellStyles:{padding:"1/2",horizontalAlign:"between",gap:"1/3"},tabIndex:-1,onUpdateValidValue:({value:S})=>{let T=a.hour%12+(S==2?12:0);d(S),m({modifiedType:"update",hour:T,minutes:a.minutes})}}),r(C,{styles:{borderTop:!0,margin:[0,1]}}),r(z.Radio,{tone:"plain",icon:!0,value:[p],options:[{value:1,label:"/ 1\u5206"},{value:2,label:"/ 2\u5206"},{value:5,label:"/ 5\u5206"}],styles:{flexType:"col",gap:0},cellStyles:{padding:"1/2",horizontalAlign:"between",gap:"1/3"},tabIndex:-1,onUpdateValidValue:({value:S})=>{o(S)}})]}),h(x,{children:[h(C,{styles:{flexCenter:!0,fontSize:"3.paragraph",isSemiBoldFont:!0},children:[a.hour.zeroEmbed(2)," : ",a.minutes.zeroEmbed(2)]}),h(B,{styles:{flexWrap:!1,borderRadius:"1.tone.primary",boxShadow:"0.remark.inset",flexChilds:"even",padding:["1/3",0]},freeCSS:{minWidth:12*12},children:[r(x,{styles:{gap:0,overflow:"auto",padding:"2/3",borderRight:!0},freeCSS:{maxHeight:12*22},children:g.Clock.Hours({onClick:S=>{let R=S+(n==2?12:0);m({modifiedType:"update",hour:R,minutes:a.minutes})},min:e,max:s,ampm:n})}),r(x,{styles:{gap:0,overflow:"auto",padding:"2/3"},freeCSS:{maxHeight:12*22},children:g.Clock.Minutes({onClick:S=>{m({modifiedType:"update",hour:a.hour,minutes:S})},min:e,max:s,unit:p})})]})]})]}),r(g.Variables.Footer,{tipsID:t,onValueUpdate:i})]})},Hours:l=>{let e=[];for(let s=0;s<12;s++){let i=l.ampm==2?s+12:s,t=!1;{let a=Number(String(i*100).replace(/\D/ig,""));if(l.min&&Number(String(l.min).replace(/\D/ig,""))>a&&(t=!0),l.max){let m=Number(String(l.max).replace(/\D/ig,""));a>m&&(t=!0)}}e.push(r(k.Button.Normal.R,{isLocked:t,styles:{borderBottom:!0,borderRadius:0,padding:["1/2",1]},freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{l.onClick(s)},children:i.zeroEmbed(2)},s))}return e},Minutes:l=>{let e=[];for(let s=0;s<60/l.unit;s++){let i=s*l.unit;e.push(r(k.Button.Normal.R,{styles:{borderBottom:!0,borderRadius:0,padding:["1/2",1]},freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{l.onClick(i)},children:i.zeroEmbed(2)},i))}return e}},Date:{index:l=>{let{min:e,max:s,onValueUpdate:i,tipsID:t,val_value:a,set_value:m}=l,{year:n,month:d,date:p}=a;return h(x,{styles:{padding:1},children:[h(B,{styles:{horizontalAlign:"between",verticalAlign:"center",flexWrap:!1},children:[h(B,{styles:{verticalAlign:"bottom",horizontalAlign:"left",gap:"2/3",flexWrap:!1},children:[r(D,{override:"force",enableUnSelected:!1,value:n,options:A(),styles:{border:"1.thin",padding:["1/3","2/3"],paddingRight:2},rightIconStyles:{right:"1/3"},onUpdateValidValue:({value:o})=>{m({modifiedType:"update",year:Number(o),month:d,date:p})}}),r(D,{override:"force",enableUnSelected:!1,value:d,options:(()=>{let o=[];for(let u=1;u<=12;u++)o.push({value:u,label:String(u),displayLabel:String(u)+"\u6708"});return o})(),placeholder:"",styles:{border:"1.thin",padding:["1/3","2/3"],paddingRight:2},rightIconStyles:{right:"1/3"},onUpdateValidValue:({value:o})=>{m({modifiedType:"update",year:n,month:Number(o),date:p})}})]}),r(g.Variables.ShiftButtons,{callback:o=>{let u=d+o,c=n;o==-1?(u<=0&&c--,u=u||12):d==12&&c++,m({modifiedType:"update",year:c,month:u,date:a.date})}})]}),r(C,{styles:{borderTop:!0}}),r(C,{children:g.Date.MonthCalendar({min:e,max:s,year:a.year,month:a.month,current:[a.year,a.month,a.date],callback:o=>{let[u,c,S]=o;m({modifiedType:"update",year:u,month:c,date:S})}})}),r(g.Variables.Footer,{tipsID:t,onValueUpdate:i})]})},MonthCalendar:l=>{let{min:e,max:s,year:i,month:t,current:a,callback:m}=l,n=y.Time(),d=y.Time([i,t.zeroEmbed(2),"01"].join("/")),p=d.getLastDayOfTheMonth(),o=y.Time(d).addMonth(-1).getLastDayOfTheMonth().date,u=[],c=[],S=[],R=[],T={padding:0,unitWidth:3,unitHeight:3,flexCenter:!0,borderRadius:"3.tone.tertiary"};for(var f=0;f<7;f++)u.push(r(C,{className:[b("CalendarDay"),b("Legend")].join(" "),styles:T,children:["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][f]},f));for(var f=0;f<d.weekday;f++)c.unshift(r(C,{className:[b("CalendarDay"),b("Dummy")].join(" "),styles:v({fontColor:"4.thin"},T),children:o-f},f));for(var f=1;f<=p.date;f++){let U=f,L=i==n.year&&t==n.month&&f==n.date,P=!1;{let _=Number(String([i,t.zeroEmbed(2),f.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(l.min&&Number(String(l.min).replace(/\D/ig,""))>_&&(P=!0),l.max){let E=Number(String(l.max).replace(/\D/ig,""));_>E&&(P=!0)}}S.push(r(k.Button.Clear.R,{className:[b("CalendarDay"),b("isToday_"+L)].join(" "),styles:M(v({},T),{fontColor:"1.clear",padding:0,flexCenter:!0,borderRadius:"sphere",ssEffectsOnActive:"shrink"}),onClick:()=>{m([i,t,U])},tabIndex:-1,isLocked:P,children:f},U))}for(var f=1;f<7-p.weekday;f++)R.push(r(C,{className:[b("CalendarDay"),b("Dummy")].join(" "),styles:v({fontColor:"4.thin"},T),children:f},f));return h(w,{styles:{gridCols:7,gap:"1/3"},children:[u,c,S,R]})}},Month:{index:l=>{let{min:e,max:s,onValueUpdate:i,tipsID:t,val_value:a,set_value:m}=l,{year:n,month:d}=a;return h(x,{styles:{padding:1},children:[h(N.Separate,{styles:{gap:0},children:[r(N.Center,{styles:{verticalAlign:"bottom",gap:"2/3"},children:r(D,{enableUnSelected:!1,value:n,options:A(),override:"force",styles:{border:"1.thin",padding:["1/3","2/3"],paddingRight:2},rightIconStyles:{right:"1/3"},onUpdateValidValue:({value:p})=>{m({modifiedType:"update",year:Number(p),month:d})}})}),r(g.Variables.ShiftButtons,{callback:p=>{let o=Math.min(Math.max(n+p,1900),2100);m({modifiedType:"update",year:o,month:d})}})]}),r(C,{styles:{borderTop:!0}}),g.Month.Months({min:e,max:s,year:a.year,callback:p=>{let[o,u]=p;m({modifiedType:"update",year:o,month:u})}}),r(g.Variables.Footer,{tipsID:t,onValueUpdate:i})]})},Months:l=>{let{year:e,callback:s}=l,i=y.Time(),t=[];for(let a=1;a<=12;a++){let m=e==i.year&&a==i.month,n=!1;{let p=Number(String([e,a.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(l.min&&Number(String(l.min).replace(/\D/ig,""))>p&&(n=!0),l.max){let o=Number(String(l.max).replace(/\D/ig,""));p>o&&(n=!0)}}let d=[b("Cell"),m?b("isThisMonth"):""].join(" ");t.push(h(k.Button.Clear.R,{className:d,isLocked:n,styles:{fontColor:"2.normal",padding:["1/3",1],ssEffectsOnActive:"shrink"},onClick:()=>{s([e,a])},children:[a," \u6708"]},e+"-"+a))}return r(w,{styles:{gridCols:4,gap:"2/3"},children:t})}},Year:{index:l=>{let{min:e,max:s,onValueUpdate:i,tipsID:t,val_value:a,set_value:m}=l,{year:n}=a;return h(x,{styles:{padding:1},children:[r(D,{enableUnSelected:!1,value:n||y.Time().year,override:"force",options:A({min:e,max:s}),onUpdateValidValue:({value:d})=>{m({modifiedType:"update",year:Number(d)})}}),r(g.Variables.Footer,{tipsID:t,onValueUpdate:i,onSubmit:()=>{m({modifiedType:"update",year:Number(n||y.Time().year)})}})]})}},DateWareki:{index:l=>{let{min:e,max:s,onValueUpdate:i,tipsID:t,val_value:a,set_value:m}=l,{era:n,year:d,month:p,date:o}=a,u={val_value:a,set_value:m};return h(C,{children:[h(N.Left,{styles:{verticalAlign:"unset",borderBottom:!0,gap:0},children:[r(g.DateWareki.EraSelect,v({},u)),r(C,{styles:{borderRight:!0}}),r(g.DateWareki.Calendar,v({},u))]}),r(C,{styles:{padding:1},children:r(g.Variables.Footer,{tipsID:t,onValueUpdate:i})})]})},EraSelect:l=>{let{val_value:e,set_value:s}=l,i={padding:["1/2",1.5],fontColor:"3.blur"},t={backgroundColor:"cloud",fontColor:"2.normal",isSemiBoldFont:!0};return h(x,{styles:{gap:0,padding:1},children:[r(k.Button.Clear.R,{color:"cloud",styles:i,isActiveStyles:t,isActive:e.era=="year",onClick:()=>{let a=y.Time();s({modifiedType:"update",era:"year",year:a.year,month:a.month,date:a.date})},children:"\u897F\u66A6"}),r(k.Button.Clear.R,{color:"cloud",styles:i,isActiveStyles:t,isActive:e.era=="reiwa",onClick:()=>{let a=y.Time();s({modifiedType:"update",era:"reiwa",year:a.year,month:a.month,date:a.date})},children:"\u4EE4\u548C"}),r(k.Button.Clear.R,{color:"cloud",styles:i,isActiveStyles:t,isActive:e.era=="heisei",onClick:()=>{s({modifiedType:"update",era:"heisei",year:2019,month:1,date:1})},children:"\u5E73\u6210"}),r(k.Button.Clear.R,{color:"cloud",styles:i,isActiveStyles:t,isActive:e.era=="shouwa",onClick:()=>{s({modifiedType:"update",era:"shouwa",year:1989,month:1,date:1})},children:"\u662D\u548C"}),r(k.Button.Clear.R,{color:"cloud",styles:i,isActiveStyles:t,isActive:e.era=="taisho",onClick:()=>{s({modifiedType:"update",era:"taisho",year:1926,month:1,date:1})},children:"\u5927\u6B63"}),r(k.Button.Clear.R,{color:"cloud",styles:i,isActiveStyles:t,isActive:e.era=="meiji",onClick:()=>{s({modifiedType:"update",era:"meiji",year:1912,month:1,date:1})},children:"\u660E\u6CBB"})]})},Calendar:l=>{let{val_value:e,set_value:s}=l,i=[];if(e.era=="year")for(let t=1900;t<2100;t++)i.unshift({value:t,label:t+"\u5E74"});else if(e.era=="reiwa"){let t=y.Time().year-2018;for(let a=1;a<=t+10;a++)i.unshift({value:2019+a-1,label:"\u4EE4\u548C"+(a==1?"\u5143":a)+"\u5E74"})}else if(e.era=="heisei")for(let t=1;t<=31;t++)i.unshift({value:1989+t-1,label:"\u5E73\u6210"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="shouwa")for(let t=1;t<=64;t++)i.unshift({value:1926+t-1,label:"\u662D\u548C"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="taisho")for(let t=1;t<=15;t++)i.unshift({value:1912+t-1,label:"\u5927\u6B63"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="meiji")for(let t=1;t<=45;t++)i.unshift({value:1868+t-1,label:"\u660E\u6CBB"+(t==1?"\u5143":t)+"\u5E74"});return h(x,{styles:{padding:1},children:[h(N.Separate,{children:[r(D,{tone:"cloud",enableUnSelected:!1,override:"force",styles:{border:"1.thin",padding:["1/3","2/3"],paddingRight:2},rightIconStyles:{right:"1/3"},options:i,value:e.year,onUpdateValidValue:({value:t})=>{s(a=>M(v({},a),{modifiedType:"update",year:Number(t)}))}}),h(N.Center,{styles:{gap:"1/3"},children:[r(k.Button.Clear.S,{styles:{ssSphere:2},onClick:()=>{let t=e.month-1;s({modifiedType:"update",era:e.era,year:t==0?e.year-1:e.year,month:t==0?12:t,date:1})},children:r(V.ChevronLeft,{})}),r(D,{tone:"cloud",enableUnSelected:!1,override:"force",styles:{border:"1.thin",padding:["1/3","2/3"],paddingRight:2},rightIconStyles:{right:"1/3"},options:[{value:1,label:"1\u6708"},{value:2,label:"2\u6708"},{value:3,label:"3\u6708"},{value:4,label:"4\u6708"},{value:5,label:"5\u6708"},{value:6,label:"6\u6708"},{value:7,label:"7\u6708"},{value:8,label:"8\u6708"},{value:9,label:"9\u6708"},{value:10,label:"10\u6708"},{value:11,label:"11\u6708"},{value:12,label:"12\u6708"}],value:e.month,onUpdateValidValue:({value:t})=>{s({modifiedType:"update",era:e.era,year:e.year,month:Number(t),date:1})}}),r(k.Button.Clear.S,{styles:{ssSphere:2},onClick:()=>{let t=e.month+1;s({modifiedType:"update",era:e.era,year:t==13?e.year+1:e.year,month:t==13?1:t,date:1})},children:r(V.ChevronRight,{})})]})]}),r(g.DateWareki.MonthCell,v({},l))]},e.era)},MonthCell:l=>{let{val_value:e,set_value:s}=l,i=y.Time([e.year.zeroEmbed(4),e.month.zeroEmbed(2),e.date.zeroEmbed(2)].join("/"));if(!i.validate)return;let t=i.getFirstDayOfTheMonth().weekday,a=i.getLastDayOfTheMonth(),m=[];for(let n=0;n<7;n++)m.push(r(Y.Supplement,{styles:{flexCenter:!0,fontColor:n==0?"googleRed":n==6?"googleBlue":"3.blur"},children:y.transformer.weekday.shortJP(n)},"legend-"+n));for(let n=0;n<t;n++){let d=y.Time(i).getFirstDayOfTheMonth().addDate(n-t);m.push(r(k.Button.Sub.R,{color:"cloud",styles:{border:"1.thin",ssSphere:3,opacity:"middle"},onClick:p=>{p.preventDefault(),p.stopPropagation(),s({modifiedType:"update",era:e.era,year:d.year,month:d.month,date:d.date})},children:d.date},"lastMonth-"+n))}for(let n=1;n<=a.date;n++){let d=y.Time(i).setDate(n);m.push(r(k.Button.Border.R,{styles:{ssSquare:3},onClick:()=>{s({modifiedType:"update",era:e.era,year:d.year,month:d.month,date:d.date})},children:d.date},"currentMonth-"+n))}for(let n=0;n<7-a.weekday-1;n++){let d=y.Time(i).addMonth(1).setDate(1).addDate(n);m.push(r(k.Button.Sub.R,{color:"cloud",styles:{border:"1.thin",ssSquare:3,opacity:"middle"},onClick:p=>{p.preventDefault(),p.stopPropagation(),s({modifiedType:"update",era:e.era,year:d.year,month:d.month,date:d.date})},children:d.date},"nextMonth-"+n))}return r(w,{styles:{gridCols:7,gap:"1/4"},children:m})}},Variables:{Footer:l=>h(B,{styles:{flexWrap:!1,gap:1,flexChilds:"even"},freeCSS:{whiteSpace:"nowrap"},children:[h(k.Button.Border.R,{onClick:()=>{l.onValueUpdate("")},tabIndex:-1,styles:{flexSizing:"none",padding:["2/3",1]},children:[r(V.Times,{})," \u524A\u9664"]}),r(k.Button.Prime.R,{styles:{flexSizing:"auto",padding:["2/3",1]},onClick:()=>{l.onSubmit&&l.onSubmit(),O.close(l.tipsID)},tabIndex:-1,children:"\u6C7A\u5B9A"})]}),ShiftButtons:l=>h(B,{styles:{flexWrap:!1,gap:"1/3"},children:[r(k.Button.Clear.R,{className:b("LeftButton"),tabIndex:-1,styles:v({right:0},g.Variables.ShiftButtonStyles),onClick:()=>{l.callback(-1)},children:r(V.ChevronLeft,{})}),r(k.Button.Clear.R,{className:b("RightButton"),tabIndex:-1,styles:v({left:0},g.Variables.ShiftButtonStyles),onClick:()=>{l.callback(1)},children:r(V.ChevronRight,{})})]}),ShiftButtonStyles:{flexCenter:!0,padding:0,unitWidth:3,unitHeight:3,borderRadius:"sphere",position:"relative"}}};export{F as Picker,F as default};
|
|
1
|
+
import{b as f,c as x}from"../../../chunk-C5N2D3ZX.js";import{Fragment as H,jsx as r,jsxs as y}from"react/jsx-runtime";import{createElement as G}from"react";import{useState as I,useEffect as W,useRef as j}from"react";import c from"@mingoo/jsmin";import C from"../../../atoms/Box";import N from"../../../atoms/FAI";import D from"../../../atoms/Flex";import w from"../../../atoms/Grid";import M from"../../../mols/Row";import T from"../../../mols/Column";import Y from"../../../mols/Text";import v from"../../Button";import O from"../../Tooltips";import R from"../Select";import{List as z}from"../List";import{InputTimeClasses as g}from"../../../@styles/componentClasses";let A=i=>{var t,a;let e=[],d=Number((t=i==null?void 0:i.min)!=null?t:1900),o=Number((a=i==null?void 0:i.max)!=null?a:c.Time().addYear(10).year);for(let m=d;m<=o;m++)e.unshift({value:m,label:[m,...c.transformer.wareki(m).value].join(" - ")});return e};const F=i=>{let{restrict:e,era:d="year",defaultValue:o=""}=i;i=f({},i),i.tipsID=i.tipsID||c.uuid.gen();const t=j(!1);let[a,m]=I((()=>{var s,p;if(e=="clock"){let l=String(o).split(/[^\d]/);l[0]||(l=[0,0]);let u=Number(l[0]),h=Number(l[1]);return{modifiedType:"init",hour:u,minutes:h}}else if(e=="date"){let[l,u,h]=(s=String(o))==null?void 0:s.split(/\D/);return(c.is.nullish(l)||c.is.nullish(u)||c.is.nullish(h))&&([l,u,h]=c.Time().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",year:Number(l),month:Number(u),date:Number(h)}}else if(e!="week"){if(e=="month"){let[l,u]=String(o).split(/\D/);return(c.is.nullish(l)||c.is.nullish(u))&&([l,u]=c.Time().toFormat("%Y-%M").split("-")),{modifiedType:"init",year:Number(l),month:Number(u)}}else if(e=="year"){let[l]=String(o).split(/\D/);return c.is.nullish(l)&&([l]=c.Time().toFormat("%Y").split("-")),{modifiedType:"init",year:Number(l)}}else if(e=="dateWareki"){let[l,u,h]=(p=String(o))==null?void 0:p.split(/\D/);return(c.is.nullish(l)||c.is.nullish(u)||c.is.nullish(h))&&([l,u,h]=c.Time().toFormat("%Y-%M-%D").split("-")),{modifiedType:"init",era:d||"year",year:Number(l),month:Number(u),date:Number(h)}}}return{}})());W(()=>{if(t.current){if(a.modifiedType=="update"){let s="",p=d||"year";if(e=="clock"){let{hour:l,minutes:u}=a;s=[l.zeroEmbed(2),u.zeroEmbed(2)].join("/")}else if(e=="date"){let{year:l,month:u,date:h}=a;s=[l,u.zeroEmbed(2),h.zeroEmbed(2)].join("/")}else if(e!="week"){if(e=="month"){let{year:l,month:u}=a;s=[l,u.zeroEmbed(2)].join("/")}else if(e=="year"){let{year:l}=a;s=String(l)}else if(e=="dateWareki"){let{year:l,month:u,date:h,era:S}=a;p=S,s=[l,u.zeroEmbed(2),h.zeroEmbed(2)].join("/")}}i.onValueUpdate(s,p)}}else t.current=!0},[a]);let n=x(f({},i),{val_value:a,set_value:m});return r(C,{backgroundColor:"layer.1",borderRadius:"2.tone.secondary",boxShadow:"1.remark",border:!0,overflow:"hidden",children:r(C,{overflow:"auto",className:g(e.toCapital()+"Base"),children:e=="clock"?r(k.Clock.index,f({},n)):e=="date"?r(k.Date.index,f({},n)):e=="week"?"":e=="month"?r(k.Month.index,f({},n)):e=="year"?r(k.Year.index,f({},n)):e=="dates"||e=="months"?"":e=="dateWareki"?r(k.DateWareki.index,f({},n)):r(H,{})})})},k={Clock:{index:i=>{let{min:e,max:d,onValueUpdate:o,tipsID:t,val_value:a,set_value:m}=i,[n,s]=I(a.hour>12?2:1),[p,l]=I(Number(localStorage.getItem("timePickerUnit")||5));W(()=>{localStorage.setItem("timePickerUnit",String(p))},[p]);let{hour:u,minutes:h}=a;return y(T,{padding:1,children:[y(D,{flexType:"row",flexWrap:!1,gap:1,className:g("Body"),children:[y(T,{className:g("DesignSide"),flexSizing:0,children:[r(C,{className:g("ClockUiBase"),padding:[1,"2/3"],flexCenter:!0,children:y(C,{className:g("ClockUi"),backgroundColor:"theme.opa.low",isRounded:!0,position:"relative",children:[r(C,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[g("Needle"),g("hour")].join(" "),freeCSS:{transform:`rotate(${u*30+h/2}deg)`}}),r(C,{position:"absolute",backgroundColor:"theme",unitWidth:"1/12",className:[g("Needle"),g("minute")].join(" "),freeCSS:{transform:`rotate(${h*6}deg)`}})]})}),r(z.Radio,{tone:"plain",icon:!0,value:[n],options:[{value:1,label:"AM"},{value:2,label:"PM"}],flexType:"col",gap:0,cellStyles:{padding:"1/2",horizontalAlign:"between",gap:"1/3"},tabIndex:-1,onUpdateValidValue:({value:S})=>{let B=a.hour%12+(S==2?12:0);s(S),m({modifiedType:"update",hour:B,minutes:a.minutes})}}),r(C,{borderTop:!0,margin:[0,1]}),r(z.Radio,{tone:"plain",icon:!0,value:[p],options:[{value:1,label:"/ 1\u5206"},{value:2,label:"/ 2\u5206"},{value:5,label:"/ 5\u5206"}],flexType:"col",gap:0,cellStyles:{padding:"1/2",horizontalAlign:"between",gap:"1/3"},tabIndex:-1,onUpdateValidValue:({value:S})=>{l(S)}})]}),y(T,{children:[y(C,{flexCenter:!0,isSemiBoldFont:!0,fontSize:"3.paragraph",children:[a.hour.zeroEmbed(2)," : ",a.minutes.zeroEmbed(2)]}),y(D,{flexWrap:!1,borderRadius:"1.tone.primary",boxShadow:"0.remark.inset",flexChilds:"even",padding:["1/3",0],freeCSS:{minWidth:12*12},children:[r(T,{gap:0,overflow:"auto",padding:"2/3",borderRight:!0,freeCSS:{maxHeight:12*22},children:k.Clock.Hours({onClick:S=>{let V=S+(n==2?12:0);m({modifiedType:"update",hour:V,minutes:a.minutes})},min:e,max:d,ampm:n})}),r(T,{gap:0,overflow:"auto",padding:"2/3",freeCSS:{maxHeight:12*22},children:k.Clock.Minutes({onClick:S=>{m({modifiedType:"update",hour:a.hour,minutes:S})},min:e,max:d,unit:p})})]})]})]}),r(k.Variables.Footer,{tipsID:t,onValueUpdate:o})]})},Hours:i=>{let e=[];for(let d=0;d<12;d++){let o=i.ampm==2?d+12:d,t=!1;{let a=Number(String(o*100).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>a&&(t=!0),i.max){let m=Number(String(i.max).replace(/\D/ig,""));a>m&&(t=!0)}}e.push(r(v.Button.Normal.R,{isLocked:t,borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(d)},children:o.zeroEmbed(2)},d))}return e},Minutes:i=>{let e=[];for(let d=0;d<60/i.unit;d++){let o=d*i.unit;e.push(r(v.Button.Normal.R,{borderBottom:!0,borderRadius:0,padding:["1/2",1],freeCSS:{whiteSpace:"nowrap"},tabIndex:-1,onClick:()=>{i.onClick(o)},children:o.zeroEmbed(2)},o))}return e}},Date:{index:i=>{let{min:e,max:d,onValueUpdate:o,tipsID:t,val_value:a,set_value:m}=i,{year:n,month:s,date:p}=a;return y(T,{padding:1,children:[y(D,{flexWrap:!0,verticalAlign:"center",horizontalAlign:"between",children:[y(D,{verticalAlign:"bottom",horizontalAlign:"left",gap:"2/3",flexWrap:!1,children:[r(R,{override:"force",enableUnSelected:!1,value:n,options:A(),border:"1.thin",padding:["1/3","2/3"],paddingRight:2,rightIconStyles:{right:"1/3"},onUpdateValidValue:({value:l})=>{m({modifiedType:"update",year:Number(l),month:s,date:p})}}),r(R,{override:"force",enableUnSelected:!1,value:s,options:(()=>{let l=[];for(let u=1;u<=12;u++)l.push({value:u,label:String(u),displayLabel:String(u)+"\u6708"});return l})(),placeholder:"",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,rightIconStyles:{right:"1/3"},onUpdateValidValue:({value:l})=>{m({modifiedType:"update",year:n,month:Number(l),date:p})}})]}),r(k.Variables.ShiftButtons,{callback:l=>{let u=s+l,h=n;l==-1?(u<=0&&h--,u=u||12):s==12&&h++,m({modifiedType:"update",year:h,month:u,date:a.date})}})]}),r(C,{borderTop:!0}),r(C,{children:k.Date.MonthCalendar({min:e,max:d,year:a.year,month:a.month,current:[a.year,a.month,a.date],callback:l=>{let[u,h,S]=l;m({modifiedType:"update",year:u,month:h,date:S})}})}),r(k.Variables.Footer,{tipsID:t,onValueUpdate:o})]})},MonthCalendar:i=>{let{min:e,max:d,year:o,month:t,current:a,callback:m}=i,n=c.Time(),s=c.Time([o,t.zeroEmbed(2),"01"].join("/")),p=s.getLastDayOfTheMonth(),l=c.Time(s).addMonth(-1).getLastDayOfTheMonth().date,u=[],h=[],S=[],V=[],B={padding:0,unitWidth:3,unitHeight:3,flexCenter:!0,borderRadius:"3.tone.tertiary"};for(var b=0;b<7;b++)u.push(r(C,x(f({className:[g("CalendarDay"),g("Legend")].join(" ")},B),{children:["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][b]}),b));for(var b=0;b<s.weekday;b++)h.unshift(G(C,x(f({className:[g("CalendarDay"),g("Dummy")].join(" "),fontColor:"4.thin"},B),{key:b}),l-b));for(var b=1;b<=p.date;b++){let U=b,L=o==n.year&&t==n.month&&b==n.date,P=!1;{let _=Number(String([o,t.zeroEmbed(2),b.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>_&&(P=!0),i.max){let E=Number(String(i.max).replace(/\D/ig,""));_>E&&(P=!0)}}S.push(r(v.Button.Clear.R,x(f({className:[g("CalendarDay"),g("isToday_"+L)].join(" ")},B),{fontColor:"1.clear",padding:0,flexCenter:!0,borderRadius:"sphere",ssEffectsOnActive:"shrink",onClick:()=>{m([o,t,U])},tabIndex:-1,isLocked:P,children:b}),U))}for(var b=1;b<7-p.weekday;b++)V.push(r(C,x(f({className:[g("CalendarDay"),g("Dummy")].join(" "),fontColor:"4.thin"},B),{children:b}),b));return y(w,{gridCols:7,gap:"1/3",children:[u,h,S,V]})}},Month:{index:i=>{let{min:e,max:d,onValueUpdate:o,tipsID:t,val_value:a,set_value:m}=i,{year:n,month:s}=a;return y(T,{padding:1,children:[y(M.Separate,{gap:0,children:[r(M.Center,{verticalAlign:"bottom",gap:"2/3",children:r(R,{enableUnSelected:!1,value:n,options:A(),override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,rightIconStyles:{right:"1/3"},onUpdateValidValue:({value:p})=>{m({modifiedType:"update",year:Number(p),month:s})}})}),r(k.Variables.ShiftButtons,{callback:p=>{let l=Math.min(Math.max(n+p,1900),2100);m({modifiedType:"update",year:l,month:s})}})]}),r(C,{borderTop:!0}),k.Month.Months({min:e,max:d,year:a.year,callback:p=>{let[l,u]=p;m({modifiedType:"update",year:l,month:u})}}),r(k.Variables.Footer,{tipsID:t,onValueUpdate:o})]})},Months:i=>{let{year:e,callback:d}=i,o=c.Time(),t=[];for(let a=1;a<=12;a++){let m=e==o.year&&a==o.month,n=!1;{let p=Number(String([e,a.zeroEmbed(2)].join("/")).replace(/\D/ig,""));if(i.min&&Number(String(i.min).replace(/\D/ig,""))>p&&(n=!0),i.max){let l=Number(String(i.max).replace(/\D/ig,""));p>l&&(n=!0)}}let s=[g("Cell"),m?g("isThisMonth"):""].join(" ");t.push(y(v.Button.Clear.R,{className:s,isLocked:n,fontColor:"2.normal",padding:["1/3",1],ssEffectsOnActive:"shrink",onClick:()=>{d([e,a])},children:[a," \u6708"]},e+"-"+a))}return r(w,{gridCols:4,gap:"2/3",children:t})}},Year:{index:i=>{let{min:e,max:d,onValueUpdate:o,tipsID:t,val_value:a,set_value:m}=i,{year:n}=a;return y(T,{padding:1,children:[r(R,{enableUnSelected:!1,value:n||c.Time().year,override:"force",options:A({min:e,max:d}),onUpdateValidValue:({value:s})=>{m({modifiedType:"update",year:Number(s)})}}),r(k.Variables.Footer,{tipsID:t,onValueUpdate:o,onSubmit:()=>{m({modifiedType:"update",year:Number(n||c.Time().year)})}})]})}},DateWareki:{index:i=>{let{min:e,max:d,onValueUpdate:o,tipsID:t,val_value:a,set_value:m}=i,{era:n,year:s,month:p,date:l}=a,u={val_value:a,set_value:m};return y(C,{children:[y(M.Left,{borderBottom:!0,gap:0,verticalAlign:"unset",children:[r(k.DateWareki.EraSelect,f({},u)),r(C,{borderRight:!0}),r(k.DateWareki.Calendar,f({},u))]}),r(C,{padding:1,children:r(k.Variables.Footer,{tipsID:t,onValueUpdate:o})})]})},EraSelect:i=>{let{val_value:e,set_value:d}=i,o={padding:["1/2",1.5],fontColor:"3.blur"},t={backgroundColor:"cloud",fontColor:"2.normal",isSemiBoldFont:!0};return y(T,{padding:1,gap:0,children:[r(v.Button.Clear.R,x(f({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="year",onClick:()=>{let a=c.Time();d({modifiedType:"update",era:"year",year:a.year,month:a.month,date:a.date})},children:"\u897F\u66A6"})),r(v.Button.Clear.R,x(f({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="reiwa",onClick:()=>{let a=c.Time();d({modifiedType:"update",era:"reiwa",year:a.year,month:a.month,date:a.date})},children:"\u4EE4\u548C"})),r(v.Button.Clear.R,x(f({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="heisei",onClick:()=>{d({modifiedType:"update",era:"heisei",year:2019,month:1,date:1})},children:"\u5E73\u6210"})),r(v.Button.Clear.R,x(f({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="shouwa",onClick:()=>{d({modifiedType:"update",era:"shouwa",year:1989,month:1,date:1})},children:"\u662D\u548C"})),r(v.Button.Clear.R,x(f({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="taisho",onClick:()=>{d({modifiedType:"update",era:"taisho",year:1926,month:1,date:1})},children:"\u5927\u6B63"})),r(v.Button.Clear.R,x(f({color:"cloud"},o),{isActiveStyles:t,isActive:e.era=="meiji",onClick:()=>{d({modifiedType:"update",era:"meiji",year:1912,month:1,date:1})},children:"\u660E\u6CBB"}))]})},Calendar:i=>{let{val_value:e,set_value:d}=i,o=[];if(e.era=="year")for(let t=1900;t<2100;t++)o.unshift({value:t,label:t+"\u5E74"});else if(e.era=="reiwa"){let t=c.Time().year-2018;for(let a=1;a<=t+10;a++)o.unshift({value:2019+a-1,label:"\u4EE4\u548C"+(a==1?"\u5143":a)+"\u5E74"})}else if(e.era=="heisei")for(let t=1;t<=31;t++)o.unshift({value:1989+t-1,label:"\u5E73\u6210"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="shouwa")for(let t=1;t<=64;t++)o.unshift({value:1926+t-1,label:"\u662D\u548C"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="taisho")for(let t=1;t<=15;t++)o.unshift({value:1912+t-1,label:"\u5927\u6B63"+(t==1?"\u5143":t)+"\u5E74"});else if(e.era=="meiji")for(let t=1;t<=45;t++)o.unshift({value:1868+t-1,label:"\u660E\u6CBB"+(t==1?"\u5143":t)+"\u5E74"});return y(T,{padding:1,children:[y(M.Separate,{children:[r(R,{tone:"cloud",enableUnSelected:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,rightIconStyles:{right:"1/3"},options:o,value:e.year,onUpdateValidValue:({value:t})=>{d(a=>x(f({},a),{modifiedType:"update",year:Number(t)}))}}),y(M.Center,{gap:"1/3",children:[r(v.Button.Clear.S,{ssSphere:2,onClick:()=>{let t=e.month-1;d({modifiedType:"update",era:e.era,year:t==0?e.year-1:e.year,month:t==0?12:t,date:1})},children:r(N.ChevronLeft,{})}),r(R,{tone:"cloud",enableUnSelected:!1,override:"force",border:"1.thin",padding:["1/3","2/3"],paddingRight:2,rightIconStyles:{right:"1/3"},options:[{value:1,label:"1\u6708"},{value:2,label:"2\u6708"},{value:3,label:"3\u6708"},{value:4,label:"4\u6708"},{value:5,label:"5\u6708"},{value:6,label:"6\u6708"},{value:7,label:"7\u6708"},{value:8,label:"8\u6708"},{value:9,label:"9\u6708"},{value:10,label:"10\u6708"},{value:11,label:"11\u6708"},{value:12,label:"12\u6708"}],value:e.month,onUpdateValidValue:({value:t})=>{d({modifiedType:"update",era:e.era,year:e.year,month:Number(t),date:1})}}),r(v.Button.Clear.S,{ssSphere:2,onClick:()=>{let t=e.month+1;d({modifiedType:"update",era:e.era,year:t==13?e.year+1:e.year,month:t==13?1:t,date:1})},children:r(N.ChevronRight,{})})]})]}),r(k.DateWareki.MonthCell,f({},i))]},e.era)},MonthCell:i=>{let{val_value:e,set_value:d}=i,o=c.Time([e.year.zeroEmbed(4),e.month.zeroEmbed(2),e.date.zeroEmbed(2)].join("/"));if(!o.validate)return;let t=o.getFirstDayOfTheMonth().weekday,a=o.getLastDayOfTheMonth(),m=[];for(let n=0;n<7;n++)m.push(r(Y.Supplement,{flexCenter:!0,fontColor:n==0?"googleRed":n==6?"googleBlue":"3.blur",children:c.transformer.weekday.shortJP(n)},"legend-"+n));for(let n=0;n<t;n++){let s=c.Time(o).getFirstDayOfTheMonth().addDate(n-t);m.push(r(v.Button.Sub.R,{color:"cloud",border:"1.thin",ssSphere:3,opacity:"middle",onClick:p=>{p.preventDefault(),p.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"lastMonth-"+n))}for(let n=1;n<=a.date;n++){let s=c.Time(o).setDate(n);m.push(r(v.Button.Border.R,{ssSphere:3,onClick:()=>{d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"currentMonth-"+n))}for(let n=0;n<7-a.weekday-1;n++){let s=c.Time(o).addMonth(1).setDate(1).addDate(n);m.push(r(v.Button.Sub.R,{color:"cloud",border:"1.thin",ssSquare:3,opacity:"middle",onClick:p=>{p.preventDefault(),p.stopPropagation(),d({modifiedType:"update",era:e.era,year:s.year,month:s.month,date:s.date})},children:s.date},"nextMonth-"+n))}return r(w,{gridCols:7,gap:"1/4",children:m})}},Variables:{Footer:i=>y(D,{flexWrap:!1,gap:1,flexChilds:"even",freeCSS:{whiteSpace:"nowrap"},children:[y(v.Button.Border.R,{onClick:()=>{i.onValueUpdate("")},tabIndex:-1,flexSizing:"none",padding:["2/3",1],children:[r(N.Times,{})," \u524A\u9664"]}),r(v.Button.Prime.R,{flexSizing:"auto",padding:["2/3",1],onClick:()=>{i.onSubmit&&i.onSubmit(),O.close(i.tipsID)},tabIndex:-1,children:"\u6C7A\u5B9A"})]}),ShiftButtons:i=>y(D,{gap:"1/3",flexWrap:!1,children:[r(v.Button.Clear.R,x(f({className:g("LeftButton"),tabIndex:-1,right:0},k.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(-1)},children:r(N.ChevronLeft,{})})),r(v.Button.Clear.R,x(f({className:g("RightButton"),tabIndex:-1,left:0},k.Variables.ShiftButtonStyles),{onClick:()=>{i.callback(1)},children:r(N.ChevronRight,{})}))]}),ShiftButtonStyles:{flexCenter:!0,padding:0,unitWidth:3,unitHeight:3,borderRadius:"sphere",position:"relative"}}};export{F as Picker,F as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as G,b as s,c as _,d as Y}from"../../../chunk-C5N2D3ZX.js";import{Fragment as be,jsx as T,jsxs as ae}from"react/jsx-runtime";import{useState as W,useEffect as H,useRef as ne}from"react";import S from"@mingoo/jsmin";import{$$fromRoot as le,Config as Q,useStore as P}from"../../../@utils";import oe from"../../../atoms/Box";import se from"../../../atoms/FAI";import Z from"../../Button";import ee from"../../Tooltips";import{faClock as me}from"@fortawesome/free-solid-svg-icons/faClock";import{faCalendarAlt as ue}from"@fortawesome/free-solid-svg-icons/faCalendarAlt";import{Wrapper as pe,BoxWrapper as ce,SubmitForm as de,CommonEffects as fe,DefaultStyles as he}from"../core";import ge from"../Hidden";import ye from"../Select";import ve from"../Parts";import De from"./Picker";const C=" ~ ",Ie={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+C.length,length:4},{type:"month",from:15+C.length,length:2},{type:"date",from:18+C.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+C.length,length:4},{type:"month",from:13+C.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}},U=e=>{let{restrict:n,value:k,era:r}=e,y=S.flatArray(k||""),{defaultValue:c,format:h,ranges:u,sets:t}=Ie[n],o=[],i=n=="clock"?":":"/";for(let a=0;a<y.length;a++)y[a]=String(y[a]).replace(/\D/ig,i);for(let a=0;a<t;a++){let d=y[a]||"";if(!d.match(h))y[a]="",o.push(c);else{let b=c;d.split(/\D/).forEach((w,R)=>{if(R==0&&n=="dateWareki"){let v=Number(w);r!="year"&&(v>=2019?r=="reiwa"?v-=2018:r=="heisei"&&(v=31):v>=1989?r=="heisei"?v-=1988:r=="shouwa"&&(v=64):v>=1926?r=="shouwa"?v-=1925:r=="taisho"&&(v=15):v>=1912?r=="taisho"?v-=1911:r=="meiji"&&(v=45):v>=1868&&(v-=1867)),w=v.zeroEmbed(4)}b=b.replace(new RegExp("------------------".slice(0,w.length)),w)}),o.push(b)}}return{formatValue:o.join(C),dataValue:["dates","months"].includes(n)?y:y[0],ranges:u}};function ke(e){let{states:n}=e,{restrict:k,min:r,max:y,required:c}=n,h=[],u=S.flatArray(e.value),t={empty:!1,escalated:1,filled:!0,correct:!0,prohibited:!1};(()=>{let o=k=="clock"?":":"/";for(let i=0;i<u.length;i++)u[i]=String(u[i]).replace(/\D/ig,o);for(let i=0;i<u.length;i++){let a=u[i],d=u[i-1];a.removeLetters()||(t.empty=!0),i>0&&(t.escalated&=+(a>=d))}t.escalated&&(t.empty||(k.match(/clock/)?u.forEach(i=>{let[a,d]=i.split(/\D+/);!a||!d?t.filled=!1:(Number(a)>23||Number(d)>59)&&(t.correct=!1)}):k.match(/date/)?u.forEach(i=>{let[a,d,b]=i.split(/\D+/);if(!a||!d||!b)t.filled=!1;else{let w=S.Time(i);(!w.validate||i!=w.toFormatYMD())&&(t.correct=!1)}}):k.match(/week/)?u.forEach(i=>{let[a,d]=i.split(/\D+/);if(!a||!d)t.filled=!1;else{let b=S.Time(a+"/01/01").weekday,R=S.Time(a+"/01/0"+(7-b+1)).addWeek(Number(d)-1);a!=String(R.year)&&(t.correct=!1)}}):k.match(/month/)?u.forEach(i=>{let[a,d]=i.split(/\D+/);!a||!d?t.filled=!1:S.Time([a,d,"01"].join("/")).validate||(t.correct=!1)}):k.match(/year/),t.filled&&t.correct&&u.forEach(i=>{{let a=Number(String(i).replace(/\D/ig,""));if(r&&Number(String(r).replace(/\D/ig,""))>a&&(t.prohibited=!0),y){let d=Number(String(y).replace(/\D/ig,""));a>d&&(t.prohibited=!0)}}})))})();{let{empty:o,escalated:i,filled:a,correct:d,prohibited:b}=t;o&&c&&(h=[{type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}]),i||h.push({type:"invalid",label:"\u6642\u7CFB\u5217\u3092\u6B63\u3057\u304F\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),d||h.push({type:"invalid",label:"\u7121\u52B9\u306A\u5024\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u3059"}),a||h.push({type:"invalid",label:"\u6700\u5F8C\u307E\u3067\u5024\u3092\u57CB\u3081\u3066\u304F\u3060\u3055\u3044"}),b&&h.push({type:"invalid",label:ae(be,{children:[T(oe,{children:"\u5165\u529B\u7BC4\u56F2\u304C\u5236\u9650\u3055\u308C\u3066\u3044\u307E\u3059"}),"[",r||"\u4E0B\u9650\u7121\u3057","] ~ [",y||"\u4E0A\u9650\u7121\u3057","]"]})})}return{ok:!h.filter(({type:o})=>o=="invalid").length,notice:h}}const te={picker:{launch:e=>{let n=e.tipsID||S.uuid.gen(),o=e,{onValueUpdate:k,min:r,max:y,era:c,restrict:h,defaultValue:u}=o,t=Y(o,["onValueUpdate","min","max","era","restrict","defaultValue"]);ee.open(_(s({gravityPoint:e.gravityPoint||24,tipsID:n},t),{styles:s({padding:"1/2"},t.styles),parent:t.parent,close_option:s({aroundClick:!0,parentBlur:!1},t.close_option),content:T(De,{restrict:h,min:r,max:y,era:c,defaultValue:u,tipsID:n,onValueUpdate:(i,a)=>{k(i,a)}})}))},remove:e=>{ee.close(e)}}},Te=e=>{let z=e,{tone:n,required:k,restrict:r="clock",componentID:y,era:c,form:h,name:u,min:t,max:o,className:i,enableFormSubmit:a,checkValidationAtFirst:d,onKeyDown:b,onValidate:w,onUpdateValue:R,onUpdateValidValue:v,value:A="",leftIndicator:X,rightIndicator:M,styles:g,freeCSS:l,wrapStyles:j}=z,J=Y(z,["tone","required","restrict","componentID","era","form","name","min","max","className","enableFormSubmit","checkValidationAtFirst","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","styles","freeCSS","wrapStyles"]),[E,D]=W(c),[m,I]=W(_(s({componentID:e.componentID||""},U({restrict:r,value:A,era:E})),{eventType:"init",eventID:S.uuid.gen()})),[p,V]=W({ok:!1,notice:[]}),[O,$]=W({active:!1,index:0,prevIndex:-1});fe({type:"time",states:e,val_status:m,set_status:I,val_validate:p,set_validate:V,DefaultValidation:ke,onUpdateValue:R,onUpdateValidValue:v,ExtraOverrideStates:s({},U({restrict:r,value:A,era:E}))});const K=ne(!1);return H(()=>{if(K.current){I(x=>s(s({},x),U({restrict:r,value:x.dataValue,era:E})));let f=P.get("refreshEra_"+m.componentID);f&&f.refreshEra(E)}else K.current=!0},[E]),P.update({[m.componentID]:{openPicker:()=>{e.disabled||te.picker.launch({parent:"#Picker-"+m.componentID,tipsID:"PickerTips-"+m.componentID,restrict:r,min:t,max:o,defaultValue:m.dataValue,era:E,onValueUpdate:(f,x)=>{I(F=>_(s(s({},F),U({restrict:r,value:f,era:x})),{eventType:"update",eventID:S.uuid.gen()})),D(x)}})},resetEra:f=>{D(f),I(x=>_(s(s({},x),U({restrict:r,value:"",era:E})),{eventType:"update",eventID:S.uuid.gen()}))}}}),H(()=>{let{index:f,active:x}=O;if(x){f=Math.max(f,0),f=Math.min(f,m.ranges.length-1);let{from:F,length:B}=m.ranges[f],L=le("#"+e.id)[0];L&&L.setSelectionRange(F,F+B)}},[O]),ae(ce,{val_status:m,set_status:I,val_validate:p,states:e,children:[T(ge,{name:u,"data-input-type":"time","data-form":h,"data-validation":p.ok,componentID:m.componentID,"data-value":JSON.stringify(["dates","months"].includes(r)?!m.dataValue[0]||!m.dataValue[1]?null:m.dataValue:m.dataValue||null)}),Q.get().isTouchDevice?T(Z.Button.Plain,{className:i,freeCSS:{textAlign:"left"},children:m.formatValue,onClick:f=>{let x=P.get(m.componentID);x&&x.openPicker(),f.stopPropagation()}}):T("input",s({type:"text",inputMode:"numeric","data-input-type":"time","data-form-name":h,value:m.formatValue,className:i,tabIndex:Q.get().isTouchDevice?-1:0,onKeyDown:f=>{xe({restrict:r,event:f,val_era:E,val_status:m,set_status:I,val_focus:O,set_focus:$}),b&&b(f),a&&de(f)},onKeyUp:f=>{f.key=="Tab"&&$(x=>_(s({},x),{active:!0}))},onClick:f=>{let x=f.target.selectionEnd,F=0;m.ranges.forEach((B,L)=>{let{from:q,length:re,region:ie}=B;q<=x&&x<=q+(ie||re)&&(F=L)}),$(B=>_(s({},B),{active:!0,index:F})),f.preventDefault()},onChange:()=>{}},J))]})},xe=e=>{let{val_era:n,restrict:k,event:r,val_status:y,set_status:c,val_focus:h,set_focus:u}=e,{key:t,shiftKey:o,ctrlKey:i,metaKey:a}=r,d=i||a,{selectionStart:b,selectionEnd:w}=r.target,{index:R,prevIndex:v}=h,{ranges:A,formatValue:X}=y,M=A.length-1;if(["Tab","ArrowLeft","ArrowRight"].includes(t)){let g=0;if(t=="Tab"){let l=+!o*2-1;if(g=h.index+l,g<0||g>M)return}else{let l=t=="ArrowLeft"?-1:t=="ArrowRight"?1:0;d||b==0&&w==String(y.formatValue).length?g=l==1?M:0:g=Math.max(0,Math.min(R+l,M))}u(l=>_(s({},l),{index:g,prevIndex:R})),r.preventDefault()}if(["Backspace","ArrowUp","ArrowDown","0","1","2","3","4","5","6","7","8","9"].includes(t)){r.preventDefault();let g=R;g=Math.max(g,0),g=Math.min(g,M);let{type:l,from:j,length:J}=A[g],E=X.slice(j,j+J),D;if(t=="Backspace")D="------".slice(0,J);else if(["ArrowUp","ArrowDown"].includes(t)){let m=t=="ArrowUp"?1:-1;E=E|0,D=E+m;let[I,p,V]=l=="dateWareki"?n=="year"?[0,2999,4]:n=="reiwa"?[1,2999,4]:n=="heisei"?[1,31,4]:n=="shouwa"?[1,64,4]:n=="taisho"?[1,15,4]:n=="meiji"?[1,45,4]:[0,0,0]:l=="minute"?[0,59,2]:l=="hour"?[0,23,2]:l=="date"?[1,31,2]:l=="week"?[1,53,2]:l=="month"?[1,12,2]:l=="year"?[0,2999,4]:[0,0,0];D>p?D=I:D<I&&(D=p),D=Number(D).zeroEmbed(V)}else if(["0","1","2","3","4","5","6","7","8","9"].includes(t)){let m=E|0,I=t,p=`${m}${I}`;if(v!=R&&(m=0,p="0"+I),l=="year"||l=="dateWareki"&&n=="year")Number(p)>1e4?D=I:D=p,(D|0)>1e3&&g++;else if(["hour","minute","date","week","month"].includes(l)||l=="dateWareki"&&n!="year"){let V=l=="dateWareki"?n=="reiwa"?100:n=="heisei"?31:n=="shouwa"?64:n=="taisho"?15:n=="meiji"?45:0:l=="minute"?59:l=="hour"?23:l=="date"?31:l=="week"?53:l=="month"?12:0;D=(p|0)>V?I:p,(Number(I)>Number(String(V)[0])||E=="0000".slice(0,String(V).length)&&(p!="0000".slice(0,String(V).length)||["minute","hour"].includes(l)&&v==R)||(p|0)>=G(10,String(V).length-1))&&g++}l=="year"||l=="dateWareki"?D=(D|0).zeroEmbed(4):D=(D|0).zeroEmbed(2)}{let m=String(X).partReplace(j,String(D)),I=m.split(C).map(p=>p.replace(/(^\D|\D$)/,"").split(/\D+/).join(k=="clock"?":":"/").replace(/(^\D|\D$)/,""));if(k=="dateWareki"){let p=I[0].split(/\D/),[V,O,$]=p;p.length==3&&V&&(I=[[Number(V)-1+Number({year:1,reiwa:2019,heisei:1989,shouwa:1926,taisho:1912,meiji:1868}[n]),O,$].join("/")])}g=Math.max(g,0),g=Math.min(g,M),c(p=>_(s({},p),{dataValue:["dates","months"].includes(k)?I:I[0],formatValue:m,eventType:"update",eventID:S.uuid.gen()})),u(p=>_(s({},p),{index:g,prevIndex:p.index}))}}},N={Origin:e=>{e=s({},e);let[n]=W(e.componentID||S.uuid.gen());if(e.componentID=n,S.is.nullish(e.rightIndicator)){let k=(e.restrict||"").match(/clock/)?me:ue;e.rightIndicator=T(ve.RightIndicator,{styles:{padding:0},children:T(Z.Button.Sub.R,{color:"cloud",styles:{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 r=P.get(e.componentID);r&&r.openPicker()},children:T(se,{icon:k})})})}return T(pe,{componentID:e.componentID,children:Te,states:he.Boxish(e)})},Clock:e=>T(N.Origin,s({restrict:"clock",era:"clock"},e)),Date:e=>T(N.Origin,s({restrict:"date"},e)),Week:e=>T(N.Origin,s({restrict:"week"},e)),Month:e=>T(N.Origin,s({restrict:"month"},e)),Year:e=>T(N.Origin,s({restrict:"year"},e)),DateWareki:e=>{e=s({},e);let[n]=W(e.componentID||S.uuid.gen());e.componentID=n;let{defaultEra:k="wareki"}=e,[r,y]=W((()=>{let c="year";if(k=="wareki"&&(c="reiwa",e.value)){let[h,u,t]=e.value.split(/\D/);if(h&&u&&t){let o=Number(h);o>=2019?(o-=2019,c="reiwa"):o>=1989?(o-=1989,c="heisei"):o>=1926?(o-=1926,c="shouwa"):o>=1912?(o-=1912,c="taisho"):o>=1868&&(o-=1868,c="meiji"),o+=1}}return c})());return H(()=>{P.set({["refreshEra_"+n]:{refreshEra:c=>{y(c)}}})},[]),T(N.Origin,_(s({restrict:"dateWareki",leftIndicator:T(ye,{enableUnSelected:!1,value:r,tone:e.tone,override:"force",styles:{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:c,eventType:h})=>{y(c);let u=P.get(e.componentID);u&&u.resetEra&&u.resetEra(c)}})},e),{era:r}))},Periods:{Date:e=>T(N.Origin,s({restrict:"dates"},e)),Month:e=>T(N.Origin,s({restrict:"months"},e))},fn:te};export{N as Time,N as default};
|
|
1
|
+
import{a as q,b as m,c as _,d as Y}from"../../../chunk-C5N2D3ZX.js";import{Fragment as xe,jsx as I,jsxs as te}from"react/jsx-runtime";import{useState as C,useEffect as H,useRef as ie}from"react";import S from"@mingoo/jsmin";import{$$fromRoot as ne,Config as G,useStore as A}from"../../../@utils";import le from"../../../atoms/Box";import oe from"../../../atoms/FAI";import Q from"../../Button";import Z from"../../Tooltips";import{faClock as se}from"@fortawesome/free-solid-svg-icons/faClock";import{faCalendarAlt as me}from"@fortawesome/free-solid-svg-icons/faCalendarAlt";import{Wrapper as ue,BoxWrapper as pe,SubmitForm as ce,CommonEffects as de,DefaultStyles as fe}from"../core";import he from"../Hidden";import ge from"../Select";import ye from"../Parts";import ve from"./Picker";const P=" ~ ",De={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}},j=e=>{let{restrict:l,value:D,era:i}=e,y=S.flatArray(D||""),{defaultValue:p,format:h,ranges:u,sets:t}=De[l],s=[],n=l=="clock"?":":"/";for(let r=0;r<y.length;r++)y[r]=String(y[r]).replace(/\D/ig,n);for(let r=0;r<t;r++){let c=y[r]||"";if(!c.match(h))y[r]="",s.push(p);else{let x=p;c.split(/\D/).forEach((V,w)=>{if(w==0&&l=="dateWareki"){let v=Number(V);i!="year"&&(v>=2019?i=="reiwa"?v-=2018:i=="heisei"&&(v=31):v>=1989?i=="heisei"?v-=1988:i=="shouwa"&&(v=64):v>=1926?i=="shouwa"?v-=1925:i=="taisho"&&(v=15):v>=1912?i=="taisho"?v-=1911:i=="meiji"&&(v=45):v>=1868&&(v-=1867)),V=v.zeroEmbed(4)}x=x.replace(new RegExp("------------------".slice(0,V.length)),V)}),s.push(x)}}return{formatValue:s.join(P),dataValue:["dates","months"].includes(l)?y:y[0],ranges:u}};function Ie(e){let{states:l}=e,{restrict:D,min:i,max:y,required:p}=l,h=[],u=S.flatArray(e.value),t={empty:!1,escalated:1,filled:!0,correct:!0,prohibited:!1};(()=>{let s=D=="clock"?":":"/";for(let n=0;n<u.length;n++)u[n]=String(u[n]).replace(/\D/ig,s);for(let n=0;n<u.length;n++){let r=u[n],c=u[n-1];r.removeLetters()||(t.empty=!0),n>0&&(t.escalated&=+(r>=c))}t.escalated&&(t.empty||(D.match(/clock/)?u.forEach(n=>{let[r,c]=n.split(/\D+/);!r||!c?t.filled=!1:(Number(r)>23||Number(c)>59)&&(t.correct=!1)}):D.match(/date/)?u.forEach(n=>{let[r,c,x]=n.split(/\D+/);if(!r||!c||!x)t.filled=!1;else{let V=S.Time(n);(!V.validate||n!=V.toFormatYMD())&&(t.correct=!1)}}):D.match(/week/)?u.forEach(n=>{let[r,c]=n.split(/\D+/);if(!r||!c)t.filled=!1;else{let x=S.Time(r+"/01/01").weekday,w=S.Time(r+"/01/0"+(7-x+1)).addWeek(Number(c)-1);r!=String(w.year)&&(t.correct=!1)}}):D.match(/month/)?u.forEach(n=>{let[r,c]=n.split(/\D+/);!r||!c?t.filled=!1:S.Time([r,c,"01"].join("/")).validate||(t.correct=!1)}):D.match(/year/),t.filled&&t.correct&&u.forEach(n=>{{let r=Number(String(n).replace(/\D/ig,""));if(i&&Number(String(i).replace(/\D/ig,""))>r&&(t.prohibited=!0),y){let c=Number(String(y).replace(/\D/ig,""));r>c&&(t.prohibited=!0)}}})))})();{let{empty:s,escalated:n,filled:r,correct:c,prohibited:x}=t;s&&p&&(h=[{type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}]),n||h.push({type:"invalid",label:"\u6642\u7CFB\u5217\u3092\u6B63\u3057\u304F\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),c||h.push({type:"invalid",label:"\u7121\u52B9\u306A\u5024\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u3059"}),r||h.push({type:"invalid",label:"\u6700\u5F8C\u307E\u3067\u5024\u3092\u57CB\u3081\u3066\u304F\u3060\u3055\u3044"}),x&&h.push({type:"invalid",label:te(xe,{children:[I(le,{children:"\u5165\u529B\u7BC4\u56F2\u304C\u5236\u9650\u3055\u308C\u3066\u3044\u307E\u3059"}),"[",i||"\u4E0B\u9650\u7121\u3057","] ~ [",y||"\u4E0A\u9650\u7121\u3057","]"]})})}return{ok:!h.filter(({type:s})=>s=="invalid").length,notice:h}}const ee={picker:{launch:e=>{let l=e.tipsID||S.uuid.gen(),s=e,{onValueUpdate:D,min:i,max:y,era:p,restrict:h,defaultValue:u}=s,t=Y(s,["onValueUpdate","min","max","era","restrict","defaultValue"]);Z.open(_(m({gravityPoint:e.gravityPoint||24,tipsID:l,padding:"1/2"},t),{parent:t.parent,close_option:m({aroundClick:!0,parentBlur:!1},t.close_option),content:I(ve,{restrict:h,min:i,max:y,era:p,defaultValue:u,tipsID:l,onValueUpdate:(n,r)=>{D(n,r)}})}))},remove:e=>{Z.close(e)}}},ke=e=>{let K=e,{tone:l,required:D,restrict:i="clock",componentID:y,era:p,form:h,name:u,min:t,max:s,className:n,enableFormSubmit:r,checkValidationAtFirst:c,onKeyDown:x,onValidate:V,onUpdateValue:w,onUpdateValidValue:v,value:O="",leftIndicator:X,rightIndicator:F,freeCSS:g,wrapStyles:o}=K,$=Y(K,["tone","required","restrict","componentID","era","form","name","min","max","className","enableFormSubmit","checkValidationAtFirst","onKeyDown","onValidate","onUpdateValue","onUpdateValidValue","value","leftIndicator","rightIndicator","freeCSS","wrapStyles"]),[R,M]=C(p),[a,b]=C(_(m({componentID:e.componentID||""},j({restrict:i,value:O,era:R})),{eventType:"init",eventID:S.uuid.gen()})),[k,f]=C({ok:!1,notice:[]}),[E,B]=C({active:!1,index:0,prevIndex:-1});de({type:"time",states:e,val_status:a,set_status:b,val_validate:k,set_validate:f,DefaultValidation:Ie,onUpdateValue:w,onUpdateValidValue:v,ExtraOverrideStates:m({},j({restrict:i,value:O,era:R}))});const J=ie(!1);return H(()=>{if(J.current){b(T=>m(m({},T),j({restrict:i,value:T.dataValue,era:R})));let d=A.get("refreshEra_"+a.componentID);d&&d.refreshEra(R)}else J.current=!0},[R]),A.update({[a.componentID]:{openPicker:()=>{e.disabled||ee.picker.launch({parent:"#Picker-"+a.componentID,tipsID:"PickerTips-"+a.componentID,restrict:i,min:t,max:s,defaultValue:a.dataValue,era:R,onValueUpdate:(d,T)=>{b(W=>_(m(m({},W),j({restrict:i,value:d,era:T})),{eventType:"update",eventID:S.uuid.gen()})),M(T)}})},resetEra:d=>{M(d),b(T=>_(m(m({},T),j({restrict:i,value:"",era:R})),{eventType:"update",eventID:S.uuid.gen()}))}}}),H(()=>{let{index:d,active:T}=E;if(T){d=Math.max(d,0),d=Math.min(d,a.ranges.length-1);let{from:W,length:U}=a.ranges[d],L=ne("#"+e.id)[0];L&&L.setSelectionRange(W,W+U)}},[E]),te(pe,{val_status:a,set_status:b,val_validate:k,states:e,children:[I(he,{name:u,"data-input-type":"time","data-form":h,"data-validation":k.ok,componentID:a.componentID,"data-value":JSON.stringify(["dates","months"].includes(i)?!a.dataValue[0]||!a.dataValue[1]?null:a.dataValue:a.dataValue||null)}),G.get().isTouchDevice?I(Q.Button.Plain,{className:n,freeCSS:{textAlign:"left"},children:a.formatValue,onClick:d=>{let T=A.get(a.componentID);T&&T.openPicker(),d.stopPropagation()}}):I("input",m({type:"text",inputMode:"numeric","data-input-type":"time","data-form-name":h,value:a.formatValue,className:n,tabIndex:G.get().isTouchDevice?-1:0,onKeyDown:d=>{Te({restrict:i,event:d,val_era:R,val_status:a,set_status:b,val_focus:E,set_focus:B}),x&&x(d),r&&ce(d)},onKeyUp:d=>{d.key=="Tab"&&B(T=>_(m({},T),{active:!0}))},onClick:d=>{let T=d.target.selectionEnd,W=0;a.ranges.forEach((U,L)=>{let{from:z,length:ae,region:re}=U;z<=T&&T<=z+(re||ae)&&(W=L)}),B(U=>_(m({},U),{active:!0,index:W})),d.preventDefault()},onChange:()=>{}},$))]})},Te=e=>{let{val_era:l,restrict:D,event:i,val_status:y,set_status:p,val_focus:h,set_focus:u}=e,{key:t,shiftKey:s,ctrlKey:n,metaKey:r}=i,c=n||r,{selectionStart:x,selectionEnd:V}=i.target,{index:w,prevIndex:v}=h,{ranges:O,formatValue:X}=y,F=O.length-1;if(["Tab","ArrowLeft","ArrowRight"].includes(t)){let g=0;if(t=="Tab"){let o=+!s*2-1;if(g=h.index+o,g<0||g>F)return}else{let o=t=="ArrowLeft"?-1:t=="ArrowRight"?1:0;c||x==0&&V==String(y.formatValue).length?g=o==1?F:0:g=Math.max(0,Math.min(w+o,F))}u(o=>_(m({},o),{index:g,prevIndex:w})),i.preventDefault()}if(["Backspace","ArrowUp","ArrowDown","0","1","2","3","4","5","6","7","8","9"].includes(t)){i.preventDefault();let g=w;g=Math.max(g,0),g=Math.min(g,F);let{type:o,from:$,length:R}=O[g],M=X.slice($,$+R),a;if(t=="Backspace")a="------".slice(0,R);else if(["ArrowUp","ArrowDown"].includes(t)){let b=t=="ArrowUp"?1:-1;M=M|0,a=M+b;let[k,f,E]=o=="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]:o=="minute"?[0,59,2]:o=="hour"?[0,23,2]:o=="date"?[1,31,2]:o=="week"?[1,53,2]:o=="month"?[1,12,2]:o=="year"?[0,2999,4]:[0,0,0];a>f?a=k:a<k&&(a=f),a=Number(a).zeroEmbed(E)}else if(["0","1","2","3","4","5","6","7","8","9"].includes(t)){let b=M|0,k=t,f=`${b}${k}`;if(v!=w&&(b=0,f="0"+k),o=="year"||o=="dateWareki"&&l=="year")Number(f)>1e4?a=k:a=f,(a|0)>1e3&&g++;else if(["hour","minute","date","week","month"].includes(o)||o=="dateWareki"&&l!="year"){let E=o=="dateWareki"?l=="reiwa"?100:l=="heisei"?31:l=="shouwa"?64:l=="taisho"?15:l=="meiji"?45:0:o=="minute"?59:o=="hour"?23:o=="date"?31:o=="week"?53:o=="month"?12:0;a=(f|0)>E?k:f,(Number(k)>Number(String(E)[0])||M=="0000".slice(0,String(E).length)&&(f!="0000".slice(0,String(E).length)||["minute","hour"].includes(o)&&v==w)||(f|0)>=q(10,String(E).length-1))&&g++}o=="year"||o=="dateWareki"?a=(a|0).zeroEmbed(4):a=(a|0).zeroEmbed(2)}{let b=String(X).partReplace($,String(a)),k=b.split(P).map(f=>f.replace(/(^\D|\D$)/,"").split(/\D+/).join(D=="clock"?":":"/").replace(/(^\D|\D$)/,""));if(D=="dateWareki"){let f=k[0].split(/\D/),[E,B,J]=f;f.length==3&&E&&(k=[[Number(E)-1+Number({year:1,reiwa:2019,heisei:1989,shouwa:1926,taisho:1912,meiji:1868}[l]),B,J].join("/")])}g=Math.max(g,0),g=Math.min(g,F),p(f=>_(m({},f),{dataValue:["dates","months"].includes(D)?k:k[0],formatValue:b,eventType:"update",eventID:S.uuid.gen()})),u(f=>_(m({},f),{index:g,prevIndex:f.index}))}}},N={Origin:e=>{e=m({},e);let[l]=C(e.componentID||S.uuid.gen());if(e.componentID=l,S.is.nullish(e.rightIndicator)){let D=(e.restrict||"").match(/clock/)?se:me;e.rightIndicator=I(ye.RightIndicator,{padding:0,children:I(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 i=A.get(e.componentID);i&&i.openPicker()},children:I(oe,{icon:D})})})}return I(ue,{componentID:e.componentID,children:ke,states:fe.Boxish(e)})},Clock:e=>I(N.Origin,m({restrict:"clock",era:"clock"},e)),Date:e=>I(N.Origin,m({restrict:"date"},e)),Week:e=>I(N.Origin,m({restrict:"week"},e)),Month:e=>I(N.Origin,m({restrict:"month"},e)),Year:e=>I(N.Origin,m({restrict:"year"},e)),DateWareki:e=>{e=m({},e);let[l]=C(e.componentID||S.uuid.gen());e.componentID=l;let{defaultEra:D="wareki"}=e,[i,y]=C((()=>{let p="year";if(D=="wareki"&&(p="reiwa",e.value)){let[h,u,t]=e.value.split(/\D/);if(h&&u&&t){let s=Number(h);s>=2019?(s-=2019,p="reiwa"):s>=1989?(s-=1989,p="heisei"):s>=1926?(s-=1926,p="shouwa"):s>=1912?(s-=1912,p="taisho"):s>=1868&&(s-=1868,p="meiji"),s+=1}}return p})());return H(()=>{A.set({["refreshEra_"+l]:{refreshEra:p=>{y(p)}}})},[]),I(N.Origin,_(m({restrict:"dateWareki",leftIndicator:I(ge,{enableUnSelected:!1,value:i,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:p,eventType:h})=>{y(p);let u=A.get(e.componentID);u&&u.resetEra&&u.resetEra(p)}})},e),{era:i}))},Periods:{Date:e=>I(N.Origin,m({restrict:"dates"},e)),Month:e=>I(N.Origin,m({restrict:"months"},e))},fn:ee};export{N as Time,N as default};
|
package/dist/fn/Input/core.d.ts
CHANGED
|
@@ -46,10 +46,10 @@ export declare const ValidationCheck: {
|
|
|
46
46
|
};
|
|
47
47
|
export declare const SubmitForm: (event: React.KeyboardEvent) => boolean;
|
|
48
48
|
export declare const DefaultStyles: {
|
|
49
|
-
Input: (type: InputTypes.BoxTone) => TagProperty.
|
|
50
|
-
ListCell: (p: List.Plain) =>
|
|
49
|
+
Input: (type: InputTypes.BoxTone) => TagProperty.States;
|
|
50
|
+
ListCell: (p: List.Plain) => any;
|
|
51
51
|
Boxish: (p: any) => any;
|
|
52
52
|
Indicator: (type: InputTypes.BoxTone) => TagProperty.Properties;
|
|
53
|
-
IndicatorIcon: TagProperty.
|
|
53
|
+
IndicatorIcon: TagProperty.States;
|
|
54
54
|
};
|
|
55
55
|
export {};
|