"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _native = _interopRequireDefault(require("styled-components/native"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const DropdownContainer = _native.default.View`
  position: relative;
  display: inline-block;
`;
const DropdownButton = _native.default.TouchableOpacity`
  background-color: transparent;
  border: none;
  cursor: pointer;
`;
const DropdownIcon = _native.default.Text`
  margin-left: 5px;
`;
const DropdownList = _native.default.View`
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1;
  list-style-type: none;
  padding: 0;
  margin: 0;
  background-color: #fff;
  border: 1px solid #ccc;
`;
const DropdownItem = _native.default.Text`
  padding: 10px;
  cursor: pointer;

  &:hover {
    background-color: #f2f2f2;
  }
`;
const DropdownMenu = ({
  sortFunction,
  icon,
  values
}) => {
  const [isOpen, setIsOpen] = (0, _react.useState)(false);
  const handleItemClick = value => {
    sortFunction(value);
    setIsOpen(false);
  };
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(DropdownContainer, {
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownButton, {
      onPress: () => setIsOpen(!isOpen),
      children: icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownIcon, {
        children: icon
      })
    }), isOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownList, {
      children: values.map(value => /*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownItem, {
        onPress: () => handleItemClick(value),
        children: value
      }, value))
    })]
  });
};
var _default = exports.default = DropdownMenu;
//# sourceMappingURL=index.js.map