@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.
@@ -169,7 +169,7 @@ var CardFooter = React10__namespace.forwardRef(({ className, ...props }, ref) =>
169
169
  }
170
170
  ));
171
171
  CardFooter.displayName = "CardFooter";
172
- var Checkbox = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
172
+ var Checkbox = React10__namespace.forwardRef(({ className, indicatorIcon, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
173
173
  CheckboxPrimitive__namespace.Root,
174
174
  {
175
175
  ref,
@@ -182,7 +182,7 @@ var Checkbox = React10__namespace.forwardRef(({ className, ...props }, ref) => /
182
182
  CheckboxPrimitive__namespace.Indicator,
183
183
  {
184
184
  className: chunk5XF7Y25B_js.cn("flex items-center justify-center text-current"),
185
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3.5 w-3.5", strokeWidth: 3 })
185
+ children: indicatorIcon ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3.5 w-3.5", strokeWidth: 3 })
186
186
  }
187
187
  )
188
188
  }
@@ -1589,7 +1589,7 @@ var TableSelectAll = React10__namespace.forwardRef(({ className, ...props }, ref
1589
1589
  return null;
1590
1590
  }
1591
1591
  const handleCheckedChange = (checked) => {
1592
- if (checked) {
1592
+ if (checked === true) {
1593
1593
  context.selectAll();
1594
1594
  } else {
1595
1595
  context.deselectAll();
@@ -1601,7 +1601,8 @@ var TableSelectAll = React10__namespace.forwardRef(({ className, ...props }, ref
1601
1601
  checked: context.isAllSelected,
1602
1602
  onCheckedChange: handleCheckedChange,
1603
1603
  "aria-label": "Select all rows",
1604
- ...context.isSomeSelected && { "data-state": "indeterminate" }
1604
+ indicatorIcon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minus, { className: "h-3.5 w-3.5", strokeWidth: 3 }),
1605
+ className: "data-[state=checked]:bg-white data-[state=checked]:border-blue-600 data-[state=checked]:text-blue-600 dark:data-[state=checked]:bg-white"
1605
1606
  }
1606
1607
  ) });
1607
1608
  });
@@ -2301,27 +2302,33 @@ function DateRangePicker({
2301
2302
  from: void 0,
2302
2303
  to: void 0
2303
2304
  });
2305
+ const [draft, setDraft] = React10__namespace.useState({
2306
+ from: void 0,
2307
+ to: void 0
2308
+ });
2304
2309
  const [hoverDate, setHoverDate] = React10__namespace.useState();
2305
2310
  const [leftMonth, setLeftMonth] = React10__namespace.useState(
2306
2311
  () => dateFns.startOfMonth(value?.from ?? /* @__PURE__ */ new Date())
2307
2312
  );
2308
2313
  const [activePreset, setActivePreset] = React10__namespace.useState();
2309
- const range = value ?? internalRange;
2314
+ const committedRange = value ?? internalRange;
2315
+ const handleOpenChange = (newOpen) => {
2316
+ if (newOpen) {
2317
+ setDraft(committedRange);
2318
+ if (committedRange.from) setLeftMonth(dateFns.startOfMonth(committedRange.from));
2319
+ }
2320
+ setOpen(newOpen);
2321
+ };
2310
2322
  const handleDayClick = (date) => {
2311
- const { from, to } = range;
2323
+ const { from, to } = draft;
2312
2324
  if (!from || from && to) {
2313
- const newRange2 = { from: date, to: void 0 };
2325
+ setDraft({ from: date, to: void 0 });
2314
2326
  setActivePreset(void 0);
2315
- if (onChange) onChange(newRange2);
2316
- else setInternalRange(newRange2);
2317
2327
  return;
2318
2328
  }
2319
2329
  const [start, end] = dateFns.isBefore(from, date) ? [from, date] : [date, from];
2320
- const newRange = { from: start, to: end };
2321
- if (onChange) onChange(newRange);
2322
- else setInternalRange(newRange);
2330
+ setDraft({ from: start, to: end });
2323
2331
  setHoverDate(void 0);
2324
- setOpen(false);
2325
2332
  };
2326
2333
  const handlePreset = (preset) => {
2327
2334
  const newRange = preset.getRange();
@@ -2331,8 +2338,21 @@ function DateRangePicker({
2331
2338
  if (newRange.from) setLeftMonth(dateFns.startOfMonth(newRange.from));
2332
2339
  setOpen(false);
2333
2340
  };
2341
+ const handleApply = () => {
2342
+ if (draft.from && !draft.to) return;
2343
+ const newRange = draft.from && draft.to ? draft : void 0;
2344
+ if (onChange) onChange(newRange);
2345
+ else setInternalRange(newRange ?? { from: void 0, to: void 0 });
2346
+ setOpen(false);
2347
+ };
2348
+ const handleClear = () => {
2349
+ setDraft({ from: void 0, to: void 0 });
2350
+ setActivePreset(void 0);
2351
+ };
2352
+ const canClear = !!(draft.from || committedRange.from);
2353
+ const canApply = !(draft.from && !draft.to) && !!(draft.from || committedRange.from);
2334
2354
  const rightMonth = dateFns.addMonths(leftMonth, 1);
2335
- return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: setOpen, children: [
2355
+ return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: handleOpenChange, children: [
2336
2356
  /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
2337
2357
  "button",
2338
2358
  {
@@ -2342,12 +2362,12 @@ function DateRangePicker({
2342
2362
  "hover:bg-gray-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2",
2343
2363
  "dark:border-neutral-600 dark:bg-neutral-800 dark:hover:bg-neutral-700",
2344
2364
  "disabled:pointer-events-none disabled:opacity-50",
2345
- range.from ? "text-gray-900 dark:text-gray-100" : "text-gray-400 dark:text-gray-500",
2365
+ committedRange.from ? "text-gray-900 dark:text-gray-100" : "text-gray-400 dark:text-gray-500",
2346
2366
  className
2347
2367
  ),
2348
2368
  children: [
2349
2369
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarIcon, { className: "w-4 h-4 shrink-0 text-gray-400 dark:text-gray-500" }),
2350
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: formatDateRange(range, placeholder) })
2370
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: formatDateRange(committedRange, placeholder) })
2351
2371
  ]
2352
2372
  }
2353
2373
  ) }),
@@ -2368,34 +2388,62 @@ function DateRangePicker({
2368
2388
  preset.label
2369
2389
  ))
2370
2390
  ] }, section.title)) }),
2371
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-4 p-4", children: [
2372
- /* @__PURE__ */ jsxRuntime.jsx(
2373
- CalendarMonth,
2374
- {
2375
- month: leftMonth,
2376
- range,
2377
- hoverDate,
2378
- onDayClick: handleDayClick,
2379
- onDayHover: setHoverDate,
2380
- onPrevMonth: () => setLeftMonth(dateFns.subMonths(leftMonth, 1)),
2381
- showPrevNav: true,
2382
- showNextNav: false
2383
- }
2384
- ),
2385
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-px bg-gray-100 dark:bg-neutral-700 self-stretch" }),
2386
- /* @__PURE__ */ jsxRuntime.jsx(
2387
- CalendarMonth,
2388
- {
2389
- month: rightMonth,
2390
- range,
2391
- hoverDate,
2392
- onDayClick: handleDayClick,
2393
- onDayHover: setHoverDate,
2394
- onNextMonth: () => setLeftMonth(dateFns.addMonths(leftMonth, 1)),
2395
- showPrevNav: false,
2396
- showNextNav: true
2397
- }
2398
- )
2391
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
2392
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-4 p-4", children: [
2393
+ /* @__PURE__ */ jsxRuntime.jsx(
2394
+ CalendarMonth,
2395
+ {
2396
+ month: leftMonth,
2397
+ range: draft,
2398
+ hoverDate,
2399
+ onDayClick: handleDayClick,
2400
+ onDayHover: setHoverDate,
2401
+ onPrevMonth: () => setLeftMonth(dateFns.subMonths(leftMonth, 1)),
2402
+ showPrevNav: true,
2403
+ showNextNav: false
2404
+ }
2405
+ ),
2406
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-px bg-gray-100 dark:bg-neutral-700 self-stretch" }),
2407
+ /* @__PURE__ */ jsxRuntime.jsx(
2408
+ CalendarMonth,
2409
+ {
2410
+ month: rightMonth,
2411
+ range: draft,
2412
+ hoverDate,
2413
+ onDayClick: handleDayClick,
2414
+ onDayHover: setHoverDate,
2415
+ onNextMonth: () => setLeftMonth(dateFns.addMonths(leftMonth, 1)),
2416
+ showPrevNav: false,
2417
+ showNextNav: true
2418
+ }
2419
+ )
2420
+ ] }),
2421
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-2 px-4 py-3 border-t border-gray-100 dark:border-neutral-700", children: [
2422
+ /* @__PURE__ */ jsxRuntime.jsx(
2423
+ "button",
2424
+ {
2425
+ onClick: handleClear,
2426
+ disabled: !canClear,
2427
+ className: chunk5XF7Y25B_js.cn(
2428
+ "px-3 py-1.5 rounded-md text-sm transition-colors",
2429
+ 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"
2430
+ ),
2431
+ children: "Clear"
2432
+ }
2433
+ ),
2434
+ /* @__PURE__ */ jsxRuntime.jsx(
2435
+ "button",
2436
+ {
2437
+ onClick: handleApply,
2438
+ disabled: !canApply,
2439
+ className: chunk5XF7Y25B_js.cn(
2440
+ "px-3 py-1.5 rounded-md text-sm font-medium transition-colors",
2441
+ 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"
2442
+ ),
2443
+ children: "Apply"
2444
+ }
2445
+ )
2446
+ ] })
2399
2447
  ] })
2400
2448
  ] }) })
2401
2449
  ] });
@@ -2578,5 +2626,5 @@ exports.useColumnVisibility = useColumnVisibility;
2578
2626
  exports.useFormContext = useFormContext;
2579
2627
  exports.useFormFieldContext = useFormFieldContext;
2580
2628
  exports.useTableSelection = useTableSelection;
2581
- //# sourceMappingURL=chunk-ANAQVPFG.js.map
2582
- //# sourceMappingURL=chunk-ANAQVPFG.js.map
2629
+ //# sourceMappingURL=chunk-JP5BJYYD.js.map
2630
+ //# sourceMappingURL=chunk-JP5BJYYD.js.map