@alfadocs/ui-kit 0.94.0 → 0.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,25 +1,25 @@
1
- import { jsx as r, jsxs as c, Fragment as wt } from "react/jsx-runtime";
2
- import { forwardRef as It, useState as y, useRef as ce, useId as G, useCallback as Ke, useEffect as Le, useMemo as Ot, useImperativeHandle as Tt, Fragment as Gt } from "react";
3
- import { useTranslation as Et } from "react-i18next";
4
- import * as _ from "@radix-ui/react-popover";
5
- import * as z from "@radix-ui/react-radio-group";
6
- import { u as $e } from "./use-controllable-state-BiY4xTzM.js";
7
- import { u as Mt } from "./form-field-context-B3APVHKx.js";
8
- import { S as Vt } from "./switch-OILsBLWo.js";
9
- import { u as Ft } from "./registry-DvAUVLHh.js";
10
- import { l as Kt, m as Lt, u as $t, g as At, b as Wt, f as h, n as Ae, s as We, o as jt, q as qt, k as ue, a as _t, d as zt, t as Bt, r as je, v as qe, w as _e, p as Yt, x as Ut, D as Ht, C as Qt, y as Jt, e as Xt, z as B, h as Zt, j as ea, i as pe, c as ta } from "./date-picker-variants-eL6HjWvw.js";
11
- import { s as E } from "./subDays-BcNi04uf.js";
12
- import { C as aa } from "./calendar-days-BGWklvE-.js";
13
- import { C as ra } from "./check-DrFSN__t.js";
14
- import { i as ze } from "./isSameDay-DUEiAT0G.js";
15
- import { p as sa } from "./parse-DvA97ro9.js";
16
- function na(s, l, f) {
17
- return Kt(s, -1, f);
1
+ import { jsx as r, jsxs as c, Fragment as Ct } from "react/jsx-runtime";
2
+ import { forwardRef as Et, useState as b, useRef as fe, useId as M, useCallback as We, useEffect as je, useMemo as Mt, useImperativeHandle as Ft, Fragment as Kt } from "react";
3
+ import { useTranslation as At } from "react-i18next";
4
+ import * as H from "@radix-ui/react-popover";
5
+ import * as Q from "@radix-ui/react-radio-group";
6
+ import { u as me } from "./use-controllable-state-BiY4xTzM.js";
7
+ import { u as Lt } from "./form-field-context-B3APVHKx.js";
8
+ import { S as $t } from "./switch-OILsBLWo.js";
9
+ import { u as Wt } from "./registry-DvAUVLHh.js";
10
+ import { l as jt, m as qt, u as _t, g as zt, b as Bt, f as k, n as qe, s as _e, o as Yt, q as Ut, k as ge, a as Ht, d as Qt, t as Jt, r as ze, v as Be, w as Ye, p as Xt, x as Zt, D as ea, C as ta, y as aa, e as ra, z as J, h as sa, j as na, i as ve, c as ia } from "./date-picker-variants-eL6HjWvw.js";
11
+ import { s as F } from "./subDays-BcNi04uf.js";
12
+ import { C as oa } from "./calendar-days-BGWklvE-.js";
13
+ import { C as da } from "./check-DrFSN__t.js";
14
+ import { i as Ue } from "./isSameDay-DUEiAT0G.js";
15
+ import { p as la } from "./parse-DvA97ro9.js";
16
+ function ca(s, l, g) {
17
+ return jt(s, -1, g);
18
18
  }
19
- function Be(s, l, f) {
20
- return Lt(s, -1, f);
19
+ function He(s, l, g) {
20
+ return qt(s, -1, g);
21
21
  }
22
- const oa = {
22
+ const ua = {
23
23
  id: "date-range-picker",
24
24
  capabilities: [
25
25
  "range_pick",
@@ -38,11 +38,11 @@ const oa = {
38
38
  descriptionKey: "ui.agent.dateRangePicker.state.range",
39
39
  description: "Currently-selected ISO date range endpoints, each possibly null.",
40
40
  read: (s) => {
41
- var f, m;
41
+ var g, p;
42
42
  const l = s.getRange();
43
43
  return {
44
- from: ((f = l.from) == null ? void 0 : f.toISOString()) ?? null,
45
- to: ((m = l.to) == null ? void 0 : m.toISOString()) ?? null
44
+ from: ((g = l.from) == null ? void 0 : g.toISOString()) ?? null,
45
+ to: ((p = l.to) == null ? void 0 : p.toISOString()) ?? null
46
46
  };
47
47
  }
48
48
  },
@@ -63,11 +63,11 @@ const oa = {
63
63
  descriptionKey: "ui.agent.dateRangePicker.state.compareRange",
64
64
  description: "Resolved comparison period when compare-to-previous-period is on, else null.",
65
65
  read: (s) => {
66
- var f, m;
66
+ var g, p;
67
67
  const l = s.getCompareRange();
68
68
  return l ? {
69
- from: ((f = l.from) == null ? void 0 : f.toISOString()) ?? null,
70
- to: ((m = l.to) == null ? void 0 : m.toISOString()) ?? null
69
+ from: ((g = l.from) == null ? void 0 : g.toISOString()) ?? null,
70
+ to: ((p = l.to) == null ? void 0 : p.toISOString()) ?? null
71
71
  } : null;
72
72
  }
73
73
  }
@@ -211,71 +211,79 @@ const oa = {
211
211
  description: "Sourced from the id prop."
212
212
  }
213
213
  }
214
- }, Ye = [
214
+ }, Qe = [
215
215
  { value: "day", fallback: "Day" },
216
216
  { value: "week", fallback: "Week" },
217
217
  { value: "month", fallback: "Month" },
218
218
  { value: "quarter", fallback: "Quarter" }
219
- ], ia = [
219
+ ], pa = [
220
220
  { value: "previous", fallback: "Previous period" },
221
221
  { value: "lastYear", fallback: "Same period last year" }
222
- ], da = It(
222
+ ], fa = Et(
223
223
  ({
224
224
  value: s,
225
225
  defaultValue: l,
226
- onChange: f,
227
- commitMode: m = "auto",
228
- onApply: P,
229
- onCancel: N,
230
- showClear: Ue = !0,
231
- numberOfMonths: He = 2,
232
- granularity: me,
233
- defaultGranularity: fe,
234
- onGranularityChange: Qe,
235
- allowedGranularities: Y,
236
- compare: ge = !1,
237
- defaultCompare: Je = !1,
238
- defaultCompareMode: Xe = "previous",
239
- onCompareChange: D,
240
- weekStartsOn: M,
241
- minDate: U,
242
- maxDate: H,
243
- presets: Q,
244
- mergePresets: Ze = !1,
245
- size: ve = "md",
246
- chrome: et = "input",
247
- disabled: tt,
248
- placeholder: at,
249
- className: rt,
250
- id: st
251
- }, nt) => {
252
- const { t: n, i18n: ye } = Et(), V = Mt(), J = st ?? V.id, he = V.disabled || tt, ot = V.invalid ? "error" : "default", u = $t(ye.language), p = At(ye.language), it = at ?? n("inputs.dateRangePicker.placeholder", "Select date range"), [dt, be] = $e({
226
+ onChange: g,
227
+ commitMode: p = "auto",
228
+ onApply: w,
229
+ onCancel: I,
230
+ showClear: Je = !0,
231
+ numberOfMonths: Xe = 2,
232
+ granularity: ye,
233
+ defaultGranularity: he,
234
+ onGranularityChange: Ze,
235
+ allowedGranularities: X,
236
+ compare: j = !1,
237
+ compareEnabled: et,
238
+ defaultCompare: tt = !1,
239
+ defaultCompareMode: at = "previous",
240
+ onCompareChange: f,
241
+ weekStartsOn: K,
242
+ minDate: Z,
243
+ maxDate: ee,
244
+ presets: te,
245
+ mergePresets: rt = !1,
246
+ size: be = "md",
247
+ chrome: st = "input",
248
+ disabled: nt,
249
+ placeholder: it,
250
+ className: ot,
251
+ id: dt
252
+ }, lt) => {
253
+ const { t: n, i18n: ke } = At(), A = Lt(), ae = dt ?? A.id, Re = A.disabled || nt, ct = A.invalid ? "error" : "default", u = _t(ke.language), m = zt(ke.language), ut = it ?? n("inputs.dateRangePicker.placeholder", "Select date range"), [pt, xe] = me({
253
254
  value: s,
254
255
  defaultValue: l ?? {},
255
- onChange: f
256
- }), i = dt ?? {}, [C, b] = y(!1), [a, S] = y(i), [lt, X] = y(i.from ?? /* @__PURE__ */ new Date()), [ke, Re] = y(""), [xe, Pe] = y(""), [w, F] = y(!1), [I, K] = y(!1), $ = me !== void 0 || fe !== void 0, A = Y && Y.length > 0 ? Y : void 0, Ne = A ? Ye.filter(
257
- (e) => A.includes(e.value)
258
- ) : Ye, L = (e) => {
256
+ onChange: g
257
+ }), o = pt ?? {}, [O, R] = b(!1), [a, T] = b(o), [ft, re] = b(o.from ?? /* @__PURE__ */ new Date()), [Pe, Ne] = b(""), [De, Se] = b(""), [G, L] = b(!1), [V, $] = b(!1), q = ye !== void 0 || he !== void 0, _ = X && X.length > 0 ? X : void 0, we = _ ? Qe.filter(
258
+ (e) => _.includes(e.value)
259
+ ) : Qe, W = (e) => {
259
260
  var t;
260
- return !A || A.includes(e) ? e : ((t = Ne[0]) == null ? void 0 : t.value) ?? e;
261
- }, [ct, Z] = $e({
262
- value: me,
263
- defaultValue: L(fe ?? "day"),
264
- onChange: Qe
265
- }), W = L(ct ?? "day"), [ee, ut] = y(Je), [De, pt] = y(Xe), mt = ce(null), x = ce(!1), Ce = G(), Se = G(), we = G(), Ie = G(), te = G(), ft = G(), k = Ke(
261
+ return !_ || _.includes(e) ? e : ((t = we[0]) == null ? void 0 : t.value) ?? e;
262
+ }, [mt, se] = me({
263
+ value: ye,
264
+ defaultValue: W(he ?? "day"),
265
+ onChange: Ze
266
+ }), z = W(mt ?? "day"), [C, B] = me({
267
+ value: et,
268
+ defaultValue: tt
269
+ // onCompareChange needs the resolved range as its 2nd arg, so it is
270
+ // called manually at the commit points rather than wired here.
271
+ }), [N, E] = b(
272
+ C ?? !1
273
+ ), [Ie, gt] = b(at), vt = fe(null), D = fe(!1), Oe = M(), Te = M(), Ge = M(), Ve = M(), ne = M(), yt = M(), x = We(
266
274
  (e) => {
267
- be(e);
275
+ xe(e);
268
276
  },
269
- [be]
270
- ), gt = Wt(U, H), vt = (e) => (U ? ta(e, U) : !1) || (H ? pe(e, H) : !1);
271
- Le(() => {
272
- C && (S(i), F(!1), K(!1), x.current = !1);
273
- }, [C]), Le(() => {
274
- w || Re(
275
- a.from ? h(a.from, p, { locale: u }) : ""
276
- ), I || Pe(a.to ? h(a.to, p, { locale: u }) : "");
277
- }, [a.from, a.to, p, u]);
278
- const Oe = [
277
+ [xe]
278
+ ), ht = Bt(Z, ee), bt = (e) => (Z ? ia(e, Z) : !1) || (ee ? ve(e, ee) : !1);
279
+ je(() => {
280
+ O && (T(o), E(C ?? !1), L(!1), $(!1), D.current = !1);
281
+ }, [O]), je(() => {
282
+ G || Ne(
283
+ a.from ? k(a.from, m, { locale: u }) : ""
284
+ ), V || Se(a.to ? k(a.to, m, { locale: u }) : "");
285
+ }, [a.from, a.to, m, u]);
286
+ const Ce = [
279
287
  {
280
288
  label: n("inputs.dateRangePicker.presets.today", "Today"),
281
289
  range: () => {
@@ -286,14 +294,14 @@ const oa = {
286
294
  {
287
295
  label: n("inputs.dateRangePicker.presets.yesterday", "Yesterday"),
288
296
  range: () => {
289
- const e = E(/* @__PURE__ */ new Date(), 1);
297
+ const e = F(/* @__PURE__ */ new Date(), 1);
290
298
  return { from: e, to: e };
291
299
  }
292
300
  },
293
301
  {
294
302
  label: n("inputs.dateRangePicker.presets.last7", "Last 7 days"),
295
303
  range: () => ({
296
- from: E(/* @__PURE__ */ new Date(), 6),
304
+ from: F(/* @__PURE__ */ new Date(), 6),
297
305
  to: /* @__PURE__ */ new Date()
298
306
  })
299
307
  },
@@ -302,191 +310,200 @@ const oa = {
302
310
  range: () => ({
303
311
  // `weekStartsOn` (when set) overrides the locale's first day; when
304
312
  // undefined date-fns falls back to the locale.
305
- from: We(/* @__PURE__ */ new Date(), { locale: u, weekStartsOn: M }),
306
- to: Ae(/* @__PURE__ */ new Date(), { locale: u, weekStartsOn: M })
313
+ from: _e(/* @__PURE__ */ new Date(), { locale: u, weekStartsOn: K }),
314
+ to: qe(/* @__PURE__ */ new Date(), { locale: u, weekStartsOn: K })
307
315
  })
308
316
  },
309
317
  {
310
318
  label: n("inputs.dateRangePicker.presets.lastWeek", "Last week"),
311
319
  range: () => {
312
- const e = na(/* @__PURE__ */ new Date());
320
+ const e = ca(/* @__PURE__ */ new Date());
313
321
  return {
314
- from: We(e, { locale: u, weekStartsOn: M }),
315
- to: Ae(e, { locale: u, weekStartsOn: M })
322
+ from: _e(e, { locale: u, weekStartsOn: K }),
323
+ to: qe(e, { locale: u, weekStartsOn: K })
316
324
  };
317
325
  }
318
326
  },
319
327
  {
320
328
  label: n("inputs.dateRangePicker.presets.thisMonth", "This month"),
321
329
  range: () => ({
322
- from: qt(/* @__PURE__ */ new Date()),
323
- to: jt(/* @__PURE__ */ new Date())
330
+ from: Ut(/* @__PURE__ */ new Date()),
331
+ to: Yt(/* @__PURE__ */ new Date())
324
332
  })
325
333
  },
326
334
  {
327
335
  label: n("inputs.dateRangePicker.presets.last30", "Last 30 days"),
328
336
  range: () => ({
329
- from: E(/* @__PURE__ */ new Date(), 29),
337
+ from: F(/* @__PURE__ */ new Date(), 29),
330
338
  to: /* @__PURE__ */ new Date()
331
339
  })
332
340
  }
333
- ], j = Q ? Ze ? [...Oe, ...Q] : Q : Oe, Te = (() => {
341
+ ], ie = te ? rt ? [...Ce, ...te] : te : Ce, Ee = (() => {
334
342
  const e = [], t = /* @__PURE__ */ new Map();
335
- for (const d of j) {
336
- const o = d.group ?? "";
337
- t.has(o) || (t.set(o, []), e.push(o)), t.get(o).push(d);
343
+ for (const d of ie) {
344
+ const i = d.group ?? "";
345
+ t.has(i) || (t.set(i, []), e.push(i)), t.get(i).push(d);
338
346
  }
339
347
  return e.map((d) => ({ group: d, presets: t.get(d) }));
340
- })(), yt = Te.some((e) => e.group !== ""), O = (e, t = De) => {
348
+ })(), kt = Ee.some((e) => e.group !== ""), y = (e, t = Ie) => {
341
349
  if (!e.from || !e.to) return;
342
350
  if (t === "lastYear")
343
- return { from: Be(e.from), to: Be(e.to) };
344
- const d = ue(e.to, e.from), o = E(e.from, 1);
345
- return { from: E(o, d), to: o };
346
- }, T = ge && ee, v = T ? O(a) : void 0, ht = (() => {
347
- if (!(v != null && v.from) || !v.to) return;
348
- const e = v.from, t = v.to, d = {
351
+ return { from: He(e.from), to: He(e.to) };
352
+ const d = ge(e.to, e.from), i = F(e.from, 1);
353
+ return { from: F(i, d), to: i };
354
+ }, Y = j && N, Me = j && (C ?? !1), h = Y ? y(a) : void 0, Rt = (() => {
355
+ if (!(h != null && h.from) || !h.to) return;
356
+ const e = h.from, t = h.to, d = {
349
357
  compareStart: e,
350
358
  compareEnd: t
351
359
  };
352
- return ue(t, e) >= 2 && (d.compareMiddle = { from: _t(e, 1), to: E(t, 1) }), d;
353
- })(), Ge = (e) => {
360
+ return ge(t, e) >= 2 && (d.compareMiddle = { from: Ht(e, 1), to: F(t, 1) }), d;
361
+ })(), Fe = (e) => {
354
362
  const t = {};
355
- return $ && (t.granularity = W), T && (t.compareRange = O(e)), t.granularity || t.compareRange ? t : void 0;
356
- }, bt = (e) => {
363
+ return q && (t.granularity = z), Y && (t.compareRange = y(e)), t.granularity || t.compareRange ? t : void 0;
364
+ }, xt = (e) => {
357
365
  const t = e;
358
- pt(t), T && (D == null || D(!0, O(a, t)));
359
- }, ae = (e) => {
360
- ut(e), D == null || D(e, e ? O(a) : void 0);
361
- }, re = Ke(
366
+ gt(t), Y && p === "auto" && (f == null || f(!0, y(a, t)));
367
+ }, Pt = (e) => {
368
+ E(e), p === "auto" && (B(e), f == null || f(e, e ? y(a) : void 0));
369
+ }, oe = We(
362
370
  (e) => {
363
- S(e), m === "auto" && e.from && e.to && k(e);
371
+ T(e), p === "auto" && e.from && e.to && x(e);
364
372
  },
365
- [m, k]
366
- ), kt = (e) => {
367
- F(!1), K(!1), re({ from: e == null ? void 0 : e.from, to: e == null ? void 0 : e.to });
368
- }, Rt = (e) => {
373
+ [p, x]
374
+ ), Nt = (e) => {
375
+ L(!1), $(!1), oe({ from: e == null ? void 0 : e.from, to: e == null ? void 0 : e.to });
376
+ }, Dt = (e) => {
369
377
  const t = e.range();
370
- F(!1), K(!1), S(t), X(t.from), m === "auto" && (k(t), P == null || P(t, Ge(t)), x.current = !0, b(!1));
371
- }, se = (e, t) => {
372
- const d = e === "from" ? F : K;
378
+ L(!1), $(!1), T(t), re(t.from), p === "auto" && (x(t), w == null || w(t, Fe(t)), D.current = !0, R(!1));
379
+ }, de = (e, t) => {
380
+ const d = e === "from" ? L : $;
373
381
  if (t.trim() === "") {
374
- d(!1), re(
382
+ d(!1), oe(
375
383
  e === "from" ? { from: void 0, to: a.to } : { from: a.from, to: void 0 }
376
384
  );
377
385
  return;
378
386
  }
379
- const o = sa(t, p, /* @__PURE__ */ new Date(), { locale: u });
380
- if (!ea(o) || vt(o)) {
387
+ const i = la(t, m, /* @__PURE__ */ new Date(), { locale: u });
388
+ if (!na(i) || bt(i)) {
381
389
  d(!0);
382
390
  return;
383
391
  }
384
392
  d(!1);
385
- let R;
386
- e === "from" ? R = a.to && pe(o, a.to) ? { from: o, to: void 0 } : { from: o, to: a.to } : R = a.from && pe(a.from, o) ? { from: o, to: void 0 } : { from: a.from, to: o }, X(o), re(R);
387
- }, Ee = (e) => (t) => {
388
- t.key === "Enter" && (t.preventDefault(), se(e, e === "from" ? ke : xe));
389
- }, xt = () => {
390
- S({}), F(!1), K(!1), m === "auto" && k({});
391
- }, Pt = !!(a.from && a.to), Nt = !a.from && !a.to, Me = (Pt || Nt) && !w && !I, ne = () => {
392
- Me && (k(a), P == null || P(a, Ge(a))), x.current = !0, b(!1);
393
- }, Dt = () => {
394
- x.current = !0, b(!1);
395
- }, oe = () => {
396
- m === "apply" && (N == null || N()), S(i), b(!1);
397
- }, Ct = (e) => {
393
+ let P;
394
+ e === "from" ? P = a.to && ve(i, a.to) ? { from: i, to: void 0 } : { from: i, to: a.to } : P = a.from && ve(a.from, i) ? { from: i, to: void 0 } : { from: a.from, to: i }, re(i), oe(P);
395
+ }, Ke = (e) => (t) => {
396
+ t.key === "Enter" && (t.preventDefault(), de(e, e === "from" ? Pe : De));
397
+ }, St = () => {
398
+ T({}), L(!1), $(!1), p === "auto" && x({});
399
+ }, wt = !!(a.from && a.to), It = !a.from && !a.to, Ae = (wt || It) && !G && !V, le = () => {
400
+ Ae && (x(a), j && N !== (C ?? !1) && (B(N), f == null || f(
401
+ N,
402
+ N ? y(a) : void 0
403
+ )), w == null || w(a, Fe(a))), D.current = !0, R(!1);
404
+ }, Ot = () => {
405
+ D.current = !0, R(!1);
406
+ }, ce = () => {
407
+ p === "apply" && (I == null || I()), T(o), E(C ?? !1), R(!1);
408
+ }, Tt = (e) => {
398
409
  if (e) {
399
- x.current = !1, b(!0);
410
+ D.current = !1, R(!0);
400
411
  return;
401
412
  }
402
- m === "apply" && !x.current && (N == null || N()), S(i), x.current = !1, b(!1);
403
- }, ie = (e) => {
404
- if (!i.from || !i.to) return !1;
413
+ p === "apply" && !D.current && (I == null || I()), T(o), E(C ?? !1), D.current = !1, R(!1);
414
+ }, Gt = (e) => {
415
+ if (!o.from || !o.to) return !1;
405
416
  const t = e.range();
406
- return ze(t.from, i.from) && ze(t.to, i.to);
407
- }, Ve = (() => {
408
- if (i.from && i.to) {
409
- const e = h(i.from, p, { locale: u }), t = h(i.to, p, { locale: u });
417
+ return Ue(t.from, o.from) && Ue(t.to, o.to);
418
+ }, S = ie.find(Gt), Le = (() => {
419
+ if (o.from && o.to) {
420
+ const e = k(o.from, m, { locale: u }), t = k(o.to, m, { locale: u });
410
421
  return `${e} – ${t}`;
411
422
  }
412
- return i.from ? h(i.from, p, { locale: u }) : "";
413
- })(), q = a.from ? a.to ? null : "end" : "start", St = (() => {
423
+ return o.from ? k(o.from, m, { locale: u }) : "";
424
+ })(), U = a.from ? a.to ? null : "end" : "start", Vt = (() => {
414
425
  if (!a.from)
415
426
  return n("inputs.dateRangePicker.selectStart", "Select start date");
416
427
  if (!a.to)
417
428
  return n("inputs.dateRangePicker.selectEnd", "Select end date");
418
- const e = ue(a.to, a.from) + 1, t = h(a.from, p, { locale: u }), d = h(a.to, p, { locale: u }), o = n("inputs.dateRangePicker.days", { count: e });
419
- return `${t} – ${d} · ${o}`;
420
- })(), g = ce({
421
- currentValue: i,
422
- open: C,
423
- getGranularity: () => $ ? W : void 0,
424
- setGranularity: (e) => Z(L(e)),
425
- getCompareRange: () => T ? O(i) : void 0,
426
- setCompare: (e) => ae(e),
427
- getActivePreset: () => {
428
- var e;
429
- return (e = j.find(ie)) == null ? void 0 : e.label;
429
+ const e = ge(a.to, a.from) + 1, t = k(a.from, m, { locale: u }), d = k(a.to, m, { locale: u }), i = n("inputs.dateRangePicker.days", { count: e });
430
+ return `${t} – ${d} · ${i}`;
431
+ })(), v = fe({
432
+ currentValue: o,
433
+ open: O,
434
+ getGranularity: () => q ? z : void 0,
435
+ setGranularity: (e) => se(W(e)),
436
+ getCompareRange: () => Me ? y(o) : void 0,
437
+ // Imperative/agent path commits directly (like setRange/clear), so
438
+ // toggle_compare reflects in getCompareRange immediately — not a draft.
439
+ setCompare: (e) => {
440
+ E(e), B(e), f == null || f(
441
+ e,
442
+ e ? y(o) : void 0
443
+ );
430
444
  },
431
- getActiveEnd: () => q,
432
- apply: () => ne(),
433
- cancel: () => oe()
445
+ getActivePreset: () => S == null ? void 0 : S.label,
446
+ getActiveEnd: () => U,
447
+ apply: () => le(),
448
+ cancel: () => ce()
434
449
  });
435
- g.current = {
436
- currentValue: i,
437
- open: C,
438
- getGranularity: () => $ ? W : void 0,
439
- setGranularity: (e) => Z(L(e)),
440
- getCompareRange: () => T ? O(i) : void 0,
441
- setCompare: (e) => ae(e),
442
- getActivePreset: () => {
443
- var e;
444
- return (e = j.find(ie)) == null ? void 0 : e.label;
450
+ v.current = {
451
+ currentValue: o,
452
+ open: O,
453
+ getGranularity: () => q ? z : void 0,
454
+ setGranularity: (e) => se(W(e)),
455
+ getCompareRange: () => Me ? y(o) : void 0,
456
+ setCompare: (e) => {
457
+ E(e), B(e), f == null || f(
458
+ e,
459
+ e ? y(o) : void 0
460
+ );
445
461
  },
446
- getActiveEnd: () => q,
447
- apply: () => ne(),
448
- cancel: () => oe()
462
+ getActivePreset: () => S == null ? void 0 : S.label,
463
+ getActiveEnd: () => U,
464
+ apply: () => le(),
465
+ cancel: () => ce()
449
466
  };
450
- const de = Ot(
467
+ const ue = Mt(
451
468
  () => ({
452
- getRange: () => g.current.currentValue,
453
- setRange: (e) => k(e),
454
- clear: () => k({}),
455
- isOpen: () => g.current.open,
456
- open: () => b(!0),
457
- close: () => b(!1),
458
- getGranularity: () => g.current.getGranularity(),
459
- setGranularity: (e) => g.current.setGranularity(e),
460
- getCompareRange: () => g.current.getCompareRange(),
461
- setCompare: (e) => g.current.setCompare(e),
462
- getActivePreset: () => g.current.getActivePreset(),
463
- getActiveEnd: () => g.current.getActiveEnd(),
464
- apply: () => g.current.apply(),
465
- cancel: () => g.current.cancel()
469
+ getRange: () => v.current.currentValue,
470
+ setRange: (e) => x(e),
471
+ clear: () => x({}),
472
+ isOpen: () => v.current.open,
473
+ open: () => R(!0),
474
+ close: () => R(!1),
475
+ getGranularity: () => v.current.getGranularity(),
476
+ setGranularity: (e) => v.current.setGranularity(e),
477
+ getCompareRange: () => v.current.getCompareRange(),
478
+ setCompare: (e) => v.current.setCompare(e),
479
+ getActivePreset: () => v.current.getActivePreset(),
480
+ getActiveEnd: () => v.current.getActiveEnd(),
481
+ apply: () => v.current.apply(),
482
+ cancel: () => v.current.cancel()
466
483
  }),
467
- [k]
484
+ [x]
468
485
  );
469
- Tt(nt, () => de, [de]), Ft(oa, de, J);
470
- const Fe = (e) => e === "from" ? w ? "error" : q === "start" ? "active" : "default" : I ? "error" : q === "end" ? "active" : "default";
471
- return /* @__PURE__ */ r(_.Root, { open: C, onOpenChange: Ct, children: /* @__PURE__ */ c(
486
+ Ft(lt, () => ue, [ue]), Wt(ua, ue, ae);
487
+ const $e = (e) => e === "from" ? G ? "error" : U === "start" ? "active" : "default" : V ? "error" : U === "end" ? "active" : "default";
488
+ return /* @__PURE__ */ r(H.Root, { open: O, onOpenChange: Tt, children: /* @__PURE__ */ c(
472
489
  "div",
473
490
  {
474
- className: rt,
491
+ className: ot,
475
492
  "data-component": "date-range-picker",
476
- "data-component-id": J,
493
+ "data-component-id": ae,
477
494
  children: [
478
- /* @__PURE__ */ r(_.Trigger, { asChild: !0, disabled: he, children: /* @__PURE__ */ c(
495
+ /* @__PURE__ */ r(H.Trigger, { asChild: !0, disabled: Re, children: /* @__PURE__ */ c(
479
496
  "button",
480
497
  {
481
- ref: mt,
482
- id: J,
498
+ ref: vt,
499
+ id: ae,
483
500
  type: "button",
484
- disabled: he,
485
- "aria-describedby": V.describedBy || void 0,
486
- "aria-invalid": V.invalid || void 0,
501
+ disabled: Re,
502
+ "aria-describedby": A.describedBy || void 0,
503
+ "aria-invalid": A.invalid || void 0,
487
504
  "aria-haspopup": "dialog",
488
- "aria-expanded": C,
489
- className: Bt({ size: ve, tone: ot, chrome: et }),
505
+ "aria-expanded": O,
506
+ className: Jt({ size: be, tone: ct, chrome: st }),
490
507
  children: [
491
508
  /* @__PURE__ */ r(
492
509
  "span",
@@ -498,24 +515,24 @@ const oa = {
498
515
  // lets the flex child shrink below its content width so
499
516
  // `truncate` engages.
500
517
  "ds:min-w-0 ds:flex-1 ds:truncate ds:text-start",
501
- Ve ? "ds:text-foreground" : "ds:text-muted-foreground"
518
+ Le ? "ds:text-foreground" : "ds:text-muted-foreground"
502
519
  ].join(" "),
503
- children: Ve || it
520
+ children: Le || ut
504
521
  }
505
522
  ),
506
523
  /* @__PURE__ */ r(
507
524
  "span",
508
525
  {
509
526
  "aria-hidden": "true",
510
- className: zt({ size: ve }),
511
- children: /* @__PURE__ */ r(aa, {})
527
+ className: Qt({ size: be }),
528
+ children: /* @__PURE__ */ r(oa, {})
512
529
  }
513
530
  )
514
531
  ]
515
532
  }
516
533
  ) }),
517
- /* @__PURE__ */ r(_.Portal, { children: /* @__PURE__ */ r(
518
- _.Content,
534
+ /* @__PURE__ */ r(H.Portal, { children: /* @__PURE__ */ r(
535
+ H.Content,
519
536
  {
520
537
  sideOffset: 4,
521
538
  align: "start",
@@ -524,35 +541,35 @@ const oa = {
524
541
  "inputs.dateRangePicker.title",
525
542
  "Select date range"
526
543
  ),
527
- className: Zt(),
544
+ className: sa(),
528
545
  children: /* @__PURE__ */ c("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
529
546
  /* @__PURE__ */ c("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
530
547
  /* @__PURE__ */ c("div", { className: "ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]", children: [
531
548
  /* @__PURE__ */ r(
532
549
  "h2",
533
550
  {
534
- id: Ce,
551
+ id: Oe,
535
552
  className: "type-body-sm ds:font-semibold ds:text-foreground",
536
553
  children: n("inputs.dateRangePicker.title", "Select date range")
537
554
  }
538
555
  ),
539
- $ ? /* @__PURE__ */ r(
540
- z.Root,
556
+ q ? /* @__PURE__ */ r(
557
+ Q.Root,
541
558
  {
542
- value: W,
543
- onValueChange: (e) => Z(
544
- L(e)
559
+ value: z,
560
+ onValueChange: (e) => se(
561
+ W(e)
545
562
  ),
546
563
  "aria-label": n(
547
564
  "inputs.dateRangePicker.granularityLabel",
548
565
  "Granularity"
549
566
  ),
550
- className: qe(),
551
- children: Ne.map((e) => /* @__PURE__ */ r(
552
- z.Item,
567
+ className: Be(),
568
+ children: we.map((e) => /* @__PURE__ */ r(
569
+ Q.Item,
553
570
  {
554
571
  value: e.value,
555
- className: je(),
572
+ className: ze(),
556
573
  children: n(
557
574
  `inputs.dateRangePicker.granularity.${e.value}`,
558
575
  e.fallback
@@ -568,7 +585,7 @@ const oa = {
568
585
  /* @__PURE__ */ r(
569
586
  "label",
570
587
  {
571
- htmlFor: Se,
588
+ htmlFor: Te,
572
589
  className: "ds:text-[length:var(--font-size-xs)] ds:text-muted-foreground",
573
590
  children: n("inputs.dateRangePicker.startLabel", "Start date")
574
591
  }
@@ -576,18 +593,18 @@ const oa = {
576
593
  /* @__PURE__ */ r(
577
594
  "input",
578
595
  {
579
- id: Se,
596
+ id: Te,
580
597
  type: "text",
581
598
  inputMode: "numeric",
582
- value: ke,
583
- placeholder: p.toUpperCase(),
584
- "aria-invalid": w || void 0,
585
- "aria-describedby": w ? te : void 0,
586
- onChange: (e) => Re(e.target.value),
587
- onBlur: (e) => se("from", e.target.value),
588
- onKeyDown: Ee("from"),
589
- className: _e({
590
- state: Fe("from")
599
+ value: Pe,
600
+ placeholder: m.toUpperCase(),
601
+ "aria-invalid": G || void 0,
602
+ "aria-describedby": G ? ne : void 0,
603
+ onChange: (e) => Ne(e.target.value),
604
+ onBlur: (e) => de("from", e.target.value),
605
+ onKeyDown: Ke("from"),
606
+ className: Ye({
607
+ state: $e("from")
591
608
  })
592
609
  }
593
610
  )
@@ -604,7 +621,7 @@ const oa = {
604
621
  /* @__PURE__ */ r(
605
622
  "label",
606
623
  {
607
- htmlFor: we,
624
+ htmlFor: Ge,
608
625
  className: "ds:text-[length:var(--font-size-xs)] ds:text-muted-foreground",
609
626
  children: n("inputs.dateRangePicker.endLabel", "End date")
610
627
  }
@@ -612,54 +629,54 @@ const oa = {
612
629
  /* @__PURE__ */ r(
613
630
  "input",
614
631
  {
615
- id: we,
632
+ id: Ge,
616
633
  type: "text",
617
634
  inputMode: "numeric",
618
- value: xe,
619
- placeholder: p.toUpperCase(),
620
- "aria-invalid": I || void 0,
621
- "aria-describedby": I ? te : void 0,
622
- onChange: (e) => Pe(e.target.value),
623
- onBlur: (e) => se("to", e.target.value),
624
- onKeyDown: Ee("to"),
625
- className: _e({
626
- state: Fe("to")
635
+ value: De,
636
+ placeholder: m.toUpperCase(),
637
+ "aria-invalid": V || void 0,
638
+ "aria-describedby": V ? ne : void 0,
639
+ onChange: (e) => Se(e.target.value),
640
+ onBlur: (e) => de("to", e.target.value),
641
+ onKeyDown: Ke("to"),
642
+ className: Ye({
643
+ state: $e("to")
627
644
  })
628
645
  }
629
646
  )
630
647
  ] })
631
648
  ] }),
632
- w || I ? /* @__PURE__ */ r(
649
+ G || V ? /* @__PURE__ */ r(
633
650
  "p",
634
651
  {
635
- id: te,
652
+ id: ne,
636
653
  role: "alert",
637
654
  className: "ds:text-[length:var(--font-size-xs)] ds:text-destructive",
638
655
  children: n(
639
656
  "inputs.dateRangePicker.invalidDate",
640
657
  "Enter a date as {{format}}",
641
658
  {
642
- format: p.toUpperCase()
659
+ format: m.toUpperCase()
643
660
  }
644
661
  )
645
662
  }
646
663
  ) : null
647
664
  ] }),
648
665
  /* @__PURE__ */ c("div", { className: "ds:flex ds:gap-[var(--spacing-md)]", children: [
649
- j.length > 0 ? /* @__PURE__ */ r("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)] ds:min-w-[8rem] ds:border-e ds:border-border ds:pe-[var(--spacing-md)]", children: Te.map((e, t) => {
650
- const d = `${Ce}-pg${t}`, o = e.presets.map((R) => {
651
- const le = ie(R);
666
+ ie.length > 0 ? /* @__PURE__ */ r("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)] ds:min-w-[8rem] ds:border-e ds:border-border ds:pe-[var(--spacing-md)]", children: Ee.map((e, t) => {
667
+ const d = `${Oe}-pg${t}`, i = e.presets.map((P) => {
668
+ const pe = P === S;
652
669
  return /* @__PURE__ */ c(
653
670
  "button",
654
671
  {
655
672
  type: "button",
656
- "aria-pressed": le,
657
- onClick: () => Rt(R),
658
- className: Yt({ active: le }),
673
+ "aria-pressed": pe,
674
+ onClick: () => Dt(P),
675
+ className: Xt({ active: pe }),
659
676
  children: [
660
- /* @__PURE__ */ r("span", { className: "ds:min-w-0 ds:truncate", children: R.label }),
661
- le ? /* @__PURE__ */ r(
662
- ra,
677
+ /* @__PURE__ */ r("span", { className: "ds:min-w-0 ds:truncate", children: P.label }),
678
+ pe ? /* @__PURE__ */ r(
679
+ da,
663
680
  {
664
681
  "aria-hidden": "true",
665
682
  className: "ds:size-4 ds:shrink-0 ds:text-primary"
@@ -667,10 +684,10 @@ const oa = {
667
684
  ) : null
668
685
  ]
669
686
  },
670
- R.label
687
+ P.label
671
688
  );
672
689
  });
673
- return yt && e.group ? /* @__PURE__ */ c(
690
+ return kt && e.group ? /* @__PURE__ */ c(
674
691
  "div",
675
692
  {
676
693
  role: "group",
@@ -681,56 +698,56 @@ const oa = {
681
698
  "div",
682
699
  {
683
700
  id: d,
684
- className: Ut(),
701
+ className: Zt(),
685
702
  children: e.group
686
703
  }
687
704
  ),
688
- o
705
+ i
689
706
  ]
690
707
  },
691
708
  e.group
692
- ) : /* @__PURE__ */ r(Gt, { children: o }, e.group || "_ungrouped");
709
+ ) : /* @__PURE__ */ r(Kt, { children: i }, e.group || "_ungrouped");
693
710
  }) }) : null,
694
- /* @__PURE__ */ c("div", { role: "region", "aria-labelledby": Ie, children: [
695
- /* @__PURE__ */ r("span", { id: Ie, className: "ds:sr-only", children: n("inputs.dateRangePicker.gridLabel", "Calendar") }),
711
+ /* @__PURE__ */ c("div", { role: "region", "aria-labelledby": Ve, children: [
712
+ /* @__PURE__ */ r("span", { id: Ve, className: "ds:sr-only", children: n("inputs.dateRangePicker.gridLabel", "Calendar") }),
696
713
  /* @__PURE__ */ r(
697
- Ht,
714
+ ea,
698
715
  {
699
716
  mode: "range",
700
717
  selected: a.from ? { from: a.from, to: a.to } : void 0,
701
- onSelect: kt,
702
- month: lt,
703
- onMonthChange: X,
704
- numberOfMonths: He,
705
- weekStartsOn: M,
706
- disabled: gt,
718
+ onSelect: Nt,
719
+ month: ft,
720
+ onMonthChange: re,
721
+ numberOfMonths: Xe,
722
+ weekStartsOn: K,
723
+ disabled: ht,
707
724
  locale: u,
708
725
  showOutsideDays: !0,
709
726
  fixedWeeks: !0,
710
727
  pagedNavigation: !0,
711
- classNames: Xt,
712
- modifiers: ht,
713
- modifiersClassNames: Jt,
714
- components: { Chevron: Qt }
728
+ classNames: ra,
729
+ modifiers: Rt,
730
+ modifiersClassNames: aa,
731
+ components: { Chevron: ta }
715
732
  }
716
733
  )
717
734
  ] })
718
735
  ] }),
719
- ge ? /* @__PURE__ */ c("div", { className: "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)] ds:border-t ds:border-border ds:pt-[var(--spacing-sm)]", children: [
736
+ j ? /* @__PURE__ */ c("div", { className: "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)] ds:border-t ds:border-border ds:pt-[var(--spacing-sm)]", children: [
720
737
  /* @__PURE__ */ r(
721
- Vt,
738
+ $t,
722
739
  {
723
- id: ft,
740
+ id: yt,
724
741
  label: n(
725
742
  "inputs.dateRangePicker.compareLabel",
726
743
  "Compare to previous period"
727
744
  ),
728
745
  size: "sm",
729
- checked: ee,
730
- onCheckedChange: ae
746
+ checked: N,
747
+ onCheckedChange: Pt
731
748
  }
732
749
  ),
733
- T && v ? /* @__PURE__ */ c("span", { className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)] ds:text-[length:var(--font-size-xs)] ds:text-muted-foreground", children: [
750
+ Y && h ? /* @__PURE__ */ c("span", { className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)] ds:text-[length:var(--font-size-xs)] ds:text-muted-foreground", children: [
734
751
  /* @__PURE__ */ r(
735
752
  "span",
736
753
  {
@@ -738,23 +755,23 @@ const oa = {
738
755
  className: "ds:inline-block ds:size-3 ds:rounded-[calc(var(--radius-sm)-2px)] ds:bg-[var(--calendar-compare-fill)] ds:border-b-2 ds:border-dashed ds:border-b-[var(--calendar-compare-edge)]"
739
756
  }
740
757
  ),
741
- `${h(v.from, p, { locale: u })} – ${h(v.to, p, { locale: u })}`
758
+ `${k(h.from, m, { locale: u })} – ${k(h.to, m, { locale: u })}`
742
759
  ] }) : null,
743
- ee ? /* @__PURE__ */ r(
744
- z.Root,
760
+ N ? /* @__PURE__ */ r(
761
+ Q.Root,
745
762
  {
746
- value: De,
747
- onValueChange: bt,
763
+ value: Ie,
764
+ onValueChange: xt,
748
765
  "aria-label": n(
749
766
  "inputs.dateRangePicker.compareModeLabel",
750
767
  "Comparison period"
751
768
  ),
752
- className: `${qe()} ds:ms-auto`,
753
- children: ia.map((e) => /* @__PURE__ */ r(
754
- z.Item,
769
+ className: `${Be()} ds:ms-auto`,
770
+ children: pa.map((e) => /* @__PURE__ */ r(
771
+ Q.Item,
755
772
  {
756
773
  value: e.value,
757
- className: je(),
774
+ className: ze(),
758
775
  children: n(
759
776
  `inputs.dateRangePicker.compareMode.${e.value}`,
760
777
  e.fallback
@@ -772,26 +789,26 @@ const oa = {
772
789
  role: "status",
773
790
  "aria-live": "polite",
774
791
  className: "type-body-sm ds:min-w-0 ds:truncate ds:text-muted-foreground",
775
- children: St
792
+ children: Vt
776
793
  }
777
794
  ),
778
795
  /* @__PURE__ */ c("div", { className: "ds:flex ds:shrink-0 ds:gap-[var(--spacing-xs)]", children: [
779
- Ue ? /* @__PURE__ */ r(
796
+ Je ? /* @__PURE__ */ r(
780
797
  "button",
781
798
  {
782
799
  type: "button",
783
- onClick: xt,
784
- className: B({ intent: "ghost" }),
800
+ onClick: St,
801
+ className: J({ intent: "ghost" }),
785
802
  children: n("inputs.dateRangePicker.clear", "Clear")
786
803
  }
787
804
  ) : null,
788
- m === "apply" ? /* @__PURE__ */ c(wt, { children: [
805
+ p === "apply" ? /* @__PURE__ */ c(Ct, { children: [
789
806
  /* @__PURE__ */ r(
790
807
  "button",
791
808
  {
792
809
  type: "button",
793
- onClick: oe,
794
- className: B({ intent: "ghost" }),
810
+ onClick: ce,
811
+ className: J({ intent: "ghost" }),
795
812
  children: n("inputs.dateRangePicker.cancel", "Cancel")
796
813
  }
797
814
  ),
@@ -799,9 +816,9 @@ const oa = {
799
816
  "button",
800
817
  {
801
818
  type: "button",
802
- disabled: !Me,
803
- onClick: ne,
804
- className: B({ intent: "primary" }),
819
+ disabled: !Ae,
820
+ onClick: le,
821
+ className: J({ intent: "primary" }),
805
822
  children: n("inputs.dateRangePicker.apply", "Apply")
806
823
  }
807
824
  )
@@ -809,8 +826,8 @@ const oa = {
809
826
  "button",
810
827
  {
811
828
  type: "button",
812
- onClick: Dt,
813
- className: B({ intent: "primary" }),
829
+ onClick: Ot,
830
+ className: J({ intent: "primary" }),
814
831
  children: n("inputs.dateRangePicker.done", "Done")
815
832
  }
816
833
  )
@@ -824,9 +841,9 @@ const oa = {
824
841
  ) });
825
842
  }
826
843
  );
827
- da.displayName = "DateRangePicker";
844
+ fa.displayName = "DateRangePicker";
828
845
  export {
829
- da as D,
830
- oa as d
846
+ fa as D,
847
+ ua as d
831
848
  };
832
- //# sourceMappingURL=date-range-picker-Cfv4Sr63.js.map
849
+ //# sourceMappingURL=date-range-picker-pEG3Ln3i.js.map