@clicktap/ui 0.12.18 → 0.13.0

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.
@@ -0,0 +1 @@
1
+ import j,{useRef as _,useState as ie,useEffect as H,useMemo as Ie,useLayoutEffect as xe}from"react";function Ae(e,t){var r={};for(var u in e)Object.prototype.hasOwnProperty.call(e,u)&&t.indexOf(u)<0&&(r[u]=e[u]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,u=Object.getOwnPropertySymbols(e);i<u.length;i++)t.indexOf(u[i])<0&&Object.prototype.propertyIsEnumerable.call(e,u[i])&&(r[u[i]]=e[u[i]]);return r}var K;(function(e){e.event="event",e.props="prop"})(K||(K={}));function R(){}function be(e){var t,r=void 0;return function(){for(var u=[],i=arguments.length;i--;)u[i]=arguments[i];return t&&u.length===t.length&&u.every(function(s,m){return s===t[m]})||(t=u,r=e.apply(void 0,u)),r}}function Q(e){return!!(e||"").match(/\d/)}function X(e){return e==null}function we(e){return typeof e=="number"&&isNaN(e)}function Te(e){return X(e)||we(e)||typeof e=="number"&&!isFinite(e)}function Ee(e){var t=_(e);t.current=e;var r=_(function(){for(var u=[],i=arguments.length;i--;)u[i]=arguments[i];return t.current.apply(t,u)});return r.current}function re(e,t){return Array(t+1).join(e)}function Me(e){var t=e+"",r=t[0]==="-"?"-":"";r&&(t=t.substring(1));var u=t.split(/[eE]/g),i=u[0],s=u[1];if(s=Number(s),!s)return r+i;i=i.replace(".","");var m=1+s,y=i.length;return m<0?i="0."+re("0",Math.abs(m))+i:m>=y?i=i+re("0",m-y):i=(i.substring(0,m)||"0")+"."+i.substring(m),r+i}function ae(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var r=e.createTextRange();return r.move("character",t),r.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var Oe=be(function(e,t){for(var r=0,u=0,i=e.length,s=t.length;e[r]===t[r]&&r<i;)r++;for(;e[i-1-u]===t[s-1-u]&&s-u>r&&i-u>r;)u++;return{from:{start:r,end:i-u},to:{start:r,end:s-u}}}),Be=function(e,t){var r=Math.min(e.selectionStart,t);return{from:{start:r,end:e.selectionEnd},to:{start:r,end:t}}};function Ne(e,t,r){return Math.min(Math.max(e,t),r)}function J(e){return Math.max(e.selectionStart,e.selectionEnd)}function Re(){return typeof navigator<"u"&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function _e(e){var t=e.currentValue,r=e.formattedValue,u=e.currentValueIndex,i=e.formattedValueIndex;return t[u]===r[i]}function Fe(e,t,r,u,i,s,m){m===void 0&&(m=_e);var y=i.findIndex(function(P){return P}),S=e.slice(0,y);!t&&!r.startsWith(S)&&(t=S,r=S+r,u=u+S.length);for(var I=r.length,O=e.length,T={},h=new Array(I),V=0;V<I;V++){h[V]=-1;for(var d=0,x=O;d<x;d++){var C=m({currentValue:r,lastValue:t,formattedValue:e,currentValueIndex:V,formattedValueIndex:d});if(C&&T[d]!==!0){h[V]=d,T[d]=!0;break}}}for(var v=u;v<I&&(h[v]===-1||!s(r[v]));)v++;var A=v===I||h[v]===-1?O:h[v];for(v=u-1;v>0&&h[v]===-1;)v--;var b=v===-1||h[v]===-1?0:h[v]+1;return b>A?A:u-b<A-u?b:A}function ue(e,t,r,u){var i=e.length;if(t=Ne(t,0,i),u==="left"){for(;t>=0&&!r[t];)t--;t===-1&&(t=r.indexOf(!0))}else{for(;t<=i&&!r[t];)t++;t>i&&(t=r.lastIndexOf(!0))}return t===-1&&(t=i),t}function Le(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),r=0,u=t.length;r<u;r++)t[r]=!!(Q(e[r])||Q(e[r-1]));return t}function je(e,t,r,u,i,s){s===void 0&&(s=R);var m=Ee(function(d,x){var C,v;return Te(d)?(v="",C=""):typeof d=="number"||x?(v=typeof d=="number"?Me(d):d,C=u(v)):(v=i(d,void 0),C=u(v)),{formattedValue:C,numAsString:v}}),y=ie(function(){return m(X(e)?t:e,r)}),S=y[0],I=y[1],O=function(d,x){d.formattedValue!==S.formattedValue&&I({formattedValue:d.formattedValue,numAsString:d.value}),s(d,x)},T=e,h=r;X(e)&&(T=S.numAsString,h=!0);var V=m(T,h);return Ie(function(){I(V)},[V.formattedValue]),[S,O]}function De(e){return e.replace(/[^0-9]/g,"")}function ke(e){return e}function Ke(e){var t=e.type;t===void 0&&(t="text");var r=e.displayType;r===void 0&&(r="input");var u=e.customInput,i=e.renderText,s=e.getInputRef,m=e.format;m===void 0&&(m=ke);var y=e.removeFormatting;y===void 0&&(y=De);var S=e.defaultValue,I=e.valueIsNumericString,O=e.onValueChange,T=e.isAllowed,h=e.onChange;h===void 0&&(h=R);var V=e.onKeyDown;V===void 0&&(V=R);var d=e.onMouseUp;d===void 0&&(d=R);var x=e.onFocus;x===void 0&&(x=R);var C=e.onBlur;C===void 0&&(C=R);var v=e.value,A=e.getCaretBoundary;A===void 0&&(A=Le);var b=e.isValidInputCharacter;b===void 0&&(b=Q);var P=e.isCharacterSame,q=Ae(e,["type","displayType","customInput","renderText","getInputRef","format","removeFormatting","defaultValue","valueIsNumericString","onValueChange","isAllowed","onChange","onKeyDown","onMouseUp","onFocus","onBlur","value","getCaretBoundary","isValidInputCharacter","isCharacterSame"]),Y=je(v,S,!!I,m,y,O),Z=Y[0],g=Z.formattedValue,D=Z.numAsString,oe=Y[1],k=_(),U=_({formattedValue:g,numAsString:D}),ee=function(n,a){U.current={formattedValue:n.formattedValue,numAsString:n.value},oe(n,a)},te=ie(!1),fe=te[0],le=te[1],F=_(null),B=_({setCaretTimeout:null,focusTimeout:null});H(function(){return le(!0),function(){clearTimeout(B.current.setCaretTimeout),clearTimeout(B.current.focusTimeout)}},[]);var ce=m,z=function(n,a){var o=parseFloat(a);return{formattedValue:n,value:a,floatValue:isNaN(o)?void 0:o}},N=function(n,a,o){n.selectionStart===0&&n.selectionEnd===n.value.length||(ae(n,a),B.current.setCaretTimeout=setTimeout(function(){n.value===o&&n.selectionStart!==a&&ae(n,a)},0))},L=function(n,a,o){return ue(n,a,A(n),o)},W=function(n,a,o){var l=A(a),p=Fe(a,g,n,o,l,b,P);return p=ue(a,p,l),p},ve=function(n){var a=n.formattedValue;a===void 0&&(a="");var o=n.input,l=n.source,p=n.event,c=n.numAsString,f;if(o){var w=n.inputValue||o.value,E=J(o);o.value=a,f=W(w,a,E),f!==void 0&&N(o,f,a)}a!==g&&ee(z(a,c),{event:p,source:l})};H(function(){var n=U.current,a=n.formattedValue,o=n.numAsString;(g!==a||D!==o)&&ee(z(g,D),{event:void 0,source:K.props})},[g,D]);var de=F.current?J(F.current):void 0,se=typeof window<"u"?xe:H;se(function(){var n=F.current;if(g!==U.current.formattedValue&&n){var a=W(U.current.formattedValue,g,de);n.value=g,N(n,a,g)}},[g]);var me=function(n,a,o){var l=a.target,p=k.current?Be(k.current,l.selectionEnd):Oe(g,n),c=Object.assign(Object.assign({},p),{lastValue:g}),f=y(n,c),w=ce(f);if(f=y(w,void 0),T&&!T(z(w,f))){var E=a.target,M=J(E),G=W(n,g,M);return E.value=g,N(E,G,g),!1}return ve({formattedValue:w,numAsString:f,inputValue:n,event:a,source:o,input:a.target}),!0},$=function(n,a){a===void 0&&(a=0);var o=n.selectionStart,l=n.selectionEnd;k.current={selectionStart:o,selectionEnd:l+a}},ge=function(n){var a=n.target,o=a.value,l=me(o,n,K.event);l&&h(n),k.current=void 0},he=function(n){var a=n.target,o=n.key,l=a.selectionStart,p=a.selectionEnd,c=a.value;c===void 0&&(c="");var f;o==="ArrowLeft"||o==="Backspace"?f=Math.max(l-1,0):o==="ArrowRight"?f=Math.min(l+1,c.length):o==="Delete"&&(f=l);var w=0;o==="Delete"&&l===p&&(w=1);var E=o==="ArrowLeft"||o==="ArrowRight";if(f===void 0||l!==p&&!E){V(n),$(a,w);return}var M=f;if(E){var G=o==="ArrowLeft"?"left":"right";M=L(c,f,G),M!==f&&n.preventDefault()}else o==="Delete"&&!b(c[f])?M=L(c,f,"right"):o==="Backspace"&&!b(c[f])&&(M=L(c,f,"left"));M!==f&&N(a,M,c),V(n),$(a,w)},pe=function(n){var a=n.target,o=function(){var l=a.selectionStart,p=a.selectionEnd,c=a.value;if(c===void 0&&(c=""),l===p){var f=L(c,l);f!==l&&N(a,f,c)}};o(),requestAnimationFrame(function(){o()}),d(n),$(a)},ye=function(n){n.persist&&n.persist();var a=n.target,o=n.currentTarget;F.current=a,B.current.focusTimeout=setTimeout(function(){var l=a.selectionStart,p=a.selectionEnd,c=a.value;c===void 0&&(c="");var f=L(c,l);f!==l&&!(l===0&&p===c.length)&&N(a,f,c),x(Object.assign(Object.assign({},n),{currentTarget:o}))},0)},Ve=function(n){F.current=null,clearTimeout(B.current.focusTimeout),clearTimeout(B.current.setCaretTimeout),C(n)},Se=fe&&Re()?"numeric":void 0,ne=Object.assign({inputMode:Se},q,{type:t,value:g,onChange:ge,onKeyDown:he,onMouseUp:pe,onFocus:ye,onBlur:Ve});if(r==="text")return i?j.createElement(j.Fragment,null,i(g,q)||null):j.createElement("span",Object.assign({},q,{ref:s}),g);if(u){var Ce=u;return j.createElement(Ce,Object.assign({},ne,{ref:s}))}return j.createElement("input",Object.assign({},ne,{ref:s}))}export{Ke as N};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{AvatarGroup as m}from"@nextui-org/avatar";import{c as n}from"../../../assets/cn-CytzSlOG.js";function f({children:a,isGrid:r,renderCount:o,className:t}){return e(m,{isGrid:r,max:0,renderCount:o??void 0,className:n(r?"inline-grid":"flex",r?"gap-3":"gap-0","grid-cols-4","items-center",t),children:a})}export{f as AvatarGroup,f as default};
1
+ import{jsx as t}from"react/jsx-runtime";import{AvatarGroup as n}from"@nextui-org/avatar";import{c as m}from"../../../assets/cn-CytzSlOG.js";function c({children:a,isGrid:r,renderCount:e,className:o}){return t(n,{isGrid:r,max:0,renderCount:e??void 0,className:m(r?"inline-grid":"flex",r?"gap-3":"gap-0","grid-cols-4","items-center",o),children:a})}export{c as AvatarGroup,c as default};
@@ -1 +1 @@
1
- import{jsx as p}from"react/jsx-runtime";import{Provider as P}from"react-aria-components";import a,{useState as w,useRef as d,useEffect as x,useCallback as C,useMemo as E,useContext as N,createContext as k,useId as R}from"react";import{a as S,c as I}from"../../assets/cn-CytzSlOG.js";function M(t,n,r){let[f,e]=w(t||n),c=d(t!==void 0),o=t!==void 0;x(()=>{let l=c.current;l!==o&&console.warn(`WARN: A component changed from ${l?"controlled":"uncontrolled"} to ${o?"controlled":"uncontrolled"}.`),c.current=o},[o]);let s=o?t:f,y=C((l,...$)=>{let m=(u,...i)=>{r&&(Object.is(s,u)||r(u,...i)),o||(s=u)};typeof l=="function"?(console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320"),e((i,...O)=>{let h=l(o?s:i,...O);return m(h,...$),o?i:h})):(o||e(l),m(l,...$))},[o,s,r]);return[s,y]}const V=typeof document<"u"?a.useLayoutEffect:()=>{};let g=new Map;function j(t,n){if(t===n)return t;let r=g.get(t);if(r)return r.forEach(e=>e(n)),n;let f=g.get(n);return f?(f.forEach(e=>e(t)),t):n}function A(...t){return(...n)=>{for(let r of t)typeof r=="function"&&r(...n)}}function F(...t){let n={...t[0]};for(let r=1;r<t.length;r++){let f=t[r];for(let e in f){let c=n[e],o=f[e];typeof c=="function"&&typeof o=="function"&&e[0]==="o"&&e[1]==="n"&&e.charCodeAt(2)>=65&&e.charCodeAt(2)<=90?n[e]=A(c,o):(e==="className"||e==="UNSAFE_className")&&typeof c=="string"&&typeof o=="string"?n[e]=S(c,o):e==="id"&&c&&o?n.id=j(c,o):n[e]=o!==void 0?o:c}}return n}function T(t){const n=d(null);return E(()=>({get current(){return n.current},set current(r){n.current=r,typeof t=="function"?t(r):t&&(t.current=r)}}),[t])}function U(t,n){V(()=>{if(t&&t.ref&&n)return t.ref.current=n.current,()=>{t.ref&&(t.ref.current=null)}})}const b=a.createContext({register:()=>{}});b.displayName="PressResponderContext";const W=a.forwardRef(({children:t,...n},r)=>{let f=d(!1),e=N(b);r=T(r||(e==null?void 0:e.ref));let c=F(e||{},{...n,ref:r,register(){f.current=!0,e&&e.register()}});return U(e,r),x(()=>{f.current||(console.warn("A PressResponder was rendered without a pressable child. Either call the usePress hook, or wrap your DOM node with <Pressable> component."),f.current=!0)},[]),a.createElement(b.Provider,{value:c},t)}),D=k({});function z({children:t,className:n,...r}){const f=R(),[e,c]=M(r.isOpen,r.defaultOpen||!1,r.onOpenChange),o=d(null),s=C(()=>{c(!e)},[c,e]);return p(P,{values:[[D,{isOpen:e,id:f,defaultOpen:r.defaultOpen||!1}]],children:p(W,{ref:o,isPressed:e,onPress:s,"aria-expanded":e,"aria-controls":f,children:p("div",{className:I("w-full",n),children:t})})})}export{z as CollapsibleTrigger,D as CollapsibleTriggerStateContext,z as default};
1
+ import{jsx as p}from"react/jsx-runtime";import{Provider as P}from"react-aria-components";import a,{useState as w,useRef as d,useEffect as x,useCallback as C,useMemo as E,useContext as N,createContext as k,useId as R}from"react";import{a as S,c as I}from"../../assets/cn-CytzSlOG.js";function M(t,r,n){let[f,e]=w(t||r),c=d(t!==void 0),o=t!==void 0;x(()=>{let l=c.current;l!==o&&console.warn(`WARN: A component changed from ${l?"controlled":"uncontrolled"} to ${o?"controlled":"uncontrolled"}.`),c.current=o},[o]);let s=o?t:f,y=C((l,...$)=>{let m=(u,...i)=>{n&&(Object.is(s,u)||n(u,...i)),o||(s=u)};typeof l=="function"?(console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320"),e((i,...O)=>{let h=l(o?s:i,...O);return m(h,...$),o?i:h})):(o||e(l),m(l,...$))},[o,s,n]);return[s,y]}const V=typeof document<"u"?a.useLayoutEffect:()=>{};let g=new Map;function j(t,r){if(t===r)return t;let n=g.get(t);if(n)return n.forEach(e=>e(r)),r;let f=g.get(r);return f?(f.forEach(e=>e(t)),t):r}function A(...t){return(...r)=>{for(let n of t)typeof n=="function"&&n(...r)}}function F(...t){let r={...t[0]};for(let n=1;n<t.length;n++){let f=t[n];for(let e in f){let c=r[e],o=f[e];typeof c=="function"&&typeof o=="function"&&e[0]==="o"&&e[1]==="n"&&e.charCodeAt(2)>=65&&e.charCodeAt(2)<=90?r[e]=A(c,o):(e==="className"||e==="UNSAFE_className")&&typeof c=="string"&&typeof o=="string"?r[e]=S(c,o):e==="id"&&c&&o?r.id=j(c,o):r[e]=o!==void 0?o:c}}return r}function T(t){const r=d(null);return E(()=>({get current(){return r.current},set current(n){r.current=n,typeof t=="function"?t(n):t&&(t.current=n)}}),[t])}function U(t,r){V(()=>{if(t&&t.ref&&r)return t.ref.current=r.current,()=>{t.ref&&(t.ref.current=null)}})}const b=a.createContext({register:()=>{}});b.displayName="PressResponderContext";const W=a.forwardRef(({children:t,...r},n)=>{let f=d(!1),e=N(b);n=T(n||(e==null?void 0:e.ref));let c=F(e||{},{...r,ref:n,register(){f.current=!0,e&&e.register()}});return U(e,n),x(()=>{f.current||(console.warn("A PressResponder was rendered without a pressable child. Either call the usePress hook, or wrap your DOM node with <Pressable> component."),f.current=!0)},[]),a.createElement(b.Provider,{value:c},t)}),D=k({});function z({children:t,className:r,...n}){const f=R(),[e,c]=M(n.isOpen,n.defaultOpen||!1,n.onOpenChange),o=d(null),s=C(()=>{c(!e)},[c,e]);return p(P,{values:[[D,{isOpen:e,id:f,defaultOpen:n.defaultOpen||!1}]],children:p(W,{ref:o,isPressed:e,onPress:s,"aria-expanded":e,"aria-controls":f,children:p("div",{className:I("w-full",r),children:t})})})}export{z as CollapsibleTrigger,D as CollapsibleTriggerStateContext,z as default};
@@ -1 +1 @@
1
- import{jsxs as V,jsx as i}from"react/jsx-runtime";import{N as I}from"../../assets/react-number-format.es-CQi9xzIr.js";import{TextField as v,Label as s,Text as w,FieldError as C,Input as E}from"react-aria-components";import{useState as F,useEffect as $}from"react";import{c as o}from"../../assets/cn-CytzSlOG.js";function j({className:d,...n}){return i(E,{className:o("border-solid border border-slate-300 rounded-md","text-sm text-slate-900 placeholder-slate-400","h-10 px-2 py-0 m-0 w-full","bg-white","transition-all duration-200 ease-in-out","hover:border-slate-400","focus:outline-2 focus:outline focus:outline-slate-200 focus:border-slate-400","disabled:border-slate-200 disabled:bg-slate-100","invalid:border-red-500 invalid:bg-red-100 invalid:text-red-600","invalid:hover:border-red-600 invalid:focus:border-red-600 invalid:focus:outline-red-200",d),...n})}function S({label:d,description:n,errorMessage:b,placeholder:x,value:l,className:a,classNames:e,onChange:u,...p}){const[h,f]=F(l||"");$(()=>{f(l||"")},[l]);const m=r=>{if(r==="")return"";let t=r.substring(0,2);const g=r.substring(2,4);return t.length===1&&Number(t[0])>1?t=`0${t[0]}`:t.length===2&&(Number(t)===0?t="01":Number(t)>12&&(t="12")),`${t}/${g}`},c=r=>{f(r.formattedValue),u&&u(r.formattedValue)};return V(v,{className:o("flex flex-col w-full text-slate-900",a),...p,children:[i(s,{className:o("flex text-slate-500 text-sm",e==null?void 0:e.label),children:d}),i(I,{format:m,customInput:j,className:o(e==null?void 0:e.input),placeholder:x,value:h,onValueChange:c}),n&&i(w,{className:o("flex text-slate-500 text-sm",e==null?void 0:e.description),slot:"description",children:n}),i(C,{className:o("flex text-red-500 text-sm",e==null?void 0:e.error),children:b})]})}export{S as CreditCardExpirationInput,S as default};
1
+ import{jsxs as V,jsx as i}from"react/jsx-runtime";import{N as I}from"../../assets/react-number-format.es-DAlzZXlB.js";import{TextField as v,Label as s,Text as w,FieldError as C,Input as E}from"react-aria-components";import{useState as F,useEffect as $}from"react";import{c as o}from"../../assets/cn-CytzSlOG.js";function j({className:d,...n}){return i(E,{className:o("border-solid border border-slate-300 rounded-md","text-sm text-slate-900 placeholder-slate-400","h-10 px-2 py-0 m-0 w-full","bg-white","transition-all duration-200 ease-in-out","hover:border-slate-400","focus:outline-2 focus:outline focus:outline-slate-200 focus:border-slate-400","disabled:border-slate-200 disabled:bg-slate-100","invalid:border-red-500 invalid:bg-red-100 invalid:text-red-600","invalid:hover:border-red-600 invalid:focus:border-red-600 invalid:focus:outline-red-200",d),...n})}function S({label:d,description:n,errorMessage:b,placeholder:x,value:l,className:a,classNames:e,onChange:u,...p}){const[h,f]=F(l||"");$(()=>{f(l||"")},[l]);const m=r=>{if(r==="")return"";let t=r.substring(0,2);const g=r.substring(2,4);return t.length===1&&Number(t[0])>1?t=`0${t[0]}`:t.length===2&&(Number(t)===0?t="01":Number(t)>12&&(t="12")),`${t}/${g}`},c=r=>{f(r.formattedValue),u&&u(r.formattedValue)};return V(v,{className:o("flex flex-col w-full text-slate-900",a),...p,children:[i(s,{className:o("flex text-slate-500 text-sm",e==null?void 0:e.label),children:d}),i(I,{format:m,customInput:j,className:o(e==null?void 0:e.input),placeholder:x,value:h,onValueChange:c}),n&&i(w,{className:o("flex text-slate-500 text-sm",e==null?void 0:e.description),slot:"description",children:n}),i(C,{className:o("flex text-red-500 text-sm",e==null?void 0:e.error),children:b})]})}export{S as CreditCardExpirationInput,S as default};
@@ -1 +1 @@
1
- import{CreditCardExpirationInput as d}from"./CreditCardExpirationInput.js";import"react/jsx-runtime";import"../../assets/react-number-format.es-CQi9xzIr.js";import"react";import"react-aria-components";import"../../assets/cn-CytzSlOG.js";export{d as CreditCardExpirationInput};
1
+ import{CreditCardExpirationInput as d}from"./CreditCardExpirationInput.js";import"react/jsx-runtime";import"../../assets/react-number-format.es-DAlzZXlB.js";import"react";import"react-aria-components";import"../../assets/cn-CytzSlOG.js";export{d as CreditCardExpirationInput};
@@ -1 +1 @@
1
- import{jsxs as I,jsx as i}from"react/jsx-runtime";import{useState as C,useEffect as w}from"react";import{N as P}from"../../assets/react-number-format.es-CQi9xzIr.js";import{TextField as j,Label as E,Text as L,FieldError as T,Input as k}from"react-aria-components";import{c as o}from"../../assets/cn-CytzSlOG.js";const b=n=>{const a=[{regex:/^4[0-9]{0,15}/,format:"#### #### #### ####"},{regex:/^5[1-5][0-9]{0,14}/,format:"#### #### #### ####"},{regex:/^3[47][0-9]{0,13}/,format:"#### ###### #####"},{regex:/^6(?:011|5[0-9]{2})[0-9]{0,12}/,format:"#### #### #### ####"},{regex:/^3(?:0[0-5]|[68][0-9])[0-9]{0,11}/,format:"#### ###### ####"},{regex:/^(?:2131|1800|35\d{3})\d{0,11}/,format:"#### #### #### ####"}].find(x=>x.regex.test(n));return a?a.format:"#### #### #### #### ###"};function y({className:n,...l}){return i(k,{className:o("border-solid border border-slate-300 rounded-md","text-sm text-slate-900 placeholder-slate-400","h-10 px-2 py-0 m-0 w-full","bg-white","transition-all duration-200 ease-in-out","hover:border-slate-400","focus:outline-2 focus:outline focus:outline-slate-200 focus:border-slate-400","disabled:border-slate-200 disabled:bg-slate-100","invalid:border-red-500 invalid:bg-red-100 invalid:text-red-600","invalid:hover:border-red-600 invalid:focus:border-red-600 invalid:focus:outline-red-200",n),...l})}function D({label:n,description:l,errorMessage:a,placeholder:x,value:m,onChange:p,className:h,classNames:e,...s}){const[V,g]=C(m||"");w(()=>{g(m||"")},[m]);const v=u=>{if(u==="")return"";const t=u.replace(/\s+/g,""),f=b(t);let d="",r=0;for(let c=0;c<f.length;c+=1)if(f[c]==="#")if(r<t.length)d+=t[r],r+=1;else break;else d+=f[c];return d},F=u=>{const t=u.value.replace(/\s+/g,""),d=b(t).replace(/[^#]/g,"").length,r=t.slice(0,d);g(r),p&&p(r)};return I(j,{className:o("flex flex-col w-full text-slate-900",h),...s,children:[i(E,{className:o("flex text-slate-500 text-sm",e==null?void 0:e.label),children:n}),i(P,{value:V,format:v,customInput:y,className:o(e==null?void 0:e.input),placeholder:x,onValueChange:F}),l&&i(L,{className:o("flex text-slate-500 text-sm",e==null?void 0:e.description),slot:"description",children:l}),i(T,{className:o("flex text-red-500 text-sm",e==null?void 0:e.error),children:a})]})}export{D as CreditCardInput,D as default};
1
+ import{jsxs as I,jsx as i}from"react/jsx-runtime";import{useState as C,useEffect as w}from"react";import{N as P}from"../../assets/react-number-format.es-DAlzZXlB.js";import{TextField as j,Label as E,Text as L,FieldError as T,Input as k}from"react-aria-components";import{c as o}from"../../assets/cn-CytzSlOG.js";const b=n=>{const a=[{regex:/^4[0-9]{0,15}/,format:"#### #### #### ####"},{regex:/^5[1-5][0-9]{0,14}/,format:"#### #### #### ####"},{regex:/^3[47][0-9]{0,13}/,format:"#### ###### #####"},{regex:/^6(?:011|5[0-9]{2})[0-9]{0,12}/,format:"#### #### #### ####"},{regex:/^3(?:0[0-5]|[68][0-9])[0-9]{0,11}/,format:"#### ###### ####"},{regex:/^(?:2131|1800|35\d{3})\d{0,11}/,format:"#### #### #### ####"}].find(x=>x.regex.test(n));return a?a.format:"#### #### #### #### ###"};function y({className:n,...l}){return i(k,{className:o("border-solid border border-slate-300 rounded-md","text-sm text-slate-900 placeholder-slate-400","h-10 px-2 py-0 m-0 w-full","bg-white","transition-all duration-200 ease-in-out","hover:border-slate-400","focus:outline-2 focus:outline focus:outline-slate-200 focus:border-slate-400","disabled:border-slate-200 disabled:bg-slate-100","invalid:border-red-500 invalid:bg-red-100 invalid:text-red-600","invalid:hover:border-red-600 invalid:focus:border-red-600 invalid:focus:outline-red-200",n),...l})}function D({label:n,description:l,errorMessage:a,placeholder:x,value:m,onChange:p,className:h,classNames:e,...s}){const[V,g]=C(m||"");w(()=>{g(m||"")},[m]);const v=u=>{if(u==="")return"";const t=u.replace(/\s+/g,""),f=b(t);let d="",r=0;for(let c=0;c<f.length;c+=1)if(f[c]==="#")if(r<t.length)d+=t[r],r+=1;else break;else d+=f[c];return d},F=u=>{const t=u.value.replace(/\s+/g,""),d=b(t).replace(/[^#]/g,"").length,r=t.slice(0,d);g(r),p&&p(r)};return I(j,{className:o("flex flex-col w-full text-slate-900",h),...s,children:[i(E,{className:o("flex text-slate-500 text-sm",e==null?void 0:e.label),children:n}),i(P,{value:V,format:v,customInput:y,className:o(e==null?void 0:e.input),placeholder:x,onValueChange:F}),l&&i(L,{className:o("flex text-slate-500 text-sm",e==null?void 0:e.description),slot:"description",children:l}),i(T,{className:o("flex text-red-500 text-sm",e==null?void 0:e.error),children:a})]})}export{D as CreditCardInput,D as default};
@@ -1 +1 @@
1
- import{CreditCardInput as e}from"./CreditCardInput.js";import"react/jsx-runtime";import"react";import"../../assets/react-number-format.es-CQi9xzIr.js";import"react-aria-components";import"../../assets/cn-CytzSlOG.js";export{e as CreditCardInput};
1
+ import{CreditCardInput as e}from"./CreditCardInput.js";import"react/jsx-runtime";import"react";import"../../assets/react-number-format.es-DAlzZXlB.js";import"react-aria-components";import"../../assets/cn-CytzSlOG.js";export{e as CreditCardInput};
@@ -1 +1 @@
1
- import{jsx as o}from"react/jsx-runtime";import{forwardRef as p,useId as v}from"react";import{ModalOverlay as y}from"react-aria-components";import{motion as h,AnimatePresence as b}from"framer-motion";import{useDialogTrigger as x}from"../DialogTrigger/DialogTrigger.js";import{c as M}from"../../assets/cn-CytzSlOG.js";const O=p(({style:i,...e},t)=>{const n=typeof i=="function"?i(e):i;return o(y,{...e,ref:t,style:n})}),g=h.create(O);function a({animate:i,animation:e,setAnimation:t,className:n,animationVariants:d,children:l,...s}){const c=v(),{key:m,...f}=s;return o(g,{isExiting:e==="hidden",onAnimationComplete:u=>{t(r=>u==="hidden"&&r==="hidden"?"unmounted":r)},variants:d||{hidden:{opacity:0,backdropFilter:"blur(0px)",transition:{delay:.08}},visible:{opacity:1,backdropFilter:"blur(8px)"}},initial:"hidden",animate:i,exit:"hidden",className:M("bg-black/30","fixed top-0 left-0","z-50","w-screen h-[var(--visual-viewport-height)]",n),...f,children:l},m||c)}function j(i){const{isOpen:e}=i,{animation:t,setAnimation:n}=x();return e!==void 0?o(b,{children:e&&o(a,{...i,animate:"visible",animation:t,setAnimation:n})}):o(a,{...i,animate:t,animation:t,setAnimation:n})}export{j as ModalOverlay,j as default};
1
+ import{jsx as o}from"react/jsx-runtime";import{forwardRef as p,useId as v}from"react";import{ModalOverlay as y}from"react-aria-components";import{motion as h,AnimatePresence as b}from"framer-motion";import{useDialogTrigger as x}from"../DialogTrigger/DialogTrigger.js";import{c as M}from"../../assets/cn-CytzSlOG.js";const O=p(({style:e,...i},n)=>{const t=typeof e=="function"?e(i):e;return o(y,{...i,ref:n,style:t})}),g=h.create(O);function a({animate:e,animation:i,setAnimation:n,className:t,animationVariants:d,children:l,...s}){const c=v(),{key:m,...f}=s;return o(g,{isExiting:i==="hidden",onAnimationComplete:u=>{n(r=>u==="hidden"&&r==="hidden"?"unmounted":r)},variants:d||{hidden:{opacity:0,backdropFilter:"blur(0px)",transition:{delay:.08}},visible:{opacity:1,backdropFilter:"blur(8px)"}},initial:"hidden",animate:e,exit:"hidden",className:M("bg-black/30","fixed top-0 left-0","z-50","w-screen h-[var(--visual-viewport-height)]",t),...f,children:l},m||c)}function j(e){const{isOpen:i}=e,{animation:n,setAnimation:t}=x();return i!==void 0?o(b,{children:i&&o(a,{...e,animate:"visible",animation:n,setAnimation:t})}):o(a,{...e,animate:n,animation:n,setAnimation:t})}export{j as ModalOverlay,j as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as f,Fragment as O}from"react/jsx-runtime";import{Popover as I,ComboBox as P,Label as S,Input as j,Button as A,Text as D,FieldError as E,ListBox as F}from"react-aria-components";import{forwardRef as M,useState as h}from"react";import{motion as T}from"framer-motion";import{c as d}from"../../assets/cn-CytzSlOG.js";import{Pulse as R}from"../Loader/Pulse.js";const U=M((o,i)=>e(I,{...o,ref:i})),W=T.create(U);function q({buttonIcon:o,...i}){return o?typeof o=="function"?o(i):o:e("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:d("transition-all ease-in-out duration-200",i.isOpen?"rotate-180":"rotate-0"),children:e("path",{d:"M6 9L12 15L18 9",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:d(["stroke-slate-900",i.isDisabled&&"stroke-slate-400",i.isInvalid&&"stroke-red-500"])})})}function V({label:o,description:i,errorMessage:p,children:v,placeholder:g,key:w,isLoading:n,slots:r,popoverPortalContainer:_,popoverOffset:c,selectedKey:k,className:y,classNames:t,...l}){const[a,u]=h("unmounted"),[x,B]=h(!1);return e(P,{onOpenChange:()=>{u(a==="visible"?"hidden":"visible"),B(!x)},isDisabled:l.isDisabled||n,"data-has-value":!!k,...l,className:d("flex flex-col","w-full",y),children:C=>f(O,{children:[e(S,{className:d("flex","text-xs text-slate-500",t==null?void 0:t.label),children:o}),f("div",{className:d("flex","relative","w-full",t==null?void 0:t.comboBoxContainer),children:[e(j,{placeholder:g,className:d("border border-solid border-slate-300","text-sm text-slate-900","py-0 px-2","h-10 w-full","m-0","rounded-md","bg-white","transition-all ease-in-out duration-200","data-[hovered]:border-slate-400","data-[focused]:border-slate-400 data-[focused]:outline data-[focused]:outline-2 data-[focused]:outline-slate-200"," data-[disabled]:bg-slate-100 data-[disabled]:border-slate-300",n?"data-[disabled]:text-slate-900":"data-[disabled]:text-slate-500","data-[invalid]:border-red-500 data-[invalid]:bg-red-100 data-[invalid]:text-red-600","data-[invalid]:data-[hovered]:border-red-600","data-[invalid]:data-[focused]:border-red-600 data-[invalid]:data-[focused]:outline data-[invalid]:data-[focused]:outline-2 data-[invalid]:data-[focused]:outline-red-200","data-[invalid]:placeholder:text-slate-400",t==null?void 0:t.input)}),n?e("div",{className:d("absolute top-2 right-2","block",t==null?void 0:t.loader),children:(r==null?void 0:r.loadingIcon)||e(R,{})}):e(A,{className:d("absolute top-2 right-0","block","border-none","bg-none",t==null?void 0:t.arrowButton),children:e(q,{buttonIcon:r==null?void 0:r.buttonIcon,...C})})]}),i&&e(D,{slot:"description",className:d("flex","text-xs","text-slate-500",t==null?void 0:t.description),children:i}),e(E,{className:d("flex","text-xs","text-red-500",t==null?void 0:t.errorMessage),children:p}),e(W,{isOpen:x,isExiting:a==="hidden",offset:c,UNSTABLE_portalContainer:_,onAnimationComplete:L=>{u(b=>L==="hidden"&&b==="hidden"?"unmounted":b)},variants:{hidden:{opacity:0,y:-10},visible:{opacity:1,y:0}},initial:"hidden",animate:a,className:d("px-0 py-1.5","shadow-[0_10px_15px_-3px_rgba(0,0,0,0.1),0_4px_6px_-4px_rgba(0,0,0,0.1)]","rounded-md","w-[var(--trigger-width)]","bg-white","border border-solid border-slate-300",t==null?void 0:t.listContainer),children:e(F,{className:d("max-h-80","overflow-y-scroll",t==null?void 0:t.list),children:v})},w)]})})}export{V as Select,V as default};
1
+ import{jsx as e,jsxs as v,Fragment as O}from"react/jsx-runtime";import{Popover as S,ComboBox as I,Label as P,Input as j,Button as m,Text as A,FieldError as D,ListBox as E}from"react-aria-components";import{forwardRef as F,useState as g}from"react";import{motion as M}from"framer-motion";import{c as o}from"../../assets/cn-CytzSlOG.js";import{Pulse as T}from"../Loader/Pulse.js";const R=F((d,i)=>e(S,{...d,ref:i})),U=M.create(R);function W({buttonIcon:d,...i}){return d?typeof d=="function"?d(i):d:e("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:o("transition-all ease-in-out duration-200",i.isOpen?"rotate-180":"rotate-0"),children:e("path",{d:"M6 9L12 15L18 9",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:o(["stroke-slate-900",i.isDisabled&&"stroke-slate-400",i.isInvalid&&"stroke-red-500"])})})}function q({listBoxComponent:d,children:i,...r}){return e(d||E,{...r,children:i})}function X({label:d,description:i,errorMessage:r,children:u,placeholder:w,key:C,isLoading:a,slots:n,popoverPortalContainer:B,popoverOffset:c,selectedKey:x,className:_,classNames:t,...b}){const[l,f]=g("unmounted"),[h,k]=g(!1);return e(I,{onOpenChange:()=>{f(l==="visible"?"hidden":"visible"),k(!h)},isDisabled:b.isDisabled||a,"data-has-value":!!x,selectedKey:x,...b,className:o("flex flex-col","w-full",_),children:y=>v(O,{children:[e(P,{className:o("flex","text-xs text-slate-500",t==null?void 0:t.label),children:d}),v("div",{className:o("flex","relative","w-full",t==null?void 0:t.comboBoxContainer),children:[e(j,{placeholder:w,className:o("border border-solid border-slate-300","text-sm text-slate-900","py-0 px-2","h-10 w-full","m-0","rounded-md","bg-white","transition-all ease-in-out duration-200","data-[hovered]:border-slate-400","data-[focused]:border-slate-400 data-[focused]:outline data-[focused]:outline-2 data-[focused]:outline-slate-200"," data-[disabled]:bg-slate-100 data-[disabled]:border-slate-300",a?"data-[disabled]:text-slate-900":"data-[disabled]:text-slate-500","data-[invalid]:border-red-500 data-[invalid]:bg-red-100 data-[invalid]:text-red-600","data-[invalid]:data-[hovered]:border-red-600","data-[invalid]:data-[focused]:border-red-600 data-[invalid]:data-[focused]:outline data-[invalid]:data-[focused]:outline-2 data-[invalid]:data-[focused]:outline-red-200","data-[invalid]:placeholder:text-slate-400",t==null?void 0:t.input)}),a?e("div",{className:o("absolute top-2 right-2","block",t==null?void 0:t.loader),children:(n==null?void 0:n.loadingIcon)||e(T,{})}):e(m,{className:o("absolute top-2 right-0","block","border-none","bg-none",t==null?void 0:t.arrowButton),children:e(W,{buttonIcon:n==null?void 0:n.buttonIcon,...y})})]}),i&&e(A,{slot:"description",className:o("flex","text-xs","text-slate-500",t==null?void 0:t.description),children:i}),e(D,{className:o("flex","text-xs","text-red-500",t==null?void 0:t.errorMessage),children:r}),e(U,{isOpen:h,isExiting:l==="hidden",offset:c,UNSTABLE_portalContainer:B,onAnimationComplete:L=>{f(p=>L==="hidden"&&p==="hidden"?"unmounted":p)},variants:{hidden:{opacity:0,y:-10},visible:{opacity:1,y:0}},initial:"hidden",animate:l,className:o("px-0 py-1.5","shadow-[0_10px_15px_-3px_rgba(0,0,0,0.1),0_4px_6px_-4px_rgba(0,0,0,0.1)]","rounded-md","w-[var(--trigger-width)]","bg-white","border border-solid border-slate-300",t==null?void 0:t.listContainer),children:e(q,{listBoxComponent:n==null?void 0:n.listBoxComponent,className:o("max-h-80","overflow-y-scroll",t==null?void 0:t.list),children:u})},C)]})})}export{X as Select,X as default};
@@ -1,10 +1,11 @@
1
- import { ComboBoxRenderProps, ComboBoxProps as AriaComboBoxProps, ValidationResult } from 'react-aria-components';
2
- import { Key, ReactNode } from 'react';
1
+ import { ComboBoxRenderProps, ComboBoxProps as AriaComboBoxProps, ValidationResult, ListBoxProps } from 'react-aria-components';
2
+ import { ComponentType, Key, ReactNode } from 'react';
3
3
  import { SlotsToClasses } from '../../types/SlotsToClasses';
4
4
  export type ComboBoxPopoverAnimationState = 'unmounted' | 'hidden' | 'visible';
5
- export type SelectSlots = {
5
+ export type SelectSlots<T extends object> = {
6
6
  buttonIcon?: ReactNode | ((values: ComboBoxRenderProps) => ReactNode);
7
7
  loadingIcon?: ReactNode;
8
+ listBoxComponent?: ComponentType<ListBoxProps<T>>;
8
9
  };
9
10
  export interface SelectProps<T extends object> extends Omit<AriaComboBoxProps<T>, 'children'> {
10
11
  label?: string;
@@ -14,7 +15,7 @@ export interface SelectProps<T extends object> extends Omit<AriaComboBoxProps<T>
14
15
  key?: Key | null;
15
16
  isLoading?: boolean;
16
17
  children: ReactNode | ((item: T) => ReactNode);
17
- slots?: SelectSlots;
18
+ slots?: SelectSlots<T>;
18
19
  popoverOffset?: number;
19
20
  popoverPortalContainer?: Element;
20
21
  classNames?: SlotsToClasses<'label' | 'name' | 'comboBoxContainer' | 'input' | 'loader' | 'arrowButton' | 'description' | 'errorMessage' | 'listContainer' | 'list'>;
@@ -1 +1 @@
1
- import{jsx as l,jsxs as u,Fragment as c}from"react/jsx-runtime";import{Switch as g}from"react-aria-components";import{c as n}from"../../assets/cn-CytzSlOG.js";function h({children:e,className:a,classNames:t,...s}){return l(g,{className:n("flex items-center gap-2 text-sm text-slate-500 forced-color-adjust-none group","",a),...s,children:o=>{const{isSelected:b,isHovered:r,isFocused:i,isPressed:d,isDisabled:f}=o;return u(c,{children:[l("div",{className:n("w-12 h-7 bg-transparent border-solid border border-slate-300 rounded-3xl transition-all duration-200 ease-in-out","before:block before:w-5 before:h-5 before:m-[3px] before:bg-slate-300 before:rounded-full","before:transition-all before:duration-200 before:ease-in-out",[r&&"border-slate-400",b&&[" bg-slate-300 before:translate-x-full before:bg-white",(r||i)&&"border-slate-400"],i&&["outline outline-2 outline-slate-200"],d&&"before:bg-slate-400",f&&"bg-slate-100",t==null?void 0:t.indicator])}),typeof e=="function"?e({defaultChildren:void 0,...o}):e]})}})}export{h as Switch,h as default};
1
+ import{jsx as n,jsxs as u,Fragment as c}from"react/jsx-runtime";import{Switch as g}from"react-aria-components";import{c as l}from"../../assets/cn-CytzSlOG.js";function h({children:e,className:a,classNames:t,...s}){return n(g,{className:l("flex items-center gap-2 text-sm text-slate-500 forced-color-adjust-none group","",a),...s,children:o=>{const{isSelected:b,isHovered:r,isFocused:i,isPressed:d,isDisabled:f}=o;return u(c,{children:[n("div",{className:l("w-12 h-7 bg-transparent border-solid border border-slate-300 rounded-3xl transition-all duration-200 ease-in-out","before:block before:w-5 before:h-5 before:m-[3px] before:bg-slate-300 before:rounded-full","before:transition-all before:duration-200 before:ease-in-out",[r&&"border-slate-400",b&&[" bg-slate-300 before:translate-x-full before:bg-white",(r||i)&&"border-slate-400"],i&&["outline outline-2 outline-slate-200"],d&&"before:bg-slate-400",f&&"bg-slate-100",t==null?void 0:t.indicator])}),typeof e=="function"?e({defaultChildren:void 0,...o}):e]})}})}export{h as Switch,h as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clicktap/ui",
3
- "version": "0.12.18",
3
+ "version": "0.13.0",
4
4
  "private": false,
5
5
  "author": "Clicktap",
6
6
  "description": "A library of React UI components and low-level hooks.",
@@ -1 +0,0 @@
1
- import j,{useRef as _,useState as ue,useEffect as H,useMemo as Ie,useLayoutEffect as xe}from"react";function Ae(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var u=0,i=Object.getOwnPropertySymbols(e);u<i.length;u++)t.indexOf(i[u])<0&&Object.prototype.propertyIsEnumerable.call(e,i[u])&&(n[i[u]]=e[i[u]]);return n}var K;(function(e){e.event="event",e.props="prop"})(K||(K={}));function R(){}function be(e){var t,n=void 0;return function(){for(var i=[],u=arguments.length;u--;)i[u]=arguments[u];return t&&i.length===t.length&&i.every(function(d,m){return d===t[m]})||(t=i,n=e.apply(void 0,i)),n}}function Q(e){return!!(e||"").match(/\d/)}function X(e){return e==null}function we(e){return typeof e=="number"&&isNaN(e)}function Te(e){return X(e)||we(e)||typeof e=="number"&&!isFinite(e)}function Ee(e){var t=_(e);t.current=e;var n=_(function(){for(var i=[],u=arguments.length;u--;)i[u]=arguments[u];return t.current.apply(t,i)});return n.current}function ne(e,t){return Array(t+1).join(e)}function Me(e){var t=e+"",n=t[0]==="-"?"-":"";n&&(t=t.substring(1));var i=t.split(/[eE]/g),u=i[0],d=i[1];if(d=Number(d),!d)return n+u;u=u.replace(".","");var m=1+d,y=u.length;return m<0?u="0."+ne("0",Math.abs(m))+u:m>=y?u=u+ne("0",m-y):u=(u.substring(0,m)||"0")+"."+u.substring(m),n+u}function ae(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var n=e.createTextRange();return n.move("character",t),n.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var Oe=be(function(e,t){for(var n=0,i=0,u=e.length,d=t.length;e[n]===t[n]&&n<u;)n++;for(;e[u-1-i]===t[d-1-i]&&d-i>n&&u-i>n;)i++;return{from:{start:n,end:u-i},to:{start:n,end:d-i}}}),Be=function(e,t){var n=Math.min(e.selectionStart,t);return{from:{start:n,end:e.selectionEnd},to:{start:n,end:t}}};function Ne(e,t,n){return Math.min(Math.max(e,t),n)}function J(e){return Math.max(e.selectionStart,e.selectionEnd)}function Re(){return typeof navigator<"u"&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function _e(e){var t=e.currentValue,n=e.formattedValue,i=e.currentValueIndex,u=e.formattedValueIndex;return t[i]===n[u]}function Fe(e,t,n,i,u,d,m){m===void 0&&(m=_e);var y=u.findIndex(function(P){return P}),S=e.slice(0,y);!t&&!n.startsWith(S)&&(t=S,n=S+n,i=i+S.length);for(var I=n.length,O=e.length,T={},h=new Array(I),V=0;V<I;V++){h[V]=-1;for(var s=0,x=O;s<x;s++){var C=m({currentValue:n,lastValue:t,formattedValue:e,currentValueIndex:V,formattedValueIndex:s});if(C&&T[s]!==!0){h[V]=s,T[s]=!0;break}}}for(var c=i;c<I&&(h[c]===-1||!d(n[c]));)c++;var A=c===I||h[c]===-1?O:h[c];for(c=i-1;c>0&&h[c]===-1;)c--;var b=c===-1||h[c]===-1?0:h[c]+1;return b>A?A:i-b<A-i?b:A}function ie(e,t,n,i){var u=e.length;if(t=Ne(t,0,u),i==="left"){for(;t>=0&&!n[t];)t--;t===-1&&(t=n.indexOf(!0))}else{for(;t<=u&&!n[t];)t++;t>u&&(t=n.lastIndexOf(!0))}return t===-1&&(t=u),t}function Le(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),n=0,i=t.length;n<i;n++)t[n]=!!(Q(e[n])||Q(e[n-1]));return t}function je(e,t,n,i,u,d){d===void 0&&(d=R);var m=Ee(function(s,x){var C,c;return Te(s)?(c="",C=""):typeof s=="number"||x?(c=typeof s=="number"?Me(s):s,C=i(c)):(c=u(s,void 0),C=i(c)),{formattedValue:C,numAsString:c}}),y=ue(function(){return m(X(e)?t:e,n)}),S=y[0],I=y[1],O=function(s,x){s.formattedValue!==S.formattedValue&&I({formattedValue:s.formattedValue,numAsString:s.value}),d(s,x)},T=e,h=n;X(e)&&(T=S.numAsString,h=!0);var V=m(T,h);return Ie(function(){I(V)},[V.formattedValue]),[S,O]}function De(e){return e.replace(/[^0-9]/g,"")}function ke(e){return e}function Ke(e){var t=e.type;t===void 0&&(t="text");var n=e.displayType;n===void 0&&(n="input");var i=e.customInput,u=e.renderText,d=e.getInputRef,m=e.format;m===void 0&&(m=ke);var y=e.removeFormatting;y===void 0&&(y=De);var S=e.defaultValue,I=e.valueIsNumericString,O=e.onValueChange,T=e.isAllowed,h=e.onChange;h===void 0&&(h=R);var V=e.onKeyDown;V===void 0&&(V=R);var s=e.onMouseUp;s===void 0&&(s=R);var x=e.onFocus;x===void 0&&(x=R);var C=e.onBlur;C===void 0&&(C=R);var c=e.value,A=e.getCaretBoundary;A===void 0&&(A=Le);var b=e.isValidInputCharacter;b===void 0&&(b=Q);var P=e.isCharacterSame,q=Ae(e,["type","displayType","customInput","renderText","getInputRef","format","removeFormatting","defaultValue","valueIsNumericString","onValueChange","isAllowed","onChange","onKeyDown","onMouseUp","onFocus","onBlur","value","getCaretBoundary","isValidInputCharacter","isCharacterSame"]),Y=je(c,S,!!I,m,y,O),Z=Y[0],g=Z.formattedValue,D=Z.numAsString,oe=Y[1],k=_(),U=_({formattedValue:g,numAsString:D}),ee=function(r,a){U.current={formattedValue:r.formattedValue,numAsString:r.value},oe(r,a)},te=ue(!1),fe=te[0],le=te[1],F=_(null),B=_({setCaretTimeout:null,focusTimeout:null});H(function(){return le(!0),function(){clearTimeout(B.current.setCaretTimeout),clearTimeout(B.current.focusTimeout)}},[]);var ve=m,z=function(r,a){var o=parseFloat(a);return{formattedValue:r,value:a,floatValue:isNaN(o)?void 0:o}},N=function(r,a,o){r.selectionStart===0&&r.selectionEnd===r.value.length||(ae(r,a),B.current.setCaretTimeout=setTimeout(function(){r.value===o&&r.selectionStart!==a&&ae(r,a)},0))},L=function(r,a,o){return ie(r,a,A(r),o)},W=function(r,a,o){var l=A(a),p=Fe(a,g,r,o,l,b,P);return p=ie(a,p,l),p},ce=function(r){var a=r.formattedValue;a===void 0&&(a="");var o=r.input,l=r.source,p=r.event,v=r.numAsString,f;if(o){var w=r.inputValue||o.value,E=J(o);o.value=a,f=W(w,a,E),f!==void 0&&N(o,f,a)}a!==g&&ee(z(a,v),{event:p,source:l})};H(function(){var r=U.current,a=r.formattedValue,o=r.numAsString;(g!==a||D!==o)&&ee(z(g,D),{event:void 0,source:K.props})},[g,D]);var se=F.current?J(F.current):void 0,de=typeof window<"u"?xe:H;de(function(){var r=F.current;if(g!==U.current.formattedValue&&r){var a=W(U.current.formattedValue,g,se);r.value=g,N(r,a,g)}},[g]);var me=function(r,a,o){var l=a.target,p=k.current?Be(k.current,l.selectionEnd):Oe(g,r),v=Object.assign(Object.assign({},p),{lastValue:g}),f=y(r,v),w=ve(f);if(f=y(w,void 0),T&&!T(z(w,f))){var E=a.target,M=J(E),G=W(r,g,M);return E.value=g,N(E,G,g),!1}return ce({formattedValue:w,numAsString:f,inputValue:r,event:a,source:o,input:a.target}),!0},$=function(r,a){a===void 0&&(a=0);var o=r.selectionStart,l=r.selectionEnd;k.current={selectionStart:o,selectionEnd:l+a}},ge=function(r){var a=r.target,o=a.value,l=me(o,r,K.event);l&&h(r),k.current=void 0},he=function(r){var a=r.target,o=r.key,l=a.selectionStart,p=a.selectionEnd,v=a.value;v===void 0&&(v="");var f;o==="ArrowLeft"||o==="Backspace"?f=Math.max(l-1,0):o==="ArrowRight"?f=Math.min(l+1,v.length):o==="Delete"&&(f=l);var w=0;o==="Delete"&&l===p&&(w=1);var E=o==="ArrowLeft"||o==="ArrowRight";if(f===void 0||l!==p&&!E){V(r),$(a,w);return}var M=f;if(E){var G=o==="ArrowLeft"?"left":"right";M=L(v,f,G),M!==f&&r.preventDefault()}else o==="Delete"&&!b(v[f])?M=L(v,f,"right"):o==="Backspace"&&!b(v[f])&&(M=L(v,f,"left"));M!==f&&N(a,M,v),V(r),$(a,w)},pe=function(r){var a=r.target,o=function(){var l=a.selectionStart,p=a.selectionEnd,v=a.value;if(v===void 0&&(v=""),l===p){var f=L(v,l);f!==l&&N(a,f,v)}};o(),requestAnimationFrame(function(){o()}),s(r),$(a)},ye=function(r){r.persist&&r.persist();var a=r.target,o=r.currentTarget;F.current=a,B.current.focusTimeout=setTimeout(function(){var l=a.selectionStart,p=a.selectionEnd,v=a.value;v===void 0&&(v="");var f=L(v,l);f!==l&&!(l===0&&p===v.length)&&N(a,f,v),x(Object.assign(Object.assign({},r),{currentTarget:o}))},0)},Ve=function(r){F.current=null,clearTimeout(B.current.focusTimeout),clearTimeout(B.current.setCaretTimeout),C(r)},Se=fe&&Re()?"numeric":void 0,re=Object.assign({inputMode:Se},q,{type:t,value:g,onChange:ge,onKeyDown:he,onMouseUp:pe,onFocus:ye,onBlur:Ve});if(n==="text")return u?j.createElement(j.Fragment,null,u(g,q)||null):j.createElement("span",Object.assign({},q,{ref:d}),g);if(i){var Ce=i;return j.createElement(Ce,Object.assign({},re,{ref:d}))}return j.createElement("input",Object.assign({},re,{ref:d}))}export{Ke as N};