@enact/ui 4.5.2 → 4.5.3
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 +6 -26
- package/BodyText/tests/BodyText-specs.js +0 -19
- package/Button/Button.js +26 -56
- package/Button/tests/Button-specs.js +0 -26
- package/CHANGELOG.md +4 -0
- package/Cancelable/Cancelable.js +8 -47
- package/Cancelable/cancelHandler.js +5 -12
- package/Cancelable/modalHandler.js +3 -11
- package/Cancelable/tests/Cancelable-specs.js +3 -57
- package/Changeable/Changeable.js +2 -34
- package/Changeable/tests/Changeable-specs.js +20 -66
- package/ComponentOverride/ComponentOverride.js +1 -13
- package/FloatingLayer/FloatingLayer.js +17 -73
- package/FloatingLayer/FloatingLayerContainer.js +0 -15
- package/FloatingLayer/FloatingLayerDecorator.js +4 -17
- package/FloatingLayer/Scrim.js +9 -53
- package/FloatingLayer/index.js +0 -4
- package/FloatingLayer/tests/FloatingLayer-specs.js +8 -22
- package/FloatingLayer/tests/Scrim-specs.js +0 -9
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +0 -13
- package/FloatingLayer/useFloatingLayer.js +3 -14
- package/FloatingLayer/useFloatingLayerDecorator.js +3 -11
- package/ForwardRef/ForwardRef.js +1 -10
- package/GridListImageItem/GridListImageItem.js +17 -50
- package/Group/Group.js +4 -35
- package/Group/GroupItem.js +15 -32
- package/Group/tests/Group-specs.js +0 -32
- package/Heading/Heading.js +7 -35
- package/Heading/tests/Heading-specs.js +81 -14
- package/Icon/Icon.js +14 -48
- package/Icon/tests/Icon-specs.js +0 -22
- package/IconButton/IconButton.js +12 -50
- package/IconButton/tests/IconButton-specs.js +0 -7
- package/Image/Image.js +16 -45
- package/Image/tests/Image-specs.js +0 -14
- package/ImageItem/ImageItem.js +17 -46
- package/ImageItem/tests/ImageItem-specs.js +0 -25
- package/Item/Item.js +8 -32
- package/Item/tests/Item-specs.js +0 -24
- package/LabeledIcon/LabeledIcon.js +19 -50
- package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
- package/Layout/Cell.js +11 -37
- package/Layout/Layout.js +14 -37
- package/Layout/tests/Layout-specs.js +10 -39
- package/Marquee/MarqueeBase.js +29 -63
- package/Marquee/MarqueeController.js +11 -72
- package/Marquee/MarqueeDecorator.js +62 -196
- package/Marquee/index.js +1 -5
- package/Marquee/tests/Marquee-specs.js +258 -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 +0 -4
- package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +25 -0
- package/Placeholder/tests/PlaceholderDecorator-specs.js +28 -0
- package/ProgressBar/ProgressBar.js +13 -44
- package/ProgressBar/tests/ProgressBar-specs.js +0 -17
- package/RadioDecorator/RadioControllerDecorator.js +1 -29
- package/RadioDecorator/RadioDecorator.js +4 -42
- package/RadioDecorator/tests/RadioDecorator-specs.js +12 -49
- package/Repeater/Repeater.js +9 -33
- package/Repeater/tests/Repeater-specs.js +0 -38
- package/Resizable/Resizable.js +7 -35
- package/Resizable/tests/Resizable-specs.js +34 -0
- package/Routable/Link.js +8 -44
- package/Routable/Routable.js +10 -33
- package/Routable/Route.js +0 -6
- package/Routable/Router.js +13 -56
- 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 +179 -386
- package/Scrollable/ScrollableNative.js +188 -391
- package/Scrollable/Scrollbar.js +28 -100
- package/Scroller/Scroller.js +15 -39
- package/Scroller/ScrollerBasic.js +34 -89
- package/Scroller/UiScrollerBase.js +31 -84
- 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 +26 -64
- package/Slider/tests/Slider-specs.js +94 -7
- package/Slider/utils.js +0 -2
- package/SlotItem/SlotItem.js +15 -41
- 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 +15 -42
- 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 +15 -52
- package/ToggleItem/tests/ToggleItem-specs.js +0 -30
- package/Toggleable/Toggle.js +1 -15
- package/Toggleable/Toggleable.js +12 -45
- package/Toggleable/tests/Toggleable-specs.js +28 -96
- package/Toggleable/useToggle.js +3 -19
- package/Touchable/ClickAllow.js +5 -14
- package/Touchable/Drag.js +16 -54
- package/Touchable/Flick.js +11 -42
- package/Touchable/Hold.js +21 -68
- package/Touchable/Touch.js +37 -65
- package/Touchable/Touchable.js +32 -71
- package/Touchable/config.js +8 -22
- package/Touchable/tests/Touchable-specs.js +270 -119
- package/Touchable/tests/useTouch-specs.js +6 -80
- package/Touchable/useTouch.js +17 -34
- package/Transition/Transition.js +37 -118
- package/Transition/tests/Transition-specs.js +20 -60
- package/ViewManager/Arranger.js +10 -22
- package/ViewManager/TransitionGroup.js +31 -106
- package/ViewManager/View.js +35 -91
- package/ViewManager/ViewManager.js +19 -83
- 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 +256 -406
- package/VirtualList/VirtualList.js +29 -69
- package/VirtualList/VirtualListBase.js +0 -3
- package/VirtualList/VirtualListBasic.js +270 -428
- package/VirtualList/tests/VirtualList-specs.js +9 -37
- 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 +7 -22
- 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 +8 -2
- 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
|
@@ -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,35 +5,20 @@ 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
|
*
|
|
@@ -91,29 +76,28 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
91
76
|
function useTouch() {
|
|
92
77
|
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
93
78
|
var _config$getActive = config.getActive,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
79
|
+
getActive = _config$getActive === void 0 ? false : _config$getActive,
|
|
80
|
+
disabled = config.disabled,
|
|
81
|
+
dragConfig = config.dragConfig,
|
|
82
|
+
flickConfig = config.flickConfig,
|
|
83
|
+
holdConfig = config.holdConfig,
|
|
84
|
+
onDrag = config.onDrag,
|
|
85
|
+
onDragEnd = config.onDragEnd,
|
|
86
|
+
onDragStart = config.onDragStart,
|
|
87
|
+
onHold = config.onHold,
|
|
88
|
+
onHoldEnd = config.onHoldEnd,
|
|
89
|
+
onHoldStart = config.onHoldStart,
|
|
90
|
+
onFlick = config.onFlick;
|
|
106
91
|
var touch = (0, _useClass["default"])(_Touch["default"]);
|
|
107
|
-
|
|
108
92
|
var _useState = (0, _react.useState)(_state.States.Inactive),
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
93
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
94
|
+
state = _useState2[0],
|
|
95
|
+
setState = _useState2[1];
|
|
113
96
|
touch.setPropsAndContext(_objectSpread(_objectSpread({}, config), {}, {
|
|
114
97
|
disabled: !!disabled
|
|
115
|
-
}), state, setState);
|
|
98
|
+
}), state, setState);
|
|
116
99
|
|
|
100
|
+
// componentDidMount and componentWillUnmount
|
|
117
101
|
(0, _react.useEffect)(function () {
|
|
118
102
|
touch.addGlobalHandlers();
|
|
119
103
|
return function () {
|
|
@@ -146,6 +130,5 @@ function useTouch() {
|
|
|
146
130
|
handlers: touch.getHandlers()
|
|
147
131
|
};
|
|
148
132
|
}
|
|
149
|
-
|
|
150
133
|
var _default = useTouch;
|
|
151
134
|
exports["default"] = _default;
|