@starasia/input 6.0.0 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/input.es.js +2 -2
- package/dist/input.umd.js +2 -2
- package/package.json +1 -1
package/dist/input.es.js
CHANGED
|
@@ -11,7 +11,7 @@ const $n = `
|
|
|
11
11
|
|
|
12
12
|
--sa-input-icon-subtle: var(--sa-icon-subtle, #505258);
|
|
13
13
|
--sa-input-icon-subtlest: var(--sa-icon-subtlest, #6b6e76);
|
|
14
|
-
--sa-input-icon-success: var(--sa-icon-success, #
|
|
14
|
+
--sa-input-icon-success: var(--sa-icon-success, #186742);
|
|
15
15
|
--sa-input-icon-disable: var(--sa-icon-disable, #181a198f);
|
|
16
16
|
|
|
17
17
|
--sa-input-border-subtle: var(--sa-border-subtle, #0b120e24);
|
|
@@ -616,7 +616,7 @@ const $n = `
|
|
|
616
616
|
`, z = (n) => n === "lg" || n === "xl" ? 18 : n === "xs" ? 14 : 16, J = {
|
|
617
617
|
default: "var(--sa-color-gray-800, #505258)",
|
|
618
618
|
error: "var(--sa-text-error, #a4133c)",
|
|
619
|
-
success: "var(--sa-text-success, #
|
|
619
|
+
success: "var(--sa-text-success, #186742)",
|
|
620
620
|
disable: "var(--sa-icon-disable, #181a198f)"
|
|
621
621
|
}, xn = (n, e) => e ? J.disable : J[n] ?? J.default;
|
|
622
622
|
function Dn(n) {
|
package/dist/input.umd.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
--sa-input-icon-subtle: var(--sa-icon-subtle, #505258);
|
|
11
11
|
--sa-input-icon-subtlest: var(--sa-icon-subtlest, #6b6e76);
|
|
12
|
-
--sa-input-icon-success: var(--sa-icon-success, #
|
|
12
|
+
--sa-input-icon-success: var(--sa-icon-success, #186742);
|
|
13
13
|
--sa-input-icon-disable: var(--sa-icon-disable, #181a198f);
|
|
14
14
|
|
|
15
15
|
--sa-input-border-subtle: var(--sa-border-subtle, #0b120e24);
|
|
@@ -611,7 +611,7 @@
|
|
|
611
611
|
.sa-tf-label-inside.sa-tf-floating.sa-tf-size-xl .sa-tf-box {
|
|
612
612
|
min-height: 80px;
|
|
613
613
|
}
|
|
614
|
-
`,y=t=>t==="lg"||t==="xl"?18:t==="xs"?14:16,j={default:"var(--sa-color-gray-800, #505258)",error:"var(--sa-text-error, #a4133c)",success:"var(--sa-text-success, #
|
|
614
|
+
`,y=t=>t==="lg"||t==="xl"?18:t==="xs"?14:16,j={default:"var(--sa-color-gray-800, #505258)",error:"var(--sa-text-error, #a4133c)",success:"var(--sa-text-success, #186742)",disable:"var(--sa-icon-disable, #181a198f)"},Q=(t,e)=>e?j.disable:j[t]??j.default;function hn(t){return Number(t.replace(/\./g,""))}function F(t){let e=t.replace(/[^\d]/g,"");return e=e.replace(/^0+(?=\d)/,""),e.replace(/\B(?=(\d{3})+(?!\d))/g,".")}function vn(t,e){if(e<=0)return 0;let r=0;for(let l=0;l<t.length;l++)if(/\d/.test(t[l])&&(r+=1,r===e))return l+1;return t.length}const mn=o.forwardRef(({options:t,value:e,setValue:r,isComponentVisible:l,onOptionChange:d},f)=>{const[c,T]=o.useState([]),u=o.useRef(null),p=()=>{if(f!=null&&f.current&&u.current){const h=window.innerHeight,x=f==null?void 0:f.current.getBoundingClientRect(),m=u.current.getBoundingClientRect(),w=x.bottom+m.height;u.current.style.left=`${x.left}px`,u.current.style.width=`${x.width}px`,w>=h-10?u.current.style.top=`${x.top-m.height-5}px`:u.current.style.top=`${x.top+x.height}px`}};return o.useEffect(()=>(window.addEventListener("scroll",p),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p),window.removeEventListener("resize",p)}),[f,u]),o.useEffect(()=>{p()},[l]),o.useEffect(()=>{T((t==null?void 0:t.filter(h=>h.toLowerCase().startsWith(e.toLowerCase())))||[])},[e,t]),n.jsx("div",{ref:u,style:{position:"fixed",padding:"8px",boxSizing:"border-box",boxShadow:"0px 8px 12px 0px var(--sa-color-black-alpha-a8, #00000014)",borderRadius:"8px",background:"white",overflow:"auto",zIndex:5e4},children:c==null?void 0:c.map(h=>wn(h,e,r,d))})}),wn=(t,e,r,l)=>{const d=t.toLowerCase().indexOf(e.toLowerCase());return n.jsxs("p",{style:{fontFamily:'var(--sa-font-family, "Inter", sans-serif)',color:"var(--sa-color-gray-400, #b7b9be)",fontWeight:500,padding:"8px 14px",cursor:"pointer"},onClick:()=>{r(t),l&&l(t)},children:[t.slice(0,d),n.jsx("span",{style:{color:"var(--sa-text-primary, #292a2e)"},children:t.slice(d,d+e.length)}),t.slice(d+e.length)]})};function kn(t){const[e,r]=o.useState(t),l=o.useRef(null),d=f=>{l.current&&!l.current.contains(f.target)&&r(!1)};return o.useEffect(()=>(document.addEventListener("click",d,!0),()=>{document.removeEventListener("click",d,!0)}),[]),{ref:l,isComponentVisible:e,setIsComponentVisible:r}}const Z="sa-input-styles";(t=>{if(!(typeof document>"u")&&!document.getElementById(Z)){const e=document.createElement("style");e.id=Z,e.textContent=t,document.head.appendChild(e)}})(gn);const yn=t=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[n.jsx("circle",{cx:"8",cy:"8",r:"6.5",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M5.2 8.2l1.8 1.8 3.8-4.2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),zn=t=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[n.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"currentColor",opacity:"0.2"}),n.jsx("path",{d:"M5.5 5.5l5 5M10.5 5.5l-5 5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})]}),R=o.forwardRef((t,e)=>{const{size:r="sm",variant:l="outline",status:d="default",label:f,labelPosition:c="outside-top",required:T,optional:u,description:p,helperText:h,errorText:x,leftIcon:m,rightIcon:w,leftAddons:S,rightAddons:B,onClickLeftIcon:sn,onClickRightIcon:O,fullWidth:In=!0,highlightPlaceholder:V,currency:E,options:L,onOptionChange:Y,clearable:Sn=!0,onClear:A,...a}=t,M=a.value!==void 0,[W,z]=o.useState(()=>{const s=a.value!==void 0?String(a.value??""):String(a.defaultValue??"");return E?F(s):s}),[en,an]=o.useState(!1),[Bn,rn]=o.useState(""),C=o.useRef(null),N=o.useRef(null);o.useImperativeHandle(e,()=>N.current);const on=o.useRef(a.id??`sa-input-${Math.random().toString(36).slice(2,9)}`),{isComponentVisible:ln,ref:_,setIsComponentVisible:En}=kn(!1);o.useLayoutEffect(()=>{if(!M)return;const s=a.value===void 0||a.value===null?"":String(a.value),i=E?F(s):s;z(g=>g===i?g:i)},[a.value,E,M]),o.useLayoutEffect(()=>{if(C.current===null)return;const s=N.current,i=C.current;if(C.current=null,!!s)try{s.setSelectionRange(i,i)}catch{}},[W]);const I=W,$=I!==""&&I!==void 0,k=d==="disable"||a.disabled,q=k?"disable":d,H=c==="inside",Ln=H&&($||en),K=["sa-tf",`sa-tf-variant-${l}`,`sa-tf-size-${r}`,`sa-tf-status-${q}`,`sa-tf-label-${c}`,en?"sa-tf-focused":"",k?"sa-tf-disabled":"",Ln?"sa-tf-floating":"",f?"":"sa-tf-no-label",In?"sa-tf-fullwidth":""].filter(Boolean).join(" "),$n=()=>{var s;return(s=N.current)==null?void 0:s.focus()},Dn=s=>{var bn,xn;if(!E){const D=s.target.selectionStart;D!==null&&(C.current=D),z(s.target.value),(bn=a.onChange)==null||bn.call(a,s);return}const i=s.target.value;let g=i,v=s.target.selectionStart??i.length;if(Bn==="Backspace"){const D=W.replace(/\D/g,""),Vn=i.replace(/\D/g,"");D.length===Vn.length&&v>0&&(g=i.slice(0,v-1)+i.slice(v),v-=1)}const J=F(g),Tn=g.slice(0,v).replace(/\D/g,"").length,On=vn(J,Tn);C.current=On,z(J),(xn=a.onChange)==null||xn.call(a,{...s,target:{...s.target,value:String(hn(J)),name:s.target.name}}),rn("")},P=s=>f?n.jsxs("div",{className:s,children:[n.jsx("label",{htmlFor:on.current,style:{cursor:k?"not-allowed":"pointer"},children:f}),u?n.jsx("span",{className:"sa-tf-optional",children:"Optional"}):null,T?n.jsx("span",{className:"sa-tf-required","aria-hidden":"true",children:"*"}):null]}):null,U=n.jsxs(n.Fragment,{children:[h?n.jsx("p",{className:"sa-tf-helper",children:h}):null,x&&d==="error"?n.jsx("p",{className:"sa-tf-error",children:x}):null]}),X=(s,i)=>n.jsx("span",{className:`sa-tf-icon${i?" sa-tf-icon-clickable":""}`,onClick:i,children:o.cloneElement(s,{width:y(r),height:y(r),color:Q(q,k),style:{color:Q(q,k)}})}),dn=()=>{var i;return w==null?null:!o.isValidElement(w)||((i=w.type)==null?void 0:i.__saRaw)===!0?n.jsx("span",{className:`sa-tf-icon${O?" sa-tf-icon-clickable":""}`,onClick:O,children:w}):X(w,O)},fn=d==="success"?n.jsx("span",{className:"sa-tf-icon sa-tf-success-mark","aria-hidden":"true",children:n.jsx(yn,{width:y(r),height:y(r)})}):null,jn=s=>{var g;s.stopPropagation(),M||z("");const i={target:{value:"",name:a.name},currentTarget:{value:"",name:a.name}};(g=a.onChange)==null||g.call(a,i),A==null||A(),C.current=0,requestAnimationFrame(()=>{var v;return(v=N.current)==null?void 0:v.focus()})},cn=Sn&&!k?n.jsx("button",{type:"button",className:`sa-tf-icon sa-tf-clear${$?"":" sa-tf-clear-hidden"}`,"aria-label":"Clear input","aria-hidden":!$,tabIndex:-1,onClick:jn,onMouseDown:s=>s.preventDefault(),children:n.jsx(zn,{width:y(r),height:y(r)})}):null,Fn=!$&&!!a.placeholder&&!!V,un=n.jsxs("div",{className:"sa-tf-field-wrap",children:[n.jsx("input",{...a,id:on.current,ref:N,className:"sa-tf-input",disabled:k,placeholder:V?"":a.placeholder,value:I,onFocus:s=>{var i;an(!0),En(!0),(i=a.onFocus)==null||i.call(a,s)},onBlur:s=>{var i;an(!1),(i=a.onBlur)==null||i.call(a,s)},onKeyDown:s=>{var i;s.key==="Backspace"&&rn(s.key),(i=a.onKeyDown)==null||i.call(a,s)},onChange:Dn}),Fn?Cn(a.placeholder,V):null]}),pn=I&&ln&&(L!=null&&L.length)?n.jsx(mn,{options:L,value:I,setValue:z,ref:_,isComponentVisible:ln,onOptionChange:s=>{Y==null||Y(s),z(s)}}):null,G=H?n.jsxs("div",{className:"sa-tf-box",ref:_,onClick:$n,children:[S?n.jsx("div",{className:"sa-tf-addon sa-tf-addon-left",children:S}):null,n.jsxs("div",{className:"sa-tf-box-content",children:[m?X(m,sn):null,n.jsxs("div",{className:"sa-tf-inside-stack",children:[P("sa-tf-inside-label-row"),n.jsx("div",{className:"sa-tf-inside-row",children:un})]}),cn,fn,dn()]}),B?n.jsx("div",{className:"sa-tf-addon sa-tf-addon-right",children:B}):null,pn]}):n.jsxs("div",{className:"sa-tf-box",ref:_,children:[S?n.jsx("div",{className:"sa-tf-addon sa-tf-addon-left",children:S}):null,n.jsxs("div",{className:"sa-tf-box-content",children:[m?X(m,sn):null,un,cn,fn,dn()]}),B?n.jsx("div",{className:"sa-tf-addon sa-tf-addon-right",children:B}):null,pn]});return c==="outside-left"?n.jsxs("div",{className:K,children:[n.jsxs("div",{className:"sa-tf-label-col",children:[P("sa-tf-label"),p?n.jsx("p",{className:"sa-tf-desc-top",children:p}):null]}),n.jsxs("div",{className:"sa-tf-input-col",children:[G,U]})]}):H?n.jsxs("div",{className:K,children:[G,U]}):n.jsxs("div",{className:K,children:[P("sa-tf-label"),p?n.jsx("p",{className:"sa-tf-desc-top",children:p}):null,G,U]})}),Cn=(t,e)=>{if(!t)return null;if(!e)return n.jsx("p",{className:"sa-tf-placeholder",children:t});const r=t.toLowerCase().indexOf(e.toLowerCase());return r===-1?n.jsx("p",{className:"sa-tf-placeholder",children:t}):n.jsxs("p",{className:"sa-tf-placeholder",children:[t.slice(0,r),n.jsx("span",{className:"sa-tf-placeholder-highlight",children:t.slice(r,r+e.length)}),t.slice(r+e.length)]})};R.displayName="Input";const Nn=`.sa-kbd {
|
|
615
615
|
display: inline-flex;
|
|
616
616
|
align-items: center;
|
|
617
617
|
gap: var(--sa-spacing-4, 4px);
|