@pantheon-systems/design-toolkit-react
Version:
Pantheon's React Design Toolkit
63 lines (60 loc) • 3.11 kB
JavaScript
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import PropTypes from 'prop-types';
import LoadingLine from '../LoadingStates/LoadingLine.js';
import { jsxs, jsx } from 'react/jsx-runtime';
var _excluded = ["HtmlTag", "alignItems", "capitalize", "children", "flex", "isLoading", "isLoadingScreenReaderText", "justifyContent"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var TextCell = function TextCell(_ref) {
var HtmlTag = _ref.HtmlTag,
alignItems = _ref.alignItems,
capitalize = _ref.capitalize,
children = _ref.children,
flex = _ref.flex,
isLoading = _ref.isLoading,
isLoadingScreenReaderText = _ref.isLoadingScreenReaderText,
justifyContent = _ref.justifyContent,
props = _objectWithoutProperties(_ref, _excluded);
if (isLoading) {
return /*#__PURE__*/jsxs("div", {
className: "leading-2 mr-8",
role: "status",
children: [/*#__PURE__*/jsx("span", {
className: "sr-only",
children: isLoadingScreenReaderText
}), /*#__PURE__*/jsx(LoadingLine, {
height: 6,
width: "70%"
}), /*#__PURE__*/jsx(LoadingLine, {
height: 6
})]
});
}
return /*#__PURE__*/jsx(HtmlTag, _objectSpread(_objectSpread({}, props), {}, {
className: "".concat(flex ? 'flex' : '', " ").concat(alignItems, " ").concat(justifyContent, " ").concat(capitalize ? 'capitalize' : ''),
children: children
}));
};
TextCell.defaultProps = {
alignItems: 'items-start',
capitalize: false,
flex: false,
HtmlTag: 'span',
isLoading: false,
isLoadingScreenReaderText: 'Loading...',
justifyContent: 'justify-start'
};
TextCell.propTypes = {
HtmlTag: PropTypes.string,
alignItems: PropTypes.oneOf(['items-baseline', 'items-center', 'items-end', 'items-start', 'items-stretch']),
capitalize: PropTypes.bool,
children: PropTypes.node.isRequired,
flex: PropTypes.bool,
isLoading: PropTypes.bool,
isLoadingScreenReaderText: PropTypes.string,
justifyContent: PropTypes.oneOf(['justify-around', 'justify-between', 'justify-center', 'justify-end', 'justify-evenly', 'justify-start'])
};
var TextCell$1 = TextCell;
export { TextCell$1 as default };
//# sourceMappingURL=TextCell.js.map