@datum-cloud/datum-ui 0.2.1 → 0.3.0-alpha.1a6419a
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/autocomplete/index.mjs +2 -2
- package/dist/{autocomplete-DZtI97HP.mjs → autocomplete-B9bCkXtz.mjs} +2 -2
- package/dist/avatar-stack/index.mjs +2 -2
- package/dist/{avatar-stack-JCfBlPB9.mjs → avatar-stack-Bh-tLz0X.mjs} +1 -1
- package/dist/calendar-date-picker-mlbzp3xR.mjs +665 -0
- package/dist/components/features/calendar-date-picker/calendar-date-picker.d.ts +2 -1
- package/dist/components/features/calendar-date-picker/calendar-date-picker.d.ts.map +1 -1
- package/dist/components/features/data-table/adapters/nuqs-adapter.d.ts +46 -0
- package/dist/components/features/data-table/adapters/nuqs-adapter.d.ts.map +1 -0
- package/dist/components/features/data-table/columns/selection-column.d.ts +6 -0
- package/dist/components/features/data-table/columns/selection-column.d.ts.map +1 -0
- package/dist/components/features/data-table/components/active-filters.d.ts +5 -0
- package/dist/components/features/data-table/components/active-filters.d.ts.map +1 -0
- package/dist/components/features/data-table/components/bulk-actions.d.ts +3 -0
- package/dist/components/features/data-table/components/bulk-actions.d.ts.map +1 -0
- package/dist/components/features/data-table/components/column-header.d.ts +3 -0
- package/dist/components/features/data-table/components/column-header.d.ts.map +1 -0
- package/dist/components/features/data-table/components/content.d.ts +3 -0
- package/dist/components/features/data-table/components/content.d.ts.map +1 -0
- package/dist/components/features/data-table/components/inline-content.d.ts +3 -0
- package/dist/components/features/data-table/components/inline-content.d.ts.map +1 -0
- package/dist/components/features/data-table/components/loading.d.ts +3 -0
- package/dist/components/features/data-table/components/loading.d.ts.map +1 -0
- package/dist/components/features/data-table/components/pagination.d.ts +3 -0
- package/dist/components/features/data-table/components/pagination.d.ts.map +1 -0
- package/dist/components/features/data-table/components/row-actions.d.ts +3 -0
- package/dist/components/features/data-table/components/row-actions.d.ts.map +1 -0
- package/dist/components/features/data-table/components/search.d.ts +3 -0
- package/dist/components/features/data-table/components/search.d.ts.map +1 -0
- package/dist/components/features/data-table/constants.d.ts +5 -0
- package/dist/components/features/data-table/constants.d.ts.map +1 -0
- package/dist/components/features/data-table/core/client-provider.d.ts +11 -0
- package/dist/components/features/data-table/core/client-provider.d.ts.map +1 -0
- package/dist/components/features/data-table/core/data-table-context.d.ts +10 -0
- package/dist/components/features/data-table/core/data-table-context.d.ts.map +1 -0
- package/dist/components/features/data-table/core/filter-engine.d.ts +16 -0
- package/dist/components/features/data-table/core/filter-engine.d.ts.map +1 -0
- package/dist/components/features/data-table/core/server-provider.d.ts +11 -0
- package/dist/components/features/data-table/core/server-provider.d.ts.map +1 -0
- package/dist/components/features/data-table/core/store.d.ts +3 -0
- package/dist/components/features/data-table/core/store.d.ts.map +1 -0
- package/dist/components/features/data-table/data-table.d.ts +30 -0
- package/dist/components/features/data-table/data-table.d.ts.map +1 -0
- package/dist/components/features/data-table/filters/checkbox-filter.d.ts +3 -0
- package/dist/components/features/data-table/filters/checkbox-filter.d.ts.map +1 -0
- package/dist/components/features/data-table/filters/date-picker-filter.d.ts +3 -0
- package/dist/components/features/data-table/filters/date-picker-filter.d.ts.map +1 -0
- package/dist/components/features/data-table/filters/select-filter.d.ts +3 -0
- package/dist/components/features/data-table/filters/select-filter.d.ts.map +1 -0
- package/dist/components/features/data-table/hooks/index.d.ts +4 -0
- package/dist/components/features/data-table/hooks/index.d.ts.map +1 -0
- package/dist/components/features/data-table/hooks/use-data-table-client.d.ts +20 -0
- package/dist/components/features/data-table/hooks/use-data-table-client.d.ts.map +1 -0
- package/dist/components/features/data-table/hooks/use-data-table-context.d.ts +2 -0
- package/dist/components/features/data-table/hooks/use-data-table-context.d.ts.map +1 -0
- package/dist/components/features/data-table/hooks/use-data-table-server.d.ts +30 -0
- package/dist/components/features/data-table/hooks/use-data-table-server.d.ts.map +1 -0
- package/dist/components/features/data-table/hooks/use-selectors.d.ts +81 -0
- package/dist/components/features/data-table/hooks/use-selectors.d.ts.map +1 -0
- package/dist/components/features/data-table/index.d.ts +11 -0
- package/dist/components/features/data-table/index.d.ts.map +1 -0
- package/dist/components/features/data-table/types.d.ts +324 -0
- package/dist/components/features/data-table/types.d.ts.map +1 -0
- package/dist/data-table/index.mjs +1629 -0
- package/dist/date-picker/index.mjs +4 -3
- package/dist/dropdown/index.mjs +1 -1
- package/dist/dropdown-menu-DAFyO-qD.mjs +87 -0
- package/dist/dropzone/index.mjs +1 -1
- package/dist/empty-content/index.mjs +1 -1
- package/dist/form/index.mjs +6 -6
- package/dist/grid/index.mjs +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/index.mjs +38 -36
- package/dist/input-number/index.mjs +1 -1
- package/dist/input-with-addons/index.mjs +1 -1
- package/dist/loader-overlay/index.mjs +1 -1
- package/dist/map/index.mjs +3 -2
- package/dist/{map-WL6jhkSM.mjs → map-ClJD-qxm.mjs} +4 -84
- package/dist/more-actions/index.mjs +2 -2
- package/dist/{more-actions-Ch1f6Mh3.mjs → more-actions-DbC8dyed.mjs} +2 -2
- package/dist/page-title/index.mjs +1 -1
- package/dist/popover/index.mjs +1 -1
- package/dist/radio-group/index.mjs +1 -1
- package/dist/select/index.mjs +1 -1
- package/dist/sheet/index.mjs +2 -2
- package/dist/{sheet-BKiCwtNO.mjs → sheet-mx5XjyEY.mjs} +1 -1
- package/dist/sidebar/index.mjs +4 -4
- package/dist/{sidebar-DfqezV8t.mjs → sidebar-C4NqSr4r.mjs} +3 -3
- package/dist/skeleton/index.mjs +1 -1
- package/dist/spinner/index.mjs +1 -1
- package/dist/stepper/index.mjs +1 -1
- package/dist/switch/index.mjs +1 -1
- package/dist/table/index.mjs +1 -1
- package/dist/tabs/index.mjs +1 -1
- package/dist/tag-input/index.mjs +1 -1
- package/dist/task-queue/index.mjs +3 -3
- package/dist/{task-queue-dropdown-DW72ikDH.mjs → task-queue-dropdown-fo3TX58Q.mjs} +3 -3
- package/dist/textarea/index.mjs +1 -1
- package/dist/theme/index.mjs +1 -1
- package/dist/{to-api-format-C2xjQUcI.mjs → to-api-format-zI26rEBI.mjs} +6 -661
- package/dist/toast/index.mjs +1 -1
- package/dist/tooltip/index.mjs +1 -1
- package/dist/typography/index.mjs +1 -1
- package/dist/{use-copy-to-clipboard-ki-WoTml.mjs → use-copy-to-clipboard-C7xqNxBX.mjs} +1 -1
- package/dist/{use-stepper-BaToCYMs.mjs → use-stepper-CB1injte.mjs} +10 -10
- package/dist/visually-hidden/index.mjs +1 -1
- package/package.json +15 -1
- /package/dist/{col-lrLMZaTJ.mjs → col-RfO7d6AR.mjs} +0 -0
- /package/dist/{dropdown-DtSa_lqc.mjs → dropdown-Cs7Xr8w7.mjs} +0 -0
- /package/dist/{dropzone-BkOnwrS4.mjs → dropzone-BT5fEDEF.mjs} +0 -0
- /package/dist/{empty-content-BM9rzI13.mjs → empty-content-iDu3NUqG.mjs} +0 -0
- /package/dist/{input-number-9o62JHRl.mjs → input-number-D9ydFith.mjs} +0 -0
- /package/dist/{input-with-addons-BQn7KCTU.mjs → input-with-addons-CdgiUQce.mjs} +0 -0
- /package/dist/{loader-overlay-DUaQSZQP.mjs → loader-overlay-D83QeQNj.mjs} +0 -0
- /package/dist/{map-leaflet-imports-C4JYls8q.mjs → map-leaflet-imports-CdzvEnzY.mjs} +0 -0
- /package/dist/{page-title-BJuo81rT.mjs → page-title-SGchAF6Y.mjs} +0 -0
- /package/dist/{popover-SQlKSz6L.mjs → popover-Ds9624qY.mjs} +0 -0
- /package/dist/{radio-group-Oshv0b-U.mjs → radio-group-B9Hm77LQ.mjs} +0 -0
- /package/dist/{select-DVlEzD2W.mjs → select-CwVIFWFO.mjs} +0 -0
- /package/dist/{sheet-CtnP6gTD.mjs → sheet-Cemwh78x.mjs} +0 -0
- /package/dist/{skeleton-vzbxA-DQ.mjs → skeleton-Cs6Q5GQc.mjs} +0 -0
- /package/dist/{spinner-BE7k2bAD.mjs → spinner-earfjpJs.mjs} +0 -0
- /package/dist/{stepper-SWB-u_nM.mjs → stepper-BG9DIzN5.mjs} +0 -0
- /package/dist/{switch-Calk7Gyw.mjs → switch-B2VVauH6.mjs} +0 -0
- /package/dist/{table-CsXBcQLI.mjs → table-Dc3HfbM4.mjs} +0 -0
- /package/dist/{tabs-D8n-dqnw.mjs → tabs-Ccb4uqbe.mjs} +0 -0
- /package/dist/{tag-input-Di7SDNbK.mjs → tag-input-BfHaKoMF.mjs} +0 -0
- /package/dist/{textarea-CxE3YbC7.mjs → textarea-X4OjkqLJ.mjs} +0 -0
- /package/dist/{theme.provider-CzCxEFFh.mjs → theme.provider-Nun_O9-O.mjs} +0 -0
- /package/dist/{tooltip-Dd3ActSS.mjs → tooltip-DZFG1iMs.mjs} +0 -0
- /package/dist/{typography-UA7ZZvgJ.mjs → typography-T7WgvO77.mjs} +0 -0
- /package/dist/{use-debounce-B6wPrZV8.mjs → use-debounce-Ctljs3MB.mjs} +0 -0
- /package/dist/{use-toast-mdn_CqRY.mjs → use-toast-DN-fZBzJ.mjs} +0 -0
- /package/dist/{visuallyhidden-aaTUk4Yo.mjs → visuallyhidden-CgkVhApW.mjs} +0 -0
|
@@ -1,672 +1,17 @@
|
|
|
1
1
|
import { t as cn } from "./cn-DWCc1QRE.mjs";
|
|
2
2
|
import { t as Button } from "./button-C1wRfGtT.mjs";
|
|
3
3
|
import { t as Separator } from "./separator-T2ppyD-8.mjs";
|
|
4
|
-
import { t as Button$1 } from "./button-AzpnV-WB.mjs";
|
|
5
4
|
import { t as Icon } from "./icon-wrapper-9ticVbRL.mjs";
|
|
6
5
|
import { t as Calendar$1 } from "./calendar-DlIHeWb0.mjs";
|
|
7
6
|
import { t as Input } from "./input-fzXBheCN.mjs";
|
|
8
|
-
import { i as PopoverTrigger, r as PopoverContent, t as Popover } from "./popover-
|
|
9
|
-
import { i as SelectItem, l as SelectTrigger, n as SelectContent, t as Select, u as SelectValue } from "./select-
|
|
10
|
-
import { cva } from "class-variance-authority";
|
|
7
|
+
import { i as PopoverTrigger, r as PopoverContent, t as Popover } from "./popover-Ds9624qY.mjs";
|
|
8
|
+
import { i as SelectItem, l as SelectTrigger, n as SelectContent, t as Select, u as SelectValue } from "./select-CwVIFWFO.mjs";
|
|
11
9
|
import { Calendar, CalendarIcon, Globe, X } from "lucide-react";
|
|
12
|
-
import * as React$1 from "react";
|
|
13
10
|
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { format, isSameDay, isSameYear, parse, subDays, subHours, subMinutes } from "date-fns";
|
|
13
|
+
import { fromZonedTime, toZonedTime } from "date-fns-tz";
|
|
17
14
|
|
|
18
|
-
//#region src/components/features/calendar-date-picker/calendar-date-picker.tsx
|
|
19
|
-
const months = [
|
|
20
|
-
"January",
|
|
21
|
-
"February",
|
|
22
|
-
"March",
|
|
23
|
-
"April",
|
|
24
|
-
"May",
|
|
25
|
-
"June",
|
|
26
|
-
"July",
|
|
27
|
-
"August",
|
|
28
|
-
"September",
|
|
29
|
-
"October",
|
|
30
|
-
"November",
|
|
31
|
-
"December"
|
|
32
|
-
];
|
|
33
|
-
const multiSelectVariants = cva("flex font-normal shadow-none items-center justify-center whitespace-nowrap rounded-md text-sm text-foreground ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", {
|
|
34
|
-
variants: { variant: {
|
|
35
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
36
|
-
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
37
|
-
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
38
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
39
|
-
ghost: "hover:bg-accent hover:text-accent-foreground text-background",
|
|
40
|
-
link: "text-primary underline-offset-4 hover:underline text-background"
|
|
41
|
-
} },
|
|
42
|
-
defaultVariants: { variant: "default" }
|
|
43
|
-
});
|
|
44
|
-
function CalendarDatePicker({ ref, id = "calendar-date-picker", className, triggerClassName, date, closeOnSelect = false, numberOfMonths = 2, yearsRange = 10, onDateSelect, variant, placeholder, excludePresets, customPresets, minDate, maxDate, disableFuture = false, disablePast = false, maxRange, ...props }) {
|
|
45
|
-
const [isPopoverOpen, setIsPopoverOpen] = React$1.useState(false);
|
|
46
|
-
const [selectedRange, setSelectedRange] = React$1.useState(numberOfMonths === 2 ? "This Year" : "Today");
|
|
47
|
-
const [monthFrom, setMonthFrom] = React$1.useState(date?.from);
|
|
48
|
-
const [yearFrom, setYearFrom] = React$1.useState(date?.from?.getFullYear());
|
|
49
|
-
const [monthTo, setMonthTo] = React$1.useState(numberOfMonths === 2 ? date?.to : date?.from);
|
|
50
|
-
const [yearTo, setYearTo] = React$1.useState(numberOfMonths === 2 ? date?.to?.getFullYear() : date?.from?.getFullYear());
|
|
51
|
-
const [highlightedPart, setHighlightedPart] = React$1.useState(null);
|
|
52
|
-
const [pendingDate, setPendingDate] = React$1.useState(date);
|
|
53
|
-
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
54
|
-
const today = /* @__PURE__ */ new Date();
|
|
55
|
-
const effectiveMinDate = React$1.useMemo(() => {
|
|
56
|
-
let min = minDate;
|
|
57
|
-
if (disablePast) {
|
|
58
|
-
const todayStart = startOfDay(today);
|
|
59
|
-
min = min ? min > todayStart ? min : todayStart : todayStart;
|
|
60
|
-
}
|
|
61
|
-
return min;
|
|
62
|
-
}, [
|
|
63
|
-
minDate,
|
|
64
|
-
disablePast,
|
|
65
|
-
today
|
|
66
|
-
]);
|
|
67
|
-
const effectiveMaxDate = React$1.useMemo(() => {
|
|
68
|
-
let max = maxDate;
|
|
69
|
-
if (disableFuture) {
|
|
70
|
-
const todayEnd = endOfDay(today);
|
|
71
|
-
max = max ? max < todayEnd ? max : todayEnd : todayEnd;
|
|
72
|
-
}
|
|
73
|
-
return max;
|
|
74
|
-
}, [
|
|
75
|
-
maxDate,
|
|
76
|
-
disableFuture,
|
|
77
|
-
today
|
|
78
|
-
]);
|
|
79
|
-
const isDateDisabled = React$1.useCallback((date) => {
|
|
80
|
-
if (effectiveMinDate && date < effectiveMinDate) return true;
|
|
81
|
-
if (effectiveMaxDate && date > effectiveMaxDate) return true;
|
|
82
|
-
return false;
|
|
83
|
-
}, [effectiveMinDate, effectiveMaxDate]);
|
|
84
|
-
const getDaysDifference = React$1.useCallback((from, to) => {
|
|
85
|
-
const timeDiff = Math.abs(to.getTime() - from.getTime());
|
|
86
|
-
return Math.ceil(timeDiff / (1e3 * 60 * 60 * 24));
|
|
87
|
-
}, []);
|
|
88
|
-
const isRangeValid = React$1.useCallback((from, to) => {
|
|
89
|
-
if (!maxRange) return true;
|
|
90
|
-
if (numberOfMonths === 1) return true;
|
|
91
|
-
return getDaysDifference(from, to) <= maxRange;
|
|
92
|
-
}, [
|
|
93
|
-
maxRange,
|
|
94
|
-
numberOfMonths,
|
|
95
|
-
getDaysDifference
|
|
96
|
-
]);
|
|
97
|
-
const adjustRangeToMaxRange = React$1.useCallback((from, to) => {
|
|
98
|
-
if (!maxRange || numberOfMonths === 1) return {
|
|
99
|
-
from,
|
|
100
|
-
to
|
|
101
|
-
};
|
|
102
|
-
if (getDaysDifference(from, to) <= maxRange) return {
|
|
103
|
-
from,
|
|
104
|
-
to
|
|
105
|
-
};
|
|
106
|
-
const adjustedTo = new Date(from.getTime() + maxRange * 24 * 60 * 60 * 1e3);
|
|
107
|
-
if (effectiveMaxDate && adjustedTo > effectiveMaxDate) {
|
|
108
|
-
const adjustedFrom = /* @__PURE__ */ new Date(to.getTime() - maxRange * 24 * 60 * 60 * 1e3);
|
|
109
|
-
if (effectiveMinDate && adjustedFrom < effectiveMinDate) return {
|
|
110
|
-
from,
|
|
111
|
-
to
|
|
112
|
-
};
|
|
113
|
-
return {
|
|
114
|
-
from: adjustedFrom,
|
|
115
|
-
to
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
return {
|
|
119
|
-
from,
|
|
120
|
-
to: adjustedTo
|
|
121
|
-
};
|
|
122
|
-
}, [
|
|
123
|
-
maxRange,
|
|
124
|
-
numberOfMonths,
|
|
125
|
-
getDaysDifference,
|
|
126
|
-
effectiveMinDate,
|
|
127
|
-
effectiveMaxDate
|
|
128
|
-
]);
|
|
129
|
-
React$1.useEffect(() => {
|
|
130
|
-
setPendingDate(date);
|
|
131
|
-
}, [date]);
|
|
132
|
-
const handleClose = () => setIsPopoverOpen(false);
|
|
133
|
-
const handleTogglePopover = () => setIsPopoverOpen((prev) => !prev);
|
|
134
|
-
const handleClear = (e) => {
|
|
135
|
-
e.stopPropagation();
|
|
136
|
-
onDateSelect(void 0);
|
|
137
|
-
setPendingDate({
|
|
138
|
-
from: void 0,
|
|
139
|
-
to: void 0
|
|
140
|
-
});
|
|
141
|
-
setSelectedRange(null);
|
|
142
|
-
};
|
|
143
|
-
const handleApply = () => {
|
|
144
|
-
if (pendingDate?.from) onDateSelect({
|
|
145
|
-
from: pendingDate.from,
|
|
146
|
-
to: pendingDate.to || pendingDate.from
|
|
147
|
-
});
|
|
148
|
-
setIsPopoverOpen(false);
|
|
149
|
-
};
|
|
150
|
-
const handleReset = () => {
|
|
151
|
-
setPendingDate(date);
|
|
152
|
-
setMonthFrom(date?.from);
|
|
153
|
-
setYearFrom(date?.from?.getFullYear());
|
|
154
|
-
setMonthTo(numberOfMonths === 2 ? date?.to : date?.from);
|
|
155
|
-
setYearTo(numberOfMonths === 2 ? date?.to?.getFullYear() : date?.from?.getFullYear());
|
|
156
|
-
setSelectedRange(null);
|
|
157
|
-
};
|
|
158
|
-
const selectDateRange = (from, to, range) => {
|
|
159
|
-
const startDate = startOfDay(toDate(from, { timeZone }));
|
|
160
|
-
const endDate = numberOfMonths === 2 ? endOfDay(toDate(to, { timeZone })) : startDate;
|
|
161
|
-
if (isDateDisabled(startDate) || isDateDisabled(endDate)) return;
|
|
162
|
-
let finalDates = {
|
|
163
|
-
from: startDate,
|
|
164
|
-
to: endDate
|
|
165
|
-
};
|
|
166
|
-
if (numberOfMonths === 2 && !isRangeValid(startDate, endDate)) {
|
|
167
|
-
finalDates = adjustRangeToMaxRange(startDate, endDate);
|
|
168
|
-
if (!isRangeValid(finalDates.from, finalDates.to)) return;
|
|
169
|
-
}
|
|
170
|
-
setPendingDate({
|
|
171
|
-
from: finalDates.from,
|
|
172
|
-
to: finalDates.to
|
|
173
|
-
});
|
|
174
|
-
setSelectedRange(range);
|
|
175
|
-
setMonthFrom(finalDates.from);
|
|
176
|
-
setYearFrom(finalDates.from.getFullYear());
|
|
177
|
-
setMonthTo(finalDates.to);
|
|
178
|
-
setYearTo(finalDates.to.getFullYear());
|
|
179
|
-
if (closeOnSelect) {
|
|
180
|
-
onDateSelect({
|
|
181
|
-
from: finalDates.from,
|
|
182
|
-
to: finalDates.to
|
|
183
|
-
});
|
|
184
|
-
setIsPopoverOpen(false);
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
const handleDateSelect = (range) => {
|
|
188
|
-
if (range) {
|
|
189
|
-
let from = startOfDay(toDate(range.from, { timeZone }));
|
|
190
|
-
let to = range.to ? endOfDay(toDate(range.to, { timeZone })) : from;
|
|
191
|
-
if (numberOfMonths === 1) if (range.from !== pendingDate?.from) to = from;
|
|
192
|
-
else from = startOfDay(toDate(range.to, { timeZone }));
|
|
193
|
-
if (isDateDisabled(from) || isDateDisabled(to)) return;
|
|
194
|
-
let finalDates = {
|
|
195
|
-
from,
|
|
196
|
-
to
|
|
197
|
-
};
|
|
198
|
-
if (numberOfMonths === 2 && !isRangeValid(from, to)) {
|
|
199
|
-
finalDates = adjustRangeToMaxRange(from, to);
|
|
200
|
-
if (!isRangeValid(finalDates.from, finalDates.to)) return;
|
|
201
|
-
}
|
|
202
|
-
setPendingDate({
|
|
203
|
-
from: finalDates.from,
|
|
204
|
-
to: finalDates.to
|
|
205
|
-
});
|
|
206
|
-
setMonthFrom(finalDates.from);
|
|
207
|
-
setYearFrom(finalDates.from.getFullYear());
|
|
208
|
-
setMonthTo(finalDates.to);
|
|
209
|
-
setYearTo(finalDates.to.getFullYear());
|
|
210
|
-
if (closeOnSelect) {
|
|
211
|
-
onDateSelect({
|
|
212
|
-
from: finalDates.from,
|
|
213
|
-
to: finalDates.to
|
|
214
|
-
});
|
|
215
|
-
setIsPopoverOpen(false);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
setSelectedRange(null);
|
|
219
|
-
};
|
|
220
|
-
const handleMonthChange = (newMonthIndex, part) => {
|
|
221
|
-
setSelectedRange(null);
|
|
222
|
-
if (part === "from") {
|
|
223
|
-
if (yearFrom !== void 0) {
|
|
224
|
-
if (newMonthIndex < 0 || newMonthIndex > yearsRange + 1) return;
|
|
225
|
-
const newMonth = new Date(yearFrom, newMonthIndex, 1);
|
|
226
|
-
const from = numberOfMonths === 2 ? startOfMonth(toDate(newMonth, { timeZone })) : pendingDate?.from ? new Date(pendingDate.from.getFullYear(), newMonth.getMonth(), pendingDate.from.getDate()) : newMonth;
|
|
227
|
-
const to = numberOfMonths === 2 ? pendingDate?.to ? endOfDay(toDate(pendingDate.to, { timeZone })) : endOfMonth(toDate(newMonth, { timeZone })) : from;
|
|
228
|
-
if (from <= to) {
|
|
229
|
-
setPendingDate({
|
|
230
|
-
from,
|
|
231
|
-
to
|
|
232
|
-
});
|
|
233
|
-
setMonthFrom(newMonth);
|
|
234
|
-
setMonthTo(pendingDate?.to);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
} else if (yearTo !== void 0) {
|
|
238
|
-
if (newMonthIndex < 0 || newMonthIndex > yearsRange + 1) return;
|
|
239
|
-
const newMonth = new Date(yearTo, newMonthIndex, 1);
|
|
240
|
-
const from = pendingDate?.from ? startOfDay(toDate(pendingDate.from, { timeZone })) : startOfMonth(toDate(newMonth, { timeZone }));
|
|
241
|
-
const to = numberOfMonths === 2 ? endOfMonth(toDate(newMonth, { timeZone })) : from;
|
|
242
|
-
if (from <= to) {
|
|
243
|
-
setPendingDate({
|
|
244
|
-
from,
|
|
245
|
-
to
|
|
246
|
-
});
|
|
247
|
-
setMonthTo(newMonth);
|
|
248
|
-
setMonthFrom(pendingDate?.from);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
const years = Array.from({ length: yearsRange + 1 }, (_, i) => today.getFullYear() - yearsRange / 2 + i);
|
|
253
|
-
const handleYearChange = (newYear, part) => {
|
|
254
|
-
setSelectedRange(null);
|
|
255
|
-
if (part === "from") {
|
|
256
|
-
if (years.includes(newYear)) {
|
|
257
|
-
const newMonth = monthFrom ? new Date(newYear, monthFrom ? monthFrom.getMonth() : 0, 1) : new Date(newYear, 0, 1);
|
|
258
|
-
const from = numberOfMonths === 2 ? startOfMonth(toDate(newMonth, { timeZone })) : pendingDate?.from ? new Date(newYear, newMonth.getMonth(), pendingDate.from.getDate()) : newMonth;
|
|
259
|
-
const to = numberOfMonths === 2 ? pendingDate?.to ? endOfDay(toDate(pendingDate.to, { timeZone })) : endOfMonth(toDate(newMonth, { timeZone })) : from;
|
|
260
|
-
if (from <= to) {
|
|
261
|
-
setPendingDate({
|
|
262
|
-
from,
|
|
263
|
-
to
|
|
264
|
-
});
|
|
265
|
-
setYearFrom(newYear);
|
|
266
|
-
setMonthFrom(newMonth);
|
|
267
|
-
setYearTo(pendingDate?.to?.getFullYear());
|
|
268
|
-
setMonthTo(pendingDate?.to);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
} else if (years.includes(newYear)) {
|
|
272
|
-
const newMonth = monthTo ? new Date(newYear, monthTo.getMonth(), 1) : new Date(newYear, 0, 1);
|
|
273
|
-
const from = pendingDate?.from ? startOfDay(toDate(pendingDate.from, { timeZone })) : startOfMonth(toDate(newMonth, { timeZone }));
|
|
274
|
-
const to = numberOfMonths === 2 ? endOfMonth(toDate(newMonth, { timeZone })) : from;
|
|
275
|
-
if (from <= to) {
|
|
276
|
-
setPendingDate({
|
|
277
|
-
from,
|
|
278
|
-
to
|
|
279
|
-
});
|
|
280
|
-
setYearTo(newYear);
|
|
281
|
-
setMonthTo(newMonth);
|
|
282
|
-
setYearFrom(pendingDate?.from?.getFullYear());
|
|
283
|
-
setMonthFrom(pendingDate?.from);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
const defaultDateRangePresets = [
|
|
288
|
-
{
|
|
289
|
-
key: "today",
|
|
290
|
-
label: "Today",
|
|
291
|
-
start: today,
|
|
292
|
-
end: today
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
key: "yesterday",
|
|
296
|
-
label: "Yesterday",
|
|
297
|
-
start: subDays(today, 1),
|
|
298
|
-
end: subDays(today, 1)
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
key: "thisWeek",
|
|
302
|
-
label: "This Week",
|
|
303
|
-
start: startOfWeek(today, { weekStartsOn: 1 }),
|
|
304
|
-
end: endOfWeek(today, { weekStartsOn: 1 })
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
key: "lastWeek",
|
|
308
|
-
label: "Last Week",
|
|
309
|
-
start: subDays(startOfWeek(today, { weekStartsOn: 1 }), 7),
|
|
310
|
-
end: subDays(endOfWeek(today, { weekStartsOn: 1 }), 7)
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
key: "last7Days",
|
|
314
|
-
label: "Last 7 Days",
|
|
315
|
-
start: subDays(today, 6),
|
|
316
|
-
end: today
|
|
317
|
-
},
|
|
318
|
-
{
|
|
319
|
-
key: "thisMonth",
|
|
320
|
-
label: "This Month",
|
|
321
|
-
start: startOfMonth(today),
|
|
322
|
-
end: endOfMonth(today)
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
key: "lastMonth",
|
|
326
|
-
label: "Last Month",
|
|
327
|
-
start: startOfMonth(subDays(today, today.getDate())),
|
|
328
|
-
end: endOfMonth(subDays(today, today.getDate()))
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
key: "thisYear",
|
|
332
|
-
label: "This Year",
|
|
333
|
-
start: startOfYear(today),
|
|
334
|
-
end: endOfYear(today)
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
key: "lastYear",
|
|
338
|
-
label: "Last Year",
|
|
339
|
-
start: startOfYear(subDays(today, 365)),
|
|
340
|
-
end: endOfYear(subDays(today, 365))
|
|
341
|
-
}
|
|
342
|
-
];
|
|
343
|
-
const allDateRangePresets = customPresets || defaultDateRangePresets;
|
|
344
|
-
const dateRanges = React$1.useMemo(() => {
|
|
345
|
-
return allDateRangePresets.filter((preset) => {
|
|
346
|
-
if (excludePresets?.includes(preset.key)) return false;
|
|
347
|
-
const startValid = !isDateDisabled(preset.start);
|
|
348
|
-
const endValid = !isDateDisabled(preset.end);
|
|
349
|
-
const rangeValid = numberOfMonths === 1 || isRangeValid(preset.start, preset.end);
|
|
350
|
-
return startValid && endValid && rangeValid;
|
|
351
|
-
});
|
|
352
|
-
}, [
|
|
353
|
-
isDateDisabled,
|
|
354
|
-
excludePresets,
|
|
355
|
-
numberOfMonths,
|
|
356
|
-
isRangeValid
|
|
357
|
-
]);
|
|
358
|
-
const handleMouseOver = (part) => {
|
|
359
|
-
setHighlightedPart(part);
|
|
360
|
-
};
|
|
361
|
-
const handleMouseLeave = () => {
|
|
362
|
-
setHighlightedPart(null);
|
|
363
|
-
};
|
|
364
|
-
const handleWheel = (event) => {
|
|
365
|
-
event.preventDefault();
|
|
366
|
-
setSelectedRange(null);
|
|
367
|
-
if (highlightedPart === "firstDay") {
|
|
368
|
-
const newDate = new Date(pendingDate?.from);
|
|
369
|
-
const increment = event.deltaY > 0 ? -1 : 1;
|
|
370
|
-
newDate.setDate(newDate.getDate() + increment);
|
|
371
|
-
if (newDate <= pendingDate?.to) {
|
|
372
|
-
numberOfMonths === 2 ? setPendingDate({
|
|
373
|
-
from: newDate,
|
|
374
|
-
to: new Date(pendingDate?.to)
|
|
375
|
-
}) : setPendingDate({
|
|
376
|
-
from: newDate,
|
|
377
|
-
to: newDate
|
|
378
|
-
});
|
|
379
|
-
setMonthFrom(newDate);
|
|
380
|
-
} else if (newDate > pendingDate?.to && numberOfMonths === 1) {
|
|
381
|
-
setPendingDate({
|
|
382
|
-
from: newDate,
|
|
383
|
-
to: newDate
|
|
384
|
-
});
|
|
385
|
-
setMonthFrom(newDate);
|
|
386
|
-
}
|
|
387
|
-
} else if (highlightedPart === "firstMonth") handleMonthChange((monthFrom ? monthFrom.getMonth() : 0) + (event.deltaY > 0 ? -1 : 1), "from");
|
|
388
|
-
else if (highlightedPart === "firstYear" && yearFrom !== void 0) handleYearChange(yearFrom + (event.deltaY > 0 ? -1 : 1), "from");
|
|
389
|
-
else if (highlightedPart === "secondDay") {
|
|
390
|
-
const newDate = new Date(pendingDate?.to);
|
|
391
|
-
const increment = event.deltaY > 0 ? -1 : 1;
|
|
392
|
-
newDate.setDate(newDate.getDate() + increment);
|
|
393
|
-
if (newDate >= pendingDate?.from) {
|
|
394
|
-
setPendingDate({
|
|
395
|
-
from: new Date(pendingDate?.from),
|
|
396
|
-
to: newDate
|
|
397
|
-
});
|
|
398
|
-
setMonthTo(newDate);
|
|
399
|
-
}
|
|
400
|
-
} else if (highlightedPart === "secondMonth") handleMonthChange((monthTo ? monthTo.getMonth() : 0) + (event.deltaY > 0 ? -1 : 1), "to");
|
|
401
|
-
else if (highlightedPart === "secondYear" && yearTo !== void 0) handleYearChange(yearTo + (event.deltaY > 0 ? -1 : 1), "to");
|
|
402
|
-
};
|
|
403
|
-
React$1.useEffect(() => {
|
|
404
|
-
const elements = [
|
|
405
|
-
document.getElementById(`firstDay-${id}`),
|
|
406
|
-
document.getElementById(`firstMonth-${id}`),
|
|
407
|
-
document.getElementById(`firstYear-${id}`),
|
|
408
|
-
document.getElementById(`secondDay-${id}`),
|
|
409
|
-
document.getElementById(`secondMonth-${id}`),
|
|
410
|
-
document.getElementById(`secondYear-${id}`)
|
|
411
|
-
];
|
|
412
|
-
const addPassiveEventListener = (element) => {
|
|
413
|
-
if (element) element.addEventListener("wheel", handleWheel, { passive: false });
|
|
414
|
-
};
|
|
415
|
-
elements.forEach(addPassiveEventListener);
|
|
416
|
-
return () => {
|
|
417
|
-
elements.forEach((element) => {
|
|
418
|
-
if (element) element.removeEventListener("wheel", handleWheel);
|
|
419
|
-
});
|
|
420
|
-
};
|
|
421
|
-
}, [highlightedPart, pendingDate]);
|
|
422
|
-
const formatWithTz = (date, fmt) => formatInTimeZone(date, timeZone, fmt);
|
|
423
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("style", { children: `
|
|
424
|
-
.date-part {
|
|
425
|
-
touch-action: none;
|
|
426
|
-
}
|
|
427
|
-
` }), /* @__PURE__ */ jsxs(Popover, {
|
|
428
|
-
open: isPopoverOpen,
|
|
429
|
-
onOpenChange: setIsPopoverOpen,
|
|
430
|
-
children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
431
|
-
asChild: true,
|
|
432
|
-
children: /* @__PURE__ */ jsx(Button$1, {
|
|
433
|
-
id: "date",
|
|
434
|
-
ref,
|
|
435
|
-
...props,
|
|
436
|
-
className: cn("w-full", triggerClassName, multiSelectVariants({
|
|
437
|
-
variant,
|
|
438
|
-
className
|
|
439
|
-
})),
|
|
440
|
-
onClick: handleTogglePopover,
|
|
441
|
-
suppressHydrationWarning: true,
|
|
442
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
443
|
-
className: "flex w-full items-center justify-between gap-2",
|
|
444
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
445
|
-
className: "flex items-center gap-2",
|
|
446
|
-
children: [/* @__PURE__ */ jsx(CalendarIcon, { className: "text-muted-foreground h-4 w-4" }), /* @__PURE__ */ jsx("span", { children: date?.from ? date.to ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
447
|
-
/* @__PURE__ */ jsx("span", {
|
|
448
|
-
id: `firstDay-${id}`,
|
|
449
|
-
className: cn("date-part", highlightedPart === "firstDay" && "font-bold underline"),
|
|
450
|
-
onMouseOver: () => handleMouseOver("firstDay"),
|
|
451
|
-
onMouseLeave: handleMouseLeave,
|
|
452
|
-
children: formatWithTz(date.from, "dd")
|
|
453
|
-
}),
|
|
454
|
-
" ",
|
|
455
|
-
/* @__PURE__ */ jsx("span", {
|
|
456
|
-
id: `firstMonth-${id}`,
|
|
457
|
-
className: cn("date-part", highlightedPart === "firstMonth" && "font-bold underline"),
|
|
458
|
-
onMouseOver: () => handleMouseOver("firstMonth"),
|
|
459
|
-
onMouseLeave: handleMouseLeave,
|
|
460
|
-
children: formatWithTz(date.from, "LLL")
|
|
461
|
-
}),
|
|
462
|
-
",",
|
|
463
|
-
" ",
|
|
464
|
-
/* @__PURE__ */ jsx("span", {
|
|
465
|
-
id: `firstYear-${id}`,
|
|
466
|
-
className: cn("date-part", highlightedPart === "firstYear" && "font-bold underline"),
|
|
467
|
-
onMouseOver: () => handleMouseOver("firstYear"),
|
|
468
|
-
onMouseLeave: handleMouseLeave,
|
|
469
|
-
children: formatWithTz(date.from, "y")
|
|
470
|
-
}),
|
|
471
|
-
numberOfMonths === 2 && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
472
|
-
" - ",
|
|
473
|
-
/* @__PURE__ */ jsx("span", {
|
|
474
|
-
id: `secondDay-${id}`,
|
|
475
|
-
className: cn("date-part", highlightedPart === "secondDay" && "font-bold underline"),
|
|
476
|
-
onMouseOver: () => handleMouseOver("secondDay"),
|
|
477
|
-
onMouseLeave: handleMouseLeave,
|
|
478
|
-
children: formatWithTz(date.to, "dd")
|
|
479
|
-
}),
|
|
480
|
-
" ",
|
|
481
|
-
/* @__PURE__ */ jsx("span", {
|
|
482
|
-
id: `secondMonth-${id}`,
|
|
483
|
-
className: cn("date-part", highlightedPart === "secondMonth" && "font-bold underline"),
|
|
484
|
-
onMouseOver: () => handleMouseOver("secondMonth"),
|
|
485
|
-
onMouseLeave: handleMouseLeave,
|
|
486
|
-
children: formatWithTz(date.to, "LLL")
|
|
487
|
-
}),
|
|
488
|
-
",",
|
|
489
|
-
" ",
|
|
490
|
-
/* @__PURE__ */ jsx("span", {
|
|
491
|
-
id: `secondYear-${id}`,
|
|
492
|
-
className: cn("date-part", highlightedPart === "secondYear" && "font-bold underline"),
|
|
493
|
-
onMouseOver: () => handleMouseOver("secondYear"),
|
|
494
|
-
onMouseLeave: handleMouseLeave,
|
|
495
|
-
children: formatWithTz(date.to, "y")
|
|
496
|
-
})
|
|
497
|
-
] })
|
|
498
|
-
] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
499
|
-
/* @__PURE__ */ jsx("span", {
|
|
500
|
-
id: "day",
|
|
501
|
-
className: cn("date-part", highlightedPart === "day" && "font-bold underline"),
|
|
502
|
-
onMouseOver: () => handleMouseOver("day"),
|
|
503
|
-
onMouseLeave: handleMouseLeave,
|
|
504
|
-
children: formatWithTz(date.from, "dd")
|
|
505
|
-
}),
|
|
506
|
-
" ",
|
|
507
|
-
/* @__PURE__ */ jsx("span", {
|
|
508
|
-
id: "month",
|
|
509
|
-
className: cn("date-part", highlightedPart === "month" && "font-bold underline"),
|
|
510
|
-
onMouseOver: () => handleMouseOver("month"),
|
|
511
|
-
onMouseLeave: handleMouseLeave,
|
|
512
|
-
children: formatWithTz(date.from, "LLL")
|
|
513
|
-
}),
|
|
514
|
-
",",
|
|
515
|
-
" ",
|
|
516
|
-
/* @__PURE__ */ jsx("span", {
|
|
517
|
-
id: "year",
|
|
518
|
-
className: cn("date-part", highlightedPart === "year" && "font-bold underline"),
|
|
519
|
-
onMouseOver: () => handleMouseOver("year"),
|
|
520
|
-
onMouseLeave: handleMouseLeave,
|
|
521
|
-
children: formatWithTz(date.from, "y")
|
|
522
|
-
})
|
|
523
|
-
] }) : /* @__PURE__ */ jsx("span", {
|
|
524
|
-
className: "text-muted-foreground",
|
|
525
|
-
children: placeholder || "Pick a date"
|
|
526
|
-
}) })]
|
|
527
|
-
}), date?.from && /* @__PURE__ */ jsxs("div", {
|
|
528
|
-
onClick: handleClear,
|
|
529
|
-
className: "text-muted-foreground hover:text-primary size-4 p-0 hover:bg-transparent",
|
|
530
|
-
children: [/* @__PURE__ */ jsx(X, { size: 14 }), /* @__PURE__ */ jsx("span", {
|
|
531
|
-
className: "sr-only",
|
|
532
|
-
children: "Clear date"
|
|
533
|
-
})]
|
|
534
|
-
})]
|
|
535
|
-
})
|
|
536
|
-
})
|
|
537
|
-
}), isPopoverOpen && /* @__PURE__ */ jsx(PopoverContent, {
|
|
538
|
-
className: "w-auto",
|
|
539
|
-
align: "center",
|
|
540
|
-
avoidCollisions: false,
|
|
541
|
-
onInteractOutside: handleClose,
|
|
542
|
-
onEscapeKeyDown: handleClose,
|
|
543
|
-
style: {
|
|
544
|
-
maxHeight: "var(--radix-popover-content-available-height)",
|
|
545
|
-
overflowY: "auto"
|
|
546
|
-
},
|
|
547
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
548
|
-
className: "flex",
|
|
549
|
-
children: [numberOfMonths === 2 && /* @__PURE__ */ jsx("div", {
|
|
550
|
-
className: "border-foreground/10 hidden flex-col gap-1 border-r pr-4 text-left md:flex",
|
|
551
|
-
children: dateRanges.map(({ key, label, start, end }) => /* @__PURE__ */ jsx(Button$1, {
|
|
552
|
-
variant: "ghost",
|
|
553
|
-
size: "sm",
|
|
554
|
-
className: cn("hover:bg-primary/90 hover:text-background justify-start", selectedRange === label && "bg-primary text-background hover:bg-primary/90 hover:text-background"),
|
|
555
|
-
onClick: () => {
|
|
556
|
-
selectDateRange(start, end, label);
|
|
557
|
-
setMonthFrom(start);
|
|
558
|
-
setYearFrom(start.getFullYear());
|
|
559
|
-
setMonthTo(end);
|
|
560
|
-
setYearTo(end.getFullYear());
|
|
561
|
-
},
|
|
562
|
-
children: label
|
|
563
|
-
}, key))
|
|
564
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
565
|
-
className: "flex flex-col",
|
|
566
|
-
children: [
|
|
567
|
-
/* @__PURE__ */ jsxs("div", {
|
|
568
|
-
className: "flex items-center gap-4",
|
|
569
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
570
|
-
className: "ml-3 flex gap-2",
|
|
571
|
-
children: [/* @__PURE__ */ jsxs(Select, {
|
|
572
|
-
onValueChange: (value) => {
|
|
573
|
-
handleMonthChange(months.indexOf(value), "from");
|
|
574
|
-
setSelectedRange(null);
|
|
575
|
-
},
|
|
576
|
-
value: monthFrom ? months[monthFrom.getMonth()] : void 0,
|
|
577
|
-
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
578
|
-
className: "hover:bg-accent hover:text-accent-foreground hidden w-[122px] font-medium focus:ring-0 focus:ring-offset-0 sm:flex",
|
|
579
|
-
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Month" })
|
|
580
|
-
}), /* @__PURE__ */ jsx(SelectContent, { children: months.map((month, idx) => /* @__PURE__ */ jsx(SelectItem, {
|
|
581
|
-
value: month,
|
|
582
|
-
children: month
|
|
583
|
-
}, idx)) })]
|
|
584
|
-
}), /* @__PURE__ */ jsxs(Select, {
|
|
585
|
-
onValueChange: (value) => {
|
|
586
|
-
handleYearChange(Number(value), "from");
|
|
587
|
-
setSelectedRange(null);
|
|
588
|
-
},
|
|
589
|
-
value: yearFrom ? yearFrom.toString() : void 0,
|
|
590
|
-
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
591
|
-
className: "hover:bg-accent hover:text-accent-foreground hidden w-[122px] font-medium focus:ring-0 focus:ring-offset-0 sm:flex",
|
|
592
|
-
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Year" })
|
|
593
|
-
}), /* @__PURE__ */ jsx(SelectContent, { children: years.map((year, idx) => /* @__PURE__ */ jsx(SelectItem, {
|
|
594
|
-
value: year.toString(),
|
|
595
|
-
children: year
|
|
596
|
-
}, idx)) })]
|
|
597
|
-
})]
|
|
598
|
-
}), numberOfMonths === 2 && /* @__PURE__ */ jsxs("div", {
|
|
599
|
-
className: "flex gap-2",
|
|
600
|
-
children: [/* @__PURE__ */ jsxs(Select, {
|
|
601
|
-
onValueChange: (value) => {
|
|
602
|
-
handleMonthChange(months.indexOf(value), "to");
|
|
603
|
-
setSelectedRange(null);
|
|
604
|
-
},
|
|
605
|
-
value: monthTo ? months[monthTo.getMonth()] : void 0,
|
|
606
|
-
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
607
|
-
className: "hover:bg-accent hover:text-accent-foreground hidden w-[122px] font-medium focus:ring-0 focus:ring-offset-0 sm:flex",
|
|
608
|
-
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Month" })
|
|
609
|
-
}), /* @__PURE__ */ jsx(SelectContent, { children: months.map((month, idx) => /* @__PURE__ */ jsx(SelectItem, {
|
|
610
|
-
value: month,
|
|
611
|
-
children: month
|
|
612
|
-
}, idx)) })]
|
|
613
|
-
}), /* @__PURE__ */ jsxs(Select, {
|
|
614
|
-
onValueChange: (value) => {
|
|
615
|
-
handleYearChange(Number(value), "to");
|
|
616
|
-
setSelectedRange(null);
|
|
617
|
-
},
|
|
618
|
-
value: yearTo ? yearTo.toString() : void 0,
|
|
619
|
-
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
620
|
-
className: "hover:bg-accent hover:text-accent-foreground hidden w-[122px] font-medium focus:ring-0 focus:ring-offset-0 sm:flex",
|
|
621
|
-
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Year" })
|
|
622
|
-
}), /* @__PURE__ */ jsx(SelectContent, { children: years.map((year, idx) => /* @__PURE__ */ jsx(SelectItem, {
|
|
623
|
-
value: year.toString(),
|
|
624
|
-
children: year
|
|
625
|
-
}, idx)) })]
|
|
626
|
-
})]
|
|
627
|
-
})]
|
|
628
|
-
}),
|
|
629
|
-
/* @__PURE__ */ jsx("div", {
|
|
630
|
-
className: "flex",
|
|
631
|
-
children: /* @__PURE__ */ jsx(Calendar$1, {
|
|
632
|
-
mode: "range",
|
|
633
|
-
defaultMonth: monthFrom,
|
|
634
|
-
month: monthFrom,
|
|
635
|
-
onMonthChange: setMonthFrom,
|
|
636
|
-
selected: pendingDate,
|
|
637
|
-
onSelect: handleDateSelect,
|
|
638
|
-
numberOfMonths,
|
|
639
|
-
showOutsideDays: false,
|
|
640
|
-
disabled: isDateDisabled,
|
|
641
|
-
fromDate: effectiveMinDate,
|
|
642
|
-
toDate: effectiveMaxDate,
|
|
643
|
-
className
|
|
644
|
-
})
|
|
645
|
-
}),
|
|
646
|
-
!closeOnSelect && /* @__PURE__ */ jsxs("div", {
|
|
647
|
-
className: "flex justify-end gap-2 border-t p-3",
|
|
648
|
-
children: [/* @__PURE__ */ jsx(Button$1, {
|
|
649
|
-
variant: "outline",
|
|
650
|
-
size: "sm",
|
|
651
|
-
onClick: handleReset,
|
|
652
|
-
type: "button",
|
|
653
|
-
children: "Reset"
|
|
654
|
-
}), /* @__PURE__ */ jsx(Button$1, {
|
|
655
|
-
size: "sm",
|
|
656
|
-
onClick: handleApply,
|
|
657
|
-
type: "button",
|
|
658
|
-
children: "Apply"
|
|
659
|
-
})]
|
|
660
|
-
})
|
|
661
|
-
]
|
|
662
|
-
})]
|
|
663
|
-
})
|
|
664
|
-
})]
|
|
665
|
-
})] });
|
|
666
|
-
}
|
|
667
|
-
CalendarDatePicker.displayName = "CalendarDatePicker";
|
|
668
|
-
|
|
669
|
-
//#endregion
|
|
670
15
|
//#region src/components/features/time-range-picker/utils/timezone.ts
|
|
671
16
|
/**
|
|
672
17
|
* Get the UTC offset string for a timezone
|
|
@@ -1503,4 +848,4 @@ function toApiTimeRange(value, timezone, presets = DEFAULT_PRESETS) {
|
|
|
1503
848
|
}
|
|
1504
849
|
|
|
1505
850
|
//#endregion
|
|
1506
|
-
export { utcToLocalInputString as C, utcStringToZonedDate as S,
|
|
851
|
+
export { utcToLocalInputString as C, utcStringToZonedDate as S, getBrowserTimezone as _, formatTimeRangeDisplay as a, getTimezoneOffset as b, getPresetByKey as c, TimezoneSelector as d, QuickRangesPanel as f, formatUtcForDisplay as g, formatTimezoneLabel as h, formatSingleTimeDisplay as i, getPresetByShortcut as l, createTimezoneOption as m, TimeRangePicker as n, DEFAULT_PRESETS as o, CustomRangePanel as p, formatDateForInput as r, getDefaultPreset as s, toApiTimeRange as t, getPresetRange as u, getDefaultTimezoneOptions as v, zonedDateToUtcString as w, localInputStringToUtc as x, getShortTimezoneDisplay as y };
|
package/dist/toast/index.mjs
CHANGED
package/dist/tooltip/index.mjs
CHANGED