@codapet/design-system 0.4.3 → 0.4.4
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/index.mjs +53 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2351,7 +2351,11 @@ function DateInput({
|
|
|
2351
2351
|
|
|
2352
2352
|
// src/components/ui/date-range-input.tsx
|
|
2353
2353
|
import "class-variance-authority";
|
|
2354
|
-
import {
|
|
2354
|
+
import {
|
|
2355
|
+
format as dateFnsFormat2,
|
|
2356
|
+
parse as dateFnsParse2,
|
|
2357
|
+
isValid as isValid2
|
|
2358
|
+
} from "date-fns";
|
|
2355
2359
|
import { CalendarDays as CalendarDays2 } from "lucide-react";
|
|
2356
2360
|
import * as React21 from "react";
|
|
2357
2361
|
import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
@@ -2444,8 +2448,8 @@ function formatRange(range, dateFormat = "MM/DD/YYYY") {
|
|
|
2444
2448
|
if (!range) return "";
|
|
2445
2449
|
const from = formatDate2(range.from, dateFormat);
|
|
2446
2450
|
const to = formatDate2(range.to, dateFormat);
|
|
2447
|
-
if (from && to) return `${from} \u2013 ${to}`;
|
|
2448
|
-
if (from) return
|
|
2451
|
+
if (from && to) return from === to ? from : `${from} \u2013 ${to}`;
|
|
2452
|
+
if (from) return from;
|
|
2449
2453
|
return "";
|
|
2450
2454
|
}
|
|
2451
2455
|
function parseRange(value, dateFormat = "MM/DD/YYYY") {
|
|
@@ -2453,11 +2457,19 @@ function parseRange(value, dateFormat = "MM/DD/YYYY") {
|
|
|
2453
2457
|
const parts = value.split(/\s*[\u2013\-]\s*/);
|
|
2454
2458
|
const fromStr = parts[0]?.trim();
|
|
2455
2459
|
if (!fromStr) return null;
|
|
2456
|
-
const fromParsed = dateFnsParse2(
|
|
2460
|
+
const fromParsed = dateFnsParse2(
|
|
2461
|
+
fromStr,
|
|
2462
|
+
DATE_FORMAT_TOKENS2[dateFormat],
|
|
2463
|
+
/* @__PURE__ */ new Date()
|
|
2464
|
+
);
|
|
2457
2465
|
if (!isValid2(fromParsed)) return null;
|
|
2458
2466
|
const toStr = parts[1]?.trim();
|
|
2459
2467
|
if (!toStr) return { from: fromParsed, to: void 0 };
|
|
2460
|
-
const toParsed = dateFnsParse2(
|
|
2468
|
+
const toParsed = dateFnsParse2(
|
|
2469
|
+
toStr,
|
|
2470
|
+
DATE_FORMAT_TOKENS2[dateFormat],
|
|
2471
|
+
/* @__PURE__ */ new Date()
|
|
2472
|
+
);
|
|
2461
2473
|
if (!isValid2(toParsed)) return { from: fromParsed, to: void 0 };
|
|
2462
2474
|
return { from: fromParsed, to: toParsed };
|
|
2463
2475
|
}
|
|
@@ -2565,6 +2577,12 @@ function DateRangeInput({
|
|
|
2565
2577
|
}
|
|
2566
2578
|
setDateRange(range);
|
|
2567
2579
|
};
|
|
2580
|
+
const handleClear = () => {
|
|
2581
|
+
setDateRange(void 0);
|
|
2582
|
+
};
|
|
2583
|
+
const handleAdd = () => {
|
|
2584
|
+
setOpen(false);
|
|
2585
|
+
};
|
|
2568
2586
|
const resolvedCalendarProps = {
|
|
2569
2587
|
...calendarProps,
|
|
2570
2588
|
mode: "range",
|
|
@@ -2654,15 +2672,39 @@ function DateRangeInput({
|
|
|
2654
2672
|
...inputProps
|
|
2655
2673
|
}
|
|
2656
2674
|
) }) }),
|
|
2657
|
-
/* @__PURE__ */
|
|
2675
|
+
/* @__PURE__ */ jsxs11(
|
|
2658
2676
|
PopoverContent,
|
|
2659
2677
|
{
|
|
2660
|
-
className: "w-auto overflow-
|
|
2678
|
+
className: "w-auto p-0 flex flex-col overflow-y-auto max-h-[min(90dvh,520px)]",
|
|
2661
2679
|
align: "end",
|
|
2662
2680
|
alignOffset: -8,
|
|
2663
2681
|
sideOffset: 10,
|
|
2664
2682
|
side: "top",
|
|
2665
|
-
children:
|
|
2683
|
+
children: [
|
|
2684
|
+
/* @__PURE__ */ jsx23(Calendar, { ...resolvedCalendarProps }),
|
|
2685
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-2 px-2 py-2", children: [
|
|
2686
|
+
/* @__PURE__ */ jsx23(
|
|
2687
|
+
Button,
|
|
2688
|
+
{
|
|
2689
|
+
variant: "ghost-secondary",
|
|
2690
|
+
size: "sm",
|
|
2691
|
+
onClick: handleClear,
|
|
2692
|
+
type: "button",
|
|
2693
|
+
children: "Clear"
|
|
2694
|
+
}
|
|
2695
|
+
),
|
|
2696
|
+
/* @__PURE__ */ jsx23(
|
|
2697
|
+
Button,
|
|
2698
|
+
{
|
|
2699
|
+
variant: "primary",
|
|
2700
|
+
size: "sm",
|
|
2701
|
+
onClick: handleAdd,
|
|
2702
|
+
type: "button",
|
|
2703
|
+
children: "Add"
|
|
2704
|
+
}
|
|
2705
|
+
)
|
|
2706
|
+
] })
|
|
2707
|
+
]
|
|
2666
2708
|
}
|
|
2667
2709
|
)
|
|
2668
2710
|
] }) });
|
|
@@ -5465,14 +5507,14 @@ function TimeInput({
|
|
|
5465
5507
|
/* @__PURE__ */ jsx49(
|
|
5466
5508
|
PopoverContent,
|
|
5467
5509
|
{
|
|
5468
|
-
className: "w-auto p-0",
|
|
5510
|
+
className: "w-auto p-0 ",
|
|
5469
5511
|
align: "end",
|
|
5470
5512
|
alignOffset: -8,
|
|
5471
5513
|
sideOffset: 10,
|
|
5472
5514
|
side: "top",
|
|
5473
5515
|
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
5474
5516
|
children: /* @__PURE__ */ jsxs24("div", { className: "flex divide-x", children: [
|
|
5475
|
-
/* @__PURE__ */ jsx49("div", { className: "h-56 w-16 overflow-y-auto overscroll-contain
|
|
5517
|
+
/* @__PURE__ */ jsx49("div", { className: "h-56 w-16 overflow-y-auto overscroll-y-contain [-webkit-overflow-scrolling:touch]", children: /* @__PURE__ */ jsx49("div", { ref: hoursRef, className: "flex flex-col p-1 ", children: hoursList.map((h) => /* @__PURE__ */ jsx49(
|
|
5476
5518
|
Button,
|
|
5477
5519
|
{
|
|
5478
5520
|
variant: "ghost",
|
|
@@ -5487,7 +5529,7 @@ function TimeInput({
|
|
|
5487
5529
|
},
|
|
5488
5530
|
h
|
|
5489
5531
|
)) }) }),
|
|
5490
|
-
/* @__PURE__ */ jsx49("div", { className: "h-56 w-16 overflow-y-auto overscroll-contain", children: /* @__PURE__ */ jsx49("div", { ref: minutesRef, className: "flex flex-col p-1", children: minutesList.map((m) => /* @__PURE__ */ jsx49(
|
|
5532
|
+
/* @__PURE__ */ jsx49("div", { className: "h-56 w-16 overflow-y-auto overscroll-y-contain [-webkit-overflow-scrolling:touch]", children: /* @__PURE__ */ jsx49("div", { ref: minutesRef, className: "flex flex-col p-1", children: minutesList.map((m) => /* @__PURE__ */ jsx49(
|
|
5491
5533
|
Button,
|
|
5492
5534
|
{
|
|
5493
5535
|
variant: "ghost",
|