@enact/spotlight
Advanced tools
Comparing version 1.8.0 to 1.9.0
@@ -0,1 +1,7 @@ | ||
'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"); } } | ||
@@ -181,3 +187,3 @@ | ||
export default Accelerator; | ||
export { Accelerator }; | ||
exports.default = Accelerator; | ||
exports.Accelerator = Accelerator; |
@@ -5,2 +5,13 @@ # Change Log | ||
## [1.9.0] - 2017-09-19 | ||
### Changed | ||
- `spotlight` to block handling repeated key down events that were interrupted by a pointer event | ||
### Fixed | ||
- `spotlight` to not try to focus something when the window is activated unless the window has been previously blurred | ||
- `spotlight` to prevent containers that have been unmounted from being considered potential targets | ||
## [1.8.0] - 2017-09-07 | ||
@@ -7,0 +18,0 @@ |
{ | ||
"name": "@enact/spotlight", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"description": "A focus management library", | ||
@@ -24,3 +24,3 @@ "main": "src/spotlight.js", | ||
"dependencies": { | ||
"@enact/core": "^1.8.0", | ||
"@enact/core": "^1.9.0", | ||
"prop-types": "~15.5.10", | ||
@@ -27,0 +27,0 @@ "ramda": "~0.24.1", |
@@ -0,1 +1,8 @@ | ||
'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; }; | ||
@@ -5,2 +12,22 @@ | ||
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"); } } | ||
@@ -12,21 +39,12 @@ | ||
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; } | ||
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 | ||
*/ | ||
/** | ||
* 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. | ||
@@ -128,7 +146,7 @@ * | ||
*/ | ||
var SpotlightContainerDecorator = hoc(defaultConfig, function (config, Wrapped) { | ||
var SpotlightContainerDecorator = (0, _hoc2.default)(defaultConfig, function (config, Wrapped) { | ||
var _class, _temp; | ||
var forwardMouseEnter = forward(enterEvent); | ||
var forwardMouseLeave = forward(leaveEvent); | ||
var forwardMouseEnter = (0, _handle.forward)(enterEvent); | ||
var forwardMouseLeave = (0, _handle.forward)(leaveEvent); | ||
@@ -159,3 +177,3 @@ var navigableFilter = config.navigableFilter, | ||
_this.handleMouseEnter = function (ev) { | ||
Spotlight.setActiveContainer(_this.state.id); | ||
_spotlight2.default.setActiveContainer(_this.state.id); | ||
forwardMouseEnter(ev, _this.props); | ||
@@ -167,3 +185,3 @@ }; | ||
var parentContainer = ev.currentTarget.parentNode.closest('[data-container-id]'); | ||
var activeContainer = Spotlight.getActiveContainer(); | ||
var activeContainer = _spotlight2.default.getActiveContainer(); | ||
@@ -174,3 +192,3 @@ // if this container is wrapped by another and this is the currently active | ||
activeContainer = parentContainer.dataset.containerId; | ||
Spotlight.setActiveContainer(activeContainer); | ||
_spotlight2.default.setActiveContainer(activeContainer); | ||
} | ||
@@ -182,3 +200,3 @@ } | ||
_this.state = { | ||
id: Spotlight.add(_this.props.containerId) | ||
id: _spotlight2.default.add(_this.props.containerId) | ||
}; | ||
@@ -199,3 +217,3 @@ return _this; | ||
Spotlight.set(this.state.id, cfg); | ||
_spotlight2.default.add(this.state.id, cfg); | ||
} | ||
@@ -206,4 +224,4 @@ }, { | ||
if (this.props.containerId !== nextProps.containerId) { | ||
Spotlight.remove(this.props.containerId); | ||
Spotlight.add(nextProps.containerId); | ||
_spotlight2.default.remove(this.props.containerId); | ||
_spotlight2.default.add(nextProps.containerId); | ||
this.setState({ | ||
@@ -218,3 +236,3 @@ id: nextProps.containerId | ||
if (this.props.spotlightRestrict !== prevProps.spotlightRestrict) { | ||
Spotlight.set(this.state.id, { restrict: this.props.spotlightRestrict }); | ||
_spotlight2.default.set(this.state.id, { restrict: this.props.spotlightRestrict }); | ||
} | ||
@@ -226,5 +244,5 @@ } | ||
if (preserveId) { | ||
Spotlight.unmount(this.state.id); | ||
_spotlight2.default.unmount(this.state.id); | ||
} else { | ||
Spotlight.remove(this.state.id); | ||
_spotlight2.default.remove(this.state.id); | ||
} | ||
@@ -255,3 +273,3 @@ } | ||
return React.createElement(Wrapped, rest); | ||
return _react2.default.createElement(Wrapped, rest); | ||
} | ||
@@ -261,3 +279,3 @@ }]); | ||
return _class; | ||
}(React.Component), _class.displayName = 'SpotlightContainerDecorator', _class.propTypes = /** @lends spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.prototype */{ | ||
}(_react2.default.Component), _class.displayName = 'SpotlightContainerDecorator', _class.propTypes = /** @lends spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.prototype */{ | ||
/** | ||
@@ -269,3 +287,3 @@ * Specifies the container id. If the value is `null`, an id will be generated. | ||
*/ | ||
containerId: PropTypes.string, | ||
containerId: _propTypes2.default.string, | ||
@@ -279,3 +297,3 @@ /** | ||
*/ | ||
spotlightDisabled: PropTypes.bool, | ||
spotlightDisabled: _propTypes2.default.bool, | ||
@@ -289,3 +307,3 @@ /** | ||
*/ | ||
spotlightMuted: PropTypes.bool, | ||
spotlightMuted: _propTypes2.default.bool, | ||
@@ -304,3 +322,3 @@ /** | ||
*/ | ||
spotlightRestrict: PropTypes.oneOf(['none', 'self-first', 'self-only']) | ||
spotlightRestrict: _propTypes2.default.oneOf(['none', 'self-first', 'self-only']) | ||
}, _class.defaultProps = { | ||
@@ -312,3 +330,4 @@ spotlightDisabled: false, | ||
export default SpotlightContainerDecorator; | ||
export { SpotlightContainerDecorator, spotlightDefaultClass }; | ||
exports.default = SpotlightContainerDecorator; | ||
exports.SpotlightContainerDecorator = SpotlightContainerDecorator; | ||
exports.spotlightDefaultClass = spotlightDefaultClass; |
@@ -1,4 +0,8 @@ | ||
/* global Element */ | ||
"use strict"; | ||
export default function (set, remove) { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = function (set, remove) { | ||
var polyfilled = false; | ||
@@ -42,2 +46,2 @@ | ||
}); | ||
} | ||
}; |
@@ -1,25 +0,39 @@ | ||
import { mount } from 'enzyme'; | ||
import React from 'react'; | ||
import Spotlight from '../../src/spotlight'; | ||
'use strict'; | ||
import SpotlightContainerDecorator from '../SpotlightContainerDecorator'; | ||
var _enzyme = require('enzyme'); | ||
import closest from './Element.prototype.closest'; | ||
var _react = require('react'); | ||
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 React.createElement('div', props); | ||
return _react2.default.createElement('div', props); | ||
}; | ||
closest(before, after); | ||
(0, _ElementPrototype2.default)(before, after); | ||
beforeEach(function () { | ||
Spotlight.setActiveContainer(null); | ||
_spotlight2.default.setActiveContainer(null); | ||
}); | ||
it('should set itself as the active container on mouse enter', function () { | ||
var Component = SpotlightContainerDecorator(Div); | ||
var Component = (0, _SpotlightContainerDecorator2.default)(Div); | ||
var subject = mount(React.createElement(Component, { containerId: 'test-container' })); | ||
var subject = (0, _enzyme.mount)(_react2.default.createElement(Component, { containerId: 'test-container' })); | ||
@@ -29,3 +43,3 @@ subject.find(Div).prop('onMouseEnter')(); | ||
var expected = 'test-container'; | ||
var actual = Spotlight.getActiveContainer(); | ||
var actual = _spotlight2.default.getActiveContainer(); | ||
@@ -36,9 +50,9 @@ expect(actual).to.equal(expected); | ||
it('should set active container to parent container on mouse leave', function () { | ||
var Component = SpotlightContainerDecorator(Div); | ||
var Component = (0, _SpotlightContainerDecorator2.default)(Div); | ||
var node = document.createElement('div'); | ||
var subject = mount(React.createElement( | ||
var subject = (0, _enzyme.mount)(_react2.default.createElement( | ||
Component, | ||
{ containerId: 'outer-container' }, | ||
React.createElement(Component, { containerId: 'inner-container' }) | ||
_react2.default.createElement(Component, { containerId: 'inner-container' }) | ||
), { attachTo: node }); | ||
@@ -57,3 +71,3 @@ | ||
var expected = 'outer-container'; | ||
var actual = Spotlight.getActiveContainer(); | ||
var actual = _spotlight2.default.getActiveContainer(); | ||
@@ -64,10 +78,10 @@ expect(actual).to.equal(expected); | ||
it('should not set active container on mouse leave if another container is active', function () { | ||
var Component = SpotlightContainerDecorator(Div); | ||
var Component = (0, _SpotlightContainerDecorator2.default)(Div); | ||
var node = document.createElement('div'); | ||
var subject = mount(React.createElement( | ||
var subject = (0, _enzyme.mount)(_react2.default.createElement( | ||
Component, | ||
{ containerId: 'outer-container' }, | ||
React.createElement(Component, { containerId: 'inner-container' }), | ||
React.createElement(Component, { containerId: 'self-only-container' }) | ||
_react2.default.createElement(Component, { containerId: 'inner-container' }), | ||
_react2.default.createElement(Component, { containerId: 'self-only-container' }) | ||
), { attachTo: node }); | ||
@@ -83,3 +97,3 @@ | ||
// set another container to be active | ||
Spotlight.setActiveContainer('self-only-container'); | ||
_spotlight2.default.setActiveContainer('self-only-container'); | ||
@@ -90,3 +104,3 @@ // leave inner-container | ||
var expected = 'self-only-container'; | ||
var actual = Spotlight.getActiveContainer(); | ||
var actual = _spotlight2.default.getActiveContainer(); | ||
@@ -93,0 +107,0 @@ expect(actual).to.equal(expected); |
@@ -0,1 +1,8 @@ | ||
'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; }; | ||
@@ -5,23 +12,31 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _hoc = require('@enact/core/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 _hoc2 = _interopRequireDefault(_hoc); | ||
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 _react = require('react'); | ||
/** | ||
* Exports the {@link spotlight/SpotlightRootDecorator.SpotlightRootDecorator} | ||
* Higher-order Component. | ||
* | ||
* @module spotlight/SpotlightRootDecorator | ||
*/ | ||
var _react2 = _interopRequireDefault(_react); | ||
import hoc from '@enact/core/hoc'; | ||
import React from 'react'; | ||
var _spotlight = require('../src/spotlight'); | ||
import Spotlight from '../src/spotlight'; | ||
import { spottableClass } from '../Spottable'; | ||
var _spotlight2 = _interopRequireDefault(_spotlight); | ||
import { rootContainerId } from '../src/container'; | ||
var _Spottable = require('../Spottable'); | ||
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 | ||
*/ | ||
/** | ||
@@ -60,3 +75,3 @@ * Default configuration for SpotlightRootDecorator | ||
*/ | ||
var SpotlightRootDecorator = hoc(defaultConfig, function (config, Wrapped) { | ||
var SpotlightRootDecorator = (0, _hoc2.default)(defaultConfig, function (config, Wrapped) { | ||
var _class, _temp2; | ||
@@ -95,8 +110,8 @@ | ||
Spotlight.initialize({ | ||
selector: '.' + spottableClass, | ||
_spotlight2.default.initialize({ | ||
selector: '.' + _Spottable.spottableClass, | ||
restrict: 'none' | ||
}); | ||
Spotlight.set(rootContainerId, { | ||
_spotlight2.default.set(_container.rootContainerId, { | ||
overflow: true | ||
@@ -106,3 +121,3 @@ }); | ||
if (palmSystem && palmSystem.cursor) { | ||
Spotlight.setPointerMode(palmSystem.cursor.visibility); | ||
_spotlight2.default.setPointerMode(palmSystem.cursor.visibility); | ||
} | ||
@@ -115,3 +130,3 @@ } | ||
if (!noAutoFocus) { | ||
Spotlight.focus(); | ||
_spotlight2.default.focus(); | ||
} | ||
@@ -122,3 +137,3 @@ } | ||
value: function componentWillUnmount() { | ||
Spotlight.terminate(); | ||
_spotlight2.default.terminate(); | ||
} | ||
@@ -128,3 +143,3 @@ }, { | ||
value: function render() { | ||
return React.createElement(Wrapped, this.props); | ||
return _react2.default.createElement(Wrapped, this.props); | ||
} | ||
@@ -134,7 +149,7 @@ }]); | ||
return _class; | ||
}(React.Component), _class.displayName = 'SpotlightRootDecorator', _temp2; | ||
}(_react2.default.Component), _class.displayName = 'SpotlightRootDecorator', _temp2; | ||
}); | ||
export default SpotlightRootDecorator; | ||
export { rootContainerId as spotlightRootContainerName, // DEPRECATED | ||
SpotlightRootDecorator }; | ||
exports.default = SpotlightRootDecorator; | ||
exports.spotlightRootContainerName = _container.rootContainerId; | ||
exports.SpotlightRootDecorator = SpotlightRootDecorator; |
@@ -0,1 +1,8 @@ | ||
'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; }; | ||
@@ -5,2 +12,30 @@ | ||
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; } | ||
@@ -12,23 +47,11 @@ | ||
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; } | ||
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 | ||
*/ | ||
/** | ||
* 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 | ||
@@ -90,3 +113,3 @@ * | ||
*/ | ||
var Spottable = hoc(defaultConfig, function (config, Wrapped) { | ||
var Spottable = (0, _hoc2.default)(defaultConfig, function (config, Wrapped) { | ||
var _class, _temp; | ||
@@ -127,9 +150,9 @@ | ||
if (onSpotlightDown && is('down', keyCode)) { | ||
if (onSpotlightDown && (0, _keymap.is)('down', keyCode)) { | ||
onSpotlightDown(ev); | ||
} else if (onSpotlightLeft && is('left', keyCode)) { | ||
} else if (onSpotlightLeft && (0, _keymap.is)('left', keyCode)) { | ||
onSpotlightLeft(ev); | ||
} else if (onSpotlightRight && is('right', keyCode)) { | ||
} else if (onSpotlightRight && (0, _keymap.is)('right', keyCode)) { | ||
onSpotlightRight(ev); | ||
} else if (onSpotlightUp && is('up', keyCode)) { | ||
} else if (onSpotlightUp && (0, _keymap.is)('up', keyCode)) { | ||
onSpotlightUp(ev); | ||
@@ -164,5 +187,5 @@ } | ||
_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')); | ||
_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')); | ||
@@ -174,6 +197,6 @@ _this.handleBlur = function (ev) { | ||
if (Spotlight.isMuted(ev.target)) { | ||
if (_spotlight2.default.isMuted(ev.target)) { | ||
ev.stopPropagation(); | ||
} else { | ||
forward('onBlur', ev, _this.props); | ||
(0, _handle.forward)('onBlur', ev, _this.props); | ||
} | ||
@@ -187,6 +210,6 @@ }; | ||
if (Spotlight.isMuted(ev.target)) { | ||
if (_spotlight2.default.isMuted(ev.target)) { | ||
ev.stopPropagation(); | ||
} else { | ||
forward('onFocus', ev, _this.props); | ||
(0, _handle.forward)('onFocus', ev, _this.props); | ||
} | ||
@@ -205,3 +228,3 @@ }; | ||
// eslint-disable-next-line react/no-find-dom-node | ||
this.node = ReactDOM.findDOMNode(this); | ||
this.node = _reactDom2.default.findDOMNode(this); | ||
} | ||
@@ -213,15 +236,15 @@ }, { | ||
if (this.state.spotted && (!prevProps.disabled && this.props.disabled || !prevProps.spotlightDisabled && this.props.spotlightDisabled)) { | ||
forward('onSpotlightDisappear', null, this.props); | ||
(0, _handle.forward)('onSpotlightDisappear', null, this.props); | ||
if (lastSelectTarget === this) { | ||
selectCancelled = true; | ||
forward('onMouseUp', null, this.props); | ||
(0, _handle.forward)('onMouseUp', null, this.props); | ||
} | ||
// if spotlight didn't move, find something else to spot starting from here | ||
var current = Spotlight.getCurrent(); | ||
if (!Spotlight.getPointerMode() && (!current || this.node === current)) { | ||
var current = _spotlight2.default.getCurrent(); | ||
if (!_spotlight2.default.getPointerMode() && (!current || this.node === current)) { | ||
this.node.blur(); | ||
getContainersForNode(this.node).reverse().reduce(function (found, id) { | ||
return found || Spotlight.focus(id); | ||
(0, _container.getContainersForNode)(this.node).reverse().reduce(function (found, id) { | ||
return found || _spotlight2.default.focus(id); | ||
}, false); | ||
@@ -233,7 +256,7 @@ } | ||
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 (!_spotlight2.default.getCurrent() && !_spotlight2.default.getPointerMode() && !_spotlight2.default.isPaused()) { | ||
var containers = (0, _container.getContainersForNode)(this.node); | ||
var containerId = _spotlight2.default.getActiveContainer(); | ||
if (containers.indexOf(containerId) >= 0) { | ||
Spotlight.focus(containerId); | ||
_spotlight2.default.focus(containerId); | ||
} | ||
@@ -247,3 +270,3 @@ } | ||
if (this.state.spotted) { | ||
forward('onSpotlightDisappear', null, this.props); | ||
(0, _handle.forward)('onSpotlightDisappear', null, this.props); | ||
} | ||
@@ -280,3 +303,3 @@ } | ||
return React.createElement(Wrapped, _extends({}, rest, { | ||
return _react2.default.createElement(Wrapped, _extends({}, rest, { | ||
onBlur: this.handleBlur, | ||
@@ -293,3 +316,3 @@ onFocus: this.handleFocus, | ||
return _class; | ||
}(React.Component), _class.displayName = 'Spottable', _class.propTypes = /** @lends spotlight/Spottable.Spottable.prototype */{ | ||
}(_react2.default.Component), _class.displayName = 'Spottable', _class.propTypes = /** @lends spotlight/Spottable.Spottable.prototype */{ | ||
/** | ||
@@ -302,3 +325,3 @@ * Whether or not the component is in a disabled state. | ||
*/ | ||
disabled: PropTypes.bool, | ||
disabled: _propTypes2.default.bool, | ||
@@ -312,3 +335,3 @@ /** | ||
*/ | ||
onSpotlightDisappear: PropTypes.func, | ||
onSpotlightDisappear: _propTypes2.default.func, | ||
@@ -322,3 +345,3 @@ /** | ||
*/ | ||
onSpotlightDown: PropTypes.func, | ||
onSpotlightDown: _propTypes2.default.func, | ||
@@ -332,3 +355,3 @@ /** | ||
*/ | ||
onSpotlightLeft: PropTypes.func, | ||
onSpotlightLeft: _propTypes2.default.func, | ||
@@ -342,3 +365,3 @@ /** | ||
*/ | ||
onSpotlightRight: PropTypes.func, | ||
onSpotlightRight: _propTypes2.default.func, | ||
@@ -352,3 +375,3 @@ /** | ||
*/ | ||
onSpotlightUp: PropTypes.func, | ||
onSpotlightUp: _propTypes2.default.func, | ||
@@ -362,3 +385,3 @@ /** | ||
*/ | ||
spotlightDisabled: PropTypes.bool, | ||
spotlightDisabled: _propTypes2.default.bool, | ||
@@ -372,7 +395,8 @@ /** | ||
*/ | ||
tabIndex: PropTypes.number | ||
tabIndex: _propTypes2.default.number | ||
}, _temp; | ||
}); | ||
export default Spottable; | ||
export { Spottable, spottableClass }; | ||
exports.default = Spottable; | ||
exports.Spottable = Spottable; | ||
exports.spottableClass = spottableClass; |
@@ -1,18 +0,37 @@ | ||
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; }; | ||
'use strict'; | ||
/** | ||
* Exports methods and members for creating and maintaining spotlight containers. | ||
* | ||
* @module spotlight/container | ||
* @private | ||
*/ | ||
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.addContainer = exports.setContainerLastFocusedElement = exports.isContainer5WayHoldable = exports.getContainersForNode = exports.getContainerNavigableElements = exports.getContainerLastFocusedElement = exports.getContainerDefaultElement = exports.getContainerConfig = exports.getContainerNode = exports.getAllContainerIds = undefined; | ||
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 _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 { matchSelector } from './utils'; | ||
var _and = require('ramda/src/and'); | ||
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'; | ||
@@ -44,2 +63,4 @@ var containerConfigs = new Map(); | ||
var GlobalConfig = { | ||
// set to false for unmounted containers to omit them from searches | ||
active: true, | ||
continue5WayHold: false, | ||
@@ -182,3 +203,3 @@ defaultElement: '', // <extSelector> except "@" syntax. | ||
return container.dataset.containerDisabled !== 'true'; | ||
}).reduce(and, true); | ||
}).reduce(_and2.default, true); | ||
}; | ||
@@ -333,3 +354,3 @@ | ||
return [n]; | ||
}).reduce(concat, []); | ||
}).reduce(_concat2.default, []); | ||
}; | ||
@@ -479,2 +500,23 @@ | ||
/** | ||
* Adds a container and marks it active. When a container id is not specified, it will be generated. | ||
* | ||
* @param {String|Object} containerIdOrConfig Either a string container id or a configuration | ||
* object. | ||
* @param {Object} [config] Container configuration when `containerIdOrConfig` | ||
* is a string. When omitted, the container will have | ||
* the default `GlobalConfig`. | ||
* | ||
* @returns {String} The container id | ||
* @memberof spotlight/container | ||
* @public | ||
*/ | ||
var addContainer = function addContainer() { | ||
var containerId = configureContainer.apply(undefined, arguments); | ||
var config = getContainerConfig(containerId); | ||
config.active = true; | ||
return containerId; | ||
}; | ||
/** | ||
* Removes a container | ||
@@ -538,3 +580,3 @@ * | ||
var config = getContainerConfig(containerId); | ||
if (verify && config.selector && !isContainer(node) && !matchSelector(config.selector, node)) { | ||
if (verify && config.selector && !isContainer(node) && !(0, _utils.matchSelector)(config.selector, node)) { | ||
return false; | ||
@@ -560,3 +602,5 @@ } | ||
while ((id = keys.next()) && !id.done) { | ||
ids.push(id.value); | ||
if (isActiveContainer(id.value)) { | ||
ids.push(id.value); | ||
} | ||
} | ||
@@ -572,3 +616,3 @@ | ||
* | ||
* @returns {Node} Default focus element | ||
* @returns {Node|null} Default focus element | ||
* @memberof spotlight/container | ||
@@ -578,4 +622,5 @@ * @public | ||
function getContainerDefaultElement(containerId) { | ||
var defaultElementSelector = getContainerConfig(containerId).defaultElement; | ||
var config = getContainerConfig(containerId); | ||
var defaultElementSelector = config && config.defaultElement; | ||
if (!defaultElementSelector) { | ||
@@ -585,3 +630,3 @@ return null; | ||
defaultElementSelector = coerceArray(defaultElementSelector); | ||
defaultElementSelector = (0, _util.coerceArray)(defaultElementSelector); | ||
var spottables = getDeepSpottableDescendants(containerId); | ||
@@ -596,3 +641,3 @@ | ||
return spottables.filter(function (elem) { | ||
return matchSelector(selector, elem) && isNavigable(elem, containerId, true); | ||
return (0, _utils.matchSelector)(selector, elem) && isNavigable(elem, containerId, true); | ||
})[0]; | ||
@@ -612,3 +657,3 @@ } | ||
* | ||
* @returns {Node|String} DOM Node last focused | ||
* @returns {Node|String|null} DOM Node last focused | ||
* @memberof spotlight/container | ||
@@ -618,8 +663,11 @@ * @public | ||
function getContainerLastFocusedElement(containerId) { | ||
var _getContainerConfig = getContainerConfig(containerId), | ||
lastFocusedElement = _getContainerConfig.lastFocusedElement; | ||
var config = getContainerConfig(containerId); | ||
if (!config || !config.lastFocusedElement) { | ||
return null; | ||
} | ||
// lastFocusedElement may be a container ID so try to convert it to a node to test navigability | ||
var lastFocusedElement = config.lastFocusedElement; | ||
var node = lastFocusedElement; | ||
@@ -690,3 +738,3 @@ if (typeof node === 'string') { | ||
return next ? coerceArray(next) : []; | ||
return next ? (0, _util.coerceArray)(next) : []; | ||
} | ||
@@ -798,2 +846,3 @@ | ||
if (config) { | ||
config.active = false; | ||
persistLastFocusedElement(containerId); | ||
@@ -807,4 +856,9 @@ | ||
function isActiveContainer(containerId) { | ||
var config = getContainerConfig(containerId); | ||
return config && config.active; | ||
} | ||
function getDefaultContainer() { | ||
return _defaultContainerId; | ||
return isActiveContainer(_defaultContainerId) ? _defaultContainerId : ''; | ||
} | ||
@@ -823,3 +877,3 @@ | ||
function getLastContainer() { | ||
return _lastContainerId; | ||
return isActiveContainer(_lastContainerId) ? _lastContainerId : ''; | ||
} | ||
@@ -844,5 +898,5 @@ | ||
var targetContainers = getContainersForNode(target); | ||
var targetInnerContainer = last(targetContainers); | ||
var targetInnerContainer = (0, _last2.default)(targetContainers); | ||
var sharedContainer = last(intersection(currentContainers, targetContainers)); | ||
var sharedContainer = (0, _last2.default)((0, _intersection2.default)(currentContainers, targetContainers)); | ||
@@ -860,10 +914,30 @@ if (sharedContainer || currentContainerConfig.restrict !== 'self-only') { | ||
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 }; | ||
exports.getAllContainerIds = getAllContainerIds; | ||
exports.getContainerNode = getContainerNode; | ||
exports.getContainerConfig = getContainerConfig; | ||
exports.getContainerDefaultElement = getContainerDefaultElement; | ||
exports.getContainerLastFocusedElement = getContainerLastFocusedElement; | ||
exports.getContainerNavigableElements = getContainerNavigableElements; | ||
exports.getContainersForNode = getContainersForNode; | ||
exports.isContainer5WayHoldable = isContainer5WayHoldable; | ||
exports.setContainerLastFocusedElement = setContainerLastFocusedElement; | ||
exports.addContainer = addContainer; | ||
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; |
@@ -0,2 +1,7 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function prioritize(priorities) { | ||
@@ -232,3 +237,3 @@ var destPriority = null; | ||
export default navigate; | ||
export { navigate }; | ||
exports.default = navigate; | ||
exports.navigate = navigate; |
@@ -1,11 +0,12 @@ | ||
/** | ||
* Exports methods and members for working with pointer events in spotlight | ||
* | ||
* @module spotlight/pointer | ||
* @private | ||
*/ | ||
'use strict'; | ||
import { is } from '@enact/core/keymap'; | ||
import { Job } from '@enact/core/util'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.updatePointerPosition = exports.setPointerMode = exports.notifyPointerMove = exports.notifyKeyDown = exports.getPointerMode = exports.getLastPointerPosition = undefined; | ||
var _keymap = require('@enact/core/keymap'); | ||
var _util = require('@enact/core/util'); | ||
/* | ||
@@ -18,2 +19,9 @@ * 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; | ||
@@ -89,3 +97,3 @@ | ||
// event, but not too large that another unrelated event can be fired inside the window | ||
var hidePointerJob = new Job(function (callback) { | ||
var hidePointerJob = new _util.Job(function (callback) { | ||
setPointerMode(false); | ||
@@ -135,6 +143,6 @@ if (callback) { | ||
// for hide/show pointer events, handle them and return true | ||
if (is('pointerHide', keyCode)) { | ||
if ((0, _keymap.is)('pointerHide', keyCode)) { | ||
hidePointerJob.start(callback); | ||
return true; | ||
} else if (is('pointerShow', keyCode)) { | ||
} else if ((0, _keymap.is)('pointerShow', keyCode)) { | ||
setPointerMode(true); | ||
@@ -149,2 +157,7 @@ return true; | ||
export { getLastPointerPosition, getPointerMode, notifyKeyDown, notifyPointerMove, setPointerMode, updatePointerPosition }; | ||
exports.getLastPointerPosition = getLastPointerPosition; | ||
exports.getPointerMode = getPointerMode; | ||
exports.notifyKeyDown = notifyKeyDown; | ||
exports.notifyPointerMove = notifyPointerMove; | ||
exports.setPointerMode = setPointerMode; | ||
exports.updatePointerPosition = updatePointerPosition; |
@@ -0,1 +1,30 @@ | ||
'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 }; } | ||
/* | ||
@@ -19,22 +48,8 @@ * A javascript-based implementation of Spatial Navigation. | ||
import { is } from '@enact/core/keymap'; | ||
import last from 'ramda/src/last'; | ||
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 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'); | ||
/** | ||
@@ -53,3 +68,3 @@ * Translates keyCodes into 5-way direction descriptions (e.g. `'down'`) | ||
var SpotlightAccelerator = new Accelerator(); | ||
var SpotlightAccelerator = new _Accelerator2.default(); | ||
@@ -96,2 +111,19 @@ /** | ||
/* | ||
* Whether to set focus during the next window focus event | ||
* | ||
* @type {Boolean} | ||
* @default false | ||
*/ | ||
var _spotOnWindowFocus = false; | ||
/* | ||
* `true` when a pointer move event occurs during a keypress. Used to short circuit key down | ||
* handling until the next keyup occurs. | ||
* | ||
* @type {Boolean} | ||
* @default false | ||
*/ | ||
var _pointerMoveDuringKeyPress = false; | ||
/* | ||
* protected methods | ||
@@ -107,3 +139,3 @@ */ | ||
function shouldPreventNavigation() { | ||
return !getAllContainerIds().length || _pause; | ||
return !(0, _container.getAllContainerIds)().length || _pause; | ||
} | ||
@@ -123,4 +155,4 @@ | ||
if (getPointerMode() && !fromPointer) { | ||
setContainerLastFocusedElement(elem, containerIds); | ||
if ((0, _pointer.getPointerMode)() && !fromPointer) { | ||
(0, _container.setContainerLastFocusedElement)(elem, containerIds); | ||
return false; | ||
@@ -170,19 +202,41 @@ } | ||
if (!containerIds || !containerIds.length) { | ||
containerIds = getContainersForNode(elem); | ||
containerIds = (0, _container.getContainersForNode)(elem); | ||
} | ||
var containerId = last(containerIds); | ||
var containerId = (0, _last2.default)(containerIds); | ||
if (containerId) { | ||
setContainerLastFocusedElement(elem, containerIds); | ||
setLastContainer(containerId); | ||
(0, _container.setContainerLastFocusedElement)(elem, containerIds); | ||
(0, _container.setLastContainer)(containerId); | ||
} | ||
} | ||
function restoreFocus() { | ||
var lastContainerId = (0, _container.getLastContainer)(); | ||
var next = [_container.rootContainerId]; | ||
if (lastContainerId) { | ||
next.unshift(lastContainerId); | ||
// only prepend last focused if it exists so that Spotlight.focus() doesn't receive | ||
// a falsey target | ||
var lastFocused = (0, _container.getContainerLastFocusedElement)(lastContainerId); | ||
if (lastFocused) { | ||
next.unshift(lastFocused); | ||
} | ||
} | ||
// attempt to find a target starting with the last focused element in the last | ||
// container, followed by the last container, and finally the root container | ||
return next.reduce(function (focused, target) { | ||
return focused || Spotlight.focus(target); | ||
}, false); | ||
} | ||
function spotNextFromPoint(direction, position) { | ||
var containerId = getLastContainer(); | ||
var next = getTargetByDirectionFromPosition(direction, position, containerId); | ||
var containerId = Spotlight.getActiveContainer(); | ||
var next = (0, _target.getTargetByDirectionFromPosition)(direction, position, containerId); | ||
if (next) { | ||
setContainerPreviousTarget(containerId, direction, next, getContainerLastFocusedElement(containerId)); | ||
(0, _container.setContainerPreviousTarget)(containerId, direction, next, (0, _container.getContainerLastFocusedElement)(containerId)); | ||
return focusElement(next, getContainersForNode(next)); | ||
return focusElement(next, (0, _container.getContainersForNode)(next)); | ||
} | ||
@@ -194,15 +248,15 @@ | ||
function spotNext(direction, currentFocusedElement, currentContainerIds) { | ||
var next = getTargetByDirectionFromElement(direction, currentFocusedElement); | ||
var next = (0, _target.getTargetByDirectionFromElement)(direction, currentFocusedElement); | ||
if (next) { | ||
var currentContainerId = last(currentContainerIds); | ||
var nextContainerIds = getContainersForNode(next); | ||
var currentContainerId = (0, _last2.default)(currentContainerIds); | ||
var nextContainerIds = (0, _container.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 && !isContainer5WayHoldable(currentContainerId)) { | ||
if (_5WayKeyHold && nextContainerIds.indexOf(currentContainerId) < 0 && !(0, _container.isContainer5WayHoldable)(currentContainerId)) { | ||
return false; | ||
} | ||
setContainerPreviousTarget(currentContainerId, direction, next, currentFocusedElement); | ||
(0, _container.setContainerPreviousTarget)(currentContainerId, direction, next, currentFocusedElement); | ||
@@ -216,21 +270,10 @@ return focusElement(next, nextContainerIds); | ||
function onAcceleratedKeyDown(evt) { | ||
var currentFocusedElement = _getCurrent(); | ||
var direction = getDirection(evt.keyCode); | ||
if (!currentFocusedElement) { | ||
var lastContainerId = getLastContainer(); | ||
if (lastContainerId) { | ||
currentFocusedElement = getContainerLastFocusedElement(lastContainerId); | ||
} | ||
if (!currentFocusedElement) { | ||
focusElement(getTargetByContainer(), getContainersForNode(currentFocusedElement)); | ||
if (!direction) return; | ||
return preventDefault(evt); | ||
} | ||
} | ||
var currentFocusedElement = _getCurrent(); | ||
var currentContainerIds = (0, _container.getContainersForNode)(currentFocusedElement); | ||
var currentContainerIds = getContainersForNode(currentFocusedElement); | ||
if (direction && !spotNext(direction, currentFocusedElement, currentContainerIds) && currentFocusedElement !== document.activeElement) { | ||
focusElement(currentFocusedElement, currentContainerIds); | ||
} | ||
spotNext(direction, currentFocusedElement, currentContainerIds); | ||
} | ||
@@ -245,19 +288,21 @@ | ||
Spotlight.setPointerMode(false); | ||
_spotOnWindowFocus = true; | ||
} | ||
function onFocus() { | ||
var palmSystem = window.PalmSystem; | ||
// Normally, there isn't focus here unless the window has been blurred 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) unless the window was previously blurred | ||
if (_spotOnWindowFocus) { | ||
var palmSystem = window.PalmSystem; | ||
if (palmSystem && palmSystem.cursor) { | ||
Spotlight.setPointerMode(palmSystem.cursor.visibility); | ||
} | ||
if (palmSystem && palmSystem.cursor) { | ||
Spotlight.setPointerMode(palmSystem.cursor.visibility); | ||
} | ||
// 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)); | ||
Spotlight.focus((0, _container.getContainerLastFocusedElement)(_container.rootContainerId)); | ||
_spotOnWindowFocus = false; | ||
} | ||
@@ -267,2 +312,3 @@ } | ||
function onKeyUp(evt) { | ||
_pointerMoveDuringKeyPress = false; | ||
var keyCode = evt.keyCode; | ||
@@ -277,5 +323,4 @@ | ||
function handlePointerHide() { | ||
var lastContainerId = getLastContainer(); | ||
if (!_getCurrent() && lastContainerId) { | ||
Spotlight.focus(getContainerLastFocusedElement(lastContainerId)); | ||
if (!_getCurrent()) { | ||
restoreFocus(); | ||
} | ||
@@ -291,13 +336,14 @@ } | ||
var direction = getDirection(keyCode); | ||
var pointerHandled = notifyKeyDown(keyCode, handlePointerHide); | ||
var pointerHandled = (0, _pointer.notifyKeyDown)(keyCode, handlePointerHide); | ||
if (pointerHandled || !(direction || isEnter(keyCode))) { | ||
_pointerMoveDuringKeyPress = true; | ||
return; | ||
} | ||
if (!_pause) { | ||
if (!_pause && !_pointerMoveDuringKeyPress) { | ||
if (_getCurrent()) { | ||
SpotlightAccelerator.processKey(evt, onAcceleratedKeyDown); | ||
} else if (!spotNextFromPoint(direction, getLastPointerPosition())) { | ||
Spotlight.focus(getContainerLastFocusedElement(getLastContainer())); | ||
} else if (!spotNextFromPoint(direction, (0, _pointer.getLastPointerPosition)())) { | ||
restoreFocus(); | ||
} | ||
@@ -320,11 +366,15 @@ _5WayKeyHold = true; | ||
var current = _getCurrent(); | ||
var update = notifyPointerMove(current, target, clientX, clientY); | ||
var update = (0, _pointer.notifyPointerMove)(current, target, clientX, clientY); | ||
if (update) { | ||
var next = getNavigableTarget(target); | ||
if (_5WayKeyHold) { | ||
_pointerMoveDuringKeyPress = true; | ||
} | ||
var next = (0, _target.getNavigableTarget)(target); | ||
// TODO: Consider encapsulating this work within focusElement | ||
if (next !== current) { | ||
if (next) { | ||
focusElement(next, getContainersForNode(next), true); | ||
focusElement(next, (0, _container.getContainersForNode)(next), true); | ||
@@ -334,3 +384,3 @@ return true; | ||
current.blur(); | ||
setLastContainerFromTarget(current, target); | ||
(0, _container.setLastContainerFromTarget)(current, target); | ||
} | ||
@@ -347,7 +397,7 @@ } | ||
if (getPointerMode()) { | ||
var next = getNavigableTarget(target); // account for child controls | ||
if ((0, _pointer.getPointerMode)()) { | ||
var next = (0, _target.getNavigableTarget)(target); // account for child controls | ||
if (next && next !== _getCurrent()) { | ||
focusElement(next, getContainersForNode(next), true); | ||
focusElement(next, (0, _container.getContainersForNode)(next), true); | ||
@@ -379,5 +429,5 @@ return true; | ||
window.addEventListener('mousemove', onMouseMove); | ||
setLastContainer(rootContainerId); | ||
configureDefaults(containerDefaults); | ||
configureContainer(rootContainerId); | ||
(0, _container.setLastContainer)(_container.rootContainerId); | ||
(0, _container.configureDefaults)(containerDefaults); | ||
(0, _container.configureContainer)(_container.rootContainerId); | ||
_initialized = true; | ||
@@ -409,5 +459,5 @@ } | ||
clear: function clear() { | ||
removeAllContainers(); | ||
setDefaultContainer(); | ||
setLastContainer(); | ||
(0, _container.removeAllContainers)(); | ||
(0, _container.setDefaultContainer)(); | ||
(0, _container.setLastContainer)(); | ||
_duringFocusChange = false; | ||
@@ -421,2 +471,3 @@ }, | ||
* | ||
* @function | ||
* @param {String|Object} param1 Configuration object or container ID | ||
@@ -427,5 +478,3 @@ * @param {Object|undefined} param2 Configuration object if container ID supplied in param1 | ||
*/ | ||
set: function set(containerId, config) { | ||
configureContainer(containerId, config); | ||
}, | ||
set: _container.configureContainer, | ||
@@ -438,2 +487,3 @@ // add(<config>); | ||
* | ||
* @function | ||
* @param {String|Object} param1 Configuration object or container ID | ||
@@ -444,5 +494,3 @@ * @param {Object|undefined} param2 Configuration object if container ID supplied in param1 | ||
*/ | ||
add: function add(containerId, config) { | ||
return configureContainer(containerId, config); | ||
}, | ||
add: _container.addContainer, | ||
@@ -453,3 +501,3 @@ unmount: function unmount(containerId) { | ||
} | ||
unmountContainer(containerId); | ||
(0, _container.unmountContainer)(containerId); | ||
}, | ||
@@ -468,5 +516,5 @@ | ||
} | ||
if (getContainerConfig(containerId)) { | ||
removeContainer(containerId); | ||
if (getLastContainer() === containerId) { | ||
if ((0, _container.getContainerConfig)(containerId)) { | ||
(0, _container.removeContainer)(containerId); | ||
if ((0, _container.getLastContainer)() === containerId) { | ||
Spotlight.setActiveContainer(null); | ||
@@ -487,4 +535,4 @@ } | ||
disableSelector: function disableSelector(containerId) { | ||
if (isContainer(containerId)) { | ||
configureContainer(containerId, { selectorDisabled: false }); | ||
if ((0, _container.isContainer)(containerId)) { | ||
(0, _container.configureContainer)(containerId, { selectorDisabled: false }); | ||
return true; | ||
@@ -504,4 +552,4 @@ } | ||
enableSelector: function enableSelector(containerId) { | ||
if (isContainer(containerId)) { | ||
configureContainer(containerId, { selectorDisabled: false }); | ||
if ((0, _container.isContainer)(containerId)) { | ||
(0, _container.configureContainer)(containerId, { selectorDisabled: false }); | ||
return true; | ||
@@ -551,15 +599,15 @@ } | ||
if (!elem) { | ||
target = getTargetByContainer(); | ||
target = (0, _target.getTargetByContainer)(); | ||
} else if (typeof elem === 'string') { | ||
if (getContainerConfig(elem)) { | ||
target = getTargetByContainer(elem); | ||
if ((0, _container.getContainerConfig)(elem)) { | ||
target = (0, _target.getTargetByContainer)(elem); | ||
wasContainerId = true; | ||
} else { | ||
target = getTargetBySelector(elem); | ||
target = (0, _target.getTargetBySelector)(elem); | ||
} | ||
} | ||
var nextContainerIds = getContainersForNode(target); | ||
var nextContainerId = last(nextContainerIds); | ||
if (isNavigable(target, nextContainerId)) { | ||
var nextContainerIds = (0, _container.getContainersForNode)(target); | ||
var nextContainerId = (0, _last2.default)(nextContainerIds); | ||
if ((0, _container.isNavigable)(target, nextContainerId)) { | ||
return focusElement(target, nextContainerIds); | ||
@@ -593,3 +641,3 @@ } else if (wasContainerId) { | ||
var elem = selector ? parseSelector(selector)[0] : _getCurrent(); | ||
var elem = selector ? (0, _utils.parseSelector)(selector)[0] : _getCurrent(); | ||
if (!elem) { | ||
@@ -599,3 +647,3 @@ return false; | ||
var containerIds = getContainersForNode(elem); | ||
var containerIds = (0, _container.getContainersForNode)(elem); | ||
if (!containerIds.length) { | ||
@@ -611,2 +659,3 @@ return false; | ||
* | ||
* @function | ||
* @param {String|undefined} containerId The container ID or a falsy value to clear default container | ||
@@ -616,3 +665,3 @@ * @returns {undefined} | ||
*/ | ||
setDefaultContainer: setDefaultContainer, | ||
setDefaultContainer: _container.setDefaultContainer, | ||
@@ -625,3 +674,5 @@ /** | ||
*/ | ||
getActiveContainer: getLastContainer, | ||
getActiveContainer: function getActiveContainer() { | ||
return (0, _container.getLastContainer)() || _container.rootContainerId; | ||
}, | ||
@@ -636,3 +687,3 @@ /** | ||
setActiveContainer: function setActiveContainer(containerId) { | ||
setLastContainer(containerId || rootContainerId); | ||
(0, _container.setLastContainer)(containerId || _container.rootContainerId); | ||
}, | ||
@@ -647,3 +698,3 @@ | ||
*/ | ||
getPointerMode: getPointerMode, | ||
getPointerMode: _pointer.getPointerMode, | ||
@@ -658,3 +709,3 @@ /** | ||
*/ | ||
setPointerMode: setPointerMode, | ||
setPointerMode: _pointer.setPointerMode, | ||
@@ -673,3 +724,3 @@ /** | ||
return matchSelector('[data-container-muted="true"] .' + spottableClass, elem); | ||
return (0, _utils.matchSelector)('[data-container-muted="true"] .' + _Spottable.spottableClass, elem); | ||
}, | ||
@@ -699,3 +750,3 @@ | ||
return matchSelector('.' + spottableClass, elem); | ||
return (0, _utils.matchSelector)('.' + _Spottable.spottableClass, elem); | ||
}, | ||
@@ -725,3 +776,3 @@ | ||
return _getSpottableDescendants(containerId); | ||
return (0, _container.getSpottableDescendants)(containerId); | ||
} | ||
@@ -733,3 +784,4 @@ }; | ||
export default Spotlight; | ||
export { getDirection, Spotlight }; | ||
exports.default = Spotlight; | ||
exports.getDirection = getDirection; | ||
exports.Spotlight = Spotlight; |
@@ -1,11 +0,26 @@ | ||
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); } } | ||
'use strict'; | ||
import last from 'ramda/src/last'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.getTargetBySelector = exports.getTargetByDirectionFromPosition = exports.getTargetByDirectionFromElement = exports.getTargetByContainer = exports.getNavigableTarget = undefined; | ||
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 _last = require('ramda/src/last'); | ||
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 = getContainersForNode(elem); | ||
var containers = (0, _container.getContainersForNode)(elem); | ||
var verifySelector = true; | ||
@@ -15,3 +30,3 @@ | ||
var containerId = containers[i]; | ||
if (!isNavigable(elem, containerId, verifySelector)) { | ||
if (!(0, _container.isNavigable)(elem, containerId, verifySelector)) { | ||
return false; | ||
@@ -30,3 +45,3 @@ } | ||
var addRange = function addRange(id) { | ||
var config = getContainerConfig(id); | ||
var config = (0, _container.getContainerConfig)(id); | ||
if (id && range.indexOf(id) < 0 && config && !config.selectorDisabled) { | ||
@@ -40,5 +55,5 @@ range.push(id); | ||
} else { | ||
addRange(getDefaultContainer()); | ||
addRange(getLastContainer()); | ||
[].concat(_toConsumableArray(getAllContainerIds())).map(addRange); | ||
addRange((0, _container.getDefaultContainer)()); | ||
addRange((0, _container.getLastContainer)()); | ||
[].concat(_toConsumableArray((0, _container.getAllContainerIds)())).map(addRange); | ||
} | ||
@@ -51,3 +66,3 @@ | ||
return getContainersToSearch(containerId).reduce(function (next, id) { | ||
return next || getContainerFocusTarget(id); | ||
return next || (0, _container.getContainerFocusTarget)(id); | ||
}, null); | ||
@@ -65,6 +80,6 @@ } | ||
var next = parseSelector(selector)[0]; | ||
var next = (0, _utils.parseSelector)(selector)[0]; | ||
if (next) { | ||
var nextContainerIds = getContainersForNode(next); | ||
if (isNavigable(next, last(nextContainerIds), true)) { | ||
var nextContainerIds = (0, _container.getContainersForNode)(next); | ||
if ((0, _container.isNavigable)(next, (0, _last2.default)(nextContainerIds), true)) { | ||
return next; | ||
@@ -78,3 +93,3 @@ } | ||
function isRestrictedContainer(containerId) { | ||
var config = getContainerConfig(containerId); | ||
var config = (0, _container.getContainerConfig)(containerId); | ||
return config.enterTo === 'last-focused' || config.enterTo === 'default-element'; | ||
@@ -84,4 +99,4 @@ } | ||
function getSpottableDescendantsWithoutContainers(containerId, containerIds) { | ||
return getSpottableDescendants(containerId).filter(function (n) { | ||
return !isContainer(n) || containerIds.indexOf(n.dataset.containerId) === -1; | ||
return (0, _container.getSpottableDescendants)(containerId).filter(function (n) { | ||
return !(0, _container.isContainer)(n) || containerIds.indexOf(n.dataset.containerId) === -1; | ||
}); | ||
@@ -97,8 +112,8 @@ } | ||
return elementRects.filter(function (rect) { | ||
if (isContainer(rect.element)) { | ||
if ((0, _container.isContainer)(rect.element)) { | ||
// For containers, test intersection since they may be larger than the bounding rect | ||
return intersects(boundingRect, rect); | ||
return (0, _utils.intersects)(boundingRect, rect); | ||
} else { | ||
// For elements, use contains with the center to include mostly visible elements | ||
return contains(boundingRect, rect.center); | ||
return (0, _utils.contains)(boundingRect, rect.center); | ||
} | ||
@@ -111,3 +126,3 @@ }); | ||
var overlapping = elementRects.filter(function (rect) { | ||
return isContainer(rect.element) && contains(rect, elementRect); | ||
return (0, _container.isContainer)(rect.element) && (0, _utils.contains)(rect, elementRect); | ||
}); | ||
@@ -130,5 +145,5 @@ | ||
// a container tree with `element` | ||
var nextConfig = getContainerConfig(containerId); | ||
var nextConfig = (0, _container.getContainerConfig)(containerId); | ||
if (nextConfig.overflow) { | ||
return getContainerRect(containerId); | ||
return (0, _utils.getContainerRect)(containerId); | ||
} | ||
@@ -139,3 +154,3 @@ } | ||
var elements = getSpottableDescendantsWithoutContainers(containerId, elementContainerIds); | ||
var elementRects = filterRects(getRects(elements), boundingRect); | ||
var elementRects = filterRects((0, _utils.getRects)(elements), boundingRect); | ||
@@ -165,6 +180,6 @@ var next = null; | ||
// try to navigate from position to one of the candidates in containerId | ||
next = navigate(positionRect, direction, elementRects, getContainerConfig(containerId)); | ||
next = (0, _navigate2.default)(positionRect, direction, elementRects, (0, _container.getContainerConfig)(containerId)); | ||
// if we match a container, recurse into it | ||
if (next && isContainer(next)) { | ||
if (next && (0, _container.isContainer)(next)) { | ||
var nextContainerId = next.dataset.containerId; | ||
@@ -209,3 +224,3 @@ | ||
// shortcut for previous target from element if it were saved | ||
var previous = getContainerPreviousTarget(containerId, direction, element); | ||
var previous = (0, _container.getContainerPreviousTarget)(containerId, direction, element); | ||
if (previous && elements.indexOf(previous) !== -1) { | ||
@@ -215,3 +230,3 @@ return previous; | ||
var elementRects = filterRects(getRects(elements), boundingRect); | ||
var elementRects = filterRects((0, _utils.getRects)(elements), boundingRect); | ||
@@ -242,6 +257,6 @@ var next = null; | ||
// try to navigate from element to one of the candidates in containerId | ||
next = navigate(elementRect, direction, elementRects, getContainerConfig(containerId)); | ||
next = (0, _navigate2.default)(elementRect, direction, elementRects, (0, _container.getContainerConfig)(containerId)); | ||
// if we match a container, | ||
if (next && isContainer(next)) { | ||
if (next && (0, _container.isContainer)(next)) { | ||
var nextContainerId = next.dataset.containerId; | ||
@@ -293,5 +308,5 @@ | ||
var elementRect = getRect(element); | ||
var elementRect = (0, _utils.getRect)(element); | ||
return getNavigableContainersForNode(element).reduceRight(function (result, containerId, index, elementContainerIds) { | ||
return (0, _container.getNavigableContainersForNode)(element).reduceRight(function (result, containerId, index, elementContainerIds) { | ||
result = result || getTargetInContainerByDirectionFromElement(direction, containerId, element, elementRect, elementContainerIds); | ||
@@ -315,5 +330,5 @@ | ||
function getTargetByDirectionFromPosition(direction, position, containerId) { | ||
var pointerRect = getPointRect(position); | ||
var pointerRect = (0, _utils.getPointRect)(position); | ||
return getNavigableContainersForNode(getContainerNode(containerId)).reduceRight(function (result, id, index, elementContainerIds) { | ||
return (0, _container.getNavigableContainersForNode)((0, _container.getContainerNode)(containerId)).reduceRight(function (result, id, index, elementContainerIds) { | ||
return result || getTargetInContainerByDirectionFromPosition(direction, id, pointerRect, elementContainerIds); | ||
@@ -335,3 +350,3 @@ }, null); | ||
function getLeaveForTarget(containerId, direction) { | ||
var config = getContainerConfig(containerId); | ||
var config = (0, _container.getContainerConfig)(containerId); | ||
@@ -346,4 +361,4 @@ var target = config.restrict !== 'self-only' && config.leaveFor && config.leaveFor[direction]; | ||
var nextContainerIds = getContainersForNode(target); | ||
if (isNavigable(target, last(nextContainerIds))) { | ||
var nextContainerIds = (0, _container.getContainersForNode)(target); | ||
if ((0, _container.isNavigable)(target, (0, _last2.default)(nextContainerIds))) { | ||
return target; | ||
@@ -359,3 +374,3 @@ } | ||
var parent = void 0; | ||
while (target && (isContainer(target) || !isFocusable(target))) { | ||
while (target && ((0, _container.isContainer)(target) || !isFocusable(target))) { | ||
parent = target.parentNode; | ||
@@ -367,2 +382,6 @@ target = parent === document ? null : parent; // calling isNavigable on document is problematic | ||
export { getNavigableTarget, getTargetByContainer, getTargetByDirectionFromElement, getTargetByDirectionFromPosition, getTargetBySelector }; | ||
exports.getNavigableTarget = getNavigableTarget; | ||
exports.getTargetByContainer = getTargetByContainer; | ||
exports.getTargetByDirectionFromElement = getTargetByDirectionFromElement; | ||
exports.getTargetByDirectionFromPosition = getTargetByDirectionFromPosition; | ||
exports.getTargetBySelector = getTargetBySelector; |
@@ -0,37 +1,39 @@ | ||
'use strict'; | ||
var _node, _container, _container2, _container3, _container4, _container5, _container6, _container7, _container8, _container9, _container10, _container11, _container12, _container13, _container15; | ||
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 _container16 = 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 node({ className: 'other' }); | ||
return (0, _utils.node)({ className: 'other' }); | ||
}; | ||
var scenarios = { | ||
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)) | ||
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, _container16.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, _container16.containerAttribute, 'first'), _defineProperty(_container, 'children', (0, _utils.someSpottables)(5)), _container)), (0, _utils.container)((_container2 = {}, _defineProperty(_container2, _container16.containerAttribute, 'second'), _defineProperty(_container2, 'children', (0, _utils.someSpottables)(5)), _container2))), | ||
mixedOrder: (0, _utils.join)((0, _utils.container)((_container3 = {}, _defineProperty(_container3, _container16.containerAttribute, 'first'), _defineProperty(_container3, 'name', 'c1'), _container3)), (0, _utils.spottable)({ name: 's1' }), (0, _utils.container)((_container4 = {}, _defineProperty(_container4, _container16.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, _container16.containerAttribute, 'first-container'), _defineProperty(_container7, 'children', (0, _utils.join)((0, _utils.someSpottables)(2), (0, _utils.container)((_container6 = {}, _defineProperty(_container6, _container16.containerAttribute, 'second-container'), _defineProperty(_container6, 'children', (0, _utils.join)((0, _utils.spottable)({ id: 'secondContainerFirstSpottable' }), (0, _utils.someSpottables)(2), (0, _utils.container)((_container5 = {}, _defineProperty(_container5, _container16.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, _container16.containerAttribute, 'container'), _defineProperty(_container8, 'data-container-disabled', true), _defineProperty(_container8, 'children', (0, _utils.someSpottables)(5)), _container8)), | ||
spottablesInNestedDisabledContainer: (0, _utils.container)((_container10 = {}, _defineProperty(_container10, _container16.containerAttribute, 'container'), _defineProperty(_container10, 'data-container-disabled', true), _defineProperty(_container10, 'children', (0, _utils.container)((_container9 = {}, _defineProperty(_container9, _container16.containerAttribute, 'child'), _defineProperty(_container9, 'children', (0, _utils.someSpottables)(5)), _container9))), _container10)), | ||
containerWithDefaultAndLastFocused: (0, _utils.container)((_container11 = {}, _defineProperty(_container11, _container16.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, _container16.containerAttribute, 'container'), _defineProperty(_container13, 'children', (0, _utils.join)((0, _utils.spottable)({ id: 'firstSpottable' }), (0, _utils.someSpottables)(5), (0, _utils.container)((_container12 = {}, _defineProperty(_container12, _container16.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)), | ||
emptySubcontainer: (0, _utils.container)((_container15 = {}, _defineProperty(_container15, _container16.containerAttribute, 'container'), _defineProperty(_container15, 'children', (0, _utils.join)((0, _utils.container)(_defineProperty({}, _container16.containerAttribute, 'subcontainer')), (0, _utils.spottable)({ id: 'afterSubcontainer' }))), _container15)) | ||
}; | ||
var setupContainers = function setupContainers() { | ||
configureDefaults({ | ||
(0, _container16.configureDefaults)({ | ||
selector: '.spottable' | ||
}); | ||
configureContainer(rootContainerId); | ||
setLastContainer(rootContainerId); | ||
(0, _container16.configureContainer)(_container16.rootContainerId); | ||
(0, _container16.setLastContainer)(_container16.rootContainerId); | ||
}; | ||
@@ -41,3 +43,3 @@ | ||
// clean up any containers we create for safe tests | ||
getAllContainerIds().forEach(removeContainer); | ||
(0, _container16.removeAllContainers)(); | ||
}; | ||
@@ -50,5 +52,5 @@ | ||
it('should find spottables', testScenario(scenarios.onlySpottables, function () { | ||
it('should find spottables', (0, _utils.testScenario)(scenarios.onlySpottables, function () { | ||
var expected = 5; | ||
var actual = getSpottableDescendants(rootContainerId).length; | ||
var actual = (0, _container16.getSpottableDescendants)(_container16.rootContainerId).length; | ||
@@ -58,5 +60,5 @@ expect(actual).to.equal(expected); | ||
it('should find containers', testScenario(scenarios.onlyContainers, function () { | ||
it('should find containers', (0, _utils.testScenario)(scenarios.onlyContainers, function () { | ||
var expected = 5; | ||
var actual = getSpottableDescendants(rootContainerId).length; | ||
var actual = (0, _container16.getSpottableDescendants)(_container16.rootContainerId).length; | ||
@@ -66,5 +68,5 @@ expect(actual).to.equal(expected); | ||
it('should find spottables and containers', testScenario(scenarios.spottableAndContainers, function () { | ||
it('should find spottables and containers', (0, _utils.testScenario)(scenarios.spottableAndContainers, function () { | ||
var expected = 10; | ||
var actual = getSpottableDescendants(rootContainerId).length; | ||
var actual = (0, _container16.getSpottableDescendants)(_container16.rootContainerId).length; | ||
@@ -74,5 +76,5 @@ expect(actual).to.equal(expected); | ||
it('should only find spottables with non-spottable siblings', testScenario(scenarios.nonSpottableSiblings, function () { | ||
it('should only find spottables with non-spottable siblings', (0, _utils.testScenario)(scenarios.nonSpottableSiblings, function () { | ||
var expected = 5; | ||
var actual = getSpottableDescendants(rootContainerId).length; | ||
var actual = (0, _container16.getSpottableDescendants)(_container16.rootContainerId).length; | ||
@@ -82,5 +84,5 @@ expect(actual).to.equal(expected); | ||
it('should only find top-level containers', testScenario(scenarios.nestedContainers, function () { | ||
it('should only find top-level containers', (0, _utils.testScenario)(scenarios.nestedContainers, function () { | ||
var expected = 1; | ||
var actual = getSpottableDescendants(rootContainerId).length; | ||
var actual = (0, _container16.getSpottableDescendants)(_container16.rootContainerId).length; | ||
@@ -90,5 +92,5 @@ expect(actual).to.equal(expected); | ||
it('should only find top-level containers and spottables', testScenario(scenarios.nestedContainersWithSpottables, function () { | ||
it('should only find top-level containers and spottables', (0, _utils.testScenario)(scenarios.nestedContainersWithSpottables, function () { | ||
var expected = 6; | ||
var actual = getSpottableDescendants(rootContainerId).length; | ||
var actual = (0, _container16.getSpottableDescendants)(_container16.rootContainerId).length; | ||
@@ -98,7 +100,7 @@ expect(actual).to.equal(expected); | ||
it('should not find spottables in sibling containers', testScenario(scenarios.siblingContainers, function () { | ||
configureContainer('first'); | ||
it('should not find spottables in sibling containers', (0, _utils.testScenario)(scenarios.siblingContainers, function () { | ||
(0, _container16.configureContainer)('first'); | ||
var expected = 5; | ||
var actual = getSpottableDescendants('first').length; | ||
var actual = (0, _container16.getSpottableDescendants)('first').length; | ||
@@ -108,7 +110,7 @@ expect(actual).to.equal(expected); | ||
it('should not find spottables in descendant containers', testScenario(scenarios.complexTree, function () { | ||
configureContainer('first-container'); | ||
it('should not find spottables in descendant containers', (0, _utils.testScenario)(scenarios.complexTree, function () { | ||
(0, _container16.configureContainer)('first-container'); | ||
var expected = 3; | ||
var actual = getSpottableDescendants('first-container').length; | ||
var actual = (0, _container16.getSpottableDescendants)('first-container').length; | ||
@@ -118,8 +120,8 @@ expect(actual).to.equal(expected); | ||
it('should not find containers that are disabled', testScenario(scenarios.complexTree, function () { | ||
configureContainer('first-container'); | ||
configureContainer('second-container'); | ||
it('should not find containers that are disabled', (0, _utils.testScenario)(scenarios.complexTree, function () { | ||
(0, _container16.configureContainer)('first-container'); | ||
(0, _container16.configureContainer)('second-container'); | ||
var expected = 3; | ||
var actual = getSpottableDescendants('second-container').length; | ||
var actual = (0, _container16.getSpottableDescendants)('second-container').length; | ||
@@ -129,7 +131,7 @@ expect(actual).to.equal(expected); | ||
it('should not any spottables within a disabled container', testScenario(scenarios.spottablesInDisabledContainer, function () { | ||
configureContainer('container'); | ||
it('should not any spottables within a disabled container', (0, _utils.testScenario)(scenarios.spottablesInDisabledContainer, function () { | ||
(0, _container16.configureContainer)('container'); | ||
var expected = 0; | ||
var actual = getSpottableDescendants('container').length; | ||
var actual = (0, _container16.getSpottableDescendants)('container').length; | ||
@@ -139,8 +141,8 @@ expect(actual).to.equal(expected); | ||
it('should not any spottables within a disabled ancestor container', testScenario(scenarios.spottablesInNestedDisabledContainer, function () { | ||
configureContainer('container'); | ||
configureContainer('child'); | ||
it('should not any spottables within a disabled ancestor container', (0, _utils.testScenario)(scenarios.spottablesInNestedDisabledContainer, function () { | ||
(0, _container16.configureContainer)('container'); | ||
(0, _container16.configureContainer)('child'); | ||
var expected = 0; | ||
var actual = getSpottableDescendants('child').length; | ||
var actual = (0, _container16.getSpottableDescendants)('child').length; | ||
@@ -150,5 +152,5 @@ expect(actual).to.equal(expected); | ||
it('should return spottables and containers in source order', testScenario(scenarios.mixedOrder, function () { | ||
it('should return spottables and containers in source order', (0, _utils.testScenario)(scenarios.mixedOrder, function () { | ||
var expected = ['c1', 's1', 'c2', 's2']; | ||
var actual = getSpottableDescendants(rootContainerId).map(function (n) { | ||
var actual = (0, _container16.getSpottableDescendants)(_container16.rootContainerId).map(function (n) { | ||
return n.getAttribute('name'); | ||
@@ -162,5 +164,5 @@ }); | ||
describe('#getContainersForNode', function () { | ||
it('should return the rootContainerId when no other containers exist', testScenario(scenarios.onlySpottables, function (root) { | ||
var expected = [rootContainerId]; | ||
var actual = getContainersForNode(root.lastChild); | ||
it('should return the rootContainerId when no other containers exist', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) { | ||
var expected = [_container16.rootContainerId]; | ||
var actual = (0, _container16.getContainersForNode)(root.lastChild); | ||
@@ -170,6 +172,6 @@ expect(actual).to.deep.equal(expected); | ||
it('should return all ancestor container ids', testScenario(scenarios.complexTree, function (root) { | ||
it('should return all ancestor container ids', (0, _utils.testScenario)(scenarios.complexTree, function (root) { | ||
var childOfThird = root.querySelector('#child-of-third'); | ||
var expected = [rootContainerId, 'first-container', 'second-container', 'third-container']; | ||
var actual = getContainersForNode(childOfThird); | ||
var expected = [_container16.rootContainerId, 'first-container', 'second-container', 'third-container']; | ||
var actual = (0, _container16.getContainersForNode)(childOfThird); | ||
@@ -179,6 +181,6 @@ expect(actual).to.deep.equal(expected); | ||
it('should return immediate container id as last in list', testScenario(scenarios.complexTree, function (root) { | ||
it('should return immediate container id as last in list', (0, _utils.testScenario)(scenarios.complexTree, function (root) { | ||
var childOfThird = root.querySelector('#child-of-third'); | ||
var expected = 'third-container'; | ||
var actual = getContainersForNode(childOfThird).pop(); | ||
var actual = (0, _container16.getContainersForNode)(childOfThird).pop(); | ||
@@ -191,7 +193,7 @@ expect(actual).to.deep.equal(expected); | ||
beforeEach(function () { | ||
configureContainer('test-container'); | ||
(0, _container16.configureContainer)('test-container'); | ||
}); | ||
afterEach(function () { | ||
removeContainer('test-container'); | ||
(0, _container16.removeContainer)('test-container'); | ||
}); | ||
@@ -201,6 +203,6 @@ | ||
var div = document.createElement('div'); | ||
div.setAttribute(containerAttribute, 'my-container'); | ||
div.setAttribute(_container16.containerAttribute, 'my-container'); | ||
var expected = true; | ||
var actual = isContainer(div); | ||
var actual = (0, _container16.isContainer)(div); | ||
@@ -214,3 +216,3 @@ expect(actual).to.equal(expected); | ||
var expected = false; | ||
var actual = isContainer(div); | ||
var actual = (0, _container16.isContainer)(div); | ||
@@ -222,3 +224,3 @@ expect(actual).to.equal(expected); | ||
var expected = true; | ||
var actual = isContainer('test-container'); | ||
var actual = (0, _container16.isContainer)('test-container'); | ||
@@ -230,3 +232,3 @@ expect(actual).to.equal(expected); | ||
var expected = false; | ||
var actual = isContainer('unconfigured-container'); | ||
var actual = (0, _container16.isContainer)('unconfigured-container'); | ||
@@ -241,4 +243,4 @@ expect(actual).to.equal(expected); | ||
it('should return the last focused element when enterTo is "last-focused"', testScenario(scenarios.containerWithDefaultAndLastFocused, function (root) { | ||
configureContainer('container', { | ||
it('should return the last focused element when enterTo is "last-focused"', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function (root) { | ||
(0, _container16.configureContainer)('container', { | ||
enterTo: 'last-focused', | ||
@@ -248,6 +250,6 @@ defaultElement: '.spottable-default' | ||
setContainerLastFocusedElement(root.querySelector('#lastFocused'), ['container']); | ||
(0, _container16.setContainerLastFocusedElement)(root.querySelector('#lastFocused'), ['container']); | ||
var expected = 'lastFocused'; | ||
var actual = getContainerFocusTarget('container').id; | ||
var actual = (0, _container16.getContainerFocusTarget)('container').id; | ||
@@ -257,4 +259,4 @@ expect(actual).to.equal(expected); | ||
it('should return the default spottable element when enterTo is "last-focused" but no element has been focused', testScenario(scenarios.containerWithDefaultAndLastFocused, function () { | ||
configureContainer('container', { | ||
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, _container16.configureContainer)('container', { | ||
enterTo: 'last-focused', | ||
@@ -265,3 +267,3 @@ defaultElement: '.spottable-default' | ||
var expected = 'spottableDefault'; | ||
var actual = getContainerFocusTarget('container').id; | ||
var actual = (0, _container16.getContainerFocusTarget)('container').id; | ||
@@ -271,4 +273,4 @@ expect(actual).to.equal(expected); | ||
it('should return the first spottable element when enterTo is "last-focused" and defaultElement is not configured', testScenario(scenarios.containerWithDefaultAndLastFocused, function () { | ||
configureContainer('container', { | ||
it('should return the first spottable element when enterTo is "last-focused" and defaultElement is not configured', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () { | ||
(0, _container16.configureContainer)('container', { | ||
enterTo: 'last-focused' | ||
@@ -278,3 +280,3 @@ }); | ||
var expected = 'firstSpottable'; | ||
var actual = getContainerFocusTarget('container').id; | ||
var actual = (0, _container16.getContainerFocusTarget)('container').id; | ||
@@ -284,4 +286,4 @@ expect(actual).to.equal(expected); | ||
it('should return the first spottable element when enterTo is "last-focused" and defaultElement is not found', testScenario(scenarios.containerWithDefaultAndLastFocused, function () { | ||
configureContainer('container', { | ||
it('should return the first spottable element when enterTo is "last-focused" and defaultElement is not found', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () { | ||
(0, _container16.configureContainer)('container', { | ||
enterTo: 'last-focused', | ||
@@ -293,3 +295,3 @@ // configured, but not found | ||
var expected = 'firstSpottable'; | ||
var actual = getContainerFocusTarget('container').id; | ||
var actual = (0, _container16.getContainerFocusTarget)('container').id; | ||
@@ -299,4 +301,4 @@ expect(actual).to.equal(expected); | ||
it('should return the default spottable element when enterTo is "default-element"', testScenario(scenarios.containerWithDefaultAndLastFocused, function () { | ||
configureContainer('container', { | ||
it('should return the default spottable element when enterTo is "default-element"', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () { | ||
(0, _container16.configureContainer)('container', { | ||
enterTo: 'default-element', | ||
@@ -307,3 +309,3 @@ defaultElement: '.spottable-default' | ||
var expected = 'spottableDefault'; | ||
var actual = getContainerFocusTarget('container').id; | ||
var actual = (0, _container16.getContainerFocusTarget)('container').id; | ||
@@ -313,4 +315,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', testScenario(scenarios.containerWithDefaultAndLastFocused, function () { | ||
configureContainer('container', { | ||
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, _container16.configureContainer)('container', { | ||
enterTo: 'default-element', | ||
@@ -321,3 +323,3 @@ defaultElement: ['.does-not-exist', '.spottable-default'] | ||
var expected = 'spottableDefault'; | ||
var actual = getContainerFocusTarget('container').id; | ||
var actual = (0, _container16.getContainerFocusTarget)('container').id; | ||
@@ -329,4 +331,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', testScenario(scenarios.containerWithDefaultAndLastFocused, function (root) { | ||
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', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function (root) { | ||
(0, _container16.configureContainer)('container', { | ||
enterTo: 'default-element', | ||
@@ -337,3 +339,3 @@ defaultElement: [root.querySelector('#lastFocused'), '.spottable-default'] | ||
var expected = 'lastFocused'; | ||
var actual = getContainerFocusTarget('container').id; | ||
var actual = (0, _container16.getContainerFocusTarget)('container').id; | ||
@@ -343,4 +345,4 @@ expect(actual).to.equal(expected); | ||
it('should return the first spottable element when enterTo is "default-element" but defaultElement is not configured', testScenario(scenarios.containerWithDefaultAndLastFocused, function () { | ||
configureContainer('container', { | ||
it('should return the first spottable element when enterTo is "default-element" but defaultElement is not configured', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () { | ||
(0, _container16.configureContainer)('container', { | ||
enterTo: 'default-element' | ||
@@ -350,3 +352,3 @@ }); | ||
var expected = 'firstSpottable'; | ||
var actual = getContainerFocusTarget('container').id; | ||
var actual = (0, _container16.getContainerFocusTarget)('container').id; | ||
@@ -356,4 +358,4 @@ expect(actual).to.equal(expected); | ||
it('should return the first spottable element when enterTo is "default-element" but defaultElement is not found', testScenario(scenarios.containerWithDefaultAndLastFocused, function () { | ||
configureContainer('container', { | ||
it('should return the first spottable element when enterTo is "default-element" but defaultElement is not found', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () { | ||
(0, _container16.configureContainer)('container', { | ||
enterTo: 'default-element', | ||
@@ -364,3 +366,3 @@ defaultElement: '[data-default-spottable]' | ||
var expected = 'firstSpottable'; | ||
var actual = getContainerFocusTarget('container').id; | ||
var actual = (0, _container16.getContainerFocusTarget)('container').id; | ||
@@ -370,11 +372,11 @@ expect(actual).to.equal(expected); | ||
it('should return the default element when enterTo is "default-element" and defaultElement is within a subcontainer', testScenario(scenarios.complexTree, function () { | ||
configureContainer('first-container', { | ||
it('should return the default element when enterTo is "default-element" and defaultElement is within a subcontainer', (0, _utils.testScenario)(scenarios.complexTree, function () { | ||
(0, _container16.configureContainer)('first-container', { | ||
enterTo: 'default-element', | ||
defaultElement: '[' + containerAttribute + '=\'second-container\'] > .spottable' | ||
defaultElement: '[' + _container16.containerAttribute + '=\'second-container\'] > .spottable' | ||
}); | ||
configureContainer('second-container'); | ||
(0, _container16.configureContainer)('second-container'); | ||
var expected = 'second-container'; | ||
var actual = getContainerFocusTarget('first-container').parentNode.dataset.containerId; | ||
var actual = (0, _container16.getContainerFocusTarget)('first-container').parentNode.dataset.containerId; | ||
@@ -384,11 +386,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', testScenario(scenarios.complexTree, function () { | ||
configureContainer('second-container', { | ||
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, _container16.configureContainer)('second-container', { | ||
enterTo: 'default-element', | ||
defaultElement: '[' + containerAttribute + '=\'third-container\'] > .spottable' | ||
defaultElement: '[' + _container16.containerAttribute + '=\'third-container\'] > .spottable' | ||
}); | ||
configureContainer('third-container'); | ||
(0, _container16.configureContainer)('third-container'); | ||
var expected = 'secondContainerFirstSpottable'; | ||
var actual = getContainerFocusTarget('second-container').id; | ||
var actual = (0, _container16.getContainerFocusTarget)('second-container').id; | ||
@@ -398,7 +400,7 @@ expect(actual).to.equal(expected); | ||
it('should return the first spottable element when enterTo is not configured', testScenario(scenarios.containerWithDefaultAndLastFocused, function () { | ||
configureContainer('container'); | ||
it('should return the first spottable element when enterTo is not configured', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () { | ||
(0, _container16.configureContainer)('container'); | ||
var expected = 'firstSpottable'; | ||
var actual = getContainerFocusTarget('container').id; | ||
var actual = (0, _container16.getContainerFocusTarget)('container').id; | ||
@@ -408,4 +410,4 @@ expect(actual).to.equal(expected); | ||
it('should return the default element when enterTo is not configured and defaultElement is configured', testScenario(scenarios.containerWithDefaultAndLastFocused, function () { | ||
configureContainer('container', { | ||
it('should return the default element when enterTo is not configured and defaultElement is configured', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () { | ||
(0, _container16.configureContainer)('container', { | ||
defaultElement: '.spottable-default' | ||
@@ -415,3 +417,3 @@ }); | ||
var expected = 'spottableDefault'; | ||
var actual = getContainerFocusTarget('container').id; | ||
var actual = (0, _container16.getContainerFocusTarget)('container').id; | ||
@@ -421,8 +423,8 @@ expect(actual).to.equal(expected); | ||
it('should cascade search into child containers with', testScenario(scenarios.nestedContainersWithDefaultAndLastFocused, function (root) { | ||
configureContainer('container', { | ||
it('should cascade search into child containers with', (0, _utils.testScenario)(scenarios.nestedContainersWithDefaultAndLastFocused, function (root) { | ||
(0, _container16.configureContainer)('container', { | ||
defaultElement: '.spottable-default' | ||
}); | ||
configureContainer('child', { | ||
(0, _container16.configureContainer)('child', { | ||
enterTo: 'last-focused', | ||
@@ -432,6 +434,6 @@ defaultElement: '.spottable-default' | ||
setContainerLastFocusedElement(root.querySelector('#lastChildFocused'), [rootContainerId, 'container', 'child']); | ||
(0, _container16.setContainerLastFocusedElement)(root.querySelector('#lastChildFocused'), [_container16.rootContainerId, 'container', 'child']); | ||
var expected = 'lastChildFocused'; | ||
var actual = getContainerFocusTarget('container').id; | ||
var actual = (0, _container16.getContainerFocusTarget)('container').id; | ||
@@ -441,4 +443,4 @@ expect(actual).to.equal(expected); | ||
it('should cascade search into child containers when multiple containers have enterTo configured', testScenario(scenarios.nestedContainersWithDefaultAndLastFocused, function (root) { | ||
configureContainer('container', { | ||
it('should cascade search into child containers when multiple containers have enterTo configured', (0, _utils.testScenario)(scenarios.nestedContainersWithDefaultAndLastFocused, function (root) { | ||
(0, _container16.configureContainer)('container', { | ||
enterTo: 'last-focused', | ||
@@ -448,3 +450,3 @@ defaultElement: '.spottable-default' | ||
configureContainer('child', { | ||
(0, _container16.configureContainer)('child', { | ||
enterTo: 'last-focused', | ||
@@ -454,6 +456,6 @@ defaultElement: '.spottable-default' | ||
setContainerLastFocusedElement(root.querySelector('#lastChildFocused'), [rootContainerId, 'container', 'child']); | ||
(0, _container16.setContainerLastFocusedElement)(root.querySelector('#lastChildFocused'), [_container16.rootContainerId, 'container', 'child']); | ||
var expected = 'lastChildFocused'; | ||
var actual = getContainerFocusTarget('container').id; | ||
var actual = (0, _container16.getContainerFocusTarget)('container').id; | ||
@@ -463,8 +465,8 @@ expect(actual).to.equal(expected); | ||
it('should skip empty subcontainers', testScenario(scenarios.emptySubcontainer, function () { | ||
configureContainer('container'); | ||
configureContainer('subcontainer'); | ||
it('should skip empty subcontainers', (0, _utils.testScenario)(scenarios.emptySubcontainer, function () { | ||
(0, _container16.configureContainer)('container'); | ||
(0, _container16.configureContainer)('subcontainer'); | ||
var expected = 'afterSubcontainer'; | ||
var actual = getContainerFocusTarget('container').id; | ||
var actual = (0, _container16.getContainerFocusTarget)('container').id; | ||
@@ -481,3 +483,3 @@ expect(actual).to.equal(expected); | ||
var expected = false; | ||
var actual = isNavigable(null, rootContainerId); | ||
var actual = (0, _container16.isNavigable)(null, _container16.rootContainerId); | ||
@@ -487,5 +489,5 @@ expect(actual).to.equal(expected); | ||
it('should return true for any node when not verifying selector and without a navigableFilter', testScenario(scenarios.nonSpottableSiblings, function (root) { | ||
it('should return true for any node when not verifying selector and without a navigableFilter', (0, _utils.testScenario)(scenarios.nonSpottableSiblings, function (root) { | ||
var expected = true; | ||
var actual = isNavigable(root.querySelector('.other'), rootContainerId); | ||
var actual = (0, _container16.isNavigable)(root.querySelector('.other'), _container16.rootContainerId); | ||
@@ -495,5 +497,5 @@ expect(actual).to.equal(expected); | ||
it('should return true for spottable children when verifying selector', testScenario(scenarios.onlySpottables, function (root) { | ||
it('should return true for spottable children when verifying selector', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) { | ||
var expected = true; | ||
var actual = isNavigable(root.querySelector('.spottable'), rootContainerId, true); | ||
var actual = (0, _container16.isNavigable)(root.querySelector('.spottable'), _container16.rootContainerId, true); | ||
@@ -503,5 +505,5 @@ expect(actual).to.equal(expected); | ||
it('should return true for spottable children when verifying selector', testScenario(scenarios.onlySpottables, function (root) { | ||
it('should return true for spottable children when verifying selector', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) { | ||
var expected = true; | ||
var actual = isNavigable(root.querySelector('.spottable'), rootContainerId, true); | ||
var actual = (0, _container16.isNavigable)(root.querySelector('.spottable'), _container16.rootContainerId, true); | ||
@@ -511,5 +513,5 @@ expect(actual).to.equal(expected); | ||
it('should return true for containers', testScenario(scenarios.onlyContainers, function (root) { | ||
it('should return true for containers', (0, _utils.testScenario)(scenarios.onlyContainers, function (root) { | ||
var expected = true; | ||
var actual = isNavigable(root.querySelector('[' + containerAttribute + ']'), rootContainerId, true); | ||
var actual = (0, _container16.isNavigable)(root.querySelector('[' + _container16.containerAttribute + ']'), _container16.rootContainerId, true); | ||
@@ -519,7 +521,7 @@ expect(actual).to.equal(expected); | ||
it('should filter the node with navigableFilter', testScenario(scenarios.spottableAndContainers, function (root) { | ||
configureContainer(rootContainerId, { | ||
it('should filter the node with navigableFilter', (0, _utils.testScenario)(scenarios.spottableAndContainers, function (root) { | ||
(0, _container16.configureContainer)(_container16.rootContainerId, { | ||
// test filter which makes containers non-navigable | ||
navigableFilter: function navigableFilter(n) { | ||
return !isContainer(n); | ||
return !(0, _container16.isContainer)(n); | ||
} | ||
@@ -529,3 +531,3 @@ }); | ||
var expected = false; | ||
var actual = isNavigable(root.querySelector('[' + containerAttribute + ']'), rootContainerId, true); | ||
var actual = (0, _container16.isNavigable)(root.querySelector('[' + _container16.containerAttribute + ']'), _container16.rootContainerId, true); | ||
@@ -540,9 +542,9 @@ expect(actual).to.equal(expected); | ||
it('should update lastFocusedElement for a single container', testScenario(scenarios.onlySpottables, function (root) { | ||
it('should update lastFocusedElement for a single container', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) { | ||
var item = root.querySelectorAll('.spottable').item(3); | ||
setContainerLastFocusedElement(item, getContainersForNode(item)); | ||
(0, _container16.setContainerLastFocusedElement)(item, (0, _container16.getContainersForNode)(item)); | ||
var expected = item; | ||
var actual = getContainerConfig(rootContainerId).lastFocusedElement; | ||
var actual = (0, _container16.getContainerConfig)(_container16.rootContainerId).lastFocusedElement; | ||
@@ -552,12 +554,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', testScenario(scenarios.complexTree, function (root) { | ||
var item = root.querySelectorAll('[' + containerAttribute + '=\'first-container\'] .spottable').item(0); | ||
configureContainer('first-container', { | ||
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('[' + _container16.containerAttribute + '=\'first-container\'] .spottable').item(0); | ||
(0, _container16.configureContainer)('first-container', { | ||
enterTo: 'last-focused' | ||
}); | ||
setContainerLastFocusedElement(item, getContainersForNode(item)); | ||
(0, _container16.setContainerLastFocusedElement)(item, (0, _container16.getContainersForNode)(item)); | ||
var expected = 'first-container'; | ||
var actual = getContainerConfig(rootContainerId).lastFocusedElement; | ||
var actual = (0, _container16.getContainerConfig)(_container16.rootContainerId).lastFocusedElement; | ||
@@ -567,9 +569,9 @@ expect(actual).to.equal(expected); | ||
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); | ||
it('should ignore sub-containers that does not have enterTo configured', (0, _utils.testScenario)(scenarios.complexTree, function (root) { | ||
var item = root.querySelectorAll('[' + _container16.containerAttribute + '=\'second-container\'] .spottable').item(0); | ||
setContainerLastFocusedElement(item, getContainersForNode(item)); | ||
(0, _container16.setContainerLastFocusedElement)(item, (0, _container16.getContainersForNode)(item)); | ||
var expected = item; | ||
var actual = getContainerConfig(rootContainerId).lastFocusedElement; | ||
var actual = (0, _container16.getContainerConfig)(_container16.rootContainerId).lastFocusedElement; | ||
@@ -579,12 +581,12 @@ expect(actual).to.equal(expected); | ||
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', { | ||
it('should update lastFocusedElement to the first sub-container that has enterTo configured', (0, _utils.testScenario)(scenarios.complexTree, function (root) { | ||
var item = root.querySelectorAll('[' + _container16.containerAttribute + '=\'second-container\'] .spottable').item(0); | ||
(0, _container16.configureContainer)('second-container', { | ||
enterTo: 'last-focused' | ||
}); | ||
setContainerLastFocusedElement(item, getContainersForNode(item)); | ||
(0, _container16.setContainerLastFocusedElement)(item, (0, _container16.getContainersForNode)(item)); | ||
var expected = 'second-container'; | ||
var actual = getContainerConfig(rootContainerId).lastFocusedElement; | ||
var actual = (0, _container16.getContainerConfig)(_container16.rootContainerId).lastFocusedElement; | ||
@@ -599,11 +601,11 @@ expect(actual).to.equal(expected); | ||
it('should return element when last focused is not within a subcontainer with enterTo', testScenario(scenarios.onlySpottables, function (root) { | ||
it('should return element when last focused is not within a subcontainer with enterTo', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) { | ||
var index = 3; | ||
var item = root.querySelectorAll('.spottable').item(index); | ||
setContainerLastFocusedElement(item, getContainersForNode(item)); | ||
(0, _container16.setContainerLastFocusedElement)(item, (0, _container16.getContainersForNode)(item)); | ||
unmountContainer(rootContainerId); | ||
(0, _container16.unmountContainer)(_container16.rootContainerId); | ||
var expected = true; | ||
var actual = getContainerConfig(rootContainerId).lastFocusedKey.element; | ||
var actual = (0, _container16.getContainerConfig)(_container16.rootContainerId).lastFocusedKey.element; | ||
@@ -613,13 +615,13 @@ expect(actual).to.equal(expected); | ||
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', { | ||
it('should return container when last focused is within a subcontainer with enterTo', (0, _utils.testScenario)(scenarios.complexTree, function (root) { | ||
var item = root.querySelectorAll('[' + _container16.containerAttribute + '="first-container"] .spottable').item(1); | ||
(0, _container16.configureContainer)('first-container', { | ||
enterTo: 'last-focused' | ||
}); | ||
setContainerLastFocusedElement(item, getContainersForNode(item)); | ||
(0, _container16.setContainerLastFocusedElement)(item, (0, _container16.getContainersForNode)(item)); | ||
unmountContainer(rootContainerId); | ||
(0, _container16.unmountContainer)(_container16.rootContainerId); | ||
var expected = true; | ||
var actual = getContainerConfig(rootContainerId).lastFocusedKey.container; | ||
var actual = (0, _container16.getContainerConfig)(_container16.rootContainerId).lastFocusedKey.container; | ||
@@ -629,11 +631,11 @@ expect(actual).to.equal(expected); | ||
it('should save the index of the node when lastFocusedPersist is undefined', testScenario(scenarios.onlySpottables, function (root) { | ||
it('should save the index of the node when lastFocusedPersist is undefined', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) { | ||
var index = 3; | ||
var item = root.querySelectorAll('.spottable').item(index); | ||
setContainerLastFocusedElement(item, getContainersForNode(item)); | ||
(0, _container16.setContainerLastFocusedElement)(item, (0, _container16.getContainersForNode)(item)); | ||
unmountContainer(rootContainerId); | ||
(0, _container16.unmountContainer)(_container16.rootContainerId); | ||
var expected = index; | ||
var actual = getContainerConfig(rootContainerId).lastFocusedKey.key; | ||
var actual = (0, _container16.getContainerConfig)(_container16.rootContainerId).lastFocusedKey.key; | ||
@@ -643,6 +645,6 @@ expect(actual).to.equal(expected); | ||
it('should save a custom key for container-configured lastFocusedPersist', testScenario(scenarios.onlySpottables, function (root) { | ||
it('should save a custom key for container-configured lastFocusedPersist', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) { | ||
var index = 3; | ||
var item = root.querySelectorAll('.spottable').item(3); | ||
configureContainer(rootContainerId, { | ||
(0, _container16.configureContainer)(_container16.rootContainerId, { | ||
lastFocusedPersist: function lastFocusedPersist(n, all) { | ||
@@ -655,8 +657,8 @@ return { | ||
}); | ||
setContainerLastFocusedElement(item, getContainersForNode(item)); | ||
(0, _container16.setContainerLastFocusedElement)(item, (0, _container16.getContainersForNode)(item)); | ||
unmountContainer(rootContainerId); | ||
(0, _container16.unmountContainer)(_container16.rootContainerId); | ||
var expected = 'item-' + index; | ||
var actual = getContainerConfig(rootContainerId).lastFocusedKey.key; | ||
var actual = (0, _container16.getContainerConfig)(_container16.rootContainerId).lastFocusedKey.key; | ||
@@ -666,13 +668,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', testScenario(scenarios.complexTree, function (root) { | ||
var item = root.querySelectorAll('[' + containerAttribute + '="first-container"] .spottable').item(1); | ||
configureContainer('first-container', { | ||
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('[' + _container16.containerAttribute + '="first-container"] .spottable').item(1); | ||
(0, _container16.configureContainer)('first-container', { | ||
enterTo: 'last-focused' | ||
}); | ||
setContainerLastFocusedElement(item, getContainersForNode(item)); | ||
(0, _container16.setContainerLastFocusedElement)(item, (0, _container16.getContainersForNode)(item)); | ||
unmountContainer(rootContainerId); | ||
(0, _container16.unmountContainer)(_container16.rootContainerId); | ||
var expected = 'first-container'; | ||
var actual = getContainerConfig(rootContainerId).lastFocusedKey.key; | ||
var actual = (0, _container16.getContainerConfig)(_container16.rootContainerId).lastFocusedKey.key; | ||
@@ -682,13 +684,23 @@ expect(actual).to.equal(expected); | ||
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)); | ||
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('[' + _container16.containerAttribute + '="second-container"] .spottable').item(1); | ||
(0, _container16.setContainerLastFocusedElement)(item, (0, _container16.getContainersForNode)(item)); | ||
unmountContainer(rootContainerId); | ||
(0, _container16.unmountContainer)(_container16.rootContainerId); | ||
var expected = 4; | ||
var actual = getContainerConfig(rootContainerId).lastFocusedKey.key; | ||
var actual = (0, _container16.getContainerConfig)(_container16.rootContainerId).lastFocusedKey.key; | ||
expect(actual).to.equal(expected); | ||
})); | ||
it('should mark the container inactive', (0, _utils.testScenario)(scenarios.complexTree, function () { | ||
(0, _container16.addContainer)('first-container'); | ||
(0, _container16.unmountContainer)('first-container'); | ||
var expected = false; | ||
var actual = (0, _container16.getContainerConfig)('first-container').active; | ||
expect(actual).to.equal(expected); | ||
})); | ||
}); | ||
@@ -700,4 +712,4 @@ | ||
it('should be nearest restrict="self-only" container to current if target is not within it', testScenario(scenarios.complexTree, function (root) { | ||
configureContainer('first-container', { | ||
it('should be nearest restrict="self-only" container to current if target is not within it', (0, _utils.testScenario)(scenarios.complexTree, function (root) { | ||
(0, _container16.configureContainer)('first-container', { | ||
restrict: 'self-only' | ||
@@ -708,6 +720,6 @@ }); | ||
setLastContainerFromTarget(current, target); | ||
(0, _container16.setLastContainerFromTarget)(current, target); | ||
var expected = 'first-container'; | ||
var actual = getLastContainer(); | ||
var actual = (0, _container16.getLastContainer)(); | ||
@@ -717,7 +729,7 @@ expect(actual).to.equal(expected); | ||
it('should be use nearest container to target if within current container', testScenario(scenarios.complexTree, function (root) { | ||
configureContainer('first-container', { | ||
it('should be use nearest container to target if within current container', (0, _utils.testScenario)(scenarios.complexTree, function (root) { | ||
(0, _container16.configureContainer)('first-container', { | ||
restrict: 'none' | ||
}); | ||
configureContainer('second-container', { | ||
(0, _container16.configureContainer)('second-container', { | ||
restrict: 'none' | ||
@@ -728,6 +740,6 @@ }); | ||
setLastContainerFromTarget(current, target); | ||
(0, _container16.setLastContainerFromTarget)(current, target); | ||
var expected = 'second-container'; | ||
var actual = getLastContainer(); | ||
var actual = (0, _container16.getLastContainer)(); | ||
@@ -737,7 +749,7 @@ expect(actual).to.equal(expected); | ||
it('should target container if it is restrict="self-only" and contains current container', testScenario(scenarios.complexTree, function (root) { | ||
configureContainer('first-container', { | ||
it('should target container if it is restrict="self-only" and contains current container', (0, _utils.testScenario)(scenarios.complexTree, function (root) { | ||
(0, _container16.configureContainer)('first-container', { | ||
restrict: 'self-only' | ||
}); | ||
configureContainer('second-container', { | ||
(0, _container16.configureContainer)('second-container', { | ||
restrict: 'none' | ||
@@ -748,6 +760,6 @@ }); | ||
setLastContainerFromTarget(current, target); | ||
(0, _container16.setLastContainerFromTarget)(current, target); | ||
var expected = 'first-container'; | ||
var actual = getLastContainer(); | ||
var actual = (0, _container16.getLastContainer)(); | ||
@@ -757,2 +769,74 @@ expect(actual).to.equal(expected); | ||
}); | ||
describe('#getDefaultContainer', function () { | ||
beforeEach(setupContainers); | ||
afterEach(teardownContainers); | ||
it('should return an empty string when container is inactive', (0, _utils.testScenario)(scenarios.complexTree, function () { | ||
(0, _container16.unmountContainer)(_container16.rootContainerId); | ||
var expected = ''; | ||
var actual = (0, _container16.getDefaultContainer)(); | ||
expect(actual).to.equal(expected); | ||
})); | ||
}); | ||
describe('#getLastContainer', function () { | ||
beforeEach(setupContainers); | ||
afterEach(teardownContainers); | ||
it('should return an empty string when container is inactive', (0, _utils.testScenario)(scenarios.complexTree, function () { | ||
(0, _container16.addContainer)('first-container'); | ||
(0, _container16.setLastContainer)('first-container'); | ||
(0, _container16.unmountContainer)('first-container'); | ||
var expected = ''; | ||
var actual = (0, _container16.getLastContainer)(); | ||
expect(actual).to.equal(expected); | ||
})); | ||
}); | ||
describe('#getAllContainerIds', function () { | ||
beforeEach(setupContainers); | ||
afterEach(teardownContainers); | ||
it('should not include inacive containers', (0, _utils.testScenario)(scenarios.onlyContainers, function (root) { | ||
var containerId = root.querySelector('[data-container-id]').dataset.containerId; | ||
(0, _container16.addContainer)(containerId); | ||
(0, _container16.unmountContainer)(containerId); | ||
var expected = -1; | ||
var actual = (0, _container16.getAllContainerIds)().indexOf(containerId); | ||
expect(actual).to.equal(expected); | ||
})); | ||
}); | ||
describe('#getContainerLastFocusedElement', function () { | ||
beforeEach(setupContainers); | ||
afterEach(teardownContainers); | ||
it('should return null for an invalid container', (0, _utils.testScenario)(scenarios.onlySpottables, function () { | ||
var expected = null; | ||
var actual = (0, _container16.getContainerLastFocusedElement)('does-not-exist'); | ||
expect(actual).to.equal(expected); | ||
})); | ||
}); | ||
describe('#getContainerDefaultElement', function () { | ||
beforeEach(setupContainers); | ||
afterEach(teardownContainers); | ||
it('should return null for an invalid container', (0, _utils.testScenario)(scenarios.onlySpottables, function () { | ||
var expected = null; | ||
var actual = (0, _container16.getContainerDefaultElement)('does-not-exist'); | ||
expect(actual).to.equal(expected); | ||
})); | ||
}); | ||
}); |
@@ -0,5 +1,11 @@ | ||
'use strict'; | ||
var _navigate = require('../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); } } | ||
import navigate from '../navigate'; | ||
// loose copy from utils/getRect to fabricate a rect for navigation | ||
@@ -33,3 +39,3 @@ function getRect(top, left, height, width, elem) { | ||
var expected = 'above'; | ||
var actual = navigate(targetRect, 'up', rects, {}); | ||
var actual = (0, _navigate2.default)(targetRect, 'up', rects, {}); | ||
@@ -46,3 +52,3 @@ expect(actual).to.equal(expected); | ||
var expected = 'left'; | ||
var actual = navigate(targetRect, 'left', rects, {}); | ||
var actual = (0, _navigate2.default)(targetRect, 'left', rects, {}); | ||
@@ -59,3 +65,3 @@ expect(actual).to.equal(expected); | ||
var expected = 'below'; | ||
var actual = navigate(targetRect, 'down', rects, {}); | ||
var actual = (0, _navigate2.default)(targetRect, 'down', rects, {}); | ||
@@ -72,3 +78,3 @@ expect(actual).to.equal(expected); | ||
var expected = 'right'; | ||
var actual = navigate(targetRect, 'right', rects, {}); | ||
var actual = (0, _navigate2.default)(targetRect, 'right', rects, {}); | ||
@@ -85,10 +91,10 @@ expect(actual).to.equal(expected); | ||
expect(navigate(targetRect, 'up', rects, {})).to.equal('under'); | ||
expect((0, _navigate2.default)(targetRect, 'up', rects, {})).to.equal('under'); | ||
expect(navigate(targetRect, 'down', rects, {})).to.equal('below'); | ||
expect((0, _navigate2.default)(targetRect, 'down', rects, {})).to.equal('below'); | ||
expect(navigate(targetRect, 'left', rects, {})).to.equal('left'); | ||
expect((0, _navigate2.default)(targetRect, 'left', rects, {})).to.equal('left'); | ||
expect(navigate(targetRect, 'right', rects, {})).to.equal('right'); | ||
expect((0, _navigate2.default)(targetRect, 'right', rects, {})).to.equal('right'); | ||
}); | ||
}); |
@@ -1,8 +0,10 @@ | ||
import { addAll, removeAll } from '@enact/core/keymap'; | ||
'use strict'; | ||
import { getLastPointerPosition, getPointerMode, notifyKeyDown, notifyPointerMove, setPointerMode, updatePointerPosition } from '../pointer'; | ||
var _keymap = require('@enact/core/keymap'); | ||
var _pointer = require('../pointer'); | ||
var reset = function reset() { | ||
updatePointerPosition(null, null); | ||
setPointerMode(true); | ||
(0, _pointer.updatePointerPosition)(null, null); | ||
(0, _pointer.setPointerMode)(true); | ||
}; | ||
@@ -16,3 +18,3 @@ | ||
var expected = ['x', 'y']; | ||
var actual = Object.keys(getLastPointerPosition()); | ||
var actual = Object.keys((0, _pointer.getLastPointerPosition)()); | ||
@@ -34,6 +36,6 @@ expect(actual).to.deep.equal(expected); | ||
before(function () { | ||
return addAll(keyMap); | ||
return (0, _keymap.addAll)(keyMap); | ||
}); | ||
after(function () { | ||
return removeAll(keyMap); | ||
return (0, _keymap.removeAll)(keyMap); | ||
}); | ||
@@ -43,3 +45,3 @@ | ||
// establish a consistent pointer mode state for each test | ||
setPointerMode(false); | ||
(0, _pointer.setPointerMode)(false); | ||
}); | ||
@@ -49,3 +51,3 @@ | ||
var expected = true; | ||
var actual = notifyKeyDown(keyMap.pointerHide); | ||
var actual = (0, _pointer.notifyKeyDown)(keyMap.pointerHide); | ||
@@ -57,3 +59,3 @@ expect(actual).to.equal(expected); | ||
var expected = true; | ||
var actual = notifyKeyDown(keyMap.pointerShow); | ||
var actual = (0, _pointer.notifyKeyDown)(keyMap.pointerShow); | ||
@@ -64,6 +66,6 @@ expect(actual).to.equal(expected); | ||
it('should enable pointer mode for pointer show key events', function () { | ||
notifyKeyDown(keyMap.pointerShow); | ||
(0, _pointer.notifyKeyDown)(keyMap.pointerShow); | ||
var expected = true; | ||
var actual = getPointerMode(); | ||
var actual = (0, _pointer.getPointerMode)(); | ||
@@ -74,6 +76,6 @@ expect(actual).to.equal(expected); | ||
it('should disable pointer mode for pointer show key events', function (done) { | ||
setPointerMode(true); | ||
notifyKeyDown(keyMap.pointerHide, function () { | ||
(0, _pointer.setPointerMode)(true); | ||
(0, _pointer.notifyKeyDown)(keyMap.pointerHide, function () { | ||
var expected = false; | ||
var actual = getPointerMode(); | ||
var actual = (0, _pointer.getPointerMode)(); | ||
@@ -87,7 +89,7 @@ expect(actual).to.equal(expected); | ||
it('should disable pointer mode for non-pointer key events', function () { | ||
setPointerMode(true); | ||
notifyKeyDown(12); | ||
(0, _pointer.setPointerMode)(true); | ||
(0, _pointer.notifyKeyDown)(12); | ||
var expected = false; | ||
var actual = getPointerMode(); | ||
var actual = (0, _pointer.getPointerMode)(); | ||
@@ -102,6 +104,6 @@ expect(actual).to.equal(expected); | ||
notifyPointerMove(null, null, x, null); | ||
(0, _pointer.notifyPointerMove)(null, null, x, null); | ||
var expected = 20; | ||
var actual = getLastPointerPosition().x; | ||
var actual = (0, _pointer.getLastPointerPosition)().x; | ||
@@ -114,6 +116,6 @@ expect(actual).to.equal(expected); | ||
notifyPointerMove(null, null, null, y); | ||
(0, _pointer.notifyPointerMove)(null, null, null, y); | ||
var expected = 20; | ||
var actual = getLastPointerPosition().y; | ||
var actual = (0, _pointer.getLastPointerPosition)().y; | ||
@@ -124,7 +126,7 @@ expect(actual).to.equal(expected); | ||
it('should enable pointer mode if the pointer positionchanges', function () { | ||
setPointerMode(false); | ||
notifyPointerMove(null, null, 5, 5); | ||
(0, _pointer.setPointerMode)(false); | ||
(0, _pointer.notifyPointerMove)(null, null, 5, 5); | ||
var expected = true; | ||
var actual = getPointerMode(); | ||
var actual = (0, _pointer.getPointerMode)(); | ||
@@ -135,6 +137,6 @@ expect(actual).to.equal(expected); | ||
it('should return false if the pointer has not moved', function () { | ||
notifyPointerMove(null, null, 5, 5); | ||
(0, _pointer.notifyPointerMove)(null, null, 5, 5); | ||
var expected = false; | ||
var actual = notifyPointerMove(null, null, 5, 5); | ||
var actual = (0, _pointer.notifyPointerMove)(null, null, 5, 5); | ||
@@ -146,6 +148,6 @@ expect(actual).to.equal(expected); | ||
// change into pointer mode indicates a potential for change of focus | ||
setPointerMode(false); | ||
(0, _pointer.setPointerMode)(false); | ||
var expected = true; | ||
var actual = notifyPointerMove(null, null, 5, 5); | ||
var actual = (0, _pointer.notifyPointerMove)(null, null, 5, 5); | ||
@@ -157,3 +159,3 @@ expect(actual).to.equal(expected); | ||
var expected = true; | ||
var actual = notifyPointerMove(null, null, 5, 5); | ||
var actual = (0, _pointer.notifyPointerMove)(null, null, 5, 5); | ||
@@ -168,6 +170,6 @@ expect(actual).to.equal(expected); | ||
notifyPointerMove(null, current, 5, 5); | ||
(0, _pointer.notifyPointerMove)(null, current, 5, 5); | ||
var expected = false; | ||
var actual = notifyPointerMove(current, target, 10, 10); | ||
var actual = (0, _pointer.notifyPointerMove)(current, target, 10, 10); | ||
@@ -181,6 +183,6 @@ expect(actual).to.equal(expected); | ||
notifyPointerMove(null, current, 5, 5); | ||
(0, _pointer.notifyPointerMove)(null, current, 5, 5); | ||
var expected = true; | ||
var actual = notifyPointerMove(current, target, 10, 10); | ||
var actual = (0, _pointer.notifyPointerMove)(current, target, 10, 10); | ||
@@ -187,0 +189,0 @@ expect(actual).to.equal(expected); |
@@ -0,13 +1,15 @@ | ||
'use strict'; | ||
var _container2, _container3, _container4, _container5, _container6, _container7, _container8, _container9, _container10, _container11; | ||
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 _container12 = require('../container'); | ||
import { configureContainer, configureDefaults, containerAttribute, getAllContainerIds, removeContainer, rootContainerId, setDefaultContainer } from '../container'; | ||
var _target = require('../target'); | ||
import { getNavigableTarget, getTargetByContainer, getTargetByDirectionFromElement, getTargetByDirectionFromPosition, getTargetBySelector } from '../target'; | ||
var _utils = require('./utils'); | ||
import { container, join, node, someSpottables, 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 node({ className: 'other' }); | ||
return (0, _utils.node)({ className: 'other' }); | ||
}; | ||
@@ -20,3 +22,3 @@ | ||
var positionedSpottable = function positionedSpottable(id, top, left) { | ||
return spottable({ | ||
return (0, _utils.spottable)({ | ||
id: id, | ||
@@ -30,12 +32,12 @@ style: position(top, left) | ||
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)); | ||
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)); | ||
}; | ||
var scenarios = { | ||
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({ | ||
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)({ | ||
style: 'position: relative', | ||
children: join(grid(), spottable({ | ||
children: (0, _utils.join)(grid(), (0, _utils.spottable)({ | ||
id: 'over-middle-center', | ||
@@ -45,29 +47,29 @@ style: 'position: absolute; top: 12px; left: 15px; height: 1px; width: 1px;' | ||
}), | ||
overflow: join(spottable({ id: 'outside-overflow' }), node({ | ||
overflow: (0, _utils.join)((0, _utils.spottable)({ id: 'outside-overflow' }), (0, _utils.node)({ | ||
// allocate some empty space so that overflow items would be otherwise navigable | ||
style: 'height: 100px' | ||
}), container((_container7 = {}, _defineProperty(_container7, containerAttribute, 'overflow-container'), _defineProperty(_container7, 'style', 'position: relative; height: 30px; width: 30px;'), _defineProperty(_container7, 'children', join(spottable({ | ||
}), (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)({ | ||
id: 'overflow-above', | ||
style: 'position: absolute; top: -10px; left: 0px; height: 10px; width: 10px;' | ||
}), spottable({ | ||
}), (0, _utils.spottable)({ | ||
id: 'overflow-below', | ||
style: 'position: absolute; top: 30px; left: 0px; height: 10px; width: 10px;' | ||
}), spottable({ | ||
}), (0, _utils.spottable)({ | ||
id: 'overflow-within', | ||
style: 'position: absolute; top: 0px; left: 0px; height: 10px; width: 10px;' | ||
}))), _container7))), | ||
overflowLargeSubContainer: join(spottable({ id: 'outside-overflow' }), node({ | ||
overflowLargeSubContainer: (0, _utils.join)((0, _utils.spottable)({ id: 'outside-overflow' }), (0, _utils.node)({ | ||
// allocate some empty space so that overflow items would be otherwise navigable | ||
style: 'height: 100px' | ||
}), 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({ | ||
}), (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)({ | ||
// allocate space to push following spottable into view | ||
style: 'height: 10px' | ||
}), spottable({ | ||
}), (0, _utils.spottable)({ | ||
id: 'in-large-container' | ||
}))), _container8)), spottable({ | ||
}))), _container8)), (0, _utils.spottable)({ | ||
id: 'below-large-container', | ||
style: 'position: absolute; top: 40px; left: 0px; height: 10px; width: 10px;' | ||
}))), _container9))), | ||
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)) | ||
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)) | ||
}; | ||
@@ -80,6 +82,6 @@ | ||
var setupContainers = function setupContainers() { | ||
configureDefaults({ | ||
(0, _container12.configureDefaults)({ | ||
selector: '.spottable' | ||
}); | ||
configureContainer(rootContainerId); | ||
(0, _container12.configureContainer)(_container12.rootContainerId); | ||
}; | ||
@@ -89,4 +91,4 @@ | ||
// clean up any containers we create for safe tests | ||
getAllContainerIds().forEach(removeContainer); | ||
setDefaultContainer(); | ||
(0, _container12.getAllContainerIds)().forEach(_container12.removeContainer); | ||
(0, _container12.setDefaultContainer)(); | ||
}; | ||
@@ -99,7 +101,7 @@ | ||
describe('#getNavigableTarget', function () { | ||
it('should find spottable parent', testScenario(scenarios.complexTree, function (root) { | ||
it('should find spottable parent', (0, _utils.testScenario)(scenarios.complexTree, function (root) { | ||
var other = root.querySelector('.other'); | ||
var expected = other.parentNode; | ||
var actual = getNavigableTarget(other); | ||
var actual = (0, _target.getNavigableTarget)(other); | ||
@@ -109,8 +111,8 @@ expect(actual).to.equal(expected); | ||
it('should skip containers', testScenario(scenarios.nonSpottableInContainer, function (root) { | ||
configureContainer('first'); | ||
it('should skip containers', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function (root) { | ||
(0, _container12.configureContainer)('first'); | ||
var other = root.querySelector('.other'); | ||
var expected = null; | ||
var actual = getNavigableTarget(other); | ||
var actual = (0, _target.getNavigableTarget)(other); | ||
@@ -120,5 +122,5 @@ expect(actual).to.equal(expected); | ||
it('should respect container-specific selector', testScenario(scenarios.nonSpottableInContainer, function (root) { | ||
it('should respect container-specific selector', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function (root) { | ||
// make '.other' a valid spottable element | ||
configureContainer('first', { | ||
(0, _container12.configureContainer)('first', { | ||
selector: '.other' | ||
@@ -129,3 +131,3 @@ }); | ||
var expected = other; | ||
var actual = getNavigableTarget(other); | ||
var actual = (0, _target.getNavigableTarget)(other); | ||
@@ -135,8 +137,8 @@ expect(actual).to.equal(expected); | ||
it('should respect disabled containers', testScenario(scenarios.complexTree, function (root) { | ||
configureContainer('third-container'); | ||
var other = root.querySelector('[' + containerAttribute + '=\'third-container\'] .spottable'); | ||
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'); | ||
var expected = null; | ||
var actual = getNavigableTarget(other); | ||
var actual = (0, _target.getNavigableTarget)(other); | ||
@@ -148,7 +150,7 @@ expect(actual).to.equal(expected); | ||
describe('#getTargetByContainer', function () { | ||
it('should find spottable element within provided container', testScenario(scenarios.complexTree, function () { | ||
configureContainer('first-container'); | ||
it('should find spottable element within provided container', (0, _utils.testScenario)(scenarios.complexTree, function () { | ||
(0, _container12.configureContainer)('first-container'); | ||
var expected = 'spottable'; | ||
var actual = safeTarget(getTargetByContainer('first-container'), function (t) { | ||
var actual = safeTarget((0, _target.getTargetByContainer)('first-container'), function (t) { | ||
return t.className; | ||
@@ -160,8 +162,8 @@ }); | ||
it('should return null when container does not contain any spottable elements', testScenario(scenarios.nonSpottableInContainer, function () { | ||
configureContainer('first'); | ||
configureContainer('second'); | ||
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'); | ||
var expected = null; | ||
var actual = getTargetByContainer('second'); | ||
var actual = (0, _target.getTargetByContainer)('second'); | ||
@@ -171,8 +173,8 @@ expect(actual).to.equal(expected); | ||
it('should find the first spottable in the root when no container specified', testScenario(scenarios.nonSpottableInContainer, function () { | ||
configureContainer('first'); | ||
configureContainer('second'); | ||
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'); | ||
var expected = 'in-root'; | ||
var actual = safeTarget(getTargetByContainer(), function (t) { | ||
var actual = safeTarget((0, _target.getTargetByContainer)(), function (t) { | ||
return t.id; | ||
@@ -184,9 +186,9 @@ }); | ||
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'); | ||
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'); | ||
var expected = 'spottable'; | ||
var actual = safeTarget(getTargetByContainer(), function (t) { | ||
var actual = safeTarget((0, _target.getTargetByContainer)(), function (t) { | ||
return t.className; | ||
@@ -200,7 +202,7 @@ }); | ||
describe('#getTargetBySelector', function () { | ||
it('should find spottable element within container when "@" prefix used', testScenario(scenarios.nonSpottableInContainer, function () { | ||
configureContainer('first'); | ||
it('should find spottable element within container when "@" prefix used', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () { | ||
(0, _container12.configureContainer)('first'); | ||
var expected = 'spottable'; | ||
var actual = safeTarget(getTargetBySelector('@first'), function (t) { | ||
var actual = safeTarget((0, _target.getTargetBySelector)('@first'), function (t) { | ||
return t.className; | ||
@@ -212,7 +214,7 @@ }); | ||
it('should find spottable element within container when "@" prefix used', testScenario(scenarios.nonSpottableInContainer, function () { | ||
configureContainer('first'); | ||
it('should find spottable element within container when "@" prefix used', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () { | ||
(0, _container12.configureContainer)('first'); | ||
var expected = 'in-first'; | ||
var actual = safeTarget(getTargetBySelector('#in-first'), function (t) { | ||
var actual = safeTarget((0, _target.getTargetBySelector)('#in-first'), function (t) { | ||
return t.id; | ||
@@ -224,4 +226,4 @@ }); | ||
it('should return null when the node exists but is not navigable within its container', testScenario(scenarios.nonSpottableInContainer, function () { | ||
configureContainer('first', { | ||
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', { | ||
navigableFilter: function navigableFilter() { | ||
@@ -233,3 +235,3 @@ return false; | ||
var expected = null; | ||
var actual = getTargetBySelector('#in-first'); | ||
var actual = (0, _target.getTargetBySelector)('#in-first'); | ||
@@ -239,7 +241,7 @@ expect(actual).to.equal(expected); | ||
it('should return null when the node exists but does not match the container\'s selector', testScenario(scenarios.nonSpottableInContainer, function () { | ||
configureContainer('first'); | ||
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'); | ||
var expected = null; | ||
var actual = getTargetBySelector('[' + containerAttribute + '=\'first\'] .other'); | ||
var actual = (0, _target.getTargetBySelector)('[' + _container12.containerAttribute + '=\'first\'] .other'); | ||
@@ -249,9 +251,9 @@ expect(actual).to.equal(expected); | ||
it('should return null for an empty selectors', testScenario(scenarios.nonSpottableInContainer, function () { | ||
it('should return null for an empty selectors', (0, _utils.testScenario)(scenarios.nonSpottableInContainer, function () { | ||
var expected = null; | ||
// eslint-disable-next-line no-undefined | ||
expect(getTargetBySelector(undefined)).to.equal(expected); | ||
expect(getTargetBySelector(null)).to.equal(expected); | ||
expect(getTargetBySelector('')).to.equal(expected); | ||
expect((0, _target.getTargetBySelector)(undefined)).to.equal(expected); | ||
expect((0, _target.getTargetBySelector)(null)).to.equal(expected); | ||
expect((0, _target.getTargetBySelector)('')).to.equal(expected); | ||
})); | ||
@@ -261,19 +263,19 @@ }); | ||
describe('#getTargetByDirectionFromElement', function () { | ||
it('should find target within container by direction', testScenario(scenarios.grid, function (root) { | ||
configureContainer('grid'); | ||
it('should find target within container by direction', (0, _utils.testScenario)(scenarios.grid, function (root) { | ||
(0, _container12.configureContainer)('grid'); | ||
var center = root.querySelector('#middle-center'); | ||
expect(safeTarget(getTargetByDirectionFromElement('up', center), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', center), function (t) { | ||
return t.id; | ||
})).to.equal('top-center'); | ||
expect(safeTarget(getTargetByDirectionFromElement('down', center), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', center), function (t) { | ||
return t.id; | ||
})).to.equal('bottom-center'); | ||
expect(safeTarget(getTargetByDirectionFromElement('left', center), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('left', center), function (t) { | ||
return t.id; | ||
})).to.equal('middle-left'); | ||
expect(safeTarget(getTargetByDirectionFromElement('right', center), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('right', center), function (t) { | ||
return t.id; | ||
@@ -283,4 +285,4 @@ })).to.equal('middle-right'); | ||
it('should find target within container from floating element', testScenario(scenarios.overlap, function (root) { | ||
configureContainer('grid', { | ||
it('should find target within container from floating element', (0, _utils.testScenario)(scenarios.overlap, function (root) { | ||
(0, _container12.configureContainer)('grid', { | ||
enterTo: 'default-element', | ||
@@ -292,3 +294,3 @@ defaultElement: '#bottom-right' | ||
expect(safeTarget(getTargetByDirectionFromElement('down', overlap), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', overlap), function (t) { | ||
return t.id; | ||
@@ -298,4 +300,4 @@ })).to.equal('middle-center'); | ||
it('should ignore targets outside the bounds of an overflow container', testScenario(scenarios.overflow, function (root) { | ||
configureContainer('overflow-container', { | ||
it('should ignore targets outside the bounds of an overflow container', (0, _utils.testScenario)(scenarios.overflow, function (root) { | ||
(0, _container12.configureContainer)('overflow-container', { | ||
overflow: true | ||
@@ -306,3 +308,3 @@ }); | ||
expect(safeTarget(getTargetByDirectionFromElement('down', element), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) { | ||
return t.id; | ||
@@ -312,7 +314,7 @@ })).to.equal('overflow-within'); | ||
it('should find target within container larger than overflow container', testScenario(scenarios.overflowLargeSubContainer, function (root) { | ||
configureContainer('overflow-container', { | ||
it('should find target within container larger than overflow container', (0, _utils.testScenario)(scenarios.overflowLargeSubContainer, function (root) { | ||
(0, _container12.configureContainer)('overflow-container', { | ||
overflow: true | ||
}); | ||
configureContainer('inside', { | ||
(0, _container12.configureContainer)('inside', { | ||
enterTo: null | ||
@@ -323,3 +325,3 @@ }); | ||
expect(safeTarget(getTargetByDirectionFromElement('down', element), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) { | ||
return t.id; | ||
@@ -329,4 +331,4 @@ })).to.equal('in-large-container'); | ||
it('should find target out of bounds of overflow container from within container', testScenario(scenarios.overflow, function (root) { | ||
configureContainer('overflow-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', { | ||
overflow: true | ||
@@ -337,7 +339,7 @@ }); | ||
expect(safeTarget(getTargetByDirectionFromElement('down', element), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) { | ||
return t.id; | ||
})).to.equal('overflow-below'); | ||
expect(safeTarget(getTargetByDirectionFromElement('up', element), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) { | ||
return t.id; | ||
@@ -347,13 +349,13 @@ })).to.equal('overflow-above'); | ||
it('should stop at restrict="self-only" boundaries', testScenario(scenarios.complexTree, function (root) { | ||
configureContainer('first-container', { | ||
it('should stop at restrict="self-only" boundaries', (0, _utils.testScenario)(scenarios.complexTree, function (root) { | ||
(0, _container12.configureContainer)('first-container', { | ||
restrict: 'none' | ||
}); | ||
configureContainer('second-container', { | ||
(0, _container12.configureContainer)('second-container', { | ||
restrict: 'self-only' | ||
}); | ||
var element = root.querySelector('[' + containerAttribute + '="second-container"] .spottable'); | ||
var element = root.querySelector('[' + _container12.containerAttribute + '="second-container"] .spottable'); | ||
expect(safeTarget(getTargetByDirectionFromElement('up', element), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) { | ||
return t.id; | ||
@@ -363,4 +365,4 @@ })).to.equal('NOT FOUND'); | ||
it('should respect enterTo="default-element" containers', testScenario(scenarios.grid, function (root) { | ||
configureContainer('grid', { | ||
it('should respect enterTo="default-element" containers', (0, _utils.testScenario)(scenarios.grid, function (root) { | ||
(0, _container12.configureContainer)('grid', { | ||
restrict: 'none', | ||
@@ -373,3 +375,3 @@ enterTo: 'default-element', | ||
expect(safeTarget(getTargetByDirectionFromElement('down', element), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) { | ||
return t.id; | ||
@@ -379,4 +381,4 @@ })).to.equal('bottom-right'); | ||
it('should respect enterTo="last-focused" containers', testScenario(scenarios.grid, function (root) { | ||
configureContainer('grid', { | ||
it('should respect enterTo="last-focused" containers', (0, _utils.testScenario)(scenarios.grid, function (root) { | ||
(0, _container12.configureContainer)('grid', { | ||
restrict: 'none', | ||
@@ -393,3 +395,3 @@ enterTo: 'last-focused', | ||
expect(safeTarget(getTargetByDirectionFromElement('down', element), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) { | ||
return t.id; | ||
@@ -399,4 +401,4 @@ })).to.equal('bottom-right'); | ||
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', { | ||
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', { | ||
restrict: 'none', | ||
@@ -410,3 +412,3 @@ leaveFor: { | ||
expect(safeTarget(getTargetByDirectionFromElement('up', element), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) { | ||
return t.id; | ||
@@ -416,4 +418,4 @@ })).to.equal('after-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', { | ||
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', { | ||
restrict: 'none', | ||
@@ -427,3 +429,3 @@ leaveFor: { | ||
expect(safeTarget(getTargetByDirectionFromElement('up', element), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) { | ||
return t.id; | ||
@@ -433,4 +435,4 @@ })).to.equal('top-center'); | ||
it('should not follow the leaveFor config when the selector does not match an element', testScenario(scenarios.grid, function (root) { | ||
configureContainer('grid', { | ||
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', { | ||
restrict: 'none', | ||
@@ -444,3 +446,3 @@ leaveFor: { | ||
expect(safeTarget(getTargetByDirectionFromElement('up', element), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) { | ||
return t.id; | ||
@@ -450,7 +452,7 @@ })).to.equal('before-grid'); | ||
it('should ignore empty containers', testScenario(scenarios.emptyContainer, function (root) { | ||
configureContainer('empty-container'); | ||
it('should ignore empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) { | ||
(0, _container12.configureContainer)('empty-container'); | ||
var element = root.querySelector('#above'); | ||
expect(safeTarget(getTargetByDirectionFromElement('down', element), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) { | ||
return t.id; | ||
@@ -460,7 +462,7 @@ })).to.equal('below'); | ||
it('should ignore overlapping empty containers', testScenario(scenarios.emptyContainerOverlap, function (root) { | ||
configureContainer('empty-container'); | ||
it('should ignore overlapping empty containers', (0, _utils.testScenario)(scenarios.emptyContainerOverlap, function (root) { | ||
(0, _container12.configureContainer)('empty-container'); | ||
var element = root.querySelector('#above'); | ||
expect(safeTarget(getTargetByDirectionFromElement('down', element), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) { | ||
return t.id; | ||
@@ -472,4 +474,4 @@ })).to.equal('below'); | ||
describe('#getTargetByDirectionFromPosition', function () { | ||
it('should find target within container', testScenario(scenarios.grid, function (root) { | ||
configureContainer('grid'); | ||
it('should find target within container', (0, _utils.testScenario)(scenarios.grid, function (root) { | ||
(0, _container12.configureContainer)('grid'); | ||
var rect = root.querySelector('#middle-center').getBoundingClientRect(); | ||
@@ -481,15 +483,15 @@ var center = { | ||
expect(safeTarget(getTargetByDirectionFromPosition('up', center, 'grid'), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', center, 'grid'), function (t) { | ||
return t.id; | ||
})).to.equal('top-center'); | ||
expect(safeTarget(getTargetByDirectionFromPosition('down', center, 'grid'), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', center, 'grid'), function (t) { | ||
return t.id; | ||
})).to.equal('bottom-center'); | ||
expect(safeTarget(getTargetByDirectionFromPosition('left', center, 'grid'), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('left', center, 'grid'), function (t) { | ||
return t.id; | ||
})).to.equal('middle-left'); | ||
expect(safeTarget(getTargetByDirectionFromPosition('right', center, 'grid'), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('right', center, 'grid'), function (t) { | ||
return t.id; | ||
@@ -499,4 +501,4 @@ })).to.equal('middle-right'); | ||
it('should not find a target when at bounds of container with restrict="self-only"', testScenario(scenarios.grid, function (root) { | ||
configureContainer('grid', { | ||
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', { | ||
restrict: 'self-only' | ||
@@ -510,3 +512,3 @@ }); | ||
expect(safeTarget(getTargetByDirectionFromPosition('up', topCenterOfGrid, 'grid'), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', topCenterOfGrid, 'grid'), function (t) { | ||
return t.id; | ||
@@ -516,4 +518,4 @@ })).to.equal('NOT FOUND'); | ||
it('should not find a target outside of container when restrict is not set', testScenario(scenarios.grid, function (root) { | ||
configureContainer('grid', { | ||
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', { | ||
restrict: 'none' | ||
@@ -527,3 +529,3 @@ }); | ||
expect(safeTarget(getTargetByDirectionFromPosition('up', topCenterOfGrid, 'grid'), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', topCenterOfGrid, 'grid'), function (t) { | ||
return t.id; | ||
@@ -533,4 +535,4 @@ })).to.equal('before-grid'); | ||
it('should cascade into unrestricted subcontainers', testScenario(scenarios.grid, function (root) { | ||
configureContainer('grid', { | ||
it('should cascade into unrestricted subcontainers', (0, _utils.testScenario)(scenarios.grid, function (root) { | ||
(0, _container12.configureContainer)('grid', { | ||
restrict: 'none' | ||
@@ -544,3 +546,3 @@ }); | ||
expect(safeTarget(getTargetByDirectionFromPosition('down', aboveCenterOfGrid, rootContainerId), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', aboveCenterOfGrid, _container12.rootContainerId), function (t) { | ||
return t.id; | ||
@@ -550,4 +552,4 @@ })).to.equal('top-center'); | ||
it('should ignore enterTo config of restricted subcontainers', testScenario(scenarios.grid, function (root) { | ||
configureContainer('grid', { | ||
it('should ignore enterTo config of restricted subcontainers', (0, _utils.testScenario)(scenarios.grid, function (root) { | ||
(0, _container12.configureContainer)('grid', { | ||
restrict: 'none', | ||
@@ -563,3 +565,3 @@ enterTo: 'default-element', | ||
expect(safeTarget(getTargetByDirectionFromPosition('down', aboveCenterOfGrid, rootContainerId), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', aboveCenterOfGrid, _container12.rootContainerId), function (t) { | ||
return t.id; | ||
@@ -569,4 +571,4 @@ })).to.equal('top-center'); | ||
it('should find target within container from floating element', testScenario(scenarios.overlap, function (root) { | ||
configureContainer('grid', { | ||
it('should find target within container from floating element', (0, _utils.testScenario)(scenarios.overlap, function (root) { | ||
(0, _container12.configureContainer)('grid', { | ||
enterTo: 'default-element', | ||
@@ -582,3 +584,3 @@ defaultElement: '#bottom-right' | ||
expect(safeTarget(getTargetByDirectionFromPosition('down', { x: x, y: y }, rootContainerId), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', { x: x, y: y }, _container12.rootContainerId), function (t) { | ||
return t.id; | ||
@@ -588,4 +590,4 @@ })).to.equal('middle-center'); | ||
it('should ignore targets outside the bounds of an overflow container', testScenario(scenarios.overflow, function (root) { | ||
configureContainer('overflow-container', { | ||
it('should ignore targets outside the bounds of an overflow container', (0, _utils.testScenario)(scenarios.overflow, function (root) { | ||
(0, _container12.configureContainer)('overflow-container', { | ||
overflow: true | ||
@@ -600,3 +602,3 @@ }); | ||
expect(safeTarget(getTargetByDirectionFromPosition('down', { x: x, y: y }, rootContainerId), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', { x: x, y: y }, _container12.rootContainerId), function (t) { | ||
return t.id; | ||
@@ -606,7 +608,7 @@ })).to.equal('overflow-within'); | ||
it('should find target within container larger than overflow container', testScenario(scenarios.overflowLargeSubContainer, function (root) { | ||
configureContainer('overflow-container', { | ||
it('should find target within container larger than overflow container', (0, _utils.testScenario)(scenarios.overflowLargeSubContainer, function (root) { | ||
(0, _container12.configureContainer)('overflow-container', { | ||
overflow: true | ||
}); | ||
configureContainer('inside', { | ||
(0, _container12.configureContainer)('inside', { | ||
enterTo: null | ||
@@ -621,3 +623,3 @@ }); | ||
expect(safeTarget(getTargetByDirectionFromPosition('down', { x: x, y: y }, rootContainerId), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', { x: x, y: y }, _container12.rootContainerId), function (t) { | ||
return t.id; | ||
@@ -627,4 +629,4 @@ })).to.equal('in-large-container'); | ||
it('should find target out of bounds of overflow container from within container', testScenario(scenarios.overflow, function (root) { | ||
configureContainer('overflow-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', { | ||
overflow: true | ||
@@ -644,7 +646,7 @@ }); | ||
expect(safeTarget(getTargetByDirectionFromPosition('down', { x: x, y: y + 1 }, rootContainerId), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', { x: x, y: y + 1 }, _container12.rootContainerId), function (t) { | ||
return t.id; | ||
})).to.equal('overflow-below'); | ||
expect(safeTarget(getTargetByDirectionFromPosition('up', { x: x, y: y - 1 }, rootContainerId), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', { x: x, y: y - 1 }, _container12.rootContainerId), function (t) { | ||
return t.id; | ||
@@ -654,4 +656,4 @@ })).to.equal('overflow-above'); | ||
it('should ignore empty containers', testScenario(scenarios.emptyContainer, function (root) { | ||
configureContainer('empty-container'); | ||
it('should ignore empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) { | ||
(0, _container12.configureContainer)('empty-container'); | ||
var element = root.querySelector('#above'); | ||
@@ -668,3 +670,3 @@ | ||
expect(safeTarget(getTargetByDirectionFromPosition('down', { x: x, y: y }, rootContainerId), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', { x: x, y: y }, _container12.rootContainerId), function (t) { | ||
return t.id; | ||
@@ -674,4 +676,4 @@ })).to.equal('below'); | ||
it('should ignore overlapping empty containers', testScenario(scenarios.emptyContainer, function (root) { | ||
configureContainer('empty-container'); | ||
it('should ignore overlapping empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) { | ||
(0, _container12.configureContainer)('empty-container'); | ||
var element = root.querySelector('#above'); | ||
@@ -688,3 +690,3 @@ | ||
expect(safeTarget(getTargetByDirectionFromPosition('down', { x: x, y: y }, rootContainerId), function (t) { | ||
expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', { x: x, y: y }, _container12.rootContainerId), function (t) { | ||
return t.id; | ||
@@ -691,0 +693,0 @@ })).to.equal('below'); |
@@ -0,1 +1,8 @@ | ||
'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; }; | ||
@@ -5,10 +12,14 @@ | ||
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 _ramda = require('ramda'); | ||
import R from 'ramda'; | ||
var _ramda2 = _interopRequireDefault(_ramda); | ||
import { containerAttribute } from '../container'; | ||
var _container = require('../container'); | ||
var join = R.unapply(R.join('\n')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
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) { | ||
@@ -33,3 +44,3 @@ return function () { | ||
var generateContainerId = function generateContainerId() { | ||
return containerAttribute + '=' + _id++; | ||
return _container.containerAttribute + '=' + _id++; | ||
}; | ||
@@ -69,10 +80,19 @@ | ||
var container = function container(props) { | ||
return node(_extends(_defineProperty({}, containerAttribute, _id++), coerceProps(props))); | ||
return node(_extends(_defineProperty({}, _container.containerAttribute, _id++), coerceProps(props))); | ||
}; | ||
var someNodes = R.useWith(R.compose(R.join('\n'), R.map), [R.identity, R.range(0)]); | ||
var someNodes = _ramda2.default.useWith(_ramda2.default.compose(_ramda2.default.join('\n'), _ramda2.default.map), [_ramda2.default.identity, _ramda2.default.range(0)]); | ||
var someSpottables = someNodes(spottable); | ||
var someContainers = someNodes(container); | ||
var someSpottablesAndContainers = R.converge(R.concat, [someSpottables, someContainers]); | ||
var someSpottablesAndContainers = _ramda2.default.converge(_ramda2.default.concat, [someSpottables, someContainers]); | ||
export { container, generateContainerId, join, node, someContainers, someNodes, someSpottables, someSpottablesAndContainers, spottable, testScenario }; | ||
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; |
@@ -0,7 +1,18 @@ | ||
'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; }; | ||
import curry from 'ramda/src/curry'; | ||
var _curry = require('ramda/src/curry'); | ||
import { getContainerNode } from './container'; | ||
var _curry2 = _interopRequireDefault(_curry); | ||
var _container = require('./container'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var elementMatchesSelector = function elementMatchesSelector(selector) { | ||
@@ -15,3 +26,3 @@ var matchedNodes = (this.parentNode || this.document).querySelectorAll(selector); | ||
var matchSelector = curry(function (selector, elem) { | ||
var matchSelector = (0, _curry2.default)(function (selector, elem) { | ||
if (typeof selector === 'string') { | ||
@@ -69,7 +80,7 @@ return elementMatchesSelector.call(elem, selector); | ||
var intersects = curry(function (containerRect, elementRect) { | ||
var intersects = (0, _curry2.default)(function (containerRect, elementRect) { | ||
return testIntersection('intersects', containerRect, elementRect); | ||
}); | ||
var contains = curry(function (containerRect, elementRect) { | ||
var contains = (0, _curry2.default)(function (containerRect, elementRect) { | ||
return testIntersection('contains', containerRect, elementRect); | ||
@@ -155,3 +166,3 @@ }); | ||
function getContainerRect(containerId) { | ||
var containerNode = getContainerNode(containerId); | ||
var containerNode = (0, _container.getContainerNode)(containerId); | ||
@@ -165,2 +176,9 @@ if (containerNode === document) { | ||
export { contains, getContainerRect, getPointRect, getRect, getRects, intersects, matchSelector, parseSelector }; | ||
exports.contains = contains; | ||
exports.getContainerRect = getContainerRect; | ||
exports.getPointRect = getPointRect; | ||
exports.getRect = getRect; | ||
exports.getRects = getRects; | ||
exports.intersects = intersects; | ||
exports.matchSelector = matchSelector; | ||
exports.parseSelector = parseSelector; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
223180
4541
Updated@enact/core@^1.9.0