@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.
Files changed (222) hide show
  1. package/AnnounceDecorator/Announce.js +1 -40
  2. package/AnnounceDecorator/AnnounceDecorator.js +3 -21
  3. package/AnnounceDecorator/tests/Announce-specs.js +2 -7
  4. package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +2 -6
  5. package/AnnounceDecorator/tests/useAnnounce-specs.js +8 -19
  6. package/AnnounceDecorator/useAnnounce.js +0 -6
  7. package/BodyText/BodyText.js +8 -28
  8. package/BodyText/tests/BodyText-specs.js +0 -19
  9. package/Button/Button.js +33 -63
  10. package/Button/tests/Button-specs.js +0 -26
  11. package/CHANGELOG.md +45 -0
  12. package/Cancelable/Cancelable.js +8 -47
  13. package/Cancelable/cancelHandler.js +5 -12
  14. package/Cancelable/modalHandler.js +3 -11
  15. package/Cancelable/tests/Cancelable-specs.js +3 -57
  16. package/Changeable/Changeable.js +2 -34
  17. package/Changeable/tests/Changeable-specs.js +20 -66
  18. package/ComponentOverride/ComponentOverride.js +1 -13
  19. package/FloatingLayer/FloatingLayer.js +17 -73
  20. package/FloatingLayer/FloatingLayerContainer.js +0 -15
  21. package/FloatingLayer/FloatingLayerDecorator.js +4 -17
  22. package/FloatingLayer/Scrim.js +9 -53
  23. package/FloatingLayer/index.js +0 -4
  24. package/FloatingLayer/package.json +3 -0
  25. package/FloatingLayer/tests/FloatingLayer-specs.js +8 -22
  26. package/FloatingLayer/tests/Scrim-specs.js +0 -9
  27. package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +0 -13
  28. package/FloatingLayer/useFloatingLayer.js +3 -14
  29. package/FloatingLayer/useFloatingLayerDecorator.js +3 -11
  30. package/ForwardRef/ForwardRef.js +1 -10
  31. package/GridListImageItem/GridListImageItem.js +18 -51
  32. package/Group/Group.js +5 -36
  33. package/Group/GroupItem.js +16 -33
  34. package/Group/tests/Group-specs.js +0 -32
  35. package/Heading/Heading.js +8 -36
  36. package/Heading/tests/Heading-specs.js +81 -14
  37. package/Icon/Icon.js +19 -53
  38. package/Icon/tests/Icon-specs.js +0 -22
  39. package/IconButton/IconButton.js +24 -57
  40. package/IconButton/tests/IconButton-specs.js +0 -7
  41. package/Image/Image.js +17 -46
  42. package/Image/tests/Image-specs.js +0 -14
  43. package/ImageItem/ImageItem.js +18 -47
  44. package/ImageItem/tests/ImageItem-specs.js +0 -25
  45. package/Item/Item.js +9 -33
  46. package/Item/tests/Item-specs.js +0 -24
  47. package/LabeledIcon/LabeledIcon.js +22 -53
  48. package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
  49. package/Layout/Cell.js +18 -44
  50. package/Layout/Layout.js +23 -46
  51. package/Layout/tests/Layout-specs.js +10 -39
  52. package/Marquee/MarqueeBase.js +29 -63
  53. package/Marquee/MarqueeController.js +11 -72
  54. package/Marquee/MarqueeDecorator.js +70 -196
  55. package/Marquee/index.js +1 -5
  56. package/Marquee/tests/Marquee-specs.js +295 -87
  57. package/Measurable/Measurable.js +12 -34
  58. package/Measurable/tests/Measurable-specs.js +115 -0
  59. package/Media/Media.js +15 -65
  60. package/Media/tests/Media-specs.js +168 -0
  61. package/Placeholder/PlaceholderControllerDecorator.js +7 -43
  62. package/Placeholder/PlaceholderDecorator.js +7 -38
  63. package/Placeholder/index.js +1 -5
  64. package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +25 -0
  65. package/Placeholder/tests/PlaceholderDecorator-specs.js +28 -0
  66. package/ProgressBar/ProgressBar.js +14 -45
  67. package/ProgressBar/tests/ProgressBar-specs.js +0 -17
  68. package/RadioDecorator/RadioControllerDecorator.js +7 -29
  69. package/RadioDecorator/RadioDecorator.js +9 -42
  70. package/RadioDecorator/tests/RadioDecorator-specs.js +12 -49
  71. package/Repeater/Repeater.js +9 -33
  72. package/Repeater/tests/Repeater-specs.js +0 -38
  73. package/Resizable/Resizable.js +9 -37
  74. package/Resizable/tests/Resizable-specs.js +34 -0
  75. package/Routable/Link.js +11 -47
  76. package/Routable/Routable.js +12 -35
  77. package/Routable/Route.js +0 -6
  78. package/Routable/Router.js +15 -58
  79. package/Routable/tests/Routable-specs.js +7 -33
  80. package/Routable/tests/Router-specs.js +18 -44
  81. package/Routable/useLink.js +4 -8
  82. package/Routable/util.js +18 -24
  83. package/Scrollable/ScrollAnimator.js +49 -65
  84. package/Scrollable/ScrollThumb.js +2 -13
  85. package/Scrollable/Scrollable.js +180 -387
  86. package/Scrollable/ScrollableNative.js +189 -392
  87. package/Scrollable/Scrollbar.js +30 -102
  88. package/Scroller/Scroller.js +15 -39
  89. package/Scroller/ScrollerBasic.js +34 -89
  90. package/Scroller/UiScrollerBase.js +37 -84
  91. package/Scroller/tests/Scroller-specs.js +56 -0
  92. package/Skinnable/Skinnable.js +11 -38
  93. package/Skinnable/tests/Skinnable-specs.js +3 -74
  94. package/Skinnable/tests/useSkins-specs.js +1 -13
  95. package/Skinnable/tests/util-specs.js +0 -14
  96. package/Skinnable/useSkins.js +8 -15
  97. package/Skinnable/util.js +9 -20
  98. package/Slider/Knob.js +5 -24
  99. package/Slider/PositionDecorator.js +16 -54
  100. package/Slider/Slider.js +29 -67
  101. package/Slider/tests/Slider-specs.js +94 -7
  102. package/Slider/utils.js +0 -2
  103. package/SlotItem/SlotItem.js +23 -45
  104. package/SlotItem/tests/SlotItem-specs.js +0 -5
  105. package/Slottable/Slottable.js +4 -12
  106. package/Slottable/tests/Slottable-specs.js +19 -46
  107. package/Slottable/tests/useSlots-specs.js +27 -65
  108. package/Slottable/useSlots.js +8 -33
  109. package/Spinner/Spinner.js +16 -43
  110. package/Spinner/tests/Spinner-specs.js +0 -15
  111. package/ToggleIcon/ToggleIcon.js +10 -36
  112. package/ToggleIcon/tests/ToggleIcon-specs.js +0 -16
  113. package/ToggleItem/ToggleItem.js +24 -57
  114. package/ToggleItem/tests/ToggleItem-specs.js +0 -30
  115. package/Toggleable/Toggle.js +1 -15
  116. package/Toggleable/Toggleable.js +12 -45
  117. package/Toggleable/tests/Toggleable-specs.js +28 -96
  118. package/Toggleable/useToggle.js +3 -19
  119. package/Touchable/ClickAllow.js +5 -14
  120. package/Touchable/Drag.js +16 -54
  121. package/Touchable/Flick.js +11 -42
  122. package/Touchable/Hold.js +21 -68
  123. package/Touchable/Pinch.js +185 -0
  124. package/Touchable/Touch.js +71 -76
  125. package/Touchable/Touchable.js +95 -75
  126. package/Touchable/config.js +27 -24
  127. package/Touchable/tests/Touchable-specs.js +360 -119
  128. package/Touchable/tests/useTouch-specs.js +6 -80
  129. package/Touchable/useTouch.js +57 -65
  130. package/Transition/Transition.js +37 -118
  131. package/Transition/tests/Transition-specs.js +20 -60
  132. package/ViewManager/Arranger.js +10 -22
  133. package/ViewManager/TransitionGroup.js +32 -107
  134. package/ViewManager/View.js +35 -91
  135. package/ViewManager/ViewManager.js +20 -84
  136. package/ViewManager/tests/View-specs.js +0 -17
  137. package/ViewManager/tests/ViewManager-specs.js +236 -305
  138. package/ViewManager/tests/test-utils.js +0 -8
  139. package/VirtualList/UiVirtualListBase.js +265 -409
  140. package/VirtualList/VirtualList.js +29 -69
  141. package/VirtualList/VirtualListBase.js +0 -3
  142. package/VirtualList/VirtualListBasic.js +273 -431
  143. package/VirtualList/tests/VirtualGridList-native-specs.js +161 -0
  144. package/VirtualList/tests/VirtualGridList-specs.js +614 -0
  145. package/VirtualList/tests/VirtualList-native-specs.js +152 -0
  146. package/VirtualList/tests/VirtualList-specs.js +423 -95
  147. package/internal/IdProvider/IdProvider.js +7 -21
  148. package/internal/IdProvider/Provider.js +4 -17
  149. package/internal/IdProvider/tests/IdProvider-specs.js +44 -0
  150. package/internal/IdProvider/tests/useId-specs.js +6 -20
  151. package/internal/IdProvider/useId.js +0 -6
  152. package/internal/Pure/Pure.js +3 -30
  153. package/internal/Pure/tests/Pure-specs.js +88 -0
  154. package/internal/localized-fonts/localized-fonts.js +33 -62
  155. package/internal/localized-fonts/tests/localized-fonts-specs.js +33 -0
  156. package/internal/selection/selection.js +1 -6
  157. package/internal/selection/tests/selection-specs.js +6 -4
  158. package/internal/validators/tests/validators-specs.js +80 -0
  159. package/internal/validators/validators.js +14 -34
  160. package/package.json +9 -3
  161. package/resolution/ResolutionDecorator.js +4 -40
  162. package/resolution/index.js +0 -7
  163. package/resolution/resolution.js +42 -80
  164. package/resolution/tests/ResolutionDecorator-specs.js +4 -11
  165. package/resolution/tests/resolution-specs.js +2 -2
  166. package/useControlledState/tests/useControlledState-specs.js +15 -46
  167. package/useControlledState/useControlledState.js +11 -22
  168. package/useScroll/ScrollAnimator.js +49 -65
  169. package/useScroll/Scrollbar.js +22 -58
  170. package/useScroll/ScrollbarTrack.js +3 -19
  171. package/useScroll/useScroll.js +267 -454
  172. package/useScroll/utilDOM.js +8 -14
  173. package/useScroll/utilEvent.js +0 -4
  174. package/AnnounceDecorator/AnnounceDecorator.d.ts +0 -64
  175. package/BodyText/BodyText.d.ts +0 -66
  176. package/Button/Button.d.ts +0 -125
  177. package/Cancelable/Cancelable.d.ts +0 -64
  178. package/Changeable/Changeable.d.ts +0 -54
  179. package/ComponentOverride/ComponentOverride.d.ts +0 -52
  180. package/ForwardRef/ForwardRef.d.ts +0 -22
  181. package/GridListImageItem/GridListImageItem.d.ts +0 -85
  182. package/Group/Group.d.ts +0 -107
  183. package/Heading/Heading.d.ts +0 -90
  184. package/Icon/Icon.d.ts +0 -88
  185. package/IconButton/IconButton.d.ts +0 -115
  186. package/Image/Image.d.ts +0 -113
  187. package/ImageItem/ImageItem.d.ts +0 -83
  188. package/Item/Item.d.ts +0 -64
  189. package/LabeledIcon/LabeledIcon.d.ts +0 -130
  190. package/Layout/Layout.d.ts +0 -247
  191. package/Marquee/index.d.ts +0 -258
  192. package/Measurable/Measurable.d.ts +0 -26
  193. package/Media/Media.d.ts +0 -99
  194. package/Placeholder/index.d.ts +0 -53
  195. package/ProgressBar/ProgressBar.d.ts +0 -92
  196. package/RadioDecorator/RadioDecorator.d.ts +0 -35
  197. package/Repeater/Repeater.d.ts +0 -83
  198. package/Resizable/Resizable.d.ts +0 -31
  199. package/Routable/Routable.d.ts +0 -148
  200. package/Scrollable/Scrollable.d.ts +0 -0
  201. package/Scroller/Scroller.d.ts +0 -276
  202. package/Skinnable/Skinnable.d.ts +0 -94
  203. package/Slider/Slider.d.ts +0 -202
  204. package/SlotItem/SlotItem.d.ts +0 -118
  205. package/Slottable/Slottable.d.ts +0 -22
  206. package/Spinner/Spinner.d.ts +0 -95
  207. package/ToggleIcon/ToggleIcon.d.ts +0 -90
  208. package/ToggleItem/ToggleItem.d.ts +0 -134
  209. package/Toggleable/Toggleable.d.ts +0 -103
  210. package/Touchable/Touchable.d.ts +0 -175
  211. package/Transition/Transition.d.ts +0 -196
  212. package/ViewManager/ViewManager.d.ts +0 -191
  213. package/VirtualList/VirtualList.d.ts +0 -530
  214. package/index.d.ts +0 -0
  215. package/internal/IdProvider/IdProvider.d.ts +0 -0
  216. package/internal/Pure/Pure.d.ts +0 -0
  217. package/internal/localized-fonts/localized-fonts.d.ts +0 -53
  218. package/internal/selection/selection.d.ts +0 -0
  219. package/internal/validators/validators.d.ts +0 -0
  220. package/resolution/index.d.ts +0 -187
  221. package/useControlledState/useControlledState.d.ts +0 -0
  222. 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
- id = _ref.id,
38
- rest = _objectWithoutProperties(_ref, _excluded);
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
- }); // eslint-disable-next-line no-undefined
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
- var clickEvent = _react.createEvent.click(component, {}); // a matching timeStamp is used by Touchable to prevent multiple onTaps on "true"
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
  });
@@ -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 Instance-specific overrides of the drag configuration
43
- * @property {Object} flickConfig Instance-specific overrides of the flick configuration
44
- * @property {Object} holdConfig Instance-specific overrides of the hold configuration
45
- * @property {Boolean} getActive Enables active state management
46
- * @property {Boolean} disabled Disables a hook
47
- * @property {Boolean} noResume Prevents resuming the touch events and gestures when re-entering the component
48
- * @property {Function} onBlur Event handler for a blur event
49
- * @property {Function} onClick Event handler for a click event
50
- * @property {Function} onMouseDown Event handler for a mousedown event
51
- * @property {Function} onMouseEnter Event handler for a mouseenter event
52
- * @property {Function} onMouseLeave Event handler for a mouseleave event
53
- * @property {Function} onMouseMove Event handler for a mousemove event
54
- * @property {Function} onMouseUp Event handler for a mouseup event
55
- * @property {Function} onTouchEnd Event handler for a touchend event
56
- * @property {Function} onTouchMove Event handler for a touchmove event
57
- * @property {Function} onTouchStart Event handler for a touchstart event
58
- * @property {Function} onDown Event handler for 'down' pointer events
59
- * @property {Function} onDrag Event handler for a drag gesture
60
- * @property {Function} onDragEnd Event handler for the end of a drag gesture
61
- * @property {Function} onDragStart Event handler for the start of a drag gesture
62
- * @property {Function} onFlick Event handler for a flick gesture
63
- * @property {Function} onHold Event handler for hold pulse events
64
- * @property {Function} onHoldEnd Event handler for the end of hold events
65
- * @property {Function} onHoldStart Event handler for hold events
66
- * @property {Function} onMove Event handler for a pointer moving
67
- * @property {Function} onTap Event handler for 'tap' pointer events
68
- * @property {Function} onUp Event handler for 'up' pointer events
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`, and `onHoldEnd`.
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
- getActive = _config$getActive === void 0 ? false : _config$getActive,
95
- disabled = config.disabled,
96
- dragConfig = config.dragConfig,
97
- flickConfig = config.flickConfig,
98
- holdConfig = config.holdConfig,
99
- onDrag = config.onDrag,
100
- onDragEnd = config.onDragEnd,
101
- onDragStart = config.onDragStart,
102
- onHold = config.onHold,
103
- onHoldEnd = config.onHoldEnd,
104
- onHoldStart = config.onHoldStart,
105
- onFlick = config.onFlick;
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
- _useState2 = _slicedToArray(_useState, 2),
110
- state = _useState2[0],
111
- setState = _useState2[1];
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); // componentDidMount and componentWillUnmount
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;