@enact/ui 4.9.2 → 5.0.0-alpha.2

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 (181) hide show
  1. package/AnnounceDecorator/Announce.js +20 -22
  2. package/AnnounceDecorator/AnnounceDecorator.js +5 -5
  3. package/AnnounceDecorator/tests/Announce-specs.js +1 -1
  4. package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +1 -1
  5. package/AnnounceDecorator/tests/useAnnounce-specs.js +1 -1
  6. package/AnnounceDecorator/useAnnounce.js +1 -1
  7. package/BodyText/BodyText.js +5 -5
  8. package/BodyText/tests/BodyText-specs.js +1 -1
  9. package/Button/Button.js +5 -5
  10. package/Button/tests/Button-specs.js +3 -3
  11. package/CHANGELOG.md +33 -0
  12. package/Cancelable/Cancelable.js +22 -24
  13. package/Cancelable/tests/Cancelable-specs.js +4 -4
  14. package/Changeable/Changeable.js +22 -24
  15. package/Changeable/tests/Changeable-specs.js +1 -1
  16. package/ComponentOverride/ComponentOverride.js +4 -4
  17. package/FloatingLayer/FloatingLayer.js +20 -22
  18. package/FloatingLayer/FloatingLayerContainer.js +6 -7
  19. package/FloatingLayer/FloatingLayerDecorator.js +5 -5
  20. package/FloatingLayer/Scrim.js +18 -20
  21. package/FloatingLayer/tests/FloatingLayer-specs.js +1 -1
  22. package/FloatingLayer/tests/Scrim-specs.js +1 -1
  23. package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +2 -2
  24. package/FloatingLayer/useFloatingLayer.js +4 -4
  25. package/FloatingLayer/useFloatingLayerDecorator.js +1 -1
  26. package/ForwardRef/ForwardRef.js +3 -3
  27. package/Group/Group.js +5 -5
  28. package/Group/GroupItem.js +5 -5
  29. package/Group/tests/Group-specs.js +4 -4
  30. package/Heading/Heading.js +5 -5
  31. package/Heading/tests/Heading-specs.js +1 -1
  32. package/Icon/Icon.js +5 -5
  33. package/Icon/tests/Icon-specs.js +1 -1
  34. package/Image/Image.js +5 -5
  35. package/Image/tests/Image-specs.js +1 -1
  36. package/ImageItem/ImageItem.js +5 -5
  37. package/ImageItem/tests/ImageItem-specs.js +3 -3
  38. package/Item/Item.js +5 -5
  39. package/Item/tests/Item-specs.js +3 -3
  40. package/LabeledIcon/LabeledIcon.js +5 -5
  41. package/LabeledIcon/tests/LabeledIcon-specs.js +1 -1
  42. package/Layout/Cell.js +5 -5
  43. package/Layout/Layout.js +5 -5
  44. package/Layout/tests/Layout-specs.js +7 -7
  45. package/Marquee/MarqueeBase.js +5 -5
  46. package/Marquee/MarqueeController.js +3 -3
  47. package/Marquee/MarqueeDecorator.js +30 -51
  48. package/Marquee/index.d.ts +10 -14
  49. package/Marquee/index.js +1 -1
  50. package/Marquee/tests/Marquee-specs.js +5 -6
  51. package/Marquee/useMarqueeController.js +2 -2
  52. package/Measurable/Measurable.js +8 -8
  53. package/Measurable/tests/Measurable-specs.js +8 -10
  54. package/Media/Media.js +17 -19
  55. package/Placeholder/PlaceholderControllerDecorator.js +22 -24
  56. package/Placeholder/PlaceholderDecorator.js +20 -22
  57. package/Placeholder/index.js +1 -1
  58. package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +2 -2
  59. package/Placeholder/tests/PlaceholderDecorator-specs.js +1 -1
  60. package/ProgressBar/ProgressBar.js +5 -5
  61. package/ProgressBar/tests/ProgressBar-specs.js +1 -1
  62. package/Repeater/Repeater.js +5 -5
  63. package/Repeater/tests/Repeater-specs.js +3 -3
  64. package/Resizable/Resizable.js +3 -3
  65. package/Resizable/tests/Resizable-specs.js +2 -2
  66. package/Resizable/tests/useResize-specs.js +3 -3
  67. package/Resizable/useResize.js +3 -3
  68. package/Routable/Link.js +17 -19
  69. package/Routable/Routable.js +5 -5
  70. package/Routable/Route.js +1 -1
  71. package/Routable/Router.js +22 -24
  72. package/Routable/tests/Routable-specs.js +9 -9
  73. package/Routable/tests/Router-specs.js +1 -1
  74. package/Routable/util.js +1 -1
  75. package/Scroller/Scroller.d.ts +0 -120
  76. package/Scroller/Scroller.js +3 -11
  77. package/Scroller/ScrollerBasic.js +19 -21
  78. package/Scroller/tests/Scroller-specs.js +1 -1
  79. package/Skinnable/Skinnable.js +5 -5
  80. package/Skinnable/tests/Skinnable-specs.js +3 -3
  81. package/Skinnable/tests/useSkins-specs.js +3 -3
  82. package/Skinnable/util.js +1 -1
  83. package/Slider/Knob.js +5 -5
  84. package/Slider/PositionDecorator.js +25 -27
  85. package/Slider/Slider.js +5 -5
  86. package/Slider/tests/Slider-specs.js +1 -1
  87. package/Slottable/Slottable.js +3 -5
  88. package/Slottable/tests/Slottable-specs.js +1 -1
  89. package/Slottable/tests/useSlots-specs.js +1 -1
  90. package/Slottable/useSlots.js +5 -5
  91. package/Spinner/Spinner.js +5 -5
  92. package/ToggleIcon/ToggleIcon.js +5 -5
  93. package/ToggleIcon/tests/ToggleIcon-specs.js +3 -3
  94. package/Toggleable/Toggle.js +6 -7
  95. package/Toggleable/Toggleable.js +6 -6
  96. package/Toggleable/tests/Toggleable-specs.js +1 -1
  97. package/Toggleable/useToggle.js +8 -8
  98. package/Touchable/ClickAllow.js +5 -6
  99. package/Touchable/Drag.js +6 -6
  100. package/Touchable/Flick.js +7 -8
  101. package/Touchable/Hold.js +7 -8
  102. package/Touchable/Pinch.js +6 -6
  103. package/Touchable/Touch.js +6 -7
  104. package/Touchable/Touchable.js +5 -5
  105. package/Touchable/config.js +2 -2
  106. package/Touchable/tests/Touchable-specs.js +3 -3
  107. package/Touchable/tests/useTouch-specs.js +5 -5
  108. package/Touchable/useTouch.js +7 -7
  109. package/Transition/Transition.js +17 -19
  110. package/Transition/tests/Transition-specs.js +7 -7
  111. package/ViewManager/Arranger.js +3 -3
  112. package/ViewManager/TransitionGroup.js +18 -20
  113. package/ViewManager/View.js +15 -17
  114. package/ViewManager/ViewManager.js +25 -27
  115. package/ViewManager/tests/View-specs.js +1 -1
  116. package/ViewManager/tests/ViewManager-specs.js +16 -18
  117. package/VirtualList/VirtualList.d.ts +0 -158
  118. package/VirtualList/VirtualList.js +3 -17
  119. package/VirtualList/VirtualListBasic.js +42 -43
  120. package/VirtualList/tests/VirtualGridList-native-specs.js +4 -4
  121. package/VirtualList/tests/VirtualGridList-specs.js +6 -6
  122. package/VirtualList/tests/VirtualList-native-specs.js +5 -5
  123. package/VirtualList/tests/VirtualList-specs.js +7 -7
  124. package/internal/IdProvider/IdProvider.js +3 -3
  125. package/internal/IdProvider/Provider.js +5 -6
  126. package/internal/IdProvider/tests/IdProvider-specs.js +3 -3
  127. package/internal/IdProvider/tests/useId-specs.js +3 -3
  128. package/internal/IdProvider/useId.js +1 -1
  129. package/internal/Pure/Pure.js +20 -22
  130. package/internal/Pure/tests/Pure-specs.js +15 -17
  131. package/internal/localized-fonts/localized-fonts.js +4 -4
  132. package/internal/selection/selection.js +1 -1
  133. package/package.json +5 -4
  134. package/resolution/ResolutionDecorator.js +21 -23
  135. package/resolution/index.js +2 -2
  136. package/resolution/tests/ResolutionDecorator-specs.js +1 -1
  137. package/useControlledState/tests/useControlledState-specs.js +5 -5
  138. package/useControlledState/useControlledState.js +4 -4
  139. package/useScroll/ScrollAnimator.js +6 -7
  140. package/useScroll/Scrollbar.js +5 -5
  141. package/useScroll/ScrollbarTrack.js +5 -5
  142. package/useScroll/useScroll.js +9 -9
  143. package/useScroll/utilDOM.js +1 -1
  144. package/GridListImageItem/GridListImageItem.d.ts +0 -85
  145. package/GridListImageItem/GridListImageItem.js +0 -250
  146. package/GridListImageItem/GridListImageItem.module.css +0 -28
  147. package/GridListImageItem/package.json +0 -3
  148. package/IconButton/IconButton.d.ts +0 -115
  149. package/IconButton/IconButton.js +0 -253
  150. package/IconButton/IconButton.module.css +0 -11
  151. package/IconButton/package.json +0 -3
  152. package/IconButton/tests/IconButton-specs.js +0 -29
  153. package/RadioDecorator/RadioControllerDecorator.js +0 -101
  154. package/RadioDecorator/RadioDecorator.d.ts +0 -35
  155. package/RadioDecorator/RadioDecorator.js +0 -177
  156. package/RadioDecorator/package.json +0 -3
  157. package/RadioDecorator/tests/RadioDecorator-specs.js +0 -247
  158. package/Scrollable/ScrollAnimator.js +0 -130
  159. package/Scrollable/ScrollThumb.js +0 -57
  160. package/Scrollable/ScrollThumb.module.css +0 -34
  161. package/Scrollable/Scrollable.js +0 -1430
  162. package/Scrollable/Scrollable.module.css +0 -36
  163. package/Scrollable/ScrollableNative.js +0 -1429
  164. package/Scrollable/Scrollbar.js +0 -281
  165. package/Scrollable/Scrollbar.module.css +0 -24
  166. package/Scrollable/package.json +0 -3
  167. package/Scroller/UiScroller.module.css +0 -10
  168. package/Scroller/UiScrollerBase.js +0 -372
  169. package/SlotItem/SlotItem.d.ts +0 -118
  170. package/SlotItem/SlotItem.js +0 -248
  171. package/SlotItem/SlotItem.module.css +0 -12
  172. package/SlotItem/package.json +0 -3
  173. package/SlotItem/tests/SlotItem-specs.js +0 -24
  174. package/ToggleItem/ToggleItem.d.ts +0 -132
  175. package/ToggleItem/ToggleItem.js +0 -301
  176. package/ToggleItem/ToggleItem.module.css +0 -9
  177. package/ToggleItem/package.json +0 -3
  178. package/ToggleItem/tests/ToggleItem-specs.js +0 -120
  179. package/VirtualList/UiVirtualList.module.css +0 -26
  180. package/VirtualList/UiVirtualListBase.js +0 -1410
  181. package/VirtualList/VirtualListBase.js +0 -33
@@ -1,253 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = exports.IconButtonDecorator = exports.IconButtonBase = exports.IconButton = void 0;
7
- var _deprecate = _interopRequireDefault(require("@enact/core/internal/deprecate"));
8
- var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
9
- var _kind = _interopRequireDefault(require("@enact/core/kind"));
10
- var _propTypes2 = _interopRequireDefault(require("prop-types"));
11
- var _compose = _interopRequireDefault(require("ramda/src/compose"));
12
- var _react = require("react");
13
- var _ComponentOverride = _interopRequireDefault(require("../ComponentOverride"));
14
- var _ForwardRef = _interopRequireDefault(require("../ForwardRef"));
15
- var _Touchable = _interopRequireDefault(require("../Touchable"));
16
- var _IconButtonModule = _interopRequireDefault(require("./IconButton.module.css"));
17
- var _jsxRuntime = require("react/jsx-runtime");
18
- var _excluded = ["buttonComponent", "children", "componentRef", "css", "flip", "icon", "iconComponent", "size"];
19
- /**
20
- * An {@link ui/Icon.Icon|Icon} that acts like a {@link ui/Button.Button|Button}.
21
- *
22
- * You may specify an image or a font-based icon by setting the `children` to either the path
23
- * to the image or a string from an {@link ui/Icon.Icon.iconList|iconList}. This is unstyled,
24
- * but can easily be extended and customized by a theme or application.
25
- *
26
- * @module ui/IconButton
27
- * @exports IconButton
28
- * @exports IconButtonBase
29
- * @exports IconButtonDecorator
30
- * @deprecated Will be removed in 5.0.0. Use {@link ui/Button} instead.
31
- */
32
- /**
33
- * A ui-styled button without any behavior.
34
- *
35
- * @class IconButtonBase
36
- * @memberof ui/IconButton
37
- * @ui
38
- * @public
39
- */
40
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
41
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
42
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
43
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
44
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
45
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
46
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
47
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
48
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
49
- 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; }
50
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
51
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
52
- 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; }
53
- 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; }
54
- var IconButtonBase = exports.IconButtonBase = (0, _kind["default"])({
55
- name: 'ui:IconButton',
56
- propTypes: /** @lends ui/IconButton.IconButtonBase.prototype */{
57
- /**
58
- * This is the root component used to render the button and will receive all props except
59
- * `icon`.
60
- *
61
- * @type {Component|Element}
62
- * @required
63
- * @public
64
- */
65
- buttonComponent: _propTypes["default"].componentOverride.isRequired,
66
- /**
67
- * The component used to render the {@link ui/IconButton.IconButtonBase.icon|icon}.
68
- *
69
- * This component will receive the `flip` and `size` property set on the `IconButton` as well as the
70
- * `icon` class to customize its styling.
71
- *
72
- * @type {Component}
73
- * @required
74
- * @public
75
- */
76
- iconComponent: _propTypes["default"].component.isRequired,
77
- /**
78
- * Additional children that follow the icon.
79
- *
80
- * If `icon` isn't specified but `children` is, `children` is used as the icon's value.
81
- *
82
- * @see {@link ui/Icon.IconBase.children}
83
- * @type {Node}
84
- * @public
85
- */
86
- children: _propTypes2["default"].node,
87
- /**
88
- * Called with a reference to the root component.
89
- *
90
- * When using {@link ui/IconButton.IconButton}, the `ref` prop is forwarded to this
91
- * component as `componentRef`.
92
- *
93
- * @type {Object|Function}
94
- * @public
95
- */
96
- componentRef: _propTypes["default"].ref,
97
- /**
98
- * Customizes the component by mapping the supplied collection of CSS class names to the
99
- * corresponding internal elements and states of this component.
100
- *
101
- * The following classes are supported:
102
- *
103
- * * `iconButton` - The root component class
104
- * * `icon` - The {@link ui/IconButton.IconButtonBase.iconComponent|icon component} class
105
- * * `large` - Applied when `size` prop is `'large'`
106
- * * `small` - Applied when `size` prop is `'small'`
107
- * * `pressed` - Applied when `pressed` prop is `true`
108
- *
109
- * @type {Object}
110
- * @public
111
- */
112
- css: _propTypes2["default"].object,
113
- /**
114
- * Disables IconButton.
115
- *
116
- * When `true`, the button is shown as disabled and does not generate
117
- * `onClick` {@link /docs/developer-guide/glossary/#event|events}.
118
- *
119
- * @type {Boolean}
120
- * @default false
121
- * @public
122
- */
123
- disabled: _propTypes2["default"].bool,
124
- /**
125
- * Flip the icon horizontally, vertically or both.
126
- *
127
- * @type {('both'|'horizontal'|'vertical')}
128
- * @public
129
- */
130
- flip: _propTypes2["default"].string,
131
- /**
132
- * The icon displayed within the IconButton.
133
- *
134
- * If not specified, `children` is used as the icon value instead.
135
- *
136
- * @type {String}
137
- * @public
138
- */
139
- icon: _propTypes2["default"].string,
140
- /**
141
- * Applies the `pressed` CSS class.
142
- *
143
- * @type {Boolean}
144
- * @default false
145
- * @public
146
- */
147
- pressed: _propTypes2["default"].bool,
148
- /**
149
- * Applies the `selected` CSS class.
150
- *
151
- * @type {Boolean}
152
- * @default false
153
- * @public
154
- */
155
- selected: _propTypes2["default"].bool,
156
- /**
157
- * The size of the button.
158
- *
159
- * Applies the CSS class which can be customized by
160
- * {@link /docs/developer-guide/theming/|theming}.
161
- *
162
- * @type {String}
163
- * @public
164
- */
165
- size: _propTypes2["default"].string
166
- },
167
- defaultProps: {
168
- disabled: false,
169
- pressed: false,
170
- selected: false
171
- },
172
- styles: {
173
- css: _IconButtonModule["default"],
174
- className: 'iconButton',
175
- publicClassNames: true
176
- },
177
- computed: {
178
- className: function className(_ref) {
179
- var size = _ref.size,
180
- styler = _ref.styler;
181
- return styler.append(size);
182
- }
183
- },
184
- render: (0, _deprecate["default"])(function (_ref2) {
185
- var buttonComponent = _ref2.buttonComponent,
186
- children = _ref2.children,
187
- componentRef = _ref2.componentRef,
188
- css = _ref2.css,
189
- flip = _ref2.flip,
190
- icon = _ref2.icon,
191
- Icon = _ref2.iconComponent,
192
- size = _ref2.size,
193
- rest = _objectWithoutProperties(_ref2, _excluded);
194
- // To support the simpler use case of only specifying the icon as the children within
195
- // <IconButton>, this falls back on using children if icon isn't specified.
196
- if (!icon && children) {
197
- icon = children;
198
- children = null;
199
- }
200
- return (0, _ComponentOverride["default"])(_objectSpread(_objectSpread({}, rest), {}, {
201
- component: buttonComponent,
202
- size: size,
203
- minWidth: false,
204
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {
205
- flip: flip,
206
- size: size,
207
- className: css.icon,
208
- children: icon
209
- }, "icon")].concat(_toConsumableArray(_react.Children.toArray(children))),
210
- ref: componentRef
211
- }));
212
- }, {
213
- name: 'ui/IconButton',
214
- replacedBy: 'ui/Button',
215
- until: '5.0.0'
216
- })
217
- });
218
-
219
- /**
220
- * A higher-order component that adds universal button behaviors to an {@link ui/IconButton.IconButtonBase|IconButtonBase}.
221
- *
222
- * @hoc
223
- * @memberof ui/IconButton
224
- * @mixes ui/ForwardRef.ForwardRef
225
- * @mixes ui/Touchable.Touchable
226
- * @public
227
- */
228
- var IconButtonDecorator = exports.IconButtonDecorator = (0, _compose["default"])((0, _ForwardRef["default"])({
229
- prop: 'componentRef'
230
- }), (0, _Touchable["default"])({
231
- activeProp: 'pressed'
232
- }));
233
-
234
- /**
235
- * A minimally styled, but interactive, Button ready for customization by a theme.
236
- *
237
- * Example:
238
- * ```
239
- * <IconButton size="small">
240
- * plus
241
- * </IconButton>
242
- * ```
243
- *
244
- * @class IconButton
245
- * @extends ui/IconButton.IconButtonBase
246
- * @mixes ui/IconButton.IconButtonDecorator
247
- * @omit componentRef
248
- * @memberof ui/IconButton
249
- * @ui
250
- * @public
251
- */
252
- var IconButton = exports.IconButton = IconButtonDecorator(IconButtonBase);
253
- var _default = exports["default"] = IconButton;
@@ -1,11 +0,0 @@
1
- .iconButton {
2
- box-sizing: border-box;
3
- background-position: center 0;
4
- }
5
- .iconButton .icon {
6
- margin: 0 auto;
7
- pointer-events: none;
8
- }
9
- .iconButton.small {
10
- /* Public Class Names */
11
- }
@@ -1,3 +0,0 @@
1
- {
2
- "main": "IconButton.js"
3
- }
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- var _react = require("react");
4
- var _react2 = require("@testing-library/react");
5
- var _IconButton = _interopRequireDefault(require("../IconButton"));
6
- var _jsxRuntime = require("react/jsx-runtime");
7
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8
- describe('IconButton', function () {
9
- var Button = /*#__PURE__*/(0, _react.forwardRef)(function (props, fn) {
10
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
11
- ref: fn
12
- });
13
- });
14
- function Icon() {
15
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
16
- }
17
- test('should return a DOM node reference for `componentRef`', function () {
18
- var ref = jest.fn();
19
- (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton["default"], {
20
- ref: ref,
21
- buttonComponent: Button,
22
- iconComponent: Icon,
23
- children: "star"
24
- }));
25
- var expected = 'DIV';
26
- var actual = ref.mock.calls[0][0].nodeName;
27
- expect(actual).toBe(expected);
28
- });
29
- });
@@ -1,101 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = exports.RadioControllerDecorator = exports.RadioContext = void 0;
7
- var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
8
- var _deprecate = _interopRequireDefault(require("@enact/core/internal/deprecate"));
9
- var _Registry = _interopRequireDefault(require("@enact/core/internal/Registry"));
10
- var _react = require("react");
11
- var _jsxRuntime = require("react/jsx-runtime");
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
- 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
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
20
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
27
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
28
- var RadioContext = exports.RadioContext = /*#__PURE__*/(0, _react.createContext)();
29
-
30
- /**
31
- * A higher-order component that establishes a radio group context for its descendants.
32
- *
33
- * Any descendants that are wrapped by {@link ui/RadioDecorator.RadioDecorator} will be mutually exclusive.
34
- *
35
- * @class RadioControllerDecorator
36
- * @memberof ui/RadioDecorator
37
- * @hoc
38
- * @public
39
- * @deprecated Will be removed in 5.0.0.
40
- */
41
- var RadioControllerDecorator = exports.RadioControllerDecorator = (0, _hoc["default"])(function (config, Wrapped) {
42
- var _class;
43
- return _class = /*#__PURE__*/function (_Component) {
44
- _inherits(_class, _Component);
45
- var _super = _createSuper(_class);
46
- function _class(props) {
47
- var _this;
48
- _classCallCheck(this, _class);
49
- _this = _super.call(this, props);
50
- _this.active = null;
51
- _this.registry = _Registry["default"].create(_this.handleNotify.bind(_assertThisInitialized(_this)));
52
- return _this;
53
- }
54
- _createClass(_class, [{
55
- key: "handleNotify",
56
- value: function handleNotify(ev, instance) {
57
- if (ev.action === 'activate') {
58
- this.activate(instance);
59
- } else if (ev.action === 'deactivate') {
60
- this.deactivate(instance);
61
- }
62
- }
63
- }, {
64
- key: "activate",
65
- value: function activate(item) {
66
- var _this2 = this;
67
- // if the active radio item isn't item and item is active, try to deactivate all the
68
- // other radio items
69
- if (this.active && this.active !== item) {
70
- this.registry.notify({
71
- action: 'deactivate'
72
- }, function (i) {
73
- return i === _this2.active;
74
- });
75
- }
76
- this.active = item;
77
- }
78
- }, {
79
- key: "deactivate",
80
- value: function deactivate(item) {
81
- if (this.active === item) {
82
- this.active = null;
83
- }
84
- }
85
- }, {
86
- key: "render",
87
- value: function render() {
88
- (0, _deprecate["default"])({
89
- name: 'ui/RadioDecorator.RadioControllerDecorator',
90
- until: '5.0.0'
91
- });
92
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(RadioContext.Provider, {
93
- value: this.registry.register,
94
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread({}, this.props))
95
- });
96
- }
97
- }]);
98
- return _class;
99
- }(_react.Component), _class.displayName = 'RadioControllerDecorator', _class;
100
- });
101
- var _default = exports["default"] = RadioControllerDecorator;
@@ -1,35 +0,0 @@
1
- // Type definitions for ui/RadioDecorator
2
-
3
- type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
4
- type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
5
-
6
- export interface RadioControllerDecoratorProps {}
7
- export function RadioControllerDecorator<P>(
8
- Component: React.ComponentType<P> | string,
9
- ): React.ComponentType<P & RadioControllerDecoratorProps>;
10
-
11
- export interface RadioDecoratorConfig extends Object {
12
- /**
13
- * The event indicating the wrapped component is activated
14
- */
15
- activate?: string;
16
- /**
17
- * The event indicating the wrapped component is deactivated
18
- */
19
- deactivate?: string;
20
- /**
21
- * The name of a boolean prop that activates the wrapped component when it is true.
22
- */
23
- prop?: string;
24
- }
25
- export interface RadioDecoratorProps {}
26
- export function RadioDecorator<P>(
27
- config: RadioDecoratorConfig,
28
- Component: React.ComponentType<P> | string,
29
- ): React.ComponentType<P & RadioDecoratorProps>;
30
-
31
- export function RadioDecorator<P>(
32
- Component: React.ComponentType<P> | string,
33
- ): React.ComponentType<P & RadioDecoratorProps>;
34
-
35
- export default RadioDecorator;
@@ -1,177 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "RadioControllerDecorator", {
7
- enumerable: true,
8
- get: function get() {
9
- return _RadioControllerDecorator.RadioControllerDecorator;
10
- }
11
- });
12
- exports["default"] = exports.RadioDecorator = void 0;
13
- var _deprecate = _interopRequireDefault(require("@enact/core/internal/deprecate"));
14
- var _handle = require("@enact/core/handle");
15
- var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
16
- var _react = require("react");
17
- var _RadioControllerDecorator = require("./RadioControllerDecorator");
18
- var _jsxRuntime = require("react/jsx-runtime");
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
20
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
24
- 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); } }
25
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
26
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
27
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
28
- 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); }
29
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
30
- 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); }; }
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
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
33
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
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
- */
47
- var defaultConfig = {
48
- /**
49
- * The event indicating the wrapped component is activated
50
- *
51
- * @type {String}
52
- * @default null
53
- * @memberof ui/RadioDecorator.RadioDecorator.defaultConfig
54
- */
55
- activate: null,
56
- /**
57
- * The event indicating the wrapped component is deactivated
58
- *
59
- * @type {String}
60
- * @default null
61
- * @memberof ui/RadioDecorator.RadioDecorator.defaultConfig
62
- */
63
- deactivate: null,
64
- /**
65
- * The name of a boolean prop that activates the wrapped component when it is true.
66
- *
67
- * @type {String}
68
- * @default 'active'
69
- * @memberof ui/RadioDecorator.RadioDecorator.defaultConfig
70
- */
71
- prop: 'active'
72
- };
73
-
74
- /**
75
- * A higher-order component (HOC) that allows another component to have a mutually exclusive
76
- * relationship with other descendants of the same {@link ui/RadioDecorator.RadioControllerDecorator}.
77
- *
78
- * When the `activate` event for the wrapped component is called, the component is activated and the
79
- * previously activated component, if any, is deactivated by invoking the `deactivate` event.
80
- *
81
- * @class RadioDecorator
82
- * @memberof ui/RadioDecorator
83
- * @hoc
84
- * @public
85
- */
86
- var RadioDecorator = exports.RadioDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
87
- var _class;
88
- var activate = config.activate,
89
- deactivate = config.deactivate,
90
- prop = config.prop;
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
- /*
102
- * Invoked by a `RadioControllerDecorator` when the wrapped component should be deactivated
103
- *
104
- * @returns {undefined}
105
- */
106
- _this.deactivate = function () {
107
- if (_this.props[prop]) {
108
- (0, _handle.forwardCustom)(deactivate)(null, _this.props);
109
- }
110
- };
111
- _this.handleActivate = function () {
112
- if (_this.controller) {
113
- _this.controller.notify({
114
- action: 'activate'
115
- });
116
- }
117
- (0, _handle.forwardCustom)(activate)(null, _this.props);
118
- };
119
- _this.handleDeactivate = function () {
120
- if (_this.controller) {
121
- _this.controller.notify({
122
- action: 'deactivate'
123
- });
124
- }
125
- (0, _handle.forwardCustom)(deactivate)(null, _this.props);
126
- };
127
- return _this;
128
- }
129
- _createClass(_class, [{
130
- key: "componentDidMount",
131
- value: function componentDidMount() {
132
- if (this.context && typeof this.context === 'function') {
133
- this.controller = this.context(this.handleDeactivate);
134
- this.notifyController();
135
- }
136
- }
137
- }, {
138
- key: "componentDidUpdate",
139
- value: function componentDidUpdate() {
140
- this.notifyController();
141
- }
142
- }, {
143
- key: "componentWillUnmount",
144
- value: function componentWillUnmount() {
145
- if (this.controller) {
146
- this.controller.unregister();
147
- }
148
- }
149
- }, {
150
- key: "notifyController",
151
- value: function notifyController() {
152
- if (this.controller && prop && this.props[prop]) {
153
- this.controller.notify({
154
- action: 'activate'
155
- });
156
- }
157
- }
158
- }, {
159
- key: "render",
160
- value: function render() {
161
- (0, _deprecate["default"])({
162
- name: 'ui/RadioDecorator.RadioDecorator',
163
- until: '5.0.0'
164
- });
165
- var props = this.props;
166
- if (activate || deactivate) {
167
- props = Object.assign({}, this.props);
168
- if (activate) props[activate] = this.handleActivate;
169
- if (deactivate) props[deactivate] = this.handleDeactivate;
170
- }
171
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread({}, props));
172
- }
173
- }]);
174
- return _class;
175
- }(_react.Component), _class.displayName = 'RadioDecorator', _class.contextType = _RadioControllerDecorator.RadioContext, _class;
176
- });
177
- var _default = exports["default"] = RadioDecorator;
@@ -1,3 +0,0 @@
1
- {
2
- "main": "RadioDecorator.js"
3
- }