"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.CollectionSearch = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _mobxReactLite = require("mobx-react-lite");
var _designSystem = require("@wix/design-system");
var _react = _interopRequireDefault(require("react"));
var _react2 = require("@wix/bex-core/react");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/CollectionSearch.tsx";
const CollectionSearch = exports.CollectionSearch = (0, _mobxReactLite.observer)(function CollectionSearch({
  onSearchChange,
  onSearchClick,
  onSearchBlur,
  visibility,
  ...rest
}) {
  const collection = (0, _react2.useCollectionContext)();
  const {
    query: {
      search
    },
    translate: t
  } = collection;
  return /*#__PURE__*/_react.default.createElement(_designSystem.Search, (0, _extends2.default)({
    dataHook: "collection-search",
    onChange: e => {
      const value = e.target.value;
      collection.search(e.target.value, {
        clearResult: true
      });
      onSearchChange == null || onSearchChange(value);
    },
    value: search.value,
    onClear: () => {
      const value = '';
      collection.clearSearch();
      onSearchChange == null || onSearchChange(value);
    },
    placeholder: t('cairo.searchPlaceholder', {
      defaultValue: ''
    }),
    onInputClicked: () => onSearchClick == null ? void 0 : onSearchClick(),
    textOverflow: "ellipsis",
    onBlur: e => {
      const value = e.target.value;
      onSearchBlur == null || onSearchBlur(value);
    }
  }, rest, {
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 31,
      columnNumber: 5
    }
  }));
});
//# sourceMappingURL=CollectionSearch.js.map