@enact/ui 4.5.1 → 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.
Files changed (167) 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 +6 -26
  8. package/BodyText/tests/BodyText-specs.js +0 -19
  9. package/Button/Button.js +26 -56
  10. package/Button/tests/Button-specs.js +0 -26
  11. package/CHANGELOG.md +10 -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/tests/FloatingLayer-specs.js +8 -22
  25. package/FloatingLayer/tests/Scrim-specs.js +0 -9
  26. package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +0 -13
  27. package/FloatingLayer/useFloatingLayer.js +3 -14
  28. package/FloatingLayer/useFloatingLayerDecorator.js +3 -11
  29. package/ForwardRef/ForwardRef.js +1 -10
  30. package/GridListImageItem/GridListImageItem.js +17 -50
  31. package/Group/Group.js +4 -35
  32. package/Group/GroupItem.js +15 -32
  33. package/Group/tests/Group-specs.js +0 -32
  34. package/Heading/Heading.js +7 -35
  35. package/Heading/tests/Heading-specs.js +81 -14
  36. package/Icon/Icon.js +14 -48
  37. package/Icon/tests/Icon-specs.js +0 -22
  38. package/IconButton/IconButton.js +12 -50
  39. package/IconButton/tests/IconButton-specs.js +0 -7
  40. package/Image/Image.js +16 -45
  41. package/Image/tests/Image-specs.js +0 -14
  42. package/ImageItem/ImageItem.js +17 -46
  43. package/ImageItem/tests/ImageItem-specs.js +0 -25
  44. package/Item/Item.js +8 -32
  45. package/Item/tests/Item-specs.js +0 -24
  46. package/LabeledIcon/LabeledIcon.js +19 -50
  47. package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
  48. package/Layout/Cell.js +11 -37
  49. package/Layout/Layout.js +14 -37
  50. package/Layout/tests/Layout-specs.js +10 -39
  51. package/Marquee/MarqueeBase.js +31 -64
  52. package/Marquee/MarqueeController.js +11 -72
  53. package/Marquee/MarqueeDecorator.js +62 -196
  54. package/Marquee/index.js +1 -5
  55. package/Marquee/tests/Marquee-specs.js +258 -87
  56. package/Measurable/Measurable.js +12 -34
  57. package/Measurable/tests/Measurable-specs.js +115 -0
  58. package/Media/Media.js +15 -65
  59. package/Media/tests/Media-specs.js +168 -0
  60. package/Placeholder/PlaceholderControllerDecorator.js +7 -43
  61. package/Placeholder/PlaceholderDecorator.js +7 -38
  62. package/Placeholder/index.js +0 -4
  63. package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +25 -0
  64. package/Placeholder/tests/PlaceholderDecorator-specs.js +28 -0
  65. package/ProgressBar/ProgressBar.js +13 -44
  66. package/ProgressBar/tests/ProgressBar-specs.js +0 -17
  67. package/RadioDecorator/RadioControllerDecorator.js +1 -29
  68. package/RadioDecorator/RadioDecorator.js +4 -42
  69. package/RadioDecorator/tests/RadioDecorator-specs.js +12 -49
  70. package/Repeater/Repeater.js +9 -33
  71. package/Repeater/tests/Repeater-specs.js +0 -38
  72. package/Resizable/Resizable.js +7 -35
  73. package/Resizable/tests/Resizable-specs.js +34 -0
  74. package/Routable/Link.js +8 -44
  75. package/Routable/Routable.js +10 -33
  76. package/Routable/Route.js +0 -6
  77. package/Routable/Router.js +13 -56
  78. package/Routable/tests/Routable-specs.js +7 -33
  79. package/Routable/tests/Router-specs.js +18 -44
  80. package/Routable/useLink.js +4 -8
  81. package/Routable/util.js +18 -24
  82. package/Scrollable/ScrollAnimator.js +49 -65
  83. package/Scrollable/ScrollThumb.js +2 -13
  84. package/Scrollable/Scrollable.js +179 -386
  85. package/Scrollable/ScrollableNative.js +188 -391
  86. package/Scrollable/Scrollbar.js +28 -100
  87. package/Scroller/Scroller.js +15 -39
  88. package/Scroller/ScrollerBasic.js +34 -89
  89. package/Scroller/UiScrollerBase.js +31 -84
  90. package/Skinnable/Skinnable.js +11 -38
  91. package/Skinnable/tests/Skinnable-specs.js +3 -74
  92. package/Skinnable/tests/useSkins-specs.js +1 -13
  93. package/Skinnable/tests/util-specs.js +0 -14
  94. package/Skinnable/useSkins.js +8 -15
  95. package/Skinnable/util.js +9 -20
  96. package/Slider/Knob.js +5 -24
  97. package/Slider/PositionDecorator.js +16 -54
  98. package/Slider/Slider.js +26 -64
  99. package/Slider/tests/Slider-specs.js +94 -7
  100. package/Slider/utils.js +0 -2
  101. package/SlotItem/SlotItem.js +15 -41
  102. package/SlotItem/tests/SlotItem-specs.js +0 -5
  103. package/Slottable/Slottable.js +4 -12
  104. package/Slottable/tests/Slottable-specs.js +19 -46
  105. package/Slottable/tests/useSlots-specs.js +27 -65
  106. package/Slottable/useSlots.js +8 -33
  107. package/Spinner/Spinner.js +15 -42
  108. package/Spinner/tests/Spinner-specs.js +0 -15
  109. package/ToggleIcon/ToggleIcon.js +10 -36
  110. package/ToggleIcon/tests/ToggleIcon-specs.js +0 -16
  111. package/ToggleItem/ToggleItem.js +15 -52
  112. package/ToggleItem/tests/ToggleItem-specs.js +0 -30
  113. package/Toggleable/Toggle.js +1 -15
  114. package/Toggleable/Toggleable.js +12 -45
  115. package/Toggleable/tests/Toggleable-specs.js +28 -96
  116. package/Toggleable/useToggle.js +3 -19
  117. package/Touchable/ClickAllow.js +5 -14
  118. package/Touchable/Drag.js +16 -54
  119. package/Touchable/Flick.js +11 -42
  120. package/Touchable/Hold.js +21 -68
  121. package/Touchable/Touch.js +37 -65
  122. package/Touchable/Touchable.js +32 -71
  123. package/Touchable/config.js +8 -22
  124. package/Touchable/tests/Touchable-specs.js +270 -119
  125. package/Touchable/tests/useTouch-specs.js +6 -80
  126. package/Touchable/useTouch.js +17 -34
  127. package/Transition/Transition.js +37 -118
  128. package/Transition/tests/Transition-specs.js +20 -60
  129. package/ViewManager/Arranger.js +10 -22
  130. package/ViewManager/TransitionGroup.js +31 -106
  131. package/ViewManager/View.js +35 -91
  132. package/ViewManager/ViewManager.js +19 -83
  133. package/ViewManager/tests/View-specs.js +0 -17
  134. package/ViewManager/tests/ViewManager-specs.js +236 -305
  135. package/ViewManager/tests/test-utils.js +0 -8
  136. package/VirtualList/UiVirtualListBase.js +256 -406
  137. package/VirtualList/VirtualList.js +29 -69
  138. package/VirtualList/VirtualListBase.js +0 -3
  139. package/VirtualList/VirtualListBasic.js +270 -428
  140. package/VirtualList/tests/VirtualList-specs.js +9 -37
  141. package/internal/IdProvider/IdProvider.js +7 -21
  142. package/internal/IdProvider/Provider.js +4 -17
  143. package/internal/IdProvider/tests/IdProvider-specs.js +44 -0
  144. package/internal/IdProvider/tests/useId-specs.js +7 -22
  145. package/internal/IdProvider/useId.js +0 -6
  146. package/internal/Pure/Pure.js +3 -30
  147. package/internal/Pure/tests/Pure-specs.js +88 -0
  148. package/internal/localized-fonts/localized-fonts.js +33 -62
  149. package/internal/localized-fonts/tests/localized-fonts-specs.js +33 -0
  150. package/internal/selection/selection.js +1 -6
  151. package/internal/selection/tests/selection-specs.js +6 -4
  152. package/internal/validators/tests/validators-specs.js +80 -0
  153. package/internal/validators/validators.js +14 -34
  154. package/package.json +8 -2
  155. package/resolution/ResolutionDecorator.js +4 -40
  156. package/resolution/index.js +0 -7
  157. package/resolution/resolution.js +42 -80
  158. package/resolution/tests/ResolutionDecorator-specs.js +4 -11
  159. package/resolution/tests/resolution-specs.js +2 -2
  160. package/useControlledState/tests/useControlledState-specs.js +15 -46
  161. package/useControlledState/useControlledState.js +11 -22
  162. package/useScroll/ScrollAnimator.js +49 -65
  163. package/useScroll/Scrollbar.js +22 -58
  164. package/useScroll/ScrollbarTrack.js +3 -19
  165. package/useScroll/useScroll.js +267 -454
  166. package/useScroll/utilDOM.js +8 -14
  167. package/useScroll/utilEvent.js +0 -4
@@ -4,68 +4,49 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = exports.Touch = void 0;
7
-
8
7
  var _handle = require("@enact/core/handle");
9
-
10
8
  var _dispatcher = require("@enact/core/dispatcher");
11
-
12
9
  var _complement = _interopRequireDefault(require("ramda/src/complement"));
13
-
14
10
  var _platform = _interopRequireDefault(require("@enact/core/platform"));
15
-
16
11
  var _config = require("./config");
17
-
18
12
  var _state = require("./state");
19
-
20
13
  var _ClickAllow = _interopRequireDefault(require("./ClickAllow"));
21
-
22
14
  var _Drag = require("./Drag");
23
-
24
15
  var _Flick = require("./Flick");
25
-
26
16
  var _Hold = require("./Hold");
27
-
28
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
29
-
30
18
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
31
-
32
19
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
33
-
34
20
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
35
-
36
21
  var getEventCoordinates = function getEventCoordinates(ev) {
37
22
  var x = ev.clientX,
38
- y = ev.clientY,
39
- type = ev.type;
40
-
23
+ y = ev.clientY,
24
+ type = ev.type;
41
25
  if (type.indexOf('touch') === 0) {
42
26
  x = ev.targetTouches[0].clientX;
43
27
  y = ev.targetTouches[0].clientY;
44
28
  }
45
-
46
29
  return {
47
30
  x: x,
48
31
  y: y
49
32
  };
50
- }; // Establish a standard payload for onDown/onUp/onTap events and pass it along to a handler
51
-
33
+ };
52
34
 
35
+ // Establish a standard payload for onDown/onUp/onTap events and pass it along to a handler
53
36
  var makeTouchableEvent = function makeTouchableEvent(type) {
54
37
  return function (ev) {
55
38
  var target = ev.target,
56
- currentTarget = ev.currentTarget;
39
+ currentTarget = ev.currentTarget;
57
40
  var clientX = ev.clientX,
58
- clientY = ev.clientY,
59
- pageX = ev.pageX,
60
- pageY = ev.pageY;
61
-
41
+ clientY = ev.clientY,
42
+ pageX = ev.pageX,
43
+ pageY = ev.pageY;
62
44
  if (ev.changedTouches) {
63
45
  clientX = ev.changedTouches[0].clientX;
64
46
  clientY = ev.changedTouches[0].clientY;
65
47
  pageX = ev.changedTouches[0].pageX;
66
48
  pageY = ev.changedTouches[0].pageY;
67
49
  }
68
-
69
50
  return {
70
51
  type: type,
71
52
  target: target,
@@ -77,45 +58,48 @@ var makeTouchableEvent = function makeTouchableEvent(type) {
77
58
  };
78
59
  };
79
60
  };
80
-
81
61
  var isEnabled = (0, _handle.forProp)('disabled', false);
82
62
  var handleDown = (0, _handle.handle)(isEnabled, (0, _handle.adaptEvent)(makeTouchableEvent('onDown'), (0, _handle.forwardWithPrevent)('onDown')), (0, _handle.call)('activate'), (0, _handle.call)('startGesture')).named('handleDown');
83
63
  var handleUp = (0, _handle.handle)(isEnabled, (0, _handle.call)('endGesture'), (0, _handle.call)('isTracking'), (0, _handle.adaptEvent)(makeTouchableEvent('onUp'), (0, _handle.forwardWithPrevent)('onUp')), (0, _handle.adaptEvent)(makeTouchableEvent('onTap'), (0, _handle.forward)('onTap')))["finally"]((0, _handle.call)('deactivate')).named('handleUp');
84
64
  var handleEnter = (0, _handle.handle)(isEnabled, (0, _handle.forProp)('noResume', false), (0, _handle.call)('enterGesture'), (0, _handle.call)('isPaused'), (0, _handle.call)('activate')).named('handleEnter');
85
- var handleLeave = (0, _handle.handle)(isEnabled, (0, _handle.call)('leaveGesture'), (0, _handle.oneOf)([(0, _handle.forProp)('noResume', false), (0, _handle.call)('pause')], [_handle.returnsTrue, (0, _handle.call)('deactivate')])).named('handleLeave'); // Mouse event handlers
65
+ var handleLeave = (0, _handle.handle)(isEnabled, (0, _handle.call)('leaveGesture'), (0, _handle.oneOf)([(0, _handle.forProp)('noResume', false), (0, _handle.call)('pause')], [_handle.returnsTrue, (0, _handle.call)('deactivate')])).named('handleLeave');
66
+
67
+ // Mouse event handlers
86
68
 
87
69
  var handleMouseDown = (0, _handle.handle)((0, _handle.forward)('onMouseDown'), (0, _handle.call)('shouldAllowMouseEvent'), handleDown);
88
70
  var handleMouseEnter = (0, _handle.handle)((0, _handle.forward)('onMouseEnter'), handleEnter);
89
71
  var handleMouseMove = (0, _handle.handle)((0, _handle.forward)('onMouseMove'), (0, _handle.call)('moveGesture'));
90
72
  var handleMouseLeave = (0, _handle.handle)((0, _handle.forward)('onMouseLeave'), handleLeave);
91
73
  var handleMouseUp = (0, _handle.handle)((0, _handle.returnsTrue)((0, _handle.call)('setLastMouseUp')), (0, _handle.forward)('onMouseUp'), handleUp);
92
- var handleClick = (0, _handle.handle)(isEnabled, // wrapping another handler to always forward onClick but, if onTap should occur, it should
74
+ var handleClick = (0, _handle.handle)(isEnabled,
75
+ // wrapping another handler to always forward onClick but, if onTap should occur, it should
93
76
  // occur first to keep in sync with the up handler which emits onTap first
94
- (0, _handle.handle)((0, _handle.call)('shouldAllowTap'), (0, _handle.call)('activate'), handleUp)["finally"]((0, _handle.forward)('onClick'))); // Touch event handlers
77
+ (0, _handle.handle)((0, _handle.call)('shouldAllowTap'), (0, _handle.call)('activate'), handleUp)["finally"]((0, _handle.forward)('onClick')));
78
+
79
+ // Touch event handlers
95
80
 
96
81
  var handleTouchStart = (0, _handle.handle)((0, _handle.forward)('onTouchStart'), (0, _handle.call)('startTouch'), handleDown);
97
- var handleTouchMove = (0, _handle.handle)((0, _handle.forward)('onTouchMove'), (0, _handle.call)('isTracking'), // we don't receive enter/leave events during a touch so we have to simulate them by
82
+ var handleTouchMove = (0, _handle.handle)((0, _handle.forward)('onTouchMove'), (0, _handle.call)('isTracking'),
83
+ // we don't receive enter/leave events during a touch so we have to simulate them by
98
84
  // detecting when the touch leaves the boundary. oneOf returns the value of whichever
99
85
  // branch it follows so we append moveHold to either to handle moves that aren't
100
86
  // entering or leaving
101
87
  (0, _handle.adaptEvent)(makeTouchableEvent('onMove'), (0, _handle.forward)('onMove')), (0, _handle.oneOf)([(0, _handle.call)('hasTouchLeftTarget'), handleLeave], [_handle.returnsTrue, handleEnter])["finally"]((0, _handle.call)('moveGesture')));
102
- var handleTouchEnd = (0, _handle.handle)((0, _handle.forward)('onTouchEnd'), // block the next mousedown to prevent duplicate touchable events
103
- (0, _handle.returnsTrue)((0, _handle.call)('setLastTouchEnd')), (0, _handle.call)('isTracking'), (0, _complement["default"])((0, _handle.call)('hasTouchLeftTarget')), (0, _handle.returnsTrue)((0, _handle.call)('endTouch')), handleUp); // Global touchend/mouseup event handler to deactivate the component
88
+ var handleTouchEnd = (0, _handle.handle)((0, _handle.forward)('onTouchEnd'),
89
+ // block the next mousedown to prevent duplicate touchable events
90
+ (0, _handle.returnsTrue)((0, _handle.call)('setLastTouchEnd')), (0, _handle.call)('isTracking'), (0, _complement["default"])((0, _handle.call)('hasTouchLeftTarget')), (0, _handle.returnsTrue)((0, _handle.call)('endTouch')), handleUp);
104
91
 
92
+ // Global touchend/mouseup event handler to deactivate the component
105
93
  var handleGlobalUp = (0, _handle.handle)((0, _handle.call)('isTracking'), (0, _handle.call)('deactivate'))["finally"]((0, _handle.call)('endGesture'));
106
94
  var handleGlobalMove = (0, _handle.handle)((0, _handle.call)('isTracking'), (0, _handle.call)('containsCurrentTarget'), (0, _handle.call)('moveGesture'));
107
95
  var handleBlur = (0, _handle.handle)((0, _handle.forward)('onBlur'), (0, _handle.call)('hasFocus'), (0, _handle.call)('blurGesture'));
108
-
109
96
  var Touch = /*#__PURE__*/function () {
110
97
  function Touch() {
111
98
  var _this = this;
112
-
113
99
  _classCallCheck(this, Touch);
114
-
115
100
  this.getHandlers = function () {
116
101
  return _this.handlers;
117
102
  };
118
-
119
103
  this.context = {};
120
104
  this.target = null;
121
105
  this.targetHadFocus = false;
@@ -133,7 +117,6 @@ var Touch = /*#__PURE__*/function () {
133
117
  onMouseLeave: handleMouseLeave.bindAs(this, 'handleMouseLeave'),
134
118
  onMouseUp: handleMouseUp.bindAs(this, 'handleMouseUp')
135
119
  };
136
-
137
120
  if (_platform["default"].touch) {
138
121
  Object.assign(this.handlers, {
139
122
  onTouchStart: handleTouchStart.bindAs(this, 'handleTouchStart'),
@@ -141,11 +124,9 @@ var Touch = /*#__PURE__*/function () {
141
124
  onTouchEnd: handleTouchEnd.bindAs(this, 'handleTouchEnd')
142
125
  });
143
126
  }
144
-
145
127
  handleGlobalUp.bindAs(this, 'handleGlobalUp');
146
128
  handleGlobalMove.bindAs(this, 'handleGlobalMove');
147
129
  }
148
-
149
130
  _createClass(Touch, [{
150
131
  key: "setPropsAndContext",
151
132
  value: function setPropsAndContext(config, state, setState) {
@@ -170,7 +151,6 @@ var Touch = /*#__PURE__*/function () {
170
151
  if (_platform["default"].touch) {
171
152
  (0, _dispatcher.on)('touchend', this.handleGlobalUp, document);
172
153
  }
173
-
174
154
  (0, _dispatcher.on)('mouseup', this.handleGlobalUp, document);
175
155
  (0, _dispatcher.on)('mousemove', this.handleGlobalMove, document);
176
156
  }
@@ -180,11 +160,11 @@ var Touch = /*#__PURE__*/function () {
180
160
  if (_platform["default"].touch) {
181
161
  (0, _dispatcher.off)('touchend', this.handleGlobalUp, document);
182
162
  }
183
-
184
163
  (0, _dispatcher.off)('mouseup', this.handleGlobalUp, document);
185
164
  (0, _dispatcher.off)('mousemove', this.handleGlobalMove, document);
186
- } // State Management
165
+ }
187
166
 
167
+ // State Management
188
168
  }, {
189
169
  key: "setTarget",
190
170
  value: function setTarget(target) {
@@ -199,22 +179,18 @@ var Touch = /*#__PURE__*/function () {
199
179
  key: "activate",
200
180
  value: function activate(ev) {
201
181
  this.setTarget(ev.currentTarget);
202
-
203
182
  if (this.props.getActive) {
204
183
  this.context.setState(_state.States.Active);
205
184
  }
206
-
207
185
  return true;
208
186
  }
209
187
  }, {
210
188
  key: "deactivate",
211
189
  value: function deactivate() {
212
190
  this.clearTarget();
213
-
214
191
  if (this.props.getActive) {
215
192
  this.context.setState(_state.States.Inactive);
216
193
  }
217
-
218
194
  return true;
219
195
  }
220
196
  }, {
@@ -223,7 +199,6 @@ var Touch = /*#__PURE__*/function () {
223
199
  if (this.props.getActive && this.context.state === _state.States.Active) {
224
200
  this.context.setState(_state.States.Paused);
225
201
  }
226
-
227
202
  return true;
228
203
  }
229
204
  }, {
@@ -239,20 +214,19 @@ var Touch = /*#__PURE__*/function () {
239
214
  this.hold.updateProps(props);
240
215
  this.flick.updateProps(props);
241
216
  this.drag.updateProps(props);
242
- } // Gesture Support
217
+ }
243
218
 
219
+ // Gesture Support
244
220
  }, {
245
221
  key: "startTouch",
246
222
  value: function startTouch(_ref) {
247
223
  var target = _ref.target,
248
- currentTarget = _ref.currentTarget;
249
-
224
+ currentTarget = _ref.currentTarget;
250
225
  if (currentTarget.contains(target)) {
251
226
  (0, _dispatcher.on)('contextmenu', _handle.preventDefault);
252
227
  this.targetBounds = currentTarget.getBoundingClientRect();
253
228
  return true;
254
229
  }
255
-
256
230
  return false;
257
231
  }
258
232
  }, {
@@ -266,9 +240,9 @@ var Touch = /*#__PURE__*/function () {
266
240
  value: function startGesture(ev, props) {
267
241
  var coords = getEventCoordinates(ev);
268
242
  var _this$config = this.config,
269
- hold = _this$config.hold,
270
- flick = _this$config.flick,
271
- drag = _this$config.drag;
243
+ hold = _this$config.hold,
244
+ flick = _this$config.flick,
245
+ drag = _this$config.drag;
272
246
  this.hold.begin(hold, props, coords);
273
247
  this.flick.begin(flick, props, coords);
274
248
  this.drag.begin(drag, props, coords, this.target);
@@ -315,8 +289,9 @@ var Touch = /*#__PURE__*/function () {
315
289
  this.flick.end();
316
290
  this.drag.end();
317
291
  return true;
318
- } // Event handler utilities
292
+ }
319
293
 
294
+ // Event handler utilities
320
295
  }, {
321
296
  key: "isTracking",
322
297
  value: function isTracking() {
@@ -337,15 +312,14 @@ var Touch = /*#__PURE__*/function () {
337
312
  key: "hasTouchLeftTarget",
338
313
  value: function hasTouchLeftTarget(ev) {
339
314
  var _this2 = this;
340
-
341
315
  return Array.from(ev.changedTouches).reduce(function (hasLeft, _ref2) {
342
316
  var pageX = _ref2.pageX,
343
- pageY = _ref2.pageY;
317
+ pageY = _ref2.pageY;
344
318
  var _this2$targetBounds = _this2.targetBounds,
345
- left = _this2$targetBounds.left,
346
- right = _this2$targetBounds.right,
347
- top = _this2$targetBounds.top,
348
- bottom = _this2$targetBounds.bottom;
319
+ left = _this2$targetBounds.left,
320
+ right = _this2$targetBounds.right,
321
+ top = _this2$targetBounds.top,
322
+ bottom = _this2$targetBounds.bottom;
349
323
  return hasLeft && left > pageX || right < pageX || top > pageY || bottom < pageY;
350
324
  }, true);
351
325
  }
@@ -376,10 +350,8 @@ var Touch = /*#__PURE__*/function () {
376
350
  this.clickAllow.setLastTouchEnd(ev);
377
351
  }
378
352
  }]);
379
-
380
353
  return Touch;
381
354
  }();
382
-
383
355
  exports.Touch = Touch;
384
356
  var _default = Touch;
385
357
  exports["default"] = _default;
@@ -17,79 +17,59 @@ Object.defineProperty(exports, "useTouch", {
17
17
  return _useTouch["default"];
18
18
  }
19
19
  });
20
-
21
20
  var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
22
-
23
21
  var _propTypes = _interopRequireDefault(require("prop-types"));
24
-
25
22
  var _react = require("react");
26
-
27
23
  var _config = require("./config");
28
-
29
24
  var _Drag = require("./Drag");
30
-
31
25
  var _Flick = require("./Flick");
32
-
33
26
  var _Hold = require("./Hold");
34
-
35
27
  var _useTouch = _interopRequireDefault(require("./useTouch"));
36
-
37
28
  var _jsxRuntime = require("react/jsx-runtime");
38
-
39
29
  var _excluded = ["dragConfig", "flickConfig", "holdConfig", "disabled", "noResume", "onBlur", "onClick", "onMouseDown", "onMouseEnter", "onMouseLeave", "onMouseMove", "onMouseUp", "onTouchEnd", "onTouchMove", "onTouchStart", "onDown", "onDrag", "onDragEnd", "onDragStart", "onFlick", "onHold", "onHoldEnd", "onHoldStart", "onMove", "onTap", "onUp"];
40
-
41
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
42
-
43
31
  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; }
44
-
45
32
  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; }
46
-
47
33
  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; }
48
-
49
34
  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; }
50
-
51
35
  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; }
52
-
53
36
  var selectProps = function selectProps(props) {
54
37
  var dragConfig = props.dragConfig,
55
- flickConfig = props.flickConfig,
56
- holdConfig = props.holdConfig,
57
- disabled = props.disabled,
58
- noResume = props.noResume,
59
- onBlur = props.onBlur,
60
- onClick = props.onClick,
61
- onMouseDown = props.onMouseDown,
62
- onMouseEnter = props.onMouseEnter,
63
- onMouseLeave = props.onMouseLeave,
64
- onMouseMove = props.onMouseMove,
65
- onMouseUp = props.onMouseUp,
66
- onTouchEnd = props.onTouchEnd,
67
- onTouchMove = props.onTouchMove,
68
- onTouchStart = props.onTouchStart,
69
- onDown = props.onDown,
70
- onDrag = props.onDrag,
71
- onDragEnd = props.onDragEnd,
72
- onDragStart = props.onDragStart,
73
- onFlick = props.onFlick,
74
- onHold = props.onHold,
75
- onHoldEnd = props.onHoldEnd,
76
- onHoldStart = props.onHoldStart,
77
- onMove = props.onMove,
78
- onTap = props.onTap,
79
- onUp = props.onUp,
80
- rest = _objectWithoutProperties(props, _excluded);
81
-
38
+ flickConfig = props.flickConfig,
39
+ holdConfig = props.holdConfig,
40
+ disabled = props.disabled,
41
+ noResume = props.noResume,
42
+ onBlur = props.onBlur,
43
+ onClick = props.onClick,
44
+ onMouseDown = props.onMouseDown,
45
+ onMouseEnter = props.onMouseEnter,
46
+ onMouseLeave = props.onMouseLeave,
47
+ onMouseMove = props.onMouseMove,
48
+ onMouseUp = props.onMouseUp,
49
+ onTouchEnd = props.onTouchEnd,
50
+ onTouchMove = props.onTouchMove,
51
+ onTouchStart = props.onTouchStart,
52
+ onDown = props.onDown,
53
+ onDrag = props.onDrag,
54
+ onDragEnd = props.onDragEnd,
55
+ onDragStart = props.onDragStart,
56
+ onFlick = props.onFlick,
57
+ onHold = props.onHold,
58
+ onHoldEnd = props.onHoldEnd,
59
+ onHoldStart = props.onHoldStart,
60
+ onMove = props.onMove,
61
+ onTap = props.onTap,
62
+ onUp = props.onUp,
63
+ rest = _objectWithoutProperties(props, _excluded);
82
64
  return {
83
65
  configForHook: {
84
66
  /* configs */
85
67
  dragConfig: dragConfig,
86
68
  flickConfig: flickConfig,
87
69
  holdConfig: holdConfig,
88
-
89
70
  /* general props */
90
71
  disabled: disabled,
91
72
  noResume: noResume,
92
-
93
73
  /* events to be captured and forwarded by useTouch hook */
94
74
  onBlur: onBlur,
95
75
  onClick: onClick,
@@ -101,7 +81,6 @@ var selectProps = function selectProps(props) {
101
81
  onTouchEnd: onTouchEnd,
102
82
  onTouchMove: onTouchMove,
103
83
  onTouchStart: onTouchStart,
104
-
105
84
  /* custom events to be forwarded by useTouch hook */
106
85
  onDown: onDown,
107
86
  onDrag: onDrag,
@@ -120,14 +99,13 @@ var selectProps = function selectProps(props) {
120
99
  }, rest)
121
100
  };
122
101
  };
102
+
123
103
  /**
124
104
  * Default config for `Touchable`.
125
105
  *
126
106
  * @memberof ui/Touchable.Touchable
127
107
  * @hocconfig
128
108
  */
129
-
130
-
131
109
  var defaultConfig = {
132
110
  /**
133
111
  * Configures the prop name to pass the active state to the wrapped component
@@ -138,6 +116,7 @@ var defaultConfig = {
138
116
  */
139
117
  activeProp: null
140
118
  };
119
+
141
120
  /**
142
121
  * A higher-order component that provides a consistent set of pointer events -- `onDown`, `onUp`,
143
122
  * and `onTap` -- across mouse and touch interfaces along with support for common gestures including
@@ -151,24 +130,21 @@ var defaultConfig = {
151
130
  * @hoc
152
131
  * @public
153
132
  */
154
-
155
133
  var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
156
- var activeProp = config.activeProp; // eslint-disable-next-line no-shadow
134
+ var activeProp = config.activeProp;
157
135
 
136
+ // eslint-disable-next-line no-shadow
158
137
  var Touchable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
159
138
  var _selectProps = selectProps(props),
160
- configForHook = _selectProps.configForHook,
161
- propsForWrapped = _selectProps.propsForWrapped;
162
-
139
+ configForHook = _selectProps.configForHook,
140
+ propsForWrapped = _selectProps.propsForWrapped;
163
141
  var hook = (0, _useTouch["default"])(_objectSpread({
164
142
  getActive: !!activeProp
165
143
  }, configForHook));
166
144
  Object.assign(propsForWrapped, hook.handlers);
167
-
168
145
  if (activeProp) {
169
146
  propsForWrapped[activeProp] = hook.active;
170
147
  }
171
-
172
148
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread(_objectSpread({}, propsForWrapped), {}, {
173
149
  ref: ref
174
150
  }));
@@ -183,7 +159,6 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
183
159
  * @public
184
160
  */
185
161
  disabled: _propTypes["default"].bool,
186
-
187
162
  /**
188
163
  * Instance-specific overrides of the drag configuration.
189
164
  *
@@ -193,7 +168,6 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
193
168
  * @public
194
169
  */
195
170
  dragConfig: _Drag.dragConfigPropType,
196
-
197
171
  /**
198
172
  * Instance-specific overrides of the flick configuration.
199
173
  *
@@ -203,7 +177,6 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
203
177
  * @public
204
178
  */
205
179
  flickConfig: _Flick.flickConfigPropType,
206
-
207
180
  /**
208
181
  * Instance-specific overrides of the hold configuration.
209
182
  *
@@ -213,7 +186,6 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
213
186
  * @public
214
187
  */
215
188
  holdConfig: _Hold.holdConfigPropType,
216
-
217
189
  /**
218
190
  * Prevents resuming the touch events and gestures when re-entering the component.
219
191
  *
@@ -223,7 +195,6 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
223
195
  * @public
224
196
  */
225
197
  noResume: _propTypes["default"].bool,
226
-
227
198
  /**
228
199
  * Event handler for 'down' pointer events.
229
200
  *
@@ -232,7 +203,6 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
232
203
  * @public
233
204
  */
234
205
  onDown: _propTypes["default"].func,
235
-
236
206
  /**
237
207
  * Event handler for a drag gesture.
238
208
  *
@@ -247,7 +217,6 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
247
217
  * @public
248
218
  */
249
219
  onDrag: _propTypes["default"].func,
250
-
251
220
  /**
252
221
  * Event handler for the end of a drag gesture.
253
222
  *
@@ -260,7 +229,6 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
260
229
  * @public
261
230
  */
262
231
  onDragEnd: _propTypes["default"].func,
263
-
264
232
  /**
265
233
  * Event handler for the start of a drag gesture.
266
234
  *
@@ -275,7 +243,6 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
275
243
  * @public
276
244
  */
277
245
  onDragStart: _propTypes["default"].func,
278
-
279
246
  /**
280
247
  * Event handler for a flick gesture.
281
248
  *
@@ -292,7 +259,6 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
292
259
  * @public
293
260
  */
294
261
  onFlick: _propTypes["default"].func,
295
-
296
262
  /**
297
263
  * Event handler for hold pulse events.
298
264
  *
@@ -306,7 +272,6 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
306
272
  * @public
307
273
  */
308
274
  onHold: _propTypes["default"].func,
309
-
310
275
  /**
311
276
  * Event handler for the end of hold events.
312
277
  *
@@ -320,7 +285,6 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
320
285
  * @public
321
286
  */
322
287
  onHoldEnd: _propTypes["default"].func,
323
-
324
288
  /**
325
289
  * Event handler for hold events.
326
290
  *
@@ -336,7 +300,6 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
336
300
  * @public
337
301
  */
338
302
  onHoldStart: _propTypes["default"].func,
339
-
340
303
  /**
341
304
  * Event handler for 'move' pointer events.
342
305
  *
@@ -345,7 +308,6 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
345
308
  * @public
346
309
  */
347
310
  onMove: _propTypes["default"].func,
348
-
349
311
  /**
350
312
  * Event handler for 'tap' pointer events.
351
313
  *
@@ -354,7 +316,6 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
354
316
  * @public
355
317
  */
356
318
  onTap: _propTypes["default"].func,
357
-
358
319
  /**
359
320
  * Event handler for 'up' pointer events.
360
321
  *
@@ -4,48 +4,41 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.resetDefaultConfig = exports.mergeConfig = exports.getConfig = exports["default"] = exports.configure = void 0;
7
-
8
7
  var _Drag = require("./Drag.js");
9
-
10
8
  var _Flick = require("./Flick.js");
11
-
12
9
  var _Hold = require("./Hold.js");
13
-
14
10
  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; }
15
-
16
11
  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; }
17
-
18
12
  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; }
19
-
20
13
  var allowedDragKeys = Object.keys(_Drag.defaultDragConfig);
21
14
  var allowedFlickKeys = Object.keys(_Flick.defaultFlickConfig);
22
15
  var allowedHoldKeys = Object.keys(_Hold.defaultHoldConfig);
16
+
23
17
  /**
24
18
  * The Global Gesture Configuration Object
25
19
  *
26
20
  * @private
27
21
  * @memberof ui/Touchable
28
22
  */
23
+ var config = {};
29
24
 
30
- var config = {}; // map-friendly clone method
31
-
25
+ // map-friendly clone method
32
26
  var clone = function clone(o) {
33
27
  return Object.assign({}, o);
34
- }; // Merges two configuation objects while retaining only the allowed keys
35
-
28
+ };
36
29
 
30
+ // Merges two configuation objects while retaining only the allowed keys
37
31
  var mergeGestureConfig = function mergeGestureConfig(current, update, allowed) {
38
32
  var cfg = _objectSpread(_objectSpread({}, current), update);
39
-
40
33
  Object.keys(cfg).forEach(function (key) {
41
34
  if (allowed.indexOf(key) === -1) {
42
35
  delete cfg[key];
43
36
  }
44
37
  });
45
38
  return cfg;
46
- }; // Merges the current global config with the provided `cfg` and returns the result
47
-
39
+ };
48
40
 
41
+ // Merges the current global config with the provided `cfg` and returns the result
49
42
  var mergeConfig = function mergeConfig(cfg) {
50
43
  var merged = {
51
44
  drag: mergeGestureConfig(config.drag, cfg.drag, allowedDragKeys),
@@ -55,6 +48,7 @@ var mergeConfig = function mergeConfig(cfg) {
55
48
  merged.hold.events = merged.hold.events.map(clone);
56
49
  return merged;
57
50
  };
51
+
58
52
  /**
59
53
  * Configures the global gesture configuration for the application.
60
54
  *
@@ -117,22 +111,15 @@ var mergeConfig = function mergeConfig(cfg) {
117
111
  * @public
118
112
  * @memberof ui/Touchable
119
113
  */
120
-
121
-
122
114
  exports.mergeConfig = mergeConfig;
123
-
124
115
  var configure = function configure(cfg) {
125
116
  config = mergeConfig(cfg);
126
117
  };
127
-
128
118
  exports.configure = configure;
129
-
130
119
  var getConfig = function getConfig() {
131
120
  return config;
132
121
  };
133
-
134
122
  exports.getConfig = getConfig;
135
-
136
123
  var resetDefaultConfig = function resetDefaultConfig() {
137
124
  return configure({
138
125
  drag: _Drag.defaultDragConfig,
@@ -140,7 +127,6 @@ var resetDefaultConfig = function resetDefaultConfig() {
140
127
  flick: _Flick.defaultFlickConfig
141
128
  });
142
129
  };
143
-
144
130
  exports.resetDefaultConfig = resetDefaultConfig;
145
131
  resetDefaultConfig();
146
132
  var _default = configure;