mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-03-31 10:11:38 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
931d666fcc | ||
|
|
40c433c6df | ||
|
|
9888c2a3c6 | ||
|
|
3fa18becc7 | ||
|
|
aafeb0adad | ||
|
|
89468b7d6e | ||
|
|
f66af5e04d | ||
|
|
2363524fa7 | ||
|
|
5855e55615 | ||
|
|
5033e12d18 |
@@ -74,7 +74,7 @@ recipes" guide.
|
||||
Examples of using React Native for Web with other web tools:
|
||||
|
||||
* [Docz](https://github.com/pedronauck/docz-plugin-react-native)
|
||||
* [Gatsby](https://github.com/gatsbyjs/gatsby/tree/master/examples/using-react-native-web)
|
||||
* [Gatsby](https://github.com/slorber/gatsby-plugin-react-native-web)
|
||||
* [Next.js](https://github.com/zeit/next.js/tree/master/examples/with-react-native-web)
|
||||
* [Phenomic](https://github.com/phenomic/phenomic/tree/master/examples/react-native-web-app)
|
||||
* [Razzle](https://github.com/jaredpalmer/razzle/tree/master/examples/with-react-native-web)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.6",
|
||||
"name": "react-native-web-monorepo",
|
||||
"scripts": {
|
||||
"clean": "del ./packages/*/dist",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "babel-plugin-react-native-web",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.6",
|
||||
"description": "Babel plugin for React Native for Web",
|
||||
"main": "index.js",
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "benchmarks",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.6",
|
||||
"scripts": {
|
||||
"build": "mkdir -p dist && cp -f index.html dist/index.html && ./node_modules/.bin/webpack-cli --config ./webpack.config.js",
|
||||
"release": "yarn build && git checkout gh-pages && rm -rf ../../benchmarks && mv dist ../../benchmarks && git add -A && git commit -m \"Benchmarks deploy\" && git push origin gh-pages && git checkout -"
|
||||
@@ -18,7 +18,7 @@
|
||||
"react-dom": "^16.5.1",
|
||||
"react-fela": "^7.3.1",
|
||||
"react-jss": "^8.6.1",
|
||||
"react-native-web": "0.9.3",
|
||||
"react-native-web": "0.9.6",
|
||||
"reactxp": "^1.3.0",
|
||||
"styled-components": "^3.3.3",
|
||||
"styled-jsx": "^2.2.7",
|
||||
@@ -26,7 +26,7 @@
|
||||
"styletron-react": "^4.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-plugin-react-native-web": "0.9.3",
|
||||
"babel-plugin-react-native-web": "0.9.6",
|
||||
"css-loader": "^1.0.0",
|
||||
"style-loader": "^0.21.0",
|
||||
"url-loader": "^1.0.1",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "react-native-examples",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.6",
|
||||
"scripts": {
|
||||
"build": "mkdir -p dist && cp -f src/index.html dist/index.html && ./node_modules/.bin/webpack-cli --config ./webpack.config.js",
|
||||
"release": "yarn build && git checkout gh-pages && rm -rf ../../examples && mv dist ../../examples && git add -A && git commit -m \"Examples deploy\" && git push origin gh-pages && git checkout -"
|
||||
@@ -10,10 +10,10 @@
|
||||
"babel-runtime": "^6.26.0",
|
||||
"react": "^16.5.1",
|
||||
"react-dom": "^16.5.1",
|
||||
"react-native-web": "0.9.3"
|
||||
"react-native-web": "0.9.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-plugin-react-native-web": "0.9.3",
|
||||
"babel-plugin-react-native-web": "0.9.6",
|
||||
"babel-plugin-transform-runtime": "^6.23.0",
|
||||
"file-loader": "^1.1.11",
|
||||
"webpack": "^4.8.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-web",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.6",
|
||||
"description": "React Native for Web",
|
||||
"module": "dist/index.js",
|
||||
"main": "dist/cjs/index.js",
|
||||
|
||||
@@ -8,11 +8,16 @@
|
||||
* @flow
|
||||
*/
|
||||
|
||||
let clipboardAvailable;
|
||||
|
||||
export default class Clipboard {
|
||||
static isAvailable() {
|
||||
return (
|
||||
typeof document.queryCommandSupported === 'function' && document.queryCommandSupported('copy')
|
||||
);
|
||||
if (clipboardAvailable === undefined) {
|
||||
clipboardAvailable =
|
||||
typeof document.queryCommandSupported === 'function' &&
|
||||
document.queryCommandSupported('copy');
|
||||
}
|
||||
return clipboardAvailable;
|
||||
}
|
||||
|
||||
static getString(): Promise<string> {
|
||||
|
||||
@@ -279,15 +279,13 @@ const styles = StyleSheet.create({
|
||||
...commonStyle,
|
||||
flexDirection: 'column',
|
||||
overflowX: 'hidden',
|
||||
overflowY: 'auto',
|
||||
touchAction: 'pan-y'
|
||||
overflowY: 'auto'
|
||||
},
|
||||
baseHorizontal: {
|
||||
...commonStyle,
|
||||
flexDirection: 'row',
|
||||
overflowX: 'auto',
|
||||
overflowY: 'hidden',
|
||||
touchAction: 'pan-x'
|
||||
overflowY: 'hidden'
|
||||
},
|
||||
contentContainerHorizontal: {
|
||||
flexDirection: 'row'
|
||||
|
||||
@@ -32,11 +32,13 @@ describe('StyleSheet/i18nStyle', () => {
|
||||
test('converts end/start values', () => {
|
||||
const initial = {
|
||||
float: 'start',
|
||||
textAlign: 'end'
|
||||
textAlign: 'end',
|
||||
transitionProperty: 'marginStart'
|
||||
};
|
||||
const expected = {
|
||||
float: 'left',
|
||||
textAlign: 'right'
|
||||
textAlign: 'right',
|
||||
transitionProperty: 'marginLeft'
|
||||
};
|
||||
expect(i18nStyle(initial)).toEqual(expected);
|
||||
});
|
||||
@@ -56,7 +58,8 @@ describe('StyleSheet/i18nStyle', () => {
|
||||
clear: 'left',
|
||||
float: 'left',
|
||||
textAlign: 'right',
|
||||
textShadowOffset: { width: '1rem', height: 10 }
|
||||
textShadowOffset: { width: '1rem', height: 10 },
|
||||
transitionProperty: 'marginLeft'
|
||||
};
|
||||
expect(i18nStyle(initial)).toEqual(initial);
|
||||
});
|
||||
@@ -116,11 +119,13 @@ describe('StyleSheet/i18nStyle', () => {
|
||||
test('converts end/start values', () => {
|
||||
const initial = {
|
||||
float: 'start',
|
||||
textAlign: 'end'
|
||||
textAlign: 'end',
|
||||
transitionProperty: 'marginStart'
|
||||
};
|
||||
const expected = {
|
||||
float: 'right',
|
||||
textAlign: 'left'
|
||||
textAlign: 'left',
|
||||
transitionProperty: 'marginRight'
|
||||
};
|
||||
expect(i18nStyle(initial)).toEqual(expected);
|
||||
});
|
||||
@@ -140,7 +145,8 @@ describe('StyleSheet/i18nStyle', () => {
|
||||
clear: 'left',
|
||||
float: 'left',
|
||||
textAlign: 'right',
|
||||
textShadowOffset: { width: '1rem', height: 10 }
|
||||
textShadowOffset: { width: '1rem', height: 10 },
|
||||
transitionProperty: 'marginLeft'
|
||||
};
|
||||
expect(i18nStyle(initial)).toEqual(initial);
|
||||
});
|
||||
@@ -183,11 +189,13 @@ describe('StyleSheet/i18nStyle', () => {
|
||||
test('converts end/start values', () => {
|
||||
const initial = {
|
||||
float: 'start',
|
||||
textAlign: 'end'
|
||||
textAlign: 'end',
|
||||
transitionProperty: 'marginStart'
|
||||
};
|
||||
const expected = {
|
||||
float: 'right',
|
||||
textAlign: 'left'
|
||||
textAlign: 'left',
|
||||
transitionProperty: 'marginRight'
|
||||
};
|
||||
expect(i18nStyle(initial)).toEqual(expected);
|
||||
});
|
||||
@@ -212,12 +220,14 @@ describe('StyleSheet/i18nStyle', () => {
|
||||
const initial = {
|
||||
float: 'left',
|
||||
textAlign: 'right',
|
||||
textShadowOffset: { width: '1rem', height: 10 }
|
||||
textShadowOffset: { width: '1rem', height: 10 },
|
||||
transitionProperty: 'marginLeft'
|
||||
};
|
||||
const expected = {
|
||||
float: 'right',
|
||||
textAlign: 'left',
|
||||
textShadowOffset: { width: '-1rem', height: 10 }
|
||||
textShadowOffset: { width: '-1rem', height: 10 },
|
||||
transitionProperty: 'marginRight'
|
||||
};
|
||||
expect(i18nStyle(initial)).toEqual(expected);
|
||||
});
|
||||
|
||||
@@ -116,6 +116,19 @@ const i18nStyle = originalStyle => {
|
||||
}
|
||||
}
|
||||
|
||||
// BiDi flip transitionProperty value
|
||||
if (prop === 'transitionProperty') {
|
||||
// BiDi flip properties
|
||||
if (PROPERTIES_I18N.hasOwnProperty(value)) {
|
||||
// convert start/end
|
||||
const convertedValue = PROPERTIES_I18N[originalValue];
|
||||
value = isRTL ? PROPERTIES_FLIP[convertedValue] : convertedValue;
|
||||
} else if (isRTL && doLeftAndRightSwapInRTL && PROPERTIES_FLIP[originalValue]) {
|
||||
value = PROPERTIES_FLIP[originalValue];
|
||||
}
|
||||
}
|
||||
|
||||
// Create finalized style
|
||||
if (isRTL && prop === 'textShadowOffset') {
|
||||
nextStyle[prop] = value;
|
||||
nextStyle[prop].width = additiveInverse(value.width);
|
||||
|
||||
@@ -696,9 +696,16 @@ const TouchableMixin = {
|
||||
const touch = TouchEventUtils.extractSingleTouch(e.nativeEvent);
|
||||
const pageX = touch && touch.pageX;
|
||||
const pageY = touch && touch.pageY;
|
||||
const locationX = touch && touch.locationX;
|
||||
const locationY = touch && touch.locationY;
|
||||
this.pressInLocation = { pageX, pageY, locationX, locationY };
|
||||
this.pressInLocation = {
|
||||
pageX,
|
||||
pageY,
|
||||
get locationX() {
|
||||
return touch && touch.locationX;
|
||||
},
|
||||
get locationY() {
|
||||
return touch && touch.locationY;
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
_getDistanceBetweenPoints: function(aX: number, aY: number, bX: number, bY: number) {
|
||||
|
||||
@@ -8,6 +8,7 @@ const whitelist = {
|
||||
children: true,
|
||||
disabled: true,
|
||||
importantForAccessibility: true,
|
||||
nativeID: true,
|
||||
onBlur: true,
|
||||
onContextMenu: true,
|
||||
onFocus: true,
|
||||
|
||||
@@ -78,6 +78,7 @@ function normalizeTouchEvent(nativeEvent) {
|
||||
typeof nativeEvent.stopPropagation === 'function'
|
||||
? nativeEvent.stopPropagation.bind(nativeEvent)
|
||||
: emptyFunction;
|
||||
const singleChangedTouch = changedTouches[0];
|
||||
|
||||
const event = {
|
||||
_normalized: true,
|
||||
@@ -85,11 +86,15 @@ function normalizeTouchEvent(nativeEvent) {
|
||||
cancelable: nativeEvent.cancelable,
|
||||
changedTouches,
|
||||
defaultPrevented: nativeEvent.defaultPrevented,
|
||||
identifier: undefined,
|
||||
locationX: undefined,
|
||||
locationY: undefined,
|
||||
pageX: nativeEvent.pageX,
|
||||
pageY: nativeEvent.pageY,
|
||||
identifier: singleChangedTouch ? singleChangedTouch.identifier : undefined,
|
||||
get locationX() {
|
||||
return singleChangedTouch ? singleChangedTouch.locationX : undefined;
|
||||
},
|
||||
get locationY() {
|
||||
return singleChangedTouch ? singleChangedTouch.locationY : undefined;
|
||||
},
|
||||
pageX: singleChangedTouch ? singleChangedTouch.pageX : nativeEvent.pageX,
|
||||
pageY: singleChangedTouch ? singleChangedTouch.pageY : nativeEvent.pageY,
|
||||
preventDefault,
|
||||
stopImmediatePropagation,
|
||||
stopPropagation,
|
||||
@@ -102,14 +107,6 @@ function normalizeTouchEvent(nativeEvent) {
|
||||
which: nativeEvent.which
|
||||
};
|
||||
|
||||
if (changedTouches[0]) {
|
||||
event.identifier = changedTouches[0].identifier;
|
||||
event.pageX = changedTouches[0].pageX;
|
||||
event.pageY = changedTouches[0].pageY;
|
||||
event.locationX = changedTouches[0].locationX;
|
||||
event.locationY = changedTouches[0].locationY;
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
@@ -164,8 +161,12 @@ function normalizeMouseEvent(nativeEvent) {
|
||||
changedTouches: touches,
|
||||
defaultPrevented: nativeEvent.defaultPrevented,
|
||||
identifier: touches[0].identifier,
|
||||
locationX: touches[0].locationX,
|
||||
locationY: touches[0].locationY,
|
||||
get locationX() {
|
||||
return touches[0].locationX;
|
||||
},
|
||||
get locationY() {
|
||||
return touches[0].locationY;
|
||||
},
|
||||
pageX: nativeEvent.pageX,
|
||||
pageY: nativeEvent.pageY,
|
||||
preventDefault,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import UIManager from '../../../exports/UIManager';
|
||||
|
||||
const __DEV__ = process.env.NODE !== 'production';
|
||||
const __DEV__ = process.env.NODE_ENV !== 'production';
|
||||
const { checkPropTypes } = PropTypes;
|
||||
|
||||
const Types = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "website",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.6",
|
||||
"scripts": {
|
||||
"build": "build-storybook -o ./dist -c ./storybook/.storybook",
|
||||
"start": "start-storybook -p 9001 -c ./storybook/.storybook",
|
||||
@@ -12,10 +12,10 @@
|
||||
"@storybook/react": "^3.4.3",
|
||||
"react": "^16.5.1",
|
||||
"react-dom": "^16.5.1",
|
||||
"react-native-web": "0.9.3"
|
||||
"react-native-web": "0.9.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-plugin-react-native-web": "0.9.3",
|
||||
"babel-plugin-react-native-web": "0.9.6",
|
||||
"url-loader": "^1.0.1",
|
||||
"webpack": "^4.8.1"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user