Skip to content

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 38 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
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 Aug 17, 2021
ed9235c
added chips-input presenter
mendyEdri Aug 23, 2021
dec823a
set disable color logic code
mendyEdri Aug 23, 2021
56f253e
demo screen changes
mendyEdri Aug 23, 2021
6a66baf
migrate to typescript, added new chip usage supporting code
mendyEdri Aug 23, 2021
784001b
Merge branch 'master' into feat/chips-input-v2
mendyEdri Aug 23, 2021
eefbbc2
Fixed namings on tests
mendyEdri Aug 23, 2021
d4487db
typings
mendyEdri Aug 24, 2021
3cc26e2
build ts
mendyEdri Sep 5, 2021
3f7f91a
Merge branch 'master' into feat/chips-input-v2
mendyEdri Sep 5, 2021
6dbb8fa
build ts
mendyEdri Sep 5, 2021
1c8e43a
remove old typings
mendyEdri Sep 5, 2021
17944ea
rename chipsProps to chips
mendyEdri Sep 5, 2021
a6c176e
export new typings
mendyEdri Sep 5, 2021
3cf3ced
renaming
mendyEdri Sep 5, 2021
93123d0
export from generatedTypes
mendyEdri Sep 5, 2021
01ca150
fixed export path
mendyEdri Sep 5, 2021
a44e00e
added key for performance
mendyEdri Sep 9, 2021
fbffefa
Merge branch 'master' into feat/chips-input-v2
mendyEdri Oct 4, 2021
9585e78
rename method
mendyEdri Oct 20, 2021
650e717
missing import
mendyEdri Oct 20, 2021
38c6608
Merge branch 'master' into feat/chips-input-v2
mendyEdri Oct 20, 2021
d8537cf
rename method name in demo screen
mendyEdri Oct 20, 2021
ce1915a
ChipsInputScreen.js -> ChipsInputScreen.tsx
mendyEdri Oct 20, 2021
9fb87b1
migrate ChipsInputScreen to typescript
mendyEdri Oct 20, 2021
61689ca
add missing export prop
mendyEdri Oct 20, 2021
e098955
change spread position to override the default labelStyle
mendyEdri Oct 21, 2021
85aa6f2
Export chipsProps
mendyEdri Oct 21, 2021
532f470
Kept old usage for later reference, export new prop that contains `va…
mendyEdri Oct 24, 2021
71b9449
added deprecation note
mendyEdri Oct 24, 2021
2bb2ffa
use ChipsInputChipProp to have `invalid` prop in this type
mendyEdri Oct 24, 2021
d04fb89
Extract inline style
mendyEdri Oct 25, 2021
bfb8309
change array decleration to transpile with typescript
mendyEdri Oct 28, 2021
a6f9242
PR Comments
mendyEdri Nov 2, 2021
5d385b8
removed ref inline function
mendyEdri Nov 2, 2021
e0f0db0
move code inside other function
mendyEdri Nov 2, 2021
3497126
make CI great again
mendyEdri Nov 2, 2021
d5b3bc6
Update src/components/chipsInput/index.tsx
Inbal-Tish Nov 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 0 additions & 95 deletions demo/src/screens/componentScreens/ChipsInputScreen.js

This file was deleted.

169 changes: 169 additions & 0 deletions demo/src/screens/componentScreens/ChipsInputScreen.tsx
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}}
/>
<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
}
});
2 changes: 1 addition & 1 deletion generatedTypes/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export {default as TouchableOpacity, TouchableOpacityProps} from './src/componen
export {default as Button, ButtonSize, ButtonProps} from './src/components/button';
export {default as Stepper, StepperProps} from './src/components/stepper';
export {default as Checkbox, CheckboxProps} from './src/components/checkbox';
export {default as ChipsInput, ChipsInputProps, ChipsInputChipProps} from './src/components/chipsInput';
export {default as Chip, ChipProps} from './src/components/chip';
export {default as ColorPicker, ColorPickerProps} from './src/components/colorPicker';
export {default as ColorPalette, ColorPaletteProps} from './src/components/colorPicker/ColorPalette';
Expand Down Expand Up @@ -93,7 +94,6 @@ export {
TextArea,
MaskedInput,
ColorSliderGroup,
ChipsInput,
SharedTransition,
Toast,
WheelPickerDialog,
Expand Down
7 changes: 7 additions & 0 deletions generatedTypes/src/components/chipsInput/Presenter.d.ts
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;
Loading