@atawi/react-date-picker 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Atawi
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,318 @@
1
+ # React Date Picker
2
+
3
+ A beautiful, customizable date and time picker component for React with comprehensive built-in styling, multiple themes and localization support.
4
+
5
+ ![npm version](https://img.shields.io/npm/v/@ahmedalatawi/react-date-picker)
6
+ ![license](https://img.shields.io/npm/l/@ahmedalatawi/react-date-picker)
7
+ ![bundle size](https://img.shields.io/bundlephobia/minzip/@ahmedalatawi/react-date-picker)
8
+
9
+ ## Features
10
+
11
+ - 📅 Multiple selection modes:
12
+ - Single date selection
13
+ - Date range selection
14
+ - Week range selection
15
+ - 🕒 Time picker with 12/24-hour format support
16
+ - 🌍 Internationalization support with date-fns locales
17
+ - 🎨 Beautiful built-in styling that works out of the box
18
+ - 🎯 Fully customizable styling with CSS classes
19
+ - 📱 Responsive and mobile-friendly design
20
+ - ♿ Accessibility-friendly with full keyboard navigation
21
+ - 🔧 TypeScript support
22
+ - 📝 Date notes and annotations support
23
+ - ✨ Confirmation mode with OK button
24
+ - 🎯 Standalone time picker component
25
+ - 📦 Tree-shakeable, lightweight, and works without any dependencies on CSS frameworks
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ npm install @atawi/react-date-picker
31
+ ```
32
+
33
+ ## Setup
34
+
35
+ The library works out of the box with comprehensive built-in styles. Simply import the component and start using it:
36
+
37
+ ```tsx
38
+ import { DateTimePicker } from "@atawi/react-date-picker";
39
+
40
+ function App() {
41
+ const [date, setDate] = useState(new Date());
42
+
43
+ return <DateTimePicker value={date} onChange={setDate} showTime />;
44
+ }
45
+ ```
46
+
47
+ The library includes comprehensive built-in styles that provide:
48
+
49
+ - Beautiful hover states and interactions
50
+ - Modern blue selection colors
51
+ - Dark mode support
52
+ - Fully responsive design
53
+ - Smooth animations and transitions
54
+ - Professional appearance suitable for any application
55
+
56
+ ## Basic Usage
57
+
58
+ ```tsx
59
+ import { DateTimePicker } from "@atawi/react-date-picker";
60
+
61
+ function App() {
62
+ const [date, setDate] = useState(new Date());
63
+
64
+ return <DateTimePicker value={date} onChange={setDate} showTime />;
65
+ }
66
+ ```
67
+
68
+ ## Examples
69
+
70
+ ### Single Date Selection
71
+
72
+ ```tsx
73
+ // Basic date picker
74
+ <DateTimePicker
75
+ value={date}
76
+ onChange={setDate}
77
+ mode="single"
78
+ showTime={false}
79
+ />
80
+
81
+ // With time selection
82
+ <DateTimePicker
83
+ value={date}
84
+ onChange={setDate}
85
+ mode="single"
86
+ showTime
87
+ use24Hour={false}
88
+ />
89
+ ```
90
+
91
+ ### Date Range Selection
92
+
93
+ ```tsx
94
+ const [dateRange, setDateRange] = useState<[Date, Date]>([
95
+ new Date(),
96
+ addDays(new Date(), 5),
97
+ ]);
98
+
99
+ <DateTimePicker
100
+ value={dateRange}
101
+ onChange={setDateRange}
102
+ mode="range"
103
+ showTime={false}
104
+ />;
105
+ ```
106
+
107
+ ### Week Range Selection
108
+
109
+ ```tsx
110
+ const [weekRange, setWeekRange] = useState<[Date, Date]>([
111
+ startOfWeek(new Date()),
112
+ endOfWeek(new Date()),
113
+ ]);
114
+
115
+ <DateTimePicker
116
+ value={weekRange}
117
+ onChange={setWeekRange}
118
+ mode="week"
119
+ showTime={false}
120
+ />;
121
+ ```
122
+
123
+ ### With Date Notes
124
+
125
+ ```tsx
126
+ const notes = [
127
+ {
128
+ date: new Date(),
129
+ note: "Today's special event: Team meeting at 2 PM",
130
+ },
131
+ {
132
+ startDate: addDays(new Date(), 3),
133
+ endDate: addDays(new Date(), 5),
134
+ note: "Annual conference in New York",
135
+ },
136
+ ];
137
+
138
+ <DateTimePicker value={date} onChange={setDate} mode="single" notes={notes} />;
139
+ ```
140
+
141
+ ### Dark Mode
142
+
143
+ ```tsx
144
+ <DateTimePicker
145
+ value={date}
146
+ onChange={setDate}
147
+ mode="single"
148
+ showTime
149
+ darkMode={true}
150
+ />
151
+ ```
152
+
153
+ ### With Confirmation Button
154
+
155
+ ```tsx
156
+ const [selectedDate, setSelectedDate] = useState(new Date());
157
+ const [isOpen, setIsOpen] = useState(false);
158
+
159
+ <DateTimePicker
160
+ value={selectedDate}
161
+ onChange={setSelectedDate}
162
+ mode="single"
163
+ showTime
164
+ isOpen={isOpen}
165
+ onOpenChange={setIsOpen}
166
+ footer={
167
+ <div
168
+ style={{
169
+ marginTop: "1rem",
170
+ paddingTop: "1rem",
171
+ borderTop: "1px solid #e5e7eb",
172
+ display: "flex",
173
+ justifyContent: "flex-end",
174
+ }}
175
+ >
176
+ <ConfirmButton
177
+ onConfirm={() => {
178
+ // Handle confirmation
179
+ setIsOpen(false);
180
+ }}
181
+ />
182
+ </div>
183
+ }
184
+ />;
185
+ ```
186
+
187
+ ### Standalone Time Picker
188
+
189
+ ```tsx
190
+ import { TimePicker } from "@atawi/react-date-picker";
191
+
192
+ const [time, setTime] = useState(new Date());
193
+
194
+ <TimePicker value={time} onChange={setTime} use24Hour={false} />;
195
+ ```
196
+
197
+ ### Custom Styling
198
+
199
+ You can customize the appearance using CSS classes:
200
+
201
+ ```tsx
202
+ const customStyles = {
203
+ containerClassName: "my-date-picker",
204
+ triggerClassName: "my-trigger-button",
205
+ calendarClassName: "my-calendar",
206
+ dayClassName: "my-day-button",
207
+ selectedDayClassName: "my-selected-day",
208
+ };
209
+
210
+ <DateTimePicker value={date} onChange={setDate} styles={customStyles} />;
211
+ ```
212
+
213
+ Then style with CSS:
214
+
215
+ ```css
216
+ .my-date-picker {
217
+ /* Custom container styles */
218
+ }
219
+
220
+ .my-trigger-button {
221
+ background: #f0f0f0;
222
+ border: 2px solid #ccc;
223
+ border-radius: 8px;
224
+ }
225
+
226
+ .my-selected-day {
227
+ background: #ff6b6b;
228
+ color: white;
229
+ }
230
+ ```
231
+
232
+ ## Props API
233
+
234
+ ### DateTimePicker Props
235
+
236
+ | Prop | Type | Default | Description |
237
+ | --------------- | -------------------------------------- | ------------ | -------------------------------- |
238
+ | `value` | `Date \| [Date, Date]` | `new Date()` | Selected date or date range |
239
+ | `onChange` | `(date: Date \| [Date, Date]) => void` | Required | Callback when date changes |
240
+ | `mode` | `'single' \| 'range' \| 'week'` | `'single'` | Selection mode |
241
+ | `showTime` | `boolean` | `true` | Show time picker |
242
+ | `use24Hour` | `boolean` | `false` | Use 24-hour format |
243
+ | `disabled` | `boolean` | `false` | Disable the picker |
244
+ | `disabledDates` | `Date[]` | `[]` | Array of disabled dates |
245
+ | `locale` | `Locale` | `undefined` | date-fns locale object |
246
+ | `notes` | `DateNoteType[]` | `[]` | Array of date notes |
247
+ | `darkMode` | `boolean` | `false` | Enable dark mode styling |
248
+ | `isOpen` | `boolean` | `undefined` | Control open state |
249
+ | `onOpenChange` | `(isOpen: boolean) => void` | `undefined` | Callback when open state changes |
250
+ | `footer` | `React.ReactNode` | `undefined` | Custom footer content |
251
+ | `styles` | `StyleProps` | `{}` | Custom style classes |
252
+
253
+ ### TimePicker Props
254
+
255
+ | Prop | Type | Default | Description |
256
+ | ----------- | ---------------------- | -------- | -------------------------- |
257
+ | `value` | `Date` | Required | Selected time |
258
+ | `onChange` | `(date: Date) => void` | Required | Callback when time changes |
259
+ | `use24Hour` | `boolean` | `false` | Use 24-hour format |
260
+ | `disabled` | `boolean` | `false` | Disable the picker |
261
+ | `darkMode` | `boolean` | `false` | Enable dark mode styling |
262
+ | `styles` | `StyleProps` | `{}` | Custom style classes |
263
+
264
+ ### Style Props
265
+
266
+ | Prop | Type | Description |
267
+ | ---------------------- | -------- | -------------------------------- |
268
+ | `containerClassName` | `string` | Class for the main container |
269
+ | `triggerClassName` | `string` | Class for the trigger button |
270
+ | `calendarClassName` | `string` | Class for the calendar container |
271
+ | `dayClassName` | `string` | Class for calendar day buttons |
272
+ | `selectedDayClassName` | `string` | Class for selected day |
273
+ | `rangeClassName` | `string` | Class for days in range |
274
+ | `timePickerClassName` | `string` | Class for time picker section |
275
+
276
+ ## Styling
277
+
278
+ The library comes with beautiful built-in styles that work out of the box. You can customize the appearance by:
279
+
280
+ 1. **Using the `styles` prop** to apply custom CSS classes
281
+ 2. **Using the `darkMode` prop** for automatic dark mode styling
282
+ 3. **Overriding CSS classes** in your own stylesheet
283
+ 4. **Using CSS custom properties** for theme customization
284
+
285
+ ### Built-in Themes
286
+
287
+ The library includes several built-in visual themes:
288
+
289
+ - Default modern theme with blue accents
290
+ - Dark mode support (automatic via media queries or manual via `darkMode` prop)
291
+ - Material Design inspired styling
292
+ - Clean, minimal appearance
293
+ - Professional business styling
294
+
295
+ ## Accessibility
296
+
297
+ The component is built with accessibility in mind:
298
+
299
+ - Full keyboard navigation support
300
+ - ARIA labels and roles
301
+ - Focus management
302
+ - Screen reader friendly
303
+ - High contrast mode support
304
+
305
+ ## Browser Support
306
+
307
+ - Chrome (and Chromium-based browsers) ≥ 60
308
+ - Firefox ≥ 60
309
+ - Safari ≥ 12
310
+ - Edge ≥ 79
311
+
312
+ ## Contributing
313
+
314
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
315
+
316
+ ## License
317
+
318
+ MIT © [Atawi](https://github.com/ahmedalatawi)
@@ -0,0 +1 @@
1
+ export {}