@zag-js/date-utils 0.0.0-dev-20230107115230 → 0.0.0-dev-20230107162034
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
package/dist/index.mjs
CHANGED
|
@@ -1,34 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
addSegment,
|
|
3
3
|
setSegment
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import {
|
|
6
|
-
SEGMENT_PAGE_STEP,
|
|
7
|
-
isSegmentEditable
|
|
8
|
-
} from "./chunk-6NI2PIAA.mjs";
|
|
4
|
+
} from "./chunk-CAV5WKCZ.mjs";
|
|
9
5
|
import {
|
|
10
6
|
getSegmentLimits
|
|
11
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-L3YHK2WH.mjs";
|
|
12
8
|
import {
|
|
13
9
|
getMonthDates
|
|
14
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-HUBKWHIN.mjs";
|
|
15
11
|
import {
|
|
16
12
|
getDatesInWeek,
|
|
17
13
|
getWeekDates
|
|
18
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-JZVHAOWX.mjs";
|
|
19
15
|
import {
|
|
20
16
|
getYearsRange
|
|
21
17
|
} from "./chunk-TTJVXKJY.mjs";
|
|
22
18
|
import {
|
|
23
|
-
clampDate,
|
|
24
19
|
getNextDay,
|
|
20
|
+
getPreviousAvailableDate,
|
|
25
21
|
getPreviousDay,
|
|
26
22
|
getTodayDate,
|
|
27
23
|
setCalendar,
|
|
28
24
|
setDate,
|
|
29
25
|
setMonth,
|
|
30
26
|
setYear
|
|
31
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-ZZPZ2BFS.mjs";
|
|
32
28
|
import {
|
|
33
29
|
getNextPage,
|
|
34
30
|
getNextRow,
|
|
@@ -38,11 +34,15 @@ import {
|
|
|
38
34
|
getPreviousSection,
|
|
39
35
|
getSectionEnd,
|
|
40
36
|
getSectionStart
|
|
41
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-MY373KF2.mjs";
|
|
38
|
+
import {
|
|
39
|
+
SEGMENT_PAGE_STEP,
|
|
40
|
+
isSegmentEditable
|
|
41
|
+
} from "./chunk-6NI2PIAA.mjs";
|
|
42
42
|
import {
|
|
43
43
|
alignDate,
|
|
44
44
|
alignStartDate
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-BUT5IUNZ.mjs";
|
|
46
46
|
import {
|
|
47
47
|
isDateDisabled,
|
|
48
48
|
isDateEqual,
|
|
@@ -52,26 +52,28 @@ import {
|
|
|
52
52
|
isNextVisibleRangeInvalid,
|
|
53
53
|
isPreviousVisibleRangeInvalid,
|
|
54
54
|
isTodayDate
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-6EJZROXM.mjs";
|
|
56
56
|
import {
|
|
57
57
|
alignCenter,
|
|
58
58
|
alignEnd,
|
|
59
59
|
alignStart,
|
|
60
60
|
constrainStart,
|
|
61
61
|
constrainValue
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-MGPXEJO4.mjs";
|
|
63
63
|
import {
|
|
64
64
|
getEndDate,
|
|
65
65
|
getUnitDuration
|
|
66
66
|
} from "./chunk-ZSLC7OI2.mjs";
|
|
67
67
|
import {
|
|
68
68
|
formatSelectedDate
|
|
69
|
-
} from "./chunk-
|
|
70
|
-
import
|
|
69
|
+
} from "./chunk-GKU5M6QU.mjs";
|
|
70
|
+
import {
|
|
71
|
+
formatVisibleRange
|
|
72
|
+
} from "./chunk-URPTPFL3.mjs";
|
|
71
73
|
import {
|
|
72
74
|
formatRange
|
|
73
|
-
} from "./chunk-
|
|
74
|
-
import "./chunk-
|
|
75
|
+
} from "./chunk-HKHGJ6WS.mjs";
|
|
76
|
+
import "./chunk-BBE325GQ.mjs";
|
|
75
77
|
export {
|
|
76
78
|
SEGMENT_PAGE_STEP,
|
|
77
79
|
addSegment,
|
|
@@ -80,11 +82,11 @@ export {
|
|
|
80
82
|
alignEnd,
|
|
81
83
|
alignStart,
|
|
82
84
|
alignStartDate,
|
|
83
|
-
clampDate,
|
|
84
85
|
constrainStart,
|
|
85
86
|
constrainValue,
|
|
86
87
|
formatRange,
|
|
87
88
|
formatSelectedDate,
|
|
89
|
+
formatVisibleRange,
|
|
88
90
|
getDatesInWeek,
|
|
89
91
|
getEndDate,
|
|
90
92
|
getMonthDates,
|
|
@@ -92,6 +94,7 @@ export {
|
|
|
92
94
|
getNextPage,
|
|
93
95
|
getNextRow,
|
|
94
96
|
getNextSection,
|
|
97
|
+
getPreviousAvailableDate,
|
|
95
98
|
getPreviousDay,
|
|
96
99
|
getPreviousPage,
|
|
97
100
|
getPreviousRow,
|
package/dist/mutation.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { CalendarDate, Calendar } from '@internationalized/date';
|
|
2
|
-
import {
|
|
1
|
+
import { CalendarDate, Calendar, DateValue } from '@internationalized/date';
|
|
2
|
+
import { a as DateAvailableFn } from './types-cbf8b45a.js';
|
|
3
3
|
|
|
4
|
-
declare function clampDate(ctx: DateContext, date: CalendarDate): CalendarDate;
|
|
5
4
|
declare function getTodayDate(timezone: string): CalendarDate;
|
|
6
5
|
declare function getNextDay(date: CalendarDate): CalendarDate;
|
|
7
6
|
declare function getPreviousDay(date: CalendarDate): CalendarDate;
|
|
8
7
|
declare function setMonth(date: CalendarDate, month: number): CalendarDate;
|
|
9
8
|
declare function setYear(date: CalendarDate, year: number): CalendarDate;
|
|
10
9
|
declare function setCalendar(date: CalendarDate, calendar: Calendar): CalendarDate;
|
|
11
|
-
declare function setDate(
|
|
10
|
+
declare function setDate(date: CalendarDate, startDate: CalendarDate, isDateUnavailable: DateAvailableFn, minValue: CalendarDate, maxValue: CalendarDate): CalendarDate | undefined;
|
|
11
|
+
declare function getPreviousAvailableDate(date: CalendarDate, minValue: DateValue, isDateUnavailable?: DateAvailableFn): CalendarDate | undefined;
|
|
12
12
|
|
|
13
|
-
export {
|
|
13
|
+
export { getNextDay, getPreviousAvailableDate, getPreviousDay, getTodayDate, setCalendar, setDate, setMonth, setYear };
|
package/dist/mutation.js
CHANGED
|
@@ -20,8 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/mutation.ts
|
|
21
21
|
var mutation_exports = {};
|
|
22
22
|
__export(mutation_exports, {
|
|
23
|
-
clampDate: () => clampDate,
|
|
24
23
|
getNextDay: () => getNextDay,
|
|
24
|
+
getPreviousAvailableDate: () => getPreviousAvailableDate,
|
|
25
25
|
getPreviousDay: () => getPreviousDay,
|
|
26
26
|
getTodayDate: () => getTodayDate,
|
|
27
27
|
setCalendar: () => setCalendar,
|
|
@@ -30,43 +30,23 @@ __export(mutation_exports, {
|
|
|
30
30
|
setYear: () => setYear
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(mutation_exports);
|
|
33
|
-
var
|
|
33
|
+
var import_date2 = require("@internationalized/date");
|
|
34
34
|
|
|
35
35
|
// src/constrain.ts
|
|
36
36
|
var import_date = require("@internationalized/date");
|
|
37
|
-
function constrainValue(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
date = (0, import_date.maxDate)(date, (0, import_date.toCalendarDate)(min));
|
|
37
|
+
function constrainValue(date, minValue, maxValue) {
|
|
38
|
+
if (minValue) {
|
|
39
|
+
date = (0, import_date.maxDate)(date, (0, import_date.toCalendarDate)(minValue));
|
|
41
40
|
}
|
|
42
|
-
if (
|
|
43
|
-
date = (0, import_date.minDate)(date, (0, import_date.toCalendarDate)(
|
|
41
|
+
if (maxValue) {
|
|
42
|
+
date = (0, import_date.minDate)(date, (0, import_date.toCalendarDate)(maxValue));
|
|
44
43
|
}
|
|
45
44
|
return date;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
// src/assertion.ts
|
|
49
|
-
var import_date2 = require("@internationalized/date");
|
|
50
|
-
function isDateInvalid(ctx, date) {
|
|
51
|
-
return ctx.min != null && date.compare(ctx.min) < 0 || ctx.max != null && date.compare(ctx.max) > 0;
|
|
52
|
-
}
|
|
53
|
-
function isDateUnavailable(ctx, date) {
|
|
54
|
-
var _a;
|
|
55
|
-
if (!date) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
if ((_a = ctx.isUnavailable) == null ? void 0 : _a.call(ctx, date)) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
return isDateInvalid(ctx, date);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
47
|
// src/mutation.ts
|
|
65
|
-
function clampDate(ctx, date) {
|
|
66
|
-
return constrainValue(ctx, date);
|
|
67
|
-
}
|
|
68
48
|
function getTodayDate(timezone) {
|
|
69
|
-
return (0,
|
|
49
|
+
return (0, import_date2.today)(timezone);
|
|
70
50
|
}
|
|
71
51
|
function getNextDay(date) {
|
|
72
52
|
return date.add({ days: 1 });
|
|
@@ -81,26 +61,19 @@ function setYear(date, year) {
|
|
|
81
61
|
return date.set({ year });
|
|
82
62
|
}
|
|
83
63
|
function setCalendar(date, calendar) {
|
|
84
|
-
return (0,
|
|
64
|
+
return (0, import_date2.toCalendar)((0, import_date2.toCalendarDate)(date), calendar);
|
|
85
65
|
}
|
|
86
|
-
function setDate(
|
|
66
|
+
function setDate(date, startDate, isDateUnavailable, minValue, maxValue) {
|
|
87
67
|
let result;
|
|
88
|
-
result =
|
|
89
|
-
result = getPreviousAvailableDate(
|
|
90
|
-
if (!result)
|
|
91
|
-
return;
|
|
92
|
-
result = (0, import_date3.toCalendar)(result, (date == null ? void 0 : date.calendar) || new import_date3.GregorianCalendar());
|
|
93
|
-
if (date && "hour" in date) {
|
|
94
|
-
return date.set(result);
|
|
95
|
-
}
|
|
68
|
+
result = constrainValue(date, minValue, maxValue);
|
|
69
|
+
result = getPreviousAvailableDate(date, startDate, isDateUnavailable);
|
|
96
70
|
return result;
|
|
97
71
|
}
|
|
98
|
-
function getPreviousAvailableDate(
|
|
99
|
-
|
|
100
|
-
if (!isDateUnavailable(ctx, date) || !minValue) {
|
|
72
|
+
function getPreviousAvailableDate(date, minValue, isDateUnavailable) {
|
|
73
|
+
if (!isDateUnavailable) {
|
|
101
74
|
return date;
|
|
102
75
|
}
|
|
103
|
-
while (date.compare(minValue) >= 0 && isDateUnavailable(
|
|
76
|
+
while (date.compare(minValue) >= 0 && isDateUnavailable(date)) {
|
|
104
77
|
date = date.subtract({ days: 1 });
|
|
105
78
|
}
|
|
106
79
|
if (date.compare(minValue) >= 0) {
|
|
@@ -109,8 +82,8 @@ function getPreviousAvailableDate(ctx, date, min) {
|
|
|
109
82
|
}
|
|
110
83
|
// Annotate the CommonJS export names for ESM import in node:
|
|
111
84
|
0 && (module.exports = {
|
|
112
|
-
clampDate,
|
|
113
85
|
getNextDay,
|
|
86
|
+
getPreviousAvailableDate,
|
|
114
87
|
getPreviousDay,
|
|
115
88
|
getTodayDate,
|
|
116
89
|
setCalendar,
|
package/dist/mutation.mjs
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
-
clampDate,
|
|
3
2
|
getNextDay,
|
|
3
|
+
getPreviousAvailableDate,
|
|
4
4
|
getPreviousDay,
|
|
5
5
|
getTodayDate,
|
|
6
6
|
setCalendar,
|
|
7
7
|
setDate,
|
|
8
8
|
setMonth,
|
|
9
9
|
setYear
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-HP2COJGP.mjs";
|
|
10
|
+
} from "./chunk-ZZPZ2BFS.mjs";
|
|
11
|
+
import "./chunk-MGPXEJO4.mjs";
|
|
13
12
|
export {
|
|
14
|
-
clampDate,
|
|
15
13
|
getNextDay,
|
|
14
|
+
getPreviousAvailableDate,
|
|
16
15
|
getPreviousDay,
|
|
17
16
|
getTodayDate,
|
|
18
17
|
setCalendar,
|
package/dist/pagination.d.ts
CHANGED
|
@@ -1,25 +1,44 @@
|
|
|
1
|
-
import { CalendarDate } from '@internationalized/date';
|
|
2
|
-
import { D as DateContext } from './types-9f60d2f1.js';
|
|
1
|
+
import { CalendarDate, DateDuration } from '@internationalized/date';
|
|
3
2
|
|
|
4
|
-
declare function getNextPage(
|
|
3
|
+
declare function getNextPage(focusedDate: CalendarDate, startDate: CalendarDate, visibleDuration: DateDuration, locale: string, minValue: CalendarDate, maxValue: CalendarDate): {
|
|
5
4
|
startDate: CalendarDate;
|
|
6
5
|
focusedDate: CalendarDate;
|
|
6
|
+
endDate: CalendarDate;
|
|
7
7
|
};
|
|
8
|
-
declare function getPreviousPage(
|
|
8
|
+
declare function getPreviousPage(focusedDate: CalendarDate, startDate: CalendarDate, visibleDuration: DateDuration, locale: string, minValue: CalendarDate, maxValue: CalendarDate): {
|
|
9
9
|
startDate: CalendarDate;
|
|
10
10
|
focusedDate: CalendarDate;
|
|
11
|
+
endDate: CalendarDate;
|
|
11
12
|
};
|
|
12
|
-
declare function
|
|
13
|
-
declare function getSectionEnd(ctx: DateContext, date: CalendarDate, endDate: CalendarDate): CalendarDate | undefined;
|
|
14
|
-
declare function getNextSection(ctx: DateContext, date: CalendarDate, larger?: boolean): CalendarDate | undefined;
|
|
15
|
-
declare function getPreviousSection(ctx: DateContext, date: CalendarDate, larger?: boolean): CalendarDate | undefined;
|
|
16
|
-
declare function getNextRow(ctx: DateContext, date: CalendarDate, startDate: CalendarDate): CalendarDate | {
|
|
13
|
+
declare function getNextRow(focusedDate: CalendarDate, startDate: CalendarDate, visibleDuration: DateDuration, locale: string, minValue: CalendarDate, maxValue: CalendarDate): {
|
|
17
14
|
startDate: CalendarDate;
|
|
18
15
|
focusedDate: CalendarDate;
|
|
16
|
+
endDate: CalendarDate;
|
|
19
17
|
} | undefined;
|
|
20
|
-
declare function getPreviousRow(
|
|
18
|
+
declare function getPreviousRow(focusedDate: CalendarDate, startDate: CalendarDate, visibleDuration: DateDuration, locale: string, minValue: CalendarDate, maxValue: CalendarDate): {
|
|
21
19
|
startDate: CalendarDate;
|
|
22
20
|
focusedDate: CalendarDate;
|
|
21
|
+
endDate: CalendarDate;
|
|
22
|
+
} | undefined;
|
|
23
|
+
declare function getSectionStart(focusedDate: CalendarDate, startDate: CalendarDate, visibleDuration: DateDuration, locale: string, minValue: CalendarDate, maxValue: CalendarDate): {
|
|
24
|
+
startDate: CalendarDate;
|
|
25
|
+
focusedDate: CalendarDate;
|
|
26
|
+
endDate: CalendarDate;
|
|
27
|
+
} | undefined;
|
|
28
|
+
declare function getSectionEnd(focusedDate: CalendarDate, startDate: CalendarDate, visibleDuration: DateDuration, locale: string, minValue: CalendarDate, maxValue: CalendarDate): {
|
|
29
|
+
startDate: CalendarDate;
|
|
30
|
+
focusedDate: CalendarDate;
|
|
31
|
+
endDate: CalendarDate;
|
|
32
|
+
} | undefined;
|
|
33
|
+
declare function getNextSection(focusedDate: CalendarDate, startDate: CalendarDate, larger: boolean, visibleDuration: DateDuration, locale: string, minValue: CalendarDate, maxValue: CalendarDate): {
|
|
34
|
+
startDate: CalendarDate;
|
|
35
|
+
focusedDate: CalendarDate;
|
|
36
|
+
endDate: CalendarDate;
|
|
37
|
+
} | undefined;
|
|
38
|
+
declare function getPreviousSection(focusedDate: CalendarDate, startDate: CalendarDate, larger: boolean, visibleDuration: DateDuration, locale: string, minValue: CalendarDate, maxValue: CalendarDate): {
|
|
39
|
+
startDate: CalendarDate;
|
|
40
|
+
focusedDate: CalendarDate;
|
|
41
|
+
endDate: CalendarDate;
|
|
23
42
|
} | undefined;
|
|
24
43
|
|
|
25
44
|
export { getNextPage, getNextRow, getNextSection, getPreviousPage, getPreviousRow, getPreviousSection, getSectionEnd, getSectionStart };
|
package/dist/pagination.js
CHANGED
|
@@ -30,24 +30,28 @@ __export(pagination_exports, {
|
|
|
30
30
|
getSectionStart: () => getSectionStart
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(pagination_exports);
|
|
33
|
-
var
|
|
33
|
+
var import_date3 = require("@internationalized/date");
|
|
34
34
|
|
|
35
|
-
// src/
|
|
35
|
+
// src/assertion.ts
|
|
36
36
|
var import_date = require("@internationalized/date");
|
|
37
|
-
function
|
|
38
|
-
|
|
37
|
+
function isDateInvalid(date, minValue, maxValue) {
|
|
38
|
+
return minValue != null && date.compare(minValue) < 0 || maxValue != null && date.compare(maxValue) > 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/constrain.ts
|
|
42
|
+
var import_date2 = require("@internationalized/date");
|
|
43
|
+
function alignStart(date, duration, locale, min, max) {
|
|
39
44
|
let aligned = date;
|
|
40
45
|
if (duration.years) {
|
|
41
|
-
aligned = (0,
|
|
46
|
+
aligned = (0, import_date2.startOfYear)(date);
|
|
42
47
|
} else if (duration.months) {
|
|
43
|
-
aligned = (0,
|
|
48
|
+
aligned = (0, import_date2.startOfMonth)(date);
|
|
44
49
|
} else if (duration.weeks) {
|
|
45
|
-
aligned = (0,
|
|
50
|
+
aligned = (0, import_date2.startOfWeek)(date, locale);
|
|
46
51
|
}
|
|
47
|
-
return constrainStart(
|
|
52
|
+
return constrainStart(date, aligned, duration, locale, min, max);
|
|
48
53
|
}
|
|
49
|
-
function alignEnd(
|
|
50
|
-
const { duration } = ctx;
|
|
54
|
+
function alignEnd(date, duration, locale, min, max) {
|
|
51
55
|
let d = { ...duration };
|
|
52
56
|
if (d.days) {
|
|
53
57
|
d.days--;
|
|
@@ -58,29 +62,27 @@ function alignEnd(ctx, date) {
|
|
|
58
62
|
} else if (d.years) {
|
|
59
63
|
d.years--;
|
|
60
64
|
}
|
|
61
|
-
let aligned = alignStart(
|
|
62
|
-
return constrainStart(
|
|
63
|
-
}
|
|
64
|
-
function constrainValue(ctx, date) {
|
|
65
|
-
let { min, max } = ctx;
|
|
66
|
-
if (min) {
|
|
67
|
-
date = (0, import_date.maxDate)(date, (0, import_date.toCalendarDate)(min));
|
|
68
|
-
}
|
|
69
|
-
if (max) {
|
|
70
|
-
date = (0, import_date.minDate)(date, (0, import_date.toCalendarDate)(max));
|
|
71
|
-
}
|
|
72
|
-
return date;
|
|
65
|
+
let aligned = alignStart(date, duration, locale).subtract(d);
|
|
66
|
+
return constrainStart(date, aligned, duration, locale, min, max);
|
|
73
67
|
}
|
|
74
|
-
function constrainStart(
|
|
75
|
-
let { min, max } = ctx;
|
|
68
|
+
function constrainStart(date, aligned, duration, locale, min, max) {
|
|
76
69
|
if (min && date.compare(min) >= 0) {
|
|
77
|
-
aligned = (0,
|
|
70
|
+
aligned = (0, import_date2.maxDate)(aligned, alignStart((0, import_date2.toCalendarDate)(min), duration, locale));
|
|
78
71
|
}
|
|
79
72
|
if (max && date.compare(max) <= 0) {
|
|
80
|
-
aligned = (0,
|
|
73
|
+
aligned = (0, import_date2.minDate)(aligned, alignEnd((0, import_date2.toCalendarDate)(max), duration, locale));
|
|
81
74
|
}
|
|
82
75
|
return aligned;
|
|
83
76
|
}
|
|
77
|
+
function constrainValue(date, minValue, maxValue) {
|
|
78
|
+
if (minValue) {
|
|
79
|
+
date = (0, import_date2.maxDate)(date, (0, import_date2.toCalendarDate)(minValue));
|
|
80
|
+
}
|
|
81
|
+
if (maxValue) {
|
|
82
|
+
date = (0, import_date2.minDate)(date, (0, import_date2.toCalendarDate)(maxValue));
|
|
83
|
+
}
|
|
84
|
+
return date;
|
|
85
|
+
}
|
|
84
86
|
|
|
85
87
|
// src/duration.ts
|
|
86
88
|
function getUnitDuration(duration) {
|
|
@@ -90,94 +92,186 @@ function getUnitDuration(duration) {
|
|
|
90
92
|
}
|
|
91
93
|
return d;
|
|
92
94
|
}
|
|
95
|
+
function getEndDate(startDate, duration) {
|
|
96
|
+
let d = { ...duration };
|
|
97
|
+
if (d.days) {
|
|
98
|
+
d.days--;
|
|
99
|
+
} else {
|
|
100
|
+
d.days = -1;
|
|
101
|
+
}
|
|
102
|
+
return startDate.add(d);
|
|
103
|
+
}
|
|
93
104
|
|
|
94
105
|
// src/pagination.ts
|
|
95
|
-
function
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
function getAdjustedDateFn(visibleDuration, locale, minValue, maxValue) {
|
|
107
|
+
return function getDate(options) {
|
|
108
|
+
const { startDate, focusedDate } = options;
|
|
109
|
+
const endDate = getEndDate(startDate, visibleDuration);
|
|
110
|
+
if (isDateInvalid(focusedDate, minValue, maxValue)) {
|
|
111
|
+
return {
|
|
112
|
+
startDate,
|
|
113
|
+
focusedDate: constrainValue(focusedDate, minValue, maxValue),
|
|
114
|
+
endDate
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
if (focusedDate.compare(startDate) < 0) {
|
|
118
|
+
return {
|
|
119
|
+
startDate: alignEnd(focusedDate, visibleDuration, locale, minValue, maxValue),
|
|
120
|
+
endDate,
|
|
121
|
+
focusedDate: constrainValue(focusedDate, minValue, maxValue)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (focusedDate.compare(endDate) > 0) {
|
|
125
|
+
return {
|
|
126
|
+
startDate: alignStart(focusedDate, visibleDuration, locale, minValue, maxValue),
|
|
127
|
+
endDate,
|
|
128
|
+
focusedDate: constrainValue(focusedDate, minValue, maxValue)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
startDate,
|
|
133
|
+
endDate,
|
|
134
|
+
focusedDate: constrainValue(focusedDate, minValue, maxValue)
|
|
135
|
+
};
|
|
100
136
|
};
|
|
101
137
|
}
|
|
102
|
-
function
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
focusedDate:
|
|
107
|
-
|
|
138
|
+
function getNextPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
139
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
140
|
+
const start = startDate.add(visibleDuration);
|
|
141
|
+
return adjust({
|
|
142
|
+
focusedDate: focusedDate.add(visibleDuration),
|
|
143
|
+
startDate: alignStart(
|
|
144
|
+
constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue),
|
|
145
|
+
visibleDuration,
|
|
146
|
+
locale
|
|
147
|
+
)
|
|
148
|
+
});
|
|
108
149
|
}
|
|
109
|
-
function
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
150
|
+
function getPreviousPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
151
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
152
|
+
let start = startDate.subtract(visibleDuration);
|
|
153
|
+
return adjust({
|
|
154
|
+
focusedDate: focusedDate.subtract(visibleDuration),
|
|
155
|
+
startDate: alignStart(
|
|
156
|
+
constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue),
|
|
157
|
+
visibleDuration,
|
|
158
|
+
locale
|
|
159
|
+
)
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function getNextRow(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
163
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
164
|
+
if (visibleDuration.days) {
|
|
165
|
+
return getNextPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue);
|
|
113
166
|
}
|
|
114
|
-
if (
|
|
115
|
-
return (
|
|
167
|
+
if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years) {
|
|
168
|
+
return adjust({
|
|
169
|
+
focusedDate: focusedDate.add({ weeks: 1 }),
|
|
170
|
+
startDate
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function getPreviousRow(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
175
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
176
|
+
if (visibleDuration.days) {
|
|
177
|
+
return getPreviousPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue);
|
|
116
178
|
}
|
|
117
|
-
if (
|
|
118
|
-
return (
|
|
179
|
+
if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years) {
|
|
180
|
+
return adjust({
|
|
181
|
+
focusedDate: focusedDate.subtract({ weeks: 1 }),
|
|
182
|
+
startDate
|
|
183
|
+
});
|
|
119
184
|
}
|
|
120
185
|
}
|
|
121
|
-
function
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
124
|
-
return
|
|
186
|
+
function getSectionStart(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
187
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
188
|
+
if (visibleDuration.days) {
|
|
189
|
+
return adjust({
|
|
190
|
+
focusedDate: startDate,
|
|
191
|
+
startDate
|
|
192
|
+
});
|
|
125
193
|
}
|
|
126
|
-
if (
|
|
127
|
-
return (
|
|
194
|
+
if (visibleDuration.weeks) {
|
|
195
|
+
return adjust({
|
|
196
|
+
focusedDate: (0, import_date3.startOfWeek)(focusedDate, locale),
|
|
197
|
+
startDate
|
|
198
|
+
});
|
|
128
199
|
}
|
|
129
|
-
if (
|
|
130
|
-
return (
|
|
200
|
+
if (visibleDuration.months || visibleDuration.years) {
|
|
201
|
+
return adjust({
|
|
202
|
+
focusedDate: (0, import_date3.startOfMonth)(focusedDate),
|
|
203
|
+
startDate
|
|
204
|
+
});
|
|
131
205
|
}
|
|
132
206
|
}
|
|
133
|
-
function
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
137
|
-
return
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
207
|
+
function getSectionEnd(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
208
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
209
|
+
const endDate = getEndDate(startDate, visibleDuration);
|
|
210
|
+
if (visibleDuration.days) {
|
|
211
|
+
return adjust({
|
|
212
|
+
focusedDate: endDate,
|
|
213
|
+
startDate
|
|
214
|
+
});
|
|
141
215
|
}
|
|
142
|
-
if (
|
|
143
|
-
return
|
|
216
|
+
if (visibleDuration.weeks) {
|
|
217
|
+
return adjust({
|
|
218
|
+
focusedDate: (0, import_date3.endOfWeek)(focusedDate, locale),
|
|
219
|
+
startDate
|
|
220
|
+
});
|
|
144
221
|
}
|
|
145
|
-
if (
|
|
146
|
-
return
|
|
222
|
+
if (visibleDuration.months || visibleDuration.years) {
|
|
223
|
+
return adjust({
|
|
224
|
+
focusedDate: (0, import_date3.endOfMonth)(focusedDate),
|
|
225
|
+
startDate
|
|
226
|
+
});
|
|
147
227
|
}
|
|
148
228
|
}
|
|
149
|
-
function
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
229
|
+
function getNextSection(focusedDate, startDate, larger, visibleDuration, locale, minValue, maxValue) {
|
|
230
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
231
|
+
if (!larger && !visibleDuration.days) {
|
|
232
|
+
return adjust({
|
|
233
|
+
focusedDate: focusedDate.add(getUnitDuration(visibleDuration)),
|
|
234
|
+
startDate
|
|
235
|
+
});
|
|
154
236
|
}
|
|
155
|
-
if (
|
|
156
|
-
return
|
|
237
|
+
if (visibleDuration.days) {
|
|
238
|
+
return getNextPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue);
|
|
157
239
|
}
|
|
158
|
-
if (
|
|
159
|
-
return
|
|
240
|
+
if (visibleDuration.weeks) {
|
|
241
|
+
return adjust({
|
|
242
|
+
focusedDate: focusedDate.add({ months: 1 }),
|
|
243
|
+
startDate
|
|
244
|
+
});
|
|
160
245
|
}
|
|
161
|
-
if (
|
|
162
|
-
return
|
|
246
|
+
if (visibleDuration.months || visibleDuration.years) {
|
|
247
|
+
return adjust({
|
|
248
|
+
focusedDate: focusedDate.add({ years: 1 }),
|
|
249
|
+
startDate
|
|
250
|
+
});
|
|
163
251
|
}
|
|
164
252
|
}
|
|
165
|
-
function
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
168
|
-
return
|
|
253
|
+
function getPreviousSection(focusedDate, startDate, larger, visibleDuration, locale, minValue, maxValue) {
|
|
254
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
255
|
+
if (!larger && !visibleDuration.days) {
|
|
256
|
+
return adjust({
|
|
257
|
+
focusedDate: focusedDate.subtract(getUnitDuration(visibleDuration)),
|
|
258
|
+
startDate
|
|
259
|
+
});
|
|
169
260
|
}
|
|
170
|
-
if (
|
|
171
|
-
return
|
|
261
|
+
if (visibleDuration.days) {
|
|
262
|
+
return getPreviousPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue);
|
|
172
263
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
264
|
+
if (visibleDuration.weeks) {
|
|
265
|
+
return adjust({
|
|
266
|
+
focusedDate: focusedDate.subtract({ months: 1 }),
|
|
267
|
+
startDate
|
|
268
|
+
});
|
|
178
269
|
}
|
|
179
|
-
if (
|
|
180
|
-
return
|
|
270
|
+
if (visibleDuration.months || visibleDuration.years) {
|
|
271
|
+
return adjust({
|
|
272
|
+
focusedDate: focusedDate.subtract({ years: 1 }),
|
|
273
|
+
startDate
|
|
274
|
+
});
|
|
181
275
|
}
|
|
182
276
|
}
|
|
183
277
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/pagination.mjs
CHANGED
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
getPreviousSection,
|
|
8
8
|
getSectionEnd,
|
|
9
9
|
getSectionStart
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-MY373KF2.mjs";
|
|
11
|
+
import "./chunk-6EJZROXM.mjs";
|
|
12
|
+
import "./chunk-MGPXEJO4.mjs";
|
|
12
13
|
import "./chunk-ZSLC7OI2.mjs";
|
|
13
14
|
export {
|
|
14
15
|
getNextPage,
|
package/dist/placeholder.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _internationalized_date from '@internationalized/date';
|
|
2
|
-
import {
|
|
2
|
+
import { b as DateGranularity } from './types-cbf8b45a.js';
|
|
3
3
|
|
|
4
4
|
declare function getTodayPlaceholderDate(timeZone: string): _internationalized_date.ZonedDateTime;
|
|
5
5
|
declare function createPlaceholderDate(granularity: DateGranularity, timeZone: string): _internationalized_date.CalendarDate | _internationalized_date.ZonedDateTime;
|