@enact/ui 4.1.2 → 4.5.0-alpha.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 (169) hide show
  1. package/AnnounceDecorator/Announce.js +9 -9
  2. package/AnnounceDecorator/AnnounceDecorator.js +6 -4
  3. package/AnnounceDecorator/tests/Announce-specs.js +13 -5
  4. package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +9 -7
  5. package/AnnounceDecorator/tests/useAnnounce-specs.js +25 -17
  6. package/AnnounceDecorator/useAnnounce.js +1 -1
  7. package/BodyText/BodyText.d.ts +1 -1
  8. package/BodyText/BodyText.js +6 -4
  9. package/BodyText/tests/BodyText-specs.js +51 -37
  10. package/Button/Button.d.ts +6 -6
  11. package/Button/Button.js +11 -7
  12. package/Button/tests/Button-specs.js +104 -3
  13. package/CHANGELOG.md +25 -0
  14. package/Cancelable/Cancelable.js +12 -11
  15. package/Cancelable/tests/Cancelable-specs.js +133 -70
  16. package/Changeable/Changeable.js +9 -9
  17. package/Changeable/tests/Changeable-specs.js +172 -110
  18. package/ComponentOverride/ComponentOverride.js +6 -4
  19. package/FloatingLayer/FloatingLayer.js +40 -49
  20. package/FloatingLayer/FloatingLayer.module.css +3 -0
  21. package/FloatingLayer/FloatingLayerContainer.js +2 -2
  22. package/FloatingLayer/FloatingLayerDecorator.js +6 -4
  23. package/FloatingLayer/Scrim.js +9 -7
  24. package/FloatingLayer/index.js +1 -1
  25. package/FloatingLayer/tests/FloatingLayer-specs.js +83 -8
  26. package/FloatingLayer/tests/Scrim-specs.js +20 -11
  27. package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +17 -11
  28. package/FloatingLayer/useFloatingLayer.js +2 -2
  29. package/FloatingLayer/useFloatingLayerDecorator.js +1 -1
  30. package/ForwardRef/ForwardRef.js +3 -3
  31. package/GridListImageItem/GridListImageItem.d.ts +1 -1
  32. package/GridListImageItem/GridListImageItem.js +6 -4
  33. package/Group/Group.d.ts +2 -2
  34. package/Group/Group.js +7 -4
  35. package/Group/GroupItem.js +6 -4
  36. package/Group/tests/Group-specs.js +73 -43
  37. package/Heading/Heading.d.ts +2 -1
  38. package/Heading/Heading.js +6 -4
  39. package/Heading/tests/Heading-specs.js +27 -20
  40. package/Icon/Icon.d.ts +4 -4
  41. package/Icon/Icon.js +6 -4
  42. package/Icon/tests/Icon-specs.js +54 -33
  43. package/IconButton/IconButton.d.ts +4 -4
  44. package/IconButton/IconButton.js +6 -4
  45. package/IconButton/tests/IconButton-specs.js +2 -2
  46. package/Image/Image.js +6 -4
  47. package/Image/tests/Image-specs.js +41 -31
  48. package/ImageItem/ImageItem.js +8 -5
  49. package/ImageItem/tests/ImageItem-specs.js +75 -72
  50. package/Item/Item.js +6 -4
  51. package/Item/tests/Item-specs.js +59 -35
  52. package/LabeledIcon/LabeledIcon.d.ts +4 -4
  53. package/LabeledIcon/LabeledIcon.js +6 -4
  54. package/LabeledIcon/tests/LabeledIcon-specs.js +30 -19
  55. package/Layout/Cell.js +6 -4
  56. package/Layout/Layout.d.ts +16 -16
  57. package/Layout/Layout.js +6 -4
  58. package/Layout/tests/Layout-specs.js +42 -30
  59. package/Marquee/MarqueeBase.js +7 -9
  60. package/Marquee/MarqueeController.js +9 -9
  61. package/Marquee/MarqueeDecorator.js +18 -13
  62. package/Marquee/index.d.ts +4 -1
  63. package/Marquee/index.js +2 -1
  64. package/Marquee/tests/Marquee-specs.js +254 -122
  65. package/Measurable/Measurable.js +4 -4
  66. package/Media/Media.js +10 -10
  67. package/Placeholder/PlaceholderControllerDecorator.js +9 -9
  68. package/Placeholder/PlaceholderDecorator.js +9 -9
  69. package/ProgressBar/ProgressBar.js +6 -4
  70. package/ProgressBar/tests/ProgressBar-specs.js +60 -42
  71. package/README.md +1 -1
  72. package/RadioDecorator/RadioControllerDecorator.js +9 -9
  73. package/RadioDecorator/RadioDecorator.js +12 -14
  74. package/RadioDecorator/tests/RadioDecorator-specs.js +179 -65
  75. package/Repeater/Repeater.d.ts +2 -1
  76. package/Repeater/Repeater.js +6 -4
  77. package/Repeater/tests/Repeater-specs.js +90 -49
  78. package/Resizable/Resizable.js +10 -10
  79. package/Routable/Link.js +9 -7
  80. package/Routable/Routable.d.ts +2 -2
  81. package/Routable/Routable.js +10 -6
  82. package/Routable/Route.js +1 -1
  83. package/Routable/Router.js +14 -11
  84. package/Routable/tests/Routable-specs.js +29 -20
  85. package/Routable/tests/Router-specs.js +65 -41
  86. package/Routable/useLink.js +1 -1
  87. package/Routable/util.js +1 -1
  88. package/Scrollable/ScrollAnimator.js +2 -2
  89. package/Scrollable/ScrollThumb.js +3 -3
  90. package/Scrollable/Scrollable.js +14 -10
  91. package/Scrollable/ScrollableNative.js +14 -10
  92. package/Scrollable/Scrollbar.js +14 -8
  93. package/Scroller/Scroller.d.ts +2 -14
  94. package/Scroller/Scroller.js +8 -7
  95. package/Scroller/ScrollerBasic.js +18 -35
  96. package/Scroller/UiScrollerBase.js +9 -7
  97. package/Skinnable/Skinnable.js +6 -4
  98. package/Skinnable/tests/Skinnable-specs.js +104 -56
  99. package/Skinnable/tests/useSkins-specs.js +39 -44
  100. package/Skinnable/useSkins.js +1 -1
  101. package/Slider/Knob.js +6 -4
  102. package/Slider/PositionDecorator.js +9 -9
  103. package/Slider/Slider.d.ts +3 -3
  104. package/Slider/Slider.js +6 -4
  105. package/Slider/tests/Slider-specs.js +4 -4
  106. package/SlotItem/SlotItem.d.ts +2 -2
  107. package/SlotItem/SlotItem.js +6 -4
  108. package/SlotItem/tests/SlotItem-specs.js +4 -4
  109. package/Slottable/Slottable.js +3 -3
  110. package/Slottable/tests/Slottable-specs.js +67 -36
  111. package/Slottable/tests/useSlots-specs.js +68 -35
  112. package/Slottable/useSlots.js +6 -4
  113. package/Spinner/Spinner.d.ts +1 -1
  114. package/Spinner/Spinner.js +6 -4
  115. package/Spinner/tests/Spinner-specs.js +46 -31
  116. package/ToggleIcon/ToggleIcon.js +6 -4
  117. package/ToggleIcon/tests/ToggleIcon-specs.js +32 -20
  118. package/ToggleItem/ToggleItem.d.ts +13 -11
  119. package/ToggleItem/ToggleItem.js +6 -4
  120. package/ToggleItem/tests/ToggleItem-specs.js +54 -37
  121. package/Toggleable/Toggle.js +10 -10
  122. package/Toggleable/Toggleable.js +11 -17
  123. package/Toggleable/tests/Toggleable-specs.js +464 -324
  124. package/Toggleable/useToggle.js +4 -2
  125. package/Touchable/ClickAllow.js +2 -2
  126. package/Touchable/Drag.js +22 -22
  127. package/Touchable/Flick.js +22 -18
  128. package/Touchable/Hold.js +18 -23
  129. package/Touchable/Touch.js +2 -2
  130. package/Touchable/Touchable.d.ts +3 -3
  131. package/Touchable/Touchable.js +7 -4
  132. package/Touchable/config.js +3 -3
  133. package/Touchable/tests/Touchable-specs.js +225 -109
  134. package/Touchable/tests/useTouch-specs.js +163 -86
  135. package/Touchable/useTouch.js +4 -4
  136. package/Transition/Transition.d.ts +29 -27
  137. package/Transition/Transition.js +22 -17
  138. package/Transition/tests/Transition-specs.js +116 -36
  139. package/ViewManager/Arranger.js +3 -3
  140. package/ViewManager/TransitionGroup.js +10 -9
  141. package/ViewManager/View.js +7 -7
  142. package/ViewManager/ViewManager.d.ts +4 -4
  143. package/ViewManager/ViewManager.js +24 -22
  144. package/ViewManager/tests/View-specs.js +141 -81
  145. package/ViewManager/tests/ViewManager-specs.js +486 -193
  146. package/VirtualList/UiVirtualListBase.js +26 -35
  147. package/VirtualList/VirtualList.d.ts +11 -29
  148. package/VirtualList/VirtualList.js +10 -9
  149. package/VirtualList/VirtualListBase.js +1 -1
  150. package/VirtualList/VirtualListBasic.js +44 -61
  151. package/VirtualList/tests/VirtualList-specs.js +81 -95
  152. package/internal/IdProvider/IdProvider.js +3 -3
  153. package/internal/IdProvider/Provider.js +2 -2
  154. package/internal/IdProvider/tests/useId-specs.js +37 -20
  155. package/internal/Pure/Pure.js +9 -9
  156. package/internal/localized-fonts/localized-fonts.js +1 -1
  157. package/internal/validators/validators.js +1 -1
  158. package/package.json +11 -11
  159. package/resolution/ResolutionDecorator.js +9 -9
  160. package/resolution/index.js +2 -2
  161. package/resolution/resolution.js +4 -2
  162. package/resolution/tests/ResolutionDecorator-specs.js +17 -8
  163. package/styles/mixins.less +14 -2
  164. package/useControlledState/tests/useControlledState-specs.js +68 -43
  165. package/useControlledState/useControlledState.js +2 -2
  166. package/useScroll/ScrollAnimator.js +2 -2
  167. package/useScroll/Scrollbar.js +7 -4
  168. package/useScroll/ScrollbarTrack.js +6 -4
  169. package/useScroll/useScroll.js +18 -29
@@ -1,18 +1,20 @@
1
1
  "use strict";
2
2
 
3
- var _enzyme = require("enzyme");
4
-
5
- var _useTouch = _interopRequireDefault(require("../useTouch"));
3
+ var _react = require("@testing-library/react");
6
4
 
7
5
  var _config = require("../config");
8
6
 
7
+ var _useTouch = _interopRequireDefault(require("../useTouch"));
8
+
9
9
  var _jsxRuntime = require("react/jsx-runtime");
10
10
 
11
+ var _excluded = ["activeProp", "id"];
12
+
11
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
14
 
13
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
15
+ 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; }
14
16
 
15
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
+ 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; }
16
18
 
17
19
  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; }
18
20
 
@@ -21,14 +23,19 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
21
23
  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; }
22
24
 
23
25
  describe('useTouch', function () {
24
- var DivComponent = function DivComponent() {
25
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
26
+ var data;
27
+
28
+ var DivComponent = function DivComponent(props) {
29
+ data = props;
30
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
31
+ "data-testid": "component"
32
+ });
26
33
  };
27
34
 
28
35
  var TouchableComponent = function TouchableComponent(_ref) {
29
- var id = _ref.id,
30
- activeProp = _ref.activeProp,
31
- rest = _objectWithoutProperties(_ref, ["id", "activeProp"]);
36
+ var activeProp = _ref.activeProp,
37
+ id = _ref.id,
38
+ rest = _objectWithoutProperties(_ref, _excluded);
32
39
 
33
40
  var hook = (0, _useTouch["default"])(_objectSpread({
34
41
  getActive: !!activeProp
@@ -48,13 +55,11 @@ describe('useTouch', function () {
48
55
  beforeEach(_config.resetDefaultConfig);
49
56
  afterEach(_config.resetDefaultConfig);
50
57
  test('should return active state when activeProp is configured', function () {
51
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
58
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
52
59
  activeProp: "active"
53
60
  }));
54
- var wrapped = subject.find(DivComponent);
55
- var expected = true;
56
- var actual = ('active' in wrapped.props());
57
- expect(actual).toBe(expected);
61
+ var expected = data.active;
62
+ expect(expected).toBeDefined();
58
63
  });
59
64
  test('should merge configurations', function () {
60
65
  (0, _config.configure)({
@@ -108,83 +113,116 @@ describe('useTouch', function () {
108
113
  describe('#onDown', function () {
109
114
  test('should invoke onDown handle on mouse down', function () {
110
115
  var handler = jest.fn();
111
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
116
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
112
117
  activeProp: "active",
113
118
  onDown: handler
114
119
  }));
115
- subject.simulate('mousedown', {});
120
+
121
+ var component = _react.screen.getByTestId('component');
122
+
123
+ _react.fireEvent.mouseDown(component, {});
124
+
116
125
  var expected = 1;
117
- var actual = handler.mock.calls.length;
118
- expect(actual).toBe(expected);
126
+ expect(handler).toHaveBeenCalledTimes(expected);
119
127
  });
120
128
  });
121
129
  describe('#onUp', function () {
122
130
  test('should invoke onUp handle on mouse up', function () {
123
131
  var handler = jest.fn();
124
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
132
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
125
133
  activeProp: "active",
126
134
  onUp: handler
127
135
  }));
128
- subject.simulate('mousedown', {});
129
- subject.simulate('mouseup', {});
136
+
137
+ var component = _react.screen.getByTestId('component');
138
+
139
+ _react.fireEvent.mouseDown(component, {});
140
+
141
+ _react.fireEvent.mouseUp(component, {});
142
+
130
143
  var expected = 1;
131
- var actual = handler.mock.calls.length;
132
- expect(actual).toBe(expected);
144
+ expect(handler).toHaveBeenCalledTimes(expected);
133
145
  });
134
146
  });
135
147
  describe('#onTap', function () {
136
148
  test('should be called on mouse up', function () {
137
149
  var handler = jest.fn();
138
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
150
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
139
151
  activeProp: "active",
140
152
  onTap: handler
141
153
  }));
142
- subject.simulate('mousedown', {});
143
- subject.simulate('mouseup', {});
154
+
155
+ var component = _react.screen.getByTestId('component');
156
+
157
+ _react.fireEvent.mouseDown(component, {});
158
+
159
+ _react.fireEvent.mouseUp(component, {});
160
+
144
161
  var expected = 1;
145
- var actual = handler.mock.calls.length;
146
- expect(actual).toBe(expected);
162
+ expect(handler).toHaveBeenCalledTimes(expected);
147
163
  });
148
164
  test('should be called on click', function () {
149
165
  var handler = jest.fn();
150
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
166
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
151
167
  activeProp: "active",
152
168
  onTap: handler
153
169
  }));
154
- subject.simulate('click');
170
+
171
+ var component = _react.screen.getByTestId('component');
172
+
173
+ _react.fireEvent.click(component, {});
174
+
155
175
  var expected = 1;
156
- var actual = handler.mock.calls.length;
157
- expect(actual).toBe(expected);
176
+ expect(handler).toHaveBeenCalledTimes(expected);
158
177
  });
159
178
  test('should be called before onClick on click', function () {
160
179
  var handler = jest.fn();
161
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
180
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
162
181
  activeProp: "active",
163
182
  onClick: handler,
164
183
  onTap: handler
165
184
  }));
166
- subject.simulate('click');
185
+
186
+ var component = _react.screen.getByTestId('component');
187
+
188
+ _react.fireEvent.click(component, {});
189
+
167
190
  var expected = ['onTap', 'click'];
168
191
  var actual = handler.mock.calls.map(function (call) {
169
192
  return call[0].type;
170
193
  });
171
194
  expect(actual).toEqual(expected);
172
195
  });
173
- test('should be called before onCLick on mouse up', function () {
196
+ test('should be called before onClick on mouse up', function () {
174
197
  var handler = jest.fn();
175
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
198
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
176
199
  activeProp: "active",
177
200
  onClick: handler,
178
201
  onTap: handler
179
202
  }));
180
- var ev = {
181
- // a matching timeStamp is used by Touchable to prevent multiple onTaps on "true"
182
- // click (mouseup + click)
183
- timeStamp: 1
184
- };
185
- subject.simulate('mousedown', ev);
186
- subject.simulate('mouseup', ev);
187
- subject.simulate('click', ev);
203
+
204
+ var component = _react.screen.getByTestId('component');
205
+
206
+ var mouseDownEvent = _react.createEvent.mouseDown(component, {});
207
+
208
+ var mouseUpEvent = _react.createEvent.mouseUp(component, {});
209
+
210
+ var clickEvent = _react.createEvent.click(component, {}); // a matching timeStamp is used by Touchable to prevent multiple onTaps on "true"
211
+ // click (mouseup + click)
212
+
213
+
214
+ Object.defineProperty(mouseDownEvent, 'timeStamp', {
215
+ value: 1
216
+ });
217
+ Object.defineProperty(mouseUpEvent, 'timeStamp', {
218
+ value: 1
219
+ });
220
+ Object.defineProperty(clickEvent, 'timeStamp', {
221
+ value: 1
222
+ });
223
+ (0, _react.fireEvent)(component, mouseDownEvent);
224
+ (0, _react.fireEvent)(component, mouseUpEvent);
225
+ (0, _react.fireEvent)(component, clickEvent);
188
226
  var expected = ['onTap', 'click'];
189
227
  var actual = handler.mock.calls.map(function (call) {
190
228
  return call[0].type;
@@ -193,95 +231,129 @@ describe('useTouch', function () {
193
231
  });
194
232
  test('should be preventable via onUp handler', function () {
195
233
  var handler = jest.fn();
196
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
234
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
197
235
  activeProp: "active",
198
236
  onTap: handler,
199
237
  onUp: preventDefault
200
238
  }));
201
- subject.simulate('mousedown', {});
202
- subject.simulate('mouseup', {});
203
- var expected = 0;
204
- var actual = handler.mock.calls.length;
205
- expect(actual).toBe(expected);
239
+
240
+ var component = _react.screen.getByTestId('component');
241
+
242
+ _react.fireEvent.mouseDown(component, {});
243
+
244
+ _react.fireEvent.mouseUp(component, {});
245
+
246
+ expect(handler).not.toHaveBeenCalled();
206
247
  });
207
248
  });
208
249
  describe('state management', function () {
209
250
  describe('activate', function () {
210
251
  test('should update active state on mouse down when activeProp is configured', function () {
211
252
  var handler = jest.fn();
212
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
253
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
213
254
  activeProp: "active",
214
255
  onDown: handler
215
256
  }));
216
- var beforeDown = subject.find(DivComponent).prop('active');
217
- subject.simulate('mousedown', {});
218
- var afterDown = subject.find(DivComponent).prop('active');
257
+
258
+ var component = _react.screen.getByTestId('component');
259
+
260
+ var beforeDown = data.active;
261
+
262
+ _react.fireEvent.mouseDown(component, {});
263
+
264
+ var afterDown = data.active;
219
265
  var expected = false;
220
266
  var actual = beforeDown === afterDown;
221
267
  expect(actual).toBe(expected);
222
268
  });
223
269
  test('should not update active state on mouse down when disabled', function () {
224
270
  var handler = jest.fn();
225
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
271
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
226
272
  activeProp: "active",
227
273
  disabled: true,
228
274
  onDown: handler
229
275
  }));
230
- subject.simulate('mousedown', {});
276
+
277
+ var component = _react.screen.getByTestId('component');
278
+
279
+ _react.fireEvent.mouseDown(component, {});
280
+
231
281
  var expected = false;
232
- var actual = subject.find(DivComponent).prop('active');
282
+ var actual = data.active;
233
283
  expect(actual).toBe(expected);
234
284
  });
235
285
  test('should not update active state on mouse down when preventDefault is called', function () {
236
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
286
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
237
287
  activeProp: "active",
238
288
  onDown: preventDefault
239
289
  }));
240
- subject.simulate('mousedown', {});
290
+
291
+ var component = _react.screen.getByTestId('component');
292
+
293
+ _react.fireEvent.mouseDown(component, {});
294
+
241
295
  var expected = false;
242
- var actual = subject.find(DivComponent).prop('active');
296
+ var actual = data.active;
243
297
  expect(actual).toBe(expected);
244
298
  });
245
299
  });
246
300
  describe('deactivate', function () {
247
301
  test('should update active state on mouse up when activeProp is configured', function () {
248
302
  var handler = jest.fn();
249
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
303
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
250
304
  activeProp: "active",
251
305
  onDown: handler
252
306
  }));
253
- subject.simulate('mousedown', {});
254
- var beforeUp = subject.find(DivComponent).prop('active');
255
- subject.simulate('mouseup', {});
256
- var afterUp = subject.find(DivComponent).prop('active');
307
+
308
+ var component = _react.screen.getByTestId('component');
309
+
310
+ _react.fireEvent.mouseDown(component, {});
311
+
312
+ var beforeUp = data.active;
313
+
314
+ _react.fireEvent.mouseUp(component, {});
315
+
316
+ var afterUp = data.active;
257
317
  var expected = false;
258
318
  var actual = beforeUp === afterUp;
259
319
  expect(actual).toBe(expected);
260
320
  });
261
321
  test('should not update active state on mouse down when disabled', function () {
262
322
  var handler = jest.fn();
263
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
323
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
264
324
  activeProp: "active",
265
325
  disabled: true,
266
326
  onDown: handler
267
327
  }));
268
- subject.simulate('mousedown', {});
269
- var beforeUp = subject.find(DivComponent).prop('active');
270
- subject.simulate('mouseup', {});
271
- var afterUp = subject.find(DivComponent).prop('active');
328
+
329
+ var component = _react.screen.getByTestId('component');
330
+
331
+ _react.fireEvent.mouseDown(component, {});
332
+
333
+ var beforeUp = data.active;
334
+
335
+ _react.fireEvent.mouseUp(component, {});
336
+
337
+ var afterUp = data.active;
272
338
  var expected = true;
273
339
  var actual = beforeUp === afterUp;
274
340
  expect(actual).toBe(expected);
275
341
  });
276
342
  test('should not update active state on mouse down when preventDefault is called', function () {
277
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
343
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
278
344
  activeProp: "active",
279
345
  onDown: preventDefault
280
346
  }));
281
- subject.simulate('mousedown', {});
282
- var beforeUp = subject.find(DivComponent).prop('active');
283
- subject.simulate('mouseup', {});
284
- var afterUp = subject.find(DivComponent).prop('active');
347
+
348
+ var component = _react.screen.getByTestId('component');
349
+
350
+ _react.fireEvent.mouseDown(component, {});
351
+
352
+ var beforeUp = data.active;
353
+
354
+ _react.fireEvent.mouseUp(component, {});
355
+
356
+ var afterUp = data.active;
285
357
  var expected = true;
286
358
  var actual = beforeUp === afterUp;
287
359
  expect(actual).toBe(expected);
@@ -301,14 +373,17 @@ describe('useTouch', function () {
301
373
  id: "outer"
302
374
  }, outerHook.handlers), {}, {
303
375
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({
304
- id: "inner"
376
+ "data-testid": "inner"
305
377
  }, innerHook.handlers), {}, {
306
378
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(DivComponent, {})
307
379
  }))
308
380
  }));
309
381
  };
310
382
 
311
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
383
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
384
+
385
+ var inner = _react.screen.getByTestId('inner');
386
+
312
387
  var mouseEvent = {
313
388
  timeStamp: 1
314
389
  };
@@ -323,14 +398,16 @@ describe('useTouch', function () {
323
398
  clientY: 0
324
399
  }]
325
400
  };
326
- var inner = subject.find('div#inner');
327
- inner.simulate('touchstart', touchEvent);
328
- inner.simulate('touchend', touchEvent);
329
- inner.simulate('mousedown', mouseEvent);
330
- inner.simulate('mouseup', mouseEvent);
331
- var expected = 1;
332
- var actual = handler.mock.calls.length;
333
- expect(actual).toBe(expected);
401
+
402
+ _react.fireEvent.touchStart(inner, touchEvent);
403
+
404
+ _react.fireEvent.touchEnd(inner, touchEvent);
405
+
406
+ _react.fireEvent.mouseDown(inner, mouseEvent);
407
+
408
+ _react.fireEvent.mouseUp(inner, mouseEvent);
409
+
410
+ expect(handler).toHaveBeenCalled();
334
411
  });
335
412
  });
336
413
  });
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useTouch = useTouch;
7
6
  exports["default"] = void 0;
7
+ exports.useTouch = useTouch;
8
8
 
9
9
  var _useClass = _interopRequireDefault(require("@enact/core/useClass"));
10
10
 
@@ -16,9 +16,9 @@ var _Touch = _interopRequireDefault(require("./Touch"));
16
16
 
17
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
18
18
 
19
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
19
+ 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
20
 
21
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
21
+ 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
22
 
23
23
  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
24
 
@@ -30,7 +30,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
30
30
 
31
31
  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
32
 
33
- function _iterableToArrayLimit(arr, i) { var _i = arr && (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; }
33
+ 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
34
 
35
35
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
36
36
 
@@ -75,10 +75,11 @@ are also supported and treated as milliseconds.
75
75
  */
76
76
  noAnimation?: boolean;
77
77
  /**
78
- * The transition timing function.
79
- * * Supported function names are: `ease` , `ease-in` , `ease-out` , `ease-in-out` , `ease-in-quart` ,
80
- `ease-out-quart` , and `linear` .
81
- */
78
+ * The transition timing function.
79
+ * * Supported function names are: `ease` , `ease-in` , `ease-out` , `ease-in-out` , `ease-in-quart` ,
80
+ *
81
+ * `ease-out-quart` , and `linear` .
82
+ */
82
83
  timingFunction?: string;
83
84
  /**
84
85
  * The type of transition to affect the content.
@@ -86,19 +87,19 @@ are also supported and treated as milliseconds.
86
87
  *
87
88
  * Details on types:
88
89
  * * `'slide'` - Typically used for bringing something which is off the edge of the screen,
89
- and not visible, onto the screen. Think of a popup, toast, notification, dialog, or
90
- an overlaying menu. This requires no re-rendering or repainting of the screen during
91
- the transition, making it very performant. However, this does not affect layout at
92
- all, which makes it less useful for transitioning from a place already on the
93
- screen.
90
+ and not visible, onto the screen. Think of a popup, toast, notification, dialog, or
91
+ an overlaying menu. This requires no re-rendering or repainting of the screen during
92
+ the transition, making it very performant. However, this does not affect layout at
93
+ all, which makes it less useful for transitioning from a place already on the
94
+ screen.
94
95
  * * `'clip'` - This is useful for showing a component that transitions-in from a location
95
- that is already on the screen. Examples would be an expanding header or an
96
- accordion. This type does affects layout, its current size will push other sibling
97
- elements to make room for itself. Because of this, repainting the layout does happen
98
- during transition.
96
+ that is already on the screen. Examples would be an expanding header or an
97
+ accordion. This type does affects layout, its current size will push other sibling
98
+ elements to make room for itself. Because of this, repainting the layout does happen
99
+ during transition.
99
100
  * * `'fade'` - Fade the components onto the screen, from 0 opacity (completely invisible)
100
- to 1 (full visibility). Pretty basic, but useful for fading on/off a tooltip, a
101
- menu, a panel, or even view contents. This does not affect layout at all.
101
+ to 1 (full visibility). Pretty basic, but useful for fading on/off a tooltip, a
102
+ menu, a panel, or even view contents. This does not affect layout at all.
102
103
  */
103
104
  type?: string;
104
105
  /**
@@ -130,7 +131,8 @@ export interface TransitionProps {
130
131
  /**
131
132
  * Controls how long the transition should take.
132
133
  * * Supported preset durations are: `'short'` (250ms), `'medium'` (500ms), and `'long'` (1s).
133
- `'medium'` (500ms) is default when no others are specified.
134
+ *
135
+ * `'medium'` (500ms) is default when no others are specified.
134
136
  *
135
137
  * Any valid CSS duration value is also accepted, e.g. "200ms" or "3s". Pure numeric values
136
138
  are also supported and treated as miliseconds.
@@ -162,19 +164,19 @@ Supported function names are: `ease` , `ease-in` , `ease-out` , `ease-in-out
162
164
  *
163
165
  * Details on types:
164
166
  * * `'slide'` - Typically used for bringing something which is off the edge of the screen,
165
- and not visible, onto the screen. Think of a popup, toast, notification, dialog, or
166
- an overlaying menu. This requires no re-rendering or repainting of the screen during
167
- the transition, making it very performant. However, this does not affect layout at
168
- all, which makes it less useful for transitioning from a place already on the
169
- screen.
167
+ and not visible, onto the screen. Think of a popup, toast, notification, dialog, or
168
+ an overlaying menu. This requires no re-rendering or repainting of the screen during
169
+ the transition, making it very performant. However, this does not affect layout at
170
+ all, which makes it less useful for transitioning from a place already on the
171
+ screen.
170
172
  * * `'clip'` - This is useful for showing a component that transitions-in from a location
171
- that is already on the screen. Examples would be an expanding header or an
172
- accordion. This type does affects layout, its current size will push other sibling
173
- elements to make room for itself. Because of this, repainting the layout does happen
174
- during transition.
173
+ that is already on the screen. Examples would be an expanding header or an
174
+ accordion. This type does affects layout, its current size will push other sibling
175
+ elements to make room for itself. Because of this, repainting the layout does happen
176
+ during transition.
175
177
  * * `'fade'` - Fade the components onto the screen, from 0 opacity (completely invisible)
176
- to 1 (full visibility). Pretty basic, but useful for fading on/off a tooltip, a
177
- menu, a panel, or even view contents. This does not affect layout at all.
178
+ to 1 (full visibility). Pretty basic, but useful for fading on/off a tooltip, a
179
+ menu, a panel, or even view contents. This does not affect layout at all.
178
180
  */
179
181
  type?: string;
180
182
  /**