lucid-ui
Version:
A UI component library from AppNexus.
99 lines • 6.48 kB
JavaScript
"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.Panel = void 0;
var lodash_1 = __importDefault(require("lodash"));
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 cx = style_helpers_1.lucidClassNames.bind('&-Panel');
var bool = prop_types_1.default.bool, node = prop_types_1.default.node, object = prop_types_1.default.object, string = prop_types_1.default.string;
var PanelHeader = function (_props) { return null; };
PanelHeader.displayName = 'Panel.Header';
PanelHeader.peek = {
description: "\n\t\tContent displayed at the top of the panel.\n\t",
};
PanelHeader.propTypes = {
description: string,
children: node,
};
PanelHeader.propName = 'Header';
var PanelFooter = function (_props) { return null; };
PanelFooter.displayName = 'Panel.Footer';
PanelFooter.peek = {
description: "\n\t\tContent displayed at the bottom of the panel.\n\t",
};
PanelFooter.propTypes = {
description: string,
children: node,
};
PanelFooter.propName = 'Footer';
var defaultProps = {
isGutterless: false,
hasMargin: true,
isScrollable: true,
};
var Panel = function (props) {
var children = props.children, className = props.className, isGutterless = props.isGutterless, hasMargin = props.hasMargin, style = props.style, isScrollable = props.isScrollable, passThroughs = __rest(props, ["children", "className", "isGutterless", "hasMargin", "style", "isScrollable"]);
var headerChildProp = lodash_1.default.first(lodash_1.default.map(component_types_1.findTypes(props, exports.Panel.Header), 'props'));
var footerChildProp = lodash_1.default.first(lodash_1.default.map(component_types_1.findTypes(props, exports.Panel.Footer), 'props'));
return (react_1.default.createElement("div", __assign({}, component_types_1.omitProps(passThroughs, undefined, lodash_1.default.keys(exports.Panel.propTypes)), { className: cx('&', className, {
'&-is-not-gutterless': !isGutterless,
'&-has-margin': hasMargin,
'&-is-scrollable': isScrollable,
}), style: style }),
headerChildProp ? (react_1.default.createElement("header", __assign({}, headerChildProp, { className: cx('&-Header', headerChildProp.className) }))) : null,
react_1.default.createElement("section", { className: cx('&-content') }, children),
footerChildProp ? (react_1.default.createElement("footer", __assign({}, footerChildProp, { className: cx('&-Footer', footerChildProp.className) }))) : null));
};
exports.Panel = Panel;
exports.Panel.defaultProps = defaultProps;
exports.Panel.displayName = 'Panel';
exports.Panel.peek = {
description: "\n\t\tPanel is used to wrap content to better organize elements in window.\n\t",
categories: ['layout'],
};
exports.Panel.propTypes = {
className: string(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\t\tAppended to the component-specific class names set on the root element.\n\t"], ["\n\t\tAppended to the component-specific class names set on the root element.\n\t"]))),
Header: node(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n\t\t*Child Element* - Header contents. Only one `Header` is used.\n\t"], ["\n\t\t*Child Element* - Header contents. Only one \\`Header\\` is used.\n\t"]))),
Footer: node(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n\t\t*Child Element* - Footer contents. Only one `Footer` is used.\n\t"], ["\n\t\t*Child Element* - Footer contents. Only one \\`Footer\\` is used.\n\t"]))),
children: node(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n\t\tGenerally you should only have a single child element so the centering\n\t\tworks correctly.\n\t"], ["\n\t\tGenerally you should only have a single child element so the centering\n\t\tworks correctly.\n\t"]))),
isGutterless: bool(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n\t\tIf set to true, creates a content section with no padding.\n\t"], ["\n\t\tIf set to true, creates a content section with no padding.\n\t"]))),
hasMargin: bool(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n\t\tIf set to false, removes margin around the Panel\n\t"], ["\n\t\tIf set to false, removes margin around the Panel\n\t"]))),
style: object(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n\t\tStyles that are passed through to root element.\n\t"], ["\n\t\tStyles that are passed through to root element.\n\t"]))),
isScrollable: bool(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n\t\tIf set to true, makes content overflow scrollable, when Panel has a set\n\t\theight.\n\t"], ["\n\t\tIf set to true, makes content overflow scrollable, when Panel has a set\n\t\theight.\n\t"]))),
};
exports.Panel.Header = PanelHeader;
exports.Panel.Footer = PanelFooter;
exports.default = exports.Panel;
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
//# sourceMappingURL=Panel.js.map