@serendie/ui 2.1.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +79 -74
- package/dist/components/Accordion/Accordion.d.ts +1 -1
- package/dist/components/Avatar/Avatar.d.ts +1 -1
- package/dist/components/Banner/Banner.d.ts +1 -1
- package/dist/components/BottomNavigation/BottomNavigationItem.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +2 -2
- package/dist/components/Button/Button.js +22 -21
- package/dist/components/DatePicker/DatePicker.d.ts +13 -0
- package/dist/components/DatePicker/DatePicker.js +203 -0
- package/dist/components/DatePicker/index.d.ts +2 -0
- package/dist/components/DatePicker/index.js +6 -0
- package/dist/components/DatePicker/parseDate.d.ts +1 -0
- package/dist/components/DatePicker/styles.d.ts +1 -0
- package/dist/components/DatePicker/styles.js +224 -0
- package/dist/components/IconButton/IconButton.d.ts +3 -3
- package/dist/components/List/ListItem.d.ts +1 -1
- package/dist/components/ModalDialog/ModalDialog.d.ts +1 -1
- package/dist/components/NotificationBadge/NotificationBadge.d.ts +1 -1
- package/dist/components/Pagination/Pagination.d.ts +1 -1
- package/dist/components/ProgressIndicator/AnimatedArc.d.ts +6 -0
- package/dist/components/ProgressIndicator/AnimatedArc.js +46 -0
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +11 -29
- package/dist/components/ProgressIndicator/ProgressIndicator.js +201 -43
- package/dist/components/ProgressIndicator/ProgressIndicatorIndeterminate.d.ts +10 -0
- package/dist/components/ProgressIndicator/ProgressIndicatorIndeterminate.js +215 -0
- package/dist/components/ProgressIndicator/index.d.ts +4 -1
- package/dist/components/ProgressIndicator/index.js +3 -2
- package/dist/components/ProgressIndicator/util.d.ts +1 -0
- package/dist/components/ProgressIndicator/util.js +13 -0
- package/dist/components/Search/Search.d.ts +1 -1
- package/dist/components/Select/Select.d.ts +1 -1
- package/dist/components/Switch/Switch.d.ts +1 -1
- package/dist/components/Tabs/Tabs.d.ts +1 -1
- package/dist/components/TextField/TextField.js +59 -156
- package/dist/components/Toast/Toast.d.ts +1 -1
- package/dist/components/TopAppBar/TopAppBar.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +80 -75
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-content.js +15 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-context.js +5 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-control.js +13 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-input.js +14 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-label.js +13 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-month-select.js +13 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-next-trigger.js +14 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-positioner.js +14 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-prev-trigger.js +14 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-root.js +55 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-table-body.js +14 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-table-cell-trigger.js +19 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-table-cell.js +26 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-table-head.js +14 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-table-header.js +14 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-table-row.js +14 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-table.js +16 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-trigger.js +13 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-view-control.js +14 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-view.js +23 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker-year-select.js +13 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/date-picker.anatomy.js +5 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/use-date-picker-context.js +10 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/use-date-picker-table-cell-props-context.js +10 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/use-date-picker-table-props-context.js +10 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/use-date-picker-view-props-context.js +12 -0
- package/dist/node_modules/@ark-ui/react/dist/components/date-picker/use-date-picker.js +18 -0
- package/dist/node_modules/@ark-ui/react/dist/components/factory.js +11 -12
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-root.js +5 -4
- package/dist/node_modules/@ark-ui/react/dist/utils/use-event.js +0 -1
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +36 -36
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +238 -235
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +88 -83
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +68 -67
- package/dist/node_modules/@internationalized/date/dist/CalendarDate.js +178 -0
- package/dist/node_modules/@internationalized/date/dist/DateFormatter.js +99 -0
- package/dist/node_modules/@internationalized/date/dist/GregorianCalendar.js +98 -0
- package/dist/node_modules/@internationalized/date/dist/conversion.js +135 -0
- package/dist/node_modules/@internationalized/date/dist/manipulation.js +205 -0
- package/dist/node_modules/@internationalized/date/dist/queries.js +202 -0
- package/dist/node_modules/@internationalized/date/dist/string.js +41 -0
- package/dist/node_modules/@internationalized/date/dist/utils.js +6 -0
- package/dist/node_modules/@internationalized/date/dist/weekStartData.js +100 -0
- package/dist/node_modules/@swc/helpers/esm/_check_private_redeclaration.js +7 -0
- package/dist/node_modules/@swc/helpers/esm/_class_private_field_init.js +7 -0
- package/dist/node_modules/@zag-js/anatomy/dist/index.js +15 -14
- package/dist/node_modules/@zag-js/aria-hidden/dist/index.js +23 -23
- package/dist/node_modules/@zag-js/collection/dist/index.js +102 -71
- package/dist/node_modules/@zag-js/combobox/dist/index.js +482 -426
- package/dist/node_modules/@zag-js/date-picker/dist/index.js +1826 -0
- package/dist/node_modules/@zag-js/date-utils/dist/index.js +366 -0
- package/dist/node_modules/@zag-js/dialog/dist/index.js +66 -64
- package/dist/node_modules/@zag-js/dismissable/dist/index.js +94 -69
- package/dist/node_modules/@zag-js/dom-query/dist/index.js +359 -300
- package/dist/node_modules/@zag-js/live-region/dist/index.js +39 -0
- package/dist/node_modules/@zag-js/menu/dist/index.js +357 -340
- package/dist/node_modules/@zag-js/popper/dist/index.js +123 -120
- package/dist/node_modules/@zag-js/presence/dist/index.js +17 -17
- package/dist/node_modules/@zag-js/radio-group/dist/index.js +118 -117
- package/dist/node_modules/@zag-js/react/dist/index.js +124 -121
- package/dist/node_modules/@zag-js/select/dist/index.js +211 -197
- package/dist/node_modules/@zag-js/toast/dist/index.js +73 -71
- package/dist/node_modules/@zag-js/tooltip/dist/index.js +31 -30
- package/dist/node_modules/@zag-js/utils/dist/index.js +150 -104
- package/dist/preset.d.ts +11 -1
- package/dist/recipes/index.d.ts +3 -2
- package/dist/recipes/index.js +5 -2
- package/dist/recipes/textFieldRecipe.d.ts +6 -0
- package/dist/recipes/textFieldRecipe.js +107 -0
- package/dist/styled-system/css/cva.js +43 -38
- package/dist/styled-system/recipes/create-recipe.js +37 -0
- package/dist/styled-system/recipes/text-field-recipe.js +61 -0
- package/dist/styles.css +1 -1
- package/dist/tokens/keyframes/index.d.ts +8 -0
- package/dist/tokens/keyframes/index.js +6 -2
- package/package.json +3 -3
- package/styled-system/recipes/create-recipe.js +82 -0
- package/styled-system/recipes/index.d.ts +2 -0
- package/styled-system/recipes/index.js +1 -0
- package/styled-system/recipes/text-field-recipe.d.ts +28 -0
- package/styled-system/recipes/text-field-recipe.js +72 -0
- package/styled-system/types/prop-type.d.ts +1 -1
- package/dist/node_modules/@zag-js/store/dist/index.js +0 -131
- package/dist/node_modules/proxy-compare/dist/index.js +0 -7
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
let n = /* @__PURE__ */ new Map();
|
|
2
|
+
class c {
|
|
3
|
+
/** Formats a date as a string according to the locale and format options passed to the constructor. */
|
|
4
|
+
format(e) {
|
|
5
|
+
return this.formatter.format(e);
|
|
6
|
+
}
|
|
7
|
+
/** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */
|
|
8
|
+
formatToParts(e) {
|
|
9
|
+
return this.formatter.formatToParts(e);
|
|
10
|
+
}
|
|
11
|
+
/** Formats a date range as a string. */
|
|
12
|
+
formatRange(e, r) {
|
|
13
|
+
if (typeof this.formatter.formatRange == "function")
|
|
14
|
+
return this.formatter.formatRange(e, r);
|
|
15
|
+
if (r < e) throw new RangeError("End date must be >= start date");
|
|
16
|
+
return `${this.formatter.format(e)} – ${this.formatter.format(r)}`;
|
|
17
|
+
}
|
|
18
|
+
/** Formats a date range as an array of parts. */
|
|
19
|
+
formatRangeToParts(e, r) {
|
|
20
|
+
if (typeof this.formatter.formatRangeToParts == "function")
|
|
21
|
+
return this.formatter.formatRangeToParts(e, r);
|
|
22
|
+
if (r < e) throw new RangeError("End date must be >= start date");
|
|
23
|
+
let u = this.formatter.formatToParts(e), t = this.formatter.formatToParts(r);
|
|
24
|
+
return [
|
|
25
|
+
...u.map((a) => ({
|
|
26
|
+
...a,
|
|
27
|
+
source: "startRange"
|
|
28
|
+
})),
|
|
29
|
+
{
|
|
30
|
+
type: "literal",
|
|
31
|
+
value: " – ",
|
|
32
|
+
source: "shared"
|
|
33
|
+
},
|
|
34
|
+
...t.map((a) => ({
|
|
35
|
+
...a,
|
|
36
|
+
source: "endRange"
|
|
37
|
+
}))
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
/** Returns the resolved formatting options based on the values passed to the constructor. */
|
|
41
|
+
resolvedOptions() {
|
|
42
|
+
let e = this.formatter.resolvedOptions();
|
|
43
|
+
return m() && (this.resolvedHourCycle || (this.resolvedHourCycle = d(e.locale, this.options)), e.hourCycle = this.resolvedHourCycle, e.hour12 = this.resolvedHourCycle === "h11" || this.resolvedHourCycle === "h12"), e.calendar === "ethiopic-amete-alem" && (e.calendar = "ethioaa"), e;
|
|
44
|
+
}
|
|
45
|
+
constructor(e, r = {}) {
|
|
46
|
+
this.formatter = h(e, r), this.options = r;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const l = {
|
|
50
|
+
true: {
|
|
51
|
+
// Only Japanese uses the h11 style for 12 hour time. All others use h12.
|
|
52
|
+
ja: "h11"
|
|
53
|
+
},
|
|
54
|
+
false: {}
|
|
55
|
+
};
|
|
56
|
+
function h(o, e = {}) {
|
|
57
|
+
if (typeof e.hour12 == "boolean" && i()) {
|
|
58
|
+
e = {
|
|
59
|
+
...e
|
|
60
|
+
};
|
|
61
|
+
let t = l[String(e.hour12)][o.split("-")[0]], a = e.hour12 ? "h12" : "h23";
|
|
62
|
+
e.hourCycle = t ?? a, delete e.hour12;
|
|
63
|
+
}
|
|
64
|
+
let r = o + (e ? Object.entries(e).sort((t, a) => t[0] < a[0] ? -1 : 1).join() : "");
|
|
65
|
+
if (n.has(r)) return n.get(r);
|
|
66
|
+
let u = new Intl.DateTimeFormat(o, e);
|
|
67
|
+
return n.set(r, u), u;
|
|
68
|
+
}
|
|
69
|
+
let f = null;
|
|
70
|
+
function i() {
|
|
71
|
+
return f == null && (f = new Intl.DateTimeFormat("en-US", {
|
|
72
|
+
hour: "numeric",
|
|
73
|
+
hour12: !1
|
|
74
|
+
}).format(new Date(2020, 2, 3, 0)) === "24"), f;
|
|
75
|
+
}
|
|
76
|
+
let s = null;
|
|
77
|
+
function m() {
|
|
78
|
+
return s == null && (s = new Intl.DateTimeFormat("fr", {
|
|
79
|
+
hour: "numeric",
|
|
80
|
+
hour12: !1
|
|
81
|
+
}).resolvedOptions().hourCycle === "h12"), s;
|
|
82
|
+
}
|
|
83
|
+
function d(o, e) {
|
|
84
|
+
if (!e.timeStyle && !e.hour) return;
|
|
85
|
+
o = o.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, ""), o += (o.includes("-u-") ? "" : "-u") + "-nu-latn";
|
|
86
|
+
let r = h(o, {
|
|
87
|
+
...e,
|
|
88
|
+
timeZone: void 0
|
|
89
|
+
// use local timezone
|
|
90
|
+
}), u = parseInt(r.formatToParts(new Date(2020, 2, 3, 0)).find((a) => a.type === "hour").value, 10), t = parseInt(r.formatToParts(new Date(2020, 2, 3, 23)).find((a) => a.type === "hour").value, 10);
|
|
91
|
+
if (u === 0 && t === 23) return "h23";
|
|
92
|
+
if (u === 24 && t === 23) return "h24";
|
|
93
|
+
if (u === 0 && t === 11) return "h11";
|
|
94
|
+
if (u === 12 && t === 11) return "h12";
|
|
95
|
+
throw new Error("Unexpected hour cycle result");
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
c as DateFormatter
|
|
99
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { CalendarDate as m } from "./CalendarDate.js";
|
|
2
|
+
import { mod as s } from "./utils.js";
|
|
3
|
+
const p = 1721426;
|
|
4
|
+
function b(r, e, t, l) {
|
|
5
|
+
e = C(r, e);
|
|
6
|
+
let a = e - 1, n = -2;
|
|
7
|
+
return t <= 2 ? n = 0 : d(e) && (n = -1), p - 1 + 365 * a + Math.floor(a / 4) - Math.floor(a / 100) + Math.floor(a / 400) + Math.floor((367 * t - 362) / 12 + n + l);
|
|
8
|
+
}
|
|
9
|
+
function d(r) {
|
|
10
|
+
return r % 4 === 0 && (r % 100 !== 0 || r % 400 === 0);
|
|
11
|
+
}
|
|
12
|
+
function C(r, e) {
|
|
13
|
+
return r === "BC" ? 1 - e : e;
|
|
14
|
+
}
|
|
15
|
+
function Y(r) {
|
|
16
|
+
let e = "AD";
|
|
17
|
+
return r <= 0 && (e = "BC", r = 1 - r), [
|
|
18
|
+
e,
|
|
19
|
+
r
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
const B = {
|
|
23
|
+
standard: [
|
|
24
|
+
31,
|
|
25
|
+
28,
|
|
26
|
+
31,
|
|
27
|
+
30,
|
|
28
|
+
31,
|
|
29
|
+
30,
|
|
30
|
+
31,
|
|
31
|
+
31,
|
|
32
|
+
30,
|
|
33
|
+
31,
|
|
34
|
+
30,
|
|
35
|
+
31
|
|
36
|
+
],
|
|
37
|
+
leapyear: [
|
|
38
|
+
31,
|
|
39
|
+
29,
|
|
40
|
+
31,
|
|
41
|
+
30,
|
|
42
|
+
31,
|
|
43
|
+
30,
|
|
44
|
+
31,
|
|
45
|
+
31,
|
|
46
|
+
30,
|
|
47
|
+
31,
|
|
48
|
+
30,
|
|
49
|
+
31
|
|
50
|
+
]
|
|
51
|
+
};
|
|
52
|
+
class q {
|
|
53
|
+
fromJulianDay(e) {
|
|
54
|
+
let t = e, l = t - p, a = Math.floor(l / 146097), n = s(l, 146097), $ = Math.floor(n / 36524), i = s(n, 36524), y = Math.floor(i / 1461), x = s(i, 1461), u = Math.floor(x / 365), M = a * 400 + $ * 100 + y * 4 + u + ($ !== 4 && u !== 4 ? 1 : 0), [f, o] = Y(M), g = t - b(f, o, 1, 1), c = 2;
|
|
55
|
+
t < b(f, o, 3, 1) ? c = 0 : d(o) && (c = 1);
|
|
56
|
+
let h = Math.floor(((g + c) * 12 + 373) / 367), D = t - b(f, o, h, 1) + 1;
|
|
57
|
+
return new m(f, o, h, D);
|
|
58
|
+
}
|
|
59
|
+
toJulianDay(e) {
|
|
60
|
+
return b(e.era, e.year, e.month, e.day);
|
|
61
|
+
}
|
|
62
|
+
getDaysInMonth(e) {
|
|
63
|
+
return B[d(e.year) ? "leapyear" : "standard"][e.month - 1];
|
|
64
|
+
}
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
66
|
+
getMonthsInYear(e) {
|
|
67
|
+
return 12;
|
|
68
|
+
}
|
|
69
|
+
getDaysInYear(e) {
|
|
70
|
+
return d(e.year) ? 366 : 365;
|
|
71
|
+
}
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
73
|
+
getYearsInEra(e) {
|
|
74
|
+
return 9999;
|
|
75
|
+
}
|
|
76
|
+
getEras() {
|
|
77
|
+
return [
|
|
78
|
+
"BC",
|
|
79
|
+
"AD"
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
isInverseEra(e) {
|
|
83
|
+
return e.era === "BC";
|
|
84
|
+
}
|
|
85
|
+
balanceDate(e) {
|
|
86
|
+
e.year <= 0 && (e.era = e.era === "BC" ? "AD" : "BC", e.year = 1 - e.year);
|
|
87
|
+
}
|
|
88
|
+
constructor() {
|
|
89
|
+
this.identifier = "gregory";
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
q as GregorianCalendar,
|
|
94
|
+
Y as fromExtendedYear,
|
|
95
|
+
C as getExtendedYear,
|
|
96
|
+
b as gregorianToJulianDay,
|
|
97
|
+
d as isLeapYear
|
|
98
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { CalendarDateTime as C, CalendarDate as U, ZonedDateTime as b } from "./CalendarDate.js";
|
|
2
|
+
import { constrain as M } from "./manipulation.js";
|
|
3
|
+
import { getExtendedYear as h, GregorianCalendar as p } from "./GregorianCalendar.js";
|
|
4
|
+
import { getLocalTimeZone as y, isEqualCalendar as v } from "./queries.js";
|
|
5
|
+
function u(e) {
|
|
6
|
+
e = $(e, new p());
|
|
7
|
+
let t = h(e.era, e.year);
|
|
8
|
+
return T(t, e.month, e.day, e.hour, e.minute, e.second, e.millisecond);
|
|
9
|
+
}
|
|
10
|
+
function T(e, t, n, r, o, a, c) {
|
|
11
|
+
let f = /* @__PURE__ */ new Date();
|
|
12
|
+
return f.setUTCHours(r, o, a, c), f.setUTCFullYear(e, t - 1, n), f.getTime();
|
|
13
|
+
}
|
|
14
|
+
function i(e, t) {
|
|
15
|
+
if (t === "UTC") return 0;
|
|
16
|
+
if (e > 0 && t === y()) return new Date(e).getTimezoneOffset() * -6e4;
|
|
17
|
+
let { year: n, month: r, day: o, hour: a, minute: c, second: f } = x(e, t);
|
|
18
|
+
return T(n, r, o, a, c, f, 0) - Math.floor(e / 1e3) * 1e3;
|
|
19
|
+
}
|
|
20
|
+
const m = /* @__PURE__ */ new Map();
|
|
21
|
+
function x(e, t) {
|
|
22
|
+
let n = m.get(t);
|
|
23
|
+
n || (n = new Intl.DateTimeFormat("en-US", {
|
|
24
|
+
timeZone: t,
|
|
25
|
+
hour12: !1,
|
|
26
|
+
era: "short",
|
|
27
|
+
year: "numeric",
|
|
28
|
+
month: "numeric",
|
|
29
|
+
day: "numeric",
|
|
30
|
+
hour: "numeric",
|
|
31
|
+
minute: "numeric",
|
|
32
|
+
second: "numeric"
|
|
33
|
+
}), m.set(t, n));
|
|
34
|
+
let r = n.formatToParts(new Date(e)), o = {};
|
|
35
|
+
for (let a of r) a.type !== "literal" && (o[a.type] = a.value);
|
|
36
|
+
return {
|
|
37
|
+
// Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253
|
|
38
|
+
year: o.era === "BC" || o.era === "B" ? -o.year + 1 : +o.year,
|
|
39
|
+
month: +o.month,
|
|
40
|
+
day: +o.day,
|
|
41
|
+
hour: o.hour === "24" ? 0 : +o.hour,
|
|
42
|
+
minute: +o.minute,
|
|
43
|
+
second: +o.second
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const d = 864e5;
|
|
47
|
+
function F(e, t, n, r) {
|
|
48
|
+
return (n === r ? [
|
|
49
|
+
n
|
|
50
|
+
] : [
|
|
51
|
+
n,
|
|
52
|
+
r
|
|
53
|
+
]).filter((a) => A(e, t, a));
|
|
54
|
+
}
|
|
55
|
+
function A(e, t, n) {
|
|
56
|
+
let r = x(n, t);
|
|
57
|
+
return e.year === r.year && e.month === r.month && e.day === r.day && e.hour === r.hour && e.minute === r.minute && e.second === r.second;
|
|
58
|
+
}
|
|
59
|
+
function D(e, t, n = "compatible") {
|
|
60
|
+
let r = B(e);
|
|
61
|
+
if (t === "UTC") return u(r);
|
|
62
|
+
if (t === y() && n === "compatible") {
|
|
63
|
+
r = $(r, new p());
|
|
64
|
+
let l = /* @__PURE__ */ new Date(), s = h(r.era, r.year);
|
|
65
|
+
return l.setFullYear(s, r.month - 1, r.day), l.setHours(r.hour, r.minute, r.second, r.millisecond), l.getTime();
|
|
66
|
+
}
|
|
67
|
+
let o = u(r), a = i(o - d, t), c = i(o + d, t), f = F(r, t, o - a, o - c);
|
|
68
|
+
if (f.length === 1) return f[0];
|
|
69
|
+
if (f.length > 1) switch (n) {
|
|
70
|
+
case "compatible":
|
|
71
|
+
case "earlier":
|
|
72
|
+
return f[0];
|
|
73
|
+
case "later":
|
|
74
|
+
return f[f.length - 1];
|
|
75
|
+
case "reject":
|
|
76
|
+
throw new RangeError("Multiple possible absolute times found");
|
|
77
|
+
}
|
|
78
|
+
switch (n) {
|
|
79
|
+
case "earlier":
|
|
80
|
+
return Math.min(o - a, o - c);
|
|
81
|
+
case "compatible":
|
|
82
|
+
case "later":
|
|
83
|
+
return Math.max(o - a, o - c);
|
|
84
|
+
case "reject":
|
|
85
|
+
throw new RangeError("No such absolute time found");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function L(e, t, n = "compatible") {
|
|
89
|
+
return new Date(D(e, t, n));
|
|
90
|
+
}
|
|
91
|
+
function g(e, t) {
|
|
92
|
+
let n = i(e, t), r = new Date(e + n), o = r.getUTCFullYear(), a = r.getUTCMonth() + 1, c = r.getUTCDate(), f = r.getUTCHours(), l = r.getUTCMinutes(), s = r.getUTCSeconds(), w = r.getUTCMilliseconds();
|
|
93
|
+
return new b(o < 1 ? "BC" : "AD", o < 1 ? -o + 1 : o, a, c, t, n, f, l, s, w);
|
|
94
|
+
}
|
|
95
|
+
function S(e) {
|
|
96
|
+
return new U(e.calendar, e.era, e.year, e.month, e.day);
|
|
97
|
+
}
|
|
98
|
+
function B(e, t) {
|
|
99
|
+
let n = 0, r = 0, o = 0, a = 0;
|
|
100
|
+
if ("timeZone" in e) ({ hour: n, minute: r, second: o, millisecond: a } = e);
|
|
101
|
+
else if ("hour" in e && !t) return e;
|
|
102
|
+
return t && ({ hour: n, minute: r, second: o, millisecond: a } = t), new C(e.calendar, e.era, e.year, e.month, e.day, n, r, o, a);
|
|
103
|
+
}
|
|
104
|
+
function $(e, t) {
|
|
105
|
+
if (v(e.calendar, t)) return e;
|
|
106
|
+
let n = t.fromJulianDay(e.calendar.toJulianDay(e)), r = e.copy();
|
|
107
|
+
return r.calendar = t, r.era = n.era, r.year = n.year, r.month = n.month, r.day = n.day, M(r), r;
|
|
108
|
+
}
|
|
109
|
+
function j(e, t, n) {
|
|
110
|
+
if (e instanceof b)
|
|
111
|
+
return e.timeZone === t ? e : Y(e, t);
|
|
112
|
+
let r = D(e, t, n);
|
|
113
|
+
return g(r, t);
|
|
114
|
+
}
|
|
115
|
+
function z(e) {
|
|
116
|
+
let t = u(e) - e.offset;
|
|
117
|
+
return new Date(t);
|
|
118
|
+
}
|
|
119
|
+
function Y(e, t) {
|
|
120
|
+
let n = u(e) - e.offset;
|
|
121
|
+
return $(g(n, t), e.calendar);
|
|
122
|
+
}
|
|
123
|
+
export {
|
|
124
|
+
u as epochFromDate,
|
|
125
|
+
g as fromAbsolute,
|
|
126
|
+
i as getTimeZoneOffset,
|
|
127
|
+
D as toAbsolute,
|
|
128
|
+
$ as toCalendar,
|
|
129
|
+
S as toCalendarDate,
|
|
130
|
+
B as toCalendarDateTime,
|
|
131
|
+
L as toDate,
|
|
132
|
+
Y as toTimeZone,
|
|
133
|
+
j as toZoned,
|
|
134
|
+
z as zonedToDate
|
|
135
|
+
};
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { toCalendarDateTime as M, toAbsolute as h, epochFromDate as Z, fromAbsolute as $, toCalendar as y } from "./conversion.js";
|
|
2
|
+
import { GregorianCalendar as g } from "./GregorianCalendar.js";
|
|
3
|
+
const i = 36e5;
|
|
4
|
+
function Y(e, r) {
|
|
5
|
+
let n = e.copy(), a = "hour" in n ? N(n, r) : 0;
|
|
6
|
+
x(n, r.years || 0), n.calendar.balanceYearMonth && n.calendar.balanceYearMonth(n, e), n.month += r.months || 0, D(n), k(n), n.day += (r.weeks || 0) * 7, n.day += r.days || 0, n.day += a, A(n), n.calendar.balanceDate && n.calendar.balanceDate(n), n.year < 1 && (n.year = 1, n.month = 1, n.day = 1);
|
|
7
|
+
let c = n.calendar.getYearsInEra(n);
|
|
8
|
+
if (n.year > c) {
|
|
9
|
+
var l, t;
|
|
10
|
+
let d = (l = (t = n.calendar).isInverseEra) === null || l === void 0 ? void 0 : l.call(t, n);
|
|
11
|
+
n.year = c, n.month = d ? 1 : n.calendar.getMonthsInYear(n), n.day = d ? 1 : n.calendar.getDaysInMonth(n);
|
|
12
|
+
}
|
|
13
|
+
n.month < 1 && (n.month = 1, n.day = 1);
|
|
14
|
+
let o = n.calendar.getMonthsInYear(n);
|
|
15
|
+
return n.month > o && (n.month = o, n.day = n.calendar.getDaysInMonth(n)), n.day = Math.max(1, Math.min(n.calendar.getDaysInMonth(n), n.day)), n;
|
|
16
|
+
}
|
|
17
|
+
function x(e, r) {
|
|
18
|
+
var n, a;
|
|
19
|
+
!((n = (a = e.calendar).isInverseEra) === null || n === void 0) && n.call(a, e) && (r = -r), e.year += r;
|
|
20
|
+
}
|
|
21
|
+
function D(e) {
|
|
22
|
+
for (; e.month < 1; )
|
|
23
|
+
x(e, -1), e.month += e.calendar.getMonthsInYear(e);
|
|
24
|
+
let r = 0;
|
|
25
|
+
for (; e.month > (r = e.calendar.getMonthsInYear(e)); )
|
|
26
|
+
e.month -= r, x(e, 1);
|
|
27
|
+
}
|
|
28
|
+
function A(e) {
|
|
29
|
+
for (; e.day < 1; )
|
|
30
|
+
e.month--, D(e), e.day += e.calendar.getDaysInMonth(e);
|
|
31
|
+
for (; e.day > e.calendar.getDaysInMonth(e); )
|
|
32
|
+
e.day -= e.calendar.getDaysInMonth(e), e.month++, D(e);
|
|
33
|
+
}
|
|
34
|
+
function k(e) {
|
|
35
|
+
e.month = Math.max(1, Math.min(e.calendar.getMonthsInYear(e), e.month)), e.day = Math.max(1, Math.min(e.calendar.getDaysInMonth(e), e.day));
|
|
36
|
+
}
|
|
37
|
+
function w(e) {
|
|
38
|
+
e.calendar.constrainDate && e.calendar.constrainDate(e), e.year = Math.max(1, Math.min(e.calendar.getYearsInEra(e), e.year)), k(e);
|
|
39
|
+
}
|
|
40
|
+
function v(e) {
|
|
41
|
+
let r = {};
|
|
42
|
+
for (let n in e) typeof e[n] == "number" && (r[n] = -e[n]);
|
|
43
|
+
return r;
|
|
44
|
+
}
|
|
45
|
+
function j(e, r) {
|
|
46
|
+
return Y(e, v(r));
|
|
47
|
+
}
|
|
48
|
+
function U(e, r) {
|
|
49
|
+
let n = e.copy();
|
|
50
|
+
return r.era != null && (n.era = r.era), r.year != null && (n.year = r.year), r.month != null && (n.month = r.month), r.day != null && (n.day = r.day), w(n), n;
|
|
51
|
+
}
|
|
52
|
+
function I(e, r) {
|
|
53
|
+
let n = e.copy();
|
|
54
|
+
return r.hour != null && (n.hour = r.hour), r.minute != null && (n.minute = r.minute), r.second != null && (n.second = r.second), r.millisecond != null && (n.millisecond = r.millisecond), F(n), n;
|
|
55
|
+
}
|
|
56
|
+
function O(e) {
|
|
57
|
+
e.second += Math.floor(e.millisecond / 1e3), e.millisecond = b(e.millisecond, 1e3), e.minute += Math.floor(e.second / 60), e.second = b(e.second, 60), e.hour += Math.floor(e.minute / 60), e.minute = b(e.minute, 60);
|
|
58
|
+
let r = Math.floor(e.hour / 24);
|
|
59
|
+
return e.hour = b(e.hour, 24), r;
|
|
60
|
+
}
|
|
61
|
+
function F(e) {
|
|
62
|
+
e.millisecond = Math.max(0, Math.min(e.millisecond, 1e3)), e.second = Math.max(0, Math.min(e.second, 59)), e.minute = Math.max(0, Math.min(e.minute, 59)), e.hour = Math.max(0, Math.min(e.hour, 23));
|
|
63
|
+
}
|
|
64
|
+
function b(e, r) {
|
|
65
|
+
let n = e % r;
|
|
66
|
+
return n < 0 && (n += r), n;
|
|
67
|
+
}
|
|
68
|
+
function N(e, r) {
|
|
69
|
+
return e.hour += r.hours || 0, e.minute += r.minutes || 0, e.second += r.seconds || 0, e.millisecond += r.milliseconds || 0, O(e);
|
|
70
|
+
}
|
|
71
|
+
function P(e, r, n, a) {
|
|
72
|
+
let c = e.copy();
|
|
73
|
+
switch (r) {
|
|
74
|
+
case "era": {
|
|
75
|
+
let o = e.calendar.getEras(), d = o.indexOf(e.era);
|
|
76
|
+
if (d < 0) throw new Error("Invalid era: " + e.era);
|
|
77
|
+
d = s(d, n, 0, o.length - 1, a == null ? void 0 : a.round), c.era = o[d], w(c);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case "year":
|
|
81
|
+
var l, t;
|
|
82
|
+
!((l = (t = c.calendar).isInverseEra) === null || l === void 0) && l.call(t, c) && (n = -n), c.year = s(e.year, n, -1 / 0, 9999, a == null ? void 0 : a.round), c.year === -1 / 0 && (c.year = 1), c.calendar.balanceYearMonth && c.calendar.balanceYearMonth(c, e);
|
|
83
|
+
break;
|
|
84
|
+
case "month":
|
|
85
|
+
c.month = s(e.month, n, 1, e.calendar.getMonthsInYear(e), a == null ? void 0 : a.round);
|
|
86
|
+
break;
|
|
87
|
+
case "day":
|
|
88
|
+
c.day = s(e.day, n, 1, e.calendar.getDaysInMonth(e), a == null ? void 0 : a.round);
|
|
89
|
+
break;
|
|
90
|
+
default:
|
|
91
|
+
throw new Error("Unsupported field " + r);
|
|
92
|
+
}
|
|
93
|
+
return e.calendar.balanceDate && e.calendar.balanceDate(c), w(c), c;
|
|
94
|
+
}
|
|
95
|
+
function V(e, r, n, a) {
|
|
96
|
+
let c = e.copy();
|
|
97
|
+
switch (r) {
|
|
98
|
+
case "hour": {
|
|
99
|
+
let l = e.hour, t = 0, o = 23;
|
|
100
|
+
if ((a == null ? void 0 : a.hourCycle) === 12) {
|
|
101
|
+
let d = l >= 12;
|
|
102
|
+
t = d ? 12 : 0, o = d ? 23 : 11;
|
|
103
|
+
}
|
|
104
|
+
c.hour = s(l, n, t, o, a == null ? void 0 : a.round);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case "minute":
|
|
108
|
+
c.minute = s(e.minute, n, 0, 59, a == null ? void 0 : a.round);
|
|
109
|
+
break;
|
|
110
|
+
case "second":
|
|
111
|
+
c.second = s(e.second, n, 0, 59, a == null ? void 0 : a.round);
|
|
112
|
+
break;
|
|
113
|
+
case "millisecond":
|
|
114
|
+
c.millisecond = s(e.millisecond, n, 0, 999, a == null ? void 0 : a.round);
|
|
115
|
+
break;
|
|
116
|
+
default:
|
|
117
|
+
throw new Error("Unsupported field " + r);
|
|
118
|
+
}
|
|
119
|
+
return c;
|
|
120
|
+
}
|
|
121
|
+
function s(e, r, n, a, c = !1) {
|
|
122
|
+
if (c) {
|
|
123
|
+
e += Math.sign(r), e < n && (e = a);
|
|
124
|
+
let l = Math.abs(r);
|
|
125
|
+
r > 0 ? e = Math.ceil(e / l) * l : e = Math.floor(e / l) * l, e > a && (e = n);
|
|
126
|
+
} else
|
|
127
|
+
e += r, e < n ? e = a - (n - e - 1) : e > a && (e = n + (e - a - 1));
|
|
128
|
+
return e;
|
|
129
|
+
}
|
|
130
|
+
function G(e, r) {
|
|
131
|
+
let n;
|
|
132
|
+
if (r.years != null && r.years !== 0 || r.months != null && r.months !== 0 || r.weeks != null && r.weeks !== 0 || r.days != null && r.days !== 0) {
|
|
133
|
+
let c = Y(M(e), {
|
|
134
|
+
years: r.years,
|
|
135
|
+
months: r.months,
|
|
136
|
+
weeks: r.weeks,
|
|
137
|
+
days: r.days
|
|
138
|
+
});
|
|
139
|
+
n = h(c, e.timeZone);
|
|
140
|
+
} else
|
|
141
|
+
n = Z(e) - e.offset;
|
|
142
|
+
n += r.milliseconds || 0, n += (r.seconds || 0) * 1e3, n += (r.minutes || 0) * 6e4, n += (r.hours || 0) * 36e5;
|
|
143
|
+
let a = $(n, e.timeZone);
|
|
144
|
+
return y(a, e.calendar);
|
|
145
|
+
}
|
|
146
|
+
function q(e, r) {
|
|
147
|
+
return G(e, v(r));
|
|
148
|
+
}
|
|
149
|
+
function z(e, r, n, a) {
|
|
150
|
+
switch (r) {
|
|
151
|
+
case "hour": {
|
|
152
|
+
let c = 0, l = 23;
|
|
153
|
+
if ((a == null ? void 0 : a.hourCycle) === 12) {
|
|
154
|
+
let f = e.hour >= 12;
|
|
155
|
+
c = f ? 12 : 0, l = f ? 23 : 11;
|
|
156
|
+
}
|
|
157
|
+
let t = M(e), o = y(I(t, {
|
|
158
|
+
hour: c
|
|
159
|
+
}), new g()), d = [
|
|
160
|
+
h(o, e.timeZone, "earlier"),
|
|
161
|
+
h(o, e.timeZone, "later")
|
|
162
|
+
].filter((f) => $(f, e.timeZone).day === o.day)[0], m = y(I(t, {
|
|
163
|
+
hour: l
|
|
164
|
+
}), new g()), E = [
|
|
165
|
+
h(m, e.timeZone, "earlier"),
|
|
166
|
+
h(m, e.timeZone, "later")
|
|
167
|
+
].filter((f) => $(f, e.timeZone).day === m.day).pop(), u = Z(e) - e.offset, p = Math.floor(u / i), C = u % i;
|
|
168
|
+
return u = s(p, n, Math.floor(d / i), Math.floor(E / i), a == null ? void 0 : a.round) * i + C, y($(u, e.timeZone), e.calendar);
|
|
169
|
+
}
|
|
170
|
+
case "minute":
|
|
171
|
+
case "second":
|
|
172
|
+
case "millisecond":
|
|
173
|
+
return V(e, r, n, a);
|
|
174
|
+
case "era":
|
|
175
|
+
case "year":
|
|
176
|
+
case "month":
|
|
177
|
+
case "day": {
|
|
178
|
+
let c = P(M(e), r, n, a), l = h(c, e.timeZone);
|
|
179
|
+
return y($(l, e.timeZone), e.calendar);
|
|
180
|
+
}
|
|
181
|
+
default:
|
|
182
|
+
throw new Error("Unsupported field " + r);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function B(e, r, n) {
|
|
186
|
+
let a = M(e), c = I(U(a, r), r);
|
|
187
|
+
if (c.compare(a) === 0) return e;
|
|
188
|
+
let l = h(c, e.timeZone, n);
|
|
189
|
+
return y($(l, e.timeZone), e.calendar);
|
|
190
|
+
}
|
|
191
|
+
export {
|
|
192
|
+
Y as add,
|
|
193
|
+
G as addZoned,
|
|
194
|
+
w as constrain,
|
|
195
|
+
F as constrainTime,
|
|
196
|
+
P as cycleDate,
|
|
197
|
+
V as cycleTime,
|
|
198
|
+
z as cycleZoned,
|
|
199
|
+
v as invertDuration,
|
|
200
|
+
U as set,
|
|
201
|
+
I as setTime,
|
|
202
|
+
B as setZoned,
|
|
203
|
+
j as subtract,
|
|
204
|
+
q as subtractZoned
|
|
205
|
+
};
|