@enact/ui 4.5.2 → 4.6.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 +1 -40
- package/AnnounceDecorator/AnnounceDecorator.js +3 -21
- package/AnnounceDecorator/tests/Announce-specs.js +2 -7
- package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +2 -6
- package/AnnounceDecorator/tests/useAnnounce-specs.js +8 -19
- package/AnnounceDecorator/useAnnounce.js +0 -6
- package/BodyText/BodyText.js +8 -28
- package/BodyText/tests/BodyText-specs.js +0 -19
- package/Button/Button.js +33 -63
- package/Button/tests/Button-specs.js +0 -26
- package/CHANGELOG.md +45 -0
- package/Cancelable/Cancelable.js +8 -47
- package/Cancelable/cancelHandler.js +5 -12
- package/Cancelable/modalHandler.js +3 -11
- package/Cancelable/tests/Cancelable-specs.js +3 -57
- package/Changeable/Changeable.js +2 -34
- package/Changeable/tests/Changeable-specs.js +20 -66
- package/ComponentOverride/ComponentOverride.js +1 -13
- package/FloatingLayer/FloatingLayer.js +17 -73
- package/FloatingLayer/FloatingLayerContainer.js +0 -15
- package/FloatingLayer/FloatingLayerDecorator.js +4 -17
- package/FloatingLayer/Scrim.js +9 -53
- package/FloatingLayer/index.js +0 -4
- package/FloatingLayer/package.json +3 -0
- package/FloatingLayer/tests/FloatingLayer-specs.js +8 -22
- package/FloatingLayer/tests/Scrim-specs.js +0 -9
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +0 -13
- package/FloatingLayer/useFloatingLayer.js +3 -14
- package/FloatingLayer/useFloatingLayerDecorator.js +3 -11
- package/ForwardRef/ForwardRef.js +1 -10
- package/GridListImageItem/GridListImageItem.js +18 -51
- package/Group/Group.js +5 -36
- package/Group/GroupItem.js +16 -33
- package/Group/tests/Group-specs.js +0 -32
- package/Heading/Heading.js +8 -36
- package/Heading/tests/Heading-specs.js +81 -14
- package/Icon/Icon.js +19 -53
- package/Icon/tests/Icon-specs.js +0 -22
- package/IconButton/IconButton.js +24 -57
- package/IconButton/tests/IconButton-specs.js +0 -7
- package/Image/Image.js +17 -46
- package/Image/tests/Image-specs.js +0 -14
- package/ImageItem/ImageItem.js +18 -47
- package/ImageItem/tests/ImageItem-specs.js +0 -25
- package/Item/Item.js +9 -33
- package/Item/tests/Item-specs.js +0 -24
- package/LabeledIcon/LabeledIcon.js +22 -53
- package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
- package/Layout/Cell.js +18 -44
- package/Layout/Layout.js +23 -46
- package/Layout/tests/Layout-specs.js +10 -39
- package/Marquee/MarqueeBase.js +29 -63
- package/Marquee/MarqueeController.js +11 -72
- package/Marquee/MarqueeDecorator.js +70 -196
- package/Marquee/index.js +1 -5
- package/Marquee/tests/Marquee-specs.js +295 -87
- package/Measurable/Measurable.js +12 -34
- package/Measurable/tests/Measurable-specs.js +115 -0
- package/Media/Media.js +15 -65
- package/Media/tests/Media-specs.js +168 -0
- package/Placeholder/PlaceholderControllerDecorator.js +7 -43
- package/Placeholder/PlaceholderDecorator.js +7 -38
- package/Placeholder/index.js +1 -5
- package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +25 -0
- package/Placeholder/tests/PlaceholderDecorator-specs.js +28 -0
- package/ProgressBar/ProgressBar.js +14 -45
- package/ProgressBar/tests/ProgressBar-specs.js +0 -17
- package/RadioDecorator/RadioControllerDecorator.js +7 -29
- package/RadioDecorator/RadioDecorator.js +9 -42
- package/RadioDecorator/tests/RadioDecorator-specs.js +12 -49
- package/Repeater/Repeater.js +9 -33
- package/Repeater/tests/Repeater-specs.js +0 -38
- package/Resizable/Resizable.js +9 -37
- package/Resizable/tests/Resizable-specs.js +34 -0
- package/Routable/Link.js +11 -47
- package/Routable/Routable.js +12 -35
- package/Routable/Route.js +0 -6
- package/Routable/Router.js +15 -58
- package/Routable/tests/Routable-specs.js +7 -33
- package/Routable/tests/Router-specs.js +18 -44
- package/Routable/useLink.js +4 -8
- package/Routable/util.js +18 -24
- package/Scrollable/ScrollAnimator.js +49 -65
- package/Scrollable/ScrollThumb.js +2 -13
- package/Scrollable/Scrollable.js +180 -387
- package/Scrollable/ScrollableNative.js +189 -392
- package/Scrollable/Scrollbar.js +30 -102
- package/Scroller/Scroller.js +15 -39
- package/Scroller/ScrollerBasic.js +34 -89
- package/Scroller/UiScrollerBase.js +37 -84
- package/Scroller/tests/Scroller-specs.js +56 -0
- package/Skinnable/Skinnable.js +11 -38
- package/Skinnable/tests/Skinnable-specs.js +3 -74
- package/Skinnable/tests/useSkins-specs.js +1 -13
- package/Skinnable/tests/util-specs.js +0 -14
- package/Skinnable/useSkins.js +8 -15
- package/Skinnable/util.js +9 -20
- package/Slider/Knob.js +5 -24
- package/Slider/PositionDecorator.js +16 -54
- package/Slider/Slider.js +29 -67
- package/Slider/tests/Slider-specs.js +94 -7
- package/Slider/utils.js +0 -2
- package/SlotItem/SlotItem.js +23 -45
- package/SlotItem/tests/SlotItem-specs.js +0 -5
- package/Slottable/Slottable.js +4 -12
- package/Slottable/tests/Slottable-specs.js +19 -46
- package/Slottable/tests/useSlots-specs.js +27 -65
- package/Slottable/useSlots.js +8 -33
- package/Spinner/Spinner.js +16 -43
- package/Spinner/tests/Spinner-specs.js +0 -15
- package/ToggleIcon/ToggleIcon.js +10 -36
- package/ToggleIcon/tests/ToggleIcon-specs.js +0 -16
- package/ToggleItem/ToggleItem.js +24 -57
- package/ToggleItem/tests/ToggleItem-specs.js +0 -30
- package/Toggleable/Toggle.js +1 -15
- package/Toggleable/Toggleable.js +12 -45
- package/Toggleable/tests/Toggleable-specs.js +28 -96
- package/Toggleable/useToggle.js +3 -19
- package/Touchable/ClickAllow.js +5 -14
- package/Touchable/Drag.js +16 -54
- package/Touchable/Flick.js +11 -42
- package/Touchable/Hold.js +21 -68
- package/Touchable/Pinch.js +185 -0
- package/Touchable/Touch.js +71 -76
- package/Touchable/Touchable.js +95 -75
- package/Touchable/config.js +27 -24
- package/Touchable/tests/Touchable-specs.js +360 -119
- package/Touchable/tests/useTouch-specs.js +6 -80
- package/Touchable/useTouch.js +57 -65
- package/Transition/Transition.js +37 -118
- package/Transition/tests/Transition-specs.js +20 -60
- package/ViewManager/Arranger.js +10 -22
- package/ViewManager/TransitionGroup.js +32 -107
- package/ViewManager/View.js +35 -91
- package/ViewManager/ViewManager.js +20 -84
- package/ViewManager/tests/View-specs.js +0 -17
- package/ViewManager/tests/ViewManager-specs.js +236 -305
- package/ViewManager/tests/test-utils.js +0 -8
- package/VirtualList/UiVirtualListBase.js +265 -409
- package/VirtualList/VirtualList.js +29 -69
- package/VirtualList/VirtualListBase.js +0 -3
- package/VirtualList/VirtualListBasic.js +273 -431
- package/VirtualList/tests/VirtualGridList-native-specs.js +161 -0
- package/VirtualList/tests/VirtualGridList-specs.js +614 -0
- package/VirtualList/tests/VirtualList-native-specs.js +152 -0
- package/VirtualList/tests/VirtualList-specs.js +423 -95
- package/internal/IdProvider/IdProvider.js +7 -21
- package/internal/IdProvider/Provider.js +4 -17
- package/internal/IdProvider/tests/IdProvider-specs.js +44 -0
- package/internal/IdProvider/tests/useId-specs.js +6 -20
- package/internal/IdProvider/useId.js +0 -6
- package/internal/Pure/Pure.js +3 -30
- package/internal/Pure/tests/Pure-specs.js +88 -0
- package/internal/localized-fonts/localized-fonts.js +33 -62
- package/internal/localized-fonts/tests/localized-fonts-specs.js +33 -0
- package/internal/selection/selection.js +1 -6
- package/internal/selection/tests/selection-specs.js +6 -4
- package/internal/validators/tests/validators-specs.js +80 -0
- package/internal/validators/validators.js +14 -34
- package/package.json +9 -3
- package/resolution/ResolutionDecorator.js +4 -40
- package/resolution/index.js +0 -7
- package/resolution/resolution.js +42 -80
- package/resolution/tests/ResolutionDecorator-specs.js +4 -11
- package/resolution/tests/resolution-specs.js +2 -2
- package/useControlledState/tests/useControlledState-specs.js +15 -46
- package/useControlledState/useControlledState.js +11 -22
- package/useScroll/ScrollAnimator.js +49 -65
- package/useScroll/Scrollbar.js +22 -58
- package/useScroll/ScrollbarTrack.js +3 -19
- package/useScroll/useScroll.js +267 -454
- package/useScroll/utilDOM.js +8 -14
- package/useScroll/utilEvent.js +0 -4
- package/AnnounceDecorator/AnnounceDecorator.d.ts +0 -64
- package/BodyText/BodyText.d.ts +0 -66
- package/Button/Button.d.ts +0 -125
- package/Cancelable/Cancelable.d.ts +0 -64
- package/Changeable/Changeable.d.ts +0 -54
- package/ComponentOverride/ComponentOverride.d.ts +0 -52
- package/ForwardRef/ForwardRef.d.ts +0 -22
- package/GridListImageItem/GridListImageItem.d.ts +0 -85
- package/Group/Group.d.ts +0 -107
- package/Heading/Heading.d.ts +0 -90
- package/Icon/Icon.d.ts +0 -88
- package/IconButton/IconButton.d.ts +0 -115
- package/Image/Image.d.ts +0 -113
- package/ImageItem/ImageItem.d.ts +0 -83
- package/Item/Item.d.ts +0 -64
- package/LabeledIcon/LabeledIcon.d.ts +0 -130
- package/Layout/Layout.d.ts +0 -247
- package/Marquee/index.d.ts +0 -258
- package/Measurable/Measurable.d.ts +0 -26
- package/Media/Media.d.ts +0 -99
- package/Placeholder/index.d.ts +0 -53
- package/ProgressBar/ProgressBar.d.ts +0 -92
- package/RadioDecorator/RadioDecorator.d.ts +0 -35
- package/Repeater/Repeater.d.ts +0 -83
- package/Resizable/Resizable.d.ts +0 -31
- package/Routable/Routable.d.ts +0 -148
- package/Scrollable/Scrollable.d.ts +0 -0
- package/Scroller/Scroller.d.ts +0 -276
- package/Skinnable/Skinnable.d.ts +0 -94
- package/Slider/Slider.d.ts +0 -202
- package/SlotItem/SlotItem.d.ts +0 -118
- package/Slottable/Slottable.d.ts +0 -22
- package/Spinner/Spinner.d.ts +0 -95
- package/ToggleIcon/ToggleIcon.d.ts +0 -90
- package/ToggleItem/ToggleItem.d.ts +0 -134
- package/Toggleable/Toggleable.d.ts +0 -103
- package/Touchable/Touchable.d.ts +0 -175
- package/Transition/Transition.d.ts +0 -196
- package/ViewManager/ViewManager.d.ts +0 -191
- package/VirtualList/VirtualList.d.ts +0 -530
- package/index.d.ts +0 -0
- package/internal/IdProvider/IdProvider.d.ts +0 -0
- package/internal/Pure/Pure.d.ts +0 -0
- package/internal/localized-fonts/localized-fonts.d.ts +0 -53
- package/internal/selection/selection.d.ts +0 -0
- package/internal/validators/validators.d.ts +0 -0
- package/resolution/index.d.ts +0 -187
- package/useControlledState/useControlledState.d.ts +0 -0
- package/useScroll/useScroll.d.ts +0 -0
|
@@ -1,42 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _react = require("@testing-library/react");
|
|
4
|
-
|
|
5
4
|
var _config = require("../config");
|
|
6
|
-
|
|
7
5
|
var _useTouch = _interopRequireDefault(require("../useTouch"));
|
|
8
|
-
|
|
9
6
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
-
|
|
11
7
|
var _excluded = ["activeProp", "id"];
|
|
12
|
-
|
|
13
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
-
|
|
15
9
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
-
|
|
17
10
|
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; }
|
|
18
|
-
|
|
19
11
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
20
|
-
|
|
21
12
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
22
|
-
|
|
23
13
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
24
|
-
|
|
25
14
|
describe('useTouch', function () {
|
|
26
15
|
var data;
|
|
27
|
-
|
|
28
16
|
var DivComponent = function DivComponent(props) {
|
|
29
17
|
data = props;
|
|
30
18
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
31
19
|
"data-testid": "component"
|
|
32
20
|
});
|
|
33
21
|
};
|
|
34
|
-
|
|
35
22
|
var TouchableComponent = function TouchableComponent(_ref) {
|
|
36
23
|
var activeProp = _ref.activeProp,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
id = _ref.id,
|
|
25
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
40
26
|
var hook = (0, _useTouch["default"])(_objectSpread({
|
|
41
27
|
getActive: !!activeProp
|
|
42
28
|
}, rest));
|
|
@@ -46,11 +32,9 @@ describe('useTouch', function () {
|
|
|
46
32
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(DivComponent, _objectSpread({}, _defineProperty({}, activeProp, hook.active)))
|
|
47
33
|
}));
|
|
48
34
|
};
|
|
49
|
-
|
|
50
35
|
var preventDefault = function preventDefault(ev) {
|
|
51
36
|
return ev.preventDefault();
|
|
52
37
|
};
|
|
53
|
-
|
|
54
38
|
describe('config', function () {
|
|
55
39
|
beforeEach(_config.resetDefaultConfig);
|
|
56
40
|
afterEach(_config.resetDefaultConfig);
|
|
@@ -76,8 +60,9 @@ describe('useTouch', function () {
|
|
|
76
60
|
flick: {
|
|
77
61
|
notSupported: 10
|
|
78
62
|
}
|
|
79
|
-
});
|
|
63
|
+
});
|
|
80
64
|
|
|
65
|
+
// eslint-disable-next-line no-undefined
|
|
81
66
|
var expected = undefined;
|
|
82
67
|
var actual = (0, _config.getConfig)().flick.notSupported;
|
|
83
68
|
expect(actual).toBe(expected);
|
|
@@ -117,11 +102,8 @@ describe('useTouch', function () {
|
|
|
117
102
|
activeProp: "active",
|
|
118
103
|
onDown: handler
|
|
119
104
|
}));
|
|
120
|
-
|
|
121
105
|
var component = _react.screen.getByTestId('component');
|
|
122
|
-
|
|
123
106
|
_react.fireEvent.mouseDown(component, {});
|
|
124
|
-
|
|
125
107
|
var expected = 1;
|
|
126
108
|
expect(handler).toHaveBeenCalledTimes(expected);
|
|
127
109
|
});
|
|
@@ -133,13 +115,9 @@ describe('useTouch', function () {
|
|
|
133
115
|
activeProp: "active",
|
|
134
116
|
onUp: handler
|
|
135
117
|
}));
|
|
136
|
-
|
|
137
118
|
var component = _react.screen.getByTestId('component');
|
|
138
|
-
|
|
139
119
|
_react.fireEvent.mouseDown(component, {});
|
|
140
|
-
|
|
141
120
|
_react.fireEvent.mouseUp(component, {});
|
|
142
|
-
|
|
143
121
|
var expected = 1;
|
|
144
122
|
expect(handler).toHaveBeenCalledTimes(expected);
|
|
145
123
|
});
|
|
@@ -151,13 +129,9 @@ describe('useTouch', function () {
|
|
|
151
129
|
activeProp: "active",
|
|
152
130
|
onTap: handler
|
|
153
131
|
}));
|
|
154
|
-
|
|
155
132
|
var component = _react.screen.getByTestId('component');
|
|
156
|
-
|
|
157
133
|
_react.fireEvent.mouseDown(component, {});
|
|
158
|
-
|
|
159
134
|
_react.fireEvent.mouseUp(component, {});
|
|
160
|
-
|
|
161
135
|
var expected = 1;
|
|
162
136
|
expect(handler).toHaveBeenCalledTimes(expected);
|
|
163
137
|
});
|
|
@@ -167,11 +141,8 @@ describe('useTouch', function () {
|
|
|
167
141
|
activeProp: "active",
|
|
168
142
|
onTap: handler
|
|
169
143
|
}));
|
|
170
|
-
|
|
171
144
|
var component = _react.screen.getByTestId('component');
|
|
172
|
-
|
|
173
145
|
_react.fireEvent.click(component, {});
|
|
174
|
-
|
|
175
146
|
var expected = 1;
|
|
176
147
|
expect(handler).toHaveBeenCalledTimes(expected);
|
|
177
148
|
});
|
|
@@ -182,11 +153,8 @@ describe('useTouch', function () {
|
|
|
182
153
|
onClick: handler,
|
|
183
154
|
onTap: handler
|
|
184
155
|
}));
|
|
185
|
-
|
|
186
156
|
var component = _react.screen.getByTestId('component');
|
|
187
|
-
|
|
188
157
|
_react.fireEvent.click(component, {});
|
|
189
|
-
|
|
190
158
|
var expected = ['onTap', 'click'];
|
|
191
159
|
var actual = handler.mock.calls.map(function (call) {
|
|
192
160
|
return call[0].type;
|
|
@@ -200,17 +168,13 @@ describe('useTouch', function () {
|
|
|
200
168
|
onClick: handler,
|
|
201
169
|
onTap: handler
|
|
202
170
|
}));
|
|
203
|
-
|
|
204
171
|
var component = _react.screen.getByTestId('component');
|
|
205
|
-
|
|
206
172
|
var mouseDownEvent = _react.createEvent.mouseDown(component, {});
|
|
207
|
-
|
|
208
173
|
var mouseUpEvent = _react.createEvent.mouseUp(component, {});
|
|
174
|
+
var clickEvent = _react.createEvent.click(component, {});
|
|
209
175
|
|
|
210
|
-
|
|
176
|
+
// a matching timeStamp is used by Touchable to prevent multiple onTaps on "true"
|
|
211
177
|
// click (mouseup + click)
|
|
212
|
-
|
|
213
|
-
|
|
214
178
|
Object.defineProperty(mouseDownEvent, 'timeStamp', {
|
|
215
179
|
value: 1
|
|
216
180
|
});
|
|
@@ -236,13 +200,9 @@ describe('useTouch', function () {
|
|
|
236
200
|
onTap: handler,
|
|
237
201
|
onUp: preventDefault
|
|
238
202
|
}));
|
|
239
|
-
|
|
240
203
|
var component = _react.screen.getByTestId('component');
|
|
241
|
-
|
|
242
204
|
_react.fireEvent.mouseDown(component, {});
|
|
243
|
-
|
|
244
205
|
_react.fireEvent.mouseUp(component, {});
|
|
245
|
-
|
|
246
206
|
expect(handler).not.toHaveBeenCalled();
|
|
247
207
|
});
|
|
248
208
|
});
|
|
@@ -254,13 +214,9 @@ describe('useTouch', function () {
|
|
|
254
214
|
activeProp: "active",
|
|
255
215
|
onDown: handler
|
|
256
216
|
}));
|
|
257
|
-
|
|
258
217
|
var component = _react.screen.getByTestId('component');
|
|
259
|
-
|
|
260
218
|
var beforeDown = data.active;
|
|
261
|
-
|
|
262
219
|
_react.fireEvent.mouseDown(component, {});
|
|
263
|
-
|
|
264
220
|
var afterDown = data.active;
|
|
265
221
|
var expected = false;
|
|
266
222
|
var actual = beforeDown === afterDown;
|
|
@@ -273,11 +229,8 @@ describe('useTouch', function () {
|
|
|
273
229
|
disabled: true,
|
|
274
230
|
onDown: handler
|
|
275
231
|
}));
|
|
276
|
-
|
|
277
232
|
var component = _react.screen.getByTestId('component');
|
|
278
|
-
|
|
279
233
|
_react.fireEvent.mouseDown(component, {});
|
|
280
|
-
|
|
281
234
|
var expected = false;
|
|
282
235
|
var actual = data.active;
|
|
283
236
|
expect(actual).toBe(expected);
|
|
@@ -287,11 +240,8 @@ describe('useTouch', function () {
|
|
|
287
240
|
activeProp: "active",
|
|
288
241
|
onDown: preventDefault
|
|
289
242
|
}));
|
|
290
|
-
|
|
291
243
|
var component = _react.screen.getByTestId('component');
|
|
292
|
-
|
|
293
244
|
_react.fireEvent.mouseDown(component, {});
|
|
294
|
-
|
|
295
245
|
var expected = false;
|
|
296
246
|
var actual = data.active;
|
|
297
247
|
expect(actual).toBe(expected);
|
|
@@ -304,15 +254,10 @@ describe('useTouch', function () {
|
|
|
304
254
|
activeProp: "active",
|
|
305
255
|
onDown: handler
|
|
306
256
|
}));
|
|
307
|
-
|
|
308
257
|
var component = _react.screen.getByTestId('component');
|
|
309
|
-
|
|
310
258
|
_react.fireEvent.mouseDown(component, {});
|
|
311
|
-
|
|
312
259
|
var beforeUp = data.active;
|
|
313
|
-
|
|
314
260
|
_react.fireEvent.mouseUp(component, {});
|
|
315
|
-
|
|
316
261
|
var afterUp = data.active;
|
|
317
262
|
var expected = false;
|
|
318
263
|
var actual = beforeUp === afterUp;
|
|
@@ -325,15 +270,10 @@ describe('useTouch', function () {
|
|
|
325
270
|
disabled: true,
|
|
326
271
|
onDown: handler
|
|
327
272
|
}));
|
|
328
|
-
|
|
329
273
|
var component = _react.screen.getByTestId('component');
|
|
330
|
-
|
|
331
274
|
_react.fireEvent.mouseDown(component, {});
|
|
332
|
-
|
|
333
275
|
var beforeUp = data.active;
|
|
334
|
-
|
|
335
276
|
_react.fireEvent.mouseUp(component, {});
|
|
336
|
-
|
|
337
277
|
var afterUp = data.active;
|
|
338
278
|
var expected = true;
|
|
339
279
|
var actual = beforeUp === afterUp;
|
|
@@ -344,15 +284,10 @@ describe('useTouch', function () {
|
|
|
344
284
|
activeProp: "active",
|
|
345
285
|
onDown: preventDefault
|
|
346
286
|
}));
|
|
347
|
-
|
|
348
287
|
var component = _react.screen.getByTestId('component');
|
|
349
|
-
|
|
350
288
|
_react.fireEvent.mouseDown(component, {});
|
|
351
|
-
|
|
352
289
|
var beforeUp = data.active;
|
|
353
|
-
|
|
354
290
|
_react.fireEvent.mouseUp(component, {});
|
|
355
|
-
|
|
356
291
|
var afterUp = data.active;
|
|
357
292
|
var expected = true;
|
|
358
293
|
var actual = beforeUp === afterUp;
|
|
@@ -363,7 +298,6 @@ describe('useTouch', function () {
|
|
|
363
298
|
describe('touch', function () {
|
|
364
299
|
test('should only emit onTap once when tapping an child instance of Touchable', function () {
|
|
365
300
|
var handler = jest.fn();
|
|
366
|
-
|
|
367
301
|
var Component = function Component() {
|
|
368
302
|
var outerHook = (0, _useTouch["default"])({
|
|
369
303
|
onTap: handler
|
|
@@ -379,11 +313,8 @@ describe('useTouch', function () {
|
|
|
379
313
|
}))
|
|
380
314
|
}));
|
|
381
315
|
};
|
|
382
|
-
|
|
383
316
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
|
|
384
|
-
|
|
385
317
|
var inner = _react.screen.getByTestId('inner');
|
|
386
|
-
|
|
387
318
|
var mouseEvent = {
|
|
388
319
|
timeStamp: 1
|
|
389
320
|
};
|
|
@@ -398,15 +329,10 @@ describe('useTouch', function () {
|
|
|
398
329
|
clientY: 0
|
|
399
330
|
}]
|
|
400
331
|
};
|
|
401
|
-
|
|
402
332
|
_react.fireEvent.touchStart(inner, touchEvent);
|
|
403
|
-
|
|
404
333
|
_react.fireEvent.touchEnd(inner, touchEvent);
|
|
405
|
-
|
|
406
334
|
_react.fireEvent.mouseDown(inner, mouseEvent);
|
|
407
|
-
|
|
408
335
|
_react.fireEvent.mouseUp(inner, mouseEvent);
|
|
409
|
-
|
|
410
336
|
expect(handler).toHaveBeenCalled();
|
|
411
337
|
});
|
|
412
338
|
});
|
package/Touchable/useTouch.js
CHANGED
|
@@ -5,67 +5,56 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
exports.useTouch = useTouch;
|
|
8
|
-
|
|
9
8
|
var _useClass = _interopRequireDefault(require("@enact/core/useClass"));
|
|
10
|
-
|
|
11
9
|
var _react = require("react");
|
|
12
|
-
|
|
13
10
|
var _state = require("./state");
|
|
14
|
-
|
|
15
11
|
var _Touch = _interopRequireDefault(require("./Touch"));
|
|
16
|
-
|
|
17
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
18
|
-
|
|
19
13
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
|
-
|
|
21
14
|
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; }
|
|
22
|
-
|
|
23
15
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
|
-
|
|
25
16
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
26
|
-
|
|
27
17
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
28
|
-
|
|
29
18
|
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); }
|
|
30
|
-
|
|
31
19
|
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; }
|
|
32
|
-
|
|
33
20
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
34
|
-
|
|
35
21
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
36
|
-
|
|
37
22
|
/**
|
|
38
23
|
* Configuration for `useTouch`
|
|
39
24
|
*
|
|
40
25
|
* @typedef {Object} useTouchConfig
|
|
41
26
|
* @memberof ui/Touchable
|
|
42
|
-
* @property {Object} dragConfig
|
|
43
|
-
* @property {Object} flickConfig
|
|
44
|
-
* @property {Object} holdConfig
|
|
45
|
-
* @property {
|
|
46
|
-
* @property {Boolean}
|
|
47
|
-
* @property {Boolean}
|
|
48
|
-
* @property {
|
|
49
|
-
* @property {Function}
|
|
50
|
-
* @property {Function}
|
|
51
|
-
* @property {Function}
|
|
52
|
-
* @property {Function}
|
|
53
|
-
* @property {Function}
|
|
54
|
-
* @property {Function}
|
|
55
|
-
* @property {Function}
|
|
56
|
-
* @property {Function}
|
|
57
|
-
* @property {Function}
|
|
58
|
-
* @property {Function}
|
|
59
|
-
* @property {Function}
|
|
60
|
-
* @property {Function}
|
|
61
|
-
* @property {Function}
|
|
62
|
-
* @property {Function}
|
|
63
|
-
* @property {Function}
|
|
64
|
-
* @property {Function}
|
|
65
|
-
* @property {Function}
|
|
66
|
-
* @property {Function}
|
|
67
|
-
* @property {Function}
|
|
68
|
-
* @property {Function}
|
|
27
|
+
* @property {Object} dragConfig Instance-specific overrides of the drag configuration
|
|
28
|
+
* @property {Object} flickConfig Instance-specific overrides of the flick configuration
|
|
29
|
+
* @property {Object} holdConfig Instance-specific overrides of the hold configuration
|
|
30
|
+
* @property {Object} pinchConfig Instance-specific overrides of the pinch configuration
|
|
31
|
+
* @property {Boolean} getActive Enables active state management
|
|
32
|
+
* @property {Boolean} disabled Disables a hook
|
|
33
|
+
* @property {Boolean} noResume Prevents resuming the touch events and gestures when re-entering the component
|
|
34
|
+
* @property {Function} onBlur Event handler for a blur event
|
|
35
|
+
* @property {Function} onClick Event handler for a click event
|
|
36
|
+
* @property {Function} onMouseDown Event handler for a mousedown event
|
|
37
|
+
* @property {Function} onMouseEnter Event handler for a mouseenter event
|
|
38
|
+
* @property {Function} onMouseLeave Event handler for a mouseleave event
|
|
39
|
+
* @property {Function} onMouseMove Event handler for a mousemove event
|
|
40
|
+
* @property {Function} onMouseUp Event handler for a mouseup event
|
|
41
|
+
* @property {Function} onTouchEnd Event handler for a touchend event
|
|
42
|
+
* @property {Function} onTouchMove Event handler for a touchmove event
|
|
43
|
+
* @property {Function} onTouchStart Event handler for a touchstart event
|
|
44
|
+
* @property {Function} onDown Event handler for 'down' pointer events
|
|
45
|
+
* @property {Function} onDrag Event handler for a drag gesture
|
|
46
|
+
* @property {Function} onDragEnd Event handler for the end of a drag gesture
|
|
47
|
+
* @property {Function} onDragStart Event handler for the start of a drag gesture
|
|
48
|
+
* @property {Function} onFlick Event handler for a flick gesture
|
|
49
|
+
* @property {Function} onHold Event handler for hold pulse events
|
|
50
|
+
* @property {Function} onHoldEnd Event handler for the end of hold events
|
|
51
|
+
* @property {Function} onHoldStart Event handler for hold events
|
|
52
|
+
* @property {Function} onPinch Event handler for pinch gesture
|
|
53
|
+
* @property {Function} onPinchEnd Event handler for the end of pinch gesture
|
|
54
|
+
* @property {Function} onPinchStart Event handler for pinch gesture
|
|
55
|
+
* @property {Function} onMove Event handler for a pointer moving
|
|
56
|
+
* @property {Function} onTap Event handler for 'tap' pointer events
|
|
57
|
+
* @property {Function} onUp Event handler for 'up' pointer events
|
|
69
58
|
* @see {@link ui/Touchable.configure}
|
|
70
59
|
* @private
|
|
71
60
|
*/
|
|
@@ -83,7 +72,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
83
72
|
/**
|
|
84
73
|
* Provides a consistent set of pointer events -- `onDown`, `onUp`, and `onTap` --
|
|
85
74
|
* across mouse and touch interfaces along with support for common gestures including
|
|
86
|
-
* `onFlick`, `onDrag`, `onHoldStart`, `onHold`,
|
|
75
|
+
* `onFlick`, `onDragStart`, `onDrag`, `onDragEnd`, `onHoldStart`, `onHold`, `onHoldEnd`,
|
|
76
|
+
* `onPinchStart`, `onPinch`, and `onPinchEnd`.
|
|
87
77
|
* @param {useTouchConfig} config Configuration options
|
|
88
78
|
* @returns {useTouchInterface}
|
|
89
79
|
* @private
|
|
@@ -91,29 +81,32 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
91
81
|
function useTouch() {
|
|
92
82
|
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
93
83
|
var _config$getActive = config.getActive,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
84
|
+
getActive = _config$getActive === void 0 ? false : _config$getActive,
|
|
85
|
+
disabled = config.disabled,
|
|
86
|
+
dragConfig = config.dragConfig,
|
|
87
|
+
flickConfig = config.flickConfig,
|
|
88
|
+
holdConfig = config.holdConfig,
|
|
89
|
+
pinchConfig = config.pinchConfig,
|
|
90
|
+
onDrag = config.onDrag,
|
|
91
|
+
onDragEnd = config.onDragEnd,
|
|
92
|
+
onDragStart = config.onDragStart,
|
|
93
|
+
onHold = config.onHold,
|
|
94
|
+
onHoldEnd = config.onHoldEnd,
|
|
95
|
+
onHoldStart = config.onHoldStart,
|
|
96
|
+
onFlick = config.onFlick,
|
|
97
|
+
onPinch = config.onPinch,
|
|
98
|
+
onPinchEnd = config.onPinchEnd,
|
|
99
|
+
onPinchStart = config.onPinchStart;
|
|
106
100
|
var touch = (0, _useClass["default"])(_Touch["default"]);
|
|
107
|
-
|
|
108
101
|
var _useState = (0, _react.useState)(_state.States.Inactive),
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
103
|
+
state = _useState2[0],
|
|
104
|
+
setState = _useState2[1];
|
|
113
105
|
touch.setPropsAndContext(_objectSpread(_objectSpread({}, config), {}, {
|
|
114
106
|
disabled: !!disabled
|
|
115
|
-
}), state, setState);
|
|
107
|
+
}), state, setState);
|
|
116
108
|
|
|
109
|
+
// componentDidMount and componentWillUnmount
|
|
117
110
|
(0, _react.useEffect)(function () {
|
|
118
111
|
touch.addGlobalHandlers();
|
|
119
112
|
return function () {
|
|
@@ -123,12 +116,12 @@ function useTouch() {
|
|
|
123
116
|
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
124
117
|
|
|
125
118
|
(0, _react.useEffect)(function () {
|
|
126
|
-
touch.updateGestureConfig(dragConfig, flickConfig, holdConfig);
|
|
127
|
-
}, [dragConfig, flickConfig, holdConfig]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
119
|
+
touch.updateGestureConfig(dragConfig, flickConfig, holdConfig, pinchConfig);
|
|
120
|
+
}, [dragConfig, flickConfig, holdConfig, pinchConfig]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
128
121
|
|
|
129
122
|
(0, _react.useEffect)(function () {
|
|
130
123
|
touch.updateProps(config);
|
|
131
|
-
}, [onDrag, onDragEnd, onDragStart, onHold, onHoldEnd, onHoldStart, onFlick]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
124
|
+
}, [onDrag, onDragEnd, onDragStart, onHold, onHoldEnd, onHoldStart, onFlick, onPinch, onPinchEnd, onPinchStart]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
132
125
|
|
|
133
126
|
(0, _react.useEffect)(function () {
|
|
134
127
|
if (disabled) {
|
|
@@ -146,6 +139,5 @@ function useTouch() {
|
|
|
146
139
|
handlers: touch.getHandlers()
|
|
147
140
|
};
|
|
148
141
|
}
|
|
149
|
-
|
|
150
142
|
var _default = useTouch;
|
|
151
143
|
exports["default"] = _default;
|