@enact/spotlight 4.7.10 → 4.9.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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
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.9.0-alpha.1] - 2024-04-09
6
+
7
+ ### Fixed
8
+
9
+ - `spotlight` navigation from the focused element clipped by an overflow container
10
+
5
11
  ## [4.7.10] - 2024-03-05
6
12
 
7
13
  ### Fixed
@@ -36,7 +36,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Objec
36
36
  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); }; }
37
37
  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); }
38
38
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
39
- 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; } }
39
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
40
40
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
41
41
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
42
42
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -46,7 +46,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Objec
46
46
  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); }; }
47
47
  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); }
48
48
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
49
- 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
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
50
50
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /**
51
51
  * Exports the {@link spotlight/SpotlightRootDecorator.SpotlightRootDecorator}
52
52
  * higher-order component.
@@ -3,6 +3,7 @@
3
3
  require("@testing-library/jest-dom");
4
4
  var _react = require("@testing-library/react");
5
5
  var _SpotlightRootDecorator = require("../SpotlightRootDecorator");
6
+ var _container = require("../../src/container");
6
7
  var _jsxRuntime = require("react/jsx-runtime");
7
8
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
9
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -37,4 +38,12 @@ describe('SpotlightRootDecorator', function () {
37
38
  var actual = (0, _SpotlightRootDecorator.getInputType)();
38
39
  expect(actual).toBe(expected);
39
40
  });
41
+ test('should set spotlightRootDecorator container enterTo config to `null` by default', function () {
42
+ var App = (0, _SpotlightRootDecorator.SpotlightRootDecorator)(AppBase);
43
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(App, {}));
44
+ var containerConfig = (0, _container.getContainerConfig)('spotlightRootDecorator');
45
+ var expected = null;
46
+ var actual = containerConfig.enterTo;
47
+ expect(actual).toBe(expected);
48
+ });
40
49
  });
@@ -45,7 +45,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Objec
45
45
  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); }; }
46
46
  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
47
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
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; } }
48
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
49
49
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
50
50
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
51
51
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -22,7 +22,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Objec
22
22
  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); }; }
23
23
  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); }
24
24
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25
- 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; } }
25
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
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(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
28
28
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/spotlight",
3
- "version": "4.7.10",
3
+ "version": "4.9.0-alpha.1",
4
4
  "description": "A focus management library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,6 +11,7 @@
11
11
  "main": "src/spotlight.js",
12
12
  "scripts": {
13
13
  "clean": "enact clean",
14
+ "interlink": "npm link ../core",
14
15
  "lint": "enact lint --strict",
15
16
  "test": "enact test",
16
17
  "test-json": "enact test --json",
@@ -24,8 +25,8 @@
24
25
  }
25
26
  },
26
27
  "dependencies": {
27
- "@enact/core": "^4.7.10",
28
- "classnames": "^2.3.2",
28
+ "@enact/core": "^4.9.0-alpha.1",
29
+ "classnames": "^2.5.1",
29
30
  "prop-types": "^15.8.1",
30
31
  "ramda": "^0.29.1",
31
32
  "react": "^18.2.0",
package/src/container.js CHANGED
@@ -85,8 +85,8 @@ var GlobalConfig = {
85
85
  continue5WayHold: false,
86
86
  defaultElement: '',
87
87
  // <extSelector> except "@" syntax.
88
- enterTo: '',
89
- // '', 'last-focused', 'default-element'
88
+ enterTo: null,
89
+ // null, 'last-focused', 'default-element'
90
90
  isStandardFocusableMode: false,
91
91
  // @private - set to true to focus standard focusable element
92
92
  lastFocusedElement: null,
package/src/spotlight.js CHANGED
@@ -442,10 +442,10 @@ var Spotlight = exports.Spotlight = function () {
442
442
  window.addEventListener('keyup', onKeyUp);
443
443
  window.addEventListener('mouseover', onMouseOver);
444
444
  window.addEventListener('mousemove', onMouseMove);
445
- if (_platform["default"].touch) {
445
+ if (_platform["default"].touchEvent) {
446
446
  window.addEventListener('touchend', onTouchEnd);
447
447
  }
448
- if (_platform["default"].webos) {
448
+ if (_platform["default"].type === 'webos') {
449
449
  window.top.document.addEventListener('webOSMouse', handleWebOSMouseEvent);
450
450
  window.top.document.addEventListener('keyboardStateChange', handleKeyboardStateChangeEvent);
451
451
  }
@@ -475,10 +475,10 @@ var Spotlight = exports.Spotlight = function () {
475
475
  window.removeEventListener('keyup', onKeyUp);
476
476
  window.removeEventListener('mouseover', onMouseOver);
477
477
  window.removeEventListener('mousemove', onMouseMove);
478
- if (_platform["default"].touch) {
478
+ if (_platform["default"].touchEvent) {
479
479
  window.removeEventListener('touchend', onTouchEnd);
480
480
  }
481
- if (_platform["default"].webos) {
481
+ if (_platform["default"].type === 'webos') {
482
482
  window.top.document.removeEventListener('webOSMouse', handleWebOSMouseEvent);
483
483
  window.top.document.removeEventListener('keyboardStateChange', handleKeyboardStateChangeEvent);
484
484
  }
package/src/target.js CHANGED
@@ -297,13 +297,14 @@ function getTargetInContainerByDirectionFromElement(direction, containerId, elem
297
297
  }
298
298
  function getTargetByDirectionFromElement(direction, element) {
299
299
  var _getContainerConfig;
300
+ var getIntersectRectOfElem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
300
301
  var extSelector = element.getAttribute('data-spot-' + direction);
301
302
  if (typeof extSelector === 'string') {
302
303
  return getTargetBySelector(extSelector);
303
304
  }
304
305
  var elementContainerId = (0, _container.getContainersForNode)(element).pop();
305
306
  var next = (0, _container.getNavigableContainersForNode)(element).reduceRight(function (result, containerId, index, elementContainerIds) {
306
- result = result || getTargetInContainerByDirectionFromElement(direction, containerId, element, (0, _utils.getRect)(element), elementContainerIds);
307
+ result = result || getTargetInContainerByDirectionFromElement(direction, containerId, element, getIntersectRectOfElem ? (0, _utils.getIntersectionRect)((0, _container.getContainerNode)(elementContainerId), element) : (0, _utils.getRect)(element), elementContainerIds);
307
308
  if (!result) {
308
309
  result = getLeaveForTarget(containerId, direction);
309
310
 
@@ -316,26 +317,18 @@ function getTargetByDirectionFromElement(direction, element) {
316
317
  }
317
318
  return result;
318
319
  }, null);
319
- if (next === element && elementContainerId !== _container.rootContainerId && (_getContainerConfig = (0, _container.getContainerConfig)(elementContainerId)) !== null && _getContainerConfig !== void 0 && _getContainerConfig.overflow) {
320
- next = (0, _container.getNavigableContainersForNode)(element).reduceRight(function (result, containerId, index, elementContainerIds) {
321
- result = result || getTargetInContainerByDirectionFromElement(direction, containerId, element, (0, _utils.getIntersectionRect)((0, _container.getContainerNode)(elementContainerId), element), elementContainerIds);
322
- if (!result) {
323
- result = getLeaveForTarget(containerId, direction);
324
320
 
325
- // To support a `leaveFor` configuration with navigation disallowed in the current
326
- // `direction`, we return the current element to prevent further searches for a
327
- // target in this reduction.
328
- if (result === false) {
329
- result = element;
330
- }
331
- }
332
- return result;
333
- }, null);
334
- }
335
-
336
- // if the reduce above returns the original element, it means it hit a `leaveFor` config that
321
+ // If the reduce above returns the original element,
322
+ // check if the element is clipped by an overflow container. If true, find the target by direction with the intersection rect of the element.
323
+ // If the reduce above returns the original element again, it means it hit a `leaveFor` config that
337
324
  // prevents navigation so we enforce that here by returning null.
338
- return next !== element ? next : null;
325
+ if (next !== element) {
326
+ return next;
327
+ } else if (elementContainerId !== _container.rootContainerId && (_getContainerConfig = (0, _container.getContainerConfig)(elementContainerId)) !== null && _getContainerConfig !== void 0 && _getContainerConfig.overflow && !getIntersectRectOfElem) {
328
+ return getTargetByDirectionFromElement(direction, element, true);
329
+ } else {
330
+ return null;
331
+ }
339
332
  }
340
333
  function getTargetByDirectionFromPosition(direction, position, containerId) {
341
334
  var pointerRect = (0, _utils.getPointRect)(position);
@@ -2,6 +2,17 @@
2
2
 
3
3
  var _inputType = require("../inputType");
4
4
  describe('inputType', function () {
5
+ test('should have a default input type as \'key\'', function () {
6
+ var expected = 'key';
7
+ var actual = (0, _inputType.getInputType)();
8
+ expect(actual).toBe(expected);
9
+ });
10
+ test('should ignore input type in internal variable when invalid type is set', function () {
11
+ (0, _inputType.setInputType)('none');
12
+ var expected = 'key';
13
+ var actual = (0, _inputType.getInputType)();
14
+ expect(actual).toBe(expected);
15
+ });
5
16
  test('should set input type properly in internal variable', function () {
6
17
  (0, _inputType.setInputType)('touch');
7
18
  var expected = 'touch';