@mediaradar/design-components 0.45.2 → 0.46.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
@@ -98,8 +98,24 @@ var define_FONT_SIZE_KEYS_default = ["control-caption", "badge", "micro", "xs",
98
98
  var import_react = require("react");
99
99
  var import_react_dom = require("react-dom");
100
100
  var import_lucide_react = require("lucide-react");
101
+
102
+ // src/cn.ts
103
+ var import_clsx = require("clsx");
104
+ var import_tailwind_merge = require("tailwind-merge");
105
+ var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({
106
+ extend: {
107
+ classGroups: {
108
+ "font-size": [{ text: define_FONT_SIZE_KEYS_default }]
109
+ }
110
+ }
111
+ });
112
+ function cn(...inputs) {
113
+ return twMerge((0, import_clsx.clsx)(inputs));
114
+ }
115
+
116
+ // src/InfoTip.tsx
101
117
  var import_jsx_runtime = require("react/jsx-runtime");
102
- function InfoTip({ text, size = 11, label = "More information", trigger = "click" }) {
118
+ function InfoTip({ text, size = 11, label = "More information", trigger = "click", className, testIdPrefix }) {
103
119
  const [open, setOpen] = (0, import_react.useState)(false);
104
120
  const [pos, setPos] = (0, import_react.useState)(null);
105
121
  const btnRef = (0, import_react.useRef)(null);
@@ -160,8 +176,12 @@ function InfoTip({ text, size = 11, label = "More information", trigger = "click
160
176
  "aria-label": label,
161
177
  "aria-expanded": open,
162
178
  "aria-describedby": textId,
179
+ "data-testid": testIdPrefix,
163
180
  ...hoverProps,
164
- className: "inline-flex cursor-pointer items-center text-text-tertiary transition-colors hover:text-text-primary focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
181
+ className: cn(
182
+ "inline-flex cursor-pointer items-center text-text-tertiary transition-colors hover:text-text-primary focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
183
+ className
184
+ ),
165
185
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Info, { size, "aria-hidden": "true" })
166
186
  }
167
187
  ),
@@ -190,8 +210,8 @@ var import_lucide_react3 = require("lucide-react");
190
210
  // src/AdvertiserSearchPrompt.tsx
191
211
  var import_lucide_react2 = require("lucide-react");
192
212
  var import_jsx_runtime2 = require("react/jsx-runtime");
193
- function AdvertiserSearchPrompt({ label = "an advertiser name" }) {
194
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex flex-col items-center gap-2 px-4 py-8 text-center", children: [
213
+ function AdvertiserSearchPrompt({ label = "an advertiser name", className, testIdPrefix }) {
214
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: cn("flex flex-col items-center gap-2 px-4 py-8 text-center", className), "data-testid": testIdPrefix, children: [
195
215
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "flex h-9 w-9 items-center justify-center rounded-full bg-subtle text-text-tertiary", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react2.Search, { size: 16, "aria-hidden": "true" }) }),
196
216
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "text-xs leading-snug text-text-tertiary", children: [
197
217
  "Start typing ",
@@ -201,20 +221,6 @@ function AdvertiserSearchPrompt({ label = "an advertiser name" }) {
201
221
  ] });
202
222
  }
203
223
 
204
- // src/cn.ts
205
- var import_clsx = require("clsx");
206
- var import_tailwind_merge = require("tailwind-merge");
207
- var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({
208
- extend: {
209
- classGroups: {
210
- "font-size": [{ text: define_FONT_SIZE_KEYS_default }]
211
- }
212
- }
213
- });
214
- function cn(...inputs) {
215
- return twMerge((0, import_clsx.clsx)(inputs));
216
- }
217
-
218
224
  // src/ChipTrigger.tsx
219
225
  var import_jsx_runtime3 = require("react/jsx-runtime");
220
226
  function chipTriggerClass(_variant = "box") {
@@ -225,13 +231,20 @@ function chipTriggerClass(_variant = "box") {
225
231
  // a different kind of control. The variant no longer changes anything.
226
232
  );
227
233
  }
228
- function ChipContent({ caption, value, icon }) {
229
- const stack = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "flex flex-col gap-1 text-left leading-none", children: [
230
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-control-caption leading-none uppercase tracking-wide text-text-tertiary", children: caption }),
231
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-xs leading-none font-medium text-text-primary", children: value })
232
- ] });
234
+ function ChipContent({ caption, value, icon, className, testIdPrefix }) {
235
+ const stack = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
236
+ "span",
237
+ {
238
+ className: cn("flex flex-col gap-1 text-left leading-none", !icon && className),
239
+ "data-testid": icon ? void 0 : testIdPrefix,
240
+ children: [
241
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-control-caption leading-none uppercase tracking-wide text-text-tertiary", children: caption }),
242
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-xs leading-none font-medium text-text-primary", children: value })
243
+ ]
244
+ }
245
+ );
233
246
  if (icon) {
234
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "flex items-center gap-2", children: [
247
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: cn("flex items-center gap-2", className), "data-testid": testIdPrefix, children: [
235
248
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "shrink-0 text-text-tertiary", children: icon }),
236
249
  stack
237
250
  ] });
@@ -241,9 +254,6 @@ function ChipContent({ caption, value, icon }) {
241
254
 
242
255
  // src/AdvertiserQuickFilter.tsx
243
256
  var import_jsx_runtime4 = require("react/jsx-runtime");
244
- function cx(...parts) {
245
- return parts.filter(Boolean).join(" ");
246
- }
247
257
  var SELECT_ALL_THRESHOLD = 5;
248
258
  function usePaging(total, pageSize, resetKey) {
249
259
  const [pages, setPages] = (0, import_react2.useState)(1);
@@ -274,6 +284,7 @@ function AdvertiserQuickFilter({
274
284
  promptLabel = "an advertiser name",
275
285
  noResultsHint = "Try checking your spelling or searching for a broader brand name.",
276
286
  clearLabel = "Clear advertisers",
287
+ className,
277
288
  testIdPrefix
278
289
  }) {
279
290
  const [open, setOpen] = (0, import_react2.useState)(false);
@@ -354,7 +365,7 @@ function AdvertiserQuickFilter({
354
365
  const shown = open && !showFooter ? draft : selected;
355
366
  const counted = parked.length ? shown.filter((id) => !parked.includes(id)) : shown;
356
367
  const value = counted.length === 0 ? "All" : counted.length === 1 ? options.find((o) => o.id === counted[0])?.label ?? "1 selected" : `${counted.length} selected`;
357
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "relative", ref, children: [
368
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cn("relative", className), ref, "data-testid": testIdPrefix, children: [
358
369
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
359
370
  "button",
360
371
  {
@@ -371,7 +382,7 @@ function AdvertiserQuickFilter({
371
382
  {
372
383
  size: 14,
373
384
  "aria-hidden": "true",
374
- className: cx("shrink-0 text-text-secondary transition-transform", open && "rotate-180")
385
+ className: cn("shrink-0 text-text-secondary transition-transform", open && "rotate-180")
375
386
  }
376
387
  )
377
388
  ]
@@ -380,7 +391,7 @@ function AdvertiserQuickFilter({
380
391
  open && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
381
392
  "div",
382
393
  {
383
- className: cx(
394
+ className: cn(
384
395
  "absolute top-[calc(100%+8px)] z-30 flex w-72 flex-col overflow-hidden rounded-card border border-border-default bg-surface shadow-overlay",
385
396
  align === "right" ? "right-0" : "left-0"
386
397
  ),
@@ -410,7 +421,7 @@ function AdvertiserQuickFilter({
410
421
  type: "button",
411
422
  onClick: clearSearch,
412
423
  "aria-label": "Clear search",
413
- className: "shrink-0 text-text-tertiary transition-colors hover:text-text-primary",
424
+ className: "shrink-0 text-text-tertiary transition-colors hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
414
425
  children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react3.X, { size: 13 })
415
426
  }
416
427
  )
@@ -424,14 +435,14 @@ function AdvertiserQuickFilter({
424
435
  "data-testid": testIdPrefix && `${testIdPrefix}-selected-toggle`,
425
436
  onClick: () => setSelectedOpen((v) => !v),
426
437
  "aria-expanded": selectedOpen,
427
- className: "flex w-full items-center gap-1.5 rounded-control px-2 py-1 text-left text-micro font-semibold uppercase tracking-wide text-text-tertiary transition-colors hover:text-text-primary",
438
+ className: "flex w-full items-center gap-1.5 rounded-control px-2 py-1 text-left text-micro font-semibold uppercase tracking-wide text-text-tertiary transition-colors hover:text-text-primary focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
428
439
  children: [
429
440
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
430
441
  import_lucide_react3.ChevronDown,
431
442
  {
432
443
  size: 13,
433
444
  "aria-hidden": "true",
434
- className: cx("transition-transform", !selectedOpen && "-rotate-90")
445
+ className: cn("transition-transform", !selectedOpen && "-rotate-90")
435
446
  }
436
447
  ),
437
448
  "Selected (",
@@ -469,7 +480,7 @@ function AdvertiserQuickFilter({
469
480
  type: "button",
470
481
  "data-testid": testIdPrefix && `${testIdPrefix}-select-all-visible`,
471
482
  onClick: toggleAllVisible,
472
- className: "flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-xs font-semibold text-text-link transition-colors hover:bg-subtle",
483
+ className: "flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-xs font-semibold text-text-link transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
473
484
  children: [
474
485
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react3.ListChecks, { size: 14, "aria-hidden": "true" }),
475
486
  allVisibleSelected ? `Deselect ${results.length} visible` : `Select all ${results.length} visible`
@@ -511,7 +522,7 @@ function AdvertiserQuickFilter({
511
522
  "data-testid": testIdPrefix && `${testIdPrefix}-clear-all`,
512
523
  onClick: () => setDraft(clearValue),
513
524
  disabled: draft.length === 0,
514
- className: "text-dense font-medium text-text-secondary transition-colors hover:text-text-primary disabled:opacity-40",
525
+ className: "text-dense font-medium text-text-secondary transition-colors hover:text-text-primary disabled:opacity-40 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
515
526
  children: "Clear all"
516
527
  }
517
528
  ),
@@ -521,7 +532,7 @@ function AdvertiserQuickFilter({
521
532
  type: "button",
522
533
  "data-testid": testIdPrefix && `${testIdPrefix}-apply`,
523
534
  onClick: apply,
524
- className: "rounded-control bg-brand-primaryAction px-5 py-2 text-dense font-semibold text-brand-onprimary transition hover:brightness-110",
535
+ className: "rounded-control bg-brand-primaryAction px-5 py-2 text-dense font-semibold text-brand-onprimary transition hover:brightness-110 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
525
536
  children: "Apply"
526
537
  }
527
538
  )
@@ -535,7 +546,7 @@ function AdvertiserQuickFilter({
535
546
  {
536
547
  type: "button",
537
548
  onClick: () => setDraft([]),
538
- className: "text-xs font-medium text-text-link hover:underline",
549
+ className: "text-xs font-medium text-text-link hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
539
550
  children: clearLabel
540
551
  }
541
552
  )
@@ -569,7 +580,7 @@ function OptionRow({
569
580
  e.stopPropagation();
570
581
  onToggle();
571
582
  },
572
- className: cx(
583
+ className: cn(
573
584
  "flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-[5px] border transition-colors",
574
585
  "focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
575
586
  checked ? "border-transparent bg-brand-primaryAction text-brand-onprimary" : "border-border-interactive bg-surface hover:border-brand-primaryAction"
@@ -642,11 +653,12 @@ var KIND = {
642
653
  category: "px-2 py-1"
643
654
  };
644
655
  var CATEGORY = "bg-subtle font-medium text-text-tertiary";
645
- function Badge({ tone = "neutral", kind = "label", dot = false, children, className }) {
656
+ function Badge({ tone = "neutral", kind = "label", dot = false, children, className, testIdPrefix }) {
646
657
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
647
658
  "span",
648
659
  {
649
660
  style: kind === "category" ? void 0 : TONE_STYLE[tone],
661
+ "data-testid": testIdPrefix,
650
662
  className: cn(
651
663
  // `inline-flex` + `gap` so a leading icon sits on the text baseline
652
664
  // without every caller re-inventing the spacing. `shrink-0` because a
@@ -668,7 +680,7 @@ function Badge({ tone = "neutral", kind = "label", dot = false, children, classN
668
680
  // src/Delta.tsx
669
681
  var import_lucide_react4 = require("lucide-react");
670
682
  var import_jsx_runtime6 = require("react/jsx-runtime");
671
- function Delta({ value, suffix = "%", arrow = false, period, className }) {
683
+ function Delta({ value, suffix = "%", arrow = false, period, className, testIdPrefix }) {
672
684
  const up = value >= 0;
673
685
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
674
686
  "span",
@@ -678,6 +690,7 @@ function Delta({ value, suffix = "%", arrow = false, period, className }) {
678
690
  up ? "text-text-success" : "text-text-danger",
679
691
  className
680
692
  ),
693
+ "data-testid": testIdPrefix,
681
694
  children: [
682
695
  arrow && (up ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react4.ArrowUpRight, { size: 13, "aria-hidden": "true" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react4.ArrowDownRight, { size: 13, "aria-hidden": "true" })),
683
696
  up ? "+" : "\u2212",
@@ -690,6 +703,7 @@ function Delta({ value, suffix = "%", arrow = false, period, className }) {
690
703
  }
691
704
 
692
705
  // src/CheckBox.tsx
706
+ var import_react3 = require("react");
693
707
  var import_lucide_react5 = require("lucide-react");
694
708
  var import_jsx_runtime7 = require("react/jsx-runtime");
695
709
  function boxClass(on, disabled) {
@@ -703,28 +717,19 @@ function Glyph({ checked, indeterminate }) {
703
717
  if (indeterminate) return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react5.Minus, { size: 13, strokeWidth: 3 });
704
718
  return checked ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react5.Check, { size: 13, strokeWidth: 3 }) : null;
705
719
  }
706
- function CheckBox({
707
- checked,
708
- indeterminate,
709
- onChange,
710
- ariaLabel,
711
- disabled,
712
- stopPropagation = true,
713
- testId,
714
- title,
715
- className
716
- }) {
720
+ var CheckBox = (0, import_react3.forwardRef)(function CheckBox2({ checked, indeterminate, onChange, ariaLabel, disabled, stopPropagation = true, testId, testIdPrefix, title, className }, ref) {
717
721
  const on = checked || !!indeterminate;
718
722
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
719
723
  "button",
720
724
  {
725
+ ref,
721
726
  type: "button",
722
727
  role: "checkbox",
723
728
  "aria-checked": indeterminate ? "mixed" : checked,
724
729
  "aria-label": ariaLabel,
725
730
  title,
726
731
  disabled,
727
- "data-testid": testId,
732
+ "data-testid": testId ?? testIdPrefix,
728
733
  onClick: (e) => {
729
734
  if (stopPropagation) e.stopPropagation();
730
735
  onChange();
@@ -742,13 +747,24 @@ function CheckBox({
742
747
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Glyph, { checked, indeterminate })
743
748
  }
744
749
  );
745
- }
746
- function CheckBoxBox({ checked, indeterminate, disabled, className }) {
747
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { "aria-hidden": "true", className: cn(boxClass(checked || !!indeterminate, disabled), className), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Glyph, { checked, indeterminate }) });
748
- }
750
+ });
751
+ CheckBox.displayName = "CheckBox";
752
+ var CheckBoxBox = (0, import_react3.forwardRef)(function CheckBoxBox2({ checked, indeterminate, disabled, className, testIdPrefix }, ref) {
753
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
754
+ "span",
755
+ {
756
+ ref,
757
+ "aria-hidden": "true",
758
+ "data-testid": testIdPrefix,
759
+ className: cn(boxClass(checked || !!indeterminate, disabled), className),
760
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Glyph, { checked, indeterminate })
761
+ }
762
+ );
763
+ });
764
+ CheckBoxBox.displayName = "CheckBoxBox";
749
765
 
750
766
  // src/DateRangeFilter.tsx
751
- var import_react3 = require("react");
767
+ var import_react4 = require("react");
752
768
  var import_lucide_react6 = require("lucide-react");
753
769
  var import_jsx_runtime8 = require("react/jsx-runtime");
754
770
  var DEFAULT_SHORTCUTS = [
@@ -905,6 +921,7 @@ function DateRangeFilter({
905
921
  initialRange,
906
922
  compare,
907
923
  onApply,
924
+ className,
908
925
  testIdPrefix,
909
926
  granularity = "day",
910
927
  formatDate,
@@ -921,39 +938,39 @@ function DateRangeFilter({
921
938
  const SHORTCUTS = (presetSet === "creativeIntel" ? CREATIVE_INTEL_SHORTCUTS : DEFAULT_SHORTCUTS).filter(
922
939
  (s) => !excludePresets.includes(s)
923
940
  );
924
- const today = (0, import_react3.useMemo)(() => todayProp ?? /* @__PURE__ */ new Date(), []);
941
+ const today = (0, import_react4.useMemo)(() => todayProp ?? /* @__PURE__ */ new Date(), []);
925
942
  const initShortcut = matchShortcut(SHORTCUTS, controlled ? controlledValue : defaultValue);
926
943
  const initRange = controlled ? controlledRange : initShortcut === "Custom" && initialRange ? snap(...initialRange) : snap(...presetRange(initShortcut === "Custom" ? "Rolling 12 months" : initShortcut, today));
927
944
  const compareLabel = (id) => compare?.options.find((o) => o.id === id)?.label;
928
945
  const dateLine = (s, e) => monthly ? `${fmtMonth(s)} \u2013 ${fmtMonth(e)}` : formatted ? showRange(s, e) : shortDates ? `${fmt(s)} \u2013 ${fmt(e)}` : fullRangeLabel(s, e);
929
- const [open, setOpen] = (0, import_react3.useState)(false);
930
- const [uncontrolledValue, setUncontrolledValue] = (0, import_react3.useState)(
946
+ const [open, setOpen] = (0, import_react4.useState)(false);
947
+ const [uncontrolledValue, setUncontrolledValue] = (0, import_react4.useState)(
931
948
  startsEmpty ? emptyLabel : showDates ? presetLabel(initShortcut) : defaultValue || "Last 7 days"
932
949
  );
933
- const [uncontrolledDatesLine, setUncontrolledDatesLine] = (0, import_react3.useState)(
950
+ const [uncontrolledDatesLine, setUncontrolledDatesLine] = (0, import_react4.useState)(
934
951
  startsEmpty ? null : dateLine(initRange[0], initRange[1])
935
952
  );
936
- const committed = (0, import_react3.useRef)({ shortcut: initShortcut, start: initRange[0], end: initRange[1], set: !startsEmpty });
937
- const [cmp, setCmp] = (0, import_react3.useState)(compare?.value);
938
- const committedCmp = (0, import_react3.useRef)(compare?.value);
939
- const [appliedCmp, setAppliedCmp] = (0, import_react3.useState)(compare?.value);
940
- (0, import_react3.useEffect)(() => {
953
+ const committed = (0, import_react4.useRef)({ shortcut: initShortcut, start: initRange[0], end: initRange[1], set: !startsEmpty });
954
+ const [cmp, setCmp] = (0, import_react4.useState)(compare?.value);
955
+ const committedCmp = (0, import_react4.useRef)(compare?.value);
956
+ const [appliedCmp, setAppliedCmp] = (0, import_react4.useState)(compare?.value);
957
+ (0, import_react4.useEffect)(() => {
941
958
  committedCmp.current = compare?.value;
942
959
  setAppliedCmp(compare?.value);
943
960
  }, [compare?.value]);
944
- const compareName = `${(0, import_react3.useId)()}-compare`;
961
+ const compareName = `${(0, import_react4.useId)()}-compare`;
945
962
  const displayValue = controlled ? showDates ? presetLabel(initShortcut) : showValue(controlledValue, initRange[0], initRange[1]) : showValue(uncontrolledValue, committed.current.start, committed.current.end);
946
963
  const displayDatesLine = controlled ? dateLine(initRange[0], initRange[1]) : uncontrolledDatesLine;
947
- const [shortcut, setShortcut] = (0, import_react3.useState)(initShortcut);
948
- const [start, setStart] = (0, import_react3.useState)(initRange[0]);
949
- const [end, setEnd] = (0, import_react3.useState)(initRange[1]);
950
- const [leftMonth, setLeftMonth] = (0, import_react3.useState)(new Date(initRange[0].getFullYear(), initRange[0].getMonth(), 1));
951
- const ref = (0, import_react3.useRef)(null);
952
- (0, import_react3.useEffect)(() => {
964
+ const [shortcut, setShortcut] = (0, import_react4.useState)(initShortcut);
965
+ const [start, setStart] = (0, import_react4.useState)(initRange[0]);
966
+ const [end, setEnd] = (0, import_react4.useState)(initRange[1]);
967
+ const [leftMonth, setLeftMonth] = (0, import_react4.useState)(new Date(initRange[0].getFullYear(), initRange[0].getMonth(), 1));
968
+ const ref = (0, import_react4.useRef)(null);
969
+ (0, import_react4.useEffect)(() => {
953
970
  if (controlled || startsEmpty) return;
954
971
  onRangeChange?.(committed.current.start, committed.current.end);
955
972
  }, []);
956
- (0, import_react3.useEffect)(() => {
973
+ (0, import_react4.useEffect)(() => {
957
974
  if (!open) return;
958
975
  const committedShortcut = controlled ? initShortcut : committed.current.shortcut;
959
976
  const committedStart = controlled ? initRange[0] : committed.current.start;
@@ -1015,14 +1032,14 @@ function DateRangeFilter({
1015
1032
  onApply?.(shortcut === "Custom" ? `${fmt(s)} \u2013 ${fmt(e)}` : shortcut, s, e, cmp);
1016
1033
  setOpen(false);
1017
1034
  };
1018
- const popRef = (0, import_react3.useRef)(null);
1019
- const [flipBelow, setFlipBelow] = (0, import_react3.useState)(false);
1020
- (0, import_react3.useLayoutEffect)(() => {
1035
+ const popRef = (0, import_react4.useRef)(null);
1036
+ const [flipBelow, setFlipBelow] = (0, import_react4.useState)(false);
1037
+ (0, import_react4.useLayoutEffect)(() => {
1021
1038
  if (!open || placement !== "above" || !ref.current || !popRef.current) return;
1022
1039
  setFlipBelow(ref.current.getBoundingClientRect().top < popRef.current.offsetHeight + 16);
1023
1040
  }, [open, placement]);
1024
1041
  const above = placement === "above" && !flipBelow;
1025
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "relative", ref, children: [
1042
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: cn("relative", className), ref, "data-testid": testIdPrefix, children: [
1026
1043
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1027
1044
  "button",
1028
1045
  {
@@ -1062,7 +1079,7 @@ function DateRangeFilter({
1062
1079
  type: "button",
1063
1080
  "data-testid": testIdPrefix && `${testIdPrefix}-option-${slug2(s)}`,
1064
1081
  onClick: () => choosePreset(s),
1065
- className: `rounded-control px-3 py-2 text-left text-dense font-medium transition-colors ${shortcut === s ? "bg-subtle text-text-primary" : "text-text-secondary hover:bg-subtle hover:text-text-primary"}`,
1082
+ className: `rounded-control px-3 py-2 text-left text-dense font-medium transition-colors focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus ${shortcut === s ? "bg-subtle text-text-primary" : "text-text-secondary hover:bg-subtle hover:text-text-primary"}`,
1066
1083
  children: s
1067
1084
  },
1068
1085
  s
@@ -1080,7 +1097,7 @@ function DateRangeFilter({
1080
1097
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "w-[252px]", children: [
1081
1098
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "mb-2 flex items-center justify-between", children: [
1082
1099
  offset === 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(NavBtn, { onClick: () => setLeftMonth(addMonths(leftMonth, -1)), "aria-label": "Previous month", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react6.ChevronLeft, { size: 16 }) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "h-7 w-7" }),
1083
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "text-[15px] font-semibold text-text-primary", children: [
1100
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "text-panel-title font-semibold text-text-primary", children: [
1084
1101
  MONTHS[m.getMonth()],
1085
1102
  " ",
1086
1103
  m.getFullYear()
@@ -1103,7 +1120,7 @@ function DateRangeFilter({
1103
1120
  else if (end && isEnd) band = "left-0 right-1/2";
1104
1121
  else band = "left-0 right-0";
1105
1122
  }
1106
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", onClick: () => pickDay(d), className: "relative flex h-9 items-center justify-center", children: [
1123
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", onClick: () => pickDay(d), className: "relative flex h-9 items-center justify-center focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus", children: [
1107
1124
  band && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: `absolute inset-y-[3px] bg-ai-tint ${band}`, "aria-hidden": "true" }),
1108
1125
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1109
1126
  "span",
@@ -1148,8 +1165,8 @@ function DateRangeFilter({
1148
1165
  ] }),
1149
1166
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "mt-4 flex items-center justify-end gap-2", children: [
1150
1167
  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." }),
1151
- /* @__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-dense font-semibold text-text-primary transition-colors hover:bg-subtle", children: "Cancel" }),
1152
- /* @__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-dense font-semibold text-brand-onprimary transition-[filter] hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-50", children: "Apply" })
1168
+ /* @__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-dense font-semibold text-text-primary transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", children: "Cancel" }),
1169
+ /* @__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-dense font-semibold text-brand-onprimary transition-[filter] hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", children: "Apply" })
1153
1170
  ] })
1154
1171
  ] })
1155
1172
  ]
@@ -1164,11 +1181,11 @@ function Field({ label, value }) {
1164
1181
  ] });
1165
1182
  }
1166
1183
  function NavBtn({ children, onClick, ...rest }) {
1167
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", onClick, className: "flex h-7 w-7 items-center justify-center rounded-full text-text-secondary transition-colors hover:bg-subtle hover:text-text-primary", ...rest, children });
1184
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", onClick, className: "flex h-7 w-7 items-center justify-center rounded-full text-text-secondary transition-colors hover:bg-subtle hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", ...rest, children });
1168
1185
  }
1169
1186
 
1170
1187
  // src/SearchBar.tsx
1171
- var import_react4 = require("react");
1188
+ var import_react5 = require("react");
1172
1189
  var import_lucide_react7 = require("lucide-react");
1173
1190
  var import_jsx_runtime9 = require("react/jsx-runtime");
1174
1191
  var HEIGHT = { sm: "h-8", md: "h-10", lg: "h-11" };
@@ -1196,10 +1213,7 @@ function mergeAdCodes(existing, incoming) {
1196
1213
  function slug3(value) {
1197
1214
  return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
1198
1215
  }
1199
- function cx2(...classes) {
1200
- return classes.filter(Boolean).join(" ");
1201
- }
1202
- function SearchBar({
1216
+ var SearchBar = (0, import_react5.forwardRef)(function SearchBar2({
1203
1217
  placeholder = "Search\u2026",
1204
1218
  value,
1205
1219
  onChange,
@@ -1213,18 +1227,23 @@ function SearchBar({
1213
1227
  onDownloadAdCodes,
1214
1228
  className,
1215
1229
  testIdPrefix
1216
- }) {
1217
- const [open, setOpen] = (0, import_react4.useState)(false);
1218
- const ref = (0, import_react4.useRef)(null);
1219
- const input = (0, import_react4.useRef)(null);
1220
- const [codesOpen, setCodesOpen] = (0, import_react4.useState)(false);
1221
- const codesRef = (0, import_react4.useRef)(null);
1222
- const codesPopover = (0, import_react4.useRef)(null);
1223
- const refocus = (0, import_react4.useRef)(null);
1230
+ }, forwardedRef) {
1231
+ const [open, setOpen] = (0, import_react5.useState)(false);
1232
+ const ref = (0, import_react5.useRef)(null);
1233
+ const input = (0, import_react5.useRef)(null);
1234
+ const setInput = (el) => {
1235
+ input.current = el;
1236
+ if (typeof forwardedRef === "function") forwardedRef(el);
1237
+ else if (forwardedRef) forwardedRef.current = el;
1238
+ };
1239
+ const [codesOpen, setCodesOpen] = (0, import_react5.useState)(false);
1240
+ const codesRef = (0, import_react5.useRef)(null);
1241
+ const codesPopover = (0, import_react5.useRef)(null);
1242
+ const refocus = (0, import_react5.useRef)(null);
1224
1243
  const adCodeMode = variant === "filterable" && matchValue?.mode === "adCode" && !!onAdCodesChange;
1225
1244
  const matchedCount = adCodes.filter((c) => isAdCodeMatched?.(c)).length;
1226
1245
  const hasMisses = !!isAdCodeMatched && matchedCount < adCodes.length;
1227
- (0, import_react4.useEffect)(() => {
1246
+ (0, import_react5.useEffect)(() => {
1228
1247
  if (!codesOpen) return;
1229
1248
  const onKey = (e) => {
1230
1249
  if (e.key !== "Escape") return;
@@ -1241,7 +1260,7 @@ function SearchBar({
1241
1260
  window.removeEventListener("mousedown", onClick);
1242
1261
  };
1243
1262
  }, [codesOpen]);
1244
- (0, import_react4.useLayoutEffect)(() => {
1263
+ (0, import_react5.useLayoutEffect)(() => {
1245
1264
  const i = refocus.current;
1246
1265
  if (i === null) return;
1247
1266
  refocus.current = null;
@@ -1254,7 +1273,7 @@ function SearchBar({
1254
1273
  if (!next.length) setCodesOpen(false);
1255
1274
  onAdCodesChange?.(next);
1256
1275
  };
1257
- (0, import_react4.useEffect)(() => {
1276
+ (0, import_react5.useEffect)(() => {
1258
1277
  if (!open) return;
1259
1278
  const onKey = (e) => e.key === "Escape" && setOpen(false);
1260
1279
  const onClick = (e) => {
@@ -1271,11 +1290,12 @@ function SearchBar({
1271
1290
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1272
1291
  "div",
1273
1292
  {
1274
- className: cx2(
1293
+ className: cn(
1275
1294
  "relative flex min-w-[200px] flex-1 items-stretch rounded-control border border-border-strong bg-input focus-within:outline-2 focus-within:outline-offset-1 focus-within:outline-border-focus",
1276
1295
  HEIGHT[size],
1277
1296
  className
1278
1297
  ),
1298
+ "data-testid": testIdPrefix,
1279
1299
  children: [
1280
1300
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1281
1301
  "div",
@@ -1293,7 +1313,7 @@ function SearchBar({
1293
1313
  adCodeMode && adCodes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1294
1314
  "span",
1295
1315
  {
1296
- className: cx2(
1316
+ className: cn(
1297
1317
  "inline-flex shrink-0 items-center gap-1 rounded-full py-0.5 pl-2 pr-1 text-xs font-medium",
1298
1318
  hasMisses ? "bg-status-danger/15 text-text-danger" : "bg-subtle text-text-primary"
1299
1319
  ),
@@ -1330,7 +1350,7 @@ function SearchBar({
1330
1350
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1331
1351
  "input",
1332
1352
  {
1333
- ref: input,
1353
+ ref: setInput,
1334
1354
  type: "text",
1335
1355
  value,
1336
1356
  onChange: (e) => onChange?.(e.target.value),
@@ -1363,7 +1383,7 @@ function SearchBar({
1363
1383
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1364
1384
  "li",
1365
1385
  {
1366
- className: cx2(
1386
+ className: cn(
1367
1387
  "inline-flex items-center gap-1 rounded-full py-1 pl-2.5 pr-1.5 text-card-title",
1368
1388
  missed ? "bg-status-danger/15 text-text-danger" : "bg-subtle text-text-primary"
1369
1389
  ),
@@ -1466,7 +1486,7 @@ function SearchBar({
1466
1486
  {
1467
1487
  size: 14,
1468
1488
  "aria-hidden": "true",
1469
- className: cx2("shrink-0 text-text-secondary transition-transform", open && "rotate-180")
1489
+ className: cn("shrink-0 text-text-secondary transition-transform", open && "rotate-180")
1470
1490
  }
1471
1491
  )
1472
1492
  ]
@@ -1555,7 +1575,8 @@ function SearchBar({
1555
1575
  ]
1556
1576
  }
1557
1577
  );
1558
- }
1578
+ });
1579
+ SearchBar.displayName = "SearchBar";
1559
1580
  function Divider() {
1560
1581
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "my-2.5 border-t border-border-default", "aria-hidden": "true" });
1561
1582
  }
@@ -1569,7 +1590,7 @@ function ModeRow({
1569
1590
  onSelect,
1570
1591
  testId
1571
1592
  }) {
1572
- const descId = (0, import_react4.useId)();
1593
+ const descId = (0, import_react5.useId)();
1573
1594
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1574
1595
  "div",
1575
1596
  {
@@ -1602,7 +1623,7 @@ function ModeRow({
1602
1623
  ] }),
1603
1624
  selected && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react7.Check, { size: 16, strokeWidth: 2.5, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" })
1604
1625
  ] }),
1605
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { id: descId, className: "block text-[12.5px] leading-snug text-text-secondary", children: description })
1626
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { id: descId, className: "block text-xs leading-snug text-text-secondary", children: description })
1606
1627
  ]
1607
1628
  }
1608
1629
  );
@@ -1624,12 +1645,12 @@ function RadioOption({
1624
1645
  },
1625
1646
  role: "radio",
1626
1647
  "aria-checked": checked,
1627
- className: "flex items-center gap-1.5 text-dense font-medium text-text-primary",
1648
+ className: "flex items-center gap-1.5 text-dense font-medium text-text-primary focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
1628
1649
  children: [
1629
1650
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1630
1651
  "span",
1631
1652
  {
1632
- className: cx2(
1653
+ className: cn(
1633
1654
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border-2 transition-colors",
1634
1655
  checked ? "border-brand-primaryAction" : "border-border-interactive"
1635
1656
  ),
@@ -1642,10 +1663,10 @@ function RadioOption({
1642
1663
  );
1643
1664
  }
1644
1665
  function RowInfoTip({ text }) {
1645
- const [open, setOpen] = (0, import_react4.useState)(false);
1646
- const id = (0, import_react4.useId)();
1647
- const ref = (0, import_react4.useRef)(null);
1648
- (0, import_react4.useEffect)(() => {
1666
+ const [open, setOpen] = (0, import_react5.useState)(false);
1667
+ const id = (0, import_react5.useId)();
1668
+ const ref = (0, import_react5.useRef)(null);
1669
+ (0, import_react5.useEffect)(() => {
1649
1670
  if (!open) return;
1650
1671
  const onDown = (e) => {
1651
1672
  if (ref.current && !ref.current.contains(e.target)) setOpen(false);
@@ -1674,7 +1695,7 @@ function RowInfoTip({ text }) {
1674
1695
  {
1675
1696
  id,
1676
1697
  hidden: !open,
1677
- className: "absolute left-0 top-[calc(100%+6px)] z-40 w-[220px] rounded-control border border-border-default bg-surface px-2.5 py-1.5 text-[11.5px] font-normal leading-snug text-text-secondary shadow-overlay",
1698
+ className: "absolute left-0 top-[calc(100%+6px)] z-40 w-[220px] rounded-control border border-border-default bg-surface px-2.5 py-1.5 text-xs font-normal leading-snug text-text-secondary shadow-overlay",
1678
1699
  children: text
1679
1700
  }
1680
1701
  )
@@ -1682,7 +1703,7 @@ function RowInfoTip({ text }) {
1682
1703
  }
1683
1704
 
1684
1705
  // src/SectionRail.tsx
1685
- var import_react5 = require("react");
1706
+ var import_react6 = require("react");
1686
1707
  var import_lucide_react8 = require("lucide-react");
1687
1708
  var import_jsx_runtime10 = require("react/jsx-runtime");
1688
1709
  function SectionRail({
@@ -1691,13 +1712,15 @@ function SectionRail({
1691
1712
  subtitle,
1692
1713
  viewAllLabel,
1693
1714
  viewAllHref,
1694
- children
1715
+ children,
1716
+ className,
1717
+ testIdPrefix
1695
1718
  }) {
1696
- const scrollRef = (0, import_react5.useRef)(null);
1719
+ const scrollRef = (0, import_react6.useRef)(null);
1697
1720
  const scroll = (direction) => {
1698
1721
  scrollRef.current?.scrollBy({ left: direction * 320, behavior: "smooth" });
1699
1722
  };
1700
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: "flex flex-col gap-4", children: [
1723
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: cn("flex flex-col gap-4", className), "data-testid": testIdPrefix, children: [
1701
1724
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("header", { className: "flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between", children: [
1702
1725
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { children: [
1703
1726
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
@@ -1727,7 +1750,7 @@ function SectionRail({
1727
1750
  type: "button",
1728
1751
  onClick: () => scroll(-1),
1729
1752
  "aria-label": "Previous",
1730
- className: "hidden h-10 w-10 items-center justify-center rounded-control border border-border-default text-text-secondary transition-colors hover:bg-subtle hover:text-text-primary sm:flex lg:hidden",
1753
+ className: "hidden h-10 w-10 items-center justify-center rounded-control border border-border-default text-text-secondary transition-colors hover:bg-subtle hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus sm:flex lg:hidden",
1731
1754
  children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react8.ChevronLeft, { size: 16 })
1732
1755
  }
1733
1756
  ),
@@ -1737,7 +1760,7 @@ function SectionRail({
1737
1760
  type: "button",
1738
1761
  onClick: () => scroll(1),
1739
1762
  "aria-label": "Next",
1740
- className: "hidden h-10 w-10 items-center justify-center rounded-control border border-border-default text-text-secondary transition-colors hover:bg-subtle hover:text-text-primary sm:flex lg:hidden",
1763
+ className: "hidden h-10 w-10 items-center justify-center rounded-control border border-border-default text-text-secondary transition-colors hover:bg-subtle hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus sm:flex lg:hidden",
1741
1764
  children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react8.ChevronRight, { size: 16 })
1742
1765
  }
1743
1766
  )
@@ -1755,18 +1778,15 @@ function SectionRail({
1755
1778
  }
1756
1779
 
1757
1780
  // src/DataScopeFilter.tsx
1758
- var import_react6 = require("react");
1781
+ var import_react7 = require("react");
1759
1782
  var import_lucide_react9 = require("lucide-react");
1760
1783
  var import_jsx_runtime11 = require("react/jsx-runtime");
1761
1784
  var FINAL_ONLY_TEXT = "Trims time periods to data that has finalized across the selected media formats. Some formats (e.g. Network TV and Cinema) finalize later, so the most recent periods may still change. Turn on for stable, report-ready numbers.";
1762
- function cx3(...classes) {
1763
- return classes.filter(Boolean).join(" ");
1764
- }
1765
- function DataScopeFilter({ value, onChange, align = "right" }) {
1766
- const [open, setOpen] = (0, import_react6.useState)(false);
1767
- const ref = (0, import_react6.useRef)(null);
1785
+ function DataScopeFilter({ value, onChange, align = "right", className, testIdPrefix }) {
1786
+ const [open, setOpen] = (0, import_react7.useState)(false);
1787
+ const ref = (0, import_react7.useRef)(null);
1768
1788
  const display = value ? "Final only" : "All";
1769
- (0, import_react6.useEffect)(() => {
1789
+ (0, import_react7.useEffect)(() => {
1770
1790
  if (!open) return;
1771
1791
  const onDown = (e) => {
1772
1792
  if (ref.current && !ref.current.contains(e.target)) setOpen(false);
@@ -1783,13 +1803,14 @@ function DataScopeFilter({ value, onChange, align = "right" }) {
1783
1803
  onChange(v);
1784
1804
  setOpen(false);
1785
1805
  };
1786
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "relative", ref, children: [
1806
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: cn("relative", className), ref, "data-testid": testIdPrefix, children: [
1787
1807
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1788
1808
  "button",
1789
1809
  {
1790
1810
  type: "button",
1791
1811
  onClick: () => setOpen((o) => !o),
1792
1812
  "aria-expanded": open,
1813
+ "data-testid": testIdPrefix && `${testIdPrefix}-trigger`,
1793
1814
  className: chipTriggerClass(),
1794
1815
  children: [
1795
1816
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ChipContent, { caption: "Data", value: display }),
@@ -1798,7 +1819,7 @@ function DataScopeFilter({ value, onChange, align = "right" }) {
1798
1819
  {
1799
1820
  size: 14,
1800
1821
  "aria-hidden": "true",
1801
- className: cx3("shrink-0 text-text-secondary transition-transform", open && "rotate-180")
1822
+ className: cn("shrink-0 text-text-secondary transition-transform", open && "rotate-180")
1802
1823
  }
1803
1824
  )
1804
1825
  ]
@@ -1809,7 +1830,8 @@ function DataScopeFilter({ value, onChange, align = "right" }) {
1809
1830
  {
1810
1831
  role: "group",
1811
1832
  "aria-label": "Data",
1812
- className: cx3(
1833
+ "data-testid": testIdPrefix && `${testIdPrefix}-popover`,
1834
+ className: cn(
1813
1835
  "absolute top-[calc(100%+8px)] z-30 min-w-[220px] overflow-hidden rounded-card border border-border-default bg-surface p-1 shadow-overlay",
1814
1836
  align === "right" ? "right-0" : "left-0"
1815
1837
  ),
@@ -1833,13 +1855,13 @@ function Option({
1833
1855
  type: "button",
1834
1856
  "aria-pressed": selected,
1835
1857
  onClick,
1836
- className: cx3(
1837
- "flex items-center gap-2 rounded-control px-2.5 py-2 text-left text-dense transition-colors hover:bg-subtle",
1858
+ className: cn(
1859
+ "flex items-center gap-2 rounded-control px-2.5 py-2 text-left text-dense transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
1838
1860
  hint ? "flex-1" : "w-full",
1839
1861
  selected ? "font-semibold text-text-primary" : "text-text-secondary"
1840
1862
  ),
1841
1863
  children: [
1842
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react9.Check, { size: 14, "aria-hidden": "true", className: cx3("shrink-0 text-brand-primaryAction", !selected && "invisible") }),
1864
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react9.Check, { size: 14, "aria-hidden": "true", className: cn("shrink-0 text-brand-primaryAction", !selected && "invisible") }),
1843
1865
  label
1844
1866
  ]
1845
1867
  }
@@ -1852,7 +1874,7 @@ function Option({
1852
1874
  }
1853
1875
 
1854
1876
  // src/SelectFilter.tsx
1855
- var import_react7 = require("react");
1877
+ var import_react8 = require("react");
1856
1878
  var import_react_dom2 = require("react-dom");
1857
1879
  var import_lucide_react10 = require("lucide-react");
1858
1880
 
@@ -1879,9 +1901,6 @@ function MenuError({ onRetry }) {
1879
1901
 
1880
1902
  // src/SelectFilter.tsx
1881
1903
  var import_jsx_runtime13 = require("react/jsx-runtime");
1882
- function cx4(...classes) {
1883
- return classes.filter(Boolean).join(" ");
1884
- }
1885
1904
  function slug4(value) {
1886
1905
  return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
1887
1906
  }
@@ -1913,12 +1932,12 @@ function SelectFilter({
1913
1932
  renderIcon
1914
1933
  }) {
1915
1934
  const sm = size === "sm";
1916
- const [open, setOpen] = (0, import_react7.useState)(false);
1917
- const [pos, setPos] = (0, import_react7.useState)(null);
1918
- const ref = (0, import_react7.useRef)(null);
1919
- const popoverRef = (0, import_react7.useRef)(null);
1920
- const close = (0, import_react7.useCallback)(() => setOpen(false), []);
1921
- const reposition = (0, import_react7.useCallback)(() => {
1935
+ const [open, setOpen] = (0, import_react8.useState)(false);
1936
+ const [pos, setPos] = (0, import_react8.useState)(null);
1937
+ const ref = (0, import_react8.useRef)(null);
1938
+ const popoverRef = (0, import_react8.useRef)(null);
1939
+ const close = (0, import_react8.useCallback)(() => setOpen(false), []);
1940
+ const reposition = (0, import_react8.useCallback)(() => {
1922
1941
  if (!ref.current) return;
1923
1942
  const r = ref.current.getBoundingClientRect();
1924
1943
  const h = Math.min(options.length * 36 + 8, 288);
@@ -1929,11 +1948,11 @@ function SelectFilter({
1929
1948
  width: r.width
1930
1949
  });
1931
1950
  }, [align, options.length]);
1932
- (0, import_react7.useLayoutEffect)(() => {
1951
+ (0, import_react8.useLayoutEffect)(() => {
1933
1952
  if (!open) return;
1934
1953
  reposition();
1935
1954
  }, [open, reposition]);
1936
- (0, import_react7.useEffect)(() => {
1955
+ (0, import_react8.useEffect)(() => {
1937
1956
  if (!open) return;
1938
1957
  const onKey = (e) => e.key === "Escape" && close();
1939
1958
  const onClick = (e) => {
@@ -1964,7 +1983,7 @@ function SelectFilter({
1964
1983
  " ",
1965
1984
  valueContent
1966
1985
  ] }) : valueContent;
1967
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: cx4("relative", fullWidth && "w-full"), ref, children: [
1986
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: cn("relative", fullWidth && "w-full"), ref, "data-testid": testIdPrefix, children: [
1968
1987
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1969
1988
  "button",
1970
1989
  {
@@ -1975,7 +1994,7 @@ function SelectFilter({
1975
1994
  "aria-haspopup": "listbox",
1976
1995
  "aria-label": sm && !inlineCaption ? caption : void 0,
1977
1996
  disabled,
1978
- className: cx4(
1997
+ className: cn(
1979
1998
  sm ? "flex h-8 items-center gap-1.5 rounded-control border border-border-strong bg-input pl-2.5 pr-2 text-dense font-medium text-text-primary transition-colors hover:bg-subtle focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus" : chipTriggerClass(),
1980
1999
  "disabled:pointer-events-none disabled:opacity-40",
1981
2000
  fullWidth && "w-full justify-between",
@@ -1988,7 +2007,7 @@ function SelectFilter({
1988
2007
  {
1989
2008
  size: 14,
1990
2009
  "aria-hidden": "true",
1991
- className: cx4("shrink-0 text-text-secondary transition-transform", open && "rotate-180")
2010
+ className: cn("shrink-0 text-text-secondary transition-transform", open && "rotate-180")
1992
2011
  }
1993
2012
  )
1994
2013
  ]
@@ -2001,7 +2020,7 @@ function SelectFilter({
2001
2020
  ref: popoverRef,
2002
2021
  "data-testid": testIdPrefix && `${testIdPrefix}-popover`,
2003
2022
  style: { position: "fixed", top: pos.top, left: pos.left, right: pos.right, width: fullWidth ? pos.width : void 0 },
2004
- className: cx4(
2023
+ className: cn(
2005
2024
  "z-[65] flex flex-col overflow-hidden rounded-card border border-border-default bg-surface shadow-overlay",
2006
2025
  !fullWidth && (sm ? "w-max min-w-28 max-w-72" : "w-56")
2007
2026
  ),
@@ -2020,14 +2039,14 @@ function SelectFilter({
2020
2039
  onChange(o);
2021
2040
  close();
2022
2041
  },
2023
- className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle",
2042
+ className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
2024
2043
  children: [
2025
2044
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center text-brand-primaryAction", children: selected && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Check, { size: 15, strokeWidth: 3 }) }),
2026
2045
  renderIcon && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(OptionIcon, { children: renderIcon(o) }),
2027
2046
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2028
2047
  "span",
2029
2048
  {
2030
- className: cx4("flex-1 text-sm", selected ? "font-semibold text-text-primary" : "text-text-primary"),
2049
+ className: cn("flex-1 text-sm", selected ? "font-semibold text-text-primary" : "text-text-primary"),
2031
2050
  children: o
2032
2051
  }
2033
2052
  )
@@ -2044,19 +2063,20 @@ function SelectFilter({
2044
2063
  }
2045
2064
 
2046
2065
  // src/Card.tsx
2047
- var import_react8 = require("react");
2066
+ var import_react9 = require("react");
2048
2067
  var import_jsx_runtime14 = require("react/jsx-runtime");
2049
- var Card = (0, import_react8.forwardRef)(function Card2({ staticCard, title, titleAs: TitleTag = "h3", subtitle, action, className, children, ...rest }, ref) {
2068
+ var Card = (0, import_react9.forwardRef)(function Card2({ staticCard, title, titleAs: TitleTag = "h3", subtitle, action, className, testIdPrefix, children, ...rest }, ref) {
2050
2069
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2051
2070
  "article",
2052
2071
  {
2053
2072
  ref,
2054
- className: [
2073
+ className: cn(
2055
2074
  "flex h-full flex-col overflow-hidden rounded-card border border-border-default bg-surface shadow-raised",
2056
2075
  // Interactive hover: deeper drop shadow only -- no elevation/transform.
2057
2076
  !staticCard && "group transition-shadow hover:shadow-overlay",
2058
2077
  className
2059
- ].filter(Boolean).join(" "),
2078
+ ),
2079
+ "data-testid": testIdPrefix,
2060
2080
  ...rest,
2061
2081
  children: title ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-1 flex-col p-card-padding", children: [
2062
2082
  /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-start justify-between gap-2", children: [
@@ -2080,7 +2100,7 @@ var NO_RESULTS_BODY = "Your filters may be too narrow, conflict with each other,
2080
2100
  function noResultsBody(workspaceName) {
2081
2101
  return workspaceName ? `Nothing in the \u201C${workspaceName}\u201D workspace matches. ${NO_RESULTS_BODY}` : NO_RESULTS_BODY;
2082
2102
  }
2083
- var PRIMARY_ACTION_CLASS = "rounded-control bg-brand-primaryAction px-3.5 py-2 text-dense font-semibold text-brand-onprimary transition-colors hover:opacity-90";
2103
+ var PRIMARY_ACTION_CLASS = "rounded-control bg-brand-primaryAction px-3.5 py-2 text-dense font-semibold text-brand-onprimary transition-colors hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus";
2084
2104
  var QUIET_ACTION_CLASS = "rounded-control text-dense font-medium text-text-link transition-colors hover:underline focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus";
2085
2105
  function NoResultsEmptyState({
2086
2106
  title = NO_RESULTS_TITLE,
@@ -2090,13 +2110,14 @@ function NoResultsEmptyState({
2090
2110
  onClearFilters,
2091
2111
  onEditFilters,
2092
2112
  actions,
2113
+ className,
2093
2114
  testIdPrefix
2094
2115
  }) {
2095
2116
  const bodyText = body ?? noResultsBody(workspaceName);
2096
2117
  const showClear = hasFilters !== false && Boolean(onClearFilters);
2097
2118
  const showEdit = Boolean(onEditFilters);
2098
2119
  const hasActions = showClear || showEdit || Boolean(actions && actions.length > 0);
2099
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col items-center justify-center gap-3 text-center", "data-testid": testIdPrefix, children: [
2120
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: cn("flex flex-col items-center justify-center gap-3 text-center", className), "data-testid": testIdPrefix, children: [
2100
2121
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "flex h-11 w-11 items-center justify-center rounded-full bg-subtle text-text-tertiary", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react11.FilterX, { size: 20, "aria-hidden": "true" }) }),
2101
2122
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("h2", { className: "text-base font-semibold text-text-primary", children: title }),
2102
2123
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "max-w-[420px] text-dense leading-relaxed text-text-secondary", children: bodyText }),
@@ -2136,14 +2157,21 @@ function NoResultsEmptyState({
2136
2157
  }
2137
2158
 
2138
2159
  // src/WorkspaceSelectedCard.tsx
2139
- var import_react9 = require("react");
2160
+ var import_react10 = require("react");
2140
2161
  var import_lucide_react12 = require("lucide-react");
2141
2162
  var import_jsx_runtime16 = require("react/jsx-runtime");
2142
- function cx5(...parts) {
2143
- return parts.filter(Boolean).join(" ");
2144
- }
2145
- function WorkspaceSelectedCard({ groups, testIdPrefix }) {
2146
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("aside", { className: "sticky top-4 flex min-w-0 flex-col gap-4 self-start rounded-card border border-border-default bg-surface px-5 pb-5 pt-4 shadow-raised sm:px-6 sm:pb-6", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex flex-col divide-y divide-border-default", children: groups.map((g) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SummaryGroupItem, { group: g, testIdPrefix }, g.id)) }) });
2163
+ function WorkspaceSelectedCard({ groups, className, testIdPrefix }) {
2164
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2165
+ "aside",
2166
+ {
2167
+ className: cn(
2168
+ "sticky top-4 flex min-w-0 flex-col gap-4 self-start rounded-card border border-border-default bg-surface px-5 pb-5 pt-4 shadow-raised sm:px-6 sm:pb-6",
2169
+ className
2170
+ ),
2171
+ "data-testid": testIdPrefix,
2172
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex flex-col divide-y divide-border-default", children: groups.map((g) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SummaryGroupItem, { group: g, testIdPrefix }, g.id)) })
2173
+ }
2174
+ );
2147
2175
  }
2148
2176
  function SummaryGroupItem({
2149
2177
  group,
@@ -2153,9 +2181,9 @@ function SummaryGroupItem({
2153
2181
  const ownCount = group.items.length;
2154
2182
  const subCount = (group.subGroups ?? []).reduce((n, sg) => n + sg.items.length, 0);
2155
2183
  const expandCount = ownCount + subCount;
2156
- const [open, setOpen] = (0, import_react9.useState)(expandCount > 0);
2157
- const wasEmpty = (0, import_react9.useRef)(expandCount === 0);
2158
- (0, import_react9.useEffect)(() => {
2184
+ const [open, setOpen] = (0, import_react10.useState)(expandCount > 0);
2185
+ const wasEmpty = (0, import_react10.useRef)(expandCount === 0);
2186
+ (0, import_react10.useEffect)(() => {
2159
2187
  if (wasEmpty.current && expandCount > 0) setOpen(true);
2160
2188
  else if (expandCount === 0) setOpen(false);
2161
2189
  wasEmpty.current = expandCount === 0;
@@ -2168,17 +2196,17 @@ function SummaryGroupItem({
2168
2196
  onClick: () => setOpen((v) => !v),
2169
2197
  "aria-expanded": open,
2170
2198
  "data-testid": testIdPrefix && `${testIdPrefix}-group-${group.id}`,
2171
- className: "flex w-full min-w-0 items-center gap-2 text-left",
2199
+ className: "flex w-full min-w-0 items-center gap-2 text-left focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
2172
2200
  children: [
2173
2201
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2174
2202
  import_lucide_react12.ChevronDown,
2175
2203
  {
2176
2204
  size: 14,
2177
2205
  "aria-hidden": "true",
2178
- className: cx5("shrink-0 text-text-secondary transition-transform", !open && "-rotate-90")
2206
+ className: cn("shrink-0 text-text-secondary transition-transform", !open && "-rotate-90")
2179
2207
  }
2180
2208
  ),
2181
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: cx5("truncate font-semibold text-text-primary", nested ? "text-xs" : "text-dense"), children: group.label }),
2209
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: cn("truncate font-semibold text-text-primary", nested ? "text-xs" : "text-dense"), children: group.label }),
2182
2210
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "shrink-0 rounded-full bg-subtle px-1.5 py-0.5 text-micro font-semibold text-text-secondary", children: ownCount })
2183
2211
  ]
2184
2212
  }
@@ -2200,7 +2228,7 @@ function SummaryGroupItem({
2200
2228
  type: "button",
2201
2229
  "aria-label": `Remove ${item.name}`,
2202
2230
  onClick: () => group.onRemove(item.id),
2203
- className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-control text-text-secondary hover:bg-subtle hover:text-text-danger",
2231
+ className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-control text-text-secondary hover:bg-subtle hover:text-text-danger focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
2204
2232
  children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react12.X, { size: 12, "aria-hidden": "true" })
2205
2233
  }
2206
2234
  )
@@ -2214,7 +2242,7 @@ function SummaryGroupItem({
2214
2242
  type: "button",
2215
2243
  onClick: group.onRemoveAll,
2216
2244
  "data-testid": testIdPrefix && `${testIdPrefix}-remove-all-${group.id}`,
2217
- className: "mt-0.5 self-start text-micro font-medium text-text-link hover:underline",
2245
+ className: "mt-0.5 self-start text-micro font-medium text-text-link hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
2218
2246
  children: "Remove all"
2219
2247
  }
2220
2248
  )
@@ -2234,10 +2262,12 @@ var LEGEND_WIDTHS = [58, 44, 66, 50, 38, 62, 46, 54];
2234
2262
  function AxisFrame({
2235
2263
  height,
2236
2264
  xTicks,
2237
- children
2265
+ children,
2266
+ className,
2267
+ testIdPrefix
2238
2268
  }) {
2239
2269
  const gutter = xTicks > 0 ? X_AXIS_H : 0;
2240
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "w-full", style: { height }, role: "presentation", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "relative h-full w-full", children: [
2270
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: cn("w-full", className), style: { height }, role: "presentation", "aria-hidden": "true", "data-testid": testIdPrefix, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "relative h-full w-full", children: [
2241
2271
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "absolute inset-y-0 right-0", style: { left: Y_AXIS_W, bottom: gutter }, children: [
2242
2272
  GRID_ROWS.map((pct) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2243
2273
  "div",
@@ -2294,8 +2324,8 @@ function BlankLegend({ rows, reverse = false }) {
2294
2324
  // src/BarChartPlaceholder.tsx
2295
2325
  var import_jsx_runtime18 = require("react/jsx-runtime");
2296
2326
  var BAR_PROFILE = [92, 86, 76, 65, 57, 40, 30, 24, 18, 13];
2297
- function BarChartPlaceholder({ height = 220 }) {
2298
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AxisFrame, { height, xTicks: BAR_PROFILE.length, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex h-full w-full items-end gap-2", children: BAR_PROFILE.map((pct, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex-1 rounded-t-small bg-subtle", style: { height: `${pct}%` } }, i)) }) });
2327
+ function BarChartPlaceholder({ height = 220, className, testIdPrefix }) {
2328
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AxisFrame, { height, xTicks: BAR_PROFILE.length, className, testIdPrefix, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex h-full w-full items-end gap-2", children: BAR_PROFILE.map((pct, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex-1 rounded-t-small bg-subtle", style: { height: `${pct}%` } }, i)) }) });
2299
2329
  }
2300
2330
 
2301
2331
  // src/LineChartPlaceholder.tsx
@@ -2307,9 +2337,9 @@ var LINE_SERIES = [
2307
2337
  [86, 82, 84, 77, 79, 71, 73, 66, 68, 61]
2308
2338
  ];
2309
2339
  var LINE_FORECAST_FROM = 7;
2310
- function LineChartPlaceholder({ height = 280 }) {
2340
+ function LineChartPlaceholder({ height = 280, className, testIdPrefix }) {
2311
2341
  const toPath = (pts, from, to) => pts.slice(from, to).map((y, i) => `${(i + from) / (pts.length - 1) * 100},${y}`).join(" ");
2312
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(AxisFrame, { height, xTicks: LINE_SERIES[0].length, children: [
2342
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(AxisFrame, { height, xTicks: LINE_SERIES[0].length, className, testIdPrefix, children: [
2313
2343
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { viewBox: "0 0 100 100", preserveAspectRatio: "none", className: "absolute inset-0 h-full w-full", children: LINE_SERIES.map((pts, s) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("g", { children: [
2314
2344
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2315
2345
  "polyline",
@@ -2357,9 +2387,9 @@ function LineChartPlaceholder({ height = 280 }) {
2357
2387
  // src/PieChartPlaceholder.tsx
2358
2388
  var import_jsx_runtime20 = require("react/jsx-runtime");
2359
2389
  var PIE_SEAMS = [0, 115, 180, 230, 262, 288, 310, 332];
2360
- function PieChartPlaceholder({ height = 220, legendRows = 8 }) {
2390
+ function PieChartPlaceholder({ height = 220, legendRows = 8, className, testIdPrefix }) {
2361
2391
  const r = 45;
2362
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex w-full items-center gap-3", style: { height }, role: "presentation", "aria-hidden": "true", children: [
2392
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: cn("flex w-full items-center gap-3", className), style: { height }, role: "presentation", "aria-hidden": "true", "data-testid": testIdPrefix, children: [
2363
2393
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex h-full items-center justify-center", style: { width: "60%" }, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("svg", { viewBox: "0 0 100 100", className: "h-full", style: { aspectRatio: "1 / 1" }, children: [
2364
2394
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("circle", { cx: "50", cy: "50", r, fill: "var(--mr-color-subtle)" }),
2365
2395
  PIE_SEAMS.map((deg) => {
@@ -2394,7 +2424,9 @@ function StackedColumnPlaceholder({
2394
2424
  height = 220,
2395
2425
  width = 96,
2396
2426
  legendRows = 4,
2397
- axis = false
2427
+ axis = false,
2428
+ className,
2429
+ testIdPrefix
2398
2430
  }) {
2399
2431
  const column = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex h-full flex-col overflow-hidden rounded-control bg-subtle", style: { width }, children: columnBands(legendRows).map((pct, i) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2400
2432
  "div",
@@ -2408,19 +2440,16 @@ function StackedColumnPlaceholder({
2408
2440
  },
2409
2441
  i
2410
2442
  )) });
2411
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex w-full gap-4", style: { height }, role: "presentation", "aria-hidden": "true", children: [
2443
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: cn("flex w-full gap-4", className), style: { height }, role: "presentation", "aria-hidden": "true", "data-testid": testIdPrefix, children: [
2412
2444
  axis ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { style: { width: "55%" }, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AxisFrame, { height, xTicks: 0, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex h-full items-stretch justify-center", children: column }) }) }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex items-stretch py-1", children: column }),
2413
2445
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(BlankLegend, { rows: legendRows, reverse: !axis })
2414
2446
  ] });
2415
2447
  }
2416
2448
 
2417
2449
  // src/Tooltip.tsx
2418
- var import_react10 = require("react");
2450
+ var import_react11 = require("react");
2419
2451
  var import_react_dom3 = require("react-dom");
2420
2452
  var import_jsx_runtime22 = require("react/jsx-runtime");
2421
- function cx6(...parts) {
2422
- return parts.filter(Boolean).join(" ");
2423
- }
2424
2453
  function addDescribedBy(el, id) {
2425
2454
  const ids = (el.getAttribute("aria-describedby") ?? "").split(" ").filter(Boolean);
2426
2455
  if (!ids.includes(id)) el.setAttribute("aria-describedby", [...ids, id].join(" "));
@@ -2456,18 +2485,18 @@ function Tooltip({
2456
2485
  variant = "surface",
2457
2486
  testIdPrefix
2458
2487
  }) {
2459
- const [anchor, setAnchor] = (0, import_react10.useState)(null);
2460
- const [boxWidth, setBoxWidth] = (0, import_react10.useState)(null);
2461
- const ref = (0, import_react10.useRef)(null);
2462
- const boxRef = (0, import_react10.useRef)(null);
2463
- const hideTimer = (0, import_react10.useRef)(null);
2464
- const showTimer = (0, import_react10.useRef)(null);
2465
- const exitTimer = (0, import_react10.useRef)(null);
2466
- const [shown, setShown] = (0, import_react10.useState)(false);
2467
- const openRef = (0, import_react10.useRef)(false);
2468
- const mountedRef = (0, import_react10.useRef)(false);
2469
- const id = (0, import_react10.useId)();
2470
- const describedRef = (0, import_react10.useRef)(null);
2488
+ const [anchor, setAnchor] = (0, import_react11.useState)(null);
2489
+ const [boxWidth, setBoxWidth] = (0, import_react11.useState)(null);
2490
+ const ref = (0, import_react11.useRef)(null);
2491
+ const boxRef = (0, import_react11.useRef)(null);
2492
+ const hideTimer = (0, import_react11.useRef)(null);
2493
+ const showTimer = (0, import_react11.useRef)(null);
2494
+ const exitTimer = (0, import_react11.useRef)(null);
2495
+ const [shown, setShown] = (0, import_react11.useState)(false);
2496
+ const openRef = (0, import_react11.useRef)(false);
2497
+ const mountedRef = (0, import_react11.useRef)(false);
2498
+ const id = (0, import_react11.useId)();
2499
+ const describedRef = (0, import_react11.useRef)(null);
2471
2500
  const clearHideTimer = () => {
2472
2501
  if (hideTimer.current) {
2473
2502
  clearTimeout(hideTimer.current);
@@ -2486,7 +2515,7 @@ function Tooltip({
2486
2515
  exitTimer.current = null;
2487
2516
  }
2488
2517
  };
2489
- (0, import_react10.useEffect)(
2518
+ (0, import_react11.useEffect)(
2490
2519
  () => () => {
2491
2520
  clearHideTimer();
2492
2521
  clearShowTimer();
@@ -2560,7 +2589,7 @@ function Tooltip({
2560
2589
  clearHideTimer();
2561
2590
  hideTimer.current = setTimeout(hideNow, 120);
2562
2591
  };
2563
- (0, import_react10.useEffect)(() => {
2592
+ (0, import_react11.useEffect)(() => {
2564
2593
  if (!anchorRef) return;
2565
2594
  const el = anchorRef.current;
2566
2595
  if (!el) return;
@@ -2575,13 +2604,13 @@ function Tooltip({
2575
2604
  el.removeEventListener("blur", hide);
2576
2605
  };
2577
2606
  }, [anchorRef, placement, delay]);
2578
- (0, import_react10.useEffect)(() => {
2607
+ (0, import_react11.useEffect)(() => {
2579
2608
  if (!anchor) return;
2580
2609
  const onKey = (e) => e.key === "Escape" && hideNow();
2581
2610
  window.addEventListener("keydown", onKey);
2582
2611
  return () => window.removeEventListener("keydown", onKey);
2583
2612
  }, [anchor]);
2584
- (0, import_react10.useLayoutEffect)(() => {
2613
+ (0, import_react11.useLayoutEffect)(() => {
2585
2614
  if (!anchor) return;
2586
2615
  const el = boxRef.current;
2587
2616
  if (!el) return;
@@ -2617,7 +2646,7 @@ function Tooltip({
2617
2646
  onMouseEnter: interactive ? keepOpen : void 0,
2618
2647
  onMouseLeave: interactive ? hide : void 0,
2619
2648
  onTransitionEnd: onBoxTransitionEnd,
2620
- className: cx6(
2649
+ className: cn(
2621
2650
  "fixed z-[90] w-max max-w-xs whitespace-normal break-words px-2.5 py-1.5 text-xs leading-snug",
2622
2651
  // Fade in/out. The sys duration token rather than a ref one:
2623
2652
  // it is what Button's hover/press transition uses, and a
@@ -2642,6 +2671,7 @@ function Tooltip({
2642
2671
  {
2643
2672
  ref,
2644
2673
  className,
2674
+ "data-testid": testIdPrefix,
2645
2675
  onMouseEnter: show,
2646
2676
  onMouseLeave: hide,
2647
2677
  onFocus: (e) => {
@@ -2661,9 +2691,11 @@ function Tooltip({
2661
2691
  var import_jsx_runtime23 = require("react/jsx-runtime");
2662
2692
  function AdvertiserNoResults({
2663
2693
  query,
2664
- hint = "Try checking your spelling or searching for a broader brand name."
2694
+ hint = "Try checking your spelling or searching for a broader brand name.",
2695
+ className,
2696
+ testIdPrefix
2665
2697
  }) {
2666
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-col items-center gap-1.5 px-4 py-8 text-center", children: [
2698
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: cn("flex flex-col items-center gap-1.5 px-4 py-8 text-center", className), "data-testid": testIdPrefix, children: [
2667
2699
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("p", { className: "text-dense font-medium text-text-primary", children: [
2668
2700
  "No results found for \u201C",
2669
2701
  query,
@@ -2676,14 +2708,17 @@ function AdvertiserNoResults({
2676
2708
  // src/SelectAllVisible.tsx
2677
2709
  var import_lucide_react13 = require("lucide-react");
2678
2710
  var import_jsx_runtime24 = require("react/jsx-runtime");
2679
- function SelectAllVisible({ count, allSelected, onToggle, testIdPrefix }) {
2711
+ function SelectAllVisible({ count, allSelected, onToggle, className, testIdPrefix }) {
2680
2712
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
2681
2713
  "button",
2682
2714
  {
2683
2715
  type: "button",
2684
2716
  "data-testid": testIdPrefix && `${testIdPrefix}-select-all-visible`,
2685
2717
  onClick: onToggle,
2686
- className: "flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-xs font-semibold text-text-link transition-colors hover:bg-subtle",
2718
+ className: cn(
2719
+ "flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-xs font-semibold text-text-link transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
2720
+ className
2721
+ ),
2687
2722
  children: [
2688
2723
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react13.ListChecks, { size: 14, "aria-hidden": "true" }),
2689
2724
  allSelected ? `Deselect ${count} visible` : `Select all ${count} visible`
@@ -2695,12 +2730,9 @@ function SelectAllVisible({ count, allSelected, onToggle, testIdPrefix }) {
2695
2730
  // src/SelectedSection.tsx
2696
2731
  var import_lucide_react14 = require("lucide-react");
2697
2732
  var import_jsx_runtime25 = require("react/jsx-runtime");
2698
- function cx7(...parts) {
2699
- return parts.filter(Boolean).join(" ");
2700
- }
2701
- function SelectedSection({ count, open, onToggle, children, testIdPrefix }) {
2733
+ function SelectedSection({ count, open, onToggle, children, className, testIdPrefix }) {
2702
2734
  if (count === 0) return null;
2703
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col", children: [
2735
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: cn("flex flex-col", className), "data-testid": testIdPrefix, children: [
2704
2736
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
2705
2737
  "button",
2706
2738
  {
@@ -2708,9 +2740,9 @@ function SelectedSection({ count, open, onToggle, children, testIdPrefix }) {
2708
2740
  "data-testid": testIdPrefix && `${testIdPrefix}-selected-toggle`,
2709
2741
  onClick: onToggle,
2710
2742
  "aria-expanded": open,
2711
- className: "flex w-full items-center gap-1.5 rounded-control px-2 py-1 text-left text-micro font-semibold uppercase tracking-wide text-text-tertiary transition-colors hover:text-text-primary",
2743
+ className: "flex w-full items-center gap-1.5 rounded-control px-2 py-1 text-left text-micro font-semibold uppercase tracking-wide text-text-tertiary transition-colors hover:text-text-primary focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
2712
2744
  children: [
2713
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react14.ChevronDown, { size: 13, "aria-hidden": "true", className: cx7("transition-transform", !open && "-rotate-90") }),
2745
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react14.ChevronDown, { size: 13, "aria-hidden": "true", className: cn("transition-transform", !open && "-rotate-90") }),
2714
2746
  "Selected (",
2715
2747
  count,
2716
2748
  ")"
@@ -2722,12 +2754,12 @@ function SelectedSection({ count, open, onToggle, children, testIdPrefix }) {
2722
2754
  }
2723
2755
 
2724
2756
  // src/SelectionPicker.tsx
2725
- var import_react12 = require("react");
2757
+ var import_react13 = require("react");
2726
2758
  var import_react_dom4 = require("react-dom");
2727
2759
  var import_lucide_react15 = require("lucide-react");
2728
2760
 
2729
2761
  // src/Tabs.tsx
2730
- var import_react11 = require("react");
2762
+ var import_react12 = require("react");
2731
2763
  var import_jsx_runtime26 = require("react/jsx-runtime");
2732
2764
  function arrowKeys(e, row) {
2733
2765
  if (!row || !["ArrowLeft", "ArrowRight", "Home", "End"].includes(e.key)) return;
@@ -2738,14 +2770,15 @@ function arrowKeys(e, row) {
2738
2770
  items[next]?.focus();
2739
2771
  items[next]?.click();
2740
2772
  }
2741
- function Tabs({ items, value, onChange, idPrefix = "tabs", className, ...rest }) {
2742
- const row = (0, import_react11.useRef)(null);
2773
+ function Tabs({ items, value, onChange, idPrefix = "tabs", className, testIdPrefix, ...rest }) {
2774
+ const row = (0, import_react12.useRef)(null);
2743
2775
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2744
2776
  "div",
2745
2777
  {
2746
2778
  ref: row,
2747
2779
  role: "tablist",
2748
2780
  "aria-label": rest["aria-label"],
2781
+ "data-testid": testIdPrefix,
2749
2782
  onKeyDown: (e) => arrowKeys(e, row.current),
2750
2783
  className: cn("flex gap-6 border-b border-border-default", className),
2751
2784
  children: items.map((item) => {
@@ -2756,6 +2789,7 @@ function Tabs({ items, value, onChange, idPrefix = "tabs", className, ...rest })
2756
2789
  type: "button",
2757
2790
  role: "tab",
2758
2791
  id: `${idPrefix}-tab-${item.value}`,
2792
+ "data-testid": testIdPrefix && `${testIdPrefix}-tab-${item.value}`,
2759
2793
  "aria-controls": `${idPrefix}-panel-${item.value}`,
2760
2794
  "aria-selected": on,
2761
2795
  tabIndex: on ? 0 : -1,
@@ -2782,15 +2816,17 @@ function SegmentedControl({
2782
2816
  onChange,
2783
2817
  size = "sm",
2784
2818
  className,
2819
+ testIdPrefix,
2785
2820
  ...rest
2786
2821
  }) {
2787
- const row = (0, import_react11.useRef)(null);
2822
+ const row = (0, import_react12.useRef)(null);
2788
2823
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2789
2824
  "div",
2790
2825
  {
2791
2826
  ref: row,
2792
2827
  role: "radiogroup",
2793
2828
  "aria-label": rest["aria-label"],
2829
+ "data-testid": testIdPrefix,
2794
2830
  onKeyDown: (e) => arrowKeys(e, row.current),
2795
2831
  className: cn("inline-flex w-fit items-stretch gap-0.5 rounded-full bg-subtle p-1", size === "md" ? "h-10" : "h-8", className),
2796
2832
  children: options.map((o) => {
@@ -2803,7 +2839,7 @@ function SegmentedControl({
2803
2839
  "aria-checked": on,
2804
2840
  tabIndex: on ? 0 : -1,
2805
2841
  onClick: () => onChange(o.value),
2806
- "data-testid": o.testId,
2842
+ "data-testid": o.testId ?? (testIdPrefix && `${testIdPrefix}-option-${o.value}`),
2807
2843
  className: cn(
2808
2844
  "rounded-full px-3 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-border-focus",
2809
2845
  size === "md" ? "text-sm" : "text-xs",
@@ -2820,9 +2856,6 @@ function SegmentedControl({
2820
2856
 
2821
2857
  // src/SelectionPicker.tsx
2822
2858
  var import_jsx_runtime27 = require("react/jsx-runtime");
2823
- function cx8(...parts) {
2824
- return parts.filter(Boolean).join(" ");
2825
- }
2826
2859
  function slug5(value) {
2827
2860
  return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
2828
2861
  }
@@ -2852,18 +2885,19 @@ function SelectionPicker({
2852
2885
  loadingMore = false,
2853
2886
  onLoadMore,
2854
2887
  toolbarExtra,
2888
+ className,
2855
2889
  testIdPrefix
2856
2890
  }) {
2857
2891
  const hasAccountLists = !!accountLists;
2858
- const [source, setSource] = (0, import_react12.useState)("search");
2859
- const [query, setQuery] = (0, import_react12.useState)("");
2860
- const [activeFilters, setActiveFilters] = (0, import_react12.useState)(() => {
2892
+ const [source, setSource] = (0, import_react13.useState)("search");
2893
+ const [query, setQuery] = (0, import_react13.useState)("");
2894
+ const [activeFilters, setActiveFilters] = (0, import_react13.useState)(() => {
2861
2895
  const init = {};
2862
2896
  if (defaultFilters) for (const [label, opts] of Object.entries(defaultFilters)) init[label] = new Set(opts);
2863
2897
  return init;
2864
2898
  });
2865
- const [expanded, setExpanded] = (0, import_react12.useState)(/* @__PURE__ */ new Set());
2866
- const selectedIds = (0, import_react12.useMemo)(() => new Set(selected.map((s) => s.id)), [selected]);
2899
+ const [expanded, setExpanded] = (0, import_react13.useState)(/* @__PURE__ */ new Set());
2900
+ const selectedIds = (0, import_react13.useMemo)(() => new Set(selected.map((s) => s.id)), [selected]);
2867
2901
  const toggleFilter = (label, opt) => {
2868
2902
  setActiveFilters((prev) => {
2869
2903
  const next = { ...prev };
@@ -2875,7 +2909,7 @@ function SelectionPicker({
2875
2909
  };
2876
2910
  const activeFilterCount = filters.reduce((n, f) => n + (activeFilters[f.label]?.size ?? 0), 0);
2877
2911
  const hasSearched = showResultsWithoutSearch || query.trim().length > 0 || !requireQuery && activeFilterCount > 0;
2878
- const filteredCatalog = (0, import_react12.useMemo)(() => {
2912
+ const filteredCatalog = (0, import_react13.useMemo)(() => {
2879
2913
  if (!hasSearched || results !== void 0) return [];
2880
2914
  const q = query.trim().toLowerCase();
2881
2915
  return catalog.filter((row) => {
@@ -2914,7 +2948,7 @@ function SelectionPicker({
2914
2948
  }
2915
2949
  };
2916
2950
  const rowGridCols = showInfoColumn ? "grid-cols-[36px_1fr_44px]" : "grid-cols-[36px_1fr]";
2917
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex flex-col gap-4", children: [
2951
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: cn("flex flex-col gap-4", className), "data-testid": testIdPrefix, children: [
2918
2952
  helper && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
2919
2953
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "text-dense text-text-secondary", children: helper }),
2920
2954
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("hr", { className: "-mx-5 -mt-2 border-border-default sm:-mx-6" })
@@ -2974,7 +3008,7 @@ function SelectionPicker({
2974
3008
  /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
2975
3009
  "div",
2976
3010
  {
2977
- className: cx8(
3011
+ className: cn(
2978
3012
  "grid items-center gap-2 border-b border-border-default bg-canvas px-3 py-2 text-micro font-semibold uppercase tracking-[0.06em] text-text-secondary",
2979
3013
  rowGridCols
2980
3014
  ),
@@ -2987,10 +3021,10 @@ function SelectionPicker({
2987
3021
  disabled: toggleable.length === 0,
2988
3022
  onChange: toggleAll,
2989
3023
  ariaLabel: "Select all",
2990
- testId: testIdPrefix && `${testIdPrefix}-select-all`
3024
+ testIdPrefix: testIdPrefix && `${testIdPrefix}-select-all`
2991
3025
  }
2992
3026
  ),
2993
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cx8("grid gap-2", gridForColumns(columns)), children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: c.className, children: c.header }, c.key)) }),
3027
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cn("grid gap-2", gridForColumns(columns)), children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: c.className, children: c.header }, c.key)) }),
2994
3028
  showInfoColumn && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "text-right", children: "Info" })
2995
3029
  ]
2996
3030
  }
@@ -3006,7 +3040,7 @@ function SelectionPicker({
3006
3040
  {
3007
3041
  onClick: isLocked ? void 0 : () => toggleRow(row),
3008
3042
  "aria-disabled": isLocked || void 0,
3009
- className: cx8(
3043
+ className: cn(
3010
3044
  "grid items-center gap-2 px-3 py-2.5",
3011
3045
  rowGridCols,
3012
3046
  isLocked ? "cursor-default opacity-50" : "cursor-pointer hover:bg-subtle",
@@ -3020,10 +3054,10 @@ function SelectionPicker({
3020
3054
  checked: isSel,
3021
3055
  onChange: () => toggleRow(row),
3022
3056
  ariaLabel: row.name,
3023
- testId: testIdPrefix && `${testIdPrefix}-row-${slug5(row.id)}`
3057
+ testIdPrefix: testIdPrefix && `${testIdPrefix}-row-${slug5(row.id)}`
3024
3058
  }
3025
3059
  ),
3026
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cx8("grid gap-2 text-dense text-text-primary", gridForColumns(columns)), children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: cx8("truncate", c.className), children: c.render(row) }, c.key)) }),
3060
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cn("grid gap-2 text-dense text-text-primary", gridForColumns(columns)), children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: cn("truncate", c.className), children: c.render(row) }, c.key)) }),
3027
3061
  showInfoColumn && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex items-center justify-end", children: kids && kids.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3028
3062
  "button",
3029
3063
  {
@@ -3037,8 +3071,8 @@ function SelectionPicker({
3037
3071
  return n;
3038
3072
  });
3039
3073
  },
3040
- className: "flex h-7 w-7 items-center justify-center rounded-control text-text-secondary hover:bg-canvas hover:text-text-primary",
3041
- children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react15.ChevronRight, { size: 15, className: cx8("transition-transform", isOpen && "rotate-90") })
3074
+ className: "flex h-7 w-7 items-center justify-center rounded-control text-text-secondary hover:bg-canvas hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
3075
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react15.ChevronRight, { size: 15, className: cn("transition-transform", isOpen && "rotate-90") })
3042
3076
  }
3043
3077
  ) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3044
3078
  "span",
@@ -3065,8 +3099,8 @@ function SelectionPicker({
3065
3099
  type: "button",
3066
3100
  disabled: kidSel,
3067
3101
  onClick: () => addRows([kid]),
3068
- className: cx8(
3069
- "inline-flex items-center gap-1 rounded-control px-2 py-1 text-xs font-medium",
3102
+ className: cn(
3103
+ "inline-flex items-center gap-1 rounded-control px-2 py-1 text-xs font-medium focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
3070
3104
  kidSel ? "text-text-tertiary" : "text-text-link hover:bg-subtle"
3071
3105
  ),
3072
3106
  children: [
@@ -3089,7 +3123,7 @@ function SelectionPicker({
3089
3123
  onClick: onLoadMore,
3090
3124
  disabled: loadingMore,
3091
3125
  "data-testid": testIdPrefix && `${testIdPrefix}-load-more`,
3092
- className: "flex w-full items-center justify-center gap-2 border-t border-border-default px-2 py-1.5 text-dense text-brand-primaryAction transition-colors hover:bg-subtle disabled:opacity-50",
3126
+ className: "flex w-full items-center justify-center gap-2 border-t border-border-default px-2 py-1.5 text-dense text-brand-primaryAction transition-colors hover:bg-subtle disabled:opacity-50 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
3093
3127
  children: [
3094
3128
  loadingMore ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react15.Loader2, { size: 13, className: "animate-spin", "aria-hidden": "true" }) : null,
3095
3129
  loadingMore ? "Loading\u2026" : "Load more"
@@ -3110,15 +3144,15 @@ function SelectionPicker({
3110
3144
  onClick: () => onToggleList?.(list.id),
3111
3145
  "aria-pressed": on,
3112
3146
  "data-testid": testIdPrefix && `${testIdPrefix}-list-${list.id}`,
3113
- className: cx8(
3114
- "flex items-center gap-3 rounded-control border px-3.5 py-3 text-left transition-colors",
3147
+ className: cn(
3148
+ "flex items-center gap-3 rounded-control border px-3.5 py-3 text-left transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
3115
3149
  on ? "border-brand-primaryAction bg-brand-primarySoft" : "border-border-default bg-surface hover:bg-subtle"
3116
3150
  ),
3117
3151
  children: [
3118
3152
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3119
3153
  "span",
3120
3154
  {
3121
- className: cx8(
3155
+ className: cn(
3122
3156
  "flex h-5 w-5 shrink-0 items-center justify-center rounded-full",
3123
3157
  on ? "text-brand-primaryAction" : "text-text-secondary"
3124
3158
  ),
@@ -3135,7 +3169,7 @@ function SelectionPicker({
3135
3169
  formatListDate(list.updatedAt)
3136
3170
  ] })
3137
3171
  ] }),
3138
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: cx8("shrink-0 text-xs font-medium", on ? "text-brand-primaryAction" : "text-text-secondary"), children: on ? "Added" : "Add" })
3172
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: cn("shrink-0 text-xs font-medium", on ? "text-brand-primaryAction" : "text-text-secondary"), children: on ? "Added" : "Add" })
3139
3173
  ]
3140
3174
  },
3141
3175
  list.id
@@ -3165,16 +3199,16 @@ function SelectionPicker({
3165
3199
  }
3166
3200
  var EDGE_FADE = 44;
3167
3201
  function ScrollFade({ className, children }) {
3168
- const elRef = (0, import_react12.useRef)(null);
3169
- const [edges, setEdges] = (0, import_react12.useState)({ top: false, bottom: false });
3170
- const sync = (0, import_react12.useCallback)(() => {
3202
+ const elRef = (0, import_react13.useRef)(null);
3203
+ const [edges, setEdges] = (0, import_react13.useState)({ top: false, bottom: false });
3204
+ const sync = (0, import_react13.useCallback)(() => {
3171
3205
  const el = elRef.current;
3172
3206
  if (!el) return;
3173
3207
  const top = el.scrollTop > 2;
3174
3208
  const bottom = el.scrollTop + el.clientHeight < el.scrollHeight - 2;
3175
3209
  setEdges((prev) => prev.top === top && prev.bottom === bottom ? prev : { top, bottom });
3176
3210
  }, []);
3177
- const attach = (0, import_react12.useCallback)(
3211
+ const attach = (0, import_react13.useCallback)(
3178
3212
  (el) => {
3179
3213
  elRef.current = el;
3180
3214
  if (!el) return;
@@ -3204,19 +3238,19 @@ function FilterDropdown({
3204
3238
  onToggle,
3205
3239
  testIdPrefix
3206
3240
  }) {
3207
- const [open, setOpen] = (0, import_react12.useState)(false);
3208
- const [q, setQ] = (0, import_react12.useState)("");
3209
- const btnRef = (0, import_react12.useRef)(null);
3210
- const menuRef = (0, import_react12.useRef)(null);
3211
- const [pos, setPos] = (0, import_react12.useState)(null);
3241
+ const [open, setOpen] = (0, import_react13.useState)(false);
3242
+ const [q, setQ] = (0, import_react13.useState)("");
3243
+ const btnRef = (0, import_react13.useRef)(null);
3244
+ const menuRef = (0, import_react13.useRef)(null);
3245
+ const [pos, setPos] = (0, import_react13.useState)(null);
3212
3246
  const searchable = filter.options.length > 8;
3213
3247
  const shownOptions = searchable && q.trim() ? filter.options.filter((o) => o.toLowerCase().includes(q.trim().toLowerCase())) : filter.options;
3214
- (0, import_react12.useLayoutEffect)(() => {
3248
+ (0, import_react13.useLayoutEffect)(() => {
3215
3249
  if (!open || !btnRef.current) return;
3216
3250
  const r = btnRef.current.getBoundingClientRect();
3217
3251
  setPos({ top: r.bottom + 6, left: r.left });
3218
3252
  }, [open]);
3219
- (0, import_react12.useEffect)(() => {
3253
+ (0, import_react13.useEffect)(() => {
3220
3254
  if (!open) {
3221
3255
  setQ("");
3222
3256
  return;
@@ -3248,10 +3282,10 @@ function FilterDropdown({
3248
3282
  onClick: () => setOpen((v) => !v),
3249
3283
  "aria-expanded": open,
3250
3284
  "data-testid": testIdPrefix && `${testIdPrefix}-filter-${filterSlug}`,
3251
- className: "inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-control border border-border-strong bg-input px-3 text-dense font-medium text-text-secondary transition-colors hover:bg-subtle",
3285
+ className: "inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-control border border-border-strong bg-input px-3 text-dense font-medium text-text-secondary transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
3252
3286
  children: [
3253
3287
  label,
3254
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react15.ChevronDown, { size: 13, "aria-hidden": "true", className: cx8("transition-transform", open && "rotate-180") })
3288
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react15.ChevronDown, { size: 13, "aria-hidden": "true", className: cn("transition-transform", open && "rotate-180") })
3255
3289
  ]
3256
3290
  }
3257
3291
  ),
@@ -3278,7 +3312,7 @@ function FilterDropdown({
3278
3312
  }
3279
3313
  )
3280
3314
  ] }),
3281
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cx8("flex flex-col gap-0.5", searchable && "max-h-60 overflow-y-auto"), children: shownOptions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "px-2 py-3 text-center text-xs text-text-secondary", children: "No matches." }) : shownOptions.map((opt) => {
3315
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cn("flex flex-col gap-0.5", searchable && "max-h-60 overflow-y-auto"), children: shownOptions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "px-2 py-3 text-center text-xs text-text-secondary", children: "No matches." }) : shownOptions.map((opt) => {
3282
3316
  const on = active.has(opt);
3283
3317
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
3284
3318
  "label",
@@ -3291,7 +3325,7 @@ function FilterDropdown({
3291
3325
  checked: on,
3292
3326
  onChange: () => onToggle(opt),
3293
3327
  ariaLabel: opt,
3294
- testId: testIdPrefix && `${testIdPrefix}-filter-${filterSlug}-${slug5(opt)}`
3328
+ testIdPrefix: testIdPrefix && `${testIdPrefix}-filter-${filterSlug}-${slug5(opt)}`
3295
3329
  }
3296
3330
  ),
3297
3331
  opt
@@ -3315,11 +3349,8 @@ function gridForColumns(columns) {
3315
3349
  }
3316
3350
 
3317
3351
  // src/PublisherBreakdownList.tsx
3318
- var import_react13 = require("react");
3352
+ var import_react14 = require("react");
3319
3353
  var import_jsx_runtime28 = require("react/jsx-runtime");
3320
- function cx9(...parts) {
3321
- return parts.filter(Boolean).join(" ");
3322
- }
3323
3354
  var fmtM = (v) => v >= 100 ? `$${Math.round(v)}M` : `$${v.toFixed(1)}M`;
3324
3355
  function priorYearAmt(spendN, yoy) {
3325
3356
  if (yoy === "NEW" || yoy <= -100) return null;
@@ -3361,7 +3392,7 @@ var COL_CURRENT = 76;
3361
3392
  var COL_PREVIOUS = 76;
3362
3393
  var COL_YOY = 44;
3363
3394
  function MetricListHeader({ className }) {
3364
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx9("flex items-baseline gap-2 pb-2", className), children: [
3395
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cn("flex items-baseline gap-2 pb-2", className), children: [
3365
3396
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "flex-1" }),
3366
3397
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "flex shrink-0 items-center gap-2 pr-1.5", children: [
3367
3398
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-right text-micro font-medium text-text-tertiary", style: { width: COL_CURRENT }, children: "Current" }),
@@ -3376,21 +3407,29 @@ function MetricCells({ spendN, yoy }) {
3376
3407
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "flex shrink-0 items-center gap-2 pr-1.5", children: [
3377
3408
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-right text-xs font-bold tabular-nums text-text-primary", style: { width: COL_CURRENT }, children: fmtM(spendN) }),
3378
3409
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-right text-xs font-normal tabular-nums text-text-primary", style: { width: COL_PREVIOUS }, children: prior ?? "\u2014" }),
3379
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "flex justify-end", style: { width: COL_YOY }, children: yoy === "NEW" ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "rounded-full bg-status-warning/15 px-1.5 text-badge font-semibold text-text-warning", children: "NEW" }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: cx9("text-right text-xs font-semibold tabular-nums", up ? "text-text-success" : "text-text-danger"), children: [
3410
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "flex justify-end", style: { width: COL_YOY }, children: yoy === "NEW" ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "rounded-full bg-status-warning/15 px-1.5 text-badge font-semibold text-text-warning", children: "NEW" }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: cn("text-right text-xs font-semibold tabular-nums", up ? "text-text-success" : "text-text-danger"), children: [
3380
3411
  up ? "+" : "\u2212",
3381
3412
  Math.abs(yoy),
3382
3413
  "%"
3383
3414
  ] }) })
3384
3415
  ] });
3385
3416
  }
3386
- function PublisherBreakdownList({ rows, defaultVisibleCount = 10, padded = true, viewAllHref, renderLogo }) {
3387
- const [showAll, setShowAll] = (0, import_react13.useState)(false);
3417
+ function PublisherBreakdownList({
3418
+ rows,
3419
+ defaultVisibleCount = 10,
3420
+ padded = true,
3421
+ viewAllHref,
3422
+ renderLogo,
3423
+ className,
3424
+ testIdPrefix
3425
+ }) {
3426
+ const [showAll, setShowAll] = (0, import_react14.useState)(false);
3388
3427
  const visible = showAll ? rows : rows.slice(0, defaultVisibleCount);
3389
3428
  const rowPad = padded ? "px-5" : "";
3390
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col", children: [
3429
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cn("flex flex-col", className), "data-testid": testIdPrefix, children: [
3391
3430
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col", children: [
3392
3431
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(MetricListHeader, { className: rowPad }),
3393
- visible.map((p) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx9("flex items-center justify-between gap-3 border-t border-border-default/60 py-2.5 first:border-t-0", rowPad), children: [
3432
+ visible.map((p) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cn("flex items-center justify-between gap-3 border-t border-border-default/60 py-2.5 first:border-t-0", rowPad), children: [
3394
3433
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex min-w-0 items-center gap-2.5", children: [
3395
3434
  renderLogo ? renderLogo(p) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Monogram, { name: p.brand, size: 28 }),
3396
3435
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "min-w-0", children: [
@@ -3398,30 +3437,30 @@ function PublisherBreakdownList({ rows, defaultVisibleCount = 10, padded = true,
3398
3437
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-sm font-semibold text-text-primary", children: p.brand }),
3399
3438
  p.tags.map((t) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(BreakdownTag, { children: t }, t))
3400
3439
  ] }),
3401
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "truncate text-[11.5px] text-text-tertiary", children: p.owner })
3440
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "truncate text-micro text-text-tertiary", children: p.owner })
3402
3441
  ] })
3403
3442
  ] }),
3404
3443
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(MetricCells, { spendN: p.spendN, yoy: p.yoy })
3405
3444
  ] }, p.brand))
3406
3445
  ] }),
3407
- rows.length > defaultVisibleCount && (viewAllHref ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cx9("border-t border-border-default py-3", rowPad), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { href: viewAllHref, className: "text-xs font-semibold text-text-link hover:underline", children: "See all publishers" }) }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx9("flex items-center gap-2 border-t border-border-default py-3 text-xs text-text-tertiary", rowPad), children: [
3446
+ rows.length > defaultVisibleCount && (viewAllHref ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cn("border-t border-border-default py-3", rowPad), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { href: viewAllHref, className: "text-xs font-semibold text-text-link hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", children: "See all publishers" }) }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cn("flex items-center gap-2 border-t border-border-default py-3 text-xs text-text-tertiary", rowPad), children: [
3408
3447
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { children: [
3409
3448
  "Showing ",
3410
3449
  visible.length,
3411
3450
  " of ",
3412
3451
  rows.length
3413
3452
  ] }),
3414
- !showAll ? /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("button", { type: "button", onClick: () => setShowAll(true), className: "font-semibold text-text-link hover:underline", children: [
3453
+ !showAll ? /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("button", { type: "button", onClick: () => setShowAll(true), className: "font-semibold text-text-link hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", children: [
3415
3454
  "See all (",
3416
3455
  rows.length - defaultVisibleCount,
3417
3456
  " more)"
3418
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("button", { type: "button", onClick: () => setShowAll(false), className: "font-semibold text-text-link hover:underline", children: "Show less" })
3457
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("button", { type: "button", onClick: () => setShowAll(false), className: "font-semibold text-text-link hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", children: "Show less" })
3419
3458
  ] }))
3420
3459
  ] });
3421
3460
  }
3422
3461
 
3423
3462
  // src/Button.tsx
3424
- var import_react14 = require("react");
3463
+ var import_react15 = require("react");
3425
3464
  var import_react_slot = require("@radix-ui/react-slot");
3426
3465
  var import_class_variance_authority = require("class-variance-authority");
3427
3466
  var import_lucide_react16 = require("lucide-react");
@@ -3486,10 +3525,11 @@ var buttonVariants = (0, import_class_variance_authority.cva)(
3486
3525
  }
3487
3526
  }
3488
3527
  );
3489
- var Button = (0, import_react14.forwardRef)(
3490
- ({ className, variant, size, iconOnly, asChild = false, loading = false, disabled, children, ...props }, ref) => {
3528
+ var Button = (0, import_react15.forwardRef)(
3529
+ ({ className, testIdPrefix, variant, size, iconOnly, asChild = false, loading = false, disabled, children, ...props }, ref) => {
3491
3530
  const shared = {
3492
3531
  className: cn(buttonVariants({ variant, size, iconOnly, className })),
3532
+ "data-testid": testIdPrefix,
3493
3533
  disabled: disabled || loading,
3494
3534
  "aria-busy": loading || void 0,
3495
3535
  ...props
@@ -3511,15 +3551,19 @@ function FilterDropdownFooter({
3511
3551
  onClear,
3512
3552
  onApply,
3513
3553
  clearLabel = "Clear all",
3514
- applyLabel = "Apply"
3554
+ applyLabel = "Apply",
3555
+ className,
3556
+ testIdPrefix
3515
3557
  }) {
3516
3558
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
3517
3559
  "div",
3518
3560
  {
3519
3561
  className: cn(
3520
3562
  "flex items-center gap-2 border-t border-border-default p-2",
3521
- onClear ? "justify-between" : "justify-end"
3563
+ onClear ? "justify-between" : "justify-end",
3564
+ className
3522
3565
  ),
3566
+ "data-testid": testIdPrefix,
3523
3567
  children: [
3524
3568
  onClear && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Button, { type: "button", variant: "ghost", size: "sm", onClick: onClear, children: clearLabel }),
3525
3569
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Button, { type: "button", variant: "primary", size: "sm", onClick: onApply, children: applyLabel })
@@ -3529,7 +3573,7 @@ function FilterDropdownFooter({
3529
3573
  }
3530
3574
 
3531
3575
  // src/NameListModal.tsx
3532
- var import_react15 = require("react");
3576
+ var import_react16 = require("react");
3533
3577
  var import_react_dom5 = require("react-dom");
3534
3578
  var import_jsx_runtime31 = require("react/jsx-runtime");
3535
3579
  function NameListModal({
@@ -3540,23 +3584,25 @@ function NameListModal({
3540
3584
  onSubmit,
3541
3585
  fieldLabel = "List name",
3542
3586
  placeholder = "e.g. Q4 prospecting targets",
3543
- options
3587
+ options,
3588
+ className,
3589
+ testIdPrefix
3544
3590
  }) {
3545
- const [name, setName] = (0, import_react15.useState)(initialName);
3546
- const [checked, setChecked] = (0, import_react15.useState)(
3591
+ const [name, setName] = (0, import_react16.useState)(initialName);
3592
+ const [checked, setChecked] = (0, import_react16.useState)(
3547
3593
  () => Object.fromEntries((options ?? []).map((o) => [o.key, !!o.initial]))
3548
3594
  );
3549
3595
  const toggle = (key) => setChecked((c) => ({ ...c, [key]: !c[key] }));
3550
- const dialogRef = (0, import_react15.useRef)(null);
3551
- const titleId = (0, import_react15.useId)();
3552
- const fieldId = (0, import_react15.useId)();
3553
- (0, import_react15.useEffect)(() => {
3596
+ const dialogRef = (0, import_react16.useRef)(null);
3597
+ const titleId = (0, import_react16.useId)();
3598
+ const fieldId = (0, import_react16.useId)();
3599
+ (0, import_react16.useEffect)(() => {
3554
3600
  const onKey = (e) => e.key === "Escape" && onCancel();
3555
3601
  window.addEventListener("keydown", onKey);
3556
3602
  return () => window.removeEventListener("keydown", onKey);
3557
3603
  }, [onCancel]);
3558
- const [opener] = (0, import_react15.useState)(() => typeof document === "undefined" ? null : document.activeElement);
3559
- (0, import_react15.useEffect)(
3604
+ const [opener] = (0, import_react16.useState)(() => typeof document === "undefined" ? null : document.activeElement);
3605
+ (0, import_react16.useEffect)(
3560
3606
  () => () => {
3561
3607
  const active = document.activeElement;
3562
3608
  if (!active || active === document.body) opener?.focus?.();
@@ -3596,7 +3642,8 @@ function NameListModal({
3596
3642
  "aria-modal": "true",
3597
3643
  "aria-labelledby": titleId,
3598
3644
  onKeyDown: trapTab,
3599
- className: "w-full max-w-110 rounded-card border border-border-default bg-surface p-5 shadow-overlay",
3645
+ "data-testid": testIdPrefix,
3646
+ className: cn("w-full max-w-110 rounded-card border border-border-default bg-surface p-5 shadow-overlay", className),
3600
3647
  children: [
3601
3648
  /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("h2", { id: titleId, className: "text-base font-semibold text-text-primary", children: title }),
3602
3649
  /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "mt-4 flex flex-col gap-1.5", children: [
@@ -3633,9 +3680,9 @@ function NameListModal({
3633
3680
  // src/FilterChipBar.tsx
3634
3681
  var import_lucide_react17 = require("lucide-react");
3635
3682
  var import_jsx_runtime32 = require("react/jsx-runtime");
3636
- function FilterChipBar({ chips, onRemove, onClearAll, parkedKeys }) {
3683
+ function FilterChipBar({ chips, onRemove, onClearAll, parkedKeys, className, testIdPrefix }) {
3637
3684
  if (chips.length === 0) return null;
3638
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-wrap items-center gap-1.5 border-t border-border-default pt-2.5", children: [
3685
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: cn("flex flex-wrap items-center gap-1.5 border-t border-border-default pt-2.5", className), "data-testid": testIdPrefix, children: [
3639
3686
  chips.map((c) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3640
3687
  Chip,
3641
3688
  {
@@ -3646,7 +3693,15 @@ function FilterChipBar({ chips, onRemove, onClearAll, parkedKeys }) {
3646
3693
  },
3647
3694
  c.key
3648
3695
  )),
3649
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("button", { type: "button", onClick: onClearAll, className: "ml-1 text-xs font-medium text-text-link hover:underline", children: "Clear all" })
3696
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3697
+ "button",
3698
+ {
3699
+ type: "button",
3700
+ onClick: onClearAll,
3701
+ className: "ml-1 rounded-small text-xs font-medium text-text-link hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
3702
+ children: "Clear all"
3703
+ }
3704
+ )
3650
3705
  ] });
3651
3706
  }
3652
3707
  function Chip({
@@ -3676,7 +3731,7 @@ function Chip({
3676
3731
  type: "button",
3677
3732
  onClick: onRemove,
3678
3733
  "aria-label": `Remove ${groupLabel}: ${label}`,
3679
- className: "text-text-tertiary transition-colors hover:text-text-primary",
3734
+ className: "rounded-full text-text-tertiary transition-colors hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
3680
3735
  children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react17.X, { size: 12 })
3681
3736
  }
3682
3737
  )
@@ -3695,6 +3750,7 @@ function Chip({
3695
3750
  }
3696
3751
 
3697
3752
  // src/SortButton.tsx
3753
+ var import_react17 = require("react");
3698
3754
  var import_lucide_react18 = require("lucide-react");
3699
3755
  var import_jsx_runtime33 = require("react/jsx-runtime");
3700
3756
  var ALIGN = {
@@ -3702,59 +3758,65 @@ var ALIGN = {
3702
3758
  center: "justify-center text-center",
3703
3759
  right: "justify-end text-right"
3704
3760
  };
3705
- function SortButton({
3706
- label,
3707
- sortKey,
3708
- sort,
3709
- onSort,
3710
- disabled = false,
3711
- sortable = true,
3712
- align = "left",
3713
- testIdPrefix
3714
- }) {
3715
- if (!sortable) return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: cn("inline-flex", ALIGN[align]), children: label });
3716
- const active = !disabled && sort.key === sortKey;
3717
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
3718
- "button",
3719
- {
3720
- type: "button",
3721
- disabled,
3722
- onClick: () => onSort(sortKey),
3723
- "data-testid": testIdPrefix && `${testIdPrefix}-sort-${sortKey}`,
3724
- className: cn(
3725
- // ALIGN's text-* overrides the UA default on <button>, which would centre a
3726
- // label that wraps onto two lines, out of step with the column under it.
3727
- // `uppercase` is NOT this control imposing a treatment -- it is
3728
- // restoring one. Every table header row sets uppercase on the <tr>,
3729
- // and a <button> does not inherit text-transform from its parent
3730
- // (measured: the <th> computes `uppercase`, the button inside it
3731
- // computes `none`), so without this a sortable label renders
3732
- // sentence case beside caps neighbours in the same band.
3733
- //
3734
- // Letter-spacing DOES inherit, which is why no tracking is set here.
3735
- // This control used to set its own `tracking-wide` while every
3736
- // header row sets `tracking-wider`, so sortable labels rendered
3737
- // subtly tighter than the fixed headers next to them. A control
3738
- // should carry exactly the properties that do not inherit, and
3739
- // nothing more.
3740
- "group inline-flex items-center gap-1 uppercase transition-colors focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
3741
- ALIGN[align],
3742
- !disabled && "hover:text-text-primary"
3743
- ),
3744
- children: [
3745
- label,
3746
- !disabled && (active ? sort.dir === "asc" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_lucide_react18.ArrowUp, { size: 12, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_lucide_react18.ArrowDown, { size: 12, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3747
- import_lucide_react18.ArrowUpDown,
3748
- {
3749
- size: 12,
3750
- "aria-hidden": "true",
3751
- className: "shrink-0 text-text-tertiary opacity-50 transition-opacity group-hover:opacity-100"
3752
- }
3753
- ))
3754
- ]
3755
- }
3756
- );
3757
- }
3761
+ var SortButton = (0, import_react17.forwardRef)(
3762
+ function SortButton2({
3763
+ label,
3764
+ sortKey,
3765
+ sort,
3766
+ onSort,
3767
+ disabled = false,
3768
+ sortable = true,
3769
+ align = "left",
3770
+ className,
3771
+ testIdPrefix
3772
+ }, ref) {
3773
+ if (!sortable) return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: cn("inline-flex", ALIGN[align], className), children: label });
3774
+ const active = !disabled && sort.key === sortKey;
3775
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
3776
+ "button",
3777
+ {
3778
+ ref,
3779
+ type: "button",
3780
+ disabled,
3781
+ onClick: () => onSort(sortKey),
3782
+ "data-testid": testIdPrefix && `${testIdPrefix}-sort-${sortKey}`,
3783
+ className: cn(
3784
+ // ALIGN's text-* overrides the UA default on <button>, which would centre a
3785
+ // label that wraps onto two lines, out of step with the column under it.
3786
+ // `uppercase` is NOT this control imposing a treatment -- it is
3787
+ // restoring one. Every table header row sets uppercase on the <tr>,
3788
+ // and a <button> does not inherit text-transform from its parent
3789
+ // (measured: the <th> computes `uppercase`, the button inside it
3790
+ // computes `none`), so without this a sortable label renders
3791
+ // sentence case beside caps neighbours in the same band.
3792
+ //
3793
+ // Letter-spacing DOES inherit, which is why no tracking is set here.
3794
+ // This control used to set its own `tracking-wide` while every
3795
+ // header row sets `tracking-wider`, so sortable labels rendered
3796
+ // subtly tighter than the fixed headers next to them. A control
3797
+ // should carry exactly the properties that do not inherit, and
3798
+ // nothing more.
3799
+ "group inline-flex items-center gap-1 uppercase transition-colors focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
3800
+ ALIGN[align],
3801
+ !disabled && "hover:text-text-primary",
3802
+ className
3803
+ ),
3804
+ children: [
3805
+ label,
3806
+ !disabled && (active ? sort.dir === "asc" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_lucide_react18.ArrowUp, { size: 12, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_lucide_react18.ArrowDown, { size: 12, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3807
+ import_lucide_react18.ArrowUpDown,
3808
+ {
3809
+ size: 12,
3810
+ "aria-hidden": "true",
3811
+ className: "shrink-0 text-text-tertiary opacity-50 transition-opacity group-hover:opacity-100"
3812
+ }
3813
+ ))
3814
+ ]
3815
+ }
3816
+ );
3817
+ }
3818
+ );
3819
+ SortButton.displayName = "SortButton";
3758
3820
 
3759
3821
  // src/tableSort.ts
3760
3822
  function cycleSort(current, key, firstDir = "desc") {
@@ -3786,9 +3848,9 @@ function pageWindow(current, total) {
3786
3848
  }
3787
3849
  return out;
3788
3850
  }
3789
- function Pager({ page, totalPages, onPage, disabled = false, label = "Pagination" }) {
3790
- const btn = "flex h-8 min-w-8 items-center justify-center rounded-control px-2 text-dense transition-colors disabled:pointer-events-none disabled:opacity-30";
3791
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("nav", { "aria-label": label, className: "flex items-center gap-1", children: [
3851
+ function Pager({ page, totalPages, onPage, disabled = false, label = "Pagination", className, testIdPrefix }) {
3852
+ const btn = "flex h-8 min-w-8 items-center justify-center rounded-control px-2 text-dense transition-colors disabled:pointer-events-none disabled:opacity-30 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus";
3853
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("nav", { "aria-label": label, className: cn("flex items-center gap-1", className), "data-testid": testIdPrefix, children: [
3792
3854
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3793
3855
  "button",
3794
3856
  {
@@ -3850,22 +3912,24 @@ var SIZES = {
3850
3912
  md: "h-7 w-7 text-micro",
3851
3913
  lg: "h-11 w-11 text-panel-title"
3852
3914
  };
3853
- function WorkspaceAvatar({ name, size = "md" }) {
3915
+ function WorkspaceAvatar({ name, size = "md", className, testIdPrefix }) {
3854
3916
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3855
3917
  "span",
3856
3918
  {
3857
3919
  "aria-hidden": "true",
3858
3920
  className: cn(
3859
3921
  "flex shrink-0 items-center justify-center rounded-control bg-subtle font-semibold leading-none text-text-secondary",
3860
- SIZES[size]
3922
+ SIZES[size],
3923
+ className
3861
3924
  ),
3925
+ "data-testid": testIdPrefix,
3862
3926
  children: size === "xs" ? workspaceInitials(name ?? "All data").slice(0, 1) : workspaceInitials(name ?? "All data")
3863
3927
  }
3864
3928
  );
3865
3929
  }
3866
3930
 
3867
3931
  // src/Toast.tsx
3868
- var import_react16 = require("react");
3932
+ var import_react18 = require("react");
3869
3933
  var import_react_dom6 = require("react-dom");
3870
3934
  var import_lucide_react20 = require("lucide-react");
3871
3935
  var import_jsx_runtime36 = require("react/jsx-runtime");
@@ -3874,11 +3938,11 @@ var ICON = {
3874
3938
  success: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react20.Check, { size: 15, className: "shrink-0", "aria-hidden": "true" }),
3875
3939
  warning: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react20.AlertTriangle, { size: 15, className: "shrink-0", "aria-hidden": "true" })
3876
3940
  };
3877
- function Toast({ message, action, onClose, tone = "neutral", duration, className }) {
3941
+ function Toast({ message, action, onClose, tone = "neutral", duration, className, testIdPrefix }) {
3878
3942
  const ms = duration ?? (action ? 1e4 : 5e3);
3879
- const [paused, setPaused] = (0, import_react16.useState)(false);
3880
- const closed = (0, import_react16.useRef)(false);
3881
- (0, import_react16.useEffect)(() => {
3943
+ const [paused, setPaused] = (0, import_react18.useState)(false);
3944
+ const closed = (0, import_react18.useRef)(false);
3945
+ (0, import_react18.useEffect)(() => {
3882
3946
  if (paused) return;
3883
3947
  const t = window.setTimeout(() => {
3884
3948
  if (closed.current) return;
@@ -3893,6 +3957,7 @@ function Toast({ message, action, onClose, tone = "neutral", duration, className
3893
3957
  {
3894
3958
  role: "status",
3895
3959
  "aria-live": "polite",
3960
+ "data-testid": testIdPrefix,
3896
3961
  onMouseEnter: () => setPaused(true),
3897
3962
  onMouseLeave: () => setPaused(false),
3898
3963
  onFocusCapture: () => setPaused(true),
@@ -3939,8 +4004,8 @@ function Toast({ message, action, onClose, tone = "neutral", duration, className
3939
4004
 
3940
4005
  // src/Tag.tsx
3941
4006
  var import_jsx_runtime37 = require("react/jsx-runtime");
3942
- function Tag({ children, className }) {
3943
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Badge, { kind: "category", className, children });
4007
+ function Tag({ children, className, testIdPrefix }) {
4008
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Badge, { kind: "category", className, testIdPrefix, children });
3944
4009
  }
3945
4010
 
3946
4011
  // src/TablePagination.tsx
@@ -3962,7 +4027,7 @@ function TablePagination({
3962
4027
  const current = Math.min(page, totalPages);
3963
4028
  const rangeStart = totalItems === 0 ? 0 : (current - 1) * perPage + 1;
3964
4029
  const rangeEnd = Math.min(current * perPage, totalItems);
3965
- const btn = "flex h-8 min-w-8 items-center justify-center rounded-control px-2 text-dense transition-colors";
4030
+ const btn = "flex h-8 min-w-8 items-center justify-center rounded-control px-2 text-dense transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus";
3966
4031
  const off = "disabled:pointer-events-none disabled:opacity-30";
3967
4032
  const stepBtn = cn(btn, "text-text-secondary hover:bg-subtle hover:text-text-primary", off);
3968
4033
  const range = /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("span", { className: "text-dense text-text-tertiary tabular-nums", children: [
@@ -4070,7 +4135,7 @@ function TablePagination({
4070
4135
  }
4071
4136
 
4072
4137
  // src/DateRangePicker.tsx
4073
- var import_react17 = require("react");
4138
+ var import_react19 = require("react");
4074
4139
  var import_lucide_react22 = require("lucide-react");
4075
4140
  var import_jsx_runtime39 = require("react/jsx-runtime");
4076
4141
  var MONTH_ABBR = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
@@ -4134,21 +4199,23 @@ function DateRangePicker({
4134
4199
  today,
4135
4200
  years,
4136
4201
  formatDate,
4137
- formatRange
4202
+ formatRange,
4203
+ className,
4204
+ testIdPrefix
4138
4205
  }) {
4139
- const end = (0, import_react17.useMemo)(() => today ?? startOfToday(), [today]);
4206
+ const end = (0, import_react19.useMemo)(() => today ?? startOfToday(), [today]);
4140
4207
  const yearOptions = years ?? [3, 2, 1, 0].map((n) => end.getFullYear() - n);
4141
- const [open, setOpen] = (0, import_react17.useState)(false);
4142
- const [value, setValue] = (0, import_react17.useState)(defaultValue);
4143
- const [draft, setDraft] = (0, import_react17.useState)(defaultValue);
4144
- const ref = (0, import_react17.useRef)(null);
4145
- const [fromMo, setFromMo] = (0, import_react17.useState)(end.getMonth());
4146
- const [fromYr, setFromYr] = (0, import_react17.useState)(end.getFullYear() - 1);
4147
- const [toMo, setToMo] = (0, import_react17.useState)(end.getMonth());
4148
- const [toYr, setToYr] = (0, import_react17.useState)(end.getFullYear());
4149
- const [fromQ, setFromQ] = (0, import_react17.useState)(Math.floor(end.getMonth() / 3));
4150
- const [toQ, setToQ] = (0, import_react17.useState)(Math.floor(end.getMonth() / 3));
4151
- (0, import_react17.useEffect)(() => {
4208
+ const [open, setOpen] = (0, import_react19.useState)(false);
4209
+ const [value, setValue] = (0, import_react19.useState)(defaultValue);
4210
+ const [draft, setDraft] = (0, import_react19.useState)(defaultValue);
4211
+ const ref = (0, import_react19.useRef)(null);
4212
+ const [fromMo, setFromMo] = (0, import_react19.useState)(end.getMonth());
4213
+ const [fromYr, setFromYr] = (0, import_react19.useState)(end.getFullYear() - 1);
4214
+ const [toMo, setToMo] = (0, import_react19.useState)(end.getMonth());
4215
+ const [toYr, setToYr] = (0, import_react19.useState)(end.getFullYear());
4216
+ const [fromQ, setFromQ] = (0, import_react19.useState)(Math.floor(end.getMonth() / 3));
4217
+ const [toQ, setToQ] = (0, import_react19.useState)(Math.floor(end.getMonth() / 3));
4218
+ (0, import_react19.useEffect)(() => {
4152
4219
  const [s, e] = resolveRange(value, end);
4153
4220
  onRangeChange?.(s, e);
4154
4221
  }, [value]);
@@ -4156,7 +4223,7 @@ function DateRangePicker({
4156
4223
  if (!open) setDraft(value);
4157
4224
  setOpen((o) => !o);
4158
4225
  };
4159
- (0, import_react17.useEffect)(() => {
4226
+ (0, import_react19.useEffect)(() => {
4160
4227
  if (!open) return;
4161
4228
  const onDown = (e) => {
4162
4229
  if (ref.current && !ref.current.contains(e.target)) setOpen(false);
@@ -4182,7 +4249,7 @@ function DateRangePicker({
4182
4249
  if (showFooter) setDraft(label);
4183
4250
  else commit(label);
4184
4251
  };
4185
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "relative", ref, children: [
4252
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: cn("relative", className), ref, "data-testid": testIdPrefix, children: [
4186
4253
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
4187
4254
  "button",
4188
4255
  {
@@ -4206,7 +4273,7 @@ function DateRangePicker({
4206
4273
  {
4207
4274
  type: "button",
4208
4275
  onClick: () => showFooter ? setDraft(p) : commit(p),
4209
- className: cn("block w-full px-3 py-2 text-left text-dense transition-colors hover:bg-subtle", (showFooter ? draft : value) === p ? "font-semibold text-brand-primaryAction" : "text-text-secondary"),
4276
+ className: cn("block w-full px-3 py-2 text-left text-dense transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus", (showFooter ? draft : value) === p ? "font-semibold text-brand-primaryAction" : "text-text-secondary"),
4210
4277
  children: p
4211
4278
  },
4212
4279
  p
@@ -4236,7 +4303,7 @@ function DateRangePicker({
4236
4303
  type: "button",
4237
4304
  onClick: applyCustom,
4238
4305
  disabled: !valid,
4239
- className: "self-start text-dense font-semibold text-brand-primaryAction transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-40",
4306
+ className: "self-start text-dense font-semibold text-brand-primaryAction transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-40 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
4240
4307
  children: showFooter ? "Use custom range" : "Apply"
4241
4308
  }
4242
4309
  )
@@ -4248,7 +4315,7 @@ function DateRangePicker({
4248
4315
  }
4249
4316
 
4250
4317
  // src/MultiSelectFilter.tsx
4251
- var import_react18 = require("react");
4318
+ var import_react20 = require("react");
4252
4319
  var import_lucide_react23 = require("lucide-react");
4253
4320
  var import_jsx_runtime40 = require("react/jsx-runtime");
4254
4321
  function MultiSelectFilter({
@@ -4276,15 +4343,17 @@ function MultiSelectFilter({
4276
4343
  onRetry,
4277
4344
  valueLabel,
4278
4345
  hints,
4279
- note
4346
+ note,
4347
+ className,
4348
+ testIdPrefix
4280
4349
  }) {
4281
4350
  const groupLeaves = (g) => g.children.length ? g.children : [{ id: g.id, label: g.label }];
4282
4351
  const leafOptions = groups ? groups.flatMap(groupLeaves) : options;
4283
- const [open, setOpen] = (0, import_react18.useState)(false);
4284
- const [q, setQ] = (0, import_react18.useState)("");
4285
- const [draft, setDraft] = (0, import_react18.useState)(selected);
4286
- const ref = (0, import_react18.useRef)(null);
4287
- const close = (0, import_react18.useCallback)(() => {
4352
+ const [open, setOpen] = (0, import_react20.useState)(false);
4353
+ const [q, setQ] = (0, import_react20.useState)("");
4354
+ const [draft, setDraft] = (0, import_react20.useState)(selected);
4355
+ const ref = (0, import_react20.useRef)(null);
4356
+ const close = (0, import_react20.useCallback)(() => {
4288
4357
  setOpen(false);
4289
4358
  setQ("");
4290
4359
  if (showFooter) return;
@@ -4301,7 +4370,7 @@ function MultiSelectFilter({
4301
4370
  setOpen(false);
4302
4371
  setQ("");
4303
4372
  };
4304
- (0, import_react18.useEffect)(() => {
4373
+ (0, import_react20.useEffect)(() => {
4305
4374
  if (!open) return;
4306
4375
  const onKey = (e) => e.key === "Escape" && close();
4307
4376
  const onClick = (e) => {
@@ -4351,13 +4420,14 @@ function MultiSelectFilter({
4351
4420
  const kids = live.filter((c) => c.label.toLowerCase().includes(ql));
4352
4421
  return kids.length ? { ...g, children: kids } : null;
4353
4422
  }).filter((g) => g !== null) : [];
4354
- return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: cn("relative", fullWidth && "w-full"), ref, children: [
4423
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: cn("relative", fullWidth && "w-full", className), ref, "data-testid": testIdPrefix, children: [
4355
4424
  /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
4356
4425
  "button",
4357
4426
  {
4358
4427
  type: "button",
4359
4428
  onClick: () => open ? close() : openTray(),
4360
4429
  "aria-expanded": open,
4430
+ "data-testid": testIdPrefix && `${testIdPrefix}-trigger`,
4361
4431
  className: cn(chipTriggerClass(variant), fullWidth && "w-full justify-between"),
4362
4432
  children: [
4363
4433
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ChipContent, { caption, value, icon }),
@@ -4380,6 +4450,7 @@ function MultiSelectFilter({
4380
4450
  menuWidthClass,
4381
4451
  align === "right" ? "right-0" : "left-0"
4382
4452
  ),
4453
+ "data-testid": testIdPrefix && `${testIdPrefix}-popover`,
4383
4454
  role: "dialog",
4384
4455
  "aria-label": caption,
4385
4456
  children: loading ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(MenuLoading, {}) : error ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(MenuError, { onRetry }) : /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
@@ -4395,7 +4466,7 @@ function MultiSelectFilter({
4395
4466
  className: "h-full flex-1 bg-transparent text-dense outline-hidden placeholder:text-text-tertiary"
4396
4467
  }
4397
4468
  ),
4398
- q && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("button", { type: "button", onClick: () => setQ(""), "aria-label": "Clear search", className: "text-text-tertiary hover:text-text-primary", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_lucide_react23.X, { size: 13 }) })
4469
+ q && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("button", { type: "button", onClick: () => setQ(""), "aria-label": "Clear search", className: "text-text-tertiary hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_lucide_react23.X, { size: 13 }) })
4399
4470
  ] }) }),
4400
4471
  /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "max-h-[280px] overflow-y-auto p-1", children: [
4401
4472
  groups ? visibleGroups.map((g) => {
@@ -4406,7 +4477,7 @@ function MultiSelectFilter({
4406
4477
  {
4407
4478
  type: "button",
4408
4479
  onClick: () => toggleGroup(g),
4409
- className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle",
4480
+ className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
4410
4481
  children: [
4411
4482
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CheckBoxBox, { checked: state === "all", indeterminate: state === "some" }),
4412
4483
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: cn("flex-1 text-sm text-text-primary", !plainParent && "font-semibold"), children: labelled(g.id, g.label) }),
@@ -4421,7 +4492,7 @@ function MultiSelectFilter({
4421
4492
  {
4422
4493
  type: "button",
4423
4494
  onClick: () => toggle(c.id),
4424
- className: "flex w-full items-center gap-2.5 rounded-control py-2 pl-9 pr-2 text-left transition-colors hover:bg-subtle",
4495
+ className: "flex w-full items-center gap-2.5 rounded-control py-2 pl-9 pr-2 text-left transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
4425
4496
  children: [
4426
4497
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CheckBoxBox, { checked }),
4427
4498
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "flex-1 text-sm text-text-primary", children: labelled(c.id, c.label) }),
@@ -4439,7 +4510,7 @@ function MultiSelectFilter({
4439
4510
  {
4440
4511
  type: "button",
4441
4512
  onClick: () => toggle(o.id),
4442
- className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle",
4513
+ className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
4443
4514
  children: [
4444
4515
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CheckBoxBox, { checked }),
4445
4516
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "flex-1 text-sm text-text-primary", children: labelled(o.id, o.label) }),
@@ -4457,7 +4528,7 @@ function MultiSelectFilter({
4457
4528
  {
4458
4529
  type: "button",
4459
4530
  onClick: () => setDraft([]),
4460
- className: "text-xs font-medium text-text-link hover:underline",
4531
+ className: "text-xs font-medium text-text-link hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
4461
4532
  children: [
4462
4533
  "Clear ",
4463
4534
  caption.toLowerCase()
@@ -4478,17 +4549,19 @@ function OptionCount({ n }) {
4478
4549
  }
4479
4550
 
4480
4551
  // src/Toggle.tsx
4552
+ var import_react21 = require("react");
4481
4553
  var import_jsx_runtime41 = require("react/jsx-runtime");
4482
4554
  var SIZES2 = {
4483
4555
  sm: { track: "h-5 w-9", knob: "h-4 w-4", on: "translate-x-[18px]" },
4484
4556
  md: { track: "h-6 w-11", knob: "h-5 w-5", on: "translate-x-[22px]" }
4485
4557
  };
4486
4558
  var OFF_TRACK = "color-mix(in srgb, var(--mr-color-border-interactive) 70%, var(--mr-color-text-secondary))";
4487
- function Toggle({ checked, onChange, label, size = "md", disabled, className, testIdPrefix }) {
4559
+ var Toggle = (0, import_react21.forwardRef)(function Toggle2({ checked, onChange, label, size = "md", disabled, className, testIdPrefix }, ref) {
4488
4560
  const s = SIZES2[size];
4489
4561
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4490
4562
  "button",
4491
4563
  {
4564
+ ref,
4492
4565
  type: "button",
4493
4566
  role: "switch",
4494
4567
  "aria-checked": checked,
@@ -4516,20 +4589,21 @@ function Toggle({ checked, onChange, label, size = "md", disabled, className, te
4516
4589
  )
4517
4590
  }
4518
4591
  );
4519
- }
4592
+ });
4593
+ Toggle.displayName = "Toggle";
4520
4594
 
4521
4595
  // src/AISpark.tsx
4522
- var import_react19 = require("react");
4596
+ var import_react22 = require("react");
4523
4597
  var import_lucide_react24 = require("lucide-react");
4524
4598
  var import_jsx_runtime42 = require("react/jsx-runtime");
4525
- function AISpark({ size = 16, className }) {
4526
- const id = (0, import_react19.useId)();
4599
+ function AISpark({ size = 16, className, testIdPrefix }) {
4600
+ const id = (0, import_react22.useId)();
4527
4601
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
4528
4602
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("svg", { width: "0", height: "0", "aria-hidden": "true", style: { position: "absolute" }, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("linearGradient", { id, x1: "0", y1: "0", x2: "1", y2: "1", children: [
4529
4603
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("stop", { offset: "0%", stopColor: "var(--mr-color-brand-primary)" }),
4530
4604
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("stop", { offset: "100%", className: "[stop-color:#9474ff] in-data-[theme=dark]:[stop-color:#a488ff]" })
4531
4605
  ] }) }) }),
4532
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_lucide_react24.Sparkles, { size, stroke: `url(#${id})`, className, "aria-hidden": "true" })
4606
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_lucide_react24.Sparkles, { size, stroke: `url(#${id})`, className, "data-testid": testIdPrefix, "aria-hidden": "true" })
4533
4607
  ] });
4534
4608
  }
4535
4609
 
@@ -4545,11 +4619,12 @@ var srLabel = {
4545
4619
  recent: "Recent (today)",
4546
4620
  stale: "Older than a day"
4547
4621
  };
4548
- function Freshness({ level }) {
4622
+ function Freshness({ level, className, testIdPrefix }) {
4549
4623
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4550
4624
  "span",
4551
4625
  {
4552
- className: cn("inline-block h-1.5 w-1.5 shrink-0 rounded-full", dotColor[level]),
4626
+ className: cn("inline-block h-1.5 w-1.5 shrink-0 rounded-full", dotColor[level], className),
4627
+ "data-testid": testIdPrefix,
4553
4628
  role: "img",
4554
4629
  "aria-label": srLabel[level]
4555
4630
  }
@@ -4558,8 +4633,8 @@ function Freshness({ level }) {
4558
4633
 
4559
4634
  // src/SectionHeading.tsx
4560
4635
  var import_jsx_runtime44 = require("react/jsx-runtime");
4561
- function SectionHeading({ title, description, actions, as: Tag2 = "h2", id, className }) {
4562
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: cn("flex flex-wrap items-end justify-between gap-x-4 gap-y-2", className), children: [
4636
+ function SectionHeading({ title, description, actions, as: Tag2 = "h2", id, className, testIdPrefix }) {
4637
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: cn("flex flex-wrap items-end justify-between gap-x-4 gap-y-2", className), "data-testid": testIdPrefix, children: [
4563
4638
  /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "min-w-0", children: [
4564
4639
  /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Tag2, { id, className: "text-base font-semibold text-text-primary", children: title }),
4565
4640
  description && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "mt-0.5 text-dense text-text-secondary", children: description })
@@ -4571,8 +4646,8 @@ function SectionHeading({ title, description, actions, as: Tag2 = "h2", id, clas
4571
4646
  // src/PageHeader.tsx
4572
4647
  var import_lucide_react25 = require("lucide-react");
4573
4648
  var import_jsx_runtime45 = require("react/jsx-runtime");
4574
- function PageHeader({ title, description, actions, meta, back, className }) {
4575
- return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("header", { className: cn("flex flex-wrap items-center justify-between gap-x-6 gap-y-3", className), children: [
4649
+ function PageHeader({ title, description, actions, meta, back, className, testIdPrefix }) {
4650
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("header", { className: cn("flex flex-wrap items-center justify-between gap-x-6 gap-y-3", className), "data-testid": testIdPrefix, children: [
4576
4651
  /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "min-w-0", children: [
4577
4652
  back && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
4578
4653
  "a",
@@ -4597,7 +4672,7 @@ function PageHeader({ title, description, actions, meta, back, className }) {
4597
4672
  }
4598
4673
 
4599
4674
  // src/Modal.tsx
4600
- var import_react20 = require("react");
4675
+ var import_react23 = require("react");
4601
4676
  var import_react_dom7 = require("react-dom");
4602
4677
  var import_lucide_react26 = require("lucide-react");
4603
4678
  var import_jsx_runtime46 = require("react/jsx-runtime");
@@ -4610,13 +4685,13 @@ var WIDTH = {
4610
4685
  xl: "max-w-300"
4611
4686
  };
4612
4687
  var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
4613
- function Modal({ open, onClose, title, description, size = "md", footer, children, className }) {
4614
- const titleId = (0, import_react20.useId)();
4615
- const descId = (0, import_react20.useId)();
4616
- const panel = (0, import_react20.useRef)(null);
4617
- const close = (0, import_react20.useRef)(onClose);
4688
+ function Modal({ open, onClose, title, description, size = "md", footer, children, className, testIdPrefix }) {
4689
+ const titleId = (0, import_react23.useId)();
4690
+ const descId = (0, import_react23.useId)();
4691
+ const panel = (0, import_react23.useRef)(null);
4692
+ const close = (0, import_react23.useRef)(onClose);
4618
4693
  close.current = onClose;
4619
- (0, import_react20.useEffect)(() => {
4694
+ (0, import_react23.useEffect)(() => {
4620
4695
  if (!open) return;
4621
4696
  const opener = document.activeElement;
4622
4697
  const firstIn = (region) => panel.current?.querySelector(region)?.querySelector(FOCUSABLE) ?? null;
@@ -4662,6 +4737,7 @@ function Modal({ open, onClose, title, description, size = "md", footer, childre
4662
4737
  ref: panel,
4663
4738
  role: "dialog",
4664
4739
  "aria-modal": "true",
4740
+ "data-testid": testIdPrefix,
4665
4741
  "aria-labelledby": titleId,
4666
4742
  "aria-describedby": description ? descId : void 0,
4667
4743
  tabIndex: -1,
@@ -4700,7 +4776,7 @@ function Modal({ open, onClose, title, description, size = "md", footer, childre
4700
4776
 
4701
4777
  // src/EmptyState.tsx
4702
4778
  var import_jsx_runtime47 = require("react/jsx-runtime");
4703
- function EmptyState({ icon, title, description, action, size = "sm", className }) {
4779
+ function EmptyState({ icon, title, description, action, size = "sm", className, testIdPrefix }) {
4704
4780
  const md = size === "md";
4705
4781
  return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
4706
4782
  "div",
@@ -4710,6 +4786,7 @@ function EmptyState({ icon, title, description, action, size = "sm", className }
4710
4786
  md ? "gap-2 px-6 py-16" : "gap-1.5 px-4 py-8",
4711
4787
  className
4712
4788
  ),
4789
+ "data-testid": testIdPrefix,
4713
4790
  children: [
4714
4791
  icon && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
4715
4792
  "span",
@@ -4731,16 +4808,16 @@ function EmptyState({ icon, title, description, action, size = "sm", className }
4731
4808
  }
4732
4809
 
4733
4810
  // src/TextField.tsx
4734
- var import_react21 = require("react");
4811
+ var import_react24 = require("react");
4735
4812
  var import_jsx_runtime48 = require("react/jsx-runtime");
4736
4813
  var HEIGHT2 = { sm: "h-8", md: "h-10", lg: "h-11" };
4737
- var TextField = (0, import_react21.forwardRef)(
4738
- ({ label, hint, error, size = "md", icon, className, id, disabled, ...props }, ref) => {
4739
- const auto = (0, import_react21.useId)();
4814
+ var TextField = (0, import_react24.forwardRef)(
4815
+ ({ label, hint, error, size = "md", icon, className, testIdPrefix, id, disabled, ...props }, ref) => {
4816
+ const auto = (0, import_react24.useId)();
4740
4817
  const fieldId = id ?? auto;
4741
4818
  const noteId = `${fieldId}-note`;
4742
4819
  const note = error ?? hint;
4743
- return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: cn("flex flex-col gap-1.5", className), children: [
4820
+ return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: cn("flex flex-col gap-1.5", className), "data-testid": testIdPrefix, children: [
4744
4821
  label && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("label", { htmlFor: fieldId, className: "text-xs font-medium text-text-secondary", children: label }),
4745
4822
  /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
4746
4823
  "div",
@@ -4775,7 +4852,7 @@ var TextField = (0, import_react21.forwardRef)(
4775
4852
  TextField.displayName = "TextField";
4776
4853
 
4777
4854
  // src/Drawer.tsx
4778
- var import_react22 = require("react");
4855
+ var import_react25 = require("react");
4779
4856
  var import_react_dom8 = require("react-dom");
4780
4857
  var import_lucide_react27 = require("lucide-react");
4781
4858
  var import_jsx_runtime49 = require("react/jsx-runtime");
@@ -4786,15 +4863,15 @@ var WIDTH2 = {
4786
4863
  };
4787
4864
  var EXIT_MS = 200;
4788
4865
  var FOCUSABLE2 = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
4789
- function Drawer({ open, onClose, title, description, size = "sm", footer, children, className }) {
4790
- const titleId = (0, import_react22.useId)();
4791
- const descId = (0, import_react22.useId)();
4792
- const panel = (0, import_react22.useRef)(null);
4793
- const close = (0, import_react22.useRef)(onClose);
4866
+ function Drawer({ open, onClose, title, description, size = "sm", footer, children, className, testIdPrefix }) {
4867
+ const titleId = (0, import_react25.useId)();
4868
+ const descId = (0, import_react25.useId)();
4869
+ const panel = (0, import_react25.useRef)(null);
4870
+ const close = (0, import_react25.useRef)(onClose);
4794
4871
  close.current = onClose;
4795
- const [mounted, setMounted] = (0, import_react22.useState)(open);
4796
- const [shown, setShown] = (0, import_react22.useState)(false);
4797
- (0, import_react22.useEffect)(() => {
4872
+ const [mounted, setMounted] = (0, import_react25.useState)(open);
4873
+ const [shown, setShown] = (0, import_react25.useState)(false);
4874
+ (0, import_react25.useEffect)(() => {
4798
4875
  if (open) {
4799
4876
  setMounted(true);
4800
4877
  const raf = requestAnimationFrame(() => requestAnimationFrame(() => setShown(true)));
@@ -4804,7 +4881,7 @@ function Drawer({ open, onClose, title, description, size = "sm", footer, childr
4804
4881
  const t = setTimeout(() => setMounted(false), EXIT_MS);
4805
4882
  return () => clearTimeout(t);
4806
4883
  }, [open]);
4807
- (0, import_react22.useEffect)(() => {
4884
+ (0, import_react25.useEffect)(() => {
4808
4885
  if (!open || !mounted) return;
4809
4886
  const opener = document.activeElement;
4810
4887
  const firstIn = (region) => panel.current?.querySelector(region)?.querySelector(FOCUSABLE2) ?? null;
@@ -4860,6 +4937,7 @@ function Drawer({ open, onClose, title, description, size = "sm", footer, childr
4860
4937
  ref: panel,
4861
4938
  role: "dialog",
4862
4939
  "aria-modal": "true",
4940
+ "data-testid": testIdPrefix,
4863
4941
  "aria-labelledby": titleId,
4864
4942
  "aria-describedby": description ? descId : void 0,
4865
4943
  tabIndex: -1,
@@ -4897,7 +4975,7 @@ function Drawer({ open, onClose, title, description, size = "sm", footer, childr
4897
4975
  }
4898
4976
 
4899
4977
  // src/DataTable.tsx
4900
- var import_react23 = require("react");
4978
+ var import_react26 = require("react");
4901
4979
  var import_jsx_runtime50 = require("react/jsx-runtime");
4902
4980
  var WIDTH3 = { fill: "", sm: "w-24", md: "w-36", lg: "w-48" };
4903
4981
  var MAX_H = { sm: "max-h-80", md: "max-h-120", lg: "max-h-160" };
@@ -4919,9 +4997,10 @@ function DataTable({
4919
4997
  maxHeight,
4920
4998
  footer,
4921
4999
  className,
5000
+ testIdPrefix,
4922
5001
  ...rest
4923
5002
  }) {
4924
- const titleId = (0, import_react23.useId)();
5003
+ const titleId = (0, import_react26.useId)();
4925
5004
  const head = HEAD_PAD[density];
4926
5005
  const pad = CELL_PAD[density];
4927
5006
  const align = (c) => c.numeric ? "text-right" : "text-left";
@@ -4930,62 +5009,70 @@ function DataTable({
4930
5009
  const col = columns.find((c) => c.key === key);
4931
5010
  onSortChange?.(cycleSort(sort, key, col?.firstDir ?? (col?.numeric ? "desc" : "asc")));
4932
5011
  };
4933
- 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: [
4934
- title && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
4935
- /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "min-w-0", children: [
4936
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("h3", { id: titleId, className: "text-style-card-title", children: title }),
4937
- subtitle && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("p", { className: "mt-0.5 text-xs text-text-tertiary", children: subtitle })
4938
- ] }),
4939
- action && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "shrink-0", children: action })
4940
- ] }),
4941
- /* @__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)(
4942
- "table",
4943
- {
4944
- "aria-labelledby": title ? titleId : void 0,
4945
- "aria-label": title ? void 0 : rest["aria-label"],
4946
- "aria-busy": loading || void 0,
4947
- className: "w-full border-collapse text-left",
4948
- children: [
4949
- /* @__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)(
4950
- "th",
4951
- {
4952
- scope: "col",
4953
- "aria-sort": c.sortable ? ariaSortFor(sort, c.key) : void 0,
4954
- className: cn("border-b border-border-default font-semibold", head, align(c), width(c)),
4955
- children: c.sortable && onSortChange ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
4956
- SortButton,
5012
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
5013
+ "div",
5014
+ {
5015
+ className: cn("flex w-full flex-col overflow-hidden rounded-card border border-border-default bg-surface", className),
5016
+ "data-testid": testIdPrefix,
5017
+ children: [
5018
+ title && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
5019
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "min-w-0", children: [
5020
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("h3", { id: titleId, className: "text-style-card-title", children: title }),
5021
+ subtitle && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("p", { className: "mt-0.5 text-xs text-text-tertiary", children: subtitle })
5022
+ ] }),
5023
+ action && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "shrink-0", children: action })
5024
+ ] }),
5025
+ /* @__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)(
5026
+ "table",
5027
+ {
5028
+ "aria-labelledby": title ? titleId : void 0,
5029
+ "aria-label": title ? void 0 : rest["aria-label"],
5030
+ "aria-busy": loading || void 0,
5031
+ className: "w-full border-collapse text-left",
5032
+ children: [
5033
+ /* @__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)(
5034
+ "th",
5035
+ {
5036
+ scope: "col",
5037
+ "aria-sort": c.sortable ? ariaSortFor(sort, c.key) : void 0,
5038
+ className: cn("border-b border-border-default font-semibold", head, align(c), width(c)),
5039
+ children: c.sortable && onSortChange ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5040
+ SortButton,
5041
+ {
5042
+ label: c.label,
5043
+ sortKey: c.key,
5044
+ align: c.numeric ? "right" : "left",
5045
+ sort: sortProp(sort),
5046
+ onSort,
5047
+ testIdPrefix
5048
+ }
5049
+ ) : c.label
5050
+ },
5051
+ c.key
5052
+ )) }) }),
5053
+ /* @__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)(
5054
+ "span",
4957
5055
  {
4958
- label: c.label,
4959
- sortKey: c.key,
4960
- align: c.numeric ? "right" : "left",
4961
- sort: sortProp(sort),
4962
- onSort
5056
+ className: cn(
5057
+ "inline-block h-3 animate-pulse rounded-full bg-subtle",
5058
+ c.numeric ? "w-12" : "w-2/3"
5059
+ )
4963
5060
  }
4964
- ) : c.label
4965
- },
4966
- c.key
4967
- )) }) }),
4968
- /* @__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)(
4969
- "span",
4970
- {
4971
- className: cn(
4972
- "inline-block h-3 animate-pulse rounded-full bg-subtle",
4973
- c.numeric ? "w-12" : "w-2/3"
4974
- )
4975
- }
4976
- ) }, 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)(
4977
- "td",
4978
- {
4979
- className: cn("border-b border-border-default", pad, align(c), c.numeric && "tabular-nums"),
4980
- children: c.cell(row)
4981
- },
4982
- c.key
4983
- )) }, rowKey(row))) })
4984
- ]
4985
- }
4986
- ) }),
4987
- footer && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "border-t border-border-default px-4 py-3", children: footer })
4988
- ] });
5061
+ ) }, 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)(
5062
+ "td",
5063
+ {
5064
+ className: cn("border-b border-border-default", pad, align(c), c.numeric && "tabular-nums"),
5065
+ children: c.cell(row)
5066
+ },
5067
+ c.key
5068
+ )) }, rowKey(row))) })
5069
+ ]
5070
+ }
5071
+ ) }),
5072
+ footer && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "border-t border-border-default px-4 py-3", children: footer })
5073
+ ]
5074
+ }
5075
+ );
4989
5076
  }
4990
5077
 
4991
5078
  // src/MediaLabel.tsx
@@ -4999,7 +5086,7 @@ var FILL = {
4999
5086
  Newspaper: "bg-media-newspaper",
5000
5087
  Magazine: "bg-media-magazine"
5001
5088
  };
5002
- function MediaLabel({ type, className }) {
5089
+ function MediaLabel({ type, className, testIdPrefix }) {
5003
5090
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
5004
5091
  "span",
5005
5092
  {
@@ -5008,18 +5095,22 @@ function MediaLabel({ type, className }) {
5008
5095
  FILL[type] ?? "bg-media-other",
5009
5096
  className
5010
5097
  ),
5098
+ "data-testid": testIdPrefix,
5011
5099
  children: type
5012
5100
  }
5013
5101
  );
5014
5102
  }
5015
5103
 
5016
5104
  // src/SuggestionChip.tsx
5105
+ var import_react27 = require("react");
5017
5106
  var import_jsx_runtime52 = require("react/jsx-runtime");
5018
- function SuggestionChip({ children, className, type = "button", ...props }) {
5107
+ var SuggestionChip = (0, import_react27.forwardRef)(function SuggestionChip2({ children, className, testIdPrefix, type = "button", ...props }, ref) {
5019
5108
  return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
5020
5109
  "button",
5021
5110
  {
5111
+ ref,
5022
5112
  type,
5113
+ "data-testid": testIdPrefix,
5023
5114
  ...props,
5024
5115
  className: cn(
5025
5116
  "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",
@@ -5028,17 +5119,21 @@ function SuggestionChip({ children, className, type = "button", ...props }) {
5028
5119
  children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "truncate", children })
5029
5120
  }
5030
5121
  );
5031
- }
5122
+ });
5123
+ SuggestionChip.displayName = "SuggestionChip";
5032
5124
 
5033
5125
  // src/ToggleChip.tsx
5126
+ var import_react28 = require("react");
5034
5127
  var import_lucide_react28 = require("lucide-react");
5035
5128
  var import_jsx_runtime53 = require("react/jsx-runtime");
5036
- function ToggleChip({ selected, onChange, children, className, type = "button", onClick, ...props }) {
5129
+ var ToggleChip = (0, import_react28.forwardRef)(function ToggleChip2({ selected, onChange, children, className, testIdPrefix, type = "button", onClick, ...props }, ref) {
5037
5130
  return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
5038
5131
  "button",
5039
5132
  {
5133
+ ref,
5040
5134
  type,
5041
5135
  "aria-pressed": selected,
5136
+ "data-testid": testIdPrefix,
5042
5137
  ...props,
5043
5138
  onClick: (e) => {
5044
5139
  onClick?.(e);
@@ -5055,17 +5150,18 @@ function ToggleChip({ selected, onChange, children, className, type = "button",
5055
5150
  ]
5056
5151
  }
5057
5152
  );
5058
- }
5153
+ });
5154
+ ToggleChip.displayName = "ToggleChip";
5059
5155
 
5060
5156
  // src/CopyButton.tsx
5061
- var import_react24 = require("react");
5157
+ var import_react29 = require("react");
5062
5158
  var import_lucide_react29 = require("lucide-react");
5063
5159
  var import_jsx_runtime54 = require("react/jsx-runtime");
5064
5160
  var CONFIRM_MS = 2e3;
5065
- function CopyButton({ value, label, "aria-label": ariaLabel, size = "xs", className }) {
5066
- const [copied, setCopied] = (0, import_react24.useState)(false);
5067
- const timer = (0, import_react24.useRef)(void 0);
5068
- (0, import_react24.useEffect)(() => () => clearTimeout(timer.current), []);
5161
+ var CopyButton = (0, import_react29.forwardRef)(function CopyButton2({ value, label, "aria-label": ariaLabel, size = "xs", className, testIdPrefix }, ref) {
5162
+ const [copied, setCopied] = (0, import_react29.useState)(false);
5163
+ const timer = (0, import_react29.useRef)(void 0);
5164
+ (0, import_react29.useEffect)(() => () => clearTimeout(timer.current), []);
5069
5165
  const copy = async () => {
5070
5166
  try {
5071
5167
  await navigator.clipboard.writeText(typeof value === "function" ? value() : value);
@@ -5081,7 +5177,9 @@ function CopyButton({ value, label, "aria-label": ariaLabel, size = "xs", classN
5081
5177
  return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
5082
5178
  Button,
5083
5179
  {
5180
+ ref,
5084
5181
  type: "button",
5182
+ "data-testid": testIdPrefix,
5085
5183
  variant: "ghost",
5086
5184
  size,
5087
5185
  iconOnly: !label,
@@ -5095,7 +5193,8 @@ function CopyButton({ value, label, "aria-label": ariaLabel, size = "xs", classN
5095
5193
  ]
5096
5194
  }
5097
5195
  );
5098
- }
5196
+ });
5197
+ CopyButton.displayName = "CopyButton";
5099
5198
 
5100
5199
  // src/InlineMessage.tsx
5101
5200
  var import_lucide_react30 = require("lucide-react");
@@ -5114,13 +5213,14 @@ var ICON_INK = {
5114
5213
  danger: "text-text-danger"
5115
5214
  };
5116
5215
  var ICON2 = { info: import_lucide_react30.Info, success: import_lucide_react30.CheckCircle2, warning: import_lucide_react30.AlertTriangle, danger: import_lucide_react30.XCircle };
5117
- function InlineMessage({ tone = "info", title, children, actions, onDismiss, className }) {
5216
+ function InlineMessage({ tone = "info", title, children, actions, onDismiss, className, testIdPrefix }) {
5118
5217
  const Icon = ICON2[tone];
5119
5218
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
5120
5219
  "div",
5121
5220
  {
5122
5221
  role: tone === "warning" || tone === "danger" ? "alert" : "status",
5123
5222
  className: cn("flex items-start gap-2.5 rounded-control border px-3 py-2.5 text-sm", BOX[tone], className),
5223
+ "data-testid": testIdPrefix,
5124
5224
  children: [
5125
5225
  /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Icon, { size: 16, "aria-hidden": "true", className: cn("mt-0.5 shrink-0", ICON_INK[tone]) }),
5126
5226
  /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "min-w-0 flex-1", children: [