@theengineerguy/chronos-picker 1.0.5 → 1.0.6
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/index.esm.js +281 -247
- package/dist/index.js +1 -1
- package/dist/src/constants/holidays.d.ts +5 -0
- package/dist/src/constants/holidays.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as h, jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { DateTime as
|
|
2
|
+
import { useMemo as Y, useState as S, useEffect as B, useRef as Q, useCallback as G } from "react";
|
|
3
|
+
import { DateTime as w } from "luxon";
|
|
4
4
|
const me = "Asia/Kolkata", X = [
|
|
5
5
|
{ value: "Asia/Kolkata", label: "India (IST)" },
|
|
6
6
|
{ value: "America/New_York", label: "Eastern Time (ET)" },
|
|
@@ -15,113 +15,113 @@ const me = "Asia/Kolkata", X = [
|
|
|
15
15
|
{ value: "Australia/Sydney", label: "Sydney (AEDT)" },
|
|
16
16
|
{ value: "UTC", label: "UTC" }
|
|
17
17
|
];
|
|
18
|
-
function
|
|
19
|
-
return
|
|
18
|
+
function L(e, i) {
|
|
19
|
+
return w.isDateTime(e) ? e.setZone(i) : typeof e == "string" ? w.fromISO(e, { zone: i }) : w.fromJSDate(e, { zone: i });
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
21
|
+
function H(e) {
|
|
22
|
+
return w.now().setZone(e);
|
|
23
23
|
}
|
|
24
24
|
function F(e) {
|
|
25
|
-
const
|
|
26
|
-
return `UTC${
|
|
25
|
+
const s = w.now().setZone(e).offset, l = Math.floor(Math.abs(s) / 60), c = Math.abs(s) % 60;
|
|
26
|
+
return `UTC${s >= 0 ? "+" : "-"}${l}${c > 0 ? `:${c.toString().padStart(2, "0")}` : ""}`;
|
|
27
27
|
}
|
|
28
|
-
function ue(e,
|
|
29
|
-
const
|
|
30
|
-
{ year: e, month:
|
|
31
|
-
{ zone:
|
|
32
|
-
),
|
|
33
|
-
|
|
34
|
-
let
|
|
35
|
-
|
|
28
|
+
function ue(e, i, s, l, c, v, d, y, g) {
|
|
29
|
+
const M = w.fromObject(
|
|
30
|
+
{ year: e, month: i, day: 1 },
|
|
31
|
+
{ zone: s }
|
|
32
|
+
), I = M.startOf("week"), R = M.endOf("month").endOf("week"), E = w.now().setZone(s).startOf("day"), P = d != null && y != null, O = d == null ? void 0 : d.startOf("day"), x = y == null ? void 0 : y.endOf("day"), n = /* @__PURE__ */ new Map();
|
|
33
|
+
g && g.forEach((b) => {
|
|
34
|
+
let T;
|
|
35
|
+
w.isDateTime(b.date) ? T = b.date.setZone(s) : typeof b.date == "string" ? T = w.fromISO(b.date, { zone: s }) : T = w.fromJSDate(b.date, { zone: s }), n.set(T.toISODate() || "", { name: b.name, type: b.type || "national" });
|
|
36
36
|
});
|
|
37
37
|
const u = [];
|
|
38
|
-
let $ = [],
|
|
39
|
-
for (;
|
|
40
|
-
const
|
|
41
|
-
let
|
|
42
|
-
P &&
|
|
43
|
-
let
|
|
44
|
-
c &&
|
|
45
|
-
const
|
|
38
|
+
let $ = [], r = I;
|
|
39
|
+
for (; r <= R; ) {
|
|
40
|
+
const b = r.month === i, T = r.hasSame(E, "day"), t = r.startOf("day"), p = r.toISODate() || "";
|
|
41
|
+
let a = !1, C = !1, N = !1, W = !1;
|
|
42
|
+
P && O && x ? (N = t.hasSame(O, "day"), W = t.hasSame(x, "day"), C = t >= O && t <= x || N || W, a = N || W) : l && (a = r.hasSame(l, "day"));
|
|
43
|
+
let k = !1;
|
|
44
|
+
c && r < c.startOf("day") && (k = !0), v && r > v.endOf("day") && (k = !0);
|
|
45
|
+
const K = n.get(p);
|
|
46
46
|
$.push({
|
|
47
|
-
date:
|
|
48
|
-
isCurrentMonth:
|
|
49
|
-
isToday:
|
|
50
|
-
isSelected:
|
|
51
|
-
isDisabled:
|
|
47
|
+
date: r,
|
|
48
|
+
isCurrentMonth: b,
|
|
49
|
+
isToday: T,
|
|
50
|
+
isSelected: a,
|
|
51
|
+
isDisabled: k,
|
|
52
52
|
isInRange: C,
|
|
53
|
-
isRangeStart:
|
|
54
|
-
isRangeEnd:
|
|
55
|
-
holiday:
|
|
56
|
-
}), $.length === 7 && (u.push($), $ = []),
|
|
53
|
+
isRangeStart: N,
|
|
54
|
+
isRangeEnd: W,
|
|
55
|
+
holiday: K ? { date: r, ...K } : void 0
|
|
56
|
+
}), $.length === 7 && (u.push($), $ = []), r = r.plus({ days: 1 });
|
|
57
57
|
}
|
|
58
58
|
return u;
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
const e =
|
|
62
|
-
for (let
|
|
63
|
-
const
|
|
64
|
-
|
|
60
|
+
function pe() {
|
|
61
|
+
const e = w.now().startOf("week"), i = [];
|
|
62
|
+
for (let s = 0; s < 7; s++) {
|
|
63
|
+
const l = e.plus({ days: s });
|
|
64
|
+
i.push(l.toFormat("ccc"));
|
|
65
65
|
}
|
|
66
|
-
return
|
|
66
|
+
return i;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function ye() {
|
|
69
69
|
const e = [];
|
|
70
|
-
for (let
|
|
71
|
-
const
|
|
72
|
-
e.push(
|
|
70
|
+
for (let i = 1; i <= 12; i++) {
|
|
71
|
+
const s = w.fromObject({ month: i });
|
|
72
|
+
e.push(s.toFormat("MMMM"));
|
|
73
73
|
}
|
|
74
74
|
return e;
|
|
75
75
|
}
|
|
76
|
-
const
|
|
76
|
+
const fe = ({
|
|
77
77
|
viewDate: e,
|
|
78
|
-
selectedDate:
|
|
79
|
-
onDateSelect:
|
|
80
|
-
onViewDateChange:
|
|
78
|
+
selectedDate: i,
|
|
79
|
+
onDateSelect: s,
|
|
80
|
+
onViewDateChange: l,
|
|
81
81
|
timezone: c,
|
|
82
|
-
minDate:
|
|
82
|
+
minDate: v,
|
|
83
83
|
maxDate: d,
|
|
84
|
-
selectedStart:
|
|
85
|
-
selectedEnd:
|
|
86
|
-
onRangeSelect:
|
|
87
|
-
holidays:
|
|
84
|
+
selectedStart: y,
|
|
85
|
+
selectedEnd: g,
|
|
86
|
+
onRangeSelect: M,
|
|
87
|
+
holidays: I
|
|
88
88
|
}) => {
|
|
89
|
-
const
|
|
89
|
+
const _ = M != null, R = Y(() => ue(
|
|
90
90
|
e.year,
|
|
91
91
|
e.month,
|
|
92
92
|
c,
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
i ?? void 0,
|
|
94
|
+
v,
|
|
95
95
|
d,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
), [e,
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
},
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
}, u = (
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
}, $ = (
|
|
110
|
-
if (!
|
|
111
|
-
if (
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
else if (
|
|
116
|
-
const C =
|
|
117
|
-
|
|
96
|
+
y ?? void 0,
|
|
97
|
+
g ?? void 0,
|
|
98
|
+
I
|
|
99
|
+
), [e, i, c, v, d, y, g, I]), E = Y(() => pe(), []), P = Y(() => ye(), []), O = () => {
|
|
100
|
+
l(e.minus({ months: 1 }));
|
|
101
|
+
}, x = () => {
|
|
102
|
+
l(e.plus({ months: 1 }));
|
|
103
|
+
}, n = (t) => {
|
|
104
|
+
const p = parseInt(t.target.value, 10);
|
|
105
|
+
l(e.set({ month: p }));
|
|
106
|
+
}, u = (t) => {
|
|
107
|
+
const p = parseInt(t.target.value, 10);
|
|
108
|
+
l(e.set({ year: p }));
|
|
109
|
+
}, $ = (t, p) => {
|
|
110
|
+
if (!p)
|
|
111
|
+
if (_ && M) {
|
|
112
|
+
const a = t.startOf("day");
|
|
113
|
+
if (y == null)
|
|
114
|
+
M(t, t);
|
|
115
|
+
else if (g != null && y.hasSame(g, "day")) {
|
|
116
|
+
const C = y.startOf("day");
|
|
117
|
+
a < C ? M(t, y) : M(y, t);
|
|
118
118
|
} else
|
|
119
|
-
|
|
119
|
+
M(t, t);
|
|
120
120
|
} else
|
|
121
|
-
|
|
122
|
-
},
|
|
123
|
-
(
|
|
124
|
-
},
|
|
121
|
+
s(t);
|
|
122
|
+
}, r = (t, p, a) => {
|
|
123
|
+
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), $(p, a));
|
|
124
|
+
}, b = e.year, T = Array.from({ length: 21 }, (t, p) => b - 10 + p);
|
|
125
125
|
return /* @__PURE__ */ h("div", { className: "chronos-calendar", role: "region", "aria-label": "Calendar", children: [
|
|
126
126
|
/* @__PURE__ */ h("div", { className: "chronos-calendar-header", children: [
|
|
127
127
|
/* @__PURE__ */ o(
|
|
@@ -129,7 +129,7 @@ const ye = ({
|
|
|
129
129
|
{
|
|
130
130
|
type: "button",
|
|
131
131
|
className: "chronos-nav-button",
|
|
132
|
-
onClick:
|
|
132
|
+
onClick: O,
|
|
133
133
|
"aria-label": "Previous month",
|
|
134
134
|
children: "‹"
|
|
135
135
|
}
|
|
@@ -140,9 +140,9 @@ const ye = ({
|
|
|
140
140
|
{
|
|
141
141
|
className: "chronos-month-select",
|
|
142
142
|
value: e.month,
|
|
143
|
-
onChange:
|
|
143
|
+
onChange: n,
|
|
144
144
|
"aria-label": "Select month",
|
|
145
|
-
children: P.map((
|
|
145
|
+
children: P.map((t, p) => /* @__PURE__ */ o("option", { value: p + 1, children: t }, p))
|
|
146
146
|
}
|
|
147
147
|
),
|
|
148
148
|
/* @__PURE__ */ o(
|
|
@@ -152,7 +152,7 @@ const ye = ({
|
|
|
152
152
|
value: e.year,
|
|
153
153
|
onChange: u,
|
|
154
154
|
"aria-label": "Select year",
|
|
155
|
-
children:
|
|
155
|
+
children: T.map((t) => /* @__PURE__ */ o("option", { value: t, children: t }, t))
|
|
156
156
|
}
|
|
157
157
|
)
|
|
158
158
|
] }),
|
|
@@ -161,58 +161,58 @@ const ye = ({
|
|
|
161
161
|
{
|
|
162
162
|
type: "button",
|
|
163
163
|
className: "chronos-nav-button",
|
|
164
|
-
onClick:
|
|
164
|
+
onClick: x,
|
|
165
165
|
"aria-label": "Next month",
|
|
166
166
|
children: "›"
|
|
167
167
|
}
|
|
168
168
|
)
|
|
169
169
|
] }),
|
|
170
170
|
/* @__PURE__ */ h("div", { className: "chronos-calendar-grid", children: [
|
|
171
|
-
/* @__PURE__ */ o("div", { className: "chronos-weekday-row", children:
|
|
172
|
-
|
|
171
|
+
/* @__PURE__ */ o("div", { className: "chronos-weekday-row", children: E.map((t) => /* @__PURE__ */ o("div", { className: "chronos-weekday", children: t }, t)) }),
|
|
172
|
+
R.map((t, p) => /* @__PURE__ */ o("div", { className: "chronos-week-row", children: t.map((a, C) => /* @__PURE__ */ h(
|
|
173
173
|
"button",
|
|
174
174
|
{
|
|
175
175
|
type: "button",
|
|
176
|
-
className: `chronos-day ${
|
|
177
|
-
onClick: () => $(
|
|
178
|
-
onKeyDown: (
|
|
179
|
-
disabled:
|
|
180
|
-
"aria-label": `${
|
|
181
|
-
"aria-selected":
|
|
182
|
-
"aria-current":
|
|
183
|
-
title:
|
|
176
|
+
className: `chronos-day ${a.isSelected ? "selected" : ""} ${a.isToday ? "today" : ""} ${a.isCurrentMonth ? "" : "other-month"} ${a.isDisabled ? "disabled" : ""} ${a.isInRange ? "in-range" : ""} ${a.isRangeStart ? "range-start" : ""} ${a.isRangeEnd ? "range-end" : ""} ${a.holiday ? `holiday ${a.holiday.type}` : ""}`,
|
|
177
|
+
onClick: () => $(a.date, a.isDisabled),
|
|
178
|
+
onKeyDown: (N) => r(N, a.date, a.isDisabled),
|
|
179
|
+
disabled: a.isDisabled,
|
|
180
|
+
"aria-label": `${a.date.toFormat("MMMM d, yyyy")}${a.holiday ? `, ${a.holiday.name}` : ""}`,
|
|
181
|
+
"aria-selected": a.isSelected,
|
|
182
|
+
"aria-current": a.isToday ? "date" : void 0,
|
|
183
|
+
title: a.holiday ? a.holiday.name : void 0,
|
|
184
184
|
children: [
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
a.date.day,
|
|
186
|
+
a.holiday && /* @__PURE__ */ o("span", { className: "chronos-holiday-dot" })
|
|
187
187
|
]
|
|
188
188
|
},
|
|
189
189
|
C
|
|
190
|
-
)) },
|
|
190
|
+
)) }, p))
|
|
191
191
|
] })
|
|
192
192
|
] });
|
|
193
|
-
},
|
|
193
|
+
}, be = ({
|
|
194
194
|
value: e,
|
|
195
|
-
onChange:
|
|
196
|
-
use24Hour:
|
|
195
|
+
onChange: i,
|
|
196
|
+
use24Hour: s
|
|
197
197
|
}) => {
|
|
198
|
-
const [
|
|
198
|
+
const [l, c] = S((e == null ? void 0 : e.hour) ?? 12), [v, d] = S((e == null ? void 0 : e.minute) ?? 0), [y, g] = S(
|
|
199
199
|
e && e.hour >= 12 ? "PM" : "AM"
|
|
200
200
|
);
|
|
201
|
-
|
|
202
|
-
e && (c(e.hour), d(e.minute),
|
|
201
|
+
B(() => {
|
|
202
|
+
e && (c(e.hour), d(e.minute), g(e.hour >= 12 ? "PM" : "AM"));
|
|
203
203
|
}, [e]);
|
|
204
|
-
const
|
|
205
|
-
c(
|
|
206
|
-
let u =
|
|
207
|
-
|
|
208
|
-
},
|
|
209
|
-
d(
|
|
210
|
-
},
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
let u =
|
|
214
|
-
|
|
215
|
-
},
|
|
204
|
+
const M = (n) => {
|
|
205
|
+
c(n);
|
|
206
|
+
let u = n;
|
|
207
|
+
s || (y === "PM" && n !== 12 ? u = n + 12 : y === "AM" && n === 12 && (u = 0)), i(u, v);
|
|
208
|
+
}, I = (n) => {
|
|
209
|
+
d(n), i(l, n);
|
|
210
|
+
}, _ = () => {
|
|
211
|
+
const n = y === "AM" ? "PM" : "AM";
|
|
212
|
+
g(n);
|
|
213
|
+
let u = l;
|
|
214
|
+
n === "PM" && l !== 12 ? u = l + 12 : n === "AM" && l === 12 ? u = 0 : n === "AM" && l > 12 && (u = l - 12), i(u, v);
|
|
215
|
+
}, R = s ? l : l % 12 || 12, E = s ? 23 : 12, P = s ? 0 : 1, O = Array.from({ length: E - P + 1 }, (n, u) => P + u), x = Array.from({ length: 60 }, (n, u) => u);
|
|
216
216
|
return /* @__PURE__ */ h("div", { className: "chronos-time-picker", role: "group", "aria-label": "Time picker", children: [
|
|
217
217
|
/* @__PURE__ */ h("div", { className: "chronos-time-header", children: [
|
|
218
218
|
/* @__PURE__ */ h(
|
|
@@ -240,10 +240,10 @@ const ye = ({
|
|
|
240
240
|
{
|
|
241
241
|
id: "chronos-hour-select",
|
|
242
242
|
className: "chronos-time-select",
|
|
243
|
-
value:
|
|
244
|
-
onChange: (
|
|
243
|
+
value: R,
|
|
244
|
+
onChange: (n) => M(parseInt(n.target.value, 10)),
|
|
245
245
|
"aria-label": "Select hour",
|
|
246
|
-
children:
|
|
246
|
+
children: O.map((n) => /* @__PURE__ */ o("option", { value: n, children: n.toString().padStart(2, "0") }, n))
|
|
247
247
|
}
|
|
248
248
|
)
|
|
249
249
|
] }),
|
|
@@ -255,33 +255,33 @@ const ye = ({
|
|
|
255
255
|
{
|
|
256
256
|
id: "chronos-minute-select",
|
|
257
257
|
className: "chronos-time-select",
|
|
258
|
-
value:
|
|
259
|
-
onChange: (
|
|
258
|
+
value: v,
|
|
259
|
+
onChange: (n) => I(parseInt(n.target.value, 10)),
|
|
260
260
|
"aria-label": "Select minute",
|
|
261
|
-
children:
|
|
261
|
+
children: x.map((n) => /* @__PURE__ */ o("option", { value: n, children: n.toString().padStart(2, "0") }, n))
|
|
262
262
|
}
|
|
263
263
|
)
|
|
264
264
|
] }),
|
|
265
|
-
!
|
|
265
|
+
!s && /* @__PURE__ */ o(
|
|
266
266
|
"button",
|
|
267
267
|
{
|
|
268
268
|
type: "button",
|
|
269
269
|
className: "chronos-period-toggle",
|
|
270
|
-
onClick:
|
|
271
|
-
"aria-label": `Switch to ${
|
|
272
|
-
children:
|
|
270
|
+
onClick: _,
|
|
271
|
+
"aria-label": `Switch to ${y === "AM" ? "PM" : "AM"}`,
|
|
272
|
+
children: y
|
|
273
273
|
}
|
|
274
274
|
)
|
|
275
275
|
] })
|
|
276
276
|
] });
|
|
277
|
-
},
|
|
277
|
+
}, Me = ({
|
|
278
278
|
value: e,
|
|
279
|
-
onChange:
|
|
279
|
+
onChange: i
|
|
280
280
|
}) => {
|
|
281
|
-
const [
|
|
281
|
+
const [s, l] = S(!1), c = X.find((d) => d.value === e) || {
|
|
282
282
|
label: e
|
|
283
|
-
},
|
|
284
|
-
|
|
283
|
+
}, v = (d) => {
|
|
284
|
+
i(d), l(!1);
|
|
285
285
|
};
|
|
286
286
|
return /* @__PURE__ */ h("div", { className: "chronos-timezone-selector", children: [
|
|
287
287
|
/* @__PURE__ */ h("div", { className: "chronos-timezone-header", children: [
|
|
@@ -308,8 +308,8 @@ const ye = ({
|
|
|
308
308
|
{
|
|
309
309
|
type: "button",
|
|
310
310
|
className: "chronos-timezone-button",
|
|
311
|
-
onClick: () =>
|
|
312
|
-
"aria-expanded":
|
|
311
|
+
onClick: () => l(!s),
|
|
312
|
+
"aria-expanded": s,
|
|
313
313
|
"aria-label": "Select timezone",
|
|
314
314
|
children: [
|
|
315
315
|
/* @__PURE__ */ o("span", { className: "chronos-timezone-label", children: c.label }),
|
|
@@ -317,7 +317,7 @@ const ye = ({
|
|
|
317
317
|
/* @__PURE__ */ o(
|
|
318
318
|
"svg",
|
|
319
319
|
{
|
|
320
|
-
className: `chronos-chevron ${
|
|
320
|
+
className: `chronos-chevron ${s ? "expanded" : ""}`,
|
|
321
321
|
xmlns: "http://www.w3.org/2000/svg",
|
|
322
322
|
viewBox: "0 0 24 24",
|
|
323
323
|
fill: "none",
|
|
@@ -329,12 +329,12 @@ const ye = ({
|
|
|
329
329
|
]
|
|
330
330
|
}
|
|
331
331
|
),
|
|
332
|
-
|
|
332
|
+
s && /* @__PURE__ */ o("div", { className: "chronos-timezone-list", role: "listbox", children: X.map((d) => /* @__PURE__ */ h(
|
|
333
333
|
"button",
|
|
334
334
|
{
|
|
335
335
|
type: "button",
|
|
336
336
|
className: `chronos-timezone-option ${d.value === e ? "selected" : ""}`,
|
|
337
|
-
onClick: () =>
|
|
337
|
+
onClick: () => v(d.value),
|
|
338
338
|
role: "option",
|
|
339
339
|
"aria-selected": d.value === e,
|
|
340
340
|
children: [
|
|
@@ -346,132 +346,132 @@ const ye = ({
|
|
|
346
346
|
)) })
|
|
347
347
|
] });
|
|
348
348
|
};
|
|
349
|
-
function V(e,
|
|
349
|
+
function V(e, i, s) {
|
|
350
350
|
return {
|
|
351
351
|
iso: e.toISO() || "",
|
|
352
|
-
formatted: e.toFormat(`${
|
|
352
|
+
formatted: e.toFormat(`${i} ${s}`),
|
|
353
353
|
timestamp: e.toMillis(),
|
|
354
354
|
dateTime: e
|
|
355
355
|
};
|
|
356
356
|
}
|
|
357
|
-
const
|
|
357
|
+
const Ne = ({
|
|
358
358
|
value: e,
|
|
359
|
-
onChange:
|
|
360
|
-
timezone:
|
|
361
|
-
dateFormat:
|
|
359
|
+
onChange: i,
|
|
360
|
+
timezone: s = me,
|
|
361
|
+
dateFormat: l = "DD",
|
|
362
362
|
timeFormat: c = "HH:mm",
|
|
363
|
-
minDate:
|
|
363
|
+
minDate: v,
|
|
364
364
|
maxDate: d,
|
|
365
|
-
placeholder:
|
|
366
|
-
disabled:
|
|
367
|
-
showTime:
|
|
368
|
-
use24Hour:
|
|
369
|
-
className:
|
|
370
|
-
ariaLabel:
|
|
371
|
-
showTimezoneSelector:
|
|
365
|
+
placeholder: y = "Select date and time",
|
|
366
|
+
disabled: g = !1,
|
|
367
|
+
showTime: M = !0,
|
|
368
|
+
use24Hour: I = !0,
|
|
369
|
+
className: _ = "",
|
|
370
|
+
ariaLabel: R = "Date and time picker",
|
|
371
|
+
showTimezoneSelector: E = !1,
|
|
372
372
|
theme: P = "light",
|
|
373
|
-
orientation:
|
|
374
|
-
selectionMode:
|
|
375
|
-
rangeValue:
|
|
373
|
+
orientation: O = "portrait",
|
|
374
|
+
selectionMode: x = "single",
|
|
375
|
+
rangeValue: n,
|
|
376
376
|
onRangeChange: u,
|
|
377
377
|
holidays: $
|
|
378
378
|
}) => {
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
!
|
|
382
|
-
}, [e,
|
|
383
|
-
|
|
384
|
-
}, [
|
|
385
|
-
const
|
|
386
|
-
|
|
379
|
+
const r = x === "range", [b, T] = S(!1), [t, p] = S(() => !r && e ? L(e, s) : null), [a, C] = S(() => r && (n != null && n.start) ? L(n.start, s) : null), [N, W] = S(() => r && (n != null && n.end) ? L(n.end, s) : null), [k, K] = S(s), [ee, Z] = S(() => t || a || N || H(s)), J = Q(null), U = Q(null);
|
|
380
|
+
B(() => {
|
|
381
|
+
!r && e && p(L(e, k));
|
|
382
|
+
}, [e, k, r]), B(() => {
|
|
383
|
+
r && (n == null ? void 0 : n.start) != null && (n == null ? void 0 : n.end) != null && (C(L(n.start, k)), W(L(n.end, k)));
|
|
384
|
+
}, [r, n, k]), B(() => {
|
|
385
|
+
const f = (m) => {
|
|
386
|
+
J.current && !J.current.contains(m.target) && T(!1);
|
|
387
387
|
};
|
|
388
|
-
if (
|
|
389
|
-
return document.addEventListener("mousedown",
|
|
390
|
-
}, [
|
|
391
|
-
const
|
|
392
|
-
var
|
|
393
|
-
m.key === "Escape" &&
|
|
388
|
+
if (b)
|
|
389
|
+
return document.addEventListener("mousedown", f), () => document.removeEventListener("mousedown", f);
|
|
390
|
+
}, [b]), B(() => {
|
|
391
|
+
const f = (m) => {
|
|
392
|
+
var D;
|
|
393
|
+
m.key === "Escape" && b && (T(!1), (D = U.current) == null || D.focus());
|
|
394
394
|
};
|
|
395
|
-
return document.addEventListener("keydown",
|
|
396
|
-
}, [
|
|
397
|
-
const
|
|
398
|
-
let m =
|
|
399
|
-
if (
|
|
400
|
-
hour:
|
|
401
|
-
minute:
|
|
402
|
-
second:
|
|
403
|
-
})),
|
|
404
|
-
const
|
|
395
|
+
return document.addEventListener("keydown", f), () => document.removeEventListener("keydown", f);
|
|
396
|
+
}, [b]);
|
|
397
|
+
const ne = G((f) => {
|
|
398
|
+
let m = f;
|
|
399
|
+
if (t && (m = f.set({
|
|
400
|
+
hour: t.hour,
|
|
401
|
+
minute: t.minute,
|
|
402
|
+
second: t.second
|
|
403
|
+
})), p(m), Z(m), M || T(!1), i) {
|
|
404
|
+
const D = {
|
|
405
405
|
iso: m.toISO() || "",
|
|
406
|
-
formatted: m.toFormat(`${
|
|
406
|
+
formatted: m.toFormat(`${l} ${c}`),
|
|
407
407
|
timestamp: m.toMillis(),
|
|
408
408
|
dateTime: m
|
|
409
409
|
};
|
|
410
|
-
|
|
410
|
+
i(D);
|
|
411
411
|
}
|
|
412
|
-
}, [
|
|
413
|
-
const A = (
|
|
414
|
-
if (
|
|
415
|
-
const
|
|
412
|
+
}, [t, M, i, l, c]), te = G((f, m) => {
|
|
413
|
+
const A = (t || H(k)).set({ hour: f, minute: m, second: 0 });
|
|
414
|
+
if (p(A), i) {
|
|
415
|
+
const z = {
|
|
416
416
|
iso: A.toISO() || "",
|
|
417
|
-
formatted: A.toFormat(`${
|
|
417
|
+
formatted: A.toFormat(`${l} ${c}`),
|
|
418
418
|
timestamp: A.toMillis(),
|
|
419
419
|
dateTime: A
|
|
420
420
|
};
|
|
421
|
-
|
|
421
|
+
i(z);
|
|
422
422
|
}
|
|
423
|
-
}, [
|
|
424
|
-
const
|
|
425
|
-
if (C(
|
|
426
|
-
const ce = V(
|
|
423
|
+
}, [t, k, i, l, c]), oe = G((f, m) => {
|
|
424
|
+
const D = f.startOf("day"), A = m.startOf("day"), [z, j] = D <= A ? [D, A] : [A, D];
|
|
425
|
+
if (C(z), W(j), Z(z), u) {
|
|
426
|
+
const ce = V(z, l, c), de = V(j, l, c), he = Math.max(0, Math.ceil(j.diff(z, "days").days));
|
|
427
427
|
u({ start: ce, end: de, nights: he });
|
|
428
428
|
}
|
|
429
|
-
}, [u,
|
|
430
|
-
if (
|
|
431
|
-
const m =
|
|
432
|
-
if (
|
|
433
|
-
const
|
|
429
|
+
}, [u, l, c]), ae = G((f) => {
|
|
430
|
+
if (K(f), t) {
|
|
431
|
+
const m = t.setZone(f);
|
|
432
|
+
if (p(m), Z(m), i) {
|
|
433
|
+
const D = {
|
|
434
434
|
iso: m.toISO() || "",
|
|
435
|
-
formatted: m.toFormat(`${
|
|
435
|
+
formatted: m.toFormat(`${l} ${c}`),
|
|
436
436
|
timestamp: m.toMillis(),
|
|
437
437
|
dateTime: m
|
|
438
438
|
};
|
|
439
|
-
|
|
439
|
+
i(D);
|
|
440
440
|
}
|
|
441
441
|
} else
|
|
442
|
-
|
|
443
|
-
}, [
|
|
444
|
-
|
|
445
|
-
},
|
|
446
|
-
(
|
|
447
|
-
},
|
|
442
|
+
Z(H(f));
|
|
443
|
+
}, [t, i, l, c]), q = () => {
|
|
444
|
+
g || T(!b);
|
|
445
|
+
}, se = (f) => {
|
|
446
|
+
(f.key === "Enter" || f.key === " ") && (f.preventDefault(), q());
|
|
447
|
+
}, ie = r ? a && N ? `${a.toFormat("d MMM yyyy")} – ${N.toFormat("d MMM yyyy")}` : "" : t ? t.toFormat(`${l} ${M ? c : ""}`) : "", le = v ? L(v, k) : void 0, re = d ? L(d, k) : void 0;
|
|
448
448
|
return /* @__PURE__ */ h(
|
|
449
449
|
"div",
|
|
450
450
|
{
|
|
451
|
-
ref:
|
|
452
|
-
className: `chronos-picker ${
|
|
453
|
-
"data-disabled":
|
|
451
|
+
ref: J,
|
|
452
|
+
className: `chronos-picker ${_}`,
|
|
453
|
+
"data-disabled": g,
|
|
454
454
|
"data-theme": P,
|
|
455
455
|
children: [
|
|
456
456
|
/* @__PURE__ */ h(
|
|
457
457
|
"div",
|
|
458
458
|
{
|
|
459
459
|
className: "chronos-input-wrapper",
|
|
460
|
-
onClick:
|
|
460
|
+
onClick: q,
|
|
461
461
|
children: [
|
|
462
462
|
/* @__PURE__ */ o(
|
|
463
463
|
"input",
|
|
464
464
|
{
|
|
465
|
-
ref:
|
|
465
|
+
ref: U,
|
|
466
466
|
type: "text",
|
|
467
467
|
className: "chronos-input",
|
|
468
|
-
value:
|
|
469
|
-
placeholder:
|
|
468
|
+
value: ie,
|
|
469
|
+
placeholder: y,
|
|
470
470
|
readOnly: !0,
|
|
471
|
-
disabled:
|
|
472
|
-
onKeyDown:
|
|
473
|
-
"aria-label":
|
|
474
|
-
"aria-expanded":
|
|
471
|
+
disabled: g,
|
|
472
|
+
onKeyDown: se,
|
|
473
|
+
"aria-label": R,
|
|
474
|
+
"aria-expanded": b,
|
|
475
475
|
"aria-haspopup": "dialog",
|
|
476
476
|
role: "combobox"
|
|
477
477
|
}
|
|
@@ -496,57 +496,57 @@ const Te = ({
|
|
|
496
496
|
]
|
|
497
497
|
}
|
|
498
498
|
),
|
|
499
|
-
|
|
499
|
+
b && /* @__PURE__ */ o(
|
|
500
500
|
"div",
|
|
501
501
|
{
|
|
502
502
|
className: "chronos-dropdown",
|
|
503
|
-
"data-orientation":
|
|
504
|
-
"data-range-mode":
|
|
503
|
+
"data-orientation": O,
|
|
504
|
+
"data-range-mode": r,
|
|
505
505
|
role: "dialog",
|
|
506
506
|
"aria-label": "Date and time picker dialog",
|
|
507
507
|
children: /* @__PURE__ */ h("div", { className: "chronos-dropdown-content", children: [
|
|
508
|
-
|
|
508
|
+
r && a && N && /* @__PURE__ */ h("div", { className: "chronos-range-summary", children: [
|
|
509
509
|
/* @__PURE__ */ h("div", { className: "chronos-range-nights", children: [
|
|
510
|
-
Math.max(0, Math.ceil(
|
|
510
|
+
Math.max(0, Math.ceil(N.diff(a, "days").days)),
|
|
511
511
|
" nights"
|
|
512
512
|
] }),
|
|
513
513
|
/* @__PURE__ */ h("div", { className: "chronos-range-dates", children: [
|
|
514
|
-
|
|
514
|
+
a.toFormat("d MMM yyyy"),
|
|
515
515
|
" – ",
|
|
516
|
-
|
|
516
|
+
N.toFormat("d MMM yyyy")
|
|
517
517
|
] })
|
|
518
518
|
] }),
|
|
519
519
|
/* @__PURE__ */ o(
|
|
520
|
-
|
|
520
|
+
fe,
|
|
521
521
|
{
|
|
522
522
|
viewDate: ee,
|
|
523
|
-
selectedDate:
|
|
524
|
-
onDateSelect:
|
|
525
|
-
onViewDateChange:
|
|
526
|
-
timezone:
|
|
527
|
-
minDate:
|
|
528
|
-
maxDate:
|
|
529
|
-
selectedStart:
|
|
530
|
-
selectedEnd:
|
|
531
|
-
onRangeSelect:
|
|
523
|
+
selectedDate: r ? null : t,
|
|
524
|
+
onDateSelect: ne,
|
|
525
|
+
onViewDateChange: Z,
|
|
526
|
+
timezone: k,
|
|
527
|
+
minDate: le,
|
|
528
|
+
maxDate: re,
|
|
529
|
+
selectedStart: r ? a : void 0,
|
|
530
|
+
selectedEnd: r ? N : void 0,
|
|
531
|
+
onRangeSelect: r ? oe : void 0,
|
|
532
532
|
holidays: $
|
|
533
533
|
}
|
|
534
534
|
),
|
|
535
|
-
!
|
|
536
|
-
|
|
537
|
-
|
|
535
|
+
!r && (M || E) && /* @__PURE__ */ h("div", { className: "chronos-sidebar", children: [
|
|
536
|
+
M && /* @__PURE__ */ o(
|
|
537
|
+
be,
|
|
538
538
|
{
|
|
539
|
-
value:
|
|
540
|
-
onChange:
|
|
541
|
-
use24Hour:
|
|
542
|
-
timezone:
|
|
539
|
+
value: t,
|
|
540
|
+
onChange: te,
|
|
541
|
+
use24Hour: I,
|
|
542
|
+
timezone: k
|
|
543
543
|
}
|
|
544
544
|
),
|
|
545
|
-
|
|
546
|
-
|
|
545
|
+
E && /* @__PURE__ */ o(
|
|
546
|
+
Me,
|
|
547
547
|
{
|
|
548
|
-
value:
|
|
549
|
-
onChange:
|
|
548
|
+
value: k,
|
|
549
|
+
onChange: ae
|
|
550
550
|
}
|
|
551
551
|
)
|
|
552
552
|
] })
|
|
@@ -556,11 +556,45 @@ const Te = ({
|
|
|
556
556
|
]
|
|
557
557
|
}
|
|
558
558
|
);
|
|
559
|
-
}
|
|
559
|
+
}, Te = [
|
|
560
|
+
// --- 2026 National Holidays (India) ---
|
|
561
|
+
{ date: "2026-01-26", name: "Republic Day", type: "national" },
|
|
562
|
+
{ date: "2026-03-19", name: "Holi", type: "national" },
|
|
563
|
+
// Tentative
|
|
564
|
+
{ date: "2026-04-14", name: "Dr. Ambedkar Jayanti", type: "national" },
|
|
565
|
+
{ date: "2026-08-15", name: "Independence Day", type: "national" },
|
|
566
|
+
{ date: "2026-10-02", name: "Gandhi Jayanti", type: "national" },
|
|
567
|
+
{ date: "2026-10-20", name: "Dussehra", type: "national" },
|
|
568
|
+
// Tentative
|
|
569
|
+
{ date: "2026-11-08", name: "Diwali", type: "national" },
|
|
570
|
+
// Tentative
|
|
571
|
+
{ date: "2026-12-25", name: "Christmas", type: "national" }
|
|
572
|
+
], we = [
|
|
573
|
+
// Republic Day Weekend (Jan 24-26)
|
|
574
|
+
{ date: "2026-01-24", name: "Long Weekend: Trip to Jaipur?", type: "long-weekend" },
|
|
575
|
+
{ date: "2026-01-25", name: "Long Weekend: Fort Visit", type: "long-weekend" },
|
|
576
|
+
{ date: "2026-01-26", name: "Republic Day", type: "long-weekend" },
|
|
577
|
+
// Holi Weekend (Mar 19-22 - Take Friday off)
|
|
578
|
+
{ date: "2026-03-19", name: "Holi Celebration", type: "long-weekend" },
|
|
579
|
+
{ date: "2026-03-20", name: "Take a leave! Beach time?", type: "long-weekend" },
|
|
580
|
+
{ date: "2026-03-21", name: "Relaxing Saturday", type: "long-weekend" },
|
|
581
|
+
{ date: "2026-03-22", name: "Lazy Sunday", type: "long-weekend" },
|
|
582
|
+
// Independence Day Weekend (Aug 15-17)
|
|
583
|
+
{ date: "2026-08-15", name: "Independence Day", type: "long-weekend" },
|
|
584
|
+
{ date: "2026-08-16", name: "Sunday Brunch", type: "long-weekend" },
|
|
585
|
+
{ date: "2026-08-17", name: "Take a leave? Hills calling!", type: "long-weekend" },
|
|
586
|
+
// Monday leave suggestion
|
|
587
|
+
// Diwali Weekend (Nov 7-9)
|
|
588
|
+
{ date: "2026-11-07", name: "Choti Diwali", type: "long-weekend" },
|
|
589
|
+
{ date: "2026-11-08", name: "Diwali", type: "long-weekend" },
|
|
590
|
+
{ date: "2026-11-09", name: "Govardhan Puja (Take leave)", type: "long-weekend" }
|
|
591
|
+
];
|
|
560
592
|
export {
|
|
561
593
|
X as COMMON_TIMEZONES,
|
|
562
594
|
me as DEFAULT_TIMEZONE,
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
595
|
+
Ne as DateTimePicker,
|
|
596
|
+
Te as INDIAN_HOLIDAYS_2026,
|
|
597
|
+
we as LONG_WEEKENDS_2026,
|
|
598
|
+
L as convertToTimezone,
|
|
599
|
+
H as nowInTimezone
|
|
566
600
|
};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(S,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("luxon")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","luxon"],e):(S=typeof globalThis<"u"?globalThis:S||self,e(S.ChronosPicker={},S.jsxRuntime,S.React,S.luxon))})(this,function(S,e,c,D){"use strict";const G="Asia/Kolkata",U=[{value:"Asia/Kolkata",label:"India (IST)"},{value:"America/New_York",label:"Eastern Time (ET)"},{value:"America/Chicago",label:"Central Time (CT)"},{value:"America/Denver",label:"Mountain Time (MT)"},{value:"America/Los_Angeles",label:"Pacific Time (PT)"},{value:"Europe/London",label:"London (GMT/BST)"},{value:"Europe/Paris",label:"Central Europe (CET)"},{value:"Asia/Dubai",label:"Dubai (GST)"},{value:"Asia/Singapore",label:"Singapore (SGT)"},{value:"Asia/Tokyo",label:"Tokyo (JST)"},{value:"Australia/Sydney",label:"Sydney (AEDT)"},{value:"UTC",label:"UTC"}];function w(s,r){return D.DateTime.isDateTime(s)?s.setZone(r):typeof s=="string"?D.DateTime.fromISO(s,{zone:r}):D.DateTime.fromJSDate(s,{zone:r})}function K(s){return D.DateTime.now().setZone(s)}function J(s){const a=D.DateTime.now().setZone(s).offset,l=Math.floor(Math.abs(a)/60),d=Math.abs(a)%60;return`UTC${a>=0?"+":"-"}${l}${d>0?`:${d.toString().padStart(2,"0")}`:""}`}function F(s,r,a,l,d,v,h,y,N){const b=D.DateTime.fromObject({year:s,month:r,day:1},{zone:a}),I=b.startOf("week"),Z=b.endOf("month").endOf("week"),P=D.DateTime.now().setZone(a).startOf("day"),z=h!=null&&y!=null,C=h==null?void 0:h.startOf("day"),$=y==null?void 0:y.endOf("day"),o=new Map;N&&N.forEach(M=>{let g;D.DateTime.isDateTime(M.date)?g=M.date.setZone(a):typeof M.date=="string"?g=D.DateTime.fromISO(M.date,{zone:a}):g=D.DateTime.fromJSDate(M.date,{zone:a}),o.set(g.toISODate()||"",{name:M.name,type:M.type||"national"})});const m=[];let E=[],i=I;for(;i<=Z;){const M=i.month===r,g=i.hasSame(P,"day"),t=i.startOf("day"),p=i.toISODate()||"";let n=!1,A=!1,k=!1,L=!1;z&&C&&$?(k=t.hasSame(C,"day"),L=t.hasSame($,"day"),A=t>=C&&t<=$||k||L,n=k||L):l&&(n=i.hasSame(l,"day"));let T=!1;d&&i<d.startOf("day")&&(T=!0),v&&i>v.endOf("day")&&(T=!0);const B=o.get(p);E.push({date:i,isCurrentMonth:M,isToday:g,isSelected:n,isDisabled:T,isInRange:A,isRangeStart:k,isRangeEnd:L,holiday:B?{date:i,...B}:void 0}),E.length===7&&(m.push(E),E=[]),i=i.plus({days:1})}return m}function V(){const s=D.DateTime.now().startOf("week"),r=[];for(let a=0;a<7;a++){const l=s.plus({days:a});r.push(l.toFormat("ccc"))}return r}function R(){const s=[];for(let r=1;r<=12;r++){const a=D.DateTime.fromObject({month:r});s.push(a.toFormat("MMMM"))}return s}const ee=({viewDate:s,selectedDate:r,onDateSelect:a,onViewDateChange:l,timezone:d,minDate:v,maxDate:h,selectedStart:y,selectedEnd:N,onRangeSelect:b,holidays:I})=>{const _=b!=null,Z=c.useMemo(()=>F(s.year,s.month,d,r??void 0,v,h,y??void 0,N??void 0,I),[s,r,d,v,h,y,N,I]),P=c.useMemo(()=>V(),[]),z=c.useMemo(()=>R(),[]),C=()=>{l(s.minus({months:1}))},$=()=>{l(s.plus({months:1}))},o=t=>{const p=parseInt(t.target.value,10);l(s.set({month:p}))},m=t=>{const p=parseInt(t.target.value,10);l(s.set({year:p}))},E=(t,p)=>{if(!p)if(_&&b){const n=t.startOf("day");if(y==null)b(t,t);else if(N!=null&&y.hasSame(N,"day")){const A=y.startOf("day");n<A?b(t,y):b(y,t)}else b(t,t)}else a(t)},i=(t,p,n)=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),E(p,n))},M=s.year,g=Array.from({length:21},(t,p)=>M-10+p);return e.jsxs("div",{className:"chronos-calendar",role:"region","aria-label":"Calendar",children:[e.jsxs("div",{className:"chronos-calendar-header",children:[e.jsx("button",{type:"button",className:"chronos-nav-button",onClick:C,"aria-label":"Previous month",children:"‹"}),e.jsxs("div",{className:"chronos-month-year-selectors",children:[e.jsx("select",{className:"chronos-month-select",value:s.month,onChange:o,"aria-label":"Select month",children:z.map((t,p)=>e.jsx("option",{value:p+1,children:t},p))}),e.jsx("select",{className:"chronos-year-select",value:s.year,onChange:m,"aria-label":"Select year",children:g.map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsx("button",{type:"button",className:"chronos-nav-button",onClick:$,"aria-label":"Next month",children:"›"})]}),e.jsxs("div",{className:"chronos-calendar-grid",children:[e.jsx("div",{className:"chronos-weekday-row",children:P.map(t=>e.jsx("div",{className:"chronos-weekday",children:t},t))}),Z.map((t,p)=>e.jsx("div",{className:"chronos-week-row",children:t.map((n,A)=>e.jsxs("button",{type:"button",className:`chronos-day ${n.isSelected?"selected":""} ${n.isToday?"today":""} ${n.isCurrentMonth?"":"other-month"} ${n.isDisabled?"disabled":""} ${n.isInRange?"in-range":""} ${n.isRangeStart?"range-start":""} ${n.isRangeEnd?"range-end":""} ${n.holiday?`holiday ${n.holiday.type}`:""}`,onClick:()=>E(n.date,n.isDisabled),onKeyDown:k=>i(k,n.date,n.isDisabled),disabled:n.isDisabled,"aria-label":`${n.date.toFormat("MMMM d, yyyy")}${n.holiday?`, ${n.holiday.name}`:""}`,"aria-selected":n.isSelected,"aria-current":n.isToday?"date":void 0,title:n.holiday?n.holiday.name:void 0,children:[n.date.day,n.holiday&&e.jsx("span",{className:"chronos-holiday-dot"})]},A))},p))]})]})},se=({value:s,onChange:r,use24Hour:a})=>{const[l,d]=c.useState((s==null?void 0:s.hour)??12),[v,h]=c.useState((s==null?void 0:s.minute)??0),[y,N]=c.useState(s&&s.hour>=12?"PM":"AM");c.useEffect(()=>{s&&(d(s.hour),h(s.minute),N(s.hour>=12?"PM":"AM"))},[s]);const b=o=>{d(o);let m=o;a||(y==="PM"&&o!==12?m=o+12:y==="AM"&&o===12&&(m=0)),r(m,v)},I=o=>{h(o),r(l,o)},_=()=>{const o=y==="AM"?"PM":"AM";N(o);let m=l;o==="PM"&&l!==12?m=l+12:o==="AM"&&l===12?m=0:o==="AM"&&l>12&&(m=l-12),r(m,v)},Z=a?l:l%12||12,P=a?23:12,z=a?0:1,C=Array.from({length:P-z+1},(o,m)=>z+m),$=Array.from({length:60},(o,m)=>m);return e.jsxs("div",{className:"chronos-time-picker",role:"group","aria-label":"Time picker",children:[e.jsxs("div",{className:"chronos-time-header",children:[e.jsxs("svg",{className:"chronos-clock-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("span",{children:"Time"})]}),e.jsxs("div",{className:"chronos-time-controls",children:[e.jsxs("div",{className:"chronos-time-input-group",children:[e.jsx("label",{htmlFor:"chronos-hour-select",className:"chronos-time-label",children:"Hour"}),e.jsx("select",{id:"chronos-hour-select",className:"chronos-time-select",value:Z,onChange:o=>b(parseInt(o.target.value,10)),"aria-label":"Select hour",children:C.map(o=>e.jsx("option",{value:o,children:o.toString().padStart(2,"0")},o))})]}),e.jsx("span",{className:"chronos-time-separator",children:":"}),e.jsxs("div",{className:"chronos-time-input-group",children:[e.jsx("label",{htmlFor:"chronos-minute-select",className:"chronos-time-label",children:"Minute"}),e.jsx("select",{id:"chronos-minute-select",className:"chronos-time-select",value:v,onChange:o=>I(parseInt(o.target.value,10)),"aria-label":"Select minute",children:$.map(o=>e.jsx("option",{value:o,children:o.toString().padStart(2,"0")},o))})]}),!a&&e.jsx("button",{type:"button",className:"chronos-period-toggle",onClick:_,"aria-label":`Switch to ${y==="AM"?"PM":"AM"}`,children:y})]})]})},oe=({value:s,onChange:r})=>{const[a,l]=c.useState(!1),d=U.find(h=>h.value===s)||{label:s},v=h=>{r(h),l(!1)};return e.jsxs("div",{className:"chronos-timezone-selector",children:[e.jsxs("div",{className:"chronos-timezone-header",children:[e.jsxs("svg",{className:"chronos-globe-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),e.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),e.jsx("span",{children:"Timezone"})]}),e.jsxs("button",{type:"button",className:"chronos-timezone-button",onClick:()=>l(!a),"aria-expanded":a,"aria-label":"Select timezone",children:[e.jsx("span",{className:"chronos-timezone-label",children:d.label}),e.jsx("span",{className:"chronos-timezone-offset",children:J(s)}),e.jsx("svg",{className:`chronos-chevron ${a?"expanded":""}`,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),a&&e.jsx("div",{className:"chronos-timezone-list",role:"listbox",children:U.map(h=>e.jsxs("button",{type:"button",className:`chronos-timezone-option ${h.value===s?"selected":""}`,onClick:()=>v(h.value),role:"option","aria-selected":h.value===s,children:[e.jsx("span",{className:"chronos-timezone-option-label",children:h.label}),e.jsx("span",{className:"chronos-timezone-option-offset",children:J(h.value)})]},h.value))})]})};function H(s,r,a){return{iso:s.toISO()||"",formatted:s.toFormat(`${r} ${a}`),timestamp:s.toMillis(),dateTime:s}}const te=({value:s,onChange:r,timezone:a=G,dateFormat:l="DD",timeFormat:d="HH:mm",minDate:v,maxDate:h,placeholder:y="Select date and time",disabled:N=!1,showTime:b=!0,use24Hour:I=!0,className:_="",ariaLabel:Z="Date and time picker",showTimezoneSelector:P=!1,theme:z="light",orientation:C="portrait",selectionMode:$="single",rangeValue:o,onRangeChange:m,holidays:E})=>{const i=$==="range",[M,g]=c.useState(!1),[t,p]=c.useState(()=>!i&&s?w(s,a):null),[n,A]=c.useState(()=>i&&(o!=null&&o.start)?w(o.start,a):null),[k,L]=c.useState(()=>i&&(o!=null&&o.end)?w(o.end,a):null),[T,B]=c.useState(a),[ne,W]=c.useState(()=>t||n||k||K(a)),Y=c.useRef(null),Q=c.useRef(null);c.useEffect(()=>{!i&&s&&p(w(s,T))},[s,T,i]),c.useEffect(()=>{i&&(o==null?void 0:o.start)!=null&&(o==null?void 0:o.end)!=null&&(A(w(o.start,T)),L(w(o.end,T)))},[i,o,T]),c.useEffect(()=>{const u=f=>{Y.current&&!Y.current.contains(f.target)&&g(!1)};if(M)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[M]),c.useEffect(()=>{const u=f=>{var O;f.key==="Escape"&&M&&(g(!1),(O=Q.current)==null||O.focus())};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[M]);const ae=c.useCallback(u=>{let f=u;if(t&&(f=u.set({hour:t.hour,minute:t.minute,second:t.second})),p(f),W(f),b||g(!1),r){const O={iso:f.toISO()||"",formatted:f.toFormat(`${l} ${d}`),timestamp:f.toMillis(),dateTime:f};r(O)}},[t,b,r,l,d]),re=c.useCallback((u,f)=>{const x=(t||K(T)).set({hour:u,minute:f,second:0});if(p(x),r){const j={iso:x.toISO()||"",formatted:x.toFormat(`${l} ${d}`),timestamp:x.toMillis(),dateTime:x};r(j)}},[t,T,r,l,d]),le=c.useCallback((u,f)=>{const O=u.startOf("day"),x=f.startOf("day"),[j,q]=O<=x?[O,x]:[x,O];if(A(j),L(q),W(j),m){const me=H(j,l,d),pe=H(q,l,d),ye=Math.max(0,Math.ceil(q.diff(j,"days").days));m({start:me,end:pe,nights:ye})}},[m,l,d]),ie=c.useCallback(u=>{if(B(u),t){const f=t.setZone(u);if(p(f),W(f),r){const O={iso:f.toISO()||"",formatted:f.toFormat(`${l} ${d}`),timestamp:f.toMillis(),dateTime:f};r(O)}}else W(K(u))},[t,r,l,d]),X=()=>{N||g(!M)},ce=u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),X())},de=i?n&&k?`${n.toFormat("d MMM yyyy")} – ${k.toFormat("d MMM yyyy")}`:"":t?t.toFormat(`${l} ${b?d:""}`):"",he=v?w(v,T):void 0,fe=h?w(h,T):void 0;return e.jsxs("div",{ref:Y,className:`chronos-picker ${_}`,"data-disabled":N,"data-theme":z,children:[e.jsxs("div",{className:"chronos-input-wrapper",onClick:X,children:[e.jsx("input",{ref:Q,type:"text",className:"chronos-input",value:de,placeholder:y,readOnly:!0,disabled:N,onKeyDown:ce,"aria-label":Z,"aria-expanded":M,"aria-haspopup":"dialog",role:"combobox"}),e.jsxs("svg",{className:"chronos-calendar-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),e.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),e.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})]}),M&&e.jsx("div",{className:"chronos-dropdown","data-orientation":C,"data-range-mode":i,role:"dialog","aria-label":"Date and time picker dialog",children:e.jsxs("div",{className:"chronos-dropdown-content",children:[i&&n&&k&&e.jsxs("div",{className:"chronos-range-summary",children:[e.jsxs("div",{className:"chronos-range-nights",children:[Math.max(0,Math.ceil(k.diff(n,"days").days))," nights"]}),e.jsxs("div",{className:"chronos-range-dates",children:[n.toFormat("d MMM yyyy")," – ",k.toFormat("d MMM yyyy")]})]}),e.jsx(ee,{viewDate:ne,selectedDate:i?null:t,onDateSelect:ae,onViewDateChange:W,timezone:T,minDate:he,maxDate:fe,selectedStart:i?n:void 0,selectedEnd:i?k:void 0,onRangeSelect:i?le:void 0,holidays:E}),!i&&(b||P)&&e.jsxs("div",{className:"chronos-sidebar",children:[b&&e.jsx(se,{value:t,onChange:re,use24Hour:I,timezone:T}),P&&e.jsx(oe,{value:T,onChange:ie})]})]})})]})};S.COMMON_TIMEZONES=U,S.DEFAULT_TIMEZONE=G,S.DateTimePicker=te,S.convertToTimezone=w,S.nowInTimezone=K,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(T,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("luxon")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","luxon"],e):(T=typeof globalThis<"u"?globalThis:T||self,e(T.ChronosPicker={},T.jsxRuntime,T.React,T.luxon))})(this,function(T,e,c,S){"use strict";const H="Asia/Kolkata",G=[{value:"Asia/Kolkata",label:"India (IST)"},{value:"America/New_York",label:"Eastern Time (ET)"},{value:"America/Chicago",label:"Central Time (CT)"},{value:"America/Denver",label:"Mountain Time (MT)"},{value:"America/Los_Angeles",label:"Pacific Time (PT)"},{value:"Europe/London",label:"London (GMT/BST)"},{value:"Europe/Paris",label:"Central Europe (CET)"},{value:"Asia/Dubai",label:"Dubai (GST)"},{value:"Asia/Singapore",label:"Singapore (SGT)"},{value:"Asia/Tokyo",label:"Tokyo (JST)"},{value:"Australia/Sydney",label:"Sydney (AEDT)"},{value:"UTC",label:"UTC"}];function O(n,l){return S.DateTime.isDateTime(n)?n.setZone(l):typeof n=="string"?S.DateTime.fromISO(n,{zone:l}):S.DateTime.fromJSDate(n,{zone:l})}function K(n){return S.DateTime.now().setZone(n)}function U(n){const a=S.DateTime.now().setZone(n).offset,r=Math.floor(Math.abs(a)/60),d=Math.abs(a)%60;return`UTC${a>=0?"+":"-"}${r}${d>0?`:${d.toString().padStart(2,"0")}`:""}`}function F(n,l,a,r,d,v,h,y,N){const b=S.DateTime.fromObject({year:n,month:l,day:1},{zone:a}),x=b.startOf("week"),L=b.endOf("month").endOf("week"),P=S.DateTime.now().setZone(a).startOf("day"),_=h!=null&&y!=null,E=h==null?void 0:h.startOf("day"),C=y==null?void 0:y.endOf("day"),t=new Map;N&&N.forEach(M=>{let D;S.DateTime.isDateTime(M.date)?D=M.date.setZone(a):typeof M.date=="string"?D=S.DateTime.fromISO(M.date,{zone:a}):D=S.DateTime.fromJSDate(M.date,{zone:a}),t.set(D.toISODate()||"",{name:M.name,type:M.type||"national"})});const m=[];let I=[],i=x;for(;i<=L;){const M=i.month===l,D=i.hasSame(P,"day"),o=i.startOf("day"),p=i.toISODate()||"";let s=!1,$=!1,g=!1,W=!1;_&&E&&C?(g=o.hasSame(E,"day"),W=o.hasSame(C,"day"),$=o>=E&&o<=C||g||W,s=g||W):r&&(s=i.hasSame(r,"day"));let k=!1;d&&i<d.startOf("day")&&(k=!0),v&&i>v.endOf("day")&&(k=!0);const B=t.get(p);I.push({date:i,isCurrentMonth:M,isToday:D,isSelected:s,isDisabled:k,isInRange:$,isRangeStart:g,isRangeEnd:W,holiday:B?{date:i,...B}:void 0}),I.length===7&&(m.push(I),I=[]),i=i.plus({days:1})}return m}function V(){const n=S.DateTime.now().startOf("week"),l=[];for(let a=0;a<7;a++){const r=n.plus({days:a});l.push(r.toFormat("ccc"))}return l}function R(){const n=[];for(let l=1;l<=12;l++){const a=S.DateTime.fromObject({month:l});n.push(a.toFormat("MMMM"))}return n}const ee=({viewDate:n,selectedDate:l,onDateSelect:a,onViewDateChange:r,timezone:d,minDate:v,maxDate:h,selectedStart:y,selectedEnd:N,onRangeSelect:b,holidays:x})=>{const z=b!=null,L=c.useMemo(()=>F(n.year,n.month,d,l??void 0,v,h,y??void 0,N??void 0,x),[n,l,d,v,h,y,N,x]),P=c.useMemo(()=>V(),[]),_=c.useMemo(()=>R(),[]),E=()=>{r(n.minus({months:1}))},C=()=>{r(n.plus({months:1}))},t=o=>{const p=parseInt(o.target.value,10);r(n.set({month:p}))},m=o=>{const p=parseInt(o.target.value,10);r(n.set({year:p}))},I=(o,p)=>{if(!p)if(z&&b){const s=o.startOf("day");if(y==null)b(o,o);else if(N!=null&&y.hasSame(N,"day")){const $=y.startOf("day");s<$?b(o,y):b(y,o)}else b(o,o)}else a(o)},i=(o,p,s)=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),I(p,s))},M=n.year,D=Array.from({length:21},(o,p)=>M-10+p);return e.jsxs("div",{className:"chronos-calendar",role:"region","aria-label":"Calendar",children:[e.jsxs("div",{className:"chronos-calendar-header",children:[e.jsx("button",{type:"button",className:"chronos-nav-button",onClick:E,"aria-label":"Previous month",children:"‹"}),e.jsxs("div",{className:"chronos-month-year-selectors",children:[e.jsx("select",{className:"chronos-month-select",value:n.month,onChange:t,"aria-label":"Select month",children:_.map((o,p)=>e.jsx("option",{value:p+1,children:o},p))}),e.jsx("select",{className:"chronos-year-select",value:n.year,onChange:m,"aria-label":"Select year",children:D.map(o=>e.jsx("option",{value:o,children:o},o))})]}),e.jsx("button",{type:"button",className:"chronos-nav-button",onClick:C,"aria-label":"Next month",children:"›"})]}),e.jsxs("div",{className:"chronos-calendar-grid",children:[e.jsx("div",{className:"chronos-weekday-row",children:P.map(o=>e.jsx("div",{className:"chronos-weekday",children:o},o))}),L.map((o,p)=>e.jsx("div",{className:"chronos-week-row",children:o.map((s,$)=>e.jsxs("button",{type:"button",className:`chronos-day ${s.isSelected?"selected":""} ${s.isToday?"today":""} ${s.isCurrentMonth?"":"other-month"} ${s.isDisabled?"disabled":""} ${s.isInRange?"in-range":""} ${s.isRangeStart?"range-start":""} ${s.isRangeEnd?"range-end":""} ${s.holiday?`holiday ${s.holiday.type}`:""}`,onClick:()=>I(s.date,s.isDisabled),onKeyDown:g=>i(g,s.date,s.isDisabled),disabled:s.isDisabled,"aria-label":`${s.date.toFormat("MMMM d, yyyy")}${s.holiday?`, ${s.holiday.name}`:""}`,"aria-selected":s.isSelected,"aria-current":s.isToday?"date":void 0,title:s.holiday?s.holiday.name:void 0,children:[s.date.day,s.holiday&&e.jsx("span",{className:"chronos-holiday-dot"})]},$))},p))]})]})},ne=({value:n,onChange:l,use24Hour:a})=>{const[r,d]=c.useState((n==null?void 0:n.hour)??12),[v,h]=c.useState((n==null?void 0:n.minute)??0),[y,N]=c.useState(n&&n.hour>=12?"PM":"AM");c.useEffect(()=>{n&&(d(n.hour),h(n.minute),N(n.hour>=12?"PM":"AM"))},[n]);const b=t=>{d(t);let m=t;a||(y==="PM"&&t!==12?m=t+12:y==="AM"&&t===12&&(m=0)),l(m,v)},x=t=>{h(t),l(r,t)},z=()=>{const t=y==="AM"?"PM":"AM";N(t);let m=r;t==="PM"&&r!==12?m=r+12:t==="AM"&&r===12?m=0:t==="AM"&&r>12&&(m=r-12),l(m,v)},L=a?r:r%12||12,P=a?23:12,_=a?0:1,E=Array.from({length:P-_+1},(t,m)=>_+m),C=Array.from({length:60},(t,m)=>m);return e.jsxs("div",{className:"chronos-time-picker",role:"group","aria-label":"Time picker",children:[e.jsxs("div",{className:"chronos-time-header",children:[e.jsxs("svg",{className:"chronos-clock-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("span",{children:"Time"})]}),e.jsxs("div",{className:"chronos-time-controls",children:[e.jsxs("div",{className:"chronos-time-input-group",children:[e.jsx("label",{htmlFor:"chronos-hour-select",className:"chronos-time-label",children:"Hour"}),e.jsx("select",{id:"chronos-hour-select",className:"chronos-time-select",value:L,onChange:t=>b(parseInt(t.target.value,10)),"aria-label":"Select hour",children:E.map(t=>e.jsx("option",{value:t,children:t.toString().padStart(2,"0")},t))})]}),e.jsx("span",{className:"chronos-time-separator",children:":"}),e.jsxs("div",{className:"chronos-time-input-group",children:[e.jsx("label",{htmlFor:"chronos-minute-select",className:"chronos-time-label",children:"Minute"}),e.jsx("select",{id:"chronos-minute-select",className:"chronos-time-select",value:v,onChange:t=>x(parseInt(t.target.value,10)),"aria-label":"Select minute",children:C.map(t=>e.jsx("option",{value:t,children:t.toString().padStart(2,"0")},t))})]}),!a&&e.jsx("button",{type:"button",className:"chronos-period-toggle",onClick:z,"aria-label":`Switch to ${y==="AM"?"PM":"AM"}`,children:y})]})]})},te=({value:n,onChange:l})=>{const[a,r]=c.useState(!1),d=G.find(h=>h.value===n)||{label:n},v=h=>{l(h),r(!1)};return e.jsxs("div",{className:"chronos-timezone-selector",children:[e.jsxs("div",{className:"chronos-timezone-header",children:[e.jsxs("svg",{className:"chronos-globe-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),e.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),e.jsx("span",{children:"Timezone"})]}),e.jsxs("button",{type:"button",className:"chronos-timezone-button",onClick:()=>r(!a),"aria-expanded":a,"aria-label":"Select timezone",children:[e.jsx("span",{className:"chronos-timezone-label",children:d.label}),e.jsx("span",{className:"chronos-timezone-offset",children:U(n)}),e.jsx("svg",{className:`chronos-chevron ${a?"expanded":""}`,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),a&&e.jsx("div",{className:"chronos-timezone-list",role:"listbox",children:G.map(h=>e.jsxs("button",{type:"button",className:`chronos-timezone-option ${h.value===n?"selected":""}`,onClick:()=>v(h.value),role:"option","aria-selected":h.value===n,children:[e.jsx("span",{className:"chronos-timezone-option-label",children:h.label}),e.jsx("span",{className:"chronos-timezone-option-offset",children:U(h.value)})]},h.value))})]})};function q(n,l,a){return{iso:n.toISO()||"",formatted:n.toFormat(`${l} ${a}`),timestamp:n.toMillis(),dateTime:n}}const oe=({value:n,onChange:l,timezone:a=H,dateFormat:r="DD",timeFormat:d="HH:mm",minDate:v,maxDate:h,placeholder:y="Select date and time",disabled:N=!1,showTime:b=!0,use24Hour:x=!0,className:z="",ariaLabel:L="Date and time picker",showTimezoneSelector:P=!1,theme:_="light",orientation:E="portrait",selectionMode:C="single",rangeValue:t,onRangeChange:m,holidays:I})=>{const i=C==="range",[M,D]=c.useState(!1),[o,p]=c.useState(()=>!i&&n?O(n,a):null),[s,$]=c.useState(()=>i&&(t!=null&&t.start)?O(t.start,a):null),[g,W]=c.useState(()=>i&&(t!=null&&t.end)?O(t.end,a):null),[k,B]=c.useState(a),[le,j]=c.useState(()=>o||s||g||K(a)),J=c.useRef(null),Q=c.useRef(null);c.useEffect(()=>{!i&&n&&p(O(n,k))},[n,k,i]),c.useEffect(()=>{i&&(t==null?void 0:t.start)!=null&&(t==null?void 0:t.end)!=null&&($(O(t.start,k)),W(O(t.end,k)))},[i,t,k]),c.useEffect(()=>{const u=f=>{J.current&&!J.current.contains(f.target)&&D(!1)};if(M)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[M]),c.useEffect(()=>{const u=f=>{var w;f.key==="Escape"&&M&&(D(!1),(w=Q.current)==null||w.focus())};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[M]);const re=c.useCallback(u=>{let f=u;if(o&&(f=u.set({hour:o.hour,minute:o.minute,second:o.second})),p(f),j(f),b||D(!1),l){const w={iso:f.toISO()||"",formatted:f.toFormat(`${r} ${d}`),timestamp:f.toMillis(),dateTime:f};l(w)}},[o,b,l,r,d]),ie=c.useCallback((u,f)=>{const A=(o||K(k)).set({hour:u,minute:f,second:0});if(p(A),l){const Z={iso:A.toISO()||"",formatted:A.toFormat(`${r} ${d}`),timestamp:A.toMillis(),dateTime:A};l(Z)}},[o,k,l,r,d]),ce=c.useCallback((u,f)=>{const w=u.startOf("day"),A=f.startOf("day"),[Z,Y]=w<=A?[w,A]:[A,w];if($(Z),W(Y),j(Z),m){const ye=q(Z,r,d),ue=q(Y,r,d),Me=Math.max(0,Math.ceil(Y.diff(Z,"days").days));m({start:ye,end:ue,nights:Me})}},[m,r,d]),de=c.useCallback(u=>{if(B(u),o){const f=o.setZone(u);if(p(f),j(f),l){const w={iso:f.toISO()||"",formatted:f.toFormat(`${r} ${d}`),timestamp:f.toMillis(),dateTime:f};l(w)}}else j(K(u))},[o,l,r,d]),X=()=>{N||D(!M)},he=u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),X())},fe=i?s&&g?`${s.toFormat("d MMM yyyy")} – ${g.toFormat("d MMM yyyy")}`:"":o?o.toFormat(`${r} ${b?d:""}`):"",me=v?O(v,k):void 0,pe=h?O(h,k):void 0;return e.jsxs("div",{ref:J,className:`chronos-picker ${z}`,"data-disabled":N,"data-theme":_,children:[e.jsxs("div",{className:"chronos-input-wrapper",onClick:X,children:[e.jsx("input",{ref:Q,type:"text",className:"chronos-input",value:fe,placeholder:y,readOnly:!0,disabled:N,onKeyDown:he,"aria-label":L,"aria-expanded":M,"aria-haspopup":"dialog",role:"combobox"}),e.jsxs("svg",{className:"chronos-calendar-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),e.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),e.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})]}),M&&e.jsx("div",{className:"chronos-dropdown","data-orientation":E,"data-range-mode":i,role:"dialog","aria-label":"Date and time picker dialog",children:e.jsxs("div",{className:"chronos-dropdown-content",children:[i&&s&&g&&e.jsxs("div",{className:"chronos-range-summary",children:[e.jsxs("div",{className:"chronos-range-nights",children:[Math.max(0,Math.ceil(g.diff(s,"days").days))," nights"]}),e.jsxs("div",{className:"chronos-range-dates",children:[s.toFormat("d MMM yyyy")," – ",g.toFormat("d MMM yyyy")]})]}),e.jsx(ee,{viewDate:le,selectedDate:i?null:o,onDateSelect:re,onViewDateChange:j,timezone:k,minDate:me,maxDate:pe,selectedStart:i?s:void 0,selectedEnd:i?g:void 0,onRangeSelect:i?ce:void 0,holidays:I}),!i&&(b||P)&&e.jsxs("div",{className:"chronos-sidebar",children:[b&&e.jsx(ne,{value:o,onChange:ie,use24Hour:x,timezone:k}),P&&e.jsx(te,{value:k,onChange:de})]})]})})]})},se=[{date:"2026-01-26",name:"Republic Day",type:"national"},{date:"2026-03-19",name:"Holi",type:"national"},{date:"2026-04-14",name:"Dr. Ambedkar Jayanti",type:"national"},{date:"2026-08-15",name:"Independence Day",type:"national"},{date:"2026-10-02",name:"Gandhi Jayanti",type:"national"},{date:"2026-10-20",name:"Dussehra",type:"national"},{date:"2026-11-08",name:"Diwali",type:"national"},{date:"2026-12-25",name:"Christmas",type:"national"}],ae=[{date:"2026-01-24",name:"Long Weekend: Trip to Jaipur?",type:"long-weekend"},{date:"2026-01-25",name:"Long Weekend: Fort Visit",type:"long-weekend"},{date:"2026-01-26",name:"Republic Day",type:"long-weekend"},{date:"2026-03-19",name:"Holi Celebration",type:"long-weekend"},{date:"2026-03-20",name:"Take a leave! Beach time?",type:"long-weekend"},{date:"2026-03-21",name:"Relaxing Saturday",type:"long-weekend"},{date:"2026-03-22",name:"Lazy Sunday",type:"long-weekend"},{date:"2026-08-15",name:"Independence Day",type:"long-weekend"},{date:"2026-08-16",name:"Sunday Brunch",type:"long-weekend"},{date:"2026-08-17",name:"Take a leave? Hills calling!",type:"long-weekend"},{date:"2026-11-07",name:"Choti Diwali",type:"long-weekend"},{date:"2026-11-08",name:"Diwali",type:"long-weekend"},{date:"2026-11-09",name:"Govardhan Puja (Take leave)",type:"long-weekend"}];T.COMMON_TIMEZONES=G,T.DEFAULT_TIMEZONE=H,T.DateTimePicker=oe,T.INDIAN_HOLIDAYS_2026=se,T.LONG_WEEKENDS_2026=ae,T.convertToTimezone=O,T.nowInTimezone=K,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"holidays.d.ts","sourceRoot":"","sources":["../../../src/constants/holidays.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,eAAO,MAAM,oBAAoB,EAAE,OAAO,EAUzC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,OAAO,EAqBvC,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { DateTimePicker } from './components/DateTimePicker';
|
|
2
2
|
export type { DateTimePickerProps, DateTimeValue, DateTimeRangeValue } from './types';
|
|
3
3
|
export { DEFAULT_TIMEZONE, COMMON_TIMEZONES, convertToTimezone, nowInTimezone } from './utils/timezone';
|
|
4
|
+
export { INDIAN_HOLIDAYS_2026, LONG_WEEKENDS_2026 } from './constants/holidays';
|
|
5
|
+
export type { Holiday } from './types';
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACxG,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAChF,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC"}
|
package/package.json
CHANGED