UNPKG

lucid-ui

Version:

A UI component library from AppNexus.

66 lines (61 loc) 3 kB
import _keys from "lodash/keys"; function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } import React from 'react'; import PropTypes from 'react-peek/prop-types'; import { omitProps } from '../../util/component-types'; import { lucidClassNames } from '../../util/style-helpers'; import Table from '../Table/Table'; var cx = lucidClassNames.bind('&-ScrollTable'); var object = PropTypes.object, string = PropTypes.string, bool = PropTypes.bool, node = PropTypes.node, number = PropTypes.number, oneOfType = PropTypes.oneOfType; var defaultProps = { hasWordWrap: false, hasBorder: false }; export var ScrollTable = function ScrollTable(props) { var children = props.children, className = props.className, style = props.style, tableWidth = props.tableWidth, hasWordWrap = props.hasWordWrap, hasBorder = props.hasBorder, passThroughs = _objectWithoutProperties(props, ["children", "className", "style", "tableWidth", "hasWordWrap", "hasBorder"]); return /*#__PURE__*/React.createElement("div", { className: cx('&', { '&-has-border': hasBorder }, className), style: style }, /*#__PURE__*/React.createElement(Table, _extends({}, omitProps(passThroughs, undefined, _keys(ScrollTable.propTypes), false), { style: { width: tableWidth }, hasWordWrap: hasWordWrap }), children)); }; ScrollTable.defaultProps = defaultProps; ScrollTable.displayName = 'ScrollTable'; ScrollTable.peek = { description: "\n\t\tTable in a scrollable container.\n\t", categories: ['table'], madeFrom: ['Table'] }; ScrollTable.Thead = Table.Thead; ScrollTable.Tbody = Table.Tbody; ScrollTable.Tr = Table.Tr; ScrollTable.Th = Table.Th; ScrollTable.Td = Table.Td; ScrollTable.propTypes = { children: node, className: string, style: object, tableWidth: oneOfType([number, string]), hasWordWrap: bool, hasBorder: bool }; export default ScrollTable;