@zag-js/date-utils 0.0.0-dev-20230107115230
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 +19 -0
- package/dist/align.d.ts +7 -0
- package/dist/align.js +105 -0
- package/dist/align.mjs +9 -0
- package/dist/assertion.d.ts +13 -0
- package/dist/assertion.js +77 -0
- package/dist/assertion.mjs +20 -0
- package/dist/chunk-2DZ3KIVJ.mjs +73 -0
- package/dist/chunk-6NI2PIAA.mjs +27 -0
- package/dist/chunk-6XKXGQP6.mjs +32 -0
- package/dist/chunk-7JERMWT3.mjs +46 -0
- package/dist/chunk-C4U2N3JC.mjs +65 -0
- package/dist/chunk-DI2YG6VG.mjs +24 -0
- package/dist/chunk-ECAENYV6.mjs +19 -0
- package/dist/chunk-EXWX3KZT.mjs +64 -0
- package/dist/chunk-FJMTHABG.mjs +8 -0
- package/dist/chunk-HP2COJGP.mjs +76 -0
- package/dist/chunk-M4F23P2U.mjs +35 -0
- package/dist/chunk-TCPXGBJP.mjs +33 -0
- package/dist/chunk-TTJVXKJY.mjs +12 -0
- package/dist/chunk-VWVBJ5CB.mjs +110 -0
- package/dist/chunk-XHAL6X5Z.mjs +27 -0
- package/dist/chunk-ZSLC7OI2.mjs +22 -0
- package/dist/constrain.d.ts +10 -0
- package/dist/constrain.js +97 -0
- package/dist/constrain.mjs +14 -0
- package/dist/duration.d.ts +11 -0
- package/dist/duration.js +47 -0
- package/dist/duration.mjs +8 -0
- package/dist/format-range.d.ts +6 -0
- package/dist/format-range.js +51 -0
- package/dist/format-range.mjs +6 -0
- package/dist/format-selected-date.d.ts +6 -0
- package/dist/format-selected-date.js +86 -0
- package/dist/format-selected-date.mjs +9 -0
- package/dist/format-visible-range.d.ts +6 -0
- package/dist/format-visible-range.js +102 -0
- package/dist/format-visible-range.mjs +30 -0
- package/dist/get-era-format.d.ts +5 -0
- package/dist/get-era-format.js +32 -0
- package/dist/get-era-format.mjs +6 -0
- package/dist/get-formatter.d.ts +7 -0
- package/dist/get-formatter.js +61 -0
- package/dist/get-formatter.mjs +9 -0
- package/dist/get-month-dates.d.ts +5 -0
- package/dist/get-month-dates.js +65 -0
- package/dist/get-month-dates.mjs +7 -0
- package/dist/get-week-dates.d.ts +7 -0
- package/dist/get-week-dates.js +60 -0
- package/dist/get-week-dates.mjs +8 -0
- package/dist/get-year-range.d.ts +7 -0
- package/dist/get-year-range.js +36 -0
- package/dist/get-year-range.mjs +6 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +656 -0
- package/dist/index.mjs +120 -0
- package/dist/mutation.d.ts +13 -0
- package/dist/mutation.js +120 -0
- package/dist/mutation.mjs +22 -0
- package/dist/pagination.d.ts +25 -0
- package/dist/pagination.js +193 -0
- package/dist/pagination.mjs +22 -0
- package/dist/placeholder.d.ts +7 -0
- package/dist/placeholder.js +47 -0
- package/dist/placeholder.mjs +21 -0
- package/dist/segment-constants.d.ts +2 -0
- package/dist/segment-constants.js +52 -0
- package/dist/segment-constants.mjs +8 -0
- package/dist/segment-limit.d.ts +14 -0
- package/dist/segment-limit.js +97 -0
- package/dist/segment-limit.mjs +6 -0
- package/dist/segment-mutation.d.ts +8 -0
- package/dist/segment-mutation.js +89 -0
- package/dist/segment-mutation.mjs +8 -0
- package/dist/segment-parts.d.ts +25 -0
- package/dist/segment-parts.js +143 -0
- package/dist/segment-parts.mjs +37 -0
- package/dist/types-9f60d2f1.d.ts +61 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.js +18 -0
- package/dist/types.mjs +0 -0
- package/package.json +53 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addSegment,
|
|
3
|
+
setSegment
|
|
4
|
+
} from "./chunk-EXWX3KZT.mjs";
|
|
5
|
+
import {
|
|
6
|
+
SEGMENT_PAGE_STEP,
|
|
7
|
+
isSegmentEditable
|
|
8
|
+
} from "./chunk-6NI2PIAA.mjs";
|
|
9
|
+
import {
|
|
10
|
+
getSegmentLimits
|
|
11
|
+
} from "./chunk-2DZ3KIVJ.mjs";
|
|
12
|
+
import {
|
|
13
|
+
getMonthDates
|
|
14
|
+
} from "./chunk-ECAENYV6.mjs";
|
|
15
|
+
import {
|
|
16
|
+
getDatesInWeek,
|
|
17
|
+
getWeekDates
|
|
18
|
+
} from "./chunk-M4F23P2U.mjs";
|
|
19
|
+
import {
|
|
20
|
+
getYearsRange
|
|
21
|
+
} from "./chunk-TTJVXKJY.mjs";
|
|
22
|
+
import {
|
|
23
|
+
clampDate,
|
|
24
|
+
getNextDay,
|
|
25
|
+
getPreviousDay,
|
|
26
|
+
getTodayDate,
|
|
27
|
+
setCalendar,
|
|
28
|
+
setDate,
|
|
29
|
+
setMonth,
|
|
30
|
+
setYear
|
|
31
|
+
} from "./chunk-C4U2N3JC.mjs";
|
|
32
|
+
import {
|
|
33
|
+
getNextPage,
|
|
34
|
+
getNextRow,
|
|
35
|
+
getNextSection,
|
|
36
|
+
getPreviousPage,
|
|
37
|
+
getPreviousRow,
|
|
38
|
+
getPreviousSection,
|
|
39
|
+
getSectionEnd,
|
|
40
|
+
getSectionStart
|
|
41
|
+
} from "./chunk-VWVBJ5CB.mjs";
|
|
42
|
+
import {
|
|
43
|
+
alignDate,
|
|
44
|
+
alignStartDate
|
|
45
|
+
} from "./chunk-6XKXGQP6.mjs";
|
|
46
|
+
import {
|
|
47
|
+
isDateDisabled,
|
|
48
|
+
isDateEqual,
|
|
49
|
+
isDateInvalid,
|
|
50
|
+
isDateOutsideVisibleRange,
|
|
51
|
+
isDateUnavailable,
|
|
52
|
+
isNextVisibleRangeInvalid,
|
|
53
|
+
isPreviousVisibleRangeInvalid,
|
|
54
|
+
isTodayDate
|
|
55
|
+
} from "./chunk-7JERMWT3.mjs";
|
|
56
|
+
import {
|
|
57
|
+
alignCenter,
|
|
58
|
+
alignEnd,
|
|
59
|
+
alignStart,
|
|
60
|
+
constrainStart,
|
|
61
|
+
constrainValue
|
|
62
|
+
} from "./chunk-HP2COJGP.mjs";
|
|
63
|
+
import {
|
|
64
|
+
getEndDate,
|
|
65
|
+
getUnitDuration
|
|
66
|
+
} from "./chunk-ZSLC7OI2.mjs";
|
|
67
|
+
import {
|
|
68
|
+
formatSelectedDate
|
|
69
|
+
} from "./chunk-DI2YG6VG.mjs";
|
|
70
|
+
import "./chunk-TCPXGBJP.mjs";
|
|
71
|
+
import {
|
|
72
|
+
formatRange
|
|
73
|
+
} from "./chunk-XHAL6X5Z.mjs";
|
|
74
|
+
import "./chunk-FJMTHABG.mjs";
|
|
75
|
+
export {
|
|
76
|
+
SEGMENT_PAGE_STEP,
|
|
77
|
+
addSegment,
|
|
78
|
+
alignCenter,
|
|
79
|
+
alignDate,
|
|
80
|
+
alignEnd,
|
|
81
|
+
alignStart,
|
|
82
|
+
alignStartDate,
|
|
83
|
+
clampDate,
|
|
84
|
+
constrainStart,
|
|
85
|
+
constrainValue,
|
|
86
|
+
formatRange,
|
|
87
|
+
formatSelectedDate,
|
|
88
|
+
getDatesInWeek,
|
|
89
|
+
getEndDate,
|
|
90
|
+
getMonthDates,
|
|
91
|
+
getNextDay,
|
|
92
|
+
getNextPage,
|
|
93
|
+
getNextRow,
|
|
94
|
+
getNextSection,
|
|
95
|
+
getPreviousDay,
|
|
96
|
+
getPreviousPage,
|
|
97
|
+
getPreviousRow,
|
|
98
|
+
getPreviousSection,
|
|
99
|
+
getSectionEnd,
|
|
100
|
+
getSectionStart,
|
|
101
|
+
getSegmentLimits,
|
|
102
|
+
getTodayDate,
|
|
103
|
+
getUnitDuration,
|
|
104
|
+
getWeekDates,
|
|
105
|
+
getYearsRange,
|
|
106
|
+
isDateDisabled,
|
|
107
|
+
isDateEqual,
|
|
108
|
+
isDateInvalid,
|
|
109
|
+
isDateOutsideVisibleRange,
|
|
110
|
+
isDateUnavailable,
|
|
111
|
+
isNextVisibleRangeInvalid,
|
|
112
|
+
isPreviousVisibleRangeInvalid,
|
|
113
|
+
isSegmentEditable,
|
|
114
|
+
isTodayDate,
|
|
115
|
+
setCalendar,
|
|
116
|
+
setDate,
|
|
117
|
+
setMonth,
|
|
118
|
+
setSegment,
|
|
119
|
+
setYear
|
|
120
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CalendarDate, Calendar } from '@internationalized/date';
|
|
2
|
+
import { D as DateContext } from './types-9f60d2f1.js';
|
|
3
|
+
|
|
4
|
+
declare function clampDate(ctx: DateContext, date: CalendarDate): CalendarDate;
|
|
5
|
+
declare function getTodayDate(timezone: string): CalendarDate;
|
|
6
|
+
declare function getNextDay(date: CalendarDate): CalendarDate;
|
|
7
|
+
declare function getPreviousDay(date: CalendarDate): CalendarDate;
|
|
8
|
+
declare function setMonth(date: CalendarDate, month: number): CalendarDate;
|
|
9
|
+
declare function setYear(date: CalendarDate, year: number): CalendarDate;
|
|
10
|
+
declare function setCalendar(date: CalendarDate, calendar: Calendar): CalendarDate;
|
|
11
|
+
declare function setDate(ctx: DateContext, date: CalendarDate, nextDate: CalendarDate, startDate: CalendarDate): CalendarDate | undefined;
|
|
12
|
+
|
|
13
|
+
export { clampDate, getNextDay, getPreviousDay, getTodayDate, setCalendar, setDate, setMonth, setYear };
|
package/dist/mutation.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/mutation.ts
|
|
21
|
+
var mutation_exports = {};
|
|
22
|
+
__export(mutation_exports, {
|
|
23
|
+
clampDate: () => clampDate,
|
|
24
|
+
getNextDay: () => getNextDay,
|
|
25
|
+
getPreviousDay: () => getPreviousDay,
|
|
26
|
+
getTodayDate: () => getTodayDate,
|
|
27
|
+
setCalendar: () => setCalendar,
|
|
28
|
+
setDate: () => setDate,
|
|
29
|
+
setMonth: () => setMonth,
|
|
30
|
+
setYear: () => setYear
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(mutation_exports);
|
|
33
|
+
var import_date3 = require("@internationalized/date");
|
|
34
|
+
|
|
35
|
+
// src/constrain.ts
|
|
36
|
+
var import_date = require("@internationalized/date");
|
|
37
|
+
function constrainValue(ctx, date) {
|
|
38
|
+
let { min, max } = ctx;
|
|
39
|
+
if (min) {
|
|
40
|
+
date = (0, import_date.maxDate)(date, (0, import_date.toCalendarDate)(min));
|
|
41
|
+
}
|
|
42
|
+
if (max) {
|
|
43
|
+
date = (0, import_date.minDate)(date, (0, import_date.toCalendarDate)(max));
|
|
44
|
+
}
|
|
45
|
+
return date;
|
|
46
|
+
}
|
|
47
|
+
|
|
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
|
+
// src/mutation.ts
|
|
65
|
+
function clampDate(ctx, date) {
|
|
66
|
+
return constrainValue(ctx, date);
|
|
67
|
+
}
|
|
68
|
+
function getTodayDate(timezone) {
|
|
69
|
+
return (0, import_date3.today)(timezone);
|
|
70
|
+
}
|
|
71
|
+
function getNextDay(date) {
|
|
72
|
+
return date.add({ days: 1 });
|
|
73
|
+
}
|
|
74
|
+
function getPreviousDay(date) {
|
|
75
|
+
return date.subtract({ days: 1 });
|
|
76
|
+
}
|
|
77
|
+
function setMonth(date, month) {
|
|
78
|
+
return date.set({ month });
|
|
79
|
+
}
|
|
80
|
+
function setYear(date, year) {
|
|
81
|
+
return date.set({ year });
|
|
82
|
+
}
|
|
83
|
+
function setCalendar(date, calendar) {
|
|
84
|
+
return (0, import_date3.toCalendar)((0, import_date3.toCalendarDate)(date), calendar);
|
|
85
|
+
}
|
|
86
|
+
function setDate(ctx, date, nextDate, startDate) {
|
|
87
|
+
let result;
|
|
88
|
+
result = clampDate(ctx, nextDate);
|
|
89
|
+
result = getPreviousAvailableDate(ctx, nextDate, startDate);
|
|
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
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
function getPreviousAvailableDate(ctx, date, min) {
|
|
99
|
+
const minValue = min != null ? min : ctx.min;
|
|
100
|
+
if (!isDateUnavailable(ctx, date) || !minValue) {
|
|
101
|
+
return date;
|
|
102
|
+
}
|
|
103
|
+
while (date.compare(minValue) >= 0 && isDateUnavailable(ctx, date)) {
|
|
104
|
+
date = date.subtract({ days: 1 });
|
|
105
|
+
}
|
|
106
|
+
if (date.compare(minValue) >= 0) {
|
|
107
|
+
return date;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
111
|
+
0 && (module.exports = {
|
|
112
|
+
clampDate,
|
|
113
|
+
getNextDay,
|
|
114
|
+
getPreviousDay,
|
|
115
|
+
getTodayDate,
|
|
116
|
+
setCalendar,
|
|
117
|
+
setDate,
|
|
118
|
+
setMonth,
|
|
119
|
+
setYear
|
|
120
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clampDate,
|
|
3
|
+
getNextDay,
|
|
4
|
+
getPreviousDay,
|
|
5
|
+
getTodayDate,
|
|
6
|
+
setCalendar,
|
|
7
|
+
setDate,
|
|
8
|
+
setMonth,
|
|
9
|
+
setYear
|
|
10
|
+
} from "./chunk-C4U2N3JC.mjs";
|
|
11
|
+
import "./chunk-7JERMWT3.mjs";
|
|
12
|
+
import "./chunk-HP2COJGP.mjs";
|
|
13
|
+
export {
|
|
14
|
+
clampDate,
|
|
15
|
+
getNextDay,
|
|
16
|
+
getPreviousDay,
|
|
17
|
+
getTodayDate,
|
|
18
|
+
setCalendar,
|
|
19
|
+
setDate,
|
|
20
|
+
setMonth,
|
|
21
|
+
setYear
|
|
22
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CalendarDate } from '@internationalized/date';
|
|
2
|
+
import { D as DateContext } from './types-9f60d2f1.js';
|
|
3
|
+
|
|
4
|
+
declare function getNextPage(ctx: DateContext, date: CalendarDate, startDate: CalendarDate): {
|
|
5
|
+
startDate: CalendarDate;
|
|
6
|
+
focusedDate: CalendarDate;
|
|
7
|
+
};
|
|
8
|
+
declare function getPreviousPage(ctx: DateContext, date: CalendarDate, startDate: CalendarDate): {
|
|
9
|
+
startDate: CalendarDate;
|
|
10
|
+
focusedDate: CalendarDate;
|
|
11
|
+
};
|
|
12
|
+
declare function getSectionStart(ctx: DateContext, date: CalendarDate, startDate: CalendarDate): CalendarDate | undefined;
|
|
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 | {
|
|
17
|
+
startDate: CalendarDate;
|
|
18
|
+
focusedDate: CalendarDate;
|
|
19
|
+
} | undefined;
|
|
20
|
+
declare function getPreviousRow(ctx: DateContext, date: CalendarDate, startDate: CalendarDate): CalendarDate | {
|
|
21
|
+
startDate: CalendarDate;
|
|
22
|
+
focusedDate: CalendarDate;
|
|
23
|
+
} | undefined;
|
|
24
|
+
|
|
25
|
+
export { getNextPage, getNextRow, getNextSection, getPreviousPage, getPreviousRow, getPreviousSection, getSectionEnd, getSectionStart };
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/pagination.ts
|
|
21
|
+
var pagination_exports = {};
|
|
22
|
+
__export(pagination_exports, {
|
|
23
|
+
getNextPage: () => getNextPage,
|
|
24
|
+
getNextRow: () => getNextRow,
|
|
25
|
+
getNextSection: () => getNextSection,
|
|
26
|
+
getPreviousPage: () => getPreviousPage,
|
|
27
|
+
getPreviousRow: () => getPreviousRow,
|
|
28
|
+
getPreviousSection: () => getPreviousSection,
|
|
29
|
+
getSectionEnd: () => getSectionEnd,
|
|
30
|
+
getSectionStart: () => getSectionStart
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(pagination_exports);
|
|
33
|
+
var import_date2 = require("@internationalized/date");
|
|
34
|
+
|
|
35
|
+
// src/constrain.ts
|
|
36
|
+
var import_date = require("@internationalized/date");
|
|
37
|
+
function alignStart(ctx, date) {
|
|
38
|
+
let { locale, duration } = ctx;
|
|
39
|
+
let aligned = date;
|
|
40
|
+
if (duration.years) {
|
|
41
|
+
aligned = (0, import_date.startOfYear)(date);
|
|
42
|
+
} else if (duration.months) {
|
|
43
|
+
aligned = (0, import_date.startOfMonth)(date);
|
|
44
|
+
} else if (duration.weeks) {
|
|
45
|
+
aligned = (0, import_date.startOfWeek)(date, locale);
|
|
46
|
+
}
|
|
47
|
+
return constrainStart(ctx, date, aligned);
|
|
48
|
+
}
|
|
49
|
+
function alignEnd(ctx, date) {
|
|
50
|
+
const { duration } = ctx;
|
|
51
|
+
let d = { ...duration };
|
|
52
|
+
if (d.days) {
|
|
53
|
+
d.days--;
|
|
54
|
+
} else if (d.weeks) {
|
|
55
|
+
d.weeks--;
|
|
56
|
+
} else if (d.months) {
|
|
57
|
+
d.months--;
|
|
58
|
+
} else if (d.years) {
|
|
59
|
+
d.years--;
|
|
60
|
+
}
|
|
61
|
+
let aligned = alignStart(ctx, date).subtract(d);
|
|
62
|
+
return constrainStart(ctx, date, aligned);
|
|
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;
|
|
73
|
+
}
|
|
74
|
+
function constrainStart(ctx, date, aligned) {
|
|
75
|
+
let { min, max } = ctx;
|
|
76
|
+
if (min && date.compare(min) >= 0) {
|
|
77
|
+
aligned = (0, import_date.maxDate)(aligned, alignStart(ctx, (0, import_date.toCalendarDate)(min)));
|
|
78
|
+
}
|
|
79
|
+
if (max && date.compare(max) <= 0) {
|
|
80
|
+
aligned = (0, import_date.minDate)(aligned, alignEnd(ctx, (0, import_date.toCalendarDate)(max)));
|
|
81
|
+
}
|
|
82
|
+
return aligned;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/duration.ts
|
|
86
|
+
function getUnitDuration(duration) {
|
|
87
|
+
let d = { ...duration };
|
|
88
|
+
for (let key in d) {
|
|
89
|
+
d[key] = 1;
|
|
90
|
+
}
|
|
91
|
+
return d;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/pagination.ts
|
|
95
|
+
function getNextPage(ctx, date, startDate) {
|
|
96
|
+
const start = startDate.add(ctx.duration);
|
|
97
|
+
return {
|
|
98
|
+
startDate: alignStart(ctx, constrainStart(ctx, date, start)),
|
|
99
|
+
focusedDate: constrainValue(ctx, date.add(ctx.duration))
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function getPreviousPage(ctx, date, startDate) {
|
|
103
|
+
const start = startDate.subtract(ctx.duration);
|
|
104
|
+
return {
|
|
105
|
+
startDate: alignStart(ctx, constrainStart(ctx, date, start)),
|
|
106
|
+
focusedDate: constrainValue(ctx, date.subtract(ctx.duration))
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function getSectionStart(ctx, date, startDate) {
|
|
110
|
+
const d = ctx.duration;
|
|
111
|
+
if (d.days) {
|
|
112
|
+
return startDate;
|
|
113
|
+
}
|
|
114
|
+
if (d.weeks) {
|
|
115
|
+
return (0, import_date2.startOfWeek)(date, ctx.locale);
|
|
116
|
+
}
|
|
117
|
+
if (d.months || d.years) {
|
|
118
|
+
return (0, import_date2.startOfMonth)(date);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function getSectionEnd(ctx, date, endDate) {
|
|
122
|
+
const d = ctx.duration;
|
|
123
|
+
if (d.days) {
|
|
124
|
+
return endDate;
|
|
125
|
+
}
|
|
126
|
+
if (d.weeks) {
|
|
127
|
+
return (0, import_date2.endOfWeek)(date, ctx.locale);
|
|
128
|
+
}
|
|
129
|
+
if (d.months || d.years) {
|
|
130
|
+
return (0, import_date2.endOfMonth)(date);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function getNextSection(ctx, date, larger) {
|
|
134
|
+
const d = ctx.duration;
|
|
135
|
+
const unitDuration = getUnitDuration(ctx.duration);
|
|
136
|
+
if (!larger && !d.days) {
|
|
137
|
+
return date.add(unitDuration);
|
|
138
|
+
}
|
|
139
|
+
if (d.days) {
|
|
140
|
+
return date.add(d);
|
|
141
|
+
}
|
|
142
|
+
if (d.weeks) {
|
|
143
|
+
return date.add({ months: 1 });
|
|
144
|
+
}
|
|
145
|
+
if (d.months || d.years) {
|
|
146
|
+
return date.add({ years: 1 });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function getPreviousSection(ctx, date, larger) {
|
|
150
|
+
const d = ctx.duration;
|
|
151
|
+
const unitDuration = getUnitDuration(ctx.duration);
|
|
152
|
+
if (!larger && !d.days) {
|
|
153
|
+
return date.subtract(unitDuration);
|
|
154
|
+
}
|
|
155
|
+
if (d.days) {
|
|
156
|
+
return date.subtract(ctx.duration);
|
|
157
|
+
}
|
|
158
|
+
if (d.weeks) {
|
|
159
|
+
return date.subtract({ months: 1 });
|
|
160
|
+
}
|
|
161
|
+
if (d.months || d.years) {
|
|
162
|
+
return date.subtract({ years: 1 });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function getNextRow(ctx, date, startDate) {
|
|
166
|
+
const d = ctx.duration;
|
|
167
|
+
if (d.days) {
|
|
168
|
+
return getNextPage(ctx, date, startDate);
|
|
169
|
+
}
|
|
170
|
+
if (d.weeks || d.months || d.years) {
|
|
171
|
+
return date.add({ weeks: 1 });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function getPreviousRow(ctx, date, startDate) {
|
|
175
|
+
const d = ctx.duration;
|
|
176
|
+
if (d.days) {
|
|
177
|
+
return getPreviousPage(ctx, date, startDate);
|
|
178
|
+
}
|
|
179
|
+
if (d.weeks || d.months || d.years) {
|
|
180
|
+
return date.subtract({ weeks: 1 });
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
184
|
+
0 && (module.exports = {
|
|
185
|
+
getNextPage,
|
|
186
|
+
getNextRow,
|
|
187
|
+
getNextSection,
|
|
188
|
+
getPreviousPage,
|
|
189
|
+
getPreviousRow,
|
|
190
|
+
getPreviousSection,
|
|
191
|
+
getSectionEnd,
|
|
192
|
+
getSectionStart
|
|
193
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getNextPage,
|
|
3
|
+
getNextRow,
|
|
4
|
+
getNextSection,
|
|
5
|
+
getPreviousPage,
|
|
6
|
+
getPreviousRow,
|
|
7
|
+
getPreviousSection,
|
|
8
|
+
getSectionEnd,
|
|
9
|
+
getSectionStart
|
|
10
|
+
} from "./chunk-VWVBJ5CB.mjs";
|
|
11
|
+
import "./chunk-HP2COJGP.mjs";
|
|
12
|
+
import "./chunk-ZSLC7OI2.mjs";
|
|
13
|
+
export {
|
|
14
|
+
getNextPage,
|
|
15
|
+
getNextRow,
|
|
16
|
+
getNextSection,
|
|
17
|
+
getPreviousPage,
|
|
18
|
+
getPreviousRow,
|
|
19
|
+
getPreviousSection,
|
|
20
|
+
getSectionEnd,
|
|
21
|
+
getSectionStart
|
|
22
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as _internationalized_date from '@internationalized/date';
|
|
2
|
+
import { c as DateGranularity } from './types-9f60d2f1.js';
|
|
3
|
+
|
|
4
|
+
declare function getTodayPlaceholderDate(timeZone: string): _internationalized_date.ZonedDateTime;
|
|
5
|
+
declare function createPlaceholderDate(granularity: DateGranularity, timeZone: string): _internationalized_date.CalendarDate | _internationalized_date.ZonedDateTime;
|
|
6
|
+
|
|
7
|
+
export { createPlaceholderDate, getTodayPlaceholderDate };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/placeholder.ts
|
|
21
|
+
var placeholder_exports = {};
|
|
22
|
+
__export(placeholder_exports, {
|
|
23
|
+
createPlaceholderDate: () => createPlaceholderDate,
|
|
24
|
+
getTodayPlaceholderDate: () => getTodayPlaceholderDate
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(placeholder_exports);
|
|
27
|
+
var import_date = require("@internationalized/date");
|
|
28
|
+
function getTodayPlaceholderDate(timeZone) {
|
|
29
|
+
return (0, import_date.now)(timeZone).set({
|
|
30
|
+
hour: 0,
|
|
31
|
+
minute: 0,
|
|
32
|
+
second: 0,
|
|
33
|
+
millisecond: 0
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function createPlaceholderDate(granularity, timeZone) {
|
|
37
|
+
let date = getTodayPlaceholderDate(timeZone);
|
|
38
|
+
if (granularity === "year" || granularity === "month" || granularity === "day") {
|
|
39
|
+
return (0, import_date.toCalendarDate)(date);
|
|
40
|
+
}
|
|
41
|
+
return date;
|
|
42
|
+
}
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
createPlaceholderDate,
|
|
46
|
+
getTodayPlaceholderDate
|
|
47
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/placeholder.ts
|
|
2
|
+
import { now, toCalendarDate } from "@internationalized/date";
|
|
3
|
+
function getTodayPlaceholderDate(timeZone) {
|
|
4
|
+
return now(timeZone).set({
|
|
5
|
+
hour: 0,
|
|
6
|
+
minute: 0,
|
|
7
|
+
second: 0,
|
|
8
|
+
millisecond: 0
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function createPlaceholderDate(granularity, timeZone) {
|
|
12
|
+
let date = getTodayPlaceholderDate(timeZone);
|
|
13
|
+
if (granularity === "year" || granularity === "month" || granularity === "day") {
|
|
14
|
+
return toCalendarDate(date);
|
|
15
|
+
}
|
|
16
|
+
return date;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
createPlaceholderDate,
|
|
20
|
+
getTodayPlaceholderDate
|
|
21
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/segment-constants.ts
|
|
21
|
+
var segment_constants_exports = {};
|
|
22
|
+
__export(segment_constants_exports, {
|
|
23
|
+
SEGMENT_PAGE_STEP: () => SEGMENT_PAGE_STEP,
|
|
24
|
+
isSegmentEditable: () => isSegmentEditable
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(segment_constants_exports);
|
|
27
|
+
var EDITABLE_SEGMENTS = {
|
|
28
|
+
year: true,
|
|
29
|
+
month: true,
|
|
30
|
+
day: true,
|
|
31
|
+
hour: true,
|
|
32
|
+
minute: true,
|
|
33
|
+
second: true,
|
|
34
|
+
dayPeriod: true,
|
|
35
|
+
era: true
|
|
36
|
+
};
|
|
37
|
+
var SEGMENT_PAGE_STEP = {
|
|
38
|
+
year: 5,
|
|
39
|
+
month: 2,
|
|
40
|
+
day: 7,
|
|
41
|
+
hour: 2,
|
|
42
|
+
minute: 15,
|
|
43
|
+
second: 15
|
|
44
|
+
};
|
|
45
|
+
function isSegmentEditable(segment) {
|
|
46
|
+
return EDITABLE_SEGMENTS[segment];
|
|
47
|
+
}
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
SEGMENT_PAGE_STEP,
|
|
51
|
+
isSegmentEditable
|
|
52
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DateValue } from '@internationalized/date';
|
|
2
|
+
import { e as DateSegmentPart, f as DateFormatOptions } from './types-9f60d2f1.js';
|
|
3
|
+
|
|
4
|
+
declare function getSegmentLimits(date: DateValue, type: DateSegmentPart, options: DateFormatOptions): {
|
|
5
|
+
value: number;
|
|
6
|
+
min: number;
|
|
7
|
+
max: number;
|
|
8
|
+
} | {
|
|
9
|
+
value?: undefined;
|
|
10
|
+
min?: undefined;
|
|
11
|
+
max?: undefined;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { getSegmentLimits };
|