@carbon-labs/wc-date-picker 0.2.0 → 0.4.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/es/__stories__/{date-picker.stories.d.ts → date-picker-web-components.stories.d.ts} +5 -5
- package/{lib/state-machine → es}/adapters/web-component-adapter.d.ts +3 -3
- package/es/{state-machine/adapters → adapters}/web-component-adapter.js +1 -4
- package/es/adapters/web-component-adapter.js.map +1 -0
- package/es/components/{date-picker/calendar-renderer.js → calendar-renderer.js} +9 -9
- package/es/components/calendar-renderer.js.map +1 -0
- package/es/components/{date-picker/date-picker-input-skeleton.js → date-picker-input-skeleton.js} +2 -2
- package/es/components/date-picker-input-skeleton.js.map +1 -0
- package/es/components/{date-picker/date-picker-input.js → date-picker-input.js} +5 -5
- package/es/components/date-picker-input.js.map +1 -0
- package/es/components/{date-picker/date-picker.d.ts → date-picker.d.ts} +6 -3
- package/es/components/{date-picker/date-picker.js → date-picker.js} +69 -137
- package/es/components/date-picker.js.map +1 -0
- package/es/components/{date-picker/date-picker.scss.js → date-picker.scss.js} +1 -1
- package/{lib/components/date-picker → es/components}/defs.d.ts +1 -1
- package/es/components/{date-picker/defs.js → defs.js} +1 -1
- package/es/components/defs.js.map +1 -0
- package/es/index.d.ts +5 -4
- package/es/index.js +5 -4
- package/es/index.js.map +1 -1
- package/lib/__stories__/{date-picker.stories.d.ts → date-picker-web-components.stories.d.ts} +5 -5
- package/{es/state-machine → lib}/adapters/web-component-adapter.d.ts +3 -3
- package/lib/{state-machine/adapters → adapters}/web-component-adapter.js +24 -27
- package/lib/adapters/web-component-adapter.js.map +1 -0
- package/lib/components/{date-picker/calendar-renderer.js → calendar-renderer.js} +11 -11
- package/lib/components/calendar-renderer.js.map +1 -0
- package/lib/components/{date-picker/date-picker-input-skeleton.js → date-picker-input-skeleton.js} +2 -2
- package/lib/components/date-picker-input-skeleton.js.map +1 -0
- package/lib/components/{date-picker/date-picker-input.js → date-picker-input.js} +5 -5
- package/lib/components/date-picker-input.js.map +1 -0
- package/lib/components/{date-picker/date-picker.d.ts → date-picker.d.ts} +6 -3
- package/lib/components/{date-picker/date-picker.js → date-picker.js} +105 -173
- package/lib/components/date-picker.js.map +1 -0
- package/lib/components/{date-picker/date-picker.scss.js → date-picker.scss.js} +1 -1
- package/{es/components/date-picker → lib/components}/defs.d.ts +1 -1
- package/lib/components/{date-picker/defs.js → defs.js} +1 -1
- package/lib/components/defs.js.map +1 -0
- package/lib/index.d.ts +5 -4
- package/lib/index.js +13 -4
- package/lib/index.js.map +1 -1
- package/package.json +4 -3
- package/es/components/date-picker/calendar-renderer.js.map +0 -1
- package/es/components/date-picker/date-picker-input-skeleton.js.map +0 -1
- package/es/components/date-picker/date-picker-input.js.map +0 -1
- package/es/components/date-picker/date-picker.js.map +0 -1
- package/es/components/date-picker/defs.js.map +0 -1
- package/es/state-machine/actions.d.ts +0 -35
- package/es/state-machine/actions.js +0 -860
- package/es/state-machine/actions.js.map +0 -1
- package/es/state-machine/adapters/web-component-adapter.js.map +0 -1
- package/es/state-machine/effects.d.ts +0 -35
- package/es/state-machine/effects.js +0 -92
- package/es/state-machine/effects.js.map +0 -1
- package/es/state-machine/guards.d.ts +0 -41
- package/es/state-machine/guards.js +0 -143
- package/es/state-machine/guards.js.map +0 -1
- package/es/state-machine/index.d.ts +0 -12
- package/es/state-machine/machine.d.ts +0 -92
- package/es/state-machine/machine.js +0 -272
- package/es/state-machine/machine.js.map +0 -1
- package/es/state-machine/states.d.ts +0 -89
- package/es/state-machine/states.js +0 -105
- package/es/state-machine/states.js.map +0 -1
- package/es/state-machine/temporal-utils.d.ts +0 -203
- package/es/state-machine/temporal-utils.js +0 -128
- package/es/state-machine/temporal-utils.js.map +0 -1
- package/es/state-machine/types.d.ts +0 -163
- package/lib/components/date-picker/calendar-renderer.js.map +0 -1
- package/lib/components/date-picker/date-picker-input-skeleton.js.map +0 -1
- package/lib/components/date-picker/date-picker-input.js.map +0 -1
- package/lib/components/date-picker/date-picker.js.map +0 -1
- package/lib/components/date-picker/defs.js.map +0 -1
- package/lib/state-machine/actions.d.ts +0 -35
- package/lib/state-machine/actions.js +0 -864
- package/lib/state-machine/actions.js.map +0 -1
- package/lib/state-machine/adapters/web-component-adapter.js.map +0 -1
- package/lib/state-machine/effects.d.ts +0 -35
- package/lib/state-machine/effects.js +0 -96
- package/lib/state-machine/effects.js.map +0 -1
- package/lib/state-machine/guards.d.ts +0 -41
- package/lib/state-machine/guards.js +0 -147
- package/lib/state-machine/guards.js.map +0 -1
- package/lib/state-machine/index.d.ts +0 -12
- package/lib/state-machine/machine.d.ts +0 -92
- package/lib/state-machine/machine.js +0 -274
- package/lib/state-machine/machine.js.map +0 -1
- package/lib/state-machine/states.d.ts +0 -89
- package/lib/state-machine/states.js +0 -105
- package/lib/state-machine/states.js.map +0 -1
- package/lib/state-machine/temporal-utils.d.ts +0 -203
- package/lib/state-machine/temporal-utils.js +0 -136
- package/lib/state-machine/temporal-utils.js.map +0 -1
- package/lib/state-machine/types.d.ts +0 -163
- /package/es/components/{date-picker/calendar-renderer.d.ts → calendar-renderer.d.ts} +0 -0
- /package/es/components/{date-picker/date-picker-input-skeleton.d.ts → date-picker-input-skeleton.d.ts} +0 -0
- /package/es/components/{date-picker/date-picker-input.d.ts → date-picker-input.d.ts} +0 -0
- /package/es/components/{date-picker/date-picker.scss.js.map → date-picker.scss.js.map} +0 -0
- /package/lib/components/{date-picker/calendar-renderer.d.ts → calendar-renderer.d.ts} +0 -0
- /package/lib/components/{date-picker/date-picker-input-skeleton.d.ts → date-picker-input-skeleton.d.ts} +0 -0
- /package/lib/components/{date-picker/date-picker-input.d.ts → date-picker-input.d.ts} +0 -0
- /package/lib/components/{date-picker/date-picker.scss.js.map → date-picker.scss.js.map} +0 -0
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2026
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Temporal API utilities for date picker
|
|
9
|
-
* Uses the modern Temporal API for robust date handling
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Convert a Date object to Temporal.PlainDate
|
|
13
|
-
*
|
|
14
|
-
* @param {Date} date - JavaScript Date object
|
|
15
|
-
* @returns Temporal.PlainDate
|
|
16
|
-
*/
|
|
17
|
-
export declare function dateToPlainDate(date: Date): Temporal.PlainDate;
|
|
18
|
-
/**
|
|
19
|
-
* Convert Temporal.PlainDate to Date object
|
|
20
|
-
*
|
|
21
|
-
* @param {Temporal.PlainDate} plainDate - Temporal.PlainDate
|
|
22
|
-
* @returns JavaScript Date object
|
|
23
|
-
*/
|
|
24
|
-
export declare function plainDateToDate(plainDate: Temporal.PlainDate): Date;
|
|
25
|
-
/**
|
|
26
|
-
* Convert Temporal.PlainDate to ISO date string (YYYY-MM-DD)
|
|
27
|
-
*
|
|
28
|
-
* @param {Temporal.PlainDate} plainDate - Temporal.PlainDate
|
|
29
|
-
* @returns ISO date string
|
|
30
|
-
*/
|
|
31
|
-
export declare function plainDateToISOString(plainDate: Temporal.PlainDate): string;
|
|
32
|
-
/**
|
|
33
|
-
* Parse ISO date string to Temporal.PlainDate
|
|
34
|
-
*
|
|
35
|
-
* @param {string} isoString - ISO date string (YYYY-MM-DD)
|
|
36
|
-
* @returns Temporal.PlainDate or null if invalid
|
|
37
|
-
*/
|
|
38
|
-
export declare function parseISOToPlainDate(isoString: string): Temporal.PlainDate | null;
|
|
39
|
-
/**
|
|
40
|
-
* Parse a date string in various formats to Temporal.PlainDate
|
|
41
|
-
* Supports: ISO (YYYY-MM-DD), US (MM/DD/YYYY), and JavaScript Date objects
|
|
42
|
-
*
|
|
43
|
-
* @param {string | Date} dateInput - Date string or Date object
|
|
44
|
-
* @returns Temporal.PlainDate or null if invalid
|
|
45
|
-
*/
|
|
46
|
-
export declare function parseDateToPlainDate(dateInput: string | Date | null | undefined): Temporal.PlainDate | null;
|
|
47
|
-
/**
|
|
48
|
-
* Compare two Temporal.PlainDate objects
|
|
49
|
-
*
|
|
50
|
-
* @param {Temporal.PlainDate} date1 - First date
|
|
51
|
-
* @param {Temporal.PlainDate} date2 - Second date
|
|
52
|
-
* @returns -1 if date1 < date2, 0 if equal, 1 if date1 > date2
|
|
53
|
-
*/
|
|
54
|
-
export declare function comparePlainDates(date1: Temporal.PlainDate, date2: Temporal.PlainDate): number;
|
|
55
|
-
/**
|
|
56
|
-
* Check if a date is within a range
|
|
57
|
-
*
|
|
58
|
-
* @param {Temporal.PlainDate} date - Date to check
|
|
59
|
-
* @param {Temporal.PlainDate | null} minDate - Minimum date (inclusive)
|
|
60
|
-
* @param {Temporal.PlainDate | null} maxDate - Maximum date (inclusive)
|
|
61
|
-
* @returns True if date is within range
|
|
62
|
-
*/
|
|
63
|
-
export declare function isDateInRange(date: Temporal.PlainDate, minDate: Temporal.PlainDate | null, maxDate: Temporal.PlainDate | null): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Format a Temporal.PlainDate according to a format string
|
|
66
|
-
* Supports common format tokens: Y, m, d
|
|
67
|
-
*
|
|
68
|
-
* @param {Temporal.PlainDate} date - Date to format
|
|
69
|
-
* @param {string} format - Format string (e.g., 'm/d/Y', 'Y-m-d')
|
|
70
|
-
* @returns Formatted date string
|
|
71
|
-
*/
|
|
72
|
-
export declare function formatPlainDate(date: Temporal.PlainDate, format: string): string;
|
|
73
|
-
/**
|
|
74
|
-
* Get today's date as Temporal.PlainDate
|
|
75
|
-
*
|
|
76
|
-
* @returns Today's date
|
|
77
|
-
*/
|
|
78
|
-
export declare function getToday(): Temporal.PlainDate;
|
|
79
|
-
/**
|
|
80
|
-
* Add days to a date
|
|
81
|
-
*
|
|
82
|
-
* @param {Temporal.PlainDate} date - Starting date
|
|
83
|
-
* @param {number} days - Number of days to add (can be negative)
|
|
84
|
-
* @returns New date
|
|
85
|
-
*/
|
|
86
|
-
export declare function addDays(date: Temporal.PlainDate, days: number): Temporal.PlainDate;
|
|
87
|
-
/**
|
|
88
|
-
* Add months to a date
|
|
89
|
-
*
|
|
90
|
-
* @param {Temporal.PlainDate} date - Starting date
|
|
91
|
-
* @param {number} months - Number of months to add (can be negative)
|
|
92
|
-
* @returns New date
|
|
93
|
-
*/
|
|
94
|
-
export declare function addMonths(date: Temporal.PlainDate, months: number): Temporal.PlainDate;
|
|
95
|
-
/**
|
|
96
|
-
* Get the number of days between two dates
|
|
97
|
-
*
|
|
98
|
-
* @param {Temporal.PlainDate} date1 - First date
|
|
99
|
-
* @param {Temporal.PlainDate} date2 - Second date
|
|
100
|
-
* @returns Number of days (positive if date2 is after date1)
|
|
101
|
-
*/
|
|
102
|
-
export declare function daysBetween(date1: Temporal.PlainDate, date2: Temporal.PlainDate): number;
|
|
103
|
-
/**
|
|
104
|
-
* Check if two dates are equal
|
|
105
|
-
*
|
|
106
|
-
* @param {Temporal.PlainDate} date1 - First date
|
|
107
|
-
* @param {Temporal.PlainDate} date2 - Second date
|
|
108
|
-
* @returns True if dates are equal
|
|
109
|
-
*/
|
|
110
|
-
export declare function areDatesEqual(date1: Temporal.PlainDate | null, date2: Temporal.PlainDate | null): boolean;
|
|
111
|
-
/**
|
|
112
|
-
* Get the start of the month for a given date
|
|
113
|
-
*
|
|
114
|
-
* @param {Temporal.PlainDate} date - Input date
|
|
115
|
-
* @returns First day of the month
|
|
116
|
-
*/
|
|
117
|
-
export declare function getMonthStart(date: Temporal.PlainDate): Temporal.PlainDate;
|
|
118
|
-
/**
|
|
119
|
-
* Get the end of the month for a given date
|
|
120
|
-
*
|
|
121
|
-
* @param {Temporal.PlainDate} date - Input date
|
|
122
|
-
* @returns Last day of the month
|
|
123
|
-
*/
|
|
124
|
-
export declare function getMonthEnd(date: Temporal.PlainDate): Temporal.PlainDate;
|
|
125
|
-
/**
|
|
126
|
-
* Check if a date is today
|
|
127
|
-
*
|
|
128
|
-
* @param {Temporal.PlainDate} date - Date to check
|
|
129
|
-
* @returns True if date is today
|
|
130
|
-
*/
|
|
131
|
-
export declare function isToday(date: Temporal.PlainDate): boolean;
|
|
132
|
-
/**
|
|
133
|
-
* Check if a date is in the past
|
|
134
|
-
*
|
|
135
|
-
* @param {Temporal.PlainDate} date - Date to check
|
|
136
|
-
* @returns True if date is before today
|
|
137
|
-
*/
|
|
138
|
-
export declare function isPast(date: Temporal.PlainDate): boolean;
|
|
139
|
-
/**
|
|
140
|
-
* Check if a date is in the future
|
|
141
|
-
*
|
|
142
|
-
* @param {Temporal.PlainDate} date - Date to check
|
|
143
|
-
* @returns True if date is after today
|
|
144
|
-
*/
|
|
145
|
-
export declare function isFuture(date: Temporal.PlainDate): boolean;
|
|
146
|
-
/**
|
|
147
|
-
* Parse a date string with a specific format
|
|
148
|
-
* Supports common format tokens: Y, m, d
|
|
149
|
-
*
|
|
150
|
-
* @param {string} dateString - Date string to parse
|
|
151
|
-
* @param {string} format - Format string (e.g., 'm/d/Y', 'Y-m-d')
|
|
152
|
-
* @returns Temporal.PlainDate or null if invalid
|
|
153
|
-
*/
|
|
154
|
-
export declare function parseDateString(dateString: string, format: string): Temporal.PlainDate | null;
|
|
155
|
-
/**
|
|
156
|
-
* Polyfill check for Temporal API
|
|
157
|
-
*
|
|
158
|
-
* @returns True if Temporal API is available
|
|
159
|
-
*/
|
|
160
|
-
export declare function isTemporalAvailable(): boolean;
|
|
161
|
-
/**
|
|
162
|
-
* Get a fallback date handler if Temporal is not available
|
|
163
|
-
* This provides a migration path for browsers without Temporal support
|
|
164
|
-
*/
|
|
165
|
-
export declare function getDateHandler(): {
|
|
166
|
-
type: "temporal";
|
|
167
|
-
toISOString: typeof plainDateToISOString;
|
|
168
|
-
fromISOString: typeof parseISOToPlainDate;
|
|
169
|
-
compare: typeof comparePlainDates;
|
|
170
|
-
format: typeof formatPlainDate;
|
|
171
|
-
isInRange: typeof isDateInRange;
|
|
172
|
-
} | {
|
|
173
|
-
type: "date";
|
|
174
|
-
/**
|
|
175
|
-
*
|
|
176
|
-
* @param {Temporal.PlainDate} date - The date to convert
|
|
177
|
-
*/
|
|
178
|
-
toISOString: (date: Date) => string;
|
|
179
|
-
/**
|
|
180
|
-
*
|
|
181
|
-
* @param {string} str - The ISO string to parse
|
|
182
|
-
*/
|
|
183
|
-
fromISOString: (str: string) => Date | null;
|
|
184
|
-
/**
|
|
185
|
-
*
|
|
186
|
-
* @param {Temporal.PlainDate} d1 - First date
|
|
187
|
-
* @param {Temporal.PlainDate} d2 - Second date
|
|
188
|
-
*/
|
|
189
|
-
compare: (d1: Date, d2: Date) => number;
|
|
190
|
-
/**
|
|
191
|
-
*
|
|
192
|
-
* @param {Temporal.PlainDate} date - The date to format
|
|
193
|
-
* @param {string} format - The format string
|
|
194
|
-
*/
|
|
195
|
-
format: (date: Date, format: string) => string;
|
|
196
|
-
/**
|
|
197
|
-
*
|
|
198
|
-
* @param {Temporal.PlainDate} date - The date to check
|
|
199
|
-
* @param {Temporal.PlainDate | null} min - Minimum date
|
|
200
|
-
* @param {Temporal.PlainDate | null} max - Maximum date
|
|
201
|
-
*/
|
|
202
|
-
isInRange: (date: Date, min: Date | null, max: Date | null) => boolean;
|
|
203
|
-
};
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Copyright IBM Corp. 2026
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
-
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Temporal API utilities for date picker
|
|
11
|
-
* Uses the modern Temporal API for robust date handling
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Convert a Date object to Temporal.PlainDate
|
|
15
|
-
*
|
|
16
|
-
* @param {Date} date - JavaScript Date object
|
|
17
|
-
* @returns Temporal.PlainDate
|
|
18
|
-
*/
|
|
19
|
-
function dateToPlainDate(date) {
|
|
20
|
-
return Temporal.PlainDate.from({
|
|
21
|
-
year: date.getFullYear(),
|
|
22
|
-
month: date.getMonth() + 1,
|
|
23
|
-
day: date.getDate(),
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Convert Temporal.PlainDate to Date object
|
|
28
|
-
*
|
|
29
|
-
* @param {Temporal.PlainDate} plainDate - Temporal.PlainDate
|
|
30
|
-
* @returns JavaScript Date object
|
|
31
|
-
*/
|
|
32
|
-
function plainDateToDate(plainDate) {
|
|
33
|
-
return new Date(plainDate.year, plainDate.month - 1, plainDate.day);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Convert Temporal.PlainDate to ISO date string (YYYY-MM-DD)
|
|
37
|
-
*
|
|
38
|
-
* @param {Temporal.PlainDate} plainDate - Temporal.PlainDate
|
|
39
|
-
* @returns ISO date string
|
|
40
|
-
*/
|
|
41
|
-
function plainDateToISOString(plainDate) {
|
|
42
|
-
return plainDate.toString();
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Parse ISO date string to Temporal.PlainDate
|
|
46
|
-
*
|
|
47
|
-
* @param {string} isoString - ISO date string (YYYY-MM-DD)
|
|
48
|
-
* @returns Temporal.PlainDate or null if invalid
|
|
49
|
-
*/
|
|
50
|
-
function parseISOToPlainDate(isoString) {
|
|
51
|
-
try {
|
|
52
|
-
return Temporal.PlainDate.from(isoString);
|
|
53
|
-
}
|
|
54
|
-
catch (_a) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Parse a date string in various formats to Temporal.PlainDate
|
|
60
|
-
* Supports: ISO (YYYY-MM-DD), US (MM/DD/YYYY), and JavaScript Date objects
|
|
61
|
-
*
|
|
62
|
-
* @param {string | Date} dateInput - Date string or Date object
|
|
63
|
-
* @returns Temporal.PlainDate or null if invalid
|
|
64
|
-
*/
|
|
65
|
-
function parseDateToPlainDate(dateInput) {
|
|
66
|
-
if (!dateInput) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
// Handle Date objects
|
|
70
|
-
if (dateInput instanceof Date) {
|
|
71
|
-
return dateToPlainDate(dateInput);
|
|
72
|
-
}
|
|
73
|
-
// Try ISO format first (YYYY-MM-DD)
|
|
74
|
-
try {
|
|
75
|
-
return Temporal.PlainDate.from(dateInput);
|
|
76
|
-
}
|
|
77
|
-
catch (_a) {
|
|
78
|
-
// Not ISO format, try parsing MM/DD/YYYY or M/D/YYYY
|
|
79
|
-
const parts = dateInput.split('/');
|
|
80
|
-
if (parts.length === 3) {
|
|
81
|
-
const month = parseInt(parts[0], 10);
|
|
82
|
-
const day = parseInt(parts[1], 10);
|
|
83
|
-
const year = parseInt(parts[2], 10);
|
|
84
|
-
if (!isNaN(month) && !isNaN(day) && !isNaN(year)) {
|
|
85
|
-
try {
|
|
86
|
-
return Temporal.PlainDate.from({
|
|
87
|
-
year,
|
|
88
|
-
month,
|
|
89
|
-
day,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
catch (_b) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Compare two Temporal.PlainDate objects
|
|
102
|
-
*
|
|
103
|
-
* @param {Temporal.PlainDate} date1 - First date
|
|
104
|
-
* @param {Temporal.PlainDate} date2 - Second date
|
|
105
|
-
* @returns -1 if date1 < date2, 0 if equal, 1 if date1 > date2
|
|
106
|
-
*/
|
|
107
|
-
function comparePlainDates(date1, date2) {
|
|
108
|
-
return Temporal.PlainDate.compare(date1, date2);
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Check if a date is within a range
|
|
112
|
-
*
|
|
113
|
-
* @param {Temporal.PlainDate} date - Date to check
|
|
114
|
-
* @param {Temporal.PlainDate | null} minDate - Minimum date (inclusive)
|
|
115
|
-
* @param {Temporal.PlainDate | null} maxDate - Maximum date (inclusive)
|
|
116
|
-
* @returns True if date is within range
|
|
117
|
-
*/
|
|
118
|
-
function isDateInRange(date, minDate, maxDate) {
|
|
119
|
-
if (minDate && comparePlainDates(date, minDate) < 0) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
if (maxDate && comparePlainDates(date, maxDate) > 0) {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
127
|
-
// Made with Bob
|
|
128
|
-
|
|
129
|
-
exports.comparePlainDates = comparePlainDates;
|
|
130
|
-
exports.dateToPlainDate = dateToPlainDate;
|
|
131
|
-
exports.isDateInRange = isDateInRange;
|
|
132
|
-
exports.parseDateToPlainDate = parseDateToPlainDate;
|
|
133
|
-
exports.parseISOToPlainDate = parseISOToPlainDate;
|
|
134
|
-
exports.plainDateToDate = plainDateToDate;
|
|
135
|
-
exports.plainDateToISOString = plainDateToISOString;
|
|
136
|
-
//# sourceMappingURL=temporal-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"temporal-utils.js","sources":["../../../state-machine/temporal-utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;AAKG;AAEH;;;AAGG;AAEH;;;;;AAKG;AACG,SAAU,eAAe,CAAC,IAAU,EAAA;AACxC,IAAA,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC;AAC7B,QAAA,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE;AACxB,QAAA,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;AAC1B,QAAA,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE;AACpB,KAAA,CAAC;AACJ;AAEA;;;;;AAKG;AACG,SAAU,eAAe,CAAC,SAA6B,EAAA;AAC3D,IAAA,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,GAAG,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC;AACrE;AAEA;;;;;AAKG;AACG,SAAU,oBAAoB,CAAC,SAA6B,EAAA;AAChE,IAAA,OAAO,SAAS,CAAC,QAAQ,EAAE;AAC7B;AAEA;;;;;AAKG;AACG,SAAU,mBAAmB,CACjC,SAAiB,EAAA;AAEjB,IAAA,IAAI;QACF,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;IAC3C;AAAE,IAAA,OAAA,EAAA,EAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF;AAEA;;;;;;AAMG;AACG,SAAU,oBAAoB,CAClC,SAA2C,EAAA;IAE3C,IAAI,CAAC,SAAS,EAAE;AACd,QAAA,OAAO,IAAI;IACb;;AAGA,IAAA,IAAI,SAAS,YAAY,IAAI,EAAE;AAC7B,QAAA,OAAO,eAAe,CAAC,SAAS,CAAC;IACnC;;AAGA,IAAA,IAAI;QACF,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;IAC3C;AAAE,IAAA,OAAA,EAAA,EAAM;;QAEN,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC;AAClC,QAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YACtB,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;YACpC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;YAClC,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAEnC,YAAA,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;AAChD,gBAAA,IAAI;AACF,oBAAA,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC;wBAC7B,IAAI;wBACJ,KAAK;wBACL,GAAG;AACJ,qBAAA,CAAC;gBACJ;AAAE,gBAAA,OAAA,EAAA,EAAM;AACN,oBAAA,OAAO,IAAI;gBACb;YACF;QACF;AACA,QAAA,OAAO,IAAI;IACb;AACF;AAEA;;;;;;AAMG;AACG,SAAU,iBAAiB,CAC/B,KAAyB,EACzB,KAAyB,EAAA;IAEzB,OAAO,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;AACjD;AAEA;;;;;;;AAOG;SACa,aAAa,CAC3B,IAAwB,EACxB,OAAkC,EAClC,OAAkC,EAAA;IAElC,IAAI,OAAO,IAAI,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE;AACnD,QAAA,OAAO,KAAK;IACd;IACA,IAAI,OAAO,IAAI,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE;AACnD,QAAA,OAAO,KAAK;IACd;AACA,IAAA,OAAO,IAAI;AACb;AAuQA;;;;;;;;;;"}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2026
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Temporal API type declarations
|
|
9
|
-
* Using Temporal for modern date handling
|
|
10
|
-
*/
|
|
11
|
-
declare global {
|
|
12
|
-
namespace Temporal {
|
|
13
|
-
interface PlainDate {
|
|
14
|
-
readonly year: number;
|
|
15
|
-
readonly month: number;
|
|
16
|
-
readonly day: number;
|
|
17
|
-
readonly daysInMonth: number;
|
|
18
|
-
toString(): string;
|
|
19
|
-
with(dateLike: {
|
|
20
|
-
year?: number;
|
|
21
|
-
month?: number;
|
|
22
|
-
day?: number;
|
|
23
|
-
}): PlainDate;
|
|
24
|
-
add(duration: {
|
|
25
|
-
days?: number;
|
|
26
|
-
months?: number;
|
|
27
|
-
years?: number;
|
|
28
|
-
}): PlainDate;
|
|
29
|
-
until(other: PlainDate): {
|
|
30
|
-
days: number;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
interface PlainDateConstructor {
|
|
34
|
-
from(item: string | {
|
|
35
|
-
year: number;
|
|
36
|
-
month: number;
|
|
37
|
-
day: number;
|
|
38
|
-
}): PlainDate;
|
|
39
|
-
compare(one: PlainDate, two: PlainDate): number;
|
|
40
|
-
}
|
|
41
|
-
const PlainDate: PlainDateConstructor;
|
|
42
|
-
interface Now {
|
|
43
|
-
plainDateISO(): PlainDate;
|
|
44
|
-
}
|
|
45
|
-
const Now: Now;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Date picker modes
|
|
50
|
-
*/
|
|
51
|
-
export type DatePickerMode = 'simple' | 'single' | 'range';
|
|
52
|
-
/**
|
|
53
|
-
* Input type for range mode
|
|
54
|
-
*/
|
|
55
|
-
export type InputType = 'from' | 'to';
|
|
56
|
-
/**
|
|
57
|
-
* Date picker state machine context
|
|
58
|
-
* Contains all the state needed to manage the datepicker
|
|
59
|
-
* Uses Temporal.PlainDate for robust date handling
|
|
60
|
-
*/
|
|
61
|
-
export interface DatePickerContext {
|
|
62
|
-
/** The mode of the date picker */
|
|
63
|
-
mode: DatePickerMode;
|
|
64
|
-
/** The current value as ISO date string(s) */
|
|
65
|
-
value: string;
|
|
66
|
-
/** The selected start date (using Temporal API) */
|
|
67
|
-
startDate: Temporal.PlainDate | null;
|
|
68
|
-
/** The selected end date (range mode only, using Temporal API) */
|
|
69
|
-
endDate: Temporal.PlainDate | null;
|
|
70
|
-
/** Whether the calendar dropdown is open */
|
|
71
|
-
isOpen: boolean;
|
|
72
|
-
/** Whether an input has focus */
|
|
73
|
-
isFocused: boolean;
|
|
74
|
-
/** Whether the component is disabled */
|
|
75
|
-
isDisabled: boolean;
|
|
76
|
-
/** Whether the component is readonly */
|
|
77
|
-
isReadonly: boolean;
|
|
78
|
-
/** Whether the component is in an invalid state */
|
|
79
|
-
isInvalid: boolean;
|
|
80
|
-
/** The last focused input (for range mode) */
|
|
81
|
-
lastFocusedInput: InputType | null;
|
|
82
|
-
/** Minimum selectable date (using Temporal API) */
|
|
83
|
-
minDate: Temporal.PlainDate | null;
|
|
84
|
-
/** Maximum selectable date (using Temporal API) */
|
|
85
|
-
maxDate: Temporal.PlainDate | null;
|
|
86
|
-
/** Date format string */
|
|
87
|
-
dateFormat: string;
|
|
88
|
-
/** Whether to allow manual input */
|
|
89
|
-
allowInput: boolean;
|
|
90
|
-
/** Whether to close calendar on date selection */
|
|
91
|
-
closeOnSelect: boolean;
|
|
92
|
-
/** Error message if any */
|
|
93
|
-
errorMessage?: string;
|
|
94
|
-
/** The currently viewed month in the calendar (using Temporal API) */
|
|
95
|
-
viewDate: Temporal.PlainDate | null;
|
|
96
|
-
/** The date that currently has keyboard focus in the calendar */
|
|
97
|
-
focusedDate: Temporal.PlainDate | null;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Event payload types
|
|
101
|
-
*/
|
|
102
|
-
export interface DateSelectPayload {
|
|
103
|
-
date: Temporal.PlainDate;
|
|
104
|
-
inputType?: InputType;
|
|
105
|
-
}
|
|
106
|
-
export interface InputFocusPayload {
|
|
107
|
-
inputType: InputType;
|
|
108
|
-
}
|
|
109
|
-
export interface KeyboardPayload {
|
|
110
|
-
key: string;
|
|
111
|
-
shiftKey?: boolean;
|
|
112
|
-
}
|
|
113
|
-
export interface ValueChangePayload {
|
|
114
|
-
value: string;
|
|
115
|
-
}
|
|
116
|
-
export interface ValidationErrorPayload {
|
|
117
|
-
message: string;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Date picker event
|
|
121
|
-
*/
|
|
122
|
-
export interface DatePickerEvent<T = any> {
|
|
123
|
-
type: string;
|
|
124
|
-
payload?: T;
|
|
125
|
-
timestamp: number;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* State transition information
|
|
129
|
-
*/
|
|
130
|
-
export interface StateTransition {
|
|
131
|
-
from: string;
|
|
132
|
-
to: string;
|
|
133
|
-
event: DatePickerEvent;
|
|
134
|
-
context: DatePickerContext;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Guard function type - determines if a transition is allowed
|
|
138
|
-
*/
|
|
139
|
-
export type StateGuard = (context: DatePickerContext, event: DatePickerEvent) => boolean;
|
|
140
|
-
/**
|
|
141
|
-
* Action function type - updates context during transition
|
|
142
|
-
*/
|
|
143
|
-
export type StateAction = (context: DatePickerContext, event: DatePickerEvent) => Partial<DatePickerContext>;
|
|
144
|
-
/**
|
|
145
|
-
* Side effect function type - performs side effects after transition
|
|
146
|
-
*/
|
|
147
|
-
export type SideEffect = (context: DatePickerContext, event: DatePickerEvent) => void;
|
|
148
|
-
/**
|
|
149
|
-
* Transition listener function type
|
|
150
|
-
*/
|
|
151
|
-
export type TransitionListener = (transition: StateTransition) => void;
|
|
152
|
-
/**
|
|
153
|
-
* State configuration
|
|
154
|
-
*/
|
|
155
|
-
export interface StateConfig {
|
|
156
|
-
guards?: Record<string, StateGuard>;
|
|
157
|
-
actions?: Record<string, StateAction>;
|
|
158
|
-
effects?: Record<string, SideEffect>;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Transition map type
|
|
162
|
-
*/
|
|
163
|
-
export type TransitionMap = Record<string, Partial<Record<string, string>>>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|