Skip to content

Commit 067d78d

Browse files
feat: add more docs
1 parent 4ef7869 commit 067d78d

File tree

5 files changed

+51
-7
lines changed

5 files changed

+51
-7
lines changed

README.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ npm install react-native-paper-dates --save
5757

5858
## Usage
5959

60-
### Single date Picker
60+
### Single date Picker (modal)
6161

6262
```tsx
6363
import * as React from 'react';
@@ -107,7 +107,7 @@ export default function ReadMeExampleSingle() {
107107
}
108108
```
109109

110-
### Range picker
110+
### Range picker (modal)
111111
```tsx
112112
import * as React from 'react';
113113
import { Button } from 'react-native-paper';
@@ -140,7 +140,7 @@ export default function ReadMeExampleRange() {
140140
Pick range
141141
</Button>
142142
<DatePickerModal
143-
// locale={'en'} optional, default: automatic
143+
locale="en"
144144
mode="range"
145145
visible={open}
146146
onDismiss={onDismiss}
@@ -153,7 +153,6 @@ export default function ReadMeExampleRange() {
153153
// disabledDates: [new Date()] // optional
154154
// }}
155155
// onChange={} // same props as onConfirm but triggered without confirmed by user
156-
// locale={'nl'} // optional
157156
// saveLabel="Save" // optional
158157
// label="Select period" // optional
159158
// startLabel="From" // optional
@@ -195,7 +194,7 @@ export default function ReadMeExampleMultiple() {
195194
</Button>
196195

197196
<DatePickerModal
198-
// locale={'en'} optional, default: automatic
197+
locale="en"
199198
mode="multiple"
200199
visible={open}
201200
onDismiss={onDismiss}
@@ -207,7 +206,6 @@ export default function ReadMeExampleMultiple() {
207206
// endDate: new Date(), // optional
208207
// disabledDates: [new Date()] // optional
209208
// }}
210-
// locale={'nl'} // optional
211209
// saveLabel="Save" // optional
212210
// label="Select period" // optional
213211
// startLabel="From" // optional
@@ -219,6 +217,28 @@ export default function ReadMeExampleMultiple() {
219217
}
220218
```
221219

220+
### Input date with modal button
221+
```tsx
222+
export default function ReadMeExampleDatePickerInput() {
223+
const [inputDate, setInputDate] = React.useState<Date | undefined>(undefined)
224+
225+
return (
226+
<>
227+
<DatePickerInput
228+
locale="en"
229+
label="Birthdate"
230+
value={inputDate}
231+
onChange={(d) => setInputDate(d)}
232+
inputMode="start"
233+
// mode="outlined" (see react-native-paper docs)
234+
// other react native TextInput props
235+
/>
236+
</>
237+
)
238+
}
239+
240+
```
241+
222242
### Time picker
223243
```tsx
224244
import * as React from 'react'
@@ -252,7 +272,7 @@ export default function TimePickerPage() {
252272
cancelLabel="Cancel" // optional, default: 'Cancel'
253273
confirmLabel="Ok" // optional, default: 'Ok'
254274
animationType="fade" // optional, default is 'none'
255-
locale={'en'} // optional, default is automically detected by your system
275+
locale="en" // optional, default is automically detected by your system
256276
/>
257277
<Button onPress={()=> setVisible(true)}>
258278
Pick time
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as React from 'react'
2+
3+
import { DatePickerInput } from '../../src/index'
4+
5+
export default function ReadMeExampleDatePickerInput() {
6+
const [inputDate, setInputDate] = React.useState<Date | undefined>(undefined)
7+
8+
return (
9+
<>
10+
<DatePickerInput
11+
locale="en"
12+
label="Birthdate"
13+
value={inputDate}
14+
onChange={(d) => setInputDate(d)}
15+
inputMode="start"
16+
// mode="outlined" (see react-native-paper docs)
17+
// other react native TextInput props
18+
/>
19+
</>
20+
)
21+
}

example/src/ReadMeExampleMultiple.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default function ReadMeExampleMultiple() {
3333
// validRange={{
3434
// startDate: new Date(2021, 1, 2), // optional
3535
// endDate: new Date(), // optional
36+
// disabledDates: [new Date()] // optional
3637
// }}
3738
// locale={'nl'} // optional
3839
// saveLabel="Save" // optional

example/src/ReadMeExampleRange.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default function ReadMeExampleRange() {
3939
// validRange={{
4040
// startDate: new Date(2021, 1, 2), // optional
4141
// endDate: new Date(), // optional
42+
// disabledDates: [new Date()] // optional
4243
// }}
4344
// onChange={} // same props as onConfirm but triggered without confirmed by user
4445
// locale={'nl'} // optional

example/src/ReadMeExampleSingle.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default function ReadMeExampleSingle() {
3333
// validRange={{
3434
// startDate: new Date(2021, 1, 2), // optional
3535
// endDate: new Date(), // optional
36+
// disabledDates: [new Date()] // optional
3637
// }}
3738
// onChange={} // same props as onConfirm but triggered without confirmed by user
3839
// saveLabel="Save" // optional

0 commit comments

Comments
 (0)