react-widgets
Version:
An à la carte set of polished, extensible, and accessible inputs built for React
62 lines (58 loc) • 2.11 kB
JavaScript
const _excluded = ["className", "dropUp", "open", "role", "id", "transition", "children"];
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); }
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 cn from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import SlideDownTransition from './SlideDownTransition';
import { elementType } from './PropTypes';
const StaticContainer = /*#__PURE__*/React.memo(({
children
}) => children, (_, {
shouldUpdate
}) => !shouldUpdate);
const defaultProps = {
open: false,
transition: SlideDownTransition
};
const propTypes = {
open: PropTypes.bool,
dropUp: PropTypes.bool,
onEntering: PropTypes.func,
onEntered: PropTypes.func,
transition: elementType,
role: PropTypes.string,
id: PropTypes.string
};
const Popup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
let {
className,
dropUp,
open,
role,
id,
transition,
children
} = _ref,
props = _objectWithoutPropertiesLoose(_ref, _excluded);
const Transition = transition;
return /*#__PURE__*/React.createElement(Transition, _extends({}, props, {
in: open,
dropUp: dropUp,
timeout: undefined
/**hack*/
,
className: cn('rw-popup-container', className)
}), /*#__PURE__*/React.createElement("div", {
id: id,
className: "rw-popup",
ref: ref,
role: role
}, /*#__PURE__*/React.createElement(StaticContainer, {
shouldUpdate: open
}, children)));
});
Popup.displayName = 'Popup';
Popup.propTypes = propTypes;
Popup.defaultProps = defaultProps;
export default Popup;