@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
46 lines (45 loc) • 2.23 kB
JavaScript
"use client";
require("../../../_virtual/_rolldown/runtime.cjs");
const require_get_single_element_child = require("../../../core/utils/get-single-element-child/get-single-element-child.cjs");
const require_use_props = require("../../../core/MantineProvider/use-props/use-props.cjs");
const require_factory = require("../../../core/factory/factory.cjs");
const require_Popover = require("../../Popover/Popover.cjs");
const require_Combobox_context = require("../Combobox.context.cjs");
const require_use_combobox_target_props = require("../use-combobox-target-props/use-combobox-target-props.cjs");
let react = require("react");
let _mantine_hooks = require("@mantine/hooks");
let react_jsx_runtime = require("react/jsx-runtime");
//#region packages/@mantine/core/src/components/Combobox/ComboboxTarget/ComboboxTarget.tsx
const defaultProps = {
refProp: "ref",
targetType: "input",
withKeyboardNavigation: true,
withAriaAttributes: true,
withExpandedAttribute: false,
autoComplete: "off"
};
const ComboboxTarget = require_factory.factory((props) => {
const { children, refProp, withKeyboardNavigation, withAriaAttributes, withExpandedAttribute, targetType, autoComplete, ref, ...others } = require_use_props.useProps("ComboboxTarget", defaultProps, props);
const child = require_get_single_element_child.getSingleElementChild(children);
if (!child) throw new Error("Combobox.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");
const ctx = require_Combobox_context.useComboboxContext();
const clonedElement = (0, react.cloneElement)(child, {
...require_use_combobox_target_props.useComboboxTargetProps({
targetType,
withAriaAttributes,
withKeyboardNavigation,
withExpandedAttribute,
onKeyDown: child.props.onKeyDown,
autoComplete
}),
...others
});
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Popover.Popover.Target, {
ref: (0, _mantine_hooks.useMergedRef)(ref, ctx.store.targetRef),
children: clonedElement
});
});
ComboboxTarget.displayName = "@mantine/core/ComboboxTarget";
//#endregion
exports.ComboboxTarget = ComboboxTarget;
//# sourceMappingURL=ComboboxTarget.cjs.map