@pos-360/horizon 0.22.1 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-K67HDQZ5.mjs → chunk-252FLGXZ.mjs} +370 -4
- package/dist/chunk-252FLGXZ.mjs.map +1 -0
- package/dist/{chunk-CY7BVG4S.js → chunk-GF46A2DX.js} +372 -2
- package/dist/chunk-GF46A2DX.js.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +115 -99
- package/dist/index.mjs +1 -1
- package/dist/primitives.d.mts +46 -1
- package/dist/primitives.d.ts +46 -1
- package/dist/primitives.js +115 -99
- package/dist/primitives.mjs +1 -1
- package/package.json +2 -1
- package/dist/chunk-CY7BVG4S.js.map +0 -1
- package/dist/chunk-K67HDQZ5.mjs.map +0 -1
|
@@ -5,7 +5,7 @@ import { Slot } from '@radix-ui/react-slot';
|
|
|
5
5
|
import { cva } from 'class-variance-authority';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
7
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
8
|
-
import { Check, X, ChevronRight, Circle, ChevronDown, ChevronUp, Search, PenLine, SlidersHorizontal } from 'lucide-react';
|
|
8
|
+
import { Check, X, ChevronRight, Circle, ChevronDown, ChevronUp, Search, PenLine, SlidersHorizontal, CalendarIcon, ChevronLeft } from 'lucide-react';
|
|
9
9
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
10
10
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
11
11
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
@@ -15,6 +15,7 @@ import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
|
15
15
|
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
16
16
|
import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
|
|
17
17
|
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
18
|
+
import { endOfDay, startOfDay, endOfWeek, startOfWeek, endOfMonth, startOfMonth, subDays, subMonths, addMonths, subYears, isBefore, isSameDay, format, isSameMonth, eachDayOfInterval, isWithinInterval } from 'date-fns';
|
|
18
19
|
|
|
19
20
|
var buttonVariants = cva(
|
|
20
21
|
"group inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-hz-md text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
@@ -2066,7 +2067,372 @@ var Switch = React10.forwardRef(({ className, size, label, labelPosition = "righ
|
|
|
2066
2067
|
);
|
|
2067
2068
|
});
|
|
2068
2069
|
Switch.displayName = "Switch";
|
|
2070
|
+
var WEEKDAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
2071
|
+
function getCalendarDays(month) {
|
|
2072
|
+
const start = startOfWeek(startOfMonth(month), { weekStartsOn: 0 });
|
|
2073
|
+
const end = endOfWeek(endOfMonth(month), { weekStartsOn: 0 });
|
|
2074
|
+
return eachDayOfInterval({ start, end });
|
|
2075
|
+
}
|
|
2076
|
+
function CalendarMonth({
|
|
2077
|
+
month,
|
|
2078
|
+
range,
|
|
2079
|
+
hoverDate,
|
|
2080
|
+
onDayClick,
|
|
2081
|
+
onDayHover,
|
|
2082
|
+
onPrevMonth,
|
|
2083
|
+
onNextMonth,
|
|
2084
|
+
showPrevNav = true,
|
|
2085
|
+
showNextNav = true
|
|
2086
|
+
}) {
|
|
2087
|
+
const days = getCalendarDays(month);
|
|
2088
|
+
const today = /* @__PURE__ */ new Date();
|
|
2089
|
+
const getEffectiveTo = () => range.to ?? hoverDate;
|
|
2090
|
+
const isInRange = (date) => {
|
|
2091
|
+
const { from } = range;
|
|
2092
|
+
const effectiveTo = getEffectiveTo();
|
|
2093
|
+
if (!from || !effectiveTo) return false;
|
|
2094
|
+
const [start, end] = isBefore(from, effectiveTo) ? [from, effectiveTo] : [effectiveTo, from];
|
|
2095
|
+
return isWithinInterval(date, { start, end });
|
|
2096
|
+
};
|
|
2097
|
+
const isRangeStart = (date) => {
|
|
2098
|
+
const { from } = range;
|
|
2099
|
+
const effectiveTo = getEffectiveTo();
|
|
2100
|
+
if (!from) return false;
|
|
2101
|
+
if (!effectiveTo) return isSameDay(date, from);
|
|
2102
|
+
return isBefore(from, effectiveTo) ? isSameDay(date, from) : isSameDay(date, effectiveTo);
|
|
2103
|
+
};
|
|
2104
|
+
const isRangeEnd = (date) => {
|
|
2105
|
+
const { from } = range;
|
|
2106
|
+
const effectiveTo = getEffectiveTo();
|
|
2107
|
+
if (!from || !effectiveTo) return false;
|
|
2108
|
+
return isBefore(from, effectiveTo) ? isSameDay(date, effectiveTo) : isSameDay(date, from);
|
|
2109
|
+
};
|
|
2110
|
+
return /* @__PURE__ */ jsxs("div", { className: "w-[252px]", children: [
|
|
2111
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-3", children: [
|
|
2112
|
+
/* @__PURE__ */ jsx(
|
|
2113
|
+
"button",
|
|
2114
|
+
{
|
|
2115
|
+
onClick: onPrevMonth,
|
|
2116
|
+
className: cn(
|
|
2117
|
+
"p-1 rounded-md transition-colors",
|
|
2118
|
+
showPrevNav ? "hover:bg-gray-100 dark:hover:bg-neutral-700 text-gray-500 dark:text-gray-400" : "invisible pointer-events-none"
|
|
2119
|
+
),
|
|
2120
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "w-4 h-4" })
|
|
2121
|
+
}
|
|
2122
|
+
),
|
|
2123
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-semibold text-gray-900 dark:text-gray-100", children: format(month, "MMMM yyyy") }),
|
|
2124
|
+
/* @__PURE__ */ jsx(
|
|
2125
|
+
"button",
|
|
2126
|
+
{
|
|
2127
|
+
onClick: onNextMonth,
|
|
2128
|
+
className: cn(
|
|
2129
|
+
"p-1 rounded-md transition-colors",
|
|
2130
|
+
showNextNav ? "hover:bg-gray-100 dark:hover:bg-neutral-700 text-gray-500 dark:text-gray-400" : "invisible pointer-events-none"
|
|
2131
|
+
),
|
|
2132
|
+
children: /* @__PURE__ */ jsx(ChevronRight, { className: "w-4 h-4" })
|
|
2133
|
+
}
|
|
2134
|
+
)
|
|
2135
|
+
] }),
|
|
2136
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-7 mb-1", children: WEEKDAYS.map((day) => /* @__PURE__ */ jsx(
|
|
2137
|
+
"div",
|
|
2138
|
+
{
|
|
2139
|
+
className: "text-center text-xs font-medium text-gray-400 dark:text-gray-500 py-1",
|
|
2140
|
+
children: day
|
|
2141
|
+
},
|
|
2142
|
+
day
|
|
2143
|
+
)) }),
|
|
2144
|
+
/* @__PURE__ */ jsx(
|
|
2145
|
+
"div",
|
|
2146
|
+
{
|
|
2147
|
+
className: "grid grid-cols-7",
|
|
2148
|
+
onMouseLeave: () => onDayHover(void 0),
|
|
2149
|
+
children: days.map((day, idx) => {
|
|
2150
|
+
const outside = !isSameMonth(day, month);
|
|
2151
|
+
const inRange = !outside && isInRange(day);
|
|
2152
|
+
const rangeStart = !outside && isRangeStart(day);
|
|
2153
|
+
const rangeEnd = !outside && isRangeEnd(day);
|
|
2154
|
+
const isToday = isSameDay(day, today);
|
|
2155
|
+
return /* @__PURE__ */ jsx(
|
|
2156
|
+
"div",
|
|
2157
|
+
{
|
|
2158
|
+
className: cn(
|
|
2159
|
+
"h-9 flex items-center justify-center",
|
|
2160
|
+
(inRange || rangeStart || rangeEnd) && "bg-blue-50 dark:bg-blue-950/40",
|
|
2161
|
+
rangeStart && !rangeEnd && "rounded-l-full",
|
|
2162
|
+
rangeEnd && !rangeStart && "rounded-r-full",
|
|
2163
|
+
rangeStart && rangeEnd && "rounded-full"
|
|
2164
|
+
),
|
|
2165
|
+
children: /* @__PURE__ */ jsx(
|
|
2166
|
+
"button",
|
|
2167
|
+
{
|
|
2168
|
+
onClick: () => !outside && onDayClick(day),
|
|
2169
|
+
onMouseEnter: () => !outside && onDayHover(day),
|
|
2170
|
+
tabIndex: outside ? -1 : 0,
|
|
2171
|
+
className: cn(
|
|
2172
|
+
"w-8 h-8 rounded-full text-sm flex items-center justify-center transition-colors",
|
|
2173
|
+
outside && "text-gray-300 dark:text-gray-600 pointer-events-none",
|
|
2174
|
+
!outside && !rangeStart && !rangeEnd && "text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-neutral-700",
|
|
2175
|
+
!outside && inRange && !rangeStart && !rangeEnd && "text-blue-700 dark:text-blue-300 hover:bg-blue-100 dark:hover:bg-blue-900/50",
|
|
2176
|
+
(rangeStart || rangeEnd) && "bg-blue-600 text-white hover:bg-blue-700 dark:hover:bg-blue-500",
|
|
2177
|
+
isToday && !rangeStart && !rangeEnd && !outside && "font-bold"
|
|
2178
|
+
),
|
|
2179
|
+
children: format(day, "d")
|
|
2180
|
+
}
|
|
2181
|
+
)
|
|
2182
|
+
},
|
|
2183
|
+
idx
|
|
2184
|
+
);
|
|
2185
|
+
})
|
|
2186
|
+
}
|
|
2187
|
+
)
|
|
2188
|
+
] });
|
|
2189
|
+
}
|
|
2190
|
+
var DEFAULT_PRESETS = [
|
|
2191
|
+
{
|
|
2192
|
+
label: "Today",
|
|
2193
|
+
getRange: () => ({
|
|
2194
|
+
from: startOfDay(/* @__PURE__ */ new Date()),
|
|
2195
|
+
to: endOfDay(/* @__PURE__ */ new Date())
|
|
2196
|
+
})
|
|
2197
|
+
},
|
|
2198
|
+
{
|
|
2199
|
+
label: "Yesterday",
|
|
2200
|
+
getRange: () => {
|
|
2201
|
+
const d = subDays(/* @__PURE__ */ new Date(), 1);
|
|
2202
|
+
return { from: startOfDay(d), to: endOfDay(d) };
|
|
2203
|
+
}
|
|
2204
|
+
},
|
|
2205
|
+
{
|
|
2206
|
+
label: "This Week",
|
|
2207
|
+
getRange: () => ({
|
|
2208
|
+
from: startOfWeek(/* @__PURE__ */ new Date(), { weekStartsOn: 0 }),
|
|
2209
|
+
to: endOfWeek(/* @__PURE__ */ new Date(), { weekStartsOn: 0 })
|
|
2210
|
+
})
|
|
2211
|
+
},
|
|
2212
|
+
{
|
|
2213
|
+
label: "Last Week",
|
|
2214
|
+
getRange: () => {
|
|
2215
|
+
const d = subDays(/* @__PURE__ */ new Date(), 7);
|
|
2216
|
+
return {
|
|
2217
|
+
from: startOfWeek(d, { weekStartsOn: 0 }),
|
|
2218
|
+
to: endOfWeek(d, { weekStartsOn: 0 })
|
|
2219
|
+
};
|
|
2220
|
+
}
|
|
2221
|
+
},
|
|
2222
|
+
{
|
|
2223
|
+
label: "This Month",
|
|
2224
|
+
getRange: () => ({
|
|
2225
|
+
from: startOfMonth(/* @__PURE__ */ new Date()),
|
|
2226
|
+
to: endOfMonth(/* @__PURE__ */ new Date())
|
|
2227
|
+
})
|
|
2228
|
+
},
|
|
2229
|
+
{
|
|
2230
|
+
label: "Last Month",
|
|
2231
|
+
getRange: () => {
|
|
2232
|
+
const d = subMonths(/* @__PURE__ */ new Date(), 1);
|
|
2233
|
+
return { from: startOfMonth(d), to: endOfMonth(d) };
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
];
|
|
2237
|
+
function formatDateRange(range, placeholder) {
|
|
2238
|
+
if (!range?.from) return placeholder;
|
|
2239
|
+
if (!range.to || isSameDay(range.from, range.to)) {
|
|
2240
|
+
return format(range.from, "MMM d, yyyy");
|
|
2241
|
+
}
|
|
2242
|
+
const sameYear = range.from.getFullYear() === range.to.getFullYear();
|
|
2243
|
+
if (sameYear) {
|
|
2244
|
+
return `${format(range.from, "MMM d")} \u2013 ${format(range.to, "MMM d, yyyy")}`;
|
|
2245
|
+
}
|
|
2246
|
+
return `${format(range.from, "MMM d, yyyy")} \u2013 ${format(range.to, "MMM d, yyyy")}`;
|
|
2247
|
+
}
|
|
2248
|
+
function DateRangePicker({
|
|
2249
|
+
value,
|
|
2250
|
+
onChange,
|
|
2251
|
+
presets = DEFAULT_PRESETS,
|
|
2252
|
+
placeholder = "Select date range",
|
|
2253
|
+
disabled = false,
|
|
2254
|
+
align = "start",
|
|
2255
|
+
className
|
|
2256
|
+
}) {
|
|
2257
|
+
const [open, setOpen] = React10.useState(false);
|
|
2258
|
+
const [internalRange, setInternalRange] = React10.useState({
|
|
2259
|
+
from: void 0,
|
|
2260
|
+
to: void 0
|
|
2261
|
+
});
|
|
2262
|
+
const [hoverDate, setHoverDate] = React10.useState();
|
|
2263
|
+
const [leftMonth, setLeftMonth] = React10.useState(
|
|
2264
|
+
() => startOfMonth(value?.from ?? /* @__PURE__ */ new Date())
|
|
2265
|
+
);
|
|
2266
|
+
const [activePreset, setActivePreset] = React10.useState();
|
|
2267
|
+
const range = value ?? internalRange;
|
|
2268
|
+
const handleDayClick = (date) => {
|
|
2269
|
+
const { from, to } = range;
|
|
2270
|
+
if (!from || from && to) {
|
|
2271
|
+
const newRange2 = { from: date, to: void 0 };
|
|
2272
|
+
setActivePreset(void 0);
|
|
2273
|
+
if (onChange) onChange(newRange2);
|
|
2274
|
+
else setInternalRange(newRange2);
|
|
2275
|
+
return;
|
|
2276
|
+
}
|
|
2277
|
+
const [start, end] = isBefore(from, date) ? [from, date] : [date, from];
|
|
2278
|
+
const newRange = { from: start, to: end };
|
|
2279
|
+
if (onChange) onChange(newRange);
|
|
2280
|
+
else setInternalRange(newRange);
|
|
2281
|
+
setHoverDate(void 0);
|
|
2282
|
+
setOpen(false);
|
|
2283
|
+
};
|
|
2284
|
+
const handlePreset = (preset) => {
|
|
2285
|
+
const newRange = preset.getRange();
|
|
2286
|
+
if (onChange) onChange(newRange);
|
|
2287
|
+
else setInternalRange(newRange);
|
|
2288
|
+
setActivePreset(preset.label);
|
|
2289
|
+
if (newRange.from) setLeftMonth(startOfMonth(newRange.from));
|
|
2290
|
+
setOpen(false);
|
|
2291
|
+
};
|
|
2292
|
+
const rightMonth = addMonths(leftMonth, 1);
|
|
2293
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
2294
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
2295
|
+
"button",
|
|
2296
|
+
{
|
|
2297
|
+
disabled,
|
|
2298
|
+
className: cn(
|
|
2299
|
+
"inline-flex items-center gap-2 rounded-md border border-gray-300 bg-white px-3 py-2 text-sm shadow-sm transition-colors",
|
|
2300
|
+
"hover:bg-gray-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2",
|
|
2301
|
+
"dark:border-neutral-600 dark:bg-neutral-800 dark:hover:bg-neutral-700",
|
|
2302
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
2303
|
+
range.from ? "text-gray-900 dark:text-gray-100" : "text-gray-400 dark:text-gray-500",
|
|
2304
|
+
className
|
|
2305
|
+
),
|
|
2306
|
+
children: [
|
|
2307
|
+
/* @__PURE__ */ jsx(CalendarIcon, { className: "w-4 h-4 shrink-0 text-gray-400 dark:text-gray-500" }),
|
|
2308
|
+
/* @__PURE__ */ jsx("span", { children: formatDateRange(range, placeholder) })
|
|
2309
|
+
]
|
|
2310
|
+
}
|
|
2311
|
+
) }),
|
|
2312
|
+
/* @__PURE__ */ jsx(PopoverContent, { align, className: "w-auto p-0 overflow-hidden", children: /* @__PURE__ */ jsxs("div", { className: "flex divide-x divide-gray-100 dark:divide-neutral-700", children: [
|
|
2313
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col p-3 gap-0.5 min-w-[130px]", children: [
|
|
2314
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase tracking-wider mb-2 px-2", children: "Presets" }),
|
|
2315
|
+
presets.map((preset) => /* @__PURE__ */ jsx(
|
|
2316
|
+
"button",
|
|
2317
|
+
{
|
|
2318
|
+
onClick: () => handlePreset(preset),
|
|
2319
|
+
className: cn(
|
|
2320
|
+
"w-full text-left px-2 py-1.5 rounded-md text-sm transition-colors",
|
|
2321
|
+
activePreset === preset.label ? "bg-blue-50 text-blue-600 font-medium dark:bg-blue-950/50 dark:text-blue-400" : "text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-neutral-700"
|
|
2322
|
+
),
|
|
2323
|
+
children: preset.label
|
|
2324
|
+
},
|
|
2325
|
+
preset.label
|
|
2326
|
+
))
|
|
2327
|
+
] }),
|
|
2328
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-4 p-4", children: [
|
|
2329
|
+
/* @__PURE__ */ jsx(
|
|
2330
|
+
CalendarMonth,
|
|
2331
|
+
{
|
|
2332
|
+
month: leftMonth,
|
|
2333
|
+
range,
|
|
2334
|
+
hoverDate,
|
|
2335
|
+
onDayClick: handleDayClick,
|
|
2336
|
+
onDayHover: setHoverDate,
|
|
2337
|
+
onPrevMonth: () => setLeftMonth(subMonths(leftMonth, 1)),
|
|
2338
|
+
showPrevNav: true,
|
|
2339
|
+
showNextNav: false
|
|
2340
|
+
}
|
|
2341
|
+
),
|
|
2342
|
+
/* @__PURE__ */ jsx("div", { className: "w-px bg-gray-100 dark:bg-neutral-700 self-stretch" }),
|
|
2343
|
+
/* @__PURE__ */ jsx(
|
|
2344
|
+
CalendarMonth,
|
|
2345
|
+
{
|
|
2346
|
+
month: rightMonth,
|
|
2347
|
+
range,
|
|
2348
|
+
hoverDate,
|
|
2349
|
+
onDayClick: handleDayClick,
|
|
2350
|
+
onDayHover: setHoverDate,
|
|
2351
|
+
onNextMonth: () => setLeftMonth(addMonths(leftMonth, 1)),
|
|
2352
|
+
showPrevNav: false,
|
|
2353
|
+
showNextNav: true
|
|
2354
|
+
}
|
|
2355
|
+
)
|
|
2356
|
+
] })
|
|
2357
|
+
] }) })
|
|
2358
|
+
] });
|
|
2359
|
+
}
|
|
2360
|
+
var DEFAULT_COMPARISON_PERIODS = [
|
|
2361
|
+
{
|
|
2362
|
+
key: "yesterday",
|
|
2363
|
+
label: "vs. Yesterday",
|
|
2364
|
+
getRange: () => {
|
|
2365
|
+
const d = subDays(/* @__PURE__ */ new Date(), 1);
|
|
2366
|
+
return { from: startOfDay(d), to: endOfDay(d) };
|
|
2367
|
+
}
|
|
2368
|
+
},
|
|
2369
|
+
{
|
|
2370
|
+
key: "last-week",
|
|
2371
|
+
label: "vs. Last Week",
|
|
2372
|
+
getRange: () => {
|
|
2373
|
+
const d = subDays(/* @__PURE__ */ new Date(), 7);
|
|
2374
|
+
return {
|
|
2375
|
+
from: startOfWeek(d, { weekStartsOn: 0 }),
|
|
2376
|
+
to: endOfWeek(d, { weekStartsOn: 0 })
|
|
2377
|
+
};
|
|
2378
|
+
}
|
|
2379
|
+
},
|
|
2380
|
+
{
|
|
2381
|
+
key: "last-month",
|
|
2382
|
+
label: "vs. Last Month",
|
|
2383
|
+
getRange: () => {
|
|
2384
|
+
const d = subMonths(/* @__PURE__ */ new Date(), 1);
|
|
2385
|
+
return { from: startOfMonth(d), to: endOfMonth(d) };
|
|
2386
|
+
}
|
|
2387
|
+
},
|
|
2388
|
+
{
|
|
2389
|
+
key: "last-year",
|
|
2390
|
+
label: "vs. Last Year",
|
|
2391
|
+
getRange: () => {
|
|
2392
|
+
const d = subYears(/* @__PURE__ */ new Date(), 1);
|
|
2393
|
+
return {
|
|
2394
|
+
from: startOfDay(new Date(d.getFullYear(), 0, 1)),
|
|
2395
|
+
to: endOfDay(new Date(d.getFullYear(), 11, 31))
|
|
2396
|
+
};
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
];
|
|
2400
|
+
var AUTO_SWITCH_THRESHOLD = 4;
|
|
2401
|
+
function PeriodComparisonSelector({
|
|
2402
|
+
value,
|
|
2403
|
+
onChange,
|
|
2404
|
+
options = DEFAULT_COMPARISON_PERIODS,
|
|
2405
|
+
mode,
|
|
2406
|
+
size = "default",
|
|
2407
|
+
placeholder = "Compare to...",
|
|
2408
|
+
disabled = false,
|
|
2409
|
+
className
|
|
2410
|
+
}) {
|
|
2411
|
+
const resolvedMode = mode ?? (options.length <= AUTO_SWITCH_THRESHOLD ? "segmented" : "select");
|
|
2412
|
+
const handleChange = (key) => {
|
|
2413
|
+
const period = options.find((o) => o.key === key);
|
|
2414
|
+
if (period) onChange?.(key, period);
|
|
2415
|
+
};
|
|
2416
|
+
if (resolvedMode === "segmented") {
|
|
2417
|
+
return /* @__PURE__ */ jsx(
|
|
2418
|
+
SegmentedControl,
|
|
2419
|
+
{
|
|
2420
|
+
options: options.map((o) => ({ label: o.label, value: o.key })),
|
|
2421
|
+
value,
|
|
2422
|
+
onChange: handleChange,
|
|
2423
|
+
size,
|
|
2424
|
+
radius: "md",
|
|
2425
|
+
disabled,
|
|
2426
|
+
className
|
|
2427
|
+
}
|
|
2428
|
+
);
|
|
2429
|
+
}
|
|
2430
|
+
return /* @__PURE__ */ jsxs(Select, { value, onValueChange: handleChange, disabled, children: [
|
|
2431
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className, children: /* @__PURE__ */ jsx(SelectValue, { placeholder, children: options.find((o) => o.key === value)?.label }) }),
|
|
2432
|
+
/* @__PURE__ */ jsx(SelectContent, { children: options.map((o) => /* @__PURE__ */ jsx(SelectItem, { value: o.key, children: o.label }, o.key)) })
|
|
2433
|
+
] });
|
|
2434
|
+
}
|
|
2069
2435
|
|
|
2070
|
-
export { Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, ColumnSelection, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Form, FormControl, FormDescription, FormField, FormLabel, FormMessage, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, SegmentedControl, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator3 as Separator, Skeleton, SkeletonAvatar, SkeletonBadge, SkeletonButton, SkeletonCard, SkeletonIcon, SkeletonInput, SkeletonSubtitle, SkeletonTableRow, SkeletonTableRows, SkeletonText, SkeletonTitle, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, TableRowCheckbox, TableSelectAll, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toggle, buttonVariants, segmentedControlItemVariants, segmentedControlVariants, separatorVariants, switchLabelVariants, switchThumbVariants, switchTrackVariants, toggleGroupVariants, toggleItemVariants, useColumnVisibility, useFormContext, useFormFieldContext, useTableSelection };
|
|
2071
|
-
//# sourceMappingURL=chunk-
|
|
2072
|
-
//# sourceMappingURL=chunk-
|
|
2436
|
+
export { Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, ColumnSelection, DEFAULT_COMPARISON_PERIODS, DEFAULT_PRESETS, DateRangePicker, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Form, FormControl, FormDescription, FormField, FormLabel, FormMessage, PeriodComparisonSelector, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, SegmentedControl, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator3 as Separator, Skeleton, SkeletonAvatar, SkeletonBadge, SkeletonButton, SkeletonCard, SkeletonIcon, SkeletonInput, SkeletonSubtitle, SkeletonTableRow, SkeletonTableRows, SkeletonText, SkeletonTitle, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, TableRowCheckbox, TableSelectAll, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toggle, buttonVariants, segmentedControlItemVariants, segmentedControlVariants, separatorVariants, switchLabelVariants, switchThumbVariants, switchTrackVariants, toggleGroupVariants, toggleItemVariants, useColumnVisibility, useFormContext, useFormFieldContext, useTableSelection };
|
|
2437
|
+
//# sourceMappingURL=chunk-252FLGXZ.mjs.map
|
|
2438
|
+
//# sourceMappingURL=chunk-252FLGXZ.mjs.map
|