lucid-ui
Version:
A UI component library from Xandr.
122 lines • 6.14 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 __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 __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.LoadingIndicator = void 0;
var lodash_1 = __importDefault(require("lodash"));
var react_1 = __importDefault(require("react"));
var prop_types_1 = __importDefault(require("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,
anchorMessage: false,
fixedMessage: false,
overlayKind: 'light',
};
var LoadingIndicator = function (props) {
var children = props.children, className = props.className, isLoading = props.isLoading, anchorMessage = props.anchorMessage, fixedMessage = props.fixedMessage, passThroughs = __rest(props, ["children", "className", "isLoading", "anchorMessage", "fixedMessage"]);
var messageElement = (0, component_types_1.getFirst)(props, exports.LoadingIndicator.LoadingMessage, react_1.default.createElement(LoadingMessage_1.default, null));
var otherChildren = (0, component_types_1.rejectTypes)(children, exports.LoadingIndicator.LoadingMessage);
return (react_1.default.createElement(OverlayWrapper_1.default, __assign({}, lodash_1.default.omit(passThroughs, ['Message', 'initialState', 'callbackId']), { 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: "A loading indicator wrapper with optional overlay.",
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 = {
/**
Class names that are appended to the defaults.
*/
className: string,
/**
Any valid React children.
*/
children: node,
/**
Set this to \`false\` if you don't want the semi-transparent overlay over
the wrapped content
*/
hasOverlay: bool,
/**
Controls the visibility of the \`LoadingMessage\` and overlay.
*/
isLoading: bool,
/**
Positions the loading message near the top of the container. By default,
the loading message is vertically aligned to the middle of the container.
*/
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,
/**
Style variations for the overlay behind the loading indicator.
*/
overlayKind: oneOf(['light', 'dark']),
};
exports.LoadingIndicator.defaultProps = defaultProps;
exports.default = exports.LoadingIndicator;
//# sourceMappingURL=LoadingIndicator.js.map