lucid-ui
Version:
A UI component library from Xandr.
120 lines • 5.58 kB
JavaScript
;
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("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: "The Message to display in the overlay.",
};
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((0, component_types_1.getFirst)(props, exports.OverlayWrapperMessage), 'props', {});
var otherChildren = (0, component_types_1.rejectTypes)(children, [exports.OverlayWrapperMessage]);
return (react_1.default.createElement("div", __assign({}, passThroughs, { 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: "A wrapper with optional overlay to wrap content. `OverlayWrapper` is meant to wrap another component and cover its content, while `Overlay` is meant for overlaying an entire page.",
categories: ['utility'],
};
exports.OverlayWrapper.propTypes = {
/**
Controls whether the message should be displayed over the wrapped
content.
*/
isVisible: bool,
/**
Set this to \`false\` if you don't want the semi-transparent overlay over
the wrapped content.
*/
hasOverlay: bool,
/**
Class names that are appended to the defaults.
*/
className: string,
/**
Any valid React children.
*/
children: node,
/**
Style variations for the overlay behind the message.
*/
overlayKind: oneOf(['light', 'dark']),
/**
By default, the \`OverlayMessage\` is vertically aligned to the middle of the
OverlayWrapper. Set this to true to position the \`OverlayMessage\` near the top of
the \`OverlayWrapper\`.
*/
anchorMessage: bool,
/**
By default, the OverlayMessage is vertically aligned to the middle of the
\`OverlayWrapper\` and the \`OverlayWrapper\` is the height of the entire content.
Set this to true to position the \`OverlayMessage\` near the center of the
\`OverlayWrapper\`, and fix the \`OverlayWrapper\` to the screen height and width.
*/
fixedMessage: bool,
/*
*Child Element* The Message to display in the overlay.
*/
Message: node,
};
exports.OverlayWrapper.Message = exports.OverlayWrapperMessage;
exports.default = exports.OverlayWrapper;
//# sourceMappingURL=OverlayWrapper.js.map