mehdi-akbari-calendar 0.1.0 → 0.1.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/dist/components/Calendar/Calendar.d.ts +10 -0
- package/dist/components/internal/CalendarHeader.d.ts +11 -0
- package/dist/components/internal/DayCell.d.ts +15 -0
- package/dist/components/internal/MonthPickerView.d.ts +10 -0
- package/dist/components/internal/MonthView.d.ts +16 -0
- package/dist/components/internal/YearView.d.ts +9 -0
- package/dist/hooks/useCalendar.d.ts +36 -0
- package/dist/index.d.ts +3 -9
- package/dist/react.d.ts +6 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/utils/dateAdapter.d.ts +35 -0
- package/package.json +9 -7
- package/dist/index.d.mts +0 -11
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DateRange } from '../../types';
|
|
3
|
+
import type { UseCalendarOptions } from '../../hooks/useCalendar';
|
|
4
|
+
export type { DateRange };
|
|
5
|
+
export interface PersianCalendarProps extends Omit<UseCalendarOptions, 'range'> {
|
|
6
|
+
onDateSelect?: (date: Date | null) => void;
|
|
7
|
+
range?: DateRange;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const PersianCalendar: React.FC<PersianCalendarProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface CalendarHeaderProps {
|
|
3
|
+
title: string;
|
|
4
|
+
calendarType: 'jalali' | 'gregorian';
|
|
5
|
+
onToggleCalendarType: () => void;
|
|
6
|
+
onNext: () => void;
|
|
7
|
+
onPrev: () => void;
|
|
8
|
+
onTitleClick: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const CalendarHeader: React.FC<CalendarHeaderProps>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DateFunctions } from '../../utils/dateAdapter';
|
|
3
|
+
export interface DayCellProps {
|
|
4
|
+
date: Date;
|
|
5
|
+
isCurrentMonth: boolean;
|
|
6
|
+
isSelected: boolean;
|
|
7
|
+
isToday: boolean;
|
|
8
|
+
isInRange?: boolean;
|
|
9
|
+
isRangeStart?: boolean;
|
|
10
|
+
isRangeEnd?: boolean;
|
|
11
|
+
isDisabled?: boolean;
|
|
12
|
+
onClick: (date: Date) => void;
|
|
13
|
+
dateFns: DateFunctions;
|
|
14
|
+
}
|
|
15
|
+
export declare const DayCell: React.FC<DayCellProps>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DateFunctions } from '../../utils/dateAdapter';
|
|
3
|
+
interface MonthPickerViewProps {
|
|
4
|
+
months: Date[];
|
|
5
|
+
onSelectMonth: (monthIndex: number) => void;
|
|
6
|
+
isCurrentMonth: (monthIndex: number) => boolean;
|
|
7
|
+
dateFns: DateFunctions;
|
|
8
|
+
}
|
|
9
|
+
export declare const MonthPickerView: React.FC<MonthPickerViewProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DateFunctions } from '../../utils/dateAdapter';
|
|
3
|
+
interface MonthViewProps {
|
|
4
|
+
daysOfMonth: Date[];
|
|
5
|
+
weekDays: string[];
|
|
6
|
+
dateFns: DateFunctions;
|
|
7
|
+
onSelectDate: (date: Date) => void;
|
|
8
|
+
isDateSelected: (date: Date) => boolean;
|
|
9
|
+
isInRange: (date: Date) => boolean;
|
|
10
|
+
isRangeStart: (date: Date) => boolean;
|
|
11
|
+
isRangeEnd: (date: Date) => boolean;
|
|
12
|
+
isSameMonthAsCurrent: (date: Date) => boolean;
|
|
13
|
+
isToday: (date: Date) => boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const MonthView: React.FC<MonthViewProps>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface YearViewProps {
|
|
3
|
+
years: number[];
|
|
4
|
+
onSelectYear: (year: number) => void;
|
|
5
|
+
isCurrentYear: (year: number) => boolean;
|
|
6
|
+
isYearDisabled: (year: number) => boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const YearView: React.FC<YearViewProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { CalendarViewMode, DateRange, CalendarType } from '../types';
|
|
2
|
+
export interface UseCalendarOptions {
|
|
3
|
+
initialDate?: Date;
|
|
4
|
+
minYear?: number;
|
|
5
|
+
maxYear?: number;
|
|
6
|
+
initialCalendarType?: CalendarType;
|
|
7
|
+
range?: DateRange;
|
|
8
|
+
}
|
|
9
|
+
export declare const useCalendar: ({ initialDate, minYear, maxYear, initialCalendarType, range }?: UseCalendarOptions) => {
|
|
10
|
+
viewMode: CalendarViewMode;
|
|
11
|
+
currentDate: Date;
|
|
12
|
+
selectedDate: Date | null;
|
|
13
|
+
daysOfMonth: Date[];
|
|
14
|
+
monthsOfYear: Date[];
|
|
15
|
+
yearsOfDecade: number[];
|
|
16
|
+
headerTitle: string;
|
|
17
|
+
calendarType: CalendarType;
|
|
18
|
+
weekDays: string[];
|
|
19
|
+
dateFns: import("../utils/dateAdapter").DateFunctions;
|
|
20
|
+
toggleCalendarType: () => void;
|
|
21
|
+
goToNext: () => void;
|
|
22
|
+
goToPrev: () => void;
|
|
23
|
+
handleSelectDay: (date: Date) => void;
|
|
24
|
+
handleSelectMonth: (monthIndex: number) => void;
|
|
25
|
+
handleSelectYear: (year: number) => void;
|
|
26
|
+
handleHeaderClick: () => void;
|
|
27
|
+
isSameMonthAsCurrent: (date: Date) => boolean;
|
|
28
|
+
isDateSelected: (date: Date) => boolean;
|
|
29
|
+
isInRange: (date: Date) => boolean;
|
|
30
|
+
isRangeStart: (date: Date) => boolean;
|
|
31
|
+
isRangeEnd: (date: Date) => boolean;
|
|
32
|
+
isToday: (date: Date) => boolean;
|
|
33
|
+
isCurrentMonth: (monthIndex: number) => boolean;
|
|
34
|
+
isCurrentYear: (year: number) => boolean;
|
|
35
|
+
isYearDisabled: (year: number) => boolean;
|
|
36
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* This is the main entry point for non-React functionalities and types.
|
|
3
|
+
* It allows users to import types or utility functions without pulling in React.
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
from: Date | null;
|
|
6
|
-
to: Date | null;
|
|
7
|
-
}
|
|
8
|
-
type CalendarType = 'jalali' | 'gregorian';
|
|
9
|
-
type CalendarViewMode = 'day' | 'month' | 'year';
|
|
10
|
-
|
|
11
|
-
export type { CalendarType, CalendarViewMode, DateRange };
|
|
5
|
+
export * from "./types";
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CalendarType } from '../types';
|
|
2
|
+
export interface DateFunctions {
|
|
3
|
+
startOfMonth: (date: Date) => Date;
|
|
4
|
+
endOfMonth: (date: Date) => Date;
|
|
5
|
+
startOfWeek: (date: Date) => Date;
|
|
6
|
+
endOfWeek: (date: Date) => Date;
|
|
7
|
+
eachDayOfInterval: (interval: {
|
|
8
|
+
start: Date;
|
|
9
|
+
end: Date;
|
|
10
|
+
}) => Date[];
|
|
11
|
+
isSameMonth: (dateLeft: Date, dateRight: Date) => boolean;
|
|
12
|
+
isSameDay: (dateLeft: Date, dateRight: Date) => boolean;
|
|
13
|
+
format: (date: Date, formatStr: string) => string;
|
|
14
|
+
addMonths: (date: Date, amount: number) => Date;
|
|
15
|
+
subMonths: (date: Date, amount: number) => Date;
|
|
16
|
+
getYear: (date: Date) => number;
|
|
17
|
+
setYear: (date: Date, year: number) => Date;
|
|
18
|
+
getMonth: (date: Date) => number;
|
|
19
|
+
setMonth: (date: Date, month: number) => Date;
|
|
20
|
+
startOfYear: (date: Date) => Date;
|
|
21
|
+
eachMonthOfInterval: (interval: {
|
|
22
|
+
start: Date;
|
|
23
|
+
end: Date;
|
|
24
|
+
}) => Date[];
|
|
25
|
+
endOfYear: (date: Date) => Date;
|
|
26
|
+
addYears: (date: Date, amount: number) => Date;
|
|
27
|
+
subYears: (date: Date, amount: number) => Date;
|
|
28
|
+
isDate: (value: any) => boolean;
|
|
29
|
+
isWithinInterval: (date: Date, interval: {
|
|
30
|
+
start: Date;
|
|
31
|
+
end: Date;
|
|
32
|
+
}) => boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare const getDateFunctions: (type: CalendarType) => DateFunctions;
|
|
35
|
+
export declare const getWeekDays: (type: CalendarType) => string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mehdi-akbari-calendar",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A professional and customizable Persian (Jalali) calendar component for React.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -24,12 +24,14 @@
|
|
|
24
24
|
},
|
|
25
25
|
"./styles.css": "./dist/styles.css"
|
|
26
26
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
"scripts": {
|
|
28
|
+
"clean": "npx rimraf dist",
|
|
29
|
+
"build:js": "tsup",
|
|
30
|
+
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
31
|
+
"build": "npm run clean && npm run build:js && npm run build:types && copyfiles -u 1 src/styles.css dist",
|
|
32
|
+
"dev": "tsup --watch",
|
|
33
|
+
"prepublishOnly": "npm run build"
|
|
34
|
+
},
|
|
33
35
|
"peerDependencies": {
|
|
34
36
|
"react": ">=18",
|
|
35
37
|
"react-dom": ">=18"
|
package/dist/index.d.mts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents a date range with a start and end date.
|
|
3
|
-
*/
|
|
4
|
-
interface DateRange {
|
|
5
|
-
from: Date | null;
|
|
6
|
-
to: Date | null;
|
|
7
|
-
}
|
|
8
|
-
type CalendarType = 'jalali' | 'gregorian';
|
|
9
|
-
type CalendarViewMode = 'day' | 'month' | 'year';
|
|
10
|
-
|
|
11
|
-
export type { CalendarType, CalendarViewMode, DateRange };
|