@mediaradar/design-components 0.58.0 → 0.59.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 +262 -119
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +157 -29
- package/dist/index.d.ts +157 -29
- package/dist/index.js +283 -143
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3992,9 +3992,9 @@ function Chip({
|
|
|
3992
3992
|
}
|
|
3993
3993
|
|
|
3994
3994
|
// src/SortButton.tsx
|
|
3995
|
-
import { forwardRef as forwardRef7 } from "react";
|
|
3995
|
+
import { forwardRef as forwardRef7, useImperativeHandle, useRef as useRef13 } from "react";
|
|
3996
3996
|
import { ArrowUp, ArrowDown, ArrowUpDown } from "lucide-react";
|
|
3997
|
-
import { jsx as jsx37, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
3997
|
+
import { Fragment as Fragment4, jsx as jsx37, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
3998
3998
|
var ALIGN = {
|
|
3999
3999
|
left: "justify-start text-left",
|
|
4000
4000
|
center: "justify-center text-center",
|
|
@@ -4009,15 +4009,22 @@ var SortButton = forwardRef7(
|
|
|
4009
4009
|
disabled = false,
|
|
4010
4010
|
sortable = true,
|
|
4011
4011
|
align = "left",
|
|
4012
|
+
description,
|
|
4012
4013
|
className,
|
|
4013
4014
|
testIdPrefix
|
|
4014
4015
|
}, ref) {
|
|
4015
|
-
|
|
4016
|
+
const own = useRef13(null);
|
|
4017
|
+
useImperativeHandle(ref, () => own.current);
|
|
4018
|
+
const text = description ? /* @__PURE__ */ jsx37("span", { className: DESCRIBED, children: label }) : label;
|
|
4019
|
+
if (!sortable) {
|
|
4020
|
+
const plain = /* @__PURE__ */ jsx37("span", { className: cn("inline-flex", ALIGN[align], className), children: text });
|
|
4021
|
+
return description ? /* @__PURE__ */ jsx37(HeaderTip, { description, children: plain }) : plain;
|
|
4022
|
+
}
|
|
4016
4023
|
const active = !disabled && sort.key === sortKey;
|
|
4017
|
-
|
|
4024
|
+
const button = /* @__PURE__ */ jsxs35(
|
|
4018
4025
|
"button",
|
|
4019
4026
|
{
|
|
4020
|
-
ref,
|
|
4027
|
+
ref: own,
|
|
4021
4028
|
type: "button",
|
|
4022
4029
|
disabled,
|
|
4023
4030
|
onClick: () => onSort(sortKey),
|
|
@@ -4044,27 +4051,35 @@ var SortButton = forwardRef7(
|
|
|
4044
4051
|
className
|
|
4045
4052
|
),
|
|
4046
4053
|
children: [
|
|
4047
|
-
|
|
4054
|
+
text,
|
|
4048
4055
|
!disabled && (active ? sort.dir === "asc" ? /* @__PURE__ */ jsx37(ArrowUp, { size: 12, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }) : /* @__PURE__ */ jsx37(ArrowDown, { size: 12, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }) : /* @__PURE__ */ jsx37(
|
|
4049
4056
|
ArrowUpDown,
|
|
4050
4057
|
{
|
|
4051
4058
|
size: 12,
|
|
4052
4059
|
"aria-hidden": "true",
|
|
4053
|
-
className: "shrink-0 text-text-tertiary opacity-
|
|
4060
|
+
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"
|
|
4054
4061
|
}
|
|
4055
4062
|
))
|
|
4056
4063
|
]
|
|
4057
4064
|
}
|
|
4058
4065
|
);
|
|
4066
|
+
return /* @__PURE__ */ jsxs35(Fragment4, { children: [
|
|
4067
|
+
button,
|
|
4068
|
+
description && /* @__PURE__ */ jsx37(Tooltip, { anchorRef: own, label: description, delay: 300, placement: "top" })
|
|
4069
|
+
] });
|
|
4059
4070
|
}
|
|
4060
4071
|
);
|
|
4061
4072
|
SortButton.displayName = "SortButton";
|
|
4073
|
+
var DESCRIBED = "underline decoration-dotted decoration-1 decoration-text-tertiary underline-offset-4";
|
|
4074
|
+
function HeaderTip({ description, children }) {
|
|
4075
|
+
return /* @__PURE__ */ jsx37(Tooltip, { label: description, delay: 300, className: "inline-flex rounded-xs focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-border-focus", children: /* @__PURE__ */ jsx37("span", { tabIndex: 0, children }) });
|
|
4076
|
+
}
|
|
4062
4077
|
|
|
4063
4078
|
// src/tableSort.ts
|
|
4064
|
-
function cycleSort(current, key, firstDir = "desc") {
|
|
4079
|
+
function cycleSort(current, key, firstDir = "desc", fallback = null) {
|
|
4065
4080
|
if (!current || current.key !== key) return { key, dir: firstDir };
|
|
4066
4081
|
if (current.dir === firstDir) return { key, dir: firstDir === "desc" ? "asc" : "desc" };
|
|
4067
|
-
return
|
|
4082
|
+
return fallback && fallback.key === key ? { key, dir: firstDir } : fallback;
|
|
4068
4083
|
}
|
|
4069
4084
|
function sortProp(sort) {
|
|
4070
4085
|
return sort ?? { key: null, dir: "desc" };
|
|
@@ -4171,7 +4186,7 @@ function WorkspaceAvatar({ name, size = "md", className, testIdPrefix }) {
|
|
|
4171
4186
|
}
|
|
4172
4187
|
|
|
4173
4188
|
// src/Toast.tsx
|
|
4174
|
-
import { useEffect as useEffect11, useRef as
|
|
4189
|
+
import { useEffect as useEffect11, useRef as useRef14, useState as useState12 } from "react";
|
|
4175
4190
|
import { createPortal as createPortal6 } from "react-dom";
|
|
4176
4191
|
import { AlertTriangle, Check as Check8 } from "lucide-react";
|
|
4177
4192
|
import { jsx as jsx40, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
@@ -4183,7 +4198,7 @@ var ICON = {
|
|
|
4183
4198
|
function Toast({ message, action, onClose, tone = "neutral", duration, className, testIdPrefix }) {
|
|
4184
4199
|
const ms = duration ?? (action ? 1e4 : 5e3);
|
|
4185
4200
|
const [paused, setPaused] = useState12(false);
|
|
4186
|
-
const closed =
|
|
4201
|
+
const closed = useRef14(false);
|
|
4187
4202
|
useEffect11(() => {
|
|
4188
4203
|
if (paused) return;
|
|
4189
4204
|
const t = window.setTimeout(() => {
|
|
@@ -4377,7 +4392,7 @@ function TablePagination({
|
|
|
4377
4392
|
}
|
|
4378
4393
|
|
|
4379
4394
|
// src/DateRangePicker.tsx
|
|
4380
|
-
import { useEffect as useEffect12, useMemo as useMemo4, useRef as
|
|
4395
|
+
import { useEffect as useEffect12, useMemo as useMemo4, useRef as useRef15, useState as useState13 } from "react";
|
|
4381
4396
|
import { ChevronDown as ChevronDown9 } from "lucide-react";
|
|
4382
4397
|
import { jsx as jsx43, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
4383
4398
|
var MONTH_ABBR = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
@@ -4450,7 +4465,7 @@ function DateRangePicker({
|
|
|
4450
4465
|
const [open, setOpen] = useState13(false);
|
|
4451
4466
|
const [value, setValue] = useState13(defaultValue);
|
|
4452
4467
|
const [draft, setDraft] = useState13(defaultValue);
|
|
4453
|
-
const ref =
|
|
4468
|
+
const ref = useRef15(null);
|
|
4454
4469
|
const [fromMo, setFromMo] = useState13(end.getMonth());
|
|
4455
4470
|
const [fromYr, setFromYr] = useState13(end.getFullYear() - 1);
|
|
4456
4471
|
const [toMo, setToMo] = useState13(end.getMonth());
|
|
@@ -4557,9 +4572,9 @@ function DateRangePicker({
|
|
|
4557
4572
|
}
|
|
4558
4573
|
|
|
4559
4574
|
// src/MultiSelectFilter.tsx
|
|
4560
|
-
import { useCallback as useCallback4, useEffect as useEffect13, useRef as
|
|
4575
|
+
import { useCallback as useCallback4, useEffect as useEffect13, useRef as useRef16, useState as useState14 } from "react";
|
|
4561
4576
|
import { ChevronDown as ChevronDown10, Search as Search5, X as X5 } from "lucide-react";
|
|
4562
|
-
import { Fragment as
|
|
4577
|
+
import { Fragment as Fragment5, jsx as jsx44, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
4563
4578
|
var SEARCH_AFTER = 8;
|
|
4564
4579
|
function MultiSelectFilter({
|
|
4565
4580
|
caption,
|
|
@@ -4596,7 +4611,7 @@ function MultiSelectFilter({
|
|
|
4596
4611
|
const [open, setOpen] = useState14(false);
|
|
4597
4612
|
const [q, setQ] = useState14("");
|
|
4598
4613
|
const [draft, setDraft] = useState14(selected);
|
|
4599
|
-
const ref =
|
|
4614
|
+
const ref = useRef16(null);
|
|
4600
4615
|
const close = useCallback4(() => {
|
|
4601
4616
|
setOpen(false);
|
|
4602
4617
|
setQ("");
|
|
@@ -4703,7 +4718,7 @@ function MultiSelectFilter({
|
|
|
4703
4718
|
"data-testid": testIdPrefix && `${testIdPrefix}-popover`,
|
|
4704
4719
|
role: "dialog",
|
|
4705
4720
|
"aria-label": caption,
|
|
4706
|
-
children: loading ? /* @__PURE__ */ jsx44(MenuLoading, {}) : error ? /* @__PURE__ */ jsx44(MenuError, { onRetry }) : /* @__PURE__ */ jsxs40(
|
|
4721
|
+
children: loading ? /* @__PURE__ */ jsx44(MenuLoading, {}) : error ? /* @__PURE__ */ jsx44(MenuError, { onRetry }) : /* @__PURE__ */ jsxs40(Fragment5, { children: [
|
|
4707
4722
|
showSearch && /* @__PURE__ */ jsx44("div", { className: "border-b border-border-default p-2", children: /* @__PURE__ */ jsxs40("div", { className: "flex h-8 items-center gap-2 rounded-control border border-border-strong bg-input px-2.5 focus-within:outline-2 focus-within:outline-offset-1 focus-within:outline-border-focus", children: [
|
|
4708
4723
|
/* @__PURE__ */ jsx44(Search5, { size: 14, className: "text-text-secondary", "aria-hidden": "true" }),
|
|
4709
4724
|
/* @__PURE__ */ jsx44(
|
|
@@ -4845,10 +4860,10 @@ Toggle.displayName = "Toggle";
|
|
|
4845
4860
|
// src/AISpark.tsx
|
|
4846
4861
|
import { useId as useId6 } from "react";
|
|
4847
4862
|
import { Sparkles } from "lucide-react";
|
|
4848
|
-
import { Fragment as
|
|
4863
|
+
import { Fragment as Fragment6, jsx as jsx46, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
4849
4864
|
function AISpark({ size = 16, className, testIdPrefix }) {
|
|
4850
4865
|
const id = useId6();
|
|
4851
|
-
return /* @__PURE__ */ jsxs41(
|
|
4866
|
+
return /* @__PURE__ */ jsxs41(Fragment6, { children: [
|
|
4852
4867
|
/* @__PURE__ */ jsx46("svg", { width: "0", height: "0", "aria-hidden": "true", style: { position: "absolute" }, children: /* @__PURE__ */ jsx46("defs", { children: /* @__PURE__ */ jsxs41("linearGradient", { id, x1: "0", y1: "0", x2: "1", y2: "1", children: [
|
|
4853
4868
|
/* @__PURE__ */ jsx46("stop", { offset: "0%", stopColor: "var(--mr-color-brand-primary)" }),
|
|
4854
4869
|
/* @__PURE__ */ jsx46("stop", { offset: "100%", stopColor: "var(--mr-color-ai-violet)" })
|
|
@@ -4922,7 +4937,7 @@ function PageHeader({ title, description, actions, meta, back, className, testId
|
|
|
4922
4937
|
}
|
|
4923
4938
|
|
|
4924
4939
|
// src/Modal.tsx
|
|
4925
|
-
import { useEffect as useEffect14, useId as useId7, useRef as
|
|
4940
|
+
import { useEffect as useEffect14, useId as useId7, useRef as useRef17, useState as useState15 } from "react";
|
|
4926
4941
|
import { createPortal as createPortal7 } from "react-dom";
|
|
4927
4942
|
import { X as X6 } from "lucide-react";
|
|
4928
4943
|
import { jsx as jsx50, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
@@ -4939,8 +4954,8 @@ var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:
|
|
|
4939
4954
|
function Modal({ open, onClose, title, description, size = "md", footer, children, className, testIdPrefix }) {
|
|
4940
4955
|
const titleId = useId7();
|
|
4941
4956
|
const descId = useId7();
|
|
4942
|
-
const panel =
|
|
4943
|
-
const close =
|
|
4957
|
+
const panel = useRef17(null);
|
|
4958
|
+
const close = useRef17(onClose);
|
|
4944
4959
|
close.current = onClose;
|
|
4945
4960
|
const [mounted, setMounted] = useState15(open);
|
|
4946
4961
|
const [shown, setShown] = useState15(false);
|
|
@@ -5120,7 +5135,7 @@ var TextField = forwardRef9(
|
|
|
5120
5135
|
TextField.displayName = "TextField";
|
|
5121
5136
|
|
|
5122
5137
|
// src/Drawer.tsx
|
|
5123
|
-
import { useEffect as useEffect15, useId as useId9, useRef as
|
|
5138
|
+
import { useEffect as useEffect15, useId as useId9, useRef as useRef18, useState as useState16 } from "react";
|
|
5124
5139
|
import { createPortal as createPortal8 } from "react-dom";
|
|
5125
5140
|
import { X as X7 } from "lucide-react";
|
|
5126
5141
|
import { jsx as jsx53, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
@@ -5134,8 +5149,8 @@ var FOCUSABLE2 = 'a[href], button:not([disabled]), input:not([disabled]), select
|
|
|
5134
5149
|
function Drawer({ open, onClose, title, description, size = "sm", footer, children, className, testIdPrefix }) {
|
|
5135
5150
|
const titleId = useId9();
|
|
5136
5151
|
const descId = useId9();
|
|
5137
|
-
const panel =
|
|
5138
|
-
const close =
|
|
5152
|
+
const panel = useRef18(null);
|
|
5153
|
+
const close = useRef18(onClose);
|
|
5139
5154
|
close.current = onClose;
|
|
5140
5155
|
const [mounted, setMounted] = useState16(open);
|
|
5141
5156
|
const [shown, setShown] = useState16(false);
|
|
@@ -5243,12 +5258,90 @@ function Drawer({ open, onClose, title, description, size = "sm", footer, childr
|
|
|
5243
5258
|
}
|
|
5244
5259
|
|
|
5245
5260
|
// src/DataTable.tsx
|
|
5246
|
-
import { useId as useId10 } from "react";
|
|
5261
|
+
import { Fragment as Fragment7, useEffect as useEffect16, useId as useId10, useState as useState17 } from "react";
|
|
5262
|
+
import { ChevronRight as ChevronRight6 } from "lucide-react";
|
|
5263
|
+
|
|
5264
|
+
// src/numbers.ts
|
|
5265
|
+
var US = { units: ["K", "M", "B", "T"] };
|
|
5266
|
+
var STYLES = {
|
|
5267
|
+
"en-US": US,
|
|
5268
|
+
"en-CA": US,
|
|
5269
|
+
"en-GB": { units: ["k", "m", "bn", "tn"] }
|
|
5270
|
+
};
|
|
5271
|
+
var styleFor = (language) => STYLES[language ?? "en-US"] ?? US;
|
|
5272
|
+
var NO_VALUE = "\u2014";
|
|
5273
|
+
var MINUS = "\u2212";
|
|
5274
|
+
var SHORTEN_FROM = 1e4;
|
|
5275
|
+
var isMissing = (v) => v === null || v === void 0 || Number.isNaN(v);
|
|
5276
|
+
var withCommas = (n) => Math.round(n).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
5277
|
+
function shortAbs(abs, style) {
|
|
5278
|
+
if (abs < SHORTEN_FROM) return withCommas(abs);
|
|
5279
|
+
let tier = Math.min(Math.floor(Math.log10(abs) / 3), 4);
|
|
5280
|
+
let scaled = Math.round(abs / 1e3 ** tier * 10) / 10;
|
|
5281
|
+
if (scaled >= 1e3 && tier < 4) {
|
|
5282
|
+
tier += 1;
|
|
5283
|
+
scaled = Math.round(abs / 1e3 ** tier * 10) / 10;
|
|
5284
|
+
}
|
|
5285
|
+
const text = Number.isInteger(scaled) ? withCommas(scaled) : scaled.toFixed(1);
|
|
5286
|
+
return `${text}${style.units[tier - 1]}`;
|
|
5287
|
+
}
|
|
5288
|
+
function symbol(opts) {
|
|
5289
|
+
const currency = opts.currency ?? "USD";
|
|
5290
|
+
if (currency === "GBP") return "\xA3";
|
|
5291
|
+
if (currency === "EUR") return "\u20AC";
|
|
5292
|
+
if (opts.mixedDollars) return currency === "CAD" ? "CA$" : "US$";
|
|
5293
|
+
return "$";
|
|
5294
|
+
}
|
|
5295
|
+
var sign = (v) => v < 0 ? MINUS : "";
|
|
5296
|
+
function formatCount(value, opts = {}) {
|
|
5297
|
+
if (isMissing(value)) return NO_VALUE;
|
|
5298
|
+
return sign(value) + shortAbs(Math.abs(value), styleFor(opts.language));
|
|
5299
|
+
}
|
|
5300
|
+
function formatCountFull(value) {
|
|
5301
|
+
if (isMissing(value)) return NO_VALUE;
|
|
5302
|
+
return sign(value) + withCommas(Math.abs(value));
|
|
5303
|
+
}
|
|
5304
|
+
function formatMoney(value, opts = {}) {
|
|
5305
|
+
if (isMissing(value)) return NO_VALUE;
|
|
5306
|
+
return sign(value) + symbol(opts) + shortAbs(Math.abs(value), styleFor(opts.language));
|
|
5307
|
+
}
|
|
5308
|
+
function formatMoneyFull(value, opts = {}) {
|
|
5309
|
+
if (isMissing(value)) return NO_VALUE;
|
|
5310
|
+
return sign(value) + symbol(opts) + withCommas(Math.abs(value));
|
|
5311
|
+
}
|
|
5312
|
+
function formatPercent(value, _opts = {}) {
|
|
5313
|
+
if (isMissing(value)) return NO_VALUE;
|
|
5314
|
+
const abs = Math.abs(value);
|
|
5315
|
+
if (abs > 0 && abs < 0.05) return `${value < 0 ? MINUS : ""}<0.1%`;
|
|
5316
|
+
const text = (Math.round(abs * 10) / 10).toFixed(1);
|
|
5317
|
+
return text === "0.0" ? "0.0%" : `${sign(value)}${text}%`;
|
|
5318
|
+
}
|
|
5319
|
+
|
|
5320
|
+
// src/DataTable.tsx
|
|
5247
5321
|
import { jsx as jsx54, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
5248
5322
|
var WIDTH3 = { fill: "", sm: "w-24", md: "w-36", lg: "w-48" };
|
|
5249
5323
|
var MAX_H = { sm: "max-h-80", md: "max-h-120", lg: "max-h-160" };
|
|
5250
5324
|
var HEAD_PAD = { default: "px-4 py-3", compact: "px-3 py-2" };
|
|
5251
5325
|
var CELL_PAD = { default: "px-4 py-3.5", compact: "px-3 py-2" };
|
|
5326
|
+
var OWN_CLICK = "a, button, input, select, textarea, label, summary, [role='button'], [role='checkbox'], [role='menuitem'], [role='switch'], [role='tab'], [contenteditable='true']";
|
|
5327
|
+
function NoValue({ reason = "No data" }) {
|
|
5328
|
+
return /* @__PURE__ */ jsxs48(Tooltip, { label: reason, delay: 300, className: "text-text-tertiary", children: [
|
|
5329
|
+
/* @__PURE__ */ jsx54("span", { "aria-hidden": "true", children: NO_VALUE }),
|
|
5330
|
+
/* @__PURE__ */ jsx54("span", { className: "sr-only", children: reason })
|
|
5331
|
+
] });
|
|
5332
|
+
}
|
|
5333
|
+
function TableLink({ className, ...props }) {
|
|
5334
|
+
return /* @__PURE__ */ jsx54(
|
|
5335
|
+
"a",
|
|
5336
|
+
{
|
|
5337
|
+
...props,
|
|
5338
|
+
className: cn(
|
|
5339
|
+
"rounded-xs text-inherit decoration-1 underline-offset-2 hover:underline focus-visible:underline focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-border-focus",
|
|
5340
|
+
className
|
|
5341
|
+
)
|
|
5342
|
+
}
|
|
5343
|
+
);
|
|
5344
|
+
}
|
|
5252
5345
|
function DataTable({
|
|
5253
5346
|
columns,
|
|
5254
5347
|
rows,
|
|
@@ -5256,8 +5349,14 @@ function DataTable({
|
|
|
5256
5349
|
title,
|
|
5257
5350
|
subtitle,
|
|
5258
5351
|
action,
|
|
5352
|
+
variant = "default",
|
|
5353
|
+
titleAs = "h2",
|
|
5259
5354
|
sort = null,
|
|
5260
5355
|
onSortChange,
|
|
5356
|
+
defaultSort = null,
|
|
5357
|
+
renderExpanded,
|
|
5358
|
+
canExpand,
|
|
5359
|
+
rowLabel,
|
|
5261
5360
|
density = "default",
|
|
5262
5361
|
loading = false,
|
|
5263
5362
|
loadingRows = 5,
|
|
@@ -5271,24 +5370,48 @@ function DataTable({
|
|
|
5271
5370
|
const titleId = useId10();
|
|
5272
5371
|
const head = HEAD_PAD[density];
|
|
5273
5372
|
const pad2 = CELL_PAD[density];
|
|
5274
|
-
const
|
|
5275
|
-
const
|
|
5373
|
+
const right = (c) => c.numeric || c.rank;
|
|
5374
|
+
const align = (c) => right(c) ? "text-right" : "text-left";
|
|
5375
|
+
const width = (c) => c.rank ? "w-12" : WIDTH3[c.width ?? (c.numeric ? "md" : "fill")];
|
|
5376
|
+
const shown = sort ?? defaultSort;
|
|
5276
5377
|
const onSort = (key) => {
|
|
5277
5378
|
const col = columns.find((c) => c.key === key);
|
|
5278
|
-
onSortChange?.(cycleSort(
|
|
5379
|
+
onSortChange?.(cycleSort(shown, key, col?.firstDir ?? (right(col) ? "desc" : "asc"), defaultSort));
|
|
5279
5380
|
};
|
|
5280
|
-
|
|
5381
|
+
const [open, setOpen] = useState17(() => /* @__PURE__ */ new Set());
|
|
5382
|
+
const visibleKeys = rows.map(rowKey).join("|");
|
|
5383
|
+
useEffect16(() => setOpen(/* @__PURE__ */ new Set()), [shown?.key, shown?.dir, visibleKeys]);
|
|
5384
|
+
const expandable = (row) => !!renderExpanded && (canExpand ? canExpand(row) : true);
|
|
5385
|
+
const anyExpandable = !!renderExpanded && rows.some(expandable);
|
|
5386
|
+
const toggle = (key) => setOpen((prev) => {
|
|
5387
|
+
const next = new Set(prev);
|
|
5388
|
+
if (next.has(key)) next.delete(key);
|
|
5389
|
+
else next.add(key);
|
|
5390
|
+
return next;
|
|
5391
|
+
});
|
|
5392
|
+
const onRowClick = (e, key) => {
|
|
5393
|
+
if (e.target.closest(OWN_CLICK)) return;
|
|
5394
|
+
if (window.getSelection?.()?.toString()) return;
|
|
5395
|
+
toggle(key);
|
|
5396
|
+
};
|
|
5397
|
+
const span = columns.length + (anyExpandable ? 1 : 0);
|
|
5398
|
+
const renderCell = (c, row) => {
|
|
5399
|
+
const v = c.cell(row);
|
|
5400
|
+
return v === null || v === void 0 || v === "" ? /* @__PURE__ */ jsx54(NoValue, { reason: c.missing }) : v;
|
|
5401
|
+
};
|
|
5402
|
+
const inside = variant === "chart";
|
|
5403
|
+
const frame = /* @__PURE__ */ jsxs48(
|
|
5281
5404
|
"div",
|
|
5282
5405
|
{
|
|
5283
|
-
className: cn("flex w-full flex-col overflow-hidden rounded-card border border-border-default bg-surface", className),
|
|
5406
|
+
className: cn("flex w-full flex-col overflow-hidden rounded-card border border-border-default bg-surface", !(title && !inside) && className),
|
|
5284
5407
|
"data-testid": testIdPrefix,
|
|
5285
5408
|
children: [
|
|
5286
|
-
title && /* @__PURE__ */ jsxs48("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
|
|
5409
|
+
title && inside && /* @__PURE__ */ jsxs48("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
|
|
5287
5410
|
/* @__PURE__ */ jsxs48("div", { className: "min-w-0", children: [
|
|
5288
|
-
/* @__PURE__ */ jsx54("h3", { id: titleId, className: "text-
|
|
5289
|
-
subtitle && /* @__PURE__ */ jsx54("p", { className: "mt-0.5 text-xs text-text-tertiary", children: subtitle })
|
|
5411
|
+
/* @__PURE__ */ jsx54("h3", { id: titleId, className: "text-panel-title font-semibold text-text-primary", children: title }),
|
|
5412
|
+
subtitle && /* @__PURE__ */ jsx54("p", { className: "mt-0.5 text-xs leading-snug text-text-tertiary", children: subtitle })
|
|
5290
5413
|
] }),
|
|
5291
|
-
action && /* @__PURE__ */ jsx54("div", { className: "shrink-0", children: action })
|
|
5414
|
+
action && /* @__PURE__ */ jsx54("div", { className: "shrink-0 text-text-tertiary", children: action })
|
|
5292
5415
|
] }),
|
|
5293
5416
|
/* @__PURE__ */ jsx54("div", { className: cn("overflow-x-auto", maxHeight && cn("overflow-y-auto", MAX_H[maxHeight])), children: /* @__PURE__ */ jsxs48(
|
|
5294
5417
|
"table",
|
|
@@ -5298,42 +5421,94 @@ function DataTable({
|
|
|
5298
5421
|
"aria-busy": loading || void 0,
|
|
5299
5422
|
className: "w-full border-collapse text-left",
|
|
5300
5423
|
children: [
|
|
5301
|
-
/* @__PURE__ */ jsx54("thead", { className: cn(maxHeight && "sticky top-0 z-10"), children: /* @__PURE__ */
|
|
5302
|
-
"th",
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5424
|
+
/* @__PURE__ */ jsx54("thead", { className: cn(maxHeight && "sticky top-0 z-10"), children: /* @__PURE__ */ jsxs48("tr", { className: "bg-subtle text-micro font-semibold uppercase tracking-wider text-text-secondary", children: [
|
|
5425
|
+
anyExpandable && /* @__PURE__ */ jsx54("th", { scope: "col", className: cn("w-10 border-b border-border-default", head), children: /* @__PURE__ */ jsx54("span", { className: "sr-only", children: "Details" }) }),
|
|
5426
|
+
columns.map((c) => /* @__PURE__ */ jsx54(
|
|
5427
|
+
"th",
|
|
5428
|
+
{
|
|
5429
|
+
scope: "col",
|
|
5430
|
+
"aria-sort": c.sortable ? ariaSortFor(shown, c.key) : void 0,
|
|
5431
|
+
className: cn("group/head whitespace-nowrap border-b border-border-default font-semibold", head, align(c), width(c)),
|
|
5432
|
+
children: c.sortable && onSortChange ? /* @__PURE__ */ jsx54(
|
|
5433
|
+
SortButton,
|
|
5434
|
+
{
|
|
5435
|
+
label: c.label,
|
|
5436
|
+
sortKey: c.key,
|
|
5437
|
+
align: right(c) ? "right" : "left",
|
|
5438
|
+
sort: sortProp(shown),
|
|
5439
|
+
onSort,
|
|
5440
|
+
description: c.info,
|
|
5441
|
+
testIdPrefix
|
|
5442
|
+
}
|
|
5443
|
+
) : c.info ? /* @__PURE__ */ jsx54(SortButton, { label: c.label, sortKey: c.key, sortable: false, sort: sortProp(shown), onSort: () => {
|
|
5444
|
+
}, description: c.info, align: right(c) ? "right" : "left" }) : c.label
|
|
5445
|
+
},
|
|
5446
|
+
c.key
|
|
5447
|
+
))
|
|
5448
|
+
] }) }),
|
|
5449
|
+
/* @__PURE__ */ jsx54("tbody", { className: "text-dense text-text-primary", children: loading ? Array.from({ length: loadingRows }, (_, i) => /* @__PURE__ */ jsxs48("tr", { "aria-hidden": "true", className: "[&:last-child>td]:border-b-0", children: [
|
|
5450
|
+
anyExpandable && /* @__PURE__ */ jsx54("td", { className: cn("border-b border-border-default", pad2) }),
|
|
5451
|
+
columns.map((c) => /* @__PURE__ */ jsx54("td", { className: cn("border-b border-border-default", pad2, align(c)), children: /* @__PURE__ */ jsx54(
|
|
5452
|
+
"span",
|
|
5453
|
+
{
|
|
5454
|
+
className: cn(
|
|
5455
|
+
"inline-block h-3 animate-pulse rounded-full bg-subtle",
|
|
5456
|
+
c.numeric ? "w-12" : "w-2/3"
|
|
5457
|
+
)
|
|
5458
|
+
}
|
|
5459
|
+
) }, c.key))
|
|
5460
|
+
] }, i)) : rows.length === 0 ? /* @__PURE__ */ jsx54("tr", { children: /* @__PURE__ */ jsx54("td", { colSpan: span, className: "px-6 py-12", children: empty ?? /* @__PURE__ */ jsx54(NoResultsEmptyState, {}) }) }) : rows.map((row, index) => {
|
|
5461
|
+
const key = rowKey(row);
|
|
5462
|
+
const canOpen = expandable(row);
|
|
5463
|
+
const isOpen = canOpen && open.has(key);
|
|
5464
|
+
const panelId = `${titleId}-row-${index}`;
|
|
5465
|
+
return /* @__PURE__ */ jsxs48(Fragment7, { children: [
|
|
5466
|
+
/* @__PURE__ */ jsxs48(
|
|
5467
|
+
"tr",
|
|
5309
5468
|
{
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5469
|
+
onClick: canOpen ? (e) => onRowClick(e, key) : void 0,
|
|
5470
|
+
className: cn("hover:bg-subtle [&:last-child>td]:border-b-0", canOpen && "cursor-pointer", isOpen && "bg-subtle"),
|
|
5471
|
+
children: [
|
|
5472
|
+
anyExpandable && /* @__PURE__ */ jsx54("td", { className: cn("border-b border-border-default pr-0", pad2, isOpen && "border-b-0"), children: canOpen && /* @__PURE__ */ jsx54(
|
|
5473
|
+
"button",
|
|
5474
|
+
{
|
|
5475
|
+
type: "button",
|
|
5476
|
+
"aria-expanded": isOpen,
|
|
5477
|
+
"aria-controls": isOpen ? panelId : void 0,
|
|
5478
|
+
"aria-label": `${isOpen ? "Hide" : "Show"} details${rowLabel ? ` for ${rowLabel(row)}` : ""}`,
|
|
5479
|
+
onClick: () => toggle(key),
|
|
5480
|
+
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",
|
|
5481
|
+
children: /* @__PURE__ */ jsx54(
|
|
5482
|
+
ChevronRight6,
|
|
5483
|
+
{
|
|
5484
|
+
size: 16,
|
|
5485
|
+
"aria-hidden": "true",
|
|
5486
|
+
className: cn("transition-transform motion-reduce:transition-none", isOpen && "rotate-90")
|
|
5487
|
+
}
|
|
5488
|
+
)
|
|
5489
|
+
}
|
|
5490
|
+
) }),
|
|
5491
|
+
columns.map((c) => /* @__PURE__ */ jsx54(
|
|
5492
|
+
"td",
|
|
5493
|
+
{
|
|
5494
|
+
className: cn(
|
|
5495
|
+
"border-b border-border-default",
|
|
5496
|
+
pad2,
|
|
5497
|
+
align(c),
|
|
5498
|
+
right(c) && "tabular-nums",
|
|
5499
|
+
c.rank && "text-text-tertiary",
|
|
5500
|
+
isOpen && "border-b-0"
|
|
5501
|
+
),
|
|
5502
|
+
children: renderCell(c, row)
|
|
5503
|
+
},
|
|
5504
|
+
c.key
|
|
5505
|
+
))
|
|
5506
|
+
]
|
|
5316
5507
|
}
|
|
5317
|
-
)
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
/* @__PURE__ */ jsx54("tbody", { className: "text-dense text-text-primary", children: loading ? Array.from({ length: loadingRows }, (_, i) => /* @__PURE__ */ jsx54("tr", { "aria-hidden": "true", className: "[&:last-child>td]:border-b-0", children: columns.map((c) => /* @__PURE__ */ jsx54("td", { className: cn("border-b border-border-default", pad2, align(c)), children: /* @__PURE__ */ jsx54(
|
|
5322
|
-
"span",
|
|
5323
|
-
{
|
|
5324
|
-
className: cn(
|
|
5325
|
-
"inline-block h-3 animate-pulse rounded-full bg-subtle",
|
|
5326
|
-
c.numeric ? "w-12" : "w-2/3"
|
|
5327
|
-
)
|
|
5328
|
-
}
|
|
5329
|
-
) }, c.key)) }, i)) : rows.length === 0 ? /* @__PURE__ */ jsx54("tr", { children: /* @__PURE__ */ jsx54("td", { colSpan: columns.length, className: "px-6 py-12", children: empty ?? /* @__PURE__ */ jsx54(NoResultsEmptyState, {}) }) }) : rows.map((row) => /* @__PURE__ */ jsx54("tr", { className: "hover:bg-subtle [&:last-child>td]:border-b-0", children: columns.map((c) => /* @__PURE__ */ jsx54(
|
|
5330
|
-
"td",
|
|
5331
|
-
{
|
|
5332
|
-
className: cn("border-b border-border-default", pad2, align(c), c.numeric && "tabular-nums"),
|
|
5333
|
-
children: c.cell(row)
|
|
5334
|
-
},
|
|
5335
|
-
c.key
|
|
5336
|
-
)) }, rowKey(row))) })
|
|
5508
|
+
),
|
|
5509
|
+
isOpen && /* @__PURE__ */ jsx54("tr", { className: "[&:last-child>td]:border-b-0", children: /* @__PURE__ */ jsx54("td", { id: panelId, colSpan: span, className: "border-b border-border-default bg-subtle px-4 pb-4 pl-14", children: renderExpanded(row) }) })
|
|
5510
|
+
] }, key);
|
|
5511
|
+
}) })
|
|
5337
5512
|
]
|
|
5338
5513
|
}
|
|
5339
5514
|
) }),
|
|
@@ -5341,6 +5516,11 @@ function DataTable({
|
|
|
5341
5516
|
]
|
|
5342
5517
|
}
|
|
5343
5518
|
);
|
|
5519
|
+
if (!title || inside) return frame;
|
|
5520
|
+
return /* @__PURE__ */ jsxs48("section", { "aria-labelledby": titleId, className: cn("flex w-full flex-col gap-3", className), children: [
|
|
5521
|
+
/* @__PURE__ */ jsx54(SectionHeading, { id: titleId, as: titleAs, title, description: subtitle, actions: action }),
|
|
5522
|
+
frame
|
|
5523
|
+
] });
|
|
5344
5524
|
}
|
|
5345
5525
|
|
|
5346
5526
|
// src/MediaLabel.tsx
|
|
@@ -5422,14 +5602,14 @@ var ToggleChip = forwardRef11(function ToggleChip2({ selected, onChange, childre
|
|
|
5422
5602
|
ToggleChip.displayName = "ToggleChip";
|
|
5423
5603
|
|
|
5424
5604
|
// src/CopyButton.tsx
|
|
5425
|
-
import { forwardRef as forwardRef12, useEffect as
|
|
5605
|
+
import { forwardRef as forwardRef12, useEffect as useEffect17, useRef as useRef19, useState as useState18 } from "react";
|
|
5426
5606
|
import { Check as Check10, Copy } from "lucide-react";
|
|
5427
5607
|
import { jsx as jsx58, jsxs as jsxs50 } from "react/jsx-runtime";
|
|
5428
5608
|
var CONFIRM_MS = 2e3;
|
|
5429
5609
|
var CopyButton = forwardRef12(function CopyButton2({ value, label, "aria-label": ariaLabel, size = "xs", className, testIdPrefix }, ref) {
|
|
5430
|
-
const [copied, setCopied] =
|
|
5431
|
-
const timer =
|
|
5432
|
-
|
|
5610
|
+
const [copied, setCopied] = useState18(false);
|
|
5611
|
+
const timer = useRef19(void 0);
|
|
5612
|
+
useEffect17(() => () => clearTimeout(timer.current), []);
|
|
5433
5613
|
const copy = async () => {
|
|
5434
5614
|
try {
|
|
5435
5615
|
await navigator.clipboard.writeText(typeof value === "function" ? value() : value);
|
|
@@ -5512,8 +5692,8 @@ function InlineMessage({ tone = "info", title, children, actions, onDismiss, cla
|
|
|
5512
5692
|
}
|
|
5513
5693
|
|
|
5514
5694
|
// src/FilterDrawer.tsx
|
|
5515
|
-
import { useEffect as
|
|
5516
|
-
import { ChevronLeft as ChevronLeft5, ChevronRight as
|
|
5695
|
+
import { useEffect as useEffect18, useLayoutEffect as useLayoutEffect6, useRef as useRef20, useState as useState19 } from "react";
|
|
5696
|
+
import { ChevronLeft as ChevronLeft5, ChevronRight as ChevronRight7 } from "lucide-react";
|
|
5517
5697
|
import { jsx as jsx60, jsxs as jsxs52 } from "react/jsx-runtime";
|
|
5518
5698
|
var SLIDE_MS = 200;
|
|
5519
5699
|
function reducedMotion() {
|
|
@@ -5532,10 +5712,10 @@ function FilterDrawer({
|
|
|
5532
5712
|
size = "sm",
|
|
5533
5713
|
testIdPrefix
|
|
5534
5714
|
}) {
|
|
5535
|
-
const [view, setViewState] =
|
|
5536
|
-
const [leaving, setLeaving] =
|
|
5537
|
-
const [phase, setPhase] =
|
|
5538
|
-
const [wasOpen, setWasOpen] =
|
|
5715
|
+
const [view, setViewState] = useState19(focus);
|
|
5716
|
+
const [leaving, setLeaving] = useState19(null);
|
|
5717
|
+
const [phase, setPhase] = useState19("run");
|
|
5718
|
+
const [wasOpen, setWasOpen] = useState19(open);
|
|
5539
5719
|
if (open !== wasOpen) {
|
|
5540
5720
|
setWasOpen(open);
|
|
5541
5721
|
if (open) {
|
|
@@ -5555,15 +5735,15 @@ function FilterDrawer({
|
|
|
5555
5735
|
const raf = requestAnimationFrame(() => requestAnimationFrame(() => setPhase("run")));
|
|
5556
5736
|
return () => cancelAnimationFrame(raf);
|
|
5557
5737
|
}, [phase]);
|
|
5558
|
-
|
|
5738
|
+
useEffect18(() => {
|
|
5559
5739
|
if (!leaving || phase !== "run") return;
|
|
5560
5740
|
const t = setTimeout(() => setLeaving(null), SLIDE_MS);
|
|
5561
5741
|
return () => clearTimeout(t);
|
|
5562
5742
|
}, [leaving, phase]);
|
|
5563
|
-
const backRef =
|
|
5564
|
-
const rowRefs =
|
|
5565
|
-
const lastView =
|
|
5566
|
-
|
|
5743
|
+
const backRef = useRef20(null);
|
|
5744
|
+
const rowRefs = useRef20(/* @__PURE__ */ new Map());
|
|
5745
|
+
const lastView = useRef20(null);
|
|
5746
|
+
useEffect18(() => {
|
|
5567
5747
|
if (!open) return;
|
|
5568
5748
|
if (view) backRef.current?.focus();
|
|
5569
5749
|
else if (lastView.current) rowRefs.current.get(lastView.current)?.focus();
|
|
@@ -5599,7 +5779,7 @@ function FilterDrawer({
|
|
|
5599
5779
|
),
|
|
5600
5780
|
/* @__PURE__ */ jsx60("span", { className: "flex-1 text-sm font-medium text-text-primary", children: x.label }),
|
|
5601
5781
|
x.badge && /* @__PURE__ */ jsx60(Badge, { tone: "brand", children: x.badge }),
|
|
5602
|
-
/* @__PURE__ */ jsx60(
|
|
5782
|
+
/* @__PURE__ */ jsx60(ChevronRight7, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-secondary" })
|
|
5603
5783
|
]
|
|
5604
5784
|
}
|
|
5605
5785
|
) }, x.id)) });
|
|
@@ -5704,8 +5884,8 @@ var AllFiltersButton = forwardRef13(function AllFiltersButton2({ count = 0, open
|
|
|
5704
5884
|
// src/Menu.tsx
|
|
5705
5885
|
import { forwardRef as forwardRef14 } from "react";
|
|
5706
5886
|
import { Slot as Slot2, Slottable } from "@radix-ui/react-slot";
|
|
5707
|
-
import { Check as Check11, ChevronRight as
|
|
5708
|
-
import { Fragment as
|
|
5887
|
+
import { Check as Check11, ChevronRight as ChevronRight8 } from "lucide-react";
|
|
5888
|
+
import { Fragment as Fragment8, jsx as jsx62, jsxs as jsxs54 } from "react/jsx-runtime";
|
|
5709
5889
|
var ROW_SELECTOR = '[role^="menuitem"]:not([aria-disabled="true"]):not(:disabled)';
|
|
5710
5890
|
function moveFocus(e) {
|
|
5711
5891
|
const keys = ["ArrowDown", "ArrowUp", "Home", "End"];
|
|
@@ -5739,7 +5919,7 @@ var MenuItem = forwardRef14(
|
|
|
5739
5919
|
({ className, testIdPrefix, icon, trailing, description, submenu, checked, danger, disabled, asChild = false, children, ...props }, ref) => {
|
|
5740
5920
|
const Comp = asChild ? Slot2 : "button";
|
|
5741
5921
|
const radio = checked !== void 0;
|
|
5742
|
-
const body = /* @__PURE__ */ jsxs54(
|
|
5922
|
+
const body = /* @__PURE__ */ jsxs54(Fragment8, { children: [
|
|
5743
5923
|
icon && /* @__PURE__ */ jsx62("span", { "aria-hidden": "true", className: cn("flex shrink-0", danger ? "text-text-danger" : "text-text-secondary"), children: icon }),
|
|
5744
5924
|
asChild ? (
|
|
5745
5925
|
// The link's own text lands here; the link becomes the row.
|
|
@@ -5750,7 +5930,7 @@ var MenuItem = forwardRef14(
|
|
|
5750
5930
|
] }),
|
|
5751
5931
|
trailing && /* @__PURE__ */ jsx62("span", { className: "ml-auto flex shrink-0 items-center text-xs text-text-secondary", children: trailing }),
|
|
5752
5932
|
radio && checked && /* @__PURE__ */ jsx62(Check11, { size: 16, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }),
|
|
5753
|
-
submenu && /* @__PURE__ */ jsx62(
|
|
5933
|
+
submenu && /* @__PURE__ */ jsx62(ChevronRight8, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-secondary" })
|
|
5754
5934
|
] });
|
|
5755
5935
|
return /* @__PURE__ */ jsx62(
|
|
5756
5936
|
Comp,
|
|
@@ -5903,60 +6083,17 @@ function defaultDateOrder(country) {
|
|
|
5903
6083
|
return c === "US" || c === "CA" || c === "" ? "mdy" : "dmy";
|
|
5904
6084
|
}
|
|
5905
6085
|
|
|
5906
|
-
// src/
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
"
|
|
5911
|
-
|
|
5912
|
-
};
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
var isMissing = (v) => v === null || v === void 0 || Number.isNaN(v);
|
|
5918
|
-
var withCommas = (n) => Math.round(n).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
5919
|
-
function shortAbs(abs, style) {
|
|
5920
|
-
if (abs < SHORTEN_FROM) return withCommas(abs);
|
|
5921
|
-
let tier = Math.min(Math.floor(Math.log10(abs) / 3), 4);
|
|
5922
|
-
let scaled = Math.round(abs / 1e3 ** tier * 10) / 10;
|
|
5923
|
-
if (scaled >= 1e3 && tier < 4) {
|
|
5924
|
-
tier += 1;
|
|
5925
|
-
scaled = Math.round(abs / 1e3 ** tier * 10) / 10;
|
|
5926
|
-
}
|
|
5927
|
-
const text = Number.isInteger(scaled) ? withCommas(scaled) : scaled.toFixed(1);
|
|
5928
|
-
return `${text}${style.units[tier - 1]}`;
|
|
5929
|
-
}
|
|
5930
|
-
function symbol(opts) {
|
|
5931
|
-
const currency = opts.currency ?? "USD";
|
|
5932
|
-
if (currency === "GBP") return "\xA3";
|
|
5933
|
-
if (currency === "EUR") return "\u20AC";
|
|
5934
|
-
if (opts.mixedDollars) return currency === "CAD" ? "CA$" : "US$";
|
|
5935
|
-
return "$";
|
|
5936
|
-
}
|
|
5937
|
-
var sign = (v) => v < 0 ? MINUS : "";
|
|
5938
|
-
function formatCount(value, opts = {}) {
|
|
5939
|
-
if (isMissing(value)) return NO_VALUE;
|
|
5940
|
-
return sign(value) + shortAbs(Math.abs(value), styleFor(opts.language));
|
|
5941
|
-
}
|
|
5942
|
-
function formatCountFull(value) {
|
|
5943
|
-
if (isMissing(value)) return NO_VALUE;
|
|
5944
|
-
return sign(value) + withCommas(Math.abs(value));
|
|
5945
|
-
}
|
|
5946
|
-
function formatMoney(value, opts = {}) {
|
|
5947
|
-
if (isMissing(value)) return NO_VALUE;
|
|
5948
|
-
return sign(value) + symbol(opts) + shortAbs(Math.abs(value), styleFor(opts.language));
|
|
5949
|
-
}
|
|
5950
|
-
function formatMoneyFull(value, opts = {}) {
|
|
5951
|
-
if (isMissing(value)) return NO_VALUE;
|
|
5952
|
-
return sign(value) + symbol(opts) + withCommas(Math.abs(value));
|
|
5953
|
-
}
|
|
5954
|
-
function formatPercent(value, _opts = {}) {
|
|
5955
|
-
if (isMissing(value)) return NO_VALUE;
|
|
5956
|
-
const abs = Math.abs(value);
|
|
5957
|
-
if (abs > 0 && abs < 0.05) return `${value < 0 ? MINUS : ""}<0.1%`;
|
|
5958
|
-
const text = (Math.round(abs * 10) / 10).toFixed(1);
|
|
5959
|
-
return text === "0.0" ? "0.0%" : `${sign(value)}${text}%`;
|
|
6086
|
+
// src/Figure.tsx
|
|
6087
|
+
import { Fragment as Fragment9, jsx as jsx63, jsxs as jsxs55 } from "react/jsx-runtime";
|
|
6088
|
+
function Figure({ value, kind = "money", missing, ...opts }) {
|
|
6089
|
+
if (value === null || value === void 0 || Number.isNaN(value)) return /* @__PURE__ */ jsx63(NoValue, { reason: missing });
|
|
6090
|
+
const short = kind === "money" ? formatMoney(value, opts) : formatCount(value, opts);
|
|
6091
|
+
const full = kind === "money" ? formatMoneyFull(value, opts) : formatCountFull(value);
|
|
6092
|
+
if (short === full) return /* @__PURE__ */ jsx63(Fragment9, { children: short });
|
|
6093
|
+
return /* @__PURE__ */ jsxs55(Tooltip, { label: full, delay: 300, children: [
|
|
6094
|
+
/* @__PURE__ */ jsx63("span", { "aria-hidden": "true", children: short }),
|
|
6095
|
+
/* @__PURE__ */ jsx63("span", { className: "sr-only", children: full })
|
|
6096
|
+
] });
|
|
5960
6097
|
}
|
|
5961
6098
|
export {
|
|
5962
6099
|
AISpark,
|
|
@@ -5982,6 +6119,7 @@ export {
|
|
|
5982
6119
|
Delta,
|
|
5983
6120
|
Drawer,
|
|
5984
6121
|
EmptyState,
|
|
6122
|
+
Figure,
|
|
5985
6123
|
FilterChipBar,
|
|
5986
6124
|
FilterDrawer,
|
|
5987
6125
|
FilterDropdownFooter,
|
|
@@ -6002,6 +6140,7 @@ export {
|
|
|
6002
6140
|
NO_VALUE,
|
|
6003
6141
|
NameListModal,
|
|
6004
6142
|
NoResultsEmptyState,
|
|
6143
|
+
NoValue,
|
|
6005
6144
|
PRIMARY_ACTION_CLASS,
|
|
6006
6145
|
PageHeader,
|
|
6007
6146
|
Pager,
|
|
@@ -6022,6 +6161,7 @@ export {
|
|
|
6022
6161
|
StatStrip,
|
|
6023
6162
|
StatTile,
|
|
6024
6163
|
SuggestionChip,
|
|
6164
|
+
TableLink,
|
|
6025
6165
|
TablePagination,
|
|
6026
6166
|
Tabs,
|
|
6027
6167
|
Tag,
|