UNPKG

@braineet/ui

Version:

Braineet design system

35 lines 1.83 kB
var _excluded = ["state", "withCancel", "multi", "comboboxOptions"]; function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } 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)); };