UNPKG

lucid-ui

Version:

A UI component library from AppNexus.

94 lines 7.51 kB
"use strict"; var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.OverlayWrapper = exports.OverlayWrapperMessage = void 0; /* eslint-disable react/prop-types */ var react_1 = __importDefault(require("react")); var prop_types_1 = __importDefault(require("react-peek/prop-types")); var lodash_1 = __importDefault(require("lodash")); var style_helpers_1 = require("../../util/style-helpers"); var component_types_1 = require("../../util/component-types"); var react_transition_group_1 = require("react-transition-group"); var cx = style_helpers_1.lucidClassNames.bind('&-OverlayWrapper'); var bool = prop_types_1.default.bool, node = prop_types_1.default.node, oneOf = prop_types_1.default.oneOf, string = prop_types_1.default.string; var OverlayWrapperMessage = function (_props) { return null; }; exports.OverlayWrapperMessage = OverlayWrapperMessage; exports.OverlayWrapperMessage.displayName = 'OverlayWrapper.Message'; exports.OverlayWrapperMessage.peek = { description: "\n\t\tThe Message to display in the overlay.\n\t", }; exports.OverlayWrapperMessage.propName = 'Message'; exports.OverlayWrapperMessage.propTypes = { children: node, }; var defaultProps = { hasOverlay: true, overlayKind: 'light', anchorMessage: false, fixedMessage: false, isVisible: false, }; var OverlayWrapper = function (props) { var hasOverlay = props.hasOverlay, isVisible = props.isVisible, className = props.className, children = props.children, overlayKind = props.overlayKind, anchorMessage = props.anchorMessage, fixedMessage = props.fixedMessage, passThroughs = __rest(props, ["hasOverlay", "isVisible", "className", "children", "overlayKind", "anchorMessage", "fixedMessage"]); var messageElementProp = lodash_1.default.get(component_types_1.getFirst(props, exports.OverlayWrapperMessage), 'props', {}); var otherChildren = component_types_1.rejectTypes(children, [exports.OverlayWrapperMessage]); return (react_1.default.createElement("div", __assign({}, component_types_1.omitProps(passThroughs, undefined, lodash_1.default.keys(exports.OverlayWrapper.propTypes)), { className: cx('&', className) }), otherChildren, react_1.default.createElement(react_transition_group_1.CSSTransition, { in: isVisible, classNames: cx('&-message-container'), timeout: 300, unmountOnExit: true }, react_1.default.createElement("div", { className: cx('&-message-container', { '&-has-overlay': hasOverlay, '&-kind-light': hasOverlay && overlayKind === 'light', '&-anchored-message': anchorMessage, '&-fixed-message': fixedMessage, }) }, react_1.default.createElement("div", __assign({}, messageElementProp)))))); }; exports.OverlayWrapper = OverlayWrapper; exports.OverlayWrapper.defaultProps = defaultProps; exports.OverlayWrapper.displayName = 'OverlayWrapper'; exports.OverlayWrapper.peek = { description: "\n\t\tA wrapper with optional overlay to wrap content. `Overlay` is meant\n\t\tfor overlaying an entire page, while this component is meant to wrap\n\t\tanother component and cover its content.\n\t", categories: ['utility'], }; exports.OverlayWrapper.propTypes = { isVisible: bool(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\t\tControls whether the message should be displayed over the wrapped\n\t\tcontent.\n\t"], ["\n\t\tControls whether the message should be displayed over the wrapped\n\t\tcontent.\n\t"]))), hasOverlay: bool(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n\t\tSet this to `false` if you don't want the semi-transparent overlay over\n\t\tthe wrapped content.\n\t"], ["\n\t\tSet this to \\`false\\` if you don't want the semi-transparent overlay over\n\t\tthe wrapped content.\n\t"]))), className: string(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n\t\tClass names that are appended to the defaults.\n\t"], ["\n\t\tClass names that are appended to the defaults.\n\t"]))), children: node(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n\t\tAny valid React children.\n\t"], ["\n\t\tAny valid React children.\n\t"]))), overlayKind: oneOf(['light', 'dark'])(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n\t\tStyle variations for the overlay behind the message.\n\t"], ["\n\t\tStyle variations for the overlay behind the message.\n\t"]))), anchorMessage: bool(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n\t\tBy default, the `OverlayMessage` is vertically aligned to the middle of the\n\t\tOverlayWrapper. Set this to true to position the `OverlayMessage` near the top of \n\t\tthe `OverlayWrapper`.\n\t"], ["\n\t\tBy default, the \\`OverlayMessage\\` is vertically aligned to the middle of the\n\t\tOverlayWrapper. Set this to true to position the \\`OverlayMessage\\` near the top of \n\t\tthe \\`OverlayWrapper\\`.\n\t"]))), fixedMessage: bool(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n\t\tBy default, the OverlayMessage is vertically aligned to the middle of the\n\t\t`OverlayWrapper` and the `OverlayWrapper` is the height of the entire content.\n\t\tSet this to true to position the `OverlayMessage` near the center of the \n\t\t`OverlayWrapper`, and fix the `OverlayWrapper` to the screen height and width.\n\t"], ["\n\t\tBy default, the OverlayMessage is vertically aligned to the middle of the\n\t\t\\`OverlayWrapper\\` and the \\`OverlayWrapper\\` is the height of the entire content.\n\t\tSet this to true to position the \\`OverlayMessage\\` near the center of the \n\t\t\\`OverlayWrapper\\`, and fix the \\`OverlayWrapper\\` to the screen height and width.\n\t"]))), Message: node(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n\t\t*Child Element* The Message to display in the overlay.\n\t"], ["\n\t\t*Child Element* The Message to display in the overlay.\n\t"]))), }; exports.OverlayWrapper.Message = exports.OverlayWrapperMessage; exports.default = exports.OverlayWrapper; var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8; //# sourceMappingURL=OverlayWrapper.js.map