@enact/spotlight 4.7.8 → 4.7.10
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.js +4 -6
- package/CHANGELOG.md +22 -0
- package/Pause/Pause.js +4 -6
- package/Pause/tests/Pause-specs.js +2 -2
- package/README.md +1 -1
- package/SpotlightContainerDecorator/SpotlightContainer.js +6 -8
- package/SpotlightContainerDecorator/SpotlightContainerDecorator.js +9 -12
- package/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +4 -4
- package/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +4 -4
- package/SpotlightContainerDecorator/useSpotlightContainer.js +2 -2
- package/SpotlightRootDecorator/SpotlightRootDecorator.js +17 -19
- package/SpotlightRootDecorator/tests/SpotlightRootDecorator-specs.js +4 -4
- package/Spottable/Spottable.js +8 -10
- package/Spottable/SpottableCore.js +5 -8
- package/Spottable/tests/Spottable-specs.js +4 -4
- package/Spottable/tests/useSpot-specs.js +6 -6
- package/Spottable/useSpottable.js +6 -8
- package/package.json +3 -3
- package/src/container.js +46 -41
- package/src/inputType.js +6 -11
- package/src/navigate.js +1 -2
- package/src/pointer.js +8 -15
- package/src/spotlight.js +3 -6
- package/src/target.js +117 -100
- package/src/tests/container-specs.js +197 -178
- package/src/tests/spotlight-specs.js +5 -6
- package/src/tests/target-specs.js +14 -16
- package/src/tests/utils-specs.js +76 -0
- package/src/tests/utils.js +15 -26
- package/src/utils.js +32 -7
|
@@ -16,11 +16,11 @@ var _react = require("react");
|
|
|
16
16
|
var _SpottableCore = require("./SpottableCore");
|
|
17
17
|
var _excluded = ["spotRef", "emulateMouse", "selectionKeys", "spotlightDisabled"];
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
function ownKeys(
|
|
20
|
-
function _objectSpread(
|
|
19
|
+
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; }
|
|
20
|
+
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; }
|
|
21
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(
|
|
23
|
-
function _toPrimitive(
|
|
22
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
23
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
24
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; }
|
|
25
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; }
|
|
26
26
|
var ENTER_KEY = 13;
|
|
@@ -74,7 +74,7 @@ var REMOTE_OK_KEY = 16777221;
|
|
|
74
74
|
* @private
|
|
75
75
|
*/
|
|
76
76
|
|
|
77
|
-
var useSpottable = function useSpottable() {
|
|
77
|
+
var useSpottable = exports.useSpottable = function useSpottable() {
|
|
78
78
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
79
79
|
spotRef = _ref.spotRef,
|
|
80
80
|
emulateMouse = _ref.emulateMouse,
|
|
@@ -121,6 +121,4 @@ var useSpottable = function useSpottable() {
|
|
|
121
121
|
onMouseLeave: hook.handleLeave
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
|
-
exports
|
|
125
|
-
var _default = useSpottable;
|
|
126
|
-
exports["default"] = _default;
|
|
124
|
+
var _default = exports["default"] = useSpottable;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enact/spotlight",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.10",
|
|
4
4
|
"description": "A focus management library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@enact/core": "^4.7.
|
|
27
|
+
"@enact/core": "^4.7.10",
|
|
28
28
|
"classnames": "^2.3.2",
|
|
29
29
|
"prop-types": "^15.8.1",
|
|
30
|
-
"ramda": "^0.29.
|
|
30
|
+
"ramda": "^0.29.1",
|
|
31
31
|
"react": "^18.2.0",
|
|
32
32
|
"react-dom": "^18.2.0",
|
|
33
33
|
"warning": "^4.0.3"
|
package/src/container.js
CHANGED
|
@@ -16,6 +16,7 @@ exports.getDeepSpottableDescendants = void 0;
|
|
|
16
16
|
exports.getDefaultContainer = getDefaultContainer;
|
|
17
17
|
exports.getLastContainer = getLastContainer;
|
|
18
18
|
exports.getNavigableContainersForNode = getNavigableContainersForNode;
|
|
19
|
+
exports.getPositionTargetOnFocus = getPositionTargetOnFocus;
|
|
19
20
|
exports.isNavigable = exports.isContainer5WayHoldable = exports.isContainer = exports.getSpottableDescendants = void 0;
|
|
20
21
|
exports.isWithinOverflowContainer = isWithinOverflowContainer;
|
|
21
22
|
exports.mayActivateContainer = mayActivateContainer;
|
|
@@ -37,31 +38,29 @@ var _intersection = _interopRequireDefault(require("ramda/src/intersection"));
|
|
|
37
38
|
var _last = _interopRequireDefault(require("ramda/src/last"));
|
|
38
39
|
var _utils = require("./utils");
|
|
39
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
40
|
-
function ownKeys(
|
|
41
|
-
function _objectSpread(
|
|
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
|
+
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; }
|
|
42
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; }
|
|
43
|
-
function _toPropertyKey(
|
|
44
|
-
function _toPrimitive(
|
|
44
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
45
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
45
46
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
46
47
|
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."); }
|
|
47
48
|
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); }
|
|
48
49
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
49
50
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
50
51
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var containerAttribute = 'data-spotlight-id';
|
|
57
|
-
exports.containerAttribute = containerAttribute;
|
|
52
|
+
* Exports methods and members for creating and maintaining spotlight containers.
|
|
53
|
+
*
|
|
54
|
+
* @module spotlight/container
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
var containerAttribute = exports.containerAttribute = 'data-spotlight-id';
|
|
58
58
|
var containerConfigs = new Map();
|
|
59
59
|
var containerKey = 'spotlightId';
|
|
60
60
|
var disabledKey = 'spotlightContainerDisabled';
|
|
61
61
|
var containerPrefix = 'container-';
|
|
62
62
|
var containerSelector = '[data-spotlight-container]';
|
|
63
|
-
var rootContainerId = 'spotlightRootDecorator';
|
|
64
|
-
exports.rootContainerId = rootContainerId;
|
|
63
|
+
var rootContainerId = exports.rootContainerId = 'spotlightRootDecorator';
|
|
65
64
|
var reverseDirections = {
|
|
66
65
|
'left': 'right',
|
|
67
66
|
'up': 'down',
|
|
@@ -118,6 +117,8 @@ var GlobalConfig = {
|
|
|
118
117
|
overflow: false,
|
|
119
118
|
partition: false,
|
|
120
119
|
// use the container bounds for partitioning when leaving
|
|
120
|
+
positionTargetOnFocus: false,
|
|
121
|
+
// @private - use the container for the position target when its descendants is focused
|
|
121
122
|
rememberSource: false,
|
|
122
123
|
restrict: 'self-first',
|
|
123
124
|
// 'self-first', 'self-only', 'none'
|
|
@@ -197,7 +198,7 @@ var mapContainers = function mapContainers(node, fn) {
|
|
|
197
198
|
* @memberof spotlight/container
|
|
198
199
|
* @private
|
|
199
200
|
*/
|
|
200
|
-
var getContainerConfig = function getContainerConfig(id) {
|
|
201
|
+
var getContainerConfig = exports.getContainerConfig = function getContainerConfig(id) {
|
|
201
202
|
return containerConfigs.get(id);
|
|
202
203
|
};
|
|
203
204
|
|
|
@@ -210,8 +211,7 @@ var getContainerConfig = function getContainerConfig(id) {
|
|
|
210
211
|
* @memberof spotlight/container
|
|
211
212
|
* @private
|
|
212
213
|
*/
|
|
213
|
-
exports.
|
|
214
|
-
var isContainer = function isContainer(nodeOrId) {
|
|
214
|
+
var isContainer = exports.isContainer = function isContainer(nodeOrId) {
|
|
215
215
|
if (typeof nodeOrId === 'string') {
|
|
216
216
|
return containerConfigs.has(nodeOrId);
|
|
217
217
|
}
|
|
@@ -227,7 +227,6 @@ var isContainer = function isContainer(nodeOrId) {
|
|
|
227
227
|
* @memberof spotlight/container
|
|
228
228
|
* @private
|
|
229
229
|
*/
|
|
230
|
-
exports.isContainer = isContainer;
|
|
231
230
|
var isContainerEnabled = function isContainerEnabled(node) {
|
|
232
231
|
return mapContainers(node, function (container) {
|
|
233
232
|
return container.dataset[disabledKey] !== 'true';
|
|
@@ -243,7 +242,7 @@ var isContainerEnabled = function isContainerEnabled(node) {
|
|
|
243
242
|
* @memberof spotlight/container
|
|
244
243
|
* @private
|
|
245
244
|
*/
|
|
246
|
-
var getContainerId = function getContainerId(node) {
|
|
245
|
+
var getContainerId = exports.getContainerId = function getContainerId(node) {
|
|
247
246
|
return node.dataset[containerKey];
|
|
248
247
|
};
|
|
249
248
|
|
|
@@ -256,7 +255,6 @@ var getContainerId = function getContainerId(node) {
|
|
|
256
255
|
* @memberof spotlight/container
|
|
257
256
|
* @private
|
|
258
257
|
*/
|
|
259
|
-
exports.getContainerId = getContainerId;
|
|
260
258
|
var getContainerSelector = function getContainerSelector(node) {
|
|
261
259
|
if (isContainerNode(node)) {
|
|
262
260
|
return "[".concat(containerAttribute, "=\"").concat(getContainerId(node), "\"]");
|
|
@@ -289,7 +287,7 @@ var getSubContainerSelector = function getSubContainerSelector(node) {
|
|
|
289
287
|
* @memberof spotlight/container
|
|
290
288
|
* @private
|
|
291
289
|
*/
|
|
292
|
-
var getContainerNode = function getContainerNode(containerId) {
|
|
290
|
+
var getContainerNode = exports.getContainerNode = function getContainerNode(containerId) {
|
|
293
291
|
if (!containerId) {
|
|
294
292
|
return null;
|
|
295
293
|
} else if (containerId === rootContainerId) {
|
|
@@ -309,7 +307,6 @@ var getContainerNode = function getContainerNode(containerId) {
|
|
|
309
307
|
* @memberof spotlight/container
|
|
310
308
|
* @private
|
|
311
309
|
*/
|
|
312
|
-
exports.getContainerNode = getContainerNode;
|
|
313
310
|
var navigableFilter = function navigableFilter(node, containerId) {
|
|
314
311
|
var nodeStyle = node && (0, _snapshot.isWindowReady)() && window.getComputedStyle(node);
|
|
315
312
|
var config = getContainerConfig(containerId);
|
|
@@ -357,7 +354,7 @@ var getOwnedNodes = function getOwnedNodes(node, selector) {
|
|
|
357
354
|
* @memberof spotlight/container
|
|
358
355
|
* @public
|
|
359
356
|
*/
|
|
360
|
-
var getSpottableDescendants = function getSpottableDescendants(containerId) {
|
|
357
|
+
var getSpottableDescendants = exports.getSpottableDescendants = function getSpottableDescendants(containerId) {
|
|
361
358
|
var node = getContainerNode(containerId);
|
|
362
359
|
|
|
363
360
|
// if it's falsy or is a disabled container, return an empty set
|
|
@@ -390,8 +387,7 @@ var getSpottableDescendants = function getSpottableDescendants(containerId) {
|
|
|
390
387
|
* @memberof spotlight/container
|
|
391
388
|
* @private
|
|
392
389
|
*/
|
|
393
|
-
exports.
|
|
394
|
-
var getDeepSpottableDescendants = function getDeepSpottableDescendants(containerId, excludedContainers) {
|
|
390
|
+
var getDeepSpottableDescendants = exports.getDeepSpottableDescendants = function getDeepSpottableDescendants(containerId, excludedContainers) {
|
|
395
391
|
return getSpottableDescendants(containerId).map(function (n) {
|
|
396
392
|
if (isContainer(n)) {
|
|
397
393
|
var id = getContainerId(n);
|
|
@@ -414,8 +410,7 @@ var getDeepSpottableDescendants = function getDeepSpottableDescendants(container
|
|
|
414
410
|
* @memberof spotlight/container
|
|
415
411
|
* @private
|
|
416
412
|
*/
|
|
417
|
-
exports.
|
|
418
|
-
var isContainer5WayHoldable = function isContainer5WayHoldable(containerId) {
|
|
413
|
+
var isContainer5WayHoldable = exports.isContainer5WayHoldable = function isContainer5WayHoldable(containerId) {
|
|
419
414
|
var config = getContainerConfig(containerId);
|
|
420
415
|
return config && config.continue5WayHold || false;
|
|
421
416
|
};
|
|
@@ -430,7 +425,6 @@ var isContainer5WayHoldable = function isContainer5WayHoldable(containerId) {
|
|
|
430
425
|
* @memberof spotlight/container
|
|
431
426
|
* @private
|
|
432
427
|
*/
|
|
433
|
-
exports.isContainer5WayHoldable = isContainer5WayHoldable;
|
|
434
428
|
function getContainersForNode(node) {
|
|
435
429
|
var containers = mapContainers(node, getContainerId);
|
|
436
430
|
containers.unshift(rootContainerId);
|
|
@@ -525,7 +519,7 @@ var mergeConfig = function mergeConfig(current, updated) {
|
|
|
525
519
|
* @memberof spotlight/container
|
|
526
520
|
* @public
|
|
527
521
|
*/
|
|
528
|
-
var configureContainer = function configureContainer() {
|
|
522
|
+
var configureContainer = exports.configureContainer = function configureContainer() {
|
|
529
523
|
var containerId, config;
|
|
530
524
|
if (typeof (arguments.length <= 0 ? undefined : arguments[0]) === 'object') {
|
|
531
525
|
config = arguments.length <= 0 ? undefined : arguments[0];
|
|
@@ -557,8 +551,7 @@ var configureContainer = function configureContainer() {
|
|
|
557
551
|
* @memberof spotlight/container
|
|
558
552
|
* @public
|
|
559
553
|
*/
|
|
560
|
-
exports.
|
|
561
|
-
var addContainer = function addContainer() {
|
|
554
|
+
var addContainer = exports.addContainer = function addContainer() {
|
|
562
555
|
var containerId = configureContainer.apply(void 0, arguments);
|
|
563
556
|
var config = getContainerConfig(containerId);
|
|
564
557
|
config.active = true;
|
|
@@ -574,8 +567,7 @@ var addContainer = function addContainer() {
|
|
|
574
567
|
* @memberof spotlight/container
|
|
575
568
|
* @public
|
|
576
569
|
*/
|
|
577
|
-
exports.
|
|
578
|
-
var removeContainer = function removeContainer(containerId) {
|
|
570
|
+
var removeContainer = exports.removeContainer = function removeContainer(containerId) {
|
|
579
571
|
containerConfigs["delete"](containerId);
|
|
580
572
|
};
|
|
581
573
|
|
|
@@ -586,8 +578,7 @@ var removeContainer = function removeContainer(containerId) {
|
|
|
586
578
|
* @memberof spotlight/container
|
|
587
579
|
* @public
|
|
588
580
|
*/
|
|
589
|
-
exports.
|
|
590
|
-
var removeAllContainers = function removeAllContainers() {
|
|
581
|
+
var removeAllContainers = exports.removeAllContainers = function removeAllContainers() {
|
|
591
582
|
containerConfigs.clear();
|
|
592
583
|
};
|
|
593
584
|
|
|
@@ -600,8 +591,7 @@ var removeAllContainers = function removeAllContainers() {
|
|
|
600
591
|
* @memberof spotlight/container
|
|
601
592
|
* @public
|
|
602
593
|
*/
|
|
603
|
-
exports.
|
|
604
|
-
var configureDefaults = function configureDefaults(config) {
|
|
594
|
+
var configureDefaults = exports.configureDefaults = function configureDefaults(config) {
|
|
605
595
|
GlobalConfig = mergeConfig(GlobalConfig, config);
|
|
606
596
|
};
|
|
607
597
|
|
|
@@ -616,8 +606,7 @@ var configureDefaults = function configureDefaults(config) {
|
|
|
616
606
|
* @memberof spotlight/container
|
|
617
607
|
* @public
|
|
618
608
|
*/
|
|
619
|
-
exports.
|
|
620
|
-
var isNavigable = function isNavigable(node, containerId, verify) {
|
|
609
|
+
var isNavigable = exports.isNavigable = function isNavigable(node, containerId, verify) {
|
|
621
610
|
if (!node ||
|
|
622
611
|
// jsdom reports all nodes as having no size so we must skip this condition in our tests
|
|
623
612
|
process.env.NODE_ENV !== 'test' && node.offsetWidth <= 0 && node.offsetHeight <= 0) {
|
|
@@ -641,8 +630,7 @@ var isNavigable = function isNavigable(node, containerId, verify) {
|
|
|
641
630
|
* @memberof spotlight/container
|
|
642
631
|
* @private
|
|
643
632
|
*/
|
|
644
|
-
exports.
|
|
645
|
-
var getAllContainerIds = function getAllContainerIds() {
|
|
633
|
+
var getAllContainerIds = exports.getAllContainerIds = function getAllContainerIds() {
|
|
646
634
|
var ids = [];
|
|
647
635
|
var keys = containerConfigs.keys();
|
|
648
636
|
|
|
@@ -666,7 +654,6 @@ var getAllContainerIds = function getAllContainerIds() {
|
|
|
666
654
|
* @memberof spotlight/container
|
|
667
655
|
* @public
|
|
668
656
|
*/
|
|
669
|
-
exports.getAllContainerIds = getAllContainerIds;
|
|
670
657
|
function getContainerDefaultElement(containerId, preferredEnterTo) {
|
|
671
658
|
var config = getContainerConfig(containerId);
|
|
672
659
|
var defaultElementSelector = config && config.defaultElement;
|
|
@@ -1098,4 +1085,22 @@ function notifyEnterContainer(direction, previous, previousContainerIds, current
|
|
|
1098
1085
|
}
|
|
1099
1086
|
}
|
|
1100
1087
|
});
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* Returns the closest container that wrap the element and has positionTargetOnFocus configured
|
|
1092
|
+
*
|
|
1093
|
+
* @param {Node} spotItem Focused element
|
|
1094
|
+
* @param {String[]} containerIds Ids for containers that wrap the spotItem element
|
|
1095
|
+
* @private
|
|
1096
|
+
*/
|
|
1097
|
+
function getPositionTargetOnFocus(spotItem) {
|
|
1098
|
+
var containerIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getContainersForNode(spotItem);
|
|
1099
|
+
return containerIds.reduce(function (result, containerId) {
|
|
1100
|
+
var _getContainerConfig;
|
|
1101
|
+
if ((_getContainerConfig = getContainerConfig(containerId)) !== null && _getContainerConfig !== void 0 && _getContainerConfig.positionTargetOnFocus) {
|
|
1102
|
+
result = getContainerNode(containerId);
|
|
1103
|
+
}
|
|
1104
|
+
return result;
|
|
1105
|
+
}, spotItem);
|
|
1101
1106
|
}
|
package/src/inputType.js
CHANGED
|
@@ -20,17 +20,15 @@ var input = {
|
|
|
20
20
|
touch: false
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
var activateInputType = function activateInputType(activated) {
|
|
23
|
+
var activateInputType = exports.activateInputType = function activateInputType(activated) {
|
|
24
24
|
input.activated = activated;
|
|
25
25
|
};
|
|
26
|
-
exports.
|
|
27
|
-
var getInputType = function getInputType() {
|
|
26
|
+
var getInputType = exports.getInputType = function getInputType() {
|
|
28
27
|
return Object.keys(input.types).find(function (type) {
|
|
29
28
|
return input.types[type];
|
|
30
29
|
});
|
|
31
30
|
};
|
|
32
|
-
exports.
|
|
33
|
-
var setInputType = function setInputType(inputType) {
|
|
31
|
+
var setInputType = exports.setInputType = function setInputType(inputType) {
|
|
34
32
|
if (Object.prototype.hasOwnProperty.call(input.types, inputType) && !input.types[inputType]) {
|
|
35
33
|
Object.keys(input.types).map(function (type) {
|
|
36
34
|
input.types[type] = false;
|
|
@@ -39,18 +37,15 @@ var setInputType = function setInputType(inputType) {
|
|
|
39
37
|
input.applied = false;
|
|
40
38
|
}
|
|
41
39
|
};
|
|
42
|
-
exports.
|
|
43
|
-
var applyInputTypeToNode = function applyInputTypeToNode(node) {
|
|
40
|
+
var applyInputTypeToNode = exports.applyInputTypeToNode = function applyInputTypeToNode(node) {
|
|
44
41
|
Object.keys(input.types).map(function (type) {
|
|
45
42
|
node.classList.toggle('spotlight-input-' + type, input.types[type]);
|
|
46
43
|
});
|
|
47
44
|
input.applied = true;
|
|
48
45
|
};
|
|
49
|
-
exports.
|
|
50
|
-
var getInputInfo = function getInputInfo() {
|
|
46
|
+
var getInputInfo = exports.getInputInfo = function getInputInfo() {
|
|
51
47
|
return {
|
|
52
48
|
activated: input.activated,
|
|
53
49
|
applied: input.applied
|
|
54
50
|
};
|
|
55
|
-
};
|
|
56
|
-
exports.getInputInfo = getInputInfo;
|
|
51
|
+
};
|
package/src/navigate.js
CHANGED
package/src/pointer.js
CHANGED
|
@@ -29,7 +29,7 @@ var _pointerMode = true;
|
|
|
29
29
|
* @memberof spotlight/pointer
|
|
30
30
|
* @private
|
|
31
31
|
*/
|
|
32
|
-
var setPointerMode = function setPointerMode(pointerMode) {
|
|
32
|
+
var setPointerMode = exports.setPointerMode = function setPointerMode(pointerMode) {
|
|
33
33
|
_pointerMode = pointerMode;
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -40,13 +40,11 @@ var setPointerMode = function setPointerMode(pointerMode) {
|
|
|
40
40
|
* @memberof spotlight/pointer
|
|
41
41
|
* @private
|
|
42
42
|
*/
|
|
43
|
-
exports.
|
|
44
|
-
var getPointerMode = function getPointerMode() {
|
|
43
|
+
var getPointerMode = exports.getPointerMode = function getPointerMode() {
|
|
45
44
|
return _pointerMode;
|
|
46
45
|
};
|
|
47
46
|
|
|
48
47
|
// Cached pointer position
|
|
49
|
-
exports.getPointerMode = getPointerMode;
|
|
50
48
|
var _pointerX = null;
|
|
51
49
|
var _pointerY = null;
|
|
52
50
|
|
|
@@ -60,7 +58,7 @@ var _pointerY = null;
|
|
|
60
58
|
* @memberof spotlight/pointer
|
|
61
59
|
* @private
|
|
62
60
|
*/
|
|
63
|
-
var hasPointerMoved = function hasPointerMoved(x, y) {
|
|
61
|
+
var hasPointerMoved = exports.hasPointerMoved = function hasPointerMoved(x, y) {
|
|
64
62
|
return x !== _pointerX || y !== _pointerY;
|
|
65
63
|
};
|
|
66
64
|
|
|
@@ -75,8 +73,7 @@ var hasPointerMoved = function hasPointerMoved(x, y) {
|
|
|
75
73
|
* @memberof spotlight/pointer
|
|
76
74
|
* @private
|
|
77
75
|
*/
|
|
78
|
-
exports.
|
|
79
|
-
var updatePointerPosition = function updatePointerPosition(x, y) {
|
|
76
|
+
var updatePointerPosition = exports.updatePointerPosition = function updatePointerPosition(x, y) {
|
|
80
77
|
// Chrome emits mousemove on scroll, but client coordinates do not change.
|
|
81
78
|
if (hasPointerMoved(x, y)) {
|
|
82
79
|
setPointerMode(true);
|
|
@@ -94,8 +91,7 @@ var updatePointerPosition = function updatePointerPosition(x, y) {
|
|
|
94
91
|
* @memberof spotlight/pointer
|
|
95
92
|
* @private
|
|
96
93
|
*/
|
|
97
|
-
exports.
|
|
98
|
-
var getLastPointerPosition = function getLastPointerPosition() {
|
|
94
|
+
var getLastPointerPosition = exports.getLastPointerPosition = function getLastPointerPosition() {
|
|
99
95
|
return {
|
|
100
96
|
x: _pointerX,
|
|
101
97
|
y: _pointerY
|
|
@@ -106,7 +102,6 @@ var getLastPointerPosition = function getLastPointerPosition() {
|
|
|
106
102
|
// following directional key event to fire, and to prevent momentary spotting of the last
|
|
107
103
|
// focused item - needs to be a value large enough to account for the potentially-trailing
|
|
108
104
|
// event, but not too large that another unrelated event can be fired inside the window
|
|
109
|
-
exports.getLastPointerPosition = getLastPointerPosition;
|
|
110
105
|
var hidePointerJob = new _util.Job(function (callback) {
|
|
111
106
|
setPointerMode(false);
|
|
112
107
|
if (callback) {
|
|
@@ -125,7 +120,7 @@ var hidePointerJob = new _util.Job(function (callback) {
|
|
|
125
120
|
* @memberof spotlight/pointer
|
|
126
121
|
* @private
|
|
127
122
|
*/
|
|
128
|
-
var notifyPointerMove = function notifyPointerMove(current, target, x, y) {
|
|
123
|
+
var notifyPointerMove = exports.notifyPointerMove = function notifyPointerMove(current, target, x, y) {
|
|
129
124
|
var priorPointerMode = getPointerMode();
|
|
130
125
|
if (updatePointerPosition(x, y)) {
|
|
131
126
|
// if we're entering pointer mode and the target element isn't within the currently
|
|
@@ -149,8 +144,7 @@ var notifyPointerMove = function notifyPointerMove(current, target, x, y) {
|
|
|
149
144
|
* @memberof spotlight/pointer
|
|
150
145
|
* @private
|
|
151
146
|
*/
|
|
152
|
-
exports.
|
|
153
|
-
var notifyKeyDown = function notifyKeyDown(keyCode, callback) {
|
|
147
|
+
var notifyKeyDown = exports.notifyKeyDown = function notifyKeyDown(keyCode, callback) {
|
|
154
148
|
var _window$webOSSystem;
|
|
155
149
|
var webOSSystem = (_window$webOSSystem = window.webOSSystem) !== null && _window$webOSSystem !== void 0 ? _window$webOSSystem : window.PalmSystem;
|
|
156
150
|
|
|
@@ -165,5 +159,4 @@ var notifyKeyDown = function notifyKeyDown(keyCode, callback) {
|
|
|
165
159
|
setPointerMode(false);
|
|
166
160
|
}
|
|
167
161
|
return false;
|
|
168
|
-
};
|
|
169
|
-
exports.notifyKeyDown = notifyKeyDown;
|
|
162
|
+
};
|
package/src/spotlight.js
CHANGED
|
@@ -52,10 +52,9 @@ var isUp = (0, _keymap.is)('up');
|
|
|
52
52
|
* @returns {String|false} - One of `'up'`, `'down'`, `'left'`, `'right'` or `false` if not a direction key
|
|
53
53
|
* @public
|
|
54
54
|
*/
|
|
55
|
-
var getDirection = function getDirection(keyCode) {
|
|
55
|
+
var getDirection = exports.getDirection = function getDirection(keyCode) {
|
|
56
56
|
return isDown(keyCode) && 'down' || isLeft(keyCode) && 'left' || isRight(keyCode) && 'right' || isUp(keyCode) && 'up';
|
|
57
57
|
};
|
|
58
|
-
exports.getDirection = getDirection;
|
|
59
58
|
var SpotlightAccelerator = new _Accelerator["default"]();
|
|
60
59
|
|
|
61
60
|
/**
|
|
@@ -78,7 +77,7 @@ var SpotlightAccelerator = new _Accelerator["default"]();
|
|
|
78
77
|
* @memberof spotlight
|
|
79
78
|
* @public
|
|
80
79
|
*/
|
|
81
|
-
var Spotlight = function () {
|
|
80
|
+
var Spotlight = exports.Spotlight = function () {
|
|
82
81
|
'use strict';
|
|
83
82
|
|
|
84
83
|
/*
|
|
@@ -808,6 +807,4 @@ var Spotlight = function () {
|
|
|
808
807
|
};
|
|
809
808
|
return exports;
|
|
810
809
|
}();
|
|
811
|
-
exports
|
|
812
|
-
var _default = Spotlight;
|
|
813
|
-
exports["default"] = _default;
|
|
810
|
+
var _default = exports["default"] = Spotlight;
|