@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/approved-components.json +1 -1
- package/dist/index.cjs +1067 -512
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +332 -30
- package/dist/index.d.ts +332 -30
- package/dist/index.js +1063 -509
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3951,6 +3951,8 @@ function FilterDropdownFooter({
|
|
|
3951
3951
|
onApply,
|
|
3952
3952
|
clearLabel = "Clear all",
|
|
3953
3953
|
applyLabel = "Apply",
|
|
3954
|
+
onCancel,
|
|
3955
|
+
cancelLabel = "Cancel",
|
|
3954
3956
|
className,
|
|
3955
3957
|
testIdPrefix
|
|
3956
3958
|
}) {
|
|
@@ -3965,7 +3967,10 @@ function FilterDropdownFooter({
|
|
|
3965
3967
|
"data-testid": testIdPrefix,
|
|
3966
3968
|
children: [
|
|
3967
3969
|
onClear && /* @__PURE__ */ jsx35(Button, { type: "button", variant: "ghost", size: "sm", onClick: onClear, children: clearLabel }),
|
|
3968
|
-
/* @__PURE__ */
|
|
3970
|
+
/* @__PURE__ */ jsxs33("div", { className: "flex items-center gap-2", children: [
|
|
3971
|
+
onCancel && /* @__PURE__ */ jsx35(Button, { type: "button", variant: "secondary", size: "sm", onClick: onCancel, children: cancelLabel }),
|
|
3972
|
+
/* @__PURE__ */ jsx35(Button, { type: "button", variant: "primary", size: "sm", onClick: onApply, children: applyLabel })
|
|
3973
|
+
] })
|
|
3969
3974
|
]
|
|
3970
3975
|
}
|
|
3971
3976
|
);
|
|
@@ -4178,6 +4183,15 @@ var SortButton = forwardRef7(
|
|
|
4178
4183
|
return description ? /* @__PURE__ */ jsx38(HeaderTip, { description, children: plain }) : plain;
|
|
4179
4184
|
}
|
|
4180
4185
|
const active = !disabled && sort.key === sortKey;
|
|
4186
|
+
const iconFirst = align === "right";
|
|
4187
|
+
const icon = disabled ? null : active ? sort.dir === "asc" ? /* @__PURE__ */ jsx38(ArrowUp, { size: 12, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }) : /* @__PURE__ */ jsx38(ArrowDown, { size: 12, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }) : /* @__PURE__ */ jsx38(
|
|
4188
|
+
ArrowUpDown,
|
|
4189
|
+
{
|
|
4190
|
+
size: 12,
|
|
4191
|
+
"aria-hidden": "true",
|
|
4192
|
+
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"
|
|
4193
|
+
}
|
|
4194
|
+
);
|
|
4181
4195
|
const button = /* @__PURE__ */ jsxs36(
|
|
4182
4196
|
"button",
|
|
4183
4197
|
{
|
|
@@ -4208,15 +4222,9 @@ var SortButton = forwardRef7(
|
|
|
4208
4222
|
className
|
|
4209
4223
|
),
|
|
4210
4224
|
children: [
|
|
4225
|
+
iconFirst && icon,
|
|
4211
4226
|
text,
|
|
4212
|
-
!
|
|
4213
|
-
ArrowUpDown,
|
|
4214
|
-
{
|
|
4215
|
-
size: 12,
|
|
4216
|
-
"aria-hidden": "true",
|
|
4217
|
-
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"
|
|
4218
|
-
}
|
|
4219
|
-
))
|
|
4227
|
+
!iconFirst && icon
|
|
4220
4228
|
]
|
|
4221
4229
|
}
|
|
4222
4230
|
);
|
|
@@ -4614,6 +4622,7 @@ function DateRangePicker({
|
|
|
4614
4622
|
years,
|
|
4615
4623
|
formatDate: formatDate2,
|
|
4616
4624
|
formatRange,
|
|
4625
|
+
caption,
|
|
4617
4626
|
className,
|
|
4618
4627
|
testIdPrefix
|
|
4619
4628
|
}) {
|
|
@@ -4623,6 +4632,7 @@ function DateRangePicker({
|
|
|
4623
4632
|
const [value, setValue] = useState14(defaultValue);
|
|
4624
4633
|
const [draft, setDraft] = useState14(defaultValue);
|
|
4625
4634
|
const ref = useRef15(null);
|
|
4635
|
+
const triggerRef = useRef15(null);
|
|
4626
4636
|
const [fromMo, setFromMo] = useState14(end.getMonth());
|
|
4627
4637
|
const [fromYr, setFromYr] = useState14(end.getFullYear() - 1);
|
|
4628
4638
|
const [toMo, setToMo] = useState14(end.getMonth());
|
|
@@ -4667,13 +4677,14 @@ function DateRangePicker({
|
|
|
4667
4677
|
/* @__PURE__ */ jsxs40(
|
|
4668
4678
|
"button",
|
|
4669
4679
|
{
|
|
4680
|
+
ref: triggerRef,
|
|
4670
4681
|
type: "button",
|
|
4671
4682
|
onClick: toggleOpen,
|
|
4672
4683
|
"aria-expanded": open,
|
|
4673
4684
|
"aria-haspopup": "listbox",
|
|
4674
4685
|
className: chipTriggerClass(),
|
|
4675
4686
|
children: [
|
|
4676
|
-
/* @__PURE__ */ jsxs40("span", { className: "flex flex-col gap-1 text-left leading-none", children: [
|
|
4687
|
+
caption ? /* @__PURE__ */ jsx44(ChipContent, { caption, value }) : /* @__PURE__ */ jsxs40("span", { className: "flex flex-col gap-1 text-left leading-none", children: [
|
|
4677
4688
|
/* @__PURE__ */ jsx44("span", { className: "text-control-caption leading-none text-text-tertiary", children: spanLabel2(value, end, formatDate2, formatRange) }),
|
|
4678
4689
|
/* @__PURE__ */ jsx44("span", { className: "text-xs leading-none font-medium text-text-primary", children: value })
|
|
4679
4690
|
] }),
|
|
@@ -4681,6 +4692,7 @@ function DateRangePicker({
|
|
|
4681
4692
|
]
|
|
4682
4693
|
}
|
|
4683
4694
|
),
|
|
4695
|
+
caption && !open && /* @__PURE__ */ jsx44(Tooltip, { anchorRef: triggerRef, label: spanLabel2(value, end, formatDate2, formatRange), delay: 300, placement: "top" }),
|
|
4684
4696
|
open && /* @__PURE__ */ jsxs40("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: [
|
|
4685
4697
|
presets.map((p) => /* @__PURE__ */ jsx44(
|
|
4686
4698
|
"button",
|
|
@@ -4759,12 +4771,18 @@ function MultiSelectFilter({
|
|
|
4759
4771
|
valueLabel,
|
|
4760
4772
|
hints,
|
|
4761
4773
|
note,
|
|
4774
|
+
hideCaption = false,
|
|
4775
|
+
size = "md",
|
|
4776
|
+
inlineCaption = false,
|
|
4777
|
+
max,
|
|
4778
|
+
maxReason,
|
|
4762
4779
|
className,
|
|
4763
4780
|
testIdPrefix
|
|
4764
4781
|
}) {
|
|
4765
4782
|
const groupLeaves = (g) => g.children.length ? g.children : [{ id: g.id, label: g.label }];
|
|
4766
4783
|
const leafOptions = groups ? groups.flatMap(groupLeaves) : options;
|
|
4767
4784
|
const showSearch = searchable ?? leafOptions.length > SEARCH_AFTER;
|
|
4785
|
+
const sm = size === "sm";
|
|
4768
4786
|
const [open, setOpen] = useState15(false);
|
|
4769
4787
|
const [q, setQ] = useState15("");
|
|
4770
4788
|
const [draft, setDraft] = useState15(selected);
|
|
@@ -4805,9 +4823,12 @@ function MultiSelectFilter({
|
|
|
4805
4823
|
window.removeEventListener("mousedown", onClick);
|
|
4806
4824
|
};
|
|
4807
4825
|
}, [open, close]);
|
|
4826
|
+
const capReason = maxReason ?? `Up to ${max}. Untick one to add another.`;
|
|
4827
|
+
const overCap = (n) => max !== void 0 && n > max;
|
|
4808
4828
|
const toggle = (id) => setDraft((cur) => {
|
|
4809
4829
|
const next = cur.includes(id) ? cur.filter((x) => x !== id) : [...cur, id];
|
|
4810
4830
|
if (next.length < min) return cur;
|
|
4831
|
+
if (!cur.includes(id) && overCap(next.length)) return cur;
|
|
4811
4832
|
return next;
|
|
4812
4833
|
});
|
|
4813
4834
|
const toggleGroup = (g) => setDraft((cur) => {
|
|
@@ -4816,8 +4837,40 @@ function MultiSelectFilter({
|
|
|
4816
4837
|
const allSel = ids.every((id) => cur.includes(id));
|
|
4817
4838
|
const next = allSel ? cur.filter((id) => !ids.includes(id)) : [.../* @__PURE__ */ new Set([...cur, ...ids])];
|
|
4818
4839
|
if (next.length < min) return cur;
|
|
4840
|
+
if (!allSel && overCap(next.length)) return cur;
|
|
4819
4841
|
return next;
|
|
4820
4842
|
});
|
|
4843
|
+
const blockedLeaf = (id) => !draft.includes(id) && overCap(draft.length + 1) ? capReason : null;
|
|
4844
|
+
const blockedGroup = (g) => {
|
|
4845
|
+
if (max === void 0) return null;
|
|
4846
|
+
const ids = groupLeaves(g).map((c) => c.id).filter((id) => !counts || (counts[id] ?? 0) > 0 || draft.includes(id));
|
|
4847
|
+
if (!ids.length || ids.every((id) => draft.includes(id))) return null;
|
|
4848
|
+
return overCap((/* @__PURE__ */ new Set([...draft, ...ids])).size) ? capReason : null;
|
|
4849
|
+
};
|
|
4850
|
+
const row = (opts) => {
|
|
4851
|
+
const button = /* @__PURE__ */ jsxs41(
|
|
4852
|
+
"button",
|
|
4853
|
+
{
|
|
4854
|
+
type: "button",
|
|
4855
|
+
role: "checkbox",
|
|
4856
|
+
"aria-checked": opts.indeterminate ? "mixed" : opts.checked,
|
|
4857
|
+
"aria-disabled": opts.blocked ? "true" : void 0,
|
|
4858
|
+
onClick: opts.blocked ? void 0 : opts.onClick,
|
|
4859
|
+
className: cn(
|
|
4860
|
+
"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",
|
|
4861
|
+
opts.indent ? "pl-9 pr-2" : "px-2",
|
|
4862
|
+
opts.blocked ? "cursor-not-allowed" : "hover:bg-subtle"
|
|
4863
|
+
),
|
|
4864
|
+
children: [
|
|
4865
|
+
/* @__PURE__ */ jsx45(CheckBoxBox, { checked: opts.checked, indeterminate: opts.indeterminate, disabled: !!opts.blocked }),
|
|
4866
|
+
/* @__PURE__ */ jsx45("span", { className: cn("flex-1 text-sm", opts.blocked ? "text-text-tertiary" : "text-text-primary", opts.bold && "font-semibold"), children: opts.label }),
|
|
4867
|
+
opts.count
|
|
4868
|
+
]
|
|
4869
|
+
},
|
|
4870
|
+
opts.key
|
|
4871
|
+
);
|
|
4872
|
+
return opts.blocked ? /* @__PURE__ */ jsx45(Tooltip, { label: opts.blocked, delay: 300, className: "flex w-full", children: button }, opts.key) : button;
|
|
4873
|
+
};
|
|
4821
4874
|
const isAvailable = (id) => !counts || (counts[id] ?? 0) > 0 || draft.includes(id);
|
|
4822
4875
|
const countFor = (id) => counts?.[id] ?? 0;
|
|
4823
4876
|
const groupState = (g) => {
|
|
@@ -4849,10 +4902,27 @@ function MultiSelectFilter({
|
|
|
4849
4902
|
type: "button",
|
|
4850
4903
|
onClick: () => open ? close() : openTray(),
|
|
4851
4904
|
"aria-expanded": open,
|
|
4905
|
+
"aria-label": sm && !inlineCaption || !sm && hideCaption ? caption : void 0,
|
|
4852
4906
|
"data-testid": testIdPrefix && `${testIdPrefix}-trigger`,
|
|
4853
|
-
className: cn(
|
|
4907
|
+
className: cn(
|
|
4908
|
+
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),
|
|
4909
|
+
fullWidth && "w-full justify-between"
|
|
4910
|
+
),
|
|
4854
4911
|
children: [
|
|
4855
|
-
/* @__PURE__ */
|
|
4912
|
+
sm ? /* @__PURE__ */ jsxs41("span", { className: "flex items-center gap-1.5", children: [
|
|
4913
|
+
icon && /* @__PURE__ */ jsx45("span", { className: "shrink-0 text-text-tertiary", children: icon }),
|
|
4914
|
+
inlineCaption ? /* @__PURE__ */ jsxs41("span", { children: [
|
|
4915
|
+
/* @__PURE__ */ jsxs41("span", { className: "font-normal text-text-secondary", children: [
|
|
4916
|
+
caption,
|
|
4917
|
+
":"
|
|
4918
|
+
] }),
|
|
4919
|
+
" ",
|
|
4920
|
+
value
|
|
4921
|
+
] }) : value
|
|
4922
|
+
] }) : hideCaption ? /* @__PURE__ */ jsxs41("span", { className: "flex items-center gap-2", children: [
|
|
4923
|
+
icon && /* @__PURE__ */ jsx45("span", { className: "shrink-0 text-text-tertiary", children: icon }),
|
|
4924
|
+
value
|
|
4925
|
+
] }) : /* @__PURE__ */ jsx45(ChipContent, { caption, value, icon }),
|
|
4856
4926
|
/* @__PURE__ */ jsx45(
|
|
4857
4927
|
ChevronDown10,
|
|
4858
4928
|
{
|
|
@@ -4894,54 +4964,38 @@ function MultiSelectFilter({
|
|
|
4894
4964
|
groups ? visibleGroups.map((g) => {
|
|
4895
4965
|
const state = groupState(g);
|
|
4896
4966
|
return /* @__PURE__ */ jsxs41("div", { children: [
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
children: [
|
|
4919
|
-
/* @__PURE__ */ jsx45(CheckBoxBox, { checked }),
|
|
4920
|
-
/* @__PURE__ */ jsx45("span", { className: "flex-1 text-sm text-text-primary", children: labelled(c.id, c.label) }),
|
|
4921
|
-
counts && /* @__PURE__ */ jsx45(OptionCount, { n: countFor(c.id) })
|
|
4922
|
-
]
|
|
4923
|
-
},
|
|
4924
|
-
c.id
|
|
4925
|
-
);
|
|
4926
|
-
})
|
|
4967
|
+
row({
|
|
4968
|
+
key: g.id,
|
|
4969
|
+
onClick: () => toggleGroup(g),
|
|
4970
|
+
checked: state === "all",
|
|
4971
|
+
indeterminate: state === "some",
|
|
4972
|
+
label: labelled(g.id, g.label),
|
|
4973
|
+
count: counts && /* @__PURE__ */ jsx45(OptionCount, { n: countFor(g.id) }),
|
|
4974
|
+
bold: !plainParent,
|
|
4975
|
+
blocked: blockedGroup(g)
|
|
4976
|
+
}),
|
|
4977
|
+
g.children.map(
|
|
4978
|
+
(c) => row({
|
|
4979
|
+
key: c.id,
|
|
4980
|
+
onClick: () => toggle(c.id),
|
|
4981
|
+
checked: draft.includes(c.id),
|
|
4982
|
+
label: labelled(c.id, c.label),
|
|
4983
|
+
count: counts && /* @__PURE__ */ jsx45(OptionCount, { n: countFor(c.id) }),
|
|
4984
|
+
indent: true,
|
|
4985
|
+
blocked: blockedLeaf(c.id)
|
|
4986
|
+
})
|
|
4987
|
+
)
|
|
4927
4988
|
] }, g.id);
|
|
4928
|
-
}) : items.map(
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
/* @__PURE__ */ jsx45("span", { className: "flex-1 text-sm text-text-primary", children: labelled(o.id, o.label) }),
|
|
4939
|
-
counts && /* @__PURE__ */ jsx45(OptionCount, { n: countFor(o.id) })
|
|
4940
|
-
]
|
|
4941
|
-
},
|
|
4942
|
-
o.id
|
|
4943
|
-
);
|
|
4944
|
-
}),
|
|
4989
|
+
}) : items.map(
|
|
4990
|
+
(o) => row({
|
|
4991
|
+
key: o.id,
|
|
4992
|
+
onClick: () => toggle(o.id),
|
|
4993
|
+
checked: draft.includes(o.id),
|
|
4994
|
+
label: labelled(o.id, o.label),
|
|
4995
|
+
count: counts && /* @__PURE__ */ jsx45(OptionCount, { n: countFor(o.id) }),
|
|
4996
|
+
blocked: blockedLeaf(o.id)
|
|
4997
|
+
})
|
|
4998
|
+
),
|
|
4945
4999
|
(groups && !visibleGroups.length || !groups && !items.length) && /* @__PURE__ */ jsx45("div", { className: "py-6 text-center text-dense text-text-tertiary", children: "No matches." })
|
|
4946
5000
|
] }),
|
|
4947
5001
|
note && /* @__PURE__ */ jsx45("p", { className: "border-t border-border-default px-3 py-2 text-xs text-text-tertiary", children: note }),
|
|
@@ -5415,8 +5469,8 @@ function Drawer({ open, onClose, title, description, size = "sm", footer, childr
|
|
|
5415
5469
|
}
|
|
5416
5470
|
|
|
5417
5471
|
// src/DataTable.tsx
|
|
5418
|
-
import { Fragment as
|
|
5419
|
-
import { ChevronRight as
|
|
5472
|
+
import { Fragment as Fragment8, useEffect as useEffect19, useId as useId11, useLayoutEffect as useLayoutEffect7, useRef as useRef21, useState as useState20 } from "react";
|
|
5473
|
+
import { ChevronRight as ChevronRight7 } from "lucide-react";
|
|
5420
5474
|
|
|
5421
5475
|
// src/numbers.ts
|
|
5422
5476
|
var US = { units: ["K", "M", "B", "T"] };
|
|
@@ -5474,12 +5528,425 @@ function formatPercent(value, _opts = {}) {
|
|
|
5474
5528
|
return text === "0.0" ? "0.0%" : `${sign(value)}${text}%`;
|
|
5475
5529
|
}
|
|
5476
5530
|
|
|
5531
|
+
// src/StickyBar.tsx
|
|
5532
|
+
import { useEffect as useEffect17, useRef as useRef19, useState as useState18 } from "react";
|
|
5533
|
+
import { jsx as jsx55 } from "react/jsx-runtime";
|
|
5534
|
+
function scrollParent(el) {
|
|
5535
|
+
if (typeof window === "undefined") return null;
|
|
5536
|
+
for (let p = el?.parentElement ?? null; p && p !== document.body && p !== document.documentElement; p = p.parentElement) {
|
|
5537
|
+
const y = window.getComputedStyle(p).overflowY;
|
|
5538
|
+
if (y === "auto" || y === "scroll" || y === "overlay") return p;
|
|
5539
|
+
}
|
|
5540
|
+
return null;
|
|
5541
|
+
}
|
|
5542
|
+
function viewportOf(root) {
|
|
5543
|
+
if (!root) return { top: 0, bottom: window.innerHeight };
|
|
5544
|
+
const r = root.getBoundingClientRect();
|
|
5545
|
+
return { top: r.top + root.clientTop, bottom: r.top + root.clientTop + root.clientHeight };
|
|
5546
|
+
}
|
|
5547
|
+
function scrollPadding(root) {
|
|
5548
|
+
if (!root) return { top: 0, bottom: 0 };
|
|
5549
|
+
const cs = window.getComputedStyle(root);
|
|
5550
|
+
return { top: parseFloat(cs.paddingTop) || 0, bottom: parseFloat(cs.paddingBottom) || 0 };
|
|
5551
|
+
}
|
|
5552
|
+
var STICKY_BAR_ATTR = "data-sticky-bar";
|
|
5553
|
+
function StickyBar({ children, className, testIdPrefix }) {
|
|
5554
|
+
const ref = useRef19(null);
|
|
5555
|
+
const [stuck, setStuck] = useState18(false);
|
|
5556
|
+
const [pad2, setPad] = useState18(0);
|
|
5557
|
+
const [edges, setEdges] = useState18({ left: 0, right: 0 });
|
|
5558
|
+
useEffect17(() => {
|
|
5559
|
+
const el = ref.current;
|
|
5560
|
+
const parent = el?.parentElement;
|
|
5561
|
+
if (!el || !parent) return void 0;
|
|
5562
|
+
let root = scrollParent(el);
|
|
5563
|
+
const update = () => setStuck(el.getBoundingClientRect().top <= viewportOf(root).top + 0.5 && (root ? root.scrollTop : window.scrollY) > 0);
|
|
5564
|
+
const resize = () => {
|
|
5565
|
+
root = scrollParent(el);
|
|
5566
|
+
setPad(scrollPadding(root).top);
|
|
5567
|
+
const pr = parent.getBoundingClientRect();
|
|
5568
|
+
const ps = window.getComputedStyle(parent);
|
|
5569
|
+
const colLeft = pr.left + parent.clientLeft + (parseFloat(ps.paddingLeft) || 0);
|
|
5570
|
+
const colRight = pr.left + parent.clientLeft + parent.clientWidth - (parseFloat(ps.paddingRight) || 0);
|
|
5571
|
+
const rr = root?.getBoundingClientRect();
|
|
5572
|
+
const boxLeft = root && rr ? rr.left + root.clientLeft : 0;
|
|
5573
|
+
const boxRight = root && rr ? rr.left + root.clientLeft + root.clientWidth : document.documentElement.clientWidth;
|
|
5574
|
+
const next = { left: Math.max(0, colLeft - boxLeft), right: Math.max(0, boxRight - colRight) };
|
|
5575
|
+
setEdges((prev) => prev.left === next.left && prev.right === next.right ? prev : next);
|
|
5576
|
+
update();
|
|
5577
|
+
};
|
|
5578
|
+
resize();
|
|
5579
|
+
document.addEventListener("scroll", update, { capture: true, passive: true });
|
|
5580
|
+
window.addEventListener("resize", resize);
|
|
5581
|
+
const ro = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(resize);
|
|
5582
|
+
ro?.observe(parent);
|
|
5583
|
+
return () => {
|
|
5584
|
+
document.removeEventListener("scroll", update, { capture: true });
|
|
5585
|
+
window.removeEventListener("resize", resize);
|
|
5586
|
+
ro?.disconnect();
|
|
5587
|
+
};
|
|
5588
|
+
}, []);
|
|
5589
|
+
return /* @__PURE__ */ jsx55(
|
|
5590
|
+
"div",
|
|
5591
|
+
{
|
|
5592
|
+
ref,
|
|
5593
|
+
...{ [STICKY_BAR_ATTR]: "" },
|
|
5594
|
+
"data-stuck": stuck ? "" : void 0,
|
|
5595
|
+
"data-testid": testIdPrefix,
|
|
5596
|
+
className: cn("sticky top-0 z-10 border-b bg-canvas", stuck ? "border-border-default" : "border-transparent", className),
|
|
5597
|
+
style: {
|
|
5598
|
+
// At the very top of what scrolls, past the scroll box's own padding.
|
|
5599
|
+
top: pad2 ? -pad2 : void 0,
|
|
5600
|
+
// Stuck: a full-width band, edge to edge of the scroll box; the
|
|
5601
|
+
// filter bar inside stays where it was.
|
|
5602
|
+
...stuck && (edges.left || edges.right) ? { marginLeft: -edges.left, marginRight: -edges.right, paddingLeft: edges.left, paddingRight: edges.right } : null
|
|
5603
|
+
},
|
|
5604
|
+
children
|
|
5605
|
+
}
|
|
5606
|
+
);
|
|
5607
|
+
}
|
|
5608
|
+
|
|
5609
|
+
// src/DataTableHeaderMenu.tsx
|
|
5610
|
+
import { useCallback as useCallback5, useEffect as useEffect18, useId as useId10, useLayoutEffect as useLayoutEffect6, useRef as useRef20, useState as useState19 } from "react";
|
|
5611
|
+
import { createPortal as createPortal9 } from "react-dom";
|
|
5612
|
+
import { Check as Check10, ChevronDown as ChevronDown11 } from "lucide-react";
|
|
5613
|
+
|
|
5614
|
+
// src/Menu.tsx
|
|
5615
|
+
import { forwardRef as forwardRef10 } from "react";
|
|
5616
|
+
import { Slot as Slot2, Slottable } from "@radix-ui/react-slot";
|
|
5617
|
+
import { Check as Check9, ChevronRight as ChevronRight6 } from "lucide-react";
|
|
5618
|
+
import { jsx as jsx56, jsxs as jsxs49 } from "react/jsx-runtime";
|
|
5619
|
+
var ROW_SELECTOR = '[role^="menuitem"]:not([aria-disabled="true"]):not(:disabled)';
|
|
5620
|
+
function moveFocus(e) {
|
|
5621
|
+
const keys = ["ArrowDown", "ArrowUp", "Home", "End"];
|
|
5622
|
+
if (!keys.includes(e.key)) return;
|
|
5623
|
+
const rows = Array.from(e.currentTarget.querySelectorAll(ROW_SELECTOR));
|
|
5624
|
+
if (!rows.length) return;
|
|
5625
|
+
e.preventDefault();
|
|
5626
|
+
const i = rows.indexOf(document.activeElement);
|
|
5627
|
+
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;
|
|
5628
|
+
rows[next].focus();
|
|
5629
|
+
}
|
|
5630
|
+
var Menu = forwardRef10(
|
|
5631
|
+
({ className, testIdPrefix, onKeyDown, children, ...props }, ref) => /* @__PURE__ */ jsx56(
|
|
5632
|
+
"div",
|
|
5633
|
+
{
|
|
5634
|
+
ref,
|
|
5635
|
+
role: "menu",
|
|
5636
|
+
"data-testid": testIdPrefix,
|
|
5637
|
+
onKeyDown: (e) => {
|
|
5638
|
+
moveFocus(e);
|
|
5639
|
+
onKeyDown?.(e);
|
|
5640
|
+
},
|
|
5641
|
+
className: cn("flex flex-col p-1", className),
|
|
5642
|
+
...props,
|
|
5643
|
+
children
|
|
5644
|
+
}
|
|
5645
|
+
)
|
|
5646
|
+
);
|
|
5647
|
+
Menu.displayName = "Menu";
|
|
5648
|
+
var MenuItem = forwardRef10(
|
|
5649
|
+
({ className, testIdPrefix, icon, trailing, description, submenu, checked, danger, disabled, asChild = false, children, ...props }, ref) => {
|
|
5650
|
+
const Comp = asChild ? Slot2 : "button";
|
|
5651
|
+
const radio = checked !== void 0;
|
|
5652
|
+
return /* @__PURE__ */ jsxs49(
|
|
5653
|
+
Comp,
|
|
5654
|
+
{
|
|
5655
|
+
ref,
|
|
5656
|
+
type: asChild ? void 0 : "button",
|
|
5657
|
+
role: radio ? "menuitemradio" : "menuitem",
|
|
5658
|
+
"aria-checked": radio ? checked : void 0,
|
|
5659
|
+
"aria-haspopup": submenu ? "menu" : void 0,
|
|
5660
|
+
"aria-disabled": disabled || void 0,
|
|
5661
|
+
disabled: asChild ? void 0 : disabled,
|
|
5662
|
+
tabIndex: -1,
|
|
5663
|
+
"data-testid": testIdPrefix,
|
|
5664
|
+
className: cn(
|
|
5665
|
+
"flex min-h-9 w-full items-center gap-2.5 rounded-control px-3 py-1.5 text-left text-sm transition-colors",
|
|
5666
|
+
"focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
|
|
5667
|
+
danger ? "text-text-danger" : "text-text-primary",
|
|
5668
|
+
disabled ? "cursor-not-allowed opacity-40" : "hover:bg-subtle focus-visible:bg-subtle",
|
|
5669
|
+
className
|
|
5670
|
+
),
|
|
5671
|
+
...props,
|
|
5672
|
+
children: [
|
|
5673
|
+
icon && /* @__PURE__ */ jsx56("span", { "aria-hidden": "true", className: cn("flex shrink-0", danger ? "text-text-danger" : "text-text-secondary"), children: icon }),
|
|
5674
|
+
asChild ? (
|
|
5675
|
+
// The link's own text lands here; the link becomes the row.
|
|
5676
|
+
/* @__PURE__ */ jsx56(Slottable, { children })
|
|
5677
|
+
) : /* @__PURE__ */ jsxs49("span", { className: "min-w-0 flex-1", children: [
|
|
5678
|
+
/* @__PURE__ */ jsx56("span", { className: "block truncate", children }),
|
|
5679
|
+
description && /* @__PURE__ */ jsx56("span", { className: "block truncate text-xs text-text-tertiary", children: description })
|
|
5680
|
+
] }),
|
|
5681
|
+
trailing && /* @__PURE__ */ jsx56("span", { className: "ml-auto flex shrink-0 items-center text-xs text-text-secondary", children: trailing }),
|
|
5682
|
+
radio && checked && /* @__PURE__ */ jsx56(Check9, { size: 16, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }),
|
|
5683
|
+
submenu && /* @__PURE__ */ jsx56(ChevronRight6, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-secondary" })
|
|
5684
|
+
]
|
|
5685
|
+
}
|
|
5686
|
+
);
|
|
5687
|
+
}
|
|
5688
|
+
);
|
|
5689
|
+
MenuItem.displayName = "MenuItem";
|
|
5690
|
+
function MenuLabel({ className, testIdPrefix, id, children }) {
|
|
5691
|
+
return /* @__PURE__ */ jsx56(
|
|
5692
|
+
"div",
|
|
5693
|
+
{
|
|
5694
|
+
id,
|
|
5695
|
+
role: "presentation",
|
|
5696
|
+
"data-testid": testIdPrefix,
|
|
5697
|
+
className: cn("px-3 pb-1 pt-2 text-micro font-semibold uppercase tracking-wide text-text-tertiary", className),
|
|
5698
|
+
children
|
|
5699
|
+
}
|
|
5700
|
+
);
|
|
5701
|
+
}
|
|
5702
|
+
function MenuSeparator({ className, testIdPrefix }) {
|
|
5703
|
+
return /* @__PURE__ */ jsx56("div", { role: "separator", "data-testid": testIdPrefix, className: cn("-mx-1 my-1 border-t border-border-default", className) });
|
|
5704
|
+
}
|
|
5705
|
+
|
|
5706
|
+
// src/DataTableHeaderMenu.tsx
|
|
5707
|
+
import { Fragment as Fragment7, jsx as jsx57, jsxs as jsxs50 } from "react/jsx-runtime";
|
|
5708
|
+
function RadioSection({
|
|
5709
|
+
label,
|
|
5710
|
+
rows,
|
|
5711
|
+
value,
|
|
5712
|
+
onPick,
|
|
5713
|
+
first,
|
|
5714
|
+
testId
|
|
5715
|
+
}) {
|
|
5716
|
+
const id = useId10();
|
|
5717
|
+
const enabled = rows.filter((r) => !r.disabled);
|
|
5718
|
+
const tabStop = enabled.some((r) => r.id === value) ? value : enabled[0]?.id;
|
|
5719
|
+
const onKey = (e) => {
|
|
5720
|
+
const keys = ["ArrowDown", "ArrowUp", "ArrowRight", "ArrowLeft", "Home", "End"];
|
|
5721
|
+
if (!keys.includes(e.key) || enabled.length === 0) return;
|
|
5722
|
+
e.preventDefault();
|
|
5723
|
+
const i = Math.max(0, enabled.findIndex((r) => r.id === value));
|
|
5724
|
+
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;
|
|
5725
|
+
onPick(enabled[next].id);
|
|
5726
|
+
const el = e.currentTarget.querySelectorAll('[role="radio"]:not([aria-disabled="true"])')[next];
|
|
5727
|
+
el?.focus();
|
|
5728
|
+
};
|
|
5729
|
+
return /* @__PURE__ */ jsxs50(Fragment7, { children: [
|
|
5730
|
+
/* @__PURE__ */ jsx57(MenuLabel, { id, children: label }),
|
|
5731
|
+
/* @__PURE__ */ jsx57("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) => {
|
|
5732
|
+
const checked = r.id === value;
|
|
5733
|
+
return /* @__PURE__ */ jsxs50(
|
|
5734
|
+
"button",
|
|
5735
|
+
{
|
|
5736
|
+
type: "button",
|
|
5737
|
+
role: "radio",
|
|
5738
|
+
"aria-checked": checked,
|
|
5739
|
+
"aria-disabled": r.disabled || void 0,
|
|
5740
|
+
tabIndex: r.id === tabStop ? 0 : -1,
|
|
5741
|
+
onClick: () => !r.disabled && onPick(r.id),
|
|
5742
|
+
className: cn(
|
|
5743
|
+
// MenuItem's row: 36px, 14px, inset and rounded, the tick on the right.
|
|
5744
|
+
"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",
|
|
5745
|
+
"focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
|
|
5746
|
+
r.disabled ? "cursor-not-allowed opacity-40" : "hover:bg-subtle focus-visible:bg-subtle"
|
|
5747
|
+
),
|
|
5748
|
+
children: [
|
|
5749
|
+
/* @__PURE__ */ jsx57("span", { className: "min-w-0 flex-1 truncate", children: r.label }),
|
|
5750
|
+
checked && /* @__PURE__ */ jsx57(Check10, { size: 16, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" })
|
|
5751
|
+
]
|
|
5752
|
+
},
|
|
5753
|
+
r.id ?? "__none"
|
|
5754
|
+
);
|
|
5755
|
+
}) })
|
|
5756
|
+
] });
|
|
5757
|
+
}
|
|
5758
|
+
function HeaderMenuTrigger({
|
|
5759
|
+
menu,
|
|
5760
|
+
columnLabel,
|
|
5761
|
+
sortDir,
|
|
5762
|
+
onSort,
|
|
5763
|
+
testId
|
|
5764
|
+
}) {
|
|
5765
|
+
const [open, setOpen] = useState19(false);
|
|
5766
|
+
const [pos, setPos] = useState19(null);
|
|
5767
|
+
const trigger = useRef20(null);
|
|
5768
|
+
const panel = useRef20(null);
|
|
5769
|
+
const { groupBy, breakOutBy } = menu;
|
|
5770
|
+
const groupLabel = groupBy.options.find((o) => o.id === groupBy.value)?.label ?? "";
|
|
5771
|
+
const breakLabel = breakOutBy?.value != null ? breakOutBy.options.find((o) => o.id === breakOutBy.value)?.label : void 0;
|
|
5772
|
+
const [draftGroup, setDraftGroup] = useState19(groupBy.value);
|
|
5773
|
+
const [draftBreak, setDraftBreak] = useState19(breakOutBy?.value ?? null);
|
|
5774
|
+
const [draftSort, setDraftSort] = useState19(sortDir);
|
|
5775
|
+
const openPanel = () => {
|
|
5776
|
+
setDraftGroup(groupBy.value);
|
|
5777
|
+
setDraftBreak(breakOutBy?.value ?? null);
|
|
5778
|
+
setDraftSort(sortDir);
|
|
5779
|
+
setOpen(true);
|
|
5780
|
+
};
|
|
5781
|
+
const close = useCallback5((refocus) => {
|
|
5782
|
+
setOpen(false);
|
|
5783
|
+
if (refocus) trigger.current?.focus();
|
|
5784
|
+
}, []);
|
|
5785
|
+
const apply = () => {
|
|
5786
|
+
if (draftGroup !== groupBy.value) groupBy.onChange(draftGroup);
|
|
5787
|
+
if (breakOutBy && draftBreak !== breakOutBy.value) breakOutBy.onChange(draftBreak);
|
|
5788
|
+
if (onSort && draftSort && draftSort !== sortDir) onSort(draftSort);
|
|
5789
|
+
close(true);
|
|
5790
|
+
};
|
|
5791
|
+
const place = useCallback5(() => {
|
|
5792
|
+
const t = trigger.current;
|
|
5793
|
+
if (!t) return;
|
|
5794
|
+
const r = t.getBoundingClientRect();
|
|
5795
|
+
const h = panel.current?.offsetHeight ?? 0;
|
|
5796
|
+
const above = r.bottom + 4 + h > window.innerHeight && r.top - 4 - h > 0;
|
|
5797
|
+
setPos({ top: above ? r.top - 4 - h : r.bottom + 4, left: r.left });
|
|
5798
|
+
}, []);
|
|
5799
|
+
useLayoutEffect6(() => {
|
|
5800
|
+
if (open) place();
|
|
5801
|
+
else setPos(null);
|
|
5802
|
+
}, [open, place]);
|
|
5803
|
+
const placed = pos !== null;
|
|
5804
|
+
useEffect18(() => {
|
|
5805
|
+
if (open && placed) panel.current?.querySelector('[data-first-group] [tabindex="0"]')?.focus();
|
|
5806
|
+
}, [open, placed]);
|
|
5807
|
+
useEffect18(() => {
|
|
5808
|
+
if (!open) return void 0;
|
|
5809
|
+
const onDown = (e) => {
|
|
5810
|
+
const t = e.target;
|
|
5811
|
+
if (trigger.current?.contains(t) || panel.current?.contains(t)) return;
|
|
5812
|
+
close(false);
|
|
5813
|
+
};
|
|
5814
|
+
window.addEventListener("mousedown", onDown);
|
|
5815
|
+
window.addEventListener("resize", place);
|
|
5816
|
+
window.addEventListener("scroll", place, true);
|
|
5817
|
+
return () => {
|
|
5818
|
+
window.removeEventListener("mousedown", onDown);
|
|
5819
|
+
window.removeEventListener("resize", place);
|
|
5820
|
+
window.removeEventListener("scroll", place, true);
|
|
5821
|
+
};
|
|
5822
|
+
}, [open, close, place]);
|
|
5823
|
+
const onTriggerKey = (e) => {
|
|
5824
|
+
if (e.key === "ArrowDown" && !open) {
|
|
5825
|
+
e.preventDefault();
|
|
5826
|
+
openPanel();
|
|
5827
|
+
}
|
|
5828
|
+
};
|
|
5829
|
+
const onPanelKey = (e) => {
|
|
5830
|
+
if (e.key === "Escape") {
|
|
5831
|
+
e.preventDefault();
|
|
5832
|
+
e.stopPropagation();
|
|
5833
|
+
close(true);
|
|
5834
|
+
return;
|
|
5835
|
+
}
|
|
5836
|
+
if (e.key === "Tab") {
|
|
5837
|
+
const stops = [...e.currentTarget.querySelectorAll('[tabindex="0"], button:not([tabindex])')];
|
|
5838
|
+
const at = stops.indexOf(document.activeElement);
|
|
5839
|
+
if (e.shiftKey && at === 0 || !e.shiftKey && at === stops.length - 1) {
|
|
5840
|
+
e.preventDefault();
|
|
5841
|
+
close(true);
|
|
5842
|
+
}
|
|
5843
|
+
}
|
|
5844
|
+
};
|
|
5845
|
+
const pickGroup = (id) => {
|
|
5846
|
+
setDraftGroup(id);
|
|
5847
|
+
if (draftBreak === id) setDraftBreak(null);
|
|
5848
|
+
};
|
|
5849
|
+
return /* @__PURE__ */ jsxs50(Fragment7, { children: [
|
|
5850
|
+
/* @__PURE__ */ jsxs50(
|
|
5851
|
+
"button",
|
|
5852
|
+
{
|
|
5853
|
+
ref: trigger,
|
|
5854
|
+
type: "button",
|
|
5855
|
+
"aria-haspopup": "dialog",
|
|
5856
|
+
"aria-expanded": open,
|
|
5857
|
+
"data-testid": testId,
|
|
5858
|
+
onClick: () => open ? close(false) : openPanel(),
|
|
5859
|
+
onKeyDown: onTriggerKey,
|
|
5860
|
+
className: cn(
|
|
5861
|
+
// Restores the header row's uppercase: a <button> doesn't inherit
|
|
5862
|
+
// text-transform (see SortButton). The negative margin keeps the
|
|
5863
|
+
// label lined up with the names under it while the hover fill
|
|
5864
|
+
// reaches past it.
|
|
5865
|
+
"-mx-1.5 -my-1 inline-flex items-center gap-1 rounded-control px-1.5 py-1 uppercase transition-colors",
|
|
5866
|
+
"hover:bg-border-default hover:text-text-primary aria-expanded:bg-border-default aria-expanded:text-text-primary",
|
|
5867
|
+
"focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-border-focus"
|
|
5868
|
+
),
|
|
5869
|
+
children: [
|
|
5870
|
+
/* @__PURE__ */ jsxs50("span", { children: [
|
|
5871
|
+
groupLabel,
|
|
5872
|
+
breakLabel && /* @__PURE__ */ jsxs50(Fragment7, { children: [
|
|
5873
|
+
/* @__PURE__ */ jsx57("span", { "aria-hidden": "true", className: "text-text-tertiary", children: " \u203A " }),
|
|
5874
|
+
/* @__PURE__ */ jsx57("span", { className: "sr-only", children: " then " }),
|
|
5875
|
+
breakLabel
|
|
5876
|
+
] })
|
|
5877
|
+
] }),
|
|
5878
|
+
/* @__PURE__ */ jsx57(ChevronDown11, { size: 12, "aria-hidden": "true", className: cn("shrink-0 transition-transform motion-reduce:transition-none", open && "rotate-180") })
|
|
5879
|
+
]
|
|
5880
|
+
}
|
|
5881
|
+
),
|
|
5882
|
+
open && createPortal9(
|
|
5883
|
+
/* @__PURE__ */ jsxs50(
|
|
5884
|
+
"div",
|
|
5885
|
+
{
|
|
5886
|
+
ref: panel,
|
|
5887
|
+
role: "dialog",
|
|
5888
|
+
"aria-label": columnLabel,
|
|
5889
|
+
"data-testid": testId && `${testId}-menu`,
|
|
5890
|
+
onKeyDown: onPanelKey,
|
|
5891
|
+
style: { position: "fixed", top: pos?.top ?? 0, left: pos?.left ?? 0, visibility: pos ? void 0 : "hidden" },
|
|
5892
|
+
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",
|
|
5893
|
+
children: [
|
|
5894
|
+
/* @__PURE__ */ jsxs50("div", { className: "flex min-h-0 flex-col overflow-y-auto p-1", children: [
|
|
5895
|
+
/* @__PURE__ */ jsx57(
|
|
5896
|
+
RadioSection,
|
|
5897
|
+
{
|
|
5898
|
+
first: true,
|
|
5899
|
+
label: groupBy.label ?? "Group rows by",
|
|
5900
|
+
rows: groupBy.options,
|
|
5901
|
+
value: draftGroup,
|
|
5902
|
+
onPick: pickGroup
|
|
5903
|
+
}
|
|
5904
|
+
),
|
|
5905
|
+
breakOutBy && /* @__PURE__ */ jsxs50(Fragment7, { children: [
|
|
5906
|
+
/* @__PURE__ */ jsx57(MenuSeparator, {}),
|
|
5907
|
+
/* @__PURE__ */ jsx57(
|
|
5908
|
+
RadioSection,
|
|
5909
|
+
{
|
|
5910
|
+
label: breakOutBy.label ?? "Then break out by",
|
|
5911
|
+
rows: [{ id: null, label: "None" }, ...breakOutBy.options.map((o) => ({ ...o, disabled: o.id === draftGroup }))],
|
|
5912
|
+
value: draftBreak,
|
|
5913
|
+
onPick: setDraftBreak
|
|
5914
|
+
}
|
|
5915
|
+
)
|
|
5916
|
+
] }),
|
|
5917
|
+
onSort && /* @__PURE__ */ jsxs50(Fragment7, { children: [
|
|
5918
|
+
/* @__PURE__ */ jsx57(MenuSeparator, {}),
|
|
5919
|
+
/* @__PURE__ */ jsx57(
|
|
5920
|
+
RadioSection,
|
|
5921
|
+
{
|
|
5922
|
+
label: "Sort",
|
|
5923
|
+
rows: [
|
|
5924
|
+
{ id: "asc", label: "A to Z" },
|
|
5925
|
+
{ id: "desc", label: "Z to A" }
|
|
5926
|
+
],
|
|
5927
|
+
value: draftSort ?? void 0,
|
|
5928
|
+
onPick: setDraftSort
|
|
5929
|
+
}
|
|
5930
|
+
)
|
|
5931
|
+
] })
|
|
5932
|
+
] }),
|
|
5933
|
+
/* @__PURE__ */ jsx57(FilterDropdownFooter, { onCancel: () => close(true), onApply: apply })
|
|
5934
|
+
]
|
|
5935
|
+
}
|
|
5936
|
+
),
|
|
5937
|
+
document.body
|
|
5938
|
+
)
|
|
5939
|
+
] });
|
|
5940
|
+
}
|
|
5941
|
+
|
|
5477
5942
|
// src/DataTable.tsx
|
|
5478
|
-
import { Fragment as
|
|
5943
|
+
import { Fragment as Fragment9, jsx as jsx58, jsxs as jsxs51 } from "react/jsx-runtime";
|
|
5479
5944
|
var WIDTH3 = { fill: "", sm: "w-24", md: "w-36", lg: "w-48" };
|
|
5480
5945
|
var MAX_H = { sm: "max-h-80", md: "max-h-120", lg: "max-h-160" };
|
|
5946
|
+
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)]";
|
|
5481
5947
|
var HEAD_PAD = { default: "px-4 py-3", compact: "px-3 py-2" };
|
|
5482
5948
|
var CELL_PAD = { default: "px-4 py-3.5", compact: "px-3 py-2" };
|
|
5949
|
+
var EXPAND_PAD = "px-2";
|
|
5483
5950
|
var SUB_INDENT = { default: "pl-10", compact: "pl-9" };
|
|
5484
5951
|
var TINT = "bg-brand-primaryTint";
|
|
5485
5952
|
var TINT_HOVER = "group-hover/row:bg-linear-to-r group-hover/row:from-brand-primaryAction/10 group-hover/row:to-brand-primaryAction/10";
|
|
@@ -5495,6 +5962,7 @@ function isDev() {
|
|
|
5495
5962
|
return false;
|
|
5496
5963
|
}
|
|
5497
5964
|
}
|
|
5965
|
+
var useBrowserLayoutEffect = typeof window === "undefined" ? useEffect19 : useLayoutEffect7;
|
|
5498
5966
|
function rowClickCounts(e) {
|
|
5499
5967
|
if (e.target.closest(OWN_CLICK)) return false;
|
|
5500
5968
|
const sel = window.getSelection?.();
|
|
@@ -5502,13 +5970,13 @@ function rowClickCounts(e) {
|
|
|
5502
5970
|
return true;
|
|
5503
5971
|
}
|
|
5504
5972
|
function NoValue({ reason = "No data" }) {
|
|
5505
|
-
return /* @__PURE__ */
|
|
5506
|
-
/* @__PURE__ */
|
|
5507
|
-
/* @__PURE__ */
|
|
5973
|
+
return /* @__PURE__ */ jsxs51(Tooltip, { label: reason, delay: 300, className: "text-text-tertiary", children: [
|
|
5974
|
+
/* @__PURE__ */ jsx58("span", { "aria-hidden": "true", children: NO_VALUE }),
|
|
5975
|
+
/* @__PURE__ */ jsx58("span", { className: "sr-only", children: reason })
|
|
5508
5976
|
] });
|
|
5509
5977
|
}
|
|
5510
5978
|
function TableLink({ className, ...props }) {
|
|
5511
|
-
return /* @__PURE__ */
|
|
5979
|
+
return /* @__PURE__ */ jsx58(
|
|
5512
5980
|
"a",
|
|
5513
5981
|
{
|
|
5514
5982
|
...props,
|
|
@@ -5556,26 +6024,29 @@ function DataTable({
|
|
|
5556
6024
|
refreshing = false,
|
|
5557
6025
|
onRetry,
|
|
5558
6026
|
empty,
|
|
5559
|
-
maxHeight,
|
|
6027
|
+
maxHeight: maxHeightProp,
|
|
5560
6028
|
footer,
|
|
6029
|
+
sticky = false,
|
|
6030
|
+
stickyTop,
|
|
5561
6031
|
className,
|
|
5562
6032
|
testIdPrefix,
|
|
5563
6033
|
...rest
|
|
5564
6034
|
}) {
|
|
5565
|
-
const
|
|
6035
|
+
const maxHeight = sticky ? void 0 : maxHeightProp;
|
|
6036
|
+
const titleId = useId11();
|
|
5566
6037
|
const showSkeleton = useDelayedLoading(loading);
|
|
5567
6038
|
const head = HEAD_PAD[density];
|
|
5568
6039
|
const pad2 = CELL_PAD[density];
|
|
5569
6040
|
const right = (c) => c.numeric || c.rank;
|
|
5570
6041
|
const align = (c) => right(c) ? "text-right" : "text-left";
|
|
5571
|
-
const width = (c) => c.rank ? "w-12" : WIDTH3[c.width ?? (c.numeric ? "md" : "fill")];
|
|
6042
|
+
const width = (c) => c.rank ? "w-12" : WIDTH3[c.width ?? (c.lead ? "sm" : c.numeric ? "md" : "fill")];
|
|
5572
6043
|
const shown = sort ?? defaultSort;
|
|
5573
6044
|
const onSort = (key) => {
|
|
5574
6045
|
const col = columns.find((c) => c.key === key);
|
|
5575
6046
|
onSortChange?.(cycleSort(shown, key, col?.firstDir ?? (right(col) ? "desc" : "asc"), defaultSort));
|
|
5576
6047
|
};
|
|
5577
6048
|
const clash = !!onRowClick && (!!renderExpandedProp || !!subRowsProp);
|
|
5578
|
-
|
|
6049
|
+
useEffect19(() => {
|
|
5579
6050
|
if (clash && isDev()) {
|
|
5580
6051
|
console.warn("DataTable: pass `onRowClick` or rows that open in place (`renderExpanded`, `subRows`), not both. The row click wins; rows won't open.");
|
|
5581
6052
|
}
|
|
@@ -5586,10 +6057,10 @@ function DataTable({
|
|
|
5586
6057
|
const kids = subRows?.(row);
|
|
5587
6058
|
return kids && kids.length > 0 ? kids : null;
|
|
5588
6059
|
};
|
|
5589
|
-
const [open, setOpen] =
|
|
6060
|
+
const [open, setOpen] = useState20(() => /* @__PURE__ */ new Set());
|
|
5590
6061
|
const visible = rows.map(rowKey);
|
|
5591
6062
|
const resetOn = subRows ? [...visible].sort().join("|") : `${shown?.key}|${shown?.dir}|${visible.join("|")}`;
|
|
5592
|
-
|
|
6063
|
+
useEffect19(() => setOpen(/* @__PURE__ */ new Set()), [resetOn]);
|
|
5593
6064
|
const expandable = (row) => (!!renderExpanded || !!childrenOf(row)) && (canExpand ? canExpand(row) : true);
|
|
5594
6065
|
const anyExpandable = (!!renderExpanded || !!subRows) && rows.some(expandable);
|
|
5595
6066
|
const toggle = (key) => setOpen((prev) => {
|
|
@@ -5610,8 +6081,8 @@ function DataTable({
|
|
|
5610
6081
|
pickable.forEach((k) => allVisible ? next.delete(k) : next.add(k));
|
|
5611
6082
|
setPicked(next);
|
|
5612
6083
|
};
|
|
5613
|
-
const lastPicked =
|
|
5614
|
-
const shiftHeld =
|
|
6084
|
+
const lastPicked = useRef21(null);
|
|
6085
|
+
const shiftHeld = useRef21(false);
|
|
5615
6086
|
const togglePick = (index) => {
|
|
5616
6087
|
const key = visible[index];
|
|
5617
6088
|
const on = !picked.has(key);
|
|
@@ -5628,12 +6099,12 @@ function DataTable({
|
|
|
5628
6099
|
};
|
|
5629
6100
|
const count = selectedCount ?? picked.size;
|
|
5630
6101
|
const barCount = selectable && selectionBar ? count : 0;
|
|
5631
|
-
const scroller =
|
|
5632
|
-
const [pinned, setPinned] =
|
|
5633
|
-
const [scrolled, setScrolled] =
|
|
5634
|
-
const heads =
|
|
5635
|
-
const [lefts, setLefts] =
|
|
5636
|
-
|
|
6102
|
+
const scroller = useRef21(null);
|
|
6103
|
+
const [pinned, setPinned] = useState20(false);
|
|
6104
|
+
const [scrolled, setScrolled] = useState20(false);
|
|
6105
|
+
const heads = useRef21(/* @__PURE__ */ new Map());
|
|
6106
|
+
const [lefts, setLefts] = useState20({});
|
|
6107
|
+
useEffect19(() => {
|
|
5637
6108
|
const el = scroller.current;
|
|
5638
6109
|
if (!el || typeof ResizeObserver === "undefined") return void 0;
|
|
5639
6110
|
const measure = () => {
|
|
@@ -5653,7 +6124,7 @@ function DataTable({
|
|
|
5653
6124
|
if (el.firstElementChild) ro.observe(el.firstElementChild);
|
|
5654
6125
|
return () => ro.disconnect();
|
|
5655
6126
|
}, []);
|
|
5656
|
-
const nameIdx = Math.max(0, columns.findIndex((c) => !c.rank));
|
|
6127
|
+
const nameIdx = Math.max(0, columns.findIndex((c) => !c.rank && !c.lead));
|
|
5657
6128
|
const leftOf = (part) => lefts[String(part)] ?? 0;
|
|
5658
6129
|
const headRef = (part) => (el) => {
|
|
5659
6130
|
if (el) heads.current.set(String(part), el);
|
|
@@ -5666,13 +6137,81 @@ function DataTable({
|
|
|
5666
6137
|
part === nameIdx && "max-w-60 border-r border-r-border-default"
|
|
5667
6138
|
) : "";
|
|
5668
6139
|
const pinStyle = (part) => isPinned(part) ? { left: leftOf(part) } : void 0;
|
|
5669
|
-
const edge = (part) => pinned && scrolled && part === nameIdx ? /* @__PURE__ */
|
|
6140
|
+
const edge = (part) => pinned && scrolled && part === nameIdx ? /* @__PURE__ */ jsx58("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;
|
|
5670
6141
|
const span = columns.length + (anyExpandable ? 1 : 0) + (selectable ? 1 : 0);
|
|
6142
|
+
const wrapRef = useRef21(null);
|
|
6143
|
+
const theadRef = useRef21(null);
|
|
6144
|
+
const cloneRef = useRef21(null);
|
|
6145
|
+
const [stuck, setStuck] = useState20(false);
|
|
6146
|
+
const [geom, setGeom] = useState20({ cols: [], width: 0, height: 0 });
|
|
6147
|
+
const [barH, setBarH] = useState20(0);
|
|
6148
|
+
const [scrollPad, setScrollPad] = useState20({ top: 0, bottom: 0 });
|
|
6149
|
+
const [footerStuck, setFooterStuck] = useState20(false);
|
|
6150
|
+
const [scrolledDown, setScrolledDown] = useState20(false);
|
|
6151
|
+
const [animate, setAnimate] = useState20(false);
|
|
6152
|
+
useEffect19(() => {
|
|
6153
|
+
const thead = theadRef.current;
|
|
6154
|
+
if (!sticky || !thead || typeof ResizeObserver === "undefined") return void 0;
|
|
6155
|
+
const measure = () => {
|
|
6156
|
+
const cells = [...thead.rows[0]?.cells ?? []];
|
|
6157
|
+
const next = { cols: cells.map((c) => c.getBoundingClientRect().width), width: thead.getBoundingClientRect().width, height: thead.getBoundingClientRect().height };
|
|
6158
|
+
setGeom((prev) => prev.width === next.width && prev.height === next.height && prev.cols.join() === next.cols.join() ? prev : next);
|
|
6159
|
+
};
|
|
6160
|
+
measure();
|
|
6161
|
+
const ro = new ResizeObserver(measure);
|
|
6162
|
+
ro.observe(thead);
|
|
6163
|
+
for (const c of thead.rows[0]?.cells ?? []) ro.observe(c);
|
|
6164
|
+
return () => ro.disconnect();
|
|
6165
|
+
}, [sticky, span]);
|
|
6166
|
+
useBrowserLayoutEffect(() => {
|
|
6167
|
+
const wrap = wrapRef.current;
|
|
6168
|
+
if (!sticky || !wrap) return void 0;
|
|
6169
|
+
let root = scrollParent(wrap);
|
|
6170
|
+
const bar2 = (root ?? document).querySelector(`[${STICKY_BAR_ATTR}]`) ?? document.querySelector(`[${STICKY_BAR_ATTR}]`);
|
|
6171
|
+
const update = () => {
|
|
6172
|
+
const thead = theadRef.current;
|
|
6173
|
+
const clone = cloneRef.current;
|
|
6174
|
+
if (thead && clone) setStuck(clone.getBoundingClientRect().top > thead.getBoundingClientRect().top + 0.5);
|
|
6175
|
+
setFooterStuck(wrap.getBoundingClientRect().bottom > viewportOf(root).bottom + 1);
|
|
6176
|
+
setScrolledDown((root ? root.scrollTop : window.scrollY) > 0);
|
|
6177
|
+
};
|
|
6178
|
+
const measure = () => {
|
|
6179
|
+
root = scrollParent(wrap);
|
|
6180
|
+
setBarH(bar2 ? bar2.getBoundingClientRect().height : 0);
|
|
6181
|
+
setScrollPad((prev) => {
|
|
6182
|
+
const next = scrollPadding(root);
|
|
6183
|
+
return prev.top === next.top && prev.bottom === next.bottom ? prev : next;
|
|
6184
|
+
});
|
|
6185
|
+
update();
|
|
6186
|
+
};
|
|
6187
|
+
measure();
|
|
6188
|
+
const raf = requestAnimationFrame(() => setAnimate(true));
|
|
6189
|
+
document.addEventListener("scroll", update, { capture: true, passive: true });
|
|
6190
|
+
window.addEventListener("resize", measure);
|
|
6191
|
+
const ro = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
|
|
6192
|
+
if (bar2) ro?.observe(bar2);
|
|
6193
|
+
ro?.observe(wrap);
|
|
6194
|
+
return () => {
|
|
6195
|
+
cancelAnimationFrame(raf);
|
|
6196
|
+
document.removeEventListener("scroll", update, { capture: true });
|
|
6197
|
+
window.removeEventListener("resize", measure);
|
|
6198
|
+
ro?.disconnect();
|
|
6199
|
+
};
|
|
6200
|
+
}, [sticky]);
|
|
6201
|
+
useEffect19(() => {
|
|
6202
|
+
const clone = cloneRef.current;
|
|
6203
|
+
if (!clone) return;
|
|
6204
|
+
clone.querySelectorAll("button, a[href], input, [tabindex]").forEach((el) => {
|
|
6205
|
+
if (el.tabIndex !== -1) el.tabIndex = -1;
|
|
6206
|
+
});
|
|
6207
|
+
if (scroller.current) clone.scrollLeft = scroller.current.scrollLeft;
|
|
6208
|
+
});
|
|
6209
|
+
const top = (stickyTop ?? barH) - scrollPad.top;
|
|
5671
6210
|
const renderCell = (c, row) => {
|
|
5672
6211
|
const v = c.cell(row);
|
|
5673
|
-
return v === null || v === void 0 || v === "" ? /* @__PURE__ */
|
|
6212
|
+
return v === null || v === void 0 || v === "" ? /* @__PURE__ */ jsx58(NoValue, { reason: c.missing }) : v;
|
|
5674
6213
|
};
|
|
5675
|
-
const fit = (ci, content) => pinned && ci === nameIdx ? /* @__PURE__ */
|
|
6214
|
+
const fit = (ci, content) => pinned && ci === nameIdx ? /* @__PURE__ */ jsx58(Tooltip, { label: content, whenTruncated: true, delay: 300, className: "block truncate", children: content }) : content;
|
|
5676
6215
|
const colBg = (c, rowBg) => c.highlight ? TINT : rowBg;
|
|
5677
6216
|
const firstPart = selectable ? "select" : anyExpandable ? "expand" : 0;
|
|
5678
6217
|
const ringCls = (part) => onRowClick ? cn(
|
|
@@ -5682,13 +6221,13 @@ function DataTable({
|
|
|
5682
6221
|
part === columns.length - 1 && RING_RIGHT,
|
|
5683
6222
|
pinned && scrolled && part === nameIdx && part !== columns.length - 1 && RING_PAST_EDGE
|
|
5684
6223
|
) : "";
|
|
5685
|
-
const plainRow = (kind, row, key, rowBg, extra) => /* @__PURE__ */
|
|
5686
|
-
selectable && /* @__PURE__ */
|
|
5687
|
-
anyExpandable && /* @__PURE__ */
|
|
6224
|
+
const plainRow = (kind, row, key, rowBg, extra) => /* @__PURE__ */ jsxs51("tr", { id: extra?.id, className: cn("[&:last-child>td]:border-b-0", kind === "total" && "font-semibold"), children: [
|
|
6225
|
+
selectable && /* @__PURE__ */ jsx58("td", { className: cn("border-b border-border-default pr-0", pad2, rowBg, pinCls("select", "body", rowBg)), style: pinStyle("select") }),
|
|
6226
|
+
anyExpandable && /* @__PURE__ */ jsx58("td", { className: cn("border-b border-border-default", pad2, EXPAND_PAD, rowBg, pinCls("expand", "body", rowBg)), style: pinStyle("expand") }),
|
|
5688
6227
|
columns.map((c, ci) => {
|
|
5689
6228
|
const bg = kind === "sub" ? colBg(c, rowBg) : rowBg;
|
|
5690
6229
|
const isName = ci === nameIdx;
|
|
5691
|
-
return /* @__PURE__ */
|
|
6230
|
+
return /* @__PURE__ */ jsxs51(
|
|
5692
6231
|
"td",
|
|
5693
6232
|
{
|
|
5694
6233
|
className: cn(
|
|
@@ -5703,8 +6242,8 @@ function DataTable({
|
|
|
5703
6242
|
),
|
|
5704
6243
|
style: pinStyle(ci),
|
|
5705
6244
|
children: [
|
|
5706
|
-
c.rank ? null : isName && kind === "total" ? fit(ci, totalsLabel) : kind === "total" ? /* @__PURE__ */
|
|
5707
|
-
kind === "sub" && isName && rowLabel && extra?.parent !== void 0 && /* @__PURE__ */
|
|
6245
|
+
c.rank || c.lead ? null : isName && kind === "total" ? fit(ci, totalsLabel) : kind === "total" ? /* @__PURE__ */ jsx58(DeltaBoldContext.Provider, { value: true, children: fit(ci, renderCell(c, row)) }) : fit(ci, renderCell(c, row)),
|
|
6246
|
+
kind === "sub" && isName && rowLabel && extra?.parent !== void 0 && /* @__PURE__ */ jsxs51("span", { className: "sr-only", children: [
|
|
5708
6247
|
", in ",
|
|
5709
6248
|
rowLabel(extra.parent)
|
|
5710
6249
|
] }),
|
|
@@ -5715,231 +6254,293 @@ function DataTable({
|
|
|
5715
6254
|
);
|
|
5716
6255
|
})
|
|
5717
6256
|
] }, key);
|
|
6257
|
+
const headRow = (clone) => /* @__PURE__ */ jsxs51("tr", { className: "bg-subtle text-micro font-semibold uppercase tracking-wider text-text-secondary", children: [
|
|
6258
|
+
selectable && /* @__PURE__ */ jsx58("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__ */ jsx58(
|
|
6259
|
+
CheckBox,
|
|
6260
|
+
{
|
|
6261
|
+
checked: allVisible,
|
|
6262
|
+
indeterminate: someVisible && !allVisible,
|
|
6263
|
+
onChange: toggleAllVisible,
|
|
6264
|
+
disabled: pickable.length === 0,
|
|
6265
|
+
ariaLabel: allVisible ? "Deselect all rows on this page" : "Select all rows on this page"
|
|
6266
|
+
}
|
|
6267
|
+
) : /* @__PURE__ */ jsx58("span", { className: "sr-only", children: "Select" }) }),
|
|
6268
|
+
anyExpandable && /* @__PURE__ */ jsx58("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__ */ jsx58("span", { className: "sr-only", children: "Details" }) }),
|
|
6269
|
+
columns.map((c, ci) => /* @__PURE__ */ jsxs51(
|
|
6270
|
+
"th",
|
|
6271
|
+
{
|
|
6272
|
+
ref: !clone && ci <= nameIdx ? headRef(ci) : void 0,
|
|
6273
|
+
scope: "col",
|
|
6274
|
+
"aria-sort": c.sortable || c.headerMenu && onSortChange ? ariaSortFor(shown, c.key) : void 0,
|
|
6275
|
+
className: cn(
|
|
6276
|
+
"group/head whitespace-nowrap border-b border-border-default font-semibold",
|
|
6277
|
+
head,
|
|
6278
|
+
align(c),
|
|
6279
|
+
width(c),
|
|
6280
|
+
c.highlight && TINT,
|
|
6281
|
+
pinCls(ci, "head", c.highlight ? TINT : void 0)
|
|
6282
|
+
),
|
|
6283
|
+
style: pinStyle(ci),
|
|
6284
|
+
children: [
|
|
6285
|
+
c.headerMenu ? /* @__PURE__ */ jsx58(
|
|
6286
|
+
HeaderMenuTrigger,
|
|
6287
|
+
{
|
|
6288
|
+
menu: c.headerMenu,
|
|
6289
|
+
columnLabel: c.label,
|
|
6290
|
+
sortDir: shown?.key === c.key ? shown.dir : null,
|
|
6291
|
+
onSort: onSortChange ? (dir) => onSortChange({ key: c.key, dir }) : void 0,
|
|
6292
|
+
testId: clone || !testIdPrefix ? void 0 : `${testIdPrefix}-header-menu-${c.key}`
|
|
6293
|
+
}
|
|
6294
|
+
) : c.sortable && onSortChange ? /* @__PURE__ */ jsx58(
|
|
6295
|
+
SortButton,
|
|
6296
|
+
{
|
|
6297
|
+
label: c.label,
|
|
6298
|
+
sortKey: c.key,
|
|
6299
|
+
align: right(c) ? "right" : "left",
|
|
6300
|
+
sort: sortProp(shown),
|
|
6301
|
+
onSort,
|
|
6302
|
+
description: c.info,
|
|
6303
|
+
testIdPrefix: clone ? void 0 : testIdPrefix
|
|
6304
|
+
}
|
|
6305
|
+
) : c.info ? /* @__PURE__ */ jsx58(SortButton, { label: c.label, sortKey: c.key, sortable: false, sort: sortProp(shown), onSort: () => {
|
|
6306
|
+
}, description: c.info, align: right(c) ? "right" : "left" }) : c.label,
|
|
6307
|
+
edge(ci)
|
|
6308
|
+
]
|
|
6309
|
+
},
|
|
6310
|
+
c.key
|
|
6311
|
+
))
|
|
6312
|
+
] });
|
|
5718
6313
|
const inside = variant === "chart";
|
|
5719
|
-
const bar = barCount > 0 ? /* @__PURE__ */
|
|
5720
|
-
/* @__PURE__ */
|
|
6314
|
+
const bar = barCount > 0 ? /* @__PURE__ */ jsxs51("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 text-dense", children: [
|
|
6315
|
+
/* @__PURE__ */ jsxs51("span", { role: "status", className: "font-medium text-text-primary", children: [
|
|
5721
6316
|
formatCountFull(count),
|
|
5722
6317
|
" selected"
|
|
5723
6318
|
] }),
|
|
5724
|
-
allVisible && totalCount !== void 0 && count < totalCount && onSelectAll && /* @__PURE__ */
|
|
6319
|
+
allVisible && totalCount !== void 0 && count < totalCount && onSelectAll && /* @__PURE__ */ jsxs51(Button, { variant: "link", size: "sm", onClick: onSelectAll, children: [
|
|
5725
6320
|
"Select all ",
|
|
5726
6321
|
formatCountFull(totalCount)
|
|
5727
6322
|
] }),
|
|
5728
6323
|
selectionActions,
|
|
5729
|
-
/* @__PURE__ */
|
|
6324
|
+
/* @__PURE__ */ jsx58(Button, { variant: "link", size: "sm", onClick: () => onSelectedChange?.([]), children: "Clear" })
|
|
5730
6325
|
] }) : null;
|
|
5731
|
-
const
|
|
6326
|
+
const scrollArea = /* @__PURE__ */ jsx58(
|
|
5732
6327
|
"div",
|
|
5733
6328
|
{
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
"
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
className: cn("
|
|
5750
|
-
|
|
5751
|
-
"
|
|
5752
|
-
{
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
"
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
6329
|
+
ref: scroller,
|
|
6330
|
+
onScroll: (e) => {
|
|
6331
|
+
setScrolled(e.currentTarget.scrollLeft > 0);
|
|
6332
|
+
if (cloneRef.current) cloneRef.current.scrollLeft = e.currentTarget.scrollLeft;
|
|
6333
|
+
},
|
|
6334
|
+
className: cn("overflow-x-auto", SCROLLBAR, maxHeight && cn("overflow-y-auto", MAX_H[maxHeight])),
|
|
6335
|
+
children: /* @__PURE__ */ jsxs51(
|
|
6336
|
+
"table",
|
|
6337
|
+
{
|
|
6338
|
+
"aria-labelledby": title ? titleId : void 0,
|
|
6339
|
+
"aria-label": title ? void 0 : rest["aria-label"],
|
|
6340
|
+
"aria-busy": loading || refreshing || void 0,
|
|
6341
|
+
className: "w-full border-separate border-spacing-0 text-left",
|
|
6342
|
+
children: [
|
|
6343
|
+
/* @__PURE__ */ jsx58("thead", { ref: theadRef, className: cn(maxHeight && "sticky top-0 z-10"), children: headRow(false) }),
|
|
6344
|
+
/* @__PURE__ */ jsx58("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__ */ jsxs51("tr", { "aria-hidden": "true", className: "[&:last-child>td]:border-b-0", children: [
|
|
6345
|
+
selectable && /* @__PURE__ */ jsx58("td", { className: cn("border-b border-border-default", pad2) }),
|
|
6346
|
+
anyExpandable && /* @__PURE__ */ jsx58("td", { className: cn("border-b border-border-default", pad2, EXPAND_PAD) }),
|
|
6347
|
+
columns.map((c) => /* @__PURE__ */ jsx58("td", { className: cn("border-b border-border-default", pad2, align(c)), children: showSkeleton ? /* @__PURE__ */ jsx58(Skeleton, { className: cn("inline-block", right(c) ? "w-12" : "w-2/3") }) : /* @__PURE__ */ jsx58("span", { className: "inline-block h-3" }) }, c.key))
|
|
6348
|
+
] }, i)) : rows.length === 0 ? /* @__PURE__ */ jsx58("tr", { children: /* @__PURE__ */ jsx58("td", { colSpan: span, className: "px-6 py-12", children: empty ?? /* @__PURE__ */ jsx58(NoResultsEmptyState, {}) }) }) : /* @__PURE__ */ jsxs51(Fragment9, { children: [
|
|
6349
|
+
totalsRow !== void 0 && plainRow("total", totalsRow, "__totals", "bg-subtle"),
|
|
6350
|
+
rows.map((row, ri) => {
|
|
6351
|
+
const key = rowKey(row);
|
|
6352
|
+
const canOpen = expandable(row);
|
|
6353
|
+
const kids = canOpen ? childrenOf(row) : null;
|
|
6354
|
+
const isOpen = canOpen && open.has(key);
|
|
6355
|
+
const panelOpen = isOpen && !kids;
|
|
6356
|
+
const panelId = `${titleId}-row-${ri}`;
|
|
6357
|
+
const kidIds = kids ? kids.map((_, si) => `${panelId}-${si}`) : [];
|
|
6358
|
+
const rowBg = highlightRow?.(row) ? cn(TINT, onRowClick && TINT_HOVER) : panelOpen ? "bg-subtle" : void 0;
|
|
6359
|
+
const reason = selectable ? blocked(row) : false;
|
|
6360
|
+
const ticked = picked.has(key);
|
|
6361
|
+
const label = rowLabel ? rowLabel(row) : "row";
|
|
6362
|
+
const clickable = !!onRowClick || canOpen;
|
|
6363
|
+
return /* @__PURE__ */ jsxs51(Fragment8, { children: [
|
|
6364
|
+
/* @__PURE__ */ jsxs51(
|
|
6365
|
+
"tr",
|
|
6366
|
+
{
|
|
6367
|
+
onClick: onRowClick ? (e) => rowClickCounts(e) && onRowClick(row) : canOpen ? (e) => rowClickCounts(e) && toggle(key) : void 0,
|
|
6368
|
+
className: cn(
|
|
6369
|
+
"group/row hover:bg-subtle [&:last-child>td]:border-b-0",
|
|
6370
|
+
clickable && "cursor-pointer",
|
|
6371
|
+
panelOpen && "bg-subtle"
|
|
6372
|
+
// The row's hidden open button has keyboard focus: ring the whole row.
|
|
6373
|
+
),
|
|
6374
|
+
children: [
|
|
6375
|
+
selectable && /* @__PURE__ */ jsx58(
|
|
6376
|
+
"td",
|
|
6377
|
+
{
|
|
6378
|
+
onPointerDownCapture: (e) => shiftHeld.current = e.shiftKey,
|
|
6379
|
+
onKeyDownCapture: (e) => shiftHeld.current = e.shiftKey,
|
|
6380
|
+
className: cn("border-b border-border-default pr-0", pad2, panelOpen && "border-b-0", rowBg, ringCls("select"), pinCls("select", "body", rowBg)),
|
|
6381
|
+
style: pinStyle("select"),
|
|
6382
|
+
children: reason ? /* @__PURE__ */ jsx58(Tooltip, { label: reason, delay: 300, className: "inline-flex align-middle", children: /* @__PURE__ */ jsx58(
|
|
6383
|
+
"button",
|
|
6384
|
+
{
|
|
6385
|
+
type: "button",
|
|
6386
|
+
role: "checkbox",
|
|
6387
|
+
"aria-checked": ticked,
|
|
6388
|
+
"aria-disabled": "true",
|
|
6389
|
+
"aria-label": `Select ${label}`,
|
|
6390
|
+
onClick: (e) => e.preventDefault(),
|
|
6391
|
+
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",
|
|
6392
|
+
children: /* @__PURE__ */ jsx58(CheckBoxBox, { checked: ticked, disabled: true })
|
|
6393
|
+
}
|
|
6394
|
+
) }) : /* @__PURE__ */ jsx58(CheckBox, { checked: ticked, onChange: () => togglePick(ri), ariaLabel: `Select ${label}` })
|
|
6395
|
+
}
|
|
5783
6396
|
),
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
c.sortable && onSortChange ? /* @__PURE__ */ jsx55(
|
|
5787
|
-
SortButton,
|
|
5788
|
-
{
|
|
5789
|
-
label: c.label,
|
|
5790
|
-
sortKey: c.key,
|
|
5791
|
-
align: right(c) ? "right" : "left",
|
|
5792
|
-
sort: sortProp(shown),
|
|
5793
|
-
onSort,
|
|
5794
|
-
description: c.info,
|
|
5795
|
-
testIdPrefix
|
|
5796
|
-
}
|
|
5797
|
-
) : c.info ? /* @__PURE__ */ jsx55(SortButton, { label: c.label, sortKey: c.key, sortable: false, sort: sortProp(shown), onSort: () => {
|
|
5798
|
-
}, description: c.info, align: right(c) ? "right" : "left" }) : c.label,
|
|
5799
|
-
edge(ci)
|
|
5800
|
-
]
|
|
5801
|
-
},
|
|
5802
|
-
c.key
|
|
5803
|
-
))
|
|
5804
|
-
] }) }),
|
|
5805
|
-
/* @__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: [
|
|
5806
|
-
selectable && /* @__PURE__ */ jsx55("td", { className: cn("border-b border-border-default", pad2) }),
|
|
5807
|
-
anyExpandable && /* @__PURE__ */ jsx55("td", { className: cn("border-b border-border-default", pad2) }),
|
|
5808
|
-
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))
|
|
5809
|
-
] }, i)) : rows.length === 0 ? /* @__PURE__ */ jsx55("tr", { children: /* @__PURE__ */ jsx55("td", { colSpan: span, className: "px-6 py-12", children: empty ?? /* @__PURE__ */ jsx55(NoResultsEmptyState, {}) }) }) : /* @__PURE__ */ jsxs49(Fragment8, { children: [
|
|
5810
|
-
totalsRow !== void 0 && plainRow("total", totalsRow, "__totals", "bg-subtle"),
|
|
5811
|
-
rows.map((row, ri) => {
|
|
5812
|
-
const key = rowKey(row);
|
|
5813
|
-
const canOpen = expandable(row);
|
|
5814
|
-
const kids = canOpen ? childrenOf(row) : null;
|
|
5815
|
-
const isOpen = canOpen && open.has(key);
|
|
5816
|
-
const panelOpen = isOpen && !kids;
|
|
5817
|
-
const panelId = `${titleId}-row-${ri}`;
|
|
5818
|
-
const kidIds = kids ? kids.map((_, si) => `${panelId}-${si}`) : [];
|
|
5819
|
-
const rowBg = highlightRow?.(row) ? cn(TINT, onRowClick && TINT_HOVER) : panelOpen ? "bg-subtle" : void 0;
|
|
5820
|
-
const reason = selectable ? blocked(row) : false;
|
|
5821
|
-
const ticked = picked.has(key);
|
|
5822
|
-
const label = rowLabel ? rowLabel(row) : "row";
|
|
5823
|
-
const clickable = !!onRowClick || canOpen;
|
|
5824
|
-
return /* @__PURE__ */ jsxs49(Fragment7, { children: [
|
|
5825
|
-
/* @__PURE__ */ jsxs49(
|
|
5826
|
-
"tr",
|
|
6397
|
+
anyExpandable && /* @__PURE__ */ jsx58(
|
|
6398
|
+
"td",
|
|
5827
6399
|
{
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
className: cn("border-b border-border-default pr-0", pad2, panelOpen && "border-b-0", rowBg, ringCls("select"), pinCls("select", "body", rowBg)),
|
|
5842
|
-
style: pinStyle("select"),
|
|
5843
|
-
children: reason ? /* @__PURE__ */ jsx55(Tooltip, { label: reason, delay: 300, className: "inline-flex align-middle", children: /* @__PURE__ */ jsx55(
|
|
5844
|
-
"button",
|
|
5845
|
-
{
|
|
5846
|
-
type: "button",
|
|
5847
|
-
role: "checkbox",
|
|
5848
|
-
"aria-checked": ticked,
|
|
5849
|
-
"aria-disabled": "true",
|
|
5850
|
-
"aria-label": `Select ${label}`,
|
|
5851
|
-
onClick: (e) => e.preventDefault(),
|
|
5852
|
-
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",
|
|
5853
|
-
children: /* @__PURE__ */ jsx55(CheckBoxBox, { checked: ticked, disabled: true })
|
|
5854
|
-
}
|
|
5855
|
-
) }) : /* @__PURE__ */ jsx55(CheckBox, { checked: ticked, onChange: () => togglePick(ri), ariaLabel: `Select ${label}` })
|
|
5856
|
-
}
|
|
5857
|
-
),
|
|
5858
|
-
anyExpandable && /* @__PURE__ */ jsx55(
|
|
5859
|
-
"td",
|
|
5860
|
-
{
|
|
5861
|
-
className: cn("border-b border-border-default pr-0", pad2, panelOpen && "border-b-0", rowBg, ringCls("expand"), pinCls("expand", "body", rowBg)),
|
|
5862
|
-
style: pinStyle("expand"),
|
|
5863
|
-
children: canOpen && /* @__PURE__ */ jsx55(
|
|
5864
|
-
"button",
|
|
5865
|
-
{
|
|
5866
|
-
type: "button",
|
|
5867
|
-
"aria-expanded": isOpen,
|
|
5868
|
-
"aria-controls": isOpen ? kids ? kidIds.join(" ") : panelId : void 0,
|
|
5869
|
-
"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)}` : ""}`,
|
|
5870
|
-
onClick: () => toggle(key),
|
|
5871
|
-
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",
|
|
5872
|
-
children: /* @__PURE__ */ jsx55(
|
|
5873
|
-
ChevronRight6,
|
|
5874
|
-
{
|
|
5875
|
-
size: 16,
|
|
5876
|
-
"aria-hidden": "true",
|
|
5877
|
-
className: cn("transition-transform motion-reduce:transition-none", isOpen && "rotate-90")
|
|
5878
|
-
}
|
|
5879
|
-
)
|
|
5880
|
-
}
|
|
5881
|
-
)
|
|
5882
|
-
}
|
|
5883
|
-
),
|
|
5884
|
-
columns.map((c, ci) => {
|
|
5885
|
-
const bg = colBg(c, rowBg);
|
|
5886
|
-
const opener = !!onRowClick && ci === nameIdx;
|
|
5887
|
-
return /* @__PURE__ */ jsxs49(
|
|
5888
|
-
"td",
|
|
6400
|
+
className: cn("border-b border-border-default", pad2, EXPAND_PAD, panelOpen && "border-b-0", rowBg, ringCls("expand"), pinCls("expand", "body", rowBg)),
|
|
6401
|
+
style: pinStyle("expand"),
|
|
6402
|
+
children: canOpen && /* @__PURE__ */ jsx58(
|
|
6403
|
+
"button",
|
|
6404
|
+
{
|
|
6405
|
+
type: "button",
|
|
6406
|
+
"aria-expanded": isOpen,
|
|
6407
|
+
"aria-controls": isOpen ? kids ? kidIds.join(" ") : panelId : void 0,
|
|
6408
|
+
"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)}` : ""}`,
|
|
6409
|
+
onClick: () => toggle(key),
|
|
6410
|
+
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",
|
|
6411
|
+
children: /* @__PURE__ */ jsx58(
|
|
6412
|
+
ChevronRight7,
|
|
5889
6413
|
{
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
ringCls(ci),
|
|
5898
|
-
bg,
|
|
5899
|
-
pinCls(ci, "body", bg)
|
|
5900
|
-
),
|
|
5901
|
-
style: pinStyle(ci),
|
|
5902
|
-
children: [
|
|
5903
|
-
fit(ci, renderCell(c, row)),
|
|
5904
|
-
opener && // The keyboard's and screen reader's way to the row click. It
|
|
5905
|
-
// stays hidden; while it has focus the whole row takes the ring.
|
|
5906
|
-
/* @__PURE__ */ jsx55("button", { type: "button", "data-row-open": "", onClick: () => onRowClick(row), className: "sr-only", children: rowClickLabel ? rowClickLabel(row) : `Open ${rowLabel ? rowLabel(row) : "row"}` }),
|
|
5907
|
-
edge(ci)
|
|
5908
|
-
]
|
|
5909
|
-
},
|
|
5910
|
-
c.key
|
|
5911
|
-
);
|
|
5912
|
-
})
|
|
5913
|
-
]
|
|
6414
|
+
size: 16,
|
|
6415
|
+
"aria-hidden": "true",
|
|
6416
|
+
className: cn("transition-transform motion-reduce:transition-none", isOpen && "rotate-90")
|
|
6417
|
+
}
|
|
6418
|
+
)
|
|
6419
|
+
}
|
|
6420
|
+
)
|
|
5914
6421
|
}
|
|
5915
6422
|
),
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
6423
|
+
columns.map((c, ci) => {
|
|
6424
|
+
const bg = colBg(c, rowBg);
|
|
6425
|
+
const opener = !!onRowClick && ci === nameIdx;
|
|
6426
|
+
return /* @__PURE__ */ jsxs51(
|
|
6427
|
+
"td",
|
|
6428
|
+
{
|
|
6429
|
+
className: cn(
|
|
6430
|
+
"border-b border-border-default",
|
|
6431
|
+
pad2,
|
|
6432
|
+
align(c),
|
|
6433
|
+
right(c) && "tabular-nums",
|
|
6434
|
+
c.rank && "text-text-tertiary",
|
|
6435
|
+
panelOpen && "border-b-0",
|
|
6436
|
+
ringCls(ci),
|
|
6437
|
+
bg,
|
|
6438
|
+
pinCls(ci, "body", bg)
|
|
6439
|
+
),
|
|
6440
|
+
style: pinStyle(ci),
|
|
6441
|
+
children: [
|
|
6442
|
+
fit(ci, renderCell(c, row)),
|
|
6443
|
+
opener && // The keyboard's and screen reader's way to the row click. It
|
|
6444
|
+
// stays hidden; while it has focus the whole row takes the ring.
|
|
6445
|
+
/* @__PURE__ */ jsx58("button", { type: "button", "data-row-open": "", onClick: () => onRowClick(row), className: "sr-only", children: rowClickLabel ? rowClickLabel(row) : `Open ${rowLabel ? rowLabel(row) : "row"}` }),
|
|
6446
|
+
edge(ci)
|
|
6447
|
+
]
|
|
6448
|
+
},
|
|
6449
|
+
c.key
|
|
6450
|
+
);
|
|
6451
|
+
})
|
|
6452
|
+
]
|
|
6453
|
+
}
|
|
6454
|
+
),
|
|
6455
|
+
panelOpen && /* @__PURE__ */ jsx58("tr", { className: "[&:last-child>td]:border-b-0", children: /* @__PURE__ */ jsx58("td", { id: panelId, colSpan: span, className: "border-b border-border-default bg-subtle px-4 pb-4 pl-14", children: renderExpanded(row) }) }),
|
|
6456
|
+
isOpen && kids?.map(
|
|
6457
|
+
(child, si) => plainRow("sub", child, `${key}::${rowKey(child)}`, highlightRow?.(child) ? TINT : "bg-subtle", { id: kidIds[si], parent: row })
|
|
6458
|
+
)
|
|
6459
|
+
] }, key);
|
|
6460
|
+
})
|
|
6461
|
+
] }) })
|
|
6462
|
+
]
|
|
6463
|
+
}
|
|
6464
|
+
)
|
|
6465
|
+
}
|
|
6466
|
+
);
|
|
6467
|
+
const bare = inside || !title && barCount === 0;
|
|
6468
|
+
const frame = /* @__PURE__ */ jsxs51(
|
|
6469
|
+
"div",
|
|
6470
|
+
{
|
|
6471
|
+
className: cn(
|
|
6472
|
+
"relative flex w-full flex-col rounded-card border border-border-default bg-surface",
|
|
6473
|
+
// clip, not hidden, on a sticky table: hidden would make the frame the
|
|
6474
|
+
// box its header sticks in, instead of the page.
|
|
6475
|
+
sticky ? "overflow-clip" : "overflow-hidden",
|
|
6476
|
+
!sticky && bare && className
|
|
6477
|
+
),
|
|
6478
|
+
"data-testid": testIdPrefix,
|
|
6479
|
+
children: [
|
|
6480
|
+
title && inside && /* @__PURE__ */ jsxs51("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
|
|
6481
|
+
/* @__PURE__ */ jsxs51("div", { className: "min-w-0", children: [
|
|
6482
|
+
/* @__PURE__ */ jsx58("h3", { id: titleId, className: "text-panel-title font-semibold text-text-primary", children: title }),
|
|
6483
|
+
subtitle && /* @__PURE__ */ jsx58("p", { className: "mt-0.5 text-xs leading-snug text-text-tertiary", children: subtitle })
|
|
6484
|
+
] }),
|
|
6485
|
+
(bar ?? action) && /* @__PURE__ */ jsx58("div", { className: "shrink-0 text-text-tertiary", children: bar ?? action })
|
|
6486
|
+
] }),
|
|
6487
|
+
sticky ? (
|
|
6488
|
+
// The copy of the header sticks within this box, so it leaves with the last row.
|
|
6489
|
+
/* @__PURE__ */ jsxs51("div", { className: "relative", children: [
|
|
6490
|
+
/* @__PURE__ */ jsx58(
|
|
6491
|
+
"div",
|
|
6492
|
+
{
|
|
6493
|
+
ref: cloneRef,
|
|
6494
|
+
"aria-hidden": "true",
|
|
6495
|
+
"data-sticky-head": "",
|
|
6496
|
+
onWheel: (e) => {
|
|
6497
|
+
if (scroller.current && Math.abs(e.deltaX) > Math.abs(e.deltaY)) scroller.current.scrollLeft += e.deltaX;
|
|
6498
|
+
},
|
|
6499
|
+
className: "sticky z-2 overflow-hidden",
|
|
6500
|
+
style: { top, height: geom.height, marginBottom: -geom.height, visibility: stuck ? "visible" : "hidden" },
|
|
6501
|
+
children: /* @__PURE__ */ jsxs51("table", { className: "table-fixed border-separate border-spacing-0 text-left", style: { width: geom.width }, children: [
|
|
6502
|
+
/* @__PURE__ */ jsx58("colgroup", { children: geom.cols.map((w, i) => /* @__PURE__ */ jsx58("col", { style: { width: w } }, i)) }),
|
|
6503
|
+
/* @__PURE__ */ jsx58("thead", { children: headRow(true) })
|
|
6504
|
+
] })
|
|
5924
6505
|
}
|
|
5925
|
-
)
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
/* @__PURE__ */
|
|
5930
|
-
|
|
6506
|
+
),
|
|
6507
|
+
scrollArea
|
|
6508
|
+
] })
|
|
6509
|
+
) : scrollArea,
|
|
6510
|
+
refreshing && !loading && /* @__PURE__ */ jsx58(RefreshLine, {}),
|
|
6511
|
+
/* @__PURE__ */ jsx58(LongWait, { loading, onRetry, className: "mb-3 px-4" }),
|
|
6512
|
+
footer && !sticky && /* @__PURE__ */ jsx58("div", { className: "border-t border-border-default px-4 py-3", children: footer })
|
|
5931
6513
|
]
|
|
5932
6514
|
}
|
|
5933
6515
|
);
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
6516
|
+
const hideFooter = footerStuck && !scrolledDown;
|
|
6517
|
+
const body = sticky ? /* @__PURE__ */ jsxs51("div", { ref: wrapRef, className: cn("flex w-full flex-col", bare && className), children: [
|
|
6518
|
+
frame,
|
|
6519
|
+
footer && /* @__PURE__ */ jsx58(
|
|
6520
|
+
"div",
|
|
6521
|
+
{
|
|
6522
|
+
"data-sticky-footer": "",
|
|
6523
|
+
style: scrollPad.bottom ? { bottom: -scrollPad.bottom } : void 0,
|
|
6524
|
+
className: cn(
|
|
6525
|
+
"sticky bottom-0 z-3 border-t bg-canvas py-3",
|
|
6526
|
+
footerStuck ? "border-border-default" : "border-transparent",
|
|
6527
|
+
animate && "transition-[opacity,translate] duration-(--mr-motion-duration-interactive) ease-interactive motion-reduce:transition-none",
|
|
6528
|
+
// Hidden, not gone: Tab still reaches it, and focus shows it.
|
|
6529
|
+
hideFooter && "pointer-events-none translate-y-full opacity-0 focus-within:pointer-events-auto focus-within:translate-y-0 focus-within:opacity-100"
|
|
6530
|
+
),
|
|
6531
|
+
children: footer
|
|
6532
|
+
}
|
|
6533
|
+
)
|
|
6534
|
+
] }) : frame;
|
|
6535
|
+
if (bare) return body;
|
|
6536
|
+
return /* @__PURE__ */ jsxs51("section", { "aria-labelledby": title ? titleId : void 0, className: cn("flex w-full flex-col gap-3", className), children: [
|
|
6537
|
+
title ? /* @__PURE__ */ jsx58(SectionHeading, { id: titleId, as: titleAs, title, description: subtitle, actions: bar ?? action }) : /* @__PURE__ */ jsx58("div", { className: "flex justify-end", children: bar }),
|
|
6538
|
+
body
|
|
5938
6539
|
] });
|
|
5939
6540
|
}
|
|
5940
6541
|
|
|
5941
6542
|
// src/MediaLabel.tsx
|
|
5942
|
-
import { jsx as
|
|
6543
|
+
import { jsx as jsx59 } from "react/jsx-runtime";
|
|
5943
6544
|
var FILL = {
|
|
5944
6545
|
TV: "bg-media-tv",
|
|
5945
6546
|
CTV: "bg-media-ctv",
|
|
@@ -5950,7 +6551,7 @@ var FILL = {
|
|
|
5950
6551
|
Magazine: "bg-media-magazine"
|
|
5951
6552
|
};
|
|
5952
6553
|
function MediaLabel({ type, className, testIdPrefix }) {
|
|
5953
|
-
return /* @__PURE__ */
|
|
6554
|
+
return /* @__PURE__ */ jsx59(
|
|
5954
6555
|
"span",
|
|
5955
6556
|
{
|
|
5956
6557
|
className: cn(
|
|
@@ -5965,10 +6566,10 @@ function MediaLabel({ type, className, testIdPrefix }) {
|
|
|
5965
6566
|
}
|
|
5966
6567
|
|
|
5967
6568
|
// src/SuggestionChip.tsx
|
|
5968
|
-
import { forwardRef as
|
|
5969
|
-
import { jsx as
|
|
5970
|
-
var SuggestionChip =
|
|
5971
|
-
return /* @__PURE__ */
|
|
6569
|
+
import { forwardRef as forwardRef11 } from "react";
|
|
6570
|
+
import { jsx as jsx60 } from "react/jsx-runtime";
|
|
6571
|
+
var SuggestionChip = forwardRef11(function SuggestionChip2({ children, className, testIdPrefix, type = "button", ...props }, ref) {
|
|
6572
|
+
return /* @__PURE__ */ jsx60(
|
|
5972
6573
|
"button",
|
|
5973
6574
|
{
|
|
5974
6575
|
ref,
|
|
@@ -5979,18 +6580,18 @@ var SuggestionChip = forwardRef10(function SuggestionChip2({ children, className
|
|
|
5979
6580
|
"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",
|
|
5980
6581
|
className
|
|
5981
6582
|
),
|
|
5982
|
-
children: /* @__PURE__ */
|
|
6583
|
+
children: /* @__PURE__ */ jsx60("span", { className: "truncate", children })
|
|
5983
6584
|
}
|
|
5984
6585
|
);
|
|
5985
6586
|
});
|
|
5986
6587
|
SuggestionChip.displayName = "SuggestionChip";
|
|
5987
6588
|
|
|
5988
6589
|
// src/ToggleChip.tsx
|
|
5989
|
-
import { forwardRef as
|
|
5990
|
-
import { Check as
|
|
5991
|
-
import { jsx as
|
|
5992
|
-
var ToggleChip =
|
|
5993
|
-
return /* @__PURE__ */
|
|
6590
|
+
import { forwardRef as forwardRef12 } from "react";
|
|
6591
|
+
import { Check as Check11 } from "lucide-react";
|
|
6592
|
+
import { jsx as jsx61, jsxs as jsxs52 } from "react/jsx-runtime";
|
|
6593
|
+
var ToggleChip = forwardRef12(function ToggleChip2({ selected, onChange, children, className, testIdPrefix, type = "button", onClick, ...props }, ref) {
|
|
6594
|
+
return /* @__PURE__ */ jsxs52(
|
|
5994
6595
|
"button",
|
|
5995
6596
|
{
|
|
5996
6597
|
ref,
|
|
@@ -6008,7 +6609,7 @@ var ToggleChip = forwardRef11(function ToggleChip2({ selected, onChange, childre
|
|
|
6008
6609
|
className
|
|
6009
6610
|
),
|
|
6010
6611
|
children: [
|
|
6011
|
-
selected && /* @__PURE__ */
|
|
6612
|
+
selected && /* @__PURE__ */ jsx61(Check11, { size: 14, "aria-hidden": "true", className: "-ml-0.5 shrink-0" }),
|
|
6012
6613
|
children
|
|
6013
6614
|
]
|
|
6014
6615
|
}
|
|
@@ -6017,14 +6618,14 @@ var ToggleChip = forwardRef11(function ToggleChip2({ selected, onChange, childre
|
|
|
6017
6618
|
ToggleChip.displayName = "ToggleChip";
|
|
6018
6619
|
|
|
6019
6620
|
// src/CopyButton.tsx
|
|
6020
|
-
import { forwardRef as
|
|
6021
|
-
import { Check as
|
|
6022
|
-
import { jsx as
|
|
6621
|
+
import { forwardRef as forwardRef13, useEffect as useEffect20, useRef as useRef22, useState as useState21 } from "react";
|
|
6622
|
+
import { Check as Check12, Copy } from "lucide-react";
|
|
6623
|
+
import { jsx as jsx62, jsxs as jsxs53 } from "react/jsx-runtime";
|
|
6023
6624
|
var CONFIRM_MS = 2e3;
|
|
6024
|
-
var CopyButton =
|
|
6025
|
-
const [copied, setCopied] =
|
|
6026
|
-
const timer =
|
|
6027
|
-
|
|
6625
|
+
var CopyButton = forwardRef13(function CopyButton2({ value, label, "aria-label": ariaLabel, size = "xs", className, testIdPrefix }, ref) {
|
|
6626
|
+
const [copied, setCopied] = useState21(false);
|
|
6627
|
+
const timer = useRef22(void 0);
|
|
6628
|
+
useEffect20(() => () => clearTimeout(timer.current), []);
|
|
6028
6629
|
const copy = async () => {
|
|
6029
6630
|
try {
|
|
6030
6631
|
await navigator.clipboard.writeText(typeof value === "function" ? value() : value);
|
|
@@ -6036,8 +6637,8 @@ var CopyButton = forwardRef12(function CopyButton2({ value, label, "aria-label":
|
|
|
6036
6637
|
timer.current = setTimeout(() => setCopied(false), CONFIRM_MS);
|
|
6037
6638
|
};
|
|
6038
6639
|
const iconSize = size === "xs" ? 13 : 15;
|
|
6039
|
-
const icon = copied ? /* @__PURE__ */
|
|
6040
|
-
return /* @__PURE__ */
|
|
6640
|
+
const icon = copied ? /* @__PURE__ */ jsx62(Check12, { size: iconSize, "aria-hidden": "true", className: "shrink-0 text-text-success" }) : /* @__PURE__ */ jsx62(Copy, { size: iconSize, "aria-hidden": "true", className: "shrink-0" });
|
|
6641
|
+
return /* @__PURE__ */ jsxs53(
|
|
6041
6642
|
Button,
|
|
6042
6643
|
{
|
|
6043
6644
|
ref,
|
|
@@ -6051,8 +6652,8 @@ var CopyButton = forwardRef12(function CopyButton2({ value, label, "aria-label":
|
|
|
6051
6652
|
className: cn(!copied && "text-text-secondary", className),
|
|
6052
6653
|
children: [
|
|
6053
6654
|
icon,
|
|
6054
|
-
label && /* @__PURE__ */
|
|
6055
|
-
/* @__PURE__ */
|
|
6655
|
+
label && /* @__PURE__ */ jsx62("span", { children: copied ? "Copied" : label }),
|
|
6656
|
+
/* @__PURE__ */ jsx62("span", { role: "status", className: "sr-only", children: copied ? "Copied" : "" })
|
|
6056
6657
|
]
|
|
6057
6658
|
}
|
|
6058
6659
|
);
|
|
@@ -6061,7 +6662,7 @@ CopyButton.displayName = "CopyButton";
|
|
|
6061
6662
|
|
|
6062
6663
|
// src/InlineMessage.tsx
|
|
6063
6664
|
import { AlertTriangle as AlertTriangle2, CheckCircle2, Info as Info3, X as X8, XCircle } from "lucide-react";
|
|
6064
|
-
import { jsx as
|
|
6665
|
+
import { jsx as jsx63, jsxs as jsxs54 } from "react/jsx-runtime";
|
|
6065
6666
|
var BOX = {
|
|
6066
6667
|
info: "border-brand-primaryAction/30 bg-brand-primaryAction/10",
|
|
6067
6668
|
success: "border-status-success/40 bg-status-success/10",
|
|
@@ -6078,27 +6679,27 @@ var ICON_INK = {
|
|
|
6078
6679
|
var ICON2 = { info: Info3, success: CheckCircle2, warning: AlertTriangle2, danger: XCircle };
|
|
6079
6680
|
function InlineMessage({ tone = "info", title, children, actions, onDismiss, className, testIdPrefix }) {
|
|
6080
6681
|
const Icon = ICON2[tone];
|
|
6081
|
-
return /* @__PURE__ */
|
|
6682
|
+
return /* @__PURE__ */ jsxs54(
|
|
6082
6683
|
"div",
|
|
6083
6684
|
{
|
|
6084
6685
|
role: tone === "warning" || tone === "danger" ? "alert" : "status",
|
|
6085
6686
|
className: cn("flex items-start gap-2.5 rounded-control border px-3 py-2.5 text-sm", BOX[tone], className),
|
|
6086
6687
|
"data-testid": testIdPrefix,
|
|
6087
6688
|
children: [
|
|
6088
|
-
/* @__PURE__ */
|
|
6089
|
-
/* @__PURE__ */
|
|
6090
|
-
/* @__PURE__ */
|
|
6091
|
-
children && /* @__PURE__ */
|
|
6092
|
-
actions && /* @__PURE__ */
|
|
6689
|
+
/* @__PURE__ */ jsx63(Icon, { size: 16, "aria-hidden": "true", className: cn("mt-0.5 shrink-0", ICON_INK[tone]) }),
|
|
6690
|
+
/* @__PURE__ */ jsxs54("div", { className: "min-w-0 flex-1", children: [
|
|
6691
|
+
/* @__PURE__ */ jsx63("p", { className: "font-semibold text-text-primary", children: title }),
|
|
6692
|
+
children && /* @__PURE__ */ jsx63("div", { className: "mt-0.5 text-text-secondary", children }),
|
|
6693
|
+
actions && /* @__PURE__ */ jsx63("div", { className: "mt-2 flex flex-wrap items-center gap-2", children: actions })
|
|
6093
6694
|
] }),
|
|
6094
|
-
onDismiss && /* @__PURE__ */
|
|
6695
|
+
onDismiss && /* @__PURE__ */ jsx63(
|
|
6095
6696
|
"button",
|
|
6096
6697
|
{
|
|
6097
6698
|
type: "button",
|
|
6098
6699
|
onClick: onDismiss,
|
|
6099
6700
|
"aria-label": "Dismiss",
|
|
6100
6701
|
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",
|
|
6101
|
-
children: /* @__PURE__ */
|
|
6702
|
+
children: /* @__PURE__ */ jsx63(X8, { size: 14, "aria-hidden": "true" })
|
|
6102
6703
|
}
|
|
6103
6704
|
)
|
|
6104
6705
|
]
|
|
@@ -6107,9 +6708,9 @@ function InlineMessage({ tone = "info", title, children, actions, onDismiss, cla
|
|
|
6107
6708
|
}
|
|
6108
6709
|
|
|
6109
6710
|
// src/FilterDrawer.tsx
|
|
6110
|
-
import { useEffect as
|
|
6111
|
-
import { ChevronLeft as ChevronLeft5, ChevronRight as
|
|
6112
|
-
import { jsx as
|
|
6711
|
+
import { useEffect as useEffect21, useLayoutEffect as useLayoutEffect8, useRef as useRef23, useState as useState22 } from "react";
|
|
6712
|
+
import { ChevronLeft as ChevronLeft5, ChevronRight as ChevronRight8 } from "lucide-react";
|
|
6713
|
+
import { Fragment as Fragment10, jsx as jsx64, jsxs as jsxs55 } from "react/jsx-runtime";
|
|
6113
6714
|
var SLIDE_MS = 200;
|
|
6114
6715
|
function reducedMotion() {
|
|
6115
6716
|
return typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
@@ -6125,19 +6726,30 @@ function FilterDrawer({
|
|
|
6125
6726
|
onApply,
|
|
6126
6727
|
focus = null,
|
|
6127
6728
|
size = "sm",
|
|
6729
|
+
hasChanges,
|
|
6128
6730
|
testIdPrefix
|
|
6129
6731
|
}) {
|
|
6130
|
-
const
|
|
6131
|
-
const [
|
|
6132
|
-
const [
|
|
6133
|
-
const [
|
|
6732
|
+
const marks = (list) => list.map((x) => `${x.id}:${x.count ?? 0}:${x.badge ?? ""}`).join("|");
|
|
6733
|
+
const [openedWith, setOpenedWith] = useState22(() => marks(sections));
|
|
6734
|
+
const [confirming, setConfirming] = useState22(false);
|
|
6735
|
+
const [view, setViewState] = useState22(focus);
|
|
6736
|
+
const [leaving, setLeaving] = useState22(null);
|
|
6737
|
+
const [phase, setPhase] = useState22("run");
|
|
6738
|
+
const [wasOpen, setWasOpen] = useState22(open);
|
|
6134
6739
|
if (open !== wasOpen) {
|
|
6135
6740
|
setWasOpen(open);
|
|
6741
|
+
setConfirming(false);
|
|
6136
6742
|
if (open) {
|
|
6137
6743
|
setViewState(focus);
|
|
6138
6744
|
setLeaving(null);
|
|
6745
|
+
setOpenedWith(marks(sections));
|
|
6139
6746
|
}
|
|
6140
6747
|
}
|
|
6748
|
+
const changed = hasChanges ?? marks(sections) !== openedWith;
|
|
6749
|
+
const requestClose = () => {
|
|
6750
|
+
if (changed) setConfirming(true);
|
|
6751
|
+
else onClose();
|
|
6752
|
+
};
|
|
6141
6753
|
const setView = (next) => {
|
|
6142
6754
|
if (!reducedMotion()) {
|
|
6143
6755
|
setLeaving({ view, dir: next ? 1 : -1 });
|
|
@@ -6145,20 +6757,20 @@ function FilterDrawer({
|
|
|
6145
6757
|
}
|
|
6146
6758
|
setViewState(next);
|
|
6147
6759
|
};
|
|
6148
|
-
|
|
6760
|
+
useLayoutEffect8(() => {
|
|
6149
6761
|
if (phase !== "start") return;
|
|
6150
6762
|
const raf = requestAnimationFrame(() => requestAnimationFrame(() => setPhase("run")));
|
|
6151
6763
|
return () => cancelAnimationFrame(raf);
|
|
6152
6764
|
}, [phase]);
|
|
6153
|
-
|
|
6765
|
+
useEffect21(() => {
|
|
6154
6766
|
if (!leaving || phase !== "run") return;
|
|
6155
6767
|
const t = setTimeout(() => setLeaving(null), SLIDE_MS);
|
|
6156
6768
|
return () => clearTimeout(t);
|
|
6157
6769
|
}, [leaving, phase]);
|
|
6158
|
-
const backRef =
|
|
6159
|
-
const rowRefs =
|
|
6160
|
-
const lastView =
|
|
6161
|
-
|
|
6770
|
+
const backRef = useRef23(null);
|
|
6771
|
+
const rowRefs = useRef23(/* @__PURE__ */ new Map());
|
|
6772
|
+
const lastView = useRef23(null);
|
|
6773
|
+
useEffect21(() => {
|
|
6162
6774
|
if (!open) return;
|
|
6163
6775
|
if (view) backRef.current?.focus();
|
|
6164
6776
|
else if (lastView.current) rowRefs.current.get(lastView.current)?.focus();
|
|
@@ -6171,8 +6783,8 @@ function FilterDrawer({
|
|
|
6171
6783
|
const outgoing = phase === "start" ? void 0 : dir > 0 ? "translateX(-33%)" : "translateX(100%)";
|
|
6172
6784
|
const panel = (v, rows = true) => {
|
|
6173
6785
|
const s = v ? sections.find((x) => x.id === v) : void 0;
|
|
6174
|
-
if (s) return /* @__PURE__ */
|
|
6175
|
-
return /* @__PURE__ */
|
|
6786
|
+
if (s) return /* @__PURE__ */ jsx64("div", { className: "border-t border-border-default px-5 pt-4", children: renderSection(s.id) });
|
|
6787
|
+
return /* @__PURE__ */ jsx64("ul", { className: "border-t border-border-default", children: sections.map((x) => /* @__PURE__ */ jsx64("li", { className: "border-b border-border-default", children: /* @__PURE__ */ jsxs55(
|
|
6176
6788
|
"button",
|
|
6177
6789
|
{
|
|
6178
6790
|
ref: rows ? (el) => {
|
|
@@ -6184,7 +6796,7 @@ function FilterDrawer({
|
|
|
6184
6796
|
"data-testid": testIdPrefix && `${testIdPrefix}-row-${x.id}`,
|
|
6185
6797
|
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",
|
|
6186
6798
|
children: [
|
|
6187
|
-
/* @__PURE__ */
|
|
6799
|
+
/* @__PURE__ */ jsx64(
|
|
6188
6800
|
x.icon,
|
|
6189
6801
|
{
|
|
6190
6802
|
size: 17,
|
|
@@ -6192,100 +6804,132 @@ function FilterDrawer({
|
|
|
6192
6804
|
className: inUse(x) ? "text-brand-primaryAction" : "text-text-secondary"
|
|
6193
6805
|
}
|
|
6194
6806
|
),
|
|
6195
|
-
/* @__PURE__ */
|
|
6196
|
-
/* @__PURE__ */
|
|
6197
|
-
/* @__PURE__ */
|
|
6807
|
+
/* @__PURE__ */ jsx64("span", { className: "flex-1 text-sm font-medium text-text-primary", children: x.label }),
|
|
6808
|
+
/* @__PURE__ */ jsx64(SectionMark, { section: x }),
|
|
6809
|
+
/* @__PURE__ */ jsx64(ChevronRight8, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-secondary" })
|
|
6198
6810
|
]
|
|
6199
6811
|
}
|
|
6200
6812
|
) }, x.id)) });
|
|
6201
6813
|
};
|
|
6202
|
-
return /* @__PURE__ */
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
onClick: () => setView(null),
|
|
6216
|
-
"aria-label": "Back to all filters",
|
|
6217
|
-
"data-testid": testIdPrefix && `${testIdPrefix}-back`,
|
|
6218
|
-
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",
|
|
6219
|
-
children: /* @__PURE__ */ jsx61(ChevronLeft5, { size: 18, "aria-hidden": "true" })
|
|
6220
|
-
}
|
|
6221
|
-
),
|
|
6222
|
-
focused.label,
|
|
6223
|
-
(focused.count ?? 0) > 0 && /* @__PURE__ */ jsx61(CountBadge, { count: focused.count }),
|
|
6224
|
-
focused.info && /* @__PURE__ */ jsx61(InfoTip, { text: focused.info, label: `About ${focused.label}` })
|
|
6225
|
-
] }) : "Filters",
|
|
6226
|
-
footer: focused ? (
|
|
6227
|
-
// Picks are kept as they're made; only See results, on the list, applies them.
|
|
6228
|
-
/* @__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" }) })
|
|
6229
|
-
) : /* @__PURE__ */ jsxs53("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
6230
|
-
/* @__PURE__ */ jsx61(Button, { variant: "link", size: "md", onClick: onClearAll, className: "px-0", children: "Clear all" }),
|
|
6231
|
-
/* @__PURE__ */ jsxs53("div", { className: "flex items-center gap-2", children: [
|
|
6232
|
-
/* @__PURE__ */ jsx61(Button, { variant: "secondary", size: "md", onClick: onClose, children: "Cancel" }),
|
|
6233
|
-
/* @__PURE__ */ jsx61(
|
|
6814
|
+
return /* @__PURE__ */ jsxs55(Fragment10, { children: [
|
|
6815
|
+
/* @__PURE__ */ jsx64(
|
|
6816
|
+
Modal,
|
|
6817
|
+
{
|
|
6818
|
+
open: open && confirming,
|
|
6819
|
+
onClose: () => setConfirming(false),
|
|
6820
|
+
size: "sm",
|
|
6821
|
+
title: "Discard changes?",
|
|
6822
|
+
description: "Your filter picks haven't been applied.",
|
|
6823
|
+
testIdPrefix: testIdPrefix && `${testIdPrefix}-discard`,
|
|
6824
|
+
footer: /* @__PURE__ */ jsxs55(Fragment10, { children: [
|
|
6825
|
+
/* @__PURE__ */ jsx64(Button, { variant: "secondary", size: "md", onClick: () => setConfirming(false), children: "Keep editing" }),
|
|
6826
|
+
/* @__PURE__ */ jsx64(
|
|
6234
6827
|
Button,
|
|
6235
6828
|
{
|
|
6236
|
-
variant: "
|
|
6829
|
+
variant: "danger",
|
|
6237
6830
|
size: "md",
|
|
6238
6831
|
onClick: () => {
|
|
6239
|
-
|
|
6832
|
+
setConfirming(false);
|
|
6240
6833
|
onClose();
|
|
6241
6834
|
},
|
|
6242
|
-
children: "
|
|
6835
|
+
children: "Discard"
|
|
6243
6836
|
}
|
|
6244
6837
|
)
|
|
6245
6838
|
] })
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6839
|
+
}
|
|
6840
|
+
),
|
|
6841
|
+
/* @__PURE__ */ jsx64(
|
|
6842
|
+
Drawer,
|
|
6843
|
+
{
|
|
6844
|
+
open,
|
|
6845
|
+
onClose: requestClose,
|
|
6846
|
+
size,
|
|
6847
|
+
testIdPrefix,
|
|
6848
|
+
title: focused ? /* @__PURE__ */ jsxs55("span", { className: "flex items-center gap-1.5", children: [
|
|
6849
|
+
/* @__PURE__ */ jsx64(
|
|
6850
|
+
"button",
|
|
6851
|
+
{
|
|
6852
|
+
ref: backRef,
|
|
6853
|
+
type: "button",
|
|
6854
|
+
onClick: () => setView(null),
|
|
6855
|
+
"aria-label": "Back to all filters",
|
|
6856
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-back`,
|
|
6857
|
+
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",
|
|
6858
|
+
children: /* @__PURE__ */ jsx64(ChevronLeft5, { size: 18, "aria-hidden": "true" })
|
|
6859
|
+
}
|
|
6860
|
+
),
|
|
6861
|
+
focused.label,
|
|
6862
|
+
(focused.count ?? 0) > 0 && /* @__PURE__ */ jsx64(CountBadge, { count: focused.count }),
|
|
6863
|
+
focused.info && /* @__PURE__ */ jsx64(InfoTip, { text: focused.info, label: `About ${focused.label}` })
|
|
6864
|
+
] }) : "Filters",
|
|
6865
|
+
footer: focused ? (
|
|
6866
|
+
// Picks are kept as they're made; Apply goes back to the list, and only
|
|
6867
|
+
// See results, on the list, applies them to the page.
|
|
6868
|
+
/* @__PURE__ */ jsxs55("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
6869
|
+
/* @__PURE__ */ jsx64(Button, { variant: "link", size: "md", onClick: () => onClearSection(focused.id), className: "px-0", children: "Clear" }),
|
|
6870
|
+
/* @__PURE__ */ jsx64(Button, { variant: "primary", size: "md", onClick: () => setView(null), testIdPrefix: testIdPrefix && `${testIdPrefix}-apply-section`, children: "Apply" })
|
|
6871
|
+
] })
|
|
6872
|
+
) : /* @__PURE__ */ jsxs55("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
6873
|
+
/* @__PURE__ */ jsx64(Button, { variant: "link", size: "md", onClick: onClearAll, className: "px-0", children: "Clear all" }),
|
|
6874
|
+
/* @__PURE__ */ jsxs55("div", { className: "flex items-center gap-2", children: [
|
|
6875
|
+
/* @__PURE__ */ jsx64(Button, { variant: "secondary", size: "md", onClick: onClose, children: "Cancel" }),
|
|
6876
|
+
/* @__PURE__ */ jsx64(
|
|
6877
|
+
Button,
|
|
6878
|
+
{
|
|
6879
|
+
variant: "primary",
|
|
6880
|
+
size: "md",
|
|
6881
|
+
onClick: () => {
|
|
6882
|
+
onApply();
|
|
6883
|
+
onClose();
|
|
6884
|
+
},
|
|
6885
|
+
children: "See results"
|
|
6886
|
+
}
|
|
6887
|
+
)
|
|
6888
|
+
] })
|
|
6889
|
+
] }),
|
|
6890
|
+
children: /* @__PURE__ */ jsxs55("div", { className: "relative -mx-5 overflow-x-clip", children: [
|
|
6891
|
+
/* @__PURE__ */ jsx64(
|
|
6892
|
+
"div",
|
|
6893
|
+
{
|
|
6894
|
+
style: { transform: incoming },
|
|
6895
|
+
className: cn(moving && "transition-transform duration-(--mr-motion-duration-interactive) ease-interactive motion-reduce:transition-none"),
|
|
6896
|
+
children: panel(view)
|
|
6897
|
+
},
|
|
6898
|
+
view ?? "__list"
|
|
6899
|
+
),
|
|
6900
|
+
leaving && /* @__PURE__ */ jsx64(
|
|
6901
|
+
"div",
|
|
6902
|
+
{
|
|
6903
|
+
"aria-hidden": "true",
|
|
6904
|
+
ref: (el) => el?.setAttribute("inert", ""),
|
|
6905
|
+
style: { transform: outgoing, opacity: phase === "start" ? 1 : dir > 0 ? 0.4 : 1 },
|
|
6906
|
+
className: "pointer-events-none absolute inset-x-0 top-0 transition duration-(--mr-motion-duration-interactive) ease-interactive motion-reduce:transition-none",
|
|
6907
|
+
children: panel(leaving.view, false)
|
|
6908
|
+
}
|
|
6909
|
+
)
|
|
6910
|
+
] })
|
|
6911
|
+
}
|
|
6912
|
+
)
|
|
6913
|
+
] });
|
|
6270
6914
|
}
|
|
6271
6915
|
var inUse = (x) => (x.count ?? 0) > 0 || !!x.badge;
|
|
6272
6916
|
function CountBadge({ count }) {
|
|
6273
|
-
return /* @__PURE__ */
|
|
6917
|
+
return /* @__PURE__ */ jsxs55(Badge, { tone: "brandSolid", kind: "count", children: [
|
|
6274
6918
|
count,
|
|
6275
|
-
/* @__PURE__ */
|
|
6919
|
+
/* @__PURE__ */ jsx64("span", { className: "sr-only", children: " selected" })
|
|
6276
6920
|
] });
|
|
6277
6921
|
}
|
|
6278
6922
|
function SectionMark({ section }) {
|
|
6279
|
-
if ((section.count ?? 0) > 0) return /* @__PURE__ */
|
|
6280
|
-
return section.badge ? /* @__PURE__ */
|
|
6923
|
+
if ((section.count ?? 0) > 0) return /* @__PURE__ */ jsx64(CountBadge, { count: section.count });
|
|
6924
|
+
return section.badge ? /* @__PURE__ */ jsx64(Badge, { tone: "brand", children: section.badge }) : null;
|
|
6281
6925
|
}
|
|
6282
6926
|
|
|
6283
6927
|
// src/AllFiltersButton.tsx
|
|
6284
|
-
import { forwardRef as
|
|
6928
|
+
import { forwardRef as forwardRef14 } from "react";
|
|
6285
6929
|
import { SlidersHorizontal } from "lucide-react";
|
|
6286
|
-
import { jsx as
|
|
6287
|
-
var AllFiltersButton =
|
|
6288
|
-
return /* @__PURE__ */
|
|
6930
|
+
import { jsx as jsx65, jsxs as jsxs56 } from "react/jsx-runtime";
|
|
6931
|
+
var AllFiltersButton = forwardRef14(function AllFiltersButton2({ count = 0, open, className, testIdPrefix, ...rest }, ref) {
|
|
6932
|
+
return /* @__PURE__ */ jsxs56(
|
|
6289
6933
|
"button",
|
|
6290
6934
|
{
|
|
6291
6935
|
ref,
|
|
@@ -6297,105 +6941,14 @@ var AllFiltersButton = forwardRef13(function AllFiltersButton2({ count = 0, open
|
|
|
6297
6941
|
className: cn(chipTriggerClass(), className),
|
|
6298
6942
|
...rest,
|
|
6299
6943
|
children: [
|
|
6300
|
-
/* @__PURE__ */
|
|
6301
|
-
/* @__PURE__ */
|
|
6302
|
-
count > 0 && /* @__PURE__ */
|
|
6944
|
+
/* @__PURE__ */ jsx65(SlidersHorizontal, { size: 15, "aria-hidden": "true", className: "text-text-secondary" }),
|
|
6945
|
+
/* @__PURE__ */ jsx65("span", { className: "text-dense font-medium text-text-primary", children: "All filters" }),
|
|
6946
|
+
count > 0 && /* @__PURE__ */ jsx65(Badge, { tone: "brandSolid", kind: "count", children: count })
|
|
6303
6947
|
]
|
|
6304
6948
|
}
|
|
6305
6949
|
);
|
|
6306
6950
|
});
|
|
6307
6951
|
|
|
6308
|
-
// src/Menu.tsx
|
|
6309
|
-
import { forwardRef as forwardRef14 } from "react";
|
|
6310
|
-
import { Slot as Slot2, Slottable } from "@radix-ui/react-slot";
|
|
6311
|
-
import { Check as Check11, ChevronRight as ChevronRight8 } from "lucide-react";
|
|
6312
|
-
import { jsx as jsx63, jsxs as jsxs55 } from "react/jsx-runtime";
|
|
6313
|
-
var ROW_SELECTOR = '[role^="menuitem"]:not([aria-disabled="true"]):not(:disabled)';
|
|
6314
|
-
function moveFocus(e) {
|
|
6315
|
-
const keys = ["ArrowDown", "ArrowUp", "Home", "End"];
|
|
6316
|
-
if (!keys.includes(e.key)) return;
|
|
6317
|
-
const rows = Array.from(e.currentTarget.querySelectorAll(ROW_SELECTOR));
|
|
6318
|
-
if (!rows.length) return;
|
|
6319
|
-
e.preventDefault();
|
|
6320
|
-
const i = rows.indexOf(document.activeElement);
|
|
6321
|
-
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;
|
|
6322
|
-
rows[next].focus();
|
|
6323
|
-
}
|
|
6324
|
-
var Menu = forwardRef14(
|
|
6325
|
-
({ className, testIdPrefix, onKeyDown, children, ...props }, ref) => /* @__PURE__ */ jsx63(
|
|
6326
|
-
"div",
|
|
6327
|
-
{
|
|
6328
|
-
ref,
|
|
6329
|
-
role: "menu",
|
|
6330
|
-
"data-testid": testIdPrefix,
|
|
6331
|
-
onKeyDown: (e) => {
|
|
6332
|
-
moveFocus(e);
|
|
6333
|
-
onKeyDown?.(e);
|
|
6334
|
-
},
|
|
6335
|
-
className: cn("flex flex-col p-1", className),
|
|
6336
|
-
...props,
|
|
6337
|
-
children
|
|
6338
|
-
}
|
|
6339
|
-
)
|
|
6340
|
-
);
|
|
6341
|
-
Menu.displayName = "Menu";
|
|
6342
|
-
var MenuItem = forwardRef14(
|
|
6343
|
-
({ className, testIdPrefix, icon, trailing, description, submenu, checked, danger, disabled, asChild = false, children, ...props }, ref) => {
|
|
6344
|
-
const Comp = asChild ? Slot2 : "button";
|
|
6345
|
-
const radio = checked !== void 0;
|
|
6346
|
-
return /* @__PURE__ */ jsxs55(
|
|
6347
|
-
Comp,
|
|
6348
|
-
{
|
|
6349
|
-
ref,
|
|
6350
|
-
type: asChild ? void 0 : "button",
|
|
6351
|
-
role: radio ? "menuitemradio" : "menuitem",
|
|
6352
|
-
"aria-checked": radio ? checked : void 0,
|
|
6353
|
-
"aria-haspopup": submenu ? "menu" : void 0,
|
|
6354
|
-
"aria-disabled": disabled || void 0,
|
|
6355
|
-
disabled: asChild ? void 0 : disabled,
|
|
6356
|
-
tabIndex: -1,
|
|
6357
|
-
"data-testid": testIdPrefix,
|
|
6358
|
-
className: cn(
|
|
6359
|
-
"flex min-h-9 w-full items-center gap-2.5 rounded-control px-3 py-1.5 text-left text-sm transition-colors",
|
|
6360
|
-
"focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
|
|
6361
|
-
danger ? "text-text-danger" : "text-text-primary",
|
|
6362
|
-
disabled ? "cursor-not-allowed opacity-40" : "hover:bg-subtle focus-visible:bg-subtle",
|
|
6363
|
-
className
|
|
6364
|
-
),
|
|
6365
|
-
...props,
|
|
6366
|
-
children: [
|
|
6367
|
-
icon && /* @__PURE__ */ jsx63("span", { "aria-hidden": "true", className: cn("flex shrink-0", danger ? "text-text-danger" : "text-text-secondary"), children: icon }),
|
|
6368
|
-
asChild ? (
|
|
6369
|
-
// The link's own text lands here; the link becomes the row.
|
|
6370
|
-
/* @__PURE__ */ jsx63(Slottable, { children })
|
|
6371
|
-
) : /* @__PURE__ */ jsxs55("span", { className: "min-w-0 flex-1", children: [
|
|
6372
|
-
/* @__PURE__ */ jsx63("span", { className: "block truncate", children }),
|
|
6373
|
-
description && /* @__PURE__ */ jsx63("span", { className: "block truncate text-xs text-text-tertiary", children: description })
|
|
6374
|
-
] }),
|
|
6375
|
-
trailing && /* @__PURE__ */ jsx63("span", { className: "ml-auto flex shrink-0 items-center text-xs text-text-secondary", children: trailing }),
|
|
6376
|
-
radio && checked && /* @__PURE__ */ jsx63(Check11, { size: 16, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }),
|
|
6377
|
-
submenu && /* @__PURE__ */ jsx63(ChevronRight8, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-secondary" })
|
|
6378
|
-
]
|
|
6379
|
-
}
|
|
6380
|
-
);
|
|
6381
|
-
}
|
|
6382
|
-
);
|
|
6383
|
-
MenuItem.displayName = "MenuItem";
|
|
6384
|
-
function MenuLabel({ className, testIdPrefix, children }) {
|
|
6385
|
-
return /* @__PURE__ */ jsx63(
|
|
6386
|
-
"div",
|
|
6387
|
-
{
|
|
6388
|
-
role: "presentation",
|
|
6389
|
-
"data-testid": testIdPrefix,
|
|
6390
|
-
className: cn("px-3 pb-1 pt-2 text-micro font-semibold uppercase tracking-wide text-text-tertiary", className),
|
|
6391
|
-
children
|
|
6392
|
-
}
|
|
6393
|
-
);
|
|
6394
|
-
}
|
|
6395
|
-
function MenuSeparator({ className, testIdPrefix }) {
|
|
6396
|
-
return /* @__PURE__ */ jsx63("div", { role: "separator", "data-testid": testIdPrefix, className: cn("-mx-1 my-1 border-t border-border-default", className) });
|
|
6397
|
-
}
|
|
6398
|
-
|
|
6399
6952
|
// src/dates.ts
|
|
6400
6953
|
var MONTHS2 = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
6401
6954
|
var MONTHS_LONG = [
|
|
@@ -6507,15 +7060,15 @@ function defaultDateOrder(country) {
|
|
|
6507
7060
|
}
|
|
6508
7061
|
|
|
6509
7062
|
// src/Figure.tsx
|
|
6510
|
-
import { Fragment as
|
|
7063
|
+
import { Fragment as Fragment11, jsx as jsx66, jsxs as jsxs57 } from "react/jsx-runtime";
|
|
6511
7064
|
function Figure({ value, kind = "money", missing, ...opts }) {
|
|
6512
|
-
if (value === null || value === void 0 || Number.isNaN(value)) return /* @__PURE__ */
|
|
7065
|
+
if (value === null || value === void 0 || Number.isNaN(value)) return /* @__PURE__ */ jsx66(NoValue, { reason: missing });
|
|
6513
7066
|
const short = kind === "money" ? formatMoney(value, opts) : formatCount(value, opts);
|
|
6514
7067
|
const full = kind === "money" ? formatMoneyFull(value, opts) : formatCountFull(value);
|
|
6515
|
-
if (short === full) return /* @__PURE__ */
|
|
6516
|
-
return /* @__PURE__ */
|
|
6517
|
-
/* @__PURE__ */
|
|
6518
|
-
/* @__PURE__ */
|
|
7068
|
+
if (short === full) return /* @__PURE__ */ jsx66(Fragment11, { children: short });
|
|
7069
|
+
return /* @__PURE__ */ jsxs57(Tooltip, { label: full, delay: 300, children: [
|
|
7070
|
+
/* @__PURE__ */ jsx66("span", { "aria-hidden": "true", children: short }),
|
|
7071
|
+
/* @__PURE__ */ jsx66("span", { className: "sr-only", children: full })
|
|
6519
7072
|
] });
|
|
6520
7073
|
}
|
|
6521
7074
|
export {
|
|
@@ -6590,6 +7143,7 @@ export {
|
|
|
6590
7143
|
StatStrip,
|
|
6591
7144
|
StatStripSkeleton,
|
|
6592
7145
|
StatTile,
|
|
7146
|
+
StickyBar,
|
|
6593
7147
|
SuggestionChip,
|
|
6594
7148
|
TableLink,
|
|
6595
7149
|
TablePagination,
|