@mediaradar/design-components 0.49.0 → 0.50.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 +3 -1
- package/dist/index.cjs +191 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +116 -2
- package/dist/index.d.ts +116 -2
- package/dist/index.js +189 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.50.0",
|
|
3
3
|
"components": [
|
|
4
4
|
"AISpark",
|
|
5
5
|
"AdvertiserNoResults",
|
|
6
6
|
"AdvertiserQuickFilter",
|
|
7
7
|
"AdvertiserSearchPrompt",
|
|
8
|
+
"AllFiltersButton",
|
|
8
9
|
"Badge",
|
|
9
10
|
"BarChartPlaceholder",
|
|
10
11
|
"Button",
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
"Drawer",
|
|
21
22
|
"EmptyState",
|
|
22
23
|
"FilterChipBar",
|
|
24
|
+
"FilterDrawer",
|
|
23
25
|
"FilterDropdownFooter",
|
|
24
26
|
"Freshness",
|
|
25
27
|
"InfoTip",
|
package/dist/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ __export(index_exports, {
|
|
|
25
25
|
AdvertiserNoResults: () => AdvertiserNoResults,
|
|
26
26
|
AdvertiserQuickFilter: () => AdvertiserQuickFilter,
|
|
27
27
|
AdvertiserSearchPrompt: () => AdvertiserSearchPrompt,
|
|
28
|
+
AllFiltersButton: () => AllFiltersButton,
|
|
28
29
|
Badge: () => Badge,
|
|
29
30
|
BarChartPlaceholder: () => BarChartPlaceholder,
|
|
30
31
|
Button: () => Button,
|
|
@@ -42,6 +43,7 @@ __export(index_exports, {
|
|
|
42
43
|
Drawer: () => Drawer,
|
|
43
44
|
EmptyState: () => EmptyState,
|
|
44
45
|
FilterChipBar: () => FilterChipBar,
|
|
46
|
+
FilterDrawer: () => FilterDrawer,
|
|
45
47
|
FilterDropdownFooter: () => FilterDropdownFooter,
|
|
46
48
|
Freshness: () => Freshness,
|
|
47
49
|
InfoTip: () => InfoTip,
|
|
@@ -5396,12 +5398,200 @@ function InlineMessage({ tone = "info", title, children, actions, onDismiss, cla
|
|
|
5396
5398
|
}
|
|
5397
5399
|
);
|
|
5398
5400
|
}
|
|
5401
|
+
|
|
5402
|
+
// src/FilterDrawer.tsx
|
|
5403
|
+
var import_react30 = require("react");
|
|
5404
|
+
var import_lucide_react31 = require("lucide-react");
|
|
5405
|
+
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
5406
|
+
var SLIDE_MS = 200;
|
|
5407
|
+
function reducedMotion() {
|
|
5408
|
+
return typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
5409
|
+
}
|
|
5410
|
+
function FilterDrawer({
|
|
5411
|
+
open,
|
|
5412
|
+
onClose,
|
|
5413
|
+
sections,
|
|
5414
|
+
renderSection,
|
|
5415
|
+
activeCount = 0,
|
|
5416
|
+
onClearSection,
|
|
5417
|
+
onClearAll,
|
|
5418
|
+
onApply,
|
|
5419
|
+
focus = null,
|
|
5420
|
+
size = "sm",
|
|
5421
|
+
testIdPrefix
|
|
5422
|
+
}) {
|
|
5423
|
+
const [view, setViewState] = (0, import_react30.useState)(focus);
|
|
5424
|
+
const [leaving, setLeaving] = (0, import_react30.useState)(null);
|
|
5425
|
+
const [phase, setPhase] = (0, import_react30.useState)("run");
|
|
5426
|
+
const [wasOpen, setWasOpen] = (0, import_react30.useState)(open);
|
|
5427
|
+
if (open !== wasOpen) {
|
|
5428
|
+
setWasOpen(open);
|
|
5429
|
+
if (open) {
|
|
5430
|
+
setViewState(focus);
|
|
5431
|
+
setLeaving(null);
|
|
5432
|
+
}
|
|
5433
|
+
}
|
|
5434
|
+
const setView = (next) => {
|
|
5435
|
+
if (!reducedMotion()) {
|
|
5436
|
+
setLeaving({ view, dir: next ? 1 : -1 });
|
|
5437
|
+
setPhase("start");
|
|
5438
|
+
}
|
|
5439
|
+
setViewState(next);
|
|
5440
|
+
};
|
|
5441
|
+
(0, import_react30.useLayoutEffect)(() => {
|
|
5442
|
+
if (phase !== "start") return;
|
|
5443
|
+
const raf = requestAnimationFrame(() => requestAnimationFrame(() => setPhase("run")));
|
|
5444
|
+
return () => cancelAnimationFrame(raf);
|
|
5445
|
+
}, [phase]);
|
|
5446
|
+
(0, import_react30.useEffect)(() => {
|
|
5447
|
+
if (!leaving || phase !== "run") return;
|
|
5448
|
+
const t = setTimeout(() => setLeaving(null), SLIDE_MS);
|
|
5449
|
+
return () => clearTimeout(t);
|
|
5450
|
+
}, [leaving, phase]);
|
|
5451
|
+
const backRef = (0, import_react30.useRef)(null);
|
|
5452
|
+
const rowRefs = (0, import_react30.useRef)(/* @__PURE__ */ new Map());
|
|
5453
|
+
const lastView = (0, import_react30.useRef)(null);
|
|
5454
|
+
(0, import_react30.useEffect)(() => {
|
|
5455
|
+
if (!open) return;
|
|
5456
|
+
if (view) backRef.current?.focus();
|
|
5457
|
+
else if (lastView.current) rowRefs.current.get(lastView.current)?.focus();
|
|
5458
|
+
lastView.current = view;
|
|
5459
|
+
}, [view, open]);
|
|
5460
|
+
const focused = view ? sections.find((s) => s.id === view) : void 0;
|
|
5461
|
+
const dir = leaving?.dir ?? 1;
|
|
5462
|
+
const moving = !!leaving;
|
|
5463
|
+
const incoming = moving && phase === "start" ? dir > 0 ? "translateX(100%)" : "translateX(-33%)" : void 0;
|
|
5464
|
+
const outgoing = phase === "start" ? void 0 : dir > 0 ? "translateX(-33%)" : "translateX(100%)";
|
|
5465
|
+
const panel = (v, rows = true) => {
|
|
5466
|
+
const s = v ? sections.find((x) => x.id === v) : void 0;
|
|
5467
|
+
if (s) return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "px-5 pt-1", children: renderSection(s.id) });
|
|
5468
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("ul", { className: "border-t border-border-default", children: sections.map((x) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("li", { className: "border-b border-border-default", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
5469
|
+
"button",
|
|
5470
|
+
{
|
|
5471
|
+
ref: rows ? (el) => {
|
|
5472
|
+
if (el) rowRefs.current.set(x.id, el);
|
|
5473
|
+
else rowRefs.current.delete(x.id);
|
|
5474
|
+
} : void 0,
|
|
5475
|
+
type: "button",
|
|
5476
|
+
onClick: () => setView(x.id),
|
|
5477
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-row-${x.id}`,
|
|
5478
|
+
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",
|
|
5479
|
+
children: [
|
|
5480
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
5481
|
+
x.icon,
|
|
5482
|
+
{
|
|
5483
|
+
size: 17,
|
|
5484
|
+
"aria-hidden": "true",
|
|
5485
|
+
className: x.badge ? "text-brand-primaryAction" : "text-text-secondary"
|
|
5486
|
+
}
|
|
5487
|
+
),
|
|
5488
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "flex-1 text-sm font-medium text-text-primary", children: x.label }),
|
|
5489
|
+
x.badge && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Badge, { tone: "brand", children: x.badge }),
|
|
5490
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_lucide_react31.ChevronRight, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-secondary" })
|
|
5491
|
+
]
|
|
5492
|
+
}
|
|
5493
|
+
) }, x.id)) });
|
|
5494
|
+
};
|
|
5495
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
5496
|
+
Drawer,
|
|
5497
|
+
{
|
|
5498
|
+
open,
|
|
5499
|
+
onClose,
|
|
5500
|
+
size,
|
|
5501
|
+
testIdPrefix,
|
|
5502
|
+
title: focused ? /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("span", { className: "flex items-center gap-1.5", children: [
|
|
5503
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
5504
|
+
"button",
|
|
5505
|
+
{
|
|
5506
|
+
ref: backRef,
|
|
5507
|
+
type: "button",
|
|
5508
|
+
onClick: () => setView(null),
|
|
5509
|
+
"aria-label": "Back to all filters",
|
|
5510
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-back`,
|
|
5511
|
+
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-border-focus",
|
|
5512
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_lucide_react31.ChevronLeft, { size: 18, "aria-hidden": "true" })
|
|
5513
|
+
}
|
|
5514
|
+
),
|
|
5515
|
+
focused.label,
|
|
5516
|
+
focused.info && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(InfoTip, { text: focused.info, label: `About ${focused.label}` })
|
|
5517
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("span", { className: "flex items-center gap-2.5", children: [
|
|
5518
|
+
"Filters",
|
|
5519
|
+
activeCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Badge, { tone: "brandSolid", kind: "count", children: activeCount })
|
|
5520
|
+
] }),
|
|
5521
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
5522
|
+
focused ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Button, { variant: "link", size: "md", onClick: () => onClearSection(focused.id), className: "px-0", children: "Clear" }) : /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Button, { variant: "link", size: "md", onClick: onClearAll, className: "px-0", children: "Clear all" }),
|
|
5523
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
5524
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Button, { variant: "secondary", size: "md", onClick: onClose, children: "Cancel" }),
|
|
5525
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
5526
|
+
Button,
|
|
5527
|
+
{
|
|
5528
|
+
variant: "primary",
|
|
5529
|
+
size: "md",
|
|
5530
|
+
onClick: () => {
|
|
5531
|
+
onApply();
|
|
5532
|
+
onClose();
|
|
5533
|
+
},
|
|
5534
|
+
children: "Apply"
|
|
5535
|
+
}
|
|
5536
|
+
)
|
|
5537
|
+
] })
|
|
5538
|
+
] }),
|
|
5539
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "relative -mx-5 overflow-x-clip", children: [
|
|
5540
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
5541
|
+
"div",
|
|
5542
|
+
{
|
|
5543
|
+
style: { transform: incoming },
|
|
5544
|
+
className: cn(moving && "transition-transform duration-(--mr-motion-duration-interactive) ease-interactive motion-reduce:transition-none"),
|
|
5545
|
+
children: panel(view)
|
|
5546
|
+
},
|
|
5547
|
+
view ?? "__list"
|
|
5548
|
+
),
|
|
5549
|
+
leaving && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
5550
|
+
"div",
|
|
5551
|
+
{
|
|
5552
|
+
"aria-hidden": "true",
|
|
5553
|
+
ref: (el) => el?.setAttribute("inert", ""),
|
|
5554
|
+
style: { transform: outgoing, opacity: phase === "start" ? 1 : dir > 0 ? 0.4 : 1 },
|
|
5555
|
+
className: "pointer-events-none absolute inset-x-0 top-0 transition duration-(--mr-motion-duration-interactive) ease-interactive motion-reduce:transition-none",
|
|
5556
|
+
children: panel(leaving.view, false)
|
|
5557
|
+
}
|
|
5558
|
+
)
|
|
5559
|
+
] })
|
|
5560
|
+
}
|
|
5561
|
+
);
|
|
5562
|
+
}
|
|
5563
|
+
|
|
5564
|
+
// src/AllFiltersButton.tsx
|
|
5565
|
+
var import_react31 = require("react");
|
|
5566
|
+
var import_lucide_react32 = require("lucide-react");
|
|
5567
|
+
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
5568
|
+
var AllFiltersButton = (0, import_react31.forwardRef)(function AllFiltersButton2({ count = 0, open, className, testIdPrefix, ...rest }, ref) {
|
|
5569
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
5570
|
+
"button",
|
|
5571
|
+
{
|
|
5572
|
+
ref,
|
|
5573
|
+
type: "button",
|
|
5574
|
+
"aria-haspopup": "dialog",
|
|
5575
|
+
"aria-expanded": open,
|
|
5576
|
+
"aria-label": count > 0 ? `All filters, ${count} in use` : void 0,
|
|
5577
|
+
"data-testid": testIdPrefix,
|
|
5578
|
+
className: cn(chipTriggerClass(), className),
|
|
5579
|
+
...rest,
|
|
5580
|
+
children: [
|
|
5581
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_lucide_react32.SlidersHorizontal, { size: 15, "aria-hidden": "true", className: "text-text-secondary" }),
|
|
5582
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "text-dense font-medium text-text-primary", children: "All filters" }),
|
|
5583
|
+
count > 0 && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(Badge, { tone: "brandSolid", kind: "count", children: count })
|
|
5584
|
+
]
|
|
5585
|
+
}
|
|
5586
|
+
);
|
|
5587
|
+
});
|
|
5399
5588
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5400
5589
|
0 && (module.exports = {
|
|
5401
5590
|
AISpark,
|
|
5402
5591
|
AdvertiserNoResults,
|
|
5403
5592
|
AdvertiserQuickFilter,
|
|
5404
5593
|
AdvertiserSearchPrompt,
|
|
5594
|
+
AllFiltersButton,
|
|
5405
5595
|
Badge,
|
|
5406
5596
|
BarChartPlaceholder,
|
|
5407
5597
|
Button,
|
|
@@ -5419,6 +5609,7 @@ function InlineMessage({ tone = "info", title, children, actions, onDismiss, cla
|
|
|
5419
5609
|
Drawer,
|
|
5420
5610
|
EmptyState,
|
|
5421
5611
|
FilterChipBar,
|
|
5612
|
+
FilterDrawer,
|
|
5422
5613
|
FilterDropdownFooter,
|
|
5423
5614
|
Freshness,
|
|
5424
5615
|
InfoTip,
|