UNPKG

2.11 kBJavaScriptView Raw
1const _excluded = ["className", "dropUp", "open", "role", "id", "transition", "children"];
2
3function _extends() { _extends = Object.assign || 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); }
4
5function _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; }
6
7import cn from 'classnames';
8import PropTypes from 'prop-types';
9import React from 'react';
10import SlideDownTransition from './SlideDownTransition';
11import { elementType } from './PropTypes';
12const StaticContainer = /*#__PURE__*/React.memo(({
13 children
14}) => children, (_, {
15 shouldUpdate
16}) => !shouldUpdate);
17const defaultProps = {
18 open: false,
19 transition: SlideDownTransition
20};
21const propTypes = {
22 open: PropTypes.bool,
23 dropUp: PropTypes.bool,
24 onEntering: PropTypes.func,
25 onEntered: PropTypes.func,
26 transition: elementType,
27 role: PropTypes.string,
28 id: PropTypes.string
29};
30const Popup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
31 let {
32 className,
33 dropUp,
34 open,
35 role,
36 id,
37 transition,
38 children
39 } = _ref,
40 props = _objectWithoutPropertiesLoose(_ref, _excluded);
41
42 const Transition = transition;
43 return /*#__PURE__*/React.createElement(Transition, _extends({}, props, {
44 in: open,
45 dropUp: dropUp,
46 timeout: undefined
47 /**hack*/
48 ,
49 className: cn('rw-popup-container', className)
50 }), /*#__PURE__*/React.createElement("div", {
51 id: id,
52 className: "rw-popup",
53 ref: ref,
54 role: role
55 }, /*#__PURE__*/React.createElement(StaticContainer, {
56 shouldUpdate: open
57 }, children)));
58});
59Popup.displayName = 'Popup';
60Popup.propTypes = propTypes;
61Popup.defaultProps = defaultProps;
62export default Popup;
\No newline at end of file