@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.
- package/dist/approved-components.json +1 -1
- package/dist/index.cjs +234 -97
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -9
- package/dist/index.d.ts +35 -9
- package/dist/index.js +241 -104
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5395,7 +5395,7 @@ function Drawer({ open, onClose, title, description, size = "sm", footer, childr
|
|
|
5395
5395
|
}
|
|
5396
5396
|
|
|
5397
5397
|
// src/DataTable.tsx
|
|
5398
|
-
import { Fragment as Fragment7, useEffect as useEffect17, useId as useId10, useState as useState18 } from "react";
|
|
5398
|
+
import { Fragment as Fragment7, useEffect as useEffect17, useId as useId10, useRef as useRef19, useState as useState18 } from "react";
|
|
5399
5399
|
import { ChevronRight as ChevronRight6 } from "lucide-react";
|
|
5400
5400
|
|
|
5401
5401
|
// src/numbers.ts
|
|
@@ -5494,6 +5494,12 @@ function DataTable({
|
|
|
5494
5494
|
renderExpanded,
|
|
5495
5495
|
canExpand,
|
|
5496
5496
|
rowLabel,
|
|
5497
|
+
selected,
|
|
5498
|
+
onSelectedChange,
|
|
5499
|
+
totalCount,
|
|
5500
|
+
onSelectAll,
|
|
5501
|
+
selectedCount,
|
|
5502
|
+
selectionActions,
|
|
5497
5503
|
density = "default",
|
|
5498
5504
|
loading = false,
|
|
5499
5505
|
loadingRows = 5,
|
|
@@ -5534,16 +5540,86 @@ function DataTable({
|
|
|
5534
5540
|
if (window.getSelection?.()?.toString()) return;
|
|
5535
5541
|
toggle(key);
|
|
5536
5542
|
};
|
|
5537
|
-
const
|
|
5543
|
+
const selectable = !!onSelectedChange;
|
|
5544
|
+
const picked = new Set(selected ?? []);
|
|
5545
|
+
const visible = rows.map(rowKey);
|
|
5546
|
+
const allVisible = visible.length > 0 && visible.every((k) => picked.has(k));
|
|
5547
|
+
const someVisible = visible.some((k) => picked.has(k));
|
|
5548
|
+
const setPicked = (next) => onSelectedChange?.([...next]);
|
|
5549
|
+
const toggleAllVisible = () => {
|
|
5550
|
+
const next = new Set(picked);
|
|
5551
|
+
visible.forEach((k) => allVisible ? next.delete(k) : next.add(k));
|
|
5552
|
+
setPicked(next);
|
|
5553
|
+
};
|
|
5554
|
+
const lastPicked = useRef19(null);
|
|
5555
|
+
const shiftHeld = useRef19(false);
|
|
5556
|
+
const togglePick = (index) => {
|
|
5557
|
+
const key = visible[index];
|
|
5558
|
+
const on = !picked.has(key);
|
|
5559
|
+
const next = new Set(picked);
|
|
5560
|
+
const from = shiftHeld.current && lastPicked.current !== null ? Math.min(lastPicked.current, index) : index;
|
|
5561
|
+
const to = shiftHeld.current && lastPicked.current !== null ? Math.max(lastPicked.current, index) : index;
|
|
5562
|
+
for (let i = from; i <= to; i++) on ? next.add(visible[i]) : next.delete(visible[i]);
|
|
5563
|
+
lastPicked.current = index;
|
|
5564
|
+
setPicked(next);
|
|
5565
|
+
};
|
|
5566
|
+
const count = selectedCount ?? picked.size;
|
|
5567
|
+
const scroller = useRef19(null);
|
|
5568
|
+
const [pinned, setPinned] = useState18(false);
|
|
5569
|
+
const [scrolled, setScrolled] = useState18(false);
|
|
5570
|
+
const heads = useRef19(/* @__PURE__ */ new Map());
|
|
5571
|
+
const [lefts, setLefts] = useState18({});
|
|
5572
|
+
useEffect17(() => {
|
|
5573
|
+
const el = scroller.current;
|
|
5574
|
+
if (!el || typeof ResizeObserver === "undefined") return void 0;
|
|
5575
|
+
const measure = () => {
|
|
5576
|
+
setPinned(el.scrollWidth > el.clientWidth + 1);
|
|
5577
|
+
const next = {};
|
|
5578
|
+
heads.current.forEach((th, id) => next[id] = th.offsetLeft);
|
|
5579
|
+
setLefts((prev) => Object.keys(next).every((k) => prev[k] === next[k]) && Object.keys(prev).length === Object.keys(next).length ? prev : next);
|
|
5580
|
+
};
|
|
5581
|
+
measure();
|
|
5582
|
+
const ro = new ResizeObserver(measure);
|
|
5583
|
+
ro.observe(el);
|
|
5584
|
+
if (el.firstElementChild) ro.observe(el.firstElementChild);
|
|
5585
|
+
return () => ro.disconnect();
|
|
5586
|
+
}, []);
|
|
5587
|
+
const nameIdx = Math.max(0, columns.findIndex((c) => !c.rank));
|
|
5588
|
+
const leftOf = (part) => lefts[String(part)] ?? 0;
|
|
5589
|
+
const headRef = (part) => (el) => {
|
|
5590
|
+
if (el) heads.current.set(String(part), el);
|
|
5591
|
+
else heads.current.delete(String(part));
|
|
5592
|
+
};
|
|
5593
|
+
const isPinned = (part) => pinned && (typeof part !== "number" || part <= nameIdx);
|
|
5594
|
+
const pinCls = (part, where, rowBg) => isPinned(part) ? cn(
|
|
5595
|
+
"sticky z-1",
|
|
5596
|
+
where === "head" ? "bg-subtle" : rowBg ?? "bg-surface group-hover/row:bg-subtle",
|
|
5597
|
+
part === nameIdx && "max-w-60 border-r border-r-border-default"
|
|
5598
|
+
) : "";
|
|
5599
|
+
const pinStyle = (part) => isPinned(part) ? { left: leftOf(part) } : void 0;
|
|
5600
|
+
const edge = (part) => pinned && scrolled && part === nameIdx ? /* @__PURE__ */ jsx55("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;
|
|
5601
|
+
const span = columns.length + (anyExpandable ? 1 : 0) + (selectable ? 1 : 0);
|
|
5538
5602
|
const renderCell = (c, row) => {
|
|
5539
5603
|
const v = c.cell(row);
|
|
5540
5604
|
return v === null || v === void 0 || v === "" ? /* @__PURE__ */ jsx55(NoValue, { reason: c.missing }) : v;
|
|
5541
5605
|
};
|
|
5542
5606
|
const inside = variant === "chart";
|
|
5607
|
+
const bar = selectable && count > 0 ? /* @__PURE__ */ jsxs49("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 text-dense", children: [
|
|
5608
|
+
/* @__PURE__ */ jsxs49("span", { role: "status", className: "font-medium text-text-primary", children: [
|
|
5609
|
+
formatCountFull(count),
|
|
5610
|
+
" selected"
|
|
5611
|
+
] }),
|
|
5612
|
+
allVisible && totalCount !== void 0 && count < totalCount && onSelectAll && /* @__PURE__ */ jsxs49(Button, { variant: "link", size: "sm", onClick: onSelectAll, children: [
|
|
5613
|
+
"Select all ",
|
|
5614
|
+
formatCountFull(totalCount)
|
|
5615
|
+
] }),
|
|
5616
|
+
selectionActions,
|
|
5617
|
+
/* @__PURE__ */ jsx55(Button, { variant: "link", size: "sm", onClick: () => onSelectedChange?.([]), children: "Clear" })
|
|
5618
|
+
] }) : null;
|
|
5543
5619
|
const frame = /* @__PURE__ */ jsxs49(
|
|
5544
5620
|
"div",
|
|
5545
5621
|
{
|
|
5546
|
-
className: cn("relative flex w-full flex-col overflow-hidden rounded-card border border-border-default bg-surface", !
|
|
5622
|
+
className: cn("relative flex w-full flex-col overflow-hidden rounded-card border border-border-default bg-surface", (inside || !title && count === 0) && className),
|
|
5547
5623
|
"data-testid": testIdPrefix,
|
|
5548
5624
|
children: [
|
|
5549
5625
|
title && inside && /* @__PURE__ */ jsxs49("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
|
|
@@ -5551,108 +5627,160 @@ function DataTable({
|
|
|
5551
5627
|
/* @__PURE__ */ jsx55("h3", { id: titleId, className: "text-panel-title font-semibold text-text-primary", children: title }),
|
|
5552
5628
|
subtitle && /* @__PURE__ */ jsx55("p", { className: "mt-0.5 text-xs leading-snug text-text-tertiary", children: subtitle })
|
|
5553
5629
|
] }),
|
|
5554
|
-
action && /* @__PURE__ */ jsx55("div", { className: "shrink-0 text-text-tertiary", children: action })
|
|
5630
|
+
(bar ?? action) && /* @__PURE__ */ jsx55("div", { className: "shrink-0 text-text-tertiary", children: bar ?? action })
|
|
5555
5631
|
] }),
|
|
5556
|
-
/* @__PURE__ */ jsx55(
|
|
5557
|
-
"
|
|
5632
|
+
/* @__PURE__ */ jsx55(
|
|
5633
|
+
"div",
|
|
5558
5634
|
{
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
"
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
className: cn("
|
|
5572
|
-
|
|
5573
|
-
SortButton,
|
|
5635
|
+
ref: scroller,
|
|
5636
|
+
onScroll: (e) => setScrolled(e.currentTarget.scrollLeft > 0),
|
|
5637
|
+
className: cn("overflow-x-auto", maxHeight && cn("overflow-y-auto", MAX_H[maxHeight])),
|
|
5638
|
+
children: /* @__PURE__ */ jsxs49(
|
|
5639
|
+
"table",
|
|
5640
|
+
{
|
|
5641
|
+
"aria-labelledby": title ? titleId : void 0,
|
|
5642
|
+
"aria-label": title ? void 0 : rest["aria-label"],
|
|
5643
|
+
"aria-busy": loading || refreshing || void 0,
|
|
5644
|
+
className: "w-full border-separate border-spacing-0 text-left",
|
|
5645
|
+
children: [
|
|
5646
|
+
/* @__PURE__ */ jsx55("thead", { className: cn(maxHeight && "sticky top-0 z-10"), children: /* @__PURE__ */ jsxs49("tr", { className: "bg-subtle text-micro font-semibold uppercase tracking-wider text-text-secondary", children: [
|
|
5647
|
+
selectable && /* @__PURE__ */ jsx55("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__ */ jsx55(
|
|
5648
|
+
CheckBox,
|
|
5574
5649
|
{
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
onSort,
|
|
5580
|
-
description: c.info,
|
|
5581
|
-
testIdPrefix
|
|
5650
|
+
checked: allVisible,
|
|
5651
|
+
indeterminate: someVisible && !allVisible,
|
|
5652
|
+
onChange: toggleAllVisible,
|
|
5653
|
+
ariaLabel: allVisible ? "Deselect all rows on this page" : "Select all rows on this page"
|
|
5582
5654
|
}
|
|
5583
|
-
)
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5655
|
+
) }),
|
|
5656
|
+
anyExpandable && /* @__PURE__ */ jsx55("th", { ref: headRef("expand"), scope: "col", className: cn("w-10 border-b border-border-default", head, pinCls("expand", "head")), style: pinStyle("expand"), children: /* @__PURE__ */ jsx55("span", { className: "sr-only", children: "Details" }) }),
|
|
5657
|
+
columns.map((c, ci) => /* @__PURE__ */ jsxs49(
|
|
5658
|
+
"th",
|
|
5659
|
+
{
|
|
5660
|
+
ref: ci <= nameIdx ? headRef(ci) : void 0,
|
|
5661
|
+
scope: "col",
|
|
5662
|
+
"aria-sort": c.sortable ? ariaSortFor(shown, c.key) : void 0,
|
|
5663
|
+
className: cn("group/head whitespace-nowrap border-b border-border-default font-semibold", head, align(c), width(c), pinCls(ci, "head")),
|
|
5664
|
+
style: pinStyle(ci),
|
|
5665
|
+
children: [
|
|
5666
|
+
c.sortable && onSortChange ? /* @__PURE__ */ jsx55(
|
|
5667
|
+
SortButton,
|
|
5668
|
+
{
|
|
5669
|
+
label: c.label,
|
|
5670
|
+
sortKey: c.key,
|
|
5671
|
+
align: right(c) ? "right" : "left",
|
|
5672
|
+
sort: sortProp(shown),
|
|
5673
|
+
onSort,
|
|
5674
|
+
description: c.info,
|
|
5675
|
+
testIdPrefix
|
|
5676
|
+
}
|
|
5677
|
+
) : c.info ? /* @__PURE__ */ jsx55(SortButton, { label: c.label, sortKey: c.key, sortable: false, sort: sortProp(shown), onSort: () => {
|
|
5678
|
+
}, description: c.info, align: right(c) ? "right" : "left" }) : c.label,
|
|
5679
|
+
edge(ci)
|
|
5680
|
+
]
|
|
5681
|
+
},
|
|
5682
|
+
c.key
|
|
5683
|
+
))
|
|
5684
|
+
] }) }),
|
|
5685
|
+
/* @__PURE__ */ jsx55("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__ */ jsxs49("tr", { "aria-hidden": "true", className: "[&:last-child>td]:border-b-0", children: [
|
|
5686
|
+
selectable && /* @__PURE__ */ jsx55("td", { className: cn("border-b border-border-default", pad2) }),
|
|
5687
|
+
anyExpandable && /* @__PURE__ */ jsx55("td", { className: cn("border-b border-border-default", pad2) }),
|
|
5688
|
+
columns.map((c) => /* @__PURE__ */ jsx55("td", { className: cn("border-b border-border-default", pad2, align(c)), children: showSkeleton ? /* @__PURE__ */ jsx55(Skeleton, { className: cn("inline-block", right(c) ? "w-12" : "w-2/3") }) : /* @__PURE__ */ jsx55("span", { className: "inline-block h-3" }) }, c.key))
|
|
5689
|
+
] }, i)) : rows.length === 0 ? /* @__PURE__ */ jsx55("tr", { children: /* @__PURE__ */ jsx55("td", { colSpan: span, className: "px-6 py-12", children: empty ?? /* @__PURE__ */ jsx55(NoResultsEmptyState, {}) }) }) : rows.map((row, ri) => {
|
|
5690
|
+
const key = rowKey(row);
|
|
5691
|
+
const canOpen = expandable(row);
|
|
5692
|
+
const isOpen = canOpen && open.has(key);
|
|
5693
|
+
const panelId = `${titleId}-row-${ri}`;
|
|
5694
|
+
return /* @__PURE__ */ jsxs49(Fragment7, { children: [
|
|
5695
|
+
/* @__PURE__ */ jsxs49(
|
|
5696
|
+
"tr",
|
|
5697
|
+
{
|
|
5698
|
+
onClick: canOpen ? (e) => onRowClick(e, key) : void 0,
|
|
5699
|
+
className: cn("group/row hover:bg-subtle [&:last-child>td]:border-b-0", canOpen && "cursor-pointer", isOpen && "bg-subtle"),
|
|
5700
|
+
children: [
|
|
5701
|
+
selectable && /* @__PURE__ */ jsx55(
|
|
5702
|
+
"td",
|
|
5615
5703
|
{
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
className: cn("
|
|
5704
|
+
onPointerDownCapture: (e) => shiftHeld.current = e.shiftKey,
|
|
5705
|
+
onKeyDownCapture: (e) => shiftHeld.current = e.shiftKey,
|
|
5706
|
+
className: cn("border-b border-border-default pr-0", pad2, isOpen && "border-b-0", pinCls("select", "body", isOpen ? "bg-subtle" : void 0)),
|
|
5707
|
+
style: pinStyle("select"),
|
|
5708
|
+
children: /* @__PURE__ */ jsx55(
|
|
5709
|
+
CheckBox,
|
|
5710
|
+
{
|
|
5711
|
+
checked: picked.has(key),
|
|
5712
|
+
onChange: () => togglePick(ri),
|
|
5713
|
+
ariaLabel: `Select ${rowLabel ? rowLabel(row) : "row"}`
|
|
5714
|
+
}
|
|
5715
|
+
)
|
|
5619
5716
|
}
|
|
5620
|
-
)
|
|
5621
|
-
}
|
|
5622
|
-
) }),
|
|
5623
|
-
columns.map((c) => /* @__PURE__ */ jsx55(
|
|
5624
|
-
"td",
|
|
5625
|
-
{
|
|
5626
|
-
className: cn(
|
|
5627
|
-
"border-b border-border-default",
|
|
5628
|
-
pad2,
|
|
5629
|
-
align(c),
|
|
5630
|
-
right(c) && "tabular-nums",
|
|
5631
|
-
c.rank && "text-text-tertiary",
|
|
5632
|
-
isOpen && "border-b-0"
|
|
5633
5717
|
),
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5718
|
+
anyExpandable && /* @__PURE__ */ jsx55(
|
|
5719
|
+
"td",
|
|
5720
|
+
{
|
|
5721
|
+
className: cn("border-b border-border-default pr-0", pad2, isOpen && "border-b-0", pinCls("expand", "body", isOpen ? "bg-subtle" : void 0)),
|
|
5722
|
+
style: pinStyle("expand"),
|
|
5723
|
+
children: canOpen && /* @__PURE__ */ jsx55(
|
|
5724
|
+
"button",
|
|
5725
|
+
{
|
|
5726
|
+
type: "button",
|
|
5727
|
+
"aria-expanded": isOpen,
|
|
5728
|
+
"aria-controls": isOpen ? panelId : void 0,
|
|
5729
|
+
"aria-label": `${isOpen ? "Hide" : "Show"} details${rowLabel ? ` for ${rowLabel(row)}` : ""}`,
|
|
5730
|
+
onClick: () => toggle(key),
|
|
5731
|
+
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",
|
|
5732
|
+
children: /* @__PURE__ */ jsx55(
|
|
5733
|
+
ChevronRight6,
|
|
5734
|
+
{
|
|
5735
|
+
size: 16,
|
|
5736
|
+
"aria-hidden": "true",
|
|
5737
|
+
className: cn("transition-transform motion-reduce:transition-none", isOpen && "rotate-90")
|
|
5738
|
+
}
|
|
5739
|
+
)
|
|
5740
|
+
}
|
|
5741
|
+
)
|
|
5742
|
+
}
|
|
5743
|
+
),
|
|
5744
|
+
columns.map((c, ci) => /* @__PURE__ */ jsxs49(
|
|
5745
|
+
"td",
|
|
5746
|
+
{
|
|
5747
|
+
className: cn(
|
|
5748
|
+
"border-b border-border-default",
|
|
5749
|
+
pad2,
|
|
5750
|
+
align(c),
|
|
5751
|
+
right(c) && "tabular-nums",
|
|
5752
|
+
c.rank && "text-text-tertiary",
|
|
5753
|
+
isOpen && "border-b-0",
|
|
5754
|
+
pinCls(ci, "body", isOpen ? "bg-subtle" : void 0)
|
|
5755
|
+
),
|
|
5756
|
+
style: pinStyle(ci),
|
|
5757
|
+
children: [
|
|
5758
|
+
pinned && ci === nameIdx ? /* @__PURE__ */ jsx55(Tooltip, { label: renderCell(c, row), whenTruncated: true, delay: 300, className: "block truncate", children: renderCell(c, row) }) : renderCell(c, row),
|
|
5759
|
+
edge(ci)
|
|
5760
|
+
]
|
|
5761
|
+
},
|
|
5762
|
+
c.key
|
|
5763
|
+
))
|
|
5764
|
+
]
|
|
5765
|
+
}
|
|
5766
|
+
),
|
|
5767
|
+
isOpen && /* @__PURE__ */ jsx55("tr", { className: "[&:last-child>td]:border-b-0", children: /* @__PURE__ */ jsx55("td", { id: panelId, colSpan: span, className: "border-b border-border-default bg-subtle px-4 pb-4 pl-14", children: renderExpanded(row) }) })
|
|
5768
|
+
] }, key);
|
|
5769
|
+
}) })
|
|
5770
|
+
]
|
|
5771
|
+
}
|
|
5772
|
+
)
|
|
5645
5773
|
}
|
|
5646
|
-
)
|
|
5774
|
+
),
|
|
5647
5775
|
refreshing && !loading && /* @__PURE__ */ jsx55(RefreshLine, {}),
|
|
5648
5776
|
/* @__PURE__ */ jsx55(LongWait, { loading, onRetry, className: "mb-3 px-4" }),
|
|
5649
5777
|
footer && /* @__PURE__ */ jsx55("div", { className: "border-t border-border-default px-4 py-3", children: footer })
|
|
5650
5778
|
]
|
|
5651
5779
|
}
|
|
5652
5780
|
);
|
|
5653
|
-
if (!title
|
|
5654
|
-
return /* @__PURE__ */ jsxs49("section", { "aria-labelledby": titleId, className: cn("flex w-full flex-col gap-3", className), children: [
|
|
5655
|
-
/* @__PURE__ */ jsx55(SectionHeading, { id: titleId, as: titleAs, title, description: subtitle, actions: action }),
|
|
5781
|
+
if (inside || !title && count === 0) return frame;
|
|
5782
|
+
return /* @__PURE__ */ jsxs49("section", { "aria-labelledby": title ? titleId : void 0, className: cn("flex w-full flex-col gap-3", className), children: [
|
|
5783
|
+
title ? /* @__PURE__ */ jsx55(SectionHeading, { id: titleId, as: titleAs, title, description: subtitle, actions: bar ?? action }) : /* @__PURE__ */ jsx55("div", { className: "flex justify-end", children: bar }),
|
|
5656
5784
|
frame
|
|
5657
5785
|
] });
|
|
5658
5786
|
}
|
|
@@ -5736,13 +5864,13 @@ var ToggleChip = forwardRef11(function ToggleChip2({ selected, onChange, childre
|
|
|
5736
5864
|
ToggleChip.displayName = "ToggleChip";
|
|
5737
5865
|
|
|
5738
5866
|
// src/CopyButton.tsx
|
|
5739
|
-
import { forwardRef as forwardRef12, useEffect as useEffect18, useRef as
|
|
5867
|
+
import { forwardRef as forwardRef12, useEffect as useEffect18, useRef as useRef20, useState as useState19 } from "react";
|
|
5740
5868
|
import { Check as Check10, Copy } from "lucide-react";
|
|
5741
5869
|
import { jsx as jsx59, jsxs as jsxs51 } from "react/jsx-runtime";
|
|
5742
5870
|
var CONFIRM_MS = 2e3;
|
|
5743
5871
|
var CopyButton = forwardRef12(function CopyButton2({ value, label, "aria-label": ariaLabel, size = "xs", className, testIdPrefix }, ref) {
|
|
5744
5872
|
const [copied, setCopied] = useState19(false);
|
|
5745
|
-
const timer =
|
|
5873
|
+
const timer = useRef20(void 0);
|
|
5746
5874
|
useEffect18(() => () => clearTimeout(timer.current), []);
|
|
5747
5875
|
const copy = async () => {
|
|
5748
5876
|
try {
|
|
@@ -5826,7 +5954,7 @@ function InlineMessage({ tone = "info", title, children, actions, onDismiss, cla
|
|
|
5826
5954
|
}
|
|
5827
5955
|
|
|
5828
5956
|
// src/FilterDrawer.tsx
|
|
5829
|
-
import { useEffect as useEffect19, useLayoutEffect as useLayoutEffect6, useRef as
|
|
5957
|
+
import { useEffect as useEffect19, useLayoutEffect as useLayoutEffect6, useRef as useRef21, useState as useState20 } from "react";
|
|
5830
5958
|
import { ChevronLeft as ChevronLeft5, ChevronRight as ChevronRight7 } from "lucide-react";
|
|
5831
5959
|
import { jsx as jsx61, jsxs as jsxs53 } from "react/jsx-runtime";
|
|
5832
5960
|
var SLIDE_MS = 200;
|
|
@@ -5838,7 +5966,7 @@ function FilterDrawer({
|
|
|
5838
5966
|
onClose,
|
|
5839
5967
|
sections,
|
|
5840
5968
|
renderSection,
|
|
5841
|
-
activeCount
|
|
5969
|
+
activeCount: _activeCount,
|
|
5842
5970
|
onClearSection,
|
|
5843
5971
|
onClearAll,
|
|
5844
5972
|
onApply,
|
|
@@ -5874,9 +6002,9 @@ function FilterDrawer({
|
|
|
5874
6002
|
const t = setTimeout(() => setLeaving(null), SLIDE_MS);
|
|
5875
6003
|
return () => clearTimeout(t);
|
|
5876
6004
|
}, [leaving, phase]);
|
|
5877
|
-
const backRef =
|
|
5878
|
-
const rowRefs =
|
|
5879
|
-
const lastView =
|
|
6005
|
+
const backRef = useRef21(null);
|
|
6006
|
+
const rowRefs = useRef21(/* @__PURE__ */ new Map());
|
|
6007
|
+
const lastView = useRef21(null);
|
|
5880
6008
|
useEffect19(() => {
|
|
5881
6009
|
if (!open) return;
|
|
5882
6010
|
if (view) backRef.current?.focus();
|
|
@@ -5908,11 +6036,11 @@ function FilterDrawer({
|
|
|
5908
6036
|
{
|
|
5909
6037
|
size: 17,
|
|
5910
6038
|
"aria-hidden": "true",
|
|
5911
|
-
className: x
|
|
6039
|
+
className: inUse(x) ? "text-brand-primaryAction" : "text-text-secondary"
|
|
5912
6040
|
}
|
|
5913
6041
|
),
|
|
5914
6042
|
/* @__PURE__ */ jsx61("span", { className: "flex-1 text-sm font-medium text-text-primary", children: x.label }),
|
|
5915
|
-
|
|
6043
|
+
/* @__PURE__ */ jsx61(SectionMark, { section: x }),
|
|
5916
6044
|
/* @__PURE__ */ jsx61(ChevronRight7, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-secondary" })
|
|
5917
6045
|
]
|
|
5918
6046
|
}
|
|
@@ -5939,11 +6067,9 @@ function FilterDrawer({
|
|
|
5939
6067
|
}
|
|
5940
6068
|
),
|
|
5941
6069
|
focused.label,
|
|
6070
|
+
(focused.count ?? 0) > 0 && /* @__PURE__ */ jsx61(CountBadge, { count: focused.count }),
|
|
5942
6071
|
focused.info && /* @__PURE__ */ jsx61(InfoTip, { text: focused.info, label: `About ${focused.label}` })
|
|
5943
|
-
] }) :
|
|
5944
|
-
"Filters",
|
|
5945
|
-
activeCount > 0 && /* @__PURE__ */ jsx61(Badge, { tone: "brandSolid", kind: "count", children: activeCount })
|
|
5946
|
-
] }),
|
|
6072
|
+
] }) : "Filters",
|
|
5947
6073
|
footer: focused ? (
|
|
5948
6074
|
// Picks are kept as they're made; only See results, on the list, applies them.
|
|
5949
6075
|
/* @__PURE__ */ jsx61("div", { className: "flex w-full items-center", children: /* @__PURE__ */ jsx61(Button, { variant: "link", size: "md", onClick: () => onClearSection(focused.id), className: "px-0", children: "Clear" }) })
|
|
@@ -5989,6 +6115,17 @@ function FilterDrawer({
|
|
|
5989
6115
|
}
|
|
5990
6116
|
);
|
|
5991
6117
|
}
|
|
6118
|
+
var inUse = (x) => (x.count ?? 0) > 0 || !!x.badge;
|
|
6119
|
+
function CountBadge({ count }) {
|
|
6120
|
+
return /* @__PURE__ */ jsxs53(Badge, { tone: "brandSolid", kind: "count", children: [
|
|
6121
|
+
count,
|
|
6122
|
+
/* @__PURE__ */ jsx61("span", { className: "sr-only", children: " selected" })
|
|
6123
|
+
] });
|
|
6124
|
+
}
|
|
6125
|
+
function SectionMark({ section }) {
|
|
6126
|
+
if ((section.count ?? 0) > 0) return /* @__PURE__ */ jsx61(CountBadge, { count: section.count });
|
|
6127
|
+
return section.badge ? /* @__PURE__ */ jsx61(Badge, { tone: "brand", children: section.badge }) : null;
|
|
6128
|
+
}
|
|
5992
6129
|
|
|
5993
6130
|
// src/AllFiltersButton.tsx
|
|
5994
6131
|
import { forwardRef as forwardRef13 } from "react";
|