@pibit.ai/cure-design-system 0.5.7 → 0.5.8

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.
Files changed (72) hide show
  1. package/dist/applications/date-picker/calendar.d.ts +42 -0
  2. package/dist/applications/date-picker/calendar.d.ts.map +1 -0
  3. package/dist/applications/date-picker/calendar.js +310 -0
  4. package/dist/applications/date-picker/cell.d.ts +15 -0
  5. package/dist/applications/date-picker/cell.d.ts.map +1 -0
  6. package/dist/applications/date-picker/cell.js +90 -0
  7. package/dist/applications/date-picker/date-input.d.ts +7 -0
  8. package/dist/applications/date-picker/date-input.d.ts.map +1 -0
  9. package/dist/applications/date-picker/date-input.js +39 -0
  10. package/dist/applications/date-picker/date-picker.d.ts +47 -0
  11. package/dist/applications/date-picker/date-picker.d.ts.map +1 -0
  12. package/dist/applications/date-picker/date-picker.js +237 -0
  13. package/dist/applications/date-picker/date-range-picker.d.ts +44 -0
  14. package/dist/applications/date-picker/date-range-picker.d.ts.map +1 -0
  15. package/dist/applications/date-picker/date-range-picker.js +335 -0
  16. package/dist/applications/date-picker/date-range-presets.d.ts +50 -0
  17. package/dist/applications/date-picker/date-range-presets.d.ts.map +1 -0
  18. package/dist/applications/date-picker/date-range-presets.js +86 -0
  19. package/dist/applications/date-picker/date-time-calendar.d.ts +34 -0
  20. package/dist/applications/date-picker/date-time-calendar.d.ts.map +1 -0
  21. package/dist/applications/date-picker/date-time-calendar.js +140 -0
  22. package/dist/applications/date-picker/index.d.ts +12 -0
  23. package/dist/applications/date-picker/index.d.ts.map +1 -0
  24. package/dist/applications/date-picker/index.js +36 -0
  25. package/dist/applications/date-picker/range-calendar.d.ts +23 -0
  26. package/dist/applications/date-picker/range-calendar.d.ts.map +1 -0
  27. package/dist/applications/date-picker/range-calendar.js +210 -0
  28. package/dist/applications/date-picker/range-preset.d.ts +10 -0
  29. package/dist/applications/date-picker/range-preset.d.ts.map +1 -0
  30. package/dist/applications/date-picker/range-preset.js +27 -0
  31. package/dist/applications/date-picker/styles.d.ts +8 -0
  32. package/dist/applications/date-picker/styles.d.ts.map +1 -0
  33. package/dist/applications/date-picker/styles.js +14 -0
  34. package/dist/applications/date-picker/time-field.d.ts +7 -0
  35. package/dist/applications/date-picker/time-field.d.ts.map +1 -0
  36. package/dist/applications/date-picker/time-field.js +116 -0
  37. package/dist/applications/date-picker/time-list.d.ts +23 -0
  38. package/dist/applications/date-picker/time-list.d.ts.map +1 -0
  39. package/dist/applications/date-picker/time-list.js +89 -0
  40. package/dist/hooks/use-breakpoint.d.ts +10 -0
  41. package/dist/hooks/use-breakpoint.d.ts.map +1 -0
  42. package/dist/hooks/use-breakpoint.js +21 -0
  43. package/dist/index.d.ts +1 -0
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +341 -316
  46. package/dist/node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.js +6 -6
  47. package/dist/node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.js +6 -6
  48. package/dist/primitives/select/multi-select.js +81 -82
  49. package/dist/styles/components.css +1 -1
  50. package/package.json +8 -1
  51. package/dist/node_modules/@react-aria/focus/dist/FocusScope.js +0 -442
  52. package/dist/node_modules/@react-aria/i18n/dist/context.js +0 -10
  53. package/dist/node_modules/@react-aria/i18n/dist/useCollator.js +0 -11
  54. package/dist/node_modules/@react-aria/i18n/dist/useDefaultLocale.js +0 -36
  55. package/dist/node_modules/@react-aria/i18n/dist/useFilter.js +0 -35
  56. package/dist/node_modules/@react-aria/i18n/dist/utils.js +0 -44
  57. package/dist/node_modules/@react-aria/interactions/dist/focusSafely.js +0 -18
  58. package/dist/node_modules/@react-aria/interactions/dist/useFocusVisible.js +0 -62
  59. package/dist/node_modules/@react-aria/interactions/dist/utils.js +0 -5
  60. package/dist/node_modules/@react-aria/ssr/dist/SSRProvider.js +0 -49
  61. package/dist/node_modules/@react-aria/utils/dist/DOMFunctions.js +0 -27
  62. package/dist/node_modules/@react-aria/utils/dist/ShadowTreeWalker.js +0 -130
  63. package/dist/node_modules/@react-aria/utils/dist/domHelpers.js +0 -15
  64. package/dist/node_modules/@react-aria/utils/dist/focusWithoutScrolling.js +0 -45
  65. package/dist/node_modules/@react-aria/utils/dist/isElementVisible.js +0 -25
  66. package/dist/node_modules/@react-aria/utils/dist/isFocusable.js +0 -37
  67. package/dist/node_modules/@react-aria/utils/dist/isVirtualEvent.js +0 -7
  68. package/dist/node_modules/@react-aria/utils/dist/openLink.js +0 -28
  69. package/dist/node_modules/@react-aria/utils/dist/platform.js +0 -47
  70. package/dist/node_modules/@react-aria/utils/dist/runAfterTransition.js +0 -35
  71. package/dist/node_modules/@react-aria/utils/dist/useLayoutEffect.js +0 -6
  72. package/dist/node_modules/@react-stately/flags/dist/import.js +0 -7
@@ -0,0 +1,237 @@
1
+ import { jsx as e, jsxs as m, Fragment as W } from "react/jsx-runtime";
2
+ import { getLocalTimeZone as E, toCalendarDateTime as Y, today as A } from "@internationalized/date";
3
+ import { useControlledState as ee } from "@react-stately/utils";
4
+ import { Calendar as $, XClose as te } from "@untitledui/icons";
5
+ import { useState as oe, useCallback as ne, useEffect as re } from "react";
6
+ import { useDateFormatter as ie, I18nProvider as le } from "react-aria";
7
+ import { DatePicker as ae, Group as se, ButtonContext as de, Popover as ce, Dialog as me } from "react-aria-components";
8
+ import { cx as r, sortCx as ue } from "../../utils/cn.js";
9
+ import { ControlledCalendarContextProvider as he, Calendar as q } from "./calendar.js";
10
+ import { Button as g } from "../../primitives/button/button.js";
11
+ import { DateTimeCalendar as fe } from "./date-time-calendar.js";
12
+ const P = [A(E())], s = ue({
13
+ xs: { button: "xs", text: "text-xs", icon: "size-3!" },
14
+ sm: { button: "xs", text: "text-sm", icon: "size-3.5!" },
15
+ md: { button: "sm", text: "text-md", icon: "size-4!" }
16
+ }), pe = (t) => t === "hour" || t === "minute" || t === "second", S = (t) => t && !("hour" in t) ? Y(t) : t;
17
+ function ge({
18
+ committedValue: t,
19
+ onSync: y
20
+ }) {
21
+ return re(() => {
22
+ y(t);
23
+ }, []), null;
24
+ }
25
+ const Oe = ({
26
+ value: t,
27
+ defaultValue: y,
28
+ onChange: F,
29
+ onApply: b,
30
+ onCancel: x,
31
+ className: C,
32
+ showFooter: v = !0,
33
+ triggerClassName: k,
34
+ clearable: I = !1,
35
+ endAdornment: w,
36
+ isDisabled: O,
37
+ size: i = "xs",
38
+ granularity: u,
39
+ minValue: T,
40
+ maxValue: V,
41
+ isDateUnavailable: j,
42
+ firstDayOfWeek: z,
43
+ hourCycle: U,
44
+ timeStep: X,
45
+ defaultTime: Z,
46
+ ...G
47
+ }) => {
48
+ const n = pe(u), L = {
49
+ minValue: T,
50
+ maxValue: V,
51
+ isDateUnavailable: j,
52
+ firstDayOfWeek: z,
53
+ isReadOnly: G.isReadOnly
54
+ }, h = U ?? (n ? 12 : void 0), _ = ie({
55
+ month: "short",
56
+ day: "numeric",
57
+ year: "numeric",
58
+ ...n && {
59
+ hour: "numeric",
60
+ minute: "2-digit",
61
+ second: u === "second" ? "2-digit" : void 0,
62
+ hourCycle: h === 24 ? "h23" : h === 12 ? "h12" : void 0
63
+ }
64
+ }), [d, c] = ee(
65
+ t,
66
+ y || null,
67
+ F
68
+ ), D = d ?? null, [f, N] = oe(
69
+ D
70
+ ), o = v, l = o ? D : d, H = o ? () => {
71
+ } : c, B = l ? _.format(l.toDate(E())) : n ? "Select date and time" : "Select date", p = typeof C == "string" && C.includes("w-full"), J = (a) => {
72
+ o && (c(f), b == null || b(f ?? void 0)), a();
73
+ }, K = ne(() => {
74
+ c(null);
75
+ }, [c]), M = I && D != null && !O, R = w ? "pr-8" : void 0;
76
+ return /* @__PURE__ */ e(le, { locale: "en-US", children: /* @__PURE__ */ m(
77
+ ae,
78
+ {
79
+ shouldCloseOnSelect: !v && !n,
80
+ ...G,
81
+ minValue: T,
82
+ maxValue: V,
83
+ isDateUnavailable: j,
84
+ firstDayOfWeek: z,
85
+ granularity: u,
86
+ hourCycle: h,
87
+ isDisabled: O,
88
+ className: C,
89
+ value: n ? S(o ? l : d) : o ? l : d,
90
+ onChange: H,
91
+ children: [
92
+ /* @__PURE__ */ m(se, { className: r("relative", p && "w-full"), children: [
93
+ M ? /* @__PURE__ */ m(
94
+ "div",
95
+ {
96
+ className: r(
97
+ "flex min-w-0 overflow-hidden rounded-md bg-primary ring-1 ring-secondary ring-inset border border-secondary",
98
+ p && "w-full"
99
+ ),
100
+ children: [
101
+ /* @__PURE__ */ e(
102
+ g,
103
+ {
104
+ size: s[i].button,
105
+ color: "secondary",
106
+ iconLeading: $,
107
+ className: r(
108
+ "min-w-0 flex-1 rounded-none ring-0 shadow-none",
109
+ s[i].text,
110
+ p && "justify-start",
111
+ R,
112
+ k
113
+ ),
114
+ leadingClassName: s[i].icon,
115
+ children: B
116
+ }
117
+ ),
118
+ /* @__PURE__ */ e(
119
+ "button",
120
+ {
121
+ type: "button",
122
+ "aria-label": "Clear date",
123
+ onClick: K,
124
+ className: r(
125
+ "flex w-9 shrink-0 items-center justify-center bg-primary text-fg-quaternary",
126
+ "transition-colors hover:bg-primary_hover hover:text-secondary",
127
+ "focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-inset"
128
+ ),
129
+ children: /* @__PURE__ */ e(te, { "aria-hidden": !0, className: "size-4 shrink-0" })
130
+ }
131
+ )
132
+ ]
133
+ }
134
+ ) : /* @__PURE__ */ e(
135
+ g,
136
+ {
137
+ size: s[i].button,
138
+ color: "secondary",
139
+ iconLeading: $,
140
+ className: r(
141
+ s[i].text,
142
+ p && "w-full min-w-0 justify-start",
143
+ R,
144
+ k
145
+ ),
146
+ leadingClassName: s[i].icon,
147
+ children: B
148
+ }
149
+ ),
150
+ w ? /* @__PURE__ */ e(de.Provider, { value: null, children: /* @__PURE__ */ e(
151
+ "div",
152
+ {
153
+ className: r(
154
+ "absolute top-1/2 z-10 -translate-y-1/2",
155
+ M ? "right-9" : "right-1"
156
+ ),
157
+ children: w
158
+ }
159
+ ) }) : null
160
+ ] }),
161
+ /* @__PURE__ */ e(
162
+ ce,
163
+ {
164
+ offset: 8,
165
+ placement: "bottom right",
166
+ containerPadding: 16,
167
+ className: ({ isEntering: a, isExiting: Q }) => r(
168
+ "origin-(--trigger-anchor-point) will-change-transform overflow-y-auto",
169
+ a && "duration-150 ease-out animate-in fade-in placement-right:slide-in-from-left-0.5 placement-top:slide-in-from-bottom-0.5 placement-bottom:slide-in-from-top-0.5",
170
+ Q && "duration-100 ease-in animate-out fade-out placement-right:slide-out-to-left-0.5 placement-top:slide-out-to-bottom-0.5 placement-bottom:slide-out-to-top-0.5"
171
+ ),
172
+ children: /* @__PURE__ */ e(me, { className: "rounded-2xl bg-primary shadow-xl border border-secondary", children: ({ close: a }) => /* @__PURE__ */ m(W, { children: [
173
+ o && /* @__PURE__ */ e(
174
+ ge,
175
+ {
176
+ committedValue: n ? S(l) ?? null : l,
177
+ onSync: N
178
+ }
179
+ ),
180
+ /* @__PURE__ */ e("div", { className: "flex px-6 py-5", children: n ? /* @__PURE__ */ e(
181
+ fe,
182
+ {
183
+ value: o ? f : S(d) ?? null,
184
+ onChange: o ? N : c,
185
+ ...L,
186
+ highlightedDates: P,
187
+ timeStep: X,
188
+ hourCycle: h,
189
+ timeGranularity: u,
190
+ defaultTime: Z
191
+ }
192
+ ) : o ? /* @__PURE__ */ e(
193
+ he,
194
+ {
195
+ value: f,
196
+ onChange: N,
197
+ children: /* @__PURE__ */ e(
198
+ q,
199
+ {
200
+ ...L,
201
+ highlightedDates: P
202
+ }
203
+ )
204
+ }
205
+ ) : /* @__PURE__ */ e(q, { highlightedDates: P }) }),
206
+ v && /* @__PURE__ */ m("div", { className: "grid grid-cols-2 gap-3 border-t border-secondary p-4", children: [
207
+ /* @__PURE__ */ e(
208
+ g,
209
+ {
210
+ size: "md",
211
+ color: "secondary",
212
+ onClick: () => {
213
+ x == null || x(), a();
214
+ },
215
+ children: "Cancel"
216
+ }
217
+ ),
218
+ /* @__PURE__ */ e(
219
+ g,
220
+ {
221
+ size: "md",
222
+ color: "primary",
223
+ onClick: () => J(a),
224
+ children: "Apply"
225
+ }
226
+ )
227
+ ] })
228
+ ] }) })
229
+ }
230
+ )
231
+ ]
232
+ }
233
+ ) });
234
+ };
235
+ export {
236
+ Oe as DatePicker
237
+ };
@@ -0,0 +1,44 @@
1
+ import { DateRangePickerProps as AriaDateRangePickerProps, DateValue } from 'react-aria-components';
2
+ export interface DateRangePickerProps extends AriaDateRangePickerProps<DateValue> {
3
+ /** The function to call when the apply button is clicked. */
4
+ onApply?: () => void;
5
+ /** The function to call when the cancel button is clicked. */
6
+ onCancel?: () => void;
7
+ /** The function to call when the reset button is clicked. */
8
+ onReset?: () => void;
9
+ /** Header label shown before the field selector. */
10
+ headerLabel?: string;
11
+ /** Options for the header field selector. */
12
+ rangeFieldOptions?: Array<{
13
+ label: string;
14
+ value: string;
15
+ }>;
16
+ /** Controlled selected value for the header field selector. */
17
+ selectedRangeField?: string;
18
+ /** Callback when header field selection changes. */
19
+ onRangeFieldChange?: (value: string) => void;
20
+ /** Right-aligned timezone label text. */
21
+ timezoneLabel?: string;
22
+ /** Enable showing time selectors next to date inputs. */
23
+ enableTimeSelection?: boolean;
24
+ /** Custom time options for the time selectors. */
25
+ timeOptions?: Array<{
26
+ label: string;
27
+ value: string;
28
+ }>;
29
+ /** Controlled start time value (selectedKey). */
30
+ startTime?: string;
31
+ /** Controlled end time value (selectedKey). */
32
+ endTime?: string;
33
+ /** Callback when either start or end time changes. */
34
+ onTimeChange?: (t: {
35
+ startTime: string;
36
+ endTime: string;
37
+ }) => void;
38
+ showFieldDropdown?: boolean;
39
+ size?: "xs" | "sm" | "md" | "lg";
40
+ buttonClassName?: string;
41
+ iconClassName?: string;
42
+ }
43
+ export declare const DateRangePicker: ({ value: valueProp, defaultValue, onChange, onApply, onCancel, onReset, headerLabel, rangeFieldOptions, selectedRangeField, onRangeFieldChange, timezoneLabel, enableTimeSelection, timeOptions, startTime, endTime, onTimeChange, showFieldDropdown, size, buttonClassName, iconClassName, ...props }: DateRangePickerProps) => import("react/jsx-runtime").JSX.Element;
44
+ //# sourceMappingURL=date-range-picker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-range-picker.d.ts","sourceRoot":"","sources":["../../../src/applications/date-picker/date-range-picker.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,IAAI,wBAAwB,EAChD,SAAS,EACV,MAAM,uBAAuB,CAAC;AA0C/B,MAAM,WAAW,oBAAqB,SAAQ,wBAAwB,CAAC,SAAS,CAAC;IAC/E,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6CAA6C;IAC7C,iBAAiB,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5D,+DAA+D;IAC/D,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oDAAoD;IACpD,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,yCAAyC;IACzC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kDAAkD;IAClD,WAAW,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACnE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,eAAe,GAAI,wSAyB7B,oBAAoB,4CAqatB,CAAC"}
@@ -0,0 +1,335 @@
1
+ import { jsxs as o, jsx as a } from "react/jsx-runtime";
2
+ import { useState as y, useRef as mt, useEffect as E, useMemo as U } from "react";
3
+ import { today as nt, getLocalTimeZone as w } from "@internationalized/date";
4
+ import { Calendar as ft } from "@untitledui/icons";
5
+ import { useDateFormatter as pt } from "react-aria";
6
+ import { useLocale as xt, DateRangePicker as ut, Group as yt, Popover as bt, Dialog as Nt } from "react-aria-components";
7
+ import { Select as b } from "../../primitives/select/select.js";
8
+ import { cx as I } from "../../utils/cn.js";
9
+ import { getDateRangePresets as St, PRESET_LABELS as B, detectDateRangePresetKey as ht, getDateRangeFromPresetKey as X } from "./date-range-presets.js";
10
+ import { DateInput as A } from "./date-input.js";
11
+ import { RangeCalendar as vt } from "./range-calendar.js";
12
+ import { RangePresetButton as Dt } from "./range-preset.js";
13
+ import { Button as L } from "../../primitives/button/button.js";
14
+ function N(d) {
15
+ if (!d || typeof d.year != "number")
16
+ return !1;
17
+ const _ = d, { year: l, month: p, day: i } = _;
18
+ return l >= 1e3 && l <= 9999 && p >= 1 && p <= 12 && i >= 1 && i <= 31;
19
+ }
20
+ const Mt = ({
21
+ value: d,
22
+ defaultValue: _,
23
+ onChange: l,
24
+ onApply: p,
25
+ onCancel: i,
26
+ onReset: M,
27
+ headerLabel: V = "Selected date range for",
28
+ rangeFieldOptions: O = [
29
+ { label: "Created date", value: "created_date" },
30
+ { label: "Proposed Effective date", value: "proposed_effective_date" }
31
+ ],
32
+ selectedRangeField: T,
33
+ onRangeFieldChange: j,
34
+ timezoneLabel: Pt = "(GMT-8:00) Pacific Time",
35
+ enableTimeSelection: G = !0,
36
+ timeOptions: D,
37
+ startTime: P,
38
+ endTime: g,
39
+ onTimeChange: c,
40
+ showFieldDropdown: C = !0,
41
+ size: tt = "xs",
42
+ buttonClassName: et,
43
+ iconClassName: rt,
44
+ ...st
45
+ }) => {
46
+ var H, J;
47
+ const { locale: S } = xt(), at = [nt(w())], W = pt({
48
+ month: "2-digit",
49
+ day: "2-digit",
50
+ year: "numeric"
51
+ }), [r, x] = y(d ?? _ ?? null), [lt, h] = y(null), [Y, u] = y("Select date"), k = mt(!1), [K, ot] = y(!1);
52
+ E(() => {
53
+ d !== void 0 && x(d);
54
+ }, [d]);
55
+ const q = U(
56
+ () => (O || []).map((e) => ({
57
+ id: e.value,
58
+ label: e.label
59
+ })),
60
+ [O]
61
+ ), m = U(() => {
62
+ if (D && D.length > 0)
63
+ return D.map((t) => ({ id: t.value, label: t.label }));
64
+ const e = [];
65
+ for (let t = 0; t < 24; t++)
66
+ for (let s of [0, 30]) {
67
+ const n = (t + 11) % 12 + 1, v = t < 12 ? "am" : "pm", f = `${n}:${s === 0 ? "00" : "30"} ${v}`;
68
+ e.push({ id: f, label: f });
69
+ }
70
+ return e.push({ id: "11:59 pm", label: "11:59 pm" }), e;
71
+ }, [D]), [Z, R] = y(
72
+ P ?? ((H = m == null ? void 0 : m[0]) == null ? void 0 : H.id) ?? "12:00 am"
73
+ ), [F, $] = y(
74
+ g ?? ((J = m == null ? void 0 : m[0]) == null ? void 0 : J.id) ?? "12:00 am"
75
+ );
76
+ E(() => {
77
+ P !== void 0 && R(P);
78
+ }, [P]), E(() => {
79
+ g !== void 0 && $(g);
80
+ }, [g]);
81
+ const it = (e, t) => {
82
+ R(e), $(t), c == null || c({ startTime: e, endTime: t });
83
+ }, ct = r != null && r.start && N(r.start) ? W.format(r.start.toDate(w())) : "Select date", dt = r != null && r.end && N(r.end) ? W.format(r.end.toDate(w())) : "Select date", z = (() => {
84
+ const e = St(S);
85
+ return Object.fromEntries(
86
+ Object.entries(B).map(
87
+ ([t, s]) => [t, { label: s, value: e[t] }]
88
+ )
89
+ );
90
+ })();
91
+ return E(() => {
92
+ if (!(r != null && r.start) || !(r != null && r.end)) {
93
+ u("Select date");
94
+ return;
95
+ }
96
+ const e = ht(r, S);
97
+ u(e ? B[e] : "");
98
+ }, [r, S]), /* @__PURE__ */ o(
99
+ ut,
100
+ {
101
+ "aria-label": "Date range picker",
102
+ shouldCloseOnSelect: !1,
103
+ ...st,
104
+ value: r,
105
+ onOpenChange: (e) => {
106
+ if (ot(e), !e && !k.current && (i == null || i()), e) {
107
+ k.current = !1;
108
+ const t = r == null ? void 0 : r.preset;
109
+ if (t) {
110
+ const n = X(t, S);
111
+ x(n), l == null || l(n);
112
+ }
113
+ const s = t ? X(t, S).start : r == null ? void 0 : r.start;
114
+ s && h(s);
115
+ }
116
+ },
117
+ onChange: (e) => {
118
+ if (!(e != null && e.start) || !(e != null && e.end)) {
119
+ x(e), u(""), l == null || l(e);
120
+ return;
121
+ }
122
+ const { start: t, end: s } = e, n = !(r != null && r.start) || t.compare(r.start) !== 0, v = !(r != null && r.end) || s.compare(r.end) !== 0;
123
+ if (v && N(s) ? h(s) : n && N(t) && h(t), !N(t) || !N(s)) {
124
+ x(e), u(""), l == null || l(e);
125
+ return;
126
+ }
127
+ const Q = t.compare(s);
128
+ let f = { start: t, end: s };
129
+ Q > 0 && (n && !v ? f = { start: t, end: t } : v && !n ? f = { start: s, end: s } : f = { start: t, end: t }), x(f), u(""), l == null || l(f);
130
+ },
131
+ children: [
132
+ /* @__PURE__ */ a(yt, { "data-popover-open": K, children: /* @__PURE__ */ a(
133
+ L,
134
+ {
135
+ size: tt,
136
+ color: "secondary",
137
+ iconLeading: /* @__PURE__ */ a(ft, { className: I("size-4", rt) }),
138
+ className: I(
139
+ !K && et,
140
+ K && "shadow-[0_0_0_4px_rgba(102,112,133,0.14)]"
141
+ ),
142
+ children: Y || (r ? `${ct} – ${dt}` : /* @__PURE__ */ a("span", { className: "text-placeholder", children: "Select dates" }))
143
+ }
144
+ ) }),
145
+ /* @__PURE__ */ a(
146
+ bt,
147
+ {
148
+ placement: "bottom right",
149
+ offset: 8,
150
+ className: ({ isEntering: e, isExiting: t }) => I(
151
+ "origin-(--trigger-anchor-point) will-change-transform",
152
+ e && "duration-150 ease-out animate-in fade-in placement-right:slide-in-from-left-0.5 placement-top:slide-in-from-bottom-0.5 placement-bottom:slide-in-from-top-0.5",
153
+ t && "duration-100 ease-in animate-out fade-out placement-right:slide-out-to-left-0.5 placement-top:slide-out-to-bottom-0.5 placement-bottom:slide-out-to-top-0.5"
154
+ ),
155
+ style: { marginLeft: "80px" },
156
+ children: /* @__PURE__ */ a(Nt, { className: "flex w-full rounded-2xl bg-primary ring ring-secondary focus:outline-hidden max-h-[60vh] overflow-y-auto", children: ({ close: e }) => /* @__PURE__ */ o("div", { className: "flex w-full flex-col", children: [
157
+ C && /* @__PURE__ */ a("div", { className: "flex items-center justify-between px-4 py-3 border-b border-secondary", children: /* @__PURE__ */ o("div", { className: "flex items-center gap-3", children: [
158
+ /* @__PURE__ */ a("span", { className: "text-sm text-text-secondary", children: V }),
159
+ q.length > 0 && /* @__PURE__ */ a(
160
+ b,
161
+ {
162
+ size: "sm",
163
+ className: "w-64",
164
+ selectedKey: T,
165
+ onSelectionChange: (t) => j == null ? void 0 : j(String(t)),
166
+ items: q,
167
+ textStyles: "text-primary text-sm font-normal",
168
+ children: (t) => /* @__PURE__ */ a(
169
+ b.Item,
170
+ {
171
+ textStyles: "text-primary text-sm",
172
+ id: t.id,
173
+ children: t.label
174
+ }
175
+ )
176
+ }
177
+ )
178
+ ] }) }),
179
+ /* @__PURE__ */ o("div", { className: "flex", children: [
180
+ /* @__PURE__ */ a("div", { className: "hidden w-38 flex-col gap-0.5 border-r border-solid border-secondary p-3 lg:flex", children: Object.keys(B).map(
181
+ (t) => {
182
+ const s = z[t];
183
+ return /* @__PURE__ */ a(
184
+ Dt,
185
+ {
186
+ value: s.value,
187
+ onClick: () => {
188
+ x(s.value), l == null || l(s.value), u(s.label), h(s.value.start), t === "today" && it("12:00 am", "11:59 pm");
189
+ },
190
+ children: s.label
191
+ },
192
+ t
193
+ );
194
+ }
195
+ ) }),
196
+ /* @__PURE__ */ o("div", { className: "flex flex-col", children: [
197
+ /* @__PURE__ */ a(
198
+ vt,
199
+ {
200
+ focusedValue: lt,
201
+ onFocusChange: h,
202
+ highlightedDates: at,
203
+ presets: {
204
+ lastWeek: z.lastWeek,
205
+ lastMonth: z.lastMonth,
206
+ lastYear: z.lastYear
207
+ },
208
+ containerClassName: "justify-around"
209
+ }
210
+ ),
211
+ /* @__PURE__ */ o("div", { className: "flex justify-between gap-3 border-t border-secondary p-2", children: [
212
+ /* @__PURE__ */ o("div", { className: "hidden items-center gap-3 md:flex", children: [
213
+ /* @__PURE__ */ o("div", { className: "flex items-center gap-3", children: [
214
+ /* @__PURE__ */ a(
215
+ A,
216
+ {
217
+ slot: "start",
218
+ className: "min-w-[117px] text-sm"
219
+ }
220
+ ),
221
+ G && /* @__PURE__ */ a(
222
+ b,
223
+ {
224
+ size: "sm",
225
+ className: "w-[115px]",
226
+ popoverClassName: "w-auto min-w-max",
227
+ selectedKey: Z || void 0,
228
+ onSelectionChange: (t) => {
229
+ const s = String(t);
230
+ R(s), c == null || c({
231
+ startTime: s,
232
+ endTime: F || ""
233
+ });
234
+ },
235
+ items: m,
236
+ textStyles: "text-primary py-0.5 text-sm font-body font-normal",
237
+ children: (t) => /* @__PURE__ */ a(
238
+ b.Item,
239
+ {
240
+ textStyles: "text-primary text-sm font-body font-normal",
241
+ id: t.id,
242
+ children: t.label
243
+ }
244
+ )
245
+ }
246
+ )
247
+ ] }),
248
+ /* @__PURE__ */ a("div", { className: "text-md text-quaternary", children: "–" }),
249
+ /* @__PURE__ */ o("div", { className: "flex items-center gap-3", children: [
250
+ /* @__PURE__ */ a(
251
+ A,
252
+ {
253
+ slot: "end",
254
+ className: "min-w-[117px] text-sm"
255
+ }
256
+ ),
257
+ G && /* @__PURE__ */ a(
258
+ b,
259
+ {
260
+ size: "sm",
261
+ className: "w-[115px]",
262
+ popoverClassName: "w-auto min-w-max",
263
+ selectedKey: F || void 0,
264
+ onSelectionChange: (t) => {
265
+ const s = String(t);
266
+ $(s), c == null || c({
267
+ startTime: Z || "",
268
+ endTime: s
269
+ });
270
+ },
271
+ items: m,
272
+ textStyles: "text-primary py-0.5 text-sm font-body font-normal",
273
+ children: (t) => /* @__PURE__ */ a(
274
+ b.Item,
275
+ {
276
+ id: t.id,
277
+ textStyles: "text-primary text-sm font-body font-normal",
278
+ children: t.label
279
+ }
280
+ )
281
+ }
282
+ )
283
+ ] })
284
+ ] }),
285
+ /* @__PURE__ */ o("div", { className: "grid w-full grid-cols-2 gap-3 md:flex md:w-auto", children: [
286
+ M && /* @__PURE__ */ a(
287
+ L,
288
+ {
289
+ size: "xs",
290
+ color: "secondary",
291
+ className: "p-2",
292
+ onClick: () => {
293
+ k.current = !0, M(), e();
294
+ },
295
+ children: "Reset"
296
+ }
297
+ ),
298
+ /* @__PURE__ */ a(
299
+ L,
300
+ {
301
+ size: "xs",
302
+ color: "secondary",
303
+ className: "p-2",
304
+ onClick: () => {
305
+ i == null || i(), e();
306
+ },
307
+ children: "Cancel"
308
+ }
309
+ ),
310
+ /* @__PURE__ */ a(
311
+ L,
312
+ {
313
+ size: "xs",
314
+ color: "primary",
315
+ className: "p-2",
316
+ onClick: () => {
317
+ k.current = !0, p == null || p(), e();
318
+ },
319
+ children: "Apply"
320
+ }
321
+ )
322
+ ] })
323
+ ] })
324
+ ] })
325
+ ] })
326
+ ] }) })
327
+ }
328
+ )
329
+ ]
330
+ }
331
+ );
332
+ };
333
+ export {
334
+ Mt as DateRangePicker
335
+ };
@@ -0,0 +1,50 @@
1
+ import { CalendarDate } from '@internationalized/date';
2
+ export declare const PRESET_LABELS: {
3
+ readonly today: "Today";
4
+ readonly yesterday: "Yesterday";
5
+ readonly thisWeek: "This week";
6
+ readonly lastWeek: "Last week";
7
+ readonly last30Days: "Last 30 days";
8
+ readonly last90Days: "Last 90 days";
9
+ readonly thisMonth: "This month";
10
+ readonly lastMonth: "Last month";
11
+ readonly thisYear: "This year";
12
+ readonly lastYear: "Last year";
13
+ };
14
+ export type DateRangePresetKey = keyof typeof PRESET_LABELS;
15
+ type DatePart = {
16
+ year: number;
17
+ month: number;
18
+ day: number;
19
+ };
20
+ export type DateRangeLike = {
21
+ start: DatePart | CalendarDate | null;
22
+ end: DatePart | CalendarDate | null;
23
+ /**
24
+ * Preserves the semantic preset independently of its resolved dates.
25
+ * This is important for rolling presets (for example Last 30 days) when
26
+ * the local calendar day changes while the application remains open.
27
+ */
28
+ preset?: DateRangePresetKey;
29
+ };
30
+ export type PresetDateRange = {
31
+ start: CalendarDate;
32
+ end: CalendarDate;
33
+ preset: DateRangePresetKey;
34
+ };
35
+ /**
36
+ * Preset date ranges resolved from the current date — shared by DateRangePicker and filter retention.
37
+ *
38
+ * @param weekStartLocale - Locale passed to `startOfWeek` / `endOfWeek` only (e.g. US vs ISO week start).
39
+ * Preset labels are not localized.
40
+ */
41
+ export declare const getDateRangePresets: (weekStartLocale?: string) => Record<DateRangePresetKey, PresetDateRange>;
42
+ export declare const getDateRangeFromPresetKey: (key: DateRangePresetKey, weekStartLocale?: string) => PresetDateRange;
43
+ /** Resolve a semantic preset to its dates for the current local calendar day. */
44
+ export declare const resolveDateRangePreset: (range: DateRangeLike, weekStartLocale?: string) => DateRangeLike | PresetDateRange;
45
+ /** Returns the preset key when the range matches a known preset, otherwise null. */
46
+ export declare const detectDateRangePresetKey: (range: DateRangeLike | null | undefined, weekStartLocale?: string) => DateRangePresetKey | null;
47
+ /** Clone a range without discarding its semantic preset marker. */
48
+ export declare const cloneDateRange: <T extends DateRangeLike>(range: T) => T;
49
+ export {};
50
+ //# sourceMappingURL=date-range-presets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-range-presets.d.ts","sourceRoot":"","sources":["../../../src/applications/date-picker/date-range-presets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAOb,MAAM,yBAAyB,CAAC;AAEjC,eAAO,MAAM,aAAa;;;;;;;;;;;CAWhB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,aAAa,CAAC;AAE5D,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,QAAQ,GAAG,YAAY,GAAG,IAAI,CAAC;IACtC,GAAG,EAAE,QAAQ,GAAG,YAAY,GAAG,IAAI,CAAC;IACpC;;;;OAIG;IACH,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,YAAY,CAAC;IACpB,GAAG,EAAE,YAAY,CAAC;IAClB,MAAM,EAAE,kBAAkB,CAAC;CAC5B,CAAC;AAWF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,wBAAyB,KACxB,MAAM,CAAC,kBAAkB,EAAE,eAAe,CAoD5C,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,KAAK,kBAAkB,EACvB,wBAAyB,KACxB,eAEF,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,sBAAsB,GACjC,OAAO,aAAa,EACpB,wBAAyB,KACxB,aAAa,GAAG,eAIlB,CAAC;AAEF,oFAAoF;AACpF,eAAO,MAAM,wBAAwB,GACnC,OAAO,aAAa,GAAG,IAAI,GAAG,SAAS,EACvC,wBAAyB,KACxB,kBAAkB,GAAG,IAqBvB,CAAC;AAEF,mEAAmE;AACnE,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,aAAa,EAAE,OAAO,CAAC,KAAG,CAEjE,CAAC"}