@zag-js/date-utils 0.1.2 → 0.1.4
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/chunk-5HGHDJ3L.mjs +14 -0
- package/dist/chunk-AMZ7CJ5F.mjs +18 -0
- package/dist/chunk-CAYCTIEJ.mjs +29 -0
- package/dist/chunk-G4VVKINZ.mjs +14 -0
- package/dist/chunk-KBGJA6NB.mjs +55 -0
- package/dist/chunk-KFJ757ZA.mjs +32 -0
- package/dist/chunk-KLHRN7WS.mjs +20 -0
- package/dist/chunk-KN3YMOSL.mjs +8 -0
- package/dist/chunk-LGEGBP3O.mjs +20 -0
- package/dist/{chunk-NXMEZINO.mjs → chunk-LQAXQPWP.mjs} +4 -7
- package/dist/chunk-ODG5YF5H.mjs +21 -0
- package/dist/chunk-SI75FOJ2.mjs +11 -0
- package/dist/chunk-U3OBXRHI.mjs +42 -0
- package/dist/format-date.d.ts +9 -0
- package/dist/format-date.js +79 -0
- package/dist/format-date.mjs +6 -0
- package/dist/format-selected-date.d.ts +1 -2
- package/dist/format-selected-date.js +14 -14
- package/dist/format-selected-date.mjs +3 -2
- package/dist/format-visible-range.d.ts +1 -2
- package/dist/format-visible-range.js +29 -50
- package/dist/format-visible-range.mjs +4 -3
- package/dist/get-day-formatter.d.ts +5 -0
- package/dist/{placeholder.js → get-day-formatter.js} +22 -21
- package/dist/get-day-formatter.mjs +7 -0
- package/dist/get-decade-range.d.ts +3 -0
- package/dist/get-decade-range.js +38 -0
- package/dist/get-decade-range.mjs +6 -0
- package/dist/get-end-of-week.d.ts +5 -0
- package/dist/{segment-constants.js → get-end-of-week.js} +17 -32
- package/dist/get-end-of-week.mjs +11 -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-month-days.d.ts +6 -0
- package/dist/{get-month-dates.js → get-month-days.js} +26 -27
- package/dist/get-month-days.mjs +9 -0
- package/dist/get-month-formatter.d.ts +5 -0
- package/dist/{get-formatter.js → get-month-formatter.js} +14 -26
- package/dist/get-month-formatter.mjs +7 -0
- package/dist/get-month-names.d.ts +3 -0
- package/dist/get-month-names.js +38 -0
- package/dist/get-month-names.mjs +6 -0
- package/dist/get-start-of-week.d.ts +5 -0
- package/dist/get-start-of-week.js +35 -0
- package/dist/get-start-of-week.mjs +6 -0
- package/dist/get-week-days.d.ts +10 -0
- package/dist/get-week-days.js +62 -0
- package/dist/get-week-days.mjs +8 -0
- package/dist/get-weekday-formats.d.ts +10 -0
- package/dist/get-weekday-formats.js +44 -0
- package/dist/get-weekday-formats.mjs +6 -0
- package/dist/index.d.ts +10 -8
- package/dist/index.js +223 -307
- package/dist/index.mjs +40 -41
- package/dist/parse-date.d.ts +5 -0
- package/dist/parse-date.js +66 -0
- package/dist/parse-date.mjs +6 -0
- package/dist/types.d.ts +1 -2
- package/package.json +2 -2
- package/dist/chunk-55BYHK5B.mjs +0 -31
- package/dist/chunk-DZM5JUL2.mjs +0 -22
- package/dist/chunk-ETRHBIGD.mjs +0 -66
- package/dist/chunk-GLQDJRSE.mjs +0 -31
- package/dist/chunk-JZVHAOWX.mjs +0 -35
- package/dist/chunk-MGRIF22W.mjs +0 -18
- package/dist/chunk-SQCHVCXH.mjs +0 -42
- package/dist/chunk-TSOWYV6W.mjs +0 -34
- package/dist/chunk-U6WRBS5P.mjs +0 -77
- package/dist/get-formatter.d.ts +0 -8
- package/dist/get-formatter.mjs +0 -8
- package/dist/get-month-dates.d.ts +0 -5
- package/dist/get-month-dates.mjs +0 -7
- package/dist/get-week-dates.d.ts +0 -7
- package/dist/get-week-dates.js +0 -60
- package/dist/get-week-dates.mjs +0 -8
- package/dist/placeholder.d.ts +0 -7
- package/dist/placeholder.mjs +0 -8
- package/dist/segment-constants.d.ts +0 -27
- package/dist/segment-constants.mjs +0 -10
- package/dist/segment-limit.d.ts +0 -10
- package/dist/segment-limit.js +0 -101
- package/dist/segment-limit.mjs +0 -6
- package/dist/segment-mutation.d.ts +0 -7
- package/dist/segment-mutation.js +0 -91
- package/dist/segment-mutation.mjs +0 -8
- package/dist/segment-parts.d.ts +0 -27
- package/dist/segment-parts.js +0 -159
- package/dist/segment-parts.mjs +0 -11
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "./chunk-ETRHBIGD.mjs";
|
|
2
|
+
getWeekDays
|
|
3
|
+
} from "./chunk-AMZ7CJ5F.mjs";
|
|
5
4
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "./chunk-SQCHVCXH.mjs";
|
|
9
|
-
import {
|
|
10
|
-
getSegmentLimits
|
|
11
|
-
} from "./chunk-U6WRBS5P.mjs";
|
|
12
|
-
import {
|
|
13
|
-
getMonthDates
|
|
14
|
-
} from "./chunk-MGRIF22W.mjs";
|
|
15
|
-
import {
|
|
16
|
-
getDatesInWeek,
|
|
17
|
-
getWeekDates
|
|
18
|
-
} from "./chunk-JZVHAOWX.mjs";
|
|
5
|
+
getWeekdayFormats
|
|
6
|
+
} from "./chunk-KLHRN7WS.mjs";
|
|
19
7
|
import {
|
|
20
8
|
getYearsRange
|
|
21
9
|
} from "./chunk-TTJVXKJY.mjs";
|
|
@@ -41,14 +29,19 @@ import {
|
|
|
41
29
|
getSectionStart
|
|
42
30
|
} from "./chunk-VTFZA34K.mjs";
|
|
43
31
|
import {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
} from "./chunk-DZM5JUL2.mjs";
|
|
32
|
+
parseDateString
|
|
33
|
+
} from "./chunk-U3OBXRHI.mjs";
|
|
47
34
|
import {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
getDecadeRange
|
|
36
|
+
} from "./chunk-G4VVKINZ.mjs";
|
|
37
|
+
import {
|
|
38
|
+
getDaysInWeek,
|
|
39
|
+
getMonthDays
|
|
40
|
+
} from "./chunk-KFJ757ZA.mjs";
|
|
41
|
+
import {
|
|
42
|
+
getMonthNames
|
|
43
|
+
} from "./chunk-5HGHDJ3L.mjs";
|
|
44
|
+
import "./chunk-SI75FOJ2.mjs";
|
|
52
45
|
import {
|
|
53
46
|
alignDate,
|
|
54
47
|
alignStartDate
|
|
@@ -75,18 +68,25 @@ import {
|
|
|
75
68
|
getUnitDuration
|
|
76
69
|
} from "./chunk-ZSLC7OI2.mjs";
|
|
77
70
|
import {
|
|
78
|
-
|
|
79
|
-
} from "./chunk-
|
|
71
|
+
formatDate
|
|
72
|
+
} from "./chunk-KBGJA6NB.mjs";
|
|
80
73
|
import {
|
|
81
|
-
|
|
82
|
-
} from "./chunk-
|
|
74
|
+
formatSelectedDate
|
|
75
|
+
} from "./chunk-LQAXQPWP.mjs";
|
|
83
76
|
import {
|
|
84
77
|
formatRange
|
|
85
78
|
} from "./chunk-HKHGJ6WS.mjs";
|
|
86
|
-
import
|
|
79
|
+
import {
|
|
80
|
+
formatVisibleRange
|
|
81
|
+
} from "./chunk-CAYCTIEJ.mjs";
|
|
82
|
+
import {
|
|
83
|
+
getMonthFormatter
|
|
84
|
+
} from "./chunk-LGEGBP3O.mjs";
|
|
85
|
+
import {
|
|
86
|
+
getDayFormatter
|
|
87
|
+
} from "./chunk-ODG5YF5H.mjs";
|
|
88
|
+
import "./chunk-KN3YMOSL.mjs";
|
|
87
89
|
export {
|
|
88
|
-
SEGMENT_PAGE_STEP,
|
|
89
|
-
addSegment,
|
|
90
90
|
alignCenter,
|
|
91
91
|
alignDate,
|
|
92
92
|
alignEnd,
|
|
@@ -94,15 +94,18 @@ export {
|
|
|
94
94
|
alignStartDate,
|
|
95
95
|
constrainStart,
|
|
96
96
|
constrainValue,
|
|
97
|
-
|
|
97
|
+
formatDate,
|
|
98
98
|
formatRange,
|
|
99
99
|
formatSelectedDate,
|
|
100
100
|
formatVisibleRange,
|
|
101
101
|
getAdjustedDateFn,
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
getDayFormatter,
|
|
103
|
+
getDaysInWeek,
|
|
104
|
+
getDecadeRange,
|
|
104
105
|
getEndDate,
|
|
105
|
-
|
|
106
|
+
getMonthDays,
|
|
107
|
+
getMonthFormatter,
|
|
108
|
+
getMonthNames,
|
|
106
109
|
getNextDay,
|
|
107
110
|
getNextPage,
|
|
108
111
|
getNextRow,
|
|
@@ -114,13 +117,10 @@ export {
|
|
|
114
117
|
getPreviousSection,
|
|
115
118
|
getSectionEnd,
|
|
116
119
|
getSectionStart,
|
|
117
|
-
getSegmentLimits,
|
|
118
|
-
getSegmentPageStep,
|
|
119
|
-
getSegments,
|
|
120
120
|
getTodayDate,
|
|
121
|
-
getTodayPlaceholderDate,
|
|
122
121
|
getUnitDuration,
|
|
123
|
-
|
|
122
|
+
getWeekDays,
|
|
123
|
+
getWeekdayFormats,
|
|
124
124
|
getYearsRange,
|
|
125
125
|
isDateDisabled,
|
|
126
126
|
isDateEqual,
|
|
@@ -129,11 +129,10 @@ export {
|
|
|
129
129
|
isDateUnavailable,
|
|
130
130
|
isNextVisibleRangeInvalid,
|
|
131
131
|
isPreviousVisibleRangeInvalid,
|
|
132
|
-
isSegmentEditable,
|
|
133
132
|
isTodayDate,
|
|
133
|
+
parseDateString,
|
|
134
134
|
setCalendar,
|
|
135
135
|
setDate,
|
|
136
136
|
setMonth,
|
|
137
|
-
setSegment,
|
|
138
137
|
setYear
|
|
139
138
|
};
|
|
@@ -0,0 +1,66 @@
|
|
|
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/parse-date.ts
|
|
21
|
+
var parse_date_exports = {};
|
|
22
|
+
__export(parse_date_exports, {
|
|
23
|
+
parseDateString: () => parseDateString
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(parse_date_exports);
|
|
26
|
+
var import_date = require("@internationalized/date");
|
|
27
|
+
function parseDateString(date, locale, timeZone) {
|
|
28
|
+
const regex = createRegex(locale, timeZone);
|
|
29
|
+
const { year, month, day } = extract(regex, date) ?? {};
|
|
30
|
+
if (year != null && year.length === 4 && month != null && +month <= 12 && day != null && +day <= 31) {
|
|
31
|
+
return new import_date.CalendarDate(+year, +month, +day);
|
|
32
|
+
}
|
|
33
|
+
const time = Date.parse(date);
|
|
34
|
+
if (!isNaN(time)) {
|
|
35
|
+
const date2 = new Date(time);
|
|
36
|
+
return new import_date.CalendarDate(date2.getFullYear(), date2.getMonth() + 1, date2.getDate());
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function createRegex(locale, timeZone) {
|
|
40
|
+
const formatter = new import_date.DateFormatter(locale, { day: "numeric", month: "numeric", year: "numeric", timeZone });
|
|
41
|
+
const parts = formatter.formatToParts(new Date(2e3, 11, 25));
|
|
42
|
+
return parts.map(({ type, value }) => type === "literal" ? value : `((?!=<${type}>)\\d+)`).join("");
|
|
43
|
+
}
|
|
44
|
+
function extract(pattern, str) {
|
|
45
|
+
const matches = str.match(pattern);
|
|
46
|
+
return pattern.toString().match(/<(.+?)>/g)?.map((group) => {
|
|
47
|
+
const groupMatches = group.match(/<(.+)>/);
|
|
48
|
+
if (!groupMatches || groupMatches.length <= 0) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return group.match(/<(.+)>/)?.[1];
|
|
52
|
+
}).reduce((acc, curr, index) => {
|
|
53
|
+
if (!curr)
|
|
54
|
+
return acc;
|
|
55
|
+
if (matches && matches.length > index) {
|
|
56
|
+
acc[curr] = matches[index + 1];
|
|
57
|
+
} else {
|
|
58
|
+
acc[curr] = null;
|
|
59
|
+
}
|
|
60
|
+
return acc;
|
|
61
|
+
}, {});
|
|
62
|
+
}
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
parseDateString
|
|
66
|
+
});
|
package/dist/types.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ type DateAdjustFn = (options: {
|
|
|
16
16
|
focusedDate: CalendarDate;
|
|
17
17
|
endDate: CalendarDate;
|
|
18
18
|
};
|
|
19
|
-
type DateSegmentPart = Intl.DateTimeFormatPartTypes;
|
|
20
19
|
type DateFormatOptions = Intl.ResolvedDateTimeFormatOptions;
|
|
21
20
|
|
|
22
|
-
export { DateAdjustFn, DateAlignment, DateAvailableFn, DateFormatOptions, DateGranularity,
|
|
21
|
+
export { DateAdjustFn, DateAlignment, DateAvailableFn, DateFormatOptions, DateGranularity, GetFormatterFn, GetPlaceholderFn };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/date-utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Date utilities for zag.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"clean-package": "2.2.0",
|
|
31
|
-
"@internationalized/date": "^3.0
|
|
31
|
+
"@internationalized/date": "^3.1.0"
|
|
32
32
|
},
|
|
33
33
|
"module": "dist/index.mjs",
|
|
34
34
|
"types": "dist/index.d.ts",
|
package/dist/chunk-55BYHK5B.mjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// src/segment-constants.ts
|
|
2
|
-
var EDITABLE_SEGMENTS = {
|
|
3
|
-
year: true,
|
|
4
|
-
month: true,
|
|
5
|
-
day: true,
|
|
6
|
-
hour: true,
|
|
7
|
-
minute: true,
|
|
8
|
-
second: true,
|
|
9
|
-
dayPeriod: true,
|
|
10
|
-
era: true
|
|
11
|
-
};
|
|
12
|
-
var SEGMENT_PAGE_STEP = {
|
|
13
|
-
year: 5,
|
|
14
|
-
month: 2,
|
|
15
|
-
day: 7,
|
|
16
|
-
hour: 2,
|
|
17
|
-
minute: 15,
|
|
18
|
-
second: 15
|
|
19
|
-
};
|
|
20
|
-
function isSegmentEditable(segment) {
|
|
21
|
-
return EDITABLE_SEGMENTS[segment];
|
|
22
|
-
}
|
|
23
|
-
function getSegmentPageStep(segment) {
|
|
24
|
-
return SEGMENT_PAGE_STEP[segment] ?? 1;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export {
|
|
28
|
-
SEGMENT_PAGE_STEP,
|
|
29
|
-
isSegmentEditable,
|
|
30
|
-
getSegmentPageStep
|
|
31
|
-
};
|
package/dist/chunk-DZM5JUL2.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
|
|
19
|
-
export {
|
|
20
|
-
getTodayPlaceholderDate,
|
|
21
|
-
createPlaceholderDate
|
|
22
|
-
};
|
package/dist/chunk-ETRHBIGD.mjs
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// src/segment-mutation.ts
|
|
2
|
-
function addSegment(date, part, amount, options) {
|
|
3
|
-
switch (part) {
|
|
4
|
-
case "era":
|
|
5
|
-
case "year":
|
|
6
|
-
case "month":
|
|
7
|
-
case "day":
|
|
8
|
-
return date.cycle(part, amount, { round: part === "year" });
|
|
9
|
-
}
|
|
10
|
-
if ("hour" in date) {
|
|
11
|
-
switch (part) {
|
|
12
|
-
case "dayPeriod": {
|
|
13
|
-
let hours = date.hour;
|
|
14
|
-
let isPM = hours >= 12;
|
|
15
|
-
return date.set({ hour: isPM ? hours - 12 : hours + 12 });
|
|
16
|
-
}
|
|
17
|
-
case "hour":
|
|
18
|
-
case "minute":
|
|
19
|
-
case "second":
|
|
20
|
-
return date.cycle(part, amount, {
|
|
21
|
-
round: part !== "hour",
|
|
22
|
-
hourCycle: options?.hour12 ? 12 : 24
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return date;
|
|
27
|
-
}
|
|
28
|
-
function setSegment(date, part, value, options) {
|
|
29
|
-
switch (part) {
|
|
30
|
-
case "day":
|
|
31
|
-
case "month":
|
|
32
|
-
case "year":
|
|
33
|
-
case "era":
|
|
34
|
-
return date.set({ [part]: value });
|
|
35
|
-
}
|
|
36
|
-
if ("hour" in date) {
|
|
37
|
-
switch (part) {
|
|
38
|
-
case "dayPeriod": {
|
|
39
|
-
let hours = date.hour;
|
|
40
|
-
let wasPM = hours >= 12;
|
|
41
|
-
let isPM = value >= 12;
|
|
42
|
-
return isPM === wasPM ? date : date.set({ hour: wasPM ? hours - 12 : hours + 12 });
|
|
43
|
-
}
|
|
44
|
-
case "hour":
|
|
45
|
-
if (options?.hour12) {
|
|
46
|
-
let hours = date.hour;
|
|
47
|
-
let wasPM = hours >= 12;
|
|
48
|
-
if (!wasPM && value === 12) {
|
|
49
|
-
value = 0;
|
|
50
|
-
}
|
|
51
|
-
if (wasPM && value < 12) {
|
|
52
|
-
value += 12;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
case "minute":
|
|
56
|
-
case "second":
|
|
57
|
-
return date.set({ [part]: value });
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return date;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export {
|
|
64
|
-
addSegment,
|
|
65
|
-
setSegment
|
|
66
|
-
};
|
package/dist/chunk-GLQDJRSE.mjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
formatRange
|
|
3
|
-
} from "./chunk-HKHGJ6WS.mjs";
|
|
4
|
-
import {
|
|
5
|
-
getDateFormatter,
|
|
6
|
-
getMonthFormatter
|
|
7
|
-
} from "./chunk-TSOWYV6W.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 ?? 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
|
-
};
|
package/dist/chunk-JZVHAOWX.mjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// src/get-week-dates.ts
|
|
2
|
-
import { getDayOfWeek, isSameDay, startOfWeek } from "@internationalized/date";
|
|
3
|
-
function getDatesInWeek(weekIndex, fromDate, locale) {
|
|
4
|
-
let date = fromDate.add({ weeks: weekIndex });
|
|
5
|
-
let dates = [];
|
|
6
|
-
date = startOfWeek(date, locale);
|
|
7
|
-
let dayOfWeek = getDayOfWeek(date, locale);
|
|
8
|
-
for (let i = 0; i < dayOfWeek; i++) {
|
|
9
|
-
dates.push(null);
|
|
10
|
-
}
|
|
11
|
-
while (dates.length < 7) {
|
|
12
|
-
dates.push(date);
|
|
13
|
-
let nextDate = date.add({ days: 1 });
|
|
14
|
-
if (isSameDay(date, nextDate)) {
|
|
15
|
-
break;
|
|
16
|
-
}
|
|
17
|
-
date = nextDate;
|
|
18
|
-
}
|
|
19
|
-
while (dates.length < 7) {
|
|
20
|
-
dates.push(null);
|
|
21
|
-
}
|
|
22
|
-
return dates;
|
|
23
|
-
}
|
|
24
|
-
function getWeekDates(fromDate, timeZone, locale) {
|
|
25
|
-
let weekStart = startOfWeek(fromDate, locale);
|
|
26
|
-
let weekArr = [...new Array(7).keys()];
|
|
27
|
-
return weekArr.map((index) => {
|
|
28
|
-
return weekStart.add({ days: index }).toDate(timeZone);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export {
|
|
33
|
-
getDatesInWeek,
|
|
34
|
-
getWeekDates
|
|
35
|
-
};
|
package/dist/chunk-MGRIF22W.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getDatesInWeek
|
|
3
|
-
} from "./chunk-JZVHAOWX.mjs";
|
|
4
|
-
|
|
5
|
-
// src/get-month-dates.ts
|
|
6
|
-
import { getWeeksInMonth } from "@internationalized/date";
|
|
7
|
-
function getMonthDates(startDate, duration, locale) {
|
|
8
|
-
let weeksInMonth = getWeeksInMonth(startDate, locale);
|
|
9
|
-
let numOfWeeks = duration.weeks ?? weeksInMonth;
|
|
10
|
-
let weekArr = [...new Array(numOfWeeks).keys()];
|
|
11
|
-
return weekArr.map((index) => {
|
|
12
|
-
return getDatesInWeek(index, startDate, locale);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
getMonthDates
|
|
18
|
-
};
|
package/dist/chunk-SQCHVCXH.mjs
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getSegmentLimits
|
|
3
|
-
} from "./chunk-U6WRBS5P.mjs";
|
|
4
|
-
import {
|
|
5
|
-
getTodayPlaceholderDate
|
|
6
|
-
} from "./chunk-DZM5JUL2.mjs";
|
|
7
|
-
import {
|
|
8
|
-
isSegmentEditable
|
|
9
|
-
} from "./chunk-55BYHK5B.mjs";
|
|
10
|
-
|
|
11
|
-
// src/segment-parts.ts
|
|
12
|
-
function getAllSegments(segments) {
|
|
13
|
-
return segments.filter((segment) => isSegmentEditable(segment.type)).reduce((acc, segment) => (acc[segment.type] = true, acc), {});
|
|
14
|
-
}
|
|
15
|
-
function getPlaceholder(options) {
|
|
16
|
-
const placeholder = { day: "dd", month: "mm", year: "yyyy" };
|
|
17
|
-
return placeholder[options.field];
|
|
18
|
-
}
|
|
19
|
-
function getSegments(date, validSegments, formatter, timeZone) {
|
|
20
|
-
const dateValue = date || getTodayPlaceholderDate(timeZone);
|
|
21
|
-
const segments = formatter.formatToParts(dateValue.toDate(timeZone));
|
|
22
|
-
return segments.map((segment) => {
|
|
23
|
-
let isEditable = isSegmentEditable(segment.type);
|
|
24
|
-
if (segment.type === "era")
|
|
25
|
-
isEditable = false;
|
|
26
|
-
let isPlaceholder = isSegmentEditable(segment.type) && !validSegments[segment.type];
|
|
27
|
-
let placeholder = isSegmentEditable(segment.type) ? getPlaceholder({ field: segment.type }) : null;
|
|
28
|
-
return {
|
|
29
|
-
type: segment.type,
|
|
30
|
-
text: isPlaceholder ? placeholder : segment.value,
|
|
31
|
-
...getSegmentLimits(dateValue, segment.type, formatter.resolvedOptions()),
|
|
32
|
-
isPlaceholder: !!isPlaceholder,
|
|
33
|
-
placeholder,
|
|
34
|
-
isEditable: !!isEditable
|
|
35
|
-
};
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export {
|
|
40
|
-
getAllSegments,
|
|
41
|
-
getSegments
|
|
42
|
-
};
|
package/dist/chunk-TSOWYV6W.mjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// src/get-formatter.ts
|
|
2
|
-
function getEraFormat(date) {
|
|
3
|
-
return date?.calendar.identifier === "gregory" && date.era === "BC" ? "short" : void 0;
|
|
4
|
-
}
|
|
5
|
-
function getDateFormatter(startDate, endDate, getDateFormatter2, timeZone) {
|
|
6
|
-
let start = startDate;
|
|
7
|
-
let end = endDate ?? startDate;
|
|
8
|
-
let era = getEraFormat(start) || getEraFormat(end);
|
|
9
|
-
return getDateFormatter2({
|
|
10
|
-
weekday: "long",
|
|
11
|
-
month: "long",
|
|
12
|
-
year: "numeric",
|
|
13
|
-
day: "numeric",
|
|
14
|
-
era,
|
|
15
|
-
timeZone
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
function getMonthFormatter(startDate, endDate, getDateFormatter2, timeZone) {
|
|
19
|
-
let start = startDate;
|
|
20
|
-
let end = endDate ?? startDate;
|
|
21
|
-
let era = getEraFormat(start) || getEraFormat(end);
|
|
22
|
-
return getDateFormatter2({
|
|
23
|
-
month: "long",
|
|
24
|
-
year: "numeric",
|
|
25
|
-
era,
|
|
26
|
-
calendar: start?.calendar.identifier,
|
|
27
|
-
timeZone
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export {
|
|
32
|
-
getDateFormatter,
|
|
33
|
-
getMonthFormatter
|
|
34
|
-
};
|
package/dist/chunk-U6WRBS5P.mjs
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
// src/segment-limit.ts
|
|
2
|
-
import { getMinimumDayInMonth, getMinimumMonthInYear } from "@internationalized/date";
|
|
3
|
-
function getSegmentLimits(date, type, options) {
|
|
4
|
-
switch (type) {
|
|
5
|
-
case "era": {
|
|
6
|
-
let eras = date.calendar.getEras();
|
|
7
|
-
return {
|
|
8
|
-
value: eras.indexOf(date.era),
|
|
9
|
-
min: 0,
|
|
10
|
-
max: eras.length - 1
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
case "year":
|
|
14
|
-
return {
|
|
15
|
-
value: date.year,
|
|
16
|
-
min: 1,
|
|
17
|
-
max: date.calendar.getYearsInEra(date)
|
|
18
|
-
};
|
|
19
|
-
case "month":
|
|
20
|
-
return {
|
|
21
|
-
value: date.month,
|
|
22
|
-
min: getMinimumMonthInYear(date),
|
|
23
|
-
max: date.calendar.getMonthsInYear(date)
|
|
24
|
-
};
|
|
25
|
-
case "day":
|
|
26
|
-
return {
|
|
27
|
-
value: date.day,
|
|
28
|
-
min: getMinimumDayInMonth(date),
|
|
29
|
-
max: date.calendar.getDaysInMonth(date)
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
if ("hour" in date) {
|
|
33
|
-
switch (type) {
|
|
34
|
-
case "dayPeriod":
|
|
35
|
-
return {
|
|
36
|
-
value: date.hour >= 12 ? 12 : 0,
|
|
37
|
-
min: 0,
|
|
38
|
-
max: 12
|
|
39
|
-
};
|
|
40
|
-
case "hour":
|
|
41
|
-
if (options?.hour12) {
|
|
42
|
-
let isPM = date.hour >= 12;
|
|
43
|
-
return {
|
|
44
|
-
value: date.hour,
|
|
45
|
-
min: isPM ? 12 : 0,
|
|
46
|
-
max: isPM ? 23 : 11
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
value: date.hour,
|
|
51
|
-
min: 0,
|
|
52
|
-
max: 23
|
|
53
|
-
};
|
|
54
|
-
case "minute":
|
|
55
|
-
return {
|
|
56
|
-
value: date.minute,
|
|
57
|
-
min: 0,
|
|
58
|
-
max: 59
|
|
59
|
-
};
|
|
60
|
-
case "second":
|
|
61
|
-
return {
|
|
62
|
-
value: date.second,
|
|
63
|
-
min: 0,
|
|
64
|
-
max: 59
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
value: -1,
|
|
70
|
-
min: -1,
|
|
71
|
-
max: -1
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export {
|
|
76
|
-
getSegmentLimits
|
|
77
|
-
};
|
package/dist/get-formatter.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as _internationalized_date from '@internationalized/date';
|
|
2
|
-
import { CalendarDate } from '@internationalized/date';
|
|
3
|
-
import { GetFormatterFn } from './types.js';
|
|
4
|
-
|
|
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;
|
|
7
|
-
|
|
8
|
-
export { getDateFormatter, getMonthFormatter };
|
package/dist/get-formatter.mjs
DELETED
package/dist/get-month-dates.mjs
DELETED
package/dist/get-week-dates.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CalendarDate } from '@internationalized/date';
|
|
2
|
-
|
|
3
|
-
type DatesInWeek = (CalendarDate | null)[];
|
|
4
|
-
declare function getDatesInWeek(weekIndex: number, fromDate: CalendarDate, locale: string): (CalendarDate | null)[];
|
|
5
|
-
declare function getWeekDates(fromDate: CalendarDate, timeZone: string, locale: string): Date[];
|
|
6
|
-
|
|
7
|
-
export { DatesInWeek, getDatesInWeek, getWeekDates };
|