-
Notifications
You must be signed in to change notification settings - Fork 3.5k
7535 refactor picker compatible form #7807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
stitesExpensify
merged 36 commits into
Expensify:main
from
LucioChavezFuentes:7535_refactor-picker-compatible-form
Apr 7, 2022
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
4ef2b51
install @storybook/addon-react-native-web
LucioChavezFuentes def46e5
align error text to label
LucioChavezFuentes 01fa795
Refactor BasePicker to Picker new props
LucioChavezFuentes a5db0db
Create BasePicker's Web version file
LucioChavezFuentes 68d619f
Extend focus method of View ref to scroll
LucioChavezFuentes d940295
refactor Picker to new proTypes
LucioChavezFuentes c243e76
Add Picker component to Form.stories
LucioChavezFuentes 857ca43
create Picker.stories.js
LucioChavezFuentes 5353111
change default 'value' prop to 'undefined'
LucioChavezFuentes dc3ba4c
update value propType, pass value prop
LucioChavezFuentes 37451fa
remove unneccesary operator
LucioChavezFuentes 82c9cd2
Revert "change default 'value' prop to 'undefined'"
LucioChavezFuentes addc22a
update comment about scroll to Picker on Web
LucioChavezFuentes 0724ae4
update comment about ref, remove unneeded operator
LucioChavezFuentes 094efba
convert index to index.native, index.web to index
LucioChavezFuentes 170fc70
update @react-native-picker/picker
LucioChavezFuentes ff316d8
Merge branch 'Expensify:main' into 7535_refactor-picker-compatible-form
LucioChavezFuentes 7fb4b0f
remove false param on scrollIntoView
LucioChavezFuentes 58d70b5
Merge branch '7535_refactor-picker-compatible-form' of https://github…
LucioChavezFuentes cf69266
Merge branch 'main' into 7535_refactor-picker-compatible-form
LucioChavezFuentes 73ef24c
Merge branch 'main' to fix storybook
LucioChavezFuentes e9a33e2
update react native picker
LucioChavezFuentes b8158b9
correct InputIDProps name
LucioChavezFuentes 2da10cf
add style prop to InlineErrorText, add style Picker
LucioChavezFuentes a893f1a
remove alternative logic to Picker ref
LucioChavezFuentes 57ab9f7
fix minor naming and empty lines
LucioChavezFuentes bc1310d
fix coding style errors
LucioChavezFuentes f12725a
merge main fix conflicts
LucioChavezFuentes 189ca7c
rename onInputChange on Picker.stories
LucioChavezFuentes 4287a7a
Merge branch 'main' into 7535_refactor-picker-compatible-form
LucioChavezFuentes 5dcec43
Merge branch 'main' into 7535_refactor-picker-compatible-form
LucioChavezFuentes eb0013d
Merge branch '7535_refactor-picker-compatible-form' of https://github…
LucioChavezFuentes 3f0f3da
merge main, fix inline error conflicts
LucioChavezFuentes 7da320a
remove old picker dependency on picker-select
LucioChavezFuentes 5060819
Merge branch 'main' into 7535_refactor-picker-compatible-form
LucioChavezFuentes bcc4c66
rename onChange to onInputChange on all Pickers
LucioChavezFuentes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,53 @@ | ||
| import React from 'react'; | ||
| import RNPickerSelect from 'react-native-picker-select'; | ||
| import _ from 'underscore'; | ||
|
|
||
| import styles from '../../../styles/styles'; | ||
| import * as basePickerPropTypes from './basePickerPropTypes'; | ||
| import basePickerStyles from './basePickerStyles'; | ||
|
|
||
| const BasePicker = props => ( | ||
| <RNPickerSelect | ||
| onValueChange={props.onChange} | ||
| items={props.items} | ||
| style={props.size === 'normal' ? basePickerStyles(props.disabled, props.hasError, props.focused) : styles.pickerSmall} | ||
| useNativeAndroidPickerStyle={false} | ||
| placeholder={props.placeholder} | ||
| value={props.value} | ||
| Icon={() => props.icon(props.size)} | ||
| disabled={props.disabled} | ||
| fixAndroidTouchableBug | ||
| onOpen={props.onOpen} | ||
| onClose={props.onClose} | ||
| pickerProps={{ | ||
| onFocus: props.onOpen, | ||
| onBlur: props.onClose, | ||
| }} | ||
| /> | ||
| ); | ||
| class BasePicker extends React.Component { | ||
luacmartins marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| constructor(props) { | ||
| super(props); | ||
|
|
||
| this.state = { | ||
| selectedValue: this.props.value || this.props.defaultValue, | ||
| }; | ||
|
|
||
| this.updateSelectedValueAndExecuteOnChange = this.updateSelectedValueAndExecuteOnChange.bind(this); | ||
| } | ||
|
|
||
| updateSelectedValueAndExecuteOnChange(value) { | ||
| this.props.onInputChange(value); | ||
luacmartins marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| this.setState({selectedValue: value}); | ||
| } | ||
|
|
||
| render() { | ||
| const hasError = !_.isEmpty(this.props.errorText); | ||
| return ( | ||
| <RNPickerSelect | ||
| onValueChange={this.updateSelectedValueAndExecuteOnChange} | ||
| items={this.props.items} | ||
| style={this.props.size === 'normal' ? basePickerStyles(this.props.disabled, hasError, this.props.focused) : styles.pickerSmall} | ||
| useNativeAndroidPickerStyle={false} | ||
| placeholder={this.props.placeholder} | ||
| value={this.state.selectedValue} | ||
| Icon={() => this.props.icon(this.props.size)} | ||
| disabled={this.props.disabled} | ||
| fixAndroidTouchableBug | ||
| onOpen={this.props.onOpen} | ||
| onClose={this.props.onClose} | ||
| pickerProps={{ | ||
| onFocus: this.props.onOpen, | ||
| onBlur: this.props.onBlur, | ||
| ref: this.props.innerRef, | ||
| }} | ||
| /> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| BasePicker.propTypes = basePickerPropTypes.propTypes; | ||
| BasePicker.defaultProps = basePickerPropTypes.defaultProps; | ||
luacmartins marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| BasePicker.displayName = 'BasePicker'; | ||
|
|
||
| export default BasePicker; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.