@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.
Files changed (44) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +32 -5
  3. package/dist/App.d.ts +2 -0
  4. package/dist/components/DateTimePicker/Calendar.d.ts +24 -0
  5. package/dist/components/DateTimePicker/ConfirmButton.d.ts +9 -0
  6. package/dist/components/DateTimePicker/DateNote.d.ts +3 -0
  7. package/dist/components/DateTimePicker/DateTimePicker.d.ts +3 -0
  8. package/dist/components/DateTimePicker/Popover.d.ts +9 -0
  9. package/dist/components/DateTimePicker/TimePicker.d.ts +12 -0
  10. package/dist/components/DateTimePicker/Tooltip.d.ts +7 -0
  11. package/dist/components/DateTimePicker/__tests__/Calendar.test.d.ts +1 -0
  12. package/dist/components/DateTimePicker/__tests__/ConfirmButton.test.d.ts +1 -0
  13. package/dist/components/DateTimePicker/__tests__/DateNote.test.d.ts +1 -0
  14. package/dist/components/DateTimePicker/__tests__/DateTimePicker.test.d.ts +1 -0
  15. package/dist/components/DateTimePicker/__tests__/Popover.test.d.ts +1 -0
  16. package/dist/components/DateTimePicker/__tests__/TimePicker.test.d.ts +1 -0
  17. package/dist/components/DateTimePicker/__tests__/Tooltip.test.d.ts +1 -0
  18. package/dist/components/DateTimePicker/types.d.ts +31 -0
  19. package/dist/components/TimePicker/TimePicker.d.ts +17 -0
  20. package/dist/components/TimePicker/__tests__/TimePicker.test.d.ts +1 -0
  21. package/dist/components/examples/CleanRangeExample.d.ts +2 -0
  22. package/dist/components/examples/ConfirmationExample.d.ts +2 -0
  23. package/dist/components/examples/HotelBookingExample.d.ts +2 -0
  24. package/dist/components/examples/MaterialExample.d.ts +2 -0
  25. package/dist/components/examples/NotesExample.d.ts +2 -0
  26. package/dist/components/examples/RangeNotesExample.d.ts +2 -0
  27. package/dist/components/examples/TimePickerExample.d.ts +2 -0
  28. package/dist/components/examples/WeekRangeExample.d.ts +2 -0
  29. package/dist/components/icons/index.d.ts +9 -0
  30. package/dist/hooks/__tests__/useA11y.test.d.ts +1 -0
  31. package/dist/hooks/__tests__/useKeyboardNavigation.test.d.ts +1 -0
  32. package/dist/hooks/useA11y.d.ts +5 -0
  33. package/dist/hooks/useKeyboardNavigation.d.ts +1 -0
  34. package/dist/index.d.ts +15 -1
  35. package/dist/index.js +158 -157
  36. package/dist/index.js.map +1 -1
  37. package/dist/main.d.ts +0 -0
  38. package/dist/setupTests.d.ts +0 -0
  39. package/dist/types/dates.d.ts +17 -0
  40. package/dist/utils/dates.d.ts +6 -0
  41. package/dist/utils/dates.test.d.ts +1 -0
  42. package/dist/utils/notes.d.ts +3 -0
  43. package/dist/utils/notes.test.d.ts +1 -0
  44. 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
- A beautiful, customizable date and time picker component for React with comprehensive built-in styling, multiple themes and localization support.
3
+ ![](https://github.com/AhmedAlatawi/react-date-picker/actions/workflows/ci.yml/badge.svg)
4
+ ![npm version](https://img.shields.io/npm/v/@atawi/react-date-picker)
5
+ ![license](https://img.shields.io/npm/l/@atawi/react-date-picker)
6
+ ![bundle size](https://img.shields.io/bundlephobia/minzip/@atawi/react-date-picker)
7
+ [![codecov](https://codecov.io/github/ahmedalatawi/react-date-picker/graph/badge.svg?token=141KSD7U2J)](https://codecov.io/github/ahmedalatawi/react-date-picker)
4
8
 
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)
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
- The library works out of the box with comprehensive built-in styles. Simply import the component and start using it:
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,2 @@
1
+ declare function App(): import("react/jsx-runtime").JSX.Element;
2
+ export default App;
@@ -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,9 @@
1
+ import { FC, ReactNode } from 'react';
2
+ interface ConfirmButtonProps {
3
+ onConfirm: () => void;
4
+ className?: string;
5
+ children?: ReactNode;
6
+ darkMode?: boolean;
7
+ }
8
+ export declare const ConfirmButton: FC<ConfirmButtonProps>;
9
+ export {};
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { DateNoteProps } from '../../types/dates';
3
+ export declare const DateNote: FC<DateNoteProps>;
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { DateTimePickerProps } from './types';
3
+ export declare const DateTimePicker: FC<DateTimePickerProps>;
@@ -0,0 +1,9 @@
1
+ import { FC, ReactNode } from 'react';
2
+ interface PopoverProps {
3
+ isOpen: boolean;
4
+ onClose: () => void;
5
+ children: ReactNode;
6
+ content: ReactNode;
7
+ }
8
+ export declare const Popover: FC<PopoverProps>;
9
+ 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,7 @@
1
+ import { FC, ReactNode } from 'react';
2
+ interface TooltipProps {
3
+ content: ReactNode;
4
+ className?: string;
5
+ }
6
+ export declare const Tooltip: FC<TooltipProps>;
7
+ 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,2 @@
1
+ import { FC } from 'react';
2
+ export declare const CleanRangeExample: FC;
@@ -0,0 +1,2 @@
1
+ import { FC } from 'react';
2
+ export declare const ConfirmationExample: FC;
@@ -0,0 +1,2 @@
1
+ import { FC } from 'react';
2
+ export declare const HotelBookingExample: FC;
@@ -0,0 +1,2 @@
1
+ import { FC } from 'react';
2
+ export declare const MaterialExample: FC;
@@ -0,0 +1,2 @@
1
+ import { FC } from 'react';
2
+ export declare const NotesExample: FC;
@@ -0,0 +1,2 @@
1
+ import { FC } from 'react';
2
+ export declare const RangeNotesExample: FC;
@@ -0,0 +1,2 @@
1
+ import { FC } from 'react';
2
+ export declare const TimePickerExample: FC;
@@ -0,0 +1,2 @@
1
+ import { FC } from 'react';
2
+ export declare const WeekRangeExample: FC;
@@ -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,5 @@
1
+ export declare const useA11y: (isOpen: boolean, onClose: () => void, triggerRef: React.RefObject<HTMLElement>, contentRef: React.RefObject<HTMLElement>) => {
2
+ role: string;
3
+ "aria-modal": boolean;
4
+ "aria-label": string;
5
+ };
@@ -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';