universal-datetime-picker 2.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.
- package/LICENSE +21 -0
- package/README.md +452 -0
- package/dist/angular/index.d.mts +15 -0
- package/dist/angular/index.d.ts +15 -0
- package/dist/angular/index.js +2196 -0
- package/dist/angular/index.mjs +2183 -0
- package/dist/cdn/universal-datetime-picker.iife.js +1 -0
- package/dist/core/index.d.mts +58 -0
- package/dist/core/index.d.ts +58 -0
- package/dist/core/index.js +867 -0
- package/dist/core/index.mjs +832 -0
- package/dist/index.d.mts +183 -0
- package/dist/index.d.ts +185 -0
- package/dist/index.js +2054 -0
- package/dist/index.mjs +2030 -0
- package/dist/rangeController-Bq35aBwe.d.mts +271 -0
- package/dist/rangeController-Bq35aBwe.d.ts +271 -0
- package/dist/rangeRenderer-AVv6PJbW.d.mts +21 -0
- package/dist/rangeRenderer-a3hFk-kK.d.ts +21 -0
- package/dist/style.css +1 -0
- package/dist/svelte/index.d.mts +11 -0
- package/dist/svelte/index.d.ts +11 -0
- package/dist/svelte/index.js +2194 -0
- package/dist/svelte/index.mjs +2182 -0
- package/dist/vanilla/index.d.mts +21 -0
- package/dist/vanilla/index.d.ts +21 -0
- package/dist/vanilla/index.js +1831 -0
- package/dist/vanilla/index.mjs +1812 -0
- package/dist/vue/index.d.mts +9 -0
- package/dist/vue/index.d.ts +9 -0
- package/dist/vue/index.js +2193 -0
- package/dist/vue/index.mjs +2181 -0
- package/dist/wc/index.d.mts +43 -0
- package/dist/wc/index.d.ts +43 -0
- package/dist/wc/index.js +2204 -0
- package/dist/wc/index.mjs +2189 -0
- package/package.json +232 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
import { Dayjs } from 'dayjs';
|
|
4
|
+
export { default as dayjs } from 'dayjs';
|
|
5
|
+
|
|
6
|
+
type DateTimeMode = "datetime" | "date" | "time";
|
|
7
|
+
/**
|
|
8
|
+
* How date and time panels are arranged when `mode="datetime"`.
|
|
9
|
+
* - `combined` (default): both panels visible at once (no Date/Time tabs)
|
|
10
|
+
* - `tabs`: separate Date / Time tabs (legacy layout)
|
|
11
|
+
*/
|
|
12
|
+
type DateTimeLayout = "combined" | "tabs";
|
|
13
|
+
type DateTimeValue = Date | string | Dayjs | null;
|
|
14
|
+
/**
|
|
15
|
+
* Time-only selection when `asString={false}` and `mode="time"`.
|
|
16
|
+
* `hour` is 1–12; `hour24` is 0–23.
|
|
17
|
+
*/
|
|
18
|
+
interface TimeValue {
|
|
19
|
+
hour: number;
|
|
20
|
+
hour24: number;
|
|
21
|
+
minute: number;
|
|
22
|
+
second: number;
|
|
23
|
+
ampm: "AM" | "PM";
|
|
24
|
+
formatted: string;
|
|
25
|
+
}
|
|
26
|
+
/** Value passed to `onChange` for DateTime / DateTimeInput. */
|
|
27
|
+
type DateTimeChangeValue = Date | TimeValue | string | null;
|
|
28
|
+
/** Optional chrome strings for UI labels (not a full i18n suite). */
|
|
29
|
+
interface DateTimeLabels {
|
|
30
|
+
date?: string;
|
|
31
|
+
time?: string;
|
|
32
|
+
clear?: string;
|
|
33
|
+
close?: string;
|
|
34
|
+
ok?: string;
|
|
35
|
+
start?: string;
|
|
36
|
+
end?: string;
|
|
37
|
+
chooseDate?: string;
|
|
38
|
+
chooseDateRange?: string;
|
|
39
|
+
chooseMonth?: string;
|
|
40
|
+
chooseYear?: string;
|
|
41
|
+
previousMonth?: string;
|
|
42
|
+
nextMonth?: string;
|
|
43
|
+
previousYear?: string;
|
|
44
|
+
nextYear?: string;
|
|
45
|
+
selectEnd?: string;
|
|
46
|
+
}
|
|
47
|
+
declare const DEFAULT_LABELS: Required<DateTimeLabels>;
|
|
48
|
+
/** Shared picker options (framework-agnostic). */
|
|
49
|
+
interface DateTimeBaseOptions {
|
|
50
|
+
value?: DateTimeValue;
|
|
51
|
+
defaultValue?: DateTimeValue;
|
|
52
|
+
onChange?: (value: DateTimeChangeValue) => void;
|
|
53
|
+
asString?: boolean;
|
|
54
|
+
showSeconds?: boolean;
|
|
55
|
+
format?: string;
|
|
56
|
+
mode?: DateTimeMode;
|
|
57
|
+
layout?: DateTimeLayout;
|
|
58
|
+
minDate?: DateTimeValue;
|
|
59
|
+
maxDate?: DateTimeValue;
|
|
60
|
+
disablePastDates?: boolean;
|
|
61
|
+
disableFutureDates?: boolean;
|
|
62
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
63
|
+
use12Hours?: boolean;
|
|
64
|
+
inline?: boolean;
|
|
65
|
+
className?: string;
|
|
66
|
+
/** Inline style object or CSS string (vanilla / WC). */
|
|
67
|
+
style?: Partial<CSSStyleDeclaration> | string | Record<string, string | number>;
|
|
68
|
+
locale?: string;
|
|
69
|
+
labels?: DateTimeLabels;
|
|
70
|
+
theme?: "light" | "dark";
|
|
71
|
+
open?: boolean;
|
|
72
|
+
defaultOpen?: boolean;
|
|
73
|
+
onOpenChange?: (open: boolean) => void;
|
|
74
|
+
anchorEl?: HTMLElement | null;
|
|
75
|
+
popover?: boolean;
|
|
76
|
+
}
|
|
77
|
+
interface DateRangeValue {
|
|
78
|
+
start: Date | string | null;
|
|
79
|
+
end: Date | string | null;
|
|
80
|
+
}
|
|
81
|
+
interface DateTimeRangeOptions {
|
|
82
|
+
value?: {
|
|
83
|
+
start: DateTimeValue;
|
|
84
|
+
end: DateTimeValue;
|
|
85
|
+
} | null;
|
|
86
|
+
defaultValue?: {
|
|
87
|
+
start: DateTimeValue;
|
|
88
|
+
end: DateTimeValue;
|
|
89
|
+
} | null;
|
|
90
|
+
onChange?: (value: DateRangeValue) => void;
|
|
91
|
+
asString?: boolean;
|
|
92
|
+
format?: string;
|
|
93
|
+
minDate?: DateTimeValue;
|
|
94
|
+
maxDate?: DateTimeValue;
|
|
95
|
+
disablePastDates?: boolean;
|
|
96
|
+
disableFutureDates?: boolean;
|
|
97
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
98
|
+
locale?: string;
|
|
99
|
+
labels?: DateTimeLabels;
|
|
100
|
+
open?: boolean;
|
|
101
|
+
defaultOpen?: boolean;
|
|
102
|
+
onOpenChange?: (open: boolean) => void;
|
|
103
|
+
inline?: boolean;
|
|
104
|
+
className?: string;
|
|
105
|
+
style?: Partial<CSSStyleDeclaration> | string | Record<string, string | number>;
|
|
106
|
+
}
|
|
107
|
+
interface CalendarDay {
|
|
108
|
+
date: Dayjs;
|
|
109
|
+
isCurrentMonth: boolean;
|
|
110
|
+
isCurrentDate: boolean;
|
|
111
|
+
isFuture: boolean;
|
|
112
|
+
isPast: boolean;
|
|
113
|
+
isWeekend: boolean;
|
|
114
|
+
isDisabled: boolean;
|
|
115
|
+
isSelected: boolean;
|
|
116
|
+
isInRange?: boolean;
|
|
117
|
+
isRangeStart?: boolean;
|
|
118
|
+
isRangeEnd?: boolean;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
type DateTimeBaseProps = Omit<DateTimeBaseOptions, "style"> & {
|
|
122
|
+
style?: CSSProperties;
|
|
123
|
+
};
|
|
124
|
+
interface DateTimeProps extends DateTimeBaseProps {
|
|
125
|
+
open?: boolean;
|
|
126
|
+
defaultOpen?: boolean;
|
|
127
|
+
onOpenChange?: (open: boolean) => void;
|
|
128
|
+
anchorEl?: HTMLElement | null;
|
|
129
|
+
popover?: boolean;
|
|
130
|
+
}
|
|
131
|
+
interface DateTimeInputProps extends DateTimeBaseProps {
|
|
132
|
+
open?: boolean;
|
|
133
|
+
defaultOpen?: boolean;
|
|
134
|
+
onOpenChange?: (open: boolean) => void;
|
|
135
|
+
placeholder?: string;
|
|
136
|
+
id?: string;
|
|
137
|
+
name?: string;
|
|
138
|
+
disabled?: boolean;
|
|
139
|
+
readOnly?: boolean;
|
|
140
|
+
"aria-labelledby"?: string;
|
|
141
|
+
"aria-label"?: string;
|
|
142
|
+
inputClassName?: string;
|
|
143
|
+
}
|
|
144
|
+
type DateTimeRangeProps = Omit<DateTimeRangeOptions, "style"> & {
|
|
145
|
+
style?: CSSProperties;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
declare function DateTime(props: DateTimeProps): react.JSX.Element | null;
|
|
149
|
+
|
|
150
|
+
declare function DateTimeInput(props: DateTimeInputProps): react.JSX.Element;
|
|
151
|
+
|
|
152
|
+
declare function DateTimeRange(props: DateTimeRangeProps): react.JSX.Element | null;
|
|
153
|
+
|
|
154
|
+
declare const DEFAULT_FORMAT = "YYYY-MM-DD HH:mm:ss";
|
|
155
|
+
declare const DATE_FORMAT = "YYYY-MM-DD";
|
|
156
|
+
declare const TIME_FORMAT = "HH:mm:ss";
|
|
157
|
+
|
|
158
|
+
interface BuildCalendarOptions {
|
|
159
|
+
viewMonth: Dayjs;
|
|
160
|
+
selected?: Dayjs | null;
|
|
161
|
+
rangeStart?: Dayjs | null;
|
|
162
|
+
rangeEnd?: Dayjs | null;
|
|
163
|
+
/** Tentative end for hover preview while selecting a range. */
|
|
164
|
+
hoverEnd?: Dayjs | null;
|
|
165
|
+
minDate?: DateTimeValue;
|
|
166
|
+
maxDate?: DateTimeValue;
|
|
167
|
+
disablePastDates?: boolean;
|
|
168
|
+
disableFutureDates?: boolean;
|
|
169
|
+
weekStartsOn?: number;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Builds a month grid of weeks × days with correct current-month flags
|
|
173
|
+
* (including the last day of the month).
|
|
174
|
+
*/
|
|
175
|
+
declare function buildCalendarMonth(options: BuildCalendarOptions): CalendarDay[][];
|
|
176
|
+
|
|
177
|
+
type DateTimeComponent = typeof DateTime & {
|
|
178
|
+
Input: typeof DateTimeInput;
|
|
179
|
+
Range: typeof DateTimeRange;
|
|
180
|
+
};
|
|
181
|
+
declare const DateTimeWithExtras: DateTimeComponent;
|
|
182
|
+
|
|
183
|
+
export { type CalendarDay, DATE_FORMAT, DEFAULT_FORMAT, DEFAULT_LABELS, type DateRangeValue, DateTime, type DateTimeBaseProps, type DateTimeChangeValue, DateTimeInput, type DateTimeInputProps, type DateTimeLabels, type DateTimeLayout, type DateTimeMode, type DateTimeProps, DateTimeRange, type DateTimeRangeProps, type DateTimeValue, TIME_FORMAT, type TimeValue, buildCalendarMonth, DateTimeWithExtras as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
import { Dayjs } from 'dayjs';
|
|
4
|
+
export { default as dayjs } from 'dayjs';
|
|
5
|
+
|
|
6
|
+
type DateTimeMode = "datetime" | "date" | "time";
|
|
7
|
+
/**
|
|
8
|
+
* How date and time panels are arranged when `mode="datetime"`.
|
|
9
|
+
* - `combined` (default): both panels visible at once (no Date/Time tabs)
|
|
10
|
+
* - `tabs`: separate Date / Time tabs (legacy layout)
|
|
11
|
+
*/
|
|
12
|
+
type DateTimeLayout = "combined" | "tabs";
|
|
13
|
+
type DateTimeValue = Date | string | Dayjs | null;
|
|
14
|
+
/**
|
|
15
|
+
* Time-only selection when `asString={false}` and `mode="time"`.
|
|
16
|
+
* `hour` is 1–12; `hour24` is 0–23.
|
|
17
|
+
*/
|
|
18
|
+
interface TimeValue {
|
|
19
|
+
hour: number;
|
|
20
|
+
hour24: number;
|
|
21
|
+
minute: number;
|
|
22
|
+
second: number;
|
|
23
|
+
ampm: "AM" | "PM";
|
|
24
|
+
formatted: string;
|
|
25
|
+
}
|
|
26
|
+
/** Value passed to `onChange` for DateTime / DateTimeInput. */
|
|
27
|
+
type DateTimeChangeValue = Date | TimeValue | string | null;
|
|
28
|
+
/** Optional chrome strings for UI labels (not a full i18n suite). */
|
|
29
|
+
interface DateTimeLabels {
|
|
30
|
+
date?: string;
|
|
31
|
+
time?: string;
|
|
32
|
+
clear?: string;
|
|
33
|
+
close?: string;
|
|
34
|
+
ok?: string;
|
|
35
|
+
start?: string;
|
|
36
|
+
end?: string;
|
|
37
|
+
chooseDate?: string;
|
|
38
|
+
chooseDateRange?: string;
|
|
39
|
+
chooseMonth?: string;
|
|
40
|
+
chooseYear?: string;
|
|
41
|
+
previousMonth?: string;
|
|
42
|
+
nextMonth?: string;
|
|
43
|
+
previousYear?: string;
|
|
44
|
+
nextYear?: string;
|
|
45
|
+
selectEnd?: string;
|
|
46
|
+
}
|
|
47
|
+
declare const DEFAULT_LABELS: Required<DateTimeLabels>;
|
|
48
|
+
/** Shared picker options (framework-agnostic). */
|
|
49
|
+
interface DateTimeBaseOptions {
|
|
50
|
+
value?: DateTimeValue;
|
|
51
|
+
defaultValue?: DateTimeValue;
|
|
52
|
+
onChange?: (value: DateTimeChangeValue) => void;
|
|
53
|
+
asString?: boolean;
|
|
54
|
+
showSeconds?: boolean;
|
|
55
|
+
format?: string;
|
|
56
|
+
mode?: DateTimeMode;
|
|
57
|
+
layout?: DateTimeLayout;
|
|
58
|
+
minDate?: DateTimeValue;
|
|
59
|
+
maxDate?: DateTimeValue;
|
|
60
|
+
disablePastDates?: boolean;
|
|
61
|
+
disableFutureDates?: boolean;
|
|
62
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
63
|
+
use12Hours?: boolean;
|
|
64
|
+
inline?: boolean;
|
|
65
|
+
className?: string;
|
|
66
|
+
/** Inline style object or CSS string (vanilla / WC). */
|
|
67
|
+
style?: Partial<CSSStyleDeclaration> | string | Record<string, string | number>;
|
|
68
|
+
locale?: string;
|
|
69
|
+
labels?: DateTimeLabels;
|
|
70
|
+
theme?: "light" | "dark";
|
|
71
|
+
open?: boolean;
|
|
72
|
+
defaultOpen?: boolean;
|
|
73
|
+
onOpenChange?: (open: boolean) => void;
|
|
74
|
+
anchorEl?: HTMLElement | null;
|
|
75
|
+
popover?: boolean;
|
|
76
|
+
}
|
|
77
|
+
interface DateRangeValue {
|
|
78
|
+
start: Date | string | null;
|
|
79
|
+
end: Date | string | null;
|
|
80
|
+
}
|
|
81
|
+
interface DateTimeRangeOptions {
|
|
82
|
+
value?: {
|
|
83
|
+
start: DateTimeValue;
|
|
84
|
+
end: DateTimeValue;
|
|
85
|
+
} | null;
|
|
86
|
+
defaultValue?: {
|
|
87
|
+
start: DateTimeValue;
|
|
88
|
+
end: DateTimeValue;
|
|
89
|
+
} | null;
|
|
90
|
+
onChange?: (value: DateRangeValue) => void;
|
|
91
|
+
asString?: boolean;
|
|
92
|
+
format?: string;
|
|
93
|
+
minDate?: DateTimeValue;
|
|
94
|
+
maxDate?: DateTimeValue;
|
|
95
|
+
disablePastDates?: boolean;
|
|
96
|
+
disableFutureDates?: boolean;
|
|
97
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
98
|
+
locale?: string;
|
|
99
|
+
labels?: DateTimeLabels;
|
|
100
|
+
open?: boolean;
|
|
101
|
+
defaultOpen?: boolean;
|
|
102
|
+
onOpenChange?: (open: boolean) => void;
|
|
103
|
+
inline?: boolean;
|
|
104
|
+
className?: string;
|
|
105
|
+
style?: Partial<CSSStyleDeclaration> | string | Record<string, string | number>;
|
|
106
|
+
}
|
|
107
|
+
interface CalendarDay {
|
|
108
|
+
date: Dayjs;
|
|
109
|
+
isCurrentMonth: boolean;
|
|
110
|
+
isCurrentDate: boolean;
|
|
111
|
+
isFuture: boolean;
|
|
112
|
+
isPast: boolean;
|
|
113
|
+
isWeekend: boolean;
|
|
114
|
+
isDisabled: boolean;
|
|
115
|
+
isSelected: boolean;
|
|
116
|
+
isInRange?: boolean;
|
|
117
|
+
isRangeStart?: boolean;
|
|
118
|
+
isRangeEnd?: boolean;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
type DateTimeBaseProps = Omit<DateTimeBaseOptions, "style"> & {
|
|
122
|
+
style?: CSSProperties;
|
|
123
|
+
};
|
|
124
|
+
interface DateTimeProps extends DateTimeBaseProps {
|
|
125
|
+
open?: boolean;
|
|
126
|
+
defaultOpen?: boolean;
|
|
127
|
+
onOpenChange?: (open: boolean) => void;
|
|
128
|
+
anchorEl?: HTMLElement | null;
|
|
129
|
+
popover?: boolean;
|
|
130
|
+
}
|
|
131
|
+
interface DateTimeInputProps extends DateTimeBaseProps {
|
|
132
|
+
open?: boolean;
|
|
133
|
+
defaultOpen?: boolean;
|
|
134
|
+
onOpenChange?: (open: boolean) => void;
|
|
135
|
+
placeholder?: string;
|
|
136
|
+
id?: string;
|
|
137
|
+
name?: string;
|
|
138
|
+
disabled?: boolean;
|
|
139
|
+
readOnly?: boolean;
|
|
140
|
+
"aria-labelledby"?: string;
|
|
141
|
+
"aria-label"?: string;
|
|
142
|
+
inputClassName?: string;
|
|
143
|
+
}
|
|
144
|
+
type DateTimeRangeProps = Omit<DateTimeRangeOptions, "style"> & {
|
|
145
|
+
style?: CSSProperties;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
declare function DateTime(props: DateTimeProps): react.JSX.Element | null;
|
|
149
|
+
|
|
150
|
+
declare function DateTimeInput(props: DateTimeInputProps): react.JSX.Element;
|
|
151
|
+
|
|
152
|
+
declare function DateTimeRange(props: DateTimeRangeProps): react.JSX.Element | null;
|
|
153
|
+
|
|
154
|
+
declare const DEFAULT_FORMAT = "YYYY-MM-DD HH:mm:ss";
|
|
155
|
+
declare const DATE_FORMAT = "YYYY-MM-DD";
|
|
156
|
+
declare const TIME_FORMAT = "HH:mm:ss";
|
|
157
|
+
|
|
158
|
+
interface BuildCalendarOptions {
|
|
159
|
+
viewMonth: Dayjs;
|
|
160
|
+
selected?: Dayjs | null;
|
|
161
|
+
rangeStart?: Dayjs | null;
|
|
162
|
+
rangeEnd?: Dayjs | null;
|
|
163
|
+
/** Tentative end for hover preview while selecting a range. */
|
|
164
|
+
hoverEnd?: Dayjs | null;
|
|
165
|
+
minDate?: DateTimeValue;
|
|
166
|
+
maxDate?: DateTimeValue;
|
|
167
|
+
disablePastDates?: boolean;
|
|
168
|
+
disableFutureDates?: boolean;
|
|
169
|
+
weekStartsOn?: number;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Builds a month grid of weeks × days with correct current-month flags
|
|
173
|
+
* (including the last day of the month).
|
|
174
|
+
*/
|
|
175
|
+
declare function buildCalendarMonth(options: BuildCalendarOptions): CalendarDay[][];
|
|
176
|
+
|
|
177
|
+
type DateTimeComponent = typeof DateTime & {
|
|
178
|
+
Input: typeof DateTimeInput;
|
|
179
|
+
Range: typeof DateTimeRange;
|
|
180
|
+
};
|
|
181
|
+
declare const DateTimeWithExtras: DateTimeComponent;
|
|
182
|
+
|
|
183
|
+
// @ts-ignore
|
|
184
|
+
export = DateTimeWithExtras;
|
|
185
|
+
export { type CalendarDay, DATE_FORMAT, DEFAULT_FORMAT, DEFAULT_LABELS, type DateRangeValue, DateTime, type DateTimeBaseProps, type DateTimeChangeValue, DateTimeInput, type DateTimeInputProps, type DateTimeLabels, type DateTimeLayout, type DateTimeMode, type DateTimeProps, DateTimeRange, type DateTimeRangeProps, type DateTimeValue, TIME_FORMAT, type TimeValue, buildCalendarMonth };
|