@atawi/react-date-picker 2.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 +4 -0
- package/README.md +25 -3
- 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/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 +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -17,3 +17,7 @@ import "@atawi/react-date-picker/style.css";
|
|
|
17
17
|
### Documentation
|
|
18
18
|
|
|
19
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
|
@@ -37,9 +37,10 @@ npm install @atawi/react-date-picker
|
|
|
37
37
|
Import the package stylesheet once in your app entry, then import components:
|
|
38
38
|
|
|
39
39
|
```tsx
|
|
40
|
-
import "@atawi/react-date-picker/style.css";
|
|
41
40
|
import { DateTimePicker } from "@atawi/react-date-picker";
|
|
42
41
|
|
|
42
|
+
import "@atawi/react-date-picker/style.css";
|
|
43
|
+
|
|
43
44
|
function App() {
|
|
44
45
|
const [date, setDate] = useState(new Date());
|
|
45
46
|
|
|
@@ -59,9 +60,10 @@ The library includes comprehensive built-in styles that provide:
|
|
|
59
60
|
## Basic Usage
|
|
60
61
|
|
|
61
62
|
```tsx
|
|
62
|
-
import "@atawi/react-date-picker/style.css";
|
|
63
63
|
import { DateTimePicker } from "@atawi/react-date-picker";
|
|
64
64
|
|
|
65
|
+
import "@atawi/react-date-picker/style.css";
|
|
66
|
+
|
|
65
67
|
function App() {
|
|
66
68
|
const [date, setDate] = useState(new Date());
|
|
67
69
|
|
|
@@ -69,6 +71,25 @@ function App() {
|
|
|
69
71
|
}
|
|
70
72
|
```
|
|
71
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
|
+
|
|
72
93
|
## Examples
|
|
73
94
|
|
|
74
95
|
### Single Date Selection
|
|
@@ -191,9 +212,10 @@ const [isOpen, setIsOpen] = useState(false);
|
|
|
191
212
|
### Standalone Time Picker
|
|
192
213
|
|
|
193
214
|
```tsx
|
|
194
|
-
import "@atawi/react-date-picker/style.css";
|
|
195
215
|
import { TimePicker } from "@atawi/react-date-picker";
|
|
196
216
|
|
|
217
|
+
import "@atawi/react-date-picker/style.css";
|
|
218
|
+
|
|
197
219
|
const [time, setTime] = useState(new Date());
|
|
198
220
|
|
|
199
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';
|
package/dist/main.d.ts
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface DateNote {
|
|
2
|
+
date: Date;
|
|
3
|
+
note: string;
|
|
4
|
+
}
|
|
5
|
+
export interface DateRangeNote {
|
|
6
|
+
startDate: Date;
|
|
7
|
+
endDate: Date;
|
|
8
|
+
note: string;
|
|
9
|
+
}
|
|
10
|
+
export type DateNoteType = DateNote | DateRangeNote;
|
|
11
|
+
export interface DateNoteProps {
|
|
12
|
+
notes: DateNoteType[];
|
|
13
|
+
hoveredDate?: Date | null;
|
|
14
|
+
selectedDate?: Date;
|
|
15
|
+
selectedRange?: [Date | null, Date | null];
|
|
16
|
+
darkMode?: boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const generateDisabledDates: (bookedRanges: [Date, Date][], blockedDays?: number) => Date[];
|
|
2
|
+
export declare const isDateDisabled: (date: Date, disabledDates: Date[]) => boolean;
|
|
3
|
+
export declare const getBookedRanges: () => [Date, Date][];
|
|
4
|
+
export declare const getWeekRange: (date: Date) => [Date, Date];
|
|
5
|
+
export declare const isDateInWeek: (date: Date, weekDate: Date) => boolean;
|
|
6
|
+
export declare const getWeekDays: (date: Date) => Date[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED