UNPKG

lucid-ui

Version:

A UI component library from AppNexus.

92 lines 7.23 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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.LoadingIndicator = void 0; /* eslint-disable react/prop-types */ var react_1 = __importDefault(require("react")); var prop_types_1 = __importDefault(require("react-peek/prop-types")); var style_helpers_1 = require("../../util/style-helpers"); var component_types_1 = require("../../util/component-types"); var OverlayWrapper_1 = __importStar(require("../OverlayWrapper/OverlayWrapper")); var LoadingMessage_1 = __importDefault(require("../LoadingMessage/LoadingMessage")); var cx = style_helpers_1.lucidClassNames.bind('&-LoadingIndicator'); 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 defaultProps = { hasOverlay: true, isLoading: false, overlayKind: 'light', anchorMessage: false, fixedMessage: false, }; var LoadingIndicator = function (props) { var children = props.children, className = props.className, isLoading = props.isLoading, anchorMessage = props.anchorMessage, fixedMessage = props.fixedMessage; var messageElement = component_types_1.getFirst(props, exports.LoadingIndicator.LoadingMessage, react_1.default.createElement(LoadingMessage_1.default, null)); var otherChildren = component_types_1.rejectTypes(children, exports.LoadingIndicator.LoadingMessage); return (react_1.default.createElement(OverlayWrapper_1.default, __assign({}, component_types_1.omitProps(props, undefined, // _.keys(LoadingIndicator.propTypes) ['children', 'className', 'isLoading', 'Message']), { className: cx('&', className), isVisible: isLoading, anchorMessage: anchorMessage, fixedMessage: fixedMessage }), otherChildren, react_1.default.createElement(OverlayWrapper_1.OverlayWrapperMessage, null, messageElement))); }; exports.LoadingIndicator = LoadingIndicator; exports.LoadingIndicator.LoadingMessage = LoadingMessage_1.default; exports.LoadingIndicator.displayName = 'LoadingIndicator'; exports.LoadingIndicator.peek = { description: "\n\t\tA loading indicator wrapper with optional overlay.\n\t", notes: { overview: "\n\t\t\tA visual indication that a section or component of the interface is loading.\n\t\t", intendedUse: "\n\t\t\t- Use in places where data takes time to load. LoadingIndicator lets users know that the information they expect to see will appear shortly.\n\t\t\t- Use the light overlay, `overlayKind: \"light\"`\n\t\t", technicalRecommendations: "\n\t\t\tIf a page is displaying a lot of data coming from multiple sources, try as best as possible to load the individual parts of the UI, so as not to disrupt the user and block them from interacting with the entire page until all data is loaded.\n\t\t", }, categories: ['Loading Indicator'], madeFrom: ['OverlayWrapper', 'LoadingMessage'], }; exports.LoadingIndicator.propTypes = { className: string(templateObject_1 || (templateObject_1 = __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_2 || (templateObject_2 = __makeTemplateObject(["\n\t\tAny valid React children.\n\t"], ["\n\t\tAny valid React children.\n\t"]))), hasOverlay: bool(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n\t\tSet this to `false` if you don't want the semi-transparent overlay over\n\t\tthe wrapped content\n "], ["\n\t\tSet this to \\`false\\` if you don't want the semi-transparent overlay over\n\t\tthe wrapped content\n "]))), isLoading: bool(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n\t\tControls the visibility of the `LoadingMessage` and overlay.\n\t"], ["\n\t\tControls the visibility of the \\`LoadingMessage\\` and overlay.\n\t"]))), anchorMessage: bool(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n\t\tPositions the loading message near the top of the container. By default,\n\t\tthe loading message is vertically aligned to the middle of the container.\n\t"], ["\n\t\tPositions the loading message near the top of the container. By default,\n\t\tthe loading message is vertically aligned to the middle of the container.\n\t"]))), fixedMessage: bool(templateObject_6 || (templateObject_6 = __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"]))), overlayKind: oneOf(['light', 'dark'])(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n\t\tStyle variations for the overlay behind the loading indicator.\n\t"], ["\n\t\tStyle variations for the overlay behind the loading indicator.\n\t"]))), }; exports.LoadingIndicator.defaultProps = defaultProps; exports.default = exports.LoadingIndicator; var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7; //# sourceMappingURL=LoadingIndicator.js.map