Compare commits

..

650 Commits

Author SHA1 Message Date
Kyle Fang
7b021c56f0 feat: add logbox functions 2020-10-31 14:41:16 +08:00
Nicolas Gallagher
6624a70cca 0.14.7 2020-10-30 10:52:37 -07:00
Nicolas Gallagher
5806b249dd [fix] Use browser expansion of 'flex' style
Fix #1792
2020-10-30 10:47:32 -07:00
Nicolas Gallagher
1048f7ce3e 0.14.6 2020-10-29 17:14:39 -07:00
Nicolas Gallagher
18f5a33c0d [fix] Don't require mocking window.matchMedia in jest
For people who don't mock unsupported DOM APIs for jsdom in their jest setup.

Fix #1789
2020-10-29 17:13:47 -07:00
Nicolas Gallagher
07e578edb8 [fix] ResponderSystem negotiation logic
This fixes a bug in the negotiation logic that caused a cycle of
terminate->grant events to be sent to the current responder during a pointer
move. The root cause was using an incorrect event path in the calculation of
the lowest common ancestor's index. The fix is to ensure that the event path
stored with the current responder is pruned to begin with the node that is the
current responder (rather than any child responders it may have contained).
2020-10-29 17:13:46 -07:00
Nicolas Gallagher
d2e6c29e25 [fix] Pan interactions should cancel 'click' events on the target
If a pan interaction has taken place, it is not expected that 'click' events
occur on the target element when the pointer is released (as was occuring with
mouse pointers). This patch cancels any 'click' that occurs within the pan
target's subtree, within 250ms of the pan gesture ending.

Fix #1788
2020-10-29 17:13:42 -07:00
Nicolas Gallagher
03897d32be [fix] Disabled pressables should propagate 'click' events
If a pressable is disabled it should not prevent the propagation of native
'click' events, unless the underlying DOM node has an 'aria-role' of 'button'.
This emulates the native '<button>' behavior.

Fix #1781
2020-10-29 15:57:35 -07:00
Nicolas Gallagher
b8fddcf6b1 0.14.5 2020-10-27 11:06:27 -07:00
Charlie Croom
d9c755dff0 [fix] Enter key handling for components explicitly given accessible prop
Close #1783
2020-10-27 10:54:24 -07:00
burakgormek
63c39454de [fix] Pressable disabled cursor state
Close #1782
2020-10-27 10:54:18 -07:00
Nicolas Gallagher
89be8a9f8b Fix ViewProps import path
This error was not surfaced by Flow locally but surfaced in CI.
2020-10-22 12:28:17 -07:00
Nicolas Gallagher
b4e53e8cd3 0.14.4 2020-10-22 11:00:02 -07:00
Charlie Croom
cea4172efb [fix] Prevent onClick being called when certain roles are disabled
Fix #1779
Close #1780
2020-10-22 10:56:40 -07:00
Charlie Croom
a2d72ee89c [fix] Avoid usePlatformMethods excess ref creation
Close #1777
2020-10-22 10:35:13 -07:00
Nicolas Gallagher
2428b6c6fc 0.14.3 2020-10-19 16:02:22 -07:00
Nicolas Gallagher
0aa77685aa [fix] Add matrix transform style
Remove the deprecated 'transformMatrix' style prop and support 'matrix' and
'matrix3d' in the 'transform' prop.

Fix #1771
2020-10-19 15:50:02 -07:00
Nicolas Gallagher
663458713c 0.14.2 2020-10-16 12:57:49 -07:00
TikiTDO
3118315140 [fix] Remove 'collapsable' prop from createAnimatedComponent
This is an Android-only prop that has no platform guard in React Native. The
web has a native 'collapsable' prop that React DOM complains about when it is
not a string value.

Close #1767
2020-10-16 12:55:51 -07:00
Charlie Croom
09c2f1975b [fix] Prevent constant Image reloading when source given as an object
Close #1770
2020-10-16 12:55:48 -07:00
Charlie Croom
18d5d449a7 [fix] Callback ref less on Views by making classList constant
Close #1766
2020-10-16 12:33:58 -07:00
Nicolas Gallagher
933bd138ce 0.14.1 2020-10-12 13:41:20 -07:00
Nicolas Gallagher
c2019a9881 [fix] Pressable cursor and touch-action styles
Also add unit tests for Pressable.

Fix #1764
2020-10-12 13:37:42 -07:00
Nicolas Gallagher
78174d7b48 0.14.0 2020-10-09 12:59:41 -07:00
Nicolas Gallagher
38fd574984 [add] Pressable support for hover state
This patch ports the 'useHover' hook to React Native for Web, providing hover
state that is scoped to a pressable and does not bubble to ancestor pressables.
This behavior aligns with the behavior of the focus and press states.

Fix #1708
2020-10-09 11:35:36 -07:00
Nicolas Gallagher
5b7a6bc30a Move hooks into 'modules' directory 2020-10-09 11:35:35 -07:00
James Ward
d97a1ca567 [add] Modal component
This adds support for the React Native Modal on web.

The app content is hidden from screen readers by setting the aria-modal flag on
the modal. This focus is trapped within the modal, both when attempting to
focus elsewhere using the mouse as well as when attempting to focus elsewhere
using the keyboard. A built-in "Escape to close" mechanism is been implemented
that calls 'onRequestClose' for the active modal.

Close #1646
Fix #1020
2020-10-09 11:32:31 -07:00
Nicolas Gallagher
6bd41a622a Remove react-dom vendor directory 2020-10-09 11:32:30 -07:00
Nicolas Gallagher
108366a724 [change] Default flex-basis value of Views
React Native has an implementation of flexbox that does not quite follow the
W3C spec for flexbox. Previously, React Native for Web attempted to replicate
the React Native rendering by setting flexBasis to 0%. However, this created
its own problems where views could collapse down to 0px in height on the web.
This patch relies sets the default flexBasis back to 'auto'. This will cause
different rendering inconsistencies with React Native, which can be addressed
by making changes to existing React Native styles. And ultimately, it is up to
Yoga to correct its flexbox implementation.

Fix #1640
Fix #1604
Fix #1264
Close #1265
2020-10-09 11:32:30 -07:00
Nicolas Gallagher
bf2e10d482 0.13.18 2020-10-09 11:17:09 -07:00
Mark Lawlor
faf7fa3374 [fix] skip ResizeObserver warning during SSR
Close #1762
2020-10-09 11:14:00 -07:00
Nicolas Gallagher
df14c7278a 0.13.17 2020-10-08 12:29:11 -07:00
Nicolas Gallagher
b15e8784c4 Add unit tests for ref imperative methods 2020-10-08 12:27:15 -07:00
Nicolas Gallagher
583e16fa8d Memoize refs
Refs can be memoized following the fix in the previous commit.

Fix #1755
Fix #1665
2020-10-07 15:28:34 -07:00
Nicolas Gallagher
b4322734a2 [fix] Order of ref merging
Ensure internal refs are called before the forwardedRef. This ensures that the
DOM element mutation performed by usePlatformMethods occurs before user-space
refs are called.

Ref #1749
2020-10-07 15:28:33 -07:00
Nicolas Gallagher
bdcb4de7dc 0.13.16 2020-10-06 11:41:31 -07:00
Nicolas Gallagher
d8ee51e326 [fix] CSS scrollbarWidth
The previous code wasn't inserting the W3C rule because it had the same selector as the rule for proprietary styles. However, the Firefox value isn't supported anymore, and the Edge value is unnecessary as Edge uses Blink now. This patch removes the non-WebKit fallback styles for this property.

Fix #1760
2020-10-06 11:38:17 -07:00
Nicolas Gallagher
aad0c88cea 0.13.15 2020-10-05 15:38:06 -07:00
Nicolas Gallagher
6d04e7243e [fix] Don't propagate click or contextmenu events on disabled elements
This patch fixes the PressResponder to avoid propagating click and contextmenu
events in all circumstances. It also prevents click propagating for focusable
elements that are disabled, mirroring the behavior of native buttons when
disabled.

Fix #1757
2020-10-05 15:33:50 -07:00
Julian Hundeloh
ba5e9e3079 [add] AccessibilityInfo isReduceMotionEnabled
Close #1754
2020-10-05 14:51:41 -07:00
Shobhit Chittora
06d3cadf05 Update docs suggested preset to metro-react-native-babel-preset
Updating the document as `babel-preset-react-native` is deprecated in favor for
`metro-react-native-babel-preset`. More info here -
https://www.npmjs.com/package/babel-preset-react-native.

Close #1751
2020-10-05 14:48:38 -07:00
Nicolas Gallagher
72bfe499c5 Add to View tests 2020-10-05 14:28:27 -07:00
Nicolas Gallagher
92ac1f94c5 Add to Text tests 2020-10-05 13:20:28 -07:00
Nicolas Gallagher
5edba02319 Add to Image tests 2020-10-05 13:16:13 -07:00
Nicolas Gallagher
2276e17310 Add to CheckBox tests 2020-10-05 13:16:12 -07:00
Nicolas Gallagher
222fa3490e Add to Button tests 2020-10-05 13:16:11 -07:00
Nicolas Gallagher
0fb3036f31 Add to ActivityIndicator tests 2020-10-05 13:16:11 -07:00
Nicolas Gallagher
7bc6fc8347 0.13.14 2020-09-24 13:39:37 -07:00
Nicolas Gallagher
c60417ab34 [fix] Revert ref memoization
Memoizing refs caused unexpected regressions in some class component patterns.
The memoization is being reverted for now.

Fix #1749
2020-09-24 13:26:21 -07:00
Nicolas Gallagher
af0d80a808 0.13.13 2020-09-21 15:56:18 -07:00
Richard Lindhout
12e91a35a4 [fix] nested Text selection
Allow text to be made selectable within a text node that is not selectable.

Close #1742
2020-09-21 15:49:27 -07:00
Nicolas Gallagher
376ccc31b1 [fix] Optimize ref merging
Close #1746
Fix #1665
2020-09-21 14:04:14 -07:00
Hossein Mohammadi
4a70300b08 Remove unnecessary code from setValueForStyles
Close #1734
2020-09-11 10:27:52 -07:00
Nicolas Gallagher
7ab04987f0 Fix compressed-size build script 2020-09-09 16:08:56 -07:00
Nicolas Gallagher
f52a9bcfd2 Add compressed-size action
Reports minified + gzipped size of modules
2020-09-09 13:46:23 -07:00
Nicolas Gallagher
74acb21aa8 0.13.12 2020-09-09 11:57:58 -07:00
Nicolas Gallagher
1e1236597a [fix] Image SSR hydration warnings
React doesn't currently provide an API for defining SSR-safe IDs, so we have to
suppress the hydration warnings that occur.

The 'useOpaqueIdentifier' hook is intended to support this use case but is not
currently a public API and development has been paused.
https://github.com/facebook/react/pull/17322.

Close #1375
2020-09-09 11:56:50 -07:00
SaltyWater
e9d81afbd4 [fix] Forward scroll end event to ScrollView onScroll handler
Close #1728
2020-09-09 11:43:53 -07:00
Nicolas Gallagher
9ed9231b04 0.13.11 2020-09-08 12:33:37 -07:00
Nicolas Gallagher
d5ab3770c0 [fix] PressResponder keyboard edge-case
Fixes the state-machine logic for the press responder when focus is moved away
from the target element during a 'keydown' event.
2020-09-08 12:32:00 -07:00
Nicolas Gallagher
397de88137 0.13.10 2020-09-08 11:24:19 -07:00
Nicolas Gallagher
bb8a1b1455 [fix] ScrollView scrollEventThrottle logic
Fix #1726
2020-09-08 11:22:35 -07:00
dependabot[bot]
214b296c11 Bump bin-links from 1.1.3 to 1.1.8
Bumps [bin-links](https://github.com/npm/bin-links) from 1.1.3 to 1.1.8.
- [Release notes](https://github.com/npm/bin-links/releases)
- [Changelog](https://github.com/npm/bin-links/blob/v1.1.8/CHANGELOG.md)
- [Commits](https://github.com/npm/bin-links/compare/v1.1.3...v1.1.8)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-08 11:02:38 -07:00
dependabot[bot]
a7df78afbe Bump markdown-to-jsx from 6.10.3 to 6.11.4
Bumps [markdown-to-jsx](https://github.com/probablyup/markdown-to-jsx) from 6.10.3 to 6.11.4.
- [Release notes](https://github.com/probablyup/markdown-to-jsx/releases)
- [Commits](https://github.com/probablyup/markdown-to-jsx/compare/6.10.3...6.11.4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-08 11:02:25 -07:00
Harrison Mendonça
c6425a0048 [fix] Add event parameter to Image onLoad callback
Close #1723
2020-09-08 11:01:29 -07:00
Nicolas Gallagher
8add92f776 0.13.9 2020-08-25 12:05:29 -07:00
Nicolas Gallagher
9a0acc5464 [fix] Layout of nested Text elements
Remove the 'dir=auto' attribute from nested Text elements as this can cause
browsers to produce broken text layouts.

Fix #1714
2020-08-25 12:04:08 -07:00
Nicolas Gallagher
a31c4c65d0 [fix] Remove Animated 'useNativeDriver' warning
Fix #1693
2020-08-25 11:12:29 -07:00
Colby Stauss
834bd5b98b [fix] Animated getScrollableNode check
Close #1695
Fix #1680
2020-08-25 11:10:10 -07:00
Nicolas Gallagher
de2a66c694 [fix] ResponderEvent touch identifier normalization
Move the touch identifier normalization into the ResponderEvent creation. This ensures that the identifier is consistent throughout. If application code reads an identifier from a touch object it can be used to find that touch in the `touchBank` array.

Fix #1716
2020-08-25 10:58:39 -07:00
Richard Lindhout
9ed0c407a9 [fix] TextInput keyboardType for 'numeric' and 'decimal'
Don't rely on native restrictions and validations for these keyboardType
values, as developers often want custom presentation (e.g., comma separators)
and custom validation.

Fix #1705
Fix #1438
Fix #1280
Close #1709
2020-08-21 11:00:21 -07:00
H3RSKO
7a8a70b948 Fix typo in README
Close #1706
2020-08-21 10:42:22 -07:00
Nicolas Gallagher
67a3d78799 0.13.8 2020-08-17 11:32:37 -07:00
Nicolas Gallagher
77bdb9086e [fix] Avoid needing to memoize onLayout callbacks
If 'onLayout' is an inline function, it could cause the DOM node to enter a
cycle of being observed/unobserved with the result that 'onLayout' was
constantly called.

Fix #1704
2020-08-17 11:10:53 -07:00
Nicolas Gallagher
7fc17d01cc 0.13.7 2020-08-12 10:58:28 -07:00
Evan Bacon
b8283245cf [fix] check for window availability in ResponderSystem
Close #1699
2020-08-12 10:50:11 -07:00
Nicolas Gallagher
75c5a90563 0.13.6 2020-08-10 14:13:13 -07:00
Nicolas Gallagher
3233d0ffe9 [fix] Responder negotiation between siblings
There should be responder negotiation between siblings if there is no common ancestor connected to the responder system. Instead the current responder should continue to receive events. This was only occuring for mouse events during mousemove, as the target can change during the course of the movement.
2020-08-10 13:26:13 -07:00
Nicolas Gallagher
251cdfb220 0.13.5 2020-08-03 14:10:51 -07:00
Nicolas Gallagher
7c46a3667e [fix] update System font stack
Remove system-ui as it has rendering issues for certain OS/language combinations.
See https://phabricator.wikimedia.org/T175877

Fix #1638
2020-08-03 14:09:57 -07:00
Nicolas Gallagher
5a15dcae66 [fix] Dimensions doesn't debounce change listener
Fix #1662
2020-08-03 13:46:47 -07:00
Nicolas Gallagher
af0ae004ff [fix] Image forwards ViewProps
Close #1637
2020-08-03 13:44:27 -07:00
Ryoga Kitagawa
08f722ac86 [fix] ScrollView forwards dataSet
Close #1675
2020-08-03 13:43:44 -07:00
dependabot[bot]
6bf69c0015 Bump elliptic from 6.4.1 to 6.5.3
Bumps [elliptic](https://github.com/indutny/elliptic) from 6.4.1 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](https://github.com/indutny/elliptic/compare/v6.4.1...v6.5.3)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-30 11:22:01 -07:00
dependabot[bot]
28f51fa492 Bump lodash from 4.17.15 to 4.17.19
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-30 11:21:40 -07:00
Nicolas Gallagher
5426762ed4 0.13.4 2020-07-20 12:26:49 -07:00
Nicolas Gallagher
10de987785 [fix] usePlatformMethods guard against null hostNode
Fix #1679
2020-07-20 12:22:17 -07:00
Nicolas Gallagher
72638d028b 0.13.3 2020-07-07 14:43:10 -07:00
Colby Stauss
097cd31a90 [fix] Image tintColor updates
Fix #1319
Close #1664
2020-07-07 14:40:45 -07:00
Nicolas Gallagher
96dcce0261 0.13.2 2020-07-07 11:45:46 -07:00
Nicolas Gallagher
1497bb4d72 [fix] TouchableWithoutFeedback child ref
Fix #1663
2020-07-07 11:35:54 -07:00
dependabot[bot]
99e6d7137f Bump websocket-extensions from 0.1.3 to 0.1.4
Bumps [websocket-extensions](https://github.com/faye/websocket-extensions-node) from 0.1.3 to 0.1.4.
- [Release notes](https://github.com/faye/websocket-extensions-node/releases)
- [Changelog](https://github.com/faye/websocket-extensions-node/blob/master/CHANGELOG.md)
- [Commits](https://github.com/faye/websocket-extensions-node/compare/0.1.3...0.1.4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-01 10:59:24 -07:00
Nicolas Gallagher
8c391604ba 0.13.1 2020-06-29 12:20:51 -07:00
Nicolas Gallagher
7ef070195b [fix] setNativeProps and pointerEvent prop
The pointerEvent prop is converted into a DOM style property and needs to be
accounted for by setNativeProps.

Close #1656
Fix #1655
2020-06-29 10:58:34 -07:00
Nicolas Gallagher
728e20ff1f [fix] jest preset
Fix #1654
2020-06-29 09:59:17 -07:00
Nicolas Gallagher
824cca1972 0.13.0 2020-06-26 15:16:53 -07:00
Nicolas Gallagher
cfe36d780e Minimal update of Animated
Ref #1576
2020-06-26 14:51:55 -07:00
Nicolas Gallagher
5dda71c2a6 [change] Remove 'accessibilityRelationship'; add 'dataSet'
Remove the 'accessibilityRelationship' prop which is not part of React Native.
The general approach to supporting ARIA-like accessibility APIs in React Native
needs revisiting and it will be easier to stop going down this path.

This patch also reverts the "unstable_ariaSet" change, and renames
"unstable_dataSet" to "dataSet". Avoiding another breaking change to
accessibility props will ease upgrading for now.
2020-06-26 14:51:55 -07:00
Nicolas Gallagher
972317c17c PressResponder fix invariant edge case
If keyup events fall through to a "pressable" element that is not the responder
(e.g., a keydown in a modal closes the modal) it should not attempt to
transition the state.

Also replace invariant with console.error to allow the app to recover if
unexpected signals occur.
2020-06-26 14:51:54 -07:00
Nicolas Gallagher
0901be6e5c [fix] TextInput onKeyPress and onSubmitEditing events
onKeyPress forwards the synthetic keydown event.
onSubmitEditing is only called if IME composition is not in progress.

Fix #1332
2020-06-26 14:51:53 -07:00
Nicolas Gallagher
52f903229e Minor cleanup of StyleSheet 2020-06-26 14:51:52 -07:00
Nicolas Gallagher
3230713d6b [change] Remove support for microdata props
Microdata was removed from the HTML spec and most browsers.
2020-06-26 14:51:52 -07:00
Nicolas Gallagher
53dd03d83b Fix PressResponder click prevention logic 2020-06-26 14:51:51 -07:00
Nicolas Gallagher
c2d4fd6d77 Fix TextInput onSelectionChange logic 2020-06-26 14:51:51 -07:00
Nicolas Gallagher
fc78cb06fd Fix updates to opacity in TouchableOpacity 2020-06-26 14:51:50 -07:00
liorJuice
cd9be22947 [fix] Clipboard copy edge-case
Make sure clipboard works even if global CSS is affecting user text selection.

Fix #1559
2020-06-26 14:51:50 -07:00
Jaap Frolich
324995ec2b [add] Appearance module
Close #1597
2020-06-26 14:51:50 -07:00
Nicolas Gallagher
cecacbc3ac Add eslint-plugin-flowtype 2020-06-26 14:51:49 -07:00
Nicolas Gallagher
ff6109ec1c Update README and docs 2020-06-26 14:51:49 -07:00
Nicolas Gallagher
aa647567ad [change] Remove hitSlop
Rely on the native behavior of browsers to provide hitslop for touch on
interactive elements.

Fix 1609
2020-06-26 14:51:48 -07:00
Nicolas Gallagher
e9933b107a Adjust keyboard onClick shim 2020-06-26 14:51:48 -07:00
Nicolas Gallagher
4b4163f630 [add] AccessibilityInfo API update
Close #1574
2020-06-26 14:51:47 -07:00
Nicolas Gallagher
ac945761e6 [fix] Add getNativeScrollRef to FlatList
Fix #1560
Close #1563
2020-06-26 14:51:47 -07:00
Nicolas Gallagher
7ab3cf0d42 [change] Remove scrollWithoutAnimationTo from ScrollView
Remove this API which was previously deprecated.
2020-06-26 14:51:47 -07:00
Nicolas Gallagher
37ff6b4888 Reorganize usePressEvents and PressResponder 2020-06-26 14:51:46 -07:00
Nicolas Gallagher
cf7d5e9b07 [fix] forwarding of refs and props
Fixes a performance regression in prop forwarding by reintroducing prop filtering.
Fixes ref forwarding to host components, mutating the host node to add imperative APIs.
2020-06-26 14:51:45 -07:00
Nicolas Gallagher
0ffbf66b1a [change] Remove TabBarIOS and TimePickerAndroid exports
These modules have been removed from React Native
2020-06-26 14:51:45 -07:00
Nicolas Gallagher
a7da67cd09 Reorganize internal modules 2020-06-26 14:51:45 -07:00
Nicolas Gallagher
603adc46ab Alternative PanResponder API 2020-06-26 14:51:44 -07:00
Nicolas Gallagher
88f5dedffd [change] Add Pressable and replace Touchables
Port and rewrite "Pressability" from React Native as "PressResponder". This
integrates a press target with the responder system on web. It avoids
performing layout measurement during gestures by eschewing React Native's
iOS-like UX in favor of expected Web UX: a press target will look pressed until
the pointer is released, even if the pointer has moved outside the bounding
rect of the target.

The PressResponder is used to reimplement the existing Touchables. It's
expected that they will eventually be removed in favor of Pressable.

Fix #1583
Fix #1564
Fix #1534
Fix #1419
Fix #1219
Fix #1166
2020-06-26 14:51:43 -07:00
Nicolas Gallagher
7e724b279d Remove enzyme 2020-06-26 14:51:42 -07:00
Nicolas Gallagher
204c432f66 [change] Text and View onClick handling
Makes `onClick` part of the stable props API. In the future this will be used
to implement `onPress` in the Touchables/Pressables. Special handling of click
for keyboards is performed in `createElement`. At the moment, `Text` still
includes the `onPress` prop, which will only be called if `onClick` is not also
being used. In the future `Text` (in React Native) should remove the Touchable
props from its API.
2020-06-26 14:51:41 -07:00
Nicolas Gallagher
66751502a3 [change] Replace the ResponderEventPlugin
Replaces the ResponderEventPlugin with useResponderEvents hook.

Also removes the event "normalization" of mouse, touch, and click events.
These events are not part of the responder system and will no longer be
modified from what ReactDOM dispatches.

Fix #1589
Fix #1568
Fix #1571
Fix #829
Fix #693
2020-06-26 14:51:40 -07:00
Nicolas Gallagher
4146b16a68 Add PanResponder examples to docs 2020-06-05 11:53:48 -07:00
Nicolas Gallagher
fe013b30dc Add dom-event-testing-libary as a private package
This is copied from facebook/react with various fixes applied (which I'll push
upstream at a later date). Necessary for testing the Responder Event System
rewrite.
2020-06-05 11:53:47 -07:00
Nicolas Gallagher
fa6e269832 Add missing imports to docs mdx files 2020-06-02 10:57:38 -07:00
Nicolas Gallagher
ee1cb490d6 Fix optional value flow types 2020-06-02 10:57:37 -07:00
Nicolas Gallagher
f4e8b6b194 [change] modernize Image
Rewrite Image to use function components and hooks.

Fix #1322
2020-06-02 10:57:36 -07:00
Nicolas Gallagher
7e616f6d46 Fix props table for docs
Stop using the built-in Props table from Storybook (which wasn't working.)
2020-06-02 10:57:36 -07:00
Nicolas Gallagher
8952eccf86 [change] Explicitly forward props and introduce unstable_{ariaSet,dataSet}
Rather than filtering props, they are explicitly forwarded in each component.
This makes it easier to see exactly which props are being forwarded to host
components by each React Native component. Two new props - `unstable_ariaSet`
and `unstable_dataSet` - are introduced to avoid iterating over props to find
`aria` and `data` props.

The `accessibilityValue` prop is also implemented.
2020-06-02 10:57:35 -07:00
Nicolas Gallagher
654f65e3e0 [change] modernize TextInput
Rewrite TextInput to use function components and hooks.
Rewrite the unit tests to replace enzyme with testing-library.

Fix #1339
2020-06-02 10:55:51 -07:00
Nicolas Gallagher
d94a14dc8c [change] RefreshControl, StatusBar, YellowBox as function components 2020-06-02 10:55:50 -07:00
Nicolas Gallagher
8d37fde5ee [change] modernize Picker
Rewrite Picker to use function components and hooks.
Rewrite the tests to replace enzyme with testing-library.
2020-06-02 10:55:50 -07:00
Nicolas Gallagher
fdf53df301 [change] modernize CheckBox
Rewrite CheckBox to use function components and hooks.
Rewrite the tests to replace enzyme with testing-library.
2020-06-02 10:55:49 -07:00
Nicolas Gallagher
999c2ad122 [change] modernize ActivityIndicator
Rewrite ActivityIndicator to use function components and hooks.
Rewrite the tests to replace enzyme with testing-library.
2020-06-02 10:55:49 -07:00
Nicolas Gallagher
35236a3cc2 [change] modernize Text
Rewrite Text to use function components and hooks.
2020-06-02 10:55:48 -07:00
Nicolas Gallagher
2724ca0293 Add eslint-plugin-react-hooks 2020-06-02 10:55:48 -07:00
Nicolas Gallagher
fc443c5abd [change] modernize View
Rewrite View to use function components and hooks.

The 'usePlatformMethods' hook also fixes a bug in the class-based
implementation of 'setNativeProps' which was unable to correctly merge its
styles with those provided via the component API. In the future,
'setNativeProps' will be removed from React Native anyway.

See (3) in #1136 for more context.
2020-06-02 10:55:47 -07:00
Nicolas Gallagher
7d440c74f4 [change] modernize Switch
Rewrite Switch to use function components and hooks.
Rewrite the tests to replace enzyme with testing-library.
2020-06-02 10:55:47 -07:00
Nicolas Gallagher
ebc3882661 [change] modernize ScrollViewBase
Rewrite ScrollViewBase to use function components and hooks.
Rewrite the tests to replace enzyme with testing-library.
2020-06-02 10:55:46 -07:00
Nicolas Gallagher
b28d2a8214 [fix] SafeAreaView types 2020-06-02 10:55:46 -07:00
Nicolas Gallagher
94ecc46ece [change] modernize ProgressBar
Rewrite ProgressBar to use function components and hooks.
Rewrite the tests to replace enzyme with testing-library.
2020-06-02 10:55:45 -07:00
Nicolas Gallagher
5b40b9d6aa [change] modernize ImageBackground
Rewrite ImageBackground to use function components and hooks.
Rewrite the tests to replace enzyme with testing-library.
2020-06-02 10:55:45 -07:00
Nicolas Gallagher
840a2e91d4 [change] modernize Button
Rewrite Button to use function components.
Rewrite the tests to replace enzyme with testing-library.
2020-06-02 10:55:44 -07:00
Nicolas Gallagher
96d8649197 [change] modernize AppRegistry
Rewrite AppRegistry to use function components and hooks.
Rewrite the tests to replace enzyme with testing-library.
2020-06-02 10:55:44 -07:00
Nicolas Gallagher
a2cccaf528 [change] Add usePlatformMethods to implement instance methods
A hook equivalent for implementing "native methods" on refs to elements backed
by function components.
2020-06-02 10:55:43 -07:00
Nicolas Gallagher
51ac083d56 [change] Add useElementLayout hook to implement onLayout callback
A hook equivalent for implementing onLayout in function components.  Removes
the fallback to using window resize events. A ResizeObserver polyfill is now
requires to use the `onLayout` prop.
2020-06-02 10:55:43 -07:00
Nicolas Gallagher
9dbe17fa6a 0.12.3 2020-06-02 10:51:45 -07:00
Nicolas Gallagher
f4a481bb4f [fix] Allow 'lang' attribute to be forwarded to DOM nodes 2020-06-02 10:38:35 -07:00
Nicolas Gallagher
5287044f40 0.12.2 2020-02-24 14:08:31 -08:00
Vladimir Guguiev
92737d33f4 [fix] Prevent injectEventPluginsByName throwing when re-evaluating code
Close #1539
2020-02-24 13:53:23 -08:00
editkid
18427aae50 [fix] Avoid use of Object.values
Improve compatibility with older browsers (without polyfilling)

Close #1541
2020-02-24 13:30:05 -08:00
Evan Bacon
a7ab961d95 [fix] Image support for variable resolution images
Renders the asset scale which is closest to the window scale. Requires bundler integration.

Close #1456

Co-authored-by: David Calhoun <dpcalhoun@gmail.com>
2020-02-10 11:17:14 -08:00
Nicolas Gallagher
c8b73fa4e4 0.12.1 2020-02-06 13:39:50 -08:00
Nicolas Gallagher
3d53273fe7 Update internal paths to docs 2020-02-06 13:38:38 -08:00
Nicolas Gallagher
5b7f584f19 [fix] View filtering of accessibility props 2020-02-06 11:27:31 -08:00
Nicolas Gallagher
88c664fa0f Update dependencies for 'benchmarks' package 2020-01-30 17:11:13 -08:00
Nicolas Gallagher
dff62b3af6 Update jest dependencies 2020-01-30 17:01:07 -08:00
Nicolas Gallagher
032279e5f7 Update dependencies for 'docs' package 2020-01-30 16:54:01 -08:00
Nicolas Gallagher
d30d65b29d Update babel dependencies 2020-01-30 16:45:07 -08:00
Nicolas Gallagher
dee418bb93 0.12.0 2020-01-24 14:24:35 -08:00
Brandon Ros
1cc7e6cbf4 Fix bad invariant import path 2020-01-10 15:55:40 -08:00
Nicolas Gallagher
16c0109df6 Replace invariant with console.error in View
Jest dumps the invariant error to the console when unit tests run, which is
both annoying and more likely to cause unwanted error to go unnoticed. We're
also moving away from using 'invariant' in React. This patch replaces the
invariant with a call to 'console.error', which won't crash an app that is
using raw text nodes as View children, but it's better than nothing.
2019-12-21 16:58:14 +00:00
Nicolas Gallagher
287251a06a [change] Remove 'placeholderTextColor' from 'createElement' props
TextInput converts the 'placeholderTextColor' prop to a style.
2019-12-21 16:57:11 +00:00
Nicolas Gallagher
e670e8135b [fix] TextInput forwards placeholderTextColor
Fix a bug introduced by 924e891f58

Ref #1512
2019-12-20 23:30:37 +00:00
Nicolas Gallagher
e22f0bebb3 [fix] ScrollView disabling of scroll
Make sure 'scrollEnabled={false}' works on desktop browsers and no longer
relies on using 'e.preventDefault()'.

Fix #1491
2019-12-20 19:30:09 +00:00
luis filipe
f16c2c45ea [fix] ScrollView scrollEventThrottle development warning check
Close #1498
2019-12-20 19:24:41 +00:00
Nicolas Gallagher
fc033a3161 [add] TextInput disabled prop
Add support for disabling TextInput elements

Fix #1036
2019-12-20 19:18:01 +00:00
Greg Westneat
8fa9fc5cc5 Update README link for Docz
Close #1504
2019-12-19 22:35:30 +00:00
Nicolas Gallagher
e0412acb94 [add] Allow style scrollbarWidth 'thin' value
Close #1499
2019-12-19 16:59:06 +00:00
ecreeth
0b31a8b096 Refactor import and export in react-native-web entry file
Close #1509
2019-12-19 11:04:41 +00:00
Nicolas Gallagher
b10711bddd [fix] TextInput autoComplete behavior
Fix 'autoComplete' behavior now that Chrome has fixed broken behavior for 'off'.
Add fallback support for React Native's 'autoCompleteType' prop.

Close #1404
2019-12-18 22:31:45 +00:00
Chris Drackett
5334a4f0d8 [fix] TextInput remove default browser margin
Close #1458
2019-12-18 22:24:37 +00:00
Maxime Thirouin
df1b62cd45 [add] useWindowDimensions hook
Add the 'useWindowDimensions' hook from React Native

Close #1487
2019-12-18 16:53:07 +00:00
Max Thirouin
4763cc71c6 Document reasoning behind hairlineWidth value
Close #1488
2019-12-18 16:33:36 +00:00
Nicolas Gallagher
aa8593ba97 [change] Switch prop 'trackColor' support
Remove support for legacy React Native props and add support for the
'trackColor' object. Retains support for the web-only equivalents as I think
this API is preferable to the one in React Native, both in terms of flexibility
and performance (no inline objects).

Fix #1382
2019-12-18 16:22:54 +00:00
Nicolas Gallagher
3c9cc66264 Update storybook dependencies 2019-12-18 14:52:03 +00:00
Nicolas Gallagher
1ad1693039 [change] Remove PropTypes exports and internal use
Removes the following deprecated exports: `ColorPropType`,
`EdgeInsetsPropType`, `PointPropType`, `TextPropTypes`, and `ViewPropTypes`.

Remove all use of `prop-types` in the implementations of components. Flow types
are used instead, so there will no longer be runtime warnings related to props.

NOTE: Removes support for `className` prop.

Fix #1383
Close #1477
Close #1474
Close #1489
2019-12-18 12:40:31 +00:00
Nicolas Gallagher
924e891f58 Update babel-plugin-tester 2019-11-15 14:21:16 -08:00
dependabot[bot]
fced06aeaa Bump js-yaml from 3.12.0 to 3.13.1
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.12.0 to 3.13.1.
- [Release notes](https://github.com/nodeca/js-yaml/releases)
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/3.12.0...3.13.1)

Close #1479

Signed-off-by: dependabot[bot] <support@github.com>
2019-11-13 16:29:19 -08:00
dependabot[bot]
21d60a3e9a Bump lodash from 4.17.11 to 4.17.15
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.15.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.11...4.17.15)

Close #1478

Signed-off-by: dependabot[bot] <support@github.com>
2019-11-13 16:28:38 -08:00
dependabot[bot]
f4ff2e8891 Bump mixin-deep from 1.3.1 to 1.3.2
Bumps [mixin-deep](https://github.com/jonschlinkert/mixin-deep) from 1.3.1 to 1.3.2.
- [Release notes](https://github.com/jonschlinkert/mixin-deep/releases)
- [Commits](https://github.com/jonschlinkert/mixin-deep/compare/1.3.1...1.3.2)

Close #1468

Signed-off-by: dependabot[bot] <support@github.com>
2019-11-13 16:28:01 -08:00
Nicolas Gallagher
f43ce41f0d Update README 2019-11-13 11:30:31 -08:00
Nicolas Gallagher
afb8d3b7fb [change] Configure hydration using AppRegistry.runApplication()
Client-side hydration of server-rendered HTML now requires that `hydrate` is explicitly set in the `appParams` passed to `AppRegistry.runApplication()`.

Fix #1374
2019-11-12 16:54:51 -08:00
Nicolas Gallagher
e4ed0fd3c8 [fix] ScrollResponder componentWillMount -> UNSAFE_componentWillMount 2019-11-12 15:36:10 -08:00
Nicolas Gallagher
297cda7901 Rewrite interactive documentation
Consolidate all docs within the latest storybook

Ref #1172
2019-11-12 15:19:48 -08:00
Nicolas Gallagher
8cf00a5c5a Update inline-style-prefixer and misc deps 2019-11-12 14:42:58 -08:00
Nicolas Gallagher
3fd90b9252 Update flow to 0.109
Add $FlowFixMe to vendor code that produces flow errors
2019-11-12 14:42:57 -08:00
Nicolas Gallagher
9e7c37128e Update 'benchmarks' dependencies 2019-11-12 14:42:54 -08:00
Nicolas Gallagher
41e6dca1e3 Update linter and formatter tools 2019-10-08 13:06:20 -07:00
Nicolas Gallagher
02a3640f95 Update test tools 2019-10-08 13:06:17 -07:00
Nicolas Gallagher
290a2a76ce Update babel build tools 2019-10-08 13:04:10 -07:00
Nicolas Gallagher
1b3c31ff6a Run prettier across codebase
Close #1444
2019-10-07 14:26:24 -07:00
Nicolas Gallagher
d4b9f35d33 [change] createElement -> unstable_createElement
Rename the 'createElement' export to reflect its unstable status.

Fix #1385
2019-10-07 14:20:49 -07:00
Nicolas Gallagher
3ac0b96498 [change] Update Touchable components
Reference RN 0.60 implementations with web-specific fixes

Ref #1172
Fix #1105
2019-10-07 14:01:05 -07:00
Nicolas Gallagher
33f1c3566c [add] forwardedRef prop to View and Text
Ref #1172
2019-10-04 11:37:26 -07:00
Nicolas Gallagher
d57fb6eb01 [change] accessibilityRelationship and accessibilityState props
Adds the accessibilityState and accessibilityRelationship object props that map
to ARIA props.

Removes the accessibilityStates array prop that is not compatible with web
accessibility services.

Ref #1172
2019-10-04 11:37:26 -07:00
Nicolas Gallagher
ae94551ac5 [change] Remove accessibilityTraits and accessibilityComponentType props
These props are deprecated in React Native and replaced by accessibilityRole

Ref #1352
2019-10-04 11:37:25 -07:00
Nicolas Gallagher
1af0218d26 Remove unused 'shadowSpread' prop type
Close #1357
2019-10-04 11:37:25 -07:00
Nicolas Gallagher
d554d83727 [change] Text uses createContext
Replaces the legacy 'contextTypes' API.
Removes 'enzyme' from related tests. Back to recording DOM snapshots.

Close #1248
Ref #1172
2019-10-04 11:37:25 -07:00
Nicolas Gallagher
25dd43e960 [change] Update vendor code
* FlatList
* SectionList
* VirtualizedList
* VirtualizedSectionList
2019-10-04 11:37:22 -07:00
Nicolas Gallagher
c4a2a6d4a3 Update to flow-bin@0.98 2019-10-04 11:07:09 -07:00
Nicolas Gallagher
ad674e4b4f [add] Platform.isTesting 2019-10-04 11:07:09 -07:00
Nicolas Gallagher
304e8a83ab [change] Update Animated
react-native@v0.60.0-rc.3

Fix #1378
Fix #1325
Close #1306
2019-10-04 11:07:09 -07:00
Nicolas Gallagher
ac71506610 [change] Remove WebView
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:09 -07:00
Nicolas Gallagher
847870e4b3 [change] Remove ViewPagerAndroid
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:09 -07:00
Nicolas Gallagher
845c2726b2 [change] Remove VibrationIOS
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:09 -07:00
Nicolas Gallagher
9d76d58891 [change] Remove ToolbarAndroid
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:09 -07:00
Nicolas Gallagher
f54c957199 [change] Remove SwipeableListView
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:09 -07:00
Nicolas Gallagher
425102c16e [change] Remove StatusBarIOS
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
0c350d2678 [change] Remove SnapshotViewIOS
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
eaa24ae91d [change] Remove Slider
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
24801cb5da [change] Remove SegmentedControlIOS
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
41e4f05eb0 [change] Remove PushNotificationIOS
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
72ede16c9c [change] Remove ProgressBarAndroid and ProgressViewIOS
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
7ec9b075a1 [change] Remove PickerIOS
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
89bc074327 [change] Remove NetInfo
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
add0e0cb7e [change] Remove NavigatorIOS
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
8900cea576 [change] Remove MaskedViewIOS
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
6c682bbb92 [change] Remove ListView
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
ece4e95d4d [change] Remove ImageStore
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
f9eadc10d2 [change] Remove ImagePickerIOS
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
cc5a5d7d27 [change] Remove ImageEditor
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
800f24466e [change] Remove DatePickerAndroid and DatePickerIOS
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
5a12430b50 [change] Remove CameraRoll
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
fbdbfa5484 [change] Remove AsyncStorage
Ref #1352
Ref https://github.com/react-native-community/async-storage/issues/52
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
920211b998 [change] Remove AlertIOS
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Nicolas Gallagher
c0c7a18aca [change] Remove ActionSheetIOS
Ref #1352
Ref https://github.com/facebook/react-native/issues/23313
2019-10-04 11:07:08 -07:00
Marnus Weststrate
250ee3c234 [fix] Only inject ResponderEventPlugin client-side
Close #1434
Fix #1433
2019-09-30 10:49:41 -07:00
John Rees
6ce88e6db0 Fix docs link to create-react-app
Close #1440
2019-09-30 10:49:24 -07:00
Nicolas Gallagher
e810f1fd2b 0.11.7 2019-08-16 13:15:07 -07:00
Quentin Woivré
d2e8d616e2 [fix] Support for native scroll-width style
Close #1418
2019-08-16 13:09:30 -07:00
Nicolas Gallagher
1cce9a1668 0.11.6 2019-08-09 11:51:16 -07:00
Giuseppe Gurgone
96a23c1c21 [fix] StyleSheet hydration with single quotes in attribute selectors
Edge uses single quotes for attribute selectors.

Fix #1317
Close #1415
2019-08-09 11:23:50 -07:00
Charlie Croom
ebbade3a6f [fix] TextInput support for 'returnKeyType'
Close #1413

Co-authored-by: Nicolas Gallagher <nicolasgallagher@gmail.com>
2019-08-09 11:21:17 -07:00
Pawel Borkowski
ef770d4bd1 [fix] Add support for browsers that implement scrollbar-width
Close #1395
2019-08-09 11:08:55 -07:00
Bruno Lemos
a7ddd7b9ac [fix] SafeAreaView ref supports setNativeProps
https://github.com/facebook/react-native/pull/24589

Close #1407
2019-08-09 11:01:08 -07:00
Evan Bacon
8f5e7d4e14 [fix] Export DeviceEventEmitter
Close #1402
2019-08-09 10:58:30 -07:00
Nicolas Gallagher
45f94eb43d 0.11.5 2019-07-02 14:06:34 -07:00
Nicolas Gallagher
5092be40ac Fix RNTester Image examples
The 'resizeMode' static no longer exists.

Fix #1360
Close #1387
2019-07-02 13:23:44 -07:00
Evan Bacon
b144992f51 [fix] Add enum types to interaction prop types
Close #1358
2019-07-02 13:23:44 -07:00
Nicolas Gallagher
9d5a41c702 [fix] Don't stringify application params
Close #1365
2019-07-02 13:17:53 -07:00
Evan Bacon
11d00ff111 [add] SafeAreaView support for iOS 11 CSS constant
Close #1359
2019-07-02 13:09:59 -07:00
Ross Williams
8908db7690 [fix] InteractionManager runAfterInteractions resolve
Close #1355
InteractionManager runAfterInteractions does not resolve its promise unless the function is provided with a callback. Using promises, the user of the library should not need to provide a callback. This update adds an else case when there is no callback to call the Promise's resolve function without arguments.
2019-07-02 12:56:17 -07:00
Giuseppe Gurgone
29146fe5bc [fix] StyleSheet group sorting
Close #1356
2019-07-02 12:54:42 -07:00
Nicolas Gallagher
33dc3cb018 0.11.4 2019-05-21 14:17:21 -07:00
Nicolas Gallagher
4f5de8d016 [fix] typo in ScrollView prevents hiding scrollbars 2019-05-21 14:14:23 -07:00
Nicolas Gallagher
cddc2e346b 0.11.3 2019-05-21 12:21:08 -07:00
Evan Bacon
fa09df8b59 [fix] ScrollView support for hiding scroll indicators
Implements 'showsHorizontalScrollIndicator' and 'showVerticalScrollIndicator' by polyfilling the 'scrollbar-width' property from the draft CSS spec for scrollbars. Scrollbars can only be shown for both or neither axis.

Close #1307

Co-authored-by: Nicolas Gallagher <nicolasgallagher@gmail.com>
2019-05-21 11:02:38 -07:00
Nicolas Gallagher
be5106f5d3 [fix] textDecoration{Color,Line,Style} styles
Attempting to fallback to CSS2 text-decoration is not reliable for inline
styles. This patch assumes CSS3 text-decoration support when server-rendering,
and uses CSS.supports to check for runtime support. When CSS3 support is
available the long-form properties are preserved.

Fix #1312
2019-05-15 17:33:53 -07:00
Charlie Croom
37ca236d09 [fix] Image displays defaultSource until source load completes
This fixes an issue that would cause the defaultSource to be removed as soon as
the source beings to load. The original intent was to support progressive
JPEGs. However, in cases where a defaultSource has been provided, we should
respect the intent to display it until the primary source is ready to
immediately replace the defaultSource.

Close #1345
2019-05-15 16:17:00 -07:00
Charlie Croom
950bfd039c [add] Image.queryCache API
Image.queryCache is a React Native method that allows the user to see
if a given uri is in the cache. It specifies three return options:
disk, memory or both. Choosing both seemed most appropriate since
we don't really know and can't confirm.

The way Image is implemented, if RNW thinks the image might already
be loaded, it displays it immediately. Otherwise there can be a flash
of a frame. In some scenarios, if the user chooses to preload and then
make an Image element, it would still flash. By adding it to the cache,
we can prevent that.

Close #1344
2019-05-15 15:41:05 -07:00
Nicolas Gallagher
39d2e18ccf [fix] Text accessibilityRole propTypes warning
Close #1320
2019-05-15 11:23:24 -07:00
Nicolas Gallagher
e9f68e380b [fix] Avoid using Object.values
Not everyone is polyfilling older environments

Fix #1334
2019-05-15 11:22:02 -07:00
Doug Miller
2ce434e8f8 [fix] Babel plugin rewrite for main index require
Recently the default export was removed from react-native-web. In some
scenarios it is possible to still get to this import path which does not work
anymore. Removing the `.default` fixes commonjs imports from index.

Close #1341
2019-05-15 11:05:35 -07:00
Janic Duplessis
3eeda686b1 [fix] Prevent maxFontSizeMultiplier prop forwarding to DOM
Close #1313
2019-05-15 10:59:36 -07:00
MoOx
70e3ea8b57 Add documentation for Node.js module aliasing
Close #1315
2019-05-15 10:57:51 -07:00
ashbhir
cc99391f9d [fix] Text default border style
Close #1335
2019-05-15 10:45:05 -07:00
Yukiya Nakagawa
27713bd8cc Fix docs typo
Close #1297
2019-05-15 10:44:31 -07:00
Nicolas Gallagher
801937748b 0.11.2 2019-03-22 10:02:44 -07:00
Nicolas Gallagher
9cbe387d9f [fix] CSS insertion in Edge browser
Edge browser throws `HierarchyRequestError` while inserting CSS rules into CSS
Media Queries. Therefore, a different mechanism is required to control CSS
order. This patch tracks the starting index of each group of CSS rules in the
DOM style sheet.

Fix #1300
Close #1302
2019-03-22 09:58:18 -07:00
Nicolas Gallagher
c1459d7b21 Remove '!important' check from setValueForStyles
'!important' styles are no longer used internally and are not supported in the
public API.
2019-03-19 10:32:59 -07:00
Mathieu Acthernoene
36dacb2052 [change] Update flow-bin to 0.95.1
Fix related type errors

Close #1269

Co-authored-by: Nicolas Gallagher <nicolasgallagher@gmail.com>
2019-03-18 13:00:05 -07:00
Nicolas Gallagher
b732cec83e Fix copyright headers 2019-03-18 11:13:17 -07:00
Nicolas Gallagher
ad78fc7a38 0.11.1 2019-03-15 14:08:24 -07:00
Nicolas Gallagher
33e54c755b [fix] StyleSheet SSR of classic CSS
Hack something together to get classic CSS going through the same pathway as
the rest of the styles. This gets classic CSS showing up in the SSR CSS output.

Fix #1286
2019-03-15 10:20:56 -07:00
Paul Armstrong
74a36a2a4e [fix] Jest preset module export
Export the preset as a module so that paths can be resolved relative to a Jest
config file.

Close #1290
2019-03-15 10:07:56 -07:00
Nicolas Gallagher
8d1f5afead Fix website Image examples
Remove use of 'resizeMode' static, which is no longer supported.
2019-03-14 14:20:25 -07:00
Nicolas Gallagher
763e2d4001 0.11.0 2019-03-12 17:45:10 -07:00
Nicolas Gallagher
f507410ab4 [fix] Schema prop types
Ref 34427897f3
2019-03-12 17:43:22 -07:00
Nicolas Gallagher
97372d7e4c Update benchmark results for 0.11.0 2019-03-12 17:30:10 -07:00
Nicolas Gallagher
9872c97169 Remove whitespace from CSS rules
Minimizes bytes from CSS code that might be inlined in the head of the document
during SSR.
2019-03-12 13:53:48 -07:00
Nicolas Gallagher
d50f6304dc [change] Add className prop deprecation warning
View and Text will not support the 'className' prop in a future release.

Fix #1146
2019-03-12 13:00:57 -07:00
Nicolas Gallagher
330895534d [change] CSS class prefix 'rn' -> 'r' 2019-03-12 13:00:57 -07:00
Nicolas Gallagher
0e302a50d2 [change] Refactor style resolver
Minor refactor of the style resolver to convert it to a factory function.
2019-03-12 13:00:57 -07:00
Nicolas Gallagher
f048d848a1 [change] Replace outline with outline{Color,Style,Width} styles
Rather than mix shortform and longform properties, the 'outline' property is
removed in favour of the longform properties. Support for `outlineOffset` is
also included.

Fix #1255
Close #1256
2019-03-12 13:00:57 -07:00
Nicolas Gallagher
c68b532696 [change] StyleSheet validation
Stop relying on React internals and propTypes validation.
2019-03-12 13:00:57 -07:00
Nicolas Gallagher
d4417e93a3 [change] Use classic CSS in View, Text, etc., implementations
The CSS base styles for certain primitives are implemented using classic CSS to
reduce browser layout times and better support 'null' values in
StyleSheet-defined styles. Combined with the previous patch this reduces the
benchmark layout times by about 30%.

Ref #1136
Fix #1044
Fix #1223
Fix #13
2019-03-12 13:00:57 -07:00
Nicolas Gallagher
9f860b8dfc [change] StyleSheet: compile styles directly to CSS
Introduces a centralized compiler for "atomic" and "classic" CSS output. The
"classic" compiler is for internal use only and offers no CSS safety
guarantees. The "atomic compiler is used to implement the public-facing
StyleSheet API.

The atomic compiler now maps the React style declarations, rather than CSS
style declarations, to CSS rules. This avoids having to convert React styles to
CSS styles before being able to lookup classNames. And it reduces the number of
CSS rules needed by each DOM element.

Before:

    { paddingHorizontal: 0; }
        ↓
    .paddingLeft-0 { padding-left: 0; }
    .paddingRight-0 { padding-right: 0; }

After:

    { paddingHorizontal: 0; }
        ↓
    .paddingHorizontal-0 { padding-left: 0; padding-right: 0 }

Overview of previous StyleSheet resolver:

1. Localise styles
2. Transform to CSS styles
3. Expand short-form properties
4a. Lookup Atomic CSS for each declaration
4b. Compile Atomic CSS for each static declaration
  i. Vendor prefix
  ii. Insert CSS rules
4c. Create inline style for each dynamic-only declaration
  i. Vendor prefix

Overview of new StyleSheet design:

1. Localise styles
2a. Lookup Atomic CSS for each declaration
2b. Compile Atomic CSS for each static declarations
  i. Transform to CSS styles
  ii. Expand short-form properties
  iii. Vendor prefix
  iiii. Insert CSS rules
2c. Create inline style for each dynamic-only declaration
  i. Transform to CSS styles
  ii. Expand short-form properties
  iii. Vendor prefix

Ref #1136
2019-03-12 13:00:57 -07:00
Nicolas Gallagher
29be779f77 [change] CSS insertion by OrderedCSSStyleSheet
`OrderedCSSStyleSheet` can be used to control the order in which CSS rules are
inserted. This feature is necessary to support the combined use of Classic CSS
and Atomic CSS. It also makes it possible to control the order of Atomic CSS
rules, which is necessary to correctly resolve style conflicts (e.g., between
'margin' and 'marginHorizontal') without expanding short-form properties to
long-form properties.

Ref #1136
2019-03-12 13:00:57 -07:00
Evan Bacon
2a418bed0c [change] Organize unimplemented modules in directories
Creates a {path}/index.js for each module that has no web
implementation. This enables the babel preset to rewrite all paths and
prevent apps from bundling unused modules.

Fix #1281
Close #1282
2019-03-11 21:13:16 -07:00
Nicolas Gallagher
5e9449e893 Update benchmark libraries 2019-03-11 20:17:29 -07:00
Alec Winograd
67979b7282 [add] TextInput support for "onContentSizeChange"
Fix #793
Close #1226
2019-03-11 14:14:13 -07:00
Nicolas Gallagher
3d3ea9aeed [change] Remove ART export
Anticipate the removal of ART from React Native core:
https://github.com/facebook/react-native/issues/23313

Simplifies dependencies and builds for web apps.

Close #1251
2019-03-11 13:33:49 -07:00
Nicolas Gallagher
69bd0f631d [change] Remove default ES Module export
Remove the default export that was provided for compatibility with legacy
imports of React Native CommonJS modules. These patterns are no longer
supported:

```
import ReactNative from 'react-native';
const ReactNative = require('react-native');
```

Fix #1258
Close #1277
2019-03-11 13:12:24 -07:00
Evan Bacon
9ce2b5bf0c [fix] NativeEventEmitter implementation
Close #1275
2019-03-08 13:06:19 -08:00
Hiroki Sato
cf7b020c5d [fix] set textShadow if only blur and color provided
Mirrors a recent fix to React Native.

Close #1182
2019-03-08 12:42:36 -08:00
Nicolas Gallagher
49edcb291e [change] remove 'resizeMode' static from 'Image'
Use strings instead of the 'Image.resizeMode' static. Corresponding change in React Native:

https://github.com/facebook/react-native/commit/870775e
2019-03-08 12:40:59 -08:00
Nicolas Gallagher
6a84d74185 0.10.1 2019-03-07 11:32:33 -08:00
Nicolas Gallagher
282cb34054 Fix npm publish errors 2019-03-07 11:31:50 -08:00
Wyatt Greenway
421cb095f7 [fix] PickerItem cyclic dependency
Close #1270
2019-03-07 11:06:48 -08:00
Nicolas Gallagher
0c08ba3a7d [fix] Text support for accessibilityRole="none"
Fix #1262
2019-03-07 11:02:57 -08:00
Nicolas Gallagher
e4c3a21c42 [fix] TextInput autoComplete="off"
Browsers treat autoComplete "off" as "on". The fix is to provide the browser
with an unrecognized value so that it doesn't attempt to auto-fill the input.

Fix #1249
2019-03-07 10:58:27 -08:00
Nicolas Gallagher
34427897f3 [add] Support for Schema prop types
View and Text forward Schema prop types to host DOM node.
https://schema.org/docs/gs.html

Fix #1247
2019-03-07 10:50:34 -08:00
Dan Alloway
63868b492d Fix project scripts in Windows environments
Close #1252
2019-03-01 14:49:55 -08:00
Nicolas Gallagher
8ce5750d34 0.10.0 2019-01-30 14:13:58 -08:00
Nicolas Gallagher
eb77062608 Remove unnecessary snapshot tests
Remove snapshots that were unnecessarily recording generated CSS output.
2019-01-22 18:48:29 -08:00
Nicolas Gallagher
b6fc6f228e Add new Text render benchmark 2019-01-22 18:48:29 -08:00
Nicolas Gallagher
6c725357ff Add a note about referrer tracking 2019-01-22 18:48:29 -08:00
atp
dce5b7321d [add] Text support for wordBreak style
Close #1200
2019-01-22 18:48:29 -08:00
Nicolas Gallagher
52ca784680 Use default array sort function 2019-01-22 18:48:29 -08:00
Nicolas Gallagher
244b0e4425 Don't print AppRegistry message in unit tests 2019-01-22 18:48:29 -08:00
Nicolas Gallagher
21c3931b69 [fix] use getBoundingClientRect to measure layout
Fix #1037
Fix #1151
2019-01-22 18:48:29 -08:00
Nicolas Gallagher
e696e637bd [add] support backdropFilter style
Close #1070
2019-01-22 18:48:29 -08:00
Nicolas Gallagher
b62a7bf44d Update webpack for examples 2019-01-22 18:48:29 -08:00
Nicolas Gallagher
69d1da4560 Update eslint 2019-01-22 18:48:29 -08:00
Nicolas Gallagher
8925bf76af [change] implement TextInput without e.which
e.which is considered deprecated and should be replaced with e.key.

Fix #1190
Close #1193
2019-01-22 18:48:28 -08:00
Nicolas Gallagher
77d4bd8a97 [change] Compile using Babel 7
Fix #1170
Close #1205
Close #1191
2019-01-22 18:48:28 -08:00
Nicolas Gallagher
4040151ee6 [add] support for accessibilityRole and accessibilityStates
React Native 0.57 introduced 'accessibilityRole' and
'accessibilityStates' as cross-platform accessibility APIs to replace
'accessibilityComponentType' and 'accessibilityTraits' for Android and
iOS.

React Native for Web has supported the 'accessibilityRole' for a while.
This patch maps some of the values defined in React Native to web
equivalents, and continues to allow a larger selection of roles for web
apps. It also adds support for 'accessibilityStates', mapping values to
ARIA states with boolean values and expanding support beyond 'disabled'
and 'selected'.

Fix #1112
Close #1113
2019-01-22 18:48:25 -08:00
Nicolas Gallagher
000b92e707 0.9.13 2018-12-31 17:31:46 -08:00
Nicolas Gallagher
d5f5dbccdb [fix] inline-style-prefixer API update
Fix #1217
2018-12-31 17:22:05 -08:00
Nicolas Gallagher
79456d5920 0.9.12 2018-12-31 10:34:04 -08:00
Nicolas Gallagher
2d1e303a6a [fix] ScrollView with stickyHeaderIndices regression
A ScrollView with stickyHeaderIndices would not render children that
weren't sticky.

Fixes 1e202b6bd5
2018-12-31 10:26:33 -08:00
Nicolas Gallagher
209ff1fa40 0.9.11 2018-12-31 08:23:58 -08:00
Nicolas Gallagher
34d8160a43 [fix] CSS animation insertion for Android 5.1 HuaWei browser
Inserting unprefixed CSS keyframes rules causes a `SYNTAX_ERR: DOM Exception
12` error in Android 5.1. A similar issue with inserting rules containing
vendor-prefixed pseudo-selectors was patched by wrapping rule in `@media all
{}` blocks. This patch removes the media query wrapper from keyframe animations
(as it doesn't prevent the error) and relies on `CSSStyleSheet::insertRule`
being called within a try-catch block.

Fix #1199
Close #1210
2018-12-31 07:47:52 -08:00
Nicolas Gallagher
ada5651be2 Don't minify local benchmarks build 2018-12-24 13:35:21 +00:00
Nicolas Gallagher
9fe9d3c68a Update react-native-web dependencies 2018-12-24 13:03:49 +00:00
krister
1e202b6bd5 [add] ScrollView support for pagingEnabled
Available in browsers that support CSS snappoints.

Fix #1057
Close #1212

Co-authored-by: Nicolas Gallagher <nicolasgallagher@gmail.com>
2018-12-23 18:05:29 +00:00
Robert Sayre
2b77bfd853 [fix] improve style resolver performance
Script time in the benchmark was profiled by adding `console.profile` around
the timings for script time. The call to Array.join in the resolve function
stood out. Since the code already iterates over the array it can run slightly
faster by building the cache key in that loop instead.

Close #1213
2018-12-23 15:07:48 +00:00
Nicolas Gallagher
d0ac55aa4f Update benchmarks dependencies 2018-12-21 21:33:43 +00:00
Nicolas Gallagher
66dd1bd9ef Remove glamor and radium from benchmarks
Glamor is unmaintained. Radium is extremely slow. There is no need to compare
against these libraries.
2018-12-21 21:20:30 +00:00
Nicolas Gallagher
6add18c6f0 0.9.10 2018-12-21 21:04:26 +00:00
krister
30d7c31b65 [fix] ScrollView smooth scrolling
Rely on the `element.scroll()` programmatic API when available (or polyfilled).

Fix #1203
Fix #1173
Close #1208
2018-12-21 20:57:25 +00:00
Raibima Putra
f7e6b43422 Fix docs typo
Close #1209
2018-12-21 20:46:29 +00:00
Nicolas Gallagher
4b3f6efb21 Support style inspection in production 2018-12-10 17:01:23 -08:00
Nicolas Gallagher
85e098deec 0.9.9 2018-12-05 14:46:11 -08:00
Nicolas Gallagher
c949b0145a [fix] TextInput onKeyPress supports Escape key
Fix #1189
2018-11-27 12:15:59 -08:00
Charlie Croom
86b4cf5a51 [add] scaleZ and scale3d style transforms
Web-specific additions similar to the web-specific additions to `translate` styles.

Close #1184
2018-11-27 11:53:04 -08:00
Giuseppe
1b7ce4eec6 [fix] Fix regression in modality refactor
Fixes https://github.com/necolas/react-native-web/pull/1169#issuecomment-440590544

And removes the focus ring for press-after-keyboard edge cases.

Close #1186

Co-authored-by: Nicolas Gallagher <nicolasgallagher@gmail.com>
2018-11-27 11:52:46 -08:00
Nicolas Gallagher
8c8978ff76 0.9.8 2018-11-15 21:40:18 -08:00
Nicolas Gallagher
513b5de881 Partially revert d841db2337
The modification to VirtualizedList is not required now that ScrollView wraps
sticky header items in a View.
2018-11-15 10:26:49 -08:00
Julian Hundeloh
145f80409d [fix] ScrollView dependency on 'style' forwarding for sticky headers
Not every item that may be rendered by a ScrollView will forward 'style', so cloning the item element is not safe. Instead, we can wrap the item in a 'View' and apply the styles for the sticky header to this element.

Close #1175
2018-11-15 10:24:54 -08:00
Julian Hundeloh
6d92cc5ec3 [fix] ListView section error when missing renderHeader
Close #1174
2018-11-15 10:11:54 -08:00
Nicolas Gallagher
ec6458c09d Update some links in README 2018-11-15 10:09:14 -08:00
James Munro
a84c2ac95e Add DataCamp to companies using react-native-web in production
Close #1176
2018-11-15 10:07:26 -08:00
Nicolas Gallagher
75db0e9183 0.9.7 2018-11-12 17:53:16 -08:00
Giuseppe Gurgone
4b9a5fd8b4 [fix] modality performance
Inserting and deleting the CSS ':focus' rule triggers styles recalculation for the
entire DOM tree which results in performance degradation on focus and makes the
keyboard very slow to open in Safari iOS.

This commit fixes the issue by picking up the upstream changes to the W3C
focus-visible polyfill. A class name is applied to elements when they receive
focus via keyboard. The related CSS rule is inserted only once into the style
sheet. This performs much better since the browser needs to recalculate styles
only for the focused element and its small subtree.

Fix #1155
Close #1169
2018-11-12 15:54:07 -08:00
Nicolas Gallagher
b6be677db9 [fix] ref.focus() should focus any element type
Ensure that programmatic focus can be moved to any element. Each
instance of a primitive component type (e.g., `View`, `Text`, etc.)
includes a `focus` method. However, on the web only certain elements can
receive programmatic focus by default: those that can also receive
keyboard focus, e.g., `a`, `button`, `input`, etc. All other element
types must set `tabIndex="-1"` in order to be programmatically focusable
without also being focusable via keyboard or mouse.

Fix #1099
2018-11-10 12:03:44 -08:00
Nicolas Gallagher
91c9457392 Remove reference to create-react-native-app
Close #1167
2018-11-10 11:23:04 -08:00
Nicolas Gallagher
006d315a1a Add example Next.js recipes 2018-11-10 11:07:54 -08:00
Nicolas Gallagher
220eb79357 Fix UIExplorer headings accessibility 2018-11-10 11:05:49 -08:00
Murtaza Raja
5db9a765b0 Fix README install command typo
Close #1163
2018-11-04 18:39:23 -08:00
Nicolas Gallagher
931d666fcc 0.9.6 2018-11-01 12:29:18 -07:00
hushicai
40c433c6df [fix] only call 'getBoundingClientRect' if nativeEvent.location{X,Y} is accessed
Calculating the `location{X,Y}` values for events requires a call to
`getBoundingClientRect`. To prevent unnecessary performance costs, these values
are implemented as getters and will only make the DOM API call when accessed in
application code.

Close #1157
2018-11-01 09:06:10 -07:00
hushicai
9888c2a3c6 [fix] scrolling of nested ScrollViews
Use of 'pan-x' and 'pan-y' on ScrollView prevents the browser handling
scrolling of a parent ScrollView that is scrollable along the other axis.

Fix #1160
Close #1161
2018-11-01 09:01:29 -07:00
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
Nicolas Gallagher
a54bdeec09 0.9.2 2018-10-09 18:02:55 -07:00
atp
8fa7dc63ec [add] TextInput support for 'caretColor' CSS property
Close #1127
2018-10-09 17:59:57 -07:00
Bruno Lemos
d841db2337 [fix] VirtualizedList sticky header support
The way that sticky headers work on web requires the ScrollView to apply
'position:sticky' to a clone of the element. This wasn't working for
VirtualizedList because the style prop was not passed to the default
CellRendererComponent implementation.

Fix #1066
Close #1122
2018-10-09 17:54:10 -07:00
Rick
8e7d31cff5 [fix] ignore native-only TextInput props
TextInput inherits ViewPropTypes but many of them do nothing (even in
React Native).

Close #1123
2018-10-09 17:46:19 -07:00
Nicolas Gallagher
0764687a8f [fix] VirtualizedList disabled virtualization in tests
Fix #1077
Close #1118
2018-10-09 17:37:02 -07:00
Charlie Croom
d31bdf2cf8 [fix] ResizeObserve only on elements using 'onLayout' prop
Only observe nodes when the 'onLayout' prop is specified on the
element. Fixes performance regression for browsers that rely on
MutationObserver-based shim for ResizeObserver.

Fix #1128
Close #1129
2018-10-09 17:31:32 -07:00
Nicolas Gallagher
1f3a77dada 0.9.1 2018-09-27 14:30:26 -07:00
Nicolas Gallagher
c3cbd53a8a [fix] ResponderEventPlugin removal of emulated mouse events
If the work related to a touch/press event takes a long enough time
(i.e., CPU intensive, old device, etc.) the browser may produce emulated
mouse events >500ms after the original touch event. This causes the
related Responder events to fire twice. To avoid that happening, this
patch increases the filter threshold used by the ResponderEventPlugin
from 200ms to 1000ms.

Fix #1078
2018-09-22 16:33:46 -07:00
Nicolas Gallagher
4f5ee15e4b Fix website TouchableHighlight example 2018-09-22 16:20:49 -07:00
Nicolas Gallagher
9a1cade1f0 0.9.0 2018-09-17 10:55:16 -07:00
Nicolas Gallagher
506dba933c [change] Support React DOM 16.5
React DOM 16.5 changed unstable APIs that this project depends upon.
This regression was fixed in React DOM 16.5.1 but requires React Native
for Web to migrate to a different unstable API exported by React DOM.

Fix #1096
Close #1106
2018-09-17 10:16:33 -07:00
Nicolas Gallagher
c0de9dddf3 0.8.11 2018-09-17 09:47:04 -07:00
David Calhoun
96c9c06272 Update the Docz integration link
Close #1102
2018-09-17 09:37:32 -07:00
Charlie Croom
505e3faee8 [fix] 'menuitem' role supports Enter/Space keyboard interaction
The 'menuitem' ARIA role should support Enter/Space keyboard interaction
as if it were a button. This is required because the ARIA spec makes it
so that the ARIA properties of 'menuitem' children are ignored, i.e.,
you can't just wrap a button in a 'menuitem' and expect Assistive
Technologies to surface the button to users.

Fix #1068
Close #1069
2018-09-17 09:30:06 -07:00
Nicolas Gallagher
1f06229289 [fix] react-native-web@0.8 pinned to React 16.4 2018-09-17 08:47:37 -07:00
Nicolas Gallagher
fc743e6eee Fix sandbox placeholder 2018-09-17 08:44:52 -07:00
Tomoya Hirano
ef97adec6e [fix] Picker doesn't pass 'onValueChange' to DOM node
Fix #1104
Close #1107
2018-09-17 08:19:13 -07:00
Nicolas Gallagher
f196335281 0.8.10 2018-09-09 13:10:51 -07:00
Anton Nyman
d29e31d9d6 [fix] better cross-browser support for textDecoration styles
Safari requires '-webkit' prefixes for CSS3 text-decoration styles, and
IE/Edge only support CSS2 text-decoration styles. This patch provides a
fallback for the CSS2 case and relies on the CSS3 properties for color
and style.

Close #1053

Co-authored-by: Nicolas Gallagher <nicolasgallagher@gmail.com>
2018-09-09 12:03:10 -07:00
Nicolas Gallagher
c7c1f29016 Reorganize documentation
Close #1092
Close #1095
2018-09-09 11:33:09 -07:00
Nicolas Gallagher
b56a737d62 [fix] prevent findNodeHandle throwing on unmounted components
Fix #1097
2018-09-09 11:11:18 -07:00
Nicolas Gallagher
f062eded40 [fix] Switch applies accessibilityLabel to native control
VoiceOver requires that the aria-label for the checkbox is applied to
the checkbox itself and not a wrapping element.

Fix #1072
2018-08-17 15:16:38 -07:00
Nicolas Gallagher
fcc4fbf678 [fix] TextInput defaults to numberOfLines={1} for multiline
Fix #1071
2018-08-17 11:23:23 -07:00
James Long
a18d30c809 [fix] Add inputAccessoryViewID to TextInput props
Close #1076
2018-08-17 11:12:56 -07:00
Marcel Miranda Ackerman
b9172ceb8e [fix] Image EncodingError for SVG in Safari iOS 11
Fixes an EncodingError exception being thrown in Safari iOS 11 when
decoding an SVG URL. The exception prevents the onLoad handler from
being called.

Close #1063
2018-08-17 11:09:32 -07:00
Michael S. Kazmier
744aaa26d4 [fix] Picker supports View props
Close #1064
2018-08-17 11:07:22 -07:00
Justine De Caires
2b5ddf753e [add] objectFit and objectPosition to style validation
Close #1046
2018-08-17 10:58:05 -07:00
Ben Milman
b84e3b938a Fix typo in docs
Close #1049
2018-08-17 10:56:54 -07:00
Nicolas Gallagher
9c8407162e 0.8.9 2018-07-19 12:32:40 -07:00
Jeremy
16b9ec2917 [fix] nested ScrollView scroll behaviour propagation
Allow ScrollView to be scrolled from gestures originating in a
descendent ScrollView.

Fix #1042
Close #1043
2018-07-19 12:17:42 -07:00
Nicolas Gallagher
d4af1eb981 0.8.8 2018-07-06 15:06:46 -07:00
Nicolas Gallagher
405a3b79e8 [fix] TextInput calls onSelectionChange upon user input
Fix #1018
2018-07-06 15:00:50 -07:00
Nicolas Gallagher
afd5293172 Update React packages 2018-07-06 13:46:21 -07:00
Nicolas Gallagher
e4831b7bd8 Update benchmarks dependencies 2018-07-06 13:45:56 -07:00
Nicolas Gallagher
baffc9a9e6 0.8.7 2018-07-05 11:50:17 -07:00
Nicolas Gallagher
4151b47005 [fix] backgroundClip prefixing when value is 'text'
Temporary work-around for a bug in inline-style-prefixer.

Fix #1014
2018-07-05 11:46:49 -07:00
Nicolas Gallagher
96ec805f59 [fix] TextInput multiline value with onSubmitEditing
Prevent a newline from being added when submitting a multiline text
input using the "Enter" key.

Fix #1013
2018-07-04 12:32:48 -07:00
Nicolas Gallagher
d2df2c296e 0.8.6 2018-06-28 09:47:56 -07:00
Nicolas Gallagher
af80b046fa Update Flow config documentation
Close #1007
2018-06-28 09:33:07 -07:00
Nicolas Gallagher
1d01af57d0 [fix] add mousedown and mouseup to supported View props
Fix #1008
2018-06-28 09:08:28 -07:00
Johannes
e7613ca4d1 [fix] onLayout TypeError if node already unmounted
Close #993
2018-06-28 09:02:20 -07:00
Nicolas Gallagher
0e81c6ef27 0.8.5 2018-06-26 07:55:35 -07:00
Nicolas Gallagher
7fa8940325 [fix] VirtualizedList calls to findNodeHandle
Fix #1004
2018-06-26 07:52:07 -07:00
Nicolas Gallagher
3e681bed3e GitHub issue template adjustment
Move help text into HTML comments and make it clear that issues will be
closed if the issue template is ignored.
2018-06-15 10:47:04 -07:00
ral51
ecd4b40c71 Fix source code links on website
Close #994
2018-06-14 13:45:38 -07:00
Nicolas Gallagher
e7cb364b63 0.8.4 2018-06-14 13:40:57 -07:00
Nicolas Gallagher
90bd23f783 [fix] onLayout event object
Make sure that `this` within the `target` getter references the React
component rather than the layout event object.

Fix #996
2018-06-14 13:21:25 -07:00
Nicolas Gallagher
47a281373a 0.8.3 2018-06-06 16:24:02 -07:00
Nicolas Gallagher
6a0302169c [fix] react-native-web package files
Fix #987
2018-06-06 16:21:33 -07:00
Nicolas Gallagher
b195f2b1f5 0.8.2 2018-06-05 13:22:24 -07:00
Nicolas Gallagher
7b81d2a7ec Fix AsyncStorageExample
Comment out React Native's use of non-standard `done()` method, which
isn't available on `async` functions even though it is polyfilled for
the global Promise.
2018-06-05 13:13:36 -07:00
Nicolas Gallagher
a1d8ea776e [fix] PickerIOS is alias for Picker
PickerIOS API is a subset of the cross-platform Picker. This patch
provides some compatibility for use of PickerIOS / PickerIOS.Item in
legacy code.
2018-06-05 13:12:59 -07:00
Nicolas Gallagher
15b960f097 0.8.1 2018-06-05 09:31:42 -07:00
Nicolas Gallagher
001be82178 [fix] remove AppRegistry logging in production
Fix #986
2018-06-05 09:08:36 -07:00
Nicolas Gallagher
5eeef9e3d2 [fix] only call preventDefault for clicks on links
The previous incarnation of this fix would cancel clicks that bubble up
to elements like ScrollViews, with undesired impact on child element
events. Instead, limit the hack to elements with accessibilityRole=link.

Fix #985
2018-06-05 09:02:35 -07:00
Nicolas Gallagher
6a310999d0 0.8.0 2018-06-04 11:55:16 -07:00
Nicolas Gallagher
a9ad313a79 Add examples app to release tasks 2018-06-04 11:54:11 -07:00
Nicolas Gallagher
d0ca7585ab Update docs
Close #960
2018-06-04 11:40:08 -07:00
Nicolas Gallagher
3f8624e25f [change] StyleSheet.hairlineWidth is whole pixel value
Even on high DPI screens, browsers can round sub-pixel values down to
`0`. This causes hairlineWidth borders/heights/etc not to be rendered.
Revert `hairlineWidth` value back to `1`.
2018-06-04 11:40:08 -07:00
Nicolas Gallagher
8f0c39c2fe [change] introduce Jest preset
A simple Jest preset that configures module mapping and produces
human-readable styles (i.e., not converted to numeric form).

Fix #928
Fix #963
2018-06-04 11:40:07 -07:00
Nicolas Gallagher
4f9216853b Add more paths to jest ignore 2018-06-04 11:40:07 -07:00
Nicolas Gallagher
14f7dfd515 [fix] Clipboard preserves line breaks
Fix #979
2018-06-04 11:40:07 -07:00
Nicolas Gallagher
c336995952 [change] prevent default click behavior when using responder system
Certain HTML elements have a default behaviour (e.g., link navigation)
that can only be prevented in the `click` event handler. The responder
event system doesn't make use of `click` and no callbacks have access to
the `click` event. To prevent unwanted default behaviour, and emulate
the behavior in React Native, the `click` callback will automatically
call `preventDefault()` when the responder system is being used.

The result is that components like `Touchable*` that are overloaded as
web links need to explicitly trigger the link navigation, e.g.,

```
<TouchableOpacity
  accessibilityTraits="link"
  href={href}
  onPress={(e) => {
    Linking.openUrl(href);
  }}
/>
```

Fix #970
2018-06-04 11:40:07 -07:00
Nicolas Gallagher
2afa5a3cf7 [change] remove componentWillReceiveProps from Image 2018-06-04 11:40:07 -07:00
Nicolas Gallagher
9fb818cfd4 [fix] Image resizeMode for 'center' and 'repeat'
React Native will scale down an image to fit its container before
centering or repeating it.
2018-06-04 11:40:07 -07:00
Nicolas Gallagher
3153cd8213 [add] Image support for blurRadius, tintColor, and shadows
Use CSS filters to implement React Native image styles.

Ref #362
Ref #548
2018-06-04 11:40:07 -07:00
Nicolas Gallagher
026a92fd53 [fix] babel-plugin option to rewrite to commonjs paths
Allow the babel plugin to be configured to rewrite paths to either ES
modules (default) or CommonJS.

Ref #961
2018-06-04 11:40:07 -07:00
Nicolas Gallagher
e0f010da47 [change] whitelist props passed to React DOM
Avoiding unknown property warnings from React DOM. Many components
within and build upon React Native do not filter their own properties
and spread them into View. It is expected that React Native ignore these
properties.

Fix #898
2018-06-04 11:40:06 -07:00
Nicolas Gallagher
b299eb6c59 [add] SwipeableFlatList and SwipeableListView 2018-06-04 11:39:55 -07:00
Nicolas Gallagher
da38e87b50 [fix] minor inconsistency in textShadow style resolution
React Native doesn't apply textShadow styles when the 'height' or
'width' offset is 0.
2018-06-04 11:39:12 -07:00
Nicolas Gallagher
a40521f485 [fix] shadow style props resolution 2018-06-04 10:24:35 -07:00
Nicolas Gallagher
f62ed22a14 [add] Text support for textDecoration{Color,Style} 2018-06-04 10:24:35 -07:00
Nicolas Gallagher
bfaca0557b [fix] add UIManager to NativeModules 2018-06-04 10:24:35 -07:00
Nicolas Gallagher
c3eedabac4 Add React Native examples app
RNTester examples taken from React Native 0.55.4.

Minor changes to disable / enable some examples for the web.
2018-06-04 10:24:31 -07:00
Nicolas Gallagher
cf43ffd700 [change] Export stubs for iOS/Android modules
Fix #958
Fix #967
2018-06-04 10:21:45 -07:00
Nicolas Gallagher
a8e5d43db5 Move 'website' to 'packages/website'
Keep all workspaces in the 'packages' directory.
2018-06-03 11:32:55 -07:00
Nicolas Gallagher
b4e3427fea [fix] UIManager measurements don't block
A large number of layout measurements (and their corresponding tasks)
can block the main thread. Make the work async and try to keep the UI
responsive to user input while the layout work is taking place.
2018-06-03 11:32:54 -07:00
Nicolas Gallagher
a82cfbe504 [fix] Image layout in Firefox
Layout is more reliable in Firefox if the root element's flexBasis is
'auto'. This patch also moves the background image to an internal tile.
2018-06-03 11:32:54 -07:00
Nicolas Gallagher
0eae7bed2e [change] Image should not be draggable by default 2018-06-03 11:32:54 -07:00
Nicolas Gallagher
b8f54f61f0 [change] Image uses decode() not requestIdleCallback()
Chrome heavily throttles `requestIdleCallback` while scrolling, which
causes delays in image loading. Instead, use the relatively new
`decode()` API to decode the image off the main thread and prevent jank,
without delaying loading itself.

Fix #764
Ref #759
2018-06-03 11:32:54 -07:00
Nicolas Gallagher
d5c6b98340 [fix] Image loading callbacks when mounting cached image 2018-06-03 11:32:54 -07:00
Nicolas Gallagher
16b2fb9bd7 [fix] Image loading for source={{ uri: '' }}
Avoid an error being thrown from attempting to call `match` on an object
value.

Fix #962
2018-06-03 11:32:54 -07:00
Nicolas Gallagher
48e62fcd64 Add PJPEG example to docs 2018-06-03 11:32:54 -07:00
Nicolas Gallagher
0816c40790 [fix] add 'target' to onLayout nativeEvent 2018-06-03 11:32:54 -07:00
Nicolas Gallagher
2756ab49c3 [fix] TextInput add 'numbers-and-punctuation' keyboardType 2018-06-03 11:32:54 -07:00
Nicolas Gallagher
10407f3aa2 [add] Share API
Fix #958
2018-06-03 11:32:54 -07:00
Nicolas Gallagher
0ee3310290 [change] Linking API
Linking updates the application document's URL rather than opening a new
window. This change also makes deep-linking work.
2018-06-03 11:32:53 -07:00
Nicolas Gallagher
19b356aaea [add] Alert API 2018-06-03 11:32:53 -07:00
Nicolas Gallagher
ea744fe780 [add] NativeEventEmitter export
Export NativeEventEmitter and provide React Native's implementation.
2018-06-03 11:32:53 -07:00
Nicolas Gallagher
f254c8eae6 [change] update Animated implementation
Mirror contents of React Native 0.55.4
2018-06-03 11:32:53 -07:00
Nicolas Gallagher
5fcb36fc21 [change] ListView update 2018-06-03 11:32:53 -07:00
Nicolas Gallagher
377f23f725 [add] SectionList
Close #831
2018-06-03 11:32:51 -07:00
Nicolas Gallagher
fc0b81416a [add] FlatList 2018-06-03 10:16:51 -07:00
Nicolas Gallagher
cb545b0dac [add] LayoutAnimation export
Fix #803
2018-06-03 10:16:51 -07:00
Nicolas Gallagher
f684a3656e [fix] InteractionManager improvements 2018-06-03 10:16:51 -07:00
Nicolas Gallagher
45975d3a1e Update and reorganize React Native vendor code 2018-06-03 10:16:50 -07:00
Nicolas Gallagher
2d83ffbd6b Add .prettierignore file 2018-06-03 10:16:50 -07:00
Nicolas Gallagher
64307c066a Update eslint globals 2018-06-03 10:16:50 -07:00
Nicolas Gallagher
bb66639519 [fix] ScrollView stickyHeaderIndices basic support
Close #434
2018-06-03 10:16:47 -07:00
Nicolas Gallagher
c00360491b [fix] ScrollView methods and horizontal layout
Horizontal ScrollView was not scrollable when combined with
RefreshControl.

Add a stub for the flashScrollIndicators method.
2018-05-29 11:04:27 -07:00
Nicolas Gallagher
4bc16fa3eb [fix] AppState should not throw for 'memoryWarning' event 2018-05-29 11:04:27 -07:00
Nicolas Gallagher
2237777341 [fix] Vibration has default pattern
Rather than throwing an error when a pattern is not provided, set a
default value as per React Native.
2018-05-29 11:04:27 -07:00
Nicolas Gallagher
6a2252891a [fix] ImageBackground with <Text> children
Prevent Text from displaying behind the Image.
2018-05-29 11:04:27 -07:00
Nicolas Gallagher
206a236df2 [add] AccessibilityInfo and DeviceInfo stubs 2018-05-29 11:04:27 -07:00
Nicolas Gallagher
ff5a928a50 [fix] processColor compatibility with React Native 2018-05-29 11:04:27 -07:00
Nicolas Gallagher
61bf7e76b0 [fix] CommonJS exports can be imported without 'default'
Make sure all the CommonJS modules can be required as normal, rather
than needing to be suffixed with `.default` due to being compiled from
ES modules.
2018-05-29 11:04:24 -07:00
Nicolas Gallagher
e3170623f1 [fix] use ES modules everywhere
Webpack doesn't like mixing `import` with `module.exports`, and some of
the dynamic requires cannot be safely used in both an ES and CommonJS
module environment without looking for `.default` each time.
2018-05-25 15:45:38 -07:00
Nicolas Gallagher
392de22992 0.7.3 2018-05-25 15:39:03 -07:00
Sunny R Gupta
c84163d80e Fix typo in examples text 2018-05-25 15:06:48 -07:00
Philipp Spiess
50442c4e7c [fix] ResponderEventPlugin with React 16.4
React 16.4 includes the necessary ResponderEventPlugin dependencies and
makes some changes to the event internals that causes a breaking change.
This patch fixes rendering with react-dom@16.4 while preserving
backward-compatibility with earlier versions of react-dom.

Close #908
2018-05-25 15:02:28 -07:00
Nicolas Gallagher
eb0e0b8771 0.7.2 2018-05-19 08:46:55 -07:00
Nicolas Gallagher
15d5e57e92 [fix] convert VirtualizedList vendor code to ES modules
Webpack has trouble bundling a mix of CommonJS and ES modules in the
same package.

Fix #957
2018-05-19 08:45:21 -07:00
Nicolas Gallagher
def873e9e3 0.7.1 2018-05-18 18:16:51 -07:00
Nicolas Gallagher
9e9b40f155 [fix] ResponderEventPlugin injection for tree-shaking bundler
Previously this depended on a side-effecting `import` statement which
would be removed under tree-shaking.
2018-05-18 18:13:30 -07:00
Nicolas Gallagher
4a45595b7a 0.7.0 2018-05-18 17:29:47 -07:00
Nicolas Gallagher
45095fd300 Documentation updates 2018-05-18 17:27:39 -07:00
Nicolas Gallagher
004c7ce478 [change] export ES modules by default
ES modules are the default package export. Commonjs modules are exported
from 'dist/cjs'. Modern bundlers like webpack can consume ES modules.
The addition of the `sideEffects:false` to the `package.json` helps
webpack tree-shaking modules.
2018-05-18 17:27:36 -07:00
Nicolas Gallagher
96c3f09fac [fix] Firefox UI for numeric TextInput
Fix #900
2018-05-18 13:40:15 -07:00
Nicolas Gallagher
edc99e79eb [change] ResponderEventPlugin filters browser emulated mouse events
Browsers dispatch mouse events after touch events:
https://developer.mozilla.org/en-US/docs/Web/API/Touch_events/Supporting_both_TouchEvent_and_MouseEvent

There have been several attempts to avoid this behaviour affecting the
ResponderEvent system. The previous approach of cancelling the event in
the `onResponderRelease` event handler can end up cancelling other
events that are expected, e.g., `focus`.

Instead, this patch changes the `ResponderEventPlugin.extractEvents`
function to filter the mouse events that occur a short time after a
touch event. (It's assumed that people will not be clicking a mouse
within a few hundred ms of performing a touch.) This allows the
ResponderEvent system to function as expected and leaves other callbacks
to fire as they would be expected to in React DOM, i.e., both
`onTouchStart` and `onMouseDown` will be called following a touch start.

Fix #835
Fix #888
Fix #932
Close #938
Ref #802
2018-05-18 13:39:25 -07:00
Nicolas Gallagher
e8f2c98786 [add] mark focusable DOM nodes with 'data-focusable'
Focus-based UIs can use out-of-tree focus algorithms to manage focus
using remote control devices. This patch marks DOM nodes that React
Native considers "focusable".

Close #827
2018-05-18 11:56:56 -07:00
Nicolas Gallagher
dcdf1468f9 [fix] onLayout timing without ResizeObserver
onLayout is called after the component is mounted to the DOM. This makes
both the fallback and ResizeObserver code path behave the same as React
Native.

Fix #911
Fix #941
Close #939
2018-05-18 11:44:30 -07:00
Nicolas Gallagher
ee5e80064f [add] support for CSP policy requiring 'nonce' on <style>
CSP policy may prevent writing to `<style>` unless a `nonce` attribute
is set. This change makes that possible by moving the modality-related
styles into the main style sheet, and allowing additional props to be
provided to the `<style>` element when rendering on the server. For
example:

```
const { element, getStyleElement } = AppRegistry.getApplication('App');
const html = renderToString(element);
const css = renderToStaticMarkup(getStyleElement({ nonce }));
```
2018-05-18 11:44:24 -07:00
Philipp Spiess
3e4d8d6b2f Upgrade React and all transitive dependencies
Close #942
2018-05-16 15:01:19 -07:00
Nicolas Gallagher
d3a8270d55 Add a development sandbox to storybook 2018-05-09 10:38:34 -07:00
Nicolas Gallagher
18933724d6 Remove @providesModule from all modules
Ref: d5e9e55fa3
2018-05-08 10:28:25 -07:00
Nicolas Gallagher
e7f84a9228 Add GitHub issue templates
Close #931
2018-05-08 10:11:27 -07:00
Scott Kyle
8b1e6f816f [change] remove NetInfo.isConnected.getConnectionInfo()
React Native doesn't have `NetInfo.isConnected.getConnectionInfo()`.
This was incorrectly added to the API while updating the main `NetInfo`
API.

Close #937
2018-05-08 10:01:41 -07:00
Scott Kyle
02b6f3ff3c [fix] findNodeHandle import in VirtualizedList
Close #936
2018-05-08 09:53:50 -07:00
odalay
6f52007cc8 Fix CheckboxScreen link on website
Close #926
2018-05-08 09:53:16 -07:00
Nicolas Gallagher
1e59e53e66 Update jest 2018-05-08 09:49:02 -07:00
Nicolas Gallagher
f6a65210ca Update formatter and linter 2018-05-08 09:24:08 -07:00
Nicolas Gallagher
2e9071eb0e Update benchmarks dependencies 2018-05-08 09:15:51 -07:00
Nicolas Gallagher
8f25fcc05b Update storybook dependencies 2018-05-07 15:00:22 -07:00
Nicolas Gallagher
1e8577fc9e [fix] setting flex styles as inline styles
Reverts #648 as browsers are inconsistent in how they handle
'flex-basis', so this hack isn't effective. And React has no support for
using '!important' in inline styles.

Fix #798
2018-04-30 11:51:18 -07:00
Nicolas Gallagher
c51f567d19 Simplify tests for several exported modules 2018-04-24 15:54:40 -07:00
Nicolas Gallagher
bce5957991 0.6.1 2018-04-21 12:16:05 -07:00
Nicolas Gallagher
34d8409d43 Update yarn.lock 2018-04-21 12:15:18 -07:00
Sébastien Lorber
8442f13e96 Add Gatsby integration to README
Close #868
2018-04-21 12:12:50 -07:00
Nicolas Gallagher
c6e2b584af [fix] AppRegistry.getApplication shouldn't throw if missing options
Fix #899
2018-04-21 12:05:42 -07:00
Philipp Spiess
38affa9bae Fix Game2048 on desktop browsers
The React Native example only listens for touch events but on web we can
listen to mouse events to improve support.

Close #909
2018-04-21 11:56:14 -07:00
Nicolas Gallagher
f9ebdb6327 Documentation layout fixes 2018-04-21 11:50:39 -07:00
Nicolas Gallagher
83a8758f68 0.6.0 2018-04-15 15:56:10 -07:00
MoOx
e022d166dd Update Phenomic integration link to official example 2018-04-15 15:26:24 -07:00
Nicolas Gallagher
1a225bc449 [fix] Text onPress event propagation
The press event should not propagate.

Fix #897
2018-04-15 15:23:32 -07:00
Nicolas Gallagher
cf2612663b [fix] createElement uses provided function component
If the component provided to 'createElement' is not a string alias for a
DOM component, it will no longer attempt to replace that component with
a DOM component inferred from the 'accessibility{Component,Role,Traits}'
prop.

Fix #895
2018-04-15 15:03:34 -07:00
Nicolas Gallagher
1aec803086 [fix] Picker.Item support for 'color' prop
Not well supported by browsers.

Fix #810
2018-04-08 11:43:20 -07:00
Nicolas Gallagher
2050730b77 [fix] consistency of nativeEvent.location{X,Y} between touch and mouse
Calculate `location{X,Y}` in the same way for both touch and mouse
events. Also defer the call to `getBoundingClientRect` to avoid
unnecessary DOM queries when the data is not used.
2018-04-08 11:05:12 -07:00
Nicolas Gallagher
a67bf0f490 [change] synchronous layout measurement 2018-04-08 10:38:31 -07:00
Nicolas Gallagher
4529a4ac0a Update benchmarks dependencies 2018-04-07 17:20:01 -07:00
Giuseppe Gurgone
5a04d07a35 [change] call 'onLayout' when elements are resized
Uses ResizeObserver to monitor layout changes. Falls back to
window.onresize (with initial firing).

Fix #60
Close #848
2018-04-07 17:03:17 -07:00
Nicolas Gallagher
9427eea293 [add] VirtualizedList support
Make changes needed to run VirtualizedList using React Native for Web.

Close #659
2018-04-07 10:25:15 -07:00
Nicolas Gallagher
b9803e1e07 Add snapshot of VirtualizedList from React Native
Exact source code of the module and its dependencies, for the given SHA.
2018-04-07 10:25:15 -07:00
slorber
7a3a9a5c3f [add] AppRegistry support for React render callback
Close #858

Co-authored-by: Nicolas Gallagher <nicolasgallagher@gmail.com>
2018-04-07 10:15:17 -07:00
Nicolas Gallagher
4c59343fd3 [fix] SafeAreaView inset padding for Safari
See https://webkit.org/blog/7929/designing-websites-for-iphone-x/

Fix #859
2018-04-02 14:32:15 -07:00
Nicolas Gallagher
ce89b7e3ec [change] move 'react-art' to peerDependencies 2018-04-02 14:31:26 -07:00
Nicolas Gallagher
23fa663a6e [fix] Text font styling
Don't use 'font' shorthand internally to reset font styles, as the
framework's internal styles may be injected after application styles,
causing 'font' to override 'font-*' properties.

Fix #881
2018-04-02 11:37:59 -07:00
Nicolas Gallagher
b96dd668d3 [add] AppRegistry provider methods
Adds support for the following methods in React Native:
- setComponentProviderInstrumentationHook
- setWrapperComponentProvider
2018-04-01 10:29:27 -07:00
Nicolas Gallagher
a9cacb2ef5 [change] AppRegistry container is not absolutely positioned
Aligned with latest layout of AppContainer in React Native.

Fix #871
2018-04-01 09:47:02 -07:00
Nicolas Gallagher
c122814591 0.5.4 2018-04-01 09:34:51 -07:00
Bruno Lemos
efe18f1b7e [fix] Linking.openURL on Firefox
Fix #883
Close #884
2018-04-01 09:25:16 -07:00
Nicolas Gallagher
e1b576e427 [add] StyleSheet support for 'System' in font stack
Allow 'System' to be used in a font-family stack, e.g., "Noto, System".

Update the 'System' font stack to include "system-ui", which is the
latest keyword for system fonts.
2018-03-31 14:57:29 -07:00
Nicolas Gallagher
5d77d6e30f [fix] TextInput focus management
Defer to the browser's native handling of 'blur' and 'focus'; directly
update the internal state of TextInputState. Fixes an issue with
preserving focus when the tab is backgrounded.

Also ensure the TextInputState is correctly set when a component mounts.
When 'autoFocus' is true, 'onFocus' can be called before the internal
ref is set.

Fix #880
2018-03-31 14:01:19 -07:00
Jesús Darío
8fb9a88ee6 Add webpack-cli to getting started guide 2018-03-29 15:49:43 -07:00
Kyle Goggin
a7cda988ef [fix] ignore 'tvParallaxProperties' prop
Close #867
2018-03-29 15:47:39 -07:00
Nicolas Gallagher
b239cfb04d [fix] update InteractionManager stub
Fix #875
2018-03-29 15:32:38 -07:00
Nicolas Gallagher
8e94d858b2 [fix] Picker prop types
Fix #879
2018-03-29 15:11:16 -07:00
Nicolas Gallagher
aa22b06359 0.5.3 2018-03-15 13:32:24 -07:00
Paul Armstrong
2aa565c7c3 [fix] Picker default fontFamily
Close #860
2018-03-15 13:08:23 -07:00
Sakamoto, Kazunori
7b9b57960d Update getting-started.md
Fix __DEV__ value in example web/webpack.config.js

Close #862
2018-03-15 13:06:58 -07:00
Nicolas Gallagher
eae3ee9dca 0.5.2 2018-03-07 19:56:46 -08:00
Nicolas Gallagher
74e1a196b6 [fix] Linking.openURL works with nonce use
`Linking` no longer uses an iframe hack to add 'noopener' support to
older Safari. Instead it relies on browsers having support for
'noopener'.

Fix #837
Close #846
2018-03-05 11:50:08 -08:00
Nicolas Gallagher
48da9814e7 Update benchmark libraries 2018-03-05 10:40:02 -08:00
Nicolas Gallagher
4d391ef57c Link to example integrations in README 2018-03-05 10:22:26 -08:00
Nicolas Gallagher
780df69a80 Update link to Glitch starter 2018-03-01 19:37:12 -08:00
Nicolas Gallagher
6c229da01f Minor improvement to AppRegistry console.log message 2018-02-26 15:20:35 -08:00
Nicolas Gallagher
ae7aa818fb 0.5.1 2018-02-20 17:48:12 -08:00
Nicolas Gallagher
306cf67932 [add] Image style support for animations, interactions, and filters 2018-02-20 17:45:19 -08:00
Nicolas Gallagher
619c2048be [add] support for 'transformStyle' style prop 2018-02-20 17:44:22 -08:00
Nicolas Gallagher
b9f9a4f8d7 Move some View style propTypes to InteractionPropTypes 2018-02-20 17:43:22 -08:00
Nicolas Gallagher
58bc18c2f5 Group 'transition' style propTypes with animations 2018-02-20 17:42:19 -08:00
Nicolas Gallagher
073940fc4e Group 'perspective' style propType with transforms 2018-02-20 17:40:57 -08:00
Nicolas Gallagher
5c462303de Inline some values in TextStylePropTypes 2018-02-20 17:32:45 -08:00
Nicolas Gallagher
5fb92da317 [fix] Switch layout when left/right do not flip
The I18nManager can now disable the automatic BiDi flipping of
left/right, which caused the Switch layout to break in RTL mode. Change
the styles to use start/end.
2018-02-20 16:44:46 -08:00
Nicolas Gallagher
cafe10d851 Improve View 'pointerEvents' example 2018-02-19 18:48:31 -08:00
Nicolas Gallagher
b28581f44e [fix] Touchable 'touchAction' value 2018-02-19 18:27:49 -08:00
Nicolas Gallagher
9333e7e887 0.5.0 2018-02-19 15:48:05 -08:00
Nicolas Gallagher
b28cbbb37e [fix] TextInput default font styles
Match React Native (and web) expected defaults.
2018-02-19 15:29:05 -08:00
Nicolas Gallagher
a53372ceb3 [fix] babel-plugin only rewrites paths for known modules
Don't rewrite import paths for non-existent modules or types. They will
attempt to be imported from the package's main export. This change
currently requires a module map to be generated for the babel-plugin to
use. The map is automatically regenerated for any commit that alters the
entry file of react-native-web.

Fix #822
2018-02-19 13:05:42 -08:00
Nicolas Gallagher
239a43978f Update yarn.lock 2018-02-18 17:43:22 -08:00
Nicolas Gallagher
b4e4bfbb3c Fix the event handlers with event normalization
Events are now normalized within the responder system, so those handlers
don't need to be listed anymore. Recently added events (blur,
contextmenu, focus) are now also normalized.
2018-02-18 17:42:02 -08:00
Nicolas Gallagher
893963a799 [fix] PanResponder grant firing twice on touch devices
Touch events can produce trailing mouse events, which cause unwanted
events to fire in the responder event system.  This issue is avoided in
`Touchable` by cancelling the event in the responder release callback.
To fix the issue in other areas, like the PaneResponder, this hack is
moved into `createElement` and applied to event `onResponderRelease`
callback.

Fix #802
2018-02-18 17:41:48 -08:00
Nicolas Gallagher
e5adc5a37c Add 'coveragePathIgnorePatterns' to jest config 2018-02-17 18:03:36 -08:00
Nicolas Gallagher
6d908189a7 [fix] Text support for 'fontVariant' style
Fix #824
Close #825
2018-02-17 18:03:31 -08:00
Nicolas Gallagher
31db333ba3 [fix] Image support for SVG base64 data
The previous fix to support inline SVG data in utf-8 format broke images
that were rendering base64 SVGs.
2018-02-17 15:55:45 -08:00
Nicolas Gallagher
9fe089ca21 [add] development warning about using '!important' in styles
React Native for Web may use '!important' as part of the internal
resolving of styles. But user styles should never be allowed to include
'!important' in the value. Print a warning to the console when they do.
2018-02-17 14:46:31 -08:00
Nicolas Gallagher
a314d5b2e4 [change] MIT license
Now possible to license under MIT following the change to React Native's
license.

26684cf3ad

Fix #828
2018-02-17 12:23:45 -08:00
Nicolas Gallagher
fb845ebf44 Update benchmarks dependencies 2018-02-16 19:08:19 -08:00
Nicolas Gallagher
0d0c7e6e27 Document 'onBlur', 'onFocus', and 'onContextMenu' props 2018-02-16 18:53:33 -08:00
Nicolas Gallagher
f37003a079 Add end/start to BorderPropTypes 2018-02-15 19:08:34 -08:00
Nicolas Gallagher
f1fc2a9e37 Rewrite I18nManager and i18nStyle unit tests 2018-02-15 18:46:08 -08:00
Nicolas Gallagher
92794cdc9f [add] I18nManager and StyleSheet support for RTL without left/right flip
I18nManager supports `doLeftAndRightSwapInRTL` and
`swapLeftAndRightInRTL` to query and control the BiDi-flipping of
left/right properties and values. For example, you may choose to use
`end`/`start` for positioning that flips with writing direction, and
then disable `left`/`right` swapping in RTL so that `left` will always
be `left`.

The StyleSheet resolver cache must also account for the third "direction"
variant: RTL with no swapping of left/right.
2018-02-15 18:45:45 -08:00
Nicolas Gallagher
b754776373 [add] StyleSheet support for start/end properties and values
Add support for new style properties and values that automatically
account for the writing direction (as introduced in React Native
0.51.0). The start/end variants are automatically resolved to match the
global writing direction, as defined by I18nManager.isRTL. Start/End
take precedence over Left/Right.

Adds support for the following properties:

* `borderTop{End,Start}Radius`
* `borderBottom{End,Start}Radius`
* `border{End,Start}Color`
* `border{End,Start}Style`
* `border{End,Start}Width`
* `end`
* `margin{End,Start}`
* `padding{End,Start}`
* `start`

And values:

* `clear: "end" | "start"`
* `float: "end" | "start"`
* `textAlign: "end" | "start"`
2018-02-15 18:43:09 -08:00
Nicolas Gallagher
155b34e495 Fix unit test timeouts on Travis CI
Jest recommends using 'runInBand' for Travis CI. It runs all tests
serially in the current process, rather than creating a worker pool of
child processes that run tests.
2018-02-14 14:26:03 -08:00
Nicolas Gallagher
00c9dc4236 [fix] setNativeProps can apply flex styles
Updates the 'setValueForStyle' implementation to support style values
that contain "!important". This allows the 'flex{Basis,Grow,Shrink}'
values created by the style resolver to be applied. They currently use
the important priority as a work-around for browser-inconsistencies in
the 'flex' shorthand.

Upstream fix: https://github.com/facebook/react/pull/12181

Ref #798
Close #813
2018-02-14 13:51:00 -08:00
Nicolas Gallagher
b66aba1a06 website: fix ImageBackground source code link
Close #820
2018-02-14 13:39:14 -08:00
Nicolas Gallagher
17f8a674b8 [fix] ResponderEventPlugin skips 'mouseup' when no touch is active
Prevent the responder system recording 'mouseup' events if there is no
active 'touch'.

Fix #816
2018-02-13 15:02:09 -08:00
Nicolas Gallagher
b8080ba775 [fix] Touchable press events regression in 9ee89bc
Fix a regression introduced by "ResponderEvent event filtering"
9ee89bc7f7. Touchable press events were
firing twice after the event normalization was moved up into
'extractEvents'. The reason is:

1) events were previously not normalized throughout the responder system
2) once they were normalized, the fix introduced by a535c558d8 stopped working
3) because normalized nativeEvent did not include event data like 'cancelable'.

This patch adds more of the original nativeEvent fields to the
normalized event, so that React's synthetic event can return the correct
information for 'bubbles', 'cancelable', 'isDefaultPrevented()', etc.
2018-02-13 13:34:17 -08:00
Nicolas Gallagher
7265736545 [fix] StyleSheet accepts 'space-evenly' value for 'justifyContent' 2018-02-12 10:35:30 -08:00
Bulat Kidasov
399f465e59 [fix] NativeMethodsMixin measure/measureInWindow with scroll
Account for scroll offsets when calculating measurements.

Fix #702
Fix #805
Close #806
2018-02-12 10:27:47 -08:00
Nicolas Gallagher
9ee89bc7f7 [fix] ResponderEventPlugin event filtering
Exclude middle, wheel, and right click mouse events from the responder
system. This fixes the Touchables incorrectly triggering 'onPress' in
response to these events.

Filter mousemove events in the 'extractEvents' methods, and check for
active touches rather than the length of the touch bank. This fixes the
PanResponder not functioning after the first touch in Firefox.

Fix #719
Fix #729
Close #804
2018-02-12 10:08:44 -08:00
Jakub Rimal
748b2d0f3f [fix] Image 'source' prop update when missing in initial render
Close #811
2018-02-12 08:27:48 -08:00
Nicolas Gallagher
fb4635e013 Update README's 2018-02-08 16:09:56 -08:00
Nicolas Gallagher
73b459e770 [add] TextInput onKeyPress support for arrow keys
Close #791
Close #792
2018-02-08 10:57:32 -08:00
Nicolas Gallagher
a41af0f65f 0.4.0 2018-02-06 16:35:20 -08:00
Nicolas Gallagher
96eecc0da3 Replace lerna with custom script
Each package version is now updated with each release.

Fix #783
2018-02-06 16:30:03 -08:00
Nicolas Gallagher
69d5373222 [fix] Firefox rendering of TextInput
Removes UA controls from numeric inputs in Firefox, and makes the
default border solid in all browsers.

Fix #789
2018-02-06 11:17:38 -08:00
Nicolas Gallagher
538ab88eda Separate modules for StyleSheet and related side-effects 2018-02-05 12:18:43 -08:00
Nicolas Gallagher
21b3f39c0b [fix] babel-plugin require call for compiled modules
require('module') => require('module').default

Fix #786
2018-02-04 10:42:21 -08:00
Nicolas Gallagher
998e275e65 [add] CSS keyframes support via 'animationName' style
Keyframes can be defined using an array of objects as the value of
'animationName'. Each keyframe is transformed into a CSS keyframe rule.
2018-02-03 11:48:57 -08:00
Nicolas Gallagher
31d428a649 [fix] add support for TextInput placeholderTextColor prop
This change also ensures that potential object-styles (user-provided or
placeholderTextColor) are group together at the end of the style array.

Fix #560
2018-01-31 10:55:45 -08:00
Nicolas Gallagher
240cf7e05f [change] AppRegistry and StyleSheet APIs to fix SSR
SSR was not working correctly. Styles would accumulate in the style
cache and the styles returned for each 'getApplication' call would not
represent the styles needed to render a given tree, but rather all the
styles needed to render every tree that has been rendered by that server
instance.

This is now fixed by reinitializing the style resolver after a call to
'getStyleSheet' on the server. The return type of
'AppRegistry.getApplication' is changed – { element, getStyleElement }.
The 'getStyleElement' function must be called after the component tree
has been rendered.  Note that if 'getStyleElement' is not called for a
response, then its styles may leak into the next response's styles (but
will not affect the UX).

This patch also removes the 'StyleSheet.getStyleSheets' (web-only) API
and requires SSR to be done using 'AppRegistry.getApplication'.

Fix #778
2018-01-31 10:55:45 -08:00
Nicolas Gallagher
2ad710d83a [change] StyleSheet does not eagerly resolve and inject styles
Resolving styles at the same time as they are registered is problematic.
This work doesn't need to be complete until the moment a component is
rendered, rather than being done at startup.
2018-01-31 10:55:45 -08:00
Nicolas Gallagher
dcce72b66e Reorganize style resolver
The style resolver is reorganized to remove React Native style
registration, and contain all the stateful resolver logic (previously
partially found in NativeMethodsMixin).

Style registration is done in 'StyleSheet.create', and will subsequently
be decoupled from eager style resolution.

The stateful resolver is fully contained in the
ReactNativeStyleResolver. The options are removed from the resolver as
they aren't needed to implement the correct i18n-ified styles. This
functionality is also covered by unit tests now.
2018-01-31 10:55:44 -08:00
Nicolas Gallagher
083769d642 [fix] resolve inline-style pointerEvents to classNames
pointerEvents styles are now always resolved to classNames, even if
working with dynamic styles. In practice, inline-style pointerEvents
have always resolved to classNames as an accident of 'createElement'
registering each pointerEvent style. However, this patch ensures that
the style resolver produces correct output, and introduces the basic
mechanism by which 'placeholderTextColor' (for which classNames cannot
be precomputed) could function similarly.
2018-01-31 10:55:44 -08:00
Nicolas Gallagher
a53dba8c62 [change] simplify CSS rule injection
WebStyleSheet handles injecting CSS rules and returning the style
sheet's text content.

All CSS, including the reset, is now added using WebStyleSheet and the DOM API 'insertRule'.
Browsers will throw a parse error on unrecognized vendor-prefixes in
selectors, so rules with unsafe selectors are wrapped in '@media all {}'
before being passed to 'insertRule'. (This will be relevant when
attempting to support 'placeholderTextColor'. And it is a way to
batch-insert rules with a single call to 'insertRule'.)

The html tag 'font-family' CSS reset is removed as it's not needed.
2018-01-31 10:55:44 -08:00
Nicolas Gallagher
670d43ba04 Refactor how pointerEvents styles are managed 2018-01-31 10:55:44 -08:00
Nicolas Gallagher
73a731f2da Rename StyleManager and StyleRegistry 2018-01-31 10:55:44 -08:00
Nicolas Gallagher
1542f1f369 0.3.4 2018-01-31 10:31:50 -08:00
Nicolas Gallagher
6f58d7abe7 [fix] TextInput support for spellCheck prop
Fix #501
2018-01-31 10:27:08 -08:00
Nicolas Gallagher
7e0fbf9691 Fix yarn.lock
Yarn didn't make these changes to yarn.lock after updating packages.
2018-01-29 12:46:12 -08:00
Maximilian Stoiber
865034e8f7 Update benchmark instructions 2018-01-29 12:40:37 -08:00
Nicolas Gallagher
6e96ee4f3c Update benchmarked libraries 2018-01-29 08:59:18 -08:00
Maxime Thirouin
16d98b49f0 [fix] ignore native-only Image props
Close #788
2018-01-26 14:59:59 -08:00
Nicolas Gallagher
d04721c75a Update yarn.lock 2018-01-23 13:01:48 -08:00
Nicolas Gallagher
8512709251 Fix benchmark picker touch target size in Safari 2018-01-23 12:24:56 -08:00
Nicolas Gallagher
efeaea70a9 Benchmarks include forced layout time
This change to 'benchmarks' reports the time taken to perform a forced
layout after mounting the tree. Adding a forced layout to the stress
tests can surface how different approaches to styling may affect browser
render timings.

The total time displayed is now the sum of "scripting time" (previously
total time) and "layout time". The layout time is a reflection of the
time the browser takes to perform a style recalculation and relayout of
the document.

The Benchmark component now has a 'forceLayout' prop. When it is 'true'
a forced layout is triggered on componentDidUpdate. The time taken is
added to the sample's timing data.
2018-01-23 12:24:18 -08:00
Nicolas Gallagher
a403244e67 Update benchmarks library dependencies 2018-01-23 09:49:48 -08:00
Oleg Slobodskoi
985c1d63b6 Add benchmarks update test for react-jss
Close #785
2018-01-23 09:11:38 -08:00
Nicolas Gallagher
9d8d4057f6 Benchmark app component optimizations 2018-01-22 15:52:37 -08:00
Nicolas Gallagher
ec8843fe90 Compute benchmark props before each iteration
Fix a bug in the logic that was meant to perform component prop
computation in-between cycles.
2018-01-22 13:24:41 -08:00
Nicolas Gallagher
935970156c Benchmarks report total run time 2018-01-21 17:02:21 -08:00
Nicolas Gallagher
e4e6147081 0.3.3 2018-01-19 14:05:46 -08:00
Nicolas Gallagher
3e1b68d801 Add Moto G4 example benchmark results 2018-01-19 13:59:13 -08:00
Giuseppe Gurgone
1b493c9914 Add styled-jsx to benchmarks
Close #782
2018-01-19 12:51:21 -08:00
hushicai
6ecdc1a517 [fix] babel-plugin VariableDeclaration case
Convert VariableDeclarations, e.g.,

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

Close #781
2018-01-19 00:09:43 -08:00
Nicolas Gallagher
619079cedf Move babel-plugin npm badge to correct README 2018-01-18 10:24:02 -08:00
Javi Velasco
bbf7674b43 Add react-fela to benchmarks
Close #779
2018-01-18 10:03:13 -08:00
Nicolas Gallagher
f163e4f16f Use full URLs for README links 2018-01-18 09:50:14 -08:00
Nicolas Gallagher
bd8c2d6f24 Add npm badge to babel-plugin-react-native-web README 2018-01-18 09:49:54 -08:00
Nicolas Gallagher
3906b6b41b Add benchmarks app link to README 2018-01-17 19:38:58 -08:00
Nicolas Gallagher
753ef963f6 0.3.2 2018-01-17 19:18:50 -08:00
Nicolas Gallagher
0721245b3e Patch release script
Disable husky on version commit. Current publish script doesn't account
for attempts to republish the same version.
2018-01-17 19:15:23 -08:00
Nicolas Gallagher
b7adfd5f32 [fix] Picker.Item label text
Render the label as a child of 'option' rather than using the 'label'
attribute.

Fix #774
2018-01-17 17:59:05 -08:00
Nicolas Gallagher
a9342daee2 Add release script for benchmarks 2018-01-17 17:40:13 -08:00
Nicolas Gallagher
ed0cafac7c Rewrite benchmarks app
Reorganizes and rewrites the benchmarks. Each implementation is now
self-contained and the benchmarks can be run using a GUI. The benchmarks
themselves have been changed so that individual tests render over a
shorter time frame and more samples are taken.
2018-01-17 17:21:53 -08:00
Nicolas Gallagher
6e6fd4b5d0 Add note about Object.assign polyfill to docs 2018-01-16 17:14:17 -08:00
Nicolas Gallagher
5cd533e6cc 0.3.1 2018-01-16 11:15:45 -08:00
Nicolas Gallagher
d5e8d85ce9 Fix example in babel plugin README 2018-01-16 11:11:50 -08:00
Nicolas Gallagher
e234568a34 Fix source links in documentation 2018-01-11 12:59:44 -08:00
Nicolas Gallagher
19cf0711bc [add] StyleSheet support for 'overscrollBehavior'
An experimental CSS property to control the behavior when the scroll
position of a scroll container reaches the edge of the scrollport. This
allows web apps to get closer to native scrolling behaviour and
performance.

https://wicg.github.io/overscroll-behavior/
https://developers.google.com/web/updates/2017/11/overscroll-behavior

Fix #765
2018-01-11 12:58:43 -08:00
Johannes
067e3f346f [fix] KeyboardAvoidingView missing 'this' binding
Close #762
2018-01-11 12:53:54 -08:00
Nicolas Gallagher
2117e44e9d [fix] limit Image loader deferral to 1000ms
This patch introduces a limit on how long image loading is deferred, and
mitigates an issue with lengthy delays to 'requestIdleCallback' in the
Chrome browser.

Fix #759
2018-01-11 12:08:30 -08:00
Nicolas Gallagher
902ba22877 Update to flow-bin@0.63.1 2018-01-09 17:49:52 -08:00
Nicolas Gallagher
60c2cd65df Update to lint-staged@6.0.0 2018-01-09 17:36:19 -08:00
Nicolas Gallagher
fde29326f1 Update to lerna@2.6.0 2018-01-09 17:35:53 -08:00
Nicolas Gallagher
44d795437e Update to storybook@3.3.6 2018-01-09 17:34:28 -08:00
Nicolas Gallagher
03598d869b Update to babel-plugin-tester@5.0.0 2018-01-09 17:31:52 -08:00
Nicolas Gallagher
a3e44a5c60 Update to enzyme@3.3.0 2018-01-09 17:27:38 -08:00
Nicolas Gallagher
02b124eceb Update yarn.lock 2018-01-08 18:53:05 -08:00
Nicolas Gallagher
91472bc3d6 0.3.0 2018-01-08 18:42:16 -08:00
Nicolas Gallagher
7f45c52ce7 Update to inline-style-prefixer@4.0.0 2018-01-08 18:31:36 -08:00
Nicolas Gallagher
b6ef1d3a36 [fix] handle "monospace" font-family on web
This hack corrects the inheritance and scaling of font size when the
font-family is "monospace".
2018-01-08 12:19:24 -08:00
Maxime Thirouin
fd6ccbcfb3 [fix] ignore more native-only View/Text props
Fix #735
Close #753
2018-01-08 12:10:46 -08:00
Maxime Thirouin
17614e348b Use prettier config instead of CLI args
This allows IDE plugins that rely on prettier config (introduced in
[1.6.0](https://github.com/prettier/prettier/pull/2434)) to detect
prettier and run it automatically with the correct config.

Close #757
2018-01-08 12:06:58 -08:00
Maxime Thirouin
c26ef0eb3b Run precommit hook automatically
Help to ensure that code is formatted and linted before commits and PRs.

Fix #755
Close #756
Close #754
2018-01-08 11:59:26 -08:00
Nicolas Gallagher
b78206d2f4 Remove 'transform-runtime' from webpack example 2018-01-08 11:49:28 -08:00
Nicolas Gallagher
69e0396fb1 Minor README edit 2018-01-05 16:35:39 -08:00
Nicolas Gallagher
6d9154196e [fix] StyleSheet.hairlineWidth guard against missing document.body 2018-01-04 14:30:24 -08:00
Nicolas Gallagher
87fdd6c73b [change] 'react-native-web' module organization and exports
The patch reorganizes the top-level module division of the
'react-native-web' project.

Previously, the package's exported modules were found in:

    apis/*/index.js
    components/*/index.js
    components/*/*.js
    modules/*/index.js
    propTypes/*.js

Now, each part of the exported API is found in:

    exports/*/index.js

And anything not directly part of the exported API is found in:

    modules/*/index.js
    vendor/*/index.js

Close #748
2018-01-04 14:30:24 -08:00
Nicolas Gallagher
209bd3aee1 [fix] babel-plugin support for 'react-native-web' module name
Now rewrites import/export/require statements from 'react-native-web'.
Install the plugin in the 'benchmarks' package.
2018-01-01 12:01:22 -08:00
Nicolas Gallagher
46e77d0b00 Change babel presets
Tune the compiled output to reduce file size.
2017-12-31 15:47:16 -08:00
Nicolas Gallagher
6f10f6be9c [fix] AppRegistry.unmountApplicationComponentAtRootTag
Fixes the bad import of a named export rather than the default export.
2017-12-30 19:06:03 -08:00
Nicolas Gallagher
0d0fdc15ac Minor docs fixes 2017-12-30 18:43:05 -08:00
Nicolas Gallagher
bff3f50ae0 Fix release script 2017-12-30 18:42:35 -08:00
Liron Yahdav
85aaa39206 [fix] i18n of styles when using 'setNativeProps'
Close #732
2017-12-30 14:31:22 -08:00
Nicolas Gallagher
b85a7062be Fix formatting of benchmarks table 2017-12-30 14:11:54 -08:00
Nicolas Gallagher
af47d5f414 [fix] React warning when using hitSlop prop
Make sure the hitSlop element has a 'key'.

Fix #743
2017-12-30 14:06:33 -08:00
Nicolas Gallagher
41d90e0238 [fix] ReactDOM hydration warnings in development
Don't try to hydrate from SSR HTML during development.

Fix #745
2017-12-30 14:02:01 -08:00
Nicolas Gallagher
86263a2fa0 Reorganize and add to benchmarks
Rearrange the benchmark code so that each implementation is
self-contained. Adds the SierpinskiTriangle case that 'emotion'
introduced in their fork of the 'react-native-web' benchmarks. And make
it possible to run benchmarks on a per-library basis.
2017-12-30 13:53:04 -08:00
Nicolas Gallagher
f6d1caab9d Document web-only Switch props 2017-12-26 09:19:04 +00:00
Nicolas Gallagher
1776891736 Improve project introduction and guides
Adopt the structure of the React README and improve the contribution
guidelines to include Facebook's CoC. Fix various links following the
move to a monorepo.
2017-12-26 09:12:15 +00:00
Nicolas Gallagher
f52a851972 Use an .eslintignore file 2017-12-24 12:50:44 +00:00
Nicolas Gallagher
3026465ae3 Monorepo
Introduces a monorepo structure, relies on yarn workspaces to share
dependencies, and lerna for syncing versions across the monorepo.

* Create 2 workspaces:
    'packages' and 'website'
* Create 2 public packages:
    'babel-plugin-react-native-web' and 'react-native-web'
* Create 1 private package:
    'benchmarks'

A simple release script runs the tests, builds the package assets,
increments the package version numbers, git commits and tags, publishes
the package to npm, pushes the changes to github, and releases the
website update.

Close #657
2017-12-24 12:33:41 +00:00
Nicolas Gallagher
14d87f4b30 Fix tests not running in CI
Accidentally stopped running tests after this patch:
9a5b932139
2017-12-23 13:16:53 +00:00
Nicolas Gallagher
5881f07323 Fix typo in benchmark results 2017-12-20 23:23:24 +00:00
937 changed files with 57541 additions and 34689 deletions

5
.eslintignore Normal file
View File

@@ -0,0 +1,5 @@
coverage
dist
node_modules
packages/**/vendor/*
packages/examples

View File

@@ -1,4 +1,11 @@
{
"settings": {
"react": {
"pragma": "React",
"version": "16.6",
"flowVersion": "0.109.0" // Flow version
}
},
// babel parser to support ES6/7 features
"parser": "babel-eslint",
"parserOptions": {
@@ -10,30 +17,24 @@
"sourceType": "module"
},
"extends": [
"plugin:flowtype/recommended",
"prettier",
"prettier/react"
],
"plugins": [
"flowtype",
"promise",
"react"
"react",
"react-hooks"
],
"env": {
"browser": true,
"es6": true,
"jest": true,
"node": true
},
"globals": {
"document": false,
"navigator": false,
"window": false,
// Flow global types
"HTMLInputElement": false,
"ReactClass": false,
"ReactComponent": false,
"ReactElement": false,
"ReactPropsChainableTypeChecker": false,
"ReactPropsCheckType": false,
"ReactPropTypes": false,
"SyntheticEvent": false
},
"rules": {
"camelcase": 0,
@@ -123,12 +124,16 @@
"valid-typeof": 2,
"yoda": [2, "never"],
// flow
"flowtype/generic-spacing": 0,
"flowtype/space-after-type-colon": 0,
// promise
"promise/param-names": 2,
// react
"react/display-name": 0,
"react/jsx-no-bind": 2,
"react/jsx-no-bind": 0,
"react/jsx-no-duplicate-props": 2,
"react/jsx-no-undef": 2,
"react/jsx-pascal-case": 2,
@@ -142,11 +147,15 @@
"react/no-string-refs": 2,
"react/no-unknown-property": 2,
"react/prefer-es6-class": 2,
"react/prop-types": 2,
"react/prop-types": 0,
"react/react-in-jsx-scope": 0,
"react/self-closing-comp": 2,
"react/sort-comp": 0,
"react/sort-prop-types": 2,
"react/wrap-multilines": 0
"react/wrap-multilines": 0,
// react-hooks
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
}
}

View File

@@ -1,13 +1,20 @@
[version]
^0.109.0
[ignore]
.*/__tests__/.*
.*/benchmarks/.*
.*/docs/.*
<PROJECT_ROOT>/.*/__tests__/.*
<PROJECT_ROOT>/packages/.*/dist/.*
<PROJECT_ROOT>/packages/docs/.*
.*/node_modules/babel-plugin-transform-react-remove-prop-types/*
[include]
[libs]
types
<PROJECT_ROOT>/types
[options]
unsafe.enable_getters_and_setters=true
suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState

View File

@@ -4,7 +4,8 @@
Before opening an issue, please search the [issue
tracker](https://github.com/necolas/react-native-web/issues) to make sure your
issue hasn't already been reported.
issue hasn't already been reported. Please note that your issue may be closed
if it doesn't include the information requested in the issue template.
## Getting started
@@ -17,7 +18,7 @@ Fork, then clone the repo:
git clone https://github.com/your-username/react-native-web.git
```
Install dependencies (requires [yarn](https://yarnpkg.com/en/docs/install):
Install dependencies (requires [yarn](https://yarnpkg.com/en/docs/install)):
```
yarn
@@ -25,6 +26,12 @@ yarn
## Automated tests
To run the linter:
```
yarn lint
```
To run flow:
```
@@ -40,62 +47,58 @@ yarn jest
…in watch mode:
```
yarn jest:watch
yarn jest --watch
```
To run all automated tests:
To run all these automated tests:
```
yarn test
```
## Visual tests
To run the interactive storybook:
```
yarn docs:start
```
To generate a static build of the storybook:
```
yarn docs:build
```
To run the performance benchmarks in a browser (opening `./benchmarks/index.html`):
```
yarn benchmark
```
## Compile and build
To compile the source code to `dist`:
To compile the `react-native-web` source code:
```
yarn compile
```
To create a UMD bundle of the library:
…in watch mode:
```
yarn build
yarn compile --watch
```
### Pre-commit
## Documentation and visual tests
To format and lint code before commit:
To run the interactive storybook:
```
yarn precommit
yarn docs
```
To format and lint the entire project:
When you're also making changes to the 'react-native-web' source files, run this
command in another process:
```
yarn fmt
yarn lint
yarn compile --watch
```
## Benchmarks
To run the benchmarks locally:
```
yarn benchmarks
open ./packages/benchmarks/dist/index.html
```
To develop against these benchmarks:
```
yarn compile --watch
yarn benchmarks --watch
```
### New Features
@@ -106,13 +109,12 @@ that we won't want to accept.
## Pull requests
**Before submitting a pull request,** please make sure the following is done:
**Before submitting a pull request**, please make sure the following is done:
1. Fork the repository and create your branch from `master`.
2. If you've added code that should be tested, add tests!
3. If you've changed APIs, update the documentation.
4. Ensure the tests pass (`yarn test`).
5. Lint and format your code (`yarn fmt && yarn lint`).
You can now submit a pull request, referencing any issues it addresses.
@@ -123,3 +125,18 @@ After you have submitted your pull request, we'll try to get back to you as
soon as possible. We may suggest some changes or improvements.
Thank you for contributing!
## Releases
To commit, publish, and push a final version:
```
yarn release <version>
```
Release candidates or versions that you'd like to publish to npm, but do not
want to produce a commit and push it to GitHub:
```
yarn release <version> --skip-git
```

View File

@@ -1,20 +0,0 @@
**Do you want to request a *feature* or report a *bug*?**
**What is the current behavior?**
**If the current behavior is a bug, please provide the steps to reproduce and
if a minimal demo of the problem via Glitch or similar (template:
https://glitch.com/edit/#!/react-native-web-playground).**
1.
2.
**What is the expected behavior?**
**Environment (include versions). Did this work in previous versions?**
* OS:
* Device:
* Browser:
* React Native for Web (version):
* React (version):

52
.github/ISSUE_TEMPLATE/bug.md vendored Normal file
View File

@@ -0,0 +1,52 @@
---
name: "\U0001F41B Bug report"
about: "If something isn't working as expected \U0001F914"
---
<!--
Thank you for reporting an issue. Please note that an issue must include the
information that is marked as REQUIRED below, or it may be closed.
-->
**The problem**
<!--
REQUIRED: A clear and concise description of the bug or problem.
-->
**How to reproduce**
<!--
REQUIRED: Create a test case by forking this template https://codesandbox.io/s/6lx6ql1w5r
Failing to include a reduced test case may result in the issue being closed,
and will delay any potential fix. Your application or GitHub project is NOT
considered a reduced test case. If the issue only affects certain browsers,
providing screenshots is also helpful.
-->
Simplified test case: <!-- add link here -->
Steps to reproduce:
1.
2.
3.
**Expected behavior**
<!--
REQUIRED: A clear and concise description of what you expected to happen.
Please check that the behaviour is not expected React Native behaviour by
running your test case on iOS or Android using https://snack.expo.io.
-->
**Environment (include versions). Did this work in previous versions?**
* React Native for Web (version): TBC
* React (version): TBC
* Browser: TBC
<!--
OPTIONAL:
**Additional context**
Add any other context about the problem here.
-->

17
.github/ISSUE_TEMPLATE/feature.md vendored Normal file
View File

@@ -0,0 +1,17 @@
---
name: "\U0001F680 Feature request"
about: If you have a suggestion
---
**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is, e.g., I have an issue when [...] -->
**Describe a solution you'd like**
<!-- A clear and concise description of what you want to happen. Add any considered drawbacks. -->
**Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->

View File

@@ -1 +0,0 @@
**Before submitting a pull request,** please make sure you have followed the steps the CONTRIBUTING guide.

13
.github/workflows/compressed-size.yml vendored Normal file
View File

@@ -0,0 +1,13 @@
name: compressed-size
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: necolas/compressed-size-action@master
with:
build-script: "compile"
exclude: "./packages/react-native-web/dist/cjs/{index.js,**/*.js}"
pattern: "./packages/react-native-web/dist/{index.js,**/*.js}"
repo-token: "${{ secrets.GITHUB_TOKEN }}"

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
coverage
node_modules
dist

5
.prettierignore Normal file
View File

@@ -0,0 +1,5 @@
coverage
dist
node_modules
packages/**/vendor/*
packages/examples

View File

@@ -1,8 +1,17 @@
language: node_js
node_js:
- "6"
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- "10"
before_install:
# Install Yarn
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
cache:
yarn: true
directories:
- node_modules
script:
- yarn lint
- yarn test

1
.watchmanconfig Normal file
View File

@@ -0,0 +1 @@
{}

45
LICENSE
View File

@@ -1,31 +1,22 @@
BSD License
MIT License
For React Native software
Copyright (c) 2015-present, Nicolas Gallagher.
Copyright (c) 2015-present, Facebook, Inc.
Copyright (c) 2015-present, Nicolas Gallagher. All rights reserved.
Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name Facebook nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

282
README.md
View File

@@ -1,126 +1,216 @@
# React Native for Web
[![Build Status][travis-image]][travis-url]
[![npm version][npm-image]][npm-url]
[![npm version][package-badge]][package-url] [![Build Status][ci-badge]][ci-url] [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://reactjs.org/docs/how-to-contribute.html#your-first-pull-request)
"React Native for Web" brings the platform-agnostic Components and APIs of
[React Native][react-native-url] to the Web.
**Compatibility: React Native >= 0.63**.
Browse the [interactive
documentation](https://necolas.github.io/react-native-web/storybook/) or [try
it out](https://glitch.com/edit/#!/react-native-web-playground) on Glitch.
"React Native for Web" makes it possible to run [React
Native][react-native-url] components and APIs on the web using React DOM.
## Features
* **High-quality web interfaces**: makes it easy to
create [fast](https://github.com/necolas/react-native-web/blob/master/packages/benchmarks/README.md),
adaptive web UIs in JavaScript. It provides native-quality interactions, support
for multiple input modes (touch, mouse, keyboard), optimized vendor-prefixed
styles, built-in support for RTL layout, built-in accessibility, and integrates
with React Dev Tools.
* Interoperability with ReactDOM components.
* Native-like touch handling.
* Built-in integration with web accessibility APIs.
* Built-in support for LTR and RTL layouts.
* Built-in expressive and reliable subset of CSS.
* Optimized, vendor-prefixed CSS with [good runtime performance](benchmarks/README.md).
* Server-side rendering of HTML and critical CSS.
* Browser support: Chrome, Firefox, Safari >= 7, IE 10, Edge.
* **Write once, render anywhere**: interoperates with existing React DOM
components and is compatible with the majority of the React Native API. You can
develop new components for native and web without rewriting existing code.
React Native for Web can also render to HTML and critical CSS on the server
using Node.js.
Who is using React Native for Web in production?
[Twitter](https://mobile.twitter.com),
[Expo](https://docs.expo.io/workflow/web/),
[Major League Soccer](https://matchcenter.mlssoccer.com),
[Flipkart](https://twitter.com/naqvitalha/status/969577892991549440),
[Uber](https://www.youtube.com/watch?v=RV9rxrNIxnY),
[The Times](https://github.com/newsuk/times-components),
[DataCamp](https://www.datacamp.com/community/tech/porting-practice-to-web-part1).
Browser support: Chrome, Firefox, Edge, Safari 7+, IE 10+.
Components and APIs deprecated in React Native are not supported by React Native for Web.
## Quick start
Install in your existing app using `yarn` or `npm`:
```
yarn add react react-dom react-native-web
```
Add the `react-native-web/babel` plugin to your Babel configuration. This will
alias `react-native` to `react-native-web` and exclude any modules not required
by the app.
```json
{
"plugins": [
"react-native-web/babel"
],
"presets": [
"react-native"
]
}
```
(For React/ReactDOM 15.4 15.6 support, install `react-native-web@<0.1.0`)
See the [Getting Started](docs/guides/getting-started.md) guide for more details.
The easiest way to get started is to edit this
[CodeSandbox](https://codesandbox.io/s/q4qymyp2l6) template. You dont need to
install anything to try it out.
## Documentation
The [interactive
documentation](https://necolas.github.io/react-native-web/storybook/) shows all
the supported APIs and Components.
The [documentation app](https://necolas.github.com/react-native-web/docs) covers
installation, configuration, APIs, and guides.
Guides:
The [React Native documentation][react-native-url] contains more information
about the [Gesture Responder
system](https://facebook.github.io/react-native/docs/gesture-responder-system.html),
[animations](https://facebook.github.io/react-native/docs/animations.html), and
other design details.
* [Getting started](docs/guides/getting-started.md)
* [Style](docs/guides/style.md)
* [Accessibility](docs/guides/accessibility.md)
* [Direct manipulation](docs/guides/direct-manipulation.md)
* [Internationalization](docs/guides/internationalization.md)
* [Advanced use](docs/guides/advanced.md)
* [Known issues](docs/guides/known-issues.md)
## Libraries and integrations
## Example code
List of React Native packages with known web compatibility:
* [React Native Directory](https://reactnative.directory/?web=true)
Examples of using React Native for Web with other web tools:
* [Docz](https://github.com/doczjs/docz/tree/master/examples/react-native)
* [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)
(and [example recipes](https://gist.github.com/necolas/f9034091723f1b279be86c7429eb0c96))
* [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)
* [Storybook](https://github.com/necolas/react-native-web/tree/master/packages/docs/)
* [Styleguidist](https://github.com/styleguidist/react-styleguidist/tree/master/examples/react-native)
## Examples
And here is a simple example to get you started. The documentation includes
interactive examples and the [source
code](https://github.com/necolas/react-native-web/blob/master/packages/docs) is
also available.
```js
import React from 'react'
import { AppRegistry, Image, StyleSheet, Text, View } from 'react-native'
import React from 'react';
import { AppRegistry, StyleSheet, Text, View } from 'react-native';
// Components
const Card = ({ children }) => <View style={styles.card}>{children}</View>
const Title = ({ children }) => <Text style={styles.title}>{children}</Text>
const Photo = ({ uri }) => <Image source={{ uri }} style={styles.image} />
const App = () => (
<Card>
<Title>App Card</Title>
<Photo uri="/some-photo.jpg" />
</Card>
)
// Styles
const styles = StyleSheet.create({
card: {
flexGrow: 1,
justifyContent: 'center'
},
title: {
fontSize: '1.25rem',
fontWeight: 'bold'
},
image: {
height: 40,
marginVertical: 10,
width: 40
class App extends React.Component {
render() {
return (
<View style={styles.box}>
<Text style={styles.text}>Hello, world!</Text>
</View>
);
}
})
}
// App registration and rendering
AppRegistry.registerComponent('MyApp', () => App)
AppRegistry.runApplication('MyApp', { rootTag: document.getElementById('react-root') })
const styles = StyleSheet.create({
box: { padding: 10 },
text: { fontWeight: 'bold' }
});
AppRegistry.registerComponent('App', () => App);
AppRegistry.runApplication('App', { rootTag: document.getElementById('react-root') });
```
## Starter kits
This example will render the `App` into a container on the page.
* [Glitch](https://glitch.com/edit/#!/react-native-web-playground)
* [create-react-app](https://github.com/facebookincubator/create-react-app)
You'll notice that there is no reference to `react-dom`; the `App` component is
defined using the platform-agnostic APIs and Components introduced by React
Native. This allows the app to be rendered to web and native platforms.
## Related projects
## Compatibility with React Native
* [react-primitives](https://github.com/lelandrichardson/react-primitives/)
* [react-sketchapp](https://github.com/airbnb/react-sketchapp)
* [reactxp](https://github.com/microsoft/reactxp)
* [react-native-web-player](https://github.com/dabbott/react-native-web-player)
React Native v0.60
### Components
| Name | Status | Notes |
| :----------------------- | :----- | :---- |
| ActivityIndicator | ✓ | |
| Button | ✓ | |
| CheckBox | ✓ | |
| FlatList | ✓ | |
| Image | ✓ | Missing multiple sources ([#515](https://github.com/necolas/react-native-web/issues/515)) and HTTP headers ([#1019](https://github.com/necolas/react-native-web/issues/1019)). |
| ImageBackground | ✓ | |
| KeyboardAvoidingView | (✓) | Mock. No equivalent web APIs. |
| Modal | ✓ | |
| Picker | ✓ | |
| Pressable | ✓ | |
| RefreshControl | ✘ | Not started ([#1027](https://github.com/necolas/react-native-web/issues/1027)). |
| SafeAreaView | ✓ | |
| ScrollView | ✓ | Missing momentum scroll events ([#1021](https://github.com/necolas/react-native-web/issues/1021)). |
| SectionList | ✓ | |
| StatusBar | (✓) | Mock. No equivalent web APIs. |
| Switch | ✓ | |
| Text | ✓ | Missing `onLongPress` ([#1011](https://github.com/necolas/react-native-web/issues/1011)) support. |
| TextInput | ✓ | Missing rich text features ([#1023](https://github.com/necolas/react-native-web/issues/1023)), and auto-expanding behaviour ([#795](https://github.com/necolas/react-native-web/issues/795)). |
| Touchable | ✓ | Includes additional support for mouse and keyboard interactions. |
| TouchableHighlight | ✓ | |
| TouchableNativeFeedback | ✘ | Not started ([#1024](https://github.com/necolas/react-native-web/issues/1024)). |
| TouchableOpacity | ✓ | |
| TouchableWithoutFeedback | ✓ | |
| View | ✓ | |
| VirtualizedList | ✓ | |
| YellowBox | (✓) | Mock. No YellowBox functionality. |
### Modules
| Name | Status | Notes |
| :----------------------- | :----- | :---- |
| AccessibilityInfo | (✓) | Mock. No equivalent web APIs. |
| Alert | ✘ | Not started ([#1026](https://github.com/necolas/react-native-web/issues/1026)). |
| Animated | ✓ | Missing `useNativeDriver` support. |
| Appearance | ✓ | |
| AppRegistry | ✓ | Includes additional support for server rendering with `getApplication`. |
| AppState | ✓ | |
| BackHandler | (✓) | Mock. No equivalent web APIs. |
| Clipboard | ✓ | |
| DeviceInfo | (✓) | Limited information. |
| Dimensions | ✓ | |
| Easing | ✓ | |
| Geolocation | ✓ | |
| I18nManager | ✓ | Includes additional support for runtime switch to RTL. |
| InteractionManager | (✓) | |
| Keyboard | (✓) | Mock. |
| LayoutAnimation | (✓) | Missing translation to web animations. |
| Linking | ✓ | |
| NativeEventEmitter | ✓ | |
| NativeMethodsMixin | ✓ | |
| NativeModules | (✓) | Mocked. Missing ability to load native modules. |
| PanResponder | ✓ | |
| PixelRatio | ✓ | |
| Platform | ✓ | |
| Settings | ✘ | No equivalent web APIs. |
| Share | ✓ | Only available over HTTPS. Read about the [Web Share API](https://wicg.github.io/web-share/). |
| StyleSheet | ✓ | |
| UIManager | ✓ | |
| Vibration | ✓ | |
| useColorScheme | ✓ | |
| useWindowDimensions | ✓ | |
## Contributing
The main purpose of this repository is to help evolve React web and native
development towards the platform-agnostic design of React Native, and in the
process make it faster and easier to build high-quality experiences for the web
with React. Development happens in the open on GitHub, and we are grateful for
contributing bugfixes and improvements. Read below to learn how you can take
part in improving React Native for Web.
### Code of conduct
Facebook has adopted a [Code of Conduct][code-of-conduct] that this project
expects all participants to adhere to. Please read the full text so that you
can understand what actions will and will not be tolerated.
### Contributing guide
Read the [contributing guide][contributing-url] to learn about the
development process, how to propose bugfixes and improvements, and how to build
and test your changes to React Native for Web.
### Good first issues
To help you get you familiar with the contribution process, there is a list of
[good first issues][good-first-issue-url] that contain bugs which have a
relatively limited scope. This is a great place to get started.
## License
React Native for Web is [BSD licensed](LICENSE).
React Native for Web is [MIT licensed](./LICENSE). By contributing to React
Native for Web, you agree that your contributions will be licensed under its
MIT license.
[npm-image]: https://badge.fury.io/js/react-native-web.svg
[npm-url]: https://yarnpkg.com/en/package/react-native-web
[package-badge]: https://img.shields.io/npm/v/react-native-web.svg?style=flat
[package-url]: https://yarnpkg.com/en/package/react-native-web
[ci-badge]: https://travis-ci.org/necolas/react-native-web.svg?branch=master
[ci-url]: https://travis-ci.org/necolas/react-native-web
[react-native-url]: https://facebook.github.io/react-native/
[travis-image]: https://travis-ci.org/necolas/react-native-web.svg?branch=master
[travis-url]: https://travis-ci.org/necolas/react-native-web
[contributing-url]: https://github.com/necolas/react-native-web/blob/master/.github/CONTRIBUTING.md
[good-first-issue-url]: https://github.com/necolas/react-native-web/labels/good%20first%20issue
[code-of-conduct]: https://code.facebook.com/codeofconduct

7
babel.config.js Normal file
View File

@@ -0,0 +1,7 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['./scripts/babel/preset']
};
};

View File

@@ -1,161 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`1. Rewrite react-native paths for react-native-web 1`] = `
"
import { View } from 'react-native';
↓ ↓ ↓ ↓ ↓ ↓
import View from 'react-native-web/dist/components/View';
"
`;
exports[`2. Rewrite react-native paths for react-native-web 1`] = `
"
import { Switch, Text, View as MyView, ViewPropTypes } from 'react-native';
↓ ↓ ↓ ↓ ↓ ↓
import Switch from 'react-native-web/dist/components/Switch';
import Text from 'react-native-web/dist/components/Text';
import MyView from 'react-native-web/dist/components/View';
import ViewPropTypes from 'react-native-web/dist/components/View/ViewPropTypes';
"
`;
exports[`3. Rewrite react-native paths for react-native-web 1`] = `
"
import { createElement, Switch, StyleSheet } from 'react-native';
↓ ↓ ↓ ↓ ↓ ↓
import createElement from 'react-native-web/dist/modules/createElement';
import Switch from 'react-native-web/dist/components/Switch';
import StyleSheet from 'react-native-web/dist/apis/StyleSheet';
"
`;
exports[`4. Rewrite react-native paths for react-native-web 1`] = `
"
import { InvalidThing, TouchableOpacity } from 'react-native';
↓ ↓ ↓ ↓ ↓ ↓
import { InvalidThing } from 'react-native-web';
import TouchableOpacity from 'react-native-web/dist/components/Touchable/TouchableOpacity';
"
`;
exports[`5. Rewrite react-native paths for react-native-web 1`] = `
"
import * as RNW from 'react-native';
↓ ↓ ↓ ↓ ↓ ↓
import * as RNW from 'react-native-web';
"
`;
exports[`6. Rewrite react-native paths for react-native-web 1`] = `
"
const { View } = require('react-native');
↓ ↓ ↓ ↓ ↓ ↓
const View = require('react-native-web/dist/components/View');
"
`;
exports[`7. Rewrite react-native paths for react-native-web 1`] = `
"
let { Switch, Text, View: MyView } = require('react-native');
↓ ↓ ↓ ↓ ↓ ↓
let Switch = require('react-native-web/dist/components/Switch');
let Text = require('react-native-web/dist/components/Text');
let MyView = require('react-native-web/dist/components/View');
"
`;
exports[`8. Rewrite react-native paths for react-native-web 1`] = `
"
var { createElement, Switch, StyleSheet } = require('react-native');
↓ ↓ ↓ ↓ ↓ ↓
var createElement = require('react-native-web/dist/modules/createElement');
var Switch = require('react-native-web/dist/components/Switch');
var StyleSheet = require('react-native-web/dist/apis/StyleSheet');
"
`;
exports[`9. Rewrite react-native paths for react-native-web 1`] = `
"
const { InvalidThing, TouchableOpacity } = require('react-native');
↓ ↓ ↓ ↓ ↓ ↓
const TouchableOpacity = require('react-native-web/dist/components/Touchable/TouchableOpacity');
"
`;
exports[`10. Rewrite react-native paths for react-native-web 1`] = `
"
export { View } from 'react-native';
↓ ↓ ↓ ↓ ↓ ↓
export { default as View } from 'react-native-web/dist/components/View';
"
`;
exports[`11. Rewrite react-native paths for react-native-web 1`] = `
"
export { Switch, Text, View as MyView, ViewPropTypes } from 'react-native';
↓ ↓ ↓ ↓ ↓ ↓
export { default as Switch } from 'react-native-web/dist/components/Switch';
export { default as Text } from 'react-native-web/dist/components/Text';
export { default as MyView } from 'react-native-web/dist/components/View';
export { default as ViewPropTypes } from 'react-native-web/dist/components/View/ViewPropTypes';
"
`;
exports[`12. Rewrite react-native paths for react-native-web 1`] = `
"
export { createElement, Switch, StyleSheet } from 'react-native';
↓ ↓ ↓ ↓ ↓ ↓
export { default as createElement } from 'react-native-web/dist/modules/createElement';
export { default as Switch } from 'react-native-web/dist/components/Switch';
export { default as StyleSheet } from 'react-native-web/dist/apis/StyleSheet';
"
`;
exports[`13. Rewrite react-native paths for react-native-web 1`] = `
"
export { InvalidThing, TouchableOpacity } from 'react-native';
↓ ↓ ↓ ↓ ↓ ↓
export { InvalidThing } from 'react-native-web';
export { default as TouchableOpacity } from 'react-native-web/dist/components/Touchable/TouchableOpacity';
"
`;
exports[`14. Rewrite react-native paths for react-native-web 1`] = `
"
export { default as RNW } from 'react-native';
↓ ↓ ↓ ↓ ↓ ↓
export { default as RNW } from 'react-native-web';
"
`;

View File

@@ -1,46 +0,0 @@
const plugin = require('..');
const pluginTester = require('babel-plugin-tester');
pluginTester({
plugin,
snapshot: true,
tests: [
// import react-native
"import { View } from 'react-native';",
"import { Switch, Text, View as MyView, ViewPropTypes } from 'react-native';",
"import { createElement, Switch, StyleSheet } from 'react-native';",
"import { InvalidThing, TouchableOpacity } from 'react-native';",
"import * as RNW from 'react-native';",
// import react-native-web
// "import { View } from 'react-native-web';",
// "import { Switch, Text, View as MyView } from 'react-native-web';",
// "import { createElement, Switch, StyleSheet } from 'react-native-web';",
// "import { InvalidThing, TouchableOpacity } from 'react-native-web';",
// "import * as RNW from 'react-native-web';",
// require react-native
"const { View } = require('react-native');",
"let { Switch, Text, View: MyView } = require('react-native');",
"var { createElement, Switch, StyleSheet } = require('react-native');",
"const { InvalidThing, TouchableOpacity } = require('react-native');",
// require react-native-web
// "const { View } = require('react-native-web');",
// "let { Switch, Text, View: MyView } = require('react-native-web');",
// "var { createElement, Switch, StyleSheet } = require('react-native-web');",
// "const { InvalidThing, TouchableOpacity } = require('react-native-web');",
// export react-native
"export { View } from 'react-native';",
"export { Switch, Text, View as MyView, ViewPropTypes } from 'react-native';",
"export { createElement, Switch, StyleSheet } from 'react-native';",
"export { InvalidThing, TouchableOpacity } from 'react-native';",
"export { default as RNW } from 'react-native';",
{
code: "const RNW = require('react-native');",
output: "const RNW = require('react-native');",
snapshot: false
}
]
});

View File

@@ -1,182 +0,0 @@
const getDistLocation = importName => {
const root = 'react-native-web/dist';
switch (importName) {
// apis
case 'Animated':
case 'AppRegistry':
case 'AppState':
case 'AsyncStorage':
case 'BackHandler':
case 'Clipboard':
case 'Dimensions':
case 'Easing':
case 'I18nManager':
case 'InteractionManager':
case 'Keyboard':
case 'Linking':
case 'NetInfo':
case 'PanResponder':
case 'PixelRatio':
case 'Platform':
case 'StyleSheet':
case 'UIManager':
case 'Vibration': {
return `${root}/apis/${importName}`;
}
// components
case 'ActivityIndicator':
case 'ART':
case 'Button':
case 'FlatList':
case 'Image':
case 'KeyboardAvoidingView':
case 'ListView':
case 'Modal':
case 'Picker':
case 'ProgressBar':
case 'RefreshControl':
case 'ScrollView':
case 'SectionList':
case 'Slider':
case 'StatusBar':
case 'Switch':
case 'Text':
case 'TextInput':
case 'View':
case 'VirtualizedList': {
return `${root}/components/${importName}`;
}
case 'Touchable':
case 'TouchableHighlight':
case 'TouchableNativeFeedback':
case 'TouchableOpacity':
case 'TouchableWithoutFeedback': {
return `${root}/components/Touchable/${importName}`;
}
// modules
case 'createElement':
case 'findNodeHandle':
case 'NativeModules':
case 'processColor':
case 'render':
case 'unmountComponentAtNode': {
return `${root}/modules/${importName}`;
}
// propTypes
case 'ColorPropType':
case 'EdgeInsetsPropType':
case 'PointPropType': {
return `${root}/propTypes/${importName}`;
}
case 'TextPropTypes': {
return `${root}/components/Text/${importName}`;
}
case 'ViewPropTypes': {
return `${root}/components/View/${importName}`;
}
default:
return;
}
};
const isReactNativeRequire = (t, node) => {
const { declarations } = node;
if (declarations.length > 1) {
return false;
}
const { id, init } = declarations[0];
return (
t.isObjectPattern(id) &&
t.isCallExpression(init) &&
t.isIdentifier(init.callee) &&
init.callee.name === 'require' &&
init.arguments.length === 1 &&
init.arguments[0].value === 'react-native'
);
};
module.exports = function({ types: t }) {
return {
name: 'Rewrite react-native paths for react-native-web',
visitor: {
ImportDeclaration(path) {
const { source, specifiers } = path.node;
if (source && source.value === 'react-native' && specifiers.length) {
const imports = specifiers
.map(specifier => {
if (t.isImportSpecifier(specifier)) {
const importName = specifier.imported.name;
const distLocation = getDistLocation(importName);
if (distLocation) {
return t.importDeclaration(
[t.importDefaultSpecifier(t.identifier(specifier.local.name))],
t.stringLiteral(distLocation)
);
}
}
return t.importDeclaration([specifier], t.stringLiteral('react-native-web'));
})
.filter(Boolean);
path.replaceWithMultiple(imports);
}
},
ExportNamedDeclaration(path) {
const { source, specifiers } = path.node;
if (source && source.value === 'react-native' && specifiers.length) {
const exports = specifiers
.map(specifier => {
if (t.isExportSpecifier(specifier)) {
const exportName = specifier.exported.name;
const localName = specifier.local.name;
const distLocation = getDistLocation(localName);
if (distLocation) {
return t.exportNamedDeclaration(
null,
[t.exportSpecifier(t.identifier('default'), t.identifier(exportName))],
t.stringLiteral(distLocation)
);
}
return t.exportNamedDeclaration(
null,
[specifier],
t.stringLiteral('react-native-web')
);
}
})
.filter(Boolean);
path.replaceWithMultiple(exports);
}
},
VariableDeclaration(path) {
if (isReactNativeRequire(t, path.node)) {
const { id } = path.node.declarations[0];
const imports = id.properties
.map(identifier => {
const distLocation = getDistLocation(identifier.key.name);
if (distLocation) {
return t.variableDeclaration(path.node.kind, [
t.variableDeclarator(
t.identifier(identifier.value.name),
t.callExpression(t.identifier('require'), [t.stringLiteral(distLocation)])
)
]);
}
})
.filter(Boolean);
path.replaceWithMultiple(imports);
}
}
}
};
};

View File

@@ -1,47 +0,0 @@
# Performance
To run these benchmarks from the root of the project:
```
yarn benchmark
open ./benchmarks/index.html
```
Append `?fastest` to the URL to include the fastest "other libraries", and
`?all` to include all the "other libraries".
## Notes
The components used in the render benchmarks are simple enough to be
implemented by multiple UI or style libraries. The implementations are not
equivalent in functionality. For example, the "React Native for Web" benchmark includes a
complete `View` implementation and the `StyleSheet` also converts React Native
styles to DOM styles, has deterministic resolution, and supports RTL layout.
## Benchmark results
Typical render timings*: mean ± two standard deviations.
| Implementation | Deep tree (ms) | Wide tree (ms) | Tweets (ms) |
| :--- | ---: | ---: | ---: |
| `css-modules` | `80.47` `±25.13` | `144.87` `±32.70` | |
| `react-native-web@0.2.1` | `88.68` `±28.78` | `178.17` `±39.90` | `13.78` `±2.90ms` |
Other libraries
| Implementation | Deep tree (ms) | Wide tree (ms) |
| :--- | ---: | ---: |
| `styletron@3.0.0-rc.5` | `79.41` `±27.49` | `152.95` `±29.46` |
| `aphrodite@1.2.5` | `85.13` `±25.39` | `162.87` `±25.91` |
| `glamor@2.20.40` | `109.92` `±29.88` | `193.01` `±32.03` |
| `react-jss@8.2.0` | `134.28` `±49.00` | `278.78` `±50.39` |
| `emotion@8.0.12` | `139.08` `±46.18` | `253.45` `±52.69` |
| `styled-components@2.3.2` | `194.43` `416.28` | `404.86` `±56.59` |
| `reactxp@0.46.6` | `219.46` `±57.24` | `424.18` `±76.10` |
| `radium@0.19.6` | `359.32` `±90.27` | `795.91` `±88.93` |
These results indicate that render times when using `react-native-web`,
`css-modules`, `aphrodite`, and `styletron` are roughly equivalent and
significantly faster than alternatives.
*MacBook Pro (13-inch, Early 2011); 2.3 GHz Intel Core i5; 8 GB 1333 MHz DDR3. Google Chrome 62.

View File

@@ -1,97 +0,0 @@
import * as marky from 'marky';
const fmt = time => `${Math.round(time * 100) / 100}ms`;
const measure = (name, fn) => {
marky.mark(name);
fn();
const performanceMeasure = marky.stop(name);
return performanceMeasure.duration;
};
const mean = values => {
const sum = values.reduce((sum, value) => sum + value, 0);
return sum / values.length;
};
const median = values => {
if (!Array.isArray(values)) {
return 0;
}
if (values.length === 1) {
return values[0];
}
const numbers = [...values].sort((a, b) => a - b);
return (numbers[(numbers.length - 1) >> 1] + numbers[numbers.length >> 1]) / 2;
};
const standardDeviation = values => {
const avg = mean(values);
const squareDiffs = values.map(value => {
const diff = value - avg;
return diff * diff;
});
const meanSquareDiff = mean(squareDiffs);
return Math.sqrt(meanSquareDiff);
};
const benchmark = ({ name, description, setup, teardown, task, runs }) => {
return new Promise(resolve => {
const durations = [];
let i = 0;
setup();
const first = measure('first', task);
teardown();
const done = () => {
const stdDev = standardDeviation(durations);
const formattedFirst = fmt(first);
const formattedMean = fmt(mean(durations));
const formattedMedian = fmt(median(durations));
const formattedStdDev = fmt(stdDev);
console.groupCollapsed(`${name}\n${formattedMean} ±${fmt(2 * stdDev)}`);
description && console.log(description);
console.log(`First: ${formattedFirst}`);
console.log(`Median: ${formattedMedian}`);
console.log(`Mean: ${formattedMean}`);
console.log(`Standard deviation: ${formattedStdDev}`);
console.log(durations);
console.groupEnd();
resolve();
};
const a = () => {
setup();
window.requestAnimationFrame(b);
};
const b = () => {
const duration = measure('mean', task);
durations.push(duration);
window.requestAnimationFrame(c);
};
const c = () => {
teardown();
window.requestAnimationFrame(d);
};
const d = () => {
i += 1;
if (i < runs) {
window.requestAnimationFrame(a);
} else {
window.requestAnimationFrame(done);
}
};
window.requestAnimationFrame(a);
});
};
export default benchmark;

View File

@@ -1,24 +0,0 @@
import benchmark from './benchmark';
import ReactDOM from 'react-dom';
const node = document.querySelector('.root');
const createRenderBenchmark = ({ description, getElement, name, runs }) => () => {
const setup = () => {};
const teardown = () => {
ReactDOM.unmountComponentAtNode(node);
};
return benchmark({
name,
description,
runs,
setup,
teardown,
task: () => {
ReactDOM.render(getElement(), node);
}
});
};
export default createRenderBenchmark;

View File

@@ -1,11 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Performance tests</title>
</head>
<body>
<div class="root"></div>
<script src="dist/performance.bundle.js"></script>
</body>
</html>

View File

@@ -1,63 +0,0 @@
import aphrodite from './src/aphrodite';
import cssModules from './src/css-modules';
import emotion from './src/emotion';
import glamor from './src/glamor';
import jss from './src/jss';
import radium from './src/radium';
import reactNative from './src/react-native';
import styledComponents from './src/styled-components';
import styletron from './src/styletron';
import xp from './src/reactxp';
import renderDeepTree from './tests/renderDeepTree';
import renderTweet from './tests/renderTweet';
import renderWideTree from './tests/renderWideTree';
const testAll = window.location.search === '?all';
const testFastest = window.location.search === '?fastest';
const coreTests = [
() => renderTweet('react-native-web', reactNative),
() => renderDeepTree('css-modules', cssModules),
() => renderWideTree('css-modules', cssModules),
() => renderDeepTree('react-native-web', reactNative),
() => renderWideTree('react-native-web', reactNative)
];
const fastestTests = [
() => renderDeepTree('styletron', styletron),
() => renderWideTree('styletron', styletron),
() => renderDeepTree('aphrodite', aphrodite),
() => renderWideTree('aphrodite', aphrodite)
];
/**
* Optionally run tests using other libraries
*/
const restTests = [
() => renderDeepTree('glamor', glamor),
() => renderWideTree('glamor', glamor),
() => renderDeepTree('react-jss', jss),
() => renderWideTree('react-jss', jss),
() => renderDeepTree('emotion', emotion),
() => renderWideTree('emotion', emotion),
() => renderDeepTree('styled-components', styledComponents),
() => renderWideTree('styled-components', styledComponents),
() => renderDeepTree('reactxp', xp),
() => renderWideTree('reactxp', xp),
() => renderDeepTree('radium', radium),
() => renderWideTree('radium', radium)
];
const tests = [...coreTests];
if (testFastest) {
tests.push(...fastestTests);
}
if (testAll) {
tests.push(...fastestTests);
tests.push(...restTests);
}
// run benchmarks
tests.reduce((promise, test) => promise.then(test()), Promise.resolve());

View File

@@ -1,21 +0,0 @@
{
"name": "benchmarks",
"private": true,
"dependencies": {
"aphrodite": "^1.2.5",
"classnames": "^2.2.5",
"emotion": "^8.0.12",
"glamor": "^2.20.40",
"marky": "^1.2.0",
"radium": "^0.19.6",
"react-jss": "^8.2.0",
"reactxp": "^0.46.6",
"styled-components": "^2.3.2",
"styletron-client": "^3.0.0-rc.5",
"styletron-utils": "^3.0.0-rc.3"
},
"devDependencies": {
"css-loader": "^0.28.7",
"style-loader": "^0.19.1"
}
}

View File

@@ -1,7 +0,0 @@
import Box from './components/Box/aphrodite';
import View from './components/View/aphrodite';
export default {
Box,
View
};

View File

@@ -1,108 +0,0 @@
import PropTypes from 'prop-types';
import theme from '../theme';
import React, { PureComponent } from 'react';
import { StyleSheet, Text } from 'react-native';
class AppText extends PureComponent {
static displayName = 'AppText';
static propTypes = {
align: PropTypes.oneOf(['center', 'left', 'right']),
color: PropTypes.oneOf(['blue', 'deepGray', 'normal', 'red', 'white']),
fontStyle: PropTypes.oneOf(['normal', 'italic']),
size: PropTypes.oneOf(['small', 'normal', 'large']),
uppercase: PropTypes.bool,
weight: PropTypes.oneOf(['normal', 'bold'])
};
render() {
const { align, color, fontStyle, size, uppercase, weight, ...other } = this.props;
const style = [
styles.root,
align && alignStyles[align],
color && colorStyles[color],
fontStyle && fontStyles[fontStyle],
size && sizeStyles[size],
weight && weightStyles[weight],
uppercase === true && styles.uppercase
];
return <Text {...other} style={style} />;
}
}
const styles = StyleSheet.create({
root: {
fontFamily: theme.fontFamily,
fontSize: theme.fontSize.normal,
fontWeight: 'normal',
lineHeight: theme.createLength(theme.lineHeight),
wordWrap: 'break-word'
},
uppercase: {
textTransform: 'uppercase'
}
});
const alignStyles = StyleSheet.create({
center: {
textAlign: 'center'
},
left: {
textAlign: 'left'
},
right: {
textAlign: 'right'
}
});
const colorStyles = StyleSheet.create({
blue: {
color: theme.colors.blue
},
deepGray: {
color: theme.colors.deepGray
},
normal: {
color: theme.colors.textBlack
},
red: {
color: theme.colors.red
},
white: {
color: theme.colors.white
}
});
const fontStyles = StyleSheet.create({
normal: {
fontStyle: 'normal'
},
italic: {
fontStyle: 'italic'
}
});
const sizeStyles = StyleSheet.create({
small: {
fontSize: theme.fontSize.small
},
normal: {
fontSize: theme.fontSize.normal
},
large: {
fontSize: theme.fontSize.large
}
});
const weightStyles = StyleSheet.create({
normal: {
fontWeight: '400'
},
bold: {
fontWeight: 'bold'
}
});
export default AppText;

View File

@@ -1,41 +0,0 @@
import PropTypes from 'prop-types';
import React, { PureComponent } from 'react';
import { StyleSheet, View } from 'react-native';
class AspectRatio extends PureComponent {
static displayName = 'AspectRatio';
static propTypes = {
children: PropTypes.any,
ratio: PropTypes.number,
style: PropTypes.object
};
static defaultProps = {
ratio: 1
};
render() {
const { children, ratio, style } = this.props;
const percentage = 100 / ratio;
return (
<View style={[styles.root, style]}>
<View style={[styles.shim, { paddingBottom: `${percentage}%` }]} />
<View style={StyleSheet.absoluteFill}>{children}</View>
</View>
);
}
}
const styles = StyleSheet.create({
root: {
overflow: 'hidden'
},
shim: {
display: 'block',
width: '100%'
}
});
export default AspectRatio;

View File

@@ -1,48 +0,0 @@
/* eslint-disable react/prop-types */
import React from 'react';
import View from '../View/emotion';
const Box = ({ color, fixed = false, layout = 'column', outer = false, ...other }) => (
<View
{...other}
style={[
styles[`color${color}`],
fixed && styles.fixed,
layout === 'row' && styles.row,
outer && styles.outer
]}
/>
);
const styles = {
outer: {
padding: 4
},
row: {
flexDirection: 'row'
},
color0: {
backgroundColor: '#222'
},
color1: {
backgroundColor: '#666'
},
color2: {
backgroundColor: '#999'
},
color3: {
backgroundColor: 'blue'
},
color4: {
backgroundColor: 'orange'
},
color5: {
backgroundColor: 'red'
},
fixed: {
width: 20,
height: 20
}
};
export default Box;

View File

@@ -1,49 +0,0 @@
/* eslint-disable react/prop-types */
import Radium from 'radium';
import React from 'react';
import View from '../View/radium';
const Box = ({ color, fixed = false, layout = 'column', outer = false, ...other }) => (
<View
{...other}
style={[
styles[`color${color}`],
fixed && styles.fixed,
layout === 'row' && styles.row,
outer && styles.outer
]}
/>
);
const styles = {
outer: {
padding: 4
},
row: {
flexDirection: 'row'
},
color0: {
backgroundColor: '#222'
},
color1: {
backgroundColor: '#666'
},
color2: {
backgroundColor: '#999'
},
color3: {
backgroundColor: 'blue'
},
color4: {
backgroundColor: 'orange'
},
color5: {
backgroundColor: 'red'
},
fixed: {
width: 20,
height: 20
}
};
export default Radium(Box);

View File

@@ -1,36 +0,0 @@
.outer {
padding: 4px;
}
.row {
flex-direction: row;
}
.color0 {
background-color: #222;
}
.color1 {
background-color: #666;
}
.color2 {
background-color: #999;
}
.color3 {
background-color: blue;
}
.color4 {
background-color: orange;
}
.color5 {
background-color: red;
}
.fixed {
width: 20px;
height: 20px;
}

View File

@@ -1,49 +0,0 @@
/* eslint-disable react/prop-types */
import { injectStylePrefixed } from 'styletron-utils';
import React from 'react';
import View, { styletron } from '../View/styletron';
const Box = ({ color, fixed = false, layout = 'column', outer = false, ...other }) => (
<View
{...other}
style={[
styles[`color${color}`],
fixed && styles.fixed,
layout === 'row' && styles.row,
outer && styles.outer
]}
/>
);
const styles = {
outer: injectStylePrefixed(styletron, {
padding: '4px'
}),
row: injectStylePrefixed(styletron, {
flexDirection: 'row'
}),
color0: injectStylePrefixed(styletron, {
backgroundColor: '#222'
}),
color1: injectStylePrefixed(styletron, {
backgroundColor: '#666'
}),
color2: injectStylePrefixed(styletron, {
backgroundColor: '#999'
}),
color3: injectStylePrefixed(styletron, {
backgroundColor: 'blue'
}),
color4: injectStylePrefixed(styletron, {
backgroundColor: 'orange'
}),
color5: injectStylePrefixed(styletron, {
backgroundColor: 'red'
}),
fixed: injectStylePrefixed(styletron, {
width: '20px',
height: '20px'
})
};
export default Box;

View File

@@ -1,53 +0,0 @@
import PropTypes from 'prop-types';
import { StyleSheet, View } from 'react-native';
import React, { Component } from 'react';
import theme from '../theme';
class GridView extends Component {
static displayName = 'GridView';
static propTypes = {
children: PropTypes.node,
hasGap: PropTypes.bool,
style: PropTypes.object
};
render() {
const { children, hasGap, style, ...other } = this.props;
return (
<View {...other} style={[style, styles.root, hasGap && styles.hasGap]}>
{React.Children.map(children, child => {
return (
child &&
React.cloneElement(child, {
style: [child.props.style, styles.column, hasGap && styles.hasGapColumn]
})
);
})}
</View>
);
}
}
const styles = StyleSheet.create({
root: {
flexDirection: 'row'
},
/**
* 1. Distribute all space (rather than extra space)
* 2. Prevent wide content from forcing wider flex columns
*/
column: {
flexBasis: 0, // 1
minWidth: 0 // 2
},
hasGap: {
marginHorizontal: theme.createLength(theme.spaceX * -0.5, 'rem')
},
hasGapColumn: {
marginHorizontal: theme.createLength(theme.spaceX * 0.5, 'rem')
}
});
export default GridView;

View File

@@ -1,20 +0,0 @@
/* eslint-disable react/prop-types */
import { createElement } from 'react-native';
import React from 'react';
import styles from './styles';
const IconDirectMessage = props =>
createElement('svg', {
children: (
<g>
<path d="M43.34 14H12.66L28 27.946z" />
<path d="M51.392 14.789L30.018 34.22c-.009.008-.028.006-.039.012-.563.5-1.266.768-1.98.768-.72 0-1.442-.258-2.017-.78L4.609 14.79A3.957 3.957 0 0 0 3 18v37a1.998 1.998 0 0 0 2 2c.464 0 .924-.162 1.292-.473L19 46h30c2.243 0 4-1.757 4-4V18a3.96 3.96 0 0 0-1.608-3.211z" />
</g>
),
style: [styles.icon, props.style],
viewBox: '0 0 56 72'
});
IconDirectMessage.metadata = { height: 72, width: 56 };
export default IconDirectMessage;

View File

@@ -1,19 +0,0 @@
/* eslint-disable react/prop-types */
import { createElement } from 'react-native';
import React from 'react';
import styles from './styles';
const IconHeart = props =>
createElement('svg', {
children: (
<g>
<path d="M38.723 12c-7.187 0-11.16 7.306-11.723 8.131C26.437 19.306 22.504 12 15.277 12 8.791 12 3.533 18.163 3.533 24.647 3.533 39.964 21.891 55.907 27 56c5.109-.093 23.467-16.036 23.467-31.353C50.467 18.163 45.209 12 38.723 12z" />
</g>
),
style: [styles.icon, props.style],
viewBox: '0 0 54 72'
});
IconHeart.metadata = { height: 72, width: 54 };
export default IconHeart;

View File

@@ -1,19 +0,0 @@
/* eslint-disable react/prop-types */
import { createElement } from 'react-native';
import React from 'react';
import styles from './styles';
const IconReply = props =>
createElement('svg', {
children: (
<g>
<path d="M41 31h-9V19a2.999 2.999 0 0 0-4.817-2.386l-21 16a3 3 0 0 0-.001 4.773l21 16a3.006 3.006 0 0 0 3.15.301A2.997 2.997 0 0 0 32 51V39h9c5.514 0 10 4.486 10 10a4 4 0 0 0 8 0c0-9.925-8.075-18-18-18z" />
</g>
),
style: [styles.icon, props.style],
viewBox: '0 0 62 72'
});
IconReply.metadata = { height: 72, width: 62 };
export default IconReply;

View File

@@ -1,19 +0,0 @@
/* eslint-disable react/prop-types */
import { createElement } from 'react-native';
import React from 'react';
import styles from './styles';
const IconRetweet = props =>
createElement('svg', {
children: (
<g>
<path d="M70.676 36.644A3 3 0 0 0 68 35h-7V19a4 4 0 0 0-4-4H34a4 4 0 0 0 0 8h18a1 1 0 0 1 1 .998V35h-7a3.001 3.001 0 0 0-2.419 4.775l11 15a3.003 3.003 0 0 0 4.839-.001l11-15a3.001 3.001 0 0 0 .256-3.13zM40.001 48H22a.995.995 0 0 1-.992-.96L21.001 36h7a3.001 3.001 0 0 0 2.419-4.775l-11-15a3.003 3.003 0 0 0-4.839.001l-11 15A3 3 0 0 0 6.001 36h7l.011 16.003a4 4 0 0 0 4 3.997h22.989a4 4 0 0 0 0-8z" />
</g>
),
style: [styles.icon, props.style],
viewBox: '0 0 74 72'
});
IconRetweet.metadata = { height: 72, width: 74 };
export default IconRetweet;

View File

@@ -1,15 +0,0 @@
import { StyleSheet } from 'react-native';
const styles = StyleSheet.create({
icon: {
display: 'inline-block',
fill: 'currentcolor',
height: '1.25em',
maxWidth: '100%',
position: 'relative',
userSelect: 'none',
verticalAlign: 'text-bottom'
}
});
export default styles;

View File

@@ -1,58 +0,0 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
class DeepTree extends Component {
static propTypes = {
breadth: PropTypes.number.isRequired,
components: PropTypes.object,
depth: PropTypes.number.isRequired,
id: PropTypes.number.isRequired,
wrap: PropTypes.number.isRequired
};
/* necessary for reactxp to work without errors */
static childContextTypes = {
focusManager: PropTypes.object
};
getChildContext() {
return {
focusManager: {
addFocusableComponent() {},
removeFocusableComponent() {},
restrictFocusWithin() {},
removeFocusRestriction() {},
limitFocusWithin() {},
removeFocusLimitation() {}
}
};
}
render() {
const { breadth, components, depth, id, wrap } = this.props;
const { Box } = components;
let result = (
<Box color={id % 3} components={components} layout={depth % 2 === 0 ? 'column' : 'row'} outer>
{depth === 0 && <Box color={id % 3 + 3} components={components} fixed />}
{depth !== 0 &&
Array.from({ length: breadth }).map((el, i) => (
<DeepTree
breadth={breadth}
components={components}
depth={depth - 1}
id={i}
key={i}
wrap={wrap}
/>
))}
</Box>
);
for (let i = 0; i < wrap; i++) {
result = <Box components={components}>{result}</Box>;
}
return result;
}
}
export default DeepTree;

View File

@@ -1,144 +0,0 @@
import AspectRatio from '../AspectRatio';
import GridView from '../GridView';
import PropTypes from 'prop-types';
import TweetActionsBar from '../TweetActionsBar';
import TweetText from '../TweetText';
import UserAvatar from '../UserAvatar';
import UserNames from '../UserNames';
import { Image, StyleSheet, Text, View } from 'react-native';
import React, { Component } from 'react';
import theme from '../theme';
export class Tweet extends Component {
static displayName = 'Tweet';
static propTypes = {
tweet: PropTypes.object.isRequired
};
render() {
const { tweet } = this.props;
const { id, lang, media, textParts, timestamp, user } = tweet;
const { fullName, profileImageUrl, screenName } = user;
return (
<View accessibilityRole="article" accessible style={styles.root}>
<GridView hasGap>
<View style={styles.avatarColumn}>
<View
accessibilityRole="link"
accessible
href={`/${screenName}`}
style={styles.avatarLink}
>
<UserAvatar style={styles.avatar} uri={profileImageUrl} />
</View>
</View>
<View style={styles.bodyColumn}>
<View style={styles.body}>
<View style={styles.row}>
<Text
accessibilityRole="link"
children={timestamp}
href={`/${screenName}/status/${id}`}
style={styles.timestamp}
/>
<UserNames fullName={fullName} screenName={screenName} />
</View>
<View accessibilityRole="heading" aria-level="4">
<TweetText displayMode={'links'} lang={lang} textParts={textParts} />
</View>
{media ? (
<View style={styles.richContent}>
<AspectRatio ratio={16 / 9}>
<Image
resizeMode={Image.resizeMode.cover}
source={media.source}
style={styles.media}
/>
</AspectRatio>
</View>
) : null}
</View>
<TweetActionsBar
actions={[
{ name: 'reply', label: 'Reply' },
{
name: 'retweet',
label: 'Retweet',
count: tweet.retweet_count,
highlighted: tweet.retweeted
},
{
name: 'like',
label: 'Like',
count: tweet.favorite_count,
highlighted: tweet.favorited
},
{ name: 'directMessage', label: 'Direct Message' }
]}
style={styles.actionBar}
/>
</View>
</GridView>
</View>
);
}
}
const styles = StyleSheet.create({
root: {
paddingVertical: theme.createLength(theme.spaceY * 0.75, 'rem'),
paddingHorizontal: theme.createLength(theme.spaceX, 'rem')
},
avatarColumn: {
flexGrow: 1,
minWidth: 32
},
bodyColumn: {
flexGrow: 7
},
row: {
flexDirection: 'row',
justifyContent: 'space-between'
},
avatarLink: {
display: 'block',
flexShrink: 1,
flexGrow: 0,
width: '100%'
},
avatar: {
width: '100%'
},
body: {
marginTop: '-0.15rem'
},
timestamp: {
color: theme.colors.deepGray,
marginLeft: theme.createLength(theme.spaceX, 'rem'),
order: 1,
textDecorationLine: 'none',
whiteSpace: 'nowrap'
},
actionBar: {
marginTop: theme.createLength(theme.spaceY * 0.5, 'rem')
},
richContent: {
borderRadius: '0.35rem',
marginTop: theme.createLength(theme.spaceY * 0.5, 'rem'),
overflow: 'hidden'
},
media: {
...StyleSheet.absoluteFillObject,
margin: 'auto',
width: 'auto',
height: 'auto'
}
});
export default Tweet;

View File

@@ -1,78 +0,0 @@
import IconReply from '../Icons/Reply';
import IconHeart from '../Icons/Heart';
import IconRetweet from '../Icons/Retweet';
import IconDirectMessage from '../Icons/DirectMessage';
import PropTypes from 'prop-types';
import React from 'react';
import theme from '../theme';
import { Text, View, StyleSheet } from 'react-native';
const getIcon = (icon, highlighted) => {
switch (icon) {
case 'like':
return <IconHeart />;
case 'reply':
return <IconReply />;
case 'retweet':
return <IconRetweet />;
case 'directMessage':
return <IconDirectMessage />;
default:
return null;
}
};
export default class TweetAction extends React.Component {
static displayName = 'TweetAction';
static propTypes = {
count: PropTypes.number,
displayMode: PropTypes.oneOf(['like', 'reply', 'retweet', 'directMessage']),
highlighted: PropTypes.bool,
onPress: PropTypes.func,
style: PropTypes.object
};
render() {
const { count, displayMode, highlighted, onPress, style } = this.props;
return (
<View accessibilityRole="button" onPress={onPress} style={[styles.root, style]}>
<Text
style={[
styles.inner,
displayMode === 'like' && highlighted && styles.likedColor,
displayMode === 'retweet' && highlighted && styles.retweetedColor
]}
>
{getIcon(displayMode, highlighted)}
{count > 0 ? <Text style={styles.count}>{count}</Text> : null}
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
root: {
minHeight: theme.createLength(theme.lineHeight, 'rem'),
overflow: 'visible',
userSelect: 'none',
whiteSpace: 'nowrap'
},
inner: {
alignItems: 'center',
color: theme.colors.deepGray,
display: 'flex',
flexDirection: 'row'
},
count: {
marginLeft: '0.25em'
},
retweetedColor: {
color: theme.colors.green
},
likedColor: {
color: theme.colors.red
}
});

View File

@@ -1,52 +0,0 @@
import PropTypes from 'prop-types';
import TweetAction from '../TweetAction';
import { View, StyleSheet } from 'react-native';
import React, { PureComponent } from 'react';
const actionNames = ['reply', 'retweet', 'like', 'directMessage'];
export default class TweetActionsBar extends PureComponent {
static propTypes = {
actions: PropTypes.arrayOf(
PropTypes.shape({
count: PropTypes.number,
label: PropTypes.string,
highlighted: PropTypes.bool,
name: PropTypes.oneOf(actionNames).isRequired,
onPress: PropTypes.func
})
),
style: PropTypes.object
};
render() {
const { actions, style } = this.props;
/* eslint-disable react/jsx-handler-names */
return (
<View style={[styles.root, style]}>
{actions.map((action, i) => (
<TweetAction
accessibilityLabel={actions.label}
count={action.count}
displayMode={action.name}
highlighted={action.highlighted}
key={i}
onPress={action.onPress}
style={styles.action}
/>
))}
</View>
);
}
}
const styles = StyleSheet.create({
root: {
flexDirection: 'row'
},
action: {
display: 'block',
marginRight: '10%'
}
});

View File

@@ -1,29 +0,0 @@
import AppText from '../AppText';
import React from 'react';
import TweetTextPart from '../TweetTextPart';
import { array, number, string } from 'prop-types';
class TweetText extends React.Component {
static displayName = 'TweetText';
static propTypes = {
displayMode: TweetTextPart.propTypes.displayMode,
lang: string,
numberOfLines: number,
textParts: array.isRequired
};
render() {
const { displayMode, lang, numberOfLines, textParts, ...other } = this.props;
return (
<AppText {...other} lang={lang} numberOfLines={numberOfLines}>
{textParts.map((part, i) => (
<TweetTextPart displayMode={displayMode} key={i} part={part} />
))}
</AppText>
);
}
}
export default TweetText;

View File

@@ -1,113 +0,0 @@
/* eslint-disable react/prop-types */
import { Image, StyleSheet, Text } from 'react-native';
import PropTypes from 'prop-types';
import React from 'react';
import theme from '../theme';
const createTextEntity = ({ part }) => <Text>{`${part.prefix}${part.text}`}</Text>;
const createTwemojiEntity = ({ part }) => (
<Image
accessibilityLabel={part.text}
draggable={false}
source={{ uri: part.emoji }}
style={styles.twemoji}
/>
);
// @mention, #hashtag, $cashtag
const createSymbolEntity = ({ displayMode, part }) => {
const links = displayMode === 'links';
return (
<Text accessibilityRole={links ? 'link' : null} href={part.url} style={[links && styles.link]}>
{`${part.prefix}${part.text}`}
</Text>
);
};
// internal links
const createLinkEntity = ({ displayMode, part }) => {
const { displayUrl, linkRelation, url } = part;
const links = displayMode === 'links';
return (
<Text
accessibilityRole={links ? 'link' : null}
href={url}
rel={links ? linkRelation : null}
style={[links && styles.link]}
>
{displayUrl}
</Text>
);
};
// external links
const createExternalLinkEntity = ({ displayMode, part }) => {
const { displayUrl, linkRelation, url } = part;
const links = displayMode === 'links';
return (
<Text
accessibilityRole={links ? 'link' : null}
href={url}
rel={links ? linkRelation : null}
style={[links && styles.link]}
target="_blank"
>
{displayUrl}
</Text>
);
};
class TweetTextPart extends React.Component {
static displayName = 'TweetTextPart';
static propTypes = {
displayMode: PropTypes.oneOf(['links', 'no-links']),
part: PropTypes.object
};
static defaultProps = {
displayMode: 'links'
};
render() {
let renderer;
const { isEmoji, isEntity, isHashtag, isMention, isMedia, isUrl } = this.props.part;
if (isEmoji || isEntity || isUrl || isMedia) {
if (isUrl) {
renderer = createExternalLinkEntity;
} else if (isHashtag || isMention) {
renderer = createSymbolEntity;
} else if (isEmoji) {
renderer = createTwemojiEntity;
} else {
renderer = createLinkEntity;
}
} else {
renderer = createTextEntity;
}
return renderer(this.props);
}
}
const styles = StyleSheet.create({
link: {
color: theme.colors.blue,
textDecorationLine: 'none',
unicodeBidi: 'embed'
},
twemoji: {
display: 'inline-block',
height: '1.25em',
width: '1.25em',
paddingRight: '0.05em',
paddingLeft: '0.1em',
verticalAlign: '-0.2em'
}
});
export default TweetTextPart;

View File

@@ -1,65 +0,0 @@
import AspectRatio from '../AspectRatio';
import PropTypes from 'prop-types';
import { Image, StyleSheet } from 'react-native';
import React, { PureComponent } from 'react';
import theme from '../theme';
class UserAvatar extends PureComponent {
static displayName = 'UserAvatar';
static propTypes = {
accessibilityLabel: PropTypes.string,
circle: PropTypes.bool,
style: PropTypes.object,
uri: PropTypes.string
};
static defaultProps = {
circle: false
};
render() {
const { accessibilityLabel, circle, style, uri } = this.props;
return (
<AspectRatio ratio={1} style={[styles.root, style]}>
{uri ? (
<Image
accessibilityLabel={accessibilityLabel}
onLoad={this._handleLoad}
ref={this._setImageRef}
source={{ uri }}
style={[styles.image, circle && styles.circle]}
/>
) : null}
</AspectRatio>
);
}
_handleLoad = () => {
this._imageRef && this._imageRef.setNativeProps(nativeProps);
};
_setImageRef = component => {
this._imageRef = component;
};
}
const nativeProps = { style: { backgroundColor: '#fff' } };
const styles = StyleSheet.create({
root: {
borderRadius: '0.35rem'
},
circle: {
borderRadius: '9999px'
},
image: {
backgroundColor: theme.colors.fadedGray,
display: 'block',
height: '100%',
width: '100%'
}
});
export default UserAvatar;

View File

@@ -1,52 +0,0 @@
import AppText from '../AppText';
import PropTypes from 'prop-types';
import { StyleSheet } from 'react-native';
import React, { PureComponent } from 'react';
class UserNames extends PureComponent {
static displayName = 'UserNames';
static propTypes = {
fullName: PropTypes.string,
layout: PropTypes.oneOf(['nowrap', 'stack']),
onPress: PropTypes.func,
screenName: PropTypes.string,
style: PropTypes.object
};
static defaultProps = {
layout: 'nowrap'
};
render() {
const { fullName, layout, onPress, screenName, style, ...other } = this.props;
return (
<AppText
{...other}
color="deepGray"
numberOfLines={layout === 'nowrap' ? 1 : null}
onPress={onPress}
style={[styles.root, style]}
>
<AppText color="normal" weight="bold">
{fullName}
</AppText>
{layout === 'stack' ? ' \u000A' : ' '}
<AppText color="deepGray" style={styles.screenName}>{`@${screenName}`}</AppText>
</AppText>
);
}
}
const styles = StyleSheet.create({
root: {
display: 'inline-block'
},
screenName: {
unicodeBidi: 'embed',
writingDirection: 'ltr'
}
});
export default UserNames;

View File

@@ -1,31 +0,0 @@
/* eslint-disable react/prop-types */
import Radium from 'radium';
import React from 'react';
class View extends React.Component {
render() {
const { style, ...other } = this.props;
return <div {...other} style={[styles.root, style]} />;
}
}
const styles = {
root: {
alignItems: 'stretch',
borderWidth: 0,
borderStyle: 'solid',
boxSizing: 'border-box',
display: 'flex',
flexBasis: 'auto',
flexDirection: 'column',
flexShrink: 0,
margin: 0,
padding: 0,
position: 'relative',
// fix flexbox bugs
minHeight: 0,
minWidth: 0
}
};
export default Radium(View);

View File

@@ -1,33 +0,0 @@
/* eslint-disable react/prop-types */
import classnames from 'classnames';
import Styletron from 'styletron-client';
import { injectStylePrefixed } from 'styletron-utils';
import React from 'react';
export const styletron = new Styletron();
class View extends React.Component {
render() {
const { style, ...other } = this.props;
return <div {...other} className={classnames(viewStyle, ...style)} />;
}
}
const viewStyle = injectStylePrefixed(styletron, {
alignItems: 'stretch',
borderWidth: '0px',
borderStyle: 'solid',
boxSizing: 'border-box',
display: 'flex',
flexBasis: 'auto',
flexDirection: 'column',
flexShrink: '0',
margin: '0px',
padding: '0px',
position: 'relative',
// fix flexbox bugs
minHeight: '0px',
minWidth: '0px'
});
export default View;

View File

@@ -1,40 +0,0 @@
const colors = {
blue: '#1B95E0',
lightBlue: '#71C9F8',
green: '#17BF63',
orange: '#F45D22',
purple: '#794BC4',
red: '#E0245E',
white: '#FFFFFF',
yellow: '#FFAD1F',
deepGray: '#657786',
fadedGray: '#E6ECF0',
faintGray: '#F5F8FA',
gray: '#AAB8C2',
lightGray: '#CCD6DD',
textBlack: '#14171A'
};
const fontSize = {
root: '14px',
// font scale
small: '0.85rem',
normal: '1rem',
large: '1.25rem'
};
const theme = {
colors,
fontFamily:
'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif, ' +
'"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"', // emoji fonts
fontSize,
lineHeight: 1.3125,
spaceX: 0.6,
spaceY: 1.3125,
createLength(num, unit) {
return `${num}${unit}`;
}
};
export default theme;

View File

@@ -1,9 +0,0 @@
import Box from './components/Box/css-modules';
import View from './components/View/css-modules';
const api = {
Box,
View
};
export default api;

View File

@@ -1,7 +0,0 @@
import Box from './components/Box/emotion';
import View from './components/View/emotion';
export default {
Box,
View
};

View File

@@ -1,7 +0,0 @@
import Box from './components/Box/glamor';
import View from './components/View/glamor';
export default {
Box,
View
};

View File

@@ -1,9 +0,0 @@
import Box from './components/Box/jss';
import View from './components/View/jss';
const api = {
Box,
View
};
export default api;

View File

@@ -1,9 +0,0 @@
import Box from './components/Box/radium';
import View from './components/View/radium';
const api = {
Box,
View
};
export default api;

View File

@@ -1,9 +0,0 @@
import Box from './components/Box/react-native';
import Tweet from './components/Tweet';
import { View } from 'react-native';
export default {
Box,
Tweet,
View
};

View File

@@ -1,7 +0,0 @@
import Box from './components/Box/reactxp';
import { View } from 'reactxp';
export default {
Box,
View
};

View File

@@ -1,7 +0,0 @@
import Box from './components/Box/styled-components';
import View from './components/View/styled-components';
export default {
Box,
View
};

View File

@@ -1,7 +0,0 @@
import Box from './components/Box/styletron';
import View from './components/View/styletron';
export default {
Box,
View
};

View File

@@ -1,14 +0,0 @@
import createRenderBenchmark from '../createRenderBenchmark';
import NestedTree from '../src/components/NestedTree';
import React from 'react';
const renderDeepTree = (label, components) =>
createRenderBenchmark({
name: `Deep tree [${label}]`,
runs: 20,
getElement() {
return <NestedTree breadth={3} components={components} depth={6} id={0} wrap={1} />;
}
});
export default renderDeepTree;

View File

@@ -1,113 +0,0 @@
import createRenderBenchmark from '../createRenderBenchmark';
import Tweet from '../src/components/Tweet';
import React from 'react';
const tweet1 = {
favorite_count: 30,
favorited: true,
id: '834889712556875776',
lang: 'en',
retweet_count: 6,
retweeted: false,
textParts: [
{
prefix: '',
text: 'Living burrito to burrito '
},
{
emoji: 'https://abs-0.twimg.com/emoji/v2/svg/1f32f.svg',
isEmoji: true,
prefix: '',
text: '🌯'
},
{
emoji: 'https://abs-0.twimg.com/emoji/v2/svg/1f32f.svg',
isEmoji: true,
prefix: '',
text: '🌯'
},
{
emoji: 'https://abs-0.twimg.com/emoji/v2/svg/1f32f.svg',
isEmoji: true,
prefix: '',
text: '🌯'
}
],
timestamp: 'Feb 23',
user: {
fullName: 'Nicolas',
screenName: 'necolas',
profileImageUrl: 'https://pbs.twimg.com/profile_images/804365942360719360/dQnPejph_normal.jpg'
}
};
const tweet2 = {
favorite_count: 84,
favorited: false,
id: '730896800060579840',
lang: 'en',
media: {
source: {
uri: 'https://pbs.twimg.com/media/CiSqvsJVEAAtLZ1.jpg',
width: 600,
height: 338
}
},
retweet_count: 4,
retweeted: true,
textParts: [
{
prefix: '',
text: 'Presenting '
},
{
displayUrl: 'mobile.twitter.com',
expandedUrl: 'https://mobile.twitter.com',
isEntity: true,
isUrl: true,
linkRelation: 'nofollow',
prefix: '',
text: '',
textDirection: 'ltr',
url: 'https://t.co/4hRCAxiUUG'
},
{
prefix: '',
text: ' with '
},
{
isEntity: true,
isMention: true,
prefix: '@',
text: 'davidbellona',
textDirection: 'ltr',
url: '/davidbellona'
},
{
prefix: '',
text: " at Twitter's all hands meeting "
}
],
timestamp: 'May 12',
user: {
fullName: 'Nicolas',
screenName: 'necolas',
profileImageUrl: 'https://pbs.twimg.com/profile_images/804365942360719360/dQnPejph_normal.jpg'
}
};
const renderTweet = label =>
createRenderBenchmark({
name: `Tweet [${label}]`,
runs: 10,
getElement() {
return (
<div style={{ width: 500 }}>
<Tweet tweet={tweet1} />
<Tweet tweet={tweet2} />
</div>
);
}
});
export default renderTweet;

View File

@@ -1,14 +0,0 @@
import createRenderBenchmark from '../createRenderBenchmark';
import NestedTree from '../src/components/NestedTree';
import React from 'react';
const renderWideTree = (label, components) =>
createRenderBenchmark({
name: `Wide tree [${label}]`,
runs: 20,
getElement() {
return <NestedTree breadth={10} components={components} depth={3} id={0} wrap={4} />;
}
});
export default renderWideTree;

File diff suppressed because it is too large Load Diff

View File

@@ -1,125 +0,0 @@
# Accessibility
On the Web, assistive technologies (e.g., VoiceOver, TalkBack screen readers)
derive useful information about the structure, purpose, and interactivity of
apps from their [HTML elements][html-accessibility-url], attributes, and [ARIA
in HTML][aria-in-html-url]. React Native for Web includes APIs designed to
provide developers with support for making apps more accessible. The most
common and best supported accessibility features of the Web are exposed as the
props: `accessible`, `accessibilityLabel`, `accessibilityLiveRegion`,
`accessibilityRole`, and `importantForAccessibility`.
## Accessibility properties
### accessible
When `true`, indicates that the view is an accessibility element. When a view
is an accessibility element, it groups its children into a single focusable
component. By default, all touchable elements, buttons, and links are
"accessible". Prefer using `accessibilityRole` (e.g., `button`, `link`) to
create focusable HTML elements wherever possible. On web, `accessible={true}`
is implemented using `tabIndex`.
### accessibilityLabel
When a view is marked as `accessible`, it is a good practice to set an
`accessibilityLabel` on the view, so that people who use screen readers know
what element they have selected. On web, `accessibilityLabel` is implemented
using `aria-label`.
```
<TouchableOpacity accessibilityLabel={'Tap me!'} accessible={true} onPress={this._onPress}>
<View style={styles.button}>
<Text style={styles.buttonText}>Press me!</Text>
</View>
</TouchableOpacity>
```
### accessibilityRole
In some cases, we also want to alert the end user of the type of selected
component (i.e., that it is a “button”). To provide more context to screen
readers, you should specify the `accessibilityRole` property. (Note that React
Native for Web also provides a compatibility mapping of equivalent
`accessibilityTraits` and `accessibilityComponentType` values to
`accessibilityRole`).
The `accessibilityRole` prop is used to infer an [analogous HTML
element][html-aria-url] and ARIA `role`, where possible. In most cases, both
the element and ARIA `role` are rendered. While this may contradict some ARIA
recommendations, it also helps avoid certain HTML5 conformance errors and
accessibility anti-patterns (e.g., giving a `heading` role to a `button`
element) and browser bugs.
For example:
* `<View accessibilityRole='article' />` => `<article role='article' />`.
* `<View accessibilityRole='banner' />` => `<header role='banner' />`.
* `<View accessibilityRole='button' />` => `<div role='button' tabIndex='0' />`.
* `<Text accessibilityRole='label' />` => `<label />`.
* `<Text accessibilityRole='link' href='/' />` => `<a role='link' href='/' />`.
* `<View accessibilityRole='main' />` => `<main role='main' />`.
In the example below, the `TouchableHighlight` is announced by screen
readers as a button.
```js
<TouchableHighlight accessibilityRole="button" onPress={this._handlePress}>
<View style={styles.button}>
<Text style={styles.buttonText}>Press me!</Text>
</View>
</TouchableHighlight>
```
Note: The `button` role is not implemented using the native `button` element
due to browsers limiting the use of flexbox layout on its children.
Note: Avoid changing `accessibilityRole` values over time or after user
actions. Generally, accessibility APIs do not provide a means of notifying
assistive technologies of a `role` value change.
### accessibilityLiveRegion
When components dynamically change we may need to inform the user. The
`accessibilityLiveRegion` property serves this purpose and can be set to
`none`, `polite` and `assertive`. On web, `accessibilityLiveRegion` is
implemented using `aria-live`.
* `none`: Accessibility services should not announce changes to this view.
* `polite`: Accessibility services should announce changes to this view.
* `assertive`: Accessibility services should interrupt ongoing speech to immediately announce changes to this view.
```
<TouchableWithoutFeedback onPress={this._addOne}>
<View style={styles.embedded}>
<Text>Click me</Text>
</View>
</TouchableWithoutFeedback>
<Text accessibilityLiveRegion="polite">
Clicked {this.state.count} times
</Text>
```
In the above example, method `_addOne` changes the `state.count` variable. As
soon as an end user clicks the `TouchableWithoutFeedback`, screen readers
announce text in the `Text` view because of its
`accessibilityLiveRegion="polite"` property.
### importantForAccessibility
The `importantForAccessibility` property controls if a view appears in the
accessibility tree and if it is reported to accessibility services. On web, a
value of `no` will remove a focusable element from the tab flow, and a value of
`no-hide-descendants` will also hide the entire subtree from assistive
technologies (this is implemented using `aria-hidden`).
### Other
Other ARIA properties can be set via [direct
manipulation](./direct-manipulation.md) or props (this may change in the
future).
[aria-in-html-url]: https://w3c.github.io/aria-in-html/
[html-accessibility-url]: http://www.html5accessibility.com/
[html-aria-url]: http://www.w3.org/TR/html-aria/

View File

@@ -1,240 +0,0 @@
# Getting started
This guide will help you to correctly configure build and test tools to work
with React Native for Web. (Alternatively, you can quickly setup a local
project using the starter kits listed in the README.)
It is recommended that your application provide a `Promise` and `Array.from`
polyfill.
## Web packager
[Webpack](https://webpack.js.org) is a popular build tool for web apps. Below is an
_example_ of how to configure a build that uses [Babel](https://babeljs.io/) to
compile your JavaScript for the web. Please refer to the webpack documentation
when setting up your project.
Install webpack-related dependencies, for example:
```
yarn add --dev babel-loader url-loader webpack webpack-dev-server
```
Create a `web/webpack.config.js` file:
```js
// web/webpack.config.js
const path = require('path');
const webpack = require('webpack');
const appDirectory = path.resolve(__dirname, '../');
// This is needed for webpack to compile JavaScript.
// Many OSS React Native packages are not compiled to ES5 before being
// published. If you depend on uncompiled packages they may cause webpack build
// errors. To fix this webpack can be configured to compile to the necessary
// `node_module`.
const babelLoaderConfiguration = {
test: /\.js$/,
// Add every directory that needs to be compiled by Babel during the build.
include: [
path.resolve(appDirectory, 'index.web.js'),
path.resolve(appDirectory, 'src'),
path.resolve(appDirectory, 'node_modules/react-native-uncompiled')
],
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
// This aliases 'react-native' to 'react-native-web' and includes only
// the modules needed by the app.
plugins: ['react-native-web/babel', 'transform-runtime'],
// The 'react-native' preset is recommended (or use your own .babelrc).
presets: ['react-native']
}
}
};
// This is needed for webpack to import static images in JavaScript files.
const imageLoaderConfiguration = {
test: /\.(gif|jpe?g|png|svg)$/,
use: {
loader: 'url-loader',
options: {
name: '[name].[ext]'
}
}
};
module.exports = {
// your web-specific entry file
entry: path.resolve(appDirectory, 'index.web.js'),
// configures where the build ends up
output: {
filename: 'bundle.web.js',
path: path.resolve(appDirectory, 'dist')
},
// ...the rest of your config
module: {
rules: [
babelLoaderConfiguration,
imageLoaderConfiguration
]
},
plugins: [
// `process.env.NODE_ENV === 'production'` must be `true` for production
// builds to eliminate development checks and reduce build size. You may
// wish to include additional optimizations.
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
__DEV__: process.env.NODE_ENV === 'production' || true
})
],
resolve: {
// If you're working on a multi-platform React Native app, web-specific
// module implementations should be written in files using the extension
// `.web.js`.
extensions: [ '.web.js', '.js' ]
}
}
```
To run in development from the root of your application:
```
./node_modules/.bin/webpack-dev-server -d --config ./web/webpack.config.js --inline --hot --colors
```
To build for production:
```
./node_modules/.bin/webpack -p --config ./web/webpack.config.js
```
Please refer to the Webpack documentation for more information on configuration.
### Client-side rendering
Rendering using `AppRegistry`:
```js
// index.web.js
import App from './src/App';
import React from 'react';
import ReactNative, { AppRegistry } from 'react-native';
// register the app
AppRegistry.registerComponent('App', () => App);
AppRegistry.runApplication('App', {
initialProps: {},
rootTag: document.getElementById('react-app')
});
```
Rendering within existing web apps is also possible using `ReactNative`:
```js
import AppHeader from './src/AppHeader';
import React from 'react';
import ReactNative from 'react-native';
// use .hydrate if hydrating a SSR app
ReactNative.render(<AppHeader />, document.getElementById('react-app-header'))
```
And finally, `react-native-web` components will also be rendering within a tree
produced by calling `ReactDOM.render` (i.e., an existing web app), but
otherwise it is not recommended.
### Server-side rendering
Server-side rendering is supported using the `AppRegistry`:
```js
import App from './src/App';
import ReactDOMServer from 'react-dom/server'
import ReactNative, { AppRegistry } from 'react-native'
// register the app
AppRegistry.registerComponent('App', () => App)
// prerender the app
const { element, stylesheets } = AppRegistry.getApplication('App', { initialProps });
const initialHTML = ReactDOMServer.renderToString(element);
const initialStyles = stylesheets.map((sheet) => ReactDOMServer.renderToStaticMarkup(sheet)).join('\n');
// construct HTML document
const document = `
<!DOCTYPE html>
<html>
<head>
${initialStyles}
</head>
<body>
${initialHTML}
`
```
## Web-specific code
Minor platform differences can use the `Platform` module.
```js
import { Platform } from 'react-native';
const styles = StyleSheet.create({
height: (Platform.OS === 'web') ? 200 : 100,
});
```
More significant platform differences should use platform-specific files (see
the webpack configuration above for resolving `*.web.js` files):
For example, with the following files in your project:
```
MyComponent.android.js
MyComponent.ios.js
MyComponent.web.js
```
And the following import:
```js
import MyComponent from './MyComponent';
```
React Native will automatically import the correct variant for each specific
target platform.
## Testing with Jest
[Jest](https://facebook.github.io/jest/) can be configured to improve snapshots
of `react-native-web` components.
```
{
"snapshotSerializers": [ "enzyme-to-json/serializer", "react-native-web/jest/serializer" ]
}
```
Jest also needs to map `react-native` to `react-native-web` (unless you are
using Babel with the `react-native-web/babel` plugin).
```
{
"moduleNameMapper": {
"react-native": "<rootDir>/node_modules/react-native-web"
}
}
```
Please refer to the Jest documentation for more information.

View File

@@ -1,31 +0,0 @@
# Known issues
## Safari flexbox performance
Safari version prior to 10.1 can suffer from extremely [poor flexbox
performance](https://bugs.webkit.org/show_bug.cgi?id=150445). The recommended
way to work around this issue (as used on mobile.twitter.com) is to set
`display:block` on Views in your element hierarchy that you know don't need
flexbox layout.
## Missing modules and components
Not all of the views present on iOS/Android are currently available on Web. We
are very much interested in the community's feedback on the next set of modules
and views.
Not all the modules or views for iOS/Android can be implemented on Web. In some
cases it will be necessary to use a Web counterpart or to guard the use of a
module with `Platform.OS` (e.g. `NativeModules`)
## Missing component props
There are properties that do not work across all platforms. All web-specific
props are annotated with `(web)` in the documentation.
## Platform parity
There are some known issues in React Native where APIs could be made more
consistent between platforms. For example, React Native for Web includes
`ActivityIndicator` and a horizontal `ProgressBar` for Web use, in anticipation
of the convergence between the iOS and Android components in React Native.

View File

@@ -1,11 +0,0 @@
{
"scripts": {
"build": "yarn && build-storybook -o ./dist -c ./storybook/.storybook",
"start": "start-storybook -p 9001 -c ./storybook/.storybook",
"release": "yarn build && git checkout gh-pages && rm -rf ../storybook && mv dist ../storybook && git add -A && git commit -m \"Storybook deploy\" && git push origin gh-pages && git checkout -"
},
"dependencies": {
"@storybook/addon-options": "^3.1.6",
"@storybook/react": "^3.1.9"
}
}

View File

@@ -1 +0,0 @@
import '@storybook/addon-options/register';

View File

@@ -1,23 +0,0 @@
import { setOptions } from '@storybook/addon-options';
import centered from './decorator-centered';
import { configure, addDecorator } from '@storybook/react';
const context = require.context('../', true, /Screen\.js$/);
addDecorator(centered);
setOptions({
name: 'React Native Web',
url: 'https://necolas.github.io/react-native-web',
goFullScreen: false,
showLeftPanel: true,
showDownPanel: false,
showSearchBox: false,
downPanelInRight: false
});
function loadStories() {
context.keys().forEach(context);
}
configure(loadStories, module);

View File

@@ -1,36 +0,0 @@
const path = require('path');
const webpack = require('webpack');
module.exports = (storybookBaseConfig, configType) => {
const DEV = configType === 'DEVELOPMENT';
storybookBaseConfig.module.rules.push({
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: { cacheDirectory: true }
}
});
storybookBaseConfig.module.rules.push({
test: /\.(gif|jpe?g|png|svg)$/,
use: {
loader: 'url-loader',
options: { name: '[name].[ext]' }
}
});
storybookBaseConfig.plugins.push(
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
'process.env.__REACT_NATIVE_DEBUG_ENABLED__': DEV
})
);
storybookBaseConfig.resolve.alias = {
'react-native': path.join(__dirname, '../../../src/module')
};
return storybookBaseConfig;
};

View File

@@ -1,59 +0,0 @@
/* eslint-disable react/jsx-sort-props */
/**
* @flow
*/
import PropAnimating from './examples/PropAnimating';
import PropColor from './examples/PropColor';
import PropHidesWhenStopped from './examples/PropHidesWhenStopped';
import PropSize from './examples/PropSize';
import React from 'react';
import UIExplorer, { Description, DocItem, Section, storiesOf } from '../../ui-explorer';
const ActivityIndicatorScreen = () => (
<UIExplorer title="ActivityIndicator" url="1-components/ActivityIndicator">
<Description>Displays a customizable activity indicator</Description>
<Section title="Props">
<DocItem name="...View props" />
<DocItem
name="animating"
typeInfo="?boolean = true"
description="Whether to show the indicator or hide it."
example={{
render: () => <PropAnimating />
}}
/>
<DocItem
name="color"
typeInfo="?color = #1976D2"
description="The foreground color of the spinner."
example={{
render: () => <PropColor />
}}
/>
<DocItem
name="hidesWhenStopped"
typeInfo="?boolean = true"
description="Whether the indicator should hide when not animating."
example={{
render: () => <PropHidesWhenStopped />
}}
/>
<DocItem
name="size"
typeInfo="?enum('small', 'large') | number = 'small'"
description="Size of the indicator. Small has a height of 20px, large has a height of 36px."
example={{
render: () => <PropSize />
}}
/>
</Section>
</UIExplorer>
);
storiesOf('Components', module).add('ActivityIndicator', ActivityIndicatorScreen);

View File

@@ -1,22 +0,0 @@
/**
* @flow
*/
import { ActivityIndicator, StyleSheet, View } from 'react-native';
import React from 'react';
const ActivityIndicatorAnimatingExample = () => (
<View style={styles.horizontal}>
<ActivityIndicator />
<ActivityIndicator animating={false} />
</View>
);
const styles = StyleSheet.create({
horizontal: {
alignItems: 'center',
flexDirection: 'row'
}
});
export default ActivityIndicatorAnimatingExample;

View File

@@ -1,34 +0,0 @@
/**
* @flow
*/
import React from 'react';
import { ActivityIndicator, StyleSheet, View } from 'react-native';
const ActivityIndicatorColorExample = () => (
<View style={styles.horizontal}>
<ActivityIndicator color="#1DA1F2" style={styles.rightPadding} />
<ActivityIndicator color="#17BF63" style={styles.rightPadding} />
<ActivityIndicator color="#F45D22" style={styles.rightPadding} />
<ActivityIndicator color="#794BC4" style={styles.rightPadding} />
<ActivityIndicator color="#E0245E" style={styles.rightPadding} />
<ActivityIndicator color="#FFAD1F" style={styles.rightPadding} />
</View>
);
const styles = StyleSheet.create({
horizontal: {
alignItems: 'center',
flexDirection: 'row'
},
rightPadding: {
paddingRight: 10
}
});
ActivityIndicatorColorExample.metadata = {
id: 'ActivityIndicator.props.color',
description: ''
};
export default ActivityIndicatorColorExample;

View File

@@ -1,33 +0,0 @@
/**
* @flow
*/
import React from 'react';
import { ActivityIndicator, StyleSheet, View } from 'react-native';
const sizes = [20, 'small', 36, 'large', 60];
const ActivityIndicatorSizeExample = () => (
<View style={styles.horizontal}>
{sizes.map((size, i) => <ActivityIndicator key={i} size={size} style={styles.rightPadding} />)}
<ActivityIndicator size="large" style={styles.large} />
</View>
);
const styles = StyleSheet.create({
horizontal: {
alignItems: 'center',
flexDirection: 'row'
},
rightPadding: {
paddingRight: 10
},
large: { marginLeft: 20, transform: [{ scale: 1.75 }] }
});
ActivityIndicatorSizeExample.metadata = {
id: 'ActivityIndicator.props.size',
description: ''
};
export default ActivityIndicatorSizeExample;

View File

@@ -1,74 +0,0 @@
/* eslint-disable react/jsx-sort-props */
/**
* @flow
*/
import React from 'react';
import PropColor from './examples/PropColor';
import PropDisabled from './examples/PropDisabled';
import PropOnPress from './examples/PropOnPress';
import UIExplorer, {
AppText,
Code,
Description,
DocItem,
Section,
storiesOf
} from '../../ui-explorer';
const ButtonScreen = () => (
<UIExplorer title="Button" url="1-components/Button">
<Description>
<AppText>
A basic button component. Supports a minimal level of customization. You can build your own
custom button using <Code>TouchableOpacity</Code> or <Code>TouchableNativeFeedback</Code>.
</AppText>
</Description>
<Section title="Props">
<DocItem
name="accessibilityLabel"
typeInfo="?string"
description="Overrides the text that's read by a screen reader when the user interacts with the element."
/>
<DocItem
name="color"
typeInfo="?string"
description="Background color of the button."
example={{
render: () => <PropColor />
}}
/>
<DocItem
name="disabled"
typeInfo="?boolean"
description="If true, disable all interactions for this element."
example={{
render: () => <PropDisabled />
}}
/>
<DocItem
name="onPress"
typeInfo="function"
description="This function is called on press."
example={{
render: () => <PropOnPress />
}}
/>
<DocItem
name="testID"
typeInfo="?string"
description="Used to locate this view in end-to-end tests."
/>
<DocItem name="title" typeInfo="string" description="Text to display inside the button." />
</Section>
</UIExplorer>
);
storiesOf('Components', module).add('Button', ButtonScreen);

View File

@@ -1,23 +0,0 @@
/**
* @flow
*/
import React from 'react';
import { DividerVertical } from '../helpers';
import { Button, View } from 'react-native';
const emptyFunction = () => {};
const ButtonColorExample = () => (
<View>
<Button color="#17BF63" onPress={emptyFunction} title="Press me" />
<DividerVertical />
<Button color="#F45D22" onPress={emptyFunction} title="Press me" />
<DividerVertical />
<Button color="#794BC4" onPress={emptyFunction} title="Press me" />
<DividerVertical />
<Button color="#E0245E" onPress={emptyFunction} title="Press me" />
</View>
);
export default ButtonColorExample;

View File

@@ -1,13 +0,0 @@
/**
* @flow
*/
import React from 'react';
import { Button } from 'react-native';
const onPress = () => {
console.error('Disabled button should not trigger onPress!');
};
const ButtonDisabledExample = () => <Button disabled onPress={onPress} title="Disabled button" />;
export default ButtonDisabledExample;

View File

@@ -1,29 +0,0 @@
/**
* @flow
*/
import React from 'react';
import { DividerHorizontal } from '../helpers';
import { Button, StyleSheet, View } from 'react-native';
const emptyFunction = () => {};
const ButtonOnPressExample = () => (
<View style={styles.horizontal}>
<Button
accessibilityLabel="This sounds great!"
onPress={emptyFunction}
title="This looks great!"
/>
<DividerHorizontal />
<Button color="#841584" onPress={emptyFunction} title="Ok!" />
</View>
);
const styles = StyleSheet.create({
horizontal: {
flexDirection: 'row'
}
});
export default ButtonOnPressExample;

View File

@@ -1,93 +0,0 @@
/* eslint-disable react/jsx-sort-props */
/**
* @flow
*/
import CustomSize from './examples/CustomSize';
import PropColor from './examples/PropColor';
import PropDisabled from './examples/PropDisabled';
import PropOnValueChange from './examples/PropOnValueChange';
import PropValue from './examples/PropValue';
import React from 'react';
import UIExplorer, {
AppText,
Code,
Description,
DocItem,
Section,
storiesOf
} from '../../ui-explorer';
const CheckBoxScreen = () => (
<UIExplorer title="CheckBox" url="components/CheckBox">
<Description>
<AppText>
This is a controlled component that requires an <Code>onValueChange</Code> callback that
updates the value prop in order for the component to reflect user actions. If the{' '}
<Code>value</Code> prop is not updated, the component will continue to render the supplied{' '}
<Code>value</Code> prop instead of the expected result of any user actions.
</AppText>
</Description>
<Section title="Props">
<DocItem name="...View props" />
<DocItem
description="Customize the color of the checkbox."
example={{
render: () => <PropColor />
}}
label="web"
name="color"
typeInfo="?color"
/>
<DocItem
description="If true, the user won't be able to interact with the checkbox."
example={{
render: () => <PropDisabled />
}}
name="disabled"
typeInfo="?boolean = false"
/>
<DocItem
description="Invoked with the event when the value changes."
name="onChange"
typeInfo="?function"
/>
<DocItem
description="Invoked with the new value when the value changes."
example={{
render: () => <PropOnValueChange />
}}
name="onValueChange"
typeInfo="?function"
/>
<DocItem
description="The value of the checkbox. If `true` the checkbox will be checked."
example={{
render: () => <PropValue />
}}
name="value"
typeInfo="?boolean = false"
/>
</Section>
<Section title="More examples">
<DocItem
description="The checkbox size can be controlled by the 'height' and 'width' style properties"
example={{
code: '<CheckBox style={{ height: 32, width: 32 }} />',
render: () => <CustomSize />
}}
name="Custom size"
/>
</Section>
</UIExplorer>
);
storiesOf('Components', module).add('CheckBox', CheckBoxScreen);

View File

@@ -1,20 +0,0 @@
/**
* @flow
*/
import React from 'react';
import styles from './styles';
import { CheckBox, View } from 'react-native';
const CustomSizeExample = () => (
<View style={styles.row}>
<View style={styles.marginRight}>
<CheckBox style={{ height: 20, width: 20 }} value />
</View>
<View style={styles.marginRight}>
<CheckBox style={{ height: 32, width: 32 }} value />
</View>
</View>
);
export default CustomSizeExample;

View File

@@ -1,20 +0,0 @@
/**
* @flow
*/
import React from 'react';
import styles from './styles';
import { CheckBox, View } from 'react-native';
const CheckBoxColorExample = () => (
<View style={styles.row}>
<View style={styles.marginRight}>
<CheckBox color="#1DA1F2" value />
</View>
<View style={styles.marginRight}>
<CheckBox color="#F45D22" value />
</View>
</View>
);
export default CheckBoxColorExample;

View File

@@ -1,20 +0,0 @@
/**
* @flow
*/
import React from 'react';
import styles from './styles';
import { CheckBox, View } from 'react-native';
const CheckBoxDisabledExample = () => (
<View style={styles.row}>
<View style={styles.marginRight}>
<CheckBox disabled value={false} />
</View>
<View style={styles.marginRight}>
<CheckBox disabled value />
</View>
</View>
);
export default CheckBoxDisabledExample;

View File

@@ -1,20 +0,0 @@
/**
* @flow
*/
import React from 'react';
import styles from './styles';
import { CheckBox, View } from 'react-native';
const CheckBoxValueExample = () => (
<View style={styles.row}>
<View style={styles.marginRight}>
<CheckBox value={false} />
</View>
<View style={styles.marginRight}>
<CheckBox value />
</View>
</View>
);
export default CheckBoxValueExample;

View File

@@ -1,32 +0,0 @@
/* eslint-disable react/jsx-sort-props */
/**
* @flow
*/
import React from 'react';
import PropChildren from './examples/PropChildren';
import UIExplorer, { Description, DocItem, Section, storiesOf } from '../../ui-explorer';
const ImageBackgroundScreen = () => (
<UIExplorer title="ImageBackground" url="1-components/ImageBackground">
<Description>A image component with support for child content.</Description>
<Section title="Props">
<DocItem name="...Image props" />
<DocItem
name="children"
typeInfo="?any"
description="Content to display over the image."
example={{
render: () => <PropChildren />
}}
/>
<DocItem name="imageStyle" typeInfo="?style" description="Styles for the inner image." />
</Section>
</UIExplorer>
);
storiesOf('Components', module).add('ImageBackground', ImageBackgroundScreen);

View File

@@ -1,171 +0,0 @@
/* eslint-disable react/jsx-sort-props */
/**
* @flow
*/
import React from 'react';
import PropDefaultSource from './examples/PropDefaultSource';
import PropDraggable from './examples/PropDraggable';
import PropOnError from './examples/PropOnError';
import PropOnLoad from './examples/PropOnLoad';
import PropOnLoadEnd from './examples/PropOnLoadEnd';
import PropOnLoadStart from './examples/PropOnLoadStart';
import PropResizeMode from './examples/PropResizeMode';
import PropSource from './examples/PropSource';
import StaticGetSizeExample from './examples/StaticGetSize';
import StaticPrefetchExample from './examples/StaticPrefetch';
import UIExplorer, {
AppText,
Code,
Description,
DocItem,
Section,
storiesOf
} from '../../ui-explorer';
const ImageScreen = () => (
<UIExplorer title="Image" url="1-components/Image">
<Description>
An accessibile image component with support for image resizing, default image, and child
content.
</Description>
<Section title="Props">
<DocItem name="...View props" />
<DocItem
name="defaultSource"
typeInfo="?object"
description={
<AppText>
An image to display as a placeholder while downloading the final image off the network.{' '}
<Code>{'{ uri: string, width, height }'}</Code>
</AppText>
}
example={{
render: () => <PropDefaultSource />
}}
/>
<DocItem
label="web"
name="draggable"
typeInfo="?boolean = true"
description="When false, the image will not be draggable"
example={{
render: () => <PropDraggable />
}}
/>
<DocItem
name="onError"
typeInfo="?function"
description={
<AppText>
Invoked on load error with <Code>{'{nativeEvent: {error}}'}</Code>.
</AppText>
}
example={{
render: () => <PropOnError />
}}
/>
<DocItem
name="onLoad"
typeInfo="?function"
description="Invoked when load completes successfully."
example={{
render: () => <PropOnLoad />
}}
/>
<DocItem
name="onLoadEnd"
typeInfo="?function"
description="Invoked when load either succeeds or fails."
example={{
render: () => <PropOnLoadEnd />
}}
/>
<DocItem
name="onLoadStart"
typeInfo="?function"
description="Invoked on load start."
example={{
render: () => <PropOnLoadStart />
}}
/>
<DocItem
name="resizeMode"
typeInfo="?enum('center', 'contain', 'cover', 'none', 'repeat', 'stretch') = 'cover';"
description="Determines how to resize the image when the frame doesn't match the raw image dimensions."
example={{
render: () => <PropResizeMode />
}}
/>
<DocItem
name="source"
typeInfo="?object"
description={
<AppText>
<Code>uri</Code> is a string representing the resource identifier for the image, which
could be an http address or a base64 encoded image.{' '}
<Code>{'{ uri: string, width, height }'}</Code>
</AppText>
}
example={{
render: () => <PropSource />
}}
/>
<DocItem name="style" typeInfo="?style" />
</Section>
<Section title="Properties">
<DocItem
name="static resizeMode"
typeInfo="object"
example={{
code: '<Image resizeMode={Image.resizeMode.contain} />'
}}
/>
</Section>
<Section title="Methods">
<DocItem
name="static getSize"
typeInfo="(uri: string, success: (width, height) => {}, failure: function) => void"
description={[
<AppText key={1}>
Retrieve the width and height (in pixels) of an image prior to displaying it. This
method can fail if the image cannot be found, or fails to download.
</AppText>,
<AppText key={2}>
(In order to retrieve the image dimensions, the image may first need to be loaded or
downloaded, after which it will be cached. This means that in principle you could use
this method to preload images, however it is not optimized for that purpose, and may in
future be implemented in a way that does not fully load/download the image data.)
</AppText>
]}
example={{
render: () => <StaticGetSizeExample />
}}
/>
<DocItem
name="static prefetch"
typeInfo="(url: string) => Promise"
description="Prefetches a remote image for later use by downloading it."
example={{
render: () => <StaticPrefetchExample />
}}
/>
</Section>
</UIExplorer>
);
storiesOf('Components', module).add('Image', ImageScreen);

View File

@@ -1,14 +0,0 @@
/**
* @flow
*/
import * as helpers from '../helpers';
import sources from '../sources';
import React from 'react';
import { Image } from 'react-native';
const ImageDefaultSourceExample = () => (
<Image defaultSource={sources.placeholder} style={helpers.styles.base} />
);
export default ImageDefaultSourceExample;

View File

@@ -1,11 +0,0 @@
/**
* @flow
*/
import NetworkImage from './NetworkImage';
import React from 'react';
import sources from '../sources';
const ImageOnErrorExample = () => <NetworkImage logMethod="onError" source={sources.broken} />;
export default ImageOnErrorExample;

View File

@@ -1,14 +0,0 @@
/**
* @flow
*/
import { createUncachedURI } from '../helpers';
import NetworkImage from './NetworkImage';
import React from 'react';
import sources from '../sources';
const ImageOnLoadExample = () => (
<NetworkImage logMethod="onLoad" source={createUncachedURI(sources.largeAlt)} />
);
export default ImageOnLoadExample;

View File

@@ -1,14 +0,0 @@
/**
* @flow
*/
import { createUncachedURI } from '../helpers';
import NetworkImage from './NetworkImage';
import React from 'react';
import sources from '../sources';
const ImageOnLoadEndExample = () => (
<NetworkImage logMethod="onLoadEnd" source={createUncachedURI(sources.largeAlt)} />
);
export default ImageOnLoadEndExample;

View File

@@ -1,14 +0,0 @@
/**
* @flow
*/
import { createUncachedURI } from '../helpers';
import NetworkImage from './NetworkImage';
import React from 'react';
import sources from '../sources';
const ImageOnLoadStartExample = () => (
<NetworkImage logMethod="onLoadStart" source={createUncachedURI(sources.largeAlt)} />
);
export default ImageOnLoadStartExample;

View File

@@ -1,74 +0,0 @@
/**
* @flow
*/
import React from 'react';
import sources from '../sources';
import { Image, StyleSheet, Text, View } from 'react-native';
const ImageResizeModeExample = () => (
<View>
{[sources.small].map((source, i) => {
return (
<View key={i}>
<View style={styles.horizontal}>
<View>
<Text style={[styles.resizeModeText]}>Contain</Text>
<Image
resizeMode={Image.resizeMode.contain}
source={source}
style={styles.resizeMode}
/>
</View>
<View>
<Text style={[styles.resizeModeText]}>Cover</Text>
<Image
resizeMode={Image.resizeMode.cover}
source={source}
style={styles.resizeMode}
/>
</View>
<View>
<Text style={[styles.resizeModeText]}>Stretch</Text>
<Image
resizeMode={Image.resizeMode.stretch}
source={source}
style={styles.resizeMode}
/>
</View>
<View>
<Text style={[styles.resizeModeText]}>Repeat</Text>
<Image resizeMode={'repeat'} source={source} style={styles.resizeMode} />
</View>
<View>
<Text style={[styles.resizeModeText]}>Center</Text>
<Image resizeMode={'center'} source={source} style={styles.resizeMode} />
</View>
</View>
</View>
);
})}
</View>
);
const styles = StyleSheet.create({
horizontal: {
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'space-between'
},
resizeMode: {
borderColor: 'black',
borderWidth: 0.5,
height: 120,
width: 120
},
resizeModeText: {
marginBottom: '0.5rem'
},
leftMargin: {
marginLeft: 10
}
});
export default ImageResizeModeExample;

View File

@@ -1,52 +0,0 @@
/**
* @flow
*/
import sources from '../sources';
import React from 'react';
import { Image, StyleSheet, Text, View } from 'react-native';
const ImageSourceExample = () => (
<View style={styles.row}>
<View style={styles.column}>
<Text style={styles.text}>Static image</Text>
<Image source={sources.static} style={styles.image} />
</View>
<View style={styles.column}>
<Text style={styles.text}>Animated GIF</Text>
<Image source={sources.animatedGif} style={styles.image} />
</View>
<View style={styles.column}>
<Text style={styles.text}>Data PNG</Text>
<Image source={sources.dataPng} style={styles.image} />
</View>
<View style={styles.column}>
<Text style={styles.text}>Data SVG</Text>
<Image source={sources.dataSvg} style={styles.image} />
</View>
</View>
);
const styles = StyleSheet.create({
row: {
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'space-between'
},
column: {
alignItems: 'flex-start',
marginBottom: '1rem'
},
text: {
marginBottom: '0.5rem'
},
image: {
borderColor: 'black',
borderWidth: 0.5,
height: 120,
width: 120,
resizeMode: 'cover'
}
});
export default ImageSourceExample;

View File

@@ -1,113 +0,0 @@
/* eslint-disable react/jsx-sort-props, react/jsx-no-bind, no-alert */
/**
* @flow
*/
import React from 'react';
import PickerExample from './examples/PickerExample';
import UIExplorer, {
AppText,
Description,
DocItem,
Section,
StyleList,
storiesOf
} from '../../ui-explorer';
import { View } from 'react-native';
const PickerScreen = () => (
<View>
<UIExplorer title="Picker">
<Description>
<AppText>Renders the native &lt;select&gt; component.</AppText>
</Description>
<Section title="Props">
<DocItem
name="children"
typeInfo="?Array<Picker.Item>"
description="The items to display in the picker."
example={{
code: `<Picker>
<Picker.Item label="Goblet of Fire" />
<Picker.Item label="Order of the Phoenix" />
</Picker>`
}}
/>
<DocItem
name="enabled"
typeInfo="?boolean"
description="If set to false, the picker will be disabled, i.e., the user will not be able to make a selection."
example={{
render: () => <PickerExample enabled={false} />
}}
/>
<DocItem
name="onValueChange"
typeInfo="?(itemValue, itemIndex) => void"
description="Callback for when an item is selected. This is called with the value and index prop of the item that was selected."
example={{
render: () => (
<PickerExample
onValueChange={(itemValue, itemPosition) => {
window.alert(`itemValue: ${itemValue}, itemPosition: ${itemPosition}`);
}}
/>
)
}}
/>
<DocItem
name="selectedValue"
typeInfo="?string"
description="Select the item with the matching value."
example={{
render: () => <PickerExample selectedValue="book-3" />
}}
/>
<DocItem
name="style"
typeInfo="?style"
description={
<StyleList
stylePropTypes={[
{
name: '…View#style'
},
{
name: 'color',
typeInfo: 'color'
}
]}
/>
}
/>
<DocItem
name="testID"
typeInfo="?string"
description="Used to locate this view in end-to-end tests."
/>
</Section>
</UIExplorer>
<UIExplorer title="Picker.Item" url="1-components/Picker">
<Description>Individual selectable item in a Picker.</Description>
<Section title="Props">
<DocItem name="label" typeInfo="string" description="Text to display for this item" />
<DocItem name="testID" typeInfo="?string" />
<DocItem
name="value"
typeInfo="?number | string"
description="The value to be passed to the picker's 'onValueChange' callback when this item is selected."
/>
</Section>
</UIExplorer>
</View>
);
storiesOf('Components', module).add('Picker', PickerScreen);

View File

@@ -1,68 +0,0 @@
/**
* @flow
*/
import PropColor from './examples/PropColor';
import CustomSize from './examples/CustomSize';
import PropIndeterminate from './examples/PropIndeterminate';
import PropProgress from './examples/PropProgress';
import PropTrackColor from './examples/PropTrackColor';
import React from 'react';
import UIExplorer, { Description, DocItem, Section, storiesOf } from '../../ui-explorer';
const ProgressBarScreen = () => (
<UIExplorer title="ProgressBar" url="1-components/ProgressBar">
<Description>Display an activity progress bar</Description>
<Section title="Props">
<DocItem name="...View props" />
<DocItem
description="Color of the progress bar."
example={{
render: () => <PropColor />
}}
name="color"
typeInfo="?string = #1976D2"
/>
<DocItem
description="Whether the progress bar will show indeterminate progress."
example={{
render: () => <PropIndeterminate />
}}
name="indeterminate"
typeInfo="?boolean = true"
/>
<DocItem
description="The progress value (between 0 and 1)."
example={{
render: () => <PropProgress />
}}
name="progress"
typeInfo="?number"
/>
<DocItem
description="Color of the track bar."
example={{
render: () => <PropTrackColor />
}}
name="trackColor"
typeInfo="?string = 'transparent'"
/>
</Section>
<Section title="More examples">
<DocItem
description="Custom sizes can be created using styles"
example={{
code: '<ProgressBar style={{ borderRadius: 10, height: 10 }} trackColor="#D1E3F6" />',
render: () => <CustomSize />
}}
/>
</Section>
</UIExplorer>
);
storiesOf('Components', module).add('ProgressBar', ProgressBarScreen);

View File

@@ -1,28 +0,0 @@
/**
* @flow
*/
import { DividerVertical } from '../helpers';
import React from 'react';
import { ProgressBar, StyleSheet, View } from 'react-native';
const ProgressBarCustomSizeExample = () => (
<View>
<ProgressBar color="#1DA1F2" progress={0.33} style={styles.one} trackColor="#D1E3F6" />
<DividerVertical />
<ProgressBar color="#1DA1F2" progress={0.33} style={styles.two} trackColor="#D1E3F6" />
</View>
);
const styles = StyleSheet.create({
one: {
borderRadius: 10,
height: 10
},
two: {
borderRadius: 10,
height: 20
}
});
export default ProgressBarCustomSizeExample;

View File

@@ -1,23 +0,0 @@
/**
* @flow
*/
import React from 'react';
import { DividerVertical } from '../helpers';
import { ProgressBar, View } from 'react-native';
const ProgressBarColorExample = () => (
<View>
<ProgressBar color="#1DA1F2" progress={0.2} />
<DividerVertical />
<ProgressBar color="#17BF63" progress={0.4} />
<DividerVertical />
<ProgressBar color="#F45D22" progress={0.6} />
<DividerVertical />
<ProgressBar color="#794BC4" progress={0.8} />
<DividerVertical />
<ProgressBar color="#E0245E" progress={1.0} />
</View>
);
export default ProgressBarColorExample;

View File

@@ -1,10 +0,0 @@
/**
* @flow
*/
import React from 'react';
import { ProgressBar } from 'react-native';
const ProgressBarIndeterminateExample = () => <ProgressBar indeterminate trackColor="#D1E3F6" />;
export default ProgressBarIndeterminateExample;

View File

@@ -1,48 +0,0 @@
/**
* @flow
*/
import { DividerVertical } from '../helpers';
import React, { PureComponent } from 'react';
import { ProgressBar, StyleSheet, View } from 'react-native';
class ProgressBarProgressExample extends PureComponent {
state = { progress: 0 };
componentDidMount() {
this._updateProgress();
}
componentWillUnmount() {
window.cancelAnimationFrame(this._frame);
}
render() {
return (
<View>
<ProgressBar color="#794BC4" progress={0.2} style={styles.progress} />
<DividerVertical />
<ProgressBar color="#794BC4" progress={this._getProgress(0.2)} style={styles.progress} />
</View>
);
}
_getProgress(offset) {
const progress = this.state.progress + offset;
return Math.sin(progress % Math.PI) % 1;
}
_updateProgress() {
const progress = this.state.progress + 0.01;
this.setState(() => ({ progress }));
this._frame = window.requestAnimationFrame(() => this._updateProgress());
}
}
const styles = StyleSheet.create({
progress: {
minWidth: 200
}
});
export default ProgressBarProgressExample;

View File

@@ -1,19 +0,0 @@
/**
* @flow
*/
import { DividerVertical } from '../helpers';
import React from 'react';
import { ProgressBar, View } from 'react-native';
const ProgressBarTrackColorExample = () => (
<View>
<ProgressBar color="#1DA1F2" progress={0.1} trackColor="#17BF63" />
<DividerVertical />
<ProgressBar color="#1DA1F2" progress={0.2} trackColor="#F45D22" />
<DividerVertical />
<ProgressBar color="#1DA1F2" progress={0.3} trackColor="#794BC4" />
</View>
);
export default ProgressBarTrackColorExample;

View File

@@ -1,172 +0,0 @@
/* eslint-disable react/jsx-no-bind, react/jsx-sort-props */
/**
* @flow
*/
import { HorizontalExample } from './examples/Horizontal';
import ScrollToExample from './examples/ScrollTo';
import ScrollToEndExample from './examples/ScrollToEnd';
import React from 'react';
import UIExplorer, {
AppText,
Code,
Description,
DocItem,
Section,
storiesOf,
TextList
} from '../../ui-explorer';
const ScrollViewScreen = () => (
<UIExplorer title="ScrollView" url="1-components/ScrollView">
<Description>
<AppText>
A scrollable <Code>View</Code> that provides itegration with the touch-locking responder
system. <Code>ScrollView</Code>'s must have a bounded height: either set the height of the
view directly (discouraged) or make sure all parent views have bounded height (e.g.,
transfer <Code>{'{ flex: 1}'}</Code> down the view stack).
</AppText>
</Description>
<Section title="Props">
<DocItem name="...View props" />
<DocItem
name="contentContainerStyle"
typeInfo="?style"
description="These styles will be applied to the scroll view content container which wraps all of the child views."
/>
<DocItem
name="horizontal"
typeInfo="?boolean = false"
description="When true, the scroll view's children are arranged horizontally in a row instead of vertically in a column."
example={{
render: () => <HorizontalExample />
}}
/>
<DocItem
name="keyboardDismissMode"
typeInfo="?enum('none', 'on-drag') = 'none'"
description={[
<AppText>
Determines whether the keyboard gets dismissed in response to a scroll drag.
</AppText>,
<TextList
items={[
<AppText>
<Code>none</Code> (the default): drags do not dismiss the keyboard.
</AppText>,
<AppText>
<Code>on-drag</Code>: the keyboard is dismissed when a drag begins.
</AppText>,
<AppText>
<Code>interactive</Code> (not supported on web; same as <Code>none</Code>)
</AppText>
]}
/>
]}
/>
<DocItem
name="onContentSizeChange"
typeInfo="?function"
description={
<AppText>
Called when scrollable content view of the <Code>ScrollView</Code> changes. It's
implemented using the <Code>onLayout</Code> handler attached to the content container
which this <Code>ScrollView</Code> renders.
</AppText>
}
/>
<DocItem
name="onScroll"
typeInfo="?function"
description={[
<AppText>
Fires at most once per frame during scrolling. The frequency of the events can be
contolled using the <Code>scrollEventThrottle</Code> prop.
</AppText>,
<AppText>Invoked on scroll with the following event:</AppText>,
<Code>{`{
nativeEvent: {
contentOffset: { x, y },
contentSize: { height, width },
layoutMeasurement: { height, width }
}
}`}</Code>
]}
/>
<DocItem
name="scrollEnabled"
typeInfo="?boolean = true"
description="When false, the content does not scroll."
/>
<DocItem
name="scrollEventThrottle"
typeInfo="?number = 0"
description={
<AppText>
This controls how often the scroll event will be fired while scrolling (as a time
interval in ms). A lower number yields better accuracy for code that is tracking the
scroll position, but can lead to scroll performance problems. The default value is{' '}
<Code>0</Code>, which means the scroll event will be sent only once each time the view
is scrolled.
</AppText>
}
/>
</Section>
<Section title="Instance methods">
<DocItem
name="getInnerViewNode"
typeInfo="() => node"
description="Returns a reference to the underlying content container DOM node within the ScrollView."
/>
<DocItem
name="getScrollableNode"
typeInfo="() => node"
description="Returns a reference to the underlying scrollable DOM node."
/>
<DocItem
name="getScrollResponder"
typeInfo="() => ScrollResponder"
description={
<AppText>
Returns a reference to the underlying scroll responder, which supports operations like{' '}
<Code>scrollTo</Code>. All <Code>ScrollView</Code>-like components should implement this
method so that they can be composed while providing access to the underlying scroll
responder's methods.
</AppText>
}
/>
<DocItem
name="scrollTo"
typeInfo="(options: { x: number = 0; y: number = 0; animated: boolean = true }) => void"
description="Scrolls to a given `x`, `y` offset (animation is not currently supported)."
example={{
render: () => <ScrollToExample />
}}
/>
<DocItem
name="scrollToEnd"
typeInfo="(options: { animated: boolean = true }) => void"
description="Scrolls to the end of the scroll view."
example={{
render: () => <ScrollToEndExample />
}}
/>
</Section>
</UIExplorer>
);
storiesOf('Components', module).add('ScrollView', ScrollViewScreen);

View File

@@ -1,68 +0,0 @@
/* eslint-disable react/jsx-no-bind */
/**
* @flow
*/
import React from 'react';
import { ScrollView, StyleSheet, Text, View } from 'react-native';
const onScroll = () => {
console.log('ScrollView.onScroll');
};
const VerticalExample = () => (
<View style={styles.scrollViewContainer}>
<ScrollView
contentContainerStyle={styles.scrollViewContentContainerStyle}
onScroll={onScroll}
scrollEventThrottle={16} // ~60 events per second
style={styles.scrollViewStyle}
>
{Array.from({ length: 50 }).map((item, i) => (
<View key={i} style={[styles.box, styles.horizontalBox]}>
<Text>{i}</Text>
</View>
))}
</ScrollView>
</View>
);
const HorizontalExample = () => (
<View style={styles.scrollViewContainer}>
<ScrollView
contentContainerStyle={styles.scrollViewContentContainerStyle}
horizontal
onScroll={onScroll}
scrollEventThrottle={16} // ~60 events per second
style={styles.scrollViewStyle}
>
{Array.from({ length: 50 }).map((item, i) => (
<View key={i} style={[styles.box, styles.horizontalBox]}>
<Text>{i}</Text>
</View>
))}
</ScrollView>
</View>
);
export { HorizontalExample, VerticalExample };
const styles = StyleSheet.create({
box: {
flexGrow: 1,
justifyContent: 'center',
borderWidth: 1
},
scrollViewContainer: {
height: 200,
width: 300
},
scrollViewStyle: {
borderWidth: 1
},
scrollViewContentContainerStyle: {
backgroundColor: '#eee',
padding: 10
}
});

Some files were not shown because too many files have changed in this diff Show More