Skip to content

Commit

Permalink
[change] use ES2015 modules
Browse files Browse the repository at this point in the history
Ref #102
  • Loading branch information
necolas committed Jun 10, 2017
1 parent 060d96b commit 43d297b
Show file tree
Hide file tree
Showing 101 changed files with 210 additions and 240 deletions.
6 changes: 3 additions & 3 deletions docs/storybook/components/TextInput/TextInputExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import React from 'react';
import { storiesOf } from '@kadira/storybook';
import UIExplorer from '../../UIExplorer';
import { any, bool, object, string } from 'prop-types';
import { StyleSheet, Text, TextInput, View } from 'react-native';
import { any, bool, string } from 'prop-types';
import { StyleSheet, Text, TextInput, TextPropTypes, View } from 'react-native';

class WithLabel extends React.Component {
static propTypes = {
Expand Down Expand Up @@ -320,7 +320,7 @@ class SelectionExample extends React.Component {

static propTypes = {
multiline: bool,
style: object,
style: TextPropTypes.style,
value: string
};

Expand Down
6 changes: 3 additions & 3 deletions docs/storybook/components/View/ViewTransformsExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ class Flip extends React.Component {
this._animate();
}

_animate() {
_animate = () => {
this.state.theta.setValue(0);
Animated.timing(this.state.theta, {
toValue: 360,
duration: 5000
}).start(this._animate);
}
};

render() {
return (
Expand Down Expand Up @@ -255,4 +255,4 @@ const examples = [
}
];

module.exports = examples;
export default examples;
2 changes: 1 addition & 1 deletion docs/storybook/demos/Calculator/Calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,4 +438,4 @@ const calculatorStyles = StyleSheet.create({
}
});

module.exports = Calculator;
export default Calculator;
2 changes: 1 addition & 1 deletion docs/storybook/demos/Game2048/Game2048.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,4 @@ const styles = StyleSheet.create({

AppRegistry.registerComponent('Game2048', () => Game2048);

module.exports = Game2048;
export default Game2048;
2 changes: 1 addition & 1 deletion docs/storybook/demos/Game2048/GameBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,4 @@ Board.prototype.hasLost = function() {
return !canMove;
};

module.exports = Board;
export default Board;
2 changes: 1 addition & 1 deletion docs/storybook/demos/TicTacToe/TicTacToe.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,4 @@ const styles = StyleSheet.create({

AppRegistry.registerComponent('TicTacToeApp', () => TicTacToeApp);

module.exports = TicTacToeApp;
export default TicTacToeApp;
4 changes: 3 additions & 1 deletion src/apis/Animated/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import View from '../../components/View';

Animated.inject.FlattenStyle(StyleSheet.flatten);

module.exports = {
const AnimatedImplementation = {
...Animated,
Image: Animated.createAnimatedComponent(Image),
ScrollView: Animated.createAnimatedComponent(ScrollView),
Text: Animated.createAnimatedComponent(Text),
View: Animated.createAnimatedComponent(View)
};

export default AnimatedImplementation;
4 changes: 1 addition & 3 deletions src/apis/AppRegistry/AppContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type State = {
mainKey: number
};

class AppContainer extends Component {
export default class AppContainer extends Component {
props: Props;
state: State = { mainKey: 1 };

Expand Down Expand Up @@ -61,5 +61,3 @@ const styles = StyleSheet.create({
flex: 1
}
});

module.exports = AppContainer;
4 changes: 1 addition & 3 deletions src/apis/AppRegistry/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type AppConfig = {
/**
* `AppRegistry` is the JS entry point to running all React Native apps.
*/
class AppRegistry {
export default class AppRegistry {
static getAppKeys(): Array<string> {
return Object.keys(runnables);
}
Expand Down Expand Up @@ -90,5 +90,3 @@ class AppRegistry {
unmountComponentAtNode(rootTag);
}
}

module.exports = AppRegistry;
4 changes: 1 addition & 3 deletions src/apis/AppState/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const AppStates = {

const listeners = [];

class AppState {
export default class AppState {
static isAvailable = ExecutionEnvironment.canUseDOM && document.visibilityState;

static get currentState() {
Expand Down Expand Up @@ -65,5 +65,3 @@ class AppState {
}
}
}

module.exports = AppState;
4 changes: 1 addition & 3 deletions src/apis/AsyncStorage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const createPromiseAll = (promises, callback, processResult) => {
);
};

class AsyncStorage {
export default class AsyncStorage {
/**
* Erases *all* AsyncStorage for the domain.
*/
Expand Down Expand Up @@ -147,5 +147,3 @@ class AsyncStorage {
return createPromiseAll(promises, callback);
}
}

module.exports = AsyncStorage;
2 changes: 1 addition & 1 deletion src/apis/BackAndroid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ const BackAndroid = {
removeEventListener: emptyFunction
};

module.exports = BackAndroid;
export default BackAndroid;
4 changes: 1 addition & 3 deletions src/apis/Clipboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @flow
*/

class Clipboard {
export default class Clipboard {
static isSupported() {
return (
typeof document.queryCommandSupported === 'function' && document.queryCommandSupported('copy')
Expand Down Expand Up @@ -47,5 +47,3 @@ class Clipboard {
return success;
}
}

module.exports = Clipboard;
4 changes: 1 addition & 3 deletions src/apis/Dimensions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const win = canUseDOM

const dimensions = {};

class Dimensions {
export default class Dimensions {
static get(dimension: string): Object {
invariant(dimensions[dimension], `No dimension set for key ${dimension}`);
return dimensions[dimension];
Expand Down Expand Up @@ -52,5 +52,3 @@ Dimensions.set();
if (canUseDOM) {
window.addEventListener('resize', debounce(Dimensions.set, 16), false);
}

module.exports = Dimensions;
2 changes: 1 addition & 1 deletion src/apis/I18nManager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ const I18nManager: I18nManagerStatus = {
}
};

module.exports = I18nManager;
export default I18nManager;
2 changes: 1 addition & 1 deletion src/apis/InteractionManager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ const InteractionManager = {
addListener: () => {}
};

module.exports = InteractionManager;
export default InteractionManager;
2 changes: 1 addition & 1 deletion src/apis/Linking/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ const iframeOpen = url => {
}
};

module.exports = Linking;
export default Linking;
2 changes: 1 addition & 1 deletion src/apis/NetInfo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ const NetInfo = {
}
};

module.exports = NetInfo;
export default NetInfo;
6 changes: 2 additions & 4 deletions src/apis/PanResponder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* All rights reserved.
*/

'use strict';

var TouchHistoryMath = require('../../vendor/TouchHistoryMath');
import TouchHistoryMath from '../../vendor/TouchHistoryMath';

var currentCentroidXOfTouchesChangedAfter = TouchHistoryMath.currentCentroidXOfTouchesChangedAfter;
var currentCentroidYOfTouchesChangedAfter = TouchHistoryMath.currentCentroidYOfTouchesChangedAfter;
Expand Down Expand Up @@ -385,4 +383,4 @@ var PanResponder = {
}
};

module.exports = PanResponder;
export default PanResponder;
4 changes: 1 addition & 3 deletions src/apis/PixelRatio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Dimensions from '../Dimensions';
/**
* PixelRatio gives access to the device pixel density.
*/
class PixelRatio {
export default class PixelRatio {
/**
* Returns the device pixel density.
*/
Expand Down Expand Up @@ -45,5 +45,3 @@ class PixelRatio {
return Math.round(layoutSize * ratio) / ratio;
}
}

module.exports = PixelRatio;
2 changes: 1 addition & 1 deletion src/apis/Platform/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ const Platform = {
select: (obj: Object) => ('web' in obj ? obj.web : obj.default)
};

module.exports = Platform;
export default Platform;
4 changes: 1 addition & 3 deletions src/apis/StyleSheet/StyleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const pointerEventsCss =
`.${pointerEvents.boxOnly} *{pointer-events:none;}\n` +
`.${pointerEvents.none}{pointer-events:none;}`;

class StyleManager {
export default class StyleManager {
constructor() {
// custom pointer event values are implemented using descendent selectors,
// so we manually create the CSS and pre-register the declarations
Expand Down Expand Up @@ -131,5 +131,3 @@ class StyleManager {
cache.byClassName[className] = { prop, value };
}
}

module.exports = StyleManager;
4 changes: 1 addition & 3 deletions src/apis/StyleSheet/StyleRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const createCacheKey = id => {

const classListToString = list => list.join(' ').trim();

class StyleRegistry {
export default class StyleRegistry {
constructor() {
this.cache = { ltr: {}, rtl: {} };
this.styleManager = new StyleManager();
Expand Down Expand Up @@ -189,5 +189,3 @@ class StyleRegistry {
return this._resolveStyle(style, options);
}
}

module.exports = StyleRegistry;
4 changes: 1 addition & 3 deletions src/apis/StyleSheet/StyleSheetValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { oneOf, string } from 'prop-types';
// plz don't fire me.
const ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';

class StyleSheetValidation {
export default class StyleSheetValidation {
static validateStyleProp(prop, style, caller) {
if (process.env.NODE_ENV !== 'production') {
if (allStylePropTypes[prop] === undefined) {
Expand Down Expand Up @@ -89,5 +89,3 @@ StyleSheetValidation.addValidStylePropTypes({
listStyle: string,
pointerEvents: string
});

module.exports = StyleSheetValidation;
2 changes: 1 addition & 1 deletion src/apis/StyleSheet/createReactDOMStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,4 @@ const createReactDOMStyle = style => {
return resolvedStyle;
};

module.exports = createReactDOMStyle;
export default createReactDOMStyle;
2 changes: 1 addition & 1 deletion src/apis/StyleSheet/flattenStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ function flattenStyle(style: ?StyleObj): ?Object {
return result;
}

module.exports = flattenStyle;
export default flattenStyle;
2 changes: 1 addition & 1 deletion src/apis/StyleSheet/generateCss.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ const createDeclarationString = (prop, val) => {
const generateCss = style =>
mapKeyValue(prefixStyles(style), createDeclarationString).sort().join(';');

module.exports = generateCss;
export default generateCss;
3 changes: 2 additions & 1 deletion src/apis/StyleSheet/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ function murmurhash2_32_gc(str, seed) {
return h >>> 0;
}

module.exports = str => murmurhash2_32_gc(str, 1).toString(36);
const hash = str => murmurhash2_32_gc(str, 1).toString(36);
export default hash;
2 changes: 1 addition & 1 deletion src/apis/StyleSheet/i18nStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ const i18nStyle = originalStyle => {
return nextStyle;
};

module.exports = i18nStyle;
export default i18nStyle;
7 changes: 5 additions & 2 deletions src/apis/StyleSheet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ const absoluteFillObject = {
};
const absoluteFill = StyleRegistry.register(absoluteFillObject);

module.exports = {
const StyleSheet = {
absoluteFill,
absoluteFillObject,
create(styles) {
const result = {};
Object.keys(styles).forEach(key => {
if (process.env.NODE_ENV !== 'production') {
require('./StyleSheetValidation').validateStyle(key, styles);
const StyleSheetValidation = require('./StyleSheetValidation').default;
StyleSheetValidation.validateStyle(key, styles);
}
result[key] = StyleRegistry.register(styles[key]);
});
Expand All @@ -29,3 +30,5 @@ module.exports = {
return StyleRegistry.getStyleSheetHtml();
}
};

export default StyleSheet;
2 changes: 1 addition & 1 deletion src/apis/StyleSheet/normalizeValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ const normalizeValue = (property, value) => {
return value;
};

module.exports = normalizeValue;
export default normalizeValue;
2 changes: 1 addition & 1 deletion src/apis/StyleSheet/registry.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import StyleRegistry from './StyleRegistry';
const registry = new StyleRegistry();
module.exports = registry;
export default registry;
3 changes: 1 addition & 2 deletions src/apis/StyleSheet/staticCss.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports =
'html{' + // css reset
export default 'html{' + // css reset
'font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;' +
'-webkit-tap-highlight-color:rgba(0,0,0,0);' +
'}\n' +
Expand Down
2 changes: 1 addition & 1 deletion src/apis/UIManager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ const UIManager = {
}
};

module.exports = UIManager;
export default UIManager;
2 changes: 1 addition & 1 deletion src/apis/Vibration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ const Vibration = {
}
};

module.exports = Vibration;
export default Vibration;
2 changes: 1 addition & 1 deletion src/components/ActivityIndicator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ const indicatorSizes = StyleSheet.create({
}
});

module.exports = applyNativeMethods(ActivityIndicator);
export default applyNativeMethods(ActivityIndicator);
2 changes: 1 addition & 1 deletion src/components/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ const styles = StyleSheet.create({
}
});

module.exports = Button;
export default Button;
2 changes: 1 addition & 1 deletion src/components/Image/ImageResizeMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ const ImageResizeMode = {
stretch: 'stretch'
};

module.exports = ImageResizeMode;
export default ImageResizeMode;
Loading

0 comments on commit 43d297b

Please sign in to comment.