@enact/ui 4.6.0 → 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 (65) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/FloatingLayer/package.json +3 -0
  3. package/IconButton/IconButton.js +7 -2
  4. package/RadioDecorator/RadioControllerDecorator.js +6 -0
  5. package/RadioDecorator/RadioDecorator.js +5 -0
  6. package/Scroller/UiScrollerBase.js +6 -0
  7. package/SlotItem/SlotItem.js +6 -2
  8. package/ToggleItem/ToggleItem.js +6 -2
  9. package/Touchable/Pinch.js +185 -0
  10. package/Touchable/Touch.js +34 -11
  11. package/Touchable/Touchable.js +63 -4
  12. package/Touchable/config.js +19 -2
  13. package/Touchable/tests/Touchable-specs.js +96 -6
  14. package/Touchable/useTouch.js +41 -32
  15. package/VirtualList/UiVirtualListBase.js +6 -0
  16. package/package.json +2 -2
  17. package/AnnounceDecorator/AnnounceDecorator.d.ts +0 -64
  18. package/BodyText/BodyText.d.ts +0 -66
  19. package/Button/Button.d.ts +0 -125
  20. package/Cancelable/Cancelable.d.ts +0 -64
  21. package/Changeable/Changeable.d.ts +0 -54
  22. package/ComponentOverride/ComponentOverride.d.ts +0 -52
  23. package/ForwardRef/ForwardRef.d.ts +0 -22
  24. package/GridListImageItem/GridListImageItem.d.ts +0 -85
  25. package/Group/Group.d.ts +0 -107
  26. package/Heading/Heading.d.ts +0 -90
  27. package/Icon/Icon.d.ts +0 -88
  28. package/IconButton/IconButton.d.ts +0 -115
  29. package/Image/Image.d.ts +0 -113
  30. package/ImageItem/ImageItem.d.ts +0 -83
  31. package/Item/Item.d.ts +0 -64
  32. package/LabeledIcon/LabeledIcon.d.ts +0 -130
  33. package/Layout/Layout.d.ts +0 -247
  34. package/Marquee/index.d.ts +0 -258
  35. package/Measurable/Measurable.d.ts +0 -26
  36. package/Media/Media.d.ts +0 -99
  37. package/Placeholder/index.d.ts +0 -53
  38. package/ProgressBar/ProgressBar.d.ts +0 -92
  39. package/RadioDecorator/RadioDecorator.d.ts +0 -35
  40. package/Repeater/Repeater.d.ts +0 -83
  41. package/Resizable/Resizable.d.ts +0 -31
  42. package/Routable/Routable.d.ts +0 -148
  43. package/Scrollable/Scrollable.d.ts +0 -0
  44. package/Scroller/Scroller.d.ts +0 -276
  45. package/Skinnable/Skinnable.d.ts +0 -94
  46. package/Slider/Slider.d.ts +0 -202
  47. package/SlotItem/SlotItem.d.ts +0 -118
  48. package/Slottable/Slottable.d.ts +0 -22
  49. package/Spinner/Spinner.d.ts +0 -95
  50. package/ToggleIcon/ToggleIcon.d.ts +0 -90
  51. package/ToggleItem/ToggleItem.d.ts +0 -134
  52. package/Toggleable/Toggleable.d.ts +0 -103
  53. package/Touchable/Touchable.d.ts +0 -175
  54. package/Transition/Transition.d.ts +0 -196
  55. package/ViewManager/ViewManager.d.ts +0 -191
  56. package/VirtualList/VirtualList.d.ts +0 -530
  57. package/index.d.ts +0 -0
  58. package/internal/IdProvider/IdProvider.d.ts +0 -0
  59. package/internal/Pure/Pure.d.ts +0 -0
  60. package/internal/localized-fonts/localized-fonts.d.ts +0 -53
  61. package/internal/selection/selection.d.ts +0 -0
  62. package/internal/validators/validators.d.ts +0 -0
  63. package/resolution/index.d.ts +0 -187
  64. package/useControlledState/useControlledState.d.ts +0 -0
  65. package/useScroll/useScroll.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  The following is a curated list of changes in the Enact ui module, newest changes on the top.
4
4
 
5
+ ## [4.6.1] - 2023-02-03
6
+
7
+ ### Added
8
+
9
+ - `ui/Touchable` events `onPinch`, `onPinchStart`, `onPinchEnd`, and config `pinchConfig` to support pinch gesture
10
+
11
+ ### Deprecated
12
+
13
+ - `ui/IconButton` to be removed in 5.0.0, use `ui/Button` instead
14
+ - `ui/RadioDecorator` to be removed in 5.0.0
15
+ - `ui/Scroller.ScrollerBase` to be removed in 5.0.0
16
+ - `ui/SlotItem` to be removed in 5.0.0
17
+ - `ui/ToggleItem` to be removed in 5.0.0
18
+ - `ui/VirtualList.VirtualListBase` to be removed 5.0.0
19
+
5
20
  ## [4.6.0] - 2022-12-05
6
21
 
7
22
  ### Fixed
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "index.js"
3
+ }
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = exports.IconButtonDecorator = exports.IconButtonBase = exports.IconButton = void 0;
7
+ var _deprecate = _interopRequireDefault(require("@enact/core/internal/deprecate"));
7
8
  var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
8
9
  var _kind = _interopRequireDefault(require("@enact/core/kind"));
9
10
  var _propTypes2 = _interopRequireDefault(require("prop-types"));
@@ -165,7 +166,7 @@ var IconButtonBase = (0, _kind["default"])({
165
166
  return styler.append(size);
166
167
  }
167
168
  },
168
- render: function render(_ref2) {
169
+ render: (0, _deprecate["default"])(function (_ref2) {
169
170
  var buttonComponent = _ref2.buttonComponent,
170
171
  children = _ref2.children,
171
172
  componentRef = _ref2.componentRef,
@@ -193,7 +194,11 @@ var IconButtonBase = (0, _kind["default"])({
193
194
  }, "icon")].concat(_toConsumableArray(_react.Children.toArray(children))),
194
195
  ref: componentRef
195
196
  }));
196
- }
197
+ }, {
198
+ name: 'ui/IconButton',
199
+ replacedBy: 'ui/Button',
200
+ until: '5.0.0'
201
+ })
197
202
  });
198
203
 
199
204
  /**
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = exports.RadioControllerDecorator = exports.RadioContext = void 0;
7
7
  var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
8
+ var _deprecate = _interopRequireDefault(require("@enact/core/internal/deprecate"));
8
9
  var _Registry = _interopRequireDefault(require("@enact/core/internal/Registry"));
9
10
  var _react = require("react");
10
11
  var _jsxRuntime = require("react/jsx-runtime");
@@ -33,6 +34,7 @@ var RadioContext = /*#__PURE__*/(0, _react.createContext)();
33
34
  * @memberof ui/RadioDecorator
34
35
  * @hoc
35
36
  * @public
37
+ * @deprecated Will be removed in 5.0.0.
36
38
  */
37
39
  exports.RadioContext = RadioContext;
38
40
  var RadioControllerDecorator = (0, _hoc["default"])(function (config, Wrapped) {
@@ -82,6 +84,10 @@ var RadioControllerDecorator = (0, _hoc["default"])(function (config, Wrapped) {
82
84
  }, {
83
85
  key: "render",
84
86
  value: function render() {
87
+ (0, _deprecate["default"])({
88
+ name: 'ui/RadioDecorator.RadioControllerDecorator',
89
+ until: '5.0.0'
90
+ });
85
91
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(RadioContext.Provider, {
86
92
  value: this.registry.register,
87
93
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread({}, this.props))
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "RadioControllerDecorator", {
10
10
  }
11
11
  });
12
12
  exports["default"] = exports.RadioDecorator = void 0;
13
+ var _deprecate = _interopRequireDefault(require("@enact/core/internal/deprecate"));
13
14
  var _handle = require("@enact/core/handle");
14
15
  var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
15
16
  var _react = require("react");
@@ -150,6 +151,10 @@ var RadioDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wrapp
150
151
  }, {
151
152
  key: "render",
152
153
  value: function render() {
154
+ (0, _deprecate["default"])({
155
+ name: 'ui/RadioDecorator.RadioDecorator',
156
+ until: '5.0.0'
157
+ });
153
158
  var props = this.props;
154
159
  if (activate || deactivate) {
155
160
  props = Object.assign({}, this.props);
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = exports.ScrollerBase = void 0;
7
7
  var _classnames = _interopRequireDefault(require("classnames"));
8
+ var _deprecate = _interopRequireDefault(require("@enact/core/internal/deprecate"));
8
9
  var _platform = require("@enact/core/platform");
9
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
11
  var _react = require("react");
@@ -36,6 +37,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
36
37
  * @memberof ui/Scroller
37
38
  * @ui
38
39
  * @public
40
+ * @deprecated Will be removed in 5.0.0.
39
41
  */
40
42
  var ScrollerBase = /*#__PURE__*/function (_Component) {
41
43
  _inherits(ScrollerBase, _Component);
@@ -157,6 +159,10 @@ var ScrollerBase = /*#__PURE__*/function (_Component) {
157
159
  }, {
158
160
  key: "render",
159
161
  value: function render() {
162
+ (0, _deprecate["default"])({
163
+ name: 'ui/Scroller.ScrollerBase',
164
+ until: '5.0.0'
165
+ });
160
166
  var _this$props = this.props,
161
167
  className = _this$props.className,
162
168
  style = _this$props.style,
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = exports.SlotItemDecorator = exports.SlotItemBase = exports.SlotItem = void 0;
7
+ var _deprecate = _interopRequireDefault(require("@enact/core/internal/deprecate"));
7
8
  var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
8
9
  var _kind = _interopRequireDefault(require("@enact/core/kind"));
9
10
  var _propTypes2 = _interopRequireDefault(require("prop-types"));
@@ -168,7 +169,7 @@ var SlotItemBase = (0, _kind["default"])({
168
169
  }) : null;
169
170
  }
170
171
  },
171
- render: function render(_ref4) {
172
+ render: (0, _deprecate["default"])(function (_ref4) {
172
173
  var children = _ref4.children,
173
174
  Component = _ref4.component,
174
175
  componentRef = _ref4.componentRef,
@@ -184,7 +185,10 @@ var SlotItemBase = (0, _kind["default"])({
184
185
  inline: inline,
185
186
  children: [slotBefore, children, slotAfter]
186
187
  }));
187
- }
188
+ }, {
189
+ name: 'ui/SlotItem',
190
+ until: '5.0.0'
191
+ })
188
192
  });
189
193
 
190
194
  /**
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = exports.ToggleItemDecorator = exports.ToggleItemBase = exports.ToggleItem = void 0;
7
+ var _deprecate = _interopRequireDefault(require("@enact/core/internal/deprecate"));
7
8
  var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
8
9
  var _kind = _interopRequireDefault(require("@enact/core/kind"));
9
10
  var _propTypes2 = _interopRequireDefault(require("prop-types"));
@@ -221,7 +222,7 @@ var ToggleItemBase = (0, _kind["default"])({
221
222
  slotBefore: iconCreator('before'),
222
223
  slotAfter: iconCreator('after')
223
224
  },
224
- render: function render(_ref2) {
225
+ render: (0, _deprecate["default"])(function (_ref2) {
225
226
  var Component = _ref2.component,
226
227
  componentRef = _ref2.componentRef,
227
228
  css = _ref2.css,
@@ -241,7 +242,10 @@ var ToggleItemBase = (0, _kind["default"])({
241
242
  "aria-checked": selected,
242
243
  children: children
243
244
  }));
244
- }
245
+ }, {
246
+ name: 'ui/ToggleItem',
247
+ until: '5.0.0'
248
+ })
245
249
  });
246
250
 
247
251
  /**
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.pinchConfigPropType = exports.defaultPinchConfig = exports["default"] = exports.Pinch = void 0;
7
+ var _clamp = _interopRequireDefault(require("ramda/src/clamp"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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; }
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; }
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; }
13
+ 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); } }
14
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
15
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16
+ var Pinch = /*#__PURE__*/_createClass(function Pinch() {
17
+ var _this = this;
18
+ _classCallCheck(this, Pinch);
19
+ this.pinchConfig = null;
20
+ this.startScale = 1.0;
21
+ this.scale = 1.0;
22
+ this.isPinching = function () {
23
+ return _this.pinchConfig != null;
24
+ };
25
+ this.setContainerBounds = function (node) {
26
+ var _this$pinchConfig = _this.pinchConfig,
27
+ isGlobal = _this$pinchConfig.global,
28
+ boxSizing = _this$pinchConfig.boxSizing;
29
+ var bounds = null;
30
+ if (typeof window === 'undefined' || !node) return;
31
+ if (isGlobal) {
32
+ bounds = {
33
+ minX: 0,
34
+ minY: 0,
35
+ maxX: window.innerWidth,
36
+ maxY: window.innerHeight
37
+ };
38
+ } else {
39
+ bounds = node.getBoundingClientRect();
40
+
41
+ // adjust for padding when using content-box
42
+ if (boxSizing === 'content-box') {
43
+ var computedStyle = window.getComputedStyle(node);
44
+ bounds = {
45
+ minX: bounds.left + parseInt(computedStyle.paddingLeft),
46
+ minY: bounds.top + parseInt(computedStyle.paddingTop),
47
+ maxX: bounds.right - parseInt(computedStyle.paddingRight),
48
+ maxY: bounds.bottom - parseInt(computedStyle.paddingBottom)
49
+ };
50
+ } else {
51
+ bounds = {
52
+ minX: bounds.left,
53
+ minY: bounds.top,
54
+ maxX: bounds.right,
55
+ maxY: bounds.bottom
56
+ };
57
+ }
58
+ }
59
+ _this.bounds = bounds;
60
+ };
61
+ this.getBoundsCoords = function (_ref) {
62
+ var x = _ref.x,
63
+ y = _ref.y;
64
+ var _this$bounds = _this.bounds,
65
+ maxX = _this$bounds.maxX,
66
+ maxY = _this$bounds.maxY,
67
+ minX = _this$bounds.minX,
68
+ minY = _this$bounds.minY;
69
+ return {
70
+ x: (0, _clamp["default"])(minX, maxX, x) - minX,
71
+ y: (0, _clamp["default"])(minY, maxY, y) - minY
72
+ };
73
+ };
74
+ this.getDistance = function (coords) {
75
+ if (Array.isArray(coords)) {
76
+ var _this$getBoundsCoords = _this.getBoundsCoords(coords[0]),
77
+ x1 = _this$getBoundsCoords.x,
78
+ y1 = _this$getBoundsCoords.y;
79
+ var _this$getBoundsCoords2 = _this.getBoundsCoords(coords[1]),
80
+ x2 = _this$getBoundsCoords2.x,
81
+ y2 = _this$getBoundsCoords2.y;
82
+ var dx = x1 - x2;
83
+ var dy = y1 - y2;
84
+ return Math.sqrt(dx * dx + dy * dy);
85
+ }
86
+ return 0;
87
+ };
88
+ this.updateScale = function (scale) {
89
+ var _this$pinchConfig2 = _this.pinchConfig,
90
+ maxScale = _this$pinchConfig2.maxScale,
91
+ minScale = _this$pinchConfig2.minScale;
92
+ var newScale = (0, _clamp["default"])(minScale, maxScale, scale);
93
+ if (newScale !== _this.scale) {
94
+ _this.scale = newScale;
95
+ return true;
96
+ }
97
+ return false;
98
+ };
99
+ this.begin = function (config, _ref2, coords, node) {
100
+ var noResume = _ref2.noResume,
101
+ onPinch = _ref2.onPinch,
102
+ onPinchEnd = _ref2.onPinchEnd,
103
+ onPinchStart = _ref2.onPinchStart;
104
+ if (!onPinch && !onPinchStart && !onPinchEnd) {
105
+ return;
106
+ }
107
+ _this.pinchConfig = _objectSpread(_objectSpread({}, config), {}, {
108
+ node: node,
109
+ resume: !noResume
110
+ });
111
+ _this.setContainerBounds(node);
112
+ _this.startDist = _this.getDistance(coords);
113
+ _this.previousDist = _this.startDist;
114
+ _this.startScale = _this.scale;
115
+ _this.onPinch = onPinch;
116
+ _this.onPinchStart = onPinchStart;
117
+ _this.onPinchEnd = onPinchEnd;
118
+ if (_this.onPinchStart) {
119
+ _this.onPinchStart({
120
+ type: 'onPinchStart',
121
+ coords: coords
122
+ });
123
+ }
124
+ };
125
+ this.updateProps = function (_ref3) {
126
+ var onPinch = _ref3.onPinch,
127
+ onPinchEnd = _ref3.onPinchEnd,
128
+ onPinchStart = _ref3.onPinchStart;
129
+ // Check `isPinching` gesture is not in progress. Check if gesture exists before updating the references to the `pinchConfig`
130
+ if (!_this.isPinching()) return;
131
+
132
+ // This will update the `pinchConfig` with the new value
133
+ _this.onPinch = onPinch;
134
+ _this.onPinchStart = onPinchStart;
135
+ _this.onPinchEnd = onPinchEnd;
136
+ };
137
+ this.move = function (coords) {
138
+ if (!_this.isPinching()) return;
139
+ var moveTolerance = _this.pinchConfig.moveTolerance;
140
+ var currentDist = _this.getDistance(coords);
141
+ var scale = currentDist / _this.startDist * _this.startScale;
142
+ if (Math.abs(_this.previousDist - currentDist) > moveTolerance && _this.onPinch && _this.updateScale(scale)) {
143
+ _this.onPinch({
144
+ type: 'onPinch',
145
+ scale: _this.scale,
146
+ coords: coords
147
+ });
148
+ _this.previousDist = currentDist;
149
+ }
150
+ };
151
+ this.blur = function () {
152
+ if (!_this.isPinching()) return;
153
+ if (!_this.pinchConfig.global) {
154
+ _this.end();
155
+ }
156
+ };
157
+ this.end = function () {
158
+ if (!_this.isPinching()) return;
159
+ if (_this.onPinchEnd) {
160
+ _this.onPinchEnd({
161
+ type: 'onPinchEnd'
162
+ });
163
+ }
164
+ _this.pinchConfig = null;
165
+ };
166
+ });
167
+ exports.Pinch = Pinch;
168
+ var defaultPinchConfig = {
169
+ boxSizing: 'border-box',
170
+ global: false,
171
+ maxScale: 4,
172
+ minScale: 0.5,
173
+ moveTolerance: 16
174
+ };
175
+ exports.defaultPinchConfig = defaultPinchConfig;
176
+ var pinchConfigPropType = _propTypes["default"].shape({
177
+ boxSizing: _propTypes["default"].string,
178
+ global: _propTypes["default"].bool,
179
+ maxScale: _propTypes["default"].number,
180
+ minScale: _propTypes["default"].number,
181
+ moveTolerance: _propTypes["default"].number
182
+ });
183
+ exports.pinchConfigPropType = pinchConfigPropType;
184
+ var _default = Pinch;
185
+ exports["default"] = _default;
@@ -14,6 +14,7 @@ var _ClickAllow = _interopRequireDefault(require("./ClickAllow"));
14
14
  var _Drag = require("./Drag");
15
15
  var _Flick = require("./Flick");
16
16
  var _Hold = require("./Hold");
17
+ var _Pinch = require("./Pinch");
17
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
18
19
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
20
  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,8 +24,17 @@ var getEventCoordinates = function getEventCoordinates(ev) {
23
24
  y = ev.clientY,
24
25
  type = ev.type;
25
26
  if (type.indexOf('touch') === 0) {
26
- x = ev.targetTouches[0].clientX;
27
- y = ev.targetTouches[0].clientY;
27
+ if (ev.targetTouches.length >= 2) {
28
+ return Array.from(ev.targetTouches, function (targetTouch) {
29
+ return {
30
+ x: targetTouch.clientX,
31
+ y: targetTouch.clientY
32
+ };
33
+ });
34
+ } else {
35
+ x = ev.targetTouches[0].clientX;
36
+ y = ev.targetTouches[0].clientY;
37
+ }
28
38
  }
29
39
  return {
30
40
  x: x,
@@ -107,6 +117,7 @@ var Touch = /*#__PURE__*/function () {
107
117
  this.drag = new _Drag.Drag();
108
118
  this.flick = new _Flick.Flick();
109
119
  this.hold = new _Hold.Hold();
120
+ this.pinch = new _Pinch.Pinch();
110
121
  this.clickAllow = new _ClickAllow["default"]();
111
122
  this.handlers = {
112
123
  onClick: handleClick.bindAs(this, 'handleClick'),
@@ -137,11 +148,12 @@ var Touch = /*#__PURE__*/function () {
137
148
  }
138
149
  }, {
139
150
  key: "updateGestureConfig",
140
- value: function updateGestureConfig(dragConfig, flickConfig, holdConfig) {
151
+ value: function updateGestureConfig(dragConfig, flickConfig, holdConfig, pinchConfig) {
141
152
  this.config = (0, _config.mergeConfig)({
142
153
  drag: dragConfig,
143
154
  flick: flickConfig,
144
- hold: holdConfig
155
+ hold: holdConfig,
156
+ pinch: pinchConfig
145
157
  });
146
158
  }
147
159
  }, {
@@ -210,7 +222,8 @@ var Touch = /*#__PURE__*/function () {
210
222
  }, {
211
223
  key: "updateProps",
212
224
  value: function updateProps(props) {
213
- // Update the props onHoldStart, onHold, and onHoldEnd on any gesture (hold, flick, drag).
225
+ // Update the props onHoldStart, onHold, and onHoldEnd on any gesture (pinch, hold, flick, drag).
226
+ this.pinch.updateProps(props);
214
227
  this.hold.updateProps(props);
215
228
  this.flick.updateProps(props);
216
229
  this.drag.updateProps(props);
@@ -240,12 +253,17 @@ var Touch = /*#__PURE__*/function () {
240
253
  value: function startGesture(ev, props) {
241
254
  var coords = getEventCoordinates(ev);
242
255
  var _this$config = this.config,
256
+ pinch = _this$config.pinch,
243
257
  hold = _this$config.hold,
244
258
  flick = _this$config.flick,
245
259
  drag = _this$config.drag;
246
- this.hold.begin(hold, props, coords);
247
- this.flick.begin(flick, props, coords);
248
- this.drag.begin(drag, props, coords, this.target);
260
+ if (Array.isArray(coords)) {
261
+ this.pinch.begin(pinch, props, coords, this.target);
262
+ } else {
263
+ this.hold.begin(hold, props, coords);
264
+ this.flick.begin(flick, props, coords);
265
+ this.drag.begin(drag, props, coords, this.target);
266
+ }
249
267
  this.targetHadFocus = this.target === document.activeElement;
250
268
  return true;
251
269
  }
@@ -253,9 +271,13 @@ var Touch = /*#__PURE__*/function () {
253
271
  key: "moveGesture",
254
272
  value: function moveGesture(ev) {
255
273
  var coords = getEventCoordinates(ev);
256
- this.hold.move(coords);
257
- this.flick.move(coords);
258
- this.drag.move(coords);
274
+ if (Array.isArray(coords)) {
275
+ this.pinch.move(coords);
276
+ } else {
277
+ this.hold.move(coords);
278
+ this.flick.move(coords);
279
+ this.drag.move(coords);
280
+ }
259
281
  return true;
260
282
  }
261
283
  }, {
@@ -285,6 +307,7 @@ var Touch = /*#__PURE__*/function () {
285
307
  key: "endGesture",
286
308
  value: function endGesture() {
287
309
  this.targetHadFocus = false;
310
+ this.pinch.end();
288
311
  this.hold.end();
289
312
  this.flick.end();
290
313
  this.drag.end();
@@ -24,9 +24,10 @@ var _config = require("./config");
24
24
  var _Drag = require("./Drag");
25
25
  var _Flick = require("./Flick");
26
26
  var _Hold = require("./Hold");
27
+ var _Pinch = require("./Pinch");
27
28
  var _useTouch = _interopRequireDefault(require("./useTouch"));
28
29
  var _jsxRuntime = require("react/jsx-runtime");
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"];
30
+ var _excluded = ["dragConfig", "flickConfig", "holdConfig", "pinchConfig", "disabled", "noResume", "onBlur", "onClick", "onMouseDown", "onMouseEnter", "onMouseLeave", "onMouseMove", "onMouseUp", "onTouchEnd", "onTouchMove", "onTouchStart", "onDown", "onDrag", "onDragEnd", "onDragStart", "onFlick", "onHold", "onHoldEnd", "onHoldStart", "onMove", "onPinch", "onPinchEnd", "onPinchStart", "onTap", "onUp"];
30
31
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
31
32
  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; }
32
33
  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; }
@@ -37,6 +38,7 @@ var selectProps = function selectProps(props) {
37
38
  var dragConfig = props.dragConfig,
38
39
  flickConfig = props.flickConfig,
39
40
  holdConfig = props.holdConfig,
41
+ pinchConfig = props.pinchConfig,
40
42
  disabled = props.disabled,
41
43
  noResume = props.noResume,
42
44
  onBlur = props.onBlur,
@@ -58,6 +60,9 @@ var selectProps = function selectProps(props) {
58
60
  onHoldEnd = props.onHoldEnd,
59
61
  onHoldStart = props.onHoldStart,
60
62
  onMove = props.onMove,
63
+ onPinch = props.onPinch,
64
+ onPinchEnd = props.onPinchEnd,
65
+ onPinchStart = props.onPinchStart,
61
66
  onTap = props.onTap,
62
67
  onUp = props.onUp,
63
68
  rest = _objectWithoutProperties(props, _excluded);
@@ -67,6 +72,7 @@ var selectProps = function selectProps(props) {
67
72
  dragConfig: dragConfig,
68
73
  flickConfig: flickConfig,
69
74
  holdConfig: holdConfig,
75
+ pinchConfig: pinchConfig,
70
76
  /* general props */
71
77
  disabled: disabled,
72
78
  noResume: noResume,
@@ -91,6 +97,9 @@ var selectProps = function selectProps(props) {
91
97
  onHoldEnd: onHoldEnd,
92
98
  onHoldStart: onHoldStart,
93
99
  onMove: onMove,
100
+ onPinch: onPinch,
101
+ onPinchEnd: onPinchEnd,
102
+ onPinchStart: onPinchStart,
94
103
  onTap: onTap,
95
104
  onUp: onUp
96
105
  },
@@ -120,8 +129,8 @@ var defaultConfig = {
120
129
  /**
121
130
  * A higher-order component that provides a consistent set of pointer events -- `onDown`, `onUp`,
122
131
  * and `onTap` -- across mouse and touch interfaces along with support for common gestures including
123
- * `onFlick`, `onDrag`, `onHoldStart`, `onHold`, and `onHoldEnd`.
124
- *
132
+ * `onFlick`, `onDragStart`, `onDrag`, `onDragEnd`, `onHoldStart`, `onHold`, `onHoldEnd`,
133
+ * `onPinchStart`, `onPinch`, and `onPinchEnd`.
125
134
  * Note: This HoC passes a number of props to the wrapped component that should be passed to the
126
135
  * main DOM node or consumed by the wrapped component.
127
136
  *
@@ -308,6 +317,47 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
308
317
  * @public
309
318
  */
310
319
  onMove: _propTypes["default"].func,
320
+ /**
321
+ * Event handler for a pinch gesture.
322
+ *
323
+ * Event payload includes:
324
+ *
325
+ * * `type` - Type of event, `'onPinch'`
326
+ * * `scale` - The scale factor, calculated from the distance while pinching.
327
+ * The default value is 1.0. The value would be a number between
328
+ * pinchConfig.minScale and pinchConfig.maxScale.
329
+ * * `coords` - The coordinates array of the touch point, relative to the viewport
330
+ *
331
+ * @memberof ui/Touchable.Touchable.prototype
332
+ * @type {Function}
333
+ * @public
334
+ */
335
+ onPinch: _propTypes["default"].func,
336
+ /**
337
+ * Event handler for the end of a pinch gesture.
338
+ *
339
+ * Event payload includes:
340
+ *
341
+ * * `type` - Type of event, `'onPinchEnd'`
342
+ *
343
+ * @memberof ui/Touchable.Touchable.prototype
344
+ * @type {Function}
345
+ * @public
346
+ */
347
+ onPinchEnd: _propTypes["default"].func,
348
+ /**
349
+ * Event handler for the start of a pinch gesture.
350
+ *
351
+ * Event payload includes:
352
+ *
353
+ * * `type` - Type of event, `'onPinchStart'`
354
+ * * `coords` - The coordinates array of the touch point, relative to the viewport
355
+ *
356
+ * @memberof ui/Touchable.Touchable.prototype
357
+ * @type {Function}
358
+ * @public
359
+ */
360
+ onPinchStart: _propTypes["default"].func,
311
361
  /**
312
362
  * Event handler for 'tap' pointer events.
313
363
  *
@@ -323,7 +373,16 @@ var Touchable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
323
373
  * @type {Function}
324
374
  * @public
325
375
  */
326
- onUp: _propTypes["default"].func
376
+ onUp: _propTypes["default"].func,
377
+ /**
378
+ * Instance-specific overrides of the pinch configuration.
379
+ *
380
+ * @see {@link ui/Touchable.configure}
381
+ * @memberof ui/Touchable.Touchable.prototype
382
+ * @type {Object}
383
+ * @public
384
+ */
385
+ pinchConfig: _Pinch.pinchConfigPropType
327
386
  };
328
387
  Touchable.defaultProps = {
329
388
  disabled: false,
@@ -7,12 +7,14 @@ exports.resetDefaultConfig = exports.mergeConfig = exports.getConfig = exports["
7
7
  var _Drag = require("./Drag.js");
8
8
  var _Flick = require("./Flick.js");
9
9
  var _Hold = require("./Hold.js");
10
+ var _Pinch = require("./Pinch");
10
11
  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; }
11
12
  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; }
12
13
  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; }
13
14
  var allowedDragKeys = Object.keys(_Drag.defaultDragConfig);
14
15
  var allowedFlickKeys = Object.keys(_Flick.defaultFlickConfig);
15
16
  var allowedHoldKeys = Object.keys(_Hold.defaultHoldConfig);
17
+ var allowedPinchKeys = Object.keys(_Pinch.defaultPinchConfig);
16
18
 
17
19
  /**
18
20
  * The Global Gesture Configuration Object
@@ -43,7 +45,8 @@ var mergeConfig = function mergeConfig(cfg) {
43
45
  var merged = {
44
46
  drag: mergeGestureConfig(config.drag, cfg.drag, allowedDragKeys),
45
47
  flick: mergeGestureConfig(config.flick, cfg.flick, allowedFlickKeys),
46
- hold: mergeGestureConfig(config.hold, cfg.hold, allowedHoldKeys)
48
+ hold: mergeGestureConfig(config.hold, cfg.hold, allowedHoldKeys),
49
+ pinch: mergeGestureConfig(config.pinch, cfg.pinch, allowedPinchKeys)
47
50
  };
48
51
  merged.hold.events = merged.hold.events.map(clone);
49
52
  return merged;
@@ -104,6 +107,19 @@ var mergeConfig = function mergeConfig(cfg) {
104
107
  * controls the amount of time that must pass before this `onHoldStart` event is fired and should
105
108
  * be a multiple of `frequency`.
106
109
  *
110
+ * `pinch`
111
+ *
112
+ * * `boxSizing` - The part of the component's box model is used as the bounds of the constraint.
113
+ * Only applies when `global` is `false`.
114
+ * * `'border-box'` - the default, includes the padding and border but excludes the margin.
115
+ * * `'content-box'` - excludes the padding, border, and margin.
116
+ * * `global` - When `true`, pinch gestures will continue when leaving the bounds of the component
117
+ * or blurring the component.
118
+ * * `maxScale` - The maximum scale value. Defaults to `4`.
119
+ * * `minScale` - The minimum scale value. Defaults to `0.5`.
120
+ * * `moveTolerance` - The distance difference from the previous distance that the pointer may move
121
+ * before cancelling the scaling. Defaults to `16`.
122
+ *
107
123
  * @function
108
124
  * @param {Object} cfg A partial or complete configuration object
109
125
  *
@@ -123,8 +139,9 @@ exports.getConfig = getConfig;
123
139
  var resetDefaultConfig = function resetDefaultConfig() {
124
140
  return configure({
125
141
  drag: _Drag.defaultDragConfig,
142
+ flick: _Flick.defaultFlickConfig,
126
143
  hold: _Hold.defaultHoldConfig,
127
- flick: _Flick.defaultFlickConfig
144
+ pinch: _Pinch.defaultPinchConfig
128
145
  });
129
146
  };
130
147
  exports.resetDefaultConfig = resetDefaultConfig;