@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,614 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _container12 = require("../container");
|
|
4
|
-
|
|
5
|
-
var _target = require("../target");
|
|
6
|
-
|
|
7
|
-
var _utils = require("./utils");
|
|
8
|
-
|
|
9
|
-
var _container2, _container3, _container4, _container5, _container6, _container7, _container8, _container9, _container10, _container11;
|
|
10
|
-
|
|
11
|
-
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; }
|
|
12
|
-
|
|
13
|
-
var nonSpottable = function nonSpottable() {
|
|
14
|
-
return (0, _utils.node)({
|
|
15
|
-
className: 'other'
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
var position = function position(top, left) {
|
|
20
|
-
return "position: absolute; top: ".concat(top, "px; left: ").concat(left, "px; height: 10px; width: 10px;");
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
var positionedSpottable = function positionedSpottable(id, top, left) {
|
|
24
|
-
return (0, _utils.spottable)({
|
|
25
|
-
id: id,
|
|
26
|
-
style: position(top, left)
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
var grid = function grid() {
|
|
31
|
-
var _container;
|
|
32
|
-
|
|
33
|
-
return (0, _utils.container)((_container = {}, _defineProperty(_container, _container12.containerAttribute, 'grid'), _defineProperty(_container, "style", 'position: relative; height: 30px; width: 30px;'), _defineProperty(_container, "children", (0, _utils.join)(positionedSpottable('top-left', 0, 0), positionedSpottable('top-center', 0, 10), positionedSpottable('top-right', 0, 20), positionedSpottable('middle-left', 10, 0), positionedSpottable('middle-center', 10, 10), positionedSpottable('middle-right', 10, 20), positionedSpottable('bottom-left', 20, 0), positionedSpottable('bottom-center', 20, 10), positionedSpottable('bottom-right', 20, 20))), _container));
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
var scenarios = {
|
|
37
|
-
complexTree: (0, _utils.join)((0, _utils.spottable)(nonSpottable()), (0, _utils.container)((_container4 = {}, _defineProperty(_container4, _container12.containerAttribute, 'first-container'), _defineProperty(_container4, "children", (0, _utils.join)((0, _utils.someSpottables)(2), (0, _utils.container)((_container3 = {}, _defineProperty(_container3, _container12.containerAttribute, 'second-container'), _defineProperty(_container3, "children", (0, _utils.join)((0, _utils.someSpottables)(3), (0, _utils.container)((_container2 = {}, _defineProperty(_container2, _container12.containerAttribute, 'third-container'), _defineProperty(_container2, 'data-spotlight-container-disabled', true), _defineProperty(_container2, "children", (0, _utils.join)((0, _utils.someSpottables)(4), (0, _utils.node)({
|
|
38
|
-
id: 'child-of-third'
|
|
39
|
-
}))), _container2)))), _container3)))), _container4))),
|
|
40
|
-
nonSpottableInContainer: (0, _utils.join)((0, _utils.spottable)({
|
|
41
|
-
id: 'in-root'
|
|
42
|
-
}), (0, _utils.container)((_container5 = {}, _defineProperty(_container5, _container12.containerAttribute, 'first'), _defineProperty(_container5, "children", (0, _utils.join)(nonSpottable(), (0, _utils.spottable)({
|
|
43
|
-
id: 'in-first'
|
|
44
|
-
}))), _container5)), (0, _utils.container)((_container6 = {}, _defineProperty(_container6, _container12.containerAttribute, 'second'), _defineProperty(_container6, "children", (0, _utils.join)(nonSpottable())), _container6))),
|
|
45
|
-
grid: (0, _utils.join)((0, _utils.spottable)({
|
|
46
|
-
id: 'before-grid',
|
|
47
|
-
style: 'height: 10px'
|
|
48
|
-
}), grid(), (0, _utils.spottable)({
|
|
49
|
-
id: 'after-grid',
|
|
50
|
-
style: 'height: 10px'
|
|
51
|
-
})),
|
|
52
|
-
overlap: (0, _utils.node)({
|
|
53
|
-
style: 'position: relative',
|
|
54
|
-
children: (0, _utils.join)(grid(), (0, _utils.spottable)({
|
|
55
|
-
id: 'over-middle-center',
|
|
56
|
-
style: 'position: absolute; top: 12px; left: 15px; height: 1px; width: 1px;'
|
|
57
|
-
}))
|
|
58
|
-
}),
|
|
59
|
-
overflow: (0, _utils.join)((0, _utils.spottable)({
|
|
60
|
-
id: 'outside-overflow'
|
|
61
|
-
}), (0, _utils.node)({
|
|
62
|
-
// allocate some empty space so that overflow items would be otherwise navigable
|
|
63
|
-
style: 'height: 100px'
|
|
64
|
-
}), (0, _utils.container)((_container7 = {}, _defineProperty(_container7, _container12.containerAttribute, 'overflow-container'), _defineProperty(_container7, "style", 'position: relative; height: 30px; width: 30px;'), _defineProperty(_container7, "children", (0, _utils.join)((0, _utils.spottable)({
|
|
65
|
-
id: 'overflow-above',
|
|
66
|
-
style: 'position: absolute; top: -10px; left: 0px; height: 10px; width: 10px;'
|
|
67
|
-
}), (0, _utils.spottable)({
|
|
68
|
-
id: 'overflow-below',
|
|
69
|
-
style: 'position: absolute; top: 30px; left: 0px; height: 10px; width: 10px;'
|
|
70
|
-
}), (0, _utils.spottable)({
|
|
71
|
-
id: 'overflow-within',
|
|
72
|
-
style: 'position: absolute; top: 0px; left: 0px; height: 10px; width: 10px;'
|
|
73
|
-
}))), _container7))),
|
|
74
|
-
overflowLargeSubContainer: (0, _utils.join)((0, _utils.spottable)({
|
|
75
|
-
id: 'outside-overflow'
|
|
76
|
-
}), (0, _utils.node)({
|
|
77
|
-
// allocate some empty space so that overflow items would be otherwise navigable
|
|
78
|
-
style: 'height: 100px'
|
|
79
|
-
}), (0, _utils.container)((_container9 = {}, _defineProperty(_container9, _container12.containerAttribute, 'overflow-container'), _defineProperty(_container9, "style", 'position: relative; height: 30px; width: 30px;'), _defineProperty(_container9, "children", (0, _utils.join)((0, _utils.container)((_container8 = {}, _defineProperty(_container8, _container12.containerAttribute, 'inside'), _defineProperty(_container8, "style", 'position: absolute; top: -10px; left: 0px; height: 50px; width: 10px;'), _defineProperty(_container8, "children", (0, _utils.join)((0, _utils.node)({
|
|
80
|
-
// allocate space to push following spottable into view
|
|
81
|
-
style: 'height: 10px'
|
|
82
|
-
}), (0, _utils.spottable)({
|
|
83
|
-
id: 'in-large-container'
|
|
84
|
-
}))), _container8)), (0, _utils.spottable)({
|
|
85
|
-
id: 'below-large-container',
|
|
86
|
-
style: 'position: absolute; top: 40px; left: 0px; height: 10px; width: 10px;'
|
|
87
|
-
}))), _container9))),
|
|
88
|
-
emptyContainer: (0, _utils.join)(positionedSpottable('above', 0, 10), (0, _utils.container)((_container10 = {}, _defineProperty(_container10, _container12.containerAttribute, 'empty-container'), _defineProperty(_container10, "style", position(10, 10)), _container10)), positionedSpottable('below', 30, 0)),
|
|
89
|
-
emptyContainerOverlap: (0, _utils.join)(positionedSpottable('above', 5, 10), (0, _utils.container)((_container11 = {}, _defineProperty(_container11, _container12.containerAttribute, 'empty-container'), _defineProperty(_container11, "style", position(10, 10)), _container11)), positionedSpottable('below', 30, 0))
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
var safeTarget = function safeTarget(n, fn) {
|
|
93
|
-
return n ? fn(n) : 'NOT FOUND';
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
var setupContainers = function setupContainers() {
|
|
97
|
-
(0, _container12.configureDefaults)({
|
|
98
|
-
selector: '.spottable'
|
|
99
|
-
});
|
|
100
|
-
(0, _container12.configureContainer)(_container12.rootContainerId);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
var teardownContainers = function teardownContainers() {
|
|
104
|
-
// clean up any containers we create for safe tests
|
|
105
|
-
(0, _container12.getAllContainerIds)().forEach(_container12.removeContainer);
|
|
106
|
-
(0, _container12.setDefaultContainer)();
|
|
107
|
-
}; // NOTE: Skipping most tests because JSDOM does not support measurments
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
describe('target', function () {
|
|
111
|
-
beforeEach(setupContainers);
|
|
112
|
-
afterEach(teardownContainers);
|
|
113
|
-
describe.skip('#getNavigableTarget', function () {
|
|
114
|
-
test('should find spottable parent', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
115
|
-
var other = root.querySelector('.other');
|
|
116
|
-
var expected = other.parentNode;
|
|
117
|
-
var actual = (0, _target.getNavigableTarget)(other);
|
|
118
|
-
expect(actual).toBe(expected);
|
|
119
|
-
}));
|
|
120
|
-
test('should skip containers', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function (root) {
|
|
121
|
-
(0, _container12.configureContainer)('first');
|
|
122
|
-
var other = root.querySelector('.other');
|
|
123
|
-
var expected = null;
|
|
124
|
-
var actual = (0, _target.getNavigableTarget)(other);
|
|
125
|
-
expect(actual).toBe(expected);
|
|
126
|
-
}));
|
|
127
|
-
test('should respect container-specific selector', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function (root) {
|
|
128
|
-
// make '.other' a valid spottable element
|
|
129
|
-
(0, _container12.configureContainer)('first', {
|
|
130
|
-
selector: '.other'
|
|
131
|
-
});
|
|
132
|
-
var other = root.querySelector('.other');
|
|
133
|
-
var expected = other;
|
|
134
|
-
var actual = (0, _target.getNavigableTarget)(other);
|
|
135
|
-
expect(actual).toBe(expected);
|
|
136
|
-
}));
|
|
137
|
-
test('should respect disabled containers', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
138
|
-
(0, _container12.configureContainer)('third-container');
|
|
139
|
-
var other = root.querySelector("[".concat(_container12.containerAttribute, "='third-container'] .spottable"));
|
|
140
|
-
var expected = null;
|
|
141
|
-
var actual = (0, _target.getNavigableTarget)(other);
|
|
142
|
-
expect(actual).toBe(expected);
|
|
143
|
-
}));
|
|
144
|
-
});
|
|
145
|
-
describe('#getTargetByContainer', function () {
|
|
146
|
-
test('should find spottable element within provided container', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
147
|
-
(0, _container12.configureContainer)('first-container');
|
|
148
|
-
var expected = 'spottable';
|
|
149
|
-
var actual = safeTarget((0, _target.getTargetByContainer)('first-container'), function (t) {
|
|
150
|
-
return t.className;
|
|
151
|
-
});
|
|
152
|
-
expect(actual).toBe(expected);
|
|
153
|
-
}));
|
|
154
|
-
test('should return null when container does not contain any spottable elements', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () {
|
|
155
|
-
(0, _container12.configureContainer)('first');
|
|
156
|
-
(0, _container12.configureContainer)('second');
|
|
157
|
-
var expected = null;
|
|
158
|
-
var actual = (0, _target.getTargetByContainer)('second');
|
|
159
|
-
expect(actual).toBe(expected);
|
|
160
|
-
}));
|
|
161
|
-
test('should find the first spottable in the root when no container specified', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () {
|
|
162
|
-
(0, _container12.configureContainer)('first');
|
|
163
|
-
(0, _container12.configureContainer)('second');
|
|
164
|
-
var expected = 'in-root';
|
|
165
|
-
var actual = safeTarget((0, _target.getTargetByContainer)(), function (t) {
|
|
166
|
-
return t.id;
|
|
167
|
-
});
|
|
168
|
-
expect(actual).toBe(expected);
|
|
169
|
-
}));
|
|
170
|
-
test('should find the first spottable in the default container when set and no container specified', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () {
|
|
171
|
-
(0, _container12.configureContainer)('first');
|
|
172
|
-
(0, _container12.configureContainer)('second');
|
|
173
|
-
(0, _container12.setDefaultContainer)('first');
|
|
174
|
-
var expected = 'spottable';
|
|
175
|
-
var actual = safeTarget((0, _target.getTargetByContainer)(), function (t) {
|
|
176
|
-
return t.className;
|
|
177
|
-
});
|
|
178
|
-
expect(actual).toBe(expected);
|
|
179
|
-
}));
|
|
180
|
-
test('should return `default-element` when last focused is unset', (0, _utils.testScenario)(scenarios.grid, function () {
|
|
181
|
-
(0, _container12.configureContainer)('grid', {
|
|
182
|
-
enterTo: 'last-focused',
|
|
183
|
-
defaultElement: '#middle-center'
|
|
184
|
-
});
|
|
185
|
-
var expected = 'middle-center';
|
|
186
|
-
var actual = safeTarget((0, _target.getTargetByContainer)('grid'), function (t) {
|
|
187
|
-
return t.id;
|
|
188
|
-
});
|
|
189
|
-
expect(actual).toBe(expected);
|
|
190
|
-
}));
|
|
191
|
-
test('should return `default-element` when `last-focused` is requested but is unset', (0, _utils.testScenario)(scenarios.grid, function () {
|
|
192
|
-
(0, _container12.configureContainer)('grid', {
|
|
193
|
-
defaultElement: '#middle-center'
|
|
194
|
-
});
|
|
195
|
-
var expected = 'middle-center';
|
|
196
|
-
var actual = safeTarget((0, _target.getTargetByContainer)('grid', 'last-focused'), function (t) {
|
|
197
|
-
return t.id;
|
|
198
|
-
});
|
|
199
|
-
expect(actual).toBe(expected);
|
|
200
|
-
}));
|
|
201
|
-
test('should return default element when configured for `last-focused` but requested `default-element`', (0, _utils.testScenario)(scenarios.grid, function () {
|
|
202
|
-
(0, _container12.configureContainer)('grid', {
|
|
203
|
-
enterTo: 'last-focused',
|
|
204
|
-
lastFocusedElement: document.querySelector('#top-left'),
|
|
205
|
-
defaultElement: '#middle-center'
|
|
206
|
-
});
|
|
207
|
-
var expected = 'middle-center';
|
|
208
|
-
var actual = safeTarget((0, _target.getTargetByContainer)('grid', 'default-element'), function (t) {
|
|
209
|
-
return t.id;
|
|
210
|
-
});
|
|
211
|
-
expect(actual).toBe(expected);
|
|
212
|
-
}));
|
|
213
|
-
test('should return last focused element when configured for `default-element` but requested `last-focused`', (0, _utils.testScenario)(scenarios.grid, function () {
|
|
214
|
-
(0, _container12.configureContainer)('grid', {
|
|
215
|
-
enterTo: 'default-element',
|
|
216
|
-
lastFocusedElement: document.querySelector('#top-left'),
|
|
217
|
-
defaultElement: '#middle-center'
|
|
218
|
-
});
|
|
219
|
-
var expected = 'top-left';
|
|
220
|
-
var actual = safeTarget((0, _target.getTargetByContainer)('grid', 'last-focused'), function (t) {
|
|
221
|
-
return t.id;
|
|
222
|
-
});
|
|
223
|
-
expect(actual).toBe(expected);
|
|
224
|
-
}));
|
|
225
|
-
});
|
|
226
|
-
describe('#getTargetBySelector', function () {
|
|
227
|
-
test('should find spottable element within container when "@" prefix used', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () {
|
|
228
|
-
(0, _container12.configureContainer)('first');
|
|
229
|
-
var expected = 'spottable';
|
|
230
|
-
var actual = safeTarget((0, _target.getTargetBySelector)('@first'), function (t) {
|
|
231
|
-
return t.className;
|
|
232
|
-
});
|
|
233
|
-
expect(actual).toBe(expected);
|
|
234
|
-
}));
|
|
235
|
-
test('should find spottable element within container when "#" prefix used', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () {
|
|
236
|
-
(0, _container12.configureContainer)('first');
|
|
237
|
-
var expected = 'in-first';
|
|
238
|
-
var actual = safeTarget((0, _target.getTargetBySelector)('#in-first'), function (t) {
|
|
239
|
-
return t.id;
|
|
240
|
-
});
|
|
241
|
-
expect(actual).toBe(expected);
|
|
242
|
-
}));
|
|
243
|
-
test('should return null when the node exists but is not navigable within its container', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () {
|
|
244
|
-
(0, _container12.configureContainer)('first', {
|
|
245
|
-
navigableFilter: function navigableFilter() {
|
|
246
|
-
return false;
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
var expected = null;
|
|
250
|
-
var actual = (0, _target.getTargetBySelector)('#in-first');
|
|
251
|
-
expect(actual).toBe(expected);
|
|
252
|
-
}));
|
|
253
|
-
test('should return null when the node exists but does not match the container\'s selector', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () {
|
|
254
|
-
(0, _container12.configureContainer)('first');
|
|
255
|
-
var expected = null;
|
|
256
|
-
var actual = (0, _target.getTargetBySelector)("[".concat(_container12.containerAttribute, "='first'] .other"));
|
|
257
|
-
expect(actual).toBe(expected);
|
|
258
|
-
}));
|
|
259
|
-
test('should return null for an empty selectors', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () {
|
|
260
|
-
var expected = null; // eslint-disable-next-line no-undefined
|
|
261
|
-
|
|
262
|
-
expect((0, _target.getTargetBySelector)(undefined)).toBe(expected);
|
|
263
|
-
expect((0, _target.getTargetBySelector)(null)).toBe(expected);
|
|
264
|
-
expect((0, _target.getTargetBySelector)('')).toBe(expected);
|
|
265
|
-
}));
|
|
266
|
-
});
|
|
267
|
-
describe.skip('#getTargetByDirectionFromElement', function () {
|
|
268
|
-
test('should find target within container by direction', (0, _utils.testScenario)(scenarios.grid, function (root) {
|
|
269
|
-
(0, _container12.configureContainer)('grid');
|
|
270
|
-
var center = root.querySelector('#middle-center');
|
|
271
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', center), function (t) {
|
|
272
|
-
return t.id;
|
|
273
|
-
})).toBe('top-center');
|
|
274
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', center), function (t) {
|
|
275
|
-
return t.id;
|
|
276
|
-
})).toBe('bottom-center');
|
|
277
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('left', center), function (t) {
|
|
278
|
-
return t.id;
|
|
279
|
-
})).toBe('middle-left');
|
|
280
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('right', center), function (t) {
|
|
281
|
-
return t.id;
|
|
282
|
-
})).toBe('middle-right');
|
|
283
|
-
}));
|
|
284
|
-
test('should find target within container from floating element', (0, _utils.testScenario)(scenarios.overlap, function (root) {
|
|
285
|
-
(0, _container12.configureContainer)('grid', {
|
|
286
|
-
enterTo: 'default-element',
|
|
287
|
-
defaultElement: '#bottom-right'
|
|
288
|
-
});
|
|
289
|
-
var overlap = root.querySelector('#over-middle-center');
|
|
290
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', overlap), function (t) {
|
|
291
|
-
return t.id;
|
|
292
|
-
})).toBe('middle-center');
|
|
293
|
-
}));
|
|
294
|
-
test('should ignore targets outside the bounds of an overflow container', (0, _utils.testScenario)(scenarios.overflow, function (root) {
|
|
295
|
-
(0, _container12.configureContainer)('overflow-container', {
|
|
296
|
-
overflow: true
|
|
297
|
-
});
|
|
298
|
-
var element = root.querySelector('#outside-overflow');
|
|
299
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
|
|
300
|
-
return t.id;
|
|
301
|
-
})).toBe('overflow-within');
|
|
302
|
-
}));
|
|
303
|
-
test('should find target within container larger than overflow container', (0, _utils.testScenario)(scenarios.overflowLargeSubContainer, function (root) {
|
|
304
|
-
(0, _container12.configureContainer)('overflow-container', {
|
|
305
|
-
overflow: true
|
|
306
|
-
});
|
|
307
|
-
(0, _container12.configureContainer)('inside', {
|
|
308
|
-
enterTo: null
|
|
309
|
-
});
|
|
310
|
-
var element = root.querySelector('#outside-overflow');
|
|
311
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
|
|
312
|
-
return t.id;
|
|
313
|
-
})).toBe('in-large-container');
|
|
314
|
-
}));
|
|
315
|
-
test('should find target out of bounds of overflow container from within container', (0, _utils.testScenario)(scenarios.overflow, function (root) {
|
|
316
|
-
(0, _container12.configureContainer)('overflow-container', {
|
|
317
|
-
overflow: true
|
|
318
|
-
});
|
|
319
|
-
var element = root.querySelector('#overflow-within');
|
|
320
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
|
|
321
|
-
return t.id;
|
|
322
|
-
})).toBe('overflow-below');
|
|
323
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
|
|
324
|
-
return t.id;
|
|
325
|
-
})).toBe('overflow-above');
|
|
326
|
-
}));
|
|
327
|
-
test('should stop at restrict="self-only" boundaries', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
328
|
-
(0, _container12.configureContainer)('first-container', {
|
|
329
|
-
restrict: 'none'
|
|
330
|
-
});
|
|
331
|
-
(0, _container12.configureContainer)('second-container', {
|
|
332
|
-
restrict: 'self-only'
|
|
333
|
-
});
|
|
334
|
-
var element = root.querySelector("[".concat(_container12.containerAttribute, "=\"second-container\"] .spottable"));
|
|
335
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
|
|
336
|
-
return t.id;
|
|
337
|
-
})).toBe('NOT FOUND');
|
|
338
|
-
}));
|
|
339
|
-
test('should respect enterTo="default-element" containers', (0, _utils.testScenario)(scenarios.grid, function (root) {
|
|
340
|
-
(0, _container12.configureContainer)('grid', {
|
|
341
|
-
restrict: 'none',
|
|
342
|
-
enterTo: 'default-element',
|
|
343
|
-
defaultElement: '#bottom-right'
|
|
344
|
-
});
|
|
345
|
-
var element = root.querySelector('#before-grid');
|
|
346
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
|
|
347
|
-
return t.id;
|
|
348
|
-
})).toBe('bottom-right');
|
|
349
|
-
}));
|
|
350
|
-
test('should respect enterTo="last-focused" containers', (0, _utils.testScenario)(scenarios.grid, function (root) {
|
|
351
|
-
(0, _container12.configureContainer)('grid', {
|
|
352
|
-
restrict: 'none',
|
|
353
|
-
enterTo: 'last-focused',
|
|
354
|
-
lastFocusedKey: {
|
|
355
|
-
container: false,
|
|
356
|
-
element: true,
|
|
357
|
-
key: 8
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
var element = root.querySelector('#before-grid');
|
|
361
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
|
|
362
|
-
return t.id;
|
|
363
|
-
})).toBe('bottom-right');
|
|
364
|
-
}));
|
|
365
|
-
test('should follow the leaveFor config when no target is found within the container in the given direction', (0, _utils.testScenario)(scenarios.grid, function (root) {
|
|
366
|
-
(0, _container12.configureContainer)('grid', {
|
|
367
|
-
restrict: 'none',
|
|
368
|
-
leaveFor: {
|
|
369
|
-
up: '#after-grid'
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
var element = root.querySelector('#top-center');
|
|
373
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
|
|
374
|
-
return t.id;
|
|
375
|
-
})).toBe('after-grid');
|
|
376
|
-
}));
|
|
377
|
-
test('should not follow the leaveFor config when a target is found within the container in the given direction', (0, _utils.testScenario)(scenarios.grid, function (root) {
|
|
378
|
-
(0, _container12.configureContainer)('grid', {
|
|
379
|
-
restrict: 'none',
|
|
380
|
-
leaveFor: {
|
|
381
|
-
up: '#after-grid'
|
|
382
|
-
}
|
|
383
|
-
});
|
|
384
|
-
var element = root.querySelector('#middle-center');
|
|
385
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
|
|
386
|
-
return t.id;
|
|
387
|
-
})).toBe('top-center');
|
|
388
|
-
}));
|
|
389
|
-
test('should not follow the leaveFor config when the selector does not match an element', (0, _utils.testScenario)(scenarios.grid, function (root) {
|
|
390
|
-
(0, _container12.configureContainer)('grid', {
|
|
391
|
-
restrict: 'none',
|
|
392
|
-
leaveFor: {
|
|
393
|
-
up: '#does-not-exist'
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
var element = root.querySelector('#top-center');
|
|
397
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
|
|
398
|
-
return t.id;
|
|
399
|
-
})).toBe('before-grid');
|
|
400
|
-
}));
|
|
401
|
-
test('should ignore empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) {
|
|
402
|
-
(0, _container12.configureContainer)('empty-container');
|
|
403
|
-
var element = root.querySelector('#above');
|
|
404
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
|
|
405
|
-
return t.id;
|
|
406
|
-
})).toBe('below');
|
|
407
|
-
}));
|
|
408
|
-
test('should ignore overlapping empty containers', (0, _utils.testScenario)(scenarios.emptyContainerOverlap, function (root) {
|
|
409
|
-
(0, _container12.configureContainer)('empty-container');
|
|
410
|
-
var element = root.querySelector('#above');
|
|
411
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
|
|
412
|
-
return t.id;
|
|
413
|
-
})).toBe('below');
|
|
414
|
-
}));
|
|
415
|
-
});
|
|
416
|
-
describe.skip('#getTargetByDirectionFromPosition', function () {
|
|
417
|
-
test('should find target within container', (0, _utils.testScenario)(scenarios.grid, function (root) {
|
|
418
|
-
(0, _container12.configureContainer)('grid');
|
|
419
|
-
var rect = root.querySelector('#middle-center').getBoundingClientRect();
|
|
420
|
-
var center = {
|
|
421
|
-
x: rect.left + rect.width / 2,
|
|
422
|
-
y: rect.top + rect.height / 2
|
|
423
|
-
};
|
|
424
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', center, 'grid'), function (t) {
|
|
425
|
-
return t.id;
|
|
426
|
-
})).toBe('top-center');
|
|
427
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', center, 'grid'), function (t) {
|
|
428
|
-
return t.id;
|
|
429
|
-
})).toBe('bottom-center');
|
|
430
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('left', center, 'grid'), function (t) {
|
|
431
|
-
return t.id;
|
|
432
|
-
})).toBe('middle-left');
|
|
433
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('right', center, 'grid'), function (t) {
|
|
434
|
-
return t.id;
|
|
435
|
-
})).toBe('middle-right');
|
|
436
|
-
}));
|
|
437
|
-
test('should not find a target when at bounds of container with restrict="self-only"', (0, _utils.testScenario)(scenarios.grid, function (root) {
|
|
438
|
-
(0, _container12.configureContainer)('grid', {
|
|
439
|
-
restrict: 'self-only'
|
|
440
|
-
});
|
|
441
|
-
var rect = root.querySelector('#top-center').getBoundingClientRect();
|
|
442
|
-
var topCenterOfGrid = {
|
|
443
|
-
x: rect.left + rect.width / 2,
|
|
444
|
-
y: rect.top
|
|
445
|
-
};
|
|
446
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', topCenterOfGrid, 'grid'), function (t) {
|
|
447
|
-
return t.id;
|
|
448
|
-
})).toBe('NOT FOUND');
|
|
449
|
-
}));
|
|
450
|
-
test('should not find a target outside of container when restrict is not set', (0, _utils.testScenario)(scenarios.grid, function (root) {
|
|
451
|
-
(0, _container12.configureContainer)('grid', {
|
|
452
|
-
restrict: 'none'
|
|
453
|
-
});
|
|
454
|
-
var rect = root.querySelector('#top-center').getBoundingClientRect();
|
|
455
|
-
var topCenterOfGrid = {
|
|
456
|
-
x: rect.left + rect.width / 2,
|
|
457
|
-
y: rect.top
|
|
458
|
-
};
|
|
459
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', topCenterOfGrid, 'grid'), function (t) {
|
|
460
|
-
return t.id;
|
|
461
|
-
})).toBe('before-grid');
|
|
462
|
-
}));
|
|
463
|
-
test('should cascade into unrestricted subcontainers', (0, _utils.testScenario)(scenarios.grid, function (root) {
|
|
464
|
-
(0, _container12.configureContainer)('grid', {
|
|
465
|
-
restrict: 'none'
|
|
466
|
-
});
|
|
467
|
-
var rect = root.querySelector('#top-center').getBoundingClientRect();
|
|
468
|
-
var aboveCenterOfGrid = {
|
|
469
|
-
x: rect.left + rect.width / 2,
|
|
470
|
-
y: rect.top - 1
|
|
471
|
-
};
|
|
472
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', aboveCenterOfGrid, _container12.rootContainerId), function (t) {
|
|
473
|
-
return t.id;
|
|
474
|
-
})).toBe('top-center');
|
|
475
|
-
}));
|
|
476
|
-
test('should ignore enterTo config of restricted subcontainers', (0, _utils.testScenario)(scenarios.grid, function (root) {
|
|
477
|
-
(0, _container12.configureContainer)('grid', {
|
|
478
|
-
restrict: 'none',
|
|
479
|
-
enterTo: 'default-element',
|
|
480
|
-
defaultElement: '#bottom-right'
|
|
481
|
-
});
|
|
482
|
-
var rect = root.querySelector('#top-center').getBoundingClientRect();
|
|
483
|
-
var aboveCenterOfGrid = {
|
|
484
|
-
x: rect.left + rect.width / 2,
|
|
485
|
-
y: rect.top - 1
|
|
486
|
-
};
|
|
487
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', aboveCenterOfGrid, _container12.rootContainerId), function (t) {
|
|
488
|
-
return t.id;
|
|
489
|
-
})).toBe('top-center');
|
|
490
|
-
}));
|
|
491
|
-
test('should find target within container from floating element', (0, _utils.testScenario)(scenarios.overlap, function (root) {
|
|
492
|
-
(0, _container12.configureContainer)('grid', {
|
|
493
|
-
enterTo: 'default-element',
|
|
494
|
-
defaultElement: '#bottom-right'
|
|
495
|
-
});
|
|
496
|
-
var overlap = root.querySelector('#over-middle-center');
|
|
497
|
-
|
|
498
|
-
var _overlap$getBoundingC = overlap.getBoundingClientRect(),
|
|
499
|
-
x = _overlap$getBoundingC.left,
|
|
500
|
-
y = _overlap$getBoundingC.top;
|
|
501
|
-
|
|
502
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', {
|
|
503
|
-
x: x,
|
|
504
|
-
y: y
|
|
505
|
-
}, _container12.rootContainerId), function (t) {
|
|
506
|
-
return t.id;
|
|
507
|
-
})).toBe('middle-center');
|
|
508
|
-
}));
|
|
509
|
-
test('should ignore targets outside the bounds of an overflow container', (0, _utils.testScenario)(scenarios.overflow, function (root) {
|
|
510
|
-
(0, _container12.configureContainer)('overflow-container', {
|
|
511
|
-
overflow: true
|
|
512
|
-
});
|
|
513
|
-
var element = root.querySelector('#outside-overflow');
|
|
514
|
-
|
|
515
|
-
var _element$getBoundingC = element.getBoundingClientRect(),
|
|
516
|
-
x = _element$getBoundingC.left,
|
|
517
|
-
y = _element$getBoundingC.top;
|
|
518
|
-
|
|
519
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', {
|
|
520
|
-
x: x,
|
|
521
|
-
y: y
|
|
522
|
-
}, _container12.rootContainerId), function (t) {
|
|
523
|
-
return t.id;
|
|
524
|
-
})).toBe('overflow-within');
|
|
525
|
-
}));
|
|
526
|
-
test('should find target within container larger than overflow container', (0, _utils.testScenario)(scenarios.overflowLargeSubContainer, function (root) {
|
|
527
|
-
(0, _container12.configureContainer)('overflow-container', {
|
|
528
|
-
overflow: true
|
|
529
|
-
});
|
|
530
|
-
(0, _container12.configureContainer)('inside', {
|
|
531
|
-
enterTo: null
|
|
532
|
-
});
|
|
533
|
-
var element = root.querySelector('#outside-overflow');
|
|
534
|
-
|
|
535
|
-
var _element$getBoundingC2 = element.getBoundingClientRect(),
|
|
536
|
-
x = _element$getBoundingC2.left,
|
|
537
|
-
y = _element$getBoundingC2.top;
|
|
538
|
-
|
|
539
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', {
|
|
540
|
-
x: x,
|
|
541
|
-
y: y
|
|
542
|
-
}, _container12.rootContainerId), function (t) {
|
|
543
|
-
return t.id;
|
|
544
|
-
})).toBe('in-large-container');
|
|
545
|
-
}));
|
|
546
|
-
test('should find target out of bounds of overflow container from within container', (0, _utils.testScenario)(scenarios.overflow, function (root) {
|
|
547
|
-
(0, _container12.configureContainer)('overflow-container', {
|
|
548
|
-
overflow: true
|
|
549
|
-
});
|
|
550
|
-
var element = root.querySelector('#overflow-within');
|
|
551
|
-
|
|
552
|
-
var _element$getBoundingC3 = element.getBoundingClientRect(),
|
|
553
|
-
left = _element$getBoundingC3.left,
|
|
554
|
-
width = _element$getBoundingC3.width,
|
|
555
|
-
top = _element$getBoundingC3.top,
|
|
556
|
-
height = _element$getBoundingC3.height;
|
|
557
|
-
|
|
558
|
-
var x = left + width / 2;
|
|
559
|
-
var y = top + height / 2;
|
|
560
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', {
|
|
561
|
-
x: x,
|
|
562
|
-
y: y + 1
|
|
563
|
-
}, _container12.rootContainerId), function (t) {
|
|
564
|
-
return t.id;
|
|
565
|
-
})).toBe('overflow-below');
|
|
566
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', {
|
|
567
|
-
x: x,
|
|
568
|
-
y: y - 1
|
|
569
|
-
}, _container12.rootContainerId), function (t) {
|
|
570
|
-
return t.id;
|
|
571
|
-
})).toBe('overflow-above');
|
|
572
|
-
}));
|
|
573
|
-
test('should ignore empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) {
|
|
574
|
-
(0, _container12.configureContainer)('empty-container');
|
|
575
|
-
var element = root.querySelector('#above');
|
|
576
|
-
|
|
577
|
-
var _element$getBoundingC4 = element.getBoundingClientRect(),
|
|
578
|
-
left = _element$getBoundingC4.left,
|
|
579
|
-
width = _element$getBoundingC4.width,
|
|
580
|
-
top = _element$getBoundingC4.top,
|
|
581
|
-
height = _element$getBoundingC4.height;
|
|
582
|
-
|
|
583
|
-
var x = left + width / 2;
|
|
584
|
-
var y = top + height - 1; // just inside the bottom of 'above'
|
|
585
|
-
|
|
586
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', {
|
|
587
|
-
x: x,
|
|
588
|
-
y: y
|
|
589
|
-
}, _container12.rootContainerId), function (t) {
|
|
590
|
-
return t.id;
|
|
591
|
-
})).toBe('below');
|
|
592
|
-
}));
|
|
593
|
-
test('should ignore overlapping empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) {
|
|
594
|
-
(0, _container12.configureContainer)('empty-container');
|
|
595
|
-
var element = root.querySelector('#above');
|
|
596
|
-
|
|
597
|
-
var _element$getBoundingC5 = element.getBoundingClientRect(),
|
|
598
|
-
left = _element$getBoundingC5.left,
|
|
599
|
-
width = _element$getBoundingC5.width,
|
|
600
|
-
top = _element$getBoundingC5.top,
|
|
601
|
-
height = _element$getBoundingC5.height;
|
|
602
|
-
|
|
603
|
-
var x = left + width / 2;
|
|
604
|
-
var y = top + height + 1; // just inside the empty container
|
|
605
|
-
|
|
606
|
-
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', {
|
|
607
|
-
x: x,
|
|
608
|
-
y: y
|
|
609
|
-
}, _container12.rootContainerId), function (t) {
|
|
610
|
-
return t.id;
|
|
611
|
-
})).toBe('below');
|
|
612
|
-
}));
|
|
613
|
-
});
|
|
614
|
-
});
|