@enact/ui 4.5.2 → 4.6.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.
- package/AnnounceDecorator/Announce.js +1 -40
- package/AnnounceDecorator/AnnounceDecorator.js +3 -21
- package/AnnounceDecorator/tests/Announce-specs.js +2 -7
- package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +2 -6
- package/AnnounceDecorator/tests/useAnnounce-specs.js +8 -19
- package/AnnounceDecorator/useAnnounce.js +0 -6
- package/BodyText/BodyText.d.ts +1 -1
- package/BodyText/BodyText.js +8 -28
- package/BodyText/tests/BodyText-specs.js +0 -19
- package/Button/Button.d.ts +6 -6
- package/Button/Button.js +33 -63
- package/Button/tests/Button-specs.js +0 -26
- package/CHANGELOG.md +30 -0
- package/Cancelable/Cancelable.js +8 -47
- package/Cancelable/cancelHandler.js +5 -12
- package/Cancelable/modalHandler.js +3 -11
- package/Cancelable/tests/Cancelable-specs.js +3 -57
- package/Changeable/Changeable.js +2 -34
- package/Changeable/tests/Changeable-specs.js +20 -66
- package/ComponentOverride/ComponentOverride.js +1 -13
- package/FloatingLayer/FloatingLayer.js +17 -73
- package/FloatingLayer/FloatingLayerContainer.js +0 -15
- package/FloatingLayer/FloatingLayerDecorator.js +4 -17
- package/FloatingLayer/Scrim.js +9 -53
- package/FloatingLayer/index.js +0 -4
- package/FloatingLayer/tests/FloatingLayer-specs.js +8 -22
- package/FloatingLayer/tests/Scrim-specs.js +0 -9
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +0 -13
- package/FloatingLayer/useFloatingLayer.js +3 -14
- package/FloatingLayer/useFloatingLayerDecorator.js +3 -11
- package/ForwardRef/ForwardRef.js +1 -10
- package/GridListImageItem/GridListImageItem.d.ts +1 -1
- package/GridListImageItem/GridListImageItem.js +18 -51
- package/Group/Group.js +5 -36
- package/Group/GroupItem.js +16 -33
- package/Group/tests/Group-specs.js +0 -32
- package/Heading/Heading.js +8 -36
- package/Heading/tests/Heading-specs.js +81 -14
- package/Icon/Icon.d.ts +4 -4
- package/Icon/Icon.js +19 -53
- package/Icon/tests/Icon-specs.js +0 -22
- package/IconButton/IconButton.d.ts +4 -4
- package/IconButton/IconButton.js +17 -55
- package/IconButton/tests/IconButton-specs.js +0 -7
- package/Image/Image.js +17 -46
- package/Image/tests/Image-specs.js +0 -14
- package/ImageItem/ImageItem.js +18 -47
- package/ImageItem/tests/ImageItem-specs.js +0 -25
- package/Item/Item.js +9 -33
- package/Item/tests/Item-specs.js +0 -24
- package/LabeledIcon/LabeledIcon.d.ts +2 -2
- package/LabeledIcon/LabeledIcon.js +22 -53
- package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
- package/Layout/Cell.js +18 -44
- package/Layout/Layout.d.ts +16 -16
- package/Layout/Layout.js +23 -46
- package/Layout/tests/Layout-specs.js +10 -39
- package/Marquee/MarqueeBase.js +29 -63
- package/Marquee/MarqueeController.js +11 -72
- package/Marquee/MarqueeDecorator.js +70 -196
- package/Marquee/index.js +1 -5
- package/Marquee/tests/Marquee-specs.js +295 -87
- package/Measurable/Measurable.js +12 -34
- package/Measurable/tests/Measurable-specs.js +115 -0
- package/Media/Media.js +15 -65
- package/Media/tests/Media-specs.js +168 -0
- package/Placeholder/PlaceholderControllerDecorator.js +7 -43
- package/Placeholder/PlaceholderDecorator.js +7 -38
- package/Placeholder/index.js +1 -5
- package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +25 -0
- package/Placeholder/tests/PlaceholderDecorator-specs.js +28 -0
- package/ProgressBar/ProgressBar.js +14 -45
- package/ProgressBar/tests/ProgressBar-specs.js +0 -17
- package/RadioDecorator/RadioControllerDecorator.js +1 -29
- package/RadioDecorator/RadioDecorator.js +4 -42
- package/RadioDecorator/tests/RadioDecorator-specs.js +12 -49
- package/Repeater/Repeater.js +9 -33
- package/Repeater/tests/Repeater-specs.js +0 -38
- package/Resizable/Resizable.js +9 -37
- package/Resizable/tests/Resizable-specs.js +34 -0
- package/Routable/Link.js +11 -47
- package/Routable/Routable.d.ts +2 -2
- package/Routable/Routable.js +12 -35
- package/Routable/Route.js +0 -6
- package/Routable/Router.js +15 -58
- package/Routable/tests/Routable-specs.js +7 -33
- package/Routable/tests/Router-specs.js +18 -44
- package/Routable/useLink.js +4 -8
- package/Routable/util.js +18 -24
- package/Scrollable/ScrollAnimator.js +49 -65
- package/Scrollable/ScrollThumb.js +2 -13
- package/Scrollable/Scrollable.js +180 -387
- package/Scrollable/ScrollableNative.js +189 -392
- package/Scrollable/Scrollbar.js +30 -102
- package/Scroller/Scroller.js +15 -39
- package/Scroller/ScrollerBasic.js +34 -89
- package/Scroller/UiScrollerBase.js +31 -84
- package/Scroller/tests/Scroller-specs.js +56 -0
- package/Skinnable/Skinnable.js +11 -38
- package/Skinnable/tests/Skinnable-specs.js +3 -74
- package/Skinnable/tests/useSkins-specs.js +1 -13
- package/Skinnable/tests/util-specs.js +0 -14
- package/Skinnable/useSkins.js +8 -15
- package/Skinnable/util.js +9 -20
- package/Slider/Knob.js +5 -24
- package/Slider/PositionDecorator.js +16 -54
- package/Slider/Slider.d.ts +2 -2
- package/Slider/Slider.js +29 -67
- package/Slider/tests/Slider-specs.js +94 -7
- package/Slider/utils.js +0 -2
- package/SlotItem/SlotItem.d.ts +1 -1
- package/SlotItem/SlotItem.js +17 -43
- package/SlotItem/tests/SlotItem-specs.js +0 -5
- package/Slottable/Slottable.js +4 -12
- package/Slottable/tests/Slottable-specs.js +19 -46
- package/Slottable/tests/useSlots-specs.js +27 -65
- package/Slottable/useSlots.js +8 -33
- package/Spinner/Spinner.d.ts +1 -1
- package/Spinner/Spinner.js +16 -43
- package/Spinner/tests/Spinner-specs.js +0 -15
- package/ToggleIcon/ToggleIcon.js +10 -36
- package/ToggleIcon/tests/ToggleIcon-specs.js +0 -16
- package/ToggleItem/ToggleItem.d.ts +3 -3
- package/ToggleItem/ToggleItem.js +18 -55
- package/ToggleItem/tests/ToggleItem-specs.js +0 -30
- package/Toggleable/Toggle.js +1 -15
- package/Toggleable/Toggleable.js +12 -45
- package/Toggleable/tests/Toggleable-specs.js +28 -96
- package/Toggleable/useToggle.js +3 -19
- package/Touchable/ClickAllow.js +5 -14
- package/Touchable/Drag.js +16 -54
- package/Touchable/Flick.js +11 -42
- package/Touchable/Hold.js +21 -68
- package/Touchable/Touch.js +37 -65
- package/Touchable/Touchable.js +32 -71
- package/Touchable/config.js +8 -22
- package/Touchable/tests/Touchable-specs.js +270 -119
- package/Touchable/tests/useTouch-specs.js +6 -80
- package/Touchable/useTouch.js +17 -34
- package/Transition/Transition.js +37 -118
- package/Transition/tests/Transition-specs.js +20 -60
- package/ViewManager/Arranger.js +10 -22
- package/ViewManager/TransitionGroup.js +32 -107
- package/ViewManager/View.js +35 -91
- package/ViewManager/ViewManager.d.ts +1 -1
- package/ViewManager/ViewManager.js +20 -84
- package/ViewManager/tests/View-specs.js +0 -17
- package/ViewManager/tests/ViewManager-specs.js +236 -305
- package/ViewManager/tests/test-utils.js +0 -8
- package/VirtualList/UiVirtualListBase.js +259 -409
- package/VirtualList/VirtualList.d.ts +4 -4
- package/VirtualList/VirtualList.js +29 -69
- package/VirtualList/VirtualListBase.js +0 -3
- package/VirtualList/VirtualListBasic.js +273 -431
- package/VirtualList/tests/VirtualGridList-native-specs.js +161 -0
- package/VirtualList/tests/VirtualGridList-specs.js +614 -0
- package/VirtualList/tests/VirtualList-native-specs.js +152 -0
- package/VirtualList/tests/VirtualList-specs.js +423 -95
- package/internal/IdProvider/IdProvider.js +7 -21
- package/internal/IdProvider/Provider.js +4 -17
- package/internal/IdProvider/tests/IdProvider-specs.js +44 -0
- package/internal/IdProvider/tests/useId-specs.js +6 -20
- package/internal/IdProvider/useId.js +0 -6
- package/internal/Pure/Pure.js +3 -30
- package/internal/Pure/tests/Pure-specs.js +88 -0
- package/internal/localized-fonts/localized-fonts.js +33 -62
- package/internal/localized-fonts/tests/localized-fonts-specs.js +33 -0
- package/internal/selection/selection.js +1 -6
- package/internal/selection/tests/selection-specs.js +6 -4
- package/internal/validators/tests/validators-specs.js +80 -0
- package/internal/validators/validators.js +14 -34
- package/package.json +9 -3
- package/resolution/ResolutionDecorator.js +4 -40
- package/resolution/index.js +0 -7
- package/resolution/resolution.js +42 -80
- package/resolution/tests/ResolutionDecorator-specs.js +4 -11
- package/resolution/tests/resolution-specs.js +2 -2
- package/useControlledState/tests/useControlledState-specs.js +15 -46
- package/useControlledState/useControlledState.js +11 -22
- package/useScroll/ScrollAnimator.js +49 -65
- package/useScroll/Scrollbar.js +22 -58
- package/useScroll/ScrollbarTrack.js +3 -19
- package/useScroll/useScroll.js +267 -454
- package/useScroll/utilDOM.js +8 -14
- package/useScroll/utilEvent.js +0 -4
|
@@ -4,74 +4,42 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.MarqueeDecorator = void 0;
|
|
7
|
-
|
|
8
7
|
var _direction = _interopRequireDefault(require("direction"));
|
|
9
|
-
|
|
10
8
|
var _dispatcher = require("@enact/core/dispatcher");
|
|
11
|
-
|
|
12
9
|
var _handle = require("@enact/core/handle");
|
|
13
|
-
|
|
14
10
|
var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
|
|
15
|
-
|
|
16
11
|
var _deprecate = _interopRequireDefault(require("@enact/core/internal/deprecate"));
|
|
17
|
-
|
|
18
12
|
var _keymap = require("@enact/core/keymap");
|
|
19
|
-
|
|
20
13
|
var _util = require("@enact/core/util");
|
|
21
|
-
|
|
22
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
23
|
-
|
|
24
15
|
var _react = require("react");
|
|
25
|
-
|
|
26
16
|
var _reactDom = require("react-dom");
|
|
27
|
-
|
|
28
17
|
var _warning = _interopRequireDefault(require("warning"));
|
|
29
|
-
|
|
30
18
|
var _resolution = require("../resolution");
|
|
31
|
-
|
|
32
19
|
var _Resizable = require("../Resizable");
|
|
33
|
-
|
|
34
20
|
var _MarqueeBase = _interopRequireDefault(require("./MarqueeBase"));
|
|
35
|
-
|
|
36
21
|
var _MarqueeController = require("./MarqueeController");
|
|
37
|
-
|
|
38
22
|
var _MarqueeModule = _interopRequireDefault(require("./Marquee.module.css"));
|
|
39
|
-
|
|
40
23
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
41
|
-
|
|
42
24
|
var _excluded = ["alignment", "children", "disabled", "marqueeOn", "marqueeSpeed"];
|
|
43
|
-
|
|
44
25
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
45
|
-
|
|
46
26
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
47
|
-
|
|
48
27
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
49
|
-
|
|
50
28
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
51
|
-
|
|
52
29
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
53
|
-
|
|
54
30
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
55
|
-
|
|
56
31
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
57
|
-
|
|
58
32
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
59
|
-
|
|
60
33
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
61
|
-
|
|
62
34
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
63
|
-
|
|
64
35
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
65
|
-
|
|
66
36
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
67
|
-
|
|
68
37
|
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
69
|
-
|
|
70
38
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
71
|
-
|
|
72
39
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
73
|
-
|
|
74
40
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
41
|
+
// The minimum number of milliseconds to wait before resetting the marquee position after it finishes.
|
|
42
|
+
var MINIMUM_MARQUEE_RESET_DELAY = 40;
|
|
75
43
|
|
|
76
44
|
/**
|
|
77
45
|
* Default configuration parameters for {@link ui/Marquee.MarqueeDecorator}
|
|
@@ -89,7 +57,6 @@ var defaultConfig = {
|
|
|
89
57
|
* @memberof ui/Marquee.MarqueeDecorator.defaultConfig
|
|
90
58
|
*/
|
|
91
59
|
blur: 'onBlur',
|
|
92
|
-
|
|
93
60
|
/**
|
|
94
61
|
* Optional CSS class name to customize the marquee `component`
|
|
95
62
|
*
|
|
@@ -99,7 +66,6 @@ var defaultConfig = {
|
|
|
99
66
|
* @deprecated Will be removed in 5.0.0. Use {@link ui/Marquee.MarqueeDecorator.defaultConfig.css} instead.
|
|
100
67
|
*/
|
|
101
68
|
className: null,
|
|
102
|
-
|
|
103
69
|
/**
|
|
104
70
|
* The base marquee component wrapping the content.
|
|
105
71
|
*
|
|
@@ -108,7 +74,6 @@ var defaultConfig = {
|
|
|
108
74
|
* @memberof ui/Marquee.MarqueeDecorator.defaultConfig
|
|
109
75
|
*/
|
|
110
76
|
component: _MarqueeBase["default"],
|
|
111
|
-
|
|
112
77
|
/**
|
|
113
78
|
* Customizes the component by mapping the supplied collection of CSS class names to the
|
|
114
79
|
* corresponding internal elements and states of this component.
|
|
@@ -126,7 +91,6 @@ var defaultConfig = {
|
|
|
126
91
|
* @memberof ui/Marquee.MarqueeDecorator.defaultConfig
|
|
127
92
|
*/
|
|
128
93
|
css: null,
|
|
129
|
-
|
|
130
94
|
/**
|
|
131
95
|
* Property containing the callback to start the animation when `marqueeOn` is `'hover'`
|
|
132
96
|
*
|
|
@@ -135,7 +99,6 @@ var defaultConfig = {
|
|
|
135
99
|
* @memberof ui/Marquee.MarqueeDecorator.defaultConfig
|
|
136
100
|
*/
|
|
137
101
|
enter: 'onMouseEnter',
|
|
138
|
-
|
|
139
102
|
/**
|
|
140
103
|
* Property containing the callback to start the animation when `marqueeOn` is `'focus'`
|
|
141
104
|
*
|
|
@@ -144,7 +107,6 @@ var defaultConfig = {
|
|
|
144
107
|
* @memberof ui/Marquee.MarqueeDecorator.defaultConfig
|
|
145
108
|
*/
|
|
146
109
|
focus: 'onFocus',
|
|
147
|
-
|
|
148
110
|
/**
|
|
149
111
|
* Invalidate the distance if any property (like 'inline') changes.
|
|
150
112
|
* Expects an array of props which on change trigger invalidateMetrics.
|
|
@@ -154,7 +116,6 @@ var defaultConfig = {
|
|
|
154
116
|
* @memberof ui/Marquee.MarqueeDecorator.defaultConfig
|
|
155
117
|
*/
|
|
156
118
|
invalidateProps: ['remeasure'],
|
|
157
|
-
|
|
158
119
|
/**
|
|
159
120
|
* Property containing the callback to stop the animation when `marqueeOn` is `'hover'`
|
|
160
121
|
*
|
|
@@ -163,7 +124,6 @@ var defaultConfig = {
|
|
|
163
124
|
* @memberof ui/Marquee.MarqueeDecorator.defaultConfig
|
|
164
125
|
*/
|
|
165
126
|
leave: 'onMouseLeave',
|
|
166
|
-
|
|
167
127
|
/**
|
|
168
128
|
* A function that determines the text directionality of a string.
|
|
169
129
|
*
|
|
@@ -179,6 +139,7 @@ var defaultConfig = {
|
|
|
179
139
|
return (0, _direction["default"])(str) === 'rtl' ? 'rtl' : 'ltr';
|
|
180
140
|
}
|
|
181
141
|
};
|
|
142
|
+
|
|
182
143
|
/*
|
|
183
144
|
* Checks whether any of the invalidateProps has changed or not
|
|
184
145
|
*
|
|
@@ -188,19 +149,17 @@ var defaultConfig = {
|
|
|
188
149
|
* @returns {Boolean} `true` if any of the props changed
|
|
189
150
|
* @private
|
|
190
151
|
*/
|
|
191
|
-
|
|
192
152
|
var didPropChange = function didPropChange(propList, prev, next) {
|
|
193
153
|
var hasPropsChanged = propList.map(function (i) {
|
|
194
154
|
return prev[i] !== next[i];
|
|
195
155
|
});
|
|
196
156
|
return hasPropsChanged.indexOf(true) !== -1;
|
|
197
157
|
};
|
|
158
|
+
|
|
198
159
|
/*
|
|
199
160
|
* There's only one timer shared for Marquee so we need to keep track of what we may be using it
|
|
200
161
|
* for. We may need to clean up certain things as we move among states.
|
|
201
162
|
*/
|
|
202
|
-
|
|
203
|
-
|
|
204
163
|
var TimerState = {
|
|
205
164
|
CLEAR: 0,
|
|
206
165
|
// No timers pending
|
|
@@ -209,8 +168,8 @@ var TimerState = {
|
|
|
209
168
|
RESET_PENDING: 2,
|
|
210
169
|
// Marquee finished, waiting for reset delay
|
|
211
170
|
SYNCSTART_PENDING: 3 // Waiting to alert Controller that we want to start marqueeing
|
|
212
|
-
|
|
213
171
|
};
|
|
172
|
+
|
|
214
173
|
/**
|
|
215
174
|
* A higher-order component that provides marquee functionalities.
|
|
216
175
|
*
|
|
@@ -222,18 +181,15 @@ var TimerState = {
|
|
|
222
181
|
* @hoc
|
|
223
182
|
* @public
|
|
224
183
|
*/
|
|
225
|
-
|
|
226
184
|
var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
|
|
227
185
|
var _class;
|
|
228
|
-
|
|
229
186
|
var blur = config.blur,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
187
|
+
MarqueeComponent = config.component,
|
|
188
|
+
enter = config.enter,
|
|
189
|
+
focus = config.focus,
|
|
190
|
+
invalidateProps = config.invalidateProps,
|
|
191
|
+
leave = config.leave,
|
|
192
|
+
marqueeDirection = config.marqueeDirection;
|
|
237
193
|
if (config.className) {
|
|
238
194
|
(0, _deprecate["default"])({
|
|
239
195
|
name: 'ui/MarqueeDecorator.config.className',
|
|
@@ -241,16 +197,15 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
241
197
|
until: '5.0.0'
|
|
242
198
|
});
|
|
243
199
|
}
|
|
244
|
-
|
|
245
200
|
var css = typeof config.css === 'object' && config.css || {
|
|
246
201
|
marquee: config.className
|
|
247
|
-
};
|
|
202
|
+
};
|
|
248
203
|
|
|
204
|
+
// Generate functions to forward events to containers
|
|
249
205
|
var forwardBlur = (0, _handle.forward)(blur);
|
|
250
206
|
var forwardFocus = (0, _handle.forward)(focus);
|
|
251
207
|
var forwardEnter = (0, _handle.forward)(enter);
|
|
252
208
|
var forwardLeave = (0, _handle.forward)(leave);
|
|
253
|
-
|
|
254
209
|
var determineTextDirection = function determineTextDirection(node, rtl, forceDirection) {
|
|
255
210
|
// Text directionality is a function of locale direction (rtl), content (node.textContent),
|
|
256
211
|
// and props (forceDirection) in increasing order of significance.
|
|
@@ -259,20 +214,14 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
259
214
|
} else if (node) {
|
|
260
215
|
rtl = marqueeDirection(node.textContent) === 'rtl';
|
|
261
216
|
}
|
|
262
|
-
|
|
263
217
|
return rtl;
|
|
264
218
|
};
|
|
265
|
-
|
|
266
219
|
return _class = /*#__PURE__*/function (_PureComponent) {
|
|
267
220
|
_inherits(_class, _PureComponent);
|
|
268
|
-
|
|
269
221
|
var _super = _createSuper(_class);
|
|
270
|
-
|
|
271
222
|
function _class(props) {
|
|
272
223
|
var _this;
|
|
273
|
-
|
|
274
224
|
_classCallCheck(this, _class);
|
|
275
|
-
|
|
276
225
|
_this = _super.call(this, props);
|
|
277
226
|
_this.promoteJob = new _util.Job(function () {
|
|
278
227
|
if (_this.contentFits === false) {
|
|
@@ -290,10 +239,8 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
290
239
|
} : null;
|
|
291
240
|
});
|
|
292
241
|
});
|
|
293
|
-
|
|
294
242
|
_this.start = function () {
|
|
295
243
|
var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props.marqueeDelay;
|
|
296
|
-
|
|
297
244
|
if (_this.props.marqueeDisabled) {
|
|
298
245
|
// if marquee isn't necessary, do not set `animating` but return `true` to mark it
|
|
299
246
|
// complete if it's synchronized so it doesn't block other instances.
|
|
@@ -305,7 +252,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
305
252
|
// our group already did it.
|
|
306
253
|
_this.setTimeout(function () {
|
|
307
254
|
_this.calculateMetrics();
|
|
308
|
-
|
|
309
255
|
if (_this.contentFits === false) {
|
|
310
256
|
_this.setState({
|
|
311
257
|
promoted: true,
|
|
@@ -317,28 +263,21 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
317
263
|
}, delay, TimerState.START_PENDING);
|
|
318
264
|
}
|
|
319
265
|
};
|
|
320
|
-
|
|
321
266
|
_this.stop = function () {
|
|
322
267
|
_this.clearTimeout();
|
|
323
|
-
|
|
324
268
|
if (_this.state.animating) {
|
|
325
269
|
_this.setState({
|
|
326
270
|
animating: false
|
|
327
271
|
});
|
|
328
272
|
}
|
|
329
|
-
|
|
330
273
|
_this.demote();
|
|
331
274
|
};
|
|
332
|
-
|
|
333
275
|
_this.tryStartingAnimation = function (delay) {
|
|
334
276
|
if (_this.state.animating || _this.timerState !== TimerState.CLEAR) return;
|
|
335
|
-
|
|
336
277
|
_this.startAnimation(delay);
|
|
337
278
|
};
|
|
338
|
-
|
|
339
279
|
_this.startAnimation = function (delay) {
|
|
340
280
|
_this.promote(delay);
|
|
341
|
-
|
|
342
281
|
if (_this.sync) {
|
|
343
282
|
// If we're running a timer for anything, we should let that finish, unless it's
|
|
344
283
|
// another syncstart request. We should probably check to see if the start request
|
|
@@ -348,7 +287,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
348
287
|
if (_this.timerState !== TimerState.CLEAR && _this.timerState !== TimerState.SYNCSTART_PENDING) {
|
|
349
288
|
return;
|
|
350
289
|
}
|
|
351
|
-
|
|
352
290
|
_this.setTimeout(function () {
|
|
353
291
|
_this.context.start();
|
|
354
292
|
}, delay, TimerState.SYNCSTART_PENDING);
|
|
@@ -356,25 +294,28 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
356
294
|
_this.start(delay);
|
|
357
295
|
}
|
|
358
296
|
};
|
|
359
|
-
|
|
360
297
|
_this.restartAnimation = function (delay) {
|
|
361
298
|
(0, _reactDom.flushSync)(function () {
|
|
362
299
|
_this.setState({
|
|
363
300
|
animating: false
|
|
364
301
|
});
|
|
365
|
-
});
|
|
366
|
-
|
|
302
|
+
});
|
|
303
|
+
// synchronized Marquees defer to the controller to restart them
|
|
367
304
|
if (_this.sync) {
|
|
368
|
-
|
|
305
|
+
// Even in sync mode, it is necessary to apply a minimum reset delay.
|
|
306
|
+
// In detail, the timer with 40ms delay needs to be applied only when marqueeDelay is less than 40,
|
|
307
|
+
// but for consistency, we decided to apply 40ms in all cases.
|
|
308
|
+
_this.setTimeout(function () {
|
|
309
|
+
_this.context.complete(_assertThisInitialized(_this));
|
|
310
|
+
}, MINIMUM_MARQUEE_RESET_DELAY, TimerState.RESET_PENDING);
|
|
369
311
|
} else if (!_this.state.animating) {
|
|
370
312
|
_this.startAnimation(delay);
|
|
371
313
|
}
|
|
372
314
|
};
|
|
373
|
-
|
|
374
315
|
_this.resetAnimation = function () {
|
|
375
|
-
var delay = Math.max(
|
|
316
|
+
var delay = Math.max(MINIMUM_MARQUEE_RESET_DELAY, _this.props.marqueeResetDelay + _this.props.marqueeDelay);
|
|
317
|
+
// If we're already timing a start action, don't reset. Start actions will clear us if
|
|
376
318
|
// sync.
|
|
377
|
-
|
|
378
319
|
if (_this.timerState === TimerState.CLEAR) {
|
|
379
320
|
// If invoked immediately, the setState call in restartAnimation is batched and will
|
|
380
321
|
// break any non-marquee-on-render instances because the subsequent startAnimation
|
|
@@ -389,62 +330,46 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
389
330
|
}, 0, TimerState.RESET_PENDING);
|
|
390
331
|
}
|
|
391
332
|
};
|
|
392
|
-
|
|
393
333
|
_this.cancelAnimation = function () {
|
|
394
334
|
if (_this.sync) {
|
|
395
335
|
_this.context.cancel(_assertThisInitialized(_this));
|
|
396
|
-
|
|
397
336
|
return;
|
|
398
337
|
}
|
|
399
|
-
|
|
400
338
|
_this.stop();
|
|
401
339
|
};
|
|
402
|
-
|
|
403
340
|
_this.handleResize = function () {
|
|
404
341
|
if (_this.node && !_this.props.marqueeDisabled) {
|
|
405
342
|
_this.invalidateMetrics();
|
|
406
|
-
|
|
407
343
|
if (_this.state.animating) {
|
|
408
344
|
_this.cancelAnimation();
|
|
409
|
-
|
|
410
345
|
_this.resetAnimation();
|
|
411
346
|
}
|
|
412
347
|
}
|
|
413
348
|
};
|
|
414
|
-
|
|
415
349
|
_this.handleMarqueeComplete = function () {
|
|
416
350
|
_this.resetAnimation();
|
|
417
351
|
};
|
|
418
|
-
|
|
419
352
|
_this.handleFocus = function (ev) {
|
|
420
353
|
_this.isFocused = true;
|
|
421
|
-
|
|
422
354
|
if (!_this.sync) {
|
|
423
355
|
if (!_this.state.animating) {
|
|
424
356
|
_this.startAnimation();
|
|
425
357
|
}
|
|
426
358
|
}
|
|
427
|
-
|
|
428
359
|
forwardFocus(ev, _this.props);
|
|
429
360
|
};
|
|
430
|
-
|
|
431
361
|
_this.handleBlur = function (ev) {
|
|
432
362
|
_this.promoteJob.stop();
|
|
433
|
-
|
|
434
363
|
forwardBlur(ev, _this.props);
|
|
435
|
-
|
|
436
364
|
if (_this.isFocused) {
|
|
437
365
|
_this.isFocused = false;
|
|
438
|
-
|
|
439
366
|
if (!_this.sync && !(_this.isHovered && _this.props.marqueeOn === 'hover')) {
|
|
440
367
|
_this.cancelAnimation();
|
|
441
368
|
}
|
|
442
369
|
}
|
|
443
370
|
};
|
|
444
|
-
|
|
445
371
|
_this.handleEnter = function (ev) {
|
|
446
372
|
_this.isHovered = true;
|
|
447
|
-
|
|
448
373
|
if (_this.props.marqueeOn === 'hover') {
|
|
449
374
|
if (_this.sync) {
|
|
450
375
|
_this.context.enter(_assertThisInitialized(_this));
|
|
@@ -452,30 +377,22 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
452
377
|
_this.startAnimation();
|
|
453
378
|
}
|
|
454
379
|
}
|
|
455
|
-
|
|
456
380
|
forwardEnter(ev, _this.props);
|
|
457
381
|
};
|
|
458
|
-
|
|
459
382
|
_this.handleLeave = function (ev) {
|
|
460
383
|
_this.promoteJob.stop();
|
|
461
|
-
|
|
462
384
|
_this.handleUnhover();
|
|
463
|
-
|
|
464
385
|
forwardLeave(ev, _this.props);
|
|
465
386
|
};
|
|
466
|
-
|
|
467
387
|
_this.handlePointerHide = function (_ref) {
|
|
468
388
|
var keyCode = _ref.keyCode;
|
|
469
|
-
|
|
470
389
|
if ((0, _keymap.is)('pointerHide', keyCode)) {
|
|
471
390
|
_this.handleUnhover();
|
|
472
391
|
}
|
|
473
392
|
};
|
|
474
|
-
|
|
475
393
|
_this.cacheNode = function (node) {
|
|
476
394
|
_this.node = node;
|
|
477
395
|
};
|
|
478
|
-
|
|
479
396
|
_this.state = {
|
|
480
397
|
animating: false,
|
|
481
398
|
overflow: 'ellipsis',
|
|
@@ -489,7 +406,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
489
406
|
_this.resizeRegistry = null;
|
|
490
407
|
return _this;
|
|
491
408
|
}
|
|
492
|
-
|
|
493
409
|
_createClass(_class, [{
|
|
494
410
|
key: "componentDidMount",
|
|
495
411
|
value: function componentDidMount() {
|
|
@@ -500,36 +416,31 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
500
416
|
stop: this.stop
|
|
501
417
|
});
|
|
502
418
|
}
|
|
503
|
-
|
|
504
419
|
this.validateTextDirection();
|
|
505
|
-
|
|
506
420
|
if (this.props.marqueeOn === 'render') {
|
|
507
421
|
this.startAnimation(this.props.marqueeOnRenderDelay);
|
|
508
422
|
}
|
|
509
|
-
|
|
510
423
|
(0, _dispatcher.on)('keydown', this.handlePointerHide, document);
|
|
511
424
|
}
|
|
512
425
|
}, {
|
|
513
426
|
key: "componentDidUpdate",
|
|
514
427
|
value: function componentDidUpdate(prevProps) {
|
|
515
428
|
var _this$props = this.props,
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
429
|
+
children = _this$props.children,
|
|
430
|
+
disabled = _this$props.disabled,
|
|
431
|
+
forceDirection = _this$props.forceDirection,
|
|
432
|
+
locale = _this$props.locale,
|
|
433
|
+
marqueeOn = _this$props.marqueeOn,
|
|
434
|
+
marqueeDisabled = _this$props.marqueeDisabled,
|
|
435
|
+
marqueeSpacing = _this$props.marqueeSpacing,
|
|
436
|
+
marqueeSpeed = _this$props.marqueeSpeed,
|
|
437
|
+
rtl = _this$props.rtl;
|
|
525
438
|
var forceRestartMarquee = false;
|
|
526
|
-
|
|
527
439
|
if (prevProps.locale !== locale || prevProps.rtl !== rtl || prevProps.marqueeSpacing !== marqueeSpacing || !(0, _util.shallowEqual)(prevProps.children, children) || invalidateProps && didPropChange(invalidateProps, prevProps, this.props)) {
|
|
528
440
|
// restart marqueeOn="render" marquees or synced marquees that were animating
|
|
529
441
|
forceRestartMarquee = marqueeOn === 'render' || this.sync && (this.state.animating || this.timerState > TimerState.CLEAR);
|
|
530
442
|
this.invalidateMetrics();
|
|
531
443
|
this.cancelAnimation();
|
|
532
|
-
|
|
533
444
|
if (forceRestartMarquee && marqueeOn === 'focus') {
|
|
534
445
|
this.resetAnimation();
|
|
535
446
|
}
|
|
@@ -538,9 +449,7 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
538
449
|
} else if (disabled && this.isHovered && marqueeOn === 'focus' && this.sync) {
|
|
539
450
|
this.context.enter(this);
|
|
540
451
|
}
|
|
541
|
-
|
|
542
452
|
this.validateTextDirection();
|
|
543
|
-
|
|
544
453
|
if (forceRestartMarquee || this.shouldStartMarquee()) {
|
|
545
454
|
this.tryStartingAnimation(this.props.marqueeOn === 'render' ? this.props.marqueeOnRenderDelay : this.props.marqueeDelay);
|
|
546
455
|
}
|
|
@@ -551,22 +460,18 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
551
460
|
this.clearTimeout();
|
|
552
461
|
this.promoteJob.stop();
|
|
553
462
|
this.demoteJob.stop();
|
|
554
|
-
|
|
555
463
|
if (this.sync) {
|
|
556
464
|
this.context.unregister(this);
|
|
557
465
|
}
|
|
558
|
-
|
|
559
466
|
if (this.resizeRegistry) {
|
|
560
467
|
this.resizeRegistry.unregister(this.handleResize);
|
|
561
468
|
}
|
|
562
|
-
|
|
563
469
|
(0, _dispatcher.off)('keydown', this.handlePointerHide, document);
|
|
564
470
|
}
|
|
565
471
|
}, {
|
|
566
472
|
key: "demote",
|
|
567
473
|
value: function demote() {
|
|
568
474
|
this.promoteJob.stop();
|
|
569
|
-
|
|
570
475
|
if (this.state.promoted) {
|
|
571
476
|
this.demoteJob.idle();
|
|
572
477
|
}
|
|
@@ -578,12 +483,12 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
578
483
|
this.demoteJob.stop();
|
|
579
484
|
this.promoteJob.startAfter(Math.max(0, delay - 200));
|
|
580
485
|
}
|
|
486
|
+
|
|
581
487
|
/*
|
|
582
488
|
* Clears the timer
|
|
583
489
|
*
|
|
584
490
|
* @returns {undefined}
|
|
585
491
|
*/
|
|
586
|
-
|
|
587
492
|
}, {
|
|
588
493
|
key: "clearTimeout",
|
|
589
494
|
value: function clearTimeout() {
|
|
@@ -591,9 +496,9 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
591
496
|
window.clearTimeout(this.timer);
|
|
592
497
|
this.timer = null;
|
|
593
498
|
}
|
|
594
|
-
|
|
595
499
|
this.timerState = TimerState.CLEAR;
|
|
596
500
|
}
|
|
501
|
+
|
|
597
502
|
/*
|
|
598
503
|
* Starts a new timer
|
|
599
504
|
*
|
|
@@ -601,16 +506,13 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
601
506
|
* @param {Number} time Delay in milliseconds
|
|
602
507
|
* @returns {undefined}
|
|
603
508
|
*/
|
|
604
|
-
|
|
605
509
|
}, {
|
|
606
510
|
key: "setTimeout",
|
|
607
511
|
value: function setTimeout(fn) {
|
|
608
512
|
var _this2 = this;
|
|
609
|
-
|
|
610
513
|
var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
611
514
|
var state = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : TimerState.CLEAR;
|
|
612
515
|
this.clearTimeout();
|
|
613
|
-
|
|
614
516
|
if (window) {
|
|
615
517
|
this.timerState = state;
|
|
616
518
|
this.timer = window.setTimeout(function () {
|
|
@@ -619,35 +521,35 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
619
521
|
}, time);
|
|
620
522
|
}
|
|
621
523
|
}
|
|
524
|
+
|
|
622
525
|
/*
|
|
623
526
|
* Checks to see if the children changed during a condition that should cause us to re-check
|
|
624
527
|
* the animation state
|
|
625
528
|
*
|
|
626
529
|
* @returns {Boolean} - `true` if a possible marquee condition exists
|
|
627
530
|
*/
|
|
628
|
-
|
|
629
531
|
}, {
|
|
630
532
|
key: "shouldStartMarquee",
|
|
631
533
|
value: function shouldStartMarquee() {
|
|
632
534
|
var _this$props2 = this.props,
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
535
|
+
disabled = _this$props2.disabled,
|
|
536
|
+
marqueeDisabled = _this$props2.marqueeDisabled,
|
|
537
|
+
marqueeOn = _this$props2.marqueeOn;
|
|
636
538
|
return !marqueeDisabled && (marqueeOn === 'render' || !this.sync && (this.isFocused && marqueeOn === 'focus' && !disabled || this.isHovered && (marqueeOn === 'hover' || marqueeOn === 'focus' && disabled)));
|
|
637
539
|
}
|
|
540
|
+
|
|
638
541
|
/*
|
|
639
542
|
* Invalidates marquee metrics requiring them to be recalculated
|
|
640
543
|
*
|
|
641
544
|
* @returns {undefined}
|
|
642
545
|
*/
|
|
643
|
-
|
|
644
546
|
}, {
|
|
645
547
|
key: "invalidateMetrics",
|
|
646
548
|
value: function invalidateMetrics() {
|
|
647
|
-
this.spacing = 0;
|
|
648
|
-
|
|
649
|
-
this.distance = null;
|
|
650
|
-
|
|
549
|
+
this.spacing = 0;
|
|
550
|
+
// Null distance is the special value to allow recalculation
|
|
551
|
+
this.distance = null;
|
|
552
|
+
// Assume the marquee does not fit until calculations show otherwise
|
|
651
553
|
this.contentFits = null;
|
|
652
554
|
this.setState(function (state) {
|
|
653
555
|
if (state.overflow === 'ellipsis' && state.promoted === false) return null;
|
|
@@ -673,20 +575,20 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
673
575
|
scrollWidth: this.node.scrollWidth,
|
|
674
576
|
width: this.node.getBoundingClientRect().width
|
|
675
577
|
};
|
|
676
|
-
}
|
|
677
|
-
|
|
578
|
+
}
|
|
678
579
|
|
|
580
|
+
// move all the children into the wrapper node ...
|
|
679
581
|
var wrapper = document.createElement('span');
|
|
680
582
|
this.moveChildren(this.node, wrapper);
|
|
681
|
-
this.node.appendChild(wrapper);
|
|
583
|
+
this.node.appendChild(wrapper);
|
|
682
584
|
|
|
585
|
+
// measure it to find the precise floating point width of the content ...
|
|
683
586
|
var _wrapper$getBoundingC = wrapper.getBoundingClientRect(),
|
|
684
|
-
|
|
685
|
-
|
|
587
|
+
scrollWidth = _wrapper$getBoundingC.width;
|
|
686
588
|
var _this$node$getBoundin = this.node.getBoundingClientRect(),
|
|
687
|
-
|
|
688
|
-
|
|
589
|
+
width = _this$node$getBoundin.width;
|
|
689
590
|
|
|
591
|
+
// and move all the children back and remove the wrapper
|
|
690
592
|
this.node.removeChild(wrapper);
|
|
691
593
|
this.moveChildren(wrapper, this.node);
|
|
692
594
|
return {
|
|
@@ -694,22 +596,22 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
694
596
|
width: width
|
|
695
597
|
};
|
|
696
598
|
}
|
|
599
|
+
|
|
697
600
|
/*
|
|
698
601
|
* Determines if the component should marquee and the distance to animate
|
|
699
602
|
*
|
|
700
603
|
* @returns {undefined}
|
|
701
604
|
*/
|
|
702
|
-
|
|
703
605
|
}, {
|
|
704
606
|
key: "calculateMetrics",
|
|
705
607
|
value: function calculateMetrics() {
|
|
706
|
-
var node = this.node;
|
|
608
|
+
var node = this.node;
|
|
707
609
|
|
|
610
|
+
// TODO: absolute showing check (or assume that it won't be rendered if it isn't showing?)
|
|
708
611
|
if (node && this.distance == null && !this.props.marqueeDisabled) {
|
|
709
612
|
var _this$measureWidths = this.measureWidths(),
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
613
|
+
width = _this$measureWidths.width,
|
|
614
|
+
scrollWidth = _this$measureWidths.scrollWidth;
|
|
713
615
|
this.spacing = this.getSpacing(width);
|
|
714
616
|
this.distance = this.calculateDistance(width, scrollWidth, this.spacing);
|
|
715
617
|
this.contentFits = !this.shouldAnimate(this.distance);
|
|
@@ -721,6 +623,7 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
721
623
|
});
|
|
722
624
|
}
|
|
723
625
|
}
|
|
626
|
+
|
|
724
627
|
/*
|
|
725
628
|
* Calculates the distance the marquee must travel to reveal all of the content
|
|
726
629
|
*
|
|
@@ -729,18 +632,16 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
729
632
|
* @param {Number} spacing Horizontal spacing
|
|
730
633
|
* @returns {Number} Distance to travel in pixels
|
|
731
634
|
*/
|
|
732
|
-
|
|
733
635
|
}, {
|
|
734
636
|
key: "calculateDistance",
|
|
735
637
|
value: function calculateDistance(width, scrollWidth, spacing) {
|
|
736
638
|
var overflow = scrollWidth - width;
|
|
737
|
-
|
|
738
639
|
if (this.shouldAnimate(overflow)) {
|
|
739
640
|
return scrollWidth + spacing;
|
|
740
641
|
}
|
|
741
|
-
|
|
742
642
|
return 0;
|
|
743
643
|
}
|
|
644
|
+
|
|
744
645
|
/*
|
|
745
646
|
* A custom overflow-determining method to reflect real-world truncation/ellipsis
|
|
746
647
|
* calculation. This catches an edge case that the browser typically does not, where the
|
|
@@ -753,7 +654,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
753
654
|
* @param {Number} distance Amount of overflow in pixels
|
|
754
655
|
* @returns {String} text-overflow value
|
|
755
656
|
*/
|
|
756
|
-
|
|
757
657
|
}, {
|
|
758
658
|
key: "calculateTextOverflow",
|
|
759
659
|
value: function calculateTextOverflow(distance) {
|
|
@@ -763,42 +663,39 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
763
663
|
key: "getSpacing",
|
|
764
664
|
value: function getSpacing(width) {
|
|
765
665
|
var marqueeSpacing = this.props.marqueeSpacing;
|
|
766
|
-
|
|
767
666
|
if (typeof marqueeSpacing === 'string') {
|
|
768
667
|
if (/^\d+(\.\d+)?%$/.test(marqueeSpacing)) {
|
|
769
668
|
return width * Number.parseFloat(marqueeSpacing) / 100;
|
|
770
|
-
}
|
|
771
|
-
|
|
669
|
+
}
|
|
772
670
|
|
|
671
|
+
// warning for invalid string value;
|
|
773
672
|
return 0;
|
|
774
673
|
}
|
|
775
|
-
|
|
776
674
|
return (0, _resolution.scale)(marqueeSpacing);
|
|
777
675
|
}
|
|
676
|
+
|
|
778
677
|
/*
|
|
779
678
|
* Calculates if the marquee should animate
|
|
780
679
|
*
|
|
781
680
|
* @param {Number} distance Amount of overflow in pixels
|
|
782
681
|
* @returns {Boolean} `true` if it should animated
|
|
783
682
|
*/
|
|
784
|
-
|
|
785
683
|
}, {
|
|
786
684
|
key: "shouldAnimate",
|
|
787
685
|
value: function shouldAnimate(distance) {
|
|
788
686
|
return distance > 0;
|
|
789
687
|
}
|
|
688
|
+
|
|
790
689
|
/*
|
|
791
690
|
* Starts the animation without synchronizing
|
|
792
691
|
*
|
|
793
692
|
* @param {Number} [delay] Milliseconds to wait before animating
|
|
794
693
|
* @returns {undefined}
|
|
795
694
|
*/
|
|
796
|
-
|
|
797
695
|
}, {
|
|
798
696
|
key: "handleUnhover",
|
|
799
697
|
value: function handleUnhover() {
|
|
800
698
|
this.isHovered = false;
|
|
801
|
-
|
|
802
699
|
if (this.props.marqueeOn === 'hover') {
|
|
803
700
|
if (this.sync) {
|
|
804
701
|
this.context.leave(this);
|
|
@@ -811,7 +708,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
811
708
|
key: "validateTextDirection",
|
|
812
709
|
value: function validateTextDirection() {
|
|
813
710
|
var _this3 = this;
|
|
814
|
-
|
|
815
711
|
this.setState(function (state, props) {
|
|
816
712
|
var rtl = determineTextDirection(_this3.node, props.rtl, props.forceDirection);
|
|
817
713
|
return state.rtl === rtl ? null : {
|
|
@@ -823,31 +719,27 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
823
719
|
key: "renderMarquee",
|
|
824
720
|
value: function renderMarquee() {
|
|
825
721
|
var _this$props3 = this.props,
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
722
|
+
alignment = _this$props3.alignment,
|
|
723
|
+
children = _this$props3.children,
|
|
724
|
+
disabled = _this$props3.disabled,
|
|
725
|
+
marqueeOn = _this$props3.marqueeOn,
|
|
726
|
+
marqueeSpeed = _this$props3.marqueeSpeed,
|
|
727
|
+
rest = _objectWithoutProperties(_this$props3, _excluded);
|
|
833
728
|
var marqueeOnFocus = marqueeOn === 'focus';
|
|
834
729
|
var marqueeOnHover = marqueeOn === 'hover';
|
|
835
730
|
var marqueeOnRender = marqueeOn === 'render';
|
|
836
|
-
|
|
837
731
|
if (marqueeOnFocus) {
|
|
838
732
|
rest[focus] = this.handleFocus;
|
|
839
|
-
}
|
|
840
|
-
|
|
733
|
+
}
|
|
841
734
|
|
|
735
|
+
// TODO: cancel others on hover
|
|
842
736
|
if (marqueeOnHover || marqueeOnFocus) {
|
|
843
737
|
rest[enter] = this.handleEnter;
|
|
844
738
|
rest[leave] = this.handleLeave;
|
|
845
739
|
}
|
|
846
|
-
|
|
847
740
|
if (marqueeOnRender) {
|
|
848
741
|
rest[enter] = this.handleEnter;
|
|
849
742
|
}
|
|
850
|
-
|
|
851
743
|
delete rest.forceDirection;
|
|
852
744
|
delete rest.locale;
|
|
853
745
|
delete rest.marqueeCentered;
|
|
@@ -901,13 +793,11 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
901
793
|
key: "render",
|
|
902
794
|
value: function render() {
|
|
903
795
|
var _this4 = this;
|
|
904
|
-
|
|
905
796
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Resizable.ResizeContext.Consumer, {
|
|
906
797
|
children: function children(register) {
|
|
907
798
|
if (!_this4.resizeRegistry && register) {
|
|
908
799
|
_this4.resizeRegistry = register(_this4.handleResize);
|
|
909
800
|
}
|
|
910
|
-
|
|
911
801
|
if (_this4.props.marqueeDisabled) {
|
|
912
802
|
return _this4.renderWrapped();
|
|
913
803
|
} else {
|
|
@@ -917,11 +807,8 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
917
807
|
});
|
|
918
808
|
}
|
|
919
809
|
}]);
|
|
920
|
-
|
|
921
810
|
return _class;
|
|
922
|
-
}(_react.PureComponent), _class.displayName = 'ui:MarqueeDecorator', _class.propTypes =
|
|
923
|
-
/** @lends ui/Marquee.MarqueeDecorator.prototype */
|
|
924
|
-
{
|
|
811
|
+
}(_react.PureComponent), _class.displayName = 'ui:MarqueeDecorator', _class.propTypes = /** @lends ui/Marquee.MarqueeDecorator.prototype */{
|
|
925
812
|
/**
|
|
926
813
|
* Text alignment value of the marquee. Valid values are `'left'`, `'right'` and `'center'`.
|
|
927
814
|
*
|
|
@@ -929,7 +816,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
929
816
|
* @public
|
|
930
817
|
*/
|
|
931
818
|
alignment: _propTypes["default"].oneOf(['left', 'right', 'center']),
|
|
932
|
-
|
|
933
819
|
/**
|
|
934
820
|
* Children to be marqueed
|
|
935
821
|
*
|
|
@@ -937,7 +823,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
937
823
|
* @public
|
|
938
824
|
*/
|
|
939
825
|
children: _propTypes["default"].node,
|
|
940
|
-
|
|
941
826
|
/**
|
|
942
827
|
* Passed through to the wrapped component.
|
|
943
828
|
*
|
|
@@ -949,7 +834,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
949
834
|
* @public
|
|
950
835
|
*/
|
|
951
836
|
disabled: _propTypes["default"].bool,
|
|
952
|
-
|
|
953
837
|
/**
|
|
954
838
|
* Forces the `direction` of the marquee.
|
|
955
839
|
*
|
|
@@ -964,7 +848,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
964
848
|
* @public
|
|
965
849
|
*/
|
|
966
850
|
forceDirection: _propTypes["default"].oneOf(['rtl', 'ltr', 'locale']),
|
|
967
|
-
|
|
968
851
|
/**
|
|
969
852
|
* The current locale as a
|
|
970
853
|
* {@link https://tools.ietf.org/html/rfc5646|BCP 47 language tag}.
|
|
@@ -973,7 +856,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
973
856
|
* @public
|
|
974
857
|
*/
|
|
975
858
|
locale: _propTypes["default"].string,
|
|
976
|
-
|
|
977
859
|
/**
|
|
978
860
|
* Number of milliseconds to wait before starting marquee when `marqueeOn` is `'hover'` or
|
|
979
861
|
* `'focus'` or before restarting any marquee.
|
|
@@ -983,14 +865,12 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
983
865
|
* @public
|
|
984
866
|
*/
|
|
985
867
|
marqueeDelay: _propTypes["default"].number,
|
|
986
|
-
|
|
987
868
|
/**
|
|
988
869
|
* Disables all marquee behavior and removes supporting markup.
|
|
989
870
|
*
|
|
990
871
|
* @type {Boolean}
|
|
991
872
|
*/
|
|
992
873
|
marqueeDisabled: _propTypes["default"].bool,
|
|
993
|
-
|
|
994
874
|
/**
|
|
995
875
|
* Determines what triggers the marquee to start its animation.
|
|
996
876
|
*
|
|
@@ -999,7 +879,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
999
879
|
* @public
|
|
1000
880
|
*/
|
|
1001
881
|
marqueeOn: _propTypes["default"].oneOf(['focus', 'hover', 'render']),
|
|
1002
|
-
|
|
1003
882
|
/**
|
|
1004
883
|
* Number of milliseconds to wait before starting marquee the first time.
|
|
1005
884
|
*
|
|
@@ -1010,7 +889,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
1010
889
|
* @public
|
|
1011
890
|
*/
|
|
1012
891
|
marqueeOnRenderDelay: _propTypes["default"].number,
|
|
1013
|
-
|
|
1014
892
|
/**
|
|
1015
893
|
* Number of milliseconds to wait before resetting the marquee position after it
|
|
1016
894
|
* finishes.
|
|
@@ -1022,7 +900,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
1022
900
|
* @public
|
|
1023
901
|
*/
|
|
1024
902
|
marqueeResetDelay: _propTypes["default"].number,
|
|
1025
|
-
|
|
1026
903
|
/**
|
|
1027
904
|
* Amount of spacing between the instances of the content when animating.
|
|
1028
905
|
*
|
|
@@ -1037,7 +914,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
1037
914
|
* @public
|
|
1038
915
|
*/
|
|
1039
916
|
marqueeSpacing: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
1040
|
-
|
|
1041
917
|
/**
|
|
1042
918
|
* Rate of marquee measured in pixels/second.
|
|
1043
919
|
*
|
|
@@ -1046,7 +922,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
1046
922
|
* @public
|
|
1047
923
|
*/
|
|
1048
924
|
marqueeSpeed: _propTypes["default"].number,
|
|
1049
|
-
|
|
1050
925
|
/**
|
|
1051
926
|
* Used to signal for a remeasurement inside of marquee.
|
|
1052
927
|
*
|
|
@@ -1056,7 +931,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
1056
931
|
* @private
|
|
1057
932
|
*/
|
|
1058
933
|
remeasure: _propTypes["default"].any,
|
|
1059
|
-
|
|
1060
934
|
/**
|
|
1061
935
|
* Indicates the text directionality of the current locale is right-to-left
|
|
1062
936
|
*
|