@pos-360/horizon 0.27.1 → 0.28.1
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-5XF7Y25B.js → chunk-23BJPJOK.js} +14 -2
- package/dist/chunk-23BJPJOK.js.map +1 -0
- package/dist/{chunk-BFDGIY6V.mjs → chunk-6O2HW4YY.mjs} +3 -3
- package/dist/{chunk-BFDGIY6V.mjs.map → chunk-6O2HW4YY.mjs.map} +1 -1
- package/dist/{chunk-UQ66UPWH.mjs → chunk-EZDGMHS7.mjs} +14 -3
- package/dist/chunk-EZDGMHS7.mjs.map +1 -0
- package/dist/{chunk-JP5BJYYD.js → chunk-JI2LA5FH.js} +462 -104
- package/dist/chunk-JI2LA5FH.js.map +1 -0
- package/dist/{chunk-2LATCE3V.mjs → chunk-QJMRQP66.mjs} +373 -16
- package/dist/chunk-QJMRQP66.mjs.map +1 -0
- package/dist/{chunk-3LLPK34Q.js → chunk-U2XUN4SS.js} +83 -83
- package/dist/{chunk-3LLPK34Q.js.map → chunk-U2XUN4SS.js.map} +1 -1
- package/dist/enhanced.js +32 -32
- package/dist/enhanced.mjs +2 -2
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +157 -149
- package/dist/index.mjs +3 -3
- package/dist/primitives.d.mts +18 -2
- package/dist/primitives.d.ts +18 -2
- package/dist/primitives.js +121 -117
- package/dist/primitives.mjs +2 -2
- package/package.json +1 -1
- package/dist/chunk-2LATCE3V.mjs.map +0 -1
- package/dist/chunk-5XF7Y25B.js.map +0 -1
- package/dist/chunk-JP5BJYYD.js.map +0 -1
- package/dist/chunk-UQ66UPWH.mjs.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { cn, Label, Tooltip } from './chunk-
|
|
1
|
+
import { cn, Label, Tooltip, mergeRefs } from './chunk-EZDGMHS7.mjs';
|
|
2
2
|
import * as React10 from 'react';
|
|
3
3
|
import { useState, useEffect, useCallback } from 'react';
|
|
4
4
|
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, Minus, PenLine, SlidersHorizontal, CalendarIcon, ChevronLeft } from 'lucide-react';
|
|
8
|
+
import { Check, X, ChevronRight, Circle, ChevronDown, ChevronUp, Search, Minus, PenLine, SlidersHorizontal, CalendarIcon, ChevronLeft, Clock } 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';
|
|
@@ -2079,6 +2079,311 @@ var Switch = React10.forwardRef(({ className, size, label, labelPosition = "righ
|
|
|
2079
2079
|
);
|
|
2080
2080
|
});
|
|
2081
2081
|
Switch.displayName = "Switch";
|
|
2082
|
+
var DEFAULT_TIME_RANGE = {
|
|
2083
|
+
from: { hour: null, minute: null },
|
|
2084
|
+
to: { hour: null, minute: null }
|
|
2085
|
+
};
|
|
2086
|
+
function isTimeSet(tv) {
|
|
2087
|
+
return tv.hour !== null && tv.minute !== null;
|
|
2088
|
+
}
|
|
2089
|
+
function to12Hour(hour24) {
|
|
2090
|
+
if (hour24 === null) return { hour12: null, period: "AM" };
|
|
2091
|
+
const period = hour24 >= 12 ? "PM" : "AM";
|
|
2092
|
+
const hour12 = hour24 % 12 || 12;
|
|
2093
|
+
return { hour12, period };
|
|
2094
|
+
}
|
|
2095
|
+
function to24Hour(hour12, period) {
|
|
2096
|
+
if (period === "AM") return hour12 === 12 ? 0 : hour12;
|
|
2097
|
+
return hour12 === 12 ? 12 : hour12 + 12;
|
|
2098
|
+
}
|
|
2099
|
+
function pad(n) {
|
|
2100
|
+
return n.toString().padStart(2, "0");
|
|
2101
|
+
}
|
|
2102
|
+
function clamp(val, min, max) {
|
|
2103
|
+
return Math.max(min, Math.min(max, val));
|
|
2104
|
+
}
|
|
2105
|
+
function TimeInput({
|
|
2106
|
+
value,
|
|
2107
|
+
min,
|
|
2108
|
+
max,
|
|
2109
|
+
onChange,
|
|
2110
|
+
onComplete,
|
|
2111
|
+
inputRef,
|
|
2112
|
+
disabled = false,
|
|
2113
|
+
"aria-label": ariaLabel
|
|
2114
|
+
}) {
|
|
2115
|
+
const [editValue, setEditValue] = React10.useState(null);
|
|
2116
|
+
const internalRef = React10.useRef(null);
|
|
2117
|
+
const committedRef = React10.useRef(false);
|
|
2118
|
+
const setRefs = React10.useCallback(mergeRefs(internalRef, inputRef), [inputRef]);
|
|
2119
|
+
const handleChange = (e) => {
|
|
2120
|
+
const raw = e.target.value.replace(/\D/g, "").slice(0, 2);
|
|
2121
|
+
if (raw === "") {
|
|
2122
|
+
setEditValue(raw);
|
|
2123
|
+
return;
|
|
2124
|
+
}
|
|
2125
|
+
const parsed = parseInt(raw, 10);
|
|
2126
|
+
const clamped = clamp(parsed, min, max);
|
|
2127
|
+
const display = parsed !== clamped ? pad(clamped) : raw;
|
|
2128
|
+
setEditValue(display);
|
|
2129
|
+
if (raw.length === 2) {
|
|
2130
|
+
committedRef.current = true;
|
|
2131
|
+
onChange(clamped);
|
|
2132
|
+
setEditValue(null);
|
|
2133
|
+
onComplete?.();
|
|
2134
|
+
}
|
|
2135
|
+
};
|
|
2136
|
+
const commit = () => {
|
|
2137
|
+
if (committedRef.current) {
|
|
2138
|
+
committedRef.current = false;
|
|
2139
|
+
setEditValue(null);
|
|
2140
|
+
return;
|
|
2141
|
+
}
|
|
2142
|
+
if (editValue === null) return;
|
|
2143
|
+
if (editValue === "") {
|
|
2144
|
+
setEditValue(null);
|
|
2145
|
+
return;
|
|
2146
|
+
}
|
|
2147
|
+
const parsed = parseInt(editValue, 10);
|
|
2148
|
+
if (!isNaN(parsed)) {
|
|
2149
|
+
onChange(clamp(parsed, min, max));
|
|
2150
|
+
}
|
|
2151
|
+
setEditValue(null);
|
|
2152
|
+
};
|
|
2153
|
+
const handleKeyDown = (e) => {
|
|
2154
|
+
if (e.key === "Enter") {
|
|
2155
|
+
commit();
|
|
2156
|
+
internalRef.current?.blur();
|
|
2157
|
+
} else if (e.key === "Escape") {
|
|
2158
|
+
setEditValue(null);
|
|
2159
|
+
internalRef.current?.blur();
|
|
2160
|
+
} else if (e.key === "ArrowUp") {
|
|
2161
|
+
e.preventDefault();
|
|
2162
|
+
const curr = value ?? min;
|
|
2163
|
+
const next = curr >= max ? min : curr + 1;
|
|
2164
|
+
onChange(next);
|
|
2165
|
+
setEditValue(pad(next));
|
|
2166
|
+
} else if (e.key === "ArrowDown") {
|
|
2167
|
+
e.preventDefault();
|
|
2168
|
+
const curr = value ?? max;
|
|
2169
|
+
const next = curr <= min ? max : curr - 1;
|
|
2170
|
+
onChange(next);
|
|
2171
|
+
setEditValue(pad(next));
|
|
2172
|
+
}
|
|
2173
|
+
};
|
|
2174
|
+
return /* @__PURE__ */ jsx(
|
|
2175
|
+
"input",
|
|
2176
|
+
{
|
|
2177
|
+
ref: setRefs,
|
|
2178
|
+
type: "text",
|
|
2179
|
+
inputMode: "numeric",
|
|
2180
|
+
"aria-label": ariaLabel,
|
|
2181
|
+
disabled,
|
|
2182
|
+
value: editValue ?? (value === null ? "--" : pad(value)),
|
|
2183
|
+
onChange: handleChange,
|
|
2184
|
+
onFocus: (e) => {
|
|
2185
|
+
setEditValue("");
|
|
2186
|
+
requestAnimationFrame(() => e.target.select());
|
|
2187
|
+
},
|
|
2188
|
+
onBlur: () => commit(),
|
|
2189
|
+
onKeyDown: handleKeyDown,
|
|
2190
|
+
className: cn(
|
|
2191
|
+
"w-9 h-8 rounded-md border text-center text-sm tabular-nums font-medium outline-none transition-colors",
|
|
2192
|
+
"bg-white border-gray-200 text-gray-600",
|
|
2193
|
+
"focus:border-blue-500 focus:ring-1 focus:ring-blue-500/30 focus:text-gray-700",
|
|
2194
|
+
"dark:bg-neutral-800 dark:border-neutral-600 dark:text-gray-100",
|
|
2195
|
+
"dark:focus:border-blue-400 dark:focus:ring-blue-400/30",
|
|
2196
|
+
disabled && "opacity-40 cursor-not-allowed bg-gray-50 dark:bg-neutral-900"
|
|
2197
|
+
)
|
|
2198
|
+
}
|
|
2199
|
+
);
|
|
2200
|
+
}
|
|
2201
|
+
function PeriodToggle({ value, onChange, disabled = false }) {
|
|
2202
|
+
return /* @__PURE__ */ jsx(
|
|
2203
|
+
"div",
|
|
2204
|
+
{
|
|
2205
|
+
className: cn(
|
|
2206
|
+
"inline-flex rounded-md border overflow-hidden",
|
|
2207
|
+
disabled && "opacity-40 cursor-not-allowed",
|
|
2208
|
+
"border-gray-200 dark:border-neutral-600"
|
|
2209
|
+
),
|
|
2210
|
+
children: ["AM", "PM"].map((p) => /* @__PURE__ */ jsx(
|
|
2211
|
+
"button",
|
|
2212
|
+
{
|
|
2213
|
+
type: "button",
|
|
2214
|
+
disabled,
|
|
2215
|
+
onClick: () => onChange(p),
|
|
2216
|
+
className: cn(
|
|
2217
|
+
"px-2 h-8 text-xs font-semibold tracking-wide transition-colors",
|
|
2218
|
+
"disabled:pointer-events-none",
|
|
2219
|
+
value === p ? "!bg-blue-600 !text-white dark:!bg-blue-500" : "bg-white text-gray-500 hover:bg-gray-50 hover:text-gray-600 dark:bg-neutral-800 dark:text-gray-400 dark:hover:bg-neutral-700"
|
|
2220
|
+
),
|
|
2221
|
+
children: p
|
|
2222
|
+
},
|
|
2223
|
+
p
|
|
2224
|
+
))
|
|
2225
|
+
}
|
|
2226
|
+
);
|
|
2227
|
+
}
|
|
2228
|
+
function TimeField({
|
|
2229
|
+
label,
|
|
2230
|
+
value,
|
|
2231
|
+
onChange,
|
|
2232
|
+
hourRef,
|
|
2233
|
+
minuteRef,
|
|
2234
|
+
onMinuteComplete,
|
|
2235
|
+
disabled = false
|
|
2236
|
+
}) {
|
|
2237
|
+
const { hour12, period } = to12Hour(value.hour);
|
|
2238
|
+
const minuteInputRef = React10.useRef(null);
|
|
2239
|
+
const mergedMinuteRef = React10.useCallback(mergeRefs(minuteInputRef, minuteRef), [minuteRef]);
|
|
2240
|
+
const handleHourChange = (newHour12) => {
|
|
2241
|
+
onChange({ ...value, hour: to24Hour(newHour12, period) });
|
|
2242
|
+
};
|
|
2243
|
+
const handleMinuteChange = (newMinute) => {
|
|
2244
|
+
onChange({ ...value, minute: newMinute });
|
|
2245
|
+
};
|
|
2246
|
+
const handlePeriodChange = (newPeriod) => {
|
|
2247
|
+
if (hour12 === null) return;
|
|
2248
|
+
onChange({ ...value, hour: to24Hour(hour12, newPeriod) });
|
|
2249
|
+
};
|
|
2250
|
+
const focusMinute = () => {
|
|
2251
|
+
minuteInputRef.current?.focus();
|
|
2252
|
+
};
|
|
2253
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
2254
|
+
/* @__PURE__ */ jsx(
|
|
2255
|
+
"span",
|
|
2256
|
+
{
|
|
2257
|
+
className: cn(
|
|
2258
|
+
"text-xs font-semibold uppercase tracking-wider",
|
|
2259
|
+
disabled ? "text-gray-300 dark:text-gray-600" : "text-gray-400 dark:text-gray-500"
|
|
2260
|
+
),
|
|
2261
|
+
children: label
|
|
2262
|
+
}
|
|
2263
|
+
),
|
|
2264
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
2265
|
+
/* @__PURE__ */ jsx(
|
|
2266
|
+
TimeInput,
|
|
2267
|
+
{
|
|
2268
|
+
value: hour12,
|
|
2269
|
+
min: 1,
|
|
2270
|
+
max: 12,
|
|
2271
|
+
onChange: handleHourChange,
|
|
2272
|
+
onComplete: focusMinute,
|
|
2273
|
+
inputRef: hourRef,
|
|
2274
|
+
disabled,
|
|
2275
|
+
"aria-label": `${label} hour`
|
|
2276
|
+
}
|
|
2277
|
+
),
|
|
2278
|
+
/* @__PURE__ */ jsx(
|
|
2279
|
+
"span",
|
|
2280
|
+
{
|
|
2281
|
+
className: cn(
|
|
2282
|
+
"text-sm font-bold select-none",
|
|
2283
|
+
disabled ? "text-gray-300 dark:text-gray-600" : "text-gray-400 dark:text-gray-500"
|
|
2284
|
+
),
|
|
2285
|
+
children: ":"
|
|
2286
|
+
}
|
|
2287
|
+
),
|
|
2288
|
+
/* @__PURE__ */ jsx(
|
|
2289
|
+
TimeInput,
|
|
2290
|
+
{
|
|
2291
|
+
value: value.minute,
|
|
2292
|
+
min: 0,
|
|
2293
|
+
max: 59,
|
|
2294
|
+
onChange: handleMinuteChange,
|
|
2295
|
+
onComplete: onMinuteComplete,
|
|
2296
|
+
inputRef: mergedMinuteRef,
|
|
2297
|
+
disabled,
|
|
2298
|
+
"aria-label": `${label} minute`
|
|
2299
|
+
}
|
|
2300
|
+
),
|
|
2301
|
+
/* @__PURE__ */ jsx(
|
|
2302
|
+
PeriodToggle,
|
|
2303
|
+
{
|
|
2304
|
+
value: period,
|
|
2305
|
+
onChange: handlePeriodChange,
|
|
2306
|
+
disabled
|
|
2307
|
+
}
|
|
2308
|
+
)
|
|
2309
|
+
] })
|
|
2310
|
+
] });
|
|
2311
|
+
}
|
|
2312
|
+
function TimePickerRow({ value, onChange, disabled = false }) {
|
|
2313
|
+
const toHourRef = React10.useRef(null);
|
|
2314
|
+
const fromSet = isTimeSet(value.from);
|
|
2315
|
+
const toSet = isTimeSet(value.to);
|
|
2316
|
+
const bothSet = fromSet && toSet;
|
|
2317
|
+
const fromMinutes = (value.from.hour ?? 0) * 60 + (value.from.minute ?? 0);
|
|
2318
|
+
const toMinutes = (value.to.hour ?? 0) * 60 + (value.to.minute ?? 0);
|
|
2319
|
+
const bothEqual = fromMinutes === toMinutes;
|
|
2320
|
+
const isOvernight = bothSet && toMinutes < fromMinutes;
|
|
2321
|
+
const durationMinutes = bothSet && !bothEqual ? isOvernight ? 24 * 60 - fromMinutes + toMinutes : toMinutes - fromMinutes : 0;
|
|
2322
|
+
const durationHours = Math.floor(durationMinutes / 60);
|
|
2323
|
+
const durationRemaining = durationMinutes % 60;
|
|
2324
|
+
const showDuration = bothSet && !bothEqual;
|
|
2325
|
+
const durationLabel = durationRemaining > 0 ? `${durationHours}h ${durationRemaining}m window${isOvernight ? " (overnight)" : ""}` : `${durationHours}h window${isOvernight ? " (overnight)" : ""}`;
|
|
2326
|
+
return /* @__PURE__ */ jsx(
|
|
2327
|
+
"div",
|
|
2328
|
+
{
|
|
2329
|
+
className: cn(
|
|
2330
|
+
"flex flex-col px-4 pt-2 pb-3 gap-1",
|
|
2331
|
+
"border-t border-gray-100 dark:border-neutral-700"
|
|
2332
|
+
),
|
|
2333
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
|
|
2334
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-1", children: [
|
|
2335
|
+
/* @__PURE__ */ jsx(
|
|
2336
|
+
Clock,
|
|
2337
|
+
{
|
|
2338
|
+
className: cn(
|
|
2339
|
+
"w-4 h-4 shrink-0",
|
|
2340
|
+
disabled ? "text-gray-300 dark:text-gray-600" : "text-gray-400 dark:text-gray-500"
|
|
2341
|
+
)
|
|
2342
|
+
}
|
|
2343
|
+
),
|
|
2344
|
+
/* @__PURE__ */ jsx("span", { className: "text-[9px] font-medium text-gray-300 dark:text-gray-600 tracking-wide", children: "OPT" })
|
|
2345
|
+
] }),
|
|
2346
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 flex-1", children: [
|
|
2347
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-5", children: [
|
|
2348
|
+
/* @__PURE__ */ jsx(
|
|
2349
|
+
TimeField,
|
|
2350
|
+
{
|
|
2351
|
+
label: "From",
|
|
2352
|
+
value: value.from,
|
|
2353
|
+
onChange: (from) => onChange({ ...value, from }),
|
|
2354
|
+
onMinuteComplete: () => toHourRef.current?.focus(),
|
|
2355
|
+
disabled
|
|
2356
|
+
}
|
|
2357
|
+
),
|
|
2358
|
+
/* @__PURE__ */ jsx(
|
|
2359
|
+
"div",
|
|
2360
|
+
{
|
|
2361
|
+
className: cn(
|
|
2362
|
+
"w-4 h-px",
|
|
2363
|
+
disabled ? "bg-gray-200 dark:bg-neutral-700" : "bg-gray-300 dark:bg-neutral-600"
|
|
2364
|
+
)
|
|
2365
|
+
}
|
|
2366
|
+
),
|
|
2367
|
+
/* @__PURE__ */ jsx(
|
|
2368
|
+
TimeField,
|
|
2369
|
+
{
|
|
2370
|
+
label: "To",
|
|
2371
|
+
value: value.to,
|
|
2372
|
+
onChange: (to) => onChange({ ...value, to }),
|
|
2373
|
+
hourRef: toHourRef,
|
|
2374
|
+
disabled
|
|
2375
|
+
}
|
|
2376
|
+
)
|
|
2377
|
+
] }),
|
|
2378
|
+
showDuration && /* @__PURE__ */ jsx("span", { className: cn(
|
|
2379
|
+
"text-[10px] font-medium pl-0.5",
|
|
2380
|
+
isOvernight ? "text-amber-500 dark:text-amber-400" : "text-gray-400 dark:text-gray-500"
|
|
2381
|
+
), children: durationLabel })
|
|
2382
|
+
] })
|
|
2383
|
+
] })
|
|
2384
|
+
}
|
|
2385
|
+
);
|
|
2386
|
+
}
|
|
2082
2387
|
var WEEKDAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
2083
2388
|
function getCalendarDays(month) {
|
|
2084
2389
|
const start = startOfWeek(startOfMonth(month), { weekStartsOn: 0 });
|
|
@@ -2246,16 +2551,25 @@ var DEFAULT_PRESETS = [
|
|
|
2246
2551
|
}
|
|
2247
2552
|
}
|
|
2248
2553
|
];
|
|
2249
|
-
function
|
|
2554
|
+
function formatTime(tv) {
|
|
2555
|
+
if (tv.hour === null || tv.minute === null) return "--:--";
|
|
2556
|
+
const period = tv.hour >= 12 ? "PM" : "AM";
|
|
2557
|
+
const h = tv.hour % 12 || 12;
|
|
2558
|
+
const m = tv.minute.toString().padStart(2, "0");
|
|
2559
|
+
return `${h}:${m} ${period}`;
|
|
2560
|
+
}
|
|
2561
|
+
function formatDateRange(range, placeholder, time) {
|
|
2250
2562
|
if (!range?.from) return placeholder;
|
|
2563
|
+
const timeActive = time && time.from.hour !== null && time.to.hour !== null;
|
|
2564
|
+
const timeSuffix = timeActive ? ` ${formatTime(time.from)} \u2013 ${formatTime(time.to)}` : "";
|
|
2251
2565
|
if (!range.to || isSameDay(range.from, range.to)) {
|
|
2252
|
-
return format(range.from, "MMM d, yyyy");
|
|
2566
|
+
return format(range.from, "MMM d, yyyy") + timeSuffix;
|
|
2253
2567
|
}
|
|
2254
2568
|
const sameYear = range.from.getFullYear() === range.to.getFullYear();
|
|
2255
2569
|
if (sameYear) {
|
|
2256
|
-
return `${format(range.from, "MMM d")} \u2013 ${format(range.to, "MMM d, yyyy")}`;
|
|
2570
|
+
return `${format(range.from, "MMM d")} \u2013 ${format(range.to, "MMM d, yyyy")}${timeSuffix}`;
|
|
2257
2571
|
}
|
|
2258
|
-
return `${format(range.from, "MMM d, yyyy")} \u2013 ${format(range.to, "MMM d, yyyy")}`;
|
|
2572
|
+
return `${format(range.from, "MMM d, yyyy")} \u2013 ${format(range.to, "MMM d, yyyy")}${timeSuffix}`;
|
|
2259
2573
|
}
|
|
2260
2574
|
function DateRangePicker({
|
|
2261
2575
|
value,
|
|
@@ -2265,7 +2579,10 @@ function DateRangePicker({
|
|
|
2265
2579
|
placeholder = "Select date range",
|
|
2266
2580
|
disabled = false,
|
|
2267
2581
|
align = "start",
|
|
2268
|
-
className
|
|
2582
|
+
className,
|
|
2583
|
+
showTimePicker = false,
|
|
2584
|
+
timeValue,
|
|
2585
|
+
onTimeChange
|
|
2269
2586
|
}) {
|
|
2270
2587
|
const [open, setOpen] = React10.useState(false);
|
|
2271
2588
|
const [internalRange, setInternalRange] = React10.useState({
|
|
@@ -2281,11 +2598,19 @@ function DateRangePicker({
|
|
|
2281
2598
|
() => startOfMonth(value?.from ?? /* @__PURE__ */ new Date())
|
|
2282
2599
|
);
|
|
2283
2600
|
const [activePreset, setActivePreset] = React10.useState();
|
|
2601
|
+
const [internalTime, setInternalTime] = React10.useState(DEFAULT_TIME_RANGE);
|
|
2284
2602
|
const committedRange = value ?? internalRange;
|
|
2603
|
+
const currentTime = timeValue ?? internalTime;
|
|
2604
|
+
const handleTimeChange = (newTime) => {
|
|
2605
|
+
if (onTimeChange) onTimeChange(newTime);
|
|
2606
|
+
else setInternalTime(newTime);
|
|
2607
|
+
};
|
|
2608
|
+
const timeVisible = !!(draft.from && draft.to);
|
|
2285
2609
|
const handleOpenChange = (newOpen) => {
|
|
2286
2610
|
if (newOpen) {
|
|
2287
2611
|
setDraft(committedRange);
|
|
2288
2612
|
if (committedRange.from) setLeftMonth(startOfMonth(committedRange.from));
|
|
2613
|
+
if (!onTimeChange) setInternalTime(currentTime);
|
|
2289
2614
|
}
|
|
2290
2615
|
setOpen(newOpen);
|
|
2291
2616
|
};
|
|
@@ -2302,11 +2627,17 @@ function DateRangePicker({
|
|
|
2302
2627
|
};
|
|
2303
2628
|
const handlePreset = (preset) => {
|
|
2304
2629
|
const newRange = preset.getRange();
|
|
2305
|
-
if (
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2630
|
+
if (showTimePicker) {
|
|
2631
|
+
setDraft(newRange);
|
|
2632
|
+
setActivePreset(preset.label);
|
|
2633
|
+
if (newRange.from) setLeftMonth(startOfMonth(newRange.from));
|
|
2634
|
+
} else {
|
|
2635
|
+
if (onChange) onChange(newRange);
|
|
2636
|
+
else setInternalRange(newRange);
|
|
2637
|
+
setActivePreset(preset.label);
|
|
2638
|
+
if (newRange.from) setLeftMonth(startOfMonth(newRange.from));
|
|
2639
|
+
setOpen(false);
|
|
2640
|
+
}
|
|
2310
2641
|
};
|
|
2311
2642
|
const handleApply = () => {
|
|
2312
2643
|
if (draft.from && !draft.to) return;
|
|
@@ -2318,6 +2649,7 @@ function DateRangePicker({
|
|
|
2318
2649
|
const handleClear = () => {
|
|
2319
2650
|
setDraft({ from: void 0, to: void 0 });
|
|
2320
2651
|
setActivePreset(void 0);
|
|
2652
|
+
if (showTimePicker) handleTimeChange(DEFAULT_TIME_RANGE);
|
|
2321
2653
|
};
|
|
2322
2654
|
const canClear = !!(draft.from || committedRange.from);
|
|
2323
2655
|
const canApply = !(draft.from && !draft.to) && !!(draft.from || committedRange.from);
|
|
@@ -2337,7 +2669,11 @@ function DateRangePicker({
|
|
|
2337
2669
|
),
|
|
2338
2670
|
children: [
|
|
2339
2671
|
/* @__PURE__ */ jsx(CalendarIcon, { className: "w-4 h-4 shrink-0 text-gray-400 dark:text-gray-500" }),
|
|
2340
|
-
/* @__PURE__ */ jsx("span", { children: formatDateRange(
|
|
2672
|
+
/* @__PURE__ */ jsx("span", { children: formatDateRange(
|
|
2673
|
+
committedRange,
|
|
2674
|
+
placeholder,
|
|
2675
|
+
showTimePicker ? currentTime : void 0
|
|
2676
|
+
) })
|
|
2341
2677
|
]
|
|
2342
2678
|
}
|
|
2343
2679
|
) }),
|
|
@@ -2388,6 +2724,27 @@ function DateRangePicker({
|
|
|
2388
2724
|
}
|
|
2389
2725
|
)
|
|
2390
2726
|
] }),
|
|
2727
|
+
showTimePicker && /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: timeVisible && /* @__PURE__ */ jsx(
|
|
2728
|
+
motion.div,
|
|
2729
|
+
{
|
|
2730
|
+
initial: { height: 0, opacity: 0 },
|
|
2731
|
+
animate: { height: "auto", opacity: 1 },
|
|
2732
|
+
exit: { height: 0, opacity: 0 },
|
|
2733
|
+
transition: {
|
|
2734
|
+
height: { type: "spring", stiffness: 400, damping: 30, mass: 0.8 },
|
|
2735
|
+
opacity: { duration: 0.2 }
|
|
2736
|
+
},
|
|
2737
|
+
className: "overflow-hidden",
|
|
2738
|
+
children: /* @__PURE__ */ jsx(
|
|
2739
|
+
TimePickerRow,
|
|
2740
|
+
{
|
|
2741
|
+
value: currentTime,
|
|
2742
|
+
onChange: handleTimeChange
|
|
2743
|
+
}
|
|
2744
|
+
)
|
|
2745
|
+
},
|
|
2746
|
+
"time-picker"
|
|
2747
|
+
) }),
|
|
2391
2748
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-2 px-4 py-3 border-t border-gray-100 dark:border-neutral-700", children: [
|
|
2392
2749
|
/* @__PURE__ */ jsx(
|
|
2393
2750
|
"button",
|
|
@@ -2494,6 +2851,6 @@ function PeriodComparisonSelector({
|
|
|
2494
2851
|
] });
|
|
2495
2852
|
}
|
|
2496
2853
|
|
|
2497
|
-
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 };
|
|
2498
|
-
//# sourceMappingURL=chunk-
|
|
2499
|
-
//# sourceMappingURL=chunk-
|
|
2854
|
+
export { Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, ColumnSelection, DEFAULT_COMPARISON_PERIODS, DEFAULT_PRESETS, DEFAULT_TIME_RANGE, 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 };
|
|
2855
|
+
//# sourceMappingURL=chunk-QJMRQP66.mjs.map
|
|
2856
|
+
//# sourceMappingURL=chunk-QJMRQP66.mjs.map
|