@mieweb/ui 0.11.0-dev.33 → 0.11.0-dev.34
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/{chunk-PJN4HM2X.cjs → chunk-3O3Q3DX7.cjs} +21 -21
- package/dist/{chunk-PJN4HM2X.cjs.map → chunk-3O3Q3DX7.cjs.map} +1 -1
- package/dist/{chunk-M42FTWY2.cjs → chunk-46RYJYN2.cjs} +6 -6
- package/dist/{chunk-M42FTWY2.cjs.map → chunk-46RYJYN2.cjs.map} +1 -1
- package/dist/{chunk-JMAZ2GKT.js → chunk-4GSFVD5V.js} +3 -3
- package/dist/{chunk-JMAZ2GKT.js.map → chunk-4GSFVD5V.js.map} +1 -1
- package/dist/{chunk-2R3ILG4Y.cjs → chunk-4M2KE4O5.cjs} +7 -7
- package/dist/{chunk-2R3ILG4Y.cjs.map → chunk-4M2KE4O5.cjs.map} +1 -1
- package/dist/{chunk-NAQMIFUF.js → chunk-4SUEBKTY.js} +3 -3
- package/dist/{chunk-NAQMIFUF.js.map → chunk-4SUEBKTY.js.map} +1 -1
- package/dist/{chunk-X6HEWIYP.cjs → chunk-6O6EYKOG.cjs} +130 -874
- package/dist/chunk-6O6EYKOG.cjs.map +1 -0
- package/dist/{chunk-ZNYBLM4O.cjs → chunk-DXNVQQYN.cjs} +4 -4
- package/dist/{chunk-ZNYBLM4O.cjs.map → chunk-DXNVQQYN.cjs.map} +1 -1
- package/dist/{chunk-WEGKY2LY.js → chunk-EWPNM6OO.js} +5 -3
- package/dist/chunk-EWPNM6OO.js.map +1 -0
- package/dist/{chunk-IBEQ54XW.js → chunk-EX7Q5545.js} +4 -4
- package/dist/{chunk-IBEQ54XW.js.map → chunk-EX7Q5545.js.map} +1 -1
- package/dist/{chunk-VV2U36T6.cjs → chunk-MZR634HI.cjs} +9 -9
- package/dist/{chunk-VV2U36T6.cjs.map → chunk-MZR634HI.cjs.map} +1 -1
- package/dist/{chunk-JCO62XMU.cjs → chunk-NCPDUJKJ.cjs} +43 -26
- package/dist/chunk-NCPDUJKJ.cjs.map +1 -0
- package/dist/{chunk-PYAK7XXD.js → chunk-NW6D6AFL.js} +80 -819
- package/dist/chunk-NW6D6AFL.js.map +1 -0
- package/dist/{chunk-ZPPMEUGR.cjs → chunk-PGJLW2NO.cjs} +7 -7
- package/dist/{chunk-ZPPMEUGR.cjs.map → chunk-PGJLW2NO.cjs.map} +1 -1
- package/dist/{chunk-ZFJJMDV3.js → chunk-RTADGBBN.js} +3 -3
- package/dist/{chunk-ZFJJMDV3.js.map → chunk-RTADGBBN.js.map} +1 -1
- package/dist/{chunk-LJ4CCM3V.cjs → chunk-S2CJ57BX.cjs} +5 -3
- package/dist/chunk-S2CJ57BX.cjs.map +1 -0
- package/dist/{chunk-KSQQBFDQ.js → chunk-SPGP252Q.js} +43 -26
- package/dist/chunk-SPGP252Q.js.map +1 -0
- package/dist/{chunk-67SD6VPF.cjs → chunk-SVC7NPQ6.cjs} +6 -6
- package/dist/{chunk-67SD6VPF.cjs.map → chunk-SVC7NPQ6.cjs.map} +1 -1
- package/dist/{chunk-TWQSMUE6.js → chunk-VMEVLBI3.js} +46 -38
- package/dist/chunk-VMEVLBI3.js.map +1 -0
- package/dist/{chunk-QNJEDBIN.js → chunk-X5HLVACK.js} +4 -4
- package/dist/{chunk-QNJEDBIN.js.map → chunk-X5HLVACK.js.map} +1 -1
- package/dist/{chunk-LC3JL2HB.cjs → chunk-XEHD2HA5.cjs} +46 -38
- package/dist/chunk-XEHD2HA5.cjs.map +1 -0
- package/dist/{chunk-R3MJKY63.js → chunk-YGSPIDE4.js} +3 -3
- package/dist/{chunk-R3MJKY63.js.map → chunk-YGSPIDE4.js.map} +1 -1
- package/dist/{chunk-7LKTIZLR.js → chunk-YR45POH2.js} +3 -3
- package/dist/{chunk-7LKTIZLR.js.map → chunk-YR45POH2.js.map} +1 -1
- package/dist/components/AlertDialog/index.cjs +6 -6
- package/dist/components/AlertDialog/index.js +2 -2
- package/dist/components/EmailEditor/index.cjs +12 -12
- package/dist/components/EmailEditor/index.js +3 -3
- package/dist/components/KeyboardShortcutsOverlay/index.cjs +4 -4
- package/dist/components/KeyboardShortcutsOverlay/index.js +2 -2
- package/dist/components/MediaEditor/index.cjs +7 -7
- package/dist/components/MediaEditor/index.js +2 -2
- package/dist/components/MediaFeed/index.cjs +3 -3
- package/dist/components/MediaFeed/index.js +2 -2
- package/dist/components/Modal/index.cjs +9 -9
- package/dist/components/Modal/index.js +1 -1
- package/dist/components/RichTextEditor/index.cjs +4 -4
- package/dist/components/RichTextEditor/index.js +1 -1
- package/dist/components/SuperChat/index.cjs +3 -3
- package/dist/components/SuperChat/index.js +2 -2
- package/dist/components/Textarea/index.cjs +5 -5
- package/dist/components/Textarea/index.js +2 -2
- package/dist/esheet.cjs +462 -1233
- package/dist/esheet.cjs.map +1 -1
- package/dist/esheet.d.cts +2 -2
- package/dist/esheet.d.ts +2 -2
- package/dist/esheet.js +375 -1146
- package/dist/esheet.js.map +1 -1
- package/dist/index.cjs +1011 -239
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +804 -17
- package/dist/index.js.map +1 -1
- package/dist/{model-NPW2JMHZ.cjs → model-EFXX5JZN.cjs} +18 -18
- package/dist/{model-NPW2JMHZ.cjs.map → model-EFXX5JZN.cjs.map} +1 -1
- package/dist/{model-SG5H3TCJ.js → model-TAARSYDY.js} +4 -4
- package/dist/{model-SG5H3TCJ.js.map → model-TAARSYDY.js.map} +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/chunk-JCO62XMU.cjs.map +0 -1
- package/dist/chunk-KSQQBFDQ.js.map +0 -1
- package/dist/chunk-LC3JL2HB.cjs.map +0 -1
- package/dist/chunk-LJ4CCM3V.cjs.map +0 -1
- package/dist/chunk-PYAK7XXD.js.map +0 -1
- package/dist/chunk-TWQSMUE6.js.map +0 -1
- package/dist/chunk-WEGKY2LY.js.map +0 -1
- package/dist/chunk-X6HEWIYP.cjs.map +0 -1
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
import { CodingChips, RowActionToolbar, RowIconButton, currentAssertion } from './chunk-
|
|
1
|
+
import { CodingChips, RowActionToolbar, RowIconButton, currentAssertion } from './chunk-SPGP252Q.js';
|
|
2
2
|
import { Tooltip } from './chunk-YFWDS6MX.js';
|
|
3
3
|
import { RadioGroup, Radio } from './chunk-EPSB4WTL.js';
|
|
4
4
|
import { Label } from './chunk-I3WGZPI6.js';
|
|
5
5
|
import { DateInput } from './chunk-I6Y2KLTZ.js';
|
|
6
|
-
import { Textarea } from './chunk-
|
|
6
|
+
import { Textarea } from './chunk-4SUEBKTY.js';
|
|
7
7
|
import { useMessages } from './chunk-5YOT4DVH.js';
|
|
8
8
|
import { Select } from './chunk-VCI2Y7ST.js';
|
|
9
9
|
import { Dropdown, DropdownItem, DropdownSeparator } from './chunk-OYUIEJPN.js';
|
|
10
10
|
import { Card, CardHeader, CardContent } from './chunk-QYSUYB3S.js';
|
|
11
11
|
import { Checkbox } from './chunk-753Z3NXL.js';
|
|
12
|
-
import { Modal, ModalHeader, ModalTitle, ModalClose, ModalBody, ModalFooter } from './chunk-
|
|
12
|
+
import { Modal, ModalHeader, ModalTitle, ModalClose, ModalBody, ModalFooter } from './chunk-VMEVLBI3.js';
|
|
13
13
|
import { Input } from './chunk-3IMM2PM4.js';
|
|
14
14
|
import { useDragReorder, reorderIds, dragIndicatorClasses } from './chunk-YUMOM3KE.js';
|
|
15
15
|
import { useLiveAnnouncement } from './chunk-HNXLLDPN.js';
|
|
16
|
-
import { useFocusTrap } from './chunk-4SMSH4OY.js';
|
|
17
|
-
import { useEscapeKey } from './chunk-T4ME7QCT.js';
|
|
18
|
-
import { useClickOutside } from './chunk-62ZOA6PX.js';
|
|
19
|
-
import { useAnchoredPosition } from './chunk-WSNMQQ4P.js';
|
|
20
16
|
import { dateToDisplayFormat, isValidDate, displayFormatToDateString } from './chunk-RC2YMOMS.js';
|
|
21
|
-
import { isStorybookDocsMode } from './chunk-VSQF22GL.js';
|
|
22
17
|
import { AlertCircle, Plus, RefreshCw, Pencil, GripVertical, Trash2, StickyNote, Ban, ChevronUp, ChevronDown, Link, MoreVertical, Send, Stethoscope, Scan, TestTube2, Pill, CalendarCheck, ExternalLink, ThumbsUp, HandMetal, ThumbsDown, HelpCircle, AlertTriangle } from './chunk-BKSPDTX4.js';
|
|
23
18
|
import { isRtl } from './chunk-YVKBXNPK.js';
|
|
24
19
|
import { Badge } from './chunk-522WJIVI.js';
|
|
@@ -26,8 +21,6 @@ import { Button } from './chunk-WX2XB6FP.js';
|
|
|
26
21
|
import { cn } from './chunk-TQONQSJO.js';
|
|
27
22
|
import * as React4 from 'react';
|
|
28
23
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
29
|
-
import { createPortal } from 'react-dom';
|
|
30
|
-
import { Calendar, ChevronLeft, ChevronRight, ChevronDown as ChevronDown$1 } from 'lucide-react';
|
|
31
24
|
|
|
32
25
|
var TYPE_ORDER = ["drug", "food", "environmental", "other"];
|
|
33
26
|
var ALLERGY_TYPE_LABELS = {
|
|
@@ -279,7 +272,7 @@ var AllergyList = React4.forwardRef(
|
|
|
279
272
|
onClick: onAdd,
|
|
280
273
|
leftIcon: /* @__PURE__ */ jsx(Plus, { size: 12 }),
|
|
281
274
|
className: "h-auto rounded-full px-2.5 py-1 text-xs",
|
|
282
|
-
children: m("Add
|
|
275
|
+
children: m("Add")
|
|
283
276
|
}
|
|
284
277
|
)
|
|
285
278
|
] })
|
|
@@ -549,7 +542,7 @@ function AllergyManager({
|
|
|
549
542
|
bare: true,
|
|
550
543
|
clearOnSelect: true,
|
|
551
544
|
placeholder: m(
|
|
552
|
-
"Search drug allergens to add \u2014 use Add
|
|
545
|
+
"Search drug allergens to add \u2014 use Add for food/environmental"
|
|
553
546
|
),
|
|
554
547
|
onSelect: (result) => {
|
|
555
548
|
if (requireCode && (!result.codetype.trim() || !result.fullcode.trim()))
|
|
@@ -1159,9 +1152,22 @@ var Assessment = React4.forwardRef(
|
|
|
1159
1152
|
const [pendingFreeText, setPendingFreeText] = React4.useState(
|
|
1160
1153
|
null
|
|
1161
1154
|
);
|
|
1155
|
+
const [freeDraft, setFreeDraft] = React4.useState("");
|
|
1162
1156
|
React4.useEffect(() => {
|
|
1163
1157
|
if (addMode !== "auto") setPendingFreeText(null);
|
|
1164
1158
|
}, [addMode]);
|
|
1159
|
+
const handleAddFreeText = (text) => {
|
|
1160
|
+
if (addMode === "problem") {
|
|
1161
|
+
onAddAssessment?.({ label: text });
|
|
1162
|
+
} else if (addMode === "order") {
|
|
1163
|
+
onAddOrder?.(null, {
|
|
1164
|
+
type: "procedure",
|
|
1165
|
+
display: text
|
|
1166
|
+
});
|
|
1167
|
+
} else {
|
|
1168
|
+
setPendingFreeText(text);
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1165
1171
|
const [announcement, setAnnouncement] = useLiveAnnouncement();
|
|
1166
1172
|
const ambientCodeLookup = useCodeLookupConfig();
|
|
1167
1173
|
const effectiveRenderOrderSearch = renderOrderSearch === false ? void 0 : renderOrderSearch ?? (ambientCodeLookup ? contextOrderSearch(ambientCodeLookup) : void 0);
|
|
@@ -1537,7 +1543,7 @@ var Assessment = React4.forwardRef(
|
|
|
1537
1543
|
item.concernId
|
|
1538
1544
|
);
|
|
1539
1545
|
}) }),
|
|
1540
|
-
!readOnly && availableAddModes.length > 0 &&
|
|
1546
|
+
!readOnly && availableAddModes.length > 0 && (onAddAssessment || onAddOrder) && /* @__PURE__ */ jsxs(
|
|
1541
1547
|
"div",
|
|
1542
1548
|
{
|
|
1543
1549
|
role: "form",
|
|
@@ -1566,7 +1572,7 @@ var Assessment = React4.forwardRef(
|
|
|
1566
1572
|
]
|
|
1567
1573
|
}
|
|
1568
1574
|
),
|
|
1569
|
-
/* @__PURE__ */ jsx("div", { className: "min-w-64 flex-1", children: effectiveRenderOrderSearch({
|
|
1575
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-64 flex-1", children: effectiveRenderOrderSearch ? effectiveRenderOrderSearch({
|
|
1570
1576
|
domains: addMode === "problem" ? ["condition", "occupational"] : addMode === "order" ? ["med", "lab", "procedure", "vaccine"] : void 0,
|
|
1571
1577
|
// auto: everything — the pick decides
|
|
1572
1578
|
// auto: concerns rank ahead of orders — surveillance
|
|
@@ -1603,19 +1609,46 @@ var Assessment = React4.forwardRef(
|
|
|
1603
1609
|
});
|
|
1604
1610
|
}
|
|
1605
1611
|
},
|
|
1606
|
-
onFreeText:
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1612
|
+
onFreeText: handleAddFreeText
|
|
1613
|
+
}) : /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
1614
|
+
/* @__PURE__ */ jsx(
|
|
1615
|
+
"input",
|
|
1616
|
+
{
|
|
1617
|
+
type: "text",
|
|
1618
|
+
"data-slot": "input",
|
|
1619
|
+
value: freeDraft,
|
|
1620
|
+
onChange: (e) => setFreeDraft(e.target.value),
|
|
1621
|
+
onKeyDown: (e) => {
|
|
1622
|
+
if (e.key === "Enter" && freeDraft.trim()) {
|
|
1623
|
+
handleAddFreeText(freeDraft.trim());
|
|
1624
|
+
setFreeDraft("");
|
|
1625
|
+
}
|
|
1626
|
+
},
|
|
1627
|
+
placeholder: m("Type a name and press Enter\u2026"),
|
|
1628
|
+
"aria-label": m("Add as free text"),
|
|
1629
|
+
className: cn(
|
|
1630
|
+
"border-border bg-background text-foreground placeholder:text-muted-foreground",
|
|
1631
|
+
"h-10 w-full rounded-md border px-2.5 text-sm",
|
|
1632
|
+
"focus:ring-ring focus:ring-2 focus:outline-none"
|
|
1633
|
+
)
|
|
1616
1634
|
}
|
|
1617
|
-
|
|
1618
|
-
|
|
1635
|
+
),
|
|
1636
|
+
/* @__PURE__ */ jsx(
|
|
1637
|
+
Button,
|
|
1638
|
+
{
|
|
1639
|
+
variant: "outline",
|
|
1640
|
+
size: "sm",
|
|
1641
|
+
onClick: () => {
|
|
1642
|
+
handleAddFreeText(freeDraft.trim());
|
|
1643
|
+
setFreeDraft("");
|
|
1644
|
+
},
|
|
1645
|
+
disabled: !freeDraft.trim(),
|
|
1646
|
+
leftIcon: /* @__PURE__ */ jsx(Plus, { size: 12 }),
|
|
1647
|
+
className: "h-10",
|
|
1648
|
+
children: m("Add")
|
|
1649
|
+
}
|
|
1650
|
+
)
|
|
1651
|
+
] }) }),
|
|
1619
1652
|
addMode === "auto" && pendingFreeText !== null && /* @__PURE__ */ jsxs(
|
|
1620
1653
|
"div",
|
|
1621
1654
|
{
|
|
@@ -2388,793 +2421,6 @@ function ConditionEditor({
|
|
|
2388
2421
|
);
|
|
2389
2422
|
}
|
|
2390
2423
|
ConditionEditor.displayName = "ConditionEditor";
|
|
2391
|
-
function getDefaultPresets(labels = {}) {
|
|
2392
|
-
const {
|
|
2393
|
-
today = "Today",
|
|
2394
|
-
thisWeek = "This Week",
|
|
2395
|
-
thisMonth = "This Month",
|
|
2396
|
-
lastMonth = "Last Month",
|
|
2397
|
-
last24Hours = "Last 24 Hours",
|
|
2398
|
-
last7Days = "Last 7 Days",
|
|
2399
|
-
last30Days = "Last 30 Days"
|
|
2400
|
-
} = labels;
|
|
2401
|
-
return [
|
|
2402
|
-
{ key: "today", label: today },
|
|
2403
|
-
{ key: "this-week", label: thisWeek },
|
|
2404
|
-
{ key: "this-month", label: thisMonth },
|
|
2405
|
-
{ key: "last-month", label: lastMonth },
|
|
2406
|
-
{ key: "last-24-hours", label: last24Hours },
|
|
2407
|
-
{ key: "last-7-days", label: last7Days },
|
|
2408
|
-
{ key: "last-30-days", label: last30Days }
|
|
2409
|
-
];
|
|
2410
|
-
}
|
|
2411
|
-
function getExtendedPresets(labels = {}) {
|
|
2412
|
-
const {
|
|
2413
|
-
today = "Today",
|
|
2414
|
-
yesterday = "Yesterday",
|
|
2415
|
-
thisWeek = "This Week",
|
|
2416
|
-
lastWeek = "Last Week",
|
|
2417
|
-
thisMonth = "This Month",
|
|
2418
|
-
lastMonth = "Last Month",
|
|
2419
|
-
thisQuarter = "This Quarter",
|
|
2420
|
-
lastQuarter = "Last Quarter",
|
|
2421
|
-
thisYear = "This Year",
|
|
2422
|
-
lastYear = "Last Year",
|
|
2423
|
-
last24Hours = "Last 24 Hours",
|
|
2424
|
-
last7Days = "Last 7 Days",
|
|
2425
|
-
last30Days = "Last 30 Days",
|
|
2426
|
-
last90Days = "Last 90 Days",
|
|
2427
|
-
last365Days = "Last 365 Days"
|
|
2428
|
-
} = labels;
|
|
2429
|
-
return [
|
|
2430
|
-
{ key: "today", label: today },
|
|
2431
|
-
{ key: "yesterday", label: yesterday },
|
|
2432
|
-
{ key: "last-24-hours", label: last24Hours },
|
|
2433
|
-
{ key: "this-week", label: thisWeek },
|
|
2434
|
-
{ key: "last-week", label: lastWeek },
|
|
2435
|
-
{ key: "last-7-days", label: last7Days },
|
|
2436
|
-
{ key: "this-month", label: thisMonth },
|
|
2437
|
-
{ key: "last-month", label: lastMonth },
|
|
2438
|
-
{ key: "last-30-days", label: last30Days },
|
|
2439
|
-
{ key: "this-quarter", label: thisQuarter },
|
|
2440
|
-
{ key: "last-quarter", label: lastQuarter },
|
|
2441
|
-
{ key: "last-90-days", label: last90Days },
|
|
2442
|
-
{ key: "this-year", label: thisYear },
|
|
2443
|
-
{ key: "last-year", label: lastYear },
|
|
2444
|
-
{ key: "last-365-days", label: last365Days }
|
|
2445
|
-
];
|
|
2446
|
-
}
|
|
2447
|
-
function endOfDay(d) {
|
|
2448
|
-
return new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59, 59, 999);
|
|
2449
|
-
}
|
|
2450
|
-
function calculateDateRange(presetKey) {
|
|
2451
|
-
const now = /* @__PURE__ */ new Date();
|
|
2452
|
-
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
2453
|
-
switch (presetKey) {
|
|
2454
|
-
case "today":
|
|
2455
|
-
return { start: today, end: endOfDay(today) };
|
|
2456
|
-
case "yesterday": {
|
|
2457
|
-
const yesterday = new Date(today);
|
|
2458
|
-
yesterday.setDate(today.getDate() - 1);
|
|
2459
|
-
return { start: yesterday, end: endOfDay(yesterday) };
|
|
2460
|
-
}
|
|
2461
|
-
case "this-week": {
|
|
2462
|
-
const dayOfWeek = today.getDay();
|
|
2463
|
-
const sunday = new Date(today);
|
|
2464
|
-
sunday.setDate(today.getDate() - dayOfWeek);
|
|
2465
|
-
const saturday = new Date(sunday);
|
|
2466
|
-
saturday.setDate(sunday.getDate() + 6);
|
|
2467
|
-
return { start: sunday, end: endOfDay(saturday) };
|
|
2468
|
-
}
|
|
2469
|
-
case "last-week": {
|
|
2470
|
-
const dayOfWeek = today.getDay();
|
|
2471
|
-
const lastSunday = new Date(today);
|
|
2472
|
-
lastSunday.setDate(today.getDate() - dayOfWeek - 7);
|
|
2473
|
-
const lastSaturday = new Date(lastSunday);
|
|
2474
|
-
lastSaturday.setDate(lastSunday.getDate() + 6);
|
|
2475
|
-
return { start: lastSunday, end: endOfDay(lastSaturday) };
|
|
2476
|
-
}
|
|
2477
|
-
case "this-month": {
|
|
2478
|
-
const firstDay = new Date(now.getFullYear(), now.getMonth(), 1);
|
|
2479
|
-
const lastDay = new Date(now.getFullYear(), now.getMonth() + 1, 0);
|
|
2480
|
-
return { start: firstDay, end: endOfDay(lastDay) };
|
|
2481
|
-
}
|
|
2482
|
-
case "last-month": {
|
|
2483
|
-
const firstDay = new Date(now.getFullYear(), now.getMonth() - 1, 1);
|
|
2484
|
-
const lastDay = new Date(now.getFullYear(), now.getMonth(), 0);
|
|
2485
|
-
return { start: firstDay, end: endOfDay(lastDay) };
|
|
2486
|
-
}
|
|
2487
|
-
case "this-quarter": {
|
|
2488
|
-
const quarter = Math.floor(now.getMonth() / 3);
|
|
2489
|
-
const firstDay = new Date(now.getFullYear(), quarter * 3, 1);
|
|
2490
|
-
const lastDay = new Date(now.getFullYear(), quarter * 3 + 3, 0);
|
|
2491
|
-
return { start: firstDay, end: endOfDay(lastDay) };
|
|
2492
|
-
}
|
|
2493
|
-
case "last-quarter": {
|
|
2494
|
-
const quarter = Math.floor(now.getMonth() / 3);
|
|
2495
|
-
const firstDay = new Date(now.getFullYear(), (quarter - 1) * 3, 1);
|
|
2496
|
-
const lastDay = new Date(now.getFullYear(), quarter * 3, 0);
|
|
2497
|
-
return { start: firstDay, end: endOfDay(lastDay) };
|
|
2498
|
-
}
|
|
2499
|
-
case "this-year": {
|
|
2500
|
-
const firstDay = new Date(now.getFullYear(), 0, 1);
|
|
2501
|
-
const lastDay = new Date(now.getFullYear(), 11, 31);
|
|
2502
|
-
return { start: firstDay, end: endOfDay(lastDay) };
|
|
2503
|
-
}
|
|
2504
|
-
case "last-year": {
|
|
2505
|
-
const firstDay = new Date(now.getFullYear() - 1, 0, 1);
|
|
2506
|
-
const lastDay = new Date(now.getFullYear() - 1, 11, 31);
|
|
2507
|
-
return { start: firstDay, end: endOfDay(lastDay) };
|
|
2508
|
-
}
|
|
2509
|
-
case "last-24-hours":
|
|
2510
|
-
return {
|
|
2511
|
-
start: new Date(now.getTime() - 24 * 60 * 60 * 1e3),
|
|
2512
|
-
end: now
|
|
2513
|
-
};
|
|
2514
|
-
case "last-7-days":
|
|
2515
|
-
return {
|
|
2516
|
-
start: new Date(now.getTime() - 7 * 24 * 60 * 60 * 1e3),
|
|
2517
|
-
end: now
|
|
2518
|
-
};
|
|
2519
|
-
case "last-30-days":
|
|
2520
|
-
return {
|
|
2521
|
-
start: new Date(now.getTime() - 30 * 24 * 60 * 60 * 1e3),
|
|
2522
|
-
end: now
|
|
2523
|
-
};
|
|
2524
|
-
case "last-90-days":
|
|
2525
|
-
return {
|
|
2526
|
-
start: new Date(now.getTime() - 90 * 24 * 60 * 60 * 1e3),
|
|
2527
|
-
end: now
|
|
2528
|
-
};
|
|
2529
|
-
case "last-365-days":
|
|
2530
|
-
return {
|
|
2531
|
-
start: new Date(now.getTime() - 365 * 24 * 60 * 60 * 1e3),
|
|
2532
|
-
end: now
|
|
2533
|
-
};
|
|
2534
|
-
default:
|
|
2535
|
-
return { start: null, end: null };
|
|
2536
|
-
}
|
|
2537
|
-
}
|
|
2538
|
-
function formatDateRange(range) {
|
|
2539
|
-
if (!range.start && !range.end) return "";
|
|
2540
|
-
const formatDate = (d) => {
|
|
2541
|
-
if (!d) return "";
|
|
2542
|
-
return d.toLocaleDateString("en-US", {
|
|
2543
|
-
month: "short",
|
|
2544
|
-
day: "numeric",
|
|
2545
|
-
year: "numeric"
|
|
2546
|
-
});
|
|
2547
|
-
};
|
|
2548
|
-
if (range.start && range.end) {
|
|
2549
|
-
return `${formatDate(range.start)} - ${formatDate(range.end)}`;
|
|
2550
|
-
}
|
|
2551
|
-
return formatDate(range.start || range.end);
|
|
2552
|
-
}
|
|
2553
|
-
function DateRangePicker({
|
|
2554
|
-
value,
|
|
2555
|
-
onChange,
|
|
2556
|
-
presets,
|
|
2557
|
-
activePreset,
|
|
2558
|
-
placeholder = "Pick a date range",
|
|
2559
|
-
className,
|
|
2560
|
-
align = "auto",
|
|
2561
|
-
showPresets = true,
|
|
2562
|
-
variant = "desktop",
|
|
2563
|
-
labels = {}
|
|
2564
|
-
}) {
|
|
2565
|
-
const finalPresets = presets || getDefaultPresets(labels);
|
|
2566
|
-
const [isCalendarOpen, setIsCalendarOpen] = React4.useState(false);
|
|
2567
|
-
const [leftMonth, setLeftMonth] = React4.useState(
|
|
2568
|
-
() => value?.start?.getMonth() ?? (/* @__PURE__ */ new Date()).getMonth()
|
|
2569
|
-
);
|
|
2570
|
-
const [leftYear, setLeftYear] = React4.useState(
|
|
2571
|
-
() => value?.start?.getFullYear() ?? (/* @__PURE__ */ new Date()).getFullYear()
|
|
2572
|
-
);
|
|
2573
|
-
const [rangeStart, setRangeStart] = React4.useState(
|
|
2574
|
-
value?.start ?? null
|
|
2575
|
-
);
|
|
2576
|
-
const [rangeEnd, setRangeEnd] = React4.useState(
|
|
2577
|
-
value?.end ?? null
|
|
2578
|
-
);
|
|
2579
|
-
const [selectingEnd, setSelectingEnd] = React4.useState(false);
|
|
2580
|
-
const [hoverDate, setHoverDate] = React4.useState(null);
|
|
2581
|
-
const calendarRef = React4.useRef(null);
|
|
2582
|
-
const triggerRef = React4.useRef(null);
|
|
2583
|
-
const [resolvedAlign, setResolvedAlign] = React4.useState(
|
|
2584
|
-
align === "end" ? "end" : "start"
|
|
2585
|
-
);
|
|
2586
|
-
const isMobileVariant = variant === "mobile";
|
|
2587
|
-
const isResponsive = variant === "responsive";
|
|
2588
|
-
const focusTrapRef = useFocusTrap(
|
|
2589
|
-
isMobileVariant && isCalendarOpen
|
|
2590
|
-
);
|
|
2591
|
-
const rightMonth = leftMonth === 11 ? 0 : leftMonth + 1;
|
|
2592
|
-
const rightYear = leftMonth === 11 ? leftYear + 1 : leftYear;
|
|
2593
|
-
React4.useEffect(() => {
|
|
2594
|
-
if (!value) {
|
|
2595
|
-
setRangeStart(null);
|
|
2596
|
-
setRangeEnd(null);
|
|
2597
|
-
return;
|
|
2598
|
-
}
|
|
2599
|
-
setRangeStart(value.start ?? null);
|
|
2600
|
-
setRangeEnd(value.end ?? null);
|
|
2601
|
-
}, [value]);
|
|
2602
|
-
const wrapperRef = React4.useRef(null);
|
|
2603
|
-
const outsideRefs = React4.useMemo(
|
|
2604
|
-
() => [wrapperRef, calendarRef],
|
|
2605
|
-
[calendarRef]
|
|
2606
|
-
);
|
|
2607
|
-
useClickOutside(
|
|
2608
|
-
outsideRefs,
|
|
2609
|
-
() => {
|
|
2610
|
-
setIsCalendarOpen(false);
|
|
2611
|
-
setSelectingEnd(false);
|
|
2612
|
-
},
|
|
2613
|
-
isCalendarOpen
|
|
2614
|
-
);
|
|
2615
|
-
const { anchorRef, floatingRef, style } = useAnchoredPosition({
|
|
2616
|
-
open: !isMobileVariant && isCalendarOpen,
|
|
2617
|
-
placement: resolvedAlign === "end" ? "bottom-end" : "bottom-start"
|
|
2618
|
-
});
|
|
2619
|
-
useEscapeKey(() => {
|
|
2620
|
-
setIsCalendarOpen(false);
|
|
2621
|
-
setSelectingEnd(false);
|
|
2622
|
-
triggerRef.current?.focus();
|
|
2623
|
-
}, isCalendarOpen);
|
|
2624
|
-
React4.useEffect(() => {
|
|
2625
|
-
if (isStorybookDocsMode()) return;
|
|
2626
|
-
if (isMobileVariant && isCalendarOpen) {
|
|
2627
|
-
const prev = document.body.style.overflow;
|
|
2628
|
-
document.body.style.overflow = "hidden";
|
|
2629
|
-
return () => {
|
|
2630
|
-
document.body.style.overflow = prev;
|
|
2631
|
-
};
|
|
2632
|
-
}
|
|
2633
|
-
}, [isMobileVariant, isCalendarOpen]);
|
|
2634
|
-
React4.useLayoutEffect(() => {
|
|
2635
|
-
if (isMobileVariant || !isCalendarOpen) return;
|
|
2636
|
-
if (align === "start" || align === "end") {
|
|
2637
|
-
setResolvedAlign(align);
|
|
2638
|
-
return;
|
|
2639
|
-
}
|
|
2640
|
-
if (typeof window === "undefined") return;
|
|
2641
|
-
const trigger = triggerRef.current;
|
|
2642
|
-
if (!trigger) return;
|
|
2643
|
-
const rect = trigger.getBoundingClientRect();
|
|
2644
|
-
const estimatedPopupWidth = showPresets ? 840 : 640;
|
|
2645
|
-
const margin = 8;
|
|
2646
|
-
const overflowsRight = rect.left + estimatedPopupWidth > window.innerWidth - margin;
|
|
2647
|
-
const fitsLeftAligned = rect.right - estimatedPopupWidth >= margin;
|
|
2648
|
-
setResolvedAlign(overflowsRight && fitsLeftAligned ? "end" : "start");
|
|
2649
|
-
}, [align, isCalendarOpen, isMobileVariant, showPresets]);
|
|
2650
|
-
const handlePresetSelect = (presetKey) => {
|
|
2651
|
-
const range = calculateDateRange(presetKey);
|
|
2652
|
-
setRangeStart(range.start);
|
|
2653
|
-
setRangeEnd(range.end);
|
|
2654
|
-
setSelectingEnd(false);
|
|
2655
|
-
setIsCalendarOpen(false);
|
|
2656
|
-
if (range.start) {
|
|
2657
|
-
setLeftMonth(range.start.getMonth());
|
|
2658
|
-
setLeftYear(range.start.getFullYear());
|
|
2659
|
-
}
|
|
2660
|
-
onChange(range, presetKey);
|
|
2661
|
-
};
|
|
2662
|
-
const handleDayClick = (day, month, year) => {
|
|
2663
|
-
const clicked = new Date(year, month, day);
|
|
2664
|
-
if (!selectingEnd) {
|
|
2665
|
-
setRangeStart(clicked);
|
|
2666
|
-
setRangeEnd(null);
|
|
2667
|
-
setSelectingEnd(true);
|
|
2668
|
-
} else {
|
|
2669
|
-
let start = rangeStart;
|
|
2670
|
-
let end = clicked;
|
|
2671
|
-
if (end < start) {
|
|
2672
|
-
[start, end] = [end, start];
|
|
2673
|
-
}
|
|
2674
|
-
setRangeStart(start);
|
|
2675
|
-
setRangeEnd(end);
|
|
2676
|
-
setSelectingEnd(false);
|
|
2677
|
-
if (variant !== "mobile") {
|
|
2678
|
-
setIsCalendarOpen(false);
|
|
2679
|
-
}
|
|
2680
|
-
onChange({ start, end });
|
|
2681
|
-
}
|
|
2682
|
-
};
|
|
2683
|
-
const toggleCalendar = () => {
|
|
2684
|
-
if (!isCalendarOpen) {
|
|
2685
|
-
if (value?.start) {
|
|
2686
|
-
setRangeStart(value.start);
|
|
2687
|
-
setRangeEnd(value.end ?? null);
|
|
2688
|
-
setLeftMonth(value.start.getMonth());
|
|
2689
|
-
setLeftYear(value.start.getFullYear());
|
|
2690
|
-
} else {
|
|
2691
|
-
const now = /* @__PURE__ */ new Date();
|
|
2692
|
-
setLeftMonth(now.getMonth());
|
|
2693
|
-
setLeftYear(now.getFullYear());
|
|
2694
|
-
}
|
|
2695
|
-
setSelectingEnd(false);
|
|
2696
|
-
}
|
|
2697
|
-
setIsCalendarOpen(!isCalendarOpen);
|
|
2698
|
-
};
|
|
2699
|
-
const goToPrevMonth = () => {
|
|
2700
|
-
if (leftMonth === 0) {
|
|
2701
|
-
setLeftMonth(11);
|
|
2702
|
-
setLeftYear(leftYear - 1);
|
|
2703
|
-
} else {
|
|
2704
|
-
setLeftMonth(leftMonth - 1);
|
|
2705
|
-
}
|
|
2706
|
-
};
|
|
2707
|
-
const goToNextMonth = () => {
|
|
2708
|
-
if (leftMonth === 11) {
|
|
2709
|
-
setLeftMonth(0);
|
|
2710
|
-
setLeftYear(leftYear + 1);
|
|
2711
|
-
} else {
|
|
2712
|
-
setLeftMonth(leftMonth + 1);
|
|
2713
|
-
}
|
|
2714
|
-
};
|
|
2715
|
-
const getDaysInMonth = (month, year) => new Date(year, month + 1, 0).getDate();
|
|
2716
|
-
const getFirstDayOfMonth = (month, year) => new Date(year, month, 1).getDay();
|
|
2717
|
-
const isSameDay = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
2718
|
-
const isInRange = (date) => {
|
|
2719
|
-
const start = rangeStart;
|
|
2720
|
-
const end = selectingEnd ? hoverDate : rangeEnd;
|
|
2721
|
-
if (!start || !end) return false;
|
|
2722
|
-
const [lo, hi] = start <= end ? [start, end] : [end, start];
|
|
2723
|
-
return date > lo && date < hi;
|
|
2724
|
-
};
|
|
2725
|
-
const isStart = (date) => {
|
|
2726
|
-
if (!rangeStart) return false;
|
|
2727
|
-
return isSameDay(date, rangeStart);
|
|
2728
|
-
};
|
|
2729
|
-
const isEnd = (date) => {
|
|
2730
|
-
const end = selectingEnd ? hoverDate : rangeEnd;
|
|
2731
|
-
if (!end) return false;
|
|
2732
|
-
return isSameDay(date, end);
|
|
2733
|
-
};
|
|
2734
|
-
const isToday = (date) => {
|
|
2735
|
-
const today = /* @__PURE__ */ new Date();
|
|
2736
|
-
return isSameDay(date, today);
|
|
2737
|
-
};
|
|
2738
|
-
const displayValue = value ? formatDateRange(value) : "";
|
|
2739
|
-
const monthNames = React4.useMemo(
|
|
2740
|
-
() => Array.from(
|
|
2741
|
-
{ length: 12 },
|
|
2742
|
-
(_, i) => new Intl.DateTimeFormat(void 0, { month: "long" }).format(
|
|
2743
|
-
new Date(2e3, i, 1)
|
|
2744
|
-
)
|
|
2745
|
-
),
|
|
2746
|
-
[]
|
|
2747
|
-
);
|
|
2748
|
-
const weekdayNames = React4.useMemo(
|
|
2749
|
-
() => Array.from(
|
|
2750
|
-
{ length: 7 },
|
|
2751
|
-
(_, i) => new Intl.DateTimeFormat(void 0, { weekday: "short" }).format(
|
|
2752
|
-
new Date(1970, 0, 4 + i)
|
|
2753
|
-
)
|
|
2754
|
-
),
|
|
2755
|
-
[]
|
|
2756
|
-
);
|
|
2757
|
-
const renderMonthGrid = (month, year) => {
|
|
2758
|
-
const daysInMonth = getDaysInMonth(month, year);
|
|
2759
|
-
const firstDay = getFirstDayOfMonth(month, year);
|
|
2760
|
-
const prevMonth = month === 0 ? 11 : month - 1;
|
|
2761
|
-
const prevYear = month === 0 ? year - 1 : year;
|
|
2762
|
-
const daysInPrevMonth = getDaysInMonth(prevMonth, prevYear);
|
|
2763
|
-
const cells = [];
|
|
2764
|
-
for (let i = firstDay - 1; i >= 0; i--) {
|
|
2765
|
-
cells.push({
|
|
2766
|
-
day: daysInPrevMonth - i,
|
|
2767
|
-
month: prevMonth,
|
|
2768
|
-
year: prevYear,
|
|
2769
|
-
isCurrentMonth: false
|
|
2770
|
-
});
|
|
2771
|
-
}
|
|
2772
|
-
for (let i = 1; i <= daysInMonth; i++) {
|
|
2773
|
-
cells.push({ day: i, month, year, isCurrentMonth: true });
|
|
2774
|
-
}
|
|
2775
|
-
const nextMonth = month === 11 ? 0 : month + 1;
|
|
2776
|
-
const nextYear = month === 11 ? year + 1 : year;
|
|
2777
|
-
const remaining = 42 - cells.length;
|
|
2778
|
-
for (let i = 1; i <= remaining; i++) {
|
|
2779
|
-
cells.push({
|
|
2780
|
-
day: i,
|
|
2781
|
-
month: nextMonth,
|
|
2782
|
-
year: nextYear,
|
|
2783
|
-
isCurrentMonth: false
|
|
2784
|
-
});
|
|
2785
|
-
}
|
|
2786
|
-
return /* @__PURE__ */ jsxs("div", { className: "w-[280px]", "data-slot": "date-range-grid", children: [
|
|
2787
|
-
/* @__PURE__ */ jsx("div", { className: "mb-1 grid grid-cols-7", "data-slot": "date-range-weekdays", children: weekdayNames.map((dayName) => /* @__PURE__ */ jsx(
|
|
2788
|
-
"div",
|
|
2789
|
-
{
|
|
2790
|
-
className: "text-muted-foreground py-1 text-center text-xs font-medium",
|
|
2791
|
-
"data-slot": "date-range-weekday",
|
|
2792
|
-
children: dayName
|
|
2793
|
-
},
|
|
2794
|
-
dayName
|
|
2795
|
-
)) }),
|
|
2796
|
-
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-7", "data-slot": "date-range-day-grid", children: cells.map((cell, index) => {
|
|
2797
|
-
const date = new Date(cell.year, cell.month, cell.day);
|
|
2798
|
-
const inRange = isInRange(date);
|
|
2799
|
-
const start = isStart(date);
|
|
2800
|
-
const end = isEnd(date);
|
|
2801
|
-
const today = isToday(date);
|
|
2802
|
-
return /* @__PURE__ */ jsx(
|
|
2803
|
-
"button",
|
|
2804
|
-
{
|
|
2805
|
-
type: "button",
|
|
2806
|
-
"data-slot": "date-range-day",
|
|
2807
|
-
onClick: () => handleDayClick(cell.day, cell.month, cell.year),
|
|
2808
|
-
onMouseEnter: () => {
|
|
2809
|
-
if (selectingEnd) {
|
|
2810
|
-
setHoverDate(date);
|
|
2811
|
-
}
|
|
2812
|
-
},
|
|
2813
|
-
className: cn(
|
|
2814
|
-
"relative h-9 w-10 text-center text-sm",
|
|
2815
|
-
"focus:ring-ring focus:z-10 focus:ring-2 focus:outline-none",
|
|
2816
|
-
"transition-colors",
|
|
2817
|
-
// Not current month — dimmed
|
|
2818
|
-
!cell.isCurrentMonth && "text-muted-foreground/50",
|
|
2819
|
-
// Current month — normal
|
|
2820
|
-
cell.isCurrentMonth && "text-foreground",
|
|
2821
|
-
// Hover
|
|
2822
|
-
"hover:bg-muted",
|
|
2823
|
-
// In range background
|
|
2824
|
-
inRange && "bg-muted",
|
|
2825
|
-
// Start date
|
|
2826
|
-
start && "bg-foreground text-background hover:bg-foreground rounded-s-md font-semibold",
|
|
2827
|
-
// End date
|
|
2828
|
-
end && !start && "border-foreground text-foreground rounded-e-md border font-semibold",
|
|
2829
|
-
// Today indicator (only if not start/end)
|
|
2830
|
-
today && !start && !end && "font-semibold"
|
|
2831
|
-
),
|
|
2832
|
-
children: cell.day
|
|
2833
|
-
},
|
|
2834
|
-
index
|
|
2835
|
-
);
|
|
2836
|
-
}) })
|
|
2837
|
-
] });
|
|
2838
|
-
};
|
|
2839
|
-
return /* @__PURE__ */ jsxs(
|
|
2840
|
-
"div",
|
|
2841
|
-
{
|
|
2842
|
-
ref: (node) => {
|
|
2843
|
-
wrapperRef.current = node;
|
|
2844
|
-
anchorRef.current = node;
|
|
2845
|
-
},
|
|
2846
|
-
className: cn("relative inline-block", className),
|
|
2847
|
-
"data-slot": "date-range-picker",
|
|
2848
|
-
children: [
|
|
2849
|
-
/* @__PURE__ */ jsxs(
|
|
2850
|
-
"button",
|
|
2851
|
-
{
|
|
2852
|
-
ref: triggerRef,
|
|
2853
|
-
type: "button",
|
|
2854
|
-
onClick: toggleCalendar,
|
|
2855
|
-
"aria-expanded": isCalendarOpen,
|
|
2856
|
-
"aria-haspopup": "dialog",
|
|
2857
|
-
"data-slot": "date-range-trigger",
|
|
2858
|
-
className: cn(
|
|
2859
|
-
"border-input bg-background hover:bg-muted",
|
|
2860
|
-
"inline-flex w-[300px] items-center gap-2 rounded-md border px-4 py-2 text-start text-sm font-normal",
|
|
2861
|
-
"focus:ring-ring focus:ring-2 focus:outline-none",
|
|
2862
|
-
"transition-colors",
|
|
2863
|
-
!displayValue && "text-muted-foreground"
|
|
2864
|
-
),
|
|
2865
|
-
children: [
|
|
2866
|
-
/* @__PURE__ */ jsx(Calendar, { className: "h-4 w-4", "data-slot": "date-range-trigger-icon" }),
|
|
2867
|
-
displayValue || placeholder
|
|
2868
|
-
]
|
|
2869
|
-
}
|
|
2870
|
-
),
|
|
2871
|
-
isMobileVariant && isCalendarOpen && // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
2872
|
-
/* @__PURE__ */ jsx(
|
|
2873
|
-
"div",
|
|
2874
|
-
{
|
|
2875
|
-
"data-slot": "date-range-mobile-overlay",
|
|
2876
|
-
className: "fixed inset-0 z-50 flex items-end justify-center bg-black/40",
|
|
2877
|
-
onClick: (event) => {
|
|
2878
|
-
if (event.target !== event.currentTarget) return;
|
|
2879
|
-
setIsCalendarOpen(false);
|
|
2880
|
-
setSelectingEnd(false);
|
|
2881
|
-
setHoverDate(null);
|
|
2882
|
-
if (triggerRef.current instanceof HTMLElement) {
|
|
2883
|
-
triggerRef.current.focus();
|
|
2884
|
-
}
|
|
2885
|
-
},
|
|
2886
|
-
children: /* @__PURE__ */ jsxs(
|
|
2887
|
-
"div",
|
|
2888
|
-
{
|
|
2889
|
-
ref: (node) => {
|
|
2890
|
-
calendarRef.current = node;
|
|
2891
|
-
focusTrapRef.current = node;
|
|
2892
|
-
},
|
|
2893
|
-
className: "bg-background animate-in slide-in-from-bottom max-h-[90vh] w-full max-w-md overflow-y-auto rounded-t-2xl px-6 pt-4 pb-6 shadow-xl",
|
|
2894
|
-
role: "dialog",
|
|
2895
|
-
"aria-modal": "true",
|
|
2896
|
-
"aria-labelledby": "mobile-date-range-title",
|
|
2897
|
-
"data-slot": "date-range-mobile-sheet",
|
|
2898
|
-
children: [
|
|
2899
|
-
/* @__PURE__ */ jsx(
|
|
2900
|
-
"div",
|
|
2901
|
-
{
|
|
2902
|
-
className: "bg-muted mx-auto mb-4 h-1 w-10 rounded-full",
|
|
2903
|
-
"data-slot": "date-range-mobile-handle"
|
|
2904
|
-
}
|
|
2905
|
-
),
|
|
2906
|
-
/* @__PURE__ */ jsx(
|
|
2907
|
-
"h3",
|
|
2908
|
-
{
|
|
2909
|
-
id: "mobile-date-range-title",
|
|
2910
|
-
className: "mb-4 text-lg font-semibold",
|
|
2911
|
-
"data-slot": "date-range-mobile-title",
|
|
2912
|
-
children: placeholder
|
|
2913
|
-
}
|
|
2914
|
-
),
|
|
2915
|
-
/* @__PURE__ */ jsxs(
|
|
2916
|
-
"div",
|
|
2917
|
-
{
|
|
2918
|
-
className: "mb-3 flex items-center justify-center gap-4",
|
|
2919
|
-
"data-slot": "date-range-month-header",
|
|
2920
|
-
children: [
|
|
2921
|
-
/* @__PURE__ */ jsx(
|
|
2922
|
-
"button",
|
|
2923
|
-
{
|
|
2924
|
-
type: "button",
|
|
2925
|
-
onClick: goToPrevMonth,
|
|
2926
|
-
className: "hover:bg-muted rounded-md p-1 transition-colors",
|
|
2927
|
-
"aria-label": "Previous month",
|
|
2928
|
-
"data-slot": "date-range-nav",
|
|
2929
|
-
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4 rtl:-scale-x-100" })
|
|
2930
|
-
}
|
|
2931
|
-
),
|
|
2932
|
-
/* @__PURE__ */ jsxs(
|
|
2933
|
-
"div",
|
|
2934
|
-
{
|
|
2935
|
-
className: "text-sm font-medium",
|
|
2936
|
-
"data-slot": "date-range-month-label",
|
|
2937
|
-
children: [
|
|
2938
|
-
monthNames[leftMonth],
|
|
2939
|
-
" ",
|
|
2940
|
-
leftYear
|
|
2941
|
-
]
|
|
2942
|
-
}
|
|
2943
|
-
),
|
|
2944
|
-
/* @__PURE__ */ jsx(
|
|
2945
|
-
"button",
|
|
2946
|
-
{
|
|
2947
|
-
type: "button",
|
|
2948
|
-
onClick: goToNextMonth,
|
|
2949
|
-
className: "hover:bg-muted rounded-md p-1 transition-colors",
|
|
2950
|
-
"aria-label": "Next month",
|
|
2951
|
-
"data-slot": "date-range-nav",
|
|
2952
|
-
children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 rtl:-scale-x-100" })
|
|
2953
|
-
}
|
|
2954
|
-
)
|
|
2955
|
-
]
|
|
2956
|
-
}
|
|
2957
|
-
),
|
|
2958
|
-
/* @__PURE__ */ jsx(
|
|
2959
|
-
"div",
|
|
2960
|
-
{
|
|
2961
|
-
className: "flex justify-center",
|
|
2962
|
-
onMouseLeave: () => setHoverDate(null),
|
|
2963
|
-
children: renderMonthGrid(leftMonth, leftYear)
|
|
2964
|
-
}
|
|
2965
|
-
),
|
|
2966
|
-
/* @__PURE__ */ jsx(
|
|
2967
|
-
"button",
|
|
2968
|
-
{
|
|
2969
|
-
type: "button",
|
|
2970
|
-
"data-slot": "date-range-mobile-done",
|
|
2971
|
-
onClick: () => {
|
|
2972
|
-
setIsCalendarOpen(false);
|
|
2973
|
-
setSelectingEnd(false);
|
|
2974
|
-
if (triggerRef.current instanceof HTMLElement) {
|
|
2975
|
-
triggerRef.current.focus();
|
|
2976
|
-
}
|
|
2977
|
-
},
|
|
2978
|
-
className: "border-input hover:bg-muted mt-6 w-full rounded-lg border py-3 text-sm font-medium transition-colors",
|
|
2979
|
-
children: labels?.done ?? "Done"
|
|
2980
|
-
}
|
|
2981
|
-
)
|
|
2982
|
-
]
|
|
2983
|
-
}
|
|
2984
|
-
)
|
|
2985
|
-
}
|
|
2986
|
-
),
|
|
2987
|
-
!isMobileVariant && isCalendarOpen && createPortal(
|
|
2988
|
-
/* @__PURE__ */ jsx(
|
|
2989
|
-
"div",
|
|
2990
|
-
{
|
|
2991
|
-
ref: (node) => {
|
|
2992
|
-
calendarRef.current = node;
|
|
2993
|
-
floatingRef.current = node;
|
|
2994
|
-
},
|
|
2995
|
-
style,
|
|
2996
|
-
className: cn(
|
|
2997
|
-
"overflow-auto",
|
|
2998
|
-
"bg-background border-border rounded-lg border shadow-lg"
|
|
2999
|
-
),
|
|
3000
|
-
role: "dialog",
|
|
3001
|
-
"aria-label": "Choose date range",
|
|
3002
|
-
"data-slot": "date-range-popup",
|
|
3003
|
-
children: /* @__PURE__ */ jsxs("div", { className: "flex", children: [
|
|
3004
|
-
showPresets && /* @__PURE__ */ jsx(
|
|
3005
|
-
"div",
|
|
3006
|
-
{
|
|
3007
|
-
className: cn(
|
|
3008
|
-
"border-border flex w-[200px] shrink-0 flex-col gap-0.5 border-e p-3",
|
|
3009
|
-
isResponsive && "hidden md:flex"
|
|
3010
|
-
),
|
|
3011
|
-
"data-slot": "date-range-presets",
|
|
3012
|
-
children: finalPresets.map((preset) => /* @__PURE__ */ jsx(
|
|
3013
|
-
"button",
|
|
3014
|
-
{
|
|
3015
|
-
type: "button",
|
|
3016
|
-
onClick: () => handlePresetSelect(preset.key),
|
|
3017
|
-
"data-slot": "date-range-preset",
|
|
3018
|
-
className: cn(
|
|
3019
|
-
"rounded-md px-3 py-1.5 text-start text-sm transition-colors",
|
|
3020
|
-
"hover:bg-muted",
|
|
3021
|
-
activePreset === preset.key && "bg-primary-800 text-white"
|
|
3022
|
-
),
|
|
3023
|
-
children: preset.label
|
|
3024
|
-
},
|
|
3025
|
-
preset.key
|
|
3026
|
-
))
|
|
3027
|
-
}
|
|
3028
|
-
),
|
|
3029
|
-
/* @__PURE__ */ jsxs("div", { className: "p-4", "data-slot": "date-range-calendar", children: [
|
|
3030
|
-
/* @__PURE__ */ jsx(
|
|
3031
|
-
"p",
|
|
3032
|
-
{
|
|
3033
|
-
className: "text-muted-foreground mb-4 text-sm",
|
|
3034
|
-
"data-slot": "date-range-subtitle",
|
|
3035
|
-
children: "Select a start and end date from the calendar."
|
|
3036
|
-
}
|
|
3037
|
-
),
|
|
3038
|
-
/* @__PURE__ */ jsxs(
|
|
3039
|
-
"div",
|
|
3040
|
-
{
|
|
3041
|
-
className: "flex gap-8",
|
|
3042
|
-
onMouseLeave: () => setHoverDate(null),
|
|
3043
|
-
"data-slot": "date-range-calendars",
|
|
3044
|
-
children: [
|
|
3045
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
3046
|
-
/* @__PURE__ */ jsxs(
|
|
3047
|
-
"div",
|
|
3048
|
-
{
|
|
3049
|
-
className: "mb-3 flex items-center",
|
|
3050
|
-
"data-slot": "date-range-month-header",
|
|
3051
|
-
children: [
|
|
3052
|
-
/* @__PURE__ */ jsx(
|
|
3053
|
-
"button",
|
|
3054
|
-
{
|
|
3055
|
-
type: "button",
|
|
3056
|
-
onClick: goToPrevMonth,
|
|
3057
|
-
className: "hover:bg-muted rounded-md p-1 transition-colors",
|
|
3058
|
-
"aria-label": "Previous month",
|
|
3059
|
-
"data-slot": "date-range-nav",
|
|
3060
|
-
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4 rtl:-scale-x-100" })
|
|
3061
|
-
}
|
|
3062
|
-
),
|
|
3063
|
-
/* @__PURE__ */ jsxs(
|
|
3064
|
-
"div",
|
|
3065
|
-
{
|
|
3066
|
-
className: "flex-1 text-center text-sm font-medium",
|
|
3067
|
-
"data-slot": "date-range-month-label",
|
|
3068
|
-
children: [
|
|
3069
|
-
monthNames[leftMonth],
|
|
3070
|
-
" ",
|
|
3071
|
-
leftYear
|
|
3072
|
-
]
|
|
3073
|
-
}
|
|
3074
|
-
),
|
|
3075
|
-
isResponsive && /* @__PURE__ */ jsx(
|
|
3076
|
-
"button",
|
|
3077
|
-
{
|
|
3078
|
-
type: "button",
|
|
3079
|
-
onClick: goToNextMonth,
|
|
3080
|
-
className: "hover:bg-muted rounded-md p-1 transition-colors md:hidden",
|
|
3081
|
-
"aria-label": "Next month",
|
|
3082
|
-
"data-slot": "date-range-nav",
|
|
3083
|
-
children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 rtl:-scale-x-100" })
|
|
3084
|
-
}
|
|
3085
|
-
)
|
|
3086
|
-
]
|
|
3087
|
-
}
|
|
3088
|
-
),
|
|
3089
|
-
renderMonthGrid(leftMonth, leftYear)
|
|
3090
|
-
] }),
|
|
3091
|
-
/* @__PURE__ */ jsxs("div", { className: cn(isResponsive && "hidden md:block"), children: [
|
|
3092
|
-
/* @__PURE__ */ jsxs(
|
|
3093
|
-
"div",
|
|
3094
|
-
{
|
|
3095
|
-
className: "mb-3 flex items-center",
|
|
3096
|
-
"data-slot": "date-range-month-header",
|
|
3097
|
-
children: [
|
|
3098
|
-
/* @__PURE__ */ jsxs(
|
|
3099
|
-
"div",
|
|
3100
|
-
{
|
|
3101
|
-
className: "flex-1 text-center text-sm font-medium",
|
|
3102
|
-
"data-slot": "date-range-month-label",
|
|
3103
|
-
children: [
|
|
3104
|
-
monthNames[rightMonth],
|
|
3105
|
-
" ",
|
|
3106
|
-
rightYear
|
|
3107
|
-
]
|
|
3108
|
-
}
|
|
3109
|
-
),
|
|
3110
|
-
/* @__PURE__ */ jsx(
|
|
3111
|
-
"button",
|
|
3112
|
-
{
|
|
3113
|
-
type: "button",
|
|
3114
|
-
onClick: goToNextMonth,
|
|
3115
|
-
className: "hover:bg-muted rounded-md p-1 transition-colors",
|
|
3116
|
-
"aria-label": "Next month",
|
|
3117
|
-
"data-slot": "date-range-nav",
|
|
3118
|
-
children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 rtl:-scale-x-100" })
|
|
3119
|
-
}
|
|
3120
|
-
)
|
|
3121
|
-
]
|
|
3122
|
-
}
|
|
3123
|
-
),
|
|
3124
|
-
renderMonthGrid(rightMonth, rightYear)
|
|
3125
|
-
] })
|
|
3126
|
-
]
|
|
3127
|
-
}
|
|
3128
|
-
)
|
|
3129
|
-
] })
|
|
3130
|
-
] })
|
|
3131
|
-
}
|
|
3132
|
-
),
|
|
3133
|
-
document.body
|
|
3134
|
-
)
|
|
3135
|
-
]
|
|
3136
|
-
}
|
|
3137
|
-
);
|
|
3138
|
-
}
|
|
3139
|
-
function DateRangeFilter({
|
|
3140
|
-
value: _value,
|
|
3141
|
-
onChange,
|
|
3142
|
-
presets,
|
|
3143
|
-
activePreset,
|
|
3144
|
-
variant = "outline",
|
|
3145
|
-
className,
|
|
3146
|
-
labels = {}
|
|
3147
|
-
}) {
|
|
3148
|
-
const finalPresets = presets || getDefaultPresets(labels);
|
|
3149
|
-
const activeLabel = finalPresets.find((p) => p.key === activePreset)?.label;
|
|
3150
|
-
const handlePresetSelect = (presetKey) => {
|
|
3151
|
-
const range = calculateDateRange(presetKey);
|
|
3152
|
-
onChange(range, presetKey);
|
|
3153
|
-
};
|
|
3154
|
-
return /* @__PURE__ */ jsx(
|
|
3155
|
-
Dropdown,
|
|
3156
|
-
{
|
|
3157
|
-
trigger: /* @__PURE__ */ jsxs(Button, { variant, size: "md", className, children: [
|
|
3158
|
-
/* @__PURE__ */ jsx(Calendar, { className: "me-2 h-4 w-4" }),
|
|
3159
|
-
activeLabel || labels.filter || "Filter by Date",
|
|
3160
|
-
/* @__PURE__ */ jsx(ChevronDown$1, { className: "ms-2 h-3 w-3" })
|
|
3161
|
-
] }),
|
|
3162
|
-
className: "w-56",
|
|
3163
|
-
"data-slot": "date-range-filter",
|
|
3164
|
-
children: finalPresets.map((preset) => /* @__PURE__ */ jsx(
|
|
3165
|
-
DropdownItem,
|
|
3166
|
-
{
|
|
3167
|
-
onClick: () => handlePresetSelect(preset.key),
|
|
3168
|
-
className: cn(
|
|
3169
|
-
activePreset === preset.key && "bg-primary/10 text-primary"
|
|
3170
|
-
),
|
|
3171
|
-
children: preset.label
|
|
3172
|
-
},
|
|
3173
|
-
preset.key
|
|
3174
|
-
))
|
|
3175
|
-
}
|
|
3176
|
-
);
|
|
3177
|
-
}
|
|
3178
2424
|
var GROUP_ORDER = [
|
|
3179
2425
|
"unreconciled",
|
|
3180
2426
|
"taking",
|
|
@@ -3480,7 +2726,7 @@ var MedicationList = React4.forwardRef(
|
|
|
3480
2726
|
onClick: onAddOther,
|
|
3481
2727
|
leftIcon: /* @__PURE__ */ jsx(Plus, { size: 12 }),
|
|
3482
2728
|
className: "h-auto rounded-full px-2.5 py-1 text-xs",
|
|
3483
|
-
children: m("
|
|
2729
|
+
children: m("Add")
|
|
3484
2730
|
}
|
|
3485
2731
|
)
|
|
3486
2732
|
] })
|
|
@@ -3609,6 +2855,12 @@ function lookupToMedicationFields(result) {
|
|
|
3609
2855
|
function newId2() {
|
|
3610
2856
|
return `med-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
3611
2857
|
}
|
|
2858
|
+
function isoDateToDisplay(value) {
|
|
2859
|
+
return value && /^\d{4}-\d{2}-\d{2}$/.test(value) ? dateToDisplayFormat(value) : value;
|
|
2860
|
+
}
|
|
2861
|
+
function displayDateToIso(value) {
|
|
2862
|
+
return value ? displayFormatToDateString(value) : value;
|
|
2863
|
+
}
|
|
3612
2864
|
function MedicationEditor({
|
|
3613
2865
|
open,
|
|
3614
2866
|
medication,
|
|
@@ -3621,7 +2873,11 @@ function MedicationEditor({
|
|
|
3621
2873
|
const ambientCodeLookup = useCodeLookupConfig();
|
|
3622
2874
|
const effectiveCodeLookup = codeLookup === false ? void 0 : codeLookup ?? ambientCodeLookup ?? void 0;
|
|
3623
2875
|
const [draft, setDraft] = React4.useState(
|
|
3624
|
-
() => medication
|
|
2876
|
+
() => medication ? {
|
|
2877
|
+
...medication,
|
|
2878
|
+
startDate: isoDateToDisplay(medication.startDate),
|
|
2879
|
+
endDate: isoDateToDisplay(medication.endDate)
|
|
2880
|
+
} : {
|
|
3625
2881
|
id: newId2(),
|
|
3626
2882
|
name: "",
|
|
3627
2883
|
status: "unreconciled"
|
|
@@ -3862,7 +3118,12 @@ function MedicationEditor({
|
|
|
3862
3118
|
Button,
|
|
3863
3119
|
{
|
|
3864
3120
|
onClick: () => {
|
|
3865
|
-
onSave({
|
|
3121
|
+
onSave({
|
|
3122
|
+
...draft,
|
|
3123
|
+
name: draft.name.trim(),
|
|
3124
|
+
startDate: displayDateToIso(draft.startDate),
|
|
3125
|
+
endDate: displayDateToIso(draft.endDate)
|
|
3126
|
+
});
|
|
3866
3127
|
onClose();
|
|
3867
3128
|
},
|
|
3868
3129
|
disabled: !canSave,
|
|
@@ -4102,6 +3363,6 @@ function MedicationReconciliation({
|
|
|
4102
3363
|
] });
|
|
4103
3364
|
}
|
|
4104
3365
|
|
|
4105
|
-
export { ALLERGY_TYPE_LABELS, AllergyList, AllergyManager, Assessment, CodeLookupContext, CodeLookupProvider, ConditionEditor,
|
|
4106
|
-
//# sourceMappingURL=chunk-
|
|
4107
|
-
//# sourceMappingURL=chunk-
|
|
3366
|
+
export { ALLERGY_TYPE_LABELS, AllergyList, AllergyManager, Assessment, CodeLookupContext, CodeLookupProvider, ConditionEditor, MEDICATION_STATUS_LABELS, MedicationEditor, MedicationList, MedicationReconciliation, ORDER_TYPE_META, ORDER_TYPE_SEARCH_DOMAINS, doseFormToQuantityUnit, isConditionCodetype, labelToMedicationFields, lookupToMedicationFields, normalizeConditionCodingSystem, orderTypeForCodetype, parseMedicationLabel, parseSig, useCodeLookupConfig };
|
|
3367
|
+
//# sourceMappingURL=chunk-NW6D6AFL.js.map
|
|
3368
|
+
//# sourceMappingURL=chunk-NW6D6AFL.js.map
|