@enact/ui 4.5.2 → 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 (222) hide show
  1. package/AnnounceDecorator/Announce.js +1 -40
  2. package/AnnounceDecorator/AnnounceDecorator.js +3 -21
  3. package/AnnounceDecorator/tests/Announce-specs.js +2 -7
  4. package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +2 -6
  5. package/AnnounceDecorator/tests/useAnnounce-specs.js +8 -19
  6. package/AnnounceDecorator/useAnnounce.js +0 -6
  7. package/BodyText/BodyText.js +8 -28
  8. package/BodyText/tests/BodyText-specs.js +0 -19
  9. package/Button/Button.js +33 -63
  10. package/Button/tests/Button-specs.js +0 -26
  11. package/CHANGELOG.md +45 -0
  12. package/Cancelable/Cancelable.js +8 -47
  13. package/Cancelable/cancelHandler.js +5 -12
  14. package/Cancelable/modalHandler.js +3 -11
  15. package/Cancelable/tests/Cancelable-specs.js +3 -57
  16. package/Changeable/Changeable.js +2 -34
  17. package/Changeable/tests/Changeable-specs.js +20 -66
  18. package/ComponentOverride/ComponentOverride.js +1 -13
  19. package/FloatingLayer/FloatingLayer.js +17 -73
  20. package/FloatingLayer/FloatingLayerContainer.js +0 -15
  21. package/FloatingLayer/FloatingLayerDecorator.js +4 -17
  22. package/FloatingLayer/Scrim.js +9 -53
  23. package/FloatingLayer/index.js +0 -4
  24. package/FloatingLayer/package.json +3 -0
  25. package/FloatingLayer/tests/FloatingLayer-specs.js +8 -22
  26. package/FloatingLayer/tests/Scrim-specs.js +0 -9
  27. package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +0 -13
  28. package/FloatingLayer/useFloatingLayer.js +3 -14
  29. package/FloatingLayer/useFloatingLayerDecorator.js +3 -11
  30. package/ForwardRef/ForwardRef.js +1 -10
  31. package/GridListImageItem/GridListImageItem.js +18 -51
  32. package/Group/Group.js +5 -36
  33. package/Group/GroupItem.js +16 -33
  34. package/Group/tests/Group-specs.js +0 -32
  35. package/Heading/Heading.js +8 -36
  36. package/Heading/tests/Heading-specs.js +81 -14
  37. package/Icon/Icon.js +19 -53
  38. package/Icon/tests/Icon-specs.js +0 -22
  39. package/IconButton/IconButton.js +24 -57
  40. package/IconButton/tests/IconButton-specs.js +0 -7
  41. package/Image/Image.js +17 -46
  42. package/Image/tests/Image-specs.js +0 -14
  43. package/ImageItem/ImageItem.js +18 -47
  44. package/ImageItem/tests/ImageItem-specs.js +0 -25
  45. package/Item/Item.js +9 -33
  46. package/Item/tests/Item-specs.js +0 -24
  47. package/LabeledIcon/LabeledIcon.js +22 -53
  48. package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
  49. package/Layout/Cell.js +18 -44
  50. package/Layout/Layout.js +23 -46
  51. package/Layout/tests/Layout-specs.js +10 -39
  52. package/Marquee/MarqueeBase.js +29 -63
  53. package/Marquee/MarqueeController.js +11 -72
  54. package/Marquee/MarqueeDecorator.js +70 -196
  55. package/Marquee/index.js +1 -5
  56. package/Marquee/tests/Marquee-specs.js +295 -87
  57. package/Measurable/Measurable.js +12 -34
  58. package/Measurable/tests/Measurable-specs.js +115 -0
  59. package/Media/Media.js +15 -65
  60. package/Media/tests/Media-specs.js +168 -0
  61. package/Placeholder/PlaceholderControllerDecorator.js +7 -43
  62. package/Placeholder/PlaceholderDecorator.js +7 -38
  63. package/Placeholder/index.js +1 -5
  64. package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +25 -0
  65. package/Placeholder/tests/PlaceholderDecorator-specs.js +28 -0
  66. package/ProgressBar/ProgressBar.js +14 -45
  67. package/ProgressBar/tests/ProgressBar-specs.js +0 -17
  68. package/RadioDecorator/RadioControllerDecorator.js +7 -29
  69. package/RadioDecorator/RadioDecorator.js +9 -42
  70. package/RadioDecorator/tests/RadioDecorator-specs.js +12 -49
  71. package/Repeater/Repeater.js +9 -33
  72. package/Repeater/tests/Repeater-specs.js +0 -38
  73. package/Resizable/Resizable.js +9 -37
  74. package/Resizable/tests/Resizable-specs.js +34 -0
  75. package/Routable/Link.js +11 -47
  76. package/Routable/Routable.js +12 -35
  77. package/Routable/Route.js +0 -6
  78. package/Routable/Router.js +15 -58
  79. package/Routable/tests/Routable-specs.js +7 -33
  80. package/Routable/tests/Router-specs.js +18 -44
  81. package/Routable/useLink.js +4 -8
  82. package/Routable/util.js +18 -24
  83. package/Scrollable/ScrollAnimator.js +49 -65
  84. package/Scrollable/ScrollThumb.js +2 -13
  85. package/Scrollable/Scrollable.js +180 -387
  86. package/Scrollable/ScrollableNative.js +189 -392
  87. package/Scrollable/Scrollbar.js +30 -102
  88. package/Scroller/Scroller.js +15 -39
  89. package/Scroller/ScrollerBasic.js +34 -89
  90. package/Scroller/UiScrollerBase.js +37 -84
  91. package/Scroller/tests/Scroller-specs.js +56 -0
  92. package/Skinnable/Skinnable.js +11 -38
  93. package/Skinnable/tests/Skinnable-specs.js +3 -74
  94. package/Skinnable/tests/useSkins-specs.js +1 -13
  95. package/Skinnable/tests/util-specs.js +0 -14
  96. package/Skinnable/useSkins.js +8 -15
  97. package/Skinnable/util.js +9 -20
  98. package/Slider/Knob.js +5 -24
  99. package/Slider/PositionDecorator.js +16 -54
  100. package/Slider/Slider.js +29 -67
  101. package/Slider/tests/Slider-specs.js +94 -7
  102. package/Slider/utils.js +0 -2
  103. package/SlotItem/SlotItem.js +23 -45
  104. package/SlotItem/tests/SlotItem-specs.js +0 -5
  105. package/Slottable/Slottable.js +4 -12
  106. package/Slottable/tests/Slottable-specs.js +19 -46
  107. package/Slottable/tests/useSlots-specs.js +27 -65
  108. package/Slottable/useSlots.js +8 -33
  109. package/Spinner/Spinner.js +16 -43
  110. package/Spinner/tests/Spinner-specs.js +0 -15
  111. package/ToggleIcon/ToggleIcon.js +10 -36
  112. package/ToggleIcon/tests/ToggleIcon-specs.js +0 -16
  113. package/ToggleItem/ToggleItem.js +24 -57
  114. package/ToggleItem/tests/ToggleItem-specs.js +0 -30
  115. package/Toggleable/Toggle.js +1 -15
  116. package/Toggleable/Toggleable.js +12 -45
  117. package/Toggleable/tests/Toggleable-specs.js +28 -96
  118. package/Toggleable/useToggle.js +3 -19
  119. package/Touchable/ClickAllow.js +5 -14
  120. package/Touchable/Drag.js +16 -54
  121. package/Touchable/Flick.js +11 -42
  122. package/Touchable/Hold.js +21 -68
  123. package/Touchable/Pinch.js +185 -0
  124. package/Touchable/Touch.js +71 -76
  125. package/Touchable/Touchable.js +95 -75
  126. package/Touchable/config.js +27 -24
  127. package/Touchable/tests/Touchable-specs.js +360 -119
  128. package/Touchable/tests/useTouch-specs.js +6 -80
  129. package/Touchable/useTouch.js +57 -65
  130. package/Transition/Transition.js +37 -118
  131. package/Transition/tests/Transition-specs.js +20 -60
  132. package/ViewManager/Arranger.js +10 -22
  133. package/ViewManager/TransitionGroup.js +32 -107
  134. package/ViewManager/View.js +35 -91
  135. package/ViewManager/ViewManager.js +20 -84
  136. package/ViewManager/tests/View-specs.js +0 -17
  137. package/ViewManager/tests/ViewManager-specs.js +236 -305
  138. package/ViewManager/tests/test-utils.js +0 -8
  139. package/VirtualList/UiVirtualListBase.js +265 -409
  140. package/VirtualList/VirtualList.js +29 -69
  141. package/VirtualList/VirtualListBase.js +0 -3
  142. package/VirtualList/VirtualListBasic.js +273 -431
  143. package/VirtualList/tests/VirtualGridList-native-specs.js +161 -0
  144. package/VirtualList/tests/VirtualGridList-specs.js +614 -0
  145. package/VirtualList/tests/VirtualList-native-specs.js +152 -0
  146. package/VirtualList/tests/VirtualList-specs.js +423 -95
  147. package/internal/IdProvider/IdProvider.js +7 -21
  148. package/internal/IdProvider/Provider.js +4 -17
  149. package/internal/IdProvider/tests/IdProvider-specs.js +44 -0
  150. package/internal/IdProvider/tests/useId-specs.js +6 -20
  151. package/internal/IdProvider/useId.js +0 -6
  152. package/internal/Pure/Pure.js +3 -30
  153. package/internal/Pure/tests/Pure-specs.js +88 -0
  154. package/internal/localized-fonts/localized-fonts.js +33 -62
  155. package/internal/localized-fonts/tests/localized-fonts-specs.js +33 -0
  156. package/internal/selection/selection.js +1 -6
  157. package/internal/selection/tests/selection-specs.js +6 -4
  158. package/internal/validators/tests/validators-specs.js +80 -0
  159. package/internal/validators/validators.js +14 -34
  160. package/package.json +9 -3
  161. package/resolution/ResolutionDecorator.js +4 -40
  162. package/resolution/index.js +0 -7
  163. package/resolution/resolution.js +42 -80
  164. package/resolution/tests/ResolutionDecorator-specs.js +4 -11
  165. package/resolution/tests/resolution-specs.js +2 -2
  166. package/useControlledState/tests/useControlledState-specs.js +15 -46
  167. package/useControlledState/useControlledState.js +11 -22
  168. package/useScroll/ScrollAnimator.js +49 -65
  169. package/useScroll/Scrollbar.js +22 -58
  170. package/useScroll/ScrollbarTrack.js +3 -19
  171. package/useScroll/useScroll.js +267 -454
  172. package/useScroll/utilDOM.js +8 -14
  173. package/useScroll/utilEvent.js +0 -4
  174. package/AnnounceDecorator/AnnounceDecorator.d.ts +0 -64
  175. package/BodyText/BodyText.d.ts +0 -66
  176. package/Button/Button.d.ts +0 -125
  177. package/Cancelable/Cancelable.d.ts +0 -64
  178. package/Changeable/Changeable.d.ts +0 -54
  179. package/ComponentOverride/ComponentOverride.d.ts +0 -52
  180. package/ForwardRef/ForwardRef.d.ts +0 -22
  181. package/GridListImageItem/GridListImageItem.d.ts +0 -85
  182. package/Group/Group.d.ts +0 -107
  183. package/Heading/Heading.d.ts +0 -90
  184. package/Icon/Icon.d.ts +0 -88
  185. package/IconButton/IconButton.d.ts +0 -115
  186. package/Image/Image.d.ts +0 -113
  187. package/ImageItem/ImageItem.d.ts +0 -83
  188. package/Item/Item.d.ts +0 -64
  189. package/LabeledIcon/LabeledIcon.d.ts +0 -130
  190. package/Layout/Layout.d.ts +0 -247
  191. package/Marquee/index.d.ts +0 -258
  192. package/Measurable/Measurable.d.ts +0 -26
  193. package/Media/Media.d.ts +0 -99
  194. package/Placeholder/index.d.ts +0 -53
  195. package/ProgressBar/ProgressBar.d.ts +0 -92
  196. package/RadioDecorator/RadioDecorator.d.ts +0 -35
  197. package/Repeater/Repeater.d.ts +0 -83
  198. package/Resizable/Resizable.d.ts +0 -31
  199. package/Routable/Routable.d.ts +0 -148
  200. package/Scrollable/Scrollable.d.ts +0 -0
  201. package/Scroller/Scroller.d.ts +0 -276
  202. package/Skinnable/Skinnable.d.ts +0 -94
  203. package/Slider/Slider.d.ts +0 -202
  204. package/SlotItem/SlotItem.d.ts +0 -118
  205. package/Slottable/Slottable.d.ts +0 -22
  206. package/Spinner/Spinner.d.ts +0 -95
  207. package/ToggleIcon/ToggleIcon.d.ts +0 -90
  208. package/ToggleItem/ToggleItem.d.ts +0 -134
  209. package/Toggleable/Toggleable.d.ts +0 -103
  210. package/Touchable/Touchable.d.ts +0 -175
  211. package/Transition/Transition.d.ts +0 -196
  212. package/ViewManager/ViewManager.d.ts +0 -191
  213. package/VirtualList/VirtualList.d.ts +0 -530
  214. package/index.d.ts +0 -0
  215. package/internal/IdProvider/IdProvider.d.ts +0 -0
  216. package/internal/Pure/Pure.d.ts +0 -0
  217. package/internal/localized-fonts/localized-fonts.d.ts +0 -53
  218. package/internal/selection/selection.d.ts +0 -0
  219. package/internal/validators/validators.d.ts +0 -0
  220. package/resolution/index.d.ts +0 -187
  221. package/useControlledState/useControlledState.d.ts +0 -0
  222. package/useScroll/useScroll.d.ts +0 -0
@@ -10,33 +10,19 @@ Object.defineProperty(exports, "useSkins", {
10
10
  return _useSkins["default"];
11
11
  }
12
12
  });
13
-
14
13
  var _classnames = _interopRequireDefault(require("classnames"));
15
-
16
14
  var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
17
-
18
15
  var _propTypes = _interopRequireDefault(require("prop-types"));
19
-
20
16
  var _useSkins = _interopRequireDefault(require("./useSkins"));
21
-
22
17
  var _util = require("./util");
23
-
24
18
  var _jsxRuntime = require("react/jsx-runtime");
25
-
26
19
  var _excluded = ["className", "skin", "skinVariants"];
27
-
28
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
29
-
30
21
  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; }
31
-
32
22
  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; }
33
-
34
23
  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; }
35
-
36
24
  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; }
37
-
38
25
  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; }
39
-
40
26
  /**
41
27
  * Default config for `Skinnable`.
42
28
  *
@@ -55,7 +41,6 @@ var defaultConfig = {
55
41
  * @memberof ui/Skinnable.Skinnable.defaultConfig
56
42
  */
57
43
  variantsProp: null,
58
-
59
44
  /**
60
45
  * The prop in which to pass the effective skin to the wrapped component.
61
46
  *
@@ -65,7 +50,6 @@ var defaultConfig = {
65
50
  * @memberof ui/Skinnable.Skinnable.defaultConfig
66
51
  */
67
52
  prop: null,
68
-
69
53
  /**
70
54
  * A hash mapping the available skin names to their CSS class name.
71
55
  *
@@ -75,7 +59,6 @@ var defaultConfig = {
75
59
  * @memberof ui/Skinnable.Skinnable.defaultConfig
76
60
  */
77
61
  skins: null,
78
-
79
62
  /**
80
63
  * Assign a default skin from the `skins` list.
81
64
  *
@@ -86,7 +69,6 @@ var defaultConfig = {
86
69
  * @memberof ui/Skinnable.Skinnable.defaultConfig
87
70
  */
88
71
  defaultSkin: null,
89
-
90
72
  /**
91
73
  * Initial collection of applied variants
92
74
  *
@@ -97,7 +79,6 @@ var defaultConfig = {
97
79
  * @memberof ui/Skinnable.Skinnable.defaultConfig
98
80
  */
99
81
  defaultVariants: null,
100
-
101
82
  /**
102
83
  * A complete list of all supported variants.
103
84
  *
@@ -109,6 +90,7 @@ var defaultConfig = {
109
90
  */
110
91
  allowedVariants: null
111
92
  };
93
+
112
94
  /**
113
95
  * A higher-order component that assigns skinning classes for the purposes of styling children components.
114
96
  *
@@ -139,21 +121,20 @@ var defaultConfig = {
139
121
  * @hoc
140
122
  * @public
141
123
  */
142
-
143
124
  var Skinnable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
144
125
  var prop = config.prop,
145
- skins = config.skins,
146
- defaultSkin = config.defaultSkin,
147
- variants = config.allowedVariants,
148
- variantsProp = config.variantsProp;
149
- var defaultVariants = (0, _util.objectify)(config.defaultVariants); // eslint-disable-next-line no-shadow
126
+ skins = config.skins,
127
+ defaultSkin = config.defaultSkin,
128
+ variants = config.allowedVariants,
129
+ variantsProp = config.variantsProp;
130
+ var defaultVariants = (0, _util.objectify)(config.defaultVariants);
150
131
 
132
+ // eslint-disable-next-line no-shadow
151
133
  function Skinnable(_ref) {
152
134
  var className = _ref.className,
153
- skin = _ref.skin,
154
- skinVariants = _ref.skinVariants,
155
- rest = _objectWithoutProperties(_ref, _excluded);
156
-
135
+ skin = _ref.skin,
136
+ skinVariants = _ref.skinVariants,
137
+ rest = _objectWithoutProperties(_ref, _excluded);
157
138
  var hook = (0, _useSkins["default"])({
158
139
  defaultSkin: defaultSkin,
159
140
  defaultVariants: defaultVariants,
@@ -163,25 +144,18 @@ var Skinnable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
163
144
  variants: variants
164
145
  });
165
146
  var allClassNames = (0, _classnames["default"])(hook.className, className);
166
-
167
147
  if (allClassNames) {
168
148
  rest.className = allClassNames;
169
149
  }
170
-
171
150
  if (prop) {
172
151
  rest[prop] = hook.skin;
173
152
  }
174
-
175
153
  if (variantsProp) {
176
154
  rest[variantsProp] = hook.variants;
177
155
  }
178
-
179
156
  return hook.provideSkins( /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread({}, rest)));
180
157
  }
181
-
182
- Skinnable.propTypes =
183
- /** @lends ui/Skinnable.Skinnable.prototype */
184
- {
158
+ Skinnable.propTypes = /** @lends ui/Skinnable.Skinnable.prototype */{
185
159
  /**
186
160
  * The name of the skin a component should use to render itself. Available skins are
187
161
  * defined in the "defaultConfig" for this HOC.
@@ -190,7 +164,6 @@ var Skinnable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
190
164
  * @public
191
165
  */
192
166
  skin: _propTypes["default"].string,
193
-
194
167
  /**
195
168
  * The variant(s) on a skin that a component should use when rendering. These will
196
169
  * typically alter the appearance of a skin's existing definition in a way that does not
@@ -1,31 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  require("@testing-library/jest-dom");
4
-
5
4
  var _react = require("@testing-library/react");
6
-
7
5
  var _Skinnable = _interopRequireDefault(require("../Skinnable"));
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
  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
-
15
9
  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; }
16
-
17
10
  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; }
18
-
19
11
  describe('Skinnable Specs', function () {
20
12
  test('should do nothing when nothing is specified', function () {
21
13
  var config = {};
22
14
  var data;
23
-
24
15
  var Component = function Component(props) {
25
16
  data = props;
26
17
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
27
18
  };
28
-
29
19
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
30
20
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {}));
31
21
  expect(data).toMatchObject({});
@@ -38,19 +28,15 @@ describe('Skinnable Specs', function () {
38
28
  light: 'lightSkin'
39
29
  }
40
30
  };
41
-
42
31
  var Component = function Component(props) {
43
32
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
44
33
  };
45
-
46
34
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
47
35
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
48
36
  "data-testid": "skinnableComponent"
49
37
  }));
50
38
  var expected = 'darkSkin';
51
-
52
39
  var component = _react.screen.getByTestId('skinnableComponent');
53
-
54
40
  expect(component).toHaveClass(expected);
55
41
  });
56
42
  test('should add the preferred skin class when the skin prop is specified', function () {
@@ -61,20 +47,16 @@ describe('Skinnable Specs', function () {
61
47
  light: 'lightSkin'
62
48
  }
63
49
  };
64
-
65
50
  var Component = function Component(props) {
66
51
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
67
52
  };
68
-
69
53
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
70
54
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
71
55
  "data-testid": "skinnableComponent",
72
56
  skin: "light"
73
57
  }));
74
58
  var expected = 'lightSkin';
75
-
76
59
  var component = _react.screen.getByTestId('skinnableComponent');
77
-
78
60
  expect(component).toHaveClass(expected);
79
61
  });
80
62
  test('should ignore the preferred skin prop if it\'s not one of the available skins', function () {
@@ -86,12 +68,10 @@ describe('Skinnable Specs', function () {
86
68
  }
87
69
  };
88
70
  var data;
89
-
90
71
  var Component = function Component(props) {
91
72
  data = props;
92
73
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
93
74
  };
94
-
95
75
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
96
76
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
97
77
  "data-testid": "skinnableComponent",
@@ -107,11 +87,9 @@ describe('Skinnable Specs', function () {
107
87
  light: 'lightSkin'
108
88
  }
109
89
  };
110
-
111
90
  var Component = function Component(props) {
112
91
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
113
92
  };
114
-
115
93
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
116
94
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
117
95
  className: "cheatingComponent",
@@ -119,9 +97,7 @@ describe('Skinnable Specs', function () {
119
97
  skin: "potato"
120
98
  }));
121
99
  var expected = 'cheatingComponent';
122
-
123
100
  var component = _react.screen.getByTestId('skinnableComponent');
124
-
125
101
  expect(component).toHaveClass(expected);
126
102
  });
127
103
  test('should ignore the skinVariants prop if there are no defined allowedVariants', function () {
@@ -132,20 +108,16 @@ describe('Skinnable Specs', function () {
132
108
  light: 'lightSkin'
133
109
  }
134
110
  };
135
-
136
111
  var Component = function Component(props) {
137
112
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
138
113
  };
139
-
140
114
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
141
115
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
142
116
  "data-testid": "skinnableComponent",
143
117
  skinVariants: "potato"
144
118
  }));
145
119
  var expected = 'darkSkin';
146
-
147
120
  var component = _react.screen.getByTestId('skinnableComponent');
148
-
149
121
  expect(component).toHaveClass(expected);
150
122
  });
151
123
  test('should only apply allowed variants assigned by the skinVariants prop', function () {
@@ -157,20 +129,16 @@ describe('Skinnable Specs', function () {
157
129
  },
158
130
  allowedVariants: ['normal', 'smallCaps', 'unicase']
159
131
  };
160
-
161
132
  var Component = function Component(props) {
162
133
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
163
134
  };
164
-
165
135
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
166
136
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
167
137
  "data-testid": "skinnableComponent",
168
138
  skinVariants: "normal potato unicase"
169
139
  }));
170
140
  var expected = 'darkSkin normal unicase';
171
-
172
141
  var component = _react.screen.getByTestId('skinnableComponent');
173
-
174
142
  expect(component).toHaveClass(expected);
175
143
  });
176
144
  test('should apply default variants even if the skinVariants prop is explicitly empty', function () {
@@ -183,20 +151,16 @@ describe('Skinnable Specs', function () {
183
151
  },
184
152
  allowedVariants: ['normal', 'smallCaps', 'unicase']
185
153
  };
186
-
187
154
  var Component = function Component(props) {
188
155
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
189
156
  };
190
-
191
157
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
192
158
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
193
159
  "data-testid": "skinnableComponent",
194
160
  skinVariants: ""
195
161
  }));
196
162
  var expected = 'darkSkin normal';
197
-
198
163
  var component = _react.screen.getByTestId('skinnableComponent');
199
-
200
164
  expect(component).toHaveClass(expected);
201
165
  });
202
166
  test('should apply default variants and the skinVariants if both are defined', function () {
@@ -209,20 +173,16 @@ describe('Skinnable Specs', function () {
209
173
  },
210
174
  allowedVariants: ['normal', 'smallCaps', 'unicase']
211
175
  };
212
-
213
176
  var Component = function Component(props) {
214
177
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
215
178
  };
216
-
217
179
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
218
180
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
219
181
  "data-testid": "skinnableComponent",
220
182
  skinVariants: "unicase"
221
183
  }));
222
184
  var expected = 'darkSkin normal unicase';
223
-
224
185
  var component = _react.screen.getByTestId('skinnableComponent');
225
-
226
186
  expect(component).toHaveClass(expected);
227
187
  });
228
188
  test('should apply variants supplied via an array or a string in the same way', function () {
@@ -235,26 +195,20 @@ describe('Skinnable Specs', function () {
235
195
  },
236
196
  allowedVariants: ['normal', 'smallCaps', 'unicase']
237
197
  };
238
-
239
198
  var Component = function Component(props) {
240
199
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
241
200
  };
242
-
243
201
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
244
202
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
245
203
  "data-testid": "skinnableComponent1",
246
204
  skinVariants: "normal unicase"
247
205
  }));
248
-
249
206
  var component1ClassNames = _react.screen.getByTestId('skinnableComponent1').className;
250
-
251
207
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
252
208
  "data-testid": "skinnableComponent2",
253
209
  skinVariants: ['normal', 'unicase']
254
210
  }));
255
-
256
211
  var component2ClassNames = _react.screen.getByTestId('skinnableComponent2').className;
257
-
258
212
  expect(component1ClassNames).toEqual(component2ClassNames);
259
213
  });
260
214
  test('should allow opting out of the default variants if an object is supplied to skinVariants with false as variant-key values', function () {
@@ -267,11 +221,9 @@ describe('Skinnable Specs', function () {
267
221
  },
268
222
  allowedVariants: ['normal', 'smallCaps', 'unicase']
269
223
  };
270
-
271
224
  var Component = function Component(props) {
272
225
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
273
226
  };
274
-
275
227
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
276
228
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
277
229
  "data-testid": "skinnableComponent",
@@ -281,9 +233,7 @@ describe('Skinnable Specs', function () {
281
233
  }
282
234
  }));
283
235
  var expected = 'darkSkin unicase';
284
-
285
236
  var component = _react.screen.getByTestId('skinnableComponent');
286
-
287
237
  expect(component).toHaveClass(expected);
288
238
  });
289
239
  test('should ignore variants, sent by an object, equaling null, undefined, or empty string', function () {
@@ -296,11 +246,9 @@ describe('Skinnable Specs', function () {
296
246
  },
297
247
  allowedVariants: ['normal', 'smallCaps', 'unicase']
298
248
  };
299
-
300
249
  var Component = function Component(props) {
301
250
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
302
251
  };
303
-
304
252
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
305
253
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
306
254
  "data-testid": "skinnableComponent",
@@ -311,9 +259,7 @@ describe('Skinnable Specs', function () {
311
259
  }
312
260
  }));
313
261
  var expected = 'darkSkin normal';
314
-
315
262
  var component = _react.screen.getByTestId('skinnableComponent');
316
-
317
263
  expect(component).toHaveClass(expected);
318
264
  });
319
265
  test('should apply parent variants', function () {
@@ -326,11 +272,9 @@ describe('Skinnable Specs', function () {
326
272
  },
327
273
  allowedVariants: ['normal', 'smallCaps', 'unicase']
328
274
  };
329
-
330
275
  var Component = function Component(props) {
331
276
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
332
277
  };
333
-
334
278
  var SkinnableParent = (0, _Skinnable["default"])(config, Component);
335
279
  var SkinnableChild = (0, _Skinnable["default"])(config, Component);
336
280
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableParent, {
@@ -341,9 +285,7 @@ describe('Skinnable Specs', function () {
341
285
  })
342
286
  }));
343
287
  var expected = 'darkSkin normal unicase smallCaps';
344
-
345
288
  var component = _react.screen.getByTestId('skinnableChild');
346
-
347
289
  expect(component).toHaveClass(expected);
348
290
  });
349
291
  test('should be able to override a parent\'s variants by assigning a false skinVariant', function () {
@@ -356,11 +298,9 @@ describe('Skinnable Specs', function () {
356
298
  },
357
299
  allowedVariants: ['normal', 'smallCaps', 'unicase']
358
300
  };
359
-
360
301
  var Component = function Component(props) {
361
302
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
362
303
  };
363
-
364
304
  var SkinnableParent = (0, _Skinnable["default"])(config, Component);
365
305
  var SkinnableChild = (0, _Skinnable["default"])(config, Component);
366
306
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableParent, {
@@ -373,9 +313,7 @@ describe('Skinnable Specs', function () {
373
313
  })
374
314
  }));
375
315
  var expected = 'darkSkin normal smallCaps';
376
-
377
316
  var component = _react.screen.getByTestId('skinnableChild');
378
-
379
317
  expect(component).toHaveClass(expected);
380
318
  });
381
319
  test('should inherit an overridden default variant', function () {
@@ -388,11 +326,9 @@ describe('Skinnable Specs', function () {
388
326
  },
389
327
  allowedVariants: ['normal', 'smallCaps', 'unicase']
390
328
  };
391
-
392
329
  var Component = function Component(props) {
393
330
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
394
331
  };
395
-
396
332
  var SkinnableParent = (0, _Skinnable["default"])(config, Component);
397
333
  var SkinnableChild = (0, _Skinnable["default"])(config, Component);
398
334
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableParent, {
@@ -406,9 +342,7 @@ describe('Skinnable Specs', function () {
406
342
  })
407
343
  }));
408
344
  var expected = 'darkSkin';
409
-
410
345
  var component = _react.screen.getByTestId('innerChild');
411
-
412
346
  expect(component).toHaveClass(expected);
413
347
  });
414
348
  test('should not force re-render of child if child unaffected', function () {
@@ -422,27 +356,22 @@ describe('Skinnable Specs', function () {
422
356
  allowedVariants: ['normal', 'smallCaps', 'unicase']
423
357
  };
424
358
  var wasRendered = jest.fn();
425
-
426
359
  var Component = function Component(props) {
427
360
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
428
361
  };
429
-
430
362
  var ChildComponent = function ChildComponent() {
431
363
  wasRendered();
432
364
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
433
365
  children: "Hello"
434
366
  });
435
367
  };
436
-
437
368
  var SkinnableParent = (0, _Skinnable["default"])(config, Component);
438
369
  var SkinnableChild = (0, _Skinnable["default"])(config, ChildComponent);
439
370
  var childrenProp = /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableChild, {});
440
-
441
371
  var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableParent, {
442
- children: childrenProp
443
- })),
444
- rerender = _render.rerender;
445
-
372
+ children: childrenProp
373
+ })),
374
+ rerender = _render.rerender;
446
375
  rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableParent, {
447
376
  className: "foo",
448
377
  children: childrenProp
@@ -1,42 +1,30 @@
1
1
  "use strict";
2
2
 
3
3
  require("@testing-library/jest-dom");
4
-
5
4
  var _react = require("@testing-library/react");
6
-
7
5
  var _useSkins = _interopRequireDefault(require("../useSkins"));
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
  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
-
15
9
  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; }
16
-
17
10
  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; }
18
-
19
11
  describe('Skinnable Specs', function () {
20
12
  var data;
21
-
22
13
  var Base = function Base(props) {
23
14
  data = props;
24
15
  return null;
25
16
  };
26
-
27
17
  function Component(_ref) {
28
18
  var config = _ref.config;
29
19
  var skins = (0, _useSkins["default"])(config);
30
20
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Base, _objectSpread({}, skins));
31
21
  }
32
-
33
22
  function Parent(_ref2) {
34
23
  var config = _ref2.config,
35
- children = _ref2.children;
24
+ children = _ref2.children;
36
25
  var skins = (0, _useSkins["default"])(config);
37
26
  return skins.provideSkins(children);
38
27
  }
39
-
40
28
  test('should add a default skin class when no skin prop is specified', function () {
41
29
  var config = {
42
30
  defaultSkin: 'dark',
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _util = require("../util");
4
-
5
4
  var _this = void 0;
6
-
7
5
  describe('Skinnable/util/objectify Specs', function () {
8
6
  test('should convert a plain string to an object with one key and value true', function () {
9
7
  var subject = 'string1';
@@ -72,49 +70,37 @@ describe('Skinnable/util/preferDefined Specs', function () {
72
70
  test('should return the first element if it is a normal string', function () {
73
71
  var subject = ['string1', 'string2'];
74
72
  var expected = 'string1';
75
-
76
73
  var actual = _util.preferDefined.apply(_this, subject);
77
-
78
74
  expect(actual).toEqual(expected);
79
75
  });
80
76
  test('should return the first element if even if it is an empty string', function () {
81
77
  var subject = ['', 'string2'];
82
78
  var expected = '';
83
-
84
79
  var actual = _util.preferDefined.apply(_this, subject);
85
-
86
80
  expect(actual).toEqual(expected);
87
81
  });
88
82
  test('should return the first element if it is a true boolean', function () {
89
83
  var subject = [true, 'string2'];
90
84
  var expected = true;
91
-
92
85
  var actual = _util.preferDefined.apply(_this, subject);
93
-
94
86
  expect(actual).toEqual(expected);
95
87
  });
96
88
  test('should return the first element if it is a false boolean', function () {
97
89
  var subject = [false, 'string2'];
98
90
  var expected = false;
99
-
100
91
  var actual = _util.preferDefined.apply(_this, subject);
101
-
102
92
  expect(actual).toEqual(expected);
103
93
  });
104
94
  test('should return the second element if the first is null', function () {
105
95
  var subject = [null, 'string2'];
106
96
  var expected = 'string2';
107
-
108
97
  var actual = _util.preferDefined.apply(_this, subject);
109
-
110
98
  expect(actual).toEqual(expected);
111
99
  });
112
100
  test('should return the second element if the first is undefined', function () {
113
101
  var subject = [void 0, 'string2'];
114
102
  var expected = 'string2';
115
-
116
103
  var actual = _util.preferDefined.apply(_this, subject);
117
-
118
104
  expect(actual).toEqual(expected);
119
105
  });
120
106
  });
@@ -5,13 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  exports.useSkins = useSkins;
8
-
9
8
  var _react = require("react");
10
-
11
9
  var _util = require("./util");
12
-
13
10
  var _jsxRuntime = require("react/jsx-runtime");
14
-
15
11
  /**
16
12
  * Allows a component to respond to skin changes via the Context API
17
13
  *
@@ -32,6 +28,7 @@ var _jsxRuntime = require("react/jsx-runtime");
32
28
  * @private
33
29
  */
34
30
  var SkinContext = /*#__PURE__*/(0, _react.createContext)(null);
31
+
35
32
  /**
36
33
  * Configuration for `useSkins`
37
34
  *
@@ -88,19 +85,16 @@ var SkinContext = /*#__PURE__*/(0, _react.createContext)(null);
88
85
  * @returns {useSkinsInterface}
89
86
  * @private
90
87
  */
91
-
92
88
  function useSkins(config) {
93
89
  var defaultSkin = config.defaultSkin,
94
- defaultVariants = config.defaultVariants,
95
- skin = config.skin,
96
- skins = config.skins,
97
- skinVariants = config.skinVariants,
98
- variants = config.variants;
99
-
90
+ defaultVariants = config.defaultVariants,
91
+ skin = config.skin,
92
+ skins = config.skins,
93
+ skinVariants = config.skinVariants,
94
+ variants = config.variants;
100
95
  var _ref = (0, _react.useContext)(SkinContext) || {},
101
- parentSkin = _ref.parentSkin,
102
- parentVariants = _ref.parentVariants;
103
-
96
+ parentSkin = _ref.parentSkin,
97
+ parentVariants = _ref.parentVariants;
104
98
  var effectiveSkin = (0, _util.determineSkin)(defaultSkin, skin, parentSkin);
105
99
  var effectiveVariants = (0, _react.useMemo)(function () {
106
100
  return (0, _util.determineVariants)(defaultVariants, variants, skinVariants, parentVariants);
@@ -125,6 +119,5 @@ function useSkins(config) {
125
119
  provideSkins: provideSkins
126
120
  };
127
121
  }
128
-
129
122
  var _default = useSkins;
130
123
  exports["default"] = _default;