@initbase/react-datetime-picker 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# @initbase/react-datetime-picker
|
|
2
|
+
|
|
3
|
+
Zero-dependency date, time, and range pickers for React 18+.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @initbase/react-datetime-picker
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Import the component you need and its CSS:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { DatePicker } from '@initbase/react-datetime-picker';
|
|
17
|
+
import '@initbase/react-datetime-picker/datetime-picker.css';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### DatePicker
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { useState } from 'react';
|
|
24
|
+
import { DatePicker } from '@initbase/react-datetime-picker';
|
|
25
|
+
|
|
26
|
+
function Example() {
|
|
27
|
+
const [value, setValue] = useState<Date | null>(null);
|
|
28
|
+
return (
|
|
29
|
+
<DatePicker value={value} onChange={setValue} placeholder="Pick a date" />
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### DateRangePicker
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { useState } from 'react';
|
|
38
|
+
import { DateRangePicker } from '@initbase/react-datetime-picker';
|
|
39
|
+
|
|
40
|
+
function Example() {
|
|
41
|
+
const [value, setValue] = useState<[Date | null, Date | null]>([null, null]);
|
|
42
|
+
return (
|
|
43
|
+
<DateRangePicker value={value} onChange={setValue} placeholder="Pick a range" />
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### TimePicker
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
import { useState } from 'react';
|
|
52
|
+
import { TimePicker } from '@initbase/react-datetime-picker';
|
|
53
|
+
|
|
54
|
+
function Example() {
|
|
55
|
+
const [value, setValue] = useState<Date | null>(null);
|
|
56
|
+
return (
|
|
57
|
+
<TimePicker value={value} onChange={setValue} />
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### DateTimePicker
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { useState } from 'react';
|
|
66
|
+
import { DateTimePicker } from '@initbase/react-datetime-picker';
|
|
67
|
+
|
|
68
|
+
function Example() {
|
|
69
|
+
const [value, setValue] = useState<Date | null>(null);
|
|
70
|
+
return (
|
|
71
|
+
<DateTimePicker value={value} onChange={setValue} />
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### TimeRangePicker / DateTimeRangePicker
|
|
77
|
+
|
|
78
|
+
Same pattern with `[Date | null, Date | null]` tuple values.
|
|
79
|
+
|
|
80
|
+
## Common props
|
|
81
|
+
|
|
82
|
+
| Prop | Type | Default | Description |
|
|
83
|
+
|---|---|---|---|
|
|
84
|
+
| `value` | `Date \| null` / `[Date\|null, Date\|null]` | — | Controlled value |
|
|
85
|
+
| `onChange` | `(value) => void` | — | Change handler |
|
|
86
|
+
| `placeholder` | `string` | — | Placeholder text |
|
|
87
|
+
| `position` | `'bottom' \| 'top' \| 'flexible'` | `'flexible'` | Popover position |
|
|
88
|
+
| `step` | `number` | `1` | Minute/second step interval |
|
|
89
|
+
| `use12h` | `boolean` | `false` | 12-hour format |
|
|
90
|
+
| `showSeconds` | `boolean` | `false` | Show seconds column |
|
|
91
|
+
|
|
92
|
+
## Theming
|
|
93
|
+
|
|
94
|
+
Customize with CSS custom properties on any parent of `.rdp-wrapper`:
|
|
95
|
+
|
|
96
|
+
```css
|
|
97
|
+
.rdp-wrapper {
|
|
98
|
+
--rdp-primary: #4f46e5;
|
|
99
|
+
--rdp-primary-hover: #4338ca;
|
|
100
|
+
--rdp-text: #111827;
|
|
101
|
+
--rdp-text-muted: #9ca3af;
|
|
102
|
+
--rdp-border: #e5e7eb;
|
|
103
|
+
--rdp-border-radius: 8px;
|
|
104
|
+
--rdp-font-size: 14px;
|
|
105
|
+
--rdp-cell-size: 36px;
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Links
|
|
110
|
+
|
|
111
|
+
- [Docs](https://initbase.github.io/react-datetime-picker/docs/intro)
|
|
112
|
+
- [Demo](https://initbase.github.io/react-datetime-picker/demo/)
|
|
113
|
+
- [GitHub](https://github.com/initbase/react-datetime-picker)
|
|
114
|
+
- [Support](https://ko-fi.com/burhanahmeed)
|