flexible-multi-calendar-datepicker 1.0.0

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.
@@ -0,0 +1,124 @@
1
+ import * as React from 'react';
2
+ import React__default from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ type CalendarSystem = "jalali" | "islamic" | "gregorian";
6
+ type CalendarLocale = "fa" | "en";
7
+ type IslamicDateAdjustment = -2 | -1 | 0 | 1 | 2;
8
+
9
+ type AnchorRef = React.RefObject<HTMLElement> | React.MutableRefObject<HTMLElement | null>;
10
+ type JalaliDisabledDateRange = {
11
+ /** First disabled day (inclusive). */
12
+ from: Date;
13
+ /** Last disabled day (inclusive). */
14
+ to: Date;
15
+ };
16
+ type JalaliDatepickerProps = {
17
+ open: boolean;
18
+ anchorRef: AnchorRef;
19
+ value?: Date | null;
20
+ defaultValue?: Date | null;
21
+ onChange?: (d: Date | null) => void;
22
+ onConfirm: (d: Date | null) => void;
23
+ onClose: () => void;
24
+ /** Optional per-instance label. Pass an empty string or null to hide it. */
25
+ label?: React.ReactNode;
26
+ locale?: "fa" | "en";
27
+ /** Calendar system. Existing integrations default to Jalali. */
28
+ calendar?: CalendarSystem;
29
+ /**
30
+ * Moves calculated Islamic dates by -2..+2 days to match a local or
31
+ * officially announced lunar calendar. Only used with calendar="islamic".
32
+ */
33
+ islamicDateAdjustment?: IslamicDateAdjustment;
34
+ className?: string;
35
+ style?: React.CSSProperties;
36
+ /** محل اختیاری Portal؛ پیش‌فرض document.body است. */
37
+ portalContainer?: HTMLElement | null;
38
+ /**
39
+ * نمایش دکمه‌های تأیید و انصراف.
40
+ * false: انتخاب روز فوراً مقدار را ارسال می‌کند و تقویم بسته می‌شود.
41
+ * true: مقدار فقط با تأیید ارسال می‌شود و انصراف state مقصد را تغییر نمی‌دهد.
42
+ * @default false
43
+ */
44
+ showActionButtons?: boolean;
45
+ /** Date ranges that cannot be selected. Both boundaries are included. */
46
+ disabledDateRanges?: readonly JalaliDisabledDateRange[];
47
+ labels?: {
48
+ titleFrom?: string;
49
+ titleTo?: string;
50
+ confirm?: string;
51
+ cancel?: string;
52
+ chooseDate?: string;
53
+ today?: string;
54
+ };
55
+ };
56
+ declare function JalaliDatepicker(props: JalaliDatepickerProps): React.ReactPortal | null;
57
+ declare const _default: React.MemoExoticComponent<typeof JalaliDatepicker>;
58
+
59
+ type Option = {
60
+ id: string | number;
61
+ label: React__default.ReactNode;
62
+ value?: string;
63
+ disabled?: boolean;
64
+ };
65
+ type SingleChange = {
66
+ id: string | number | null;
67
+ value: string | null;
68
+ label?: string | null;
69
+ };
70
+ type MultiChange = {
71
+ ids: Array<string | number>;
72
+ values: string[];
73
+ labels: string[];
74
+ };
75
+ type BaseProps = {
76
+ name?: string;
77
+ options: ReadonlyArray<Option>;
78
+ dir?: "rtl" | "ltr";
79
+ disabled?: boolean;
80
+ placeholderLabel?: string;
81
+ hasPlaceholder?: boolean;
82
+ showCheckIcon?: boolean;
83
+ colorVar?: string;
84
+ required?: boolean;
85
+ containerStyle?: React__default.CSSProperties;
86
+ className?: string;
87
+ listClassName?: string;
88
+ style?: React__default.CSSProperties;
89
+ placement?: "down" | "up" | "auto";
90
+ panelOffset?: number;
91
+ };
92
+ type SingleProps = {
93
+ multi?: false;
94
+ defaultSelectedId?: string | number | null;
95
+ selectedId?: string | number | null;
96
+ onChange?: (sel: SingleChange) => void;
97
+ };
98
+ type MultiProps = {
99
+ multi: true;
100
+ defaultSelectedIds?: Array<string | number> | null;
101
+ selectedIds?: Array<string | number> | null;
102
+ onChange?: (sel: MultiChange) => void;
103
+ };
104
+ type ComboSelectProps = BaseProps & (SingleProps | MultiProps);
105
+ declare function ComboSelectImpl(props: ComboSelectProps): react_jsx_runtime.JSX.Element;
106
+ declare const ComboSelect: React__default.MemoExoticComponent<typeof ComboSelectImpl>;
107
+
108
+ declare const ArrowDownCombo: React.FC<React.SVGProps<SVGSVGElement>>;
109
+ declare const TickCircle: React.FC<React.SVGProps<SVGSVGElement>>;
110
+
111
+ type CalendarDisplayFormat = "YYYY-MM-DD" | "YYYY/MM/DD" | "DD/MM/YYYY" | "DD MMM YYYY" | "MMMM DD, YYYY" | "dddd, DD MMMM YYYY" | "dddd DD MMMM YYYY";
112
+ type JalaliDisplayFormat = CalendarDisplayFormat;
113
+ type JalaliFormatLocale = CalendarLocale;
114
+ type CalendarFormatOptions = {
115
+ calendar?: CalendarSystem;
116
+ locale?: CalendarLocale;
117
+ islamicDateAdjustment?: IslamicDateAdjustment;
118
+ };
119
+ declare function formatCalendarDate(date: Date | null | undefined, format?: CalendarDisplayFormat, options?: CalendarFormatOptions): string;
120
+ declare function parseCalendarDate(input: string, format: CalendarDisplayFormat, options?: CalendarFormatOptions): Date | null;
121
+ declare function formatJalaliDate(date: Date | null | undefined, format?: JalaliDisplayFormat, locale?: JalaliFormatLocale): string;
122
+ declare function parseJalaliDate(input: string, format: JalaliDisplayFormat, locale?: JalaliFormatLocale): Date | null;
123
+
124
+ export { ArrowDownCombo, type CalendarDisplayFormat, type CalendarFormatOptions, type CalendarLocale, type CalendarSystem, ComboSelect, type MultiChange as ComboSelectMultiChange, type Option as ComboSelectOption, type ComboSelectProps, type SingleChange as ComboSelectSingleChange, type IslamicDateAdjustment, _default as JalaliDatepicker, type JalaliDatepickerProps, type JalaliDisabledDateRange, type JalaliDisplayFormat, type JalaliFormatLocale, _default as PersianDatepicker, TickCircle, formatCalendarDate, formatJalaliDate, parseCalendarDate, parseJalaliDate };
@@ -0,0 +1,124 @@
1
+ import * as React from 'react';
2
+ import React__default from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ type CalendarSystem = "jalali" | "islamic" | "gregorian";
6
+ type CalendarLocale = "fa" | "en";
7
+ type IslamicDateAdjustment = -2 | -1 | 0 | 1 | 2;
8
+
9
+ type AnchorRef = React.RefObject<HTMLElement> | React.MutableRefObject<HTMLElement | null>;
10
+ type JalaliDisabledDateRange = {
11
+ /** First disabled day (inclusive). */
12
+ from: Date;
13
+ /** Last disabled day (inclusive). */
14
+ to: Date;
15
+ };
16
+ type JalaliDatepickerProps = {
17
+ open: boolean;
18
+ anchorRef: AnchorRef;
19
+ value?: Date | null;
20
+ defaultValue?: Date | null;
21
+ onChange?: (d: Date | null) => void;
22
+ onConfirm: (d: Date | null) => void;
23
+ onClose: () => void;
24
+ /** Optional per-instance label. Pass an empty string or null to hide it. */
25
+ label?: React.ReactNode;
26
+ locale?: "fa" | "en";
27
+ /** Calendar system. Existing integrations default to Jalali. */
28
+ calendar?: CalendarSystem;
29
+ /**
30
+ * Moves calculated Islamic dates by -2..+2 days to match a local or
31
+ * officially announced lunar calendar. Only used with calendar="islamic".
32
+ */
33
+ islamicDateAdjustment?: IslamicDateAdjustment;
34
+ className?: string;
35
+ style?: React.CSSProperties;
36
+ /** محل اختیاری Portal؛ پیش‌فرض document.body است. */
37
+ portalContainer?: HTMLElement | null;
38
+ /**
39
+ * نمایش دکمه‌های تأیید و انصراف.
40
+ * false: انتخاب روز فوراً مقدار را ارسال می‌کند و تقویم بسته می‌شود.
41
+ * true: مقدار فقط با تأیید ارسال می‌شود و انصراف state مقصد را تغییر نمی‌دهد.
42
+ * @default false
43
+ */
44
+ showActionButtons?: boolean;
45
+ /** Date ranges that cannot be selected. Both boundaries are included. */
46
+ disabledDateRanges?: readonly JalaliDisabledDateRange[];
47
+ labels?: {
48
+ titleFrom?: string;
49
+ titleTo?: string;
50
+ confirm?: string;
51
+ cancel?: string;
52
+ chooseDate?: string;
53
+ today?: string;
54
+ };
55
+ };
56
+ declare function JalaliDatepicker(props: JalaliDatepickerProps): React.ReactPortal | null;
57
+ declare const _default: React.MemoExoticComponent<typeof JalaliDatepicker>;
58
+
59
+ type Option = {
60
+ id: string | number;
61
+ label: React__default.ReactNode;
62
+ value?: string;
63
+ disabled?: boolean;
64
+ };
65
+ type SingleChange = {
66
+ id: string | number | null;
67
+ value: string | null;
68
+ label?: string | null;
69
+ };
70
+ type MultiChange = {
71
+ ids: Array<string | number>;
72
+ values: string[];
73
+ labels: string[];
74
+ };
75
+ type BaseProps = {
76
+ name?: string;
77
+ options: ReadonlyArray<Option>;
78
+ dir?: "rtl" | "ltr";
79
+ disabled?: boolean;
80
+ placeholderLabel?: string;
81
+ hasPlaceholder?: boolean;
82
+ showCheckIcon?: boolean;
83
+ colorVar?: string;
84
+ required?: boolean;
85
+ containerStyle?: React__default.CSSProperties;
86
+ className?: string;
87
+ listClassName?: string;
88
+ style?: React__default.CSSProperties;
89
+ placement?: "down" | "up" | "auto";
90
+ panelOffset?: number;
91
+ };
92
+ type SingleProps = {
93
+ multi?: false;
94
+ defaultSelectedId?: string | number | null;
95
+ selectedId?: string | number | null;
96
+ onChange?: (sel: SingleChange) => void;
97
+ };
98
+ type MultiProps = {
99
+ multi: true;
100
+ defaultSelectedIds?: Array<string | number> | null;
101
+ selectedIds?: Array<string | number> | null;
102
+ onChange?: (sel: MultiChange) => void;
103
+ };
104
+ type ComboSelectProps = BaseProps & (SingleProps | MultiProps);
105
+ declare function ComboSelectImpl(props: ComboSelectProps): react_jsx_runtime.JSX.Element;
106
+ declare const ComboSelect: React__default.MemoExoticComponent<typeof ComboSelectImpl>;
107
+
108
+ declare const ArrowDownCombo: React.FC<React.SVGProps<SVGSVGElement>>;
109
+ declare const TickCircle: React.FC<React.SVGProps<SVGSVGElement>>;
110
+
111
+ type CalendarDisplayFormat = "YYYY-MM-DD" | "YYYY/MM/DD" | "DD/MM/YYYY" | "DD MMM YYYY" | "MMMM DD, YYYY" | "dddd, DD MMMM YYYY" | "dddd DD MMMM YYYY";
112
+ type JalaliDisplayFormat = CalendarDisplayFormat;
113
+ type JalaliFormatLocale = CalendarLocale;
114
+ type CalendarFormatOptions = {
115
+ calendar?: CalendarSystem;
116
+ locale?: CalendarLocale;
117
+ islamicDateAdjustment?: IslamicDateAdjustment;
118
+ };
119
+ declare function formatCalendarDate(date: Date | null | undefined, format?: CalendarDisplayFormat, options?: CalendarFormatOptions): string;
120
+ declare function parseCalendarDate(input: string, format: CalendarDisplayFormat, options?: CalendarFormatOptions): Date | null;
121
+ declare function formatJalaliDate(date: Date | null | undefined, format?: JalaliDisplayFormat, locale?: JalaliFormatLocale): string;
122
+ declare function parseJalaliDate(input: string, format: JalaliDisplayFormat, locale?: JalaliFormatLocale): Date | null;
123
+
124
+ export { ArrowDownCombo, type CalendarDisplayFormat, type CalendarFormatOptions, type CalendarLocale, type CalendarSystem, ComboSelect, type MultiChange as ComboSelectMultiChange, type Option as ComboSelectOption, type ComboSelectProps, type SingleChange as ComboSelectSingleChange, type IslamicDateAdjustment, _default as JalaliDatepicker, type JalaliDatepickerProps, type JalaliDisabledDateRange, type JalaliDisplayFormat, type JalaliFormatLocale, _default as PersianDatepicker, TickCircle, formatCalendarDate, formatJalaliDate, parseCalendarDate, parseJalaliDate };