@adam-milo/ui 1.0.139 → 1.0.140

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/index125.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});exports.calculateFittingChips=(e,t,r,a,s)=>{let n=0,l=0;for(let u=0;u<e.length;u++){const c=e[u],i=t.get(c.value)||0;if(0===i){l++;break}const o=n+(u>0?a:0)+i;if(u<e.length-1){if(o+a+s>r&&l>0)break}else if(o>r&&l>0)break;n=o,l++}return Math.max(1,l)},exports.parseGapValue=(e,t,r)=>{if(!e)return.5*t;const a=e.match(/^([\d.]+)(px|rem|em)?/);if(!a)return.5*t;const s=parseFloat(a[1]);switch(a[2]||"px"){case"px":return s;case"rem":return s*t;case"em":return s*r;default:return.5*t}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=["p-0.5 m-0 border-none bg-transparent","flex items-center justify-center flex-shrink-0","text-[var(--color-icon-secondary)] cursor-pointer rounded","transition-colors duration-150","hover:text-[var(--color-system-text)]","focus:outline-2 focus:outline-[var(--color-clickable)] focus:outline-offset-1","focus:not(:focus-visible):outline-none"].join(" "),o=["z-[100] max-w-[var(--max-width-xs)] px-3 py-2","bg-[var(--color-text)] rounded-md shadow-[0_0.25rem_0.75rem_var(--shadow-color-lg)]","text-12 font-normal leading-relaxed text-[var(--color-card)]","animate-in fade-in-0 zoom-in-95"].join(" "),t=["flex items-center self-stretch w-full","h-[var(--input-height)] p-[0.875rem]","text-16 leading-none text-[var(--color-text)]","bg-[var(--color-card)] border border-[var(--color-border)] rounded-[var(--radius-md)]","transition-[border-color,box-shadow] duration-200 ease-in-out","cursor-text","placeholder:text-[var(--color-icon-secondary)]","focus:outline-none focus:border-[var(--color-button-blue)]","hover:enabled:border-[var(--color-button-blue)]","disabled:cursor-not-allowed disabled:opacity-50 disabled:pointer-events-none","disabled:[-webkit-text-fill-color:var(--color-text)]"].join(" "),r=["absolute top-1/2 start-3 -translate-y-1/2","flex items-center justify-center","text-[var(--color-icon-secondary)] pointer-events-none"].join(" "),l=["absolute top-1/2 end-3.5 -translate-y-1/2","flex items-center justify-center w-8 h-8 p-0","bg-transparent border-none text-[var(--color-icon-secondary)] cursor-pointer","transition-colors duration-200","hover:text-[var(--color-system-text)]","focus:outline-2 focus:outline-[var(--color-clickable)] focus:outline-offset-2 focus:rounded-sm","focus:not(:focus-visible):outline-none","active:-translate-y-1/2 active:scale-95"].join(" ");exports.errorStyles="text-12 font-normal leading-none text-[var(--color-error)]",exports.fieldContainerStyles="relative flex items-center w-full",exports.helperStyles="text-12 leading-none text-[var(--color-grey-07)]",exports.inputBaseStyles=t,exports.inputErrorStyles="border-[var(--color-error)] focus:border-[var(--color-error)] hover:enabled:border-[var(--color-error)]",exports.inputWithLeftIconStyles="ps-10",exports.inputWithToggleStyles="pe-12",exports.labelRowStyles="flex items-center justify-between h-4 w-full",exports.labelStyles="text-16 font-normal text-[var(--color-grey-07)] leading-none",exports.leftIconStyles=r,exports.toggleStyles=l,exports.tooltipContentStyles=o,exports.tooltipTriggerStyles=e,exports.wrapperStyles="flex flex-col justify-center items-start gap-2 w-full";
package/dist/index125.js CHANGED
@@ -1 +1 @@
1
- const e=(e,t,r)=>{if(!e)return.5*t;const n=e.match(/^([\d.]+)(px|rem|em)?/);if(!n)return.5*t;const a=parseFloat(n[1]);switch(n[2]||"px"){case"px":return a;case"rem":return a*t;case"em":return a*r;default:return.5*t}},t=(e,t,r,n,a)=>{let s=0,c=0;for(let u=0;u<e.length;u++){const f=e[u],l=t.get(f.value)||0;if(0===l){c++;break}const o=s+(u>0?n:0)+l;if(u<e.length-1){if(o+n+a>r&&c>0)break}else if(o>r&&c>0)break;s=o,c++}return Math.max(1,c)};export{t as calculateFittingChips,e as parseGapValue};
1
+ const e="flex flex-col justify-center items-start gap-2 w-full",o="flex items-center justify-between h-4 w-full",r="text-16 font-normal text-[var(--color-grey-07)] leading-none",t=["p-0.5 m-0 border-none bg-transparent","flex items-center justify-center flex-shrink-0","text-[var(--color-icon-secondary)] cursor-pointer rounded","transition-colors duration-150","hover:text-[var(--color-system-text)]","focus:outline-2 focus:outline-[var(--color-clickable)] focus:outline-offset-1","focus:not(:focus-visible):outline-none"].join(" "),n=["z-[100] max-w-[var(--max-width-xs)] px-3 py-2","bg-[var(--color-text)] rounded-md shadow-[0_0.25rem_0.75rem_var(--shadow-color-lg)]","text-12 font-normal leading-relaxed text-[var(--color-card)]","animate-in fade-in-0 zoom-in-95"].join(" "),l="relative flex items-center w-full",a=["flex items-center self-stretch w-full","h-[var(--input-height)] p-[0.875rem]","text-16 leading-none text-[var(--color-text)]","bg-[var(--color-card)] border border-[var(--color-border)] rounded-[var(--radius-md)]","transition-[border-color,box-shadow] duration-200 ease-in-out","cursor-text","placeholder:text-[var(--color-icon-secondary)]","focus:outline-none focus:border-[var(--color-button-blue)]","hover:enabled:border-[var(--color-button-blue)]","disabled:cursor-not-allowed disabled:opacity-50 disabled:pointer-events-none","disabled:[-webkit-text-fill-color:var(--color-text)]"].join(" "),c="border-[var(--color-error)] focus:border-[var(--color-error)] hover:enabled:border-[var(--color-error)]",s="ps-10",i="pe-12",d=["absolute top-1/2 start-3 -translate-y-1/2","flex items-center justify-center","text-[var(--color-icon-secondary)] pointer-events-none"].join(" "),u=["absolute top-1/2 end-3.5 -translate-y-1/2","flex items-center justify-center w-8 h-8 p-0","bg-transparent border-none text-[var(--color-icon-secondary)] cursor-pointer","transition-colors duration-200","hover:text-[var(--color-system-text)]","focus:outline-2 focus:outline-[var(--color-clickable)] focus:outline-offset-2 focus:rounded-sm","focus:not(:focus-visible):outline-none","active:-translate-y-1/2 active:scale-95"].join(" "),f="text-12 leading-none text-[var(--color-grey-07)]",x="text-12 font-normal leading-none text-[var(--color-error)]";export{x as errorStyles,l as fieldContainerStyles,f as helperStyles,a as inputBaseStyles,c as inputErrorStyles,s as inputWithLeftIconStyles,i as inputWithToggleStyles,o as labelRowStyles,r as labelStyles,d as leftIconStyles,u as toggleStyles,n as tooltipContentStyles,t as tooltipTriggerStyles,e as wrapperStyles};
package/dist/index126.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=["p-0.5 m-0 border-none bg-transparent","flex items-center justify-center flex-shrink-0","text-[var(--color-icon-secondary)] cursor-pointer rounded","transition-colors duration-150","hover:text-[var(--color-system-text)]","focus:outline-2 focus:outline-[var(--color-clickable)] focus:outline-offset-1","focus:not(:focus-visible):outline-none"].join(" "),o=["z-[100] max-w-[var(--max-width-xs)] px-3 py-2","bg-[var(--color-text)] rounded-md shadow-[0_0.25rem_0.75rem_var(--shadow-color-lg)]","text-12 font-normal leading-relaxed text-[var(--color-card)]","animate-in fade-in-0 zoom-in-95"].join(" "),t=["flex items-center self-stretch w-full","h-[var(--input-height)] p-[0.875rem]","text-16 leading-none text-[var(--color-text)]","bg-[var(--color-card)] border border-[var(--color-border)] rounded-[var(--radius-md)]","transition-[border-color,box-shadow] duration-200 ease-in-out","cursor-text","placeholder:text-[var(--color-icon-secondary)]","focus:outline-none focus:border-[var(--color-button-blue)]","hover:enabled:border-[var(--color-button-blue)]","disabled:cursor-not-allowed disabled:opacity-50 disabled:pointer-events-none","disabled:[-webkit-text-fill-color:var(--color-text)]"].join(" "),r=["absolute top-1/2 start-3 -translate-y-1/2","flex items-center justify-center","text-[var(--color-icon-secondary)] pointer-events-none"].join(" "),l=["absolute top-1/2 end-3.5 -translate-y-1/2","flex items-center justify-center w-8 h-8 p-0","bg-transparent border-none text-[var(--color-icon-secondary)] cursor-pointer","transition-colors duration-200","hover:text-[var(--color-system-text)]","focus:outline-2 focus:outline-[var(--color-clickable)] focus:outline-offset-2 focus:rounded-sm","focus:not(:focus-visible):outline-none","active:-translate-y-1/2 active:scale-95"].join(" ");exports.errorStyles="text-12 font-normal leading-none text-[var(--color-error)]",exports.fieldContainerStyles="relative flex items-center w-full",exports.helperStyles="text-12 leading-none text-[var(--color-grey-07)]",exports.inputBaseStyles=t,exports.inputErrorStyles="border-[var(--color-error)] focus:border-[var(--color-error)] hover:enabled:border-[var(--color-error)]",exports.inputWithLeftIconStyles="ps-10",exports.inputWithToggleStyles="pe-12",exports.labelRowStyles="flex items-center justify-between h-4 w-full",exports.labelStyles="text-16 font-normal text-[var(--color-grey-07)] leading-none",exports.leftIconStyles=r,exports.toggleStyles=l,exports.tooltipContentStyles=o,exports.tooltipTriggerStyles=e,exports.wrapperStyles="flex flex-col justify-center items-start gap-2 w-full";
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});exports.calculateFittingChips=(e,t,r,a,s)=>{let n=0,l=0;for(let u=0;u<e.length;u++){const c=e[u],i=t.get(c.value)||0;if(0===i){l++;break}const o=n+(u>0?a:0)+i;if(u<e.length-1){if(o+a+s>r&&l>0)break}else if(o>r&&l>0)break;n=o,l++}return Math.max(1,l)},exports.parseGapValue=(e,t,r)=>{if(!e)return.5*t;const a=e.match(/^([\d.]+)(px|rem|em)?/);if(!a)return.5*t;const s=parseFloat(a[1]);switch(a[2]||"px"){case"px":return s;case"rem":return s*t;case"em":return s*r;default:return.5*t}};
package/dist/index126.js CHANGED
@@ -1 +1 @@
1
- const e="flex flex-col justify-center items-start gap-2 w-full",o="flex items-center justify-between h-4 w-full",r="text-16 font-normal text-[var(--color-grey-07)] leading-none",t=["p-0.5 m-0 border-none bg-transparent","flex items-center justify-center flex-shrink-0","text-[var(--color-icon-secondary)] cursor-pointer rounded","transition-colors duration-150","hover:text-[var(--color-system-text)]","focus:outline-2 focus:outline-[var(--color-clickable)] focus:outline-offset-1","focus:not(:focus-visible):outline-none"].join(" "),n=["z-[100] max-w-[var(--max-width-xs)] px-3 py-2","bg-[var(--color-text)] rounded-md shadow-[0_0.25rem_0.75rem_var(--shadow-color-lg)]","text-12 font-normal leading-relaxed text-[var(--color-card)]","animate-in fade-in-0 zoom-in-95"].join(" "),l="relative flex items-center w-full",a=["flex items-center self-stretch w-full","h-[var(--input-height)] p-[0.875rem]","text-16 leading-none text-[var(--color-text)]","bg-[var(--color-card)] border border-[var(--color-border)] rounded-[var(--radius-md)]","transition-[border-color,box-shadow] duration-200 ease-in-out","cursor-text","placeholder:text-[var(--color-icon-secondary)]","focus:outline-none focus:border-[var(--color-button-blue)]","hover:enabled:border-[var(--color-button-blue)]","disabled:cursor-not-allowed disabled:opacity-50 disabled:pointer-events-none","disabled:[-webkit-text-fill-color:var(--color-text)]"].join(" "),c="border-[var(--color-error)] focus:border-[var(--color-error)] hover:enabled:border-[var(--color-error)]",s="ps-10",i="pe-12",d=["absolute top-1/2 start-3 -translate-y-1/2","flex items-center justify-center","text-[var(--color-icon-secondary)] pointer-events-none"].join(" "),u=["absolute top-1/2 end-3.5 -translate-y-1/2","flex items-center justify-center w-8 h-8 p-0","bg-transparent border-none text-[var(--color-icon-secondary)] cursor-pointer","transition-colors duration-200","hover:text-[var(--color-system-text)]","focus:outline-2 focus:outline-[var(--color-clickable)] focus:outline-offset-2 focus:rounded-sm","focus:not(:focus-visible):outline-none","active:-translate-y-1/2 active:scale-95"].join(" "),f="text-12 leading-none text-[var(--color-grey-07)]",x="text-12 font-normal leading-none text-[var(--color-error)]";export{x as errorStyles,l as fieldContainerStyles,f as helperStyles,a as inputBaseStyles,c as inputErrorStyles,s as inputWithLeftIconStyles,i as inputWithToggleStyles,o as labelRowStyles,r as labelStyles,d as leftIconStyles,u as toggleStyles,n as tooltipContentStyles,t as tooltipTriggerStyles,e as wrapperStyles};
1
+ const e=(e,t,r)=>{if(!e)return.5*t;const n=e.match(/^([\d.]+)(px|rem|em)?/);if(!n)return.5*t;const a=parseFloat(n[1]);switch(n[2]||"px"){case"px":return a;case"rem":return a*t;case"em":return a*r;default:return.5*t}},t=(e,t,r,n,a)=>{let s=0,c=0;for(let u=0;u<e.length;u++){const f=e[u],l=t.get(f.value)||0;if(0===l){c++;break}const o=s+(u>0?n:0)+l;if(u<e.length-1){if(o+n+a>r&&c>0)break}else if(o>r&&c>0)break;s=o,c++}return Math.max(1,c)};export{t as calculateFittingChips,e as parseGapValue};
package/dist/index15.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),a=require("react-dom"),r=require("./index67.cjs"),o=require("@adam-milo/icons"),s=require("./index69.cjs"),n=require("./index79.cjs"),l=require("./index81.cjs"),i={name:"United States",dialCode:"+1",flag:"🇺🇸",mask:s.defaultPhoneMask},c=(e,t)=>{const a=t.trim().toLocaleLowerCase();if(!a)return!0;const r=a.replace(/\D/g,""),o=e.dialCode.replace(/\D/g,"");return e.name.toLocaleLowerCase().includes(a)||e.code.toLocaleLowerCase().includes(a)||e.dialCode.toLocaleLowerCase().includes(a)||r.length>0&&o.includes(r)},d=t.forwardRef(({label:d,error:u,helperText:h,fullWidth:p=!0,value:y="",onChange:f,countryCode:m,initialCountryCode:g,onCountryChange:x,countries:S,countrySearchPlaceholder:v="Search countries",countrySearchNoResultsText:w="No countries found",enableFormatting:b=!0,maxNationalDigits:$=s.E164_MAX_NATIONAL_DIGITS,onValidationChange:C,disabled:N,required:I,placeholder:L,id:j,"data-cy":D,"data-testid":k,className:E,onFocus:M,onBlur:A,...P},T)=>{const[_,q]=t.useState(!1),[F,R]=t.useState(!1),[W,G]=t.useState(0),[O,z]=t.useState(""),[B,V]=t.useState({top:0,left:0,width:0}),[X,K]=t.useState(()=>m??g??"US"),U=m??X,H=t.useId(),J=j||H,Q=`${J}-error`,Y=`${J}-helper`,Z=`${J}-listbox`,ee=t.useRef(null),te=t.useRef(null),ae=t.useRef(null),re=t.useRef(null),oe=t.useRef(null),se=t.useRef([]),ne=D||"phone-input",le=k||"phone-input",ie=S.find(e=>e.code===U)||S[0]||i,ce=t.useMemo(()=>S.filter(e=>c(e,O)),[S,O]),de=ie.mask??s.defaultPhoneMask,ue=Number.isFinite($)?Math.min(Math.max(Math.floor($),1),s.E164_MAX_NATIONAL_DIGITS):s.E164_MAX_NATIONAL_DIGITS,he=L??de.placeholder,pe=d&&I&&!d.includes("*")?`${d}*`:d,ye=ie.dialCode.replace(/\D/g,"").length,fe=s.getPhoneDigits(y),me=y.startsWith("+")?fe.slice(ye):fe,ge=b?s.formatWithMask(me,de):me,xe=t.useCallback(()=>{if(N)return;z("");const e=S.findIndex(e=>e.code===U);G(0===S.length?-1:Math.max(0,e)),q(!0)},[S,U,N]),Se=t.useCallback(()=>{q(!1),z(""),G(0)},[]);t.useEffect(()=>{_&&oe.current?.focus()},[_]),t.useEffect(()=>{!_||W<0||se.current[W]?.scrollIntoView?.({block:"nearest"})},[W,_]),t.useLayoutEffect(()=>{if(!_||!te.current)return;const e=()=>{if(te.current){const e=te.current.getBoundingClientRect();V({top:e.bottom+8,left:e.left,width:Math.max(e.width,320)})}};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[_]),t.useEffect(()=>{const e=e=>{const t=e.target,a=ee.current?.contains(t),r=ae.current?.contains(t);a||r||Se()};return _&&document.addEventListener("pointerdown",e),()=>{document.removeEventListener("pointerdown",e)}},[Se,_]),t.useEffect(()=>{if(!_)return;const e=ae.current;if(!e)return;const t=e=>e.stopPropagation(),a={passive:!1};return e.addEventListener("touchmove",t,a),e.addEventListener("wheel",t,a),()=>{e.removeEventListener("touchmove",t),e.removeEventListener("wheel",t)}},[_]);const ve=t.useCallback(e=>{void 0===m&&K(e.code),x?.(e);const t=s.getPhoneDigits(y),a=ie.dialCode.replace(/\D/g,"").length,r=y.startsWith("+")?t.slice(a):t;f?.(`${e.dialCode}${r}`),Se(),setTimeout(()=>{const e=ee.current?.querySelector("input");e?.focus()},0)},[Se,m,x,f,y,ie.dialCode]),we=t.useCallback(e=>{switch(e.key){case"ArrowDown":e.preventDefault(),G(e=>0===ce.length?-1:Math.min(e+1,ce.length-1));break;case"ArrowUp":e.preventDefault(),G(e=>0===ce.length?-1:Math.max(e-1,0));break;case"Enter":W>=0&&ce[W]&&(e.preventDefault(),ve(ce[W]));break;case"Escape":e.preventDefault(),Se(),re.current?.focus();break;case"Tab":Se()}},[Se,ce,W,ve]),be=N?"disabled":u?"error":F||_?"focus":"idle";return e.jsxs("div",{ref:ee,className:r.cn(l.wrapperStyles,p&&l.wrapperFullWidthStyles),"data-cy":`${ne}-wrapper`,"data-testid":`${le}-wrapper`,children:[d&&e.jsx("label",{htmlFor:J,className:l.labelStyles,"data-cy":`${ne}-label`,"data-testid":`${le}-label`,children:pe}),e.jsxs("div",{ref:te,className:r.cn(l.containerBaseStyles,p&&l.containerFullWidthStyles,"focus"===be&&l.containerFocusStyles,"error"===be&&l.containerErrorStyles,"disabled"===be&&l.containerDisabledStyles,"idle"===be&&l.containerIdleStyles),"data-state":be,"data-cy":`${ne}-container`,"data-testid":`${le}-container`,children:[e.jsxs("button",{ref:re,type:"button",className:l.triggerStyles,onClick:()=>_?Se():xe(),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key&&"ArrowDown"!==e.key||(e.preventDefault(),xe())},disabled:N,"aria-haspopup":"listbox","aria-expanded":_,"aria-controls":Z,"aria-label":`Select country. Current: ${ie.name}`,"data-cy":`${ne}-country-trigger`,"data-testid":`${le}-country-trigger`,children:[e.jsx(n.CountryFlag,{flag:ie.flag,className:l.flagStyles,"data-cy":`${ne}-flag`,"data-testid":`${le}-flag`}),e.jsx(o.Icon,{name:"ChevronDownIcon",size:"sm",color:F||_?"clickable":"text",decorative:!0,"data-cy":`${ne}-chevron`})]}),e.jsx("span",{className:l.dialCodeStyles,"data-cy":`${ne}-dial-code`,"data-testid":`${le}-dial-code`,children:ie.dialCode}),e.jsx("input",{ref:T,id:J,type:"tel",inputMode:"numeric",value:ge,onChange:e=>{const t=e.target.value,a=(b?s.getPhoneDigits(t):t.replace(/[^0-9]/g,"")).slice(0,ue);f?.(`${ie.dialCode}${a}`),C?.(a.length>0)},onFocus:e=>{R(!0),M?.(e)},onBlur:e=>{R(!1),A?.(e)},placeholder:he,disabled:N,required:I,className:r.cn(l.inputStyles,E),"aria-invalid":u?"true":"false","aria-required":I?"true":void 0,"aria-describedby":u?Q:h?Y:void 0,"data-cy":ne,"data-testid":le,...P})]}),_&&a.createPortal(e.jsxs("div",{ref:ae,className:l.dropdownStyles,style:{top:B.top,left:B.left,width:B.width,minWidth:"20rem"},"data-cy":`${ne}-dropdown`,"data-testid":`${le}-dropdown`,children:[e.jsxs("div",{className:l.searchWrapperStyles,children:[e.jsx("span",{className:l.searchIconStyles,children:e.jsx(o.Icon,{name:"MagnifyingGlassIcon",size:"sm",color:"icon-secondary",decorative:!0})}),e.jsx("input",{ref:oe,type:"text",role:"combobox",className:l.searchInputStyles,value:O,onChange:e=>{const t=e.target.value;z(t);const a=S.filter(e=>c(e,t));G(a.length>0?0:-1)},onKeyDown:we,placeholder:v,"aria-label":v,"aria-autocomplete":"list","aria-expanded":"true","aria-controls":Z,"aria-activedescendant":W>=0&&ce[W]?`${Z}-option-${ce[W].code.toLowerCase()}`:void 0,"data-cy":`${ne}-country-search`,"data-testid":`${le}-country-search`}),O&&e.jsx("button",{type:"button",className:l.clearSearchStyles,onClick:()=>{z(""),G(S.length>0?0:-1),oe.current?.focus()},"aria-label":"Clear search","data-cy":`${ne}-country-search-clear`,"data-testid":`${le}-country-search-clear`,children:e.jsx(o.Icon,{name:"Cross2Icon",size:"sm",color:"icon-secondary",decorative:!0})})]}),e.jsx("div",{id:Z,role:"listbox","aria-label":"Select country",className:l.dropdownViewportStyles,"data-cy":`${ne}-country-list`,"data-testid":`${le}-country-list`,children:0===ce.length?e.jsx("div",{role:"status","aria-live":"polite",className:l.noResultsStyles,"data-cy":`${ne}-country-no-results`,"data-testid":`${le}-country-no-results`,children:w}):ce.map((t,a)=>e.jsxs("div",{ref:e=>{se.current[a]=e},id:`${Z}-option-${t.code.toLowerCase()}`,role:"option",tabIndex:-1,"aria-selected":t.code===U,className:r.cn(l.optionBaseStyles,a===W&&l.optionHighlightedStyles,t.code===U&&l.optionSelectedStyles),onClick:()=>ve(t),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),ve(t))},onMouseEnter:()=>G(a),"data-cy":`${ne}-option-${t.code.toLowerCase()}`,"data-testid":`${le}-option-${t.code.toLowerCase()}`,children:[e.jsx(n.CountryFlag,{flag:t.flag,className:l.optionFlagStyles}),e.jsx("span",{className:l.optionNameStyles,children:t.name}),e.jsx("span",{className:l.optionDialCodeStyles,children:t.dialCode})]},t.code))})]}),document.body),u&&e.jsx("span",{id:Q,className:l.errorStyles,role:"alert","data-cy":`${ne}-error`,"data-testid":`${le}-error`,children:u}),h&&!u&&e.jsx("span",{id:Y,className:l.helperStyles,"data-cy":`${ne}-helper`,"data-testid":`${le}-helper`,children:h})]})});d.displayName="PhoneInput",exports.E164_MAX_NATIONAL_DIGITS=s.E164_MAX_NATIONAL_DIGITS,exports.defaultPhoneMask=s.defaultPhoneMask,exports.formatWithMask=s.formatWithMask,exports.getPhoneDigits=s.getPhoneDigits,exports.isValidPhoneLength=s.isValidPhoneLength,exports.PhoneInput=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),a=require("react-dom"),r=require("./index67.cjs"),o=require("@adam-milo/icons"),s=require("./index69.cjs"),n=require("./index79.cjs"),l=require("./index81.cjs"),i={name:"United States",dialCode:"+1",flag:"🇺🇸",mask:s.defaultPhoneMask},c=(e,t)=>{const a=t.trim().toLocaleLowerCase();if(!a)return!0;const r=a.replace(/\D/g,""),o=e.dialCode.replace(/\D/g,"");return e.name.toLocaleLowerCase().includes(a)||e.code.toLocaleLowerCase().includes(a)||e.dialCode.toLocaleLowerCase().includes(a)||r.length>0&&o.includes(r)},d=t.forwardRef(({label:d,error:u,helperText:h,fullWidth:p=!0,value:y="",onChange:f,countryCode:m,initialCountryCode:g,onCountryChange:x,countries:S,countrySearchPlaceholder:v="Search countries",countrySearchNoResultsText:w="No countries found",enableFormatting:b=!0,maxNationalDigits:$=s.E164_MAX_NATIONAL_DIGITS,onValidationChange:C,disabled:N,required:j,placeholder:L,id:k,"data-cy":D,"data-testid":I,className:E,onFocus:M,onBlur:P,...A},T)=>{const[q,_]=t.useState(!1),[F,R]=t.useState(!1),[W,z]=t.useState(0),[B,G]=t.useState(""),[O,V]=t.useState({top:0,left:0,width:0}),[X,K]=t.useState(()=>m??g??"US"),U=m??X,H=t.useId(),J=k||H,Q=`${J}-error`,Y=`${J}-helper`,Z=`${J}-listbox`,ee=t.useRef(null),te=t.useRef(null),ae=t.useRef(null),re=t.useRef(null),oe=t.useRef(null),se=t.useRef([]),ne=D||"phone-input",le=I||"phone-input",ie=S.find(e=>e.code===U)||S[0]||i,ce=t.useMemo(()=>S.filter(e=>c(e,B)),[S,B]),de=ie.mask??s.defaultPhoneMask,ue=Number.isFinite($)?Math.max(Math.floor($),1):s.E164_MAX_NATIONAL_DIGITS,he=L??de.placeholder,pe=d&&j&&!d.includes("*")?`${d}*`:d,ye=ie.dialCode.replace(/\D/g,"").length,fe=s.getPhoneDigits(y),me=y.startsWith("+")?fe.slice(ye):fe,ge=b?s.formatWithMask(me,de,ue):me,xe=t.useCallback(()=>{if(N)return;G("");const e=S.findIndex(e=>e.code===U);z(0===S.length?-1:Math.max(0,e)),_(!0)},[S,U,N]),Se=t.useCallback(()=>{_(!1),G(""),z(0)},[]);t.useEffect(()=>{q&&oe.current?.focus()},[q]),t.useEffect(()=>{!q||W<0||se.current[W]?.scrollIntoView?.({block:"nearest"})},[W,q]),t.useLayoutEffect(()=>{if(!q||!te.current)return;const e=()=>{if(te.current){const e=te.current.getBoundingClientRect();V({top:e.bottom+8,left:e.left,width:Math.max(e.width,320)})}};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[q]),t.useEffect(()=>{const e=e=>{const t=e.target,a=ee.current?.contains(t),r=ae.current?.contains(t);a||r||Se()};return q&&document.addEventListener("pointerdown",e),()=>{document.removeEventListener("pointerdown",e)}},[Se,q]),t.useEffect(()=>{if(!q)return;const e=ae.current;if(!e)return;const t=e=>e.stopPropagation(),a={passive:!1};return e.addEventListener("touchmove",t,a),e.addEventListener("wheel",t,a),()=>{e.removeEventListener("touchmove",t),e.removeEventListener("wheel",t)}},[q]);const ve=t.useCallback(e=>{void 0===m&&K(e.code),x?.(e);const t=s.getPhoneDigits(y),a=ie.dialCode.replace(/\D/g,"").length,r=y.startsWith("+")?t.slice(a):t;f?.(`${e.dialCode}${r}`),Se(),setTimeout(()=>{const e=ee.current?.querySelector("input");e?.focus()},0)},[Se,m,x,f,y,ie.dialCode]),we=t.useCallback(e=>{switch(e.key){case"ArrowDown":e.preventDefault(),z(e=>0===ce.length?-1:Math.min(e+1,ce.length-1));break;case"ArrowUp":e.preventDefault(),z(e=>0===ce.length?-1:Math.max(e-1,0));break;case"Enter":W>=0&&ce[W]&&(e.preventDefault(),ve(ce[W]));break;case"Escape":e.preventDefault(),Se(),re.current?.focus();break;case"Tab":Se()}},[Se,ce,W,ve]),be=N?"disabled":u?"error":F||q?"focus":"idle";return e.jsxs("div",{ref:ee,className:r.cn(l.wrapperStyles,p&&l.wrapperFullWidthStyles),"data-cy":`${ne}-wrapper`,"data-testid":`${le}-wrapper`,children:[d&&e.jsx("label",{htmlFor:J,className:l.labelStyles,"data-cy":`${ne}-label`,"data-testid":`${le}-label`,children:pe}),e.jsxs("div",{ref:te,className:r.cn(l.containerBaseStyles,p&&l.containerFullWidthStyles,"focus"===be&&l.containerFocusStyles,"error"===be&&l.containerErrorStyles,"disabled"===be&&l.containerDisabledStyles,"idle"===be&&l.containerIdleStyles),"data-state":be,"data-cy":`${ne}-container`,"data-testid":`${le}-container`,children:[e.jsxs("button",{ref:re,type:"button",className:l.triggerStyles,onClick:()=>q?Se():xe(),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key&&"ArrowDown"!==e.key||(e.preventDefault(),xe())},disabled:N,"aria-haspopup":"listbox","aria-expanded":q,"aria-controls":Z,"aria-label":`Select country. Current: ${ie.name}`,"data-cy":`${ne}-country-trigger`,"data-testid":`${le}-country-trigger`,children:[e.jsx(n.CountryFlag,{flag:ie.flag,className:l.flagStyles,"data-cy":`${ne}-flag`,"data-testid":`${le}-flag`}),e.jsx(o.Icon,{name:"ChevronDownIcon",size:"sm",color:F||q?"clickable":"text",decorative:!0,"data-cy":`${ne}-chevron`})]}),e.jsx("span",{className:l.dialCodeStyles,"data-cy":`${ne}-dial-code`,"data-testid":`${le}-dial-code`,children:ie.dialCode}),e.jsx("input",{ref:T,id:J,type:"tel",inputMode:"numeric",value:ge,onChange:e=>{const t=e.target.value,a=(b?s.getPhoneDigits(t):t.replace(/[^0-9]/g,"")).slice(0,ue);f?.(`${ie.dialCode}${a}`),C?.(a.length>0)},onFocus:e=>{R(!0),M?.(e)},onBlur:e=>{R(!1),P?.(e)},placeholder:he,disabled:N,required:j,className:r.cn(l.inputStyles,E),"aria-invalid":u?"true":"false","aria-required":j?"true":void 0,"aria-describedby":u?Q:h?Y:void 0,"data-cy":ne,"data-testid":le,...A})]}),q&&a.createPortal(e.jsxs("div",{ref:ae,className:l.dropdownStyles,style:{top:O.top,left:O.left,width:O.width,minWidth:"20rem"},"data-cy":`${ne}-dropdown`,"data-testid":`${le}-dropdown`,children:[e.jsxs("div",{className:l.searchWrapperStyles,children:[e.jsx("span",{className:l.searchIconStyles,children:e.jsx(o.Icon,{name:"MagnifyingGlassIcon",size:"sm",color:"icon-secondary",decorative:!0})}),e.jsx("input",{ref:oe,type:"text",role:"combobox",className:l.searchInputStyles,value:B,onChange:e=>{const t=e.target.value;G(t);const a=S.filter(e=>c(e,t));z(a.length>0?0:-1)},onKeyDown:we,placeholder:v,"aria-label":v,"aria-autocomplete":"list","aria-expanded":"true","aria-controls":Z,"aria-activedescendant":W>=0&&ce[W]?`${Z}-option-${ce[W].code.toLowerCase()}`:void 0,"data-cy":`${ne}-country-search`,"data-testid":`${le}-country-search`}),B&&e.jsx("button",{type:"button",className:l.clearSearchStyles,onClick:()=>{G(""),z(S.length>0?0:-1),oe.current?.focus()},"aria-label":"Clear search","data-cy":`${ne}-country-search-clear`,"data-testid":`${le}-country-search-clear`,children:e.jsx(o.Icon,{name:"Cross2Icon",size:"sm",color:"icon-secondary",decorative:!0})})]}),e.jsx("div",{id:Z,role:"listbox","aria-label":"Select country",className:l.dropdownViewportStyles,"data-cy":`${ne}-country-list`,"data-testid":`${le}-country-list`,children:0===ce.length?e.jsx("div",{role:"status","aria-live":"polite",className:l.noResultsStyles,"data-cy":`${ne}-country-no-results`,"data-testid":`${le}-country-no-results`,children:w}):ce.map((t,a)=>e.jsxs("div",{ref:e=>{se.current[a]=e},id:`${Z}-option-${t.code.toLowerCase()}`,role:"option",tabIndex:-1,"aria-selected":t.code===U,className:r.cn(l.optionBaseStyles,a===W&&l.optionHighlightedStyles,t.code===U&&l.optionSelectedStyles),onClick:()=>ve(t),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),ve(t))},onMouseEnter:()=>z(a),"data-cy":`${ne}-option-${t.code.toLowerCase()}`,"data-testid":`${le}-option-${t.code.toLowerCase()}`,children:[e.jsx(n.CountryFlag,{flag:t.flag,className:l.optionFlagStyles}),e.jsx("span",{className:l.optionNameStyles,children:t.name}),e.jsx("span",{className:l.optionDialCodeStyles,children:t.dialCode})]},t.code))})]}),document.body),u&&e.jsx("span",{id:Q,className:l.errorStyles,role:"alert","data-cy":`${ne}-error`,"data-testid":`${le}-error`,children:u}),h&&!u&&e.jsx("span",{id:Y,className:l.helperStyles,"data-cy":`${ne}-helper`,"data-testid":`${le}-helper`,children:h})]})});d.displayName="PhoneInput",exports.E164_MAX_NATIONAL_DIGITS=s.E164_MAX_NATIONAL_DIGITS,exports.defaultPhoneMask=s.defaultPhoneMask,exports.formatWithMask=s.formatWithMask,exports.getPhoneDigits=s.getPhoneDigits,exports.isValidPhoneLength=s.isValidPhoneLength,exports.PhoneInput=d;
package/dist/index15.js CHANGED
@@ -1,4 +1,4 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{forwardRef as a,useState as r,useId as o,useRef as n,useMemo as i,useCallback as l,useEffect as c,useLayoutEffect as d}from"react";import{createPortal as s}from"react-dom";import{cn as u}from"./index67.js";import{Icon as m}from"@adam-milo/icons";import{defaultPhoneMask as p,getPhoneDigits as h,formatWithMask as f,E164_MAX_NATIONAL_DIGITS as y}from"./index69.js";import{isValidPhoneLength as v}from"./index69.js";import{CountryFlag as $}from"./index79.js";import{labelStyles as g,triggerStyles as w,flagStyles as b,dialCodeStyles as C,dropdownStyles as N,searchWrapperStyles as x,searchIconStyles as L,searchInputStyles as k,clearSearchStyles as D,dropdownViewportStyles as E,noResultsStyles as M,optionFlagStyles as S,optionNameStyles as I,optionDialCodeStyles as j,optionSelectedStyles as z,optionHighlightedStyles as F,optionBaseStyles as q,errorStyles as T,helperStyles as W,inputStyles as A,containerIdleStyles as B,containerDisabledStyles as K,containerErrorStyles as P,containerFocusStyles as U,containerFullWidthStyles as R,containerBaseStyles as V,wrapperFullWidthStyles as G,wrapperStyles as H}from"./index81.js";const J={name:"United States",dialCode:"+1",flag:"🇺🇸",mask:p},O=(e,t)=>{const a=t.trim().toLocaleLowerCase();if(!a)return!0;const r=a.replace(/\D/g,""),o=e.dialCode.replace(/\D/g,"");return e.name.toLocaleLowerCase().includes(a)||e.code.toLocaleLowerCase().includes(a)||e.dialCode.toLocaleLowerCase().includes(a)||r.length>0&&o.includes(r)},Q=a(({label:a,error:v,helperText:Q,fullWidth:X=!0,value:Y="",onChange:Z,countryCode:_,initialCountryCode:ee,onCountryChange:te,countries:ae,countrySearchPlaceholder:re="Search countries",countrySearchNoResultsText:oe="No countries found",enableFormatting:ne=!0,maxNationalDigits:ie=y,onValidationChange:le,disabled:ce,required:de,placeholder:se,id:ue,"data-cy":me,"data-testid":pe,className:he,onFocus:fe,onBlur:ye,...ve},$e)=>{const[ge,we]=r(!1),[be,Ce]=r(!1),[Ne,xe]=r(0),[Le,ke]=r(""),[De,Ee]=r({top:0,left:0,width:0}),[Me,Se]=r(()=>_??ee??"US"),Ie=_??Me,je=o(),ze=ue||je,Fe=`${ze}-error`,qe=`${ze}-helper`,Te=`${ze}-listbox`,We=n(null),Ae=n(null),Be=n(null),Ke=n(null),Pe=n(null),Ue=n([]),Re=me||"phone-input",Ve=pe||"phone-input",Ge=ae.find(e=>e.code===Ie)||ae[0]||J,He=i(()=>ae.filter(e=>O(e,Le)),[ae,Le]),Je=Ge.mask??p,Oe=Number.isFinite(ie)?Math.min(Math.max(Math.floor(ie),1),y):y,Qe=se??Je.placeholder,Xe=a&&de&&!a.includes("*")?`${a}*`:a,Ye=Ge.dialCode.replace(/\D/g,"").length,Ze=h(Y),_e=Y.startsWith("+")?Ze.slice(Ye):Ze,et=ne?f(_e,Je):_e,tt=l(()=>{if(ce)return;ke("");const e=ae.findIndex(e=>e.code===Ie);xe(0===ae.length?-1:Math.max(0,e)),we(!0)},[ae,Ie,ce]),at=l(()=>{we(!1),ke(""),xe(0)},[]);c(()=>{ge&&Pe.current?.focus()},[ge]),c(()=>{!ge||Ne<0||Ue.current[Ne]?.scrollIntoView?.({block:"nearest"})},[Ne,ge]),d(()=>{if(!ge||!Ae.current)return;const e=()=>{if(Ae.current){const e=Ae.current.getBoundingClientRect();Ee({top:e.bottom+8,left:e.left,width:Math.max(e.width,320)})}};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[ge]),c(()=>{const e=e=>{const t=e.target,a=We.current?.contains(t),r=Be.current?.contains(t);a||r||at()};return ge&&document.addEventListener("pointerdown",e),()=>{document.removeEventListener("pointerdown",e)}},[at,ge]),c(()=>{if(!ge)return;const e=Be.current;if(!e)return;const t=e=>e.stopPropagation(),a={passive:!1};return e.addEventListener("touchmove",t,a),e.addEventListener("wheel",t,a),()=>{e.removeEventListener("touchmove",t),e.removeEventListener("wheel",t)}},[ge]);const rt=l(e=>{void 0===_&&Se(e.code),te?.(e);const t=h(Y),a=Ge.dialCode.replace(/\D/g,"").length,r=Y.startsWith("+")?t.slice(a):t;Z?.(`${e.dialCode}${r}`),at(),setTimeout(()=>{const e=We.current?.querySelector("input");e?.focus()},0)},[at,_,te,Z,Y,Ge.dialCode]),ot=l(e=>{switch(e.key){case"ArrowDown":e.preventDefault(),xe(e=>0===He.length?-1:Math.min(e+1,He.length-1));break;case"ArrowUp":e.preventDefault(),xe(e=>0===He.length?-1:Math.max(e-1,0));break;case"Enter":Ne>=0&&He[Ne]&&(e.preventDefault(),rt(He[Ne]));break;case"Escape":e.preventDefault(),at(),Ke.current?.focus();break;case"Tab":at()}},[at,He,Ne,rt]),nt=ce?"disabled":v?"error":be||ge?"focus":"idle";/* @__PURE__ */
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{forwardRef as a,useState as r,useId as o,useRef as n,useMemo as i,useCallback as l,useEffect as c,useLayoutEffect as d}from"react";import{createPortal as s}from"react-dom";import{cn as u}from"./index67.js";import{Icon as m}from"@adam-milo/icons";import{defaultPhoneMask as p,getPhoneDigits as h,formatWithMask as f,E164_MAX_NATIONAL_DIGITS as y}from"./index69.js";import{isValidPhoneLength as v}from"./index69.js";import{CountryFlag as $}from"./index79.js";import{labelStyles as g,triggerStyles as w,flagStyles as b,dialCodeStyles as C,dropdownStyles as N,searchWrapperStyles as x,searchIconStyles as L,searchInputStyles as k,clearSearchStyles as D,dropdownViewportStyles as E,noResultsStyles as M,optionFlagStyles as S,optionNameStyles as I,optionDialCodeStyles as j,optionSelectedStyles as z,optionHighlightedStyles as F,optionBaseStyles as q,errorStyles as T,helperStyles as W,inputStyles as A,containerIdleStyles as B,containerDisabledStyles as K,containerErrorStyles as P,containerFocusStyles as U,containerFullWidthStyles as R,containerBaseStyles as V,wrapperFullWidthStyles as G,wrapperStyles as H}from"./index81.js";const J={name:"United States",dialCode:"+1",flag:"🇺🇸",mask:p},O=(e,t)=>{const a=t.trim().toLocaleLowerCase();if(!a)return!0;const r=a.replace(/\D/g,""),o=e.dialCode.replace(/\D/g,"");return e.name.toLocaleLowerCase().includes(a)||e.code.toLocaleLowerCase().includes(a)||e.dialCode.toLocaleLowerCase().includes(a)||r.length>0&&o.includes(r)},Q=a(({label:a,error:v,helperText:Q,fullWidth:X=!0,value:Y="",onChange:Z,countryCode:_,initialCountryCode:ee,onCountryChange:te,countries:ae,countrySearchPlaceholder:re="Search countries",countrySearchNoResultsText:oe="No countries found",enableFormatting:ne=!0,maxNationalDigits:ie=y,onValidationChange:le,disabled:ce,required:de,placeholder:se,id:ue,"data-cy":me,"data-testid":pe,className:he,onFocus:fe,onBlur:ye,...ve},$e)=>{const[ge,we]=r(!1),[be,Ce]=r(!1),[Ne,xe]=r(0),[Le,ke]=r(""),[De,Ee]=r({top:0,left:0,width:0}),[Me,Se]=r(()=>_??ee??"US"),Ie=_??Me,je=o(),ze=ue||je,Fe=`${ze}-error`,qe=`${ze}-helper`,Te=`${ze}-listbox`,We=n(null),Ae=n(null),Be=n(null),Ke=n(null),Pe=n(null),Ue=n([]),Re=me||"phone-input",Ve=pe||"phone-input",Ge=ae.find(e=>e.code===Ie)||ae[0]||J,He=i(()=>ae.filter(e=>O(e,Le)),[ae,Le]),Je=Ge.mask??p,Oe=Number.isFinite(ie)?Math.max(Math.floor(ie),1):y,Qe=se??Je.placeholder,Xe=a&&de&&!a.includes("*")?`${a}*`:a,Ye=Ge.dialCode.replace(/\D/g,"").length,Ze=h(Y),_e=Y.startsWith("+")?Ze.slice(Ye):Ze,et=ne?f(_e,Je,Oe):_e,tt=l(()=>{if(ce)return;ke("");const e=ae.findIndex(e=>e.code===Ie);xe(0===ae.length?-1:Math.max(0,e)),we(!0)},[ae,Ie,ce]),at=l(()=>{we(!1),ke(""),xe(0)},[]);c(()=>{ge&&Pe.current?.focus()},[ge]),c(()=>{!ge||Ne<0||Ue.current[Ne]?.scrollIntoView?.({block:"nearest"})},[Ne,ge]),d(()=>{if(!ge||!Ae.current)return;const e=()=>{if(Ae.current){const e=Ae.current.getBoundingClientRect();Ee({top:e.bottom+8,left:e.left,width:Math.max(e.width,320)})}};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[ge]),c(()=>{const e=e=>{const t=e.target,a=We.current?.contains(t),r=Be.current?.contains(t);a||r||at()};return ge&&document.addEventListener("pointerdown",e),()=>{document.removeEventListener("pointerdown",e)}},[at,ge]),c(()=>{if(!ge)return;const e=Be.current;if(!e)return;const t=e=>e.stopPropagation(),a={passive:!1};return e.addEventListener("touchmove",t,a),e.addEventListener("wheel",t,a),()=>{e.removeEventListener("touchmove",t),e.removeEventListener("wheel",t)}},[ge]);const rt=l(e=>{void 0===_&&Se(e.code),te?.(e);const t=h(Y),a=Ge.dialCode.replace(/\D/g,"").length,r=Y.startsWith("+")?t.slice(a):t;Z?.(`${e.dialCode}${r}`),at(),setTimeout(()=>{const e=We.current?.querySelector("input");e?.focus()},0)},[at,_,te,Z,Y,Ge.dialCode]),ot=l(e=>{switch(e.key){case"ArrowDown":e.preventDefault(),xe(e=>0===He.length?-1:Math.min(e+1,He.length-1));break;case"ArrowUp":e.preventDefault(),xe(e=>0===He.length?-1:Math.max(e-1,0));break;case"Enter":Ne>=0&&He[Ne]&&(e.preventDefault(),rt(He[Ne]));break;case"Escape":e.preventDefault(),at(),Ke.current?.focus();break;case"Tab":at()}},[at,He,Ne,rt]),nt=ce?"disabled":v?"error":be||ge?"focus":"idle";/* @__PURE__ */
2
2
  return e("div",{ref:We,className:u(H,X&&G),"data-cy":`${Re}-wrapper`,"data-testid":`${Ve}-wrapper`,children:[a&&/* @__PURE__ */t("label",{htmlFor:ze,className:g,"data-cy":`${Re}-label`,"data-testid":`${Ve}-label`,children:Xe}),
3
3
  /* @__PURE__ */e("div",{ref:Ae,className:u(V,X&&R,"focus"===nt&&U,"error"===nt&&P,"disabled"===nt&&K,"idle"===nt&&B),"data-state":nt,"data-cy":`${Re}-container`,"data-testid":`${Ve}-container`,children:[
4
4
  /* @__PURE__ */e("button",{ref:Ke,type:"button",className:w,onClick:()=>ge?at():tt(),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key&&"ArrowDown"!==e.key||(e.preventDefault(),tt())},disabled:ce,"aria-haspopup":"listbox","aria-expanded":ge,"aria-controls":Te,"aria-label":`Select country. Current: ${Ge.name}`,"data-cy":`${Re}-country-trigger`,"data-testid":`${Ve}-country-trigger`,children:[
package/dist/index69.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});exports.E164_MAX_NATIONAL_DIGITS=15,exports.defaultPhoneMask={mask:"### ### ####",placeholder:"123 456 7890",maxLength:10},exports.formatWithMask=function(e,t){const n=e.replace(/\D/g,"").slice(0,15);let r="",o=0;for(let s=0;s<t.mask.length&&o<n.length;s++)"#"===t.mask[s]?(r+=n[o],o++):r+=t.mask[s];return o<n.length&&(r+=n.slice(o)),r},exports.getPhoneDigits=function(e){return e.replace(/\D/g,"")},exports.isValidPhoneLength=function(e,t){const n=e.replace(/\D/g,"");return n.length>0&&n.length<=15};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});exports.E164_MAX_NATIONAL_DIGITS=15,exports.defaultPhoneMask={mask:"### ### ####",placeholder:"123 456 7890",maxLength:10},exports.formatWithMask=function(e,t,n=15){const r=Number.isFinite(n)?Math.max(Math.floor(n),1):15,o=e.replace(/\D/g,"").slice(0,r);let s="",l=0;for(let a=0;a<t.mask.length&&l<o.length;a++)"#"===t.mask[a]?(s+=o[l],l++):s+=t.mask[a];return l<o.length&&(s+=o.slice(l)),s},exports.getPhoneDigits=function(e){return e.replace(/\D/g,"")},exports.isValidPhoneLength=function(e,t){const n=e.replace(/\D/g,"");return n.length>0&&n.length<=15};
package/dist/index69.js CHANGED
@@ -1 +1 @@
1
- const e=15,n={mask:"### ### ####",placeholder:"123 456 7890",maxLength:10};function t(e,n){const t=e.replace(/\D/g,"").slice(0,15);let l="",c=0;for(let r=0;r<n.mask.length&&c<t.length;r++)"#"===n.mask[r]?(l+=t[c],c++):l+=n.mask[r];return c<t.length&&(l+=t.slice(c)),l}function l(e){return e.replace(/\D/g,"")}function c(e,n){const t=e.replace(/\D/g,"");return t.length>0&&t.length<=15}export{e as E164_MAX_NATIONAL_DIGITS,n as defaultPhoneMask,t as formatWithMask,l as getPhoneDigits,c as isValidPhoneLength};
1
+ const e=15,t={mask:"### ### ####",placeholder:"123 456 7890",maxLength:10};function n(e,t,n=15){const l=Number.isFinite(n)?Math.max(Math.floor(n),1):15,r=e.replace(/\D/g,"").slice(0,l);let a="",c=0;for(let o=0;o<t.mask.length&&c<r.length;o++)"#"===t.mask[o]?(a+=r[c],c++):a+=t.mask[o];return c<r.length&&(a+=r.slice(c)),a}function l(e){return e.replace(/\D/g,"")}function r(e,t){const n=e.replace(/\D/g,"");return n.length>0&&n.length<=15}export{e as E164_MAX_NATIONAL_DIGITS,t as defaultPhoneMask,n as formatWithMask,l as getPhoneDigits,r as isValidPhoneLength};
package/dist/index74.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),r=require("./index67.cjs"),s=require("./index85.cjs"),a=require("./index126.cjs"),l=require("./index76.cjs"),n=require("./index87.cjs"),i=t.forwardRef(({type:i="text",label:o,tooltip:c,error:d,helperText:u,fullWidth:h=!1,leftIcon:p,showPasswordToggle:f=!0,showLastChar:g=!0,lastCharDelay:x=500,validate:y,onValidationChange:j,className:v,id:m,onChange:S,onBlur:C,required:N,value:b,"data-cy":k,"data-testid":w,...$},T)=>{const[q,L]=t.useState(!1),[M,R]=t.useState(),[W,E]=t.useState(!1),[I,B]=t.useState(!1),F=t.useRef(!1),[P,z]=t.useState(""),D=t.useRef(""),O=t.useRef(null),V=t.useRef(null),H=l.useMergedRef(T,V),_=t.useId(),A=m||_,G=`${A}-error`,J=`${A}-helper`,K=k||"input",Q=w||"input",U="password"===i,X=U&&f,Y=U&&g&&!q&&void 0===b,Z=U&&(q||Y&&D.current.length>0)?"text":i,ee=o&&N&&!o.includes("*")?`${o} *`:o,te=t.useMemo(()=>n.debounce(e=>{if(y&&F.current){const t=y(e);R(t),j?.(!t)}},300),[y,j]),re=t.useRef(te);t.useEffect(()=>{re.current=te},[te]),t.useEffect(()=>{process.env.NODE_ENV},[U,g,b]),t.useEffect(()=>()=>{O.current&&clearTimeout(O.current),re.current.cancel()},[]);const se=Y&&void 0===b?P:q&&U&&void 0===b?D.current||"":b,ae=d||M,le=$.disabled?"disabled":ae?"error":W?"focus":I?"hover":"idle";return e.jsxs("div",{className:a.wrapperStyles,"data-cy":`${K}-wrapper`,"data-testid":`${Q}-wrapper`,children:[(o||c)&&e.jsxs("div",{className:a.labelRowStyles,children:[o&&e.jsx("label",{htmlFor:A,className:a.labelStyles,"data-cy":`${K}-label`,"data-testid":`${Q}-label`,children:ee}),c&&e.jsx(s.FormTooltip,{content:c,triggerClassName:a.tooltipTriggerStyles,contentClassName:a.tooltipContentStyles,dataCyPrefix:K,dataTestIdPrefix:Q})]}),e.jsxs("div",{className:a.fieldContainerStyles,children:[p&&e.jsx("span",{className:a.leftIconStyles,"data-cy":`${K}-left-icon`,"data-testid":`${Q}-left-icon`,"aria-hidden":"true",children:p}),e.jsx("input",{ref:H,id:A,type:Z,value:se,className:r.cn(a.inputBaseStyles,ae&&a.inputErrorStyles,p&&a.inputWithLeftIconStyles,X&&a.inputWithToggleStyles,v),"aria-invalid":ae?"true":"false","aria-required":N?"true":void 0,"aria-describedby":ae?G:u?J:void 0,"data-cy":K,"data-testid":Q,"data-state":le,onChange:e=>{let t=e.target.value;if(Y){const r=e.target.value,s=D.current,a=P.length;let l;if(0===r.length)l="";else if(r.length>a){const e=r.slice(a);l=s+e}else if(r.length<a)l=s.slice(0,r.length);else{const e=r.slice(-1);l=s.slice(0,-1)+e}D.current=l;const n=l?"•".repeat(l.length-1)+l.slice(-1):"";if(z(n),t=l,S){const t={...e,target:{...e.target,value:l},currentTarget:{...e.currentTarget,value:l}};S(t)}O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{z("•".repeat(l.length))},x)}else S?.(e);F.current&&te(t)},onFocus:e=>{E(!0),$.onFocus?.(e)},onBlur:e=>{if(E(!1),F.current=!0,y){const t=Y?D.current:e.target.value,r=y(t);R(r),j?.(!r)}C?.(e)},onMouseEnter:()=>B(!0),onMouseLeave:()=>B(!1),required:N,...$}),X&&e.jsx("button",{type:"button",className:a.toggleStyles,onClick:()=>{L(e=>!e),setTimeout(()=>V.current?.focus(),0)},"aria-label":q?"Hide password":"Show password","data-cy":`${K}-toggle`,"data-testid":`${Q}-toggle`,children:q?e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M10 4C5.5 4 2 10 2 10s3.5 6 8 6 8-6 8-6-3.5-6-8-6z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),e.jsx("circle",{cx:"10",cy:"10",r:"2.5",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})]}):e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M10 4C5.5 4 2 10 2 10s3.5 6 8 6 8-6 8-6-3.5-6-8-6z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),e.jsx("circle",{cx:"10",cy:"10",r:"2.5",stroke:"currentColor",strokeWidth:"1.5",fill:"none"}),e.jsx("path",{d:"M3 3l14 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})})]}),ae&&e.jsx("span",{id:G,className:a.errorStyles,role:"alert","data-cy":`${K}-error`,"data-testid":`${Q}-error`,children:ae}),u&&!ae&&e.jsx("span",{id:J,className:a.helperStyles,"data-cy":`${K}-helper`,"data-testid":`${Q}-helper`,children:u})]})});i.displayName="Input",exports.Input=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),r=require("./index67.cjs"),s=require("./index85.cjs"),a=require("./index125.cjs"),l=require("./index76.cjs"),n=require("./index87.cjs"),i=t.forwardRef(({type:i="text",label:o,tooltip:c,error:d,helperText:u,fullWidth:h=!1,leftIcon:p,showPasswordToggle:f=!0,showLastChar:g=!0,lastCharDelay:x=500,validate:y,onValidationChange:j,className:v,id:m,onChange:S,onBlur:C,required:N,value:b,"data-cy":k,"data-testid":w,...$},T)=>{const[q,L]=t.useState(!1),[M,R]=t.useState(),[W,E]=t.useState(!1),[I,B]=t.useState(!1),F=t.useRef(!1),[P,z]=t.useState(""),D=t.useRef(""),O=t.useRef(null),V=t.useRef(null),H=l.useMergedRef(T,V),_=t.useId(),A=m||_,G=`${A}-error`,J=`${A}-helper`,K=k||"input",Q=w||"input",U="password"===i,X=U&&f,Y=U&&g&&!q&&void 0===b,Z=U&&(q||Y&&D.current.length>0)?"text":i,ee=o&&N&&!o.includes("*")?`${o} *`:o,te=t.useMemo(()=>n.debounce(e=>{if(y&&F.current){const t=y(e);R(t),j?.(!t)}},300),[y,j]),re=t.useRef(te);t.useEffect(()=>{re.current=te},[te]),t.useEffect(()=>{process.env.NODE_ENV},[U,g,b]),t.useEffect(()=>()=>{O.current&&clearTimeout(O.current),re.current.cancel()},[]);const se=Y&&void 0===b?P:q&&U&&void 0===b?D.current||"":b,ae=d||M,le=$.disabled?"disabled":ae?"error":W?"focus":I?"hover":"idle";return e.jsxs("div",{className:a.wrapperStyles,"data-cy":`${K}-wrapper`,"data-testid":`${Q}-wrapper`,children:[(o||c)&&e.jsxs("div",{className:a.labelRowStyles,children:[o&&e.jsx("label",{htmlFor:A,className:a.labelStyles,"data-cy":`${K}-label`,"data-testid":`${Q}-label`,children:ee}),c&&e.jsx(s.FormTooltip,{content:c,triggerClassName:a.tooltipTriggerStyles,contentClassName:a.tooltipContentStyles,dataCyPrefix:K,dataTestIdPrefix:Q})]}),e.jsxs("div",{className:a.fieldContainerStyles,children:[p&&e.jsx("span",{className:a.leftIconStyles,"data-cy":`${K}-left-icon`,"data-testid":`${Q}-left-icon`,"aria-hidden":"true",children:p}),e.jsx("input",{ref:H,id:A,type:Z,value:se,className:r.cn(a.inputBaseStyles,ae&&a.inputErrorStyles,p&&a.inputWithLeftIconStyles,X&&a.inputWithToggleStyles,v),"aria-invalid":ae?"true":"false","aria-required":N?"true":void 0,"aria-describedby":ae?G:u?J:void 0,"data-cy":K,"data-testid":Q,"data-state":le,onChange:e=>{let t=e.target.value;if(Y){const r=e.target.value,s=D.current,a=P.length;let l;if(0===r.length)l="";else if(r.length>a){const e=r.slice(a);l=s+e}else if(r.length<a)l=s.slice(0,r.length);else{const e=r.slice(-1);l=s.slice(0,-1)+e}D.current=l;const n=l?"•".repeat(l.length-1)+l.slice(-1):"";if(z(n),t=l,S){const t={...e,target:{...e.target,value:l},currentTarget:{...e.currentTarget,value:l}};S(t)}O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{z("•".repeat(l.length))},x)}else S?.(e);F.current&&te(t)},onFocus:e=>{E(!0),$.onFocus?.(e)},onBlur:e=>{if(E(!1),F.current=!0,y){const t=Y?D.current:e.target.value,r=y(t);R(r),j?.(!r)}C?.(e)},onMouseEnter:()=>B(!0),onMouseLeave:()=>B(!1),required:N,...$}),X&&e.jsx("button",{type:"button",className:a.toggleStyles,onClick:()=>{L(e=>!e),setTimeout(()=>V.current?.focus(),0)},"aria-label":q?"Hide password":"Show password","data-cy":`${K}-toggle`,"data-testid":`${Q}-toggle`,children:q?e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M10 4C5.5 4 2 10 2 10s3.5 6 8 6 8-6 8-6-3.5-6-8-6z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),e.jsx("circle",{cx:"10",cy:"10",r:"2.5",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})]}):e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M10 4C5.5 4 2 10 2 10s3.5 6 8 6 8-6 8-6-3.5-6-8-6z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),e.jsx("circle",{cx:"10",cy:"10",r:"2.5",stroke:"currentColor",strokeWidth:"1.5",fill:"none"}),e.jsx("path",{d:"M3 3l14 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})})]}),ae&&e.jsx("span",{id:G,className:a.errorStyles,role:"alert","data-cy":`${K}-error`,"data-testid":`${Q}-error`,children:ae}),u&&!ae&&e.jsx("span",{id:J,className:a.helperStyles,"data-cy":`${K}-helper`,"data-testid":`${Q}-helper`,children:u})]})});i.displayName="Input",exports.Input=i;
package/dist/index74.js CHANGED
@@ -1,4 +1,4 @@
1
- import{jsxs as e,jsx as r}from"react/jsx-runtime";import{forwardRef as t,useState as a,useRef as n,useId as o,useMemo as i,useEffect as l}from"react";import{cn as s}from"./index67.js";import{FormTooltip as c}from"./index85.js";import{wrapperStyles as d,labelRowStyles as u,labelStyles as h,tooltipContentStyles as p,tooltipTriggerStyles as m,fieldContainerStyles as f,leftIconStyles as g,inputWithToggleStyles as v,inputWithLeftIconStyles as y,inputErrorStyles as N,inputBaseStyles as k,toggleStyles as x,errorStyles as C,helperStyles as $}from"./index126.js";import{useMergedRef as w}from"./index76.js";import{debounce as b}from"./index87.js";const T=t(({type:t="text",label:T,tooltip:j,error:L,helperText:W,fullWidth:M=!1,leftIcon:B,showPasswordToggle:q=!0,showLastChar:E=!0,lastCharDelay:F=500,validate:I,onValidationChange:P,className:z,id:D,onChange:V,onBlur:H,required:O,value:S,"data-cy":_,"data-testid":A,...G},J)=>{const[K,Q]=a(!1),[R,U]=a(),[X,Y]=a(!1),[Z,ee]=a(!1),re=n(!1),[te,ae]=a(""),ne=n(""),oe=n(null),ie=n(null),le=w(J,ie),se=o(),ce=D||se,de=`${ce}-error`,ue=`${ce}-helper`,he=_||"input",pe=A||"input",me="password"===t,fe=me&&q,ge=me&&E&&!K&&void 0===S,ve=me&&(K||ge&&ne.current.length>0)?"text":t,ye=T&&O&&!T.includes("*")?`${T} *`:T,Ne=i(()=>b(e=>{if(I&&re.current){const r=I(e);U(r),P?.(!r)}},300),[I,P]),ke=n(Ne);l(()=>{ke.current=Ne},[Ne]),l(()=>{process.env.NODE_ENV},[me,E,S]),l(()=>()=>{oe.current&&clearTimeout(oe.current),ke.current.cancel()},[]);const xe=ge&&void 0===S?te:K&&me&&void 0===S?ne.current||"":S,Ce=L||R,$e=G.disabled?"disabled":Ce?"error":X?"focus":Z?"hover":"idle";/* @__PURE__ */
1
+ import{jsxs as e,jsx as r}from"react/jsx-runtime";import{forwardRef as t,useState as a,useRef as n,useId as o,useMemo as i,useEffect as l}from"react";import{cn as s}from"./index67.js";import{FormTooltip as c}from"./index85.js";import{wrapperStyles as d,labelRowStyles as u,labelStyles as h,tooltipContentStyles as p,tooltipTriggerStyles as m,fieldContainerStyles as f,leftIconStyles as g,inputWithToggleStyles as v,inputWithLeftIconStyles as y,inputErrorStyles as N,inputBaseStyles as k,toggleStyles as x,errorStyles as C,helperStyles as $}from"./index125.js";import{useMergedRef as w}from"./index76.js";import{debounce as b}from"./index87.js";const T=t(({type:t="text",label:T,tooltip:j,error:L,helperText:W,fullWidth:M=!1,leftIcon:B,showPasswordToggle:q=!0,showLastChar:E=!0,lastCharDelay:F=500,validate:I,onValidationChange:P,className:z,id:D,onChange:V,onBlur:H,required:O,value:S,"data-cy":_,"data-testid":A,...G},J)=>{const[K,Q]=a(!1),[R,U]=a(),[X,Y]=a(!1),[Z,ee]=a(!1),re=n(!1),[te,ae]=a(""),ne=n(""),oe=n(null),ie=n(null),le=w(J,ie),se=o(),ce=D||se,de=`${ce}-error`,ue=`${ce}-helper`,he=_||"input",pe=A||"input",me="password"===t,fe=me&&q,ge=me&&E&&!K&&void 0===S,ve=me&&(K||ge&&ne.current.length>0)?"text":t,ye=T&&O&&!T.includes("*")?`${T} *`:T,Ne=i(()=>b(e=>{if(I&&re.current){const r=I(e);U(r),P?.(!r)}},300),[I,P]),ke=n(Ne);l(()=>{ke.current=Ne},[Ne]),l(()=>{process.env.NODE_ENV},[me,E,S]),l(()=>()=>{oe.current&&clearTimeout(oe.current),ke.current.cancel()},[]);const xe=ge&&void 0===S?te:K&&me&&void 0===S?ne.current||"":S,Ce=L||R,$e=G.disabled?"disabled":Ce?"error":X?"focus":Z?"hover":"idle";/* @__PURE__ */
2
2
  return e("div",{className:d,"data-cy":`${he}-wrapper`,"data-testid":`${pe}-wrapper`,children:[(T||j)&&/* @__PURE__ */e("div",{className:u,children:[T&&/* @__PURE__ */r("label",{htmlFor:ce,className:h,"data-cy":`${he}-label`,"data-testid":`${pe}-label`,children:ye}),j&&/* @__PURE__ */r(c,{content:j,triggerClassName:m,contentClassName:p,dataCyPrefix:he,dataTestIdPrefix:pe})]}),
3
3
  /* @__PURE__ */e("div",{className:f,children:[B&&/* @__PURE__ */r("span",{className:g,"data-cy":`${he}-left-icon`,"data-testid":`${pe}-left-icon`,"aria-hidden":"true",children:B}),
4
4
  /* @__PURE__ */r("input",{ref:le,id:ce,type:ve,value:xe,className:s(k,Ce&&N,B&&y,fe&&v,z),"aria-invalid":Ce?"true":"false","aria-required":O?"true":void 0,"aria-describedby":Ce?de:W?ue:void 0,"data-cy":he,"data-testid":pe,"data-state":$e,onChange:e=>{let r=e.target.value;if(ge){const t=e.target.value,a=ne.current,n=te.length;let o;if(0===t.length)o="";else if(t.length>n){const e=t.slice(n);o=a+e}else if(t.length<n)o=a.slice(0,t.length);else{const e=t.slice(-1);o=a.slice(0,-1)+e}ne.current=o;const i=o?"•".repeat(o.length-1)+o.slice(-1):"";if(ae(i),r=o,V){const r={...e,target:{...e.target,value:o},currentTarget:{...e.currentTarget,value:o}};V(r)}oe.current&&clearTimeout(oe.current),oe.current=setTimeout(()=>{ae("•".repeat(o.length))},F)}else V?.(e);re.current&&Ne(r)},onFocus:e=>{Y(!0),G.onFocus?.(e)},onBlur:e=>{if(Y(!1),re.current=!0,I){const r=ge?ne.current:e.target.value,t=I(r);U(t),P?.(!t)}H?.(e)},onMouseEnter:()=>ee(!0),onMouseLeave:()=>ee(!1),required:O,...G}),fe&&/* @__PURE__ */r("button",{type:"button",className:x,onClick:()=>{Q(e=>!e),setTimeout(()=>ie.current?.focus(),0)},"aria-label":K?"Hide password":"Show password","data-cy":`${he}-toggle`,"data-testid":`${pe}-toggle`,children:/* @__PURE__ */e("svg",K?{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[
package/dist/index98.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("./index125.cjs");exports.useChipOverflow=(r,n,u,c,s)=>{const[o,l]=e.useState(r.length),i=e.useCallback(()=>{if(void 0!==s)return void l(Math.min(s,r.length));const e=n.current;if(!e)return;const o=e.clientWidth,i=parseFloat(getComputedStyle(document.documentElement).fontSize)||16,a=window.getComputedStyle(e),f=a.gap,h=parseFloat(a.fontSize)||16,d=t.parseGapValue(f,i,h),m=3.75*i;for(let t=0;t<r.length;t++){const e=r[t],n=u.current[t];n&&c.current.set(e.value,n.offsetWidth)}const g=t.calculateFittingChips(r,c.current,o,d,m);l(g)},[r,s,n,u,c]),a=((t,r)=>{const n=e.useRef(null);return e.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]),e.useCallback((...e)=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>t(...e),r)},[t,r])})(i,100);e.useEffect(()=>{u.current.length>r.length&&(u.current=u.current.slice(0,r.length));const e=new Set(r.map(e=>e.value));if(c.current.forEach((t,r)=>{e.has(r)||c.current.delete(r)}),void 0===s){r.some(e=>!c.current.has(e.value))?l(r.length):setTimeout(i,0)}},[r,s,i,u,c]),e.useEffect(()=>{const e=n.current;if(!e)return;const t=new ResizeObserver(()=>{a()});return t.observe(e),setTimeout(i,0),()=>{t.disconnect()}},[i,a,n]);const f=r.slice(0,o),h=r.slice(o);return{visibleCount:o,visibleItems:f,hiddenItems:h,hasOverflow:h.length>0}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("./index126.cjs");exports.useChipOverflow=(r,n,u,c,s)=>{const[o,l]=e.useState(r.length),i=e.useCallback(()=>{if(void 0!==s)return void l(Math.min(s,r.length));const e=n.current;if(!e)return;const o=e.clientWidth,i=parseFloat(getComputedStyle(document.documentElement).fontSize)||16,a=window.getComputedStyle(e),f=a.gap,h=parseFloat(a.fontSize)||16,d=t.parseGapValue(f,i,h),m=3.75*i;for(let t=0;t<r.length;t++){const e=r[t],n=u.current[t];n&&c.current.set(e.value,n.offsetWidth)}const g=t.calculateFittingChips(r,c.current,o,d,m);l(g)},[r,s,n,u,c]),a=((t,r)=>{const n=e.useRef(null);return e.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]),e.useCallback((...e)=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>t(...e),r)},[t,r])})(i,100);e.useEffect(()=>{u.current.length>r.length&&(u.current=u.current.slice(0,r.length));const e=new Set(r.map(e=>e.value));if(c.current.forEach((t,r)=>{e.has(r)||c.current.delete(r)}),void 0===s){r.some(e=>!c.current.has(e.value))?l(r.length):setTimeout(i,0)}},[r,s,i,u,c]),e.useEffect(()=>{const e=n.current;if(!e)return;const t=new ResizeObserver(()=>{a()});return t.observe(e),setTimeout(i,0),()=>{t.disconnect()}},[i,a,n]);const f=r.slice(0,o),h=r.slice(o);return{visibleCount:o,visibleItems:f,hiddenItems:h,hasOverflow:h.length>0}};
package/dist/index98.js CHANGED
@@ -1 +1 @@
1
- import{useState as e,useCallback as t,useEffect as r,useRef as n}from"react";import{parseGapValue as o,calculateFittingChips as c}from"./index125.js";const u=(u,s,i,l,m)=>{const[a,h]=e(u.length),d=t(()=>{if(void 0!==m)return void h(Math.min(m,u.length));const e=s.current;if(!e)return;const t=e.clientWidth,r=parseFloat(getComputedStyle(document.documentElement).fontSize)||16,n=window.getComputedStyle(e),a=n.gap,d=parseFloat(n.fontSize)||16,f=o(a,r,d),g=3.75*r;for(let o=0;o<u.length;o++){const e=u[o],t=i.current[o];t&&l.current.set(e.value,t.offsetWidth)}const v=c(u,l.current,t,f,g);h(v)},[u,m,s,i,l]),f=((e,o)=>{const c=n(null);return r(()=>()=>{c.current&&clearTimeout(c.current)},[]),t((...t)=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>e(...t),o)},[e,o])})(d,100);r(()=>{i.current.length>u.length&&(i.current=i.current.slice(0,u.length));const e=new Set(u.map(e=>e.value));if(l.current.forEach((t,r)=>{e.has(r)||l.current.delete(r)}),void 0===m){u.some(e=>!l.current.has(e.value))?h(u.length):setTimeout(d,0)}},[u,m,d,i,l]),r(()=>{const e=s.current;if(!e)return;const t=new ResizeObserver(()=>{f()});return t.observe(e),setTimeout(d,0),()=>{t.disconnect()}},[d,f,s]);const g=u.slice(0,a),v=u.slice(a);return{visibleCount:a,visibleItems:g,hiddenItems:v,hasOverflow:v.length>0}};export{u as useChipOverflow};
1
+ import{useState as e,useCallback as t,useEffect as r,useRef as n}from"react";import{parseGapValue as o,calculateFittingChips as c}from"./index126.js";const u=(u,s,i,l,m)=>{const[a,h]=e(u.length),d=t(()=>{if(void 0!==m)return void h(Math.min(m,u.length));const e=s.current;if(!e)return;const t=e.clientWidth,r=parseFloat(getComputedStyle(document.documentElement).fontSize)||16,n=window.getComputedStyle(e),a=n.gap,d=parseFloat(n.fontSize)||16,f=o(a,r,d),g=3.75*r;for(let o=0;o<u.length;o++){const e=u[o],t=i.current[o];t&&l.current.set(e.value,t.offsetWidth)}const v=c(u,l.current,t,f,g);h(v)},[u,m,s,i,l]),f=((e,o)=>{const c=n(null);return r(()=>()=>{c.current&&clearTimeout(c.current)},[]),t((...t)=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>e(...t),o)},[e,o])})(d,100);r(()=>{i.current.length>u.length&&(i.current=i.current.slice(0,u.length));const e=new Set(u.map(e=>e.value));if(l.current.forEach((t,r)=>{e.has(r)||l.current.delete(r)}),void 0===m){u.some(e=>!l.current.has(e.value))?h(u.length):setTimeout(d,0)}},[u,m,d,i,l]),r(()=>{const e=s.current;if(!e)return;const t=new ResizeObserver(()=>{f()});return t.observe(e),setTimeout(d,0),()=>{t.disconnect()}},[d,f,s]);const g=u.slice(0,a),v=u.slice(a);return{visibleCount:a,visibleItems:g,hiddenItems:v,hasOverflow:v.length>0}};export{u as useChipOverflow};
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneInput.component.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/phone-input/PhoneInput.component.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAgC1D,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAyBrB,eAAO,MAAM,UAAU,8GAghBtB,CAAC;AAIF,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"PhoneInput.component.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/phone-input/PhoneInput.component.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAgC1D,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAyBrB,eAAO,MAAM,UAAU,8GAihBtB,CAAC;AAIF,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
@@ -20,7 +20,10 @@ export interface PhoneInputProps extends Omit<InputHTMLAttributes<HTMLInputEleme
20
20
  /** Localized message shown when country search has no matches. */
21
21
  countrySearchNoResultsText?: string;
22
22
  enableFormatting?: boolean;
23
- /** Maximum national digits accepted by typing or paste. Defaults to the E.164 cap. */
23
+ /**
24
+ * Maximum national digits accepted by typing or paste.
25
+ * Defaults to the E.164 national cap (15); may be raised above it when needed.
26
+ */
24
27
  maxNationalDigits?: number;
25
28
  /**
26
29
  * Soft signal when national digits are non-empty. Not mask-length or
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneInput.types.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/phone-input/PhoneInput.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAC3C,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,GAAG,OAAO,GAAG,UAAU,CAC9B;IACC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8GAA8G;IAC9G,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,gGAAgG;IAChG,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB,qEAAqE;IACrE,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,kEAAkE;IAClE,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,sFAAsF;IACtF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
1
+ {"version":3,"file":"PhoneInput.types.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/phone-input/PhoneInput.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAC3C,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,GAAG,OAAO,GAAG,UAAU,CAC9B;IACC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8GAA8G;IAC9G,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,gGAAgG;IAChG,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB,qEAAqE;IACrE,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,kEAAkE;IAClE,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
@@ -8,9 +8,9 @@ export declare const defaultPhoneMask: PhoneMask;
8
8
  /**
9
9
  * Format digits using the given mask for display.
10
10
  * Digits beyond the mask’s `#` slots are appended unformatted so longer valid
11
- * numbers remain visible. Caps at {@link E164_MAX_NATIONAL_DIGITS}.
11
+ * numbers remain visible. Caps at `maxDigits` (defaults to {@link E164_MAX_NATIONAL_DIGITS}).
12
12
  */
13
- export declare function formatWithMask(value: string, mask: PhoneMask): string;
13
+ export declare function formatWithMask(value: string, mask: PhoneMask, maxDigits?: number): string;
14
14
  export declare function getPhoneDigits(formattedValue: string): string;
15
15
  /**
16
16
  * Soft length check only — not a substitute for real phone validation.
@@ -1 +1 @@
1
- {"version":3,"file":"countries.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/phone-input/countries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE5D,8FAA8F;AAC9F,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C,2DAA2D;AAC3D,eAAO,MAAM,gBAAgB,EAAE,SAI9B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAqBrE;AAED,wBAAgB,cAAc,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,CAG5E"}
1
+ {"version":3,"file":"countries.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/phone-input/countries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE5D,8FAA8F;AAC9F,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C,2DAA2D;AAC3D,eAAO,MAAM,gBAAgB,EAAE,SAI9B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,SAAS,EACf,SAAS,GAAE,MAAiC,GAC3C,MAAM,CAwBR;AAED,wBAAgB,cAAc,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,CAG5E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adam-milo/ui",
3
- "version": "1.0.139",
3
+ "version": "1.0.140",
4
4
  "type": "module",
5
5
  "description": "Adam Milo Design System - UI Component Library",
6
6
  "keywords": [