-
Notifications
You must be signed in to change notification settings - Fork 734
Feat/chips input v2 #1490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feat/chips input v2 #1490
Changes from 30 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
0468453
index.js -> index.tsx
mendyEdri ed9235c
added chips-input presenter
mendyEdri dec823a
set disable color logic code
mendyEdri 56f253e
demo screen changes
mendyEdri 6a66baf
migrate to typescript, added new chip usage supporting code
mendyEdri 784001b
Merge branch 'master' into feat/chips-input-v2
mendyEdri eefbbc2
Fixed namings on tests
mendyEdri d4487db
typings
mendyEdri 3cc26e2
build ts
mendyEdri 3f7f91a
Merge branch 'master' into feat/chips-input-v2
mendyEdri 6dbb8fa
build ts
mendyEdri 1c8e43a
remove old typings
mendyEdri 17944ea
rename chipsProps to chips
mendyEdri a6c176e
export new typings
mendyEdri 3cf3ced
renaming
mendyEdri 93123d0
export from generatedTypes
mendyEdri 01ca150
fixed export path
mendyEdri a44e00e
added key for performance
mendyEdri fbffefa
Merge branch 'master' into feat/chips-input-v2
mendyEdri 9585e78
rename method
mendyEdri 650e717
missing import
mendyEdri 38c6608
Merge branch 'master' into feat/chips-input-v2
mendyEdri d8537cf
rename method name in demo screen
mendyEdri ce1915a
ChipsInputScreen.js -> ChipsInputScreen.tsx
mendyEdri 9fb87b1
migrate ChipsInputScreen to typescript
mendyEdri 61689ca
add missing export prop
mendyEdri e098955
change spread position to override the default labelStyle
mendyEdri 85aa6f2
Export chipsProps
mendyEdri 532f470
Kept old usage for later reference, export new prop that contains `va…
mendyEdri 71b9449
added deprecation note
mendyEdri 2bb2ffa
use ChipsInputChipProp to have `invalid` prop in this type
mendyEdri d04fb89
Extract inline style
mendyEdri bfb8309
change array decleration to transpile with typescript
mendyEdri a6f9242
PR Comments
mendyEdri 5d385b8
removed ref inline function
mendyEdri e0f0db0
move code inside other function
mendyEdri 3497126
make CI great again
mendyEdri d5b3bc6
Update src/components/chipsInput/index.tsx
Inbal-Tish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
import React, {Component} from 'react'; | ||
import {StyleSheet, ScrollView} from 'react-native'; | ||
import {View, Colors, Text, Typography, ChipsInput, ChipsInputChipProps} from 'react-native-ui-lib'; // eslint-disable-line | ||
|
||
interface State { | ||
chips: Array<ChipsInputChipProps>; | ||
namesChips: Array<ChipsInputChipProps>; | ||
nonRemovalChips: Array<ChipsInputChipProps>; | ||
customChips: Array<string>; | ||
tags: Array<string | any>; | ||
tags2: Array<string>; | ||
tags3: Array<string>; | ||
} | ||
|
||
export default class ChipsInputScreen extends Component<{}, State> { | ||
// @ts-ignore | ||
customChipsInput = React.createRef<ChipsInput>(); | ||
|
||
constructor(props: any) { | ||
super(props); | ||
|
||
this.state = { | ||
chips: [{label: 'Falcon 9'}, {label: 'Enterprise'}, {label: 'Challenger', borderRadius: 0}, {label: 'Coca Cola', invalid: true}], | ||
namesChips: [{label: 'Amit'}, {label: 'Ethan', invalid: true}], | ||
nonRemovalChips: [{label: 'Non'}, {label: 'Removable'}, {label: 'Tags'}], | ||
customChips: ['Chips', 'Input'], | ||
tags: [{label: 'Amit'}, {label: 'Ethan', invalid: true}], | ||
tags2: ['Non', 'Removable', 'Tags'], | ||
tags3: ['Change', 'Typography'] | ||
}; | ||
} | ||
|
||
onTagPress = (tagIndex: number, markedTagIndex: number) => { | ||
this.customChipsInput.current?.markTagIndex(tagIndex === markedTagIndex ? undefined : tagIndex); | ||
}; | ||
|
||
renderCustomTag(tag: any, _: number, shouldMarkToRemove: boolean) { | ||
return ( | ||
<View style={[styles.customTag, shouldMarkToRemove && {backgroundColor: Colors.purple70}]}> | ||
<Text white>{tag.label}</Text> | ||
</View> | ||
); | ||
} | ||
|
||
renderLeftElement = () => { | ||
return ( | ||
<View center height={40} marginR-s2 style={{alignItems: 'flex-start'}}> | ||
<Text grey30 text70M> | ||
To: | ||
</Text> | ||
</View> | ||
); | ||
}; | ||
|
||
renderSearchTypeInput = () => { | ||
return ( | ||
<> | ||
<Text marginB-10 text60>Search Type</Text> | ||
<View bg-grey60> | ||
<ChipsInput | ||
placeholder={'Enter Tags'} | ||
chips={this.state.chips} | ||
leftElement={this.renderLeftElement()} | ||
hideUnderline | ||
maxHeight={100} | ||
/> | ||
</View> | ||
</> | ||
); | ||
}; | ||
|
||
renderFormTypeInput = () => { | ||
return ( | ||
<View marginT-40> | ||
<Text marginB-10 text60>Form Type</Text> | ||
<ChipsInput | ||
placeholder={'Enter Tags'} | ||
title={'Mendy'} | ||
chips={this.state.chips} | ||
maxLength={4} | ||
/> | ||
</View> | ||
); | ||
}; | ||
|
||
onCreateTag = (value: string) => { | ||
return {label: value}; | ||
} | ||
|
||
render() { | ||
return ( | ||
<ScrollView keyboardShouldPersistTaps="never"> | ||
<View style={styles.container}> | ||
<Text text40 marginB-20> | ||
ChipsInput | ||
</Text> | ||
|
||
|
||
{this.renderSearchTypeInput()} | ||
|
||
{this.renderFormTypeInput()} | ||
|
||
<ChipsInput | ||
containerStyle={{marginBottom: 25}} | ||
placeholder="Enter Tags" | ||
chips={this.state.namesChips} | ||
validationErrorMessage="error validation message" | ||
/> | ||
|
||
<ChipsInput | ||
containerStyle={{marginBottom: 25}} | ||
placeholder="Editing disabled" | ||
chips={this.state.nonRemovalChips} | ||
disableTagRemoval | ||
disableTagAdding | ||
/> | ||
|
||
<Text text50 marginV-20>Old Usage</Text> | ||
<ChipsInput | ||
containerStyle={{marginBottom: 25}} | ||
placeholder="Enter Tags" | ||
tags={this.state.tags} | ||
validationErrorMessage="error validation message" | ||
/> | ||
|
||
<ChipsInput | ||
containerStyle={{marginBottom: 25}} | ||
placeholder="Editing disabled" | ||
tags={this.state.tags2} | ||
disableTagRemoval | ||
disableTagAdding | ||
/> | ||
<ChipsInput | ||
ref={this.customChipsInput} | ||
containerStyle={{marginBottom: 25}} | ||
placeholder="With custom tags" | ||
tags={this.state.tags} | ||
renderTag={this.renderCustomTag} | ||
onCreateTag={this.onCreateTag} | ||
onTagPress={this.onTagPress} | ||
inputStyle={{...Typography.text60, color: Colors.blue30}} | ||
Inbal-Tish marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/> | ||
<ChipsInput | ||
text60 | ||
containerStyle={{marginBottom: 25}} | ||
placeholder="Enter Tags" | ||
tags={this.state.tags3} | ||
/> | ||
|
||
</View> | ||
</ScrollView> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
padding: 15 | ||
}, | ||
customTag: { | ||
backgroundColor: Colors.purple30, | ||
paddingVertical: 2, | ||
paddingHorizontal: 8, | ||
borderRadius: 3, | ||
marginRight: 10, | ||
marginBottom: 10 | ||
} | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { ChipsInputChipProps, ChipsInputProps } from './index'; | ||
export declare const isContainsInvalid: (chips: Array<ChipsInputChipProps>) => boolean; | ||
export declare const getValidationBasedColor: (chips: Array<ChipsInputChipProps>, defaultChip?: ChipsInputChipProps | undefined) => string; | ||
export declare const getCounterTextColor: (stateChips: Array<ChipsInputChipProps>, props: ChipsInputProps) => string; | ||
export declare const getCounterText: (count: number, maxLength: number) => string; | ||
export declare const getChipDismissColor: (chip: ChipsInputChipProps, isSelected: boolean, defaultChipProps?: ChipsInputChipProps | undefined) => string; | ||
export declare const isDisabled: (props: ChipsInputProps) => boolean; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.