Polite.js 763 B

1234567891011121314151617181920212223242526
  1. import _typeof from "@babel/runtime/helpers/esm/typeof";
  2. import * as React from 'react';
  3. export default function Polite(props) {
  4. var visible = props.visible,
  5. values = props.values;
  6. if (!visible) {
  7. return null;
  8. }
  9. // Only cut part of values since it's a screen reader
  10. var MAX_COUNT = 50;
  11. return /*#__PURE__*/React.createElement("span", {
  12. "aria-live": "polite",
  13. style: {
  14. width: 0,
  15. height: 0,
  16. position: 'absolute',
  17. overflow: 'hidden',
  18. opacity: 0
  19. }
  20. }, "".concat(values.slice(0, MAX_COUNT).map(function (_ref) {
  21. var label = _ref.label,
  22. value = _ref.value;
  23. return ['number', 'string'].includes(_typeof(label)) ? label : value;
  24. }).join(', ')), values.length > MAX_COUNT ? ', ...' : null);
  25. }