-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14603 from Expensify/update-staging-from-main
Update version to 1.2.60-0 on staging
- Loading branch information
Showing
29 changed files
with
232 additions
and
165 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import PropTypes from 'prop-types'; | ||
import stylePropTypes from '../../styles/stylePropTypes'; | ||
|
||
const propTypes = { | ||
/* A function to execute when form is submitted with ENTER */ | ||
onSubmit: PropTypes.func.isRequired, | ||
|
||
/** Children to wrap with FormSubmit. */ | ||
children: PropTypes.node.isRequired, | ||
|
||
/** Container styles */ | ||
style: stylePropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
style: [], | ||
}; | ||
|
||
export {propTypes, defaultProps}; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react'; | ||
import lodashGet from 'lodash/get'; | ||
import {View} from 'react-native'; | ||
import * as formSubmitPropTypes from './formSubmitPropTypes'; | ||
|
||
// This is a wrapper component to handle the ENTER key press, and submit the form. | ||
class FormSubmit extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.submitForm = this.submitForm.bind(this); | ||
} | ||
|
||
/** | ||
* Calls the submit callback when ENTER is pressed on a form element. | ||
* @param {Object} event | ||
*/ | ||
|
||
submitForm(event) { | ||
// ENTER is pressed with modifier key, do not submit the form | ||
if (event.shiftKey || event.key !== 'Enter') { | ||
return; | ||
} | ||
|
||
const tagName = lodashGet(event, 'target.tagName', ''); | ||
|
||
// ENTER is pressed on INPUT or SELECT element, call the submit callback. | ||
if (tagName === 'INPUT' || tagName === 'SELECT') { | ||
this.props.onSubmit(); | ||
return; | ||
} | ||
|
||
// Pressing Enter on TEXTAREA element adds a new line. When `dataset.submitOnEnter` prop is passed, call the submit callback. | ||
if (tagName === 'TEXTAREA' && lodashGet(event, 'target.dataset.submitOnEnter', 'false') === 'true') { | ||
this.props.onSubmit(); | ||
return; | ||
} | ||
|
||
// ENTER is pressed on checkbox element, call the submit callback. | ||
if (lodashGet(event, 'target.role') === 'checkbox') { | ||
this.props.onSubmit(); | ||
} | ||
} | ||
|
||
render() { | ||
return ( | ||
|
||
// React-native-web prevents event bubbling on TextInput for key presses | ||
// https://github.com/necolas/react-native-web/blob/fa47f80d34ee6cde2536b2a2241e326f84b633c4/packages/react-native-web/src/exports/TextInput/index.js#L272 | ||
// Thus use capture phase. | ||
<View onKeyDownCapture={this.submitForm} style={this.props.style}>{this.props.children}</View> | ||
); | ||
} | ||
} | ||
|
||
FormSubmit.propTypes = formSubmitPropTypes.propTypes; | ||
FormSubmit.defaultProps = formSubmitPropTypes.defaultProps; | ||
|
||
export default FormSubmit; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import * as formSubmitPropTypes from './formSubmitPropTypes'; | ||
|
||
const FormSubmit = props => <View style={props.style}>{props.children}</View>; | ||
|
||
FormSubmit.propTypes = formSubmitPropTypes.propTypes; | ||
FormSubmit.defaultProps = formSubmitPropTypes.defaultProps; | ||
FormSubmit.displayName = 'FormSubmit'; | ||
|
||
export default FormSubmit; |
This file contains 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 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 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.