@enact/ui 4.5.1 → 4.6.0

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 (185) 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.d.ts +1 -1
  8. package/BodyText/BodyText.js +8 -28
  9. package/BodyText/tests/BodyText-specs.js +0 -19
  10. package/Button/Button.d.ts +6 -6
  11. package/Button/Button.js +33 -63
  12. package/Button/tests/Button-specs.js +0 -26
  13. package/CHANGELOG.md +36 -0
  14. package/Cancelable/Cancelable.js +8 -47
  15. package/Cancelable/cancelHandler.js +5 -12
  16. package/Cancelable/modalHandler.js +3 -11
  17. package/Cancelable/tests/Cancelable-specs.js +3 -57
  18. package/Changeable/Changeable.js +2 -34
  19. package/Changeable/tests/Changeable-specs.js +20 -66
  20. package/ComponentOverride/ComponentOverride.js +1 -13
  21. package/FloatingLayer/FloatingLayer.js +17 -73
  22. package/FloatingLayer/FloatingLayerContainer.js +0 -15
  23. package/FloatingLayer/FloatingLayerDecorator.js +4 -17
  24. package/FloatingLayer/Scrim.js +9 -53
  25. package/FloatingLayer/index.js +0 -4
  26. package/FloatingLayer/tests/FloatingLayer-specs.js +8 -22
  27. package/FloatingLayer/tests/Scrim-specs.js +0 -9
  28. package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +0 -13
  29. package/FloatingLayer/useFloatingLayer.js +3 -14
  30. package/FloatingLayer/useFloatingLayerDecorator.js +3 -11
  31. package/ForwardRef/ForwardRef.js +1 -10
  32. package/GridListImageItem/GridListImageItem.d.ts +1 -1
  33. package/GridListImageItem/GridListImageItem.js +18 -51
  34. package/Group/Group.js +5 -36
  35. package/Group/GroupItem.js +16 -33
  36. package/Group/tests/Group-specs.js +0 -32
  37. package/Heading/Heading.js +8 -36
  38. package/Heading/tests/Heading-specs.js +81 -14
  39. package/Icon/Icon.d.ts +4 -4
  40. package/Icon/Icon.js +19 -53
  41. package/Icon/tests/Icon-specs.js +0 -22
  42. package/IconButton/IconButton.d.ts +4 -4
  43. package/IconButton/IconButton.js +17 -55
  44. package/IconButton/tests/IconButton-specs.js +0 -7
  45. package/Image/Image.js +17 -46
  46. package/Image/tests/Image-specs.js +0 -14
  47. package/ImageItem/ImageItem.js +18 -47
  48. package/ImageItem/tests/ImageItem-specs.js +0 -25
  49. package/Item/Item.js +9 -33
  50. package/Item/tests/Item-specs.js +0 -24
  51. package/LabeledIcon/LabeledIcon.d.ts +2 -2
  52. package/LabeledIcon/LabeledIcon.js +22 -53
  53. package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
  54. package/Layout/Cell.js +18 -44
  55. package/Layout/Layout.d.ts +16 -16
  56. package/Layout/Layout.js +23 -46
  57. package/Layout/tests/Layout-specs.js +10 -39
  58. package/Marquee/MarqueeBase.js +31 -64
  59. package/Marquee/MarqueeController.js +11 -72
  60. package/Marquee/MarqueeDecorator.js +70 -196
  61. package/Marquee/index.js +1 -5
  62. package/Marquee/tests/Marquee-specs.js +295 -87
  63. package/Measurable/Measurable.js +12 -34
  64. package/Measurable/tests/Measurable-specs.js +115 -0
  65. package/Media/Media.js +15 -65
  66. package/Media/tests/Media-specs.js +168 -0
  67. package/Placeholder/PlaceholderControllerDecorator.js +7 -43
  68. package/Placeholder/PlaceholderDecorator.js +7 -38
  69. package/Placeholder/index.js +1 -5
  70. package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +25 -0
  71. package/Placeholder/tests/PlaceholderDecorator-specs.js +28 -0
  72. package/ProgressBar/ProgressBar.js +14 -45
  73. package/ProgressBar/tests/ProgressBar-specs.js +0 -17
  74. package/RadioDecorator/RadioControllerDecorator.js +1 -29
  75. package/RadioDecorator/RadioDecorator.js +4 -42
  76. package/RadioDecorator/tests/RadioDecorator-specs.js +12 -49
  77. package/Repeater/Repeater.js +9 -33
  78. package/Repeater/tests/Repeater-specs.js +0 -38
  79. package/Resizable/Resizable.js +9 -37
  80. package/Resizable/tests/Resizable-specs.js +34 -0
  81. package/Routable/Link.js +11 -47
  82. package/Routable/Routable.d.ts +2 -2
  83. package/Routable/Routable.js +12 -35
  84. package/Routable/Route.js +0 -6
  85. package/Routable/Router.js +15 -58
  86. package/Routable/tests/Routable-specs.js +7 -33
  87. package/Routable/tests/Router-specs.js +18 -44
  88. package/Routable/useLink.js +4 -8
  89. package/Routable/util.js +18 -24
  90. package/Scrollable/ScrollAnimator.js +49 -65
  91. package/Scrollable/ScrollThumb.js +2 -13
  92. package/Scrollable/Scrollable.js +180 -387
  93. package/Scrollable/ScrollableNative.js +189 -392
  94. package/Scrollable/Scrollbar.js +30 -102
  95. package/Scroller/Scroller.js +15 -39
  96. package/Scroller/ScrollerBasic.js +34 -89
  97. package/Scroller/UiScrollerBase.js +31 -84
  98. package/Scroller/tests/Scroller-specs.js +56 -0
  99. package/Skinnable/Skinnable.js +11 -38
  100. package/Skinnable/tests/Skinnable-specs.js +3 -74
  101. package/Skinnable/tests/useSkins-specs.js +1 -13
  102. package/Skinnable/tests/util-specs.js +0 -14
  103. package/Skinnable/useSkins.js +8 -15
  104. package/Skinnable/util.js +9 -20
  105. package/Slider/Knob.js +5 -24
  106. package/Slider/PositionDecorator.js +16 -54
  107. package/Slider/Slider.d.ts +2 -2
  108. package/Slider/Slider.js +29 -67
  109. package/Slider/tests/Slider-specs.js +94 -7
  110. package/Slider/utils.js +0 -2
  111. package/SlotItem/SlotItem.d.ts +1 -1
  112. package/SlotItem/SlotItem.js +17 -43
  113. package/SlotItem/tests/SlotItem-specs.js +0 -5
  114. package/Slottable/Slottable.js +4 -12
  115. package/Slottable/tests/Slottable-specs.js +19 -46
  116. package/Slottable/tests/useSlots-specs.js +27 -65
  117. package/Slottable/useSlots.js +8 -33
  118. package/Spinner/Spinner.d.ts +1 -1
  119. package/Spinner/Spinner.js +16 -43
  120. package/Spinner/tests/Spinner-specs.js +0 -15
  121. package/ToggleIcon/ToggleIcon.js +10 -36
  122. package/ToggleIcon/tests/ToggleIcon-specs.js +0 -16
  123. package/ToggleItem/ToggleItem.d.ts +3 -3
  124. package/ToggleItem/ToggleItem.js +18 -55
  125. package/ToggleItem/tests/ToggleItem-specs.js +0 -30
  126. package/Toggleable/Toggle.js +1 -15
  127. package/Toggleable/Toggleable.js +12 -45
  128. package/Toggleable/tests/Toggleable-specs.js +28 -96
  129. package/Toggleable/useToggle.js +3 -19
  130. package/Touchable/ClickAllow.js +5 -14
  131. package/Touchable/Drag.js +16 -54
  132. package/Touchable/Flick.js +11 -42
  133. package/Touchable/Hold.js +21 -68
  134. package/Touchable/Touch.js +37 -65
  135. package/Touchable/Touchable.js +32 -71
  136. package/Touchable/config.js +8 -22
  137. package/Touchable/tests/Touchable-specs.js +270 -119
  138. package/Touchable/tests/useTouch-specs.js +6 -80
  139. package/Touchable/useTouch.js +17 -34
  140. package/Transition/Transition.js +37 -118
  141. package/Transition/tests/Transition-specs.js +20 -60
  142. package/ViewManager/Arranger.js +10 -22
  143. package/ViewManager/TransitionGroup.js +32 -107
  144. package/ViewManager/View.js +35 -91
  145. package/ViewManager/ViewManager.d.ts +1 -1
  146. package/ViewManager/ViewManager.js +20 -84
  147. package/ViewManager/tests/View-specs.js +0 -17
  148. package/ViewManager/tests/ViewManager-specs.js +236 -305
  149. package/ViewManager/tests/test-utils.js +0 -8
  150. package/VirtualList/UiVirtualListBase.js +259 -409
  151. package/VirtualList/VirtualList.d.ts +4 -4
  152. package/VirtualList/VirtualList.js +29 -69
  153. package/VirtualList/VirtualListBase.js +0 -3
  154. package/VirtualList/VirtualListBasic.js +273 -431
  155. package/VirtualList/tests/VirtualGridList-native-specs.js +161 -0
  156. package/VirtualList/tests/VirtualGridList-specs.js +614 -0
  157. package/VirtualList/tests/VirtualList-native-specs.js +152 -0
  158. package/VirtualList/tests/VirtualList-specs.js +423 -95
  159. package/internal/IdProvider/IdProvider.js +7 -21
  160. package/internal/IdProvider/Provider.js +4 -17
  161. package/internal/IdProvider/tests/IdProvider-specs.js +44 -0
  162. package/internal/IdProvider/tests/useId-specs.js +6 -20
  163. package/internal/IdProvider/useId.js +0 -6
  164. package/internal/Pure/Pure.js +3 -30
  165. package/internal/Pure/tests/Pure-specs.js +88 -0
  166. package/internal/localized-fonts/localized-fonts.js +33 -62
  167. package/internal/localized-fonts/tests/localized-fonts-specs.js +33 -0
  168. package/internal/selection/selection.js +1 -6
  169. package/internal/selection/tests/selection-specs.js +6 -4
  170. package/internal/validators/tests/validators-specs.js +80 -0
  171. package/internal/validators/validators.js +14 -34
  172. package/package.json +9 -3
  173. package/resolution/ResolutionDecorator.js +4 -40
  174. package/resolution/index.js +0 -7
  175. package/resolution/resolution.js +42 -80
  176. package/resolution/tests/ResolutionDecorator-specs.js +4 -11
  177. package/resolution/tests/resolution-specs.js +2 -2
  178. package/useControlledState/tests/useControlledState-specs.js +15 -46
  179. package/useControlledState/useControlledState.js +11 -22
  180. package/useScroll/ScrollAnimator.js +49 -65
  181. package/useScroll/Scrollbar.js +22 -58
  182. package/useScroll/ScrollbarTrack.js +3 -19
  183. package/useScroll/useScroll.js +267 -454
  184. package/useScroll/utilDOM.js +8 -14
  185. package/useScroll/utilEvent.js +0 -4
@@ -1,26 +1,113 @@
1
1
  "use strict";
2
2
 
3
+ require("@testing-library/jest-dom");
3
4
  var _react = require("@testing-library/react");
4
-
5
+ var _ProgressBar = _interopRequireDefault(require("../../ProgressBar"));
6
+ var _Knob = _interopRequireDefault(require("../Knob"));
5
7
  var _Slider = _interopRequireDefault(require("../Slider"));
6
-
7
8
  var _jsxRuntime = require("react/jsx-runtime");
8
-
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
-
11
10
  describe('Slider', function () {
12
- function ProgressBar() {
11
+ function CustomProgressBar() {
13
12
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
14
13
  }
15
-
16
14
  test('should return a DOM node reference for `componentRef`', function () {
17
15
  var ref = jest.fn();
18
16
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Slider["default"], {
19
- progressBarComponent: ProgressBar,
17
+ progressBarComponent: CustomProgressBar,
20
18
  ref: ref
21
19
  }));
22
20
  var expected = 'DIV';
23
21
  var actual = ref.mock.calls[0][0].nodeName;
24
22
  expect(actual).toBe(expected);
25
23
  });
24
+ test('should set \'ui-slider-proportion-end-knob\' to 0 when \'defaultValue\' is smaller than min value', function () {
25
+ jest.spyOn(console, 'warn').mockImplementation(function () {});
26
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Slider["default"], {
27
+ defaultValue: -10,
28
+ knobComponent: _Knob["default"],
29
+ max: 100,
30
+ min: 0,
31
+ progressBarComponent: _ProgressBar["default"],
32
+ step: 3
33
+ }));
34
+ var slider = _react.screen.getByRole('progressbar').parentElement;
35
+ var expected = '0';
36
+ expect(slider).toHaveStyle({
37
+ '--ui-slider-proportion-end-knob': expected
38
+ });
39
+ });
40
+ test('should set \'ui-slider-proportion-end-knob\' to 1 when \'defaultValue\' is bigger than max value', function () {
41
+ jest.spyOn(console, 'warn').mockImplementation(function () {});
42
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Slider["default"], {
43
+ defaultValue: 110,
44
+ knobComponent: _Knob["default"],
45
+ max: 100,
46
+ min: 0,
47
+ progressBarComponent: _ProgressBar["default"],
48
+ step: 3
49
+ }));
50
+ var slider = _react.screen.getByRole('progressbar').parentElement;
51
+ var expected = '1';
52
+ expect(slider).toHaveStyle({
53
+ '--ui-slider-proportion-end-knob': expected
54
+ });
55
+ });
56
+ test('should set \'ui-slider-proportion-end-knob\' to 0.5 when \'defaultValue\' is half of the range between min and max value', function () {
57
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Slider["default"], {
58
+ defaultValue: 50,
59
+ knobComponent: _Knob["default"],
60
+ max: 100,
61
+ min: 0,
62
+ progressBarComponent: _ProgressBar["default"],
63
+ step: 3
64
+ }));
65
+ var slider = _react.screen.getByRole('progressbar').parentElement;
66
+ var expected = '0.5';
67
+ expect(slider).toHaveStyle({
68
+ '--ui-slider-proportion-end-knob': expected
69
+ });
70
+ });
71
+ test('should fire `onChange` with `onChange` type of horizontal slider when value changed', function () {
72
+ var handleChange = jest.fn();
73
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Slider["default"], {
74
+ defaultValue: 50,
75
+ onChange: handleChange,
76
+ progressBarComponent: _ProgressBar["default"],
77
+ step: 5
78
+ }));
79
+ var knob = _react.screen.getByRole('progressbar').children.item(1);
80
+ _react.fireEvent.mouseDown(knob);
81
+ var expected = {
82
+ type: 'onChange'
83
+ };
84
+ var actual = handleChange.mock.calls.length && handleChange.mock.calls[0][0];
85
+ expect(actual).toMatchObject(expected);
86
+ });
87
+ test('should fire `onChange` with `onChange` type of vertical slider when value changed', function () {
88
+ var handleChange = jest.fn();
89
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Slider["default"], {
90
+ defaultValue: 50,
91
+ onChange: handleChange,
92
+ progressBarComponent: _ProgressBar["default"],
93
+ orientation: "vertical",
94
+ step: 5
95
+ }));
96
+ var knob = _react.screen.getByRole('progressbar').children.item(1);
97
+ _react.fireEvent.mouseDown(knob);
98
+ var expected = {
99
+ type: 'onChange'
100
+ };
101
+ var actual = handleChange.mock.calls.length && handleChange.mock.calls[0][0];
102
+ expect(actual).toMatchObject(expected);
103
+ });
104
+ });
105
+ describe('Knob', function () {
106
+ test('should render a knob', function () {
107
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Knob["default"], {
108
+ role: "knob"
109
+ }));
110
+ var knob = _react.screen.queryByRole('knob');
111
+ expect(knob).toBeInTheDocument();
112
+ });
26
113
  });
package/Slider/utils.js CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.calcProportion = void 0;
7
-
8
7
  var calcProportion = function calcProportion(min, max, value) {
9
8
  if (value <= min) {
10
9
  return 0;
@@ -14,5 +13,4 @@ var calcProportion = function calcProportion(min, max, value) {
14
13
  return (value - min) / (max - min);
15
14
  }
16
15
  };
17
-
18
16
  exports.calcProportion = calcProportion;
@@ -12,7 +12,7 @@ export interface SlotItemBaseProps {
12
12
  * The type of component to use to render the item.
13
13
  *
14
14
  * This component will receive the `inline` prop and any additional unhandled props provided
15
- to `SlotItem` . A derivative of [Item] is recommended.
15
+ to `SlotItem` . A derivative of is recommended.
16
16
  */
17
17
  component: React.ComponentType;
18
18
  /**
@@ -4,37 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = exports.SlotItemDecorator = exports.SlotItemBase = exports.SlotItem = void 0;
7
-
8
7
  var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
9
-
10
8
  var _kind = _interopRequireDefault(require("@enact/core/kind"));
11
-
12
9
  var _propTypes2 = _interopRequireDefault(require("prop-types"));
13
-
14
10
  var _compose = _interopRequireDefault(require("ramda/src/compose"));
15
-
16
11
  var _Slottable = _interopRequireDefault(require("../Slottable"));
17
-
18
12
  var _SlotItemModule = _interopRequireDefault(require("./SlotItem.module.css"));
19
-
20
13
  var _ForwardRef = _interopRequireDefault(require("../ForwardRef"));
21
-
22
14
  var _jsxRuntime = require("react/jsx-runtime");
23
-
24
15
  var _excluded = ["children", "component", "componentRef", "inline", "slotAfter", "slotBefore"];
25
-
26
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
27
-
28
17
  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; }
29
-
30
18
  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; }
31
-
32
19
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
33
-
34
20
  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; }
35
-
36
21
  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; }
37
-
38
22
  /**
39
23
  * A ui-styled `SlotItem` without any behavior.
40
24
  *
@@ -45,21 +29,18 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
45
29
  */
46
30
  var SlotItemBase = (0, _kind["default"])({
47
31
  name: 'SlotItem',
48
- propTypes:
49
- /** @lends ui/SlotItem.SlotItemBase.prototype */
50
- {
32
+ propTypes: /** @lends ui/SlotItem.SlotItemBase.prototype */{
51
33
  /**
52
34
  * The type of component to use to render the item.
53
35
  *
54
36
  * This component will receive the `inline` prop and any additional unhandled props provided
55
- * to `SlotItem`. A derivative of [Item]{@link ui/Item.Item} is recommended.
37
+ * to `SlotItem`. A derivative of {@link ui/Item.Item|Item} is recommended.
56
38
  *
57
39
  * @type {Component}
58
40
  * @required
59
41
  * @public
60
42
  */
61
43
  component: _propTypes["default"].component.isRequired,
62
-
63
44
  /**
64
45
  * Controls the visibility state of the slots.
65
46
  *
@@ -81,7 +62,6 @@ var SlotItemBase = (0, _kind["default"])({
81
62
  * @public
82
63
  */
83
64
  autoHide: _propTypes2["default"].oneOf(['after', 'before', 'both']),
84
-
85
65
  /**
86
66
  * Called with a reference to the root component.
87
67
  *
@@ -92,7 +72,6 @@ var SlotItemBase = (0, _kind["default"])({
92
72
  * @public
93
73
  */
94
74
  componentRef: _propTypes["default"].ref,
95
-
96
75
  /**
97
76
  * Customizes the component by mapping the supplied collection of CSS class names to the
98
77
  * corresponding internal elements and states of this component.
@@ -110,7 +89,6 @@ var SlotItemBase = (0, _kind["default"])({
110
89
  * @public
111
90
  */
112
91
  css: _propTypes2["default"].object,
113
-
114
92
  /**
115
93
  * Applies inline styling to the component.
116
94
  *
@@ -119,7 +97,6 @@ var SlotItemBase = (0, _kind["default"])({
119
97
  * @public
120
98
  */
121
99
  inline: _propTypes2["default"].bool,
122
-
123
100
  /**
124
101
  * The layout technique for `SlotItem`.
125
102
  *
@@ -131,7 +108,6 @@ var SlotItemBase = (0, _kind["default"])({
131
108
  * @public
132
109
  */
133
110
  layout: _propTypes2["default"].oneOf(['flex']),
134
-
135
111
  /**
136
112
  * Nodes to be inserted after `children` and hidden using `autoHide`.
137
113
  *
@@ -141,7 +117,6 @@ var SlotItemBase = (0, _kind["default"])({
141
117
  * @public
142
118
  */
143
119
  slotAfter: _propTypes2["default"].node,
144
-
145
120
  /**
146
121
  * Nodes to be inserted before `children` and hidden using `autoHide`.
147
122
  *
@@ -164,16 +139,16 @@ var SlotItemBase = (0, _kind["default"])({
164
139
  computed: {
165
140
  className: function className(_ref) {
166
141
  var inline = _ref.inline,
167
- layout = _ref.layout,
168
- styler = _ref.styler;
142
+ layout = _ref.layout,
143
+ styler = _ref.styler;
169
144
  return styler.append(layout, {
170
145
  inline: inline
171
146
  });
172
147
  },
173
148
  slotBefore: function slotBefore(_ref2) {
174
149
  var _slotBefore = _ref2.slotBefore,
175
- autoHide = _ref2.autoHide,
176
- styler = _ref2.styler;
150
+ autoHide = _ref2.autoHide,
151
+ styler = _ref2.styler;
177
152
  return _slotBefore ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
178
153
  className: styler.join('slot', 'before', {
179
154
  hidden: autoHide === 'before' || autoHide === 'both'
@@ -183,8 +158,8 @@ var SlotItemBase = (0, _kind["default"])({
183
158
  },
184
159
  slotAfter: function slotAfter(_ref3) {
185
160
  var _slotAfter = _ref3.slotAfter,
186
- autoHide = _ref3.autoHide,
187
- styler = _ref3.styler;
161
+ autoHide = _ref3.autoHide,
162
+ styler = _ref3.styler;
188
163
  return _slotAfter ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
189
164
  className: styler.join('slot', 'after', {
190
165
  hidden: autoHide === 'after' || autoHide === 'both'
@@ -195,13 +170,12 @@ var SlotItemBase = (0, _kind["default"])({
195
170
  },
196
171
  render: function render(_ref4) {
197
172
  var children = _ref4.children,
198
- Component = _ref4.component,
199
- componentRef = _ref4.componentRef,
200
- inline = _ref4.inline,
201
- slotAfter = _ref4.slotAfter,
202
- slotBefore = _ref4.slotBefore,
203
- rest = _objectWithoutProperties(_ref4, _excluded);
204
-
173
+ Component = _ref4.component,
174
+ componentRef = _ref4.componentRef,
175
+ inline = _ref4.inline,
176
+ slotAfter = _ref4.slotAfter,
177
+ slotBefore = _ref4.slotBefore,
178
+ rest = _objectWithoutProperties(_ref4, _excluded);
205
179
  delete rest.autoHide;
206
180
  delete rest.layout;
207
181
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, _objectSpread(_objectSpread({
@@ -212,8 +186,9 @@ var SlotItemBase = (0, _kind["default"])({
212
186
  }));
213
187
  }
214
188
  });
189
+
215
190
  /**
216
- * A ui-specific higher-order component (HOC) with slot behaviors to apply to [SlotItem]{@link ui/SlotItem.SlotItemBase}.
191
+ * A ui-specific higher-order component (HOC) with slot behaviors to apply to {@link ui/SlotItem.SlotItemBase|SlotItem}.
217
192
  *
218
193
  * @class SlotItemDecorator
219
194
  * @memberof ui/SlotItem
@@ -222,13 +197,13 @@ var SlotItemBase = (0, _kind["default"])({
222
197
  * @hoc
223
198
  * @public
224
199
  */
225
-
226
200
  exports.SlotItemBase = SlotItemBase;
227
201
  var SlotItemDecorator = (0, _compose["default"])((0, _ForwardRef["default"])({
228
202
  prop: 'componentRef'
229
203
  }), (0, _Slottable["default"])({
230
204
  slots: ['slotAfter', 'slotBefore']
231
205
  }));
206
+
232
207
  /**
233
208
  * A ui-styled item with built-in support for slots.
234
209
  *
@@ -252,7 +227,6 @@ var SlotItemDecorator = (0, _compose["default"])((0, _ForwardRef["default"])({
252
227
  * @ui
253
228
  * @public
254
229
  */
255
-
256
230
  exports.SlotItemDecorator = SlotItemDecorator;
257
231
  var SlotItem = SlotItemDecorator(SlotItemBase);
258
232
  exports.SlotItem = SlotItem;
@@ -1,15 +1,10 @@
1
1
  "use strict";
2
2
 
3
3
  var _react = require("@testing-library/react");
4
-
5
4
  var _react2 = require("react");
6
-
7
5
  var _SlotItem = _interopRequireDefault(require("../SlotItem"));
8
-
9
6
  var _jsxRuntime = require("react/jsx-runtime");
10
-
11
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
-
13
8
  describe('SlotItem', function () {
14
9
  test('should return a DOM node reference for `componentRef`', function () {
15
10
  var component = /*#__PURE__*/(0, _react2.forwardRef)(function (props, fn) {
@@ -10,21 +10,13 @@ Object.defineProperty(exports, "useSlots", {
10
10
  return _useSlots["default"];
11
11
  }
12
12
  });
13
-
14
13
  var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
15
-
16
14
  var _useSlots = _interopRequireDefault(require("./useSlots"));
17
-
18
15
  var _jsxRuntime = require("react/jsx-runtime");
19
-
20
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
-
22
17
  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; }
23
-
24
18
  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; }
25
-
26
19
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
-
28
20
  /**
29
21
  * Default config for `Slottable`.
30
22
  *
@@ -41,6 +33,7 @@ var defaultConfig = {
41
33
  */
42
34
  slots: null
43
35
  };
36
+
44
37
  /**
45
38
  * A higher-order component that allows wrapped components to separate children into pre-designated 'slots'.
46
39
  *
@@ -53,10 +46,10 @@ var defaultConfig = {
53
46
  * @hoc
54
47
  * @public
55
48
  */
56
-
57
49
  var Slottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
58
- var slots = config.slots; // eslint-disable-next-line no-shadow
50
+ var slots = config.slots;
59
51
 
52
+ // eslint-disable-next-line no-shadow
60
53
  return function Slottable(props) {
61
54
  // extract the slots into a new object but populating the default value to be undefined so
62
55
  // the key exists in order to allow the current "harmful" behavior below. Must be undefined
@@ -67,17 +60,16 @@ var Slottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
67
60
  slots.forEach(function (k) {
68
61
  return slotProps[k] = undefined;
69
62
  }); // eslint-disable-line no-undefined
63
+
70
64
  // Slottable allows there to be other values in the destination slot and merges them.
71
65
  // However, consumers can't avoid key warnings when merging the two lists so we should
72
66
  // "consider this harmful" and not continue to support this with the hook and instead
73
67
  // encourage using the slot as the default with the prop as a fallback as implemented by the
74
68
  // hook.
75
-
76
69
  var distributed = (0, _useSlots["default"])(slotProps);
77
70
  slots.forEach(function (slot) {
78
71
  var dist = distributed[slot];
79
72
  var prop = props[slot];
80
-
81
73
  if (prop != null && dist != null) {
82
74
  distributed[slot] = [].concat(prop, dist);
83
75
  } else if (prop != null) {
@@ -1,26 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  var _kind = _interopRequireDefault(require("@enact/core/kind"));
4
-
5
4
  require("@testing-library/jest-dom");
6
-
7
5
  var _react = require("@testing-library/react");
8
-
9
6
  var _Slottable = _interopRequireDefault(require("../Slottable"));
10
-
11
7
  var _jsxRuntime = require("react/jsx-runtime");
12
-
13
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
-
15
9
  /* eslint no-console: ["error", { allow: ["warn", "error"] }] */
10
+
16
11
  describe('Slottable Specs', function () {
17
12
  test('should distribute children with a \'slot\' property', function () {
18
13
  var Component = (0, _Slottable["default"])({
19
14
  slots: ['a', 'b', 'c']
20
15
  }, function (_ref) {
21
16
  var a = _ref.a,
22
- b = _ref.b,
23
- c = _ref.c;
17
+ b = _ref.b,
18
+ c = _ref.c;
24
19
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
25
20
  "data-testid": "slottable",
26
21
  children: [c, b, a]
@@ -38,9 +33,7 @@ describe('Slottable Specs', function () {
38
33
  children: "C"
39
34
  })]
40
35
  }));
41
-
42
36
  var actual = _react.screen.getByTestId('slottable');
43
-
44
37
  var expected = 'CBA';
45
38
  expect(actual.textContent).toBe(expected);
46
39
  });
@@ -49,9 +42,9 @@ describe('Slottable Specs', function () {
49
42
  slots: ['a', 'b', 'c', 'custom']
50
43
  }, function (_ref2) {
51
44
  var a = _ref2.a,
52
- b = _ref2.b,
53
- c = _ref2.c,
54
- custom = _ref2.custom;
45
+ b = _ref2.b,
46
+ c = _ref2.c,
47
+ custom = _ref2.custom;
55
48
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
56
49
  "data-testid": "slottable",
57
50
  children: [c, b, a, custom]
@@ -71,9 +64,7 @@ describe('Slottable Specs', function () {
71
64
  children: "C"
72
65
  })]
73
66
  }));
74
-
75
67
  var actual = _react.screen.getByTestId('slottable');
76
-
77
68
  var expected = 'CBAD';
78
69
  expect(actual.textContent).toBe(expected);
79
70
  });
@@ -92,8 +83,8 @@ describe('Slottable Specs', function () {
92
83
  slots: ['a', 'b', 'c']
93
84
  }, function (_ref4) {
94
85
  var a = _ref4.a,
95
- b = _ref4.b,
96
- c = _ref4.c;
86
+ b = _ref4.b,
87
+ c = _ref4.c;
97
88
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
98
89
  "data-testid": "slottable",
99
90
  children: [c, b, a]
@@ -111,9 +102,7 @@ describe('Slottable Specs', function () {
111
102
  })]
112
103
  }));
113
104
  var expected = 'CBA';
114
-
115
105
  var actual = _react.screen.getByTestId('slottable');
116
-
117
106
  expect(actual.textContent).toBe(expected);
118
107
  });
119
108
  test('should distribute children with no \'slot\' property to Slottable\'s \'children\'', function () {
@@ -121,8 +110,8 @@ describe('Slottable Specs', function () {
121
110
  slots: ['a', 'b']
122
111
  }, function (_ref5) {
123
112
  var a = _ref5.a,
124
- b = _ref5.b,
125
- children = _ref5.children;
113
+ b = _ref5.b,
114
+ children = _ref5.children;
126
115
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
127
116
  "data-testid": "slottable",
128
117
  children: [children, b, a]
@@ -140,9 +129,7 @@ describe('Slottable Specs', function () {
140
129
  })]
141
130
  }));
142
131
  var expected = 'CBA';
143
-
144
132
  var actual = _react.screen.getByTestId('slottable');
145
-
146
133
  expect(actual.textContent).toBe(expected);
147
134
  });
148
135
  test('should not distribute children with an invalid \'slot\' property', function () {
@@ -153,8 +140,8 @@ describe('Slottable Specs', function () {
153
140
  slots: ['a', 'b']
154
141
  }, function (_ref6) {
155
142
  var a = _ref6.a,
156
- b = _ref6.b,
157
- c = _ref6.c;
143
+ b = _ref6.b,
144
+ c = _ref6.c;
158
145
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
159
146
  "data-testid": "slottable",
160
147
  children: [c, b, a]
@@ -173,11 +160,10 @@ describe('Slottable Specs', function () {
173
160
  })]
174
161
  }));
175
162
  var expected = 'BA';
176
-
177
163
  var actual = _react.screen.getByTestId('slottable');
164
+ expect(actual.textContent).toBe(expected);
178
165
 
179
- expect(actual.textContent).toBe(expected); // Check to make sure that we only get the one expected error
180
-
166
+ // Check to make sure that we only get the one expected error
181
167
  var actualErrorsLength = console.error.mock.calls.length;
182
168
  var expectedErrorLength = 1;
183
169
  expect(actualErrorsLength).toBe(expectedErrorLength);
@@ -190,9 +176,9 @@ describe('Slottable Specs', function () {
190
176
  slots: ['a', 'b', 'c', 'custom']
191
177
  }, function (_ref7) {
192
178
  var a = _ref7.a,
193
- b = _ref7.b,
194
- c = _ref7.c,
195
- custom = _ref7.custom;
179
+ b = _ref7.b,
180
+ c = _ref7.c,
181
+ custom = _ref7.custom;
196
182
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
197
183
  className: "root-div",
198
184
  "data-testid": "slottable",
@@ -214,14 +200,10 @@ describe('Slottable Specs', function () {
214
200
  })]
215
201
  }));
216
202
  var expected = 'CBD';
217
-
218
203
  var actual = _react.screen.getByTestId('slottable');
219
-
220
204
  expect(actual.textContent).toBe(expected);
221
205
  var expectedTitle = 'Div A';
222
-
223
206
  var actualChild = _react.screen.getByTestId('slottable').children[2];
224
-
225
207
  expect(actualChild).toHaveAttribute('title', expectedTitle);
226
208
  });
227
209
  test('should preserve values in \'slot\' property', function () {
@@ -247,9 +229,7 @@ describe('Slottable Specs', function () {
247
229
  }, "A")
248
230
  }));
249
231
  var expected = 'XA';
250
-
251
232
  var actual = _react.screen.getByTestId('slottable');
252
-
253
233
  expect(actual.textContent).toBe(expected);
254
234
  });
255
235
  test('should add values to existing array in \'slot\' property', function () {
@@ -262,18 +242,17 @@ describe('Slottable Specs', function () {
262
242
  children: a
263
243
  });
264
244
  });
265
- /* eslint-disable jsx-a11y/anchor-is-valid */
266
245
 
246
+ /* eslint-disable jsx-a11y/anchor-is-valid */
267
247
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
268
248
  a: ['a', 'b'],
269
249
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
270
250
  children: "c"
271
251
  })
272
252
  }));
273
- /* eslint-enable jsx-a11y/anchor-is-valid */
274
253
 
254
+ /* eslint-enable jsx-a11y/anchor-is-valid */
275
255
  var actual = _react.screen.getByTestId('slottable');
276
-
277
256
  expect(actual).toHaveTextContent('abc');
278
257
  });
279
258
  test('should distribute multiple children with the same slot into the same slot', function () {
@@ -285,7 +264,6 @@ describe('Slottable Specs', function () {
285
264
  children: a
286
265
  });
287
266
  }
288
-
289
267
  var Component = (0, _Slottable["default"])({
290
268
  slots: ['a']
291
269
  }, ComponentBase);
@@ -302,9 +280,7 @@ describe('Slottable Specs', function () {
302
280
  })]
303
281
  }));
304
282
  var expected = 'AAA';
305
-
306
283
  var actual = _react.screen.getByTestId('slottable');
307
-
308
284
  expect(actual.textContent).toBe(expected);
309
285
  });
310
286
  test('should allow downstream component to have default value for unset slot', function () {
@@ -315,7 +291,6 @@ describe('Slottable Specs', function () {
315
291
  children: a
316
292
  });
317
293
  }
318
-
319
294
  ComponentBase.defaultProps = {
320
295
  a: 'Default A'
321
296
  };
@@ -323,9 +298,7 @@ describe('Slottable Specs', function () {
323
298
  slots: ['a']
324
299
  }, ComponentBase);
325
300
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
326
-
327
301
  var actual = _react.screen.getByTestId('slottable');
328
-
329
302
  expect(actual).toHaveTextContent('Default A');
330
303
  });
331
304
  });