@theengineerguy/chronos-picker 1.0.5 → 1.0.7

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 CHANGED
@@ -1,7 +1,43 @@
1
- import { jsxs as h, jsx as o } from "react/jsx-runtime";
2
- import { useMemo as G, useState as w, useEffect as K, useRef as Q, useCallback as j } from "react";
3
- import { DateTime as O } from "luxon";
4
- const me = "Asia/Kolkata", X = [
1
+ import { jsxs as h, jsx as a } from "react/jsx-runtime";
2
+ import { useMemo as j, useState as $, useEffect as G, useRef as Q, useCallback as H } from "react";
3
+ import { DateTime as w } from "luxon";
4
+ const pe = "Asia/Kolkata", ye = [
5
+ // --- 2026 National Holidays (India) ---
6
+ { date: "2026-01-26", name: "Republic Day", type: "national" },
7
+ { date: "2026-03-19", name: "Holi", type: "national" },
8
+ // Tentative
9
+ { date: "2026-04-14", name: "Dr. Ambedkar Jayanti", type: "national" },
10
+ { date: "2026-08-15", name: "Independence Day", type: "national" },
11
+ { date: "2026-10-02", name: "Gandhi Jayanti", type: "national" },
12
+ { date: "2026-10-20", name: "Dussehra", type: "national" },
13
+ // Tentative
14
+ { date: "2026-11-08", name: "Diwali", type: "national" },
15
+ // Tentative
16
+ { date: "2026-12-25", name: "Christmas", type: "national" }
17
+ ], Me = [
18
+ // Republic Day Weekend (Jan 24-26)
19
+ { date: "2026-01-24", name: "Long Weekend: Trip to Jaipur?", type: "long-weekend" },
20
+ { date: "2026-01-25", name: "Long Weekend: Fort Visit", type: "long-weekend" },
21
+ { date: "2026-01-26", name: "Republic Day", type: "long-weekend" },
22
+ // Holi Weekend (Mar 19-22 - Take Friday off)
23
+ { date: "2026-03-19", name: "Holi Celebration", type: "long-weekend" },
24
+ { date: "2026-03-20", name: "Take a leave! Beach time?", type: "long-weekend" },
25
+ { date: "2026-03-21", name: "Relaxing Saturday", type: "long-weekend" },
26
+ { date: "2026-03-22", name: "Lazy Sunday", type: "long-weekend" },
27
+ // Independence Day Weekend (Aug 15-17)
28
+ { date: "2026-08-15", name: "Independence Day", type: "long-weekend" },
29
+ { date: "2026-08-16", name: "Sunday Brunch", type: "long-weekend" },
30
+ { date: "2026-08-17", name: "Take a leave? Hills calling!", type: "long-weekend" },
31
+ // Monday leave suggestion
32
+ // Diwali Weekend (Nov 7-9)
33
+ { date: "2026-11-07", name: "Choti Diwali", type: "long-weekend" },
34
+ { date: "2026-11-08", name: "Diwali", type: "long-weekend" },
35
+ { date: "2026-11-09", name: "Govardhan Puja (Take leave)", type: "long-weekend" }
36
+ ];
37
+ function be(e) {
38
+ return e === pe ? [...ye, ...Me] : [];
39
+ }
40
+ const ke = "Asia/Kolkata", X = [
5
41
  { value: "Asia/Kolkata", label: "India (IST)" },
6
42
  { value: "America/New_York", label: "Eastern Time (ET)" },
7
43
  { value: "America/Chicago", label: "Central Time (CT)" },
@@ -15,204 +51,204 @@ const me = "Asia/Kolkata", X = [
15
51
  { value: "Australia/Sydney", label: "Sydney (AEDT)" },
16
52
  { value: "UTC", label: "UTC" }
17
53
  ];
18
- function R(e, r) {
19
- return O.isDateTime(e) ? e.setZone(r) : typeof e == "string" ? O.fromISO(e, { zone: r }) : O.fromJSDate(e, { zone: r });
54
+ function _(e, i) {
55
+ return w.isDateTime(e) ? e.setZone(i) : typeof e == "string" ? w.fromISO(e, { zone: i }) : w.fromJSDate(e, { zone: i });
20
56
  }
21
- function J(e) {
22
- return O.now().setZone(e);
57
+ function U(e) {
58
+ return w.now().setZone(e);
23
59
  }
24
- function F(e) {
25
- const a = O.now().setZone(e).offset, i = Math.floor(Math.abs(a) / 60), c = Math.abs(a) % 60;
26
- return `UTC${a >= 0 ? "+" : "-"}${i}${c > 0 ? `:${c.toString().padStart(2, "0")}` : ""}`;
60
+ function V(e) {
61
+ const s = w.now().setZone(e).offset, r = Math.floor(Math.abs(s) / 60), l = Math.abs(s) % 60;
62
+ return `UTC${s >= 0 ? "+" : "-"}${r}${l > 0 ? `:${l.toString().padStart(2, "0")}` : ""}`;
27
63
  }
28
- function ue(e, r, a, i, c, N, d, p, k) {
29
- const b = O.fromObject(
30
- { year: e, month: r, day: 1 },
31
- { zone: a }
32
- ), E = b.startOf("week"), z = b.endOf("month").endOf("week"), I = O.now().setZone(a).startOf("day"), P = d != null && p != null, x = d == null ? void 0 : d.startOf("day"), D = p == null ? void 0 : p.endOf("day"), t = /* @__PURE__ */ new Map();
33
- k && k.forEach((M) => {
34
- let g;
35
- O.isDateTime(M.date) ? g = M.date.setZone(a) : typeof M.date == "string" ? g = O.fromISO(M.date, { zone: a }) : g = O.fromJSDate(M.date, { zone: a }), t.set(g.toISODate() || "", { name: M.name, type: M.type || "national" });
64
+ function ve(e, i, s, r, l, k, c, y, v) {
65
+ const M = w.fromObject(
66
+ { year: e, month: i, day: 1 },
67
+ { zone: s }
68
+ ), E = M.startOf("week"), R = M.endOf("month").endOf("week"), P = w.now().setZone(s).startOf("day"), L = c != null && y != null, A = c == null ? void 0 : c.startOf("day"), C = y == null ? void 0 : y.endOf("day"), n = /* @__PURE__ */ new Map();
69
+ v && v.forEach((N) => {
70
+ let d;
71
+ w.isDateTime(N.date) ? d = N.date.setZone(s) : typeof N.date == "string" ? d = w.fromISO(N.date, { zone: s }) : d = w.fromJSDate(N.date, { zone: s }), n.set(d.toISODate() || "", { name: N.name, type: N.type || "national" });
36
72
  });
37
73
  const u = [];
38
- let $ = [], l = E;
39
- for (; l <= z; ) {
40
- const M = l.month === r, g = l.hasSame(I, "day"), n = l.startOf("day"), f = l.toISODate() || "";
41
- let s = !1, C = !1, T = !1, L = !1;
42
- P && x && D ? (T = n.hasSame(x, "day"), L = n.hasSame(D, "day"), C = n >= x && n <= D || T || L, s = T || L) : i && (s = l.hasSame(i, "day"));
43
- let v = !1;
44
- c && l < c.startOf("day") && (v = !0), N && l > N.endOf("day") && (v = !0);
45
- const B = t.get(f);
46
- $.push({
47
- date: l,
48
- isCurrentMonth: M,
49
- isToday: g,
50
- isSelected: s,
51
- isDisabled: v,
52
- isInRange: C,
53
- isRangeStart: T,
54
- isRangeEnd: L,
55
- holiday: B ? { date: l, ...B } : void 0
56
- }), $.length === 7 && (u.push($), $ = []), l = l.plus({ days: 1 });
74
+ let x = [], b = E;
75
+ for (; b <= R; ) {
76
+ const N = b.month === i, d = b.hasSame(P, "day"), o = b.startOf("day"), f = b.toISODate() || "";
77
+ let t = !1, D = !1, g = !1, W = !1;
78
+ L && A && C ? (g = o.hasSame(A, "day"), W = o.hasSame(C, "day"), D = o >= A && o <= C || g || W, t = g || W) : r && (t = b.hasSame(r, "day"));
79
+ let S = !1;
80
+ l && b < l.startOf("day") && (S = !0), k && b > k.endOf("day") && (S = !0);
81
+ const K = n.get(f);
82
+ x.push({
83
+ date: b,
84
+ isCurrentMonth: N,
85
+ isToday: d,
86
+ isSelected: t,
87
+ isDisabled: S,
88
+ isInRange: D,
89
+ isRangeStart: g,
90
+ isRangeEnd: W,
91
+ holiday: K ? { date: b, ...K } : void 0
92
+ }), x.length === 7 && (u.push(x), x = []), b = b.plus({ days: 1 });
57
93
  }
58
94
  return u;
59
95
  }
60
- function fe() {
61
- const e = O.now().startOf("week"), r = [];
62
- for (let a = 0; a < 7; a++) {
63
- const i = e.plus({ days: a });
64
- r.push(i.toFormat("ccc"));
96
+ function ge() {
97
+ const e = w.now().startOf("week"), i = [];
98
+ for (let s = 0; s < 7; s++) {
99
+ const r = e.plus({ days: s });
100
+ i.push(r.toFormat("ccc"));
65
101
  }
66
- return r;
102
+ return i;
67
103
  }
68
- function pe() {
104
+ function Ne() {
69
105
  const e = [];
70
- for (let r = 1; r <= 12; r++) {
71
- const a = O.fromObject({ month: r });
72
- e.push(a.toFormat("MMMM"));
106
+ for (let i = 1; i <= 12; i++) {
107
+ const s = w.fromObject({ month: i });
108
+ e.push(s.toFormat("MMMM"));
73
109
  }
74
110
  return e;
75
111
  }
76
- const ye = ({
112
+ const Te = ({
77
113
  viewDate: e,
78
- selectedDate: r,
79
- onDateSelect: a,
80
- onViewDateChange: i,
81
- timezone: c,
82
- minDate: N,
83
- maxDate: d,
84
- selectedStart: p,
85
- selectedEnd: k,
86
- onRangeSelect: b,
114
+ selectedDate: i,
115
+ onDateSelect: s,
116
+ onViewDateChange: r,
117
+ timezone: l,
118
+ minDate: k,
119
+ maxDate: c,
120
+ selectedStart: y,
121
+ selectedEnd: v,
122
+ onRangeSelect: M,
87
123
  holidays: E
88
124
  }) => {
89
- const W = b != null, z = G(() => ue(
125
+ const z = M != null, R = j(() => ve(
90
126
  e.year,
91
127
  e.month,
128
+ l,
129
+ i ?? void 0,
130
+ k,
92
131
  c,
93
- r ?? void 0,
94
- N,
95
- d,
96
- p ?? void 0,
97
- k ?? void 0,
132
+ y ?? void 0,
133
+ v ?? void 0,
98
134
  E
99
- ), [e, r, c, N, d, p, k, E]), I = G(() => fe(), []), P = G(() => pe(), []), x = () => {
100
- i(e.minus({ months: 1 }));
101
- }, D = () => {
102
- i(e.plus({ months: 1 }));
103
- }, t = (n) => {
104
- const f = parseInt(n.target.value, 10);
105
- i(e.set({ month: f }));
106
- }, u = (n) => {
107
- const f = parseInt(n.target.value, 10);
108
- i(e.set({ year: f }));
109
- }, $ = (n, f) => {
135
+ ), [e, i, l, k, c, y, v, E]), P = j(() => ge(), []), L = j(() => Ne(), []), A = () => {
136
+ r(e.minus({ months: 1 }));
137
+ }, C = () => {
138
+ r(e.plus({ months: 1 }));
139
+ }, n = (o) => {
140
+ const f = parseInt(o.target.value, 10);
141
+ r(e.set({ month: f }));
142
+ }, u = (o) => {
143
+ const f = parseInt(o.target.value, 10);
144
+ r(e.set({ year: f }));
145
+ }, x = (o, f) => {
110
146
  if (!f)
111
- if (W && b) {
112
- const s = n.startOf("day");
113
- if (p == null)
114
- b(n, n);
115
- else if (k != null && p.hasSame(k, "day")) {
116
- const C = p.startOf("day");
117
- s < C ? b(n, p) : b(p, n);
147
+ if (z && M) {
148
+ const t = o.startOf("day");
149
+ if (y == null)
150
+ M(o, o);
151
+ else if (v != null && y.hasSame(v, "day")) {
152
+ const D = y.startOf("day");
153
+ t < D ? M(o, y) : M(y, o);
118
154
  } else
119
- b(n, n);
155
+ M(o, o);
120
156
  } else
121
- a(n);
122
- }, l = (n, f, s) => {
123
- (n.key === "Enter" || n.key === " ") && (n.preventDefault(), $(f, s));
124
- }, M = e.year, g = Array.from({ length: 21 }, (n, f) => M - 10 + f);
157
+ s(o);
158
+ }, b = (o, f, t) => {
159
+ (o.key === "Enter" || o.key === " ") && (o.preventDefault(), x(f, t));
160
+ }, N = e.year, d = Array.from({ length: 21 }, (o, f) => N - 10 + f);
125
161
  return /* @__PURE__ */ h("div", { className: "chronos-calendar", role: "region", "aria-label": "Calendar", children: [
126
162
  /* @__PURE__ */ h("div", { className: "chronos-calendar-header", children: [
127
- /* @__PURE__ */ o(
163
+ /* @__PURE__ */ a(
128
164
  "button",
129
165
  {
130
166
  type: "button",
131
167
  className: "chronos-nav-button",
132
- onClick: x,
168
+ onClick: A,
133
169
  "aria-label": "Previous month",
134
170
  children: "‹"
135
171
  }
136
172
  ),
137
173
  /* @__PURE__ */ h("div", { className: "chronos-month-year-selectors", children: [
138
- /* @__PURE__ */ o(
174
+ /* @__PURE__ */ a(
139
175
  "select",
140
176
  {
141
177
  className: "chronos-month-select",
142
178
  value: e.month,
143
- onChange: t,
179
+ onChange: n,
144
180
  "aria-label": "Select month",
145
- children: P.map((n, f) => /* @__PURE__ */ o("option", { value: f + 1, children: n }, f))
181
+ children: L.map((o, f) => /* @__PURE__ */ a("option", { value: f + 1, children: o }, f))
146
182
  }
147
183
  ),
148
- /* @__PURE__ */ o(
184
+ /* @__PURE__ */ a(
149
185
  "select",
150
186
  {
151
187
  className: "chronos-year-select",
152
188
  value: e.year,
153
189
  onChange: u,
154
190
  "aria-label": "Select year",
155
- children: g.map((n) => /* @__PURE__ */ o("option", { value: n, children: n }, n))
191
+ children: d.map((o) => /* @__PURE__ */ a("option", { value: o, children: o }, o))
156
192
  }
157
193
  )
158
194
  ] }),
159
- /* @__PURE__ */ o(
195
+ /* @__PURE__ */ a(
160
196
  "button",
161
197
  {
162
198
  type: "button",
163
199
  className: "chronos-nav-button",
164
- onClick: D,
200
+ onClick: C,
165
201
  "aria-label": "Next month",
166
202
  children: "›"
167
203
  }
168
204
  )
169
205
  ] }),
170
206
  /* @__PURE__ */ h("div", { className: "chronos-calendar-grid", children: [
171
- /* @__PURE__ */ o("div", { className: "chronos-weekday-row", children: I.map((n) => /* @__PURE__ */ o("div", { className: "chronos-weekday", children: n }, n)) }),
172
- z.map((n, f) => /* @__PURE__ */ o("div", { className: "chronos-week-row", children: n.map((s, C) => /* @__PURE__ */ h(
207
+ /* @__PURE__ */ a("div", { className: "chronos-weekday-row", children: P.map((o) => /* @__PURE__ */ a("div", { className: "chronos-weekday", children: o }, o)) }),
208
+ R.map((o, f) => /* @__PURE__ */ a("div", { className: "chronos-week-row", children: o.map((t, D) => /* @__PURE__ */ h(
173
209
  "button",
174
210
  {
175
211
  type: "button",
176
- 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}` : ""}`,
177
- onClick: () => $(s.date, s.isDisabled),
178
- onKeyDown: (T) => l(T, s.date, s.isDisabled),
179
- disabled: s.isDisabled,
180
- "aria-label": `${s.date.toFormat("MMMM d, yyyy")}${s.holiday ? `, ${s.holiday.name}` : ""}`,
181
- "aria-selected": s.isSelected,
182
- "aria-current": s.isToday ? "date" : void 0,
183
- title: s.holiday ? s.holiday.name : void 0,
212
+ className: `chronos-day ${t.isSelected ? "selected" : ""} ${t.isToday ? "today" : ""} ${t.isCurrentMonth ? "" : "other-month"} ${t.isDisabled ? "disabled" : ""} ${t.isInRange ? "in-range" : ""} ${t.isRangeStart ? "range-start" : ""} ${t.isRangeEnd ? "range-end" : ""} ${t.holiday ? `holiday ${t.holiday.type}` : ""}`,
213
+ onClick: () => x(t.date, t.isDisabled),
214
+ onKeyDown: (g) => b(g, t.date, t.isDisabled),
215
+ disabled: t.isDisabled,
216
+ "aria-label": `${t.date.toFormat("MMMM d, yyyy")}${t.holiday ? `, ${t.holiday.name}` : ""}`,
217
+ "aria-selected": t.isSelected,
218
+ "aria-current": t.isToday ? "date" : void 0,
219
+ title: t.holiday ? t.holiday.name : void 0,
184
220
  children: [
185
- s.date.day,
186
- s.holiday && /* @__PURE__ */ o("span", { className: "chronos-holiday-dot" })
221
+ t.date.day,
222
+ t.holiday && /* @__PURE__ */ a("span", { className: "chronos-holiday-dot" })
187
223
  ]
188
224
  },
189
- C
225
+ D
190
226
  )) }, f))
191
227
  ] })
192
228
  ] });
193
- }, Me = ({
229
+ }, we = ({
194
230
  value: e,
195
- onChange: r,
196
- use24Hour: a
231
+ onChange: i,
232
+ use24Hour: s
197
233
  }) => {
198
- const [i, c] = w((e == null ? void 0 : e.hour) ?? 12), [N, d] = w((e == null ? void 0 : e.minute) ?? 0), [p, k] = w(
234
+ const [r, l] = $((e == null ? void 0 : e.hour) ?? 12), [k, c] = $((e == null ? void 0 : e.minute) ?? 0), [y, v] = $(
199
235
  e && e.hour >= 12 ? "PM" : "AM"
200
236
  );
201
- K(() => {
202
- e && (c(e.hour), d(e.minute), k(e.hour >= 12 ? "PM" : "AM"));
237
+ G(() => {
238
+ e && (l(e.hour), c(e.minute), v(e.hour >= 12 ? "PM" : "AM"));
203
239
  }, [e]);
204
- const b = (t) => {
205
- c(t);
206
- let u = t;
207
- a || (p === "PM" && t !== 12 ? u = t + 12 : p === "AM" && t === 12 && (u = 0)), r(u, N);
208
- }, E = (t) => {
209
- d(t), r(i, t);
210
- }, W = () => {
211
- const t = p === "AM" ? "PM" : "AM";
212
- k(t);
213
- let u = i;
214
- t === "PM" && i !== 12 ? u = i + 12 : t === "AM" && i === 12 ? u = 0 : t === "AM" && i > 12 && (u = i - 12), r(u, N);
215
- }, z = a ? i : i % 12 || 12, I = a ? 23 : 12, P = a ? 0 : 1, x = Array.from({ length: I - P + 1 }, (t, u) => P + u), D = Array.from({ length: 60 }, (t, u) => u);
240
+ const M = (n) => {
241
+ l(n);
242
+ let u = n;
243
+ s || (y === "PM" && n !== 12 ? u = n + 12 : y === "AM" && n === 12 && (u = 0)), i(u, k);
244
+ }, E = (n) => {
245
+ c(n), i(r, n);
246
+ }, z = () => {
247
+ const n = y === "AM" ? "PM" : "AM";
248
+ v(n);
249
+ let u = r;
250
+ n === "PM" && r !== 12 ? u = r + 12 : n === "AM" && r === 12 ? u = 0 : n === "AM" && r > 12 && (u = r - 12), i(u, k);
251
+ }, R = s ? r : r % 12 || 12, P = s ? 23 : 12, L = s ? 0 : 1, A = Array.from({ length: P - L + 1 }, (n, u) => L + u), C = Array.from({ length: 60 }, (n, u) => u);
216
252
  return /* @__PURE__ */ h("div", { className: "chronos-time-picker", role: "group", "aria-label": "Time picker", children: [
217
253
  /* @__PURE__ */ h("div", { className: "chronos-time-header", children: [
218
254
  /* @__PURE__ */ h(
@@ -225,63 +261,63 @@ const ye = ({
225
261
  stroke: "currentColor",
226
262
  strokeWidth: "2",
227
263
  children: [
228
- /* @__PURE__ */ o("circle", { cx: "12", cy: "12", r: "10" }),
229
- /* @__PURE__ */ o("polyline", { points: "12 6 12 12 16 14" })
264
+ /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "10" }),
265
+ /* @__PURE__ */ a("polyline", { points: "12 6 12 12 16 14" })
230
266
  ]
231
267
  }
232
268
  ),
233
- /* @__PURE__ */ o("span", { children: "Time" })
269
+ /* @__PURE__ */ a("span", { children: "Time" })
234
270
  ] }),
235
271
  /* @__PURE__ */ h("div", { className: "chronos-time-controls", children: [
236
272
  /* @__PURE__ */ h("div", { className: "chronos-time-input-group", children: [
237
- /* @__PURE__ */ o("label", { htmlFor: "chronos-hour-select", className: "chronos-time-label", children: "Hour" }),
238
- /* @__PURE__ */ o(
273
+ /* @__PURE__ */ a("label", { htmlFor: "chronos-hour-select", className: "chronos-time-label", children: "Hour" }),
274
+ /* @__PURE__ */ a(
239
275
  "select",
240
276
  {
241
277
  id: "chronos-hour-select",
242
278
  className: "chronos-time-select",
243
- value: z,
244
- onChange: (t) => b(parseInt(t.target.value, 10)),
279
+ value: R,
280
+ onChange: (n) => M(parseInt(n.target.value, 10)),
245
281
  "aria-label": "Select hour",
246
- children: x.map((t) => /* @__PURE__ */ o("option", { value: t, children: t.toString().padStart(2, "0") }, t))
282
+ children: A.map((n) => /* @__PURE__ */ a("option", { value: n, children: n.toString().padStart(2, "0") }, n))
247
283
  }
248
284
  )
249
285
  ] }),
250
- /* @__PURE__ */ o("span", { className: "chronos-time-separator", children: ":" }),
286
+ /* @__PURE__ */ a("span", { className: "chronos-time-separator", children: ":" }),
251
287
  /* @__PURE__ */ h("div", { className: "chronos-time-input-group", children: [
252
- /* @__PURE__ */ o("label", { htmlFor: "chronos-minute-select", className: "chronos-time-label", children: "Minute" }),
253
- /* @__PURE__ */ o(
288
+ /* @__PURE__ */ a("label", { htmlFor: "chronos-minute-select", className: "chronos-time-label", children: "Minute" }),
289
+ /* @__PURE__ */ a(
254
290
  "select",
255
291
  {
256
292
  id: "chronos-minute-select",
257
293
  className: "chronos-time-select",
258
- value: N,
259
- onChange: (t) => E(parseInt(t.target.value, 10)),
294
+ value: k,
295
+ onChange: (n) => E(parseInt(n.target.value, 10)),
260
296
  "aria-label": "Select minute",
261
- children: D.map((t) => /* @__PURE__ */ o("option", { value: t, children: t.toString().padStart(2, "0") }, t))
297
+ children: C.map((n) => /* @__PURE__ */ a("option", { value: n, children: n.toString().padStart(2, "0") }, n))
262
298
  }
263
299
  )
264
300
  ] }),
265
- !a && /* @__PURE__ */ o(
301
+ !s && /* @__PURE__ */ a(
266
302
  "button",
267
303
  {
268
304
  type: "button",
269
305
  className: "chronos-period-toggle",
270
- onClick: W,
271
- "aria-label": `Switch to ${p === "AM" ? "PM" : "AM"}`,
272
- children: p
306
+ onClick: z,
307
+ "aria-label": `Switch to ${y === "AM" ? "PM" : "AM"}`,
308
+ children: y
273
309
  }
274
310
  )
275
311
  ] })
276
312
  ] });
277
- }, be = ({
313
+ }, De = ({
278
314
  value: e,
279
- onChange: r
315
+ onChange: i
280
316
  }) => {
281
- const [a, i] = w(!1), c = X.find((d) => d.value === e) || {
317
+ const [s, r] = $(!1), l = X.find((c) => c.value === e) || {
282
318
  label: e
283
- }, N = (d) => {
284
- r(d), i(!1);
319
+ }, k = (c) => {
320
+ i(c), r(!1);
285
321
  };
286
322
  return /* @__PURE__ */ h("div", { className: "chronos-timezone-selector", children: [
287
323
  /* @__PURE__ */ h("div", { className: "chronos-timezone-header", children: [
@@ -295,183 +331,185 @@ const ye = ({
295
331
  stroke: "currentColor",
296
332
  strokeWidth: "2",
297
333
  children: [
298
- /* @__PURE__ */ o("circle", { cx: "12", cy: "12", r: "10" }),
299
- /* @__PURE__ */ o("line", { x1: "2", y1: "12", x2: "22", y2: "12" }),
300
- /* @__PURE__ */ o("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" })
334
+ /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "10" }),
335
+ /* @__PURE__ */ a("line", { x1: "2", y1: "12", x2: "22", y2: "12" }),
336
+ /* @__PURE__ */ a("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" })
301
337
  ]
302
338
  }
303
339
  ),
304
- /* @__PURE__ */ o("span", { children: "Timezone" })
340
+ /* @__PURE__ */ a("span", { children: "Timezone" })
305
341
  ] }),
306
342
  /* @__PURE__ */ h(
307
343
  "button",
308
344
  {
309
345
  type: "button",
310
346
  className: "chronos-timezone-button",
311
- onClick: () => i(!a),
312
- "aria-expanded": a,
347
+ onClick: () => r(!s),
348
+ "aria-expanded": s,
313
349
  "aria-label": "Select timezone",
314
350
  children: [
315
- /* @__PURE__ */ o("span", { className: "chronos-timezone-label", children: c.label }),
316
- /* @__PURE__ */ o("span", { className: "chronos-timezone-offset", children: F(e) }),
317
- /* @__PURE__ */ o(
351
+ /* @__PURE__ */ a("span", { className: "chronos-timezone-label", children: l.label }),
352
+ /* @__PURE__ */ a("span", { className: "chronos-timezone-offset", children: V(e) }),
353
+ /* @__PURE__ */ a(
318
354
  "svg",
319
355
  {
320
- className: `chronos-chevron ${a ? "expanded" : ""}`,
356
+ className: `chronos-chevron ${s ? "expanded" : ""}`,
321
357
  xmlns: "http://www.w3.org/2000/svg",
322
358
  viewBox: "0 0 24 24",
323
359
  fill: "none",
324
360
  stroke: "currentColor",
325
361
  strokeWidth: "2",
326
- children: /* @__PURE__ */ o("polyline", { points: "6 9 12 15 18 9" })
362
+ children: /* @__PURE__ */ a("polyline", { points: "6 9 12 15 18 9" })
327
363
  }
328
364
  )
329
365
  ]
330
366
  }
331
367
  ),
332
- a && /* @__PURE__ */ o("div", { className: "chronos-timezone-list", role: "listbox", children: X.map((d) => /* @__PURE__ */ h(
368
+ s && /* @__PURE__ */ a("div", { className: "chronos-timezone-list", role: "listbox", children: X.map((c) => /* @__PURE__ */ h(
333
369
  "button",
334
370
  {
335
371
  type: "button",
336
- className: `chronos-timezone-option ${d.value === e ? "selected" : ""}`,
337
- onClick: () => N(d.value),
372
+ className: `chronos-timezone-option ${c.value === e ? "selected" : ""}`,
373
+ onClick: () => k(c.value),
338
374
  role: "option",
339
- "aria-selected": d.value === e,
375
+ "aria-selected": c.value === e,
340
376
  children: [
341
- /* @__PURE__ */ o("span", { className: "chronos-timezone-option-label", children: d.label }),
342
- /* @__PURE__ */ o("span", { className: "chronos-timezone-option-offset", children: F(d.value) })
377
+ /* @__PURE__ */ a("span", { className: "chronos-timezone-option-label", children: c.label }),
378
+ /* @__PURE__ */ a("span", { className: "chronos-timezone-option-offset", children: V(c.value) })
343
379
  ]
344
380
  },
345
- d.value
381
+ c.value
346
382
  )) })
347
383
  ] });
348
384
  };
349
- function V(e, r, a) {
385
+ function ee(e, i, s) {
350
386
  return {
351
387
  iso: e.toISO() || "",
352
- formatted: e.toFormat(`${r} ${a}`),
388
+ formatted: e.toFormat(`${i} ${s}`),
353
389
  timestamp: e.toMillis(),
354
390
  dateTime: e
355
391
  };
356
392
  }
357
- const Te = ({
393
+ const $e = ({
358
394
  value: e,
359
- onChange: r,
360
- timezone: a = me,
361
- dateFormat: i = "DD",
362
- timeFormat: c = "HH:mm",
363
- minDate: N,
364
- maxDate: d,
365
- placeholder: p = "Select date and time",
366
- disabled: k = !1,
367
- showTime: b = !0,
395
+ onChange: i,
396
+ timezone: s = ke,
397
+ dateFormat: r = "DD",
398
+ timeFormat: l = "HH:mm",
399
+ minDate: k,
400
+ maxDate: c,
401
+ placeholder: y = "Select date and time",
402
+ disabled: v = !1,
403
+ showTime: M = !0,
368
404
  use24Hour: E = !0,
369
- className: W = "",
370
- ariaLabel: z = "Date and time picker",
371
- showTimezoneSelector: I = !1,
372
- theme: P = "light",
373
- orientation: x = "portrait",
374
- selectionMode: D = "single",
375
- rangeValue: t,
405
+ className: z = "",
406
+ ariaLabel: R = "Date and time picker",
407
+ showTimezoneSelector: P = !1,
408
+ theme: L = "light",
409
+ orientation: A = "portrait",
410
+ selectionMode: C = "single",
411
+ rangeValue: n,
376
412
  onRangeChange: u,
377
- holidays: $
413
+ holidays: x,
414
+ customHolidays: b,
415
+ showHolidays: N = !0
378
416
  }) => {
379
- const l = D === "range", [M, g] = w(!1), [n, f] = w(() => !l && e ? R(e, a) : null), [s, C] = w(() => l && (t != null && t.start) ? R(t.start, a) : null), [T, L] = w(() => l && (t != null && t.end) ? R(t.end, a) : null), [v, B] = w(a), [ee, _] = w(() => n || s || T || J(a)), U = Q(null), q = Q(null);
380
- K(() => {
381
- !l && e && f(R(e, v));
382
- }, [e, v, l]), K(() => {
383
- l && (t == null ? void 0 : t.start) != null && (t == null ? void 0 : t.end) != null && (C(R(t.start, v)), L(R(t.end, v)));
384
- }, [l, t, v]), K(() => {
385
- const y = (m) => {
386
- U.current && !U.current.contains(m.target) && g(!1);
417
+ const d = C === "range", [o, f] = $(!1), [t, D] = $(() => !d && e ? _(e, s) : null), [g, W] = $(() => d && (n != null && n.start) ? _(n.start, s) : null), [S, K] = $(() => d && (n != null && n.end) ? _(n.end, s) : null), [T, ne] = $(s), [te, B] = $(() => t || g || S || U(s)), J = Q(null), q = Q(null);
418
+ G(() => {
419
+ !d && e && D(_(e, T));
420
+ }, [e, T, d]), G(() => {
421
+ d && (n == null ? void 0 : n.start) != null && (n == null ? void 0 : n.end) != null && (W(_(n.start, T)), K(_(n.end, T)));
422
+ }, [d, n, T]), G(() => {
423
+ const p = (m) => {
424
+ J.current && !J.current.contains(m.target) && f(!1);
387
425
  };
388
- if (M)
389
- return document.addEventListener("mousedown", y), () => document.removeEventListener("mousedown", y);
390
- }, [M]), K(() => {
391
- const y = (m) => {
392
- var S;
393
- m.key === "Escape" && M && (g(!1), (S = q.current) == null || S.focus());
426
+ if (o)
427
+ return document.addEventListener("mousedown", p), () => document.removeEventListener("mousedown", p);
428
+ }, [o]), G(() => {
429
+ const p = (m) => {
430
+ var O;
431
+ m.key === "Escape" && o && (f(!1), (O = q.current) == null || O.focus());
394
432
  };
395
- return document.addEventListener("keydown", y), () => document.removeEventListener("keydown", y);
396
- }, [M]);
397
- const te = j((y) => {
398
- let m = y;
399
- if (n && (m = y.set({
400
- hour: n.hour,
401
- minute: n.minute,
402
- second: n.second
403
- })), f(m), _(m), b || g(!1), r) {
404
- const S = {
433
+ return document.addEventListener("keydown", p), () => document.removeEventListener("keydown", p);
434
+ }, [o]);
435
+ const oe = H((p) => {
436
+ let m = p;
437
+ if (t && (m = p.set({
438
+ hour: t.hour,
439
+ minute: t.minute,
440
+ second: t.second
441
+ })), D(m), B(m), M || f(!1), i) {
442
+ const O = {
405
443
  iso: m.toISO() || "",
406
- formatted: m.toFormat(`${i} ${c}`),
444
+ formatted: m.toFormat(`${r} ${l}`),
407
445
  timestamp: m.toMillis(),
408
446
  dateTime: m
409
447
  };
410
- r(S);
448
+ i(O);
411
449
  }
412
- }, [n, b, r, i, c]), ne = j((y, m) => {
413
- const A = (n || J(v)).set({ hour: y, minute: m, second: 0 });
414
- if (f(A), r) {
450
+ }, [t, M, i, r, l]), ae = H((p, m) => {
451
+ const I = (t || U(T)).set({ hour: p, minute: m, second: 0 });
452
+ if (D(I), i) {
415
453
  const Z = {
416
- iso: A.toISO() || "",
417
- formatted: A.toFormat(`${i} ${c}`),
418
- timestamp: A.toMillis(),
419
- dateTime: A
454
+ iso: I.toISO() || "",
455
+ formatted: I.toFormat(`${r} ${l}`),
456
+ timestamp: I.toMillis(),
457
+ dateTime: I
420
458
  };
421
- r(Z);
459
+ i(Z);
422
460
  }
423
- }, [n, v, r, i, c]), oe = j((y, m) => {
424
- const S = y.startOf("day"), A = m.startOf("day"), [Z, Y] = S <= A ? [S, A] : [A, S];
425
- if (C(Z), L(Y), _(Z), u) {
426
- const ce = V(Z, i, c), de = V(Y, i, c), he = Math.max(0, Math.ceil(Y.diff(Z, "days").days));
427
- u({ start: ce, end: de, nights: he });
461
+ }, [t, T, i, r, l]), se = H((p, m) => {
462
+ const O = p.startOf("day"), I = m.startOf("day"), [Z, Y] = O <= I ? [O, I] : [I, O];
463
+ if (W(Z), K(Y), B(Z), u) {
464
+ const me = ee(Z, r, l), ue = ee(Y, r, l), fe = Math.max(0, Math.ceil(Y.diff(Z, "days").days));
465
+ u({ start: me, end: ue, nights: fe });
428
466
  }
429
- }, [u, i, c]), se = j((y) => {
430
- if (B(y), n) {
431
- const m = n.setZone(y);
432
- if (f(m), _(m), r) {
433
- const S = {
467
+ }, [u, r, l]), ie = H((p) => {
468
+ if (ne(p), t) {
469
+ const m = t.setZone(p);
470
+ if (D(m), B(m), i) {
471
+ const O = {
434
472
  iso: m.toISO() || "",
435
- formatted: m.toFormat(`${i} ${c}`),
473
+ formatted: m.toFormat(`${r} ${l}`),
436
474
  timestamp: m.toMillis(),
437
475
  dateTime: m
438
476
  };
439
- r(S);
477
+ i(O);
440
478
  }
441
479
  } else
442
- _(J(y));
443
- }, [n, r, i, c]), H = () => {
444
- k || g(!M);
445
- }, ae = (y) => {
446
- (y.key === "Enter" || y.key === " ") && (y.preventDefault(), H());
447
- }, re = l ? s && T ? `${s.toFormat("d MMM yyyy")} – ${T.toFormat("d MMM yyyy")}` : "" : n ? n.toFormat(`${i} ${b ? c : ""}`) : "", ie = N ? R(N, v) : void 0, le = d ? R(d, v) : void 0;
480
+ B(U(p));
481
+ }, [t, i, r, l]), F = () => {
482
+ v || f(!o);
483
+ }, re = (p) => {
484
+ (p.key === "Enter" || p.key === " ") && (p.preventDefault(), F());
485
+ }, le = d ? g && S ? `${g.toFormat("d MMM yyyy")} – ${S.toFormat("d MMM yyyy")}` : "" : t ? t.toFormat(`${r} ${M ? l : ""}`) : "", ce = k ? _(k, T) : void 0, de = c ? _(c, T) : void 0, he = x !== void 0 ? x : N ? [...be(T), ...b ?? []] : b ?? [];
448
486
  return /* @__PURE__ */ h(
449
487
  "div",
450
488
  {
451
- ref: U,
452
- className: `chronos-picker ${W}`,
453
- "data-disabled": k,
454
- "data-theme": P,
489
+ ref: J,
490
+ className: `chronos-picker ${z}`,
491
+ "data-disabled": v,
492
+ "data-theme": L,
455
493
  children: [
456
494
  /* @__PURE__ */ h(
457
495
  "div",
458
496
  {
459
497
  className: "chronos-input-wrapper",
460
- onClick: H,
498
+ onClick: F,
461
499
  children: [
462
- /* @__PURE__ */ o(
500
+ /* @__PURE__ */ a(
463
501
  "input",
464
502
  {
465
503
  ref: q,
466
504
  type: "text",
467
505
  className: "chronos-input",
468
- value: re,
469
- placeholder: p,
506
+ value: le,
507
+ placeholder: y,
470
508
  readOnly: !0,
471
- disabled: k,
472
- onKeyDown: ae,
473
- "aria-label": z,
474
- "aria-expanded": M,
509
+ disabled: v,
510
+ onKeyDown: re,
511
+ "aria-label": R,
512
+ "aria-expanded": o,
475
513
  "aria-haspopup": "dialog",
476
514
  role: "combobox"
477
515
  }
@@ -486,67 +524,67 @@ const Te = ({
486
524
  stroke: "currentColor",
487
525
  strokeWidth: "2",
488
526
  children: [
489
- /* @__PURE__ */ o("rect", { x: "3", y: "4", width: "18", height: "18", rx: "2", ry: "2" }),
490
- /* @__PURE__ */ o("line", { x1: "16", y1: "2", x2: "16", y2: "6" }),
491
- /* @__PURE__ */ o("line", { x1: "8", y1: "2", x2: "8", y2: "6" }),
492
- /* @__PURE__ */ o("line", { x1: "3", y1: "10", x2: "21", y2: "10" })
527
+ /* @__PURE__ */ a("rect", { x: "3", y: "4", width: "18", height: "18", rx: "2", ry: "2" }),
528
+ /* @__PURE__ */ a("line", { x1: "16", y1: "2", x2: "16", y2: "6" }),
529
+ /* @__PURE__ */ a("line", { x1: "8", y1: "2", x2: "8", y2: "6" }),
530
+ /* @__PURE__ */ a("line", { x1: "3", y1: "10", x2: "21", y2: "10" })
493
531
  ]
494
532
  }
495
533
  )
496
534
  ]
497
535
  }
498
536
  ),
499
- M && /* @__PURE__ */ o(
537
+ o && /* @__PURE__ */ a(
500
538
  "div",
501
539
  {
502
540
  className: "chronos-dropdown",
503
- "data-orientation": x,
504
- "data-range-mode": l,
541
+ "data-orientation": A,
542
+ "data-range-mode": d,
505
543
  role: "dialog",
506
544
  "aria-label": "Date and time picker dialog",
507
545
  children: /* @__PURE__ */ h("div", { className: "chronos-dropdown-content", children: [
508
- l && s && T && /* @__PURE__ */ h("div", { className: "chronos-range-summary", children: [
546
+ d && g && S && /* @__PURE__ */ h("div", { className: "chronos-range-summary", children: [
509
547
  /* @__PURE__ */ h("div", { className: "chronos-range-nights", children: [
510
- Math.max(0, Math.ceil(T.diff(s, "days").days)),
548
+ Math.max(0, Math.ceil(S.diff(g, "days").days)),
511
549
  " nights"
512
550
  ] }),
513
551
  /* @__PURE__ */ h("div", { className: "chronos-range-dates", children: [
514
- s.toFormat("d MMM yyyy"),
552
+ g.toFormat("d MMM yyyy"),
515
553
  " – ",
516
- T.toFormat("d MMM yyyy")
554
+ S.toFormat("d MMM yyyy")
517
555
  ] })
518
556
  ] }),
519
- /* @__PURE__ */ o(
520
- ye,
557
+ /* @__PURE__ */ a(
558
+ Te,
521
559
  {
522
- viewDate: ee,
523
- selectedDate: l ? null : n,
524
- onDateSelect: te,
525
- onViewDateChange: _,
526
- timezone: v,
527
- minDate: ie,
528
- maxDate: le,
529
- selectedStart: l ? s : void 0,
530
- selectedEnd: l ? T : void 0,
531
- onRangeSelect: l ? oe : void 0,
532
- holidays: $
560
+ viewDate: te,
561
+ selectedDate: d ? null : t,
562
+ onDateSelect: oe,
563
+ onViewDateChange: B,
564
+ timezone: T,
565
+ minDate: ce,
566
+ maxDate: de,
567
+ selectedStart: d ? g : void 0,
568
+ selectedEnd: d ? S : void 0,
569
+ onRangeSelect: d ? se : void 0,
570
+ holidays: he
533
571
  }
534
572
  ),
535
- !l && (b || I) && /* @__PURE__ */ h("div", { className: "chronos-sidebar", children: [
536
- b && /* @__PURE__ */ o(
537
- Me,
573
+ !d && (M || P) && /* @__PURE__ */ h("div", { className: "chronos-sidebar", children: [
574
+ M && /* @__PURE__ */ a(
575
+ we,
538
576
  {
539
- value: n,
540
- onChange: ne,
577
+ value: t,
578
+ onChange: ae,
541
579
  use24Hour: E,
542
- timezone: v
580
+ timezone: T
543
581
  }
544
582
  ),
545
- I && /* @__PURE__ */ o(
546
- be,
583
+ P && /* @__PURE__ */ a(
584
+ De,
547
585
  {
548
- value: v,
549
- onChange: se
586
+ value: T,
587
+ onChange: ie
550
588
  }
551
589
  )
552
590
  ] })
@@ -559,8 +597,12 @@ const Te = ({
559
597
  };
560
598
  export {
561
599
  X as COMMON_TIMEZONES,
562
- me as DEFAULT_TIMEZONE,
563
- Te as DateTimePicker,
564
- R as convertToTimezone,
565
- J as nowInTimezone
600
+ pe as DEFAULT_HOLIDAYS_TIMEZONE,
601
+ ke as DEFAULT_TIMEZONE,
602
+ $e as DateTimePicker,
603
+ ye as INDIAN_HOLIDAYS_2026,
604
+ Me as LONG_WEEKENDS_2026,
605
+ _ as convertToTimezone,
606
+ be as getDefaultHolidaysForTimezone,
607
+ U as nowInTimezone
566
608
  };
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(M,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):(M=typeof globalThis<"u"?globalThis:M||self,e(M.ChronosPicker={},M.jsxRuntime,M.React,M.luxon))})(this,function(M,e,i,S){"use strict";const J="Asia/Kolkata",q=[{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"}],F=[{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"}];function Q(n){return n===J?[...q,...F]:[]}const X="Asia/Kolkata",B=[{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 A(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 Y(n){return S.DateTime.now().setZone(n)}function V(n){const a=S.DateTime.now().setZone(n).offset,r=Math.floor(Math.abs(a)/60),c=Math.abs(a)%60;return`UTC${a>=0?"+":"-"}${r}${c>0?`:${c.toString().padStart(2,"0")}`:""}`}function te(n,l,a,r,c,b,d,u,v){const T=S.DateTime.fromObject({year:n,month:l,day:1},{zone:a}),P=T.startOf("week"),z=T.endOf("month").endOf("week"),_=S.DateTime.now().setZone(a).startOf("day"),L=d!=null&&u!=null,C=d==null?void 0:d.startOf("day"),$=u==null?void 0:u.endOf("day"),t=new Map;v&&v.forEach(D=>{let h;S.DateTime.isDateTime(D.date)?h=D.date.setZone(a):typeof D.date=="string"?h=S.DateTime.fromISO(D.date,{zone:a}):h=S.DateTime.fromJSDate(D.date,{zone:a}),t.set(h.toISODate()||"",{name:D.name,type:D.type||"national"})});const m=[];let I=[],k=P;for(;k<=z;){const D=k.month===l,h=k.hasSame(_,"day"),s=k.startOf("day"),y=k.toISODate()||"";let o=!1,w=!1,N=!1,W=!1;L&&C&&$?(N=s.hasSame(C,"day"),W=s.hasSame($,"day"),w=s>=C&&s<=$||N||W,o=N||W):r&&(o=k.hasSame(r,"day"));let O=!1;c&&k<c.startOf("day")&&(O=!0),b&&k>b.endOf("day")&&(O=!0);const H=t.get(y);I.push({date:k,isCurrentMonth:D,isToday:h,isSelected:o,isDisabled:O,isInRange:w,isRangeStart:N,isRangeEnd:W,holiday:H?{date:k,...H}:void 0}),I.length===7&&(m.push(I),I=[]),k=k.plus({days:1})}return m}function oe(){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 se(){const n=[];for(let l=1;l<=12;l++){const a=S.DateTime.fromObject({month:l});n.push(a.toFormat("MMMM"))}return n}const ae=({viewDate:n,selectedDate:l,onDateSelect:a,onViewDateChange:r,timezone:c,minDate:b,maxDate:d,selectedStart:u,selectedEnd:v,onRangeSelect:T,holidays:P})=>{const Z=T!=null,z=i.useMemo(()=>te(n.year,n.month,c,l??void 0,b,d,u??void 0,v??void 0,P),[n,l,c,b,d,u,v,P]),_=i.useMemo(()=>oe(),[]),L=i.useMemo(()=>se(),[]),C=()=>{r(n.minus({months:1}))},$=()=>{r(n.plus({months:1}))},t=s=>{const y=parseInt(s.target.value,10);r(n.set({month:y}))},m=s=>{const y=parseInt(s.target.value,10);r(n.set({year:y}))},I=(s,y)=>{if(!y)if(Z&&T){const o=s.startOf("day");if(u==null)T(s,s);else if(v!=null&&u.hasSame(v,"day")){const w=u.startOf("day");o<w?T(s,u):T(u,s)}else T(s,s)}else a(s)},k=(s,y,o)=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),I(y,o))},D=n.year,h=Array.from({length:21},(s,y)=>D-10+y);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:n.month,onChange:t,"aria-label":"Select month",children:L.map((s,y)=>e.jsx("option",{value:y+1,children:s},y))}),e.jsx("select",{className:"chronos-year-select",value:n.year,onChange:m,"aria-label":"Select year",children:h.map(s=>e.jsx("option",{value:s,children:s},s))})]}),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:_.map(s=>e.jsx("div",{className:"chronos-weekday",children:s},s))}),z.map((s,y)=>e.jsx("div",{className:"chronos-week-row",children:s.map((o,w)=>e.jsxs("button",{type:"button",className:`chronos-day ${o.isSelected?"selected":""} ${o.isToday?"today":""} ${o.isCurrentMonth?"":"other-month"} ${o.isDisabled?"disabled":""} ${o.isInRange?"in-range":""} ${o.isRangeStart?"range-start":""} ${o.isRangeEnd?"range-end":""} ${o.holiday?`holiday ${o.holiday.type}`:""}`,onClick:()=>I(o.date,o.isDisabled),onKeyDown:N=>k(N,o.date,o.isDisabled),disabled:o.isDisabled,"aria-label":`${o.date.toFormat("MMMM d, yyyy")}${o.holiday?`, ${o.holiday.name}`:""}`,"aria-selected":o.isSelected,"aria-current":o.isToday?"date":void 0,title:o.holiday?o.holiday.name:void 0,children:[o.date.day,o.holiday&&e.jsx("span",{className:"chronos-holiday-dot"})]},w))},y))]})]})},le=({value:n,onChange:l,use24Hour:a})=>{const[r,c]=i.useState((n==null?void 0:n.hour)??12),[b,d]=i.useState((n==null?void 0:n.minute)??0),[u,v]=i.useState(n&&n.hour>=12?"PM":"AM");i.useEffect(()=>{n&&(c(n.hour),d(n.minute),v(n.hour>=12?"PM":"AM"))},[n]);const T=t=>{c(t);let m=t;a||(u==="PM"&&t!==12?m=t+12:u==="AM"&&t===12&&(m=0)),l(m,b)},P=t=>{d(t),l(r,t)},Z=()=>{const t=u==="AM"?"PM":"AM";v(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,b)},z=a?r:r%12||12,_=a?23:12,L=a?0:1,C=Array.from({length:_-L+1},(t,m)=>L+m),$=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:z,onChange:t=>T(parseInt(t.target.value,10)),"aria-label":"Select hour",children:C.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:b,onChange:t=>P(parseInt(t.target.value,10)),"aria-label":"Select minute",children:$.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 ${u==="AM"?"PM":"AM"}`,children:u})]})]})},re=({value:n,onChange:l})=>{const[a,r]=i.useState(!1),c=B.find(d=>d.value===n)||{label:n},b=d=>{l(d),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:c.label}),e.jsx("span",{className:"chronos-timezone-offset",children:V(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:B.map(d=>e.jsxs("button",{type:"button",className:`chronos-timezone-option ${d.value===n?"selected":""}`,onClick:()=>b(d.value),role:"option","aria-selected":d.value===n,children:[e.jsx("span",{className:"chronos-timezone-option-label",children:d.label}),e.jsx("span",{className:"chronos-timezone-option-offset",children:V(d.value)})]},d.value))})]})};function R(n,l,a){return{iso:n.toISO()||"",formatted:n.toFormat(`${l} ${a}`),timestamp:n.toMillis(),dateTime:n}}const ie=({value:n,onChange:l,timezone:a=X,dateFormat:r="DD",timeFormat:c="HH:mm",minDate:b,maxDate:d,placeholder:u="Select date and time",disabled:v=!1,showTime:T=!0,use24Hour:P=!0,className:Z="",ariaLabel:z="Date and time picker",showTimezoneSelector:_=!1,theme:L="light",orientation:C="portrait",selectionMode:$="single",rangeValue:t,onRangeChange:m,holidays:I,customHolidays:k,showHolidays:D=!0})=>{const h=$==="range",[s,y]=i.useState(!1),[o,w]=i.useState(()=>!h&&n?A(n,a):null),[N,W]=i.useState(()=>h&&(t!=null&&t.start)?A(t.start,a):null),[O,H]=i.useState(()=>h&&(t!=null&&t.end)?A(t.end,a):null),[g,ce]=i.useState(a),[de,K]=i.useState(()=>o||N||O||Y(a)),G=i.useRef(null),ee=i.useRef(null);i.useEffect(()=>{!h&&n&&w(A(n,g))},[n,g,h]),i.useEffect(()=>{h&&(t==null?void 0:t.start)!=null&&(t==null?void 0:t.end)!=null&&(W(A(t.start,g)),H(A(t.end,g)))},[h,t,g]),i.useEffect(()=>{const p=f=>{G.current&&!G.current.contains(f.target)&&y(!1)};if(s)return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[s]),i.useEffect(()=>{const p=f=>{var E;f.key==="Escape"&&s&&(y(!1),(E=ee.current)==null||E.focus())};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[s]);const he=i.useCallback(p=>{let f=p;if(o&&(f=p.set({hour:o.hour,minute:o.minute,second:o.second})),w(f),K(f),T||y(!1),l){const E={iso:f.toISO()||"",formatted:f.toFormat(`${r} ${c}`),timestamp:f.toMillis(),dateTime:f};l(E)}},[o,T,l,r,c]),fe=i.useCallback((p,f)=>{const x=(o||Y(g)).set({hour:p,minute:f,second:0});if(w(x),l){const j={iso:x.toISO()||"",formatted:x.toFormat(`${r} ${c}`),timestamp:x.toMillis(),dateTime:x};l(j)}},[o,g,l,r,c]),me=i.useCallback((p,f)=>{const E=p.startOf("day"),x=f.startOf("day"),[j,U]=E<=x?[E,x]:[x,E];if(W(j),H(U),K(j),m){const be=R(j,r,c),ve=R(U,r,c),Ne=Math.max(0,Math.ceil(U.diff(j,"days").days));m({start:be,end:ve,nights:Ne})}},[m,r,c]),ye=i.useCallback(p=>{if(ce(p),o){const f=o.setZone(p);if(w(f),K(f),l){const E={iso:f.toISO()||"",formatted:f.toFormat(`${r} ${c}`),timestamp:f.toMillis(),dateTime:f};l(E)}}else K(Y(p))},[o,l,r,c]),ne=()=>{v||y(!s)},pe=p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),ne())},ue=h?N&&O?`${N.toFormat("d MMM yyyy")} – ${O.toFormat("d MMM yyyy")}`:"":o?o.toFormat(`${r} ${T?c:""}`):"",Me=b?A(b,g):void 0,Te=d?A(d,g):void 0,ke=I!==void 0?I:D?[...Q(g),...k??[]]:k??[];return e.jsxs("div",{ref:G,className:`chronos-picker ${Z}`,"data-disabled":v,"data-theme":L,children:[e.jsxs("div",{className:"chronos-input-wrapper",onClick:ne,children:[e.jsx("input",{ref:ee,type:"text",className:"chronos-input",value:ue,placeholder:u,readOnly:!0,disabled:v,onKeyDown:pe,"aria-label":z,"aria-expanded":s,"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"})]})]}),s&&e.jsx("div",{className:"chronos-dropdown","data-orientation":C,"data-range-mode":h,role:"dialog","aria-label":"Date and time picker dialog",children:e.jsxs("div",{className:"chronos-dropdown-content",children:[h&&N&&O&&e.jsxs("div",{className:"chronos-range-summary",children:[e.jsxs("div",{className:"chronos-range-nights",children:[Math.max(0,Math.ceil(O.diff(N,"days").days))," nights"]}),e.jsxs("div",{className:"chronos-range-dates",children:[N.toFormat("d MMM yyyy")," – ",O.toFormat("d MMM yyyy")]})]}),e.jsx(ae,{viewDate:de,selectedDate:h?null:o,onDateSelect:he,onViewDateChange:K,timezone:g,minDate:Me,maxDate:Te,selectedStart:h?N:void 0,selectedEnd:h?O:void 0,onRangeSelect:h?me:void 0,holidays:ke}),!h&&(T||_)&&e.jsxs("div",{className:"chronos-sidebar",children:[T&&e.jsx(le,{value:o,onChange:fe,use24Hour:P,timezone:g}),_&&e.jsx(re,{value:g,onChange:ye})]})]})})]})};M.COMMON_TIMEZONES=B,M.DEFAULT_HOLIDAYS_TIMEZONE=J,M.DEFAULT_TIMEZONE=X,M.DateTimePicker=ie,M.INDIAN_HOLIDAYS_2026=q,M.LONG_WEEKENDS_2026=F,M.convertToTimezone=A,M.getDefaultHolidaysForTimezone=Q,M.nowInTimezone=Y,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimePicker.d.ts","sourceRoot":"","sources":["../../../src/components/DateTimePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAExE,OAAO,EAAE,mBAAmB,EAAiB,MAAM,UAAU,CAAC;AAK9D,OAAO,8BAA8B,CAAC;AAWtC,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAySxD,CAAC"}
1
+ {"version":3,"file":"DateTimePicker.d.ts","sourceRoot":"","sources":["../../../src/components/DateTimePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAExE,OAAO,EAAE,mBAAmB,EAAiB,MAAM,UAAU,CAAC;AAM9D,OAAO,8BAA8B,CAAC;AAWtC,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAkTxD,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { Holiday } from '../types';
2
+
3
+ /** IANA timezone for which built-in 2026 holidays are provided */
4
+ export declare const DEFAULT_HOLIDAYS_TIMEZONE = "Asia/Kolkata";
5
+ export declare const INDIAN_HOLIDAYS_2026: Holiday[];
6
+ export declare const LONG_WEEKENDS_2026: Holiday[];
7
+ /**
8
+ * Returns default national holidays and long weekend suggestions for the given timezone.
9
+ * Built-in data is provided for Asia/Kolkata (India) for 2026; other timezones get an empty array.
10
+ * Use with customHolidays prop to add your own dates on top of these.
11
+ */
12
+ export declare function getDefaultHolidaysForTimezone(timezone: string): Holiday[];
13
+ //# sourceMappingURL=holidays.d.ts.map
@@ -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,kEAAkE;AAClE,eAAO,MAAM,yBAAyB,iBAAiB,CAAC;AAExD,eAAO,MAAM,oBAAoB,EAAE,OAAO,EAUzC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,OAAO,EAqBvC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,EAAE,CAKzE"}
@@ -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, DEFAULT_HOLIDAYS_TIMEZONE, getDefaultHolidaysForTimezone, } from './constants/holidays';
5
+ export type { Holiday } from './types';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -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,EACL,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,6BAA6B,GAC9B,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC"}
@@ -65,8 +65,21 @@ export interface DateTimePickerProps {
65
65
  } | null;
66
66
  /** Callback when range changes (selectionMode is 'range') */
67
67
  onRangeChange?: (value: DateTimeRangeValue) => void;
68
- /** List of holidays to display */
68
+ /**
69
+ * List of holidays to display. When provided, this fully overrides default holidays
70
+ * for the timezone. Omit to use built-in holidays (Asia/Kolkata 2026) plus customHolidays.
71
+ */
69
72
  holidays?: Holiday[];
73
+ /**
74
+ * Custom holiday dates to add on top of the default holidays for the selected timezone.
75
+ * Ignored when holidays prop is set. Only used when timezone has built-in data or you pass holidays.
76
+ */
77
+ customHolidays?: Holiday[];
78
+ /**
79
+ * Whether to show default national holidays and long weekend suggestions for the selected timezone.
80
+ * Default true. Set to false to hide built-in holidays (customHolidays and holidays still apply if set).
81
+ */
82
+ showHolidays?: boolean;
70
83
  }
71
84
  export interface CalendarDate {
72
85
  date: DateTime;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,qBAAqB;IACrB,KAAK,EAAE,aAAa,CAAC;IACrB,mBAAmB;IACnB,GAAG,EAAE,aAAa,CAAC;IACnB,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,UAAU,GAAG,cAAc,CAAC;CACpC;AAED,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAC;IAEjC,sCAAsC;IACtC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAE1C,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAExB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAExB,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,uBAAuB;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,gCAAgC;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,6BAA6B;IAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B,yCAAyC;IACzC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAEzB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;IAEvC,6EAA6E;IAC7E,aAAa,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAEnC,gDAAgD;IAChD,UAAU,CAAC,EAAE;QAAE,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAC;QAAC,GAAG,EAAE,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAA;KAAE,GAAG,IAAI,CAAC;IAEvF,6DAA6D;IAC7D,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAEpD,kCAAkC;IAClC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,QAAQ,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,yDAAyD;IACzD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8BAA8B;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,4BAA4B;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,wCAAwC;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,qBAAqB;IACrB,KAAK,EAAE,aAAa,CAAC;IACrB,mBAAmB;IACnB,GAAG,EAAE,aAAa,CAAC;IACnB,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,UAAU,GAAG,cAAc,CAAC;CACpC;AAED,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAC;IAEjC,sCAAsC;IACtC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAE1C,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAExB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAExB,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,uBAAuB;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,gCAAgC;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,6BAA6B;IAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B,yCAAyC;IACzC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAEzB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;IAEvC,6EAA6E;IAC7E,aAAa,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAEnC,gDAAgD;IAChD,UAAU,CAAC,EAAE;QAAE,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAC;QAAC,GAAG,EAAE,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAA;KAAE,GAAG,IAAI,CAAC;IAEvF,6DAA6D;IAC7D,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAEpD;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IAErB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,EAAE,CAAC;IAE3B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,QAAQ,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,yDAAyD;IACzD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8BAA8B;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,4BAA4B;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,wCAAwC;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theengineerguy/chronos-picker",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "A modern, accessible date & time picker with comprehensive timezone support",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",