best-react-datepicker 0.2.0 → 0.2.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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +273 -0
  3. package/package.json +1 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 best-react-datepicker contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,273 @@
1
+ # best-react-datepicker
2
+
3
+ The most customizable, accessible, zero-dependency React date picker.
4
+
5
+ - **7 picker components** — DatePicker, RangePicker, TimePicker, DateTimePicker, MonthPicker, YearPicker, WeekPicker
6
+ - **Zero dependencies** — only React as a peer dependency
7
+ - **Fully accessible** — keyboard navigation, ARIA labels, screen reader announcements
8
+ - **CSS variable theming** — change one variable to retheme everything
9
+ - **Dark mode** — built-in dark theme via `.brdp-dark` class
10
+ - **Size variants** — `sm`, `md`, `lg` prop on all pickers
11
+ - **Month/Year dropdowns** — native select elements for quick date jumps
12
+ - **Range presets** — built-in preset helper with active state tracking
13
+ - **Compact range mode** — single-calendar layout with presets below
14
+ - **TypeScript** — full type definitions included
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ npm install best-react-datepicker
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ ```tsx
25
+ import { DatePicker } from 'best-react-datepicker';
26
+ import 'best-react-datepicker/styles.css';
27
+
28
+ function App() {
29
+ const [date, setDate] = useState<Date | null>(null);
30
+
31
+ return (
32
+ <DatePicker
33
+ value={date}
34
+ onChange={setDate}
35
+ placeholder="Pick a date"
36
+ />
37
+ );
38
+ }
39
+ ```
40
+
41
+ ## Components
42
+
43
+ ### DatePicker
44
+
45
+ Single date selection with optional constraints.
46
+
47
+ ```tsx
48
+ <DatePicker
49
+ value={date}
50
+ onChange={setDate}
51
+ placeholder="Pick a date"
52
+ minDate={new Date(2026, 0, 1)}
53
+ maxDate={new Date(2026, 11, 31)}
54
+ disabled={{ dayOfWeek: [0, 6] }}
55
+ clearable
56
+ size="md"
57
+ />
58
+ ```
59
+
60
+ ### RangePicker
61
+
62
+ Date range selection with optional presets.
63
+
64
+ ```tsx
65
+ import { RangePicker, createPresets } from 'best-react-datepicker';
66
+
67
+ const presets = createPresets();
68
+
69
+ <RangePicker
70
+ value={range}
71
+ onChange={setRange}
72
+ presets={presets}
73
+ showPresets
74
+ numberOfMonths={2}
75
+ />
76
+ ```
77
+
78
+ **Compact mode** — single calendar with presets below:
79
+
80
+ ```tsx
81
+ <RangePicker
82
+ value={range}
83
+ onChange={setRange}
84
+ presets={presets}
85
+ showPresets
86
+ compact
87
+ closeOnSelect
88
+ />
89
+ ```
90
+
91
+ ### TimePicker
92
+
93
+ ```tsx
94
+ <TimePicker
95
+ value={time}
96
+ onChange={setTime}
97
+ minuteStep={5}
98
+ format="12h"
99
+ />
100
+ ```
101
+
102
+ ### DateTimePicker
103
+
104
+ Combined date and time selection with tabbed interface.
105
+
106
+ ```tsx
107
+ <DateTimePicker
108
+ value={dateTime}
109
+ onChange={setDateTime}
110
+ placeholder="Pick date & time"
111
+ />
112
+ ```
113
+
114
+ ### MonthPicker
115
+
116
+ ```tsx
117
+ <MonthPicker
118
+ value={monthDate}
119
+ onChange={setMonthDate}
120
+ placeholder="Pick a month"
121
+ />
122
+ ```
123
+
124
+ ### YearPicker
125
+
126
+ ```tsx
127
+ <YearPicker
128
+ value={year}
129
+ onChange={setYear}
130
+ placeholder="Pick a year"
131
+ />
132
+ ```
133
+
134
+ ### WeekPicker
135
+
136
+ ```tsx
137
+ <WeekPicker
138
+ onChange={(start, end, weekNumber) => {
139
+ console.log(`Week ${weekNumber}: ${start} – ${end}`);
140
+ }}
141
+ />
142
+ ```
143
+
144
+ ## Size Variants
145
+
146
+ All pickers accept a `size` prop: `"sm"`, `"md"` (default), or `"lg"`.
147
+
148
+ ```tsx
149
+ <DatePicker size="sm" placeholder="Small" />
150
+ <DatePicker size="md" placeholder="Medium" />
151
+ <DatePicker size="lg" placeholder="Large" />
152
+ ```
153
+
154
+ ## Presets
155
+
156
+ Use `createPresets()` to generate common range presets:
157
+
158
+ ```tsx
159
+ import { createPresets } from 'best-react-datepicker';
160
+
161
+ // All built-in presets
162
+ const presets = createPresets();
163
+
164
+ // Select specific presets
165
+ const presets = createPresets({
166
+ include: ['today', 'last7', 'last30', 'thisMonth'],
167
+ });
168
+
169
+ // Add custom presets
170
+ const presets = createPresets({
171
+ include: ['today', 'last7'],
172
+ custom: [
173
+ {
174
+ label: 'Next 7 days',
175
+ value: () => ({ from: new Date(), to: addDays(new Date(), 6) }),
176
+ },
177
+ ],
178
+ });
179
+ ```
180
+
181
+ Built-in preset keys: `today`, `yesterday`, `last7`, `last30`, `thisMonth`, `lastMonth`, `thisYear`
182
+
183
+ ## Theming
184
+
185
+ Override CSS variables to match your brand:
186
+
187
+ ```tsx
188
+ <div style={{
189
+ '--brdp-color-accent': '#8b5cf6',
190
+ '--brdp-color-accent-light': '#ede9fe',
191
+ '--brdp-color-accent-dark': '#7c3aed',
192
+ }}>
193
+ <DatePicker placeholder="Purple theme" />
194
+ </div>
195
+ ```
196
+
197
+ ### Dark Mode
198
+
199
+ ```tsx
200
+ <div className="brdp-dark">
201
+ <DatePicker placeholder="Dark mode" />
202
+ </div>
203
+ ```
204
+
205
+ Or use the data attribute:
206
+
207
+ ```html
208
+ <div data-brdp-theme="dark">...</div>
209
+ ```
210
+
211
+ ### Key CSS Variables
212
+
213
+ | Variable | Default | Description |
214
+ |---|---|---|
215
+ | `--brdp-color-accent` | `#2563eb` | Primary accent color |
216
+ | `--brdp-color-accent-light` | `#dbeafe` | Light accent (range background) |
217
+ | `--brdp-color-accent-dark` | `#1d4ed8` | Dark accent (hover states) |
218
+ | `--brdp-color-bg` | `#ffffff` | Background color |
219
+ | `--brdp-color-text` | `#111827` | Text color |
220
+ | `--brdp-color-border` | `#e5e7eb` | Border color |
221
+ | `--brdp-cell-size` | `40px` | Day cell size |
222
+ | `--brdp-radius-day` | `9999px` | Day cell border radius |
223
+ | `--brdp-font-family` | `inherit` | Font family |
224
+
225
+ ## Headless Usage
226
+
227
+ Use the hooks directly for full control over rendering:
228
+
229
+ ```tsx
230
+ import { useDatePicker } from 'best-react-datepicker/hooks';
231
+
232
+ function CustomDatePicker() {
233
+ const picker = useDatePicker({
234
+ onChange: (date) => console.log(date),
235
+ closeOnSelect: true,
236
+ });
237
+
238
+ // Build your own UI using picker state and methods
239
+ return <div>{/* your custom UI */}</div>;
240
+ }
241
+ ```
242
+
243
+ Available hooks: `useDatePicker`, `useRangePicker`, `useTimePicker`, `useDateTimePicker`, `useMonthPicker`, `useYearPicker`, `useWeekPicker`, `useCalendar`, `useMultiPicker`
244
+
245
+ ## Utilities
246
+
247
+ Date utilities are available as a separate entry point:
248
+
249
+ ```tsx
250
+ import {
251
+ addDays,
252
+ subMonths,
253
+ startOfMonth,
254
+ formatDate,
255
+ parseDate,
256
+ } from 'best-react-datepicker/utils';
257
+ ```
258
+
259
+ ## Accessibility
260
+
261
+ - Full keyboard navigation (arrow keys, Home/End, Page Up/Down, Escape)
262
+ - ARIA labels on all interactive elements
263
+ - Live region announcements for month changes
264
+ - Focus trapping within popover
265
+ - Screen reader support for selected states
266
+
267
+ ## Browser Support
268
+
269
+ All modern browsers (Chrome, Firefox, Safari, Edge).
270
+
271
+ ## License
272
+
273
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "best-react-datepicker",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "The most customizable, accessible, zero-dependency React date picker",
5
5
  "license": "MIT",
6
6
  "type": "module",