@enact/limestone 1.3.0 → 1.9.3
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 +4 -2
- package/Alert/Alert.js +4 -1
- package/Alert/Alert.module.css +36 -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/CHANGELOG.md +220 -0
- package/Card/Card.d.ts +36 -8
- package/Card/Card.js +157 -20
- package/Card/Card.module.css +277 -58
- package/Card/tests/Card-specs.js +30 -0
- 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 +69 -4
- package/Chips/Chip.js +60 -7
- package/Chips/Chip.module.css +3 -3
- package/Chips/Chips.js +26 -12
- package/Chips/Chips.module.css +1 -1
- package/Chips/tests/Chip-specs.js +19 -9
- package/Chips/tests/Chips-specs.js +19 -19
- package/ContextualMenuDecorator/ContextualMenuDecorator.d.ts +4 -5
- package/ContextualPopupDecorator/ContextualPopup.module.css +34 -34
- package/ContextualPopupDecorator/ContextualPopupDecorator.js +557 -549
- package/DatePicker/DatePicker.d.ts +4 -5
- package/DayPicker/DayPicker.d.ts +8 -7
- package/Dropdown/Dropdown.d.ts +11 -13
- package/Dropdown/Dropdown.module.css +9 -9
- package/Dropdown/DropdownList.js +16 -11
- package/FixedPopupPanels/FixedPopupPanels.d.ts +4 -2
- package/FixedPopupPanels/FixedPopupPanels.module.css +18 -18
- package/FlexiblePopupPanels/FlexiblePopupPanels.module.css +23 -23
- package/FormCheckboxItem/FormCheckboxItem.d.ts +5 -4
- package/Heading/Heading.d.ts +8 -7
- package/Heading/Heading.module.css +5 -5
- package/Icon/Icon.d.ts +14 -4
- package/Icon/Icon.js +48 -2
- package/Icon/Icon.module.css +1 -1
- package/Icon/IconList.js +25 -1
- package/IconItem/IconItem.d.ts +13 -12
- package/IconItem/IconItem.js +15 -0
- package/IconItem/IconItem.module.css +107 -1
- package/Image/Image.d.ts +5 -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 +9 -2
- package/Input/Input.module.css +37 -8
- package/Input/InputField.js +5 -1
- package/Input/InputField.module.css +17 -2
- package/Input/InputFieldSpotlightDecorator.js +213 -229
- package/Input/index.d.ts +15 -18
- package/Input/tests/InputField-specs.js +21 -0
- 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.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/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/PageViews/PageViews.js +165 -80
- package/PageViews/PageViewsRouter.js +9 -0
- package/PageViews/tests/PageViews-specs.js +84 -0
- package/Panels/Header.js +48 -30
- 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 +242 -240
- package/Popup/Popup.module.css +24 -24
- package/PopupTabLayout/PopupTabLayout.d.ts +5 -7
- package/PopupTabLayout/PopupTabLayout.js +15 -9
- 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 +67 -2
- package/RadioItem/RadioItem.module.css +36 -36
- package/RangePicker/RangePicker.module.css +2 -2
- package/Scroller/EditableWrapper.js +11 -4
- package/Scroller/Scroller.d.ts +20 -16
- package/Scroller/Scroller.js +9 -3
- package/Scroller/Scroller.module.css +4 -4
- package/Slider/Slider.d.ts +16 -14
- package/Slider/Slider.js +37 -4
- package/Slider/Slider.module.css +314 -91
- package/Slider/tests/Slider-specs.js +2 -1
- package/Spinner/Spinner.d.ts +5 -4
- 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 +15 -9
- 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/TabLayout-specs.js +52 -0
- package/ThemeDecorator/ThemeDecorator.d.ts +9 -10
- package/ThemeDecorator/fontGenerator.js +1 -1
- package/ThemeDecorator/screenTypes.json +1 -0
- package/TimePicker/TimePicker.module.css +1 -1
- package/TooltipDecorator/Tooltip.module.css +1 -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 +128 -23
- package/VideoPlayer/VideoPlayer.module.css +28 -11
- package/VirtualList/VirtualList.d.ts +9 -2
- package/VirtualList/VirtualList.js +31 -6
- 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/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/DateComponentPicker/DateComponentPicker.module.css +2 -2
- package/internal/DateTime/DateTime.module.css +1 -0
- package/internal/Panels/PanelsRouter.js +16 -5
- package/internal/Picker/Picker.module.css +2 -2
- package/internal/SharedStateDecorator/SharedStateDecorator.js +76 -99
- package/internal/validators/validators.js +21 -2
- package/package.json +14 -14
- package/styles/colors-highcontrast.less +9 -1
- package/styles/colors.less +11 -7
- package/styles/motion-mixins.less +66 -0
- package/styles/motions.less +78 -0
- package/styles/variables.less +176 -150
- package/useScroll/HoverToScroll.js +8 -5
- package/useScroll/ScrollbarTrack.module.css +8 -8
- package/useScroll/useEvent.js +7 -1
- package/useScroll/useScroll.js +2 -0
- 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,257 +301,270 @@ 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 Popup = exports.Popup =
|
|
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
|
+
var componentProps = (0, _util.setDefaultProps)(props, popupDefaultProps);
|
|
325
|
+
var noAnimation = componentProps.noAnimation,
|
|
326
|
+
noAutoDismiss = componentProps.noAutoDismiss,
|
|
327
|
+
no5WayClose = componentProps.no5WayClose,
|
|
328
|
+
onClose = componentProps.onClose,
|
|
329
|
+
open = componentProps.open,
|
|
330
|
+
position = componentProps.position,
|
|
331
|
+
scrimType = componentProps.scrimType,
|
|
332
|
+
spotlightRestrict = componentProps.spotlightRestrict,
|
|
333
|
+
rest = _objectWithoutProperties(componentProps, _excluded2);
|
|
334
|
+
|
|
335
|
+
// Assign the needed props to the rest object for the child component
|
|
336
|
+
Object.assign(rest, {
|
|
337
|
+
noAnimation: noAnimation,
|
|
338
|
+
position: position,
|
|
339
|
+
spotlightRestrict: spotlightRestrict
|
|
340
|
+
});
|
|
341
|
+
var _useState = (0, _react.useState)(null),
|
|
342
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
343
|
+
activator = _useState2[0],
|
|
344
|
+
setActivator = _useState2[1];
|
|
345
|
+
var _useState3 = (0, _react.useState)(false),
|
|
346
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
347
|
+
addKeyDownListener = _useState4[0],
|
|
348
|
+
setAddKeyDownListener = _useState4[1];
|
|
349
|
+
var _useState5 = (0, _react.useState)(open),
|
|
350
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
351
|
+
floatLayerOpen = _useState6[0],
|
|
352
|
+
setFloatLayerOpen = _useState6[1];
|
|
353
|
+
var _useState7 = (0, _react.useState)(open ? OpenState.OPEN : OpenState.CLOSED),
|
|
354
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
355
|
+
popupOpen = _useState8[0],
|
|
356
|
+
setPopupOpen = _useState8[1];
|
|
357
|
+
var _useState9 = (0, _react.useState)(open),
|
|
358
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
359
|
+
prevOpen = _useState0[0],
|
|
360
|
+
setPrevOpen = _useState0[1];
|
|
361
|
+
var containerIdRef = (0, _react.useRef)(null);
|
|
362
|
+
var pausedRef = (0, _react.useRef)(new _Pause["default"]('Popup'));
|
|
363
|
+
if (!containerIdRef.current) {
|
|
364
|
+
containerIdRef.current = _spotlight["default"].add();
|
|
365
|
+
}
|
|
366
|
+
var getDerivedStateFromProps = (0, _react.useCallback)(function () {
|
|
367
|
+
if (open !== prevOpen) {
|
|
368
|
+
if (open) {
|
|
369
|
+
setPopupOpen(noAnimation || floatLayerOpen ? OpenState.OPEN : OpenState.CLOSED);
|
|
370
|
+
setFloatLayerOpen(true);
|
|
371
|
+
setActivator(_spotlight["default"].getCurrent());
|
|
372
|
+
setPrevOpen(open);
|
|
373
|
+
} else {
|
|
374
|
+
// Disables the spotlight container of popup when `noAnimation` set
|
|
375
|
+
if (noAnimation) {
|
|
376
|
+
var node = getContainerNode(containerIdRef.current);
|
|
377
|
+
if (node) {
|
|
378
|
+
node.dataset['spotlightContainerDisabled'] = true;
|
|
357
379
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
380
|
+
}
|
|
381
|
+
setPopupOpen(OpenState.CLOSED);
|
|
382
|
+
setFloatLayerOpen(popupOpen === OpenState.OPEN ? !noAnimation : false);
|
|
383
|
+
setActivator(noAnimation ? null : activator);
|
|
384
|
+
setPrevOpen(open);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return null;
|
|
388
|
+
}, [activator, floatLayerOpen, noAnimation, open, popupOpen, prevOpen]);
|
|
389
|
+
var handleKeyDown = (0, _react.useCallback)(function (ev) {
|
|
390
|
+
if (no5WayClose) return;
|
|
391
|
+
var keyCode = ev.keyCode;
|
|
392
|
+
var direction = (0, _spotlight.getDirection)(keyCode);
|
|
393
|
+
var spottables = _spotlight["default"].getSpottableDescendants(containerIdRef.current).length;
|
|
394
|
+
var current = _spotlight["default"].getCurrent();
|
|
395
|
+
if (direction && (!spottables || current && getContainerNode(containerIdRef.current).contains(current))) {
|
|
396
|
+
// explicitly restrict navigation in order to manage focus state when attempting to leave the popup
|
|
397
|
+
_spotlight["default"].set(containerIdRef.current, {
|
|
398
|
+
restrict: 'self-only'
|
|
399
|
+
});
|
|
400
|
+
if (onClose) {
|
|
401
|
+
var focusChanged;
|
|
402
|
+
if (spottables && current && spotlightRestrict !== 'self-only') {
|
|
403
|
+
focusChanged = _spotlight["default"].move(direction);
|
|
404
|
+
if (focusChanged) {
|
|
361
405
|
// stop propagation to prevent default spotlight behavior
|
|
362
406
|
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
407
|
}
|
|
367
408
|
}
|
|
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);
|
|
409
|
+
if (!spottables || focusChanged === false && (position === 'center' || isUp(keyCode) && position === 'bottom' || isDown(keyCode) && position === 'top' || isRight(keyCode) && position === 'left' || isLeft(keyCode) && position === 'right')) {
|
|
410
|
+
// prevent default page scrolling
|
|
411
|
+
ev.preventDefault();
|
|
412
|
+
// stop propagation to prevent default spotlight behavior
|
|
413
|
+
ev.stopPropagation();
|
|
414
|
+
// set the pointer mode to false on keydown
|
|
415
|
+
_spotlight["default"].setPointerMode(false);
|
|
416
|
+
(0, _handle.forwardCustom)('onClose')(null, componentProps);
|
|
384
417
|
}
|
|
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
418
|
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
|
|
419
|
+
}
|
|
420
|
+
}, [componentProps, no5WayClose, onClose, position, spotlightRestrict]);
|
|
421
|
+
var spotActivator = (0, _react.useCallback)(function () {
|
|
422
|
+
pausedRef.current.resume();
|
|
401
423
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
424
|
+
// only spot the activator if the popup is closed
|
|
425
|
+
if (open) return;
|
|
426
|
+
var current = _spotlight["default"].getCurrent();
|
|
427
|
+
var containerNode = getContainerNode(containerIdRef.current);
|
|
428
|
+
var lastContainerId = (0, _container.getLastContainer)();
|
|
429
|
+
setAddKeyDownListener(false);
|
|
408
430
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
_spotlight["default"].focus();
|
|
417
|
-
}
|
|
418
|
-
} else {
|
|
419
|
-
_spotlight["default"].disableSelector(lastContainerId);
|
|
431
|
+
// if there is no currently-spotted control, or it is wrapped by the popup's container, we
|
|
432
|
+
// know it's safe to change focus
|
|
433
|
+
if (!current || containerNode && containerNode.contains(current)) {
|
|
434
|
+
// attempt to set focus to the activator, if available
|
|
435
|
+
if (!_spotlight["default"].isPaused() || !pausedRef.current.isPaused()) {
|
|
436
|
+
if (activator) {
|
|
437
|
+
if (!_spotlight["default"].focus(activator)) {
|
|
420
438
|
_spotlight["default"].focus();
|
|
421
|
-
_spotlight["default"].enableSelector(lastContainerId);
|
|
422
439
|
}
|
|
440
|
+
} else {
|
|
441
|
+
_spotlight["default"].disableSelector(lastContainerId);
|
|
442
|
+
_spotlight["default"].focus();
|
|
443
|
+
_spotlight["default"].enableSelector(lastContainerId);
|
|
423
444
|
}
|
|
424
445
|
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
|
|
446
|
+
}
|
|
447
|
+
}, [activator, open]);
|
|
448
|
+
var spotPopupContent = (0, _react.useCallback)(function () {
|
|
449
|
+
pausedRef.current.resume();
|
|
428
450
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
var current = _spotlight["default"].getCurrent();
|
|
451
|
+
// only spot the activator if the popup is open
|
|
452
|
+
if (!open) return;
|
|
453
|
+
setAddKeyDownListener(true);
|
|
454
|
+
if (!_spotlight["default"].isPaused() && !_spotlight["default"].focus(containerIdRef.current)) {
|
|
455
|
+
var current = _spotlight["default"].getCurrent();
|
|
435
456
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
}
|
|
442
|
-
_spotlight["default"].setActiveContainer(containerId);
|
|
457
|
+
// In cases where the container contains no spottable controls, or we're in pointer-mode, focus
|
|
458
|
+
// cannot inherently set the active container or blur the active control, so we must do that
|
|
459
|
+
// here.
|
|
460
|
+
if (current) {
|
|
461
|
+
current.blur();
|
|
443
462
|
}
|
|
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
|
-
}
|
|
463
|
+
_spotlight["default"].setActiveContainer(containerIdRef.current);
|
|
464
|
+
}
|
|
465
|
+
}, [open]);
|
|
466
|
+
var handleFloatingLayerOpen = (0, _react.useCallback)(function () {
|
|
467
|
+
if (!noAnimation && popupOpen !== OpenState.OPEN) {
|
|
468
|
+
setPopupOpen(OpenState.OPENING);
|
|
469
|
+
} else if (popupOpen === OpenState.OPEN && open) {
|
|
470
|
+
spotPopupContent();
|
|
471
|
+
}
|
|
472
|
+
}, [noAnimation, open, popupOpen, spotPopupContent]);
|
|
473
|
+
var handleDismiss = (0, _react.useCallback)(function (ev) {
|
|
474
|
+
(0, _handle.forwardCustom)('onClose', function () {
|
|
475
|
+
return {
|
|
476
|
+
detail: ev === null || ev === void 0 ? void 0 : ev.detail
|
|
477
|
+
};
|
|
478
|
+
})(null, componentProps);
|
|
479
|
+
}, [componentProps]);
|
|
480
|
+
var handlePopupHide = (0, _react.useCallback)(function (ev) {
|
|
481
|
+
forwardHide(ev, componentProps);
|
|
482
|
+
setFloatLayerOpen(function () {
|
|
483
|
+
if (!ev.currentTarget || ev.currentTarget.getAttribute('data-spotlight-id') === containerIdRef.current) {
|
|
484
|
+
spotActivator();
|
|
469
485
|
}
|
|
486
|
+
setActivator(null);
|
|
487
|
+
return false;
|
|
488
|
+
});
|
|
489
|
+
}, [componentProps, spotActivator]);
|
|
490
|
+
var handlePopupShow = (0, _react.useCallback)(function (ev) {
|
|
491
|
+
forwardShow(ev, componentProps);
|
|
492
|
+
setPopupOpen(OpenState.OPEN);
|
|
493
|
+
if (!ev.currentTarget || ev.currentTarget.getAttribute('data-spotlight-id') === containerIdRef.current) {
|
|
494
|
+
spotPopupContent();
|
|
470
495
|
}
|
|
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);
|
|
496
|
+
}, [componentProps, spotPopupContent]);
|
|
497
|
+
(0, _react.useLayoutEffect)(function () {
|
|
498
|
+
getDerivedStateFromProps();
|
|
499
|
+
}, [getDerivedStateFromProps]);
|
|
500
|
+
(0, _react.useEffect)(function () {
|
|
501
|
+
if (open !== prevOpen) {
|
|
502
|
+
if (!noAnimation) {
|
|
503
|
+
if (!open && (popupOpen === OpenState.OPENING || popupOpen === OpenState.OPEN)) {
|
|
504
|
+
// If the popup is supposed to be closed (!open) and is actually not fully
|
|
505
|
+
// closed (OpenState.OPENING or OpenState.OPEN), we must resume spotlight navigation. This
|
|
506
|
+
// can occur when quickly toggling a Popup open and closed.
|
|
507
|
+
pausedRef.current.resume();
|
|
508
|
+
} else {
|
|
509
|
+
// Otherwise, we pause spotlight so it is locked until the popup is ready
|
|
510
|
+
pausedRef.current.pause();
|
|
491
511
|
}
|
|
512
|
+
} else if (open) {
|
|
513
|
+
forwardShow(null, componentProps);
|
|
514
|
+
spotPopupContent();
|
|
515
|
+
} else if (prevOpen) {
|
|
516
|
+
forwardHide(null, componentProps);
|
|
517
|
+
spotActivator();
|
|
492
518
|
}
|
|
493
|
-
checkScrimNone(this.props);
|
|
494
519
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
520
|
+
checkScrimNone(componentProps);
|
|
521
|
+
}, [componentProps, noAnimation, open, popupOpen, prevOpen, spotActivator, spotPopupContent]);
|
|
522
|
+
(0, _react.useEffect)(function () {
|
|
523
|
+
checkScrimNone(componentProps);
|
|
524
|
+
|
|
525
|
+
// Spot the content after it's mounted.
|
|
526
|
+
if (open) {
|
|
527
|
+
// If the popup is open on mount, we need to pause spotlight so nothing steals focus
|
|
528
|
+
// while the popup is rendering.
|
|
529
|
+
pausedRef.current.pause();
|
|
530
|
+
if (getContainerNode(containerIdRef.current)) {
|
|
531
|
+
spotPopupContent();
|
|
500
532
|
}
|
|
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
533
|
}
|
|
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
|
-
}
|
|
534
|
+
return function () {
|
|
535
|
+
if (open) {
|
|
536
|
+
(0, _dispatcher.off)('keydown', handleKeyDown);
|
|
553
537
|
}
|
|
554
|
-
|
|
538
|
+
_spotlight["default"].remove(containerIdRef.current);
|
|
539
|
+
};
|
|
540
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
541
|
+
}, []);
|
|
542
|
+
(0, _react.useEffect)(function () {
|
|
543
|
+
if (addKeyDownListener) {
|
|
544
|
+
(0, _dispatcher.on)('keydown', handleKeyDown);
|
|
545
|
+
} else {
|
|
546
|
+
(0, _dispatcher.off)('keydown', handleKeyDown);
|
|
555
547
|
}
|
|
556
|
-
|
|
557
|
-
|
|
548
|
+
return function () {
|
|
549
|
+
(0, _dispatcher.off)('keydown', handleKeyDown);
|
|
550
|
+
};
|
|
551
|
+
}, [addKeyDownListener, handleKeyDown]);
|
|
552
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_FloatingLayer["default"], {
|
|
553
|
+
noAutoDismiss: noAutoDismiss,
|
|
554
|
+
open: floatLayerOpen,
|
|
555
|
+
onOpen: handleFloatingLayerOpen,
|
|
556
|
+
onDismiss: handleDismiss,
|
|
557
|
+
scrimType: scrimType,
|
|
558
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnedPopupBase, _objectSpread(_objectSpread({}, rest), {}, {
|
|
559
|
+
"data-webos-voice-exclusive": true,
|
|
560
|
+
onHide: handlePopupHide,
|
|
561
|
+
onShow: handlePopupShow,
|
|
562
|
+
open: popupOpen >= OpenState.OPENING,
|
|
563
|
+
spotlightId: containerIdRef.current
|
|
564
|
+
}))
|
|
565
|
+
});
|
|
566
|
+
};
|
|
567
|
+
Popup.displayName = 'Popup';
|
|
558
568
|
Popup.propTypes = /** @lends limestone/Popup.Popup.prototype */{
|
|
559
569
|
/**
|
|
560
570
|
* Prevents closing the popup via 5-way navigation out of the content.
|
|
@@ -679,12 +689,4 @@ Popup.propTypes = /** @lends limestone/Popup.Popup.prototype */{
|
|
|
679
689
|
*/
|
|
680
690
|
spotlightRestrict: _propTypes["default"].oneOf(['self-first', 'self-only'])
|
|
681
691
|
};
|
|
682
|
-
Popup.defaultProps = {
|
|
683
|
-
noAnimation: false,
|
|
684
|
-
noAutoDismiss: false,
|
|
685
|
-
open: false,
|
|
686
|
-
position: 'bottom',
|
|
687
|
-
scrimType: 'translucent',
|
|
688
|
-
spotlightRestrict: 'self-only'
|
|
689
|
-
};
|
|
690
692
|
var _default = exports["default"] = Popup;
|