UNPKG

@braineet/ui

Version:

Braineet design system

35 lines 1.66 kB
var _excluded = ["state", "withCancel", "multi", "comboboxOptions"]; function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } import React from 'react'; import { useCombobox as useBaseCombobox } from 'ariakit/combobox'; import Input from '../input'; import InputTags from '../inputTags'; import { ComboboxCancel } from './ComboboxCancel'; import { jsx as _jsx } from "react/jsx-runtime"; export var Combobox = function Combobox(_ref) { var state = _ref.state, withCancel = _ref.withCancel, multi = _ref.multi, _ref$comboboxOptions = _ref.comboboxOptions, comboboxOptions = _ref$comboboxOptions === void 0 ? {} : _ref$comboboxOptions, props = _objectWithoutPropertiesLoose(_ref, _excluded); var inputProps = useBaseCombobox(_extends({ state: state }, comboboxOptions)); var renderCancel = withCancel && state.value && /*#__PURE__*/_jsx(ComboboxCancel, { state: state }); if (multi) { return /*#__PURE__*/_jsx(InputTags, _extends({ boxRef: state.wrapperRef, placeholder: "Search..." }, props, inputProps)); } return /*#__PURE__*/_jsx(Input, _extends({ placeholder: "Search...", autoRefresh: true, debounce: 0, addonAfter: renderCancel }, inputProps, props)); };