@enact/ui 4.1.3 → 4.1.4
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/Button/Button.js +5 -3
- package/CHANGELOG.md +15 -0
- package/Marquee/MarqueeDecorator.js +6 -3
- package/Marquee/index.d.ts +4 -1
- package/Marquee/tests/Marquee-specs.js +21 -0
- package/Scroller/Scroller.d.ts +0 -12
- package/Scroller/ScrollerBasic.js +9 -28
- package/Transition/Transition.js +9 -3
- package/Transition/tests/Transition-specs.js +0 -24
- package/VirtualList/UiVirtualListBase.js +10 -20
- package/VirtualList/VirtualList.d.ts +0 -20
- package/VirtualList/VirtualListBasic.js +33 -49
- package/VirtualList/tests/VirtualList-specs.js +0 -45
- package/package.json +2 -2
- package/useScroll/useScroll.js +10 -24
package/Button/Button.js
CHANGED
|
@@ -241,9 +241,11 @@ var ButtonBase = (0, _kind["default"])({
|
|
|
241
241
|
props.flip = iconFlip;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
|
|
245
|
-
children
|
|
246
|
-
}
|
|
244
|
+
if (_icon !== true) {
|
|
245
|
+
props.children = _icon;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ComponentOverride["default"], _objectSpread({}, props));
|
|
247
249
|
}
|
|
248
250
|
},
|
|
249
251
|
render: function render(_ref3) {
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
The following is a curated list of changes in the Enact ui module, newest changes on the top.
|
|
4
4
|
|
|
5
|
+
## [4.1.4] - 2022-03-24
|
|
6
|
+
|
|
7
|
+
### Removed
|
|
8
|
+
|
|
9
|
+
- `ui/Scroller` and `ui/VirtualList` prop `data-webos-voice-focused`, `data-webos-voice-disabled`, and `data-webos-voice-group-label`
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `ui/MarqueeDecorator` `locale` type for `forceDirection` prop not to override the direction depending on contents
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- `ui/Button` not to pass `icon` prop as children when `icon` is true
|
|
18
|
+
- `ui/Transition` to pass the event when handling transition event
|
|
19
|
+
|
|
5
20
|
## [4.1.3] - 2022-03-07
|
|
6
21
|
|
|
7
22
|
- Updated to use `forwardCustom` and add `type` when forwarding custom events
|
|
@@ -219,7 +219,7 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
219
219
|
// Text directionality is a function of locale direction (rtl), content (node.textContent),
|
|
220
220
|
// and props (forceDirection) in increasing order of significance.
|
|
221
221
|
if (forceDirection) {
|
|
222
|
-
rtl = forceDirection === 'rtl';
|
|
222
|
+
rtl = forceDirection === 'locale' ? rtl : forceDirection === 'rtl';
|
|
223
223
|
} else if (node) {
|
|
224
224
|
rtl = marqueeDirection(node.textContent) === 'rtl';
|
|
225
225
|
}
|
|
@@ -916,14 +916,17 @@ var MarqueeDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wra
|
|
|
916
916
|
/**
|
|
917
917
|
* Forces the `direction` of the marquee.
|
|
918
918
|
*
|
|
919
|
-
* Valid values are `'rtl'` and `'
|
|
919
|
+
* Valid values are `'rtl'`, `'ltr'`, and `'locale'`. This includes non-text elements as well.
|
|
920
920
|
* The default behavior, if this prop is unset, is to evaluate the text content for
|
|
921
921
|
* directionality using {@link i18n/util.isRtlText}.
|
|
922
922
|
*
|
|
923
|
+
* If `'locale'`, the `direction` is determined by the locale, same as {@link ui/Marquee.MarqueeDecorator.rtl}.
|
|
924
|
+
* In other words, it will not consider the text content for determining the direction.
|
|
925
|
+
*
|
|
923
926
|
* @type {String}
|
|
924
927
|
* @public
|
|
925
928
|
*/
|
|
926
|
-
forceDirection: _propTypes["default"].oneOf(['rtl', 'ltr']),
|
|
929
|
+
forceDirection: _propTypes["default"].oneOf(['rtl', 'ltr', 'locale']),
|
|
927
930
|
|
|
928
931
|
/**
|
|
929
932
|
* The current locale as a
|
package/Marquee/index.d.ts
CHANGED
|
@@ -166,9 +166,12 @@ unfocusable) components to marquee.
|
|
|
166
166
|
/**
|
|
167
167
|
* Forces the `direction` of the marquee.
|
|
168
168
|
*
|
|
169
|
-
* Valid values are `'rtl'` and `'
|
|
169
|
+
* Valid values are `'rtl'` , `'ltr'` , and `'locale'` . This includes non-text elements as well.
|
|
170
170
|
The default behavior, if this prop is unset, is to evaluate the text content for
|
|
171
171
|
directionality using .
|
|
172
|
+
*
|
|
173
|
+
* If `'locale'` , the `direction` is determined by the locale, same as .
|
|
174
|
+
In other words, it will not consider the text content for determining the direction.
|
|
172
175
|
*/
|
|
173
176
|
forceDirection?: string;
|
|
174
177
|
/**
|
|
@@ -108,6 +108,27 @@ describe('Marquee', function () {
|
|
|
108
108
|
'direction': expected
|
|
109
109
|
});
|
|
110
110
|
});
|
|
111
|
+
test('should not override direction to RTL when forceDirection is "locale" and locale is LTR', function () {
|
|
112
|
+
var _render3 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Marquee, {
|
|
113
|
+
forceDirection: "locale",
|
|
114
|
+
children: ltrText
|
|
115
|
+
})),
|
|
116
|
+
rerender = _render3.rerender;
|
|
117
|
+
|
|
118
|
+
var marquee = _react.screen.getByText(ltrText);
|
|
119
|
+
|
|
120
|
+
var expected = 'ltr';
|
|
121
|
+
expect(marquee).toHaveStyle({
|
|
122
|
+
'direction': expected
|
|
123
|
+
});
|
|
124
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Marquee, {
|
|
125
|
+
forceDirection: "locale",
|
|
126
|
+
children: rtlText
|
|
127
|
+
}));
|
|
128
|
+
expect(marquee).toHaveStyle({
|
|
129
|
+
'direction': expected
|
|
130
|
+
});
|
|
131
|
+
});
|
|
111
132
|
test('should override direction to LTR when forceDirection is set and locale is RTL', function () {
|
|
112
133
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Marquee, {
|
|
113
134
|
"data-testid": "marquee",
|
package/Scroller/Scroller.d.ts
CHANGED
|
@@ -6,18 +6,6 @@ type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
|
6
6
|
type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
|
|
7
7
|
|
|
8
8
|
export interface ScrollerBasicProps {
|
|
9
|
-
/**
|
|
10
|
-
* Disable voice control feature of component.
|
|
11
|
-
*/
|
|
12
|
-
"data-webos-voice-disabled"?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Activates the component for voice control.
|
|
15
|
-
*/
|
|
16
|
-
"data-webos-voice-focused"?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* The voice control group label.
|
|
19
|
-
*/
|
|
20
|
-
"data-webos-voice-group-label"?: string;
|
|
21
9
|
/**
|
|
22
10
|
* Direction of the scroller.
|
|
23
11
|
*
|
|
@@ -170,7 +170,8 @@ var ScrollerBasic = /*#__PURE__*/function (_Component) {
|
|
|
170
170
|
}
|
|
171
171
|
}, {
|
|
172
172
|
key: "setScrollPosition",
|
|
173
|
-
value:
|
|
173
|
+
value: // scrollMode 'translate'
|
|
174
|
+
function setScrollPosition(x, y) {
|
|
174
175
|
var node = this.props.scrollContentRef.current;
|
|
175
176
|
|
|
176
177
|
if (this.isVertical()) {
|
|
@@ -182,12 +183,16 @@ var ScrollerBasic = /*#__PURE__*/function (_Component) {
|
|
|
182
183
|
node.scrollLeft = this.getRtlPositionX(x);
|
|
183
184
|
this.scrollPos.left = x;
|
|
184
185
|
}
|
|
185
|
-
} // scrollMode '
|
|
186
|
+
} // scrollMode 'native'
|
|
186
187
|
|
|
187
188
|
}, {
|
|
188
189
|
key: "scrollToPosition",
|
|
189
|
-
value: function scrollToPosition(
|
|
190
|
-
this.props.scrollContentRef.current.scrollTo(
|
|
190
|
+
value: function scrollToPosition(left, top, behavior) {
|
|
191
|
+
this.props.scrollContentRef.current.scrollTo({
|
|
192
|
+
left: this.getRtlPositionX(left),
|
|
193
|
+
top: top,
|
|
194
|
+
behavior: behavior
|
|
195
|
+
});
|
|
191
196
|
} // scrollMode 'native'
|
|
192
197
|
|
|
193
198
|
}, {
|
|
@@ -260,30 +265,6 @@ ScrollerBasic.propTypes =
|
|
|
260
265
|
*/
|
|
261
266
|
cbScrollTo: _propTypes2["default"].func,
|
|
262
267
|
|
|
263
|
-
/**
|
|
264
|
-
* Disable voice control feature of component.
|
|
265
|
-
*
|
|
266
|
-
* @type {Boolean}
|
|
267
|
-
* @public
|
|
268
|
-
*/
|
|
269
|
-
'data-webos-voice-disabled': _propTypes2["default"].bool,
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Activates the component for voice control.
|
|
273
|
-
*
|
|
274
|
-
* @type {Boolean}
|
|
275
|
-
* @public
|
|
276
|
-
*/
|
|
277
|
-
'data-webos-voice-focused': _propTypes2["default"].bool,
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* The voice control group label.
|
|
281
|
-
*
|
|
282
|
-
* @type {String}
|
|
283
|
-
* @public
|
|
284
|
-
*/
|
|
285
|
-
'data-webos-voice-group-label': _propTypes2["default"].string,
|
|
286
|
-
|
|
287
268
|
/**
|
|
288
269
|
* Direction of the scroller.
|
|
289
270
|
*
|
package/Transition/Transition.js
CHANGED
|
@@ -371,13 +371,19 @@ var Transition = /*#__PURE__*/function (_Component) {
|
|
|
371
371
|
};
|
|
372
372
|
|
|
373
373
|
_this.handleTransitionEnd = function (ev) {
|
|
374
|
-
(0, _handle.
|
|
374
|
+
(0, _handle.forward)('onTransitionEnd', ev, _this.props);
|
|
375
375
|
|
|
376
376
|
if (ev.target === _this.childNode) {
|
|
377
377
|
if (!_this.props.visible) {
|
|
378
|
-
(0, _handle.
|
|
378
|
+
(0, _handle.forward)('onHide', {
|
|
379
|
+
type: 'onHide',
|
|
380
|
+
currentTarget: ev.currentTarget
|
|
381
|
+
}, _this.props);
|
|
379
382
|
} else if (_this.props.visible) {
|
|
380
|
-
(0, _handle.
|
|
383
|
+
(0, _handle.forward)('onShow', {
|
|
384
|
+
type: 'onShow',
|
|
385
|
+
currentTarget: ev.currentTarget
|
|
386
|
+
}, _this.props);
|
|
381
387
|
}
|
|
382
388
|
}
|
|
383
389
|
};
|
|
@@ -179,30 +179,6 @@ describe('Transition Specs', function () {
|
|
|
179
179
|
var actual = handleHide.mock.calls.length && handleHide.mock.calls[0][0];
|
|
180
180
|
expect(handleHide).toBeCalledTimes(expected);
|
|
181
181
|
expect(actual).toMatchObject(expectedType);
|
|
182
|
-
});
|
|
183
|
-
test('should fire \'onTransitionEnd\' event with type', function () {
|
|
184
|
-
var handleTransitionEnd = jest.fn();
|
|
185
|
-
|
|
186
|
-
var ChildNode = function ChildNode(props) {
|
|
187
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, props), {}, {
|
|
188
|
-
children: "Body"
|
|
189
|
-
}));
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Transition["default"], {
|
|
193
|
-
onTransitionEnd: handleTransitionEnd,
|
|
194
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ChildNode, {})
|
|
195
|
-
}));
|
|
196
|
-
|
|
197
|
-
_react.fireEvent.transitionEnd(_react.screen.getByText('Body'));
|
|
198
|
-
|
|
199
|
-
var expected = 1;
|
|
200
|
-
var expectedType = {
|
|
201
|
-
type: 'onTransitionEnd'
|
|
202
|
-
};
|
|
203
|
-
var actual = handleTransitionEnd.mock.calls.length && handleTransitionEnd.mock.calls[0][0];
|
|
204
|
-
expect(handleTransitionEnd).toBeCalledTimes(expected);
|
|
205
|
-
expect(actual).toMatchObject(expectedType);
|
|
206
182
|
}); // Tests for prop and className combinations
|
|
207
183
|
|
|
208
184
|
var directionCombination = [['up', 'up'], ['right', 'right'], ['down', 'down'], ['left', 'left']];
|
|
@@ -1113,11 +1113,10 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
|
|
|
1113
1113
|
value: function render() {
|
|
1114
1114
|
var _this$props7 = this.props,
|
|
1115
1115
|
className = _this$props7.className,
|
|
1116
|
-
|
|
1117
|
-
voiceGroupLabel = _this$props7['data-webos-voice-group-label'],
|
|
1116
|
+
containerProps = _this$props7.containerProps,
|
|
1118
1117
|
itemsRenderer = _this$props7.itemsRenderer,
|
|
1119
1118
|
style = _this$props7.style,
|
|
1120
|
-
rest = _objectWithoutProperties(_this$props7, ["className", "
|
|
1119
|
+
rest = _objectWithoutProperties(_this$props7, ["className", "containerProps", "itemsRenderer", "style"]),
|
|
1121
1120
|
cc = this.cc,
|
|
1122
1121
|
itemContainerRef = this.itemContainerRef,
|
|
1123
1122
|
primary = this.primary,
|
|
@@ -1147,10 +1146,9 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
|
|
|
1147
1146
|
this.positionItems();
|
|
1148
1147
|
}
|
|
1149
1148
|
|
|
1150
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
1151
|
-
className: containerClasses
|
|
1152
|
-
|
|
1153
|
-
"data-webos-voice-group-label": voiceGroupLabel,
|
|
1149
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({
|
|
1150
|
+
className: containerClasses
|
|
1151
|
+
}, containerProps), {}, {
|
|
1154
1152
|
ref: this.containerRef,
|
|
1155
1153
|
style: style,
|
|
1156
1154
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, rest), {}, {
|
|
@@ -1162,7 +1160,7 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
|
|
|
1162
1160
|
primary: primary
|
|
1163
1161
|
})
|
|
1164
1162
|
}))
|
|
1165
|
-
});
|
|
1163
|
+
}));
|
|
1166
1164
|
}
|
|
1167
1165
|
}], [{
|
|
1168
1166
|
key: "getDerivedStateFromProps",
|
|
@@ -1264,20 +1262,12 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
|
|
|
1264
1262
|
}),
|
|
1265
1263
|
|
|
1266
1264
|
/**
|
|
1267
|
-
*
|
|
1268
|
-
*
|
|
1269
|
-
* @type {Boolean}
|
|
1270
|
-
* @public
|
|
1271
|
-
*/
|
|
1272
|
-
'data-webos-voice-focused': _propTypes["default"].bool,
|
|
1273
|
-
|
|
1274
|
-
/**
|
|
1275
|
-
* The voice control group label.
|
|
1265
|
+
* An object with properties to be passed to the container DOM.
|
|
1276
1266
|
*
|
|
1277
|
-
* @type {
|
|
1278
|
-
* @
|
|
1267
|
+
* @type {Object}
|
|
1268
|
+
* @private
|
|
1279
1269
|
*/
|
|
1280
|
-
|
|
1270
|
+
containerProps: _propTypes["default"].object,
|
|
1281
1271
|
|
|
1282
1272
|
/**
|
|
1283
1273
|
* The number of items of data the list contains.
|
|
@@ -195,18 +195,6 @@ renderItem = ({index, ...rest}) => {
|
|
|
195
195
|
* Client size of the list; valid values are an object that has `clientWidth` and `clientHeight` .
|
|
196
196
|
*/
|
|
197
197
|
clientSize?: object;
|
|
198
|
-
/**
|
|
199
|
-
* Disable voice control feature of component.
|
|
200
|
-
*/
|
|
201
|
-
"data-webos-voice-disabled"?: boolean;
|
|
202
|
-
/**
|
|
203
|
-
* Activates the component for voice control.
|
|
204
|
-
*/
|
|
205
|
-
"data-webos-voice-focused"?: boolean;
|
|
206
|
-
/**
|
|
207
|
-
* The voice control group label.
|
|
208
|
-
*/
|
|
209
|
-
"data-webos-voice-group-label"?: string;
|
|
210
198
|
/**
|
|
211
199
|
* The number of items of data the list contains.
|
|
212
200
|
*/
|
|
@@ -302,14 +290,6 @@ this.scrollTo({align: 'top'}); // scroll to the top
|
|
|
302
290
|
* Client size of the list; valid values are an object that has `clientWidth` and `clientHeight` .
|
|
303
291
|
*/
|
|
304
292
|
clientSize?: object;
|
|
305
|
-
/**
|
|
306
|
-
* Activates the component for voice control.
|
|
307
|
-
*/
|
|
308
|
-
"data-webos-voice-focused"?: boolean;
|
|
309
|
-
/**
|
|
310
|
-
* The voice control group label.
|
|
311
|
-
*/
|
|
312
|
-
"data-webos-voice-group-label"?: string;
|
|
313
293
|
/**
|
|
314
294
|
* The number of items of data the list contains.
|
|
315
295
|
*/
|
|
@@ -159,17 +159,16 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
159
159
|
_this.itemPositions = [];
|
|
160
160
|
_this.indexToScrollIntoView = -1;
|
|
161
161
|
|
|
162
|
-
_this.updateScrollPosition = function (_ref) {
|
|
162
|
+
_this.updateScrollPosition = function (_ref, behavior) {
|
|
163
163
|
var x = _ref.x,
|
|
164
164
|
y = _ref.y;
|
|
165
|
-
var rtl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.props.rtl;
|
|
166
165
|
|
|
167
166
|
if (_this.props.scrollMode === 'native') {
|
|
168
|
-
_this.scrollToPosition(x, y,
|
|
167
|
+
_this.scrollToPosition(x, y, behavior);
|
|
169
168
|
} else {
|
|
170
169
|
_this.setScrollPositionTarget(x, y);
|
|
171
170
|
|
|
172
|
-
_this.setScrollPosition(x, y
|
|
171
|
+
_this.setScrollPosition(x, y);
|
|
173
172
|
}
|
|
174
173
|
};
|
|
175
174
|
|
|
@@ -319,6 +318,14 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
319
318
|
}
|
|
320
319
|
};
|
|
321
320
|
|
|
321
|
+
_this.getRtlPositionX = function (x) {
|
|
322
|
+
if (_this.props.rtl) {
|
|
323
|
+
return _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 || _platform.platform.androidChrome >= 85 ? -x : _this.scrollBounds.maxLeft - x;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return x;
|
|
327
|
+
};
|
|
328
|
+
|
|
322
329
|
_this.applyStyleToNewNode = function (index) {
|
|
323
330
|
var _this2;
|
|
324
331
|
|
|
@@ -538,7 +545,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
538
545
|
this.updateScrollPosition({
|
|
539
546
|
x: xMax > x ? x : xMax,
|
|
540
547
|
y: yMax > y ? y : yMax
|
|
541
|
-
});
|
|
548
|
+
}, 'instant');
|
|
542
549
|
deferScrollTo = true;
|
|
543
550
|
} else if (this.hasDataSizeChanged) {
|
|
544
551
|
var newState = this.getStatesAndUpdateBounds(this.props, this.state.firstIndex); // eslint-disable-next-line react/no-did-update-set-state
|
|
@@ -547,7 +554,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
547
554
|
this.setContainerSize();
|
|
548
555
|
deferScrollTo = true;
|
|
549
556
|
} else if (prevProps.rtl !== this.props.rtl) {
|
|
550
|
-
this.updateScrollPosition(this.getXY(this.scrollPosition, 0));
|
|
557
|
+
this.updateScrollPosition(this.getXY(this.scrollPosition, 0), 'instant');
|
|
551
558
|
}
|
|
552
559
|
|
|
553
560
|
var maxPos = this.isPrimaryDirectionVertical ? this.scrollBounds.maxTop : this.scrollBounds.maxLeft;
|
|
@@ -692,9 +699,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
692
699
|
if (scrollMode === 'translate' && this.contentRef.current) {
|
|
693
700
|
this.contentRef.current.style.transform = null;
|
|
694
701
|
} else if (scrollMode === 'native' && node) {
|
|
695
|
-
|
|
696
|
-
this.updateScrollPosition(this.getXY(this.scrollPosition, 0));
|
|
697
|
-
node.style.scrollBehavior = 'smooth';
|
|
702
|
+
this.updateScrollPosition(this.getXY(this.scrollPosition, 0), 'instant');
|
|
698
703
|
}
|
|
699
704
|
}
|
|
700
705
|
}, {
|
|
@@ -835,15 +840,14 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
835
840
|
|
|
836
841
|
}, {
|
|
837
842
|
key: "scrollToPosition",
|
|
838
|
-
value:
|
|
839
|
-
|
|
840
|
-
|
|
843
|
+
value: // scrollMode 'native' only
|
|
844
|
+
function scrollToPosition(left, top, behavior) {
|
|
841
845
|
if (this.props.scrollContentRef.current && this.props.scrollContentRef.current.scrollTo) {
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
846
|
+
this.props.scrollContentRef.current.scrollTo({
|
|
847
|
+
left: this.getRtlPositionX(left),
|
|
848
|
+
top: top,
|
|
849
|
+
behavior: behavior
|
|
850
|
+
});
|
|
847
851
|
}
|
|
848
852
|
} // scrollMode 'native' only
|
|
849
853
|
|
|
@@ -860,7 +864,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
860
864
|
}, {
|
|
861
865
|
key: "setScrollPositionTarget",
|
|
862
866
|
value: function setScrollPositionTarget(x, y) {
|
|
863
|
-
// The `
|
|
867
|
+
// The `left`, `top` as parameters in scrollToPosition() are the position when stopping scrolling.
|
|
864
868
|
// But the `x`, `y` as parameters in setScrollPosition() are the position between current position and the position stopping scrolling.
|
|
865
869
|
// To know the position when stopping scrolling properly, `x` and `y` are passed and cached in `this.scrollPositionTarget`.
|
|
866
870
|
if (this.isPrimaryDirectionVertical) {
|
|
@@ -873,7 +877,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
873
877
|
}, {
|
|
874
878
|
key: "setScrollPosition",
|
|
875
879
|
value: function setScrollPosition(x, y) {
|
|
876
|
-
var rtl =
|
|
880
|
+
var rtl = this.props.rtl;
|
|
877
881
|
|
|
878
882
|
if (this.contentRef.current) {
|
|
879
883
|
this.contentRef.current.style.transform = "translate3d(".concat(rtl ? x : -x, "px, -").concat(y, "px, 0)");
|
|
@@ -1170,14 +1174,12 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
1170
1174
|
function render() {
|
|
1171
1175
|
var _this$props7 = this.props,
|
|
1172
1176
|
className = _this$props7.className,
|
|
1173
|
-
|
|
1174
|
-
voiceGroupLabel = _this$props7['data-webos-voice-group-label'],
|
|
1175
|
-
voiceDisabled = _this$props7['data-webos-voice-disabled'],
|
|
1177
|
+
containerProps = _this$props7.containerProps,
|
|
1176
1178
|
placeholderRenderer = _this$props7.placeholderRenderer,
|
|
1177
1179
|
role = _this$props7.role,
|
|
1178
1180
|
style = _this$props7.style,
|
|
1179
1181
|
scrollMode = _this$props7.scrollMode,
|
|
1180
|
-
rest = _objectWithoutProperties(_this$props7, ["className", "
|
|
1182
|
+
rest = _objectWithoutProperties(_this$props7, ["className", "containerProps", "placeholderRenderer", "role", "style", "scrollMode"]),
|
|
1181
1183
|
cc = this.cc,
|
|
1182
1184
|
isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
|
|
1183
1185
|
primary = this.primary,
|
|
@@ -1214,11 +1216,9 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
1214
1216
|
this.positionItems();
|
|
1215
1217
|
}
|
|
1216
1218
|
|
|
1217
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
1218
|
-
className: containerClasses
|
|
1219
|
-
|
|
1220
|
-
"data-webos-voice-group-label": voiceGroupLabel,
|
|
1221
|
-
"data-webos-voice-disabled": voiceDisabled,
|
|
1219
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({
|
|
1220
|
+
className: containerClasses
|
|
1221
|
+
}, containerProps), {}, {
|
|
1222
1222
|
ref: this.props.scrollContentRef,
|
|
1223
1223
|
style: style,
|
|
1224
1224
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, rest), {}, {
|
|
@@ -1227,7 +1227,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
1227
1227
|
role: role,
|
|
1228
1228
|
children: [].concat(_toConsumableArray(cc), [placeholderRenderer && placeholderRenderer(primary)])
|
|
1229
1229
|
}))
|
|
1230
|
-
});
|
|
1230
|
+
}));
|
|
1231
1231
|
}
|
|
1232
1232
|
}], [{
|
|
1233
1233
|
key: "getDerivedStateFromProps",
|
|
@@ -1321,28 +1321,12 @@ VirtualListBasic.propTypes =
|
|
|
1321
1321
|
}),
|
|
1322
1322
|
|
|
1323
1323
|
/**
|
|
1324
|
-
*
|
|
1325
|
-
*
|
|
1326
|
-
* @type {Boolean}
|
|
1327
|
-
* @public
|
|
1328
|
-
*/
|
|
1329
|
-
'data-webos-voice-disabled': _propTypes2["default"].bool,
|
|
1330
|
-
|
|
1331
|
-
/**
|
|
1332
|
-
* Activates the component for voice control.
|
|
1324
|
+
* An object with properties to be passed to the container DOM.
|
|
1333
1325
|
*
|
|
1334
|
-
* @type {
|
|
1335
|
-
* @
|
|
1336
|
-
*/
|
|
1337
|
-
'data-webos-voice-focused': _propTypes2["default"].bool,
|
|
1338
|
-
|
|
1339
|
-
/**
|
|
1340
|
-
* The voice control group label.
|
|
1341
|
-
*
|
|
1342
|
-
* @type {String}
|
|
1343
|
-
* @public
|
|
1326
|
+
* @type {Object}
|
|
1327
|
+
* @private
|
|
1344
1328
|
*/
|
|
1345
|
-
|
|
1329
|
+
containerProps: _propTypes2["default"].object,
|
|
1346
1330
|
|
|
1347
1331
|
/**
|
|
1348
1332
|
* The number of items of data the list contains.
|
|
@@ -285,49 +285,4 @@ describe('VirtualList', function () {
|
|
|
285
285
|
}, 0);
|
|
286
286
|
});
|
|
287
287
|
});
|
|
288
|
-
describe('Voice Control', function () {
|
|
289
|
-
test('should render "data-webos-voice-focused" to outermost node of VirtualList', function () {
|
|
290
|
-
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
291
|
-
cbScrollTo: getScrollTo,
|
|
292
|
-
clientSize: clientSize,
|
|
293
|
-
dataSize: dataSize,
|
|
294
|
-
itemRenderer: renderItem,
|
|
295
|
-
itemSize: 30,
|
|
296
|
-
"data-webos-voice-focused": true
|
|
297
|
-
}));
|
|
298
|
-
|
|
299
|
-
var actual = _react.screen.getByRole('list').parentElement;
|
|
300
|
-
|
|
301
|
-
expect(actual).toHaveAttribute('data-webos-voice-focused', 'true');
|
|
302
|
-
});
|
|
303
|
-
test('should render "data-webos-voice-group-label" to outermost node of VirtualList', function () {
|
|
304
|
-
var label = 'group label';
|
|
305
|
-
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
306
|
-
cbScrollTo: getScrollTo,
|
|
307
|
-
clientSize: clientSize,
|
|
308
|
-
dataSize: dataSize,
|
|
309
|
-
itemRenderer: renderItem,
|
|
310
|
-
itemSize: 30,
|
|
311
|
-
"data-webos-voice-group-label": label
|
|
312
|
-
}));
|
|
313
|
-
|
|
314
|
-
var actual = _react.screen.getByRole('list').parentElement;
|
|
315
|
-
|
|
316
|
-
expect(actual).toHaveAttribute('data-webos-voice-group-label', label);
|
|
317
|
-
});
|
|
318
|
-
test('should render "data-webos-voice-disabled" to outermost node of VirtualList', function () {
|
|
319
|
-
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
320
|
-
cbScrollTo: getScrollTo,
|
|
321
|
-
clientSize: clientSize,
|
|
322
|
-
dataSize: dataSize,
|
|
323
|
-
itemRenderer: renderItem,
|
|
324
|
-
itemSize: 30,
|
|
325
|
-
"data-webos-voice-disabled": true
|
|
326
|
-
}));
|
|
327
|
-
|
|
328
|
-
var actual = _react.screen.getByRole('list').parentElement;
|
|
329
|
-
|
|
330
|
-
expect(actual).toHaveAttribute('data-webos-voice-disabled', 'true');
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
288
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enact/ui",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.4",
|
|
4
4
|
"description": "A collection of simplified unstyled cross-platform UI components for Enact",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@enact/core": "^4.1.
|
|
28
|
+
"@enact/core": "^4.1.4",
|
|
29
29
|
"classnames": "^2.3.1",
|
|
30
30
|
"direction": "^1.0.4",
|
|
31
31
|
"invariant": "^2.2.4",
|
package/useScroll/useScroll.js
CHANGED
|
@@ -132,9 +132,6 @@ var useScrollBase = function useScrollBase(props) {
|
|
|
132
132
|
children = props.children,
|
|
133
133
|
className = props.className,
|
|
134
134
|
clientSize = props.clientSize,
|
|
135
|
-
voiceDisabled = props['data-webos-voice-disabled'],
|
|
136
|
-
voiceFocused = props['data-webos-voice-focused'],
|
|
137
|
-
voiceGroupLabel = props['data-webos-voice-group-label'],
|
|
138
135
|
assignProperties = props.assignProperties,
|
|
139
136
|
dataSize = props.dataSize,
|
|
140
137
|
direction = props.direction,
|
|
@@ -161,7 +158,7 @@ var useScrollBase = function useScrollBase(props) {
|
|
|
161
158
|
verticalScrollbar = props.verticalScrollbar,
|
|
162
159
|
verticalScrollbarHandle = props.verticalScrollbarHandle,
|
|
163
160
|
wrap = props.wrap,
|
|
164
|
-
rest = _objectWithoutProperties(props, ["childProps", "children", "className", "clientSize", "
|
|
161
|
+
rest = _objectWithoutProperties(props, ["childProps", "children", "className", "clientSize", "assignProperties", "dataSize", "direction", "horizontalScrollbar", "horizontalScrollbarHandle", "itemRenderer", "itemSize", "itemSizes", "noScrollByDrag", "noScrollByWheel", "overhang", "overscrollEffectOn", "pageScroll", "role", "rtl", "scrollContainerRef", "scrollContentHandle", "scrollContentRef", "scrollMode", "setScrollContainerHandle", "snapToCenter", "spacing", "spotlightContainerDisabled", "verticalScrollbar", "verticalScrollbarHandle", "wrap"]),
|
|
165
162
|
scrollClasses = (0, _classnames["default"])(_useScrollModule["default"].scroll, className); // The following props are the one having the same naming function in this scope.
|
|
166
163
|
// So it is better to use props[propName]
|
|
167
164
|
// instead of extracting it from the `props` and renaming it
|
|
@@ -430,7 +427,7 @@ var useScrollBase = function useScrollBase(props) {
|
|
|
430
427
|
var enqueueForceUpdate = (0, _react.useCallback)(function () {
|
|
431
428
|
scrollContentHandle.current.calculateMetrics(scrollContentHandle.current.props);
|
|
432
429
|
forceUpdate();
|
|
433
|
-
}, [forceUpdate, scrollContentHandle]);
|
|
430
|
+
}, [forceUpdate, scrollContentHandle]); // scrollMode 'translate' ]]
|
|
434
431
|
|
|
435
432
|
function handleResizeWindow() {
|
|
436
433
|
var propsHandleResizeWindow = props.handleResizeWindow; // `handleSize` in `ui/resolution.ResolutionDecorator` should be executed first.
|
|
@@ -449,14 +446,13 @@ var useScrollBase = function useScrollBase(props) {
|
|
|
449
446
|
animate: false
|
|
450
447
|
});
|
|
451
448
|
} else {
|
|
452
|
-
|
|
453
|
-
scrollContentHandle.current.scrollToPosition(0, 0);
|
|
454
|
-
scrollContentRef.current.style.scrollBehavior = 'smooth';
|
|
449
|
+
scrollContentHandle.current.scrollToPosition(0, 0, 'instant');
|
|
455
450
|
}
|
|
456
451
|
|
|
457
452
|
enqueueForceUpdate();
|
|
458
453
|
});
|
|
459
|
-
}
|
|
454
|
+
} // scrollMode 'translate' [[
|
|
455
|
+
|
|
460
456
|
|
|
461
457
|
var handleResize = (0, _react.useCallback)(function (ev) {
|
|
462
458
|
if (ev.action === 'invalidateBounds') {
|
|
@@ -1247,11 +1243,9 @@ var useScrollBase = function useScrollBase(props) {
|
|
|
1247
1243
|
} else {
|
|
1248
1244
|
// scrollMode 'native'
|
|
1249
1245
|
if (animate) {
|
|
1250
|
-
scrollContentHandle.current.scrollToPosition(targetX, targetY);
|
|
1246
|
+
scrollContentHandle.current.scrollToPosition(targetX, targetY, 'smooth');
|
|
1251
1247
|
} else {
|
|
1252
|
-
|
|
1253
|
-
scrollContentHandle.current.scrollToPosition(targetX, targetY);
|
|
1254
|
-
scrollContentRef.current.style.scrollBehavior = 'smooth';
|
|
1248
|
+
scrollContentHandle.current.scrollToPosition(targetX, targetY, 'instant');
|
|
1255
1249
|
}
|
|
1256
1250
|
|
|
1257
1251
|
if (props.start) {
|
|
@@ -1316,7 +1310,7 @@ var useScrollBase = function useScrollBase(props) {
|
|
|
1316
1310
|
setScrollTop(top);
|
|
1317
1311
|
}
|
|
1318
1312
|
|
|
1319
|
-
scrollContentHandle.current.setScrollPosition(mutableRef.current.scrollLeft, mutableRef.current.scrollTop
|
|
1313
|
+
scrollContentHandle.current.setScrollPosition(mutableRef.current.scrollLeft, mutableRef.current.scrollTop);
|
|
1320
1314
|
forwardScrollEvent('onScroll');
|
|
1321
1315
|
} // scrollMode 'translate' ]]
|
|
1322
1316
|
|
|
@@ -1342,9 +1336,7 @@ var useScrollBase = function useScrollBase(props) {
|
|
|
1342
1336
|
}
|
|
1343
1337
|
|
|
1344
1338
|
function stopForNative() {
|
|
1345
|
-
|
|
1346
|
-
scrollContentHandle.current.scrollToPosition(mutableRef.current.scrollLeft + (rtl ? -0.1 : 0.1), mutableRef.current.scrollTop + 0.1);
|
|
1347
|
-
scrollContentRef.current.style.scrollBehavior = 'smooth';
|
|
1339
|
+
scrollContentHandle.current.scrollToPosition(mutableRef.current.scrollLeft + (rtl ? -0.1 : 0.1), mutableRef.current.scrollTop + 0.1, 'instant');
|
|
1348
1340
|
}
|
|
1349
1341
|
|
|
1350
1342
|
function stop() {
|
|
@@ -1558,7 +1550,6 @@ var useScrollBase = function useScrollBase(props) {
|
|
|
1558
1550
|
(0, _utilEvent["default"])('scroll').addEventListener(scrollContentRef, onScroll, {
|
|
1559
1551
|
passive: true
|
|
1560
1552
|
});
|
|
1561
|
-
scrollContentRef.current.style.scrollBehavior = 'smooth';
|
|
1562
1553
|
} // scrollMode 'native' ]]
|
|
1563
1554
|
|
|
1564
1555
|
|
|
@@ -1623,11 +1614,6 @@ var useScrollBase = function useScrollBase(props) {
|
|
|
1623
1614
|
onTouchStart: scrollMode === 'native' ? onTouchStart : null // scrollMode 'native'
|
|
1624
1615
|
|
|
1625
1616
|
}));
|
|
1626
|
-
var voiceProps = {
|
|
1627
|
-
'data-webos-voice-disabled': voiceDisabled,
|
|
1628
|
-
'data-webos-voice-focused': voiceFocused,
|
|
1629
|
-
'data-webos-voice-group-label': voiceGroupLabel
|
|
1630
|
-
};
|
|
1631
1617
|
var scrollContentProps = props.itemRenderer ? // If the child component is a VirtualList
|
|
1632
1618
|
{
|
|
1633
1619
|
childProps: childProps,
|
|
@@ -1643,7 +1629,7 @@ var useScrollBase = function useScrollBase(props) {
|
|
|
1643
1629
|
} : {
|
|
1644
1630
|
children: children
|
|
1645
1631
|
};
|
|
1646
|
-
assignProperties('scrollContentProps', _objectSpread(_objectSpread(
|
|
1632
|
+
assignProperties('scrollContentProps', _objectSpread(_objectSpread({}, scrollContentProps), {}, {
|
|
1647
1633
|
cbScrollTo: scrollTo,
|
|
1648
1634
|
className: [_useScrollModule["default"].scrollFill],
|
|
1649
1635
|
direction: direction,
|