@clicktap/ui 0.41.0 → 0.42.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.
- package/components/Accordion/Accordion.js +1 -1
- package/components/Accordion.d.ts +1 -0
- package/components/Accordion.js +1 -0
- package/components/AssetRenderer/renderers/DownloadLink.d.ts +1 -1
- package/components/AssetRenderer/renderers.d.ts +1 -0
- package/components/AssetRenderer/renderers.js +1 -0
- package/components/AssetRenderer.d.ts +1 -0
- package/components/AssetRenderer.js +1 -0
- package/components/Avatar/Avatar.js +1 -1
- package/components/Avatar.d.ts +1 -0
- package/components/Avatar.js +1 -0
- package/components/Badge/Badge.js +1 -1
- package/components/Badge.d.ts +1 -0
- package/components/Badge.js +1 -0
- package/components/Breadcrumbs/BreadcrumbLink.js +1 -1
- package/components/Breadcrumbs.d.ts +1 -0
- package/components/Breadcrumbs.js +1 -0
- package/components/Button/Button.js +1 -1
- package/components/Button/ButtonLoadingContent.js +1 -1
- package/components/Button/index.js +1 -1
- package/components/Button.d.ts +1 -0
- package/components/Button.js +1 -0
- package/components/Card.d.ts +1 -0
- package/components/Card.js +1 -0
- package/components/Checkbox/Checkbox.js +1 -1
- package/components/Checkbox.d.ts +1 -0
- package/components/Checkbox.js +1 -0
- package/components/Collapsible.d.ts +1 -0
- package/components/Collapsible.js +1 -0
- package/components/Collection/AttributeDataProvider.d.ts +1 -0
- package/components/Collection/AttributeDataProvider.js +1 -0
- package/components/Collection/CollectionFilterChips/CollectionFilterChips.js +1 -1
- package/components/Collection/CollectionFilterChips/index.js +1 -1
- package/components/Collection/CollectionFilterChips.d.ts +1 -0
- package/components/Collection/CollectionFilterChips.js +1 -0
- package/components/Collection/CollectionFilters/CollectionFilters.js +1 -1
- package/components/Collection/CollectionFilters/index.js +1 -1
- package/components/Collection/CollectionFilters.d.ts +1 -0
- package/components/Collection/CollectionFilters.js +1 -0
- package/components/Collection/CollectionToolbar/CollectionToolbar.js +1 -1
- package/components/Collection/CollectionToolbar/index.js +1 -1
- package/components/Collection/CollectionToolbar.d.ts +1 -0
- package/components/Collection/CollectionToolbar.js +1 -0
- package/components/Collection/EmptyResults/EmptyResults.js +1 -1
- package/components/Collection/EmptyResults.d.ts +1 -0
- package/components/Collection/EmptyResults.js +1 -0
- package/components/Collection/FilterAccordionTitle/FilterAccordionTitle.js +1 -1
- package/components/Collection/FilterAccordionTitle.d.ts +1 -0
- package/components/Collection/FilterAccordionTitle.js +1 -0
- package/components/Collection/FilterRenderer/Renderer/Boolean.js +1 -1
- package/components/Collection/FilterRenderer/Renderer/Option.js +1 -1
- package/components/Collection/FilterRenderer/Renderer/Range.js +1 -1
- package/components/Collection/FilterRenderer/Renderer/Swatch/SwatchColor.js +1 -1
- package/components/Collection/FilterRenderer/Renderer/Swatch/SwatchImage.js +1 -1
- package/components/Collection/FilterRenderer/Renderer/Swatch/SwatchText.js +1 -1
- package/components/Collection/FilterRenderer/Renderer.d.ts +1 -0
- package/components/Collection/FilterRenderer/Renderer.js +1 -0
- package/components/Collection/FilterRenderer.d.ts +1 -0
- package/components/Collection/FilterRenderer.js +1 -0
- package/components/Collection/ProductCardSwatches/ProductCardSwatches.js +1 -1
- package/components/Collection/ProductCardSwatches.d.ts +1 -0
- package/components/Collection/ProductCardSwatches.js +1 -0
- package/components/Collection/ProductPrice.d.ts +1 -0
- package/components/Collection/ProductPrice.js +1 -0
- package/components/Collection/index.js +1 -1
- package/components/Collection.d.ts +1 -0
- package/components/Collection.js +1 -0
- package/components/Container.d.ts +1 -0
- package/components/Container.js +1 -0
- package/components/ContextMenu/ContextMenu.js +1 -1
- package/components/ContextMenu.d.ts +1 -0
- package/components/ContextMenu.js +1 -0
- package/components/CreditCardExpirationInput/CreditCardExpirationInput.js +1 -1
- package/components/CreditCardExpirationInput.d.ts +1 -0
- package/components/CreditCardExpirationInput.js +1 -0
- package/components/CreditCardInput/CreditCardInput.js +1 -1
- package/components/CreditCardInput.d.ts +1 -0
- package/components/CreditCardInput.js +1 -0
- package/components/DateInput/DateInput.js +1 -1
- package/components/DateInput.d.ts +1 -0
- package/components/DateInput.js +1 -0
- package/components/DateTimeFormat/DateTimeFormat.d.ts +1 -1
- package/components/DateTimeFormat.d.ts +1 -0
- package/components/DateTimeFormat.js +1 -0
- package/components/Dialog/Dialog.js +1 -1
- package/components/Dialog.d.ts +1 -0
- package/components/Dialog.js +1 -0
- package/components/DialogTrigger.d.ts +1 -0
- package/components/DialogTrigger.js +1 -0
- package/components/Divider.d.ts +1 -0
- package/components/Divider.js +1 -0
- package/components/DobInput/DobInput.js +1 -1
- package/components/DobInput.d.ts +1 -0
- package/components/DobInput.js +1 -0
- package/components/Drawer/Drawer.js +1 -1
- package/components/Drawer.d.ts +1 -0
- package/components/Drawer.js +1 -0
- package/components/FeatureGate/AccessDenied.d.ts +2 -2
- package/components/FeatureGate/AccessDenied.js +1 -1
- package/components/FeatureGate/FeatureGate.d.ts +1 -1
- package/components/FeatureGate/FeatureGate.js +1 -1
- package/components/FeatureGate/PermissionRequired.d.ts +1 -1
- package/components/FeatureGate/PermissionRequired.js +1 -1
- package/components/FeatureGate/UpgradePrompt.d.ts +1 -1
- package/components/FeatureGate/UpgradePrompt.js +1 -1
- package/components/Icon/NoEntryIcon.js +1 -1
- package/components/Icon/StarIcon.js +1 -1
- package/components/Icon.d.ts +1 -0
- package/components/Icon.js +1 -0
- package/components/Image/Image.d.ts +44 -3
- package/components/Image/Image.js +1 -1
- package/components/Image/ImageContext.d.ts +30 -0
- package/components/Image/ImageContext.js +1 -0
- package/components/Image/imageShared.d.ts +74 -0
- package/components/Image/imageShared.js +1 -0
- package/components/Image/index.d.ts +3 -1
- package/components/Image/index.js +1 -1
- package/components/Image.d.ts +1 -0
- package/components/Image.js +1 -0
- package/components/Input/Input.js +1 -1
- package/components/Input.d.ts +1 -0
- package/components/Input.js +1 -0
- package/components/Link/Link.js +1 -1
- package/components/Link.d.ts +1 -0
- package/components/Link.js +1 -0
- package/components/LinkAsButton/LinkAsButton.js +1 -1
- package/components/LinkAsButton/index.js +1 -1
- package/components/LinkAsButton.d.ts +1 -0
- package/components/LinkAsButton.js +1 -0
- package/components/Loader/CircularEasing.js +1 -1
- package/components/Loader/Pulse.js +1 -1
- package/components/Loader/index.js +1 -1
- package/components/Loader.d.ts +1 -0
- package/components/Loader.js +1 -0
- package/components/Menu.d.ts +1 -0
- package/components/Menu.js +1 -0
- package/components/Meter/Meter.js +1 -1
- package/components/Meter.d.ts +1 -0
- package/components/Meter.js +1 -0
- package/components/Modal.d.ts +1 -0
- package/components/Modal.js +1 -0
- package/components/ModalOverlay.d.ts +1 -0
- package/components/ModalOverlay.js +1 -0
- package/components/NumberFormat/NumberFormat.d.ts +1 -1
- package/components/NumberFormat.d.ts +1 -0
- package/components/NumberFormat.js +1 -0
- package/components/NumberInput/NumberInput.js +1 -1
- package/components/NumberInput.d.ts +1 -0
- package/components/NumberInput.js +1 -0
- package/components/NumberTicker.d.ts +1 -0
- package/components/NumberTicker.js +1 -0
- package/components/Pagination/Pagination.js +1 -1
- package/components/Pagination.d.ts +1 -0
- package/components/Pagination.js +1 -0
- package/components/PasswordCheck/PasswordCheck.js +1 -1
- package/components/PasswordCheck.d.ts +1 -0
- package/components/PasswordCheck.js +1 -0
- package/components/PhoneInput/PhoneInput.js +1 -1
- package/components/PhoneInput.d.ts +1 -0
- package/components/PhoneInput.js +1 -0
- package/components/PinInput/PinInput.js +1 -1
- package/components/PinInput.d.ts +1 -0
- package/components/PinInput.js +1 -0
- package/components/Progressbar/LinearProgressbar.js +1 -1
- package/components/Progressbar.d.ts +1 -0
- package/components/Progressbar.js +1 -0
- package/components/Radio/Radio.js +1 -1
- package/components/Radio.d.ts +1 -0
- package/components/Radio.js +1 -0
- package/components/RadioGroup/RadioGroup.js +1 -1
- package/components/RadioGroup.d.ts +1 -0
- package/components/RadioGroup.js +1 -0
- package/components/ResendCode.d.ts +1 -0
- package/components/ResendCode.js +1 -0
- package/components/Select/ButtonSelect.js +1 -1
- package/components/Select/ComboBoxSelect.js +1 -1
- package/components/Select/MultiButtonSelect.js +1 -1
- package/components/Select/Select.js +1 -1
- package/components/Select/index.js +1 -1
- package/components/Select/parts.js +1 -1
- package/components/Select.d.ts +1 -0
- package/components/Select.js +1 -0
- package/components/Skeleton.d.ts +1 -0
- package/components/Skeleton.js +1 -0
- package/components/Slider/Slider.js +1 -1
- package/components/Slider.d.ts +1 -0
- package/components/Slider.js +1 -0
- package/components/Switch/Switch.js +1 -1
- package/components/Switch.d.ts +1 -0
- package/components/Switch.js +1 -0
- package/components/Table.d.ts +1 -0
- package/components/Table.js +1 -0
- package/components/Tabs/Tab.js +1 -1
- package/components/Tabs/TabList.js +1 -1
- package/components/Tabs.d.ts +1 -0
- package/components/Tabs.js +1 -0
- package/components/Time.d.ts +1 -0
- package/components/Time.js +1 -0
- package/components/TimeInput/TimeInput.js +1 -1
- package/components/TimeInput.d.ts +1 -0
- package/components/TimeInput.js +1 -0
- package/components/Timezone.d.ts +1 -0
- package/components/Timezone.js +1 -0
- package/components/ToggleButton/ToggleButton.js +1 -1
- package/components/ToggleButton.d.ts +1 -0
- package/components/ToggleButton.js +1 -0
- package/components/Tooltip.d.ts +1 -0
- package/components/Tooltip.js +1 -0
- package/components/UploadImage/UploadImage.js +1 -1
- package/components/UploadImage/index.js +1 -1
- package/components/UploadImage.d.ts +1 -0
- package/components/UploadImage.js +1 -0
- package/docs/migrations/2026/04/2026-04-24-image-placeholder-frontend-fallback.md +3 -3
- package/docs/migrations/2026/04/2026-04-30-prune-invalid-pdp-selections.md +2 -2
- package/docs/migrations/2026/04/2026-04-30-top-down-pdp-option-dependency.md +2 -2
- package/docs/migrations/2026/08/2026-08-04-password-reveal-press-and-hold.md +48 -0
- package/docs/migrations/2026/08/2026-08-06-clicktap-ui-image-next-subpath.md +101 -0
- package/docs/migrations/2026/08/2026-08-06-clicktap-ui-loaders-drop-framer-motion.md +77 -0
- package/docs/migrations/2026/08/2026-08-06-clicktap-ui-semantic-tokens.md +106 -0
- package/docs/migrations/README.md +2 -0
- package/hooks/useCollectionState.d.ts +1 -0
- package/hooks/useCollectionState.js +1 -0
- package/hooks/useRoute/RouteContext.d.ts +8 -0
- package/hooks/useRoute/index.js +1 -1
- package/hooks/useRoute/useRoute.js +1 -1
- package/hooks/useRoute.d.ts +1 -0
- package/hooks/useRoute.js +1 -0
- package/next/Image.d.ts +11 -0
- package/next/Image.js +1 -0
- package/next/index.d.ts +8 -0
- package/next/index.js +1 -0
- package/package.json +62 -6
- package/theme.css +162 -0
- package/utils/collection.d.ts +1 -0
- package/utils/collection.js +1 -0
- package/utils/variantOptions.d.ts +1 -0
- package/utils/variantOptions.js +1 -0
- package/tailwind.config.js +0 -6
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { NumberFormatProps } from './NumberFormat.types';
|
|
2
|
-
export declare function NumberFormat({ locale, style, fallback, children, ...options }: NumberFormatProps): string | number |
|
|
2
|
+
export declare function NumberFormat({ locale, style, fallback, children, ...options }: NumberFormatProps): string | number | boolean | import('react').ReactElement<any, string | import('react').JSXElementConstructor<any>> | Iterable<import('react').ReactNode> | null;
|
|
3
3
|
export default NumberFormat;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NumberFormat/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NumberFormat/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsxs as
|
|
1
|
+
"use client";import{jsxs as u,jsx as e}from"react/jsx-runtime";import{NumberField as p,Label as h,Group as m,Button as a,Input as x,Text as v,FieldError as w}from"react-aria-components";import{cn as r}from"../../utils/cn.js";const k=e("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e("path",{d:"M5 12H19",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),y=e("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e("path",{d:"M12 5V19M5 12H19",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})});function L({label:b,description:n,errorMessage:c,isInvalid:d,isReadOnly:i,slots:s,className:g,classNames:o,...f}){const t=["group-hover:border-border-emphasis","group-disabled:border-border-subtle","group-invalid:border-danger-soft group-invalid:bg-danger-surface group-invalid:text-danger","group-invalid:group-hover:border-danger","group-invalid:group-focus:border-danger"],l=["flex items-center justify-center shrink-0","rounded-md border-solid border","font-semibold text-sm","w-10 h-10 py-0 px-0 cursor-pointer disabled:cursor-default","transition-all duration-200 ease-in-out","focus:outline-2 focus:outline focus:outline-border-subtle pressed:scale-95","bg-transparent hover:bg-transparent focus:bg-transparent disabled:bg-transparent","border-border hover:border-border-emphasis focus:border-border-emphasis disabled:border-border-subtle","text-fg disabled:text-fg-muted","group-aria-readonly:bg-surface-subtle group-aria-readonly:text-fg-muted group-aria-readonly:border-border-subtle group-aria-readonly:cursor-default"];return u(p,{isInvalid:d,isReadOnly:i,className:r("flex flex-col w-full",g),...f,children:[e(h,{className:r("flex text-fg-muted text-sm",o?.label),children:b}),u(m,{isInvalid:d,"aria-readonly":i,className:r("flex rounded-md group","focus-within:outline-2 focus-within:outline focus-within:outline-border-subtle","focus-within:invalid:outline-2 focus-within:invalid:outline focus-within:invalid:outline-border-subtle","disabled:bg-surface-subtle",o?.group),children:[e(a,{slot:"decrement",className:r(l,t,"border-r-0 rounded-r-none",o?.decrementBtn),children:s?.decrementIcon||k}),e(x,{className:r("border-solid border border-border text-center","text-sm text-fg placeholder-fg-subtle","h-10 px-2 py-0 m-0 w-full","bg-white","transition-all duration-200 ease-in-out","hover:border-border-emphasis","focus:outline-0 focus:border-border-emphasis","disabled:border-border-subtle disabled:bg-surface-subtle","invalid:border-danger-soft invalid:bg-danger-surface invalid:text-danger","invalid:hover:border-danger invalid:focus:border-danger",t,o?.input)}),e(a,{slot:"increment",className:r(l,t,"border-l-0 rounded-l-none",o?.incrementBtn),children:s?.incrementIcon||y})]}),n&&e(v,{className:r("flex text-fg-muted text-sm",o?.description),slot:"description",children:n}),e(w,{className:r("flex text-danger-soft text-sm",o?.error),children:c})]})}export{L as NumberInput,L as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NumberInput/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NumberInput/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NumberTicker/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NumberTicker/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as s}from"react/jsx-runtime";import{Pagination as n}from"@heroui/pagination";import{cn as
|
|
1
|
+
"use client";import{jsx as s}from"react/jsx-runtime";import{Pagination as n}from"@heroui/pagination";import{cn as e}from"../../utils/cn.js";const r=e("w-8 h-8 flex justify-center items-center cursor-pointer shadow-none","border border-border-subtle data-[disabled=true]:border-0",'rounded transition-colors duration-300 data-[focus-visible="true"]:outline-white data-[focus-visible="true"]:outline-offset-4',"hover:bg-slate-50 data-[disabled=true]:bg-surface-subtle data-[disabled=true]:text-fg-subtle","[&>svg]:w-4.5 [&>svg]:h-auto");function b({showControls:a=!0,className:o,classNames:t,...i}){return s(n,{showControls:a,className:e("text-slate-600",o),classNames:{wrapper:e("flex flex-nowrap gap-2 lg:gap-3",t?.wrapper),item:e("w-8 h-8 flex text-sm justify-center items-center cursor-pointer rounded shadow-none","border-solid border border-slate-100 bg-transparent transition-colors duration-300",'data-[active=true]:bg-slate-500 data-[active=true]:text-white data-[focus-visible="true"]:outline-white data-[focus-visible="true"]:outline-offset-4',"[&[data-hover=true]:not([data-active=true])]:border-border-subtle",t?.item),prev:e(r,t?.prev),next:e(r,t?.next),ellipsis:e("w-4 h-4.5 scale-110 translate-y-1",t?.ellipsis)},...i})}export{b as Pagination,b as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Pagination/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Pagination/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsxs as n,jsx as t}from"react/jsx-runtime";import{cn as r}from"../../utils/cn.js";import{checkStrength as d,getProgressText as
|
|
1
|
+
"use client";import{jsxs as n,jsx as t}from"react/jsx-runtime";import{cn as r}from"../../utils/cn.js";import{checkStrength as d,getProgressText as c}from"./PasswordCheck.utils.js";const g=[{label:"At least 8 characters",test:s=>s.length>=8},{label:"At least one uppercase letter",test:s=>/[A-Z]/.test(s)},{label:"At least one digit",test:s=>/\d/.test(s)},{label:"At least one special character",test:s=>/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?~]/.test(s)}];function m({value:s,variant:i="default",requirements:o=g}){const e=d(s);return i==="requirements"?s?n("div",{className:"mt-4 flex flex-col gap-2",children:[t("ul",{className:"flex flex-col gap-1 text-xs text-left",children:o.map(a=>{const l=a.test(s);return n("li",{className:"flex items-center gap-1.5",children:[t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:r("shrink-0 transition-colors",l?"text-success":"text-fg-subtle"),children:l?t("path",{d:"M20 6 9 17l-5-5"}):t("circle",{cx:"12",cy:"12",r:"4"})}),t("span",{className:r("transition-colors",l?"text-green-700":"text-fg-muted"),children:a.label})]},a.label)})}),n("div",{className:"flex flex-col",children:[t("div",{className:"w-full flex gap-x-2",children:Array.from({length:5},(a,l)=>l).map((a,l)=>t("div",{className:r("grow shrink basis-1/5 h-1 rounded-full transition-colors duration-700 ease bg-slate-200",e<=l&&"bg-slate-600",(e===1||e===2)&&"bg-danger",e===3&&"bg-warning",e===4&&"bg-success",e===5&&"bg-info")},a))}),n("div",{className:r("inline-flex gap-x-1 text-xs text-fg-strong transition-opacity mt-1",e?"opacity-100":"opacity-0"),children:[t("span",{children:"Password Strength:"}),t("span",{className:r((e===1||e===2)&&"text-danger",e===3&&"text-warning",e===4&&"text-success",e===5&&"text-info"),children:c(e)})]})]})]}):null:t("div",{children:n("div",{className:r("relative w-full flex gap-x-2",i==="default"&&"mb-8 -mt-1"),children:[Array.from({length:5},(a,l)=>l).map((a,l)=>t("div",{className:r("grow shrink basis-1/5 h-1 rounded-full transition-colors duration-700 ease bg-slate-200",e<=l&&"bg-slate-600",(e===1||e===2)&&"bg-danger",e===3&&"bg-warning",e===4&&"bg-success",e===5&&"bg-info")},a)),i==="default"&&n("div",{className:r("inline-flex gap-x-1 absolute top-0 left-0 text-xs translate-y-2/4 text-fg-strong",e?"opacity-100":"opacity-0"),children:[t("span",{children:"Password Strength:"}),t("span",{className:r((e===1||e===2)&&"text-danger",e===3&&"text-warning",e===4&&"text-success",e===5&&"text-info"),children:c(e)})]})]})})}export{m as PasswordCheck,m as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PasswordCheck/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PasswordCheck/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsxs as H,jsx as j}from"react/jsx-runtime";import{useFilter as oe}from"react-aria";import k,{useState as W,useMemo as Z,useRef as _,forwardRef as se,useCallback as I,useImperativeHandle as ue,useEffect as K}from"react";import{DialogTrigger as de,Button as ce,Input as fe,ListBox as pe,ListBoxItem as me}from"react-aria-components";import{cn as J}from"../../utils/cn.js";import{Input as he}from"../Input/Input.js";import"../Skeleton/Skeleton.js";import"../../hooks/useIsClient.js";var R=[["Afghanistan","af","93"],["Albania","al","355"],["Algeria","dz","213"],["Andorra","ad","376"],["Angola","ao","244"],["Antigua and Barbuda","ag","1268"],["Argentina","ar","54",{default:"(..) .... ....","/^11/":"(..) .... ....","/^15/":"(..) ... ....","/^(2|3|4|5)/":"(.) .... ....","/^9/":"(.) .... ....."},0],["Armenia","am","374",".. ......"],["Aruba","aw","297"],["Australia","au","61",{default:". .... ....","/^4/":"... ... ...","/^5(?!50)/":"... ... ...","/^1(3|8)00/":".... ... ...","/^13/":".. .. ..","/^180/":"... ...."},0,[]],["Austria","at","43"],["Azerbaijan","az","994","(..) ... .. .."],["Bahamas","bs","1242"],["Bahrain","bh","973",".... ...."],["Bangladesh","bd","880"],["Barbados","bb","1246"],["Belarus","by","375","(..) ... .. .."],["Belgium","be","32","... .. .. .."],["Belize","bz","501"],["Benin","bj","229"],["Bhutan","bt","975"],["Bolivia","bo","591"],["Bosnia and Herzegovina","ba","387"],["Botswana","bw","267"],["Brazil","br","55","(..) .....-...."],["British Indian Ocean Territory","io","246"],["Brunei","bn","673"],["Bulgaria","bg","359"],["Burkina Faso","bf","226"],["Burundi","bi","257"],["Cambodia","kh","855"],["Cameroon","cm","237"],["Canada","ca","1","(...) ...-....",1,["204","226","236","249","250","289","306","343","365","387","403","416","418","431","437","438","450","506","514","519","548","579","581","587","604","613","639","647","672","705","709","742","778","780","782","807","819","825","867","873","902","905"]],["Cape Verde","cv","238"],["Caribbean Netherlands","bq","599","",1],["Cayman Islands","ky","1","... ... ....",4,["345"]],["Central African Republic","cf","236"],["Chad","td","235"],["Chile","cl","56"],["China","cn","86","... .... ...."],["Colombia","co","57","... ... ...."],["Comoros","km","269"],["Congo","cd","243"],["Congo","cg","242"],["Costa Rica","cr","506","....-...."],["Côte d'Ivoire","ci","225",".. .. .. .. .."],["Croatia","hr","385"],["Cuba","cu","53"],["Curaçao","cw","599","",0],["Cyprus","cy","357",".. ......"],["Czech Republic","cz","420","... ... ..."],["Denmark","dk","45",".. .. .. .."],["Djibouti","dj","253",".. .. ...."],["Dominica","dm","1767"],["Dominican Republic","do","1","(...) ...-....",2,["809","829","849"]],["Ecuador","ec","593"],["Egypt","eg","20"],["El Salvador","sv","503","....-...."],["Equatorial Guinea","gq","240"],["Eritrea","er","291"],["Estonia","ee","372",".... ......"],["Ethiopia","et","251",".. ... ...."],["Faroe Islands","fo","298",".. .. .."],["Fiji","fj","679"],["Finland","fi","358",".. ... .. .."],["France","fr","33",". .. .. .. .."],["French Guiana","gf","594","... .. .. .."],["French Polynesia","pf","689",{"/^44/":".. .. ..","/^80[0-5]/":"... .. .. ..",default:".. .. .. .."}],["Gabon","ga","241"],["Gambia","gm","220"],["Georgia","ge","995"],["Germany","de","49","... ........."],["Ghana","gh","233"],["Gibraltar","gi","350"],["Greece","gr","30"],["Greenland","gl","299",".. .. .."],["Grenada","gd","1473"],["Guadeloupe","gp","590","... .. .. ..",0],["Guam","gu","1671"],["Guatemala","gt","502","....-...."],["Guinea","gn","224"],["Guinea-Bissau","gw","245"],["Guyana","gy","592"],["Haiti","ht","509","....-...."],["Honduras","hn","504"],["Hong Kong","hk","852",".... ...."],["Hungary","hu","36"],["Iceland","is","354","... ...."],["India","in","91",".....-....."],["Indonesia","id","62"],["Iran","ir","98","... ... ...."],["Iraq","iq","964"],["Ireland","ie","353",".. ......."],["Israel","il","972","... ... ...."],["Italy","it","39","... .......",0],["Jamaica","jm","1876"],["Japan","jp","81",".. .... ...."],["Jordan","jo","962"],["Kazakhstan","kz","7","... ...-..-..",0],["Kenya","ke","254"],["Kiribati","ki","686"],["Kosovo","xk","383"],["Kuwait","kw","965",".... ...."],["Kyrgyzstan","kg","996","... ... ..."],["Laos","la","856"],["Latvia","lv","371",".. ... ..."],["Lebanon","lb","961"],["Lesotho","ls","266"],["Liberia","lr","231"],["Libya","ly","218"],["Liechtenstein","li","423"],["Lithuania","lt","370"],["Luxembourg","lu","352"],["Macau","mo","853"],["Macedonia","mk","389"],["Madagascar","mg","261"],["Malawi","mw","265"],["Malaysia","my","60","..-....-...."],["Maldives","mv","960"],["Mali","ml","223"],["Malta","mt","356"],["Marshall Islands","mh","692"],["Martinique","mq","596","... .. .. .."],["Mauritania","mr","222"],["Mauritius","mu","230"],["Mayotte","yt","262","... .. .. ..",1,["269","639"]],["Mexico","mx","52","... ... ....",0],["Micronesia","fm","691"],["Moldova","md","373","(..) ..-..-.."],["Monaco","mc","377"],["Mongolia","mn","976"],["Montenegro","me","382"],["Morocco","ma","212"],["Mozambique","mz","258"],["Myanmar","mm","95"],["Namibia","na","264"],["Nauru","nr","674"],["Nepal","np","977"],["Netherlands","nl","31",{"/^06/":"(.). .........","/^6/":". .........","/^0(10|13|14|15|20|23|24|26|30|33|35|36|38|40|43|44|45|46|50|53|55|58|70|71|72|73|74|75|76|77|78|79|82|84|85|87|88|91)/":"(.).. ........","/^(10|13|14|15|20|23|24|26|30|33|35|36|38|40|43|44|45|46|50|53|55|58|70|71|72|73|74|75|76|77|78|79|82|84|85|87|88|91)/":".. ........","/^0/":"(.)... .......",default:"... ......."}],["New Caledonia","nc","687"],["New Zealand","nz","64","...-...-...."],["Nicaragua","ni","505"],["Niger","ne","227"],["Nigeria","ng","234"],["North Korea","kp","850"],["Norway","no","47","... .. ..."],["Oman","om","968",".... ...."],["Pakistan","pk","92","...-......."],["Palau","pw","680"],["Palestine","ps","970"],["Panama","pa","507"],["Papua New Guinea","pg","675"],["Paraguay","py","595"],["Peru","pe","51"],["Philippines","ph","63","... ... ...."],["Poland","pl","48","...-...-..."],["Portugal","pt","351"],["Puerto Rico","pr","1","(...) ...-....",3,["787","939"]],["Qatar","qa","974",".... ...."],["Réunion","re","262","... .. .. ..",0],["Romania","ro","40"],["Russia","ru","7","(...) ...-..-..",1],["Rwanda","rw","250"],["Saint Kitts and Nevis","kn","1869"],["Saint Lucia","lc","1758"],["Saint Pierre & Miquelon","pm","508",{"/^708/":"... ... ...","/^8/":"... .. .. ..",default:".. .. .."}],["Saint Vincent and the Grenadines","vc","1784"],["Samoa","ws","685"],["San Marino","sm","378"],["São Tomé and Príncipe","st","239"],["Saudi Arabia","sa","966",".. ... ...."],["Senegal","sn","221"],["Serbia","rs","381"],["Seychelles","sc","248"],["Sierra Leone","sl","232"],["Singapore","sg","65","....-...."],["Slovakia","sk","421"],["Slovenia","si","386"],["Solomon Islands","sb","677"],["Somalia","so","252"],["South Africa","za","27"],["South Korea","kr","82","... .... ...."],["South Sudan","ss","211"],["Spain","es","34","... ... ..."],["Sri Lanka","lk","94"],["Sudan","sd","249"],["Suriname","sr","597"],["Swaziland","sz","268"],["Sweden","se","46","... ... ..."],["Switzerland","ch","41",".. ... .. .."],["Syria","sy","963"],["Taiwan","tw","886"],["Tajikistan","tj","992"],["Tanzania","tz","255"],["Thailand","th","66"],["Timor-Leste","tl","670"],["Togo","tg","228"],["Tonga","to","676"],["Trinidad and Tobago","tt","1868"],["Tunisia","tn","216"],["Turkey","tr","90","... ... .. .."],["Turkmenistan","tm","993"],["Tuvalu","tv","688"],["Uganda","ug","256"],["Ukraine","ua","380","(..) ... .. .."],["United Arab Emirates","ae","971",{default:".. ... ....","/^5[024568]/":".. ... ....","/^[234679]/":". ... ...."}],["United Kingdom","gb","44",".... ......"],["United States","us","1","(...) ...-....",0],["Uruguay","uy","598"],["Uzbekistan","uz","998",".. ... .. .."],["Vanuatu","vu","678"],["Vatican City","va","39",".. .... ....",1],["Venezuela","ve","58"],["Vietnam","vn","84"],["Wallis & Futuna","wf","681",".. .. .."],["Yemen","ye","967"],["Zambia","zm","260"],["Zimbabwe","zw","263"]],ye="react-international-phone-",ae=(...t)=>t.filter(e=>!!e).join(" ").trim(),Ce=(...t)=>ae(...t).split(" ").map(e=>`${ye}${e}`).join(" "),A=({addPrefix:t,rawClassNames:e})=>ae(Ce(...t),...e),ge=({value:t,mask:e,maskSymbol:l,offset:i=0,trimNonMaskCharsLeftover:a=!1,allowMaskOverflow:n=!1})=>{if(t.length<i)return t;let f=t.slice(0,i),o=t.slice(i),r=e.split("").filter(c=>c===l).length,s=o.slice(0,r),u=n?o.slice(r):"",m=f,v=0;for(let c of e.split("")){if(v>=s.length){if(!a&&c!==l){m+=c;continue}break}c===l?(m+=s[v],v+=1):m+=c}return m+u},G=t=>t?/^\d+$/.test(t):!1,X=t=>t.replace(/\D/g,""),be=(t,e)=>{let l=t.style.display;l!=="block"&&(t.style.display="block");let i=t.getBoundingClientRect(),a=e.getBoundingClientRect(),n=a.top-i.top,f=i.bottom-a.bottom;n>=0&&f>=0||(Math.abs(n)<Math.abs(f)?t.scrollTop+=n:t.scrollTop-=f),t.style.display=l},ve=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes("macintosh"),we=(t,e)=>{let l=e.disableDialCodeAndPrefix?!1:e.forceDialCode,i=e.disableDialCodeAndPrefix?!1:e.insertDialCodeOnEmpty,a=t,n=s=>e.trimNonDigitsEnd?s.trim():s;if(!a)return i&&!a.length||l?n(`${e.prefix}${e.dialCode}${e.charAfterDialCode}`):n(a);if(a=X(a),a===e.dialCode&&!e.disableDialCodeAndPrefix)return n(`${e.prefix}${e.dialCode}${e.charAfterDialCode}`);if(e.dialCode.startsWith(a)&&!e.disableDialCodeAndPrefix)return n(l?`${e.prefix}${e.dialCode}${e.charAfterDialCode}`:`${e.prefix}${a}`);if(!a.startsWith(e.dialCode)&&!e.disableDialCodeAndPrefix){if(l)return n(`${e.prefix}${e.dialCode}${e.charAfterDialCode}`);if(a.length<e.dialCode.length)return n(`${e.prefix}${a}`)}let f=()=>{let s=e.dialCode.length,u=a.slice(0,s),m=a.slice(s);return{phoneLeftSide:u,phoneRightSide:m}},{phoneLeftSide:o,phoneRightSide:r}=f();return o=`${e.prefix}${o}${e.charAfterDialCode}`,r=ge({value:r,mask:e.mask,maskSymbol:e.maskChar,trimNonMaskCharsLeftover:e.trimNonDigitsEnd||e.disableDialCodeAndPrefix&&r.length===0,allowMaskOverflow:e.allowMaskOverflow}),e.disableDialCodeAndPrefix&&(o=""),n(`${o}${r}`)},De=({phoneBeforeInput:t,phoneAfterInput:e,phoneAfterFormatted:l,cursorPositionAfterInput:i,leftOffset:a=0,deletion:n})=>{if(i<a)return a;if(!t)return l.length;let f=null;for(let u=i-1;u>=0;u-=1)if(G(e[u])){f=u;break}if(f===null){for(let u=0;u<e.length;u+=1)if(G(l[u]))return u;return e.length}let o=0;for(let u=0;u<f;u+=1)G(e[u])&&(o+=1);let r=0,s=0;for(let u=0;u<l.length&&(r+=1,G(l[u])&&(s+=1),!(s>=o+1));u+=1);if(n!=="backward")for(;!G(l[r])&&r<l.length;)r+=1;return r},Q=({phone:t,prefix:e})=>t?`${e}${X(t)}`:"";function ee({value:t,country:e,insertDialCodeOnEmpty:l,trimNonDigitsEnd:i,countries:a,prefix:n,charAfterDialCode:f,forceDialCode:o,disableDialCodeAndPrefix:r,defaultMask:s,countryGuessingEnabled:u,disableFormatting:m,allowMaskOverflow:v}){let c=t;r&&(c=c.startsWith(`${n}`)?c:`${n}${e.dialCode}${c}`);let w=u?Ee({phone:c,countries:a,currentCountryIso2:e?.iso2}):void 0,p=w?.country??e,b=we(c,{prefix:n,mask:Ae({phone:c,country:p,defaultMask:s,disableFormatting:m}),maskChar:re,dialCode:p.dialCode,trimNonDigitsEnd:i,charAfterDialCode:f,forceDialCode:o,insertDialCodeOnEmpty:l,disableDialCodeAndPrefix:r,allowMaskOverflow:v}),y=u&&!w?.fullDialCodeMatch?e:p;return{phone:Q({phone:r?`${y.dialCode}${b}`:b,prefix:n}),inputValue:b,country:y}}var xe=t=>{if(t?.toLocaleLowerCase().includes("delete")??!1)return t?.toLocaleLowerCase().includes("forward")?"forward":"backward"},ke=(t,{country:e,insertDialCodeOnEmpty:l,phoneBeforeInput:i,prefix:a,charAfterDialCode:n,forceDialCode:f,disableDialCodeAndPrefix:o,countryGuessingEnabled:r,defaultMask:s,disableFormatting:u,countries:m,allowMaskOverflow:v})=>{let c=t.nativeEvent,w=c.inputType,p=xe(w),b=!!w?.startsWith("insertFrom"),y=w==="insertText",C=c?.data||void 0,N=t.target.value,z=t.target.selectionStart??0;if(w?.includes("history"))return{inputValue:i,phone:Q({phone:i,prefix:a}),cursorPosition:i.length,country:e};if(y&&!G(C)&&N!==a)return{inputValue:i,phone:Q({phone:o?`${e.dialCode}${i}`:i,prefix:a}),cursorPosition:z-(C?.length??0),country:e};if(f&&!N.startsWith(`${a}${e.dialCode}`)&&!b){let x=N?i:`${a}${e.dialCode}${n}`;return{inputValue:x,phone:Q({phone:x,prefix:a}),cursorPosition:a.length+e.dialCode.length+n.length,country:e}}let{phone:L,inputValue:d,country:g}=ee({value:N,country:e,trimNonDigitsEnd:p==="backward",insertDialCodeOnEmpty:l,countryGuessingEnabled:r,countries:m,prefix:a,charAfterDialCode:n,forceDialCode:f,disableDialCodeAndPrefix:o,disableFormatting:u,defaultMask:s,allowMaskOverflow:v}),h=De({cursorPositionAfterInput:z,phoneBeforeInput:i,phoneAfterInput:N,phoneAfterFormatted:d,leftOffset:f?a.length+e.dialCode.length+n.length:0,deletion:p});return{phone:L,inputValue:d,cursorPosition:h,country:g}},Ne=(t,e)=>{let l=Object.keys(t),i=Object.keys(e);if(l.length!==i.length)return!1;for(let a of l)if(t[a]!==e[a])return!1;return!0},Pe=()=>{let t=_(),e=_(Date.now()),l=I(()=>{let i=Date.now(),a=t.current?i-e.current:void 0;return t.current=e.current,e.current=i,a},[]);return Z(()=>({check:l}),[l])},Se={size:20,overrideLastItemDebounceMS:-1};function Me(t,e){let{size:l,overrideLastItemDebounceMS:i,onChange:a}={...Se,...e},[n,f]=W(t),o=_([n]),r=_(0),s=Pe(),u=I((c,w)=>{let p=o.current[r.current];if(c===p||typeof c=="object"&&typeof p=="object"&&Ne(c,p))return;let b=i>0,y=s.check(),C=b&&y!==void 0?y>i:!0;if(w?.overrideLastItem!==void 0?w.overrideLastItem:!C)o.current=[...o.current.slice(0,r.current),c];else{let N=o.current.length>=l;o.current=[...o.current.slice(N?1:0,r.current+1),c],N||(r.current+=1)}f(c),a?.(c)},[a,i,l,s]),m=I(()=>{if(r.current<=0)return{success:!1};let c=o.current[r.current-1];return f(c),r.current-=1,a?.(c),{success:!0,value:c}},[a]),v=I(()=>{if(r.current+1>=o.current.length)return{success:!1};let c=o.current[r.current+1];return f(c),r.current+=1,a?.(c),{success:!0,value:c}},[a]);return[n,u,m,v]}var re=".",$={defaultCountry:"us",value:"",prefix:"+",defaultMask:"............",charAfterDialCode:" ",historySaveDebounceMS:200,disableCountryGuess:!1,disableDialCodePrefill:!1,forceDialCode:!1,disableDialCodeAndPrefix:!1,disableFormatting:!1,allowMaskOverflow:!1,countries:R},le=({defaultCountry:t=$.defaultCountry,value:e=$.value,countries:l=$.countries,prefix:i=$.prefix,defaultMask:a=$.defaultMask,charAfterDialCode:n=$.charAfterDialCode,historySaveDebounceMS:f=$.historySaveDebounceMS,disableCountryGuess:o=$.disableCountryGuess,disableDialCodePrefill:r=$.disableDialCodePrefill,forceDialCode:s=$.forceDialCode,disableDialCodeAndPrefix:u=$.disableDialCodeAndPrefix,disableFormatting:m=$.disableFormatting,allowMaskOverflow:v=$.allowMaskOverflow,onChange:c,inputRef:w})=>{let p={countries:l,prefix:i,charAfterDialCode:n,forceDialCode:u?!1:s,disableDialCodeAndPrefix:u,defaultMask:a,countryGuessingEnabled:!o,disableFormatting:m,allowMaskOverflow:v},b=_(null),y=w||b,C=D=>{Promise.resolve().then(()=>{typeof window>"u"||y.current!==document?.activeElement||y.current?.setSelectionRange(D,D)})},N=I(D=>T({value:D,field:"iso2",countries:l}),[l]),z=I(({inputValue:D,phone:P,country:S})=>{if(!c)return;let B=N(S);c({phone:P,inputValue:D,country:B})},[N,c]),[{phone:L,inputValue:d,country:g},h,x,M]=Me(()=>{let D=T({value:t,field:"iso2",countries:l});D||console.error(`[react-international-phone]: can not find a country with "${t}" iso2 code`);let P=D||T({value:"us",field:"iso2",countries:l}),{phone:S,inputValue:B,country:U}=ee({value:e,country:P,insertDialCodeOnEmpty:!r,...p});return C(B.length),{phone:S,inputValue:B,country:U.iso2}},{overrideLastItemDebounceMS:f,onChange:z}),E=Z(()=>N(g),[g,N]);K(()=>{let D=y.current;if(!D)return;let P=S=>{if(!S.key)return;let B=S.ctrlKey,U=S.metaKey,ie=S.shiftKey;if(S.key.toLowerCase()==="z"){if(ve()){if(!U)return}else if(!B)return;ie?M():x()}};return D.addEventListener("keydown",P),()=>{D.removeEventListener("keydown",P)}},[y,x,M]);let V=D=>{D.preventDefault();let{phone:P,inputValue:S,country:B,cursorPosition:U}=ke(D,{country:E,phoneBeforeInput:d,insertDialCodeOnEmpty:!1,...p});return h({inputValue:S,phone:P,country:B.iso2}),C(U),e},O=I((D,P={focusOnInput:!1})=>{let S=T({value:D,field:"iso2",countries:l});if(!S){console.error(`[react-international-phone]: can not find a country with "${D}" iso2 code`);return}let B=u?"":`${i}${S.dialCode}${n}`;h({inputValue:B,phone:`${i}${S.dialCode}`,country:S.iso2}),P.focusOnInput&&Promise.resolve().then(()=>{y.current?.focus()})},[l,u,i,n,h,y]),[q,Y]=W(!1);return K(()=>{if(!q){Y(!0),e!==L&&c?.({inputValue:d,phone:L,country:E});return}if(e===L)return;let{phone:D,inputValue:P,country:S}=ee({value:e,country:E,insertDialCodeOnEmpty:!r,...p});h({phone:D,inputValue:P,country:S.iso2})},[e]),{phone:L,inputValue:d,country:E,setCountry:O,handlePhoneValueChange:V,inputRef:y}},Ae=({phone:t,country:e,defaultMask:l="............",disableFormatting:i=!1})=>{let a=e.format,n=o=>i?o.replace(new RegExp(`[^${re}]`,"g"),""):o;if(!a)return n(l);if(typeof a=="string")return n(a);if(!a.default)return console.error(`[react-international-phone]: default mask for ${e.iso2} is not provided`),n(l);let f=Object.keys(a).find(o=>{if(o==="default")return!1;if(!(o.charAt(0)==="/"&&o.charAt(o.length-1)==="/"))return console.error(`[react-international-phone]: format regex "${o}" for ${e.iso2} is not valid`),!1;let r=new RegExp(o.substring(1,o.length-1)),s=t.replace(e.dialCode,"");return r.test(X(s))});return n(f?a[f]:a.default)},F=t=>{let[e,l,i,a,n,f]=t;return{name:e,iso2:l,dialCode:i,format:a,priority:n,areaCodes:f}},$e=t=>`Field "${t}" is not supported`,T=({field:t,value:e,countries:l=R})=>{if(["priority"].includes(t))throw new Error($e(t));let i=l.find(a=>{let n=F(a);return e===n[t]});if(i)return F(i)},Ee=({phone:t,countries:e=R,currentCountryIso2:l})=>{let i={country:void 0,fullDialCodeMatch:!1};if(!t)return i;let a=X(t);if(!a)return i;let n=i,f=({country:o,fullDialCodeMatch:r})=>{let s=o.dialCode===n.country?.dialCode,u=(o.priority??0)<(n.country?.priority??0);(!s||u)&&(n={country:o,fullDialCodeMatch:r})};for(let o of e){let r=F(o),{dialCode:s,areaCodes:u}=r;if(a.startsWith(s)){let m=n.country?Number(s)>=Number(n.country.dialCode):!0;if(u){let v=a.substring(s.length);for(let c of u)if(v.startsWith(c))return{country:r,fullDialCodeMatch:!0}}(m||s===a||!n.fullDialCodeMatch)&&f({country:r,fullDialCodeMatch:!0})}n.fullDialCodeMatch||a.length<s.length&&s.startsWith(a)&&(!n.country||Number(s)<=Number(n.country.dialCode))&&f({country:r,fullDialCodeMatch:!1})}if(l){let o=T({value:l,field:"iso2",countries:e});if(!o)return n;let r=o?(s=>{if(!s?.areaCodes)return!1;let u=a.substring(s.dialCode.length);return s.areaCodes.some(m=>m.startsWith(u))})(o):!1;n&&n.country?.dialCode===o.dialCode&&n.country!==o&&n.fullDialCodeMatch&&(!o.areaCodes||r)&&(n={country:o,fullDialCodeMatch:!0})}return n},Ie=(t,e)=>{let l=parseInt(t,16);return Number(l+e).toString(16)},Le="abcdefghijklmnopqrstuvwxyz",Fe="1f1e6",te=Le.split("").reduce((t,e,l)=>({...t,[e]:Ie(Fe,l)}),{}),_e=t=>[te[t[0]],te[t[1]]].join("-"),ne=({iso2:t,size:e,src:l,protocol:i="https",disableLazyLoading:a,className:n,style:f,...o})=>{if(!t)return k.createElement("img",{className:A({addPrefix:["flag-emoji"],rawClassNames:[n]}),width:e,height:e,...o});let r=()=>{if(l)return l;let s=_e(t);return`${i}://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${s}.svg`};return k.createElement("img",{className:A({addPrefix:["flag-emoji"],rawClassNames:[n]}),src:r(),width:e,height:e,draggable:!1,"data-country":t,loading:a?void 0:"lazy",style:{width:e,height:e,...f},alt:"",...o})},Be=1e3,Ve=({show:t,dialCodePrefix:e="+",selectedCountry:l,countries:i=R,preferredCountries:a=[],flags:n,onSelect:f,onClose:o,...r})=>{let s=_(null),u=_(),m=Z(()=>{if(!a||!a.length)return i;let d=[],g=[...i];for(let h of a){let x=g.findIndex(M=>F(M).iso2===h);if(x!==-1){let M=g.splice(x,1)[0];d.push(M)}}return d.concat(g)},[i,a]),v=_({updatedAt:void 0,value:""}),c=d=>{let g=v.current.updatedAt&&new Date().getTime()-v.current.updatedAt.getTime()>Be;v.current={value:g?d:`${v.current.value}${d}`,updatedAt:new Date};let h=m.findIndex(x=>F(x).name.toLowerCase().startsWith(v.current.value));h!==-1&&b(h)},w=I(d=>m.findIndex(g=>F(g).iso2===d),[m]),[p,b]=W(w(l)),y=()=>{u.current!==l&&b(w(l))},C=I(d=>{b(w(d.iso2)),f?.(d)},[f,w]),N=d=>{let g=m.length-1,h=x=>d==="prev"?x-1:d==="next"?x+1:d==="last"?g:0;b(x=>{let M=h(x);return M<0?0:M>g?g:M})},z=d=>{if(d.stopPropagation(),d.key==="Enter"){d.preventDefault();let g=F(m[p]);C(g);return}if(d.key==="Escape"){o?.();return}if(d.key==="ArrowUp"){d.preventDefault(),N("prev");return}if(d.key==="ArrowDown"){d.preventDefault(),N("next");return}if(d.key==="PageUp"){d.preventDefault(),N("first");return}if(d.key==="PageDown"){d.preventDefault(),N("last");return}d.key===" "&&d.preventDefault(),d.key.length===1&&!d.altKey&&!d.ctrlKey&&!d.metaKey&&c(d.key.toLocaleLowerCase())},L=I(()=>{if(!s.current||p===void 0)return;let d=F(m[p]).iso2;if(d===u.current)return;let g=s.current.querySelector(`[data-country="${d}"]`);g&&(be(s.current,g),u.current=d)},[p,m]);return K(()=>{L()},[p,L]),K(()=>{s.current&&(t?s.current.focus():y())},[t]),K(()=>{y()},[l]),k.createElement("ul",{ref:s,role:"listbox",className:A({addPrefix:["country-selector-dropdown"],rawClassNames:[r.className]}),style:{display:t?"block":"none",...r.style},onKeyDown:z,onBlur:o,tabIndex:-1,"aria-activedescendant":`react-international-phone__${F(m[p]).iso2}-option`},m.map((d,g)=>{let h=F(d),x=h.iso2===l,M=g===p,E=a.includes(h.iso2),V=g===a.length-1,O=n?.find(q=>q.iso2===h.iso2);return k.createElement(k.Fragment,{key:h.iso2},k.createElement("li",{"data-country":h.iso2,role:"option","aria-selected":x,"aria-label":`${h.name} ${e}${h.dialCode}`,id:`react-international-phone__${h.iso2}-option`,className:A({addPrefix:["country-selector-dropdown__list-item",E&&"country-selector-dropdown__list-item--preferred",x&&"country-selector-dropdown__list-item--selected",M&&"country-selector-dropdown__list-item--focused"],rawClassNames:[r.listItemClassName,E&&r.listItemPreferredClassName,x&&r.listItemSelectedClassName,M&&r.listItemFocusedClassName]}),onClick:()=>C(h),style:r.listItemStyle,title:h.name},k.createElement(ne,{iso2:h.iso2,src:O?.src,className:A({addPrefix:["country-selector-dropdown__list-item-flag-emoji"],rawClassNames:[r.listItemFlagClassName]}),style:r.listItemFlagStyle}),k.createElement("span",{className:A({addPrefix:["country-selector-dropdown__list-item-country-name"],rawClassNames:[r.listItemCountryNameClassName]}),style:r.listItemCountryNameStyle},h.name),k.createElement("span",{className:A({addPrefix:["country-selector-dropdown__list-item-dial-code"],rawClassNames:[r.listItemDialCodeClassName]}),style:r.listItemDialCodeStyle},e,h.dialCode)),V?k.createElement("hr",{className:A({addPrefix:["country-selector-dropdown__preferred-list-divider"],rawClassNames:[r.preferredListDividerClassName]}),style:r.preferredListDividerStyle}):null)}))},ze=k.memo(({selectedCountry:t,onSelect:e,disabled:l,hideDropdown:i,countries:a=R,preferredCountries:n=[],flags:f,renderButtonWrapper:o,...r})=>{let[s,u]=W(!1),m=Z(()=>{if(t)return T({value:t,field:"iso2",countries:a})},[a,t]),v=_(null),c=p=>{p.key&&["ArrowUp","ArrowDown"].includes(p.key)&&(p.preventDefault(),u(!0))},w=()=>{let p={title:m?.name,onClick:()=>u(y=>!y),onMouseDown:y=>y.preventDefault(),onKeyDown:c,disabled:i||l,role:"combobox","aria-label":"Country selector","aria-haspopup":"listbox","aria-expanded":s},b=k.createElement("div",{className:A({addPrefix:["country-selector-button__button-content"],rawClassNames:[r.buttonContentWrapperClassName]}),style:r.buttonContentWrapperStyle},k.createElement(ne,{iso2:t,src:f?.find(y=>y.iso2===t)?.src,className:A({addPrefix:["country-selector-button__flag-emoji",l&&"country-selector-button__flag-emoji--disabled"],rawClassNames:[r.flagClassName]}),style:{visibility:t?"visible":"hidden",...r.flagStyle}}),!i&&k.createElement("div",{className:A({addPrefix:["country-selector-button__dropdown-arrow",l&&"country-selector-button__dropdown-arrow--disabled",s&&"country-selector-button__dropdown-arrow--active"],rawClassNames:[r.dropdownArrowClassName]}),style:r.dropdownArrowStyle}));return o?o({children:b,rootProps:p}):k.createElement("button",{...p,type:"button",className:A({addPrefix:["country-selector-button",s&&"country-selector-button--active",l&&"country-selector-button--disabled",i&&"country-selector-button--hide-dropdown"],rawClassNames:[r.buttonClassName]}),"data-country":t,style:r.buttonStyle},b)};return k.createElement("div",{className:A({addPrefix:["country-selector"],rawClassNames:[r.className]}),style:r.style,ref:v},w(),k.createElement(Ve,{show:s,countries:a,preferredCountries:n,flags:f,onSelect:p=>{u(!1),e?.(p)},selectedCountry:t,onClose:()=>{u(!1)},...r.dropdownStyleProps}))}),Oe=({dialCode:t,prefix:e,disabled:l,style:i,className:a})=>k.createElement("div",{className:A({addPrefix:["dial-code-preview",l&&"dial-code-preview--disabled"],rawClassNames:[a]}),style:i},`${e}${t}`);se(({value:t,onChange:e,countries:l=R,preferredCountries:i,hideDropdown:a,showDisabledDialCodeAndPrefix:n,disableFocusAfterCountrySelect:f,flags:o,style:r,className:s,inputStyle:u,inputClassName:m,countrySelectorStyleProps:v,dialCodePreviewStyleProps:c,inputProps:w,placeholder:p,disabled:b,name:y,onFocus:C,onBlur:N,required:z,autoFocus:L,...d},g)=>{let h=I(P=>{e?.(P.phone,{country:P.country,inputValue:P.inputValue})},[e]),{phone:x,inputValue:M,inputRef:E,country:V,setCountry:O,handlePhoneValueChange:q}=le({value:t,countries:l,...d,onChange:h}),Y=d.disableDialCodeAndPrefix&&n&&V?.dialCode,D=I(P=>{O(P.iso2,{focusOnInput:!f})},[O,f]);return ue(g,()=>E.current?Object.assign(E.current,{setCountry:O,state:{phone:x,inputValue:M,country:V}}):null,[E,O,x,M,V]),k.createElement("div",{ref:g,className:A({addPrefix:["input-container"],rawClassNames:[s]}),style:r},k.createElement(ze,{onSelect:D,flags:o,selectedCountry:V?.iso2,countries:l,preferredCountries:i,disabled:b,hideDropdown:a,...v}),Y&&k.createElement(Oe,{dialCode:V.dialCode,prefix:d.prefix??"+",disabled:b,...c}),k.createElement("input",{onChange:q,value:M,type:"tel",ref:E,className:A({addPrefix:["input",b&&"input--disabled"],rawClassNames:[m]}),placeholder:p,disabled:b,style:u,name:y,onFocus:C,onBlur:N,autoFocus:L,required:z,...w}))});const je=R.map(F);function Ze({value:t,onChange:e,defaultCountry:l="us",...i}){const a=_(null),n=_(null),{inputValue:f,handlePhoneValueChange:o,inputRef:r,country:s,setCountry:u}=le({defaultCountry:l,value:t,countries:R,onChange:C=>{e?.(C.phone)},forceDialCode:!0}),m=`+${s.dialCode}`,{startsWith:v}=oe({sensitivity:"base"}),[c,w]=W(""),[p,b]=W(!1),y=Z(()=>je.filter(C=>v(C.name,c)),[c]);return K(()=>{p&&n.current?.focus()},[p]),H("div",{className:J("flex relative",i.label?"pt-4":""),"aria-label":i["aria-label"],children:[H(de,{isOpen:p,onOpenChange:b,children:[H(ce,{"aria-label":"Select Country",className:"flex px-4 h-10 text-sm items-center rounded-l-md bg-slate-100 gap-2 uppercase [&[aria-expanded=false]_svg]:rotate-180 border border-r-0 border-slate-300",excludeFromTabOrder:!0,children:[s.iso2,j("svg",{width:"15",height:"8",viewBox:"0 0 15 8",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:j("path",{d:"M1 7L7.5 0.999999L14 7",stroke:"currentColor"})})]}),H("div",{className:J("w-full grid absolute left-0 top-[calc(100%+.25rem)] bg-white z-50 rounded-md text-slate-600 border border-slate-300","shadow-inner",p?"block":"hidden"),ref:a,children:[j("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"none",viewBox:"0 0 17 16",className:"absolute top-4 left-[1.325rem]",children:j("path",{fill:"currentColor",fillRule:"evenodd",d:"M12.3 6.9a4.9 4.9 0 1 1-9.8 0 4.9 4.9 0 0 1 9.8 0Zm-1.1 5.7c-1.1.7-2.4 1.2-3.8 1.2a6.9 6.9 0 1 1 5.3-2.5l3 3-1.4 1.4-3.1-3Z",clipRule:"evenodd"})}),j(fe,{"aria-label":"Search for countries",placeholder:"Search for countries",className:J("pl-12 pr-5 py-4 w-full m-0 border-0 text-slate-950 transition-all duration-[0.25s] ease outline-0 bg-transparent","placeholder:text-slate-950 focus:outline-0","border-b border-slate-200"),onChange:C=>w(C.target.value),onBlur:()=>{b(!1),r.current?.focus()},value:c,ref:n}),j("div",{className:"p-2.5",children:j(pe,{className:"text-slate-950 max-h-60 overflow-y-auto",selectionMode:"single","aria-label":"Countries List",onSelectionChange:C=>{u(String([...C][0])),w(""),b(!1)},children:(p?y:[]).map(C=>H(me,{id:C.iso2,value:C,textValue:C.iso2,className:"p-3 text-slate-900 data-[hovered]:bg-slate-100 rounded-md",children:[C.name," (+",C.dialCode,")"]},C.iso2))})})]})]}),j(he,{...i,value:f,inputProps:{onChange:o},ref:r,classNames:{input:J("rounded-l-none",f.trim()===m?"text-slate-600":""),label:"absolute top-0 left-0"}})]})}export{Ze as PhoneInput,Ze as default};
|
|
1
|
+
"use client";import{jsxs as H,jsx as j}from"react/jsx-runtime";import{useFilter as ie}from"react-aria";import k,{useState as W,useMemo as Z,useRef as _,forwardRef as se,useCallback as I,useImperativeHandle as ue,useEffect as K}from"react";import{DialogTrigger as de,Button as ce,Input as fe,ListBox as pe,ListBoxItem as me}from"react-aria-components";import{cn as J}from"../../utils/cn.js";import{Input as he}from"../Input/Input.js";import"../Skeleton/Skeleton.js";import"../../hooks/useIsClient.js";var R=[["Afghanistan","af","93"],["Albania","al","355"],["Algeria","dz","213"],["Andorra","ad","376"],["Angola","ao","244"],["Antigua and Barbuda","ag","1268"],["Argentina","ar","54",{default:"(..) .... ....","/^11/":"(..) .... ....","/^15/":"(..) ... ....","/^(2|3|4|5)/":"(.) .... ....","/^9/":"(.) .... ....."},0],["Armenia","am","374",".. ......"],["Aruba","aw","297"],["Australia","au","61",{default:". .... ....","/^4/":"... ... ...","/^5(?!50)/":"... ... ...","/^1(3|8)00/":".... ... ...","/^13/":".. .. ..","/^180/":"... ...."},0,[]],["Austria","at","43"],["Azerbaijan","az","994","(..) ... .. .."],["Bahamas","bs","1242"],["Bahrain","bh","973",".... ...."],["Bangladesh","bd","880"],["Barbados","bb","1246"],["Belarus","by","375","(..) ... .. .."],["Belgium","be","32","... .. .. .."],["Belize","bz","501"],["Benin","bj","229"],["Bhutan","bt","975"],["Bolivia","bo","591"],["Bosnia and Herzegovina","ba","387"],["Botswana","bw","267"],["Brazil","br","55","(..) .....-...."],["British Indian Ocean Territory","io","246"],["Brunei","bn","673"],["Bulgaria","bg","359"],["Burkina Faso","bf","226"],["Burundi","bi","257"],["Cambodia","kh","855"],["Cameroon","cm","237"],["Canada","ca","1","(...) ...-....",1,["204","226","236","249","250","289","306","343","365","387","403","416","418","431","437","438","450","506","514","519","548","579","581","587","604","613","639","647","672","705","709","742","778","780","782","807","819","825","867","873","902","905"]],["Cape Verde","cv","238"],["Caribbean Netherlands","bq","599","",1],["Cayman Islands","ky","1","... ... ....",4,["345"]],["Central African Republic","cf","236"],["Chad","td","235"],["Chile","cl","56"],["China","cn","86","... .... ...."],["Colombia","co","57","... ... ...."],["Comoros","km","269"],["Congo","cd","243"],["Congo","cg","242"],["Costa Rica","cr","506","....-...."],["Côte d'Ivoire","ci","225",".. .. .. .. .."],["Croatia","hr","385"],["Cuba","cu","53"],["Curaçao","cw","599","",0],["Cyprus","cy","357",".. ......"],["Czech Republic","cz","420","... ... ..."],["Denmark","dk","45",".. .. .. .."],["Djibouti","dj","253",".. .. ...."],["Dominica","dm","1767"],["Dominican Republic","do","1","(...) ...-....",2,["809","829","849"]],["Ecuador","ec","593"],["Egypt","eg","20"],["El Salvador","sv","503","....-...."],["Equatorial Guinea","gq","240"],["Eritrea","er","291"],["Estonia","ee","372",".... ......"],["Ethiopia","et","251",".. ... ...."],["Faroe Islands","fo","298",".. .. .."],["Fiji","fj","679"],["Finland","fi","358",".. ... .. .."],["France","fr","33",". .. .. .. .."],["French Guiana","gf","594","... .. .. .."],["French Polynesia","pf","689",{"/^44/":".. .. ..","/^80[0-5]/":"... .. .. ..",default:".. .. .. .."}],["Gabon","ga","241"],["Gambia","gm","220"],["Georgia","ge","995"],["Germany","de","49","... ........."],["Ghana","gh","233"],["Gibraltar","gi","350"],["Greece","gr","30"],["Greenland","gl","299",".. .. .."],["Grenada","gd","1473"],["Guadeloupe","gp","590","... .. .. ..",0],["Guam","gu","1671"],["Guatemala","gt","502","....-...."],["Guinea","gn","224"],["Guinea-Bissau","gw","245"],["Guyana","gy","592"],["Haiti","ht","509","....-...."],["Honduras","hn","504"],["Hong Kong","hk","852",".... ...."],["Hungary","hu","36"],["Iceland","is","354","... ...."],["India","in","91",".....-....."],["Indonesia","id","62"],["Iran","ir","98","... ... ...."],["Iraq","iq","964"],["Ireland","ie","353",".. ......."],["Israel","il","972","... ... ...."],["Italy","it","39","... .......",0],["Jamaica","jm","1876"],["Japan","jp","81",".. .... ...."],["Jordan","jo","962"],["Kazakhstan","kz","7","... ...-..-..",0],["Kenya","ke","254"],["Kiribati","ki","686"],["Kosovo","xk","383"],["Kuwait","kw","965",".... ...."],["Kyrgyzstan","kg","996","... ... ..."],["Laos","la","856"],["Latvia","lv","371",".. ... ..."],["Lebanon","lb","961"],["Lesotho","ls","266"],["Liberia","lr","231"],["Libya","ly","218"],["Liechtenstein","li","423"],["Lithuania","lt","370"],["Luxembourg","lu","352"],["Macau","mo","853"],["Macedonia","mk","389"],["Madagascar","mg","261"],["Malawi","mw","265"],["Malaysia","my","60","..-....-...."],["Maldives","mv","960"],["Mali","ml","223"],["Malta","mt","356"],["Marshall Islands","mh","692"],["Martinique","mq","596","... .. .. .."],["Mauritania","mr","222"],["Mauritius","mu","230"],["Mayotte","yt","262","... .. .. ..",1,["269","639"]],["Mexico","mx","52","... ... ....",0],["Micronesia","fm","691"],["Moldova","md","373","(..) ..-..-.."],["Monaco","mc","377"],["Mongolia","mn","976"],["Montenegro","me","382"],["Morocco","ma","212"],["Mozambique","mz","258"],["Myanmar","mm","95"],["Namibia","na","264"],["Nauru","nr","674"],["Nepal","np","977"],["Netherlands","nl","31",{"/^06/":"(.). .........","/^6/":". .........","/^0(10|13|14|15|20|23|24|26|30|33|35|36|38|40|43|44|45|46|50|53|55|58|70|71|72|73|74|75|76|77|78|79|82|84|85|87|88|91)/":"(.).. ........","/^(10|13|14|15|20|23|24|26|30|33|35|36|38|40|43|44|45|46|50|53|55|58|70|71|72|73|74|75|76|77|78|79|82|84|85|87|88|91)/":".. ........","/^0/":"(.)... .......",default:"... ......."}],["New Caledonia","nc","687"],["New Zealand","nz","64","...-...-...."],["Nicaragua","ni","505"],["Niger","ne","227"],["Nigeria","ng","234"],["North Korea","kp","850"],["Norway","no","47","... .. ..."],["Oman","om","968",".... ...."],["Pakistan","pk","92","...-......."],["Palau","pw","680"],["Palestine","ps","970"],["Panama","pa","507"],["Papua New Guinea","pg","675"],["Paraguay","py","595"],["Peru","pe","51"],["Philippines","ph","63","... ... ...."],["Poland","pl","48","...-...-..."],["Portugal","pt","351"],["Puerto Rico","pr","1","(...) ...-....",3,["787","939"]],["Qatar","qa","974",".... ...."],["Réunion","re","262","... .. .. ..",0],["Romania","ro","40"],["Russia","ru","7","(...) ...-..-..",1],["Rwanda","rw","250"],["Saint Kitts and Nevis","kn","1869"],["Saint Lucia","lc","1758"],["Saint Pierre & Miquelon","pm","508",{"/^708/":"... ... ...","/^8/":"... .. .. ..",default:".. .. .."}],["Saint Vincent and the Grenadines","vc","1784"],["Samoa","ws","685"],["San Marino","sm","378"],["São Tomé and Príncipe","st","239"],["Saudi Arabia","sa","966",".. ... ...."],["Senegal","sn","221"],["Serbia","rs","381"],["Seychelles","sc","248"],["Sierra Leone","sl","232"],["Singapore","sg","65","....-...."],["Slovakia","sk","421"],["Slovenia","si","386"],["Solomon Islands","sb","677"],["Somalia","so","252"],["South Africa","za","27"],["South Korea","kr","82","... .... ...."],["South Sudan","ss","211"],["Spain","es","34","... ... ..."],["Sri Lanka","lk","94"],["Sudan","sd","249"],["Suriname","sr","597"],["Swaziland","sz","268"],["Sweden","se","46","... ... ..."],["Switzerland","ch","41",".. ... .. .."],["Syria","sy","963"],["Taiwan","tw","886"],["Tajikistan","tj","992"],["Tanzania","tz","255"],["Thailand","th","66"],["Timor-Leste","tl","670"],["Togo","tg","228"],["Tonga","to","676"],["Trinidad and Tobago","tt","1868"],["Tunisia","tn","216"],["Turkey","tr","90","... ... .. .."],["Turkmenistan","tm","993"],["Tuvalu","tv","688"],["Uganda","ug","256"],["Ukraine","ua","380","(..) ... .. .."],["United Arab Emirates","ae","971",{default:".. ... ....","/^5[024568]/":".. ... ....","/^[234679]/":". ... ...."}],["United Kingdom","gb","44",".... ......"],["United States","us","1","(...) ...-....",0],["Uruguay","uy","598"],["Uzbekistan","uz","998",".. ... .. .."],["Vanuatu","vu","678"],["Vatican City","va","39",".. .... ....",1],["Venezuela","ve","58"],["Vietnam","vn","84"],["Wallis & Futuna","wf","681",".. .. .."],["Yemen","ye","967"],["Zambia","zm","260"],["Zimbabwe","zw","263"]],ye="react-international-phone-",ae=(...t)=>t.filter(e=>!!e).join(" ").trim(),Ce=(...t)=>ae(...t).split(" ").map(e=>`${ye}${e}`).join(" "),A=({addPrefix:t,rawClassNames:e})=>ae(Ce(...t),...e),ge=({value:t,mask:e,maskSymbol:n,offset:o=0,trimNonMaskCharsLeftover:a=!1,allowMaskOverflow:l=!1})=>{if(t.length<o)return t;let f=t.slice(0,o),i=t.slice(o),r=e.split("").filter(c=>c===n).length,s=i.slice(0,r),u=l?i.slice(r):"",m=f,v=0;for(let c of e.split("")){if(v>=s.length){if(!a&&c!==n){m+=c;continue}break}c===n?(m+=s[v],v+=1):m+=c}return m+u},G=t=>t?/^\d+$/.test(t):!1,X=t=>t.replace(/\D/g,""),be=(t,e)=>{let n=t.style.display;n!=="block"&&(t.style.display="block");let o=t.getBoundingClientRect(),a=e.getBoundingClientRect(),l=a.top-o.top,f=o.bottom-a.bottom;l>=0&&f>=0||(Math.abs(l)<Math.abs(f)?t.scrollTop+=l:t.scrollTop-=f),t.style.display=n},ve=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes("macintosh"),we=(t,e)=>{let n=e.disableDialCodeAndPrefix?!1:e.forceDialCode,o=e.disableDialCodeAndPrefix?!1:e.insertDialCodeOnEmpty,a=t,l=s=>e.trimNonDigitsEnd?s.trim():s;if(!a)return o&&!a.length||n?l(`${e.prefix}${e.dialCode}${e.charAfterDialCode}`):l(a);if(a=X(a),a===e.dialCode&&!e.disableDialCodeAndPrefix)return l(`${e.prefix}${e.dialCode}${e.charAfterDialCode}`);if(e.dialCode.startsWith(a)&&!e.disableDialCodeAndPrefix)return l(n?`${e.prefix}${e.dialCode}${e.charAfterDialCode}`:`${e.prefix}${a}`);if(!a.startsWith(e.dialCode)&&!e.disableDialCodeAndPrefix){if(n)return l(`${e.prefix}${e.dialCode}${e.charAfterDialCode}`);if(a.length<e.dialCode.length)return l(`${e.prefix}${a}`)}let f=()=>{let s=e.dialCode.length,u=a.slice(0,s),m=a.slice(s);return{phoneLeftSide:u,phoneRightSide:m}},{phoneLeftSide:i,phoneRightSide:r}=f();return i=`${e.prefix}${i}${e.charAfterDialCode}`,r=ge({value:r,mask:e.mask,maskSymbol:e.maskChar,trimNonMaskCharsLeftover:e.trimNonDigitsEnd||e.disableDialCodeAndPrefix&&r.length===0,allowMaskOverflow:e.allowMaskOverflow}),e.disableDialCodeAndPrefix&&(i=""),l(`${i}${r}`)},De=({phoneBeforeInput:t,phoneAfterInput:e,phoneAfterFormatted:n,cursorPositionAfterInput:o,leftOffset:a=0,deletion:l})=>{if(o<a)return a;if(!t)return n.length;let f=null;for(let u=o-1;u>=0;u-=1)if(G(e[u])){f=u;break}if(f===null){for(let u=0;u<e.length;u+=1)if(G(n[u]))return u;return e.length}let i=0;for(let u=0;u<f;u+=1)G(e[u])&&(i+=1);let r=0,s=0;for(let u=0;u<n.length&&(r+=1,G(n[u])&&(s+=1),!(s>=i+1));u+=1);if(l!=="backward")for(;!G(n[r])&&r<n.length;)r+=1;return r},Q=({phone:t,prefix:e})=>t?`${e}${X(t)}`:"";function ee({value:t,country:e,insertDialCodeOnEmpty:n,trimNonDigitsEnd:o,countries:a,prefix:l,charAfterDialCode:f,forceDialCode:i,disableDialCodeAndPrefix:r,defaultMask:s,countryGuessingEnabled:u,disableFormatting:m,allowMaskOverflow:v}){let c=t;r&&(c=c.startsWith(`${l}`)?c:`${l}${e.dialCode}${c}`);let w=u?Ee({phone:c,countries:a,currentCountryIso2:e?.iso2}):void 0,p=w?.country??e,b=we(c,{prefix:l,mask:Ae({phone:c,country:p,defaultMask:s,disableFormatting:m}),maskChar:re,dialCode:p.dialCode,trimNonDigitsEnd:o,charAfterDialCode:f,forceDialCode:i,insertDialCodeOnEmpty:n,disableDialCodeAndPrefix:r,allowMaskOverflow:v}),y=u&&!w?.fullDialCodeMatch?e:p;return{phone:Q({phone:r?`${y.dialCode}${b}`:b,prefix:l}),inputValue:b,country:y}}var xe=t=>{if(t?.toLocaleLowerCase().includes("delete")??!1)return t?.toLocaleLowerCase().includes("forward")?"forward":"backward"},ke=(t,{country:e,insertDialCodeOnEmpty:n,phoneBeforeInput:o,prefix:a,charAfterDialCode:l,forceDialCode:f,disableDialCodeAndPrefix:i,countryGuessingEnabled:r,defaultMask:s,disableFormatting:u,countries:m,allowMaskOverflow:v})=>{let c=t.nativeEvent,w=c.inputType,p=xe(w),b=!!w?.startsWith("insertFrom"),y=w==="insertText",C=c?.data||void 0,N=t.target.value,z=t.target.selectionStart??0;if(w?.includes("history"))return{inputValue:o,phone:Q({phone:o,prefix:a}),cursorPosition:o.length,country:e};if(y&&!G(C)&&N!==a)return{inputValue:o,phone:Q({phone:i?`${e.dialCode}${o}`:o,prefix:a}),cursorPosition:z-(C?.length??0),country:e};if(f&&!N.startsWith(`${a}${e.dialCode}`)&&!b){let x=N?o:`${a}${e.dialCode}${l}`;return{inputValue:x,phone:Q({phone:x,prefix:a}),cursorPosition:a.length+e.dialCode.length+l.length,country:e}}let{phone:L,inputValue:d,country:g}=ee({value:N,country:e,trimNonDigitsEnd:p==="backward",insertDialCodeOnEmpty:n,countryGuessingEnabled:r,countries:m,prefix:a,charAfterDialCode:l,forceDialCode:f,disableDialCodeAndPrefix:i,disableFormatting:u,defaultMask:s,allowMaskOverflow:v}),h=De({cursorPositionAfterInput:z,phoneBeforeInput:o,phoneAfterInput:N,phoneAfterFormatted:d,leftOffset:f?a.length+e.dialCode.length+l.length:0,deletion:p});return{phone:L,inputValue:d,cursorPosition:h,country:g}},Ne=(t,e)=>{let n=Object.keys(t),o=Object.keys(e);if(n.length!==o.length)return!1;for(let a of n)if(t[a]!==e[a])return!1;return!0},Pe=()=>{let t=_(),e=_(Date.now()),n=I(()=>{let o=Date.now(),a=t.current?o-e.current:void 0;return t.current=e.current,e.current=o,a},[]);return Z(()=>({check:n}),[n])},Se={size:20,overrideLastItemDebounceMS:-1};function Me(t,e){let{size:n,overrideLastItemDebounceMS:o,onChange:a}={...Se,...e},[l,f]=W(t),i=_([l]),r=_(0),s=Pe(),u=I((c,w)=>{let p=i.current[r.current];if(c===p||typeof c=="object"&&typeof p=="object"&&Ne(c,p))return;let b=o>0,y=s.check(),C=b&&y!==void 0?y>o:!0;if(w?.overrideLastItem!==void 0?w.overrideLastItem:!C)i.current=[...i.current.slice(0,r.current),c];else{let N=i.current.length>=n;i.current=[...i.current.slice(N?1:0,r.current+1),c],N||(r.current+=1)}f(c),a?.(c)},[a,o,n,s]),m=I(()=>{if(r.current<=0)return{success:!1};let c=i.current[r.current-1];return f(c),r.current-=1,a?.(c),{success:!0,value:c}},[a]),v=I(()=>{if(r.current+1>=i.current.length)return{success:!1};let c=i.current[r.current+1];return f(c),r.current+=1,a?.(c),{success:!0,value:c}},[a]);return[l,u,m,v]}var re=".",$={defaultCountry:"us",value:"",prefix:"+",defaultMask:"............",charAfterDialCode:" ",historySaveDebounceMS:200,disableCountryGuess:!1,disableDialCodePrefill:!1,forceDialCode:!1,disableDialCodeAndPrefix:!1,disableFormatting:!1,allowMaskOverflow:!1,countries:R},ne=({defaultCountry:t=$.defaultCountry,value:e=$.value,countries:n=$.countries,prefix:o=$.prefix,defaultMask:a=$.defaultMask,charAfterDialCode:l=$.charAfterDialCode,historySaveDebounceMS:f=$.historySaveDebounceMS,disableCountryGuess:i=$.disableCountryGuess,disableDialCodePrefill:r=$.disableDialCodePrefill,forceDialCode:s=$.forceDialCode,disableDialCodeAndPrefix:u=$.disableDialCodeAndPrefix,disableFormatting:m=$.disableFormatting,allowMaskOverflow:v=$.allowMaskOverflow,onChange:c,inputRef:w})=>{let p={countries:n,prefix:o,charAfterDialCode:l,forceDialCode:u?!1:s,disableDialCodeAndPrefix:u,defaultMask:a,countryGuessingEnabled:!i,disableFormatting:m,allowMaskOverflow:v},b=_(null),y=w||b,C=D=>{Promise.resolve().then(()=>{typeof window>"u"||y.current!==document?.activeElement||y.current?.setSelectionRange(D,D)})},N=I(D=>T({value:D,field:"iso2",countries:n}),[n]),z=I(({inputValue:D,phone:P,country:S})=>{if(!c)return;let B=N(S);c({phone:P,inputValue:D,country:B})},[N,c]),[{phone:L,inputValue:d,country:g},h,x,M]=Me(()=>{let D=T({value:t,field:"iso2",countries:n});D||console.error(`[react-international-phone]: can not find a country with "${t}" iso2 code`);let P=D||T({value:"us",field:"iso2",countries:n}),{phone:S,inputValue:B,country:U}=ee({value:e,country:P,insertDialCodeOnEmpty:!r,...p});return C(B.length),{phone:S,inputValue:B,country:U.iso2}},{overrideLastItemDebounceMS:f,onChange:z}),E=Z(()=>N(g),[g,N]);K(()=>{let D=y.current;if(!D)return;let P=S=>{if(!S.key)return;let B=S.ctrlKey,U=S.metaKey,oe=S.shiftKey;if(S.key.toLowerCase()==="z"){if(ve()){if(!U)return}else if(!B)return;oe?M():x()}};return D.addEventListener("keydown",P),()=>{D.removeEventListener("keydown",P)}},[y,x,M]);let V=D=>{D.preventDefault();let{phone:P,inputValue:S,country:B,cursorPosition:U}=ke(D,{country:E,phoneBeforeInput:d,insertDialCodeOnEmpty:!1,...p});return h({inputValue:S,phone:P,country:B.iso2}),C(U),e},O=I((D,P={focusOnInput:!1})=>{let S=T({value:D,field:"iso2",countries:n});if(!S){console.error(`[react-international-phone]: can not find a country with "${D}" iso2 code`);return}let B=u?"":`${o}${S.dialCode}${l}`;h({inputValue:B,phone:`${o}${S.dialCode}`,country:S.iso2}),P.focusOnInput&&Promise.resolve().then(()=>{y.current?.focus()})},[n,u,o,l,h,y]),[q,Y]=W(!1);return K(()=>{if(!q){Y(!0),e!==L&&c?.({inputValue:d,phone:L,country:E});return}if(e===L)return;let{phone:D,inputValue:P,country:S}=ee({value:e,country:E,insertDialCodeOnEmpty:!r,...p});h({phone:D,inputValue:P,country:S.iso2})},[e]),{phone:L,inputValue:d,country:E,setCountry:O,handlePhoneValueChange:V,inputRef:y}},Ae=({phone:t,country:e,defaultMask:n="............",disableFormatting:o=!1})=>{let a=e.format,l=i=>o?i.replace(new RegExp(`[^${re}]`,"g"),""):i;if(!a)return l(n);if(typeof a=="string")return l(a);if(!a.default)return console.error(`[react-international-phone]: default mask for ${e.iso2} is not provided`),l(n);let f=Object.keys(a).find(i=>{if(i==="default")return!1;if(!(i.charAt(0)==="/"&&i.charAt(i.length-1)==="/"))return console.error(`[react-international-phone]: format regex "${i}" for ${e.iso2} is not valid`),!1;let r=new RegExp(i.substring(1,i.length-1)),s=t.replace(e.dialCode,"");return r.test(X(s))});return l(f?a[f]:a.default)},F=t=>{let[e,n,o,a,l,f]=t;return{name:e,iso2:n,dialCode:o,format:a,priority:l,areaCodes:f}},$e=t=>`Field "${t}" is not supported`,T=({field:t,value:e,countries:n=R})=>{if(["priority"].includes(t))throw new Error($e(t));let o=n.find(a=>{let l=F(a);return e===l[t]});if(o)return F(o)},Ee=({phone:t,countries:e=R,currentCountryIso2:n})=>{let o={country:void 0,fullDialCodeMatch:!1};if(!t)return o;let a=X(t);if(!a)return o;let l=o,f=({country:i,fullDialCodeMatch:r})=>{let s=i.dialCode===l.country?.dialCode,u=(i.priority??0)<(l.country?.priority??0);(!s||u)&&(l={country:i,fullDialCodeMatch:r})};for(let i of e){let r=F(i),{dialCode:s,areaCodes:u}=r;if(a.startsWith(s)){let m=l.country?Number(s)>=Number(l.country.dialCode):!0;if(u){let v=a.substring(s.length);for(let c of u)if(v.startsWith(c))return{country:r,fullDialCodeMatch:!0}}(m||s===a||!l.fullDialCodeMatch)&&f({country:r,fullDialCodeMatch:!0})}l.fullDialCodeMatch||a.length<s.length&&s.startsWith(a)&&(!l.country||Number(s)<=Number(l.country.dialCode))&&f({country:r,fullDialCodeMatch:!1})}if(n){let i=T({value:n,field:"iso2",countries:e});if(!i)return l;let r=i?(s=>{if(!s?.areaCodes)return!1;let u=a.substring(s.dialCode.length);return s.areaCodes.some(m=>m.startsWith(u))})(i):!1;l&&l.country?.dialCode===i.dialCode&&l.country!==i&&l.fullDialCodeMatch&&(!i.areaCodes||r)&&(l={country:i,fullDialCodeMatch:!0})}return l},Ie=(t,e)=>{let n=parseInt(t,16);return Number(n+e).toString(16)},Le="abcdefghijklmnopqrstuvwxyz",Fe="1f1e6",te=Le.split("").reduce((t,e,n)=>({...t,[e]:Ie(Fe,n)}),{}),_e=t=>[te[t[0]],te[t[1]]].join("-"),le=({iso2:t,size:e,src:n,protocol:o="https",disableLazyLoading:a,className:l,style:f,...i})=>{if(!t)return k.createElement("img",{className:A({addPrefix:["flag-emoji"],rawClassNames:[l]}),width:e,height:e,...i});let r=()=>{if(n)return n;let s=_e(t);return`${o}://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${s}.svg`};return k.createElement("img",{className:A({addPrefix:["flag-emoji"],rawClassNames:[l]}),src:r(),width:e,height:e,draggable:!1,"data-country":t,loading:a?void 0:"lazy",style:{width:e,height:e,...f},alt:"",...i})},Be=1e3,Ve=({show:t,dialCodePrefix:e="+",selectedCountry:n,countries:o=R,preferredCountries:a=[],flags:l,onSelect:f,onClose:i,...r})=>{let s=_(null),u=_(),m=Z(()=>{if(!a||!a.length)return o;let d=[],g=[...o];for(let h of a){let x=g.findIndex(M=>F(M).iso2===h);if(x!==-1){let M=g.splice(x,1)[0];d.push(M)}}return d.concat(g)},[o,a]),v=_({updatedAt:void 0,value:""}),c=d=>{let g=v.current.updatedAt&&new Date().getTime()-v.current.updatedAt.getTime()>Be;v.current={value:g?d:`${v.current.value}${d}`,updatedAt:new Date};let h=m.findIndex(x=>F(x).name.toLowerCase().startsWith(v.current.value));h!==-1&&b(h)},w=I(d=>m.findIndex(g=>F(g).iso2===d),[m]),[p,b]=W(w(n)),y=()=>{u.current!==n&&b(w(n))},C=I(d=>{b(w(d.iso2)),f?.(d)},[f,w]),N=d=>{let g=m.length-1,h=x=>d==="prev"?x-1:d==="next"?x+1:d==="last"?g:0;b(x=>{let M=h(x);return M<0?0:M>g?g:M})},z=d=>{if(d.stopPropagation(),d.key==="Enter"){d.preventDefault();let g=F(m[p]);C(g);return}if(d.key==="Escape"){i?.();return}if(d.key==="ArrowUp"){d.preventDefault(),N("prev");return}if(d.key==="ArrowDown"){d.preventDefault(),N("next");return}if(d.key==="PageUp"){d.preventDefault(),N("first");return}if(d.key==="PageDown"){d.preventDefault(),N("last");return}d.key===" "&&d.preventDefault(),d.key.length===1&&!d.altKey&&!d.ctrlKey&&!d.metaKey&&c(d.key.toLocaleLowerCase())},L=I(()=>{if(!s.current||p===void 0)return;let d=F(m[p]).iso2;if(d===u.current)return;let g=s.current.querySelector(`[data-country="${d}"]`);g&&(be(s.current,g),u.current=d)},[p,m]);return K(()=>{L()},[p,L]),K(()=>{s.current&&(t?s.current.focus():y())},[t]),K(()=>{y()},[n]),k.createElement("ul",{ref:s,role:"listbox",className:A({addPrefix:["country-selector-dropdown"],rawClassNames:[r.className]}),style:{display:t?"block":"none",...r.style},onKeyDown:z,onBlur:i,tabIndex:-1,"aria-activedescendant":`react-international-phone__${F(m[p]).iso2}-option`},m.map((d,g)=>{let h=F(d),x=h.iso2===n,M=g===p,E=a.includes(h.iso2),V=g===a.length-1,O=l?.find(q=>q.iso2===h.iso2);return k.createElement(k.Fragment,{key:h.iso2},k.createElement("li",{"data-country":h.iso2,role:"option","aria-selected":x,"aria-label":`${h.name} ${e}${h.dialCode}`,id:`react-international-phone__${h.iso2}-option`,className:A({addPrefix:["country-selector-dropdown__list-item",E&&"country-selector-dropdown__list-item--preferred",x&&"country-selector-dropdown__list-item--selected",M&&"country-selector-dropdown__list-item--focused"],rawClassNames:[r.listItemClassName,E&&r.listItemPreferredClassName,x&&r.listItemSelectedClassName,M&&r.listItemFocusedClassName]}),onClick:()=>C(h),style:r.listItemStyle,title:h.name},k.createElement(le,{iso2:h.iso2,src:O?.src,className:A({addPrefix:["country-selector-dropdown__list-item-flag-emoji"],rawClassNames:[r.listItemFlagClassName]}),style:r.listItemFlagStyle}),k.createElement("span",{className:A({addPrefix:["country-selector-dropdown__list-item-country-name"],rawClassNames:[r.listItemCountryNameClassName]}),style:r.listItemCountryNameStyle},h.name),k.createElement("span",{className:A({addPrefix:["country-selector-dropdown__list-item-dial-code"],rawClassNames:[r.listItemDialCodeClassName]}),style:r.listItemDialCodeStyle},e,h.dialCode)),V?k.createElement("hr",{className:A({addPrefix:["country-selector-dropdown__preferred-list-divider"],rawClassNames:[r.preferredListDividerClassName]}),style:r.preferredListDividerStyle}):null)}))},ze=k.memo(({selectedCountry:t,onSelect:e,disabled:n,hideDropdown:o,countries:a=R,preferredCountries:l=[],flags:f,renderButtonWrapper:i,...r})=>{let[s,u]=W(!1),m=Z(()=>{if(t)return T({value:t,field:"iso2",countries:a})},[a,t]),v=_(null),c=p=>{p.key&&["ArrowUp","ArrowDown"].includes(p.key)&&(p.preventDefault(),u(!0))},w=()=>{let p={title:m?.name,onClick:()=>u(y=>!y),onMouseDown:y=>y.preventDefault(),onKeyDown:c,disabled:o||n,role:"combobox","aria-label":"Country selector","aria-haspopup":"listbox","aria-expanded":s},b=k.createElement("div",{className:A({addPrefix:["country-selector-button__button-content"],rawClassNames:[r.buttonContentWrapperClassName]}),style:r.buttonContentWrapperStyle},k.createElement(le,{iso2:t,src:f?.find(y=>y.iso2===t)?.src,className:A({addPrefix:["country-selector-button__flag-emoji",n&&"country-selector-button__flag-emoji--disabled"],rawClassNames:[r.flagClassName]}),style:{visibility:t?"visible":"hidden",...r.flagStyle}}),!o&&k.createElement("div",{className:A({addPrefix:["country-selector-button__dropdown-arrow",n&&"country-selector-button__dropdown-arrow--disabled",s&&"country-selector-button__dropdown-arrow--active"],rawClassNames:[r.dropdownArrowClassName]}),style:r.dropdownArrowStyle}));return i?i({children:b,rootProps:p}):k.createElement("button",{...p,type:"button",className:A({addPrefix:["country-selector-button",s&&"country-selector-button--active",n&&"country-selector-button--disabled",o&&"country-selector-button--hide-dropdown"],rawClassNames:[r.buttonClassName]}),"data-country":t,style:r.buttonStyle},b)};return k.createElement("div",{className:A({addPrefix:["country-selector"],rawClassNames:[r.className]}),style:r.style,ref:v},w(),k.createElement(Ve,{show:s,countries:a,preferredCountries:l,flags:f,onSelect:p=>{u(!1),e?.(p)},selectedCountry:t,onClose:()=>{u(!1)},...r.dropdownStyleProps}))}),Oe=({dialCode:t,prefix:e,disabled:n,style:o,className:a})=>k.createElement("div",{className:A({addPrefix:["dial-code-preview",n&&"dial-code-preview--disabled"],rawClassNames:[a]}),style:o},`${e}${t}`);se(({value:t,onChange:e,countries:n=R,preferredCountries:o,hideDropdown:a,showDisabledDialCodeAndPrefix:l,disableFocusAfterCountrySelect:f,flags:i,style:r,className:s,inputStyle:u,inputClassName:m,countrySelectorStyleProps:v,dialCodePreviewStyleProps:c,inputProps:w,placeholder:p,disabled:b,name:y,onFocus:C,onBlur:N,required:z,autoFocus:L,...d},g)=>{let h=I(P=>{e?.(P.phone,{country:P.country,inputValue:P.inputValue})},[e]),{phone:x,inputValue:M,inputRef:E,country:V,setCountry:O,handlePhoneValueChange:q}=ne({value:t,countries:n,...d,onChange:h}),Y=d.disableDialCodeAndPrefix&&l&&V?.dialCode,D=I(P=>{O(P.iso2,{focusOnInput:!f})},[O,f]);return ue(g,()=>E.current?Object.assign(E.current,{setCountry:O,state:{phone:x,inputValue:M,country:V}}):null,[E,O,x,M,V]),k.createElement("div",{ref:g,className:A({addPrefix:["input-container"],rawClassNames:[s]}),style:r},k.createElement(ze,{onSelect:D,flags:i,selectedCountry:V?.iso2,countries:n,preferredCountries:o,disabled:b,hideDropdown:a,...v}),Y&&k.createElement(Oe,{dialCode:V.dialCode,prefix:d.prefix??"+",disabled:b,...c}),k.createElement("input",{onChange:q,value:M,type:"tel",ref:E,className:A({addPrefix:["input",b&&"input--disabled"],rawClassNames:[m]}),placeholder:p,disabled:b,style:u,name:y,onFocus:C,onBlur:N,autoFocus:L,required:z,...w}))});const je=R.map(F);function Ze({value:t,onChange:e,defaultCountry:n="us",...o}){const a=_(null),l=_(null),{inputValue:f,handlePhoneValueChange:i,inputRef:r,country:s,setCountry:u}=ne({defaultCountry:n,value:t,countries:R,onChange:C=>{e?.(C.phone)},forceDialCode:!0}),m=`+${s.dialCode}`,{startsWith:v}=ie({sensitivity:"base"}),[c,w]=W(""),[p,b]=W(!1),y=Z(()=>je.filter(C=>v(C.name,c)),[c]);return K(()=>{p&&l.current?.focus()},[p]),H("div",{className:J("flex relative",o.label?"pt-4":""),"aria-label":o["aria-label"],children:[H(de,{isOpen:p,onOpenChange:b,children:[H(ce,{"aria-label":"Select Country",className:"flex px-4 h-10 text-sm items-center rounded-l-md bg-surface-subtle gap-2 uppercase [&[aria-expanded=false]_svg]:rotate-180 border border-r-0 border-border",excludeFromTabOrder:!0,children:[s.iso2,j("svg",{width:"15",height:"8",viewBox:"0 0 15 8",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:j("path",{d:"M1 7L7.5 0.999999L14 7",stroke:"currentColor"})})]}),H("div",{className:J("w-full grid absolute left-0 top-[calc(100%+.25rem)] bg-white z-50 rounded-md text-slate-600 border border-border","shadow-inner",p?"block":"hidden"),ref:a,children:[j("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"none",viewBox:"0 0 17 16",className:"absolute top-4 left-[1.325rem]",children:j("path",{fill:"currentColor",fillRule:"evenodd",d:"M12.3 6.9a4.9 4.9 0 1 1-9.8 0 4.9 4.9 0 0 1 9.8 0Zm-1.1 5.7c-1.1.7-2.4 1.2-3.8 1.2a6.9 6.9 0 1 1 5.3-2.5l3 3-1.4 1.4-3.1-3Z",clipRule:"evenodd"})}),j(fe,{"aria-label":"Search for countries",placeholder:"Search for countries",className:J("pl-12 pr-5 py-4 w-full m-0 border-0 text-fg-strong transition-all duration-[0.25s] ease outline-0 bg-transparent","placeholder:text-fg-strong focus:outline-0","border-b border-border-subtle"),onChange:C=>w(C.target.value),onBlur:()=>{b(!1),r.current?.focus()},value:c,ref:l}),j("div",{className:"p-2.5",children:j(pe,{className:"text-fg-strong max-h-60 overflow-y-auto",selectionMode:"single","aria-label":"Countries List",onSelectionChange:C=>{u(String([...C][0])),w(""),b(!1)},children:(p?y:[]).map(C=>H(me,{id:C.iso2,value:C,textValue:C.iso2,className:"p-3 text-fg data-[hovered]:bg-surface-subtle rounded-md",children:[C.name," (+",C.dialCode,")"]},C.iso2))})})]})]}),j(he,{...o,value:f,inputProps:{onChange:i},ref:r,classNames:{input:J("rounded-l-none",f.trim()===m?"text-slate-600":""),label:"absolute top-0 left-0"}})]})}export{Ze as PhoneInput,Ze as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PhoneInput/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PhoneInput/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsxs as $,jsx as
|
|
1
|
+
"use client";import{jsxs as $,jsx as x}from"react/jsx-runtime";import{useState as L,useRef as R,useEffect as j,useCallback as V}from"react";import{Group as T,Label as _}from"react-aria-components";import{cn as f}from"../../utils/cn.js";function C({autoFocus:y=!1,description:D,errorMessage:b,isDisabled:I=!1,isInvalid:g=!1,isMasked:N=!1,isRequired:z=!0,label:k,length:i=6,name:P,onChange:d,value:S="",type:w="numeric",validationBehavior:W,className:B,classNames:p,inputProps:A,...J}){const[r,h]=L(()=>Array(i).fill("")),o=R([]);j(()=>{o.current=o.current.slice(0,i)},[i]),j(()=>{y&&o.current[0]?.focus()},[y]);const K=V(t=>{const e=t.target.value,u=Number(t.target.getAttribute("data-pin-input-index"));e!==""&&u<i-1&&o.current?.[u+1]?.focus();const l=r.map((s,c)=>c===u?e:s);h(l);const a=l.join("");d?.(a)},[r,i,d]),v=V(t=>{const e=Number(t.currentTarget.getAttribute("data-pin-input-index"));if(t.ctrlKey||t.metaKey)return;const u=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Control","Alt","Meta","Shift","Tab","Enter","Escape"],l={alpha:/^[a-z]$/i,alphanumeric:/^[a-z0-9]$/i,numeric:/^[0-9]$/i};if(!t.key.match(l[w])&&!u.includes(t.key)&&t.preventDefault(),r[e]===""&&e>0&&t.key==="Backspace"){const a=r.map((c,m)=>m===e-1?"":c);h(a),o.current?.[e-1]?.focus(),t.preventDefault();const s=a.join("");d?.(s)}if(r[e]===""&&e<r.length-1&&t.key==="Delete"){const a=r.map((c,m)=>m===e+1?"":c);h(a),o.current?.[e+1]?.focus(),t.preventDefault();const s=a.join("");d?.(s)}},[r,w,d]),E=V(t=>{const e=Number(t.currentTarget.getAttribute("data-pin-input-index"));t.preventDefault();const u=t.clipboardData?.getData("text");if(!u)return;const l=u.split("").filter(n=>{switch(w){case"alpha":return/^[a-zA-Z]$/.test(n);case"alphanumeric":return/^[a-z0-9]$/i.test(n);default:return/^[0-9]$/.test(n)}});if(l.length===0)return;const a=[...r];let s=e;for(let n=0;n<l.length&&e+n<i;n++)a[e+n]=l[n],s=e+n;h(a);const c=a.join("");d?.(c);const m=s+1<i?s+1:i-1;o.current[m]?.focus()},[r,w,i,d]);return $(T,{className:f("flex flex-wrap gap-2",B),"aria-label":k,...J,children:[k&&x(_,{className:f("flex text-fg-muted text-sm grow shrink-0 basis-full",p?.label),children:k}),r.map((t,e)=>x("div",{className:f("flex flex-col w-full flex-1 text-fg",p?.inputWrap),children:x("input",{type:N?"password":"text",autoComplete:"one-time-code","data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other",...A,className:f("border-solid border rounded-md","text-sm text-fg placeholder-fg-subtle text-center","h-10 px-2 py-0 m-0 w-full","bg-white","[&::-ms-reveal]:hidden [&::-ms-clear]:hidden","transition-all duration-200 ease-in-out","hover:border-border-emphasis","focus:outline-2 focus:outline focus:outline-border-subtle focus:border-border-emphasis","disabled:border-border-subtle disabled:bg-surface-subtle",g&&"border-danger-soft bg-danger-surface text-danger",g&&"hover:border-danger-soft focus:border-danger-soft focus:outline-border-subtle",p?.input,A?.className),onChange:K,onKeyDown:v,onPaste:E,ref:u=>{o.current[e]=u},value:t,maxLength:1,"data-pin-input-index":e,disabled:I,required:z,"aria-label":`Pin Input Digit ${e+1}`})},`pin-input-${e}`)),(D||g&&b)&&$("div",{className:f("flex flex-row flex-wrap grow shrink-0 basis-full",p?.textWrap),children:[D&&x("p",{className:f("flex text-fg-muted text-sm grow shrink-0 basis-full",p?.description),children:D}),g&&b&&typeof b=="string"&&x("p",{className:f("flex text-danger text-sm grow shrink-0 basis-full",p?.error),children:b})]})]})}export{C as PinInput,C as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PinInput/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PinInput/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as i,Fragment as
|
|
1
|
+
"use client";import{jsx as t,jsxs as i,Fragment as m}from"react/jsx-runtime";import{ProgressBar as u,Label as h}from"react-aria-components";import{motion as p}from"framer-motion";import{cn as r}from"../../utils/cn.js";function g({label:a,isIndeterminate:n,showValue:l=!0,width:d,className:s,classNames:e,...c}){return t(u,{style:{width:d||"100%"},className:r("overflow-hidden",s),...c,children:({percentage:o,valueText:f})=>i(m,{children:[i("div",{className:r("flex items-center justify-between gap-2 mb-1",e?.labelWrapper),children:[t(h,{className:r("text-sm",e?.label),children:a}),l&&t("span",{className:r("text-sm",e?.value),children:f})]}),t("div",{className:r("overflow-hidden forced-color-adjust-none h-2.5 rounded will-change-transform bg-slate-300",e?.trackWrapper),children:t(p.div,{style:{width:!n&&typeof o=="number"?`${o}%`:""},...n&&{animate:{x:["-100%","250px"]},transition:{repeat:1/0,duration:1.5}},className:r("h-full bg-surface-inverse-hover rounded transition-width duration-500 ease-in-out",{"w-1/2":n,"transition-none":n},e?.track)})})]})})}export{g as LinearProgressbar,g as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Progressbar/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Progressbar/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t,jsxs as g,Fragment as v}from"react/jsx-runtime";import{Radio as p}from"react-aria-components";import{cn as s}from"../../utils/cn.js";function m({control:e,classNames:i,isHovered:d,isFocused:r,isFocusVisible:n,isDisabled:a,isInvalid:u,isSelected:o,isPressed:l,isReadOnly:b,isRequired:f,defaultChildren:h,...x}){const c={isHovered:d,isFocused:r,isFocusVisible:n,isDisabled:a,isInvalid:u,isSelected:o,isPressed:l,isReadOnly:b,isRequired:f};return e?typeof e=="function"?e(c):e:t("div",{"data-hovered":d,"data-focused":r,"data-disabled":a,"data-invalid":u,"data-selected":o,"data-pressed":l,className:s("flex items-center justify-center w-6 h-6 border-solid border border-border ransition-all duration-300 ease rounded-full",'data-[hovered="true"]:border-border-emphasis','data-[focused="true"]:border-border-emphasis data-[focused="true"]:outline-2 data-[focused="true"]:outline data-[focused="true"]:outline-border-subtle','data-[disabled="true"]:border-border-subtle data-[disabled="true"]:bg-surface-subtle','data-[invalid="true"]:bg-danger-surface data-[invalid="true"]:text-danger data-[invalid="true"]:border-danger-soft','data-[invalid="true"]:data-[disabled="true"]:border-danger-ring data-[invalid="true"]:data-[disabled="true"]:bg-danger-surface','data-[invalid="true"]:data-[hovered="true"]:border-danger','data-[invalid="true"]:data-[focused="true"]:border-danger data-[invalid="true"]:data-[focused="true"]:outline-danger-ring','data-[invalid="true"]:data-[selected="true"]:bg-danger-surface data-[invalid="true"]:data-[selected="true"]:border-danger-soft','data-[invalid="true"]:data-[pressed="true"]:bg-danger data-[invalid="true"]:data-[pressed="true"]:border-danger',i?.control),children:t("div",{"data-invalid":u,className:s('w-3 h-3 rounded-full bg-surface-inverse opacity-0 transition-all duration-300 ease data-[invalid="true"]:bg-danger-soft',{"opacity-100":o})})})}function N({children:e,slots:i,className:d,classNames:r,...n}){return t(p,{className:s("flex items-center gap-2 group","invalid:text-danger-soft invalid:disabled:text-red-300","disabled:text-fg-subtle",d),...n,children:a=>g(v,{children:[t(m,{control:i?.control,classNames:r,...a}),typeof e=="function"?e(a):e]})})}export{N as Radio,N as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Radio/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Radio/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as r,Fragment as c}from"react/jsx-runtime";import{RadioGroup as p,Label as
|
|
1
|
+
import{jsx as e,jsxs as r,Fragment as c}from"react/jsx-runtime";import{RadioGroup as p,Label as d}from"react-aria-components";import{cn as o}from"../../utils/cn.js";function g({label:a,errorMessage:l,description:f,orientation:m,children:t,className:x,...s}){return e(p,{className:o("flex flex-col gap-4",x),orientation:m,...s,children:typeof t=="function"?t:r(c,{children:[a&&e(d,{className:"flex text-fg-muted text-xs",children:a}),e("div",{className:o("flex flex-col gap-2",m==="horizontal"&&"flex-row items-center gap-4"),children:t}),f&&e("p",{className:"flex mt-1 text-fg-muted text-sm",children:f}),l&&e("p",{className:"flex pl-6 text-danger-soft text-sm",children:l})]})})}export{g as RadioGroup,g as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './RadioGroup/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './RadioGroup/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ResendCode/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ResendCode/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsxs as
|
|
1
|
+
"use client";import{jsxs as d,jsx as o}from"react/jsx-runtime";import{useRef as l}from"react";import{useSelect as z,useButton as A,HiddenSelect as E}from"react-aria";import{useInteractOutside as G}from"@react-aria/interactions";import{useSelectState as J}from"react-stately";import{cn as e}from"../../utils/cn.js";import{ChevronIcon as Q,SelectPopover as T,SelectListBox as U}from"./parts.js";import"react-aria-components";function se(c){const{label:a,description:u,errorMessage:f,children:g,placeholder:x,slots:h,popoverOffset:v,className:N,classNames:t,isLoading:I,name:b,selectedKey:P,defaultSelectedKey:S,onSelectionChange:y,isRequired:w,items:B,autoFocus:R,isInvalid:C,"aria-label":O,"aria-labelledby":L}=c,n=!!(c.isDisabled||I),m={label:a,children:g,items:B,name:b,selectedKey:P,defaultSelectedKey:S,onSelectionChange:y,isDisabled:n,isRequired:w,autoFocus:R,isInvalid:C,"aria-label":O,"aria-labelledby":L},s=J(m),p=l(null),r=l(null),j=l(null),H=l(null),{labelProps:M,triggerProps:D,valueProps:K,menuProps:_,descriptionProps:k,errorMessageProps:q,isInvalid:i}=z(m,s,r),{buttonProps:F}=A(D,r);return G({ref:p,onInteractOutside:()=>s.close()}),d("div",{ref:p,className:e("flex flex-col","w-full",N),children:[o("label",{...M,className:e("flex","text-xs text-fg-muted",t?.label),children:a}),o(E,{state:s,triggerRef:r,label:a,name:b,isDisabled:n}),d("div",{className:e("flex","relative","w-full",t?.comboBoxContainer),children:[d("button",{...F,ref:r,className:e("flex items-center justify-between gap-2","border border-solid border-border","text-sm text-fg text-left","py-0 px-3","h-10 w-full","m-0","rounded-md","bg-white","cursor-pointer","transition-all ease-in-out duration-200","hover:border-border-emphasis","focus:outline focus:outline-2 focus:outline-border-subtle focus:border-border-emphasis","disabled:bg-surface-subtle disabled:border-border disabled:cursor-default",i&&"border-danger-soft bg-danger-surface text-danger hover:border-danger focus:border-danger focus:outline-danger-ring",t?.input),children:[o("span",{...K,className:e("truncate",!s.selectedItem&&"text-fg-subtle",t?.value),children:s.selectedItem?s.selectedItem.rendered:x??"Select..."}),o("span",{className:e("shrink-0 [&_svg]:w-4 [&_svg]:h-4",t?.arrowButton),children:o(Q,{isOpen:s.isOpen,isDisabled:n,isInvalid:i,buttonIcon:h?.buttonIcon})})]}),s.isOpen&&o(T,{popoverRef:H,offset:v,className:e(t?.listContainer),children:o(U,{state:s,listBoxProps:_,listBoxRef:j,optionClassName:e(t?.option),sectionHeadingClassName:e(t?.sectionHeading),className:e("max-h-80","overflow-y-auto","outline-none",t?.list)})})]}),u&&o("span",{...k,className:e("flex","text-xs","text-fg-muted",t?.description),children:u}),i&&typeof f=="string"&&o("span",{...q,className:e("flex","text-xs","text-danger-soft",t?.errorMessage),children:f})]})}export{se as ButtonSelect,se as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsxs as G,jsx as
|
|
1
|
+
"use client";import{jsxs as G,jsx as c}from"react/jsx-runtime";import{forwardRef as Se,useRef as g,useState as Ke,useMemo as I,isValidElement as Ve,useEffect as R}from"react";import{useFilter as we,useObjectRef as Be,useComboBox as Fe,useButton as Ne,HiddenSelect as Pe}from"react-aria";import{Section as Me,useComboBoxState as Ae}from"react-stately";import{cn as r}from"../../utils/cn.js";import{Pulse as Oe}from"../Loader/Pulse.js";import{SelectTags as Te,ChevronIcon as ke,SelectOverlay as De,SelectListBox as Le}from"./parts.js";import"react-aria-components";function S(s){return s?typeof s.rendered=="string"?s.rendered:s.textValue??"":""}function Ee(s,i){const f=i.trim().toLowerCase();let p=null,a=s.getFirstKey();for(;a!=null;){const m=s.getItem(a);if(m?.type==="item"&&(p==null&&(p=a),f.length>0&&(m.textValue??"").toLowerCase().split(/\s+/).includes(f)))return a;a=s.getKeyAfter(a)}return p}function _(s,i){const f=s.toLowerCase(),p=f.split(/\s+/);return p.includes(i)?0:f.startsWith(i)?1:p.some(a=>a.startsWith(i))?2:3}function J(s){const i=s.props;return typeof i.textValue=="string"?i.textValue:typeof i.children=="string"?i.children:""}function He(s,i){const{label:f,description:p,errorMessage:a,children:m,placeholder:k,isLoading:D,slots:L,popoverOffset:Q,className:U,classNames:l,autoComplete:K,menuTrigger:X,selectTextOnFocus:Y=!0,autoFocusFirstOption:Z=!0,searchable:je,selectionMode:$="single",selectedKey:ee,defaultSelectedKey:te,selectedKeys:V,defaultSelectedKeys:w,onSelectionChange:E,name:ne,...x}=s,u=$==="multiple",B=!!x.isDisabled,C=g(!1),h=g(null),d=x.inputValue!==void 0,[F,y]=Ke(""),N=d?x.inputValue:F,oe=I(()=>{const e=(N??"").trim().toLowerCase();if(d||typeof m=="function"||e===""||!Array.isArray(m))return m;const n=m,o=n.filter(b=>Ve(b));return o.length!==n.length||o.length===0||o.some(b=>b.type===Me)?m:[...o].sort((b,Re)=>_(J(b),e)-_(J(Re),e))},[m,d,N]),re=I(()=>u&&V?[...V]:void 0,[u,V]),se=I(()=>u&&w?[...w]:void 0,[u,w]),H={...x,label:f,children:oe,placeholder:k,isDisabled:B,menuTrigger:X??"focus",autoComplete:K,inputValue:N,...u?{selectionMode:"multiple",value:re,defaultValue:se,onChange:E}:{selectedKey:ee,defaultSelectedKey:te,onSelectionChange:e=>{if(!d){const n=e!=null?h.current?.collection.getItem(e):null;y(S(n))}E?.(e)}},onInputChange:e=>{d||y(e),x.onInputChange?.(e),!u&&e===""&&h.current?.selectedKey!=null&&h.current.setSelectedKey(null)}},{contains:le}=we({sensitivity:"base"}),t=Ae({...H,defaultFilter:le,allowsEmptyCollection:!0});R(()=>{h.current=t});const j=g(0),P=t.selectionManager.selectedKeys.size;R(()=>{u&&(P>j.current&&!d&&y(""),j.current=P)},[u,P,d]);const M=S(t.selectedItem);R(()=>{d||u||C.current||F===M||y(M)},[M,d,F,u]);const ie=g(null),W=Be(i),q=g(null),z=g(null),A=g(null),O=g(null),T=g(null),{inputProps:ue,listBoxProps:ce,labelProps:ae,buttonProps:de,descriptionProps:fe,errorMessageProps:pe}=Fe({...H,inputRef:W,listBoxRef:q,popoverRef:z,buttonRef:A},t),{buttonProps:me}=Ne(de,A),v=t.displayValidation.isInvalid,{onKeyDown:ge,onFocus:be,onBlur:he,...xe}=ue,ye=e=>{e.key==="Home"||e.key==="End"||ge?.(e)};R(()=>{const e=t.selectionManager;if(!Z||!t.isOpen||t.inputValue.length===0){T.current=null;return}const n=e.focusedKey;if(n!=null&&n!==T.current)return;const o=Ee(t.collection,t.inputValue);T.current=o??null,o!=null&&o!==n&&e.setFocusedKey(o)});const Ce=e=>{be?.(e);const n=C.current;if(C.current=!0,n||!Y)return;const o=e.target,b=o.value;b&&requestAnimationFrame(()=>{o.value===b&&o.select()})},ve=e=>{he?.(e);const n=e.currentTarget;requestAnimationFrame(()=>{document.activeElement!==n&&(C.current=!1,h.current?.close(),d||y(u?"":S(h.current?.selectedItem)))})},Ie=I(()=>new Proxy(t,{get(e,n){return n==="setValue"?o=>e.setSelectedKey(o):Reflect.get(e,n)}}),[t]);return G("div",{ref:ie,className:r("flex flex-col","w-full",U),children:[c("label",{...ae,className:r("flex","text-xs text-fg-muted",l?.label),children:f}),c(Pe,{state:Ie,triggerRef:O,label:f,name:ne,isDisabled:B,autoComplete:K}),u&&c(Te,{items:(t.selectedItems??[]).map(e=>({id:e.key,label:S(e)})),onRemove:e=>t.selectionManager.toggleSelection(e),classNames:{tagGroup:r(l?.tagGroup),tag:r(l?.tag),tagRemoveButton:r(l?.tagRemoveButton)}}),G("div",{ref:O,className:r("flex","relative","w-full",l?.comboBoxContainer),children:[c("input",{...xe,onKeyDown:ye,onFocus:Ce,onBlur:ve,ref:W,placeholder:k,autoComplete:K,className:r("border border-solid border-border","text-sm text-fg","py-0 px-2","h-10 w-full","m-0","rounded-md","bg-white","transition-all ease-in-out duration-200","hover:border-border-emphasis","focus:border-border-emphasis focus:outline focus:outline-2 focus:outline-border-subtle","disabled:bg-surface-subtle disabled:border-border",D?"disabled:text-fg":"disabled:text-fg-muted",v&&"border-danger-soft bg-danger-surface text-danger placeholder:text-fg-subtle",v&&"hover:border-danger focus:border-danger focus:outline-danger-ring",l?.input)}),D?c("div",{className:r("absolute top-2 right-2","block",l?.loader),children:L?.loadingIcon||c(Oe,{})}):c("button",{...me,ref:A,className:r("absolute top-2 right-0","block","border-none bg-none",l?.arrowButton),children:c(ke,{isOpen:t.isOpen,isDisabled:B,isInvalid:v,buttonIcon:L?.buttonIcon})}),t.isOpen&&t.collection.size>0&&c(De,{state:t,triggerRef:O,popoverRef:z,offset:Q,className:r(l?.listContainer),children:c(Le,{state:t,listBoxProps:ce,listBoxRef:q,optionVirtualFocus:!0,optionClassName:r(l?.option),sectionHeadingClassName:r(l?.sectionHeading),className:r("max-h-80","overflow-y-auto","outline-none",l?.list)})})]}),p&&c("span",{...fe,className:r("flex","text-xs","text-fg-muted",l?.description),children:p}),v&&typeof a=="string"&&c("span",{...pe,className:r("flex","text-xs","text-danger-soft",l?.errorMessage),children:a})]})}const Ye=Se(He);export{Ye as ComboBoxSelect,Ye as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsxs as d,jsx as
|
|
1
|
+
"use client";import{jsxs as d,jsx as o}from"react/jsx-runtime";import{useRef as a}from"react";import{useButton as D}from"react-aria";import{useListState as F,useOverlayTriggerState as H}from"react-stately";import{cn as e}from"../../utils/cn.js";import{ChevronIcon as _,SelectOverlay as k,SelectListBox as T}from"./parts.js";import"react-aria-components";function J(u){const{label:f,description:b,errorMessage:m,children:x,placeholder:h,slots:v,popoverOffset:y,className:N,classNames:t,isLoading:S,items:B,isInvalid:w,"aria-label":p,"aria-labelledby":I,selectedKeys:O,defaultSelectedKeys:C,onSelectionChange:R}=u,g=!!(u.isDisabled||S),r=F({children:x,items:B,selectionMode:"multiple",selectionBehavior:"toggle",selectedKeys:O,defaultSelectedKeys:C,onSelectionChange:s=>{s!=="all"&&R?.([...s])}}),l=H({}),L=a(null),n=a(null),M=a(null),j=a(null),{buttonProps:P}=D({isDisabled:g,onPress:()=>l.toggle(),"aria-label":p,"aria-labelledby":I},n),i=!!w,c=[...r.collection.getKeys()].map(s=>r.collection.getItem(s)).filter(s=>s!=null&&s.type==="item"&&r.selectionManager.isSelected(s.key)),K=c.map(s=>s.textValue).join(", ");return d("div",{ref:L,className:e("flex flex-col","w-full",N),children:[o("label",{className:e("flex","text-xs text-fg-muted",t?.label),children:f}),d("div",{className:e("flex","relative","w-full",t?.comboBoxContainer),children:[d("button",{...P,ref:n,"aria-haspopup":"listbox","aria-expanded":l.isOpen,className:e("flex items-center justify-between gap-2","border border-solid border-border","text-sm text-fg text-left","py-0 px-3","h-10 w-full","m-0","rounded-md","bg-white","cursor-pointer","transition-all ease-in-out duration-200","hover:border-border-emphasis","focus:outline focus:outline-2 focus:outline-border-subtle focus:border-border-emphasis","disabled:bg-surface-subtle disabled:border-border disabled:cursor-default",i&&"border-danger-soft bg-danger-surface text-danger hover:border-danger focus:border-danger focus:outline-danger-ring",t?.input),children:[o("span",{className:e("truncate",c.length===0&&"text-fg-subtle",t?.value),children:c.length>0?K:h??"Select..."}),o("span",{className:e("shrink-0 [&_svg]:w-4 [&_svg]:h-4",t?.arrowButton),children:o(_,{isOpen:l.isOpen,isDisabled:g,isInvalid:i,buttonIcon:v?.buttonIcon})})]}),l.isOpen&&o(k,{state:l,triggerRef:n,popoverRef:j,offset:y,className:e(t?.listContainer),children:o(T,{state:r,listBoxProps:{"aria-label":f??p??"Options",autoFocus:"first",shouldFocusWrap:!0},listBoxRef:M,optionClassName:e(t?.option),sectionHeadingClassName:e(t?.sectionHeading),className:e("max-h-80","overflow-y-auto","outline-none",t?.list)})})]}),b&&o("span",{className:e("flex","text-xs","text-fg-muted",t?.description),children:b}),i&&typeof m=="string"&&o("span",{className:e("flex","text-xs","text-danger-soft",t?.errorMessage),children:m})]})}export{J as MultiButtonSelect,J as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as r}from"react/jsx-runtime";import{forwardRef as
|
|
1
|
+
"use client";import{jsx as r}from"react/jsx-runtime";import{forwardRef as c,Children as n,isValidElement as l}from"react";import{ButtonSelect as m}from"./ButtonSelect.js";import{ComboBoxSelect as u}from"./ComboBoxSelect.js";import{MultiButtonSelect as f}from"./MultiButtonSelect.js";import{Section as a}from"react-stately";import"react-aria";import"@react-aria/interactions";import"../../utils/cn.js";import"./parts.js";import"react-aria-components";import"../Loader/Pulse.js";const h=8;function s(t){if(t.items)return[...t.items].length;if(typeof t.children=="function")return Number.POSITIVE_INFINITY;let e=0;return n.forEach(t.children,o=>{if(l(o)&&o.type===a){const i=o.props.children;e+=n.count(i)}else e+=1}),e}function S(t,e){return(t.searchable==="auto"?s(t)>h:!!t.searchable)?r(u,{ref:e,...t}):t.selectionMode==="multiple"?r(f,{...t}):r(m,{...t})}const _=c(S);export{_ as Select,_ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Option as
|
|
1
|
+
import{Option as O}from"./Option.js";import{Select as b}from"./Select.js";import{Section as g}from"react-stately";import"react/jsx-runtime";import"react";import"./ButtonSelect.js";import"react-aria";import"@react-aria/interactions";import"../../utils/cn.js";import"./parts.js";import"react-aria-components";import"./ComboBoxSelect.js";import"../Loader/Pulse.js";import"./MultiButtonSelect.js";export{O as Option,g as Section,b as Select};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{useState as m,useLayoutEffect as x,useRef as b}from"react";import{usePopover as g,Overlay as h,DismissButton as p,useListBox as v,useListBoxSection as y,useOption as _}from"react-aria";import{TagGroup as k,TagList as w,Tag as N,Button as S}from"react-aria-components";import{cn as a}from"../../utils/cn.js";function f({item:e,state:o,shouldUseVirtualFocus:r,className:t}){const n=b(null),{optionProps:d,isFocused:i,isSelected:u,isDisabled:l}=_({key:e.key,shouldUseVirtualFocus:r},o,n);return s("li",{...d,ref:n,"data-focused":i||void 0,"data-selected":u||void 0,"data-disabled":l||void 0,className:a("flex flex-auto items-center","rounded-md","p-2.5 mx-1.5","text-sm","cursor-default outline-none","text-fg","transition-all ease-in-out duration-150","data-[focused]:bg-surface-subtle","data-[selected]:font-semibold","data-[disabled]:text-fg-muted",t),children:e.rendered})}function L({section:e,state:o,shouldUseVirtualFocus:r,optionClassName:t,headingClassName:n}){const{itemProps:d,headingProps:i,groupProps:u}=y({heading:e.rendered,"aria-label":e["aria-label"]});return c("li",{...d,className:a("pt-1.5 first:pt-0"),children:[e.rendered!=null&&s("span",{...i,className:a("block px-3 pb-1 text-xs font-semibold text-fg-subtle",n),children:e.rendered}),s("ul",{...u,children:[...o.collection.getChildren(e.key)].map(l=>s(f,{item:l,state:o,shouldUseVirtualFocus:r,className:t},l.key))})]})}function O({state:e,listBoxProps:o,listBoxRef:r,className:t,optionClassName:n,sectionHeadingClassName:d,optionVirtualFocus:i}){const{listBoxProps:u}=v(o,e,r);return s("ul",{...u,ref:r,className:t,children:[...e.collection].map(l=>l.type==="section"?s(L,{section:l,state:e,shouldUseVirtualFocus:i,optionClassName:n,headingClassName:d},l.key):s(f,{item:l,state:e,shouldUseVirtualFocus:i,className:n},l.key))})}function W({children:e,popoverRef:o,offset:r,className:t}){return s("div",{ref:o,style:{marginTop:r??4},className:a("absolute top-full left-0 z-50 w-full","px-0 py-1.5","rounded-md bg-white","border border-solid border-border","shadow-[0_10px_15px_-3px_rgba(0,0,0,0.1),0_4px_6px_-4px_rgba(0,0,0,0.1)]",t),children:e})}function z({state:e,triggerRef:o,popoverRef:r,offset:t,className:n,children:d}){const{popoverProps:i}=g({triggerRef:o,popoverRef:r,isNonModal:!0,placement:"bottom start",offset:t??4},e),[u,l]=m();return x(()=>{o.current&&l(o.current.offsetWidth)},[o]),s(h,{children:c("div",{...i,ref:r,style:{...i.style,width:u},className:a("z-50","px-0 py-1.5","rounded-md bg-white","border border-solid border-border","shadow-[0_10px_15px_-3px_rgba(0,0,0,0.1),0_4px_6px_-4px_rgba(0,0,0,0.1)]",n),children:[s(p,{onDismiss:()=>e.close()}),d,s(p,{onDismiss:()=>e.close()})]})})}function C({items:e,onRemove:o,classNames:r}){return e.length===0?null:s(k,{"aria-label":"Selected options",onRemove:t=>{for(const n of t)o(n)},className:a("mb-1.5",r?.tagGroup),children:s(w,{items:e,className:a("flex flex-wrap gap-1.5"),children:t=>c(N,{id:t.id,textValue:t.label,className:a("inline-flex items-center gap-1","rounded-md bg-surface-subtle text-fg","px-2 py-0.5 text-xs","outline-none","data-[focus-visible]:ring-2 data-[focus-visible]:ring-border",r?.tag),children:[t.label,s(S,{slot:"remove","aria-label":`Remove ${t.label}`,className:a("leading-none outline-none","text-fg-muted hover:text-fg","data-[focus-visible]:text-fg",r?.tagRemoveButton),children:"×"})]})})})}function F({isOpen:e,isDisabled:o,isInvalid:r,buttonIcon:t}){return t?typeof t=="function"?t({isOpen:e,isDisabled:o,isInvalid:r}):t:s("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:a("transition-all ease-in-out duration-200",e?"rotate-180":"rotate-0"),children:s("path",{d:"M6 9L12 15L18 9",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:a(["stroke-fg",o&&"stroke-fg-subtle",r&&"stroke-danger-soft"])})})}export{F as ChevronIcon,O as SelectListBox,f as SelectOption,z as SelectOverlay,W as SelectPopover,C as SelectTags};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Select/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Select/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Skeleton/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Skeleton/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as o,jsxs as f,Fragment as m}from"react/jsx-runtime";import{Slider as p,Label as s,SliderOutput as v,SliderTrack as x,SliderThumb as w}from"react-aria-components";import{cn as a}from"../../utils/cn.js";function S({label:n,showOutput:d=!0,thumbLabels:c,classNames:t,orientation:l,isDisabled:e,children:u,...b}){return o(p,{orientation:l,isDisabled:e,className:a('data-[orientation="horizontal"]:w-full data-[orientation="horizontal"]:flex data-[orientation="horizontal"]:flex-wrap','data-[orientation="vertical"]:w-8 data-[orientation="vertical"]:block data-[orientation="vertical"]:h-full',t?.base),...b,children:u||f(m,{children:[(n||d)&&f("div",{className:a("w-full flex justify-between items-center",l==="vertical"&&"gap-2 w-max mb-2",t?.outputWrapper),children:[o(s,{className:a("flex-1 text-sm",e&&"opacity-50",t?.label),children:n}),d&&o(v,{className:a("flex flex-initial ml-auto justify-end text-sm",e&&"opacity-50",t?.output),children:({state:i})=>i.values.map((h,r)=>i.getThumbValueLabel(r)).join(" – ")})]}),o(x,{className:a('data-[orientation="horizontal"]:w-full data-[orientation="horizontal"]:h-8','data-[orientation="vertical"]:w-8 data-[orientation="vertical"]:h-full',"transition-all duration-200 ease","before:bg-slate-300 before:block before:absolute cursor-pointer",'data-[orientation="horizontal"]:before:w-full data-[orientation="horizontal"]:before:h-0.5','data-[orientation="horizontal"]:before:top-1/2 data-[orientation="horizontal"]:before:-translate-y-1/2','data-[orientation="vertical"]:before:w-0.5 data-[orientation="vertical"]:before:h-full data-[orientation="vertical"]:before:left-1/2 data-[orientation="vertical"]:before:-translate-y-1/2 data-[orientation="vertical"]:before:-translate-x-1/2',e&&"opacity-50 before:cursor-default",t?.track),children:({state:i})=>i.values.map((h,r)=>o(w,{index:r,"aria-label":c?.[r],className:a("w-6 h-6 bg-slate-300 forced-color-adjust-none cursor-pointer top-1/2","border-2 border-
|
|
1
|
+
"use client";import{jsx as o,jsxs as f,Fragment as m}from"react/jsx-runtime";import{Slider as p,Label as s,SliderOutput as v,SliderTrack as x,SliderThumb as w}from"react-aria-components";import{cn as a}from"../../utils/cn.js";function S({label:n,showOutput:d=!0,thumbLabels:c,classNames:t,orientation:l,isDisabled:e,children:u,...b}){return o(p,{orientation:l,isDisabled:e,className:a('data-[orientation="horizontal"]:w-full data-[orientation="horizontal"]:flex data-[orientation="horizontal"]:flex-wrap','data-[orientation="vertical"]:w-8 data-[orientation="vertical"]:block data-[orientation="vertical"]:h-full',t?.base),...b,children:u||f(m,{children:[(n||d)&&f("div",{className:a("w-full flex justify-between items-center",l==="vertical"&&"gap-2 w-max mb-2",t?.outputWrapper),children:[o(s,{className:a("flex-1 text-sm",e&&"opacity-50",t?.label),children:n}),d&&o(v,{className:a("flex flex-initial ml-auto justify-end text-sm",e&&"opacity-50",t?.output),children:({state:i})=>i.values.map((h,r)=>i.getThumbValueLabel(r)).join(" – ")})]}),o(x,{className:a('data-[orientation="horizontal"]:w-full data-[orientation="horizontal"]:h-8','data-[orientation="vertical"]:w-8 data-[orientation="vertical"]:h-full',"transition-all duration-200 ease","before:bg-slate-300 before:block before:absolute cursor-pointer",'data-[orientation="horizontal"]:before:w-full data-[orientation="horizontal"]:before:h-0.5','data-[orientation="horizontal"]:before:top-1/2 data-[orientation="horizontal"]:before:-translate-y-1/2','data-[orientation="vertical"]:before:w-0.5 data-[orientation="vertical"]:before:h-full data-[orientation="vertical"]:before:left-1/2 data-[orientation="vertical"]:before:-translate-y-1/2 data-[orientation="vertical"]:before:-translate-x-1/2',e&&"opacity-50 before:cursor-default",t?.track),children:({state:i})=>i.values.map((h,r)=>o(w,{index:r,"aria-label":c?.[r],className:a("w-6 h-6 bg-slate-300 forced-color-adjust-none cursor-pointer top-1/2","border-2 border-border-emphasis rounded-full",e&&"cursor-default",l==="vertical"&&"left-1/2",t?.thumb)},r))})]})})}export{S as Slider,S as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Slider/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Slider/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as s,jsxs as u,Fragment as c}from"react/jsx-runtime";import{Switch as m}from"react-aria-components";import{cn as
|
|
1
|
+
"use client";import{jsx as s,jsxs as u,Fragment as c}from"react/jsx-runtime";import{Switch as m}from"react-aria-components";import{cn as i}from"../../utils/cn.js";function x({children:e,className:a,classNames:b,...l}){return s(m,{className:i("flex items-center gap-2 text-sm text-fg-muted forced-color-adjust-none group","",a),...l,children:r=>{const{isSelected:n,isHovered:o,isFocused:t,isPressed:d,isDisabled:f}=r;return u(c,{children:[s("div",{className:i("w-12 h-7 bg-transparent border-solid border border-border 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",[o&&"border-border-emphasis",n&&[" bg-slate-300 before:translate-x-full before:bg-white",(o||t)&&"border-border-emphasis"],t&&["outline outline-2 outline-border-subtle"],d&&"before:bg-slate-400",f&&"bg-surface-subtle",b?.indicator])}),typeof e=="function"?e({defaultChildren:void 0,...r}):e]})}})}export{x as Switch,x as default};
|