@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,210 +1,221 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _enzyme = require("enzyme");
|
|
4
|
+
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
7
|
+
var _spotlight = _interopRequireDefault(require("../../src/spotlight"));
|
|
8
|
+
|
|
9
|
+
var _pointer = require("../../src/pointer");
|
|
10
|
+
|
|
11
|
+
var _SpotlightContainerDecorator = _interopRequireDefault(require("../SpotlightContainerDecorator"));
|
|
12
|
+
|
|
13
|
+
var _ElementPrototype = _interopRequireDefault(require("./Element.prototype.closest"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
|
+
|
|
17
|
+
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; }
|
|
18
|
+
|
|
19
|
+
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; }
|
|
20
|
+
|
|
21
|
+
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; }
|
|
22
|
+
|
|
23
|
+
describe('SpotlightContainerDecorator', function () {
|
|
24
|
+
var hoverPosition = {
|
|
25
|
+
clientX: 0,
|
|
26
|
+
clientY: 1
|
|
27
|
+
};
|
|
28
|
+
var unhoverPosition = {
|
|
29
|
+
clientX: 0,
|
|
30
|
+
clientY: 0
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var Div = function Div(props) {
|
|
34
|
+
return /*#__PURE__*/_react["default"].createElement("div", props);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
(0, _ElementPrototype["default"])(beforeAll, afterAll);
|
|
38
|
+
beforeEach(function () {
|
|
39
|
+
_spotlight["default"].setActiveContainer(null);
|
|
40
|
+
|
|
41
|
+
(0, _pointer.updatePointerPosition)(0, 0);
|
|
42
|
+
});
|
|
43
|
+
test('should set itself as the active container on mouse enter', function () {
|
|
44
|
+
var Component = (0, _SpotlightContainerDecorator["default"])(Div);
|
|
45
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
46
|
+
spotlightId: "test-container"
|
|
47
|
+
}));
|
|
48
|
+
subject.find(Div).prop('onMouseEnter')(hoverPosition);
|
|
49
|
+
var expected = 'test-container';
|
|
50
|
+
|
|
51
|
+
var actual = _spotlight["default"].getActiveContainer();
|
|
52
|
+
|
|
53
|
+
expect(actual).toBe(expected);
|
|
54
|
+
});
|
|
55
|
+
test('should set active container to parent container on mouse leave', function () {
|
|
56
|
+
var Component = (0, _SpotlightContainerDecorator["default"])(Div);
|
|
57
|
+
var node = document.createElement('div');
|
|
58
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
59
|
+
spotlightId: "outer-container"
|
|
60
|
+
}, /*#__PURE__*/_react["default"].createElement(Component, {
|
|
61
|
+
spotlightId: "inner-container"
|
|
62
|
+
})), {
|
|
63
|
+
attachTo: node
|
|
64
|
+
});
|
|
65
|
+
var selector = 'div[data-spotlight-id="inner-container"]';
|
|
66
|
+
var innerWrapper = subject.find(selector);
|
|
67
|
+
var innerNode = node.querySelector(selector); // set inner-container as active
|
|
68
|
+
|
|
69
|
+
innerWrapper.prop('onMouseEnter')(hoverPosition);
|
|
70
|
+
(0, _pointer.updatePointerPosition)(0, 1); // leave inner-container
|
|
71
|
+
|
|
72
|
+
innerWrapper.prop('onMouseLeave')(_objectSpread(_objectSpread({}, unhoverPosition), {}, {
|
|
73
|
+
currentTarget: innerNode
|
|
74
|
+
}));
|
|
75
|
+
var expected = 'outer-container';
|
|
76
|
+
|
|
77
|
+
var actual = _spotlight["default"].getActiveContainer();
|
|
78
|
+
|
|
79
|
+
expect(actual).toBe(expected);
|
|
80
|
+
});
|
|
81
|
+
test('should not set active container on mouse leave if another container is active', function () {
|
|
82
|
+
var Component = (0, _SpotlightContainerDecorator["default"])(Div);
|
|
83
|
+
var node = document.createElement('div');
|
|
84
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
85
|
+
spotlightId: "outer-container"
|
|
86
|
+
}, /*#__PURE__*/_react["default"].createElement(Component, {
|
|
87
|
+
spotlightId: "inner-container"
|
|
88
|
+
}), /*#__PURE__*/_react["default"].createElement(Component, {
|
|
89
|
+
spotlightId: "self-only-container"
|
|
90
|
+
})), {
|
|
91
|
+
attachTo: node
|
|
92
|
+
});
|
|
93
|
+
var selector = 'div[data-spotlight-id="inner-container"]';
|
|
94
|
+
var innerWrapper = subject.find(selector);
|
|
95
|
+
var innerNode = node.querySelector(selector); // set inner-container as active
|
|
96
|
+
|
|
97
|
+
innerWrapper.prop('onMouseEnter')(hoverPosition);
|
|
98
|
+
(0, _pointer.updatePointerPosition)(0, 1); // set another container to be active
|
|
99
|
+
|
|
100
|
+
_spotlight["default"].setActiveContainer('self-only-container'); // leave inner-container
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
innerWrapper.prop('onMouseLeave')(_objectSpread(_objectSpread({}, unhoverPosition), {}, {
|
|
104
|
+
currentTarget: innerNode
|
|
105
|
+
}));
|
|
106
|
+
var expected = 'self-only-container';
|
|
107
|
+
|
|
108
|
+
var actual = _spotlight["default"].getActiveContainer();
|
|
109
|
+
|
|
110
|
+
expect(actual).toBe(expected);
|
|
111
|
+
});
|
|
112
|
+
test('should forward onFocusCapture events', function () {
|
|
113
|
+
var spy = jest.fn();
|
|
114
|
+
var focus;
|
|
115
|
+
var Component = (0, _SpotlightContainerDecorator["default"])(function (_ref) {
|
|
116
|
+
var onFocusCapture = _ref.onFocusCapture;
|
|
117
|
+
focus = onFocusCapture;
|
|
118
|
+
return /*#__PURE__*/_react["default"].createElement("div", null);
|
|
119
|
+
});
|
|
120
|
+
(0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
121
|
+
onFocusCapture: spy
|
|
122
|
+
}));
|
|
123
|
+
focus({});
|
|
124
|
+
var expected = 1;
|
|
125
|
+
var actual = spy.mock.calls.length;
|
|
126
|
+
expect(actual).toBe(expected);
|
|
127
|
+
});
|
|
128
|
+
test('should suppress onFocusCapture events when spotlightDisabled', function () {
|
|
129
|
+
var spy = jest.fn();
|
|
130
|
+
var focus;
|
|
131
|
+
var Component = (0, _SpotlightContainerDecorator["default"])(function (_ref2) {
|
|
132
|
+
var onFocusCapture = _ref2.onFocusCapture;
|
|
133
|
+
focus = onFocusCapture;
|
|
134
|
+
return /*#__PURE__*/_react["default"].createElement("div", null);
|
|
135
|
+
});
|
|
136
|
+
(0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
137
|
+
onFocusCapture: spy,
|
|
138
|
+
spotlightDisabled: true
|
|
139
|
+
})); // building out the api called on the event object + target
|
|
140
|
+
|
|
141
|
+
focus({
|
|
142
|
+
stopPropagation: function stopPropagation() {
|
|
143
|
+
return true;
|
|
144
|
+
},
|
|
145
|
+
target: {
|
|
146
|
+
blur: function blur() {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
var expected = 0;
|
|
152
|
+
var actual = spy.mock.calls.length;
|
|
153
|
+
expect(actual).toBe(expected);
|
|
154
|
+
});
|
|
155
|
+
test('should forward onBlurCapture events', function () {
|
|
156
|
+
var spy = jest.fn();
|
|
157
|
+
|
|
158
|
+
var _blur;
|
|
159
|
+
|
|
160
|
+
var Component = (0, _SpotlightContainerDecorator["default"])(function (_ref3) {
|
|
161
|
+
var onBlurCapture = _ref3.onBlurCapture;
|
|
162
|
+
_blur = onBlurCapture;
|
|
163
|
+
return /*#__PURE__*/_react["default"].createElement("div", null);
|
|
164
|
+
});
|
|
165
|
+
(0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
166
|
+
onBlurCapture: spy,
|
|
167
|
+
spotlightDisabled: true
|
|
168
|
+
})); // building out the api called on the event object + target
|
|
169
|
+
|
|
170
|
+
_blur({
|
|
171
|
+
stopPropagation: function stopPropagation() {
|
|
172
|
+
return true;
|
|
173
|
+
},
|
|
174
|
+
target: {
|
|
175
|
+
blur: function blur() {
|
|
176
|
+
return _blur({});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
var expected = 1;
|
|
182
|
+
var actual = spy.mock.calls.length;
|
|
183
|
+
expect(actual).toBe(expected);
|
|
184
|
+
});
|
|
185
|
+
test('should suppress onBlurCapture events when focus was suppressed', function () {
|
|
186
|
+
var spy = jest.fn();
|
|
187
|
+
var focus;
|
|
188
|
+
|
|
189
|
+
var _blur2;
|
|
190
|
+
|
|
191
|
+
var Component = (0, _SpotlightContainerDecorator["default"])(function (_ref4) {
|
|
192
|
+
var onBlurCapture = _ref4.onBlurCapture,
|
|
193
|
+
onFocusCapture = _ref4.onFocusCapture;
|
|
194
|
+
_blur2 = onBlurCapture;
|
|
195
|
+
focus = onFocusCapture;
|
|
196
|
+
return /*#__PURE__*/_react["default"].createElement("div", null);
|
|
197
|
+
});
|
|
198
|
+
(0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
199
|
+
onBlurCapture: spy,
|
|
200
|
+
spotlightDisabled: true
|
|
201
|
+
})); // building out the api called on the event object + target
|
|
202
|
+
|
|
203
|
+
focus({
|
|
204
|
+
stopPropagation: function stopPropagation() {
|
|
205
|
+
return true;
|
|
206
|
+
},
|
|
207
|
+
target: {
|
|
208
|
+
// the focus handler calls blur() on the target so we're simulating that here by
|
|
209
|
+
// wiring our onBlurCapture handler directly to the invocation. This isn't a
|
|
210
|
+
// perfect modeling of the system but serves to validate the callback
|
|
211
|
+
// suppression logic.
|
|
212
|
+
blur: function blur() {
|
|
213
|
+
return _blur2({});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
var expected = 0;
|
|
218
|
+
var actual = spy.mock.calls.length;
|
|
219
|
+
expect(actual).toBe(expected);
|
|
220
|
+
});
|
|
221
|
+
});
|