@enact/spotlight 4.7.0 → 4.7.1
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/Accelerator/Accelerator.js +36 -40
- package/CHANGELOG.md +8 -0
- package/README.md +2 -2
- package/SpotlightContainerDecorator/SpotlightContainer.js +1 -2
- package/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +37 -20
- package/SpotlightRootDecorator/SpotlightRootDecorator.js +3 -6
- package/package.json +3 -3
|
@@ -31,6 +31,17 @@ function Accelerator() {
|
|
|
31
31
|
var _this = this;
|
|
32
32
|
var frequency = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [3, 3, 3, 2, 2, 2, 1];
|
|
33
33
|
_classCallCheck(this, Accelerator);
|
|
34
|
+
/**
|
|
35
|
+
* Called with the current keydown event and callback, which will be called when the event is
|
|
36
|
+
* allowed through.
|
|
37
|
+
*
|
|
38
|
+
* @function
|
|
39
|
+
* @param {Object} event - The current event to validate.
|
|
40
|
+
* @param {Function} callback - The callback to execute.
|
|
41
|
+
* @returns {Boolean} `true` if the event was consumed by processKey and callback was not called
|
|
42
|
+
* @public
|
|
43
|
+
* @memberof spotlight/Accelerator.Accelerator.prototype
|
|
44
|
+
*/
|
|
34
45
|
this.processKey = function (event, callback) {
|
|
35
46
|
switch (event.type) {
|
|
36
47
|
case 'keydown':
|
|
@@ -68,6 +79,14 @@ function Accelerator() {
|
|
|
68
79
|
return callback(event);
|
|
69
80
|
}
|
|
70
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* Resets the Accelerator instance to the default values.
|
|
84
|
+
*
|
|
85
|
+
* @function
|
|
86
|
+
* @returns {undefined}
|
|
87
|
+
* @public
|
|
88
|
+
* @memberof spotlight/Accelerator.Accelerator.prototype
|
|
89
|
+
*/
|
|
71
90
|
this.reset = function () {
|
|
72
91
|
_this.skipped = 0;
|
|
73
92
|
_this.time = 0;
|
|
@@ -75,9 +94,25 @@ function Accelerator() {
|
|
|
75
94
|
_this.canceled = false;
|
|
76
95
|
_this.accelerating = false;
|
|
77
96
|
};
|
|
97
|
+
/**
|
|
98
|
+
* Cancels the Accelerator.
|
|
99
|
+
*
|
|
100
|
+
* @function
|
|
101
|
+
* @returns {undefined}
|
|
102
|
+
* @public
|
|
103
|
+
* @memberof spotlight/Accelerator.Accelerator.prototype
|
|
104
|
+
*/
|
|
78
105
|
this.cancel = function () {
|
|
79
106
|
_this.canceled = true;
|
|
80
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* Verifies that the Accelerator is active.
|
|
110
|
+
*
|
|
111
|
+
* @function
|
|
112
|
+
* @returns {Boolean} `true` if the Accelerator is active; otherwise, `false`.
|
|
113
|
+
* @public
|
|
114
|
+
* @memberof spotlight/Accelerator.Accelerator.prototype
|
|
115
|
+
*/
|
|
81
116
|
this.isAccelerating = function () {
|
|
82
117
|
return _this.accelerating;
|
|
83
118
|
};
|
|
@@ -130,46 +165,7 @@ function Accelerator() {
|
|
|
130
165
|
* @public
|
|
131
166
|
*/
|
|
132
167
|
this.frequency = frequency;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Called with the current keydown event and callback, which will be called when the event is
|
|
137
|
-
* allowed through.
|
|
138
|
-
*
|
|
139
|
-
* @function
|
|
140
|
-
* @param {Object} event - The current event to validate.
|
|
141
|
-
* @param {Function} callback - The callback to execute.
|
|
142
|
-
* @returns {Boolean} `true` if the event was consumed by processKey and callback was not called
|
|
143
|
-
* @public
|
|
144
|
-
* @memberof spotlight/Accelerator.Accelerator.prototype
|
|
145
|
-
*/
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Resets the Accelerator instance to the default values.
|
|
149
|
-
*
|
|
150
|
-
* @function
|
|
151
|
-
* @returns {undefined}
|
|
152
|
-
* @public
|
|
153
|
-
* @memberof spotlight/Accelerator.Accelerator.prototype
|
|
154
|
-
*/
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Cancels the Accelerator.
|
|
158
|
-
*
|
|
159
|
-
* @function
|
|
160
|
-
* @returns {undefined}
|
|
161
|
-
* @public
|
|
162
|
-
* @memberof spotlight/Accelerator.Accelerator.prototype
|
|
163
|
-
*/
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Verifies that the Accelerator is active.
|
|
167
|
-
*
|
|
168
|
-
* @function
|
|
169
|
-
* @returns {Boolean} `true` if the Accelerator is active; otherwise, `false`.
|
|
170
|
-
* @public
|
|
171
|
-
* @memberof spotlight/Accelerator.Accelerator.prototype
|
|
172
|
-
*/);
|
|
168
|
+
});
|
|
173
169
|
exports.Accelerator = Accelerator;
|
|
174
170
|
var _default = Accelerator;
|
|
175
171
|
exports["default"] = _default;
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
The following is a curated list of changes in the Enact spotlight module, newest changes on the top.
|
|
4
4
|
|
|
5
|
+
## [4.7.1] - 2023-06-02
|
|
6
|
+
|
|
7
|
+
No significant changes.
|
|
8
|
+
|
|
9
|
+
## [4.5.3] - 2023-04-06
|
|
10
|
+
|
|
11
|
+
No significant changes.
|
|
12
|
+
|
|
5
13
|
## [4.7.0] - 2023-04-25
|
|
6
14
|
|
|
7
15
|
### Fixed
|
package/README.md
CHANGED
|
@@ -30,8 +30,8 @@ See the [docs](docs/) for more information.
|
|
|
30
30
|
|
|
31
31
|
## Additional Information
|
|
32
32
|
|
|
33
|
-
When using `@enact/
|
|
34
|
-
|
|
33
|
+
When using `@enact/sandstone`, the `SpotlightRootDecorator` is applied automatically by
|
|
34
|
+
`@enact/sandstone/ThemeDecorator`.
|
|
35
35
|
|
|
36
36
|
## Acknowledgments
|
|
37
37
|
|
|
@@ -20,14 +20,13 @@ var isNewPointerPosition = function isNewPointerPosition(ev) {
|
|
|
20
20
|
return (0, _pointer.hasPointerMoved)(ev.clientX, ev.clientY);
|
|
21
21
|
};
|
|
22
22
|
var SpotlightContainer = /*#__PURE__*/function () {
|
|
23
|
-
// set up context and props so we can use handle binding
|
|
24
|
-
|
|
25
23
|
function SpotlightContainer(_ref) {
|
|
26
24
|
var _this = this;
|
|
27
25
|
var containerConfig = _ref.containerConfig,
|
|
28
26
|
navigableFilter = _ref.navigableFilter,
|
|
29
27
|
preserveId = _ref.preserveId;
|
|
30
28
|
_classCallCheck(this, SpotlightContainer);
|
|
29
|
+
// set up context and props so we can use handle binding
|
|
31
30
|
this.context = {};
|
|
32
31
|
this.props = {};
|
|
33
32
|
this.navigableFilter = function (elem) {
|
|
@@ -9,6 +9,8 @@ var _spotlight = _interopRequireDefault(require("../../src/spotlight"));
|
|
|
9
9
|
var _ElementPrototype = _interopRequireDefault(require("./Element.prototype.closest"));
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
13
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
12
14
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
15
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
16
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -32,21 +34,26 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
32
34
|
_spotlight["default"].setActiveContainer(null);
|
|
33
35
|
(0, _pointer.updatePointerPosition)(0, 0);
|
|
34
36
|
});
|
|
35
|
-
test('should set itself as the active container on mouse enter', function () {
|
|
37
|
+
test('should set itself as the active container on mouse enter', /*#__PURE__*/_asyncToGenerator(function* () {
|
|
36
38
|
var Component = (0, _SpotlightContainerDecorator["default"])(Div);
|
|
39
|
+
var user = _userEvent["default"].setup();
|
|
37
40
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
38
41
|
"data-testid": testId,
|
|
39
42
|
spotlightId: "test-container"
|
|
40
43
|
}));
|
|
41
44
|
var component = _react.screen.getByTestId(testId);
|
|
42
|
-
|
|
45
|
+
yield user.pointer({
|
|
46
|
+
target: component,
|
|
47
|
+
coords: hoverPosition
|
|
48
|
+
});
|
|
43
49
|
var expected = 'test-container';
|
|
44
50
|
var actual = _spotlight["default"].getActiveContainer();
|
|
45
51
|
expect(actual).toBe(expected);
|
|
46
|
-
});
|
|
47
|
-
test('should set active container to parent container on mouse leave', function () {
|
|
52
|
+
}));
|
|
53
|
+
test('should set active container to parent container on mouse leave', /*#__PURE__*/_asyncToGenerator(function* () {
|
|
48
54
|
var Component = (0, _SpotlightContainerDecorator["default"])(Div);
|
|
49
55
|
var node = document.createElement('div');
|
|
56
|
+
var user = _userEvent["default"].setup();
|
|
50
57
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
51
58
|
spotlightId: "outer-container",
|
|
52
59
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
@@ -59,18 +66,25 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
59
66
|
var component = _react.screen.getByTestId(testId);
|
|
60
67
|
|
|
61
68
|
// set inner-container as active
|
|
62
|
-
|
|
69
|
+
yield user.pointer({
|
|
70
|
+
target: component,
|
|
71
|
+
coords: hoverPosition
|
|
72
|
+
});
|
|
63
73
|
(0, _pointer.updatePointerPosition)(0, 1);
|
|
64
74
|
|
|
65
75
|
// leave inner-container
|
|
66
|
-
|
|
76
|
+
yield user.pointer({
|
|
77
|
+
target: component.parentNode,
|
|
78
|
+
coords: unhoverPosition
|
|
79
|
+
});
|
|
67
80
|
var expected = 'outer-container';
|
|
68
81
|
var actual = _spotlight["default"].getActiveContainer();
|
|
69
82
|
expect(actual).toBe(expected);
|
|
70
|
-
});
|
|
71
|
-
test('should not set active container on mouse leave if another container is active', function () {
|
|
83
|
+
}));
|
|
84
|
+
test('should not set active container on mouse leave if another container is active', /*#__PURE__*/_asyncToGenerator(function* () {
|
|
72
85
|
var Component = (0, _SpotlightContainerDecorator["default"])(Div);
|
|
73
86
|
var node = document.createElement('div');
|
|
87
|
+
var user = _userEvent["default"].setup();
|
|
74
88
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
75
89
|
spotlightId: "outer-container",
|
|
76
90
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
@@ -85,23 +99,26 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
85
99
|
var component = _react.screen.getByTestId(testId);
|
|
86
100
|
|
|
87
101
|
// set inner-container as active
|
|
88
|
-
|
|
102
|
+
yield user.pointer({
|
|
103
|
+
target: component,
|
|
104
|
+
coords: hoverPosition
|
|
105
|
+
});
|
|
89
106
|
(0, _pointer.updatePointerPosition)(0, 1);
|
|
90
107
|
|
|
91
108
|
// set another container to be active
|
|
92
109
|
_spotlight["default"].setActiveContainer('self-only-container');
|
|
93
110
|
|
|
94
111
|
// leave inner-container
|
|
95
|
-
|
|
112
|
+
yield user.unhover(component);
|
|
96
113
|
var expected = 'self-only-container';
|
|
97
114
|
var actual = _spotlight["default"].getActiveContainer();
|
|
98
115
|
expect(actual).toBe(expected);
|
|
99
|
-
});
|
|
116
|
+
}));
|
|
100
117
|
test('should forward onFocusCapture events', function () {
|
|
101
118
|
var spy = jest.fn();
|
|
102
119
|
var focus;
|
|
103
|
-
var Component = (0, _SpotlightContainerDecorator["default"])(function (
|
|
104
|
-
var onFocusCapture =
|
|
120
|
+
var Component = (0, _SpotlightContainerDecorator["default"])(function (_ref4) {
|
|
121
|
+
var onFocusCapture = _ref4.onFocusCapture;
|
|
105
122
|
focus = onFocusCapture;
|
|
106
123
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
|
|
107
124
|
});
|
|
@@ -115,8 +132,8 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
115
132
|
test('should suppress onFocusCapture events when spotlightDisabled', function () {
|
|
116
133
|
var spy = jest.fn();
|
|
117
134
|
var focus;
|
|
118
|
-
var Component = (0, _SpotlightContainerDecorator["default"])(function (
|
|
119
|
-
var onFocusCapture =
|
|
135
|
+
var Component = (0, _SpotlightContainerDecorator["default"])(function (_ref5) {
|
|
136
|
+
var onFocusCapture = _ref5.onFocusCapture;
|
|
120
137
|
focus = onFocusCapture;
|
|
121
138
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
|
|
122
139
|
});
|
|
@@ -141,8 +158,8 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
141
158
|
test('should forward onBlurCapture events', function () {
|
|
142
159
|
var spy = jest.fn();
|
|
143
160
|
var _blur;
|
|
144
|
-
var Component = (0, _SpotlightContainerDecorator["default"])(function (
|
|
145
|
-
var onBlurCapture =
|
|
161
|
+
var Component = (0, _SpotlightContainerDecorator["default"])(function (_ref6) {
|
|
162
|
+
var onBlurCapture = _ref6.onBlurCapture;
|
|
146
163
|
_blur = onBlurCapture;
|
|
147
164
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
|
|
148
165
|
});
|
|
@@ -169,9 +186,9 @@ describe('SpotlightContainerDecorator', function () {
|
|
|
169
186
|
var spy = jest.fn();
|
|
170
187
|
var _blur2;
|
|
171
188
|
var focus;
|
|
172
|
-
var Component = (0, _SpotlightContainerDecorator["default"])(function (
|
|
173
|
-
var onBlurCapture =
|
|
174
|
-
onFocusCapture =
|
|
189
|
+
var Component = (0, _SpotlightContainerDecorator["default"])(function (_ref7) {
|
|
190
|
+
var onBlurCapture = _ref7.onBlurCapture,
|
|
191
|
+
onFocusCapture = _ref7.onFocusCapture;
|
|
175
192
|
_blur2 = onBlurCapture;
|
|
176
193
|
focus = onFocusCapture;
|
|
177
194
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
|
|
@@ -126,6 +126,7 @@ var SpotlightRootDecorator = (0, _hoc["default"])(defaultConfig, function (confi
|
|
|
126
126
|
_this.applyInputType();
|
|
127
127
|
}
|
|
128
128
|
};
|
|
129
|
+
// For key input
|
|
129
130
|
_this.handleKeyDown = function (ev) {
|
|
130
131
|
var keyCode = ev.keyCode;
|
|
131
132
|
if ((0, _keymap.is)('enter', keyCode) && _this.containerNode.classList.contains('spotlight-input-touch')) {
|
|
@@ -139,12 +140,14 @@ var SpotlightRootDecorator = (0, _hoc["default"])(defaultConfig, function (confi
|
|
|
139
140
|
_this.applyInputType();
|
|
140
141
|
}, 0);
|
|
141
142
|
};
|
|
143
|
+
// For mouse input
|
|
142
144
|
_this.handlePointerMove = function (ev) {
|
|
143
145
|
if (ev.pointerType === 'mouse') {
|
|
144
146
|
setInputType('mouse');
|
|
145
147
|
_this.applyInputType();
|
|
146
148
|
}
|
|
147
149
|
};
|
|
150
|
+
// For touch input
|
|
148
151
|
_this.handlePointerOver = function (ev) {
|
|
149
152
|
if (ev.pointerType === 'touch') {
|
|
150
153
|
setInputType('touch');
|
|
@@ -216,12 +219,6 @@ var SpotlightRootDecorator = (0, _hoc["default"])(defaultConfig, function (confi
|
|
|
216
219
|
});
|
|
217
220
|
}
|
|
218
221
|
}
|
|
219
|
-
|
|
220
|
-
// For key input
|
|
221
|
-
|
|
222
|
-
// For mouse input
|
|
223
|
-
|
|
224
|
-
// For touch input
|
|
225
222
|
}, {
|
|
226
223
|
key: "render",
|
|
227
224
|
value: function render() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enact/spotlight",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.1",
|
|
4
4
|
"description": "A focus management library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@enact/core": "^4.7.
|
|
27
|
+
"@enact/core": "^4.7.1",
|
|
28
28
|
"classnames": "^2.3.2",
|
|
29
29
|
"prop-types": "^15.8.1",
|
|
30
|
-
"ramda": "^0.
|
|
30
|
+
"ramda": "^0.29.0",
|
|
31
31
|
"react": "^18.2.0",
|
|
32
32
|
"react-dom": "^18.2.0",
|
|
33
33
|
"warning": "^4.0.3"
|