@mediaradar/design-components 0.63.0 → 0.64.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
@@ -92,6 +92,7 @@ __export(index_exports, {
92
92
  StatStrip: () => StatStrip,
93
93
  StatStripSkeleton: () => StatStripSkeleton,
94
94
  StatTile: () => StatTile,
95
+ StickyBar: () => StickyBar,
95
96
  SuggestionChip: () => SuggestionChip,
96
97
  TableLink: () => TableLink,
97
98
  TablePagination: () => TablePagination,
@@ -4891,6 +4892,9 @@ function MultiSelectFilter({
4891
4892
  valueLabel,
4892
4893
  hints,
4893
4894
  note,
4895
+ hideCaption = false,
4896
+ max,
4897
+ maxReason,
4894
4898
  className,
4895
4899
  testIdPrefix
4896
4900
  }) {
@@ -4937,9 +4941,12 @@ function MultiSelectFilter({
4937
4941
  window.removeEventListener("mousedown", onClick);
4938
4942
  };
4939
4943
  }, [open, close]);
4944
+ const capReason = maxReason ?? `Up to ${max}. Untick one to add another.`;
4945
+ const overCap = (n) => max !== void 0 && n > max;
4940
4946
  const toggle = (id) => setDraft((cur) => {
4941
4947
  const next = cur.includes(id) ? cur.filter((x) => x !== id) : [...cur, id];
4942
4948
  if (next.length < min) return cur;
4949
+ if (!cur.includes(id) && overCap(next.length)) return cur;
4943
4950
  return next;
4944
4951
  });
4945
4952
  const toggleGroup = (g) => setDraft((cur) => {
@@ -4948,8 +4955,40 @@ function MultiSelectFilter({
4948
4955
  const allSel = ids.every((id) => cur.includes(id));
4949
4956
  const next = allSel ? cur.filter((id) => !ids.includes(id)) : [.../* @__PURE__ */ new Set([...cur, ...ids])];
4950
4957
  if (next.length < min) return cur;
4958
+ if (!allSel && overCap(next.length)) return cur;
4951
4959
  return next;
4952
4960
  });
4961
+ const blockedLeaf = (id) => !draft.includes(id) && overCap(draft.length + 1) ? capReason : null;
4962
+ const blockedGroup = (g) => {
4963
+ if (max === void 0) return null;
4964
+ const ids = groupLeaves(g).map((c) => c.id).filter((id) => !counts || (counts[id] ?? 0) > 0 || draft.includes(id));
4965
+ if (!ids.length || ids.every((id) => draft.includes(id))) return null;
4966
+ return overCap((/* @__PURE__ */ new Set([...draft, ...ids])).size) ? capReason : null;
4967
+ };
4968
+ const row = (opts) => {
4969
+ const button = /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
4970
+ "button",
4971
+ {
4972
+ type: "button",
4973
+ role: "checkbox",
4974
+ "aria-checked": opts.indeterminate ? "mixed" : opts.checked,
4975
+ "aria-disabled": opts.blocked ? "true" : void 0,
4976
+ onClick: opts.blocked ? void 0 : opts.onClick,
4977
+ className: cn(
4978
+ "flex w-full items-center gap-2.5 rounded-control py-2 text-left transition-colors focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
4979
+ opts.indent ? "pl-9 pr-2" : "px-2",
4980
+ opts.blocked ? "cursor-not-allowed" : "hover:bg-subtle"
4981
+ ),
4982
+ children: [
4983
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CheckBoxBox, { checked: opts.checked, indeterminate: opts.indeterminate, disabled: !!opts.blocked }),
4984
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: cn("flex-1 text-sm", opts.blocked ? "text-text-tertiary" : "text-text-primary", opts.bold && "font-semibold"), children: opts.label }),
4985
+ opts.count
4986
+ ]
4987
+ },
4988
+ opts.key
4989
+ );
4990
+ return opts.blocked ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Tooltip, { label: opts.blocked, delay: 300, className: "flex w-full", children: button }, opts.key) : button;
4991
+ };
4953
4992
  const isAvailable = (id) => !counts || (counts[id] ?? 0) > 0 || draft.includes(id);
4954
4993
  const countFor = (id) => counts?.[id] ?? 0;
4955
4994
  const groupState = (g) => {
@@ -4981,10 +5020,17 @@ function MultiSelectFilter({
4981
5020
  type: "button",
4982
5021
  onClick: () => open ? close() : openTray(),
4983
5022
  "aria-expanded": open,
5023
+ "aria-label": hideCaption ? caption : void 0,
4984
5024
  "data-testid": testIdPrefix && `${testIdPrefix}-trigger`,
4985
- className: cn(chipTriggerClass(variant), fullWidth && "w-full justify-between"),
5025
+ className: cn(
5026
+ hideCaption ? "flex h-10 items-center gap-2 rounded-control border border-border-strong bg-input pl-3 pr-2.5 text-sm font-medium text-text-primary transition-colors hover:bg-subtle focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-border-focus" : chipTriggerClass(variant),
5027
+ fullWidth && "w-full justify-between"
5028
+ ),
4986
5029
  children: [
4987
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ChipContent, { caption, value, icon }),
5030
+ hideCaption ? /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "flex items-center gap-2", children: [
5031
+ icon && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "shrink-0 text-text-tertiary", children: icon }),
5032
+ value
5033
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ChipContent, { caption, value, icon }),
4988
5034
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4989
5035
  import_lucide_react24.ChevronDown,
4990
5036
  {
@@ -5026,54 +5072,38 @@ function MultiSelectFilter({
5026
5072
  groups ? visibleGroups.map((g) => {
5027
5073
  const state = groupState(g);
5028
5074
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { children: [
5029
- /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
5030
- "button",
5031
- {
5032
- type: "button",
5033
- onClick: () => toggleGroup(g),
5034
- 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",
5035
- children: [
5036
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CheckBoxBox, { checked: state === "all", indeterminate: state === "some" }),
5037
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: cn("flex-1 text-sm text-text-primary", !plainParent && "font-semibold"), children: labelled(g.id, g.label) }),
5038
- counts && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(OptionCount, { n: countFor(g.id) })
5039
- ]
5040
- }
5041
- ),
5042
- g.children.map((c) => {
5043
- const checked = draft.includes(c.id);
5044
- return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
5045
- "button",
5046
- {
5047
- type: "button",
5048
- onClick: () => toggle(c.id),
5049
- 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",
5050
- children: [
5051
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CheckBoxBox, { checked }),
5052
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "flex-1 text-sm text-text-primary", children: labelled(c.id, c.label) }),
5053
- counts && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(OptionCount, { n: countFor(c.id) })
5054
- ]
5055
- },
5056
- c.id
5057
- );
5058
- })
5075
+ row({
5076
+ key: g.id,
5077
+ onClick: () => toggleGroup(g),
5078
+ checked: state === "all",
5079
+ indeterminate: state === "some",
5080
+ label: labelled(g.id, g.label),
5081
+ count: counts && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(OptionCount, { n: countFor(g.id) }),
5082
+ bold: !plainParent,
5083
+ blocked: blockedGroup(g)
5084
+ }),
5085
+ g.children.map(
5086
+ (c) => row({
5087
+ key: c.id,
5088
+ onClick: () => toggle(c.id),
5089
+ checked: draft.includes(c.id),
5090
+ label: labelled(c.id, c.label),
5091
+ count: counts && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(OptionCount, { n: countFor(c.id) }),
5092
+ indent: true,
5093
+ blocked: blockedLeaf(c.id)
5094
+ })
5095
+ )
5059
5096
  ] }, g.id);
5060
- }) : items.map((o) => {
5061
- const checked = draft.includes(o.id);
5062
- return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
5063
- "button",
5064
- {
5065
- type: "button",
5066
- onClick: () => toggle(o.id),
5067
- 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",
5068
- children: [
5069
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CheckBoxBox, { checked }),
5070
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "flex-1 text-sm text-text-primary", children: labelled(o.id, o.label) }),
5071
- counts && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(OptionCount, { n: countFor(o.id) })
5072
- ]
5073
- },
5074
- o.id
5075
- );
5076
- }),
5097
+ }) : items.map(
5098
+ (o) => row({
5099
+ key: o.id,
5100
+ onClick: () => toggle(o.id),
5101
+ checked: draft.includes(o.id),
5102
+ label: labelled(o.id, o.label),
5103
+ count: counts && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(OptionCount, { n: countFor(o.id) }),
5104
+ blocked: blockedLeaf(o.id)
5105
+ })
5106
+ ),
5077
5107
  (groups && !visibleGroups.length || !groups && !items.length) && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "py-6 text-center text-dense text-text-tertiary", children: "No matches." })
5078
5108
  ] }),
5079
5109
  note && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "border-t border-border-default px-3 py-2 text-xs text-text-tertiary", children: note }),
@@ -5547,7 +5577,7 @@ function Drawer({ open, onClose, title, description, size = "sm", footer, childr
5547
5577
  }
5548
5578
 
5549
5579
  // src/DataTable.tsx
5550
- var import_react30 = require("react");
5580
+ var import_react31 = require("react");
5551
5581
  var import_lucide_react29 = require("lucide-react");
5552
5582
 
5553
5583
  // src/numbers.ts
@@ -5606,10 +5636,89 @@ function formatPercent(value, _opts = {}) {
5606
5636
  return text === "0.0" ? "0.0%" : `${sign(value)}${text}%`;
5607
5637
  }
5608
5638
 
5609
- // src/DataTable.tsx
5639
+ // src/StickyBar.tsx
5640
+ var import_react30 = require("react");
5610
5641
  var import_jsx_runtime55 = require("react/jsx-runtime");
5642
+ function scrollParent(el) {
5643
+ if (typeof window === "undefined") return null;
5644
+ for (let p = el?.parentElement ?? null; p && p !== document.body && p !== document.documentElement; p = p.parentElement) {
5645
+ const y = window.getComputedStyle(p).overflowY;
5646
+ if (y === "auto" || y === "scroll" || y === "overlay") return p;
5647
+ }
5648
+ return null;
5649
+ }
5650
+ function viewportOf(root) {
5651
+ if (!root) return { top: 0, bottom: window.innerHeight };
5652
+ const r = root.getBoundingClientRect();
5653
+ return { top: r.top + root.clientTop, bottom: r.top + root.clientTop + root.clientHeight };
5654
+ }
5655
+ function scrollPadding(root) {
5656
+ if (!root) return { top: 0, bottom: 0 };
5657
+ const cs = window.getComputedStyle(root);
5658
+ return { top: parseFloat(cs.paddingTop) || 0, bottom: parseFloat(cs.paddingBottom) || 0 };
5659
+ }
5660
+ var STICKY_BAR_ATTR = "data-sticky-bar";
5661
+ function StickyBar({ children, className, testIdPrefix }) {
5662
+ const ref = (0, import_react30.useRef)(null);
5663
+ const [stuck, setStuck] = (0, import_react30.useState)(false);
5664
+ const [pad2, setPad] = (0, import_react30.useState)(0);
5665
+ const [edges, setEdges] = (0, import_react30.useState)({ left: 0, right: 0 });
5666
+ (0, import_react30.useEffect)(() => {
5667
+ const el = ref.current;
5668
+ const parent = el?.parentElement;
5669
+ if (!el || !parent) return void 0;
5670
+ let root = scrollParent(el);
5671
+ const update = () => setStuck(el.getBoundingClientRect().top <= viewportOf(root).top + 0.5 && (root ? root.scrollTop : window.scrollY) > 0);
5672
+ const resize = () => {
5673
+ root = scrollParent(el);
5674
+ setPad(scrollPadding(root).top);
5675
+ const pr = parent.getBoundingClientRect();
5676
+ const ps = window.getComputedStyle(parent);
5677
+ const colLeft = pr.left + parent.clientLeft + (parseFloat(ps.paddingLeft) || 0);
5678
+ const colRight = pr.left + parent.clientLeft + parent.clientWidth - (parseFloat(ps.paddingRight) || 0);
5679
+ const rr = root?.getBoundingClientRect();
5680
+ const boxLeft = root && rr ? rr.left + root.clientLeft : 0;
5681
+ const boxRight = root && rr ? rr.left + root.clientLeft + root.clientWidth : document.documentElement.clientWidth;
5682
+ const next = { left: Math.max(0, colLeft - boxLeft), right: Math.max(0, boxRight - colRight) };
5683
+ setEdges((prev) => prev.left === next.left && prev.right === next.right ? prev : next);
5684
+ update();
5685
+ };
5686
+ resize();
5687
+ document.addEventListener("scroll", update, { capture: true, passive: true });
5688
+ window.addEventListener("resize", resize);
5689
+ const ro = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(resize);
5690
+ ro?.observe(parent);
5691
+ return () => {
5692
+ document.removeEventListener("scroll", update, { capture: true });
5693
+ window.removeEventListener("resize", resize);
5694
+ ro?.disconnect();
5695
+ };
5696
+ }, []);
5697
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5698
+ "div",
5699
+ {
5700
+ ref,
5701
+ ...{ [STICKY_BAR_ATTR]: "" },
5702
+ "data-stuck": stuck ? "" : void 0,
5703
+ "data-testid": testIdPrefix,
5704
+ className: cn("sticky top-0 z-10 border-b bg-canvas", stuck ? "border-border-default" : "border-transparent", className),
5705
+ style: {
5706
+ // At the very top of what scrolls, past the scroll box's own padding.
5707
+ top: pad2 ? -pad2 : void 0,
5708
+ // Stuck: a full-width band, edge to edge of the scroll box; the
5709
+ // filter bar inside stays where it was.
5710
+ ...stuck && (edges.left || edges.right) ? { marginLeft: -edges.left, marginRight: -edges.right, paddingLeft: edges.left, paddingRight: edges.right } : null
5711
+ },
5712
+ children
5713
+ }
5714
+ );
5715
+ }
5716
+
5717
+ // src/DataTable.tsx
5718
+ var import_jsx_runtime56 = require("react/jsx-runtime");
5611
5719
  var WIDTH3 = { fill: "", sm: "w-24", md: "w-36", lg: "w-48" };
5612
5720
  var MAX_H = { sm: "max-h-80", md: "max-h-120", lg: "max-h-160" };
5721
+ var SCROLLBAR = "[&::-webkit-scrollbar]:size-2 [&::-webkit-scrollbar-track]:bg-subtle [&::-webkit-scrollbar-corner]:bg-subtle [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-border-strong supports-[not_selector(::-webkit-scrollbar)]:[scrollbar-width:thin] supports-[not_selector(::-webkit-scrollbar)]:[scrollbar-color:var(--mr-color-border-strong)_var(--mr-color-subtle)]";
5613
5722
  var HEAD_PAD = { default: "px-4 py-3", compact: "px-3 py-2" };
5614
5723
  var CELL_PAD = { default: "px-4 py-3.5", compact: "px-3 py-2" };
5615
5724
  var SUB_INDENT = { default: "pl-10", compact: "pl-9" };
@@ -5627,6 +5736,7 @@ function isDev() {
5627
5736
  return false;
5628
5737
  }
5629
5738
  }
5739
+ var useBrowserLayoutEffect = typeof window === "undefined" ? import_react31.useEffect : import_react31.useLayoutEffect;
5630
5740
  function rowClickCounts(e) {
5631
5741
  if (e.target.closest(OWN_CLICK)) return false;
5632
5742
  const sel = window.getSelection?.();
@@ -5634,13 +5744,13 @@ function rowClickCounts(e) {
5634
5744
  return true;
5635
5745
  }
5636
5746
  function NoValue({ reason = "No data" }) {
5637
- return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(Tooltip, { label: reason, delay: 300, className: "text-text-tertiary", children: [
5638
- /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { "aria-hidden": "true", children: NO_VALUE }),
5639
- /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "sr-only", children: reason })
5747
+ return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(Tooltip, { label: reason, delay: 300, className: "text-text-tertiary", children: [
5748
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { "aria-hidden": "true", children: NO_VALUE }),
5749
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "sr-only", children: reason })
5640
5750
  ] });
5641
5751
  }
5642
5752
  function TableLink({ className, ...props }) {
5643
- return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5753
+ return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
5644
5754
  "a",
5645
5755
  {
5646
5756
  ...props,
@@ -5688,26 +5798,29 @@ function DataTable({
5688
5798
  refreshing = false,
5689
5799
  onRetry,
5690
5800
  empty,
5691
- maxHeight,
5801
+ maxHeight: maxHeightProp,
5692
5802
  footer,
5803
+ sticky = false,
5804
+ stickyTop,
5693
5805
  className,
5694
5806
  testIdPrefix,
5695
5807
  ...rest
5696
5808
  }) {
5697
- const titleId = (0, import_react30.useId)();
5809
+ const maxHeight = sticky ? void 0 : maxHeightProp;
5810
+ const titleId = (0, import_react31.useId)();
5698
5811
  const showSkeleton = useDelayedLoading(loading);
5699
5812
  const head = HEAD_PAD[density];
5700
5813
  const pad2 = CELL_PAD[density];
5701
5814
  const right = (c) => c.numeric || c.rank;
5702
5815
  const align = (c) => right(c) ? "text-right" : "text-left";
5703
- const width = (c) => c.rank ? "w-12" : WIDTH3[c.width ?? (c.numeric ? "md" : "fill")];
5816
+ const width = (c) => c.rank ? "w-12" : WIDTH3[c.width ?? (c.lead ? "sm" : c.numeric ? "md" : "fill")];
5704
5817
  const shown = sort ?? defaultSort;
5705
5818
  const onSort = (key) => {
5706
5819
  const col = columns.find((c) => c.key === key);
5707
5820
  onSortChange?.(cycleSort(shown, key, col?.firstDir ?? (right(col) ? "desc" : "asc"), defaultSort));
5708
5821
  };
5709
5822
  const clash = !!onRowClick && (!!renderExpandedProp || !!subRowsProp);
5710
- (0, import_react30.useEffect)(() => {
5823
+ (0, import_react31.useEffect)(() => {
5711
5824
  if (clash && isDev()) {
5712
5825
  console.warn("DataTable: pass `onRowClick` or rows that open in place (`renderExpanded`, `subRows`), not both. The row click wins; rows won't open.");
5713
5826
  }
@@ -5718,10 +5831,10 @@ function DataTable({
5718
5831
  const kids = subRows?.(row);
5719
5832
  return kids && kids.length > 0 ? kids : null;
5720
5833
  };
5721
- const [open, setOpen] = (0, import_react30.useState)(() => /* @__PURE__ */ new Set());
5834
+ const [open, setOpen] = (0, import_react31.useState)(() => /* @__PURE__ */ new Set());
5722
5835
  const visible = rows.map(rowKey);
5723
5836
  const resetOn = subRows ? [...visible].sort().join("|") : `${shown?.key}|${shown?.dir}|${visible.join("|")}`;
5724
- (0, import_react30.useEffect)(() => setOpen(/* @__PURE__ */ new Set()), [resetOn]);
5837
+ (0, import_react31.useEffect)(() => setOpen(/* @__PURE__ */ new Set()), [resetOn]);
5725
5838
  const expandable = (row) => (!!renderExpanded || !!childrenOf(row)) && (canExpand ? canExpand(row) : true);
5726
5839
  const anyExpandable = (!!renderExpanded || !!subRows) && rows.some(expandable);
5727
5840
  const toggle = (key) => setOpen((prev) => {
@@ -5742,8 +5855,8 @@ function DataTable({
5742
5855
  pickable.forEach((k) => allVisible ? next.delete(k) : next.add(k));
5743
5856
  setPicked(next);
5744
5857
  };
5745
- const lastPicked = (0, import_react30.useRef)(null);
5746
- const shiftHeld = (0, import_react30.useRef)(false);
5858
+ const lastPicked = (0, import_react31.useRef)(null);
5859
+ const shiftHeld = (0, import_react31.useRef)(false);
5747
5860
  const togglePick = (index) => {
5748
5861
  const key = visible[index];
5749
5862
  const on = !picked.has(key);
@@ -5760,12 +5873,12 @@ function DataTable({
5760
5873
  };
5761
5874
  const count = selectedCount ?? picked.size;
5762
5875
  const barCount = selectable && selectionBar ? count : 0;
5763
- const scroller = (0, import_react30.useRef)(null);
5764
- const [pinned, setPinned] = (0, import_react30.useState)(false);
5765
- const [scrolled, setScrolled] = (0, import_react30.useState)(false);
5766
- const heads = (0, import_react30.useRef)(/* @__PURE__ */ new Map());
5767
- const [lefts, setLefts] = (0, import_react30.useState)({});
5768
- (0, import_react30.useEffect)(() => {
5876
+ const scroller = (0, import_react31.useRef)(null);
5877
+ const [pinned, setPinned] = (0, import_react31.useState)(false);
5878
+ const [scrolled, setScrolled] = (0, import_react31.useState)(false);
5879
+ const heads = (0, import_react31.useRef)(/* @__PURE__ */ new Map());
5880
+ const [lefts, setLefts] = (0, import_react31.useState)({});
5881
+ (0, import_react31.useEffect)(() => {
5769
5882
  const el = scroller.current;
5770
5883
  if (!el || typeof ResizeObserver === "undefined") return void 0;
5771
5884
  const measure = () => {
@@ -5785,7 +5898,7 @@ function DataTable({
5785
5898
  if (el.firstElementChild) ro.observe(el.firstElementChild);
5786
5899
  return () => ro.disconnect();
5787
5900
  }, []);
5788
- const nameIdx = Math.max(0, columns.findIndex((c) => !c.rank));
5901
+ const nameIdx = Math.max(0, columns.findIndex((c) => !c.rank && !c.lead));
5789
5902
  const leftOf = (part) => lefts[String(part)] ?? 0;
5790
5903
  const headRef = (part) => (el) => {
5791
5904
  if (el) heads.current.set(String(part), el);
@@ -5798,13 +5911,81 @@ function DataTable({
5798
5911
  part === nameIdx && "max-w-60 border-r border-r-border-default"
5799
5912
  ) : "";
5800
5913
  const pinStyle = (part) => isPinned(part) ? { left: leftOf(part) } : void 0;
5801
- const edge = (part) => pinned && scrolled && part === nameIdx ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { "aria-hidden": "true", className: "pointer-events-none absolute inset-y-0 left-full w-2 bg-linear-to-r from-border-default to-transparent" }) : null;
5914
+ const edge = (part) => pinned && scrolled && part === nameIdx ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { "aria-hidden": "true", className: "pointer-events-none absolute inset-y-0 left-full w-2 bg-linear-to-r from-border-default to-transparent" }) : null;
5802
5915
  const span = columns.length + (anyExpandable ? 1 : 0) + (selectable ? 1 : 0);
5916
+ const wrapRef = (0, import_react31.useRef)(null);
5917
+ const theadRef = (0, import_react31.useRef)(null);
5918
+ const cloneRef = (0, import_react31.useRef)(null);
5919
+ const [stuck, setStuck] = (0, import_react31.useState)(false);
5920
+ const [geom, setGeom] = (0, import_react31.useState)({ cols: [], width: 0, height: 0 });
5921
+ const [barH, setBarH] = (0, import_react31.useState)(0);
5922
+ const [scrollPad, setScrollPad] = (0, import_react31.useState)({ top: 0, bottom: 0 });
5923
+ const [footerStuck, setFooterStuck] = (0, import_react31.useState)(false);
5924
+ const [scrolledDown, setScrolledDown] = (0, import_react31.useState)(false);
5925
+ const [animate, setAnimate] = (0, import_react31.useState)(false);
5926
+ (0, import_react31.useEffect)(() => {
5927
+ const thead = theadRef.current;
5928
+ if (!sticky || !thead || typeof ResizeObserver === "undefined") return void 0;
5929
+ const measure = () => {
5930
+ const cells = [...thead.rows[0]?.cells ?? []];
5931
+ const next = { cols: cells.map((c) => c.getBoundingClientRect().width), width: thead.getBoundingClientRect().width, height: thead.getBoundingClientRect().height };
5932
+ setGeom((prev) => prev.width === next.width && prev.height === next.height && prev.cols.join() === next.cols.join() ? prev : next);
5933
+ };
5934
+ measure();
5935
+ const ro = new ResizeObserver(measure);
5936
+ ro.observe(thead);
5937
+ for (const c of thead.rows[0]?.cells ?? []) ro.observe(c);
5938
+ return () => ro.disconnect();
5939
+ }, [sticky, span]);
5940
+ useBrowserLayoutEffect(() => {
5941
+ const wrap = wrapRef.current;
5942
+ if (!sticky || !wrap) return void 0;
5943
+ let root = scrollParent(wrap);
5944
+ const bar2 = (root ?? document).querySelector(`[${STICKY_BAR_ATTR}]`) ?? document.querySelector(`[${STICKY_BAR_ATTR}]`);
5945
+ const update = () => {
5946
+ const thead = theadRef.current;
5947
+ const clone = cloneRef.current;
5948
+ if (thead && clone) setStuck(clone.getBoundingClientRect().top > thead.getBoundingClientRect().top + 0.5);
5949
+ setFooterStuck(wrap.getBoundingClientRect().bottom > viewportOf(root).bottom + 1);
5950
+ setScrolledDown((root ? root.scrollTop : window.scrollY) > 0);
5951
+ };
5952
+ const measure = () => {
5953
+ root = scrollParent(wrap);
5954
+ setBarH(bar2 ? bar2.getBoundingClientRect().height : 0);
5955
+ setScrollPad((prev) => {
5956
+ const next = scrollPadding(root);
5957
+ return prev.top === next.top && prev.bottom === next.bottom ? prev : next;
5958
+ });
5959
+ update();
5960
+ };
5961
+ measure();
5962
+ const raf = requestAnimationFrame(() => setAnimate(true));
5963
+ document.addEventListener("scroll", update, { capture: true, passive: true });
5964
+ window.addEventListener("resize", measure);
5965
+ const ro = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
5966
+ if (bar2) ro?.observe(bar2);
5967
+ ro?.observe(wrap);
5968
+ return () => {
5969
+ cancelAnimationFrame(raf);
5970
+ document.removeEventListener("scroll", update, { capture: true });
5971
+ window.removeEventListener("resize", measure);
5972
+ ro?.disconnect();
5973
+ };
5974
+ }, [sticky]);
5975
+ (0, import_react31.useEffect)(() => {
5976
+ const clone = cloneRef.current;
5977
+ if (!clone) return;
5978
+ clone.querySelectorAll("button, a[href], input, [tabindex]").forEach((el) => {
5979
+ if (el.tabIndex !== -1) el.tabIndex = -1;
5980
+ });
5981
+ if (scroller.current) clone.scrollLeft = scroller.current.scrollLeft;
5982
+ });
5983
+ const top = (stickyTop ?? barH) - scrollPad.top;
5803
5984
  const renderCell = (c, row) => {
5804
5985
  const v = c.cell(row);
5805
- return v === null || v === void 0 || v === "" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(NoValue, { reason: c.missing }) : v;
5986
+ return v === null || v === void 0 || v === "" ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(NoValue, { reason: c.missing }) : v;
5806
5987
  };
5807
- const fit = (ci, content) => pinned && ci === nameIdx ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Tooltip, { label: content, whenTruncated: true, delay: 300, className: "block truncate", children: content }) : content;
5988
+ const fit = (ci, content) => pinned && ci === nameIdx ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Tooltip, { label: content, whenTruncated: true, delay: 300, className: "block truncate", children: content }) : content;
5808
5989
  const colBg = (c, rowBg) => c.highlight ? TINT : rowBg;
5809
5990
  const firstPart = selectable ? "select" : anyExpandable ? "expand" : 0;
5810
5991
  const ringCls = (part) => onRowClick ? cn(
@@ -5814,13 +5995,13 @@ function DataTable({
5814
5995
  part === columns.length - 1 && RING_RIGHT,
5815
5996
  pinned && scrolled && part === nameIdx && part !== columns.length - 1 && RING_PAST_EDGE
5816
5997
  ) : "";
5817
- const plainRow = (kind, row, key, rowBg, extra) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tr", { id: extra?.id, className: cn("[&:last-child>td]:border-b-0", kind === "total" && "font-semibold"), children: [
5818
- selectable && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { className: cn("border-b border-border-default pr-0", pad2, rowBg, pinCls("select", "body", rowBg)), style: pinStyle("select") }),
5819
- anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { className: cn("border-b border-border-default pr-0", pad2, rowBg, pinCls("expand", "body", rowBg)), style: pinStyle("expand") }),
5998
+ const plainRow = (kind, row, key, rowBg, extra) => /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("tr", { id: extra?.id, className: cn("[&:last-child>td]:border-b-0", kind === "total" && "font-semibold"), children: [
5999
+ selectable && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("td", { className: cn("border-b border-border-default pr-0", pad2, rowBg, pinCls("select", "body", rowBg)), style: pinStyle("select") }),
6000
+ anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("td", { className: cn("border-b border-border-default pr-0", pad2, rowBg, pinCls("expand", "body", rowBg)), style: pinStyle("expand") }),
5820
6001
  columns.map((c, ci) => {
5821
6002
  const bg = kind === "sub" ? colBg(c, rowBg) : rowBg;
5822
6003
  const isName = ci === nameIdx;
5823
- return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6004
+ return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
5824
6005
  "td",
5825
6006
  {
5826
6007
  className: cn(
@@ -5835,8 +6016,8 @@ function DataTable({
5835
6016
  ),
5836
6017
  style: pinStyle(ci),
5837
6018
  children: [
5838
- c.rank ? null : isName && kind === "total" ? fit(ci, totalsLabel) : kind === "total" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(DeltaBoldContext.Provider, { value: true, children: fit(ci, renderCell(c, row)) }) : fit(ci, renderCell(c, row)),
5839
- kind === "sub" && isName && rowLabel && extra?.parent !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("span", { className: "sr-only", children: [
6019
+ c.rank || c.lead ? null : isName && kind === "total" ? fit(ci, totalsLabel) : kind === "total" ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(DeltaBoldContext.Provider, { value: true, children: fit(ci, renderCell(c, row)) }) : fit(ci, renderCell(c, row)),
6020
+ kind === "sub" && isName && rowLabel && extra?.parent !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("span", { className: "sr-only", children: [
5840
6021
  ", in ",
5841
6022
  rowLabel(extra.parent)
5842
6023
  ] }),
@@ -5847,231 +6028,284 @@ function DataTable({
5847
6028
  );
5848
6029
  })
5849
6030
  ] }, key);
6031
+ const headRow = (clone) => /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("tr", { className: "bg-subtle text-micro font-semibold uppercase tracking-wider text-text-secondary", children: [
6032
+ selectable && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("th", { ref: clone ? void 0 : headRef("select"), scope: "col", className: cn("w-10 border-b border-border-default pr-0", head, pinCls("select", "head")), style: pinStyle("select"), children: selectAll ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6033
+ CheckBox,
6034
+ {
6035
+ checked: allVisible,
6036
+ indeterminate: someVisible && !allVisible,
6037
+ onChange: toggleAllVisible,
6038
+ disabled: pickable.length === 0,
6039
+ ariaLabel: allVisible ? "Deselect all rows on this page" : "Select all rows on this page"
6040
+ }
6041
+ ) : /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "sr-only", children: "Select" }) }),
6042
+ anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("th", { ref: clone ? void 0 : headRef("expand"), scope: "col", className: cn("w-10 border-b border-border-default", head, pinCls("expand", "head")), style: pinStyle("expand"), children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "sr-only", children: "Details" }) }),
6043
+ columns.map((c, ci) => /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
6044
+ "th",
6045
+ {
6046
+ ref: !clone && ci <= nameIdx ? headRef(ci) : void 0,
6047
+ scope: "col",
6048
+ "aria-sort": c.sortable ? ariaSortFor(shown, c.key) : void 0,
6049
+ className: cn(
6050
+ "group/head whitespace-nowrap border-b border-border-default font-semibold",
6051
+ head,
6052
+ align(c),
6053
+ width(c),
6054
+ c.highlight && TINT,
6055
+ pinCls(ci, "head", c.highlight ? TINT : void 0)
6056
+ ),
6057
+ style: pinStyle(ci),
6058
+ children: [
6059
+ c.sortable && onSortChange ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6060
+ SortButton,
6061
+ {
6062
+ label: c.label,
6063
+ sortKey: c.key,
6064
+ align: right(c) ? "right" : "left",
6065
+ sort: sortProp(shown),
6066
+ onSort,
6067
+ description: c.info,
6068
+ testIdPrefix: clone ? void 0 : testIdPrefix
6069
+ }
6070
+ ) : c.info ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(SortButton, { label: c.label, sortKey: c.key, sortable: false, sort: sortProp(shown), onSort: () => {
6071
+ }, description: c.info, align: right(c) ? "right" : "left" }) : c.label,
6072
+ edge(ci)
6073
+ ]
6074
+ },
6075
+ c.key
6076
+ ))
6077
+ ] });
5850
6078
  const inside = variant === "chart";
5851
- const bar = barCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 text-dense", children: [
5852
- /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("span", { role: "status", className: "font-medium text-text-primary", children: [
6079
+ const bar = barCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 text-dense", children: [
6080
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("span", { role: "status", className: "font-medium text-text-primary", children: [
5853
6081
  formatCountFull(count),
5854
6082
  " selected"
5855
6083
  ] }),
5856
- allVisible && totalCount !== void 0 && count < totalCount && onSelectAll && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(Button, { variant: "link", size: "sm", onClick: onSelectAll, children: [
6084
+ allVisible && totalCount !== void 0 && count < totalCount && onSelectAll && /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(Button, { variant: "link", size: "sm", onClick: onSelectAll, children: [
5857
6085
  "Select all ",
5858
6086
  formatCountFull(totalCount)
5859
6087
  ] }),
5860
6088
  selectionActions,
5861
- /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Button, { variant: "link", size: "sm", onClick: () => onSelectedChange?.([]), children: "Clear" })
6089
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Button, { variant: "link", size: "sm", onClick: () => onSelectedChange?.([]), children: "Clear" })
5862
6090
  ] }) : null;
5863
- const frame = /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6091
+ const scrollArea = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
5864
6092
  "div",
5865
6093
  {
5866
- className: cn("relative flex w-full flex-col overflow-hidden rounded-card border border-border-default bg-surface", (inside || !title && barCount === 0) && className),
5867
- "data-testid": testIdPrefix,
5868
- children: [
5869
- title && inside && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
5870
- /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "min-w-0", children: [
5871
- /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("h3", { id: titleId, className: "text-panel-title font-semibold text-text-primary", children: title }),
5872
- subtitle && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "mt-0.5 text-xs leading-snug text-text-tertiary", children: subtitle })
5873
- ] }),
5874
- (bar ?? action) && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "shrink-0 text-text-tertiary", children: bar ?? action })
5875
- ] }),
5876
- /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5877
- "div",
5878
- {
5879
- ref: scroller,
5880
- onScroll: (e) => setScrolled(e.currentTarget.scrollLeft > 0),
5881
- className: cn("overflow-x-auto", maxHeight && cn("overflow-y-auto", MAX_H[maxHeight])),
5882
- children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
5883
- "table",
5884
- {
5885
- "aria-labelledby": title ? titleId : void 0,
5886
- "aria-label": title ? void 0 : rest["aria-label"],
5887
- "aria-busy": loading || refreshing || void 0,
5888
- className: "w-full border-separate border-spacing-0 text-left",
5889
- children: [
5890
- /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("thead", { className: cn(maxHeight && "sticky top-0 z-10"), children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tr", { className: "bg-subtle text-micro font-semibold uppercase tracking-wider text-text-secondary", children: [
5891
- selectable && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("th", { ref: headRef("select"), scope: "col", className: cn("w-10 border-b border-border-default pr-0", head, pinCls("select", "head")), style: pinStyle("select"), children: selectAll ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5892
- CheckBox,
5893
- {
5894
- checked: allVisible,
5895
- indeterminate: someVisible && !allVisible,
5896
- onChange: toggleAllVisible,
5897
- disabled: pickable.length === 0,
5898
- ariaLabel: allVisible ? "Deselect all rows on this page" : "Select all rows on this page"
5899
- }
5900
- ) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "sr-only", children: "Select" }) }),
5901
- anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("th", { ref: headRef("expand"), scope: "col", className: cn("w-10 border-b border-border-default", head, pinCls("expand", "head")), style: pinStyle("expand"), children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "sr-only", children: "Details" }) }),
5902
- columns.map((c, ci) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
5903
- "th",
5904
- {
5905
- ref: ci <= nameIdx ? headRef(ci) : void 0,
5906
- scope: "col",
5907
- "aria-sort": c.sortable ? ariaSortFor(shown, c.key) : void 0,
5908
- className: cn(
5909
- "group/head whitespace-nowrap border-b border-border-default font-semibold",
5910
- head,
5911
- align(c),
5912
- width(c),
5913
- c.highlight && TINT,
5914
- pinCls(ci, "head", c.highlight ? TINT : void 0)
6094
+ ref: scroller,
6095
+ onScroll: (e) => {
6096
+ setScrolled(e.currentTarget.scrollLeft > 0);
6097
+ if (cloneRef.current) cloneRef.current.scrollLeft = e.currentTarget.scrollLeft;
6098
+ },
6099
+ className: cn("overflow-x-auto", SCROLLBAR, maxHeight && cn("overflow-y-auto", MAX_H[maxHeight])),
6100
+ children: /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
6101
+ "table",
6102
+ {
6103
+ "aria-labelledby": title ? titleId : void 0,
6104
+ "aria-label": title ? void 0 : rest["aria-label"],
6105
+ "aria-busy": loading || refreshing || void 0,
6106
+ className: "w-full border-separate border-spacing-0 text-left",
6107
+ children: [
6108
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("thead", { ref: theadRef, className: cn(maxHeight && "sticky top-0 z-10"), children: headRow(false) }),
6109
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("tbody", { className: cn("text-dense text-text-primary", refreshing && !loading && "opacity-50 transition-opacity motion-reduce:transition-none"), children: loading ? Array.from({ length: loadingRows }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("tr", { "aria-hidden": "true", className: "[&:last-child>td]:border-b-0", children: [
6110
+ selectable && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("td", { className: cn("border-b border-border-default", pad2) }),
6111
+ anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("td", { className: cn("border-b border-border-default", pad2) }),
6112
+ columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("td", { className: cn("border-b border-border-default", pad2, align(c)), children: showSkeleton ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Skeleton, { className: cn("inline-block", right(c) ? "w-12" : "w-2/3") }) : /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "inline-block h-3" }) }, c.key))
6113
+ ] }, i)) : rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("td", { colSpan: span, className: "px-6 py-12", children: empty ?? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(NoResultsEmptyState, {}) }) }) : /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(import_jsx_runtime56.Fragment, { children: [
6114
+ totalsRow !== void 0 && plainRow("total", totalsRow, "__totals", "bg-subtle"),
6115
+ rows.map((row, ri) => {
6116
+ const key = rowKey(row);
6117
+ const canOpen = expandable(row);
6118
+ const kids = canOpen ? childrenOf(row) : null;
6119
+ const isOpen = canOpen && open.has(key);
6120
+ const panelOpen = isOpen && !kids;
6121
+ const panelId = `${titleId}-row-${ri}`;
6122
+ const kidIds = kids ? kids.map((_, si) => `${panelId}-${si}`) : [];
6123
+ const rowBg = highlightRow?.(row) ? cn(TINT, onRowClick && TINT_HOVER) : panelOpen ? "bg-subtle" : void 0;
6124
+ const reason = selectable ? blocked(row) : false;
6125
+ const ticked = picked.has(key);
6126
+ const label = rowLabel ? rowLabel(row) : "row";
6127
+ const clickable = !!onRowClick || canOpen;
6128
+ return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(import_react31.Fragment, { children: [
6129
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
6130
+ "tr",
6131
+ {
6132
+ onClick: onRowClick ? (e) => rowClickCounts(e) && onRowClick(row) : canOpen ? (e) => rowClickCounts(e) && toggle(key) : void 0,
6133
+ className: cn(
6134
+ "group/row hover:bg-subtle [&:last-child>td]:border-b-0",
6135
+ clickable && "cursor-pointer",
6136
+ panelOpen && "bg-subtle"
6137
+ // The row's hidden open button has keyboard focus: ring the whole row.
6138
+ ),
6139
+ children: [
6140
+ selectable && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6141
+ "td",
6142
+ {
6143
+ onPointerDownCapture: (e) => shiftHeld.current = e.shiftKey,
6144
+ onKeyDownCapture: (e) => shiftHeld.current = e.shiftKey,
6145
+ className: cn("border-b border-border-default pr-0", pad2, panelOpen && "border-b-0", rowBg, ringCls("select"), pinCls("select", "body", rowBg)),
6146
+ style: pinStyle("select"),
6147
+ children: reason ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Tooltip, { label: reason, delay: 300, className: "inline-flex align-middle", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6148
+ "button",
6149
+ {
6150
+ type: "button",
6151
+ role: "checkbox",
6152
+ "aria-checked": ticked,
6153
+ "aria-disabled": "true",
6154
+ "aria-label": `Select ${label}`,
6155
+ onClick: (e) => e.preventDefault(),
6156
+ className: "flex cursor-not-allowed rounded-small focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-border-focus",
6157
+ children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(CheckBoxBox, { checked: ticked, disabled: true })
6158
+ }
6159
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(CheckBox, { checked: ticked, onChange: () => togglePick(ri), ariaLabel: `Select ${label}` })
6160
+ }
5915
6161
  ),
5916
- style: pinStyle(ci),
5917
- children: [
5918
- c.sortable && onSortChange ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5919
- SortButton,
5920
- {
5921
- label: c.label,
5922
- sortKey: c.key,
5923
- align: right(c) ? "right" : "left",
5924
- sort: sortProp(shown),
5925
- onSort,
5926
- description: c.info,
5927
- testIdPrefix
5928
- }
5929
- ) : c.info ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(SortButton, { label: c.label, sortKey: c.key, sortable: false, sort: sortProp(shown), onSort: () => {
5930
- }, description: c.info, align: right(c) ? "right" : "left" }) : c.label,
5931
- edge(ci)
5932
- ]
5933
- },
5934
- c.key
5935
- ))
5936
- ] }) }),
5937
- /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tbody", { className: cn("text-dense text-text-primary", refreshing && !loading && "opacity-50 transition-opacity motion-reduce:transition-none"), children: loading ? Array.from({ length: loadingRows }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tr", { "aria-hidden": "true", className: "[&:last-child>td]:border-b-0", children: [
5938
- selectable && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { className: cn("border-b border-border-default", pad2) }),
5939
- anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { className: cn("border-b border-border-default", pad2) }),
5940
- columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { className: cn("border-b border-border-default", pad2, align(c)), children: showSkeleton ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Skeleton, { className: cn("inline-block", right(c) ? "w-12" : "w-2/3") }) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "inline-block h-3" }) }, c.key))
5941
- ] }, i)) : rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { colSpan: span, className: "px-6 py-12", children: empty ?? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(NoResultsEmptyState, {}) }) }) : /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
5942
- totalsRow !== void 0 && plainRow("total", totalsRow, "__totals", "bg-subtle"),
5943
- rows.map((row, ri) => {
5944
- const key = rowKey(row);
5945
- const canOpen = expandable(row);
5946
- const kids = canOpen ? childrenOf(row) : null;
5947
- const isOpen = canOpen && open.has(key);
5948
- const panelOpen = isOpen && !kids;
5949
- const panelId = `${titleId}-row-${ri}`;
5950
- const kidIds = kids ? kids.map((_, si) => `${panelId}-${si}`) : [];
5951
- const rowBg = highlightRow?.(row) ? cn(TINT, onRowClick && TINT_HOVER) : panelOpen ? "bg-subtle" : void 0;
5952
- const reason = selectable ? blocked(row) : false;
5953
- const ticked = picked.has(key);
5954
- const label = rowLabel ? rowLabel(row) : "row";
5955
- const clickable = !!onRowClick || canOpen;
5956
- return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_react30.Fragment, { children: [
5957
- /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
5958
- "tr",
6162
+ anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6163
+ "td",
5959
6164
  {
5960
- onClick: onRowClick ? (e) => rowClickCounts(e) && onRowClick(row) : canOpen ? (e) => rowClickCounts(e) && toggle(key) : void 0,
5961
- className: cn(
5962
- "group/row hover:bg-subtle [&:last-child>td]:border-b-0",
5963
- clickable && "cursor-pointer",
5964
- panelOpen && "bg-subtle"
5965
- // The row's hidden open button has keyboard focus: ring the whole row.
5966
- ),
5967
- children: [
5968
- selectable && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5969
- "td",
5970
- {
5971
- onPointerDownCapture: (e) => shiftHeld.current = e.shiftKey,
5972
- onKeyDownCapture: (e) => shiftHeld.current = e.shiftKey,
5973
- className: cn("border-b border-border-default pr-0", pad2, panelOpen && "border-b-0", rowBg, ringCls("select"), pinCls("select", "body", rowBg)),
5974
- style: pinStyle("select"),
5975
- children: reason ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Tooltip, { label: reason, delay: 300, className: "inline-flex align-middle", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5976
- "button",
5977
- {
5978
- type: "button",
5979
- role: "checkbox",
5980
- "aria-checked": ticked,
5981
- "aria-disabled": "true",
5982
- "aria-label": `Select ${label}`,
5983
- onClick: (e) => e.preventDefault(),
5984
- className: "flex cursor-not-allowed rounded-small focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-border-focus",
5985
- children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(CheckBoxBox, { checked: ticked, disabled: true })
5986
- }
5987
- ) }) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(CheckBox, { checked: ticked, onChange: () => togglePick(ri), ariaLabel: `Select ${label}` })
5988
- }
5989
- ),
5990
- anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5991
- "td",
5992
- {
5993
- className: cn("border-b border-border-default pr-0", pad2, panelOpen && "border-b-0", rowBg, ringCls("expand"), pinCls("expand", "body", rowBg)),
5994
- style: pinStyle("expand"),
5995
- children: canOpen && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5996
- "button",
5997
- {
5998
- type: "button",
5999
- "aria-expanded": isOpen,
6000
- "aria-controls": isOpen ? kids ? kidIds.join(" ") : panelId : void 0,
6001
- "aria-label": kids ? `${isOpen ? "Hide" : "Show"} ${kids.length} ${kids.length === 1 ? subRowNoun.one : subRowNoun.other}${rowLabel ? ` under ${rowLabel(row)}` : ""}` : `${isOpen ? "Hide" : "Show"} details${rowLabel ? ` for ${rowLabel(row)}` : ""}`,
6002
- onClick: () => toggle(key),
6003
- className: "flex size-6 items-center justify-center rounded-control text-text-tertiary hover:text-text-primary focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-border-focus",
6004
- children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6005
- import_lucide_react29.ChevronRight,
6006
- {
6007
- size: 16,
6008
- "aria-hidden": "true",
6009
- className: cn("transition-transform motion-reduce:transition-none", isOpen && "rotate-90")
6010
- }
6011
- )
6012
- }
6013
- )
6014
- }
6015
- ),
6016
- columns.map((c, ci) => {
6017
- const bg = colBg(c, rowBg);
6018
- const opener = !!onRowClick && ci === nameIdx;
6019
- return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6020
- "td",
6165
+ className: cn("border-b border-border-default pr-0", pad2, panelOpen && "border-b-0", rowBg, ringCls("expand"), pinCls("expand", "body", rowBg)),
6166
+ style: pinStyle("expand"),
6167
+ children: canOpen && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6168
+ "button",
6169
+ {
6170
+ type: "button",
6171
+ "aria-expanded": isOpen,
6172
+ "aria-controls": isOpen ? kids ? kidIds.join(" ") : panelId : void 0,
6173
+ "aria-label": kids ? `${isOpen ? "Hide" : "Show"} ${kids.length} ${kids.length === 1 ? subRowNoun.one : subRowNoun.other}${rowLabel ? ` under ${rowLabel(row)}` : ""}` : `${isOpen ? "Hide" : "Show"} details${rowLabel ? ` for ${rowLabel(row)}` : ""}`,
6174
+ onClick: () => toggle(key),
6175
+ className: "flex size-6 items-center justify-center rounded-control text-text-tertiary hover:text-text-primary focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-border-focus",
6176
+ children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6177
+ import_lucide_react29.ChevronRight,
6021
6178
  {
6022
- className: cn(
6023
- "border-b border-border-default",
6024
- pad2,
6025
- align(c),
6026
- right(c) && "tabular-nums",
6027
- c.rank && "text-text-tertiary",
6028
- panelOpen && "border-b-0",
6029
- ringCls(ci),
6030
- bg,
6031
- pinCls(ci, "body", bg)
6032
- ),
6033
- style: pinStyle(ci),
6034
- children: [
6035
- fit(ci, renderCell(c, row)),
6036
- opener && // The keyboard's and screen reader's way to the row click. It
6037
- // stays hidden; while it has focus the whole row takes the ring.
6038
- /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("button", { type: "button", "data-row-open": "", onClick: () => onRowClick(row), className: "sr-only", children: rowClickLabel ? rowClickLabel(row) : `Open ${rowLabel ? rowLabel(row) : "row"}` }),
6039
- edge(ci)
6040
- ]
6041
- },
6042
- c.key
6043
- );
6044
- })
6045
- ]
6179
+ size: 16,
6180
+ "aria-hidden": "true",
6181
+ className: cn("transition-transform motion-reduce:transition-none", isOpen && "rotate-90")
6182
+ }
6183
+ )
6184
+ }
6185
+ )
6046
6186
  }
6047
6187
  ),
6048
- panelOpen && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tr", { className: "[&:last-child>td]:border-b-0", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { id: panelId, colSpan: span, className: "border-b border-border-default bg-subtle px-4 pb-4 pl-14", children: renderExpanded(row) }) }),
6049
- isOpen && kids?.map(
6050
- (child, si) => plainRow("sub", child, `${key}::${rowKey(child)}`, highlightRow?.(child) ? TINT : "bg-subtle", { id: kidIds[si], parent: row })
6051
- )
6052
- ] }, key);
6053
- })
6054
- ] }) })
6055
- ]
6188
+ columns.map((c, ci) => {
6189
+ const bg = colBg(c, rowBg);
6190
+ const opener = !!onRowClick && ci === nameIdx;
6191
+ return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
6192
+ "td",
6193
+ {
6194
+ className: cn(
6195
+ "border-b border-border-default",
6196
+ pad2,
6197
+ align(c),
6198
+ right(c) && "tabular-nums",
6199
+ c.rank && "text-text-tertiary",
6200
+ panelOpen && "border-b-0",
6201
+ ringCls(ci),
6202
+ bg,
6203
+ pinCls(ci, "body", bg)
6204
+ ),
6205
+ style: pinStyle(ci),
6206
+ children: [
6207
+ fit(ci, renderCell(c, row)),
6208
+ opener && // The keyboard's and screen reader's way to the row click. It
6209
+ // stays hidden; while it has focus the whole row takes the ring.
6210
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("button", { type: "button", "data-row-open": "", onClick: () => onRowClick(row), className: "sr-only", children: rowClickLabel ? rowClickLabel(row) : `Open ${rowLabel ? rowLabel(row) : "row"}` }),
6211
+ edge(ci)
6212
+ ]
6213
+ },
6214
+ c.key
6215
+ );
6216
+ })
6217
+ ]
6218
+ }
6219
+ ),
6220
+ panelOpen && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("tr", { className: "[&:last-child>td]:border-b-0", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("td", { id: panelId, colSpan: span, className: "border-b border-border-default bg-subtle px-4 pb-4 pl-14", children: renderExpanded(row) }) }),
6221
+ isOpen && kids?.map(
6222
+ (child, si) => plainRow("sub", child, `${key}::${rowKey(child)}`, highlightRow?.(child) ? TINT : "bg-subtle", { id: kidIds[si], parent: row })
6223
+ )
6224
+ ] }, key);
6225
+ })
6226
+ ] }) })
6227
+ ]
6228
+ }
6229
+ )
6230
+ }
6231
+ );
6232
+ const bare = inside || !title && barCount === 0;
6233
+ const frame = /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
6234
+ "div",
6235
+ {
6236
+ className: cn(
6237
+ "relative flex w-full flex-col rounded-card border border-border-default bg-surface",
6238
+ // clip, not hidden, on a sticky table: hidden would make the frame the
6239
+ // box its header sticks in, instead of the page.
6240
+ sticky ? "overflow-clip" : "overflow-hidden",
6241
+ !sticky && bare && className
6242
+ ),
6243
+ "data-testid": testIdPrefix,
6244
+ children: [
6245
+ title && inside && /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
6246
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "min-w-0", children: [
6247
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("h3", { id: titleId, className: "text-panel-title font-semibold text-text-primary", children: title }),
6248
+ subtitle && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("p", { className: "mt-0.5 text-xs leading-snug text-text-tertiary", children: subtitle })
6249
+ ] }),
6250
+ (bar ?? action) && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "shrink-0 text-text-tertiary", children: bar ?? action })
6251
+ ] }),
6252
+ sticky ? (
6253
+ // The copy of the header sticks within this box, so it leaves with the last row.
6254
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "relative", children: [
6255
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6256
+ "div",
6257
+ {
6258
+ ref: cloneRef,
6259
+ "aria-hidden": "true",
6260
+ "data-sticky-head": "",
6261
+ onWheel: (e) => {
6262
+ if (scroller.current && Math.abs(e.deltaX) > Math.abs(e.deltaY)) scroller.current.scrollLeft += e.deltaX;
6263
+ },
6264
+ className: "sticky z-2 overflow-hidden",
6265
+ style: { top, height: geom.height, marginBottom: -geom.height, visibility: stuck ? "visible" : "hidden" },
6266
+ children: /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("table", { className: "table-fixed border-separate border-spacing-0 text-left", style: { width: geom.width }, children: [
6267
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("colgroup", { children: geom.cols.map((w, i) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("col", { style: { width: w } }, i)) }),
6268
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("thead", { children: headRow(true) })
6269
+ ] })
6056
6270
  }
6057
- )
6058
- }
6059
- ),
6060
- refreshing && !loading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(RefreshLine, {}),
6061
- /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(LongWait, { loading, onRetry, className: "mb-3 px-4" }),
6062
- footer && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "border-t border-border-default px-4 py-3", children: footer })
6271
+ ),
6272
+ scrollArea
6273
+ ] })
6274
+ ) : scrollArea,
6275
+ refreshing && !loading && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(RefreshLine, {}),
6276
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(LongWait, { loading, onRetry, className: "mb-3 px-4" }),
6277
+ footer && !sticky && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "border-t border-border-default px-4 py-3", children: footer })
6063
6278
  ]
6064
6279
  }
6065
6280
  );
6066
- if (inside || !title && barCount === 0) return frame;
6067
- return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("section", { "aria-labelledby": title ? titleId : void 0, className: cn("flex w-full flex-col gap-3", className), children: [
6068
- title ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(SectionHeading, { id: titleId, as: titleAs, title, description: subtitle, actions: bar ?? action }) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "flex justify-end", children: bar }),
6069
- frame
6281
+ const hideFooter = footerStuck && !scrolledDown;
6282
+ const body = sticky ? /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { ref: wrapRef, className: cn("flex w-full flex-col", bare && className), children: [
6283
+ frame,
6284
+ footer && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6285
+ "div",
6286
+ {
6287
+ "data-sticky-footer": "",
6288
+ style: scrollPad.bottom ? { bottom: -scrollPad.bottom } : void 0,
6289
+ className: cn(
6290
+ "sticky bottom-0 z-3 border-t bg-canvas py-3",
6291
+ footerStuck ? "border-border-default" : "border-transparent",
6292
+ animate && "transition-[opacity,translate] duration-(--mr-motion-duration-interactive) ease-interactive motion-reduce:transition-none",
6293
+ // Hidden, not gone: Tab still reaches it, and focus shows it.
6294
+ hideFooter && "pointer-events-none translate-y-full opacity-0 focus-within:pointer-events-auto focus-within:translate-y-0 focus-within:opacity-100"
6295
+ ),
6296
+ children: footer
6297
+ }
6298
+ )
6299
+ ] }) : frame;
6300
+ if (bare) return body;
6301
+ return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("section", { "aria-labelledby": title ? titleId : void 0, className: cn("flex w-full flex-col gap-3", className), children: [
6302
+ title ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(SectionHeading, { id: titleId, as: titleAs, title, description: subtitle, actions: bar ?? action }) : /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "flex justify-end", children: bar }),
6303
+ body
6070
6304
  ] });
6071
6305
  }
6072
6306
 
6073
6307
  // src/MediaLabel.tsx
6074
- var import_jsx_runtime56 = require("react/jsx-runtime");
6308
+ var import_jsx_runtime57 = require("react/jsx-runtime");
6075
6309
  var FILL = {
6076
6310
  TV: "bg-media-tv",
6077
6311
  CTV: "bg-media-ctv",
@@ -6082,7 +6316,7 @@ var FILL = {
6082
6316
  Magazine: "bg-media-magazine"
6083
6317
  };
6084
6318
  function MediaLabel({ type, className, testIdPrefix }) {
6085
- return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6319
+ return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6086
6320
  "span",
6087
6321
  {
6088
6322
  className: cn(
@@ -6097,10 +6331,10 @@ function MediaLabel({ type, className, testIdPrefix }) {
6097
6331
  }
6098
6332
 
6099
6333
  // src/SuggestionChip.tsx
6100
- var import_react31 = require("react");
6101
- var import_jsx_runtime57 = require("react/jsx-runtime");
6102
- var SuggestionChip = (0, import_react31.forwardRef)(function SuggestionChip2({ children, className, testIdPrefix, type = "button", ...props }, ref) {
6103
- return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6334
+ var import_react32 = require("react");
6335
+ var import_jsx_runtime58 = require("react/jsx-runtime");
6336
+ var SuggestionChip = (0, import_react32.forwardRef)(function SuggestionChip2({ children, className, testIdPrefix, type = "button", ...props }, ref) {
6337
+ return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6104
6338
  "button",
6105
6339
  {
6106
6340
  ref,
@@ -6111,18 +6345,18 @@ var SuggestionChip = (0, import_react31.forwardRef)(function SuggestionChip2({ c
6111
6345
  "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-1 focus-visible:outline-border-focus",
6112
6346
  className
6113
6347
  ),
6114
- children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "truncate", children })
6348
+ children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "truncate", children })
6115
6349
  }
6116
6350
  );
6117
6351
  });
6118
6352
  SuggestionChip.displayName = "SuggestionChip";
6119
6353
 
6120
6354
  // src/ToggleChip.tsx
6121
- var import_react32 = require("react");
6355
+ var import_react33 = require("react");
6122
6356
  var import_lucide_react30 = require("lucide-react");
6123
- var import_jsx_runtime58 = require("react/jsx-runtime");
6124
- var ToggleChip = (0, import_react32.forwardRef)(function ToggleChip2({ selected, onChange, children, className, testIdPrefix, type = "button", onClick, ...props }, ref) {
6125
- return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
6357
+ var import_jsx_runtime59 = require("react/jsx-runtime");
6358
+ var ToggleChip = (0, import_react33.forwardRef)(function ToggleChip2({ selected, onChange, children, className, testIdPrefix, type = "button", onClick, ...props }, ref) {
6359
+ return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
6126
6360
  "button",
6127
6361
  {
6128
6362
  ref,
@@ -6140,7 +6374,7 @@ var ToggleChip = (0, import_react32.forwardRef)(function ToggleChip2({ selected,
6140
6374
  className
6141
6375
  ),
6142
6376
  children: [
6143
- selected && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_lucide_react30.Check, { size: 14, "aria-hidden": "true", className: "-ml-0.5 shrink-0" }),
6377
+ selected && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_lucide_react30.Check, { size: 14, "aria-hidden": "true", className: "-ml-0.5 shrink-0" }),
6144
6378
  children
6145
6379
  ]
6146
6380
  }
@@ -6149,14 +6383,14 @@ var ToggleChip = (0, import_react32.forwardRef)(function ToggleChip2({ selected,
6149
6383
  ToggleChip.displayName = "ToggleChip";
6150
6384
 
6151
6385
  // src/CopyButton.tsx
6152
- var import_react33 = require("react");
6386
+ var import_react34 = require("react");
6153
6387
  var import_lucide_react31 = require("lucide-react");
6154
- var import_jsx_runtime59 = require("react/jsx-runtime");
6388
+ var import_jsx_runtime60 = require("react/jsx-runtime");
6155
6389
  var CONFIRM_MS = 2e3;
6156
- var CopyButton = (0, import_react33.forwardRef)(function CopyButton2({ value, label, "aria-label": ariaLabel, size = "xs", className, testIdPrefix }, ref) {
6157
- const [copied, setCopied] = (0, import_react33.useState)(false);
6158
- const timer = (0, import_react33.useRef)(void 0);
6159
- (0, import_react33.useEffect)(() => () => clearTimeout(timer.current), []);
6390
+ var CopyButton = (0, import_react34.forwardRef)(function CopyButton2({ value, label, "aria-label": ariaLabel, size = "xs", className, testIdPrefix }, ref) {
6391
+ const [copied, setCopied] = (0, import_react34.useState)(false);
6392
+ const timer = (0, import_react34.useRef)(void 0);
6393
+ (0, import_react34.useEffect)(() => () => clearTimeout(timer.current), []);
6160
6394
  const copy = async () => {
6161
6395
  try {
6162
6396
  await navigator.clipboard.writeText(typeof value === "function" ? value() : value);
@@ -6168,8 +6402,8 @@ var CopyButton = (0, import_react33.forwardRef)(function CopyButton2({ value, la
6168
6402
  timer.current = setTimeout(() => setCopied(false), CONFIRM_MS);
6169
6403
  };
6170
6404
  const iconSize = size === "xs" ? 13 : 15;
6171
- const icon = copied ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_lucide_react31.Check, { size: iconSize, "aria-hidden": "true", className: "shrink-0 text-text-success" }) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_lucide_react31.Copy, { size: iconSize, "aria-hidden": "true", className: "shrink-0" });
6172
- return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
6405
+ const icon = copied ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_lucide_react31.Check, { size: iconSize, "aria-hidden": "true", className: "shrink-0 text-text-success" }) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_lucide_react31.Copy, { size: iconSize, "aria-hidden": "true", className: "shrink-0" });
6406
+ return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
6173
6407
  Button,
6174
6408
  {
6175
6409
  ref,
@@ -6183,8 +6417,8 @@ var CopyButton = (0, import_react33.forwardRef)(function CopyButton2({ value, la
6183
6417
  className: cn(!copied && "text-text-secondary", className),
6184
6418
  children: [
6185
6419
  icon,
6186
- label && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { children: copied ? "Copied" : label }),
6187
- /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { role: "status", className: "sr-only", children: copied ? "Copied" : "" })
6420
+ label && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { children: copied ? "Copied" : label }),
6421
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { role: "status", className: "sr-only", children: copied ? "Copied" : "" })
6188
6422
  ]
6189
6423
  }
6190
6424
  );
@@ -6193,7 +6427,7 @@ CopyButton.displayName = "CopyButton";
6193
6427
 
6194
6428
  // src/InlineMessage.tsx
6195
6429
  var import_lucide_react32 = require("lucide-react");
6196
- var import_jsx_runtime60 = require("react/jsx-runtime");
6430
+ var import_jsx_runtime61 = require("react/jsx-runtime");
6197
6431
  var BOX = {
6198
6432
  info: "border-brand-primaryAction/30 bg-brand-primaryAction/10",
6199
6433
  success: "border-status-success/40 bg-status-success/10",
@@ -6210,27 +6444,27 @@ var ICON_INK = {
6210
6444
  var ICON2 = { info: import_lucide_react32.Info, success: import_lucide_react32.CheckCircle2, warning: import_lucide_react32.AlertTriangle, danger: import_lucide_react32.XCircle };
6211
6445
  function InlineMessage({ tone = "info", title, children, actions, onDismiss, className, testIdPrefix }) {
6212
6446
  const Icon = ICON2[tone];
6213
- return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
6447
+ return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
6214
6448
  "div",
6215
6449
  {
6216
6450
  role: tone === "warning" || tone === "danger" ? "alert" : "status",
6217
6451
  className: cn("flex items-start gap-2.5 rounded-control border px-3 py-2.5 text-sm", BOX[tone], className),
6218
6452
  "data-testid": testIdPrefix,
6219
6453
  children: [
6220
- /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Icon, { size: 16, "aria-hidden": "true", className: cn("mt-0.5 shrink-0", ICON_INK[tone]) }),
6221
- /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "min-w-0 flex-1", children: [
6222
- /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { className: "font-semibold text-text-primary", children: title }),
6223
- children && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "mt-0.5 text-text-secondary", children }),
6224
- actions && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "mt-2 flex flex-wrap items-center gap-2", children: actions })
6454
+ /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Icon, { size: 16, "aria-hidden": "true", className: cn("mt-0.5 shrink-0", ICON_INK[tone]) }),
6455
+ /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("div", { className: "min-w-0 flex-1", children: [
6456
+ /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("p", { className: "font-semibold text-text-primary", children: title }),
6457
+ children && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "mt-0.5 text-text-secondary", children }),
6458
+ actions && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "mt-2 flex flex-wrap items-center gap-2", children: actions })
6225
6459
  ] }),
6226
- onDismiss && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
6460
+ onDismiss && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
6227
6461
  "button",
6228
6462
  {
6229
6463
  type: "button",
6230
6464
  onClick: onDismiss,
6231
6465
  "aria-label": "Dismiss",
6232
6466
  className: "-mr-1 -mt-0.5 flex size-6 shrink-0 items-center justify-center rounded-control text-text-tertiary hover:bg-subtle hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-border-focus",
6233
- children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_lucide_react32.X, { size: 14, "aria-hidden": "true" })
6467
+ children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_lucide_react32.X, { size: 14, "aria-hidden": "true" })
6234
6468
  }
6235
6469
  )
6236
6470
  ]
@@ -6239,9 +6473,9 @@ function InlineMessage({ tone = "info", title, children, actions, onDismiss, cla
6239
6473
  }
6240
6474
 
6241
6475
  // src/FilterDrawer.tsx
6242
- var import_react34 = require("react");
6476
+ var import_react35 = require("react");
6243
6477
  var import_lucide_react33 = require("lucide-react");
6244
- var import_jsx_runtime61 = require("react/jsx-runtime");
6478
+ var import_jsx_runtime62 = require("react/jsx-runtime");
6245
6479
  var SLIDE_MS = 200;
6246
6480
  function reducedMotion() {
6247
6481
  return typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
@@ -6257,19 +6491,30 @@ function FilterDrawer({
6257
6491
  onApply,
6258
6492
  focus = null,
6259
6493
  size = "sm",
6494
+ hasChanges,
6260
6495
  testIdPrefix
6261
6496
  }) {
6262
- const [view, setViewState] = (0, import_react34.useState)(focus);
6263
- const [leaving, setLeaving] = (0, import_react34.useState)(null);
6264
- const [phase, setPhase] = (0, import_react34.useState)("run");
6265
- const [wasOpen, setWasOpen] = (0, import_react34.useState)(open);
6497
+ const marks = (list) => list.map((x) => `${x.id}:${x.count ?? 0}:${x.badge ?? ""}`).join("|");
6498
+ const [openedWith, setOpenedWith] = (0, import_react35.useState)(() => marks(sections));
6499
+ const [confirming, setConfirming] = (0, import_react35.useState)(false);
6500
+ const [view, setViewState] = (0, import_react35.useState)(focus);
6501
+ const [leaving, setLeaving] = (0, import_react35.useState)(null);
6502
+ const [phase, setPhase] = (0, import_react35.useState)("run");
6503
+ const [wasOpen, setWasOpen] = (0, import_react35.useState)(open);
6266
6504
  if (open !== wasOpen) {
6267
6505
  setWasOpen(open);
6506
+ setConfirming(false);
6268
6507
  if (open) {
6269
6508
  setViewState(focus);
6270
6509
  setLeaving(null);
6510
+ setOpenedWith(marks(sections));
6271
6511
  }
6272
6512
  }
6513
+ const changed = hasChanges ?? marks(sections) !== openedWith;
6514
+ const requestClose = () => {
6515
+ if (changed) setConfirming(true);
6516
+ else onClose();
6517
+ };
6273
6518
  const setView = (next) => {
6274
6519
  if (!reducedMotion()) {
6275
6520
  setLeaving({ view, dir: next ? 1 : -1 });
@@ -6277,20 +6522,20 @@ function FilterDrawer({
6277
6522
  }
6278
6523
  setViewState(next);
6279
6524
  };
6280
- (0, import_react34.useLayoutEffect)(() => {
6525
+ (0, import_react35.useLayoutEffect)(() => {
6281
6526
  if (phase !== "start") return;
6282
6527
  const raf = requestAnimationFrame(() => requestAnimationFrame(() => setPhase("run")));
6283
6528
  return () => cancelAnimationFrame(raf);
6284
6529
  }, [phase]);
6285
- (0, import_react34.useEffect)(() => {
6530
+ (0, import_react35.useEffect)(() => {
6286
6531
  if (!leaving || phase !== "run") return;
6287
6532
  const t = setTimeout(() => setLeaving(null), SLIDE_MS);
6288
6533
  return () => clearTimeout(t);
6289
6534
  }, [leaving, phase]);
6290
- const backRef = (0, import_react34.useRef)(null);
6291
- const rowRefs = (0, import_react34.useRef)(/* @__PURE__ */ new Map());
6292
- const lastView = (0, import_react34.useRef)(null);
6293
- (0, import_react34.useEffect)(() => {
6535
+ const backRef = (0, import_react35.useRef)(null);
6536
+ const rowRefs = (0, import_react35.useRef)(/* @__PURE__ */ new Map());
6537
+ const lastView = (0, import_react35.useRef)(null);
6538
+ (0, import_react35.useEffect)(() => {
6294
6539
  if (!open) return;
6295
6540
  if (view) backRef.current?.focus();
6296
6541
  else if (lastView.current) rowRefs.current.get(lastView.current)?.focus();
@@ -6303,8 +6548,8 @@ function FilterDrawer({
6303
6548
  const outgoing = phase === "start" ? void 0 : dir > 0 ? "translateX(-33%)" : "translateX(100%)";
6304
6549
  const panel = (v, rows = true) => {
6305
6550
  const s = v ? sections.find((x) => x.id === v) : void 0;
6306
- if (s) return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "border-t border-border-default px-5 pt-4", children: renderSection(s.id) });
6307
- return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("ul", { className: "border-t border-border-default", children: sections.map((x) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("li", { className: "border-b border-border-default", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
6551
+ if (s) return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "border-t border-border-default px-5 pt-4", children: renderSection(s.id) });
6552
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("ul", { className: "border-t border-border-default", children: sections.map((x) => /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("li", { className: "border-b border-border-default", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
6308
6553
  "button",
6309
6554
  {
6310
6555
  ref: rows ? (el) => {
@@ -6316,7 +6561,7 @@ function FilterDrawer({
6316
6561
  "data-testid": testIdPrefix && `${testIdPrefix}-row-${x.id}`,
6317
6562
  className: "flex w-full items-center gap-3 px-5 py-3.5 text-left transition-colors hover:bg-subtle focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
6318
6563
  children: [
6319
- /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
6564
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
6320
6565
  x.icon,
6321
6566
  {
6322
6567
  size: 17,
@@ -6324,100 +6569,132 @@ function FilterDrawer({
6324
6569
  className: inUse(x) ? "text-brand-primaryAction" : "text-text-secondary"
6325
6570
  }
6326
6571
  ),
6327
- /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { className: "flex-1 text-sm font-medium text-text-primary", children: x.label }),
6328
- /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(SectionMark, { section: x }),
6329
- /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_lucide_react33.ChevronRight, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-secondary" })
6572
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "flex-1 text-sm font-medium text-text-primary", children: x.label }),
6573
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(SectionMark, { section: x }),
6574
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_lucide_react33.ChevronRight, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-secondary" })
6330
6575
  ]
6331
6576
  }
6332
6577
  ) }, x.id)) });
6333
6578
  };
6334
- return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
6335
- Drawer,
6336
- {
6337
- open,
6338
- onClose,
6339
- size,
6340
- testIdPrefix,
6341
- title: focused ? /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("span", { className: "flex items-center gap-1.5", children: [
6342
- /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
6343
- "button",
6344
- {
6345
- ref: backRef,
6346
- type: "button",
6347
- onClick: () => setView(null),
6348
- "aria-label": "Back to all filters",
6349
- "data-testid": testIdPrefix && `${testIdPrefix}-back`,
6350
- className: "-ml-1.5 rounded-control p-1 text-text-secondary hover:bg-subtle hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-border-focus",
6351
- children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_lucide_react33.ChevronLeft, { size: 18, "aria-hidden": "true" })
6352
- }
6353
- ),
6354
- focused.label,
6355
- (focused.count ?? 0) > 0 && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(CountBadge, { count: focused.count }),
6356
- focused.info && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(InfoTip, { text: focused.info, label: `About ${focused.label}` })
6357
- ] }) : "Filters",
6358
- footer: focused ? (
6359
- // Picks are kept as they're made; only See results, on the list, applies them.
6360
- /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "flex w-full items-center", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Button, { variant: "link", size: "md", onClick: () => onClearSection(focused.id), className: "px-0", children: "Clear" }) })
6361
- ) : /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("div", { className: "flex w-full items-center justify-between gap-2", children: [
6362
- /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Button, { variant: "link", size: "md", onClick: onClearAll, className: "px-0", children: "Clear all" }),
6363
- /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("div", { className: "flex items-center gap-2", children: [
6364
- /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Button, { variant: "secondary", size: "md", onClick: onClose, children: "Cancel" }),
6365
- /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
6579
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
6580
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
6581
+ Modal,
6582
+ {
6583
+ open: open && confirming,
6584
+ onClose: () => setConfirming(false),
6585
+ size: "sm",
6586
+ title: "Discard changes?",
6587
+ description: "Your filter picks haven't been applied.",
6588
+ testIdPrefix: testIdPrefix && `${testIdPrefix}-discard`,
6589
+ footer: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
6590
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Button, { variant: "secondary", size: "md", onClick: () => setConfirming(false), children: "Keep editing" }),
6591
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
6366
6592
  Button,
6367
6593
  {
6368
- variant: "primary",
6594
+ variant: "danger",
6369
6595
  size: "md",
6370
6596
  onClick: () => {
6371
- onApply();
6597
+ setConfirming(false);
6372
6598
  onClose();
6373
6599
  },
6374
- children: "See results"
6600
+ children: "Discard"
6375
6601
  }
6376
6602
  )
6377
6603
  ] })
6378
- ] }),
6379
- children: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("div", { className: "relative -mx-5 overflow-x-clip", children: [
6380
- /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
6381
- "div",
6382
- {
6383
- style: { transform: incoming },
6384
- className: cn(moving && "transition-transform duration-(--mr-motion-duration-interactive) ease-interactive motion-reduce:transition-none"),
6385
- children: panel(view)
6386
- },
6387
- view ?? "__list"
6388
- ),
6389
- leaving && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
6390
- "div",
6391
- {
6392
- "aria-hidden": "true",
6393
- ref: (el) => el?.setAttribute("inert", ""),
6394
- style: { transform: outgoing, opacity: phase === "start" ? 1 : dir > 0 ? 0.4 : 1 },
6395
- className: "pointer-events-none absolute inset-x-0 top-0 transition duration-(--mr-motion-duration-interactive) ease-interactive motion-reduce:transition-none",
6396
- children: panel(leaving.view, false)
6397
- }
6398
- )
6399
- ] })
6400
- }
6401
- );
6604
+ }
6605
+ ),
6606
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
6607
+ Drawer,
6608
+ {
6609
+ open,
6610
+ onClose: requestClose,
6611
+ size,
6612
+ testIdPrefix,
6613
+ title: focused ? /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("span", { className: "flex items-center gap-1.5", children: [
6614
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
6615
+ "button",
6616
+ {
6617
+ ref: backRef,
6618
+ type: "button",
6619
+ onClick: () => setView(null),
6620
+ "aria-label": "Back to all filters",
6621
+ "data-testid": testIdPrefix && `${testIdPrefix}-back`,
6622
+ className: "-ml-1.5 rounded-control p-1 text-text-secondary hover:bg-subtle hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-border-focus",
6623
+ children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_lucide_react33.ChevronLeft, { size: 18, "aria-hidden": "true" })
6624
+ }
6625
+ ),
6626
+ focused.label,
6627
+ (focused.count ?? 0) > 0 && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(CountBadge, { count: focused.count }),
6628
+ focused.info && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(InfoTip, { text: focused.info, label: `About ${focused.label}` })
6629
+ ] }) : "Filters",
6630
+ footer: focused ? (
6631
+ // Picks are kept as they're made; Apply goes back to the list, and only
6632
+ // See results, on the list, applies them to the page.
6633
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "flex w-full items-center justify-between gap-2", children: [
6634
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Button, { variant: "link", size: "md", onClick: () => onClearSection(focused.id), className: "px-0", children: "Clear" }),
6635
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Button, { variant: "primary", size: "md", onClick: () => setView(null), testIdPrefix: testIdPrefix && `${testIdPrefix}-apply-section`, children: "Apply" })
6636
+ ] })
6637
+ ) : /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "flex w-full items-center justify-between gap-2", children: [
6638
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Button, { variant: "link", size: "md", onClick: onClearAll, className: "px-0", children: "Clear all" }),
6639
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "flex items-center gap-2", children: [
6640
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Button, { variant: "secondary", size: "md", onClick: onClose, children: "Cancel" }),
6641
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
6642
+ Button,
6643
+ {
6644
+ variant: "primary",
6645
+ size: "md",
6646
+ onClick: () => {
6647
+ onApply();
6648
+ onClose();
6649
+ },
6650
+ children: "See results"
6651
+ }
6652
+ )
6653
+ ] })
6654
+ ] }),
6655
+ children: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "relative -mx-5 overflow-x-clip", children: [
6656
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
6657
+ "div",
6658
+ {
6659
+ style: { transform: incoming },
6660
+ className: cn(moving && "transition-transform duration-(--mr-motion-duration-interactive) ease-interactive motion-reduce:transition-none"),
6661
+ children: panel(view)
6662
+ },
6663
+ view ?? "__list"
6664
+ ),
6665
+ leaving && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
6666
+ "div",
6667
+ {
6668
+ "aria-hidden": "true",
6669
+ ref: (el) => el?.setAttribute("inert", ""),
6670
+ style: { transform: outgoing, opacity: phase === "start" ? 1 : dir > 0 ? 0.4 : 1 },
6671
+ className: "pointer-events-none absolute inset-x-0 top-0 transition duration-(--mr-motion-duration-interactive) ease-interactive motion-reduce:transition-none",
6672
+ children: panel(leaving.view, false)
6673
+ }
6674
+ )
6675
+ ] })
6676
+ }
6677
+ )
6678
+ ] });
6402
6679
  }
6403
6680
  var inUse = (x) => (x.count ?? 0) > 0 || !!x.badge;
6404
6681
  function CountBadge({ count }) {
6405
- return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(Badge, { tone: "brandSolid", kind: "count", children: [
6682
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Badge, { tone: "brandSolid", kind: "count", children: [
6406
6683
  count,
6407
- /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { className: "sr-only", children: " selected" })
6684
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "sr-only", children: " selected" })
6408
6685
  ] });
6409
6686
  }
6410
6687
  function SectionMark({ section }) {
6411
- if ((section.count ?? 0) > 0) return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(CountBadge, { count: section.count });
6412
- return section.badge ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Badge, { tone: "brand", children: section.badge }) : null;
6688
+ if ((section.count ?? 0) > 0) return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(CountBadge, { count: section.count });
6689
+ return section.badge ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Badge, { tone: "brand", children: section.badge }) : null;
6413
6690
  }
6414
6691
 
6415
6692
  // src/AllFiltersButton.tsx
6416
- var import_react35 = require("react");
6693
+ var import_react36 = require("react");
6417
6694
  var import_lucide_react34 = require("lucide-react");
6418
- var import_jsx_runtime62 = require("react/jsx-runtime");
6419
- var AllFiltersButton = (0, import_react35.forwardRef)(function AllFiltersButton2({ count = 0, open, className, testIdPrefix, ...rest }, ref) {
6420
- return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
6695
+ var import_jsx_runtime63 = require("react/jsx-runtime");
6696
+ var AllFiltersButton = (0, import_react36.forwardRef)(function AllFiltersButton2({ count = 0, open, className, testIdPrefix, ...rest }, ref) {
6697
+ return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
6421
6698
  "button",
6422
6699
  {
6423
6700
  ref,
@@ -6429,19 +6706,19 @@ var AllFiltersButton = (0, import_react35.forwardRef)(function AllFiltersButton2
6429
6706
  className: cn(chipTriggerClass(), className),
6430
6707
  ...rest,
6431
6708
  children: [
6432
- /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_lucide_react34.SlidersHorizontal, { size: 15, "aria-hidden": "true", className: "text-text-secondary" }),
6433
- /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "text-dense font-medium text-text-primary", children: "All filters" }),
6434
- count > 0 && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Badge, { tone: "brandSolid", kind: "count", children: count })
6709
+ /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_lucide_react34.SlidersHorizontal, { size: 15, "aria-hidden": "true", className: "text-text-secondary" }),
6710
+ /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { className: "text-dense font-medium text-text-primary", children: "All filters" }),
6711
+ count > 0 && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Badge, { tone: "brandSolid", kind: "count", children: count })
6435
6712
  ]
6436
6713
  }
6437
6714
  );
6438
6715
  });
6439
6716
 
6440
6717
  // src/Menu.tsx
6441
- var import_react36 = require("react");
6718
+ var import_react37 = require("react");
6442
6719
  var import_react_slot2 = require("@radix-ui/react-slot");
6443
6720
  var import_lucide_react35 = require("lucide-react");
6444
- var import_jsx_runtime63 = require("react/jsx-runtime");
6721
+ var import_jsx_runtime64 = require("react/jsx-runtime");
6445
6722
  var ROW_SELECTOR = '[role^="menuitem"]:not([aria-disabled="true"]):not(:disabled)';
6446
6723
  function moveFocus(e) {
6447
6724
  const keys = ["ArrowDown", "ArrowUp", "Home", "End"];
@@ -6453,8 +6730,8 @@ function moveFocus(e) {
6453
6730
  const next = e.key === "Home" ? 0 : e.key === "End" ? rows.length - 1 : e.key === "ArrowDown" ? (i + 1) % rows.length : (i - 1 + rows.length) % rows.length;
6454
6731
  rows[next].focus();
6455
6732
  }
6456
- var Menu = (0, import_react36.forwardRef)(
6457
- ({ className, testIdPrefix, onKeyDown, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
6733
+ var Menu = (0, import_react37.forwardRef)(
6734
+ ({ className, testIdPrefix, onKeyDown, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
6458
6735
  "div",
6459
6736
  {
6460
6737
  ref,
@@ -6471,24 +6748,11 @@ var Menu = (0, import_react36.forwardRef)(
6471
6748
  )
6472
6749
  );
6473
6750
  Menu.displayName = "Menu";
6474
- var MenuItem = (0, import_react36.forwardRef)(
6751
+ var MenuItem = (0, import_react37.forwardRef)(
6475
6752
  ({ className, testIdPrefix, icon, trailing, description, submenu, checked, danger, disabled, asChild = false, children, ...props }, ref) => {
6476
6753
  const Comp = asChild ? import_react_slot2.Slot : "button";
6477
6754
  const radio = checked !== void 0;
6478
- const body = /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
6479
- icon && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { "aria-hidden": "true", className: cn("flex shrink-0", danger ? "text-text-danger" : "text-text-secondary"), children: icon }),
6480
- asChild ? (
6481
- // The link's own text lands here; the link becomes the row.
6482
- /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_react_slot2.Slottable, { children })
6483
- ) : /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("span", { className: "min-w-0 flex-1", children: [
6484
- /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { className: "block truncate", children }),
6485
- description && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { className: "block truncate text-xs text-text-tertiary", children: description })
6486
- ] }),
6487
- trailing && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { className: "ml-auto flex shrink-0 items-center text-xs text-text-secondary", children: trailing }),
6488
- radio && checked && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_lucide_react35.Check, { size: 16, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }),
6489
- submenu && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_lucide_react35.ChevronRight, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-secondary" })
6490
- ] });
6491
- return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
6755
+ return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
6492
6756
  Comp,
6493
6757
  {
6494
6758
  ref,
@@ -6508,14 +6772,26 @@ var MenuItem = (0, import_react36.forwardRef)(
6508
6772
  className
6509
6773
  ),
6510
6774
  ...props,
6511
- children: body
6775
+ children: [
6776
+ icon && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { "aria-hidden": "true", className: cn("flex shrink-0", danger ? "text-text-danger" : "text-text-secondary"), children: icon }),
6777
+ asChild ? (
6778
+ // The link's own text lands here; the link becomes the row.
6779
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_react_slot2.Slottable, { children })
6780
+ ) : /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("span", { className: "min-w-0 flex-1", children: [
6781
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "block truncate", children }),
6782
+ description && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "block truncate text-xs text-text-tertiary", children: description })
6783
+ ] }),
6784
+ trailing && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "ml-auto flex shrink-0 items-center text-xs text-text-secondary", children: trailing }),
6785
+ radio && checked && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_lucide_react35.Check, { size: 16, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }),
6786
+ submenu && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_lucide_react35.ChevronRight, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-secondary" })
6787
+ ]
6512
6788
  }
6513
6789
  );
6514
6790
  }
6515
6791
  );
6516
6792
  MenuItem.displayName = "MenuItem";
6517
6793
  function MenuLabel({ className, testIdPrefix, children }) {
6518
- return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
6794
+ return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
6519
6795
  "div",
6520
6796
  {
6521
6797
  role: "presentation",
@@ -6526,7 +6802,7 @@ function MenuLabel({ className, testIdPrefix, children }) {
6526
6802
  );
6527
6803
  }
6528
6804
  function MenuSeparator({ className, testIdPrefix }) {
6529
- return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { role: "separator", "data-testid": testIdPrefix, className: cn("-mx-1 my-1 border-t border-border-default", className) });
6805
+ return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { role: "separator", "data-testid": testIdPrefix, className: cn("-mx-1 my-1 border-t border-border-default", className) });
6530
6806
  }
6531
6807
 
6532
6808
  // src/dates.ts
@@ -6640,15 +6916,15 @@ function defaultDateOrder(country) {
6640
6916
  }
6641
6917
 
6642
6918
  // src/Figure.tsx
6643
- var import_jsx_runtime64 = require("react/jsx-runtime");
6919
+ var import_jsx_runtime65 = require("react/jsx-runtime");
6644
6920
  function Figure({ value, kind = "money", missing, ...opts }) {
6645
- if (value === null || value === void 0 || Number.isNaN(value)) return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(NoValue, { reason: missing });
6921
+ if (value === null || value === void 0 || Number.isNaN(value)) return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(NoValue, { reason: missing });
6646
6922
  const short = kind === "money" ? formatMoney(value, opts) : formatCount(value, opts);
6647
6923
  const full = kind === "money" ? formatMoneyFull(value, opts) : formatCountFull(value);
6648
- if (short === full) return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_jsx_runtime64.Fragment, { children: short });
6649
- return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Tooltip, { label: full, delay: 300, children: [
6650
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { "aria-hidden": "true", children: short }),
6651
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "sr-only", children: full })
6924
+ if (short === full) return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_jsx_runtime65.Fragment, { children: short });
6925
+ return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(Tooltip, { label: full, delay: 300, children: [
6926
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { "aria-hidden": "true", children: short }),
6927
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "sr-only", children: full })
6652
6928
  ] });
6653
6929
  }
6654
6930
  // Annotate the CommonJS export names for ESM import in node:
@@ -6724,6 +7000,7 @@ function Figure({ value, kind = "money", missing, ...opts }) {
6724
7000
  StatStrip,
6725
7001
  StatStripSkeleton,
6726
7002
  StatTile,
7003
+ StickyBar,
6727
7004
  SuggestionChip,
6728
7005
  TableLink,
6729
7006
  TablePagination,