@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
56 lines (55 loc) • 1.71 kB
JavaScript
"use client";
import { useProps } from "../../../core/MantineProvider/use-props/use-props.mjs";
import { factory } from "../../../core/factory/factory.mjs";
import { Box } from "../../../core/Box/Box.mjs";
import Combobox_module_default from "../Combobox.module.mjs";
import { useComboboxContext } from "../Combobox.context.mjs";
import { useId } from "react";
import { jsx } from "react/jsx-runtime";
//#region packages/@mantine/core/src/components/Combobox/ComboboxOption/ComboboxOption.tsx
const ComboboxOption = factory((_props) => {
const props = useProps("ComboboxOption", null, _props);
const { classNames, className, style, styles, vars, onClick, id, active, onMouseDown, onMouseOver, disabled, selected, mod, ...others } = props;
const ctx = useComboboxContext();
const uuid = useId();
const _id = id || uuid;
return /* @__PURE__ */ jsx(Box, {
...ctx.getStyles("option", {
className,
classNames,
styles,
style
}),
...others,
id: _id,
mod: [
"combobox-option",
{
"combobox-active": active,
"combobox-disabled": disabled,
"combobox-selected": selected
},
mod
],
role: "option",
onClick: (event) => {
if (!disabled) {
ctx.onOptionSubmit?.(props.value, props);
onClick?.(event);
} else event.preventDefault();
},
onMouseDown: (event) => {
event.preventDefault();
onMouseDown?.(event);
},
onMouseOver: (event) => {
if (ctx.resetSelectionOnOptionHover) ctx.store.resetSelectedOption();
onMouseOver?.(event);
}
});
});
ComboboxOption.classes = Combobox_module_default;
ComboboxOption.displayName = "@mantine/core/ComboboxOption";
//#endregion
export { ComboboxOption };
//# sourceMappingURL=ComboboxOption.mjs.map