Paragraph.js 838 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use client";
  2. import * as React from 'react';
  3. import classNames from 'classnames';
  4. const getWidth = (index, props) => {
  5. const {
  6. width,
  7. rows = 2
  8. } = props;
  9. if (Array.isArray(width)) {
  10. return width[index];
  11. }
  12. // last paragraph
  13. if (rows - 1 === index) {
  14. return width;
  15. }
  16. return undefined;
  17. };
  18. const Paragraph = props => {
  19. const {
  20. prefixCls,
  21. className,
  22. style,
  23. rows = 0
  24. } = props;
  25. const rowList = Array.from({
  26. length: rows
  27. }).map((_, index) => (
  28. /*#__PURE__*/
  29. // eslint-disable-next-line react/no-array-index-key
  30. React.createElement("li", {
  31. key: index,
  32. style: {
  33. width: getWidth(index, props)
  34. }
  35. })));
  36. return /*#__PURE__*/React.createElement("ul", {
  37. className: classNames(prefixCls, className),
  38. style: style
  39. }, rowList);
  40. };
  41. export default Paragraph;