nearpay-datepicker-react 0.2.2

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 (36) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +131 -0
  3. package/dist/components/Calendar/Days.d.ts +12 -0
  4. package/dist/components/Calendar/Months.d.ts +6 -0
  5. package/dist/components/Calendar/Week.d.ts +2 -0
  6. package/dist/components/Calendar/Years.d.ts +9 -0
  7. package/dist/components/Calendar/index.d.ts +12 -0
  8. package/dist/components/Datepicker.d.ts +3 -0
  9. package/dist/components/Footer.d.ts +2 -0
  10. package/dist/components/Input.d.ts +6 -0
  11. package/dist/components/PrimaryButton.d.ts +3 -0
  12. package/dist/components/RoundedButton.d.ts +3 -0
  13. package/dist/components/SecondaryButton.d.ts +3 -0
  14. package/dist/components/Shortcuts.d.ts +2 -0
  15. package/dist/components/ToggleButton.d.ts +5 -0
  16. package/dist/components/VerticalDash.d.ts +2 -0
  17. package/dist/components/icons/Arrow.d.ts +6 -0
  18. package/dist/components/icons/ChevronLeftIcon.d.ts +3 -0
  19. package/dist/components/icons/ChevronRightIcon.d.ts +3 -0
  20. package/dist/components/icons/CloseIcon.d.ts +3 -0
  21. package/dist/components/icons/DateIcon.d.ts +3 -0
  22. package/dist/components/icons/DoubleChevronLeftIcon.d.ts +3 -0
  23. package/dist/components/icons/DoubleChevronRightIcon.d.ts +3 -0
  24. package/dist/constants/index.d.ts +16 -0
  25. package/dist/constants/shortcuts.d.ts +5 -0
  26. package/dist/contexts/DatepickerContext.d.ts +43 -0
  27. package/dist/helpers/index.d.ts +4 -0
  28. package/dist/hooks/index.d.ts +2 -0
  29. package/dist/index.cjs.js +4801 -0
  30. package/dist/index.cjs.js.map +1 -0
  31. package/dist/index.d.ts +3 -0
  32. package/dist/index.esm.js +4799 -0
  33. package/dist/index.esm.js.map +1 -0
  34. package/dist/libs/date.d.ts +30 -0
  35. package/dist/types/index.d.ts +98 -0
  36. package/package.json +88 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Onesine
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,131 @@
1
+ # Nearpay Datepicker
2
+
3
+ <p align="center">
4
+ A modern date range picker component for React using Tailwind 3 and dayjs. Alternative to Litepie Datepicker which uses Vuejs.
5
+ </p>
6
+
7
+ <div align="center">
8
+
9
+ [![npm version](https://img.shields.io/npm/v/nearpay-datepicker?style=flat-square)](https://www.npmjs.com/package/nearpay-datepicker)
10
+
11
+ </div>
12
+
13
+ ## Contents
14
+
15
+ - [Features](#features)
16
+ - [Installation](#installation)
17
+ - [Simple Usage](#simple-usage)
18
+ - [Playground](#playground)
19
+ - [Contributing](#contributing)
20
+
21
+ ## Features
22
+
23
+ - ✅ Theming options
24
+ - ✅ Dark mode
25
+ - ✅ Single Date
26
+ - ✅ Single date use Range
27
+ - ✅ Shortcuts
28
+ - ✅ TypeScript support
29
+ - ✅ Localization(i18n)
30
+ - ✅ Date formatting
31
+ - ✅ Disable specific dates
32
+ - ✅ Minimum Date and Maximum Date
33
+ - ✅ Custom shortcuts
34
+
35
+ ## Installation
36
+
37
+ ⚠️ Nearpay Datepicker uses Tailwind CSS 3 (with the
38
+ [@tailwindcss/forms](https://github.com/tailwindlabs/tailwindcss-forms) plugin) &
39
+ [Dayjs](https://day.js.org/en/) under the hood to work.
40
+
41
+ ### Install via npm
42
+
43
+ ```
44
+ npm install nearpay-datepicker
45
+ ```
46
+
47
+ ### Install via yarn
48
+
49
+ ```
50
+ yarn add nearpay-datepicker
51
+ ```
52
+
53
+ Make sure you have installed the peer dependencies as well with the below versions.
54
+
55
+ ```
56
+ "dayjs": "^1.11.12",
57
+ "react": "^17.0.2 || ^18.2.0" || "^19.0.0"
58
+ ```
59
+
60
+ ## Simple Usage
61
+
62
+ #### Tailwindcss Configuration
63
+
64
+ Add the datepicker to your tailwind configuration using this code
65
+
66
+ ```javascript
67
+ // in your tailwind.config.js
68
+ module.exports = {
69
+ // ...
70
+ content: ["./src/**/*.{js,jsx,ts,tsx}", "./node_modules/nearpay-datepicker/dist/index.esm.js"]
71
+ // ...
72
+ };
73
+ ```
74
+
75
+ Then use nearpay-datepicker-select in your app:
76
+
77
+ ```tsx
78
+ import { useState } from "react";
79
+ import Datepicker from "nearpay-datepicker";
80
+
81
+ const App = () => {
82
+ const [value, setValue] = useState({
83
+ startDate: null,
84
+ endDate: null
85
+ });
86
+
87
+ return (
88
+ <>
89
+ <Datepicker value={value} onChange={newValue => setValue(newValue)} />
90
+ </>
91
+ );
92
+ };
93
+
94
+ export default App;
95
+ ```
96
+
97
+ ## PlayGround
98
+
99
+ Clone the `master` branch and run commands:
100
+
101
+ ```sh
102
+ # Using npm
103
+ npm install && npm dev
104
+
105
+ # Using yarn
106
+ yarn install && yarn dev
107
+
108
+ ```
109
+
110
+ Open a browser and navigate to `http://localhost:8888`
111
+
112
+ ## Contributing
113
+
114
+ See [CONTRIBUTING.md](https://github.com/nearpayio/nearpay-datepicker/blob/master/CONTRIBUTING.md)
115
+
116
+ ## Official Documentation repo
117
+
118
+ [https://github.com/nearpayio/nearpay-datepicker-doc](https://github.com/nearpayio/nearpay-datepicker-doc)
119
+
120
+ ## Thanks to
121
+
122
+ - [Vue Tailwind Datepicker](https://vue-tailwind-datepicker.com/)
123
+ - [React](https://reactjs.org/)
124
+ - [Tailwind CSS](https://tailwindcss.com/)
125
+ - [dayjs](https://day.js.org/)
126
+
127
+ I thank you in advance for your contribution to this project.
128
+
129
+ ## License
130
+
131
+ [MIT](LICENSE) Licensed. Copyright (c) Lewhe nearpayio 2022.
@@ -0,0 +1,12 @@
1
+ interface Props {
2
+ days: {
3
+ previous: Date[];
4
+ current: Date[];
5
+ next: Date[];
6
+ };
7
+ onClickPreviousDays: (day: Date) => void;
8
+ onClickDay: (day: Date) => void;
9
+ onClickNextDays: (day: Date) => void;
10
+ }
11
+ declare const Days: (props: Props) => import("react/jsx-runtime").JSX.Element;
12
+ export default Days;
@@ -0,0 +1,6 @@
1
+ interface Props {
2
+ currentMonth: number;
3
+ clickMonth: (month: number) => void;
4
+ }
5
+ declare const Months: (props: Props) => import("react/jsx-runtime").JSX.Element;
6
+ export default Months;
@@ -0,0 +1,2 @@
1
+ declare const Week: () => import("react/jsx-runtime").JSX.Element;
2
+ export default Week;
@@ -0,0 +1,9 @@
1
+ interface Props {
2
+ year: number;
3
+ currentYear: number;
4
+ minYear: number | null;
5
+ maxYear: number | null;
6
+ clickYear: (data: number) => void;
7
+ }
8
+ declare const Years: (props: Props) => import("react/jsx-runtime").JSX.Element;
9
+ export default Years;
@@ -0,0 +1,12 @@
1
+ import { DateType } from "types";
2
+ interface Props {
3
+ date: Date;
4
+ minDate?: DateType;
5
+ maxDate?: DateType;
6
+ onClickPrevious: () => void;
7
+ onClickNext: () => void;
8
+ changeMonth: (month: number) => void;
9
+ changeYear: (year: number) => void;
10
+ }
11
+ declare const Calendar: (props: Props) => import("react/jsx-runtime").JSX.Element;
12
+ export default Calendar;
@@ -0,0 +1,3 @@
1
+ import { DatepickerType } from "../types";
2
+ declare const Datepicker: (props: DatepickerType) => import("react/jsx-runtime").JSX.Element;
3
+ export default Datepicker;
@@ -0,0 +1,2 @@
1
+ declare const Footer: () => import("react/jsx-runtime").JSX.Element;
2
+ export default Footer;
@@ -0,0 +1,6 @@
1
+ import { RefObject } from "react";
2
+ type Props = {
3
+ setContextRef?: (ref: RefObject<HTMLInputElement>) => void;
4
+ };
5
+ declare const Input: (e: Props) => import("react/jsx-runtime").JSX.Element;
6
+ export default Input;
@@ -0,0 +1,3 @@
1
+ import { ButtonProps } from "../types";
2
+ declare const PrimaryButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default PrimaryButton;
@@ -0,0 +1,3 @@
1
+ import { ButtonProps } from "../types";
2
+ declare const RoundedButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default RoundedButton;
@@ -0,0 +1,3 @@
1
+ import { ButtonProps } from "../types";
2
+ declare const SecondaryButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default SecondaryButton;
@@ -0,0 +1,2 @@
1
+ declare const Shortcuts: () => import("react/jsx-runtime").JSX.Element | null;
2
+ export default Shortcuts;
@@ -0,0 +1,5 @@
1
+ interface Props {
2
+ isEmpty: boolean;
3
+ }
4
+ declare const ToggleButton: (e: Props) => import("react/jsx-runtime").JSX.Element;
5
+ export default ToggleButton;
@@ -0,0 +1,2 @@
1
+ declare const VerticalDash: () => import("react/jsx-runtime").JSX.Element;
2
+ export default VerticalDash;
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from "react";
2
+ interface Props {
3
+ children?: ReactNode;
4
+ }
5
+ declare const Arrow: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<HTMLDivElement>>;
6
+ export default Arrow;
@@ -0,0 +1,3 @@
1
+ import { IconProps } from "../../types";
2
+ declare const ChevronLeftIcon: (props: IconProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default ChevronLeftIcon;
@@ -0,0 +1,3 @@
1
+ import { IconProps } from "../../types";
2
+ declare const ChevronRightIcon: (props: IconProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default ChevronRightIcon;
@@ -0,0 +1,3 @@
1
+ import { IconProps } from "../../types";
2
+ declare const CloseIcon: (props: IconProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default CloseIcon;
@@ -0,0 +1,3 @@
1
+ import { IconProps } from "../../types";
2
+ declare const DateIcon: (props: IconProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default DateIcon;
@@ -0,0 +1,3 @@
1
+ import { IconProps } from "../../types";
2
+ declare const DoubleChevronLeftIcon: (props: IconProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default DoubleChevronLeftIcon;
@@ -0,0 +1,3 @@
1
+ import { IconProps } from "../../types";
2
+ declare const DoubleChevronRightIcon: (props: IconProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default DoubleChevronRightIcon;
@@ -0,0 +1,16 @@
1
+ import { ColorKeys, Colors, DateLookingType, WeekStringType } from "../types";
2
+ export declare const COLORS: readonly ["blue", "orange", "yellow", "red", "purple", "amber", "lime", "green", "emerald", "teal", "cyan", "sky", "indigo", "violet", "purple", "fuchsia", "pink", "rose", "gray"];
3
+ export declare const DEFAULT_COLOR: ColorKeys;
4
+ export declare const DEFAULT_SEPARATOR = "~";
5
+ export declare const LANGUAGE = "en";
6
+ export declare const DATE_FORMAT = "YYYY-MM-DD";
7
+ export declare const START_WEEK: WeekStringType;
8
+ export declare const DATE_LOOKING_OPTIONS: readonly ["forward", "backward", "middle"];
9
+ export declare const DEFAULT_DATE_LOOKING: DateLookingType;
10
+ export declare const DAYS: readonly [0, 1, 2, 3, 4, 5, 6];
11
+ export declare const MONTHS: number[];
12
+ export declare const BG_COLOR: Colors;
13
+ export declare const TEXT_COLOR: Colors;
14
+ export declare const BORDER_COLOR: Colors;
15
+ export declare const RING_COLOR: Colors;
16
+ export declare const BUTTON_COLOR: Colors;
@@ -0,0 +1,5 @@
1
+ import { ShortcutsItem } from "../types";
2
+ declare const DEFAULT_SHORTCUTS: {
3
+ [key in string]: ShortcutsItem | ShortcutsItem[];
4
+ };
5
+ export default DEFAULT_SHORTCUTS;
@@ -0,0 +1,43 @@
1
+ import { ReactNode, RefObject } from "react";
2
+ import { Configs, Period, DateValueType, DateType, DateRangeType, ClassNamesTypeProp, PopoverDirectionType, ColorKeys, WeekStringType, DateLookingType } from "../types";
3
+ interface DatepickerStore {
4
+ arrowContainer: RefObject<HTMLDivElement> | null;
5
+ asSingle?: boolean;
6
+ calendarContainer: RefObject<HTMLDivElement> | null;
7
+ changeDatepickerValue: (value: DateValueType, e?: HTMLInputElement | null | undefined) => void;
8
+ changeDayHover: (day: DateType) => void;
9
+ changeInputText: (text: string) => void;
10
+ changePeriod: (period: Period) => void;
11
+ classNames?: ClassNamesTypeProp;
12
+ configs?: Configs;
13
+ containerClassName?: ((className: string) => string) | string | null;
14
+ dateLooking?: DateLookingType;
15
+ dayHover: DateType;
16
+ disabled?: boolean;
17
+ disabledDates?: DateRangeType[] | null;
18
+ displayFormat: string;
19
+ hideDatepicker: () => void;
20
+ i18n: string;
21
+ input?: RefObject<HTMLInputElement>;
22
+ inputClassName?: ((className: string) => string) | string | null;
23
+ inputId?: string;
24
+ inputName?: string;
25
+ inputText: string;
26
+ maxDate?: DateType | null;
27
+ minDate?: DateType | null;
28
+ period: Period;
29
+ placeholder?: string | null;
30
+ popoverDirection?: PopoverDirectionType;
31
+ primaryColor: ColorKeys;
32
+ readOnly?: boolean;
33
+ required?: boolean;
34
+ separator: string;
35
+ showFooter?: boolean;
36
+ startWeekOn?: WeekStringType | null;
37
+ toggleClassName?: ((className: string) => string) | string | null;
38
+ toggleIcon?: (open: boolean) => ReactNode;
39
+ updateFirstDate: (date: Date) => void;
40
+ value: DateValueType;
41
+ }
42
+ declare const DatepickerContext: import("react").Context<DatepickerStore>;
43
+ export default DatepickerContext;
@@ -0,0 +1,4 @@
1
+ export declare function classNames(...classes: (false | null | undefined | string)[]): string;
2
+ export declare function generateArrayNumber(start?: number, end?: number): number[];
3
+ export declare function shortString(value: string, limit?: number): string;
4
+ export declare function ucFirst(value: string): string;
@@ -0,0 +1,2 @@
1
+ import { RefObject } from "react";
2
+ export default function useOnClickOutside(ref: RefObject<HTMLDivElement>, handler: (e?: MouseEvent | TouchEvent) => void): void;