@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
1 lines • 1.94 kB
Source Map (JSON)
{"version":3,"file":"ComboboxDropdownTarget.cjs","names":["factory","useProps","isElement","Popover"],"sources":["../../../../src/components/Combobox/ComboboxDropdownTarget/ComboboxDropdownTarget.tsx"],"sourcesContent":["import { factory, Factory, isElement, useProps } from '../../../core';\nimport { Popover } from '../../Popover';\nimport { useComboboxContext } from '../Combobox.context';\n\nexport interface ComboboxDropdownTargetProps {\n ref?: React.RefObject<HTMLElement>;\n\n /** Target element */\n children: React.ReactNode;\n\n /** Key of the prop that should be used to access element ref */\n refProp?: string;\n}\n\nconst defaultProps = {\n refProp: 'ref',\n} satisfies Partial<ComboboxDropdownTargetProps>;\n\nexport type ComboboxDropdownTargetFactory = Factory<{\n props: ComboboxDropdownTargetProps;\n ref: HTMLElement;\n compound: true;\n}>;\n\nexport const ComboboxDropdownTarget = factory<ComboboxDropdownTargetFactory>((props) => {\n const { children, refProp, ref } = useProps('ComboboxDropdownTarget', defaultProps, props);\n\n // Context not used, just to throw error if used outside of Combobox\n useComboboxContext();\n\n if (!isElement(children)) {\n throw new Error(\n 'Combobox.DropdownTarget component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported'\n );\n }\n\n return (\n <Popover.Target ref={ref} refProp={refProp}>\n {children}\n </Popover.Target>\n );\n});\n\nComboboxDropdownTarget.displayName = '@mantine/core/ComboboxDropdownTarget';\n"],"mappings":";;;;;;;;;AAcA,MAAM,eAAe,EACnB,SAAS,MACX;AAQA,MAAa,yBAAyBA,gBAAAA,SAAwC,UAAU;CACtF,MAAM,EAAE,UAAU,SAAS,QAAQC,kBAAAA,SAAS,0BAA0B,cAAc,KAAK;CAGzF,yBAAA,mBAAmB;CAEnB,IAAI,CAACC,mBAAAA,UAAU,QAAQ,GACrB,MAAM,IAAI,MACR,2KACF;CAGF,OACE,iBAAA,GAAA,kBAAA,KAACC,gBAAAA,QAAQ,QAAT;EAAqB;EAAc;EAChC;CACa,CAAA;AAEpB,CAAC;AAED,uBAAuB,cAAc"}