@enact/ui 4.1.2 → 4.1.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 (84) hide show
  1. package/AnnounceDecorator/tests/Announce-specs.js +13 -5
  2. package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +9 -7
  3. package/AnnounceDecorator/tests/useAnnounce-specs.js +25 -17
  4. package/BodyText/BodyText.d.ts +1 -1
  5. package/BodyText/tests/BodyText-specs.js +49 -35
  6. package/Button/Button.d.ts +6 -6
  7. package/Button/tests/Button-specs.js +104 -3
  8. package/CHANGELOG.md +4 -0
  9. package/Cancelable/Cancelable.js +1 -1
  10. package/Cancelable/tests/Cancelable-specs.js +131 -70
  11. package/Changeable/tests/Changeable-specs.js +162 -110
  12. package/FloatingLayer/FloatingLayer.js +5 -17
  13. package/FloatingLayer/tests/FloatingLayer-specs.js +83 -8
  14. package/FloatingLayer/tests/Scrim-specs.js +20 -11
  15. package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +15 -9
  16. package/GridListImageItem/GridListImageItem.d.ts +1 -1
  17. package/Group/Group.d.ts +2 -2
  18. package/Group/tests/Group-specs.js +71 -41
  19. package/Heading/Heading.d.ts +2 -1
  20. package/Heading/tests/Heading-specs.js +27 -20
  21. package/Icon/Icon.d.ts +4 -4
  22. package/Icon/tests/Icon-specs.js +52 -31
  23. package/IconButton/IconButton.d.ts +4 -4
  24. package/IconButton/tests/IconButton-specs.js +2 -2
  25. package/Image/tests/Image-specs.js +39 -29
  26. package/ImageItem/tests/ImageItem-specs.js +71 -68
  27. package/Item/tests/Item-specs.js +59 -35
  28. package/LabeledIcon/LabeledIcon.d.ts +4 -4
  29. package/LabeledIcon/tests/LabeledIcon-specs.js +30 -19
  30. package/Layout/Layout.d.ts +16 -16
  31. package/Layout/tests/Layout-specs.js +37 -25
  32. package/Marquee/MarqueeBase.js +1 -5
  33. package/Marquee/tests/Marquee-specs.js +221 -116
  34. package/Media/Media.js +1 -3
  35. package/ProgressBar/tests/ProgressBar-specs.js +60 -42
  36. package/README.md +1 -1
  37. package/RadioDecorator/RadioDecorator.js +3 -5
  38. package/RadioDecorator/tests/RadioDecorator-specs.js +179 -65
  39. package/Repeater/Repeater.d.ts +2 -1
  40. package/Repeater/tests/Repeater-specs.js +86 -45
  41. package/Routable/Routable.d.ts +2 -2
  42. package/Routable/tests/Routable-specs.js +26 -17
  43. package/Routable/tests/Router-specs.js +65 -41
  44. package/Scrollable/Scrollable.js +1 -0
  45. package/Scrollable/ScrollableNative.js +1 -0
  46. package/Scroller/Scroller.d.ts +2 -2
  47. package/Skinnable/tests/Skinnable-specs.js +102 -54
  48. package/Skinnable/tests/useSkins-specs.js +37 -42
  49. package/Slider/Slider.d.ts +3 -3
  50. package/Slider/tests/Slider-specs.js +4 -4
  51. package/SlotItem/SlotItem.d.ts +2 -2
  52. package/SlotItem/tests/SlotItem-specs.js +4 -4
  53. package/Slottable/tests/Slottable-specs.js +67 -36
  54. package/Slottable/tests/useSlots-specs.js +68 -35
  55. package/Spinner/Spinner.d.ts +1 -1
  56. package/Spinner/tests/Spinner-specs.js +46 -31
  57. package/ToggleIcon/tests/ToggleIcon-specs.js +32 -20
  58. package/ToggleItem/ToggleItem.d.ts +13 -11
  59. package/ToggleItem/tests/ToggleItem-specs.js +51 -34
  60. package/Toggleable/Toggle.js +6 -6
  61. package/Toggleable/Toggleable.js +6 -12
  62. package/Toggleable/tests/Toggleable-specs.js +428 -324
  63. package/Touchable/Drag.js +13 -17
  64. package/Touchable/Flick.js +20 -16
  65. package/Touchable/Hold.js +14 -19
  66. package/Touchable/Touchable.d.ts +3 -3
  67. package/Touchable/tests/Touchable-specs.js +223 -109
  68. package/Touchable/tests/useTouch-specs.js +159 -84
  69. package/Transition/Transition.d.ts +29 -27
  70. package/Transition/Transition.js +5 -9
  71. package/Transition/tests/Transition-specs.js +135 -31
  72. package/ViewManager/TransitionGroup.js +6 -5
  73. package/ViewManager/View.js +1 -1
  74. package/ViewManager/ViewManager.d.ts +4 -4
  75. package/ViewManager/ViewManager.js +10 -10
  76. package/ViewManager/tests/View-specs.js +109 -81
  77. package/ViewManager/tests/ViewManager-specs.js +471 -185
  78. package/VirtualList/VirtualList.d.ts +11 -9
  79. package/VirtualList/tests/VirtualList-specs.js +44 -31
  80. package/internal/IdProvider/tests/useId-specs.js +35 -18
  81. package/package.json +11 -11
  82. package/resolution/tests/ResolutionDecorator-specs.js +17 -8
  83. package/styles/mixins.less +14 -2
  84. package/useControlledState/tests/useControlledState-specs.js +67 -42
package/Touchable/Drag.js CHANGED
@@ -98,11 +98,11 @@ var Drag = function Drag() {
98
98
  _this.startY = y;
99
99
  _this.dragConfig = _objectSpread(_objectSpread({}, config), {}, {
100
100
  node: node,
101
- onDragStart: onDragStart,
102
- onDragEnd: onDragEnd,
103
- onDrag: onDrag,
104
101
  resume: !noResume
105
102
  });
103
+ _this.onDrag = onDrag;
104
+ _this.onDragStart = onDragStart;
105
+ _this.onDragEnd = onDragEnd;
106
106
 
107
107
  _this.setContainerBounds(node);
108
108
 
@@ -116,17 +116,14 @@ var Drag = function Drag() {
116
116
  // Check `isDragging` gesture is not in progress. Check if gesture exists before updating the references to the `dragConfig`
117
117
  if (!_this.isDragging()) return; // This will update the `dragConfig` with the new value
118
118
 
119
- _this.dragConfig.onDragStart = onDragStart;
120
- _this.dragConfig.onDrag = onDrag;
121
- _this.dragConfig.onDragEnd = onDragEnd;
119
+ _this.onDrag = onDrag;
120
+ _this.onDragStart = onDragStart;
121
+ _this.onDragEnd = onDragEnd;
122
122
  };
123
123
 
124
124
  this.move = function (coords) {
125
125
  if (!_this.isDragging()) return;
126
- var _this$dragConfig2 = _this.dragConfig,
127
- moveTolerance = _this$dragConfig2.moveTolerance,
128
- onDrag = _this$dragConfig2.onDrag,
129
- onDragStart = _this$dragConfig2.onDragStart;
126
+ var moveTolerance = _this.dragConfig.moveTolerance;
130
127
 
131
128
  if (_this.tracking === Tracking.Untracked) {
132
129
  var dx = coords.x - _this.startX;
@@ -135,14 +132,14 @@ var Drag = function Drag() {
135
132
  if (Math.sqrt(dx * dx + dy * dy) >= moveTolerance) {
136
133
  _this.tracking = Tracking.Active;
137
134
 
138
- if (onDragStart) {
139
- onDragStart(_objectSpread({
135
+ if (_this.onDragStart) {
136
+ _this.onDragStart(_objectSpread({
140
137
  type: 'onDragStart'
141
138
  }, coords));
142
139
  }
143
140
  }
144
- } else if (onDrag && _this.tracking === Tracking.Active && _this.updatePosition(coords)) {
145
- onDrag(_objectSpread({
141
+ } else if (_this.onDrag && _this.tracking === Tracking.Active && _this.updatePosition(coords)) {
142
+ _this.onDrag(_objectSpread({
146
143
  type: 'onDrag'
147
144
  }, coords));
148
145
  }
@@ -158,10 +155,9 @@ var Drag = function Drag() {
158
155
 
159
156
  this.end = function () {
160
157
  if (!_this.isDragging()) return;
161
- var onDragEnd = _this.dragConfig.onDragEnd;
162
158
 
163
- if (onDragEnd && _this.tracking !== Tracking.Untracked) {
164
- onDragEnd({
159
+ if (_this.onDragEnd && _this.tracking !== Tracking.Untracked) {
160
+ _this.onDragEnd({
165
161
  type: 'onDragEnd'
166
162
  });
167
163
  }
@@ -11,6 +11,12 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
13
 
14
+ 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
+
16
+ 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
+
18
+ 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
+
14
20
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
21
 
16
22
  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); } }
@@ -23,16 +29,12 @@ var Flick = /*#__PURE__*/function () {
23
29
 
24
30
  _classCallCheck(this, Flick);
25
31
 
26
- this.begin = function (_ref, _ref2, coords) {
27
- var maxDuration = _ref.maxDuration,
28
- maxMoves = _ref.maxMoves,
29
- minVelocity = _ref.minVelocity;
30
- var onFlick = _ref2.onFlick;
31
- _this.minVelocity = minVelocity;
32
- _this.maxMoves = maxMoves;
32
+ this.begin = function (config, _ref, coords) {
33
+ var onFlick = _ref.onFlick;
34
+ _this.flickConfig = _objectSpread({}, config);
33
35
 
34
- if (maxDuration !== null) {
35
- _this.cancelJob.startAfter(maxDuration);
36
+ if (_this.flickConfig.maxDuration !== null) {
37
+ _this.cancelJob.startAfter(_this.flickConfig.maxDuration);
36
38
  }
37
39
 
38
40
  _this.tracking = !!onFlick;
@@ -42,18 +44,19 @@ var Flick = /*#__PURE__*/function () {
42
44
  _this.move(coords);
43
45
  };
44
46
 
45
- this.updateProps = function (_ref3) {
46
- var onFlick = _ref3.onFlick;
47
+ this.updateProps = function (_ref2) {
48
+ var onFlick = _ref2.onFlick;
47
49
  // Check `tracking` gesture is not in progress. Check if gesture exists before updating the references to the `onFlick`
48
50
  if (!_this.tracking) return; // This will update the `onFlick` with the new value
49
51
 
50
52
  _this.onFlick = onFlick;
51
53
  };
52
54
 
53
- this.move = function (_ref4) {
54
- var x = _ref4.x,
55
- y = _ref4.y;
55
+ this.move = function (_ref3) {
56
+ var x = _ref3.x,
57
+ y = _ref3.y;
56
58
  if (!_this.tracking) return;
59
+ var maxMoves = _this.flickConfig.maxMoves;
57
60
 
58
61
  _this.moves.push({
59
62
  x: x,
@@ -62,7 +65,7 @@ var Flick = /*#__PURE__*/function () {
62
65
  }); // track specified # of points
63
66
 
64
67
 
65
- if (_this.moves.length > _this.maxMoves) {
68
+ if (_this.moves.length > maxMoves) {
66
69
  _this.moves.shift();
67
70
  }
68
71
  };
@@ -79,6 +82,7 @@ var Flick = /*#__PURE__*/function () {
79
82
 
80
83
  this.end = function () {
81
84
  if (!_this.tracking) return;
85
+ var minVelocity = _this.flickConfig.minVelocity;
82
86
 
83
87
  _this.cancelJob.stop();
84
88
 
@@ -106,7 +110,7 @@ var Flick = /*#__PURE__*/function () {
106
110
 
107
111
  var v = Math.sqrt(x * x + y * y);
108
112
 
109
- if (v > _this.minVelocity) {
113
+ if (v > minVelocity) {
110
114
  var vertical = Math.abs(y) > Math.abs(x); // generate the flick using the start event so it has those coordinates
111
115
  // this.sendFlick(ti.startEvent, x, y, v);
112
116
 
package/Touchable/Hold.js CHANGED
@@ -52,11 +52,11 @@ var Hold = /*#__PURE__*/function () {
52
52
  _this.startX = x;
53
53
  _this.startY = y;
54
54
  _this.holdConfig = _objectSpread(_objectSpread(_objectSpread({}, defaultConfig), holdConfig), {}, {
55
- onHoldStart: onHoldStart,
56
- onHoldEnd: onHoldEnd,
57
- onHold: onHold,
58
55
  resume: !noResume
59
- }); // copy the events array since it is mutated for each hold
56
+ });
57
+ _this.onHold = onHold;
58
+ _this.onHoldStart = onHoldStart;
59
+ _this.onHoldEnd = onHoldEnd; // copy the events array since it is mutated for each hold
60
60
 
61
61
  _this.holdConfig.events = _this.holdConfig.events.slice();
62
62
 
@@ -83,9 +83,9 @@ var Hold = /*#__PURE__*/function () {
83
83
  // check `isHolding` gesture is not in progress. Check if gesture exists before updating the references to the `holdConfig`
84
84
  if (!_this.isHolding()) return; // Update the original values with new values of the gestures
85
85
 
86
- _this.holdConfig.onHold = onHold;
87
- _this.holdConfig.onHoldStart = onHoldStart;
88
- _this.holdConfig.onHoldEnd = onHoldEnd;
86
+ _this.onHold = onHold;
87
+ _this.onHoldStart = onHoldStart;
88
+ _this.onHoldEnd = onHoldEnd;
89
89
  };
90
90
 
91
91
  this.move = function (coords) {
@@ -119,12 +119,11 @@ var Hold = /*#__PURE__*/function () {
119
119
 
120
120
  this.end = function () {
121
121
  if (!_this.isHolding()) return;
122
- var onHoldEnd = _this.holdConfig.onHoldEnd;
123
122
 
124
- if (_this.pulsing && onHoldEnd) {
123
+ if (_this.pulsing && _this.onHoldEnd) {
125
124
  var time = window.performance.now() - _this.holdStart;
126
125
 
127
- onHoldEnd({
126
+ _this.onHoldEnd({
128
127
  type: 'onHoldEnd',
129
128
  time: time
130
129
  });
@@ -180,13 +179,11 @@ var Hold = /*#__PURE__*/function () {
180
179
  var n = _this.next;
181
180
 
182
181
  while (n && n.time <= holdTime) {
183
- var _this$holdConfig4 = _this.holdConfig,
184
- events = _this$holdConfig4.events,
185
- onHoldStart = _this$holdConfig4.onHoldStart;
182
+ var events = _this.holdConfig.events;
186
183
  _this.pulsing = true;
187
184
 
188
- if (onHoldStart) {
189
- onHoldStart(_objectSpread({
185
+ if (_this.onHoldStart) {
186
+ _this.onHoldStart(_objectSpread({
190
187
  type: 'onHoldStart'
191
188
  }, n));
192
189
  } // if the hold is canceled from the onHoldStart handler, we should bail early and prevent
@@ -202,10 +199,8 @@ var Hold = /*#__PURE__*/function () {
202
199
  }
203
200
 
204
201
  if (_this.pulsing) {
205
- var onHold = _this.holdConfig.onHold;
206
-
207
- if (onHold) {
208
- onHold({
202
+ if (_this.onHold) {
203
+ _this.onHold({
209
204
  type: 'onHold',
210
205
  time: holdTime
211
206
  });
@@ -93,7 +93,7 @@ export interface TouchableProps {
93
93
  * * `type` - Type of event, `'onHoldStart'`
94
94
  * * `name` - The name of the hold as configured in the events list
95
95
  * * `time` - Time, in milliseconds, configured for this hold which may vary slightly
96
- from time since the hold began
96
+ from time since the hold began
97
97
  */
98
98
  onHoldStart?: Function;
99
99
  /**
@@ -146,7 +146,7 @@ Only applies when `global` is `false` .
146
146
  * * `'border-box'` - the default, includes the padding and border but excludes the margin.
147
147
  * * `'content-box'` - excludes the padding, border, and margin.
148
148
  * * `global` - When `true` , drag gestures will continue when leaving the bounds of the component
149
- or blurring the component.
149
+ or blurring the component.
150
150
  * * `moveTolerance` - The number of pixels from the start position of the drag that the pointer
151
151
  may move before cancelling the drag. Defaults to `16` .
152
152
  *
@@ -161,7 +161,7 @@ time per move, that must be exceeded to generate a `onFlick` event.
161
161
  * * `cancelOnMove` - When `true` , the hold is cancelled when moving beyond the `moveTolerance` .
162
162
  Defaults to `false`
163
163
  * * `global` - When `true` , hold gestures will continue when leaving the bounds of the component
164
- or blurring the component.
164
+ or blurring the component.
165
165
  * * `moveTolerance` - The number of pixels from the start position of the hold that the pointer
166
166
  may move before cancelling the hold. Ignored when `cancelOnMove` is `false` . Defaults to
167
167
  `16` .