@enact/spotlight 4.1.2 → 4.5.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Accelerator/Accelerator.d.ts +2 -5
- package/Accelerator/Accelerator.js +7 -3
- package/CHANGELOG.md +17 -0
- package/Pause/Pause.d.ts +4 -6
- package/Pause/Pause.js +2 -2
- package/Pause/tests/Pause-specs.js +2 -2
- package/README.md +1 -1
- package/SpotlightContainerDecorator/SpotlightContainer.js +4 -4
- package/SpotlightContainerDecorator/SpotlightContainerDecorator.js +13 -10
- package/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +44 -38
- package/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +106 -52
- package/SpotlightContainerDecorator/useSpotlightContainer.js +4 -2
- package/SpotlightRootDecorator/SpotlightRootDecorator.js +9 -16
- package/Spottable/Spottable.js +11 -9
- package/Spottable/SpottableCore.js +4 -4
- package/Spottable/tests/Spottable-specs.js +66 -37
- package/Spottable/tests/useSpot-specs.js +128 -71
- package/Spottable/useSpottable.js +7 -4
- package/package.json +8 -8
- package/src/container.js +24 -16
- package/src/navigate.js +1 -1
- package/src/spotlight.js +1 -1
- package/src/target.js +3 -3
- package/src/tests/utils.js +2 -2
- package/src/utils.js +11 -9
- package/styles/debug.less +80 -82
|
@@ -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.
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports["default"] = exports.Accelerator = void 0;
|
|
7
|
+
|
|
8
|
+
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); } }
|
|
9
|
+
|
|
10
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
11
|
|
|
8
12
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
13
|
|
|
@@ -18,7 +22,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
18
22
|
* @class Accelerator
|
|
19
23
|
* @memberof spotlight/Accelerator
|
|
20
24
|
*/
|
|
21
|
-
var Accelerator =
|
|
25
|
+
var Accelerator = /*#__PURE__*/_createClass(
|
|
22
26
|
/**
|
|
23
27
|
* @constructor
|
|
24
28
|
* @param {Number[]} frequency - Controls the frequency with which the acceleration will
|
|
@@ -155,7 +159,7 @@ function Accelerator() {
|
|
|
155
159
|
* @public
|
|
156
160
|
* @memberof spotlight/Accelerator.Accelerator.prototype
|
|
157
161
|
*/
|
|
158
|
-
;
|
|
162
|
+
);
|
|
159
163
|
|
|
160
164
|
exports.Accelerator = Accelerator;
|
|
161
165
|
var _default = Accelerator;
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
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.5.0-alpha.1] - 2022-04-15
|
|
6
|
+
|
|
7
|
+
No significant changes.
|
|
8
|
+
|
|
9
|
+
## [4.1.4] - 2022-03-24
|
|
10
|
+
|
|
11
|
+
No significant changes.
|
|
12
|
+
|
|
13
|
+
## [4.1.3] - 2022-03-07
|
|
14
|
+
|
|
15
|
+
- Updated to use `forwardCustom` and add `type` when forwarding custom events
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- `spotlight` to correctly control focus when boundaries of an element are not integers
|
|
20
|
+
- Styles for `debug spotlight` option in samplers to work properly
|
|
21
|
+
|
|
5
22
|
## [4.1.2] - 2021-12-22
|
|
6
23
|
|
|
7
24
|
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
|
-
|
|
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
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports["default"] = exports.Pause = void 0;
|
|
6
7
|
exports.isPaused = isPaused;
|
|
7
8
|
exports.pause = pause;
|
|
8
9
|
exports.resume = _resume;
|
|
9
|
-
exports.Pause = exports["default"] = void 0;
|
|
10
10
|
|
|
11
11
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
12
|
|
|
13
13
|
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); } }
|
|
14
14
|
|
|
15
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Provides a class which allows consumers to safely pause and resume spotlight without resuming
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var _Pause = _interopRequireWildcard(require("../Pause"));
|
|
4
4
|
|
|
5
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
5
|
+
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); }
|
|
6
6
|
|
|
7
|
-
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; }
|
|
7
|
+
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; }
|
|
8
8
|
|
|
9
9
|
var PAUSED = 'Paused';
|
|
10
10
|
var NOT_PAUSED = 'Not Paused';
|
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-
|
|
46
|
+
Copyright (c) 2012-2022 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:
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports["default"] = exports.SpotlightContainer = void 0;
|
|
7
7
|
|
|
8
8
|
var _handle = require("@enact/core/handle");
|
|
9
9
|
|
|
@@ -13,9 +13,9 @@ var _spotlight = _interopRequireDefault(require("../src/spotlight"));
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
15
|
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
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
|
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
18
|
+
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; }
|
|
19
19
|
|
|
20
20
|
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
21
|
|
|
@@ -23,7 +23,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
23
23
|
|
|
24
24
|
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); } }
|
|
25
25
|
|
|
26
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
26
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
27
27
|
|
|
28
28
|
var isNewPointerPosition = function isNewPointerPosition(ev) {
|
|
29
29
|
return (0, _pointer.hasPointerMoved)(ev.clientX, ev.clientY);
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.spotlightDefaultClass = exports["default"] = exports.SpotlightContainerDecorator = void 0;
|
|
6
7
|
Object.defineProperty(exports, "useSpotlightContainer", {
|
|
7
8
|
enumerable: true,
|
|
8
9
|
get: function get() {
|
|
9
10
|
return _useSpotlightContainer["default"];
|
|
10
11
|
}
|
|
11
12
|
});
|
|
12
|
-
exports.spotlightDefaultClass = exports.SpotlightContainerDecorator = exports["default"] = void 0;
|
|
13
13
|
|
|
14
14
|
var _handle = _interopRequireWildcard(require("@enact/core/handle"));
|
|
15
15
|
|
|
@@ -25,25 +25,28 @@ var _useSpotlightContainer = _interopRequireDefault(require("./useSpotlightConta
|
|
|
25
25
|
|
|
26
26
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
27
27
|
|
|
28
|
+
var _excluded = ["navigableFilter", "preserveId"],
|
|
29
|
+
_excluded2 = ["spotlightDisabled", "spotlightId", "spotlightMuted", "spotlightRestrict"];
|
|
30
|
+
|
|
28
31
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
29
32
|
|
|
30
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
33
|
+
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); }
|
|
31
34
|
|
|
32
|
-
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; }
|
|
35
|
+
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
36
|
|
|
34
37
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
35
38
|
|
|
36
39
|
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); } }
|
|
37
40
|
|
|
38
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
41
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
39
42
|
|
|
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); }
|
|
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); }
|
|
41
44
|
|
|
42
45
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
43
46
|
|
|
44
47
|
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); }; }
|
|
45
48
|
|
|
46
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
49
|
+
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); }
|
|
47
50
|
|
|
48
51
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
49
52
|
|
|
@@ -51,9 +54,9 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
51
54
|
|
|
52
55
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
53
56
|
|
|
54
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
57
|
+
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; }
|
|
55
58
|
|
|
56
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
59
|
+
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; }
|
|
57
60
|
|
|
58
61
|
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; }
|
|
59
62
|
|
|
@@ -189,7 +192,7 @@ var defaultConfig = {
|
|
|
189
192
|
var SpotlightContainerDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
|
|
190
193
|
var navigableFilter = config.navigableFilter,
|
|
191
194
|
preserveId = config.preserveId,
|
|
192
|
-
containerConfig = _objectWithoutProperties(config,
|
|
195
|
+
containerConfig = _objectWithoutProperties(config, _excluded); // eslint-disable-next-line no-shadow
|
|
193
196
|
|
|
194
197
|
|
|
195
198
|
function SpotlightContainerDecorator(props) {
|
|
@@ -197,7 +200,7 @@ var SpotlightContainerDecorator = (0, _hoc["default"])(defaultConfig, function (
|
|
|
197
200
|
spotlightId = props.spotlightId,
|
|
198
201
|
spotlightMuted = props.spotlightMuted,
|
|
199
202
|
spotlightRestrict = props.spotlightRestrict,
|
|
200
|
-
rest = _objectWithoutProperties(props,
|
|
203
|
+
rest = _objectWithoutProperties(props, _excluded2);
|
|
201
204
|
|
|
202
205
|
var spotlightContainer = (0, _useSpotlightContainer["default"])({
|
|
203
206
|
id: spotlightId,
|
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _react = require("@testing-library/react");
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
8
8
|
|
|
9
9
|
var _SpotlightContainerDecorator = _interopRequireDefault(require("../SpotlightContainerDecorator"));
|
|
10
10
|
|
|
11
|
+
var _pointer = require("../../src/pointer");
|
|
12
|
+
|
|
13
|
+
var _spotlight = _interopRequireDefault(require("../../src/spotlight"));
|
|
14
|
+
|
|
11
15
|
var _ElementPrototype = _interopRequireDefault(require("./Element.prototype.closest"));
|
|
12
16
|
|
|
13
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
18
|
|
|
15
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
20
|
|
|
17
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
21
|
+
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; }
|
|
18
22
|
|
|
19
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
23
|
+
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; }
|
|
20
24
|
|
|
21
25
|
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; }
|
|
22
26
|
|
|
27
|
+
var testId = 'test-spotlightContainerDecorator';
|
|
23
28
|
describe('SpotlightContainerDecorator', function () {
|
|
24
29
|
var hoverPosition = {
|
|
25
30
|
clientX: 0,
|
|
@@ -42,10 +47,15 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
42
47
|
});
|
|
43
48
|
test('should set itself as the active container on mouse enter', function () {
|
|
44
49
|
var Component = (0, _SpotlightContainerDecorator["default"])(Div);
|
|
45
|
-
|
|
50
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
51
|
+
"data-testid": testId,
|
|
46
52
|
spotlightId: "test-container"
|
|
47
53
|
}));
|
|
48
|
-
|
|
54
|
+
|
|
55
|
+
var component = _react.screen.getByTestId(testId);
|
|
56
|
+
|
|
57
|
+
_userEvent["default"].hover(component, hoverPosition);
|
|
58
|
+
|
|
49
59
|
var expected = 'test-container';
|
|
50
60
|
|
|
51
61
|
var actual = _spotlight["default"].getActiveContainer();
|
|
@@ -55,24 +65,25 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
55
65
|
test('should set active container to parent container on mouse leave', function () {
|
|
56
66
|
var Component = (0, _SpotlightContainerDecorator["default"])(Div);
|
|
57
67
|
var node = document.createElement('div');
|
|
58
|
-
|
|
68
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
59
69
|
spotlightId: "outer-container",
|
|
60
70
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
71
|
+
"data-testid": testId,
|
|
61
72
|
spotlightId: "inner-container"
|
|
62
73
|
})
|
|
63
74
|
}), {
|
|
64
75
|
attachTo: node
|
|
65
76
|
});
|
|
66
|
-
var selector = 'div[data-spotlight-id="inner-container"]';
|
|
67
|
-
var innerWrapper = subject.find(selector);
|
|
68
|
-
var innerNode = node.querySelector(selector); // set inner-container as active
|
|
69
77
|
|
|
70
|
-
|
|
78
|
+
var component = _react.screen.getByTestId(testId); // set inner-container as active
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
_userEvent["default"].hover(component, hoverPosition);
|
|
82
|
+
|
|
71
83
|
(0, _pointer.updatePointerPosition)(0, 1); // leave inner-container
|
|
72
84
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}));
|
|
85
|
+
_userEvent["default"].unhover(component, unhoverPosition);
|
|
86
|
+
|
|
76
87
|
var expected = 'outer-container';
|
|
77
88
|
|
|
78
89
|
var actual = _spotlight["default"].getActiveContainer();
|
|
@@ -82,9 +93,10 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
82
93
|
test('should not set active container on mouse leave if another container is active', function () {
|
|
83
94
|
var Component = (0, _SpotlightContainerDecorator["default"])(Div);
|
|
84
95
|
var node = document.createElement('div');
|
|
85
|
-
|
|
96
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
86
97
|
spotlightId: "outer-container",
|
|
87
98
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
99
|
+
"data-testid": testId,
|
|
88
100
|
spotlightId: "inner-container"
|
|
89
101
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
90
102
|
spotlightId: "self-only-container"
|
|
@@ -92,19 +104,19 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
92
104
|
}), {
|
|
93
105
|
attachTo: node
|
|
94
106
|
});
|
|
95
|
-
var selector = 'div[data-spotlight-id="inner-container"]';
|
|
96
|
-
var innerWrapper = subject.find(selector);
|
|
97
|
-
var innerNode = node.querySelector(selector); // set inner-container as active
|
|
98
107
|
|
|
99
|
-
|
|
108
|
+
var component = _react.screen.getByTestId(testId); // set inner-container as active
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
_userEvent["default"].hover(component, hoverPosition);
|
|
112
|
+
|
|
100
113
|
(0, _pointer.updatePointerPosition)(0, 1); // set another container to be active
|
|
101
114
|
|
|
102
115
|
_spotlight["default"].setActiveContainer('self-only-container'); // leave inner-container
|
|
103
116
|
|
|
104
117
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}));
|
|
118
|
+
_userEvent["default"].unhover(component, unhoverPosition);
|
|
119
|
+
|
|
108
120
|
var expected = 'self-only-container';
|
|
109
121
|
|
|
110
122
|
var actual = _spotlight["default"].getActiveContainer();
|
|
@@ -119,13 +131,12 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
119
131
|
focus = onFocusCapture;
|
|
120
132
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
|
|
121
133
|
});
|
|
122
|
-
(0,
|
|
134
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
123
135
|
onFocusCapture: spy
|
|
124
136
|
}));
|
|
125
137
|
focus({});
|
|
126
138
|
var expected = 1;
|
|
127
|
-
|
|
128
|
-
expect(actual).toBe(expected);
|
|
139
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
129
140
|
});
|
|
130
141
|
test('should suppress onFocusCapture events when spotlightDisabled', function () {
|
|
131
142
|
var spy = jest.fn();
|
|
@@ -135,7 +146,7 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
135
146
|
focus = onFocusCapture;
|
|
136
147
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
|
|
137
148
|
});
|
|
138
|
-
(0,
|
|
149
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
139
150
|
onFocusCapture: spy,
|
|
140
151
|
spotlightDisabled: true
|
|
141
152
|
})); // building out the api called on the event object + target
|
|
@@ -150,9 +161,7 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
150
161
|
}
|
|
151
162
|
}
|
|
152
163
|
});
|
|
153
|
-
|
|
154
|
-
var actual = spy.mock.calls.length;
|
|
155
|
-
expect(actual).toBe(expected);
|
|
164
|
+
expect(spy).not.toHaveBeenCalled();
|
|
156
165
|
});
|
|
157
166
|
test('should forward onBlurCapture events', function () {
|
|
158
167
|
var spy = jest.fn();
|
|
@@ -164,7 +173,7 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
164
173
|
_blur = onBlurCapture;
|
|
165
174
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
|
|
166
175
|
});
|
|
167
|
-
(0,
|
|
176
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
168
177
|
onBlurCapture: spy,
|
|
169
178
|
spotlightDisabled: true
|
|
170
179
|
})); // building out the api called on the event object + target
|
|
@@ -181,15 +190,14 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
181
190
|
});
|
|
182
191
|
|
|
183
192
|
var expected = 1;
|
|
184
|
-
|
|
185
|
-
expect(actual).toBe(expected);
|
|
193
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
186
194
|
});
|
|
187
195
|
test('should suppress onBlurCapture events when focus was suppressed', function () {
|
|
188
196
|
var spy = jest.fn();
|
|
189
|
-
var focus;
|
|
190
197
|
|
|
191
198
|
var _blur2;
|
|
192
199
|
|
|
200
|
+
var focus;
|
|
193
201
|
var Component = (0, _SpotlightContainerDecorator["default"])(function (_ref4) {
|
|
194
202
|
var onBlurCapture = _ref4.onBlurCapture,
|
|
195
203
|
onFocusCapture = _ref4.onFocusCapture;
|
|
@@ -197,7 +205,7 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
197
205
|
focus = onFocusCapture;
|
|
198
206
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
|
|
199
207
|
});
|
|
200
|
-
(0,
|
|
208
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
201
209
|
onBlurCapture: spy,
|
|
202
210
|
spotlightDisabled: true
|
|
203
211
|
})); // building out the api called on the event object + target
|
|
@@ -216,8 +224,6 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
216
224
|
}
|
|
217
225
|
}
|
|
218
226
|
});
|
|
219
|
-
|
|
220
|
-
var actual = spy.mock.calls.length;
|
|
221
|
-
expect(actual).toBe(expected);
|
|
227
|
+
expect(spy).not.toHaveBeenCalled();
|
|
222
228
|
});
|
|
223
229
|
});
|