1 | const _excluded = ["className", "dropUp", "open", "role", "id", "transition", "children"];
|
2 |
|
3 | function _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 |
|
5 | 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; }
|
6 |
|
7 | import cn from 'classnames';
|
8 | import PropTypes from 'prop-types';
|
9 | import React from 'react';
|
10 | import SlideDownTransition from './SlideDownTransition';
|
11 | import { elementType } from './PropTypes';
|
12 | const StaticContainer = React.memo(({
|
13 | children
|
14 | }) => children, (_, {
|
15 | shouldUpdate
|
16 | }) => !shouldUpdate);
|
17 | const defaultProps = {
|
18 | open: false,
|
19 | transition: SlideDownTransition
|
20 | };
|
21 | const 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 | };
|
30 | const Popup = 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 React.createElement(Transition, _extends({}, props, {
|
44 | in: open,
|
45 | dropUp: dropUp,
|
46 | timeout: undefined
|
47 |
|
48 | ,
|
49 | className: cn('rw-popup-container', className)
|
50 | }), React.createElement("div", {
|
51 | id: id,
|
52 | className: "rw-popup",
|
53 | ref: ref,
|
54 | role: role
|
55 | }, React.createElement(StaticContainer, {
|
56 | shouldUpdate: open
|
57 | }, children)));
|
58 | });
|
59 | Popup.displayName = 'Popup';
|
60 | Popup.propTypes = propTypes;
|
61 | Popup.defaultProps = defaultProps;
|
62 | export default Popup; |
\ | No newline at end of file |