@datum-cloud/datum-ui 0.2.0-alpha.8 → 0.3.0-alpha.3670fb2
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/styles/fonts/AllianceNo1-Medium.ttf +0 -0
- package/dist/styles/fonts/AllianceNo1-Regular.ttf +0 -0
- package/dist/styles/fonts/AllianceNo1-SemiBold.ttf +0 -0
- 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 +29 -17
- /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
|
@@ -0,0 +1,665 @@
|
|
|
1
|
+
import { t as cn } from "./cn-DWCc1QRE.mjs";
|
|
2
|
+
import { t as Button } from "./button-AzpnV-WB.mjs";
|
|
3
|
+
import { t as Calendar$1 } from "./calendar-DlIHeWb0.mjs";
|
|
4
|
+
import { i as PopoverTrigger, r as PopoverContent, t as Popover } from "./popover-Ds9624qY.mjs";
|
|
5
|
+
import { i as SelectItem, l as SelectTrigger, n as SelectContent, t as Select, u as SelectValue } from "./select-CwVIFWFO.mjs";
|
|
6
|
+
import { cva } from "class-variance-authority";
|
|
7
|
+
import { CalendarIcon, X } from "lucide-react";
|
|
8
|
+
import * as React$1 from "react";
|
|
9
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { endOfDay, endOfMonth, endOfWeek, endOfYear, startOfDay, startOfMonth, startOfWeek, startOfYear, subDays } from "date-fns";
|
|
11
|
+
import { formatInTimeZone, toDate } from "date-fns-tz";
|
|
12
|
+
|
|
13
|
+
//#region src/components/features/calendar-date-picker/calendar-date-picker.tsx
|
|
14
|
+
const months = [
|
|
15
|
+
"January",
|
|
16
|
+
"February",
|
|
17
|
+
"March",
|
|
18
|
+
"April",
|
|
19
|
+
"May",
|
|
20
|
+
"June",
|
|
21
|
+
"July",
|
|
22
|
+
"August",
|
|
23
|
+
"September",
|
|
24
|
+
"October",
|
|
25
|
+
"November",
|
|
26
|
+
"December"
|
|
27
|
+
];
|
|
28
|
+
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", {
|
|
29
|
+
variants: { variant: {
|
|
30
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
31
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
32
|
+
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
33
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
34
|
+
ghost: "hover:bg-accent hover:text-accent-foreground text-background",
|
|
35
|
+
link: "text-primary underline-offset-4 hover:underline text-background"
|
|
36
|
+
} },
|
|
37
|
+
defaultVariants: { variant: "default" }
|
|
38
|
+
});
|
|
39
|
+
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, popoverClassName, ...props }) {
|
|
40
|
+
const [isPopoverOpen, setIsPopoverOpen] = React$1.useState(false);
|
|
41
|
+
const [selectedRange, setSelectedRange] = React$1.useState(numberOfMonths === 2 ? "This Year" : "Today");
|
|
42
|
+
const [monthFrom, setMonthFrom] = React$1.useState(date?.from);
|
|
43
|
+
const [yearFrom, setYearFrom] = React$1.useState(date?.from?.getFullYear());
|
|
44
|
+
const [monthTo, setMonthTo] = React$1.useState(numberOfMonths === 2 ? date?.to : date?.from);
|
|
45
|
+
const [yearTo, setYearTo] = React$1.useState(numberOfMonths === 2 ? date?.to?.getFullYear() : date?.from?.getFullYear());
|
|
46
|
+
const [highlightedPart, setHighlightedPart] = React$1.useState(null);
|
|
47
|
+
const [pendingDate, setPendingDate] = React$1.useState(date);
|
|
48
|
+
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
49
|
+
const today = /* @__PURE__ */ new Date();
|
|
50
|
+
const effectiveMinDate = React$1.useMemo(() => {
|
|
51
|
+
let min = minDate;
|
|
52
|
+
if (disablePast) {
|
|
53
|
+
const todayStart = startOfDay(today);
|
|
54
|
+
min = min ? min > todayStart ? min : todayStart : todayStart;
|
|
55
|
+
}
|
|
56
|
+
return min;
|
|
57
|
+
}, [
|
|
58
|
+
minDate,
|
|
59
|
+
disablePast,
|
|
60
|
+
today
|
|
61
|
+
]);
|
|
62
|
+
const effectiveMaxDate = React$1.useMemo(() => {
|
|
63
|
+
let max = maxDate;
|
|
64
|
+
if (disableFuture) {
|
|
65
|
+
const todayEnd = endOfDay(today);
|
|
66
|
+
max = max ? max < todayEnd ? max : todayEnd : todayEnd;
|
|
67
|
+
}
|
|
68
|
+
return max;
|
|
69
|
+
}, [
|
|
70
|
+
maxDate,
|
|
71
|
+
disableFuture,
|
|
72
|
+
today
|
|
73
|
+
]);
|
|
74
|
+
const isDateDisabled = React$1.useCallback((date) => {
|
|
75
|
+
if (effectiveMinDate && date < effectiveMinDate) return true;
|
|
76
|
+
if (effectiveMaxDate && date > effectiveMaxDate) return true;
|
|
77
|
+
return false;
|
|
78
|
+
}, [effectiveMinDate, effectiveMaxDate]);
|
|
79
|
+
const getDaysDifference = React$1.useCallback((from, to) => {
|
|
80
|
+
const timeDiff = Math.abs(to.getTime() - from.getTime());
|
|
81
|
+
return Math.ceil(timeDiff / (1e3 * 60 * 60 * 24));
|
|
82
|
+
}, []);
|
|
83
|
+
const isRangeValid = React$1.useCallback((from, to) => {
|
|
84
|
+
if (!maxRange) return true;
|
|
85
|
+
if (numberOfMonths === 1) return true;
|
|
86
|
+
return getDaysDifference(from, to) <= maxRange;
|
|
87
|
+
}, [
|
|
88
|
+
maxRange,
|
|
89
|
+
numberOfMonths,
|
|
90
|
+
getDaysDifference
|
|
91
|
+
]);
|
|
92
|
+
const adjustRangeToMaxRange = React$1.useCallback((from, to) => {
|
|
93
|
+
if (!maxRange || numberOfMonths === 1) return {
|
|
94
|
+
from,
|
|
95
|
+
to
|
|
96
|
+
};
|
|
97
|
+
if (getDaysDifference(from, to) <= maxRange) return {
|
|
98
|
+
from,
|
|
99
|
+
to
|
|
100
|
+
};
|
|
101
|
+
const adjustedTo = new Date(from.getTime() + maxRange * 24 * 60 * 60 * 1e3);
|
|
102
|
+
if (effectiveMaxDate && adjustedTo > effectiveMaxDate) {
|
|
103
|
+
const adjustedFrom = /* @__PURE__ */ new Date(to.getTime() - maxRange * 24 * 60 * 60 * 1e3);
|
|
104
|
+
if (effectiveMinDate && adjustedFrom < effectiveMinDate) return {
|
|
105
|
+
from,
|
|
106
|
+
to
|
|
107
|
+
};
|
|
108
|
+
return {
|
|
109
|
+
from: adjustedFrom,
|
|
110
|
+
to
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
from,
|
|
115
|
+
to: adjustedTo
|
|
116
|
+
};
|
|
117
|
+
}, [
|
|
118
|
+
maxRange,
|
|
119
|
+
numberOfMonths,
|
|
120
|
+
getDaysDifference,
|
|
121
|
+
effectiveMinDate,
|
|
122
|
+
effectiveMaxDate
|
|
123
|
+
]);
|
|
124
|
+
React$1.useEffect(() => {
|
|
125
|
+
setPendingDate(date);
|
|
126
|
+
}, [date]);
|
|
127
|
+
const handleClose = () => setIsPopoverOpen(false);
|
|
128
|
+
const handleTogglePopover = () => setIsPopoverOpen((prev) => !prev);
|
|
129
|
+
const handleClear = (e) => {
|
|
130
|
+
e.stopPropagation();
|
|
131
|
+
onDateSelect(void 0);
|
|
132
|
+
setPendingDate({
|
|
133
|
+
from: void 0,
|
|
134
|
+
to: void 0
|
|
135
|
+
});
|
|
136
|
+
setSelectedRange(null);
|
|
137
|
+
};
|
|
138
|
+
const handleApply = () => {
|
|
139
|
+
if (pendingDate?.from) onDateSelect({
|
|
140
|
+
from: pendingDate.from,
|
|
141
|
+
to: pendingDate.to || pendingDate.from
|
|
142
|
+
});
|
|
143
|
+
setIsPopoverOpen(false);
|
|
144
|
+
};
|
|
145
|
+
const handleReset = () => {
|
|
146
|
+
setPendingDate(date);
|
|
147
|
+
setMonthFrom(date?.from);
|
|
148
|
+
setYearFrom(date?.from?.getFullYear());
|
|
149
|
+
setMonthTo(numberOfMonths === 2 ? date?.to : date?.from);
|
|
150
|
+
setYearTo(numberOfMonths === 2 ? date?.to?.getFullYear() : date?.from?.getFullYear());
|
|
151
|
+
setSelectedRange(null);
|
|
152
|
+
};
|
|
153
|
+
const selectDateRange = (from, to, range) => {
|
|
154
|
+
const startDate = startOfDay(toDate(from, { timeZone }));
|
|
155
|
+
const endDate = numberOfMonths === 2 ? endOfDay(toDate(to, { timeZone })) : startDate;
|
|
156
|
+
if (isDateDisabled(startDate) || isDateDisabled(endDate)) return;
|
|
157
|
+
let finalDates = {
|
|
158
|
+
from: startDate,
|
|
159
|
+
to: endDate
|
|
160
|
+
};
|
|
161
|
+
if (numberOfMonths === 2 && !isRangeValid(startDate, endDate)) {
|
|
162
|
+
finalDates = adjustRangeToMaxRange(startDate, endDate);
|
|
163
|
+
if (!isRangeValid(finalDates.from, finalDates.to)) return;
|
|
164
|
+
}
|
|
165
|
+
setPendingDate({
|
|
166
|
+
from: finalDates.from,
|
|
167
|
+
to: finalDates.to
|
|
168
|
+
});
|
|
169
|
+
setSelectedRange(range);
|
|
170
|
+
setMonthFrom(finalDates.from);
|
|
171
|
+
setYearFrom(finalDates.from.getFullYear());
|
|
172
|
+
setMonthTo(finalDates.to);
|
|
173
|
+
setYearTo(finalDates.to.getFullYear());
|
|
174
|
+
if (closeOnSelect) {
|
|
175
|
+
onDateSelect({
|
|
176
|
+
from: finalDates.from,
|
|
177
|
+
to: finalDates.to
|
|
178
|
+
});
|
|
179
|
+
setIsPopoverOpen(false);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
const handleDateSelect = (range) => {
|
|
183
|
+
if (range) {
|
|
184
|
+
let from = startOfDay(toDate(range.from, { timeZone }));
|
|
185
|
+
let to = range.to ? endOfDay(toDate(range.to, { timeZone })) : from;
|
|
186
|
+
if (numberOfMonths === 1) if (range.from !== pendingDate?.from) to = from;
|
|
187
|
+
else from = startOfDay(toDate(range.to, { timeZone }));
|
|
188
|
+
if (isDateDisabled(from) || isDateDisabled(to)) return;
|
|
189
|
+
let finalDates = {
|
|
190
|
+
from,
|
|
191
|
+
to
|
|
192
|
+
};
|
|
193
|
+
if (numberOfMonths === 2 && !isRangeValid(from, to)) {
|
|
194
|
+
finalDates = adjustRangeToMaxRange(from, to);
|
|
195
|
+
if (!isRangeValid(finalDates.from, finalDates.to)) return;
|
|
196
|
+
}
|
|
197
|
+
setPendingDate({
|
|
198
|
+
from: finalDates.from,
|
|
199
|
+
to: finalDates.to
|
|
200
|
+
});
|
|
201
|
+
setMonthFrom(finalDates.from);
|
|
202
|
+
setYearFrom(finalDates.from.getFullYear());
|
|
203
|
+
setMonthTo(finalDates.to);
|
|
204
|
+
setYearTo(finalDates.to.getFullYear());
|
|
205
|
+
if (closeOnSelect) {
|
|
206
|
+
onDateSelect({
|
|
207
|
+
from: finalDates.from,
|
|
208
|
+
to: finalDates.to
|
|
209
|
+
});
|
|
210
|
+
setIsPopoverOpen(false);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
setSelectedRange(null);
|
|
214
|
+
};
|
|
215
|
+
const handleMonthChange = (newMonthIndex, part) => {
|
|
216
|
+
setSelectedRange(null);
|
|
217
|
+
if (part === "from") {
|
|
218
|
+
if (yearFrom !== void 0) {
|
|
219
|
+
if (newMonthIndex < 0 || newMonthIndex > yearsRange + 1) return;
|
|
220
|
+
const newMonth = new Date(yearFrom, newMonthIndex, 1);
|
|
221
|
+
const from = numberOfMonths === 2 ? startOfMonth(toDate(newMonth, { timeZone })) : pendingDate?.from ? new Date(pendingDate.from.getFullYear(), newMonth.getMonth(), pendingDate.from.getDate()) : newMonth;
|
|
222
|
+
const to = numberOfMonths === 2 ? pendingDate?.to ? endOfDay(toDate(pendingDate.to, { timeZone })) : endOfMonth(toDate(newMonth, { timeZone })) : from;
|
|
223
|
+
if (from <= to) {
|
|
224
|
+
setPendingDate({
|
|
225
|
+
from,
|
|
226
|
+
to
|
|
227
|
+
});
|
|
228
|
+
setMonthFrom(newMonth);
|
|
229
|
+
setMonthTo(pendingDate?.to);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
} else if (yearTo !== void 0) {
|
|
233
|
+
if (newMonthIndex < 0 || newMonthIndex > yearsRange + 1) return;
|
|
234
|
+
const newMonth = new Date(yearTo, newMonthIndex, 1);
|
|
235
|
+
const from = pendingDate?.from ? startOfDay(toDate(pendingDate.from, { timeZone })) : startOfMonth(toDate(newMonth, { timeZone }));
|
|
236
|
+
const to = numberOfMonths === 2 ? endOfMonth(toDate(newMonth, { timeZone })) : from;
|
|
237
|
+
if (from <= to) {
|
|
238
|
+
setPendingDate({
|
|
239
|
+
from,
|
|
240
|
+
to
|
|
241
|
+
});
|
|
242
|
+
setMonthTo(newMonth);
|
|
243
|
+
setMonthFrom(pendingDate?.from);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
const years = Array.from({ length: yearsRange + 1 }, (_, i) => today.getFullYear() - yearsRange / 2 + i);
|
|
248
|
+
const handleYearChange = (newYear, part) => {
|
|
249
|
+
setSelectedRange(null);
|
|
250
|
+
if (part === "from") {
|
|
251
|
+
if (years.includes(newYear)) {
|
|
252
|
+
const newMonth = monthFrom ? new Date(newYear, monthFrom ? monthFrom.getMonth() : 0, 1) : new Date(newYear, 0, 1);
|
|
253
|
+
const from = numberOfMonths === 2 ? startOfMonth(toDate(newMonth, { timeZone })) : pendingDate?.from ? new Date(newYear, newMonth.getMonth(), pendingDate.from.getDate()) : newMonth;
|
|
254
|
+
const to = numberOfMonths === 2 ? pendingDate?.to ? endOfDay(toDate(pendingDate.to, { timeZone })) : endOfMonth(toDate(newMonth, { timeZone })) : from;
|
|
255
|
+
if (from <= to) {
|
|
256
|
+
setPendingDate({
|
|
257
|
+
from,
|
|
258
|
+
to
|
|
259
|
+
});
|
|
260
|
+
setYearFrom(newYear);
|
|
261
|
+
setMonthFrom(newMonth);
|
|
262
|
+
setYearTo(pendingDate?.to?.getFullYear());
|
|
263
|
+
setMonthTo(pendingDate?.to);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
} else if (years.includes(newYear)) {
|
|
267
|
+
const newMonth = monthTo ? new Date(newYear, monthTo.getMonth(), 1) : new Date(newYear, 0, 1);
|
|
268
|
+
const from = pendingDate?.from ? startOfDay(toDate(pendingDate.from, { timeZone })) : startOfMonth(toDate(newMonth, { timeZone }));
|
|
269
|
+
const to = numberOfMonths === 2 ? endOfMonth(toDate(newMonth, { timeZone })) : from;
|
|
270
|
+
if (from <= to) {
|
|
271
|
+
setPendingDate({
|
|
272
|
+
from,
|
|
273
|
+
to
|
|
274
|
+
});
|
|
275
|
+
setYearTo(newYear);
|
|
276
|
+
setMonthTo(newMonth);
|
|
277
|
+
setYearFrom(pendingDate?.from?.getFullYear());
|
|
278
|
+
setMonthFrom(pendingDate?.from);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
const defaultDateRangePresets = [
|
|
283
|
+
{
|
|
284
|
+
key: "today",
|
|
285
|
+
label: "Today",
|
|
286
|
+
start: today,
|
|
287
|
+
end: today
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
key: "yesterday",
|
|
291
|
+
label: "Yesterday",
|
|
292
|
+
start: subDays(today, 1),
|
|
293
|
+
end: subDays(today, 1)
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
key: "thisWeek",
|
|
297
|
+
label: "This Week",
|
|
298
|
+
start: startOfWeek(today, { weekStartsOn: 1 }),
|
|
299
|
+
end: endOfWeek(today, { weekStartsOn: 1 })
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
key: "lastWeek",
|
|
303
|
+
label: "Last Week",
|
|
304
|
+
start: subDays(startOfWeek(today, { weekStartsOn: 1 }), 7),
|
|
305
|
+
end: subDays(endOfWeek(today, { weekStartsOn: 1 }), 7)
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
key: "last7Days",
|
|
309
|
+
label: "Last 7 Days",
|
|
310
|
+
start: subDays(today, 6),
|
|
311
|
+
end: today
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
key: "thisMonth",
|
|
315
|
+
label: "This Month",
|
|
316
|
+
start: startOfMonth(today),
|
|
317
|
+
end: endOfMonth(today)
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
key: "lastMonth",
|
|
321
|
+
label: "Last Month",
|
|
322
|
+
start: startOfMonth(subDays(today, today.getDate())),
|
|
323
|
+
end: endOfMonth(subDays(today, today.getDate()))
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
key: "thisYear",
|
|
327
|
+
label: "This Year",
|
|
328
|
+
start: startOfYear(today),
|
|
329
|
+
end: endOfYear(today)
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
key: "lastYear",
|
|
333
|
+
label: "Last Year",
|
|
334
|
+
start: startOfYear(subDays(today, 365)),
|
|
335
|
+
end: endOfYear(subDays(today, 365))
|
|
336
|
+
}
|
|
337
|
+
];
|
|
338
|
+
const allDateRangePresets = customPresets || defaultDateRangePresets;
|
|
339
|
+
const dateRanges = React$1.useMemo(() => {
|
|
340
|
+
return allDateRangePresets.filter((preset) => {
|
|
341
|
+
if (excludePresets?.includes(preset.key)) return false;
|
|
342
|
+
const startValid = !isDateDisabled(preset.start);
|
|
343
|
+
const endValid = !isDateDisabled(preset.end);
|
|
344
|
+
const rangeValid = numberOfMonths === 1 || isRangeValid(preset.start, preset.end);
|
|
345
|
+
return startValid && endValid && rangeValid;
|
|
346
|
+
});
|
|
347
|
+
}, [
|
|
348
|
+
isDateDisabled,
|
|
349
|
+
excludePresets,
|
|
350
|
+
numberOfMonths,
|
|
351
|
+
isRangeValid
|
|
352
|
+
]);
|
|
353
|
+
const handleMouseOver = (part) => {
|
|
354
|
+
setHighlightedPart(part);
|
|
355
|
+
};
|
|
356
|
+
const handleMouseLeave = () => {
|
|
357
|
+
setHighlightedPart(null);
|
|
358
|
+
};
|
|
359
|
+
const handleWheel = (event) => {
|
|
360
|
+
event.preventDefault();
|
|
361
|
+
setSelectedRange(null);
|
|
362
|
+
if (highlightedPart === "firstDay") {
|
|
363
|
+
const newDate = new Date(pendingDate?.from);
|
|
364
|
+
const increment = event.deltaY > 0 ? -1 : 1;
|
|
365
|
+
newDate.setDate(newDate.getDate() + increment);
|
|
366
|
+
if (newDate <= pendingDate?.to) {
|
|
367
|
+
numberOfMonths === 2 ? setPendingDate({
|
|
368
|
+
from: newDate,
|
|
369
|
+
to: new Date(pendingDate?.to)
|
|
370
|
+
}) : setPendingDate({
|
|
371
|
+
from: newDate,
|
|
372
|
+
to: newDate
|
|
373
|
+
});
|
|
374
|
+
setMonthFrom(newDate);
|
|
375
|
+
} else if (newDate > pendingDate?.to && numberOfMonths === 1) {
|
|
376
|
+
setPendingDate({
|
|
377
|
+
from: newDate,
|
|
378
|
+
to: newDate
|
|
379
|
+
});
|
|
380
|
+
setMonthFrom(newDate);
|
|
381
|
+
}
|
|
382
|
+
} else if (highlightedPart === "firstMonth") handleMonthChange((monthFrom ? monthFrom.getMonth() : 0) + (event.deltaY > 0 ? -1 : 1), "from");
|
|
383
|
+
else if (highlightedPart === "firstYear" && yearFrom !== void 0) handleYearChange(yearFrom + (event.deltaY > 0 ? -1 : 1), "from");
|
|
384
|
+
else if (highlightedPart === "secondDay") {
|
|
385
|
+
const newDate = new Date(pendingDate?.to);
|
|
386
|
+
const increment = event.deltaY > 0 ? -1 : 1;
|
|
387
|
+
newDate.setDate(newDate.getDate() + increment);
|
|
388
|
+
if (newDate >= pendingDate?.from) {
|
|
389
|
+
setPendingDate({
|
|
390
|
+
from: new Date(pendingDate?.from),
|
|
391
|
+
to: newDate
|
|
392
|
+
});
|
|
393
|
+
setMonthTo(newDate);
|
|
394
|
+
}
|
|
395
|
+
} else if (highlightedPart === "secondMonth") handleMonthChange((monthTo ? monthTo.getMonth() : 0) + (event.deltaY > 0 ? -1 : 1), "to");
|
|
396
|
+
else if (highlightedPart === "secondYear" && yearTo !== void 0) handleYearChange(yearTo + (event.deltaY > 0 ? -1 : 1), "to");
|
|
397
|
+
};
|
|
398
|
+
React$1.useEffect(() => {
|
|
399
|
+
const elements = [
|
|
400
|
+
document.getElementById(`firstDay-${id}`),
|
|
401
|
+
document.getElementById(`firstMonth-${id}`),
|
|
402
|
+
document.getElementById(`firstYear-${id}`),
|
|
403
|
+
document.getElementById(`secondDay-${id}`),
|
|
404
|
+
document.getElementById(`secondMonth-${id}`),
|
|
405
|
+
document.getElementById(`secondYear-${id}`)
|
|
406
|
+
];
|
|
407
|
+
const addPassiveEventListener = (element) => {
|
|
408
|
+
if (element) element.addEventListener("wheel", handleWheel, { passive: false });
|
|
409
|
+
};
|
|
410
|
+
elements.forEach(addPassiveEventListener);
|
|
411
|
+
return () => {
|
|
412
|
+
elements.forEach((element) => {
|
|
413
|
+
if (element) element.removeEventListener("wheel", handleWheel);
|
|
414
|
+
});
|
|
415
|
+
};
|
|
416
|
+
}, [highlightedPart, pendingDate]);
|
|
417
|
+
const formatWithTz = (date, fmt) => formatInTimeZone(date, timeZone, fmt);
|
|
418
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("style", { children: `
|
|
419
|
+
.date-part {
|
|
420
|
+
touch-action: none;
|
|
421
|
+
}
|
|
422
|
+
` }), /* @__PURE__ */ jsxs(Popover, {
|
|
423
|
+
open: isPopoverOpen,
|
|
424
|
+
onOpenChange: setIsPopoverOpen,
|
|
425
|
+
children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
426
|
+
asChild: true,
|
|
427
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
428
|
+
id: "date",
|
|
429
|
+
ref,
|
|
430
|
+
...props,
|
|
431
|
+
className: cn("w-full", triggerClassName, multiSelectVariants({
|
|
432
|
+
variant,
|
|
433
|
+
className
|
|
434
|
+
})),
|
|
435
|
+
onClick: handleTogglePopover,
|
|
436
|
+
suppressHydrationWarning: true,
|
|
437
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
438
|
+
className: "flex w-full items-center justify-between gap-2",
|
|
439
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
440
|
+
className: "flex items-center gap-2",
|
|
441
|
+
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: [
|
|
442
|
+
/* @__PURE__ */ jsx("span", {
|
|
443
|
+
id: `firstDay-${id}`,
|
|
444
|
+
className: cn("date-part", highlightedPart === "firstDay" && "font-bold underline"),
|
|
445
|
+
onMouseOver: () => handleMouseOver("firstDay"),
|
|
446
|
+
onMouseLeave: handleMouseLeave,
|
|
447
|
+
children: formatWithTz(date.from, "dd")
|
|
448
|
+
}),
|
|
449
|
+
" ",
|
|
450
|
+
/* @__PURE__ */ jsx("span", {
|
|
451
|
+
id: `firstMonth-${id}`,
|
|
452
|
+
className: cn("date-part", highlightedPart === "firstMonth" && "font-bold underline"),
|
|
453
|
+
onMouseOver: () => handleMouseOver("firstMonth"),
|
|
454
|
+
onMouseLeave: handleMouseLeave,
|
|
455
|
+
children: formatWithTz(date.from, "LLL")
|
|
456
|
+
}),
|
|
457
|
+
",",
|
|
458
|
+
" ",
|
|
459
|
+
/* @__PURE__ */ jsx("span", {
|
|
460
|
+
id: `firstYear-${id}`,
|
|
461
|
+
className: cn("date-part", highlightedPart === "firstYear" && "font-bold underline"),
|
|
462
|
+
onMouseOver: () => handleMouseOver("firstYear"),
|
|
463
|
+
onMouseLeave: handleMouseLeave,
|
|
464
|
+
children: formatWithTz(date.from, "y")
|
|
465
|
+
}),
|
|
466
|
+
numberOfMonths === 2 && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
467
|
+
" - ",
|
|
468
|
+
/* @__PURE__ */ jsx("span", {
|
|
469
|
+
id: `secondDay-${id}`,
|
|
470
|
+
className: cn("date-part", highlightedPart === "secondDay" && "font-bold underline"),
|
|
471
|
+
onMouseOver: () => handleMouseOver("secondDay"),
|
|
472
|
+
onMouseLeave: handleMouseLeave,
|
|
473
|
+
children: formatWithTz(date.to, "dd")
|
|
474
|
+
}),
|
|
475
|
+
" ",
|
|
476
|
+
/* @__PURE__ */ jsx("span", {
|
|
477
|
+
id: `secondMonth-${id}`,
|
|
478
|
+
className: cn("date-part", highlightedPart === "secondMonth" && "font-bold underline"),
|
|
479
|
+
onMouseOver: () => handleMouseOver("secondMonth"),
|
|
480
|
+
onMouseLeave: handleMouseLeave,
|
|
481
|
+
children: formatWithTz(date.to, "LLL")
|
|
482
|
+
}),
|
|
483
|
+
",",
|
|
484
|
+
" ",
|
|
485
|
+
/* @__PURE__ */ jsx("span", {
|
|
486
|
+
id: `secondYear-${id}`,
|
|
487
|
+
className: cn("date-part", highlightedPart === "secondYear" && "font-bold underline"),
|
|
488
|
+
onMouseOver: () => handleMouseOver("secondYear"),
|
|
489
|
+
onMouseLeave: handleMouseLeave,
|
|
490
|
+
children: formatWithTz(date.to, "y")
|
|
491
|
+
})
|
|
492
|
+
] })
|
|
493
|
+
] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
494
|
+
/* @__PURE__ */ jsx("span", {
|
|
495
|
+
id: "day",
|
|
496
|
+
className: cn("date-part", highlightedPart === "day" && "font-bold underline"),
|
|
497
|
+
onMouseOver: () => handleMouseOver("day"),
|
|
498
|
+
onMouseLeave: handleMouseLeave,
|
|
499
|
+
children: formatWithTz(date.from, "dd")
|
|
500
|
+
}),
|
|
501
|
+
" ",
|
|
502
|
+
/* @__PURE__ */ jsx("span", {
|
|
503
|
+
id: "month",
|
|
504
|
+
className: cn("date-part", highlightedPart === "month" && "font-bold underline"),
|
|
505
|
+
onMouseOver: () => handleMouseOver("month"),
|
|
506
|
+
onMouseLeave: handleMouseLeave,
|
|
507
|
+
children: formatWithTz(date.from, "LLL")
|
|
508
|
+
}),
|
|
509
|
+
",",
|
|
510
|
+
" ",
|
|
511
|
+
/* @__PURE__ */ jsx("span", {
|
|
512
|
+
id: "year",
|
|
513
|
+
className: cn("date-part", highlightedPart === "year" && "font-bold underline"),
|
|
514
|
+
onMouseOver: () => handleMouseOver("year"),
|
|
515
|
+
onMouseLeave: handleMouseLeave,
|
|
516
|
+
children: formatWithTz(date.from, "y")
|
|
517
|
+
})
|
|
518
|
+
] }) : /* @__PURE__ */ jsx("span", {
|
|
519
|
+
className: "text-muted-foreground",
|
|
520
|
+
children: placeholder || "Pick a date"
|
|
521
|
+
}) })]
|
|
522
|
+
}), date?.from && /* @__PURE__ */ jsxs("div", {
|
|
523
|
+
onClick: handleClear,
|
|
524
|
+
className: "text-muted-foreground hover:text-primary size-4 p-0 hover:bg-transparent",
|
|
525
|
+
children: [/* @__PURE__ */ jsx(X, { size: 14 }), /* @__PURE__ */ jsx("span", {
|
|
526
|
+
className: "sr-only",
|
|
527
|
+
children: "Clear date"
|
|
528
|
+
})]
|
|
529
|
+
})]
|
|
530
|
+
})
|
|
531
|
+
})
|
|
532
|
+
}), isPopoverOpen && /* @__PURE__ */ jsx(PopoverContent, {
|
|
533
|
+
className: cn("w-auto popover-content-width-full", popoverClassName),
|
|
534
|
+
align: "center",
|
|
535
|
+
avoidCollisions: false,
|
|
536
|
+
onInteractOutside: handleClose,
|
|
537
|
+
onEscapeKeyDown: handleClose,
|
|
538
|
+
style: {
|
|
539
|
+
maxHeight: "var(--radix-popover-content-available-height)",
|
|
540
|
+
overflowY: "auto"
|
|
541
|
+
},
|
|
542
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
543
|
+
className: "flex",
|
|
544
|
+
children: [numberOfMonths === 2 && /* @__PURE__ */ jsx("div", {
|
|
545
|
+
className: "border-foreground/10 hidden flex-col gap-1 border-r pr-4 text-left md:flex",
|
|
546
|
+
children: dateRanges.map(({ key, label, start, end }) => /* @__PURE__ */ jsx(Button, {
|
|
547
|
+
variant: "ghost",
|
|
548
|
+
size: "sm",
|
|
549
|
+
className: cn("hover:bg-primary/90 hover:text-background justify-start", selectedRange === label && "bg-primary text-background hover:bg-primary/90 hover:text-background"),
|
|
550
|
+
onClick: () => {
|
|
551
|
+
selectDateRange(start, end, label);
|
|
552
|
+
setMonthFrom(start);
|
|
553
|
+
setYearFrom(start.getFullYear());
|
|
554
|
+
setMonthTo(end);
|
|
555
|
+
setYearTo(end.getFullYear());
|
|
556
|
+
},
|
|
557
|
+
children: label
|
|
558
|
+
}, key))
|
|
559
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
560
|
+
className: "flex flex-col",
|
|
561
|
+
children: [
|
|
562
|
+
/* @__PURE__ */ jsxs("div", {
|
|
563
|
+
className: "flex items-center gap-4",
|
|
564
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
565
|
+
className: "ml-3 flex gap-2",
|
|
566
|
+
children: [/* @__PURE__ */ jsxs(Select, {
|
|
567
|
+
onValueChange: (value) => {
|
|
568
|
+
handleMonthChange(months.indexOf(value), "from");
|
|
569
|
+
setSelectedRange(null);
|
|
570
|
+
},
|
|
571
|
+
value: monthFrom ? months[monthFrom.getMonth()] : void 0,
|
|
572
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
573
|
+
className: "hover:bg-accent hover:text-accent-foreground hidden w-[122px] font-medium focus:ring-0 focus:ring-offset-0 sm:flex",
|
|
574
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Month" })
|
|
575
|
+
}), /* @__PURE__ */ jsx(SelectContent, { children: months.map((month, idx) => /* @__PURE__ */ jsx(SelectItem, {
|
|
576
|
+
value: month,
|
|
577
|
+
children: month
|
|
578
|
+
}, idx)) })]
|
|
579
|
+
}), /* @__PURE__ */ jsxs(Select, {
|
|
580
|
+
onValueChange: (value) => {
|
|
581
|
+
handleYearChange(Number(value), "from");
|
|
582
|
+
setSelectedRange(null);
|
|
583
|
+
},
|
|
584
|
+
value: yearFrom ? yearFrom.toString() : void 0,
|
|
585
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
586
|
+
className: "hover:bg-accent hover:text-accent-foreground hidden w-[122px] font-medium focus:ring-0 focus:ring-offset-0 sm:flex",
|
|
587
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Year" })
|
|
588
|
+
}), /* @__PURE__ */ jsx(SelectContent, { children: years.map((year, idx) => /* @__PURE__ */ jsx(SelectItem, {
|
|
589
|
+
value: year.toString(),
|
|
590
|
+
children: year
|
|
591
|
+
}, idx)) })]
|
|
592
|
+
})]
|
|
593
|
+
}), numberOfMonths === 2 && /* @__PURE__ */ jsxs("div", {
|
|
594
|
+
className: "flex gap-2",
|
|
595
|
+
children: [/* @__PURE__ */ jsxs(Select, {
|
|
596
|
+
onValueChange: (value) => {
|
|
597
|
+
handleMonthChange(months.indexOf(value), "to");
|
|
598
|
+
setSelectedRange(null);
|
|
599
|
+
},
|
|
600
|
+
value: monthTo ? months[monthTo.getMonth()] : void 0,
|
|
601
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
602
|
+
className: "hover:bg-accent hover:text-accent-foreground hidden w-[122px] font-medium focus:ring-0 focus:ring-offset-0 sm:flex",
|
|
603
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Month" })
|
|
604
|
+
}), /* @__PURE__ */ jsx(SelectContent, { children: months.map((month, idx) => /* @__PURE__ */ jsx(SelectItem, {
|
|
605
|
+
value: month,
|
|
606
|
+
children: month
|
|
607
|
+
}, idx)) })]
|
|
608
|
+
}), /* @__PURE__ */ jsxs(Select, {
|
|
609
|
+
onValueChange: (value) => {
|
|
610
|
+
handleYearChange(Number(value), "to");
|
|
611
|
+
setSelectedRange(null);
|
|
612
|
+
},
|
|
613
|
+
value: yearTo ? yearTo.toString() : void 0,
|
|
614
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
615
|
+
className: "hover:bg-accent hover:text-accent-foreground hidden w-[122px] font-medium focus:ring-0 focus:ring-offset-0 sm:flex",
|
|
616
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Year" })
|
|
617
|
+
}), /* @__PURE__ */ jsx(SelectContent, { children: years.map((year, idx) => /* @__PURE__ */ jsx(SelectItem, {
|
|
618
|
+
value: year.toString(),
|
|
619
|
+
children: year
|
|
620
|
+
}, idx)) })]
|
|
621
|
+
})]
|
|
622
|
+
})]
|
|
623
|
+
}),
|
|
624
|
+
/* @__PURE__ */ jsx("div", {
|
|
625
|
+
className: "flex",
|
|
626
|
+
children: /* @__PURE__ */ jsx(Calendar$1, {
|
|
627
|
+
mode: "range",
|
|
628
|
+
defaultMonth: monthFrom,
|
|
629
|
+
month: monthFrom,
|
|
630
|
+
onMonthChange: setMonthFrom,
|
|
631
|
+
selected: pendingDate,
|
|
632
|
+
onSelect: handleDateSelect,
|
|
633
|
+
numberOfMonths,
|
|
634
|
+
showOutsideDays: false,
|
|
635
|
+
disabled: isDateDisabled,
|
|
636
|
+
fromDate: effectiveMinDate,
|
|
637
|
+
toDate: effectiveMaxDate,
|
|
638
|
+
className
|
|
639
|
+
})
|
|
640
|
+
}),
|
|
641
|
+
!closeOnSelect && /* @__PURE__ */ jsxs("div", {
|
|
642
|
+
className: "flex justify-end gap-2 border-t p-3",
|
|
643
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
644
|
+
variant: "outline",
|
|
645
|
+
size: "sm",
|
|
646
|
+
onClick: handleReset,
|
|
647
|
+
type: "button",
|
|
648
|
+
children: "Reset"
|
|
649
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
650
|
+
size: "sm",
|
|
651
|
+
onClick: handleApply,
|
|
652
|
+
type: "button",
|
|
653
|
+
children: "Apply"
|
|
654
|
+
})]
|
|
655
|
+
})
|
|
656
|
+
]
|
|
657
|
+
})]
|
|
658
|
+
})
|
|
659
|
+
})]
|
|
660
|
+
})] });
|
|
661
|
+
}
|
|
662
|
+
CalendarDatePicker.displayName = "CalendarDatePicker";
|
|
663
|
+
|
|
664
|
+
//#endregion
|
|
665
|
+
export { CalendarDatePicker as t };
|
|
@@ -30,8 +30,9 @@ interface CalendarDatePickerProps extends React.HTMLAttributes<HTMLButtonElement
|
|
|
30
30
|
disableFuture?: boolean;
|
|
31
31
|
disablePast?: boolean;
|
|
32
32
|
maxRange?: number;
|
|
33
|
+
popoverClassName?: string;
|
|
33
34
|
}
|
|
34
|
-
export declare function CalendarDatePicker({ ref, id, className, triggerClassName, date, closeOnSelect, numberOfMonths, yearsRange, onDateSelect, variant, placeholder, excludePresets, customPresets, minDate, maxDate, disableFuture, disablePast, maxRange, ...props }: CalendarDatePickerProps & {
|
|
35
|
+
export declare function CalendarDatePicker({ ref, id, className, triggerClassName, date, closeOnSelect, numberOfMonths, yearsRange, onDateSelect, variant, placeholder, excludePresets, customPresets, minDate, maxDate, disableFuture, disablePast, maxRange, popoverClassName, ...props }: CalendarDatePickerProps & {
|
|
35
36
|
ref?: React.RefObject<HTMLButtonElement | null>;
|
|
36
37
|
}): import("react/jsx-runtime").JSX.Element;
|
|
37
38
|
export declare namespace CalendarDatePicker {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar-date-picker.d.ts","sourceRoot":"","sources":["../../../../src/components/features/calendar-date-picker/calendar-date-picker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAiBjD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAsB9B,QAAA,MAAM,mBAAmB;;8EAiBxB,CAAA;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,IAAI,CAAA;IACX,GAAG,EAAE,IAAI,CAAA;CACV;AAED,UAAU,uBACR,SAAQ,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,YAAY,CAAC,OAAO,mBAAmB,CAAC;IACzF,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,IAAI,EAAE,SAAS,CAAA;IACf,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,cAAc,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,EAAE,EAAE,IAAI,CAAA;KAAE,GAAG,SAAS,KAAK,IAAI,CAAA;IACnE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,aAAa,CAAC,EAAE,eAAe,EAAE,CAAA;IAEjC,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"calendar-date-picker.d.ts","sourceRoot":"","sources":["../../../../src/components/features/calendar-date-picker/calendar-date-picker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAiBjD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAsB9B,QAAA,MAAM,mBAAmB;;8EAiBxB,CAAA;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,IAAI,CAAA;IACX,GAAG,EAAE,IAAI,CAAA;CACV;AAED,UAAU,uBACR,SAAQ,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,YAAY,CAAC,OAAO,mBAAmB,CAAC;IACzF,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,IAAI,EAAE,SAAS,CAAA;IACf,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,cAAc,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,EAAE,EAAE,IAAI,CAAA;KAAE,GAAG,SAAS,KAAK,IAAI,CAAA;IACnE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,aAAa,CAAC,EAAE,eAAe,EAAE,CAAA;IAEjC,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,wBAAgB,kBAAkB,CAAC,EAAE,GAAG,EAAE,EAA2B,EAAE,SAAS,EAAE,gBAAgB,EAAE,IAAI,EAAE,aAAqB,EAAE,cAAkB,EAAE,UAAe,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,aAAqB,EAAE,WAAmB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,KAAK,EAAE,EAAE,uBAAuB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAA;CAAE,2CA+xB3Z;yBA/xBe,kBAAkB"}
|