@xploreu/components 0.4.26 → 0.4.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2URFXFQC.js +2 -0
- package/dist/chunk-2URFXFQC.js.map +1 -0
- package/dist/{chunk-RJ2SAHLO.js → chunk-6OC5NZB6.js} +2 -2
- package/dist/{chunk-RJ2SAHLO.js.map → chunk-6OC5NZB6.js.map} +1 -1
- package/dist/chunk-APGPUUGM.js +2 -0
- package/dist/chunk-APGPUUGM.js.map +1 -0
- package/dist/chunk-CDHMNEJ5.js +2 -0
- package/dist/chunk-CDHMNEJ5.js.map +1 -0
- package/dist/{chunk-QUSWZDB5.js → chunk-GRQYQEGS.js} +2 -2
- package/dist/{chunk-QUSWZDB5.js.map → chunk-GRQYQEGS.js.map} +1 -1
- package/dist/chunk-HHG7BSWN.js +2 -0
- package/dist/chunk-HHG7BSWN.js.map +1 -0
- package/dist/{chunk-W6CEQOB6.js → chunk-IT4LPPTN.js} +2 -2
- package/dist/{chunk-W6CEQOB6.js.map → chunk-IT4LPPTN.js.map} +1 -1
- package/dist/chunk-IZQFTYJD.js +2 -0
- package/dist/chunk-IZQFTYJD.js.map +1 -0
- package/dist/{chunk-VNU37GJC.js → chunk-JYFVQ5NY.js} +2 -2
- package/dist/{chunk-VNU37GJC.js.map → chunk-JYFVQ5NY.js.map} +1 -1
- package/dist/chunk-ON7PUZWI.js +2 -0
- package/dist/chunk-ON7PUZWI.js.map +1 -0
- package/dist/{chunk-V2D72N26.js → chunk-VODPMAOM.js} +2 -2
- package/dist/{chunk-V2D72N26.js.map → chunk-VODPMAOM.js.map} +1 -1
- package/dist/{chunk-O2V2JJ2V.js → chunk-WV5OCKQK.js} +2 -2
- package/dist/{chunk-O2V2JJ2V.js.map → chunk-WV5OCKQK.js.map} +1 -1
- package/dist/{chunk-H2BHLGW2.js → chunk-YB74L6RO.js} +2 -2
- package/dist/{chunk-H2BHLGW2.js.map → chunk-YB74L6RO.js.map} +1 -1
- package/dist/composites/combobox-chip-outside.js +1 -1
- package/dist/composites/combobox-chip.js +1 -1
- package/dist/composites/combobox-simple.js +1 -1
- package/dist/composites/filter-combobox.d.ts +3 -15
- package/dist/composites/filter-combobox.js +1 -1
- package/dist/composites/index.d.ts +1 -1
- package/dist/composites/index.js +1 -1
- package/dist/composites/index.js.map +1 -1
- package/dist/composites/phone-input.js +1 -1
- package/dist/effects/highlight.d.ts +13 -13
- package/dist/effects/highlight.js +1 -1
- package/dist/effects/index.js +1 -1
- package/dist/primitives/combobox.d.ts +3 -1
- package/dist/primitives/combobox.js +1 -1
- package/dist/primitives/index.d.ts +1 -1
- package/dist/primitives/index.js +1 -1
- package/dist/primitives/menu.js +1 -1
- package/dist/primitives/tabs.js +1 -1
- package/dist/ui/combobox.d.ts +4 -2
- package/dist/ui/combobox.js +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/ui/menu.js +1 -1
- package/dist/ui/pagination.js +1 -1
- package/dist/ui/tabs.d.ts +1 -1
- package/dist/ui/tabs.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2XZRLJCN.js +0 -2
- package/dist/chunk-2XZRLJCN.js.map +0 -1
- package/dist/chunk-3SPYZO2Y.js +0 -2
- package/dist/chunk-3SPYZO2Y.js.map +0 -1
- package/dist/chunk-DFAATW5A.js +0 -2
- package/dist/chunk-DFAATW5A.js.map +0 -1
- package/dist/chunk-EO656DPM.js +0 -2
- package/dist/chunk-EO656DPM.js.map +0 -1
- package/dist/chunk-PHP3T7ZS.js +0 -2
- package/dist/chunk-PHP3T7ZS.js.map +0 -1
- package/dist/chunk-TZ44HGOL.js +0 -2
- package/dist/chunk-TZ44HGOL.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {b,c as c$1}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {b,c as c$1}from'./chunk-2URFXFQC.js';import*as C from'react';import {Menu}from'@base-ui/react/menu';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}from'react/jsx-runtime';var [T,c]=getStrictContext("MenuActiveValueContext"),[R,k]=getStrictContext("MenuContext");function A(e){let[n,o]=useControlledState({value:e?.open,defaultValue:e?.defaultOpen,onChange:e?.onOpenChange}),[i,u]=C.useState(null);return jsx(T,{value:{highlightedValue:i,setHighlightedValue:u},children:jsx(R,{value:{isOpen:n,setIsOpen:o},children:jsx(Menu.Root,{"data-slot":"menu",...e,onOpenChange:o})})})}function w(e){return jsx(Menu.Trigger,{"data-slot":"menu-trigger",...e})}function D(e){let{isOpen:n}=k();return jsx(AnimatePresence,{children:n&&jsx(Menu.Portal,{"data-slot":"menu-portal",keepMounted:true,...e})})}function B(e){return jsx(Menu.Positioner,{"data-slot":"menu-positioner",...e})}function E({finalFocus:e,id:n,transition:o={duration:.2},style:i,...u}){return jsx(Menu.Popup,{finalFocus:e,id:n,render:jsx(motion.div,{animate:{opacity:1,scale:1},"data-slot":"menu-popup",exit:{opacity:0,scale:.95},initial:{opacity:0,scale:.95},style:{willChange:"opacity, transform",...i},transition:o,...u},"menu-popup")})}function F(e){return jsx(Menu.Group,{"data-slot":"menu-group",...e})}function q(e){return jsx(Menu.GroupLabel,{"data-slot":"menu-group-label",...e})}function z(e){return jsx(Menu.Separator,{"data-slot":"menu-separator",...e})}function J(e){return jsx("span",{"data-slot":"menu-shortcut",...e})}function K(e){return jsx(Menu.Arrow,{"data-slot":"menu-arrow",...e})}function N({transition:e={type:"spring",stiffness:350,damping:35},...n}){let{highlightedValue:o}=c();return jsx(b,{click:false,controlledItems:true,"data-slot":"menu-highlight",transition:e,value:o,...n})}function Q(e){return jsx(c$1,{"data-slot":"menu-highlight-item",...e})}function U({disabled:e,label:n,closeOnClick:o,nativeButton:i,id:u,...s}){let{setHighlightedValue:m}=c(),[,p]=useDataState("highlighted",void 0,a=>{if(a===true){let d=p.current,l=d?.dataset.value||d?.id||null;l&&m(l);}});return jsx(Menu.Item,{ref:p,closeOnClick:o,"data-slot":"menu-item",disabled:e,id:u,label:n,nativeButton:i,...s})}function W({label:e,defaultChecked:n,checked:o,onCheckedChange:i,disabled:u,closeOnClick:s,nativeButton:m,id:p,...a}){let{setHighlightedValue:d}=c(),[,l]=useDataState("highlighted",void 0,M=>{if(M===true){let h=l.current,y=h?.dataset.value||h?.id||null;y&&d(y);}});return jsx(Menu.CheckboxItem,{ref:l,checked:o,closeOnClick:s,"data-slot":"menu-checkbox-item",defaultChecked:n,disabled:u,id:p,label:e,nativeButton:m,onCheckedChange:i,...a})}function X({keepMounted:e,...n}){return jsx(Menu.CheckboxItemIndicator,{"data-slot":"menu-checkbox-item-indicator",keepMounted:e,render:jsx(motion.div,{"data-slot":"menu-checkbox-item-indicator",...n})})}function Y(e){return jsx(Menu.RadioGroup,{"data-slot":"menu-radio-group",...e})}function Z({value:e,disabled:n,label:o,closeOnClick:i,nativeButton:u,id:s,...m}){let{setHighlightedValue:p}=c(),[,a]=useDataState("highlighted",void 0,d=>{if(d===true){let l=a.current,M=l?.dataset.value||l?.id||null;M&&p(M);}});return jsx(Menu.RadioItem,{ref:a,closeOnClick:i,"data-slot":"menu-radio-item",disabled:n,id:s,label:o,nativeButton:u,value:e,...m})}function _({keepMounted:e,...n}){return jsx(Menu.RadioItemIndicator,{"data-slot":"menu-radio-item-indicator",keepMounted:e,render:jsx(motion.div,{"data-slot":"menu-radio-item-indicator",...n})})}function $(e){let[n,o]=useControlledState({value:e?.open,defaultValue:e?.defaultOpen,onChange:e?.onOpenChange});return jsx(R,{value:{isOpen:n,setIsOpen:o},children:jsx(Menu.SubmenuRoot,{"data-slot":"menu-submenu",...e,onOpenChange:o})})}function j({label:e,id:n,nativeButton:o,...i}){let{setHighlightedValue:u}=c(),[,s]=useDataState("highlighted",void 0,m=>{if(m===true){let p=s.current,a=p?.dataset.value||p?.id||null;a&&u(a);}});return jsx(Menu.SubmenuTrigger,{ref:s,"data-slot":"menu-submenu-trigger",id:n,label:e,nativeButton:o,...i})}export{c as a,k as b,A as c,w as d,D as e,B as f,E as g,F as h,q as i,z as j,J as k,K as l,N as m,Q as n,U as o,W as p,X as q,Y as r,Z as s,_ as t,$ as u,j as v};//# sourceMappingURL=chunk-JYFVQ5NY.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-JYFVQ5NY.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/primitives/menu.tsx"],"names":["MenuActiveValueProvider","useMenuActiveValue","getStrictContext","MenuProvider","useMenu","Menu","props","isOpen","setIsOpen","useControlledState","highlightedValue","setHighlightedValue","jsx","MenuPrimitive","MenuTrigger","MenuPortal","AnimatePresence","MenuPositioner","MenuPopup","finalFocus","id","transition","style","motion","MenuGroup","MenuGroupLabel","MenuSeparator","MenuShortcut","MenuArrow","MenuHighlight","Highlight","MenuHighlightItem","HighlightItem","MenuItem","disabled","label","closeOnClick","nativeButton","highlightedRef","useDataState","value","el","v","MenuCheckboxItem","defaultChecked","checked","onCheckedChange","MenuCheckboxItemIndicator","keepMounted","MenuRadioGroup","MenuRadioItem","MenuRadioItemIndicator","MenuSubmenu","MenuSubmenuTrigger"],"mappings":"+XAgCA,IAAM,CAACA,EAAyBC,CAAkB,CAAA,CAChDC,iBAA6C,wBAAwB,CAAA,CAEjE,CAACC,CAAAA,CAAcC,CAAO,EAC1BF,gBAAAA,CAAkC,aAAa,EAIjD,SAASG,CAAAA,CAAKC,CAAAA,CAAkB,CAC9B,GAAM,CAACC,EAAQC,CAAS,CAAA,CAAIC,mBAAmB,CAC7C,KAAA,CAAOH,GAAO,IAAA,CACd,YAAA,CAAcA,GAAO,WAAA,CACrB,QAAA,CAAUA,GAAO,YACnB,CAAC,EACK,CAACI,CAAAA,CAAkBC,CAAmB,CAAA,CAAU,CAAA,CAAA,QAAA,CACpD,IACF,CAAA,CAEA,OACEC,GAAAA,CAACZ,EA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A,CAAAI,CAAAA,CAAQ,UAAAC,CAAU,CAAA,CACvC,SAAAI,GAAAA,CAACC,IAAAA,CAAc,WAAA,CAAd,CACC,WAAA,CAAU,cAAA,CACT,GAAGP,CAAAA,CACJ,YAAA,CAAcE,EAChB,CAAA,CACF,CAEJ,CAUA,SAAS6C,CAAAA,CAAmB,CAC1B,KAAA,CAAAlB,CAAAA,CACA,EAAA,CAAAf,EACA,YAAA,CAAAiB,CAAAA,CACA,GAAG/B,CACL,CAAA,CAA4B,CAC1B,GAAM,CAAE,mBAAA,CAAAK,CAAoB,CAAA,CAAIV,CAAAA,GAC1B,EAAGqC,CAAc,CAAA,CAAIC,YAAAA,CACzB,cACA,MAAA,CACCC,CAAAA,EAAU,CACT,GAAIA,CAAAA,GAAU,KAAM,CAClB,IAAMC,EAAKH,CAAAA,CAAe,OAAA,CACpBI,EAAID,CAAAA,EAAI,OAAA,CAAQ,KAAA,EAASA,CAAAA,EAAI,EAAA,EAAM,IAAA,CACrCC,GAAG/B,CAAAA,CAAoB+B,CAAC,EAC9B,CACF,CACF,EAEA,OACE9B,GAAAA,CAACC,IAAAA,CAAc,cAAA,CAAd,CACC,GAAA,CAAKyB,EACL,WAAA,CAAU,sBAAA,CACV,GAAIlB,CAAAA,CACJ,KAAA,CAAOe,EACP,YAAA,CAAcE,CAAAA,CACb,GAAG/B,CAAAA,CACN,CAEJ","file":"chunk-VNU37GJC.js","sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\n\r\nimport { Menu as MenuPrimitive } from \"@base-ui/react/menu\"\r\nimport {\r\n AnimatePresence,\r\n type HTMLMotionProps,\r\n motion\r\n} from \"motion/react\"\r\n\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\nimport {\r\n Highlight,\r\n HighlightItem,\r\n type HighlightItemProps,\r\n type HighlightProps\r\n} from \"../effects/highlight\"\r\n\r\ntype MenuActiveValueContextType = {\r\n highlightedValue: string | null;\r\n setHighlightedValue: (value: string | null) => void;\r\n}\r\n\r\ntype MenuContextType = {\r\n isOpen: boolean;\r\n setIsOpen: MenuProps[\"onOpenChange\"];\r\n}\r\n\r\nconst [MenuActiveValueProvider, useMenuActiveValue] =\r\n getStrictContext<MenuActiveValueContextType>(\"MenuActiveValueContext\")\r\n\r\nconst [MenuProvider, useMenu] =\r\n getStrictContext<MenuContextType>(\"MenuContext\")\r\n\r\ntype MenuProps = React.ComponentProps<typeof MenuPrimitive.Root>\r\n\r\nfunction Menu(props: MenuProps) {\r\n const [isOpen, setIsOpen] = useControlledState({\r\n value: props?.open,\r\n defaultValue: props?.defaultOpen,\r\n onChange: props?.onOpenChange,\r\n })\r\n const [highlightedValue, setHighlightedValue] = React.useState<string | null>(\r\n null,\r\n )\r\n\r\n return (\r\n <MenuActiveValueProvider value={{ highlightedValue, setHighlightedValue }}>\r\n <MenuProvider value={{ isOpen, setIsOpen }}>\r\n <MenuPrimitive.Root\r\n data-slot=\"menu\"\r\n {...props}\r\n onOpenChange={setIsOpen}\r\n />\r\n </MenuProvider>\r\n </MenuActiveValueProvider>\r\n )\r\n}\r\n\r\ntype MenuTriggerProps = React.ComponentProps<typeof MenuPrimitive.Trigger>\r\n\r\nfunction MenuTrigger(props: MenuTriggerProps) {\r\n return <MenuPrimitive.Trigger data-slot=\"menu-trigger\" {...props} />\r\n}\r\n\r\ntype MenuPortalProps = Omit<\r\n React.ComponentProps<typeof MenuPrimitive.Portal>,\r\n \"keepMounted\"\r\n>\r\n\r\nfunction MenuPortal(props: MenuPortalProps) {\r\n const { isOpen } = useMenu()\r\n\r\n return (\r\n <AnimatePresence>\r\n {isOpen && (\r\n <MenuPrimitive.Portal\r\n data-slot=\"menu-portal\"\r\n keepMounted\r\n {...props}\r\n />\r\n )}\r\n </AnimatePresence>\r\n )\r\n}\r\n\r\ntype MenuPositionerProps = React.ComponentProps<\r\n typeof MenuPrimitive.Positioner\r\n>\r\n\r\nfunction MenuPositioner(props: MenuPositionerProps) {\r\n return (\r\n <MenuPrimitive.Positioner\r\n data-slot=\"menu-positioner\"\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuPopupProps = Omit<\r\n React.ComponentProps<typeof MenuPrimitive.Popup>,\r\n \"render\"\r\n> &\r\n HTMLMotionProps<\"div\">\r\n\r\nfunction MenuPopup({\r\n finalFocus,\r\n id,\r\n transition = { duration: 0.2 },\r\n style,\r\n ...props\r\n}: MenuPopupProps) {\r\n return (\r\n <MenuPrimitive.Popup\r\n finalFocus={finalFocus}\r\n id={id}\r\n render={\r\n <motion.div\r\n key=\"menu-popup\"\r\n animate={{ opacity: 1, scale: 1 }}\r\n data-slot=\"menu-popup\"\r\n exit={{ opacity: 0, scale: 0.95 }}\r\n initial={{ opacity: 0, scale: 0.95 }}\r\n style={{ willChange: \"opacity, transform\", ...style }}\r\n transition={transition}\r\n {...props}\r\n />\r\n }\r\n />\r\n )\r\n}\r\n\r\ntype MenuGroupProps = React.ComponentProps<typeof MenuPrimitive.Group>\r\n\r\nfunction MenuGroup(props: MenuGroupProps) {\r\n return <MenuPrimitive.Group data-slot=\"menu-group\" {...props} />\r\n}\r\n\r\ntype MenuGroupLabelProps = React.ComponentProps<\r\n typeof MenuPrimitive.GroupLabel\r\n>\r\n\r\nfunction MenuGroupLabel(props: MenuGroupLabelProps) {\r\n return (\r\n <MenuPrimitive.GroupLabel\r\n data-slot=\"menu-group-label\"\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuSeparatorProps = React.ComponentProps<typeof MenuPrimitive.Separator>\r\n\r\nfunction MenuSeparator(props: MenuSeparatorProps) {\r\n return <MenuPrimitive.Separator data-slot=\"menu-separator\" {...props} />\r\n}\r\n\r\ntype MenuShortcutProps = React.ComponentProps<\"span\">\r\n\r\nfunction MenuShortcut(props: MenuShortcutProps) {\r\n return <span data-slot=\"menu-shortcut\" {...props} />\r\n}\r\n\r\ntype MenuArrowProps = React.ComponentProps<typeof MenuPrimitive.Arrow>\r\n\r\nfunction MenuArrow(props: MenuArrowProps) {\r\n return <MenuPrimitive.Arrow data-slot=\"menu-arrow\" {...props} />\r\n}\r\n\r\ntype MenuHighlightProps = Omit<\r\n HighlightProps,\r\n \"controlledItems\" | \"enabled\" | \"hover\"\r\n> & {\r\n animateOnHover?: boolean;\r\n}\r\n\r\nfunction MenuHighlight({\r\n transition = { type: \"spring\", stiffness: 350, damping: 35 },\r\n ...props\r\n}: MenuHighlightProps) {\r\n const { highlightedValue } = useMenuActiveValue()\r\n\r\n return (\r\n <Highlight\r\n click={false}\r\n controlledItems\r\n data-slot=\"menu-highlight\"\r\n transition={transition}\r\n value={highlightedValue}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuHighlightItemProps = HighlightItemProps\r\n\r\nfunction MenuHighlightItem(props: MenuHighlightItemProps) {\r\n return <HighlightItem data-slot=\"menu-highlight-item\" {...props} />\r\n}\r\n\r\ntype MenuItemProps = Omit<\r\n React.ComponentProps<typeof MenuPrimitive.Item>,\r\n \"render\"\r\n> &\r\n HTMLMotionProps<\"div\">\r\n\r\nfunction MenuItem({\r\n disabled,\r\n label,\r\n closeOnClick,\r\n nativeButton,\r\n id,\r\n ...props\r\n}: MenuItemProps) {\r\n const { setHighlightedValue } = useMenuActiveValue()\r\n const [, highlightedRef] = useDataState<HTMLDivElement>(\r\n \"highlighted\",\r\n undefined,\r\n (value) => {\r\n if (value === true) {\r\n const el = highlightedRef.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 (\r\n <MenuPrimitive.Item\r\n ref={highlightedRef}\r\n closeOnClick={closeOnClick}\r\n data-slot=\"menu-item\"\r\n disabled={disabled}\r\n id={id}\r\n label={label}\r\n nativeButton={nativeButton}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuCheckboxItemProps = Omit<\r\n React.ComponentProps<typeof MenuPrimitive.CheckboxItem>,\r\n \"render\"\r\n>\r\n\r\nfunction MenuCheckboxItem({\r\n label,\r\n defaultChecked,\r\n checked,\r\n onCheckedChange,\r\n disabled,\r\n closeOnClick,\r\n nativeButton,\r\n id,\r\n ...props\r\n}: MenuCheckboxItemProps) {\r\n const { setHighlightedValue } = useMenuActiveValue()\r\n const [, highlightedRef] = useDataState<HTMLDivElement>(\r\n \"highlighted\",\r\n undefined,\r\n (value) => {\r\n if (value === true) {\r\n const el = highlightedRef.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 (\r\n <MenuPrimitive.CheckboxItem\r\n ref={highlightedRef}\r\n checked={checked}\r\n closeOnClick={closeOnClick}\r\n data-slot=\"menu-checkbox-item\"\r\n defaultChecked={defaultChecked}\r\n disabled={disabled}\r\n id={id}\r\n label={label}\r\n nativeButton={nativeButton}\r\n onCheckedChange={onCheckedChange}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuCheckboxItemIndicatorProps = Omit<\r\n React.ComponentProps<typeof MenuPrimitive.CheckboxItemIndicator>,\r\n \"render\"\r\n> &\r\n HTMLMotionProps<\"div\">\r\n\r\nfunction MenuCheckboxItemIndicator({\r\n keepMounted,\r\n ...props\r\n}: MenuCheckboxItemIndicatorProps) {\r\n return (\r\n <MenuPrimitive.CheckboxItemIndicator\r\n data-slot=\"menu-checkbox-item-indicator\"\r\n keepMounted={keepMounted}\r\n render={\r\n <motion.div data-slot=\"menu-checkbox-item-indicator\" {...props} />\r\n }\r\n />\r\n )\r\n}\r\n\r\ntype MenuRadioGroupProps = React.ComponentProps<\r\n typeof MenuPrimitive.RadioGroup\r\n>\r\n\r\nfunction MenuRadioGroup(props: MenuRadioGroupProps) {\r\n return <MenuPrimitive.RadioGroup data-slot=\"menu-radio-group\" {...props} />\r\n}\r\n\r\ntype MenuRadioItemProps = Omit<\r\n React.ComponentProps<typeof MenuPrimitive.RadioItem>,\r\n \"render\"\r\n>\r\n\r\nfunction MenuRadioItem({\r\n value,\r\n disabled,\r\n label,\r\n closeOnClick,\r\n nativeButton,\r\n id,\r\n ...props\r\n}: MenuRadioItemProps) {\r\n const { setHighlightedValue } = useMenuActiveValue()\r\n const [, highlightedRef] = useDataState<HTMLDivElement>(\r\n \"highlighted\",\r\n undefined,\r\n (value) => {\r\n if (value === true) {\r\n const el = highlightedRef.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 (\r\n <MenuPrimitive.RadioItem\r\n ref={highlightedRef}\r\n closeOnClick={closeOnClick}\r\n data-slot=\"menu-radio-item\"\r\n disabled={disabled}\r\n id={id}\r\n label={label}\r\n nativeButton={nativeButton}\r\n value={value}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuRadioItemIndicatorProps = Omit<\r\n React.ComponentProps<typeof MenuPrimitive.RadioItemIndicator>,\r\n \"render\"\r\n> &\r\n HTMLMotionProps<\"div\">\r\n\r\nfunction MenuRadioItemIndicator({\r\n keepMounted,\r\n ...props\r\n}: MenuRadioItemIndicatorProps) {\r\n return (\r\n <MenuPrimitive.RadioItemIndicator\r\n data-slot=\"menu-radio-item-indicator\"\r\n keepMounted={keepMounted}\r\n render={\r\n <motion.div data-slot=\"menu-radio-item-indicator\" {...props} />\r\n }\r\n />\r\n )\r\n}\r\n\r\ntype MenuSubmenuProps = React.ComponentProps<typeof MenuPrimitive.SubmenuRoot>\r\n\r\nfunction MenuSubmenu(props: MenuSubmenuProps) {\r\n const [isOpen, setIsOpen] = useControlledState({\r\n value: props?.open,\r\n defaultValue: props?.defaultOpen,\r\n onChange: props?.onOpenChange,\r\n })\r\n\r\n return (\r\n <MenuProvider value={{ isOpen, setIsOpen }}>\r\n <MenuPrimitive.SubmenuRoot\r\n data-slot=\"menu-submenu\"\r\n {...props}\r\n onOpenChange={setIsOpen}\r\n />\r\n </MenuProvider>\r\n )\r\n}\r\n\r\ntype MenuSubmenuTriggerProps = Omit<\r\n React.ComponentProps<typeof MenuPrimitive.SubmenuTrigger>,\r\n \"render\"\r\n> &\r\n HTMLMotionProps<\"div\"> & {\r\n disabled?: boolean;\r\n }\r\n\r\nfunction MenuSubmenuTrigger({\r\n label,\r\n id,\r\n nativeButton,\r\n ...props\r\n}: MenuSubmenuTriggerProps) {\r\n const { setHighlightedValue } = useMenuActiveValue()\r\n const [, highlightedRef] = useDataState<HTMLDivElement>(\r\n \"highlighted\",\r\n undefined,\r\n (value) => {\r\n if (value === true) {\r\n const el = highlightedRef.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 (\r\n <MenuPrimitive.SubmenuTrigger\r\n ref={highlightedRef}\r\n data-slot=\"menu-submenu-trigger\"\r\n id={id}\r\n label={label}\r\n nativeButton={nativeButton}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\nexport {\r\n Menu,\r\n MenuTrigger,\r\n MenuPortal,\r\n MenuPositioner,\r\n MenuPopup,\r\n MenuArrow,\r\n MenuItem,\r\n MenuCheckboxItem,\r\n MenuCheckboxItemIndicator,\r\n MenuRadioGroup,\r\n MenuRadioItem,\r\n MenuRadioItemIndicator,\r\n MenuGroup,\r\n MenuGroupLabel,\r\n MenuSeparator,\r\n MenuShortcut,\r\n MenuHighlight,\r\n MenuHighlightItem,\r\n MenuSubmenu,\r\n MenuSubmenuTrigger,\r\n useMenuActiveValue,\r\n useMenu,\r\n type MenuProps,\r\n type MenuTriggerProps,\r\n type MenuPortalProps,\r\n type MenuPositionerProps,\r\n type MenuPopupProps,\r\n type MenuArrowProps,\r\n type MenuItemProps,\r\n type MenuCheckboxItemProps,\r\n type MenuCheckboxItemIndicatorProps,\r\n type MenuRadioItemProps,\r\n type MenuRadioItemIndicatorProps,\r\n type MenuRadioGroupProps,\r\n type MenuGroupProps,\r\n type MenuGroupLabelProps,\r\n type MenuSeparatorProps,\r\n type MenuShortcutProps,\r\n type MenuHighlightProps,\r\n type MenuHighlightItemProps,\r\n type MenuSubmenuProps,\r\n type MenuSubmenuTriggerProps,\r\n type MenuActiveValueContextType,\r\n type MenuContextType,\r\n}"]}
|
|
1
|
+
{"version":3,"sources":["../src/primitives/menu.tsx"],"names":["MenuActiveValueProvider","useMenuActiveValue","getStrictContext","MenuProvider","useMenu","Menu","props","isOpen","setIsOpen","useControlledState","highlightedValue","setHighlightedValue","jsx","MenuPrimitive","MenuTrigger","MenuPortal","AnimatePresence","MenuPositioner","MenuPopup","finalFocus","id","transition","style","motion","MenuGroup","MenuGroupLabel","MenuSeparator","MenuShortcut","MenuArrow","MenuHighlight","Highlight","MenuHighlightItem","HighlightItem","MenuItem","disabled","label","closeOnClick","nativeButton","highlightedRef","useDataState","value","el","v","MenuCheckboxItem","defaultChecked","checked","onCheckedChange","MenuCheckboxItemIndicator","keepMounted","MenuRadioGroup","MenuRadioItem","MenuRadioItemIndicator","MenuSubmenu","MenuSubmenuTrigger"],"mappings":"+XAgCA,IAAM,CAACA,EAAyBC,CAAkB,CAAA,CAChDC,iBAA6C,wBAAwB,CAAA,CAEjE,CAACC,CAAAA,CAAcC,CAAO,EAC1BF,gBAAAA,CAAkC,aAAa,EAIjD,SAASG,CAAAA,CAAKC,CAAAA,CAAkB,CAC9B,GAAM,CAACC,EAAQC,CAAS,CAAA,CAAIC,mBAAmB,CAC7C,KAAA,CAAOH,GAAO,IAAA,CACd,YAAA,CAAcA,GAAO,WAAA,CACrB,QAAA,CAAUA,GAAO,YACnB,CAAC,EACK,CAACI,CAAAA,CAAkBC,CAAmB,CAAA,CAAU,CAAA,CAAA,QAAA,CACpD,IACF,CAAA,CAEA,OACEC,GAAAA,CAACZ,EAAA,CAAwB,KAAA,CAAO,CAAE,gBAAA,CAAAU,CAAAA,CAAkB,oBAAAC,CAAoB,CAAA,CACtE,QAAA,CAAAC,GAAAA,CAACT,CAAAA,CAAA,CAAa,MAAO,CAAE,MAAA,CAAAI,EAAQ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CAAA,CACF,CAEJ,CAUA,SAAS6C,CAAAA,CAAmB,CAC1B,KAAA,CAAAlB,CAAAA,CACA,EAAA,CAAAf,EACA,YAAA,CAAAiB,CAAAA,CACA,GAAG/B,CACL,CAAA,CAA4B,CAC1B,GAAM,CAAE,mBAAA,CAAAK,CAAoB,CAAA,CAAIV,CAAAA,GAC1B,EAAGqC,CAAc,CAAA,CAAIC,YAAAA,CACzB,cACA,MAAA,CACCC,CAAAA,EAAU,CACT,GAAIA,CAAAA,GAAU,KAAM,CAClB,IAAMC,EAAKH,CAAAA,CAAe,OAAA,CACpBI,EAAID,CAAAA,EAAI,OAAA,CAAQ,KAAA,EAASA,CAAAA,EAAI,EAAA,EAAM,IAAA,CACrCC,GAAG/B,CAAAA,CAAoB+B,CAAC,EAC9B,CACF,CACF,EAEA,OACE9B,GAAAA,CAACC,IAAAA,CAAc,cAAA,CAAd,CACC,GAAA,CAAKyB,EACL,WAAA,CAAU,sBAAA,CACV,GAAIlB,CAAAA,CACJ,KAAA,CAAOe,EACP,YAAA,CAAcE,CAAAA,CACb,GAAG/B,CAAAA,CACN,CAEJ","file":"chunk-JYFVQ5NY.js","sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\n\r\nimport { Menu as MenuPrimitive } from \"@base-ui/react/menu\"\r\nimport {\r\n AnimatePresence,\r\n type HTMLMotionProps,\r\n motion\r\n} from \"motion/react\"\r\n\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\nimport {\r\n Highlight,\r\n HighlightItem,\r\n type HighlightItemProps,\r\n type HighlightProps\r\n} from \"../effects/highlight\"\r\n\r\ntype MenuActiveValueContextType = {\r\n highlightedValue: string | null;\r\n setHighlightedValue: (value: string | null) => void;\r\n}\r\n\r\ntype MenuContextType = {\r\n isOpen: boolean;\r\n setIsOpen: MenuProps[\"onOpenChange\"];\r\n}\r\n\r\nconst [MenuActiveValueProvider, useMenuActiveValue] =\r\n getStrictContext<MenuActiveValueContextType>(\"MenuActiveValueContext\")\r\n\r\nconst [MenuProvider, useMenu] =\r\n getStrictContext<MenuContextType>(\"MenuContext\")\r\n\r\ntype MenuProps = React.ComponentProps<typeof MenuPrimitive.Root>\r\n\r\nfunction Menu(props: MenuProps) {\r\n const [isOpen, setIsOpen] = useControlledState({\r\n value: props?.open,\r\n defaultValue: props?.defaultOpen,\r\n onChange: props?.onOpenChange,\r\n })\r\n const [highlightedValue, setHighlightedValue] = React.useState<string | null>(\r\n null,\r\n )\r\n\r\n return (\r\n <MenuActiveValueProvider value={{ highlightedValue, setHighlightedValue }}>\r\n <MenuProvider value={{ isOpen, setIsOpen }}>\r\n <MenuPrimitive.Root\r\n data-slot=\"menu\"\r\n {...props}\r\n onOpenChange={setIsOpen}\r\n />\r\n </MenuProvider>\r\n </MenuActiveValueProvider>\r\n )\r\n}\r\n\r\ntype MenuTriggerProps = React.ComponentProps<typeof MenuPrimitive.Trigger>\r\n\r\nfunction MenuTrigger(props: MenuTriggerProps) {\r\n return <MenuPrimitive.Trigger data-slot=\"menu-trigger\" {...props} />\r\n}\r\n\r\ntype MenuPortalProps = Omit<\r\n React.ComponentProps<typeof MenuPrimitive.Portal>,\r\n \"keepMounted\"\r\n>\r\n\r\nfunction MenuPortal(props: MenuPortalProps) {\r\n const { isOpen } = useMenu()\r\n\r\n return (\r\n <AnimatePresence>\r\n {isOpen && (\r\n <MenuPrimitive.Portal\r\n data-slot=\"menu-portal\"\r\n keepMounted\r\n {...props}\r\n />\r\n )}\r\n </AnimatePresence>\r\n )\r\n}\r\n\r\ntype MenuPositionerProps = React.ComponentProps<\r\n typeof MenuPrimitive.Positioner\r\n>\r\n\r\nfunction MenuPositioner(props: MenuPositionerProps) {\r\n return (\r\n <MenuPrimitive.Positioner\r\n data-slot=\"menu-positioner\"\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuPopupProps = Omit<\r\n React.ComponentProps<typeof MenuPrimitive.Popup>,\r\n \"render\"\r\n> &\r\n HTMLMotionProps<\"div\">\r\n\r\nfunction MenuPopup({\r\n finalFocus,\r\n id,\r\n transition = { duration: 0.2 },\r\n style,\r\n ...props\r\n}: MenuPopupProps) {\r\n return (\r\n <MenuPrimitive.Popup\r\n finalFocus={finalFocus}\r\n id={id}\r\n render={\r\n <motion.div\r\n key=\"menu-popup\"\r\n animate={{ opacity: 1, scale: 1 }}\r\n data-slot=\"menu-popup\"\r\n exit={{ opacity: 0, scale: 0.95 }}\r\n initial={{ opacity: 0, scale: 0.95 }}\r\n style={{ willChange: \"opacity, transform\", ...style }}\r\n transition={transition}\r\n {...props}\r\n />\r\n }\r\n />\r\n )\r\n}\r\n\r\ntype MenuGroupProps = React.ComponentProps<typeof MenuPrimitive.Group>\r\n\r\nfunction MenuGroup(props: MenuGroupProps) {\r\n return <MenuPrimitive.Group data-slot=\"menu-group\" {...props} />\r\n}\r\n\r\ntype MenuGroupLabelProps = React.ComponentProps<\r\n typeof MenuPrimitive.GroupLabel\r\n>\r\n\r\nfunction MenuGroupLabel(props: MenuGroupLabelProps) {\r\n return (\r\n <MenuPrimitive.GroupLabel\r\n data-slot=\"menu-group-label\"\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuSeparatorProps = React.ComponentProps<typeof MenuPrimitive.Separator>\r\n\r\nfunction MenuSeparator(props: MenuSeparatorProps) {\r\n return <MenuPrimitive.Separator data-slot=\"menu-separator\" {...props} />\r\n}\r\n\r\ntype MenuShortcutProps = React.ComponentProps<\"span\">\r\n\r\nfunction MenuShortcut(props: MenuShortcutProps) {\r\n return <span data-slot=\"menu-shortcut\" {...props} />\r\n}\r\n\r\ntype MenuArrowProps = React.ComponentProps<typeof MenuPrimitive.Arrow>\r\n\r\nfunction MenuArrow(props: MenuArrowProps) {\r\n return <MenuPrimitive.Arrow data-slot=\"menu-arrow\" {...props} />\r\n}\r\n\r\ntype MenuHighlightProps = Omit<\r\n HighlightProps,\r\n \"controlledItems\" | \"enabled\" | \"hover\"\r\n> & {\r\n animateOnHover?: boolean;\r\n}\r\n\r\nfunction MenuHighlight({\r\n transition = { type: \"spring\", stiffness: 350, damping: 35 },\r\n ...props\r\n}: MenuHighlightProps) {\r\n const { highlightedValue } = useMenuActiveValue()\r\n\r\n return (\r\n <Highlight\r\n click={false}\r\n controlledItems\r\n data-slot=\"menu-highlight\"\r\n transition={transition}\r\n value={highlightedValue}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuHighlightItemProps = HighlightItemProps\r\n\r\nfunction MenuHighlightItem(props: MenuHighlightItemProps) {\r\n return <HighlightItem data-slot=\"menu-highlight-item\" {...props} />\r\n}\r\n\r\ntype MenuItemProps = Omit<\r\n React.ComponentProps<typeof MenuPrimitive.Item>,\r\n \"render\"\r\n> &\r\n HTMLMotionProps<\"div\">\r\n\r\nfunction MenuItem({\r\n disabled,\r\n label,\r\n closeOnClick,\r\n nativeButton,\r\n id,\r\n ...props\r\n}: MenuItemProps) {\r\n const { setHighlightedValue } = useMenuActiveValue()\r\n const [, highlightedRef] = useDataState<HTMLDivElement>(\r\n \"highlighted\",\r\n undefined,\r\n (value) => {\r\n if (value === true) {\r\n const el = highlightedRef.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 (\r\n <MenuPrimitive.Item\r\n ref={highlightedRef}\r\n closeOnClick={closeOnClick}\r\n data-slot=\"menu-item\"\r\n disabled={disabled}\r\n id={id}\r\n label={label}\r\n nativeButton={nativeButton}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuCheckboxItemProps = Omit<\r\n React.ComponentProps<typeof MenuPrimitive.CheckboxItem>,\r\n \"render\"\r\n>\r\n\r\nfunction MenuCheckboxItem({\r\n label,\r\n defaultChecked,\r\n checked,\r\n onCheckedChange,\r\n disabled,\r\n closeOnClick,\r\n nativeButton,\r\n id,\r\n ...props\r\n}: MenuCheckboxItemProps) {\r\n const { setHighlightedValue } = useMenuActiveValue()\r\n const [, highlightedRef] = useDataState<HTMLDivElement>(\r\n \"highlighted\",\r\n undefined,\r\n (value) => {\r\n if (value === true) {\r\n const el = highlightedRef.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 (\r\n <MenuPrimitive.CheckboxItem\r\n ref={highlightedRef}\r\n checked={checked}\r\n closeOnClick={closeOnClick}\r\n data-slot=\"menu-checkbox-item\"\r\n defaultChecked={defaultChecked}\r\n disabled={disabled}\r\n id={id}\r\n label={label}\r\n nativeButton={nativeButton}\r\n onCheckedChange={onCheckedChange}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuCheckboxItemIndicatorProps = Omit<\r\n React.ComponentProps<typeof MenuPrimitive.CheckboxItemIndicator>,\r\n \"render\"\r\n> &\r\n HTMLMotionProps<\"div\">\r\n\r\nfunction MenuCheckboxItemIndicator({\r\n keepMounted,\r\n ...props\r\n}: MenuCheckboxItemIndicatorProps) {\r\n return (\r\n <MenuPrimitive.CheckboxItemIndicator\r\n data-slot=\"menu-checkbox-item-indicator\"\r\n keepMounted={keepMounted}\r\n render={\r\n <motion.div data-slot=\"menu-checkbox-item-indicator\" {...props} />\r\n }\r\n />\r\n )\r\n}\r\n\r\ntype MenuRadioGroupProps = React.ComponentProps<\r\n typeof MenuPrimitive.RadioGroup\r\n>\r\n\r\nfunction MenuRadioGroup(props: MenuRadioGroupProps) {\r\n return <MenuPrimitive.RadioGroup data-slot=\"menu-radio-group\" {...props} />\r\n}\r\n\r\ntype MenuRadioItemProps = Omit<\r\n React.ComponentProps<typeof MenuPrimitive.RadioItem>,\r\n \"render\"\r\n>\r\n\r\nfunction MenuRadioItem({\r\n value,\r\n disabled,\r\n label,\r\n closeOnClick,\r\n nativeButton,\r\n id,\r\n ...props\r\n}: MenuRadioItemProps) {\r\n const { setHighlightedValue } = useMenuActiveValue()\r\n const [, highlightedRef] = useDataState<HTMLDivElement>(\r\n \"highlighted\",\r\n undefined,\r\n (value) => {\r\n if (value === true) {\r\n const el = highlightedRef.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 (\r\n <MenuPrimitive.RadioItem\r\n ref={highlightedRef}\r\n closeOnClick={closeOnClick}\r\n data-slot=\"menu-radio-item\"\r\n disabled={disabled}\r\n id={id}\r\n label={label}\r\n nativeButton={nativeButton}\r\n value={value}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuRadioItemIndicatorProps = Omit<\r\n React.ComponentProps<typeof MenuPrimitive.RadioItemIndicator>,\r\n \"render\"\r\n> &\r\n HTMLMotionProps<\"div\">\r\n\r\nfunction MenuRadioItemIndicator({\r\n keepMounted,\r\n ...props\r\n}: MenuRadioItemIndicatorProps) {\r\n return (\r\n <MenuPrimitive.RadioItemIndicator\r\n data-slot=\"menu-radio-item-indicator\"\r\n keepMounted={keepMounted}\r\n render={\r\n <motion.div data-slot=\"menu-radio-item-indicator\" {...props} />\r\n }\r\n />\r\n )\r\n}\r\n\r\ntype MenuSubmenuProps = React.ComponentProps<typeof MenuPrimitive.SubmenuRoot>\r\n\r\nfunction MenuSubmenu(props: MenuSubmenuProps) {\r\n const [isOpen, setIsOpen] = useControlledState({\r\n value: props?.open,\r\n defaultValue: props?.defaultOpen,\r\n onChange: props?.onOpenChange,\r\n })\r\n\r\n return (\r\n <MenuProvider value={{ isOpen, setIsOpen }}>\r\n <MenuPrimitive.SubmenuRoot\r\n data-slot=\"menu-submenu\"\r\n {...props}\r\n onOpenChange={setIsOpen}\r\n />\r\n </MenuProvider>\r\n )\r\n}\r\n\r\ntype MenuSubmenuTriggerProps = Omit<\r\n React.ComponentProps<typeof MenuPrimitive.SubmenuTrigger>,\r\n \"render\"\r\n> &\r\n HTMLMotionProps<\"div\"> & {\r\n disabled?: boolean;\r\n }\r\n\r\nfunction MenuSubmenuTrigger({\r\n label,\r\n id,\r\n nativeButton,\r\n ...props\r\n}: MenuSubmenuTriggerProps) {\r\n const { setHighlightedValue } = useMenuActiveValue()\r\n const [, highlightedRef] = useDataState<HTMLDivElement>(\r\n \"highlighted\",\r\n undefined,\r\n (value) => {\r\n if (value === true) {\r\n const el = highlightedRef.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 (\r\n <MenuPrimitive.SubmenuTrigger\r\n ref={highlightedRef}\r\n data-slot=\"menu-submenu-trigger\"\r\n id={id}\r\n label={label}\r\n nativeButton={nativeButton}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\nexport {\r\n Menu,\r\n MenuTrigger,\r\n MenuPortal,\r\n MenuPositioner,\r\n MenuPopup,\r\n MenuArrow,\r\n MenuItem,\r\n MenuCheckboxItem,\r\n MenuCheckboxItemIndicator,\r\n MenuRadioGroup,\r\n MenuRadioItem,\r\n MenuRadioItemIndicator,\r\n MenuGroup,\r\n MenuGroupLabel,\r\n MenuSeparator,\r\n MenuShortcut,\r\n MenuHighlight,\r\n MenuHighlightItem,\r\n MenuSubmenu,\r\n MenuSubmenuTrigger,\r\n useMenuActiveValue,\r\n useMenu,\r\n type MenuProps,\r\n type MenuTriggerProps,\r\n type MenuPortalProps,\r\n type MenuPositionerProps,\r\n type MenuPopupProps,\r\n type MenuArrowProps,\r\n type MenuItemProps,\r\n type MenuCheckboxItemProps,\r\n type MenuCheckboxItemIndicatorProps,\r\n type MenuRadioItemProps,\r\n type MenuRadioItemIndicatorProps,\r\n type MenuRadioGroupProps,\r\n type MenuGroupProps,\r\n type MenuGroupLabelProps,\r\n type MenuSeparatorProps,\r\n type MenuShortcutProps,\r\n type MenuHighlightProps,\r\n type MenuHighlightItemProps,\r\n type MenuSubmenuProps,\r\n type MenuSubmenuTriggerProps,\r\n type MenuActiveValueContextType,\r\n type MenuContextType,\r\n}"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a,b as b$1,j,i,k,l,m,q,s,w,x,H}from'./chunk-IZQFTYJD.js';import {g}from'./chunk-HHG7BSWN.js';import {b}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 ee({multiple:B=true,inputPlaceholder:q$1="Search...",container:A,items:u,infiniteScroll:H$1,isPending:U,taggable:b$2=false,maxVisible:i$1,...m$1}){let[h,x$1]=useControlledState({value:m$1?.inputValue?.toString(),defaultValue:m$1?.defaultInputValue?.toString(),onChange:m$1?.onInputValueChange}),[c,g$1]=useControlledState({value:m$1?.value??[],defaultValue:m$1?.defaultValue??[],onChange:m$1?.onValueChange}),[v,I]=r.useState([]),p=r.useRef(new Set);r.useEffect(()=>{let e=new Set(c.map(t=>t.value));I(t=>{let l=t.filter(a=>e.has(a.value));return l.length===t.length?t:(p.current=new Set(l.map(a=>a.value)),l)});},[c]);let n=h?.toString().trim()??"",X=r.useMemo(()=>n?c.some(e=>e.value.toLowerCase()===n.toLowerCase()):false,[n,c]),C=r.useMemo(()=>!b$2||!n?false:!u?.some(e=>e.label.toLowerCase()===n.toLowerCase()),[b$2,n,u]),D=r.useMemo(()=>{let e=[...u??[],...v];if(C){let t={label:n,value:n,tag:true};return [...e,t]}return e},[u,v,C,n]);return jsxs(a,{...m$1,behavior:"chip-outside",multiple:true,items:b$2?D:u,isItemEqualToValue:(e,t)=>e.value===t.value,onValueChange:(e,t)=>{if(b$2){let l=e.filter(a=>a?.tag===true&&!p.current.has(a.value));if(l.length>0){for(let a of l)p.current.add(a.value);I(a=>[...a,...l]);}}g$1(B?e:[e[e.length-1]],t);},onInputValueChange:x$1,children:[jsxs("div",{className:"flex flex-col gap-2",children:[jsx(g,{render:jsx(b,{className:"h-9 text-body-regular-3 pl-9 pr-7",endContent:jsx(b$1,{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=>{x$1("",{reason:"none",event:e.nativeEvent,cancel:()=>{},allowPropagation:()=>{},isCanceled:false,isPropagationAllowed:true,trigger:void 0});}})}),placeholder:q$1,startContent:jsx(SearchIcon,{className:"!size-4 !text-fg-tertiary-hover"}),wrapperClassName:"w-full"})}),jsx(j,{className:cn(i$1!==void 0&&"flex-nowrap overflow-hidden"),onMouseDown:e=>e.preventBaseUIHandler(),children:jsx(i,{children:e=>{let t=i$1!==void 0?e.slice(0,i$1):e,l$1=i$1!==void 0?e.length-i$1:0;return jsxs(Fragment,{children:[t?.map(a=>jsxs(k,{className:cn(i$1!==void 0&&"min-w-0 shrink"),children:[i$1!==void 0?jsx("span",{className:"truncate",children:a?.label||""}):a?.label||"",jsx(l,{})]},a?.value||"")),l$1>0&&jsxs(k,{className:"shrink-0",children:["+",l$1]})]})}})})]}),jsxs(m,{container:A,children:[jsx(q,{status:U||u===void 0?"pending":u?.length===0&&!C?"empty":null}),jsxs(s,{children:[u?.map(e=>jsx(w,{value:{label:e.label,value:e.value},children:jsx(x,{children:e.label})},e.value)),C&&jsx(w,{value:{label:n,value:n,tag:true},children:jsxs("div",{className:"flex items-center gap-1.5 w-full min-w-0",children:[!X&&jsx("span",{className:"text-text-secondary",children:"Create:"}),jsx("span",{className:"font-medium text-text-primary truncate",children:n})]})}),jsx(H,{...H$1})]})]})]})}export{ee as a};//# sourceMappingURL=chunk-ON7PUZWI.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-ON7PUZWI.js.map
|
|
@@ -0,0 +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","ComboboxItemTitle","ComboboxInfiniteScroll"],"mappings":"qWA6CA,SAASA,EAAAA,CAAgF,CACvF,QAAA,CAAAC,EAAW,IAAA,CACX,gBAAA,CAAAC,GAAAA,CAAmB,WAAA,CACnB,UAAAC,CAAAA,CACA,KAAA,CAAAC,CAAAA,CACA,cAAA,CAAAC,GAAAA,CACA,SAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,IAAW,KAAA,CACX,UAAA,CAAAC,GAAAA,CACA,GAAGC,GACL,CAAA,CAAoC,CAClC,GAAM,CAACC,EAAYC,GAAa,CAAA,CAAIC,kBAAAA,CAAmB,CACrD,KAAA,CAAOH,GAAAA,EAAO,UAAA,EAAY,QAAA,GAC1B,YAAA,CAAcA,GAAAA,EAAO,iBAAA,EAAmB,QAAA,GACxC,QAAA,CAAUA,GAAAA,EAAO,kBACnB,CAAC,EAEK,CAACI,CAAAA,CAAOC,GAAQ,CAAA,CAAIF,kBAAAA,CAAmB,CAC3C,KAAA,CAAOH,GAAAA,EAAO,OAAS,EAAC,CACxB,YAAA,CAAcA,GAAAA,EAAO,cAAgB,EAAC,CACtC,QAAA,CAAUA,GAAAA,EAAO,aACnB,CAAC,CAAA,CAIK,CAACM,CAAAA,CAAcC,CAAe,CAAA,CAAU,CAAA,CAAA,QAAA,CAAkB,EAAE,CAAA,CAC5DC,CAAAA,CAAyB,CAAA,CAAA,MAAA,CAAoB,IAAI,GAAK,CAAA,CAEtD,CAAA,CAAA,SAAA,CAAU,IAAM,CACpB,IAAMC,CAAAA,CAAgB,IAAI,GAAA,CAAIL,CAAAA,CAAM,GAAA,CAAKM,CAAAA,E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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,CAAAA,CACH,GACF,CAAA,CACF,CAAA,CAEFa,GAAAA,CAACoB,CAAAA,CAAA,CAAwB,GAAGnD,GAAAA,CAAgB,CAAA,CAAA,CAC9C,CAAA,CAAA,CACF,GACF,CAEJ","file":"chunk-ON7PUZWI.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 ComboboxItemTitle\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 <ComboboxItemTitle>\r\n {item.label}\r\n </ComboboxItemTitle>\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,2 +1,2 @@
|
|
|
1
|
-
import {c,d,e,f,g,m,h,i,n,o,p,q as q$1,r,s,t,j as j$1,k,l,u,v}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {c,d,e,f,g,m,h,i,n,o,p,q as q$1,r,s,t,j as j$1,k,l,u,v}from'./chunk-JYFVQ5NY.js';import'react';import {cn}from'@xploreu/lib/cn';import {CheckIcon,CircleIcon,ChevronRightIcon}from'lucide-react';import {jsx,jsxs}from'react/jsx-runtime';function O(e){return jsx(c,{...e})}function j(e){return jsx(d,{...e})}function T(e$1){return jsx(e,{...e$1})}function q({className:e,finalFocus:t,id:i,children:n,sideOffset:o=4,transition:a={duration:.2},...p}){return jsx(T,{children:jsx(f,{className:"z-50",sideOffset:o,...p,children:jsx(g,{finalFocus:t,id:i,transition:a,className:cn("bg-bg-primary text-text-primary max-h-(--available-height) min-w-[8rem] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border-primary p-1 shadow-xp-lg outline-hidden",e),children:jsx(m,{className:"absolute inset-0 z-0 rounded-sm bg-bg-primary-hover",children:n})})})})}function B(e){return jsx(h,{...e})}function D({className:e,inset:t,...i$1}){return jsx(i,{"data-inset":t,className:cn("px-2 py-1.5 text-label-semibold-4 text-text-secondary data-[inset]:pl-8",e),...i$1})}function E({className:e,inset:t,variant:i="default",disabled:n$1,...o$1}){return jsx(n,{activeClassName:i==="destructive"?"bg-bg-error-primary":"",disabled:n$1,children:jsx(o,{disabled:n$1,"data-inset":t,"data-variant":i,className:cn("focus:text-text-primary data-[variant=destructive]:text-text-error-primary data-[variant=destructive]:focus:text-text-error-primary data-[variant=destructive]:*:[svg]:!text-fg-error-primary [&_svg:not([class*='text-'])]:text-fg-secondary relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-body-regular-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...o$1})})}function J({className:e,children:t,checked:i,disabled:n$1,...o}){return jsx(n,{disabled:n$1,children:jsxs(p,{disabled:n$1,className:cn("focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-body-regular outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:i,...o,children:[jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:jsx(q$1,{animate:{opacity:1,scale:1},initial:{opacity:0,scale:.5},children:jsx(CheckIcon,{className:"size-4"})})}),t]})})}function K(e){return jsx(r,{...e})}function Q({className:e,children:t$1,disabled:i,...n$1}){return jsx(n,{disabled:i,children:jsxs(s,{disabled:i,className:cn("focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-body-regular outline-hidden select-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...n$1,children:[jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:jsx(t,{layoutId:"menu-item-indicator-radio",children:jsx(CircleIcon,{className:"size-2 fill-current"})})}),t$1]})})}function U({className:e,...t}){return jsx(j$1,{className:cn("-mx-1 my-1 h-px bg-border-primary",e),...t})}function V({className:e,...t}){return jsx(k,{className:cn("text-text-quaternary ml-auto text-body-regular-xs tracking-widest",e),...t})}function W(e){return jsx(l,{...e})}function X(e){return jsx(u,{...e})}function Y({disabled:e,className:t,inset:i,children:n$1,...o}){return jsx(n,{disabled:e,children:jsxs(v,{disabled:e,"data-inset":i,className:cn("focus:text-text-primary data-[state=open]:text-text-primary flex cursor-default items-center rounded-sm px-2 py-1.5 text-body-regular outline-hidden select-none data-[inset]:pl-8","aria-[expanded=true]:[&_[data-slot=chevron]]:rotate-90 [&_[data-slot=chevron]]:transition-transform [&_[data-slot=chevron]]:duration-300 [&_[data-slot=chevron]]:ease-in-out",t),...o,children:[n$1,jsx(ChevronRightIcon,{"data-slot":"chevron",className:"ml-auto size-4"})]})})}function Z({className:e,finalFocus:t,id:i,children:n,sideOffset:o=4,transition:a={duration:.2},...p}){return jsx(T,{children:jsx(f,{className:"z-50",sideOffset:o,...p,children:jsx(g,{finalFocus:t,id:i,transition:a,className:cn("bg-bg-primary text-text-primary max-h-(--available-height) min-w-[8rem] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border-primary p-1 shadow-xp-lg",e),children:n})})})}export{O as a,j as b,T as c,q as d,B as e,D as f,E as g,J as h,K as i,Q as j,U as k,V as l,W as m,X as n,Y as o,Z as p};//# sourceMappingURL=chunk-VODPMAOM.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-VODPMAOM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ui/menu.tsx"],"names":["Menu","props","jsx","MenuTrigger","MenuPortal","MenuPanel","className","finalFocus","id","children","sideOffset","transition","MenuPositioner","MenuPopup","cn","MenuHighlight","MenuGroup","MenuGroupLabel","inset","MenuItem","variant","disabled","MenuHighlightItem","MenuCheckboxItem","checked","jsxs","MenuCheckboxItemIndicator","CheckIcon","MenuRadioGroup","MenuRadioItem","MenuRadioItemIndicator","CircleIcon","MenuSeparator","MenuShortcut","MenuArrow","MenuSubmenu","MenuSubmenuTrigger","ChevronRightIcon","MenuSubmenuPanel"],"mappings":"iPAmDA,SAASA,CAAAA,CAAKC,CAAAA,CAAkB,CAC9B,OAAOC,GAAAA,CAACF,CAAAA,C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AGV,CACL,CAAA,CAA0B,CACxB,OACEC,GAAAA,CAACE,CAAAA,CAAA,CACC,QAAA,CAAAF,GAAAA,CAACU,CAAAA,CAAA,CACC,SAAA,CAAU,MAAA,CACV,UAAA,CAAYF,CAAAA,CACX,GAAGT,CAAAA,CAEJ,QAAA,CAAAC,GAAAA,CAACW,CAAAA,CAAA,CACC,UAAA,CAAYN,CAAAA,CACZ,EAAA,CAAIC,CAAAA,CACJ,UAAA,CAAYG,CAAAA,CACZ,SAAA,CAAWG,EAAAA,CACT,gMAAA,CACAR,CACF,CAAA,CAEC,QAAA,CAAAG,CAAAA,CACH,CAAA,CACF,EACF,CAEJ","file":"chunk-V2D72N26.js","sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\n\r\nimport {\r\n Menu as MenuPrimitive,\r\n MenuArrow as MenuArrowPrimitive,\r\n MenuCheckboxItem as MenuCheckboxItemPrimitive,\r\n MenuCheckboxItemIndicator as MenuCheckboxItemIndicatorPrimitive,\r\n MenuGroup as MenuGroupPrimitive,\r\n MenuGroupLabel as MenuGroupLabelPrimitive,\r\n MenuHighlight as MenuHighlightPrimitive,\r\n MenuHighlightItem as MenuHighlightItemPrimitive,\r\n MenuItem as MenuItemPrimitive,\r\n MenuPortal as MenuPortalPrimitive,\r\n MenuPopup as MenuPopupPrimitive,\r\n MenuPositioner as MenuPositionerPrimitive,\r\n MenuRadioGroup as MenuRadioGroupPrimitive,\r\n MenuRadioItem as MenuRadioItemPrimitive,\r\n MenuRadioItemIndicator as MenuRadioItemIndicatorPrimitive,\r\n MenuSeparator as MenuSeparatorPrimitive,\r\n MenuShortcut as MenuShortcutPrimitive,\r\n MenuSubmenu as MenuSubmenuPrimitive,\r\n MenuSubmenuTrigger as MenuSubmenuTriggerPrimitive,\r\n MenuTrigger as MenuTriggerPrimitive,\r\n type MenuArrowProps as MenuArrowPrimitiveProps,\r\n type MenuCheckboxItemIndicatorProps as MenuCheckboxItemIndicatorPrimitiveProps,\r\n type MenuCheckboxItemProps as MenuCheckboxItemPrimitiveProps,\r\n type MenuGroupLabelProps as MenuGroupLabelPrimitiveProps,\r\n type MenuGroupProps as MenuGroupPrimitiveProps,\r\n type MenuHighlightItemProps as MenuHighlightItemPrimitiveProps,\r\n type MenuHighlightProps as MenuHighlightPrimitiveProps,\r\n type MenuItemProps as MenuItemPrimitiveProps,\r\n type MenuPopupProps as MenuPopupPrimitiveProps,\r\n type MenuPortalProps as MenuPortalPrimitiveProps,\r\n type MenuPositionerProps as MenuPositionerPrimitiveProps,\r\n type MenuProps as MenuPrimitiveProps,\r\n type MenuRadioGroupProps as MenuRadioGroupPrimitiveProps,\r\n type MenuRadioItemProps as MenuRadioItemPrimitiveProps,\r\n type MenuRadioItemIndicatorProps as MenuRadioItemIndicatorPrimitiveProps,\r\n type MenuSeparatorProps as MenuSeparatorPrimitiveProps,\r\n type MenuShortcutProps as MenuShortcutPrimitiveProps,\r\n type MenuSubmenuProps as MenuSubmenuPrimitiveProps,\r\n type MenuSubmenuTriggerProps as MenuSubmenuTriggerPrimitiveProps,\r\n type MenuTriggerProps as MenuTriggerPrimitiveProps,\r\n} from \"../primitives/menu\"\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport { CheckIcon, ChevronRightIcon, CircleIcon } from \"lucide-react\"\r\n\r\ntype MenuProps = MenuPrimitiveProps\r\n\r\nfunction Menu(props: MenuProps) {\r\n return <MenuPrimitive {...props} />\r\n}\r\n\r\ntype MenuTriggerProps = MenuTriggerPrimitiveProps\r\n\r\nfunction MenuTrigger(props: MenuTriggerProps) {\r\n return <MenuTriggerPrimitive {...props} />\r\n}\r\n\r\ntype MenuPortalProps = MenuPortalPrimitiveProps\r\n\r\nfunction MenuPortal(props: MenuPortalProps) {\r\n return <MenuPortalPrimitive {...props} />\r\n}\r\n\r\ntype MenuPanelProps = MenuPopupPrimitiveProps & MenuPositionerPrimitiveProps\r\n\r\nfunction MenuPanel({\r\n className,\r\n finalFocus,\r\n id,\r\n children,\r\n sideOffset = 4,\r\n transition = { duration: 0.2 },\r\n ...props\r\n}: MenuPanelProps) {\r\n return (\r\n <MenuPortal>\r\n <MenuPositionerPrimitive\r\n className=\"z-50\"\r\n sideOffset={sideOffset}\r\n {...props}\r\n >\r\n <MenuPopupPrimitive\r\n finalFocus={finalFocus}\r\n id={id}\r\n transition={transition}\r\n className={cn(\r\n \"bg-bg-primary text-text-primary max-h-(--available-height) min-w-[8rem] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border-primary p-1 shadow-xp-lg outline-hidden\",\r\n className,\r\n )}\r\n >\r\n <MenuHighlightPrimitive className=\"absolute inset-0 z-0 rounded-sm bg-bg-primary-hover\">\r\n {children}\r\n </MenuHighlightPrimitive>\r\n </MenuPopupPrimitive>\r\n </MenuPositionerPrimitive>\r\n </MenuPortal>\r\n )\r\n}\r\n\r\ntype MenuGroupProps = MenuGroupPrimitiveProps\r\n\r\nfunction MenuGroup(props: MenuGroupProps) {\r\n return <MenuGroupPrimitive {...props} />\r\n}\r\n\r\ntype MenuGroupLabelProps = MenuGroupLabelPrimitiveProps & {\r\n inset?: boolean;\r\n}\r\n\r\nfunction MenuGroupLabel({ className, inset, ...props }: MenuGroupLabelProps) {\r\n return (\r\n <MenuGroupLabelPrimitive\r\n data-inset={inset}\r\n className={cn(\r\n \"px-2 py-1.5 text-label-semibold-4 text-text-secondary data-[inset]:pl-8\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuItemProps = MenuItemPrimitiveProps & {\r\n inset?: boolean;\r\n variant?: \"default\" | \"destructive\";\r\n}\r\n\r\nfunction MenuItem({\r\n className,\r\n inset,\r\n variant = \"default\",\r\n disabled,\r\n ...props\r\n}: MenuItemProps) {\r\n return (\r\n <MenuHighlightItemPrimitive\r\n activeClassName={\r\n variant === \"destructive\" ? \"bg-bg-error-primary\" : \"\"\r\n }\r\n disabled={disabled}\r\n >\r\n <MenuItemPrimitive\r\n disabled={disabled}\r\n data-inset={inset}\r\n data-variant={variant}\r\n className={cn(\r\n \"focus:text-text-primary data-[variant=destructive]:text-text-error-primary data-[variant=destructive]:focus:text-text-error-primary data-[variant=destructive]:*:[svg]:!text-fg-error-primary [&_svg:not([class*='text-'])]:text-fg-secondary relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-body-regular-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n </MenuHighlightItemPrimitive>\r\n )\r\n}\r\n\r\ntype MenuCheckboxItemProps = MenuCheckboxItemPrimitiveProps\r\n\r\nfunction MenuCheckboxItem({\r\n className,\r\n children,\r\n checked,\r\n disabled,\r\n ...props\r\n}: MenuCheckboxItemProps) {\r\n return (\r\n <MenuHighlightItemPrimitive disabled={disabled}>\r\n <MenuCheckboxItemPrimitive\r\n disabled={disabled}\r\n className={cn(\r\n \"focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-body-regular outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\r\n className,\r\n )}\r\n checked={checked}\r\n {...props}\r\n >\r\n <span className=\"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center\">\r\n <MenuCheckboxItemIndicatorPrimitive\r\n animate={{ opacity: 1, scale: 1 }}\r\n initial={{ opacity: 0, scale: 0.5 }}\r\n >\r\n <CheckIcon className=\"size-4\" />\r\n </MenuCheckboxItemIndicatorPrimitive>\r\n </span>\r\n {children}\r\n </MenuCheckboxItemPrimitive>\r\n </MenuHighlightItemPrimitive>\r\n )\r\n}\r\n\r\ntype MenuRadioGroupProps = MenuRadioGroupPrimitiveProps\r\n\r\nfunction MenuRadioGroup(props: MenuRadioGroupProps) {\r\n return <MenuRadioGroupPrimitive {...props} />\r\n}\r\n\r\ntype MenuRadioItemProps = MenuRadioItemPrimitiveProps\r\n\r\nfunction MenuRadioItem({\r\n className,\r\n children,\r\n disabled,\r\n ...props\r\n}: MenuRadioItemProps) {\r\n return (\r\n <MenuHighlightItemPrimitive disabled={disabled}>\r\n <MenuRadioItemPrimitive\r\n disabled={disabled}\r\n className={cn(\r\n \"focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-body-regular outline-hidden select-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\r\n className,\r\n )}\r\n {...props}\r\n >\r\n <span className=\"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center\">\r\n <MenuRadioItemIndicatorPrimitive layoutId=\"menu-item-indicator-radio\">\r\n <CircleIcon className=\"size-2 fill-current\" />\r\n </MenuRadioItemIndicatorPrimitive>\r\n </span>\r\n {children}\r\n </MenuRadioItemPrimitive>\r\n </MenuHighlightItemPrimitive>\r\n )\r\n}\r\n\r\ntype MenuSeparatorProps = MenuSeparatorPrimitiveProps\r\n\r\nfunction MenuSeparator({ className, ...props }: MenuSeparatorProps) {\r\n return (\r\n <MenuSeparatorPrimitive\r\n className={cn(\"-mx-1 my-1 h-px bg-border-primary\", className)}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuShortcutProps = MenuShortcutPrimitiveProps\r\n\r\nfunction MenuShortcut({ className, ...props }: MenuShortcutProps) {\r\n return (\r\n <MenuShortcutPrimitive\r\n className={cn(\r\n \"text-text-quaternary ml-auto text-body-regular-xs tracking-widest\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuArrowProps = MenuArrowPrimitiveProps\r\n\r\nfunction MenuArrow(props: MenuArrowProps) {\r\n return <MenuArrowPrimitive {...props} />\r\n}\r\n\r\ntype MenuSubmenuProps = MenuSubmenuPrimitiveProps\r\n\r\nfunction MenuSubmenu(props: MenuSubmenuProps) {\r\n return <MenuSubmenuPrimitive {...props} />\r\n}\r\n\r\ntype MenuSubmenuTriggerProps = MenuSubmenuTriggerPrimitiveProps & {\r\n inset?: boolean;\r\n children?: React.ReactNode;\r\n}\r\n\r\nfunction MenuSubmenuTrigger({\r\n disabled,\r\n className,\r\n inset,\r\n children,\r\n ...props\r\n}: MenuSubmenuTriggerProps) {\r\n return (\r\n <MenuHighlightItemPrimitive disabled={disabled}>\r\n <MenuSubmenuTriggerPrimitive\r\n disabled={disabled}\r\n data-inset={inset}\r\n className={cn(\r\n \"focus:text-text-primary data-[state=open]:text-text-primary flex cursor-default items-center rounded-sm px-2 py-1.5 text-body-regular outline-hidden select-none data-[inset]:pl-8\",\r\n \"aria-[expanded=true]:[&_[data-slot=chevron]]:rotate-90 [&_[data-slot=chevron]]:transition-transform [&_[data-slot=chevron]]:duration-300 [&_[data-slot=chevron]]:ease-in-out\",\r\n className,\r\n )}\r\n {...props}\r\n >\r\n {children}\r\n <ChevronRightIcon\r\n data-slot=\"chevron\"\r\n className=\"ml-auto size-4\"\r\n />\r\n </MenuSubmenuTriggerPrimitive>\r\n </MenuHighlightItemPrimitive>\r\n )\r\n}\r\n\r\ntype MenuSubmenuPanelProps = MenuPopupPrimitiveProps &\r\n MenuPositionerPrimitiveProps\r\n\r\nfunction MenuSubmenuPanel({\r\n className,\r\n finalFocus,\r\n id,\r\n children,\r\n sideOffset = 4,\r\n transition = { duration: 0.2 },\r\n ...props\r\n}: MenuSubmenuPanelProps) {\r\n return (\r\n <MenuPortal>\r\n <MenuPositionerPrimitive\r\n className=\"z-50\"\r\n sideOffset={sideOffset}\r\n {...props}\r\n >\r\n <MenuPopupPrimitive\r\n finalFocus={finalFocus}\r\n id={id}\r\n transition={transition}\r\n className={cn(\r\n \"bg-bg-primary text-text-primary max-h-(--available-height) min-w-[8rem] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border-primary p-1 shadow-xp-lg\",\r\n className,\r\n )}\r\n >\r\n {children}\r\n </MenuPopupPrimitive>\r\n </MenuPositionerPrimitive>\r\n </MenuPortal>\r\n )\r\n}\r\n\r\nexport {\r\n Menu,\r\n MenuTrigger,\r\n MenuPortal,\r\n MenuPanel,\r\n MenuGroup,\r\n MenuGroupLabel,\r\n MenuItem,\r\n MenuCheckboxItem,\r\n MenuRadioGroup,\r\n MenuRadioItem,\r\n MenuSeparator,\r\n MenuShortcut,\r\n MenuArrow,\r\n MenuSubmenu,\r\n MenuSubmenuTrigger,\r\n MenuSubmenuPanel,\r\n type MenuProps,\r\n type MenuTriggerProps,\r\n type MenuPortalProps,\r\n type MenuPanelProps,\r\n type MenuGroupProps,\r\n type MenuGroupLabelProps,\r\n type MenuItemProps,\r\n type MenuCheckboxItemProps,\r\n type MenuRadioGroupProps,\r\n type MenuRadioItemProps,\r\n type MenuSeparatorProps,\r\n type MenuShortcutProps,\r\n type MenuArrowProps,\r\n type MenuSubmenuProps,\r\n type MenuSubmenuTriggerProps,\r\n type MenuSubmenuPanelProps,\r\n}"]}
|
|
1
|
+
{"version":3,"sources":["../src/ui/menu.tsx"],"names":["Menu","props","jsx","MenuTrigger","MenuPortal","MenuPanel","className","finalFocus","id","children","sideOffset","transition","MenuPositioner","MenuPopup","cn","MenuHighlight","MenuGroup","MenuGroupLabel","inset","MenuItem","variant","disabled","MenuHighlightItem","MenuCheckboxItem","checked","jsxs","MenuCheckboxItemIndicator","CheckIcon","MenuRadioGroup","MenuRadioItem","MenuRadioItemIndicator","CircleIcon","MenuSeparator","MenuShortcut","MenuArrow","MenuSubmenu","MenuSubmenuTrigger","ChevronRightIcon","MenuSubmenuPanel"],"mappings":"iPAmDA,SAASA,CAAAA,CAAKC,CAAAA,CAAkB,CAC9B,OAAOC,GAAAA,CAACF,CAAAA,CAAA,CAAe,GAAGC,CAAAA,CAAO,CACnC,CAIA,SAASE,CAAAA,CAAYF,CAAAA,CAAyB,CAC5C,OAAOC,GAAAA,CAACC,CA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C,SAAA,CAAU,MAAA,CACV,UAAA,CAAYF,CAAAA,CACX,GAAGT,CAAAA,CAEJ,QAAA,CAAAC,GAAAA,CAACW,CAAAA,CAAA,CACC,UAAA,CAAYN,CAAAA,CACZ,EAAA,CAAIC,CAAAA,CACJ,UAAA,CAAYG,CAAAA,CACZ,SAAA,CAAWG,EAAAA,CACT,gMAAA,CACAR,CACF,CAAA,CAEC,QAAA,CAAAG,CAAAA,CACH,CAAA,CACF,EACF,CAEJ","file":"chunk-VODPMAOM.js","sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\n\r\nimport {\r\n Menu as MenuPrimitive,\r\n MenuArrow as MenuArrowPrimitive,\r\n MenuCheckboxItem as MenuCheckboxItemPrimitive,\r\n MenuCheckboxItemIndicator as MenuCheckboxItemIndicatorPrimitive,\r\n MenuGroup as MenuGroupPrimitive,\r\n MenuGroupLabel as MenuGroupLabelPrimitive,\r\n MenuHighlight as MenuHighlightPrimitive,\r\n MenuHighlightItem as MenuHighlightItemPrimitive,\r\n MenuItem as MenuItemPrimitive,\r\n MenuPortal as MenuPortalPrimitive,\r\n MenuPopup as MenuPopupPrimitive,\r\n MenuPositioner as MenuPositionerPrimitive,\r\n MenuRadioGroup as MenuRadioGroupPrimitive,\r\n MenuRadioItem as MenuRadioItemPrimitive,\r\n MenuRadioItemIndicator as MenuRadioItemIndicatorPrimitive,\r\n MenuSeparator as MenuSeparatorPrimitive,\r\n MenuShortcut as MenuShortcutPrimitive,\r\n MenuSubmenu as MenuSubmenuPrimitive,\r\n MenuSubmenuTrigger as MenuSubmenuTriggerPrimitive,\r\n MenuTrigger as MenuTriggerPrimitive,\r\n type MenuArrowProps as MenuArrowPrimitiveProps,\r\n type MenuCheckboxItemIndicatorProps as MenuCheckboxItemIndicatorPrimitiveProps,\r\n type MenuCheckboxItemProps as MenuCheckboxItemPrimitiveProps,\r\n type MenuGroupLabelProps as MenuGroupLabelPrimitiveProps,\r\n type MenuGroupProps as MenuGroupPrimitiveProps,\r\n type MenuHighlightItemProps as MenuHighlightItemPrimitiveProps,\r\n type MenuHighlightProps as MenuHighlightPrimitiveProps,\r\n type MenuItemProps as MenuItemPrimitiveProps,\r\n type MenuPopupProps as MenuPopupPrimitiveProps,\r\n type MenuPortalProps as MenuPortalPrimitiveProps,\r\n type MenuPositionerProps as MenuPositionerPrimitiveProps,\r\n type MenuProps as MenuPrimitiveProps,\r\n type MenuRadioGroupProps as MenuRadioGroupPrimitiveProps,\r\n type MenuRadioItemProps as MenuRadioItemPrimitiveProps,\r\n type MenuRadioItemIndicatorProps as MenuRadioItemIndicatorPrimitiveProps,\r\n type MenuSeparatorProps as MenuSeparatorPrimitiveProps,\r\n type MenuShortcutProps as MenuShortcutPrimitiveProps,\r\n type MenuSubmenuProps as MenuSubmenuPrimitiveProps,\r\n type MenuSubmenuTriggerProps as MenuSubmenuTriggerPrimitiveProps,\r\n type MenuTriggerProps as MenuTriggerPrimitiveProps,\r\n} from \"../primitives/menu\"\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport { CheckIcon, ChevronRightIcon, CircleIcon } from \"lucide-react\"\r\n\r\ntype MenuProps = MenuPrimitiveProps\r\n\r\nfunction Menu(props: MenuProps) {\r\n return <MenuPrimitive {...props} />\r\n}\r\n\r\ntype MenuTriggerProps = MenuTriggerPrimitiveProps\r\n\r\nfunction MenuTrigger(props: MenuTriggerProps) {\r\n return <MenuTriggerPrimitive {...props} />\r\n}\r\n\r\ntype MenuPortalProps = MenuPortalPrimitiveProps\r\n\r\nfunction MenuPortal(props: MenuPortalProps) {\r\n return <MenuPortalPrimitive {...props} />\r\n}\r\n\r\ntype MenuPanelProps = MenuPopupPrimitiveProps & MenuPositionerPrimitiveProps\r\n\r\nfunction MenuPanel({\r\n className,\r\n finalFocus,\r\n id,\r\n children,\r\n sideOffset = 4,\r\n transition = { duration: 0.2 },\r\n ...props\r\n}: MenuPanelProps) {\r\n return (\r\n <MenuPortal>\r\n <MenuPositionerPrimitive\r\n className=\"z-50\"\r\n sideOffset={sideOffset}\r\n {...props}\r\n >\r\n <MenuPopupPrimitive\r\n finalFocus={finalFocus}\r\n id={id}\r\n transition={transition}\r\n className={cn(\r\n \"bg-bg-primary text-text-primary max-h-(--available-height) min-w-[8rem] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border-primary p-1 shadow-xp-lg outline-hidden\",\r\n className,\r\n )}\r\n >\r\n <MenuHighlightPrimitive className=\"absolute inset-0 z-0 rounded-sm bg-bg-primary-hover\">\r\n {children}\r\n </MenuHighlightPrimitive>\r\n </MenuPopupPrimitive>\r\n </MenuPositionerPrimitive>\r\n </MenuPortal>\r\n )\r\n}\r\n\r\ntype MenuGroupProps = MenuGroupPrimitiveProps\r\n\r\nfunction MenuGroup(props: MenuGroupProps) {\r\n return <MenuGroupPrimitive {...props} />\r\n}\r\n\r\ntype MenuGroupLabelProps = MenuGroupLabelPrimitiveProps & {\r\n inset?: boolean;\r\n}\r\n\r\nfunction MenuGroupLabel({ className, inset, ...props }: MenuGroupLabelProps) {\r\n return (\r\n <MenuGroupLabelPrimitive\r\n data-inset={inset}\r\n className={cn(\r\n \"px-2 py-1.5 text-label-semibold-4 text-text-secondary data-[inset]:pl-8\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuItemProps = MenuItemPrimitiveProps & {\r\n inset?: boolean;\r\n variant?: \"default\" | \"destructive\";\r\n}\r\n\r\nfunction MenuItem({\r\n className,\r\n inset,\r\n variant = \"default\",\r\n disabled,\r\n ...props\r\n}: MenuItemProps) {\r\n return (\r\n <MenuHighlightItemPrimitive\r\n activeClassName={\r\n variant === \"destructive\" ? \"bg-bg-error-primary\" : \"\"\r\n }\r\n disabled={disabled}\r\n >\r\n <MenuItemPrimitive\r\n disabled={disabled}\r\n data-inset={inset}\r\n data-variant={variant}\r\n className={cn(\r\n \"focus:text-text-primary data-[variant=destructive]:text-text-error-primary data-[variant=destructive]:focus:text-text-error-primary data-[variant=destructive]:*:[svg]:!text-fg-error-primary [&_svg:not([class*='text-'])]:text-fg-secondary relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-body-regular-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n </MenuHighlightItemPrimitive>\r\n )\r\n}\r\n\r\ntype MenuCheckboxItemProps = MenuCheckboxItemPrimitiveProps\r\n\r\nfunction MenuCheckboxItem({\r\n className,\r\n children,\r\n checked,\r\n disabled,\r\n ...props\r\n}: MenuCheckboxItemProps) {\r\n return (\r\n <MenuHighlightItemPrimitive disabled={disabled}>\r\n <MenuCheckboxItemPrimitive\r\n disabled={disabled}\r\n className={cn(\r\n \"focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-body-regular outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\r\n className,\r\n )}\r\n checked={checked}\r\n {...props}\r\n >\r\n <span className=\"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center\">\r\n <MenuCheckboxItemIndicatorPrimitive\r\n animate={{ opacity: 1, scale: 1 }}\r\n initial={{ opacity: 0, scale: 0.5 }}\r\n >\r\n <CheckIcon className=\"size-4\" />\r\n </MenuCheckboxItemIndicatorPrimitive>\r\n </span>\r\n {children}\r\n </MenuCheckboxItemPrimitive>\r\n </MenuHighlightItemPrimitive>\r\n )\r\n}\r\n\r\ntype MenuRadioGroupProps = MenuRadioGroupPrimitiveProps\r\n\r\nfunction MenuRadioGroup(props: MenuRadioGroupProps) {\r\n return <MenuRadioGroupPrimitive {...props} />\r\n}\r\n\r\ntype MenuRadioItemProps = MenuRadioItemPrimitiveProps\r\n\r\nfunction MenuRadioItem({\r\n className,\r\n children,\r\n disabled,\r\n ...props\r\n}: MenuRadioItemProps) {\r\n return (\r\n <MenuHighlightItemPrimitive disabled={disabled}>\r\n <MenuRadioItemPrimitive\r\n disabled={disabled}\r\n className={cn(\r\n \"focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-body-regular outline-hidden select-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\r\n className,\r\n )}\r\n {...props}\r\n >\r\n <span className=\"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center\">\r\n <MenuRadioItemIndicatorPrimitive layoutId=\"menu-item-indicator-radio\">\r\n <CircleIcon className=\"size-2 fill-current\" />\r\n </MenuRadioItemIndicatorPrimitive>\r\n </span>\r\n {children}\r\n </MenuRadioItemPrimitive>\r\n </MenuHighlightItemPrimitive>\r\n )\r\n}\r\n\r\ntype MenuSeparatorProps = MenuSeparatorPrimitiveProps\r\n\r\nfunction MenuSeparator({ className, ...props }: MenuSeparatorProps) {\r\n return (\r\n <MenuSeparatorPrimitive\r\n className={cn(\"-mx-1 my-1 h-px bg-border-primary\", className)}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuShortcutProps = MenuShortcutPrimitiveProps\r\n\r\nfunction MenuShortcut({ className, ...props }: MenuShortcutProps) {\r\n return (\r\n <MenuShortcutPrimitive\r\n className={cn(\r\n \"text-text-quaternary ml-auto text-body-regular-xs tracking-widest\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuArrowProps = MenuArrowPrimitiveProps\r\n\r\nfunction MenuArrow(props: MenuArrowProps) {\r\n return <MenuArrowPrimitive {...props} />\r\n}\r\n\r\ntype MenuSubmenuProps = MenuSubmenuPrimitiveProps\r\n\r\nfunction MenuSubmenu(props: MenuSubmenuProps) {\r\n return <MenuSubmenuPrimitive {...props} />\r\n}\r\n\r\ntype MenuSubmenuTriggerProps = MenuSubmenuTriggerPrimitiveProps & {\r\n inset?: boolean;\r\n children?: React.ReactNode;\r\n}\r\n\r\nfunction MenuSubmenuTrigger({\r\n disabled,\r\n className,\r\n inset,\r\n children,\r\n ...props\r\n}: MenuSubmenuTriggerProps) {\r\n return (\r\n <MenuHighlightItemPrimitive disabled={disabled}>\r\n <MenuSubmenuTriggerPrimitive\r\n disabled={disabled}\r\n data-inset={inset}\r\n className={cn(\r\n \"focus:text-text-primary data-[state=open]:text-text-primary flex cursor-default items-center rounded-sm px-2 py-1.5 text-body-regular outline-hidden select-none data-[inset]:pl-8\",\r\n \"aria-[expanded=true]:[&_[data-slot=chevron]]:rotate-90 [&_[data-slot=chevron]]:transition-transform [&_[data-slot=chevron]]:duration-300 [&_[data-slot=chevron]]:ease-in-out\",\r\n className,\r\n )}\r\n {...props}\r\n >\r\n {children}\r\n <ChevronRightIcon\r\n data-slot=\"chevron\"\r\n className=\"ml-auto size-4\"\r\n />\r\n </MenuSubmenuTriggerPrimitive>\r\n </MenuHighlightItemPrimitive>\r\n )\r\n}\r\n\r\ntype MenuSubmenuPanelProps = MenuPopupPrimitiveProps &\r\n MenuPositionerPrimitiveProps\r\n\r\nfunction MenuSubmenuPanel({\r\n className,\r\n finalFocus,\r\n id,\r\n children,\r\n sideOffset = 4,\r\n transition = { duration: 0.2 },\r\n ...props\r\n}: MenuSubmenuPanelProps) {\r\n return (\r\n <MenuPortal>\r\n <MenuPositionerPrimitive\r\n className=\"z-50\"\r\n sideOffset={sideOffset}\r\n {...props}\r\n >\r\n <MenuPopupPrimitive\r\n finalFocus={finalFocus}\r\n id={id}\r\n transition={transition}\r\n className={cn(\r\n \"bg-bg-primary text-text-primary max-h-(--available-height) min-w-[8rem] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border-primary p-1 shadow-xp-lg\",\r\n className,\r\n )}\r\n >\r\n {children}\r\n </MenuPopupPrimitive>\r\n </MenuPositionerPrimitive>\r\n </MenuPortal>\r\n )\r\n}\r\n\r\nexport {\r\n Menu,\r\n MenuTrigger,\r\n MenuPortal,\r\n MenuPanel,\r\n MenuGroup,\r\n MenuGroupLabel,\r\n MenuItem,\r\n MenuCheckboxItem,\r\n MenuRadioGroup,\r\n MenuRadioItem,\r\n MenuSeparator,\r\n MenuShortcut,\r\n MenuArrow,\r\n MenuSubmenu,\r\n MenuSubmenuTrigger,\r\n MenuSubmenuPanel,\r\n type MenuProps,\r\n type MenuTriggerProps,\r\n type MenuPortalProps,\r\n type MenuPanelProps,\r\n type MenuGroupProps,\r\n type MenuGroupLabelProps,\r\n type MenuItemProps,\r\n type MenuCheckboxItemProps,\r\n type MenuRadioGroupProps,\r\n type MenuRadioItemProps,\r\n type MenuSeparatorProps,\r\n type MenuShortcutProps,\r\n type MenuArrowProps,\r\n type MenuSubmenuProps,\r\n type MenuSubmenuTriggerProps,\r\n type MenuSubmenuPanelProps,\r\n}"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a,j,i,k,l,m,q,s,w,A,x,H}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {a,j,i,k,l,m,q,s,w,A,x,H}from'./chunk-IZQFTYJD.js';import {f,g}from'./chunk-HHG7BSWN.js';import {a as a$1}from'./chunk-JH6RZ3QH.js';import*as r from'react';import {cn}from'@xploreu/lib/cn';import {useControlledState}from'@xploreu/hooks/use-controlled-state';import {jsxs,jsx,Fragment}from'react/jsx-runtime';function $({multiple:G=true,inputPlaceholder:j$1="Search...",container:q$1,items:s$1,infiniteScroll:z,isPending:B,taggable:C=false,maxVisible:b,...m$1}){let[O,F]=useControlledState({value:m$1?.inputValue?.toString(),defaultValue:m$1?.defaultInputValue?.toString(),onChange:m$1?.onInputValueChange}),[i$1,h]=useControlledState({value:m$1?.value??[],defaultValue:m$1?.defaultValue??[],onChange:m$1?.onValueChange}),[I,V]=r.useState([]),p=r.useRef(new Set);r.useEffect(()=>{let e=new Set(i$1.map(a=>a.value));V(a=>{let l=a.filter(o=>e.has(o.value));return l.length===a.length?a:(p.current=new Set(l.map(o=>o.value)),l)});},[i$1]);let t=O?.toString().trim()??"",v=r.useMemo(()=>t?i$1.some(e=>e.value.toLowerCase()===t.toLowerCase()):false,[t,i$1]),c=r.useMemo(()=>!C||!t?false:!s$1?.some(e=>e.label.toLowerCase()===t.toLowerCase()),[C,t,s$1]),H$1=r.useMemo(()=>{let e=[...s$1??[],...I];return c?[...e,{label:t,value:t,tag:true}]:e},[s$1,I,c,t]);return jsxs(a,{...m$1,behavior:"chip-outside",multiple:true,items:C?H$1:s$1,isItemEqualToValue:(e,a)=>e.value===a.value,onValueChange:(e,a)=>{if(C){let l=e.filter(o=>o?.tag===true&&!p.current.has(o.value));if(l.length>0){for(let o of l)p.current.add(o.value);V(o=>[...o,...l]);}}h(G?e:[e[e.length-1]],a);},onInputValueChange:F,children:[jsx(f,{className:cn(a$1(),"h-auto min-h-13 flex flex-wrap items-center gap-1.5 px-3 py-1.5 cursor-text"),children:jsxs(j,{className:cn("contents",b!==void 0&&"flex-nowrap overflow-hidden"),children:[jsx(i,{children:e=>{let a=b!==void 0?e.slice(0,b):e,l$1=b!==void 0?e.length-b:0;return jsxs(Fragment,{children:[a?.map(o=>jsxs(k,{className:cn(b!==void 0&&"min-w-0 shrink"),children:[o?.image&&jsx("img",{src:o.image,alt:o?.label||"",className:"size-4 rounded-full object-cover shrink-0 mr-1"}),b!==void 0?jsx("span",{className:"truncate",children:o?.label||""}):o?.label||"",jsx(l,{})]},o?.value||"")),l$1>0&&jsxs(k,{className:"shrink-0",children:["+",l$1]})]})}}),jsx(g,{render:jsx("input",{className:"flex-1 min-w-[80px] bg-transparent outline-none text-body-regular-1 text-text-primary placeholder:text-text-placeholder",placeholder:i$1.length===0?j$1:void 0})})]})}),jsxs(m,{container:q$1,children:[jsx(q,{status:B||s$1===void 0?"pending":s$1?.length===0&&!c?"empty":null}),jsxs(s,{children:[s$1?.map(e=>jsxs(w,{value:e,children:[e.image!==void 0&&jsx(A,{src:e.image,fallbackText:[e.label?.[0],e.label?.split(" ")?.[1]?.[0]].filter(Boolean).join(""),imageAlt:e.label}),jsx(x,{children:e.label})]},e.value)),c&&jsxs(w,{value:{label:t,value:t,tag:true},children:[!v&&jsxs("span",{className:"text-text-secondary text-body-medium-3 col-start-2",children:["Create: ",t]}),v&&jsx(x,{children:t})]}),jsx(H,{...z})]})]})]})}export{$ as a};//# sourceMappingURL=chunk-WV5OCKQK.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-WV5OCKQK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/composites/combobox-chip.tsx"],"names":["ComboboxChip","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","jsxs","Combobox","a","b","eventDetails","newTags","tag","jsx","ComboboxInputGroup","cn","inputVariants","ComboboxChips","ComboboxValue","visible","overflow","Fragment","ComboboxChipRemove","ComboboxInput","ComboboxPopup","ComboboxStatus","ComboboxList","ComboboxItem","ComboboxItemAvatar","ComboboxItemTitle","ComboboxInfiniteScroll"],"mappings":"2TA+CA,SAASA,CAAAA,CAAyF,CAChG,QAAA,CAAAC,CAAAA,CAAW,KACX,gBAAA,CAAAC,GAAAA,CAAmB,WAAA,CACnB,SAAA,CAAAC,GAAAA,CACA,KAAA,CAAAC,GAAAA,CACA,cAAA,CAAAC,EACA,SAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CAAW,KAAA,CACX,UAAA,CAAAC,CAAAA,CACA,GAAGC,GACL,CAAA,CAA6B,CAC3B,GAAM,CAACC,CAAAA,CAAYC,CAAa,CAAA,CAAIC,kBAAAA,CAAmB,CACrD,KAAA,CAAOH,GAAAA,EAAO,UAAA,EAAY,QAAA,EAAS,CACnC,YAAA,CAAcA,GAAAA,EAAO,iBAAA,EA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ACe,CAAAA,CAAA,CACC,GAAA,CAAK5B,CAAAA,CAAK,KAAA,CACV,YAAA,CAAc,CAACA,CAAAA,CAAK,KAAA,GAAQ,CAAC,CAAA,CAAGA,CAAAA,CAAK,KAAA,EAAO,KAAA,CAAM,GAAG,IAAI,CAAC,CAAA,GAAI,CAAC,CAAC,CAAA,CAAE,MAAA,CAAO,OAAO,CAAA,CAAE,KAAK,EAAE,CAAA,CACzF,QAAA,CAAUA,CAAAA,CAAK,KAAA,CACjB,CAAA,CAEFa,GAAAA,CAACgB,CAAAA,CAAA,CAAmB,QAAA,CAAA7B,CAAAA,CAAK,KAAA,CAAM,CAAA,CAAA,CAAA,CAV1BA,CAAAA,CAAK,KAWZ,CACD,CAAA,CACAG,GACCG,IAAAA,CAACqB,CAAAA,CAAA,CACC,KAAA,CAAO,CAAE,KAAA,CAAO1B,CAAAA,CAAc,KAAA,CAAOA,EAAc,GAAA,CAAK,IAAK,CAAA,CAE5D,QAAA,CAAA,CAAA,CAACC,CAAAA,EACAI,IAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,qDAAqD,QAAA,CAAA,CAAA,UAAA,CAASL,CAAAA,CAAAA,CAAa,CAAA,CAE5FC,CAAAA,EACCW,GAAAA,CAACgB,CAAAA,CAAA,CAAmB,QAAA,CAAA5B,EAAa,CAAA,CAAA,CAErC,CAAA,CAEFY,GAAAA,CAACiB,CAAAA,CAAA,CAAwB,GAAG/C,CAAAA,CAAgB,CAAA,CAAA,CAC9C,CAAA,CAAA,CACF,GACF,CAEJ","file":"chunk-O2V2JJ2V.js","sourcesContent":["import * as React from \"react\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport {\r\n ComboboxInput as ComboboxInputPrimitive,\r\n ComboboxInputGroup,\r\n} from \"../primitives/combobox\"\r\nimport {\r\n Combobox,\r\n ComboboxChip as ComboboxChipUI,\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 ComboboxValue,\r\n type ComboboxProps,\r\n ComboboxItemTitle,\r\n ComboboxItemAvatar\r\n} from \"../ui/combobox\"\r\nimport { useControlledState } from \"@xploreu/hooks/use-controlled-state\"\r\nimport { inputVariants } from \"../ui/input\"\r\n\r\ntype ComboboxChipProps<Value extends { label: string; value: string; image?: string; tag?: true }> = Omit<ComboboxProps<Value, true>, \"multiple\" | \"items\"> & {\r\n multiple?: boolean\r\n inputPlaceholder?: string\r\n container?: React.ComponentProps<typeof ComboboxPortal>[\"container\"]\r\n items?: Value[] | 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 ComboboxChip<Value extends { label: string; value: string; image?: 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}: ComboboxChipProps<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 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\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 return [...base, { label: trimmedInput, value: trimmedInput, tag: true } as unknown as Value]\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 if (taggable) {\r\n const newTags = value.filter(\r\n (v) => v?.tag === true && !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) {\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 {/* Input box with chips inside */}\r\n <ComboboxInputGroup\r\n className={cn(\r\n inputVariants(),\r\n \"h-auto min-h-13 flex flex-wrap items-center gap-1.5 px-3 py-1.5 cursor-text\"\r\n )}\r\n >\r\n {/* Chips inside the input box */}\r\n <ComboboxChips\r\n className={cn(\r\n \"contents\",\r\n maxVisible !== undefined && \"flex-nowrap overflow-hidden\"\r\n )}\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 <ComboboxChipUI\r\n key={item?.value || \"\"}\r\n className={cn(maxVisible !== undefined && \"min-w-0 shrink\")}\r\n >\r\n {item?.image && (\r\n <img\r\n src={item.image}\r\n alt={item?.label || \"\"}\r\n className=\"size-4 rounded-full object-cover shrink-0 mr-1\"\r\n />\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 </ComboboxChipUI>\r\n ))}\r\n {overflow > 0 && (\r\n <ComboboxChipUI className=\"shrink-0\">\r\n +{overflow}\r\n </ComboboxChipUI>\r\n )}\r\n </>\r\n )\r\n }}\r\n </ComboboxValue>\r\n {/* Text input — shrinks to fit remaining space (inside Chips so backspace works) */}\r\n <ComboboxInputPrimitive\r\n render={\r\n <input\r\n className=\"flex-1 min-w-[80px] bg-transparent outline-none text-body-regular-1 text-text-primary placeholder:text-text-placeholder\"\r\n placeholder={value.length === 0 ? inputPlaceholder : undefined}\r\n />\r\n }\r\n />\r\n </ComboboxChips>\r\n </ComboboxInputGroup>\r\n\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={item as Value}\r\n >\r\n {(item.image !== undefined) && (\r\n <ComboboxItemAvatar\r\n src={item.image}\r\n fallbackText={[item.label?.[0], item.label?.split(\" \")?.[1]?.[0]].filter(Boolean).join(\"\")}\r\n imageAlt={item.label}\r\n />\r\n )}\r\n <ComboboxItemTitle>{item.label}</ComboboxItemTitle>\r\n </ComboboxItem>\r\n ))}\r\n {isCreatingItem && (\r\n <ComboboxItem\r\n value={{ label: trimmedInput, value: trimmedInput, tag: true }}\r\n >\r\n {!isInputSelected && (\r\n <span className=\"text-text-secondary text-body-medium-3 col-start-2\">Create: {trimmedInput}</span>\r\n )}\r\n {isInputSelected && (\r\n <ComboboxItemTitle>{trimmedInput}</ComboboxItemTitle>\r\n )}\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 { ComboboxChip }\r\nexport type { ComboboxChipProps }\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/composites/combobox-chip.tsx"],"names":["ComboboxChip","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","jsxs","Combobox","a","b","eventDetails","newTags","tag","jsx","ComboboxInputGroup","cn","inputVariants","ComboboxChips","ComboboxValue","visible","overflow","Fragment","ComboboxChipRemove","ComboboxInput","ComboboxPopup","ComboboxStatus","ComboboxList","ComboboxItem","ComboboxItemAvatar","ComboboxItemTitle","ComboboxInfiniteScroll"],"mappings":"2TA+CA,SAASA,CAAAA,CAAyF,CAChG,QAAA,CAAAC,CAAAA,CAAW,KACX,gBAAA,CAAAC,GAAAA,CA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AA,CAAA,CAAwB,GAAG/C,CAAAA,CAAgB,CAAA,CAAA,CAC9C,CAAA,CAAA,CACF,GACF,CAEJ","file":"chunk-WV5OCKQK.js","sourcesContent":["import * as React from \"react\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport {\r\n ComboboxInput as ComboboxInputPrimitive,\r\n ComboboxInputGroup,\r\n} from \"../primitives/combobox\"\r\nimport {\r\n Combobox,\r\n ComboboxChip as ComboboxChipUI,\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 ComboboxValue,\r\n type ComboboxProps,\r\n ComboboxItemTitle,\r\n ComboboxItemAvatar\r\n} from \"../ui/combobox\"\r\nimport { useControlledState } from \"@xploreu/hooks/use-controlled-state\"\r\nimport { inputVariants } from \"../ui/input\"\r\n\r\ntype ComboboxChipProps<Value extends { label: string; value: string; image?: string; tag?: true }> = Omit<ComboboxProps<Value, true>, \"multiple\" | \"items\"> & {\r\n multiple?: boolean\r\n inputPlaceholder?: string\r\n container?: React.ComponentProps<typeof ComboboxPortal>[\"container\"]\r\n items?: Value[] | 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 ComboboxChip<Value extends { label: string; value: string; image?: 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}: ComboboxChipProps<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 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\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 return [...base, { label: trimmedInput, value: trimmedInput, tag: true } as unknown as Value]\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 if (taggable) {\r\n const newTags = value.filter(\r\n (v) => v?.tag === true && !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) {\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 {/* Input box with chips inside */}\r\n <ComboboxInputGroup\r\n className={cn(\r\n inputVariants(),\r\n \"h-auto min-h-13 flex flex-wrap items-center gap-1.5 px-3 py-1.5 cursor-text\"\r\n )}\r\n >\r\n {/* Chips inside the input box */}\r\n <ComboboxChips\r\n className={cn(\r\n \"contents\",\r\n maxVisible !== undefined && \"flex-nowrap overflow-hidden\"\r\n )}\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 <ComboboxChipUI\r\n key={item?.value || \"\"}\r\n className={cn(maxVisible !== undefined && \"min-w-0 shrink\")}\r\n >\r\n {item?.image && (\r\n <img\r\n src={item.image}\r\n alt={item?.label || \"\"}\r\n className=\"size-4 rounded-full object-cover shrink-0 mr-1\"\r\n />\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 </ComboboxChipUI>\r\n ))}\r\n {overflow > 0 && (\r\n <ComboboxChipUI className=\"shrink-0\">\r\n +{overflow}\r\n </ComboboxChipUI>\r\n )}\r\n </>\r\n )\r\n }}\r\n </ComboboxValue>\r\n {/* Text input — shrinks to fit remaining space (inside Chips so backspace works) */}\r\n <ComboboxInputPrimitive\r\n render={\r\n <input\r\n className=\"flex-1 min-w-[80px] bg-transparent outline-none text-body-regular-1 text-text-primary placeholder:text-text-placeholder\"\r\n placeholder={value.length === 0 ? inputPlaceholder : undefined}\r\n />\r\n }\r\n />\r\n </ComboboxChips>\r\n </ComboboxInputGroup>\r\n\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={item as Value}\r\n >\r\n {(item.image !== undefined) && (\r\n <ComboboxItemAvatar\r\n src={item.image}\r\n fallbackText={[item.label?.[0], item.label?.split(\" \")?.[1]?.[0]].filter(Boolean).join(\"\")}\r\n imageAlt={item.label}\r\n />\r\n )}\r\n <ComboboxItemTitle>{item.label}</ComboboxItemTitle>\r\n </ComboboxItem>\r\n ))}\r\n {isCreatingItem && (\r\n <ComboboxItem\r\n value={{ label: trimmedInput, value: trimmedInput, tag: true }}\r\n >\r\n {!isInputSelected && (\r\n <span className=\"text-text-secondary text-body-medium-3 col-start-2\">Create: {trimmedInput}</span>\r\n )}\r\n {isInputSelected && (\r\n <ComboboxItemTitle>{trimmedInput}</ComboboxItemTitle>\r\n )}\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 { ComboboxChip }\r\nexport type { ComboboxChipProps }\r\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a as a$1,b,m,e,q,s,w}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {a as a$1,b,m,e,q,s,w}from'./chunk-IZQFTYJD.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,options:s$1,onChange:i}){let[c,r]=t.useState(false),[b$1,g]=t.useState(""),[y,N]=t.useState(0),v=t.useRef(null),m$1=t.useMemo(()=>s$1.filter(e=>!!e.value),[s$1]),u=t.useMemo(()=>{let e=b$1.trim().toLowerCase();return e?m$1.filter(a=>{let f=C.getCountryCallingCode(a.value);return a.label.toLowerCase().includes(e)||a.value.toLowerCase().includes(e)||f.includes(e.replace(/^\+/,""))}):m$1},[b$1,m$1]),_=t.useMemo(()=>m$1.find(e=>e.value===o)??null,[m$1,o]);t.useEffect(()=>{N(0),v.current&&(v.current.scrollTop=0);},[b$1]);let z=Math.min(u.length*d,k),h=t.useMemo(()=>{let e=Math.floor(y/d),a=Math.max(0,e-H),f=Math.ceil(k/d),P=Math.min(u.length,e+f+H);return {startIndex:a,endIndex:P,items:u.slice(a,P)}},[u,y]),F=h.startIndex*d,U=Math.max(0,(u.length-h.endIndex)*d),q$1=t.useCallback(e=>{e?.value&&(i(e.value),g(""),r(false));},[i]);return jsxs(a$1,{behavior:"default",disabled:l,inputValue:b$1,items:u,open:c,value:_,virtualized:true,filter:null,isItemEqualToValue:(e,a)=>e.value===a.value,openOnInputClick:false,onValueChange:q$1,onInputValueChange:g,onOpenChange:e=>{r(e),e||g("");},children:[jsx(b,{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,countryName:o}),o&&jsx("span",{className:"text-body-medium-3 text-text-primary",children:o})]}),jsx(ChevronsUpDownIcon,{className:"size-3.5 shrink-0 text-fg-quaternary"})]})}),jsxs(m,{className:"w-72",children:[jsx(e,{placeholder:"Search country...","aria-label":"Search country"}),jsx(q,{status:u.length===0?"empty":null}),jsx(s,{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(w,{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-YB74L6RO.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-YB74L6RO.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":"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,CAAAA,CACP,QAASC,GAAAA,CACT,QAAA,CAAAC,CACF,CAAA,CAAuB,CACrB,GAAM,CAACC,CAAAA,CAAMC,CAAO,CAAA,CAAU,CAAA,CAAA,QAAA,CAAS,KAAK,CAAA,CACtC,CAACC,GAAAA,CAAYC,CAAa,CAAA,CAAU,CAAA,CAAA,QAAA,CAAS,EAAE,CAAA,CAC/C,CAACC,CAAAA,CAAWC,CAAY,EAAU,CAAA,CAAA,QAAA,CAAS,CAAC,CAAA,CAC5CC,CAAAA,CAAgB,SAAuB,IAAI,CAAA,CAE3CC,GA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EA,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-H2BHLGW2.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,CAAAA,CACP,QAASC,GAAAA,CACT,QAAA,CAAAC,CACF,CAAA,CAAuB,CACrB,GAAM,CAACC,CAAAA,CAAMC,CAAO,CAAA,CAAU,CAAA,CAAA,QAAA,CAAS,KAAK,CAAA,CACtC,CAACC,GAAAA,CAAYC,CAAa,CAAA,CAAU,CAAA,CAAA,QAAA,CAAS,EAAE,CAAA,CAC/C,CAACC,CAAAA,CAAWC,CAAY,EAAU,CAAA,CAAA,QAAA,CAAS,CAAC,CAAA,CAC5CC,CAAAA,CAAgB,SAAuB,IAAI,CAAA,CAE3CC,GAAAA,CAAc,CAAA,CAAA,OAAA,C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,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-YB74L6RO.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"]}
|