@enact/spotlight 4.9.0-alpha.2 → 4.9.0-beta.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/CHANGELOG.md +14 -0
- package/Spottable/Spottable.js +26 -36
- package/Spottable/tests/useSpot-specs.js +13 -46
- package/Spottable/useSpottable.js +5 -5
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
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.9.0-beta.1] - 2024-06-17
|
|
6
|
+
|
|
7
|
+
No significant changes.
|
|
8
|
+
|
|
9
|
+
## [4.9.0-alpha.3] - 2024-06-05
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- `spotlight/Spottable` to have sibling DOM node as alternative to findDOMNode API which will be removed in React 19
|
|
14
|
+
|
|
15
|
+
## [4.0.15] - 2024-05-28
|
|
16
|
+
|
|
17
|
+
No significant changes.
|
|
18
|
+
|
|
5
19
|
## [4.9.0-alpha.2] - 2024-05-24
|
|
6
20
|
|
|
7
21
|
No significant changes.
|
package/Spottable/Spottable.js
CHANGED
|
@@ -19,14 +19,13 @@ Object.defineProperty(exports, "useSpottable", {
|
|
|
19
19
|
var _handle = _interopRequireWildcard(require("@enact/core/handle"));
|
|
20
20
|
var _useHandlers = _interopRequireDefault(require("@enact/core/useHandlers"));
|
|
21
21
|
var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
|
|
22
|
-
var
|
|
22
|
+
var _WithRef = require("@enact/core/internal/WithRef");
|
|
23
23
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
24
|
-
var
|
|
24
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
25
25
|
var _react = require("react");
|
|
26
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
27
26
|
var _useSpottable = require("./useSpottable");
|
|
28
27
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
|
-
var _excluded = ["className", "disabled", "handleForceUpdate", "onSpotlightDisappear", "onSpotlightDown", "onSpotlightLeft", "onSpotlightRight", "onSpotlightUp", "selectionKeys", "spotlightDisabled", "spotlightId"
|
|
28
|
+
var _excluded = ["className", "disabled", "handleForceUpdate", "onSpotlightDisappear", "onSpotlightDown", "onSpotlightLeft", "onSpotlightRight", "onSpotlightUp", "selectionKeys", "spotlightDisabled", "spotlightId"];
|
|
30
29
|
/**
|
|
31
30
|
* Adds spottability to components.
|
|
32
31
|
*
|
|
@@ -124,7 +123,9 @@ var defaultConfig = {
|
|
|
124
123
|
*/
|
|
125
124
|
var Spottable = exports.Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
|
|
126
125
|
var emulateMouse = config.emulateMouse;
|
|
126
|
+
var WrappedWithRef = (0, _WithRef.WithRef)(Wrapped);
|
|
127
127
|
function SpottableBase(props) {
|
|
128
|
+
var nodeRef = (0, _react.useRef)();
|
|
128
129
|
var className = props.className,
|
|
129
130
|
disabled = props.disabled,
|
|
130
131
|
handleForceUpdate = props.handleForceUpdate,
|
|
@@ -136,11 +137,14 @@ var Spottable = exports.Spottable = (0, _hoc["default"])(defaultConfig, function
|
|
|
136
137
|
selectionKeys = props.selectionKeys,
|
|
137
138
|
spotlightDisabled = props.spotlightDisabled,
|
|
138
139
|
spotlightId = props.spotlightId,
|
|
139
|
-
spotRef = props.spotRef,
|
|
140
140
|
rest = _objectWithoutProperties(props, _excluded);
|
|
141
|
+
var getSpotRef = (0, _react.useCallback)(function () {
|
|
142
|
+
return nodeRef.current;
|
|
143
|
+
}, []);
|
|
141
144
|
var spot = (0, _useSpottable.useSpottable)({
|
|
142
145
|
disabled: disabled,
|
|
143
146
|
emulateMouse: emulateMouse,
|
|
147
|
+
getSpotRef: getSpotRef,
|
|
144
148
|
handleForceUpdate: handleForceUpdate,
|
|
145
149
|
onSelectionCancel: rest.onMouseUp,
|
|
146
150
|
onSpotlightDisappear: onSpotlightDisappear,
|
|
@@ -150,8 +154,7 @@ var Spottable = exports.Spottable = (0, _hoc["default"])(defaultConfig, function
|
|
|
150
154
|
onSpotlightUp: onSpotlightUp,
|
|
151
155
|
selectionKeys: selectionKeys,
|
|
152
156
|
spotlightDisabled: spotlightDisabled,
|
|
153
|
-
spotlightId: spotlightId
|
|
154
|
-
spotRef: spotRef
|
|
157
|
+
spotlightId: spotlightId
|
|
155
158
|
});
|
|
156
159
|
var tabIndex = rest.tabIndex;
|
|
157
160
|
if (tabIndex == null) {
|
|
@@ -160,9 +163,11 @@ var Spottable = exports.Spottable = (0, _hoc["default"])(defaultConfig, function
|
|
|
160
163
|
rest.tabIndex = tabIndex;
|
|
161
164
|
var handlers = (0, _useHandlers["default"])(spotHandlers, rest, spot);
|
|
162
165
|
delete rest.spotlightId;
|
|
163
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
166
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedWithRef, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, rest), spot.attributes), handlers), {}, {
|
|
164
167
|
className: (0, _classnames["default"])(className, spot.className),
|
|
165
|
-
disabled: disabled
|
|
168
|
+
disabled: disabled,
|
|
169
|
+
outermostRef: nodeRef,
|
|
170
|
+
referrerName: "Spottable"
|
|
166
171
|
}));
|
|
167
172
|
}
|
|
168
173
|
SpottableBase.propTypes = /** @lends spotlight/Spottable.Spottable.prototype */{
|
|
@@ -173,14 +178,14 @@ var Spottable = exports.Spottable = (0, _hoc["default"])(defaultConfig, function
|
|
|
173
178
|
* @default false
|
|
174
179
|
* @public
|
|
175
180
|
*/
|
|
176
|
-
disabled:
|
|
181
|
+
disabled: _propTypes["default"].bool,
|
|
177
182
|
/**
|
|
178
183
|
* The handler to force update the component.
|
|
179
184
|
*
|
|
180
185
|
* @type {Function}
|
|
181
186
|
* @public
|
|
182
187
|
*/
|
|
183
|
-
handleForceUpdate:
|
|
188
|
+
handleForceUpdate: _propTypes["default"].func,
|
|
184
189
|
/**
|
|
185
190
|
* The handler to run when the component is removed while retaining focus.
|
|
186
191
|
*
|
|
@@ -188,7 +193,7 @@ var Spottable = exports.Spottable = (0, _hoc["default"])(defaultConfig, function
|
|
|
188
193
|
* @param {Object} event
|
|
189
194
|
* @public
|
|
190
195
|
*/
|
|
191
|
-
onSpotlightDisappear:
|
|
196
|
+
onSpotlightDisappear: _propTypes["default"].func,
|
|
192
197
|
/**
|
|
193
198
|
* The handler to run when the 5-way down key is pressed.
|
|
194
199
|
*
|
|
@@ -196,7 +201,7 @@ var Spottable = exports.Spottable = (0, _hoc["default"])(defaultConfig, function
|
|
|
196
201
|
* @param {Object} event
|
|
197
202
|
* @public
|
|
198
203
|
*/
|
|
199
|
-
onSpotlightDown:
|
|
204
|
+
onSpotlightDown: _propTypes["default"].func,
|
|
200
205
|
/**
|
|
201
206
|
* The handler to run when the 5-way left key is pressed.
|
|
202
207
|
*
|
|
@@ -204,7 +209,7 @@ var Spottable = exports.Spottable = (0, _hoc["default"])(defaultConfig, function
|
|
|
204
209
|
* @param {Object} event
|
|
205
210
|
* @public
|
|
206
211
|
*/
|
|
207
|
-
onSpotlightLeft:
|
|
212
|
+
onSpotlightLeft: _propTypes["default"].func,
|
|
208
213
|
/**
|
|
209
214
|
* The handler to run when the 5-way right key is pressed.
|
|
210
215
|
*
|
|
@@ -212,7 +217,7 @@ var Spottable = exports.Spottable = (0, _hoc["default"])(defaultConfig, function
|
|
|
212
217
|
* @param {Object} event
|
|
213
218
|
* @public
|
|
214
219
|
*/
|
|
215
|
-
onSpotlightRight:
|
|
220
|
+
onSpotlightRight: _propTypes["default"].func,
|
|
216
221
|
/**
|
|
217
222
|
* The handler to run when the 5-way up key is pressed.
|
|
218
223
|
*
|
|
@@ -220,7 +225,7 @@ var Spottable = exports.Spottable = (0, _hoc["default"])(defaultConfig, function
|
|
|
220
225
|
* @param {Object} event
|
|
221
226
|
* @public
|
|
222
227
|
*/
|
|
223
|
-
onSpotlightUp:
|
|
228
|
+
onSpotlightUp: _propTypes["default"].func,
|
|
224
229
|
/**
|
|
225
230
|
* An array of numbers representing keyCodes that should trigger mouse event
|
|
226
231
|
* emulation when `emulateMouse` is `true`. If a keyCode equals a directional
|
|
@@ -230,7 +235,7 @@ var Spottable = exports.Spottable = (0, _hoc["default"])(defaultConfig, function
|
|
|
230
235
|
* @default [13, 16777221]
|
|
231
236
|
* @public
|
|
232
237
|
*/
|
|
233
|
-
selectionKeys:
|
|
238
|
+
selectionKeys: _propTypes["default"].arrayOf(_propTypes["default"].number),
|
|
234
239
|
/**
|
|
235
240
|
* When `true`, the component cannot be navigated using spotlight.
|
|
236
241
|
*
|
|
@@ -238,21 +243,14 @@ var Spottable = exports.Spottable = (0, _hoc["default"])(defaultConfig, function
|
|
|
238
243
|
* @default false
|
|
239
244
|
* @public
|
|
240
245
|
*/
|
|
241
|
-
spotlightDisabled:
|
|
246
|
+
spotlightDisabled: _propTypes["default"].bool,
|
|
242
247
|
/**
|
|
243
248
|
* Used to identify this component within the Spotlight system
|
|
244
249
|
*
|
|
245
250
|
* @type {String}
|
|
246
251
|
* @public
|
|
247
252
|
*/
|
|
248
|
-
spotlightId:
|
|
249
|
-
/*
|
|
250
|
-
* Called with a reference to spottable component
|
|
251
|
-
*
|
|
252
|
-
* @type {Object|Function}
|
|
253
|
-
* @private
|
|
254
|
-
*/
|
|
255
|
-
spotRef: _propTypes["default"].ref,
|
|
253
|
+
spotlightId: _propTypes["default"].string,
|
|
256
254
|
/**
|
|
257
255
|
* The tabIndex of the component. This value will default to -1 if left
|
|
258
256
|
* unset and the control is spottable.
|
|
@@ -260,7 +258,7 @@ var Spottable = exports.Spottable = (0, _hoc["default"])(defaultConfig, function
|
|
|
260
258
|
* @type {Number}
|
|
261
259
|
* @public
|
|
262
260
|
*/
|
|
263
|
-
tabIndex:
|
|
261
|
+
tabIndex: _propTypes["default"].number
|
|
264
262
|
};
|
|
265
263
|
|
|
266
264
|
// eslint-disable-next-line no-shadow
|
|
@@ -282,21 +280,13 @@ var Spottable = exports.Spottable = (0, _hoc["default"])(defaultConfig, function
|
|
|
282
280
|
_createClass(Spottable, [{
|
|
283
281
|
key: "componentDidMount",
|
|
284
282
|
value: function componentDidMount() {
|
|
285
|
-
// eslint-disable-next-line react/no-find-dom-node
|
|
286
|
-
this.node = _reactDom["default"].findDOMNode(this);
|
|
287
283
|
this.forceUpdate();
|
|
288
284
|
}
|
|
289
|
-
}, {
|
|
290
|
-
key: "spotRef",
|
|
291
|
-
get: function get() {
|
|
292
|
-
return this.node;
|
|
293
|
-
}
|
|
294
285
|
}, {
|
|
295
286
|
key: "render",
|
|
296
287
|
value: function render() {
|
|
297
288
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(SpottableBase, _objectSpread(_objectSpread({}, this.props), {}, {
|
|
298
|
-
handleForceUpdate: this.handleForceUpdate
|
|
299
|
-
spotRef: this.spotRef
|
|
289
|
+
handleForceUpdate: this.handleForceUpdate
|
|
300
290
|
}));
|
|
301
291
|
}
|
|
302
292
|
}]);
|
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _handle = _interopRequireWildcard(require("@enact/core/handle"));
|
|
4
|
+
var _WithRef = require("@enact/core/internal/WithRef");
|
|
4
5
|
var _useHandlers = _interopRequireDefault(require("@enact/core/useHandlers"));
|
|
5
6
|
require("@testing-library/jest-dom");
|
|
6
7
|
var _react = require("@testing-library/react");
|
|
7
8
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
9
|
var _react2 = require("react");
|
|
9
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
10
10
|
var _spotlight = _interopRequireDefault(require("../../src/spotlight.js"));
|
|
11
11
|
var _useSpottable = _interopRequireDefault(require("../useSpottable"));
|
|
12
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
var _excluded = ["className", "component", "
|
|
13
|
+
var _excluded = ["className", "component", "disabled", "emulateMouse", "onSelectionCancel", "onSpotlightDisappear", "onSpotlightDown", "onSpotlightLeft", "onSpotlightRight", "onSpotlightUp", "selectionKeys", "spotlightDisabled", "spotlightId"];
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
16
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
17
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
19
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
21
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
22
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
23
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
24
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
25
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
26
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
27
17
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
28
18
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
29
19
|
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; }
|
|
@@ -59,10 +49,13 @@ var spotHandlers = {
|
|
|
59
49
|
onMouseLeave: callContext('onMouseLeave')
|
|
60
50
|
};
|
|
61
51
|
describe('useSpottable', function () {
|
|
62
|
-
function
|
|
52
|
+
function SpottableComponent(props) {
|
|
53
|
+
var nodeRef = (0, _react2.useRef)();
|
|
54
|
+
var getSpotRef = (0, _react2.useCallback)(function () {
|
|
55
|
+
return nodeRef.current;
|
|
56
|
+
}, []);
|
|
63
57
|
var className = props.className,
|
|
64
58
|
component = props.component,
|
|
65
|
-
componentRef = props.componentRef,
|
|
66
59
|
disabled = props.disabled,
|
|
67
60
|
emulateMouse = props.emulateMouse,
|
|
68
61
|
onSelectionCancel = props.onSelectionCancel,
|
|
@@ -78,6 +71,7 @@ describe('useSpottable', function () {
|
|
|
78
71
|
var spot = (0, _useSpottable["default"])({
|
|
79
72
|
disabled: disabled,
|
|
80
73
|
emulateMouse: emulateMouse,
|
|
74
|
+
getSpotRef: getSpotRef,
|
|
81
75
|
onSelectionCancel: onSelectionCancel,
|
|
82
76
|
onSpotlightDisappear: onSpotlightDisappear,
|
|
83
77
|
onSpotlightDown: onSpotlightDown,
|
|
@@ -89,49 +83,22 @@ describe('useSpottable', function () {
|
|
|
89
83
|
spotlightId: spotlightId
|
|
90
84
|
});
|
|
91
85
|
var Comp = component || 'div';
|
|
86
|
+
var CompWithRef = (0, _WithRef.WithRef)(Comp);
|
|
92
87
|
rest.tabIndex = -1;
|
|
93
88
|
var handlers = (0, _useHandlers["default"])(spotHandlers, rest, spot);
|
|
94
|
-
compRef =
|
|
95
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
89
|
+
compRef = nodeRef.current;
|
|
90
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(CompWithRef, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, rest), spot.attributes), handlers), {}, {
|
|
96
91
|
className: (0, _classnames["default"])(className, spot.className),
|
|
97
92
|
disabled: disabled,
|
|
98
|
-
|
|
93
|
+
outermostRef: nodeRef
|
|
99
94
|
}));
|
|
100
95
|
}
|
|
101
|
-
var SpottableComponent = /*#__PURE__*/function (_Component) {
|
|
102
|
-
_inherits(SpottableComponent, _Component);
|
|
103
|
-
var _super = _createSuper(SpottableComponent);
|
|
104
|
-
function SpottableComponent() {
|
|
105
|
-
_classCallCheck(this, SpottableComponent);
|
|
106
|
-
return _super.apply(this, arguments);
|
|
107
|
-
}
|
|
108
|
-
_createClass(SpottableComponent, [{
|
|
109
|
-
key: "componentDidMount",
|
|
110
|
-
value: function componentDidMount() {
|
|
111
|
-
// eslint-disable-next-line react/no-find-dom-node
|
|
112
|
-
this.node = _reactDom["default"].findDOMNode(this);
|
|
113
|
-
}
|
|
114
|
-
}, {
|
|
115
|
-
key: "componentRef",
|
|
116
|
-
get: function get() {
|
|
117
|
-
return this.node;
|
|
118
|
-
}
|
|
119
|
-
}, {
|
|
120
|
-
key: "render",
|
|
121
|
-
value: function render() {
|
|
122
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(SpottableBase, _objectSpread(_objectSpread({}, this.props), {}, {
|
|
123
|
-
componentRef: this.componentRef
|
|
124
|
-
}));
|
|
125
|
-
}
|
|
126
|
-
}]);
|
|
127
|
-
return SpottableComponent;
|
|
128
|
-
}(_react2.Component);
|
|
129
96
|
beforeEach(function () {
|
|
130
97
|
// Spotlight.getCurrent() did not work in unit tests. It always returns `undefined`.
|
|
131
98
|
// So Spotlight.getCurrent() is replaced with the function returning the wrapped component by the Component
|
|
132
99
|
// including `useSpottable`.
|
|
133
100
|
_spotlight["default"].getCurrent = function () {
|
|
134
|
-
return compRef
|
|
101
|
+
return compRef;
|
|
135
102
|
};
|
|
136
103
|
});
|
|
137
104
|
afterEach(function () {
|
|
@@ -14,7 +14,7 @@ exports.useSpottable = void 0;
|
|
|
14
14
|
var _useClass = _interopRequireDefault(require("@enact/core/useClass"));
|
|
15
15
|
var _react = require("react");
|
|
16
16
|
var _SpottableCore = require("./SpottableCore");
|
|
17
|
-
var _excluded = ["
|
|
17
|
+
var _excluded = ["emulateMouse", "getSpotRef", "selectionKeys", "spotlightDisabled"];
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
19
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
20
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -59,7 +59,7 @@ var REMOTE_OK_KEY = 16777221;
|
|
|
59
59
|
* @property {Boolean} [keyUp] Handle to run when the 5-way up key is released.
|
|
60
60
|
* @property {Boolean} [mouseEnter] Handle when mouse enters.
|
|
61
61
|
* @property {Boolean} [mouseLeave] Handle when mouse leaves.
|
|
62
|
-
* @property {Boolean} [
|
|
62
|
+
* @property {Boolean} [spotNode] The ref for the target node.
|
|
63
63
|
* @private
|
|
64
64
|
*/
|
|
65
65
|
|
|
@@ -76,8 +76,8 @@ var REMOTE_OK_KEY = 16777221;
|
|
|
76
76
|
|
|
77
77
|
var useSpottable = exports.useSpottable = function useSpottable() {
|
|
78
78
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
79
|
-
spotRef = _ref.spotRef,
|
|
80
79
|
emulateMouse = _ref.emulateMouse,
|
|
80
|
+
getSpotRef = _ref.getSpotRef,
|
|
81
81
|
_ref$selectionKeys = _ref.selectionKeys,
|
|
82
82
|
selectionKeys = _ref$selectionKeys === void 0 ? [ENTER_KEY, REMOTE_OK_KEY] : _ref$selectionKeys,
|
|
83
83
|
spotlightDisabled = _ref.spotlightDisabled,
|
|
@@ -102,11 +102,11 @@ var useSpottable = exports.useSpottable = function useSpottable() {
|
|
|
102
102
|
spotlightDisabled: spotlightDisabled
|
|
103
103
|
}, props), context.current);
|
|
104
104
|
(0, _react.useLayoutEffect)(function () {
|
|
105
|
-
hook.load(
|
|
105
|
+
hook.load(getSpotRef() || null);
|
|
106
106
|
return function () {
|
|
107
107
|
hook.unload();
|
|
108
108
|
};
|
|
109
|
-
}, [
|
|
109
|
+
}, [getSpotRef]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
110
110
|
|
|
111
111
|
(0, _react.useLayoutEffect)(hook.didUpdate); // eslint-disable-line react-hooks/exhaustive-deps
|
|
112
112
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enact/spotlight",
|
|
3
|
-
"version": "4.9.0-
|
|
3
|
+
"version": "4.9.0-beta.1",
|
|
4
4
|
"description": "A focus management library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@enact/core": "^4.9.0-
|
|
28
|
+
"@enact/core": "^4.9.0-beta.1",
|
|
29
29
|
"classnames": "^2.5.1",
|
|
30
30
|
"prop-types": "^15.8.1",
|
|
31
31
|
"ramda": "^0.29.1",
|