@enact/spotlight 3.4.9-experimental-3 → 3.4.9-experimental-7
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/{build/Accelerator → Accelerator}/Accelerator.d.ts +0 -0
- package/Accelerator/Accelerator.js +149 -156
- package/CHANGELOG.md +22 -0
- package/{build/Pause → Pause}/Pause.d.ts +0 -0
- package/Pause/Pause.js +102 -80
- package/Pause/tests/Pause-specs.js +65 -97
- package/SpotlightContainerDecorator/SpotlightContainer.js +175 -140
- package/{build/SpotlightContainerDecorator → SpotlightContainerDecorator}/SpotlightContainerDecorator.d.ts +0 -0
- package/SpotlightContainerDecorator/SpotlightContainerDecorator.js +222 -176
- package/SpotlightContainerDecorator/tests/Element.prototype.closest.js +44 -40
- package/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +221 -210
- package/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +150 -243
- package/SpotlightContainerDecorator/useSpotlightContainer.js +47 -28
- package/{build/SpotlightRootDecorator → SpotlightRootDecorator}/SpotlightRootDecorator.d.ts +0 -0
- package/SpotlightRootDecorator/SpotlightRootDecorator.js +206 -111
- package/{build/Spottable → Spottable}/Spottable.d.ts +0 -0
- package/Spottable/Spottable.js +448 -410
- package/Spottable/tests/Spottable-specs.js +90 -117
- package/package.json +3 -2
- package/src/container.js +718 -653
- package/src/navigate.js +406 -491
- package/src/pointer.js +86 -78
- package/{build/src → src}/spotlight.d.ts +0 -0
- package/src/spotlight.js +846 -885
- package/src/target.js +448 -474
- package/src/tests/container-specs.js +643 -1251
- package/src/tests/navigate-specs.js +77 -134
- package/src/tests/pointer-specs.js +126 -182
- package/src/tests/spotlight-specs.js +103 -133
- package/src/tests/target-specs.js +597 -960
- package/src/tests/utils.js +89 -67
- package/src/utils.js +155 -158
- package/build/Accelerator/Accelerator.js +0 -162
- package/build/Accelerator/package.json +0 -3
- package/build/CHANGELOG.md +0 -838
- package/build/Pause/Pause.js +0 -164
- package/build/Pause/package.json +0 -3
- package/build/Pause/tests/Pause-specs.js +0 -65
- package/build/README.md +0 -61
- package/build/SpotlightContainerDecorator/SpotlightContainer.js +0 -176
- package/build/SpotlightContainerDecorator/SpotlightContainerDecorator.js +0 -282
- package/build/SpotlightContainerDecorator/package.json +0 -3
- package/build/SpotlightContainerDecorator/tests/Element.prototype.closest.js +0 -45
- package/build/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +0 -221
- package/build/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +0 -160
- package/build/SpotlightContainerDecorator/useSpotlightContainer.js +0 -133
- package/build/SpotlightRootDecorator/SpotlightRootDecorator.js +0 -189
- package/build/SpotlightRootDecorator/package.json +0 -3
- package/build/Spottable/Spottable.js +0 -491
- package/build/Spottable/package.json +0 -3
- package/build/Spottable/tests/Spottable-specs.js +0 -90
- package/build/package-lock.json +0 -229
- package/build/package.json +0 -28
- package/build/src/container.js +0 -1201
- package/build/src/navigate.js +0 -419
- package/build/src/pointer.js +0 -183
- package/build/src/spotlight.js +0 -896
- package/build/src/target.js +0 -507
- package/build/src/tests/container-specs.js +0 -653
- package/build/src/tests/navigate-specs.js +0 -87
- package/build/src/tests/pointer-specs.js +0 -130
- package/build/src/tests/spotlight-specs.js +0 -112
- package/build/src/tests/target-specs.js +0 -614
- package/build/src/tests/utils.js +0 -104
- package/build/src/utils.js +0 -180
- package/build/styles/debug.less +0 -97
- package/build/styles/mixins.less +0 -63
- package/docs/index.md +0 -364
package/build/Pause/Pause.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isPaused = isPaused;
|
|
7
|
-
exports.pause = pause;
|
|
8
|
-
exports.resume = _resume;
|
|
9
|
-
exports.Pause = exports["default"] = void 0;
|
|
10
|
-
|
|
11
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
-
|
|
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
|
-
|
|
15
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Provides a class which allows consumers to safely pause and resume spotlight without resuming
|
|
19
|
-
* another consumer's pause.
|
|
20
|
-
*
|
|
21
|
-
* When multiple components attempt to pause and resume spotlight at overlapping times using
|
|
22
|
-
* [Spotlight.pause()]{@link spotlight.Spotlight.pause} and
|
|
23
|
-
* [Spotlight.resume()]{@link spotlight.Spotlight.resume}, one component might resume spotlight when
|
|
24
|
-
* another expected it to still be paused.
|
|
25
|
-
*
|
|
26
|
-
* `Pause` helps to address this by setting a "soft lock" on the pause which informs other instances
|
|
27
|
-
* that the spotlight pause state is being controlled. When pause is locked, it can only be resumed
|
|
28
|
-
* by the instance that locked it. Subsequent calls to `pause` and `resume` on another instance of
|
|
29
|
-
* `Pause` have no effect.
|
|
30
|
-
*
|
|
31
|
-
* *Note:* The top-level [Spotlight.pause()]{@link spotlight.Spotlight.pause} and
|
|
32
|
-
* [Spotlight.resume()]{@link spotlight.Spotlight.resume} do not respect the pause locks and act as
|
|
33
|
-
* a user-space escape hatch.
|
|
34
|
-
*
|
|
35
|
-
* ```
|
|
36
|
-
* import Pause from '@enact/spotlight/Pause';
|
|
37
|
-
*
|
|
38
|
-
* const paused1 = new Pause('paused 1');
|
|
39
|
-
* const paused2 = new Pause('paused 2');
|
|
40
|
-
*
|
|
41
|
-
* // pauses spotlight
|
|
42
|
-
* paused1.pause();
|
|
43
|
-
*
|
|
44
|
-
* // has no effect because pause1 is in control
|
|
45
|
-
* paused2.pause();
|
|
46
|
-
*
|
|
47
|
-
* // has no effect because pause1 is in control
|
|
48
|
-
* paused2.resume();
|
|
49
|
-
*
|
|
50
|
-
* // resumes spotlight
|
|
51
|
-
* paused1.resume();
|
|
52
|
-
*
|
|
53
|
-
* ```
|
|
54
|
-
*
|
|
55
|
-
* @module spotlight/Pause
|
|
56
|
-
* @exports Pause
|
|
57
|
-
* @exports isPaused
|
|
58
|
-
* @exports pause
|
|
59
|
-
* @exports resume
|
|
60
|
-
*/
|
|
61
|
-
var paused = false; // Private, exported methods used by Spotlight to set and query the pause state from its public API
|
|
62
|
-
|
|
63
|
-
function pause() {
|
|
64
|
-
paused = true;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function _resume() {
|
|
68
|
-
paused = false;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function isPaused() {
|
|
72
|
-
return paused !== false;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Acts as a semaphore for Spotlight pause state ensuring that only the last Pause instance can
|
|
76
|
-
* resume Spotlight.
|
|
77
|
-
*
|
|
78
|
-
* *Note* {@link spotlight/Spotlight.resume} will always resume spotlight regardless of what last
|
|
79
|
-
* paused spotlight and can be used as an escape hatch to force resumption.
|
|
80
|
-
*
|
|
81
|
-
* @class Pause
|
|
82
|
-
* @memberof spotlight/Pause
|
|
83
|
-
* @public
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
var Pause = /*#__PURE__*/function () {
|
|
88
|
-
/**
|
|
89
|
-
* Accepts a name for the instance
|
|
90
|
-
*
|
|
91
|
-
* The `name` is not used but may be useful for debugging which instance has currently paused
|
|
92
|
-
* Spotlight.
|
|
93
|
-
*
|
|
94
|
-
* @param {String} name The name of the pause instance
|
|
95
|
-
* @memberof spotlight/Pause.Pause.prototype
|
|
96
|
-
* @constructor
|
|
97
|
-
* @public
|
|
98
|
-
*/
|
|
99
|
-
function Pause(name) {
|
|
100
|
-
_classCallCheck(this, Pause);
|
|
101
|
-
|
|
102
|
-
this.name = name;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
_createClass(Pause, [{
|
|
106
|
-
key: "toString",
|
|
107
|
-
value: function toString() {
|
|
108
|
-
return "Pause<".concat(this.name, ">");
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Returns `true` when Spotlight is paused by this instance
|
|
112
|
-
*
|
|
113
|
-
* @returns {Boolean}
|
|
114
|
-
* @memberof spotlight/Pause.Pause.prototype
|
|
115
|
-
* @public
|
|
116
|
-
*/
|
|
117
|
-
|
|
118
|
-
}, {
|
|
119
|
-
key: "isPaused",
|
|
120
|
-
value: function isPaused() {
|
|
121
|
-
return paused === this;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Pauses spotlight if not currently paused
|
|
125
|
-
*
|
|
126
|
-
* @returns {undefined}
|
|
127
|
-
* @memberof spotlight/Pause.Pause.prototype
|
|
128
|
-
* @public
|
|
129
|
-
*/
|
|
130
|
-
|
|
131
|
-
}, {
|
|
132
|
-
key: "pause",
|
|
133
|
-
value: function pause() {
|
|
134
|
-
if (!isPaused()) {
|
|
135
|
-
paused = this;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Resumes spotlight if this instance was the last to pause spotlight
|
|
140
|
-
*
|
|
141
|
-
* @returns {Boolean} `true` if spotlight was resumed
|
|
142
|
-
* @memberof spotlight/Pause.Pause.prototype
|
|
143
|
-
* @public
|
|
144
|
-
*/
|
|
145
|
-
|
|
146
|
-
}, {
|
|
147
|
-
key: "resume",
|
|
148
|
-
value: function resume() {
|
|
149
|
-
if (this.isPaused()) {
|
|
150
|
-
_resume();
|
|
151
|
-
|
|
152
|
-
return true;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
}]);
|
|
158
|
-
|
|
159
|
-
return Pause;
|
|
160
|
-
}();
|
|
161
|
-
|
|
162
|
-
exports.Pause = Pause;
|
|
163
|
-
var _default = Pause;
|
|
164
|
-
exports["default"] = _default;
|
package/build/Pause/package.json
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Pause = _interopRequireWildcard(require("../Pause"));
|
|
4
|
-
|
|
5
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
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; }
|
|
8
|
-
|
|
9
|
-
var PAUSED = 'Paused';
|
|
10
|
-
var NOT_PAUSED = 'Not Paused';
|
|
11
|
-
describe('Pause', function () {
|
|
12
|
-
test('should pause spotlight', function () {
|
|
13
|
-
var subject = new _Pause["default"]();
|
|
14
|
-
subject.pause();
|
|
15
|
-
var expected = PAUSED;
|
|
16
|
-
var actual = (0, _Pause.isPaused)() ? PAUSED : NOT_PAUSED;
|
|
17
|
-
subject.resume();
|
|
18
|
-
expect(actual).toBe(expected);
|
|
19
|
-
});
|
|
20
|
-
test('should resume spotlight', function () {
|
|
21
|
-
var subject = new _Pause["default"]();
|
|
22
|
-
subject.pause();
|
|
23
|
-
subject.resume();
|
|
24
|
-
var expected = NOT_PAUSED;
|
|
25
|
-
var actual = (0, _Pause.isPaused)() ? PAUSED : NOT_PAUSED;
|
|
26
|
-
expect(actual).toBe(expected);
|
|
27
|
-
});
|
|
28
|
-
test('should not resume spotlight when another Paused instance is in control', function () {
|
|
29
|
-
var subject = new _Pause["default"]();
|
|
30
|
-
var another = new _Pause["default"]();
|
|
31
|
-
another.pause();
|
|
32
|
-
subject.pause();
|
|
33
|
-
var expected = PAUSED;
|
|
34
|
-
var actual = (0, _Pause.isPaused)() ? PAUSED : NOT_PAUSED;
|
|
35
|
-
another.resume();
|
|
36
|
-
expect(actual).toBe(expected);
|
|
37
|
-
});
|
|
38
|
-
test('should not report paused when another Paused instance is in control', function () {
|
|
39
|
-
var subject = new _Pause["default"]();
|
|
40
|
-
var another = new _Pause["default"]();
|
|
41
|
-
another.pause();
|
|
42
|
-
subject.pause();
|
|
43
|
-
var expected = NOT_PAUSED;
|
|
44
|
-
var actual = subject.isPaused() ? PAUSED : NOT_PAUSED;
|
|
45
|
-
another.resume();
|
|
46
|
-
expect(actual).toBe(expected);
|
|
47
|
-
});
|
|
48
|
-
test('should not report paused when the global Spotlight is paused', function () {
|
|
49
|
-
var subject = new _Pause["default"]();
|
|
50
|
-
(0, _Pause.pause)();
|
|
51
|
-
subject.pause();
|
|
52
|
-
var expected = NOT_PAUSED;
|
|
53
|
-
var actual = subject.isPaused() ? PAUSED : NOT_PAUSED;
|
|
54
|
-
(0, _Pause.resume)();
|
|
55
|
-
expect(actual).toBe(expected);
|
|
56
|
-
});
|
|
57
|
-
test('should allow the global Spotlight to resume', function () {
|
|
58
|
-
var subject = new _Pause["default"]();
|
|
59
|
-
subject.pause();
|
|
60
|
-
(0, _Pause.resume)();
|
|
61
|
-
var expected = NOT_PAUSED;
|
|
62
|
-
var actual = (0, _Pause.isPaused)() ? PAUSED : NOT_PAUSED;
|
|
63
|
-
expect(actual).toBe(expected);
|
|
64
|
-
});
|
|
65
|
-
});
|
package/build/README.md
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# @enact/spotlight [](https://www.npmjs.com/package/@enact/spotlight)
|
|
2
|
-
|
|
3
|
-
> An extensible library for 5-way navigation and focus control.
|
|
4
|
-
|
|
5
|
-
An extensible utility that enables users to navigate
|
|
6
|
-
applications using a keyboard or television remote control. Responding to input
|
|
7
|
-
from the **UP**, **DOWN**, **LEFT**, **RIGHT**, and **RETURN** keys, Spotlight
|
|
8
|
-
provides a navigation experience that compares favorably to that of a
|
|
9
|
-
computer-with-mouse.
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
import kind from '@enact/core/kind';
|
|
15
|
-
import React from 'react';
|
|
16
|
-
import SpotlightRootDecorator from '@enact/spotlight/SpotlightRootDecorator'
|
|
17
|
-
import Spottable from '@enact/spotlight/Spottable'
|
|
18
|
-
|
|
19
|
-
const MySpottableComponent = Spottable('div');
|
|
20
|
-
|
|
21
|
-
const MyApp = kind({
|
|
22
|
-
name: 'MyApp',
|
|
23
|
-
render: () => (<MySpottableComponent>Hello, Enact!</MySpottableComponent>)
|
|
24
|
-
});
|
|
25
|
-
const MySpotlightApp = SpotlightRootDecorator(MyApp);
|
|
26
|
-
|
|
27
|
-
export default MySpotlightApp;
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
See the [docs](docs/) for more information.
|
|
31
|
-
|
|
32
|
-
## Additional Information
|
|
33
|
-
|
|
34
|
-
When using `@enact/moonstone`, the `SpotlightRootDecorator` is applied automatically by
|
|
35
|
-
`MoonstoneDecorator`.
|
|
36
|
-
|
|
37
|
-
## Acknowledgments
|
|
38
|
-
|
|
39
|
-
Spotlight is based on a fork of [JavaScript SpatialNavigation](https://github.com/luke-chang/js-spatial-navigation)
|
|
40
|
-
(c) 2016 Luke Chang, under the terms of the [Mozilla Public License](https://www.mozilla.org/en-US/MPL/2.0/).
|
|
41
|
-
|
|
42
|
-
## Copyright and License Information
|
|
43
|
-
|
|
44
|
-
Unless otherwise specified, all content, including all source code files and
|
|
45
|
-
documentation files in this repository are:
|
|
46
|
-
|
|
47
|
-
Copyright (c) 2012-2020 LG Electronics
|
|
48
|
-
|
|
49
|
-
Unless otherwise specified or set forth in the NOTICE file, all content,
|
|
50
|
-
including all source code files and documentation files in this repository are:
|
|
51
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
52
|
-
you may not use this content except in compliance with the License.
|
|
53
|
-
You may obtain a copy of the License at
|
|
54
|
-
|
|
55
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
56
|
-
|
|
57
|
-
Unless required by applicable law or agreed to in writing, software
|
|
58
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
59
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
60
|
-
See the License for the specific language governing permissions and
|
|
61
|
-
limitations under the License.
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SpotlightContainer = exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _handle = require("@enact/core/handle");
|
|
9
|
-
|
|
10
|
-
var _pointer = require("../src/pointer");
|
|
11
|
-
|
|
12
|
-
var _spotlight = _interopRequireDefault(require("../src/spotlight"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
19
|
-
|
|
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
|
-
|
|
22
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
|
-
|
|
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
|
-
|
|
26
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
27
|
-
|
|
28
|
-
var isNewPointerPosition = function isNewPointerPosition(ev) {
|
|
29
|
-
return (0, _pointer.hasPointerMoved)(ev.clientX, ev.clientY);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
var SpotlightContainer = /*#__PURE__*/function () {
|
|
33
|
-
// set up context and props so we can use handle binding
|
|
34
|
-
function SpotlightContainer(_ref) {
|
|
35
|
-
var _this = this;
|
|
36
|
-
|
|
37
|
-
var containerConfig = _ref.containerConfig,
|
|
38
|
-
navigableFilter = _ref.navigableFilter,
|
|
39
|
-
preserveId = _ref.preserveId;
|
|
40
|
-
|
|
41
|
-
_classCallCheck(this, SpotlightContainer);
|
|
42
|
-
|
|
43
|
-
this.context = {};
|
|
44
|
-
this.props = {};
|
|
45
|
-
|
|
46
|
-
this.navigableFilter = function (elem) {
|
|
47
|
-
// If the component to which this was applied specified a navigableFilter, run it
|
|
48
|
-
if (typeof _this.filter === 'function') {
|
|
49
|
-
if (_this.filter(elem) === false) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return true;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
this.onBlurCapture = function (ev) {
|
|
58
|
-
if (_this.shouldPreventBlur) {
|
|
59
|
-
(0, _handle.stop)(ev);
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return true;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
this.onFocusCapture = function (ev) {
|
|
67
|
-
if (_this.props.disabled === true) {
|
|
68
|
-
(0, _handle.stop)(ev);
|
|
69
|
-
|
|
70
|
-
_this.silentBlur(ev);
|
|
71
|
-
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return true;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
this.onPointerEnter = (0, _handle.handle)(isNewPointerPosition, function () {
|
|
79
|
-
return _spotlight["default"].setActiveContainer(_this.id);
|
|
80
|
-
}).bindAs(this, 'onPointerEnter');
|
|
81
|
-
this.onPointerLeave = (0, _handle.handle)((0, _handle.not)((0, _handle.forProp)('restrict', 'self-only')), isNewPointerPosition, function (ev) {
|
|
82
|
-
var parentContainer = ev.currentTarget.parentNode.closest('[data-spotlight-container]');
|
|
83
|
-
|
|
84
|
-
var activeContainer = _spotlight["default"].getActiveContainer(); // if this container is wrapped by another and this is the currently active
|
|
85
|
-
// container, move the active container to the parent
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (parentContainer && activeContainer === _this.id) {
|
|
89
|
-
activeContainer = parentContainer.dataset.spotlightId;
|
|
90
|
-
|
|
91
|
-
_spotlight["default"].setActiveContainer(activeContainer);
|
|
92
|
-
}
|
|
93
|
-
}).bindAs(this, 'onPointerLeave');
|
|
94
|
-
// spotlight id - set either via props or generated by Spotlight
|
|
95
|
-
this.id = null; // Preserve the spotlight id across instances when it is set via props and preserveId is set
|
|
96
|
-
|
|
97
|
-
this.canPreserveId = preserveId;
|
|
98
|
-
this.preserveId = false; // container config - set once when the container is added
|
|
99
|
-
|
|
100
|
-
this.config = containerConfig; // optional filter function to limit the spottable candidates for this container
|
|
101
|
-
|
|
102
|
-
this.filter = navigableFilter; // private hash of spotlight DOM attributes
|
|
103
|
-
|
|
104
|
-
this.attr = {
|
|
105
|
-
'data-spotlight-container': true
|
|
106
|
-
}; // Used to indicate that we want to stop propagation on blur events that occur as a
|
|
107
|
-
// result of this component imperatively blurring itself on focus when spotlightDisabled
|
|
108
|
-
|
|
109
|
-
this.shouldPreventBlur = false;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
_createClass(SpotlightContainer, [{
|
|
113
|
-
key: "setProps",
|
|
114
|
-
value: function setProps(props) {
|
|
115
|
-
var disabled = props.disabled,
|
|
116
|
-
id = props.id,
|
|
117
|
-
muted = props.muted,
|
|
118
|
-
restrict = props.restrict;
|
|
119
|
-
this.props = props;
|
|
120
|
-
|
|
121
|
-
if (this.id == null || id && this.id !== id) {
|
|
122
|
-
if (this.id) {
|
|
123
|
-
this.releaseContainer(this.id);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
this.id = _spotlight["default"].add(_objectSpread(_objectSpread({}, this.config), {}, {
|
|
127
|
-
id: id,
|
|
128
|
-
restrict: restrict,
|
|
129
|
-
navigableFilter: this.navigableFilter
|
|
130
|
-
}));
|
|
131
|
-
this.preserveId = this.canPreserveId && this.id === id;
|
|
132
|
-
} else {
|
|
133
|
-
_spotlight["default"].set(this.id, {
|
|
134
|
-
restrict: restrict
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
this.attr['data-spotlight-id'] = this.id;
|
|
139
|
-
this.attr['data-spotlight-container-disabled'] = disabled;
|
|
140
|
-
this.attr['data-spotlight-container-muted'] = muted;
|
|
141
|
-
}
|
|
142
|
-
}, {
|
|
143
|
-
key: "unload",
|
|
144
|
-
value: function unload() {
|
|
145
|
-
this.releaseContainer();
|
|
146
|
-
}
|
|
147
|
-
}, {
|
|
148
|
-
key: "releaseContainer",
|
|
149
|
-
value: function releaseContainer() {
|
|
150
|
-
if (this.preserveId) {
|
|
151
|
-
_spotlight["default"].unmount(this.id);
|
|
152
|
-
} else {
|
|
153
|
-
_spotlight["default"].remove(this.id);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}, {
|
|
157
|
-
key: "silentBlur",
|
|
158
|
-
value: function silentBlur(_ref2) {
|
|
159
|
-
var target = _ref2.target;
|
|
160
|
-
this.shouldPreventBlur = true;
|
|
161
|
-
target.blur();
|
|
162
|
-
this.shouldPreventBlur = false;
|
|
163
|
-
}
|
|
164
|
-
}, {
|
|
165
|
-
key: "attributes",
|
|
166
|
-
get: function get() {
|
|
167
|
-
return this.attr;
|
|
168
|
-
}
|
|
169
|
-
}]);
|
|
170
|
-
|
|
171
|
-
return SpotlightContainer;
|
|
172
|
-
}();
|
|
173
|
-
|
|
174
|
-
exports.SpotlightContainer = SpotlightContainer;
|
|
175
|
-
var _default = SpotlightContainer;
|
|
176
|
-
exports["default"] = _default;
|