@pos-360/horizon 0.23.0 → 0.25.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.
@@ -2279,6 +2279,7 @@ function DateRangePicker({
2279
2279
  value,
2280
2280
  onChange,
2281
2281
  presets = DEFAULT_PRESETS,
2282
+ presetSections,
2282
2283
  placeholder = "Select date range",
2283
2284
  disabled = false,
2284
2285
  align = "start",
@@ -2340,9 +2341,10 @@ function DateRangePicker({
2340
2341
  }
2341
2342
  ) }),
2342
2343
  /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { align, className: "w-auto p-0 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex divide-x divide-gray-100 dark:divide-neutral-700", children: [
2343
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col p-3 gap-0.5 min-w-[130px]", children: [
2344
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase tracking-wider mb-2 px-2", children: "Presets" }),
2345
- presets.map((preset) => /* @__PURE__ */ jsxRuntime.jsx(
2344
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col p-3 gap-0.5 min-w-[130px]", children: (presetSections ?? [{ title: "Presets", options: presets }]).map((section, si) => /* @__PURE__ */ jsxRuntime.jsxs(React10__namespace.Fragment, { children: [
2345
+ si > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-2 border-t border-gray-100 dark:border-neutral-700" }),
2346
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase tracking-wider mb-1 px-2", children: section.title }),
2347
+ section.options.map((preset) => /* @__PURE__ */ jsxRuntime.jsx(
2346
2348
  "button",
2347
2349
  {
2348
2350
  onClick: () => handlePreset(preset),
@@ -2354,7 +2356,7 @@ function DateRangePicker({
2354
2356
  },
2355
2357
  preset.label
2356
2358
  ))
2357
- ] }),
2359
+ ] }, section.title)) }),
2358
2360
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-4 p-4", children: [
2359
2361
  /* @__PURE__ */ jsxRuntime.jsx(
2360
2362
  CalendarMonth,
@@ -2387,6 +2389,81 @@ function DateRangePicker({
2387
2389
  ] }) })
2388
2390
  ] });
2389
2391
  }
2392
+ var DEFAULT_COMPARISON_PERIODS = [
2393
+ {
2394
+ key: "yesterday",
2395
+ label: "vs. 1 day prior",
2396
+ getRange: () => {
2397
+ const d = dateFns.subDays(/* @__PURE__ */ new Date(), 1);
2398
+ return { from: dateFns.startOfDay(d), to: dateFns.endOfDay(d) };
2399
+ }
2400
+ },
2401
+ {
2402
+ key: "last-week",
2403
+ label: "vs. 7 days prior",
2404
+ getRange: () => {
2405
+ const d = dateFns.subDays(/* @__PURE__ */ new Date(), 7);
2406
+ return {
2407
+ from: dateFns.startOfWeek(d, { weekStartsOn: 0 }),
2408
+ to: dateFns.endOfWeek(d, { weekStartsOn: 0 })
2409
+ };
2410
+ }
2411
+ },
2412
+ {
2413
+ key: "last-month",
2414
+ label: "vs. 30 days prior",
2415
+ getRange: () => {
2416
+ const d = dateFns.subMonths(/* @__PURE__ */ new Date(), 1);
2417
+ return { from: dateFns.startOfMonth(d), to: dateFns.endOfMonth(d) };
2418
+ }
2419
+ },
2420
+ {
2421
+ key: "last-year",
2422
+ label: "vs. 365 days prior",
2423
+ getRange: () => {
2424
+ const d = dateFns.subYears(/* @__PURE__ */ new Date(), 1);
2425
+ return {
2426
+ from: dateFns.startOfDay(new Date(d.getFullYear(), 0, 1)),
2427
+ to: dateFns.endOfDay(new Date(d.getFullYear(), 11, 31))
2428
+ };
2429
+ }
2430
+ }
2431
+ ];
2432
+ var AUTO_SWITCH_THRESHOLD = 4;
2433
+ function PeriodComparisonSelector({
2434
+ value,
2435
+ onChange,
2436
+ options = DEFAULT_COMPARISON_PERIODS,
2437
+ mode,
2438
+ size = "default",
2439
+ placeholder = "Compare to...",
2440
+ disabled = false,
2441
+ className
2442
+ }) {
2443
+ const resolvedMode = mode ?? (options.length <= AUTO_SWITCH_THRESHOLD ? "segmented" : "select");
2444
+ const handleChange = (key) => {
2445
+ const period = options.find((o) => o.key === key);
2446
+ if (period) onChange?.(key, period);
2447
+ };
2448
+ if (resolvedMode === "segmented") {
2449
+ return /* @__PURE__ */ jsxRuntime.jsx(
2450
+ SegmentedControl,
2451
+ {
2452
+ options: options.map((o) => ({ label: o.label, value: o.key })),
2453
+ value,
2454
+ onChange: handleChange,
2455
+ size,
2456
+ radius: "md",
2457
+ disabled,
2458
+ className
2459
+ }
2460
+ );
2461
+ }
2462
+ return /* @__PURE__ */ jsxRuntime.jsxs(Select, { value, onValueChange: handleChange, disabled, children: [
2463
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className, children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder, children: options.find((o) => o.key === value)?.label }) }),
2464
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options.map((o) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: o.key, children: o.label }, o.key)) })
2465
+ ] });
2466
+ }
2390
2467
 
2391
2468
  exports.Button = Button;
2392
2469
  exports.Card = Card;
@@ -2397,6 +2474,7 @@ exports.CardHeader = CardHeader;
2397
2474
  exports.CardTitle = CardTitle;
2398
2475
  exports.Checkbox = Checkbox;
2399
2476
  exports.ColumnSelection = ColumnSelection;
2477
+ exports.DEFAULT_COMPARISON_PERIODS = DEFAULT_COMPARISON_PERIODS;
2400
2478
  exports.DEFAULT_PRESETS = DEFAULT_PRESETS;
2401
2479
  exports.DateRangePicker = DateRangePicker;
2402
2480
  exports.Dialog = Dialog;
@@ -2430,6 +2508,7 @@ exports.FormDescription = FormDescription;
2430
2508
  exports.FormField = FormField;
2431
2509
  exports.FormLabel = FormLabel;
2432
2510
  exports.FormMessage = FormMessage;
2511
+ exports.PeriodComparisonSelector = PeriodComparisonSelector;
2433
2512
  exports.Popover = Popover;
2434
2513
  exports.PopoverAnchor = PopoverAnchor;
2435
2514
  exports.PopoverContent = PopoverContent;
@@ -2488,5 +2567,5 @@ exports.useColumnVisibility = useColumnVisibility;
2488
2567
  exports.useFormContext = useFormContext;
2489
2568
  exports.useFormFieldContext = useFormFieldContext;
2490
2569
  exports.useTableSelection = useTableSelection;
2491
- //# sourceMappingURL=chunk-J2AWNOYH.js.map
2492
- //# sourceMappingURL=chunk-J2AWNOYH.js.map
2570
+ //# sourceMappingURL=chunk-FBYLMSO3.js.map
2571
+ //# sourceMappingURL=chunk-FBYLMSO3.js.map