@enact/spotlight 4.5.0-alpha.1 → 4.5.0-rc.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/CHANGELOG.md +16 -0
- package/SpotlightContainerDecorator/SpotlightContainerDecorator.js +2 -2
- package/SpotlightRootDecorator/SpotlightRootDecorator.js +2 -2
- package/Spottable/Spottable.js +2 -2
- package/Spottable/tests/useSpot-specs.js +2 -2
- package/package.json +2 -2
- package/src/container.js +10 -7
- package/src/spotlight.js +17 -2
- package/src/tests/spotlight-specs.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
The following is a curated list of changes in the Enact spotlight module, newest changes on the top.
|
|
4
4
|
|
|
5
|
+
## [4.5.0-rc.1] - 2022-06-23
|
|
6
|
+
|
|
7
|
+
No significant changes.
|
|
8
|
+
|
|
9
|
+
## [4.5.0-beta.1] - 2022-05-31
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `spotlight` an optional `containerOption.toOuterContainer` parameter to `focus` function to search target recursively to outer container
|
|
14
|
+
|
|
15
|
+
## [4.5.0-alpha.2] - 2022-05-09
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- `spotlight` to not focus on an invisible element
|
|
20
|
+
|
|
5
21
|
## [4.5.0-alpha.1] - 2022-04-15
|
|
6
22
|
|
|
7
23
|
No significant changes.
|
|
@@ -42,7 +42,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
42
42
|
|
|
43
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); }
|
|
44
44
|
|
|
45
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf
|
|
45
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
46
46
|
|
|
47
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); }; }
|
|
48
48
|
|
|
@@ -52,7 +52,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
|
|
|
52
52
|
|
|
53
53
|
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; } }
|
|
54
54
|
|
|
55
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
55
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
56
56
|
|
|
57
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; }
|
|
58
58
|
|
|
@@ -37,7 +37,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
37
37
|
|
|
38
38
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
39
39
|
|
|
40
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf
|
|
40
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
41
41
|
|
|
42
42
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
43
43
|
|
|
@@ -47,7 +47,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
|
|
|
47
47
|
|
|
48
48
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
49
49
|
|
|
50
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
50
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
51
51
|
|
|
52
52
|
var input = {
|
|
53
53
|
activated: false,
|
package/Spottable/Spottable.js
CHANGED
|
@@ -53,7 +53,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
53
53
|
|
|
54
54
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
55
55
|
|
|
56
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf
|
|
56
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
57
57
|
|
|
58
58
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
59
59
|
|
|
@@ -63,7 +63,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
|
|
|
63
63
|
|
|
64
64
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
65
65
|
|
|
66
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
66
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
67
67
|
|
|
68
68
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
69
69
|
|
|
@@ -36,7 +36,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
36
36
|
|
|
37
37
|
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); }
|
|
38
38
|
|
|
39
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf
|
|
39
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
40
40
|
|
|
41
41
|
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); }; }
|
|
42
42
|
|
|
@@ -46,7 +46,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
|
|
|
46
46
|
|
|
47
47
|
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; } }
|
|
48
48
|
|
|
49
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
49
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
50
50
|
|
|
51
51
|
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; }
|
|
52
52
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enact/spotlight",
|
|
3
|
-
"version": "4.5.0-
|
|
3
|
+
"version": "4.5.0-rc.1",
|
|
4
4
|
"description": "A focus management library",
|
|
5
5
|
"main": "src/spotlight.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@enact/core": "^4.5.0-
|
|
21
|
+
"@enact/core": "^4.5.0-rc.1",
|
|
22
22
|
"classnames": "^2.3.1",
|
|
23
23
|
"prop-types": "^15.8.1",
|
|
24
24
|
"ramda": "^0.28.0",
|
package/src/container.js
CHANGED
|
@@ -34,6 +34,8 @@ var _and = _interopRequireDefault(require("ramda/src/and"));
|
|
|
34
34
|
|
|
35
35
|
var _concat = _interopRequireDefault(require("ramda/src/concat"));
|
|
36
36
|
|
|
37
|
+
var _snapshot = require("@enact/core/snapshot");
|
|
38
|
+
|
|
37
39
|
var _util = require("@enact/core/util");
|
|
38
40
|
|
|
39
41
|
var _intersection = _interopRequireDefault(require("ramda/src/intersection"));
|
|
@@ -147,18 +149,14 @@ var GlobalConfig = {
|
|
|
147
149
|
*/
|
|
148
150
|
|
|
149
151
|
var querySelector = function querySelector(node, includeSelector, excludeSelector) {
|
|
150
|
-
var include =
|
|
152
|
+
var include = new Set(node.querySelectorAll(includeSelector));
|
|
151
153
|
var exclude = node.querySelectorAll(excludeSelector);
|
|
152
154
|
|
|
153
155
|
for (var i = 0; i < exclude.length; i++) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (index >= 0) {
|
|
157
|
-
include.splice(index, 1);
|
|
158
|
-
}
|
|
156
|
+
include["delete"](exclude[i]);
|
|
159
157
|
}
|
|
160
158
|
|
|
161
|
-
return include;
|
|
159
|
+
return Array.from(include);
|
|
162
160
|
};
|
|
163
161
|
/**
|
|
164
162
|
* Determines if `node` is a spotlight container
|
|
@@ -342,8 +340,13 @@ var getContainerNode = function getContainerNode(containerId) {
|
|
|
342
340
|
exports.getContainerNode = getContainerNode;
|
|
343
341
|
|
|
344
342
|
var navigableFilter = function navigableFilter(node, containerId) {
|
|
343
|
+
var nodeStyle = node && (0, _snapshot.isWindowReady)() && window.getComputedStyle(node);
|
|
345
344
|
var config = getContainerConfig(containerId);
|
|
346
345
|
|
|
346
|
+
if (!nodeStyle || nodeStyle.display === 'none' || nodeStyle.visibility === 'hidden') {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
|
|
347
350
|
if (config && typeof config.navigableFilter === 'function') {
|
|
348
351
|
if (config.navigableFilter(node, containerId) === false) {
|
|
349
352
|
return false;
|
package/src/spotlight.js
CHANGED
|
@@ -691,8 +691,12 @@ var Spotlight = function () {
|
|
|
691
691
|
* @param {String|Node} [elem] The spotlight ID or selector for either a spottable
|
|
692
692
|
* component or a spotlight container, or spottable node. If not supplied, the default
|
|
693
693
|
* container will be focused.
|
|
694
|
-
* @param {Object} [containerOption]
|
|
695
|
-
* It
|
|
694
|
+
* @param {Object} [containerOption] The object including `enterTo` and `toOuterContainer`.
|
|
695
|
+
* It works when the first parameter `elem` is either a spotlight container ID or a spotlight container node.
|
|
696
|
+
* @param {('last-focused'|'default-element'|'topmost')} [containerOption.enterTo] Specifies preferred
|
|
697
|
+
* `enterTo` configuration.
|
|
698
|
+
* @param {Boolean} [containerOption.toOuterContainer] If the proper target is not found, search one
|
|
699
|
+
* recursively to outer container.
|
|
696
700
|
* @returns {Boolean} `true` if focus successful, `false` if not.
|
|
697
701
|
* @public
|
|
698
702
|
*/
|
|
@@ -700,6 +704,7 @@ var Spotlight = function () {
|
|
|
700
704
|
var containerOption = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
701
705
|
var target = elem;
|
|
702
706
|
var wasContainerId = false;
|
|
707
|
+
var currentContainerNode = null;
|
|
703
708
|
|
|
704
709
|
if (!elem) {
|
|
705
710
|
target = (0, _target.getTargetByContainer)();
|
|
@@ -707,6 +712,7 @@ var Spotlight = function () {
|
|
|
707
712
|
if ((0, _container.getContainerConfig)(elem)) {
|
|
708
713
|
target = (0, _target.getTargetByContainer)(elem, containerOption.enterTo);
|
|
709
714
|
wasContainerId = true;
|
|
715
|
+
currentContainerNode = (0, _container.getContainerNode)(elem);
|
|
710
716
|
} else if (/^[\w\d-]+$/.test(elem)) {
|
|
711
717
|
// support component IDs consisting of alphanumeric, dash, or underscore
|
|
712
718
|
target = (0, _target.getTargetBySelector)("[data-spotlight-id=".concat(elem, "]"));
|
|
@@ -715,6 +721,7 @@ var Spotlight = function () {
|
|
|
715
721
|
}
|
|
716
722
|
} else if ((0, _container.isContainer)(elem)) {
|
|
717
723
|
target = (0, _target.getTargetByContainer)((0, _container.getContainerId)(elem), containerOption.enterTo);
|
|
724
|
+
currentContainerNode = elem;
|
|
718
725
|
}
|
|
719
726
|
|
|
720
727
|
var nextContainerIds = (0, _container.getContainersForNode)(target);
|
|
@@ -734,6 +741,14 @@ var Spotlight = function () {
|
|
|
734
741
|
(0, _container.setLastContainer)(elem);
|
|
735
742
|
}
|
|
736
743
|
|
|
744
|
+
if (containerOption.toOuterContainer && currentContainerNode) {
|
|
745
|
+
var outerContainer = (0, _container.getContainersForNode)(currentContainerNode.parentElement).pop();
|
|
746
|
+
|
|
747
|
+
if (outerContainer) {
|
|
748
|
+
return this.focus(outerContainer, containerOption);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
737
752
|
return false;
|
|
738
753
|
},
|
|
739
754
|
// move(<direction>)
|
|
@@ -99,7 +99,7 @@ describe('Spotlight', function () {
|
|
|
99
99
|
|
|
100
100
|
expect(fn).toBeCalled();
|
|
101
101
|
}));
|
|
102
|
-
test('should focus container by
|
|
102
|
+
test('should focus container by selector', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
103
103
|
(0, _container4.configureContainer)('first-container');
|
|
104
104
|
var n = root.querySelector('[data-spotlight-id="first-container"]');
|
|
105
105
|
var fn = mockFocus(n.querySelector('.spottable'));
|