docstring_tokens
stringlengths
0
76.5k
code_tokens
stringlengths
75
1.81M
label_window
listlengths
4
2.12k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
borderBottomWidth: this.getTheme().borderWidth, padding: this.getTheme().listItemPadding, backgroundColor: this.getTheme().listDividerBg,
<mask> alignItems: 'center', <mask> borderColor: this.getTheme().listBorderColor <mask> }, <mask> listItemDivider: { <mask> borderBottomWidth: 1, <mask> padding: 7, <mask> backgroundColor: '#ddd', <mask> flex: 1, <mask> justifyContent: (this.buttonPresent()) ? 'space-between' : 'flex-start', <mask> flexDirection: 'row', <mask> borderColor: this.getTheme().listBorderColor <mask> }, </s> lists updated with badges and avatars </s> remove paddingRight: 10, paddingLeft: 10, </s> add </s> remove borderBottomWidth: 1, padding: 8, </s> add borderBottomWidth: this.getTheme().borderWidth, padding: this.getTheme().listItemPadding, </s> remove fontSize: 18, </s> add fontSize: 16, }, dividerItemText: { fontSize: 16, fontWeight: '500' </s> remove color: '#58575C', </s> add color: this.getTheme().listNoteColor,
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/d7b406efa97b545e0a07e645bbf904ab3de11538
Components/Widgets/ListItem.js
fontSize: 16, }, dividerItemText: { fontSize: 16, fontWeight: '500'
<mask> flexDirection: 'row', <mask> borderColor: this.getTheme().listBorderColor <mask> }, <mask> itemText: { <mask> fontSize: 18, <mask> }, <mask> itemIcon: { <mask> fontSize: 27, <mask> color: 'black' <mask> }, </s> lists updated with badges and avatars </s> remove fontSize: 27, </s> add fontSize: this.getTheme().iconFontSize, </s> remove color: '#58575C', </s> add color: this.getTheme().listNoteColor, </s> remove borderBottomWidth: 1, padding: 7, backgroundColor: '#ddd', </s> add borderBottomWidth: this.getTheme().borderWidth, padding: this.getTheme().listItemPadding, backgroundColor: this.getTheme().listDividerBg, </s> remove paddingRight: 10, paddingLeft: 10, </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/d7b406efa97b545e0a07e645bbf904ab3de11538
Components/Widgets/ListItem.js
fontSize: this.getTheme().iconFontSize,
<mask> itemText: { <mask> fontSize: 18, <mask> }, <mask> itemIcon: { <mask> fontSize: 27, <mask> color: 'black' <mask> }, <mask> itemNote: { <mask> fontSize: 15, <mask> color: '#58575C', </s> lists updated with badges and avatars </s> remove fontSize: 18, </s> add fontSize: 16, }, dividerItemText: { fontSize: 16, fontWeight: '500' </s> remove color: '#58575C', </s> add color: this.getTheme().listNoteColor, </s> remove if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText </s> add if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText </s> remove borderBottomWidth: 1, padding: 8, </s> add borderBottomWidth: this.getTheme().borderWidth, padding: this.getTheme().listItemPadding,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/d7b406efa97b545e0a07e645bbf904ab3de11538
Components/Widgets/ListItem.js
color: this.getTheme().listNoteColor,
<mask> color: 'black' <mask> }, <mask> itemNote: { <mask> fontSize: 15, <mask> color: '#58575C', <mask> alignSelf: 'center', <mask> fontWeight: '100', <mask> flex: 1, <mask> textAlign: 'right', <mask> </s> lists updated with badges and avatars </s> remove fontSize: 27, </s> add fontSize: this.getTheme().iconFontSize, </s> remove fontSize: 18, </s> add fontSize: 16, }, dividerItemText: { fontSize: 16, fontWeight: '500' </s> remove borderBottomWidth: 1, padding: 7, backgroundColor: '#ddd', </s> add borderBottomWidth: this.getTheme().borderWidth, padding: this.getTheme().listItemPadding, backgroundColor: this.getTheme().listDividerBg, </s> remove paddingRight: 10, paddingLeft: 10, </s> add </s> remove borderBottomWidth: 1, padding: 8, </s> add borderBottomWidth: this.getTheme().borderWidth, padding: this.getTheme().listItemPadding,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/d7b406efa97b545e0a07e645bbf904ab3de11538
Components/Widgets/ListItem.js
if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText
<mask> style: this.getInitialStyle().itemButton <mask> } <mask> } <mask> else if(child.type == Text) { <mask> if(child.props.note && this.thumbnailPresent()) { <mask> defaultProps = { <mask> style: this.getInitialStyle().itemSubNote <mask> } <mask> } <mask> else if(child.props.note) { <mask> defaultProps = { <mask> style: this.getInitialStyle().itemNote <mask> } <mask> } <mask> else { <mask> defaultProps = { <mask> style: this.getInitialStyle().itemText <mask> } <mask> } <mask> } <mask> else if(child.type == Icon) { <mask> defaultProps = { </s> lists updated with badges and avatars </s> remove newChildren.push(<View style={this.getRightStyle().right}> </s> add newChildren.push(<View style={ this.notePresent() ? this.getRightStyle().right : this.getRightStyle().right2 }> </s> remove listBorderColor: "#ddd" </s> add listBorderColor: "#ddd", listDividerBg: "#F5F5F5", listItemPadding: 15, listNoteColor: "#58575C", iconFontSize: 27, badgeColor: "#fff", badgeBg: "#ED1727" </s> remove fontSize: 27, </s> add fontSize: this.getTheme().iconFontSize, </s> remove fontSize: 18, </s> add fontSize: 16, }, dividerItemText: { fontSize: 16, fontWeight: '500'
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/d7b406efa97b545e0a07e645bbf904ab3de11538
Components/Widgets/ListItem.js
newChildren.push(<View style={ this.notePresent() ? this.getRightStyle().right : this.getRightStyle().right2 }>
<mask> } <mask> else { <mask> var childrenArray = React.Children.toArray(this.props.children); <mask> newChildren.push(React.cloneElement(childrenArray[0], this.getChildProps(childrenArray[0]))); <mask> newChildren.push(<View style={this.getRightStyle().right}> <mask> {childrenArray.slice(1).map((child) => { <mask> return React.cloneElement(child, this.getChildProps(child)); <mask> })} <mask> </View>); <mask> } </s> lists updated with badges and avatars </s> remove if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText </s> add if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText </s> remove borderBottomWidth: 1, padding: 8, </s> add borderBottomWidth: this.getTheme().borderWidth, padding: this.getTheme().listItemPadding, </s> remove listBorderColor: "#ddd" </s> add listBorderColor: "#ddd", listDividerBg: "#F5F5F5", listItemPadding: 15, listNoteColor: "#58575C", iconFontSize: 27, badgeColor: "#fff", badgeBg: "#ED1727"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/d7b406efa97b545e0a07e645bbf904ab3de11538
Components/Widgets/ListItem.js
import Badge from './Components/Widgets/Badge';
<mask> import Icon from './Components/Widgets/Icon'; <mask> import Thumbnail from './Components/Widgets/Thumbnail'; <mask> import Card from './Components/Widgets/Card'; <mask> <mask> module.exports = { <mask> Header: Header, <mask> Footer: Footer, <mask> Title: Title, </s> lists updated with badges and avatars </s> remove if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText </s> add if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText </s> remove Card: Card </s> add Card: Card, Badge: Badge </s> remove newChildren.push(<View style={this.getRightStyle().right}> </s> add newChildren.push(<View style={ this.notePresent() ? this.getRightStyle().right : this.getRightStyle().right2 }> </s> remove fontSize: 27, </s> add fontSize: this.getTheme().iconFontSize, </s> remove fontSize: 18, </s> add fontSize: 16, }, dividerItemText: { fontSize: 16, fontWeight: '500'
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/d7b406efa97b545e0a07e645bbf904ab3de11538
index.js
Card: Card, Badge: Badge
<mask> View: View, <mask> InputGroup: InputGroup, <mask> Icon: Icon, <mask> Thumbnail: Thumbnail, <mask> Card: Card <mask> }; </s> lists updated with badges and avatars </s> remove newChildren.push(<View style={this.getRightStyle().right}> </s> add newChildren.push(<View style={ this.notePresent() ? this.getRightStyle().right : this.getRightStyle().right2 }> </s> remove if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText </s> add if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText </s> remove color: '#58575C', </s> add color: this.getTheme().listNoteColor, </s> remove fontSize: 27, </s> add fontSize: this.getTheme().iconFontSize,
[ "keep", "keep", "keep", "keep", "replace", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/d7b406efa97b545e0a07e645bbf904ab3de11538
index.js
import { Box, IBoxProps } from '../components/primitives';
<mask> import React from 'react'; <mask> import { Box } from '../components/primitives'; <mask> import OverlayProvider from './Overlay/OverlayProvider'; <mask> import { useColorModeValue } from '../color-mode'; <mask> <mask> const NativeBaseWrapper = ({ children, ...props }: any) => { <mask> return ( </s> fix: added safeareaview to wrapper </s> remove const NativeBaseWrapper = ({ children, ...props }: any) => { return ( </s> add type INativeBaseWrapperProps = IBoxProps & { disableSafeArea?: boolean; }; const NativeBaseWrapper = ({ children, disableSafeArea, ...props }: INativeBaseWrapperProps) => { const styles = StyleSheet.create({ container: { flex: 1, }, }); const defaultView = ( </s> remove <Box style={{ zIndex: 999999 }} w="100%"> </s> add <Box w="100%" h="100%" zIndex={999999}> </s> remove zIndex: 99999, </s> add zIndex: 999,
[ "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/d7f4cc216dbcefe1c373eca0cff8cc78a8cb9778
src/core/NativeBaseWrapper.tsx
import { SafeAreaView, StyleSheet } from 'react-native';
<mask> import { Box, IBoxProps } from '../components/primitives'; <mask> import OverlayProvider from './Overlay/OverlayProvider'; <mask> import { useColorModeValue } from '../color-mode'; <mask> <mask> type INativeBaseWrapperProps = IBoxProps & { <mask> disableSafeArea?: boolean; <mask> }; <mask> <mask> const NativeBaseWrapper = ({ </s> fix: added safeareaview to wrapper </s> remove const NativeBaseWrapper = ({ children, ...props }: any) => { return ( </s> add type INativeBaseWrapperProps = IBoxProps & { disableSafeArea?: boolean; }; const NativeBaseWrapper = ({ children, disableSafeArea, ...props }: INativeBaseWrapperProps) => { const styles = StyleSheet.create({ container: { flex: 1, }, }); const defaultView = ( </s> remove import { Box } from '../components/primitives'; </s> add import { Box, IBoxProps } from '../components/primitives'; </s> remove <Box style={{ zIndex: 999999 }} w="100%"> </s> add <Box w="100%" h="100%" zIndex={999999}> </s> remove zIndex: 99999, </s> add zIndex: 999,
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/d7f4cc216dbcefe1c373eca0cff8cc78a8cb9778
src/core/NativeBaseWrapper.tsx
type INativeBaseWrapperProps = IBoxProps & { disableSafeArea?: boolean; }; const NativeBaseWrapper = ({ children, disableSafeArea, ...props }: INativeBaseWrapperProps) => { const styles = StyleSheet.create({ container: { flex: 1, }, }); const defaultView = (
<mask> import { Box } from '../components/primitives'; <mask> import OverlayProvider from './Overlay/OverlayProvider'; <mask> import { useColorModeValue } from '../color-mode'; <mask> <mask> const NativeBaseWrapper = ({ children, ...props }: any) => { <mask> return ( <mask> <Box <mask> flex={1} <mask> height="100%" <mask> width="100%" <mask> justifyContent="center" </s> fix: added safeareaview to wrapper </s> remove import { Box } from '../components/primitives'; </s> add import { Box, IBoxProps } from '../components/primitives'; </s> remove <Box style={{ zIndex: 999999 }} w="100%"> </s> add <Box w="100%" h="100%" zIndex={999999}> </s> remove zIndex: 99999, </s> add zIndex: 999,
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/d7f4cc216dbcefe1c373eca0cff8cc78a8cb9778
src/core/NativeBaseWrapper.tsx
return disableSafeArea ? ( defaultView ) : ( <SafeAreaView style={styles.container}>{defaultView}</SafeAreaView> );
<mask> > <mask> <OverlayProvider>{children}</OverlayProvider> <mask> </Box> <mask> ); <mask> }; <mask> <mask> export default NativeBaseWrapper; </s> fix: added safeareaview to wrapper </s> remove <Box style={{ zIndex: 999999 }} w="100%"> </s> add <Box w="100%" h="100%" zIndex={999999}> </s> remove zIndex: 99999, </s> add zIndex: 999, </s> remove const NativeBaseWrapper = ({ children, ...props }: any) => { return ( </s> add type INativeBaseWrapperProps = IBoxProps & { disableSafeArea?: boolean; }; const NativeBaseWrapper = ({ children, disableSafeArea, ...props }: INativeBaseWrapperProps) => { const styles = StyleSheet.create({ container: { flex: 1, }, }); const defaultView = ( </s> remove import { Box } from '../components/primitives'; </s> add import { Box, IBoxProps } from '../components/primitives';
[ "keep", "keep", "keep", "add", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/d7f4cc216dbcefe1c373eca0cff8cc78a8cb9778
src/core/NativeBaseWrapper.tsx
zIndex: 999,
<mask> top: 0, <mask> bottom: 0, <mask> right: 0, <mask> left: 0, <mask> zIndex: 99999, <mask> alignItems: 'center', <mask> opacity: 0.5, <mask> <mask> // backgroundColor: config.disableOverlay <mask> // ? 'transparent' </s> fix: added safeareaview to wrapper </s> remove <Box style={{ zIndex: 999999 }} w="100%"> </s> add <Box w="100%" h="100%" zIndex={999999}> </s> remove const NativeBaseWrapper = ({ children, ...props }: any) => { return ( </s> add type INativeBaseWrapperProps = IBoxProps & { disableSafeArea?: boolean; }; const NativeBaseWrapper = ({ children, disableSafeArea, ...props }: INativeBaseWrapperProps) => { const styles = StyleSheet.create({ container: { flex: 1, }, }); const defaultView = ( </s> remove import { Box } from '../components/primitives'; </s> add import { Box, IBoxProps } from '../components/primitives';
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/d7f4cc216dbcefe1c373eca0cff8cc78a8cb9778
src/core/Overlay/OverlayProvider.tsx
<Box w="100%" h="100%" zIndex={999999}>
<mask> nativeID="toast-provider" <mask> style={[providerStyle.provider, { opacity: fadeValue }]} <mask> pointerEvents={pointerEventsSetter()} <mask> > <mask> <Box style={{ zIndex: 999999 }} w="100%"> <mask> {overlayItem} <mask> </Box> <mask> <Box <mask> bg={ <mask> config.disableOverlay </s> fix: added safeareaview to wrapper </s> remove zIndex: 99999, </s> add zIndex: 999, </s> remove const NativeBaseWrapper = ({ children, ...props }: any) => { return ( </s> add type INativeBaseWrapperProps = IBoxProps & { disableSafeArea?: boolean; }; const NativeBaseWrapper = ({ children, disableSafeArea, ...props }: INativeBaseWrapperProps) => { const styles = StyleSheet.create({ container: { flex: 1, }, }); const defaultView = ( </s> remove import { Box } from '../components/primitives'; </s> add import { Box, IBoxProps } from '../components/primitives';
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/d7f4cc216dbcefe1c373eca0cff8cc78a8cb9778
src/core/Overlay/OverlayProvider.tsx
import ViewNB from './../View'; import Header from './../Header'; import Content from './../Content'; import Footer from './../Footer'; import Fab from './../Fab'; import NativeBaseComponent from '../../Base/NativeBaseComponent';
<mask> 'use strict'; <mask> <mask> import React from 'react'; <mask> import {View, Image, ScrollView} from 'react-native'; <mask> import ViewNB from './View'; <mask> import Header from './Header'; <mask> import Content from './Content'; <mask> import Footer from './Footer'; <mask> import NativeBaseComponent from '../Base/NativeBaseComponent'; <mask> import _ from 'lodash'; <mask> import computeProps from '../../Utils/computeProps'; <mask> <mask> export default class Container extends NativeBaseComponent { <mask> </s> Deletes the assets from Merge request #218 </s> remove import computeProps from '../../Utils/computeProps'; </s> add import computeProps from '../../../Utils/computeProps'; </s> remove renderOther(){ if(Array.isArray(this.props.children)) { return _.filter(this.props.children, function(item) { if(item && (item.type != Header && item.type != ViewNB && item.type != Content && item.type != Image && item.type != View && item.type != ScrollView && item.type != Footer)) { return true; } }); } else { if(this.props.children && (this.props.children.type != Header && this.props.children.type != Content && this.props.children.type != ViewNB && this.props.children.type != View && this.props.children.type != Image && this.props.children.type != ScrollView && this.props.children.type != Footer)) { return this.props.children; } } } </s> add </s> remove if(item && (item.type == ViewNB || item.type == Content || item.type == Image || item.type == View || item.type == ScrollView )) { </s> add if(item && (_.get(item, 'type', null) == ViewNB || _.get(item, 'type', null) == Content || _.get(item, 'type', null) == Image || _.get(item, 'type', null) == View || _.get(item, 'type', null) == ScrollView || _.get(item, 'type', null) == Fab )) { </s> remove if(item && item.type == Header) { </s> add if(item && _.get(item, 'type', null) == Header) { </s> remove if(item && item.type == Footer) { </s> add if(item && _.get(item, 'type', null) == Footer) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/da39a45ae142d62d9d0a125e4c3fedb1de6ad369
Components/Widgets/Container/index.js
import computeProps from '../../../Utils/computeProps';
<mask> import Content from './Content'; <mask> import Footer from './Footer'; <mask> import NativeBaseComponent from '../Base/NativeBaseComponent'; <mask> import _ from 'lodash'; <mask> import computeProps from '../../Utils/computeProps'; <mask> <mask> export default class Container extends NativeBaseComponent { <mask> <mask> propTypes: { <mask> style : React.PropTypes.object </s> Deletes the assets from Merge request #218 </s> remove import ViewNB from './View'; import Header from './Header'; import Content from './Content'; import Footer from './Footer'; import NativeBaseComponent from '../Base/NativeBaseComponent'; </s> add import ViewNB from './../View'; import Header from './../Header'; import Content from './../Content'; import Footer from './../Footer'; import Fab from './../Fab'; import NativeBaseComponent from '../../Base/NativeBaseComponent'; </s> remove renderOther(){ if(Array.isArray(this.props.children)) { return _.filter(this.props.children, function(item) { if(item && (item.type != Header && item.type != ViewNB && item.type != Content && item.type != Image && item.type != View && item.type != ScrollView && item.type != Footer)) { return true; } }); } else { if(this.props.children && (this.props.children.type != Header && this.props.children.type != Content && this.props.children.type != ViewNB && this.props.children.type != View && this.props.children.type != Image && this.props.children.type != ScrollView && this.props.children.type != Footer)) { return this.props.children; } } } </s> add </s> remove if(item && (item.type == ViewNB || item.type == Content || item.type == Image || item.type == View || item.type == ScrollView )) { </s> add if(item && (_.get(item, 'type', null) == ViewNB || _.get(item, 'type', null) == Content || _.get(item, 'type', null) == Image || _.get(item, 'type', null) == View || _.get(item, 'type', null) == ScrollView || _.get(item, 'type', null) == Fab )) { </s> remove if(item && item.type == Header) { </s> add if(item && _.get(item, 'type', null) == Header) { </s> remove if(item && item.type == Footer) { </s> add if(item && _.get(item, 'type', null) == Footer) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/da39a45ae142d62d9d0a125e4c3fedb1de6ad369
Components/Widgets/Container/index.js
<mask> <mask> propTypes: { <mask> style : React.PropTypes.object <mask> } <mask> <mask> renderOther(){ <mask> if(Array.isArray(this.props.children)) { <mask> <mask> return _.filter(this.props.children, function(item) { <mask> if(item && (item.type != Header && item.type != ViewNB && item.type != Content && item.type != Image && item.type != View && item.type != ScrollView && item.type != Footer)) { <mask> return true; <mask> } <mask> }); <mask> } <mask> <mask> else { <mask> if(this.props.children && (this.props.children.type != Header && this.props.children.type != Content && this.props.children.type != ViewNB && this.props.children.type != View && this.props.children.type != Image && this.props.children.type != ScrollView && this.props.children.type != Footer)) { <mask> return this.props.children; <mask> } <mask> } <mask> } <mask> <mask> renderHeader() { <mask> if(Array.isArray(this.props.children)) { <mask> return _.find(this.props.children, function(item) { <mask> if(item && item.type == Header) { </s> Deletes the assets from Merge request #218 </s> remove if(item && (item.type == ViewNB || item.type == Content || item.type == Image || item.type == View || item.type == ScrollView )) { </s> add if(item && (_.get(item, 'type', null) == ViewNB || _.get(item, 'type', null) == Content || _.get(item, 'type', null) == Image || _.get(item, 'type', null) == View || _.get(item, 'type', null) == ScrollView || _.get(item, 'type', null) == Fab )) { </s> remove if(this.props.children && this.props.children.type == Header) { </s> add if(this.props.children && _.get(this.props.children, 'type', null) == Header) { </s> remove if(item && item.type == Header) { </s> add if(item && _.get(item, 'type', null) == Header) { </s> remove if(item && item.type == Footer) { </s> add if(item && _.get(item, 'type', null) == Footer) { </s> remove import computeProps from '../../Utils/computeProps'; </s> add import computeProps from '../../../Utils/computeProps';
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/da39a45ae142d62d9d0a125e4c3fedb1de6ad369
Components/Widgets/Container/index.js
if(item && _.get(item, 'type', null) == Header) {
<mask> <mask> renderHeader() { <mask> if(Array.isArray(this.props.children)) { <mask> return _.find(this.props.children, function(item) { <mask> if(item && item.type == Header) { <mask> return true; <mask> } <mask> }); <mask> } <mask> </s> Deletes the assets from Merge request #218 </s> remove if(item && item.type == Footer) { </s> add if(item && _.get(item, 'type', null) == Footer) { </s> remove renderOther(){ if(Array.isArray(this.props.children)) { return _.filter(this.props.children, function(item) { if(item && (item.type != Header && item.type != ViewNB && item.type != Content && item.type != Image && item.type != View && item.type != ScrollView && item.type != Footer)) { return true; } }); } else { if(this.props.children && (this.props.children.type != Header && this.props.children.type != Content && this.props.children.type != ViewNB && this.props.children.type != View && this.props.children.type != Image && this.props.children.type != ScrollView && this.props.children.type != Footer)) { return this.props.children; } } } </s> add </s> remove if(this.props.children && this.props.children.type == Header) { </s> add if(this.props.children && _.get(this.props.children, 'type', null) == Header) { </s> remove if(item && (item.type == ViewNB || item.type == Content || item.type == Image || item.type == View || item.type == ScrollView )) { </s> add if(item && (_.get(item, 'type', null) == ViewNB || _.get(item, 'type', null) == Content || _.get(item, 'type', null) == Image || _.get(item, 'type', null) == View || _.get(item, 'type', null) == ScrollView || _.get(item, 'type', null) == Fab )) { </s> remove <View {...this.prepareRootProps()}> </s> add <View ref={c => this._root = c} {...this.prepareRootProps()}>
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/da39a45ae142d62d9d0a125e4c3fedb1de6ad369
Components/Widgets/Container/index.js
if(this.props.children && _.get(this.props.children, 'type', null) == Header) {
<mask> }); <mask> } <mask> <mask> else { <mask> if(this.props.children && this.props.children.type == Header) { <mask> return this.props.children; <mask> } <mask> } <mask> } <mask> renderContent() { </s> Deletes the assets from Merge request #218 </s> remove renderOther(){ if(Array.isArray(this.props.children)) { return _.filter(this.props.children, function(item) { if(item && (item.type != Header && item.type != ViewNB && item.type != Content && item.type != Image && item.type != View && item.type != ScrollView && item.type != Footer)) { return true; } }); } else { if(this.props.children && (this.props.children.type != Header && this.props.children.type != Content && this.props.children.type != ViewNB && this.props.children.type != View && this.props.children.type != Image && this.props.children.type != ScrollView && this.props.children.type != Footer)) { return this.props.children; } } } </s> add </s> remove if(item && item.type == Header) { </s> add if(item && _.get(item, 'type', null) == Header) { </s> remove if(item && item.type == Footer) { </s> add if(item && _.get(item, 'type', null) == Footer) { </s> remove if(item && (item.type == ViewNB || item.type == Content || item.type == Image || item.type == View || item.type == ScrollView )) { </s> add if(item && (_.get(item, 'type', null) == ViewNB || _.get(item, 'type', null) == Content || _.get(item, 'type', null) == Image || _.get(item, 'type', null) == View || _.get(item, 'type', null) == ScrollView || _.get(item, 'type', null) == Fab )) { </s> remove <View {...this.prepareRootProps()}> </s> add <View ref={c => this._root = c} {...this.prepareRootProps()}>
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/da39a45ae142d62d9d0a125e4c3fedb1de6ad369
Components/Widgets/Container/index.js
if(item && (_.get(item, 'type', null) == ViewNB || _.get(item, 'type', null) == Content || _.get(item, 'type', null) == Image || _.get(item, 'type', null) == View || _.get(item, 'type', null) == ScrollView || _.get(item, 'type', null) == Fab )) {
<mask> renderContent() { <mask> if(Array.isArray(this.props.children)) { <mask> <mask> return _.filter(this.props.children, function(item) { <mask> if(item && (item.type == ViewNB || item.type == Content || item.type == Image || item.type == View || item.type == ScrollView )) { <mask> <mask> return true; <mask> } <mask> }); <mask> } </s> Deletes the assets from Merge request #218 </s> remove renderOther(){ if(Array.isArray(this.props.children)) { return _.filter(this.props.children, function(item) { if(item && (item.type != Header && item.type != ViewNB && item.type != Content && item.type != Image && item.type != View && item.type != ScrollView && item.type != Footer)) { return true; } }); } else { if(this.props.children && (this.props.children.type != Header && this.props.children.type != Content && this.props.children.type != ViewNB && this.props.children.type != View && this.props.children.type != Image && this.props.children.type != ScrollView && this.props.children.type != Footer)) { return this.props.children; } } } </s> add </s> remove if(item && item.type == Footer) { </s> add if(item && _.get(item, 'type', null) == Footer) { </s> remove if(item && item.type == Header) { </s> add if(item && _.get(item, 'type', null) == Header) { </s> remove if(this.props.children && this.props.children.type == Header) { </s> add if(this.props.children && _.get(this.props.children, 'type', null) == Header) { </s> remove <View {...this.prepareRootProps()}> </s> add <View ref={c => this._root = c} {...this.prepareRootProps()}>
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/da39a45ae142d62d9d0a125e4c3fedb1de6ad369
Components/Widgets/Container/index.js
if(item && _.get(item, 'type', null) == Footer) {
<mask> } <mask> renderFooter() { <mask> if(Array.isArray(this.props.children)) { <mask> return _.find(this.props.children, function(item) { <mask> if(item && item.type == Footer) { <mask> return true; <mask> } <mask> }); <mask> } <mask> </s> Deletes the assets from Merge request #218 </s> remove if(item && item.type == Header) { </s> add if(item && _.get(item, 'type', null) == Header) { </s> remove renderOther(){ if(Array.isArray(this.props.children)) { return _.filter(this.props.children, function(item) { if(item && (item.type != Header && item.type != ViewNB && item.type != Content && item.type != Image && item.type != View && item.type != ScrollView && item.type != Footer)) { return true; } }); } else { if(this.props.children && (this.props.children.type != Header && this.props.children.type != Content && this.props.children.type != ViewNB && this.props.children.type != View && this.props.children.type != Image && this.props.children.type != ScrollView && this.props.children.type != Footer)) { return this.props.children; } } } </s> add </s> remove if(item && (item.type == ViewNB || item.type == Content || item.type == Image || item.type == View || item.type == ScrollView )) { </s> add if(item && (_.get(item, 'type', null) == ViewNB || _.get(item, 'type', null) == Content || _.get(item, 'type', null) == Image || _.get(item, 'type', null) == View || _.get(item, 'type', null) == ScrollView || _.get(item, 'type', null) == Fab )) { </s> remove if(this.props.children && this.props.children.type == Header) { </s> add if(this.props.children && _.get(this.props.children, 'type', null) == Header) { </s> remove <View {...this.prepareRootProps()}> </s> add <View ref={c => this._root = c} {...this.prepareRootProps()}>
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/da39a45ae142d62d9d0a125e4c3fedb1de6ad369
Components/Widgets/Container/index.js
<View ref={c => this._root = c} {...this.prepareRootProps()}>
<mask> return computeProps(this.props, defaultProps); <mask> } <mask> render() { <mask> return( <mask> <View {...this.prepareRootProps()}> <mask> <mask> {this.renderHeader()} <mask> <mask> {this.renderContent()} <mask> </s> Deletes the assets from Merge request #218 </s> remove {this.props.allowExtraContent == true ? this.renderOther() : null} </s> add </s> remove if(item && item.type == Footer) { </s> add if(item && _.get(item, 'type', null) == Footer) { </s> remove if(item && item.type == Header) { </s> add if(item && _.get(item, 'type', null) == Header) { </s> remove if(this.props.children && this.props.children.type == Header) { </s> add if(this.props.children && _.get(this.props.children, 'type', null) == Header) { </s> remove renderOther(){ if(Array.isArray(this.props.children)) { return _.filter(this.props.children, function(item) { if(item && (item.type != Header && item.type != ViewNB && item.type != Content && item.type != Image && item.type != View && item.type != ScrollView && item.type != Footer)) { return true; } }); } else { if(this.props.children && (this.props.children.type != Header && this.props.children.type != Content && this.props.children.type != ViewNB && this.props.children.type != View && this.props.children.type != Image && this.props.children.type != ScrollView && this.props.children.type != Footer)) { return this.props.children; } } } </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/da39a45ae142d62d9d0a125e4c3fedb1de6ad369
Components/Widgets/Container/index.js
<mask> {this.renderContent()} <mask> <mask> {this.renderFooter()} <mask> <mask> {this.props.allowExtraContent == true ? this.renderOther() : null} <mask> </View> <mask> ); <mask> <mask> } <mask> </s> Deletes the assets from Merge request #218 </s> remove } </s> add </s> remove <View {...this.prepareRootProps()}> </s> add <View ref={c => this._root = c} {...this.prepareRootProps()}> </s> remove renderOther(){ if(Array.isArray(this.props.children)) { return _.filter(this.props.children, function(item) { if(item && (item.type != Header && item.type != ViewNB && item.type != Content && item.type != Image && item.type != View && item.type != ScrollView && item.type != Footer)) { return true; } }); } else { if(this.props.children && (this.props.children.type != Header && this.props.children.type != Content && this.props.children.type != ViewNB && this.props.children.type != View && this.props.children.type != Image && this.props.children.type != ScrollView && this.props.children.type != Footer)) { return this.props.children; } } } </s> add </s> remove if(this.props.children && this.props.children.type == Header) { </s> add if(this.props.children && _.get(this.props.children, 'type', null) == Header) { </s> remove if(item && item.type == Footer) { </s> add if(item && _.get(item, 'type', null) == Footer) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/da39a45ae142d62d9d0a125e4c3fedb1de6ad369
Components/Widgets/Container/index.js
<mask> ); <mask> <mask> } <mask> <mask> } </s> Deletes the assets from Merge request #218 </s> remove {this.props.allowExtraContent == true ? this.renderOther() : null} </s> add </s> remove if(this.props.children && this.props.children.type == Header) { </s> add if(this.props.children && _.get(this.props.children, 'type', null) == Header) { </s> remove if(item && item.type == Footer) { </s> add if(item && _.get(item, 'type', null) == Footer) { </s> remove renderOther(){ if(Array.isArray(this.props.children)) { return _.filter(this.props.children, function(item) { if(item && (item.type != Header && item.type != ViewNB && item.type != Content && item.type != Image && item.type != View && item.type != ScrollView && item.type != Footer)) { return true; } }); } else { if(this.props.children && (this.props.children.type != Header && this.props.children.type != Content && this.props.children.type != ViewNB && this.props.children.type != View && this.props.children.type != Image && this.props.children.type != ScrollView && this.props.children.type != Footer)) { return this.props.children; } } } </s> add
[ "keep", "keep", "keep", "keep", "replace" ]
https://github.com/GeekyAnts/NativeBase/commit/da39a45ae142d62d9d0a125e4c3fedb1de6ad369
Components/Widgets/Container/index.js
}
<mask> <mask> } <mask> <mask> } </s> Deletes the assets from Merge request #218 </s> remove } </s> add </s> remove if(this.props.children && this.props.children.type == Header) { </s> add if(this.props.children && _.get(this.props.children, 'type', null) == Header) { </s> remove if(item && item.type == Footer) { </s> add if(item && _.get(item, 'type', null) == Footer) { </s> remove renderOther(){ if(Array.isArray(this.props.children)) { return _.filter(this.props.children, function(item) { if(item && (item.type != Header && item.type != ViewNB && item.type != Content && item.type != Image && item.type != View && item.type != ScrollView && item.type != Footer)) { return true; } }); } else { if(this.props.children && (this.props.children.type != Header && this.props.children.type != Content && this.props.children.type != ViewNB && this.props.children.type != View && this.props.children.type != Image && this.props.children.type != ScrollView && this.props.children.type != Footer)) { return this.props.children; } } } </s> add </s> remove if(item && item.type == Header) { </s> add if(item && _.get(item, 'type', null) == Header) {
[ "keep", "keep", "keep", "add" ]
https://github.com/GeekyAnts/NativeBase/commit/da39a45ae142d62d9d0a125e4c3fedb1de6ad369
Components/Widgets/Container/index.js
hoverProps: {
<mask> <mask> const useHover = () => { <mask> const [isHovered, setHovered] = React.useState(false); <mask> return { <mask> pressableProps: { <mask> onHoverIn: () => setHovered(true), <mask> onHoverOut: () => setHovered(false), <mask> }, <mask> isHovered, <mask> }; </s> feat: pseudo props combination, simplification and resolution </s> remove const { _hover, _pressed, _focus, _focusVisible, _disabled, ...themeProps } = usePropsResolution('Pressable', props); </s> add </s> remove const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); </s> add const { hoverProps, isHovered } = useHover(); const { pressableProps, isPressed } = useIsPressed(); </s> remove // Shallow merge defaultProps and incoming props to pass them in baseStyle, variants and sizes const combinedProps: any = { ...componentTheme.defaultProps, ...incomingProps, }; </s> add const componentTheme = get(theme, `components.${component}`, {}); const windowWidth = useWindowDimensions()?.width; const currentBreakpoint = React.useMemo( () => getClosestBreakpoint(theme.breakpoints, windowWidth), [windowWidth, theme.breakpoints] ); // STEP 1: combine default props and incoming props const incomingWithDefaultProps = merge( {}, componentTheme.defaultProps || {}, cleanIncomingProps ); // STEP 2: flatten them pseudoPropsResolver({ props: incomingWithDefaultProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); // STEP 3: Pass it to baseStyle, then variant and then size and resolve them. </s> remove componentThemeIntegratedProps[ bgProp ].linearGradient.colors = componentThemeIntegratedProps[ </s> add flattenProps[bgProp].linearGradient.colors = flattenProps[ </s> remove import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; import { useNativeBaseConfig } from '../../core/NativeBaseContext'; </s> add // TODO: have to remove as many ts-ignore as possible. const platformPropsMap = ['_ios', '_android', '_web']; const colorModePropsMap = ['_light', '_dark']; const statePropsMap = [ '_invalid', '_disabled', '_checked', '_hover', '_pressed', '_focused', ]; const pseudoPropsMap = { _web: 'web', _ios: 'ios', _android: 'android', _light: 'light', _dark: 'dark', // TODO: have to add more interactionProps and stateProps _hover: 'isHovered', _pressed: 'isPressed', _focused: 'isFocused', _disabled: 'isDisabled', _invalid: 'isInvalid', _indeterminate: 'isIndeterminate', }; const shouldResolve = ({ property, state, platform, colormode }: any) => { if (platformPropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === platform; } else if (colorModePropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === colormode; } else if (statePropsMap.includes(property)) { // @ts-ignore return state[pseudoPropsMap[property]]; } else { return false; } }; let flattenProps: any = {}; let propertyDepth: any = {}; const pseudoPropsResolver = ({ props, platform, colormode, state, currentDepth = 0, }: any) => { for (const property in props) { // @ts-ignore if (pseudoPropsMap[property]) { if (shouldResolve({ property: property, state, platform, colormode })) { pseudoPropsResolver({ props: props[property], platform, colormode, state, currentDepth: currentDepth++, }); } } else if (!property.startsWith('_')) { if ( !(propertyDepth[property] && propertyDepth[property] > currentDepth) ) { propertyDepth[property] = currentDepth; flattenProps[property] = props[property]; } } } return flattenProps; };
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/components/primitives/Pressable/Pressable.tsx
const { hoverProps, isHovered } = useHover(); const { pressableProps, isPressed } = useIsPressed();
<mask> ...props <mask> }: IPressableProps, <mask> ref: any <mask> ) => { <mask> const { pressableProps, isHovered } = useHover(); <mask> const { pressableProps: isPressedProps, isPressed } = useIsPressed(); <mask> const { focusProps, isFocused } = useFocus(); <mask> const { <mask> _hover, <mask> _pressed, <mask> _focus, </s> feat: pseudo props combination, simplification and resolution </s> remove const { _hover, _pressed, _focus, _focusVisible, _disabled, ...themeProps } = usePropsResolution('Pressable', props); </s> add </s> remove import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; import { useNativeBaseConfig } from '../../core/NativeBaseContext'; </s> add // TODO: have to remove as many ts-ignore as possible. const platformPropsMap = ['_ios', '_android', '_web']; const colorModePropsMap = ['_light', '_dark']; const statePropsMap = [ '_invalid', '_disabled', '_checked', '_hover', '_pressed', '_focused', ]; const pseudoPropsMap = { _web: 'web', _ios: 'ios', _android: 'android', _light: 'light', _dark: 'dark', // TODO: have to add more interactionProps and stateProps _hover: 'isHovered', _pressed: 'isPressed', _focused: 'isFocused', _disabled: 'isDisabled', _invalid: 'isInvalid', _indeterminate: 'isIndeterminate', }; const shouldResolve = ({ property, state, platform, colormode }: any) => { if (platformPropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === platform; } else if (colorModePropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === colormode; } else if (statePropsMap.includes(property)) { // @ts-ignore return state[pseudoPropsMap[property]]; } else { return false; } }; let flattenProps: any = {}; let propertyDepth: any = {}; const pseudoPropsResolver = ({ props, platform, colormode, state, currentDepth = 0, }: any) => { for (const property in props) { // @ts-ignore if (pseudoPropsMap[property]) { if (shouldResolve({ property: property, state, platform, colormode })) { pseudoPropsResolver({ props: props[property], platform, colormode, state, currentDepth: currentDepth++, }); } } else if (!property.startsWith('_')) { if ( !(propertyDepth[property] && propertyDepth[property] > currentDepth) ) { propertyDepth[property] = currentDepth; flattenProps[property] = props[property]; } } } return flattenProps; }; </s> remove pressableProps: { </s> add hoverProps: { </s> remove } else if (componentThemeIntegratedProps.bgColor?.linearGradient) { </s> add } else if (flattenProps.bgColor?.linearGradient) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/components/primitives/Pressable/Pressable.tsx
<mask> ) => { <mask> const { pressableProps, isHovered } = useHover(); <mask> const { pressableProps: isPressedProps, isPressed } = useIsPressed(); <mask> const { focusProps, isFocused } = useFocus(); <mask> const { <mask> _hover, <mask> _pressed, <mask> _focus, <mask> _focusVisible, <mask> _disabled, <mask> ...themeProps <mask> } = usePropsResolution('Pressable', props); <mask> const { isFocusVisible, focusProps: focusRingProps }: any = useFocusRing(); <mask> // TODO : Replace Render props with Context Hook <mask> return ( <mask> <StyledPressable <mask> ref={ref} </s> feat: pseudo props combination, simplification and resolution </s> remove const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); </s> add const { hoverProps, isHovered } = useHover(); const { pressableProps, isPressed } = useIsPressed(); </s> remove onPressIn={composeEventHandlers(onPressIn, isPressedProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} </s> add onPressIn={composeEventHandlers(onPressIn, pressableProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, pressableProps.onPressOut)} </s> remove import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; import { useNativeBaseConfig } from '../../core/NativeBaseContext'; </s> add // TODO: have to remove as many ts-ignore as possible. const platformPropsMap = ['_ios', '_android', '_web']; const colorModePropsMap = ['_light', '_dark']; const statePropsMap = [ '_invalid', '_disabled', '_checked', '_hover', '_pressed', '_focused', ]; const pseudoPropsMap = { _web: 'web', _ios: 'ios', _android: 'android', _light: 'light', _dark: 'dark', // TODO: have to add more interactionProps and stateProps _hover: 'isHovered', _pressed: 'isPressed', _focused: 'isFocused', _disabled: 'isDisabled', _invalid: 'isInvalid', _indeterminate: 'isIndeterminate', }; const shouldResolve = ({ property, state, platform, colormode }: any) => { if (platformPropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === platform; } else if (colorModePropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === colormode; } else if (statePropsMap.includes(property)) { // @ts-ignore return state[pseudoPropsMap[property]]; } else { return false; } }; let flattenProps: any = {}; let propertyDepth: any = {}; const pseudoPropsResolver = ({ props, platform, colormode, state, currentDepth = 0, }: any) => { for (const property in props) { // @ts-ignore if (pseudoPropsMap[property]) { if (shouldResolve({ property: property, state, platform, colormode })) { pseudoPropsResolver({ props: props[property], platform, colormode, state, currentDepth: currentDepth++, }); } } else if (!property.startsWith('_')) { if ( !(propertyDepth[property] && propertyDepth[property] > currentDepth) ) { propertyDepth[property] = currentDepth; flattenProps[property] = props[property]; } } } return flattenProps; }; </s> remove pressableProps: { </s> add hoverProps: {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/components/primitives/Pressable/Pressable.tsx
const { ...resolvedProps } = usePropsResolution('Pressable', props, { isHovered, isPressed, isFocused, isFocusVisible, });
<mask> const { hoverProps, isHovered } = useHover(); <mask> const { pressableProps, isPressed } = useIsPressed(); <mask> const { focusProps, isFocused } = useFocus(); <mask> const { isFocusVisible, focusProps: focusRingProps }: any = useFocusRing(); <mask> // TODO : Replace Render props with Context Hook <mask> return ( <mask> <StyledPressable <mask> ref={ref} <mask> onPressIn={composeEventHandlers(onPressIn, pressableProps.onPressIn)} <mask> onPressOut={composeEventHandlers(onPressOut, pressableProps.onPressOut)} </s> feat: pseudo props combination, simplification and resolution </s> remove const { _hover, _pressed, _focus, _focusVisible, _disabled, ...themeProps } = usePropsResolution('Pressable', props); </s> add </s> remove const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); </s> add const { hoverProps, isHovered } = useHover(); const { pressableProps, isPressed } = useIsPressed(); </s> remove onPressIn={composeEventHandlers(onPressIn, isPressedProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} </s> add onPressIn={composeEventHandlers(onPressIn, pressableProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, pressableProps.onPressOut)} </s> remove import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; import { useNativeBaseConfig } from '../../core/NativeBaseContext'; </s> add // TODO: have to remove as many ts-ignore as possible. const platformPropsMap = ['_ios', '_android', '_web']; const colorModePropsMap = ['_light', '_dark']; const statePropsMap = [ '_invalid', '_disabled', '_checked', '_hover', '_pressed', '_focused', ]; const pseudoPropsMap = { _web: 'web', _ios: 'ios', _android: 'android', _light: 'light', _dark: 'dark', // TODO: have to add more interactionProps and stateProps _hover: 'isHovered', _pressed: 'isPressed', _focused: 'isFocused', _disabled: 'isDisabled', _invalid: 'isInvalid', _indeterminate: 'isIndeterminate', }; const shouldResolve = ({ property, state, platform, colormode }: any) => { if (platformPropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === platform; } else if (colorModePropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === colormode; } else if (statePropsMap.includes(property)) { // @ts-ignore return state[pseudoPropsMap[property]]; } else { return false; } }; let flattenProps: any = {}; let propertyDepth: any = {}; const pseudoPropsResolver = ({ props, platform, colormode, state, currentDepth = 0, }: any) => { for (const property in props) { // @ts-ignore if (pseudoPropsMap[property]) { if (shouldResolve({ property: property, state, platform, colormode })) { pseudoPropsResolver({ props: props[property], platform, colormode, state, currentDepth: currentDepth++, }); } } else if (!property.startsWith('_')) { if ( !(propertyDepth[property] && propertyDepth[property] > currentDepth) ) { propertyDepth[property] = currentDepth; flattenProps[property] = props[property]; } } } return flattenProps; }; </s> remove const componentMergedTheme = merge( {}, componentTheme.defaultProps, componentBaseStyle, componentVariantProps, componentSizeProps ); if (sizeResolved) { // We remove size from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.size; } if (hasVariant) { // We remove variant from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.variant; } const componentThemeIntegratedProps = merge( {}, useColorModeProps(usePlatformProps(componentMergedTheme)), useColorModeProps(usePlatformProps(incomingProps)) ); return componentThemeIntegratedProps; }; /** * @summary Translates the prop with it's appropriate value. * @description NOTE: Avoid passo JSX and functions. * @arg {any} props - Props object with should be translated. * @arg {any} theme - Theme based on which props will be translated. * @arg {object} colorModeProps - `colorMode` object. * @arg {object} componentTheme - Theme for specific components. * @arg {object} windowWidth - Current width of the window / screen. * @returns {object} Translated props object. */ // Todo - move responsive calculation in styled system const propTranslator = ({ props, theme, colorModeProps, componentTheme, currentBreakpoint, }: { props: any; theme: any; colorModeProps: object; componentTheme: object; currentBreakpoint: number; }) => { let translatedProps: any = {}; for (const property in props) { // STEP 1 - Responsive prop check and resolve if (property.startsWith('_')) { // STEP 1.a - Resolving _ porps const nestedTranslatedProps = propTranslator({ props: props[property], theme, colorModeProps, componentTheme, currentBreakpoint, }); translatedProps[property] = nestedTranslatedProps; } else if (themePropertyMap[property]) { // STEP 1.b Resolving themed props const propValues = extractPropertyFromFunction( property, props, theme, componentTheme ); // NOTE: Direct value identified. if (typeof propValues === 'string' || typeof propValues === 'number') { translatedProps[property] = propValues; // NOTE: Nested object (excluding _props) (To be specific, only for key exist in themePropertyMap) } else if (!isNil(propValues)) { // TODO: This setion new needs to handle stuff differently for (let nestedProp in propValues) { translatedProps[nestedProp] = get( theme, `${themePropertyMap[nestedProp]}.${propValues[nestedProp]}`, propValues[nestedProp] ); } delete translatedProps[property]; // Manually handeling shadow props (example of Mapped tokens) } else if (property === 'shadow') { const resolveValueWithBreakpointValue = resolveValueWithBreakpoint( props.shadow, currentBreakpoint, property ); let shadowProps = theme[themePropertyMap[property]](colorModeProps)[ resolveValueWithBreakpointValue ]; translatedProps.style = merge({}, shadowProps, props.style); delete translatedProps[property]; } else { translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } } else { // STEP 1.d Resolving Direct Values translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } </s> add pseudoPropsResolver({ props: componentSizeProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, });
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/components/primitives/Pressable/Pressable.tsx
onPressIn={composeEventHandlers(onPressIn, pressableProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, pressableProps.onPressOut)}
<mask> // TODO : Replace Render props with Context Hook <mask> return ( <mask> <StyledPressable <mask> ref={ref} <mask> onPressIn={composeEventHandlers(onPressIn, isPressedProps.onPressIn)} <mask> onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} <mask> // @ts-ignore - web only <mask> onHoverIn={composeEventHandlers(onHoverIn, pressableProps.onHoverIn)} <mask> // @ts-ignore - web only <mask> onHoverOut={composeEventHandlers(onHoverOut, pressableProps.onHoverOut)} <mask> // @ts-ignore - web only </s> feat: pseudo props combination, simplification and resolution </s> remove onHoverIn={composeEventHandlers(onHoverIn, pressableProps.onHoverIn)} </s> add onHoverIn={composeEventHandlers(onHoverIn, hoverProps.onHoverIn)} </s> remove onHoverOut={composeEventHandlers(onHoverOut, pressableProps.onHoverOut)} </s> add onHoverOut={composeEventHandlers(onHoverOut, hoverProps.onHoverOut)} </s> remove const { _hover, _pressed, _focus, _focusVisible, _disabled, ...themeProps } = usePropsResolution('Pressable', props); </s> add </s> remove const componentMergedTheme = merge( {}, componentTheme.defaultProps, componentBaseStyle, componentVariantProps, componentSizeProps ); if (sizeResolved) { // We remove size from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.size; } if (hasVariant) { // We remove variant from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.variant; } const componentThemeIntegratedProps = merge( {}, useColorModeProps(usePlatformProps(componentMergedTheme)), useColorModeProps(usePlatformProps(incomingProps)) ); return componentThemeIntegratedProps; }; /** * @summary Translates the prop with it's appropriate value. * @description NOTE: Avoid passo JSX and functions. * @arg {any} props - Props object with should be translated. * @arg {any} theme - Theme based on which props will be translated. * @arg {object} colorModeProps - `colorMode` object. * @arg {object} componentTheme - Theme for specific components. * @arg {object} windowWidth - Current width of the window / screen. * @returns {object} Translated props object. */ // Todo - move responsive calculation in styled system const propTranslator = ({ props, theme, colorModeProps, componentTheme, currentBreakpoint, }: { props: any; theme: any; colorModeProps: object; componentTheme: object; currentBreakpoint: number; }) => { let translatedProps: any = {}; for (const property in props) { // STEP 1 - Responsive prop check and resolve if (property.startsWith('_')) { // STEP 1.a - Resolving _ porps const nestedTranslatedProps = propTranslator({ props: props[property], theme, colorModeProps, componentTheme, currentBreakpoint, }); translatedProps[property] = nestedTranslatedProps; } else if (themePropertyMap[property]) { // STEP 1.b Resolving themed props const propValues = extractPropertyFromFunction( property, props, theme, componentTheme ); // NOTE: Direct value identified. if (typeof propValues === 'string' || typeof propValues === 'number') { translatedProps[property] = propValues; // NOTE: Nested object (excluding _props) (To be specific, only for key exist in themePropertyMap) } else if (!isNil(propValues)) { // TODO: This setion new needs to handle stuff differently for (let nestedProp in propValues) { translatedProps[nestedProp] = get( theme, `${themePropertyMap[nestedProp]}.${propValues[nestedProp]}`, propValues[nestedProp] ); } delete translatedProps[property]; // Manually handeling shadow props (example of Mapped tokens) } else if (property === 'shadow') { const resolveValueWithBreakpointValue = resolveValueWithBreakpoint( props.shadow, currentBreakpoint, property ); let shadowProps = theme[themePropertyMap[property]](colorModeProps)[ resolveValueWithBreakpointValue ]; translatedProps.style = merge({}, shadowProps, props.style); delete translatedProps[property]; } else { translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } } else { // STEP 1.d Resolving Direct Values translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } </s> add pseudoPropsResolver({ props: componentSizeProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, });
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/components/primitives/Pressable/Pressable.tsx
onHoverIn={composeEventHandlers(onHoverIn, hoverProps.onHoverIn)}
<mask> ref={ref} <mask> onPressIn={composeEventHandlers(onPressIn, isPressedProps.onPressIn)} <mask> onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} <mask> // @ts-ignore - web only <mask> onHoverIn={composeEventHandlers(onHoverIn, pressableProps.onHoverIn)} <mask> // @ts-ignore - web only <mask> onHoverOut={composeEventHandlers(onHoverOut, pressableProps.onHoverOut)} <mask> // @ts-ignore - web only <mask> onFocus={composeEventHandlers( <mask> composeEventHandlers(onFocus, focusProps.onFocus), </s> feat: pseudo props combination, simplification and resolution </s> remove onHoverOut={composeEventHandlers(onHoverOut, pressableProps.onHoverOut)} </s> add onHoverOut={composeEventHandlers(onHoverOut, hoverProps.onHoverOut)} </s> remove onPressIn={composeEventHandlers(onPressIn, isPressedProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} </s> add onPressIn={composeEventHandlers(onPressIn, pressableProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, pressableProps.onPressOut)} </s> remove // Type - sizes: { size: 4 }. Refer Images if (!componentSizeProps.size) { sizeResolved = true; } </s> add </s> remove // @ts-ignore - Mutating incoming size for now. Fix it after new styled system is implemented incomingProps.size = undefined; } </s> add </s> remove const componentMergedTheme = merge( {}, componentTheme.defaultProps, componentBaseStyle, componentVariantProps, componentSizeProps ); if (sizeResolved) { // We remove size from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.size; } if (hasVariant) { // We remove variant from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.variant; } const componentThemeIntegratedProps = merge( {}, useColorModeProps(usePlatformProps(componentMergedTheme)), useColorModeProps(usePlatformProps(incomingProps)) ); return componentThemeIntegratedProps; }; /** * @summary Translates the prop with it's appropriate value. * @description NOTE: Avoid passo JSX and functions. * @arg {any} props - Props object with should be translated. * @arg {any} theme - Theme based on which props will be translated. * @arg {object} colorModeProps - `colorMode` object. * @arg {object} componentTheme - Theme for specific components. * @arg {object} windowWidth - Current width of the window / screen. * @returns {object} Translated props object. */ // Todo - move responsive calculation in styled system const propTranslator = ({ props, theme, colorModeProps, componentTheme, currentBreakpoint, }: { props: any; theme: any; colorModeProps: object; componentTheme: object; currentBreakpoint: number; }) => { let translatedProps: any = {}; for (const property in props) { // STEP 1 - Responsive prop check and resolve if (property.startsWith('_')) { // STEP 1.a - Resolving _ porps const nestedTranslatedProps = propTranslator({ props: props[property], theme, colorModeProps, componentTheme, currentBreakpoint, }); translatedProps[property] = nestedTranslatedProps; } else if (themePropertyMap[property]) { // STEP 1.b Resolving themed props const propValues = extractPropertyFromFunction( property, props, theme, componentTheme ); // NOTE: Direct value identified. if (typeof propValues === 'string' || typeof propValues === 'number') { translatedProps[property] = propValues; // NOTE: Nested object (excluding _props) (To be specific, only for key exist in themePropertyMap) } else if (!isNil(propValues)) { // TODO: This setion new needs to handle stuff differently for (let nestedProp in propValues) { translatedProps[nestedProp] = get( theme, `${themePropertyMap[nestedProp]}.${propValues[nestedProp]}`, propValues[nestedProp] ); } delete translatedProps[property]; // Manually handeling shadow props (example of Mapped tokens) } else if (property === 'shadow') { const resolveValueWithBreakpointValue = resolveValueWithBreakpoint( props.shadow, currentBreakpoint, property ); let shadowProps = theme[themePropertyMap[property]](colorModeProps)[ resolveValueWithBreakpointValue ]; translatedProps.style = merge({}, shadowProps, props.style); delete translatedProps[property]; } else { translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } } else { // STEP 1.d Resolving Direct Values translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } </s> add pseudoPropsResolver({ props: componentSizeProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, });
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/components/primitives/Pressable/Pressable.tsx
onHoverOut={composeEventHandlers(onHoverOut, hoverProps.onHoverOut)}
<mask> onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} <mask> // @ts-ignore - web only <mask> onHoverIn={composeEventHandlers(onHoverIn, pressableProps.onHoverIn)} <mask> // @ts-ignore - web only <mask> onHoverOut={composeEventHandlers(onHoverOut, pressableProps.onHoverOut)} <mask> // @ts-ignore - web only <mask> onFocus={composeEventHandlers( <mask> composeEventHandlers(onFocus, focusProps.onFocus), <mask> focusRingProps.onFocus <mask> )} </s> feat: pseudo props combination, simplification and resolution </s> remove onHoverIn={composeEventHandlers(onHoverIn, pressableProps.onHoverIn)} </s> add onHoverIn={composeEventHandlers(onHoverIn, hoverProps.onHoverIn)} </s> remove onPressIn={composeEventHandlers(onPressIn, isPressedProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} </s> add onPressIn={composeEventHandlers(onPressIn, pressableProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, pressableProps.onPressOut)} </s> remove // Type - sizes: { size: 4 }. Refer Images if (!componentSizeProps.size) { sizeResolved = true; } </s> add </s> remove // @ts-ignore - Mutating incoming size for now. Fix it after new styled system is implemented incomingProps.size = undefined; } </s> add </s> remove const componentMergedTheme = merge( {}, componentTheme.defaultProps, componentBaseStyle, componentVariantProps, componentSizeProps ); if (sizeResolved) { // We remove size from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.size; } if (hasVariant) { // We remove variant from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.variant; } const componentThemeIntegratedProps = merge( {}, useColorModeProps(usePlatformProps(componentMergedTheme)), useColorModeProps(usePlatformProps(incomingProps)) ); return componentThemeIntegratedProps; }; /** * @summary Translates the prop with it's appropriate value. * @description NOTE: Avoid passo JSX and functions. * @arg {any} props - Props object with should be translated. * @arg {any} theme - Theme based on which props will be translated. * @arg {object} colorModeProps - `colorMode` object. * @arg {object} componentTheme - Theme for specific components. * @arg {object} windowWidth - Current width of the window / screen. * @returns {object} Translated props object. */ // Todo - move responsive calculation in styled system const propTranslator = ({ props, theme, colorModeProps, componentTheme, currentBreakpoint, }: { props: any; theme: any; colorModeProps: object; componentTheme: object; currentBreakpoint: number; }) => { let translatedProps: any = {}; for (const property in props) { // STEP 1 - Responsive prop check and resolve if (property.startsWith('_')) { // STEP 1.a - Resolving _ porps const nestedTranslatedProps = propTranslator({ props: props[property], theme, colorModeProps, componentTheme, currentBreakpoint, }); translatedProps[property] = nestedTranslatedProps; } else if (themePropertyMap[property]) { // STEP 1.b Resolving themed props const propValues = extractPropertyFromFunction( property, props, theme, componentTheme ); // NOTE: Direct value identified. if (typeof propValues === 'string' || typeof propValues === 'number') { translatedProps[property] = propValues; // NOTE: Nested object (excluding _props) (To be specific, only for key exist in themePropertyMap) } else if (!isNil(propValues)) { // TODO: This setion new needs to handle stuff differently for (let nestedProp in propValues) { translatedProps[nestedProp] = get( theme, `${themePropertyMap[nestedProp]}.${propValues[nestedProp]}`, propValues[nestedProp] ); } delete translatedProps[property]; // Manually handeling shadow props (example of Mapped tokens) } else if (property === 'shadow') { const resolveValueWithBreakpointValue = resolveValueWithBreakpoint( props.shadow, currentBreakpoint, property ); let shadowProps = theme[themePropertyMap[property]](colorModeProps)[ resolveValueWithBreakpointValue ]; translatedProps.style = merge({}, shadowProps, props.style); delete translatedProps[property]; } else { translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } } else { // STEP 1.d Resolving Direct Values translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } </s> add pseudoPropsResolver({ props: componentSizeProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, });
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/components/primitives/Pressable/Pressable.tsx
{...resolvedProps}
<mask> onBlur={composeEventHandlers( <mask> composeEventHandlers(onBlur, focusProps.onBlur), <mask> focusRingProps.onBlur <mask> )} <mask> {...themeProps} <mask> {...(isHovered && _hover)} <mask> {...(isFocused && _focus)} <mask> {...(isFocusVisible && _focusVisible)} <mask> {...(isPressed && _pressed)} <mask> {...(props.disabled && _disabled)} <mask> > <mask> {typeof children !== 'function' <mask> ? children <mask> : children({ <mask> isPressed, </s> feat: pseudo props combination, simplification and resolution </s> remove let componentSizeProps: any = {}; </s> add let componentSizeProps = {}; </s> remove ...combinedProps, </s> add ...flattenProps, </s> remove ...combinedProps, </s> add ...flattenProps, </s> remove // Resolving component's baseStyle </s> add // NOTE: Resoloving baseStyle </s> remove import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; import { useNativeBaseConfig } from '../../core/NativeBaseContext'; </s> add // TODO: have to remove as many ts-ignore as possible. const platformPropsMap = ['_ios', '_android', '_web']; const colorModePropsMap = ['_light', '_dark']; const statePropsMap = [ '_invalid', '_disabled', '_checked', '_hover', '_pressed', '_focused', ]; const pseudoPropsMap = { _web: 'web', _ios: 'ios', _android: 'android', _light: 'light', _dark: 'dark', // TODO: have to add more interactionProps and stateProps _hover: 'isHovered', _pressed: 'isPressed', _focused: 'isFocused', _disabled: 'isDisabled', _invalid: 'isInvalid', _indeterminate: 'isIndeterminate', }; const shouldResolve = ({ property, state, platform, colormode }: any) => { if (platformPropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === platform; } else if (colorModePropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === colormode; } else if (statePropsMap.includes(property)) { // @ts-ignore return state[pseudoPropsMap[property]]; } else { return false; } }; let flattenProps: any = {}; let propertyDepth: any = {}; const pseudoPropsResolver = ({ props, platform, colormode, state, currentDepth = 0, }: any) => { for (const property in props) { // @ts-ignore if (pseudoPropsMap[property]) { if (shouldResolve({ property: property, state, platform, colormode })) { pseudoPropsResolver({ props: props[property], platform, colormode, state, currentDepth: currentDepth++, }); } } else if (!property.startsWith('_')) { if ( !(propertyDepth[property] && propertyDepth[property] > currentDepth) ) { propertyDepth[property] = currentDepth; flattenProps[property] = props[property]; } } } return flattenProps; };
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/components/primitives/Pressable/Pressable.tsx
<mask> import get from 'lodash.get'; <mask> import omit from 'lodash.omit'; <mask> import isNil from 'lodash.isnil'; <mask> import merge from 'lodash.merge'; <mask> import { useNativeBase } from '../useNativeBase'; <mask> import { usePlatformProps } from '../usePlatformProps'; <mask> import { useColorModeProps } from '../useColorModeProps'; <mask> import { useColorMode } from '../../core/color-mode'; </s> feat: pseudo props combination, simplification and resolution </s> remove import { usePlatformProps } from '../usePlatformProps'; import { useColorModeProps } from '../useColorModeProps'; </s> add </s> remove resolveValueWithBreakpoint, extractPropertyFromFunction, } from './utils'; import { omitUndefined, extractInObject } from './../../theme/tools'; import { themePropertyMap } from './../../theme/base'; </s> add getClosestBreakpoint, omitUndefined, extractInObject, } from '../../theme/tools';
[ "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
import { useWindowDimensions, Platform } from 'react-native';
<mask> import React from 'react'; <mask> import get from 'lodash.get'; <mask> import merge from 'lodash.merge'; <mask> import { useNativeBase } from '../useNativeBase'; <mask> import { useColorMode } from '../../core/color-mode'; <mask> import { resolveValueWithBreakpoint } from './utils'; <mask> import { <mask> getClosestBreakpoint, <mask> omitUndefined, </s> feat: pseudo props combination, simplification and resolution </s> remove import omit from 'lodash.omit'; import isNil from 'lodash.isnil'; </s> add </s> remove import { usePlatformProps } from '../usePlatformProps'; import { useColorModeProps } from '../useColorModeProps'; </s> add </s> remove resolveValueWithBreakpoint, extractPropertyFromFunction, } from './utils'; import { omitUndefined, extractInObject } from './../../theme/tools'; import { themePropertyMap } from './../../theme/base'; </s> add getClosestBreakpoint, omitUndefined, extractInObject, } from '../../theme/tools';
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
<mask> import omit from 'lodash.omit'; <mask> import isNil from 'lodash.isnil'; <mask> import merge from 'lodash.merge'; <mask> import { useNativeBase } from '../useNativeBase'; <mask> import { usePlatformProps } from '../usePlatformProps'; <mask> import { useColorModeProps } from '../useColorModeProps'; <mask> import { useColorMode } from '../../core/color-mode'; <mask> import { <mask> resolveValueWithBreakpoint, <mask> extractPropertyFromFunction, <mask> } from './utils'; </s> feat: pseudo props combination, simplification and resolution </s> remove import omit from 'lodash.omit'; import isNil from 'lodash.isnil'; </s> add </s> remove resolveValueWithBreakpoint, extractPropertyFromFunction, } from './utils'; import { omitUndefined, extractInObject } from './../../theme/tools'; import { themePropertyMap } from './../../theme/base'; </s> add getClosestBreakpoint, omitUndefined, extractInObject, } from '../../theme/tools';
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
import { resolveValueWithBreakpoint } from './utils';
<mask> import { useWindowDimensions, Platform } from 'react-native'; <mask> import { useNativeBase } from '../useNativeBase'; <mask> import { useColorMode } from '../../core/color-mode'; <mask> import { <mask> getClosestBreakpoint, <mask> omitUndefined, <mask> extractInObject, <mask> } from '../../theme/tools'; </s> feat: pseudo props combination, simplification and resolution </s> remove resolveValueWithBreakpoint, extractPropertyFromFunction, } from './utils'; import { omitUndefined, extractInObject } from './../../theme/tools'; import { themePropertyMap } from './../../theme/base'; </s> add getClosestBreakpoint, omitUndefined, extractInObject, } from '../../theme/tools'; </s> remove import omit from 'lodash.omit'; import isNil from 'lodash.isnil'; </s> add </s> remove import { usePlatformProps } from '../usePlatformProps'; import { useColorModeProps } from '../useColorModeProps'; </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
getClosestBreakpoint, omitUndefined, extractInObject, } from '../../theme/tools';
<mask> import { usePlatformProps } from '../usePlatformProps'; <mask> import { useColorModeProps } from '../useColorModeProps'; <mask> import { useColorMode } from '../../core/color-mode'; <mask> import { <mask> resolveValueWithBreakpoint, <mask> extractPropertyFromFunction, <mask> } from './utils'; <mask> import { omitUndefined, extractInObject } from './../../theme/tools'; <mask> import { themePropertyMap } from './../../theme/base'; <mask> import { useContrastText } from '../useContrastText'; <mask> import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; <mask> import { useNativeBaseConfig } from '../../core/NativeBaseContext'; <mask> <mask> /** </s> feat: pseudo props combination, simplification and resolution </s> remove import { usePlatformProps } from '../usePlatformProps'; import { useColorModeProps } from '../useColorModeProps'; </s> add </s> remove import omit from 'lodash.omit'; import isNil from 'lodash.isnil'; </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
// TODO: have to remove as many ts-ignore as possible. const platformPropsMap = ['_ios', '_android', '_web']; const colorModePropsMap = ['_light', '_dark']; const statePropsMap = [ '_invalid', '_disabled', '_checked', '_hover', '_pressed', '_focused', ]; const pseudoPropsMap = { _web: 'web', _ios: 'ios', _android: 'android', _light: 'light', _dark: 'dark', // TODO: have to add more interactionProps and stateProps _hover: 'isHovered', _pressed: 'isPressed', _focused: 'isFocused', _disabled: 'isDisabled', _invalid: 'isInvalid', _indeterminate: 'isIndeterminate', }; const shouldResolve = ({ property, state, platform, colormode }: any) => { if (platformPropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === platform; } else if (colorModePropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === colormode; } else if (statePropsMap.includes(property)) { // @ts-ignore return state[pseudoPropsMap[property]]; } else { return false; } }; let flattenProps: any = {}; let propertyDepth: any = {}; const pseudoPropsResolver = ({ props, platform, colormode, state, currentDepth = 0, }: any) => { for (const property in props) { // @ts-ignore if (pseudoPropsMap[property]) { if (shouldResolve({ property: property, state, platform, colormode })) { pseudoPropsResolver({ props: props[property], platform, colormode, state, currentDepth: currentDepth++, }); } } else if (!property.startsWith('_')) { if ( !(propertyDepth[property] && propertyDepth[property] > currentDepth) ) { propertyDepth[property] = currentDepth; flattenProps[property] = props[property]; } } } return flattenProps; };
<mask> } from './utils'; <mask> import { omitUndefined, extractInObject } from './../../theme/tools'; <mask> import { themePropertyMap } from './../../theme/base'; <mask> import { useContrastText } from '../useContrastText'; <mask> import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; <mask> import { useNativeBaseConfig } from '../../core/NativeBaseContext'; <mask> <mask> /** <mask> * @summary Resolves, simplify and merge components specific theme. <mask> * @description The function extract and execute component specifc theme (i.e., `defaultProps`, `baseStyle` and `variants`) and returns a merged and simplified object. <mask> * @arg {string} theme - Theme object of NativeBase (without component theme). </s> feat: pseudo props combination, simplification and resolution </s> remove * @summary Resolves, simplify and merge components specific theme. * @description The function extract and execute component specifc theme (i.e., `defaultProps`, `baseStyle` and `variants`) and returns a merged and simplified object. * @arg {string} theme - Theme object of NativeBase (without component theme). * @arg {object} componentTheme - Theme for specific components. </s> add * @summary Combines provided porps with component's theme props and resloves them. * @description NOTE: Avoid passing JSX and functions. * @arg {string} component - Name of the component. </s> remove resolveValueWithBreakpoint, extractPropertyFromFunction, } from './utils'; import { omitUndefined, extractInObject } from './../../theme/tools'; import { themePropertyMap } from './../../theme/base'; </s> add getClosestBreakpoint, omitUndefined, extractInObject, } from '../../theme/tools'; </s> remove * @arg {object} colorModeProps - `colorMode` object. * @returns {object} Resolved component specific theme. </s> add * @arg {object} state - dependent states. * @arg {object} config - configuration for resolution. * @returns {object} Resolved and flattened props.
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
* @summary Combines provided porps with component's theme props and resloves them. * @description NOTE: Avoid passing JSX and functions. * @arg {string} component - Name of the component.
<mask> import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; <mask> import { useNativeBaseConfig } from '../../core/NativeBaseContext'; <mask> <mask> /** <mask> * @summary Resolves, simplify and merge components specific theme. <mask> * @description The function extract and execute component specifc theme (i.e., `defaultProps`, `baseStyle` and `variants`) and returns a merged and simplified object. <mask> * @arg {string} theme - Theme object of NativeBase (without component theme). <mask> * @arg {object} componentTheme - Theme for specific components. <mask> * @arg {object} incomingProps - Props passed by the user. <mask> * @arg {object} colorModeProps - `colorMode` object. <mask> * @returns {object} Resolved component specific theme. <mask> */ <mask> const useSimplifyComponentTheme = ( </s> feat: pseudo props combination, simplification and resolution </s> remove * @arg {object} colorModeProps - `colorMode` object. * @returns {object} Resolved component specific theme. </s> add * @arg {object} state - dependent states. * @arg {object} config - configuration for resolution. * @returns {object} Resolved and flattened props. </s> remove const useSimplifyComponentTheme = ( theme: object, componentTheme: { defaultProps?: object; baseStyle?: object | Function; variants?: any | Function; sizes?: any | Function; }, incomingProps: object, colorModeProps: object, currentBreakpoint: number ) => { let sizeResolved = false; let hasVariant = false; // Resolving component's defaultProps. </s> add export function usePropsResolution( component: string, incomingProps: any, state?: any, config?: any ) { const [ignoredProps, cleanIncomingProps] = extractInObject( incomingProps, ['children', 'onPress', 'icon', 'onOpen', 'onClose'].concat( config?.ignoreProps || [] ) ); const { theme } = useNativeBase(); const colorModeProps = useColorMode(); </s> remove /** * @summary Combines provided porps with component's theme props and resloves them. * @description NOTE: Avoid passing JSX and functions. * @arg {string} component - Name of the component. * @arg {object} incomingProps - Props passed by the user. * @returns {object} Resolved props. */ export function usePropsResolution( component: string, incomingProps: any, config?: any ) { const [ignoredProps, cleanIncomingProps] = extractInObject( incomingProps, ['children', 'onPress', 'icon', 'onOpen', 'onClose'].concat( config?.ignoreProps || [] ) ); const { theme } = useNativeBase(); const colorModeProps = useColorMode(); const componentTheme = get(theme, `components.${component}`, {}); const notComponentTheme = omit(theme, ['components']); const currentBreakpoint = useNativeBaseConfig('usePropsResolution') .currentBreakpoint; // TODO: using usePlatformProps here to simplify the component theme. So that on on component level it shouldn't have to maintain the Specificity. const componentThemeIntegratedProps = useSimplifyComponentTheme( notComponentTheme, componentTheme, cleanIncomingProps, colorModeProps, currentBreakpoint ); // const platformSpecificProps = usePlatformProps(componentThemeIntegratedProps); // NOTE: sperating removing props while should be translated </s> add // STEP 5: linear Grad and contrastText </s> remove import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; import { useNativeBaseConfig } from '../../core/NativeBaseContext'; </s> add // TODO: have to remove as many ts-ignore as possible. const platformPropsMap = ['_ios', '_android', '_web']; const colorModePropsMap = ['_light', '_dark']; const statePropsMap = [ '_invalid', '_disabled', '_checked', '_hover', '_pressed', '_focused', ]; const pseudoPropsMap = { _web: 'web', _ios: 'ios', _android: 'android', _light: 'light', _dark: 'dark', // TODO: have to add more interactionProps and stateProps _hover: 'isHovered', _pressed: 'isPressed', _focused: 'isFocused', _disabled: 'isDisabled', _invalid: 'isInvalid', _indeterminate: 'isIndeterminate', }; const shouldResolve = ({ property, state, platform, colormode }: any) => { if (platformPropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === platform; } else if (colorModePropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === colormode; } else if (statePropsMap.includes(property)) { // @ts-ignore return state[pseudoPropsMap[property]]; } else { return false; } }; let flattenProps: any = {}; let propertyDepth: any = {}; const pseudoPropsResolver = ({ props, platform, colormode, state, currentDepth = 0, }: any) => { for (const property in props) { // @ts-ignore if (pseudoPropsMap[property]) { if (shouldResolve({ property: property, state, platform, colormode })) { pseudoPropsResolver({ props: props[property], platform, colormode, state, currentDepth: currentDepth++, }); } } else if (!property.startsWith('_')) { if ( !(propertyDepth[property] && propertyDepth[property] > currentDepth) ) { propertyDepth[property] = currentDepth; flattenProps[property] = props[property]; } } } return flattenProps; }; </s> remove return translatedProps; }; </s> add // STEP 4: Merge
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
* @arg {object} state - dependent states. * @arg {object} config - configuration for resolution. * @returns {object} Resolved and flattened props.
<mask> * @description The function extract and execute component specifc theme (i.e., `defaultProps`, `baseStyle` and `variants`) and returns a merged and simplified object. <mask> * @arg {string} theme - Theme object of NativeBase (without component theme). <mask> * @arg {object} componentTheme - Theme for specific components. <mask> * @arg {object} incomingProps - Props passed by the user. <mask> * @arg {object} colorModeProps - `colorMode` object. <mask> * @returns {object} Resolved component specific theme. <mask> */ <mask> const useSimplifyComponentTheme = ( <mask> theme: object, <mask> componentTheme: { <mask> defaultProps?: object; </s> feat: pseudo props combination, simplification and resolution </s> remove * @summary Resolves, simplify and merge components specific theme. * @description The function extract and execute component specifc theme (i.e., `defaultProps`, `baseStyle` and `variants`) and returns a merged and simplified object. * @arg {string} theme - Theme object of NativeBase (without component theme). * @arg {object} componentTheme - Theme for specific components. </s> add * @summary Combines provided porps with component's theme props and resloves them. * @description NOTE: Avoid passing JSX and functions. * @arg {string} component - Name of the component. </s> remove const useSimplifyComponentTheme = ( theme: object, componentTheme: { defaultProps?: object; baseStyle?: object | Function; variants?: any | Function; sizes?: any | Function; }, incomingProps: object, colorModeProps: object, currentBreakpoint: number ) => { let sizeResolved = false; let hasVariant = false; // Resolving component's defaultProps. </s> add export function usePropsResolution( component: string, incomingProps: any, state?: any, config?: any ) { const [ignoredProps, cleanIncomingProps] = extractInObject( incomingProps, ['children', 'onPress', 'icon', 'onOpen', 'onClose'].concat( config?.ignoreProps || [] ) ); const { theme } = useNativeBase(); const colorModeProps = useColorMode(); </s> remove /** * @summary Combines provided porps with component's theme props and resloves them. * @description NOTE: Avoid passing JSX and functions. * @arg {string} component - Name of the component. * @arg {object} incomingProps - Props passed by the user. * @returns {object} Resolved props. */ export function usePropsResolution( component: string, incomingProps: any, config?: any ) { const [ignoredProps, cleanIncomingProps] = extractInObject( incomingProps, ['children', 'onPress', 'icon', 'onOpen', 'onClose'].concat( config?.ignoreProps || [] ) ); const { theme } = useNativeBase(); const colorModeProps = useColorMode(); const componentTheme = get(theme, `components.${component}`, {}); const notComponentTheme = omit(theme, ['components']); const currentBreakpoint = useNativeBaseConfig('usePropsResolution') .currentBreakpoint; // TODO: using usePlatformProps here to simplify the component theme. So that on on component level it shouldn't have to maintain the Specificity. const componentThemeIntegratedProps = useSimplifyComponentTheme( notComponentTheme, componentTheme, cleanIncomingProps, colorModeProps, currentBreakpoint ); // const platformSpecificProps = usePlatformProps(componentThemeIntegratedProps); // NOTE: sperating removing props while should be translated </s> add // STEP 5: linear Grad and contrastText </s> remove return translatedProps; }; </s> add // STEP 4: Merge </s> remove const componentMergedTheme = merge( {}, componentTheme.defaultProps, componentBaseStyle, componentVariantProps, componentSizeProps ); if (sizeResolved) { // We remove size from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.size; } if (hasVariant) { // We remove variant from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.variant; } const componentThemeIntegratedProps = merge( {}, useColorModeProps(usePlatformProps(componentMergedTheme)), useColorModeProps(usePlatformProps(incomingProps)) ); return componentThemeIntegratedProps; }; /** * @summary Translates the prop with it's appropriate value. * @description NOTE: Avoid passo JSX and functions. * @arg {any} props - Props object with should be translated. * @arg {any} theme - Theme based on which props will be translated. * @arg {object} colorModeProps - `colorMode` object. * @arg {object} componentTheme - Theme for specific components. * @arg {object} windowWidth - Current width of the window / screen. * @returns {object} Translated props object. */ // Todo - move responsive calculation in styled system const propTranslator = ({ props, theme, colorModeProps, componentTheme, currentBreakpoint, }: { props: any; theme: any; colorModeProps: object; componentTheme: object; currentBreakpoint: number; }) => { let translatedProps: any = {}; for (const property in props) { // STEP 1 - Responsive prop check and resolve if (property.startsWith('_')) { // STEP 1.a - Resolving _ porps const nestedTranslatedProps = propTranslator({ props: props[property], theme, colorModeProps, componentTheme, currentBreakpoint, }); translatedProps[property] = nestedTranslatedProps; } else if (themePropertyMap[property]) { // STEP 1.b Resolving themed props const propValues = extractPropertyFromFunction( property, props, theme, componentTheme ); // NOTE: Direct value identified. if (typeof propValues === 'string' || typeof propValues === 'number') { translatedProps[property] = propValues; // NOTE: Nested object (excluding _props) (To be specific, only for key exist in themePropertyMap) } else if (!isNil(propValues)) { // TODO: This setion new needs to handle stuff differently for (let nestedProp in propValues) { translatedProps[nestedProp] = get( theme, `${themePropertyMap[nestedProp]}.${propValues[nestedProp]}`, propValues[nestedProp] ); } delete translatedProps[property]; // Manually handeling shadow props (example of Mapped tokens) } else if (property === 'shadow') { const resolveValueWithBreakpointValue = resolveValueWithBreakpoint( props.shadow, currentBreakpoint, property ); let shadowProps = theme[themePropertyMap[property]](colorModeProps)[ resolveValueWithBreakpointValue ]; translatedProps.style = merge({}, shadowProps, props.style); delete translatedProps[property]; } else { translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } } else { // STEP 1.d Resolving Direct Values translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } </s> add pseudoPropsResolver({ props: componentSizeProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, });
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
export function usePropsResolution( component: string, incomingProps: any, state?: any, config?: any ) { const [ignoredProps, cleanIncomingProps] = extractInObject( incomingProps, ['children', 'onPress', 'icon', 'onOpen', 'onClose'].concat( config?.ignoreProps || [] ) ); const { theme } = useNativeBase(); const colorModeProps = useColorMode();
<mask> * @arg {object} incomingProps - Props passed by the user. <mask> * @arg {object} colorModeProps - `colorMode` object. <mask> * @returns {object} Resolved component specific theme. <mask> */ <mask> const useSimplifyComponentTheme = ( <mask> theme: object, <mask> componentTheme: { <mask> defaultProps?: object; <mask> baseStyle?: object | Function; <mask> variants?: any | Function; <mask> sizes?: any | Function; <mask> }, <mask> incomingProps: object, <mask> colorModeProps: object, <mask> currentBreakpoint: number <mask> ) => { <mask> let sizeResolved = false; <mask> let hasVariant = false; <mask> // Resolving component's defaultProps. <mask> <mask> // Shallow merge defaultProps and incoming props to pass them in baseStyle, variants and sizes <mask> const combinedProps: any = { <mask> ...componentTheme.defaultProps, <mask> ...incomingProps, </s> feat: pseudo props combination, simplification and resolution </s> remove * @arg {object} colorModeProps - `colorMode` object. * @returns {object} Resolved component specific theme. </s> add * @arg {object} state - dependent states. * @arg {object} config - configuration for resolution. * @returns {object} Resolved and flattened props. </s> remove * @summary Resolves, simplify and merge components specific theme. * @description The function extract and execute component specifc theme (i.e., `defaultProps`, `baseStyle` and `variants`) and returns a merged and simplified object. * @arg {string} theme - Theme object of NativeBase (without component theme). * @arg {object} componentTheme - Theme for specific components. </s> add * @summary Combines provided porps with component's theme props and resloves them. * @description NOTE: Avoid passing JSX and functions. * @arg {string} component - Name of the component. </s> remove // Shallow merge defaultProps and incoming props to pass them in baseStyle, variants and sizes const combinedProps: any = { ...componentTheme.defaultProps, ...incomingProps, }; </s> add const componentTheme = get(theme, `components.${component}`, {}); const windowWidth = useWindowDimensions()?.width; const currentBreakpoint = React.useMemo( () => getClosestBreakpoint(theme.breakpoints, windowWidth), [windowWidth, theme.breakpoints] ); // STEP 1: combine default props and incoming props const incomingWithDefaultProps = merge( {}, componentTheme.defaultProps || {}, cleanIncomingProps ); // STEP 2: flatten them pseudoPropsResolver({ props: incomingWithDefaultProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); // STEP 3: Pass it to baseStyle, then variant and then size and resolve them. </s> remove /** * @summary Combines provided porps with component's theme props and resloves them. * @description NOTE: Avoid passing JSX and functions. * @arg {string} component - Name of the component. * @arg {object} incomingProps - Props passed by the user. * @returns {object} Resolved props. */ export function usePropsResolution( component: string, incomingProps: any, config?: any ) { const [ignoredProps, cleanIncomingProps] = extractInObject( incomingProps, ['children', 'onPress', 'icon', 'onOpen', 'onClose'].concat( config?.ignoreProps || [] ) ); const { theme } = useNativeBase(); const colorModeProps = useColorMode(); const componentTheme = get(theme, `components.${component}`, {}); const notComponentTheme = omit(theme, ['components']); const currentBreakpoint = useNativeBaseConfig('usePropsResolution') .currentBreakpoint; // TODO: using usePlatformProps here to simplify the component theme. So that on on component level it shouldn't have to maintain the Specificity. const componentThemeIntegratedProps = useSimplifyComponentTheme( notComponentTheme, componentTheme, cleanIncomingProps, colorModeProps, currentBreakpoint ); // const platformSpecificProps = usePlatformProps(componentThemeIntegratedProps); // NOTE: sperating removing props while should be translated </s> add // STEP 5: linear Grad and contrastText </s> remove const componentMergedTheme = merge( {}, componentTheme.defaultProps, componentBaseStyle, componentVariantProps, componentSizeProps ); if (sizeResolved) { // We remove size from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.size; } if (hasVariant) { // We remove variant from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.variant; } const componentThemeIntegratedProps = merge( {}, useColorModeProps(usePlatformProps(componentMergedTheme)), useColorModeProps(usePlatformProps(incomingProps)) ); return componentThemeIntegratedProps; }; /** * @summary Translates the prop with it's appropriate value. * @description NOTE: Avoid passo JSX and functions. * @arg {any} props - Props object with should be translated. * @arg {any} theme - Theme based on which props will be translated. * @arg {object} colorModeProps - `colorMode` object. * @arg {object} componentTheme - Theme for specific components. * @arg {object} windowWidth - Current width of the window / screen. * @returns {object} Translated props object. */ // Todo - move responsive calculation in styled system const propTranslator = ({ props, theme, colorModeProps, componentTheme, currentBreakpoint, }: { props: any; theme: any; colorModeProps: object; componentTheme: object; currentBreakpoint: number; }) => { let translatedProps: any = {}; for (const property in props) { // STEP 1 - Responsive prop check and resolve if (property.startsWith('_')) { // STEP 1.a - Resolving _ porps const nestedTranslatedProps = propTranslator({ props: props[property], theme, colorModeProps, componentTheme, currentBreakpoint, }); translatedProps[property] = nestedTranslatedProps; } else if (themePropertyMap[property]) { // STEP 1.b Resolving themed props const propValues = extractPropertyFromFunction( property, props, theme, componentTheme ); // NOTE: Direct value identified. if (typeof propValues === 'string' || typeof propValues === 'number') { translatedProps[property] = propValues; // NOTE: Nested object (excluding _props) (To be specific, only for key exist in themePropertyMap) } else if (!isNil(propValues)) { // TODO: This setion new needs to handle stuff differently for (let nestedProp in propValues) { translatedProps[nestedProp] = get( theme, `${themePropertyMap[nestedProp]}.${propValues[nestedProp]}`, propValues[nestedProp] ); } delete translatedProps[property]; // Manually handeling shadow props (example of Mapped tokens) } else if (property === 'shadow') { const resolveValueWithBreakpointValue = resolveValueWithBreakpoint( props.shadow, currentBreakpoint, property ); let shadowProps = theme[themePropertyMap[property]](colorModeProps)[ resolveValueWithBreakpointValue ]; translatedProps.style = merge({}, shadowProps, props.style); delete translatedProps[property]; } else { translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } } else { // STEP 1.d Resolving Direct Values translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } </s> add pseudoPropsResolver({ props: componentSizeProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, });
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
const componentTheme = get(theme, `components.${component}`, {}); const windowWidth = useWindowDimensions()?.width; const currentBreakpoint = React.useMemo( () => getClosestBreakpoint(theme.breakpoints, windowWidth), [windowWidth, theme.breakpoints] ); // STEP 1: combine default props and incoming props const incomingWithDefaultProps = merge( {}, componentTheme.defaultProps || {}, cleanIncomingProps ); // STEP 2: flatten them pseudoPropsResolver({ props: incomingWithDefaultProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); // STEP 3: Pass it to baseStyle, then variant and then size and resolve them.
<mask> let sizeResolved = false; <mask> let hasVariant = false; <mask> // Resolving component's defaultProps. <mask> <mask> // Shallow merge defaultProps and incoming props to pass them in baseStyle, variants and sizes <mask> const combinedProps: any = { <mask> ...componentTheme.defaultProps, <mask> ...incomingProps, <mask> }; <mask> <mask> // Resolving component's baseStyle <mask> let componentBaseStyle = {}; <mask> if (componentTheme.baseStyle) { <mask> componentBaseStyle = </s> feat: pseudo props combination, simplification and resolution </s> remove // Resolving component's baseStyle </s> add // NOTE: Resoloving baseStyle </s> remove const useSimplifyComponentTheme = ( theme: object, componentTheme: { defaultProps?: object; baseStyle?: object | Function; variants?: any | Function; sizes?: any | Function; }, incomingProps: object, colorModeProps: object, currentBreakpoint: number ) => { let sizeResolved = false; let hasVariant = false; // Resolving component's defaultProps. </s> add export function usePropsResolution( component: string, incomingProps: any, state?: any, config?: any ) { const [ignoredProps, cleanIncomingProps] = extractInObject( incomingProps, ['children', 'onPress', 'icon', 'onOpen', 'onClose'].concat( config?.ignoreProps || [] ) ); const { theme } = useNativeBase(); const colorModeProps = useColorMode(); </s> remove import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; import { useNativeBaseConfig } from '../../core/NativeBaseContext'; </s> add // TODO: have to remove as many ts-ignore as possible. const platformPropsMap = ['_ios', '_android', '_web']; const colorModePropsMap = ['_light', '_dark']; const statePropsMap = [ '_invalid', '_disabled', '_checked', '_hover', '_pressed', '_focused', ]; const pseudoPropsMap = { _web: 'web', _ios: 'ios', _android: 'android', _light: 'light', _dark: 'dark', // TODO: have to add more interactionProps and stateProps _hover: 'isHovered', _pressed: 'isPressed', _focused: 'isFocused', _disabled: 'isDisabled', _invalid: 'isInvalid', _indeterminate: 'isIndeterminate', }; const shouldResolve = ({ property, state, platform, colormode }: any) => { if (platformPropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === platform; } else if (colorModePropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === colormode; } else if (statePropsMap.includes(property)) { // @ts-ignore return state[pseudoPropsMap[property]]; } else { return false; } }; let flattenProps: any = {}; let propertyDepth: any = {}; const pseudoPropsResolver = ({ props, platform, colormode, state, currentDepth = 0, }: any) => { for (const property in props) { // @ts-ignore if (pseudoPropsMap[property]) { if (shouldResolve({ property: property, state, platform, colormode })) { pseudoPropsResolver({ props: props[property], platform, colormode, state, currentDepth: currentDepth++, }); } } else if (!property.startsWith('_')) { if ( !(propertyDepth[property] && propertyDepth[property] > currentDepth) ) { propertyDepth[property] = currentDepth; flattenProps[property] = props[property]; } } } return flattenProps; }; </s> remove const componentMergedTheme = merge( {}, componentTheme.defaultProps, componentBaseStyle, componentVariantProps, componentSizeProps ); if (sizeResolved) { // We remove size from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.size; } if (hasVariant) { // We remove variant from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.variant; } const componentThemeIntegratedProps = merge( {}, useColorModeProps(usePlatformProps(componentMergedTheme)), useColorModeProps(usePlatformProps(incomingProps)) ); return componentThemeIntegratedProps; }; /** * @summary Translates the prop with it's appropriate value. * @description NOTE: Avoid passo JSX and functions. * @arg {any} props - Props object with should be translated. * @arg {any} theme - Theme based on which props will be translated. * @arg {object} colorModeProps - `colorMode` object. * @arg {object} componentTheme - Theme for specific components. * @arg {object} windowWidth - Current width of the window / screen. * @returns {object} Translated props object. */ // Todo - move responsive calculation in styled system const propTranslator = ({ props, theme, colorModeProps, componentTheme, currentBreakpoint, }: { props: any; theme: any; colorModeProps: object; componentTheme: object; currentBreakpoint: number; }) => { let translatedProps: any = {}; for (const property in props) { // STEP 1 - Responsive prop check and resolve if (property.startsWith('_')) { // STEP 1.a - Resolving _ porps const nestedTranslatedProps = propTranslator({ props: props[property], theme, colorModeProps, componentTheme, currentBreakpoint, }); translatedProps[property] = nestedTranslatedProps; } else if (themePropertyMap[property]) { // STEP 1.b Resolving themed props const propValues = extractPropertyFromFunction( property, props, theme, componentTheme ); // NOTE: Direct value identified. if (typeof propValues === 'string' || typeof propValues === 'number') { translatedProps[property] = propValues; // NOTE: Nested object (excluding _props) (To be specific, only for key exist in themePropertyMap) } else if (!isNil(propValues)) { // TODO: This setion new needs to handle stuff differently for (let nestedProp in propValues) { translatedProps[nestedProp] = get( theme, `${themePropertyMap[nestedProp]}.${propValues[nestedProp]}`, propValues[nestedProp] ); } delete translatedProps[property]; // Manually handeling shadow props (example of Mapped tokens) } else if (property === 'shadow') { const resolveValueWithBreakpointValue = resolveValueWithBreakpoint( props.shadow, currentBreakpoint, property ); let shadowProps = theme[themePropertyMap[property]](colorModeProps)[ resolveValueWithBreakpointValue ]; translatedProps.style = merge({}, shadowProps, props.style); delete translatedProps[property]; } else { translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } } else { // STEP 1.d Resolving Direct Values translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } </s> add pseudoPropsResolver({ props: componentSizeProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); </s> remove /** * @summary Combines provided porps with component's theme props and resloves them. * @description NOTE: Avoid passing JSX and functions. * @arg {string} component - Name of the component. * @arg {object} incomingProps - Props passed by the user. * @returns {object} Resolved props. */ export function usePropsResolution( component: string, incomingProps: any, config?: any ) { const [ignoredProps, cleanIncomingProps] = extractInObject( incomingProps, ['children', 'onPress', 'icon', 'onOpen', 'onClose'].concat( config?.ignoreProps || [] ) ); const { theme } = useNativeBase(); const colorModeProps = useColorMode(); const componentTheme = get(theme, `components.${component}`, {}); const notComponentTheme = omit(theme, ['components']); const currentBreakpoint = useNativeBaseConfig('usePropsResolution') .currentBreakpoint; // TODO: using usePlatformProps here to simplify the component theme. So that on on component level it shouldn't have to maintain the Specificity. const componentThemeIntegratedProps = useSimplifyComponentTheme( notComponentTheme, componentTheme, cleanIncomingProps, colorModeProps, currentBreakpoint ); // const platformSpecificProps = usePlatformProps(componentThemeIntegratedProps); // NOTE: sperating removing props while should be translated </s> add // STEP 5: linear Grad and contrastText
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
// NOTE: Resoloving baseStyle
<mask> ...componentTheme.defaultProps, <mask> ...incomingProps, <mask> }; <mask> <mask> // Resolving component's baseStyle <mask> let componentBaseStyle = {}; <mask> if (componentTheme.baseStyle) { <mask> componentBaseStyle = <mask> typeof componentTheme.baseStyle !== 'function' <mask> ? componentTheme.baseStyle </s> feat: pseudo props combination, simplification and resolution </s> remove // Shallow merge defaultProps and incoming props to pass them in baseStyle, variants and sizes const combinedProps: any = { ...componentTheme.defaultProps, ...incomingProps, }; </s> add const componentTheme = get(theme, `components.${component}`, {}); const windowWidth = useWindowDimensions()?.width; const currentBreakpoint = React.useMemo( () => getClosestBreakpoint(theme.breakpoints, windowWidth), [windowWidth, theme.breakpoints] ); // STEP 1: combine default props and incoming props const incomingWithDefaultProps = merge( {}, componentTheme.defaultProps || {}, cleanIncomingProps ); // STEP 2: flatten them pseudoPropsResolver({ props: incomingWithDefaultProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); // STEP 3: Pass it to baseStyle, then variant and then size and resolve them. </s> remove ...combinedProps, </s> add ...flattenProps, </s> remove ...combinedProps, </s> add ...flattenProps, </s> remove let componentSizeProps: any = {}; </s> add let componentSizeProps = {}; </s> remove const useSimplifyComponentTheme = ( theme: object, componentTheme: { defaultProps?: object; baseStyle?: object | Function; variants?: any | Function; sizes?: any | Function; }, incomingProps: object, colorModeProps: object, currentBreakpoint: number ) => { let sizeResolved = false; let hasVariant = false; // Resolving component's defaultProps. </s> add export function usePropsResolution( component: string, incomingProps: any, state?: any, config?: any ) { const [ignoredProps, cleanIncomingProps] = extractInObject( incomingProps, ['children', 'onPress', 'icon', 'onOpen', 'onClose'].concat( config?.ignoreProps || [] ) ); const { theme } = useNativeBase(); const colorModeProps = useColorMode();
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
...flattenProps,
<mask> typeof componentTheme.baseStyle !== 'function' <mask> ? componentTheme.baseStyle <mask> : componentTheme.baseStyle({ <mask> theme, <mask> ...combinedProps, <mask> ...colorModeProps, <mask> }); <mask> } <mask> <mask> // To handle responsive type variant. i.e. {sm:"x"} | [x, y] </s> feat: pseudo props combination, simplification and resolution </s> remove // To handle responsive type variant. i.e. {sm:"x"} | [x, y] </s> add // NOTE: Resolving variants </s> remove combinedProps.variant, </s> add flattenProps.variant, </s> remove ...combinedProps, </s> add ...flattenProps, </s> remove // Resolving component's baseStyle </s> add // NOTE: Resoloving baseStyle </s> remove hasVariant = true; </s> add pseudoPropsResolver({ props: componentVariantProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); // We remove variant from original props if we found it in the componentTheme
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
pseudoPropsResolver({ props: componentBaseStyle, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, });
<mask> ...flattenProps, <mask> ...colorModeProps, <mask> }); <mask> } <mask> <mask> // NOTE: Resolving variants <mask> const variant = resolveValueWithBreakpoint( <mask> flattenProps.variant, </s> feat: pseudo props combination, simplification and resolution </s> remove // To handle responsive type variant. i.e. {sm:"x"} | [x, y] </s> add // NOTE: Resolving variants </s> remove combinedProps.variant, </s> add flattenProps.variant, </s> remove // To handle responsive size prop. i.e. {sm:"x"} | [x, y] </s> add // NOTE: Resolving size </s> remove // Shallow merge defaultProps and incoming props to pass them in baseStyle, variants and sizes const combinedProps: any = { ...componentTheme.defaultProps, ...incomingProps, }; </s> add const componentTheme = get(theme, `components.${component}`, {}); const windowWidth = useWindowDimensions()?.width; const currentBreakpoint = React.useMemo( () => getClosestBreakpoint(theme.breakpoints, windowWidth), [windowWidth, theme.breakpoints] ); // STEP 1: combine default props and incoming props const incomingWithDefaultProps = merge( {}, componentTheme.defaultProps || {}, cleanIncomingProps ); // STEP 2: flatten them pseudoPropsResolver({ props: incomingWithDefaultProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); // STEP 3: Pass it to baseStyle, then variant and then size and resolve them. </s> remove ...combinedProps, </s> add ...flattenProps,
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
// NOTE: Resolving variants
<mask> ...colorModeProps, <mask> }); <mask> } <mask> <mask> // To handle responsive type variant. i.e. {sm:"x"} | [x, y] <mask> const variant = resolveValueWithBreakpoint( <mask> combinedProps.variant, <mask> currentBreakpoint, <mask> 'variant' <mask> ); </s> feat: pseudo props combination, simplification and resolution </s> remove combinedProps.variant, </s> add flattenProps.variant, </s> remove ...combinedProps, </s> add ...flattenProps, </s> remove combinedProps.size, </s> add flattenProps.size, </s> remove // To handle responsive size prop. i.e. {sm:"x"} | [x, y] </s> add // NOTE: Resolving size </s> remove incomingProps.variant = undefined; </s> add flattenProps.variant = undefined;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
flattenProps.variant,
<mask> } <mask> <mask> // To handle responsive type variant. i.e. {sm:"x"} | [x, y] <mask> const variant = resolveValueWithBreakpoint( <mask> combinedProps.variant, <mask> currentBreakpoint, <mask> 'variant' <mask> ); <mask> <mask> let componentVariantProps = {}; </s> feat: pseudo props combination, simplification and resolution </s> remove // To handle responsive type variant. i.e. {sm:"x"} | [x, y] </s> add // NOTE: Resolving variants </s> remove combinedProps.size, </s> add flattenProps.size, </s> remove // To handle responsive size prop. i.e. {sm:"x"} | [x, y] </s> add // NOTE: Resolving size </s> remove ...combinedProps, </s> add ...flattenProps, </s> remove incomingProps.variant = undefined; </s> add flattenProps.variant = undefined;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
...flattenProps,
<mask> typeof componentTheme.variants[variant] !== 'function' <mask> ? componentTheme.variants[variant] <mask> : componentTheme.variants[variant]({ <mask> theme, <mask> ...combinedProps, <mask> ...colorModeProps, <mask> }); <mask> <mask> hasVariant = true; <mask> //@ts-ignore </s> feat: pseudo props combination, simplification and resolution </s> remove ...combinedProps, </s> add ...flattenProps, </s> remove hasVariant = true; </s> add pseudoPropsResolver({ props: componentVariantProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); // We remove variant from original props if we found it in the componentTheme </s> remove // Resolving component's baseStyle </s> add // NOTE: Resoloving baseStyle </s> remove sizeResolved = true; </s> add </s> remove ...combinedProps, </s> add ...flattenProps,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
pseudoPropsResolver({ props: componentVariantProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); // We remove variant from original props if we found it in the componentTheme
<mask> ...combinedProps, <mask> ...colorModeProps, <mask> }); <mask> <mask> hasVariant = true; <mask> //@ts-ignore <mask> incomingProps.variant = undefined; <mask> } <mask> <mask> // To handle responsive size prop. i.e. {sm:"x"} | [x, y] </s> feat: pseudo props combination, simplification and resolution </s> remove incomingProps.variant = undefined; </s> add flattenProps.variant = undefined; </s> remove // To handle responsive size prop. i.e. {sm:"x"} | [x, y] </s> add // NOTE: Resolving size </s> remove combinedProps.size, </s> add flattenProps.size, </s> remove ...combinedProps, </s> add ...flattenProps, </s> remove // To handle responsive type variant. i.e. {sm:"x"} | [x, y] </s> add // NOTE: Resolving variants
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
flattenProps.variant = undefined;
<mask> }); <mask> <mask> hasVariant = true; <mask> //@ts-ignore <mask> incomingProps.variant = undefined; <mask> } <mask> <mask> // To handle responsive size prop. i.e. {sm:"x"} | [x, y] <mask> const size = resolveValueWithBreakpoint( <mask> combinedProps.size, </s> feat: pseudo props combination, simplification and resolution </s> remove // To handle responsive size prop. i.e. {sm:"x"} | [x, y] </s> add // NOTE: Resolving size </s> remove combinedProps.size, </s> add flattenProps.size, </s> remove hasVariant = true; </s> add pseudoPropsResolver({ props: componentVariantProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); // We remove variant from original props if we found it in the componentTheme </s> remove // To handle responsive type variant. i.e. {sm:"x"} | [x, y] </s> add // NOTE: Resolving variants </s> remove combinedProps.variant, </s> add flattenProps.variant,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
// NOTE: Resolving size
<mask> //@ts-ignore <mask> incomingProps.variant = undefined; <mask> } <mask> <mask> // To handle responsive size prop. i.e. {sm:"x"} | [x, y] <mask> const size = resolveValueWithBreakpoint( <mask> combinedProps.size, <mask> currentBreakpoint, <mask> 'size' <mask> ); </s> feat: pseudo props combination, simplification and resolution </s> remove incomingProps.variant = undefined; </s> add flattenProps.variant = undefined; </s> remove combinedProps.size, </s> add flattenProps.size, </s> remove hasVariant = true; </s> add pseudoPropsResolver({ props: componentVariantProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); // We remove variant from original props if we found it in the componentTheme </s> remove combinedProps.variant, </s> add flattenProps.variant, </s> remove // To handle responsive type variant. i.e. {sm:"x"} | [x, y] </s> add // NOTE: Resolving variants
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
flattenProps.size,
<mask> } <mask> <mask> // To handle responsive size prop. i.e. {sm:"x"} | [x, y] <mask> const size = resolveValueWithBreakpoint( <mask> combinedProps.size, <mask> currentBreakpoint, <mask> 'size' <mask> ); <mask> <mask> let componentSizeProps: any = {}; </s> feat: pseudo props combination, simplification and resolution </s> remove // To handle responsive size prop. i.e. {sm:"x"} | [x, y] </s> add // NOTE: Resolving size </s> remove incomingProps.variant = undefined; </s> add flattenProps.variant = undefined; </s> remove combinedProps.variant, </s> add flattenProps.variant, </s> remove // To handle responsive type variant. i.e. {sm:"x"} | [x, y] </s> add // NOTE: Resolving variants </s> remove hasVariant = true; </s> add pseudoPropsResolver({ props: componentVariantProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); // We remove variant from original props if we found it in the componentTheme
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
let componentSizeProps = {};
<mask> currentBreakpoint, <mask> 'size' <mask> ); <mask> <mask> let componentSizeProps: any = {}; <mask> // Extracting props from size <mask> if (size && componentTheme.sizes && componentTheme.sizes[size]) { <mask> // Type - sizes: {lg: 1}. Refer icon theme <mask> if ( <mask> typeof componentTheme.sizes[size] === 'string' || </s> feat: pseudo props combination, simplification and resolution </s> remove ...combinedProps, </s> add ...flattenProps, </s> remove combinedProps.size, </s> add flattenProps.size, </s> remove // Type - sizes: { size: 4 }. Refer Images if (!componentSizeProps.size) { sizeResolved = true; } </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
flattenProps.size = undefined;
<mask> typeof componentTheme.sizes[size] === 'string' || <mask> typeof componentTheme.sizes[size] === 'number' <mask> ) { <mask> //@ts-ignore <mask> componentSizeProps.size = componentTheme.sizes[size]; <mask> } <mask> // Type - sizes: (props) => ({lg: {px: 1}}). Refer heading theme </s> feat: pseudo props combination, simplification and resolution </s> remove ...combinedProps, </s> add ...flattenProps, </s> remove let componentSizeProps: any = {}; </s> add let componentSizeProps = {}; </s> remove sizeResolved = true; </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
flattenProps.size = undefined;
<mask> // Type - sizes: (props) => ({lg: {px: 1}}). Refer heading theme <mask> else if (typeof componentTheme.sizes[size] === 'function') { <mask> componentSizeProps = componentTheme.sizes[size]({ <mask> theme, <mask> ...flattenProps, <mask> ...colorModeProps, </s> feat: pseudo props combination, simplification and resolution </s> remove ...combinedProps, </s> add ...flattenProps, </s> remove sizeResolved = true; </s> add </s> remove let componentSizeProps: any = {}; </s> add let componentSizeProps = {};
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
...flattenProps,
<mask> // Type - sizes: (props) => ({lg: {px: 1}}). Refer heading theme <mask> else if (typeof componentTheme.sizes[size] === 'function') { <mask> componentSizeProps = componentTheme.sizes[size]({ <mask> theme, <mask> ...combinedProps, <mask> ...colorModeProps, <mask> }); <mask> sizeResolved = true; <mask> } <mask> // Type - sizes: {lg: {px: 1}}. Refer button theme </s> feat: pseudo props combination, simplification and resolution </s> remove sizeResolved = true; </s> add </s> remove // Type - sizes: { size: 4 }. Refer Images if (!componentSizeProps.size) { sizeResolved = true; } </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
<mask> theme, <mask> ...combinedProps, <mask> ...colorModeProps, <mask> }); <mask> sizeResolved = true; <mask> } <mask> // Type - sizes: {lg: {px: 1}}. Refer button theme <mask> else { <mask> componentSizeProps = componentTheme.sizes[size]; <mask> // Type - sizes: { size: 4 }. Refer Images </s> feat: pseudo props combination, simplification and resolution </s> remove // Type - sizes: { size: 4 }. Refer Images if (!componentSizeProps.size) { sizeResolved = true; } </s> add </s> remove ...combinedProps, </s> add ...flattenProps,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
flattenProps.size = undefined;
<mask> } <mask> // Type - sizes: {lg: {px: 1}}. Refer button theme <mask> else { <mask> componentSizeProps = componentTheme.sizes[size]; <mask> } <mask> <mask> pseudoPropsResolver({ <mask> props: componentSizeProps, </s> feat: pseudo props combination, simplification and resolution </s> remove sizeResolved = true; </s> add </s> remove // Type - sizes: { size: 4 }. Refer Images if (!componentSizeProps.size) { sizeResolved = true; } </s> add </s> remove ...combinedProps, </s> add ...flattenProps,
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
<mask> } <mask> // Type - sizes: {lg: {px: 1}}. Refer button theme <mask> else { <mask> componentSizeProps = componentTheme.sizes[size]; <mask> // Type - sizes: { size: 4 }. Refer Images <mask> if (!componentSizeProps.size) { <mask> sizeResolved = true; <mask> } <mask> } <mask> // @ts-ignore - Mutating incoming size for now. Fix it after new styled system is implemented <mask> incomingProps.size = undefined; <mask> } <mask> </s> feat: pseudo props combination, simplification and resolution </s> remove sizeResolved = true; </s> add </s> remove // @ts-ignore - Mutating incoming size for now. Fix it after new styled system is implemented incomingProps.size = undefined; } </s> add </s> remove ...combinedProps, </s> add ...flattenProps,
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
<mask> if (!componentSizeProps.size) { <mask> sizeResolved = true; <mask> } <mask> } <mask> // @ts-ignore - Mutating incoming size for now. Fix it after new styled system is implemented <mask> incomingProps.size = undefined; <mask> } <mask> <mask> const componentMergedTheme = merge( <mask> {}, <mask> componentTheme.defaultProps, <mask> componentBaseStyle, </s> feat: pseudo props combination, simplification and resolution </s> remove // Type - sizes: { size: 4 }. Refer Images if (!componentSizeProps.size) { sizeResolved = true; } </s> add </s> remove const componentMergedTheme = merge( {}, componentTheme.defaultProps, componentBaseStyle, componentVariantProps, componentSizeProps ); if (sizeResolved) { // We remove size from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.size; } if (hasVariant) { // We remove variant from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.variant; } const componentThemeIntegratedProps = merge( {}, useColorModeProps(usePlatformProps(componentMergedTheme)), useColorModeProps(usePlatformProps(incomingProps)) ); return componentThemeIntegratedProps; }; /** * @summary Translates the prop with it's appropriate value. * @description NOTE: Avoid passo JSX and functions. * @arg {any} props - Props object with should be translated. * @arg {any} theme - Theme based on which props will be translated. * @arg {object} colorModeProps - `colorMode` object. * @arg {object} componentTheme - Theme for specific components. * @arg {object} windowWidth - Current width of the window / screen. * @returns {object} Translated props object. */ // Todo - move responsive calculation in styled system const propTranslator = ({ props, theme, colorModeProps, componentTheme, currentBreakpoint, }: { props: any; theme: any; colorModeProps: object; componentTheme: object; currentBreakpoint: number; }) => { let translatedProps: any = {}; for (const property in props) { // STEP 1 - Responsive prop check and resolve if (property.startsWith('_')) { // STEP 1.a - Resolving _ porps const nestedTranslatedProps = propTranslator({ props: props[property], theme, colorModeProps, componentTheme, currentBreakpoint, }); translatedProps[property] = nestedTranslatedProps; } else if (themePropertyMap[property]) { // STEP 1.b Resolving themed props const propValues = extractPropertyFromFunction( property, props, theme, componentTheme ); // NOTE: Direct value identified. if (typeof propValues === 'string' || typeof propValues === 'number') { translatedProps[property] = propValues; // NOTE: Nested object (excluding _props) (To be specific, only for key exist in themePropertyMap) } else if (!isNil(propValues)) { // TODO: This setion new needs to handle stuff differently for (let nestedProp in propValues) { translatedProps[nestedProp] = get( theme, `${themePropertyMap[nestedProp]}.${propValues[nestedProp]}`, propValues[nestedProp] ); } delete translatedProps[property]; // Manually handeling shadow props (example of Mapped tokens) } else if (property === 'shadow') { const resolveValueWithBreakpointValue = resolveValueWithBreakpoint( props.shadow, currentBreakpoint, property ); let shadowProps = theme[themePropertyMap[property]](colorModeProps)[ resolveValueWithBreakpointValue ]; translatedProps.style = merge({}, shadowProps, props.style); delete translatedProps[property]; } else { translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } } else { // STEP 1.d Resolving Direct Values translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } </s> add pseudoPropsResolver({ props: componentSizeProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); </s> remove // Shallow merge defaultProps and incoming props to pass them in baseStyle, variants and sizes const combinedProps: any = { ...componentTheme.defaultProps, ...incomingProps, }; </s> add const componentTheme = get(theme, `components.${component}`, {}); const windowWidth = useWindowDimensions()?.width; const currentBreakpoint = React.useMemo( () => getClosestBreakpoint(theme.breakpoints, windowWidth), [windowWidth, theme.breakpoints] ); // STEP 1: combine default props and incoming props const incomingWithDefaultProps = merge( {}, componentTheme.defaultProps || {}, cleanIncomingProps ); // STEP 2: flatten them pseudoPropsResolver({ props: incomingWithDefaultProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); // STEP 3: Pass it to baseStyle, then variant and then size and resolve them. </s> remove hasVariant = true; </s> add pseudoPropsResolver({ props: componentVariantProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); // We remove variant from original props if we found it in the componentTheme </s> remove incomingProps.variant = undefined; </s> add flattenProps.variant = undefined;
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
pseudoPropsResolver({ props: componentSizeProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, });
<mask> // @ts-ignore - Mutating incoming size for now. Fix it after new styled system is implemented <mask> incomingProps.size = undefined; <mask> } <mask> <mask> const componentMergedTheme = merge( <mask> {}, <mask> componentTheme.defaultProps, <mask> componentBaseStyle, <mask> componentVariantProps, <mask> componentSizeProps <mask> ); <mask> <mask> if (sizeResolved) { <mask> // We remove size from original props if we found it in the componentTheme <mask> // @ts-ignore <mask> delete componentMergedTheme.size; <mask> } <mask> <mask> if (hasVariant) { <mask> // We remove variant from original props if we found it in the componentTheme <mask> // @ts-ignore <mask> delete componentMergedTheme.variant; <mask> } <mask> <mask> const componentThemeIntegratedProps = merge( <mask> {}, <mask> useColorModeProps(usePlatformProps(componentMergedTheme)), <mask> useColorModeProps(usePlatformProps(incomingProps)) <mask> ); <mask> <mask> return componentThemeIntegratedProps; <mask> }; <mask> <mask> /** <mask> * @summary Translates the prop with it's appropriate value. <mask> * @description NOTE: Avoid passo JSX and functions. <mask> * @arg {any} props - Props object with should be translated. <mask> * @arg {any} theme - Theme based on which props will be translated. <mask> * @arg {object} colorModeProps - `colorMode` object. <mask> * @arg {object} componentTheme - Theme for specific components. <mask> * @arg {object} windowWidth - Current width of the window / screen. <mask> * @returns {object} Translated props object. <mask> */ <mask> // Todo - move responsive calculation in styled system <mask> const propTranslator = ({ <mask> props, <mask> theme, <mask> colorModeProps, <mask> componentTheme, <mask> currentBreakpoint, <mask> }: { <mask> props: any; <mask> theme: any; <mask> colorModeProps: object; <mask> componentTheme: object; <mask> currentBreakpoint: number; <mask> }) => { <mask> let translatedProps: any = {}; <mask> for (const property in props) { <mask> // STEP 1 - Responsive prop check and resolve <mask> if (property.startsWith('_')) { <mask> // STEP 1.a - Resolving _ porps <mask> const nestedTranslatedProps = propTranslator({ <mask> props: props[property], <mask> theme, <mask> colorModeProps, <mask> componentTheme, <mask> currentBreakpoint, <mask> }); <mask> translatedProps[property] = nestedTranslatedProps; <mask> } else if (themePropertyMap[property]) { <mask> // STEP 1.b Resolving themed props <mask> const propValues = extractPropertyFromFunction( <mask> property, <mask> props, <mask> theme, <mask> componentTheme <mask> ); <mask> <mask> // NOTE: Direct value identified. <mask> if (typeof propValues === 'string' || typeof propValues === 'number') { <mask> translatedProps[property] = propValues; <mask> // NOTE: Nested object (excluding _props) (To be specific, only for key exist in themePropertyMap) <mask> } else if (!isNil(propValues)) { <mask> // TODO: This setion new needs to handle stuff differently <mask> for (let nestedProp in propValues) { <mask> translatedProps[nestedProp] = get( <mask> theme, <mask> `${themePropertyMap[nestedProp]}.${propValues[nestedProp]}`, <mask> propValues[nestedProp] <mask> ); <mask> } <mask> delete translatedProps[property]; <mask> // Manually handeling shadow props (example of Mapped tokens) <mask> } else if (property === 'shadow') { <mask> const resolveValueWithBreakpointValue = resolveValueWithBreakpoint( <mask> props.shadow, <mask> currentBreakpoint, <mask> property <mask> ); <mask> let shadowProps = theme[themePropertyMap[property]](colorModeProps)[ <mask> resolveValueWithBreakpointValue <mask> ]; <mask> translatedProps.style = merge({}, shadowProps, props.style); <mask> delete translatedProps[property]; <mask> } else { <mask> translatedProps[property] = resolveValueWithBreakpoint( <mask> props[property], <mask> currentBreakpoint, <mask> property <mask> ); <mask> } <mask> } else { <mask> // STEP 1.d Resolving Direct Values <mask> translatedProps[property] = resolveValueWithBreakpoint( <mask> props[property], <mask> currentBreakpoint, <mask> property <mask> ); <mask> } <mask> } <mask> <mask> return translatedProps; <mask> }; <mask> </s> feat: pseudo props combination, simplification and resolution </s> remove /** * @summary Combines provided porps with component's theme props and resloves them. * @description NOTE: Avoid passing JSX and functions. * @arg {string} component - Name of the component. * @arg {object} incomingProps - Props passed by the user. * @returns {object} Resolved props. */ export function usePropsResolution( component: string, incomingProps: any, config?: any ) { const [ignoredProps, cleanIncomingProps] = extractInObject( incomingProps, ['children', 'onPress', 'icon', 'onOpen', 'onClose'].concat( config?.ignoreProps || [] ) ); const { theme } = useNativeBase(); const colorModeProps = useColorMode(); const componentTheme = get(theme, `components.${component}`, {}); const notComponentTheme = omit(theme, ['components']); const currentBreakpoint = useNativeBaseConfig('usePropsResolution') .currentBreakpoint; // TODO: using usePlatformProps here to simplify the component theme. So that on on component level it shouldn't have to maintain the Specificity. const componentThemeIntegratedProps = useSimplifyComponentTheme( notComponentTheme, componentTheme, cleanIncomingProps, colorModeProps, currentBreakpoint ); // const platformSpecificProps = usePlatformProps(componentThemeIntegratedProps); // NOTE: sperating removing props while should be translated </s> add // STEP 5: linear Grad and contrastText </s> remove // @ts-ignore - Mutating incoming size for now. Fix it after new styled system is implemented incomingProps.size = undefined; } </s> add </s> remove * @summary Resolves, simplify and merge components specific theme. * @description The function extract and execute component specifc theme (i.e., `defaultProps`, `baseStyle` and `variants`) and returns a merged and simplified object. * @arg {string} theme - Theme object of NativeBase (without component theme). * @arg {object} componentTheme - Theme for specific components. </s> add * @summary Combines provided porps with component's theme props and resloves them. * @description NOTE: Avoid passing JSX and functions. * @arg {string} component - Name of the component. </s> remove import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; import { useNativeBaseConfig } from '../../core/NativeBaseContext'; </s> add // TODO: have to remove as many ts-ignore as possible. const platformPropsMap = ['_ios', '_android', '_web']; const colorModePropsMap = ['_light', '_dark']; const statePropsMap = [ '_invalid', '_disabled', '_checked', '_hover', '_pressed', '_focused', ]; const pseudoPropsMap = { _web: 'web', _ios: 'ios', _android: 'android', _light: 'light', _dark: 'dark', // TODO: have to add more interactionProps and stateProps _hover: 'isHovered', _pressed: 'isPressed', _focused: 'isFocused', _disabled: 'isDisabled', _invalid: 'isInvalid', _indeterminate: 'isIndeterminate', }; const shouldResolve = ({ property, state, platform, colormode }: any) => { if (platformPropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === platform; } else if (colorModePropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === colormode; } else if (statePropsMap.includes(property)) { // @ts-ignore return state[pseudoPropsMap[property]]; } else { return false; } }; let flattenProps: any = {}; let propertyDepth: any = {}; const pseudoPropsResolver = ({ props, platform, colormode, state, currentDepth = 0, }: any) => { for (const property in props) { // @ts-ignore if (pseudoPropsMap[property]) { if (shouldResolve({ property: property, state, platform, colormode })) { pseudoPropsResolver({ props: props[property], platform, colormode, state, currentDepth: currentDepth++, }); } } else if (!property.startsWith('_')) { if ( !(propertyDepth[property] && propertyDepth[property] > currentDepth) ) { propertyDepth[property] = currentDepth; flattenProps[property] = props[property]; } } } return flattenProps; }; </s> remove // Type - sizes: { size: 4 }. Refer Images if (!componentSizeProps.size) { sizeResolved = true; } </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
// STEP 4: Merge
<mask> ); <mask> } <mask> } <mask> <mask> return translatedProps; <mask> }; <mask> <mask> /** <mask> * @summary Combines provided porps with component's theme props and resloves them. <mask> * @description NOTE: Avoid passing JSX and functions. <mask> * @arg {string} component - Name of the component. </s> feat: pseudo props combination, simplification and resolution </s> remove * @summary Resolves, simplify and merge components specific theme. * @description The function extract and execute component specifc theme (i.e., `defaultProps`, `baseStyle` and `variants`) and returns a merged and simplified object. * @arg {string} theme - Theme object of NativeBase (without component theme). * @arg {object} componentTheme - Theme for specific components. </s> add * @summary Combines provided porps with component's theme props and resloves them. * @description NOTE: Avoid passing JSX and functions. * @arg {string} component - Name of the component. </s> remove /** * @summary Combines provided porps with component's theme props and resloves them. * @description NOTE: Avoid passing JSX and functions. * @arg {string} component - Name of the component. * @arg {object} incomingProps - Props passed by the user. * @returns {object} Resolved props. */ export function usePropsResolution( component: string, incomingProps: any, config?: any ) { const [ignoredProps, cleanIncomingProps] = extractInObject( incomingProps, ['children', 'onPress', 'icon', 'onOpen', 'onClose'].concat( config?.ignoreProps || [] ) ); const { theme } = useNativeBase(); const colorModeProps = useColorMode(); const componentTheme = get(theme, `components.${component}`, {}); const notComponentTheme = omit(theme, ['components']); const currentBreakpoint = useNativeBaseConfig('usePropsResolution') .currentBreakpoint; // TODO: using usePlatformProps here to simplify the component theme. So that on on component level it shouldn't have to maintain the Specificity. const componentThemeIntegratedProps = useSimplifyComponentTheme( notComponentTheme, componentTheme, cleanIncomingProps, colorModeProps, currentBreakpoint ); // const platformSpecificProps = usePlatformProps(componentThemeIntegratedProps); // NOTE: sperating removing props while should be translated </s> add // STEP 5: linear Grad and contrastText </s> remove * @arg {object} colorModeProps - `colorMode` object. * @returns {object} Resolved component specific theme. </s> add * @arg {object} state - dependent states. * @arg {object} config - configuration for resolution. * @returns {object} Resolved and flattened props. </s> remove const componentMergedTheme = merge( {}, componentTheme.defaultProps, componentBaseStyle, componentVariantProps, componentSizeProps ); if (sizeResolved) { // We remove size from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.size; } if (hasVariant) { // We remove variant from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.variant; } const componentThemeIntegratedProps = merge( {}, useColorModeProps(usePlatformProps(componentMergedTheme)), useColorModeProps(usePlatformProps(incomingProps)) ); return componentThemeIntegratedProps; }; /** * @summary Translates the prop with it's appropriate value. * @description NOTE: Avoid passo JSX and functions. * @arg {any} props - Props object with should be translated. * @arg {any} theme - Theme based on which props will be translated. * @arg {object} colorModeProps - `colorMode` object. * @arg {object} componentTheme - Theme for specific components. * @arg {object} windowWidth - Current width of the window / screen. * @returns {object} Translated props object. */ // Todo - move responsive calculation in styled system const propTranslator = ({ props, theme, colorModeProps, componentTheme, currentBreakpoint, }: { props: any; theme: any; colorModeProps: object; componentTheme: object; currentBreakpoint: number; }) => { let translatedProps: any = {}; for (const property in props) { // STEP 1 - Responsive prop check and resolve if (property.startsWith('_')) { // STEP 1.a - Resolving _ porps const nestedTranslatedProps = propTranslator({ props: props[property], theme, colorModeProps, componentTheme, currentBreakpoint, }); translatedProps[property] = nestedTranslatedProps; } else if (themePropertyMap[property]) { // STEP 1.b Resolving themed props const propValues = extractPropertyFromFunction( property, props, theme, componentTheme ); // NOTE: Direct value identified. if (typeof propValues === 'string' || typeof propValues === 'number') { translatedProps[property] = propValues; // NOTE: Nested object (excluding _props) (To be specific, only for key exist in themePropertyMap) } else if (!isNil(propValues)) { // TODO: This setion new needs to handle stuff differently for (let nestedProp in propValues) { translatedProps[nestedProp] = get( theme, `${themePropertyMap[nestedProp]}.${propValues[nestedProp]}`, propValues[nestedProp] ); } delete translatedProps[property]; // Manually handeling shadow props (example of Mapped tokens) } else if (property === 'shadow') { const resolveValueWithBreakpointValue = resolveValueWithBreakpoint( props.shadow, currentBreakpoint, property ); let shadowProps = theme[themePropertyMap[property]](colorModeProps)[ resolveValueWithBreakpointValue ]; translatedProps.style = merge({}, shadowProps, props.style); delete translatedProps[property]; } else { translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } } else { // STEP 1.d Resolving Direct Values translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } </s> add pseudoPropsResolver({ props: componentSizeProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); </s> remove import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; import { useNativeBaseConfig } from '../../core/NativeBaseContext'; </s> add // TODO: have to remove as many ts-ignore as possible. const platformPropsMap = ['_ios', '_android', '_web']; const colorModePropsMap = ['_light', '_dark']; const statePropsMap = [ '_invalid', '_disabled', '_checked', '_hover', '_pressed', '_focused', ]; const pseudoPropsMap = { _web: 'web', _ios: 'ios', _android: 'android', _light: 'light', _dark: 'dark', // TODO: have to add more interactionProps and stateProps _hover: 'isHovered', _pressed: 'isPressed', _focused: 'isFocused', _disabled: 'isDisabled', _invalid: 'isInvalid', _indeterminate: 'isIndeterminate', }; const shouldResolve = ({ property, state, platform, colormode }: any) => { if (platformPropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === platform; } else if (colorModePropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === colormode; } else if (statePropsMap.includes(property)) { // @ts-ignore return state[pseudoPropsMap[property]]; } else { return false; } }; let flattenProps: any = {}; let propertyDepth: any = {}; const pseudoPropsResolver = ({ props, platform, colormode, state, currentDepth = 0, }: any) => { for (const property in props) { // @ts-ignore if (pseudoPropsMap[property]) { if (shouldResolve({ property: property, state, platform, colormode })) { pseudoPropsResolver({ props: props[property], platform, colormode, state, currentDepth: currentDepth++, }); } } else if (!property.startsWith('_')) { if ( !(propertyDepth[property] && propertyDepth[property] > currentDepth) ) { propertyDepth[property] = currentDepth; flattenProps[property] = props[property]; } } } return flattenProps; };
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
// STEP 5: linear Grad and contrastText
<mask> <mask> return translatedProps; <mask> }; <mask> <mask> /** <mask> * @summary Combines provided porps with component's theme props and resloves them. <mask> * @description NOTE: Avoid passing JSX and functions. <mask> * @arg {string} component - Name of the component. <mask> * @arg {object} incomingProps - Props passed by the user. <mask> * @returns {object} Resolved props. <mask> */ <mask> export function usePropsResolution( <mask> component: string, <mask> incomingProps: any, <mask> config?: any <mask> ) { <mask> const [ignoredProps, cleanIncomingProps] = extractInObject( <mask> incomingProps, <mask> ['children', 'onPress', 'icon', 'onOpen', 'onClose'].concat( <mask> config?.ignoreProps || [] <mask> ) <mask> ); <mask> <mask> const { theme } = useNativeBase(); <mask> const colorModeProps = useColorMode(); <mask> <mask> const componentTheme = get(theme, `components.${component}`, {}); <mask> const notComponentTheme = omit(theme, ['components']); <mask> <mask> const currentBreakpoint = useNativeBaseConfig('usePropsResolution') <mask> .currentBreakpoint; <mask> <mask> // TODO: using usePlatformProps here to simplify the component theme. So that on on component level it shouldn't have to maintain the Specificity. <mask> const componentThemeIntegratedProps = useSimplifyComponentTheme( <mask> notComponentTheme, <mask> componentTheme, <mask> cleanIncomingProps, <mask> colorModeProps, <mask> currentBreakpoint <mask> ); <mask> // const platformSpecificProps = usePlatformProps(componentThemeIntegratedProps); <mask> <mask> // NOTE: sperating removing props while should be translated <mask> let ignore: any = []; <mask> if ( <mask> componentThemeIntegratedProps.bg?.linearGradient || <mask> componentThemeIntegratedProps.background?.linearGradient || <mask> componentThemeIntegratedProps.bgColor?.linearGradient || </s> feat: pseudo props combination, simplification and resolution </s> remove const useSimplifyComponentTheme = ( theme: object, componentTheme: { defaultProps?: object; baseStyle?: object | Function; variants?: any | Function; sizes?: any | Function; }, incomingProps: object, colorModeProps: object, currentBreakpoint: number ) => { let sizeResolved = false; let hasVariant = false; // Resolving component's defaultProps. </s> add export function usePropsResolution( component: string, incomingProps: any, state?: any, config?: any ) { const [ignoredProps, cleanIncomingProps] = extractInObject( incomingProps, ['children', 'onPress', 'icon', 'onOpen', 'onClose'].concat( config?.ignoreProps || [] ) ); const { theme } = useNativeBase(); const colorModeProps = useColorMode(); </s> remove * @summary Resolves, simplify and merge components specific theme. * @description The function extract and execute component specifc theme (i.e., `defaultProps`, `baseStyle` and `variants`) and returns a merged and simplified object. * @arg {string} theme - Theme object of NativeBase (without component theme). * @arg {object} componentTheme - Theme for specific components. </s> add * @summary Combines provided porps with component's theme props and resloves them. * @description NOTE: Avoid passing JSX and functions. * @arg {string} component - Name of the component. </s> remove return translatedProps; }; </s> add // STEP 4: Merge </s> remove * @arg {object} colorModeProps - `colorMode` object. * @returns {object} Resolved component specific theme. </s> add * @arg {object} state - dependent states. * @arg {object} config - configuration for resolution. * @returns {object} Resolved and flattened props. </s> remove const componentMergedTheme = merge( {}, componentTheme.defaultProps, componentBaseStyle, componentVariantProps, componentSizeProps ); if (sizeResolved) { // We remove size from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.size; } if (hasVariant) { // We remove variant from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.variant; } const componentThemeIntegratedProps = merge( {}, useColorModeProps(usePlatformProps(componentMergedTheme)), useColorModeProps(usePlatformProps(incomingProps)) ); return componentThemeIntegratedProps; }; /** * @summary Translates the prop with it's appropriate value. * @description NOTE: Avoid passo JSX and functions. * @arg {any} props - Props object with should be translated. * @arg {any} theme - Theme based on which props will be translated. * @arg {object} colorModeProps - `colorMode` object. * @arg {object} componentTheme - Theme for specific components. * @arg {object} windowWidth - Current width of the window / screen. * @returns {object} Translated props object. */ // Todo - move responsive calculation in styled system const propTranslator = ({ props, theme, colorModeProps, componentTheme, currentBreakpoint, }: { props: any; theme: any; colorModeProps: object; componentTheme: object; currentBreakpoint: number; }) => { let translatedProps: any = {}; for (const property in props) { // STEP 1 - Responsive prop check and resolve if (property.startsWith('_')) { // STEP 1.a - Resolving _ porps const nestedTranslatedProps = propTranslator({ props: props[property], theme, colorModeProps, componentTheme, currentBreakpoint, }); translatedProps[property] = nestedTranslatedProps; } else if (themePropertyMap[property]) { // STEP 1.b Resolving themed props const propValues = extractPropertyFromFunction( property, props, theme, componentTheme ); // NOTE: Direct value identified. if (typeof propValues === 'string' || typeof propValues === 'number') { translatedProps[property] = propValues; // NOTE: Nested object (excluding _props) (To be specific, only for key exist in themePropertyMap) } else if (!isNil(propValues)) { // TODO: This setion new needs to handle stuff differently for (let nestedProp in propValues) { translatedProps[nestedProp] = get( theme, `${themePropertyMap[nestedProp]}.${propValues[nestedProp]}`, propValues[nestedProp] ); } delete translatedProps[property]; // Manually handeling shadow props (example of Mapped tokens) } else if (property === 'shadow') { const resolveValueWithBreakpointValue = resolveValueWithBreakpoint( props.shadow, currentBreakpoint, property ); let shadowProps = theme[themePropertyMap[property]](colorModeProps)[ resolveValueWithBreakpointValue ]; translatedProps.style = merge({}, shadowProps, props.style); delete translatedProps[property]; } else { translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } } else { // STEP 1.d Resolving Direct Values translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } </s> add pseudoPropsResolver({ props: componentSizeProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, });
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
flattenProps.bg?.linearGradient || flattenProps.background?.linearGradient || flattenProps.bgColor?.linearGradient || flattenProps.backgroundColor?.linearGradient
<mask> <mask> // NOTE: sperating removing props while should be translated <mask> let ignore: any = []; <mask> if ( <mask> componentThemeIntegratedProps.bg?.linearGradient || <mask> componentThemeIntegratedProps.background?.linearGradient || <mask> componentThemeIntegratedProps.bgColor?.linearGradient || <mask> componentThemeIntegratedProps.backgroundColor?.linearGradient <mask> ) { <mask> let bgProp = 'bg'; <mask> if (componentThemeIntegratedProps.background?.linearGradient) { <mask> bgProp = 'background'; <mask> } else if (componentThemeIntegratedProps.bgColor?.linearGradient) { </s> feat: pseudo props combination, simplification and resolution </s> remove if (componentThemeIntegratedProps.background?.linearGradient) { </s> add if (flattenProps.background?.linearGradient) { </s> remove } else if (componentThemeIntegratedProps.bgColor?.linearGradient) { </s> add } else if (flattenProps.bgColor?.linearGradient) { </s> remove /** * @summary Combines provided porps with component's theme props and resloves them. * @description NOTE: Avoid passing JSX and functions. * @arg {string} component - Name of the component. * @arg {object} incomingProps - Props passed by the user. * @returns {object} Resolved props. */ export function usePropsResolution( component: string, incomingProps: any, config?: any ) { const [ignoredProps, cleanIncomingProps] = extractInObject( incomingProps, ['children', 'onPress', 'icon', 'onOpen', 'onClose'].concat( config?.ignoreProps || [] ) ); const { theme } = useNativeBase(); const colorModeProps = useColorMode(); const componentTheme = get(theme, `components.${component}`, {}); const notComponentTheme = omit(theme, ['components']); const currentBreakpoint = useNativeBaseConfig('usePropsResolution') .currentBreakpoint; // TODO: using usePlatformProps here to simplify the component theme. So that on on component level it shouldn't have to maintain the Specificity. const componentThemeIntegratedProps = useSimplifyComponentTheme( notComponentTheme, componentTheme, cleanIncomingProps, colorModeProps, currentBreakpoint ); // const platformSpecificProps = usePlatformProps(componentThemeIntegratedProps); // NOTE: sperating removing props while should be translated </s> add // STEP 5: linear Grad and contrastText </s> remove } else if (componentThemeIntegratedProps.backgroundColor?.linearGradient) { </s> add } else if (flattenProps.backgroundColor?.linearGradient) { </s> remove let componentSizeProps: any = {}; </s> add let componentSizeProps = {};
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
if (flattenProps.background?.linearGradient) {
<mask> componentThemeIntegratedProps.bgColor?.linearGradient || <mask> componentThemeIntegratedProps.backgroundColor?.linearGradient <mask> ) { <mask> let bgProp = 'bg'; <mask> if (componentThemeIntegratedProps.background?.linearGradient) { <mask> bgProp = 'background'; <mask> } else if (componentThemeIntegratedProps.bgColor?.linearGradient) { <mask> bgProp = 'bgColor'; <mask> } else if (componentThemeIntegratedProps.backgroundColor?.linearGradient) { <mask> bgProp = 'backgroundColor'; </s> feat: pseudo props combination, simplification and resolution </s> remove } else if (componentThemeIntegratedProps.bgColor?.linearGradient) { </s> add } else if (flattenProps.bgColor?.linearGradient) { </s> remove } else if (componentThemeIntegratedProps.backgroundColor?.linearGradient) { </s> add } else if (flattenProps.backgroundColor?.linearGradient) { </s> remove componentThemeIntegratedProps.bg?.linearGradient || componentThemeIntegratedProps.background?.linearGradient || componentThemeIntegratedProps.bgColor?.linearGradient || componentThemeIntegratedProps.backgroundColor?.linearGradient </s> add flattenProps.bg?.linearGradient || flattenProps.background?.linearGradient || flattenProps.bgColor?.linearGradient || flattenProps.backgroundColor?.linearGradient </s> remove componentThemeIntegratedProps[ bgProp ].linearGradient.colors = componentThemeIntegratedProps[ </s> add flattenProps[bgProp].linearGradient.colors = flattenProps[ </s> remove import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; import { useNativeBaseConfig } from '../../core/NativeBaseContext'; </s> add // TODO: have to remove as many ts-ignore as possible. const platformPropsMap = ['_ios', '_android', '_web']; const colorModePropsMap = ['_light', '_dark']; const statePropsMap = [ '_invalid', '_disabled', '_checked', '_hover', '_pressed', '_focused', ]; const pseudoPropsMap = { _web: 'web', _ios: 'ios', _android: 'android', _light: 'light', _dark: 'dark', // TODO: have to add more interactionProps and stateProps _hover: 'isHovered', _pressed: 'isPressed', _focused: 'isFocused', _disabled: 'isDisabled', _invalid: 'isInvalid', _indeterminate: 'isIndeterminate', }; const shouldResolve = ({ property, state, platform, colormode }: any) => { if (platformPropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === platform; } else if (colorModePropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === colormode; } else if (statePropsMap.includes(property)) { // @ts-ignore return state[pseudoPropsMap[property]]; } else { return false; } }; let flattenProps: any = {}; let propertyDepth: any = {}; const pseudoPropsResolver = ({ props, platform, colormode, state, currentDepth = 0, }: any) => { for (const property in props) { // @ts-ignore if (pseudoPropsMap[property]) { if (shouldResolve({ property: property, state, platform, colormode })) { pseudoPropsResolver({ props: props[property], platform, colormode, state, currentDepth: currentDepth++, }); } } else if (!property.startsWith('_')) { if ( !(propertyDepth[property] && propertyDepth[property] > currentDepth) ) { propertyDepth[property] = currentDepth; flattenProps[property] = props[property]; } } } return flattenProps; };
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
} else if (flattenProps.bgColor?.linearGradient) {
<mask> ) { <mask> let bgProp = 'bg'; <mask> if (componentThemeIntegratedProps.background?.linearGradient) { <mask> bgProp = 'background'; <mask> } else if (componentThemeIntegratedProps.bgColor?.linearGradient) { <mask> bgProp = 'bgColor'; <mask> } else if (componentThemeIntegratedProps.backgroundColor?.linearGradient) { <mask> bgProp = 'backgroundColor'; <mask> } <mask> componentThemeIntegratedProps[ </s> feat: pseudo props combination, simplification and resolution </s> remove if (componentThemeIntegratedProps.background?.linearGradient) { </s> add if (flattenProps.background?.linearGradient) { </s> remove } else if (componentThemeIntegratedProps.backgroundColor?.linearGradient) { </s> add } else if (flattenProps.backgroundColor?.linearGradient) { </s> remove componentThemeIntegratedProps[ bgProp ].linearGradient.colors = componentThemeIntegratedProps[ </s> add flattenProps[bgProp].linearGradient.colors = flattenProps[ </s> remove componentThemeIntegratedProps.bg?.linearGradient || componentThemeIntegratedProps.background?.linearGradient || componentThemeIntegratedProps.bgColor?.linearGradient || componentThemeIntegratedProps.backgroundColor?.linearGradient </s> add flattenProps.bg?.linearGradient || flattenProps.background?.linearGradient || flattenProps.bgColor?.linearGradient || flattenProps.backgroundColor?.linearGradient </s> remove import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; import { useNativeBaseConfig } from '../../core/NativeBaseContext'; </s> add // TODO: have to remove as many ts-ignore as possible. const platformPropsMap = ['_ios', '_android', '_web']; const colorModePropsMap = ['_light', '_dark']; const statePropsMap = [ '_invalid', '_disabled', '_checked', '_hover', '_pressed', '_focused', ]; const pseudoPropsMap = { _web: 'web', _ios: 'ios', _android: 'android', _light: 'light', _dark: 'dark', // TODO: have to add more interactionProps and stateProps _hover: 'isHovered', _pressed: 'isPressed', _focused: 'isFocused', _disabled: 'isDisabled', _invalid: 'isInvalid', _indeterminate: 'isIndeterminate', }; const shouldResolve = ({ property, state, platform, colormode }: any) => { if (platformPropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === platform; } else if (colorModePropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === colormode; } else if (statePropsMap.includes(property)) { // @ts-ignore return state[pseudoPropsMap[property]]; } else { return false; } }; let flattenProps: any = {}; let propertyDepth: any = {}; const pseudoPropsResolver = ({ props, platform, colormode, state, currentDepth = 0, }: any) => { for (const property in props) { // @ts-ignore if (pseudoPropsMap[property]) { if (shouldResolve({ property: property, state, platform, colormode })) { pseudoPropsResolver({ props: props[property], platform, colormode, state, currentDepth: currentDepth++, }); } } else if (!property.startsWith('_')) { if ( !(propertyDepth[property] && propertyDepth[property] > currentDepth) ) { propertyDepth[property] = currentDepth; flattenProps[property] = props[property]; } } } return flattenProps; };
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
} else if (flattenProps.backgroundColor?.linearGradient) {
<mask> if (componentThemeIntegratedProps.background?.linearGradient) { <mask> bgProp = 'background'; <mask> } else if (componentThemeIntegratedProps.bgColor?.linearGradient) { <mask> bgProp = 'bgColor'; <mask> } else if (componentThemeIntegratedProps.backgroundColor?.linearGradient) { <mask> bgProp = 'backgroundColor'; <mask> } <mask> componentThemeIntegratedProps[ <mask> bgProp <mask> ].linearGradient.colors = componentThemeIntegratedProps[ </s> feat: pseudo props combination, simplification and resolution </s> remove } else if (componentThemeIntegratedProps.bgColor?.linearGradient) { </s> add } else if (flattenProps.bgColor?.linearGradient) { </s> remove if (componentThemeIntegratedProps.background?.linearGradient) { </s> add if (flattenProps.background?.linearGradient) { </s> remove componentThemeIntegratedProps[ bgProp ].linearGradient.colors = componentThemeIntegratedProps[ </s> add flattenProps[bgProp].linearGradient.colors = flattenProps[ </s> remove componentThemeIntegratedProps.bg?.linearGradient || componentThemeIntegratedProps.background?.linearGradient || componentThemeIntegratedProps.bgColor?.linearGradient || componentThemeIntegratedProps.backgroundColor?.linearGradient </s> add flattenProps.bg?.linearGradient || flattenProps.background?.linearGradient || flattenProps.bgColor?.linearGradient || flattenProps.backgroundColor?.linearGradient </s> remove import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; import { useNativeBaseConfig } from '../../core/NativeBaseContext'; </s> add // TODO: have to remove as many ts-ignore as possible. const platformPropsMap = ['_ios', '_android', '_web']; const colorModePropsMap = ['_light', '_dark']; const statePropsMap = [ '_invalid', '_disabled', '_checked', '_hover', '_pressed', '_focused', ]; const pseudoPropsMap = { _web: 'web', _ios: 'ios', _android: 'android', _light: 'light', _dark: 'dark', // TODO: have to add more interactionProps and stateProps _hover: 'isHovered', _pressed: 'isPressed', _focused: 'isFocused', _disabled: 'isDisabled', _invalid: 'isInvalid', _indeterminate: 'isIndeterminate', }; const shouldResolve = ({ property, state, platform, colormode }: any) => { if (platformPropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === platform; } else if (colorModePropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === colormode; } else if (statePropsMap.includes(property)) { // @ts-ignore return state[pseudoPropsMap[property]]; } else { return false; } }; let flattenProps: any = {}; let propertyDepth: any = {}; const pseudoPropsResolver = ({ props, platform, colormode, state, currentDepth = 0, }: any) => { for (const property in props) { // @ts-ignore if (pseudoPropsMap[property]) { if (shouldResolve({ property: property, state, platform, colormode })) { pseudoPropsResolver({ props: props[property], platform, colormode, state, currentDepth: currentDepth++, }); } } else if (!property.startsWith('_')) { if ( !(propertyDepth[property] && propertyDepth[property] > currentDepth) ) { propertyDepth[property] = currentDepth; flattenProps[property] = props[property]; } } } return flattenProps; };
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
flattenProps[bgProp].linearGradient.colors = flattenProps[
<mask> bgProp = 'bgColor'; <mask> } else if (componentThemeIntegratedProps.backgroundColor?.linearGradient) { <mask> bgProp = 'backgroundColor'; <mask> } <mask> componentThemeIntegratedProps[ <mask> bgProp <mask> ].linearGradient.colors = componentThemeIntegratedProps[ <mask> bgProp <mask> ].linearGradient.colors.map((color: string) => { <mask> return get(theme.colors, color, color); <mask> }); <mask> ignore = ['bg', 'background', 'backgroundColor', 'bgColor']; </s> feat: pseudo props combination, simplification and resolution </s> remove } else if (componentThemeIntegratedProps.backgroundColor?.linearGradient) { </s> add } else if (flattenProps.backgroundColor?.linearGradient) { </s> remove } else if (componentThemeIntegratedProps.bgColor?.linearGradient) { </s> add } else if (flattenProps.bgColor?.linearGradient) { </s> remove if (componentThemeIntegratedProps.background?.linearGradient) { </s> add if (flattenProps.background?.linearGradient) { </s> remove const [gradientProps, nonGradientProps] = extractInObject( componentThemeIntegratedProps, ignore ); let translatedProps = nonGradientProps; if (!shouldEnableNewStyledSystemImplementation) { translatedProps = propTranslator({ props: nonGradientProps, theme: notComponentTheme, colorModeProps, componentTheme, currentBreakpoint, }); } </s> add const [gradientProps] = extractInObject(flattenProps, ignore); </s> remove componentThemeIntegratedProps.bg?.linearGradient || componentThemeIntegratedProps.background?.linearGradient || componentThemeIntegratedProps.bgColor?.linearGradient || componentThemeIntegratedProps.backgroundColor?.linearGradient </s> add flattenProps.bg?.linearGradient || flattenProps.background?.linearGradient || flattenProps.bgColor?.linearGradient || flattenProps.backgroundColor?.linearGradient
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
const [gradientProps] = extractInObject(flattenProps, ignore);
<mask> }); <mask> ignore = ['bg', 'background', 'backgroundColor', 'bgColor']; <mask> } <mask> // NOTE: seprating bg props when linearGardiant is available <mask> const [gradientProps, nonGradientProps] = extractInObject( <mask> componentThemeIntegratedProps, <mask> ignore <mask> ); <mask> <mask> let translatedProps = nonGradientProps; <mask> <mask> if (!shouldEnableNewStyledSystemImplementation) { <mask> translatedProps = propTranslator({ <mask> props: nonGradientProps, <mask> theme: notComponentTheme, <mask> colorModeProps, <mask> componentTheme, <mask> currentBreakpoint, <mask> }); <mask> } <mask> <mask> let bgColor = <mask> translatedProps.bg ?? <mask> translatedProps.backgroundColor ?? <mask> translatedProps.bgColor; </s> feat: pseudo props combination, simplification and resolution </s> remove translatedProps.bg ?? translatedProps.backgroundColor ?? translatedProps.bgColor; </s> add flattenProps.bg ?? flattenProps.backgroundColor ?? flattenProps.bgColor; </s> remove componentThemeIntegratedProps[ bgProp ].linearGradient.colors = componentThemeIntegratedProps[ </s> add flattenProps[bgProp].linearGradient.colors = flattenProps[ </s> remove const componentMergedTheme = merge( {}, componentTheme.defaultProps, componentBaseStyle, componentVariantProps, componentSizeProps ); if (sizeResolved) { // We remove size from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.size; } if (hasVariant) { // We remove variant from original props if we found it in the componentTheme // @ts-ignore delete componentMergedTheme.variant; } const componentThemeIntegratedProps = merge( {}, useColorModeProps(usePlatformProps(componentMergedTheme)), useColorModeProps(usePlatformProps(incomingProps)) ); return componentThemeIntegratedProps; }; /** * @summary Translates the prop with it's appropriate value. * @description NOTE: Avoid passo JSX and functions. * @arg {any} props - Props object with should be translated. * @arg {any} theme - Theme based on which props will be translated. * @arg {object} colorModeProps - `colorMode` object. * @arg {object} componentTheme - Theme for specific components. * @arg {object} windowWidth - Current width of the window / screen. * @returns {object} Translated props object. */ // Todo - move responsive calculation in styled system const propTranslator = ({ props, theme, colorModeProps, componentTheme, currentBreakpoint, }: { props: any; theme: any; colorModeProps: object; componentTheme: object; currentBreakpoint: number; }) => { let translatedProps: any = {}; for (const property in props) { // STEP 1 - Responsive prop check and resolve if (property.startsWith('_')) { // STEP 1.a - Resolving _ porps const nestedTranslatedProps = propTranslator({ props: props[property], theme, colorModeProps, componentTheme, currentBreakpoint, }); translatedProps[property] = nestedTranslatedProps; } else if (themePropertyMap[property]) { // STEP 1.b Resolving themed props const propValues = extractPropertyFromFunction( property, props, theme, componentTheme ); // NOTE: Direct value identified. if (typeof propValues === 'string' || typeof propValues === 'number') { translatedProps[property] = propValues; // NOTE: Nested object (excluding _props) (To be specific, only for key exist in themePropertyMap) } else if (!isNil(propValues)) { // TODO: This setion new needs to handle stuff differently for (let nestedProp in propValues) { translatedProps[nestedProp] = get( theme, `${themePropertyMap[nestedProp]}.${propValues[nestedProp]}`, propValues[nestedProp] ); } delete translatedProps[property]; // Manually handeling shadow props (example of Mapped tokens) } else if (property === 'shadow') { const resolveValueWithBreakpointValue = resolveValueWithBreakpoint( props.shadow, currentBreakpoint, property ); let shadowProps = theme[themePropertyMap[property]](colorModeProps)[ resolveValueWithBreakpointValue ]; translatedProps.style = merge({}, shadowProps, props.style); delete translatedProps[property]; } else { translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } } else { // STEP 1.d Resolving Direct Values translatedProps[property] = resolveValueWithBreakpoint( props[property], currentBreakpoint, property ); } </s> add pseudoPropsResolver({ props: componentSizeProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); </s> remove /** * @summary Combines provided porps with component's theme props and resloves them. * @description NOTE: Avoid passing JSX and functions. * @arg {string} component - Name of the component. * @arg {object} incomingProps - Props passed by the user. * @returns {object} Resolved props. */ export function usePropsResolution( component: string, incomingProps: any, config?: any ) { const [ignoredProps, cleanIncomingProps] = extractInObject( incomingProps, ['children', 'onPress', 'icon', 'onOpen', 'onClose'].concat( config?.ignoreProps || [] ) ); const { theme } = useNativeBase(); const colorModeProps = useColorMode(); const componentTheme = get(theme, `components.${component}`, {}); const notComponentTheme = omit(theme, ['components']); const currentBreakpoint = useNativeBaseConfig('usePropsResolution') .currentBreakpoint; // TODO: using usePlatformProps here to simplify the component theme. So that on on component level it shouldn't have to maintain the Specificity. const componentThemeIntegratedProps = useSimplifyComponentTheme( notComponentTheme, componentTheme, cleanIncomingProps, colorModeProps, currentBreakpoint ); // const platformSpecificProps = usePlatformProps(componentThemeIntegratedProps); // NOTE: sperating removing props while should be translated </s> add // STEP 5: linear Grad and contrastText </s> remove componentThemeIntegratedProps.bg?.linearGradient || componentThemeIntegratedProps.background?.linearGradient || componentThemeIntegratedProps.bgColor?.linearGradient || componentThemeIntegratedProps.backgroundColor?.linearGradient </s> add flattenProps.bg?.linearGradient || flattenProps.background?.linearGradient || flattenProps.bgColor?.linearGradient || flattenProps.backgroundColor?.linearGradient
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
flattenProps.bg ?? flattenProps.backgroundColor ?? flattenProps.bgColor;
<mask> }); <mask> } <mask> <mask> let bgColor = <mask> translatedProps.bg ?? <mask> translatedProps.backgroundColor ?? <mask> translatedProps.bgColor; <mask> <mask> const contrastTextColor = useContrastText( <mask> bgColor, <mask> translatedProps?._text?.color <mask> ); </s> feat: pseudo props combination, simplification and resolution </s> remove const [gradientProps, nonGradientProps] = extractInObject( componentThemeIntegratedProps, ignore ); let translatedProps = nonGradientProps; if (!shouldEnableNewStyledSystemImplementation) { translatedProps = propTranslator({ props: nonGradientProps, theme: notComponentTheme, colorModeProps, componentTheme, currentBreakpoint, }); } </s> add const [gradientProps] = extractInObject(flattenProps, ignore); </s> remove translatedProps?._text?.color </s> add flattenProps?._text?.color </s> remove translatedProps._text = contrastTextColor </s> add flattenProps._text = contrastTextColor </s> remove ...translatedProps._text, </s> add ...flattenProps._text, </s> remove combinedProps.variant, </s> add flattenProps.variant,
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
flattenProps?._text?.color
<mask> translatedProps.bgColor; <mask> <mask> const contrastTextColor = useContrastText( <mask> bgColor, <mask> translatedProps?._text?.color <mask> ); <mask> <mask> translatedProps._text = contrastTextColor <mask> ? { <mask> color: contrastTextColor, </s> feat: pseudo props combination, simplification and resolution </s> remove translatedProps._text = contrastTextColor </s> add flattenProps._text = contrastTextColor </s> remove translatedProps.bg ?? translatedProps.backgroundColor ?? translatedProps.bgColor; </s> add flattenProps.bg ?? flattenProps.backgroundColor ?? flattenProps.bgColor; </s> remove ...translatedProps._text, </s> add ...flattenProps._text, </s> remove : translatedProps._text; </s> add : flattenProps._text; </s> remove const [gradientProps, nonGradientProps] = extractInObject( componentThemeIntegratedProps, ignore ); let translatedProps = nonGradientProps; if (!shouldEnableNewStyledSystemImplementation) { translatedProps = propTranslator({ props: nonGradientProps, theme: notComponentTheme, colorModeProps, componentTheme, currentBreakpoint, }); } </s> add const [gradientProps] = extractInObject(flattenProps, ignore);
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
flattenProps._text = contrastTextColor
<mask> bgColor, <mask> translatedProps?._text?.color <mask> ); <mask> <mask> translatedProps._text = contrastTextColor <mask> ? { <mask> color: contrastTextColor, <mask> ...translatedProps._text, <mask> } <mask> : translatedProps._text; </s> feat: pseudo props combination, simplification and resolution </s> remove ...translatedProps._text, </s> add ...flattenProps._text, </s> remove translatedProps?._text?.color </s> add flattenProps?._text?.color </s> remove : translatedProps._text; </s> add : flattenProps._text; </s> remove translatedProps.bg ?? translatedProps.backgroundColor ?? translatedProps.bgColor; </s> add flattenProps.bg ?? flattenProps.backgroundColor ?? flattenProps.bgColor; </s> remove ...translatedProps, </s> add ...flattenProps,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
...flattenProps._text,
<mask> <mask> translatedProps._text = contrastTextColor <mask> ? { <mask> color: contrastTextColor, <mask> ...translatedProps._text, <mask> } <mask> : translatedProps._text; <mask> <mask> const resolvedProps = omitUndefined({ <mask> ...translatedProps, </s> feat: pseudo props combination, simplification and resolution </s> remove : translatedProps._text; </s> add : flattenProps._text; </s> remove translatedProps._text = contrastTextColor </s> add flattenProps._text = contrastTextColor </s> remove translatedProps?._text?.color </s> add flattenProps?._text?.color </s> remove ...translatedProps, </s> add ...flattenProps, </s> remove const { _hover, _pressed, _focus, _focusVisible, _disabled, ...themeProps } = usePropsResolution('Pressable', props); </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
: flattenProps._text;
<mask> ? { <mask> color: contrastTextColor, <mask> ...translatedProps._text, <mask> } <mask> : translatedProps._text; <mask> <mask> const resolvedProps = omitUndefined({ <mask> ...translatedProps, <mask> ...ignoredProps, <mask> ...gradientProps, </s> feat: pseudo props combination, simplification and resolution </s> remove ...translatedProps._text, </s> add ...flattenProps._text, </s> remove ...translatedProps, </s> add ...flattenProps, </s> remove translatedProps._text = contrastTextColor </s> add flattenProps._text = contrastTextColor </s> remove translatedProps?._text?.color </s> add flattenProps?._text?.color
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
...flattenProps,
<mask> } <mask> : translatedProps._text; <mask> <mask> const resolvedProps = omitUndefined({ <mask> ...translatedProps, <mask> ...ignoredProps, <mask> ...gradientProps, <mask> }); <mask> <mask> return resolvedProps; </s> feat: pseudo props combination, simplification and resolution </s> remove : translatedProps._text; </s> add : flattenProps._text; </s> remove ...translatedProps._text, </s> add ...flattenProps._text, </s> remove translatedProps._text = contrastTextColor </s> add flattenProps._text = contrastTextColor
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
// STEP 6: Return flattenProps = {}; propertyDepth = {};
<mask> ...gradientProps, <mask> }); <mask> <mask> return resolvedProps; <mask> } </s> feat: pseudo props combination, simplification and resolution </s> remove ...translatedProps, </s> add ...flattenProps, </s> remove : translatedProps._text; </s> add : flattenProps._text; </s> remove componentThemeIntegratedProps[ bgProp ].linearGradient.colors = componentThemeIntegratedProps[ </s> add flattenProps[bgProp].linearGradient.colors = flattenProps[ </s> remove import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; import { useNativeBaseConfig } from '../../core/NativeBaseContext'; </s> add // TODO: have to remove as many ts-ignore as possible. const platformPropsMap = ['_ios', '_android', '_web']; const colorModePropsMap = ['_light', '_dark']; const statePropsMap = [ '_invalid', '_disabled', '_checked', '_hover', '_pressed', '_focused', ]; const pseudoPropsMap = { _web: 'web', _ios: 'ios', _android: 'android', _light: 'light', _dark: 'dark', // TODO: have to add more interactionProps and stateProps _hover: 'isHovered', _pressed: 'isPressed', _focused: 'isFocused', _disabled: 'isDisabled', _invalid: 'isInvalid', _indeterminate: 'isIndeterminate', }; const shouldResolve = ({ property, state, platform, colormode }: any) => { if (platformPropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === platform; } else if (colorModePropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === colormode; } else if (statePropsMap.includes(property)) { // @ts-ignore return state[pseudoPropsMap[property]]; } else { return false; } }; let flattenProps: any = {}; let propertyDepth: any = {}; const pseudoPropsResolver = ({ props, platform, colormode, state, currentDepth = 0, }: any) => { for (const property in props) { // @ts-ignore if (pseudoPropsMap[property]) { if (shouldResolve({ property: property, state, platform, colormode })) { pseudoPropsResolver({ props: props[property], platform, colormode, state, currentDepth: currentDepth++, }); } } else if (!property.startsWith('_')) { if ( !(propertyDepth[property] && propertyDepth[property] > currentDepth) ) { propertyDepth[property] = currentDepth; flattenProps[property] = props[property]; } } } return flattenProps; };
[ "keep", "add", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/hooks/useThemeProps/usePropsResolution.tsx
import Pressable from './pressable';
<mask> import { default as NumberInput, NumberInputStepper } from './number-input'; <mask> import PinInput from './pin-input'; <mask> import Progress from './progress'; <mask> import Radio from './radio'; <mask> import Skeleton from './skeleton'; <mask> import Spinner from './spinner'; </s> feat: pseudo props combination, simplification and resolution </s> remove import omit from 'lodash.omit'; import isNil from 'lodash.isnil'; </s> add </s> remove import { usePlatformProps } from '../usePlatformProps'; import { useColorModeProps } from '../useColorModeProps'; </s> add </s> remove resolveValueWithBreakpoint, extractPropertyFromFunction, } from './utils'; import { omitUndefined, extractInObject } from './../../theme/tools'; import { themePropertyMap } from './../../theme/base'; </s> add getClosestBreakpoint, omitUndefined, extractInObject, } from '../../theme/tools';
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/theme/components/index.ts
Pressable,
<mask> NumberInput, <mask> NumberInputStepper, <mask> PinInput, <mask> ...PopoverComponentTheme, <mask> Progress, <mask> Radio, <mask> ScaleFade, <mask> Select, <mask> SelectItem, </s> feat: pseudo props combination, simplification and resolution </s> remove import { shouldEnableNewStyledSystemImplementation } from '../../utils/styled'; import { useNativeBaseConfig } from '../../core/NativeBaseContext'; </s> add // TODO: have to remove as many ts-ignore as possible. const platformPropsMap = ['_ios', '_android', '_web']; const colorModePropsMap = ['_light', '_dark']; const statePropsMap = [ '_invalid', '_disabled', '_checked', '_hover', '_pressed', '_focused', ]; const pseudoPropsMap = { _web: 'web', _ios: 'ios', _android: 'android', _light: 'light', _dark: 'dark', // TODO: have to add more interactionProps and stateProps _hover: 'isHovered', _pressed: 'isPressed', _focused: 'isFocused', _disabled: 'isDisabled', _invalid: 'isInvalid', _indeterminate: 'isIndeterminate', }; const shouldResolve = ({ property, state, platform, colormode }: any) => { if (platformPropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === platform; } else if (colorModePropsMap.includes(property)) { // @ts-ignore return pseudoPropsMap[property] === colormode; } else if (statePropsMap.includes(property)) { // @ts-ignore return state[pseudoPropsMap[property]]; } else { return false; } }; let flattenProps: any = {}; let propertyDepth: any = {}; const pseudoPropsResolver = ({ props, platform, colormode, state, currentDepth = 0, }: any) => { for (const property in props) { // @ts-ignore if (pseudoPropsMap[property]) { if (shouldResolve({ property: property, state, platform, colormode })) { pseudoPropsResolver({ props: props[property], platform, colormode, state, currentDepth: currentDepth++, }); } } else if (!property.startsWith('_')) { if ( !(propertyDepth[property] && propertyDepth[property] > currentDepth) ) { propertyDepth[property] = currentDepth; flattenProps[property] = props[property]; } } } return flattenProps; }; </s> remove hasVariant = true; </s> add pseudoPropsResolver({ props: componentVariantProps, platform: Platform.OS, colormode: colorModeProps.colorMode, state: state || {}, }); // We remove variant from original props if we found it in the componentTheme </s> remove ...combinedProps, </s> add ...flattenProps, </s> remove combinedProps.variant, </s> add flattenProps.variant,
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/daeb9d148aef8a8fcc1adae420ee93d55554150e
src/theme/components/index.ts
useColorModeValue,
<mask> Icon, <mask> StorageManager, <mask> ColorMode, <mask> } from 'native-base'; <mask> import AsyncStorage from '@react-native-async-storage/async-storage'; <mask> <mask> function MyWrapper({ children }: any) { <mask> const { colorMode, toggleColorMode } = useColorMode(); <mask> return ( </s> Removed SafeAreaView and fixes for theme background </s> remove height="100%" width="100%" </s> add </s> remove import { IColorModeProviderProps, ColorModeProvider, useColorModeValue, } from './../color-mode'; </s> add import { IColorModeProviderProps, ColorModeProvider } from './../color-mode'; </s> remove import View from '../components/primitives/View'; import SafeAreaView from '../components/primitives/SafeAreaView'; </s> add </s> remove const Wrapper = disableSafeArea ? View : SafeAreaView; </s> add // const Wrapper = disableSafeArea ? View : SafeAreaView; </s> remove <Wrapper bg={useColorModeValue(`gray.50`, `gray.800`)} flex={1}> <HybridProvider>{children}</HybridProvider> </Wrapper> </s> add <HybridProvider>{children}</HybridProvider>
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dc462f484d38c24151cd0776d7d7d66ca718b4a2
example/storybook/stories/components/Wrapper.tsx
<mask> const { colorMode, toggleColorMode } = useColorMode(); <mask> return ( <mask> <View <mask> flex={1} <mask> height="100%" <mask> width="100%" <mask> justifyContent="center" <mask> alignItems="center" <mask> > <mask> {children} <mask> <IconButton </s> Removed SafeAreaView and fixes for theme background </s> remove const Wrapper = disableSafeArea ? View : SafeAreaView; </s> add // const Wrapper = disableSafeArea ? View : SafeAreaView; </s> remove import { IColorModeProviderProps, ColorModeProvider, useColorModeValue, } from './../color-mode'; </s> add import { IColorModeProviderProps, ColorModeProvider } from './../color-mode'; </s> remove import View from '../components/primitives/View'; import SafeAreaView from '../components/primitives/SafeAreaView'; </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dc462f484d38c24151cd0776d7d7d66ca718b4a2
example/storybook/stories/components/Wrapper.tsx
bg={useColorModeValue(`gray.50`, `gray.800`)}
<mask> flex={1} <mask> justifyContent="center" <mask> alignItems="center" <mask> > <mask> {children} <mask> <IconButton <mask> position="absolute" <mask> top={5} <mask> right={5} </s> Removed SafeAreaView and fixes for theme background </s> remove height="100%" width="100%" </s> add </s> remove <Wrapper bg={useColorModeValue(`gray.50`, `gray.800`)} flex={1}> <HybridProvider>{children}</HybridProvider> </Wrapper> </s> add <HybridProvider>{children}</HybridProvider> </s> remove const Wrapper = disableSafeArea ? View : SafeAreaView; </s> add // const Wrapper = disableSafeArea ? View : SafeAreaView; </s> remove import View from '../components/primitives/View'; import SafeAreaView from '../components/primitives/SafeAreaView'; </s> add </s> remove import { IColorModeProviderProps, ColorModeProvider, useColorModeValue, } from './../color-mode'; </s> add import { IColorModeProviderProps, ColorModeProvider } from './../color-mode';
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dc462f484d38c24151cd0776d7d7d66ca718b4a2
example/storybook/stories/components/Wrapper.tsx
import { IColorModeProviderProps, ColorModeProvider } from './../color-mode';
<mask> ThemeContext, <mask> ThemeProvider, <mask> } from 'styled-components/native'; <mask> import { theme as defaultTheme, ITheme } from './../theme'; <mask> import { <mask> IColorModeProviderProps, <mask> ColorModeProvider, <mask> useColorModeValue, <mask> } from './../color-mode'; <mask> import HybridProvider from './HybridOverlay/HybridProvider'; <mask> import View from '../components/primitives/View'; <mask> import SafeAreaView from '../components/primitives/SafeAreaView'; <mask> <mask> export interface NativeBaseProviderProps { </s> Removed SafeAreaView and fixes for theme background </s> remove import View from '../components/primitives/View'; import SafeAreaView from '../components/primitives/SafeAreaView'; </s> add </s> remove const Wrapper = disableSafeArea ? View : SafeAreaView; </s> add // const Wrapper = disableSafeArea ? View : SafeAreaView; </s> remove height="100%" width="100%" </s> add </s> remove <Wrapper bg={useColorModeValue(`gray.50`, `gray.800`)} flex={1}> <HybridProvider>{children}</HybridProvider> </Wrapper> </s> add <HybridProvider>{children}</HybridProvider>
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dc462f484d38c24151cd0776d7d7d66ca718b4a2
src/core/NativeBaseProvider.tsx
<mask> ColorModeProvider, <mask> useColorModeValue, <mask> } from './../color-mode'; <mask> import HybridProvider from './HybridOverlay/HybridProvider'; <mask> import View from '../components/primitives/View'; <mask> import SafeAreaView from '../components/primitives/SafeAreaView'; <mask> <mask> export interface NativeBaseProviderProps { <mask> theme?: ITheme; <mask> colorModeManager?: IColorModeProviderProps['colorModeManager']; <mask> children?: React.ReactNode; <mask> disableSafeArea?: boolean; </s> Removed SafeAreaView and fixes for theme background </s> remove import { IColorModeProviderProps, ColorModeProvider, useColorModeValue, } from './../color-mode'; </s> add import { IColorModeProviderProps, ColorModeProvider } from './../color-mode'; </s> remove height="100%" width="100%" </s> add </s> remove const Wrapper = disableSafeArea ? View : SafeAreaView; </s> add // const Wrapper = disableSafeArea ? View : SafeAreaView; </s> remove <Wrapper bg={useColorModeValue(`gray.50`, `gray.800`)} flex={1}> <HybridProvider>{children}</HybridProvider> </Wrapper> </s> add <HybridProvider>{children}</HybridProvider>
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dc462f484d38c24151cd0776d7d7d66ca718b4a2
src/core/NativeBaseProvider.tsx
// const Wrapper = disableSafeArea ? View : SafeAreaView;
<mask> theme = defaultTheme, <mask> disableSafeArea, <mask> children, <mask> } = props; <mask> <mask> const Wrapper = disableSafeArea ? View : SafeAreaView; <mask> return ( <mask> <ThemeProvider theme={theme}> <mask> <ColorModeProvider <mask> colorModeManager={colorModeManager} <mask> options={theme.config} </s> Removed SafeAreaView and fixes for theme background </s> remove <Wrapper bg={useColorModeValue(`gray.50`, `gray.800`)} flex={1}> <HybridProvider>{children}</HybridProvider> </Wrapper> </s> add <HybridProvider>{children}</HybridProvider> </s> remove height="100%" width="100%" </s> add </s> remove import { IColorModeProviderProps, ColorModeProvider, useColorModeValue, } from './../color-mode'; </s> add import { IColorModeProviderProps, ColorModeProvider } from './../color-mode'; </s> remove import View from '../components/primitives/View'; import SafeAreaView from '../components/primitives/SafeAreaView'; </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dc462f484d38c24151cd0776d7d7d66ca718b4a2
src/core/NativeBaseProvider.tsx
<HybridProvider>{children}</HybridProvider>
<mask> <ColorModeProvider <mask> colorModeManager={colorModeManager} <mask> options={theme.config} <mask> > <mask> <Wrapper bg={useColorModeValue(`gray.50`, `gray.800`)} flex={1}> <mask> <HybridProvider>{children}</HybridProvider> <mask> </Wrapper> <mask> </ColorModeProvider> <mask> </ThemeProvider> <mask> ); <mask> }; <mask> </s> Removed SafeAreaView and fixes for theme background </s> remove const Wrapper = disableSafeArea ? View : SafeAreaView; </s> add // const Wrapper = disableSafeArea ? View : SafeAreaView; </s> remove height="100%" width="100%" </s> add </s> remove import View from '../components/primitives/View'; import SafeAreaView from '../components/primitives/SafeAreaView'; </s> add </s> remove import { IColorModeProviderProps, ColorModeProvider, useColorModeValue, } from './../color-mode'; </s> add import { IColorModeProviderProps, ColorModeProvider } from './../color-mode';
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dc462f484d38c24151cd0776d7d7d66ca718b4a2
src/core/NativeBaseProvider.tsx
<mask> import { default as Box, IBoxProps } from '../Box'; <mask> import HStack from '../Stack/HStack'; <mask> import Pressable from '../Pressable'; <mask> import type { IButtonGroupProps, IButtonProps } from './types'; <mask> import { composeEventHandlers } from '../../../utils'; <mask> <mask> const useHover = () => { <mask> const [isHovered, setHovered] = React.useState(false); <mask> return { <mask> pressableProps: { <mask> onHoverIn: () => setHovered(true), <mask> onHoverOut: () => setHovered(false), <mask> }, <mask> isHovered, <mask> }; <mask> }; <mask> <mask> const useIsPressed = () => { <mask> const [isPressed, setIsPressed] = React.useState(false); <mask> return { <mask> pressableProps: { <mask> onPressIn: () => setIsPressed(true), <mask> onPressOut: () => setIsPressed(false), <mask> }, <mask> isPressed, <mask> }; <mask> }; <mask> <mask> const Button = ( <mask> { <mask> children, <mask> isLoading, </s> feat: add hover and pressed in pressable </s> remove type IPressableProps = PressableProps & IBoxProps; </s> add export type IPressableProps = PressableProps & IBoxProps & { onHoverIn?: any; onHoverOut?: any; _hover?: any; _pressed?: any; }; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> remove const Pressable = (props: IPressableProps, ref: any) => { return <StyledPressable {...props} ref={ref} />; </s> add const Pressable = ( { onPressIn, onPressOut, onHoverIn, onHoverOut, _hover, _pressed, ...props }: IPressableProps, ref: any ) => { const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); return ( <StyledPressable ref={ref} onPressIn={composeEventHandlers(onPressIn, isPressedProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} // @ts-ignore - web only onHoverIn={composeEventHandlers(onHoverIn, pressableProps.onHoverIn)} // @ts-ignore - web only onHoverOut={composeEventHandlers(onHoverOut, pressableProps.onHoverOut)} {...props} {...(isHovered && _hover)} {...(isPressed && _pressed)} /> ); </s> remove const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); const themeProps = { ...newProps, ...(isHovered && _hover), ...(isPressed && _pressed), </s> add const pressableProps = { ...restProps, _hover, _pressed, </s> remove const { _text, _hover, _pressed, ...newProps } = useThemeProps('Button', { </s> add const { _text, _hover, _pressed, ...restProps } = useThemeProps('Button', {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dcdcc20b5e6c4e1f8fc5cf4c83e3bc3f961c0e79
src/components/primitives/Button/index.tsx
<mask> { <mask> children, <mask> isLoading, <mask> isLoadingText, <mask> accessibilityLabel, <mask> accessibilityHint, <mask> accessibilityState, <mask> accessibilityRole, <mask> size, <mask> startIcon, <mask> onPress, <mask> onLongPress, <mask> onPressIn, </s> feat: add hover and pressed in pressable </s> remove onPress, onLongPress, onPressIn, onPressOut, onHoverIn, onHoverOut, </s> add </s> remove import { composeEventHandlers } from '../../../utils'; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> add </s> remove const { _text, _hover, _pressed, ...newProps } = useThemeProps('Button', { </s> add const { _text, _hover, _pressed, ...restProps } = useThemeProps('Button', { </s> remove const Pressable = (props: IPressableProps, ref: any) => { return <StyledPressable {...props} ref={ref} />; </s> add const Pressable = ( { onPressIn, onPressOut, onHoverIn, onHoverOut, _hover, _pressed, ...props }: IPressableProps, ref: any ) => { const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); return ( <StyledPressable ref={ref} onPressIn={composeEventHandlers(onPressIn, isPressedProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} // @ts-ignore - web only onHoverIn={composeEventHandlers(onHoverIn, pressableProps.onHoverIn)} // @ts-ignore - web only onHoverOut={composeEventHandlers(onHoverOut, pressableProps.onHoverOut)} {...props} {...(isHovered && _hover)} {...(isPressed && _pressed)} /> ); </s> remove const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); const themeProps = { ...newProps, ...(isHovered && _hover), ...(isPressed && _pressed), </s> add const pressableProps = { ...restProps, _hover, _pressed,
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dcdcc20b5e6c4e1f8fc5cf4c83e3bc3f961c0e79
src/components/primitives/Button/index.tsx
<mask> accessibilityState, <mask> accessibilityRole, <mask> size, <mask> startIcon, <mask> onPress, <mask> onLongPress, <mask> onPressIn, <mask> onPressOut, <mask> onHoverIn, <mask> onHoverOut, <mask> endIcon, <mask> spinner, <mask> ...props <mask> }: IButtonProps & IBoxProps, <mask> ref: any </s> feat: add hover and pressed in pressable </s> remove accessibilityLabel, accessibilityHint, accessibilityState, accessibilityRole, </s> add </s> remove const Pressable = (props: IPressableProps, ref: any) => { return <StyledPressable {...props} ref={ref} />; </s> add const Pressable = ( { onPressIn, onPressOut, onHoverIn, onHoverOut, _hover, _pressed, ...props }: IPressableProps, ref: any ) => { const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); return ( <StyledPressable ref={ref} onPressIn={composeEventHandlers(onPressIn, isPressedProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} // @ts-ignore - web only onHoverIn={composeEventHandlers(onHoverIn, pressableProps.onHoverIn)} // @ts-ignore - web only onHoverOut={composeEventHandlers(onHoverOut, pressableProps.onHoverOut)} {...props} {...(isHovered && _hover)} {...(isPressed && _pressed)} /> ); </s> remove const { _text, _hover, _pressed, ...newProps } = useThemeProps('Button', { </s> add const { _text, _hover, _pressed, ...restProps } = useThemeProps('Button', { </s> remove originalEventHandler?: (event: E) => void, </s> add originalEventHandler?: null | ((event: E) => void), </s> remove type IPressableProps = PressableProps & IBoxProps; </s> add export type IPressableProps = PressableProps & IBoxProps & { onHoverIn?: any; onHoverOut?: any; _hover?: any; _pressed?: any; }; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; };
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dcdcc20b5e6c4e1f8fc5cf4c83e3bc3f961c0e79
src/components/primitives/Button/index.tsx
const { _text, _hover, _pressed, ...restProps } = useThemeProps('Button', {
<mask> ...props <mask> }: IButtonProps & IBoxProps, <mask> ref: any <mask> ) => { <mask> const { _text, _hover, _pressed, ...newProps } = useThemeProps('Button', { <mask> ...props, <mask> size, <mask> }); <mask> <mask> const { isDisabled } = props; </s> feat: add hover and pressed in pressable </s> remove const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); const themeProps = { ...newProps, ...(isHovered && _hover), ...(isPressed && _pressed), </s> add const pressableProps = { ...restProps, _hover, _pressed, </s> remove const Pressable = (props: IPressableProps, ref: any) => { return <StyledPressable {...props} ref={ref} />; </s> add const Pressable = ( { onPressIn, onPressOut, onHoverIn, onHoverOut, _hover, _pressed, ...props }: IPressableProps, ref: any ) => { const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); return ( <StyledPressable ref={ref} onPressIn={composeEventHandlers(onPressIn, isPressedProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} // @ts-ignore - web only onHoverIn={composeEventHandlers(onHoverIn, pressableProps.onHoverIn)} // @ts-ignore - web only onHoverOut={composeEventHandlers(onHoverOut, pressableProps.onHoverOut)} {...props} {...(isHovered && _hover)} {...(isPressed && _pressed)} /> ); </s> remove onPress, onLongPress, onPressIn, onPressOut, onHoverIn, onHoverOut, </s> add </s> remove import { composeEventHandlers } from '../../../utils'; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> add </s> remove originalEventHandler?: (event: E) => void, </s> add originalEventHandler?: null | ((event: E) => void),
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dcdcc20b5e6c4e1f8fc5cf4c83e3bc3f961c0e79
src/components/primitives/Button/index.tsx
const pressableProps = { ...restProps, _hover, _pressed,
<mask> }); <mask> <mask> const { isDisabled } = props; <mask> <mask> const { pressableProps, isHovered } = useHover(); <mask> const { pressableProps: isPressedProps, isPressed } = useIsPressed(); <mask> <mask> const themeProps = { <mask> ...newProps, <mask> ...(isHovered && _hover), <mask> ...(isPressed && _pressed), <mask> }; <mask> <mask> return ( <mask> <Pressable <mask> onPress={onPress} </s> feat: add hover and pressed in pressable </s> remove const Pressable = (props: IPressableProps, ref: any) => { return <StyledPressable {...props} ref={ref} />; </s> add const Pressable = ( { onPressIn, onPressOut, onHoverIn, onHoverOut, _hover, _pressed, ...props }: IPressableProps, ref: any ) => { const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); return ( <StyledPressable ref={ref} onPressIn={composeEventHandlers(onPressIn, isPressedProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} // @ts-ignore - web only onHoverIn={composeEventHandlers(onHoverIn, pressableProps.onHoverIn)} // @ts-ignore - web only onHoverOut={composeEventHandlers(onHoverOut, pressableProps.onHoverOut)} {...props} {...(isHovered && _hover)} {...(isPressed && _pressed)} /> ); </s> remove const { _text, _hover, _pressed, ...newProps } = useThemeProps('Button', { </s> add const { _text, _hover, _pressed, ...restProps } = useThemeProps('Button', { </s> remove import { composeEventHandlers } from '../../../utils'; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> add </s> remove type IPressableProps = PressableProps & IBoxProps; </s> add export type IPressableProps = PressableProps & IBoxProps & { onHoverIn?: any; onHoverOut?: any; _hover?: any; _pressed?: any; }; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> remove <Pressable onPress={onPress} onLongPress={onLongPress} onPressIn={composeEventHandlers(onPressIn, isPressedProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} disabled={isDisabled} ref={ref} accessibilityHint={accessibilityHint} accessibilityRole={accessibilityRole ?? 'button'} accessibilityState={accessibilityState} accessibilityLabel={accessibilityLabel} // @ts-ignore - web only onHoverIn={composeEventHandlers(onHoverIn, pressableProps.onHoverIn)} // @ts-ignore - web only onHoverOut={composeEventHandlers(onHoverOut, pressableProps.onHoverOut)} {...themeProps} > </s> add <Pressable disabled={isDisabled} ref={ref} {...pressableProps}>
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dcdcc20b5e6c4e1f8fc5cf4c83e3bc3f961c0e79
src/components/primitives/Button/index.tsx
<Pressable disabled={isDisabled} ref={ref} {...pressableProps}>
<mask> ...(isPressed && _pressed), <mask> }; <mask> <mask> return ( <mask> <Pressable <mask> onPress={onPress} <mask> onLongPress={onLongPress} <mask> onPressIn={composeEventHandlers(onPressIn, isPressedProps.onPressIn)} <mask> onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} <mask> disabled={isDisabled} <mask> ref={ref} <mask> accessibilityHint={accessibilityHint} <mask> accessibilityRole={accessibilityRole ?? 'button'} <mask> accessibilityState={accessibilityState} <mask> accessibilityLabel={accessibilityLabel} <mask> // @ts-ignore - web only <mask> onHoverIn={composeEventHandlers(onHoverIn, pressableProps.onHoverIn)} <mask> // @ts-ignore - web only <mask> onHoverOut={composeEventHandlers(onHoverOut, pressableProps.onHoverOut)} <mask> {...themeProps} <mask> > <mask> <HStack opacity={isDisabled ? 0.7 : undefined} space={2}> <mask> {startIcon && !isLoading ? startIcon : null} <mask> {isLoading ? ( <mask> spinner ? ( <mask> spinner </s> feat: add hover and pressed in pressable </s> remove const Pressable = (props: IPressableProps, ref: any) => { return <StyledPressable {...props} ref={ref} />; </s> add const Pressable = ( { onPressIn, onPressOut, onHoverIn, onHoverOut, _hover, _pressed, ...props }: IPressableProps, ref: any ) => { const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); return ( <StyledPressable ref={ref} onPressIn={composeEventHandlers(onPressIn, isPressedProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} // @ts-ignore - web only onHoverIn={composeEventHandlers(onHoverIn, pressableProps.onHoverIn)} // @ts-ignore - web only onHoverOut={composeEventHandlers(onHoverOut, pressableProps.onHoverOut)} {...props} {...(isHovered && _hover)} {...(isPressed && _pressed)} /> ); </s> remove const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); const themeProps = { ...newProps, ...(isHovered && _hover), ...(isPressed && _pressed), </s> add const pressableProps = { ...restProps, _hover, _pressed, </s> remove import { composeEventHandlers } from '../../../utils'; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> add </s> remove type IPressableProps = PressableProps & IBoxProps; </s> add export type IPressableProps = PressableProps & IBoxProps & { onHoverIn?: any; onHoverOut?: any; _hover?: any; _pressed?: any; }; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> remove originalEventHandler?: (event: E) => void, </s> add originalEventHandler?: null | ((event: E) => void),
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dcdcc20b5e6c4e1f8fc5cf4c83e3bc3f961c0e79
src/components/primitives/Button/index.tsx
<mask> import type { ViewProps, ViewStyle } from 'react-native'; <mask> import type { IAccessibilityProps } from '../../../utils/accessibilityTypes'; <mask> import type { <mask> BorderProps, <mask> ColorProps, <mask> FlexboxProps, <mask> LayoutProps, <mask> PositionProps, <mask> SpaceProps, <mask> } from 'styled-system'; <mask> import type { <mask> customBackgroundProps, <mask> customBorderProps, <mask> customExtraProps, <mask> customLayoutProps, <mask> customOutlineProps, <mask> customShadowProps, <mask> customFlexboxProps, <mask> customPositionProps, <mask> } from '../../../utils/customProps'; <mask> import type { ITextProps } from './../Text/types'; <mask> <mask> export type IButtonProps = ViewProps & <mask> ColorProps & <mask> SpaceProps & </s> feat: add hover and pressed in pressable </s> remove export type IButtonProps = ViewProps & ColorProps & SpaceProps & LayoutProps & FlexboxProps & BorderProps & PositionProps & customBorderProps & customExtraProps & customOutlineProps & customShadowProps & customFlexboxProps & customPositionProps & customLayoutProps & customBackgroundProps & IAccessibilityProps & { style?: ViewStyle; children?: any; colorScheme?: string; variant?: string; isLoading?: any; size?: 'xs' | 'sm' | 'md' | 'lg'; onPress?: any; onLongPress?: any; onPressIn?: any; onPressOut?: any; onHoverIn?: any; onHoverOut?: any; shadow?: number; startIcon?: JSX.Element | Array<JSX.Element>; endIcon?: JSX.Element | Array<JSX.Element>; isLoadingText?: string; spinner?: JSX.Element; isDisabled?: boolean; _text?: ITextProps; }; </s> add export type IButtonProps = IPressableProps & { colorScheme?: string; variant?: string; isLoading?: any; size?: 'xs' | 'sm' | 'md' | 'lg'; startIcon?: JSX.Element | Array<JSX.Element>; endIcon?: JSX.Element | Array<JSX.Element>; isLoadingText?: string; spinner?: JSX.Element; isDisabled?: boolean; _text?: ITextProps; }; </s> remove import { composeEventHandlers } from '../../../utils'; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> add </s> remove type IPressableProps = PressableProps & IBoxProps; </s> add export type IPressableProps = PressableProps & IBoxProps & { onHoverIn?: any; onHoverOut?: any; _hover?: any; _pressed?: any; }; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> remove const { _text, _hover, _pressed, ...newProps } = useThemeProps('Button', { </s> add const { _text, _hover, _pressed, ...restProps } = useThemeProps('Button', {
[ "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dcdcc20b5e6c4e1f8fc5cf4c83e3bc3f961c0e79
src/components/primitives/Button/types.ts
import type { IPressableProps } from '../Pressable';
<mask> import type { ITextProps } from './../Text/types'; <mask> <mask> export type IButtonProps = IPressableProps & { <mask> colorScheme?: string; <mask> variant?: string; <mask> isLoading?: any; <mask> size?: 'xs' | 'sm' | 'md' | 'lg'; </s> feat: add hover and pressed in pressable </s> remove export type IButtonProps = ViewProps & ColorProps & SpaceProps & LayoutProps & FlexboxProps & BorderProps & PositionProps & customBorderProps & customExtraProps & customOutlineProps & customShadowProps & customFlexboxProps & customPositionProps & customLayoutProps & customBackgroundProps & IAccessibilityProps & { style?: ViewStyle; children?: any; colorScheme?: string; variant?: string; isLoading?: any; size?: 'xs' | 'sm' | 'md' | 'lg'; onPress?: any; onLongPress?: any; onPressIn?: any; onPressOut?: any; onHoverIn?: any; onHoverOut?: any; shadow?: number; startIcon?: JSX.Element | Array<JSX.Element>; endIcon?: JSX.Element | Array<JSX.Element>; isLoadingText?: string; spinner?: JSX.Element; isDisabled?: boolean; _text?: ITextProps; }; </s> add export type IButtonProps = IPressableProps & { colorScheme?: string; variant?: string; isLoading?: any; size?: 'xs' | 'sm' | 'md' | 'lg'; startIcon?: JSX.Element | Array<JSX.Element>; endIcon?: JSX.Element | Array<JSX.Element>; isLoadingText?: string; spinner?: JSX.Element; isDisabled?: boolean; _text?: ITextProps; }; </s> remove import type { ViewProps, ViewStyle } from 'react-native'; import type { IAccessibilityProps } from '../../../utils/accessibilityTypes'; import type { BorderProps, ColorProps, FlexboxProps, LayoutProps, PositionProps, SpaceProps, } from 'styled-system'; import type { customBackgroundProps, customBorderProps, customExtraProps, customLayoutProps, customOutlineProps, customShadowProps, customFlexboxProps, customPositionProps, } from '../../../utils/customProps'; </s> add </s> remove type IPressableProps = PressableProps & IBoxProps; </s> add export type IPressableProps = PressableProps & IBoxProps & { onHoverIn?: any; onHoverOut?: any; _hover?: any; _pressed?: any; }; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> remove originalEventHandler?: (event: E) => void, </s> add originalEventHandler?: null | ((event: E) => void), </s> remove import { composeEventHandlers } from '../../../utils'; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> add
[ "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dcdcc20b5e6c4e1f8fc5cf4c83e3bc3f961c0e79
src/components/primitives/Button/types.ts
export type IButtonProps = IPressableProps & { colorScheme?: string; variant?: string; isLoading?: any; size?: 'xs' | 'sm' | 'md' | 'lg'; startIcon?: JSX.Element | Array<JSX.Element>; endIcon?: JSX.Element | Array<JSX.Element>; isLoadingText?: string; spinner?: JSX.Element; isDisabled?: boolean; _text?: ITextProps; };
<mask> customPositionProps, <mask> } from '../../../utils/customProps'; <mask> import type { ITextProps } from './../Text/types'; <mask> <mask> export type IButtonProps = ViewProps & <mask> ColorProps & <mask> SpaceProps & <mask> LayoutProps & <mask> FlexboxProps & <mask> BorderProps & <mask> PositionProps & <mask> customBorderProps & <mask> customExtraProps & <mask> customOutlineProps & <mask> customShadowProps & <mask> customFlexboxProps & <mask> customPositionProps & <mask> customLayoutProps & <mask> customBackgroundProps & <mask> IAccessibilityProps & { <mask> style?: ViewStyle; <mask> children?: any; <mask> colorScheme?: string; <mask> variant?: string; <mask> isLoading?: any; <mask> size?: 'xs' | 'sm' | 'md' | 'lg'; <mask> onPress?: any; <mask> onLongPress?: any; <mask> onPressIn?: any; <mask> onPressOut?: any; <mask> onHoverIn?: any; <mask> onHoverOut?: any; <mask> shadow?: number; <mask> startIcon?: JSX.Element | Array<JSX.Element>; <mask> endIcon?: JSX.Element | Array<JSX.Element>; <mask> isLoadingText?: string; <mask> spinner?: JSX.Element; <mask> isDisabled?: boolean; <mask> _text?: ITextProps; <mask> }; <mask> <mask> export type IButtonGroupProps = { <mask> children: JSX.Element | Array<JSX.Element>; <mask> variant?: string; <mask> size?: 'xs' | 'sm' | 'md' | 'lg'; </s> feat: add hover and pressed in pressable </s> remove type IPressableProps = PressableProps & IBoxProps; </s> add export type IPressableProps = PressableProps & IBoxProps & { onHoverIn?: any; onHoverOut?: any; _hover?: any; _pressed?: any; }; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> remove import type { ViewProps, ViewStyle } from 'react-native'; import type { IAccessibilityProps } from '../../../utils/accessibilityTypes'; import type { BorderProps, ColorProps, FlexboxProps, LayoutProps, PositionProps, SpaceProps, } from 'styled-system'; import type { customBackgroundProps, customBorderProps, customExtraProps, customLayoutProps, customOutlineProps, customShadowProps, customFlexboxProps, customPositionProps, } from '../../../utils/customProps'; </s> add </s> remove originalEventHandler?: (event: E) => void, </s> add originalEventHandler?: null | ((event: E) => void), </s> remove import { composeEventHandlers } from '../../../utils'; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dcdcc20b5e6c4e1f8fc5cf4c83e3bc3f961c0e79
src/components/primitives/Button/types.ts
export type IPressableProps = PressableProps & IBoxProps & { onHoverIn?: any; onHoverOut?: any; _hover?: any; _pressed?: any; }; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; };
<mask> customShadow, <mask> } from '../../../utils/customProps'; <mask> import type { IBoxProps } from '../Box'; <mask> <mask> type IPressableProps = PressableProps & IBoxProps; <mask> <mask> const StyledPressable = styled(RNPressable)<IPressableProps>( <mask> color, <mask> space, <mask> layout, </s> feat: add hover and pressed in pressable </s> remove import { composeEventHandlers } from '../../../utils'; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> add </s> remove import type { ViewProps, ViewStyle } from 'react-native'; import type { IAccessibilityProps } from '../../../utils/accessibilityTypes'; import type { BorderProps, ColorProps, FlexboxProps, LayoutProps, PositionProps, SpaceProps, } from 'styled-system'; import type { customBackgroundProps, customBorderProps, customExtraProps, customLayoutProps, customOutlineProps, customShadowProps, customFlexboxProps, customPositionProps, } from '../../../utils/customProps'; </s> add </s> remove export type IButtonProps = ViewProps & ColorProps & SpaceProps & LayoutProps & FlexboxProps & BorderProps & PositionProps & customBorderProps & customExtraProps & customOutlineProps & customShadowProps & customFlexboxProps & customPositionProps & customLayoutProps & customBackgroundProps & IAccessibilityProps & { style?: ViewStyle; children?: any; colorScheme?: string; variant?: string; isLoading?: any; size?: 'xs' | 'sm' | 'md' | 'lg'; onPress?: any; onLongPress?: any; onPressIn?: any; onPressOut?: any; onHoverIn?: any; onHoverOut?: any; shadow?: number; startIcon?: JSX.Element | Array<JSX.Element>; endIcon?: JSX.Element | Array<JSX.Element>; isLoadingText?: string; spinner?: JSX.Element; isDisabled?: boolean; _text?: ITextProps; }; </s> add export type IButtonProps = IPressableProps & { colorScheme?: string; variant?: string; isLoading?: any; size?: 'xs' | 'sm' | 'md' | 'lg'; startIcon?: JSX.Element | Array<JSX.Element>; endIcon?: JSX.Element | Array<JSX.Element>; isLoadingText?: string; spinner?: JSX.Element; isDisabled?: boolean; _text?: ITextProps; }; </s> remove const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); const themeProps = { ...newProps, ...(isHovered && _hover), ...(isPressed && _pressed), </s> add const pressableProps = { ...restProps, _hover, _pressed,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dcdcc20b5e6c4e1f8fc5cf4c83e3bc3f961c0e79
src/components/primitives/Pressable/index.tsx
const Pressable = ( { onPressIn, onPressOut, onHoverIn, onHoverOut, _hover, _pressed, ...props }: IPressableProps, ref: any ) => { const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); return ( <StyledPressable ref={ref} onPressIn={composeEventHandlers(onPressIn, isPressedProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} // @ts-ignore - web only onHoverIn={composeEventHandlers(onHoverIn, pressableProps.onHoverIn)} // @ts-ignore - web only onHoverOut={composeEventHandlers(onHoverOut, pressableProps.onHoverOut)} {...props} {...(isHovered && _hover)} {...(isPressed && _pressed)} /> );
<mask> customExtra, <mask> customLayout <mask> ); <mask> <mask> const Pressable = (props: IPressableProps, ref: any) => { <mask> return <StyledPressable {...props} ref={ref} />; <mask> }; <mask> <mask> export default React.forwardRef(Pressable); </s> feat: add hover and pressed in pressable </s> remove import { composeEventHandlers } from '../../../utils'; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> add </s> remove const { _text, _hover, _pressed, ...newProps } = useThemeProps('Button', { </s> add const { _text, _hover, _pressed, ...restProps } = useThemeProps('Button', { </s> remove type IPressableProps = PressableProps & IBoxProps; </s> add export type IPressableProps = PressableProps & IBoxProps & { onHoverIn?: any; onHoverOut?: any; _hover?: any; _pressed?: any; }; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> remove const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); const themeProps = { ...newProps, ...(isHovered && _hover), ...(isPressed && _pressed), </s> add const pressableProps = { ...restProps, _hover, _pressed, </s> remove originalEventHandler?: (event: E) => void, </s> add originalEventHandler?: null | ((event: E) => void),
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dcdcc20b5e6c4e1f8fc5cf4c83e3bc3f961c0e79
src/components/primitives/Pressable/index.tsx
originalEventHandler?: null | ((event: E) => void),
<mask> }; <mask> } <mask> <mask> export function composeEventHandlers<E>( <mask> originalEventHandler?: (event: E) => void, <mask> ourEventHandler?: (event: E) => void, <mask> { checkForDefaultPrevented = true } = {} <mask> ) { <mask> return function handleEvent(event: E) { <mask> originalEventHandler?.(event); </s> feat: add hover and pressed in pressable </s> remove const { _text, _hover, _pressed, ...newProps } = useThemeProps('Button', { </s> add const { _text, _hover, _pressed, ...restProps } = useThemeProps('Button', { </s> remove import { composeEventHandlers } from '../../../utils'; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> add </s> remove type IPressableProps = PressableProps & IBoxProps; </s> add export type IPressableProps = PressableProps & IBoxProps & { onHoverIn?: any; onHoverOut?: any; _hover?: any; _pressed?: any; }; const useHover = () => { const [isHovered, setHovered] = React.useState(false); return { pressableProps: { onHoverIn: () => setHovered(true), onHoverOut: () => setHovered(false), }, isHovered, }; }; const useIsPressed = () => { const [isPressed, setIsPressed] = React.useState(false); return { pressableProps: { onPressIn: () => setIsPressed(true), onPressOut: () => setIsPressed(false), }, isPressed, }; }; </s> remove const Pressable = (props: IPressableProps, ref: any) => { return <StyledPressable {...props} ref={ref} />; </s> add const Pressable = ( { onPressIn, onPressOut, onHoverIn, onHoverOut, _hover, _pressed, ...props }: IPressableProps, ref: any ) => { const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); return ( <StyledPressable ref={ref} onPressIn={composeEventHandlers(onPressIn, isPressedProps.onPressIn)} onPressOut={composeEventHandlers(onPressOut, isPressedProps.onPressOut)} // @ts-ignore - web only onHoverIn={composeEventHandlers(onHoverIn, pressableProps.onHoverIn)} // @ts-ignore - web only onHoverOut={composeEventHandlers(onHoverOut, pressableProps.onHoverOut)} {...props} {...(isHovered && _hover)} {...(isPressed && _pressed)} /> ); </s> remove const { pressableProps, isHovered } = useHover(); const { pressableProps: isPressedProps, isPressed } = useIsPressed(); const themeProps = { ...newProps, ...(isHovered && _hover), ...(isPressed && _pressed), </s> add const pressableProps = { ...restProps, _hover, _pressed,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dcdcc20b5e6c4e1f8fc5cf4c83e3bc3f961c0e79
src/utils/mergeRefs.ts
if (!this.props.placeHolderText && this.props.defaultDate) { this.setState({ chosenDate: this.props.defaultDate }) }
<mask> defaultDate: this.props.defaultDate ? this.props.defaultDate : new Date() <mask> }); <mask> }; <mask> <mask> setDate(date) { <mask> this.setState({ chosenDate: new Date(date) }); </s> Shows default date instead of "Select Date" if placeHolderText prop isn't specified. Enhancement based on issue #2086 </s> remove "/" + (this.state.chosenDate.getMonth() + 1) + "/" + +this.state.chosenDate.getFullYear() : this.props.placeHolderText ? this.props.placeHolderText : "Select Date"} </s> add "/" + (this.state.chosenDate.getMonth() + 1) + "/" + +this.state.chosenDate.getFullYear() : this.props.placeHolderText ? this.props.placeHolderText : "Select Date"} </s> remove onRequestClose={() => {}} </s> add onRequestClose={() => { }}
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dd6e79800eecba6763aaf14f58b84463972a3af8
src/basic/DatePicker.js
"/" + (this.state.chosenDate.getMonth() + 1) + "/" + +this.state.chosenDate.getFullYear() : this.props.placeHolderText ? this.props.placeHolderText : "Select Date"}
<mask> ]} <mask> > <mask> {this.state.chosenDate <mask> ? this.state.chosenDate.getDate() + <mask> "/" + <mask> (this.state.chosenDate.getMonth() + 1) + <mask> "/" + <mask> +this.state.chosenDate.getFullYear() <mask> : this.props.placeHolderText <mask> ? this.props.placeHolderText <mask> : "Select Date"} <mask> </Text> <mask> <View> <mask> <Modal <mask> animationType={this.props.animationType} <mask> transparent={this.props.modalTransparent} //from api </s> Shows default date instead of "Select Date" if placeHolderText prop isn't specified. Enhancement based on issue #2086 </s> remove onRequestClose={() => {}} </s> add onRequestClose={() => { }}
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/dd6e79800eecba6763aaf14f58b84463972a3af8
src/basic/DatePicker.js