@enact/spotlight 3.2.3 → 3.2.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.
@@ -4,14 +4,11 @@ type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
4
4
  type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
5
5
 
6
6
  export declare class Accelerator {
7
- constructor(
8
- /**
7
+ constructor /**
9
8
  * Controls the frequency with which the acceleration will
10
9
  "freeze". While frozen, the current target item cannot change, and all events are directed
11
10
  to it.
12
- */
13
- frequency: number[]
14
- );
11
+ */(frequency: number[]);
15
12
  /**
16
13
  * Called with the current keydown event and callback, which will be called when the event is
17
14
  allowed through.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  The following is a curated list of changes in the Enact spotlight module, newest changes on the top.
4
4
 
5
+ ## [3.2.7] - 2022-01-17
6
+
7
+ No significant changes.
8
+
9
+ ## [3.2.6] - 2020-03-26
10
+
11
+ No significant changes.
12
+
13
+ ## [3.2.5] - 2019-11-14
14
+
15
+ No significant changes.
16
+
17
+ ## [3.2.4] - 2019-11-07
18
+
19
+ No significant changes.
20
+
5
21
  ## [3.2.3] - 2019-11-01
6
22
 
7
23
  No significant changes.
package/Pause/Pause.d.ts CHANGED
@@ -12,12 +12,10 @@ paused spotlight and can be used as an escape hatch to force resumption.
12
12
  */
13
13
 
14
14
  export declare class Pause {
15
- constructor(
16
- /**
17
- * The name of the pause instance
18
- */
19
- name: string
20
- );
15
+ constructor
16
+ /**
17
+ * The name of the pause instance
18
+ */(name: string);
21
19
  /**
22
20
  * Returns `true` when Spotlight is paused by this instance
23
21
  */
package/Pause/Pause.js CHANGED
@@ -84,9 +84,7 @@ function isPaused() {
84
84
  */
85
85
 
86
86
 
87
- var Pause =
88
- /*#__PURE__*/
89
- function () {
87
+ var Pause = /*#__PURE__*/function () {
90
88
  /**
91
89
  * Accepts a name for the instance
92
90
  *
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
3
5
  var _Pause = _interopRequireWildcard(require("../Pause"));
4
6
 
5
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
7
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
8
+
9
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
6
10
 
7
11
  var PAUSED = 'Paused';
8
12
  var NOT_PAUSED = 'Not Paused';
@@ -19,9 +19,11 @@ var _spotlight = _interopRequireDefault(require("../src/spotlight"));
19
19
 
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
21
 
22
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
22
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
23
23
 
24
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
24
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
25
+
26
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
25
27
 
26
28
  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; }
27
29
 
@@ -31,12 +33,16 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
31
33
 
32
34
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
33
35
 
34
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
36
+ function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
35
37
 
36
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
38
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
37
39
 
38
40
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
39
41
 
42
+ 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; } }
43
+
44
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
45
+
40
46
  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); }
41
47
 
42
48
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
@@ -193,17 +199,17 @@ var SpotlightContainerDecorator = (0, _hoc["default"])(defaultConfig, function (
193
199
  }
194
200
  };
195
201
 
196
- return _temp = _class =
197
- /*#__PURE__*/
198
- function (_React$Component) {
202
+ return _temp = _class = /*#__PURE__*/function (_React$Component) {
199
203
  _inherits(_class, _React$Component);
200
204
 
205
+ var _super = _createSuper(_class);
206
+
201
207
  function _class(props) {
202
208
  var _this;
203
209
 
204
210
  _classCallCheck(this, _class);
205
211
 
206
- _this = _possibleConstructorReturn(this, _getPrototypeOf(_class).call(this, props));
212
+ _this = _super.call(this, props);
207
213
 
208
214
  _this.navigableFilter = function (elem) {
209
215
  // If the component to which this was applied specified a navigableFilter, run it
@@ -289,7 +295,7 @@ var SpotlightContainerDecorator = (0, _hoc["default"])(defaultConfig, function (
289
295
  rest['data-spotlight-container-muted'] = spotlightMuted;
290
296
  }
291
297
 
292
- return _react["default"].createElement(Wrapped, rest);
298
+ return /*#__PURE__*/_react["default"].createElement(Wrapped, rest);
293
299
  }
294
300
  }], [{
295
301
  key: "getDerivedStateFromProps",
@@ -14,7 +14,9 @@ var _ElementPrototype = _interopRequireDefault(require("./Element.prototype.clos
14
14
 
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
16
 
17
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
17
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
18
+
19
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
20
 
19
21
  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; }
20
22
 
@@ -29,7 +31,7 @@ describe('SpotlightContainerDecorator', function () {
29
31
  };
30
32
 
31
33
  var Div = function Div(props) {
32
- return _react["default"].createElement("div", props);
34
+ return /*#__PURE__*/_react["default"].createElement("div", props);
33
35
  };
34
36
 
35
37
  (0, _ElementPrototype["default"])(beforeAll, afterAll);
@@ -40,7 +42,7 @@ describe('SpotlightContainerDecorator', function () {
40
42
  });
41
43
  test('should set itself as the active container on mouse enter', function () {
42
44
  var Component = (0, _SpotlightContainerDecorator["default"])(Div);
43
- var subject = (0, _enzyme.mount)(_react["default"].createElement(Component, {
45
+ var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
44
46
  spotlightId: "test-container"
45
47
  }));
46
48
  subject.find(Div).prop('onMouseEnter')(hoverPosition);
@@ -53,9 +55,9 @@ describe('SpotlightContainerDecorator', function () {
53
55
  test('should set active container to parent container on mouse leave', function () {
54
56
  var Component = (0, _SpotlightContainerDecorator["default"])(Div);
55
57
  var node = document.createElement('div');
56
- var subject = (0, _enzyme.mount)(_react["default"].createElement(Component, {
58
+ var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
57
59
  spotlightId: "outer-container"
58
- }, _react["default"].createElement(Component, {
60
+ }, /*#__PURE__*/_react["default"].createElement(Component, {
59
61
  spotlightId: "inner-container"
60
62
  })), {
61
63
  attachTo: node
@@ -79,11 +81,11 @@ describe('SpotlightContainerDecorator', function () {
79
81
  test('should not set active container on mouse leave if another container is active', function () {
80
82
  var Component = (0, _SpotlightContainerDecorator["default"])(Div);
81
83
  var node = document.createElement('div');
82
- var subject = (0, _enzyme.mount)(_react["default"].createElement(Component, {
84
+ var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
83
85
  spotlightId: "outer-container"
84
- }, _react["default"].createElement(Component, {
86
+ }, /*#__PURE__*/_react["default"].createElement(Component, {
85
87
  spotlightId: "inner-container"
86
- }), _react["default"].createElement(Component, {
88
+ }), /*#__PURE__*/_react["default"].createElement(Component, {
87
89
  spotlightId: "self-only-container"
88
90
  })), {
89
91
  attachTo: node
@@ -113,9 +115,9 @@ describe('SpotlightContainerDecorator', function () {
113
115
  var Component = (0, _SpotlightContainerDecorator["default"])(function (_ref) {
114
116
  var onFocusCapture = _ref.onFocusCapture;
115
117
  focus = onFocusCapture;
116
- return _react["default"].createElement("div", null);
118
+ return /*#__PURE__*/_react["default"].createElement("div", null);
117
119
  });
118
- (0, _enzyme.mount)(_react["default"].createElement(Component, {
120
+ (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
119
121
  onFocusCapture: spy
120
122
  }));
121
123
  focus({});
@@ -129,9 +131,9 @@ describe('SpotlightContainerDecorator', function () {
129
131
  var Component = (0, _SpotlightContainerDecorator["default"])(function (_ref2) {
130
132
  var onFocusCapture = _ref2.onFocusCapture;
131
133
  focus = onFocusCapture;
132
- return _react["default"].createElement("div", null);
134
+ return /*#__PURE__*/_react["default"].createElement("div", null);
133
135
  });
134
- (0, _enzyme.mount)(_react["default"].createElement(Component, {
136
+ (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
135
137
  onFocusCapture: spy,
136
138
  spotlightDisabled: true
137
139
  })); // building out the api called on the event object + target
@@ -158,9 +160,9 @@ describe('SpotlightContainerDecorator', function () {
158
160
  var Component = (0, _SpotlightContainerDecorator["default"])(function (_ref3) {
159
161
  var onBlurCapture = _ref3.onBlurCapture;
160
162
  _blur = onBlurCapture;
161
- return _react["default"].createElement("div", null);
163
+ return /*#__PURE__*/_react["default"].createElement("div", null);
162
164
  });
163
- (0, _enzyme.mount)(_react["default"].createElement(Component, {
165
+ (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
164
166
  onBlurCapture: spy,
165
167
  spotlightDisabled: true
166
168
  })); // building out the api called on the event object + target
@@ -191,9 +193,9 @@ describe('SpotlightContainerDecorator', function () {
191
193
  onFocusCapture = _ref4.onFocusCapture;
192
194
  _blur2 = onBlurCapture;
193
195
  focus = onFocusCapture;
194
- return _react["default"].createElement("div", null);
196
+ return /*#__PURE__*/_react["default"].createElement("div", null);
195
197
  });
196
- (0, _enzyme.mount)(_react["default"].createElement(Component, {
198
+ (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
197
199
  onBlurCapture: spy,
198
200
  spotlightDisabled: true
199
201
  })); // building out the api called on the event object + target
@@ -19,7 +19,7 @@ require("../styles/debug.less");
19
19
 
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
21
 
22
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
22
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
23
23
 
24
24
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
25
 
@@ -27,10 +27,14 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
27
27
 
28
28
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
29
29
 
30
+ function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
31
+
30
32
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
31
33
 
32
34
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
33
35
 
36
+ 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; } }
37
+
34
38
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
35
39
 
36
40
  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); }
@@ -77,17 +81,17 @@ var SpotlightRootDecorator = (0, _hoc["default"])(defaultConfig, function (confi
77
81
  var _class, _temp;
78
82
 
79
83
  var noAutoFocus = config.noAutoFocus;
80
- return _temp = _class =
81
- /*#__PURE__*/
82
- function (_React$Component) {
84
+ return _temp = _class = /*#__PURE__*/function (_React$Component) {
83
85
  _inherits(_class, _React$Component);
84
86
 
87
+ var _super = _createSuper(_class);
88
+
85
89
  function _class(props) {
86
90
  var _this;
87
91
 
88
92
  _classCallCheck(this, _class);
89
93
 
90
- _this = _possibleConstructorReturn(this, _getPrototypeOf(_class).call(this, props));
94
+ _this = _super.call(this, props);
91
95
 
92
96
  _this.navigableFilter = function (elem) {
93
97
  while (elem && elem !== document && elem.nodeType === 1) {
@@ -125,7 +129,7 @@ var SpotlightRootDecorator = (0, _hoc["default"])(defaultConfig, function (confi
125
129
  }, {
126
130
  key: "render",
127
131
  value: function render() {
128
- return _react["default"].createElement(Wrapped, this.props);
132
+ return /*#__PURE__*/_react["default"].createElement(Wrapped, this.props);
129
133
  }
130
134
  }]);
131
135
 
@@ -25,7 +25,7 @@ var _spotlight = require("../src/spotlight");
25
25
 
26
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
27
27
 
28
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
28
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
29
29
 
30
30
  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; }
31
31
 
@@ -37,12 +37,16 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
37
37
 
38
38
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
39
39
 
40
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
40
+ function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
41
41
 
42
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
42
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
43
43
 
44
44
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
45
45
 
46
+ 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; } }
47
+
48
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
49
+
46
50
  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); }
47
51
 
48
52
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
@@ -119,17 +123,17 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
119
123
  var _class, _temp;
120
124
 
121
125
  var emulateMouse = config.emulateMouse;
122
- return _temp = _class =
123
- /*#__PURE__*/
124
- function (_React$Component) {
126
+ return _temp = _class = /*#__PURE__*/function (_React$Component) {
125
127
  _inherits(_class, _React$Component);
126
128
 
129
+ var _super = _createSuper(_class);
130
+
127
131
  function _class(_props) {
128
132
  var _this;
129
133
 
130
134
  _classCallCheck(this, _class);
131
135
 
132
- _this = _possibleConstructorReturn(this, _getPrototypeOf(_class).call(this, _props));
136
+ _this = _super.call(this, _props);
133
137
 
134
138
  _this.shouldEmulateMouse = function (ev, props) {
135
139
  if (!emulateMouse) {
@@ -374,7 +378,7 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
374
378
  rest['data-spotlight-id'] = spotlightId;
375
379
  }
376
380
 
377
- return _react["default"].createElement(Wrapped, Object.assign({}, rest, {
381
+ return /*#__PURE__*/_react["default"].createElement(Wrapped, Object.assign({}, rest, {
378
382
  onBlur: this.handleBlur,
379
383
  onFocus: this.handleFocus,
380
384
  onMouseEnter: this.handleEnter,
@@ -11,14 +11,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
11
11
  describe('Spottable', function () {
12
12
  test('should add the spottable class', function () {
13
13
  var Component = (0, _Spottable["default"])('div');
14
- var subject = (0, _enzyme.mount)(_react["default"].createElement(Component, null));
14
+ var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, null));
15
15
  var expected = 'spottable';
16
16
  var actual = subject.find('div').prop('className');
17
17
  expect(actual).toEqual(expected);
18
18
  });
19
19
  test('should add the spottable class to a {disabled} component', function () {
20
20
  var Component = (0, _Spottable["default"])('div');
21
- var subject = (0, _enzyme.mount)(_react["default"].createElement(Component, {
21
+ var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
22
22
  disabled: true
23
23
  }));
24
24
  var expected = 'spottable';
@@ -27,7 +27,7 @@ describe('Spottable', function () {
27
27
  });
28
28
  test('should not add the spottable class to a {spotlightDisabled} component', function () {
29
29
  var Component = (0, _Spottable["default"])('div');
30
- var subject = (0, _enzyme.mount)(_react["default"].createElement(Component, {
30
+ var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
31
31
  spotlightDisabled: true
32
32
  }));
33
33
  var expected = 'spottable';
@@ -37,7 +37,7 @@ describe('Spottable', function () {
37
37
  test('should emit {onSpotlightDisappear} when unmounted while focused', function () {
38
38
  var spy = jest.fn();
39
39
  var Component = (0, _Spottable["default"])('div');
40
- var subject = (0, _enzyme.mount)(_react["default"].createElement(Component, {
40
+ var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
41
41
  onSpotlightDisappear: spy
42
42
  }));
43
43
  subject.simulate('focus');
@@ -49,10 +49,10 @@ describe('Spottable', function () {
49
49
  describe('shouldComponentUpdate', function () {
50
50
  test('should re-render when a non-Spottable prop changes', function () {
51
51
  var spy = jest.fn(function (props) {
52
- return _react["default"].createElement("div", props);
52
+ return /*#__PURE__*/_react["default"].createElement("div", props);
53
53
  });
54
54
  var Component = (0, _Spottable["default"])(spy);
55
- var subject = (0, _enzyme.mount)(_react["default"].createElement(Component, null));
55
+ var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, null));
56
56
  subject.setProps({
57
57
  'data-id': '123'
58
58
  });
@@ -62,10 +62,10 @@ describe('Spottable', function () {
62
62
  });
63
63
  test('should re-render when {selectionKeys} changes', function () {
64
64
  var spy = jest.fn(function (props) {
65
- return _react["default"].createElement("div", props);
65
+ return /*#__PURE__*/_react["default"].createElement("div", props);
66
66
  });
67
67
  var Component = (0, _Spottable["default"])(spy);
68
- var subject = (0, _enzyme.mount)(_react["default"].createElement(Component, {
68
+ var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
69
69
  selectionKeys: [1, 2, 3]
70
70
  }));
71
71
  subject.setProps({
@@ -77,10 +77,10 @@ describe('Spottable', function () {
77
77
  });
78
78
  test('should not re-render when focused', function () {
79
79
  var spy = jest.fn(function (props) {
80
- return _react["default"].createElement("div", props);
80
+ return /*#__PURE__*/_react["default"].createElement("div", props);
81
81
  });
82
82
  var Component = (0, _Spottable["default"])(spy);
83
- var subject = (0, _enzyme.mount)(_react["default"].createElement(Component, null));
83
+ var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, null));
84
84
  subject.simulate('focus');
85
85
  var expected = 1;
86
86
  var actual = spy.mock.calls.length;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/spotlight",
3
- "version": "3.2.3",
3
+ "version": "3.2.7",
4
4
  "description": "A focus management library",
5
5
  "main": "src/spotlight.js",
6
6
  "scripts": {
@@ -21,7 +21,7 @@
21
21
  "extends": "enact/strict"
22
22
  },
23
23
  "dependencies": {
24
- "@enact/core": "^3.2.3",
24
+ "@enact/core": "^3.2.7",
25
25
  "prop-types": "^15.7.2",
26
26
  "ramda": "^0.24.1",
27
27
  "react": "^16.7.0",
package/src/container.js CHANGED
@@ -39,19 +39,25 @@ var _utils = require("./utils");
39
39
 
40
40
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
41
41
 
42
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
42
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
43
+
44
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
43
45
 
44
46
  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; }
45
47
 
46
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
48
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
49
+
50
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
51
+
52
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
47
53
 
48
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
54
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
49
55
 
50
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
56
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
51
57
 
52
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
58
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
53
59
 
54
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
60
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
55
61
 
56
62
  var containerAttribute = 'data-spotlight-id';
57
63
  exports.containerAttribute = containerAttribute;
package/src/target.js CHANGED
@@ -23,17 +23,23 @@ var _utils = require("./utils");
23
23
 
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
25
 
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
26
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
27
+
28
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
27
29
 
28
30
  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; }
29
31
 
30
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
32
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
33
+
34
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
35
+
36
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
31
37
 
32
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
38
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
33
39
 
34
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
40
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
35
41
 
36
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
42
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
37
43
 
38
44
  function isFocusable(elem) {
39
45
  var containers = (0, _container.getContainersForNode)(elem);
@@ -4,13 +4,17 @@ var _navigate = _interopRequireDefault(require("../navigate"));
4
4
 
5
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6
6
 
7
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
7
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
8
 
9
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
9
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
10
 
11
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
11
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12
12
 
13
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
13
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
14
+
15
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
+
17
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
14
18
 
15
19
  // loose copy from utils/getRect to fabricate a rect for navigation
16
20
  function getRect(top, left, height, width, elem) {
@@ -11,11 +11,13 @@ var _container = require("../container");
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
13
 
14
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
15
+
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
15
17
 
16
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; }
17
19
 
18
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
20
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
19
21
 
20
22
  var join = _ramda["default"].unapply(_ramda["default"].join('\n'));
21
23
 
package/src/utils.js CHANGED
@@ -18,7 +18,7 @@ var _container = require("./container");
18
18
 
19
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
20
20
 
21
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
21
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
22
22
 
23
23
  var elementMatchesSelector = function elementMatchesSelector(selector) {
24
24
  var matchedNodes = (this.parentNode || this.document).querySelectorAll(selector);
package/docs/index.md DELETED
@@ -1,364 +0,0 @@
1
- ---
2
- title: Spotlight
3
- toc: 2
4
- ---
5
-
6
-
7
- ## What Is Spotlight?
8
-
9
- Spotlight is an extensible utility that enables users to navigate
10
- applications using a keyboard or television remote control. Responding to input
11
- from the **UP**, **DOWN**, **LEFT**, **RIGHT**, and **RETURN** keys, Spotlight
12
- provides a navigation experience that compares favorably to that of a
13
- computer-with-mouse.
14
-
15
- It was developed for use with the [Enact JavaScript framework](http://enactjs.com), but is useful as a standalone
16
- library.
17
-
18
- Spotlight is based on a fork of [JavaScript SpatialNavigation](https://github.com/luke-chang/js-spatial-navigation)
19
- (c) 2016 Luke Chang, under the terms of the [Mozilla Public License](https://www.mozilla.org/en-US/MPL/2.0/).
20
-
21
- ## Modes
22
-
23
- Spotlight operates in two mutually exclusive modes: **5-way mode** and **Pointer
24
- mode**. By default, Spotlight is configured to switch between these modes
25
- whenever suitable input is received--i.e.: it switches to pointer mode on
26
- `mousemove` and back to 5-way mode on `keydown`.
27
-
28
- Spotlight initializes in 5-way mode. On webOS, the platform's current pointer mode is used instead.
29
-
30
- ## Navigation
31
-
32
- Spotlight enables navigation between controls by assigning focus to one control
33
- at a time. Focus-enabled controls are considered to be "spottable". These spottable
34
- controls take on the CSS class `.spottable`, which allow focused controls to be styled
35
- on a per-kind basis using `.<kindClass>.spottable:focus` selectors.
36
-
37
- Spotlight uses the native HTML DOM `focus` method to assign focus to controls. Form
38
- elements can gain focus by default, but Spotlight designates a `tabindex` value to its
39
- controls, meaning even a simple `div` can be a spottable control.
40
-
41
- When an application loads, Spotlight will initially spot the first spottable
42
- control. If a control has been programmatically spotted via `Spotlight.focus(element)`
43
- immediately after being rendered, that control will be spotted instead.
44
-
45
- In 5-way mode, Spotlight uses an algorithm to determine which spottable control
46
- is the nearest one in the direction of navigation. The coordinates of a
47
- spottable control are derived from its actual position on the screen.
48
-
49
- It's worth noting that spottable controls may be found on different hierarchical
50
- levels of a component tree. Spotlight facilitates seamless navigation
51
- among the topmost spottable components found in the tree.
52
-
53
- Spottable controls can receive `onSpotlight[Direction]` properties to handle custom
54
- navigation actions. This is mainly a convenience function used for preventing natural
55
- 5-way behavior and setting focus on specific spottable components that may not normally
56
- be in the next component to be spotted.
57
-
58
- ```js
59
- handleSpotlightDown = (e) => {
60
- e.preventDefault();
61
- e.stopPropagation();
62
- Spotlight.focus('[data-component-id="myButton"]');
63
- }
64
- ```
65
- ```js
66
- <Button data-component-id='myButton'>Source Button</Button>
67
- <Button onSpotlightDown={this.handleSpotlightDown}>Target Button</Button>
68
- ```
69
-
70
- ## Selectors
71
-
72
- Spotlight identifies spottable controls via selectors. A selector can be any of the
73
- following types:
74
- - a valid selector string for `querySelectorAll`
75
- - a NodeList or an array containing DOM elements
76
- - a single DOM element
77
- - a string `'@<containerId>'` to indicate the specified container
78
- - the string `'@'` to indicate the default container
79
-
80
- There may be times where it is preferable to specify a selector instead of relying on a reference to an element
81
- or `@<containerId>`. Each time a Spottable control receives focus via 5-way or pointer navigation, Spotlight updates
82
- its cache of available Spottable controls. So for example, if your container DOM is updated programmatically, followed
83
- by the need to set focus on a newly-created default Spottable control, you will be unable to spot the control by
84
- calling focus on the container.
85
-
86
- ```js
87
- Spotlight.focus('container-name');
88
- ```
89
-
90
- Be default, Spotlight will not always update its cache of available Spottable controls when simply attempting to
91
- set focus. This is done for performance reasons. Instead, you can supply a `querySelector` string that will allow
92
- Spotlight to parse the selector, re-indexing the available Spottable controls.
93
-
94
- ```js
95
- Spotlight.focus('[data-container-id="container-name"] .spottable');
96
- ```
97
-
98
- ## SpotlightRootDecorator
99
- The `SpotlightRootDecorator` is a top-level HOC (Higher Order Component) that is
100
- required to use Spotlight. It is responsible for initializing the Spotlight instance
101
- and managing navigation event listeners.
102
-
103
- To use Spotlight in an application, simply import and wrap the `SpotlightRootDecorator`
104
- HOC around your application view:
105
-
106
- ```js
107
- import ApplicationView from './ApplicationView';
108
- import SpotlightRootDecorator from '@enact/spotlight/SpotlightRootDecorator';
109
- const App = SpotlightRootDecorator(ApplicationView);
110
- ```
111
-
112
- It's worth noting that `@enact/moonstone` applications include `SpotlightRootDecorator`
113
- by default in its `MoonstoneDecorator` HOC.
114
-
115
- ## Spottable
116
-
117
- In order to make a control focus-enabled (or "spottable") with Spotlight, simply
118
- wrap your base control with the `Spottable` HOC, like so:
119
-
120
- ```js
121
- import Spottable from '@enact/spotlight/Spottable';
122
- import Component from './Component';
123
- const SpottableComponent = Spottable(Component);
124
- ```
125
-
126
- ## Containers
127
-
128
- In order to organize controls into navigation groups, we have created Spotlight
129
- containers.
130
-
131
- A good example of how containers should be used is a set of radio buttons that
132
- must be navigable separately from the rest of the app's controls.
133
-
134
- When a Spotlight container is focused, it passes the focus to its own configurable
135
- hierarchy of spottable child controls--specifically, to the last spottable child to
136
- hold focus before the focus moved outside of the container. If the container in
137
- question has never been focused, it passes focus to its first spottable child.
138
-
139
- To define a container, wrap your base control with the `SpotlightContainerDecorator`
140
- HOC:
141
-
142
- ```js
143
- import kind from '@enact/core/kind';
144
- import SpotlightContainerDecorator from '@enact/spotlight/SpotlightContainerDecorator';
145
- const Container = SpotlightContainerDecorator(kind({
146
- name: 'Container',
147
- render: (props) => {
148
- return (
149
- <div {...props}>
150
- {/* A list of spottable controls */}
151
- </div>
152
- );
153
- }
154
- }));
155
- ```
156
-
157
- In a way, containers may be thought of as the branches--and spottable controls
158
- as the leaves--of the Spotlight navigation tree.
159
-
160
- A `spotlightDisabled` property may be applied to the container to temporarily disable the specified container's
161
- spottable controls:
162
-
163
- ```js
164
- import kind from '@enact/core/kind';
165
- import SpotlightContainerDecorator from '@enact/spotlight/SpotlightContainerDecorator';
166
- const Container = SpotlightContainerDecorator('div');
167
- const App = kind({
168
- name: 'App',
169
- render: (props) => {
170
- return (
171
- <Container {...props} spotlightDisabled>
172
- {/* A list of spottable controls */}
173
- </Container>
174
- );
175
- }
176
- });
177
- ```
178
-
179
-
180
- ## Events
181
-
182
- Spotlight uses native DOM events to navigate the available spottable controls and does not
183
- directly dispatch synthetic events to the currently spotted control.
184
-
185
- To determine if spotlight is the cause of a specific spotted control's key event, you can
186
- validate the native `target` property of the key event against `document.activeElement`.
187
-
188
-
189
- ## Spotlight API
190
-
191
- In order to use the Spotlight API, simply import Spotlight into your application and call
192
- any of its available methods to manipulate how your application responds to navigation
193
- events.
194
-
195
- ```js
196
- import Spotlight from '@enact/spotlight';
197
- ```
198
-
199
- #### `Spotlight.pause()`
200
- Temporarily pauses Spotlight until `resume()` is called.
201
-
202
- #### `Spotlight.resume()`
203
- Resumes Spotlight navigation.
204
-
205
- #### `Spotlight.focus([containerId/selector])`
206
- + `containerId/selector`: (optional) String / Selector (without @ syntax)
207
-
208
- Dispatches focus to the specified containerId or the first spottable child that
209
- matches `selector`. This method has no effect if Spotlight is paused.
210
-
211
- #### `Spotlight.move(direction, [selector])`
212
- + `direction`: `'left'`, `'right'`, `'up'` or `'down'`
213
- + `selector`: (optional) Selector (without @ syntax)
214
-
215
- Moves focus in the specified direction of `selector`. If `selector` is not specified,
216
- Spotlight will move in the given direction of the currently spotted control.
217
-
218
- ## HOC Parameters And Properties
219
-
220
- ##### Spotlight HOC Parameters
221
-
222
- Parameters in the form of an object can be passed as an initial argument to a HOC when creating a
223
- Spotlight control. In these cases, the HOC parameter should remain static and unchanged in the
224
- life-cycle of the control.
225
-
226
- ```js
227
- import Spottable from '@enact/spotlight/Spottable';
228
- // spottable control that doesn't emit `onClick` events when pressing the enter key
229
- const Control = Spottable({emulateMouse: false}, 'div');
230
- ```
231
-
232
- ##### Spotlight HOC Properties
233
-
234
- Spotlight HOCs are able to use properties that are passed to them via parent controls. These properties
235
- are passed like in any other Enact component.
236
-
237
- ```js
238
- import kind from '@enact/core/kind';
239
- import Spottable from '@enact/spotlight/Spottable';
240
-
241
- const SpottableComponent = Spottable('div');
242
- const App = kind({
243
- render: () => (<SpottableComponent spotlightDisabled />)
244
- });
245
- ```
246
-
247
- ### Spottable
248
-
249
- ##### Parameters
250
-
251
- `emulateMouse`
252
- + Type: [boolean]
253
- + Default: `true`
254
-
255
- Whether or not the component should emulate mouse events as a response to Spotlight 5-way events.
256
-
257
- ##### Properties
258
- `spotlightDisabled`
259
- + Type: [boolean]
260
- + Default: `false`
261
-
262
- May be added to temporarily make a control not spottable.
263
-
264
- `onSpotlightLeft`
265
- `onSpotlightRight`
266
- `onSpotlightUp`
267
- `onSpotlightDown`
268
- + Type: [function]
269
-
270
- A callback function to override default spotlight behavior when exiting the spottable control.
271
-
272
- `onSpotlightDisappear`
273
- + Type: [function]
274
-
275
- A callback function to be called when the component is removed while retaining focus.
276
-
277
- ### Container
278
-
279
- ##### Parameters
280
-
281
- `defaultElement`
282
- + Type: [string|string[]]
283
- + Default: `'.spottable-default'`
284
-
285
- The selector for the default spottable element within the container. When an array of selectors is
286
- provided, the first selector that successfully matches a node is used.
287
-
288
- `enterTo`
289
- + Type: [string]
290
- + Values: [`''`, `'last-focused'`, or `'default-element'`]
291
- + Default: `''`
292
-
293
- If the focus originates from another container, you can define which element in
294
- this container receives focus first.
295
-
296
- `preserveId`
297
- + Type: [boolean]
298
- + Default: `false`
299
-
300
- Whether the container will preserve the id when it unmounts.
301
-
302
- #### Properties
303
-
304
- `containerId`
305
- + Type: [string]
306
-
307
- Specifies the container id. If the value is `null`, an id will be generated.
308
-
309
- `spotlightDisabled`
310
- + Type: [boolean]
311
- + Default: `false`
312
-
313
- When `true`, controls in the container cannot be navigated.
314
-
315
- `spotlightMuted`
316
- + Type: [boolean]
317
- + Default: `false`
318
-
319
- Whether or not the container is in muted mode. When in muted mode, Spottable controls within the container
320
- can still gain focus, however their `:focus` CSS styles will not be applied, giving them the appearance
321
- of not having focus. Muting a container is generally done to temporarily disable CSS changes and
322
- default `onFocus` and `onBlur` events without removing focus from the container itself - which would
323
- happen if you disabled the container using `spotlightDisabled`.
324
-
325
- `spotlightRestrict`
326
- + Type: [string]
327
- + Values: [`'none'`, `'self-first'`, or `'self-only'`]
328
- + Default: `'none'`
329
-
330
- Restricts or prioritizes focus to the controls in the current container.
331
-
332
- ```js
333
- import SpotlightContainerDecorator from '@enact/spotlight/SpotlightContainerDecorator';
334
- import Component from './Component';
335
- const Container = SpotlightContainerDecorator({enterTo: 'last-focused', restrict: 'self-only'}, Component);
336
- ```
337
-
338
- ## Examples
339
-
340
- #### Basic usage
341
-
342
- ```js
343
- import kind from '@enact/core/kind';
344
- import SpotlightRootDecorator from '@enact/spotlight/SpotlightRootDecorator';
345
- import Spottable from '@enact/spotlight/Spottable';
346
-
347
- const SpottableComponent = Spottable(kind({
348
- name: 'SpottableComponent',
349
- render: (props) => {
350
- return (
351
- <div {...props} />
352
- );
353
- }
354
- }));
355
-
356
- const App = SpotlightRootDecorator(kind({
357
- name: 'SpotlightRootDecorator',
358
- render: (props) => {
359
- return (
360
- <SpottableComponent {...props} />
361
- );
362
- }
363
- }));
364
- ```