@pos-360/horizon 0.30.0 → 0.30.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.
@@ -15,7 +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
+ import { endOfDay, startOfDay, min, startOfWeek, startOfMonth, subDays, endOfWeek, endOfMonth, subMonths, addMonths, subYears, isBefore, isSameDay, format, isSameMonth, isAfter, eachDayOfInterval, isWithinInterval } from 'date-fns';
19
19
 
20
20
  var buttonVariants = cva(
21
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",
@@ -2099,12 +2099,12 @@ function to24Hour(hour12, period) {
2099
2099
  function pad(n) {
2100
2100
  return n.toString().padStart(2, "0");
2101
2101
  }
2102
- function clamp(val, min, max) {
2103
- return Math.max(min, Math.min(max, val));
2102
+ function clamp(val, min2, max) {
2103
+ return Math.max(min2, Math.min(max, val));
2104
2104
  }
2105
2105
  function TimeInput({
2106
2106
  value,
2107
- min,
2107
+ min: min2,
2108
2108
  max,
2109
2109
  onChange,
2110
2110
  onComplete,
@@ -2127,7 +2127,7 @@ function TimeInput({
2127
2127
  return;
2128
2128
  }
2129
2129
  const parsed = parseInt(raw, 10);
2130
- const clamped = clamp(parsed, min, max);
2130
+ const clamped = clamp(parsed, min2, max);
2131
2131
  committedRef.current = true;
2132
2132
  onChange(clamped);
2133
2133
  setEditValue(null);
@@ -2146,7 +2146,7 @@ function TimeInput({
2146
2146
  }
2147
2147
  const parsed = parseInt(editValue, 10);
2148
2148
  if (!isNaN(parsed)) {
2149
- onChange(clamp(parsed, min, max));
2149
+ onChange(clamp(parsed, min2, max));
2150
2150
  }
2151
2151
  setEditValue(null);
2152
2152
  };
@@ -2159,14 +2159,14 @@ function TimeInput({
2159
2159
  internalRef.current?.blur();
2160
2160
  } else if (e.key === "ArrowUp") {
2161
2161
  e.preventDefault();
2162
- const curr = value ?? min;
2163
- const next = curr >= max ? min : curr + 1;
2162
+ const curr = value ?? min2;
2163
+ const next = curr >= max ? min2 : curr + 1;
2164
2164
  onChange(next);
2165
2165
  setEditValue(pad(next));
2166
2166
  } else if (e.key === "ArrowDown") {
2167
2167
  e.preventDefault();
2168
2168
  const curr = value ?? max;
2169
- const next = curr <= min ? max : curr - 1;
2169
+ const next = curr <= min2 ? max : curr - 1;
2170
2170
  onChange(next);
2171
2171
  setEditValue(pad(next));
2172
2172
  }
@@ -2539,9 +2539,14 @@ function CalendarMonth({
2539
2539
  onMouseLeave: () => onDayHover(void 0),
2540
2540
  children: days.map((day, idx) => {
2541
2541
  const outside = !isSameMonth(day, month);
2542
- const inRange = !outside && isInRange(day);
2543
- const rangeStart = !outside && isRangeStart(day);
2544
- const rangeEnd = !outside && isRangeEnd(day);
2542
+ if (outside) {
2543
+ return /* @__PURE__ */ jsx("div", { className: "h-9" }, idx);
2544
+ }
2545
+ const isFuture = isAfter(startOfDay(day), startOfDay(today));
2546
+ const disabled = isFuture;
2547
+ const inRange = !disabled && isInRange(day);
2548
+ const rangeStart = !disabled && isRangeStart(day);
2549
+ const rangeEnd = !disabled && isRangeEnd(day);
2545
2550
  const isToday = isSameDay(day, today);
2546
2551
  return /* @__PURE__ */ jsx(
2547
2552
  "div",
@@ -2556,16 +2561,17 @@ function CalendarMonth({
2556
2561
  children: /* @__PURE__ */ jsx(
2557
2562
  "button",
2558
2563
  {
2559
- onClick: () => !outside && onDayClick(day),
2560
- onMouseEnter: () => !outside && onDayHover(day),
2561
- tabIndex: outside ? -1 : 0,
2564
+ onClick: () => !disabled && onDayClick(day),
2565
+ onMouseEnter: () => !disabled && onDayHover(day),
2566
+ tabIndex: disabled ? -1 : 0,
2567
+ disabled,
2562
2568
  className: cn(
2563
2569
  "w-8 h-8 rounded-full text-sm flex items-center justify-center transition-colors",
2564
- outside && "text-gray-300 dark:text-gray-600 pointer-events-none",
2565
- !outside && !rangeStart && !rangeEnd && "text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-neutral-700",
2566
- !outside && inRange && !rangeStart && !rangeEnd && "text-blue-700 dark:text-blue-300 hover:bg-blue-100 dark:hover:bg-blue-900/50",
2570
+ isFuture && "text-gray-300 dark:text-gray-600 pointer-events-none cursor-not-allowed",
2571
+ !disabled && !rangeStart && !rangeEnd && "text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-neutral-700",
2572
+ !disabled && inRange && !rangeStart && !rangeEnd && "text-blue-700 dark:text-blue-300 hover:bg-blue-100 dark:hover:bg-blue-900/50",
2567
2573
  (rangeStart || rangeEnd) && "bg-blue-600 text-white hover:bg-blue-700 dark:hover:bg-blue-500",
2568
- isToday && !rangeStart && !rangeEnd && !outside && "font-bold"
2574
+ isToday && !rangeStart && !rangeEnd && !disabled && "font-bold"
2569
2575
  ),
2570
2576
  children: format(day, "d")
2571
2577
  }
@@ -2597,7 +2603,7 @@ var DEFAULT_PRESETS = [
2597
2603
  label: "This Week",
2598
2604
  getRange: () => ({
2599
2605
  from: startOfWeek(/* @__PURE__ */ new Date(), { weekStartsOn: 0 }),
2600
- to: endOfWeek(/* @__PURE__ */ new Date(), { weekStartsOn: 0 })
2606
+ to: min([endOfWeek(/* @__PURE__ */ new Date(), { weekStartsOn: 0 }), endOfDay(/* @__PURE__ */ new Date())])
2601
2607
  })
2602
2608
  },
2603
2609
  {
@@ -2614,7 +2620,7 @@ var DEFAULT_PRESETS = [
2614
2620
  label: "This Month",
2615
2621
  getRange: () => ({
2616
2622
  from: startOfMonth(/* @__PURE__ */ new Date()),
2617
- to: endOfMonth(/* @__PURE__ */ new Date())
2623
+ to: min([endOfMonth(/* @__PURE__ */ new Date()), endOfDay(/* @__PURE__ */ new Date())])
2618
2624
  })
2619
2625
  },
2620
2626
  {
@@ -2701,17 +2707,9 @@ function DateRangePicker({
2701
2707
  };
2702
2708
  const handlePreset = (preset) => {
2703
2709
  const newRange = preset.getRange();
2704
- if (showTimePicker) {
2705
- setDraft(newRange);
2706
- setActivePreset(preset.label);
2707
- if (newRange.from) setLeftMonth(startOfMonth(newRange.from));
2708
- } else {
2709
- if (onChange) onChange(newRange);
2710
- else setInternalRange(newRange);
2711
- setActivePreset(preset.label);
2712
- if (newRange.from) setLeftMonth(startOfMonth(newRange.from));
2713
- setOpen(false);
2714
- }
2710
+ setDraft(newRange);
2711
+ setActivePreset(preset.label);
2712
+ if (newRange.from) setLeftMonth(startOfMonth(newRange.from));
2715
2713
  };
2716
2714
  const handleApply = () => {
2717
2715
  if (draft.from && !draft.to) return;
@@ -2929,17 +2927,9 @@ function DateRangePickerMobile({
2929
2927
  };
2930
2928
  const handlePreset = (preset) => {
2931
2929
  const newRange = preset.getRange();
2932
- if (showTimePicker) {
2933
- setDraft(newRange);
2934
- setActivePreset(preset.label);
2935
- if (newRange.from) setViewMonth(startOfMonth(newRange.from));
2936
- } else {
2937
- if (onChange) onChange(newRange);
2938
- else setInternalRange(newRange);
2939
- setActivePreset(preset.label);
2940
- if (newRange.from) setViewMonth(startOfMonth(newRange.from));
2941
- setOpen(false);
2942
- }
2930
+ setDraft(newRange);
2931
+ setActivePreset(preset.label);
2932
+ if (newRange.from) setViewMonth(startOfMonth(newRange.from));
2943
2933
  };
2944
2934
  const handleApply = () => {
2945
2935
  if (draft.from && !draft.to) return;
@@ -3319,5 +3309,5 @@ function PeriodComparisonSelector({
3319
3309
  }
3320
3310
 
3321
3311
  export { Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, ColumnSelection, DEFAULT_COMPARISON_PERIODS, DEFAULT_PRESETS, DEFAULT_TIME_RANGE, DateRangePicker, DateRangePickerMobile, 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, MobileDataCard, 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 };
3322
- //# sourceMappingURL=chunk-OWU2ABN4.mjs.map
3323
- //# sourceMappingURL=chunk-OWU2ABN4.mjs.map
3312
+ //# sourceMappingURL=chunk-RA7KTV62.mjs.map
3313
+ //# sourceMappingURL=chunk-RA7KTV62.mjs.map