@enact/ui 4.6.2 → 4.7.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 (91) hide show
  1. package/AnnounceDecorator/Announce.js +25 -16
  2. package/AnnounceDecorator/AnnounceDecorator.js +14 -7
  3. package/AnnounceDecorator/useAnnounce.js +1 -2
  4. package/BodyText/BodyText.js +14 -8
  5. package/Button/Button.js +16 -10
  6. package/Button/tests/Button-specs.js +10 -6
  7. package/CHANGELOG.md +18 -0
  8. package/Cancelable/Cancelable.js +13 -7
  9. package/Changeable/Changeable.js +11 -7
  10. package/ComponentOverride/ComponentOverride.js +18 -7
  11. package/FloatingLayer/FloatingLayer.js +10 -11
  12. package/FloatingLayer/FloatingLayerDecorator.js +9 -6
  13. package/ForwardRef/ForwardRef.js +11 -7
  14. package/GridListImageItem/GridListImageItem.js +16 -9
  15. package/Group/Group.js +17 -8
  16. package/Group/GroupItem.js +14 -10
  17. package/Group/tests/Group-specs.js +14 -9
  18. package/Heading/Heading.js +20 -9
  19. package/Icon/Icon.js +15 -8
  20. package/IconButton/IconButton.js +22 -9
  21. package/Image/Image.js +16 -8
  22. package/ImageItem/ImageItem.js +9 -1
  23. package/Item/Item.js +17 -9
  24. package/Item/tests/Item-specs.js +10 -6
  25. package/LabeledIcon/LabeledIcon.js +16 -8
  26. package/Layout/Cell.js +27 -4
  27. package/Layout/Layout.d.ts +22 -5
  28. package/Layout/Layout.js +154 -32
  29. package/Layout/Layout.module.css +8 -0
  30. package/Layout/tests/Layout-specs.js +39 -0
  31. package/Marquee/MarqueeController.js +43 -0
  32. package/Marquee/MarqueeDecorator.js +40 -9
  33. package/Measurable/Measurable.js +11 -7
  34. package/Media/Media.js +30 -23
  35. package/Placeholder/PlaceholderControllerDecorator.js +8 -8
  36. package/Placeholder/PlaceholderDecorator.js +7 -8
  37. package/ProgressBar/ProgressBar.js +12 -1
  38. package/RadioDecorator/RadioDecorator.js +18 -13
  39. package/RadioDecorator/tests/RadioDecorator-specs.js +28 -20
  40. package/Repeater/Repeater.js +14 -10
  41. package/Resizable/Resizable.js +28 -98
  42. package/Resizable/ResizeContext.js +17 -0
  43. package/Resizable/tests/useResize-specs.js +43 -0
  44. package/Resizable/useResize.js +66 -0
  45. package/Routable/Link.js +8 -8
  46. package/Routable/Routable.js +15 -8
  47. package/Routable/Router.js +10 -10
  48. package/Routable/tests/Routable-specs.js +9 -6
  49. package/Scrollable/ScrollThumb.js +8 -9
  50. package/Scrollable/Scrollable.js +23 -7
  51. package/Scrollable/ScrollableNative.js +19 -14
  52. package/Scroller/Scroller.js +8 -1
  53. package/Scroller/ScrollerBasic.js +8 -9
  54. package/Scroller/UiScrollerBase.js +11 -12
  55. package/Skinnable/Skinnable.js +19 -7
  56. package/Skinnable/useSkins.js +1 -2
  57. package/Slider/Knob.js +8 -8
  58. package/Slider/Slider.js +16 -9
  59. package/SlotItem/SlotItem.js +20 -8
  60. package/Slottable/Slottable.js +14 -8
  61. package/Spinner/Spinner.js +24 -9
  62. package/ToggleIcon/ToggleIcon.js +21 -9
  63. package/ToggleIcon/tests/ToggleIcon-specs.js +6 -3
  64. package/ToggleItem/ToggleItem.js +14 -1
  65. package/ToggleItem/tests/ToggleItem-specs.js +6 -3
  66. package/Toggleable/Toggleable.js +11 -7
  67. package/Toggleable/useToggle.js +0 -1
  68. package/Touchable/Drag.js +1 -0
  69. package/Touchable/Flick.js +1 -0
  70. package/Touchable/Hold.js +1 -0
  71. package/Touchable/Pinch.js +1 -0
  72. package/Touchable/Touch.js +3 -3
  73. package/Touchable/Touchable.js +7 -0
  74. package/Touchable/useTouch.js +0 -1
  75. package/Transition/Transition.js +19 -3
  76. package/ViewManager/Arranger.js +4 -1
  77. package/ViewManager/TransitionGroup.js +5 -4
  78. package/ViewManager/View.js +12 -12
  79. package/ViewManager/ViewManager.js +25 -9
  80. package/ViewManager/tests/ViewManager-specs.js +44 -0
  81. package/VirtualList/UiVirtualListBase.js +3 -4
  82. package/VirtualList/VirtualList.js +11 -1
  83. package/VirtualList/VirtualListBasic.js +4 -4
  84. package/internal/IdProvider/IdProvider.js +6 -7
  85. package/internal/IdProvider/useId.js +0 -1
  86. package/internal/Pure/Pure.js +11 -7
  87. package/package.json +3 -3
  88. package/resolution/ResolutionDecorator.js +36 -7
  89. package/resolution/resolution.js +23 -7
  90. package/useScroll/ScrollbarTrack.js +8 -8
  91. package/useScroll/useScroll.js +17 -1
package/Media/Media.js CHANGED
@@ -28,29 +28,36 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
28
28
  function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
29
29
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
30
30
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
31
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
32
- /**
33
- * Generates a key representing the source node or nodes provided
34
- *
35
- * Example:
36
- * ```
37
- * getKeyFromSource('path/file.mp4'); // 'path/file.mp4'
38
- * getKeyFromSource(
39
- * <source src="path/file.mp4" type="video/mp4" />
40
- * ); // 'path/file.mp4'
41
- * getKeyFromSource([
42
- * <source src="path/file.mp4" type="video/mp4" />,
43
- * <source src="path/file.ogg" type="video/ogg" />,
44
- * ]); // 'path/file.mp4+path/file.ogg'
45
- * ```
46
- *
47
- * @function
48
- * @param {String|Element|Element[]} source URI for a source, `<source>` node, or array of
49
- * `<source>` nodes
50
- * @returns {String} Key representing sources
51
- * @memberof ui/Media
52
- * @public
53
- */
31
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /**
32
+ * A representation of `HTMLMediaElement` component with an ability to attach a custom event
33
+ * handler.
34
+ *
35
+ * @module ui/Media
36
+ * @exports getKeyFromSource
37
+ * @exports handledMediaEventsMap
38
+ * @exports Media
39
+ */ /**
40
+ * Generates a key representing the source node or nodes provided
41
+ *
42
+ * Example:
43
+ * ```
44
+ * getKeyFromSource('path/file.mp4'); // 'path/file.mp4'
45
+ * getKeyFromSource(
46
+ * <source src="path/file.mp4" type="video/mp4" />
47
+ * ); // 'path/file.mp4'
48
+ * getKeyFromSource([
49
+ * <source src="path/file.mp4" type="video/mp4" />,
50
+ * <source src="path/file.ogg" type="video/ogg" />,
51
+ * ]); // 'path/file.mp4+path/file.ogg'
52
+ * ```
53
+ *
54
+ * @function
55
+ * @param {String|Element|Element[]} source URI for a source, `<source>` node, or array of
56
+ * `<source>` nodes
57
+ * @returns {String} Key representing sources
58
+ * @memberof ui/Media
59
+ * @public
60
+ */
54
61
  var getKeyFromSource = function getKeyFromSource() {
55
62
  var source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
56
63
  if ( /*#__PURE__*/(0, _react.isValidElement)(source)) {
@@ -26,14 +26,13 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
26
26
  function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
27
27
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
28
28
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
29
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
30
- /**
31
- * Default config for `PlaceholderControllerDecorator`.
32
- *
33
- * @memberof ui/Placeholder.PlaceholderControllerDecorator
34
- * @hocconfig
35
- * @public
36
- */
29
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /**
30
+ * Default config for `PlaceholderControllerDecorator`.
31
+ *
32
+ * @memberof ui/Placeholder.PlaceholderControllerDecorator
33
+ * @hocconfig
34
+ * @public
35
+ */
37
36
  var defaultConfig = {
38
37
  /**
39
38
  * The bounds of the container represented by an object with `height` and `width` members.
@@ -105,6 +104,7 @@ var PlaceholderControllerDecorator = (0, _hoc["default"])(defaultConfig, functio
105
104
  topThreshold: topThreshold
106
105
  });
107
106
  };
107
+ // queue up notifications when placeholders are first created
108
108
  _this.notifyAllJob = new _util.Job(_this.notifyAll, 32);
109
109
  _this.handle = _handle.handle.bind(_assertThisInitialized(_this));
110
110
  _this.handleNotify = _this.handle((0, _handle.forward)(notify), function (_ref) {
@@ -23,14 +23,13 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
23
23
  function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
24
24
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25
25
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
26
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
27
- /**
28
- * Default config for PlaceholderDecorator.
29
- *
30
- * @memberof ui/Placeholder.PlaceholderDecorator
31
- * @hocconfig
32
- * @public
33
- */
26
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /**
27
+ * Default config for PlaceholderDecorator.
28
+ *
29
+ * @memberof ui/Placeholder.PlaceholderDecorator
30
+ * @hocconfig
31
+ * @public
32
+ */
34
33
  var defaultConfig = {
35
34
  /**
36
35
  * Configures the style of the placeholder element
@@ -21,7 +21,18 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
21
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
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
23
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
24
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
24
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /**
25
+ * A basic progress bar component that can display the progress of something in a horizontal,
26
+ * vertical, or radial bar format.
27
+ *
28
+ * A secondary independent progress indicator can be displayed, to indicate
29
+ * an additional degree of information, often used as a background loading progress.
30
+ *
31
+ * @module ui/ProgressBar
32
+ * @exports ProgressBar
33
+ * @exports ProgressBarBase
34
+ * @exports ProgressBarDecorator
35
+ */
25
36
  var progressToProportion = function progressToProportion(value) {
26
37
  return (0, _clamp["default"])(0, 1, value);
27
38
  };
@@ -31,13 +31,19 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
31
31
  function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
32
32
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
33
33
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
34
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
35
- /**
36
- * Default config for `RadioDecorator`.
37
- *
38
- * @memberof ui/RadioDecorator.RadioDecorator
39
- * @hocconfig
40
- */
34
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /**
35
+ * A higher-order component that manages activation of components.
36
+ *
37
+ * @module ui/RadioDecorator
38
+ * @exports RadioDecorator
39
+ * @exports RadioControllerDecorator
40
+ * @deprecated Will be removed in 5.0.0.
41
+ */ /**
42
+ * Default config for `RadioDecorator`.
43
+ *
44
+ * @memberof ui/RadioDecorator.RadioDecorator
45
+ * @hocconfig
46
+ */
41
47
  var defaultConfig = {
42
48
  /**
43
49
  * The event indicating the wrapped component is activated
@@ -92,6 +98,11 @@ var RadioDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wrapp
92
98
  args[_key] = arguments[_key];
93
99
  }
94
100
  _this = _super.call.apply(_super, [this].concat(args));
101
+ /*
102
+ * Invoked by a `RadioControllerDecorator` when the wrapped component should be deactivated
103
+ *
104
+ * @returns {undefined}
105
+ */
95
106
  _this.deactivate = function () {
96
107
  if (_this.props[prop]) {
97
108
  (0, _handle.forwardCustom)(deactivate)(null, _this.props);
@@ -144,12 +155,6 @@ var RadioDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wrapp
144
155
  });
145
156
  }
146
157
  }
147
-
148
- /*
149
- * Invoked by a `RadioControllerDecorator` when the wrapped component should be deactivated
150
- *
151
- * @returns {undefined}
152
- */
153
158
  }, {
154
159
  key: "render",
155
160
  value: function render() {
@@ -7,6 +7,8 @@ var _react2 = require("react");
7
7
  var _RadioDecorator = require("../RadioDecorator");
8
8
  var _jsxRuntime = require("react/jsx-runtime");
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
11
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
12
  describe('RadioDecorator', function () {
11
13
  var Item = function Item(_ref) {
12
14
  var onClick = _ref.onClick,
@@ -66,12 +68,13 @@ describe('RadioDecorator', function () {
66
68
  var secondExpected = 'Active';
67
69
  expect(component).toHaveTextContent(secondExpected);
68
70
  });
69
- test('should fire `activate` event with type when become activated', function () {
71
+ test('should fire `activate` event with type when become activated', /*#__PURE__*/_asyncToGenerator(function* () {
70
72
  var Component = (0, _RadioDecorator.RadioDecorator)({
71
73
  activate: 'onClick',
72
74
  prop: 'active'
73
75
  }, Item);
74
76
  var handleActivate = jest.fn();
77
+ var user = _userEvent["default"].setup();
75
78
  var Wrapper = function Wrapper() {
76
79
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Controller, {
77
80
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
@@ -81,7 +84,7 @@ describe('RadioDecorator', function () {
81
84
  };
82
85
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapper, {}));
83
86
  var component = _react.screen.getByTestId('span-element');
84
- _userEvent["default"].click(component);
87
+ yield user.click(component);
85
88
  var expected = 1;
86
89
  var expectedType = {
87
90
  type: 'onClick'
@@ -89,13 +92,14 @@ describe('RadioDecorator', function () {
89
92
  var actual = handleActivate.mock.calls.length && handleActivate.mock.calls[0][0];
90
93
  expect(handleActivate).toBeCalledTimes(expected);
91
94
  expect(actual).toMatchObject(expectedType);
92
- });
93
- test('should fire `deactivate` event with type when become deactivated', function () {
95
+ }));
96
+ test('should fire `deactivate` event with type when become deactivated', /*#__PURE__*/_asyncToGenerator(function* () {
94
97
  var Component = (0, _RadioDecorator.RadioDecorator)({
95
98
  deactivate: 'onClick',
96
99
  prop: 'active'
97
100
  }, Item);
98
101
  var handleDeactivate = jest.fn();
102
+ var user = _userEvent["default"].setup();
99
103
  var Wrapper = function Wrapper() {
100
104
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Controller, {
101
105
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
@@ -105,7 +109,7 @@ describe('RadioDecorator', function () {
105
109
  };
106
110
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapper, {}));
107
111
  var component = _react.screen.getByTestId('span-element');
108
- _userEvent["default"].click(component);
112
+ yield user.click(component);
109
113
  var expected = 1;
110
114
  var expectedType = {
111
115
  type: 'onClick'
@@ -113,7 +117,7 @@ describe('RadioDecorator', function () {
113
117
  var actual = handleDeactivate.mock.calls.length && handleDeactivate.mock.calls[0][0];
114
118
  expect(handleDeactivate).toBeCalledTimes(expected);
115
119
  expect(actual).toMatchObject(expectedType);
116
- });
120
+ }));
117
121
  test('should not call deactivate callback on inactive items', function () {
118
122
  var handleDeactivate = jest.fn();
119
123
  var Component = (0, _RadioDecorator.RadioDecorator)({
@@ -122,8 +126,8 @@ describe('RadioDecorator', function () {
122
126
  }, Item);
123
127
 
124
128
  // deactivate() is only called when there was a previously active item
125
- var Wrapper = function Wrapper(_ref3) {
126
- var active = _ref3.active;
129
+ var Wrapper = function Wrapper(_ref5) {
130
+ var active = _ref5.active;
127
131
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Controller, {
128
132
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
129
133
  active: !active
@@ -149,13 +153,14 @@ describe('RadioDecorator', function () {
149
153
  var actual = handleDeactivate.mock.calls.length;
150
154
  expect(actual).toBe(expected);
151
155
  });
152
- test('should be activated when the activated event fires', function () {
156
+ test('should be activated when the activated event fires', /*#__PURE__*/_asyncToGenerator(function* () {
153
157
  var controllerRef = /*#__PURE__*/(0, _react2.createRef)();
154
158
  var decoratorRef = /*#__PURE__*/(0, _react2.createRef)();
155
159
  var Component = (0, _RadioDecorator.RadioDecorator)({
156
160
  activate: 'onClick',
157
161
  prop: 'active'
158
162
  }, Item);
163
+ var user = _userEvent["default"].setup();
159
164
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Controller, {
160
165
  ref: controllerRef,
161
166
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
@@ -163,16 +168,17 @@ describe('RadioDecorator', function () {
163
168
  })
164
169
  }));
165
170
  var component = _react.screen.getByTestId('span-element');
166
- _userEvent["default"].click(component);
171
+ yield user.click(component);
167
172
  expectToBeActive(controllerRef.current, decoratorRef.current);
168
- });
169
- test('should be deactivated when the deactivated event fires', function () {
173
+ }));
174
+ test('should be deactivated when the deactivated event fires', /*#__PURE__*/_asyncToGenerator(function* () {
170
175
  var controllerRef = /*#__PURE__*/(0, _react2.createRef)();
171
176
  var decoratorRef = /*#__PURE__*/(0, _react2.createRef)();
172
177
  var Component = (0, _RadioDecorator.RadioDecorator)({
173
178
  deactivate: 'onClick',
174
179
  prop: 'active'
175
180
  }, Item);
181
+ var user = _userEvent["default"].setup();
176
182
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Controller, {
177
183
  ref: controllerRef,
178
184
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
@@ -181,16 +187,17 @@ describe('RadioDecorator', function () {
181
187
  })
182
188
  }));
183
189
  var component = _react.screen.getByTestId('span-element');
184
- _userEvent["default"].click(component);
190
+ yield user.click(component);
185
191
  expectToBeActive(controllerRef.current, null);
186
- });
187
- test('should be deactivated when the activated event fires on another instance', function () {
192
+ }));
193
+ test('should be deactivated when the activated event fires on another instance', /*#__PURE__*/_asyncToGenerator(function* () {
188
194
  var controllerRef = /*#__PURE__*/(0, _react2.createRef)();
189
195
  var decoratorRef = /*#__PURE__*/(0, _react2.createRef)();
190
196
  var Component = (0, _RadioDecorator.RadioDecorator)({
191
197
  activate: 'onClick',
192
198
  prop: 'active'
193
199
  }, Item);
200
+ var user = _userEvent["default"].setup();
194
201
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Controller, {
195
202
  ref: controllerRef,
196
203
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
@@ -200,10 +207,10 @@ describe('RadioDecorator', function () {
200
207
  })]
201
208
  }));
202
209
  var inactiveComponent = _react.screen.getByText('Inactive');
203
- _userEvent["default"].click(inactiveComponent);
210
+ yield user.click(inactiveComponent);
204
211
  expectToBeActive(controllerRef.current, decoratorRef.current);
205
- });
206
- test('should not deactivate items in a ancestor controller', function () {
212
+ }));
213
+ test('should not deactivate items in a ancestor controller', /*#__PURE__*/_asyncToGenerator(function* () {
207
214
  var parentControllerRef = /*#__PURE__*/(0, _react2.createRef)();
208
215
  var parentDecoratorRef = /*#__PURE__*/(0, _react2.createRef)();
209
216
  var childControllerRef = /*#__PURE__*/(0, _react2.createRef)();
@@ -212,6 +219,7 @@ describe('RadioDecorator', function () {
212
219
  activate: 'onClick',
213
220
  prop: 'active'
214
221
  }, Item);
222
+ var user = _userEvent["default"].setup();
215
223
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Controller, {
216
224
  ref: parentControllerRef,
217
225
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
@@ -228,12 +236,12 @@ describe('RadioDecorator', function () {
228
236
  })]
229
237
  }));
230
238
  var inactiveComponents = _react.screen.getAllByText('Inactive');
231
- _userEvent["default"].click(inactiveComponents[1]);
239
+ yield user.click(inactiveComponents[1]);
232
240
 
233
241
  // Breaking the pattern of 1 expect per test in order to verify the expect change happened
234
242
  // (activating second component in child controller) and no unexpected change happened in
235
243
  // the parent controller (active component should remain the first component)
236
244
  expectToBeActive(parentControllerRef, parentDecoratorRef);
237
245
  expectToBeActive(childControllerRef, childDecoratorRef);
238
- });
246
+ }));
239
247
  });
@@ -17,16 +17,20 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
17
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; }
18
18
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
19
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
20
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
21
- /**
22
- * A stateless component that stamps out copies of `childComponent`, without
23
- * [RepeaterDecorator](ui/Repeater.RepeaterDecorator) applied.
24
- *
25
- * @class RepeaterBase
26
- * @memberof ui/Repeater
27
- * @ui
28
- * @public
29
- */
20
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /**
21
+ * A repeater component.
22
+ *
23
+ * @module ui/Repeater
24
+ * @exports Repeater
25
+ */ /**
26
+ * A stateless component that stamps out copies of `childComponent`, without
27
+ * [RepeaterDecorator](ui/Repeater.RepeaterDecorator) applied.
28
+ *
29
+ * @class RepeaterBase
30
+ * @memberof ui/Repeater
31
+ * @ui
32
+ * @public
33
+ */
30
34
  var RepeaterBase = (0, _kind["default"])({
31
35
  name: 'Repeater',
32
36
  propTypes: /** @lends ui/Repeater.RepeaterBase.prototype */{
@@ -3,44 +3,35 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = exports.ResizeContext = exports.Resizable = void 0;
7
- var _handle = require("@enact/core/handle");
6
+ exports.Resizable = void 0;
7
+ Object.defineProperty(exports, "ResizeContext", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _ResizeContext["default"];
11
+ }
12
+ });
13
+ exports["default"] = void 0;
8
14
  var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
9
15
  var _invariant = _interopRequireDefault(require("invariant"));
10
- var _react = require("react");
16
+ var _ResizeContext = _interopRequireDefault(require("./ResizeContext"));
17
+ var _useResize = _interopRequireDefault(require("./useResize"));
11
18
  var _jsxRuntime = require("react/jsx-runtime");
12
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
20
  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
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; }
15
22
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
- 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, _toPropertyKey(descriptor.key), descriptor); } }
18
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
19
23
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
20
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
21
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
22
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
24
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
25
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
26
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
27
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
28
- /**
29
- * Used internally for things to notify children that they need to resize because of a parent
30
- * update.
31
- *
32
- * @type Object
33
- * @private
34
- */
35
- var ResizeContext = /*#__PURE__*/(0, _react.createContext)();
36
-
37
- /**
38
- * Default config for `Resizable`.
39
- *
40
- * @memberof ui/Resizable.Resizable
41
- * @hocconfig
42
- */
43
- exports.ResizeContext = ResizeContext;
24
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /**
25
+ * A higher-order component that handles component resize event.
26
+ *
27
+ * @module ui/Resizable
28
+ * @exports Resizable
29
+ */ /**
30
+ * Default config for `Resizable`.
31
+ *
32
+ * @memberof ui/Resizable.Resizable
33
+ * @hocconfig
34
+ */
44
35
  var defaultConfig = {
45
36
  /**
46
37
  * A handler to process the `resize` event.
@@ -84,76 +75,15 @@ var defaultConfig = {
84
75
  * @public
85
76
  */
86
77
  var Resizable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
87
- var _class;
88
- var filter = config.filter,
89
- resize = config.resize;
78
+ var resize = config.resize;
90
79
  !resize ? process.env.NODE_ENV !== "production" ? (0, _invariant["default"])(false, "resize is required by Resizable but was omitted when applied to ".concat(Wrapped.displayName)) : (0, _invariant["default"])(false) : void 0;
91
- return _class = /*#__PURE__*/function (_Component) {
92
- _inherits(_class, _Component);
93
- var _super = _createSuper(_class);
94
- function _class() {
95
- var _this;
96
- _classCallCheck(this, _class);
97
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
98
- args[_key] = arguments[_key];
99
- }
100
- _this = _super.call.apply(_super, [this].concat(args));
101
- _this.handleResize = (0, _handle.handle)((0, _handle.forward)(resize),
102
- // optionally filter the event before notifying the container
103
- filter, (0, _handle.call)('invalidateBounds')).bind(_assertThisInitialized(_this));
104
- return _this;
105
- }
106
- _createClass(_class, [{
107
- key: "componentDidMount",
108
- value: function componentDidMount() {
109
- if (this.context && typeof this.context === 'function') {
110
- // Registry requires a callback but (for now at least) Resizable doesn't respond to
111
- // upstream events so we're initializing a no-op function to "handle" callbacks
112
- this.resizeRegistry = this.context(function () {});
113
- }
114
- }
115
- }, {
116
- key: "componentWillUnmount",
117
- value: function componentWillUnmount() {
118
- if (this.resizeRegistry) {
119
- this.resizeRegistry.unregister();
120
- }
121
- }
122
-
123
- /*
124
- * Notifies a container that a resize is necessary
125
- *
126
- * @returns {undefined}
127
- * @private
128
- */
129
- }, {
130
- key: "invalidateBounds",
131
- value: function invalidateBounds() {
132
- if (this.resizeRegistry) {
133
- this.resizeRegistry.notify({
134
- action: 'invalidateBounds'
135
- });
136
- }
137
- }
138
80
 
139
- /*
140
- * Handles the event that indicates a resize is necessary
141
- *
142
- * @param {Object} ev Event payload
143
- *
144
- * @returns {undefined}
145
- * @private
146
- */
147
- }, {
148
- key: "render",
149
- value: function render() {
150
- var props = Object.assign({}, this.props);
151
- props[resize] = this.handleResize;
152
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread({}, props));
153
- }
154
- }]);
155
- return _class;
156
- }(_react.Component), _class.displayName = 'Resizable', _class.contextType = ResizeContext, _class;
81
+ // eslint-disable-next-line no-shadow
82
+ return function Resizable(props) {
83
+ var handlers = (0, _useResize["default"])(props, config);
84
+ var resizableProps = Object.assign({}, props, handlers);
85
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread({}, resizableProps));
86
+ };
157
87
  });
158
88
  exports.Resizable = Resizable;
159
89
  var _default = Resizable;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _react = require("react");
8
+ /**
9
+ * Used internally for things to notify children that they need to resize because of a parent
10
+ * update.
11
+ *
12
+ * @type Object
13
+ * @private
14
+ */
15
+ var ResizeContext = /*#__PURE__*/(0, _react.createContext)();
16
+ var _default = ResizeContext;
17
+ exports["default"] = _default;