@mediaradar/design-components 0.63.1 → 0.65.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,
@@ -4083,6 +4084,8 @@ function FilterDropdownFooter({
4083
4084
  onApply,
4084
4085
  clearLabel = "Clear all",
4085
4086
  applyLabel = "Apply",
4087
+ onCancel,
4088
+ cancelLabel = "Cancel",
4086
4089
  className,
4087
4090
  testIdPrefix
4088
4091
  }) {
@@ -4097,7 +4100,10 @@ function FilterDropdownFooter({
4097
4100
  "data-testid": testIdPrefix,
4098
4101
  children: [
4099
4102
  onClear && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Button, { type: "button", variant: "ghost", size: "sm", onClick: onClear, children: clearLabel }),
4100
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Button, { type: "button", variant: "primary", size: "sm", onClick: onApply, children: applyLabel })
4103
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex items-center gap-2", children: [
4104
+ onCancel && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Button, { type: "button", variant: "secondary", size: "sm", onClick: onCancel, children: cancelLabel }),
4105
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Button, { type: "button", variant: "primary", size: "sm", onClick: onApply, children: applyLabel })
4106
+ ] })
4101
4107
  ]
4102
4108
  }
4103
4109
  );
@@ -4310,6 +4316,15 @@ var SortButton = (0, import_react21.forwardRef)(
4310
4316
  return description ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(HeaderTip, { description, children: plain }) : plain;
4311
4317
  }
4312
4318
  const active = !disabled && sort.key === sortKey;
4319
+ const iconFirst = align === "right";
4320
+ const icon = disabled ? null : active ? sort.dir === "asc" ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_lucide_react19.ArrowUp, { size: 12, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }) : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_lucide_react19.ArrowDown, { size: 12, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }) : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4321
+ import_lucide_react19.ArrowUpDown,
4322
+ {
4323
+ size: 12,
4324
+ "aria-hidden": "true",
4325
+ className: "shrink-0 text-text-tertiary opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100 group-hover/head:opacity-100 pointer-coarse:opacity-50"
4326
+ }
4327
+ );
4313
4328
  const button = /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
4314
4329
  "button",
4315
4330
  {
@@ -4340,15 +4355,9 @@ var SortButton = (0, import_react21.forwardRef)(
4340
4355
  className
4341
4356
  ),
4342
4357
  children: [
4358
+ iconFirst && icon,
4343
4359
  text,
4344
- !disabled && (active ? sort.dir === "asc" ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_lucide_react19.ArrowUp, { size: 12, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }) : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_lucide_react19.ArrowDown, { size: 12, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }) : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4345
- import_lucide_react19.ArrowUpDown,
4346
- {
4347
- size: 12,
4348
- "aria-hidden": "true",
4349
- className: "shrink-0 text-text-tertiary opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100 group-hover/head:opacity-100 pointer-coarse:opacity-50"
4350
- }
4351
- ))
4360
+ !iconFirst && icon
4352
4361
  ]
4353
4362
  }
4354
4363
  );
@@ -4746,6 +4755,7 @@ function DateRangePicker({
4746
4755
  years,
4747
4756
  formatDate: formatDate2,
4748
4757
  formatRange,
4758
+ caption,
4749
4759
  className,
4750
4760
  testIdPrefix
4751
4761
  }) {
@@ -4755,6 +4765,7 @@ function DateRangePicker({
4755
4765
  const [value, setValue] = (0, import_react23.useState)(defaultValue);
4756
4766
  const [draft, setDraft] = (0, import_react23.useState)(defaultValue);
4757
4767
  const ref = (0, import_react23.useRef)(null);
4768
+ const triggerRef = (0, import_react23.useRef)(null);
4758
4769
  const [fromMo, setFromMo] = (0, import_react23.useState)(end.getMonth());
4759
4770
  const [fromYr, setFromYr] = (0, import_react23.useState)(end.getFullYear() - 1);
4760
4771
  const [toMo, setToMo] = (0, import_react23.useState)(end.getMonth());
@@ -4799,13 +4810,14 @@ function DateRangePicker({
4799
4810
  /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
4800
4811
  "button",
4801
4812
  {
4813
+ ref: triggerRef,
4802
4814
  type: "button",
4803
4815
  onClick: toggleOpen,
4804
4816
  "aria-expanded": open,
4805
4817
  "aria-haspopup": "listbox",
4806
4818
  className: chipTriggerClass(),
4807
4819
  children: [
4808
- /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("span", { className: "flex flex-col gap-1 text-left leading-none", children: [
4820
+ caption ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ChipContent, { caption, value }) : /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("span", { className: "flex flex-col gap-1 text-left leading-none", children: [
4809
4821
  /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-control-caption leading-none text-text-tertiary", children: spanLabel2(value, end, formatDate2, formatRange) }),
4810
4822
  /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-xs leading-none font-medium text-text-primary", children: value })
4811
4823
  ] }),
@@ -4813,6 +4825,7 @@ function DateRangePicker({
4813
4825
  ]
4814
4826
  }
4815
4827
  ),
4828
+ caption && !open && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Tooltip, { anchorRef: triggerRef, label: spanLabel2(value, end, formatDate2, formatRange), delay: 300, placement: "top" }),
4816
4829
  open && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: cn("absolute top-full mt-2 z-30 w-70 overflow-hidden rounded-card border border-border-default bg-surface py-1 shadow-overlay", align === "right" ? "right-0" : "left-0"), children: [
4817
4830
  presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4818
4831
  "button",
@@ -4891,12 +4904,18 @@ function MultiSelectFilter({
4891
4904
  valueLabel,
4892
4905
  hints,
4893
4906
  note,
4907
+ hideCaption = false,
4908
+ size = "md",
4909
+ inlineCaption = false,
4910
+ max,
4911
+ maxReason,
4894
4912
  className,
4895
4913
  testIdPrefix
4896
4914
  }) {
4897
4915
  const groupLeaves = (g) => g.children.length ? g.children : [{ id: g.id, label: g.label }];
4898
4916
  const leafOptions = groups ? groups.flatMap(groupLeaves) : options;
4899
4917
  const showSearch = searchable ?? leafOptions.length > SEARCH_AFTER;
4918
+ const sm = size === "sm";
4900
4919
  const [open, setOpen] = (0, import_react24.useState)(false);
4901
4920
  const [q, setQ] = (0, import_react24.useState)("");
4902
4921
  const [draft, setDraft] = (0, import_react24.useState)(selected);
@@ -4937,9 +4956,12 @@ function MultiSelectFilter({
4937
4956
  window.removeEventListener("mousedown", onClick);
4938
4957
  };
4939
4958
  }, [open, close]);
4959
+ const capReason = maxReason ?? `Up to ${max}. Untick one to add another.`;
4960
+ const overCap = (n) => max !== void 0 && n > max;
4940
4961
  const toggle = (id) => setDraft((cur) => {
4941
4962
  const next = cur.includes(id) ? cur.filter((x) => x !== id) : [...cur, id];
4942
4963
  if (next.length < min) return cur;
4964
+ if (!cur.includes(id) && overCap(next.length)) return cur;
4943
4965
  return next;
4944
4966
  });
4945
4967
  const toggleGroup = (g) => setDraft((cur) => {
@@ -4948,8 +4970,40 @@ function MultiSelectFilter({
4948
4970
  const allSel = ids.every((id) => cur.includes(id));
4949
4971
  const next = allSel ? cur.filter((id) => !ids.includes(id)) : [.../* @__PURE__ */ new Set([...cur, ...ids])];
4950
4972
  if (next.length < min) return cur;
4973
+ if (!allSel && overCap(next.length)) return cur;
4951
4974
  return next;
4952
4975
  });
4976
+ const blockedLeaf = (id) => !draft.includes(id) && overCap(draft.length + 1) ? capReason : null;
4977
+ const blockedGroup = (g) => {
4978
+ if (max === void 0) return null;
4979
+ const ids = groupLeaves(g).map((c) => c.id).filter((id) => !counts || (counts[id] ?? 0) > 0 || draft.includes(id));
4980
+ if (!ids.length || ids.every((id) => draft.includes(id))) return null;
4981
+ return overCap((/* @__PURE__ */ new Set([...draft, ...ids])).size) ? capReason : null;
4982
+ };
4983
+ const row = (opts) => {
4984
+ const button = /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
4985
+ "button",
4986
+ {
4987
+ type: "button",
4988
+ role: "checkbox",
4989
+ "aria-checked": opts.indeterminate ? "mixed" : opts.checked,
4990
+ "aria-disabled": opts.blocked ? "true" : void 0,
4991
+ onClick: opts.blocked ? void 0 : opts.onClick,
4992
+ className: cn(
4993
+ "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",
4994
+ opts.indent ? "pl-9 pr-2" : "px-2",
4995
+ opts.blocked ? "cursor-not-allowed" : "hover:bg-subtle"
4996
+ ),
4997
+ children: [
4998
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CheckBoxBox, { checked: opts.checked, indeterminate: opts.indeterminate, disabled: !!opts.blocked }),
4999
+ /* @__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 }),
5000
+ opts.count
5001
+ ]
5002
+ },
5003
+ opts.key
5004
+ );
5005
+ return opts.blocked ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Tooltip, { label: opts.blocked, delay: 300, className: "flex w-full", children: button }, opts.key) : button;
5006
+ };
4953
5007
  const isAvailable = (id) => !counts || (counts[id] ?? 0) > 0 || draft.includes(id);
4954
5008
  const countFor = (id) => counts?.[id] ?? 0;
4955
5009
  const groupState = (g) => {
@@ -4981,10 +5035,27 @@ function MultiSelectFilter({
4981
5035
  type: "button",
4982
5036
  onClick: () => open ? close() : openTray(),
4983
5037
  "aria-expanded": open,
5038
+ "aria-label": sm && !inlineCaption || !sm && hideCaption ? caption : void 0,
4984
5039
  "data-testid": testIdPrefix && `${testIdPrefix}-trigger`,
4985
- className: cn(chipTriggerClass(variant), fullWidth && "w-full justify-between"),
5040
+ className: cn(
5041
+ sm ? "flex h-8 items-center gap-1.5 rounded-control border border-border-strong bg-input pl-2.5 pr-2 text-dense font-medium text-text-primary transition-colors hover:bg-subtle focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-border-focus" : 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),
5042
+ fullWidth && "w-full justify-between"
5043
+ ),
4986
5044
  children: [
4987
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ChipContent, { caption, value, icon }),
5045
+ sm ? /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "flex items-center gap-1.5", children: [
5046
+ icon && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "shrink-0 text-text-tertiary", children: icon }),
5047
+ inlineCaption ? /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { children: [
5048
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "font-normal text-text-secondary", children: [
5049
+ caption,
5050
+ ":"
5051
+ ] }),
5052
+ " ",
5053
+ value
5054
+ ] }) : value
5055
+ ] }) : hideCaption ? /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "flex items-center gap-2", children: [
5056
+ icon && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "shrink-0 text-text-tertiary", children: icon }),
5057
+ value
5058
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ChipContent, { caption, value, icon }),
4988
5059
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4989
5060
  import_lucide_react24.ChevronDown,
4990
5061
  {
@@ -5026,54 +5097,38 @@ function MultiSelectFilter({
5026
5097
  groups ? visibleGroups.map((g) => {
5027
5098
  const state = groupState(g);
5028
5099
  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
- })
5100
+ row({
5101
+ key: g.id,
5102
+ onClick: () => toggleGroup(g),
5103
+ checked: state === "all",
5104
+ indeterminate: state === "some",
5105
+ label: labelled(g.id, g.label),
5106
+ count: counts && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(OptionCount, { n: countFor(g.id) }),
5107
+ bold: !plainParent,
5108
+ blocked: blockedGroup(g)
5109
+ }),
5110
+ g.children.map(
5111
+ (c) => row({
5112
+ key: c.id,
5113
+ onClick: () => toggle(c.id),
5114
+ checked: draft.includes(c.id),
5115
+ label: labelled(c.id, c.label),
5116
+ count: counts && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(OptionCount, { n: countFor(c.id) }),
5117
+ indent: true,
5118
+ blocked: blockedLeaf(c.id)
5119
+ })
5120
+ )
5059
5121
  ] }, 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
- }),
5122
+ }) : items.map(
5123
+ (o) => row({
5124
+ key: o.id,
5125
+ onClick: () => toggle(o.id),
5126
+ checked: draft.includes(o.id),
5127
+ label: labelled(o.id, o.label),
5128
+ count: counts && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(OptionCount, { n: countFor(o.id) }),
5129
+ blocked: blockedLeaf(o.id)
5130
+ })
5131
+ ),
5077
5132
  (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
5133
  ] }),
5079
5134
  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,8 +5602,8 @@ function Drawer({ open, onClose, title, description, size = "sm", footer, childr
5547
5602
  }
5548
5603
 
5549
5604
  // src/DataTable.tsx
5550
- var import_react30 = require("react");
5551
- var import_lucide_react29 = require("lucide-react");
5605
+ var import_react33 = require("react");
5606
+ var import_lucide_react31 = require("lucide-react");
5552
5607
 
5553
5608
  // src/numbers.ts
5554
5609
  var US = { units: ["K", "M", "B", "T"] };
@@ -5606,12 +5661,425 @@ function formatPercent(value, _opts = {}) {
5606
5661
  return text === "0.0" ? "0.0%" : `${sign(value)}${text}%`;
5607
5662
  }
5608
5663
 
5609
- // src/DataTable.tsx
5664
+ // src/StickyBar.tsx
5665
+ var import_react30 = require("react");
5610
5666
  var import_jsx_runtime55 = require("react/jsx-runtime");
5667
+ function scrollParent(el) {
5668
+ if (typeof window === "undefined") return null;
5669
+ for (let p = el?.parentElement ?? null; p && p !== document.body && p !== document.documentElement; p = p.parentElement) {
5670
+ const y = window.getComputedStyle(p).overflowY;
5671
+ if (y === "auto" || y === "scroll" || y === "overlay") return p;
5672
+ }
5673
+ return null;
5674
+ }
5675
+ function viewportOf(root) {
5676
+ if (!root) return { top: 0, bottom: window.innerHeight };
5677
+ const r = root.getBoundingClientRect();
5678
+ return { top: r.top + root.clientTop, bottom: r.top + root.clientTop + root.clientHeight };
5679
+ }
5680
+ function scrollPadding(root) {
5681
+ if (!root) return { top: 0, bottom: 0 };
5682
+ const cs = window.getComputedStyle(root);
5683
+ return { top: parseFloat(cs.paddingTop) || 0, bottom: parseFloat(cs.paddingBottom) || 0 };
5684
+ }
5685
+ var STICKY_BAR_ATTR = "data-sticky-bar";
5686
+ function StickyBar({ children, className, testIdPrefix }) {
5687
+ const ref = (0, import_react30.useRef)(null);
5688
+ const [stuck, setStuck] = (0, import_react30.useState)(false);
5689
+ const [pad2, setPad] = (0, import_react30.useState)(0);
5690
+ const [edges, setEdges] = (0, import_react30.useState)({ left: 0, right: 0 });
5691
+ (0, import_react30.useEffect)(() => {
5692
+ const el = ref.current;
5693
+ const parent = el?.parentElement;
5694
+ if (!el || !parent) return void 0;
5695
+ let root = scrollParent(el);
5696
+ const update = () => setStuck(el.getBoundingClientRect().top <= viewportOf(root).top + 0.5 && (root ? root.scrollTop : window.scrollY) > 0);
5697
+ const resize = () => {
5698
+ root = scrollParent(el);
5699
+ setPad(scrollPadding(root).top);
5700
+ const pr = parent.getBoundingClientRect();
5701
+ const ps = window.getComputedStyle(parent);
5702
+ const colLeft = pr.left + parent.clientLeft + (parseFloat(ps.paddingLeft) || 0);
5703
+ const colRight = pr.left + parent.clientLeft + parent.clientWidth - (parseFloat(ps.paddingRight) || 0);
5704
+ const rr = root?.getBoundingClientRect();
5705
+ const boxLeft = root && rr ? rr.left + root.clientLeft : 0;
5706
+ const boxRight = root && rr ? rr.left + root.clientLeft + root.clientWidth : document.documentElement.clientWidth;
5707
+ const next = { left: Math.max(0, colLeft - boxLeft), right: Math.max(0, boxRight - colRight) };
5708
+ setEdges((prev) => prev.left === next.left && prev.right === next.right ? prev : next);
5709
+ update();
5710
+ };
5711
+ resize();
5712
+ document.addEventListener("scroll", update, { capture: true, passive: true });
5713
+ window.addEventListener("resize", resize);
5714
+ const ro = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(resize);
5715
+ ro?.observe(parent);
5716
+ return () => {
5717
+ document.removeEventListener("scroll", update, { capture: true });
5718
+ window.removeEventListener("resize", resize);
5719
+ ro?.disconnect();
5720
+ };
5721
+ }, []);
5722
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5723
+ "div",
5724
+ {
5725
+ ref,
5726
+ ...{ [STICKY_BAR_ATTR]: "" },
5727
+ "data-stuck": stuck ? "" : void 0,
5728
+ "data-testid": testIdPrefix,
5729
+ className: cn("sticky top-0 z-10 border-b bg-canvas", stuck ? "border-border-default" : "border-transparent", className),
5730
+ style: {
5731
+ // At the very top of what scrolls, past the scroll box's own padding.
5732
+ top: pad2 ? -pad2 : void 0,
5733
+ // Stuck: a full-width band, edge to edge of the scroll box; the
5734
+ // filter bar inside stays where it was.
5735
+ ...stuck && (edges.left || edges.right) ? { marginLeft: -edges.left, marginRight: -edges.right, paddingLeft: edges.left, paddingRight: edges.right } : null
5736
+ },
5737
+ children
5738
+ }
5739
+ );
5740
+ }
5741
+
5742
+ // src/DataTableHeaderMenu.tsx
5743
+ var import_react32 = require("react");
5744
+ var import_react_dom9 = require("react-dom");
5745
+ var import_lucide_react30 = require("lucide-react");
5746
+
5747
+ // src/Menu.tsx
5748
+ var import_react31 = require("react");
5749
+ var import_react_slot2 = require("@radix-ui/react-slot");
5750
+ var import_lucide_react29 = require("lucide-react");
5751
+ var import_jsx_runtime56 = require("react/jsx-runtime");
5752
+ var ROW_SELECTOR = '[role^="menuitem"]:not([aria-disabled="true"]):not(:disabled)';
5753
+ function moveFocus(e) {
5754
+ const keys = ["ArrowDown", "ArrowUp", "Home", "End"];
5755
+ if (!keys.includes(e.key)) return;
5756
+ const rows = Array.from(e.currentTarget.querySelectorAll(ROW_SELECTOR));
5757
+ if (!rows.length) return;
5758
+ e.preventDefault();
5759
+ const i = rows.indexOf(document.activeElement);
5760
+ 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;
5761
+ rows[next].focus();
5762
+ }
5763
+ var Menu = (0, import_react31.forwardRef)(
5764
+ ({ className, testIdPrefix, onKeyDown, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
5765
+ "div",
5766
+ {
5767
+ ref,
5768
+ role: "menu",
5769
+ "data-testid": testIdPrefix,
5770
+ onKeyDown: (e) => {
5771
+ moveFocus(e);
5772
+ onKeyDown?.(e);
5773
+ },
5774
+ className: cn("flex flex-col p-1", className),
5775
+ ...props,
5776
+ children
5777
+ }
5778
+ )
5779
+ );
5780
+ Menu.displayName = "Menu";
5781
+ var MenuItem = (0, import_react31.forwardRef)(
5782
+ ({ className, testIdPrefix, icon, trailing, description, submenu, checked, danger, disabled, asChild = false, children, ...props }, ref) => {
5783
+ const Comp = asChild ? import_react_slot2.Slot : "button";
5784
+ const radio = checked !== void 0;
5785
+ return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
5786
+ Comp,
5787
+ {
5788
+ ref,
5789
+ type: asChild ? void 0 : "button",
5790
+ role: radio ? "menuitemradio" : "menuitem",
5791
+ "aria-checked": radio ? checked : void 0,
5792
+ "aria-haspopup": submenu ? "menu" : void 0,
5793
+ "aria-disabled": disabled || void 0,
5794
+ disabled: asChild ? void 0 : disabled,
5795
+ tabIndex: -1,
5796
+ "data-testid": testIdPrefix,
5797
+ className: cn(
5798
+ "flex min-h-9 w-full items-center gap-2.5 rounded-control px-3 py-1.5 text-left text-sm transition-colors",
5799
+ "focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
5800
+ danger ? "text-text-danger" : "text-text-primary",
5801
+ disabled ? "cursor-not-allowed opacity-40" : "hover:bg-subtle focus-visible:bg-subtle",
5802
+ className
5803
+ ),
5804
+ ...props,
5805
+ children: [
5806
+ icon && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { "aria-hidden": "true", className: cn("flex shrink-0", danger ? "text-text-danger" : "text-text-secondary"), children: icon }),
5807
+ asChild ? (
5808
+ // The link's own text lands here; the link becomes the row.
5809
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_react_slot2.Slottable, { children })
5810
+ ) : /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("span", { className: "min-w-0 flex-1", children: [
5811
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "block truncate", children }),
5812
+ description && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "block truncate text-xs text-text-tertiary", children: description })
5813
+ ] }),
5814
+ trailing && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "ml-auto flex shrink-0 items-center text-xs text-text-secondary", children: trailing }),
5815
+ radio && checked && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_lucide_react29.Check, { size: 16, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }),
5816
+ submenu && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_lucide_react29.ChevronRight, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-secondary" })
5817
+ ]
5818
+ }
5819
+ );
5820
+ }
5821
+ );
5822
+ MenuItem.displayName = "MenuItem";
5823
+ function MenuLabel({ className, testIdPrefix, id, children }) {
5824
+ return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
5825
+ "div",
5826
+ {
5827
+ id,
5828
+ role: "presentation",
5829
+ "data-testid": testIdPrefix,
5830
+ className: cn("px-3 pb-1 pt-2 text-micro font-semibold uppercase tracking-wide text-text-tertiary", className),
5831
+ children
5832
+ }
5833
+ );
5834
+ }
5835
+ function MenuSeparator({ className, testIdPrefix }) {
5836
+ return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { role: "separator", "data-testid": testIdPrefix, className: cn("-mx-1 my-1 border-t border-border-default", className) });
5837
+ }
5838
+
5839
+ // src/DataTableHeaderMenu.tsx
5840
+ var import_jsx_runtime57 = require("react/jsx-runtime");
5841
+ function RadioSection({
5842
+ label,
5843
+ rows,
5844
+ value,
5845
+ onPick,
5846
+ first,
5847
+ testId
5848
+ }) {
5849
+ const id = (0, import_react32.useId)();
5850
+ const enabled = rows.filter((r) => !r.disabled);
5851
+ const tabStop = enabled.some((r) => r.id === value) ? value : enabled[0]?.id;
5852
+ const onKey = (e) => {
5853
+ const keys = ["ArrowDown", "ArrowUp", "ArrowRight", "ArrowLeft", "Home", "End"];
5854
+ if (!keys.includes(e.key) || enabled.length === 0) return;
5855
+ e.preventDefault();
5856
+ const i = Math.max(0, enabled.findIndex((r) => r.id === value));
5857
+ const next = e.key === "Home" ? 0 : e.key === "End" ? enabled.length - 1 : e.key === "ArrowDown" || e.key === "ArrowRight" ? (i + 1) % enabled.length : (i - 1 + enabled.length) % enabled.length;
5858
+ onPick(enabled[next].id);
5859
+ const el = e.currentTarget.querySelectorAll('[role="radio"]:not([aria-disabled="true"])')[next];
5860
+ el?.focus();
5861
+ };
5862
+ return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
5863
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(MenuLabel, { id, children: label }),
5864
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { role: "radiogroup", "aria-labelledby": id, onKeyDown: onKey, "data-testid": testId, "data-first-group": first ? "" : void 0, className: "flex flex-col", children: rows.map((r) => {
5865
+ const checked = r.id === value;
5866
+ return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
5867
+ "button",
5868
+ {
5869
+ type: "button",
5870
+ role: "radio",
5871
+ "aria-checked": checked,
5872
+ "aria-disabled": r.disabled || void 0,
5873
+ tabIndex: r.id === tabStop ? 0 : -1,
5874
+ onClick: () => !r.disabled && onPick(r.id),
5875
+ className: cn(
5876
+ // MenuItem's row: 36px, 14px, inset and rounded, the tick on the right.
5877
+ "flex min-h-9 w-full items-center gap-2.5 rounded-control px-3 py-1.5 text-left text-sm text-text-primary transition-colors",
5878
+ "focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
5879
+ r.disabled ? "cursor-not-allowed opacity-40" : "hover:bg-subtle focus-visible:bg-subtle"
5880
+ ),
5881
+ children: [
5882
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "min-w-0 flex-1 truncate", children: r.label }),
5883
+ checked && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_lucide_react30.Check, { size: 16, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" })
5884
+ ]
5885
+ },
5886
+ r.id ?? "__none"
5887
+ );
5888
+ }) })
5889
+ ] });
5890
+ }
5891
+ function HeaderMenuTrigger({
5892
+ menu,
5893
+ columnLabel,
5894
+ sortDir,
5895
+ onSort,
5896
+ testId
5897
+ }) {
5898
+ const [open, setOpen] = (0, import_react32.useState)(false);
5899
+ const [pos, setPos] = (0, import_react32.useState)(null);
5900
+ const trigger = (0, import_react32.useRef)(null);
5901
+ const panel = (0, import_react32.useRef)(null);
5902
+ const { groupBy, breakOutBy } = menu;
5903
+ const groupLabel = groupBy.options.find((o) => o.id === groupBy.value)?.label ?? "";
5904
+ const breakLabel = breakOutBy?.value != null ? breakOutBy.options.find((o) => o.id === breakOutBy.value)?.label : void 0;
5905
+ const [draftGroup, setDraftGroup] = (0, import_react32.useState)(groupBy.value);
5906
+ const [draftBreak, setDraftBreak] = (0, import_react32.useState)(breakOutBy?.value ?? null);
5907
+ const [draftSort, setDraftSort] = (0, import_react32.useState)(sortDir);
5908
+ const openPanel = () => {
5909
+ setDraftGroup(groupBy.value);
5910
+ setDraftBreak(breakOutBy?.value ?? null);
5911
+ setDraftSort(sortDir);
5912
+ setOpen(true);
5913
+ };
5914
+ const close = (0, import_react32.useCallback)((refocus) => {
5915
+ setOpen(false);
5916
+ if (refocus) trigger.current?.focus();
5917
+ }, []);
5918
+ const apply = () => {
5919
+ if (draftGroup !== groupBy.value) groupBy.onChange(draftGroup);
5920
+ if (breakOutBy && draftBreak !== breakOutBy.value) breakOutBy.onChange(draftBreak);
5921
+ if (onSort && draftSort && draftSort !== sortDir) onSort(draftSort);
5922
+ close(true);
5923
+ };
5924
+ const place = (0, import_react32.useCallback)(() => {
5925
+ const t = trigger.current;
5926
+ if (!t) return;
5927
+ const r = t.getBoundingClientRect();
5928
+ const h = panel.current?.offsetHeight ?? 0;
5929
+ const above = r.bottom + 4 + h > window.innerHeight && r.top - 4 - h > 0;
5930
+ setPos({ top: above ? r.top - 4 - h : r.bottom + 4, left: r.left });
5931
+ }, []);
5932
+ (0, import_react32.useLayoutEffect)(() => {
5933
+ if (open) place();
5934
+ else setPos(null);
5935
+ }, [open, place]);
5936
+ const placed = pos !== null;
5937
+ (0, import_react32.useEffect)(() => {
5938
+ if (open && placed) panel.current?.querySelector('[data-first-group] [tabindex="0"]')?.focus();
5939
+ }, [open, placed]);
5940
+ (0, import_react32.useEffect)(() => {
5941
+ if (!open) return void 0;
5942
+ const onDown = (e) => {
5943
+ const t = e.target;
5944
+ if (trigger.current?.contains(t) || panel.current?.contains(t)) return;
5945
+ close(false);
5946
+ };
5947
+ window.addEventListener("mousedown", onDown);
5948
+ window.addEventListener("resize", place);
5949
+ window.addEventListener("scroll", place, true);
5950
+ return () => {
5951
+ window.removeEventListener("mousedown", onDown);
5952
+ window.removeEventListener("resize", place);
5953
+ window.removeEventListener("scroll", place, true);
5954
+ };
5955
+ }, [open, close, place]);
5956
+ const onTriggerKey = (e) => {
5957
+ if (e.key === "ArrowDown" && !open) {
5958
+ e.preventDefault();
5959
+ openPanel();
5960
+ }
5961
+ };
5962
+ const onPanelKey = (e) => {
5963
+ if (e.key === "Escape") {
5964
+ e.preventDefault();
5965
+ e.stopPropagation();
5966
+ close(true);
5967
+ return;
5968
+ }
5969
+ if (e.key === "Tab") {
5970
+ const stops = [...e.currentTarget.querySelectorAll('[tabindex="0"], button:not([tabindex])')];
5971
+ const at = stops.indexOf(document.activeElement);
5972
+ if (e.shiftKey && at === 0 || !e.shiftKey && at === stops.length - 1) {
5973
+ e.preventDefault();
5974
+ close(true);
5975
+ }
5976
+ }
5977
+ };
5978
+ const pickGroup = (id) => {
5979
+ setDraftGroup(id);
5980
+ if (draftBreak === id) setDraftBreak(null);
5981
+ };
5982
+ return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
5983
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
5984
+ "button",
5985
+ {
5986
+ ref: trigger,
5987
+ type: "button",
5988
+ "aria-haspopup": "dialog",
5989
+ "aria-expanded": open,
5990
+ "data-testid": testId,
5991
+ onClick: () => open ? close(false) : openPanel(),
5992
+ onKeyDown: onTriggerKey,
5993
+ className: cn(
5994
+ // Restores the header row's uppercase: a <button> doesn't inherit
5995
+ // text-transform (see SortButton). The negative margin keeps the
5996
+ // label lined up with the names under it while the hover fill
5997
+ // reaches past it.
5998
+ "-mx-1.5 -my-1 inline-flex items-center gap-1 rounded-control px-1.5 py-1 uppercase transition-colors",
5999
+ "hover:bg-border-default hover:text-text-primary aria-expanded:bg-border-default aria-expanded:text-text-primary",
6000
+ "focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-border-focus"
6001
+ ),
6002
+ children: [
6003
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("span", { children: [
6004
+ groupLabel,
6005
+ breakLabel && /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
6006
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { "aria-hidden": "true", className: "text-text-tertiary", children: " \u203A " }),
6007
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "sr-only", children: " then " }),
6008
+ breakLabel
6009
+ ] })
6010
+ ] }),
6011
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_lucide_react30.ChevronDown, { size: 12, "aria-hidden": "true", className: cn("shrink-0 transition-transform motion-reduce:transition-none", open && "rotate-180") })
6012
+ ]
6013
+ }
6014
+ ),
6015
+ open && (0, import_react_dom9.createPortal)(
6016
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
6017
+ "div",
6018
+ {
6019
+ ref: panel,
6020
+ role: "dialog",
6021
+ "aria-label": columnLabel,
6022
+ "data-testid": testId && `${testId}-menu`,
6023
+ onKeyDown: onPanelKey,
6024
+ style: { position: "fixed", top: pos?.top ?? 0, left: pos?.left ?? 0, visibility: pos ? void 0 : "hidden" },
6025
+ className: "z-dropdown flex max-h-120 w-60 flex-col overflow-hidden rounded-card border border-border-default bg-surface text-left normal-case tracking-normal shadow-overlay",
6026
+ children: [
6027
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "flex min-h-0 flex-col overflow-y-auto p-1", children: [
6028
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6029
+ RadioSection,
6030
+ {
6031
+ first: true,
6032
+ label: groupBy.label ?? "Group rows by",
6033
+ rows: groupBy.options,
6034
+ value: draftGroup,
6035
+ onPick: pickGroup
6036
+ }
6037
+ ),
6038
+ breakOutBy && /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
6039
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(MenuSeparator, {}),
6040
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6041
+ RadioSection,
6042
+ {
6043
+ label: breakOutBy.label ?? "Then break out by",
6044
+ rows: [{ id: null, label: "None" }, ...breakOutBy.options.map((o) => ({ ...o, disabled: o.id === draftGroup }))],
6045
+ value: draftBreak,
6046
+ onPick: setDraftBreak
6047
+ }
6048
+ )
6049
+ ] }),
6050
+ onSort && /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
6051
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(MenuSeparator, {}),
6052
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6053
+ RadioSection,
6054
+ {
6055
+ label: "Sort",
6056
+ rows: [
6057
+ { id: "asc", label: "A to Z" },
6058
+ { id: "desc", label: "Z to A" }
6059
+ ],
6060
+ value: draftSort ?? void 0,
6061
+ onPick: setDraftSort
6062
+ }
6063
+ )
6064
+ ] })
6065
+ ] }),
6066
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(FilterDropdownFooter, { onCancel: () => close(true), onApply: apply })
6067
+ ]
6068
+ }
6069
+ ),
6070
+ document.body
6071
+ )
6072
+ ] });
6073
+ }
6074
+
6075
+ // src/DataTable.tsx
6076
+ var import_jsx_runtime58 = require("react/jsx-runtime");
5611
6077
  var WIDTH3 = { fill: "", sm: "w-24", md: "w-36", lg: "w-48" };
5612
6078
  var MAX_H = { sm: "max-h-80", md: "max-h-120", lg: "max-h-160" };
6079
+ 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
6080
  var HEAD_PAD = { default: "px-4 py-3", compact: "px-3 py-2" };
5614
6081
  var CELL_PAD = { default: "px-4 py-3.5", compact: "px-3 py-2" };
6082
+ var EXPAND_PAD = "px-2";
5615
6083
  var SUB_INDENT = { default: "pl-10", compact: "pl-9" };
5616
6084
  var TINT = "bg-brand-primaryTint";
5617
6085
  var TINT_HOVER = "group-hover/row:bg-linear-to-r group-hover/row:from-brand-primaryAction/10 group-hover/row:to-brand-primaryAction/10";
@@ -5627,6 +6095,7 @@ function isDev() {
5627
6095
  return false;
5628
6096
  }
5629
6097
  }
6098
+ var useBrowserLayoutEffect = typeof window === "undefined" ? import_react33.useEffect : import_react33.useLayoutEffect;
5630
6099
  function rowClickCounts(e) {
5631
6100
  if (e.target.closest(OWN_CLICK)) return false;
5632
6101
  const sel = window.getSelection?.();
@@ -5634,13 +6103,13 @@ function rowClickCounts(e) {
5634
6103
  return true;
5635
6104
  }
5636
6105
  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 })
6106
+ return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Tooltip, { label: reason, delay: 300, className: "text-text-tertiary", children: [
6107
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { "aria-hidden": "true", children: NO_VALUE }),
6108
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "sr-only", children: reason })
5640
6109
  ] });
5641
6110
  }
5642
6111
  function TableLink({ className, ...props }) {
5643
- return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6112
+ return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
5644
6113
  "a",
5645
6114
  {
5646
6115
  ...props,
@@ -5688,26 +6157,29 @@ function DataTable({
5688
6157
  refreshing = false,
5689
6158
  onRetry,
5690
6159
  empty,
5691
- maxHeight,
6160
+ maxHeight: maxHeightProp,
5692
6161
  footer,
6162
+ sticky = false,
6163
+ stickyTop,
5693
6164
  className,
5694
6165
  testIdPrefix,
5695
6166
  ...rest
5696
6167
  }) {
5697
- const titleId = (0, import_react30.useId)();
6168
+ const maxHeight = sticky ? void 0 : maxHeightProp;
6169
+ const titleId = (0, import_react33.useId)();
5698
6170
  const showSkeleton = useDelayedLoading(loading);
5699
6171
  const head = HEAD_PAD[density];
5700
6172
  const pad2 = CELL_PAD[density];
5701
6173
  const right = (c) => c.numeric || c.rank;
5702
6174
  const align = (c) => right(c) ? "text-right" : "text-left";
5703
- const width = (c) => c.rank ? "w-12" : WIDTH3[c.width ?? (c.numeric ? "md" : "fill")];
6175
+ const width = (c) => c.rank ? "w-12" : WIDTH3[c.width ?? (c.lead ? "sm" : c.numeric ? "md" : "fill")];
5704
6176
  const shown = sort ?? defaultSort;
5705
6177
  const onSort = (key) => {
5706
6178
  const col = columns.find((c) => c.key === key);
5707
6179
  onSortChange?.(cycleSort(shown, key, col?.firstDir ?? (right(col) ? "desc" : "asc"), defaultSort));
5708
6180
  };
5709
6181
  const clash = !!onRowClick && (!!renderExpandedProp || !!subRowsProp);
5710
- (0, import_react30.useEffect)(() => {
6182
+ (0, import_react33.useEffect)(() => {
5711
6183
  if (clash && isDev()) {
5712
6184
  console.warn("DataTable: pass `onRowClick` or rows that open in place (`renderExpanded`, `subRows`), not both. The row click wins; rows won't open.");
5713
6185
  }
@@ -5718,10 +6190,10 @@ function DataTable({
5718
6190
  const kids = subRows?.(row);
5719
6191
  return kids && kids.length > 0 ? kids : null;
5720
6192
  };
5721
- const [open, setOpen] = (0, import_react30.useState)(() => /* @__PURE__ */ new Set());
6193
+ const [open, setOpen] = (0, import_react33.useState)(() => /* @__PURE__ */ new Set());
5722
6194
  const visible = rows.map(rowKey);
5723
6195
  const resetOn = subRows ? [...visible].sort().join("|") : `${shown?.key}|${shown?.dir}|${visible.join("|")}`;
5724
- (0, import_react30.useEffect)(() => setOpen(/* @__PURE__ */ new Set()), [resetOn]);
6196
+ (0, import_react33.useEffect)(() => setOpen(/* @__PURE__ */ new Set()), [resetOn]);
5725
6197
  const expandable = (row) => (!!renderExpanded || !!childrenOf(row)) && (canExpand ? canExpand(row) : true);
5726
6198
  const anyExpandable = (!!renderExpanded || !!subRows) && rows.some(expandable);
5727
6199
  const toggle = (key) => setOpen((prev) => {
@@ -5742,8 +6214,8 @@ function DataTable({
5742
6214
  pickable.forEach((k) => allVisible ? next.delete(k) : next.add(k));
5743
6215
  setPicked(next);
5744
6216
  };
5745
- const lastPicked = (0, import_react30.useRef)(null);
5746
- const shiftHeld = (0, import_react30.useRef)(false);
6217
+ const lastPicked = (0, import_react33.useRef)(null);
6218
+ const shiftHeld = (0, import_react33.useRef)(false);
5747
6219
  const togglePick = (index) => {
5748
6220
  const key = visible[index];
5749
6221
  const on = !picked.has(key);
@@ -5760,12 +6232,12 @@ function DataTable({
5760
6232
  };
5761
6233
  const count = selectedCount ?? picked.size;
5762
6234
  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)(() => {
6235
+ const scroller = (0, import_react33.useRef)(null);
6236
+ const [pinned, setPinned] = (0, import_react33.useState)(false);
6237
+ const [scrolled, setScrolled] = (0, import_react33.useState)(false);
6238
+ const heads = (0, import_react33.useRef)(/* @__PURE__ */ new Map());
6239
+ const [lefts, setLefts] = (0, import_react33.useState)({});
6240
+ (0, import_react33.useEffect)(() => {
5769
6241
  const el = scroller.current;
5770
6242
  if (!el || typeof ResizeObserver === "undefined") return void 0;
5771
6243
  const measure = () => {
@@ -5785,7 +6257,7 @@ function DataTable({
5785
6257
  if (el.firstElementChild) ro.observe(el.firstElementChild);
5786
6258
  return () => ro.disconnect();
5787
6259
  }, []);
5788
- const nameIdx = Math.max(0, columns.findIndex((c) => !c.rank));
6260
+ const nameIdx = Math.max(0, columns.findIndex((c) => !c.rank && !c.lead));
5789
6261
  const leftOf = (part) => lefts[String(part)] ?? 0;
5790
6262
  const headRef = (part) => (el) => {
5791
6263
  if (el) heads.current.set(String(part), el);
@@ -5798,13 +6270,81 @@ function DataTable({
5798
6270
  part === nameIdx && "max-w-60 border-r border-r-border-default"
5799
6271
  ) : "";
5800
6272
  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;
6273
+ const edge = (part) => pinned && scrolled && part === nameIdx ? /* @__PURE__ */ (0, import_jsx_runtime58.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
6274
  const span = columns.length + (anyExpandable ? 1 : 0) + (selectable ? 1 : 0);
6275
+ const wrapRef = (0, import_react33.useRef)(null);
6276
+ const theadRef = (0, import_react33.useRef)(null);
6277
+ const cloneRef = (0, import_react33.useRef)(null);
6278
+ const [stuck, setStuck] = (0, import_react33.useState)(false);
6279
+ const [geom, setGeom] = (0, import_react33.useState)({ cols: [], width: 0, height: 0 });
6280
+ const [barH, setBarH] = (0, import_react33.useState)(0);
6281
+ const [scrollPad, setScrollPad] = (0, import_react33.useState)({ top: 0, bottom: 0 });
6282
+ const [footerStuck, setFooterStuck] = (0, import_react33.useState)(false);
6283
+ const [scrolledDown, setScrolledDown] = (0, import_react33.useState)(false);
6284
+ const [animate, setAnimate] = (0, import_react33.useState)(false);
6285
+ (0, import_react33.useEffect)(() => {
6286
+ const thead = theadRef.current;
6287
+ if (!sticky || !thead || typeof ResizeObserver === "undefined") return void 0;
6288
+ const measure = () => {
6289
+ const cells = [...thead.rows[0]?.cells ?? []];
6290
+ const next = { cols: cells.map((c) => c.getBoundingClientRect().width), width: thead.getBoundingClientRect().width, height: thead.getBoundingClientRect().height };
6291
+ setGeom((prev) => prev.width === next.width && prev.height === next.height && prev.cols.join() === next.cols.join() ? prev : next);
6292
+ };
6293
+ measure();
6294
+ const ro = new ResizeObserver(measure);
6295
+ ro.observe(thead);
6296
+ for (const c of thead.rows[0]?.cells ?? []) ro.observe(c);
6297
+ return () => ro.disconnect();
6298
+ }, [sticky, span]);
6299
+ useBrowserLayoutEffect(() => {
6300
+ const wrap = wrapRef.current;
6301
+ if (!sticky || !wrap) return void 0;
6302
+ let root = scrollParent(wrap);
6303
+ const bar2 = (root ?? document).querySelector(`[${STICKY_BAR_ATTR}]`) ?? document.querySelector(`[${STICKY_BAR_ATTR}]`);
6304
+ const update = () => {
6305
+ const thead = theadRef.current;
6306
+ const clone = cloneRef.current;
6307
+ if (thead && clone) setStuck(clone.getBoundingClientRect().top > thead.getBoundingClientRect().top + 0.5);
6308
+ setFooterStuck(wrap.getBoundingClientRect().bottom > viewportOf(root).bottom + 1);
6309
+ setScrolledDown((root ? root.scrollTop : window.scrollY) > 0);
6310
+ };
6311
+ const measure = () => {
6312
+ root = scrollParent(wrap);
6313
+ setBarH(bar2 ? bar2.getBoundingClientRect().height : 0);
6314
+ setScrollPad((prev) => {
6315
+ const next = scrollPadding(root);
6316
+ return prev.top === next.top && prev.bottom === next.bottom ? prev : next;
6317
+ });
6318
+ update();
6319
+ };
6320
+ measure();
6321
+ const raf = requestAnimationFrame(() => setAnimate(true));
6322
+ document.addEventListener("scroll", update, { capture: true, passive: true });
6323
+ window.addEventListener("resize", measure);
6324
+ const ro = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
6325
+ if (bar2) ro?.observe(bar2);
6326
+ ro?.observe(wrap);
6327
+ return () => {
6328
+ cancelAnimationFrame(raf);
6329
+ document.removeEventListener("scroll", update, { capture: true });
6330
+ window.removeEventListener("resize", measure);
6331
+ ro?.disconnect();
6332
+ };
6333
+ }, [sticky]);
6334
+ (0, import_react33.useEffect)(() => {
6335
+ const clone = cloneRef.current;
6336
+ if (!clone) return;
6337
+ clone.querySelectorAll("button, a[href], input, [tabindex]").forEach((el) => {
6338
+ if (el.tabIndex !== -1) el.tabIndex = -1;
6339
+ });
6340
+ if (scroller.current) clone.scrollLeft = scroller.current.scrollLeft;
6341
+ });
6342
+ const top = (stickyTop ?? barH) - scrollPad.top;
5803
6343
  const renderCell = (c, row) => {
5804
6344
  const v = c.cell(row);
5805
- return v === null || v === void 0 || v === "" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(NoValue, { reason: c.missing }) : v;
6345
+ return v === null || v === void 0 || v === "" ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(NoValue, { reason: c.missing }) : v;
5806
6346
  };
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;
6347
+ const fit = (ci, content) => pinned && ci === nameIdx ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Tooltip, { label: content, whenTruncated: true, delay: 300, className: "block truncate", children: content }) : content;
5808
6348
  const colBg = (c, rowBg) => c.highlight ? TINT : rowBg;
5809
6349
  const firstPart = selectable ? "select" : anyExpandable ? "expand" : 0;
5810
6350
  const ringCls = (part) => onRowClick ? cn(
@@ -5814,13 +6354,13 @@ function DataTable({
5814
6354
  part === columns.length - 1 && RING_RIGHT,
5815
6355
  pinned && scrolled && part === nameIdx && part !== columns.length - 1 && RING_PAST_EDGE
5816
6356
  ) : "";
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") }),
6357
+ const plainRow = (kind, row, key, rowBg, extra) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("tr", { id: extra?.id, className: cn("[&:last-child>td]:border-b-0", kind === "total" && "font-semibold"), children: [
6358
+ selectable && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("td", { className: cn("border-b border-border-default pr-0", pad2, rowBg, pinCls("select", "body", rowBg)), style: pinStyle("select") }),
6359
+ anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("td", { className: cn("border-b border-border-default", pad2, EXPAND_PAD, rowBg, pinCls("expand", "body", rowBg)), style: pinStyle("expand") }),
5820
6360
  columns.map((c, ci) => {
5821
6361
  const bg = kind === "sub" ? colBg(c, rowBg) : rowBg;
5822
6362
  const isName = ci === nameIdx;
5823
- return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6363
+ return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
5824
6364
  "td",
5825
6365
  {
5826
6366
  className: cn(
@@ -5835,8 +6375,8 @@ function DataTable({
5835
6375
  ),
5836
6376
  style: pinStyle(ci),
5837
6377
  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: [
6378
+ c.rank || c.lead ? null : isName && kind === "total" ? fit(ci, totalsLabel) : kind === "total" ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(DeltaBoldContext.Provider, { value: true, children: fit(ci, renderCell(c, row)) }) : fit(ci, renderCell(c, row)),
6379
+ kind === "sub" && isName && rowLabel && extra?.parent !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("span", { className: "sr-only", children: [
5840
6380
  ", in ",
5841
6381
  rowLabel(extra.parent)
5842
6382
  ] }),
@@ -5847,231 +6387,293 @@ function DataTable({
5847
6387
  );
5848
6388
  })
5849
6389
  ] }, key);
6390
+ const headRow = (clone) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("tr", { className: "bg-subtle text-micro font-semibold uppercase tracking-wider text-text-secondary", children: [
6391
+ selectable && /* @__PURE__ */ (0, import_jsx_runtime58.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_runtime58.jsx)(
6392
+ CheckBox,
6393
+ {
6394
+ checked: allVisible,
6395
+ indeterminate: someVisible && !allVisible,
6396
+ onChange: toggleAllVisible,
6397
+ disabled: pickable.length === 0,
6398
+ ariaLabel: allVisible ? "Deselect all rows on this page" : "Select all rows on this page"
6399
+ }
6400
+ ) : /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "sr-only", children: "Select" }) }),
6401
+ anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("th", { ref: clone ? void 0 : headRef("expand"), scope: "col", className: cn("w-10 border-b border-border-default", head, EXPAND_PAD, pinCls("expand", "head")), style: pinStyle("expand"), children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "sr-only", children: "Details" }) }),
6402
+ columns.map((c, ci) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
6403
+ "th",
6404
+ {
6405
+ ref: !clone && ci <= nameIdx ? headRef(ci) : void 0,
6406
+ scope: "col",
6407
+ "aria-sort": c.sortable || c.headerMenu && onSortChange ? ariaSortFor(shown, c.key) : void 0,
6408
+ className: cn(
6409
+ "group/head whitespace-nowrap border-b border-border-default font-semibold",
6410
+ head,
6411
+ align(c),
6412
+ width(c),
6413
+ c.highlight && TINT,
6414
+ pinCls(ci, "head", c.highlight ? TINT : void 0)
6415
+ ),
6416
+ style: pinStyle(ci),
6417
+ children: [
6418
+ c.headerMenu ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6419
+ HeaderMenuTrigger,
6420
+ {
6421
+ menu: c.headerMenu,
6422
+ columnLabel: c.label,
6423
+ sortDir: shown?.key === c.key ? shown.dir : null,
6424
+ onSort: onSortChange ? (dir) => onSortChange({ key: c.key, dir }) : void 0,
6425
+ testId: clone || !testIdPrefix ? void 0 : `${testIdPrefix}-header-menu-${c.key}`
6426
+ }
6427
+ ) : c.sortable && onSortChange ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6428
+ SortButton,
6429
+ {
6430
+ label: c.label,
6431
+ sortKey: c.key,
6432
+ align: right(c) ? "right" : "left",
6433
+ sort: sortProp(shown),
6434
+ onSort,
6435
+ description: c.info,
6436
+ testIdPrefix: clone ? void 0 : testIdPrefix
6437
+ }
6438
+ ) : c.info ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(SortButton, { label: c.label, sortKey: c.key, sortable: false, sort: sortProp(shown), onSort: () => {
6439
+ }, description: c.info, align: right(c) ? "right" : "left" }) : c.label,
6440
+ edge(ci)
6441
+ ]
6442
+ },
6443
+ c.key
6444
+ ))
6445
+ ] });
5850
6446
  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: [
6447
+ const bar = barCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 text-dense", children: [
6448
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("span", { role: "status", className: "font-medium text-text-primary", children: [
5853
6449
  formatCountFull(count),
5854
6450
  " selected"
5855
6451
  ] }),
5856
- allVisible && totalCount !== void 0 && count < totalCount && onSelectAll && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(Button, { variant: "link", size: "sm", onClick: onSelectAll, children: [
6452
+ allVisible && totalCount !== void 0 && count < totalCount && onSelectAll && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Button, { variant: "link", size: "sm", onClick: onSelectAll, children: [
5857
6453
  "Select all ",
5858
6454
  formatCountFull(totalCount)
5859
6455
  ] }),
5860
6456
  selectionActions,
5861
- /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Button, { variant: "link", size: "sm", onClick: () => onSelectedChange?.([]), children: "Clear" })
6457
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Button, { variant: "link", size: "sm", onClick: () => onSelectedChange?.([]), children: "Clear" })
5862
6458
  ] }) : null;
5863
- const frame = /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6459
+ const scrollArea = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
5864
6460
  "div",
5865
6461
  {
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)
6462
+ ref: scroller,
6463
+ onScroll: (e) => {
6464
+ setScrolled(e.currentTarget.scrollLeft > 0);
6465
+ if (cloneRef.current) cloneRef.current.scrollLeft = e.currentTarget.scrollLeft;
6466
+ },
6467
+ className: cn("overflow-x-auto", SCROLLBAR, maxHeight && cn("overflow-y-auto", MAX_H[maxHeight])),
6468
+ children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
6469
+ "table",
6470
+ {
6471
+ "aria-labelledby": title ? titleId : void 0,
6472
+ "aria-label": title ? void 0 : rest["aria-label"],
6473
+ "aria-busy": loading || refreshing || void 0,
6474
+ className: "w-full border-separate border-spacing-0 text-left",
6475
+ children: [
6476
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("thead", { ref: theadRef, className: cn(maxHeight && "sticky top-0 z-10"), children: headRow(false) }),
6477
+ /* @__PURE__ */ (0, import_jsx_runtime58.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_runtime58.jsxs)("tr", { "aria-hidden": "true", className: "[&:last-child>td]:border-b-0", children: [
6478
+ selectable && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("td", { className: cn("border-b border-border-default", pad2) }),
6479
+ anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("td", { className: cn("border-b border-border-default", pad2, EXPAND_PAD) }),
6480
+ columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("td", { className: cn("border-b border-border-default", pad2, align(c)), children: showSkeleton ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Skeleton, { className: cn("inline-block", right(c) ? "w-12" : "w-2/3") }) : /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "inline-block h-3" }) }, c.key))
6481
+ ] }, i)) : rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("td", { colSpan: span, className: "px-6 py-12", children: empty ?? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(NoResultsEmptyState, {}) }) }) : /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
6482
+ totalsRow !== void 0 && plainRow("total", totalsRow, "__totals", "bg-subtle"),
6483
+ rows.map((row, ri) => {
6484
+ const key = rowKey(row);
6485
+ const canOpen = expandable(row);
6486
+ const kids = canOpen ? childrenOf(row) : null;
6487
+ const isOpen = canOpen && open.has(key);
6488
+ const panelOpen = isOpen && !kids;
6489
+ const panelId = `${titleId}-row-${ri}`;
6490
+ const kidIds = kids ? kids.map((_, si) => `${panelId}-${si}`) : [];
6491
+ const rowBg = highlightRow?.(row) ? cn(TINT, onRowClick && TINT_HOVER) : panelOpen ? "bg-subtle" : void 0;
6492
+ const reason = selectable ? blocked(row) : false;
6493
+ const ticked = picked.has(key);
6494
+ const label = rowLabel ? rowLabel(row) : "row";
6495
+ const clickable = !!onRowClick || canOpen;
6496
+ return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_react33.Fragment, { children: [
6497
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
6498
+ "tr",
6499
+ {
6500
+ onClick: onRowClick ? (e) => rowClickCounts(e) && onRowClick(row) : canOpen ? (e) => rowClickCounts(e) && toggle(key) : void 0,
6501
+ className: cn(
6502
+ "group/row hover:bg-subtle [&:last-child>td]:border-b-0",
6503
+ clickable && "cursor-pointer",
6504
+ panelOpen && "bg-subtle"
6505
+ // The row's hidden open button has keyboard focus: ring the whole row.
6506
+ ),
6507
+ children: [
6508
+ selectable && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6509
+ "td",
6510
+ {
6511
+ onPointerDownCapture: (e) => shiftHeld.current = e.shiftKey,
6512
+ onKeyDownCapture: (e) => shiftHeld.current = e.shiftKey,
6513
+ className: cn("border-b border-border-default pr-0", pad2, panelOpen && "border-b-0", rowBg, ringCls("select"), pinCls("select", "body", rowBg)),
6514
+ style: pinStyle("select"),
6515
+ children: reason ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Tooltip, { label: reason, delay: 300, className: "inline-flex align-middle", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6516
+ "button",
6517
+ {
6518
+ type: "button",
6519
+ role: "checkbox",
6520
+ "aria-checked": ticked,
6521
+ "aria-disabled": "true",
6522
+ "aria-label": `Select ${label}`,
6523
+ onClick: (e) => e.preventDefault(),
6524
+ 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",
6525
+ children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(CheckBoxBox, { checked: ticked, disabled: true })
6526
+ }
6527
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(CheckBox, { checked: ticked, onChange: () => togglePick(ri), ariaLabel: `Select ${label}` })
6528
+ }
5915
6529
  ),
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",
6530
+ anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6531
+ "td",
5959
6532
  {
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",
6533
+ className: cn("border-b border-border-default", pad2, EXPAND_PAD, panelOpen && "border-b-0", rowBg, ringCls("expand"), pinCls("expand", "body", rowBg)),
6534
+ style: pinStyle("expand"),
6535
+ children: canOpen && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6536
+ "button",
6537
+ {
6538
+ type: "button",
6539
+ "aria-expanded": isOpen,
6540
+ "aria-controls": isOpen ? kids ? kidIds.join(" ") : panelId : void 0,
6541
+ "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)}` : ""}`,
6542
+ onClick: () => toggle(key),
6543
+ 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",
6544
+ children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6545
+ import_lucide_react31.ChevronRight,
6021
6546
  {
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
- ]
6547
+ size: 16,
6548
+ "aria-hidden": "true",
6549
+ className: cn("transition-transform motion-reduce:transition-none", isOpen && "rotate-90")
6550
+ }
6551
+ )
6552
+ }
6553
+ )
6046
6554
  }
6047
6555
  ),
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
- ]
6556
+ columns.map((c, ci) => {
6557
+ const bg = colBg(c, rowBg);
6558
+ const opener = !!onRowClick && ci === nameIdx;
6559
+ return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
6560
+ "td",
6561
+ {
6562
+ className: cn(
6563
+ "border-b border-border-default",
6564
+ pad2,
6565
+ align(c),
6566
+ right(c) && "tabular-nums",
6567
+ c.rank && "text-text-tertiary",
6568
+ panelOpen && "border-b-0",
6569
+ ringCls(ci),
6570
+ bg,
6571
+ pinCls(ci, "body", bg)
6572
+ ),
6573
+ style: pinStyle(ci),
6574
+ children: [
6575
+ fit(ci, renderCell(c, row)),
6576
+ opener && // The keyboard's and screen reader's way to the row click. It
6577
+ // stays hidden; while it has focus the whole row takes the ring.
6578
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("button", { type: "button", "data-row-open": "", onClick: () => onRowClick(row), className: "sr-only", children: rowClickLabel ? rowClickLabel(row) : `Open ${rowLabel ? rowLabel(row) : "row"}` }),
6579
+ edge(ci)
6580
+ ]
6581
+ },
6582
+ c.key
6583
+ );
6584
+ })
6585
+ ]
6586
+ }
6587
+ ),
6588
+ panelOpen && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("tr", { className: "[&:last-child>td]:border-b-0", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("td", { id: panelId, colSpan: span, className: "border-b border-border-default bg-subtle px-4 pb-4 pl-14", children: renderExpanded(row) }) }),
6589
+ isOpen && kids?.map(
6590
+ (child, si) => plainRow("sub", child, `${key}::${rowKey(child)}`, highlightRow?.(child) ? TINT : "bg-subtle", { id: kidIds[si], parent: row })
6591
+ )
6592
+ ] }, key);
6593
+ })
6594
+ ] }) })
6595
+ ]
6596
+ }
6597
+ )
6598
+ }
6599
+ );
6600
+ const bare = inside || !title && barCount === 0;
6601
+ const frame = /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
6602
+ "div",
6603
+ {
6604
+ className: cn(
6605
+ "relative flex w-full flex-col rounded-card border border-border-default bg-surface",
6606
+ // clip, not hidden, on a sticky table: hidden would make the frame the
6607
+ // box its header sticks in, instead of the page.
6608
+ sticky ? "overflow-clip" : "overflow-hidden",
6609
+ !sticky && bare && className
6610
+ ),
6611
+ "data-testid": testIdPrefix,
6612
+ children: [
6613
+ title && inside && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
6614
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "min-w-0", children: [
6615
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("h3", { id: titleId, className: "text-panel-title font-semibold text-text-primary", children: title }),
6616
+ subtitle && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "mt-0.5 text-xs leading-snug text-text-tertiary", children: subtitle })
6617
+ ] }),
6618
+ (bar ?? action) && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "shrink-0 text-text-tertiary", children: bar ?? action })
6619
+ ] }),
6620
+ sticky ? (
6621
+ // The copy of the header sticks within this box, so it leaves with the last row.
6622
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "relative", children: [
6623
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6624
+ "div",
6625
+ {
6626
+ ref: cloneRef,
6627
+ "aria-hidden": "true",
6628
+ "data-sticky-head": "",
6629
+ onWheel: (e) => {
6630
+ if (scroller.current && Math.abs(e.deltaX) > Math.abs(e.deltaY)) scroller.current.scrollLeft += e.deltaX;
6631
+ },
6632
+ className: "sticky z-2 overflow-hidden",
6633
+ style: { top, height: geom.height, marginBottom: -geom.height, visibility: stuck ? "visible" : "hidden" },
6634
+ children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("table", { className: "table-fixed border-separate border-spacing-0 text-left", style: { width: geom.width }, children: [
6635
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("colgroup", { children: geom.cols.map((w, i) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("col", { style: { width: w } }, i)) }),
6636
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("thead", { children: headRow(true) })
6637
+ ] })
6056
6638
  }
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 })
6639
+ ),
6640
+ scrollArea
6641
+ ] })
6642
+ ) : scrollArea,
6643
+ refreshing && !loading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(RefreshLine, {}),
6644
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(LongWait, { loading, onRetry, className: "mb-3 px-4" }),
6645
+ footer && !sticky && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "border-t border-border-default px-4 py-3", children: footer })
6063
6646
  ]
6064
6647
  }
6065
6648
  );
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
6649
+ const hideFooter = footerStuck && !scrolledDown;
6650
+ const body = sticky ? /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { ref: wrapRef, className: cn("flex w-full flex-col", bare && className), children: [
6651
+ frame,
6652
+ footer && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6653
+ "div",
6654
+ {
6655
+ "data-sticky-footer": "",
6656
+ style: scrollPad.bottom ? { bottom: -scrollPad.bottom } : void 0,
6657
+ className: cn(
6658
+ "sticky bottom-0 z-3 border-t bg-canvas py-3",
6659
+ footerStuck ? "border-border-default" : "border-transparent",
6660
+ animate && "transition-[opacity,translate] duration-(--mr-motion-duration-interactive) ease-interactive motion-reduce:transition-none",
6661
+ // Hidden, not gone: Tab still reaches it, and focus shows it.
6662
+ hideFooter && "pointer-events-none translate-y-full opacity-0 focus-within:pointer-events-auto focus-within:translate-y-0 focus-within:opacity-100"
6663
+ ),
6664
+ children: footer
6665
+ }
6666
+ )
6667
+ ] }) : frame;
6668
+ if (bare) return body;
6669
+ return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("section", { "aria-labelledby": title ? titleId : void 0, className: cn("flex w-full flex-col gap-3", className), children: [
6670
+ title ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(SectionHeading, { id: titleId, as: titleAs, title, description: subtitle, actions: bar ?? action }) : /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "flex justify-end", children: bar }),
6671
+ body
6070
6672
  ] });
6071
6673
  }
6072
6674
 
6073
6675
  // src/MediaLabel.tsx
6074
- var import_jsx_runtime56 = require("react/jsx-runtime");
6676
+ var import_jsx_runtime59 = require("react/jsx-runtime");
6075
6677
  var FILL = {
6076
6678
  TV: "bg-media-tv",
6077
6679
  CTV: "bg-media-ctv",
@@ -6082,7 +6684,7 @@ var FILL = {
6082
6684
  Magazine: "bg-media-magazine"
6083
6685
  };
6084
6686
  function MediaLabel({ type, className, testIdPrefix }) {
6085
- return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6687
+ return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
6086
6688
  "span",
6087
6689
  {
6088
6690
  className: cn(
@@ -6097,10 +6699,10 @@ function MediaLabel({ type, className, testIdPrefix }) {
6097
6699
  }
6098
6700
 
6099
6701
  // 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)(
6702
+ var import_react34 = require("react");
6703
+ var import_jsx_runtime60 = require("react/jsx-runtime");
6704
+ var SuggestionChip = (0, import_react34.forwardRef)(function SuggestionChip2({ children, className, testIdPrefix, type = "button", ...props }, ref) {
6705
+ return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
6104
6706
  "button",
6105
6707
  {
6106
6708
  ref,
@@ -6111,18 +6713,18 @@ var SuggestionChip = (0, import_react31.forwardRef)(function SuggestionChip2({ c
6111
6713
  "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
6714
  className
6113
6715
  ),
6114
- children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "truncate", children })
6716
+ children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "truncate", children })
6115
6717
  }
6116
6718
  );
6117
6719
  });
6118
6720
  SuggestionChip.displayName = "SuggestionChip";
6119
6721
 
6120
6722
  // src/ToggleChip.tsx
6121
- var import_react32 = require("react");
6122
- 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)(
6723
+ var import_react35 = require("react");
6724
+ var import_lucide_react32 = require("lucide-react");
6725
+ var import_jsx_runtime61 = require("react/jsx-runtime");
6726
+ var ToggleChip = (0, import_react35.forwardRef)(function ToggleChip2({ selected, onChange, children, className, testIdPrefix, type = "button", onClick, ...props }, ref) {
6727
+ return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
6126
6728
  "button",
6127
6729
  {
6128
6730
  ref,
@@ -6140,7 +6742,7 @@ var ToggleChip = (0, import_react32.forwardRef)(function ToggleChip2({ selected,
6140
6742
  className
6141
6743
  ),
6142
6744
  children: [
6143
- selected && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_lucide_react30.Check, { size: 14, "aria-hidden": "true", className: "-ml-0.5 shrink-0" }),
6745
+ selected && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_lucide_react32.Check, { size: 14, "aria-hidden": "true", className: "-ml-0.5 shrink-0" }),
6144
6746
  children
6145
6747
  ]
6146
6748
  }
@@ -6149,14 +6751,14 @@ var ToggleChip = (0, import_react32.forwardRef)(function ToggleChip2({ selected,
6149
6751
  ToggleChip.displayName = "ToggleChip";
6150
6752
 
6151
6753
  // src/CopyButton.tsx
6152
- var import_react33 = require("react");
6153
- var import_lucide_react31 = require("lucide-react");
6154
- var import_jsx_runtime59 = require("react/jsx-runtime");
6754
+ var import_react36 = require("react");
6755
+ var import_lucide_react33 = require("lucide-react");
6756
+ var import_jsx_runtime62 = require("react/jsx-runtime");
6155
6757
  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), []);
6758
+ var CopyButton = (0, import_react36.forwardRef)(function CopyButton2({ value, label, "aria-label": ariaLabel, size = "xs", className, testIdPrefix }, ref) {
6759
+ const [copied, setCopied] = (0, import_react36.useState)(false);
6760
+ const timer = (0, import_react36.useRef)(void 0);
6761
+ (0, import_react36.useEffect)(() => () => clearTimeout(timer.current), []);
6160
6762
  const copy = async () => {
6161
6763
  try {
6162
6764
  await navigator.clipboard.writeText(typeof value === "function" ? value() : value);
@@ -6168,8 +6770,8 @@ var CopyButton = (0, import_react33.forwardRef)(function CopyButton2({ value, la
6168
6770
  timer.current = setTimeout(() => setCopied(false), CONFIRM_MS);
6169
6771
  };
6170
6772
  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)(
6773
+ const icon = copied ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_lucide_react33.Check, { size: iconSize, "aria-hidden": "true", className: "shrink-0 text-text-success" }) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_lucide_react33.Copy, { size: iconSize, "aria-hidden": "true", className: "shrink-0" });
6774
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
6173
6775
  Button,
6174
6776
  {
6175
6777
  ref,
@@ -6183,8 +6785,8 @@ var CopyButton = (0, import_react33.forwardRef)(function CopyButton2({ value, la
6183
6785
  className: cn(!copied && "text-text-secondary", className),
6184
6786
  children: [
6185
6787
  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" : "" })
6788
+ label && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { children: copied ? "Copied" : label }),
6789
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { role: "status", className: "sr-only", children: copied ? "Copied" : "" })
6188
6790
  ]
6189
6791
  }
6190
6792
  );
@@ -6192,8 +6794,8 @@ var CopyButton = (0, import_react33.forwardRef)(function CopyButton2({ value, la
6192
6794
  CopyButton.displayName = "CopyButton";
6193
6795
 
6194
6796
  // src/InlineMessage.tsx
6195
- var import_lucide_react32 = require("lucide-react");
6196
- var import_jsx_runtime60 = require("react/jsx-runtime");
6797
+ var import_lucide_react34 = require("lucide-react");
6798
+ var import_jsx_runtime63 = require("react/jsx-runtime");
6197
6799
  var BOX = {
6198
6800
  info: "border-brand-primaryAction/30 bg-brand-primaryAction/10",
6199
6801
  success: "border-status-success/40 bg-status-success/10",
@@ -6207,30 +6809,30 @@ var ICON_INK = {
6207
6809
  warning: "text-text-warning",
6208
6810
  danger: "text-text-danger"
6209
6811
  };
6210
- var ICON2 = { info: import_lucide_react32.Info, success: import_lucide_react32.CheckCircle2, warning: import_lucide_react32.AlertTriangle, danger: import_lucide_react32.XCircle };
6812
+ var ICON2 = { info: import_lucide_react34.Info, success: import_lucide_react34.CheckCircle2, warning: import_lucide_react34.AlertTriangle, danger: import_lucide_react34.XCircle };
6211
6813
  function InlineMessage({ tone = "info", title, children, actions, onDismiss, className, testIdPrefix }) {
6212
6814
  const Icon = ICON2[tone];
6213
- return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
6815
+ return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
6214
6816
  "div",
6215
6817
  {
6216
6818
  role: tone === "warning" || tone === "danger" ? "alert" : "status",
6217
6819
  className: cn("flex items-start gap-2.5 rounded-control border px-3 py-2.5 text-sm", BOX[tone], className),
6218
6820
  "data-testid": testIdPrefix,
6219
6821
  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 })
6822
+ /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Icon, { size: 16, "aria-hidden": "true", className: cn("mt-0.5 shrink-0", ICON_INK[tone]) }),
6823
+ /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "min-w-0 flex-1", children: [
6824
+ /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", { className: "font-semibold text-text-primary", children: title }),
6825
+ children && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "mt-0.5 text-text-secondary", children }),
6826
+ actions && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "mt-2 flex flex-wrap items-center gap-2", children: actions })
6225
6827
  ] }),
6226
- onDismiss && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
6828
+ onDismiss && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
6227
6829
  "button",
6228
6830
  {
6229
6831
  type: "button",
6230
6832
  onClick: onDismiss,
6231
6833
  "aria-label": "Dismiss",
6232
6834
  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" })
6835
+ children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_lucide_react34.X, { size: 14, "aria-hidden": "true" })
6234
6836
  }
6235
6837
  )
6236
6838
  ]
@@ -6239,9 +6841,9 @@ function InlineMessage({ tone = "info", title, children, actions, onDismiss, cla
6239
6841
  }
6240
6842
 
6241
6843
  // src/FilterDrawer.tsx
6242
- var import_react34 = require("react");
6243
- var import_lucide_react33 = require("lucide-react");
6244
- var import_jsx_runtime61 = require("react/jsx-runtime");
6844
+ var import_react37 = require("react");
6845
+ var import_lucide_react35 = require("lucide-react");
6846
+ var import_jsx_runtime64 = require("react/jsx-runtime");
6245
6847
  var SLIDE_MS = 200;
6246
6848
  function reducedMotion() {
6247
6849
  return typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
@@ -6257,19 +6859,30 @@ function FilterDrawer({
6257
6859
  onApply,
6258
6860
  focus = null,
6259
6861
  size = "sm",
6862
+ hasChanges,
6260
6863
  testIdPrefix
6261
6864
  }) {
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);
6865
+ const marks = (list) => list.map((x) => `${x.id}:${x.count ?? 0}:${x.badge ?? ""}`).join("|");
6866
+ const [openedWith, setOpenedWith] = (0, import_react37.useState)(() => marks(sections));
6867
+ const [confirming, setConfirming] = (0, import_react37.useState)(false);
6868
+ const [view, setViewState] = (0, import_react37.useState)(focus);
6869
+ const [leaving, setLeaving] = (0, import_react37.useState)(null);
6870
+ const [phase, setPhase] = (0, import_react37.useState)("run");
6871
+ const [wasOpen, setWasOpen] = (0, import_react37.useState)(open);
6266
6872
  if (open !== wasOpen) {
6267
6873
  setWasOpen(open);
6874
+ setConfirming(false);
6268
6875
  if (open) {
6269
6876
  setViewState(focus);
6270
6877
  setLeaving(null);
6878
+ setOpenedWith(marks(sections));
6271
6879
  }
6272
6880
  }
6881
+ const changed = hasChanges ?? marks(sections) !== openedWith;
6882
+ const requestClose = () => {
6883
+ if (changed) setConfirming(true);
6884
+ else onClose();
6885
+ };
6273
6886
  const setView = (next) => {
6274
6887
  if (!reducedMotion()) {
6275
6888
  setLeaving({ view, dir: next ? 1 : -1 });
@@ -6277,20 +6890,20 @@ function FilterDrawer({
6277
6890
  }
6278
6891
  setViewState(next);
6279
6892
  };
6280
- (0, import_react34.useLayoutEffect)(() => {
6893
+ (0, import_react37.useLayoutEffect)(() => {
6281
6894
  if (phase !== "start") return;
6282
6895
  const raf = requestAnimationFrame(() => requestAnimationFrame(() => setPhase("run")));
6283
6896
  return () => cancelAnimationFrame(raf);
6284
6897
  }, [phase]);
6285
- (0, import_react34.useEffect)(() => {
6898
+ (0, import_react37.useEffect)(() => {
6286
6899
  if (!leaving || phase !== "run") return;
6287
6900
  const t = setTimeout(() => setLeaving(null), SLIDE_MS);
6288
6901
  return () => clearTimeout(t);
6289
6902
  }, [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)(() => {
6903
+ const backRef = (0, import_react37.useRef)(null);
6904
+ const rowRefs = (0, import_react37.useRef)(/* @__PURE__ */ new Map());
6905
+ const lastView = (0, import_react37.useRef)(null);
6906
+ (0, import_react37.useEffect)(() => {
6294
6907
  if (!open) return;
6295
6908
  if (view) backRef.current?.focus();
6296
6909
  else if (lastView.current) rowRefs.current.get(lastView.current)?.focus();
@@ -6303,8 +6916,8 @@ function FilterDrawer({
6303
6916
  const outgoing = phase === "start" ? void 0 : dir > 0 ? "translateX(-33%)" : "translateX(100%)";
6304
6917
  const panel = (v, rows = true) => {
6305
6918
  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)(
6919
+ if (s) return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "border-t border-border-default px-5 pt-4", children: renderSection(s.id) });
6920
+ return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("ul", { className: "border-t border-border-default", children: sections.map((x) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("li", { className: "border-b border-border-default", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
6308
6921
  "button",
6309
6922
  {
6310
6923
  ref: rows ? (el) => {
@@ -6316,7 +6929,7 @@ function FilterDrawer({
6316
6929
  "data-testid": testIdPrefix && `${testIdPrefix}-row-${x.id}`,
6317
6930
  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
6931
  children: [
6319
- /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
6932
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
6320
6933
  x.icon,
6321
6934
  {
6322
6935
  size: 17,
@@ -6324,100 +6937,132 @@ function FilterDrawer({
6324
6937
  className: inUse(x) ? "text-brand-primaryAction" : "text-text-secondary"
6325
6938
  }
6326
6939
  ),
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" })
6940
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "flex-1 text-sm font-medium text-text-primary", children: x.label }),
6941
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(SectionMark, { section: x }),
6942
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_lucide_react35.ChevronRight, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-secondary" })
6330
6943
  ]
6331
6944
  }
6332
6945
  ) }, x.id)) });
6333
6946
  };
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)(
6947
+ return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
6948
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
6949
+ Modal,
6950
+ {
6951
+ open: open && confirming,
6952
+ onClose: () => setConfirming(false),
6953
+ size: "sm",
6954
+ title: "Discard changes?",
6955
+ description: "Your filter picks haven't been applied.",
6956
+ testIdPrefix: testIdPrefix && `${testIdPrefix}-discard`,
6957
+ footer: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
6958
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Button, { variant: "secondary", size: "md", onClick: () => setConfirming(false), children: "Keep editing" }),
6959
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
6366
6960
  Button,
6367
6961
  {
6368
- variant: "primary",
6962
+ variant: "danger",
6369
6963
  size: "md",
6370
6964
  onClick: () => {
6371
- onApply();
6965
+ setConfirming(false);
6372
6966
  onClose();
6373
6967
  },
6374
- children: "See results"
6968
+ children: "Discard"
6375
6969
  }
6376
6970
  )
6377
6971
  ] })
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
- );
6972
+ }
6973
+ ),
6974
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
6975
+ Drawer,
6976
+ {
6977
+ open,
6978
+ onClose: requestClose,
6979
+ size,
6980
+ testIdPrefix,
6981
+ title: focused ? /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("span", { className: "flex items-center gap-1.5", children: [
6982
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
6983
+ "button",
6984
+ {
6985
+ ref: backRef,
6986
+ type: "button",
6987
+ onClick: () => setView(null),
6988
+ "aria-label": "Back to all filters",
6989
+ "data-testid": testIdPrefix && `${testIdPrefix}-back`,
6990
+ 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",
6991
+ children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_lucide_react35.ChevronLeft, { size: 18, "aria-hidden": "true" })
6992
+ }
6993
+ ),
6994
+ focused.label,
6995
+ (focused.count ?? 0) > 0 && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(CountBadge, { count: focused.count }),
6996
+ focused.info && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(InfoTip, { text: focused.info, label: `About ${focused.label}` })
6997
+ ] }) : "Filters",
6998
+ footer: focused ? (
6999
+ // Picks are kept as they're made; Apply goes back to the list, and only
7000
+ // See results, on the list, applies them to the page.
7001
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex w-full items-center justify-between gap-2", children: [
7002
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Button, { variant: "link", size: "md", onClick: () => onClearSection(focused.id), className: "px-0", children: "Clear" }),
7003
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Button, { variant: "primary", size: "md", onClick: () => setView(null), testIdPrefix: testIdPrefix && `${testIdPrefix}-apply-section`, children: "Apply" })
7004
+ ] })
7005
+ ) : /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex w-full items-center justify-between gap-2", children: [
7006
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Button, { variant: "link", size: "md", onClick: onClearAll, className: "px-0", children: "Clear all" }),
7007
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-2", children: [
7008
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Button, { variant: "secondary", size: "md", onClick: onClose, children: "Cancel" }),
7009
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
7010
+ Button,
7011
+ {
7012
+ variant: "primary",
7013
+ size: "md",
7014
+ onClick: () => {
7015
+ onApply();
7016
+ onClose();
7017
+ },
7018
+ children: "See results"
7019
+ }
7020
+ )
7021
+ ] })
7022
+ ] }),
7023
+ children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "relative -mx-5 overflow-x-clip", children: [
7024
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
7025
+ "div",
7026
+ {
7027
+ style: { transform: incoming },
7028
+ className: cn(moving && "transition-transform duration-(--mr-motion-duration-interactive) ease-interactive motion-reduce:transition-none"),
7029
+ children: panel(view)
7030
+ },
7031
+ view ?? "__list"
7032
+ ),
7033
+ leaving && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
7034
+ "div",
7035
+ {
7036
+ "aria-hidden": "true",
7037
+ ref: (el) => el?.setAttribute("inert", ""),
7038
+ style: { transform: outgoing, opacity: phase === "start" ? 1 : dir > 0 ? 0.4 : 1 },
7039
+ className: "pointer-events-none absolute inset-x-0 top-0 transition duration-(--mr-motion-duration-interactive) ease-interactive motion-reduce:transition-none",
7040
+ children: panel(leaving.view, false)
7041
+ }
7042
+ )
7043
+ ] })
7044
+ }
7045
+ )
7046
+ ] });
6402
7047
  }
6403
7048
  var inUse = (x) => (x.count ?? 0) > 0 || !!x.badge;
6404
7049
  function CountBadge({ count }) {
6405
- return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(Badge, { tone: "brandSolid", kind: "count", children: [
7050
+ return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Badge, { tone: "brandSolid", kind: "count", children: [
6406
7051
  count,
6407
- /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { className: "sr-only", children: " selected" })
7052
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "sr-only", children: " selected" })
6408
7053
  ] });
6409
7054
  }
6410
7055
  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;
7056
+ if ((section.count ?? 0) > 0) return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(CountBadge, { count: section.count });
7057
+ return section.badge ? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Badge, { tone: "brand", children: section.badge }) : null;
6413
7058
  }
6414
7059
 
6415
7060
  // src/AllFiltersButton.tsx
6416
- var import_react35 = require("react");
6417
- 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)(
7061
+ var import_react38 = require("react");
7062
+ var import_lucide_react36 = require("lucide-react");
7063
+ var import_jsx_runtime65 = require("react/jsx-runtime");
7064
+ var AllFiltersButton = (0, import_react38.forwardRef)(function AllFiltersButton2({ count = 0, open, className, testIdPrefix, ...rest }, ref) {
7065
+ return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
6421
7066
  "button",
6422
7067
  {
6423
7068
  ref,
@@ -6429,105 +7074,14 @@ var AllFiltersButton = (0, import_react35.forwardRef)(function AllFiltersButton2
6429
7074
  className: cn(chipTriggerClass(), className),
6430
7075
  ...rest,
6431
7076
  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 })
7077
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_lucide_react36.SlidersHorizontal, { size: 15, "aria-hidden": "true", className: "text-text-secondary" }),
7078
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "text-dense font-medium text-text-primary", children: "All filters" }),
7079
+ count > 0 && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Badge, { tone: "brandSolid", kind: "count", children: count })
6435
7080
  ]
6436
7081
  }
6437
7082
  );
6438
7083
  });
6439
7084
 
6440
- // src/Menu.tsx
6441
- var import_react36 = require("react");
6442
- var import_react_slot2 = require("@radix-ui/react-slot");
6443
- var import_lucide_react35 = require("lucide-react");
6444
- var import_jsx_runtime63 = require("react/jsx-runtime");
6445
- var ROW_SELECTOR = '[role^="menuitem"]:not([aria-disabled="true"]):not(:disabled)';
6446
- function moveFocus(e) {
6447
- const keys = ["ArrowDown", "ArrowUp", "Home", "End"];
6448
- if (!keys.includes(e.key)) return;
6449
- const rows = Array.from(e.currentTarget.querySelectorAll(ROW_SELECTOR));
6450
- if (!rows.length) return;
6451
- e.preventDefault();
6452
- const i = rows.indexOf(document.activeElement);
6453
- 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
- rows[next].focus();
6455
- }
6456
- var Menu = (0, import_react36.forwardRef)(
6457
- ({ className, testIdPrefix, onKeyDown, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
6458
- "div",
6459
- {
6460
- ref,
6461
- role: "menu",
6462
- "data-testid": testIdPrefix,
6463
- onKeyDown: (e) => {
6464
- moveFocus(e);
6465
- onKeyDown?.(e);
6466
- },
6467
- className: cn("flex flex-col p-1", className),
6468
- ...props,
6469
- children
6470
- }
6471
- )
6472
- );
6473
- Menu.displayName = "Menu";
6474
- var MenuItem = (0, import_react36.forwardRef)(
6475
- ({ className, testIdPrefix, icon, trailing, description, submenu, checked, danger, disabled, asChild = false, children, ...props }, ref) => {
6476
- const Comp = asChild ? import_react_slot2.Slot : "button";
6477
- const radio = checked !== void 0;
6478
- return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
6479
- Comp,
6480
- {
6481
- ref,
6482
- type: asChild ? void 0 : "button",
6483
- role: radio ? "menuitemradio" : "menuitem",
6484
- "aria-checked": radio ? checked : void 0,
6485
- "aria-haspopup": submenu ? "menu" : void 0,
6486
- "aria-disabled": disabled || void 0,
6487
- disabled: asChild ? void 0 : disabled,
6488
- tabIndex: -1,
6489
- "data-testid": testIdPrefix,
6490
- className: cn(
6491
- "flex min-h-9 w-full items-center gap-2.5 rounded-control px-3 py-1.5 text-left text-sm transition-colors",
6492
- "focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
6493
- danger ? "text-text-danger" : "text-text-primary",
6494
- disabled ? "cursor-not-allowed opacity-40" : "hover:bg-subtle focus-visible:bg-subtle",
6495
- className
6496
- ),
6497
- ...props,
6498
- children: [
6499
- 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 }),
6500
- asChild ? (
6501
- // The link's own text lands here; the link becomes the row.
6502
- /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_react_slot2.Slottable, { children })
6503
- ) : /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("span", { className: "min-w-0 flex-1", children: [
6504
- /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { className: "block truncate", children }),
6505
- description && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { className: "block truncate text-xs text-text-tertiary", children: description })
6506
- ] }),
6507
- trailing && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { className: "ml-auto flex shrink-0 items-center text-xs text-text-secondary", children: trailing }),
6508
- radio && checked && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_lucide_react35.Check, { size: 16, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }),
6509
- submenu && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_lucide_react35.ChevronRight, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-secondary" })
6510
- ]
6511
- }
6512
- );
6513
- }
6514
- );
6515
- MenuItem.displayName = "MenuItem";
6516
- function MenuLabel({ className, testIdPrefix, children }) {
6517
- return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
6518
- "div",
6519
- {
6520
- role: "presentation",
6521
- "data-testid": testIdPrefix,
6522
- className: cn("px-3 pb-1 pt-2 text-micro font-semibold uppercase tracking-wide text-text-tertiary", className),
6523
- children
6524
- }
6525
- );
6526
- }
6527
- function MenuSeparator({ className, testIdPrefix }) {
6528
- 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) });
6529
- }
6530
-
6531
7085
  // src/dates.ts
6532
7086
  var MONTHS2 = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
6533
7087
  var MONTHS_LONG = [
@@ -6639,15 +7193,15 @@ function defaultDateOrder(country) {
6639
7193
  }
6640
7194
 
6641
7195
  // src/Figure.tsx
6642
- var import_jsx_runtime64 = require("react/jsx-runtime");
7196
+ var import_jsx_runtime66 = require("react/jsx-runtime");
6643
7197
  function Figure({ value, kind = "money", missing, ...opts }) {
6644
- if (value === null || value === void 0 || Number.isNaN(value)) return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(NoValue, { reason: missing });
7198
+ if (value === null || value === void 0 || Number.isNaN(value)) return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(NoValue, { reason: missing });
6645
7199
  const short = kind === "money" ? formatMoney(value, opts) : formatCount(value, opts);
6646
7200
  const full = kind === "money" ? formatMoneyFull(value, opts) : formatCountFull(value);
6647
- if (short === full) return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_jsx_runtime64.Fragment, { children: short });
6648
- return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Tooltip, { label: full, delay: 300, children: [
6649
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { "aria-hidden": "true", children: short }),
6650
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "sr-only", children: full })
7201
+ if (short === full) return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_jsx_runtime66.Fragment, { children: short });
7202
+ return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(Tooltip, { label: full, delay: 300, children: [
7203
+ /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { "aria-hidden": "true", children: short }),
7204
+ /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { className: "sr-only", children: full })
6651
7205
  ] });
6652
7206
  }
6653
7207
  // Annotate the CommonJS export names for ESM import in node:
@@ -6723,6 +7277,7 @@ function Figure({ value, kind = "money", missing, ...opts }) {
6723
7277
  StatStrip,
6724
7278
  StatStripSkeleton,
6725
7279
  StatTile,
7280
+ StickyBar,
6726
7281
  SuggestionChip,
6727
7282
  TableLink,
6728
7283
  TablePagination,