@enact/ui 4.6.2 → 4.7.1
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 +25 -16
- package/AnnounceDecorator/AnnounceDecorator.js +14 -7
- package/AnnounceDecorator/useAnnounce.js +1 -2
- package/BodyText/BodyText.js +14 -8
- package/Button/Button.js +16 -10
- package/Button/tests/Button-specs.js +10 -6
- package/CHANGELOG.md +18 -0
- package/Cancelable/Cancelable.js +13 -7
- package/Changeable/Changeable.js +11 -7
- package/ComponentOverride/ComponentOverride.js +18 -7
- package/FloatingLayer/FloatingLayer.js +10 -11
- package/FloatingLayer/FloatingLayerDecorator.js +9 -6
- package/ForwardRef/ForwardRef.js +11 -7
- package/GridListImageItem/GridListImageItem.js +16 -9
- package/Group/Group.js +17 -8
- package/Group/GroupItem.js +14 -10
- package/Group/tests/Group-specs.js +14 -9
- package/Heading/Heading.js +20 -9
- package/Icon/Icon.js +15 -8
- package/IconButton/IconButton.js +22 -9
- package/Image/Image.js +16 -8
- package/ImageItem/ImageItem.js +9 -1
- package/Item/Item.js +17 -9
- package/Item/tests/Item-specs.js +10 -6
- package/LabeledIcon/LabeledIcon.js +16 -8
- package/Layout/Cell.js +27 -4
- package/Layout/Layout.d.ts +22 -5
- package/Layout/Layout.js +154 -32
- package/Layout/Layout.module.css +8 -0
- package/Layout/tests/Layout-specs.js +39 -0
- package/Marquee/MarqueeController.js +43 -0
- package/Marquee/MarqueeDecorator.js +40 -9
- package/Measurable/Measurable.js +11 -7
- package/Media/Media.js +30 -23
- package/Placeholder/PlaceholderControllerDecorator.js +8 -8
- package/Placeholder/PlaceholderDecorator.js +7 -8
- package/ProgressBar/ProgressBar.js +12 -1
- package/RadioDecorator/RadioDecorator.js +18 -13
- package/RadioDecorator/tests/RadioDecorator-specs.js +28 -20
- package/Repeater/Repeater.js +14 -10
- package/Resizable/Resizable.js +28 -98
- package/Resizable/ResizeContext.js +17 -0
- package/Resizable/tests/useResize-specs.js +43 -0
- package/Resizable/useResize.js +66 -0
- package/Routable/Link.js +8 -8
- package/Routable/Routable.js +15 -8
- package/Routable/Router.js +10 -10
- package/Routable/tests/Routable-specs.js +9 -6
- package/Scrollable/ScrollThumb.js +8 -9
- package/Scrollable/Scrollable.js +23 -7
- package/Scrollable/ScrollableNative.js +19 -14
- package/Scroller/Scroller.js +8 -1
- package/Scroller/ScrollerBasic.js +8 -9
- package/Scroller/UiScrollerBase.js +11 -12
- package/Skinnable/Skinnable.js +19 -7
- package/Skinnable/useSkins.js +1 -2
- package/Slider/Knob.js +8 -8
- package/Slider/Slider.js +16 -9
- package/SlotItem/SlotItem.js +20 -8
- package/Slottable/Slottable.js +14 -8
- package/Spinner/Spinner.js +24 -9
- package/ToggleIcon/ToggleIcon.js +21 -9
- package/ToggleIcon/tests/ToggleIcon-specs.js +6 -3
- package/ToggleItem/ToggleItem.js +14 -1
- package/ToggleItem/tests/ToggleItem-specs.js +6 -3
- package/Toggleable/Toggleable.js +11 -7
- package/Toggleable/useToggle.js +0 -1
- package/Touchable/Drag.js +1 -0
- package/Touchable/Flick.js +1 -0
- package/Touchable/Hold.js +1 -0
- package/Touchable/Pinch.js +1 -0
- package/Touchable/Touch.js +3 -3
- package/Touchable/Touchable.js +7 -0
- package/Touchable/useTouch.js +0 -1
- package/Transition/Transition.js +19 -3
- package/ViewManager/Arranger.js +4 -1
- package/ViewManager/TransitionGroup.js +5 -4
- package/ViewManager/View.js +12 -12
- package/ViewManager/ViewManager.js +25 -9
- package/ViewManager/tests/ViewManager-specs.js +44 -0
- package/VirtualList/UiVirtualListBase.js +3 -4
- package/VirtualList/VirtualList.js +11 -1
- package/VirtualList/VirtualListBasic.js +4 -4
- package/internal/IdProvider/IdProvider.js +6 -7
- package/internal/IdProvider/useId.js +0 -1
- package/internal/Pure/Pure.js +11 -7
- package/package.json +3 -3
- package/resolution/ResolutionDecorator.js +36 -7
- package/resolution/resolution.js +23 -7
- package/useScroll/ScrollbarTrack.js +8 -8
- package/useScroll/useScroll.js +17 -1
package/Layout/Layout.js
CHANGED
|
@@ -37,37 +37,159 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
37
37
|
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; }
|
|
38
38
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
39
39
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
40
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
40
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /**
|
|
41
|
+
* A convenient tool for laying-out content using `Layout`, `Cell`, `Row`, and `Column`.
|
|
42
|
+
*
|
|
43
|
+
* Layout is a powerful and versatile tool used for arranging content on the screen. On a conceptual
|
|
44
|
+
* level, it mixes the best parts of HTML tables wtih the best parts of HTML framesets, both of
|
|
45
|
+
* which were largely abandoned for their drawbacks, ignoring their strengths. A `Layout` is simply
|
|
46
|
+
* a container for `Cell`, the only "legal" child. Conversely, `Cell` may only be used in a
|
|
47
|
+
* `Layout`. Cells in a Layout can either be positioned next to each other (horizontally) or
|
|
48
|
+
* above/below each other (vertically) in what we refer to as a {@link ui/Layout.Row|Row} or
|
|
49
|
+
* {@link ui/Layout.Column|Column}, respectively.
|
|
50
|
+
*
|
|
51
|
+
* The `Row` and `Column` layout presets describe the direction of layout for their children. This
|
|
52
|
+
* can sometimes cause confusion. A `Row` of children naturally forms a _layout_ whose children can
|
|
53
|
+
* have the _appearance_ of columns. To keep things clear, think about the layout rather than the
|
|
54
|
+
* what the children themselves represent.
|
|
55
|
+
*
|
|
56
|
+
* `Layout` is an implementation of flex-box, but with built-in rails, properties, and features to
|
|
57
|
+
* help avoid common problems with flex-box; things like content overflowing, sizing quirks, and
|
|
58
|
+
* positioning problems regarding content of unknown or undefined dimension.
|
|
59
|
+
*
|
|
60
|
+
* The following scenarios are some common cases where `Layout` can truly help out. A quality of
|
|
61
|
+
* `Cell` you'll see below is that when a `Cell` has no defined size, it automatically sizes to fill
|
|
62
|
+
* any remaining space in the `Layout`. If there are multiple auto-sizing `Cell` components, they
|
|
63
|
+
* share the space, subdividing it equally among themselves. It's great to leverage this and only
|
|
64
|
+
* apply sizes to `Cell`s which must have defined sizes. `shrink` is one of the ways you can impose
|
|
65
|
+
* size guidelines on a `Cell`. It automatically fits the size of the Cell to the size of its
|
|
66
|
+
* content.
|
|
67
|
+
*
|
|
68
|
+
* A row of cells where the last one should always attach to the right side, regardless of the size
|
|
69
|
+
* of the main "content" cell:
|
|
70
|
+
* ```
|
|
71
|
+
* ┌───────┬─┐
|
|
72
|
+
* │Main │R│
|
|
73
|
+
* └───────┴─┘
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* ```
|
|
77
|
+
* <Row>
|
|
78
|
+
* <Cell>Main Content</Cell>
|
|
79
|
+
* <Cell shrink>Right Side</Cell>
|
|
80
|
+
* </Row>
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* A "two-column" layout with equal sized cells using `Row`:
|
|
84
|
+
* ```
|
|
85
|
+
* ┌────┬────┐
|
|
86
|
+
* │L │R │
|
|
87
|
+
* └────┴────┘
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* ```
|
|
91
|
+
* <Row style={{height: '100%'}}>
|
|
92
|
+
* <Cell>Left Column</Cell>
|
|
93
|
+
* <Cell>Right Column</Cell>
|
|
94
|
+
* </Row>
|
|
95
|
+
* ```
|
|
96
|
+
* *Remember:* The cells of the `Row` are the columns in our layout. It's likely that in a complex
|
|
97
|
+
* layout `Column` would be used inside the left and right cells to arrange the components, as in
|
|
98
|
+
* the example below.
|
|
99
|
+
*
|
|
100
|
+
* A full-height sidebar with a header and body to the right:
|
|
101
|
+
* ```
|
|
102
|
+
* ┌──┬──────┐
|
|
103
|
+
* │S │HEADER│
|
|
104
|
+
* │ ├──────┤
|
|
105
|
+
* │ │Body │
|
|
106
|
+
* │ │ │
|
|
107
|
+
* └──┴──────┘
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* ```
|
|
111
|
+
* <Row style={{height: '100%'}}>
|
|
112
|
+
* <Cell size="20%">Sidebar</Cell>
|
|
113
|
+
* <Cell>
|
|
114
|
+
* <Column>
|
|
115
|
+
* <Cell size={90} component="header">
|
|
116
|
+
* <h1>HEADER</h1>
|
|
117
|
+
* </Cell>
|
|
118
|
+
* <Cell>
|
|
119
|
+
* <p>Body area</p>
|
|
120
|
+
* </Cell>
|
|
121
|
+
* </Column>
|
|
122
|
+
* </Cell>
|
|
123
|
+
* </Row>
|
|
124
|
+
* ```
|
|
125
|
+
* *Note:* Here, we've set the height of `Row` so it fills the height of the screen, allowing the
|
|
126
|
+
* Sidebar Cell and content Cell to stretch from the top to the bottom. We've also leveraged the
|
|
127
|
+
* `component` prop on the header cell, which tells `Cell` to render itself as a "header" HTML tag
|
|
128
|
+
* rather than its usual "div" tag.
|
|
129
|
+
*
|
|
130
|
+
* The example below produces a layout like the following:
|
|
131
|
+
* ```
|
|
132
|
+
* ┌─┬─────┬─┐
|
|
133
|
+
* │o│Item │o│
|
|
134
|
+
* └─┴─────┴─┘
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* You'll notice the use of some special classes in the example: `"debug layout"`. Adding these on
|
|
138
|
+
* any element in your DOM hierarchy will enable borders in Layout and Cell to help visualize what
|
|
139
|
+
* is happening in the layout. They automatically change color the deeper in the stack they go.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* <Layout className="debug layout">
|
|
143
|
+
* <Cell shrink>
|
|
144
|
+
* <button>First</button>
|
|
145
|
+
* </Cell>
|
|
146
|
+
* <Cell>
|
|
147
|
+
* <div>A div with some long text in it</div>
|
|
148
|
+
* </Cell>
|
|
149
|
+
* <Cell shrink>
|
|
150
|
+
* <button>Last</button>
|
|
151
|
+
* </Cell>
|
|
152
|
+
* </Layout>
|
|
153
|
+
*
|
|
154
|
+
* @module ui/Layout
|
|
155
|
+
* @exports Cell
|
|
156
|
+
* @exports CellBase
|
|
157
|
+
* @exports CellDecorator
|
|
158
|
+
* @exports Column
|
|
159
|
+
* @exports Layout
|
|
160
|
+
* @exports LayoutBase
|
|
161
|
+
* @exports LayoutDecorator
|
|
162
|
+
* @exports Row
|
|
163
|
+
*/ /**
|
|
164
|
+
* A container for `Cell`s.
|
|
165
|
+
*
|
|
166
|
+
* A stateless component that acts as a containing area for {@link ui/Layout.Cell|Cells} to be
|
|
167
|
+
* positioned in a row or a column (horizontally or vertically, respectively. It supports an
|
|
168
|
+
* {@link ui/Layout.LayoutBase.orientation|orientation} property for laying-out its contents
|
|
169
|
+
* (`Cells`) in an organized, readable way.
|
|
170
|
+
*
|
|
171
|
+
* Example:
|
|
172
|
+
* ```
|
|
173
|
+
* import Input from '@enact/moonstone/Input';
|
|
174
|
+
* import css from './LayoutExample.less';
|
|
175
|
+
* ...
|
|
176
|
+
* <fieldset>
|
|
177
|
+
* <Layout align="center">
|
|
178
|
+
* <Cell component="label" size="40%" className={css.label} shrink>First Name</Cell>
|
|
179
|
+
* <Cell component={Input} placeholder="First" className={css.input} />
|
|
180
|
+
* </Layout>
|
|
181
|
+
* <Layout align="center">
|
|
182
|
+
* <Cell component="label" size="40%" className={css.label} shrink>Last Name</Cell>
|
|
183
|
+
* <Cell component={Input} placeholder="Last" className={css.input} />
|
|
184
|
+
* </Layout>
|
|
185
|
+
* </fieldset>
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @class LayoutBase
|
|
189
|
+
* @ui
|
|
190
|
+
* @memberof ui/Layout
|
|
191
|
+
* @public
|
|
192
|
+
*/
|
|
71
193
|
var LayoutBase = (0, _kind["default"])({
|
|
72
194
|
name: 'LayoutBase',
|
|
73
195
|
propTypes: /** @lends ui/Layout.LayoutBase.prototype */{
|
|
@@ -237,7 +359,7 @@ var LayoutDecorator = (0, _ForwardRef["default"])({
|
|
|
237
359
|
*
|
|
238
360
|
* A stateless component that acts as a containing area for {@link ui/Layout.Cell|Cells} to be
|
|
239
361
|
* positioned in a row or a column (horizontally or vertically, respectively. It supports an
|
|
240
|
-
* {@link ui/Layout.
|
|
362
|
+
* {@link ui/Layout.LayoutBase.orientation|orientation} property for laying-out its contents
|
|
241
363
|
* (`Cells`) in an organized, readable way.
|
|
242
364
|
*
|
|
243
365
|
* Example:
|
package/Layout/Layout.module.css
CHANGED
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
.layout.horizontal > .cell.grow {
|
|
23
23
|
width: 0;
|
|
24
24
|
}
|
|
25
|
+
.layout.horizontal > .cell.grow.size {
|
|
26
|
+
max-width: none;
|
|
27
|
+
min-width: var(--cell-size);
|
|
28
|
+
}
|
|
25
29
|
.layout.vertical {
|
|
26
30
|
flex-direction: column;
|
|
27
31
|
height: 100%;
|
|
@@ -33,6 +37,10 @@
|
|
|
33
37
|
height: 0;
|
|
34
38
|
align-self: normal;
|
|
35
39
|
}
|
|
40
|
+
.layout.vertical > .cell.grow.size {
|
|
41
|
+
max-height: none;
|
|
42
|
+
min-height: var(--cell-size);
|
|
43
|
+
}
|
|
36
44
|
.layout.inline {
|
|
37
45
|
display: inline-flex;
|
|
38
46
|
}
|
|
@@ -104,6 +104,45 @@ describe('Layout Specs', function () {
|
|
|
104
104
|
});
|
|
105
105
|
});
|
|
106
106
|
});
|
|
107
|
+
test('should apply a class for grow', function () {
|
|
108
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Layout.Cell, {
|
|
109
|
+
children: "Body"
|
|
110
|
+
}));
|
|
111
|
+
var cell = _react.screen.getByText('Body');
|
|
112
|
+
var expected = 'grow';
|
|
113
|
+
expect(cell).toHaveClass(expected);
|
|
114
|
+
});
|
|
115
|
+
test('should apply classes for grow and size and flexBasis styles the size prop value 100px', function () {
|
|
116
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Layout["default"], {
|
|
117
|
+
style: {
|
|
118
|
+
width: "300px"
|
|
119
|
+
},
|
|
120
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Layout.Cell, {
|
|
121
|
+
grow: true,
|
|
122
|
+
size: "100px",
|
|
123
|
+
children: "Body"
|
|
124
|
+
})
|
|
125
|
+
}));
|
|
126
|
+
var cell = _react.screen.getByText('Body');
|
|
127
|
+
var expectedGrowClass = 'grow';
|
|
128
|
+
var expectedSizeClass = 'size';
|
|
129
|
+
var expectedFlexBasis = '100px';
|
|
130
|
+
expect(cell).toHaveClass(expectedGrowClass);
|
|
131
|
+
expect(cell).toHaveClass(expectedSizeClass);
|
|
132
|
+
expect(cell).toHaveStyle({
|
|
133
|
+
'flex-basis': expectedFlexBasis
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
test('should not be apply a class for grow when using shrink', function () {
|
|
137
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Layout.Cell, {
|
|
138
|
+
grow: true,
|
|
139
|
+
shrink: true,
|
|
140
|
+
children: "Body"
|
|
141
|
+
}));
|
|
142
|
+
var cell = _react.screen.getByText('Body');
|
|
143
|
+
var notExpected = 'grow';
|
|
144
|
+
expect(cell).not.toHaveClass(notExpected);
|
|
145
|
+
});
|
|
107
146
|
test('should return a DOM node reference for `componentRef` on `Layout`', function () {
|
|
108
147
|
var ref = jest.fn();
|
|
109
148
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Layout["default"], {
|
|
@@ -78,6 +78,15 @@ var MarqueeController = (0, _hoc["default"])(defaultConfig, function (config, Wr
|
|
|
78
78
|
_this.cancelJob = new _util.Job(function () {
|
|
79
79
|
return _this.doCancel();
|
|
80
80
|
}, 30);
|
|
81
|
+
/*
|
|
82
|
+
* Registers `component` with a set of handlers for `start` and `stop`.
|
|
83
|
+
*
|
|
84
|
+
* @param {Object} component A component, typically a React component instance, on
|
|
85
|
+
* which handlers will be dispatched.
|
|
86
|
+
* @param {Object} handlers An object containing `start` and `stop` functions
|
|
87
|
+
*
|
|
88
|
+
* @returns {undefined}
|
|
89
|
+
*/
|
|
81
90
|
_this.handleRegister = function (component, handlers) {
|
|
82
91
|
var needsStart = !_this.allInactive() || _this.isFocused;
|
|
83
92
|
_this.controlled.push(_objectSpread(_objectSpread({}, handlers), {}, {
|
|
@@ -88,6 +97,13 @@ var MarqueeController = (0, _hoc["default"])(defaultConfig, function (config, Wr
|
|
|
88
97
|
_this.dispatch('start');
|
|
89
98
|
}
|
|
90
99
|
};
|
|
100
|
+
/*
|
|
101
|
+
* Unregisters `component` for synchronization
|
|
102
|
+
*
|
|
103
|
+
* @param {Object} component A previously registered component
|
|
104
|
+
*
|
|
105
|
+
* @returns {undefined}
|
|
106
|
+
*/
|
|
91
107
|
_this.handleUnregister = function (component) {
|
|
92
108
|
var wasRunning = false;
|
|
93
109
|
for (var i = 0; i < _this.controlled.length; i++) {
|
|
@@ -101,6 +117,13 @@ var MarqueeController = (0, _hoc["default"])(defaultConfig, function (config, Wr
|
|
|
101
117
|
_this.dispatch('start');
|
|
102
118
|
}
|
|
103
119
|
};
|
|
120
|
+
/*
|
|
121
|
+
* Handler for the `start` context function
|
|
122
|
+
*
|
|
123
|
+
* @param {Object} component A previously registered component
|
|
124
|
+
*
|
|
125
|
+
* @returns {undefined}
|
|
126
|
+
*/
|
|
104
127
|
_this.handleStart = function (component) {
|
|
105
128
|
_this.cancelJob.stop();
|
|
106
129
|
if (!_this.anyRunning()) {
|
|
@@ -108,6 +131,13 @@ var MarqueeController = (0, _hoc["default"])(defaultConfig, function (config, Wr
|
|
|
108
131
|
_this.dispatch('start', component);
|
|
109
132
|
}
|
|
110
133
|
};
|
|
134
|
+
/*
|
|
135
|
+
* Handler for the `cancel` context function
|
|
136
|
+
*
|
|
137
|
+
* @param {Object} component A previously registered component
|
|
138
|
+
*
|
|
139
|
+
* @returns {undefined}
|
|
140
|
+
*/
|
|
111
141
|
_this.handleCancel = function () {
|
|
112
142
|
if (_this.anyRunning()) {
|
|
113
143
|
_this.cancelJob.start();
|
|
@@ -120,6 +150,13 @@ var MarqueeController = (0, _hoc["default"])(defaultConfig, function (config, Wr
|
|
|
120
150
|
_this.markAll(STATE.inactive);
|
|
121
151
|
_this.dispatch('stop');
|
|
122
152
|
};
|
|
153
|
+
/*
|
|
154
|
+
* Handler for the `complete` context function
|
|
155
|
+
*
|
|
156
|
+
* @param {Object} component A previously registered component
|
|
157
|
+
*
|
|
158
|
+
* @returns {undefined}
|
|
159
|
+
*/
|
|
123
160
|
_this.handleComplete = function (component) {
|
|
124
161
|
var complete = _this.markReady(component);
|
|
125
162
|
if (complete) {
|
|
@@ -138,6 +175,9 @@ var MarqueeController = (0, _hoc["default"])(defaultConfig, function (config, Wr
|
|
|
138
175
|
_this.isHovered = false;
|
|
139
176
|
_this.cancelJob.start();
|
|
140
177
|
};
|
|
178
|
+
/*
|
|
179
|
+
* Handler for the focus event
|
|
180
|
+
*/
|
|
141
181
|
_this.handleFocus = function (ev) {
|
|
142
182
|
_this.isFocused = true;
|
|
143
183
|
if (!_this.anyRunning()) {
|
|
@@ -146,6 +186,9 @@ var MarqueeController = (0, _hoc["default"])(defaultConfig, function (config, Wr
|
|
|
146
186
|
_this.cancelJob.stop();
|
|
147
187
|
forwardFocus(ev, _this.props);
|
|
148
188
|
};
|
|
189
|
+
/*
|
|
190
|
+
* Handler for the blur event
|
|
191
|
+
*/
|
|
149
192
|
_this.handleBlur = function (ev) {
|
|
150
193
|
_this.isFocused = false;
|
|
151
194
|
if (_this.anyRunning()) {
|
|
@@ -39,8 +39,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
39
39
|
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); }
|
|
40
40
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
41
41
|
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; } }
|
|
42
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
43
|
-
// The minimum number of milliseconds to wait before resetting the marquee position after it finishes.
|
|
42
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } // The minimum number of milliseconds to wait before resetting the marquee position after it finishes.
|
|
44
43
|
var MINIMUM_MARQUEE_RESET_DELAY = 40;
|
|
45
44
|
|
|
46
45
|
/**
|
|
@@ -241,6 +240,12 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
241
240
|
} : null;
|
|
242
241
|
});
|
|
243
242
|
});
|
|
243
|
+
/*
|
|
244
|
+
* Starts the animation without synchronizing
|
|
245
|
+
*
|
|
246
|
+
* @param {Number} [delay] Milliseconds to wait before animating
|
|
247
|
+
* @returns {undefined}
|
|
248
|
+
*/
|
|
244
249
|
_this.start = function () {
|
|
245
250
|
var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props.marqueeDelay;
|
|
246
251
|
if (_this.props.marqueeDisabled) {
|
|
@@ -265,6 +270,11 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
265
270
|
}, delay, TimerState.START_PENDING);
|
|
266
271
|
}
|
|
267
272
|
};
|
|
273
|
+
/*
|
|
274
|
+
* Stops the animation
|
|
275
|
+
*
|
|
276
|
+
* @returns {undefined}
|
|
277
|
+
*/
|
|
268
278
|
_this.stop = function () {
|
|
269
279
|
_this.clearTimeout();
|
|
270
280
|
if (_this.state.animating) {
|
|
@@ -274,10 +284,23 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
274
284
|
}
|
|
275
285
|
_this.demote();
|
|
276
286
|
};
|
|
287
|
+
/*
|
|
288
|
+
* Starts marquee animation with synchronization, if not already animating and a timer is
|
|
289
|
+
* not already active to start.
|
|
290
|
+
*
|
|
291
|
+
* @param {Number} [delay] Milliseconds to wait before animating
|
|
292
|
+
* @returns {undefined}
|
|
293
|
+
*/
|
|
277
294
|
_this.tryStartingAnimation = function (delay) {
|
|
278
295
|
if (_this.state.animating || _this.timerState !== TimerState.CLEAR) return;
|
|
279
296
|
_this.startAnimation(delay);
|
|
280
297
|
};
|
|
298
|
+
/*
|
|
299
|
+
* Starts marquee animation with synchronization
|
|
300
|
+
*
|
|
301
|
+
* @param {Number} [delay] Milliseconds to wait before animating
|
|
302
|
+
* @returns {undefined}
|
|
303
|
+
*/
|
|
281
304
|
_this.startAnimation = function (delay) {
|
|
282
305
|
_this.promote(delay);
|
|
283
306
|
if (_this.sync) {
|
|
@@ -296,6 +319,11 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
296
319
|
_this.start(delay);
|
|
297
320
|
}
|
|
298
321
|
};
|
|
322
|
+
/*
|
|
323
|
+
* Resets the marquee and restarts it after `marqueeDelay` milliseconds.
|
|
324
|
+
*
|
|
325
|
+
* @returns {undefined}
|
|
326
|
+
*/
|
|
299
327
|
_this.restartAnimation = function (delay) {
|
|
300
328
|
(0, _reactDom.flushSync)(function () {
|
|
301
329
|
_this.setState({
|
|
@@ -314,6 +342,11 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
314
342
|
_this.startAnimation(delay);
|
|
315
343
|
}
|
|
316
344
|
};
|
|
345
|
+
/*
|
|
346
|
+
* Resets and restarts the marquee after `marqueeResetDelay` milliseconds
|
|
347
|
+
*
|
|
348
|
+
* @returns {undefined}
|
|
349
|
+
*/
|
|
317
350
|
_this.resetAnimation = function () {
|
|
318
351
|
var delay = Math.max(MINIMUM_MARQUEE_RESET_DELAY, _this.props.marqueeResetDelay + _this.props.marqueeDelay);
|
|
319
352
|
// If we're already timing a start action, don't reset. Start actions will clear us if
|
|
@@ -332,6 +365,11 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
332
365
|
}, 0, TimerState.RESET_PENDING);
|
|
333
366
|
}
|
|
334
367
|
};
|
|
368
|
+
/*
|
|
369
|
+
* Cancels the marquee
|
|
370
|
+
*
|
|
371
|
+
* @returns {undefined}
|
|
372
|
+
*/
|
|
335
373
|
_this.cancelAnimation = function () {
|
|
336
374
|
if (_this.sync) {
|
|
337
375
|
_this.context.cancel(_assertThisInitialized(_this));
|
|
@@ -687,13 +725,6 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
687
725
|
value: function shouldAnimate(distance) {
|
|
688
726
|
return distance > 0;
|
|
689
727
|
}
|
|
690
|
-
|
|
691
|
-
/*
|
|
692
|
-
* Starts the animation without synchronizing
|
|
693
|
-
*
|
|
694
|
-
* @param {Number} [delay] Milliseconds to wait before animating
|
|
695
|
-
* @returns {undefined}
|
|
696
|
-
*/
|
|
697
728
|
}, {
|
|
698
729
|
key: "handleUnhover",
|
|
699
730
|
value: function handleUnhover() {
|
package/Measurable/Measurable.js
CHANGED
|
@@ -19,13 +19,17 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructur
|
|
|
19
19
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
20
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
21
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
22
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /* global ResizeObserver, MutationObserver */ /**
|
|
23
|
+
* A higher-order component that adds the ability to measure nodes conveniently.
|
|
24
|
+
*
|
|
25
|
+
* @module ui/Measurable
|
|
26
|
+
* @exports Measurable
|
|
27
|
+
*/ /**
|
|
28
|
+
* Default config for {@link ui/Measurable.Measurable}.
|
|
29
|
+
*
|
|
30
|
+
* @memberof ui/Measurable.Measurable
|
|
31
|
+
* @hocconfig
|
|
32
|
+
*/
|
|
29
33
|
var defaultConfig = {
|
|
30
34
|
/**
|
|
31
35
|
* Configures the prop name to pass the measurement object.
|