@enact/limestone 1.3.0 → 1.10.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 (200) hide show
  1. package/.github/workflows/ci-branch.yml +21 -0
  2. package/.github/workflows/ci-pull-request.yml +16 -0
  3. package/.github/workflows/ci-reusable.yml +73 -0
  4. package/ActionGuide/ActionGuide.d.ts +5 -4
  5. package/ActionGuide/ActionGuide.module.css +1 -1
  6. package/Alert/Alert.d.ts +13 -2
  7. package/Alert/Alert.js +39 -5
  8. package/Alert/Alert.module.css +48 -1
  9. package/Alert/tests/Alert-specs.js +91 -0
  10. package/BodyText/BodyText.d.ts +5 -4
  11. package/BodyText/BodyText.module.css +7 -7
  12. package/Button/Button.d.ts +17 -12
  13. package/Button/Button.js +1 -1
  14. package/Button/Button.module.css +195 -268
  15. package/Button/tests/Button-specs.js +26 -0
  16. package/CHANGELOG.md +254 -0
  17. package/Card/Card.d.ts +40 -12
  18. package/Card/Card.js +164 -28
  19. package/Card/Card.module.css +277 -58
  20. package/Card/tests/Card-specs.js +67 -3
  21. package/Checkbox/Checkbox.d.ts +8 -7
  22. package/Checkbox/Checkbox.js +3 -1
  23. package/Checkbox/Checkbox.module.css +213 -120
  24. package/Checkbox/tests/Checkbox-specs.js +1 -1
  25. package/CheckboxItem/CheckboxItem.d.ts +22 -7
  26. package/CheckboxItem/CheckboxItem.js +71 -4
  27. package/Chips/Chip.js +72 -13
  28. package/Chips/Chip.module.css +3 -3
  29. package/Chips/Chips.js +37 -17
  30. package/Chips/Chips.module.css +1 -1
  31. package/Chips/tests/Chip-specs.js +43 -13
  32. package/Chips/tests/Chips-specs.js +31 -21
  33. package/ColorPicker/ColorPicker.js +27 -25
  34. package/ContextualMenuDecorator/ContextualMenuDecorator.d.ts +4 -5
  35. package/ContextualPopupDecorator/ContextualPopup.module.css +34 -34
  36. package/ContextualPopupDecorator/ContextualPopupDecorator.js +567 -549
  37. package/DatePicker/DatePicker.d.ts +4 -5
  38. package/DayPicker/DayPicker.d.ts +8 -7
  39. package/DayPicker/DaySelectorDecorator.js +12 -7
  40. package/Dropdown/Dropdown.d.ts +11 -13
  41. package/Dropdown/Dropdown.module.css +13 -9
  42. package/Dropdown/DropdownList.js +80 -54
  43. package/FixedPopupPanels/FixedPopupPanels.d.ts +4 -2
  44. package/FixedPopupPanels/FixedPopupPanels.module.css +18 -18
  45. package/FlexiblePopupPanels/FlexiblePopupPanels.module.css +23 -23
  46. package/FlexiblePopupPanels/useNavButtonFocus.js +7 -10
  47. package/FormCheckboxItem/FormCheckboxItem.d.ts +5 -4
  48. package/Heading/Heading.d.ts +9 -8
  49. package/Heading/Heading.js +2 -2
  50. package/Heading/Heading.module.css +5 -5
  51. package/Icon/Icon.d.ts +15 -4
  52. package/Icon/Icon.js +49 -2
  53. package/Icon/Icon.module.css +1 -1
  54. package/Icon/IconList.js +27 -1
  55. package/IconItem/IconItem.d.ts +13 -12
  56. package/IconItem/IconItem.js +15 -0
  57. package/IconItem/IconItem.module.css +107 -1
  58. package/IconItem/tests/IconItem-specs.js +30 -1
  59. package/Image/Image.d.ts +5 -4
  60. package/Image/Image.js +6 -4
  61. package/ImageItem/ImageItem.d.ts +11 -10
  62. package/ImageItem/ImageItem.js +37 -31
  63. package/ImageItem/ImageItem.module.css +30 -30
  64. package/ImageItem/tests/ImageItem-specs.js +3 -10
  65. package/Input/Input.js +21 -3
  66. package/Input/Input.module.css +37 -8
  67. package/Input/InputField.js +79 -24
  68. package/Input/InputField.module.css +273 -41
  69. package/Input/InputFieldDecoratorIcon.js +1 -0
  70. package/Input/InputFieldSpotlightDecorator.js +257 -228
  71. package/Input/index.d.ts +120 -111
  72. package/Input/tests/Input-specs.js +26 -0
  73. package/Input/tests/InputField-specs.js +170 -3
  74. package/Input/tests/InputPopup-specs.js +1 -1
  75. package/Item/Item.d.ts +16 -9
  76. package/Item/Item.js +20 -2
  77. package/Item/Item.module.css +1 -1
  78. package/KeyGuide/KeyGuide.d.ts +8 -7
  79. package/KeyGuide/KeyGuide.js +29 -27
  80. package/KeyGuide/KeyGuide.module.css +25 -1
  81. package/Marquee/Marquee.d.ts +2 -4
  82. package/MediaOverlay/MediaOverlay.d.ts +12 -11
  83. package/MediaOverlay/MediaOverlay.js +43 -21
  84. package/MediaOverlay/MediaOverlay.module.css +114 -15
  85. package/MediaOverlay/tests/MediaOverlay-specs.js +29 -0
  86. package/MediaPlayer/MediaControls.js +195 -13
  87. package/MediaPlayer/MediaControls.module.css +3 -2
  88. package/MediaPlayer/MediaSlider.module.css +7 -20
  89. package/MediaPlayer/index.d.ts +59 -7
  90. package/MediaPlayer/tests/util-specs.js +4 -1
  91. package/PageViews/PageViews.js +232 -82
  92. package/PageViews/PageViews.module.css +3 -0
  93. package/PageViews/PageViewsRouter.js +100 -42
  94. package/PageViews/tests/PageViews-specs.js +171 -0
  95. package/Panels/Header.js +54 -34
  96. package/Panels/Header.module.css +83 -31
  97. package/Panels/Panel.module.css +1 -1
  98. package/Panels/index.d.ts +7 -8
  99. package/Picker/Picker.d.ts +4 -5
  100. package/Picker/Picker.module.css +2 -2
  101. package/Popup/Popup.js +245 -242
  102. package/Popup/Popup.module.css +24 -24
  103. package/PopupTabLayout/PopupTabLayout.d.ts +5 -7
  104. package/PopupTabLayout/PopupTabLayout.js +26 -18
  105. package/PopupTabLayout/PopupTabLayout.module.css +53 -16
  106. package/PopupTabLayout/PopupTabLayoutStateContext.js +8 -0
  107. package/ProgressBar/ProgressBar.d.ts +5 -4
  108. package/ProgressBar/ProgressBarTooltip.module.css +12 -12
  109. package/ProgressButton/ProgressButton.d.ts +4 -5
  110. package/QuickGuidePanels/QuickGuidePanels.module.css +2 -2
  111. package/RadioItem/RadioItem.d.ts +18 -5
  112. package/RadioItem/RadioItem.js +69 -2
  113. package/RadioItem/RadioItem.module.css +36 -36
  114. package/RangePicker/RangePicker.module.css +2 -2
  115. package/Scroller/EditableWrapper.js +28 -18
  116. package/Scroller/Scroller.d.ts +20 -16
  117. package/Scroller/Scroller.js +20 -13
  118. package/Scroller/Scroller.module.css +4 -4
  119. package/Scroller/useThemeScroller.js +3 -3
  120. package/Slider/Slider.d.ts +20 -14
  121. package/Slider/Slider.js +71 -14
  122. package/Slider/Slider.module.css +464 -91
  123. package/Slider/SliderBehaviorDecorator.js +16 -14
  124. package/Slider/tests/Slider-specs.js +53 -1
  125. package/Slider/utils.js +23 -7
  126. package/Spinner/Spinner.d.ts +5 -4
  127. package/Spinner/Spinner.js +10 -8
  128. package/Spinner/Spinner.module.css +9 -9
  129. package/Steps/Steps.d.ts +5 -4
  130. package/Steps/Steps.js +9 -5
  131. package/Switch/Switch.d.ts +8 -7
  132. package/Switch/Switch.module.css +100 -13
  133. package/SwitchItem/SwitchItem.d.ts +9 -6
  134. package/TabLayout/RefocusDecorator.js +26 -18
  135. package/TabLayout/TabGroup.js +3 -2
  136. package/TabLayout/TabGroup.module.css +2 -2
  137. package/TabLayout/TabLayout.d.ts +6 -0
  138. package/TabLayout/TabLayout.js +11 -1
  139. package/TabLayout/TabLayout.module.css +18 -0
  140. package/TabLayout/tests/TabGroup-specs.js +1 -1
  141. package/TabLayout/tests/TabLayout-specs.js +52 -0
  142. package/ThemeDecorator/AccessibilityDecorator.js +12 -11
  143. package/ThemeDecorator/I18nFontDecorator.js +6 -4
  144. package/ThemeDecorator/ThemeDecorator.d.ts +16 -10
  145. package/ThemeDecorator/ThemeDecorator.js +24 -9
  146. package/ThemeDecorator/fontGenerator.js +1 -1
  147. package/ThemeDecorator/screenTypes.json +1 -0
  148. package/TimePicker/TimePicker.module.css +1 -1
  149. package/TimePicker/TimePickerBase.js +5 -3
  150. package/TooltipDecorator/Tooltip.module.css +1 -2
  151. package/TooltipDecorator/TooltipDecorator.js +12 -7
  152. package/TooltipDecorator/tests/useTooltip-specs.js +5 -2
  153. package/TooltipDecorator/tests/util-specs.js +12 -0
  154. package/TooltipDecorator/useTooltip.js +1 -1
  155. package/TooltipDecorator/util.js +18 -11
  156. package/VideoPlayer/Feedback.js +3 -0
  157. package/VideoPlayer/Feedback.module.css +5 -9
  158. package/VideoPlayer/FeedbackIcons.js +1 -1
  159. package/VideoPlayer/FeedbackTooltip.module.css +55 -11
  160. package/VideoPlayer/VideoPlayer.d.ts +44 -18
  161. package/VideoPlayer/VideoPlayer.js +153 -47
  162. package/VideoPlayer/VideoPlayer.module.css +28 -11
  163. package/VirtualList/VirtualList.d.ts +9 -2
  164. package/VirtualList/VirtualList.js +51 -24
  165. package/VirtualList/tests/VirtualGridList-translate-specs.js +3 -0
  166. package/VirtualList/tests/VirtualList-specs.js +28 -1
  167. package/VirtualList/tests/VirtualList-translate-specs.js +4 -1
  168. package/VirtualList/useSpotlight.js +1 -1
  169. package/WizardPanels/WizardPanels.module.css +2 -2
  170. package/WizardPanels/index.d.ts +4 -2
  171. package/fonts/Limestone_Icons.ttf +0 -0
  172. package/internal/$L/$L.js +3 -3
  173. package/internal/AsyncRenderChildren/AsyncRenderChildren.js +9 -5
  174. package/internal/AsyncRenderChildren/tests/AsyncRenderChildren-specs.js +4 -1
  175. package/internal/DateComponentPicker/DateComponentPicker.module.css +2 -2
  176. package/internal/DateTime/DateTime.module.css +1 -0
  177. package/internal/DateTime/DateTimeDecorator.js +5 -4
  178. package/internal/Panels/PanelsRouter.js +48 -31
  179. package/internal/Panels/useAutoFocus.js +10 -6
  180. package/internal/Panels/useFocusOnTransition.js +4 -3
  181. package/internal/Picker/Picker.js +7 -5
  182. package/internal/Picker/Picker.module.css +2 -2
  183. package/internal/Picker/SpottablePicker.js +15 -13
  184. package/internal/SharedStateDecorator/SharedStateDecorator.js +78 -99
  185. package/internal/validators/validators.js +21 -2
  186. package/package.json +18 -15
  187. package/styles/colors-highcontrast.less +9 -1
  188. package/styles/colors.less +12 -7
  189. package/styles/motion-mixins.less +66 -0
  190. package/styles/motions.less +78 -0
  191. package/styles/variables.less +176 -150
  192. package/useScroll/HoverToScroll.js +23 -17
  193. package/useScroll/Scrollbar.js +14 -10
  194. package/useScroll/ScrollbarPlaceholder.js +3 -5
  195. package/useScroll/ScrollbarTrack.js +7 -5
  196. package/useScroll/ScrollbarTrack.module.css +8 -8
  197. package/useScroll/useEvent.js +14 -3
  198. package/useScroll/useScroll.js +12 -2
  199. package/useScroll/useScroll.module.css +6 -6
  200. package/.travis.yml +0 -40
package/Popup/Popup.js CHANGED
@@ -4,24 +4,25 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = exports.PopupBase = exports.Popup = void 0;
7
- var _keymap = require("@enact/core/keymap");
8
7
  var _dispatcher = require("@enact/core/dispatcher");
9
- var _FloatingLayer = _interopRequireDefault(require("@enact/ui/FloatingLayer"));
8
+ var _handle = require("@enact/core/handle");
9
+ var _keymap = require("@enact/core/keymap");
10
10
  var _kind = _interopRequireDefault(require("@enact/core/kind"));
11
- var _react = require("react");
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
+ var _util = require("@enact/core/util");
13
12
  var _spotlight = _interopRequireWildcard(require("@enact/spotlight"));
14
13
  var _Pause = _interopRequireDefault(require("@enact/spotlight/Pause"));
15
14
  var _SpotlightContainerDecorator = _interopRequireDefault(require("@enact/spotlight/SpotlightContainerDecorator"));
16
15
  var _container = require("@enact/spotlight/src/container");
16
+ var _FloatingLayer = _interopRequireDefault(require("@enact/ui/FloatingLayer"));
17
17
  var _Transition = _interopRequireDefault(require("@enact/ui/Transition"));
18
- var _handle = require("@enact/core/handle");
18
+ var _propTypes = _interopRequireDefault(require("prop-types"));
19
+ var _react = require("react");
19
20
  var _warning = _interopRequireDefault(require("warning"));
20
21
  var _Skinnable = _interopRequireDefault(require("../Skinnable"));
21
22
  var _PopupModule = _interopRequireDefault(require("./Popup.module.css"));
22
23
  var _jsxRuntime = require("react/jsx-runtime");
23
24
  var _excluded = ["children", "css", "direction", "noAnimation", "onHide", "onShow", "open", "position", "spotlightId", "spotlightRestrict", "transitionContainerClassName"],
24
- _excluded2 = ["noAutoDismiss", "scrimType"];
25
+ _excluded2 = ["noAnimation", "noAutoDismiss", "no5WayClose", "onClose", "open", "position", "scrimType", "spotlightRestrict"];
25
26
  /**
26
27
  * Modal component that appears at the bottom of the screen and takes up the full screen width.
27
28
  *
@@ -34,16 +35,12 @@ var _excluded = ["children", "css", "direction", "noAnimation", "onHide", "onSho
34
35
  */
35
36
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
36
37
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
37
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
38
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
39
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
40
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
41
- function _possibleConstructorReturn(t, e) { if (e && ("object" == typeof e || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
42
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
43
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
44
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
45
- function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
46
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
38
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
39
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
40
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
41
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
42
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
43
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
47
44
  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
45
  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
46
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -304,258 +301,272 @@ var OpenState = {
304
301
  OPENING: 1,
305
302
  OPEN: 2
306
303
  };
304
+ var popupDefaultProps = {
305
+ noAnimation: false,
306
+ noAutoDismiss: false,
307
+ open: false,
308
+ position: 'bottom',
309
+ scrimType: 'translucent',
310
+ spotlightRestrict: 'self-only'
311
+ };
307
312
 
308
313
  /**
309
314
  * A stateful component that renders a popup in a
310
315
  * {@link ui/FloatingLayer.FloatingLayer|FloatingLayer}.
311
316
  *
312
- * @class Popup
317
+ * @function Popup
313
318
  * @memberof limestone/Popup
314
319
  * @extends limestone/Popup.PopupBase
315
320
  * @ui
316
321
  * @public
317
322
  */
318
- var Popup = exports.Popup = /*#__PURE__*/function (_Component) {
319
- function Popup(props) {
320
- var _this;
321
- _classCallCheck(this, Popup);
322
- _this = _callSuper(this, Popup, [props]);
323
- _this.handleFloatingLayerOpen = function () {
324
- if (!_this.props.noAnimation && _this.state.popupOpen !== OpenState.OPEN) {
325
- _this.setState({
326
- popupOpen: OpenState.OPENING
327
- });
328
- } else if (_this.state.popupOpen === OpenState.OPEN && _this.props.open) {
329
- _this.spotPopupContent();
330
- }
331
- };
332
- _this.handleKeyDown = function (ev) {
333
- var _this$props = _this.props,
334
- onClose = _this$props.onClose,
335
- no5WayClose = _this$props.no5WayClose,
336
- position = _this$props.position,
337
- spotlightRestrict = _this$props.spotlightRestrict;
338
- if (no5WayClose) return;
339
- var containerId = _this.state.containerId;
340
- var keyCode = ev.keyCode;
341
- var direction = (0, _spotlight.getDirection)(keyCode);
342
- var spottables = _spotlight["default"].getSpottableDescendants(containerId).length;
343
- var current = _spotlight["default"].getCurrent();
344
- if (direction && (!spottables || current && getContainerNode(containerId).contains(current))) {
345
- // explicitly restrict navigation in order to manage focus state when attempting to leave the popup
346
- _spotlight["default"].set(containerId, {
347
- restrict: 'self-only'
348
- });
349
- if (onClose) {
350
- var focusChanged;
351
- if (spottables && current && spotlightRestrict !== 'self-only') {
352
- focusChanged = _spotlight["default"].move(direction);
353
- if (focusChanged) {
354
- // stop propagation to prevent default spotlight behavior
355
- ev.stopPropagation();
356
- }
323
+ var _Popup = exports.Popup = function Popup(props) {
324
+ (0, _util.checkPropTypes)(_Popup, props);
325
+ var componentProps = (0, _util.setDefaultProps)(props, popupDefaultProps);
326
+ var noAnimation = componentProps.noAnimation,
327
+ noAutoDismiss = componentProps.noAutoDismiss,
328
+ no5WayClose = componentProps.no5WayClose,
329
+ onClose = componentProps.onClose,
330
+ open = componentProps.open,
331
+ position = componentProps.position,
332
+ scrimType = componentProps.scrimType,
333
+ spotlightRestrict = componentProps.spotlightRestrict,
334
+ rest = _objectWithoutProperties(componentProps, _excluded2);
335
+
336
+ // Assign the needed props to the rest object for the child component
337
+ Object.assign(rest, {
338
+ noAnimation: noAnimation,
339
+ position: position,
340
+ spotlightRestrict: spotlightRestrict
341
+ });
342
+ var _useState = (0, _react.useState)(null),
343
+ _useState2 = _slicedToArray(_useState, 2),
344
+ activator = _useState2[0],
345
+ setActivator = _useState2[1];
346
+ var _useState3 = (0, _react.useState)(false),
347
+ _useState4 = _slicedToArray(_useState3, 2),
348
+ addKeyDownListener = _useState4[0],
349
+ setAddKeyDownListener = _useState4[1];
350
+ var _useState5 = (0, _react.useState)(open),
351
+ _useState6 = _slicedToArray(_useState5, 2),
352
+ floatLayerOpen = _useState6[0],
353
+ setFloatLayerOpen = _useState6[1];
354
+ var _useState7 = (0, _react.useState)(open ? OpenState.OPEN : OpenState.CLOSED),
355
+ _useState8 = _slicedToArray(_useState7, 2),
356
+ popupOpen = _useState8[0],
357
+ setPopupOpen = _useState8[1];
358
+ var _useState9 = (0, _react.useState)(open),
359
+ _useState0 = _slicedToArray(_useState9, 2),
360
+ prevOpen = _useState0[0],
361
+ setPrevOpen = _useState0[1];
362
+ var containerIdRef = (0, _react.useRef)(null);
363
+ var pausedRef = (0, _react.useRef)(new _Pause["default"]('Popup'));
364
+ if (!containerIdRef.current) {
365
+ containerIdRef.current = _spotlight["default"].add();
366
+ }
367
+ var getDerivedStateFromProps = (0, _react.useCallback)(function () {
368
+ if (open !== prevOpen) {
369
+ if (open) {
370
+ setPopupOpen(noAnimation || floatLayerOpen ? OpenState.OPEN : OpenState.CLOSED);
371
+ setFloatLayerOpen(true);
372
+ setActivator(_spotlight["default"].getCurrent());
373
+ setPrevOpen(open);
374
+ } else {
375
+ // Disables the spotlight container of popup when `noAnimation` set
376
+ if (noAnimation) {
377
+ var node = getContainerNode(containerIdRef.current);
378
+ if (node) {
379
+ node.dataset['spotlightContainerDisabled'] = true;
357
380
  }
358
- if (!spottables || focusChanged === false && (position === 'center' || isUp(keyCode) && position === 'bottom' || isDown(keyCode) && position === 'top' || isRight(keyCode) && position === 'left' || isLeft(keyCode) && position === 'right')) {
359
- // prevent default page scrolling
360
- ev.preventDefault();
381
+ }
382
+ setPopupOpen(OpenState.CLOSED);
383
+ setFloatLayerOpen(popupOpen === OpenState.OPEN ? !noAnimation : false);
384
+ setActivator(noAnimation ? null : activator);
385
+ setPrevOpen(open);
386
+ }
387
+ }
388
+ return null;
389
+ }, [activator, floatLayerOpen, noAnimation, open, popupOpen, prevOpen]);
390
+ var handleKeyDown = (0, _react.useCallback)(function (ev) {
391
+ if (no5WayClose) return;
392
+ var keyCode = ev.keyCode;
393
+ var direction = (0, _spotlight.getDirection)(keyCode);
394
+ var spottables = _spotlight["default"].getSpottableDescendants(containerIdRef.current).length;
395
+ var current = _spotlight["default"].getCurrent();
396
+ if (direction && (!spottables || current && getContainerNode(containerIdRef.current).contains(current))) {
397
+ // explicitly restrict navigation in order to manage focus state when attempting to leave the popup
398
+ _spotlight["default"].set(containerIdRef.current, {
399
+ restrict: 'self-only'
400
+ });
401
+ if (onClose) {
402
+ var focusChanged;
403
+ if (spottables && current && spotlightRestrict !== 'self-only') {
404
+ focusChanged = _spotlight["default"].move(direction);
405
+ if (focusChanged) {
361
406
  // stop propagation to prevent default spotlight behavior
362
407
  ev.stopPropagation();
363
- // set the pointer mode to false on keydown
364
- _spotlight["default"].setPointerMode(false);
365
- (0, _handle.forwardCustom)('onClose')(null, _this.props);
366
408
  }
367
409
  }
368
- }
369
- };
370
- _this.handleDismiss = function (ev) {
371
- (0, _handle.forwardCustom)('onClose', function () {
372
- return {
373
- detail: ev === null || ev === void 0 ? void 0 : ev.detail
374
- };
375
- })(null, _this.props);
376
- };
377
- _this.handlePopupHide = function (ev) {
378
- forwardHide(ev, _this.props);
379
- _this.setState({
380
- floatLayerOpen: false
381
- }, function () {
382
- if (!ev.currentTarget || ev.currentTarget.getAttribute('data-spotlight-id') === _this.state.containerId) {
383
- _this.spotActivator(_this.state.activator);
410
+ if (!spottables || focusChanged === false && (position === 'center' || isUp(keyCode) && position === 'bottom' || isDown(keyCode) && position === 'top' || isRight(keyCode) && position === 'left' || isLeft(keyCode) && position === 'right')) {
411
+ // prevent default page scrolling
412
+ ev.preventDefault();
413
+ // stop propagation to prevent default spotlight behavior
414
+ ev.stopPropagation();
415
+ // set the pointer mode to false on keydown
416
+ _spotlight["default"].setPointerMode(false);
417
+ (0, _handle.forwardCustom)('onClose')(null, componentProps);
384
418
  }
385
- _this.setState({
386
- activator: null
387
- });
388
- });
389
- };
390
- _this.handlePopupShow = function (ev) {
391
- forwardShow(ev, _this.props);
392
- _this.setState({
393
- popupOpen: OpenState.OPEN
394
- });
395
- if (!ev.currentTarget || ev.currentTarget.getAttribute('data-spotlight-id') === _this.state.containerId) {
396
- _this.spotPopupContent();
397
419
  }
398
- };
399
- _this.spotActivator = function (activator) {
400
- _this.paused.resume();
420
+ }
421
+ }, [componentProps, no5WayClose, onClose, position, spotlightRestrict]);
422
+ var spotActivator = (0, _react.useCallback)(function () {
423
+ pausedRef.current.resume();
401
424
 
402
- // only spot the activator if the popup is closed
403
- if (_this.props.open) return;
404
- var current = _spotlight["default"].getCurrent();
405
- var containerNode = getContainerNode(_this.state.containerId);
406
- var lastContainerId = (0, _container.getLastContainer)();
407
- (0, _dispatcher.off)('keydown', _this.handleKeyDown);
425
+ // only spot the activator if the popup is closed
426
+ if (open) return;
427
+ var current = _spotlight["default"].getCurrent();
428
+ var containerNode = getContainerNode(containerIdRef.current);
429
+ var lastContainerId = (0, _container.getLastContainer)();
430
+ setAddKeyDownListener(false);
408
431
 
409
- // if there is no currently-spotted control, or it is wrapped by the popup's container, we
410
- // know it's safe to change focus
411
- if (!current || containerNode && containerNode.contains(current)) {
412
- // attempt to set focus to the activator, if available
413
- if (!_spotlight["default"].isPaused()) {
414
- if (activator) {
415
- if (!_spotlight["default"].focus(activator)) {
416
- _spotlight["default"].focus();
417
- }
418
- } else {
419
- _spotlight["default"].disableSelector(lastContainerId);
432
+ // if there is no currently-spotted control, or it is wrapped by the popup's container, we
433
+ // know it's safe to change focus
434
+ if (!current || containerNode && containerNode.contains(current)) {
435
+ // attempt to set focus to the activator, if available
436
+ if (!_spotlight["default"].isPaused() || !pausedRef.current.isPaused()) {
437
+ if (activator) {
438
+ if (!_spotlight["default"].focus(activator)) {
420
439
  _spotlight["default"].focus();
421
- _spotlight["default"].enableSelector(lastContainerId);
422
440
  }
441
+ } else {
442
+ _spotlight["default"].disableSelector(lastContainerId);
443
+ _spotlight["default"].focus();
444
+ _spotlight["default"].enableSelector(lastContainerId);
423
445
  }
424
446
  }
425
- };
426
- _this.spotPopupContent = function () {
427
- _this.paused.resume();
447
+ }
448
+ }, [activator, open]);
449
+ var spotPopupContent = (0, _react.useCallback)(function () {
450
+ pausedRef.current.resume();
428
451
 
429
- // only spot the activator if the popup is open
430
- if (!_this.props.open) return;
431
- var containerId = _this.state.containerId;
432
- (0, _dispatcher.on)('keydown', _this.handleKeyDown);
433
- if (!_spotlight["default"].isPaused() && !_spotlight["default"].focus(containerId)) {
434
- var current = _spotlight["default"].getCurrent();
452
+ // only spot the activator if the popup is open
453
+ if (!open) return;
454
+ setAddKeyDownListener(true);
455
+ if (!_spotlight["default"].isPaused() && !_spotlight["default"].focus(containerIdRef.current)) {
456
+ var current = _spotlight["default"].getCurrent();
435
457
 
436
- // In cases where the container contains no spottable controls, or we're in pointer-mode, focus
437
- // cannot inherently set the active container or blur the active control, so we must do that
438
- // here.
439
- if (current) {
440
- current.blur();
441
- }
442
- _spotlight["default"].setActiveContainer(containerId);
458
+ // In cases where the container contains no spottable controls, or we're in pointer-mode, focus
459
+ // cannot inherently set the active container or blur the active control, so we must do that
460
+ // here.
461
+ if (current) {
462
+ current.blur();
443
463
  }
444
- };
445
- _this.paused = new _Pause["default"]('Popup');
446
- _this.state = {
447
- floatLayerOpen: _this.props.open,
448
- popupOpen: _this.props.open ? OpenState.OPEN : OpenState.CLOSED,
449
- prevOpen: _this.props.open,
450
- containerId: _spotlight["default"].add(),
451
- activator: null
452
- };
453
- checkScrimNone(_this.props);
454
- return _this;
455
- }
456
-
457
- // Spot the content after it's mounted.
458
- _inherits(Popup, _Component);
459
- return _createClass(Popup, [{
460
- key: "componentDidMount",
461
- value: function componentDidMount() {
462
- if (this.props.open) {
463
- // If the popup is open on mount, we need to pause spotlight so nothing steals focus
464
- // while the popup is rendering.
465
- this.paused.pause();
466
- if (getContainerNode(this.state.containerId)) {
467
- this.spotPopupContent();
468
- }
464
+ _spotlight["default"].setActiveContainer(containerIdRef.current);
465
+ }
466
+ }, [open]);
467
+ var handleFloatingLayerOpen = (0, _react.useCallback)(function () {
468
+ if (!noAnimation && popupOpen !== OpenState.OPEN) {
469
+ setPopupOpen(OpenState.OPENING);
470
+ } else if (popupOpen === OpenState.OPEN && open) {
471
+ spotPopupContent();
472
+ }
473
+ }, [noAnimation, open, popupOpen, spotPopupContent]);
474
+ var handleDismiss = (0, _react.useCallback)(function (ev) {
475
+ (0, _handle.forwardCustom)('onClose', function () {
476
+ return {
477
+ detail: ev === null || ev === void 0 ? void 0 : ev.detail
478
+ };
479
+ })(null, componentProps);
480
+ }, [componentProps]);
481
+ var handlePopupHide = (0, _react.useCallback)(function (ev) {
482
+ forwardHide(ev, componentProps);
483
+ setFloatLayerOpen(function () {
484
+ if (!ev.currentTarget || ev.currentTarget.getAttribute('data-spotlight-id') === containerIdRef.current) {
485
+ spotActivator();
469
486
  }
487
+ setActivator(null);
488
+ return false;
489
+ });
490
+ }, [componentProps, spotActivator]);
491
+ var handlePopupShow = (0, _react.useCallback)(function (ev) {
492
+ forwardShow(ev, componentProps);
493
+ setPopupOpen(OpenState.OPEN);
494
+ if (!ev.currentTarget || ev.currentTarget.getAttribute('data-spotlight-id') === containerIdRef.current) {
495
+ spotPopupContent();
470
496
  }
471
- }, {
472
- key: "componentDidUpdate",
473
- value: function componentDidUpdate(prevProps, prevState) {
474
- if (this.props.open !== prevProps.open) {
475
- if (!this.props.noAnimation) {
476
- if (!this.props.open && this.state.popupOpen === OpenState.CLOSED) {
477
- // If the popup is supposed to be closed (!this.props.open) and is actually
478
- // fully closed (OpenState.CLOSED), we must resume spotlight navigation. This
479
- // can occur when quickly toggling a Popup open and closed.
480
- this.paused.resume();
481
- } else {
482
- // Otherwise, we pause spotlight so it is locked until the popup is ready
483
- this.paused.pause();
484
- }
485
- } else if (this.props.open) {
486
- forwardShow(null, this.props);
487
- this.spotPopupContent();
488
- } else if (prevProps.open) {
489
- forwardHide(null, this.props);
490
- this.spotActivator(prevState.activator);
497
+ }, [componentProps, spotPopupContent]);
498
+ (0, _react.useLayoutEffect)(function () {
499
+ getDerivedStateFromProps();
500
+ }, [getDerivedStateFromProps]);
501
+ (0, _react.useEffect)(function () {
502
+ if (open !== prevOpen) {
503
+ if (!noAnimation) {
504
+ if (!open && (popupOpen === OpenState.OPENING || popupOpen === OpenState.OPEN)) {
505
+ // If the popup is supposed to be closed (!open) and is actually not fully
506
+ // closed (OpenState.OPENING or OpenState.OPEN), we must resume spotlight navigation. This
507
+ // can occur when quickly toggling a Popup open and closed.
508
+ pausedRef.current.resume();
509
+ } else {
510
+ // Otherwise, we pause spotlight so it is locked until the popup is ready
511
+ pausedRef.current.pause();
491
512
  }
513
+ } else if (open) {
514
+ forwardShow(null, componentProps);
515
+ spotPopupContent();
516
+ } else if (prevOpen) {
517
+ forwardHide(null, componentProps);
518
+ spotActivator();
492
519
  }
493
- checkScrimNone(this.props);
494
520
  }
495
- }, {
496
- key: "componentWillUnmount",
497
- value: function componentWillUnmount() {
498
- if (this.props.open) {
499
- (0, _dispatcher.off)('keydown', this.handleKeyDown);
521
+ checkScrimNone(componentProps);
522
+ }, [componentProps, noAnimation, open, popupOpen, prevOpen, spotActivator, spotPopupContent]);
523
+ (0, _react.useEffect)(function () {
524
+ checkScrimNone(componentProps);
525
+
526
+ // Spot the content after it's mounted.
527
+ if (open) {
528
+ // If the popup is open on mount, we need to pause spotlight so nothing steals focus
529
+ // while the popup is rendering.
530
+ pausedRef.current.pause();
531
+ if (getContainerNode(containerIdRef.current)) {
532
+ spotPopupContent();
500
533
  }
501
- _spotlight["default"].remove(this.state.containerId);
502
- }
503
- }, {
504
- key: "render",
505
- value: function render() {
506
- var _this$props2 = this.props,
507
- noAutoDismiss = _this$props2.noAutoDismiss,
508
- scrimType = _this$props2.scrimType,
509
- rest = _objectWithoutProperties(_this$props2, _excluded2);
510
- delete rest.no5WayClose;
511
- delete rest.onClose;
512
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_FloatingLayer["default"], {
513
- noAutoDismiss: noAutoDismiss,
514
- open: this.state.floatLayerOpen,
515
- onOpen: this.handleFloatingLayerOpen,
516
- onDismiss: this.handleDismiss,
517
- scrimType: scrimType,
518
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnedPopupBase, _objectSpread(_objectSpread({}, rest), {}, {
519
- "data-webos-voice-exclusive": true,
520
- onHide: this.handlePopupHide,
521
- onShow: this.handlePopupShow,
522
- open: this.state.popupOpen >= OpenState.OPENING,
523
- spotlightId: this.state.containerId
524
- }))
525
- });
526
534
  }
527
- }], [{
528
- key: "getDerivedStateFromProps",
529
- value: function getDerivedStateFromProps(props, state) {
530
- if (props.open !== state.prevOpen) {
531
- if (props.open) {
532
- return {
533
- popupOpen: props.noAnimation || state.floatLayerOpen ? OpenState.OPEN : OpenState.CLOSED,
534
- floatLayerOpen: true,
535
- activator: _spotlight["default"].getCurrent(),
536
- prevOpen: props.open
537
- };
538
- } else {
539
- // Disables the spotlight conatiner of popup when `noAnimation` set
540
- if (props.noAnimation) {
541
- var node = getContainerNode(state.containerId);
542
- if (node) {
543
- node.dataset['spotlightContainerDisabled'] = true;
544
- }
545
- }
546
- return {
547
- popupOpen: OpenState.CLOSED,
548
- floatLayerOpen: state.popupOpen === OpenState.OPEN ? !props.noAnimation : false,
549
- activator: props.noAnimation ? null : state.activator,
550
- prevOpen: props.open
551
- };
552
- }
535
+ return function () {
536
+ if (open) {
537
+ (0, _dispatcher.off)('keydown', handleKeyDown);
553
538
  }
554
- return null;
539
+ _spotlight["default"].remove(containerIdRef.current);
540
+ };
541
+ // eslint-disable-next-line react-hooks/exhaustive-deps
542
+ }, []);
543
+ (0, _react.useEffect)(function () {
544
+ if (addKeyDownListener) {
545
+ (0, _dispatcher.on)('keydown', handleKeyDown);
546
+ } else {
547
+ (0, _dispatcher.off)('keydown', handleKeyDown);
555
548
  }
556
- }]);
557
- }(_react.Component);
558
- Popup.propTypes = /** @lends limestone/Popup.Popup.prototype */{
549
+ return function () {
550
+ (0, _dispatcher.off)('keydown', handleKeyDown);
551
+ };
552
+ }, [addKeyDownListener, handleKeyDown]);
553
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_FloatingLayer["default"], {
554
+ noAutoDismiss: noAutoDismiss,
555
+ open: floatLayerOpen,
556
+ onOpen: handleFloatingLayerOpen,
557
+ onDismiss: handleDismiss,
558
+ scrimType: scrimType,
559
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnedPopupBase, _objectSpread(_objectSpread({}, rest), {}, {
560
+ "data-webos-voice-exclusive": true,
561
+ onHide: handlePopupHide,
562
+ onShow: handlePopupShow,
563
+ open: popupOpen >= OpenState.OPENING,
564
+ spotlightId: containerIdRef.current
565
+ }))
566
+ });
567
+ };
568
+ _Popup.displayName = 'Popup';
569
+ _Popup.propTypes = /** @lends limestone/Popup.Popup.prototype */{
559
570
  /**
560
571
  * Prevents closing the popup via 5-way navigation out of the content.
561
572
  *
@@ -679,12 +690,4 @@ Popup.propTypes = /** @lends limestone/Popup.Popup.prototype */{
679
690
  */
680
691
  spotlightRestrict: _propTypes["default"].oneOf(['self-first', 'self-only'])
681
692
  };
682
- Popup.defaultProps = {
683
- noAnimation: false,
684
- noAutoDismiss: false,
685
- open: false,
686
- position: 'bottom',
687
- scrimType: 'translucent',
688
- spotlightRestrict: 'self-only'
689
- };
690
- var _default = exports["default"] = Popup;
693
+ var _default = exports["default"] = _Popup;