@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
|
@@ -1,142 +1,112 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const nonSpottable = () => node({className: 'other'});
|
|
21
|
-
|
|
22
|
-
const scenarios = {
|
|
23
|
-
complexTree: join(
|
|
24
|
-
spottable({'data-spotlight-id': 's1'}),
|
|
25
|
-
spottable(nonSpottable()),
|
|
26
|
-
container({[containerAttribute]: 'first-container', children: join(
|
|
27
|
-
someSpottables(2),
|
|
28
|
-
container({[containerAttribute]: 'second-container', children: join(
|
|
29
|
-
spottable({id: 'secondContainerFirstSpottable'}),
|
|
30
|
-
someSpottables(2),
|
|
31
|
-
container({
|
|
32
|
-
[containerAttribute]: 'third-container',
|
|
33
|
-
'data-spotlight-container-disabled': true,
|
|
34
|
-
children: join(
|
|
35
|
-
someSpottables(4),
|
|
36
|
-
node({id: 'child-of-third'})
|
|
37
|
-
)
|
|
38
|
-
})
|
|
39
|
-
)})
|
|
40
|
-
)})
|
|
41
|
-
)
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _container4 = require("../container");
|
|
4
|
+
|
|
5
|
+
var _spotlight = _interopRequireDefault(require("../spotlight"));
|
|
6
|
+
|
|
7
|
+
var _utils = require("./utils");
|
|
8
|
+
|
|
9
|
+
var _container, _container2, _container3;
|
|
10
|
+
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
+
|
|
13
|
+
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; }
|
|
14
|
+
|
|
15
|
+
var nonSpottable = function nonSpottable() {
|
|
16
|
+
return (0, _utils.node)({
|
|
17
|
+
className: 'other'
|
|
18
|
+
});
|
|
42
19
|
};
|
|
43
20
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
21
|
+
var scenarios = {
|
|
22
|
+
complexTree: (0, _utils.join)((0, _utils.spottable)({
|
|
23
|
+
'data-spotlight-id': 's1'
|
|
24
|
+
}), (0, _utils.spottable)(nonSpottable()), (0, _utils.container)((_container3 = {}, _defineProperty(_container3, _container4.containerAttribute, 'first-container'), _defineProperty(_container3, "children", (0, _utils.join)((0, _utils.someSpottables)(2), (0, _utils.container)((_container2 = {}, _defineProperty(_container2, _container4.containerAttribute, 'second-container'), _defineProperty(_container2, "children", (0, _utils.join)((0, _utils.spottable)({
|
|
25
|
+
id: 'secondContainerFirstSpottable'
|
|
26
|
+
}), (0, _utils.someSpottables)(2), (0, _utils.container)((_container = {}, _defineProperty(_container, _container4.containerAttribute, 'third-container'), _defineProperty(_container, 'data-spotlight-container-disabled', true), _defineProperty(_container, "children", (0, _utils.join)((0, _utils.someSpottables)(4), (0, _utils.node)({
|
|
27
|
+
id: 'child-of-third'
|
|
28
|
+
}))), _container)))), _container2)))), _container3)))
|
|
51
29
|
};
|
|
52
30
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
31
|
+
var setupContainers = function setupContainers() {
|
|
32
|
+
_spotlight["default"].setPointerMode(false);
|
|
33
|
+
|
|
34
|
+
(0, _container4.configureDefaults)({
|
|
35
|
+
selector: '.spottable'
|
|
36
|
+
});
|
|
37
|
+
(0, _container4.configureContainer)(_container4.rootContainerId);
|
|
38
|
+
(0, _container4.setLastContainer)(_container4.rootContainerId);
|
|
56
39
|
};
|
|
57
40
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
41
|
+
var teardownContainers = function teardownContainers() {
|
|
42
|
+
// clean up any containers we create for safe tests
|
|
43
|
+
(0, _container4.removeAllContainers)();
|
|
44
|
+
};
|
|
63
45
|
|
|
64
|
-
|
|
46
|
+
var mockFocus = function mockFocus(n) {
|
|
47
|
+
var fn = jest.fn().mockImplementation(function () {
|
|
48
|
+
return true;
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(n, 'focus', {
|
|
51
|
+
get: function get() {
|
|
52
|
+
return fn;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return fn;
|
|
65
56
|
};
|
|
66
57
|
|
|
67
|
-
describe('Spotlight', ()
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const fn = mockFocus(n);
|
|
123
|
-
Spotlight.focus('[data-spotlight-id="s1"]');
|
|
124
|
-
|
|
125
|
-
expect(fn).toBeCalled();
|
|
126
|
-
}
|
|
127
|
-
));
|
|
128
|
-
|
|
129
|
-
test('should focus container by node', testScenario(
|
|
130
|
-
scenarios.complexTree,
|
|
131
|
-
(root) => {
|
|
132
|
-
configureContainer('first-container');
|
|
133
|
-
|
|
134
|
-
const n = root.querySelector('[data-spotlight-id="first-container"]');
|
|
135
|
-
const fn = mockFocus(n.querySelector('.spottable'));
|
|
136
|
-
Spotlight.focus('[data-spotlight-id="first-container"]');
|
|
137
|
-
|
|
138
|
-
expect(fn).toBeCalled();
|
|
139
|
-
}
|
|
140
|
-
));
|
|
141
|
-
});
|
|
142
|
-
});
|
|
58
|
+
describe('Spotlight', function () {
|
|
59
|
+
describe('#focus', function () {
|
|
60
|
+
beforeEach(setupContainers);
|
|
61
|
+
afterEach(teardownContainers);
|
|
62
|
+
test('should focus spottable by id', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
63
|
+
var fn = mockFocus(root.querySelector('[data-spotlight-id="s1"]'));
|
|
64
|
+
|
|
65
|
+
_spotlight["default"].focus('s1');
|
|
66
|
+
|
|
67
|
+
expect(fn).toBeCalled();
|
|
68
|
+
}));
|
|
69
|
+
test('should focus container by id', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
70
|
+
(0, _container4.configureContainer)('first-container');
|
|
71
|
+
var fn = mockFocus(root.querySelector('[data-spotlight-id="first-container"] > .spottable'));
|
|
72
|
+
|
|
73
|
+
_spotlight["default"].focus('first-container');
|
|
74
|
+
|
|
75
|
+
expect(fn).toBeCalled();
|
|
76
|
+
}));
|
|
77
|
+
test('should focus spottable by node', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
78
|
+
var n = root.querySelector('[data-spotlight-id="s1"]');
|
|
79
|
+
var fn = mockFocus(n);
|
|
80
|
+
|
|
81
|
+
_spotlight["default"].focus(n);
|
|
82
|
+
|
|
83
|
+
expect(fn).toBeCalled();
|
|
84
|
+
}));
|
|
85
|
+
test('should focus container by node', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
86
|
+
(0, _container4.configureContainer)('first-container');
|
|
87
|
+
var n = root.querySelector('[data-spotlight-id="first-container"]');
|
|
88
|
+
var fn = mockFocus(n.querySelector('.spottable'));
|
|
89
|
+
|
|
90
|
+
_spotlight["default"].focus(n);
|
|
91
|
+
|
|
92
|
+
expect(fn).toBeCalled();
|
|
93
|
+
}));
|
|
94
|
+
test('should focus spottable by selector', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
95
|
+
var n = root.querySelector('[data-spotlight-id="s1"]');
|
|
96
|
+
var fn = mockFocus(n);
|
|
97
|
+
|
|
98
|
+
_spotlight["default"].focus('[data-spotlight-id="s1"]');
|
|
99
|
+
|
|
100
|
+
expect(fn).toBeCalled();
|
|
101
|
+
}));
|
|
102
|
+
test('should focus container by node', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
103
|
+
(0, _container4.configureContainer)('first-container');
|
|
104
|
+
var n = root.querySelector('[data-spotlight-id="first-container"]');
|
|
105
|
+
var fn = mockFocus(n.querySelector('.spottable'));
|
|
106
|
+
|
|
107
|
+
_spotlight["default"].focus('[data-spotlight-id="first-container"]');
|
|
108
|
+
|
|
109
|
+
expect(fn).toBeCalled();
|
|
110
|
+
}));
|
|
111
|
+
});
|
|
112
|
+
});
|