@pos-360/horizon 0.26.0 → 0.27.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.
@@ -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, CalendarIcon, ChevronLeft } from 'lucide-react';
8
+ import { Check, X, ChevronRight, Circle, ChevronDown, ChevronUp, Search, Minus, 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';
@@ -139,7 +139,7 @@ var CardFooter = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE
139
139
  }
140
140
  ));
141
141
  CardFooter.displayName = "CardFooter";
142
- var Checkbox = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
142
+ var Checkbox = React10.forwardRef(({ className, indicatorIcon, ...props }, ref) => /* @__PURE__ */ jsx(
143
143
  CheckboxPrimitive.Root,
144
144
  {
145
145
  ref,
@@ -152,7 +152,7 @@ var Checkbox = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__
152
152
  CheckboxPrimitive.Indicator,
153
153
  {
154
154
  className: cn("flex items-center justify-center text-current"),
155
- children: /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5", strokeWidth: 3 })
155
+ children: indicatorIcon ?? /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5", strokeWidth: 3 })
156
156
  }
157
157
  )
158
158
  }
@@ -1559,7 +1559,7 @@ var TableSelectAll = React10.forwardRef(({ className, ...props }, ref) => {
1559
1559
  return null;
1560
1560
  }
1561
1561
  const handleCheckedChange = (checked) => {
1562
- if (checked) {
1562
+ if (checked === true) {
1563
1563
  context.selectAll();
1564
1564
  } else {
1565
1565
  context.deselectAll();
@@ -1571,7 +1571,8 @@ var TableSelectAll = React10.forwardRef(({ className, ...props }, ref) => {
1571
1571
  checked: context.isAllSelected,
1572
1572
  onCheckedChange: handleCheckedChange,
1573
1573
  "aria-label": "Select all rows",
1574
- ...context.isSomeSelected && { "data-state": "indeterminate" }
1574
+ indicatorIcon: /* @__PURE__ */ jsx(Minus, { className: "h-3.5 w-3.5", strokeWidth: 3 }),
1575
+ className: "data-[state=checked]:bg-white data-[state=checked]:border-blue-600 data-[state=checked]:text-blue-600 dark:data-[state=checked]:bg-white"
1575
1576
  }
1576
1577
  ) });
1577
1578
  });
@@ -2271,27 +2272,33 @@ function DateRangePicker({
2271
2272
  from: void 0,
2272
2273
  to: void 0
2273
2274
  });
2275
+ const [draft, setDraft] = React10.useState({
2276
+ from: void 0,
2277
+ to: void 0
2278
+ });
2274
2279
  const [hoverDate, setHoverDate] = React10.useState();
2275
2280
  const [leftMonth, setLeftMonth] = React10.useState(
2276
2281
  () => startOfMonth(value?.from ?? /* @__PURE__ */ new Date())
2277
2282
  );
2278
2283
  const [activePreset, setActivePreset] = React10.useState();
2279
- const range = value ?? internalRange;
2284
+ const committedRange = value ?? internalRange;
2285
+ const handleOpenChange = (newOpen) => {
2286
+ if (newOpen) {
2287
+ setDraft(committedRange);
2288
+ if (committedRange.from) setLeftMonth(startOfMonth(committedRange.from));
2289
+ }
2290
+ setOpen(newOpen);
2291
+ };
2280
2292
  const handleDayClick = (date) => {
2281
- const { from, to } = range;
2293
+ const { from, to } = draft;
2282
2294
  if (!from || from && to) {
2283
- const newRange2 = { from: date, to: void 0 };
2295
+ setDraft({ from: date, to: void 0 });
2284
2296
  setActivePreset(void 0);
2285
- if (onChange) onChange(newRange2);
2286
- else setInternalRange(newRange2);
2287
2297
  return;
2288
2298
  }
2289
2299
  const [start, end] = isBefore(from, date) ? [from, date] : [date, from];
2290
- const newRange = { from: start, to: end };
2291
- if (onChange) onChange(newRange);
2292
- else setInternalRange(newRange);
2300
+ setDraft({ from: start, to: end });
2293
2301
  setHoverDate(void 0);
2294
- setOpen(false);
2295
2302
  };
2296
2303
  const handlePreset = (preset) => {
2297
2304
  const newRange = preset.getRange();
@@ -2301,8 +2308,21 @@ function DateRangePicker({
2301
2308
  if (newRange.from) setLeftMonth(startOfMonth(newRange.from));
2302
2309
  setOpen(false);
2303
2310
  };
2311
+ const handleApply = () => {
2312
+ if (draft.from && !draft.to) return;
2313
+ const newRange = draft.from && draft.to ? draft : void 0;
2314
+ if (onChange) onChange(newRange);
2315
+ else setInternalRange(newRange ?? { from: void 0, to: void 0 });
2316
+ setOpen(false);
2317
+ };
2318
+ const handleClear = () => {
2319
+ setDraft({ from: void 0, to: void 0 });
2320
+ setActivePreset(void 0);
2321
+ };
2322
+ const canClear = !!(draft.from || committedRange.from);
2323
+ const canApply = !(draft.from && !draft.to) && !!(draft.from || committedRange.from);
2304
2324
  const rightMonth = addMonths(leftMonth, 1);
2305
- return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
2325
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: handleOpenChange, children: [
2306
2326
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
2307
2327
  "button",
2308
2328
  {
@@ -2312,12 +2332,12 @@ function DateRangePicker({
2312
2332
  "hover:bg-gray-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2",
2313
2333
  "dark:border-neutral-600 dark:bg-neutral-800 dark:hover:bg-neutral-700",
2314
2334
  "disabled:pointer-events-none disabled:opacity-50",
2315
- range.from ? "text-gray-900 dark:text-gray-100" : "text-gray-400 dark:text-gray-500",
2335
+ committedRange.from ? "text-gray-900 dark:text-gray-100" : "text-gray-400 dark:text-gray-500",
2316
2336
  className
2317
2337
  ),
2318
2338
  children: [
2319
2339
  /* @__PURE__ */ jsx(CalendarIcon, { className: "w-4 h-4 shrink-0 text-gray-400 dark:text-gray-500" }),
2320
- /* @__PURE__ */ jsx("span", { children: formatDateRange(range, placeholder) })
2340
+ /* @__PURE__ */ jsx("span", { children: formatDateRange(committedRange, placeholder) })
2321
2341
  ]
2322
2342
  }
2323
2343
  ) }),
@@ -2338,34 +2358,62 @@ function DateRangePicker({
2338
2358
  preset.label
2339
2359
  ))
2340
2360
  ] }, section.title)) }),
2341
- /* @__PURE__ */ jsxs("div", { className: "flex gap-4 p-4", children: [
2342
- /* @__PURE__ */ jsx(
2343
- CalendarMonth,
2344
- {
2345
- month: leftMonth,
2346
- range,
2347
- hoverDate,
2348
- onDayClick: handleDayClick,
2349
- onDayHover: setHoverDate,
2350
- onPrevMonth: () => setLeftMonth(subMonths(leftMonth, 1)),
2351
- showPrevNav: true,
2352
- showNextNav: false
2353
- }
2354
- ),
2355
- /* @__PURE__ */ jsx("div", { className: "w-px bg-gray-100 dark:bg-neutral-700 self-stretch" }),
2356
- /* @__PURE__ */ jsx(
2357
- CalendarMonth,
2358
- {
2359
- month: rightMonth,
2360
- range,
2361
- hoverDate,
2362
- onDayClick: handleDayClick,
2363
- onDayHover: setHoverDate,
2364
- onNextMonth: () => setLeftMonth(addMonths(leftMonth, 1)),
2365
- showPrevNav: false,
2366
- showNextNav: true
2367
- }
2368
- )
2361
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
2362
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-4 p-4", children: [
2363
+ /* @__PURE__ */ jsx(
2364
+ CalendarMonth,
2365
+ {
2366
+ month: leftMonth,
2367
+ range: draft,
2368
+ hoverDate,
2369
+ onDayClick: handleDayClick,
2370
+ onDayHover: setHoverDate,
2371
+ onPrevMonth: () => setLeftMonth(subMonths(leftMonth, 1)),
2372
+ showPrevNav: true,
2373
+ showNextNav: false
2374
+ }
2375
+ ),
2376
+ /* @__PURE__ */ jsx("div", { className: "w-px bg-gray-100 dark:bg-neutral-700 self-stretch" }),
2377
+ /* @__PURE__ */ jsx(
2378
+ CalendarMonth,
2379
+ {
2380
+ month: rightMonth,
2381
+ range: draft,
2382
+ hoverDate,
2383
+ onDayClick: handleDayClick,
2384
+ onDayHover: setHoverDate,
2385
+ onNextMonth: () => setLeftMonth(addMonths(leftMonth, 1)),
2386
+ showPrevNav: false,
2387
+ showNextNav: true
2388
+ }
2389
+ )
2390
+ ] }),
2391
+ /* @__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
+ /* @__PURE__ */ jsx(
2393
+ "button",
2394
+ {
2395
+ onClick: handleClear,
2396
+ disabled: !canClear,
2397
+ className: cn(
2398
+ "px-3 py-1.5 rounded-md text-sm transition-colors",
2399
+ canClear ? "text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-neutral-700" : "text-gray-300 dark:text-gray-600 cursor-not-allowed"
2400
+ ),
2401
+ children: "Clear"
2402
+ }
2403
+ ),
2404
+ /* @__PURE__ */ jsx(
2405
+ "button",
2406
+ {
2407
+ onClick: handleApply,
2408
+ disabled: !canApply,
2409
+ className: cn(
2410
+ "px-3 py-1.5 rounded-md text-sm font-medium transition-colors",
2411
+ canApply ? "bg-blue-600 text-white hover:bg-blue-700 dark:hover:bg-blue-500" : "bg-blue-100 text-blue-300 cursor-not-allowed dark:bg-blue-950/30 dark:text-blue-800"
2412
+ ),
2413
+ children: "Apply"
2414
+ }
2415
+ )
2416
+ ] })
2369
2417
  ] })
2370
2418
  ] }) })
2371
2419
  ] });
@@ -2447,5 +2495,5 @@ function PeriodComparisonSelector({
2447
2495
  }
2448
2496
 
2449
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 };
2450
- //# sourceMappingURL=chunk-54W4CEU5.mjs.map
2451
- //# sourceMappingURL=chunk-54W4CEU5.mjs.map
2498
+ //# sourceMappingURL=chunk-2LATCE3V.mjs.map
2499
+ //# sourceMappingURL=chunk-2LATCE3V.mjs.map