@enact/core
Advanced tools
Comparing version 1.6.1 to 1.7.0
@@ -5,2 +5,10 @@ # Change Log | ||
## [1.7.0] - 2017-08-23 | ||
No significant changes. | ||
## [1.6.1] - 2017-08-07 | ||
No significant changes. | ||
## [1.6.0] - 2017-08-04 | ||
@@ -7,0 +15,0 @@ |
@@ -1,18 +0,11 @@ | ||
'use strict'; | ||
/** | ||
* Provides methods to add and remove global event listeners | ||
* | ||
* @module core/dispatcher | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.once = exports.on = exports.off = undefined; | ||
import curry from 'ramda/src/curry'; | ||
var _curry = require('ramda/src/curry'); | ||
import getListeners from './listeners'; | ||
var _curry2 = _interopRequireDefault(_curry); | ||
var _listeners = require('./listeners'); | ||
var _listeners2 = _interopRequireDefault(_listeners); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
@@ -25,8 +18,2 @@ * Checks if the default target of `document` exists before returning it, otherwise returns `false`. | ||
*/ | ||
/** | ||
* Provides methods to add and remove global event listeners | ||
* | ||
* @module core/dispatcher | ||
*/ | ||
var getDefaultTarget = function getDefaultTarget() { | ||
@@ -47,3 +34,3 @@ return typeof document !== 'undefined' && document; | ||
*/ | ||
var invoker = (0, _curry2.default)(function (ev, fn) { | ||
var invoker = curry(function (ev, fn) { | ||
try { | ||
@@ -69,3 +56,3 @@ fn(ev); | ||
var name = ev.type; | ||
var listeners = (0, _listeners2.default)(ev.currentTarget, name); | ||
var listeners = getListeners(ev.currentTarget, name); | ||
@@ -93,3 +80,3 @@ if (listeners) { | ||
if (target) { | ||
var listeners = (0, _listeners2.default)(target, name); | ||
var listeners = getListeners(target, name); | ||
@@ -118,3 +105,3 @@ var length = listeners.push(fn); | ||
if (target) { | ||
var listeners = (0, _listeners2.default)(target, name); | ||
var listeners = getListeners(target, name); | ||
var index = listeners.indexOf(fn); | ||
@@ -154,4 +141,2 @@ | ||
exports.off = off; | ||
exports.on = on; | ||
exports.once = once; | ||
export { off, on, once }; |
@@ -1,6 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
// Simple Map polyfill mapping targets to a hash of names->handler[] | ||
@@ -19,3 +14,3 @@ var targets = []; | ||
exports.default = getListeners; | ||
exports.getListeners = getListeners; | ||
export default getListeners; | ||
export { getListeners }; |
@@ -1,18 +0,13 @@ | ||
'use strict'; | ||
/* global CustomEvent */ | ||
var _sinon = require('sinon'); | ||
import sinon from 'sinon'; | ||
import { restoreErrorAndWarnings, watchErrorAndWarnings } from 'console-snoop'; | ||
var _sinon2 = _interopRequireDefault(_sinon); | ||
import { off, on, once } from '../dispatcher'; | ||
var _consoleSnoop = require('console-snoop'); | ||
var _dispatcher = require('../dispatcher'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
describe('dispatcher', function () { | ||
it('should register handlers on target', function () { | ||
var handler = _sinon2.default.spy(); | ||
(0, _dispatcher.on)('localechange', handler, window); | ||
var handler = sinon.spy(); | ||
on('localechange', handler, window); | ||
@@ -29,4 +24,4 @@ var ev = new CustomEvent('localechange', {}); | ||
it('should unregister handlers on target', function () { | ||
var handler = _sinon2.default.spy(); | ||
(0, _dispatcher.on)('localechange', handler, window); | ||
var handler = sinon.spy(); | ||
on('localechange', handler, window); | ||
@@ -36,3 +31,3 @@ var ev = new CustomEvent('localechange', {}); | ||
(0, _dispatcher.off)('localechange', handler, window); | ||
off('localechange', handler, window); | ||
window.dispatchEvent(ev); | ||
@@ -47,4 +42,4 @@ | ||
it('should only call a "once" handler once', function () { | ||
var handler = _sinon2.default.spy(); | ||
(0, _dispatcher.once)('localechange', handler, window); | ||
var handler = sinon.spy(); | ||
once('localechange', handler, window); | ||
@@ -62,5 +57,5 @@ var ev = new CustomEvent('localechange', {}); | ||
it('should allow unregistering a "once" before it is called', function () { | ||
var handler = _sinon2.default.spy(); | ||
var onceHandler = (0, _dispatcher.once)('localechange', handler, window); | ||
(0, _dispatcher.off)('localechange', onceHandler, window); | ||
var handler = sinon.spy(); | ||
var onceHandler = once('localechange', handler, window); | ||
off('localechange', onceHandler, window); | ||
@@ -78,4 +73,4 @@ var ev = new CustomEvent('localechange', {}); | ||
// clear enyo-console-spy so we can stub it to suppress the console.error | ||
(0, _consoleSnoop.restoreErrorAndWarnings)(); | ||
_sinon2.default.stub(console, 'error'); | ||
restoreErrorAndWarnings(); | ||
sinon.stub(console, 'error'); | ||
@@ -85,5 +80,5 @@ var throws = function throws() { | ||
}; | ||
var handler = _sinon2.default.spy(); | ||
(0, _dispatcher.on)('localechange', throws, window); | ||
(0, _dispatcher.on)('localechange', handler, window); | ||
var handler = sinon.spy(); | ||
on('localechange', throws, window); | ||
on('localechange', handler, window); | ||
@@ -96,3 +91,3 @@ var ev = new CustomEvent('localechange', {}); | ||
console.error.restore(); | ||
(0, _consoleSnoop.watchErrorAndWarnings)(); | ||
watchErrorAndWarnings(); | ||
@@ -104,2 +99,2 @@ var expected = true; | ||
}); | ||
}); /* global CustomEvent */ | ||
}); |
@@ -1,6 +0,1 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/** | ||
@@ -34,3 +29,3 @@ * Merges the local CSS object and a CSS object from the props. When both exist, the class names are | ||
exports.default = feature; | ||
exports.feature = feature; | ||
export default feature; | ||
export { feature }; |
@@ -1,14 +0,9 @@ | ||
'use strict'; | ||
/** | ||
* Exports the {@link core/factory.factory} function for creating customizeable components. | ||
* | ||
* @module core/factory | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.factory = undefined; | ||
import css from './css'; | ||
var _css = require('./css'); | ||
var _css2 = _interopRequireDefault(_css); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
@@ -86,8 +81,2 @@ * Invokes a factory feature | ||
*/ | ||
/** | ||
* Exports the {@link core/factory.factory} function for creating customizeable components. | ||
* | ||
* @module core/factory | ||
*/ | ||
var factory = function factory(defaultConfig, fn) { | ||
@@ -106,3 +95,3 @@ return function (config) { | ||
return factoryFn({ | ||
css: feature('css', _css2.default, componentConfig, authorConfig) | ||
css: feature('css', css, componentConfig, authorConfig) | ||
}); | ||
@@ -112,3 +101,3 @@ }; | ||
exports.default = factory; | ||
exports.factory = factory; | ||
export default factory; | ||
export { factory }; |
@@ -1,9 +0,3 @@ | ||
'use strict'; | ||
import css from '../css'; | ||
var _css = require('../css'); | ||
var _css2 = _interopRequireDefault(_css); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
describe('css feature', function () { | ||
@@ -19,3 +13,3 @@ var componentCss = { | ||
}; | ||
var updated = (0, _css2.default)(componentCss, authorCss); | ||
var updated = css(componentCss, authorCss); | ||
@@ -32,3 +26,3 @@ var expected = ['button', 'inner', 'other']; | ||
}; | ||
var updated = (0, _css2.default)(componentCss, authorCss); | ||
var updated = css(componentCss, authorCss); | ||
@@ -35,0 +29,0 @@ var expected = componentCss.button + ' author-button'; |
@@ -1,18 +0,9 @@ | ||
'use strict'; | ||
import sinon from 'sinon'; | ||
import factory from '../factory'; | ||
var _sinon = require('sinon'); | ||
var _sinon2 = _interopRequireDefault(_sinon); | ||
var _factory = require('../factory'); | ||
var _factory2 = _interopRequireDefault(_factory); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
describe('factory', function () { | ||
it('should allow omitting the component config', function () { | ||
var fn = _sinon2.default.spy(); | ||
var fnFactory = (0, _factory2.default)(fn); | ||
var fn = sinon.spy(); | ||
var fnFactory = factory(fn); | ||
fnFactory(); | ||
@@ -27,3 +18,3 @@ | ||
it('should pass through author config when omitting the component config', function () { | ||
var fn = _sinon2.default.spy(); | ||
var fn = sinon.spy(); | ||
var config = { | ||
@@ -35,3 +26,3 @@ css: { | ||
}; | ||
var fnFactory = (0, _factory2.default)(fn); | ||
var fnFactory = factory(fn); | ||
fnFactory(config); | ||
@@ -46,7 +37,7 @@ | ||
it('should only pass supported keys to function', function () { | ||
var fn = _sinon2.default.spy(); | ||
var fn = sinon.spy(); | ||
var config = { | ||
unsupportedKey: true | ||
}; | ||
var fnFactory = (0, _factory2.default)(fn); | ||
var fnFactory = factory(fn); | ||
fnFactory(config); | ||
@@ -53,0 +44,0 @@ |
@@ -1,57 +0,1 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.stopImmediate = exports.stop = exports.preventDefault = exports.oneOf = exports.log = exports.handle = exports.forProp = exports.forKeyCode = exports.forKey = exports.forEventProp = exports.forwardWithPrevent = exports.forward = exports.callOnEvent = undefined; | ||
var _allPass = require('ramda/src/allPass'); | ||
var _allPass2 = _interopRequireDefault(_allPass); | ||
var _always = require('ramda/src/always'); | ||
var _always2 = _interopRequireDefault(_always); | ||
var _compose = require('ramda/src/compose'); | ||
var _compose2 = _interopRequireDefault(_compose); | ||
var _cond = require('ramda/src/cond'); | ||
var _cond2 = _interopRequireDefault(_cond); | ||
var _curry = require('ramda/src/curry'); | ||
var _curry2 = _interopRequireDefault(_curry); | ||
var _identity = require('ramda/src/identity'); | ||
var _identity2 = _interopRequireDefault(_identity); | ||
var _ifElse = require('ramda/src/ifElse'); | ||
var _ifElse2 = _interopRequireDefault(_ifElse); | ||
var _is = require('ramda/src/is'); | ||
var _is2 = _interopRequireDefault(_is); | ||
var _map = require('ramda/src/map'); | ||
var _map2 = _interopRequireDefault(_map); | ||
var _T = require('ramda/src/T'); | ||
var _T2 = _interopRequireDefault(_T); | ||
var _keymap = require('../keymap'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// Ensures that everything passed to `allPass` is a function so that if null values are passed they | ||
// do not impede the event flow | ||
var makeSafeHandler = (0, _ifElse2.default)((0, _is2.default)(Function), _identity2.default, (0, _always2.default)(_T2.default)); | ||
// Accepts an array of handlers, sanitizes them, and returns a handler function | ||
/** | ||
@@ -113,4 +57,22 @@ * `core/handle` provides a set of utilities to support handling events for `kind()`s and | ||
var makeHandler = (0, _compose2.default)(_allPass2.default, (0, _map2.default)(makeSafeHandler)); | ||
import allPass from 'ramda/src/allPass'; | ||
import always from 'ramda/src/always'; | ||
import compose from 'ramda/src/compose'; | ||
import cond from 'ramda/src/cond'; | ||
import curry from 'ramda/src/curry'; | ||
import identity from 'ramda/src/identity'; | ||
import ifElse from 'ramda/src/ifElse'; | ||
import isType from 'ramda/src/is'; | ||
import map from 'ramda/src/map'; | ||
import T from 'ramda/src/T'; | ||
import { is } from '../keymap'; | ||
// Ensures that everything passed to `allPass` is a function so that if null values are passed they | ||
// do not impede the event flow | ||
var makeSafeHandler = ifElse(isType(Function), identity, always(T)); | ||
// Accepts an array of handlers, sanitizes them, and returns a handler function | ||
var makeHandler = compose(allPass, map(makeSafeHandler)); | ||
/** | ||
@@ -172,3 +134,3 @@ * Allows generating event handlers by chaining input functions to filter or short-circuit the | ||
return (0, _cond2.default)(handlers); | ||
return cond(handlers); | ||
}; | ||
@@ -195,3 +157,3 @@ | ||
*/ | ||
var callOnEvent = handle.callOnEvent = (0, _curry2.default)(function (methodName, ev) { | ||
var callOnEvent = handle.callOnEvent = curry(function (methodName, ev) { | ||
if (ev[methodName]) { | ||
@@ -226,3 +188,3 @@ ev[methodName](); | ||
*/ | ||
var forEventProp = handle.forEventProp = (0, _curry2.default)(function (prop, value, ev) { | ||
var forEventProp = handle.forEventProp = curry(function (prop, value, ev) { | ||
return ev[prop] === value; | ||
@@ -252,3 +214,3 @@ }); | ||
*/ | ||
var forward = handle.forward = (0, _curry2.default)(function (name, ev, props) { | ||
var forward = handle.forward = curry(function (name, ev, props) { | ||
var fn = props && props[name]; | ||
@@ -303,3 +265,3 @@ if (typeof fn === 'function') { | ||
*/ | ||
var forwardWithPrevent = handle.forwardWithPrevent = (0, _curry2.default)(function (name, ev, props) { | ||
var forwardWithPrevent = handle.forwardWithPrevent = curry(function (name, ev, props) { | ||
var prevented = false; | ||
@@ -395,4 +357,4 @@ var wrappedEvent = Object.assign({}, ev, { | ||
*/ | ||
var forKey = handle.forKey = (0, _curry2.default)(function (name, ev) { | ||
return (0, _keymap.is)(name, ev.keyCode); | ||
var forKey = handle.forKey = curry(function (name, ev) { | ||
return is(name, ev.keyCode); | ||
}); | ||
@@ -420,3 +382,3 @@ | ||
*/ | ||
var forProp = handle.forProp = (0, _curry2.default)(function (prop, value, ev, props) { | ||
var forProp = handle.forProp = curry(function (prop, value, ev, props) { | ||
return props[prop] === value; | ||
@@ -446,3 +408,3 @@ }); | ||
*/ | ||
var log = handle.log = (0, _curry2.default)(function (message, ev) { | ||
var log = handle.log = curry(function (message, ev) { | ||
for (var _len3 = arguments.length, args = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) { | ||
@@ -462,15 +424,3 @@ args[_key3 - 2] = arguments[_key3]; | ||
exports.default = handle; | ||
exports.callOnEvent = callOnEvent; | ||
exports.forward = forward; | ||
exports.forwardWithPrevent = forwardWithPrevent; | ||
exports.forEventProp = forEventProp; | ||
exports.forKey = forKey; | ||
exports.forKeyCode = forKeyCode; | ||
exports.forProp = forProp; | ||
exports.handle = handle; | ||
exports.log = log; | ||
exports.oneOf = oneOf; | ||
exports.preventDefault = _preventDefault; | ||
exports.stop = stop; | ||
exports.stopImmediate = stopImmediate; | ||
export default handle; | ||
export { callOnEvent, forward, forwardWithPrevent, forEventProp, forKey, forKeyCode, forProp, handle, log, oneOf, _preventDefault as preventDefault, stop, stopImmediate }; |
@@ -1,15 +0,8 @@ | ||
'use strict'; | ||
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; }; | ||
var _sinon = require('sinon'); | ||
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 _sinon2 = _interopRequireDefault(_sinon); | ||
import sinon from 'sinon'; | ||
import { handle, callOnEvent, forEventProp, forKeyCode, forProp, forward, forwardWithPrevent, oneOf, preventDefault, stop } from '../handle'; | ||
var _handle = require('../handle'); | ||
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; } | ||
describe('handle', function () { | ||
@@ -19,4 +12,4 @@ | ||
return _extends({ | ||
preventDefault: _sinon2.default.spy(), | ||
stopPropagation: _sinon2.default.spy() | ||
preventDefault: sinon.spy(), | ||
stopPropagation: sinon.spy() | ||
}, payload); | ||
@@ -33,4 +26,4 @@ }; | ||
it('should call only handler', function () { | ||
var handler = _sinon2.default.spy(returnsTrue); | ||
var callback = (0, _handle.handle)(handler); | ||
var handler = sinon.spy(returnsTrue); | ||
var callback = handle(handler); | ||
@@ -46,6 +39,6 @@ callback(makeEvent()); | ||
it('should call multiple handlers', function () { | ||
var handler1 = _sinon2.default.spy(returnsTrue); | ||
var handler2 = _sinon2.default.spy(returnsTrue); | ||
var handler1 = sinon.spy(returnsTrue); | ||
var handler2 = sinon.spy(returnsTrue); | ||
var callback = (0, _handle.handle)(handler1, handler2); | ||
var callback = handle(handler1, handler2); | ||
@@ -61,4 +54,4 @@ callback(makeEvent()); | ||
it('should skip non-function handlers', function () { | ||
var handler = _sinon2.default.spy(returnsTrue); | ||
var callback = (0, _handle.handle)(null, void 0, 0, 'purple', handler); | ||
var handler = sinon.spy(returnsTrue); | ||
var callback = handle(null, void 0, 0, 'purple', handler); | ||
@@ -74,6 +67,6 @@ callback(makeEvent()); | ||
it('should not call handlers after one that returns false', function () { | ||
var handler1 = _sinon2.default.spy(returnsTrue); | ||
var handler2 = _sinon2.default.spy(returnsTrue); | ||
var handler1 = sinon.spy(returnsTrue); | ||
var handler2 = sinon.spy(returnsTrue); | ||
var callback = (0, _handle.handle)(handler1, returnsFalse, handler2); | ||
var callback = handle(handler1, returnsFalse, handler2); | ||
@@ -89,3 +82,3 @@ callback(makeEvent()); | ||
it('should call stopPropagation on event', function () { | ||
var callback = (0, _handle.handle)(_handle.stop); | ||
var callback = handle(stop); | ||
var ev = makeEvent(); | ||
@@ -101,3 +94,3 @@ callback(ev); | ||
it('should call preventDefault on event', function () { | ||
var callback = (0, _handle.handle)(_handle.preventDefault); | ||
var callback = handle(preventDefault); | ||
var ev = makeEvent(); | ||
@@ -113,5 +106,5 @@ callback(ev); | ||
it('should call any method on event', function () { | ||
var callback = (0, _handle.handle)((0, _handle.callOnEvent)('customMethod')); | ||
var callback = handle(callOnEvent('customMethod')); | ||
var ev = makeEvent({ | ||
customMethod: _sinon2.default.spy() | ||
customMethod: sinon.spy() | ||
}); | ||
@@ -128,4 +121,4 @@ callback(ev); | ||
var keyCode = 13; | ||
var handler = _sinon2.default.spy(); | ||
var callback = (0, _handle.handle)((0, _handle.forKeyCode)(keyCode), handler); | ||
var handler = sinon.spy(); | ||
var callback = handle(forKeyCode(keyCode), handler); | ||
@@ -142,4 +135,4 @@ callback(makeEvent()); | ||
var value = 0; | ||
var handler = _sinon2.default.spy(); | ||
var callback = (0, _handle.handle)((0, _handle.forEventProp)(prop, value), handler); | ||
var handler = sinon.spy(); | ||
var callback = handle(forEventProp(prop, value), handler); | ||
@@ -160,4 +153,4 @@ // undefined shouldn't pass | ||
it('should only call handler for specified prop', function () { | ||
var handler = _sinon2.default.spy(); | ||
var callback = (0, _handle.handle)((0, _handle.forProp)('checked', true), handler); | ||
var handler = sinon.spy(); | ||
var callback = handle(forProp('checked', true), handler); | ||
@@ -181,3 +174,3 @@ // undefined shouldn't pass | ||
var propValue = 0; | ||
var spy = _sinon2.default.spy(); | ||
var spy = sinon.spy(); | ||
@@ -187,3 +180,3 @@ var props = _defineProperty({}, event, spy); | ||
(0, _handle.handle)((0, _handle.forward)(event))(payload, props); | ||
handle(forward(event))(payload, props); | ||
@@ -198,5 +191,5 @@ var expected = true; | ||
var event = 'onMyClick'; | ||
var handler = _sinon2.default.spy(); | ||
var handler = sinon.spy(); | ||
var callback = (0, _handle.handle)((0, _handle.forwardWithPrevent)(event), handler); | ||
var callback = handle(forwardWithPrevent(event), handler); | ||
@@ -209,5 +202,5 @@ callback(); | ||
var event = 'onMyClick'; | ||
var handler = _sinon2.default.spy(); | ||
var handler = sinon.spy(); | ||
var callback = (0, _handle.handle)((0, _handle.forwardWithPrevent)(event), handler); | ||
var callback = handle(forwardWithPrevent(event), handler); | ||
@@ -229,4 +222,4 @@ // should stop chain when `preventDefault()` has been called | ||
}; | ||
var handler = _sinon2.default.spy(); | ||
var h = _handle.handle.bind(componentInstance); | ||
var handler = sinon.spy(); | ||
var h = handle.bind(componentInstance); | ||
var callback = h(handler); | ||
@@ -247,4 +240,4 @@ callback(); | ||
}; | ||
var handler = _sinon2.default.spy(); | ||
var h = _handle.handle.bind(componentInstance); | ||
var handler = sinon.spy(); | ||
var h = handle.bind(componentInstance); | ||
var callback = h(handler); | ||
@@ -261,6 +254,6 @@ callback(); | ||
it('should call each handler until one passes', function () { | ||
var handler = _sinon2.default.spy(returnsTrue); | ||
var handler = sinon.spy(returnsTrue); | ||
var h1 = [returnsFalse, handler]; | ||
var h2 = [returnsTrue, handler]; | ||
var callback = (0, _handle.oneOf)(h1, h1, h2); | ||
var callback = oneOf(h1, h1, h2); | ||
callback(); | ||
@@ -275,4 +268,4 @@ | ||
it('should stop if the first handler passes', function () { | ||
var handler = _sinon2.default.spy(returnsTrue); | ||
var callback = (0, _handle.oneOf)([returnsTrue, handler], [returnsTrue, handler], [returnsTrue, handler]); | ||
var handler = sinon.spy(returnsTrue); | ||
var callback = oneOf([returnsTrue, handler], [returnsTrue, handler], [returnsTrue, handler]); | ||
callback(); | ||
@@ -287,4 +280,4 @@ | ||
it('should pass args to condition', function () { | ||
var handler = _sinon2.default.spy(returnsTrue); | ||
var callback = (0, _handle.oneOf)([handler, returnsTrue]); | ||
var handler = sinon.spy(returnsTrue); | ||
var callback = oneOf([handler, returnsTrue]); | ||
var ev = { value: 1 }; | ||
@@ -300,4 +293,4 @@ callback(ev); | ||
it('should pass args to handlers', function () { | ||
var handler = _sinon2.default.spy(returnsTrue); | ||
var callback = (0, _handle.oneOf)([returnsTrue, handler]); | ||
var handler = sinon.spy(returnsTrue); | ||
var callback = oneOf([returnsTrue, handler]); | ||
var ev = { value: 1 }; | ||
@@ -313,6 +306,6 @@ callback(ev); | ||
it('should return the value from the passed condition branch', function () { | ||
var handler = _sinon2.default.spy(function () { | ||
var handler = sinon.spy(function () { | ||
return 'ok'; | ||
}); | ||
var callback = (0, _handle.oneOf)([returnsTrue, handler]); | ||
var callback = oneOf([returnsTrue, handler]); | ||
@@ -331,5 +324,5 @@ var expected = callback(); | ||
}; | ||
var handler = _sinon2.default.spy(); | ||
var h = _handle.handle.bind(componentInstance); | ||
var callback = (0, _handle.oneOf)([returnsTrue, h(handler)]); | ||
var handler = sinon.spy(); | ||
var h = handle.bind(componentInstance); | ||
var callback = oneOf([returnsTrue, h(handler)]); | ||
callback(); | ||
@@ -336,0 +329,0 @@ |
@@ -1,10 +0,3 @@ | ||
'use strict'; | ||
import { isRenderable } from '../util'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.hoc = undefined; | ||
var _util = require('../util'); | ||
/** | ||
@@ -60,7 +53,7 @@ * Constructs a Higher-order Component using an optional set of default configuration parameters and | ||
return function (config, maybeWrapped) { | ||
if ((0, _util.isRenderable)(config)) { | ||
if (isRenderable(config)) { | ||
return factory(defaults, config); | ||
} else { | ||
var cfg = Object.assign({}, defaults, config); | ||
if ((0, _util.isRenderable)(maybeWrapped)) { | ||
if (isRenderable(maybeWrapped)) { | ||
return factory(cfg, maybeWrapped); | ||
@@ -76,3 +69,3 @@ } else { | ||
exports.default = hoc; | ||
exports.hoc = hoc; | ||
export default hoc; | ||
export { hoc }; |
@@ -1,17 +0,9 @@ | ||
'use strict'; | ||
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; }; | ||
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; }; /* eslint-disable enact/display-name */ | ||
/* eslint-disable enact/display-name */ | ||
var _react = require('react'); | ||
import React from 'react'; | ||
import { shallow, mount } from 'enzyme'; | ||
import hoc from '../hoc'; | ||
var _react2 = _interopRequireDefault(_react); | ||
var _enzyme = require('enzyme'); | ||
var _hoc = require('../hoc'); | ||
var _hoc2 = _interopRequireDefault(_hoc); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
describe('hoc', function () { | ||
@@ -23,11 +15,11 @@ | ||
var HoC = (0, _hoc2.default)(defaultConfig, function (config, Wrapped) { | ||
var HoC = hoc(defaultConfig, function (config, Wrapped) { | ||
return function (props) { | ||
return _react2.default.createElement(Wrapped, _extends({}, props, config)); | ||
return React.createElement(Wrapped, _extends({}, props, config)); | ||
}; | ||
}); | ||
var NullHoC = (0, _hoc2.default)(null, function (config, Wrapped) { | ||
var NullHoC = hoc(null, function (config, Wrapped) { | ||
return function () { | ||
return _react2.default.createElement(Wrapped, config); | ||
return React.createElement(Wrapped, config); | ||
}; | ||
@@ -37,5 +29,5 @@ }); | ||
it('should support HoC factory function as first argument to hoc()', function () { | ||
var ImplicitNullHoC = (0, _hoc2.default)(function (config, Wrapped) { | ||
var ImplicitNullHoC = hoc(function (config, Wrapped) { | ||
return function () { | ||
return _react2.default.createElement(Wrapped, config); | ||
return React.createElement(Wrapped, config); | ||
}; | ||
@@ -45,3 +37,3 @@ }); | ||
var subject = (0, _enzyme.shallow)(_react2.default.createElement(Component, null)); | ||
var subject = shallow(React.createElement(Component, null)); | ||
@@ -57,3 +49,3 @@ var expected = 'span'; | ||
var subject = (0, _enzyme.shallow)(_react2.default.createElement(Component, null)); | ||
var subject = shallow(React.createElement(Component, null)); | ||
@@ -68,7 +60,7 @@ var expected = 'span'; | ||
function Thing() { | ||
return _react2.default.createElement('div', null); | ||
return React.createElement('div', null); | ||
} | ||
var Component = HoC(Thing); | ||
var subject = (0, _enzyme.shallow)(_react2.default.createElement(Component, null)); | ||
var subject = shallow(React.createElement(Component, null)); | ||
@@ -84,3 +76,3 @@ var expected = 'Thing'; | ||
var subject = (0, _enzyme.mount)(_react2.default.createElement(Component, null)); | ||
var subject = mount(React.createElement(Component, null)); | ||
@@ -99,3 +91,3 @@ var expected = defaultConfig.color; | ||
var subject = (0, _enzyme.mount)(_react2.default.createElement(Component, null)); | ||
var subject = mount(React.createElement(Component, null)); | ||
@@ -111,3 +103,3 @@ var expected = instanceConfig.color; | ||
var subject = (0, _enzyme.mount)(_react2.default.createElement(Component, null)); | ||
var subject = mount(React.createElement(Component, null)); | ||
@@ -126,3 +118,3 @@ var expected = 1; | ||
var subject = (0, _enzyme.mount)(_react2.default.createElement(Component, null)); | ||
var subject = mount(React.createElement(Component, null)); | ||
@@ -129,0 +121,0 @@ var expected = instanceConfig.color; |
@@ -1,2 +0,1 @@ | ||
// This space intentionally left blank | ||
"use strict"; | ||
// This space intentionally left blank |
@@ -1,8 +0,1 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ApiDecorator = undefined; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -12,29 +5,22 @@ | ||
var _invariant = require('invariant'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _invariant2 = _interopRequireDefault(_invariant); | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
var _react = require('react'); | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var _react2 = _interopRequireDefault(_react); | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
var _hoc = require('../../hoc'); | ||
/** | ||
* Provides the `ApiDecorator` Higher-order Component | ||
* | ||
* @module core/internal/ApiDecorator | ||
* @private | ||
*/ | ||
var _hoc2 = _interopRequireDefault(_hoc); | ||
import invariant from 'invariant'; | ||
import React from 'react'; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
import hoc from '../../hoc'; | ||
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; } | ||
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); } } /** | ||
* Provides the `ApiDecorator` Higher-order Component | ||
* | ||
* @module core/internal/ApiDecorator | ||
* @private | ||
*/ | ||
// Invokes `name` on `provider` with `args` | ||
@@ -103,3 +89,3 @@ var invoke = function invoke(provider, name, args) { | ||
*/ | ||
var ApiDecorator = (0, _hoc2.default)(defaultConfig, function (config, Wrapped) { | ||
var ApiDecorator = hoc(defaultConfig, function (config, Wrapped) { | ||
var _class, _temp2, _initialiseProps; | ||
@@ -110,3 +96,3 @@ | ||
!(api != null) ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, 'ApiDecorator: api is a required config property') : (0, _invariant2.default)(false) : void 0; | ||
!(api != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ApiDecorator: api is a required config property') : invariant(false) : void 0; | ||
@@ -133,3 +119,3 @@ return _temp2 = _class = function (_React$Component) { | ||
value: function render() { | ||
return _react2.default.createElement(Wrapped, _extends({ setApiProvider: this.setProvider }, this.props)); | ||
return React.createElement(Wrapped, _extends({ setApiProvider: this.setProvider }, this.props)); | ||
} | ||
@@ -139,3 +125,3 @@ }]); | ||
return _class; | ||
}(_react2.default.Component), _class.displayName = 'ApiDecorator', _initialiseProps = function _initialiseProps() { | ||
}(React.Component), _class.displayName = 'ApiDecorator', _initialiseProps = function _initialiseProps() { | ||
var _this2 = this; | ||
@@ -173,3 +159,3 @@ | ||
exports.default = ApiDecorator; | ||
exports.ApiDecorator = ApiDecorator; | ||
export default ApiDecorator; | ||
export { ApiDecorator }; |
@@ -1,17 +0,3 @@ | ||
'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = require('react'); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _enzyme = require('enzyme'); | ||
var _ApiDecorator = require('../ApiDecorator'); | ||
var _ApiDecorator2 = _interopRequireDefault(_ApiDecorator); | ||
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"); } } | ||
@@ -23,2 +9,6 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import ApiDecorator from '../ApiDecorator'; | ||
describe('ApiDecorator', function () { | ||
@@ -53,3 +43,3 @@ var _class, _temp; | ||
value: function render() { | ||
return _react2.default.createElement('div', null); | ||
return React.createElement('div', null); | ||
} | ||
@@ -59,8 +49,8 @@ }]); | ||
return ApiProvider; | ||
}(_react2.default.Component), _class.displayName = 'ApiProvider', _temp); | ||
}(React.Component), _class.displayName = 'ApiProvider', _temp); | ||
it('should invoke arrow function on wrapped component', function () { | ||
var Component = (0, _ApiDecorator2.default)({ api: ['arrowFunction'] }, ApiProvider); | ||
var Component = ApiDecorator({ api: ['arrowFunction'] }, ApiProvider); | ||
var subject = (0, _enzyme.mount)(_react2.default.createElement(Component, null)); | ||
var subject = mount(React.createElement(Component, null)); | ||
@@ -74,5 +64,5 @@ var expected = 'arrow'; | ||
it('should invoke instance function on wrapped component', function () { | ||
var Component = (0, _ApiDecorator2.default)({ api: ['instanceFunction'] }, ApiProvider); | ||
var Component = ApiDecorator({ api: ['instanceFunction'] }, ApiProvider); | ||
var subject = (0, _enzyme.mount)(_react2.default.createElement(Component, null)); | ||
var subject = mount(React.createElement(Component, null)); | ||
@@ -86,5 +76,5 @@ var expected = 'instance'; | ||
it('should get an instance property on wrapped component', function () { | ||
var Component = (0, _ApiDecorator2.default)({ api: ['instanceProperty'] }, ApiProvider); | ||
var Component = ApiDecorator({ api: ['instanceProperty'] }, ApiProvider); | ||
var subject = (0, _enzyme.mount)(_react2.default.createElement(Component, null)); | ||
var subject = mount(React.createElement(Component, null)); | ||
@@ -98,5 +88,5 @@ var expected = 'property'; | ||
it('should set an instance property on wrapped component', function () { | ||
var Component = (0, _ApiDecorator2.default)({ api: ['instanceProperty'] }, ApiProvider); | ||
var Component = ApiDecorator({ api: ['instanceProperty'] }, ApiProvider); | ||
var subject = (0, _enzyme.mount)(_react2.default.createElement(Component, null)); | ||
var subject = mount(React.createElement(Component, null)); | ||
@@ -103,0 +93,0 @@ subject.instance().instanceProperty = 'updated'; |
@@ -1,6 +0,1 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/** | ||
@@ -103,3 +98,3 @@ * Provides the `deprecate` method | ||
exports.default = deprecate; | ||
exports.deprecate = deprecate; | ||
export default deprecate; | ||
export { deprecate }; |
@@ -1,22 +0,9 @@ | ||
'use strict'; | ||
// keymap uses a singleton object, map, to manage the keymap. since webpack may make multiple copies | ||
// of the module available if the import path is different, we ensure a consistent import path for | ||
// the singleton instance by facading it with this module. | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
import { addAll } from './keymap'; | ||
var _keymap = require('./keymap'); | ||
Object.keys(_keymap).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _keymap[key]; | ||
} | ||
}); | ||
}); | ||
// Add the default 5-way navigation key codes | ||
(0, _keymap.addAll)({ | ||
addAll({ | ||
enter: [13, 16777221], | ||
@@ -29,4 +16,4 @@ left: 37, | ||
pageDown: 34 | ||
}); // keymap uses a singleton object, map, to manage the keymap. since webpack may make multiple copies | ||
// of the module available if the import path is different, we ensure a consistent import path for | ||
// the singleton instance by facading it with this module. | ||
}); | ||
export * from './keymap'; |
@@ -1,14 +0,21 @@ | ||
'use strict'; | ||
/** | ||
* Manages a map of names to key codes to simplify event handlers | ||
* | ||
* ``` | ||
* import {add, is} from '@enact/core/keymap'; | ||
* | ||
* add('enter', 13); | ||
* const isEnter = is('enter'); | ||
* | ||
* // within event handler | ||
* if (isEnter(ev.keyCode)) { | ||
* // handle enter | ||
* } | ||
* ``` | ||
* | ||
* @module core/keymap | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.removeAll = exports.remove = exports.is = exports.addAll = exports.add = undefined; | ||
import curry from 'ramda/src/curry'; | ||
var _curry = require('ramda/src/curry'); | ||
var _curry2 = _interopRequireDefault(_curry); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
@@ -33,20 +40,2 @@ * The singleton map of names to keyCodes. If a name doesn't have any keyCodes mapped to it, it will | ||
*/ | ||
/** | ||
* Manages a map of names to key codes to simplify event handlers | ||
* | ||
* ``` | ||
* import {add, is} from '@enact/core/keymap'; | ||
* | ||
* add('enter', 13); | ||
* const isEnter = is('enter'); | ||
* | ||
* // within event handler | ||
* if (isEnter(ev.keyCode)) { | ||
* // handle enter | ||
* } | ||
* ``` | ||
* | ||
* @module core/keymap | ||
*/ | ||
var toLowerCase = function toLowerCase(name) { | ||
@@ -67,3 +56,3 @@ return name ? name.toLowerCase() : ''; | ||
*/ | ||
var forEachObj = (0, _curry2.default)(function (fn, set) { | ||
var forEachObj = curry(function (fn, set) { | ||
Object.keys(set).forEach(function (name) { | ||
@@ -86,3 +75,3 @@ return fn(name, set[name]); | ||
*/ | ||
var oneOrArray = (0, _curry2.default)(function (fn, name, keyCode) { | ||
var oneOrArray = curry(function (fn, name, keyCode) { | ||
if (Array.isArray(keyCode)) { | ||
@@ -106,3 +95,3 @@ keyCode.forEach(fn(name)); | ||
*/ | ||
var addOne = (0, _curry2.default)(function (name, keyCode) { | ||
var addOne = curry(function (name, keyCode) { | ||
name = toLowerCase(name); | ||
@@ -130,3 +119,3 @@ if (name in map) { | ||
*/ | ||
var removeOne = (0, _curry2.default)(function (name, keyCode) { | ||
var removeOne = curry(function (name, keyCode) { | ||
name = toLowerCase(name); | ||
@@ -205,3 +194,3 @@ if (name in map) { | ||
*/ | ||
var is = (0, _curry2.default)(function (name, keyCode) { | ||
var is = curry(function (name, keyCode) { | ||
name = toLowerCase(name); | ||
@@ -211,6 +200,2 @@ return name in map && map[name].indexOf(keyCode) >= 0; | ||
exports.add = add; | ||
exports.addAll = addAll; | ||
exports.is = is; | ||
exports.remove = remove; | ||
exports.removeAll = removeAll; | ||
export { add, addAll, is, remove, removeAll }; |
@@ -1,9 +0,3 @@ | ||
'use strict'; | ||
import * as keymap from '../'; | ||
var _ = require('../'); | ||
var keymap = _interopRequireWildcard(_); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
describe('keymap', function () { | ||
@@ -10,0 +4,0 @@ |
@@ -1,6 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/** | ||
@@ -44,3 +39,3 @@ * Accepts an object of computed property configurations and a property object, passes the property | ||
exports.default = computed; | ||
exports.computed = computed; | ||
export default computed; | ||
export { computed }; |
@@ -1,6 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/** | ||
@@ -19,3 +14,3 @@ * Adds contextTypes to a render | ||
exports.default = contextTypes; | ||
exports.contextTypes = contextTypes; | ||
export default contextTypes; | ||
export { contextTypes }; |
@@ -1,6 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/** | ||
@@ -19,3 +14,3 @@ * Adds default props to a render | ||
exports.default = defaultProps; | ||
exports.defaultProps = defaultProps; | ||
export default defaultProps; | ||
export { defaultProps }; |
@@ -1,8 +0,1 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.handlers = undefined; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -12,8 +5,2 @@ | ||
var _react = require('react'); | ||
var _react2 = _interopRequireDefault(_react); | ||
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"); } } | ||
@@ -25,2 +12,4 @@ | ||
import React from 'react'; | ||
/** | ||
@@ -83,3 +72,3 @@ * Accepts an object of event handlers and a Component and returns a React Component that creates | ||
value: function render() { | ||
return _react2.default.createElement(Component, _extends({}, this.props, this.handlers)); | ||
return React.createElement(Component, _extends({}, this.props, this.handlers)); | ||
} | ||
@@ -89,6 +78,6 @@ }]); | ||
return _class; | ||
}(_react2.default.Component), _class.displayName = 'Handlers(' + (Component.displayName || Component.name || 'Component') + ')', _temp; | ||
}(React.Component), _class.displayName = 'Handlers(' + (Component.displayName || Component.name || 'Component') + ')', _temp; | ||
}; | ||
exports.default = handlers; | ||
exports.handlers = handlers; | ||
export default handlers; | ||
export { handlers }; |
@@ -1,38 +0,9 @@ | ||
'use strict'; | ||
import computed from './computed'; | ||
import contextTypes from './contextTypes'; | ||
import defaultProps from './defaultProps'; | ||
import handlers from './handlers'; | ||
import name from './name'; | ||
import propTypes from './propTypes'; | ||
import styles from './styles'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.kind = undefined; | ||
var _computed = require('./computed'); | ||
var _computed2 = _interopRequireDefault(_computed); | ||
var _contextTypes = require('./contextTypes'); | ||
var _contextTypes2 = _interopRequireDefault(_contextTypes); | ||
var _defaultProps = require('./defaultProps'); | ||
var _defaultProps2 = _interopRequireDefault(_defaultProps); | ||
var _handlers = require('./handlers'); | ||
var _handlers2 = _interopRequireDefault(_handlers); | ||
var _name = require('./name'); | ||
var _name2 = _interopRequireDefault(_name); | ||
var _propTypes = require('./propTypes'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _styles = require('./styles'); | ||
var _styles2 = _interopRequireDefault(_styles); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
@@ -89,4 +60,4 @@ * Creates a stateless functional component with some helpful declarative sugar. | ||
var p = Object.assign({}, props); | ||
if (config.styles) p = (0, _styles2.default)(config.styles, p, context, updater); | ||
if (config.computed) p = (0, _computed2.default)(config.computed, p, context, updater); | ||
if (config.styles) p = styles(config.styles, p, context, updater); | ||
if (config.computed) p = computed(config.computed, p, context, updater); | ||
return config.render(p, context, updater); | ||
@@ -98,10 +69,10 @@ }; | ||
// need to set name and contextTypes on pre-wrapped Component | ||
if (config.contextTypes) (0, _contextTypes2.default)(config.contextTypes, render); | ||
render = (0, _handlers2.default)(config.handlers, render, config.contextTypes); | ||
if (config.contextTypes) contextTypes(config.contextTypes, render); | ||
render = handlers(config.handlers, render, config.contextTypes); | ||
} | ||
if (config.name) (0, _name2.default)(config.name, render); | ||
if (config.propTypes) (0, _propTypes2.default)(config.propTypes, render); | ||
if (config.defaultProps) (0, _defaultProps2.default)(config.defaultProps, render); | ||
if (config.contextTypes) (0, _contextTypes2.default)(config.contextTypes, render); | ||
if (config.name) name(config.name, render); | ||
if (config.propTypes) propTypes(config.propTypes, render); | ||
if (config.defaultProps) defaultProps(config.defaultProps, render); | ||
if (config.contextTypes) contextTypes(config.contextTypes, render); | ||
@@ -114,3 +85,3 @@ // Decorate the SFC with the computed property object in DEV for easier testability | ||
exports.default = kind; | ||
exports.kind = kind; | ||
export default kind; | ||
export { kind }; |
@@ -1,6 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/** | ||
@@ -20,3 +15,3 @@ * Adds displayName to a render | ||
exports.default = name; | ||
exports.name = name; | ||
export default name; | ||
export { name }; |
@@ -1,6 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/** | ||
@@ -19,3 +14,3 @@ * Adds propTypes to a render | ||
exports.default = propTypes; | ||
exports.propTypes = propTypes; | ||
export default propTypes; | ||
export { propTypes }; |
@@ -1,30 +0,10 @@ | ||
'use strict'; | ||
import curry from 'ramda/src/curry'; | ||
import compose from 'ramda/src/compose'; | ||
import merge from 'ramda/src/merge'; | ||
import classnames from 'classnames'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.styles = undefined; | ||
import { addInternalProp } from './util'; | ||
var _curry = require('ramda/src/curry'); | ||
var _curry2 = _interopRequireDefault(_curry); | ||
var _compose = require('ramda/src/compose'); | ||
var _compose2 = _interopRequireDefault(_compose); | ||
var _merge = require('ramda/src/merge'); | ||
var _merge2 = _interopRequireDefault(_merge); | ||
var _classnames = require('classnames'); | ||
var _classnames2 = _interopRequireDefault(_classnames); | ||
var _util = require('./util'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// Joins two strings in a className-friendly way | ||
var joinClasses = (0, _curry2.default)(function (a, b) { | ||
var joinClasses = curry(function (a, b) { | ||
return a + ' ' + b; | ||
@@ -35,3 +15,3 @@ }); | ||
// is falsey, returns the truthy one or the first if both are falsey. | ||
var bothOrEither = (0, _curry2.default)(function (fn, a, b) { | ||
var bothOrEither = curry(function (fn, a, b) { | ||
if (a && b) { | ||
@@ -45,3 +25,3 @@ return fn(a, b); | ||
// Returns either the value for the property or the property name itself | ||
var propOrSelf = (0, _curry2.default)(function (obj, prop) { | ||
var propOrSelf = curry(function (obj, prop) { | ||
return obj && obj[prop] || prop; | ||
@@ -52,3 +32,3 @@ }); | ||
// the class names to their css-modules name | ||
var resolveClassNames = (0, _curry2.default)(function (css, className) { | ||
var resolveClassNames = curry(function (css, className) { | ||
if (css && className) { | ||
@@ -80,3 +60,3 @@ return className.split(' ').map(propOrSelf(css)).join(' '); | ||
return bothOrEither(_merge2.default, componentStyle, authorStyle); | ||
return bothOrEither(merge, componentStyle, authorStyle); | ||
}; | ||
@@ -94,6 +74,6 @@ | ||
if (cfg.css) { | ||
return (0, _compose2.default)(resolveClassNames(cfg.css), _classnames2.default); | ||
return compose(resolveClassNames(cfg.css), classnames); | ||
} | ||
return _classnames2.default; | ||
return classnames; | ||
}; | ||
@@ -110,3 +90,3 @@ | ||
var j = props.styler.join; | ||
return props.className ? (0, _compose2.default)(joinClasses(props.className), j) : j; | ||
return props.className ? compose(joinClasses(props.className), j) : j; | ||
}; | ||
@@ -162,3 +142,3 @@ | ||
// styler should not be automatically spread onto children | ||
(0, _util.addInternalProp)(props, 'styler', { | ||
addInternalProp(props, 'styler', { | ||
join: join(cfg) | ||
@@ -173,3 +153,3 @@ }); | ||
exports.default = styles; | ||
exports.styles = styles; | ||
export default styles; | ||
export { styles }; |
@@ -1,9 +0,5 @@ | ||
'use strict'; | ||
/* globals describe, it, expect */ | ||
var _computed = require('../computed'); | ||
import computed from '../computed'; | ||
var _computed2 = _interopRequireDefault(_computed); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
describe('computed', function () { | ||
@@ -42,3 +38,3 @@ | ||
var updated = (0, _computed2.default)(cfg, props); | ||
var updated = computed(cfg, props); | ||
@@ -62,3 +58,3 @@ var expected = 1; | ||
var updated = (0, _computed2.default)(cfg, props); | ||
var updated = computed(cfg, props); | ||
@@ -86,3 +82,3 @@ var expected = 1; | ||
var updated = (0, _computed2.default)(cfg, props); | ||
var updated = computed(cfg, props); | ||
@@ -95,3 +91,3 @@ var expected = 6; | ||
it('should work with its documented example - sum', function () { | ||
var updated = (0, _computed2.default)(exampleCfg, exampleProps); | ||
var updated = computed(exampleCfg, exampleProps); | ||
@@ -105,3 +101,3 @@ var expected = 9; | ||
it('should work with its documented example - product', function () { | ||
var updated = (0, _computed2.default)(exampleCfg, exampleProps); | ||
var updated = computed(exampleCfg, exampleProps); | ||
@@ -113,2 +109,2 @@ var expected = 24; | ||
}); | ||
}); /* globals describe, it, expect */ | ||
}); |
@@ -1,9 +0,5 @@ | ||
'use strict'; | ||
/* globals describe, it, expect */ | ||
var _contextTypes = require('../contextTypes'); | ||
import contextTypes from '../contextTypes'; | ||
var _contextTypes2 = _interopRequireDefault(_contextTypes); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
describe('contextTypes', function () { | ||
@@ -19,3 +15,3 @@ | ||
(0, _contextTypes2.default)(cfg, render); | ||
contextTypes(cfg, render); | ||
@@ -27,2 +23,2 @@ var expected = true; | ||
}); | ||
}); /* globals describe, it, expect */ | ||
}); |
@@ -1,19 +0,12 @@ | ||
'use strict'; | ||
/* globals describe, it, expect */ | ||
var _react = require('react'); | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
var _react2 = _interopRequireDefault(_react); | ||
import defaultProps from '../defaultProps'; | ||
var _enzyme = require('enzyme'); | ||
var _defaultProps = require('../defaultProps'); | ||
var _defaultProps2 = _interopRequireDefault(_defaultProps); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
describe('defaultProps', function () { | ||
var Simple = function Simple(props) { | ||
return _react2.default.createElement('div', props); | ||
return React.createElement('div', props); | ||
}; | ||
@@ -31,3 +24,3 @@ Simple.defaultProps = { | ||
(0, _defaultProps2.default)(props, render); | ||
defaultProps(props, render); | ||
@@ -41,3 +34,3 @@ var expected = true; | ||
it('should add omitted props', function () { | ||
var subject = (0, _enzyme.shallow)(_react2.default.createElement(Simple, null)); | ||
var subject = shallow(React.createElement(Simple, null)); | ||
@@ -51,3 +44,3 @@ var expected = Simple.defaultProps.children; | ||
it('should add explicitly undefined props', function () { | ||
var subject = (0, _enzyme.shallow)(_react2.default.createElement(Simple, { color: void 0 })); | ||
var subject = shallow(React.createElement(Simple, { color: void 0 })); | ||
@@ -62,3 +55,3 @@ var expected = Simple.defaultProps.color; | ||
var color = 'green'; | ||
var subject = (0, _enzyme.shallow)(_react2.default.createElement(Simple, { color: color })); | ||
var subject = shallow(React.createElement(Simple, { color: color })); | ||
@@ -70,2 +63,2 @@ var expected = color; | ||
}); | ||
}); /* globals describe, it, expect */ | ||
}); |
@@ -1,30 +0,17 @@ | ||
'use strict'; | ||
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; }; | ||
var _react = require('react'); | ||
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; } | ||
var _react2 = _interopRequireDefault(_react); | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { mount } from 'enzyme'; | ||
import kind from '../kind'; | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _enzyme = require('enzyme'); | ||
var _kind = require('../kind'); | ||
var _kind2 = _interopRequireDefault(_kind); | ||
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; } | ||
describe('kind', function () { | ||
var Kind = (0, _kind2.default)({ | ||
var Kind = kind({ | ||
name: 'Kind', | ||
propTypes: { | ||
prop: _propTypes2.default.number.isRequired, | ||
label: _propTypes2.default.string | ||
prop: PropTypes.number.isRequired, | ||
label: PropTypes.string | ||
}, | ||
@@ -35,3 +22,3 @@ defaultProps: { | ||
contextTypes: { | ||
parentLabel: _propTypes2.default.string | ||
parentLabel: PropTypes.string | ||
}, | ||
@@ -56,3 +43,3 @@ styles: { | ||
delete rest.prop; | ||
return _react2.default.createElement( | ||
return React.createElement( | ||
'div', | ||
@@ -73,3 +60,3 @@ _extends({}, rest, { title: label }), | ||
it('should default {label} property', function () { | ||
var subject = _react2.default.createElement(Kind, { prop: 1 }); | ||
var subject = React.createElement(Kind, { prop: 1 }); | ||
@@ -85,3 +72,3 @@ var expected = 'Label'; | ||
// eslint-disable-next-line no-undefined | ||
var subject = _react2.default.createElement(Kind, { prop: 1, label: undefined }); | ||
var subject = React.createElement(Kind, { prop: 1, label: undefined }); | ||
@@ -95,3 +82,3 @@ var expected = 'Label'; | ||
it('should add className defined in styles', function () { | ||
var subject = (0, _enzyme.mount)(_react2.default.createElement(Kind, { prop: 1 })); | ||
var subject = mount(React.createElement(Kind, { prop: 1 })); | ||
@@ -105,3 +92,3 @@ var expected = 'kind'; | ||
it('should compute {value} property', function () { | ||
var subject = (0, _enzyme.mount)(_react2.default.createElement(Kind, { prop: 1 })); | ||
var subject = mount(React.createElement(Kind, { prop: 1 })); | ||
@@ -108,0 +95,0 @@ var expected = 2; |
@@ -1,9 +0,5 @@ | ||
'use strict'; | ||
/* globals describe, it, expect */ | ||
var _name = require('../name'); | ||
import name from '../name'; | ||
var _name2 = _interopRequireDefault(_name); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
describe('name', function () { | ||
@@ -15,3 +11,3 @@ | ||
(0, _name2.default)(cfg, render); | ||
name(cfg, render); | ||
@@ -23,2 +19,2 @@ var expected = cfg; | ||
}); | ||
}); /* globals describe, it, expect */ | ||
}); |
@@ -1,9 +0,5 @@ | ||
'use strict'; | ||
/* globals describe, it, expect */ | ||
var _propTypes = require('../propTypes'); | ||
import propTypes from '../propTypes'; | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
describe('propTypes', function () { | ||
@@ -19,3 +15,3 @@ | ||
(0, _propTypes2.default)(cfg, render); | ||
propTypes(cfg, render); | ||
@@ -27,2 +23,2 @@ var expected = true; | ||
}); | ||
}); /* globals describe, it, expect */ | ||
}); |
@@ -38,3 +38,2 @@ /* globals describe, it, expect */ | ||
}); | ||
*/ | ||
"use strict"; | ||
*/ |
@@ -1,11 +0,7 @@ | ||
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
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; }; /* globals describe, it, expect */ | ||
/* globals describe, it, expect */ | ||
var _styles = require('../styles'); | ||
import styles from '../styles'; | ||
var _styles2 = _interopRequireDefault(_styles); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
describe('styles', function () { | ||
@@ -25,3 +21,3 @@ | ||
var updated = (0, _styles2.default)(cfg, {}); | ||
var updated = styles(cfg, {}); | ||
@@ -40,3 +36,3 @@ var expected = cfg.className; | ||
var updated = (0, _styles2.default)(cfg, {}); | ||
var updated = styles(cfg, {}); | ||
@@ -53,3 +49,3 @@ var expected = css.button; | ||
}; | ||
var updated = (0, _styles2.default)({}, props); | ||
var updated = styles({}, props); | ||
@@ -70,3 +66,3 @@ var expected = props.className; | ||
var updated = (0, _styles2.default)(cfg, props); | ||
var updated = styles(cfg, props); | ||
@@ -88,3 +84,3 @@ var expected = props.className; | ||
var updated = (0, _styles2.default)(cfg, props); | ||
var updated = styles(cfg, props); | ||
@@ -106,3 +102,3 @@ var expected = props.className; | ||
var updated = (0, _styles2.default)(cfg, {}); | ||
var updated = styles(cfg, {}); | ||
@@ -121,3 +117,3 @@ var expected = cfg.style.color; | ||
}; | ||
var updated = (0, _styles2.default)({}, props); | ||
var updated = styles({}, props); | ||
@@ -142,3 +138,3 @@ var expected = props.style.color; | ||
var updated = (0, _styles2.default)(cfg, props); | ||
var updated = styles(cfg, props); | ||
@@ -165,3 +161,3 @@ var expected = 2; | ||
var updated = (0, _styles2.default)(cfg, props); | ||
var updated = styles(cfg, props); | ||
@@ -177,3 +173,3 @@ var expected = 1; | ||
it('should add styler.join() to props', function () { | ||
var updated = (0, _styles2.default)({}, {}); | ||
var updated = styles({}, {}); | ||
@@ -187,3 +183,3 @@ var expected = 'function'; | ||
it('should join classes together with a space', function () { | ||
var updated = (0, _styles2.default)({}, {}); | ||
var updated = styles({}, {}); | ||
@@ -197,3 +193,3 @@ var expected = 'abc def'; | ||
it('should resolve join classes to css map', function () { | ||
var updated = (0, _styles2.default)({ css: css }, {}); | ||
var updated = styles({ css: css }, {}); | ||
@@ -214,3 +210,3 @@ var expected = css.button + ' ' + css.client; | ||
}; | ||
var updated = (0, _styles2.default)(cfg, props); | ||
var updated = styles(cfg, props); | ||
@@ -231,3 +227,3 @@ var expected = css.button + ' button'; | ||
}; | ||
var updated = (0, _styles2.default)(cfg, props); | ||
var updated = styles(cfg, props); | ||
@@ -234,0 +230,0 @@ var expected = css.button + ' button ' + css.client; |
@@ -1,7 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var addInternalProp = exports.addInternalProp = function addInternalProp(props, name, value) { | ||
export var addInternalProp = function addInternalProp(props, name, value) { | ||
if (name in props) { | ||
@@ -8,0 +3,0 @@ props[name] = value; |
{ | ||
"name": "@enact/core", | ||
"version": "1.6.1", | ||
"version": "1.7.0", | ||
"description": "Enact is an open source JavaScript framework containing everything you need to create a fast, scalable mobile or web application.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,24 +0,15 @@ | ||
'use strict'; | ||
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; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.platform = exports.detect = undefined; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
var _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; }; /** | ||
* Exports the {@link core/platform.detect} method and the {@link core/platform.platform} | ||
* object to get information about the current platform. The default export is | ||
* {@link core/platform.platform}. | ||
* | ||
* @module core/platform | ||
*/ | ||
/** | ||
* Exports the {@link core/platform.detect} method and the {@link core/platform.platform} | ||
* object to get information about the current platform. The default export is | ||
* {@link core/platform.platform}. | ||
* | ||
* @module core/platform | ||
*/ | ||
var _uniq = require('ramda/src/uniq'); | ||
import uniq from 'ramda/src/uniq'; | ||
var _uniq2 = _interopRequireDefault(_uniq); | ||
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); } } | ||
var hasGesture = function hasGesture() { | ||
@@ -154,3 +145,3 @@ return Boolean('ongesturestart' in window || 'onmsgesturestart' in window && (window.navigator.msMaxTouchPoints > 1 || window.navigator.maxTouchPoints > 1)); | ||
var platform = {}; | ||
['gesture', 'node', 'platformName', 'touch', 'unknown'].concat(_toConsumableArray((0, _uniq2.default)(platforms.map(function (p) { | ||
['gesture', 'node', 'platformName', 'touch', 'unknown'].concat(_toConsumableArray(uniq(platforms.map(function (p) { | ||
return p.platform; | ||
@@ -167,4 +158,3 @@ })))).forEach(function (name) { | ||
exports.default = platform; | ||
exports.detect = detect; | ||
exports.platform = platform; | ||
export default platform; | ||
export { detect, platform }; |
@@ -1,7 +0,1 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -190,3 +184,3 @@ | ||
exports.default = Job; | ||
exports.Job = Job; | ||
export default Job; | ||
export { Job }; |
@@ -1,13 +0,7 @@ | ||
'use strict'; | ||
import Job from '../Job'; | ||
var _Job = require('../Job'); | ||
var _Job2 = _interopRequireDefault(_Job); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
describe('Job', function () { | ||
describe('#start', function () { | ||
it('should start job', function (done) { | ||
var j = new _Job2.default(done, 10); | ||
var j = new Job(done, 10); | ||
j.start(); | ||
@@ -26,3 +20,3 @@ }); | ||
var j = new _Job2.default(fn, 10); | ||
var j = new Job(fn, 10); | ||
j.start(value); | ||
@@ -35,3 +29,3 @@ }); | ||
var ran = false; | ||
var j = new _Job2.default(function () { | ||
var j = new Job(function () { | ||
ran = true; | ||
@@ -53,3 +47,3 @@ done(new Error('job wasn\'t stopped')); | ||
var number = 0; | ||
var j = new _Job2.default(function () { | ||
var j = new Job(function () { | ||
number++; | ||
@@ -87,3 +81,3 @@ }, 20); | ||
var j = new _Job2.default(fn, 10); | ||
var j = new Job(fn, 10); | ||
j.throttle(value); | ||
@@ -95,3 +89,3 @@ }); | ||
it('should start job', function (done) { | ||
var j = new _Job2.default(done, 10); | ||
var j = new Job(done, 10); | ||
j.idle(); | ||
@@ -110,3 +104,3 @@ }); | ||
var j = new _Job2.default(fn, 10); | ||
var j = new Job(fn, 10); | ||
j.idle(value); | ||
@@ -113,0 +107,0 @@ }); |
103
util/util.js
@@ -1,71 +0,28 @@ | ||
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.extractAriaProps = exports.isRenderable = exports.Job = exports.coerceArray = exports.coerceFunction = exports.childrenEquals = exports.cap = undefined; | ||
/** | ||
* A collection of utility methods. | ||
* | ||
* @module core/util | ||
*/ | ||
import always from 'ramda/src/always'; | ||
import compose from 'ramda/src/compose'; | ||
import equals from 'ramda/src/equals'; | ||
import isType from 'ramda/src/is'; | ||
import map from 'ramda/src/map'; | ||
import prop from 'ramda/src/prop'; | ||
import React from 'react'; | ||
import sort from 'ramda/src/sort'; | ||
import unless from 'ramda/src/unless'; | ||
import useWith from 'ramda/src/useWith'; | ||
import when from 'ramda/src/when'; | ||
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; }; /** | ||
* A collection of utility methods. | ||
* | ||
* @module core/util | ||
*/ | ||
import Job from './Job'; | ||
var _always = require('ramda/src/always'); | ||
var _always2 = _interopRequireDefault(_always); | ||
var _compose = require('ramda/src/compose'); | ||
var _compose2 = _interopRequireDefault(_compose); | ||
var _equals = require('ramda/src/equals'); | ||
var _equals2 = _interopRequireDefault(_equals); | ||
var _is = require('ramda/src/is'); | ||
var _is2 = _interopRequireDefault(_is); | ||
var _map = require('ramda/src/map'); | ||
var _map2 = _interopRequireDefault(_map); | ||
var _prop = require('ramda/src/prop'); | ||
var _prop2 = _interopRequireDefault(_prop); | ||
var _react = require('react'); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _sort = require('ramda/src/sort'); | ||
var _sort2 = _interopRequireDefault(_sort); | ||
var _unless = require('ramda/src/unless'); | ||
var _unless2 = _interopRequireDefault(_unless); | ||
var _useWith = require('ramda/src/useWith'); | ||
var _useWith2 = _interopRequireDefault(_useWith); | ||
var _when = require('ramda/src/when'); | ||
var _when2 = _interopRequireDefault(_when); | ||
var _Job = require('./Job'); | ||
var _Job2 = _interopRequireDefault(_Job); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var orderedKeys = (0, _map2.default)((0, _when2.default)(_react2.default.isValidElement, (0, _prop2.default)('key'))); | ||
var unorderedKeys = (0, _compose2.default)((0, _sort2.default)(function (a, b) { | ||
var orderedKeys = map(when(React.isValidElement, prop('key'))); | ||
var unorderedKeys = compose(sort(function (a, b) { | ||
return a - b; | ||
}), orderedKeys); | ||
var unorderedEquals = (0, _useWith2.default)(_equals2.default, [unorderedKeys, unorderedKeys]); | ||
var orderedEquals = (0, _useWith2.default)(_equals2.default, [orderedKeys, orderedKeys]); | ||
var unorderedEquals = useWith(equals, [unorderedKeys, unorderedKeys]); | ||
var orderedEquals = useWith(equals, [orderedKeys, orderedKeys]); | ||
@@ -86,4 +43,4 @@ /** | ||
var prevChildren = _react2.default.Children.toArray(prev); | ||
var nextChildren = _react2.default.Children.toArray(next); | ||
var prevChildren = React.Children.toArray(prev); | ||
var nextChildren = React.Children.toArray(next); | ||
@@ -96,3 +53,3 @@ if (prevChildren.length !== nextChildren.length) { | ||
return (0, _equals2.default)(c1, c2); | ||
return equals(c1, c2); | ||
} else if (ordered) { | ||
@@ -130,3 +87,3 @@ return orderedEquals(prevChildren, nextChildren); | ||
*/ | ||
var coerceFunction = (0, _unless2.default)((0, _is2.default)(Function), _always2.default); | ||
var coerceFunction = unless(isType(Function), always); | ||
@@ -187,8 +144,2 @@ /** | ||
exports.cap = cap; | ||
exports.childrenEquals = childrenEquals; | ||
exports.coerceFunction = coerceFunction; | ||
exports.coerceArray = coerceArray; | ||
exports.Job = _Job2.default; | ||
exports.isRenderable = isRenderable; | ||
exports.extractAriaProps = extractAriaProps; | ||
export { cap, childrenEquals, coerceFunction, coerceArray, Job, isRenderable, extractAriaProps }; |
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
107282
2994