@enact/spotlight 4.7.7 → 4.7.8
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 +4 -2
- package/CHANGELOG.md +4 -0
- package/Pause/Pause.js +4 -2
- package/SpotlightContainerDecorator/SpotlightContainer.js +6 -4
- package/SpotlightContainerDecorator/SpotlightContainerDecorator.js +8 -5
- package/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +2 -2
- package/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +2 -2
- package/SpotlightContainerDecorator/useSpotlightContainer.js +2 -1
- package/SpotlightRootDecorator/SpotlightRootDecorator.js +6 -4
- package/SpotlightRootDecorator/tests/SpotlightRootDecorator-specs.js +2 -2
- package/Spottable/Spottable.js +6 -4
- package/Spottable/SpottableCore.js +6 -3
- package/Spottable/tests/Spottable-specs.js +2 -2
- package/Spottable/tests/useSpot-specs.js +2 -2
- package/Spottable/useSpottable.js +6 -4
- package/package.json +2 -2
- package/src/container.js +34 -18
- package/src/inputType.js +11 -6
- package/src/navigate.js +2 -1
- package/src/pointer.js +15 -8
- package/src/spotlight.js +6 -3
- package/src/target.js +95 -96
- package/src/tests/utils.js +22 -12
- package/src/utils.js +6 -3
|
@@ -19,7 +19,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
19
19
|
* @class Accelerator
|
|
20
20
|
* @memberof spotlight/Accelerator
|
|
21
21
|
*/
|
|
22
|
-
var Accelerator =
|
|
22
|
+
var Accelerator = /*#__PURE__*/_createClass(
|
|
23
23
|
/**
|
|
24
24
|
* @constructor
|
|
25
25
|
* @param {Number[]} frequency - Controls the frequency with which the acceleration will
|
|
@@ -166,4 +166,6 @@ function Accelerator() {
|
|
|
166
166
|
*/
|
|
167
167
|
this.frequency = frequency;
|
|
168
168
|
});
|
|
169
|
-
|
|
169
|
+
exports.Accelerator = Accelerator;
|
|
170
|
+
var _default = Accelerator;
|
|
171
|
+
exports["default"] = _default;
|
package/CHANGELOG.md
CHANGED
package/Pause/Pause.js
CHANGED
|
@@ -82,7 +82,7 @@ function isPaused() {
|
|
|
82
82
|
* @memberof spotlight/Pause
|
|
83
83
|
* @public
|
|
84
84
|
*/
|
|
85
|
-
var Pause =
|
|
85
|
+
var Pause = /*#__PURE__*/function () {
|
|
86
86
|
/**
|
|
87
87
|
* Accepts a name for the instance
|
|
88
88
|
*
|
|
@@ -151,4 +151,6 @@ var Pause = exports.Pause = /*#__PURE__*/function () {
|
|
|
151
151
|
}]);
|
|
152
152
|
return Pause;
|
|
153
153
|
}();
|
|
154
|
-
|
|
154
|
+
exports.Pause = Pause;
|
|
155
|
+
var _default = Pause;
|
|
156
|
+
exports["default"] = _default;
|
|
@@ -8,8 +8,8 @@ var _handle = require("@enact/core/handle");
|
|
|
8
8
|
var _pointer = require("../src/pointer");
|
|
9
9
|
var _spotlight = _interopRequireDefault(require("../src/spotlight"));
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
function ownKeys(
|
|
12
|
-
function _objectSpread(
|
|
11
|
+
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; }
|
|
12
|
+
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; }
|
|
13
13
|
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; }
|
|
14
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
15
|
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,7 +19,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
19
19
|
var isNewPointerPosition = function isNewPointerPosition(ev) {
|
|
20
20
|
return (0, _pointer.hasPointerMoved)(ev.clientX, ev.clientY);
|
|
21
21
|
};
|
|
22
|
-
var SpotlightContainer =
|
|
22
|
+
var SpotlightContainer = /*#__PURE__*/function () {
|
|
23
23
|
function SpotlightContainer(_ref) {
|
|
24
24
|
var _this = this;
|
|
25
25
|
var containerConfig = _ref.containerConfig,
|
|
@@ -146,4 +146,6 @@ var SpotlightContainer = exports.SpotlightContainer = /*#__PURE__*/function () {
|
|
|
146
146
|
}]);
|
|
147
147
|
return SpotlightContainer;
|
|
148
148
|
}();
|
|
149
|
-
|
|
149
|
+
exports.SpotlightContainer = SpotlightContainer;
|
|
150
|
+
var _default = SpotlightContainer;
|
|
151
|
+
exports["default"] = _default;
|
|
@@ -38,8 +38,8 @@ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "
|
|
|
38
38
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
39
39
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
40
40
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
41
|
-
function ownKeys(
|
|
42
|
-
function _objectSpread(
|
|
41
|
+
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; }
|
|
42
|
+
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; }
|
|
43
43
|
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; }
|
|
44
44
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
45
45
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
@@ -63,7 +63,7 @@ var containerHandlers = {
|
|
|
63
63
|
* @memberof spotlight/SpotlightContainerDecorator
|
|
64
64
|
* @public
|
|
65
65
|
*/
|
|
66
|
-
var spotlightDefaultClass =
|
|
66
|
+
var spotlightDefaultClass = 'spottable-default';
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* Default config for {@link spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator}
|
|
@@ -71,6 +71,7 @@ var spotlightDefaultClass = exports.spotlightDefaultClass = 'spottable-default';
|
|
|
71
71
|
* @memberof spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator
|
|
72
72
|
* @hocconfig
|
|
73
73
|
*/
|
|
74
|
+
exports.spotlightDefaultClass = spotlightDefaultClass;
|
|
74
75
|
var defaultConfig = {
|
|
75
76
|
/**
|
|
76
77
|
* When `true`, allows focus to move outside the container to the next spottable element when
|
|
@@ -193,7 +194,7 @@ var defaultConfig = {
|
|
|
193
194
|
* @memberof spotlight/SpotlightContainerDecorator
|
|
194
195
|
* @hoc
|
|
195
196
|
*/
|
|
196
|
-
var SpotlightContainerDecorator =
|
|
197
|
+
var SpotlightContainerDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
|
|
197
198
|
var navigableFilter = config.navigableFilter,
|
|
198
199
|
preserveId = config.preserveId,
|
|
199
200
|
containerConfig = _objectWithoutProperties(config, _excluded);
|
|
@@ -288,4 +289,6 @@ var SpotlightContainerDecorator = exports.SpotlightContainerDecorator = (0, _hoc
|
|
|
288
289
|
return SpotlightContainerDecoratorAdapter;
|
|
289
290
|
}(_react.Component);
|
|
290
291
|
});
|
|
291
|
-
|
|
292
|
+
exports.SpotlightContainerDecorator = SpotlightContainerDecorator;
|
|
293
|
+
var _default = SpotlightContainerDecorator;
|
|
294
|
+
exports["default"] = _default;
|
|
@@ -11,8 +11,8 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
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
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); }); }; }
|
|
14
|
-
function ownKeys(
|
|
15
|
-
function _objectSpread(
|
|
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; }
|
|
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; }
|
|
16
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; }
|
|
17
17
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
18
18
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
@@ -8,8 +8,8 @@ var _spotlight = _interopRequireDefault(require("../../src/spotlight"));
|
|
|
8
8
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
9
|
var _excluded = ["containerConfig", "preserveId", "spotlightDisabled", "spotlightId", "spotlightMuted", "spotlightRestrict"];
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
function ownKeys(
|
|
12
|
-
function _objectSpread(
|
|
11
|
+
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; }
|
|
12
|
+
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; }
|
|
13
13
|
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; }
|
|
14
14
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
15
15
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
@@ -33,8 +33,8 @@ var _spotlight = _interopRequireDefault(require("../src/spotlight"));
|
|
|
33
33
|
require("../styles/debug.less");
|
|
34
34
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
35
35
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
36
|
-
function ownKeys(
|
|
37
|
-
function _objectSpread(
|
|
36
|
+
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; }
|
|
37
|
+
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; }
|
|
38
38
|
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; }
|
|
39
39
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
40
40
|
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); } }
|
|
@@ -89,7 +89,7 @@ var defaultConfig = {
|
|
|
89
89
|
* @returns {Function} SpotlightRootDecorator
|
|
90
90
|
* @hoc
|
|
91
91
|
*/
|
|
92
|
-
var SpotlightRootDecorator =
|
|
92
|
+
var SpotlightRootDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
|
|
93
93
|
var _class;
|
|
94
94
|
var noAutoFocus = config.noAutoFocus;
|
|
95
95
|
return _class = /*#__PURE__*/function (_Component) {
|
|
@@ -214,4 +214,6 @@ var SpotlightRootDecorator = exports.SpotlightRootDecorator = (0, _hoc["default"
|
|
|
214
214
|
return _class;
|
|
215
215
|
}(_react.Component), _class.displayName = 'SpotlightRootDecorator', _class;
|
|
216
216
|
});
|
|
217
|
-
|
|
217
|
+
exports.SpotlightRootDecorator = SpotlightRootDecorator;
|
|
218
|
+
var _default = SpotlightRootDecorator;
|
|
219
|
+
exports["default"] = _default;
|
|
@@ -4,8 +4,8 @@ require("@testing-library/jest-dom");
|
|
|
4
4
|
var _react = require("@testing-library/react");
|
|
5
5
|
var _SpotlightRootDecorator = require("../SpotlightRootDecorator");
|
|
6
6
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
|
-
function ownKeys(
|
|
8
|
-
function _objectSpread(
|
|
7
|
+
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; }
|
|
8
|
+
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; }
|
|
9
9
|
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; }
|
|
10
10
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
11
11
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
package/Spottable/Spottable.js
CHANGED
|
@@ -47,8 +47,8 @@ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "
|
|
|
47
47
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
48
48
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
49
49
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
50
|
-
function ownKeys(
|
|
51
|
-
function _objectSpread(
|
|
50
|
+
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; }
|
|
51
|
+
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; }
|
|
52
52
|
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; }
|
|
53
53
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
54
54
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
@@ -122,7 +122,7 @@ var defaultConfig = {
|
|
|
122
122
|
* @hoc
|
|
123
123
|
* @returns {Function} Spottable
|
|
124
124
|
*/
|
|
125
|
-
var Spottable =
|
|
125
|
+
var Spottable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
|
|
126
126
|
var emulateMouse = config.emulateMouse;
|
|
127
127
|
function SpottableBase(props) {
|
|
128
128
|
var className = props.className,
|
|
@@ -304,4 +304,6 @@ var Spottable = exports.Spottable = (0, _hoc["default"])(defaultConfig, function
|
|
|
304
304
|
}(_react.Component);
|
|
305
305
|
return Spottable;
|
|
306
306
|
});
|
|
307
|
-
|
|
307
|
+
exports.Spottable = Spottable;
|
|
308
|
+
var _default = Spottable;
|
|
309
|
+
exports["default"] = _default;
|
|
@@ -21,7 +21,8 @@ var REMOTE_OK_KEY = 16777221;
|
|
|
21
21
|
* @memberof spotlight/Spottable
|
|
22
22
|
* @public
|
|
23
23
|
*/
|
|
24
|
-
var spottableClass =
|
|
24
|
+
var spottableClass = 'spottable';
|
|
25
|
+
exports.spottableClass = spottableClass;
|
|
25
26
|
var isKeyboardAccessible = function isKeyboardAccessible(node) {
|
|
26
27
|
if (!node) return false;
|
|
27
28
|
var name = node.nodeName.toUpperCase();
|
|
@@ -37,7 +38,7 @@ var lastSelectTarget = null;
|
|
|
37
38
|
|
|
38
39
|
// Should we prevent select being passed through
|
|
39
40
|
var selectCancelled = false;
|
|
40
|
-
var SpottableCore =
|
|
41
|
+
var SpottableCore = /*#__PURE__*/function () {
|
|
41
42
|
function SpottableCore(_ref) {
|
|
42
43
|
var _this = this;
|
|
43
44
|
var emulateMouse = _ref.emulateMouse;
|
|
@@ -237,4 +238,6 @@ var SpottableCore = exports.SpottableCore = /*#__PURE__*/function () {
|
|
|
237
238
|
}]);
|
|
238
239
|
return SpottableCore;
|
|
239
240
|
}();
|
|
240
|
-
|
|
241
|
+
exports.SpottableCore = SpottableCore;
|
|
242
|
+
var _default = SpottableCore;
|
|
243
|
+
exports["default"] = _default;
|
|
@@ -5,8 +5,8 @@ var _react = require("@testing-library/react");
|
|
|
5
5
|
var _Spottable = _interopRequireDefault(require("../Spottable"));
|
|
6
6
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
8
|
-
function ownKeys(
|
|
9
|
-
function _objectSpread(
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
10
|
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; }
|
|
11
11
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
12
12
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
@@ -24,8 +24,8 @@ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "
|
|
|
24
24
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
25
25
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
26
26
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
27
|
-
function ownKeys(
|
|
28
|
-
function _objectSpread(
|
|
27
|
+
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; }
|
|
28
|
+
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; }
|
|
29
29
|
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; }
|
|
30
30
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
31
31
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
@@ -16,8 +16,8 @@ var _react = require("react");
|
|
|
16
16
|
var _SpottableCore = require("./SpottableCore");
|
|
17
17
|
var _excluded = ["spotRef", "emulateMouse", "selectionKeys", "spotlightDisabled"];
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
function ownKeys(
|
|
20
|
-
function _objectSpread(
|
|
19
|
+
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; }
|
|
20
|
+
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; }
|
|
21
21
|
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; }
|
|
22
22
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
23
23
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
@@ -74,7 +74,7 @@ var REMOTE_OK_KEY = 16777221;
|
|
|
74
74
|
* @private
|
|
75
75
|
*/
|
|
76
76
|
|
|
77
|
-
var useSpottable =
|
|
77
|
+
var useSpottable = function useSpottable() {
|
|
78
78
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
79
79
|
spotRef = _ref.spotRef,
|
|
80
80
|
emulateMouse = _ref.emulateMouse,
|
|
@@ -121,4 +121,6 @@ var useSpottable = exports.useSpottable = function useSpottable() {
|
|
|
121
121
|
onMouseLeave: hook.handleLeave
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
|
-
|
|
124
|
+
exports.useSpottable = useSpottable;
|
|
125
|
+
var _default = useSpottable;
|
|
126
|
+
exports["default"] = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enact/spotlight",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.8",
|
|
4
4
|
"description": "A focus management library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@enact/core": "^4.7.
|
|
27
|
+
"@enact/core": "^4.7.8",
|
|
28
28
|
"classnames": "^2.3.2",
|
|
29
29
|
"prop-types": "^15.8.1",
|
|
30
30
|
"ramda": "^0.29.0",
|
package/src/container.js
CHANGED
|
@@ -37,8 +37,8 @@ var _intersection = _interopRequireDefault(require("ramda/src/intersection"));
|
|
|
37
37
|
var _last = _interopRequireDefault(require("ramda/src/last"));
|
|
38
38
|
var _utils = require("./utils");
|
|
39
39
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
40
|
-
function ownKeys(
|
|
41
|
-
function _objectSpread(
|
|
40
|
+
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; }
|
|
41
|
+
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; }
|
|
42
42
|
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; }
|
|
43
43
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
44
44
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
@@ -53,13 +53,15 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
53
53
|
* @module spotlight/container
|
|
54
54
|
* @private
|
|
55
55
|
*/
|
|
56
|
-
var containerAttribute =
|
|
56
|
+
var containerAttribute = 'data-spotlight-id';
|
|
57
|
+
exports.containerAttribute = containerAttribute;
|
|
57
58
|
var containerConfigs = new Map();
|
|
58
59
|
var containerKey = 'spotlightId';
|
|
59
60
|
var disabledKey = 'spotlightContainerDisabled';
|
|
60
61
|
var containerPrefix = 'container-';
|
|
61
62
|
var containerSelector = '[data-spotlight-container]';
|
|
62
|
-
var rootContainerId =
|
|
63
|
+
var rootContainerId = 'spotlightRootDecorator';
|
|
64
|
+
exports.rootContainerId = rootContainerId;
|
|
63
65
|
var reverseDirections = {
|
|
64
66
|
'left': 'right',
|
|
65
67
|
'up': 'down',
|
|
@@ -195,7 +197,7 @@ var mapContainers = function mapContainers(node, fn) {
|
|
|
195
197
|
* @memberof spotlight/container
|
|
196
198
|
* @private
|
|
197
199
|
*/
|
|
198
|
-
var getContainerConfig =
|
|
200
|
+
var getContainerConfig = function getContainerConfig(id) {
|
|
199
201
|
return containerConfigs.get(id);
|
|
200
202
|
};
|
|
201
203
|
|
|
@@ -208,7 +210,8 @@ var getContainerConfig = exports.getContainerConfig = function getContainerConfi
|
|
|
208
210
|
* @memberof spotlight/container
|
|
209
211
|
* @private
|
|
210
212
|
*/
|
|
211
|
-
|
|
213
|
+
exports.getContainerConfig = getContainerConfig;
|
|
214
|
+
var isContainer = function isContainer(nodeOrId) {
|
|
212
215
|
if (typeof nodeOrId === 'string') {
|
|
213
216
|
return containerConfigs.has(nodeOrId);
|
|
214
217
|
}
|
|
@@ -224,6 +227,7 @@ var isContainer = exports.isContainer = function isContainer(nodeOrId) {
|
|
|
224
227
|
* @memberof spotlight/container
|
|
225
228
|
* @private
|
|
226
229
|
*/
|
|
230
|
+
exports.isContainer = isContainer;
|
|
227
231
|
var isContainerEnabled = function isContainerEnabled(node) {
|
|
228
232
|
return mapContainers(node, function (container) {
|
|
229
233
|
return container.dataset[disabledKey] !== 'true';
|
|
@@ -239,7 +243,7 @@ var isContainerEnabled = function isContainerEnabled(node) {
|
|
|
239
243
|
* @memberof spotlight/container
|
|
240
244
|
* @private
|
|
241
245
|
*/
|
|
242
|
-
var getContainerId =
|
|
246
|
+
var getContainerId = function getContainerId(node) {
|
|
243
247
|
return node.dataset[containerKey];
|
|
244
248
|
};
|
|
245
249
|
|
|
@@ -252,6 +256,7 @@ var getContainerId = exports.getContainerId = function getContainerId(node) {
|
|
|
252
256
|
* @memberof spotlight/container
|
|
253
257
|
* @private
|
|
254
258
|
*/
|
|
259
|
+
exports.getContainerId = getContainerId;
|
|
255
260
|
var getContainerSelector = function getContainerSelector(node) {
|
|
256
261
|
if (isContainerNode(node)) {
|
|
257
262
|
return "[".concat(containerAttribute, "=\"").concat(getContainerId(node), "\"]");
|
|
@@ -284,7 +289,7 @@ var getSubContainerSelector = function getSubContainerSelector(node) {
|
|
|
284
289
|
* @memberof spotlight/container
|
|
285
290
|
* @private
|
|
286
291
|
*/
|
|
287
|
-
var getContainerNode =
|
|
292
|
+
var getContainerNode = function getContainerNode(containerId) {
|
|
288
293
|
if (!containerId) {
|
|
289
294
|
return null;
|
|
290
295
|
} else if (containerId === rootContainerId) {
|
|
@@ -304,6 +309,7 @@ var getContainerNode = exports.getContainerNode = function getContainerNode(cont
|
|
|
304
309
|
* @memberof spotlight/container
|
|
305
310
|
* @private
|
|
306
311
|
*/
|
|
312
|
+
exports.getContainerNode = getContainerNode;
|
|
307
313
|
var navigableFilter = function navigableFilter(node, containerId) {
|
|
308
314
|
var nodeStyle = node && (0, _snapshot.isWindowReady)() && window.getComputedStyle(node);
|
|
309
315
|
var config = getContainerConfig(containerId);
|
|
@@ -351,7 +357,7 @@ var getOwnedNodes = function getOwnedNodes(node, selector) {
|
|
|
351
357
|
* @memberof spotlight/container
|
|
352
358
|
* @public
|
|
353
359
|
*/
|
|
354
|
-
var getSpottableDescendants =
|
|
360
|
+
var getSpottableDescendants = function getSpottableDescendants(containerId) {
|
|
355
361
|
var node = getContainerNode(containerId);
|
|
356
362
|
|
|
357
363
|
// if it's falsy or is a disabled container, return an empty set
|
|
@@ -384,7 +390,8 @@ var getSpottableDescendants = exports.getSpottableDescendants = function getSpot
|
|
|
384
390
|
* @memberof spotlight/container
|
|
385
391
|
* @private
|
|
386
392
|
*/
|
|
387
|
-
|
|
393
|
+
exports.getSpottableDescendants = getSpottableDescendants;
|
|
394
|
+
var getDeepSpottableDescendants = function getDeepSpottableDescendants(containerId, excludedContainers) {
|
|
388
395
|
return getSpottableDescendants(containerId).map(function (n) {
|
|
389
396
|
if (isContainer(n)) {
|
|
390
397
|
var id = getContainerId(n);
|
|
@@ -407,7 +414,8 @@ var getDeepSpottableDescendants = exports.getDeepSpottableDescendants = function
|
|
|
407
414
|
* @memberof spotlight/container
|
|
408
415
|
* @private
|
|
409
416
|
*/
|
|
410
|
-
|
|
417
|
+
exports.getDeepSpottableDescendants = getDeepSpottableDescendants;
|
|
418
|
+
var isContainer5WayHoldable = function isContainer5WayHoldable(containerId) {
|
|
411
419
|
var config = getContainerConfig(containerId);
|
|
412
420
|
return config && config.continue5WayHold || false;
|
|
413
421
|
};
|
|
@@ -422,6 +430,7 @@ var isContainer5WayHoldable = exports.isContainer5WayHoldable = function isConta
|
|
|
422
430
|
* @memberof spotlight/container
|
|
423
431
|
* @private
|
|
424
432
|
*/
|
|
433
|
+
exports.isContainer5WayHoldable = isContainer5WayHoldable;
|
|
425
434
|
function getContainersForNode(node) {
|
|
426
435
|
var containers = mapContainers(node, getContainerId);
|
|
427
436
|
containers.unshift(rootContainerId);
|
|
@@ -516,7 +525,7 @@ var mergeConfig = function mergeConfig(current, updated) {
|
|
|
516
525
|
* @memberof spotlight/container
|
|
517
526
|
* @public
|
|
518
527
|
*/
|
|
519
|
-
var configureContainer =
|
|
528
|
+
var configureContainer = function configureContainer() {
|
|
520
529
|
var containerId, config;
|
|
521
530
|
if (typeof (arguments.length <= 0 ? undefined : arguments[0]) === 'object') {
|
|
522
531
|
config = arguments.length <= 0 ? undefined : arguments[0];
|
|
@@ -548,7 +557,8 @@ var configureContainer = exports.configureContainer = function configureContaine
|
|
|
548
557
|
* @memberof spotlight/container
|
|
549
558
|
* @public
|
|
550
559
|
*/
|
|
551
|
-
|
|
560
|
+
exports.configureContainer = configureContainer;
|
|
561
|
+
var addContainer = function addContainer() {
|
|
552
562
|
var containerId = configureContainer.apply(void 0, arguments);
|
|
553
563
|
var config = getContainerConfig(containerId);
|
|
554
564
|
config.active = true;
|
|
@@ -564,7 +574,8 @@ var addContainer = exports.addContainer = function addContainer() {
|
|
|
564
574
|
* @memberof spotlight/container
|
|
565
575
|
* @public
|
|
566
576
|
*/
|
|
567
|
-
|
|
577
|
+
exports.addContainer = addContainer;
|
|
578
|
+
var removeContainer = function removeContainer(containerId) {
|
|
568
579
|
containerConfigs["delete"](containerId);
|
|
569
580
|
};
|
|
570
581
|
|
|
@@ -575,7 +586,8 @@ var removeContainer = exports.removeContainer = function removeContainer(contain
|
|
|
575
586
|
* @memberof spotlight/container
|
|
576
587
|
* @public
|
|
577
588
|
*/
|
|
578
|
-
|
|
589
|
+
exports.removeContainer = removeContainer;
|
|
590
|
+
var removeAllContainers = function removeAllContainers() {
|
|
579
591
|
containerConfigs.clear();
|
|
580
592
|
};
|
|
581
593
|
|
|
@@ -588,7 +600,8 @@ var removeAllContainers = exports.removeAllContainers = function removeAllContai
|
|
|
588
600
|
* @memberof spotlight/container
|
|
589
601
|
* @public
|
|
590
602
|
*/
|
|
591
|
-
|
|
603
|
+
exports.removeAllContainers = removeAllContainers;
|
|
604
|
+
var configureDefaults = function configureDefaults(config) {
|
|
592
605
|
GlobalConfig = mergeConfig(GlobalConfig, config);
|
|
593
606
|
};
|
|
594
607
|
|
|
@@ -603,7 +616,8 @@ var configureDefaults = exports.configureDefaults = function configureDefaults(c
|
|
|
603
616
|
* @memberof spotlight/container
|
|
604
617
|
* @public
|
|
605
618
|
*/
|
|
606
|
-
|
|
619
|
+
exports.configureDefaults = configureDefaults;
|
|
620
|
+
var isNavigable = function isNavigable(node, containerId, verify) {
|
|
607
621
|
if (!node ||
|
|
608
622
|
// jsdom reports all nodes as having no size so we must skip this condition in our tests
|
|
609
623
|
process.env.NODE_ENV !== 'test' && node.offsetWidth <= 0 && node.offsetHeight <= 0) {
|
|
@@ -627,7 +641,8 @@ var isNavigable = exports.isNavigable = function isNavigable(node, containerId,
|
|
|
627
641
|
* @memberof spotlight/container
|
|
628
642
|
* @private
|
|
629
643
|
*/
|
|
630
|
-
|
|
644
|
+
exports.isNavigable = isNavigable;
|
|
645
|
+
var getAllContainerIds = function getAllContainerIds() {
|
|
631
646
|
var ids = [];
|
|
632
647
|
var keys = containerConfigs.keys();
|
|
633
648
|
|
|
@@ -651,6 +666,7 @@ var getAllContainerIds = exports.getAllContainerIds = function getAllContainerId
|
|
|
651
666
|
* @memberof spotlight/container
|
|
652
667
|
* @public
|
|
653
668
|
*/
|
|
669
|
+
exports.getAllContainerIds = getAllContainerIds;
|
|
654
670
|
function getContainerDefaultElement(containerId, preferredEnterTo) {
|
|
655
671
|
var config = getContainerConfig(containerId);
|
|
656
672
|
var defaultElementSelector = config && config.defaultElement;
|
package/src/inputType.js
CHANGED
|
@@ -20,15 +20,17 @@ var input = {
|
|
|
20
20
|
touch: false
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
var activateInputType =
|
|
23
|
+
var activateInputType = function activateInputType(activated) {
|
|
24
24
|
input.activated = activated;
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
exports.activateInputType = activateInputType;
|
|
27
|
+
var getInputType = function getInputType() {
|
|
27
28
|
return Object.keys(input.types).find(function (type) {
|
|
28
29
|
return input.types[type];
|
|
29
30
|
});
|
|
30
31
|
};
|
|
31
|
-
|
|
32
|
+
exports.getInputType = getInputType;
|
|
33
|
+
var setInputType = function setInputType(inputType) {
|
|
32
34
|
if (Object.prototype.hasOwnProperty.call(input.types, inputType) && !input.types[inputType]) {
|
|
33
35
|
Object.keys(input.types).map(function (type) {
|
|
34
36
|
input.types[type] = false;
|
|
@@ -37,15 +39,18 @@ var setInputType = exports.setInputType = function setInputType(inputType) {
|
|
|
37
39
|
input.applied = false;
|
|
38
40
|
}
|
|
39
41
|
};
|
|
40
|
-
|
|
42
|
+
exports.setInputType = setInputType;
|
|
43
|
+
var applyInputTypeToNode = function applyInputTypeToNode(node) {
|
|
41
44
|
Object.keys(input.types).map(function (type) {
|
|
42
45
|
node.classList.toggle('spotlight-input-' + type, input.types[type]);
|
|
43
46
|
});
|
|
44
47
|
input.applied = true;
|
|
45
48
|
};
|
|
46
|
-
|
|
49
|
+
exports.applyInputTypeToNode = applyInputTypeToNode;
|
|
50
|
+
var getInputInfo = function getInputInfo() {
|
|
47
51
|
return {
|
|
48
52
|
activated: input.activated,
|
|
49
53
|
applied: input.applied
|
|
50
54
|
};
|
|
51
|
-
};
|
|
55
|
+
};
|
|
56
|
+
exports.getInputInfo = getInputInfo;
|
package/src/navigate.js
CHANGED
package/src/pointer.js
CHANGED
|
@@ -29,7 +29,7 @@ var _pointerMode = true;
|
|
|
29
29
|
* @memberof spotlight/pointer
|
|
30
30
|
* @private
|
|
31
31
|
*/
|
|
32
|
-
var setPointerMode =
|
|
32
|
+
var setPointerMode = function setPointerMode(pointerMode) {
|
|
33
33
|
_pointerMode = pointerMode;
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -40,11 +40,13 @@ var setPointerMode = exports.setPointerMode = function setPointerMode(pointerMod
|
|
|
40
40
|
* @memberof spotlight/pointer
|
|
41
41
|
* @private
|
|
42
42
|
*/
|
|
43
|
-
|
|
43
|
+
exports.setPointerMode = setPointerMode;
|
|
44
|
+
var getPointerMode = function getPointerMode() {
|
|
44
45
|
return _pointerMode;
|
|
45
46
|
};
|
|
46
47
|
|
|
47
48
|
// Cached pointer position
|
|
49
|
+
exports.getPointerMode = getPointerMode;
|
|
48
50
|
var _pointerX = null;
|
|
49
51
|
var _pointerY = null;
|
|
50
52
|
|
|
@@ -58,7 +60,7 @@ var _pointerY = null;
|
|
|
58
60
|
* @memberof spotlight/pointer
|
|
59
61
|
* @private
|
|
60
62
|
*/
|
|
61
|
-
var hasPointerMoved =
|
|
63
|
+
var hasPointerMoved = function hasPointerMoved(x, y) {
|
|
62
64
|
return x !== _pointerX || y !== _pointerY;
|
|
63
65
|
};
|
|
64
66
|
|
|
@@ -73,7 +75,8 @@ var hasPointerMoved = exports.hasPointerMoved = function hasPointerMoved(x, y) {
|
|
|
73
75
|
* @memberof spotlight/pointer
|
|
74
76
|
* @private
|
|
75
77
|
*/
|
|
76
|
-
|
|
78
|
+
exports.hasPointerMoved = hasPointerMoved;
|
|
79
|
+
var updatePointerPosition = function updatePointerPosition(x, y) {
|
|
77
80
|
// Chrome emits mousemove on scroll, but client coordinates do not change.
|
|
78
81
|
if (hasPointerMoved(x, y)) {
|
|
79
82
|
setPointerMode(true);
|
|
@@ -91,7 +94,8 @@ var updatePointerPosition = exports.updatePointerPosition = function updatePoint
|
|
|
91
94
|
* @memberof spotlight/pointer
|
|
92
95
|
* @private
|
|
93
96
|
*/
|
|
94
|
-
|
|
97
|
+
exports.updatePointerPosition = updatePointerPosition;
|
|
98
|
+
var getLastPointerPosition = function getLastPointerPosition() {
|
|
95
99
|
return {
|
|
96
100
|
x: _pointerX,
|
|
97
101
|
y: _pointerY
|
|
@@ -102,6 +106,7 @@ var getLastPointerPosition = exports.getLastPointerPosition = function getLastPo
|
|
|
102
106
|
// following directional key event to fire, and to prevent momentary spotting of the last
|
|
103
107
|
// focused item - needs to be a value large enough to account for the potentially-trailing
|
|
104
108
|
// event, but not too large that another unrelated event can be fired inside the window
|
|
109
|
+
exports.getLastPointerPosition = getLastPointerPosition;
|
|
105
110
|
var hidePointerJob = new _util.Job(function (callback) {
|
|
106
111
|
setPointerMode(false);
|
|
107
112
|
if (callback) {
|
|
@@ -120,7 +125,7 @@ var hidePointerJob = new _util.Job(function (callback) {
|
|
|
120
125
|
* @memberof spotlight/pointer
|
|
121
126
|
* @private
|
|
122
127
|
*/
|
|
123
|
-
var notifyPointerMove =
|
|
128
|
+
var notifyPointerMove = function notifyPointerMove(current, target, x, y) {
|
|
124
129
|
var priorPointerMode = getPointerMode();
|
|
125
130
|
if (updatePointerPosition(x, y)) {
|
|
126
131
|
// if we're entering pointer mode and the target element isn't within the currently
|
|
@@ -144,7 +149,8 @@ var notifyPointerMove = exports.notifyPointerMove = function notifyPointerMove(c
|
|
|
144
149
|
* @memberof spotlight/pointer
|
|
145
150
|
* @private
|
|
146
151
|
*/
|
|
147
|
-
|
|
152
|
+
exports.notifyPointerMove = notifyPointerMove;
|
|
153
|
+
var notifyKeyDown = function notifyKeyDown(keyCode, callback) {
|
|
148
154
|
var _window$webOSSystem;
|
|
149
155
|
var webOSSystem = (_window$webOSSystem = window.webOSSystem) !== null && _window$webOSSystem !== void 0 ? _window$webOSSystem : window.PalmSystem;
|
|
150
156
|
|
|
@@ -159,4 +165,5 @@ var notifyKeyDown = exports.notifyKeyDown = function notifyKeyDown(keyCode, call
|
|
|
159
165
|
setPointerMode(false);
|
|
160
166
|
}
|
|
161
167
|
return false;
|
|
162
|
-
};
|
|
168
|
+
};
|
|
169
|
+
exports.notifyKeyDown = notifyKeyDown;
|
package/src/spotlight.js
CHANGED
|
@@ -52,9 +52,10 @@ var isUp = (0, _keymap.is)('up');
|
|
|
52
52
|
* @returns {String|false} - One of `'up'`, `'down'`, `'left'`, `'right'` or `false` if not a direction key
|
|
53
53
|
* @public
|
|
54
54
|
*/
|
|
55
|
-
var getDirection =
|
|
55
|
+
var getDirection = function getDirection(keyCode) {
|
|
56
56
|
return isDown(keyCode) && 'down' || isLeft(keyCode) && 'left' || isRight(keyCode) && 'right' || isUp(keyCode) && 'up';
|
|
57
57
|
};
|
|
58
|
+
exports.getDirection = getDirection;
|
|
58
59
|
var SpotlightAccelerator = new _Accelerator["default"]();
|
|
59
60
|
|
|
60
61
|
/**
|
|
@@ -77,7 +78,7 @@ var SpotlightAccelerator = new _Accelerator["default"]();
|
|
|
77
78
|
* @memberof spotlight
|
|
78
79
|
* @public
|
|
79
80
|
*/
|
|
80
|
-
var Spotlight =
|
|
81
|
+
var Spotlight = function () {
|
|
81
82
|
'use strict';
|
|
82
83
|
|
|
83
84
|
/*
|
|
@@ -807,4 +808,6 @@ var Spotlight = exports.Spotlight = function () {
|
|
|
807
808
|
};
|
|
808
809
|
return exports;
|
|
809
810
|
}();
|
|
810
|
-
|
|
811
|
+
exports.Spotlight = Spotlight;
|
|
812
|
+
var _default = Spotlight;
|
|
813
|
+
exports["default"] = _default;
|
package/src/target.js
CHANGED
|
@@ -16,8 +16,8 @@ var _container = require("./container");
|
|
|
16
16
|
var _navigate = _interopRequireDefault(require("./navigate"));
|
|
17
17
|
var _utils = require("./utils");
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
function ownKeys(
|
|
20
|
-
function _objectSpread(
|
|
19
|
+
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; }
|
|
20
|
+
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; }
|
|
21
21
|
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; }
|
|
22
22
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
23
23
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
@@ -157,52 +157,51 @@ function getTargetInContainerByDirectionFromPosition(direction, containerId, pos
|
|
|
157
157
|
var elementRects = filterRects((0, _utils.getRects)(elements), boundingRect);
|
|
158
158
|
var next = null;
|
|
159
159
|
var _loop = function _loop() {
|
|
160
|
-
|
|
160
|
+
var overlappingContainerId = getContainerContainingRect(elementRects, positionRect);
|
|
161
161
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// found a target so break out and return
|
|
175
|
-
return 1; // break
|
|
162
|
+
// if the pointer is within a container that is a candidate element, we need to ignore container
|
|
163
|
+
// `enterTo` preferences and retrieve its spottable descendants and try to navigate to them.
|
|
164
|
+
if (overlappingContainerId) {
|
|
165
|
+
next = getTargetInContainerByDirectionFromPosition(direction, overlappingContainerId, positionRect, elementContainerIds, boundingRect);
|
|
166
|
+
if (!next) {
|
|
167
|
+
// filter out the container and try again
|
|
168
|
+
elementRects = elementRects.filter(function (rect) {
|
|
169
|
+
return rect.element.dataset.spotlightId !== overlappingContainerId;
|
|
170
|
+
});
|
|
171
|
+
return "continue";
|
|
176
172
|
}
|
|
177
173
|
|
|
178
|
-
//
|
|
179
|
-
|
|
174
|
+
// found a target so break out and return
|
|
175
|
+
return "break";
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// try to navigate from position to one of the candidates in containerId
|
|
179
|
+
next = (0, _navigate["default"])(positionRect, direction, elementRects, (0, _container.getContainerConfig)(containerId));
|
|
180
180
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
// if we match a container, recurse into it
|
|
182
|
+
if (next && (0, _container.isContainer)(next)) {
|
|
183
|
+
var nextContainerId = next.dataset.spotlightId;
|
|
184
184
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
185
|
+
// need to cache this reference so we can filter it out later if necessary
|
|
186
|
+
var lastNavigated = next;
|
|
187
|
+
next = getTargetInContainerByDirectionFromPosition(direction, nextContainerId, positionRect, elementContainerIds, getOverflowContainerRect(nextContainerId) || boundingRect);
|
|
188
|
+
if (!next) {
|
|
189
|
+
// filter out the container and try again
|
|
190
|
+
elementRects = elementRects.filter(function (rect) {
|
|
191
|
+
return rect.element !== lastNavigated;
|
|
192
|
+
});
|
|
193
|
+
return "continue";
|
|
195
194
|
}
|
|
195
|
+
}
|
|
196
196
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
_ret;
|
|
197
|
+
// If we've met every condition and haven't explicitly retried the search via `continue`,
|
|
198
|
+
// break out and return
|
|
199
|
+
return "break";
|
|
200
|
+
};
|
|
202
201
|
while (elementRects.length > 0) {
|
|
203
|
-
_ret = _loop();
|
|
204
|
-
if (_ret ===
|
|
205
|
-
if (_ret ===
|
|
202
|
+
var _ret = _loop();
|
|
203
|
+
if (_ret === "continue") continue;
|
|
204
|
+
if (_ret === "break") break;
|
|
206
205
|
}
|
|
207
206
|
return next;
|
|
208
207
|
}
|
|
@@ -228,70 +227,69 @@ function getTargetInContainerByDirectionFromElement(direction, containerId, elem
|
|
|
228
227
|
var elementRects = filterRects((0, _utils.getRects)(elements), boundingRect);
|
|
229
228
|
var next = null;
|
|
230
229
|
var _loop2 = function _loop2() {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
// if the next element is a container AND the current element is *visually* contained within
|
|
234
|
-
// one of the candidate elements, we need to ignore container `enterTo` preferences and
|
|
235
|
-
// retrieve its spottable descendants and try to navigate to them.
|
|
236
|
-
if (overlappingContainerId) {
|
|
237
|
-
next = getTargetInContainerByDirectionFromElement(direction, overlappingContainerId, element, elementRect, elementContainerIds, boundingRect);
|
|
238
|
-
if (!next) {
|
|
239
|
-
// filter out the container and try again
|
|
240
|
-
elementRects = elementRects.filter(function (rect) {
|
|
241
|
-
return rect.element.dataset.spotlightId !== overlappingContainerId;
|
|
242
|
-
});
|
|
243
|
-
return 0; // continue
|
|
244
|
-
}
|
|
230
|
+
var overlappingContainerId = getContainerContainingRect(elementRects, elementRect);
|
|
245
231
|
|
|
246
|
-
|
|
247
|
-
|
|
232
|
+
// if the next element is a container AND the current element is *visually* contained within
|
|
233
|
+
// one of the candidate elements, we need to ignore container `enterTo` preferences and
|
|
234
|
+
// retrieve its spottable descendants and try to navigate to them.
|
|
235
|
+
if (overlappingContainerId) {
|
|
236
|
+
next = getTargetInContainerByDirectionFromElement(direction, overlappingContainerId, element, elementRect, elementContainerIds, boundingRect);
|
|
237
|
+
if (!next) {
|
|
238
|
+
// filter out the container and try again
|
|
239
|
+
elementRects = elementRects.filter(function (rect) {
|
|
240
|
+
return rect.element.dataset.spotlightId !== overlappingContainerId;
|
|
241
|
+
});
|
|
242
|
+
return "continue";
|
|
248
243
|
}
|
|
249
244
|
|
|
250
|
-
//
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
245
|
+
// found a target so break out and return
|
|
246
|
+
return "break";
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// If one of the downstream containers is configured for partition, we use that
|
|
250
|
+
// container's bounds as the partition rect for navigation.
|
|
251
|
+
var partitionContainer = elementContainerIds.slice(elementContainerIds.indexOf(containerId) + 1).find(function (id) {
|
|
252
|
+
var cfg = (0, _container.getContainerConfig)(id);
|
|
253
|
+
return cfg && cfg.partition;
|
|
254
|
+
});
|
|
255
|
+
var partitionRect = elementRect;
|
|
256
|
+
if (partitionContainer) {
|
|
257
|
+
partitionRect = (0, _utils.getContainerRect)(partitionContainer);
|
|
258
|
+
}
|
|
260
259
|
|
|
261
|
-
|
|
262
|
-
|
|
260
|
+
// try to navigate from element to one of the candidates in containerId
|
|
261
|
+
next = (0, _navigate["default"])(elementRect, direction, elementRects, (0, _container.getContainerConfig)(containerId), partitionRect);
|
|
263
262
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
263
|
+
// if we match a container,
|
|
264
|
+
if (next && (0, _container.isContainer)(next)) {
|
|
265
|
+
var nextContainerId = next.dataset.spotlightId;
|
|
267
266
|
|
|
268
|
-
|
|
269
|
-
|
|
267
|
+
// need to cache this reference so we can filter it out later if necessary
|
|
268
|
+
var lastNavigated = next;
|
|
270
269
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
270
|
+
// and it is restricted, return its target
|
|
271
|
+
if (isRestrictedContainer(nextContainerId)) {
|
|
272
|
+
next = getTargetByContainer(nextContainerId);
|
|
273
|
+
} else {
|
|
274
|
+
// otherwise, recurse into it
|
|
275
|
+
next = getTargetInContainerByDirectionFromElement(direction, nextContainerId, element, elementRect, elementContainerIds, getOverflowContainerRect(nextContainerId) || boundingRect);
|
|
276
|
+
}
|
|
277
|
+
if (!next) {
|
|
278
|
+
elementRects = elementRects.filter(function (rect) {
|
|
279
|
+
return rect.element !== lastNavigated;
|
|
280
|
+
});
|
|
281
|
+
return "continue";
|
|
284
282
|
}
|
|
283
|
+
}
|
|
285
284
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
_ret2;
|
|
285
|
+
// If we've met every condition and haven't explicitly retried the search via `continue`,
|
|
286
|
+
// break out and return
|
|
287
|
+
return "break";
|
|
288
|
+
};
|
|
291
289
|
while (elementRects.length > 0) {
|
|
292
|
-
_ret2 = _loop2();
|
|
293
|
-
if (_ret2 ===
|
|
294
|
-
if (_ret2 ===
|
|
290
|
+
var _ret2 = _loop2();
|
|
291
|
+
if (_ret2 === "continue") continue;
|
|
292
|
+
if (_ret2 === "break") break;
|
|
295
293
|
}
|
|
296
294
|
return next;
|
|
297
295
|
}
|
|
@@ -427,6 +425,7 @@ var getNearestTargetInContainerFromPosition = function getNearestTargetInContain
|
|
|
427
425
|
});
|
|
428
426
|
return targets[0].target;
|
|
429
427
|
};
|
|
430
|
-
var getNearestTargetFromPosition =
|
|
428
|
+
var getNearestTargetFromPosition = function getNearestTargetFromPosition(position, containerId) {
|
|
431
429
|
return getNavigableTarget(document.elementFromPoint(position.x, position.y)) || getNearestTargetInContainerFromPosition(position, containerId);
|
|
432
|
-
};
|
|
430
|
+
};
|
|
431
|
+
exports.getNearestTargetFromPosition = getNearestTargetFromPosition;
|
package/src/tests/utils.js
CHANGED
|
@@ -7,13 +7,14 @@ exports.testScenario = exports.spottable = exports.someSpottablesAndContainers =
|
|
|
7
7
|
var _ramda = _interopRequireDefault(require("ramda"));
|
|
8
8
|
var _container = require("../container");
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
-
function ownKeys(
|
|
11
|
-
function _objectSpread(
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
12
12
|
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; }
|
|
13
13
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
14
14
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
-
var join =
|
|
16
|
-
|
|
15
|
+
var join = _ramda["default"].unapply(_ramda["default"].join('\n'));
|
|
16
|
+
exports.join = join;
|
|
17
|
+
var testScenario = function testScenario(scenario, callback) {
|
|
17
18
|
return function () {
|
|
18
19
|
var rootId = 'test-root';
|
|
19
20
|
var html = join("<div id=\"".concat(rootId, "\">"), scenario, '</div>');
|
|
@@ -27,10 +28,12 @@ var testScenario = exports.testScenario = function testScenario(scenario, callba
|
|
|
27
28
|
}
|
|
28
29
|
};
|
|
29
30
|
};
|
|
31
|
+
exports.testScenario = testScenario;
|
|
30
32
|
var _id = 1;
|
|
31
|
-
var generateContainerId =
|
|
33
|
+
var generateContainerId = function generateContainerId() {
|
|
32
34
|
return "".concat(_container.containerAttribute, "=").concat(_id++);
|
|
33
35
|
};
|
|
36
|
+
exports.generateContainerId = generateContainerId;
|
|
34
37
|
var coerceProps = function coerceProps(v) {
|
|
35
38
|
if (typeof v === 'object') {
|
|
36
39
|
return v;
|
|
@@ -40,7 +43,7 @@ var coerceProps = function coerceProps(v) {
|
|
|
40
43
|
};
|
|
41
44
|
}
|
|
42
45
|
};
|
|
43
|
-
var node =
|
|
46
|
+
var node = function node(props) {
|
|
44
47
|
var children = '';
|
|
45
48
|
var attributes = '';
|
|
46
49
|
var tag = 'div';
|
|
@@ -59,18 +62,25 @@ var node = exports.node = function node(props) {
|
|
|
59
62
|
});
|
|
60
63
|
return "<".concat(tag, " ").concat(attributes, ">").concat(children, "</").concat(tag, ">");
|
|
61
64
|
};
|
|
62
|
-
|
|
65
|
+
exports.node = node;
|
|
66
|
+
var spottable = function spottable(props) {
|
|
63
67
|
return node(_objectSpread({
|
|
64
68
|
className: 'spottable'
|
|
65
69
|
}, coerceProps(props)));
|
|
66
70
|
};
|
|
67
|
-
|
|
71
|
+
exports.spottable = spottable;
|
|
72
|
+
var container = function container(props) {
|
|
68
73
|
var _objectSpread2;
|
|
69
74
|
return node(_objectSpread((_objectSpread2 = {}, _defineProperty(_objectSpread2, _container.containerAttribute, _id++), _defineProperty(_objectSpread2, 'data-spotlight-container', true), _objectSpread2), coerceProps(props)));
|
|
70
75
|
};
|
|
71
76
|
|
|
72
77
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
73
|
-
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
var
|
|
78
|
+
exports.container = container;
|
|
79
|
+
var someNodes = _ramda["default"].useWith(_ramda["default"].compose(_ramda["default"].join('\n'), _ramda["default"].map), [_ramda["default"].identity, _ramda["default"].range(0)]);
|
|
80
|
+
exports.someNodes = someNodes;
|
|
81
|
+
var someSpottables = someNodes(spottable);
|
|
82
|
+
exports.someSpottables = someSpottables;
|
|
83
|
+
var someContainers = someNodes(container);
|
|
84
|
+
exports.someContainers = someContainers;
|
|
85
|
+
var someSpottablesAndContainers = _ramda["default"].converge(_ramda["default"].concat, [someSpottables, someContainers]);
|
|
86
|
+
exports.someSpottablesAndContainers = someSpottablesAndContainers;
|
package/src/utils.js
CHANGED
|
@@ -23,7 +23,7 @@ var elementMatchesSelector = function elementMatchesSelector(selector) {
|
|
|
23
23
|
if (typeof window === 'object') {
|
|
24
24
|
elementMatchesSelector = window.Element.prototype.matches || window.Element.prototype.matchesSelector || window.Element.prototype.mozMatchesSelector || window.Element.prototype.webkitMatchesSelector || window.Element.prototype.msMatchesSelector || window.Element.prototype.oMatchesSelector || elementMatchesSelector;
|
|
25
25
|
}
|
|
26
|
-
var matchSelector =
|
|
26
|
+
var matchSelector = (0, _curry["default"])(function (selector, elem) {
|
|
27
27
|
if (typeof selector === 'string') {
|
|
28
28
|
return elementMatchesSelector.call(elem, selector);
|
|
29
29
|
} else if (typeof selector === 'object' && selector.length) {
|
|
@@ -33,6 +33,7 @@ var matchSelector = exports.matchSelector = (0, _curry["default"])(function (sel
|
|
|
33
33
|
}
|
|
34
34
|
return false;
|
|
35
35
|
});
|
|
36
|
+
exports.matchSelector = matchSelector;
|
|
36
37
|
function parseSelector(selector) {
|
|
37
38
|
var result = [];
|
|
38
39
|
try {
|
|
@@ -76,12 +77,14 @@ var testIntersection = function testIntersection(type, containerRect, elementRec
|
|
|
76
77
|
|
|
77
78
|
return true;
|
|
78
79
|
};
|
|
79
|
-
var intersects =
|
|
80
|
+
var intersects = (0, _curry["default"])(function (containerRect, elementRect) {
|
|
80
81
|
return testIntersection('intersects', containerRect, elementRect);
|
|
81
82
|
});
|
|
82
|
-
|
|
83
|
+
exports.intersects = intersects;
|
|
84
|
+
var contains = (0, _curry["default"])(function (containerRect, elementRect) {
|
|
83
85
|
return testIntersection('contains', containerRect, elementRect);
|
|
84
86
|
});
|
|
87
|
+
exports.contains = contains;
|
|
85
88
|
function getRect(elem) {
|
|
86
89
|
var cr = elem.getBoundingClientRect();
|
|
87
90
|
var rect = {
|