@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,253 +1,160 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import Spotlight from '../../src/spotlight';
|
|
6
|
-
import {getContainerConfig} from '../../src/container';
|
|
3
|
+
var _enzyme = require("enzyme");
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
return getContainerConfig(id) != null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
describe('useSpotlightContainer', () => {
|
|
15
|
-
|
|
16
|
-
// TODO: Test lifecycle (e.g unload, preserveId)
|
|
17
|
-
|
|
18
|
-
function Component (props) {
|
|
19
|
-
const {
|
|
20
|
-
containerConfig,
|
|
21
|
-
preserveId,
|
|
22
|
-
spotlightDisabled,
|
|
23
|
-
spotlightId,
|
|
24
|
-
spotlightMuted,
|
|
25
|
-
spotlightRestrict,
|
|
26
|
-
...rest
|
|
27
|
-
} = props;
|
|
28
|
-
|
|
29
|
-
const spotlightContainer = useSpotlightContainer({
|
|
30
|
-
id: spotlightId,
|
|
31
|
-
muted: spotlightMuted,
|
|
32
|
-
disabled: spotlightDisabled,
|
|
33
|
-
restrict: spotlightRestrict,
|
|
34
|
-
|
|
35
|
-
// continue5WayHold, defaultElement, and enterTo can be in the containerConfig object
|
|
36
|
-
containerConfig,
|
|
37
|
-
preserveId
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<div
|
|
42
|
-
{...rest}
|
|
43
|
-
{...spotlightContainer.attributes}
|
|
44
|
-
/>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// remove all containers after each test
|
|
49
|
-
afterEach(Spotlight.clear);
|
|
50
|
-
|
|
51
|
-
test('should support omitting the config object', () => {
|
|
52
|
-
function Comp (props) {
|
|
53
|
-
const spotlightContainer = useSpotlightContainer();
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<div {...props} {...spotlightContainer.attributes} />
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const subject = shallow(
|
|
61
|
-
<Comp />
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
const expected = true;
|
|
65
|
-
const actual = subject.prop('data-spotlight-container');
|
|
66
|
-
|
|
67
|
-
expect(actual).toBe(expected);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
describe('attributes', () => {
|
|
71
|
-
test(
|
|
72
|
-
'should set `data-spotlight-container` attribute',
|
|
73
|
-
() => {
|
|
74
|
-
const subject = shallow(
|
|
75
|
-
<Component />
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const expected = true;
|
|
79
|
-
const actual = subject.prop('data-spotlight-container');
|
|
80
|
-
|
|
81
|
-
expect(actual).toBe(expected);
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
test(
|
|
86
|
-
'should generate a `data-spotlight-id` attribute when `id` is unset',
|
|
87
|
-
() => {
|
|
88
|
-
const subject = shallow(
|
|
89
|
-
<Component />
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
const expected = /container-\d+/;
|
|
93
|
-
const actual = subject.prop('data-spotlight-id');
|
|
94
|
-
|
|
95
|
-
expect(actual).toMatch(expected);
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
test(
|
|
100
|
-
'should reuse the same generated `data-spotlight-id` attribute on re-render',
|
|
101
|
-
() => {
|
|
102
|
-
const subject = shallow(
|
|
103
|
-
<Component />
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
const expected = subject.prop('data-spotlight-id');
|
|
107
|
-
|
|
108
|
-
subject.setProps({});
|
|
109
|
-
|
|
110
|
-
const actual = subject.prop('data-spotlight-id');
|
|
111
|
-
|
|
112
|
-
expect(actual).toMatch(expected);
|
|
113
|
-
}
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
test(
|
|
117
|
-
'should set a `data-spotlight-id` attribute when `id` is set',
|
|
118
|
-
() => {
|
|
119
|
-
const id = 'my-container';
|
|
120
|
-
const subject = shallow(
|
|
121
|
-
<Component spotlightId={id} />
|
|
122
|
-
);
|
|
7
|
+
var _spotlight = _interopRequireDefault(require("../../src/spotlight"));
|
|
123
8
|
|
|
124
|
-
|
|
125
|
-
const actual = subject.prop('data-spotlight-id');
|
|
9
|
+
var _container = require("../../src/container");
|
|
126
10
|
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
);
|
|
11
|
+
var _useSpotlightContainer = _interopRequireDefault(require("../useSpotlightContainer"));
|
|
130
12
|
|
|
131
|
-
|
|
132
|
-
'should set `data-spotlight-container-disabled` attribute to be falsey when `disabled` is unset',
|
|
133
|
-
() => {
|
|
134
|
-
const subject = shallow(
|
|
135
|
-
<Component />
|
|
136
|
-
);
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
137
14
|
|
|
138
|
-
|
|
15
|
+
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; }
|
|
139
16
|
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
);
|
|
17
|
+
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; }
|
|
143
18
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const subject = shallow(
|
|
148
|
-
<Component spotlightDisabled />
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
const expected = true;
|
|
152
|
-
const actual = subject.prop('data-spotlight-container-disabled');
|
|
153
|
-
|
|
154
|
-
expect(actual).toBe(expected);
|
|
155
|
-
}
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
test(
|
|
159
|
-
'should set `data-spotlight-container-muted` attribute to be falsey when `muted` is unset',
|
|
160
|
-
() => {
|
|
161
|
-
const subject = shallow(
|
|
162
|
-
<Component />
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
const actual = subject.prop('data-spotlight-container-muted');
|
|
166
|
-
|
|
167
|
-
expect(actual).toBeFalsy();
|
|
168
|
-
}
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
test(
|
|
172
|
-
'should set `data-spotlight-container-muted` attribute when `muted` is set',
|
|
173
|
-
() => {
|
|
174
|
-
const subject = shallow(
|
|
175
|
-
<Component spotlightMuted />
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
const expected = true;
|
|
179
|
-
const actual = subject.prop('data-spotlight-container-muted');
|
|
180
|
-
|
|
181
|
-
expect(actual).toBe(expected);
|
|
182
|
-
}
|
|
183
|
-
);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
describe('Spotlight configuration', () => {
|
|
187
|
-
test(
|
|
188
|
-
'should create a new container with the specified id',
|
|
189
|
-
() => {
|
|
190
|
-
const id = 'my-container';
|
|
191
|
-
|
|
192
|
-
expect(containerExists(id)).toBeFalsy();
|
|
193
|
-
|
|
194
|
-
shallow(
|
|
195
|
-
<Component spotlightId={id} />
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
const expected = true;
|
|
199
|
-
const actual = containerExists(id);
|
|
200
|
-
|
|
201
|
-
expect(actual).toBe(expected);
|
|
202
|
-
}
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
test(
|
|
206
|
-
'should configure a new container with the specified id',
|
|
207
|
-
() => {
|
|
208
|
-
const id = 'my-container';
|
|
209
|
-
|
|
210
|
-
expect(containerExists(id)).toBeFalsy();
|
|
211
|
-
|
|
212
|
-
const config = {
|
|
213
|
-
restrict: 'self-only',
|
|
214
|
-
defaultElement: 'my-element'
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
shallow(
|
|
218
|
-
<Component
|
|
219
|
-
spotlightId={id}
|
|
220
|
-
spotlightRestrict={config.restrict}
|
|
221
|
-
containerConfig={{defaultElement: config.defaultElement}}
|
|
222
|
-
/>
|
|
223
|
-
);
|
|
224
|
-
|
|
225
|
-
const expected = config;
|
|
226
|
-
const actual = getContainerConfig(id);
|
|
227
|
-
|
|
228
|
-
expect(actual).toMatchObject(expected);
|
|
229
|
-
}
|
|
230
|
-
);
|
|
231
|
-
|
|
232
|
-
test(
|
|
233
|
-
'should update restrict value',
|
|
234
|
-
() => {
|
|
235
|
-
const id = 'my-container';
|
|
236
|
-
const subject = shallow(
|
|
237
|
-
<Component
|
|
238
|
-
spotlightId={id}
|
|
239
|
-
spotlightRestrict="self-only"
|
|
240
|
-
/>
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
subject.setProps({spotlightRestrict: 'self-first'});
|
|
244
|
-
|
|
245
|
-
const expected = {restrict: 'self-first'};
|
|
246
|
-
const actual = getContainerConfig(id);
|
|
247
|
-
|
|
248
|
-
expect(actual).toMatchObject(expected);
|
|
249
|
-
}
|
|
250
|
-
);
|
|
251
|
-
});
|
|
252
|
-
});
|
|
19
|
+
function containerExists(id) {
|
|
20
|
+
return (0, _container.getContainerConfig)(id) != null;
|
|
21
|
+
}
|
|
253
22
|
|
|
23
|
+
describe('useSpotlightContainer', function () {
|
|
24
|
+
// TODO: Test lifecycle (e.g unload, preserveId)
|
|
25
|
+
function Component(props) {
|
|
26
|
+
var containerConfig = props.containerConfig,
|
|
27
|
+
preserveId = props.preserveId,
|
|
28
|
+
spotlightDisabled = props.spotlightDisabled,
|
|
29
|
+
spotlightId = props.spotlightId,
|
|
30
|
+
spotlightMuted = props.spotlightMuted,
|
|
31
|
+
spotlightRestrict = props.spotlightRestrict,
|
|
32
|
+
rest = _objectWithoutProperties(props, ["containerConfig", "preserveId", "spotlightDisabled", "spotlightId", "spotlightMuted", "spotlightRestrict"]);
|
|
33
|
+
|
|
34
|
+
var spotlightContainer = (0, _useSpotlightContainer["default"])({
|
|
35
|
+
id: spotlightId,
|
|
36
|
+
muted: spotlightMuted,
|
|
37
|
+
disabled: spotlightDisabled,
|
|
38
|
+
restrict: spotlightRestrict,
|
|
39
|
+
// continue5WayHold, defaultElement, and enterTo can be in the containerConfig object
|
|
40
|
+
containerConfig: containerConfig,
|
|
41
|
+
preserveId: preserveId
|
|
42
|
+
});
|
|
43
|
+
return /*#__PURE__*/_react["default"].createElement("div", Object.assign({}, rest, spotlightContainer.attributes));
|
|
44
|
+
} // remove all containers after each test
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
afterEach(_spotlight["default"].clear);
|
|
48
|
+
test('should support omitting the config object', function () {
|
|
49
|
+
function Comp(props) {
|
|
50
|
+
var spotlightContainer = (0, _useSpotlightContainer["default"])();
|
|
51
|
+
return /*#__PURE__*/_react["default"].createElement("div", Object.assign({}, props, spotlightContainer.attributes));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Comp, null));
|
|
55
|
+
var expected = true;
|
|
56
|
+
var actual = subject.prop('data-spotlight-container');
|
|
57
|
+
expect(actual).toBe(expected);
|
|
58
|
+
});
|
|
59
|
+
describe('attributes', function () {
|
|
60
|
+
test('should set `data-spotlight-container` attribute', function () {
|
|
61
|
+
var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
|
|
62
|
+
var expected = true;
|
|
63
|
+
var actual = subject.prop('data-spotlight-container');
|
|
64
|
+
expect(actual).toBe(expected);
|
|
65
|
+
});
|
|
66
|
+
test('should generate a `data-spotlight-id` attribute when `id` is unset', function () {
|
|
67
|
+
var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
|
|
68
|
+
var expected = /container-\d+/;
|
|
69
|
+
var actual = subject.prop('data-spotlight-id');
|
|
70
|
+
expect(actual).toMatch(expected);
|
|
71
|
+
});
|
|
72
|
+
test('should reuse the same generated `data-spotlight-id` attribute on re-render', function () {
|
|
73
|
+
var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
|
|
74
|
+
var expected = subject.prop('data-spotlight-id');
|
|
75
|
+
subject.setProps({});
|
|
76
|
+
var actual = subject.prop('data-spotlight-id');
|
|
77
|
+
expect(actual).toMatch(expected);
|
|
78
|
+
});
|
|
79
|
+
test('should set a `data-spotlight-id` attribute when `id` is set', function () {
|
|
80
|
+
var id = 'my-container';
|
|
81
|
+
var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
82
|
+
spotlightId: id
|
|
83
|
+
}));
|
|
84
|
+
var expected = id;
|
|
85
|
+
var actual = subject.prop('data-spotlight-id');
|
|
86
|
+
expect(actual).toBe(expected);
|
|
87
|
+
});
|
|
88
|
+
test('should set `data-spotlight-container-disabled` attribute to be falsey when `disabled` is unset', function () {
|
|
89
|
+
var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
|
|
90
|
+
var actual = subject.prop('data-spotlight-container-disabled');
|
|
91
|
+
expect(actual).toBeFalsy();
|
|
92
|
+
});
|
|
93
|
+
test('should set `data-spotlight-container-disabled` attribute when `disabled` is set', function () {
|
|
94
|
+
var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
95
|
+
spotlightDisabled: true
|
|
96
|
+
}));
|
|
97
|
+
var expected = true;
|
|
98
|
+
var actual = subject.prop('data-spotlight-container-disabled');
|
|
99
|
+
expect(actual).toBe(expected);
|
|
100
|
+
});
|
|
101
|
+
test('should set `data-spotlight-container-muted` attribute to be falsey when `muted` is unset', function () {
|
|
102
|
+
var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
|
|
103
|
+
var actual = subject.prop('data-spotlight-container-muted');
|
|
104
|
+
expect(actual).toBeFalsy();
|
|
105
|
+
});
|
|
106
|
+
test('should set `data-spotlight-container-muted` attribute when `muted` is set', function () {
|
|
107
|
+
var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
108
|
+
spotlightMuted: true
|
|
109
|
+
}));
|
|
110
|
+
var expected = true;
|
|
111
|
+
var actual = subject.prop('data-spotlight-container-muted');
|
|
112
|
+
expect(actual).toBe(expected);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
describe('Spotlight configuration', function () {
|
|
116
|
+
test('should create a new container with the specified id', function () {
|
|
117
|
+
var id = 'my-container';
|
|
118
|
+
expect(containerExists(id)).toBeFalsy();
|
|
119
|
+
(0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
120
|
+
spotlightId: id
|
|
121
|
+
}));
|
|
122
|
+
var expected = true;
|
|
123
|
+
var actual = containerExists(id);
|
|
124
|
+
expect(actual).toBe(expected);
|
|
125
|
+
});
|
|
126
|
+
test('should configure a new container with the specified id', function () {
|
|
127
|
+
var id = 'my-container';
|
|
128
|
+
expect(containerExists(id)).toBeFalsy();
|
|
129
|
+
var config = {
|
|
130
|
+
restrict: 'self-only',
|
|
131
|
+
defaultElement: 'my-element'
|
|
132
|
+
};
|
|
133
|
+
(0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
134
|
+
spotlightId: id,
|
|
135
|
+
spotlightRestrict: config.restrict,
|
|
136
|
+
containerConfig: {
|
|
137
|
+
defaultElement: config.defaultElement
|
|
138
|
+
}
|
|
139
|
+
}));
|
|
140
|
+
var expected = config;
|
|
141
|
+
var actual = (0, _container.getContainerConfig)(id);
|
|
142
|
+
expect(actual).toMatchObject(expected);
|
|
143
|
+
});
|
|
144
|
+
test('should update restrict value', function () {
|
|
145
|
+
var id = 'my-container';
|
|
146
|
+
var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
147
|
+
spotlightId: id,
|
|
148
|
+
spotlightRestrict: "self-only"
|
|
149
|
+
}));
|
|
150
|
+
subject.setProps({
|
|
151
|
+
spotlightRestrict: 'self-first'
|
|
152
|
+
});
|
|
153
|
+
var expected = {
|
|
154
|
+
restrict: 'self-first'
|
|
155
|
+
};
|
|
156
|
+
var actual = (0, _container.getContainerConfig)(id);
|
|
157
|
+
expect(actual).toMatchObject(expected);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
});
|
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
import React from 'react';
|
|
1
|
+
"use strict";
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSpotlightContainer = useSpotlightContainer;
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
|
|
9
|
+
var _useClass = _interopRequireDefault(require("@enact/core/useClass"));
|
|
10
|
+
|
|
11
|
+
var _react = _interopRequireDefault(require("react"));
|
|
12
|
+
|
|
13
|
+
var _SpotlightContainer = _interopRequireDefault(require("./SpotlightContainer"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
|
+
|
|
17
|
+
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; }
|
|
18
|
+
|
|
19
|
+
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; }
|
|
5
20
|
|
|
6
21
|
/**
|
|
7
22
|
* Configuration for `useSpotlightContainer`
|
|
@@ -82,33 +97,37 @@ import SpotlightContainer from './SpotlightContainer';
|
|
|
82
97
|
* @returns {useSpotlightContainerInterface}
|
|
83
98
|
* @private
|
|
84
99
|
*/
|
|
85
|
-
function useSpotlightContainer
|
|
86
|
-
|
|
100
|
+
function useSpotlightContainer() {
|
|
101
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
102
|
+
|
|
103
|
+
var disabled = config.disabled,
|
|
104
|
+
id = config.id,
|
|
105
|
+
muted = config.muted,
|
|
106
|
+
restrict = config.restrict,
|
|
107
|
+
rest = _objectWithoutProperties(config, ["disabled", "id", "muted", "restrict"]);
|
|
87
108
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
109
|
+
var spotlightContainer = (0, _useClass["default"])(_SpotlightContainer["default"], rest);
|
|
110
|
+
spotlightContainer.setProps({
|
|
111
|
+
disabled: disabled,
|
|
112
|
+
id: id,
|
|
113
|
+
muted: muted,
|
|
114
|
+
restrict: restrict
|
|
115
|
+
});
|
|
95
116
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
117
|
+
_react["default"].useEffect(function () {
|
|
118
|
+
return function () {
|
|
119
|
+
spotlightContainer.unload();
|
|
120
|
+
};
|
|
121
|
+
}, [spotlightContainer]);
|
|
101
122
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
123
|
+
return {
|
|
124
|
+
attributes: spotlightContainer.attributes,
|
|
125
|
+
onBlurCapture: spotlightContainer.onBlurCapture,
|
|
126
|
+
onFocusCapture: spotlightContainer.onFocusCapture,
|
|
127
|
+
onPointerEnter: spotlightContainer.onPointerEnter,
|
|
128
|
+
onPointerLeave: spotlightContainer.onPointerLeave
|
|
129
|
+
};
|
|
109
130
|
}
|
|
110
131
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
useSpotlightContainer
|
|
114
|
-
};
|
|
132
|
+
var _default = useSpotlightContainer;
|
|
133
|
+
exports["default"] = _default;
|
|
File without changes
|