@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.
- package/.github/workflows/ci-branch.yml +21 -0
- package/.github/workflows/ci-pull-request.yml +16 -0
- package/.github/workflows/ci-reusable.yml +73 -0
- package/ActionGuide/ActionGuide.d.ts +5 -4
- package/ActionGuide/ActionGuide.module.css +1 -1
- package/Alert/Alert.d.ts +13 -2
- package/Alert/Alert.js +39 -5
- package/Alert/Alert.module.css +48 -1
- package/Alert/tests/Alert-specs.js +91 -0
- package/BodyText/BodyText.d.ts +5 -4
- package/BodyText/BodyText.module.css +7 -7
- package/Button/Button.d.ts +17 -12
- package/Button/Button.js +1 -1
- package/Button/Button.module.css +195 -268
- package/Button/tests/Button-specs.js +26 -0
- package/CHANGELOG.md +254 -0
- package/Card/Card.d.ts +40 -12
- package/Card/Card.js +164 -28
- package/Card/Card.module.css +277 -58
- package/Card/tests/Card-specs.js +67 -3
- package/Checkbox/Checkbox.d.ts +8 -7
- package/Checkbox/Checkbox.js +3 -1
- package/Checkbox/Checkbox.module.css +213 -120
- package/Checkbox/tests/Checkbox-specs.js +1 -1
- package/CheckboxItem/CheckboxItem.d.ts +22 -7
- package/CheckboxItem/CheckboxItem.js +71 -4
- package/Chips/Chip.js +72 -13
- package/Chips/Chip.module.css +3 -3
- package/Chips/Chips.js +37 -17
- package/Chips/Chips.module.css +1 -1
- package/Chips/tests/Chip-specs.js +43 -13
- package/Chips/tests/Chips-specs.js +31 -21
- package/ColorPicker/ColorPicker.js +27 -25
- package/ContextualMenuDecorator/ContextualMenuDecorator.d.ts +4 -5
- package/ContextualPopupDecorator/ContextualPopup.module.css +34 -34
- package/ContextualPopupDecorator/ContextualPopupDecorator.js +567 -549
- package/DatePicker/DatePicker.d.ts +4 -5
- package/DayPicker/DayPicker.d.ts +8 -7
- package/DayPicker/DaySelectorDecorator.js +12 -7
- package/Dropdown/Dropdown.d.ts +11 -13
- package/Dropdown/Dropdown.module.css +13 -9
- package/Dropdown/DropdownList.js +80 -54
- package/FixedPopupPanels/FixedPopupPanels.d.ts +4 -2
- package/FixedPopupPanels/FixedPopupPanels.module.css +18 -18
- package/FlexiblePopupPanels/FlexiblePopupPanels.module.css +23 -23
- package/FlexiblePopupPanels/useNavButtonFocus.js +7 -10
- package/FormCheckboxItem/FormCheckboxItem.d.ts +5 -4
- package/Heading/Heading.d.ts +9 -8
- package/Heading/Heading.js +2 -2
- package/Heading/Heading.module.css +5 -5
- package/Icon/Icon.d.ts +15 -4
- package/Icon/Icon.js +49 -2
- package/Icon/Icon.module.css +1 -1
- package/Icon/IconList.js +27 -1
- package/IconItem/IconItem.d.ts +13 -12
- package/IconItem/IconItem.js +15 -0
- package/IconItem/IconItem.module.css +107 -1
- package/IconItem/tests/IconItem-specs.js +30 -1
- package/Image/Image.d.ts +5 -4
- package/Image/Image.js +6 -4
- package/ImageItem/ImageItem.d.ts +11 -10
- package/ImageItem/ImageItem.js +37 -31
- package/ImageItem/ImageItem.module.css +30 -30
- package/ImageItem/tests/ImageItem-specs.js +3 -10
- package/Input/Input.js +21 -3
- package/Input/Input.module.css +37 -8
- package/Input/InputField.js +79 -24
- package/Input/InputField.module.css +273 -41
- package/Input/InputFieldDecoratorIcon.js +1 -0
- package/Input/InputFieldSpotlightDecorator.js +257 -228
- package/Input/index.d.ts +120 -111
- package/Input/tests/Input-specs.js +26 -0
- package/Input/tests/InputField-specs.js +170 -3
- package/Input/tests/InputPopup-specs.js +1 -1
- package/Item/Item.d.ts +16 -9
- package/Item/Item.js +20 -2
- package/Item/Item.module.css +1 -1
- package/KeyGuide/KeyGuide.d.ts +8 -7
- package/KeyGuide/KeyGuide.js +29 -27
- package/KeyGuide/KeyGuide.module.css +25 -1
- package/Marquee/Marquee.d.ts +2 -4
- package/MediaOverlay/MediaOverlay.d.ts +12 -11
- package/MediaOverlay/MediaOverlay.js +43 -21
- package/MediaOverlay/MediaOverlay.module.css +114 -15
- package/MediaOverlay/tests/MediaOverlay-specs.js +29 -0
- package/MediaPlayer/MediaControls.js +195 -13
- package/MediaPlayer/MediaControls.module.css +3 -2
- package/MediaPlayer/MediaSlider.module.css +7 -20
- package/MediaPlayer/index.d.ts +59 -7
- package/MediaPlayer/tests/util-specs.js +4 -1
- package/PageViews/PageViews.js +232 -82
- package/PageViews/PageViews.module.css +3 -0
- package/PageViews/PageViewsRouter.js +100 -42
- package/PageViews/tests/PageViews-specs.js +171 -0
- package/Panels/Header.js +54 -34
- package/Panels/Header.module.css +83 -31
- package/Panels/Panel.module.css +1 -1
- package/Panels/index.d.ts +7 -8
- package/Picker/Picker.d.ts +4 -5
- package/Picker/Picker.module.css +2 -2
- package/Popup/Popup.js +245 -242
- package/Popup/Popup.module.css +24 -24
- package/PopupTabLayout/PopupTabLayout.d.ts +5 -7
- package/PopupTabLayout/PopupTabLayout.js +26 -18
- package/PopupTabLayout/PopupTabLayout.module.css +53 -16
- package/PopupTabLayout/PopupTabLayoutStateContext.js +8 -0
- package/ProgressBar/ProgressBar.d.ts +5 -4
- package/ProgressBar/ProgressBarTooltip.module.css +12 -12
- package/ProgressButton/ProgressButton.d.ts +4 -5
- package/QuickGuidePanels/QuickGuidePanels.module.css +2 -2
- package/RadioItem/RadioItem.d.ts +18 -5
- package/RadioItem/RadioItem.js +69 -2
- package/RadioItem/RadioItem.module.css +36 -36
- package/RangePicker/RangePicker.module.css +2 -2
- package/Scroller/EditableWrapper.js +28 -18
- package/Scroller/Scroller.d.ts +20 -16
- package/Scroller/Scroller.js +20 -13
- package/Scroller/Scroller.module.css +4 -4
- package/Scroller/useThemeScroller.js +3 -3
- package/Slider/Slider.d.ts +20 -14
- package/Slider/Slider.js +71 -14
- package/Slider/Slider.module.css +464 -91
- package/Slider/SliderBehaviorDecorator.js +16 -14
- package/Slider/tests/Slider-specs.js +53 -1
- package/Slider/utils.js +23 -7
- package/Spinner/Spinner.d.ts +5 -4
- package/Spinner/Spinner.js +10 -8
- package/Spinner/Spinner.module.css +9 -9
- package/Steps/Steps.d.ts +5 -4
- package/Steps/Steps.js +9 -5
- package/Switch/Switch.d.ts +8 -7
- package/Switch/Switch.module.css +100 -13
- package/SwitchItem/SwitchItem.d.ts +9 -6
- package/TabLayout/RefocusDecorator.js +26 -18
- package/TabLayout/TabGroup.js +3 -2
- package/TabLayout/TabGroup.module.css +2 -2
- package/TabLayout/TabLayout.d.ts +6 -0
- package/TabLayout/TabLayout.js +11 -1
- package/TabLayout/TabLayout.module.css +18 -0
- package/TabLayout/tests/TabGroup-specs.js +1 -1
- package/TabLayout/tests/TabLayout-specs.js +52 -0
- package/ThemeDecorator/AccessibilityDecorator.js +12 -11
- package/ThemeDecorator/I18nFontDecorator.js +6 -4
- package/ThemeDecorator/ThemeDecorator.d.ts +16 -10
- package/ThemeDecorator/ThemeDecorator.js +24 -9
- package/ThemeDecorator/fontGenerator.js +1 -1
- package/ThemeDecorator/screenTypes.json +1 -0
- package/TimePicker/TimePicker.module.css +1 -1
- package/TimePicker/TimePickerBase.js +5 -3
- package/TooltipDecorator/Tooltip.module.css +1 -2
- package/TooltipDecorator/TooltipDecorator.js +12 -7
- package/TooltipDecorator/tests/useTooltip-specs.js +5 -2
- package/TooltipDecorator/tests/util-specs.js +12 -0
- package/TooltipDecorator/useTooltip.js +1 -1
- package/TooltipDecorator/util.js +18 -11
- package/VideoPlayer/Feedback.js +3 -0
- package/VideoPlayer/Feedback.module.css +5 -9
- package/VideoPlayer/FeedbackIcons.js +1 -1
- package/VideoPlayer/FeedbackTooltip.module.css +55 -11
- package/VideoPlayer/VideoPlayer.d.ts +44 -18
- package/VideoPlayer/VideoPlayer.js +153 -47
- package/VideoPlayer/VideoPlayer.module.css +28 -11
- package/VirtualList/VirtualList.d.ts +9 -2
- package/VirtualList/VirtualList.js +51 -24
- package/VirtualList/tests/VirtualGridList-translate-specs.js +3 -0
- package/VirtualList/tests/VirtualList-specs.js +28 -1
- package/VirtualList/tests/VirtualList-translate-specs.js +4 -1
- package/VirtualList/useSpotlight.js +1 -1
- package/WizardPanels/WizardPanels.module.css +2 -2
- package/WizardPanels/index.d.ts +4 -2
- package/fonts/Limestone_Icons.ttf +0 -0
- package/internal/$L/$L.js +3 -3
- package/internal/AsyncRenderChildren/AsyncRenderChildren.js +9 -5
- package/internal/AsyncRenderChildren/tests/AsyncRenderChildren-specs.js +4 -1
- package/internal/DateComponentPicker/DateComponentPicker.module.css +2 -2
- package/internal/DateTime/DateTime.module.css +1 -0
- package/internal/DateTime/DateTimeDecorator.js +5 -4
- package/internal/Panels/PanelsRouter.js +48 -31
- package/internal/Panels/useAutoFocus.js +10 -6
- package/internal/Panels/useFocusOnTransition.js +4 -3
- package/internal/Picker/Picker.js +7 -5
- package/internal/Picker/Picker.module.css +2 -2
- package/internal/Picker/SpottablePicker.js +15 -13
- package/internal/SharedStateDecorator/SharedStateDecorator.js +78 -99
- package/internal/validators/validators.js +21 -2
- package/package.json +18 -15
- package/styles/colors-highcontrast.less +9 -1
- package/styles/colors.less +12 -7
- package/styles/motion-mixins.less +66 -0
- package/styles/motions.less +78 -0
- package/styles/variables.less +176 -150
- package/useScroll/HoverToScroll.js +23 -17
- package/useScroll/Scrollbar.js +14 -10
- package/useScroll/ScrollbarPlaceholder.js +3 -5
- package/useScroll/ScrollbarTrack.js +7 -5
- package/useScroll/ScrollbarTrack.module.css +8 -8
- package/useScroll/useEvent.js +14 -3
- package/useScroll/useScroll.js +12 -2
- package/useScroll/useScroll.module.css +6 -6
- 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
|
|
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
|
|
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
|
|
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
|
|
38
|
-
function
|
|
39
|
-
function
|
|
40
|
-
function
|
|
41
|
-
function
|
|
42
|
-
function
|
|
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
|
-
* @
|
|
317
|
+
* @function Popup
|
|
313
318
|
* @memberof limestone/Popup
|
|
314
319
|
* @extends limestone/Popup.PopupBase
|
|
315
320
|
* @ui
|
|
316
321
|
* @public
|
|
317
322
|
*/
|
|
318
|
-
var
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
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
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
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
|
-
|
|
400
|
-
|
|
420
|
+
}
|
|
421
|
+
}, [componentProps, no5WayClose, onClose, position, spotlightRestrict]);
|
|
422
|
+
var spotActivator = (0, _react.useCallback)(function () {
|
|
423
|
+
pausedRef.current.resume();
|
|
401
424
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
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
|
-
|
|
427
|
-
|
|
447
|
+
}
|
|
448
|
+
}, [activator, open]);
|
|
449
|
+
var spotPopupContent = (0, _react.useCallback)(function () {
|
|
450
|
+
pausedRef.current.resume();
|
|
428
451
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
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
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
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
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
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
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
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
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
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
|
-
|
|
529
|
-
|
|
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
|
-
|
|
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
|
-
|
|
558
|
-
|
|
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
|
-
|
|
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;
|