@enact/ui 5.6.0 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/AnnounceDecorator/Announce.js +8 -8
  2. package/AnnounceDecorator/AnnounceDecorator.js +5 -5
  3. package/BodyText/BodyText.js +5 -5
  4. package/BodyText/tests/BodyText-specs.js +2 -1
  5. package/Button/Button.js +5 -5
  6. package/CHANGELOG.md +18 -0
  7. package/Cancelable/Cancelable.js +9 -9
  8. package/Cancelable/tests/Cancelable-specs.js +5 -5
  9. package/Card/Card.js +5 -5
  10. package/Card/tests/Card-specs.js +2 -1
  11. package/Changeable/Changeable.js +9 -9
  12. package/ComponentOverride/ComponentOverride.js +15 -11
  13. package/FloatingLayer/FloatingLayer.js +10 -10
  14. package/FloatingLayer/FloatingLayerContainer.js +3 -3
  15. package/FloatingLayer/FloatingLayerDecorator.js +5 -5
  16. package/FloatingLayer/Scrim.js +9 -9
  17. package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +4 -4
  18. package/FloatingLayer/useFloatingLayer.js +3 -4
  19. package/ForwardRef/ForwardRef.js +5 -5
  20. package/Group/Group.js +5 -5
  21. package/Group/GroupItem.js +5 -5
  22. package/Group/tests/Group-specs.js +2 -1
  23. package/Heading/Heading.js +5 -5
  24. package/Icon/Icon.js +5 -5
  25. package/Icon/tests/Icon-specs.js +2 -1
  26. package/Image/Image.js +5 -5
  27. package/Image/tests/Image-specs.js +2 -1
  28. package/ImageItem/ImageItem.js +5 -5
  29. package/ImageItem/tests/ImageItem-specs.js +6 -5
  30. package/Item/Item.js +5 -5
  31. package/LabeledIcon/LabeledIcon.js +5 -5
  32. package/Layout/Cell.js +5 -5
  33. package/Layout/Layout.js +5 -5
  34. package/Layout/tests/Layout-specs.js +9 -9
  35. package/Marquee/Marquee.module.css +44 -0
  36. package/Marquee/MarqueeBase.js +134 -21
  37. package/Marquee/MarqueeController.js +4 -4
  38. package/Marquee/MarqueeDecorator.js +219 -27
  39. package/Marquee/index.d.ts +60 -12
  40. package/Marquee/tests/Marquee-specs.js +3 -3
  41. package/Marquee/tests/Marquee-vertical-specs.js +1358 -0
  42. package/Marquee/useMarqueeController.js +4 -4
  43. package/Marquee/utils.js +22 -0
  44. package/Marquee/verticalMeasure.js +118 -0
  45. package/Measurable/Measurable.js +8 -9
  46. package/Measurable/tests/Measurable-specs.js +7 -6
  47. package/Media/Media.js +10 -10
  48. package/Placeholder/PlaceholderControllerDecorator.js +9 -9
  49. package/Placeholder/PlaceholderDecorator.js +9 -9
  50. package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +4 -4
  51. package/ProgressBar/ProgressBar.js +5 -5
  52. package/Repeater/Repeater.js +5 -5
  53. package/Repeater/tests/Repeater-specs.js +6 -5
  54. package/Resizable/Resizable.js +4 -4
  55. package/Resizable/tests/Resizable-specs.js +2 -1
  56. package/Resizable/tests/useResize-specs.js +4 -4
  57. package/Resizable/useResize.js +3 -3
  58. package/Routable/Link.js +9 -9
  59. package/Routable/Routable.js +5 -5
  60. package/Routable/Router.js +9 -9
  61. package/Routable/tests/Routable-specs.js +7 -8
  62. package/Routable/tests/Router-specs.js +1 -1
  63. package/Scroller/Scroller.js +4 -4
  64. package/Scroller/ScrollerBasic.js +10 -10
  65. package/Skinnable/Skinnable.js +5 -5
  66. package/Skinnable/tests/Skinnable-specs.js +4 -4
  67. package/Skinnable/tests/useSkins-specs.js +4 -4
  68. package/Slider/Knob.js +5 -5
  69. package/Slider/PositionDecorator.js +8 -8
  70. package/Slider/Slider.js +5 -5
  71. package/Slottable/Slottable.js +4 -4
  72. package/Slottable/useSlots.js +5 -5
  73. package/Spinner/Spinner.js +5 -5
  74. package/ToggleIcon/ToggleIcon.js +5 -5
  75. package/Toggleable/Toggle.js +5 -5
  76. package/Toggleable/Toggleable.js +9 -9
  77. package/Toggleable/useToggle.js +5 -5
  78. package/Touchable/ClickAllow.js +3 -3
  79. package/Touchable/Drag.js +6 -6
  80. package/Touchable/Flick.js +5 -5
  81. package/Touchable/Hold.js +5 -5
  82. package/Touchable/Pinch.js +6 -6
  83. package/Touchable/Touch.js +3 -3
  84. package/Touchable/Touchable.js +5 -5
  85. package/Touchable/config.js +4 -4
  86. package/Touchable/tests/Touchable-specs.js +1 -1
  87. package/Touchable/tests/useTouch-specs.js +5 -5
  88. package/Touchable/useTouch.js +7 -8
  89. package/Transition/Transition.js +14 -13
  90. package/Transition/tests/Transition-specs.js +9 -9
  91. package/ViewManager/Arranger.js +4 -4
  92. package/ViewManager/TransitionGroup.js +7 -7
  93. package/ViewManager/View.js +9 -9
  94. package/ViewManager/ViewManager.js +11 -10
  95. package/ViewManager/tests/ViewManager-specs.js +6 -6
  96. package/VirtualList/VirtualList.js +4 -4
  97. package/VirtualList/VirtualListBasic.js +67 -47
  98. package/VirtualList/tests/VirtualGridList-native-specs.js +5 -5
  99. package/VirtualList/tests/VirtualGridList-specs.js +16 -15
  100. package/VirtualList/tests/VirtualList-native-specs.js +164 -16
  101. package/VirtualList/tests/VirtualList-specs.js +16 -15
  102. package/internal/IdProvider/IdProvider.js +4 -4
  103. package/internal/IdProvider/Provider.js +3 -3
  104. package/internal/IdProvider/tests/IdProvider-specs.js +4 -4
  105. package/internal/IdProvider/tests/useId-specs.js +16 -8
  106. package/internal/Pure/Pure.js +9 -9
  107. package/internal/Pure/tests/Pure-specs.js +8 -8
  108. package/internal/localized-fonts/localized-fonts.js +3 -4
  109. package/package.json +6 -6
  110. package/resolution/ResolutionDecorator.js +71 -87
  111. package/resolution/index.js +2 -1
  112. package/resolution/tests/resolution-specs.js +7 -8
  113. package/useControlledState/tests/useControlledState-specs.js +3 -4
  114. package/useControlledState/useControlledState.js +3 -4
  115. package/useScroll/ScrollAnimator.js +3 -3
  116. package/useScroll/Scrollbar.js +5 -5
  117. package/useScroll/ScrollbarTrack.js +5 -5
  118. package/useScroll/scrollMotion.js +126 -0
  119. package/useScroll/tests/scrollMotion-specs.js +215 -0
  120. package/useScroll/tests/useScroll-specs.js +430 -9
  121. package/useScroll/useScroll.js +156 -92
@@ -18,27 +18,29 @@ var _resolution = require("../resolution");
18
18
  var _Resizable = require("../Resizable");
19
19
  var _MarqueeBase = _interopRequireDefault(require("./MarqueeBase"));
20
20
  var _MarqueeController = require("./MarqueeController");
21
+ var _utils = require("./utils");
22
+ var _verticalMeasure = require("./verticalMeasure");
21
23
  var _MarqueeModule = _interopRequireDefault(require("./Marquee.module.css"));
22
24
  var _jsxRuntime = require("react/jsx-runtime");
23
- var _excluded = ["alignment", "children", "disabled", "marqueeOn", "marqueeSpeed"];
25
+ var _excluded = ["alignment", "children", "css", "disabled", "marqueeOn", "marqueeSpeed"];
24
26
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
25
27
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
26
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
27
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
28
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
28
+ function _objectSpread(r) { for (var t = 1; t < arguments.length; t++) { var o = null != arguments[t] ? arguments[t] : {}; t % 2 ? ownKeys(Object(o), !0).forEach(function (t) { _defineProperty(r, t, o[t]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(o)) : ownKeys(Object(o)).forEach(function (e) { Object.defineProperty(r, e, Object.getOwnPropertyDescriptor(o, e)); }); } return r; }
29
+ function _defineProperty(r, t, o) { return (t = _toPropertyKey(t)) in r ? Object.defineProperty(r, t, { value: o, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = o, r; }
30
+ function _objectWithoutProperties(t, r) { if (null == t) return {}; var o, n, i = _objectWithoutPropertiesLoose(t, r); if (Object.getOwnPropertySymbols) { var l = Object.getOwnPropertySymbols(t); for (n = 0; n < l.length; n++) o = l[n], -1 === r.indexOf(o) && {}.propertyIsEnumerable.call(t, o) && (i[o] = t[o]); } return i; }
29
31
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
30
32
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
31
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
33
+ function _defineProperties(r, t) { for (var o = 0; o < t.length; o++) { var i = t[o]; i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(r, _toPropertyKey(i.key), i); } }
32
34
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
33
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
34
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
35
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
35
+ function _toPropertyKey(r) { var o = _toPrimitive(r, "string"); return "symbol" == typeof o ? o : o + ""; }
36
+ function _toPrimitive(t, e) { if ("object" != typeof t || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
37
+ function _inherits(t, r) { if ("function" != typeof r && null !== r) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(r && r.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), r && _setPrototypeOf(t, r); }
38
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
39
+ function _callSuper(e, c, p) { return c = _getPrototypeOf(c), _possibleConstructorReturn(e, _isNativeReflectConstruct() ? Reflect.construct(c, p || [], _getPrototypeOf(e).constructor) : c.apply(e, p)); }
36
40
  function _possibleConstructorReturn(t, e) { if (e && ("object" == typeof e || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
37
41
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
38
42
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
39
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
40
- function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
41
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } /* global ResizeObserver */ // The minimum number of milliseconds to wait before resetting the marquee position after it finishes.
43
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } /* global ResizeObserver */ // The minimum number of milliseconds to wait before resetting the marquee position after it finishes.
42
44
  var MINIMUM_MARQUEE_RESET_DELAY = 40;
43
45
 
44
46
  /**
@@ -73,8 +75,10 @@ var defaultConfig = {
73
75
  *
74
76
  * * `marquee` - The root component class
75
77
  * * `animate` - Applied to the inner content node when the text is animating
78
+ * * `content` - The content node of a vertical marquee
76
79
  * * `spacing` - The spacing node used between the repeated content
77
80
  * * `text` - The inner content node
81
+ * * `vertical` - The root modifier for a vertical marquee
78
82
  * * `willAnimate` - Applied to the inner content node shortly before animation
79
83
  *
80
84
  * @type {Object}
@@ -128,7 +132,21 @@ var defaultConfig = {
128
132
  */
129
133
  marqueeDirection: function marqueeDirection(str) {
130
134
  return (0, _util2.isRtlText)(str) ? 'rtl' : 'ltr';
131
- }
135
+ },
136
+ /**
137
+ * Direction the marquee scrolls.
138
+ *
139
+ * `'vertical'` scrolls overflowing wrapped text by its laid-out block height.
140
+ * `'horizontal'` is the single-line marquee.
141
+ *
142
+ * This is a config option rather than a prop so a wrapped component can keep its own
143
+ * `orientation` prop.
144
+ *
145
+ * @type {('horizontal'|'vertical')}
146
+ * @default 'horizontal'
147
+ * @memberof ui/Marquee.MarqueeDecorator.defaultConfig
148
+ */
149
+ orientation: 'horizontal'
132
150
  };
133
151
 
134
152
  /*
@@ -181,7 +199,9 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
181
199
  focus = config.focus,
182
200
  invalidateProps = config.invalidateProps,
183
201
  leave = config.leave,
184
- marqueeDirection = config.marqueeDirection;
202
+ marqueeDirection = config.marqueeDirection,
203
+ orientation = config.orientation;
204
+ var vertical = orientation === 'vertical';
185
205
 
186
206
  // Generate functions to forward events to containers
187
207
  var forwardBlur = (0, _handle.forward)(blur);
@@ -219,6 +239,12 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
219
239
  } : null;
220
240
  });
221
241
  });
242
+ _this.cacheMeasurer = function (node) {
243
+ _this.measurer = node;
244
+ };
245
+ _this.cacheDuplicate = function (node) {
246
+ _this.duplicateNode = node;
247
+ };
222
248
  /*
223
249
  * Starts the animation without synchronizing
224
250
  *
@@ -231,6 +257,9 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
231
257
  // if marquee isn't necessary, do not set `animating` but return `true` to mark it
232
258
  // complete if it's synchronized so it doesn't block other instances.
233
259
  return true;
260
+ } else if (_this.isVertical() && ((0, _verticalMeasure.prefersReducedMotion)() || !(_this.props.marqueeSpeed > 0))) {
261
+ _this.calculateMetrics();
262
+ return true;
234
263
  } else if (!_this.state.animating) {
235
264
  // Don't need to worry about this.timerState because if we're sync, we were just
236
265
  // told to start, so our state is correct already. If we're not sync, this will
@@ -256,6 +285,17 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
256
285
  */
257
286
  _this.stop = function () {
258
287
  _this.clearTimeout();
288
+ if (_this.isVertical()) {
289
+ _this.promoteJob.stop();
290
+ _this.demoteJob.stop();
291
+ if (_this.state.animating || _this.state.promoted) {
292
+ _this.setState({
293
+ animating: false,
294
+ promoted: false
295
+ });
296
+ }
297
+ return;
298
+ }
259
299
  if (_this.state.animating) {
260
300
  _this.setState({
261
301
  animating: false
@@ -368,6 +408,15 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
368
408
  };
369
409
  _this.handleResize = function () {
370
410
  if (_this.node && !_this.props.marqueeDisabled) {
411
+ if (_this.isVertical()) {
412
+ // Toggling the line clamp only changes the height. A new width or text size can rewrap.
413
+ var _window$getComputedSt = window.getComputedStyle(_this.node),
414
+ fontSize = _window$getComputedSt.fontSize,
415
+ lineHeight = _window$getComputedSt.lineHeight;
416
+ var layout = "".concat((0, _verticalMeasure.round2)(_this.node.getBoundingClientRect().width), " ").concat(fontSize, " ").concat(lineHeight);
417
+ if (layout === _this.measuredLayout) return;
418
+ _this.measuredLayout = layout;
419
+ }
371
420
  _this.invalidateMetrics();
372
421
  if (_this.state.animating) {
373
422
  _this.cancelAnimation();
@@ -376,12 +425,22 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
376
425
  }
377
426
  };
378
427
  _this.handleMarqueeComplete = function () {
428
+ // Snap back before the reset timer so a vertical pause is visible immediately.
429
+ // The reset itself stays on a timeout so the restart is not batched with this update.
430
+ if (_this.isVertical() && _this.state.animating) {
431
+ _this.setState({
432
+ animating: false
433
+ });
434
+ }
379
435
  _this.resetAnimation();
380
436
  };
381
437
  _this.handleFocus = function (ev) {
382
438
  _this.isFocused = true;
383
439
  if (!_this.sync) {
384
440
  if (!_this.state.animating) {
441
+ if (_this.isVertical() && _this.contentFits === true) {
442
+ _this.invalidateMetrics();
443
+ }
385
444
  _this.startAnimation();
386
445
  }
387
446
  }
@@ -436,6 +495,11 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
436
495
  _this.resizeRegistry = null;
437
496
  _this.resizeObserver = null;
438
497
  _this.hasStartedRender = false;
498
+ _this.clipHeight = 0;
499
+ _this.measuredLayout = null;
500
+ _this.measurer = null;
501
+ _this.duplicateNode = null;
502
+ _this.removeFonts = null;
439
503
  return _this;
440
504
  }
441
505
  _inherits(_Class, _PureComponent);
@@ -458,6 +522,9 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
458
522
  });
459
523
  this.resizeObserver.observe(this.node);
460
524
  }
525
+ if (this.isVertical()) {
526
+ this.watchFonts();
527
+ }
461
528
  if (this.props.marqueeOn === 'render') {
462
529
  if (!this.props.marqueeDisabled) {
463
530
  this.hasStartedRender = true;
@@ -477,11 +544,16 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
477
544
  marqueeOn = _this$props.marqueeOn,
478
545
  marqueeDisabled = _this$props.marqueeDisabled,
479
546
  marqueeSpacing = _this$props.marqueeSpacing,
547
+ marqueeMaxLines = _this$props.marqueeMaxLines,
480
548
  marqueeSpeed = _this$props.marqueeSpeed,
481
549
  rtl = _this$props.rtl;
482
550
  var forceRestartMarquee = false;
483
551
  (0, _util.checkPropTypes)(this, this.props, prevProps);
484
- if (prevProps.locale !== locale || prevProps.rtl !== rtl || prevProps.marqueeSpacing !== marqueeSpacing || !(0, _util.shallowEqual)(prevProps.children, children) || invalidateProps && didPropChange(invalidateProps, prevProps, this.props)) {
552
+ if (!prevProps.marqueeDisabled && marqueeDisabled && this.isVertical()) {
553
+ this.isFocused = false;
554
+ this.isHovered = false;
555
+ }
556
+ if (prevProps.locale !== locale || prevProps.rtl !== rtl || prevProps.marqueeSpacing !== marqueeSpacing || prevProps.marqueeMaxLines !== marqueeMaxLines || !(0, _util.shallowEqual)(prevProps.children, children) || invalidateProps && didPropChange(invalidateProps, prevProps, this.props)) {
485
557
  forceRestartMarquee = marqueeOn === 'render' || this.sync && (this.state.animating || this.timerState > TimerState.CLEAR);
486
558
  if (forceRestartMarquee && marqueeOn === 'render') {
487
559
  this.hasStartedRender = false;
@@ -508,6 +580,7 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
508
580
  if (forceRestartMarquee || this.shouldStartMarquee()) {
509
581
  this.tryStartingAnimation(this.props.marqueeOn === 'render' ? this.props.marqueeOnRenderDelay : this.props.marqueeDelay);
510
582
  }
583
+ this.syncVerticalDuplicate();
511
584
  }
512
585
  }, {
513
586
  key: "componentWillUnmount",
@@ -526,6 +599,7 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
526
599
  this.resizeObserver = null;
527
600
  }
528
601
  (0, _dispatcher.off)('keydown', this.handlePointerHide, document);
602
+ if (this.removeFonts) this.removeFonts();
529
603
  }
530
604
  }, {
531
605
  key: "demote",
@@ -655,15 +729,80 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
655
729
  width: width
656
730
  };
657
731
  }
732
+ }, {
733
+ key: "isVertical",
734
+ value: function isVertical() {
735
+ return vertical;
736
+ }
737
+ }, {
738
+ key: "visibleLines",
739
+ value: function visibleLines() {
740
+ var marqueeMaxLines = this.props.marqueeMaxLines;
741
+ return Number.isFinite(marqueeMaxLines) && marqueeMaxLines > 0 ? Math.floor(marqueeMaxLines) : 1;
742
+ }
743
+ }, {
744
+ key: "watchFonts",
745
+ value: function watchFonts() {
746
+ var _this4 = this;
747
+ var fonts = typeof document !== 'undefined' ? document.fonts : null;
748
+ if (!fonts || typeof fonts.addEventListener !== 'function') return;
749
+ var onFonts = function onFonts() {
750
+ if (_this4.state.animating || _this4.timerState !== TimerState.CLEAR) return;
751
+ _this4.invalidateMetrics();
752
+ };
753
+ fonts.addEventListener('loadingdone', onFonts);
754
+ this.removeFonts = function () {
755
+ return fonts.removeEventListener('loadingdone', onFonts);
756
+ };
757
+ }
758
+ }, {
759
+ key: "syncVerticalDuplicate",
760
+ value: function syncVerticalDuplicate() {
761
+ if (!this.isVertical() || !this.state.promoted || !(this.distance > 0)) return;
762
+ var content = this.node;
763
+ var duplicate = this.duplicateNode;
764
+ if (content && duplicate && (duplicate.childNodes.length === 0 || duplicate.textContent !== content.textContent)) {
765
+ (0, _verticalMeasure.cloneContentInto)(content, duplicate);
766
+ }
767
+ }
768
+ }, {
769
+ key: "calculateVerticalMetrics",
770
+ value: function calculateVerticalMetrics() {
771
+ var content = this.node;
772
+ var measurer = this.measurer;
773
+ if (!content || !measurer || this.distance != null || this.props.marqueeDisabled) return;
774
+ (0, _verticalMeasure.cloneContentInto)(content, measurer);
775
+ var metrics;
776
+ try {
777
+ metrics = (0, _verticalMeasure.measureNode)(measurer, this.visibleLines());
778
+ } finally {
779
+ measurer.replaceChildren();
780
+ }
781
+ var basis = metrics.clipHeight > 0 ? metrics.clipHeight : metrics.lineHeight * this.visibleLines();
782
+ this.spacing = this.getSpacing(basis);
783
+ this.distance = metrics.overflows ? (0, _verticalMeasure.round2)(metrics.contentHeight + this.spacing) : 0;
784
+ this.contentFits = !this.shouldAnimate(this.distance);
785
+ this.clipHeight = metrics.clipHeight;
786
+ var overflow = this.calculateTextOverflow(this.distance);
787
+ this.setState(function (state) {
788
+ return state.overflow === overflow ? null : {
789
+ overflow: overflow
790
+ };
791
+ });
792
+ }
658
793
 
659
794
  /*
660
- * Determines if the component should marquee and the distance to animate
661
- *
662
- * @returns {undefined}
663
- */
795
+ * Determines if the component should marquee and the distance to animate
796
+ *
797
+ * @returns {undefined}
798
+ */
664
799
  }, {
665
800
  key: "calculateMetrics",
666
801
  value: function calculateMetrics() {
802
+ if (this.isVertical()) {
803
+ this.calculateVerticalMetrics();
804
+ return;
805
+ }
667
806
  var node = this.node;
668
807
 
669
808
  // TODO: absolute showing check (or assume that it won't be rendered if it isn't showing?)
@@ -759,9 +898,9 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
759
898
  }, {
760
899
  key: "validateTextDirection",
761
900
  value: function validateTextDirection() {
762
- var _this4 = this;
901
+ var _this5 = this;
763
902
  this.setState(function (state, props) {
764
- var rtl = determineTextDirection(_this4.node, props.rtl, props.forceDirection);
903
+ var rtl = determineTextDirection(_this5.node, props.rtl, props.forceDirection);
765
904
  return state.rtl === rtl ? null : {
766
905
  rtl: rtl
767
906
  };
@@ -773,6 +912,7 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
773
912
  var _this$props3 = this.props,
774
913
  alignment = _this$props3.alignment,
775
914
  children = _this$props3.children,
915
+ instanceCss = _this$props3.css,
776
916
  disabled = _this$props3.disabled,
777
917
  marqueeOn = _this$props3.marqueeOn,
778
918
  marqueeSpeed = _this$props3.marqueeSpeed,
@@ -780,6 +920,7 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
780
920
  var marqueeOnFocus = marqueeOn === 'focus';
781
921
  var marqueeOnHover = marqueeOn === 'hover';
782
922
  var marqueeOnRender = marqueeOn === 'render';
923
+ var mergedCss = (0, _utils.mergeCss)(css, instanceCss);
783
924
  if (marqueeOnFocus) {
784
925
  rest[focus] = this.handleFocus;
785
926
  }
@@ -801,8 +942,14 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
801
942
  delete rest.marqueeSpacing;
802
943
  delete rest.marqueeResetDelay;
803
944
  delete rest.marqueeSpeed;
945
+ delete rest.marqueeMaxLines;
804
946
  delete rest.remeasure;
805
947
  delete rest.rtl;
948
+ // The css prop styles the wrapped component. Only the marquee gets the merged map.
949
+ // A DOM element has no css prop, so the map would end up as an attribute.
950
+ if (instanceCss != null && typeof Wrapped !== 'string') {
951
+ rest.css = instanceCss;
952
+ }
806
953
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread(_objectSpread({}, rest), {}, {
807
954
  onBlur: this.handleBlur,
808
955
  disabled: disabled,
@@ -810,9 +957,14 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
810
957
  alignment: alignment,
811
958
  animating: this.state.animating,
812
959
  clientRef: this.cacheNode,
813
- css: css,
960
+ clipHeight: this.clipHeight,
961
+ css: mergedCss,
814
962
  distance: this.distance,
963
+ duplicateRef: this.cacheDuplicate,
964
+ maxLines: this.visibleLines(),
965
+ measurerRef: this.cacheMeasurer,
815
966
  onMarqueeComplete: this.handleMarqueeComplete,
967
+ orientation: orientation,
816
968
  overflow: this.state.overflow,
817
969
  spacing: this.spacing,
818
970
  rtl: this.state.rtl,
@@ -837,23 +989,28 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
837
989
  delete props.marqueeSpacing;
838
990
  delete props.marqueeResetDelay;
839
991
  delete props.marqueeSpeed;
992
+ delete props.marqueeMaxLines;
840
993
  delete props.remeasure;
841
994
  delete props.rtl;
995
+ // Keep css for a wrapped component that styles itself with it, as when the marquee runs.
996
+ if (typeof Wrapped === 'string') {
997
+ delete props.css;
998
+ }
842
999
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread({}, props));
843
1000
  }
844
1001
  }, {
845
1002
  key: "render",
846
1003
  value: function render() {
847
- var _this5 = this;
1004
+ var _this6 = this;
848
1005
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Resizable.ResizeContext.Consumer, {
849
1006
  children: function children(register) {
850
- if (!_this5.resizeRegistry && register) {
851
- _this5.resizeRegistry = register(_this5.handleResize);
1007
+ if (!_this6.resizeRegistry && register) {
1008
+ _this6.resizeRegistry = register(_this6.handleResize);
852
1009
  }
853
- if (_this5.props.marqueeDisabled) {
854
- return _this5.renderWrapped();
1010
+ if (_this6.props.marqueeDisabled) {
1011
+ return _this6.renderWrapped();
855
1012
  } else {
856
- return _this5.renderMarquee();
1013
+ return _this6.renderMarquee();
857
1014
  }
858
1015
  }
859
1016
  });
@@ -874,6 +1031,31 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
874
1031
  * @public
875
1032
  */
876
1033
  children: _propTypes["default"].node,
1034
+ /**
1035
+ * Customizes the marquee's internal elements.
1036
+ *
1037
+ * The following classes are supported:
1038
+ *
1039
+ * * `marquee` - The root component class
1040
+ * * `animate` - Applied to the inner content node when the text is animating
1041
+ * * `content` - The content node of a vertical marquee
1042
+ * * `spacing` - The spacing node used between the repeated content
1043
+ * * `text` - The inner content node
1044
+ * * `vertical` - The root modifier for a vertical marquee
1045
+ * * `willAnimate` - Applied to the inner content node shortly before animation
1046
+ *
1047
+ * An app class is appended to the class from
1048
+ * {@link ui/Marquee.MarqueeDecorator.defaultConfig.css}.
1049
+ *
1050
+ * When the decorator wraps a component, such as a `Button`, that component also receives
1051
+ * `css` to style itself. Because the same map is merged into the marquee, a `marquee`,
1052
+ * `text`, `animate`, `spacing` or `willAnimate` class in it also applies to the marquee's
1053
+ * internal elements.
1054
+ *
1055
+ * @type {Object}
1056
+ * @public
1057
+ */
1058
+ css: _propTypes["default"].object,
877
1059
  /**
878
1060
  * Passed through to the wrapped component.
879
1061
  *
@@ -922,6 +1104,15 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
922
1104
  * @type {Boolean}
923
1105
  */
924
1106
  marqueeDisabled: _propTypes["default"].bool,
1107
+ /**
1108
+ * Number of text lines that stay visible when the decorator is configured with
1109
+ * `orientation: 'vertical'`.
1110
+ *
1111
+ * @type {Number}
1112
+ * @default 3
1113
+ * @public
1114
+ */
1115
+ marqueeMaxLines: _propTypes["default"].number,
925
1116
  /**
926
1117
  * Determines what triggers the marquee to start its animation.
927
1118
  *
@@ -991,6 +1182,7 @@ var MarqueeDecorator = exports.MarqueeDecorator = (0, _hoc["default"])(defaultCo
991
1182
  rtl: _propTypes["default"].bool
992
1183
  }, _Class.defaultProps = {
993
1184
  marqueeDelay: 1000,
1185
+ marqueeMaxLines: 3,
994
1186
  marqueeOn: 'focus',
995
1187
  marqueeOnRenderDelay: 1000,
996
1188
  marqueeResetDelay: 1000,
@@ -58,8 +58,10 @@ corresponding internal elements and states of this component.
58
58
  * The following classes are supported:
59
59
  * * `marquee` - The root component class
60
60
  * * `animate` - Applied to the inner content node when the text is animating
61
+ * * `content` - The content node of a vertical marquee
61
62
  * * `spacing` - The spacing node used between the repeated content
62
63
  * * `text` - The inner content node
64
+ * * `vertical` - The root modifier for a vertical marquee
63
65
  * * `willAnimate` - Applied to the inner content node shortly before animation
64
66
  */
65
67
  css?: object;
@@ -69,10 +71,18 @@ corresponding internal elements and states of this component.
69
71
  * Usually, the `distance` is the width of the text minus the width of the container
70
72
  */
71
73
  distance?: number;
74
+ /**
75
+ * Number of text lines that stay visible when `orientation` is `'vertical'` .
76
+ */
77
+ maxLines?: number;
72
78
  /**
73
79
  * Called when the marquee completes its animation
74
80
  */
75
81
  onMarqueeComplete?: Function;
82
+ /**
83
+ * Direction the marquee scrolls.
84
+ */
85
+ orientation?: "horizontal" | "vertical";
76
86
  /**
77
87
  * Text overflow setting. Either `'clip'` or `'ellipsis'`
78
88
  */
@@ -107,6 +117,18 @@ export class MarqueeBase extends React.Component<
107
117
  Merge<React.HTMLProps<HTMLElement>, MarqueeBaseProps>
108
118
  > {}
109
119
 
120
+ export interface MarqueeProps extends Merge<
121
+ MarqueeBaseProps,
122
+ MarqueeDecoratorProps
123
+ > {}
124
+ /**
125
+ * A minimally-styled marquee component.
126
+ */
127
+
128
+ export class Marquee extends React.Component<
129
+ Merge<React.HTMLProps<HTMLElement>, MarqueeProps>
130
+ > {}
131
+
110
132
  export interface MarqueeDecoratorConfig extends Object {
111
133
  /**
112
134
  * Property containing the callback to stop the animation when `marqueeOn` is `'focus'`
@@ -123,8 +145,10 @@ corresponding internal elements and states of this component.
123
145
  * The following classes are supported:
124
146
  * * `marquee` - The root component class
125
147
  * * `animate` - Applied to the inner content node when the text is animating
148
+ * * `content` - The content node of a vertical marquee
126
149
  * * `spacing` - The spacing node used between the repeated content
127
150
  * * `text` - The inner content node
151
+ * * `vertical` - The root modifier for a vertical marquee
128
152
  * * `willAnimate` - Applied to the inner content node shortly before animation
129
153
  */
130
154
  css?: object;
@@ -153,6 +177,16 @@ Expects an array of props which on change trigger invalidateMetrics.
153
177
  * * `'ltr'` if the text should marquee to the left
154
178
  */
155
179
  marqueeDirection?: Function;
180
+ /**
181
+ * Direction the marquee scrolls.
182
+ *
183
+ * `'vertical'` scrolls overflowing wrapped text by its laid-out block height.
184
+ `'horizontal'` is the single-line marquee.
185
+ *
186
+ * This is a config option rather than a prop so a wrapped component can keep its own
187
+ `orientation` prop.
188
+ */
189
+ orientation?: "horizontal" | "vertical";
156
190
  }
157
191
  export interface MarqueeDecoratorProps {
158
192
  /**
@@ -164,6 +198,27 @@ export interface MarqueeDecoratorProps {
164
198
  */
165
199
  children?: React.ReactNode;
166
200
  /**
201
+ * Customizes the marquee's internal elements.
202
+ *
203
+ * The following classes are supported:
204
+ * * `marquee` - The root component class
205
+ * * `animate` - Applied to the inner content node when the text is animating
206
+ * * `content` - The content node of a vertical marquee
207
+ * * `spacing` - The spacing node used between the repeated content
208
+ * * `text` - The inner content node
209
+ * * `vertical` - The root modifier for a vertical marquee
210
+ * * `willAnimate` - Applied to the inner content node shortly before animation
211
+ *
212
+ * An app class is appended to the class from
213
+ .
214
+ *
215
+ * When the decorator wraps a component, such as a `Button` , that component also receives
216
+ `css` to style itself. Because the same map is merged into the marquee, a `marquee` ,
217
+ `text` , `animate` , `spacing` or `willAnimate` class in it also applies to the marquee's
218
+ internal elements.
219
+ */
220
+ css?: object;
221
+ /**
167
222
  * Passed through to the wrapped component.
168
223
  *
169
224
  * Does not affect Marquee behavior except that components that are `marqueeOn="focus"`
@@ -196,6 +251,11 @@ In other words, it will not consider the text content for determining the direct
196
251
  * Disables all marquee behavior and removes supporting markup.
197
252
  */
198
253
  marqueeDisabled?: boolean;
254
+ /**
255
+ * Number of text lines that stay visible when the decorator is configured with
256
+ `orientation: 'vertical'` .
257
+ */
258
+ marqueeMaxLines?: number;
199
259
  /**
200
260
  * Determines what triggers the marquee to start its animation.
201
261
  */
@@ -241,16 +301,4 @@ export function MarqueeDecorator<P>(
241
301
  Component: React.ComponentType<P> | string,
242
302
  ): React.ComponentType<P & MarqueeDecoratorProps>;
243
303
 
244
- export interface MarqueeProps extends Merge<
245
- MarqueeBaseProps,
246
- MarqueeDecoratorProps
247
- > {}
248
- /**
249
- * A minimally-styled marquee component.
250
- */
251
-
252
- export class Marquee extends React.Component<
253
- Merge<React.HTMLProps<HTMLElement>, MarqueeProps>
254
- > {}
255
-
256
304
  export default Marquee;
@@ -5,10 +5,10 @@ var _react = require("@testing-library/react");
5
5
  var _index = require("../index.js");
6
6
  var _jsxRuntime = require("react/jsx-runtime");
7
7
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
8
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
8
+ function _defineProperties(r, t) { for (var o = 0; o < t.length; o++) { var i = t[o]; i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(r, _toPropertyKey(i.key), i); } }
9
9
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
10
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
11
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ function _toPropertyKey(r) { var o = _toPrimitive(r, "string"); return "symbol" == typeof o ? o : o + ""; }
11
+ function _toPrimitive(t, e) { if ("object" != typeof t || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
12
12
  var ltrText = 'This is some fine latin text.',
13
13
  rtlText = 'العربية - العراق',
14
14
  ltrArray = ['The first quick brown fox jumped over the first lazy dog. The bean bird flies at sundown.', 'The second quick brown fox jumped over the second lazy dog. The bean bird flies at sundown.'];