bs-ad-calendar-react 1.2.0 → 1.2.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/AboutTab.d.ts +3 -0
- package/dist/components/BasicTab.d.ts +13 -0
- package/dist/components/Calendar/CalendarGrid.d.ts +4 -0
- package/dist/components/Calendar/CalendarHeader.d.ts +9 -0
- package/dist/components/Calendar/MonthYearPicker.d.ts +14 -0
- package/dist/components/Calendar/RangePresets.d.ts +11 -0
- package/dist/components/Calendar/index.d.ts +4 -0
- package/dist/components/CalendarInput/CalendarInput.d.ts +15 -0
- package/dist/components/CalendarInput/index.d.ts +1 -0
- package/dist/components/CalendarInputTab.d.ts +13 -0
- package/dist/components/CustomizationTab.d.ts +11 -0
- package/dist/components/ExampleCard.d.ts +13 -0
- package/dist/components/LocalizationTab.d.ts +13 -0
- package/dist/components/RangeTab.d.ts +13 -0
- package/dist/components/Tabs.d.ts +11 -0
- package/dist/constants/index.d.ts +28 -0
- package/dist/hooks/useCalendar.d.ts +19 -0
- package/dist/index.d.ts +8 -0
- package/dist/types/index.d.ts +83 -0
- package/dist/utils/bsDateHelpers.d.ts +21 -0
- package/dist/utils/dateUtils.d.ts +18 -0
- package/dist/utils/rangePresets.d.ts +16 -0
- package/package.json +5 -5
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DateOutput } from '../types';
|
|
3
|
+
interface BasicTabProps {
|
|
4
|
+
outputAD: string;
|
|
5
|
+
outputBS: string;
|
|
6
|
+
onADSelect: (date: DateOutput) => void;
|
|
7
|
+
onBSSelect: (date: DateOutput) => void;
|
|
8
|
+
copied: string | null;
|
|
9
|
+
onCopyCode: (code: string, id: string) => void;
|
|
10
|
+
renderOutput: (output: string) => React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
declare const BasicTab: React.FC<BasicTabProps>;
|
|
13
|
+
export default BasicTab;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CalendarHeaderProps } from '../../types/index.js';
|
|
3
|
+
interface ExtendedCalendarHeaderProps extends CalendarHeaderProps {
|
|
4
|
+
onYearChange: (year: number) => void;
|
|
5
|
+
onMonthChange: (month: number) => void;
|
|
6
|
+
calendarType: 'BS' | 'AD';
|
|
7
|
+
}
|
|
8
|
+
declare const CalendarHeader: React.FC<ExtendedCalendarHeaderProps>;
|
|
9
|
+
export default CalendarHeader;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface MonthYearPickerProps {
|
|
3
|
+
currentYear: number;
|
|
4
|
+
currentMonth: number;
|
|
5
|
+
months: string[];
|
|
6
|
+
onYearChange: (year: number) => void;
|
|
7
|
+
onMonthChange: (month: number) => void;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
showNepaliNumbers?: boolean;
|
|
10
|
+
convertToNepaliNumber?: (num: number) => string;
|
|
11
|
+
calendarType: 'BS' | 'AD';
|
|
12
|
+
}
|
|
13
|
+
declare const MonthYearPicker: React.FC<MonthYearPickerProps>;
|
|
14
|
+
export default MonthYearPicker;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { PredefinedRange, DateRange } from '../../types/index.js';
|
|
3
|
+
interface RangePresetsProps {
|
|
4
|
+
presets: PredefinedRange[];
|
|
5
|
+
calendarType: 'BS' | 'AD';
|
|
6
|
+
onPresetSelect: (preset: PredefinedRange, range: DateRange) => void;
|
|
7
|
+
activePreset?: string;
|
|
8
|
+
position?: 'top' | 'right' | 'bottom' | 'left';
|
|
9
|
+
}
|
|
10
|
+
declare const RangePresets: React.FC<RangePresetsProps>;
|
|
11
|
+
export default RangePresets;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DateOutput, CalendarProps } from '../../types';
|
|
3
|
+
interface CalendarInputProps extends Omit<CalendarProps, 'onDateSelect'> {
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
format?: string;
|
|
6
|
+
onDateSelect?: (date: DateOutput) => void;
|
|
7
|
+
inputClassName?: string;
|
|
8
|
+
popupClassName?: string;
|
|
9
|
+
style?: React.CSSProperties;
|
|
10
|
+
inputStyle?: React.CSSProperties;
|
|
11
|
+
icon?: React.ReactNode;
|
|
12
|
+
showIcon?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare const CalendarInput: React.FC<CalendarInputProps>;
|
|
15
|
+
export default CalendarInput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './CalendarInput';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DateOutput } from '../types';
|
|
3
|
+
interface CalendarInputTabProps {
|
|
4
|
+
outputAD: string;
|
|
5
|
+
outputBS: string;
|
|
6
|
+
onADSelect: (date: DateOutput) => void;
|
|
7
|
+
onBSSelect: (date: DateOutput) => void;
|
|
8
|
+
copied: string | null;
|
|
9
|
+
onCopyCode: (code: string, id: string) => void;
|
|
10
|
+
renderOutput: (output: string) => React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
declare const CalendarInputTab: React.FC<CalendarInputTabProps>;
|
|
13
|
+
export default CalendarInputTab;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DateOutput } from '../types';
|
|
3
|
+
interface CustomizationTabProps {
|
|
4
|
+
outputAD: string;
|
|
5
|
+
onADSelect: (date: DateOutput) => void;
|
|
6
|
+
copied: string | null;
|
|
7
|
+
onCopyCode: (code: string, id: string) => void;
|
|
8
|
+
renderOutput: (output: string) => React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
declare const CustomizationTab: React.FC<CustomizationTabProps>;
|
|
11
|
+
export default CustomizationTab;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ExampleCardProps {
|
|
3
|
+
title: string;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
output?: React.ReactNode;
|
|
6
|
+
code?: string;
|
|
7
|
+
codeId?: string;
|
|
8
|
+
copied?: string | null;
|
|
9
|
+
onCopyCode?: (code: string, id: string) => void;
|
|
10
|
+
isDark?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const ExampleCard: React.FC<ExampleCardProps>;
|
|
13
|
+
export default ExampleCard;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DateOutput } from '../types';
|
|
3
|
+
interface LocalizationTabProps {
|
|
4
|
+
outputAD: string;
|
|
5
|
+
outputBS: string;
|
|
6
|
+
onADSelect: (date: DateOutput) => void;
|
|
7
|
+
onBSSelect: (date: DateOutput) => void;
|
|
8
|
+
copied: string | null;
|
|
9
|
+
onCopyCode: (code: string, id: string) => void;
|
|
10
|
+
renderOutput: (output: string) => React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
declare const LocalizationTab: React.FC<LocalizationTabProps>;
|
|
13
|
+
export default LocalizationTab;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DateRange } from '../types';
|
|
3
|
+
interface RangeTabProps {
|
|
4
|
+
outputAD: string;
|
|
5
|
+
outputBS: string;
|
|
6
|
+
onADSelect: (range: DateRange) => void;
|
|
7
|
+
onBSSelect: (range: DateRange) => void;
|
|
8
|
+
copied: string | null;
|
|
9
|
+
onCopyCode: (code: string, id: string) => void;
|
|
10
|
+
renderRangeOutput: (output: string) => React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
declare const RangeTab: React.FC<RangeTabProps>;
|
|
13
|
+
export default RangeTab;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const NEPALI_MONTHS: string[];
|
|
2
|
+
export declare const ENGLISH_MONTHS_BS: string[];
|
|
3
|
+
export declare const ENGLISH_MONTHS_AD: string[];
|
|
4
|
+
export declare const NEPALI_DAYS: string[];
|
|
5
|
+
export declare const ENGLISH_DAYS: string[];
|
|
6
|
+
export declare const NEPALI_DIGITS: string[];
|
|
7
|
+
export declare const DEFAULT_COLORS: {
|
|
8
|
+
light: {
|
|
9
|
+
primary: string;
|
|
10
|
+
background: string;
|
|
11
|
+
text: string;
|
|
12
|
+
border: string;
|
|
13
|
+
hover: string;
|
|
14
|
+
selected: string;
|
|
15
|
+
today: string;
|
|
16
|
+
disabled: string;
|
|
17
|
+
};
|
|
18
|
+
dark: {
|
|
19
|
+
primary: string;
|
|
20
|
+
background: string;
|
|
21
|
+
text: string;
|
|
22
|
+
border: string;
|
|
23
|
+
hover: string;
|
|
24
|
+
selected: string;
|
|
25
|
+
today: string;
|
|
26
|
+
disabled: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DateInfo, CalendarProps } from '../types/index.js';
|
|
2
|
+
export declare const useCalendar: (calendarType?: CalendarProps["calendarType"]) => {
|
|
3
|
+
currentYear: number;
|
|
4
|
+
currentMonth: number;
|
|
5
|
+
selectedDate: DateInfo | null;
|
|
6
|
+
rangeStart: DateInfo | null;
|
|
7
|
+
rangeEnd: DateInfo | null;
|
|
8
|
+
today: DateInfo;
|
|
9
|
+
calendarDays: (number | null)[];
|
|
10
|
+
setCurrentYear: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
11
|
+
setCurrentMonth: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
12
|
+
setSelectedDate: import("react").Dispatch<import("react").SetStateAction<DateInfo | null>>;
|
|
13
|
+
setRangeStart: import("react").Dispatch<import("react").SetStateAction<DateInfo | null>>;
|
|
14
|
+
setRangeEnd: import("react").Dispatch<import("react").SetStateAction<DateInfo | null>>;
|
|
15
|
+
navigateMonth: (direction: number) => void;
|
|
16
|
+
isToday: (day: number) => boolean;
|
|
17
|
+
isSelected: (day: number, mode?: CalendarProps["mode"]) => boolean;
|
|
18
|
+
isInRange: (day: number) => boolean;
|
|
19
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as Calendar } from './components/Calendar';
|
|
2
|
+
export { default as CalendarInput } from './components/CalendarInput';
|
|
3
|
+
export { default as DatePicker } from './components/CalendarInput';
|
|
4
|
+
export type { DateInfo, DateRange, DateOutput, PredefinedRange, CalendarProps, CalendarHeaderProps, CalendarGridProps } from './types';
|
|
5
|
+
export { convertToNepaliNumber, getDaysInMonth, getFirstDayOfMonth, getTodayDate, createDateOutput, isDateInRange } from './utils/dateUtils';
|
|
6
|
+
export { createPredefinedRanges, PRESET_KEYS } from './utils/rangePresets';
|
|
7
|
+
export { NEPALI_MONTHS, ENGLISH_MONTHS_BS, ENGLISH_MONTHS_AD, NEPALI_DAYS, ENGLISH_DAYS, NEPALI_DIGITS, DEFAULT_COLORS } from './constants';
|
|
8
|
+
export { useCalendar } from './hooks/useCalendar';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export type DateInfo = {
|
|
2
|
+
year: number;
|
|
3
|
+
month: number;
|
|
4
|
+
day: number;
|
|
5
|
+
};
|
|
6
|
+
export type DateRange = {
|
|
7
|
+
start: DateInfo | null;
|
|
8
|
+
end: DateInfo | null;
|
|
9
|
+
};
|
|
10
|
+
export type DateOutput = {
|
|
11
|
+
bs: string;
|
|
12
|
+
ad: string;
|
|
13
|
+
formatted: {
|
|
14
|
+
bs: string;
|
|
15
|
+
ad: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type PredefinedRange = {
|
|
19
|
+
label: string;
|
|
20
|
+
getValue: (calendarType: 'BS' | 'AD') => DateRange;
|
|
21
|
+
key: string;
|
|
22
|
+
};
|
|
23
|
+
export type CalendarProps = {
|
|
24
|
+
calendarType?: 'BS' | 'AD';
|
|
25
|
+
value?: string;
|
|
26
|
+
onChange?: (date: string) => void;
|
|
27
|
+
mode?: 'single' | 'range';
|
|
28
|
+
outputFormat?: 'iso' | 'object' | 'both';
|
|
29
|
+
onDateSelect?: (data: DateOutput) => void;
|
|
30
|
+
onRangeSelect?: (range: {
|
|
31
|
+
start: DateInfo;
|
|
32
|
+
end: DateInfo;
|
|
33
|
+
}) => void;
|
|
34
|
+
showRangePresets?: boolean;
|
|
35
|
+
rangePresetsPosition?: 'top' | 'right' | 'bottom' | 'left';
|
|
36
|
+
predefinedRanges?: PredefinedRange[];
|
|
37
|
+
presetKeys?: string[];
|
|
38
|
+
presetLabels?: Record<string, string>;
|
|
39
|
+
onPresetSelect?: (preset: PredefinedRange, range: DateRange) => void;
|
|
40
|
+
renderPresets?: (props: {
|
|
41
|
+
onRangeChange: (start: DateInfo, end: DateInfo) => void;
|
|
42
|
+
}) => React.ReactNode;
|
|
43
|
+
showNepaliMonths?: boolean;
|
|
44
|
+
showNepaliDays?: boolean;
|
|
45
|
+
showNepaliNumbers?: boolean;
|
|
46
|
+
className?: string;
|
|
47
|
+
showToday?: boolean;
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
minDate?: string;
|
|
50
|
+
maxDate?: string;
|
|
51
|
+
theme?: 'light' | 'dark' | 'custom';
|
|
52
|
+
colors?: {
|
|
53
|
+
primary?: string;
|
|
54
|
+
background?: string;
|
|
55
|
+
text?: string;
|
|
56
|
+
border?: string;
|
|
57
|
+
hover?: string;
|
|
58
|
+
selected?: string;
|
|
59
|
+
today?: string;
|
|
60
|
+
disabled?: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export type CalendarHeaderProps = {
|
|
64
|
+
currentMonth: number;
|
|
65
|
+
currentYear: number;
|
|
66
|
+
months: string[];
|
|
67
|
+
onNavigateMonth: (direction: number) => void;
|
|
68
|
+
disabled?: boolean;
|
|
69
|
+
showNepaliNumbers?: boolean;
|
|
70
|
+
convertToNepaliNumber: (num: number) => string;
|
|
71
|
+
};
|
|
72
|
+
export type CalendarGridProps = {
|
|
73
|
+
calendarDays: (number | null)[];
|
|
74
|
+
days: string[];
|
|
75
|
+
onDateSelect: (day: number) => void;
|
|
76
|
+
isSelected: (day: number) => boolean;
|
|
77
|
+
isInRange: (day: number) => boolean;
|
|
78
|
+
isToday: (day: number) => boolean;
|
|
79
|
+
isDisabled?: (day: number) => boolean;
|
|
80
|
+
disabled?: boolean;
|
|
81
|
+
showNepaliNumbers?: boolean;
|
|
82
|
+
convertToNepaliNumber: (num: number) => string;
|
|
83
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DateInfo } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Add or subtract days from a BS or AD date
|
|
4
|
+
*/
|
|
5
|
+
export declare const addDays: (date: DateInfo, days: number, calendarType: "BS" | "AD") => DateInfo;
|
|
6
|
+
/**
|
|
7
|
+
* Add or subtract months from a BS or AD date
|
|
8
|
+
*/
|
|
9
|
+
export declare const addMonths: (date: DateInfo, months: number, calendarType: "BS" | "AD") => DateInfo;
|
|
10
|
+
/**
|
|
11
|
+
* Get the first day of the month for a given date
|
|
12
|
+
*/
|
|
13
|
+
export declare const getFirstDayOfMonth: (date: DateInfo) => DateInfo;
|
|
14
|
+
/**
|
|
15
|
+
* Get the last day of the month for a given date
|
|
16
|
+
*/
|
|
17
|
+
export declare const getLastDayOfMonth: (date: DateInfo, calendarType: "BS" | "AD") => DateInfo;
|
|
18
|
+
/**
|
|
19
|
+
* Get the first day of the week (Sunday) for a given date
|
|
20
|
+
*/
|
|
21
|
+
export declare const getStartOfWeek: (date: DateInfo, calendarType: "BS" | "AD") => DateInfo;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DateInfo } from '../types/index.js';
|
|
2
|
+
interface DateOutput {
|
|
3
|
+
bs: string;
|
|
4
|
+
ad: string;
|
|
5
|
+
formatted: {
|
|
6
|
+
bs: string;
|
|
7
|
+
ad: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare const convertToNepaliNumber: (num: number) => string;
|
|
11
|
+
export declare const getDaysInMonth: (calendarType: "BS" | "AD", year: number, month: number) => number;
|
|
12
|
+
export declare const getFirstDayOfMonth: (calendarType: "BS" | "AD", year: number, month: number) => number;
|
|
13
|
+
export declare const getTodayDate: (calendarType: "BS" | "AD") => DateInfo;
|
|
14
|
+
export declare const createDateOutput: (calendarType: "BS" | "AD", year: number, month: number, day: number, months: string[]) => DateOutput;
|
|
15
|
+
export declare const isDateInRange: (date: DateInfo, start: DateInfo, end: DateInfo) => boolean;
|
|
16
|
+
export declare const parseDate: (dateStr: string) => DateInfo | null;
|
|
17
|
+
export declare const isDateDisabled: (date: DateInfo, minDate?: string, maxDate?: string) => boolean;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PredefinedRange } from '../types/index.js';
|
|
2
|
+
export declare const PRESET_KEYS: {
|
|
3
|
+
readonly TODAY: "today";
|
|
4
|
+
readonly YESTERDAY: "yesterday";
|
|
5
|
+
readonly THIS_WEEK: "thisWeek";
|
|
6
|
+
readonly LAST_7_DAYS: "last7days";
|
|
7
|
+
readonly LAST_30_DAYS: "last30days";
|
|
8
|
+
readonly THIS_MONTH: "thisMonth";
|
|
9
|
+
readonly LAST_MONTH: "lastMonth";
|
|
10
|
+
readonly LAST_3_MONTHS: "last3months";
|
|
11
|
+
readonly LAST_6_MONTHS: "last6months";
|
|
12
|
+
readonly LAST_180_DAYS: "last180days";
|
|
13
|
+
readonly LAST_9_MONTHS: "last9months";
|
|
14
|
+
readonly LAST_YEAR: "lastYear";
|
|
15
|
+
};
|
|
16
|
+
export declare const createPredefinedRanges: (keys?: string[], labels?: Record<string, string>) => PredefinedRange[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bs-ad-calendar-react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A modern React calendar component supporting both Bikram Sambat (BS) and Gregorian (AD) calendars",
|
|
6
6
|
"type": "module",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
20
|
"dev": "vite",
|
|
21
|
-
"build": "tsc -p tsconfig.lib.json && vite build",
|
|
22
|
-
"build:lib": "tsc -p tsconfig.lib.json && vite build",
|
|
21
|
+
"build": "rm -rf dist && tsc -p tsconfig.lib.json && vite build",
|
|
22
|
+
"build:lib": "rm -rf dist && tsc -p tsconfig.lib.json && vite build",
|
|
23
23
|
"build:demo": "vite build --mode demo",
|
|
24
24
|
"lint": "eslint .",
|
|
25
25
|
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,css,md}\"",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"@eslint/js": "^9.39.1",
|
|
56
56
|
"@tailwindcss/postcss": "^4.1.18",
|
|
57
57
|
"@types/node": "^24.10.1",
|
|
58
|
-
"@types/react": "^
|
|
59
|
-
"@types/react-dom": "^
|
|
58
|
+
"@types/react": "^19.0.0",
|
|
59
|
+
"@types/react-dom": "^19.0.0",
|
|
60
60
|
"@vitejs/plugin-react": "^5.1.1",
|
|
61
61
|
"autoprefixer": "^10.4.23",
|
|
62
62
|
"eslint": "^9.39.1",
|