Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
Moved babel config into CLI. Cherry pick from lodash and recompose
Browse files Browse the repository at this point in the history
  • Loading branch information
asgvard committed Feb 5, 2019
1 parent 47c6700 commit 75431ff
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 123 deletions.
12 changes: 6 additions & 6 deletions dist/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ Object.defineProperty(exports, "__esModule", {
value: true
});

var _shuffle2 = require('lodash/shuffle');

var _shuffle3 = _interopRequireDefault(_shuffle2);

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 _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; }; }();
Expand All @@ -20,6 +16,10 @@ var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _shuffle = require('lodash/shuffle');

var _shuffle2 = _interopRequireDefault(_shuffle);

var _reactNative = require('react-native');

var _withFocusable = require('./withFocusable');
Expand Down Expand Up @@ -104,15 +104,15 @@ var styles = _reactNative.StyleSheet.create({
}
});

var categories = (0, _shuffle3.default)([{
var categories = (0, _shuffle2.default)([{
title: 'Featured'
}, {
title: 'Cool'
}, {
title: 'Decent'
}]);

var programs = (0, _shuffle3.default)([{
var programs = (0, _shuffle2.default)([{
title: 'Program 1',
color: '#337fdd'
}, {
Expand Down
42 changes: 21 additions & 21 deletions dist/spatialNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ Object.defineProperty(exports, "__esModule", {
});
exports.ROOT_FOCUS_KEY = undefined;

var _findKey2 = require('lodash/findKey');
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 _findKey3 = _interopRequireDefault(_findKey2);
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 _sortBy2 = require('lodash/sortBy');
var _DEFAULT_KEY_MAP;

var _sortBy3 = _interopRequireDefault(_sortBy2);
var _filter = require('lodash/filter');

var _first3 = require('lodash/first');
var _filter2 = _interopRequireDefault(_filter);

var _first4 = _interopRequireDefault(_first3);
var _first2 = require('lodash/first');

var _filter2 = require('lodash/filter');
var _first3 = _interopRequireDefault(_first2);

var _filter3 = _interopRequireDefault(_filter2);
var _sortBy = require('lodash/sortBy');

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 _sortBy2 = _interopRequireDefault(_sortBy);

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 _findKey = require('lodash/findKey');

var _DEFAULT_KEY_MAP;
var _findKey2 = _interopRequireDefault(_findKey);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

Expand Down Expand Up @@ -119,7 +119,7 @@ var SpatialNavigation = function () {

if (window) {
this.tvEventListener = function (event) {
var eventType = (0, _findKey3.default)(_this.getKeyMap(), function (code) {
var eventType = (0, _findKey2.default)(_this.getKeyMap(), function (code) {
return event.keyCode === code;
});

Expand Down Expand Up @@ -161,7 +161,7 @@ var SpatialNavigation = function () {
}, {
key: 'onKeyEvent',
value: function onKeyEvent(keyCode) {
var direction = (0, _findKey3.default)(this.getKeyMap(), function (code) {
var direction = (0, _findKey2.default)(this.getKeyMap(), function (code) {
return keyCode === code;
});

Expand Down Expand Up @@ -192,23 +192,23 @@ var SpatialNavigation = function () {
/**
* Get only the siblings with the coords on the way of our moving direction
*/
var siblings = (0, _filter3.default)(this.focusableComponents, function (component) {
var siblings = (0, _filter2.default)(this.focusableComponents, function (component) {
return component.parentFocusKey === parentFocusKey && (isIncrementalDirection && component.layout[coordinate] > layout[coordinate] || !isIncrementalDirection && component.layout[coordinate] < layout[coordinate]);
});

var currentReferencePoints = SpatialNavigation.getReferencePoints(direction, false, layout);
var currentReferenceX = currentReferencePoints.resultX;
var currentReferenceY = currentReferencePoints.resultY;

var sortedSiblings = (0, _sortBy3.default)(siblings, function (sibling) {
var sortedSiblings = (0, _sortBy2.default)(siblings, function (sibling) {
var siblingReferencePoints = SpatialNavigation.getReferencePoints(direction, true, sibling.layout);
var siblingReferenceX = siblingReferencePoints.resultX;
var siblingReferenceY = siblingReferencePoints.resultY;

return Math.sqrt(Math.pow(siblingReferenceX - currentReferenceX, 2) + Math.pow(siblingReferenceY - currentReferenceY, 2));
});

var nextComponent = (0, _first4.default)(sortedSiblings);
var nextComponent = (0, _first3.default)(sortedSiblings);

if (nextComponent) {
this.setFocus && this.setFocus(nextComponent.focusKey);
Expand Down Expand Up @@ -239,7 +239,7 @@ var SpatialNavigation = function () {
return targetFocusKey;
}

var children = (0, _filter3.default)(this.focusableComponents, function (component) {
var children = (0, _filter2.default)(this.focusableComponents, function (component) {
return component.parentFocusKey === targetFocusKey;
});

Expand All @@ -259,15 +259,15 @@ var SpatialNavigation = function () {
/**
* If there is no lastFocusedChild, trying to focus something by coordinates
*/
var sortedXChildren = (0, _sortBy3.default)(children, function (child) {
var sortedXChildren = (0, _sortBy2.default)(children, function (child) {
return child.layout.left;
});
var sortedYChildren = (0, _sortBy3.default)(sortedXChildren, function (child) {
var sortedYChildren = (0, _sortBy2.default)(sortedXChildren, function (child) {
return child.layout.top;
});

var _first2 = (0, _first4.default)(sortedYChildren),
childKey = _first2.focusKey;
var _first = (0, _first3.default)(sortedYChildren),
childKey = _first.focusKey;

/**
* If the target node is propagating focus, try to target first child
Expand Down
80 changes: 40 additions & 40 deletions dist/withFocusable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,61 @@ Object.defineProperty(exports, "__esModule", {
value: true
});

var _pure2 = require('recompose/pure');
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 _pure3 = _interopRequireDefault(_pure2);
var _reactDom = require('react-dom');

var _getContext2 = require('recompose/getContext');
var _propTypes = require('prop-types');

var _getContext3 = _interopRequireDefault(_getContext2);
var _propTypes2 = _interopRequireDefault(_propTypes);

var _withStateHandlers2 = require('recompose/withStateHandlers');
var _uniqueId = require('lodash/uniqueId');

var _withStateHandlers3 = _interopRequireDefault(_withStateHandlers2);
var _uniqueId2 = _interopRequireDefault(_uniqueId);

var _withContext2 = require('recompose/withContext');
var _indexOf = require('lodash/indexOf');

var _withContext3 = _interopRequireDefault(_withContext2);
var _indexOf2 = _interopRequireDefault(_indexOf);

var _withHandlers2 = require('recompose/withHandlers');
var _noop = require('lodash/noop');

var _withHandlers3 = _interopRequireDefault(_withHandlers2);
var _noop2 = _interopRequireDefault(_noop);

var _setPropTypes2 = require('recompose/setPropTypes');
var _compose = require('recompose/compose');

var _setPropTypes3 = _interopRequireDefault(_setPropTypes2);
var _compose2 = _interopRequireDefault(_compose);

var _lifecycle2 = require('recompose/lifecycle');
var _mapProps = require('recompose/mapProps');

var _lifecycle3 = _interopRequireDefault(_lifecycle2);
var _mapProps2 = _interopRequireDefault(_mapProps);

var _mapProps2 = require('recompose/mapProps');
var _lifecycle = require('recompose/lifecycle');

var _mapProps3 = _interopRequireDefault(_mapProps2);
var _lifecycle2 = _interopRequireDefault(_lifecycle);

var _compose2 = require('recompose/compose');
var _setPropTypes = require('recompose/setPropTypes');

var _compose3 = _interopRequireDefault(_compose2);
var _setPropTypes2 = _interopRequireDefault(_setPropTypes);

var _noop2 = require('lodash/noop');
var _withHandlers = require('recompose/withHandlers');

var _noop3 = _interopRequireDefault(_noop2);
var _withHandlers2 = _interopRequireDefault(_withHandlers);

var _indexOf2 = require('lodash/indexOf');
var _withContext = require('recompose/withContext');

var _indexOf3 = _interopRequireDefault(_indexOf2);
var _withContext2 = _interopRequireDefault(_withContext);

var _uniqueId2 = require('lodash/uniqueId');
var _withStateHandlers = require('recompose/withStateHandlers');

var _uniqueId3 = _interopRequireDefault(_uniqueId2);
var _withStateHandlers2 = _interopRequireDefault(_withStateHandlers);

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 _getContext = require('recompose/getContext');

var _reactDom = require('react-dom');
var _getContext2 = _interopRequireDefault(_getContext);

var _propTypes = require('prop-types');
var _pure = require('recompose/pure');

var _propTypes2 = _interopRequireDefault(_propTypes);
var _pure2 = _interopRequireDefault(_pure);

var _spatialNavigation = require('./spatialNavigation');

Expand All @@ -81,23 +81,23 @@ var withFocusable = function withFocusable() {
configPropagateFocus = _ref$propagateFocus === undefined ? false : _ref$propagateFocus;

return function (BaseComponent) {
return (0, _compose3.default)(_withSpatialNavigationContext.getSpatialNavigationContext, (0, _getContext3.default)({
return (0, _compose2.default)(_withSpatialNavigationContext.getSpatialNavigationContext, (0, _getContext2.default)({
/**
* From the context provided by another higher-level 'withFocusable' component
*/
parentFocusKey: _propTypes2.default.string
}), (0, _withStateHandlers3.default)(function (_ref2) {
}), (0, _withStateHandlers2.default)(function (_ref2) {
var focusKey = _ref2.focusKey,
_ref2$setFocus = _ref2.setFocus,
setFocus = _ref2$setFocus === undefined ? _noop3.default : _ref2$setFocus;
setFocus = _ref2$setFocus === undefined ? _noop2.default : _ref2$setFocus;

var realFocusKey = focusKey || (0, _uniqueId3.default)('sn:focusable-item-');
var realFocusKey = focusKey || (0, _uniqueId2.default)('sn:focusable-item-');

return {
realFocusKey: realFocusKey,
setFocus: setFocus.bind(null, realFocusKey)
};
}, {}), (0, _mapProps3.default)(function (_ref3) {
}, {}), (0, _mapProps2.default)(function (_ref3) {
var currentFocusKey = _ref3.currentFocusKey,
parentsHavingFocusedChild = _ref3.parentsHavingFocusedChild,
realFocusKey = _ref3.realFocusKey,
Expand All @@ -106,32 +106,32 @@ var withFocusable = function withFocusable() {
return _extends({}, props, {
realFocusKey: realFocusKey,
focused: currentFocusKey === realFocusKey,
hasFocusedChild: (0, _indexOf3.default)(parentsHavingFocusedChild, realFocusKey) > -1
hasFocusedChild: (0, _indexOf2.default)(parentsHavingFocusedChild, realFocusKey) > -1
});
}),

/**
* Propagate it's own 'focusKey' as a 'parentFocusKey' to it's children
*/
(0, _withContext3.default)({
(0, _withContext2.default)({
parentFocusKey: _propTypes2.default.string
}, function (_ref4) {
var realFocusKey = _ref4.realFocusKey;
return {
parentFocusKey: realFocusKey
};
}), (0, _withHandlers3.default)({
}), (0, _withHandlers2.default)({
onEnterPressHandler: function onEnterPressHandler(_ref5) {
var _ref5$onEnterPress = _ref5.onEnterPress,
onEnterPress = _ref5$onEnterPress === undefined ? _noop3.default : _ref5$onEnterPress;
onEnterPress = _ref5$onEnterPress === undefined ? _noop2.default : _ref5$onEnterPress;
return onEnterPress;
},
onBecameFocusedHandler: function onBecameFocusedHandler(_ref6) {
var _ref6$onBecameFocused = _ref6.onBecameFocused,
onBecameFocused = _ref6$onBecameFocused === undefined ? _noop3.default : _ref6$onBecameFocused;
onBecameFocused = _ref6$onBecameFocused === undefined ? _noop2.default : _ref6$onBecameFocused;
return onBecameFocused;
}
}), (0, _lifecycle3.default)({
}), (0, _lifecycle2.default)({
updateLayout: function updateLayout() {
var focusKey = this.props.realFocusKey;

Expand Down Expand Up @@ -189,7 +189,7 @@ var withFocusable = function withFocusable() {
focusKey: focusKey
});
}
}), _pure3.default, (0, _setPropTypes3.default)({
}), _pure2.default, (0, _setPropTypes2.default)({
focusKey: _propTypes2.default.string,
propagateFocus: _propTypes2.default.bool,
onEnterPress: _propTypes2.default.func,
Expand Down
32 changes: 16 additions & 16 deletions dist/withSpatialNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ Object.defineProperty(exports, "__esModule", {
value: true
});

var _pure2 = require('recompose/pure');
var _propTypes = require('prop-types');

var _pure3 = _interopRequireDefault(_pure2);
var _propTypes2 = _interopRequireDefault(_propTypes);

var _withContext2 = require('recompose/withContext');
var _compose = require('recompose/compose');

var _withContext3 = _interopRequireDefault(_withContext2);
var _compose2 = _interopRequireDefault(_compose);

var _withStateHandlers2 = require('recompose/withStateHandlers');
var _lifecycle = require('recompose/lifecycle');

var _withStateHandlers3 = _interopRequireDefault(_withStateHandlers2);
var _lifecycle2 = _interopRequireDefault(_lifecycle);

var _lifecycle2 = require('recompose/lifecycle');
var _withContext = require('recompose/withContext');

var _lifecycle3 = _interopRequireDefault(_lifecycle2);
var _withContext2 = _interopRequireDefault(_withContext);

var _compose2 = require('recompose/compose');
var _withStateHandlers = require('recompose/withStateHandlers');

var _compose3 = _interopRequireDefault(_compose2);
var _withStateHandlers2 = _interopRequireDefault(_withStateHandlers);

var _propTypes = require('prop-types');
var _pure = require('recompose/pure');

var _propTypes2 = _interopRequireDefault(_propTypes);
var _pure2 = _interopRequireDefault(_pure);

var _spatialNavigation = require('./spatialNavigation');

Expand All @@ -45,7 +45,7 @@ var withSpatialNavigation = function withSpatialNavigation() {
_spatialNavigation2.default.setKeyMap(keyMap);
}

return (0, _compose3.default)((0, _withStateHandlers3.default)({
return (0, _compose2.default)((0, _withStateHandlers2.default)({
currentFocusKey: _spatialNavigation2.default.getCurrentFocusedKey(),

/**
Expand Down Expand Up @@ -89,20 +89,20 @@ var withSpatialNavigation = function withSpatialNavigation() {
/**
* Propagate parentFocusKey as ROOT
*/
(0, _withContext3.default)({
(0, _withContext2.default)({
parentFocusKey: _propTypes2.default.string
}, function () {
return {
parentFocusKey: _spatialNavigation.ROOT_FOCUS_KEY
};
}), (0, _lifecycle3.default)({
}), (0, _lifecycle2.default)({
componentDidMount: function componentDidMount() {
_spatialNavigation2.default.init(this.props.setFocus);
},
componentWillUnmount: function componentWillUnmount() {
_spatialNavigation2.default.destroy();
}
}), _pure3.default)(BaseComponent);
}), _pure2.default)(BaseComponent);
};
};

Expand Down
Loading

0 comments on commit 75431ff

Please sign in to comment.