@enact/ui 5.4.0 → 5.4.2
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/BodyText/BodyText.d.ts +4 -5
- package/Button/Button.d.ts +4 -2
- package/CHANGELOG.md +16 -0
- package/Card/Card.d.ts +4 -2
- package/FloatingLayer/index.d.ts +4 -2
- package/Group/Group.d.ts +8 -4
- package/Heading/Heading.d.ts +4 -2
- package/Icon/Icon.d.ts +4 -2
- package/Image/Image.d.ts +4 -2
- package/ImageItem/ImageItem.d.ts +5 -7
- package/Item/Item.d.ts +8 -4
- package/LabeledIcon/LabeledIcon.d.ts +5 -7
- package/Layout/Layout.d.ts +16 -11
- package/Marquee/index.d.ts +4 -2
- package/ProgressBar/ProgressBar.d.ts +5 -7
- package/Repeater/Repeater.d.ts +4 -5
- package/Scroller/Scroller.d.ts +9 -1
- package/Scroller/ScrollerBasic.js +47 -6
- package/Scroller/tests/ScrollerBasic-specs.js +59 -0
- package/Slider/Slider.d.ts +8 -4
- package/Spinner/Spinner.d.ts +4 -5
- package/ToggleIcon/ToggleIcon.d.ts +8 -10
- package/ViewManager/ViewManager.d.ts +9 -11
- package/VirtualList/VirtualList.d.ts +4 -4
- package/VirtualList/VirtualListBasic.js +54 -8
- package/package.json +7 -7
- package/resolution/index.d.ts +4 -4
- package/useScroll/tests/useScroll-specs.js +261 -25
- package/useScroll/useScroll.js +30 -17
package/BodyText/BodyText.d.ts
CHANGED
|
@@ -50,11 +50,10 @@ export function BodyTextDecorator<P>(
|
|
|
50
50
|
Component: React.ComponentType<P> | string,
|
|
51
51
|
): React.ComponentType<P & BodyTextDecoratorProps>;
|
|
52
52
|
|
|
53
|
-
export interface BodyTextProps
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
> {}
|
|
53
|
+
export interface BodyTextProps extends Omit<
|
|
54
|
+
Merge<BodyTextBaseProps, BodyTextDecoratorProps>,
|
|
55
|
+
"componentRef"
|
|
56
|
+
> {}
|
|
58
57
|
/**
|
|
59
58
|
* A simple, unstyled text block component.
|
|
60
59
|
*/
|
package/Button/Button.d.ts
CHANGED
|
@@ -112,8 +112,10 @@ export function ButtonDecorator<P>(
|
|
|
112
112
|
Component: React.ComponentType<P> | string,
|
|
113
113
|
): React.ComponentType<P & ButtonDecoratorProps>;
|
|
114
114
|
|
|
115
|
-
export interface ButtonProps
|
|
116
|
-
|
|
115
|
+
export interface ButtonProps extends Omit<
|
|
116
|
+
Merge<ButtonBaseProps, ButtonDecoratorProps>,
|
|
117
|
+
"componentRef"
|
|
118
|
+
> {}
|
|
117
119
|
/**
|
|
118
120
|
* A minimally-styled button component with touch support.
|
|
119
121
|
*/
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
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
|
+
## [5.4.2] - 2026-01-28
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- `ui/Scroller` scroll animation method for `scrollMode: native`
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- `ui/VirtulList` not to cut off focused item when scroll by pressing key
|
|
14
|
+
- `ui/VirtualList` not to jump to the top when item size was changed
|
|
15
|
+
- `ui/VirtualList.VirtualGridList` to adjust itemSize properly when resizing window
|
|
16
|
+
|
|
17
|
+
## [5.4.1] - 2025-12-30
|
|
18
|
+
|
|
19
|
+
No significant changes.
|
|
20
|
+
|
|
5
21
|
## [5.4.0] - 2025-12-08
|
|
6
22
|
|
|
7
23
|
### Added
|
package/Card/Card.d.ts
CHANGED
|
@@ -73,8 +73,10 @@ export function CardDecorator<P>(
|
|
|
73
73
|
Component: React.ComponentType<P> | string,
|
|
74
74
|
): React.ComponentType<P & CardDecoratorProps>;
|
|
75
75
|
|
|
76
|
-
export interface CardProps
|
|
77
|
-
|
|
76
|
+
export interface CardProps extends Omit<
|
|
77
|
+
Merge<CardBaseProps, CardDecoratorProps>,
|
|
78
|
+
"componentRef"
|
|
79
|
+
> {}
|
|
78
80
|
/**
|
|
79
81
|
* A minimally styled Card ready for customization by a theme.
|
|
80
82
|
*/
|
package/FloatingLayer/index.d.ts
CHANGED
|
@@ -85,8 +85,10 @@ export class FloatingLayerBase extends React.Component<
|
|
|
85
85
|
Merge<React.HTMLProps<HTMLElement>, FloatingLayerBaseProps>
|
|
86
86
|
> {}
|
|
87
87
|
|
|
88
|
-
export interface FloatingLayerProps
|
|
89
|
-
|
|
88
|
+
export interface FloatingLayerProps extends Merge<
|
|
89
|
+
FloatingLayerBaseProps,
|
|
90
|
+
ui_Cancelable_CancelableProps
|
|
91
|
+
> {}
|
|
90
92
|
/**
|
|
91
93
|
* FloatingLayer that mixes to handle FloatingLayer dismissal.
|
|
92
94
|
*
|
package/Group/Group.d.ts
CHANGED
|
@@ -17,8 +17,10 @@ export class GroupBase extends React.Component<
|
|
|
17
17
|
Merge<React.HTMLProps<HTMLElement>, GroupBaseProps>
|
|
18
18
|
> {}
|
|
19
19
|
|
|
20
|
-
export interface GroupProps
|
|
21
|
-
|
|
20
|
+
export interface GroupProps extends Omit<
|
|
21
|
+
Merge<GroupBaseProps, GroupDecoratorProps>,
|
|
22
|
+
"componentRef"
|
|
23
|
+
> {
|
|
22
24
|
/**
|
|
23
25
|
* Component type to repeat. This can be a React component or a string describing a DOM
|
|
24
26
|
node (e.g. `'div'` )
|
|
@@ -98,8 +100,10 @@ export class Group extends React.Component<
|
|
|
98
100
|
Merge<React.HTMLProps<HTMLElement>, GroupProps>
|
|
99
101
|
> {}
|
|
100
102
|
|
|
101
|
-
export interface GroupDecoratorProps
|
|
102
|
-
|
|
103
|
+
export interface GroupDecoratorProps extends Merge<
|
|
104
|
+
ui_ForwardRef_ForwardRefProps,
|
|
105
|
+
ui_Changeable_ChangeableProps
|
|
106
|
+
> {}
|
|
103
107
|
export function GroupDecorator<P>(
|
|
104
108
|
Component: React.ComponentType<P> | string,
|
|
105
109
|
): React.ComponentType<P & GroupDecoratorProps>;
|
package/Heading/Heading.d.ts
CHANGED
|
@@ -15,8 +15,10 @@ export class HeadingBase extends React.Component<
|
|
|
15
15
|
Merge<React.HTMLProps<HTMLElement>, HeadingBaseProps>
|
|
16
16
|
> {}
|
|
17
17
|
|
|
18
|
-
export interface HeadingProps
|
|
19
|
-
|
|
18
|
+
export interface HeadingProps extends Omit<
|
|
19
|
+
Merge<HeadingBaseProps, HeadingDecoratorProps>,
|
|
20
|
+
"componentRef"
|
|
21
|
+
> {
|
|
20
22
|
/**
|
|
21
23
|
* The text for the label of the Heading.
|
|
22
24
|
*/
|
package/Icon/Icon.d.ts
CHANGED
|
@@ -75,8 +75,10 @@ export function IconDecorator<P>(
|
|
|
75
75
|
Component: React.ComponentType<P> | string,
|
|
76
76
|
): React.ComponentType<P & IconDecoratorProps>;
|
|
77
77
|
|
|
78
|
-
export interface IconProps
|
|
79
|
-
|
|
78
|
+
export interface IconProps extends Omit<
|
|
79
|
+
Merge<IconBaseProps, IconDecoratorProps>,
|
|
80
|
+
"componentRef"
|
|
81
|
+
> {}
|
|
80
82
|
/**
|
|
81
83
|
* An Icon component.
|
|
82
84
|
*/
|
package/Image/Image.d.ts
CHANGED
|
@@ -88,8 +88,10 @@ export class ImageBase extends React.Component<
|
|
|
88
88
|
Merge<React.HTMLProps<HTMLElement>, ImageBaseProps>
|
|
89
89
|
> {}
|
|
90
90
|
|
|
91
|
-
export interface ImageProps
|
|
92
|
-
|
|
91
|
+
export interface ImageProps extends Omit<
|
|
92
|
+
Merge<ImageBaseProps, ImageDecoratorProps>,
|
|
93
|
+
"componentRef"
|
|
94
|
+
> {
|
|
93
95
|
/**
|
|
94
96
|
* The aria-label for the image.
|
|
95
97
|
*
|
package/ImageItem/ImageItem.d.ts
CHANGED
|
@@ -69,17 +69,15 @@ export class ImageItemBase extends React.Component<
|
|
|
69
69
|
Merge<React.HTMLProps<HTMLElement>, ImageItemBaseProps>
|
|
70
70
|
> {}
|
|
71
71
|
|
|
72
|
-
export interface ImageItemDecoratorProps
|
|
73
|
-
extends ui_ForwardRef_ForwardRefProps {}
|
|
72
|
+
export interface ImageItemDecoratorProps extends ui_ForwardRef_ForwardRefProps {}
|
|
74
73
|
export function ImageItemDecorator<P>(
|
|
75
74
|
Component: React.ComponentType<P> | string,
|
|
76
75
|
): React.ComponentType<P & ImageItemDecoratorProps>;
|
|
77
76
|
|
|
78
|
-
export interface ImageItemProps
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
> {}
|
|
77
|
+
export interface ImageItemProps extends Omit<
|
|
78
|
+
Merge<ImageItemBaseProps, ImageItemDecoratorProps>,
|
|
79
|
+
"componentRef"
|
|
80
|
+
> {}
|
|
83
81
|
/**
|
|
84
82
|
* A minimally styled ImageItem ready for customization by a theme.
|
|
85
83
|
*/
|
package/Item/Item.d.ts
CHANGED
|
@@ -45,14 +45,18 @@ export class ItemBase extends React.Component<
|
|
|
45
45
|
Merge<React.HTMLProps<HTMLElement>, ItemBaseProps>
|
|
46
46
|
> {}
|
|
47
47
|
|
|
48
|
-
export interface ItemDecoratorProps
|
|
49
|
-
|
|
48
|
+
export interface ItemDecoratorProps extends Merge<
|
|
49
|
+
ui_ForwardRef_ForwardRefProps,
|
|
50
|
+
ui_Touchable_TouchableProps
|
|
51
|
+
> {}
|
|
50
52
|
export function ItemDecorator<P>(
|
|
51
53
|
Component: React.ComponentType<P> | string,
|
|
52
54
|
): React.ComponentType<P & ItemDecoratorProps>;
|
|
53
55
|
|
|
54
|
-
export interface ItemProps
|
|
55
|
-
|
|
56
|
+
export interface ItemProps extends Omit<
|
|
57
|
+
Merge<ItemBaseProps, ItemDecoratorProps>,
|
|
58
|
+
"componentRef"
|
|
59
|
+
> {}
|
|
56
60
|
/**
|
|
57
61
|
* A minimally-styled ready-to-use list item component with touch support.
|
|
58
62
|
*/
|
|
@@ -101,17 +101,15 @@ export class LabeledIconBase extends React.Component<
|
|
|
101
101
|
Merge<React.HTMLProps<HTMLElement>, LabeledIconBaseProps>
|
|
102
102
|
> {}
|
|
103
103
|
|
|
104
|
-
export interface LabeledIconDecoratorProps
|
|
105
|
-
extends ui_Slottable_SlottableProps {}
|
|
104
|
+
export interface LabeledIconDecoratorProps extends ui_Slottable_SlottableProps {}
|
|
106
105
|
export function LabeledIconDecorator<P>(
|
|
107
106
|
Component: React.ComponentType<P> | string,
|
|
108
107
|
): React.ComponentType<P & LabeledIconDecoratorProps>;
|
|
109
108
|
|
|
110
|
-
export interface LabeledIconProps
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
> {}
|
|
109
|
+
export interface LabeledIconProps extends Omit<
|
|
110
|
+
Merge<LabeledIconBaseProps, LabeledIconDecoratorProps>,
|
|
111
|
+
"componentRef"
|
|
112
|
+
> {}
|
|
115
113
|
/**
|
|
116
114
|
* An icon component with a label without any behaviors applied to it.
|
|
117
115
|
*
|
package/Layout/Layout.d.ts
CHANGED
|
@@ -203,8 +203,10 @@ export function CellDecorator<P>(
|
|
|
203
203
|
Component: React.ComponentType<P> | string,
|
|
204
204
|
): React.ComponentType<P & CellDecoratorProps>;
|
|
205
205
|
|
|
206
|
-
export interface CellProps
|
|
207
|
-
|
|
206
|
+
export interface CellProps extends Omit<
|
|
207
|
+
Merge<CellBaseProps, CellDecoratorProps>,
|
|
208
|
+
"componentRef"
|
|
209
|
+
> {}
|
|
208
210
|
/**
|
|
209
211
|
* A stateless component that provides a space for your content in a
|
|
210
212
|
.
|
|
@@ -219,11 +221,10 @@ export function LayoutDecorator<P>(
|
|
|
219
221
|
Component: React.ComponentType<P> | string,
|
|
220
222
|
): React.ComponentType<P & LayoutDecoratorProps>;
|
|
221
223
|
|
|
222
|
-
export interface LayoutProps
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
> {}
|
|
224
|
+
export interface LayoutProps extends Omit<
|
|
225
|
+
Merge<LayoutBaseProps, ui_ForwardRef_ForwardRefProps>,
|
|
226
|
+
"componentRef"
|
|
227
|
+
> {}
|
|
227
228
|
/**
|
|
228
229
|
* A container for `Cell` s.
|
|
229
230
|
*
|
|
@@ -254,8 +255,10 @@ export class Layout extends React.Component<
|
|
|
254
255
|
Merge<React.HTMLProps<HTMLElement>, LayoutProps>
|
|
255
256
|
> {}
|
|
256
257
|
|
|
257
|
-
export interface ColumnProps
|
|
258
|
-
|
|
258
|
+
export interface ColumnProps extends Merge<
|
|
259
|
+
LayoutProps,
|
|
260
|
+
ui_ForwardRef_ForwardRefProps
|
|
261
|
+
> {}
|
|
259
262
|
/**
|
|
260
263
|
* Shorthand for `<Layout orientation="vertical">` , which positions its
|
|
261
264
|
vertically.
|
|
@@ -272,8 +275,10 @@ export class Column extends React.Component<
|
|
|
272
275
|
Merge<React.HTMLProps<HTMLElement>, ColumnProps>
|
|
273
276
|
> {}
|
|
274
277
|
|
|
275
|
-
export interface RowProps
|
|
276
|
-
|
|
278
|
+
export interface RowProps extends Merge<
|
|
279
|
+
LayoutProps,
|
|
280
|
+
ui_ForwardRef_ForwardRefProps
|
|
281
|
+
> {}
|
|
277
282
|
/**
|
|
278
283
|
* Shorthand for `<Layout orientation="horizontal">` , which positions its
|
|
279
284
|
horizontally.
|
package/Marquee/index.d.ts
CHANGED
|
@@ -241,8 +241,10 @@ export function MarqueeDecorator<P>(
|
|
|
241
241
|
Component: React.ComponentType<P> | string,
|
|
242
242
|
): React.ComponentType<P & MarqueeDecoratorProps>;
|
|
243
243
|
|
|
244
|
-
export interface MarqueeProps
|
|
245
|
-
|
|
244
|
+
export interface MarqueeProps extends Merge<
|
|
245
|
+
MarqueeBaseProps,
|
|
246
|
+
MarqueeDecoratorProps
|
|
247
|
+
> {}
|
|
246
248
|
/**
|
|
247
249
|
* A minimally-styled marquee component.
|
|
248
250
|
*/
|
|
@@ -70,17 +70,15 @@ export class ProgressBarBase extends React.Component<
|
|
|
70
70
|
Merge<React.HTMLProps<HTMLElement>, ProgressBarBaseProps>
|
|
71
71
|
> {}
|
|
72
72
|
|
|
73
|
-
export interface ProgressBarDecoratorProps
|
|
74
|
-
extends ui_ForwardRef_ForwardRefProps {}
|
|
73
|
+
export interface ProgressBarDecoratorProps extends ui_ForwardRef_ForwardRefProps {}
|
|
75
74
|
export function ProgressBarDecorator<P>(
|
|
76
75
|
Component: React.ComponentType<P> | string,
|
|
77
76
|
): React.ComponentType<P & ProgressBarDecoratorProps>;
|
|
78
77
|
|
|
79
|
-
export interface ProgressBarProps
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
> {}
|
|
78
|
+
export interface ProgressBarProps extends Omit<
|
|
79
|
+
Merge<ProgressBarBaseProps, ProgressBarDecoratorProps>,
|
|
80
|
+
"componentRef"
|
|
81
|
+
> {}
|
|
84
82
|
/**
|
|
85
83
|
* An unstyled progress bar component that can be customized by a theme or application.
|
|
86
84
|
*/
|
package/Repeater/Repeater.d.ts
CHANGED
|
@@ -66,11 +66,10 @@ export function RepeaterDecorator<P>(
|
|
|
66
66
|
Component: React.ComponentType<P> | string,
|
|
67
67
|
): React.ComponentType<P & RepeaterDecoratorProps>;
|
|
68
68
|
|
|
69
|
-
export interface RepeaterProps
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
> {}
|
|
69
|
+
export interface RepeaterProps extends Omit<
|
|
70
|
+
Merge<RepeaterBaseProps, RepeaterDecoratorProps>,
|
|
71
|
+
"componentRef"
|
|
72
|
+
> {}
|
|
74
73
|
/**
|
|
75
74
|
* A stateless component that stamps out copies of `childComponent` .
|
|
76
75
|
*/
|
package/Scroller/Scroller.d.ts
CHANGED
|
@@ -22,7 +22,15 @@ export interface ScrollerBasicProps {
|
|
|
22
22
|
|
|
23
23
|
export class ScrollerBasic extends React.Component<
|
|
24
24
|
Merge<React.HTMLProps<HTMLElement>, ScrollerBasicProps>
|
|
25
|
-
> {
|
|
25
|
+
> {
|
|
26
|
+
/**
|
|
27
|
+
* Programmatically animates the native scroll position of `node` toward the target `left` / `top`
|
|
28
|
+
offsets using `requestAnimationFrame` . It computes the scroll direction on each axis, then repeatedly
|
|
29
|
+
calls `scrollBy` in small 18px steps (instant behavior) until the target is reached or a scroll bound
|
|
30
|
+
is hit. Used as a Chrome fallback when repeating a smooth scroll.
|
|
31
|
+
*/
|
|
32
|
+
animateScroll(any, any, any): void;
|
|
33
|
+
}
|
|
26
34
|
|
|
27
35
|
export interface ScrollerProps extends ScrollerBasicProps {
|
|
28
36
|
/**
|
|
@@ -18,6 +18,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
18
18
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
19
19
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
20
20
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
21
|
+
function _readOnlyError(r) { throw new TypeError('"' + r + '" is read-only'); }
|
|
21
22
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
22
23
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
23
24
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
@@ -45,6 +46,7 @@ var ScrollerBasic = exports.ScrollerBasic = /*#__PURE__*/function (_Component) {
|
|
|
45
46
|
args[_key] = arguments[_key];
|
|
46
47
|
}
|
|
47
48
|
_this = _callSuper(this, ScrollerBasic, [].concat(args));
|
|
49
|
+
_this.scrollAnimationId = null;
|
|
48
50
|
_this.scrollBounds = {
|
|
49
51
|
clientWidth: 0,
|
|
50
52
|
clientHeight: 0,
|
|
@@ -143,12 +145,51 @@ var ScrollerBasic = exports.ScrollerBasic = /*#__PURE__*/function (_Component) {
|
|
|
143
145
|
// scrollMode 'native'
|
|
144
146
|
}, {
|
|
145
147
|
key: "scrollToPosition",
|
|
146
|
-
value: function scrollToPosition(left, top, behavior) {
|
|
147
|
-
this.props.scrollContentRef.current
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
148
|
+
value: function scrollToPosition(left, top, behavior, repeat) {
|
|
149
|
+
var node = this.props.scrollContentRef.current;
|
|
150
|
+
var smoothBehavior = behavior === 'smooth';
|
|
151
|
+
if (_platform.platform.chrome && smoothBehavior && repeat) {
|
|
152
|
+
this.animateScroll(this.getRtlPositionX(left), top, node);
|
|
153
|
+
} else {
|
|
154
|
+
node.scrollTo({
|
|
155
|
+
left: this.getRtlPositionX(left),
|
|
156
|
+
top: top,
|
|
157
|
+
behavior: behavior
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Programmatically animates the native scroll position of `node` toward the target `left`/`top`
|
|
164
|
+
* offsets using `requestAnimationFrame`. It computes the scroll direction on each axis, then repeatedly
|
|
165
|
+
* calls `scrollBy` in small 18px steps (instant behavior) until the target is reached or a scroll bound
|
|
166
|
+
* is hit. Used as a Chrome fallback when repeating a smooth scroll.
|
|
167
|
+
*/
|
|
168
|
+
}, {
|
|
169
|
+
key: "animateScroll",
|
|
170
|
+
value: function _animateScroll(left, top, node) {
|
|
171
|
+
var _this3 = this;
|
|
172
|
+
var directionX = Math.sign(left - node.scrollLeft);
|
|
173
|
+
var directionY = Math.sign(top - node.scrollTop);
|
|
174
|
+
var _animateScroll = function animateScroll() {
|
|
175
|
+
var scrollLeft = directionX > 0 ? node.scrollLeft < left : node.scrollLeft > left;
|
|
176
|
+
var scrollTop = directionY > 0 ? node.scrollTop < top : node.scrollTop > top;
|
|
177
|
+
|
|
178
|
+
// Check if we reached the scroll bounds and cancel the animation
|
|
179
|
+
if (top > _this3.scrollBounds.maxTop && node.scrollTop === _this3.scrollBounds.maxTop || left > _this3.scrollBounds.maxLeft && node.scrollLeft === _this3.scrollBounds.maxLeft || top < 0 && node.scrollTop === 0 || left < 0 && node.scrollLeft === 0) {
|
|
180
|
+
window.cancelAnimationFrame(_this3.scrollAnimationId);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (scrollTop || scrollLeft) {
|
|
184
|
+
node.scrollBy({
|
|
185
|
+
top: directionY * 8,
|
|
186
|
+
left: directionX * 8,
|
|
187
|
+
behavior: 'instant'
|
|
188
|
+
});
|
|
189
|
+
_this3.scrollAnimationId = window.requestAnimationFrame(_animateScroll);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
this.scrollAnimationId = window.requestAnimationFrame(_animateScroll);
|
|
152
193
|
}
|
|
153
194
|
|
|
154
195
|
// scrollMode 'native'
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
|
+
var _Scroller = require("../Scroller");
|
|
5
|
+
describe('ScrollBasic', function () {
|
|
6
|
+
var scrollContentRef;
|
|
7
|
+
beforeEach(function () {
|
|
8
|
+
jest.createMockFromModule('@enact/core/platform');
|
|
9
|
+
scrollContentRef = {
|
|
10
|
+
current: {
|
|
11
|
+
scrollLeft: 0,
|
|
12
|
+
scrollTop: 0,
|
|
13
|
+
scrollBy: jest.fn(),
|
|
14
|
+
scrollTo: jest.fn()
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
afterEach(function () {
|
|
19
|
+
jest.clearAllMocks();
|
|
20
|
+
});
|
|
21
|
+
test('should call scrollBy on scrollToPosition', function () {
|
|
22
|
+
var instance = new _Scroller.ScrollerBasic({
|
|
23
|
+
scrollContentRef: scrollContentRef,
|
|
24
|
+
direction: 'both'
|
|
25
|
+
});
|
|
26
|
+
instance.scrollToPosition(100, 200, 'smooth');
|
|
27
|
+
expect(scrollContentRef.current.scrollTo).toHaveBeenCalledWith({
|
|
28
|
+
left: 100,
|
|
29
|
+
top: 200,
|
|
30
|
+
behavior: 'smooth'
|
|
31
|
+
});
|
|
32
|
+
instance.scrollToPosition(100, 200, 'instant');
|
|
33
|
+
expect(scrollContentRef.current.scrollTo).toHaveBeenCalledWith({
|
|
34
|
+
left: 100,
|
|
35
|
+
top: 200,
|
|
36
|
+
behavior: 'instant'
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
test('should call scrollBy with animated values during animateScroll', function () {
|
|
40
|
+
var rafCallback;
|
|
41
|
+
var instance = new _Scroller.ScrollerBasic({
|
|
42
|
+
scrollContentRef: scrollContentRef,
|
|
43
|
+
direction: 'both'
|
|
44
|
+
});
|
|
45
|
+
instance.scrollBounds.maxTop = 500;
|
|
46
|
+
instance.scrollBounds.maxLeft = 500;
|
|
47
|
+
window.requestAnimationFrame = jest.fn(function (cb) {
|
|
48
|
+
rafCallback = cb;
|
|
49
|
+
});
|
|
50
|
+
window.cancelAnimationFrame = jest.fn();
|
|
51
|
+
instance.animateScroll(100, 200, scrollContentRef.current);
|
|
52
|
+
rafCallback();
|
|
53
|
+
expect(scrollContentRef.current.scrollBy).toHaveBeenCalled();
|
|
54
|
+
scrollContentRef.current.scrollTop = 500;
|
|
55
|
+
instance.animateScroll(550, 550, scrollContentRef.current);
|
|
56
|
+
rafCallback();
|
|
57
|
+
expect(window.cancelAnimationFrame).toHaveBeenCalled();
|
|
58
|
+
});
|
|
59
|
+
});
|
package/Slider/Slider.d.ts
CHANGED
|
@@ -182,14 +182,18 @@ export class SliderBase extends React.Component<
|
|
|
182
182
|
Merge<React.HTMLProps<HTMLElement>, SliderBaseProps>
|
|
183
183
|
> {}
|
|
184
184
|
|
|
185
|
-
export interface SliderDecoratorProps
|
|
186
|
-
|
|
185
|
+
export interface SliderDecoratorProps extends Merge<
|
|
186
|
+
ui_Changeable_ChangeableProps,
|
|
187
|
+
ui_Touchable_TouchableProps
|
|
188
|
+
> {}
|
|
187
189
|
export function SliderDecorator<P>(
|
|
188
190
|
Component: React.ComponentType<P> | string,
|
|
189
191
|
): React.ComponentType<P & SliderDecoratorProps>;
|
|
190
192
|
|
|
191
|
-
export interface SliderProps
|
|
192
|
-
|
|
193
|
+
export interface SliderProps extends Omit<
|
|
194
|
+
Merge<SliderBaseProps, SliderDecoratorProps>,
|
|
195
|
+
"componentRef"
|
|
196
|
+
> {
|
|
193
197
|
/**
|
|
194
198
|
* Called when the value is changed.
|
|
195
199
|
*/
|
package/Spinner/Spinner.d.ts
CHANGED
|
@@ -79,11 +79,10 @@ export function SpinnerDecorator<P>(
|
|
|
79
79
|
Component: React.ComponentType<P> | string,
|
|
80
80
|
): React.ComponentType<P & SpinnerDecoratorProps>;
|
|
81
81
|
|
|
82
|
-
export interface SpinnerProps
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
> {}
|
|
82
|
+
export interface SpinnerProps extends Omit<
|
|
83
|
+
Merge<SpinnerBaseProps, SpinnerDecoratorProps>,
|
|
84
|
+
"componentRef"
|
|
85
|
+
> {}
|
|
87
86
|
/**
|
|
88
87
|
* A minimally styled component that controls `Spinner` positioning and interaction states.
|
|
89
88
|
*/
|
|
@@ -55,11 +55,10 @@ export class ToggleIconBase extends React.Component<
|
|
|
55
55
|
Merge<React.HTMLProps<HTMLElement>, ToggleIconBaseProps>
|
|
56
56
|
> {}
|
|
57
57
|
|
|
58
|
-
export interface ToggleIconDecoratorProps
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
> {}
|
|
58
|
+
export interface ToggleIconDecoratorProps extends Merge<
|
|
59
|
+
Merge<ui_ForwardRef_ForwardRefProps, ui_Toggleable_ToggleableProps>,
|
|
60
|
+
ui_Touchable_TouchableProps
|
|
61
|
+
> {}
|
|
63
62
|
/**
|
|
64
63
|
* Adds support for the `onToggle` prop callback to be fired when the `onTap` (touch-safe `onClick` )
|
|
65
64
|
event executes.
|
|
@@ -69,11 +68,10 @@ export class ToggleIconDecorator extends React.Component<
|
|
|
69
68
|
Merge<React.HTMLProps<HTMLElement>, ToggleIconDecoratorProps>
|
|
70
69
|
> {}
|
|
71
70
|
|
|
72
|
-
export interface ToggleIconProps
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
> {
|
|
71
|
+
export interface ToggleIconProps extends Omit<
|
|
72
|
+
Merge<ToggleIconBaseProps, ToggleIconDecoratorProps>,
|
|
73
|
+
"componentRef"
|
|
74
|
+
> {
|
|
77
75
|
/**
|
|
78
76
|
* The handler to run when the component is toggled.
|
|
79
77
|
*/
|
|
@@ -137,14 +137,14 @@ export interface Arranger {
|
|
|
137
137
|
* Returns an array of keyframes describing the animation when
|
|
138
138
|
a view is entering the viewport.
|
|
139
139
|
*/
|
|
140
|
-
enter: ArrangerCallback /**
|
|
140
|
+
enter: ArrangerCallback; /**
|
|
141
141
|
* Returns an array of keyframes describing the animation when
|
|
142
142
|
a view is leaving the viewport.
|
|
143
|
-
|
|
144
|
-
leave: ArrangerCallback /**
|
|
143
|
+
*/
|
|
144
|
+
leave: ArrangerCallback; /**
|
|
145
145
|
* Returns an array of keyframes describing the animation when
|
|
146
146
|
a view is remaining in the viewport.
|
|
147
|
-
|
|
147
|
+
*/
|
|
148
148
|
stay?: ArrangerCallback;
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
@@ -168,17 +168,15 @@ export declare const SlideTopArranger: Arranger;
|
|
|
168
168
|
*/
|
|
169
169
|
export declare const SlideBottomArranger: Arranger;
|
|
170
170
|
|
|
171
|
-
export interface ViewManagerDecoratorProps
|
|
172
|
-
extends ui_ForwardRef_ForwardRefProps {}
|
|
171
|
+
export interface ViewManagerDecoratorProps extends ui_ForwardRef_ForwardRefProps {}
|
|
173
172
|
export function ViewManagerDecorator<P>(
|
|
174
173
|
Component: React.ComponentType<P> | string,
|
|
175
174
|
): React.ComponentType<P & ViewManagerDecoratorProps>;
|
|
176
175
|
|
|
177
|
-
export interface ViewManagerProps
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
> {}
|
|
176
|
+
export interface ViewManagerProps extends Omit<
|
|
177
|
+
Merge<ViewManagerBaseProps, ViewManagerDecoratorProps>,
|
|
178
|
+
"componentRef"
|
|
179
|
+
> {}
|
|
182
180
|
/**
|
|
183
181
|
* A `ViewManager` controls the visibility of a configurable number of views, allowing for them to be
|
|
184
182
|
transitioned on and off the viewport.
|
|
@@ -13,9 +13,9 @@ export interface gridListItemSizeShape {
|
|
|
13
13
|
/**
|
|
14
14
|
* The minimum width of the grid list item.
|
|
15
15
|
*/
|
|
16
|
-
minWidth: number /**
|
|
16
|
+
minWidth: number; /**
|
|
17
17
|
* The minimum height of the grid list item.
|
|
18
|
-
|
|
18
|
+
*/
|
|
19
19
|
minHeight: number;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
@@ -26,9 +26,9 @@ export interface itemSizesShape {
|
|
|
26
26
|
/**
|
|
27
27
|
* The minimum size of the list item.
|
|
28
28
|
*/
|
|
29
|
-
minSize: number /**
|
|
29
|
+
minSize: number; /**
|
|
30
30
|
* An array of the list item size. If it is not defined, the list items will render with the `minSize` size.
|
|
31
|
-
|
|
31
|
+
*/
|
|
32
32
|
size: number[];
|
|
33
33
|
}
|
|
34
34
|
export interface VirtualListProps extends VirtualListBasicProps {
|
|
@@ -104,16 +104,22 @@ var VirtualListBasic = exports.VirtualListBasic = /*#__PURE__*/function (_Compon
|
|
|
104
104
|
_this.isItemSized = false;
|
|
105
105
|
_this.shouldUpdateBounds = false;
|
|
106
106
|
_this.dimensionToExtent = 0;
|
|
107
|
+
_this.itemMarginLeft = null;
|
|
108
|
+
_this.itemMarginRight = null;
|
|
109
|
+
_this.itemMarginTop = null;
|
|
110
|
+
_this.itemMarginBottom = null;
|
|
107
111
|
_this.threshold = 0;
|
|
108
112
|
_this.maxFirstIndex = 0;
|
|
109
113
|
_this.curDataSize = 0;
|
|
110
114
|
_this.hasDataSizeChanged = false;
|
|
111
115
|
_this.cc = [];
|
|
112
116
|
_this.scrollPosition = 0;
|
|
117
|
+
_this.prevScrollPosition = 0;
|
|
113
118
|
_this.scrollPositionTarget = 0;
|
|
114
119
|
_this.scrollToPositionTarget = -1;
|
|
115
120
|
// For individually sized item
|
|
116
121
|
_this.itemPositions = [];
|
|
122
|
+
_this.prevItemPositions = [];
|
|
117
123
|
_this.indexToScrollIntoView = -1;
|
|
118
124
|
_this.updateScrollPosition = function (_ref, behavior) {
|
|
119
125
|
var x = _ref.x,
|
|
@@ -165,18 +171,19 @@ var VirtualListBasic = exports.VirtualListBasic = /*#__PURE__*/function (_Compon
|
|
|
165
171
|
var maxPos = isPrimaryDirectionVertical ? scrollBounds.maxTop : scrollBounds.maxLeft;
|
|
166
172
|
var position = _this.getGridPosition(index);
|
|
167
173
|
var offset = 0;
|
|
174
|
+
var marginOffset = isPrimaryDirectionVertical ? _this.itemMarginTop + _this.itemMarginBottom : _this.itemMarginLeft + _this.itemMarginRight;
|
|
168
175
|
if (stickTo === 'start') {
|
|
169
176
|
// 'start'
|
|
170
177
|
offset = optionalOffset;
|
|
171
178
|
} else if (_this.props.itemSizes) {
|
|
172
179
|
// 'end' for different item sizes
|
|
173
|
-
offset = primary.clientSize - _this.props.itemSizes[index] - optionalOffset;
|
|
180
|
+
offset = primary.clientSize - _this.props.itemSizes[index] - marginOffset - optionalOffset;
|
|
174
181
|
} else if (stickTo === 'center') {
|
|
175
182
|
// 'center'
|
|
176
183
|
offset = primary.clientSize / 2 - primary.gridSize / 2 - optionalOffset;
|
|
177
184
|
} else {
|
|
178
185
|
// 'end' for same item sizes
|
|
179
|
-
offset = primary.clientSize - primary.itemSize - optionalOffset;
|
|
186
|
+
offset = primary.clientSize - primary.itemSize - marginOffset - optionalOffset;
|
|
180
187
|
}
|
|
181
188
|
|
|
182
189
|
/* istanbul ignore next */
|
|
@@ -387,6 +394,16 @@ var VirtualListBasic = exports.VirtualListBasic = /*#__PURE__*/function (_Compon
|
|
|
387
394
|
}, {
|
|
388
395
|
key: "componentDidUpdate",
|
|
389
396
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
397
|
+
var items = document.getElementsByClassName(_VirtualListModule["default"].listItem);
|
|
398
|
+
if (!this.itemMarginTop && this.itemMarginTop !== 0 && items.length > 0) {
|
|
399
|
+
var firstItemStyle = window.getComputedStyle(items[0].children[0]);
|
|
400
|
+
this.itemMarginTop = Number(firstItemStyle.getPropertyValue('margin-top').slice(0, -2));
|
|
401
|
+
this.itemMarginBottom = Number(firstItemStyle.getPropertyValue('margin-bottom').slice(0, -2));
|
|
402
|
+
this.itemMarginLeft = Number(firstItemStyle.getPropertyValue('margin-left').slice(0, -2));
|
|
403
|
+
this.itemMarginRight = Number(firstItemStyle.getPropertyValue('margin-right').slice(0, -2));
|
|
404
|
+
}
|
|
405
|
+
this.scrollBounds.maxTop += this.itemMarginTop + this.itemMarginBottom;
|
|
406
|
+
this.scrollBounds.maxLeft += this.itemMarginLeft + this.itemMarginRight;
|
|
390
407
|
var deferScrollTo = false;
|
|
391
408
|
var _this$state = this.state,
|
|
392
409
|
firstIndex = _this$state.firstIndex,
|
|
@@ -442,17 +459,42 @@ var VirtualListBasic = exports.VirtualListBasic = /*#__PURE__*/function (_Compon
|
|
|
442
459
|
}
|
|
443
460
|
}
|
|
444
461
|
if (prevProps.direction !== this.props.direction || prevProps.overhang !== this.props.overhang || prevProps.spacing !== this.props.spacing || !(0, _equals["default"])(prevProps.itemSize, this.props.itemSize) || !this.hasDataSizeChanged && !(0, _util.shallowEqual)(prevProps.itemSizes, this.props.itemSizes)) {
|
|
445
|
-
var _this$getXY = this.getXY(this.scrollPosition, 0),
|
|
446
|
-
x = _this$getXY.x,
|
|
447
|
-
y = _this$getXY.y;
|
|
448
|
-
this.calculateMetrics(this.props);
|
|
449
|
-
this.setState(this.getStatesAndUpdateBounds(this.props));
|
|
450
|
-
this.setContainerSize();
|
|
451
462
|
var _this$scrollBounds = this.scrollBounds,
|
|
452
463
|
clientHeight = _this$scrollBounds.clientHeight,
|
|
453
464
|
clientWidth = _this$scrollBounds.clientWidth,
|
|
454
465
|
scrollHeight = _this$scrollBounds.scrollHeight,
|
|
455
466
|
scrollWidth = _this$scrollBounds.scrollWidth;
|
|
467
|
+
|
|
468
|
+
/* istanbul ignore next */
|
|
469
|
+
if (this.scrollPosition === 0 && this.moreInfo.firstVisibleIndex !== 0) {
|
|
470
|
+
this.scrollPosition = this.prevScrollPosition;
|
|
471
|
+
this.setState({
|
|
472
|
+
firstIndex: prevState.firstIndex
|
|
473
|
+
});
|
|
474
|
+
this.updateMoreInfo(this.props.dataSize, this.scrollPosition);
|
|
475
|
+
for (var i = prevState.firstIndex; i < prevState.firstIndex + this.state.numOfItems; i++) {
|
|
476
|
+
var _this$itemPositions, _this$prevItemPositio, _this$itemPositions2, _this$prevItemPositio2;
|
|
477
|
+
var size = this.isPrimaryDirectionVertical ? clientHeight : clientWidth;
|
|
478
|
+
if (((_this$itemPositions = this.itemPositions[i + 1]) === null || _this$itemPositions === void 0 ? void 0 : _this$itemPositions.position) > ((_this$prevItemPositio = this.prevItemPositions[i + 1]) === null || _this$prevItemPositio === void 0 ? void 0 : _this$prevItemPositio.position)) {
|
|
479
|
+
if (i === this.moreInfo.lastVisibleIndex && this.getItemBottomPosition(i) > this.scrollPosition + size) {
|
|
480
|
+
this.scrollPosition = this.getItemBottomPosition(i) - size;
|
|
481
|
+
}
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
if (((_this$itemPositions2 = this.itemPositions[i + 1]) === null || _this$itemPositions2 === void 0 ? void 0 : _this$itemPositions2.position) < ((_this$prevItemPositio2 = this.prevItemPositions[i + 1]) === null || _this$prevItemPositio2 === void 0 ? void 0 : _this$prevItemPositio2.position)) {
|
|
485
|
+
if (this.itemPositions[i].position < this.scrollPosition) {
|
|
486
|
+
this.scrollPosition = this.itemPositions[i].position;
|
|
487
|
+
}
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
var _this$getXY = this.getXY(this.scrollPosition, 0),
|
|
493
|
+
x = _this$getXY.x,
|
|
494
|
+
y = _this$getXY.y;
|
|
495
|
+
this.calculateMetrics(this.props);
|
|
496
|
+
this.setState(this.getStatesAndUpdateBounds(this.props, prevState.firstIndex ? prevState.firstIndex : 0));
|
|
497
|
+
this.setContainerSize();
|
|
456
498
|
var xMax = scrollWidth - clientWidth;
|
|
457
499
|
var yMax = scrollHeight - clientHeight;
|
|
458
500
|
this.updateScrollPosition({
|
|
@@ -591,6 +633,10 @@ var VirtualListBasic = exports.VirtualListBasic = /*#__PURE__*/function (_Compon
|
|
|
591
633
|
this.secondary = secondary;
|
|
592
634
|
|
|
593
635
|
// reset
|
|
636
|
+
this.prevScrollPosition = this.scrollPosition;
|
|
637
|
+
for (var i = 0; i < this.itemPositions.length; i++) {
|
|
638
|
+
this.prevItemPositions[i] = this.itemPositions[i];
|
|
639
|
+
}
|
|
594
640
|
this.scrollPosition = 0;
|
|
595
641
|
this.scrollToPositionTarget = -1;
|
|
596
642
|
if (scrollMode === 'translate' && this.contentRef.current) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enact/ui",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.2",
|
|
4
4
|
"description": "A collection of simplified unstyled cross-platform UI components for Enact",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@enact/core": "^5.4.
|
|
36
|
-
"@enact/i18n": "^5.4.
|
|
35
|
+
"@enact/core": "^5.4.2",
|
|
36
|
+
"@enact/i18n": "^5.4.2",
|
|
37
37
|
"classnames": "^2.5.1",
|
|
38
38
|
"ilib": "^14.21.2",
|
|
39
39
|
"invariant": "^2.2.4",
|
|
40
40
|
"prop-types": "^15.8.1",
|
|
41
|
-
"ramda": "^0.
|
|
42
|
-
"react": "^19.2.
|
|
43
|
-
"react-dom": "^19.2.
|
|
44
|
-
"react-is": "^19.2.
|
|
41
|
+
"ramda": "^0.32.0",
|
|
42
|
+
"react": "^19.2.3",
|
|
43
|
+
"react-dom": "^19.2.3",
|
|
44
|
+
"react-is": "^19.2.3",
|
|
45
45
|
"warning": "^4.0.3"
|
|
46
46
|
}
|
|
47
47
|
}
|
package/resolution/index.d.ts
CHANGED
|
@@ -147,12 +147,12 @@ export interface selectSrcOptions {
|
|
|
147
147
|
/**
|
|
148
148
|
* HD / 720p Resolution image asset source URI/URL
|
|
149
149
|
*/
|
|
150
|
-
hd?: string /**
|
|
150
|
+
hd?: string; /**
|
|
151
151
|
* FHD / 1080p Resolution image asset source URI/URL
|
|
152
|
-
|
|
153
|
-
fhd?: string /**
|
|
152
|
+
*/
|
|
153
|
+
fhd?: string; /**
|
|
154
154
|
* UHD / 4K Resolution image asset source URI/URL
|
|
155
|
-
|
|
155
|
+
*/
|
|
156
156
|
uhd?: string;
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
@@ -1,20 +1,266 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("@testing-library/jest-dom");
|
|
4
|
+
var _react = require("@testing-library/react");
|
|
5
|
+
var _useScroll = require("../useScroll");
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
9
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
10
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
11
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
13
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
+
// Mock all dependencies at the top level BEFORE importing useScroll
|
|
15
|
+
var mockRiScale;
|
|
16
|
+
var mockPlatform;
|
|
17
|
+
jest.mock('../../resolution', function () {
|
|
18
|
+
return {
|
|
19
|
+
__esModule: true,
|
|
20
|
+
"default": {
|
|
21
|
+
get scale() {
|
|
22
|
+
return mockRiScale || function (val) {
|
|
23
|
+
return val;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
jest.mock('@enact/core/platform', function () {
|
|
30
|
+
return {
|
|
31
|
+
__esModule: true,
|
|
32
|
+
get platform() {
|
|
33
|
+
return mockPlatform || {
|
|
34
|
+
chrome: 120
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
global.ResizeObserver = /*#__PURE__*/function () {
|
|
40
|
+
function ResizeObserver() {
|
|
41
|
+
_classCallCheck(this, ResizeObserver);
|
|
42
|
+
}
|
|
43
|
+
return _createClass(ResizeObserver, [{
|
|
44
|
+
key: "observe",
|
|
45
|
+
value: function observe() {}
|
|
46
|
+
}, {
|
|
47
|
+
key: "unobserve",
|
|
48
|
+
value: function unobserve() {}
|
|
49
|
+
}, {
|
|
50
|
+
key: "disconnect",
|
|
51
|
+
value: function disconnect() {}
|
|
52
|
+
}]);
|
|
53
|
+
}();
|
|
54
|
+
|
|
55
|
+
// Import AFTER all mocks
|
|
56
|
+
|
|
57
|
+
// Helper function to create complete mock refs
|
|
58
|
+
function createMockRefs() {
|
|
59
|
+
return {
|
|
60
|
+
scrollContentHandle: {
|
|
61
|
+
current: {
|
|
62
|
+
getScrollBounds: jest.fn(function () {
|
|
63
|
+
return {
|
|
64
|
+
clientWidth: 1920,
|
|
65
|
+
clientHeight: 1080,
|
|
66
|
+
scrollWidth: 1000,
|
|
67
|
+
scrollHeight: 800,
|
|
68
|
+
maxTop: 200,
|
|
69
|
+
maxLeft: 200
|
|
70
|
+
};
|
|
71
|
+
}),
|
|
72
|
+
getMoreInfo: jest.fn(function () {
|
|
73
|
+
return {};
|
|
74
|
+
}),
|
|
75
|
+
hasDataSizeChanged: false,
|
|
76
|
+
syncClientSize: jest.fn(function () {
|
|
77
|
+
return false;
|
|
78
|
+
}),
|
|
79
|
+
getRtlPositionX: jest.fn(function (x) {
|
|
80
|
+
return x;
|
|
81
|
+
}),
|
|
82
|
+
calculateMetrics: jest.fn(),
|
|
83
|
+
props: {}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
scrollContainerRef: {
|
|
87
|
+
current: document.createElement('div')
|
|
88
|
+
},
|
|
89
|
+
scrollContentRef: {
|
|
90
|
+
current: document.createElement('div')
|
|
91
|
+
},
|
|
92
|
+
horizontalScrollbarHandle: {
|
|
93
|
+
current: {
|
|
94
|
+
update: jest.fn(),
|
|
95
|
+
getContainerRef: jest.fn(function () {
|
|
96
|
+
return document.createElement('div');
|
|
97
|
+
}),
|
|
98
|
+
startHidingScrollbarTrack: jest.fn()
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
verticalScrollbarHandle: {
|
|
102
|
+
current: {
|
|
103
|
+
update: jest.fn(),
|
|
104
|
+
getContainerRef: jest.fn(function () {
|
|
105
|
+
return document.createElement('div');
|
|
106
|
+
}),
|
|
107
|
+
startHidingScrollbarTrack: jest.fn()
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
4
112
|
describe('useScroll', function () {
|
|
113
|
+
describe('riRatio itemSize scaling on window resize', function () {
|
|
114
|
+
beforeEach(function () {
|
|
115
|
+
jest.useFakeTimers();
|
|
116
|
+
mockPlatform = {
|
|
117
|
+
chrome: 132
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
afterEach(function () {
|
|
121
|
+
jest.runOnlyPendingTimers();
|
|
122
|
+
jest.useRealTimers();
|
|
123
|
+
});
|
|
124
|
+
test('should scale itemSize when ri.scale(1) changes from 1 to 2', function () {
|
|
125
|
+
mockRiScale = jest.fn(function (val) {
|
|
126
|
+
return val;
|
|
127
|
+
});
|
|
128
|
+
var itemSize = {
|
|
129
|
+
minWidth: 100,
|
|
130
|
+
minHeight: 50
|
|
131
|
+
};
|
|
132
|
+
var mocks = createMockRefs();
|
|
133
|
+
var props = _objectSpread(_objectSpread({
|
|
134
|
+
itemRenderer: jest.fn(),
|
|
135
|
+
itemSize: itemSize,
|
|
136
|
+
direction: 'vertical',
|
|
137
|
+
scrollMode: 'translate'
|
|
138
|
+
}, mocks), {}, {
|
|
139
|
+
assignProperties: jest.fn(),
|
|
140
|
+
horizontalScrollbar: 'auto',
|
|
141
|
+
verticalScrollbar: 'auto'
|
|
142
|
+
});
|
|
143
|
+
(0, _react.renderHook)(function () {
|
|
144
|
+
return (0, _useScroll.useScrollBase)(props);
|
|
145
|
+
});
|
|
146
|
+
mockRiScale = jest.fn(function () {
|
|
147
|
+
return 2;
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// eslint-disable-next-line testing-library/no-unnecessary-act
|
|
151
|
+
(0, _react.act)(function () {
|
|
152
|
+
(0, _react.fireEvent)(window, new Event('resize'));
|
|
153
|
+
jest.runAllTimers();
|
|
154
|
+
});
|
|
155
|
+
expect(itemSize.minWidth).toBe(200);
|
|
156
|
+
expect(itemSize.minHeight).toBe(100);
|
|
157
|
+
});
|
|
158
|
+
test('should NOT scale when ri.scale(1) remains unchanged', function () {
|
|
159
|
+
mockRiScale = jest.fn(function (val) {
|
|
160
|
+
return val;
|
|
161
|
+
});
|
|
162
|
+
var itemSize = {
|
|
163
|
+
minWidth: 100,
|
|
164
|
+
minHeight: 50
|
|
165
|
+
};
|
|
166
|
+
var mocks = createMockRefs();
|
|
167
|
+
var props = _objectSpread(_objectSpread({
|
|
168
|
+
itemRenderer: jest.fn(),
|
|
169
|
+
itemSize: itemSize,
|
|
170
|
+
direction: 'vertical',
|
|
171
|
+
scrollMode: 'translate'
|
|
172
|
+
}, mocks), {}, {
|
|
173
|
+
assignProperties: jest.fn(),
|
|
174
|
+
horizontalScrollbar: 'auto',
|
|
175
|
+
verticalScrollbar: 'auto'
|
|
176
|
+
});
|
|
177
|
+
(0, _react.renderHook)(function () {
|
|
178
|
+
return (0, _useScroll.useScrollBase)(props);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// eslint-disable-next-line testing-library/no-unnecessary-act
|
|
182
|
+
(0, _react.act)(function () {
|
|
183
|
+
(0, _react.fireEvent)(window, new Event('resize'));
|
|
184
|
+
jest.runAllTimers();
|
|
185
|
+
});
|
|
186
|
+
expect(itemSize.minWidth).toBe(100);
|
|
187
|
+
expect(itemSize.minHeight).toBe(50);
|
|
188
|
+
});
|
|
189
|
+
test('should NOT scale when minWidth is missing', function () {
|
|
190
|
+
mockRiScale = jest.fn(function (val) {
|
|
191
|
+
return val;
|
|
192
|
+
});
|
|
193
|
+
var itemSize = {
|
|
194
|
+
minHeight: 50
|
|
195
|
+
};
|
|
196
|
+
var mocks = createMockRefs();
|
|
197
|
+
var props = _objectSpread(_objectSpread({
|
|
198
|
+
itemRenderer: jest.fn(),
|
|
199
|
+
itemSize: itemSize,
|
|
200
|
+
direction: 'vertical',
|
|
201
|
+
scrollMode: 'translate'
|
|
202
|
+
}, mocks), {}, {
|
|
203
|
+
assignProperties: jest.fn(),
|
|
204
|
+
horizontalScrollbar: 'auto',
|
|
205
|
+
verticalScrollbar: 'auto'
|
|
206
|
+
});
|
|
207
|
+
(0, _react.renderHook)(function () {
|
|
208
|
+
return (0, _useScroll.useScrollBase)(props);
|
|
209
|
+
});
|
|
210
|
+
mockRiScale = jest.fn(function () {
|
|
211
|
+
return 2;
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// eslint-disable-next-line testing-library/no-unnecessary-act
|
|
215
|
+
(0, _react.act)(function () {
|
|
216
|
+
(0, _react.fireEvent)(window, new Event('resize'));
|
|
217
|
+
jest.runAllTimers();
|
|
218
|
+
});
|
|
219
|
+
expect(itemSize.minHeight).toBe(50);
|
|
220
|
+
expect(itemSize.minWidth).toBeUndefined();
|
|
221
|
+
});
|
|
222
|
+
test('should NOT scale when minHeight is missing', function () {
|
|
223
|
+
mockRiScale = jest.fn(function (val) {
|
|
224
|
+
return val;
|
|
225
|
+
});
|
|
226
|
+
var itemSize = {
|
|
227
|
+
minWidth: 100
|
|
228
|
+
};
|
|
229
|
+
var mocks = createMockRefs();
|
|
230
|
+
var props = _objectSpread(_objectSpread({
|
|
231
|
+
itemRenderer: jest.fn(),
|
|
232
|
+
itemSize: itemSize,
|
|
233
|
+
direction: 'vertical',
|
|
234
|
+
scrollMode: 'translate'
|
|
235
|
+
}, mocks), {}, {
|
|
236
|
+
assignProperties: jest.fn(),
|
|
237
|
+
horizontalScrollbar: 'auto',
|
|
238
|
+
verticalScrollbar: 'auto'
|
|
239
|
+
});
|
|
240
|
+
(0, _react.renderHook)(function () {
|
|
241
|
+
return (0, _useScroll.useScrollBase)(props);
|
|
242
|
+
});
|
|
243
|
+
mockRiScale = jest.fn(function () {
|
|
244
|
+
return 2;
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
// eslint-disable-next-line testing-library/no-unnecessary-act
|
|
248
|
+
(0, _react.act)(function () {
|
|
249
|
+
(0, _react.fireEvent)(window, new Event('resize'));
|
|
250
|
+
jest.runAllTimers();
|
|
251
|
+
});
|
|
252
|
+
expect(itemSize.minWidth).toBe(100);
|
|
253
|
+
expect(itemSize.minHeight).toBeUndefined();
|
|
254
|
+
});
|
|
255
|
+
});
|
|
5
256
|
describe('Rounding target scroll position', function () {
|
|
6
257
|
beforeEach(function () {
|
|
7
258
|
jest.resetModules(); // important! clears cached modules
|
|
8
259
|
});
|
|
9
260
|
test('should round target position upwards when target is bigger than current position', function () {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
platform: {
|
|
14
|
-
chrome: 132
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
});
|
|
261
|
+
mockPlatform = {
|
|
262
|
+
chrome: 132
|
|
263
|
+
};
|
|
18
264
|
var _require = require('../useScroll'),
|
|
19
265
|
roundTarget = _require.roundTarget;
|
|
20
266
|
var currentPosition = {
|
|
@@ -29,15 +275,10 @@ describe('useScroll', function () {
|
|
|
29
275
|
expect(roundedTargetX).toEqual(121);
|
|
30
276
|
expect(roundedTargetY).toEqual(121);
|
|
31
277
|
});
|
|
32
|
-
test('should round target position downwards when target is
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
platform: {
|
|
37
|
-
chrome: 132
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
});
|
|
278
|
+
test('should round target position downwards when target is bi than current position', function () {
|
|
279
|
+
mockPlatform = {
|
|
280
|
+
chrome: 132
|
|
281
|
+
};
|
|
41
282
|
var _require2 = require('../useScroll'),
|
|
42
283
|
roundTarget = _require2.roundTarget;
|
|
43
284
|
var currentPosition = {
|
|
@@ -53,14 +294,9 @@ describe('useScroll', function () {
|
|
|
53
294
|
expect(roundedTargetY).toEqual(80);
|
|
54
295
|
});
|
|
55
296
|
test('should not round target position when chrome <= 120', function () {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
platform: {
|
|
60
|
-
chrome: 119
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
});
|
|
297
|
+
mockPlatform = {
|
|
298
|
+
chrome: 119
|
|
299
|
+
};
|
|
64
300
|
var _require3 = require('../useScroll'),
|
|
65
301
|
roundTarget = _require3.roundTarget;
|
|
66
302
|
var currentPosition = {
|
package/useScroll/useScroll.js
CHANGED
|
@@ -207,6 +207,10 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
207
207
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
208
208
|
isVerticalScrollbarVisible = _useState4[0],
|
|
209
209
|
setIsVerticalScrollbarVisible = _useState4[1];
|
|
210
|
+
var _useState5 = (0, _react.useState)(_resolution["default"].scale(1)),
|
|
211
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
212
|
+
riRatio = _useState6[0],
|
|
213
|
+
setRiRatio = _useState6[1];
|
|
210
214
|
var mutableRef = (0, _react.useRef)({
|
|
211
215
|
overscrollEnabled: !!props.applyOverscrollEffect,
|
|
212
216
|
// Enable the early bail out of repeated scrolling to the same position
|
|
@@ -433,8 +437,31 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
433
437
|
}, [forceUpdate, scrollContentHandle]);
|
|
434
438
|
// scrollMode 'translate' ]]
|
|
435
439
|
|
|
440
|
+
var scrollContentProps = props.itemRenderer ?
|
|
441
|
+
// If the child component is a VirtualList
|
|
442
|
+
{
|
|
443
|
+
childProps: childProps,
|
|
444
|
+
clientSize: clientSize,
|
|
445
|
+
dataSize: dataSize,
|
|
446
|
+
itemRenderer: itemRenderer,
|
|
447
|
+
itemSize: itemSize,
|
|
448
|
+
itemSizes: itemSizes,
|
|
449
|
+
overhang: overhang,
|
|
450
|
+
pageScroll: pageScroll,
|
|
451
|
+
spacing: spacing,
|
|
452
|
+
wrap: wrap
|
|
453
|
+
} : {
|
|
454
|
+
children: children
|
|
455
|
+
};
|
|
436
456
|
function handleResizeWindow() {
|
|
437
457
|
var propsHandleResizeWindow = props.handleResizeWindow;
|
|
458
|
+
if (_resolution["default"].scale(1) !== riRatio) {
|
|
459
|
+
if (scrollContentProps.itemSize.minWidth && scrollContentProps.itemSize.minHeight) {
|
|
460
|
+
scrollContentProps.itemSize.minWidth *= _resolution["default"].scale(1) / riRatio;
|
|
461
|
+
scrollContentProps.itemSize.minHeight *= _resolution["default"].scale(1) / riRatio;
|
|
462
|
+
setRiRatio(_resolution["default"].scale(1));
|
|
463
|
+
}
|
|
464
|
+
}
|
|
438
465
|
|
|
439
466
|
// `handleSize` in `ui/resolution.ResolutionDecorator` should be executed first.
|
|
440
467
|
setTimeout(function () {
|
|
@@ -849,6 +876,8 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
849
876
|
} else {
|
|
850
877
|
var _props$preventScroll;
|
|
851
878
|
(_props$preventScroll = props.preventScroll) === null || _props$preventScroll === void 0 || _props$preventScroll.call(props, ev);
|
|
879
|
+
mutableRef.current.repeat = ev.repeat;
|
|
880
|
+
if (ev.repeat && mutableRef.current.lastInputType === 'arrowKey') return;
|
|
852
881
|
(0, _handle.forward)('onKeyDown', ev, props);
|
|
853
882
|
}
|
|
854
883
|
}
|
|
@@ -1168,7 +1197,7 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
1168
1197
|
roundedTargetX = _roundTarget.roundedTargetX,
|
|
1169
1198
|
roundedTargetY = _roundTarget.roundedTargetY;
|
|
1170
1199
|
if (animate) {
|
|
1171
|
-
scrollContentHandle.current.scrollToPosition(roundedTargetX, roundedTargetY, 'smooth');
|
|
1200
|
+
scrollContentHandle.current.scrollToPosition(roundedTargetX, roundedTargetY, 'smooth', mutableRef.current.repeat);
|
|
1172
1201
|
} else {
|
|
1173
1202
|
scrollContentHandle.current.scrollToPosition(roundedTargetX, roundedTargetY, 'instant');
|
|
1174
1203
|
}
|
|
@@ -1510,22 +1539,6 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
1510
1539
|
onFlick: onFlick,
|
|
1511
1540
|
onTouchStart: scrollMode === 'native' ? onTouchStart : null // scrollMode 'native'
|
|
1512
1541
|
}));
|
|
1513
|
-
var scrollContentProps = props.itemRenderer ?
|
|
1514
|
-
// If the child component is a VirtualList
|
|
1515
|
-
{
|
|
1516
|
-
childProps: childProps,
|
|
1517
|
-
clientSize: clientSize,
|
|
1518
|
-
dataSize: dataSize,
|
|
1519
|
-
itemRenderer: itemRenderer,
|
|
1520
|
-
itemSize: itemSize,
|
|
1521
|
-
itemSizes: itemSizes,
|
|
1522
|
-
overhang: overhang,
|
|
1523
|
-
pageScroll: pageScroll,
|
|
1524
|
-
spacing: spacing,
|
|
1525
|
-
wrap: wrap
|
|
1526
|
-
} : {
|
|
1527
|
-
children: children
|
|
1528
|
-
};
|
|
1529
1542
|
assignProperties('scrollContentProps', _objectSpread(_objectSpread({}, scrollContentProps), {}, {
|
|
1530
1543
|
cbScrollTo: scrollTo,
|
|
1531
1544
|
className: [_useScrollModule["default"].scrollFill],
|