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.
- package/LICENSE +21 -0
- package/README.md +131 -0
- package/dist/components/Calendar/Days.d.ts +12 -0
- package/dist/components/Calendar/Months.d.ts +6 -0
- package/dist/components/Calendar/Week.d.ts +2 -0
- package/dist/components/Calendar/Years.d.ts +9 -0
- package/dist/components/Calendar/index.d.ts +12 -0
- package/dist/components/Datepicker.d.ts +3 -0
- package/dist/components/Footer.d.ts +2 -0
- package/dist/components/Input.d.ts +6 -0
- package/dist/components/PrimaryButton.d.ts +3 -0
- package/dist/components/RoundedButton.d.ts +3 -0
- package/dist/components/SecondaryButton.d.ts +3 -0
- package/dist/components/Shortcuts.d.ts +2 -0
- package/dist/components/ToggleButton.d.ts +5 -0
- package/dist/components/VerticalDash.d.ts +2 -0
- package/dist/components/icons/Arrow.d.ts +6 -0
- package/dist/components/icons/ChevronLeftIcon.d.ts +3 -0
- package/dist/components/icons/ChevronRightIcon.d.ts +3 -0
- package/dist/components/icons/CloseIcon.d.ts +3 -0
- package/dist/components/icons/DateIcon.d.ts +3 -0
- package/dist/components/icons/DoubleChevronLeftIcon.d.ts +3 -0
- package/dist/components/icons/DoubleChevronRightIcon.d.ts +3 -0
- package/dist/constants/index.d.ts +16 -0
- package/dist/constants/shortcuts.d.ts +5 -0
- package/dist/contexts/DatepickerContext.d.ts +43 -0
- package/dist/helpers/index.d.ts +4 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/index.cjs.js +4801 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +4799 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/libs/date.d.ts +30 -0
- package/dist/types/index.d.ts +98 -0
- package/package.json +88 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import { DateType, WeekDaysIndexType, WeekStringType } from "../types";
|
|
3
|
+
export declare function loadLanguageModule(language?: string): void;
|
|
4
|
+
export declare function dateIsValid(date: DateType): boolean;
|
|
5
|
+
export declare function isCurrentDay(date: Date): boolean;
|
|
6
|
+
export declare function dateIsSame(a: Date, b: Date, unit: dayjs.OpUnitType): boolean;
|
|
7
|
+
export declare function dateIsBefore(a: Date, b: Date, unit: dayjs.OpUnitType): boolean;
|
|
8
|
+
export declare function dateIsAfter(a: Date, b: Date, unit: dayjs.OpUnitType): boolean;
|
|
9
|
+
export declare function dateIsSameOrBefore(a: DateType, b: DateType, unit: dayjs.OpUnitType): boolean;
|
|
10
|
+
export declare function dateIsSameOrAfter(a: DateType, b: DateType, unit: dayjs.OpUnitType): boolean;
|
|
11
|
+
export declare function dateIsBetween(whoIsBetween: Date, start: Date, end: Date, unit: dayjs.OpUnitType, include?: {
|
|
12
|
+
start?: boolean;
|
|
13
|
+
end?: boolean;
|
|
14
|
+
}): boolean;
|
|
15
|
+
export declare function dateFormat(date: DateType, format: string, local?: string): string | null;
|
|
16
|
+
export declare function dateStringToDate(dateString: string): Date | null;
|
|
17
|
+
export declare function previousMonthBy(date: DateType): Date;
|
|
18
|
+
export declare function nextMonthBy(date: DateType): Date;
|
|
19
|
+
export declare function dateUpdateMonth(date: DateType, value: number): Date;
|
|
20
|
+
export declare function dateUpdateYear(date: DateType, value: number): Date;
|
|
21
|
+
export declare function firstDayOfMonth(date?: Date): Date;
|
|
22
|
+
export declare function endDayOfMonth(date?: Date): Date;
|
|
23
|
+
export declare function dayIndexInWeek(date?: Date): 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
24
|
+
export declare function previousDaysInWeek(date: Date, weekStartDayIndex?: WeekDaysIndexType): Date[];
|
|
25
|
+
export declare function nextDaysInWeek(date: Date, weekStartDayIndex?: WeekDaysIndexType): Date[];
|
|
26
|
+
export declare function daysInMonth(date?: dayjs.ConfigType): number;
|
|
27
|
+
export declare function allDaysInMonth(date?: Date): Date[];
|
|
28
|
+
export declare function weekDayStringToIndex(dayString?: WeekStringType): WeekDaysIndexType;
|
|
29
|
+
export declare function dateAdd(date: Date, value: number, unit: dayjs.ManipulateType): Date;
|
|
30
|
+
export declare function getNextDates(date: Date, limit: number): Date[];
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { MouseEventHandler, ReactNode } from "react";
|
|
2
|
+
import { COLORS, DATE_LOOKING_OPTIONS, DAYS } from "../constants";
|
|
3
|
+
export type DateType = null | Date;
|
|
4
|
+
export interface Period {
|
|
5
|
+
start: DateType;
|
|
6
|
+
end: DateType;
|
|
7
|
+
}
|
|
8
|
+
interface CustomShortcuts {
|
|
9
|
+
[key: string]: ShortcutsItem;
|
|
10
|
+
}
|
|
11
|
+
interface DefaultShortcuts {
|
|
12
|
+
today?: string;
|
|
13
|
+
yesterday?: string;
|
|
14
|
+
past?: (period: number) => string;
|
|
15
|
+
currentMonth?: string;
|
|
16
|
+
pastMonth?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface Configs {
|
|
19
|
+
shortcuts?: DefaultShortcuts | CustomShortcuts;
|
|
20
|
+
footer?: {
|
|
21
|
+
cancel?: string;
|
|
22
|
+
apply?: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface ShortcutsItem {
|
|
26
|
+
text: string;
|
|
27
|
+
daysNumber?: number;
|
|
28
|
+
period: {
|
|
29
|
+
start: Date;
|
|
30
|
+
end: Date;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export type DateRangeType = {
|
|
34
|
+
startDate: DateType;
|
|
35
|
+
endDate: DateType;
|
|
36
|
+
};
|
|
37
|
+
export type DateValueType = DateRangeType | null;
|
|
38
|
+
export type ClassNameType = ((className: string) => string) | string | null;
|
|
39
|
+
export type ClassNamesTypeProp = {
|
|
40
|
+
container?: (p?: object | null | undefined) => string | undefined;
|
|
41
|
+
input?: (p?: object | null | undefined) => string | undefined;
|
|
42
|
+
toggleButton?: (p?: object | null | undefined) => string | undefined;
|
|
43
|
+
footer?: (p?: object | null | undefined) => string | undefined;
|
|
44
|
+
};
|
|
45
|
+
export type PopoverDirectionType = "up" | "down";
|
|
46
|
+
export type WeekStringType = "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun";
|
|
47
|
+
export type WeekDaysIndexType = (typeof DAYS)[number];
|
|
48
|
+
export type DateLookingType = (typeof DATE_LOOKING_OPTIONS)[number];
|
|
49
|
+
export interface DatepickerType {
|
|
50
|
+
primaryColor?: ColorKeys;
|
|
51
|
+
value: DateValueType;
|
|
52
|
+
onChange: (value: DateValueType, e?: HTMLInputElement | null | undefined) => void;
|
|
53
|
+
useRange?: boolean;
|
|
54
|
+
showFooter?: boolean;
|
|
55
|
+
showShortcuts?: boolean;
|
|
56
|
+
configs?: Configs;
|
|
57
|
+
asSingle?: boolean;
|
|
58
|
+
placeholder?: string;
|
|
59
|
+
separator?: string;
|
|
60
|
+
startFrom?: DateType;
|
|
61
|
+
i18n?: string;
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
classNames?: ClassNamesTypeProp;
|
|
64
|
+
containerClassName?: ClassNameType;
|
|
65
|
+
popupClassName?: ClassNameType;
|
|
66
|
+
inputClassName?: ClassNameType;
|
|
67
|
+
toggleClassName?: ClassNameType;
|
|
68
|
+
toggleIcon?: (open: boolean) => ReactNode;
|
|
69
|
+
inputId?: string;
|
|
70
|
+
inputName?: string;
|
|
71
|
+
displayFormat?: string;
|
|
72
|
+
readOnly?: boolean;
|
|
73
|
+
minDate?: DateType;
|
|
74
|
+
maxDate?: DateType;
|
|
75
|
+
dateLooking?: DateLookingType;
|
|
76
|
+
disabledDates?: DateRangeType[];
|
|
77
|
+
startWeekOn?: WeekStringType;
|
|
78
|
+
popoverDirection?: PopoverDirectionType;
|
|
79
|
+
required?: boolean;
|
|
80
|
+
}
|
|
81
|
+
export type ColorKeys = (typeof COLORS)[number];
|
|
82
|
+
export interface Colors {
|
|
83
|
+
[key: string]: {
|
|
84
|
+
[K in ColorKeys]: string;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export interface IconProps {
|
|
88
|
+
className: string;
|
|
89
|
+
}
|
|
90
|
+
export interface ButtonProps {
|
|
91
|
+
children: ReactNode;
|
|
92
|
+
onClick: MouseEventHandler<HTMLButtonElement>;
|
|
93
|
+
disabled?: boolean;
|
|
94
|
+
roundedFull?: boolean;
|
|
95
|
+
padding?: string;
|
|
96
|
+
active?: boolean;
|
|
97
|
+
}
|
|
98
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nearpay-datepicker-react",
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "A modern React Datepicker using Tailwind CSS 3",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"author": "nearpayio",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"watch": "rollup -c -w",
|
|
12
|
+
"clean": "rm -rf dist .rollup.cache tsconfig.tsbuildinfo",
|
|
13
|
+
"lint": "eslint .",
|
|
14
|
+
"lint:fix": "eslint --fix .",
|
|
15
|
+
"pret": "prettier -c .",
|
|
16
|
+
"pret:fix": "prettier --ignore-path .gitignore --config ./.prettierrc --write './**/*.{js,jsx,ts,tsx,css,md,json}'",
|
|
17
|
+
"code-style": "npm run pret && npm run lint",
|
|
18
|
+
"code-style:fix": "npm run pret:fix && npm run pret:fix",
|
|
19
|
+
"build": "npm run code-style && npm run clean && rollup -c rollup.config.js --bundleConfigAsCjs",
|
|
20
|
+
"pub": "npm run build && npm publish --access public",
|
|
21
|
+
"dev": "next dev -p 8888",
|
|
22
|
+
"prepare": "husky"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/nearpayio/nearpay-datepicker"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"nearpay-datepicker",
|
|
30
|
+
"react-datepicker",
|
|
31
|
+
"tailwind-datepicker",
|
|
32
|
+
"datepicker",
|
|
33
|
+
"date-picker",
|
|
34
|
+
"daterangepicker",
|
|
35
|
+
"react-daterangepicker",
|
|
36
|
+
"date-range",
|
|
37
|
+
"date-range-picker",
|
|
38
|
+
"tailwind-daterange-picker"
|
|
39
|
+
],
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"dayjs": "^1.11.12",
|
|
42
|
+
"react": "^17.0.2 || ^18.2.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@rollup/plugin-commonjs": "^26.0.1",
|
|
46
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
47
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
48
|
+
"@tailwindcss/forms": "^0.5.7",
|
|
49
|
+
"@tailwindcss/postcss": "^4.1.13",
|
|
50
|
+
"@types/node": "^22.3.0",
|
|
51
|
+
"@types/react": "^18.3.3",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^8.1.0",
|
|
53
|
+
"@typescript-eslint/parser": "^8.1.0",
|
|
54
|
+
"dayjs": "^1.11.12",
|
|
55
|
+
"eslint": "^8.57.0",
|
|
56
|
+
"eslint-config-next": "^14.2.5",
|
|
57
|
+
"eslint-config-prettier": "^9.1.0",
|
|
58
|
+
"eslint-plugin-import": "^2.29.1",
|
|
59
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
60
|
+
"eslint-plugin-react": "^7.35.0",
|
|
61
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
62
|
+
"eslint-plugin-react-refresh": "^0.4.9",
|
|
63
|
+
"husky": "^9.1.4",
|
|
64
|
+
"lint-staged": "^15.2.9",
|
|
65
|
+
"next": "^14.2.5",
|
|
66
|
+
"pinst": "^3.0.0",
|
|
67
|
+
"postcss": "^8.4.41",
|
|
68
|
+
"prettier": "^3.3.3",
|
|
69
|
+
"react": "^18.2.0",
|
|
70
|
+
"react-dom": "^18.2.0",
|
|
71
|
+
"rollup": "^4.20.0",
|
|
72
|
+
"tailwindcss": "^4.1.13",
|
|
73
|
+
"tslib": "^2.6.3",
|
|
74
|
+
"typescript": "^5.5.4"
|
|
75
|
+
},
|
|
76
|
+
"lint-staged": {
|
|
77
|
+
"*.{ts,tsx}": [
|
|
78
|
+
"eslint",
|
|
79
|
+
"prettier --write"
|
|
80
|
+
],
|
|
81
|
+
"*.{css,scss,json,md}": [
|
|
82
|
+
"prettier --write"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
"files": [
|
|
86
|
+
"dist"
|
|
87
|
+
]
|
|
88
|
+
}
|