@mediaradar/design-components 0.60.0 → 0.62.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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.60.0",
2
+ "version": "0.62.0",
3
3
  "components": [
4
4
  "AISpark",
5
5
  "AdvertiserNoResults",
package/dist/index.cjs CHANGED
@@ -5626,6 +5626,12 @@ function DataTable({
5626
5626
  renderExpanded,
5627
5627
  canExpand,
5628
5628
  rowLabel,
5629
+ selected,
5630
+ onSelectedChange,
5631
+ totalCount,
5632
+ onSelectAll,
5633
+ selectedCount,
5634
+ selectionActions,
5629
5635
  density = "default",
5630
5636
  loading = false,
5631
5637
  loadingRows = 5,
@@ -5666,16 +5672,86 @@ function DataTable({
5666
5672
  if (window.getSelection?.()?.toString()) return;
5667
5673
  toggle(key);
5668
5674
  };
5669
- const span = columns.length + (anyExpandable ? 1 : 0);
5675
+ const selectable = !!onSelectedChange;
5676
+ const picked = new Set(selected ?? []);
5677
+ const visible = rows.map(rowKey);
5678
+ const allVisible = visible.length > 0 && visible.every((k) => picked.has(k));
5679
+ const someVisible = visible.some((k) => picked.has(k));
5680
+ const setPicked = (next) => onSelectedChange?.([...next]);
5681
+ const toggleAllVisible = () => {
5682
+ const next = new Set(picked);
5683
+ visible.forEach((k) => allVisible ? next.delete(k) : next.add(k));
5684
+ setPicked(next);
5685
+ };
5686
+ const lastPicked = (0, import_react29.useRef)(null);
5687
+ const shiftHeld = (0, import_react29.useRef)(false);
5688
+ const togglePick = (index) => {
5689
+ const key = visible[index];
5690
+ const on = !picked.has(key);
5691
+ const next = new Set(picked);
5692
+ const from = shiftHeld.current && lastPicked.current !== null ? Math.min(lastPicked.current, index) : index;
5693
+ const to = shiftHeld.current && lastPicked.current !== null ? Math.max(lastPicked.current, index) : index;
5694
+ for (let i = from; i <= to; i++) on ? next.add(visible[i]) : next.delete(visible[i]);
5695
+ lastPicked.current = index;
5696
+ setPicked(next);
5697
+ };
5698
+ const count = selectedCount ?? picked.size;
5699
+ const scroller = (0, import_react29.useRef)(null);
5700
+ const [pinned, setPinned] = (0, import_react29.useState)(false);
5701
+ const [scrolled, setScrolled] = (0, import_react29.useState)(false);
5702
+ const heads = (0, import_react29.useRef)(/* @__PURE__ */ new Map());
5703
+ const [lefts, setLefts] = (0, import_react29.useState)({});
5704
+ (0, import_react29.useEffect)(() => {
5705
+ const el = scroller.current;
5706
+ if (!el || typeof ResizeObserver === "undefined") return void 0;
5707
+ const measure = () => {
5708
+ setPinned(el.scrollWidth > el.clientWidth + 1);
5709
+ const next = {};
5710
+ heads.current.forEach((th, id) => next[id] = th.offsetLeft);
5711
+ setLefts((prev) => Object.keys(next).every((k) => prev[k] === next[k]) && Object.keys(prev).length === Object.keys(next).length ? prev : next);
5712
+ };
5713
+ measure();
5714
+ const ro = new ResizeObserver(measure);
5715
+ ro.observe(el);
5716
+ if (el.firstElementChild) ro.observe(el.firstElementChild);
5717
+ return () => ro.disconnect();
5718
+ }, []);
5719
+ const nameIdx = Math.max(0, columns.findIndex((c) => !c.rank));
5720
+ const leftOf = (part) => lefts[String(part)] ?? 0;
5721
+ const headRef = (part) => (el) => {
5722
+ if (el) heads.current.set(String(part), el);
5723
+ else heads.current.delete(String(part));
5724
+ };
5725
+ const isPinned = (part) => pinned && (typeof part !== "number" || part <= nameIdx);
5726
+ const pinCls = (part, where, rowBg) => isPinned(part) ? cn(
5727
+ "sticky z-1",
5728
+ where === "head" ? "bg-subtle" : rowBg ?? "bg-surface group-hover/row:bg-subtle",
5729
+ part === nameIdx && "max-w-60 border-r border-r-border-default"
5730
+ ) : "";
5731
+ const pinStyle = (part) => isPinned(part) ? { left: leftOf(part) } : void 0;
5732
+ 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;
5733
+ const span = columns.length + (anyExpandable ? 1 : 0) + (selectable ? 1 : 0);
5670
5734
  const renderCell = (c, row) => {
5671
5735
  const v = c.cell(row);
5672
5736
  return v === null || v === void 0 || v === "" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(NoValue, { reason: c.missing }) : v;
5673
5737
  };
5674
5738
  const inside = variant === "chart";
5739
+ const bar = selectable && count > 0 ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 text-dense", children: [
5740
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("span", { role: "status", className: "font-medium text-text-primary", children: [
5741
+ formatCountFull(count),
5742
+ " selected"
5743
+ ] }),
5744
+ allVisible && totalCount !== void 0 && count < totalCount && onSelectAll && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(Button, { variant: "link", size: "sm", onClick: onSelectAll, children: [
5745
+ "Select all ",
5746
+ formatCountFull(totalCount)
5747
+ ] }),
5748
+ selectionActions,
5749
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Button, { variant: "link", size: "sm", onClick: () => onSelectedChange?.([]), children: "Clear" })
5750
+ ] }) : null;
5675
5751
  const frame = /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
5676
5752
  "div",
5677
5753
  {
5678
- className: cn("relative flex w-full flex-col overflow-hidden rounded-card border border-border-default bg-surface", !(title && !inside) && className),
5754
+ className: cn("relative flex w-full flex-col overflow-hidden rounded-card border border-border-default bg-surface", (inside || !title && count === 0) && className),
5679
5755
  "data-testid": testIdPrefix,
5680
5756
  children: [
5681
5757
  title && inside && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
@@ -5683,108 +5759,160 @@ function DataTable({
5683
5759
  /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("h3", { id: titleId, className: "text-panel-title font-semibold text-text-primary", children: title }),
5684
5760
  subtitle && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "mt-0.5 text-xs leading-snug text-text-tertiary", children: subtitle })
5685
5761
  ] }),
5686
- action && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "shrink-0 text-text-tertiary", children: action })
5762
+ (bar ?? action) && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "shrink-0 text-text-tertiary", children: bar ?? action })
5687
5763
  ] }),
5688
- /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: cn("overflow-x-auto", maxHeight && cn("overflow-y-auto", MAX_H[maxHeight])), children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
5689
- "table",
5764
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5765
+ "div",
5690
5766
  {
5691
- "aria-labelledby": title ? titleId : void 0,
5692
- "aria-label": title ? void 0 : rest["aria-label"],
5693
- "aria-busy": loading || refreshing || void 0,
5694
- className: "w-full border-collapse text-left",
5695
- children: [
5696
- /* @__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: [
5697
- anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("th", { scope: "col", className: cn("w-10 border-b border-border-default", head), children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "sr-only", children: "Details" }) }),
5698
- columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5699
- "th",
5700
- {
5701
- scope: "col",
5702
- "aria-sort": c.sortable ? ariaSortFor(shown, c.key) : void 0,
5703
- className: cn("group/head whitespace-nowrap border-b border-border-default font-semibold", head, align(c), width(c)),
5704
- children: c.sortable && onSortChange ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5705
- SortButton,
5767
+ ref: scroller,
5768
+ onScroll: (e) => setScrolled(e.currentTarget.scrollLeft > 0),
5769
+ className: cn("overflow-x-auto", maxHeight && cn("overflow-y-auto", MAX_H[maxHeight])),
5770
+ children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
5771
+ "table",
5772
+ {
5773
+ "aria-labelledby": title ? titleId : void 0,
5774
+ "aria-label": title ? void 0 : rest["aria-label"],
5775
+ "aria-busy": loading || refreshing || void 0,
5776
+ className: "w-full border-separate border-spacing-0 text-left",
5777
+ children: [
5778
+ /* @__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: [
5779
+ 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: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5780
+ CheckBox,
5706
5781
  {
5707
- label: c.label,
5708
- sortKey: c.key,
5709
- align: right(c) ? "right" : "left",
5710
- sort: sortProp(shown),
5711
- onSort,
5712
- description: c.info,
5713
- testIdPrefix
5782
+ checked: allVisible,
5783
+ indeterminate: someVisible && !allVisible,
5784
+ onChange: toggleAllVisible,
5785
+ ariaLabel: allVisible ? "Deselect all rows on this page" : "Select all rows on this page"
5714
5786
  }
5715
- ) : c.info ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(SortButton, { label: c.label, sortKey: c.key, sortable: false, sort: sortProp(shown), onSort: () => {
5716
- }, description: c.info, align: right(c) ? "right" : "left" }) : c.label
5717
- },
5718
- c.key
5719
- ))
5720
- ] }) }),
5721
- /* @__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: [
5722
- anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { className: cn("border-b border-border-default", pad2) }),
5723
- 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))
5724
- ] }, 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, {}) }) }) : rows.map((row, index) => {
5725
- const key = rowKey(row);
5726
- const canOpen = expandable(row);
5727
- const isOpen = canOpen && open.has(key);
5728
- const panelId = `${titleId}-row-${index}`;
5729
- return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_react29.Fragment, { children: [
5730
- /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
5731
- "tr",
5732
- {
5733
- onClick: canOpen ? (e) => onRowClick(e, key) : void 0,
5734
- className: cn("hover:bg-subtle [&:last-child>td]:border-b-0", canOpen && "cursor-pointer", isOpen && "bg-subtle"),
5735
- children: [
5736
- anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { className: cn("border-b border-border-default pr-0", pad2, isOpen && "border-b-0"), children: canOpen && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5737
- "button",
5738
- {
5739
- type: "button",
5740
- "aria-expanded": isOpen,
5741
- "aria-controls": isOpen ? panelId : void 0,
5742
- "aria-label": `${isOpen ? "Hide" : "Show"} details${rowLabel ? ` for ${rowLabel(row)}` : ""}`,
5743
- onClick: () => toggle(key),
5744
- 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",
5745
- children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5746
- import_lucide_react29.ChevronRight,
5787
+ ) }),
5788
+ 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" }) }),
5789
+ columns.map((c, ci) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
5790
+ "th",
5791
+ {
5792
+ ref: ci <= nameIdx ? headRef(ci) : void 0,
5793
+ scope: "col",
5794
+ "aria-sort": c.sortable ? ariaSortFor(shown, c.key) : void 0,
5795
+ className: cn("group/head whitespace-nowrap border-b border-border-default font-semibold", head, align(c), width(c), pinCls(ci, "head")),
5796
+ style: pinStyle(ci),
5797
+ children: [
5798
+ c.sortable && onSortChange ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5799
+ SortButton,
5800
+ {
5801
+ label: c.label,
5802
+ sortKey: c.key,
5803
+ align: right(c) ? "right" : "left",
5804
+ sort: sortProp(shown),
5805
+ onSort,
5806
+ description: c.info,
5807
+ testIdPrefix
5808
+ }
5809
+ ) : c.info ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(SortButton, { label: c.label, sortKey: c.key, sortable: false, sort: sortProp(shown), onSort: () => {
5810
+ }, description: c.info, align: right(c) ? "right" : "left" }) : c.label,
5811
+ edge(ci)
5812
+ ]
5813
+ },
5814
+ c.key
5815
+ ))
5816
+ ] }) }),
5817
+ /* @__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: [
5818
+ selectable && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { className: cn("border-b border-border-default", pad2) }),
5819
+ anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { className: cn("border-b border-border-default", pad2) }),
5820
+ 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))
5821
+ ] }, 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, {}) }) }) : rows.map((row, ri) => {
5822
+ const key = rowKey(row);
5823
+ const canOpen = expandable(row);
5824
+ const isOpen = canOpen && open.has(key);
5825
+ const panelId = `${titleId}-row-${ri}`;
5826
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_react29.Fragment, { children: [
5827
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
5828
+ "tr",
5829
+ {
5830
+ onClick: canOpen ? (e) => onRowClick(e, key) : void 0,
5831
+ className: cn("group/row hover:bg-subtle [&:last-child>td]:border-b-0", canOpen && "cursor-pointer", isOpen && "bg-subtle"),
5832
+ children: [
5833
+ selectable && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5834
+ "td",
5747
5835
  {
5748
- size: 16,
5749
- "aria-hidden": "true",
5750
- className: cn("transition-transform motion-reduce:transition-none", isOpen && "rotate-90")
5836
+ onPointerDownCapture: (e) => shiftHeld.current = e.shiftKey,
5837
+ onKeyDownCapture: (e) => shiftHeld.current = e.shiftKey,
5838
+ className: cn("border-b border-border-default pr-0", pad2, isOpen && "border-b-0", pinCls("select", "body", isOpen ? "bg-subtle" : void 0)),
5839
+ style: pinStyle("select"),
5840
+ children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5841
+ CheckBox,
5842
+ {
5843
+ checked: picked.has(key),
5844
+ onChange: () => togglePick(ri),
5845
+ ariaLabel: `Select ${rowLabel ? rowLabel(row) : "row"}`
5846
+ }
5847
+ )
5751
5848
  }
5752
- )
5753
- }
5754
- ) }),
5755
- columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5756
- "td",
5757
- {
5758
- className: cn(
5759
- "border-b border-border-default",
5760
- pad2,
5761
- align(c),
5762
- right(c) && "tabular-nums",
5763
- c.rank && "text-text-tertiary",
5764
- isOpen && "border-b-0"
5765
5849
  ),
5766
- children: renderCell(c, row)
5767
- },
5768
- c.key
5769
- ))
5770
- ]
5771
- }
5772
- ),
5773
- isOpen && /* @__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) }) })
5774
- ] }, key);
5775
- }) })
5776
- ]
5850
+ anyExpandable && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5851
+ "td",
5852
+ {
5853
+ className: cn("border-b border-border-default pr-0", pad2, isOpen && "border-b-0", pinCls("expand", "body", isOpen ? "bg-subtle" : void 0)),
5854
+ style: pinStyle("expand"),
5855
+ children: canOpen && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5856
+ "button",
5857
+ {
5858
+ type: "button",
5859
+ "aria-expanded": isOpen,
5860
+ "aria-controls": isOpen ? panelId : void 0,
5861
+ "aria-label": `${isOpen ? "Hide" : "Show"} details${rowLabel ? ` for ${rowLabel(row)}` : ""}`,
5862
+ onClick: () => toggle(key),
5863
+ 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",
5864
+ children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
5865
+ import_lucide_react29.ChevronRight,
5866
+ {
5867
+ size: 16,
5868
+ "aria-hidden": "true",
5869
+ className: cn("transition-transform motion-reduce:transition-none", isOpen && "rotate-90")
5870
+ }
5871
+ )
5872
+ }
5873
+ )
5874
+ }
5875
+ ),
5876
+ columns.map((c, ci) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
5877
+ "td",
5878
+ {
5879
+ className: cn(
5880
+ "border-b border-border-default",
5881
+ pad2,
5882
+ align(c),
5883
+ right(c) && "tabular-nums",
5884
+ c.rank && "text-text-tertiary",
5885
+ isOpen && "border-b-0",
5886
+ pinCls(ci, "body", isOpen ? "bg-subtle" : void 0)
5887
+ ),
5888
+ style: pinStyle(ci),
5889
+ children: [
5890
+ pinned && ci === nameIdx ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Tooltip, { label: renderCell(c, row), whenTruncated: true, delay: 300, className: "block truncate", children: renderCell(c, row) }) : renderCell(c, row),
5891
+ edge(ci)
5892
+ ]
5893
+ },
5894
+ c.key
5895
+ ))
5896
+ ]
5897
+ }
5898
+ ),
5899
+ isOpen && /* @__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) }) })
5900
+ ] }, key);
5901
+ }) })
5902
+ ]
5903
+ }
5904
+ )
5777
5905
  }
5778
- ) }),
5906
+ ),
5779
5907
  refreshing && !loading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(RefreshLine, {}),
5780
5908
  /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(LongWait, { loading, onRetry, className: "mb-3 px-4" }),
5781
5909
  footer && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "border-t border-border-default px-4 py-3", children: footer })
5782
5910
  ]
5783
5911
  }
5784
5912
  );
5785
- if (!title || inside) return frame;
5786
- return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("section", { "aria-labelledby": titleId, className: cn("flex w-full flex-col gap-3", className), children: [
5787
- /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(SectionHeading, { id: titleId, as: titleAs, title, description: subtitle, actions: action }),
5913
+ if (inside || !title && count === 0) return frame;
5914
+ 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: [
5915
+ 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 }),
5788
5916
  frame
5789
5917
  ] });
5790
5918
  }
@@ -5970,7 +6098,7 @@ function FilterDrawer({
5970
6098
  onClose,
5971
6099
  sections,
5972
6100
  renderSection,
5973
- activeCount = 0,
6101
+ activeCount: _activeCount,
5974
6102
  onClearSection,
5975
6103
  onClearAll,
5976
6104
  onApply,
@@ -6040,11 +6168,11 @@ function FilterDrawer({
6040
6168
  {
6041
6169
  size: 17,
6042
6170
  "aria-hidden": "true",
6043
- className: x.badge ? "text-brand-primaryAction" : "text-text-secondary"
6171
+ className: inUse(x) ? "text-brand-primaryAction" : "text-text-secondary"
6044
6172
  }
6045
6173
  ),
6046
6174
  /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { className: "flex-1 text-sm font-medium text-text-primary", children: x.label }),
6047
- x.badge && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Badge, { tone: "brand", children: x.badge }),
6175
+ /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(SectionMark, { section: x }),
6048
6176
  /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_lucide_react33.ChevronRight, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-secondary" })
6049
6177
  ]
6050
6178
  }
@@ -6071,11 +6199,9 @@ function FilterDrawer({
6071
6199
  }
6072
6200
  ),
6073
6201
  focused.label,
6202
+ (focused.count ?? 0) > 0 && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(CountBadge, { count: focused.count }),
6074
6203
  focused.info && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(InfoTip, { text: focused.info, label: `About ${focused.label}` })
6075
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("span", { className: "flex items-center gap-2.5", children: [
6076
- "Filters",
6077
- activeCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Badge, { tone: "brandSolid", kind: "count", children: activeCount })
6078
- ] }),
6204
+ ] }) : "Filters",
6079
6205
  footer: focused ? (
6080
6206
  // Picks are kept as they're made; only See results, on the list, applies them.
6081
6207
  /* @__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" }) })
@@ -6121,6 +6247,17 @@ function FilterDrawer({
6121
6247
  }
6122
6248
  );
6123
6249
  }
6250
+ var inUse = (x) => (x.count ?? 0) > 0 || !!x.badge;
6251
+ function CountBadge({ count }) {
6252
+ return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(Badge, { tone: "brandSolid", kind: "count", children: [
6253
+ count,
6254
+ /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { className: "sr-only", children: " selected" })
6255
+ ] });
6256
+ }
6257
+ function SectionMark({ section }) {
6258
+ if ((section.count ?? 0) > 0) return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(CountBadge, { count: section.count });
6259
+ return section.badge ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Badge, { tone: "brand", children: section.badge }) : null;
6260
+ }
6124
6261
 
6125
6262
  // src/AllFiltersButton.tsx
6126
6263
  var import_react34 = require("react");