@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
1 lines • 2.33 kB
Source Map (JSON)
{"version":3,"file":"ComboboxOptions.cjs","names":["factory","useProps","useComboboxContext","Box","classes"],"sources":["../../../../src/components/Combobox/ComboboxOptions/ComboboxOptions.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useId } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n CompoundStylesApiProps,\n ElementProps,\n factory,\n Factory,\n useProps,\n} from '../../../core';\nimport { useComboboxContext } from '../Combobox.context';\nimport classes from '../Combobox.module.css';\n\nexport type ComboboxOptionsStylesNames = 'options';\n\nexport interface ComboboxOptionsProps\n extends BoxProps, CompoundStylesApiProps<ComboboxOptionsFactory>, ElementProps<'div'> {\n /** Id of the element that labels the options list */\n labelledBy?: string;\n}\n\nexport type ComboboxOptionsFactory = Factory<{\n props: ComboboxOptionsProps;\n ref: HTMLDivElement;\n stylesNames: ComboboxOptionsStylesNames;\n compound: true;\n}>;\n\nexport const ComboboxOptions = factory<ComboboxOptionsFactory>((_props) => {\n const props = useProps('ComboboxOptions', null, _props);\n const { classNames, className, style, styles, id, onMouseDown, labelledBy, ...others } = props;\n const ctx = useComboboxContext();\n const _id = useId(id);\n\n useEffect(() => {\n ctx.store.setListId(_id);\n }, [_id]);\n\n return (\n <Box\n {...ctx.getStyles('options', { className, style, classNames, styles })}\n {...others}\n id={_id}\n role=\"listbox\"\n aria-labelledby={labelledBy}\n onMouseDown={(event) => {\n event.preventDefault();\n onMouseDown?.(event);\n }}\n />\n );\n});\n\nComboboxOptions.classes = classes;\nComboboxOptions.displayName = '@mantine/core/ComboboxOptions';\n"],"mappings":";;;;;;;;;;;AA6BA,MAAa,kBAAkBA,gBAAAA,SAAiC,WAAW;CAEzE,MAAM,EAAE,YAAY,WAAW,OAAO,QAAQ,IAAI,aAAa,YAAY,GAAG,WADhEC,kBAAAA,SAAS,mBAAmB,MAAM,OAAO;CAEvD,MAAM,MAAMC,yBAAAA,oBAAoB;CAChC,MAAM,OAAA,GAAA,eAAA,OAAY,GAAG;AAErB,EAAA,GAAA,MAAA,iBAAgB;AACd,MAAI,MAAM,UAAU,IAAI;IACvB,CAAC,IAAI,CAAC;AAET,QACE,iBAAA,GAAA,kBAAA,KAACC,YAAAA,KAAD;EACE,GAAI,IAAI,UAAU,WAAW;GAAE;GAAW;GAAO;GAAY;GAAQ,CAAC;EACtE,GAAI;EACJ,IAAI;EACJ,MAAK;EACL,mBAAiB;EACjB,cAAc,UAAU;AACtB,SAAM,gBAAgB;AACtB,iBAAc,MAAM;;EAEtB,CAAA;EAEJ;AAEF,gBAAgB,UAAUC,wBAAAA;AAC1B,gBAAgB,cAAc"}