@enact/spotlight 4.5.1 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/Accelerator/Accelerator.js +11 -31
  2. package/Accelerator/tests/Accelerrator-specs.js +62 -0
  3. package/CHANGELOG.md +28 -0
  4. package/Pause/Pause.js +12 -22
  5. package/Pause/tests/Pause-specs.js +6 -3
  6. package/SpotlightContainerDecorator/SpotlightContainer.js +19 -45
  7. package/SpotlightContainerDecorator/SpotlightContainerDecorator.js +14 -58
  8. package/SpotlightContainerDecorator/tests/Element.prototype.closest.js +5 -10
  9. package/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +17 -47
  10. package/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +16 -53
  11. package/SpotlightContainerDecorator/useSpotlightContainer.js +4 -15
  12. package/SpotlightRootDecorator/SpotlightRootDecorator.js +4 -58
  13. package/SpotlightRootDecorator/tests/SpotlightRootDecorator-specs.js +38 -0
  14. package/Spottable/Spottable.js +26 -85
  15. package/Spottable/SpottableCore.js +32 -71
  16. package/Spottable/tests/Spottable-specs.js +8 -31
  17. package/Spottable/tests/useSpot-specs.js +27 -105
  18. package/Spottable/useSpottable.js +7 -21
  19. package/package.json +9 -3
  20. package/src/container.js +94 -219
  21. package/src/navigate.js +5 -74
  22. package/src/pointer.js +16 -31
  23. package/src/spotlight.js +40 -170
  24. package/src/target.js +61 -139
  25. package/src/tests/container-specs.js +5 -11
  26. package/src/tests/navigate-specs.js +2 -10
  27. package/src/tests/pointer-specs.js +1 -3
  28. package/src/tests/spotlight-specs.js +42 -24
  29. package/src/tests/target-specs.js +23 -47
  30. package/src/tests/utils-specs.js +54 -0
  31. package/src/tests/utils.js +2 -27
  32. package/src/utils.js +18 -37
@@ -5,21 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  exports.useSpotlightContainer = useSpotlightContainer;
8
-
9
8
  var _useClass = _interopRequireDefault(require("@enact/core/useClass"));
10
-
11
9
  var _react = require("react");
12
-
13
10
  var _SpotlightContainer = _interopRequireDefault(require("./SpotlightContainer"));
14
-
15
11
  var _excluded = ["disabled", "id", "muted", "restrict"];
16
-
17
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
18
-
19
13
  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; }
20
-
21
14
  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; }
22
-
23
15
  /**
24
16
  * Configuration for `useSpotlightContainer`
25
17
  *
@@ -101,13 +93,11 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
101
93
  */
102
94
  function useSpotlightContainer() {
103
95
  var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
104
-
105
96
  var disabled = config.disabled,
106
- id = config.id,
107
- muted = config.muted,
108
- restrict = config.restrict,
109
- rest = _objectWithoutProperties(config, _excluded);
110
-
97
+ id = config.id,
98
+ muted = config.muted,
99
+ restrict = config.restrict,
100
+ rest = _objectWithoutProperties(config, _excluded);
111
101
  var spotlightContainer = (0, _useClass["default"])(_SpotlightContainer["default"], rest);
112
102
  spotlightContainer.setProps({
113
103
  disabled: disabled,
@@ -128,6 +118,5 @@ function useSpotlightContainer() {
128
118
  onPointerLeave: spotlightContainer.onPointerLeave
129
119
  };
130
120
  }
131
-
132
121
  var _default = useSpotlightContainer;
133
122
  exports["default"] = _default;
@@ -4,51 +4,28 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.setInputType = exports.getInputType = exports["default"] = exports.activateInputType = exports.SpotlightRootDecorator = void 0;
7
-
8
7
  var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
9
-
10
8
  var _keymap = require("@enact/core/keymap");
11
-
12
9
  var _react = require("react");
13
-
14
10
  var _spotlight = _interopRequireDefault(require("../src/spotlight"));
15
-
16
11
  var _Spottable = require("../Spottable");
17
-
18
12
  var _container = require("../src/container");
19
-
20
13
  require("../styles/debug.less");
21
-
22
14
  var _jsxRuntime = require("react/jsx-runtime");
23
-
24
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
-
26
16
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
-
28
17
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
-
30
18
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31
-
32
19
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
33
-
34
20
  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); } }
35
-
36
21
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
37
-
38
22
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
39
-
40
23
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
41
-
42
24
  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); }; }
43
-
44
25
  function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
45
-
46
26
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
47
-
48
27
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
49
-
50
28
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
51
-
52
29
  var input = {
53
30
  activated: false,
54
31
  applied: false,
@@ -58,21 +35,16 @@ var input = {
58
35
  touch: false
59
36
  }
60
37
  };
61
-
62
38
  var activateInputType = function activateInputType(activated) {
63
39
  input.activated = activated;
64
40
  };
65
-
66
41
  exports.activateInputType = activateInputType;
67
-
68
42
  var getInputType = function getInputType() {
69
43
  return Object.keys(input.types).find(function (type) {
70
44
  return input.types[type];
71
45
  });
72
46
  };
73
-
74
47
  exports.getInputType = getInputType;
75
-
76
48
  var setInputType = function setInputType(inputType) {
77
49
  if (Object.prototype.hasOwnProperty.call(input.types, inputType) && !input.types[inputType]) {
78
50
  Object.keys(input.types).map(function (type) {
@@ -82,14 +54,13 @@ var setInputType = function setInputType(inputType) {
82
54
  input.applied = false;
83
55
  }
84
56
  };
57
+
85
58
  /**
86
59
  * Default configuration for SpotlightRootDecorator
87
60
  *
88
61
  * @hocconfig
89
62
  * @memberof spotlight/SpotlightRootDecorator.SpotlightRootDecorator
90
63
  */
91
-
92
-
93
64
  exports.setInputType = setInputType;
94
65
  var defaultConfig = {
95
66
  /**
@@ -102,6 +73,7 @@ var defaultConfig = {
102
73
  */
103
74
  noAutoFocus: false
104
75
  };
76
+
105
77
  /**
106
78
  * Constructs a higher-order component that initializes and enables Spotlight 5-way navigation
107
79
  * within an application.
@@ -120,23 +92,16 @@ var defaultConfig = {
120
92
  * @returns {Function} SpotlightRootDecorator
121
93
  * @hoc
122
94
  */
123
-
124
95
  var SpotlightRootDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
125
96
  var _class;
126
-
127
97
  var noAutoFocus = config.noAutoFocus;
128
98
  return _class = /*#__PURE__*/function (_Component) {
129
99
  _inherits(_class, _Component);
130
-
131
100
  var _super = _createSuper(_class);
132
-
133
101
  function _class(props) {
134
102
  var _this;
135
-
136
103
  _classCallCheck(this, _class);
137
-
138
104
  _this = _super.call(this, props);
139
-
140
105
  _this.applyInputType = function () {
141
106
  if (_assertThisInitialized(_this) && _this.containerNode) {
142
107
  Object.keys(input.types).map(function (type) {
@@ -145,78 +110,62 @@ var SpotlightRootDecorator = (0, _hoc["default"])(defaultConfig, function (confi
145
110
  input.applied = true;
146
111
  }
147
112
  };
148
-
149
113
  _this.handleFocusInBeforeMount = function () {
150
114
  _this.hasFocusedIn = true;
151
115
  };
152
-
153
116
  _this.handleFocusIn = function () {
154
117
  if (!input.applied) {
155
118
  _this.applyInputType();
156
119
  }
157
120
  };
158
-
159
121
  _this.handleKeyDown = function (ev) {
160
122
  var keyCode = ev.keyCode;
161
-
162
123
  if ((0, _keymap.is)('enter', keyCode) && _this.containerNode.classList.contains('spotlight-input-touch')) {
163
124
  // Prevent onclick event trigger by enter key
164
125
  ev.preventDefault();
165
126
  }
166
-
167
127
  setTimeout(function () {
168
128
  if (!input.activated) {
169
129
  setInputType('key');
170
130
  }
171
-
172
131
  _this.applyInputType();
173
132
  }, 0);
174
133
  };
175
-
176
134
  _this.handlePointerMove = function (ev) {
177
135
  if (ev.pointerType === 'mouse') {
178
136
  setInputType('mouse');
179
-
180
137
  _this.applyInputType();
181
138
  }
182
139
  };
183
-
184
140
  _this.handlePointerOver = function (ev) {
185
141
  if (ev.pointerType === 'touch') {
186
142
  setInputType('touch');
187
-
188
143
  _this.applyInputType();
189
144
  }
190
145
  };
191
-
192
146
  _this.containerNode = null;
193
-
194
147
  if (typeof window === 'object') {
195
148
  _spotlight["default"].initialize({
196
149
  selector: '.' + _Spottable.spottableClass,
197
150
  restrict: 'none'
198
151
  });
199
-
200
152
  _spotlight["default"].set(_container.rootContainerId, {
201
153
  overflow: true
202
- }); // Sometimes the focusin event is fired before componentDidMount.
203
-
154
+ });
204
155
 
156
+ // Sometimes the focusin event is fired before componentDidMount.
205
157
  document.addEventListener('focusin', _this.handleFocusInBeforeMount, {
206
158
  capture: true
207
159
  });
208
160
  }
209
-
210
161
  return _this;
211
162
  }
212
-
213
163
  _createClass(_class, [{
214
164
  key: "componentDidMount",
215
165
  value: function componentDidMount() {
216
166
  if (!noAutoFocus) {
217
167
  _spotlight["default"].focus();
218
168
  }
219
-
220
169
  if (typeof document === 'object') {
221
170
  this.containerNode = document.querySelector('#root');
222
171
  document.addEventListener('focusin', this.handleFocusIn, {
@@ -235,7 +184,6 @@ var SpotlightRootDecorator = (0, _hoc["default"])(defaultConfig, function (confi
235
184
  capture: true
236
185
  });
237
186
  }
238
-
239
187
  if (this.hasFocusedIn) {
240
188
  this.hasFocusedIn = false;
241
189
  this.handleFocusIn();
@@ -245,7 +193,6 @@ var SpotlightRootDecorator = (0, _hoc["default"])(defaultConfig, function (confi
245
193
  key: "componentWillUnmount",
246
194
  value: function componentWillUnmount() {
247
195
  _spotlight["default"].terminate();
248
-
249
196
  if (typeof document === 'object') {
250
197
  document.removeEventListener('focusin', this.handleFocusIn, {
251
198
  capture: true
@@ -267,7 +214,6 @@ var SpotlightRootDecorator = (0, _hoc["default"])(defaultConfig, function (confi
267
214
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread({}, this.props));
268
215
  }
269
216
  }]);
270
-
271
217
  return _class;
272
218
  }(_react.Component), _class.displayName = 'SpotlightRootDecorator', _class;
273
219
  });
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ require("@testing-library/jest-dom");
4
+ var _react = require("@testing-library/react");
5
+ var _SpotlightRootDecorator = require("../SpotlightRootDecorator");
6
+ var _jsxRuntime = require("react/jsx-runtime");
7
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+ describe('SpotlightRootDecorator', function () {
11
+ var AppBase = function AppBase(props) {
12
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({
13
+ id: "root",
14
+ "data-testid": "root"
15
+ }, props), {}, {
16
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
17
+ children: "123"
18
+ })
19
+ }));
20
+ };
21
+ test('should set `spotlight-input-key` class when the app is focused for the first time', function () {
22
+ var App = (0, _SpotlightRootDecorator.SpotlightRootDecorator)(AppBase);
23
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(App, {}));
24
+ var button = _react.screen.queryByText('123');
25
+ var element = _react.screen.getByTestId('root');
26
+ _react.fireEvent.focus(button);
27
+ var expectedClass = 'spotlight-input-key';
28
+ expect(element).toHaveClass(expectedClass);
29
+ });
30
+ test('should set input type properly in internal variable', function () {
31
+ var App = (0, _SpotlightRootDecorator.SpotlightRootDecorator)(AppBase);
32
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(App, {}));
33
+ (0, _SpotlightRootDecorator.setInputType)('touch');
34
+ var expected = 'touch';
35
+ var actual = (0, _SpotlightRootDecorator.getInputType)();
36
+ expect(actual).toBe(expected);
37
+ });
38
+ });
@@ -16,81 +16,49 @@ Object.defineProperty(exports, "useSpottable", {
16
16
  return _useSpottable.useSpottable;
17
17
  }
18
18
  });
19
-
20
19
  var _handle = _interopRequireWildcard(require("@enact/core/handle"));
21
-
22
20
  var _useHandlers = _interopRequireDefault(require("@enact/core/useHandlers"));
23
-
24
21
  var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
25
-
26
22
  var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
27
-
28
23
  var _classnames = _interopRequireDefault(require("classnames"));
29
-
30
24
  var _propTypes2 = _interopRequireDefault(require("prop-types"));
31
-
32
25
  var _react = require("react");
33
-
34
26
  var _reactDom = _interopRequireDefault(require("react-dom"));
35
-
36
27
  var _useSpottable = require("./useSpottable");
37
-
38
28
  var _jsxRuntime = require("react/jsx-runtime");
39
-
40
29
  var _excluded = ["className", "disabled", "handleForceUpdate", "onSpotlightDisappear", "onSpotlightDown", "onSpotlightLeft", "onSpotlightRight", "onSpotlightUp", "selectionKeys", "spotlightDisabled", "spotlightId", "spotRef"];
41
-
42
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
43
-
44
31
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
45
-
46
32
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
47
-
48
33
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
49
-
50
34
  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); } }
51
-
52
35
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
53
-
54
36
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
55
-
56
37
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
57
-
58
38
  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); }; }
59
-
60
39
  function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
61
-
62
40
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
63
-
64
41
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
65
-
66
42
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
67
-
68
43
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
69
-
70
44
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
71
-
72
45
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
73
-
74
46
  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; }
75
-
76
47
  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; }
77
-
78
48
  var forwardMouseDown = (0, _handle.forward)('onMouseDown'),
79
- forwardMouseUp = (0, _handle.forward)('onMouseUp'),
80
- forwardClick = (0, _handle.forward)('onClick'),
81
- forwardBlur = (0, _handle.forward)('onBlur'),
82
- forwardFocus = (0, _handle.forward)('onFocus'),
83
- forwardMouseEnter = (0, _handle.forward)('onMouseEnter'),
84
- forwardMouseLeave = (0, _handle.forward)('onMouseLeave'),
85
- forwardKeyDown = (0, _handle.forward)('onKeyDown'),
86
- forwardKeyUp = (0, _handle.forward)('onKeyUp');
87
-
49
+ forwardMouseUp = (0, _handle.forward)('onMouseUp'),
50
+ forwardClick = (0, _handle.forward)('onClick'),
51
+ forwardBlur = (0, _handle.forward)('onBlur'),
52
+ forwardFocus = (0, _handle.forward)('onFocus'),
53
+ forwardMouseEnter = (0, _handle.forward)('onMouseEnter'),
54
+ forwardMouseLeave = (0, _handle.forward)('onMouseLeave'),
55
+ forwardKeyDown = (0, _handle.forward)('onKeyDown'),
56
+ forwardKeyUp = (0, _handle.forward)('onKeyUp');
88
57
  var callContext = function callContext(name) {
89
58
  return function (ev, props, context) {
90
59
  return context[name](ev, props);
91
60
  };
92
61
  };
93
-
94
62
  var spotHandlers = {
95
63
  onKeyDown: (0, _handle["default"])(forwardKeyDown, callContext('onKeyDown'), forwardMouseDown),
96
64
  onKeyUp: (0, _handle["default"])(forwardKeyUp, callContext('onKeyUp'), forwardMouseUp, forwardClick),
@@ -103,13 +71,13 @@ var spotHandlers = {
103
71
  return forwardMouseLeave(ev, props);
104
72
  }), callContext('onMouseLeave'))
105
73
  };
74
+
106
75
  /**
107
76
  * Default configuration for Spottable
108
77
  *
109
78
  * @hocconfig
110
79
  * @memberof spotlight/Spottable.Spottable
111
80
  */
112
-
113
81
  var defaultConfig = {
114
82
  /**
115
83
  * Whether or not the component should emulate mouse events as a response
@@ -122,6 +90,7 @@ var defaultConfig = {
122
90
  */
123
91
  emulateMouse: true
124
92
  };
93
+
125
94
  /**
126
95
  * Constructs a Spotlight 5-way navigation-enabled higher-order component.
127
96
  *
@@ -144,25 +113,22 @@ var defaultConfig = {
144
113
  * @hoc
145
114
  * @returns {Function} Spottable
146
115
  */
147
-
148
116
  var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
149
117
  var emulateMouse = config.emulateMouse;
150
-
151
118
  function SpottableBase(props) {
152
119
  var className = props.className,
153
- disabled = props.disabled,
154
- handleForceUpdate = props.handleForceUpdate,
155
- onSpotlightDisappear = props.onSpotlightDisappear,
156
- onSpotlightDown = props.onSpotlightDown,
157
- onSpotlightLeft = props.onSpotlightLeft,
158
- onSpotlightRight = props.onSpotlightRight,
159
- onSpotlightUp = props.onSpotlightUp,
160
- selectionKeys = props.selectionKeys,
161
- spotlightDisabled = props.spotlightDisabled,
162
- spotlightId = props.spotlightId,
163
- spotRef = props.spotRef,
164
- rest = _objectWithoutProperties(props, _excluded);
165
-
120
+ disabled = props.disabled,
121
+ handleForceUpdate = props.handleForceUpdate,
122
+ onSpotlightDisappear = props.onSpotlightDisappear,
123
+ onSpotlightDown = props.onSpotlightDown,
124
+ onSpotlightLeft = props.onSpotlightLeft,
125
+ onSpotlightRight = props.onSpotlightRight,
126
+ onSpotlightUp = props.onSpotlightUp,
127
+ selectionKeys = props.selectionKeys,
128
+ spotlightDisabled = props.spotlightDisabled,
129
+ spotlightId = props.spotlightId,
130
+ spotRef = props.spotRef,
131
+ rest = _objectWithoutProperties(props, _excluded);
166
132
  var spot = (0, _useSpottable.useSpottable)({
167
133
  disabled: disabled,
168
134
  emulateMouse: emulateMouse,
@@ -179,11 +145,9 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
179
145
  spotRef: spotRef
180
146
  });
181
147
  var tabIndex = rest.tabIndex;
182
-
183
148
  if (tabIndex == null) {
184
149
  tabIndex = -1;
185
150
  }
186
-
187
151
  rest.tabIndex = tabIndex;
188
152
  var handlers = (0, _useHandlers["default"])(spotHandlers, rest, spot);
189
153
  delete rest.spotlightId;
@@ -192,10 +156,7 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
192
156
  disabled: disabled
193
157
  }));
194
158
  }
195
-
196
- SpottableBase.propTypes =
197
- /** @lends spotlight/Spottable.Spottable.prototype */
198
- {
159
+ SpottableBase.propTypes = /** @lends spotlight/Spottable.Spottable.prototype */{
199
160
  /**
200
161
  * Whether or not the component is in a disabled state.
201
162
  *
@@ -204,7 +165,6 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
204
165
  * @public
205
166
  */
206
167
  disabled: _propTypes2["default"].bool,
207
-
208
168
  /**
209
169
  * The handler to force update the component.
210
170
  *
@@ -212,7 +172,6 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
212
172
  * @public
213
173
  */
214
174
  handleForceUpdate: _propTypes2["default"].func,
215
-
216
175
  /**
217
176
  * The handler to run when the component is removed while retaining focus.
218
177
  *
@@ -221,7 +180,6 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
221
180
  * @public
222
181
  */
223
182
  onSpotlightDisappear: _propTypes2["default"].func,
224
-
225
183
  /**
226
184
  * The handler to run when the 5-way down key is pressed.
227
185
  *
@@ -230,7 +188,6 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
230
188
  * @public
231
189
  */
232
190
  onSpotlightDown: _propTypes2["default"].func,
233
-
234
191
  /**
235
192
  * The handler to run when the 5-way left key is pressed.
236
193
  *
@@ -239,7 +196,6 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
239
196
  * @public
240
197
  */
241
198
  onSpotlightLeft: _propTypes2["default"].func,
242
-
243
199
  /**
244
200
  * The handler to run when the 5-way right key is pressed.
245
201
  *
@@ -248,7 +204,6 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
248
204
  * @public
249
205
  */
250
206
  onSpotlightRight: _propTypes2["default"].func,
251
-
252
207
  /**
253
208
  * The handler to run when the 5-way up key is pressed.
254
209
  *
@@ -257,7 +212,6 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
257
212
  * @public
258
213
  */
259
214
  onSpotlightUp: _propTypes2["default"].func,
260
-
261
215
  /**
262
216
  * An array of numbers representing keyCodes that should trigger mouse event
263
217
  * emulation when `emulateMouse` is `true`. If a keyCode equals a directional
@@ -268,7 +222,6 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
268
222
  * @public
269
223
  */
270
224
  selectionKeys: _propTypes2["default"].arrayOf(_propTypes2["default"].number),
271
-
272
225
  /**
273
226
  * When `true`, the component cannot be navigated using spotlight.
274
227
  *
@@ -277,7 +230,6 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
277
230
  * @public
278
231
  */
279
232
  spotlightDisabled: _propTypes2["default"].bool,
280
-
281
233
  /**
282
234
  * Used to identify this component within the Spotlight system
283
235
  *
@@ -285,15 +237,13 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
285
237
  * @public
286
238
  */
287
239
  spotlightId: _propTypes2["default"].string,
288
-
289
240
  /*
290
- * Called with a reference to [component]{@link spotlight/Spottable.Spottable#component}
241
+ * Called with a reference to {@link spotlight/Spottable.Spottable#component|component}
291
242
  *
292
243
  * @type {Object|Function}
293
244
  * @private
294
245
  */
295
246
  spotRef: _propTypes["default"].ref,
296
-
297
247
  /**
298
248
  * The tabIndex of the component. This value will default to -1 if left
299
249
  * unset and the control is spottable.
@@ -302,31 +252,24 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
302
252
  * @public
303
253
  */
304
254
  tabIndex: _propTypes2["default"].number
305
- }; // eslint-disable-next-line no-shadow
255
+ };
306
256
 
257
+ // eslint-disable-next-line no-shadow
307
258
  var Spottable = /*#__PURE__*/function (_Component) {
308
259
  _inherits(Spottable, _Component);
309
-
310
260
  var _super = _createSuper(Spottable);
311
-
312
261
  function Spottable() {
313
262
  var _this;
314
-
315
263
  _classCallCheck(this, Spottable);
316
-
317
264
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
318
265
  args[_key] = arguments[_key];
319
266
  }
320
-
321
267
  _this = _super.call.apply(_super, [this].concat(args));
322
-
323
268
  _this.handleForceUpdate = function () {
324
269
  _this.forceUpdate();
325
270
  };
326
-
327
271
  return _this;
328
272
  }
329
-
330
273
  _createClass(Spottable, [{
331
274
  key: "componentDidMount",
332
275
  value: function componentDidMount() {
@@ -348,10 +291,8 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
348
291
  }));
349
292
  }
350
293
  }]);
351
-
352
294
  return Spottable;
353
295
  }(_react.Component);
354
-
355
296
  return Spottable;
356
297
  });
357
298
  exports.Spottable = Spottable;