@zag-js/date-utils 0.0.0-dev-20230107115230 → 0.0.0-dev-20230107153917
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/align.d.ts +4 -4
- package/dist/align.js +20 -24
- package/dist/align.mjs +2 -2
- package/dist/assertion.d.ts +8 -8
- package/dist/assertion.js +15 -16
- package/dist/assertion.mjs +1 -1
- package/dist/chunk-6EJZROXM.mjs +45 -0
- package/dist/{chunk-TCPXGBJP.mjs → chunk-BBE325GQ.mjs} +9 -8
- package/dist/chunk-BUT5IUNZ.mjs +32 -0
- package/dist/{chunk-EXWX3KZT.mjs → chunk-CAV5WKCZ.mjs} +4 -2
- package/dist/chunk-GKU5M6QU.mjs +25 -0
- package/dist/{chunk-XHAL6X5Z.mjs → chunk-HKHGJ6WS.mjs} +3 -3
- package/dist/{chunk-ECAENYV6.mjs → chunk-HUBKWHIN.mjs} +1 -1
- package/dist/{chunk-M4F23P2U.mjs → chunk-JZVHAOWX.mjs} +3 -3
- package/dist/{chunk-2DZ3KIVJ.mjs → chunk-L3YHK2WH.mjs} +1 -1
- package/dist/chunk-MGPXEJO4.mjs +71 -0
- package/dist/chunk-MY373KF2.mjs +198 -0
- package/dist/chunk-URPTPFL3.mjs +31 -0
- package/dist/chunk-ZZPZ2BFS.mjs +52 -0
- package/dist/constrain.d.ts +6 -7
- package/dist/constrain.js +20 -25
- package/dist/constrain.mjs +1 -1
- package/dist/format-range.d.ts +2 -3
- package/dist/format-range.js +3 -3
- package/dist/format-range.mjs +1 -1
- package/dist/format-selected-date.d.ts +3 -3
- package/dist/format-selected-date.js +13 -13
- package/dist/format-selected-date.mjs +3 -4
- package/dist/format-visible-range.d.ts +3 -3
- package/dist/format-visible-range.js +18 -17
- package/dist/format-visible-range.mjs +4 -26
- package/dist/get-formatter.d.ts +4 -3
- package/dist/get-formatter.js +6 -8
- package/dist/get-formatter.mjs +1 -2
- package/dist/get-month-dates.mjs +2 -2
- package/dist/get-week-dates.d.ts +1 -1
- package/dist/get-week-dates.js +2 -2
- package/dist/get-week-dates.mjs +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +284 -181
- package/dist/index.mjs +22 -19
- package/dist/mutation.d.ts +5 -5
- package/dist/mutation.js +16 -43
- package/dist/mutation.mjs +4 -5
- package/dist/pagination.d.ts +29 -10
- package/dist/pagination.js +183 -89
- package/dist/pagination.mjs +3 -2
- package/dist/placeholder.d.ts +1 -1
- package/dist/segment-constants.d.ts +1 -1
- package/dist/segment-limit.d.ts +2 -2
- package/dist/segment-limit.js +1 -1
- package/dist/segment-limit.mjs +1 -1
- package/dist/segment-mutation.d.ts +3 -4
- package/dist/segment-mutation.js +4 -2
- package/dist/segment-mutation.mjs +1 -1
- package/dist/segment-parts.d.ts +2 -2
- package/dist/segment-parts.js +4 -4
- package/dist/segment-parts.mjs +6 -6
- package/dist/types-cbf8b45a.d.ts +35 -0
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-6XKXGQP6.mjs +0 -32
- package/dist/chunk-7JERMWT3.mjs +0 -46
- package/dist/chunk-C4U2N3JC.mjs +0 -65
- package/dist/chunk-DI2YG6VG.mjs +0 -24
- package/dist/chunk-FJMTHABG.mjs +0 -8
- package/dist/chunk-HP2COJGP.mjs +0 -76
- package/dist/chunk-VWVBJ5CB.mjs +0 -110
- package/dist/get-era-format.d.ts +0 -5
- package/dist/get-era-format.js +0 -32
- package/dist/get-era-format.mjs +0 -6
- package/dist/types-9f60d2f1.d.ts +0 -61
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isDateInvalid
|
|
3
|
+
} from "./chunk-6EJZROXM.mjs";
|
|
4
|
+
import {
|
|
5
|
+
alignEnd,
|
|
6
|
+
alignStart,
|
|
7
|
+
constrainStart,
|
|
8
|
+
constrainValue
|
|
9
|
+
} from "./chunk-MGPXEJO4.mjs";
|
|
10
|
+
import {
|
|
11
|
+
getEndDate,
|
|
12
|
+
getUnitDuration
|
|
13
|
+
} from "./chunk-ZSLC7OI2.mjs";
|
|
14
|
+
|
|
15
|
+
// src/pagination.ts
|
|
16
|
+
import { endOfMonth, endOfWeek, startOfMonth, startOfWeek } from "@internationalized/date";
|
|
17
|
+
function getAdjustedDateFn(visibleDuration, locale, minValue, maxValue) {
|
|
18
|
+
return function getDate(options) {
|
|
19
|
+
const { startDate, focusedDate } = options;
|
|
20
|
+
const endDate = getEndDate(startDate, visibleDuration);
|
|
21
|
+
if (isDateInvalid(focusedDate, minValue, maxValue)) {
|
|
22
|
+
return {
|
|
23
|
+
startDate,
|
|
24
|
+
focusedDate: constrainValue(focusedDate, minValue, maxValue),
|
|
25
|
+
endDate
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (focusedDate.compare(startDate) < 0) {
|
|
29
|
+
return {
|
|
30
|
+
startDate: alignEnd(focusedDate, visibleDuration, locale, minValue, maxValue),
|
|
31
|
+
endDate,
|
|
32
|
+
focusedDate: constrainValue(focusedDate, minValue, maxValue)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (focusedDate.compare(endDate) > 0) {
|
|
36
|
+
return {
|
|
37
|
+
startDate: alignStart(focusedDate, visibleDuration, locale, minValue, maxValue),
|
|
38
|
+
endDate,
|
|
39
|
+
focusedDate: constrainValue(focusedDate, minValue, maxValue)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
startDate,
|
|
44
|
+
endDate,
|
|
45
|
+
focusedDate: constrainValue(focusedDate, minValue, maxValue)
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function getNextPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
50
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
51
|
+
const start = startDate.add(visibleDuration);
|
|
52
|
+
return adjust({
|
|
53
|
+
focusedDate: focusedDate.add(visibleDuration),
|
|
54
|
+
startDate: alignStart(
|
|
55
|
+
constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue),
|
|
56
|
+
visibleDuration,
|
|
57
|
+
locale
|
|
58
|
+
)
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function getPreviousPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
62
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
63
|
+
let start = startDate.subtract(visibleDuration);
|
|
64
|
+
return adjust({
|
|
65
|
+
focusedDate: focusedDate.subtract(visibleDuration),
|
|
66
|
+
startDate: alignStart(
|
|
67
|
+
constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue),
|
|
68
|
+
visibleDuration,
|
|
69
|
+
locale
|
|
70
|
+
)
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function getNextRow(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
74
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
75
|
+
if (visibleDuration.days) {
|
|
76
|
+
return getNextPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue);
|
|
77
|
+
}
|
|
78
|
+
if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years) {
|
|
79
|
+
return adjust({
|
|
80
|
+
focusedDate: focusedDate.add({ weeks: 1 }),
|
|
81
|
+
startDate
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function getPreviousRow(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
86
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
87
|
+
if (visibleDuration.days) {
|
|
88
|
+
return getPreviousPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue);
|
|
89
|
+
}
|
|
90
|
+
if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years) {
|
|
91
|
+
return adjust({
|
|
92
|
+
focusedDate: focusedDate.subtract({ weeks: 1 }),
|
|
93
|
+
startDate
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function getSectionStart(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
98
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
99
|
+
if (visibleDuration.days) {
|
|
100
|
+
return adjust({
|
|
101
|
+
focusedDate: startDate,
|
|
102
|
+
startDate
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (visibleDuration.weeks) {
|
|
106
|
+
return adjust({
|
|
107
|
+
focusedDate: startOfWeek(focusedDate, locale),
|
|
108
|
+
startDate
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (visibleDuration.months || visibleDuration.years) {
|
|
112
|
+
return adjust({
|
|
113
|
+
focusedDate: startOfMonth(focusedDate),
|
|
114
|
+
startDate
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function getSectionEnd(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
119
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
120
|
+
const endDate = getEndDate(startDate, visibleDuration);
|
|
121
|
+
if (visibleDuration.days) {
|
|
122
|
+
return adjust({
|
|
123
|
+
focusedDate: endDate,
|
|
124
|
+
startDate
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (visibleDuration.weeks) {
|
|
128
|
+
return adjust({
|
|
129
|
+
focusedDate: endOfWeek(focusedDate, locale),
|
|
130
|
+
startDate
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
if (visibleDuration.months || visibleDuration.years) {
|
|
134
|
+
return adjust({
|
|
135
|
+
focusedDate: endOfMonth(focusedDate),
|
|
136
|
+
startDate
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function getNextSection(focusedDate, startDate, larger, visibleDuration, locale, minValue, maxValue) {
|
|
141
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
142
|
+
if (!larger && !visibleDuration.days) {
|
|
143
|
+
return adjust({
|
|
144
|
+
focusedDate: focusedDate.add(getUnitDuration(visibleDuration)),
|
|
145
|
+
startDate
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (visibleDuration.days) {
|
|
149
|
+
return getNextPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue);
|
|
150
|
+
}
|
|
151
|
+
if (visibleDuration.weeks) {
|
|
152
|
+
return adjust({
|
|
153
|
+
focusedDate: focusedDate.add({ months: 1 }),
|
|
154
|
+
startDate
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (visibleDuration.months || visibleDuration.years) {
|
|
158
|
+
return adjust({
|
|
159
|
+
focusedDate: focusedDate.add({ years: 1 }),
|
|
160
|
+
startDate
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function getPreviousSection(focusedDate, startDate, larger, visibleDuration, locale, minValue, maxValue) {
|
|
165
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
166
|
+
if (!larger && !visibleDuration.days) {
|
|
167
|
+
return adjust({
|
|
168
|
+
focusedDate: focusedDate.subtract(getUnitDuration(visibleDuration)),
|
|
169
|
+
startDate
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
if (visibleDuration.days) {
|
|
173
|
+
return getPreviousPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue);
|
|
174
|
+
}
|
|
175
|
+
if (visibleDuration.weeks) {
|
|
176
|
+
return adjust({
|
|
177
|
+
focusedDate: focusedDate.subtract({ months: 1 }),
|
|
178
|
+
startDate
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
if (visibleDuration.months || visibleDuration.years) {
|
|
182
|
+
return adjust({
|
|
183
|
+
focusedDate: focusedDate.subtract({ years: 1 }),
|
|
184
|
+
startDate
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export {
|
|
190
|
+
getNextPage,
|
|
191
|
+
getPreviousPage,
|
|
192
|
+
getNextRow,
|
|
193
|
+
getPreviousRow,
|
|
194
|
+
getSectionStart,
|
|
195
|
+
getSectionEnd,
|
|
196
|
+
getNextSection,
|
|
197
|
+
getPreviousSection
|
|
198
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatRange
|
|
3
|
+
} from "./chunk-HKHGJ6WS.mjs";
|
|
4
|
+
import {
|
|
5
|
+
getDateFormatter,
|
|
6
|
+
getMonthFormatter
|
|
7
|
+
} from "./chunk-BBE325GQ.mjs";
|
|
8
|
+
|
|
9
|
+
// src/format-visible-range.ts
|
|
10
|
+
import { endOfMonth, isSameDay, startOfMonth } from "@internationalized/date";
|
|
11
|
+
function formatVisibleRange(startDate, endDate, getFormatter, isAria, timeZone) {
|
|
12
|
+
if (!startDate)
|
|
13
|
+
return "";
|
|
14
|
+
let start = startDate;
|
|
15
|
+
let end = endDate != null ? endDate : startDate;
|
|
16
|
+
let monthFormatter = getMonthFormatter(start, end, getFormatter, timeZone);
|
|
17
|
+
let dateFormatter = getDateFormatter(start, end, getFormatter, timeZone);
|
|
18
|
+
if (!isSameDay(start, startOfMonth(start))) {
|
|
19
|
+
return isAria ? formatRange(start, end, dateFormatter, (start2, end2) => `${start2} \u2013 ${end2}`, timeZone) : dateFormatter.formatRange(start.toDate(timeZone), end.toDate(timeZone));
|
|
20
|
+
}
|
|
21
|
+
if (isSameDay(end, endOfMonth(start))) {
|
|
22
|
+
return monthFormatter.format(start.toDate(timeZone));
|
|
23
|
+
}
|
|
24
|
+
if (isSameDay(end, endOfMonth(end))) {
|
|
25
|
+
return isAria ? formatRange(start, end, monthFormatter, (start2, end2) => `${start2} \u2013 ${end2}`, timeZone) : monthFormatter.formatRange(start.toDate(timeZone), end.toDate(timeZone));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
formatVisibleRange
|
|
31
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
constrainValue
|
|
3
|
+
} from "./chunk-MGPXEJO4.mjs";
|
|
4
|
+
|
|
5
|
+
// src/mutation.ts
|
|
6
|
+
import { toCalendar, toCalendarDate, today } from "@internationalized/date";
|
|
7
|
+
function getTodayDate(timezone) {
|
|
8
|
+
return today(timezone);
|
|
9
|
+
}
|
|
10
|
+
function getNextDay(date) {
|
|
11
|
+
return date.add({ days: 1 });
|
|
12
|
+
}
|
|
13
|
+
function getPreviousDay(date) {
|
|
14
|
+
return date.subtract({ days: 1 });
|
|
15
|
+
}
|
|
16
|
+
function setMonth(date, month) {
|
|
17
|
+
return date.set({ month });
|
|
18
|
+
}
|
|
19
|
+
function setYear(date, year) {
|
|
20
|
+
return date.set({ year });
|
|
21
|
+
}
|
|
22
|
+
function setCalendar(date, calendar) {
|
|
23
|
+
return toCalendar(toCalendarDate(date), calendar);
|
|
24
|
+
}
|
|
25
|
+
function setDate(date, startDate, isDateUnavailable, minValue, maxValue) {
|
|
26
|
+
let result;
|
|
27
|
+
result = constrainValue(date, minValue, maxValue);
|
|
28
|
+
result = getPreviousAvailableDate(date, startDate, isDateUnavailable);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
function getPreviousAvailableDate(date, minValue, isDateUnavailable) {
|
|
32
|
+
if (!isDateUnavailable) {
|
|
33
|
+
return date;
|
|
34
|
+
}
|
|
35
|
+
while (date.compare(minValue) >= 0 && isDateUnavailable(date)) {
|
|
36
|
+
date = date.subtract({ days: 1 });
|
|
37
|
+
}
|
|
38
|
+
if (date.compare(minValue) >= 0) {
|
|
39
|
+
return date;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
getTodayDate,
|
|
45
|
+
getNextDay,
|
|
46
|
+
getPreviousDay,
|
|
47
|
+
setMonth,
|
|
48
|
+
setYear,
|
|
49
|
+
setCalendar,
|
|
50
|
+
setDate,
|
|
51
|
+
getPreviousAvailableDate
|
|
52
|
+
};
|
package/dist/constrain.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { CalendarDate } from '@internationalized/date';
|
|
2
|
-
import { D as DateContext } from './types-9f60d2f1.js';
|
|
1
|
+
import { CalendarDate, DateDuration, DateValue } from '@internationalized/date';
|
|
3
2
|
|
|
4
|
-
declare function alignCenter(
|
|
5
|
-
declare function alignStart(
|
|
6
|
-
declare function alignEnd(
|
|
7
|
-
declare function
|
|
8
|
-
declare function
|
|
3
|
+
declare function alignCenter(date: CalendarDate, duration: DateDuration, locale: string, min?: DateValue, max?: DateValue): CalendarDate;
|
|
4
|
+
declare function alignStart(date: CalendarDate, duration: DateDuration, locale: string, min?: DateValue, max?: DateValue): CalendarDate;
|
|
5
|
+
declare function alignEnd(date: CalendarDate, duration: DateDuration, locale: string, min?: DateValue, max?: DateValue): CalendarDate;
|
|
6
|
+
declare function constrainStart(date: CalendarDate, aligned: CalendarDate, duration: DateDuration, locale: string, min?: DateValue, max?: DateValue): CalendarDate;
|
|
7
|
+
declare function constrainValue(date: CalendarDate, minValue: DateValue, maxValue: DateValue): CalendarDate;
|
|
9
8
|
|
|
10
9
|
export { alignCenter, alignEnd, alignStart, constrainStart, constrainValue };
|
package/dist/constrain.js
CHANGED
|
@@ -28,8 +28,7 @@ __export(constrain_exports, {
|
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(constrain_exports);
|
|
30
30
|
var import_date = require("@internationalized/date");
|
|
31
|
-
function alignCenter(
|
|
32
|
-
const { duration } = ctx;
|
|
31
|
+
function alignCenter(date, duration, locale, min, max) {
|
|
33
32
|
let halfDuration = {};
|
|
34
33
|
for (let key in duration) {
|
|
35
34
|
halfDuration[key] = Math.floor(duration[key] / 2);
|
|
@@ -37,11 +36,10 @@ function alignCenter(ctx, date) {
|
|
|
37
36
|
halfDuration[key]--;
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
|
-
let aligned = alignStart(
|
|
41
|
-
return constrainStart(
|
|
39
|
+
let aligned = alignStart(date, duration, locale).subtract(halfDuration);
|
|
40
|
+
return constrainStart(date, aligned, duration, locale, min, max);
|
|
42
41
|
}
|
|
43
|
-
function alignStart(
|
|
44
|
-
let { locale, duration } = ctx;
|
|
42
|
+
function alignStart(date, duration, locale, min, max) {
|
|
45
43
|
let aligned = date;
|
|
46
44
|
if (duration.years) {
|
|
47
45
|
aligned = (0, import_date.startOfYear)(date);
|
|
@@ -50,10 +48,9 @@ function alignStart(ctx, date) {
|
|
|
50
48
|
} else if (duration.weeks) {
|
|
51
49
|
aligned = (0, import_date.startOfWeek)(date, locale);
|
|
52
50
|
}
|
|
53
|
-
return constrainStart(
|
|
51
|
+
return constrainStart(date, aligned, duration, locale, min, max);
|
|
54
52
|
}
|
|
55
|
-
function alignEnd(
|
|
56
|
-
const { duration } = ctx;
|
|
53
|
+
function alignEnd(date, duration, locale, min, max) {
|
|
57
54
|
let d = { ...duration };
|
|
58
55
|
if (d.days) {
|
|
59
56
|
d.days--;
|
|
@@ -64,29 +61,27 @@ function alignEnd(ctx, date) {
|
|
|
64
61
|
} else if (d.years) {
|
|
65
62
|
d.years--;
|
|
66
63
|
}
|
|
67
|
-
let aligned = alignStart(
|
|
68
|
-
return constrainStart(
|
|
64
|
+
let aligned = alignStart(date, duration, locale).subtract(d);
|
|
65
|
+
return constrainStart(date, aligned, duration, locale, min, max);
|
|
69
66
|
}
|
|
70
|
-
function
|
|
71
|
-
let { min, max } = ctx;
|
|
72
|
-
if (min) {
|
|
73
|
-
date = (0, import_date.maxDate)(date, (0, import_date.toCalendarDate)(min));
|
|
74
|
-
}
|
|
75
|
-
if (max) {
|
|
76
|
-
date = (0, import_date.minDate)(date, (0, import_date.toCalendarDate)(max));
|
|
77
|
-
}
|
|
78
|
-
return date;
|
|
79
|
-
}
|
|
80
|
-
function constrainStart(ctx, date, aligned) {
|
|
81
|
-
let { min, max } = ctx;
|
|
67
|
+
function constrainStart(date, aligned, duration, locale, min, max) {
|
|
82
68
|
if (min && date.compare(min) >= 0) {
|
|
83
|
-
aligned = (0, import_date.maxDate)(aligned, alignStart(
|
|
69
|
+
aligned = (0, import_date.maxDate)(aligned, alignStart((0, import_date.toCalendarDate)(min), duration, locale));
|
|
84
70
|
}
|
|
85
71
|
if (max && date.compare(max) <= 0) {
|
|
86
|
-
aligned = (0, import_date.minDate)(aligned, alignEnd(
|
|
72
|
+
aligned = (0, import_date.minDate)(aligned, alignEnd((0, import_date.toCalendarDate)(max), duration, locale));
|
|
87
73
|
}
|
|
88
74
|
return aligned;
|
|
89
75
|
}
|
|
76
|
+
function constrainValue(date, minValue, maxValue) {
|
|
77
|
+
if (minValue) {
|
|
78
|
+
date = (0, import_date.maxDate)(date, (0, import_date.toCalendarDate)(minValue));
|
|
79
|
+
}
|
|
80
|
+
if (maxValue) {
|
|
81
|
+
date = (0, import_date.minDate)(date, (0, import_date.toCalendarDate)(maxValue));
|
|
82
|
+
}
|
|
83
|
+
return date;
|
|
84
|
+
}
|
|
90
85
|
// Annotate the CommonJS export names for ESM import in node:
|
|
91
86
|
0 && (module.exports = {
|
|
92
87
|
alignCenter,
|
package/dist/constrain.mjs
CHANGED
package/dist/format-range.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { DateFormatter } from '@internationalized/date';
|
|
2
|
-
import { b as DateDescriptionContext } from './types-9f60d2f1.js';
|
|
1
|
+
import { CalendarDate, DateFormatter } from '@internationalized/date';
|
|
3
2
|
|
|
4
|
-
declare function formatRange(
|
|
3
|
+
declare function formatRange(startDate: CalendarDate, endDate: CalendarDate, formatter: DateFormatter, toString: (start: string, end: string) => string, timeZone: string): string;
|
|
5
4
|
|
|
6
5
|
export { formatRange };
|
package/dist/format-range.js
CHANGED
|
@@ -23,8 +23,8 @@ __export(format_range_exports, {
|
|
|
23
23
|
formatRange: () => formatRange
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(format_range_exports);
|
|
26
|
-
function formatRange(
|
|
27
|
-
let parts = formatter.formatRangeToParts(
|
|
26
|
+
function formatRange(startDate, endDate, formatter, toString, timeZone) {
|
|
27
|
+
let parts = formatter.formatRangeToParts(startDate.toDate(timeZone), endDate.toDate(timeZone));
|
|
28
28
|
let separatorIndex = -1;
|
|
29
29
|
for (let i = 0; i < parts.length; i++) {
|
|
30
30
|
let part = parts[i];
|
|
@@ -43,7 +43,7 @@ function formatRange(ctx, formatter) {
|
|
|
43
43
|
end += parts[i].value;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
return
|
|
46
|
+
return toString(start, end);
|
|
47
47
|
}
|
|
48
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
49
49
|
0 && (module.exports = {
|
package/dist/format-range.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import '
|
|
1
|
+
import { CalendarDate } from '@internationalized/date';
|
|
2
|
+
import { G as GetFormatterFn } from './types-cbf8b45a.js';
|
|
3
3
|
|
|
4
|
-
declare function formatSelectedDate(
|
|
4
|
+
declare function formatSelectedDate(startDate: CalendarDate, endDate: CalendarDate | null, getFormatter: GetFormatterFn, isSelectingRange: boolean, timeZone: string): string;
|
|
5
5
|
|
|
6
6
|
export { formatSelectedDate };
|
|
@@ -26,8 +26,8 @@ module.exports = __toCommonJS(format_selected_date_exports);
|
|
|
26
26
|
var import_date = require("@internationalized/date");
|
|
27
27
|
|
|
28
28
|
// src/format-range.ts
|
|
29
|
-
function formatRange(
|
|
30
|
-
let parts = formatter.formatRangeToParts(
|
|
29
|
+
function formatRange(startDate, endDate, formatter, toString, timeZone) {
|
|
30
|
+
let parts = formatter.formatRangeToParts(startDate.toDate(timeZone), endDate.toDate(timeZone));
|
|
31
31
|
let separatorIndex = -1;
|
|
32
32
|
for (let i = 0; i < parts.length; i++) {
|
|
33
33
|
let part = parts[i];
|
|
@@ -46,17 +46,16 @@ function formatRange(ctx, formatter) {
|
|
|
46
46
|
end += parts[i].value;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
return
|
|
49
|
+
return toString(start, end);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
// src/get-
|
|
52
|
+
// src/get-formatter.ts
|
|
53
53
|
function getEraFormat(date) {
|
|
54
54
|
return (date == null ? void 0 : date.calendar.identifier) === "gregory" && date.era === "BC" ? "short" : void 0;
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const { start, end = start, getDateFormatter: getDateFormatter2, timeZone } = ctx;
|
|
56
|
+
function getDateFormatter(startDate, endDate, getDateFormatter2, timeZone) {
|
|
57
|
+
let start = startDate;
|
|
58
|
+
let end = endDate != null ? endDate : startDate;
|
|
60
59
|
let era = getEraFormat(start) || getEraFormat(end);
|
|
61
60
|
return getDateFormatter2({
|
|
62
61
|
weekday: "long",
|
|
@@ -69,16 +68,17 @@ function getDateFormatter(ctx) {
|
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
// src/format-selected-date.ts
|
|
72
|
-
function formatSelectedDate(
|
|
73
|
-
|
|
74
|
-
let
|
|
75
|
-
|
|
71
|
+
function formatSelectedDate(startDate, endDate, getFormatter, isSelectingRange, timeZone) {
|
|
72
|
+
let start = startDate;
|
|
73
|
+
let end = endDate != null ? endDate : startDate;
|
|
74
|
+
let formatter = getDateFormatter(start, end, getFormatter, timeZone);
|
|
75
|
+
if (isSelectingRange || start == null || end == null) {
|
|
76
76
|
return "";
|
|
77
77
|
}
|
|
78
78
|
if ((0, import_date.isSameDay)(start, end)) {
|
|
79
79
|
return formatter.format(start.toDate(timeZone));
|
|
80
80
|
}
|
|
81
|
-
return formatRange(
|
|
81
|
+
return formatRange(start, end, formatter, (start2, end2) => `${start2} \u2013 ${end2}`, timeZone);
|
|
82
82
|
}
|
|
83
83
|
// Annotate the CommonJS export names for ESM import in node:
|
|
84
84
|
0 && (module.exports = {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
formatSelectedDate
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-FJMTHABG.mjs";
|
|
3
|
+
} from "./chunk-GKU5M6QU.mjs";
|
|
4
|
+
import "./chunk-HKHGJ6WS.mjs";
|
|
5
|
+
import "./chunk-BBE325GQ.mjs";
|
|
7
6
|
export {
|
|
8
7
|
formatSelectedDate
|
|
9
8
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import '
|
|
1
|
+
import { CalendarDate } from '@internationalized/date';
|
|
2
|
+
import { G as GetFormatterFn } from './types-cbf8b45a.js';
|
|
3
3
|
|
|
4
|
-
declare function formatVisibleRange(
|
|
4
|
+
declare function formatVisibleRange(startDate: CalendarDate | null, endDate: CalendarDate | null, getFormatter: GetFormatterFn, isAria: boolean, timeZone: string): string | undefined;
|
|
5
5
|
|
|
6
6
|
export { formatVisibleRange };
|
|
@@ -26,8 +26,8 @@ module.exports = __toCommonJS(format_visible_range_exports);
|
|
|
26
26
|
var import_date = require("@internationalized/date");
|
|
27
27
|
|
|
28
28
|
// src/format-range.ts
|
|
29
|
-
function formatRange(
|
|
30
|
-
let parts = formatter.formatRangeToParts(
|
|
29
|
+
function formatRange(startDate, endDate, formatter, toString, timeZone) {
|
|
30
|
+
let parts = formatter.formatRangeToParts(startDate.toDate(timeZone), endDate.toDate(timeZone));
|
|
31
31
|
let separatorIndex = -1;
|
|
32
32
|
for (let i = 0; i < parts.length; i++) {
|
|
33
33
|
let part = parts[i];
|
|
@@ -46,17 +46,16 @@ function formatRange(ctx, formatter) {
|
|
|
46
46
|
end += parts[i].value;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
return
|
|
49
|
+
return toString(start, end);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
// src/get-
|
|
52
|
+
// src/get-formatter.ts
|
|
53
53
|
function getEraFormat(date) {
|
|
54
54
|
return (date == null ? void 0 : date.calendar.identifier) === "gregory" && date.era === "BC" ? "short" : void 0;
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const { start, end = start, getDateFormatter: getDateFormatter2, timeZone } = ctx;
|
|
56
|
+
function getDateFormatter(startDate, endDate, getDateFormatter2, timeZone) {
|
|
57
|
+
let start = startDate;
|
|
58
|
+
let end = endDate != null ? endDate : startDate;
|
|
60
59
|
let era = getEraFormat(start) || getEraFormat(end);
|
|
61
60
|
return getDateFormatter2({
|
|
62
61
|
weekday: "long",
|
|
@@ -67,8 +66,9 @@ function getDateFormatter(ctx) {
|
|
|
67
66
|
timeZone
|
|
68
67
|
});
|
|
69
68
|
}
|
|
70
|
-
function getMonthFormatter(
|
|
71
|
-
|
|
69
|
+
function getMonthFormatter(startDate, endDate, getDateFormatter2, timeZone) {
|
|
70
|
+
let start = startDate;
|
|
71
|
+
let end = endDate != null ? endDate : startDate;
|
|
72
72
|
let era = getEraFormat(start) || getEraFormat(end);
|
|
73
73
|
return getDateFormatter2({
|
|
74
74
|
month: "long",
|
|
@@ -80,20 +80,21 @@ function getMonthFormatter(ctx) {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// src/format-visible-range.ts
|
|
83
|
-
function formatVisibleRange(
|
|
84
|
-
if (!
|
|
83
|
+
function formatVisibleRange(startDate, endDate, getFormatter, isAria, timeZone) {
|
|
84
|
+
if (!startDate)
|
|
85
85
|
return "";
|
|
86
|
-
|
|
87
|
-
let
|
|
88
|
-
let
|
|
86
|
+
let start = startDate;
|
|
87
|
+
let end = endDate != null ? endDate : startDate;
|
|
88
|
+
let monthFormatter = getMonthFormatter(start, end, getFormatter, timeZone);
|
|
89
|
+
let dateFormatter = getDateFormatter(start, end, getFormatter, timeZone);
|
|
89
90
|
if (!(0, import_date.isSameDay)(start, (0, import_date.startOfMonth)(start))) {
|
|
90
|
-
return isAria ? formatRange(
|
|
91
|
+
return isAria ? formatRange(start, end, dateFormatter, (start2, end2) => `${start2} \u2013 ${end2}`, timeZone) : dateFormatter.formatRange(start.toDate(timeZone), end.toDate(timeZone));
|
|
91
92
|
}
|
|
92
93
|
if ((0, import_date.isSameDay)(end, (0, import_date.endOfMonth)(start))) {
|
|
93
94
|
return monthFormatter.format(start.toDate(timeZone));
|
|
94
95
|
}
|
|
95
96
|
if ((0, import_date.isSameDay)(end, (0, import_date.endOfMonth)(end))) {
|
|
96
|
-
return isAria ? formatRange(
|
|
97
|
+
return isAria ? formatRange(start, end, monthFormatter, (start2, end2) => `${start2} \u2013 ${end2}`, timeZone) : monthFormatter.formatRange(start.toDate(timeZone), end.toDate(timeZone));
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,30 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
formatRange
|
|
7
|
-
} from "./chunk-XHAL6X5Z.mjs";
|
|
8
|
-
import "./chunk-FJMTHABG.mjs";
|
|
9
|
-
|
|
10
|
-
// src/format-visible-range.ts
|
|
11
|
-
import { endOfMonth, isSameDay, startOfMonth } from "@internationalized/date";
|
|
12
|
-
function formatVisibleRange(ctx, isAria) {
|
|
13
|
-
if (!ctx.start)
|
|
14
|
-
return "";
|
|
15
|
-
const { start, end = start, timeZone } = ctx;
|
|
16
|
-
let monthFormatter = getMonthFormatter(ctx);
|
|
17
|
-
let dateFormatter = getDateFormatter(ctx);
|
|
18
|
-
if (!isSameDay(start, startOfMonth(start))) {
|
|
19
|
-
return isAria ? formatRange(ctx, dateFormatter) : dateFormatter.formatRange(start.toDate(timeZone), end.toDate(timeZone));
|
|
20
|
-
}
|
|
21
|
-
if (isSameDay(end, endOfMonth(start))) {
|
|
22
|
-
return monthFormatter.format(start.toDate(timeZone));
|
|
23
|
-
}
|
|
24
|
-
if (isSameDay(end, endOfMonth(end))) {
|
|
25
|
-
return isAria ? formatRange(ctx, monthFormatter) : monthFormatter.formatRange(start.toDate(timeZone), end.toDate(timeZone));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
2
|
+
formatVisibleRange
|
|
3
|
+
} from "./chunk-URPTPFL3.mjs";
|
|
4
|
+
import "./chunk-HKHGJ6WS.mjs";
|
|
5
|
+
import "./chunk-BBE325GQ.mjs";
|
|
28
6
|
export {
|
|
29
7
|
formatVisibleRange
|
|
30
8
|
};
|
package/dist/get-formatter.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as _internationalized_date from '@internationalized/date';
|
|
2
|
-
import {
|
|
2
|
+
import { CalendarDate } from '@internationalized/date';
|
|
3
|
+
import { G as GetFormatterFn } from './types-cbf8b45a.js';
|
|
3
4
|
|
|
4
|
-
declare function getDateFormatter(
|
|
5
|
-
declare function getMonthFormatter(
|
|
5
|
+
declare function getDateFormatter(startDate: CalendarDate, endDate: CalendarDate | null, getDateFormatter: GetFormatterFn, timeZone: string): _internationalized_date.DateFormatter;
|
|
6
|
+
declare function getMonthFormatter(startDate: CalendarDate, endDate: CalendarDate | null, getDateFormatter: GetFormatterFn, timeZone: string): _internationalized_date.DateFormatter;
|
|
6
7
|
|
|
7
8
|
export { getDateFormatter, getMonthFormatter };
|