Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@enact/spotlight

Package Overview
Dependencies
Maintainers
1
Versions
218
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@enact/spotlight - npm Package Compare versions

Comparing version 1.6.1 to 1.7.0

10

Accelerator/Accelerator.js

@@ -1,7 +0,1 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -187,3 +181,3 @@

exports.default = Accelerator;
exports.Accelerator = Accelerator;
export default Accelerator;
export { Accelerator };

@@ -5,2 +5,18 @@ # Change Log

## [1.7.0] - 2017-08-23
### Added
- `spotlight/SpotlightContainerDecorator` config option `continue5WayHold` to support moving focus to the next spottable element on 5-way hold key.
- `spotlight/Spottable` ability to restore focus when an initially disabled component becomes enabled
### Fixed
- `spotlight` to correctly restore focus to a spotlight container in another container
- `spotlight` to not try to focus something when the window is activated if focus is already set
## [1.6.1] - 2017-08-07
No significant changes.
## [1.6.0] - 2017-08-04

@@ -7,0 +23,0 @@

4

package.json
{
"name": "@enact/spotlight",
"version": "1.6.1",
"version": "1.7.0",
"description": "A focus management library",

@@ -24,3 +24,3 @@ "main": "src/spotlight.js",

"dependencies": {
"@enact/core": "^1.6.1",
"@enact/core": "^1.7.0",
"prop-types": "~15.5.10",

@@ -27,0 +27,0 @@ "ramda": "~0.24.1",

@@ -1,8 +0,1 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.spotlightDefaultClass = exports.SpotlightContainerDecorator = undefined;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

@@ -12,22 +5,2 @@

var _handle = require('@enact/core/handle');
var _hoc = require('@enact/core/hoc');
var _hoc2 = _interopRequireDefault(_hoc);
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _spotlight = require('../src/spotlight');
var _spotlight2 = _interopRequireDefault(_spotlight);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -39,12 +12,21 @@

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } /**
* Exports the {@link spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator}
* Higher-order Component and {@link spotlight/SpotlightContainerDecorator.spotlightDefaultClass}
* `className`. The default export is
* {@link spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator}.
*
* @module spotlight/SpotlightContainerDecorator
*/
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
/**
* Exports the {@link spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator}
* Higher-order Component and {@link spotlight/SpotlightContainerDecorator.spotlightDefaultClass}
* `className`. The default export is
* {@link spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator}.
*
* @module spotlight/SpotlightContainerDecorator
*/
import { forward } from '@enact/core/handle';
import hoc from '@enact/core/hoc';
import React from 'react';
import PropTypes from 'prop-types';
import Spotlight from '../src/spotlight';
/**
* The class name to apply to the default component to focus in a container.

@@ -67,2 +49,13 @@ *

/**
* When `true`, allows focus to move outside the container to the next spottable element when
* holding 5 way keys.
*
* @type {Boolean}
* @default false
* @memberof spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.defaultConfig
* @public
*/
continue5WayHold: false,
/**
* The selector for the default spottable element within the container.

@@ -136,7 +129,7 @@ *

*/
var SpotlightContainerDecorator = (0, _hoc2.default)(defaultConfig, function (config, Wrapped) {
var SpotlightContainerDecorator = hoc(defaultConfig, function (config, Wrapped) {
var _class, _temp;
var forwardMouseEnter = (0, _handle.forward)(enterEvent);
var forwardMouseLeave = (0, _handle.forward)(leaveEvent);
var forwardMouseEnter = forward(enterEvent);
var forwardMouseLeave = forward(leaveEvent);

@@ -167,3 +160,3 @@ var navigableFilter = config.navigableFilter,

_this.handleMouseEnter = function (ev) {
_spotlight2.default.setActiveContainer(_this.state.id);
Spotlight.setActiveContainer(_this.state.id);
forwardMouseEnter(ev, _this.props);

@@ -175,3 +168,3 @@ };

var parentContainer = ev.currentTarget.parentNode.closest('[data-container-id]');
var activeContainer = _spotlight2.default.getActiveContainer();
var activeContainer = Spotlight.getActiveContainer();

@@ -182,3 +175,3 @@ // if this container is wrapped by another and this is the currently active

activeContainer = parentContainer.dataset.containerId;
_spotlight2.default.setActiveContainer(activeContainer);
Spotlight.setActiveContainer(activeContainer);
}

@@ -190,3 +183,3 @@ }

_this.state = {
id: _spotlight2.default.add(_this.props.containerId)
id: Spotlight.add(_this.props.containerId)
};

@@ -207,3 +200,3 @@ return _this;

_spotlight2.default.set(this.state.id, cfg);
Spotlight.set(this.state.id, cfg);
}

@@ -214,4 +207,4 @@ }, {

if (this.props.containerId !== nextProps.containerId) {
_spotlight2.default.remove(this.props.containerId);
_spotlight2.default.add(nextProps.containerId);
Spotlight.remove(this.props.containerId);
Spotlight.add(nextProps.containerId);
this.setState({

@@ -226,3 +219,3 @@ id: nextProps.containerId

if (this.props.spotlightRestrict !== prevProps.spotlightRestrict) {
_spotlight2.default.set(this.state.id, { restrict: this.props.spotlightRestrict });
Spotlight.set(this.state.id, { restrict: this.props.spotlightRestrict });
}

@@ -234,5 +227,5 @@ }

if (preserveId) {
_spotlight2.default.unmount(this.state.id);
Spotlight.unmount(this.state.id);
} else {
_spotlight2.default.remove(this.state.id);
Spotlight.remove(this.state.id);
}

@@ -263,3 +256,3 @@ }

return _react2.default.createElement(Wrapped, rest);
return React.createElement(Wrapped, rest);
}

@@ -269,3 +262,3 @@ }]);

return _class;
}(_react2.default.Component), _class.displayName = 'SpotlightContainerDecorator', _class.propTypes = /** @lends spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.prototype */{
}(React.Component), _class.displayName = 'SpotlightContainerDecorator', _class.propTypes = /** @lends spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.prototype */{
/**

@@ -277,3 +270,3 @@ * Specifies the container id. If the value is `null`, an id will be generated.

*/
containerId: _propTypes2.default.string,
containerId: PropTypes.string,

@@ -287,3 +280,3 @@ /**

*/
spotlightDisabled: _propTypes2.default.bool,
spotlightDisabled: PropTypes.bool,

@@ -297,3 +290,3 @@ /**

*/
spotlightMuted: _propTypes2.default.bool,
spotlightMuted: PropTypes.bool,

@@ -312,3 +305,3 @@ /**

*/
spotlightRestrict: _propTypes2.default.oneOf(['none', 'self-first', 'self-only'])
spotlightRestrict: PropTypes.oneOf(['none', 'self-first', 'self-only'])
}, _class.defaultProps = {

@@ -320,4 +313,3 @@ spotlightDisabled: false,

exports.default = SpotlightContainerDecorator;
exports.SpotlightContainerDecorator = SpotlightContainerDecorator;
exports.spotlightDefaultClass = spotlightDefaultClass;
export default SpotlightContainerDecorator;
export { SpotlightContainerDecorator, spotlightDefaultClass };

@@ -1,8 +0,4 @@

"use strict";
/* global Element */
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (set, remove) {
export default function (set, remove) {
var polyfilled = false;

@@ -46,2 +42,2 @@

});
};
}

@@ -1,39 +0,25 @@

'use strict';
import { mount } from 'enzyme';
import React from 'react';
import Spotlight from '../../src/spotlight';
var _enzyme = require('enzyme');
import SpotlightContainerDecorator from '../SpotlightContainerDecorator';
var _react = require('react');
import closest from './Element.prototype.closest';
var _react2 = _interopRequireDefault(_react);
var _spotlight = require('../../src/spotlight');
var _spotlight2 = _interopRequireDefault(_spotlight);
var _SpotlightContainerDecorator = require('../SpotlightContainerDecorator');
var _SpotlightContainerDecorator2 = _interopRequireDefault(_SpotlightContainerDecorator);
var _ElementPrototype = require('./Element.prototype.closest');
var _ElementPrototype2 = _interopRequireDefault(_ElementPrototype);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
describe('SpotlightContainerDecorator', function () {
var Div = function Div(props) {
return _react2.default.createElement('div', props);
return React.createElement('div', props);
};
(0, _ElementPrototype2.default)(before, after);
closest(before, after);
beforeEach(function () {
_spotlight2.default.setActiveContainer(null);
Spotlight.setActiveContainer(null);
});
it('should set itself as the active container on mouse enter', function () {
var Component = (0, _SpotlightContainerDecorator2.default)(Div);
var Component = SpotlightContainerDecorator(Div);
var subject = (0, _enzyme.mount)(_react2.default.createElement(Component, { containerId: 'test-container' }));
var subject = mount(React.createElement(Component, { containerId: 'test-container' }));

@@ -43,3 +29,3 @@ subject.find(Div).prop('onMouseEnter')();

var expected = 'test-container';
var actual = _spotlight2.default.getActiveContainer();
var actual = Spotlight.getActiveContainer();

@@ -50,9 +36,9 @@ expect(actual).to.equal(expected);

it('should set active container to parent container on mouse leave', function () {
var Component = (0, _SpotlightContainerDecorator2.default)(Div);
var Component = SpotlightContainerDecorator(Div);
var node = document.createElement('div');
var subject = (0, _enzyme.mount)(_react2.default.createElement(
var subject = mount(React.createElement(
Component,
{ containerId: 'outer-container' },
_react2.default.createElement(Component, { containerId: 'inner-container' })
React.createElement(Component, { containerId: 'inner-container' })
), { attachTo: node });

@@ -71,3 +57,3 @@

var expected = 'outer-container';
var actual = _spotlight2.default.getActiveContainer();
var actual = Spotlight.getActiveContainer();

@@ -78,10 +64,10 @@ expect(actual).to.equal(expected);

it('should not set active container on mouse leave if another container is active', function () {
var Component = (0, _SpotlightContainerDecorator2.default)(Div);
var Component = SpotlightContainerDecorator(Div);
var node = document.createElement('div');
var subject = (0, _enzyme.mount)(_react2.default.createElement(
var subject = mount(React.createElement(
Component,
{ containerId: 'outer-container' },
_react2.default.createElement(Component, { containerId: 'inner-container' }),
_react2.default.createElement(Component, { containerId: 'self-only-container' })
React.createElement(Component, { containerId: 'inner-container' }),
React.createElement(Component, { containerId: 'self-only-container' })
), { attachTo: node });

@@ -97,3 +83,3 @@

// set another container to be active
_spotlight2.default.setActiveContainer('self-only-container');
Spotlight.setActiveContainer('self-only-container');

@@ -104,3 +90,3 @@ // leave inner-container

var expected = 'self-only-container';
var actual = _spotlight2.default.getActiveContainer();
var actual = Spotlight.getActiveContainer();

@@ -107,0 +93,0 @@ expect(actual).to.equal(expected);

@@ -1,8 +0,1 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SpotlightRootDecorator = exports.spotlightRootContainerName = undefined;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

@@ -12,31 +5,23 @@

var _hoc = require('@enact/core/hoc');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _hoc2 = _interopRequireDefault(_hoc);
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
var _react = require('react');
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _react2 = _interopRequireDefault(_react);
/**
* Exports the {@link spotlight/SpotlightRootDecorator.SpotlightRootDecorator}
* Higher-order Component.
*
* @module spotlight/SpotlightRootDecorator
*/
var _spotlight = require('../src/spotlight');
import hoc from '@enact/core/hoc';
import React from 'react';
var _spotlight2 = _interopRequireDefault(_spotlight);
import Spotlight from '../src/spotlight';
import { spottableClass } from '../Spottable';
var _Spottable = require('../Spottable');
import { rootContainerId } from '../src/container';
var _container = require('../src/container');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* Exports the {@link spotlight/SpotlightRootDecorator.SpotlightRootDecorator}
* Higher-order Component.
*
* @module spotlight/SpotlightRootDecorator
*/
/**

@@ -75,3 +60,3 @@ * Default configuration for SpotlightRootDecorator

*/
var SpotlightRootDecorator = (0, _hoc2.default)(defaultConfig, function (config, Wrapped) {
var SpotlightRootDecorator = hoc(defaultConfig, function (config, Wrapped) {
var _class, _temp2;

@@ -110,8 +95,8 @@

_spotlight2.default.initialize({
selector: '.' + _Spottable.spottableClass,
Spotlight.initialize({
selector: '.' + spottableClass,
restrict: 'none'
});
_spotlight2.default.set(_container.rootContainerId, {
Spotlight.set(rootContainerId, {
overflow: true

@@ -121,3 +106,3 @@ });

if (palmSystem && palmSystem.cursor) {
_spotlight2.default.setPointerMode(palmSystem.cursor.visibility);
Spotlight.setPointerMode(palmSystem.cursor.visibility);
}

@@ -130,3 +115,3 @@ }

if (!noAutoFocus) {
_spotlight2.default.focus();
Spotlight.focus();
}

@@ -137,3 +122,3 @@ }

value: function componentWillUnmount() {
_spotlight2.default.terminate();
Spotlight.terminate();
}

@@ -143,3 +128,3 @@ }, {

value: function render() {
return _react2.default.createElement(Wrapped, this.props);
return React.createElement(Wrapped, this.props);
}

@@ -149,7 +134,7 @@ }]);

return _class;
}(_react2.default.Component), _class.displayName = 'SpotlightRootDecorator', _temp2;
}(React.Component), _class.displayName = 'SpotlightRootDecorator', _temp2;
});
exports.default = SpotlightRootDecorator;
exports.spotlightRootContainerName = _container.rootContainerId;
exports.SpotlightRootDecorator = SpotlightRootDecorator;
export default SpotlightRootDecorator;
export { rootContainerId as spotlightRootContainerName, // DEPRECATED
SpotlightRootDecorator };

@@ -1,8 +0,1 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.spottableClass = exports.Spottable = undefined;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

@@ -12,30 +5,2 @@

var _handle = require('@enact/core/handle');
var _hoc = require('@enact/core/hoc');
var _hoc2 = _interopRequireDefault(_hoc);
var _keymap = require('@enact/core/keymap');
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _reactDom = require('react-dom');
var _reactDom2 = _interopRequireDefault(_reactDom);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _container = require('../src/container');
var _spotlight = require('../src/spotlight');
var _spotlight2 = _interopRequireDefault(_spotlight);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

@@ -47,11 +12,23 @@

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* Exports the {@link spotlight/Spottable.Spottable} Higher-order Component and
* the {@link spotlight/Spottable.spottableClass} `className`. The default export is
* {@link spotlight/Spottable.Spottable}.
*
* @module spotlight/Spottable
*/
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**
* Exports the {@link spotlight/Spottable.Spottable} Higher-order Component and
* the {@link spotlight/Spottable.spottableClass} `className`. The default export is
* {@link spotlight/Spottable.Spottable}.
*
* @module spotlight/Spottable
*/
import { forward, forwardWithPrevent, handle } from '@enact/core/handle';
import hoc from '@enact/core/hoc';
import { is } from '@enact/core/keymap';
import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import { getContainersForNode } from '../src/container';
import Spotlight from '../src/spotlight';
/**
* The class name for spottable components. In general, you do not need to directly access this class

@@ -113,3 +90,3 @@ *

*/
var Spottable = (0, _hoc2.default)(defaultConfig, function (config, Wrapped) {
var Spottable = hoc(defaultConfig, function (config, Wrapped) {
var _class, _temp;

@@ -150,9 +127,9 @@

if (onSpotlightDown && (0, _keymap.is)('down', keyCode)) {
if (onSpotlightDown && is('down', keyCode)) {
onSpotlightDown(ev);
} else if (onSpotlightLeft && (0, _keymap.is)('left', keyCode)) {
} else if (onSpotlightLeft && is('left', keyCode)) {
onSpotlightLeft(ev);
} else if (onSpotlightRight && (0, _keymap.is)('right', keyCode)) {
} else if (onSpotlightRight && is('right', keyCode)) {
onSpotlightRight(ev);
} else if (onSpotlightUp && (0, _keymap.is)('up', keyCode)) {
} else if (onSpotlightUp && is('up', keyCode)) {
onSpotlightUp(ev);

@@ -187,5 +164,5 @@ }

_this.handle = _handle.handle.bind(_this);
_this.handleKeyDown = _this.handle(_this.handleSelect, (0, _handle.forwardWithPrevent)('onKeyDown'), _this.forwardSpotlightEvents, _this.shouldEmulateMouse, (0, _handle.forward)('onMouseDown'));
_this.handleKeyUp = _this.handle((0, _handle.forwardWithPrevent)('onKeyUp'), _this.resetLastSelecTarget, _this.shouldEmulateMouse, (0, _handle.forward)('onMouseUp'), (0, _handle.forward)('onClick'));
_this.handle = handle.bind(_this);
_this.handleKeyDown = _this.handle(_this.handleSelect, forwardWithPrevent('onKeyDown'), _this.forwardSpotlightEvents, _this.shouldEmulateMouse, forward('onMouseDown'));
_this.handleKeyUp = _this.handle(forwardWithPrevent('onKeyUp'), _this.resetLastSelecTarget, _this.shouldEmulateMouse, forward('onMouseUp'), forward('onClick'));

@@ -197,6 +174,6 @@ _this.handleBlur = function (ev) {

if (_spotlight2.default.isMuted(ev.target)) {
if (Spotlight.isMuted(ev.target)) {
ev.stopPropagation();
} else {
(0, _handle.forward)('onBlur', ev, _this.props);
forward('onBlur', ev, _this.props);
}

@@ -210,6 +187,6 @@ };

if (_spotlight2.default.isMuted(ev.target)) {
if (Spotlight.isMuted(ev.target)) {
ev.stopPropagation();
} else {
(0, _handle.forward)('onFocus', ev, _this.props);
forward('onFocus', ev, _this.props);
}

@@ -228,3 +205,3 @@ };

// eslint-disable-next-line react/no-find-dom-node
this.node = _reactDom2.default.findDOMNode(this);
this.node = ReactDOM.findDOMNode(this);
}

@@ -235,19 +212,30 @@ }, {

// if the component is spotted and became disabled,
if (this.state.spotted && !prevProps.disabled && this.props.disabled) {
(0, _handle.forward)('onSpotlightDisappear', null, this.props);
if (this.state.spotted && (!prevProps.disabled && this.props.disabled || !prevProps.spotlightDisabled && this.props.spotlightDisabled)) {
forward('onSpotlightDisappear', null, this.props);
if (lastSelectTarget === this) {
selectCancelled = true;
(0, _handle.forward)('onMouseUp', null, this.props);
forward('onMouseUp', null, this.props);
}
// if spotlight didn't move, find something else to spot starting from here
var current = _spotlight2.default.getCurrent();
if (!_spotlight2.default.getPointerMode() && (!current || this.node === current)) {
var current = Spotlight.getCurrent();
if (!Spotlight.getPointerMode() && (!current || this.node === current)) {
this.node.blur();
(0, _container.getContainersForNode)(this.node).reverse().reduce(function (found, id) {
return found || _spotlight2.default.focus(id);
getContainersForNode(this.node).reverse().reduce(function (found, id) {
return found || Spotlight.focus(id);
}, false);
}
}
// if the component became enabled, notify spotlight to enable restoring "lost" focus
if (!this.props.disabled && !this.props.spotlightDisabled && (prevProps.disabled && !this.props.disabled || prevProps.spotlightDisabled && !this.props.spotlightDisabled)) {
if (!Spotlight.getCurrent() && !Spotlight.getPointerMode() && !Spotlight.isPaused()) {
var containers = getContainersForNode(this.node);
var containerId = Spotlight.getActiveContainer();
if (containers.indexOf(containerId) >= 0) {
Spotlight.focus(containerId);
}
}
}
}

@@ -258,3 +246,3 @@ }, {

if (this.state.spotted) {
(0, _handle.forward)('onSpotlightDisappear', null, this.props);
forward('onSpotlightDisappear', null, this.props);
}

@@ -296,3 +284,3 @@ }

return _react2.default.createElement(Wrapped, _extends({}, rest, {
return React.createElement(Wrapped, _extends({}, rest, {
disabled: disabled,

@@ -305,3 +293,3 @@ tabIndex: tabIndex

return _class;
}(_react2.default.Component), _class.displayName = 'Spottable', _class.propTypes = /** @lends spotlight/Spottable.Spottable.prototype */{
}(React.Component), _class.displayName = 'Spottable', _class.propTypes = /** @lends spotlight/Spottable.Spottable.prototype */{
/**

@@ -314,3 +302,3 @@ * Whether or not the component is in a disabled state.

*/
disabled: _propTypes2.default.bool,
disabled: PropTypes.bool,

@@ -324,3 +312,3 @@ /**

*/
onSpotlightDisappear: _propTypes2.default.func,
onSpotlightDisappear: PropTypes.func,

@@ -334,3 +322,3 @@ /**

*/
onSpotlightDown: _propTypes2.default.func,
onSpotlightDown: PropTypes.func,

@@ -344,3 +332,3 @@ /**

*/
onSpotlightLeft: _propTypes2.default.func,
onSpotlightLeft: PropTypes.func,

@@ -354,3 +342,3 @@ /**

*/
onSpotlightRight: _propTypes2.default.func,
onSpotlightRight: PropTypes.func,

@@ -364,3 +352,3 @@ /**

*/
onSpotlightUp: _propTypes2.default.func,
onSpotlightUp: PropTypes.func,

@@ -374,3 +362,3 @@ /**

*/
spotlightDisabled: _propTypes2.default.bool,
spotlightDisabled: PropTypes.bool,

@@ -384,8 +372,7 @@ /**

*/
tabIndex: _propTypes2.default.number
tabIndex: PropTypes.number
}, _temp;
});
exports.default = Spottable;
exports.Spottable = Spottable;
exports.spottableClass = spottableClass;
export default Spottable;
export { Spottable, spottableClass };

@@ -1,37 +0,18 @@

'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unmountContainer = exports.setLastContainerFromTarget = exports.setLastContainer = exports.setDefaultContainer = exports.setContainerPreviousTarget = exports.rootContainerId = exports.removeContainer = exports.removeAllContainers = exports.isNavigable = exports.isContainer = exports.getSpottableDescendants = exports.getNavigableContainersForNode = exports.getLastContainer = exports.getDefaultContainer = exports.getContainerPreviousTarget = exports.getContainerFocusTarget = exports.configureContainer = exports.configureDefaults = exports.containerAttribute = exports.setContainerLastFocusedElement = exports.getContainerNavigableElements = exports.getContainerLastFocusedElement = exports.getContainerDefaultElement = exports.getContainerConfig = exports.getContainersForNode = exports.getContainerNode = exports.getAllContainerIds = undefined;
/**
* Exports methods and members for creating and maintaining spotlight containers.
*
* @module spotlight/container
* @private
*/
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /**
* Exports methods and members for creating and maintaining spotlight containers.
*
* @module spotlight/container
* @private
*/
import and from 'ramda/src/and';
import concat from 'ramda/src/concat';
import { coerceArray } from '@enact/core/util';
import intersection from 'ramda/src/intersection';
import last from 'ramda/src/last';
var _and = require('ramda/src/and');
import { matchSelector } from './utils';
var _and2 = _interopRequireDefault(_and);
var _concat = require('ramda/src/concat');
var _concat2 = _interopRequireDefault(_concat);
var _util = require('@enact/core/util');
var _intersection = require('ramda/src/intersection');
var _intersection2 = _interopRequireDefault(_intersection);
var _last = require('ramda/src/last');
var _last2 = _interopRequireDefault(_last);
var _utils = require('./utils');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var containerAttribute = 'data-container-id';

@@ -63,14 +44,5 @@ var containerConfigs = new Map();

var GlobalConfig = {
selector: '', // can be a valid <extSelector> except "@" syntax.
straightOnly: false,
straightOverlapThreshold: 0.5,
rememberSource: false,
selectorDisabled: false,
continue5WayHold: false,
defaultElement: '', // <extSelector> except "@" syntax.
enterTo: '', // '', 'last-focused', 'default-element'
leaveFor: null, // {left: <extSelector>, right: <extSelector>, up: <extSelector>, down: <extSelector>}
restrict: 'self-first', // 'self-first', 'self-only', 'none'
tabIndexIgnoreList: 'a, input, select, textarea, button, iframe, [contentEditable=true]',
navigableFilter: null,
overflow: false,
lastFocusedElement: null,

@@ -87,6 +59,17 @@ lastFocusedKey: null,

lastFocusedRestore: function lastFocusedRestore(_ref, all) {
var key = _ref.key;
var container = _ref.container,
key = _ref.key;
return all[key];
}
return container ? key : all[key];
},
leaveFor: null, // {left: <extSelector>, right: <extSelector>, up: <extSelector>, down: <extSelector>}
navigableFilter: null,
overflow: false,
rememberSource: false,
restrict: 'self-first', // 'self-first', 'self-only', 'none'
selector: '', // can be a valid <extSelector> except "@" syntax.
selectorDisabled: false,
straightOnly: false,
straightOverlapThreshold: 0.5,
tabIndexIgnoreList: 'a, input, select, textarea, button, iframe, [contentEditable=true]'
};

@@ -200,3 +183,3 @@

return container.dataset.containerDisabled !== 'true';
}).reduce(_and2.default, true);
}).reduce(and, true);
};

@@ -351,6 +334,18 @@

return [n];
}).reduce(_concat2.default, []);
}).reduce(concat, []);
};
/**
* Determines if a container allows 5-way key hold to be preserved or not.
*
* @param {String} containerId Container Id
* @returns {Boolean} `true` if a container is 5 way holdable
* @memberof spotlight/container
* @private
*/
var isContainer5WayHoldable = function isContainer5WayHoldable(containerId) {
return getContainerConfig(containerId).continue5WayHold || false;
};
/**
* Returns an array of ids for containers that wrap the element, in order of outer-to-inner, with

@@ -543,3 +538,3 @@ * the last array item being the immediate container id of the element.

var config = getContainerConfig(containerId);
if (verify && config.selector && !isContainer(node) && !(0, _utils.matchSelector)(config.selector, node)) {
if (verify && config.selector && !isContainer(node) && !matchSelector(config.selector, node)) {
return false;

@@ -587,3 +582,3 @@ }

defaultElementSelector = (0, _util.coerceArray)(defaultElementSelector);
defaultElementSelector = coerceArray(defaultElementSelector);
var spottables = getDeepSpottableDescendants(containerId);

@@ -598,3 +593,3 @@

return spottables.filter(function (elem) {
return (0, _utils.matchSelector)(selector, elem) && isNavigable(elem, containerId, true);
return matchSelector(selector, elem) && isNavigable(elem, containerId, true);
})[0];

@@ -612,5 +607,5 @@ }

*
* @param {String} containerId ID of container
* @param {String} containerId ID of container
*
* @returns {Node} DOM Node last focused
* @returns {Node|String} DOM Node last focused
* @memberof spotlight/container

@@ -623,3 +618,11 @@ * @public

return isNavigable(lastFocusedElement, containerId, true) ? lastFocusedElement : null;
// lastFocusedElement may be a container ID so try to convert it to a node to test navigability
var node = lastFocusedElement;
if (typeof node === 'string') {
node = getContainerNode(lastFocusedElement);
}
return isNavigable(node, containerId, true) ? lastFocusedElement : null;
}

@@ -684,3 +687,3 @@

return next ? (0, _util.coerceArray)(next) : [];
return next ? coerceArray(next) : [];
}

@@ -702,9 +705,16 @@

var next = getContainerNavigableElements(containerId)[0] || null;
if (isContainer(next)) {
var nextId = isContainerNode(next) ? getContainerId(next) : next;
return getContainerFocusTarget(nextId);
}
var next = getContainerNavigableElements(containerId);
return next;
// If multiple candidates returned, we need to find the first viable target since some may
// be empty containers which should be skipped.
return next.reduce(function (result, element) {
if (result) {
return result;
} else if (isContainer(element)) {
var nextId = isContainerNode(element) ? getContainerId(element) : element;
return getContainerFocusTarget(nextId);
}
return element;
}, null) || null;
}

@@ -829,5 +839,5 @@

var targetContainers = getContainersForNode(target);
var targetInnerContainer = (0, _last2.default)(targetContainers);
var targetInnerContainer = last(targetContainers);
var sharedContainer = (0, _last2.default)((0, _intersection2.default)(currentContainers, targetContainers));
var sharedContainer = last(intersection(currentContainers, targetContainers));

@@ -845,28 +855,10 @@ if (sharedContainer || currentContainerConfig.restrict !== 'self-only') {

exports.getAllContainerIds = getAllContainerIds;
exports.getContainerNode = getContainerNode;
exports.getContainersForNode = getContainersForNode;
exports.getContainerConfig = getContainerConfig;
exports.getContainerDefaultElement = getContainerDefaultElement;
exports.getContainerLastFocusedElement = getContainerLastFocusedElement;
exports.getContainerNavigableElements = getContainerNavigableElements;
exports.setContainerLastFocusedElement = setContainerLastFocusedElement;
exports.containerAttribute = containerAttribute;
exports.configureDefaults = configureDefaults;
exports.configureContainer = configureContainer;
exports.getContainerFocusTarget = getContainerFocusTarget;
exports.getContainerPreviousTarget = getContainerPreviousTarget;
exports.getDefaultContainer = getDefaultContainer;
exports.getLastContainer = getLastContainer;
exports.getNavigableContainersForNode = getNavigableContainersForNode;
exports.getSpottableDescendants = getSpottableDescendants;
exports.isContainer = isContainer;
exports.isNavigable = isNavigable;
exports.removeAllContainers = removeAllContainers;
exports.removeContainer = removeContainer;
exports.rootContainerId = rootContainerId;
exports.setContainerPreviousTarget = setContainerPreviousTarget;
exports.setDefaultContainer = setDefaultContainer;
exports.setLastContainer = setLastContainer;
exports.setLastContainerFromTarget = setLastContainerFromTarget;
exports.unmountContainer = unmountContainer;
export {
// Remove
getAllContainerIds, getContainerNode,
// Maybe
getContainerConfig, getContainerDefaultElement, getContainerLastFocusedElement, getContainerNavigableElements, getContainersForNode, isContainer5WayHoldable, setContainerLastFocusedElement,
// Keep
containerAttribute, configureDefaults, configureContainer, getContainerFocusTarget, getContainerPreviousTarget, getDefaultContainer, getLastContainer, getNavigableContainersForNode, getSpottableDescendants, isContainer, isNavigable, removeAllContainers, removeContainer, rootContainerId, setContainerPreviousTarget, setDefaultContainer, setLastContainer, setLastContainerFromTarget, unmountContainer };

@@ -1,7 +0,2 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
function prioritize(priorities) {

@@ -237,3 +232,3 @@ var destPriority = null;

exports.default = navigate;
exports.navigate = navigate;
export default navigate;
export { navigate };

@@ -1,12 +0,11 @@

'use strict';
/**
* Exports methods and members for working with pointer events in spotlight
*
* @module spotlight/pointer
* @private
*/
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.updatePointerPosition = exports.setPointerMode = exports.notifyPointerMove = exports.notifyKeyDown = exports.getPointerMode = exports.getLastPointerPosition = undefined;
import { is } from '@enact/core/keymap';
import { Job } from '@enact/core/util';
var _keymap = require('@enact/core/keymap');
var _util = require('@enact/core/util');
/*

@@ -19,9 +18,2 @@ * Whether Spotlight is in pointer mode (as opposed to 5-way mode).

*/
/**
* Exports methods and members for working with pointer events in spotlight
*
* @module spotlight/pointer
* @private
*/
var _pointerMode = true;

@@ -97,3 +89,3 @@

// event, but not too large that another unrelated event can be fired inside the window
var hidePointerJob = new _util.Job(function (callback) {
var hidePointerJob = new Job(function (callback) {
setPointerMode(false);

@@ -143,6 +135,6 @@ if (callback) {

// for hide/show pointer events, handle them and return true
if ((0, _keymap.is)('pointerHide', keyCode)) {
if (is('pointerHide', keyCode)) {
hidePointerJob.start(callback);
return true;
} else if ((0, _keymap.is)('pointerShow', keyCode)) {
} else if (is('pointerShow', keyCode)) {
setPointerMode(true);

@@ -157,7 +149,2 @@ return true;

exports.getLastPointerPosition = getLastPointerPosition;
exports.getPointerMode = getPointerMode;
exports.notifyKeyDown = notifyKeyDown;
exports.notifyPointerMove = notifyPointerMove;
exports.setPointerMode = setPointerMode;
exports.updatePointerPosition = updatePointerPosition;
export { getLastPointerPosition, getPointerMode, notifyKeyDown, notifyPointerMove, setPointerMode, updatePointerPosition };

@@ -1,30 +0,1 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Spotlight = exports.getDirection = undefined;
var _keymap = require('@enact/core/keymap');
var _last = require('ramda/src/last');
var _last2 = _interopRequireDefault(_last);
var _Accelerator = require('../Accelerator');
var _Accelerator2 = _interopRequireDefault(_Accelerator);
var _Spottable = require('../Spottable');
var _container = require('./container');
var _pointer = require('./pointer');
var _target = require('./target');
var _utils = require('./utils');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*

@@ -48,8 +19,22 @@ * A javascript-based implementation of Spatial Navigation.

var isDown = (0, _keymap.is)('down');
var isEnter = (0, _keymap.is)('enter');
var isLeft = (0, _keymap.is)('left');
var isRight = (0, _keymap.is)('right');
var isUp = (0, _keymap.is)('up');
import { is } from '@enact/core/keymap';
import last from 'ramda/src/last';
import Accelerator from '../Accelerator';
import { spottableClass } from '../Spottable';
import { configureContainer, configureDefaults, getAllContainerIds, getContainerConfig, getContainerLastFocusedElement, getContainersForNode, getLastContainer, getSpottableDescendants as _getSpottableDescendants, isContainer, isContainer5WayHoldable, isNavigable, unmountContainer, removeAllContainers, removeContainer, rootContainerId, setContainerLastFocusedElement, setContainerPreviousTarget, setDefaultContainer, setLastContainer, setLastContainerFromTarget } from './container';
import { getLastPointerPosition, getPointerMode, notifyKeyDown, notifyPointerMove, setPointerMode } from './pointer';
import { getNavigableTarget, getTargetByContainer, getTargetByDirectionFromElement, getTargetByDirectionFromPosition, getTargetBySelector } from './target';
import { matchSelector, parseSelector } from './utils';
var isDown = is('down');
var isEnter = is('enter');
var isLeft = is('left');
var isRight = is('right');
var isUp = is('up');
/**

@@ -68,3 +53,3 @@ * Translates keyCodes into 5-way direction descriptions (e.g. `'down'`)

var SpotlightAccelerator = new _Accelerator2.default();
var SpotlightAccelerator = new Accelerator();

@@ -121,3 +106,3 @@ /**

function shouldPreventNavigation() {
return !(0, _container.getAllContainerIds)().length || _pause;
return !getAllContainerIds().length || _pause;
}

@@ -137,4 +122,4 @@

if ((0, _pointer.getPointerMode)() && !fromPointer) {
(0, _container.setContainerLastFocusedElement)(elem, containerIds);
if (getPointerMode() && !fromPointer) {
setContainerLastFocusedElement(elem, containerIds);
return false;

@@ -184,8 +169,8 @@ }

if (!containerIds || !containerIds.length) {
containerIds = (0, _container.getContainersForNode)(elem);
containerIds = getContainersForNode(elem);
}
var containerId = (0, _last2.default)(containerIds);
var containerId = last(containerIds);
if (containerId) {
(0, _container.setContainerLastFocusedElement)(elem, containerIds);
(0, _container.setLastContainer)(containerId);
setContainerLastFocusedElement(elem, containerIds);
setLastContainer(containerId);
}

@@ -195,9 +180,9 @@ }

function spotNextFromPoint(direction, position) {
var containerId = (0, _container.getLastContainer)();
var next = (0, _target.getTargetByDirectionFromPosition)(direction, position, containerId);
var containerId = getLastContainer();
var next = getTargetByDirectionFromPosition(direction, position, containerId);
if (next) {
(0, _container.setContainerPreviousTarget)(containerId, direction, next, (0, _container.getContainerLastFocusedElement)(containerId));
setContainerPreviousTarget(containerId, direction, next, getContainerLastFocusedElement(containerId));
return focusElement(next, (0, _container.getContainersForNode)(next));
return focusElement(next, getContainersForNode(next));
}

@@ -209,15 +194,15 @@

function spotNext(direction, currentFocusedElement, currentContainerIds) {
var next = (0, _target.getTargetByDirectionFromElement)(direction, currentFocusedElement);
var next = getTargetByDirectionFromElement(direction, currentFocusedElement);
if (next) {
var currentContainerId = (0, _last2.default)(currentContainerIds);
var nextContainerIds = (0, _container.getContainersForNode)(next);
var currentContainerId = last(currentContainerIds);
var nextContainerIds = getContainersForNode(next);
// prevent focus if 5-way is being held and the next element isn't wrapped by
// the current element's immediate container
if (_5WayKeyHold && nextContainerIds.indexOf(currentContainerId) < 0) {
if (_5WayKeyHold && nextContainerIds.indexOf(currentContainerId) < 0 && !isContainer5WayHoldable(currentContainerId)) {
return false;
}
(0, _container.setContainerPreviousTarget)(currentContainerId, direction, next, currentFocusedElement);
setContainerPreviousTarget(currentContainerId, direction, next, currentFocusedElement);

@@ -235,8 +220,8 @@ return focusElement(next, nextContainerIds);

if (!currentFocusedElement) {
var lastContainerId = (0, _container.getLastContainer)();
var lastContainerId = getLastContainer();
if (lastContainerId) {
currentFocusedElement = (0, _container.getContainerLastFocusedElement)(lastContainerId);
currentFocusedElement = getContainerLastFocusedElement(lastContainerId);
}
if (!currentFocusedElement) {
focusElement((0, _target.getTargetByContainer)(), (0, _container.getContainersForNode)(currentFocusedElement));
focusElement(getTargetByContainer(), getContainersForNode(currentFocusedElement));

@@ -247,3 +232,3 @@ return preventDefault(evt);

var currentContainerIds = (0, _container.getContainersForNode)(currentFocusedElement);
var currentContainerIds = getContainersForNode(currentFocusedElement);
if (direction && !spotNext(direction, currentFocusedElement, currentContainerIds) && currentFocusedElement !== document.activeElement) {

@@ -270,6 +255,11 @@ focusElement(currentFocusedElement, currentContainerIds);

// If the window was previously blurred while in pointer mode, the last active containerId may
// not have yet set focus to its spottable elements. For this reason we can't rely on setting focus
// to the last focused element of the last active containerId, so we use rootContainerId instead
Spotlight.focus((0, _container.getContainerLastFocusedElement)(_container.rootContainerId));
// Normally, there isn't focus at this point because we've blurred it above. On webOS, the
// platform may focus the window after the app has already focused a component so we prevent
// trying to focus something else (potentially) if focus is set.
if (!_getCurrent()) {
// If the window was previously blurred while in pointer mode, the last active containerId may
// not have yet set focus to its spottable elements. For this reason we can't rely on setting focus
// to the last focused element of the last active containerId, so we use rootContainerId instead
Spotlight.focus(getContainerLastFocusedElement(rootContainerId));
}
}

@@ -287,5 +277,5 @@

function handlePointerHide() {
var lastContainerId = (0, _container.getLastContainer)();
var lastContainerId = getLastContainer();
if (!_getCurrent() && lastContainerId) {
Spotlight.focus((0, _container.getContainerLastFocusedElement)(lastContainerId));
Spotlight.focus(getContainerLastFocusedElement(lastContainerId));
}

@@ -301,3 +291,3 @@ }

var direction = getDirection(keyCode);
var pointerHandled = (0, _pointer.notifyKeyDown)(keyCode, handlePointerHide);
var pointerHandled = notifyKeyDown(keyCode, handlePointerHide);

@@ -311,4 +301,4 @@ if (pointerHandled || !(direction || isEnter(keyCode))) {

SpotlightAccelerator.processKey(evt, onAcceleratedKeyDown);
} else if (!spotNextFromPoint(direction, (0, _pointer.getLastPointerPosition)())) {
Spotlight.focus((0, _container.getContainerLastFocusedElement)((0, _container.getLastContainer)()));
} else if (!spotNextFromPoint(direction, getLastPointerPosition())) {
Spotlight.focus(getContainerLastFocusedElement(getLastContainer()));
}

@@ -331,6 +321,6 @@ _5WayKeyHold = true;

var current = _getCurrent();
var update = (0, _pointer.notifyPointerMove)(current, target, clientX, clientY);
var update = notifyPointerMove(current, target, clientX, clientY);
if (update) {
var next = (0, _target.getNavigableTarget)(target);
var next = getNavigableTarget(target);

@@ -340,3 +330,3 @@ // TODO: Consider encapsulating this work within focusElement

if (next) {
focusElement(next, (0, _container.getContainersForNode)(next), true);
focusElement(next, getContainersForNode(next), true);

@@ -346,3 +336,3 @@ return true;

current.blur();
(0, _container.setLastContainerFromTarget)(current, target);
setLastContainerFromTarget(current, target);
}

@@ -359,7 +349,7 @@ }

if ((0, _pointer.getPointerMode)()) {
var next = (0, _target.getNavigableTarget)(target); // account for child controls
if (getPointerMode()) {
var next = getNavigableTarget(target); // account for child controls
if (next && next !== _getCurrent()) {
focusElement(next, (0, _container.getContainersForNode)(next), true);
focusElement(next, getContainersForNode(next), true);

@@ -391,5 +381,5 @@ return true;

window.addEventListener('mousemove', onMouseMove);
(0, _container.setLastContainer)(_container.rootContainerId);
(0, _container.configureDefaults)(containerDefaults);
(0, _container.configureContainer)(_container.rootContainerId);
setLastContainer(rootContainerId);
configureDefaults(containerDefaults);
configureContainer(rootContainerId);
_initialized = true;

@@ -421,5 +411,5 @@ }

clear: function clear() {
(0, _container.removeAllContainers)();
(0, _container.setDefaultContainer)();
(0, _container.setLastContainer)();
removeAllContainers();
setDefaultContainer();
setLastContainer();
_duringFocusChange = false;

@@ -439,3 +429,3 @@ },

set: function set(containerId, config) {
(0, _container.configureContainer)(containerId, config);
configureContainer(containerId, config);
},

@@ -455,3 +445,3 @@

add: function add(containerId, config) {
return (0, _container.configureContainer)(containerId, config);
return configureContainer(containerId, config);
},

@@ -463,3 +453,3 @@

}
(0, _container.unmountContainer)(containerId);
unmountContainer(containerId);
},

@@ -478,5 +468,5 @@

}
if ((0, _container.getContainerConfig)(containerId)) {
(0, _container.removeContainer)(containerId);
if ((0, _container.getLastContainer)() === containerId) {
if (getContainerConfig(containerId)) {
removeContainer(containerId);
if (getLastContainer() === containerId) {
Spotlight.setActiveContainer(null);

@@ -497,4 +487,4 @@ }

disableSelector: function disableSelector(containerId) {
if ((0, _container.isContainer)(containerId)) {
(0, _container.configureContainer)(containerId, { selectorDisabled: false });
if (isContainer(containerId)) {
configureContainer(containerId, { selectorDisabled: false });
return true;

@@ -514,4 +504,4 @@ }

enableSelector: function enableSelector(containerId) {
if ((0, _container.isContainer)(containerId)) {
(0, _container.configureContainer)(containerId, { selectorDisabled: false });
if (isContainer(containerId)) {
configureContainer(containerId, { selectorDisabled: false });
return true;

@@ -558,17 +548,23 @@ }

var target = elem;
var wasContainerId = false;
if (!elem) {
target = (0, _target.getTargetByContainer)();
target = getTargetByContainer();
} else if (typeof elem === 'string') {
if ((0, _container.getContainerConfig)(elem)) {
target = (0, _target.getTargetByContainer)(elem);
if (getContainerConfig(elem)) {
target = getTargetByContainer(elem);
wasContainerId = true;
} else {
target = (0, _target.getTargetBySelector)(elem);
target = getTargetBySelector(elem);
}
}
var nextContainerIds = (0, _container.getContainersForNode)(target);
var nextContainerId = (0, _last2.default)(nextContainerIds);
if ((0, _container.isNavigable)(target, nextContainerId)) {
var nextContainerIds = getContainersForNode(target);
var nextContainerId = last(nextContainerIds);
if (isNavigable(target, nextContainerId)) {
return focusElement(target, nextContainerIds);
} else if (wasContainerId) {
// if we failed to find a spottable target within the provided container, we'll set
// it as the active container to allow it to focus itself if its contents change
this.setActiveContainer(elem);
}

@@ -597,3 +593,3 @@

var elem = selector ? (0, _utils.parseSelector)(selector)[0] : _getCurrent();
var elem = selector ? parseSelector(selector)[0] : _getCurrent();
if (!elem) {

@@ -603,3 +599,3 @@ return false;

var containerIds = (0, _container.getContainersForNode)(elem);
var containerIds = getContainersForNode(elem);
if (!containerIds.length) {

@@ -619,3 +615,3 @@ return false;

*/
setDefaultContainer: _container.setDefaultContainer,
setDefaultContainer: setDefaultContainer,

@@ -628,3 +624,3 @@ /**

*/
getActiveContainer: _container.getLastContainer,
getActiveContainer: getLastContainer,

@@ -639,3 +635,3 @@ /**

setActiveContainer: function setActiveContainer(containerId) {
(0, _container.setLastContainer)(containerId || _container.rootContainerId);
setLastContainer(containerId || rootContainerId);
},

@@ -650,3 +646,3 @@

*/
getPointerMode: _pointer.getPointerMode,
getPointerMode: getPointerMode,

@@ -661,3 +657,3 @@ /**

*/
setPointerMode: _pointer.setPointerMode,
setPointerMode: setPointerMode,

@@ -676,3 +672,3 @@ /**

return (0, _utils.matchSelector)('[data-container-muted="true"] .' + _Spottable.spottableClass, elem);
return matchSelector('[data-container-muted="true"] .' + spottableClass, elem);
},

@@ -702,3 +698,3 @@

return (0, _utils.matchSelector)('.' + _Spottable.spottableClass, elem);
return matchSelector('.' + spottableClass, elem);
},

@@ -728,3 +724,3 @@

return (0, _container.getSpottableDescendants)(containerId);
return _getSpottableDescendants(containerId);
}

@@ -736,4 +732,3 @@ };

exports.default = Spotlight;
exports.getDirection = getDirection;
exports.Spotlight = Spotlight;
export default Spotlight;
export { getDirection, Spotlight };

@@ -1,26 +0,11 @@

'use strict';
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getTargetBySelector = exports.getTargetByDirectionFromPosition = exports.getTargetByDirectionFromElement = exports.getTargetByContainer = exports.getNavigableTarget = undefined;
import last from 'ramda/src/last';
var _last = require('ramda/src/last');
import { getAllContainerIds, getContainerConfig, getContainerFocusTarget, getContainerNode, getContainerPreviousTarget, getContainersForNode, getDefaultContainer, getLastContainer, getNavigableContainersForNode, getSpottableDescendants, isContainer, isNavigable } from './container';
import navigate from './navigate';
import { contains, getContainerRect, getPointRect, getRect, getRects, intersects, parseSelector } from './utils';
var _last2 = _interopRequireDefault(_last);
var _container = require('./container');
var _navigate = require('./navigate');
var _navigate2 = _interopRequireDefault(_navigate);
var _utils = require('./utils');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function isFocusable(elem) {
var containers = (0, _container.getContainersForNode)(elem);
var containers = getContainersForNode(elem);
var verifySelector = true;

@@ -30,3 +15,3 @@

var containerId = containers[i];
if (!(0, _container.isNavigable)(elem, containerId, verifySelector)) {
if (!isNavigable(elem, containerId, verifySelector)) {
return false;

@@ -45,3 +30,3 @@ }

var addRange = function addRange(id) {
var config = (0, _container.getContainerConfig)(id);
var config = getContainerConfig(id);
if (id && range.indexOf(id) < 0 && config && !config.selectorDisabled) {

@@ -55,5 +40,5 @@ range.push(id);

} else {
addRange((0, _container.getDefaultContainer)());
addRange((0, _container.getLastContainer)());
[].concat(_toConsumableArray((0, _container.getAllContainerIds)())).map(addRange);
addRange(getDefaultContainer());
addRange(getLastContainer());
[].concat(_toConsumableArray(getAllContainerIds())).map(addRange);
}

@@ -66,3 +51,3 @@

return getContainersToSearch(containerId).reduce(function (next, id) {
return next || (0, _container.getContainerFocusTarget)(id);
return next || getContainerFocusTarget(id);
}, null);

@@ -80,6 +65,6 @@ }

var next = (0, _utils.parseSelector)(selector)[0];
var next = parseSelector(selector)[0];
if (next) {
var nextContainerIds = (0, _container.getContainersForNode)(next);
if ((0, _container.isNavigable)(next, (0, _last2.default)(nextContainerIds), true)) {
var nextContainerIds = getContainersForNode(next);
if (isNavigable(next, last(nextContainerIds), true)) {
return next;

@@ -93,3 +78,3 @@ }

function isRestrictedContainer(containerId) {
var config = (0, _container.getContainerConfig)(containerId);
var config = getContainerConfig(containerId);
return config.enterTo === 'last-focused' || config.enterTo === 'default-element';

@@ -99,4 +84,4 @@ }

function getSpottableDescendantsWithoutContainers(containerId, containerIds) {
return (0, _container.getSpottableDescendants)(containerId).filter(function (n) {
return !(0, _container.isContainer)(n) || containerIds.indexOf(n.dataset.containerId) === -1;
return getSpottableDescendants(containerId).filter(function (n) {
return !isContainer(n) || containerIds.indexOf(n.dataset.containerId) === -1;
});

@@ -112,8 +97,8 @@ }

return elementRects.filter(function (rect) {
if ((0, _container.isContainer)(rect.element)) {
if (isContainer(rect.element)) {
// For containers, test intersection since they may be larger than the bounding rect
return (0, _utils.intersects)(boundingRect, rect);
return intersects(boundingRect, rect);
} else {
// For elements, use contains with the center to include mostly visible elements
return (0, _utils.contains)(boundingRect, rect.center);
return contains(boundingRect, rect.center);
}

@@ -126,3 +111,3 @@ });

var overlapping = elementRects.filter(function (rect) {
return (0, _container.isContainer)(rect.element) && (0, _utils.contains)(rect, elementRect);
return isContainer(rect.element) && contains(rect, elementRect);
});

@@ -145,5 +130,5 @@

// a container tree with `element`
var nextConfig = (0, _container.getContainerConfig)(containerId);
var nextConfig = getContainerConfig(containerId);
if (nextConfig.overflow) {
return (0, _utils.getContainerRect)(containerId);
return getContainerRect(containerId);
}

@@ -154,3 +139,3 @@ }

var elements = getSpottableDescendantsWithoutContainers(containerId, elementContainerIds);
var elementRects = filterRects((0, _utils.getRects)(elements), boundingRect);
var elementRects = filterRects(getRects(elements), boundingRect);

@@ -180,6 +165,6 @@ var next = null;

// try to navigate from position to one of the candidates in containerId
next = (0, _navigate2.default)(positionRect, direction, elementRects, (0, _container.getContainerConfig)(containerId));
next = navigate(positionRect, direction, elementRects, getContainerConfig(containerId));
// if we match a container, recurse into it
if (next && (0, _container.isContainer)(next)) {
if (next && isContainer(next)) {
var nextContainerId = next.dataset.containerId;

@@ -224,3 +209,3 @@

// shortcut for previous target from element if it were saved
var previous = (0, _container.getContainerPreviousTarget)(containerId, direction, element);
var previous = getContainerPreviousTarget(containerId, direction, element);
if (previous && elements.indexOf(previous) !== -1) {

@@ -230,3 +215,3 @@ return previous;

var elementRects = filterRects((0, _utils.getRects)(elements), boundingRect);
var elementRects = filterRects(getRects(elements), boundingRect);

@@ -257,6 +242,6 @@ var next = null;

// try to navigate from element to one of the candidates in containerId
next = (0, _navigate2.default)(elementRect, direction, elementRects, (0, _container.getContainerConfig)(containerId));
next = navigate(elementRect, direction, elementRects, getContainerConfig(containerId));
// if we match a container,
if (next && (0, _container.isContainer)(next)) {
if (next && isContainer(next)) {
var nextContainerId = next.dataset.containerId;

@@ -308,5 +293,5 @@

var elementRect = (0, _utils.getRect)(element);
var elementRect = getRect(element);
return (0, _container.getNavigableContainersForNode)(element).reduceRight(function (result, containerId, index, elementContainerIds) {
return getNavigableContainersForNode(element).reduceRight(function (result, containerId, index, elementContainerIds) {
result = result || getTargetInContainerByDirectionFromElement(direction, containerId, element, elementRect, elementContainerIds);

@@ -330,5 +315,5 @@

function getTargetByDirectionFromPosition(direction, position, containerId) {
var pointerRect = (0, _utils.getPointRect)(position);
var pointerRect = getPointRect(position);
return (0, _container.getNavigableContainersForNode)((0, _container.getContainerNode)(containerId)).reduceRight(function (result, id, index, elementContainerIds) {
return getNavigableContainersForNode(getContainerNode(containerId)).reduceRight(function (result, id, index, elementContainerIds) {
return result || getTargetInContainerByDirectionFromPosition(direction, id, pointerRect, elementContainerIds);

@@ -350,3 +335,3 @@ }, null);

function getLeaveForTarget(containerId, direction) {
var config = (0, _container.getContainerConfig)(containerId);
var config = getContainerConfig(containerId);

@@ -361,4 +346,4 @@ var target = config.restrict !== 'self-only' && config.leaveFor && config.leaveFor[direction];

var nextContainerIds = (0, _container.getContainersForNode)(target);
if ((0, _container.isNavigable)(target, (0, _last2.default)(nextContainerIds))) {
var nextContainerIds = getContainersForNode(target);
if (isNavigable(target, last(nextContainerIds))) {
return target;

@@ -374,3 +359,3 @@ }

var parent = void 0;
while (target && ((0, _container.isContainer)(target) || !isFocusable(target))) {
while (target && (isContainer(target) || !isFocusable(target))) {
parent = target.parentNode;

@@ -382,6 +367,2 @@ target = parent === document ? null : parent; // calling isNavigable on document is problematic

exports.getNavigableTarget = getNavigableTarget;
exports.getTargetByContainer = getTargetByContainer;
exports.getTargetByDirectionFromElement = getTargetByDirectionFromElement;
exports.getTargetByDirectionFromPosition = getTargetByDirectionFromPosition;
exports.getTargetBySelector = getTargetBySelector;
export { getNavigableTarget, getTargetByContainer, getTargetByDirectionFromElement, getTargetByDirectionFromPosition, getTargetBySelector };

@@ -1,38 +0,37 @@

'use strict';
var _node, _container, _container2, _container3, _container4, _container5, _container6, _container7, _container8, _container9, _container10, _container11, _container12, _container13, _container15;
var _node, _container, _container2, _container3, _container4, _container5, _container6, _container7, _container8, _container9, _container10, _container11, _container12, _container13;
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _container14 = require('../container');
import { configureContainer, configureDefaults, containerAttribute, getAllContainerIds, getContainerConfig, getContainerFocusTarget, getContainersForNode, getLastContainer, getSpottableDescendants, isContainer, isNavigable, unmountContainer, removeContainer, rootContainerId, setContainerLastFocusedElement, setLastContainer, setLastContainerFromTarget } from '../container';
var _utils = require('./utils');
import { container, join, node, someContainers, someNodes, someSpottables, someSpottablesAndContainers, spottable, testScenario } from './utils';
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var nonSpottable = function nonSpottable() {
return (0, _utils.node)({ className: 'other' });
return node({ className: 'other' });
};
var scenarios = {
onlySpottables: (0, _utils.someSpottables)(5),
onlyContainers: (0, _utils.someContainers)(5),
spottableAndContainers: (0, _utils.someSpottablesAndContainers)(5),
nonSpottableSiblings: (0, _utils.join)((0, _utils.someSpottables)(5), (0, _utils.someNodes)(nonSpottable, 5)),
nestedContainers: (0, _utils.container)((0, _utils.container)((0, _utils.container)())),
disabledContainers: (0, _utils.join)((0, _utils.someSpottables)(5), (0, _utils.someContainers)(5), (0, _utils.node)((_node = {}, _defineProperty(_node, _container14.containerAttribute, 'disabled-container'), _defineProperty(_node, 'data-container-disabled', true), _node))),
nestedContainersWithSpottables: (0, _utils.join)((0, _utils.someSpottables)(5), (0, _utils.container)({ children: (0, _utils.someSpottables)(5) })),
siblingContainers: (0, _utils.join)((0, _utils.container)((_container = {}, _defineProperty(_container, _container14.containerAttribute, 'first'), _defineProperty(_container, 'children', (0, _utils.someSpottables)(5)), _container)), (0, _utils.container)((_container2 = {}, _defineProperty(_container2, _container14.containerAttribute, 'second'), _defineProperty(_container2, 'children', (0, _utils.someSpottables)(5)), _container2))),
mixedOrder: (0, _utils.join)((0, _utils.container)((_container3 = {}, _defineProperty(_container3, _container14.containerAttribute, 'first'), _defineProperty(_container3, 'name', 'c1'), _container3)), (0, _utils.spottable)({ name: 's1' }), (0, _utils.container)((_container4 = {}, _defineProperty(_container4, _container14.containerAttribute, 'second'), _defineProperty(_container4, 'name', 'c2'), _container4)), (0, _utils.spottable)({ name: 's2' })),
complexTree: (0, _utils.join)((0, _utils.spottable)(nonSpottable()), (0, _utils.container)((_container7 = {}, _defineProperty(_container7, _container14.containerAttribute, 'first-container'), _defineProperty(_container7, 'children', (0, _utils.join)((0, _utils.someSpottables)(2), (0, _utils.container)((_container6 = {}, _defineProperty(_container6, _container14.containerAttribute, 'second-container'), _defineProperty(_container6, 'children', (0, _utils.join)((0, _utils.spottable)({ id: 'secondContainerFirstSpottable' }), (0, _utils.someSpottables)(2), (0, _utils.container)((_container5 = {}, _defineProperty(_container5, _container14.containerAttribute, 'third-container'), _defineProperty(_container5, 'data-container-disabled', true), _defineProperty(_container5, 'children', (0, _utils.join)((0, _utils.someSpottables)(4), (0, _utils.node)({ id: 'child-of-third' }))), _container5)))), _container6)))), _container7))),
spottablesInDisabledContainer: (0, _utils.container)((_container8 = {}, _defineProperty(_container8, _container14.containerAttribute, 'container'), _defineProperty(_container8, 'data-container-disabled', true), _defineProperty(_container8, 'children', (0, _utils.someSpottables)(5)), _container8)),
spottablesInNestedDisabledContainer: (0, _utils.container)((_container10 = {}, _defineProperty(_container10, _container14.containerAttribute, 'container'), _defineProperty(_container10, 'data-container-disabled', true), _defineProperty(_container10, 'children', (0, _utils.container)((_container9 = {}, _defineProperty(_container9, _container14.containerAttribute, 'child'), _defineProperty(_container9, 'children', (0, _utils.someSpottables)(5)), _container9))), _container10)),
containerWithDefaultAndLastFocused: (0, _utils.container)((_container11 = {}, _defineProperty(_container11, _container14.containerAttribute, 'container'), _defineProperty(_container11, 'children', (0, _utils.join)((0, _utils.spottable)({ id: 'firstSpottable' }), (0, _utils.someSpottables)(5), (0, _utils.node)({ id: 'spottableDefault', className: 'spottable spottable-default' }), (0, _utils.spottable)({ id: 'lastFocused' }))), _container11)),
nestedContainersWithDefaultAndLastFocused: (0, _utils.container)((_container13 = {}, _defineProperty(_container13, _container14.containerAttribute, 'container'), _defineProperty(_container13, 'children', (0, _utils.join)((0, _utils.spottable)({ id: 'firstSpottable' }), (0, _utils.someSpottables)(5), (0, _utils.container)((_container12 = {}, _defineProperty(_container12, _container14.containerAttribute, 'child'), _defineProperty(_container12, 'id', 'spottableDefault'), _defineProperty(_container12, 'className', 'spottable-default'), _defineProperty(_container12, 'children', (0, _utils.join)((0, _utils.spottable)({ id: 'firstChildSpottable' }), (0, _utils.someSpottables)(5), (0, _utils.spottable)({ id: 'lastChildFocused' }))), _container12)), (0, _utils.spottable)({ id: 'lastFocused' }))), _container13))
onlySpottables: someSpottables(5),
onlyContainers: someContainers(5),
spottableAndContainers: someSpottablesAndContainers(5),
nonSpottableSiblings: join(someSpottables(5), someNodes(nonSpottable, 5)),
nestedContainers: container(container(container())),
disabledContainers: join(someSpottables(5), someContainers(5), node((_node = {}, _defineProperty(_node, containerAttribute, 'disabled-container'), _defineProperty(_node, 'data-container-disabled', true), _node))),
nestedContainersWithSpottables: join(someSpottables(5), container({ children: someSpottables(5) })),
siblingContainers: join(container((_container = {}, _defineProperty(_container, containerAttribute, 'first'), _defineProperty(_container, 'children', someSpottables(5)), _container)), container((_container2 = {}, _defineProperty(_container2, containerAttribute, 'second'), _defineProperty(_container2, 'children', someSpottables(5)), _container2))),
mixedOrder: join(container((_container3 = {}, _defineProperty(_container3, containerAttribute, 'first'), _defineProperty(_container3, 'name', 'c1'), _container3)), spottable({ name: 's1' }), container((_container4 = {}, _defineProperty(_container4, containerAttribute, 'second'), _defineProperty(_container4, 'name', 'c2'), _container4)), spottable({ name: 's2' })),
complexTree: join(spottable(nonSpottable()), container((_container7 = {}, _defineProperty(_container7, containerAttribute, 'first-container'), _defineProperty(_container7, 'children', join(someSpottables(2), container((_container6 = {}, _defineProperty(_container6, containerAttribute, 'second-container'), _defineProperty(_container6, 'children', join(spottable({ id: 'secondContainerFirstSpottable' }), someSpottables(2), container((_container5 = {}, _defineProperty(_container5, containerAttribute, 'third-container'), _defineProperty(_container5, 'data-container-disabled', true), _defineProperty(_container5, 'children', join(someSpottables(4), node({ id: 'child-of-third' }))), _container5)))), _container6)))), _container7))),
spottablesInDisabledContainer: container((_container8 = {}, _defineProperty(_container8, containerAttribute, 'container'), _defineProperty(_container8, 'data-container-disabled', true), _defineProperty(_container8, 'children', someSpottables(5)), _container8)),
spottablesInNestedDisabledContainer: container((_container10 = {}, _defineProperty(_container10, containerAttribute, 'container'), _defineProperty(_container10, 'data-container-disabled', true), _defineProperty(_container10, 'children', container((_container9 = {}, _defineProperty(_container9, containerAttribute, 'child'), _defineProperty(_container9, 'children', someSpottables(5)), _container9))), _container10)),
containerWithDefaultAndLastFocused: container((_container11 = {}, _defineProperty(_container11, containerAttribute, 'container'), _defineProperty(_container11, 'children', join(spottable({ id: 'firstSpottable' }), someSpottables(5), node({ id: 'spottableDefault', className: 'spottable spottable-default' }), spottable({ id: 'lastFocused' }))), _container11)),
nestedContainersWithDefaultAndLastFocused: container((_container13 = {}, _defineProperty(_container13, containerAttribute, 'container'), _defineProperty(_container13, 'children', join(spottable({ id: 'firstSpottable' }), someSpottables(5), container((_container12 = {}, _defineProperty(_container12, containerAttribute, 'child'), _defineProperty(_container12, 'id', 'spottableDefault'), _defineProperty(_container12, 'className', 'spottable-default'), _defineProperty(_container12, 'children', join(spottable({ id: 'firstChildSpottable' }), someSpottables(5), spottable({ id: 'lastChildFocused' }))), _container12)), spottable({ id: 'lastFocused' }))), _container13)),
emptySubcontainer: container((_container15 = {}, _defineProperty(_container15, containerAttribute, 'container'), _defineProperty(_container15, 'children', join(container(_defineProperty({}, containerAttribute, 'subcontainer')), spottable({ id: 'afterSubcontainer' }))), _container15))
};
var setupContainers = function setupContainers() {
(0, _container14.configureDefaults)({
configureDefaults({
selector: '.spottable'
});
(0, _container14.configureContainer)(_container14.rootContainerId);
(0, _container14.setLastContainer)(_container14.rootContainerId);
configureContainer(rootContainerId);
setLastContainer(rootContainerId);
};

@@ -42,3 +41,3 @@

// clean up any containers we create for safe tests
(0, _container14.getAllContainerIds)().forEach(_container14.removeContainer);
getAllContainerIds().forEach(removeContainer);
};

@@ -51,5 +50,5 @@

it('should find spottables', (0, _utils.testScenario)(scenarios.onlySpottables, function () {
it('should find spottables', testScenario(scenarios.onlySpottables, function () {
var expected = 5;
var actual = (0, _container14.getSpottableDescendants)(_container14.rootContainerId).length;
var actual = getSpottableDescendants(rootContainerId).length;

@@ -59,5 +58,5 @@ expect(actual).to.equal(expected);

it('should find containers', (0, _utils.testScenario)(scenarios.onlyContainers, function () {
it('should find containers', testScenario(scenarios.onlyContainers, function () {
var expected = 5;
var actual = (0, _container14.getSpottableDescendants)(_container14.rootContainerId).length;
var actual = getSpottableDescendants(rootContainerId).length;

@@ -67,5 +66,5 @@ expect(actual).to.equal(expected);

it('should find spottables and containers', (0, _utils.testScenario)(scenarios.spottableAndContainers, function () {
it('should find spottables and containers', testScenario(scenarios.spottableAndContainers, function () {
var expected = 10;
var actual = (0, _container14.getSpottableDescendants)(_container14.rootContainerId).length;
var actual = getSpottableDescendants(rootContainerId).length;

@@ -75,5 +74,5 @@ expect(actual).to.equal(expected);

it('should only find spottables with non-spottable siblings', (0, _utils.testScenario)(scenarios.nonSpottableSiblings, function () {
it('should only find spottables with non-spottable siblings', testScenario(scenarios.nonSpottableSiblings, function () {
var expected = 5;
var actual = (0, _container14.getSpottableDescendants)(_container14.rootContainerId).length;
var actual = getSpottableDescendants(rootContainerId).length;

@@ -83,5 +82,5 @@ expect(actual).to.equal(expected);

it('should only find top-level containers', (0, _utils.testScenario)(scenarios.nestedContainers, function () {
it('should only find top-level containers', testScenario(scenarios.nestedContainers, function () {
var expected = 1;
var actual = (0, _container14.getSpottableDescendants)(_container14.rootContainerId).length;
var actual = getSpottableDescendants(rootContainerId).length;

@@ -91,5 +90,5 @@ expect(actual).to.equal(expected);

it('should only find top-level containers and spottables', (0, _utils.testScenario)(scenarios.nestedContainersWithSpottables, function () {
it('should only find top-level containers and spottables', testScenario(scenarios.nestedContainersWithSpottables, function () {
var expected = 6;
var actual = (0, _container14.getSpottableDescendants)(_container14.rootContainerId).length;
var actual = getSpottableDescendants(rootContainerId).length;

@@ -99,7 +98,7 @@ expect(actual).to.equal(expected);

it('should not find spottables in sibling containers', (0, _utils.testScenario)(scenarios.siblingContainers, function () {
(0, _container14.configureContainer)('first');
it('should not find spottables in sibling containers', testScenario(scenarios.siblingContainers, function () {
configureContainer('first');
var expected = 5;
var actual = (0, _container14.getSpottableDescendants)('first').length;
var actual = getSpottableDescendants('first').length;

@@ -109,7 +108,7 @@ expect(actual).to.equal(expected);

it('should not find spottables in descendant containers', (0, _utils.testScenario)(scenarios.complexTree, function () {
(0, _container14.configureContainer)('first-container');
it('should not find spottables in descendant containers', testScenario(scenarios.complexTree, function () {
configureContainer('first-container');
var expected = 3;
var actual = (0, _container14.getSpottableDescendants)('first-container').length;
var actual = getSpottableDescendants('first-container').length;

@@ -119,8 +118,8 @@ expect(actual).to.equal(expected);

it('should not find containers that are disabled', (0, _utils.testScenario)(scenarios.complexTree, function () {
(0, _container14.configureContainer)('first-container');
(0, _container14.configureContainer)('second-container');
it('should not find containers that are disabled', testScenario(scenarios.complexTree, function () {
configureContainer('first-container');
configureContainer('second-container');
var expected = 3;
var actual = (0, _container14.getSpottableDescendants)('second-container').length;
var actual = getSpottableDescendants('second-container').length;

@@ -130,7 +129,7 @@ expect(actual).to.equal(expected);

it('should not any spottables within a disabled container', (0, _utils.testScenario)(scenarios.spottablesInDisabledContainer, function () {
(0, _container14.configureContainer)('container');
it('should not any spottables within a disabled container', testScenario(scenarios.spottablesInDisabledContainer, function () {
configureContainer('container');
var expected = 0;
var actual = (0, _container14.getSpottableDescendants)('container').length;
var actual = getSpottableDescendants('container').length;

@@ -140,8 +139,8 @@ expect(actual).to.equal(expected);

it('should not any spottables within a disabled ancestor container', (0, _utils.testScenario)(scenarios.spottablesInNestedDisabledContainer, function () {
(0, _container14.configureContainer)('container');
(0, _container14.configureContainer)('child');
it('should not any spottables within a disabled ancestor container', testScenario(scenarios.spottablesInNestedDisabledContainer, function () {
configureContainer('container');
configureContainer('child');
var expected = 0;
var actual = (0, _container14.getSpottableDescendants)('child').length;
var actual = getSpottableDescendants('child').length;

@@ -151,5 +150,5 @@ expect(actual).to.equal(expected);

it('should return spottables and containers in source order', (0, _utils.testScenario)(scenarios.mixedOrder, function () {
it('should return spottables and containers in source order', testScenario(scenarios.mixedOrder, function () {
var expected = ['c1', 's1', 'c2', 's2'];
var actual = (0, _container14.getSpottableDescendants)(_container14.rootContainerId).map(function (n) {
var actual = getSpottableDescendants(rootContainerId).map(function (n) {
return n.getAttribute('name');

@@ -163,5 +162,5 @@ });

describe('#getContainersForNode', function () {
it('should return the rootContainerId when no other containers exist', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
var expected = [_container14.rootContainerId];
var actual = (0, _container14.getContainersForNode)(root.lastChild);
it('should return the rootContainerId when no other containers exist', testScenario(scenarios.onlySpottables, function (root) {
var expected = [rootContainerId];
var actual = getContainersForNode(root.lastChild);

@@ -171,6 +170,6 @@ expect(actual).to.deep.equal(expected);

it('should return all ancestor container ids', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
it('should return all ancestor container ids', testScenario(scenarios.complexTree, function (root) {
var childOfThird = root.querySelector('#child-of-third');
var expected = [_container14.rootContainerId, 'first-container', 'second-container', 'third-container'];
var actual = (0, _container14.getContainersForNode)(childOfThird);
var expected = [rootContainerId, 'first-container', 'second-container', 'third-container'];
var actual = getContainersForNode(childOfThird);

@@ -180,6 +179,6 @@ expect(actual).to.deep.equal(expected);

it('should return immediate container id as last in list', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
it('should return immediate container id as last in list', testScenario(scenarios.complexTree, function (root) {
var childOfThird = root.querySelector('#child-of-third');
var expected = 'third-container';
var actual = (0, _container14.getContainersForNode)(childOfThird).pop();
var actual = getContainersForNode(childOfThird).pop();

@@ -192,7 +191,7 @@ expect(actual).to.deep.equal(expected);

beforeEach(function () {
(0, _container14.configureContainer)('test-container');
configureContainer('test-container');
});
afterEach(function () {
(0, _container14.removeContainer)('test-container');
removeContainer('test-container');
});

@@ -202,6 +201,6 @@

var div = document.createElement('div');
div.setAttribute(_container14.containerAttribute, 'my-container');
div.setAttribute(containerAttribute, 'my-container');
var expected = true;
var actual = (0, _container14.isContainer)(div);
var actual = isContainer(div);

@@ -215,3 +214,3 @@ expect(actual).to.equal(expected);

var expected = false;
var actual = (0, _container14.isContainer)(div);
var actual = isContainer(div);

@@ -223,3 +222,3 @@ expect(actual).to.equal(expected);

var expected = true;
var actual = (0, _container14.isContainer)('test-container');
var actual = isContainer('test-container');

@@ -231,3 +230,3 @@ expect(actual).to.equal(expected);

var expected = false;
var actual = (0, _container14.isContainer)('unconfigured-container');
var actual = isContainer('unconfigured-container');

@@ -242,4 +241,4 @@ expect(actual).to.equal(expected);

it('should return the last focused element when enterTo is "last-focused"', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function (root) {
(0, _container14.configureContainer)('container', {
it('should return the last focused element when enterTo is "last-focused"', testScenario(scenarios.containerWithDefaultAndLastFocused, function (root) {
configureContainer('container', {
enterTo: 'last-focused',

@@ -249,6 +248,6 @@ defaultElement: '.spottable-default'

(0, _container14.setContainerLastFocusedElement)(root.querySelector('#lastFocused'), ['container']);
setContainerLastFocusedElement(root.querySelector('#lastFocused'), ['container']);
var expected = 'lastFocused';
var actual = (0, _container14.getContainerFocusTarget)('container').id;
var actual = getContainerFocusTarget('container').id;

@@ -258,4 +257,4 @@ expect(actual).to.equal(expected);

it('should return the default spottable element when enterTo is "last-focused" but no element has been focused', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
(0, _container14.configureContainer)('container', {
it('should return the default spottable element when enterTo is "last-focused" but no element has been focused', testScenario(scenarios.containerWithDefaultAndLastFocused, function () {
configureContainer('container', {
enterTo: 'last-focused',

@@ -266,3 +265,3 @@ defaultElement: '.spottable-default'

var expected = 'spottableDefault';
var actual = (0, _container14.getContainerFocusTarget)('container').id;
var actual = getContainerFocusTarget('container').id;

@@ -272,4 +271,4 @@ expect(actual).to.equal(expected);

it('should return the first spottable element when enterTo is "last-focused" and defaultElement is not configured', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
(0, _container14.configureContainer)('container', {
it('should return the first spottable element when enterTo is "last-focused" and defaultElement is not configured', testScenario(scenarios.containerWithDefaultAndLastFocused, function () {
configureContainer('container', {
enterTo: 'last-focused'

@@ -279,3 +278,3 @@ });

var expected = 'firstSpottable';
var actual = (0, _container14.getContainerFocusTarget)('container').id;
var actual = getContainerFocusTarget('container').id;

@@ -285,4 +284,4 @@ expect(actual).to.equal(expected);

it('should return the first spottable element when enterTo is "last-focused" and defaultElement is not found', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
(0, _container14.configureContainer)('container', {
it('should return the first spottable element when enterTo is "last-focused" and defaultElement is not found', testScenario(scenarios.containerWithDefaultAndLastFocused, function () {
configureContainer('container', {
enterTo: 'last-focused',

@@ -294,3 +293,3 @@ // configured, but not found

var expected = 'firstSpottable';
var actual = (0, _container14.getContainerFocusTarget)('container').id;
var actual = getContainerFocusTarget('container').id;

@@ -300,4 +299,4 @@ expect(actual).to.equal(expected);

it('should return the default spottable element when enterTo is "default-element"', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
(0, _container14.configureContainer)('container', {
it('should return the default spottable element when enterTo is "default-element"', testScenario(scenarios.containerWithDefaultAndLastFocused, function () {
configureContainer('container', {
enterTo: 'default-element',

@@ -308,3 +307,3 @@ defaultElement: '.spottable-default'

var expected = 'spottableDefault';
var actual = (0, _container14.getContainerFocusTarget)('container').id;
var actual = getContainerFocusTarget('container').id;

@@ -314,4 +313,4 @@ expect(actual).to.equal(expected);

it('should return the default spottable element when enterTo is "default-element" and defaultElement contains an array of selectors', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
(0, _container14.configureContainer)('container', {
it('should return the default spottable element when enterTo is "default-element" and defaultElement contains an array of selectors', testScenario(scenarios.containerWithDefaultAndLastFocused, function () {
configureContainer('container', {
enterTo: 'default-element',

@@ -322,3 +321,3 @@ defaultElement: ['.does-not-exist', '.spottable-default']

var expected = 'spottableDefault';
var actual = (0, _container14.getContainerFocusTarget)('container').id;
var actual = getContainerFocusTarget('container').id;

@@ -330,4 +329,4 @@ expect(actual).to.equal(expected);

// which was never documented and should be removed in a future release.
it('should return the default spottable element when enterTo is "default-element" and defaultElement contains an array of selectors wiht a node reference', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function (root) {
(0, _container14.configureContainer)('container', {
it('should return the default spottable element when enterTo is "default-element" and defaultElement contains an array of selectors wiht a node reference', testScenario(scenarios.containerWithDefaultAndLastFocused, function (root) {
configureContainer('container', {
enterTo: 'default-element',

@@ -338,3 +337,3 @@ defaultElement: [root.querySelector('#lastFocused'), '.spottable-default']

var expected = 'lastFocused';
var actual = (0, _container14.getContainerFocusTarget)('container').id;
var actual = getContainerFocusTarget('container').id;

@@ -344,4 +343,4 @@ expect(actual).to.equal(expected);

it('should return the first spottable element when enterTo is "default-element" but defaultElement is not configured', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
(0, _container14.configureContainer)('container', {
it('should return the first spottable element when enterTo is "default-element" but defaultElement is not configured', testScenario(scenarios.containerWithDefaultAndLastFocused, function () {
configureContainer('container', {
enterTo: 'default-element'

@@ -351,3 +350,3 @@ });

var expected = 'firstSpottable';
var actual = (0, _container14.getContainerFocusTarget)('container').id;
var actual = getContainerFocusTarget('container').id;

@@ -357,4 +356,4 @@ expect(actual).to.equal(expected);

it('should return the first spottable element when enterTo is "default-element" but defaultElement is not found', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
(0, _container14.configureContainer)('container', {
it('should return the first spottable element when enterTo is "default-element" but defaultElement is not found', testScenario(scenarios.containerWithDefaultAndLastFocused, function () {
configureContainer('container', {
enterTo: 'default-element',

@@ -365,3 +364,3 @@ defaultElement: '[data-default-spottable]'

var expected = 'firstSpottable';
var actual = (0, _container14.getContainerFocusTarget)('container').id;
var actual = getContainerFocusTarget('container').id;

@@ -371,11 +370,11 @@ expect(actual).to.equal(expected);

it('should return the default element when enterTo is "default-element" and defaultElement is within a subcontainer', (0, _utils.testScenario)(scenarios.complexTree, function () {
(0, _container14.configureContainer)('first-container', {
it('should return the default element when enterTo is "default-element" and defaultElement is within a subcontainer', testScenario(scenarios.complexTree, function () {
configureContainer('first-container', {
enterTo: 'default-element',
defaultElement: '[' + _container14.containerAttribute + '=\'second-container\'] > .spottable'
defaultElement: '[' + containerAttribute + '=\'second-container\'] > .spottable'
});
(0, _container14.configureContainer)('second-container');
configureContainer('second-container');
var expected = 'second-container';
var actual = (0, _container14.getContainerFocusTarget)('first-container').parentNode.dataset.containerId;
var actual = getContainerFocusTarget('first-container').parentNode.dataset.containerId;

@@ -385,11 +384,11 @@ expect(actual).to.equal(expected);

it('should return the first spottable element when enterTo is "default-element" and defaultElement is within a disabled subcontainer', (0, _utils.testScenario)(scenarios.complexTree, function () {
(0, _container14.configureContainer)('second-container', {
it('should return the first spottable element when enterTo is "default-element" and defaultElement is within a disabled subcontainer', testScenario(scenarios.complexTree, function () {
configureContainer('second-container', {
enterTo: 'default-element',
defaultElement: '[' + _container14.containerAttribute + '=\'third-container\'] > .spottable'
defaultElement: '[' + containerAttribute + '=\'third-container\'] > .spottable'
});
(0, _container14.configureContainer)('third-container');
configureContainer('third-container');
var expected = 'secondContainerFirstSpottable';
var actual = (0, _container14.getContainerFocusTarget)('second-container').id;
var actual = getContainerFocusTarget('second-container').id;

@@ -399,7 +398,7 @@ expect(actual).to.equal(expected);

it('should return the first spottable element when enterTo is not configured', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
(0, _container14.configureContainer)('container');
it('should return the first spottable element when enterTo is not configured', testScenario(scenarios.containerWithDefaultAndLastFocused, function () {
configureContainer('container');
var expected = 'firstSpottable';
var actual = (0, _container14.getContainerFocusTarget)('container').id;
var actual = getContainerFocusTarget('container').id;

@@ -409,4 +408,4 @@ expect(actual).to.equal(expected);

it('should return the default element when enterTo is not configured and defaultElement is configured', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
(0, _container14.configureContainer)('container', {
it('should return the default element when enterTo is not configured and defaultElement is configured', testScenario(scenarios.containerWithDefaultAndLastFocused, function () {
configureContainer('container', {
defaultElement: '.spottable-default'

@@ -416,3 +415,3 @@ });

var expected = 'spottableDefault';
var actual = (0, _container14.getContainerFocusTarget)('container').id;
var actual = getContainerFocusTarget('container').id;

@@ -422,8 +421,8 @@ expect(actual).to.equal(expected);

it('should cascade search into child containers with', (0, _utils.testScenario)(scenarios.nestedContainersWithDefaultAndLastFocused, function (root) {
(0, _container14.configureContainer)('container', {
it('should cascade search into child containers with', testScenario(scenarios.nestedContainersWithDefaultAndLastFocused, function (root) {
configureContainer('container', {
defaultElement: '.spottable-default'
});
(0, _container14.configureContainer)('child', {
configureContainer('child', {
enterTo: 'last-focused',

@@ -433,6 +432,6 @@ defaultElement: '.spottable-default'

(0, _container14.setContainerLastFocusedElement)(root.querySelector('#lastChildFocused'), [_container14.rootContainerId, 'container', 'child']);
setContainerLastFocusedElement(root.querySelector('#lastChildFocused'), [rootContainerId, 'container', 'child']);
var expected = 'lastChildFocused';
var actual = (0, _container14.getContainerFocusTarget)('container').id;
var actual = getContainerFocusTarget('container').id;

@@ -442,4 +441,4 @@ expect(actual).to.equal(expected);

it('should cascade search into child containers when multiple containers have enterTo configured', (0, _utils.testScenario)(scenarios.nestedContainersWithDefaultAndLastFocused, function (root) {
(0, _container14.configureContainer)('container', {
it('should cascade search into child containers when multiple containers have enterTo configured', testScenario(scenarios.nestedContainersWithDefaultAndLastFocused, function (root) {
configureContainer('container', {
enterTo: 'last-focused',

@@ -449,3 +448,3 @@ defaultElement: '.spottable-default'

(0, _container14.configureContainer)('child', {
configureContainer('child', {
enterTo: 'last-focused',

@@ -455,9 +454,19 @@ defaultElement: '.spottable-default'

(0, _container14.setContainerLastFocusedElement)(root.querySelector('#lastChildFocused'), [_container14.rootContainerId, 'container', 'child']);
setContainerLastFocusedElement(root.querySelector('#lastChildFocused'), [rootContainerId, 'container', 'child']);
var expected = 'lastChildFocused';
var actual = (0, _container14.getContainerFocusTarget)('container').id;
var actual = getContainerFocusTarget('container').id;
expect(actual).to.equal(expected);
}));
it('should skip empty subcontainers', testScenario(scenarios.emptySubcontainer, function () {
configureContainer('container');
configureContainer('subcontainer');
var expected = 'afterSubcontainer';
var actual = getContainerFocusTarget('container').id;
expect(actual).to.equal(expected);
}));
});

@@ -471,3 +480,3 @@

var expected = false;
var actual = (0, _container14.isNavigable)(null, _container14.rootContainerId);
var actual = isNavigable(null, rootContainerId);

@@ -477,5 +486,5 @@ expect(actual).to.equal(expected);

it('should return true for any node when not verifying selector and without a navigableFilter', (0, _utils.testScenario)(scenarios.nonSpottableSiblings, function (root) {
it('should return true for any node when not verifying selector and without a navigableFilter', testScenario(scenarios.nonSpottableSiblings, function (root) {
var expected = true;
var actual = (0, _container14.isNavigable)(root.querySelector('.other'), _container14.rootContainerId);
var actual = isNavigable(root.querySelector('.other'), rootContainerId);

@@ -485,5 +494,5 @@ expect(actual).to.equal(expected);

it('should return true for spottable children when verifying selector', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
it('should return true for spottable children when verifying selector', testScenario(scenarios.onlySpottables, function (root) {
var expected = true;
var actual = (0, _container14.isNavigable)(root.querySelector('.spottable'), _container14.rootContainerId, true);
var actual = isNavigable(root.querySelector('.spottable'), rootContainerId, true);

@@ -493,5 +502,5 @@ expect(actual).to.equal(expected);

it('should return true for spottable children when verifying selector', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
it('should return true for spottable children when verifying selector', testScenario(scenarios.onlySpottables, function (root) {
var expected = true;
var actual = (0, _container14.isNavigable)(root.querySelector('.spottable'), _container14.rootContainerId, true);
var actual = isNavigable(root.querySelector('.spottable'), rootContainerId, true);

@@ -501,5 +510,5 @@ expect(actual).to.equal(expected);

it('should return true for containers', (0, _utils.testScenario)(scenarios.onlyContainers, function (root) {
it('should return true for containers', testScenario(scenarios.onlyContainers, function (root) {
var expected = true;
var actual = (0, _container14.isNavigable)(root.querySelector('[' + _container14.containerAttribute + ']'), _container14.rootContainerId, true);
var actual = isNavigable(root.querySelector('[' + containerAttribute + ']'), rootContainerId, true);

@@ -509,7 +518,7 @@ expect(actual).to.equal(expected);

it('should filter the node with navigableFilter', (0, _utils.testScenario)(scenarios.spottableAndContainers, function (root) {
(0, _container14.configureContainer)(_container14.rootContainerId, {
it('should filter the node with navigableFilter', testScenario(scenarios.spottableAndContainers, function (root) {
configureContainer(rootContainerId, {
// test filter which makes containers non-navigable
navigableFilter: function navigableFilter(n) {
return !(0, _container14.isContainer)(n);
return !isContainer(n);
}

@@ -519,3 +528,3 @@ });

var expected = false;
var actual = (0, _container14.isNavigable)(root.querySelector('[' + _container14.containerAttribute + ']'), _container14.rootContainerId, true);
var actual = isNavigable(root.querySelector('[' + containerAttribute + ']'), rootContainerId, true);

@@ -530,9 +539,9 @@ expect(actual).to.equal(expected);

it('should update lastFocusedElement for a single container', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
it('should update lastFocusedElement for a single container', testScenario(scenarios.onlySpottables, function (root) {
var item = root.querySelectorAll('.spottable').item(3);
(0, _container14.setContainerLastFocusedElement)(item, (0, _container14.getContainersForNode)(item));
setContainerLastFocusedElement(item, getContainersForNode(item));
var expected = item;
var actual = (0, _container14.getContainerConfig)(_container14.rootContainerId).lastFocusedElement;
var actual = getContainerConfig(rootContainerId).lastFocusedElement;

@@ -542,12 +551,12 @@ expect(actual).to.equal(expected);

it('should update lastFocusedElement to the node\'s container id when element is within a container with enterTo configured', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
var item = root.querySelectorAll('[' + _container14.containerAttribute + '=\'first-container\'] .spottable').item(0);
(0, _container14.configureContainer)('first-container', {
it('should update lastFocusedElement to the node\'s container id when element is within a container with enterTo configured', testScenario(scenarios.complexTree, function (root) {
var item = root.querySelectorAll('[' + containerAttribute + '=\'first-container\'] .spottable').item(0);
configureContainer('first-container', {
enterTo: 'last-focused'
});
(0, _container14.setContainerLastFocusedElement)(item, (0, _container14.getContainersForNode)(item));
setContainerLastFocusedElement(item, getContainersForNode(item));
var expected = 'first-container';
var actual = (0, _container14.getContainerConfig)(_container14.rootContainerId).lastFocusedElement;
var actual = getContainerConfig(rootContainerId).lastFocusedElement;

@@ -557,9 +566,9 @@ expect(actual).to.equal(expected);

it('should ignore sub-containers that does not have enterTo configured', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
var item = root.querySelectorAll('[' + _container14.containerAttribute + '=\'second-container\'] .spottable').item(0);
it('should ignore sub-containers that does not have enterTo configured', testScenario(scenarios.complexTree, function (root) {
var item = root.querySelectorAll('[' + containerAttribute + '=\'second-container\'] .spottable').item(0);
(0, _container14.setContainerLastFocusedElement)(item, (0, _container14.getContainersForNode)(item));
setContainerLastFocusedElement(item, getContainersForNode(item));
var expected = item;
var actual = (0, _container14.getContainerConfig)(_container14.rootContainerId).lastFocusedElement;
var actual = getContainerConfig(rootContainerId).lastFocusedElement;

@@ -569,12 +578,12 @@ expect(actual).to.equal(expected);

it('should update lastFocusedElement to the first sub-container that has enterTo configured', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
var item = root.querySelectorAll('[' + _container14.containerAttribute + '=\'second-container\'] .spottable').item(0);
(0, _container14.configureContainer)('second-container', {
it('should update lastFocusedElement to the first sub-container that has enterTo configured', testScenario(scenarios.complexTree, function (root) {
var item = root.querySelectorAll('[' + containerAttribute + '=\'second-container\'] .spottable').item(0);
configureContainer('second-container', {
enterTo: 'last-focused'
});
(0, _container14.setContainerLastFocusedElement)(item, (0, _container14.getContainersForNode)(item));
setContainerLastFocusedElement(item, getContainersForNode(item));
var expected = 'second-container';
var actual = (0, _container14.getContainerConfig)(_container14.rootContainerId).lastFocusedElement;
var actual = getContainerConfig(rootContainerId).lastFocusedElement;

@@ -589,11 +598,11 @@ expect(actual).to.equal(expected);

it('should return element when last focused is not within a subcontainer with enterTo', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
it('should return element when last focused is not within a subcontainer with enterTo', testScenario(scenarios.onlySpottables, function (root) {
var index = 3;
var item = root.querySelectorAll('.spottable').item(index);
(0, _container14.setContainerLastFocusedElement)(item, (0, _container14.getContainersForNode)(item));
setContainerLastFocusedElement(item, getContainersForNode(item));
(0, _container14.unmountContainer)(_container14.rootContainerId);
unmountContainer(rootContainerId);
var expected = true;
var actual = (0, _container14.getContainerConfig)(_container14.rootContainerId).lastFocusedKey.element;
var actual = getContainerConfig(rootContainerId).lastFocusedKey.element;

@@ -603,13 +612,13 @@ expect(actual).to.equal(expected);

it('should return container when last focused is within a subcontainer with enterTo', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
var item = root.querySelectorAll('[' + _container14.containerAttribute + '="first-container"] .spottable').item(1);
(0, _container14.configureContainer)('first-container', {
it('should return container when last focused is within a subcontainer with enterTo', testScenario(scenarios.complexTree, function (root) {
var item = root.querySelectorAll('[' + containerAttribute + '="first-container"] .spottable').item(1);
configureContainer('first-container', {
enterTo: 'last-focused'
});
(0, _container14.setContainerLastFocusedElement)(item, (0, _container14.getContainersForNode)(item));
setContainerLastFocusedElement(item, getContainersForNode(item));
(0, _container14.unmountContainer)(_container14.rootContainerId);
unmountContainer(rootContainerId);
var expected = true;
var actual = (0, _container14.getContainerConfig)(_container14.rootContainerId).lastFocusedKey.container;
var actual = getContainerConfig(rootContainerId).lastFocusedKey.container;

@@ -619,11 +628,11 @@ expect(actual).to.equal(expected);

it('should save the index of the node when lastFocusedPersist is undefined', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
it('should save the index of the node when lastFocusedPersist is undefined', testScenario(scenarios.onlySpottables, function (root) {
var index = 3;
var item = root.querySelectorAll('.spottable').item(index);
(0, _container14.setContainerLastFocusedElement)(item, (0, _container14.getContainersForNode)(item));
setContainerLastFocusedElement(item, getContainersForNode(item));
(0, _container14.unmountContainer)(_container14.rootContainerId);
unmountContainer(rootContainerId);
var expected = index;
var actual = (0, _container14.getContainerConfig)(_container14.rootContainerId).lastFocusedKey.key;
var actual = getContainerConfig(rootContainerId).lastFocusedKey.key;

@@ -633,6 +642,6 @@ expect(actual).to.equal(expected);

it('should save a custom key for container-configured lastFocusedPersist', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
it('should save a custom key for container-configured lastFocusedPersist', testScenario(scenarios.onlySpottables, function (root) {
var index = 3;
var item = root.querySelectorAll('.spottable').item(3);
(0, _container14.configureContainer)(_container14.rootContainerId, {
configureContainer(rootContainerId, {
lastFocusedPersist: function lastFocusedPersist(n, all) {

@@ -645,8 +654,8 @@ return {

});
(0, _container14.setContainerLastFocusedElement)(item, (0, _container14.getContainersForNode)(item));
setContainerLastFocusedElement(item, getContainersForNode(item));
(0, _container14.unmountContainer)(_container14.rootContainerId);
unmountContainer(rootContainerId);
var expected = 'item-' + index;
var actual = (0, _container14.getContainerConfig)(_container14.rootContainerId).lastFocusedKey.key;
var actual = getContainerConfig(rootContainerId).lastFocusedKey.key;

@@ -656,13 +665,13 @@ expect(actual).to.equal(expected);

it('should save the container id as the key when a container with enterTo configured had the last focused item', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
var item = root.querySelectorAll('[' + _container14.containerAttribute + '="first-container"] .spottable').item(1);
(0, _container14.configureContainer)('first-container', {
it('should save the container id as the key when a container with enterTo configured had the last focused item', testScenario(scenarios.complexTree, function (root) {
var item = root.querySelectorAll('[' + containerAttribute + '="first-container"] .spottable').item(1);
configureContainer('first-container', {
enterTo: 'last-focused'
});
(0, _container14.setContainerLastFocusedElement)(item, (0, _container14.getContainersForNode)(item));
setContainerLastFocusedElement(item, getContainersForNode(item));
(0, _container14.unmountContainer)(_container14.rootContainerId);
unmountContainer(rootContainerId);
var expected = 'first-container';
var actual = (0, _container14.getContainerConfig)(_container14.rootContainerId).lastFocusedKey.key;
var actual = getContainerConfig(rootContainerId).lastFocusedKey.key;

@@ -672,10 +681,10 @@ expect(actual).to.equal(expected);

it('should save the index as the key when last focused item is only within containers without enterTo configured', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
var item = root.querySelectorAll('[' + _container14.containerAttribute + '="second-container"] .spottable').item(1);
(0, _container14.setContainerLastFocusedElement)(item, (0, _container14.getContainersForNode)(item));
it('should save the index as the key when last focused item is only within containers without enterTo configured', testScenario(scenarios.complexTree, function (root) {
var item = root.querySelectorAll('[' + containerAttribute + '="second-container"] .spottable').item(1);
setContainerLastFocusedElement(item, getContainersForNode(item));
(0, _container14.unmountContainer)(_container14.rootContainerId);
unmountContainer(rootContainerId);
var expected = 4;
var actual = (0, _container14.getContainerConfig)(_container14.rootContainerId).lastFocusedKey.key;
var actual = getContainerConfig(rootContainerId).lastFocusedKey.key;

@@ -690,4 +699,4 @@ expect(actual).to.equal(expected);

it('should be nearest restrict="self-only" container to current if target is not within it', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
(0, _container14.configureContainer)('first-container', {
it('should be nearest restrict="self-only" container to current if target is not within it', testScenario(scenarios.complexTree, function (root) {
configureContainer('first-container', {
restrict: 'self-only'

@@ -698,6 +707,6 @@ });

(0, _container14.setLastContainerFromTarget)(current, target);
setLastContainerFromTarget(current, target);
var expected = 'first-container';
var actual = (0, _container14.getLastContainer)();
var actual = getLastContainer();

@@ -707,7 +716,7 @@ expect(actual).to.equal(expected);

it('should be use nearest container to target if within current container', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
(0, _container14.configureContainer)('first-container', {
it('should be use nearest container to target if within current container', testScenario(scenarios.complexTree, function (root) {
configureContainer('first-container', {
restrict: 'none'
});
(0, _container14.configureContainer)('second-container', {
configureContainer('second-container', {
restrict: 'none'

@@ -718,6 +727,6 @@ });

(0, _container14.setLastContainerFromTarget)(current, target);
setLastContainerFromTarget(current, target);
var expected = 'second-container';
var actual = (0, _container14.getLastContainer)();
var actual = getLastContainer();

@@ -727,7 +736,7 @@ expect(actual).to.equal(expected);

it('should target container if it is restrict="self-only" and contains current container', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
(0, _container14.configureContainer)('first-container', {
it('should target container if it is restrict="self-only" and contains current container', testScenario(scenarios.complexTree, function (root) {
configureContainer('first-container', {
restrict: 'self-only'
});
(0, _container14.configureContainer)('second-container', {
configureContainer('second-container', {
restrict: 'none'

@@ -738,6 +747,6 @@ });

(0, _container14.setLastContainerFromTarget)(current, target);
setLastContainerFromTarget(current, target);
var expected = 'first-container';
var actual = (0, _container14.getLastContainer)();
var actual = getLastContainer();

@@ -744,0 +753,0 @@ expect(actual).to.equal(expected);

@@ -1,11 +0,5 @@

'use strict';
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var _navigate = require('../navigate');
import navigate from '../navigate';
var _navigate2 = _interopRequireDefault(_navigate);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
// loose copy from utils/getRect to fabricate a rect for navigation

@@ -39,3 +33,3 @@ function getRect(top, left, height, width, elem) {

var expected = 'above';
var actual = (0, _navigate2.default)(targetRect, 'up', rects, {});
var actual = navigate(targetRect, 'up', rects, {});

@@ -52,3 +46,3 @@ expect(actual).to.equal(expected);

var expected = 'left';
var actual = (0, _navigate2.default)(targetRect, 'left', rects, {});
var actual = navigate(targetRect, 'left', rects, {});

@@ -65,3 +59,3 @@ expect(actual).to.equal(expected);

var expected = 'below';
var actual = (0, _navigate2.default)(targetRect, 'down', rects, {});
var actual = navigate(targetRect, 'down', rects, {});

@@ -78,3 +72,3 @@ expect(actual).to.equal(expected);

var expected = 'right';
var actual = (0, _navigate2.default)(targetRect, 'right', rects, {});
var actual = navigate(targetRect, 'right', rects, {});

@@ -91,10 +85,10 @@ expect(actual).to.equal(expected);

expect((0, _navigate2.default)(targetRect, 'up', rects, {})).to.equal('under');
expect(navigate(targetRect, 'up', rects, {})).to.equal('under');
expect((0, _navigate2.default)(targetRect, 'down', rects, {})).to.equal('below');
expect(navigate(targetRect, 'down', rects, {})).to.equal('below');
expect((0, _navigate2.default)(targetRect, 'left', rects, {})).to.equal('left');
expect(navigate(targetRect, 'left', rects, {})).to.equal('left');
expect((0, _navigate2.default)(targetRect, 'right', rects, {})).to.equal('right');
expect(navigate(targetRect, 'right', rects, {})).to.equal('right');
});
});

@@ -1,10 +0,8 @@

'use strict';
import { addAll, removeAll } from '@enact/core/keymap';
var _keymap = require('@enact/core/keymap');
import { getLastPointerPosition, getPointerMode, notifyKeyDown, notifyPointerMove, setPointerMode, updatePointerPosition } from '../pointer';
var _pointer = require('../pointer');
var reset = function reset() {
(0, _pointer.updatePointerPosition)(null, null);
(0, _pointer.setPointerMode)(true);
updatePointerPosition(null, null);
setPointerMode(true);
};

@@ -18,3 +16,3 @@

var expected = ['x', 'y'];
var actual = Object.keys((0, _pointer.getLastPointerPosition)());
var actual = Object.keys(getLastPointerPosition());

@@ -36,6 +34,6 @@ expect(actual).to.deep.equal(expected);

before(function () {
return (0, _keymap.addAll)(keyMap);
return addAll(keyMap);
});
after(function () {
return (0, _keymap.removeAll)(keyMap);
return removeAll(keyMap);
});

@@ -45,3 +43,3 @@

// establish a consistent pointer mode state for each test
(0, _pointer.setPointerMode)(false);
setPointerMode(false);
});

@@ -51,3 +49,3 @@

var expected = true;
var actual = (0, _pointer.notifyKeyDown)(keyMap.pointerHide);
var actual = notifyKeyDown(keyMap.pointerHide);

@@ -59,3 +57,3 @@ expect(actual).to.equal(expected);

var expected = true;
var actual = (0, _pointer.notifyKeyDown)(keyMap.pointerShow);
var actual = notifyKeyDown(keyMap.pointerShow);

@@ -66,6 +64,6 @@ expect(actual).to.equal(expected);

it('should enable pointer mode for pointer show key events', function () {
(0, _pointer.notifyKeyDown)(keyMap.pointerShow);
notifyKeyDown(keyMap.pointerShow);
var expected = true;
var actual = (0, _pointer.getPointerMode)();
var actual = getPointerMode();

@@ -76,6 +74,6 @@ expect(actual).to.equal(expected);

it('should disable pointer mode for pointer show key events', function (done) {
(0, _pointer.setPointerMode)(true);
(0, _pointer.notifyKeyDown)(keyMap.pointerHide, function () {
setPointerMode(true);
notifyKeyDown(keyMap.pointerHide, function () {
var expected = false;
var actual = (0, _pointer.getPointerMode)();
var actual = getPointerMode();

@@ -89,7 +87,7 @@ expect(actual).to.equal(expected);

it('should disable pointer mode for non-pointer key events', function () {
(0, _pointer.setPointerMode)(true);
(0, _pointer.notifyKeyDown)(12);
setPointerMode(true);
notifyKeyDown(12);
var expected = false;
var actual = (0, _pointer.getPointerMode)();
var actual = getPointerMode();

@@ -104,6 +102,6 @@ expect(actual).to.equal(expected);

(0, _pointer.notifyPointerMove)(null, null, x, null);
notifyPointerMove(null, null, x, null);
var expected = 20;
var actual = (0, _pointer.getLastPointerPosition)().x;
var actual = getLastPointerPosition().x;

@@ -116,6 +114,6 @@ expect(actual).to.equal(expected);

(0, _pointer.notifyPointerMove)(null, null, null, y);
notifyPointerMove(null, null, null, y);
var expected = 20;
var actual = (0, _pointer.getLastPointerPosition)().y;
var actual = getLastPointerPosition().y;

@@ -126,7 +124,7 @@ expect(actual).to.equal(expected);

it('should enable pointer mode if the pointer positionchanges', function () {
(0, _pointer.setPointerMode)(false);
(0, _pointer.notifyPointerMove)(null, null, 5, 5);
setPointerMode(false);
notifyPointerMove(null, null, 5, 5);
var expected = true;
var actual = (0, _pointer.getPointerMode)();
var actual = getPointerMode();

@@ -137,6 +135,6 @@ expect(actual).to.equal(expected);

it('should return false if the pointer has not moved', function () {
(0, _pointer.notifyPointerMove)(null, null, 5, 5);
notifyPointerMove(null, null, 5, 5);
var expected = false;
var actual = (0, _pointer.notifyPointerMove)(null, null, 5, 5);
var actual = notifyPointerMove(null, null, 5, 5);

@@ -148,6 +146,6 @@ expect(actual).to.equal(expected);

// change into pointer mode indicates a potential for change of focus
(0, _pointer.setPointerMode)(false);
setPointerMode(false);
var expected = true;
var actual = (0, _pointer.notifyPointerMove)(null, null, 5, 5);
var actual = notifyPointerMove(null, null, 5, 5);

@@ -159,3 +157,3 @@ expect(actual).to.equal(expected);

var expected = true;
var actual = (0, _pointer.notifyPointerMove)(null, null, 5, 5);
var actual = notifyPointerMove(null, null, 5, 5);

@@ -170,6 +168,6 @@ expect(actual).to.equal(expected);

(0, _pointer.notifyPointerMove)(null, current, 5, 5);
notifyPointerMove(null, current, 5, 5);
var expected = false;
var actual = (0, _pointer.notifyPointerMove)(current, target, 10, 10);
var actual = notifyPointerMove(current, target, 10, 10);

@@ -183,6 +181,6 @@ expect(actual).to.equal(expected);

(0, _pointer.notifyPointerMove)(null, current, 5, 5);
notifyPointerMove(null, current, 5, 5);
var expected = true;
var actual = (0, _pointer.notifyPointerMove)(current, target, 10, 10);
var actual = notifyPointerMove(current, target, 10, 10);

@@ -189,0 +187,0 @@ expect(actual).to.equal(expected);

@@ -1,15 +0,13 @@

'use strict';
var _container2, _container3, _container4, _container5, _container6, _container7, _container8, _container9, _container10, _container11;
var _container12 = require('../container');
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _target = require('../target');
import { configureContainer, configureDefaults, containerAttribute, getAllContainerIds, removeContainer, rootContainerId, setDefaultContainer } from '../container';
var _utils = require('./utils');
import { getNavigableTarget, getTargetByContainer, getTargetByDirectionFromElement, getTargetByDirectionFromPosition, getTargetBySelector } from '../target';
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { container, join, node, someSpottables, spottable, testScenario } from './utils';
var nonSpottable = function nonSpottable() {
return (0, _utils.node)({ className: 'other' });
return node({ className: 'other' });
};

@@ -22,3 +20,3 @@

var positionedSpottable = function positionedSpottable(id, top, left) {
return (0, _utils.spottable)({
return spottable({
id: id,

@@ -32,12 +30,12 @@ style: position(top, left)

return (0, _utils.container)((_container = {}, _defineProperty(_container, _container12.containerAttribute, 'grid'), _defineProperty(_container, 'style', 'position: relative; height: 30px; width: 30px;'), _defineProperty(_container, 'children', (0, _utils.join)(positionedSpottable('top-left', 0, 0), positionedSpottable('top-center', 0, 10), positionedSpottable('top-right', 0, 20), positionedSpottable('middle-left', 10, 0), positionedSpottable('middle-center', 10, 10), positionedSpottable('middle-right', 10, 20), positionedSpottable('bottom-left', 20, 0), positionedSpottable('bottom-center', 20, 10), positionedSpottable('bottom-right', 20, 20))), _container));
return container((_container = {}, _defineProperty(_container, containerAttribute, 'grid'), _defineProperty(_container, 'style', 'position: relative; height: 30px; width: 30px;'), _defineProperty(_container, 'children', join(positionedSpottable('top-left', 0, 0), positionedSpottable('top-center', 0, 10), positionedSpottable('top-right', 0, 20), positionedSpottable('middle-left', 10, 0), positionedSpottable('middle-center', 10, 10), positionedSpottable('middle-right', 10, 20), positionedSpottable('bottom-left', 20, 0), positionedSpottable('bottom-center', 20, 10), positionedSpottable('bottom-right', 20, 20))), _container));
};
var scenarios = {
complexTree: (0, _utils.join)((0, _utils.spottable)(nonSpottable()), (0, _utils.container)((_container4 = {}, _defineProperty(_container4, _container12.containerAttribute, 'first-container'), _defineProperty(_container4, 'children', (0, _utils.join)((0, _utils.someSpottables)(2), (0, _utils.container)((_container3 = {}, _defineProperty(_container3, _container12.containerAttribute, 'second-container'), _defineProperty(_container3, 'children', (0, _utils.join)((0, _utils.someSpottables)(3), (0, _utils.container)((_container2 = {}, _defineProperty(_container2, _container12.containerAttribute, 'third-container'), _defineProperty(_container2, 'data-container-disabled', true), _defineProperty(_container2, 'children', (0, _utils.join)((0, _utils.someSpottables)(4), (0, _utils.node)({ id: 'child-of-third' }))), _container2)))), _container3)))), _container4))),
nonSpottableInContainer: (0, _utils.join)((0, _utils.spottable)({ id: 'in-root' }), (0, _utils.container)((_container5 = {}, _defineProperty(_container5, _container12.containerAttribute, 'first'), _defineProperty(_container5, 'children', (0, _utils.join)(nonSpottable(), (0, _utils.spottable)({ id: 'in-first' }))), _container5)), (0, _utils.container)((_container6 = {}, _defineProperty(_container6, _container12.containerAttribute, 'second'), _defineProperty(_container6, 'children', (0, _utils.join)(nonSpottable())), _container6))),
grid: (0, _utils.join)((0, _utils.spottable)({ id: 'before-grid', style: 'height: 10px' }), grid(), (0, _utils.spottable)({ id: 'after-grid', style: 'height: 10px' })),
overlap: (0, _utils.node)({
complexTree: join(spottable(nonSpottable()), container((_container4 = {}, _defineProperty(_container4, containerAttribute, 'first-container'), _defineProperty(_container4, 'children', join(someSpottables(2), container((_container3 = {}, _defineProperty(_container3, containerAttribute, 'second-container'), _defineProperty(_container3, 'children', join(someSpottables(3), container((_container2 = {}, _defineProperty(_container2, containerAttribute, 'third-container'), _defineProperty(_container2, 'data-container-disabled', true), _defineProperty(_container2, 'children', join(someSpottables(4), node({ id: 'child-of-third' }))), _container2)))), _container3)))), _container4))),
nonSpottableInContainer: join(spottable({ id: 'in-root' }), container((_container5 = {}, _defineProperty(_container5, containerAttribute, 'first'), _defineProperty(_container5, 'children', join(nonSpottable(), spottable({ id: 'in-first' }))), _container5)), container((_container6 = {}, _defineProperty(_container6, containerAttribute, 'second'), _defineProperty(_container6, 'children', join(nonSpottable())), _container6))),
grid: join(spottable({ id: 'before-grid', style: 'height: 10px' }), grid(), spottable({ id: 'after-grid', style: 'height: 10px' })),
overlap: node({
style: 'position: relative',
children: (0, _utils.join)(grid(), (0, _utils.spottable)({
children: join(grid(), spottable({
id: 'over-middle-center',

@@ -47,29 +45,29 @@ style: 'position: absolute; top: 12px; left: 15px; height: 1px; width: 1px;'

}),
overflow: (0, _utils.join)((0, _utils.spottable)({ id: 'outside-overflow' }), (0, _utils.node)({
overflow: join(spottable({ id: 'outside-overflow' }), node({
// allocate some empty space so that overflow items would be otherwise navigable
style: 'height: 100px'
}), (0, _utils.container)((_container7 = {}, _defineProperty(_container7, _container12.containerAttribute, 'overflow-container'), _defineProperty(_container7, 'style', 'position: relative; height: 30px; width: 30px;'), _defineProperty(_container7, 'children', (0, _utils.join)((0, _utils.spottable)({
}), container((_container7 = {}, _defineProperty(_container7, containerAttribute, 'overflow-container'), _defineProperty(_container7, 'style', 'position: relative; height: 30px; width: 30px;'), _defineProperty(_container7, 'children', join(spottable({
id: 'overflow-above',
style: 'position: absolute; top: -10px; left: 0px; height: 10px; width: 10px;'
}), (0, _utils.spottable)({
}), spottable({
id: 'overflow-below',
style: 'position: absolute; top: 30px; left: 0px; height: 10px; width: 10px;'
}), (0, _utils.spottable)({
}), spottable({
id: 'overflow-within',
style: 'position: absolute; top: 0px; left: 0px; height: 10px; width: 10px;'
}))), _container7))),
overflowLargeSubContainer: (0, _utils.join)((0, _utils.spottable)({ id: 'outside-overflow' }), (0, _utils.node)({
overflowLargeSubContainer: join(spottable({ id: 'outside-overflow' }), node({
// allocate some empty space so that overflow items would be otherwise navigable
style: 'height: 100px'
}), (0, _utils.container)((_container9 = {}, _defineProperty(_container9, _container12.containerAttribute, 'overflow-container'), _defineProperty(_container9, 'style', 'position: relative; height: 30px; width: 30px;'), _defineProperty(_container9, 'children', (0, _utils.join)((0, _utils.container)((_container8 = {}, _defineProperty(_container8, _container12.containerAttribute, 'inside'), _defineProperty(_container8, 'style', 'position: absolute; top: -10px; left: 0px; height: 50px; width: 10px;'), _defineProperty(_container8, 'children', (0, _utils.join)((0, _utils.node)({
}), container((_container9 = {}, _defineProperty(_container9, containerAttribute, 'overflow-container'), _defineProperty(_container9, 'style', 'position: relative; height: 30px; width: 30px;'), _defineProperty(_container9, 'children', join(container((_container8 = {}, _defineProperty(_container8, containerAttribute, 'inside'), _defineProperty(_container8, 'style', 'position: absolute; top: -10px; left: 0px; height: 50px; width: 10px;'), _defineProperty(_container8, 'children', join(node({
// allocate space to push following spottable into view
style: 'height: 10px'
}), (0, _utils.spottable)({
}), spottable({
id: 'in-large-container'
}))), _container8)), (0, _utils.spottable)({
}))), _container8)), spottable({
id: 'below-large-container',
style: 'position: absolute; top: 40px; left: 0px; height: 10px; width: 10px;'
}))), _container9))),
emptyContainer: (0, _utils.join)(positionedSpottable('above', 0, 10), (0, _utils.container)((_container10 = {}, _defineProperty(_container10, _container12.containerAttribute, 'empty-container'), _defineProperty(_container10, 'style', position(10, 10)), _container10)), positionedSpottable('below', 30, 0)),
emptyContainerOverlap: (0, _utils.join)(positionedSpottable('above', 5, 10), (0, _utils.container)((_container11 = {}, _defineProperty(_container11, _container12.containerAttribute, 'empty-container'), _defineProperty(_container11, 'style', position(10, 10)), _container11)), positionedSpottable('below', 30, 0))
emptyContainer: join(positionedSpottable('above', 0, 10), container((_container10 = {}, _defineProperty(_container10, containerAttribute, 'empty-container'), _defineProperty(_container10, 'style', position(10, 10)), _container10)), positionedSpottable('below', 30, 0)),
emptyContainerOverlap: join(positionedSpottable('above', 5, 10), container((_container11 = {}, _defineProperty(_container11, containerAttribute, 'empty-container'), _defineProperty(_container11, 'style', position(10, 10)), _container11)), positionedSpottable('below', 30, 0))
};

@@ -82,6 +80,6 @@

var setupContainers = function setupContainers() {
(0, _container12.configureDefaults)({
configureDefaults({
selector: '.spottable'
});
(0, _container12.configureContainer)(_container12.rootContainerId);
configureContainer(rootContainerId);
};

@@ -91,4 +89,4 @@

// clean up any containers we create for safe tests
(0, _container12.getAllContainerIds)().forEach(_container12.removeContainer);
(0, _container12.setDefaultContainer)();
getAllContainerIds().forEach(removeContainer);
setDefaultContainer();
};

@@ -101,7 +99,7 @@

describe('#getNavigableTarget', function () {
it('should find spottable parent', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
it('should find spottable parent', testScenario(scenarios.complexTree, function (root) {
var other = root.querySelector('.other');
var expected = other.parentNode;
var actual = (0, _target.getNavigableTarget)(other);
var actual = getNavigableTarget(other);

@@ -111,8 +109,8 @@ expect(actual).to.equal(expected);

it('should skip containers', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function (root) {
(0, _container12.configureContainer)('first');
it('should skip containers', testScenario(scenarios.nonSpottableInContainer, function (root) {
configureContainer('first');
var other = root.querySelector('.other');
var expected = null;
var actual = (0, _target.getNavigableTarget)(other);
var actual = getNavigableTarget(other);

@@ -122,5 +120,5 @@ expect(actual).to.equal(expected);

it('should respect container-specific selector', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function (root) {
it('should respect container-specific selector', testScenario(scenarios.nonSpottableInContainer, function (root) {
// make '.other' a valid spottable element
(0, _container12.configureContainer)('first', {
configureContainer('first', {
selector: '.other'

@@ -131,3 +129,3 @@ });

var expected = other;
var actual = (0, _target.getNavigableTarget)(other);
var actual = getNavigableTarget(other);

@@ -137,8 +135,8 @@ expect(actual).to.equal(expected);

it('should respect disabled containers', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
(0, _container12.configureContainer)('third-container');
var other = root.querySelector('[' + _container12.containerAttribute + '=\'third-container\'] .spottable');
it('should respect disabled containers', testScenario(scenarios.complexTree, function (root) {
configureContainer('third-container');
var other = root.querySelector('[' + containerAttribute + '=\'third-container\'] .spottable');
var expected = null;
var actual = (0, _target.getNavigableTarget)(other);
var actual = getNavigableTarget(other);

@@ -150,7 +148,7 @@ expect(actual).to.equal(expected);

describe('#getTargetByContainer', function () {
it('should find spottable element within provided container', (0, _utils.testScenario)(scenarios.complexTree, function () {
(0, _container12.configureContainer)('first-container');
it('should find spottable element within provided container', testScenario(scenarios.complexTree, function () {
configureContainer('first-container');
var expected = 'spottable';
var actual = safeTarget((0, _target.getTargetByContainer)('first-container'), function (t) {
var actual = safeTarget(getTargetByContainer('first-container'), function (t) {
return t.className;

@@ -162,8 +160,8 @@ });

it('should return null when container does not contain any spottable elements', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () {
(0, _container12.configureContainer)('first');
(0, _container12.configureContainer)('second');
it('should return null when container does not contain any spottable elements', testScenario(scenarios.nonSpottableInContainer, function () {
configureContainer('first');
configureContainer('second');
var expected = null;
var actual = (0, _target.getTargetByContainer)('second');
var actual = getTargetByContainer('second');

@@ -173,8 +171,8 @@ expect(actual).to.equal(expected);

it('should find the first spottable in the root when no container specified', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () {
(0, _container12.configureContainer)('first');
(0, _container12.configureContainer)('second');
it('should find the first spottable in the root when no container specified', testScenario(scenarios.nonSpottableInContainer, function () {
configureContainer('first');
configureContainer('second');
var expected = 'in-root';
var actual = safeTarget((0, _target.getTargetByContainer)(), function (t) {
var actual = safeTarget(getTargetByContainer(), function (t) {
return t.id;

@@ -186,9 +184,9 @@ });

it('should find the first spottable in the default container when set and no container specified', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () {
(0, _container12.configureContainer)('first');
(0, _container12.configureContainer)('second');
(0, _container12.setDefaultContainer)('first');
it('should find the first spottable in the default container when set and no container specified', testScenario(scenarios.nonSpottableInContainer, function () {
configureContainer('first');
configureContainer('second');
setDefaultContainer('first');
var expected = 'spottable';
var actual = safeTarget((0, _target.getTargetByContainer)(), function (t) {
var actual = safeTarget(getTargetByContainer(), function (t) {
return t.className;

@@ -202,7 +200,7 @@ });

describe('#getTargetBySelector', function () {
it('should find spottable element within container when "@" prefix used', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () {
(0, _container12.configureContainer)('first');
it('should find spottable element within container when "@" prefix used', testScenario(scenarios.nonSpottableInContainer, function () {
configureContainer('first');
var expected = 'spottable';
var actual = safeTarget((0, _target.getTargetBySelector)('@first'), function (t) {
var actual = safeTarget(getTargetBySelector('@first'), function (t) {
return t.className;

@@ -214,7 +212,7 @@ });

it('should find spottable element within container when "@" prefix used', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () {
(0, _container12.configureContainer)('first');
it('should find spottable element within container when "@" prefix used', testScenario(scenarios.nonSpottableInContainer, function () {
configureContainer('first');
var expected = 'in-first';
var actual = safeTarget((0, _target.getTargetBySelector)('#in-first'), function (t) {
var actual = safeTarget(getTargetBySelector('#in-first'), function (t) {
return t.id;

@@ -226,4 +224,4 @@ });

it('should return null when the node exists but is not navigable within its container', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () {
(0, _container12.configureContainer)('first', {
it('should return null when the node exists but is not navigable within its container', testScenario(scenarios.nonSpottableInContainer, function () {
configureContainer('first', {
navigableFilter: function navigableFilter() {

@@ -235,3 +233,3 @@ return false;

var expected = null;
var actual = (0, _target.getTargetBySelector)('#in-first');
var actual = getTargetBySelector('#in-first');

@@ -241,7 +239,7 @@ expect(actual).to.equal(expected);

it('should return null when the node exists but does not match the container\'s selector', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () {
(0, _container12.configureContainer)('first');
it('should return null when the node exists but does not match the container\'s selector', testScenario(scenarios.nonSpottableInContainer, function () {
configureContainer('first');
var expected = null;
var actual = (0, _target.getTargetBySelector)('[' + _container12.containerAttribute + '=\'first\'] .other');
var actual = getTargetBySelector('[' + containerAttribute + '=\'first\'] .other');

@@ -251,9 +249,9 @@ expect(actual).to.equal(expected);

it('should return null for an empty selectors', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () {
it('should return null for an empty selectors', testScenario(scenarios.nonSpottableInContainer, function () {
var expected = null;
// eslint-disable-next-line no-undefined
expect((0, _target.getTargetBySelector)(undefined)).to.equal(expected);
expect((0, _target.getTargetBySelector)(null)).to.equal(expected);
expect((0, _target.getTargetBySelector)('')).to.equal(expected);
expect(getTargetBySelector(undefined)).to.equal(expected);
expect(getTargetBySelector(null)).to.equal(expected);
expect(getTargetBySelector('')).to.equal(expected);
}));

@@ -263,19 +261,19 @@ });

describe('#getTargetByDirectionFromElement', function () {
it('should find target within container by direction', (0, _utils.testScenario)(scenarios.grid, function (root) {
(0, _container12.configureContainer)('grid');
it('should find target within container by direction', testScenario(scenarios.grid, function (root) {
configureContainer('grid');
var center = root.querySelector('#middle-center');
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', center), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('up', center), function (t) {
return t.id;
})).to.equal('top-center');
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', center), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('down', center), function (t) {
return t.id;
})).to.equal('bottom-center');
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('left', center), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('left', center), function (t) {
return t.id;
})).to.equal('middle-left');
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('right', center), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('right', center), function (t) {
return t.id;

@@ -285,4 +283,4 @@ })).to.equal('middle-right');

it('should find target within container from floating element', (0, _utils.testScenario)(scenarios.overlap, function (root) {
(0, _container12.configureContainer)('grid', {
it('should find target within container from floating element', testScenario(scenarios.overlap, function (root) {
configureContainer('grid', {
enterTo: 'default-element',

@@ -294,3 +292,3 @@ defaultElement: '#bottom-right'

expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', overlap), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('down', overlap), function (t) {
return t.id;

@@ -300,4 +298,4 @@ })).to.equal('middle-center');

it('should ignore targets outside the bounds of an overflow container', (0, _utils.testScenario)(scenarios.overflow, function (root) {
(0, _container12.configureContainer)('overflow-container', {
it('should ignore targets outside the bounds of an overflow container', testScenario(scenarios.overflow, function (root) {
configureContainer('overflow-container', {
overflow: true

@@ -308,3 +306,3 @@ });

expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('down', element), function (t) {
return t.id;

@@ -314,7 +312,7 @@ })).to.equal('overflow-within');

it('should find target within container larger than overflow container', (0, _utils.testScenario)(scenarios.overflowLargeSubContainer, function (root) {
(0, _container12.configureContainer)('overflow-container', {
it('should find target within container larger than overflow container', testScenario(scenarios.overflowLargeSubContainer, function (root) {
configureContainer('overflow-container', {
overflow: true
});
(0, _container12.configureContainer)('inside', {
configureContainer('inside', {
enterTo: null

@@ -325,3 +323,3 @@ });

expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('down', element), function (t) {
return t.id;

@@ -331,4 +329,4 @@ })).to.equal('in-large-container');

it('should find target out of bounds of overflow container from within container', (0, _utils.testScenario)(scenarios.overflow, function (root) {
(0, _container12.configureContainer)('overflow-container', {
it('should find target out of bounds of overflow container from within container', testScenario(scenarios.overflow, function (root) {
configureContainer('overflow-container', {
overflow: true

@@ -339,7 +337,7 @@ });

expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('down', element), function (t) {
return t.id;
})).to.equal('overflow-below');
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('up', element), function (t) {
return t.id;

@@ -349,13 +347,13 @@ })).to.equal('overflow-above');

it('should stop at restrict="self-only" boundaries', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
(0, _container12.configureContainer)('first-container', {
it('should stop at restrict="self-only" boundaries', testScenario(scenarios.complexTree, function (root) {
configureContainer('first-container', {
restrict: 'none'
});
(0, _container12.configureContainer)('second-container', {
configureContainer('second-container', {
restrict: 'self-only'
});
var element = root.querySelector('[' + _container12.containerAttribute + '="second-container"] .spottable');
var element = root.querySelector('[' + containerAttribute + '="second-container"] .spottable');
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('up', element), function (t) {
return t.id;

@@ -365,4 +363,4 @@ })).to.equal('NOT FOUND');

it('should respect enterTo="default-element" containers', (0, _utils.testScenario)(scenarios.grid, function (root) {
(0, _container12.configureContainer)('grid', {
it('should respect enterTo="default-element" containers', testScenario(scenarios.grid, function (root) {
configureContainer('grid', {
restrict: 'none',

@@ -375,3 +373,3 @@ enterTo: 'default-element',

expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('down', element), function (t) {
return t.id;

@@ -381,4 +379,4 @@ })).to.equal('bottom-right');

it('should respect enterTo="last-focused" containers', (0, _utils.testScenario)(scenarios.grid, function (root) {
(0, _container12.configureContainer)('grid', {
it('should respect enterTo="last-focused" containers', testScenario(scenarios.grid, function (root) {
configureContainer('grid', {
restrict: 'none',

@@ -395,3 +393,3 @@ enterTo: 'last-focused',

expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('down', element), function (t) {
return t.id;

@@ -401,4 +399,4 @@ })).to.equal('bottom-right');

it('should follow the leaveFor config when no target is found within the container in the given direction', (0, _utils.testScenario)(scenarios.grid, function (root) {
(0, _container12.configureContainer)('grid', {
it('should follow the leaveFor config when no target is found within the container in the given direction', testScenario(scenarios.grid, function (root) {
configureContainer('grid', {
restrict: 'none',

@@ -412,3 +410,3 @@ leaveFor: {

expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('up', element), function (t) {
return t.id;

@@ -418,4 +416,4 @@ })).to.equal('after-grid');

it('should not follow the leaveFor config when a target is found within the container in the given direction', (0, _utils.testScenario)(scenarios.grid, function (root) {
(0, _container12.configureContainer)('grid', {
it('should not follow the leaveFor config when a target is found within the container in the given direction', testScenario(scenarios.grid, function (root) {
configureContainer('grid', {
restrict: 'none',

@@ -429,3 +427,3 @@ leaveFor: {

expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('up', element), function (t) {
return t.id;

@@ -435,4 +433,4 @@ })).to.equal('top-center');

it('should not follow the leaveFor config when the selector does not match an element', (0, _utils.testScenario)(scenarios.grid, function (root) {
(0, _container12.configureContainer)('grid', {
it('should not follow the leaveFor config when the selector does not match an element', testScenario(scenarios.grid, function (root) {
configureContainer('grid', {
restrict: 'none',

@@ -446,3 +444,3 @@ leaveFor: {

expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('up', element), function (t) {
return t.id;

@@ -452,7 +450,7 @@ })).to.equal('before-grid');

it('should ignore empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) {
(0, _container12.configureContainer)('empty-container');
it('should ignore empty containers', testScenario(scenarios.emptyContainer, function (root) {
configureContainer('empty-container');
var element = root.querySelector('#above');
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('down', element), function (t) {
return t.id;

@@ -462,7 +460,7 @@ })).to.equal('below');

it('should ignore overlapping empty containers', (0, _utils.testScenario)(scenarios.emptyContainerOverlap, function (root) {
(0, _container12.configureContainer)('empty-container');
it('should ignore overlapping empty containers', testScenario(scenarios.emptyContainerOverlap, function (root) {
configureContainer('empty-container');
var element = root.querySelector('#above');
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
expect(safeTarget(getTargetByDirectionFromElement('down', element), function (t) {
return t.id;

@@ -474,4 +472,4 @@ })).to.equal('below');

describe('#getTargetByDirectionFromPosition', function () {
it('should find target within container', (0, _utils.testScenario)(scenarios.grid, function (root) {
(0, _container12.configureContainer)('grid');
it('should find target within container', testScenario(scenarios.grid, function (root) {
configureContainer('grid');
var rect = root.querySelector('#middle-center').getBoundingClientRect();

@@ -483,15 +481,15 @@ var center = {

expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', center, 'grid'), function (t) {
expect(safeTarget(getTargetByDirectionFromPosition('up', center, 'grid'), function (t) {
return t.id;
})).to.equal('top-center');
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', center, 'grid'), function (t) {
expect(safeTarget(getTargetByDirectionFromPosition('down', center, 'grid'), function (t) {
return t.id;
})).to.equal('bottom-center');
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('left', center, 'grid'), function (t) {
expect(safeTarget(getTargetByDirectionFromPosition('left', center, 'grid'), function (t) {
return t.id;
})).to.equal('middle-left');
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('right', center, 'grid'), function (t) {
expect(safeTarget(getTargetByDirectionFromPosition('right', center, 'grid'), function (t) {
return t.id;

@@ -501,4 +499,4 @@ })).to.equal('middle-right');

it('should not find a target when at bounds of container with restrict="self-only"', (0, _utils.testScenario)(scenarios.grid, function (root) {
(0, _container12.configureContainer)('grid', {
it('should not find a target when at bounds of container with restrict="self-only"', testScenario(scenarios.grid, function (root) {
configureContainer('grid', {
restrict: 'self-only'

@@ -512,3 +510,3 @@ });

expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', topCenterOfGrid, 'grid'), function (t) {
expect(safeTarget(getTargetByDirectionFromPosition('up', topCenterOfGrid, 'grid'), function (t) {
return t.id;

@@ -518,4 +516,4 @@ })).to.equal('NOT FOUND');

it('should not find a target outside of container when restrict is not set', (0, _utils.testScenario)(scenarios.grid, function (root) {
(0, _container12.configureContainer)('grid', {
it('should not find a target outside of container when restrict is not set', testScenario(scenarios.grid, function (root) {
configureContainer('grid', {
restrict: 'none'

@@ -529,3 +527,3 @@ });

expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', topCenterOfGrid, 'grid'), function (t) {
expect(safeTarget(getTargetByDirectionFromPosition('up', topCenterOfGrid, 'grid'), function (t) {
return t.id;

@@ -535,4 +533,4 @@ })).to.equal('before-grid');

it('should cascade into unrestricted subcontainers', (0, _utils.testScenario)(scenarios.grid, function (root) {
(0, _container12.configureContainer)('grid', {
it('should cascade into unrestricted subcontainers', testScenario(scenarios.grid, function (root) {
configureContainer('grid', {
restrict: 'none'

@@ -546,3 +544,3 @@ });

expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', aboveCenterOfGrid, _container12.rootContainerId), function (t) {
expect(safeTarget(getTargetByDirectionFromPosition('down', aboveCenterOfGrid, rootContainerId), function (t) {
return t.id;

@@ -552,4 +550,4 @@ })).to.equal('top-center');

it('should ignore enterTo config of restricted subcontainers', (0, _utils.testScenario)(scenarios.grid, function (root) {
(0, _container12.configureContainer)('grid', {
it('should ignore enterTo config of restricted subcontainers', testScenario(scenarios.grid, function (root) {
configureContainer('grid', {
restrict: 'none',

@@ -565,3 +563,3 @@ enterTo: 'default-element',

expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', aboveCenterOfGrid, _container12.rootContainerId), function (t) {
expect(safeTarget(getTargetByDirectionFromPosition('down', aboveCenterOfGrid, rootContainerId), function (t) {
return t.id;

@@ -571,4 +569,4 @@ })).to.equal('top-center');

it('should find target within container from floating element', (0, _utils.testScenario)(scenarios.overlap, function (root) {
(0, _container12.configureContainer)('grid', {
it('should find target within container from floating element', testScenario(scenarios.overlap, function (root) {
configureContainer('grid', {
enterTo: 'default-element',

@@ -584,3 +582,3 @@ defaultElement: '#bottom-right'

expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', { x: x, y: y }, _container12.rootContainerId), function (t) {
expect(safeTarget(getTargetByDirectionFromPosition('down', { x: x, y: y }, rootContainerId), function (t) {
return t.id;

@@ -590,4 +588,4 @@ })).to.equal('middle-center');

it('should ignore targets outside the bounds of an overflow container', (0, _utils.testScenario)(scenarios.overflow, function (root) {
(0, _container12.configureContainer)('overflow-container', {
it('should ignore targets outside the bounds of an overflow container', testScenario(scenarios.overflow, function (root) {
configureContainer('overflow-container', {
overflow: true

@@ -602,3 +600,3 @@ });

expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', { x: x, y: y }, _container12.rootContainerId), function (t) {
expect(safeTarget(getTargetByDirectionFromPosition('down', { x: x, y: y }, rootContainerId), function (t) {
return t.id;

@@ -608,7 +606,7 @@ })).to.equal('overflow-within');

it('should find target within container larger than overflow container', (0, _utils.testScenario)(scenarios.overflowLargeSubContainer, function (root) {
(0, _container12.configureContainer)('overflow-container', {
it('should find target within container larger than overflow container', testScenario(scenarios.overflowLargeSubContainer, function (root) {
configureContainer('overflow-container', {
overflow: true
});
(0, _container12.configureContainer)('inside', {
configureContainer('inside', {
enterTo: null

@@ -623,3 +621,3 @@ });

expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', { x: x, y: y }, _container12.rootContainerId), function (t) {
expect(safeTarget(getTargetByDirectionFromPosition('down', { x: x, y: y }, rootContainerId), function (t) {
return t.id;

@@ -629,4 +627,4 @@ })).to.equal('in-large-container');

it('should find target out of bounds of overflow container from within container', (0, _utils.testScenario)(scenarios.overflow, function (root) {
(0, _container12.configureContainer)('overflow-container', {
it('should find target out of bounds of overflow container from within container', testScenario(scenarios.overflow, function (root) {
configureContainer('overflow-container', {
overflow: true

@@ -646,7 +644,7 @@ });

expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', { x: x, y: y + 1 }, _container12.rootContainerId), function (t) {
expect(safeTarget(getTargetByDirectionFromPosition('down', { x: x, y: y + 1 }, rootContainerId), function (t) {
return t.id;
})).to.equal('overflow-below');
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', { x: x, y: y - 1 }, _container12.rootContainerId), function (t) {
expect(safeTarget(getTargetByDirectionFromPosition('up', { x: x, y: y - 1 }, rootContainerId), function (t) {
return t.id;

@@ -656,4 +654,4 @@ })).to.equal('overflow-above');

it('should ignore empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) {
(0, _container12.configureContainer)('empty-container');
it('should ignore empty containers', testScenario(scenarios.emptyContainer, function (root) {
configureContainer('empty-container');
var element = root.querySelector('#above');

@@ -670,3 +668,3 @@

expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', { x: x, y: y }, _container12.rootContainerId), function (t) {
expect(safeTarget(getTargetByDirectionFromPosition('down', { x: x, y: y }, rootContainerId), function (t) {
return t.id;

@@ -676,4 +674,4 @@ })).to.equal('below');

it('should ignore overlapping empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) {
(0, _container12.configureContainer)('empty-container');
it('should ignore overlapping empty containers', testScenario(scenarios.emptyContainer, function (root) {
configureContainer('empty-container');
var element = root.querySelector('#above');

@@ -690,3 +688,3 @@

expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', { x: x, y: y }, _container12.rootContainerId), function (t) {
expect(safeTarget(getTargetByDirectionFromPosition('down', { x: x, y: y }, rootContainerId), function (t) {
return t.id;

@@ -693,0 +691,0 @@ })).to.equal('below');

@@ -1,8 +0,1 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.testScenario = exports.spottable = exports.someSpottablesAndContainers = exports.someSpottables = exports.someNodes = exports.someContainers = exports.node = exports.join = exports.generateContainerId = exports.container = undefined;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

@@ -12,14 +5,10 @@

var _ramda = require('ramda');
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _ramda2 = _interopRequireDefault(_ramda);
import R from 'ramda';
var _container = require('../container');
import { containerAttribute } from '../container';
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var join = R.unapply(R.join('\n'));
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var join = _ramda2.default.unapply(_ramda2.default.join('\n'));
var testScenario = function testScenario(scenario, callback) {

@@ -44,3 +33,3 @@ return function () {

var generateContainerId = function generateContainerId() {
return _container.containerAttribute + '=' + _id++;
return containerAttribute + '=' + _id++;
};

@@ -80,19 +69,10 @@

var container = function container(props) {
return node(_extends(_defineProperty({}, _container.containerAttribute, _id++), coerceProps(props)));
return node(_extends(_defineProperty({}, containerAttribute, _id++), coerceProps(props)));
};
var someNodes = _ramda2.default.useWith(_ramda2.default.compose(_ramda2.default.join('\n'), _ramda2.default.map), [_ramda2.default.identity, _ramda2.default.range(0)]);
var someNodes = R.useWith(R.compose(R.join('\n'), R.map), [R.identity, R.range(0)]);
var someSpottables = someNodes(spottable);
var someContainers = someNodes(container);
var someSpottablesAndContainers = _ramda2.default.converge(_ramda2.default.concat, [someSpottables, someContainers]);
var someSpottablesAndContainers = R.converge(R.concat, [someSpottables, someContainers]);
exports.container = container;
exports.generateContainerId = generateContainerId;
exports.join = join;
exports.node = node;
exports.someContainers = someContainers;
exports.someNodes = someNodes;
exports.someSpottables = someSpottables;
exports.someSpottablesAndContainers = someSpottablesAndContainers;
exports.spottable = spottable;
exports.testScenario = testScenario;
export { container, generateContainerId, join, node, someContainers, someNodes, someSpottables, someSpottablesAndContainers, spottable, testScenario };

@@ -1,18 +0,7 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.parseSelector = exports.matchSelector = exports.intersects = exports.getRects = exports.getRect = exports.getPointRect = exports.getContainerRect = exports.contains = undefined;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _curry = require('ramda/src/curry');
import curry from 'ramda/src/curry';
var _curry2 = _interopRequireDefault(_curry);
import { getContainerNode } from './container';
var _container = require('./container');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var elementMatchesSelector = function elementMatchesSelector(selector) {

@@ -26,3 +15,3 @@ var matchedNodes = (this.parentNode || this.document).querySelectorAll(selector);

var matchSelector = (0, _curry2.default)(function (selector, elem) {
var matchSelector = curry(function (selector, elem) {
if (typeof selector === 'string') {

@@ -80,7 +69,7 @@ return elementMatchesSelector.call(elem, selector);

var intersects = (0, _curry2.default)(function (containerRect, elementRect) {
var intersects = curry(function (containerRect, elementRect) {
return testIntersection('intersects', containerRect, elementRect);
});
var contains = (0, _curry2.default)(function (containerRect, elementRect) {
var contains = curry(function (containerRect, elementRect) {
return testIntersection('contains', containerRect, elementRect);

@@ -166,3 +155,3 @@ });

function getContainerRect(containerId) {
var containerNode = (0, _container.getContainerNode)(containerId);
var containerNode = getContainerNode(containerId);

@@ -176,9 +165,2 @@ if (containerNode === document) {

exports.contains = contains;
exports.getContainerRect = getContainerRect;
exports.getPointRect = getPointRect;
exports.getRect = getRect;
exports.getRects = getRects;
exports.intersects = intersects;
exports.matchSelector = matchSelector;
exports.parseSelector = parseSelector;
export { contains, getContainerRect, getPointRect, getRect, getRects, intersects, matchSelector, parseSelector };
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc