Text.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. "use client";
  2. var __rest = this && this.__rest || function (s, e) {
  3. var t = {};
  4. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  5. if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  6. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  7. }
  8. return t;
  9. };
  10. import * as React from 'react';
  11. import omit from "rc-util/es/omit";
  12. import { devUseWarning } from '../_util/warning';
  13. import Base from './Base';
  14. const Text = (_a, ref) => {
  15. var {
  16. ellipsis
  17. } = _a,
  18. restProps = __rest(_a, ["ellipsis"]);
  19. const mergedEllipsis = React.useMemo(() => {
  20. if (ellipsis && typeof ellipsis === 'object') {
  21. return omit(ellipsis, ['expandable', 'rows']);
  22. }
  23. return ellipsis;
  24. }, [ellipsis]);
  25. if (process.env.NODE_ENV !== 'production') {
  26. const warning = devUseWarning('Typography.Text');
  27. process.env.NODE_ENV !== "production" ? warning(typeof ellipsis !== 'object' || !ellipsis || !('expandable' in ellipsis) && !('rows' in ellipsis), 'usage', '`ellipsis` do not support `expandable` or `rows` props.') : void 0;
  28. }
  29. return /*#__PURE__*/React.createElement(Base, Object.assign({
  30. ref: ref
  31. }, restProps, {
  32. ellipsis: mergedEllipsis,
  33. component: "span"
  34. }));
  35. };
  36. export default /*#__PURE__*/React.forwardRef(Text);