UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

45 lines (44 loc) 2.32 kB
"use client"; const require_get_ref_prop = require("../../core/utils/get-ref-prop/get-ref-prop.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/Combobox.context.cjs"); const require_use_combobox_target_props = require("../Combobox/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/ComboboxPopover/ComboboxPopoverTarget.tsx const defaultProps = { refProp: "ref" }; const ComboboxPopoverTarget = require_factory.factory((props) => { const { children, refProp, ref, ...others } = require_use_props.useProps("ComboboxPopoverTarget", defaultProps, props); const child = require_get_single_element_child.getSingleElementChild(children); if (!child) throw new Error("ComboboxPopover.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 targetRef = (0, _mantine_hooks.useMergedRef)(ref, ctx.store.targetRef, require_get_ref_prop.getRefProp(child)); const clonedElement = (0, react.cloneElement)(child, { ...require_use_combobox_target_props.useComboboxTargetProps({ targetType: "button", withAriaAttributes: true, withKeyboardNavigation: true, withExpandedAttribute: true, onKeyDown: child.props.onKeyDown, onClick: (event) => { ctx.store.toggleDropdown(); child.props.onClick?.(event); }, autoComplete: "off" }), ...others, [refProp]: targetRef }); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Popover.Popover.Target, { refProp, children: clonedElement }); }); ComboboxPopoverTarget.displayName = "@mantine/core/ComboboxPopoverTarget"; //#endregion exports.ComboboxPopoverTarget = ComboboxPopoverTarget; //# sourceMappingURL=ComboboxPopoverTarget.cjs.map