@xploreu/components 0.4.9 → 0.4.11

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.
Files changed (47) hide show
  1. package/dist/chunk-34QGQHPC.js +2 -0
  2. package/dist/chunk-34QGQHPC.js.map +1 -0
  3. package/dist/chunk-44LMOSRI.js +2 -0
  4. package/dist/chunk-44LMOSRI.js.map +1 -0
  5. package/dist/chunk-BIFRDHOB.js +2 -0
  6. package/dist/{chunk-XZKSYHE5.js.map → chunk-BIFRDHOB.js.map} +1 -1
  7. package/dist/chunk-CXTKXMUH.js +2 -0
  8. package/dist/{chunk-XLACGAIR.js.map → chunk-CXTKXMUH.js.map} +1 -1
  9. package/dist/chunk-I57X26R2.js +2 -0
  10. package/dist/chunk-I57X26R2.js.map +1 -0
  11. package/dist/chunk-NVQMVFSP.js +2 -0
  12. package/dist/chunk-NVQMVFSP.js.map +1 -0
  13. package/dist/chunk-RBTN73H3.js +2 -0
  14. package/dist/{chunk-QV2OO65X.js.map → chunk-RBTN73H3.js.map} +1 -1
  15. package/dist/chunk-T2PMDMOY.js +2 -0
  16. package/dist/chunk-T2PMDMOY.js.map +1 -0
  17. package/dist/chunk-WMEGATWF.js +2 -0
  18. package/dist/{chunk-S4IFBDOJ.js.map → chunk-WMEGATWF.js.map} +1 -1
  19. package/dist/composites/combobox-chip-outside.js +1 -1
  20. package/dist/composites/combobox-chip.js +1 -1
  21. package/dist/composites/combobox-simple.js +1 -1
  22. package/dist/composites/filter-combobox.js +1 -1
  23. package/dist/composites/index.js +1 -1
  24. package/dist/composites/phone-input.js +1 -1
  25. package/dist/ui/combobox.d.ts +7 -3
  26. package/dist/ui/combobox.js +1 -1
  27. package/dist/ui/index.d.ts +1 -1
  28. package/dist/ui/index.js +1 -1
  29. package/dist/ui/pagination.js +1 -1
  30. package/dist/ui/table.js +1 -1
  31. package/dist/ui/toast.d.ts +17 -6
  32. package/dist/ui/toast.js +1 -1
  33. package/package.json +1 -1
  34. package/dist/chunk-533HLE3E.js +0 -2
  35. package/dist/chunk-533HLE3E.js.map +0 -1
  36. package/dist/chunk-CHN5ZCUY.js +0 -2
  37. package/dist/chunk-CHN5ZCUY.js.map +0 -1
  38. package/dist/chunk-MXDNSGGI.js +0 -2
  39. package/dist/chunk-MXDNSGGI.js.map +0 -1
  40. package/dist/chunk-OF4LN45Z.js +0 -2
  41. package/dist/chunk-OF4LN45Z.js.map +0 -1
  42. package/dist/chunk-QV2OO65X.js +0 -2
  43. package/dist/chunk-S4IFBDOJ.js +0 -2
  44. package/dist/chunk-XLACGAIR.js +0 -2
  45. package/dist/chunk-XZKSYHE5.js +0 -2
  46. package/dist/chunk-YB5ZNOPP.js +0 -2
  47. package/dist/chunk-YB5ZNOPP.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ import {c,d,k,o,s,u,y,z,H}from'./chunk-NVQMVFSP.js';import {a}from'./chunk-JH6RZ3QH.js';import'react';import {ChevronDownIcon}from'lucide-react';import'class-variance-authority';import {cn}from'@xploreu/lib/cn';import {jsxs,jsx}from'react/jsx-runtime';function B({items:t,value:f,defaultValue:g,onValueChange:d$1,placeholder:I="Select",icon:l,container:S,isPending:y$1,className:P,triggerClassName:V,contentClassName:v,disabled:N,size:h="md",infiniteScroll:R}){return jsxs(c,{items:t,value:f,defaultValue:g,onValueChange:d$1,isItemEqualToValue:(e,T)=>e.value===T.value,disabled:N,children:[jsxs(d,{className:cn(a({size:h}),"group flex cursor-pointer items-center gap-2 pr-3 text-left",V,P),children:[l&&jsx("span",{className:"size-4.5 shrink-0 text-fg-quaternary",children:l}),jsx("span",{className:"flex-1 truncate",children:jsx(k,{children:e=>jsx("span",{className:e?"text-text-primary":"text-text-placeholder",children:e?.label??I})})}),jsx(ChevronDownIcon,{className:"size-4 shrink-0 text-fg-quaternary transition-transform group-data-[popup-open]:rotate-180"})]}),jsxs(o,{container:S,className:cn("w-72",v),align:"start",sideOffset:8,children:[jsx(s,{status:y$1||t===void 0?"pending":t.length===0?"empty":null}),jsxs(u,{children:[t?.map(e=>jsx(y,{value:e,children:jsx(z,{children:e.label})},e.value)),jsx(H,{...R})]})]})]})}export{B as a};//# sourceMappingURL=chunk-34QGQHPC.js.map
2
+ //# sourceMappingURL=chunk-34QGQHPC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/composites/combobox-simple.tsx"],"names":["ComboboxSimple","items","value","defaultValue","onValueChange","placeholder","icon","container","isPending","className","triggerClassName","contentClassName","disabled","size","infiniteScroll","jsxs","Combobox","a","b","ComboboxTrigger","cn","inputVariants","jsx","ComboboxValue","item","ChevronDownIcon","ComboboxPopup","ComboboxStatus","ComboboxList","ComboboxItem","ComboboxItemTitle","ComboboxInfiniteScroll"],"mappings":"4PA8CA,SAASA,CAAAA,CAAe,CACtB,KAAA,CAAAC,CAAAA,CACA,MAAAC,CAAAA,CACA,YAAA,CAAAC,EACA,aAAA,CAAAC,GAAAA,CACA,YAAAC,CAAAA,CAAc,QAAA,CACd,KAAAC,CAAAA,CACA,SAAA,CAAAC,EACA,SAAA,CAAAC,GAAAA,CACA,UAAAC,CAAAA,CACA,gBAAA,CAAAC,EACA,gBAAA,CAAAC,CAAAA,CACA,SAAAC,CAAAA,CACA,IAAA,CAAAC,EAAO,IAAA,CACP,cAAA,CAAAC,CACF,CAAA,CAAwB,CACtB,OACEC,IAAAA,CAACC,CAAAA,CAAA,CACC,KAAA,CAAOf,CAAAA,CACP,MAAOC,CAAAA,CACP,YAAA,CAAcC,EACd,aAAA,CAAeC,GAAAA,CACf,mBAAoB,CAACa,CAAAA,CAAGC,IAAMD,CAAAA,CAAE,KAAA,GAAUC,EAAE,KAAA,CAC5C,QAAA,CAAUN,EAEV,QAAA,CAAA,CAAAG,IAAAA,CAACI,EAAA,CACC,SAAA,CAAWC,GACTC,CAAAA,CAAc,CAAE,KAAAR,CAAK,CAAC,EACtB,6DAAA,CACAH,CAAAA,CACAD,CACF,CAAA,CAEC,QAAA,CAAA,CAAAH,CAAAA,EACCgB,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,uCAAwC,QAAA,CAAAhB,CAAAA,CAAK,EAE/DgB,GAAAA,CAAC,MAAA,CAAA,CAAK,UAAU,iBAAA,CACd,QAAA,CAAAA,IAACC,CAAAA,CAAA,CACE,SAACC,CAAAA,EACAF,GAAAA,CAAC,QAAK,SAAA,CAAWE,CAAAA,CAAO,oBAAsB,uBAAA,CAC3C,QAAA,CAAAA,GAAM,KAAA,EAASnB,CAAAA,CAClB,EAEJ,CAAA,CACF,CAAA,CACAiB,IAACG,eAAAA,CAAA,CACC,UAAU,4FAAA,CACZ,CAAA,CAAA,CACF,EAEAV,IAAAA,CAACW,CAAAA,CAAA,CACC,SAAA,CAAWnB,CAAAA,CACX,UAAWa,EAAAA,CAAG,MAAA,CAAQT,CAAgB,CAAA,CACtC,KAAA,CAAM,QACN,UAAA,CAAY,CAAA,CAEZ,UAAAW,GAAAA,CAACK,CAAAA,CAAA,CACC,MAAA,CACEnB,GAAAA,EAAaP,IAAU,MAAA,CACnB,SAAA,CACAA,EAAM,MAAA,GAAW,CAAA,CACf,QACA,IAAA,CAEV,CAAA,CACAc,KAACa,CAAAA,CAAA,CACE,UAAA3B,CAAAA,EAAO,GAAA,CAAKuB,GACXF,GAAAA,CAACO,CAAAA,CAAA,CAA8B,KAAA,CAAOL,CAAAA,CACpC,SAAAF,GAAAA,CAACQ,CAAAA,CAAA,CACE,QAAA,CAAAN,CAAAA,CAAK,MACR,CAAA,CAAA,CAHiBA,CAAAA,CAAK,KAIxB,CACD,CAAA,CACDF,IAACS,CAAAA,CAAA,CAAwB,GAAGjB,CAAAA,CAAgB,CAAA,CAAA,CAC9C,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAEJ","file":"chunk-34QGQHPC.js","sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\nimport { ChevronDownIcon } from \"lucide-react\"\r\nimport { type VariantProps } from \"class-variance-authority\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport { inputVariants } from \"../ui/input\"\r\nimport { ComboboxItem, ComboboxItemTitle } from \"../ui/combobox\"\r\nimport {\r\n Combobox,\r\n ComboboxInfiniteScroll,\r\n ComboboxList,\r\n ComboboxPopup,\r\n ComboboxPortal,\r\n ComboboxStatus,\r\n ComboboxTrigger,\r\n ComboboxValue,\r\n} from \"../ui/combobox\"\r\n\r\n// ─── Types ───\r\n\r\nexport type ComboboxSimpleItem = {\r\n label: string\r\n value: string\r\n}\r\n\r\nexport type ComboboxSimpleProps = {\r\n items: ComboboxSimpleItem[] | undefined\r\n value?: ComboboxSimpleItem | null\r\n defaultValue?: ComboboxSimpleItem | null\r\n onValueChange?: (value: ComboboxSimpleItem | null) => void\r\n placeholder?: string\r\n icon?: React.ReactNode\r\n container?: React.ComponentProps<typeof ComboboxPortal>[\"container\"]\r\n isPending?: boolean\r\n className?: string\r\n triggerClassName?: string\r\n contentClassName?: string\r\n disabled?: boolean\r\n size?: VariantProps<typeof inputVariants>[\"size\"]\r\n infiniteScroll?: React.ComponentProps<typeof ComboboxInfiniteScroll>\r\n}\r\n\r\n// ─── Component ───\r\n\r\nfunction ComboboxSimple({\r\n items,\r\n value,\r\n defaultValue,\r\n onValueChange,\r\n placeholder = \"Select\",\r\n icon,\r\n container,\r\n isPending,\r\n className,\r\n triggerClassName,\r\n contentClassName,\r\n disabled,\r\n size = \"md\",\r\n infiniteScroll,\r\n}: ComboboxSimpleProps) {\r\n return (\r\n <Combobox\r\n items={items}\r\n value={value}\r\n defaultValue={defaultValue}\r\n onValueChange={onValueChange}\r\n isItemEqualToValue={(a, b) => a.value === b.value}\r\n disabled={disabled}\r\n >\r\n <ComboboxTrigger\r\n className={cn(\r\n inputVariants({ size }),\r\n \"group flex cursor-pointer items-center gap-2 pr-3 text-left\",\r\n triggerClassName,\r\n className\r\n )}\r\n >\r\n {icon && (\r\n <span className=\"size-4.5 shrink-0 text-fg-quaternary\">{icon}</span>\r\n )}\r\n <span className=\"flex-1 truncate\">\r\n <ComboboxValue>\r\n {(item) => (\r\n <span className={item ? \"text-text-primary\" : \"text-text-placeholder\"}>\r\n {item?.label ?? placeholder}\r\n </span>\r\n )}\r\n </ComboboxValue>\r\n </span>\r\n <ChevronDownIcon\r\n className=\"size-4 shrink-0 text-fg-quaternary transition-transform group-data-[popup-open]:rotate-180\"\r\n />\r\n </ComboboxTrigger>\r\n\r\n <ComboboxPopup\r\n container={container}\r\n className={cn(\"w-72\", contentClassName)}\r\n align=\"start\"\r\n sideOffset={8}\r\n >\r\n <ComboboxStatus\r\n status={\r\n isPending || items === undefined\r\n ? \"pending\"\r\n : items.length === 0\r\n ? \"empty\"\r\n : null\r\n }\r\n />\r\n <ComboboxList>\r\n {items?.map((item) => (\r\n <ComboboxItem key={item.value} value={item}>\r\n <ComboboxItemTitle>\r\n {item.label}\r\n </ComboboxItemTitle>\r\n </ComboboxItem>\r\n ))}\r\n <ComboboxInfiniteScroll {...infiniteScroll} />\r\n </ComboboxList>\r\n </ComboboxPopup>\r\n </Combobox>\r\n )\r\n}\r\n\r\nexport { ComboboxSimple }\r\n"]}
@@ -0,0 +1,2 @@
1
+ import {c,d,o,g,s,u,y,z,H}from'./chunk-NVQMVFSP.js';import*as r from'react';import {ChevronDownIcon}from'lucide-react';import {cn}from'@xploreu/lib/cn';import {jsxs,jsx,Fragment}from'react/jsx-runtime';function Y(o$1){let{items:n,placeholder:b="Select",icon:I,container:R,isPending:v,className:w,triggerClassName:L,contentClassName:k,disabled:T,infiniteScroll:P}=o$1,a=o$1.multiple===true,u$1=r.useMemo(()=>{if(a)return o$1.value;let e=o$1.value;return e?[e]:[]},[a,o$1.value,o$1.value]),$=r.useMemo(()=>{if(a)return o$1.defaultValue??[];let e=o$1.defaultValue;return e?[e]:[]},[a,o$1.defaultValue,o$1.defaultValue]),[q,c$1]=r.useState(()=>(u$1!==void 0?u$1:$)??[]);r.useEffect(()=>{u$1!==void 0&&c$1(u$1);},[u$1]);let m=q??[],s$1=m.length>0,[p,z$1]=r.useState(""),S=r.useMemo(()=>{if(!p.trim())return n;let e=p.toLowerCase();return n?.filter(l=>l.label.toLowerCase().includes(e)||l.value.toLowerCase().includes(e))},[n,p]),A=e=>{let l=e;if(a)c$1(l),o$1.onValueChange?.(l);else {let x=l.length>0?l[l.length-1]:null;c$1(x?[x]:[]),o$1.onValueChange?.(x);}},B=()=>{c$1([]),a?o$1.onValueChange?.([]):o$1.onValueChange?.(null);},E=r.useMemo(()=>s$1?a?`${b} (${m.length})`:m[0]?.label??b:a?`All ${b}`:b,[s$1,a,b,m]);return jsxs(c,{multiple:true,items:n,value:m,onValueChange:A,isItemEqualToValue:(e,l)=>e.value===l.value,disabled:T,children:[jsxs(d,{className:cn("group flex h-9 w-fit max-w-[220px] items-center gap-2 rounded-xp-card-base border bg-bg-primary px-3 text-body-medium-3 transition-colors","border-border-primary text-text-secondary hover:bg-bg-primary-hover",s$1&&"border-border-brand bg-bg-brand-primary text-text-brand-secondary","disabled:pointer-events-none disabled:opacity-50","data-[popup-open]:border-border-brand data-[popup-open]:bg-bg-brand-primary data-[popup-open]:text-text-brand-secondary",L,w),children:[I&&jsx("span",{className:cn("size-4 shrink-0",s$1?"text-fg-brand-primary":"text-fg-quaternary"),children:I}),jsx("span",{className:"truncate",children:E}),jsx(ChevronDownIcon,{className:cn("size-4 shrink-0 transition-transform group-data-[popup-open]:rotate-180",s$1?"text-fg-brand-primary":"text-fg-quaternary")})]}),jsx(o,{container:R,className:cn("w-72",k),align:"start",sideOffset:8,children:a?jsxs("div",{className:"flex flex-col",children:[jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border-primary",children:[jsx("span",{className:"text-label-semibold-3 text-text-primary",children:b}),jsxs("button",{type:"button",disabled:!s$1,onClick:B,className:cn("text-body-medium-3 transition-colors",s$1?"cursor-pointer text-text-brand-secondary hover:text-text-brand-secondary-hover":"cursor-not-allowed text-text-disabled"),children:["Clear",s$1?` (${m.length})`:""]})]}),jsx(g,{value:p,onChange:e=>z$1(e.target.value),placeholder:`Search ${b.toLowerCase()}...`}),jsx(s,{status:v||n===void 0?"pending":S?.length===0?"empty":null}),jsxs(u,{children:[S?.map(e=>jsx(y,{indicator:"checkbox",value:e,children:jsx(z,{children:e.label})},e.value)),jsx(H,{...P})]})]}):jsxs(Fragment,{children:[jsx(s,{status:v||n===void 0?"pending":n?.length===0?"empty":null}),jsxs(u,{children:[n?.map(e=>jsx(y,{value:e,children:jsx(z,{children:e.label})},e.value)),jsx(H,{...P})]})]})})]})}export{Y as a};//# sourceMappingURL=chunk-44LMOSRI.js.map
2
+ //# sourceMappingURL=chunk-44LMOSRI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/composites/filter-combobox.tsx"],"names":["FilterCombobox","props","items","placeholder","icon","container","isPending","className","triggerClassName","contentClassName","disabled","infiniteScroll","isMultiple","controlledArray","single","defaultArray","internalValue","setInternalValue","valueArray","hasValue","search","setSearch","filteredItems","q","it","handleValueChange","next","arr","handleClear","triggerLabel","jsxs","Combobox","a","b","ComboboxTrigger","cn","jsx","ChevronDownIcon","ComboboxPopup","ComboboxInput","ComboboxStatus","ComboboxList","item","ComboboxItem","ComboboxItemTitle","ComboboxInfiniteScroll","Fragment"],"mappings":"0MA6DA,SAASA,CAAAA,CAAeC,GAAAA,CAA4B,CAClD,GAAM,CACJ,KAAA,CAAAC,CAAAA,CACA,WAAA,CAAAC,CAAAA,CAAc,SACd,IAAA,CAAAC,CAAAA,CACA,SAAA,CAAAC,CAAAA,CACA,SAAA,CAAAC,CAAAA,CACA,SAAA,CAAAC,CAAAA,CACA,gBAAA,CAAAC,CAAAA,CACA,gBAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CACA,cAAA,CAAAC,CACF,CAAA,CAAIV,GAAAA,CAEEW,CAAAA,CAAaX,GAAAA,CAAM,QAAA,GAAa,IAAA,CAGhCY,GAAAA,CAAwB,CAAA,CAAA,OAAA,CAAQ,IAAM,CAC1C,GAAID,CAAAA,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AA,CACC,MAAA,CACElC,CAAAA,EAAaJ,CAAAA,GAAU,MAAA,CACnB,SAAA,CACAA,CAAAA,EAAO,MAAA,GAAW,CAAA,CAChB,OAAA,CACA,KAEV,CAAA,CACA4B,IAAAA,CAACW,CAAAA,CAAA,CACE,QAAA,CAAA,CAAAvC,CAAAA,EAAO,GAAA,CAAKwC,CAAAA,EACXN,GAAAA,CAACO,CAAAA,CAAA,CAA8B,KAAA,CAAOD,CAAAA,CACpC,QAAA,CAAAN,GAAAA,CAACQ,CAAAA,CAAA,CACE,QAAA,CAAAF,CAAAA,CAAK,KAAA,CACR,CAAA,CAAA,CAHiBA,CAAAA,CAAK,KAIxB,CACD,CAAA,CACDN,GAAAA,CAACS,CAAAA,CAAA,CAAwB,GAAGlC,CAAAA,CAAgB,CAAA,CAAA,CAC9C,CAAA,CAAA,CACF,CAAA,CAEJ,GACF,CAEJ","file":"chunk-44LMOSRI.js","sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\nimport { CheckCircle2Icon, ChevronDownIcon, SearchIcon } from \"lucide-react\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport {\r\n ComboboxItemIndicator as ComboboxItemIndicatorPrimitive\r\n} from \"../primitives/combobox\"\r\nimport { ComboboxHighlightItem, ComboboxItem, ComboboxItemTitle } from \"../ui/combobox\"\r\nimport { Input } from \"../ui/input\"\r\nimport {\r\n Combobox,\r\n ComboboxInfiniteScroll,\r\n ComboboxInput,\r\n ComboboxList,\r\n ComboboxPopup,\r\n ComboboxPortal,\r\n ComboboxStatus,\r\n ComboboxTrigger,\r\n type ComboboxProps,\r\n} from \"../ui/combobox\"\r\n\r\n// ─── Types ───\r\n\r\nexport type FilterComboboxItem = {\r\n label: string\r\n value: string\r\n}\r\n\r\ntype BaseProps = {\r\n items: FilterComboboxItem[] | undefined\r\n placeholder?: string\r\n icon?: React.ReactNode\r\n container?: React.ComponentProps<typeof ComboboxPortal>[\"container\"]\r\n isPending?: boolean\r\n className?: string\r\n triggerClassName?: string\r\n contentClassName?: string\r\n disabled?: boolean\r\n infiniteScroll?: React.ComponentProps<typeof ComboboxInfiniteScroll>\r\n}\r\n\r\ntype SingleProps = BaseProps & {\r\n multiple?: false\r\n value?: FilterComboboxItem | null\r\n defaultValue?: FilterComboboxItem | null\r\n onValueChange?: (value: FilterComboboxItem | null) => void\r\n}\r\n\r\ntype MultipleProps = BaseProps & {\r\n multiple: true\r\n value?: FilterComboboxItem[]\r\n defaultValue?: FilterComboboxItem[]\r\n onValueChange?: (value: FilterComboboxItem[]) => void\r\n}\r\n\r\nexport type FilterComboboxProps = SingleProps | MultipleProps\r\n\r\n// ─── Component ───\r\n\r\nfunction FilterCombobox(props: FilterComboboxProps) {\r\n const {\r\n items,\r\n placeholder = \"Select\",\r\n icon,\r\n container,\r\n isPending,\r\n className,\r\n triggerClassName,\r\n contentClassName,\r\n disabled,\r\n infiniteScroll,\r\n } = props\r\n\r\n const isMultiple = props.multiple === true\r\n\r\n // Normalize controlled value to array for internal combobox (always multiple=true internally)\r\n const controlledArray = React.useMemo(() => {\r\n if (isMultiple) {\r\n return (props as MultipleProps).value\r\n }\r\n const single = (props as SingleProps).value\r\n return single ? [single] : []\r\n }, [isMultiple, (props as SingleProps).value, (props as MultipleProps).value])\r\n\r\n const defaultArray = React.useMemo(() => {\r\n if (isMultiple) {\r\n return (props as MultipleProps).defaultValue ?? []\r\n }\r\n const single = (props as SingleProps).defaultValue\r\n return single ? [single] : []\r\n }, [isMultiple, (props as SingleProps).defaultValue, (props as MultipleProps).defaultValue])\r\n\r\n const [internalValue, setInternalValue] = React.useState<FilterComboboxItem[]>(\r\n () =>\r\n (controlledArray !== undefined\r\n ? (controlledArray as FilterComboboxItem[])\r\n : (defaultArray as FilterComboboxItem[])) ?? []\r\n )\r\n\r\n // Sync when controlled value changes externally\r\n React.useEffect(() => {\r\n if (controlledArray !== undefined) {\r\n setInternalValue(controlledArray as FilterComboboxItem[])\r\n }\r\n }, [controlledArray])\r\n\r\n const valueArray = internalValue ?? []\r\n const hasValue = valueArray.length > 0\r\n\r\n // Search for multiple variant\r\n const [search, setSearch] = React.useState(\"\")\r\n\r\n const filteredItems = React.useMemo(() => {\r\n if (!search.trim()) return items\r\n const q = search.toLowerCase()\r\n return items?.filter(\r\n (it) => it.label.toLowerCase().includes(q) || it.value.toLowerCase().includes(q)\r\n )\r\n }, [items, search])\r\n\r\n const handleValueChange: ComboboxProps<FilterComboboxItem, boolean>[\"onValueChange\"] = (\r\n next\r\n ) => {\r\n const arr = next as FilterComboboxItem[]\r\n if (isMultiple) {\r\n setInternalValue(arr)\r\n ; (props as MultipleProps).onValueChange?.(arr)\r\n } else {\r\n // single: take last selected (base-ui gives array)\r\n const single = arr.length > 0 ? arr[arr.length - 1] : null\r\n const normalized = single ? [single] : []\r\n setInternalValue(normalized)\r\n ; (props as SingleProps).onValueChange?.(single)\r\n }\r\n }\r\n\r\n const handleClear = () => {\r\n setInternalValue([])\r\n if (isMultiple) {\r\n ; (props as MultipleProps).onValueChange?.([])\r\n } else {\r\n ; (props as SingleProps).onValueChange?.(null)\r\n }\r\n }\r\n\r\n // Trigger label\r\n const triggerLabel = React.useMemo(() => {\r\n if (!hasValue) {\r\n return isMultiple ? `All ${placeholder}` : placeholder\r\n }\r\n if (isMultiple) {\r\n return `${placeholder} (${valueArray.length})`\r\n }\r\n return valueArray[0]?.label ?? placeholder\r\n }, [hasValue, isMultiple, placeholder, valueArray])\r\n\r\n return (\r\n <Combobox\r\n multiple\r\n items={items}\r\n value={valueArray}\r\n onValueChange={handleValueChange}\r\n isItemEqualToValue={(a, b) => a.value === b.value}\r\n disabled={disabled}\r\n >\r\n <ComboboxTrigger\r\n className={cn(\r\n \"group flex h-9 w-fit max-w-[220px] items-center gap-2 rounded-xp-card-base border bg-bg-primary px-3 text-body-medium-3 transition-colors\",\r\n \"border-border-primary text-text-secondary hover:bg-bg-primary-hover\",\r\n hasValue && \"border-border-brand bg-bg-brand-primary text-text-brand-secondary\",\r\n \"disabled:pointer-events-none disabled:opacity-50\",\r\n \"data-[popup-open]:border-border-brand data-[popup-open]:bg-bg-brand-primary data-[popup-open]:text-text-brand-secondary\",\r\n triggerClassName,\r\n className\r\n )}\r\n >\r\n {icon && (\r\n <span\r\n className={cn(\r\n \"size-4 shrink-0\",\r\n hasValue ? \"text-fg-brand-primary\" : \"text-fg-quaternary\"\r\n )}\r\n >\r\n {icon}\r\n </span>\r\n )}\r\n <span className=\"truncate\">{triggerLabel}</span>\r\n <ChevronDownIcon\r\n className={cn(\r\n \"size-4 shrink-0 transition-transform group-data-[popup-open]:rotate-180\",\r\n hasValue ? \"text-fg-brand-primary\" : \"text-fg-quaternary\"\r\n )}\r\n />\r\n </ComboboxTrigger>\r\n\r\n <ComboboxPopup\r\n container={container}\r\n className={cn(\"w-72\", contentClassName)}\r\n align=\"start\"\r\n sideOffset={8}\r\n >\r\n {isMultiple ? (\r\n <div className=\"flex flex-col\">\r\n {/* Header: title + Clear (n) */}\r\n <div className=\"flex items-center justify-between px-3 py-2 border-b border-border-primary\">\r\n <span className=\"text-label-semibold-3 text-text-primary\">{placeholder}</span>\r\n <button\r\n type=\"button\"\r\n disabled={!hasValue}\r\n onClick={handleClear}\r\n className={cn(\r\n \"text-body-medium-3 transition-colors\",\r\n hasValue\r\n ? \"cursor-pointer text-text-brand-secondary hover:text-text-brand-secondary-hover\"\r\n : \"cursor-not-allowed text-text-disabled\"\r\n )}\r\n >\r\n Clear{hasValue ? ` (${valueArray.length})` : \"\"}\r\n </button>\r\n </div>\r\n\r\n {/* Search */}\r\n <ComboboxInput\r\n value={search}\r\n onChange={(e) => setSearch(e.target.value)}\r\n placeholder={`Search ${placeholder.toLowerCase()}...`}\r\n />\r\n\r\n {/* List */}\r\n <ComboboxStatus\r\n status={\r\n isPending || items === undefined\r\n ? \"pending\"\r\n : filteredItems?.length === 0\r\n ? \"empty\"\r\n : null\r\n }\r\n />\r\n <ComboboxList>\r\n {filteredItems?.map((item) => (\r\n <ComboboxItem indicator=\"checkbox\" key={item.value} value={item}>\r\n <ComboboxItemTitle>\r\n {item.label}\r\n </ComboboxItemTitle>\r\n </ComboboxItem>\r\n )\r\n )}\r\n <ComboboxInfiniteScroll {...infiniteScroll} />\r\n </ComboboxList>\r\n </div>\r\n ) : (\r\n <>\r\n <ComboboxStatus\r\n status={\r\n isPending || items === undefined\r\n ? \"pending\"\r\n : items?.length === 0\r\n ? \"empty\"\r\n : null\r\n }\r\n />\r\n <ComboboxList>\r\n {items?.map((item) => (\r\n <ComboboxItem key={item.value} value={item}>\r\n <ComboboxItemTitle>\r\n {item.label}\r\n </ComboboxItemTitle>\r\n </ComboboxItem>\r\n ))}\r\n <ComboboxInfiniteScroll {...infiniteScroll} />\r\n </ComboboxList>\r\n </>\r\n )}\r\n </ComboboxPopup>\r\n </Combobox>\r\n )\r\n}\r\n\r\nexport { FilterCombobox }\r\n"]}
@@ -0,0 +1,2 @@
1
+ import {c,b,d,l,k,m,n,o,s,u,y,H}from'./chunk-NVQMVFSP.js';import {b as b$1}from'./chunk-JH6RZ3QH.js';import*as r from'react';import {cn}from'@xploreu/lib/cn';import {SearchIcon,XIcon}from'lucide-react';import {useControlledState}from'@xploreu/hooks/use-controlled-state';import {jsxs,jsx,Fragment}from'react/jsx-runtime';function j({multiple:z=true,inputPlaceholder:B="Search...",container:q,items:u$1,infiniteScroll:A,isPending:H$1,taggable:c$1=false,maxVisible:i,...m$1}){let[h,g]=useControlledState({value:m$1?.inputValue?.toString(),defaultValue:m$1?.defaultInputValue?.toString(),onChange:m$1?.onInputValueChange}),[b$2,x]=useControlledState({value:m$1?.value??[],defaultValue:m$1?.defaultValue??[],onChange:m$1?.onValueChange}),[v,I]=r.useState([]),d$1=r.useRef(new Set);r.useEffect(()=>{let e=new Set(b$2.map(t=>t.value));I(t=>{let l=t.filter(a=>e.has(a.value));return l.length===t.length?t:(d$1.current=new Set(l.map(a=>a.value)),l)});},[b$2]);let n$1=h?.toString().trim()??"",U=r.useMemo(()=>n$1?b$2.some(e=>e.value.toLowerCase()===n$1.toLowerCase()):false,[n$1,b$2]),p=r.useMemo(()=>!c$1||!n$1?false:!u$1?.some(e=>e.label.toLowerCase()===n$1.toLowerCase()),[c$1,n$1,u$1]),X=r.useMemo(()=>{let e=[...u$1??[],...v];if(p){let t={label:n$1,value:n$1,tag:true};return [...e,t]}return e},[u$1,v,p,n$1]);return jsxs(c,{...m$1,behavior:"chip-outside",multiple:true,items:c$1?X:u$1,isItemEqualToValue:(e,t)=>e.value===t.value,onValueChange:(e,t)=>{if(c$1){let l=e.filter(a=>a?.tag===true&&!d$1.current.has(a.value));if(l.length>0){for(let a of l)d$1.current.add(a.value);I(a=>[...a,...l]);}}x(z?e:[e[e.length-1]],t);},onInputValueChange:g,children:[jsxs("div",{className:"flex flex-col gap-2",children:[jsx(b,{render:jsx(b$1,{className:"h-9 text-body-regular-3 pl-9 pr-7",endContent:jsx(d,{nativeButton:false,render:jsx(XIcon,{className:"!size-5 !right-1.5 data-[hidden=true]:opacity-0 opacity-100 transition-opacity duration-300 cursor-pointer","data-hidden":!h,"data-slot":"combobox-clear-input",onClick:e=>{g("",{reason:"none",event:e.nativeEvent,cancel:()=>{},allowPropagation:()=>{},isCanceled:false,isPropagationAllowed:true,trigger:void 0});}})}),placeholder:B,startContent:jsx(SearchIcon,{className:"!size-4 !text-fg-tertiary-hover"}),wrapperClassName:"w-full"})}),jsx(l,{className:cn(i!==void 0&&"flex-nowrap overflow-hidden"),onMouseDown:e=>e.preventBaseUIHandler(),children:jsx(k,{children:e=>{let t=i!==void 0?e.slice(0,i):e,l=i!==void 0?e.length-i:0;return jsxs(Fragment,{children:[t?.map(a=>jsxs(m,{className:cn(i!==void 0&&"min-w-0 shrink"),children:[i!==void 0?jsx("span",{className:"truncate",children:a?.label||""}):a?.label||"",jsx(n,{})]},a?.value||"")),l>0&&jsxs(m,{className:"shrink-0",children:["+",l]})]})}})})]}),jsxs(o,{container:q,children:[jsx(s,{status:H$1||u$1===void 0?"pending":u$1?.length===0&&!p?"empty":null}),jsxs(u,{children:[u$1?.map(e=>jsx(y,{value:{label:e.label,value:e.value},children:jsx("div",{className:"flex items-center gap-2 w-full min-w-0",children:jsx("span",{className:"truncate",children:e.label})})},e.value)),p&&jsx(y,{value:{label:n$1,value:n$1,tag:true},children:jsxs("div",{className:"flex items-center gap-1.5 w-full min-w-0",children:[!U&&jsx("span",{className:"text-text-secondary",children:"Create:"}),jsx("span",{className:"font-medium text-text-primary truncate",children:n$1})]})}),jsx(H,{...A})]})]})]})}export{j as a};//# sourceMappingURL=chunk-BIFRDHOB.js.map
2
+ //# sourceMappingURL=chunk-BIFRDHOB.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/composites/combobox-chip-outside.tsx"],"names":["ComboboxChipOutside","multiple","inputPlaceholder","container","items","infiniteScroll","isPending","taggable","maxVisible","props","inputValue","setInputValue","useControlledState","value","setValue","createdItems","setCreatedItems","createdValuesRef","currentValues","v","prev","next","item","trimmedInput","isInputSelected","isCreatingItem","combinedItems","base","createItem","jsxs","Combobox","a","b","eventDetails","newTags","tag","jsx","ComboboxInput","Input","ComboboxTrigger","XIcon","event","SearchIcon","ComboboxChips","cn","ComboboxValue","visible","overflow","Fragment","ComboboxChip","ComboboxChipRemove","ComboboxPopup","ComboboxStatus","ComboboxList","ComboboxItem","ComboboxInfiniteScroll"],"mappings":"iUA4CA,SAASA,CAAAA,CAAgF,CACvF,QAAA,CAAAC,IAAW,IAAA,CACX,gBAAA,CAAAC,CAAAA,CAAmB,WAAA,CACnB,UAAAC,CAAAA,CACA,KAAA,CAAAC,CAAAA,CACA,cAAA,CAAAC,CAAAA,CACA,SAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,EAAW,KAAA,CACX,UAAA,CAAAC,CAAAA,CACA,GAAGC,GACL,CAAA,CAAoC,CAClC,GAAM,CAACC,EAAYC,CAAa,CAAA,CAAIC,kBAAAA,CAAmB,CACrD,MAAOH,GAAAA,EAAO,UAAA,EAAY,QAAA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,CACnB,SAAA,CACAA,GAAO,MAAA,GAAW,CAAA,EAAK,CAACqB,GAAAA,CACtB,QACA,IAAA,CAEV,CAAA,CACAI,IAAAA,CAACwB,CAAAA,CAAA,CACE,QAAA,CAAA,CAAAjD,CAAAA,EAAO,GAAA,CAAKkB,CAAAA,EACXc,GAAAA,CAACkB,CAAAA,CAAA,CAEC,KAAA,CAAO,CAAE,KAAA,CAAOhC,CAAAA,CAAK,KAAA,CAAO,KAAA,CAAOA,EAAK,KAAM,CAAA,CAE9C,QAAA,CAAAc,GAAAA,CAAC,OAAI,SAAA,CAAU,wCAAA,CACb,QAAA,CAAAA,GAAAA,CAAC,QAAK,SAAA,CAAU,UAAA,CACb,QAAA,CAAAd,CAAAA,CAAK,MACR,CAAA,CACF,CAAA,CAAA,CAPKA,CAAAA,CAAK,KAQZ,CACD,CAAA,CACAG,GAAAA,EACCW,GAAAA,CAACkB,CAAAA,CAAA,CACC,KAAA,CAAO,CAAE,KAAA,CAAO/B,GAAAA,CAAc,KAAA,CAAOA,GAAAA,CAAc,GAAA,CAAK,IAAK,EAE7D,QAAA,CAAAM,IAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAU,2CACZ,QAAA,CAAA,CAAA,CAACL,CAAAA,EACAY,GAAAA,CAAC,MAAA,CAAA,CAAK,UAAU,qBAAA,CAAsB,QAAA,CAAA,SAAA,CAAO,CAAA,CAE/CA,GAAAA,CAAC,QAAK,SAAA,CAAU,wCAAA,CACb,QAAA,CAAAb,GAAAA,CACH,GACF,CAAA,CACF,CAAA,CAEFa,GAAAA,CAACmB,CAAAA,CAAA,CAAwB,GAAGlD,CAAAA,CAAgB,CAAA,CAAA,CAC9C,CAAA,CAAA,CACF,GACF,CAEJ","file":"chunk-XZKSYHE5.js","sourcesContent":["import * as React from \"react\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport { ComboboxInput as ComboboxInputPrimitive } from \"../primitives/combobox\"\r\nimport { Input } from \"../ui\"\r\nimport {\r\n Combobox,\r\n ComboboxChip,\r\n ComboboxChipRemove,\r\n ComboboxChips,\r\n ComboboxInfiniteScroll,\r\n ComboboxItem,\r\n ComboboxList,\r\n ComboboxPortal,\r\n ComboboxPopup,\r\n ComboboxStatus,\r\n ComboboxTrigger,\r\n ComboboxValue,\r\n type ComboboxProps\r\n} from \"../ui/combobox\"\r\nimport { SearchIcon, XIcon } from \"lucide-react\"\r\nimport { useControlledState } from \"@xploreu/hooks/use-controlled-state\"\r\n\r\ntype ComboboxChipOutsideProps<Value> = Omit<ComboboxProps<Value, true>, \"multiple\"> & {\r\n multiple?: boolean\r\n inputPlaceholder?: string\r\n container?: React.ComponentProps<typeof ComboboxPortal>[\"container\"]\r\n items: ({ label: string; value: string }[]) | undefined\r\n infiniteScroll?: React.ComponentProps<typeof ComboboxInfiniteScroll>\r\n isPending?: boolean\r\n /**\r\n * When true, enables creatable / taggable mode.\r\n * If the typed value has no exact match in the current item list,\r\n * a \"Create \\\"…\\\"\" option is shown at the top of the dropdown.\r\n * Created items are appended to the value with `{ label, value, tag: true }`.\r\n */\r\n taggable?: boolean\r\n /**\r\n * Maximum number of chips to show before collapsing the rest into a \"+N\" chip.\r\n * When undefined, all chips are shown.\r\n */\r\n maxVisible?: number\r\n}\r\n\r\nfunction ComboboxChipOutside<Value extends { label: string; value: string; tag?: true }>({\r\n multiple = true,\r\n inputPlaceholder = \"Search...\",\r\n container,\r\n items,\r\n infiniteScroll,\r\n isPending,\r\n taggable = false,\r\n maxVisible,\r\n ...props\r\n}: ComboboxChipOutsideProps<Value>) {\r\n const [inputValue, setInputValue] = useControlledState({\r\n value: props?.inputValue?.toString(),\r\n defaultValue: props?.defaultInputValue?.toString(),\r\n onChange: props?.onInputValueChange,\r\n })\r\n\r\n const [value, setValue] = useControlledState({\r\n value: props?.value ?? [],\r\n defaultValue: props?.defaultValue ?? [],\r\n onChange: props?.onValueChange,\r\n })\r\n\r\n // Track items created via taggable mode\r\n // Sync with value to avoid stale tags when controlled value is reset from outside\r\n const [createdItems, setCreatedItems] = React.useState<Value[]>([])\r\n const createdValuesRef = React.useRef<Set<string>>(new Set())\r\n\r\n React.useEffect(() => {\r\n const currentValues = new Set(value.map((v) => v.value))\r\n setCreatedItems((prev) => {\r\n const next = prev.filter((item) => currentValues.has(item.value))\r\n if (next.length === prev.length) return prev\r\n createdValuesRef.current = new Set(next.map((v) => v.value))\r\n return next\r\n })\r\n }, [value])\r\n\r\n // Determine if the current input has no exact match in existing items\r\n const trimmedInput = inputValue?.toString().trim() ?? \"\"\r\n const isInputSelected = React.useMemo(() => {\r\n if (!trimmedInput) return false\r\n return value.some(\r\n (item) => item.value.toLowerCase() === trimmedInput.toLowerCase()\r\n )\r\n }, [trimmedInput, value])\r\n // true = show the taggable item in dropdown (either as \"Create:\" or as checked item)\r\n const isCreatingItem = React.useMemo(() => {\r\n if (!taggable || !trimmedInput) return false\r\n return !items?.some(\r\n (item) => item.label.toLowerCase() === trimmedInput.toLowerCase()\r\n )\r\n }, [taggable, trimmedInput, items])\r\n\r\n // Merge server items with locally created tags + the \"Create\" placeholder\r\n const combinedItems = React.useMemo(() => {\r\n const base: Value[] = [\r\n ...items ?? [],\r\n ...createdItems,\r\n ]\r\n\r\n if (isCreatingItem) {\r\n const createItem = {\r\n label: trimmedInput,\r\n value: trimmedInput,\r\n tag: true,\r\n }\r\n return [...base, createItem]\r\n }\r\n\r\n return base\r\n }, [items, createdItems, isCreatingItem, trimmedInput])\r\n\r\n const handleValueChange: ComboboxProps<Value, true>[\"onValueChange\"] = (value, eventDetails) => {\r\n // Capture newly created taggable items internally\r\n if (taggable) {\r\n const newTags = value.filter(\r\n (v) => v?.tag === true\r\n && !createdValuesRef.current.has(v.value)\r\n )\r\n if (newTags.length > 0) {\r\n for (const tag of newTags) {\r\n createdValuesRef.current.add(tag.value)\r\n }\r\n setCreatedItems((prev) => [...prev, ...newTags])\r\n }\r\n }\r\n\r\n // if multiple is false, we need to replace the value with the new value instead of adding to it\r\n if (!multiple) {\r\n setValue([value[value.length - 1]], eventDetails)\r\n } else {\r\n setValue(value, eventDetails)\r\n }\r\n }\r\n\r\n return (\r\n <Combobox\r\n {...props}\r\n behavior=\"chip-outside\"\r\n multiple\r\n items={taggable ? combinedItems : items}\r\n isItemEqualToValue={(a, b) => a.value === b.value}\r\n onValueChange={handleValueChange}\r\n onInputValueChange={setInputValue}\r\n >\r\n <div className=\"flex flex-col gap-2\">\r\n <ComboboxInputPrimitive\r\n render={\r\n <Input\r\n className=\"h-9 text-body-regular-3 pl-9 pr-7\"\r\n endContent={\r\n <ComboboxTrigger\r\n nativeButton={false}\r\n render={(\r\n <XIcon\r\n className=\"!size-5 !right-1.5 data-[hidden=true]:opacity-0 opacity-100 transition-opacity duration-300 cursor-pointer\"\r\n data-hidden={!inputValue}\r\n data-slot=\"combobox-clear-input\"\r\n onClick={(event) => {\r\n setInputValue(\"\", {\r\n reason: \"none\",\r\n event: event.nativeEvent,\r\n cancel: () => { },\r\n allowPropagation: () => { },\r\n isCanceled: false,\r\n isPropagationAllowed: true,\r\n trigger: undefined,\r\n })\r\n }}\r\n />\r\n )}\r\n />\r\n }\r\n placeholder={inputPlaceholder}\r\n startContent={<SearchIcon className=\"!size-4 !text-fg-tertiary-hover\" />}\r\n wrapperClassName=\"w-full\"\r\n />\r\n }\r\n />\r\n <ComboboxChips\r\n className={cn(maxVisible !== undefined && \"flex-nowrap overflow-hidden\")}\r\n onMouseDown={(e) => e.preventBaseUIHandler()}\r\n >\r\n <ComboboxValue>\r\n {(value: Value[]) => {\r\n const visible = maxVisible !== undefined ? value.slice(0, maxVisible) : value\r\n const overflow = maxVisible !== undefined ? value.length - maxVisible : 0\r\n return (\r\n <>\r\n {visible?.map((item) => (\r\n <ComboboxChip\r\n key={item?.value || \"\"}\r\n className={cn(maxVisible !== undefined && \"min-w-0 shrink\")}\r\n >\r\n {maxVisible !== undefined\r\n ? <span className=\"truncate\">{item?.label || \"\"}</span>\r\n : (item?.label || \"\")\r\n }\r\n <ComboboxChipRemove />\r\n </ComboboxChip>\r\n ))}\r\n {overflow > 0 && (\r\n <ComboboxChip className=\"shrink-0\">\r\n +{overflow}\r\n </ComboboxChip>\r\n )}\r\n </>\r\n )\r\n }}\r\n </ComboboxValue>\r\n </ComboboxChips>\r\n </div>\r\n <ComboboxPopup container={container}>\r\n <ComboboxStatus\r\n status={\r\n isPending || items === undefined\r\n ? \"pending\"\r\n : items?.length === 0 && !isCreatingItem\r\n ? \"empty\"\r\n : null\r\n }\r\n />\r\n <ComboboxList>\r\n {items?.map((item) => (\r\n <ComboboxItem\r\n key={item.value}\r\n value={{ label: item.label, value: item.value }}\r\n >\r\n <div className=\"flex items-center gap-2 w-full min-w-0\">\r\n <span className=\"truncate\">\r\n {item.label}\r\n </span>\r\n </div>\r\n </ComboboxItem>\r\n ))}\r\n {isCreatingItem && (\r\n <ComboboxItem\r\n value={{ label: trimmedInput, value: trimmedInput, tag: true }}\r\n >\r\n <div className=\"flex items-center gap-1.5 w-full min-w-0\">\r\n {!isInputSelected && (\r\n <span className=\"text-text-secondary\">Create:</span>\r\n )}\r\n <span className=\"font-medium text-text-primary truncate\">\r\n {trimmedInput}\r\n </span>\r\n </div>\r\n </ComboboxItem>\r\n )}\r\n <ComboboxInfiniteScroll {...infiniteScroll} />\r\n </ComboboxList>\r\n </ComboboxPopup>\r\n </Combobox>\r\n )\r\n}\r\n\r\nexport { ComboboxChipOutside }"]}
1
+ {"version":3,"sources":["../src/composites/combobox-chip-outside.tsx"],"names":["ComboboxChipOutside","multiple","inputPlaceholder","container","items","infiniteScroll","isPending","taggable","maxVisible","props","inputValue","setInputValue","useControlledState","value","setValue","createdItems","setCreatedItems","createdValuesRef","currentValues","v","prev","next","item","trimmedInput","isInputSelected","isCreatingItem","combinedItems","base","createItem","jsxs","Combobox","a","b","eventDetails","newTags","tag","jsx","ComboboxInput","Input","ComboboxTrigger","XIcon","event","SearchIcon","ComboboxChips","cn","ComboboxValue","visible","overflow","Fragment","ComboboxChip","ComboboxChipRem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AAA,CAAC,MAAA,CAAA,CAAK,UAAU,qBAAA,CAAsB,QAAA,CAAA,SAAA,CAAO,CAAA,CAE/CA,GAAAA,CAAC,QAAK,SAAA,CAAU,wCAAA,CACb,QAAA,CAAAb,GAAAA,CACH,GACF,CAAA,CACF,CAAA,CAEFa,GAAAA,CAACmB,CAAAA,CAAA,CAAwB,GAAGlD,CAAAA,CAAgB,CAAA,CAAA,CAC9C,CAAA,CAAA,CACF,GACF,CAEJ","file":"chunk-BIFRDHOB.js","sourcesContent":["import * as React from \"react\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport { ComboboxInput as ComboboxInputPrimitive } from \"../primitives/combobox\"\r\nimport { Input } from \"../ui\"\r\nimport {\r\n Combobox,\r\n ComboboxChip,\r\n ComboboxChipRemove,\r\n ComboboxChips,\r\n ComboboxInfiniteScroll,\r\n ComboboxItem,\r\n ComboboxList,\r\n ComboboxPortal,\r\n ComboboxPopup,\r\n ComboboxStatus,\r\n ComboboxTrigger,\r\n ComboboxValue,\r\n type ComboboxProps\r\n} from \"../ui/combobox\"\r\nimport { SearchIcon, XIcon } from \"lucide-react\"\r\nimport { useControlledState } from \"@xploreu/hooks/use-controlled-state\"\r\n\r\ntype ComboboxChipOutsideProps<Value> = Omit<ComboboxProps<Value, true>, \"multiple\"> & {\r\n multiple?: boolean\r\n inputPlaceholder?: string\r\n container?: React.ComponentProps<typeof ComboboxPortal>[\"container\"]\r\n items: ({ label: string; value: string }[]) | undefined\r\n infiniteScroll?: React.ComponentProps<typeof ComboboxInfiniteScroll>\r\n isPending?: boolean\r\n /**\r\n * When true, enables creatable / taggable mode.\r\n * If the typed value has no exact match in the current item list,\r\n * a \"Create \\\"…\\\"\" option is shown at the top of the dropdown.\r\n * Created items are appended to the value with `{ label, value, tag: true }`.\r\n */\r\n taggable?: boolean\r\n /**\r\n * Maximum number of chips to show before collapsing the rest into a \"+N\" chip.\r\n * When undefined, all chips are shown.\r\n */\r\n maxVisible?: number\r\n}\r\n\r\nfunction ComboboxChipOutside<Value extends { label: string; value: string; tag?: true }>({\r\n multiple = true,\r\n inputPlaceholder = \"Search...\",\r\n container,\r\n items,\r\n infiniteScroll,\r\n isPending,\r\n taggable = false,\r\n maxVisible,\r\n ...props\r\n}: ComboboxChipOutsideProps<Value>) {\r\n const [inputValue, setInputValue] = useControlledState({\r\n value: props?.inputValue?.toString(),\r\n defaultValue: props?.defaultInputValue?.toString(),\r\n onChange: props?.onInputValueChange,\r\n })\r\n\r\n const [value, setValue] = useControlledState({\r\n value: props?.value ?? [],\r\n defaultValue: props?.defaultValue ?? [],\r\n onChange: props?.onValueChange,\r\n })\r\n\r\n // Track items created via taggable mode\r\n // Sync with value to avoid stale tags when controlled value is reset from outside\r\n const [createdItems, setCreatedItems] = React.useState<Value[]>([])\r\n const createdValuesRef = React.useRef<Set<string>>(new Set())\r\n\r\n React.useEffect(() => {\r\n const currentValues = new Set(value.map((v) => v.value))\r\n setCreatedItems((prev) => {\r\n const next = prev.filter((item) => currentValues.has(item.value))\r\n if (next.length === prev.length) return prev\r\n createdValuesRef.current = new Set(next.map((v) => v.value))\r\n return next\r\n })\r\n }, [value])\r\n\r\n // Determine if the current input has no exact match in existing items\r\n const trimmedInput = inputValue?.toString().trim() ?? \"\"\r\n const isInputSelected = React.useMemo(() => {\r\n if (!trimmedInput) return false\r\n return value.some(\r\n (item) => item.value.toLowerCase() === trimmedInput.toLowerCase()\r\n )\r\n }, [trimmedInput, value])\r\n // true = show the taggable item in dropdown (either as \"Create:\" or as checked item)\r\n const isCreatingItem = React.useMemo(() => {\r\n if (!taggable || !trimmedInput) return false\r\n return !items?.some(\r\n (item) => item.label.toLowerCase() === trimmedInput.toLowerCase()\r\n )\r\n }, [taggable, trimmedInput, items])\r\n\r\n // Merge server items with locally created tags + the \"Create\" placeholder\r\n const combinedItems = React.useMemo(() => {\r\n const base: Value[] = [\r\n ...items ?? [],\r\n ...createdItems,\r\n ]\r\n\r\n if (isCreatingItem) {\r\n const createItem = {\r\n label: trimmedInput,\r\n value: trimmedInput,\r\n tag: true,\r\n }\r\n return [...base, createItem]\r\n }\r\n\r\n return base\r\n }, [items, createdItems, isCreatingItem, trimmedInput])\r\n\r\n const handleValueChange: ComboboxProps<Value, true>[\"onValueChange\"] = (value, eventDetails) => {\r\n // Capture newly created taggable items internally\r\n if (taggable) {\r\n const newTags = value.filter(\r\n (v) => v?.tag === true\r\n && !createdValuesRef.current.has(v.value)\r\n )\r\n if (newTags.length > 0) {\r\n for (const tag of newTags) {\r\n createdValuesRef.current.add(tag.value)\r\n }\r\n setCreatedItems((prev) => [...prev, ...newTags])\r\n }\r\n }\r\n\r\n // if multiple is false, we need to replace the value with the new value instead of adding to it\r\n if (!multiple) {\r\n setValue([value[value.length - 1]], eventDetails)\r\n } else {\r\n setValue(value, eventDetails)\r\n }\r\n }\r\n\r\n return (\r\n <Combobox\r\n {...props}\r\n behavior=\"chip-outside\"\r\n multiple\r\n items={taggable ? combinedItems : items}\r\n isItemEqualToValue={(a, b) => a.value === b.value}\r\n onValueChange={handleValueChange}\r\n onInputValueChange={setInputValue}\r\n >\r\n <div className=\"flex flex-col gap-2\">\r\n <ComboboxInputPrimitive\r\n render={\r\n <Input\r\n className=\"h-9 text-body-regular-3 pl-9 pr-7\"\r\n endContent={\r\n <ComboboxTrigger\r\n nativeButton={false}\r\n render={(\r\n <XIcon\r\n className=\"!size-5 !right-1.5 data-[hidden=true]:opacity-0 opacity-100 transition-opacity duration-300 cursor-pointer\"\r\n data-hidden={!inputValue}\r\n data-slot=\"combobox-clear-input\"\r\n onClick={(event) => {\r\n setInputValue(\"\", {\r\n reason: \"none\",\r\n event: event.nativeEvent,\r\n cancel: () => { },\r\n allowPropagation: () => { },\r\n isCanceled: false,\r\n isPropagationAllowed: true,\r\n trigger: undefined,\r\n })\r\n }}\r\n />\r\n )}\r\n />\r\n }\r\n placeholder={inputPlaceholder}\r\n startContent={<SearchIcon className=\"!size-4 !text-fg-tertiary-hover\" />}\r\n wrapperClassName=\"w-full\"\r\n />\r\n }\r\n />\r\n <ComboboxChips\r\n className={cn(maxVisible !== undefined && \"flex-nowrap overflow-hidden\")}\r\n onMouseDown={(e) => e.preventBaseUIHandler()}\r\n >\r\n <ComboboxValue>\r\n {(value: Value[]) => {\r\n const visible = maxVisible !== undefined ? value.slice(0, maxVisible) : value\r\n const overflow = maxVisible !== undefined ? value.length - maxVisible : 0\r\n return (\r\n <>\r\n {visible?.map((item) => (\r\n <ComboboxChip\r\n key={item?.value || \"\"}\r\n className={cn(maxVisible !== undefined && \"min-w-0 shrink\")}\r\n >\r\n {maxVisible !== undefined\r\n ? <span className=\"truncate\">{item?.label || \"\"}</span>\r\n : (item?.label || \"\")\r\n }\r\n <ComboboxChipRemove />\r\n </ComboboxChip>\r\n ))}\r\n {overflow > 0 && (\r\n <ComboboxChip className=\"shrink-0\">\r\n +{overflow}\r\n </ComboboxChip>\r\n )}\r\n </>\r\n )\r\n }}\r\n </ComboboxValue>\r\n </ComboboxChips>\r\n </div>\r\n <ComboboxPopup container={container}>\r\n <ComboboxStatus\r\n status={\r\n isPending || items === undefined\r\n ? \"pending\"\r\n : items?.length === 0 && !isCreatingItem\r\n ? \"empty\"\r\n : null\r\n }\r\n />\r\n <ComboboxList>\r\n {items?.map((item) => (\r\n <ComboboxItem\r\n key={item.value}\r\n value={{ label: item.label, value: item.value }}\r\n >\r\n <div className=\"flex items-center gap-2 w-full min-w-0\">\r\n <span className=\"truncate\">\r\n {item.label}\r\n </span>\r\n </div>\r\n </ComboboxItem>\r\n ))}\r\n {isCreatingItem && (\r\n <ComboboxItem\r\n value={{ label: trimmedInput, value: trimmedInput, tag: true }}\r\n >\r\n <div className=\"flex items-center gap-1.5 w-full min-w-0\">\r\n {!isInputSelected && (\r\n <span className=\"text-text-secondary\">Create:</span>\r\n )}\r\n <span className=\"font-medium text-text-primary truncate\">\r\n {trimmedInput}\r\n </span>\r\n </div>\r\n </ComboboxItem>\r\n )}\r\n <ComboboxInfiniteScroll {...infiniteScroll} />\r\n </ComboboxList>\r\n </ComboboxPopup>\r\n </Combobox>\r\n )\r\n}\r\n\r\nexport { ComboboxChipOutside }"]}
@@ -0,0 +1,2 @@
1
+ import {c,d,k,o,u,y}from'./chunk-NVQMVFSP.js';import*as l from'react';import {ChevronDownIcon,ChevronLeftIcon,ChevronRightIcon}from'lucide-react';import {cn}from'@xploreu/lib/cn';import {jsxs,Fragment,jsx}from'react/jsx-runtime';function j({page:r,pageSize:a,total:i,onPageChange:b,onPageSizeChange:n,pageSizeOptions:m=[10,20,50,100],showPageSize:c$1=true,showRange:d$1=true,className:C,...N}){let u$1=Math.max(1,Math.ceil(i/a)),h=i===0?0:(r-1)*a+1,P=Math.min(r*a,i),s=l.useMemo(()=>m.map(e=>({label:String(e),value:e})),[m]),I=l.useMemo(()=>s.find(e=>e.value===a)??s[0],[s,a]);return jsxs("div",{className:cn("flex w-full flex-col-reverse gap-3 mt-4 sm:flex-row sm:items-center sm:justify-between border-t border-border-primary pt-3 text-body-regular-2 text-text-secondary",C),"data-slot":"pagination",...N,children:[jsxs("div",{className:"flex items-center gap-2",children:[c$1&&n&&jsxs(Fragment,{children:[jsx("span",{className:"text-label-regular-3 text-text-tertiary",children:"Rows per page"}),jsxs(c,{items:s,value:I,onValueChange:e=>{e&&n&&n(e.value);},isItemEqualToValue:(e,w)=>e.value===w.value,children:[jsxs(d,{className:"h-8 gap-2 rounded-lg border border-border-primary bg-bg-primary px-3 text-label-semibold-3 text-text-primary hover:bg-bg-secondary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border-brand-primary","aria-label":"Rows per page",children:[jsx(k,{children:e=>e?e.label:String(a)}),jsx(ChevronDownIcon,{className:"size-3.5 text-text-tertiary"})]}),jsx(o,{className:"w-24",children:jsx(u,{children:s.map(e=>jsx(y,{value:e,children:e.label},e.value))})})]})]}),c$1&&d$1&&jsx("span",{className:"text-text-tertiary",children:"\xB7"}),d$1&&jsxs("span",{className:"text-label-regular-3 text-text-tertiary",children:[h,"\u2013",P," of ",i]})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",disabled:r<=1,onClick:()=>b(r-1),className:"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border-primary bg-bg-primary text-text-secondary transition-colors hover:bg-bg-secondary hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-40","aria-label":"Previous page",children:jsx(ChevronLeftIcon,{className:"size-4"})}),jsxs("span",{className:"px-2 text-label-semibold-3 text-text-primary",children:["Page ",r," / ",u$1]}),jsx("button",{type:"button",disabled:r>=u$1,onClick:()=>b(r+1),className:"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border-primary bg-bg-primary text-text-secondary transition-colors hover:bg-bg-secondary hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-40","aria-label":"Next page",children:jsx(ChevronRightIcon,{className:"size-4"})})]})]})}export{j as a};//# sourceMappingURL=chunk-CXTKXMUH.js.map
2
+ //# sourceMappingURL=chunk-CXTKXMUH.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ui/pagination.tsx"],"names":["Pagination","page","pageSize","total","onPageChange","onPageSizeChange","pageSizeOptions","showPageSize","showRange","className","props","totalPages","startItem","endItem","items","opt","selectedItem","item","jsxs","cn","Fragment","jsx","Combobox","a","b","ComboboxTrigger","ComboboxValue","val","ChevronDownIcon","ComboboxPopup","ComboboxList","ComboboxItem","ChevronLeftIcon","ChevronRightIcon"],"mappings":"4OA6BO,SAASA,CAAAA,CAAW,CACzB,KAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CACA,KAAA,CAAAC,EACA,YAAA,CAAAC,CAAAA,CACA,gBAAA,CAAAC,CAAAA,CACA,gBAAAC,CAAAA,CAAkB,CAAC,EAAA,CAAI,EAAA,CAAI,GAAI,GAAG,CAAA,CAClC,YAAA,CAAAC,CAAAA,CAAe,KACf,SAAA,CAAAC,GAAAA,CAAY,IAAA,CACZ,SAAA,CAAAC,EACA,GAAGC,CACL,CAAA,CAAoB,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CAAU,0PACV,YAAA,CAAW,eAAA,CAEX,QAAA,CAAAoB,GAAAA,CAACW,gBAAA,CAAgB,SAAA,CAAU,QAAA,CAAS,CAAA,CACtC,EAEAd,IAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,8CAAA,CAA+C,kBACvDjB,CAAAA,CAAK,KAAA,CAAIU,GAAAA,CAAAA,CACjB,CAAA,CAEAU,IAAC,QAAA,CAAA,CACC,IAAA,CAAK,QAAA,CACL,QAAA,CAAUpB,GAAQU,GAAAA,CAClB,OAAA,CAAS,IAAMP,CAAAA,CAAaH,EAAO,CAAC,CAAA,CACpC,SAAA,CAAU,yPAAA,CACV,aAAW,WAAA,CAEX,QAAA,CAAAoB,GAAAA,CAACY,gBAAAA,CAAA,CAAiB,SAAA,CAAU,QAAA,CAAS,CAAA,CACvC,CAAA,CAAA,CACF,GACF,CAEJ","file":"chunk-XLACGAIR.js","sourcesContent":["import * as React from \"react\"\r\nimport { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon } from \"lucide-react\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport {\r\n Combobox,\r\n ComboboxItem,\r\n ComboboxList,\r\n ComboboxPopup,\r\n ComboboxTrigger,\r\n ComboboxValue,\r\n} from \"./combobox\"\r\n\r\nexport interface PaginationProps extends React.ComponentProps<\"div\"> {\r\n page: number\r\n pageSize: number\r\n total: number\r\n onPageChange: (page: number) => void\r\n onPageSizeChange?: (pageSize: number) => void\r\n pageSizeOptions?: number[]\r\n showPageSize?: boolean\r\n showRange?: boolean\r\n}\r\n\r\ntype PageSizeOptionItem = {\r\n label: string\r\n value: number\r\n}\r\n\r\nexport function Pagination({\r\n page,\r\n pageSize,\r\n total,\r\n onPageChange,\r\n onPageSizeChange,\r\n pageSizeOptions = [10, 20, 50, 100],\r\n showPageSize = true,\r\n showRange = true,\r\n className,\r\n ...props\r\n}: PaginationProps) {\r\n const totalPages = Math.max(1, Math.ceil(total / pageSize))\r\n const startItem = total === 0 ? 0 : (page - 1) * pageSize + 1\r\n const endItem = Math.min(page * pageSize, total)\r\n\r\n const items: PageSizeOptionItem[] = React.useMemo(\r\n () => pageSizeOptions.map((opt) => ({ label: String(opt), value: opt })),\r\n [pageSizeOptions]\r\n )\r\n\r\n const selectedItem = React.useMemo(\r\n () => items.find((item) => item.value === pageSize) ?? items[0],\r\n [items, pageSize]\r\n )\r\n\r\n return (\r\n <div\r\n className={cn(\r\n \"flex w-full flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between border-t border-border-primary px-4 py-3 text-body-regular-2 text-text-secondary\",\r\n className\r\n )}\r\n data-slot=\"pagination\"\r\n {...props}\r\n >\r\n {/* Left: Rows per page & range */}\r\n <div className=\"flex items-center gap-2\">\r\n {showPageSize && onPageSizeChange && (\r\n <>\r\n <span className=\"text-label-regular-3 text-text-tertiary\">\r\n Rows per page\r\n </span>\r\n <Combobox<PageSizeOptionItem>\r\n items={items}\r\n value={selectedItem}\r\n onValueChange={(item) => {\r\n if (item && onPageSizeChange) {\r\n onPageSizeChange(item.value)\r\n }\r\n }}\r\n isItemEqualToValue={(a, b) => a.value === b.value}\r\n >\r\n <ComboboxTrigger\r\n className=\"h-8 gap-2 rounded-lg border border-border-primary bg-bg-primary px-3 text-label-semibold-3 text-text-primary hover:bg-bg-secondary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border-brand-primary\"\r\n aria-label=\"Rows per page\"\r\n >\r\n <ComboboxValue>\r\n {(val) => (val ? val.label : String(pageSize))}\r\n </ComboboxValue>\r\n <ChevronDownIcon className=\"size-3.5 text-text-tertiary\" />\r\n </ComboboxTrigger>\r\n\r\n <ComboboxPopup className=\"w-24\">\r\n <ComboboxList>\r\n {items.map((item) => (\r\n <ComboboxItem\r\n key={item.value}\r\n value={item}\r\n >\r\n {item.label}\r\n </ComboboxItem>\r\n ))}\r\n </ComboboxList>\r\n </ComboboxPopup>\r\n </Combobox>\r\n </>\r\n )}\r\n\r\n {showPageSize && showRange && (\r\n <span className=\"text-text-tertiary\">·</span>\r\n )}\r\n\r\n {showRange && (\r\n <span className=\"text-label-regular-3 text-text-tertiary\">\r\n {startItem}–{endItem} of {total}\r\n </span>\r\n )}\r\n </div>\r\n\r\n {/* Right: Page controls */}\r\n <div className=\"flex items-center gap-1\">\r\n <button\r\n type=\"button\"\r\n disabled={page <= 1}\r\n onClick={() => onPageChange(page - 1)}\r\n className=\"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border-primary bg-bg-primary text-text-secondary transition-colors hover:bg-bg-secondary hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-40\"\r\n aria-label=\"Previous page\"\r\n >\r\n <ChevronLeftIcon className=\"size-4\" />\r\n </button>\r\n\r\n <span className=\"px-2 text-label-semibold-3 text-text-primary\">\r\n Page {page} / {totalPages}\r\n </span>\r\n\r\n <button\r\n type=\"button\"\r\n disabled={page >= totalPages}\r\n onClick={() => onPageChange(page + 1)}\r\n className=\"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border-primary bg-bg-primary text-text-secondary transition-colors hover:bg-bg-secondary hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-40\"\r\n aria-label=\"Next page\"\r\n >\r\n <ChevronRightIcon className=\"size-4\" />\r\n </button>\r\n </div>\r\n </div>\r\n )\r\n}\r\n"]}
1
+ {"version":3,"sources":["../src/ui/pagination.tsx"],"names":["Pagination","page","pageSize","total","onPageChange","onPageSizeChange","pageSizeOptions","showPageSize","showRange","className","props","totalPages","startItem","endItem","items","opt","selectedItem","item","jsxs","cn","Fragment","jsx","Combobox","a","b","ComboboxTrigger","ComboboxValue","val","ChevronDownIcon","ComboboxPopup","ComboboxList","ComboboxItem","ChevronLeftIcon","ChevronRightIcon"],"mappings":"qOA6BO,SAASA,CAAAA,CAAW,CACzB,KAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CACA,KAAA,CAAAC,EACA,YAAA,CAAAC,CAAAA,CACA,gBAAA,CAAAC,CAAAA,CACA,gBAA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I,SAAA,CAAU,yBAAA,CACb,UAAAG,GAAAA,CAAC,QAAA,CAAA,CACC,IAAA,CAAK,QAAA,CACL,SAAUpB,CAAAA,EAAQ,CAAA,CAClB,OAAA,CAAS,IAAMG,EAAaH,CAAAA,CAAO,CAAC,CAAA,CACpC,SAAA,CAAU,0PACV,YAAA,CAAW,eAAA,CAEX,QAAA,CAAAoB,GAAAA,CAACW,gBAAA,CAAgB,SAAA,CAAU,QAAA,CAAS,CAAA,CACtC,EAEAd,IAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,8CAAA,CAA+C,kBACvDjB,CAAAA,CAAK,KAAA,CAAIU,GAAAA,CAAAA,CACjB,CAAA,CAEAU,IAAC,QAAA,CAAA,CACC,IAAA,CAAK,QAAA,CACL,QAAA,CAAUpB,GAAQU,GAAAA,CAClB,OAAA,CAAS,IAAMP,CAAAA,CAAaH,EAAO,CAAC,CAAA,CACpC,SAAA,CAAU,yPAAA,CACV,aAAW,WAAA,CAEX,QAAA,CAAAoB,GAAAA,CAACY,gBAAAA,CAAA,CAAiB,SAAA,CAAU,QAAA,CAAS,CAAA,CACvC,CAAA,CAAA,CACF,GACF,CAEJ","file":"chunk-CXTKXMUH.js","sourcesContent":["import * as React from \"react\"\r\nimport { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon } from \"lucide-react\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport {\r\n Combobox,\r\n ComboboxItem,\r\n ComboboxList,\r\n ComboboxPopup,\r\n ComboboxTrigger,\r\n ComboboxValue,\r\n} from \"./combobox\"\r\n\r\nexport interface PaginationProps extends React.ComponentProps<\"div\"> {\r\n page: number\r\n pageSize: number\r\n total: number\r\n onPageChange: (page: number) => void\r\n onPageSizeChange?: (pageSize: number) => void\r\n pageSizeOptions?: number[]\r\n showPageSize?: boolean\r\n showRange?: boolean\r\n}\r\n\r\ntype PageSizeOptionItem = {\r\n label: string\r\n value: number\r\n}\r\n\r\nexport function Pagination({\r\n page,\r\n pageSize,\r\n total,\r\n onPageChange,\r\n onPageSizeChange,\r\n pageSizeOptions = [10, 20, 50, 100],\r\n showPageSize = true,\r\n showRange = true,\r\n className,\r\n ...props\r\n}: PaginationProps) {\r\n const totalPages = Math.max(1, Math.ceil(total / pageSize))\r\n const startItem = total === 0 ? 0 : (page - 1) * pageSize + 1\r\n const endItem = Math.min(page * pageSize, total)\r\n\r\n const items: PageSizeOptionItem[] = React.useMemo(\r\n () => pageSizeOptions.map((opt) => ({ label: String(opt), value: opt })),\r\n [pageSizeOptions]\r\n )\r\n\r\n const selectedItem = React.useMemo(\r\n () => items.find((item) => item.value === pageSize) ?? items[0],\r\n [items, pageSize]\r\n )\r\n\r\n return (\r\n <div\r\n className={cn(\r\n \"flex w-full flex-col-reverse gap-3 mt-4 sm:flex-row sm:items-center sm:justify-between border-t border-border-primary pt-3 text-body-regular-2 text-text-secondary\",\r\n className\r\n )}\r\n data-slot=\"pagination\"\r\n {...props}\r\n >\r\n {/* Left: Rows per page & range */}\r\n <div className=\"flex items-center gap-2\">\r\n {showPageSize && onPageSizeChange && (\r\n <>\r\n <span className=\"text-label-regular-3 text-text-tertiary\">\r\n Rows per page\r\n </span>\r\n <Combobox<PageSizeOptionItem>\r\n items={items}\r\n value={selectedItem}\r\n onValueChange={(item) => {\r\n if (item && onPageSizeChange) {\r\n onPageSizeChange(item.value)\r\n }\r\n }}\r\n isItemEqualToValue={(a, b) => a.value === b.value}\r\n >\r\n <ComboboxTrigger\r\n className=\"h-8 gap-2 rounded-lg border border-border-primary bg-bg-primary px-3 text-label-semibold-3 text-text-primary hover:bg-bg-secondary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border-brand-primary\"\r\n aria-label=\"Rows per page\"\r\n >\r\n <ComboboxValue>\r\n {(val) => (val ? val.label : String(pageSize))}\r\n </ComboboxValue>\r\n <ChevronDownIcon className=\"size-3.5 text-text-tertiary\" />\r\n </ComboboxTrigger>\r\n\r\n <ComboboxPopup className=\"w-24\">\r\n <ComboboxList>\r\n {items.map((item) => (\r\n <ComboboxItem\r\n key={item.value}\r\n value={item}\r\n >\r\n {item.label}\r\n </ComboboxItem>\r\n ))}\r\n </ComboboxList>\r\n </ComboboxPopup>\r\n </Combobox>\r\n </>\r\n )}\r\n\r\n {showPageSize && showRange && (\r\n <span className=\"text-text-tertiary\">·</span>\r\n )}\r\n\r\n {showRange && (\r\n <span className=\"text-label-regular-3 text-text-tertiary\">\r\n {startItem}–{endItem} of {total}\r\n </span>\r\n )}\r\n </div>\r\n\r\n {/* Right: Page controls */}\r\n <div className=\"flex items-center gap-1\">\r\n <button\r\n type=\"button\"\r\n disabled={page <= 1}\r\n onClick={() => onPageChange(page - 1)}\r\n className=\"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border-primary bg-bg-primary text-text-secondary transition-colors hover:bg-bg-secondary hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-40\"\r\n aria-label=\"Previous page\"\r\n >\r\n <ChevronLeftIcon className=\"size-4\" />\r\n </button>\r\n\r\n <span className=\"px-2 text-label-semibold-3 text-text-primary\">\r\n Page {page} / {totalPages}\r\n </span>\r\n\r\n <button\r\n type=\"button\"\r\n disabled={page >= totalPages}\r\n onClick={() => onPageChange(page + 1)}\r\n className=\"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border-primary bg-bg-primary text-text-secondary transition-colors hover:bg-bg-secondary hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-40\"\r\n aria-label=\"Next page\"\r\n >\r\n <ChevronRightIcon className=\"size-4\" />\r\n </button>\r\n </div>\r\n </div>\r\n )\r\n}\r\n"]}
@@ -0,0 +1,2 @@
1
+ import {d,e,b,c,f,g,h,i,j,a,l}from'./chunk-4IAMLCAM.js';import {b as b$1}from'./chunk-VNAMAKPG.js';import {a as a$1}from'./chunk-WI5V5Z76.js';import {b as b$3}from'./chunk-QWCYJC3T.js';import {b as b$4}from'./chunk-4WDDWMBW.js';import {b as b$2}from'./chunk-ZQWDYX2E.js';import'react';import {cn}from'@xploreu/lib/cn';import {XIcon,Loader2Icon}from'lucide-react';import {jsx,jsxs}from'react/jsx-runtime';function k({...t}){return jsx(d,{...t})}var D={"top-right":"fixed top-4 right-4 bottom-auto left-auto sm:top-4 sm:right-4 sm:bottom-auto sm:left-auto","top-left":"fixed top-4 left-4 bottom-auto right-auto sm:top-4 sm:left-4 sm:bottom-auto sm:right-auto","top-center":"fixed top-4 left-1/2 -translate-x-1/2 bottom-auto right-auto sm:top-4 sm:left-1/2 sm:-translate-x-1/2","bottom-right":"fixed bottom-4 right-4 top-auto left-auto sm:bottom-4 sm:right-4 sm:top-auto sm:left-auto","bottom-left":"fixed bottom-4 left-4 top-auto right-auto sm:bottom-4 sm:left-4 sm:top-auto sm:right-auto","bottom-center":"fixed bottom-4 left-1/2 -translate-x-1/2 top-auto right-auto sm:bottom-4 sm:left-1/2 sm:-translate-x-1/2"};function z({className:t,position:a="top-right",...e$1}){return jsx(e,{className:cn("group/viewport pointer-events-none z-50 mx-auto w-auto max-w-sm outline-none sm:mx-0 sm:w-full",D[a],t),...e$1})}function A(t){return jsx(b,{...t})}function V({className:t,children:a,style:e,...i}){return jsxs(c,{style:e,className:cn("group/toast pointer-events-auto absolute right-0 z-[calc(1000-var(--toast-index))] w-full shadow-lg will-change-transform outline-none select-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-focus-ring","bottom-0 origin-bottom rounded-l-[10.4px] rounded-r-lg","data-[position^=top]:top-0 data-[position^=top]:bottom-auto data-[position^=top]:origin-top","[--gap:0.75rem] [--height:var(--toast-frontmost-height,var(--toast-height))] [--offset-y:calc((var(--toast-index)*(var(--height)+var(--gap))*-1)+var(--toast-swipe-movement-y))] [--peek:0.75rem] [--scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--shrink:calc(1-var(--scale))]","data-[position^=top]:[--offset-y:calc((var(--toast-index)*(var(--height)+var(--gap)))+var(--toast-swipe-movement-y))]","h-(--height) [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--peek))-(var(--shrink)*var(--height))))_scale(var(--scale))] [transition:transform_500ms_cubic-bezier(0.22,1,0.36,1),opacity_500ms,height_150ms]","data-[position^=top]:[transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)+(var(--toast-index)*var(--peek))+(var(--shrink)*var(--height))))_scale(var(--scale))]","after:absolute after:top-full after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']","group-hover/viewport:data-expanded:h-(--toast-height) group-hover/viewport:data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]","group-focus-within/viewport:data-expanded:h-(--toast-height) group-focus-within/viewport:data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]","data-limited:opacity-0 data-limited:pointer-events-none data-limited:invisible data-starting-style:[transform:translateY(150%)]","data-[position^=top]:data-starting-style:[transform:translateY(-150%)]","[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(150%)]","data-[position^=top]:[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(-150%)]","data-ending-style:opacity-0","data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]","data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]","data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]","data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]","group-hover/viewport:data-expanded:data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]","group-hover/viewport:data-expanded:data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]","group-hover/viewport:data-expanded:data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]","group-hover/viewport:data-expanded:data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]","group-focus-within/viewport:data-expanded:data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]","group-focus-within/viewport:data-expanded:data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]","group-focus-within/viewport:data-expanded:data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]","group-focus-within/viewport:data-expanded:data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]",t),...i,children:[jsx("div",{className:cn("absolute left-0 inset-y-0 w-[10.4px] rounded-l-[10.4px] bg-[linear-gradient(180deg,#377DFA_0%,#185BC2_80%)]","group-data-[type=warning]/toast:bg-[linear-gradient(180deg,#F79009_0%,#B54708_80%)]","group-data-[type=info]/toast:bg-[linear-gradient(180deg,#068BEE_0%,#175BCC_80%)]","group-data-[type=success]/toast:bg-[linear-gradient(180deg,#17B26A_0%,#067647_80%)]","group-data-[type=error]/toast:bg-[linear-gradient(180deg,#F04438_0%,#B42318_80%)]")}),jsx("div",{className:cn("relative border border-border-secondary rounded-lg ml-[2.4px] bg-bg-primary z-10 bg-radial-[100%_200%_at_0%_0%] to-bg-primary","from-modal-dialog-stop-0","group-data-[type=warning]/toast:from-utility-warning-50","group-data-[type=info]/toast:from-utility-blue-50","group-data-[type=success]/toast:from-utility-success-50","group-data-[type=error]/toast:from-utility-error-50"),children:a})]})}function X({className:t,...a}){return jsx(f,{className:cn("flex h-full items-center gap-3 overflow-hidden p-4 transition-opacity duration-250 ease-[cubic-bezier(0.22,1,0.36,1)] group-data-behind/toast:opacity-0 group-hover/viewport:group-data-expanded/toast:opacity-100 group-focus-within/viewport:group-data-expanded/toast:opacity-100",t),...a})}function I({className:t,...a}){return jsx(g,{className:cn("text-label-semibold-2 text-text-primary","group-data-[type=warning]/toast:text-text-warning-primary","group-data-[type=info]/toast:text-text-info-primary","group-data-[type=success]/toast:text-text-success-primary","group-data-[type=error]/toast:text-text-error-primary",t),...a})}function B({className:t,...a}){return jsx(h,{className:cn("text-body-regular-2 text-text-secondary",t),...a})}function S({className:t,render:a=jsx(b$1,{size:"sm",variant:"secondary"}),...e}){return jsx(i,{render:a,className:cn("shrink-0",t),...e})}function R({className:t,children:a,...e}){return jsx(j,{"aria-label":"Close toast",className:cn("relative shrink-0 text-fg-quaternary after:absolute after:-inset-2 after:content-[''] hover:text-text-error-primary size-6 inline-flex items-center justify-center [&_svg:not([class*='size-'])]:size-3.5",t),...e,children:a??jsx(XIcon,{"aria-hidden":"true"})})}function q({type:t}){let a=null;return t==="success"&&(a=jsx(b$2,{className:"text-fg-success-primary"})),t==="info"&&(a=jsx(a$1,{className:"text-fg-info-primary"})),t==="warning"&&(a=jsx(b$3,{className:"text-fg-warning-primary"})),t==="error"&&(a=jsx(b$4,{className:"text-fg-error-primary"})),t==="loading"&&(a=jsx(Loader2Icon,{className:"animate-spin","aria-hidden":"true"})),a?jsx("span",{"data-slot":"toast-icon",className:"shrink-0 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-6",children:a}):null}var F=["top-right","top-left","top-center","bottom-right","bottom-left","bottom-center"];function M({defaultPosition:t,position:a,limit:e=3}){let{toasts:i}=l();return i.filter(s=>(s.position??t)===a).map((s,p)=>jsx(V,{toast:s,"data-position":a,"data-behind":p>0?"":void 0,"data-limited":e!==void 0&&p>=e?"":void 0,style:{"--toast-index":p},children:jsxs(X,{children:[jsx(q,{type:s.type}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[jsx(I,{}),jsx(B,{})]}),jsx(S,{}),jsx(R,{})]})},s.id))}function K({children:t,position:a$1="top-right",limit:e=3,toastManager:i=a,...l}){return jsxs(A,{toastManager:i,limit:e,...l,children:[t,jsx(k,{children:F.map(s=>jsx(z,{position:s,children:jsx(M,{defaultPosition:a$1,position:s,limit:e})},s))})]})}export{k as a,z as b,A as c,V as d,X as e,I as f,B as g,S as h,R as i,K as j};//# sourceMappingURL=chunk-I57X26R2.js.map
2
+ //# sourceMappingURL=chunk-I57X26R2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ui/toast.tsx"],"names":["ToastPortal","props","jsx","positionVariants","ToastViewport","className","position","cn","ToastProvider","Toast","children","style","jsxs","ToastContent","ToastTitle","ToastDescription","ToastAction","render","Button","ToastClose","XIcon","ToastIcon","type","icon","check_square_icon_default","info_square_icon_default","danger_triangle_icon_default","close_square_icon_default","Loader2Icon","POSITIONS","ToastList","defaultPosition","limit","toasts","useToastManager","item","toastItem","index","Toaster","toastManager","toast","pos"],"mappings":"oZAyCA,SAASA,CAAAA,CAAY,CAAE,GAAGC,CAAM,CAAA,CAAqB,CACnD,OAAOC,GAAAA,CAACF,CAAAA,CAAA,CAAsB,GAAGC,EAAO,CAC1C,CAoBA,IAAME,CAAAA,CAAkD,CACtD,WAAA,CACE,2FAAA,CACF,UAAA,CACE,2FAAA,CACF,YAAA,CACE,uGAAA,CACF,cAAA,CACE,2FAAA,CACF,aAAA,CACE,2FAAA,CACF,eAAA,CACE,0GACJ,CAAA,CAEA,SAASC,CAAAA,CAAc,CACrB,SAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CAAW,WAAA,CACX,GAAGL,GACL,CAAA,CAAuB,CACrB,OACEC,GAAAA,CAACE,CAAAA,CAAA,CACC,SAAA,CAAWG,EAAAA,CACT,gGAAA,CACAJ,CAAAA,CAAiBG,CAAQ,CAAA,CACzBD,CACF,CAAA,CACC,GAAGJ,GAAAA,CACN,CAEJ,CAIA,SAASO,CAAAA,CAAcP,CAAAA,CAA2B,CAChD,OAAOC,GAAAA,CAACM,CAAAA,CAAA,CAAwB,GAAGP,CAAAA,CAAO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AAU,QAAA,CAAUmC,CAAAA,CAAK,KAAA,CAAOT,CAAAA,CAAO,CAAA,CAAA,CADjDS,CAEpB,CACD,CAAA,CACH,GACF,CAEJ","file":"chunk-I57X26R2.js","sourcesContent":["\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport {\r\n ToastPortal as ToastPortalPrimitive,\r\n ToastViewport as ToastViewportPrimitive,\r\n ToastProvider as ToastProviderPrimitive,\r\n Toast as ToastPrimitive,\r\n ToastContent as ToastContentPrimitive,\r\n ToastTitle as ToastTitlePrimitive,\r\n ToastDescription as ToastDescriptionPrimitive,\r\n ToastAction as ToastActionPrimitive,\r\n ToastClose as ToastClosePrimitive,\r\n toast,\r\n createToastManager,\r\n useToastManager,\r\n type ToastPortalProps as ToastPortalPrimitiveProps,\r\n type ToastViewportProps as ToastViewportPrimitiveProps,\r\n type ToastProviderProps as ToastProviderPrimitiveProps,\r\n type ToastProps as ToastPrimitiveProps,\r\n type ToastContentProps as ToastContentPrimitiveProps,\r\n type ToastTitleProps as ToastTitlePrimitiveProps,\r\n type ToastDescriptionProps as ToastDescriptionPrimitiveProps,\r\n type ToastActionProps as ToastActionPrimitiveProps,\r\n type ToastCloseProps as ToastClosePrimitiveProps,\r\n} from \"../primitives/toast\";\r\nimport { cn } from \"@xploreu/lib/cn\";\r\nimport {\r\n InfoSquareIcon,\r\n CheckSquareIcon,\r\n CloseSquareIcon,\r\n DangerTriangleIcon,\r\n} from \"../icons\";\r\nimport { Button } from \"./button\";\r\nimport {\r\n XIcon,\r\n Loader2Icon\r\n} from \"lucide-react\"\r\n\r\ntype ToastPortalProps = ToastPortalPrimitiveProps;\r\n\r\nfunction ToastPortal({ ...props }: ToastPortalProps) {\r\n return <ToastPortalPrimitive {...props} />;\r\n}\r\n\r\nexport type ToastPosition =\r\n | \"top-right\"\r\n | \"top-left\"\r\n | \"top-center\"\r\n | \"bottom-right\"\r\n | \"bottom-left\"\r\n | \"bottom-center\";\r\n\r\ndeclare module \"@base-ui/react/toast\" {\r\n interface ToastObject<Data extends object> {\r\n position?: ToastPosition;\r\n }\r\n}\r\n\r\ntype ToastViewportProps = ToastViewportPrimitiveProps & {\r\n position?: ToastPosition;\r\n};\r\n\r\nconst positionVariants: Record<ToastPosition, string> = {\r\n \"top-right\":\r\n \"fixed top-4 right-4 bottom-auto left-auto sm:top-4 sm:right-4 sm:bottom-auto sm:left-auto\",\r\n \"top-left\":\r\n \"fixed top-4 left-4 bottom-auto right-auto sm:top-4 sm:left-4 sm:bottom-auto sm:right-auto\",\r\n \"top-center\":\r\n \"fixed top-4 left-1/2 -translate-x-1/2 bottom-auto right-auto sm:top-4 sm:left-1/2 sm:-translate-x-1/2\",\r\n \"bottom-right\":\r\n \"fixed bottom-4 right-4 top-auto left-auto sm:bottom-4 sm:right-4 sm:top-auto sm:left-auto\",\r\n \"bottom-left\":\r\n \"fixed bottom-4 left-4 top-auto right-auto sm:bottom-4 sm:left-4 sm:top-auto sm:right-auto\",\r\n \"bottom-center\":\r\n \"fixed bottom-4 left-1/2 -translate-x-1/2 top-auto right-auto sm:bottom-4 sm:left-1/2 sm:-translate-x-1/2\",\r\n};\r\n\r\nfunction ToastViewport({\r\n className,\r\n position = \"top-right\",\r\n ...props\r\n}: ToastViewportProps) {\r\n return (\r\n <ToastViewportPrimitive\r\n className={cn(\r\n \"group/viewport pointer-events-none z-50 mx-auto w-auto max-w-sm outline-none sm:mx-0 sm:w-full\",\r\n positionVariants[position],\r\n className\r\n )}\r\n {...props}\r\n />\r\n );\r\n}\r\n\r\ntype ToastProviderProps = ToastProviderPrimitiveProps;\r\n\r\nfunction ToastProvider(props: ToastProviderProps) {\r\n return <ToastProviderPrimitive {...props} />;\r\n}\r\n\r\ntype ToastProps = ToastPrimitiveProps\r\n\r\nfunction Toast({ \r\n className, \r\n children, \r\n style,\r\n ...props \r\n}: ToastProps) {\r\n return (\r\n <ToastPrimitive\r\n style={style}\r\n className={cn(\r\n \"group/toast pointer-events-auto absolute right-0 z-[calc(1000-var(--toast-index))] w-full shadow-lg will-change-transform outline-none select-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-focus-ring\",\r\n \"bottom-0 origin-bottom rounded-l-[10.4px] rounded-r-lg\",\r\n \"data-[position^=top]:top-0 data-[position^=top]:bottom-auto data-[position^=top]:origin-top\",\r\n \"[--gap:0.75rem] [--height:var(--toast-frontmost-height,var(--toast-height))] [--offset-y:calc((var(--toast-index)*(var(--height)+var(--gap))*-1)+var(--toast-swipe-movement-y))] [--peek:0.75rem] [--scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--shrink:calc(1-var(--scale))]\",\r\n \"data-[position^=top]:[--offset-y:calc((var(--toast-index)*(var(--height)+var(--gap)))+var(--toast-swipe-movement-y))]\",\r\n \"h-(--height) [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--peek))-(var(--shrink)*var(--height))))_scale(var(--scale))] [transition:transform_500ms_cubic-bezier(0.22,1,0.36,1),opacity_500ms,height_150ms]\",\r\n \"data-[position^=top]:[transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)+(var(--toast-index)*var(--peek))+(var(--shrink)*var(--height))))_scale(var(--scale))]\",\r\n \"after:absolute after:top-full after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']\",\r\n \"group-hover/viewport:data-expanded:h-(--toast-height) group-hover/viewport:data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]\",\r\n \"group-focus-within/viewport:data-expanded:h-(--toast-height) group-focus-within/viewport:data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]\",\r\n \"data-limited:opacity-0 data-limited:pointer-events-none data-limited:invisible data-starting-style:[transform:translateY(150%)]\",\r\n \"data-[position^=top]:data-starting-style:[transform:translateY(-150%)]\",\r\n \"[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(150%)]\",\r\n \"data-[position^=top]:[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(-150%)]\",\r\n \"data-ending-style:opacity-0\",\r\n \"data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]\",\r\n \"data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]\",\r\n \"data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]\",\r\n \"data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]\",\r\n \"group-hover/viewport:data-expanded:data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]\",\r\n \"group-hover/viewport:data-expanded:data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]\",\r\n \"group-hover/viewport:data-expanded:data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]\",\r\n \"group-hover/viewport:data-expanded:data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]\",\r\n \"group-focus-within/viewport:data-expanded:data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]\",\r\n \"group-focus-within/viewport:data-expanded:data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]\",\r\n \"group-focus-within/viewport:data-expanded:data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]\",\r\n \"group-focus-within/viewport:data-expanded:data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]\",\r\n className\r\n )}\r\n {...props}\r\n >\r\n <div className={cn(\r\n \"absolute left-0 inset-y-0 w-[10.4px] rounded-l-[10.4px] bg-[linear-gradient(180deg,#377DFA_0%,#185BC2_80%)]\",\r\n \"group-data-[type=warning]/toast:bg-[linear-gradient(180deg,#F79009_0%,#B54708_80%)]\",\r\n \"group-data-[type=info]/toast:bg-[linear-gradient(180deg,#068BEE_0%,#175BCC_80%)]\",\r\n \"group-data-[type=success]/toast:bg-[linear-gradient(180deg,#17B26A_0%,#067647_80%)]\",\r\n \"group-data-[type=error]/toast:bg-[linear-gradient(180deg,#F04438_0%,#B42318_80%)]\",\r\n )} />\r\n <div className={cn(\r\n \"relative border border-border-secondary rounded-lg ml-[2.4px] bg-bg-primary z-10 bg-radial-[100%_200%_at_0%_0%] to-bg-primary\",\r\n \"from-modal-dialog-stop-0\",\r\n \"group-data-[type=warning]/toast:from-utility-warning-50\",\r\n \"group-data-[type=info]/toast:from-utility-blue-50\",\r\n \"group-data-[type=success]/toast:from-utility-success-50\",\r\n \"group-data-[type=error]/toast:from-utility-error-50\",\r\n )}>\r\n {children}\r\n </div>\r\n </ToastPrimitive>\r\n );\r\n}\r\n\r\ntype ToastContentProps = ToastContentPrimitiveProps;\r\n\r\nfunction ToastContent({ className, ...props }: ToastContentProps) {\r\n return (\r\n <ToastContentPrimitive\r\n className={cn(\r\n \"flex h-full items-center gap-3 overflow-hidden p-4 transition-opacity duration-250 ease-[cubic-bezier(0.22,1,0.36,1)] group-data-behind/toast:opacity-0 group-hover/viewport:group-data-expanded/toast:opacity-100 group-focus-within/viewport:group-data-expanded/toast:opacity-100\",\r\n className\r\n )}\r\n {...props}\r\n />\r\n );\r\n}\r\n\r\ntype ToastTitleProps = ToastTitlePrimitiveProps;\r\n\r\nfunction ToastTitle({ className, ...props }: ToastTitleProps) {\r\n return (\r\n <ToastTitlePrimitive\r\n className={cn(\r\n \"text-label-semibold-2 text-text-primary\", \r\n \"group-data-[type=warning]/toast:text-text-warning-primary\",\r\n \"group-data-[type=info]/toast:text-text-info-primary\",\r\n \"group-data-[type=success]/toast:text-text-success-primary\",\r\n \"group-data-[type=error]/toast:text-text-error-primary\",\r\n className\r\n )}\r\n {...props}\r\n />\r\n );\r\n}\r\n\r\ntype ToastDescriptionProps = ToastDescriptionPrimitiveProps;\r\n\r\nfunction ToastDescription({ className, ...props }: ToastDescriptionProps) {\r\n return (\r\n <ToastDescriptionPrimitive\r\n className={cn(\"text-body-regular-2 text-text-secondary\", className)}\r\n {...props}\r\n />\r\n );\r\n}\r\n\r\ntype ToastActionProps = ToastActionPrimitiveProps;\r\n\r\nfunction ToastAction({\r\n className,\r\n render = <Button size=\"sm\" variant=\"secondary\" />,\r\n ...props\r\n}: ToastActionProps) {\r\n return (\r\n <ToastActionPrimitive\r\n render={render}\r\n className={cn(\"shrink-0\", className)}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype ToastCloseProps = ToastClosePrimitiveProps;\r\n\r\nfunction ToastClose({ className, children, ...props }: ToastCloseProps) {\r\n return (\r\n <ToastClosePrimitive\r\n aria-label=\"Close toast\"\r\n className={cn(\r\n \"relative shrink-0 text-fg-quaternary after:absolute after:-inset-2 after:content-[''] hover:text-text-error-primary size-6 inline-flex items-center justify-center [&_svg:not([class*='size-'])]:size-3.5\",\r\n className\r\n )}\r\n {...props}\r\n >\r\n {children ?? <XIcon aria-hidden=\"true\" />}\r\n </ToastClosePrimitive>\r\n );\r\n}\r\n\r\ntype ToastIconProps = { type: string | undefined }\r\n\r\nfunction ToastIcon({ type }: ToastIconProps) {\r\n let icon: React.ReactNode = null;\r\n\r\n if (type === \"success\") {\r\n icon = <CheckSquareIcon className=\"text-fg-success-primary\" />;\r\n } \r\n \r\n if (type === \"info\") {\r\n icon = <InfoSquareIcon className=\"text-fg-info-primary\" />;\r\n }\r\n \r\n if (type === \"warning\") {\r\n icon = <DangerTriangleIcon className=\"text-fg-warning-primary\" />;\r\n }\r\n \r\n if (type === \"error\") {\r\n icon = <CloseSquareIcon className=\"text-fg-error-primary\" />;\r\n }\r\n\r\n if (type === \"loading\") {\r\n icon = <Loader2Icon className=\"animate-spin\" aria-hidden=\"true\" />\r\n }\r\n\r\n if (!icon) return null;\r\n\r\n return (\r\n <span\r\n data-slot=\"toast-icon\"\r\n className=\"shrink-0 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-6\"\r\n >\r\n {icon}\r\n </span>\r\n );\r\n}\r\n\r\nconst POSITIONS: ToastPosition[] = [\r\n \"top-right\",\r\n \"top-left\",\r\n \"top-center\",\r\n \"bottom-right\",\r\n \"bottom-left\",\r\n \"bottom-center\",\r\n];\r\n\r\nfunction ToastList({\r\n defaultPosition,\r\n position,\r\n limit = 3,\r\n}: {\r\n defaultPosition: ToastPosition;\r\n position: ToastPosition;\r\n limit?: number;\r\n}) {\r\n const { toasts } = useToastManager();\r\n const matchingToasts = toasts.filter(\r\n (item) => (item.position ?? defaultPosition) === position\r\n );\r\n\r\n return matchingToasts.map((toastItem, index) => (\r\n <Toast\r\n key={toastItem.id}\r\n toast={toastItem}\r\n data-position={position}\r\n data-behind={index > 0 ? \"\" : undefined}\r\n data-limited={limit !== undefined && index >= limit ? \"\" : undefined}\r\n style={\r\n {\r\n \"--toast-index\": index,\r\n } as React.CSSProperties\r\n }\r\n >\r\n <ToastContent>\r\n <ToastIcon type={toastItem.type} />\r\n <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\r\n <ToastTitle />\r\n <ToastDescription />\r\n </div>\r\n <ToastAction />\r\n <ToastClose />\r\n </ToastContent>\r\n </Toast>\r\n ));\r\n}\r\n\r\ntype ToasterProps = ToastProviderPrimitiveProps & {\r\n position?: ToastPosition;\r\n limit?: number;\r\n};\r\n\r\nfunction Toaster({\r\n children,\r\n position = \"top-right\",\r\n limit = 3,\r\n toastManager = toast,\r\n ...props\r\n}: ToasterProps) {\r\n return (\r\n <ToastProvider toastManager={toastManager} limit={limit} {...props}>\r\n {children}\r\n <ToastPortal>\r\n {POSITIONS.map((pos) => (\r\n <ToastViewport key={pos} position={pos}>\r\n <ToastList defaultPosition={position} position={pos} limit={limit} />\r\n </ToastViewport>\r\n ))}\r\n </ToastPortal>\r\n </ToastProvider>\r\n );\r\n}\r\n\r\nexport {\r\n Toaster,\r\n Toast,\r\n ToastProvider,\r\n ToastAction,\r\n ToastClose,\r\n ToastContent,\r\n ToastDescription,\r\n ToastPortal,\r\n ToastTitle,\r\n ToastViewport,\r\n toast,\r\n createToastManager,\r\n useToastManager,\r\n type ToasterProps,\r\n type ToastProps,\r\n type ToastProviderProps,\r\n type ToastActionProps,\r\n type ToastCloseProps,\r\n type ToastContentProps,\r\n type ToastDescriptionProps,\r\n type ToastPortalProps,\r\n type ToastTitleProps,\r\n type ToastViewportProps,\r\n};\r\n\r\n\r\n"]}
@@ -0,0 +1,2 @@
1
+ import {b}from'./chunk-JH6RZ3QH.js';import {a as a$1}from'./chunk-TED2PUK6.js';import {b as b$2,c as c$2}from'./chunk-KYD4ATTG.js';import {b as b$1,c as c$1}from'./chunk-DZKJRP4J.js';import {a}from'./chunk-XG3W7QMP.js';import*as G from'react';import {SearchIcon,XIcon,Loader2Icon,CheckCircle2Icon}from'lucide-react';import {Combobox}from'@base-ui/react/combobox';import {AnimatePresence,motion}from'motion/react';import {useControlledState}from'@xploreu/hooks/use-controlled-state';import {useDataState}from'@xploreu/hooks/use-data-state';import {getStrictContext}from'@xploreu/lib/get-strict-context';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {cn}from'@xploreu/lib/cn';var[no,c]=getStrictContext("ComboboxContext"),[Co,H]=getStrictContext("ComboboxActiveValueContext");function k({behavior:o="default",...t}){let[b,m]=useControlledState({value:t?.open,defaultValue:t?.defaultOpen,onChange:t?.onOpenChange}),[s,C]=useControlledState({value:t?.inputValue?.toString(),defaultValue:t?.defaultInputValue?.toString(),onChange:t?.onInputValueChange}),[a,l]=G.useState(null),u=(x,n)=>{if(n.reason==="input-clear")return n.cancel();C(x,n);},y=(x,n)=>{let po=n.trigger?.dataset;if(o==="chip-outside"&&(n.reason==="trigger-press"&&po?.slot==="combobox-clear-input"&&!x||n.reason==="item-press"))return n.cancel();m(x,n);};return jsx(Co,{value:{highlightedValue:a,setHighlightedValue:l},children:jsx(no,{value:{open:b,setOpen:m,inputValue:s,setInputValue:C},children:jsx(Combobox.Root,{"data-slot":"combobox",...t,onInputValueChange:u,onOpenChange:y})})})}function T(o){return jsx(Combobox.Trigger,{"data-slot":"combobox-trigger",...o})}function A(o){return jsx(Combobox.Label,{"data-slot":"combobox-label",...o})}function B(o){return jsx(Combobox.InputGroup,{"data-slot":"combobox-input-group",...o})}function g(o){return jsx(Combobox.Input,{"data-slot":"combobox-input",...o})}function E(o){return jsx(Combobox.Icon,{"data-slot":"combobox-icon",...o})}function M(o){return jsx(Combobox.Clear,{"data-slot":"combobox-clear",...o})}function O(o){return jsx(Combobox.Value,{"data-slot":"combobox-value",...o})}function z(o){return jsx(Combobox.Chips,{"data-slot":"combobox-chips",...o})}function F(o){return jsx(Combobox.Chip,{"data-slot":"combobox-chip",...o})}function D(o){return jsx(Combobox.ChipRemove,{"data-slot":"combobox-chip-remove",...o})}function h(o){let{open:t}=c();return jsx(AnimatePresence,{children:t&&jsx(Combobox.Portal,{"data-slot":"combobox-portal",keepMounted:true,...o})})}function v(o){return jsx(Combobox.Positioner,{"data-slot":"combobox-positioner",...o})}function q({initialFocus:o,finalFocus:t,transition:b={type:"spring",stiffness:300,damping:25},...m}){return jsx(Combobox.Popup,{finalFocus:t,initialFocus:o,render:jsx(motion.div,{animate:{opacity:1,scale:1},"data-slot":"combobox-popup",exit:{opacity:0,scale:.5},initial:{opacity:0,scale:.5},transition:b,...m},"combobox-popup")})}function U(o){return jsx(Combobox.Backdrop,{"data-slot":"combobox-backdrop",...o})}function X(o){return jsx(Combobox.Status,{"data-slot":"combobox-status",...o})}function $(o){return jsx(Combobox.Empty,{"data-slot":"combobox-empty",...o})}function J(o){return jsx(Combobox.List,{"data-slot":"combobox-list",...o})}function K({transition:o={type:"spring",stiffness:350,damping:35},...t}){let{highlightedValue:b}=H();return jsx(b$2,{click:false,controlledItems:true,"data-slot":"combobox-highlight",transition:o,value:b,...t})}function Q(o){return jsx(c$2,{"data-slot":"combobox-highlight-item",...o})}function W(o){return jsx(Combobox.Row,{"data-slot":"combobox-row",...o})}function Y(o){let{setHighlightedValue:t}=H(),[,b]=useDataState("highlighted",void 0,(m,s)=>{if(m===true){let C=s.current,a=C?.dataset.value||C?.id||null;a&&t(a);}});return jsx(Combobox.Item,{ref:b,"data-slot":"combobox-item",...o})}function Z(o){return jsx(Combobox.ItemIndicator,{"data-slot":"combobox-item-indicator",...o})}function _(o){return jsx(Combobox.Separator,{"data-slot":"combobox-separator",...o})}function j(o){return jsx(Combobox.Group,{"data-slot":"combobox-group",...o})}function oo(o){return jsx(Combobox.GroupLabel,{"data-slot":"combobox-group-label",...o})}function to(o){return jsx(Combobox.Collection,{"data-slot":"combobox-collection",...o})}function eo(o){return jsx(Combobox.Arrow,{"data-slot":"combobox-arrow",...o})}function Fo(o){return jsx(k,{...o})}function Po(o){let{className:t,...b}=o;return jsx(T,{className:cn("group/combobox-trigger flex items-center gap-2",t),...b})}function Do(o){let{className:t,...b}=o;return jsx(A,{className:cn("text-label-semibold-2 text-text-secondary",t),...b})}function qo(o){let{className:t,...b}=o;return jsx(B,{className:cn("flex w-full items-center gap-2",t),...b})}function Uo({className:o,wrapperClassName:t,...b$1}){return jsx("div",{className:cn("px-3 py-2.5 border-b border-border-primary",t),children:jsx(g,{className:o,render:jsx(b,{size:"sm",startContent:jsx(SearchIcon,{})}),...b$1})})}function Xo({className:o,displayValueKey:t={label:"label",value:"value"},placeholder:b$1="Search and Select Company",inputProps:m,...s}){let{inputValue:C,setInputValue:a}=c(),{className:l,startContent:u,...y}=m||{};return jsx("div",{className:cn("flex flex-col gap-2",o),children:jsxs(uo,{onMouseDown:x=>x.preventBaseUIHandler(),className:"flex-col",children:[jsx(g,{render:jsx(b,{className:cn("h-9 text-body-regular-3 pl-9 pr-7",l),endContent:jsx(Po,{nativeButton:false,render:jsx(XIcon,{className:"!size-5 !right-1.5 data-[hidden=true]:opacity-0 opacity-100 transition-opacity duration-300 cursor-pointer","data-hidden":!C,"data-slot":"combobox-clear-input",onClick:x=>{a("",{reason:"none",event:x.nativeEvent,cancel:()=>{},allowPropagation:()=>{},isCanceled:false,isPropagationAllowed:true,trigger:void 0});}})}),placeholder:b$1,startContent:u??jsx(SearchIcon,{className:"!size-4 !text-fg-tertiary-hover"}),...y}),...s}),jsx(lo,{children:x=>x?.map(n=>jsxs(co,{children:[n?.[t.label]||"",jsx(yo,{})]},n?.[t.value]||""))})]})})}function $o(o){let{className:t,...b}=o;return jsx(E,{className:cn("text-text-secondary",t),...b})}function Jo(o){return jsx(M,{render:jsx(XIcon,{}),...o})}function lo(o){return jsx(O,{...o})}function uo({className:o,...t}){return jsx(z,{className:cn("flex flex-wrap gap-2",o),...t})}function co({className:o,...t}){return jsx(b$1,{className:cn("ring-1 ring-border-brand text-body-medium-3",o),color:"brand",render:jsx(F,{...t}),size:"lg"})}function yo({className:o,...t}){return jsx(c$1,{className:cn("text-fg-quaternary",o),render:jsx(D,{...t})})}function Ko({className:o,align:t="start",sideOffset:b=4,container:m,initialFocus:s,finalFocus:C,style:a,children:l,...u}){return jsx(h,{container:m,children:jsx(v,{align:t,className:"isolate z-50",sideOffset:b,...u,children:jsx(q,{className:cn("group/combobox-popup bg-bg-primary text-text-primary max-h-(--available-height) w-72 max-w-(--available-width) origin-(--transform-origin) rounded-md border border-border-primary shadow-md outline-hidden",o),finalFocus:C,initialFocus:s,style:a,children:jsx(go,{children:l})})})})}function Qo(o){return jsx(h,{...o})}function Wo(o){return jsx(v,{...o})}function Yo(o){let{className:t,...b}=o;return jsx(U,{className:cn("bg-black/30",t),...b})}function Zo({className:o,status:t,...b}){let{inputValue:m}=c(),s=m?.toString().trim(),a=t==="empty"&&s?`No matches for "${s}".`:t==="empty"&&!s?"No results.":t==="pending"?jsxs(Fragment,{children:[jsx(Loader2Icon,{className:"animate-spin size-4"}),jsx("span",{children:"Searching..."})]}):null;return jsx(X,{className:cn("px-2 py-2.5 text-body-regular-2 text-text-disabled flex items-center gap-2",!a&&"hidden",o),...b,children:a})}function _o({className:o,...t}){return jsx($,{className:cn("px-3 py-2 text-body-regular-2 text-text-secondary",o),...t})}function jo({className:o,...t}){return jsx(J,{className:cn("max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] overflow-auto scrollbar-thin flex flex-col p-1 focus-visible:outline-none",o),...t})}function go(o){let{className:t,...b}=o;return jsx(K,{className:cn("absolute inset-0 bg-bg-primary-hover",t),...b})}function ho(o){return jsx(Q,{...o})}function ot(o){let{className:t,...b}=o;return jsx(W,{className:cn("group/combobox-row",t),...b})}function tt({className:o,children:t,indicator:b="check-circle",...m}){let{disabled:s}=m;return jsx(ho,{activeClassName:"bg-bg-primary-hover rounded-md",disabled:s,children:jsxs(Y,{"data-indicator":b,className:cn("group/combobox-item relative flex w-full cursor-default items-center gap-xp-md my-px p-xp-md [[data-indicator=check-circle][data-selected]]:pr-8 data-[indicator=checkbox]:pl-8 outline-none",o),...m,children:[t,jsx(vo,{className:"absolute group-data-[indicator=check-circle]/combobox-item:right-2 group-data-[indicator=checkbox]/combobox-item:left-2",keepMounted:b==="checkbox",render:(C,a$1)=>jsxs("span",{...C,children:[b==="check-circle"&&jsx(CheckCircle2Icon,{className:"size-4 text-fg-brand-primary shrink-0"}),b==="checkbox"&&jsx(a,{checked:a$1.selected})]})})]})})}function et({className:o,...t}){return jsx("span",{className:cn("text-body-medium-3 text-text-primary truncate",o),...t})}function bt({className:o,...t}){return jsx("span",{className:cn("text-body-regular-3 text-text-secondary truncate",o),...t})}function vo(o){return jsx(Z,{...o})}function rt(o){let{className:t,...b}=o;return jsx(_,{className:cn("my-1 h-px bg-border-primary",t),...b})}function it(o){let{className:t,...b}=o;return jsx(j,{className:cn("py-1",t),...b})}function pt(o){let{className:t,...b}=o;return jsx(oo,{className:cn("px-3 py-1 text-body-semibold-sm text-text-secondary",t),...b})}function mt(o){return jsx(to,{...o})}function st(o){let{className:t,...b}=o;return jsx(eo,{className:cn("fill-bg-primary",t),...b})}function at({hasMore:o,threshold:t=.5,...b}){return jsx(a$1,{hasMore:o,threshold:t,...b,children:o&&jsxs("div",{className:"px-2 py-2.5 text-body-regular-2 text-text-disabled flex items-center gap-2",children:[jsx(Loader2Icon,{className:"animate-spin size-4"}),jsx("span",{children:"Loading more..."})]})})}export{bt as A,vo as B,rt as C,it as D,pt as E,mt as F,st as G,at as H,B as a,g as b,Fo as c,Po as d,Do as e,qo as f,Uo as g,Xo as h,$o as i,Jo as j,lo as k,uo as l,co as m,yo as n,Ko as o,Qo as p,Wo as q,Yo as r,Zo as s,_o as t,jo as u,go as v,ho as w,ot as x,tt as y,et as z};//# sourceMappingURL=chunk-NVQMVFSP.js.map
2
+ //# sourceMappingURL=chunk-NVQMVFSP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/primitives/combobox.tsx","../src/ui/combobox.tsx"],"names":["ComboboxProvider","useCombobox","getStrictContext","ComboboxActiveValueProvider","useComboboxActiveValue","Combobox","behavior","props","open","setOpen","useControlledState","inputValue","setInputValue","highlightedValue","setHighlightedValue","handleInputValueChange","eventDetails","handleOpenChange","dataSet","jsx","ComboboxPrimitive","ComboboxTrigger","ComboboxLabel","ComboboxInputGroup","ComboboxInput","ComboboxIcon","ComboboxClear","ComboboxValue","ComboboxChips","ComboboxChip","ComboboxChipRemove","ComboboxPortal","AnimatePresence","ComboboxPositioner","ComboboxPopup","initialFocus","finalFocus","transition","motion","ComboboxBackdrop","ComboboxStatus","ComboboxEmpty","ComboboxList","ComboboxHighlight","Highlight","ComboboxHighlightItem","HighlightItem","ComboboxRow","ComboboxItem","highlightedRef","useDataState","value","ref","el","v","ComboboxItemIndicator","ComboboxSeparator","ComboboxGroup","ComboboxGroupLabel","ComboboxCollection","ComboboxArrow","className","rest","cn","wrapperClassName","Input","SearchIcon","ComboboxInputFilter","displayValueKey","placeholder","inputProps","inputClassName","startContent","restInputProps","jsxs","e","XIcon","event","item","Badge","BadgeButton","align","sideOffset","container","style","children","status","trimmedInputValue","text","Fragment","Loader2Icon","indicator","disabled","state","CheckCircle2Icon","Checkbox","ComboboxItemTitle","ComboboxItemDescription","ComboboxInfiniteScroll","hasMore","threshold","InfiniteScroll"],"mappings":"6qBAiCA,GAAM,CAACA,EAAAA,CAAkBC,CAAW,CAAA,CAClCC,gBAAAA,CAAsC,iBAAiB,EAEnD,CAACC,EAAAA,CAA6BC,CAAsB,CAAA,CACxDF,gBAAAA,CAAiD,4BAA4B,EAM/E,SAASG,CAAAA,CAA8D,CACrE,QAAA,CAAAC,CAAAA,CAAW,UACX,GAAGC,CACL,CAAA,CAAmC,CACjC,GAAM,CAACC,EAAMC,CAAO,CAAA,CAAIC,kBAAAA,CAAmB,CACzC,KAAA,CAAOH,CAAAA,EAAO,KACd,YAAA,CAAcA,CAAAA,EAAO,WAAA,CACrB,QAAA,CAAUA,CAAAA,EAAO,YACnB,CAAC,CAAA,CAEK,CAACI,CAAAA,CAAYC,CAAa,CAAA,CAAIF,kBAAAA,CAAmB,CACrD,KAAA,CAAOH,CAAAA,EAAO,UAAA,EAAY,QAAA,EAAS,CACnC,YAAA,CAAcA,GAAO,iBAAA,EAAmB,QAAA,EAAS,CACjD,QAAA,CAAUA,CAAAA,EAAO,kBACnB,CAAC,CAAA,CAEK,CAACM,CAAAA,CAAkBC,CAAmB,CAAA,CAAU,CAAA,CAAA,QAAA,CAAwB,IAAI,CAAA,CAE5EC,CAAAA,CAA+E,CAACJ,CAAAA,CAAYK,CAAAA,GAAiB,CAEjH,GAAIA,CAAAA,CAAa,MAAA,GAAW,aAAA,CAAe,OAAOA,CAAAA,CAAa,QAAO,CAEtEJ,CAAAA,CAAcD,CAAAA,CAAYK,CAAY,EACxC,CAAA,CAEMC,EAAmE,CAACT,CAAAA,CAAMQ,CAAAA,GAAiB,CAC/F,IAAME,EAAAA,CAAWF,EAAa,OAAA,EAAyB,OAAA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CAAkE,CAChE,OACEY,GAAAA,CAACkF,IAAA,CACC,OAAA,CAASF,CAAAA,CACT,SAAA,CAAWC,CAAAA,CACV,GAAG7F,EAEH,QAAA,CAAA4F,CAAAA,EACCzB,IAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAU,4EAAA,CACb,UAAAvD,GAAAA,CAACuE,WAAAA,CAAA,CAAY,SAAA,CAAU,qBAAA,CAAsB,CAAA,CAC7CvE,IAAC,MAAA,CAAA,CAAK,QAAA,CAAA,iBAAA,CAEN,CAAA,CAAA,CACF,CAAA,CAEJ,CAEJ","file":"chunk-NVQMVFSP.js","sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\n\r\nimport { Combobox as ComboboxPrimitive } from \"@base-ui/react/combobox\"\r\nimport {\r\n AnimatePresence,\r\n type HTMLMotionProps,\r\n motion\r\n} from \"motion/react\"\r\n\r\nimport {\r\n Highlight,\r\n HighlightItem,\r\n type HighlightItemProps,\r\n type HighlightProps,\r\n} from \"../effects/highlight\"\r\nimport { useControlledState } from \"@xploreu/hooks/use-controlled-state\"\r\nimport { useDataState } from \"@xploreu/hooks/use-data-state\"\r\nimport { getStrictContext } from \"@xploreu/lib/get-strict-context\"\r\n\r\ntype ComboboxContextType = {\r\n open: boolean;\r\n setOpen: (open: boolean, eventDetails: ComboboxPrimitive.Root.ChangeEventDetails) => void;\r\n inputValue: string;\r\n setInputValue: (inputValue: string, eventDetails: ComboboxPrimitive.Root.ChangeEventDetails) => void;\r\n}\r\n\r\ntype ComboboxActiveValueContextType = {\r\n highlightedValue: string | null;\r\n setHighlightedValue: (value: string | null) => void;\r\n}\r\n\r\nconst [ComboboxProvider, useCombobox] =\r\n getStrictContext<ComboboxContextType>(\"ComboboxContext\")\r\n\r\nconst [ComboboxActiveValueProvider, useComboboxActiveValue] =\r\n getStrictContext<ComboboxActiveValueContextType>(\"ComboboxActiveValueContext\")\r\n\r\ntype ComboboxProps<Value, Multiple extends boolean | undefined = false> = ComboboxPrimitive.Root.Props<Value, Multiple> & {\r\n behavior?: \"default\" | \"chip-outside\";\r\n}\r\n\r\nfunction Combobox<Value, Multiple extends boolean | undefined = false>({\r\n behavior = \"default\",\r\n ...props\r\n}: ComboboxProps<Value, Multiple>) {\r\n const [open, setOpen] = useControlledState({\r\n value: props?.open,\r\n defaultValue: props?.defaultOpen,\r\n onChange: props?.onOpenChange,\r\n })\r\n\r\n const [inputValue, setInputValue] = useControlledState({\r\n value: props?.inputValue?.toString(),\r\n defaultValue: props?.defaultInputValue?.toString(),\r\n onChange: props?.onInputValueChange,\r\n })\r\n\r\n const [highlightedValue, setHighlightedValue] = React.useState<string | null>(null)\r\n\r\n const handleInputValueChange: ComboboxProps<Value, Multiple>[\"onInputValueChange\"] = (inputValue, eventDetails) => {\r\n // if the input is cleared, we want to cancel the event to prevent resetting the input value.\r\n if (eventDetails.reason === \"input-clear\") return eventDetails.cancel()\r\n\r\n setInputValue(inputValue, eventDetails)\r\n }\r\n\r\n const handleOpenChange: ComboboxProps<Value, Multiple>[\"onOpenChange\"] = (open, eventDetails) => {\r\n const dataSet = (eventDetails.trigger as HTMLElement)?.dataset\r\n\r\n\r\n if (behavior === \"chip-outside\") {\r\n if (\r\n eventDetails.reason === \"trigger-press\" &&\r\n dataSet?.slot === \"combobox-clear-input\" &&\r\n !open\r\n ) {\r\n return eventDetails.cancel()\r\n }\r\n\r\n if (eventDetails.reason === \"item-press\") {\r\n return eventDetails.cancel()\r\n }\r\n }\r\n\r\n setOpen(open, eventDetails)\r\n }\r\n\r\n return (\r\n <ComboboxActiveValueProvider value={{ highlightedValue, setHighlightedValue }}>\r\n <ComboboxProvider value={{ open, setOpen, inputValue, setInputValue }}>\r\n <ComboboxPrimitive.Root\r\n data-slot=\"combobox\"\r\n {...props}\r\n onInputValueChange={handleInputValueChange}\r\n onOpenChange={handleOpenChange}\r\n />\r\n </ComboboxProvider>\r\n </ComboboxActiveValueProvider>\r\n )\r\n}\r\n\r\ntype ComboboxTriggerProps = ComboboxPrimitive.Trigger.Props\r\n\r\nfunction ComboboxTrigger(props: ComboboxTriggerProps) {\r\n return <ComboboxPrimitive.Trigger\r\n data-slot=\"combobox-trigger\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxLabelProps = ComboboxPrimitive.Label.Props\r\n\r\nfunction ComboboxLabel(props: ComboboxLabelProps) {\r\n return <ComboboxPrimitive.Label\r\n data-slot=\"combobox-label\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxInputGroupProps = ComboboxPrimitive.InputGroup.Props\r\n\r\nfunction ComboboxInputGroup(props: ComboboxInputGroupProps) {\r\n return <ComboboxPrimitive.InputGroup\r\n data-slot=\"combobox-input-group\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxInputProps = ComboboxPrimitive.Input.Props\r\n\r\nfunction ComboboxInput(props: ComboboxInputProps) {\r\n return <ComboboxPrimitive.Input\r\n data-slot=\"combobox-input\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxIconProps = ComboboxPrimitive.Icon.Props\r\n\r\nfunction ComboboxIcon(props: ComboboxIconProps) {\r\n return <ComboboxPrimitive.Icon\r\n data-slot=\"combobox-icon\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxClearProps = ComboboxPrimitive.Clear.Props\r\n\r\nfunction ComboboxClear(props: ComboboxClearProps) {\r\n return <ComboboxPrimitive.Clear\r\n data-slot=\"combobox-clear\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxValueProps = ComboboxPrimitive.Value.Props\r\n\r\nfunction ComboboxValue(props: ComboboxValueProps) {\r\n return <ComboboxPrimitive.Value\r\n data-slot=\"combobox-value\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxChipsProps = ComboboxPrimitive.Chips.Props\r\n\r\nfunction ComboboxChips(props: ComboboxChipsProps) {\r\n return <ComboboxPrimitive.Chips\r\n data-slot=\"combobox-chips\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxChipProps = ComboboxPrimitive.Chip.Props\r\n\r\nfunction ComboboxChip(props: ComboboxChipProps) {\r\n return <ComboboxPrimitive.Chip\r\n data-slot=\"combobox-chip\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxChipRemoveProps = ComboboxPrimitive.ChipRemove.Props\r\n\r\nfunction ComboboxChipRemove(props: ComboboxChipRemoveProps) {\r\n return <ComboboxPrimitive.ChipRemove\r\n data-slot=\"combobox-chip-remove\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxPortalProps = Omit<\r\n ComboboxPrimitive.Portal.Props,\r\n \"keepMounted\"\r\n>\r\n\r\nfunction ComboboxPortal(props: ComboboxPortalProps) {\r\n const { open } = useCombobox()\r\n\r\n return (\r\n <AnimatePresence>\r\n {open && (\r\n <ComboboxPrimitive.Portal\r\n data-slot=\"combobox-portal\"\r\n keepMounted\r\n {...props}\r\n />\r\n )}\r\n </AnimatePresence>\r\n )\r\n}\r\n\r\ntype ComboboxPositionerProps = ComboboxPrimitive.Positioner.Props\r\n\r\nfunction ComboboxPositioner(props: ComboboxPositionerProps) {\r\n return (\r\n <ComboboxPrimitive.Positioner\r\n data-slot=\"combobox-positioner\"\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxPopupProps = Omit<\r\n ComboboxPrimitive.Popup.Props,\r\n \"render\"\r\n> &\r\n HTMLMotionProps<\"div\">\r\n\r\nfunction ComboboxPopup({\r\n initialFocus,\r\n finalFocus,\r\n transition = { type: \"spring\", stiffness: 300, damping: 25 },\r\n ...props\r\n}: ComboboxPopupProps) {\r\n return (\r\n <ComboboxPrimitive.Popup\r\n finalFocus={finalFocus}\r\n initialFocus={initialFocus}\r\n render={\r\n <motion.div\r\n key=\"combobox-popup\"\r\n animate={{ opacity: 1, scale: 1 }}\r\n data-slot=\"combobox-popup\"\r\n exit={{ opacity: 0, scale: 0.5 }}\r\n initial={{ opacity: 0, scale: 0.5 }}\r\n transition={transition}\r\n {...props}\r\n />\r\n }\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxBackdropProps = ComboboxPrimitive.Backdrop.Props\r\n\r\nfunction ComboboxBackdrop(props: ComboboxBackdropProps) {\r\n return <ComboboxPrimitive.Backdrop\r\n data-slot=\"combobox-backdrop\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxStatusProps = ComboboxPrimitive.Status.Props\r\n\r\nfunction ComboboxStatus(props: ComboboxStatusProps) {\r\n return <ComboboxPrimitive.Status\r\n data-slot=\"combobox-status\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxEmptyProps = ComboboxPrimitive.Empty.Props\r\n\r\nfunction ComboboxEmpty(props: ComboboxEmptyProps) {\r\n return <ComboboxPrimitive.Empty\r\n data-slot=\"combobox-empty\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxListProps = ComboboxPrimitive.List.Props\r\n\r\nfunction ComboboxList(props: ComboboxListProps) {\r\n return <ComboboxPrimitive.List\r\n data-slot=\"combobox-list\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxHighlightProps = Omit<\r\n HighlightProps,\r\n \"controlledItems\" | \"enabled\" | \"hover\"\r\n>\r\n\r\nfunction ComboboxHighlight({\r\n transition = { type: \"spring\", stiffness: 350, damping: 35 },\r\n ...props\r\n}: ComboboxHighlightProps) {\r\n const { highlightedValue } = useComboboxActiveValue()\r\n\r\n return (\r\n <Highlight\r\n click={false}\r\n controlledItems\r\n data-slot=\"combobox-highlight\"\r\n transition={transition}\r\n value={highlightedValue}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxHighlightItemProps = HighlightItemProps\r\n\r\nfunction ComboboxHighlightItem(props: ComboboxHighlightItemProps) {\r\n return (\r\n <HighlightItem\r\n data-slot=\"combobox-highlight-item\"\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxRowProps = ComboboxPrimitive.Row.Props\r\n\r\nfunction ComboboxRow(props: ComboboxRowProps) {\r\n return <ComboboxPrimitive.Row\r\n data-slot=\"combobox-row\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxItemProps = ComboboxPrimitive.Item.Props\r\n\r\nfunction ComboboxItem(props: ComboboxItemProps) {\r\n const { setHighlightedValue } = useComboboxActiveValue()\r\n const [, highlightedRef] = useDataState<HTMLDivElement>(\r\n \"highlighted\",\r\n undefined,\r\n (value, ref) => {\r\n if (value === true) {\r\n const el = ref.current\r\n const v = el?.dataset.value || el?.id || null\r\n if (v) setHighlightedValue(v)\r\n }\r\n },\r\n )\r\n\r\n return <ComboboxPrimitive.Item\r\n ref={highlightedRef}\r\n data-slot=\"combobox-item\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxItemIndicatorProps = ComboboxPrimitive.ItemIndicator.Props\r\n\r\nfunction ComboboxItemIndicator(props: ComboboxItemIndicatorProps) {\r\n return <ComboboxPrimitive.ItemIndicator\r\n data-slot=\"combobox-item-indicator\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxSeparatorProps = ComboboxPrimitive.Separator.Props\r\n\r\nfunction ComboboxSeparator(props: ComboboxSeparatorProps) {\r\n return <ComboboxPrimitive.Separator\r\n data-slot=\"combobox-separator\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxGroupProps = ComboboxPrimitive.Group.Props\r\n\r\nfunction ComboboxGroup(props: ComboboxGroupProps) {\r\n return <ComboboxPrimitive.Group\r\n data-slot=\"combobox-group\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxGroupLabelProps = ComboboxPrimitive.GroupLabel.Props\r\n\r\nfunction ComboboxGroupLabel(props: ComboboxGroupLabelProps) {\r\n return <ComboboxPrimitive.GroupLabel\r\n data-slot=\"combobox-group-label\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxCollectionProps = ComboboxPrimitive.Collection.Props\r\n\r\nfunction ComboboxCollection(props: ComboboxCollectionProps) {\r\n return <ComboboxPrimitive.Collection\r\n data-slot=\"combobox-collection\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxArrowProps = ComboboxPrimitive.Arrow.Props\r\n\r\nfunction ComboboxArrow(props: ComboboxArrowProps) {\r\n return <ComboboxPrimitive.Arrow\r\n data-slot=\"combobox-arrow\"\r\n {...props}\r\n />\r\n}\r\n\r\nexport {\r\n Combobox,\r\n type ComboboxActiveValueContextType,\r\n ComboboxArrow,\r\n type ComboboxArrowProps,\r\n ComboboxBackdrop,\r\n type ComboboxBackdropProps,\r\n ComboboxChip,\r\n type ComboboxChipProps,\r\n ComboboxChipRemove,\r\n type ComboboxChipRemoveProps,\r\n ComboboxChips,\r\n type ComboboxChipsProps,\r\n ComboboxClear,\r\n type ComboboxClearProps,\r\n ComboboxCollection,\r\n type ComboboxCollectionProps,\r\n type ComboboxContextType,\r\n ComboboxEmpty,\r\n type ComboboxEmptyProps,\r\n ComboboxGroup,\r\n ComboboxGroupLabel,\r\n type ComboboxGroupLabelProps,\r\n type ComboboxGroupProps,\r\n ComboboxHighlight,\r\n ComboboxHighlightItem,\r\n type ComboboxHighlightItemProps,\r\n type ComboboxHighlightProps,\r\n ComboboxIcon,\r\n type ComboboxIconProps,\r\n ComboboxInput,\r\n ComboboxInputGroup,\r\n type ComboboxInputGroupProps,\r\n type ComboboxInputProps,\r\n ComboboxItem,\r\n ComboboxItemIndicator,\r\n type ComboboxItemIndicatorProps,\r\n type ComboboxItemProps,\r\n ComboboxLabel,\r\n type ComboboxLabelProps,\r\n ComboboxList,\r\n type ComboboxListProps,\r\n ComboboxPopup,\r\n type ComboboxPopupProps,\r\n ComboboxPortal,\r\n type ComboboxPortalProps,\r\n ComboboxPositioner,\r\n type ComboboxPositionerProps,\r\n type ComboboxProps,\r\n ComboboxRow,\r\n type ComboboxRowProps,\r\n ComboboxSeparator,\r\n type ComboboxSeparatorProps,\r\n ComboboxStatus,\r\n type ComboboxStatusProps,\r\n ComboboxTrigger,\r\n type ComboboxTriggerProps,\r\n ComboboxValue,\r\n type ComboboxValueProps,\r\n useCombobox,\r\n useComboboxActiveValue,\r\n}","import * as React from \"react\"\r\n\r\nimport {\r\n CheckCircle2Icon,\r\n Loader2Icon,\r\n SearchIcon,\r\n XIcon\r\n} from \"lucide-react\"\r\n\r\nimport {\r\n Combobox as ComboboxPrimitive,\r\n ComboboxArrow as ComboboxArrowPrimitive,\r\n type ComboboxArrowProps as ComboboxArrowPrimitiveProps,\r\n ComboboxBackdrop as ComboboxBackdropPrimitive,\r\n type ComboboxBackdropProps as ComboboxBackdropPrimitiveProps,\r\n ComboboxChip as ComboboxChipPrimitive,\r\n type ComboboxChipProps as ComboboxChipPrimitiveProps,\r\n ComboboxChipRemove as ComboboxChipRemovePrimitive,\r\n type ComboboxChipRemoveProps as ComboboxChipRemovePrimitiveProps,\r\n ComboboxChips as ComboboxChipsPrimitive,\r\n type ComboboxChipsProps as ComboboxChipsPrimitiveProps,\r\n ComboboxClear as ComboboxClearPrimitive,\r\n type ComboboxClearProps as ComboboxClearPrimitiveProps,\r\n ComboboxCollection as ComboboxCollectionPrimitive,\r\n type ComboboxCollectionProps as ComboboxCollectionPrimitiveProps,\r\n ComboboxEmpty as ComboboxEmptyPrimitive,\r\n type ComboboxEmptyProps as ComboboxEmptyPrimitiveProps,\r\n ComboboxGroup as ComboboxGroupPrimitive,\r\n ComboboxGroupLabel as ComboboxGroupLabelPrimitive,\r\n type ComboboxGroupLabelProps as ComboboxGroupLabelPrimitiveProps,\r\n type ComboboxGroupProps as ComboboxGroupPrimitiveProps,\r\n ComboboxHighlight as ComboboxHighlightPrimitive,\r\n ComboboxHighlightItem as ComboboxHighlightItemPrimitive,\r\n type ComboboxHighlightItemProps as ComboboxHighlightItemPrimitiveProps,\r\n type ComboboxHighlightProps as ComboboxHighlightPrimitiveProps,\r\n ComboboxIcon as ComboboxIconPrimitive,\r\n type ComboboxIconProps as ComboboxIconPrimitiveProps,\r\n ComboboxInput as ComboboxInputPrimitive,\r\n ComboboxInputGroup as ComboboxInputGroupPrimitive,\r\n type ComboboxInputGroupProps as ComboboxInputGroupPrimitiveProps,\r\n type ComboboxInputProps as ComboboxInputPrimitiveProps,\r\n ComboboxItem as ComboboxItemPrimitive,\r\n ComboboxItemIndicator as ComboboxItemIndicatorPrimitive,\r\n type ComboboxItemIndicatorProps as ComboboxItemIndicatorPrimitiveProps,\r\n type ComboboxItemProps as ComboboxItemPrimitiveProps,\r\n ComboboxLabel as ComboboxLabelPrimitive,\r\n type ComboboxLabelProps as ComboboxLabelPrimitiveProps,\r\n ComboboxList as ComboboxListPrimitive,\r\n type ComboboxListProps as ComboboxListPrimitiveProps,\r\n ComboboxPopup as ComboboxPopupPrimitive,\r\n type ComboboxPopupProps as ComboboxPopupPrimitiveProps,\r\n ComboboxPortal as ComboboxPortalPrimitive,\r\n type ComboboxPortalProps as ComboboxPortalPrimitiveProps,\r\n ComboboxPositioner as ComboboxPositionerPrimitive,\r\n type ComboboxPositionerProps as ComboboxPositionerPrimitiveProps,\r\n type ComboboxProps as ComboboxPrimitiveProps,\r\n ComboboxRow as ComboboxRowPrimitive,\r\n type ComboboxRowProps as ComboboxRowPrimitiveProps,\r\n ComboboxSeparator as ComboboxSeparatorPrimitive,\r\n type ComboboxSeparatorProps as ComboboxSeparatorPrimitiveProps,\r\n ComboboxStatus as ComboboxStatusPrimitive,\r\n type ComboboxStatusProps as ComboboxStatusPrimitiveProps,\r\n ComboboxTrigger as ComboboxTriggerPrimitive,\r\n type ComboboxTriggerProps as ComboboxTriggerPrimitiveProps,\r\n ComboboxValue as ComboboxValuePrimitive,\r\n type ComboboxValueProps as ComboboxValuePrimitiveProps,\r\n useCombobox,\r\n} from \"../primitives/combobox\"\r\nimport { cn } from \"@xploreu/lib/cn\"\r\n\r\nimport { Badge, BadgeButton } from \"./badge\"\r\nimport { InfiniteScroll } from \"./infinite-scroll\"\r\nimport { Input, inputVariants } from \"./input\"\r\nimport { Checkbox } from \"./checkbox\"\r\n\r\ntype ComboboxProps<Value, Multiple extends boolean | undefined = false> = ComboboxPrimitiveProps<Value, Multiple>\r\n\r\nfunction Combobox<Value, Multiple extends boolean | undefined = false>(props: ComboboxProps<Value, Multiple>) {\r\n return (\r\n <ComboboxPrimitive {...props} />\r\n )\r\n}\r\n\r\ntype ComboboxTriggerProps = ComboboxTriggerPrimitiveProps\r\n\r\nfunction ComboboxTrigger(props: ComboboxTriggerProps) {\r\n const { className, ...rest } = props\r\n\r\n return <ComboboxTriggerPrimitive\r\n className={cn(\r\n \"group/combobox-trigger flex items-center gap-2\",\r\n className,\r\n )}\r\n {...rest}\r\n />\r\n}\r\n\r\ntype ComboboxLabelProps = ComboboxLabelPrimitiveProps\r\n\r\nfunction ComboboxLabel(props: ComboboxLabelProps) {\r\n const { className, ...rest } = props\r\n\r\n return <ComboboxLabelPrimitive\r\n className={cn(\r\n \"text-label-semibold-2 text-text-secondary\",\r\n className,\r\n )}\r\n {...rest}\r\n />\r\n}\r\n\r\ntype ComboboxInputGroupProps = ComboboxInputGroupPrimitiveProps\r\n\r\nfunction ComboboxInputGroup(props: ComboboxInputGroupProps) {\r\n const { className, ...rest } = props\r\n\r\n return <ComboboxInputGroupPrimitive\r\n className={cn(\r\n \"flex w-full items-center gap-2\",\r\n className,\r\n )}\r\n {...rest}\r\n />\r\n}\r\n\r\ntype ComboboxInputProps = ComboboxInputPrimitiveProps & {\r\n wrapperClassName?: string\r\n}\r\n\r\nfunction ComboboxInput({\r\n className,\r\n wrapperClassName,\r\n ...props\r\n}: ComboboxInputProps) {\r\n\r\n return (\r\n <div className={cn(\"px-3 py-2.5 border-b border-border-primary\", wrapperClassName)}>\r\n <ComboboxInputPrimitive\r\n className={className}\r\n render={<Input size=\"sm\" startContent={<SearchIcon />} />}\r\n {...props}\r\n />\r\n </div>\r\n )\r\n}\r\n\r\nfunction ComboboxInputFilter({\r\n className,\r\n displayValueKey = { label: \"label\", value: \"value\" },\r\n placeholder = \"Search and Select Company\",\r\n inputProps,\r\n ...props\r\n}: ComboboxInputProps & {\r\n displayValueKey?: {\r\n label: string\r\n value: string\r\n }\r\n placeholder?: string\r\n inputProps?: React.ComponentProps<typeof Input>\r\n}) {\r\n const { inputValue, setInputValue } = useCombobox()\r\n const { className: inputClassName, startContent, ...restInputProps } = inputProps || {}\r\n\r\n return (\r\n <div className={cn(\"flex flex-col gap-2\", className)}>\r\n <ComboboxChips\r\n onMouseDown={(e) => e.preventBaseUIHandler()}\r\n className=\"flex-col\"\r\n >\r\n <ComboboxInputPrimitive\r\n render={\r\n <Input\r\n className={cn(\"h-9 text-body-regular-3 pl-9 pr-7\", inputClassName)}\r\n endContent={\r\n <ComboboxTrigger\r\n nativeButton={false}\r\n render={(\r\n <XIcon\r\n className=\"!size-5 !right-1.5 data-[hidden=true]:opacity-0 opacity-100 transition-opacity duration-300 cursor-pointer\"\r\n data-hidden={!inputValue}\r\n data-slot=\"combobox-clear-input\"\r\n onClick={(event) => {\r\n setInputValue(\"\", {\r\n reason: \"none\",\r\n event: event.nativeEvent,\r\n cancel: () => { },\r\n allowPropagation: () => { },\r\n isCanceled: false,\r\n isPropagationAllowed: true,\r\n trigger: undefined,\r\n })\r\n }}\r\n />\r\n )}\r\n />\r\n }\r\n placeholder={placeholder}\r\n startContent={startContent ?? <SearchIcon className=\"!size-4 !text-fg-tertiary-hover\" />}\r\n {...restInputProps}\r\n />\r\n }\r\n {...props}\r\n />\r\n <ComboboxValue>\r\n {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}\r\n {(value) => value?.map((item: any) => (\r\n <ComboboxChip key={item?.[displayValueKey.value] || \"\"}>\r\n {item?.[displayValueKey.label] || \"\"}\r\n <ComboboxChipRemove />\r\n </ComboboxChip>\r\n ))}\r\n </ComboboxValue>\r\n </ComboboxChips>\r\n </div>\r\n )\r\n}\r\n\r\ntype ComboboxIconProps = ComboboxIconPrimitiveProps\r\n\r\nfunction ComboboxIcon(props: ComboboxIconProps) {\r\n const { className, ...rest } = props\r\n\r\n return <ComboboxIconPrimitive\r\n className={cn(\"text-text-secondary\", className)}\r\n {...rest}\r\n />\r\n}\r\n\r\ntype ComboboxClearProps = ComboboxClearPrimitiveProps\r\n\r\nfunction ComboboxClear(props: ComboboxClearProps) {\r\n\r\n return (\r\n <ComboboxClearPrimitive\r\n render={<XIcon />}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxValueProps = ComboboxValuePrimitiveProps\r\n\r\nfunction ComboboxValue(props: ComboboxValueProps) {\r\n return <ComboboxValuePrimitive {...props} />\r\n}\r\n\r\ntype ComboboxChipsProps = ComboboxChipsPrimitiveProps\r\n\r\nfunction ComboboxChips({\r\n className,\r\n ...props\r\n}: ComboboxChipsProps) {\r\n return <ComboboxChipsPrimitive\r\n className={cn(\"flex flex-wrap gap-2\", className)}\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxChipProps = ComboboxChipPrimitiveProps\r\n\r\nfunction ComboboxChip({\r\n className,\r\n ...props\r\n}: ComboboxChipProps) {\r\n return (\r\n <Badge\r\n className={cn(\"ring-1 ring-border-brand text-body-medium-3\", className)}\r\n color=\"brand\"\r\n render={(\r\n <ComboboxChipPrimitive\r\n {...props}\r\n />\r\n )}\r\n size=\"lg\"\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxChipRemoveProps = ComboboxChipRemovePrimitiveProps\r\n\r\nfunction ComboboxChipRemove({\r\n className,\r\n ...props\r\n}: ComboboxChipRemoveProps) {\r\n return (\r\n <BadgeButton\r\n className={cn(\"text-fg-quaternary\", className)}\r\n render={(\r\n <ComboboxChipRemovePrimitive\r\n {...props}\r\n />\r\n )}\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxPopupProps = ComboboxPositionerPrimitiveProps &\r\n ComboboxPopupPrimitiveProps & {\r\n container?: React.ComponentProps<typeof ComboboxPortal>[\"container\"]\r\n }\r\n\r\nfunction ComboboxPopup({\r\n className,\r\n align = \"start\",\r\n sideOffset = 4,\r\n container,\r\n initialFocus,\r\n finalFocus,\r\n style,\r\n children,\r\n ...props\r\n}: ComboboxPopupProps) {\r\n return (\r\n <ComboboxPortalPrimitive container={container}>\r\n <ComboboxPositionerPrimitive\r\n align={align}\r\n className=\"isolate z-50\"\r\n sideOffset={sideOffset}\r\n {...props}\r\n >\r\n <ComboboxPopupPrimitive\r\n className={cn(\r\n \"group/combobox-popup bg-bg-primary text-text-primary max-h-(--available-height) w-72 max-w-(--available-width) origin-(--transform-origin) rounded-md border border-border-primary shadow-md outline-hidden\",\r\n className,\r\n )}\r\n finalFocus={finalFocus}\r\n initialFocus={initialFocus}\r\n style={style}\r\n >\r\n <ComboboxHighlight>\r\n {children}\r\n </ComboboxHighlight>\r\n </ComboboxPopupPrimitive>\r\n </ComboboxPositionerPrimitive>\r\n </ComboboxPortalPrimitive>\r\n )\r\n}\r\n\r\ntype ComboboxPortalProps = ComboboxPortalPrimitiveProps\r\n\r\nfunction ComboboxPortal(props: ComboboxPortalProps) {\r\n return <ComboboxPortalPrimitive {...props} />\r\n}\r\n\r\ntype ComboboxPositionerProps = ComboboxPositionerPrimitiveProps\r\n\r\nfunction ComboboxPositioner(props: ComboboxPositionerProps) {\r\n return <ComboboxPositionerPrimitive {...props} />\r\n}\r\n\r\ntype ComboboxBackdropProps = ComboboxBackdropPrimitiveProps\r\n\r\nfunction ComboboxBackdrop(props: ComboboxBackdropProps) {\r\n const { className, ...rest } = props\r\n\r\n return <ComboboxBackdropPrimitive\r\n className={cn(\"bg-black/30\", className)}\r\n {...rest}\r\n />\r\n}\r\n\r\ntype ComboboxStatusProps = ComboboxStatusPrimitiveProps\r\n\r\nfunction ComboboxStatus({\r\n className,\r\n status,\r\n ...props\r\n}: Omit<ComboboxStatusProps, \"children\"> & {\r\n status?: \"empty\" | \"pending\" | null\r\n}) {\r\n const { inputValue } = useCombobox()\r\n\r\n const trimmedInputValue = inputValue?.toString().trim()\r\n\r\n const getText = () => {\r\n if (status === \"empty\" && trimmedInputValue)\r\n return `No matches for \"${trimmedInputValue}\".`\r\n\r\n if (status === \"empty\" && !trimmedInputValue)\r\n return \"No results.\"\r\n\r\n if (status === \"pending\")\r\n return (\r\n <>\r\n <Loader2Icon className=\"animate-spin size-4\" />\r\n <span>\r\n Searching...\r\n </span>\r\n </>\r\n )\r\n\r\n return null\r\n }\r\n\r\n const text = getText()\r\n\r\n return (\r\n <ComboboxStatusPrimitive\r\n className={cn(\r\n \"px-2 py-2.5 text-body-regular-2 text-text-disabled flex items-center gap-2\",\r\n !text && \"hidden\",\r\n className\r\n )}\r\n {...props}\r\n >\r\n {text}\r\n </ComboboxStatusPrimitive>\r\n )\r\n}\r\n\r\ntype ComboboxLoadingProps = React.ComponentProps<\"div\">\r\n\r\ntype ComboboxEmptyProps = ComboboxEmptyPrimitiveProps\r\n\r\nfunction ComboboxEmpty({ className, ...props }: ComboboxEmptyProps) {\r\n return <ComboboxEmptyPrimitive\r\n className={cn(\"px-3 py-2 text-body-regular-2 text-text-secondary\", className)}\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxListProps = ComboboxListPrimitiveProps\r\n\r\nfunction ComboboxList({\r\n className,\r\n ...props\r\n}: ComboboxListProps) {\r\n return (\r\n <ComboboxListPrimitive\r\n className={cn(\"max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] overflow-auto scrollbar-thin flex flex-col p-1 focus-visible:outline-none\", className)}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxHighlightProps = ComboboxHighlightPrimitiveProps\r\n\r\nfunction ComboboxHighlight(props: ComboboxHighlightProps) {\r\n const { className, ...rest } = props\r\n\r\n return (\r\n <ComboboxHighlightPrimitive\r\n className={cn(\"absolute inset-0 bg-bg-primary-hover\", className)}\r\n {...rest}\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxHighlightItemProps = ComboboxHighlightItemPrimitiveProps\r\n\r\nfunction ComboboxHighlightItem(props: ComboboxHighlightItemProps) {\r\n return <ComboboxHighlightItemPrimitive {...props} />\r\n}\r\n\r\ntype ComboboxRowProps = ComboboxRowPrimitiveProps\r\n\r\nfunction ComboboxRow(props: ComboboxRowProps) {\r\n const { className, ...rest } = props\r\n\r\n return <ComboboxRowPrimitive\r\n className={cn(\"group/combobox-row\", className)}\r\n {...rest}\r\n />\r\n}\r\n\r\ntype ComboboxItemProps = ComboboxItemPrimitiveProps & {\r\n indicator?: \"check-circle\" | \"checkbox\"\r\n}\r\n\r\nfunction ComboboxItem({\r\n className,\r\n children,\r\n indicator = \"check-circle\",\r\n ...props\r\n}: ComboboxItemProps) {\r\n const { disabled } = props\r\n\r\n return (\r\n <ComboboxHighlightItem\r\n activeClassName=\"bg-bg-primary-hover rounded-md\"\r\n disabled={disabled}\r\n >\r\n <ComboboxItemPrimitive\r\n data-indicator={indicator}\r\n className={cn(\r\n \"group/combobox-item relative flex w-full cursor-default items-center gap-xp-md my-px p-xp-md [[data-indicator=check-circle][data-selected]]:pr-8 data-[indicator=checkbox]:pl-8 outline-none\",\r\n className,\r\n )}\r\n {...props}\r\n >\r\n {children}\r\n <ComboboxItemIndicator\r\n className=\"absolute group-data-[indicator=check-circle]/combobox-item:right-2 group-data-[indicator=checkbox]/combobox-item:left-2\"\r\n keepMounted={indicator === \"checkbox\"}\r\n render={(props, state) => (\r\n <span {...props}>\r\n {indicator === \"check-circle\" && (\r\n <CheckCircle2Icon className=\"size-4 text-fg-brand-primary shrink-0\" />\r\n )}\r\n\r\n {indicator === \"checkbox\" && (\r\n <Checkbox checked={state.selected} />\r\n )}\r\n </span>\r\n )}\r\n />\r\n </ComboboxItemPrimitive>\r\n </ComboboxHighlightItem>\r\n )\r\n}\r\n\r\ntype ComboboxItemTitleProps = React.ComponentProps<\"span\">\r\n\r\nfunction ComboboxItemTitle({\r\n className,\r\n ...props\r\n}: ComboboxItemTitleProps) {\r\n return (\r\n <span\r\n className={cn(\r\n \"text-body-medium-3 text-text-primary truncate\",\r\n className\r\n )}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxItemDescriptionProps = React.ComponentProps<\"span\">\r\n\r\nfunction ComboboxItemDescription({\r\n className,\r\n ...props\r\n}: ComboboxItemDescriptionProps) {\r\n return (\r\n <span\r\n className={cn(\r\n \"text-body-regular-3 text-text-secondary truncate\",\r\n className\r\n )}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxItemIndicatorProps = ComboboxItemIndicatorPrimitiveProps\r\n\r\nfunction ComboboxItemIndicator(props: ComboboxItemIndicatorProps) {\r\n return (\r\n <ComboboxItemIndicatorPrimitive {...props} />\r\n )\r\n}\r\n\r\ntype ComboboxSeparatorProps = ComboboxSeparatorPrimitiveProps\r\n\r\nfunction ComboboxSeparator(props: ComboboxSeparatorProps) {\r\n const { className, ...rest } = props\r\n\r\n return <ComboboxSeparatorPrimitive\r\n className={cn(\"my-1 h-px bg-border-primary\", className)}\r\n {...rest}\r\n />\r\n}\r\n\r\ntype ComboboxGroupProps = ComboboxGroupPrimitiveProps\r\n\r\nfunction ComboboxGroup(props: ComboboxGroupProps) {\r\n const { className, ...rest } = props\r\n\r\n return <ComboboxGroupPrimitive\r\n className={cn(\"py-1\", className)}\r\n {...rest}\r\n />\r\n}\r\n\r\ntype ComboboxGroupLabelProps = ComboboxGroupLabelPrimitiveProps\r\n\r\nfunction ComboboxGroupLabel(props: ComboboxGroupLabelProps) {\r\n const { className, ...rest } = props\r\n\r\n return <ComboboxGroupLabelPrimitive\r\n className={cn(\"px-3 py-1 text-body-semibold-sm text-text-secondary\", className)}\r\n {...rest}\r\n />\r\n}\r\n\r\ntype ComboboxCollectionProps = ComboboxCollectionPrimitiveProps\r\n\r\nfunction ComboboxCollection(props: ComboboxCollectionProps) {\r\n return <ComboboxCollectionPrimitive {...props} />\r\n}\r\n\r\ntype ComboboxArrowProps = ComboboxArrowPrimitiveProps\r\n\r\nfunction ComboboxArrow(props: ComboboxArrowProps) {\r\n const { className, ...rest } = props\r\n\r\n return <ComboboxArrowPrimitive\r\n className={cn(\"fill-bg-primary\", className)}\r\n {...rest}\r\n />\r\n}\r\n\r\nfunction ComboboxInfiniteScroll({\r\n hasMore,\r\n threshold = 0.5,\r\n ...props\r\n}: Omit<React.ComponentProps<typeof InfiniteScroll>, \"children\">) {\r\n return (\r\n <InfiniteScroll\r\n hasMore={hasMore}\r\n threshold={threshold}\r\n {...props}\r\n >\r\n {hasMore && (\r\n <div className=\"px-2 py-2.5 text-body-regular-2 text-text-disabled flex items-center gap-2\">\r\n <Loader2Icon className=\"animate-spin size-4\" />\r\n <span>\r\n Loading more...\r\n </span>\r\n </div>\r\n )}\r\n </InfiniteScroll>\r\n )\r\n}\r\n\r\nexport {\r\n Combobox,\r\n ComboboxArrow,\r\n type ComboboxArrowProps,\r\n ComboboxBackdrop,\r\n type ComboboxBackdropProps,\r\n ComboboxChip,\r\n type ComboboxChipProps,\r\n ComboboxChipRemove,\r\n type ComboboxChipRemoveProps,\r\n ComboboxChips,\r\n type ComboboxChipsProps,\r\n ComboboxClear,\r\n type ComboboxClearProps,\r\n ComboboxCollection,\r\n type ComboboxCollectionProps,\r\n ComboboxPopup,\r\n type ComboboxPopupProps,\r\n ComboboxEmpty,\r\n type ComboboxEmptyProps,\r\n ComboboxGroup,\r\n ComboboxGroupLabel,\r\n type ComboboxGroupLabelProps,\r\n type ComboboxGroupProps,\r\n ComboboxHighlight,\r\n ComboboxHighlightItem,\r\n type ComboboxHighlightItemProps,\r\n type ComboboxHighlightProps,\r\n ComboboxIcon,\r\n type ComboboxIconProps,\r\n ComboboxInfiniteScroll,\r\n ComboboxInput,\r\n ComboboxInputFilter,\r\n ComboboxInputGroup,\r\n type ComboboxInputGroupProps,\r\n type ComboboxInputProps,\r\n ComboboxItem,\r\n ComboboxItemTitle,\r\n type ComboboxItemTitleProps,\r\n ComboboxItemDescription,\r\n type ComboboxItemDescriptionProps,\r\n ComboboxItemIndicator,\r\n type ComboboxItemIndicatorProps,\r\n type ComboboxItemProps,\r\n ComboboxLabel,\r\n type ComboboxLabelProps,\r\n ComboboxList,\r\n type ComboboxListProps,\r\n type ComboboxLoadingProps,\r\n ComboboxPortal,\r\n type ComboboxPortalProps,\r\n ComboboxPositioner,\r\n type ComboboxPositionerProps,\r\n type ComboboxProps,\r\n ComboboxRow,\r\n type ComboboxRowProps,\r\n ComboboxSeparator,\r\n type ComboboxSeparatorProps,\r\n ComboboxStatus,\r\n type ComboboxStatusProps,\r\n ComboboxTrigger,\r\n type ComboboxTriggerProps,\r\n ComboboxValue,\r\n type ComboboxValueProps\r\n}"]}
@@ -0,0 +1,2 @@
1
+ import {c,d as d$1,o,g,s,u,y}from'./chunk-NVQMVFSP.js';import {a}from'./chunk-JH6RZ3QH.js';import*as t from'react';import*as C from'react-phone-number-input';import Y from'react-phone-number-input/flags';import {cn}from'@xploreu/lib/cn';import'@base-ui/react/combobox';import {ChevronsUpDownIcon}from'lucide-react';import {jsx,jsxs}from'react/jsx-runtime';var R=({country:l,countryName:o})=>{let s=l?Y[l]:void 0;return jsx("span",{className:"flex h-4 w-6 shrink-0 overflow-hidden rounded-sm bg-fg-quaternary/20 [&_svg:not([class*='size-'])]:size-full",children:s&&jsx(s,{title:o})})},d=44,k=288,H=6;function D({disabled:l,value:o$1,options:s$1,onChange:i}){let[c$1,r]=t.useState(false),[b,g$1]=t.useState(""),[y$1,N]=t.useState(0),v=t.useRef(null),m=t.useMemo(()=>s$1.filter(e=>!!e.value),[s$1]),u$1=t.useMemo(()=>{let e=b.trim().toLowerCase();return e?m.filter(a=>{let f=C.getCountryCallingCode(a.value);return a.label.toLowerCase().includes(e)||a.value.toLowerCase().includes(e)||f.includes(e.replace(/^\+/,""))}):m},[b,m]),_=t.useMemo(()=>m.find(e=>e.value===o$1)??null,[m,o$1]);t.useEffect(()=>{N(0),v.current&&(v.current.scrollTop=0);},[b]);let z=Math.min(u$1.length*d,k),h=t.useMemo(()=>{let e=Math.floor(y$1/d),a=Math.max(0,e-H),f=Math.ceil(k/d),P=Math.min(u$1.length,e+f+H);return {startIndex:a,endIndex:P,items:u$1.slice(a,P)}},[u$1,y$1]),F=h.startIndex*d,U=Math.max(0,(u$1.length-h.endIndex)*d),q=t.useCallback(e=>{e?.value&&(i(e.value),g$1(""),r(false));},[i]);return jsxs(c,{behavior:"default",disabled:l,inputValue:b,items:u$1,open:c$1,value:_,virtualized:true,filter:null,isItemEqualToValue:(e,a)=>e.value===a.value,openOnInputClick:false,onValueChange:q,onInputValueChange:g$1,onOpenChange:e=>{r(e),e||g$1("");},children:[jsx(d$1,{render:jsxs("button",{type:"button",className:cn(a(),"h-11 w-18 shrink-0 justify-between gap-1 rounded-r-none border-r-0 px-3","hover:bg-bg-primary-hover focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand","disabled:pointer-events-none disabled:opacity-50"),disabled:l,children:[jsxs("span",{className:"flex items-center gap-1.5 overflow-hidden",children:[jsx(R,{country:o$1,countryName:o$1}),o$1&&jsx("span",{className:"text-body-medium-3 text-text-primary",children:o$1})]}),jsx(ChevronsUpDownIcon,{className:"size-3.5 shrink-0 text-fg-quaternary"})]})}),jsxs(o,{className:"w-72",children:[jsx(g,{placeholder:"Search country...","aria-label":"Search country"}),jsx(s,{status:u$1.length===0?"empty":null}),jsx(u,{ref:v,className:"relative gap-0",style:{height:z},onScroll:e=>N(e.currentTarget.scrollTop),children:jsx("div",{className:"flex w-full shrink-0 flex-col",style:{paddingTop:F,paddingBottom:U},children:h.items.map((e,a)=>{let f=h.startIndex+a;return jsx(y,{index:f,value:e,children:jsxs("div",{className:"flex items-center gap-2 w-full min-w-0",children:[jsx(R,{country:e.value,countryName:e.label}),jsx("span",{className:"flex-1 text-sm truncate",children:e.label}),jsxs("span",{className:"text-sm text-text-tertiary shrink-0",children:["+",C.getCountryCallingCode(e.value)]})]})},e.value)})})})]})]})}var L=t.forwardRef(({className:l,onChange:o,...s},i)=>{let c=t.useCallback(r=>{r.currentTarget.value==="+"&&(r.currentTarget.value=""),o?.(r);},[o]);return jsx("input",{className:cn(a(),"h-11 flex-1 rounded-l-none text-body-regular-2",l),ref:i,type:"tel",onChange:c,...s})});L.displayName="InputComponent";var G=t.forwardRef(({className:l,onChange:o,value:s,...i},c)=>jsx(C.default,{ref:c,className:cn("flex w-full min-w-0 items-center",l),flagComponent:R,countrySelectComponent:D,inputComponent:L,smartCaret:false,value:s||void 0,onChange:r=>o?.(r||""),...i}));G.displayName="PhoneInput";export{G as a};//# sourceMappingURL=chunk-RBTN73H3.js.map
2
+ //# sourceMappingURL=chunk-RBTN73H3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/composites/phone-input.tsx"],"names":["FlagComponent","country","countryName","Flag","flags","jsx","COUNTRY_ROW_HEIGHT","COUNTRY_LIST_HEIGHT","COUNTRY_OVERSCAN","CountrySelect","disabled","selectedCountry","countryList","onChange","open","setOpen","inputValue","setInputValue","scrollTop","setScrollTop","listRef","items","item","filteredItems","search","callingCode","value","listHeight","virtualRange","visibleStartIndex","startIndex","visibleCount","endIndex","paddingTop","paddingBottom","handleValueChange","jsxs","Combobox","a","b","ComboboxTrigger","cn","inputVariants","ChevronsUpDownIcon","ComboboxPopup","ComboboxInput","ComboboxStatus","ComboboxList","event","virtualIndex","index","ComboboxItem","InputComponent","className","props","ref","handleChange","PhoneInput"],"mappings":"2WAoCA,IAAMA,EAAgB,CAAC,CAAE,OAAA,CAAAC,CAAAA,CAAS,YAAAC,CAAY,CAAA,GAA0B,CACtE,IAAMC,EAAOF,CAAAA,CAAUG,CAAAA,CAAMH,CAAO,CAAA,CAAI,MAAA,CAExC,OACEI,GAAAA,CAAC,MAAA,CAAA,CAAK,UAAU,8GAAA,CACb,QAAA,CAAAF,CAAAA,EAAQE,GAAAA,CAACF,EAAA,CAAK,KAAA,CAAOD,CAAAA,CAAa,CAAA,CACrC,CAEJ,CAAA,CASMI,CAAAA,CAAqB,EAAA,CACrBC,CAAAA,CAAsB,IACtBC,CAAAA,CAAmB,CAAA,CASzB,SAASC,CAAAA,CAAc,CACrB,QAAA,CAAAC,CAAAA,CACA,KAAA,CAAOC,CAAAA,CACP,QAASC,CAAAA,CACT,QAAA,CAAAC,CACF,CAAA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,CAAAA,CAAW,SAAAxC,CAAAA,CAAU,GAAGyC,CAAM,CAAA,CAAGC,IAAQ,CAC5C,IAAMC,CAAAA,CAAqB,CAAA,CAAA,WAAA,CACxBR,GAA+C,CAC1CA,CAAAA,CAAM,aAAA,CAAc,KAAA,GAAU,MAChCA,CAAAA,CAAM,aAAA,CAAc,KAAA,CAAQ,EAAA,CAAA,CAG9BnC,IAAWmC,CAAK,EAClB,CAAA,CACA,CAACnC,CAAQ,CACX,CAAA,CAEA,OACER,IAAC,OAAA,CAAA,CACC,SAAA,CAAWoC,EAAAA,CACTC,CAAAA,GACA,gDAAA,CACAW,CACF,CAAA,CACA,GAAA,CAAKE,EACL,IAAA,CAAK,KAAA,CACL,QAAA,CAAUC,CAAAA,CACT,GAAGF,CAAAA,CACN,CAEJ,CAAC,CAAA,CACDF,EAAe,WAAA,CAAc,gBAAA,CAM7B,IAAMK,CAAAA,CACE,aAGJ,CAAC,CACD,SAAA,CAAAJ,CAAAA,CACA,SAAAxC,CAAAA,CACA,KAAA,CAAAa,CAAAA,CACA,GAAG4B,CACL,CAAA,CAAGC,CAAAA,GAEClD,GAAAA,CAAU,UAAT,CACC,GAAA,CAAKkD,CAAAA,CACL,SAAA,CAAWd,GACT,kCAAA,CACAY,CACF,CAAA,CACA,aAAA,CAAerD,EACf,sBAAA,CAAwBS,CAAAA,CACxB,cAAA,CAAgB2C,CAAAA,CAChB,WAAY,KAAA,CACZ,KAAA,CAAO1B,CAAAA,EAAS,MAAA,CAChB,SAAWA,CAAAA,EAAUb,CAAAA,GAAWa,CAAAA,EAAU,EAAqB,EAC9D,GAAG4B,CAAAA,CACN,CAEH,EACHG,EAAW,WAAA,CAAc,YAAA","file":"chunk-QV2OO65X.js","sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\nimport * as RPNInput from \"react-phone-number-input\"\r\nimport flags from \"react-phone-number-input/flags\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport { Combobox as ComboboxPrimitive } from \"@base-ui/react/combobox\"\r\nimport {\r\n Combobox,\r\n ComboboxInput,\r\n ComboboxItem,\r\n ComboboxList,\r\n ComboboxPopup,\r\n ComboboxStatus,\r\n ComboboxTrigger,\r\n} from \"../ui/combobox\"\r\nimport { inputVariants } from \"../ui/input\"\r\nimport { ChevronsUpDownIcon } from \"lucide-react\"\r\n\r\n// ---------------------------------------------------------------------------\r\n// Types\r\n// ---------------------------------------------------------------------------\r\n\r\ntype PhoneInputProps = Omit<\r\n React.ComponentProps<\"input\">,\r\n \"onChange\" | \"value\" | \"ref\"\r\n> &\r\n Omit<RPNInput.Props<typeof RPNInput.default>, \"onChange\"> & {\r\n onChange?: (value: RPNInput.Value) => void\r\n }\r\n\r\n// ---------------------------------------------------------------------------\r\n// Flag\r\n// ---------------------------------------------------------------------------\r\n\r\nconst FlagComponent = ({ country, countryName }: RPNInput.FlagProps) => {\r\n const Flag = country ? flags[country] : undefined\r\n\r\n return (\r\n <span className=\"flex h-4 w-6 shrink-0 overflow-hidden rounded-sm bg-fg-quaternary/20 [&_svg:not([class*='size-'])]:size-full\">\r\n {Flag && <Flag title={countryName} />}\r\n </span>\r\n )\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// Country Select — uses base-ui Combobox\r\n// ---------------------------------------------------------------------------\r\n\r\ntype CountryEntry = { label: string; value: RPNInput.Country | undefined }\r\ntype CountryItem = { label: string; value: RPNInput.Country }\r\n\r\nconst COUNTRY_ROW_HEIGHT = 44\r\nconst COUNTRY_LIST_HEIGHT = 288\r\nconst COUNTRY_OVERSCAN = 6\r\n\r\ntype CountrySelectProps = {\r\n disabled?: boolean\r\n value: RPNInput.Country\r\n options: CountryEntry[]\r\n onChange: (country: RPNInput.Country) => void\r\n}\r\n\r\nfunction CountrySelect({\r\n disabled,\r\n value: selectedCountry,\r\n options: countryList,\r\n onChange,\r\n}: CountrySelectProps) {\r\n const [open, setOpen] = React.useState(false)\r\n const [inputValue, setInputValue] = React.useState(\"\")\r\n const [scrollTop, setScrollTop] = React.useState(0)\r\n const listRef = React.useRef<HTMLDivElement>(null)\r\n\r\n const items = React.useMemo(\r\n () => countryList.filter((item): item is CountryItem => Boolean(item.value)),\r\n [countryList]\r\n )\r\n\r\n const filteredItems = React.useMemo(() => {\r\n const search = inputValue.trim().toLowerCase()\r\n\r\n if (!search) return items\r\n\r\n return items.filter((item) => {\r\n const callingCode = RPNInput.getCountryCallingCode(item.value)\r\n\r\n return item.label.toLowerCase().includes(search)\r\n || item.value.toLowerCase().includes(search)\r\n || callingCode.includes(search.replace(/^\\+/, \"\"))\r\n })\r\n }, [inputValue, items])\r\n\r\n const value = React.useMemo(\r\n () => items.find((item) => item.value === selectedCountry) ?? null,\r\n [items, selectedCountry]\r\n )\r\n\r\n React.useEffect(() => {\r\n setScrollTop(0)\r\n if (listRef.current) listRef.current.scrollTop = 0\r\n }, [inputValue])\r\n\r\n const listHeight = Math.min(\r\n filteredItems.length * COUNTRY_ROW_HEIGHT,\r\n COUNTRY_LIST_HEIGHT\r\n )\r\n\r\n const virtualRange = React.useMemo(() => {\r\n const visibleStartIndex = Math.floor(scrollTop / COUNTRY_ROW_HEIGHT)\r\n const startIndex = Math.max(\r\n 0,\r\n visibleStartIndex - COUNTRY_OVERSCAN\r\n )\r\n const visibleCount = Math.ceil(COUNTRY_LIST_HEIGHT / COUNTRY_ROW_HEIGHT)\r\n const endIndex = Math.min(\r\n filteredItems.length,\r\n visibleStartIndex + visibleCount + COUNTRY_OVERSCAN\r\n )\r\n\r\n return {\r\n startIndex,\r\n endIndex,\r\n items: filteredItems.slice(startIndex, endIndex),\r\n }\r\n }, [filteredItems, scrollTop])\r\n\r\n const paddingTop = virtualRange.startIndex * COUNTRY_ROW_HEIGHT\r\n const paddingBottom = Math.max(\r\n 0,\r\n (filteredItems.length - virtualRange.endIndex) * COUNTRY_ROW_HEIGHT\r\n )\r\n\r\n const handleValueChange = React.useCallback(\r\n (item: CountryItem | null) => {\r\n if (!item?.value) return\r\n\r\n onChange(item.value)\r\n setInputValue(\"\")\r\n setOpen(false)\r\n },\r\n [onChange]\r\n )\r\n\r\n return (\r\n <Combobox\r\n behavior=\"default\"\r\n disabled={disabled}\r\n inputValue={inputValue}\r\n items={filteredItems}\r\n open={open}\r\n value={value}\r\n virtualized\r\n filter={null}\r\n isItemEqualToValue={(a, b) => a.value === b.value}\r\n openOnInputClick={false}\r\n onValueChange={handleValueChange}\r\n onInputValueChange={setInputValue}\r\n onOpenChange={(open) => {\r\n setOpen(open)\r\n if (!open) setInputValue(\"\")\r\n }}\r\n >\r\n {/* Visible trigger button styled as part of the input */}\r\n <ComboboxTrigger\r\n render={\r\n <button\r\n type=\"button\"\r\n className={cn(\r\n inputVariants(),\r\n \"h-11 w-18 shrink-0 justify-between gap-1 rounded-r-none border-r-0 px-3\",\r\n \"hover:bg-bg-primary-hover focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand\",\r\n \"disabled:pointer-events-none disabled:opacity-50\"\r\n )}\r\n disabled={disabled}\r\n >\r\n <span className=\"flex items-center gap-1.5 overflow-hidden\">\r\n <FlagComponent\r\n country={selectedCountry}\r\n countryName={selectedCountry}\r\n />\r\n {selectedCountry && (\r\n <span className=\"text-body-medium-3 text-text-primary\">\r\n {selectedCountry}\r\n </span>\r\n )}\r\n </span>\r\n <ChevronsUpDownIcon className=\"size-3.5 shrink-0 text-fg-quaternary\" />\r\n </button>\r\n }\r\n />\r\n\r\n {/* Dropdown content */}\r\n <ComboboxPopup className=\"w-72\">\r\n <ComboboxInput\r\n placeholder=\"Search country...\"\r\n aria-label=\"Search country\"\r\n />\r\n <ComboboxStatus status={filteredItems.length === 0 ? \"empty\" : null} />\r\n <ComboboxList\r\n ref={listRef}\r\n className=\"relative gap-0\"\r\n style={{ height: listHeight }}\r\n onScroll={(event) => setScrollTop(event.currentTarget.scrollTop)}\r\n >\r\n <div\r\n className=\"flex w-full shrink-0 flex-col\"\r\n style={{ paddingTop, paddingBottom }}\r\n >\r\n {virtualRange.items.map((item, virtualIndex) => {\r\n const index = virtualRange.startIndex + virtualIndex\r\n\r\n return (\r\n <ComboboxItem\r\n key={item.value}\r\n index={index}\r\n value={item}\r\n >\r\n <div className=\"flex items-center gap-2 w-full min-w-0\">\r\n <FlagComponent country={item.value} countryName={item.label} />\r\n <span className=\"flex-1 text-sm truncate\">{item.label}</span>\r\n <span className=\"text-sm text-text-tertiary shrink-0\">\r\n +{RPNInput.getCountryCallingCode(item.value)}\r\n </span>\r\n </div>\r\n </ComboboxItem>\r\n )\r\n })}\r\n </div>\r\n </ComboboxList>\r\n </ComboboxPopup>\r\n </Combobox >\r\n )\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// Input Component\r\n// ---------------------------------------------------------------------------\r\n\r\nconst InputComponent = React.forwardRef<\r\n HTMLInputElement,\r\n React.ComponentProps<\"input\">\r\n>(({ className, onChange, ...props }, ref) => {\r\n const handleChange = React.useCallback(\r\n (event: React.ChangeEvent<HTMLInputElement>) => {\r\n if (event.currentTarget.value === \"+\") {\r\n event.currentTarget.value = \"\"\r\n }\r\n\r\n onChange?.(event)\r\n },\r\n [onChange]\r\n )\r\n\r\n return (\r\n <input\r\n className={cn(\r\n inputVariants(),\r\n \"h-11 flex-1 rounded-l-none text-body-regular-2\",\r\n className\r\n )}\r\n ref={ref}\r\n type=\"tel\"\r\n onChange={handleChange}\r\n {...props}\r\n />\r\n )\r\n})\r\nInputComponent.displayName = \"InputComponent\"\r\n\r\n// ---------------------------------------------------------------------------\r\n// Phone Input\r\n// ---------------------------------------------------------------------------\r\n\r\nconst PhoneInput: React.ForwardRefExoticComponent<PhoneInputProps> =\r\n React.forwardRef<\r\n React.ElementRef<typeof RPNInput.default>,\r\n PhoneInputProps\r\n >(({\r\n className,\r\n onChange,\r\n value,\r\n ...props\r\n }, ref) => {\r\n return (\r\n <RPNInput.default\r\n ref={ref}\r\n className={cn(\r\n \"flex w-full min-w-0 items-center\",\r\n className\r\n )}\r\n flagComponent={FlagComponent}\r\n countrySelectComponent={CountrySelect}\r\n inputComponent={InputComponent}\r\n smartCaret={false}\r\n value={value || undefined}\r\n onChange={(value) => onChange?.(value || (\"\" as RPNInput.Value))}\r\n {...props}\r\n />\r\n )\r\n })\r\nPhoneInput.displayName = \"PhoneInput\"\r\n\r\nexport { PhoneInput, type PhoneInputProps }\r\n"]}
1
+ {"version":3,"sources":["../src/composites/phone-input.tsx"],"names":["FlagComponent","country","countryName","Flag","flags","jsx","COUNTRY_ROW_HEIGHT","COUNTRY_LIST_HEIGHT","COUNTRY_OVERSCAN","CountrySelect","disabled","selectedCountry","countryList","onChange","open","setOpen","inputValue","setInputValue","scrollTop","setScrollTop","listRef","items","item","filteredItems","search","callingCode","value","listHeight","virtualRange","visibleStartIndex","startIndex","visibleCount","endIndex","paddingTop","paddingBottom","handleValueChange","jsxs","Combobox","a","b","ComboboxTrigger","cn","inputVariants","ChevronsUpDownIcon","ComboboxPopup","ComboboxInput","ComboboxStatus","ComboboxList","event","virtualIndex","index","ComboboxItem","InputComponent","className","props","ref","handleChange","PhoneInput"],"mappings":"oWAoCA,IAAMA,EAAgB,CAAC,CAAE,OAAA,CAAAC,CAAAA,CAAS,YAAAC,CAAY,CAAA,GAA0B,CACtE,IAAMC,EAAOF,CAAAA,CAAUG,CAAAA,CAAMH,CAAO,CAAA,CAAI,MAAA,CAExC,OACEI,GAAAA,CAAC,MAAA,CAAA,CAAK,UAAU,8GAAA,CACb,QAAA,CAAAF,CAAAA,EAAQE,GAAAA,CAACF,EAAA,CAAK,KAAA,CAAOD,CAAAA,CAAa,CAAA,CACrC,CAEJ,CAAA,CASMI,CAAAA,CAAqB,EAAA,CACrBC,CAAAA,CAAsB,IACtBC,CAAAA,CAAmB,CAAA,CASzB,SAASC,CAAAA,CAAc,CACrB,QAAA,CAAAC,CAAAA,CACA,KAAA,CAAOC,GAAAA,CACP,QAASC,GAAAA,CACT,QAAA,CAAAC,CACF,CAAA,CAAuB,CACrB,GAAM,CAACC,GAAAA,CAAM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AGyC,CAAM,CAAA,CAAGC,IAAQ,CAC5C,IAAMC,CAAAA,CAAqB,CAAA,CAAA,WAAA,CACxBR,GAA+C,CAC1CA,CAAAA,CAAM,aAAA,CAAc,KAAA,GAAU,MAChCA,CAAAA,CAAM,aAAA,CAAc,KAAA,CAAQ,EAAA,CAAA,CAG9BnC,IAAWmC,CAAK,EAClB,CAAA,CACA,CAACnC,CAAQ,CACX,CAAA,CAEA,OACER,IAAC,OAAA,CAAA,CACC,SAAA,CAAWoC,EAAAA,CACTC,CAAAA,GACA,gDAAA,CACAW,CACF,CAAA,CACA,GAAA,CAAKE,EACL,IAAA,CAAK,KAAA,CACL,QAAA,CAAUC,CAAAA,CACT,GAAGF,CAAAA,CACN,CAEJ,CAAC,CAAA,CACDF,EAAe,WAAA,CAAc,gBAAA,CAM7B,IAAMK,CAAAA,CACE,aAGJ,CAAC,CACD,SAAA,CAAAJ,CAAAA,CACA,SAAAxC,CAAAA,CACA,KAAA,CAAAa,CAAAA,CACA,GAAG4B,CACL,CAAA,CAAGC,CAAAA,GAEClD,GAAAA,CAAU,UAAT,CACC,GAAA,CAAKkD,CAAAA,CACL,SAAA,CAAWd,GACT,kCAAA,CACAY,CACF,CAAA,CACA,aAAA,CAAerD,EACf,sBAAA,CAAwBS,CAAAA,CACxB,cAAA,CAAgB2C,CAAAA,CAChB,WAAY,KAAA,CACZ,KAAA,CAAO1B,CAAAA,EAAS,MAAA,CAChB,SAAWA,CAAAA,EAAUb,CAAAA,GAAWa,CAAAA,EAAU,EAAqB,EAC9D,GAAG4B,CAAAA,CACN,CAEH,EACHG,EAAW,WAAA,CAAc,YAAA","file":"chunk-RBTN73H3.js","sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\nimport * as RPNInput from \"react-phone-number-input\"\r\nimport flags from \"react-phone-number-input/flags\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport { Combobox as ComboboxPrimitive } from \"@base-ui/react/combobox\"\r\nimport {\r\n Combobox,\r\n ComboboxInput,\r\n ComboboxItem,\r\n ComboboxList,\r\n ComboboxPopup,\r\n ComboboxStatus,\r\n ComboboxTrigger,\r\n} from \"../ui/combobox\"\r\nimport { inputVariants } from \"../ui/input\"\r\nimport { ChevronsUpDownIcon } from \"lucide-react\"\r\n\r\n// ---------------------------------------------------------------------------\r\n// Types\r\n// ---------------------------------------------------------------------------\r\n\r\ntype PhoneInputProps = Omit<\r\n React.ComponentProps<\"input\">,\r\n \"onChange\" | \"value\" | \"ref\"\r\n> &\r\n Omit<RPNInput.Props<typeof RPNInput.default>, \"onChange\"> & {\r\n onChange?: (value: RPNInput.Value) => void\r\n }\r\n\r\n// ---------------------------------------------------------------------------\r\n// Flag\r\n// ---------------------------------------------------------------------------\r\n\r\nconst FlagComponent = ({ country, countryName }: RPNInput.FlagProps) => {\r\n const Flag = country ? flags[country] : undefined\r\n\r\n return (\r\n <span className=\"flex h-4 w-6 shrink-0 overflow-hidden rounded-sm bg-fg-quaternary/20 [&_svg:not([class*='size-'])]:size-full\">\r\n {Flag && <Flag title={countryName} />}\r\n </span>\r\n )\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// Country Select — uses base-ui Combobox\r\n// ---------------------------------------------------------------------------\r\n\r\ntype CountryEntry = { label: string; value: RPNInput.Country | undefined }\r\ntype CountryItem = { label: string; value: RPNInput.Country }\r\n\r\nconst COUNTRY_ROW_HEIGHT = 44\r\nconst COUNTRY_LIST_HEIGHT = 288\r\nconst COUNTRY_OVERSCAN = 6\r\n\r\ntype CountrySelectProps = {\r\n disabled?: boolean\r\n value: RPNInput.Country\r\n options: CountryEntry[]\r\n onChange: (country: RPNInput.Country) => void\r\n}\r\n\r\nfunction CountrySelect({\r\n disabled,\r\n value: selectedCountry,\r\n options: countryList,\r\n onChange,\r\n}: CountrySelectProps) {\r\n const [open, setOpen] = React.useState(false)\r\n const [inputValue, setInputValue] = React.useState(\"\")\r\n const [scrollTop, setScrollTop] = React.useState(0)\r\n const listRef = React.useRef<HTMLDivElement>(null)\r\n\r\n const items = React.useMemo(\r\n () => countryList.filter((item): item is CountryItem => Boolean(item.value)),\r\n [countryList]\r\n )\r\n\r\n const filteredItems = React.useMemo(() => {\r\n const search = inputValue.trim().toLowerCase()\r\n\r\n if (!search) return items\r\n\r\n return items.filter((item) => {\r\n const callingCode = RPNInput.getCountryCallingCode(item.value)\r\n\r\n return item.label.toLowerCase().includes(search)\r\n || item.value.toLowerCase().includes(search)\r\n || callingCode.includes(search.replace(/^\\+/, \"\"))\r\n })\r\n }, [inputValue, items])\r\n\r\n const value = React.useMemo(\r\n () => items.find((item) => item.value === selectedCountry) ?? null,\r\n [items, selectedCountry]\r\n )\r\n\r\n React.useEffect(() => {\r\n setScrollTop(0)\r\n if (listRef.current) listRef.current.scrollTop = 0\r\n }, [inputValue])\r\n\r\n const listHeight = Math.min(\r\n filteredItems.length * COUNTRY_ROW_HEIGHT,\r\n COUNTRY_LIST_HEIGHT\r\n )\r\n\r\n const virtualRange = React.useMemo(() => {\r\n const visibleStartIndex = Math.floor(scrollTop / COUNTRY_ROW_HEIGHT)\r\n const startIndex = Math.max(\r\n 0,\r\n visibleStartIndex - COUNTRY_OVERSCAN\r\n )\r\n const visibleCount = Math.ceil(COUNTRY_LIST_HEIGHT / COUNTRY_ROW_HEIGHT)\r\n const endIndex = Math.min(\r\n filteredItems.length,\r\n visibleStartIndex + visibleCount + COUNTRY_OVERSCAN\r\n )\r\n\r\n return {\r\n startIndex,\r\n endIndex,\r\n items: filteredItems.slice(startIndex, endIndex),\r\n }\r\n }, [filteredItems, scrollTop])\r\n\r\n const paddingTop = virtualRange.startIndex * COUNTRY_ROW_HEIGHT\r\n const paddingBottom = Math.max(\r\n 0,\r\n (filteredItems.length - virtualRange.endIndex) * COUNTRY_ROW_HEIGHT\r\n )\r\n\r\n const handleValueChange = React.useCallback(\r\n (item: CountryItem | null) => {\r\n if (!item?.value) return\r\n\r\n onChange(item.value)\r\n setInputValue(\"\")\r\n setOpen(false)\r\n },\r\n [onChange]\r\n )\r\n\r\n return (\r\n <Combobox\r\n behavior=\"default\"\r\n disabled={disabled}\r\n inputValue={inputValue}\r\n items={filteredItems}\r\n open={open}\r\n value={value}\r\n virtualized\r\n filter={null}\r\n isItemEqualToValue={(a, b) => a.value === b.value}\r\n openOnInputClick={false}\r\n onValueChange={handleValueChange}\r\n onInputValueChange={setInputValue}\r\n onOpenChange={(open) => {\r\n setOpen(open)\r\n if (!open) setInputValue(\"\")\r\n }}\r\n >\r\n {/* Visible trigger button styled as part of the input */}\r\n <ComboboxTrigger\r\n render={\r\n <button\r\n type=\"button\"\r\n className={cn(\r\n inputVariants(),\r\n \"h-11 w-18 shrink-0 justify-between gap-1 rounded-r-none border-r-0 px-3\",\r\n \"hover:bg-bg-primary-hover focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand\",\r\n \"disabled:pointer-events-none disabled:opacity-50\"\r\n )}\r\n disabled={disabled}\r\n >\r\n <span className=\"flex items-center gap-1.5 overflow-hidden\">\r\n <FlagComponent\r\n country={selectedCountry}\r\n countryName={selectedCountry}\r\n />\r\n {selectedCountry && (\r\n <span className=\"text-body-medium-3 text-text-primary\">\r\n {selectedCountry}\r\n </span>\r\n )}\r\n </span>\r\n <ChevronsUpDownIcon className=\"size-3.5 shrink-0 text-fg-quaternary\" />\r\n </button>\r\n }\r\n />\r\n\r\n {/* Dropdown content */}\r\n <ComboboxPopup className=\"w-72\">\r\n <ComboboxInput\r\n placeholder=\"Search country...\"\r\n aria-label=\"Search country\"\r\n />\r\n <ComboboxStatus status={filteredItems.length === 0 ? \"empty\" : null} />\r\n <ComboboxList\r\n ref={listRef}\r\n className=\"relative gap-0\"\r\n style={{ height: listHeight }}\r\n onScroll={(event) => setScrollTop(event.currentTarget.scrollTop)}\r\n >\r\n <div\r\n className=\"flex w-full shrink-0 flex-col\"\r\n style={{ paddingTop, paddingBottom }}\r\n >\r\n {virtualRange.items.map((item, virtualIndex) => {\r\n const index = virtualRange.startIndex + virtualIndex\r\n\r\n return (\r\n <ComboboxItem\r\n key={item.value}\r\n index={index}\r\n value={item}\r\n >\r\n <div className=\"flex items-center gap-2 w-full min-w-0\">\r\n <FlagComponent country={item.value} countryName={item.label} />\r\n <span className=\"flex-1 text-sm truncate\">{item.label}</span>\r\n <span className=\"text-sm text-text-tertiary shrink-0\">\r\n +{RPNInput.getCountryCallingCode(item.value)}\r\n </span>\r\n </div>\r\n </ComboboxItem>\r\n )\r\n })}\r\n </div>\r\n </ComboboxList>\r\n </ComboboxPopup>\r\n </Combobox >\r\n )\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// Input Component\r\n// ---------------------------------------------------------------------------\r\n\r\nconst InputComponent = React.forwardRef<\r\n HTMLInputElement,\r\n React.ComponentProps<\"input\">\r\n>(({ className, onChange, ...props }, ref) => {\r\n const handleChange = React.useCallback(\r\n (event: React.ChangeEvent<HTMLInputElement>) => {\r\n if (event.currentTarget.value === \"+\") {\r\n event.currentTarget.value = \"\"\r\n }\r\n\r\n onChange?.(event)\r\n },\r\n [onChange]\r\n )\r\n\r\n return (\r\n <input\r\n className={cn(\r\n inputVariants(),\r\n \"h-11 flex-1 rounded-l-none text-body-regular-2\",\r\n className\r\n )}\r\n ref={ref}\r\n type=\"tel\"\r\n onChange={handleChange}\r\n {...props}\r\n />\r\n )\r\n})\r\nInputComponent.displayName = \"InputComponent\"\r\n\r\n// ---------------------------------------------------------------------------\r\n// Phone Input\r\n// ---------------------------------------------------------------------------\r\n\r\nconst PhoneInput: React.ForwardRefExoticComponent<PhoneInputProps> =\r\n React.forwardRef<\r\n React.ElementRef<typeof RPNInput.default>,\r\n PhoneInputProps\r\n >(({\r\n className,\r\n onChange,\r\n value,\r\n ...props\r\n }, ref) => {\r\n return (\r\n <RPNInput.default\r\n ref={ref}\r\n className={cn(\r\n \"flex w-full min-w-0 items-center\",\r\n className\r\n )}\r\n flagComponent={FlagComponent}\r\n countrySelectComponent={CountrySelect}\r\n inputComponent={InputComponent}\r\n smartCaret={false}\r\n value={value || undefined}\r\n onChange={(value) => onChange?.(value || (\"\" as RPNInput.Value))}\r\n {...props}\r\n />\r\n )\r\n })\r\nPhoneInput.displayName = \"PhoneInput\"\r\n\r\nexport { PhoneInput, type PhoneInputProps }\r\n"]}