wix-style-react
Version:
65 lines (55 loc) • 3.09 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["dataHook", "className", "tagName", "caption", "light", "children"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
import React from 'react';
import PropTypes from 'prop-types';
import { st, classes } from './Caption.st.css';
import Ellipsis, { extractEllipsisProps } from '../common/Ellipsis';
import { EllipsisCommonProps } from '../common/PropTypes/EllipsisCommon';
var CaptionWithEllipsis = function CaptionWithEllipsis(_ref) {
var dataHook = _ref.dataHook,
className = _ref.className,
tagName = _ref.tagName,
caption = _ref.caption,
light = _ref.light,
children = _ref.children,
props = _objectWithoutProperties(_ref, _excluded);
var _extractEllipsisProps = extractEllipsisProps(props),
ellipsisProps = _extractEllipsisProps.ellipsisProps,
componentProps = _extractEllipsisProps.componentProps;
return /*#__PURE__*/React.createElement(Ellipsis, _extends({}, ellipsisProps, {
wrapperClassName: classes[caption],
render: function render(_ref2) {
var ref = _ref2.ref,
ellipsisClasses = _ref2.ellipsisClasses;
return /*#__PURE__*/React.createElement(tagName, _objectSpread({
ref: ref,
className: st(classes.root, {
caption: caption
}, ellipsisClasses(className)),
'data-hook': dataHook,
'data-light': light
}, componentProps), children);
}
}));
};
CaptionWithEllipsis.displayName = 'Caption';
CaptionWithEllipsis.propTypes = _objectSpread({
/** Applied as data-hook HTML attribute that can be used in the tests */
dataHook: PropTypes.string,
/** class to be applied to the root element */
className: PropTypes.string,
/** tag name that will be rendered */
tagName: PropTypes.string,
caption: PropTypes.oneOf(['c1', 'c2']),
/** make the text color lighter */
light: PropTypes.bool
}, EllipsisCommonProps);
CaptionWithEllipsis.defaultProps = _objectSpread({
caption: 'c1',
tagName: 'span'
}, Ellipsis.defaultProps);
export default CaptionWithEllipsis;