@atawi/react-date-picker 1.0.0 → 2.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/CHANGELOG.md +23 -0
- package/README.md +32 -5
- package/dist/App.d.ts +2 -0
- package/dist/components/DateTimePicker/Calendar.d.ts +24 -0
- package/dist/components/DateTimePicker/ConfirmButton.d.ts +9 -0
- package/dist/components/DateTimePicker/DateNote.d.ts +3 -0
- package/dist/components/DateTimePicker/DateTimePicker.d.ts +3 -0
- package/dist/components/DateTimePicker/Popover.d.ts +9 -0
- package/dist/components/DateTimePicker/TimePicker.d.ts +12 -0
- package/dist/components/DateTimePicker/Tooltip.d.ts +7 -0
- package/dist/components/DateTimePicker/__tests__/Calendar.test.d.ts +1 -0
- package/dist/components/DateTimePicker/__tests__/ConfirmButton.test.d.ts +1 -0
- package/dist/components/DateTimePicker/__tests__/DateNote.test.d.ts +1 -0
- package/dist/components/DateTimePicker/__tests__/DateTimePicker.test.d.ts +1 -0
- package/dist/components/DateTimePicker/__tests__/Popover.test.d.ts +1 -0
- package/dist/components/DateTimePicker/__tests__/TimePicker.test.d.ts +1 -0
- package/dist/components/DateTimePicker/__tests__/Tooltip.test.d.ts +1 -0
- package/dist/components/DateTimePicker/types.d.ts +31 -0
- package/dist/components/TimePicker/TimePicker.d.ts +17 -0
- package/dist/components/TimePicker/__tests__/TimePicker.test.d.ts +1 -0
- package/dist/components/examples/CleanRangeExample.d.ts +2 -0
- package/dist/components/examples/ConfirmationExample.d.ts +2 -0
- package/dist/components/examples/HotelBookingExample.d.ts +2 -0
- package/dist/components/examples/MaterialExample.d.ts +2 -0
- package/dist/components/examples/NotesExample.d.ts +2 -0
- package/dist/components/examples/RangeNotesExample.d.ts +2 -0
- package/dist/components/examples/TimePickerExample.d.ts +2 -0
- package/dist/components/examples/WeekRangeExample.d.ts +2 -0
- package/dist/components/icons/index.d.ts +9 -0
- package/dist/hooks/__tests__/useA11y.test.d.ts +1 -0
- package/dist/hooks/__tests__/useKeyboardNavigation.test.d.ts +1 -0
- package/dist/hooks/useA11y.d.ts +5 -0
- package/dist/hooks/useKeyboardNavigation.d.ts +1 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.js +158 -157
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +0 -0
- package/dist/setupTests.d.ts +0 -0
- package/dist/types/dates.d.ts +17 -0
- package/dist/utils/dates.d.ts +6 -0
- package/dist/utils/dates.test.d.ts +1 -0
- package/dist/utils/notes.d.ts +3 -0
- package/dist/utils/notes.test.d.ts +1 -0
- package/package.json +17 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
- Consumers must explicitly import the package stylesheet:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import "@atawi/react-date-picker/style.css";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
- The stylesheet is now exported via the package subpath `@atawi/react-date-picker/style.css`.
|
|
16
|
+
|
|
17
|
+
### Documentation
|
|
18
|
+
|
|
19
|
+
- Added "Required CSS Import" guidance to API, Getting Started, Installation, Examples, and README.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- Fixed declaration packaging so `dist/index.d.ts` includes the public named exports such as `DateTimePicker` and `TimePicker`.
|
package/README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# React Date Picker
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
[](https://codecov.io/github/ahmedalatawi/react-date-picker)
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-

|
|
7
|
-

|
|
9
|
+
A beautiful, customizable date and time picker component for React with comprehensive built-in styling, multiple themes and localization support.
|
|
8
10
|
|
|
9
11
|
## Features
|
|
10
12
|
|
|
@@ -32,11 +34,13 @@ npm install @atawi/react-date-picker
|
|
|
32
34
|
|
|
33
35
|
## Setup
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
Import the package stylesheet once in your app entry, then import components:
|
|
36
38
|
|
|
37
39
|
```tsx
|
|
38
40
|
import { DateTimePicker } from "@atawi/react-date-picker";
|
|
39
41
|
|
|
42
|
+
import "@atawi/react-date-picker/style.css";
|
|
43
|
+
|
|
40
44
|
function App() {
|
|
41
45
|
const [date, setDate] = useState(new Date());
|
|
42
46
|
|
|
@@ -58,6 +62,8 @@ The library includes comprehensive built-in styles that provide:
|
|
|
58
62
|
```tsx
|
|
59
63
|
import { DateTimePicker } from "@atawi/react-date-picker";
|
|
60
64
|
|
|
65
|
+
import "@atawi/react-date-picker/style.css";
|
|
66
|
+
|
|
61
67
|
function App() {
|
|
62
68
|
const [date, setDate] = useState(new Date());
|
|
63
69
|
|
|
@@ -65,6 +71,25 @@ function App() {
|
|
|
65
71
|
}
|
|
66
72
|
```
|
|
67
73
|
|
|
74
|
+
### Locale Example (date-fns)
|
|
75
|
+
|
|
76
|
+
Use a locale from `date-fns/locale` and pass it through the `locale` prop:
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { useState } from "react";
|
|
80
|
+
import { DateTimePicker } from "@atawi/react-date-picker";
|
|
81
|
+
import { fr } from "date-fns/locale";
|
|
82
|
+
import "@atawi/react-date-picker/style.css";
|
|
83
|
+
|
|
84
|
+
function App() {
|
|
85
|
+
const [date, setDate] = useState(new Date());
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<DateTimePicker value={date} onChange={setDate} showTime locale={fr} />
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
68
93
|
## Examples
|
|
69
94
|
|
|
70
95
|
### Single Date Selection
|
|
@@ -189,6 +214,8 @@ const [isOpen, setIsOpen] = useState(false);
|
|
|
189
214
|
```tsx
|
|
190
215
|
import { TimePicker } from "@atawi/react-date-picker";
|
|
191
216
|
|
|
217
|
+
import "@atawi/react-date-picker/style.css";
|
|
218
|
+
|
|
192
219
|
const [time, setTime] = useState(new Date());
|
|
193
220
|
|
|
194
221
|
<TimePicker value={time} onChange={setTime} use24Hour={false} />;
|
package/dist/App.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Locale } from 'date-fns';
|
|
3
|
+
import { DateNoteType } from '../../types/dates';
|
|
4
|
+
import { StyleProps } from './types';
|
|
5
|
+
interface CalendarProps {
|
|
6
|
+
currentDate: Date;
|
|
7
|
+
selectedDate?: Date;
|
|
8
|
+
selectedRange?: [Date | null, Date | null];
|
|
9
|
+
hoverDate?: Date | null;
|
|
10
|
+
mode: "single" | "range" | "week";
|
|
11
|
+
disabledDates: Date[];
|
|
12
|
+
locale?: Locale;
|
|
13
|
+
onDateClick: (date: Date) => void;
|
|
14
|
+
onDateHover?: (date: Date | null) => void;
|
|
15
|
+
onPrevMonth: () => void;
|
|
16
|
+
onNextMonth: () => void;
|
|
17
|
+
onMonthSelect: (month: number) => void;
|
|
18
|
+
onYearSelect: (year: number) => void;
|
|
19
|
+
styles?: StyleProps;
|
|
20
|
+
notes?: DateNoteType[];
|
|
21
|
+
darkMode?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const Calendar: FC<CalendarProps>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Locale } from 'date-fns';
|
|
3
|
+
interface TimePickerProps {
|
|
4
|
+
value: Date;
|
|
5
|
+
onChange: (date: Date) => void;
|
|
6
|
+
use24Hour?: boolean;
|
|
7
|
+
locale?: Locale;
|
|
8
|
+
className?: string;
|
|
9
|
+
darkMode?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const TimePicker: FC<TimePickerProps>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Locale } from 'date-fns';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { DateNoteType } from '../../types/dates';
|
|
4
|
+
export interface StyleProps {
|
|
5
|
+
containerClassName?: string;
|
|
6
|
+
triggerClassName?: string;
|
|
7
|
+
calendarClassName?: string;
|
|
8
|
+
timePickerClassName?: string;
|
|
9
|
+
dayClassName?: string;
|
|
10
|
+
selectedDayClassName?: string;
|
|
11
|
+
rangeClassName?: string;
|
|
12
|
+
disabledClassName?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface DateTimePickerProps {
|
|
15
|
+
value?: Date | [Date, Date];
|
|
16
|
+
onChange: (date: Date | [Date, Date]) => void;
|
|
17
|
+
mode?: "single" | "range" | "week";
|
|
18
|
+
showTime?: boolean;
|
|
19
|
+
use24Hour?: boolean;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
disabledDates?: Date[];
|
|
22
|
+
styles?: StyleProps;
|
|
23
|
+
locale?: Locale;
|
|
24
|
+
notes?: DateNoteType[];
|
|
25
|
+
onDateHover?: (date: Date | null) => void;
|
|
26
|
+
isOpen?: boolean;
|
|
27
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
28
|
+
footer?: ReactNode;
|
|
29
|
+
className?: string;
|
|
30
|
+
darkMode?: boolean;
|
|
31
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Locale } from 'date-fns';
|
|
3
|
+
export interface TimePickerProps {
|
|
4
|
+
value: Date;
|
|
5
|
+
onChange: (date: Date) => void;
|
|
6
|
+
use24Hour?: boolean;
|
|
7
|
+
locale?: Locale;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
darkMode?: boolean;
|
|
11
|
+
styles?: {
|
|
12
|
+
containerClassName?: string;
|
|
13
|
+
triggerClassName?: string;
|
|
14
|
+
popoverClassName?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare const TimePicker: FC<TimePickerProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
interface IconProps {
|
|
3
|
+
size?: number;
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const ChevronLeftIcon: FC<IconProps>;
|
|
7
|
+
export declare const ChevronRightIcon: FC<IconProps>;
|
|
8
|
+
export declare const ClockIcon: FC<IconProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useKeyboardNavigation: (currentDate: Date, onDateSelect: (date: Date) => void, onMonthChange: (date: Date) => void) => (event: React.KeyboardEvent) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export { DateTimePicker } from './components/DateTimePicker/DateTimePicker';
|
|
2
|
+
export { TimePicker } from './components/TimePicker/TimePicker';
|
|
3
|
+
export { Calendar } from './components/DateTimePicker/Calendar';
|
|
4
|
+
export { ConfirmButton } from './components/DateTimePicker/ConfirmButton';
|
|
5
|
+
export { Popover } from './components/DateTimePicker/Popover';
|
|
6
|
+
export { DateNote } from './components/DateTimePicker/DateNote';
|
|
7
|
+
export { Tooltip } from './components/DateTimePicker/Tooltip';
|
|
8
|
+
export type { DateTimePickerProps } from './components/DateTimePicker/types';
|
|
9
|
+
export type { TimePickerProps } from './components/TimePicker/TimePicker';
|
|
10
|
+
export type { StyleProps } from './components/DateTimePicker/types';
|
|
11
|
+
export type { DateNoteType } from './types/dates';
|
|
12
|
+
export { generateDisabledDates, isDateDisabled, getWeekRange, isDateInWeek, getWeekDays, } from './utils/dates';
|
|
13
|
+
export { findNoteForDate, hasNote } from './utils/notes';
|
|
14
|
+
export { useA11y } from './hooks/useA11y';
|
|
15
|
+
export { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|