@enact/spotlight 3.4.9-experimental-3 → 3.4.9-experimental-7

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 (68) hide show
  1. package/{build/Accelerator → Accelerator}/Accelerator.d.ts +0 -0
  2. package/Accelerator/Accelerator.js +149 -156
  3. package/CHANGELOG.md +22 -0
  4. package/{build/Pause → Pause}/Pause.d.ts +0 -0
  5. package/Pause/Pause.js +102 -80
  6. package/Pause/tests/Pause-specs.js +65 -97
  7. package/SpotlightContainerDecorator/SpotlightContainer.js +175 -140
  8. package/{build/SpotlightContainerDecorator → SpotlightContainerDecorator}/SpotlightContainerDecorator.d.ts +0 -0
  9. package/SpotlightContainerDecorator/SpotlightContainerDecorator.js +222 -176
  10. package/SpotlightContainerDecorator/tests/Element.prototype.closest.js +44 -40
  11. package/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +221 -210
  12. package/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +150 -243
  13. package/SpotlightContainerDecorator/useSpotlightContainer.js +47 -28
  14. package/{build/SpotlightRootDecorator → SpotlightRootDecorator}/SpotlightRootDecorator.d.ts +0 -0
  15. package/SpotlightRootDecorator/SpotlightRootDecorator.js +206 -111
  16. package/{build/Spottable → Spottable}/Spottable.d.ts +0 -0
  17. package/Spottable/Spottable.js +448 -410
  18. package/Spottable/tests/Spottable-specs.js +90 -117
  19. package/package.json +3 -2
  20. package/src/container.js +718 -653
  21. package/src/navigate.js +406 -491
  22. package/src/pointer.js +86 -78
  23. package/{build/src → src}/spotlight.d.ts +0 -0
  24. package/src/spotlight.js +846 -885
  25. package/src/target.js +448 -474
  26. package/src/tests/container-specs.js +643 -1251
  27. package/src/tests/navigate-specs.js +77 -134
  28. package/src/tests/pointer-specs.js +126 -182
  29. package/src/tests/spotlight-specs.js +103 -133
  30. package/src/tests/target-specs.js +597 -960
  31. package/src/tests/utils.js +89 -67
  32. package/src/utils.js +155 -158
  33. package/build/Accelerator/Accelerator.js +0 -162
  34. package/build/Accelerator/package.json +0 -3
  35. package/build/CHANGELOG.md +0 -838
  36. package/build/Pause/Pause.js +0 -164
  37. package/build/Pause/package.json +0 -3
  38. package/build/Pause/tests/Pause-specs.js +0 -65
  39. package/build/README.md +0 -61
  40. package/build/SpotlightContainerDecorator/SpotlightContainer.js +0 -176
  41. package/build/SpotlightContainerDecorator/SpotlightContainerDecorator.js +0 -282
  42. package/build/SpotlightContainerDecorator/package.json +0 -3
  43. package/build/SpotlightContainerDecorator/tests/Element.prototype.closest.js +0 -45
  44. package/build/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +0 -221
  45. package/build/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +0 -160
  46. package/build/SpotlightContainerDecorator/useSpotlightContainer.js +0 -133
  47. package/build/SpotlightRootDecorator/SpotlightRootDecorator.js +0 -189
  48. package/build/SpotlightRootDecorator/package.json +0 -3
  49. package/build/Spottable/Spottable.js +0 -491
  50. package/build/Spottable/package.json +0 -3
  51. package/build/Spottable/tests/Spottable-specs.js +0 -90
  52. package/build/package-lock.json +0 -229
  53. package/build/package.json +0 -28
  54. package/build/src/container.js +0 -1201
  55. package/build/src/navigate.js +0 -419
  56. package/build/src/pointer.js +0 -183
  57. package/build/src/spotlight.js +0 -896
  58. package/build/src/target.js +0 -507
  59. package/build/src/tests/container-specs.js +0 -653
  60. package/build/src/tests/navigate-specs.js +0 -87
  61. package/build/src/tests/pointer-specs.js +0 -130
  62. package/build/src/tests/spotlight-specs.js +0 -112
  63. package/build/src/tests/target-specs.js +0 -614
  64. package/build/src/tests/utils.js +0 -104
  65. package/build/src/utils.js +0 -180
  66. package/build/styles/debug.less +0 -97
  67. package/build/styles/mixins.less +0 -63
  68. package/docs/index.md +0 -364
@@ -1,160 +0,0 @@
1
- "use strict";
2
-
3
- var _enzyme = require("enzyme");
4
-
5
- var _react = _interopRequireDefault(require("react"));
6
-
7
- var _spotlight = _interopRequireDefault(require("../../src/spotlight"));
8
-
9
- var _container = require("../../src/container");
10
-
11
- var _useSpotlightContainer = _interopRequireDefault(require("../useSpotlightContainer"));
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
-
15
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
16
-
17
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
18
-
19
- function containerExists(id) {
20
- return (0, _container.getContainerConfig)(id) != null;
21
- }
22
-
23
- describe('useSpotlightContainer', function () {
24
- // TODO: Test lifecycle (e.g unload, preserveId)
25
- function Component(props) {
26
- var containerConfig = props.containerConfig,
27
- preserveId = props.preserveId,
28
- spotlightDisabled = props.spotlightDisabled,
29
- spotlightId = props.spotlightId,
30
- spotlightMuted = props.spotlightMuted,
31
- spotlightRestrict = props.spotlightRestrict,
32
- rest = _objectWithoutProperties(props, ["containerConfig", "preserveId", "spotlightDisabled", "spotlightId", "spotlightMuted", "spotlightRestrict"]);
33
-
34
- var spotlightContainer = (0, _useSpotlightContainer["default"])({
35
- id: spotlightId,
36
- muted: spotlightMuted,
37
- disabled: spotlightDisabled,
38
- restrict: spotlightRestrict,
39
- // continue5WayHold, defaultElement, and enterTo can be in the containerConfig object
40
- containerConfig: containerConfig,
41
- preserveId: preserveId
42
- });
43
- return /*#__PURE__*/_react["default"].createElement("div", Object.assign({}, rest, spotlightContainer.attributes));
44
- } // remove all containers after each test
45
-
46
-
47
- afterEach(_spotlight["default"].clear);
48
- test('should support omitting the config object', function () {
49
- function Comp(props) {
50
- var spotlightContainer = (0, _useSpotlightContainer["default"])();
51
- return /*#__PURE__*/_react["default"].createElement("div", Object.assign({}, props, spotlightContainer.attributes));
52
- }
53
-
54
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Comp, null));
55
- var expected = true;
56
- var actual = subject.prop('data-spotlight-container');
57
- expect(actual).toBe(expected);
58
- });
59
- describe('attributes', function () {
60
- test('should set `data-spotlight-container` attribute', function () {
61
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
62
- var expected = true;
63
- var actual = subject.prop('data-spotlight-container');
64
- expect(actual).toBe(expected);
65
- });
66
- test('should generate a `data-spotlight-id` attribute when `id` is unset', function () {
67
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
68
- var expected = /container-\d+/;
69
- var actual = subject.prop('data-spotlight-id');
70
- expect(actual).toMatch(expected);
71
- });
72
- test('should reuse the same generated `data-spotlight-id` attribute on re-render', function () {
73
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
74
- var expected = subject.prop('data-spotlight-id');
75
- subject.setProps({});
76
- var actual = subject.prop('data-spotlight-id');
77
- expect(actual).toMatch(expected);
78
- });
79
- test('should set a `data-spotlight-id` attribute when `id` is set', function () {
80
- var id = 'my-container';
81
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, {
82
- spotlightId: id
83
- }));
84
- var expected = id;
85
- var actual = subject.prop('data-spotlight-id');
86
- expect(actual).toBe(expected);
87
- });
88
- test('should set `data-spotlight-container-disabled` attribute to be falsey when `disabled` is unset', function () {
89
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
90
- var actual = subject.prop('data-spotlight-container-disabled');
91
- expect(actual).toBeFalsy();
92
- });
93
- test('should set `data-spotlight-container-disabled` attribute when `disabled` is set', function () {
94
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, {
95
- spotlightDisabled: true
96
- }));
97
- var expected = true;
98
- var actual = subject.prop('data-spotlight-container-disabled');
99
- expect(actual).toBe(expected);
100
- });
101
- test('should set `data-spotlight-container-muted` attribute to be falsey when `muted` is unset', function () {
102
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
103
- var actual = subject.prop('data-spotlight-container-muted');
104
- expect(actual).toBeFalsy();
105
- });
106
- test('should set `data-spotlight-container-muted` attribute when `muted` is set', function () {
107
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, {
108
- spotlightMuted: true
109
- }));
110
- var expected = true;
111
- var actual = subject.prop('data-spotlight-container-muted');
112
- expect(actual).toBe(expected);
113
- });
114
- });
115
- describe('Spotlight configuration', function () {
116
- test('should create a new container with the specified id', function () {
117
- var id = 'my-container';
118
- expect(containerExists(id)).toBeFalsy();
119
- (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, {
120
- spotlightId: id
121
- }));
122
- var expected = true;
123
- var actual = containerExists(id);
124
- expect(actual).toBe(expected);
125
- });
126
- test('should configure a new container with the specified id', function () {
127
- var id = 'my-container';
128
- expect(containerExists(id)).toBeFalsy();
129
- var config = {
130
- restrict: 'self-only',
131
- defaultElement: 'my-element'
132
- };
133
- (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, {
134
- spotlightId: id,
135
- spotlightRestrict: config.restrict,
136
- containerConfig: {
137
- defaultElement: config.defaultElement
138
- }
139
- }));
140
- var expected = config;
141
- var actual = (0, _container.getContainerConfig)(id);
142
- expect(actual).toMatchObject(expected);
143
- });
144
- test('should update restrict value', function () {
145
- var id = 'my-container';
146
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, {
147
- spotlightId: id,
148
- spotlightRestrict: "self-only"
149
- }));
150
- subject.setProps({
151
- spotlightRestrict: 'self-first'
152
- });
153
- var expected = {
154
- restrict: 'self-first'
155
- };
156
- var actual = (0, _container.getContainerConfig)(id);
157
- expect(actual).toMatchObject(expected);
158
- });
159
- });
160
- });
@@ -1,133 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useSpotlightContainer = useSpotlightContainer;
7
- exports["default"] = void 0;
8
-
9
- var _useClass = _interopRequireDefault(require("@enact/core/useClass"));
10
-
11
- var _react = _interopRequireDefault(require("react"));
12
-
13
- var _SpotlightContainer = _interopRequireDefault(require("./SpotlightContainer"));
14
-
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
-
17
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
18
-
19
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
20
-
21
- /**
22
- * Configuration for `useSpotlightContainer`
23
- *
24
- * @typedef {Object} useSpotlightContainerConfig
25
- * @memberof spotlight/SpotlightContainerDecorator
26
- * @property {Object} [containerConfig] Spotlight container configuration. This
27
- * is a design-time configuration and only
28
- * applied once on first render.
29
- * @property {Function} [navigableFilter] Called to determine if a spottable
30
- * component is accessible. This is a
31
- * design-time configuration and only
32
- * applied once on first render.
33
- * @property {Boolean} [preserveId] Preserves the spotlight `id`, if
34
- * specified, when the component unmounts.
35
- * @property {Boolean} [disabled] Prevents controls in the container from
36
- * being navigable. This is a design-time
37
- * configuration and only applied once on
38
- * first render.
39
- * @property {Boolean} [muted] Suppresses appearance of focus within
40
- * the container while still allowing the
41
- * component to gain focus. The components
42
- * within the container are responsible for
43
- * adjusting their visual appearance based
44
- * on the presence of the
45
- * `data-spotlight-container-muted`
46
- * attribute on an ancestor container.
47
- * @property {String} [id] Identifies this component within the
48
- * Spotlight system. If unset, an id will
49
- * be generated.
50
- * @property {('self-only'|'self-first'|'none')} [restrict] Restricts or prioritizes navigation when
51
- * focus attempts to leave the container.
52
- * It can be either 'none', 'self-first',
53
- * or 'self-only'. Specifying 'self-first'
54
- * indicates that elements within the
55
- * container will have a higher likelihood
56
- * to be chosen as the next navigable
57
- * element. Specifying 'self-only'
58
- * indicates that elements in other
59
- * containers cannot be navigated to by
60
- * using 5-way navigation - however,
61
- * elements in other containers can still
62
- * receive focus by calling
63
- * `Spotlight.focus(elem)` explicitly.
64
- * Specifying 'none' indicates there should
65
- * be no restrictions when 5-way navigating
66
- * the container.
67
- * @private
68
- */
69
-
70
- /**
71
- * Object returned by `useSpotlightContainer`.
72
- *
73
- * @typedef {Object} useSpotlightContainerInterface
74
- * @memberof spotlight/SpotlightContainerDecorator
75
- * @property {Function} onBlurCapture Callback to notify hook when an node was blurred within the
76
- * container. Must be called during the capture phase of the
77
- * event flow.
78
- * @property {Function} onFocusCapture Callback to notify hook when an node was focused within the
79
- * container. Must be called during the capture phase of the
80
- * event flow.
81
- * @property {String} attributes An object of DOM attributes of representing the current
82
- * spotlight container metadata. Must be passed onto the
83
- * container node.
84
- * @property {Function} onPointerEnter Callback to notify hook when the pointer enters the
85
- * container. Must be called during the capture phase of the
86
- * event flow.
87
- * @property {Function} onPointerLeave Callback to notify hook when the pointer leaves the
88
- * container. Must be called during the capture phase of the
89
- * event flow.
90
- * @private
91
- */
92
-
93
- /**
94
- * Support Spotlight container
95
- *
96
- * @param {useSpotlightContainerConfig} [config] Configuration options
97
- * @returns {useSpotlightContainerInterface}
98
- * @private
99
- */
100
- function useSpotlightContainer() {
101
- var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
102
-
103
- var disabled = config.disabled,
104
- id = config.id,
105
- muted = config.muted,
106
- restrict = config.restrict,
107
- rest = _objectWithoutProperties(config, ["disabled", "id", "muted", "restrict"]);
108
-
109
- var spotlightContainer = (0, _useClass["default"])(_SpotlightContainer["default"], rest);
110
- spotlightContainer.setProps({
111
- disabled: disabled,
112
- id: id,
113
- muted: muted,
114
- restrict: restrict
115
- });
116
-
117
- _react["default"].useEffect(function () {
118
- return function () {
119
- spotlightContainer.unload();
120
- };
121
- }, [spotlightContainer]);
122
-
123
- return {
124
- attributes: spotlightContainer.attributes,
125
- onBlurCapture: spotlightContainer.onBlurCapture,
126
- onFocusCapture: spotlightContainer.onFocusCapture,
127
- onPointerEnter: spotlightContainer.onPointerEnter,
128
- onPointerLeave: spotlightContainer.onPointerLeave
129
- };
130
- }
131
-
132
- var _default = useSpotlightContainer;
133
- exports["default"] = _default;
@@ -1,189 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SpotlightRootDecorator = exports["default"] = void 0;
7
-
8
- var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
9
-
10
- var _keymap = require("@enact/core/keymap");
11
-
12
- var _react = _interopRequireDefault(require("react"));
13
-
14
- var _spotlight = _interopRequireDefault(require("../src/spotlight"));
15
-
16
- var _Spottable = require("../Spottable");
17
-
18
- var _container = require("../src/container");
19
-
20
- require("../styles/debug.less");
21
-
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
-
24
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
-
26
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
27
-
28
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
29
-
30
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
31
-
32
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
33
-
34
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
35
-
36
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
37
-
38
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
39
-
40
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
41
-
42
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
43
-
44
- /**
45
- * Default configuration for SpotlightRootDecorator
46
- *
47
- * @hocconfig
48
- * @memberof spotlight/SpotlightRootDecorator.SpotlightRootDecorator
49
- */
50
- var defaultConfig = {
51
- /**
52
- * When `true`, the contents of the component will not receive spotlight focus after being rendered.
53
- *
54
- * @type {Boolean}
55
- * @default false
56
- * @public
57
- * @memberof spotlight/SpotlightRootDecorator.SpotlightRootDecorator.defaultConfig
58
- */
59
- noAutoFocus: false
60
- };
61
- /**
62
- * Constructs a higher-order component that initializes and enables Spotlight 5-way navigation
63
- * within an application.
64
- *
65
- * No additional properties are passed to the wrapped component.
66
- *
67
- * Example:
68
- * ```
69
- * const App = SpotlightRootDecorator(ApplicationView);
70
- * ```
71
- *
72
- * @class SpotlightRootDecorator
73
- * @memberof spotlight/SpotlightRootDecorator
74
- * @param {Object} defaultConfig Set of default configuration parameters
75
- * @param {Function} Wrapped higher-order component
76
- * @returns {Function} SpotlightRootDecorator
77
- * @hoc
78
- */
79
-
80
- var SpotlightRootDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
81
- var _class, _temp;
82
-
83
- var noAutoFocus = config.noAutoFocus;
84
- return _temp = _class = /*#__PURE__*/function (_React$Component) {
85
- _inherits(_class, _React$Component);
86
-
87
- var _super = _createSuper(_class);
88
-
89
- function _class(props) {
90
- var _this;
91
-
92
- _classCallCheck(this, _class);
93
-
94
- _this = _super.call(this, props); // In other modules, this reference DOM element could be referred by `#root > div`.
95
-
96
- _this.handlePointerOver = function (ev) {
97
- if (ev.pointerType === 'touch') {
98
- _this.containerRef.current.classList.remove('non-touch-mode');
99
-
100
- _this.containerRef.current.classList.add('touch-mode');
101
- } else if (ev.pointerType === 'mouse') {
102
- _this.containerRef.current.classList.add('non-touch-mode');
103
-
104
- _this.containerRef.current.classList.remove('touch-mode');
105
- } else {
106
- _this.containerRef.current.classList.remove('non-touch-mode');
107
-
108
- _this.containerRef.current.classList.remove('touch-mode');
109
- }
110
- };
111
-
112
- _this.handleKeyDown = function (ev) {
113
- var keyCode = ev.keyCode;
114
-
115
- if ((0, _keymap.is)('enter', keyCode) && _this.containerRef.current.classList.contains('touch-mode')) {
116
- // Prevent onclick event trigger by enter key
117
- ev.preventDefault();
118
- }
119
-
120
- _this.containerRef.current.classList.add('non-touch-mode');
121
-
122
- _this.containerRef.current.classList.remove('touch-mode');
123
- };
124
-
125
- _this.navigableFilter = function (elem) {
126
- while (elem && elem !== document && elem.nodeType === 1) {
127
- if (elem.getAttribute('data-spotlight-container-disabled') === 'true') return false;
128
- elem = elem.parentNode;
129
- }
130
- };
131
-
132
- _this.containerRef = /*#__PURE__*/_react["default"].createRef();
133
-
134
- if (typeof window === 'object') {
135
- _spotlight["default"].initialize({
136
- selector: '.' + _Spottable.spottableClass,
137
- restrict: 'none'
138
- });
139
-
140
- _spotlight["default"].set(_container.rootContainerId, {
141
- overflow: true
142
- });
143
- }
144
-
145
- return _this;
146
- }
147
-
148
- _createClass(_class, [{
149
- key: "componentDidMount",
150
- value: function componentDidMount() {
151
- if (!noAutoFocus) {
152
- _spotlight["default"].focus();
153
- }
154
-
155
- this.containerRef.current.classList.add('non-touch-mode');
156
- document.addEventListener('pointerover', this.handlePointerOver, {
157
- capture: true
158
- });
159
- document.addEventListener('keydown', this.handleKeyDown, {
160
- capture: true
161
- });
162
- }
163
- }, {
164
- key: "componentWillUnmount",
165
- value: function componentWillUnmount() {
166
- _spotlight["default"].terminate();
167
-
168
- document.removeEventListener('pointerover', this.handlePointerOver, {
169
- capture: true
170
- });
171
- document.removeEventListener('keydown', this.handleKeyDown, {
172
- capture: true
173
- });
174
- }
175
- }, {
176
- key: "render",
177
- value: function render() {
178
- return /*#__PURE__*/_react["default"].createElement("div", {
179
- ref: this.containerRef
180
- }, /*#__PURE__*/_react["default"].createElement(Wrapped, this.props));
181
- }
182
- }]);
183
-
184
- return _class;
185
- }(_react["default"].Component), _class.displayName = 'SpotlightRootDecorator', _temp;
186
- });
187
- exports.SpotlightRootDecorator = SpotlightRootDecorator;
188
- var _default = SpotlightRootDecorator;
189
- exports["default"] = _default;
@@ -1,3 +0,0 @@
1
- {
2
- "main": "SpotlightRootDecorator.js"
3
- }