@enact/spotlight 4.6.1 → 4.7.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 (33) hide show
  1. package/Accelerator/Accelerator.d.ts +31 -0
  2. package/Accelerator/Accelerator.js +30 -1
  3. package/CHANGELOG.md +10 -0
  4. package/Pause/Pause.d.ts +33 -0
  5. package/Pause/Pause.js +3 -1
  6. package/README.md +1 -1
  7. package/SpotlightContainerDecorator/SpotlightContainer.js +4 -2
  8. package/SpotlightContainerDecorator/SpotlightContainerDecorator.d.ts +89 -0
  9. package/SpotlightContainerDecorator/SpotlightContainerDecorator.js +10 -2
  10. package/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +3 -1
  11. package/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +3 -1
  12. package/SpotlightContainerDecorator/useSpotlightContainer.js +0 -1
  13. package/SpotlightRootDecorator/SpotlightRootDecorator.d.ts +22 -0
  14. package/SpotlightRootDecorator/SpotlightRootDecorator.js +17 -3
  15. package/SpotlightRootDecorator/tests/SpotlightRootDecorator-specs.js +3 -1
  16. package/Spottable/Spottable.d.ts +75 -0
  17. package/Spottable/Spottable.js +12 -3
  18. package/Spottable/SpottableCore.js +3 -1
  19. package/Spottable/tests/Spottable-specs.js +3 -1
  20. package/Spottable/tests/useSpot-specs.js +4 -2
  21. package/Spottable/useSpottable.js +3 -1
  22. package/package.json +2 -2
  23. package/src/container.js +14 -4
  24. package/src/navigate.js +24 -23
  25. package/src/spotlight.d.ts +122 -0
  26. package/src/spotlight.js +18 -1
  27. package/src/target.js +4 -2
  28. package/src/tests/container-specs.js +3 -1
  29. package/src/tests/navigate-specs.js +1 -1
  30. package/src/tests/spotlight-specs.js +3 -1
  31. package/src/tests/target-specs.js +3 -1
  32. package/src/tests/utils.js +3 -1
  33. package/src/utils.js +36 -1
@@ -0,0 +1,31 @@
1
+ // Type definitions for spotlight/Accelerator
2
+
3
+ type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
4
+ type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
5
+
6
+ export declare class Accelerator {
7
+ constructor /**
8
+ * Controls the frequency with which the acceleration will
9
+ "freeze". While frozen, the current target item cannot change, and all events are directed
10
+ to it.
11
+ */(frequency: number[]);
12
+ /**
13
+ * Called with the current keydown event and callback, which will be called when the event is
14
+ allowed through.
15
+ */
16
+ processKey(event: object, callback: Function): boolean;
17
+ /**
18
+ * Resets the Accelerator instance to the default values.
19
+ */
20
+ reset(): void;
21
+ /**
22
+ * Cancels the Accelerator.
23
+ */
24
+ cancel(): void;
25
+ /**
26
+ * Verifies that the Accelerator is active.
27
+ */
28
+ isAccelerating(): boolean;
29
+ }
30
+
31
+ export default Accelerator;
@@ -4,8 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = exports.Accelerator = void 0;
7
- 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); } }
7
+ 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, _toPropertyKey(descriptor.key), descriptor); } }
8
8
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
9
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
10
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
9
11
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
12
  /**
11
13
  * Provides the {@link spotlight/Accelerator.Accelerator} class.
@@ -140,6 +142,33 @@ function Accelerator() {
140
142
  * @returns {Boolean} `true` if the event was consumed by processKey and callback was not called
141
143
  * @public
142
144
  * @memberof spotlight/Accelerator.Accelerator.prototype
145
+ */
146
+
147
+ /**
148
+ * Resets the Accelerator instance to the default values.
149
+ *
150
+ * @function
151
+ * @returns {undefined}
152
+ * @public
153
+ * @memberof spotlight/Accelerator.Accelerator.prototype
154
+ */
155
+
156
+ /**
157
+ * Cancels the Accelerator.
158
+ *
159
+ * @function
160
+ * @returns {undefined}
161
+ * @public
162
+ * @memberof spotlight/Accelerator.Accelerator.prototype
163
+ */
164
+
165
+ /**
166
+ * Verifies that the Accelerator is active.
167
+ *
168
+ * @function
169
+ * @returns {Boolean} `true` if the Accelerator is active; otherwise, `false`.
170
+ * @public
171
+ * @memberof spotlight/Accelerator.Accelerator.prototype
143
172
  */);
144
173
  exports.Accelerator = Accelerator;
145
174
  var _default = Accelerator;
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
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
+ ## [4.7.0] - 2023-04-25
6
+
7
+ ### Fixed
8
+
9
+ - `spotlight` to show the focus effect when pointer mode is changed to `false` while an app is loading
10
+
11
+ ## [4.6.2] - 2023-03-09
12
+
13
+ No significant changes.
14
+
5
15
  ## [4.6.1] - 2023-02-03
6
16
 
7
17
  No significant changes.
@@ -0,0 +1,33 @@
1
+ // Type definitions for spotlight/Pause
2
+
3
+ type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
4
+ type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
5
+
6
+ /**
7
+ * Acts as a semaphore for Spotlight pause state ensuring that only the last Pause instance can
8
+ resume Spotlight.
9
+ *
10
+ * _Note_ will always resume spotlight regardless of what last
11
+ paused spotlight and can be used as an escape hatch to force resumption.
12
+ */
13
+
14
+ export declare class Pause {
15
+ constructor
16
+ /**
17
+ * The name of the pause instance
18
+ */(name: string);
19
+ /**
20
+ * Returns `true` when Spotlight is paused by this instance
21
+ */
22
+ isPaused(): boolean;
23
+ /**
24
+ * Pauses spotlight if not currently paused
25
+ */
26
+ pause(): void;
27
+ /**
28
+ * Resumes spotlight if this instance was the last to pause spotlight
29
+ */
30
+ resume(): boolean;
31
+ }
32
+
33
+ export default Pause;
package/Pause/Pause.js CHANGED
@@ -8,8 +8,10 @@ exports.isPaused = isPaused;
8
8
  exports.pause = pause;
9
9
  exports.resume = _resume;
10
10
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
- 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); } }
11
+ 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, _toPropertyKey(descriptor.key), descriptor); } }
12
12
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
14
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
15
  /**
14
16
  * Provides a class which allows consumers to safely pause and resume spotlight without resuming
15
17
  * another consumer's pause.
package/README.md CHANGED
@@ -43,7 +43,7 @@ Spotlight is based on a fork of [JavaScript SpatialNavigation](https://github.co
43
43
  Unless otherwise specified, all content, including all source code files and
44
44
  documentation files in this repository are:
45
45
 
46
- Copyright (c) 2012-2022 LG Electronics
46
+ Copyright (c) 2012-2023 LG Electronics
47
47
 
48
48
  Unless otherwise specified or set forth in the NOTICE file, all content,
49
49
  including all source code files and documentation files in this repository are:
@@ -10,10 +10,12 @@ var _spotlight = _interopRequireDefault(require("../src/spotlight"));
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
11
  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; }
12
12
  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; }
13
- 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; }
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
14
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
- 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); } }
15
+ 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, _toPropertyKey(descriptor.key), descriptor); } }
16
16
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
17
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
18
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
17
19
  var isNewPointerPosition = function isNewPointerPosition(ev) {
18
20
  return (0, _pointer.hasPointerMoved)(ev.clientX, ev.clientY);
19
21
  };
@@ -0,0 +1,89 @@
1
+ // Type definitions for spotlight/SpotlightContainerDecorator
2
+
3
+ type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
4
+ type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
5
+
6
+ /**
7
+ * The class name to apply to the default component to focus in a container.
8
+ */
9
+ export declare const spotlightDefaultClass: string;
10
+ export interface SpotlightContainerDecoratorConfig extends Object {
11
+ /**
12
+ * When `true` , allows focus to move outside the container to the next spottable element when
13
+ holding 5 way keys.
14
+ */
15
+ continue5WayHold?: boolean;
16
+ /**
17
+ * The selector for the default spottable element within the container.
18
+ When an array of selectors is provided, the first selector that successfully matches a
19
+ node is used.
20
+ */
21
+ defaultElement?: string | string[];
22
+ /**
23
+ * Directs which element receives focus when gaining focus from another container. If
24
+ `'default-element'` , the default focused item will be selected. If `'last-focused'` , the
25
+ container will focus the last focused item; if the container has never had focus, the default
26
+ element will receive focus. If `null` , the default 5-way behavior will be applied.
27
+ */
28
+ enterTo?: string;
29
+ /**
30
+ * Filter the navigable elements.
31
+ */
32
+ navigableFilter?: Function;
33
+ /**
34
+ * Whether the container will preserve the specified `spotlightId` when it unmounts.
35
+ */
36
+ preserveId?: boolean;
37
+ /**
38
+ * Restricts or prioritizes navigation when focus attempts to leave the container. It
39
+ can be either 'none', 'self-first', or 'self-only'. Specifying 'self-first' indicates that
40
+ elements within the container will have a higher likelihood to be chosen as the next
41
+ navigable element. Specifying 'self-only' indicates that elements in other containers
42
+ cannot be navigated to by using 5-way navigation - however, elements in other containers
43
+ can still receive focus by calling `Spotlight.focus(elem)` explicitly. Specifying 'none'
44
+ indicates there should be no restrictions when 5-way navigating the container.
45
+ */
46
+ restrict?: string;
47
+ }
48
+ export interface SpotlightContainerDecoratorProps {
49
+ /**
50
+ * When `true` , controls in the container cannot be navigated.
51
+ */
52
+ spotlightDisabled?: boolean;
53
+ /**
54
+ * Used to identify this component within the Spotlight system.
55
+ *
56
+ * If the value is `null` , an id will be generated.
57
+ To keep the container information for restoring focus, it is required to specify
58
+ a unique identifier.
59
+ */
60
+ spotlightId?: string;
61
+ /**
62
+ * Whether or not the container is in muted mode.
63
+ *
64
+ * In muted mode, `:focus` CSS styles will not be applied to the
65
+ Spottable controls giving them the appearance of not having focus
66
+ while they still have focus.
67
+ */
68
+ spotlightMuted?: boolean;
69
+ /**
70
+ * Restricts or prioritizes navigation when focus attempts to leave the container. It
71
+ can be either 'none', 'self-first', or 'self-only'. Specifying 'self-first' indicates that
72
+ elements within the container will have a higher likelihood to be chosen as the next
73
+ navigable element. Specifying 'self-only' indicates that elements in other containers
74
+ cannot be navigated to by using 5-way navigation - however, elements in other containers
75
+ can still receive focus by calling `Spotlight.focus(elem)` explicitly. Specifying 'none'
76
+ indicates there should be no restrictions when 5-way navigating the container.
77
+ */
78
+ spotlightRestrict?: string;
79
+ }
80
+ export function SpotlightContainerDecorator<P>(
81
+ config: SpotlightContainerDecoratorConfig,
82
+ Component: React.ComponentType<P> | string
83
+ ): React.ComponentType<P & SpotlightContainerDecoratorProps>;
84
+
85
+ export function SpotlightContainerDecorator<P>(
86
+ Component: React.ComponentType<P> | string
87
+ ): React.ComponentType<P & SpotlightContainerDecoratorProps>;
88
+
89
+ export default SpotlightContainerDecorator;
@@ -19,11 +19,17 @@ var _useSpotlightContainer = _interopRequireDefault(require("./useSpotlightConta
19
19
  var _jsxRuntime = require("react/jsx-runtime");
20
20
  var _excluded = ["navigableFilter", "preserveId"],
21
21
  _excluded2 = ["spotlightDisabled", "spotlightId", "spotlightMuted", "spotlightRestrict"];
22
+ /**
23
+ * A component for managing groups of spottable components.
24
+ *
25
+ * @module spotlight/SpotlightContainerDecorator
26
+ * @exports SpotlightContainerDecorator
27
+ */
22
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
29
  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); }
24
30
  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; }
25
31
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
26
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
32
+ 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, _toPropertyKey(descriptor.key), descriptor); } }
27
33
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
28
34
  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); }
29
35
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
@@ -34,7 +40,9 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
34
40
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
35
41
  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; }
36
42
  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; }
37
- 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; }
43
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
44
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
45
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
38
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; }
39
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; }
40
48
  var callContext = function callContext(name) {
@@ -11,7 +11,9 @@ var _jsxRuntime = require("react/jsx-runtime");
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
12
  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; }
13
13
  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; }
14
- 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; }
14
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
16
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
15
17
  var testId = 'test-spotlightContainerDecorator';
16
18
  describe('SpotlightContainerDecorator', function () {
17
19
  var hoverPosition = {
@@ -10,7 +10,9 @@ var _excluded = ["containerConfig", "preserveId", "spotlightDisabled", "spotligh
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
11
  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; }
12
12
  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; }
13
- 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; }
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
15
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
16
  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; }
15
17
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
16
18
  function containerExists(id) {
@@ -83,7 +83,6 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
83
83
  * event flow.
84
84
  * @private
85
85
  */
86
-
87
86
  /**
88
87
  * Support Spotlight container
89
88
  *
@@ -0,0 +1,22 @@
1
+ // Type definitions for spotlight/SpotlightRootDecorator
2
+
3
+ type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
4
+ type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
5
+
6
+ export interface SpotlightRootDecoratorConfig extends Object {
7
+ /**
8
+ * When `true` , the contents of the component will not receive spotlight focus after being rendered.
9
+ */
10
+ noAutoFocus?: boolean;
11
+ }
12
+ export interface SpotlightRootDecoratorProps {}
13
+ export function SpotlightRootDecorator<P>(
14
+ config: SpotlightRootDecoratorConfig,
15
+ Component: React.ComponentType<P> | string
16
+ ): React.ComponentType<P & SpotlightRootDecoratorProps>;
17
+
18
+ export function SpotlightRootDecorator<P>(
19
+ Component: React.ComponentType<P> | string
20
+ ): React.ComponentType<P & SpotlightRootDecoratorProps>;
21
+
22
+ export default SpotlightRootDecorator;
@@ -15,17 +15,25 @@ var _jsxRuntime = require("react/jsx-runtime");
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
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; }
17
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; }
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; }
18
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
19
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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); } }
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, _toPropertyKey(descriptor.key), descriptor); } }
21
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; }
22
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
23
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
22
24
  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); }
23
25
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
24
26
  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); }; }
25
27
  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); }
26
28
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
27
29
  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; } }
28
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
30
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /**
31
+ * Exports the {@link spotlight/SpotlightRootDecorator.SpotlightRootDecorator}
32
+ * higher-order component.
33
+ *
34
+ * @module spotlight/SpotlightRootDecorator
35
+ * @exports SpotlightRootDecorator
36
+ */
29
37
  var input = {
30
38
  activated: false,
31
39
  applied: false,
@@ -208,6 +216,12 @@ var SpotlightRootDecorator = (0, _hoc["default"])(defaultConfig, function (confi
208
216
  });
209
217
  }
210
218
  }
219
+
220
+ // For key input
221
+
222
+ // For mouse input
223
+
224
+ // For touch input
211
225
  }, {
212
226
  key: "render",
213
227
  value: function render() {
@@ -6,7 +6,9 @@ var _SpotlightRootDecorator = require("../SpotlightRootDecorator");
6
6
  var _jsxRuntime = require("react/jsx-runtime");
7
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
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; }
9
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
12
  describe('SpotlightRootDecorator', function () {
11
13
  var AppBase = function AppBase(props) {
12
14
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({
@@ -0,0 +1,75 @@
1
+ // Type definitions for spotlight/Spottable
2
+
3
+ type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
4
+ type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
5
+
6
+ /**
7
+ * The class name for spottable components. In general, you do not need to directly access this class
8
+ */
9
+ export declare const spottableClass: string;
10
+ export interface SpottableConfig extends Object {
11
+ /**
12
+ * Whether or not the component should emulate mouse events as a response
13
+ to Spotlight 5-way events.
14
+ */
15
+ emulateMouse?: boolean;
16
+ }
17
+ export interface SpottableProps {
18
+ /**
19
+ * Whether or not the component is in a disabled state.
20
+ */
21
+ disabled?: boolean;
22
+ /**
23
+ * The handler to force update the component.
24
+ */
25
+ handleForceUpdate?: Function;
26
+ /**
27
+ * The handler to run when the component is removed while retaining focus.
28
+ */
29
+ onSpotlightDisappear?: Function;
30
+ /**
31
+ * The handler to run when the 5-way down key is pressed.
32
+ */
33
+ onSpotlightDown?: Function;
34
+ /**
35
+ * The handler to run when the 5-way left key is pressed.
36
+ */
37
+ onSpotlightLeft?: Function;
38
+ /**
39
+ * The handler to run when the 5-way right key is pressed.
40
+ */
41
+ onSpotlightRight?: Function;
42
+ /**
43
+ * The handler to run when the 5-way up key is pressed.
44
+ */
45
+ onSpotlightUp?: Function;
46
+ /**
47
+ * An array of numbers representing keyCodes that should trigger mouse event
48
+ emulation when `emulateMouse` is `true` . If a keyCode equals a directional
49
+ key, then default 5-way navigation will be prevented when that key is pressed.
50
+ */
51
+ selectionKeys?: number[];
52
+ /**
53
+ * When `true` , the component cannot be navigated using spotlight.
54
+ */
55
+ spotlightDisabled?: boolean;
56
+ /**
57
+ * Used to identify this component within the Spotlight system
58
+ */
59
+ spotlightId?: string;
60
+ /**
61
+ * The tabIndex of the component. This value will default to -1 if left
62
+ unset and the control is spottable.
63
+ */
64
+ tabIndex?: number;
65
+ }
66
+ export function Spottable<P>(
67
+ config: SpottableConfig,
68
+ Component: React.ComponentType<P> | string
69
+ ): React.ComponentType<P & SpottableProps>;
70
+
71
+ export function Spottable<P>(
72
+ Component: React.ComponentType<P> | string
73
+ ): React.ComponentType<P & SpottableProps>;
74
+
75
+ export default Spottable;
@@ -27,11 +27,18 @@ var _reactDom = _interopRequireDefault(require("react-dom"));
27
27
  var _useSpottable = require("./useSpottable");
28
28
  var _jsxRuntime = require("react/jsx-runtime");
29
29
  var _excluded = ["className", "disabled", "handleForceUpdate", "onSpotlightDisappear", "onSpotlightDown", "onSpotlightLeft", "onSpotlightRight", "onSpotlightUp", "selectionKeys", "spotlightDisabled", "spotlightId", "spotRef"];
30
+ /**
31
+ * Adds spottability to components.
32
+ *
33
+ * @module spotlight/Spottable
34
+ * @exports Spottable
35
+ * @exports spottableClass
36
+ */
30
37
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
31
38
  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); }
32
39
  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; }
33
40
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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); } }
41
+ 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, _toPropertyKey(descriptor.key), descriptor); } }
35
42
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
36
43
  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); }
37
44
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
@@ -42,7 +49,9 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
42
49
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
43
50
  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; }
44
51
  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; }
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; }
52
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
53
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
54
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
46
55
  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; }
47
56
  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; }
48
57
  var forwardMouseDown = (0, _handle.forward)('onMouseDown'),
@@ -238,7 +247,7 @@ var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
238
247
  */
239
248
  spotlightId: _propTypes2["default"].string,
240
249
  /*
241
- * Called with a reference to {@link spotlight/Spottable.Spottable#component|component}
250
+ * Called with a reference to spottable component
242
251
  *
243
252
  * @type {Object|Function}
244
253
  * @private
@@ -9,8 +9,10 @@ var _keymap = require("@enact/core/keymap");
9
9
  var _container = require("../src/container");
10
10
  var _spotlight = require("../src/spotlight");
11
11
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
- 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); } }
12
+ 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, _toPropertyKey(descriptor.key), descriptor); } }
13
13
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
15
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
16
  var REMOTE_OK_KEY = 16777221;
15
17
 
16
18
  /**
@@ -7,7 +7,9 @@ var _jsxRuntime = require("react/jsx-runtime");
7
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8
8
  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; }
9
9
  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; }
10
- 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
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
12
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
11
13
  var id = 'test-spottable';
12
14
  describe('Spottable', function () {
13
15
  test('should add the spottable class', function () {
@@ -15,7 +15,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
15
15
  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); }
16
16
  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; }
17
17
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
- 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); } }
18
+ 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, _toPropertyKey(descriptor.key), descriptor); } }
19
19
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
20
20
  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); }
21
21
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
@@ -26,7 +26,9 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
26
26
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
27
27
  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; }
28
28
  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
- 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
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
30
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
31
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
30
32
  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
33
  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; }
32
34
  var forwardMouseUp = (0, _handle.forward)('onMouseUp'),
@@ -18,7 +18,9 @@ var _excluded = ["spotRef", "emulateMouse", "selectionKeys", "spotlightDisabled"
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
19
  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; }
20
20
  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; }
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; }
21
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
23
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
22
24
  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; }
23
25
  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; }
24
26
  var ENTER_KEY = 13;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/spotlight",
3
- "version": "4.6.1",
3
+ "version": "4.7.0",
4
4
  "description": "A focus management library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,7 +24,7 @@
24
24
  }
25
25
  },
26
26
  "dependencies": {
27
- "@enact/core": "^4.6.1",
27
+ "@enact/core": "^4.7.0",
28
28
  "classnames": "^2.3.2",
29
29
  "prop-types": "^15.8.1",
30
30
  "ramda": "^0.28.0",
package/src/container.js CHANGED
@@ -39,13 +39,20 @@ var _utils = require("./utils");
39
39
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
40
40
  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; }
41
41
  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; }
42
- 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; }
42
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
43
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
44
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
43
45
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
44
46
  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."); }
45
47
  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(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
46
48
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
47
49
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
48
- 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; }
50
+ 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; } /**
51
+ * Exports methods and members for creating and maintaining spotlight containers.
52
+ *
53
+ * @module spotlight/container
54
+ * @private
55
+ */
49
56
  var containerAttribute = 'data-spotlight-id';
50
57
  exports.containerAttribute = containerAttribute;
51
58
  var containerConfigs = new Map();
@@ -81,6 +88,8 @@ var GlobalConfig = {
81
88
  // <extSelector> except "@" syntax.
82
89
  enterTo: '',
83
90
  // '', 'last-focused', 'default-element'
91
+ isStandardFocusableMode: false,
92
+ // @private - set to true to focus standard focusable element
84
93
  lastFocusedElement: null,
85
94
  lastFocusedKey: null,
86
95
  lastFocusedPersist: function lastFocusedPersist(node, all) {
@@ -133,7 +142,8 @@ var GlobalConfig = {
133
142
  * @private
134
143
  */
135
144
  var querySelector = function querySelector(node, includeSelector, excludeSelector) {
136
- var include = new Set(node.querySelectorAll(includeSelector));
145
+ var focusables = GlobalConfig.isStandardFocusableMode ? Array.prototype.filter.call(node.getElementsByTagName('*'), _utils.isStandardFocusable) : [];
146
+ var include = new Set([].concat(_toConsumableArray(node.querySelectorAll(includeSelector)), _toConsumableArray(focusables)));
137
147
  var exclude = node.querySelectorAll(excludeSelector);
138
148
  for (var i = 0; i < exclude.length; i++) {
139
149
  include["delete"](exclude[i]);
@@ -618,7 +628,7 @@ var isNavigable = function isNavigable(node, containerId, verify) {
618
628
  return false;
619
629
  }
620
630
  var config = getContainerConfig(containerId);
621
- if (verify && config && config.selector && !isContainer(node) && !(0, _utils.matchSelector)(config.selector, node)) {
631
+ if (verify && config && config.selector && !isContainer(node) && !(0, _utils.matchSelector)(config.selector, node) && !(GlobalConfig.isStandardFocusableMode && (0, _utils.isStandardFocusable)(node))) {
622
632
  return false;
623
633
  }
624
634
  return navigableFilter(node, containerId);
package/src/navigate.js CHANGED
@@ -57,34 +57,35 @@ var calcNextExtendedGridPosition = function calcNextExtendedGridPosition(current
57
57
  };
58
58
  function prioritize(priorities, targetEdge) {
59
59
  var destGroup = [];
60
- for (var index = 0; index < priorities.length; index++) {
60
+ var _loop = function _loop() {
61
61
  var destPriority = priorities[index];
62
62
  if (destPriority.group.length) {
63
- (function () {
64
- var destDistance = destPriority.distance;
65
- var destDifference = destPriority.difference;
66
- var distance = 0;
67
- var target = void 0;
68
- destPriority.group.sort(function (a, b) {
69
- for (var i = 0; i < destDistance.length; i++) {
70
- var calcDistance = destDistance[i];
71
- var delta = calcDistance(a) - calcDistance(b);
72
- if (delta) {
73
- return delta;
74
- }
63
+ var destDistance = destPriority.distance;
64
+ var destDifference = destPriority.difference;
65
+ var distance = 0;
66
+ var target;
67
+ destPriority.group.sort(function (a, b) {
68
+ for (var i = 0; i < destDistance.length; i++) {
69
+ var calcDistance = destDistance[i];
70
+ var delta = calcDistance(a) - calcDistance(b);
71
+ if (delta) {
72
+ return delta;
75
73
  }
76
- return 0;
77
- });
78
- target = destPriority.group[0];
79
- for (var i = 0; i < destDifference.length; i++) {
80
- distance += destDifference[i](target);
81
74
  }
82
- destGroup.push({
83
- distance: Math.pow(destPriority.multiplier * (distance || destPriority.minDistance) / targetEdge, 2) + targetEdge,
84
- target: target
85
- });
86
- })();
75
+ return 0;
76
+ });
77
+ target = destPriority.group[0];
78
+ for (var i = 0; i < destDifference.length; i++) {
79
+ distance += destDifference[i](target);
80
+ }
81
+ destGroup.push({
82
+ distance: Math.pow(destPriority.multiplier * (distance || destPriority.minDistance) / targetEdge, 2) + targetEdge,
83
+ target: target
84
+ });
87
85
  }
86
+ };
87
+ for (var index = 0; index < priorities.length; index++) {
88
+ _loop();
88
89
  }
89
90
  if (!destGroup.length) {
90
91
  return null;
@@ -0,0 +1,122 @@
1
+ // Type definitions for spotlight
2
+
3
+ type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
4
+ type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
5
+
6
+ /**
7
+ * Translates keyCodes into 5-way direction descriptions (e.g. `'down'` )
8
+ */
9
+ export function getDirection(keyCode: number): string | false;
10
+ /**
11
+ * Provides 5-way navigation and focus support
12
+ * ```
13
+ import Spotlight from '@enact/Spotlight';
14
+
15
+ // get the currently focused component
16
+ const current = Spotlight.getCurrent();
17
+
18
+ // focus an element by CSS selector
19
+ Spotlight.focus('.my-custom-class');
20
+
21
+ // is `current` focusable?
22
+ const isFocused = Spotlight.isSpottable(current);
23
+ ```
24
+ */
25
+ export declare const Spotlight: {
26
+ /**
27
+ * Initializes Spotlight. This is generally handled by
28
+ .
29
+ */
30
+ initialize(containerDefaults: object): void;
31
+ /**
32
+ * Terminates Spotlight. This is generally handled by .
33
+ */
34
+ terminate(): void;
35
+ /**
36
+ * Sets the config for spotlight or the specified containerID
37
+ */
38
+ set(containerIdOrConfig: string | object, config?: object): void;
39
+ /**
40
+ * Adds the config for a new container. The container ID may be passed in the configuration
41
+ object. If no container ID is supplied, a new container ID will be generated.
42
+ */
43
+ add(containerIdOrConfig: string | object, config?: object): string;
44
+ /**
45
+ * Removes a container from Spotlight
46
+ */
47
+ remove(containerId: string): boolean;
48
+ /**
49
+ * Disables the selector rules of the specified container
50
+ */
51
+ disableSelector(containerId: string): boolean;
52
+ /**
53
+ * Enables the selector rules of the specified container
54
+ */
55
+ enableSelector(containerId: string): boolean;
56
+ /**
57
+ * Pauses Spotlight
58
+ */
59
+ pause(): void;
60
+ /**
61
+ * Resumes Spotlight
62
+ */
63
+ resume(): void;
64
+ /**
65
+ * Focuses the specified component ID, container ID, element selector, or the default
66
+ container.
67
+ *
68
+ * If Spotlight is in pointer mode, focus is not changed but `elem` will be set as the last
69
+ focused element of its spotlight containers.
70
+ */
71
+ focus(elem?: string | React.ReactNode, containerOption?: object): boolean;
72
+ /**
73
+ * Moves focus to the next spottable control in the direction specified. Optionally, a source
74
+ element selector may be supplied as the starting point.
75
+ */
76
+ move(direction: string, selector: string | void): boolean;
77
+ /**
78
+ * Sets or clears the default container that will receive focus.
79
+ */
80
+ setDefaultContainer(containerId?: string): void;
81
+ /**
82
+ * Gets the currently active container.
83
+ */
84
+ getActiveContainer(): string;
85
+ /**
86
+ * Sets the currently active container.
87
+ *
88
+ * Note: If the current container is restricted to 'self-only' and `containerId` is not
89
+ contained within the current container then the active container will not be updated.
90
+ */
91
+ setActiveContainer(containerId?: string): void;
92
+ /**
93
+ * Gets the current pointer mode
94
+ */
95
+ getPointerMode(): boolean;
96
+ /**
97
+ * Sets the current pointer mode
98
+ */
99
+ setPointerMode(pointerMode: boolean): void;
100
+ /**
101
+ * Gets the muted mode value of a spottable element.
102
+ */
103
+ isMuted(elem: object): boolean;
104
+ /**
105
+ * Determines whether Spotlight is currently paused.
106
+ */
107
+ isPaused(): boolean;
108
+ /**
109
+ * Determines whether an element is spottable.
110
+ */
111
+ isSpottable(elem: object): boolean;
112
+ /**
113
+ * Returns the currently spotted control.
114
+ */
115
+ getCurrent(): React.ReactNode;
116
+ /**
117
+ * Returns a list of spottable elements wrapped by the supplied container.
118
+ */
119
+ getSpottableDescendants(containerId: string): React.ReactNode[];
120
+ };
121
+
122
+ export default Spotlight;
package/src/spotlight.js CHANGED
@@ -85,6 +85,7 @@ var Spotlight = function () {
85
85
  */
86
86
  var _initialized = false;
87
87
  var _duringFocusChange = false;
88
+ var _focusRingElement = null;
88
89
 
89
90
  /*
90
91
  * Whether a 5-way directional key is being held.
@@ -140,10 +141,11 @@ var Spotlight = function () {
140
141
  }
141
142
  }
142
143
  function focusElement(elem, containerIds, fromPointer) {
144
+ var _window$PalmSystem$cu;
143
145
  if (!elem) {
144
146
  return false;
145
147
  }
146
- if ((0, _pointer.getPointerMode)() && !fromPointer) {
148
+ if ((0, _pointer.getPointerMode)() && !fromPointer && typeof window !== 'undefined' && (!window.PalmSystem || (_window$PalmSystem$cu = window.PalmSystem.cursor) !== null && _window$PalmSystem$cu !== void 0 && _window$PalmSystem$cu.visibility)) {
147
149
  (0, _container.setContainerLastFocusedElement)(elem, containerIds);
148
150
  return false;
149
151
  }
@@ -169,6 +171,15 @@ var Spotlight = function () {
169
171
  return true;
170
172
  }
171
173
  elem.focus(focusOptions);
174
+
175
+ /* istanbul ignore next */
176
+ if (_focusRingElement) {
177
+ var elemRect = elem.getBoundingClientRect();
178
+ _focusRingElement.style.left = "".concat(elemRect.x + window.scrollX, "px");
179
+ _focusRingElement.style.top = "".concat(elemRect.y + window.scrollY, "px");
180
+ _focusRingElement.style.width = "".concat(elemRect.width, "px");
181
+ _focusRingElement.style.height = "".concat(elemRect.height, "px");
182
+ }
172
183
  _duringFocusChange = false;
173
184
  focusChanged(elem, containerIds);
174
185
  return true;
@@ -422,6 +433,7 @@ var Spotlight = function () {
422
433
  */
423
434
  initialize: function initialize(containerDefaults) {
424
435
  if (!_initialized) {
436
+ var _getContainerConfig3;
425
437
  window.addEventListener('blur', onBlur);
426
438
  window.addEventListener('focus', onFocus);
427
439
  window.addEventListener('keydown', onKeyDown);
@@ -441,6 +453,11 @@ var Spotlight = function () {
441
453
  // by default, pointer mode is off but the platform's current state will override that
442
454
  (0, _pointer.setPointerMode)(false);
443
455
  setPlatformPointerMode();
456
+
457
+ /* istanbul ignore next */
458
+ if ((_getContainerConfig3 = (0, _container.getContainerConfig)('spotlightRootDecorator')) !== null && _getContainerConfig3 !== void 0 && _getContainerConfig3.isStandardFocusableMode) {
459
+ _focusRingElement = document.querySelector('#spotlightFocusRing');
460
+ }
444
461
  _initialized = true;
445
462
  }
446
463
  },
package/src/target.js CHANGED
@@ -18,13 +18,15 @@ var _utils = require("./utils");
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
19
  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; }
20
20
  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; }
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; }
21
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
23
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
22
24
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
23
25
  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."); }
24
26
  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(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
25
27
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
26
28
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
27
- 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; }
29
+ 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; }
28
30
  function isFocusable(elem) {
29
31
  var containers = (0, _container.getContainersForNode)(elem);
30
32
  var verifySelector = true;
@@ -3,7 +3,9 @@
3
3
  var _container17 = require("../container");
4
4
  var _utils = require("./utils");
5
5
  var _node, _container, _container2, _container3, _container4, _container5, _container6, _container7, _container8, _container9, _container10, _container11, _container12, _container13, _container15, _container16;
6
- 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; }
6
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
8
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
9
  var nonSpottable = function nonSpottable() {
8
10
  return (0, _utils.node)({
9
11
  className: 'other'
@@ -7,7 +7,7 @@ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread n
7
7
  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(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
8
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
9
9
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
- 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; }
10
+ 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; }
11
11
  // loose copy from utils/getRect to fabricate a rect for navigation
12
12
  function getRect(top, left, height, width, elem) {
13
13
  var rect = {
@@ -5,7 +5,9 @@ var _spotlight = _interopRequireDefault(require("../spotlight"));
5
5
  var _utils = require("./utils");
6
6
  var _container, _container2, _container3;
7
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8
- 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; }
8
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
10
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
9
11
  var nonSpottable = function nonSpottable() {
10
12
  return (0, _utils.node)({
11
13
  className: 'other'
@@ -4,7 +4,9 @@ var _container12 = require("../container");
4
4
  var _target = require("../target");
5
5
  var _utils = require("./utils");
6
6
  var _container2, _container3, _container4, _container5, _container6, _container7, _container8, _container9, _container10, _container11;
7
- 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; }
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
9
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
10
  var nonSpottable = function nonSpottable() {
9
11
  return (0, _utils.node)({
10
12
  className: 'other'
@@ -9,7 +9,9 @@ var _container = require("../container");
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
10
  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; }
11
11
  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; }
12
- 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; }
12
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
14
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
15
  var join = _ramda["default"].unapply(_ramda["default"].join('\n'));
14
16
  exports.join = join;
15
17
  var testScenario = function testScenario(scenario, callback) {
package/src/utils.js CHANGED
@@ -8,7 +8,9 @@ exports.getContainerRect = getContainerRect;
8
8
  exports.getPointRect = getPointRect;
9
9
  exports.getRect = getRect;
10
10
  exports.getRects = getRects;
11
- exports.matchSelector = exports.intersects = void 0;
11
+ exports.intersects = void 0;
12
+ exports.isStandardFocusable = isStandardFocusable;
13
+ exports.matchSelector = void 0;
12
14
  exports.parseSelector = parseSelector;
13
15
  var _curry = _interopRequireDefault(require("ramda/src/curry"));
14
16
  var _warning = _interopRequireDefault(require("warning"));
@@ -160,4 +162,37 @@ function getContainerRect(containerId) {
160
162
  return getViewportRect();
161
163
  }
162
164
  return getRect(containerNode);
165
+ }
166
+
167
+ // For details see: https://html.spec.whatwg.org/multipage/interaction.html#focusable-area
168
+ function isStandardFocusable(element) {
169
+ if (element.tabIndex < 0) {
170
+ // If the tabIndex value is negative, it is not focusable
171
+ return false;
172
+ } else if (isElementHidden(element)) {
173
+ return false;
174
+ } else if (['BUTTON', 'INPUT', 'SELECT', 'TEXTAREA', 'OPTGROUP', 'OPTION', 'FIELDSET'].includes(element.tagName) && element.disabled) {
175
+ // If the element is actually disabled, it is not focusable
176
+ return false;
177
+ } else if (element.tagName === 'A' && element.getAttribute('href') !== null) {
178
+ // Anchor element that has an href attribute is focusable
179
+ return true;
180
+ } else if (element.tagName === 'INPUT' && element.type !== 'hidden') {
181
+ // Input element whose type attribute is not hidden is focusable
182
+ return true;
183
+ } else if (element.tabIndex >= 0 || !element.parentElement) {
184
+ // If the tabIndex value is more than 0, it is focusable
185
+ // If element is document or iframe, it is focusable
186
+ return true;
187
+ } else {
188
+ return false;
189
+ }
190
+ }
191
+ function isElementHidden(element) {
192
+ var elemRect = element.getBoundingClientRect();
193
+ if (elemRect.width <= 1 && elemRect.height <= 1 || elemRect.x < -3840 || elemRect.y < -2160 || element.getAttribute('hidden')) {
194
+ return true;
195
+ } else {
196
+ return false;
197
+ }
163
198
  }