@enact/spotlight 4.5.0-alpha.2 → 4.5.0-rc.2

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 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.2] - 2022-07-06
6
+
7
+ ### Fixed
8
+
9
+ - `spotlight` to not leave the restrict container after returning from another app
10
+
11
+ ## [4.5.0-rc.1] - 2022-06-23
12
+
13
+ No significant changes.
14
+
15
+ ## [4.5.0-beta.1] - 2022-05-31
16
+
17
+ ### Added
18
+
19
+ - `spotlight` an optional `containerOption.toOuterContainer` parameter to `focus` function to search target recursively to outer container
20
+
5
21
  ## [4.5.0-alpha.2] - 2022-05-09
6
22
 
7
23
  ### Changed
@@ -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 || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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 || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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,
@@ -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 || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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 || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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
 
@@ -16,8 +16,6 @@ var _useClass = _interopRequireDefault(require("@enact/core/useClass"));
16
16
 
17
17
  var _react = require("react");
18
18
 
19
- var _reactDom = _interopRequireDefault(require("react-dom"));
20
-
21
19
  var _SpottableCore = require("./SpottableCore");
22
20
 
23
21
  var _excluded = ["spotRef", "emulateMouse", "selectionKeys", "spotlightDisabled"];
@@ -115,8 +113,7 @@ var useSpottable = function useSpottable() {
115
113
  spotlightDisabled: spotlightDisabled
116
114
  }, props), context.current);
117
115
  (0, _react.useLayoutEffect)(function () {
118
- // eslint-disable-next-line react/no-find-dom-node
119
- hook.load(_reactDom["default"].findDOMNode(spotRef || null));
116
+ hook.load(spotRef || null);
120
117
  return function () {
121
118
  hook.unload();
122
119
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/spotlight",
3
- "version": "4.5.0-alpha.2",
3
+ "version": "4.5.0-rc.2",
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-alpha.2",
21
+ "@enact/core": "^4.5.0-rc.2",
22
22
  "classnames": "^2.3.1",
23
23
  "prop-types": "^15.8.1",
24
24
  "ramda": "^0.28.0",
package/src/container.js CHANGED
@@ -1063,11 +1063,15 @@ function containsContainer(outerContainerId, innerContainerId) {
1063
1063
 
1064
1064
 
1065
1065
  function mayActivateContainer(containerId) {
1066
- var currentContainerId = getLastContainer(); // If the current container is restricted to 'self-only' and if the next container to be
1067
- // activated is not inside the currently activated container, the next container should not be
1068
- // activated.
1066
+ var currentContainerId = getLastContainer(); // If the current container or its outer containers are restricted to 'self-only' and
1067
+ // if the next container to be activated is not inside the restrict container,
1068
+ // the next container should not be activated.
1069
1069
 
1070
- return !isRestrictedContainer(currentContainerId) || containsContainer(currentContainerId, containerId);
1070
+ var currentContainerNode = getContainerNode(currentContainerId);
1071
+ var restrictContainer = getContainersForNode(currentContainerNode).reduceRight(function (result, outerContainerId) {
1072
+ return result || (isRestrictedContainer(outerContainerId) ? outerContainerId : null);
1073
+ }, null);
1074
+ return !restrictContainer || containsContainer(restrictContainer, containerId);
1071
1075
  }
1072
1076
 
1073
1077
  function getDefaultContainer() {
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] An optional object containing preferred `enterTo`.
695
- * It will be passed to the `getTargetByContainer` when `elem` is a container.
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 node', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
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'));