@mediaradar/design-components 0.32.1 → 0.34.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.
package/dist/index.cjs CHANGED
@@ -39,6 +39,7 @@ __export(index_exports, {
39
39
  DateRangeFilter: () => DateRangeFilter,
40
40
  DateRangePicker: () => DateRangePicker,
41
41
  Delta: () => Delta,
42
+ Drawer: () => Drawer,
42
43
  EmptyState: () => EmptyState,
43
44
  FilterChipBar: () => FilterChipBar,
44
45
  FilterDropdownFooter: () => FilterDropdownFooter,
@@ -726,6 +727,7 @@ var CREATIVE_INTEL_SHORTCUTS = [
726
727
  "All available history",
727
728
  "Custom"
728
729
  ];
730
+ var HIDDEN_SHORTCUTS = ["Last 30 days"];
729
731
  var WEEKDAYS = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"];
730
732
  var MONTHS = [
731
733
  "January",
@@ -756,6 +758,20 @@ var fmt = (d) => `${MONTHS[d.getMonth()].slice(0, 3)} ${d.getDate()}, ${d.getFul
756
758
  var fmtFull = (d) => `${MONTHS[d.getMonth()]} ${d.getDate()}, ${d.getFullYear()}`;
757
759
  var fullRangeLabel = (s, e) => `${fmtFull(s)} - ${fmtFull(e)}`;
758
760
  var presetLabel = (sc) => sc === "Custom" ? "Custom range" : sc;
761
+ var MON = (d) => MONTHS[d.getMonth()].slice(0, 3);
762
+ function spanLabel(s, e) {
763
+ if (s.getFullYear() !== e.getFullYear()) return `${fmt(s)} \u2013 ${fmt(e)}`;
764
+ if (s.getMonth() !== e.getMonth()) return `${MON(s)} ${s.getDate()} \u2013 ${MON(e)} ${e.getDate()}, ${e.getFullYear()}`;
765
+ return s.getDate() === e.getDate() ? fmt(s) : `${MON(s)} ${s.getDate()} \u2013 ${e.getDate()}, ${e.getFullYear()}`;
766
+ }
767
+ function compareSpan(s, e, mode) {
768
+ if (mode === "year") {
769
+ const back = (d) => new Date(d.getFullYear() - 1, d.getMonth(), d.getDate());
770
+ return [back(s), back(e)];
771
+ }
772
+ const days = Math.round((startOfDay(e).getTime() - startOfDay(s).getTime()) / 864e5) + 1;
773
+ return [addDays(s, -days), addDays(s, -1)];
774
+ }
759
775
  function presetRange(key, today) {
760
776
  const t = startOfDay(today);
761
777
  const qMonth = Math.floor(t.getMonth() / 3) * 3;
@@ -792,6 +808,8 @@ function presetRange(key, today) {
792
808
  return [addDays(t, -6), t];
793
809
  case "Last 14 days":
794
810
  return [addDays(t, -13), t];
811
+ case "Last 30 days":
812
+ return [addDays(t, -29), t];
795
813
  case "Last month": {
796
814
  const s = new Date(t.getFullYear(), t.getMonth() - 1, 1);
797
815
  const e = new Date(t.getFullYear(), t.getMonth(), 0);
@@ -813,7 +831,7 @@ function monthGrid(year, month) {
813
831
  }
814
832
  function matchShortcut(shortcuts, label) {
815
833
  if (!label) return "Rolling 12 months";
816
- const hit = shortcuts.find((s) => s.toLowerCase() === label.toLowerCase());
834
+ const hit = [...shortcuts, ...HIDDEN_SHORTCUTS].find((s) => s.toLowerCase() === label.toLowerCase());
817
835
  return hit || "Custom";
818
836
  }
819
837
  function slug2(value) {
@@ -832,23 +850,43 @@ function DateRangeFilter({
832
850
  shortDates = false,
833
851
  icon,
834
852
  presetSet = "default",
853
+ excludePresets = [],
854
+ emptyLabel,
855
+ today: todayProp,
856
+ initialRange,
857
+ compare,
858
+ onApply,
835
859
  testIdPrefix,
836
860
  granularity = "day"
837
861
  }) {
838
862
  const monthly = granularity === "month";
839
863
  const snap = (s, e) => monthly ? [firstOfMonth(s), lastOfMonth(e)] : [s, e];
840
864
  const controlled = controlledValue !== void 0 && controlledRange !== void 0;
841
- const SHORTCUTS = presetSet === "creativeIntel" ? CREATIVE_INTEL_SHORTCUTS : DEFAULT_SHORTCUTS;
842
- const today = (0, import_react3.useMemo)(() => /* @__PURE__ */ new Date(), []);
865
+ const startsEmpty = !controlled && !!emptyLabel;
866
+ const SHORTCUTS = (presetSet === "creativeIntel" ? CREATIVE_INTEL_SHORTCUTS : DEFAULT_SHORTCUTS).filter(
867
+ (s) => !excludePresets.includes(s)
868
+ );
869
+ const today = (0, import_react3.useMemo)(() => todayProp ?? /* @__PURE__ */ new Date(), []);
843
870
  const initShortcut = matchShortcut(SHORTCUTS, controlled ? controlledValue : defaultValue);
844
- const initRange = controlled ? controlledRange : snap(...presetRange(initShortcut === "Custom" ? "Rolling 12 months" : initShortcut, today));
871
+ const initRange = controlled ? controlledRange : initShortcut === "Custom" && initialRange ? snap(...initialRange) : snap(...presetRange(initShortcut === "Custom" ? "Rolling 12 months" : initShortcut, today));
872
+ const compareLabel = (id) => compare?.options.find((o) => o.id === id)?.label;
845
873
  const dateLine = (s, e) => monthly ? `${fmtMonth(s)} \u2013 ${fmtMonth(e)}` : shortDates ? `${fmt(s)} \u2013 ${fmt(e)}` : fullRangeLabel(s, e);
846
874
  const [open, setOpen] = (0, import_react3.useState)(false);
847
875
  const [uncontrolledValue, setUncontrolledValue] = (0, import_react3.useState)(
848
- showDates ? presetLabel(initShortcut) : defaultValue || "Last 7 days"
876
+ startsEmpty ? emptyLabel : showDates ? presetLabel(initShortcut) : defaultValue || "Last 7 days"
877
+ );
878
+ const [uncontrolledDatesLine, setUncontrolledDatesLine] = (0, import_react3.useState)(
879
+ startsEmpty ? null : dateLine(initRange[0], initRange[1])
849
880
  );
850
- const [uncontrolledDatesLine, setUncontrolledDatesLine] = (0, import_react3.useState)(dateLine(initRange[0], initRange[1]));
851
- const committed = (0, import_react3.useRef)({ shortcut: initShortcut, start: initRange[0], end: initRange[1] });
881
+ const committed = (0, import_react3.useRef)({ shortcut: initShortcut, start: initRange[0], end: initRange[1], set: !startsEmpty });
882
+ const [cmp, setCmp] = (0, import_react3.useState)(compare?.value);
883
+ const committedCmp = (0, import_react3.useRef)(compare?.value);
884
+ const [appliedCmp, setAppliedCmp] = (0, import_react3.useState)(compare?.value);
885
+ (0, import_react3.useEffect)(() => {
886
+ committedCmp.current = compare?.value;
887
+ setAppliedCmp(compare?.value);
888
+ }, [compare?.value]);
889
+ const compareName = `${(0, import_react3.useId)()}-compare`;
852
890
  const displayValue = controlled ? showDates ? presetLabel(initShortcut) : controlledValue : uncontrolledValue;
853
891
  const displayDatesLine = controlled ? dateLine(initRange[0], initRange[1]) : uncontrolledDatesLine;
854
892
  const [shortcut, setShortcut] = (0, import_react3.useState)(initShortcut);
@@ -857,7 +895,7 @@ function DateRangeFilter({
857
895
  const [leftMonth, setLeftMonth] = (0, import_react3.useState)(new Date(initRange[0].getFullYear(), initRange[0].getMonth(), 1));
858
896
  const ref = (0, import_react3.useRef)(null);
859
897
  (0, import_react3.useEffect)(() => {
860
- if (controlled) return;
898
+ if (controlled || startsEmpty) return;
861
899
  onRangeChange?.(committed.current.start, committed.current.end);
862
900
  }, []);
863
901
  (0, import_react3.useEffect)(() => {
@@ -865,10 +903,12 @@ function DateRangeFilter({
865
903
  const committedShortcut = controlled ? initShortcut : committed.current.shortcut;
866
904
  const committedStart = controlled ? initRange[0] : committed.current.start;
867
905
  const committedEnd = controlled ? initRange[1] : committed.current.end;
906
+ const hasRange = controlled || committed.current.set;
868
907
  setShortcut(committedShortcut);
869
- setStart(committedStart);
870
- setEnd(committedEnd);
871
- setLeftMonth(new Date(committedStart.getFullYear(), committedStart.getMonth(), 1));
908
+ setStart(hasRange ? committedStart : null);
909
+ setEnd(hasRange ? committedEnd : null);
910
+ setLeftMonth(hasRange ? new Date(committedStart.getFullYear(), committedStart.getMonth(), 1) : addMonths(today, -1));
911
+ setCmp(committedCmp.current);
872
912
  const onKey = (e) => e.key === "Escape" && setOpen(false);
873
913
  const onClick = (e) => {
874
914
  if (ref.current && !ref.current.contains(e.target)) setOpen(false);
@@ -902,17 +942,22 @@ function DateRangeFilter({
902
942
  setEnd(e);
903
943
  } else setEnd(monthly ? lastOfMonth(d) : d);
904
944
  };
945
+ const canApply = !!start || controlled || committed.current.set;
905
946
  const apply = () => {
947
+ if (!canApply) return;
906
948
  const [s, e] = snap(start || initRange[0], end || start || initRange[0]);
907
949
  const custom = monthly ? `${fmtMonth(s)} \u2014 ${fmtMonth(e)}` : `${fmt(s)} \u2014 ${fmt(e)}`;
908
950
  const v = showDates ? presetLabel(shortcut) : shortcut === "Custom" ? custom : shortcut;
909
951
  if (!controlled) {
910
- committed.current = { shortcut, start: s, end: e };
952
+ committed.current = { shortcut, start: s, end: e, set: true };
911
953
  setUncontrolledValue(v);
912
954
  setUncontrolledDatesLine(dateLine(s, e));
913
955
  }
956
+ committedCmp.current = cmp;
957
+ setAppliedCmp(cmp);
914
958
  onChange?.(v);
915
959
  onRangeChange?.(s, e);
960
+ onApply?.(shortcut === "Custom" ? `${fmt(s)} \u2013 ${fmt(e)}` : shortcut, s, e, cmp);
916
961
  setOpen(false);
917
962
  };
918
963
  const popRef = (0, import_react3.useRef)(null);
@@ -934,8 +979,14 @@ function DateRangeFilter({
934
979
  children: [
935
980
  icon && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "shrink-0 text-text-tertiary", children: icon }),
936
981
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "flex flex-col gap-1 text-left leading-none", children: [
937
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: showDates ? "text-[11px] text-text-tertiary" : "text-control-caption uppercase tracking-wide text-text-tertiary", children: showDates ? displayDatesLine : caption }),
938
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-[12px] font-medium text-text-primary", children: displayValue })
982
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: showDates && displayDatesLine ? "text-[11px] text-text-tertiary" : "text-control-caption uppercase tracking-wide text-text-tertiary", children: showDates && displayDatesLine ? displayDatesLine : caption }),
983
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "text-[12px] font-medium text-text-primary", children: [
984
+ displayValue,
985
+ compareLabel(appliedCmp) && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "font-normal text-text-secondary", children: [
986
+ " \xB7 vs ",
987
+ compareLabel(appliedCmp).toLowerCase()
988
+ ] })
989
+ ] })
939
990
  ] }),
940
991
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react6.ChevronDown, { size: 14, "aria-hidden": "true", className: `shrink-0 text-text-secondary transition-transform ${open ? "rotate-180" : ""}` })
941
992
  ]
@@ -1011,10 +1062,39 @@ function DateRangeFilter({
1011
1062
  ] })
1012
1063
  ] }, offset);
1013
1064
  }) }),
1065
+ compare && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("fieldset", { className: "mt-4 border-t border-border-default pt-4", children: [
1066
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("legend", { className: "float-left mb-2 w-full text-xs font-medium text-text-secondary", children: "Compare to" }),
1067
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "clear-left flex flex-col gap-1", children: compare.options.map((o) => {
1068
+ const on = (cmp ?? compare.value) === o.id;
1069
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1070
+ "label",
1071
+ {
1072
+ className: `flex cursor-pointer items-center gap-2.5 rounded-control px-2 py-1.5 text-dense transition-colors ${on ? "bg-subtle" : "hover:bg-subtle"}`,
1073
+ children: [
1074
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1075
+ "input",
1076
+ {
1077
+ type: "radio",
1078
+ name: compareName,
1079
+ value: o.id,
1080
+ checked: on,
1081
+ onChange: () => setCmp(o.id),
1082
+ "data-testid": testIdPrefix && `${testIdPrefix}-compare-${slug2(o.id)}`,
1083
+ className: "h-4 w-4 accent-brand-primaryAction"
1084
+ }
1085
+ ),
1086
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: `w-44 shrink-0 ${on ? "font-semibold text-text-primary" : "text-text-secondary"}`, children: o.label }),
1087
+ start && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "tabular-nums text-text-tertiary", children: spanLabel(...compareSpan(start, end ?? start, o.id)) })
1088
+ ]
1089
+ },
1090
+ o.id
1091
+ );
1092
+ }) })
1093
+ ] }),
1014
1094
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "mt-4 flex items-center justify-end gap-2", children: [
1015
1095
  monthly && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "mr-auto text-xs text-text-tertiary", children: "Data is monthly, so ranges cover whole months." }),
1016
1096
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "data-testid": testIdPrefix && `${testIdPrefix}-cancel`, onClick: () => setOpen(false), className: "rounded-control border border-border-default bg-surface px-5 py-2 text-[13px] font-semibold text-text-primary transition-colors hover:bg-subtle", children: "Cancel" }),
1017
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "data-testid": testIdPrefix && `${testIdPrefix}-apply`, onClick: apply, className: "rounded-control bg-brand-primaryAction px-5 py-2 text-[13px] font-semibold text-brand-onprimary transition-[filter] hover:brightness-110", children: "Apply" })
1097
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "data-testid": testIdPrefix && `${testIdPrefix}-apply`, onClick: apply, disabled: !canApply, className: "rounded-control bg-brand-primaryAction px-5 py-2 text-[13px] font-semibold text-brand-onprimary transition-[filter] hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-50", children: "Apply" })
1018
1098
  ] })
1019
1099
  ] })
1020
1100
  ]
@@ -3675,7 +3755,7 @@ function resolveRange(label, today = startOfToday()) {
3675
3755
  }
3676
3756
  return [new Date(end.getFullYear(), end.getMonth() - 6, 1), end];
3677
3757
  }
3678
- function spanLabel(label, today) {
3758
+ function spanLabel2(label, today) {
3679
3759
  const [s, e] = resolveRange(label, today);
3680
3760
  return `${fmtDate(s)} \u2013 ${fmtDate(e)}`;
3681
3761
  }
@@ -3761,7 +3841,7 @@ function DateRangePicker({
3761
3841
  className: chipTriggerClass(),
3762
3842
  children: [
3763
3843
  /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("span", { className: "flex flex-col gap-1 text-left leading-none", children: [
3764
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "text-control-caption text-text-tertiary", children: spanLabel(value, end) }),
3844
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "text-control-caption text-text-tertiary", children: spanLabel2(value, end) }),
3765
3845
  /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "text-[12px] font-medium text-text-primary", children: value })
3766
3846
  ] }),
3767
3847
  /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_lucide_react22.ChevronDown, { size: 14, "aria-hidden": "true", className: cn("shrink-0 text-text-secondary transition-transform", open && "rotate-180") })
@@ -4447,10 +4527,132 @@ var TextField = (0, import_react21.forwardRef)(
4447
4527
  );
4448
4528
  TextField.displayName = "TextField";
4449
4529
 
4450
- // src/DataTable.tsx
4530
+ // src/Drawer.tsx
4451
4531
  var import_react22 = require("react");
4532
+ var import_react_dom8 = require("react-dom");
4533
+ var import_lucide_react27 = require("lucide-react");
4452
4534
  var import_jsx_runtime49 = require("react/jsx-runtime");
4453
- var WIDTH2 = { fill: "", sm: "w-24", md: "w-36", lg: "w-48" };
4535
+ var WIDTH2 = {
4536
+ sm: "max-w-110",
4537
+ md: "max-w-160",
4538
+ lg: "max-w-230"
4539
+ };
4540
+ var EXIT_MS = 200;
4541
+ var FOCUSABLE2 = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
4542
+ function Drawer({ open, onClose, title, description, size = "sm", footer, children, className }) {
4543
+ const titleId = (0, import_react22.useId)();
4544
+ const descId = (0, import_react22.useId)();
4545
+ const panel = (0, import_react22.useRef)(null);
4546
+ const close = (0, import_react22.useRef)(onClose);
4547
+ close.current = onClose;
4548
+ const [mounted, setMounted] = (0, import_react22.useState)(open);
4549
+ const [shown, setShown] = (0, import_react22.useState)(false);
4550
+ (0, import_react22.useEffect)(() => {
4551
+ if (open) {
4552
+ setMounted(true);
4553
+ const raf = requestAnimationFrame(() => requestAnimationFrame(() => setShown(true)));
4554
+ return () => cancelAnimationFrame(raf);
4555
+ }
4556
+ setShown(false);
4557
+ const t = setTimeout(() => setMounted(false), EXIT_MS);
4558
+ return () => clearTimeout(t);
4559
+ }, [open]);
4560
+ (0, import_react22.useEffect)(() => {
4561
+ if (!open || !mounted) return;
4562
+ const opener = document.activeElement;
4563
+ const firstIn = (region) => panel.current?.querySelector(region)?.querySelector(FOCUSABLE2) ?? null;
4564
+ const first = firstIn("[data-drawer-body]") ?? firstIn("[data-drawer-footer]");
4565
+ (first ?? panel.current)?.focus({ preventScroll: true });
4566
+ const overflow = document.body.style.overflow;
4567
+ document.body.style.overflow = "hidden";
4568
+ const onKey = (e) => {
4569
+ if (e.key === "Escape") {
4570
+ e.stopPropagation();
4571
+ close.current();
4572
+ return;
4573
+ }
4574
+ if (e.key !== "Tab" || !panel.current) return;
4575
+ const items = Array.from(panel.current.querySelectorAll(FOCUSABLE2));
4576
+ if (items.length === 0) return;
4577
+ const [head, tail] = [items[0], items[items.length - 1]];
4578
+ if (e.shiftKey && document.activeElement === head) {
4579
+ e.preventDefault();
4580
+ tail.focus();
4581
+ } else if (!e.shiftKey && document.activeElement === tail) {
4582
+ e.preventDefault();
4583
+ head.focus();
4584
+ }
4585
+ };
4586
+ document.addEventListener("keydown", onKey);
4587
+ return () => {
4588
+ document.removeEventListener("keydown", onKey);
4589
+ document.body.style.overflow = overflow;
4590
+ opener?.focus?.();
4591
+ };
4592
+ }, [open, mounted]);
4593
+ if (!mounted || typeof document === "undefined") return null;
4594
+ return (0, import_react_dom8.createPortal)(
4595
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "fixed inset-0 z-modal", children: [
4596
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4597
+ "div",
4598
+ {
4599
+ "aria-hidden": "true",
4600
+ onMouseDown: (e) => {
4601
+ e.preventDefault();
4602
+ onClose();
4603
+ },
4604
+ className: cn(
4605
+ "absolute inset-0 bg-scrim transition-opacity duration-(--mr-motion-duration-interactive) ease-interactive motion-reduce:transition-none",
4606
+ shown ? "opacity-100" : "opacity-0"
4607
+ )
4608
+ }
4609
+ ),
4610
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
4611
+ "div",
4612
+ {
4613
+ ref: panel,
4614
+ role: "dialog",
4615
+ "aria-modal": "true",
4616
+ "aria-labelledby": titleId,
4617
+ "aria-describedby": description ? descId : void 0,
4618
+ tabIndex: -1,
4619
+ className: cn(
4620
+ "absolute inset-y-0 right-0 flex w-full flex-col border-l border-border-default bg-surface shadow-overlay outline-hidden transition-transform duration-(--mr-motion-duration-interactive) ease-interactive motion-reduce:transition-none",
4621
+ shown ? "translate-x-0" : "translate-x-full",
4622
+ WIDTH2[size],
4623
+ className
4624
+ ),
4625
+ children: [
4626
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "flex items-start gap-3 px-5 pt-5 pb-3", children: [
4627
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "min-w-0 flex-1", children: [
4628
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("h2", { id: titleId, className: "text-base font-semibold text-text-primary", children: title }),
4629
+ description && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { id: descId, className: "mt-0.5 text-sm text-text-secondary", children: description })
4630
+ ] }),
4631
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4632
+ "button",
4633
+ {
4634
+ type: "button",
4635
+ onClick: onClose,
4636
+ "aria-label": "Close",
4637
+ className: "-mr-1.5 -mt-1 flex size-8 shrink-0 items-center justify-center rounded-control text-text-tertiary hover:bg-subtle hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
4638
+ children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_lucide_react27.X, { size: 16, "aria-hidden": "true" })
4639
+ }
4640
+ )
4641
+ ] }),
4642
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { "data-drawer-body": true, className: "min-h-0 flex-1 overflow-y-auto px-5 pb-5 text-sm text-text-primary", children }),
4643
+ footer && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { "data-drawer-footer": true, className: "flex items-center justify-end gap-2 border-t border-border-default px-5 py-3", children: footer })
4644
+ ]
4645
+ }
4646
+ )
4647
+ ] }),
4648
+ document.body
4649
+ );
4650
+ }
4651
+
4652
+ // src/DataTable.tsx
4653
+ var import_react23 = require("react");
4654
+ var import_jsx_runtime50 = require("react/jsx-runtime");
4655
+ var WIDTH3 = { fill: "", sm: "w-24", md: "w-36", lg: "w-48" };
4454
4656
  var MAX_H = { sm: "max-h-80", md: "max-h-120", lg: "max-h-160" };
4455
4657
  var HEAD_PAD = { default: "px-4 py-3", compact: "px-3 py-2" };
4456
4658
  var CELL_PAD = { default: "px-4 py-3.5", compact: "px-3 py-2" };
@@ -4472,24 +4674,24 @@ function DataTable({
4472
4674
  className,
4473
4675
  ...rest
4474
4676
  }) {
4475
- const titleId = (0, import_react22.useId)();
4677
+ const titleId = (0, import_react23.useId)();
4476
4678
  const head = HEAD_PAD[density];
4477
4679
  const pad = CELL_PAD[density];
4478
4680
  const align = (c) => c.numeric ? "text-right" : "text-left";
4479
- const width = (c) => WIDTH2[c.width ?? (c.numeric ? "md" : "fill")];
4681
+ const width = (c) => WIDTH3[c.width ?? (c.numeric ? "md" : "fill")];
4480
4682
  const onSort = (key) => {
4481
4683
  const col = columns.find((c) => c.key === key);
4482
4684
  onSortChange?.(cycleSort(sort, key, col?.firstDir ?? (col?.numeric ? "desc" : "asc")));
4483
4685
  };
4484
- return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: cn("flex w-full flex-col overflow-hidden rounded-card border border-border-default bg-surface", className), children: [
4485
- title && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
4486
- /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "min-w-0", children: [
4487
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("h3", { id: titleId, className: "text-style-card-title", children: title }),
4488
- subtitle && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { className: "mt-0.5 text-xs text-text-tertiary", children: subtitle })
4686
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: cn("flex w-full flex-col overflow-hidden rounded-card border border-border-default bg-surface", className), children: [
4687
+ title && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
4688
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "min-w-0", children: [
4689
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("h3", { id: titleId, className: "text-style-card-title", children: title }),
4690
+ subtitle && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("p", { className: "mt-0.5 text-xs text-text-tertiary", children: subtitle })
4489
4691
  ] }),
4490
- action && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "shrink-0", children: action })
4692
+ action && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "shrink-0", children: action })
4491
4693
  ] }),
4492
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: cn("overflow-x-auto", maxHeight && cn("overflow-y-auto", MAX_H[maxHeight])), children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
4694
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: cn("overflow-x-auto", maxHeight && cn("overflow-y-auto", MAX_H[maxHeight])), children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
4493
4695
  "table",
4494
4696
  {
4495
4697
  "aria-labelledby": title ? titleId : void 0,
@@ -4497,13 +4699,13 @@ function DataTable({
4497
4699
  "aria-busy": loading || void 0,
4498
4700
  className: "w-full border-collapse text-left",
4499
4701
  children: [
4500
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("thead", { className: cn(maxHeight && "sticky top-0 z-10"), children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("tr", { className: "bg-subtle text-micro font-semibold uppercase tracking-wider text-text-secondary", children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4702
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("thead", { className: cn(maxHeight && "sticky top-0 z-10"), children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tr", { className: "bg-subtle text-micro font-semibold uppercase tracking-wider text-text-secondary", children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
4501
4703
  "th",
4502
4704
  {
4503
4705
  scope: "col",
4504
4706
  "aria-sort": c.sortable ? ariaSortFor(sort, c.key) : void 0,
4505
4707
  className: cn("border-b border-border-default font-semibold", head, align(c), width(c)),
4506
- children: c.sortable && onSortChange ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4708
+ children: c.sortable && onSortChange ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
4507
4709
  SortButton,
4508
4710
  {
4509
4711
  label: c.label,
@@ -4516,7 +4718,7 @@ function DataTable({
4516
4718
  },
4517
4719
  c.key
4518
4720
  )) }) }),
4519
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("tbody", { className: "text-dense text-text-primary", children: loading ? Array.from({ length: loadingRows }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("tr", { "aria-hidden": "true", className: "[&:last-child>td]:border-b-0", children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("td", { className: cn("border-b border-border-default", pad, align(c)), children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4721
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tbody", { className: "text-dense text-text-primary", children: loading ? Array.from({ length: loadingRows }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tr", { "aria-hidden": "true", className: "[&:last-child>td]:border-b-0", children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("td", { className: cn("border-b border-border-default", pad, align(c)), children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
4520
4722
  "span",
4521
4723
  {
4522
4724
  className: cn(
@@ -4524,7 +4726,7 @@ function DataTable({
4524
4726
  c.numeric ? "w-12" : "w-2/3"
4525
4727
  )
4526
4728
  }
4527
- ) }, c.key)) }, i)) : rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("td", { colSpan: columns.length, className: "px-6 py-12", children: empty ?? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(NoResultsEmptyState, {}) }) }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("tr", { className: "hover:bg-subtle [&:last-child>td]:border-b-0", children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4729
+ ) }, c.key)) }, i)) : rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("td", { colSpan: columns.length, className: "px-6 py-12", children: empty ?? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(NoResultsEmptyState, {}) }) }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tr", { className: "hover:bg-subtle [&:last-child>td]:border-b-0", children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
4528
4730
  "td",
4529
4731
  {
4530
4732
  className: cn("border-b border-border-default", pad, align(c), c.numeric && "tabular-nums"),
@@ -4535,12 +4737,12 @@ function DataTable({
4535
4737
  ]
4536
4738
  }
4537
4739
  ) }),
4538
- footer && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "border-t border-border-default px-4 py-3", children: footer })
4740
+ footer && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "border-t border-border-default px-4 py-3", children: footer })
4539
4741
  ] });
4540
4742
  }
4541
4743
 
4542
4744
  // src/MediaLabel.tsx
4543
- var import_jsx_runtime50 = require("react/jsx-runtime");
4745
+ var import_jsx_runtime51 = require("react/jsx-runtime");
4544
4746
  var FILL = {
4545
4747
  TV: "bg-media-tv",
4546
4748
  CTV: "bg-media-ctv",
@@ -4551,7 +4753,7 @@ var FILL = {
4551
4753
  Magazine: "bg-media-magazine"
4552
4754
  };
4553
4755
  function MediaLabel({ type, className }) {
4554
- return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
4756
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
4555
4757
  "span",
4556
4758
  {
4557
4759
  className: cn(
@@ -4565,9 +4767,9 @@ function MediaLabel({ type, className }) {
4565
4767
  }
4566
4768
 
4567
4769
  // src/SuggestionChip.tsx
4568
- var import_jsx_runtime51 = require("react/jsx-runtime");
4770
+ var import_jsx_runtime52 = require("react/jsx-runtime");
4569
4771
  function SuggestionChip({ children, className, type = "button", ...props }) {
4570
- return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
4772
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
4571
4773
  "button",
4572
4774
  {
4573
4775
  type,
@@ -4576,16 +4778,16 @@ function SuggestionChip({ children, className, type = "button", ...props }) {
4576
4778
  "inline-flex h-8 max-w-full items-center rounded-full border border-border-default bg-surface px-3 text-sm text-text-primary transition-colors duration-(--mr-motion-duration-interactive) ease-interactive hover:border-border-strong hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
4577
4779
  className
4578
4780
  ),
4579
- children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "truncate", children })
4781
+ children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "truncate", children })
4580
4782
  }
4581
4783
  );
4582
4784
  }
4583
4785
 
4584
4786
  // src/ToggleChip.tsx
4585
- var import_lucide_react27 = require("lucide-react");
4586
- var import_jsx_runtime52 = require("react/jsx-runtime");
4787
+ var import_lucide_react28 = require("lucide-react");
4788
+ var import_jsx_runtime53 = require("react/jsx-runtime");
4587
4789
  function ToggleChip({ selected, onChange, children, className, type = "button", onClick, ...props }) {
4588
- return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
4790
+ return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
4589
4791
  "button",
4590
4792
  {
4591
4793
  type,
@@ -4601,7 +4803,7 @@ function ToggleChip({ selected, onChange, children, className, type = "button",
4601
4803
  className
4602
4804
  ),
4603
4805
  children: [
4604
- selected && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_lucide_react27.Check, { size: 14, "aria-hidden": "true", className: "-ml-0.5 shrink-0" }),
4806
+ selected && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_lucide_react28.Check, { size: 14, "aria-hidden": "true", className: "-ml-0.5 shrink-0" }),
4605
4807
  children
4606
4808
  ]
4607
4809
  }
@@ -4609,14 +4811,14 @@ function ToggleChip({ selected, onChange, children, className, type = "button",
4609
4811
  }
4610
4812
 
4611
4813
  // src/CopyButton.tsx
4612
- var import_react23 = require("react");
4613
- var import_lucide_react28 = require("lucide-react");
4614
- var import_jsx_runtime53 = require("react/jsx-runtime");
4814
+ var import_react24 = require("react");
4815
+ var import_lucide_react29 = require("lucide-react");
4816
+ var import_jsx_runtime54 = require("react/jsx-runtime");
4615
4817
  var CONFIRM_MS = 2e3;
4616
4818
  function CopyButton({ value, label, "aria-label": ariaLabel, size = "xs", className }) {
4617
- const [copied, setCopied] = (0, import_react23.useState)(false);
4618
- const timer = (0, import_react23.useRef)(void 0);
4619
- (0, import_react23.useEffect)(() => () => clearTimeout(timer.current), []);
4819
+ const [copied, setCopied] = (0, import_react24.useState)(false);
4820
+ const timer = (0, import_react24.useRef)(void 0);
4821
+ (0, import_react24.useEffect)(() => () => clearTimeout(timer.current), []);
4620
4822
  const copy = async () => {
4621
4823
  try {
4622
4824
  await navigator.clipboard.writeText(typeof value === "function" ? value() : value);
@@ -4628,8 +4830,8 @@ function CopyButton({ value, label, "aria-label": ariaLabel, size = "xs", classN
4628
4830
  timer.current = setTimeout(() => setCopied(false), CONFIRM_MS);
4629
4831
  };
4630
4832
  const iconSize = size === "xs" ? 13 : 15;
4631
- const icon = copied ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_lucide_react28.Check, { size: iconSize, "aria-hidden": "true", className: "shrink-0 text-text-success" }) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_lucide_react28.Copy, { size: iconSize, "aria-hidden": "true", className: "shrink-0" });
4632
- return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
4833
+ const icon = copied ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_lucide_react29.Check, { size: iconSize, "aria-hidden": "true", className: "shrink-0 text-text-success" }) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_lucide_react29.Copy, { size: iconSize, "aria-hidden": "true", className: "shrink-0" });
4834
+ return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
4633
4835
  Button,
4634
4836
  {
4635
4837
  type: "button",
@@ -4641,16 +4843,16 @@ function CopyButton({ value, label, "aria-label": ariaLabel, size = "xs", classN
4641
4843
  className: cn(!copied && "text-text-secondary", className),
4642
4844
  children: [
4643
4845
  icon,
4644
- label && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { children: copied ? "Copied" : label }),
4645
- /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { role: "status", className: "sr-only", children: copied ? "Copied" : "" })
4846
+ label && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { children: copied ? "Copied" : label }),
4847
+ /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { role: "status", className: "sr-only", children: copied ? "Copied" : "" })
4646
4848
  ]
4647
4849
  }
4648
4850
  );
4649
4851
  }
4650
4852
 
4651
4853
  // src/InlineMessage.tsx
4652
- var import_lucide_react29 = require("lucide-react");
4653
- var import_jsx_runtime54 = require("react/jsx-runtime");
4854
+ var import_lucide_react30 = require("lucide-react");
4855
+ var import_jsx_runtime55 = require("react/jsx-runtime");
4654
4856
  var BOX = {
4655
4857
  info: "border-brand-primaryAction/30 bg-brand-primaryAction/10",
4656
4858
  success: "border-status-success/40 bg-status-success/10",
@@ -4664,29 +4866,29 @@ var ICON_INK = {
4664
4866
  warning: "text-text-warning",
4665
4867
  danger: "text-text-danger"
4666
4868
  };
4667
- var ICON2 = { info: import_lucide_react29.Info, success: import_lucide_react29.CheckCircle2, warning: import_lucide_react29.AlertTriangle, danger: import_lucide_react29.XCircle };
4869
+ var ICON2 = { info: import_lucide_react30.Info, success: import_lucide_react30.CheckCircle2, warning: import_lucide_react30.AlertTriangle, danger: import_lucide_react30.XCircle };
4668
4870
  function InlineMessage({ tone = "info", title, children, actions, onDismiss, className }) {
4669
4871
  const Icon = ICON2[tone];
4670
- return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
4872
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
4671
4873
  "div",
4672
4874
  {
4673
4875
  role: tone === "warning" || tone === "danger" ? "alert" : "status",
4674
4876
  className: cn("flex items-start gap-2.5 rounded-control border px-3 py-2.5 text-sm", BOX[tone], className),
4675
4877
  children: [
4676
- /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Icon, { size: 16, "aria-hidden": "true", className: cn("mt-0.5 shrink-0", ICON_INK[tone]) }),
4677
- /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "min-w-0 flex-1", children: [
4678
- /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "font-semibold text-text-primary", children: title }),
4679
- children && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "mt-0.5 text-text-secondary", children }),
4680
- actions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "mt-2 flex flex-wrap items-center gap-2", children: actions })
4878
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Icon, { size: 16, "aria-hidden": "true", className: cn("mt-0.5 shrink-0", ICON_INK[tone]) }),
4879
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "min-w-0 flex-1", children: [
4880
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "font-semibold text-text-primary", children: title }),
4881
+ children && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "mt-0.5 text-text-secondary", children }),
4882
+ actions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "mt-2 flex flex-wrap items-center gap-2", children: actions })
4681
4883
  ] }),
4682
- onDismiss && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
4884
+ onDismiss && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
4683
4885
  "button",
4684
4886
  {
4685
4887
  type: "button",
4686
4888
  onClick: onDismiss,
4687
4889
  "aria-label": "Dismiss",
4688
4890
  className: "-mr-1 -mt-0.5 flex size-6 shrink-0 items-center justify-center rounded-control text-text-tertiary hover:bg-subtle hover:text-text-primary focus-visible:outline-2 focus-visible:outline-border-focus",
4689
- children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_lucide_react29.X, { size: 14, "aria-hidden": "true" })
4891
+ children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_lucide_react30.X, { size: 14, "aria-hidden": "true" })
4690
4892
  }
4691
4893
  )
4692
4894
  ]
@@ -4713,6 +4915,7 @@ function InlineMessage({ tone = "info", title, children, actions, onDismiss, cla
4713
4915
  DateRangeFilter,
4714
4916
  DateRangePicker,
4715
4917
  Delta,
4918
+ Drawer,
4716
4919
  EmptyState,
4717
4920
  FilterChipBar,
4718
4921
  FilterDropdownFooter,