Skip to content

Commit 65ec6ab

Browse files
committed
chore: update docs and integrate srivastavaanurag79#32
1 parent d00319a commit 65ec6ab

File tree

11 files changed

+140
-82
lines changed

11 files changed

+140
-82
lines changed

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ Enjoying react-native-paper-select? [Please leave a short review on Openbase](ht
2020

2121
Check out the new [Documentation](https://anurag-srivastava.gitbook.io/react-native-paper-select).
2222

23-
[Go to Customizable Properties](https://anurag-srivastava.gitbook.io/react-native-paper-select/guides/customizations)
24-
2523
Check out the [Example](https://anurag-srivastava.gitbook.io/react-native-paper-select/example) code or you can check the example source code in [example module](https://github.com/srivastavaanurag79/react-native-paper-select/tree/master/example).
2624

2725
[React Native Paper Select (NPM Link)](https://www.npmjs.com/package/react-native-paper-select)

SUMMARY.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
* [Basic Usage](guides/basic-usage.md)
1111
* [Advanced Usage](guides/advanced-usage.md)
12-
* [Customizations](guides/customizations.md)
13-
* [Callback](guides/callback.md)
12+
* [API](guides/api.md)
1413

1514
***
1615

example.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<figure><img src="demo1.png" alt=""><figcaption></figcaption></figure>
88

9-
9+
1010

1111
<figure><img src="demo4.png" alt=""><figcaption></figcaption></figure>
1212

@@ -107,8 +107,8 @@ export default function App() {
107107
textInputMode="flat"
108108
searchStyle={{ iconColor: 'red' }}
109109
searchPlaceholder="Procurar"
110-
modalCloseButtonText="fechar"
111-
modalDoneButtonText="terminado"
110+
dialogCloseButtonText="fechar"
111+
dialogDoneButtonText="terminado"
112112
/>
113113
<PaperButton
114114
style={styles.button}

example/src/App.tsx

+12-4
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,24 @@ export default function App() {
130130
errorText={colors.error}
131131
multiEnable={true}
132132
textInputMode="flat"
133-
searchStyle={{ iconColor: 'red' }}
134-
dialogButtonLabelStyle={{
133+
dialogCloseButtonStyle={{
135134
color: 'red',
136135
backgroundColor: 'yellow',
137136
padding: 10,
138137
borderRadius: 5,
139138
}}
139+
dialogDoneButtonStyle={{
140+
color: 'blue',
141+
backgroundColor: 'green',
142+
padding: 10,
143+
borderRadius: 5,
144+
}}
140145
searchText="Procurar"
141-
modalCloseButtonText="fechar"
142-
modalDoneButtonText="terminado"
146+
dialogCloseButtonText="fechar"
147+
dialogDoneButtonText="terminado"
148+
searchbarProps={{
149+
iconColor: 'red',
150+
}}
143151
/>
144152
<PaperButton
145153
style={styles.button}

guides/advanced-usage.md

+83-27
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,100 @@
11
# Advanced Usage
22

3-
You can customize, `PaperSelect` as per your requirement. Some of the customization options are:
4-
5-
* `textInputMode` - you have two material options to choose from `flat` and `outlined` . See [`screenshot`](broken-reference).
6-
* `modalDoneButtonText` - you can change the modal's button text in your language.
7-
* `theme` - you can change the colour of the placeholder/label using:
8-
* ```
9-
theme={{colors: {placeholder: 'black'}}}
10-
```
11-
12-
```typescript
13-
// theme={{colors: {placeholder: 'black'}}}
14-
// changes the label/placeholder color whereas
15-
// outlineColor changes the border color
3+
You can customize, `PaperSelect` as per your requirement. You can view a list of customization options at the [API](api.md) page.
4+
5+
## Translations
6+
Static texts like the button texts, "Select all", the search placeholder can all be replaced through their respective properties:
7+
- `label`: The actual label shown on the TextInput
8+
- `dialogTitle`: The title shown in the dialog, this defaults to the label defined above
9+
- `selectAllText`: The text shown on the "Select all" checkbox in the dialog, only will have an effect when `multiEnable` is true.
10+
- `searchText`: The text shown in the searchbar placeholder
11+
- `dialogCloseButtonText`: The text shown in the close button of the dialog.
12+
- `dialogDoneButtonText`: The text shown in the done button of the dialog.
13+
- `errorText`: A piece of text shown below the TextInput when you want to indicate an error has occured with your item selection.
14+
15+
## Overriding the theme
16+
Like with most react-native-paper components, the theme can be overridden on a per component basis.
17+
We utilize this method too, however the theme is applied to all sub-components below the container component.
18+
If you need to set specific styles of certain components, you can find them in any of the `...Style` properties.
19+
20+
The theme can be provided in any possible configuration you can use in regular react-native-paper components, MD2/MD3 - Light/Dark.
21+
By default it will use the theme as provided by the `PaperProvider`.
22+
23+
```tsx
24+
// This component will utilize a custom primary colour
25+
<PaperProvider theme={{ colors: { primary: "blue", secondary: "green" }}}>
26+
<PaperSelect
27+
label="Select Gender"
28+
value={gender.value}
29+
onSelection={(value: any) => {
30+
setGender({
31+
...gender,
32+
value: value.text,
33+
selectedList: value.selectedList
34+
});
35+
}}
36+
arrayList={[...gender.list]}
37+
selectedArrayList={[...gender.selectedList]}
38+
multiEnable={false}
39+
theme={{
40+
colors: {
41+
primary: 'black'
42+
}
43+
}}
44+
/>
45+
</PaperProvider>
46+
```
47+
48+
```tsx
49+
// This component will utilize the default theme as provided by the PaperProvider
50+
<PaperProvider theme={{ colors: { primary: "blue", secondary: "green" }}}>
51+
<PaperSelect
52+
label="Select Gender"
53+
value={gender.value}
54+
onSelection={(value: any) => {
55+
setGender({
56+
...gender,
57+
value: value.text,
58+
selectedList: value.selectedList
59+
});
60+
}}
61+
arrayList={[...gender.list]}
62+
selectedArrayList={[...gender.selectedList]}
63+
multiEnable={false}
64+
/>
65+
</PaperProvider>
66+
```
67+
68+
### Overriding components properties
69+
Currently we support 2 different properties for overriding additional component properties, these are:
70+
- `textInputProps`: Passes additional properties to the <TextInput> element where the selected value(s) are shown.
71+
- `checkboxProps`: Passes additional properties to the <CheckBox> elements used for picking items in the dialog, aswell as the "Select all" option.
72+
- `searchbarProps`: Passes additional properties to the <Searchbar> element used for searching in the possible items.
73+
74+
```tsx
1675
<PaperSelect
1776
label="Select Gender"
1877
value={gender.value}
1978
onSelection={(value: any) => {
2079
setGender({
2180
...gender,
2281
value: value.text,
23-
selectedList: value.selectedList,
24-
error: '',
82+
selectedList: value.selectedList
2583
});
2684
}}
2785
arrayList={[...gender.list]}
2886
selectedArrayList={[...gender.selectedList]}
29-
errorText={gender.error}
3087
multiEnable={false}
31-
outlineColor="black"
32-
theme={{
33-
colors: {
34-
placeholder: 'black'
35-
}
88+
textInputProps={{
89+
underlineColor: "red",
90+
left: <IconButton icon="delete" onPress={() => setGender(undefined)} />
91+
}}
92+
checkboxProps={{
93+
checkboxColor: "purple",
94+
checkboxUncheckedColor: "gold"
95+
}}
96+
searchbarProps={{
97+
iconColor: "brown"
3698
}}
3799
/>
38100
```
39-
40-
41-
42-
For more options, see [`Customizations`](customizations.md)
43-
44-
Check out the [`Example`](../example.md#code) code for advance usage.

guides/api.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
| Name | Type | Description | Default value | Required |
4747
| -------------- | ------------------------------------------------------- | -------------------------------------------------- | ------------- | -------- |
4848
| textInputProps | [PaperSelectTextInputProps](#PaperSelectTextInputProps) | Additional properties to supply to the text input. | undefined | :x: |
49-
| checkboxProps | [CheckboxProps](#CheckboxProps) | Additional properties to supply to the checkboxes. | undefined | :x: |
49+
| checkboxProps | [PaperSelectCheckboxProps](#PaperSelectCheckboxProps) | Additional properties to supply to the checkboxes. | undefined | :x: |
50+
| checkboxProps | [PaperSelectSearchbarProps](#PaperSelectSearchbarProps) | Additional properties to supply to the searchbar. | undefined | :x: |
5051

5152
## Types
5253

@@ -70,9 +71,17 @@ export interface PaperSelectTextInputProps {
7071

7172
### PaperSelectTextInputProps
7273
```ts
73-
export interface CheckboxProps {
74+
export interface PaperSelectCheckboxProps {
7475
checkboxColor?: string;
7576
checkboxUncheckedColor?: string;
7677
checkboxLabelStyle?: TextStyle;
7778
}
7879
```
80+
81+
### PaperSelectSearchbarProps
82+
```ts
83+
export interface PaperSelectSearchbarProps {
84+
icon?: IconSource;
85+
iconColor?: string;
86+
}
87+
```

guides/callback.md

-19
This file was deleted.

src/components/checkBox.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, { memo } from 'react';
22
import { View, StyleSheet, Text } from 'react-native';
33
import { Checkbox } from 'react-native-paper';
4-
import type { CheckboxProps } from 'src/interface/checkbox.interface';
4+
import type { PaperSelectCheckboxProps } from 'src/interface/checkbox.interface';
55

6-
interface CheckboxPropsFull extends CheckboxProps {
6+
interface CheckboxPropsFull extends PaperSelectCheckboxProps {
77
isChecked: boolean;
88
label: string;
99
}

src/interface/checkbox.interface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { TextStyle } from 'react-native';
22

3-
export interface CheckboxProps {
3+
export interface PaperSelectCheckboxProps {
44
checkboxColor?: string;
55
checkboxUncheckedColor?: string;
66
checkboxLabelStyle?: TextStyle;

src/interface/paperSelect.interface.ts

+13-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { MutableRefObject } from 'react';
22
import type { ViewStyle, TextStyle } from 'react-native';
33
import type { SearchbarProps, TextInputProps } from 'react-native-paper';
44
import type { ThemeProp } from 'react-native-paper/lib/typescript/src/types';
5-
import type { CheckboxProps } from './checkbox.interface';
5+
import type { PaperSelectCheckboxProps } from './checkbox.interface';
66

77
export interface ListItem {
88
_id: string;
@@ -26,6 +26,11 @@ export type PaperSelectTextInputProps = Pick<
2626
| 'right'
2727
>;
2828

29+
export type PaperSelectSearchbarProps = Pick<
30+
SearchbarProps,
31+
'icon' | 'iconColor'
32+
>;
33+
2934
export interface PaperSelectProps {
3035
// Required props
3136
label: string;
@@ -47,22 +52,22 @@ export interface PaperSelectProps {
4752
dialogTitle?: string;
4853
selectAllText?: string;
4954
searchText?: string;
50-
modalCloseButtonText?: string;
51-
modalDoneButtonText?: string;
55+
dialogCloseButtonText?: string;
56+
dialogDoneButtonText?: string;
5257
errorText?: string;
5358

5459
// Style props
5560
containerStyle?: ViewStyle;
5661
textInputStyle?: TextStyle;
5762
dialogStyle?: ViewStyle;
5863
dialogTitleStyle?: TextStyle;
59-
searchStyle?: SearchbarProps['style'] & {
60-
iconColor?: string;
61-
};
62-
dialogButtonLabelStyle?: TextStyle;
64+
searchStyle?: SearchbarProps['style'];
65+
dialogCloseButtonStyle?: TextStyle;
66+
dialogDoneButtonStyle?: TextStyle;
6367
errorStyle?: TextStyle;
6468

6569
// Component props
6670
textInputProps?: PaperSelectTextInputProps;
67-
checkboxProps?: CheckboxProps;
71+
checkboxProps?: PaperSelectCheckboxProps;
72+
searchbarProps?: PaperSelectSearchbarProps;
6873
}

0 commit comments

Comments
 (0)