Compare commits

..

10 Commits
0.9.2 ... 0.9.5

Author SHA1 Message Date
Nicolas Gallagher
3fa18becc7 0.9.5 2018-10-29 18:04:02 -07:00
Nicolas Gallagher
aafeb0adad [fix] RTL support for 'transitionProperty' style
The 'transitionProperty' value can be any property and this patch processes
those values in the same way as properties.

Fix #1131
2018-10-29 13:20:09 -07:00
Nicolas Gallagher
89468b7d6e 0.9.4 2018-10-22 20:06:58 -07:00
Nicolas Gallagher
f66af5e04d Update Gatsby plugin link 2018-10-22 20:03:49 -07:00
Mo Kouli
2363524fa7 [fix] process.env.NODE -> process.env.NODE_ENV
Close #1145
2018-10-22 19:14:04 -07:00
Charlie Croom
5855e55615 [fix] cache Clipboard.isAvailable() value
Fix #1149
Close #1150
2018-10-22 19:10:56 -07:00
Charlie Croom
5033e12d18 Add nativeID to View supported props filter
Close #1147
2018-10-22 18:18:53 -07:00
Nicolas Gallagher
d6e8530f4d 0.9.3 2018-10-11 17:40:41 -07:00
Charlie Croom
ad188a7ad6 [fix] Memory leak in applyLayout registry
Remove component instances from the layout registry when umounting views
that are using ResizeObserver.

Fix #1133
Close #1134
2018-10-11 17:35:04 -07:00
Nicolas Gallagher
bfaeae904e [add] View/Text prop nativeID
Maps the View and Text prop 'nativeID' to DOM 'id' as these are
equivalent.  Enables declarative use of various 'aria-*' properties that
require ID references.

Ref #1116
Close #1130
2018-10-11 17:33:08 -07:00
19 changed files with 85 additions and 28 deletions

View File

@@ -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)

View File

@@ -1,6 +1,6 @@
{
"private": true,
"version": "0.9.2",
"version": "0.9.5",
"name": "react-native-web-monorepo",
"scripts": {
"clean": "del ./packages/*/dist",

View File

@@ -1,6 +1,6 @@
{
"name": "babel-plugin-react-native-web",
"version": "0.9.2",
"version": "0.9.5",
"description": "Babel plugin for React Native for Web",
"main": "index.js",
"devDependencies": {

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "benchmarks",
"version": "0.9.2",
"version": "0.9.5",
"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.2",
"react-native-web": "0.9.5",
"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.2",
"babel-plugin-react-native-web": "0.9.5",
"css-loader": "^1.0.0",
"style-loader": "^0.21.0",
"url-loader": "^1.0.1",

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "react-native-examples",
"version": "0.9.2",
"version": "0.9.5",
"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.2"
"react-native-web": "0.9.5"
},
"devDependencies": {
"babel-plugin-react-native-web": "0.9.2",
"babel-plugin-react-native-web": "0.9.5",
"babel-plugin-transform-runtime": "^6.23.0",
"file-loader": "^1.1.11",
"webpack": "^4.8.1",

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-web",
"version": "0.9.2",
"version": "0.9.5",
"description": "React Native for Web",
"module": "dist/index.js",
"main": "dist/cjs/index.js",

View File

@@ -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> {

View File

@@ -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);
});

View File

@@ -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);

View File

@@ -21,6 +21,7 @@ const TextPropTypes = {
accessible: bool,
children: any,
importantForAccessibility: oneOf(['auto', 'no', 'no-hide-descendants', 'yes']),
nativeID: string,
numberOfLines: number,
onBlur: func,
onContextMenu: func,

View File

@@ -38,6 +38,7 @@ export type ViewProps = {
children?: any,
hitSlop?: EdgeInsetsProp,
importantForAccessibility?: 'auto' | 'yes' | 'no' | 'no-hide-descendants',
nativeID?: string,
onBlur?: Function,
onClick?: Function,
onClickCapture?: Function,
@@ -87,6 +88,7 @@ const ViewPropTypes = {
children: any,
hitSlop: EdgeInsetsPropType,
importantForAccessibility: oneOf(['auto', 'no', 'no-hide-descendants', 'yes']),
nativeID: string,
onBlur: func,
onClick: func,
onClickCapture: func,

View File

@@ -8,6 +8,7 @@ const whitelist = {
children: true,
disabled: true,
importantForAccessibility: true,
nativeID: true,
onBlur: true,
onContextMenu: true,
onFocus: true,

View File

@@ -63,14 +63,15 @@ const observe = instance => {
};
const unobserve = instance => {
delete registry[instance._layoutId];
if (resizeObserver) {
const node = findNodeHandle(instance);
if (node) {
delete registry[node._layoutId];
delete node._layoutId;
resizeObserver.unobserve(node);
}
} else {
delete registry[instance._layoutId];
delete instance._layoutId;
}
};

View File

@@ -183,6 +183,12 @@ describe('modules/createDOMProps', () => {
expect(props['aria-hidden']).toEqual(true);
});
test('prop "nativeID" becomes "id"', () => {
const nativeID = 'Example.nativeID';
const props = createProps({ nativeID });
expect(props.id).toEqual(nativeID);
});
test('prop "testID" becomes "data-testid"', () => {
const testID = 'Example.testID';
const props = createProps({ testID });

View File

@@ -77,6 +77,7 @@ const createDOMProps = (component, props, styleResolver) => {
accessibilityLabel,
accessibilityLiveRegion,
importantForAccessibility,
nativeID,
placeholderTextColor,
pointerEvents,
style: providedStyle,
@@ -164,10 +165,15 @@ const createDOMProps = (component, props, styleResolver) => {
}
// OTHER
// Native element ID
if (nativeID && nativeID.constructor === String) {
domProps.id = nativeID;
}
// Link security and automation test ids
if (component === 'a' && domProps.target === '_blank') {
domProps.rel = `${domProps.rel || ''} noopener noreferrer`;
}
// Automated test IDs
if (testID && testID.constructor === String) {
domProps['data-testid'] = testID;
}

View File

@@ -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 = {

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "website",
"version": "0.9.2",
"version": "0.9.5",
"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.2"
"react-native-web": "0.9.5"
},
"devDependencies": {
"babel-plugin-react-native-web": "0.9.2",
"babel-plugin-react-native-web": "0.9.5",
"url-loader": "^1.0.1",
"webpack": "^4.8.1"
}

View File

@@ -116,6 +116,12 @@ const TextScreen = () => (
]}
/>
<DocItem
name="nativeID"
typeInfo="?string"
description="Used to locate this view from any native DOM code, or to define accessibility relationships. This is rendered to the native 'id' DOM attribute"
/>
<DocItem
name="numberOfLines"
typeInfo="?number"

View File

@@ -119,6 +119,12 @@ const ViewScreen = () => (
]}
/>
<DocItem
name="nativeID"
typeInfo="?string"
description="Used to locate this view from any native DOM code, or to define accessibility relationships. This is rendered to the native 'id' DOM attribute"
/>
<DocItem name="onBlur" typeInfo="?function" />
<DocItem name="onContextMenu" typeInfo="?function" />
<DocItem name="onFocus" typeInfo="?function" />