@mediaradar/design-components 0.39.0 → 0.41.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 +288 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +85 -19
- package/dist/index.d.ts +85 -19
- package/dist/index.js +309 -65
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -245,6 +245,16 @@ function cx(...parts) {
|
|
|
245
245
|
return parts.filter(Boolean).join(" ");
|
|
246
246
|
}
|
|
247
247
|
var SELECT_ALL_THRESHOLD = 5;
|
|
248
|
+
function usePaging(total, pageSize, resetKey) {
|
|
249
|
+
const [pages, setPages] = (0, import_react2.useState)(1);
|
|
250
|
+
const [prevKey, setPrevKey] = (0, import_react2.useState)(resetKey);
|
|
251
|
+
if (prevKey !== resetKey) {
|
|
252
|
+
setPrevKey(resetKey);
|
|
253
|
+
setPages(1);
|
|
254
|
+
}
|
|
255
|
+
const shown = pageSize && pageSize > 0 ? Math.min(total, pages * pageSize) : total;
|
|
256
|
+
return { shown, remaining: total - shown, showMore: () => setPages((p) => p + 1) };
|
|
257
|
+
}
|
|
248
258
|
function slug(value) {
|
|
249
259
|
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
|
|
250
260
|
}
|
|
@@ -258,6 +268,8 @@ function AdvertiserQuickFilter({
|
|
|
258
268
|
showFooter = false,
|
|
259
269
|
clearValue = [],
|
|
260
270
|
parked = [],
|
|
271
|
+
prepopulate = false,
|
|
272
|
+
pageSize,
|
|
261
273
|
searchPlaceholder = "Search for an advertiser",
|
|
262
274
|
promptLabel = "an advertiser name",
|
|
263
275
|
noResultsHint = "Try checking your spelling or searching for a broader brand name.",
|
|
@@ -312,10 +324,28 @@ function AdvertiserQuickFilter({
|
|
|
312
324
|
() => draft.map((id) => options.find((o) => o.id === id)).filter(Boolean),
|
|
313
325
|
[draft, options]
|
|
314
326
|
);
|
|
315
|
-
const
|
|
316
|
-
() => ql ? options.filter((o) => !draft.includes(o.id) && o.label.toLowerCase().includes(ql)) : [],
|
|
317
|
-
[ql, options, draft]
|
|
327
|
+
const matches = (0, import_react2.useMemo)(
|
|
328
|
+
() => ql || prepopulate ? options.filter((o) => !draft.includes(o.id) && (!ql || o.label.toLowerCase().includes(ql))) : [],
|
|
329
|
+
[ql, prepopulate, options, draft]
|
|
330
|
+
);
|
|
331
|
+
const { shown: pageEnd, remaining, showMore } = usePaging(
|
|
332
|
+
matches.length,
|
|
333
|
+
prepopulate ? pageSize : void 0,
|
|
334
|
+
`${open}|${ql}`
|
|
318
335
|
);
|
|
336
|
+
const results = (0, import_react2.useMemo)(() => matches.slice(0, pageEnd), [matches, pageEnd]);
|
|
337
|
+
const resultsRef = (0, import_react2.useRef)(null);
|
|
338
|
+
const focusFrom = (0, import_react2.useRef)(null);
|
|
339
|
+
const loadMore = () => {
|
|
340
|
+
focusFrom.current = results.length;
|
|
341
|
+
showMore();
|
|
342
|
+
};
|
|
343
|
+
(0, import_react2.useEffect)(() => {
|
|
344
|
+
const from = focusFrom.current;
|
|
345
|
+
if (from === null) return;
|
|
346
|
+
focusFrom.current = null;
|
|
347
|
+
resultsRef.current?.querySelectorAll('[role="checkbox"]')[from]?.focus();
|
|
348
|
+
}, [pageEnd]);
|
|
319
349
|
const visibleIds = results.map((o) => o.id);
|
|
320
350
|
const allVisibleSelected = visibleIds.length > 0 && visibleIds.every((id) => draft.includes(id));
|
|
321
351
|
const toggleAllVisible = () => setDraft(
|
|
@@ -421,14 +451,18 @@ function AdvertiserQuickFilter({
|
|
|
421
451
|
o.id
|
|
422
452
|
)) })
|
|
423
453
|
] }),
|
|
424
|
-
|
|
454
|
+
prepopulate && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { role: "status", className: "sr-only", "data-testid": testIdPrefix && `${testIdPrefix}-result-count`, children: [
|
|
455
|
+
matches.length === 1 ? "1 result" : `${matches.length} results`,
|
|
456
|
+
remaining > 0 ? `, showing ${results.length}` : ""
|
|
457
|
+
] }),
|
|
458
|
+
!ql && !prepopulate ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AdvertiserSearchPrompt, { label: promptLabel }) : !ql && results.length === 0 ? null : results.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-col items-center gap-1.5 px-4 py-8 text-center", children: [
|
|
425
459
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "text-[13px] font-medium text-text-primary", children: [
|
|
426
460
|
"No results found for \u201C",
|
|
427
461
|
q.trim(),
|
|
428
462
|
"\u201D"
|
|
429
463
|
] }),
|
|
430
464
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-[12px] leading-snug text-text-tertiary", children: noResultsHint })
|
|
431
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
465
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { ref: resultsRef, children: [
|
|
432
466
|
results.length > SELECT_ALL_THRESHOLD && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
433
467
|
"button",
|
|
434
468
|
{
|
|
@@ -451,7 +485,22 @@ function AdvertiserQuickFilter({
|
|
|
451
485
|
testId: testIdPrefix && `${testIdPrefix}-option-${slug(o.id)}`
|
|
452
486
|
},
|
|
453
487
|
o.id
|
|
454
|
-
))
|
|
488
|
+
)),
|
|
489
|
+
remaining > 0 && !!pageSize && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
490
|
+
"button",
|
|
491
|
+
{
|
|
492
|
+
type: "button",
|
|
493
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-show-more`,
|
|
494
|
+
onClick: loadMore,
|
|
495
|
+
className: "flex w-full items-center gap-1.5 rounded-control px-2 py-2 text-left text-xs font-semibold text-text-link transition-colors hover:bg-subtle focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
|
|
496
|
+
children: [
|
|
497
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react3.Plus, { size: 13, "aria-hidden": "true" }),
|
|
498
|
+
"Show ",
|
|
499
|
+
Math.min(remaining, pageSize),
|
|
500
|
+
" more"
|
|
501
|
+
]
|
|
502
|
+
}
|
|
503
|
+
)
|
|
455
504
|
] })
|
|
456
505
|
] }),
|
|
457
506
|
showFooter ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center justify-between border-t border-border-default px-3 py-2.5", children: [
|
|
@@ -1124,6 +1173,23 @@ var MODE_LABEL = {
|
|
|
1124
1173
|
contextual: "Contextual",
|
|
1125
1174
|
adCode: "Ad Code"
|
|
1126
1175
|
};
|
|
1176
|
+
function parseAdCodes(text) {
|
|
1177
|
+
return text.split(/[\s,;]+/).map((c) => c.trim()).filter(Boolean);
|
|
1178
|
+
}
|
|
1179
|
+
function mergeAdCodes(existing, incoming) {
|
|
1180
|
+
const seen = new Set(existing.map((c) => c.toUpperCase()));
|
|
1181
|
+
const out = [...existing];
|
|
1182
|
+
for (const code of incoming) {
|
|
1183
|
+
const key = code.toUpperCase();
|
|
1184
|
+
if (seen.has(key)) continue;
|
|
1185
|
+
seen.add(key);
|
|
1186
|
+
out.push(code);
|
|
1187
|
+
}
|
|
1188
|
+
return out;
|
|
1189
|
+
}
|
|
1190
|
+
function slug3(value) {
|
|
1191
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
|
|
1192
|
+
}
|
|
1127
1193
|
function cx2(...classes) {
|
|
1128
1194
|
return classes.filter(Boolean).join(" ");
|
|
1129
1195
|
}
|
|
@@ -1135,12 +1201,53 @@ function SearchBar({
|
|
|
1135
1201
|
size = "lg",
|
|
1136
1202
|
matchValue,
|
|
1137
1203
|
onMatchChange,
|
|
1204
|
+
adCodes = [],
|
|
1205
|
+
onAdCodesChange,
|
|
1206
|
+
isAdCodeMatched,
|
|
1207
|
+
onDownloadAdCodes,
|
|
1138
1208
|
className,
|
|
1139
1209
|
testIdPrefix
|
|
1140
1210
|
}) {
|
|
1141
1211
|
const [open, setOpen] = (0, import_react4.useState)(false);
|
|
1142
1212
|
const ref = (0, import_react4.useRef)(null);
|
|
1143
1213
|
const input = (0, import_react4.useRef)(null);
|
|
1214
|
+
const [codesOpen, setCodesOpen] = (0, import_react4.useState)(false);
|
|
1215
|
+
const codesRef = (0, import_react4.useRef)(null);
|
|
1216
|
+
const codesPopover = (0, import_react4.useRef)(null);
|
|
1217
|
+
const refocus = (0, import_react4.useRef)(null);
|
|
1218
|
+
const adCodeMode = variant === "filterable" && matchValue?.mode === "adCode" && !!onAdCodesChange;
|
|
1219
|
+
const matchedCount = adCodes.filter((c) => isAdCodeMatched?.(c)).length;
|
|
1220
|
+
const hasMisses = !!isAdCodeMatched && matchedCount < adCodes.length;
|
|
1221
|
+
(0, import_react4.useEffect)(() => {
|
|
1222
|
+
if (!codesOpen) return;
|
|
1223
|
+
const onKey = (e) => {
|
|
1224
|
+
if (e.key !== "Escape") return;
|
|
1225
|
+
setCodesOpen(false);
|
|
1226
|
+
input.current?.focus();
|
|
1227
|
+
};
|
|
1228
|
+
const onClick = (e) => {
|
|
1229
|
+
if (codesRef.current && !codesRef.current.contains(e.target)) setCodesOpen(false);
|
|
1230
|
+
};
|
|
1231
|
+
window.addEventListener("keydown", onKey);
|
|
1232
|
+
window.addEventListener("mousedown", onClick);
|
|
1233
|
+
return () => {
|
|
1234
|
+
window.removeEventListener("keydown", onKey);
|
|
1235
|
+
window.removeEventListener("mousedown", onClick);
|
|
1236
|
+
};
|
|
1237
|
+
}, [codesOpen]);
|
|
1238
|
+
(0, import_react4.useLayoutEffect)(() => {
|
|
1239
|
+
const i = refocus.current;
|
|
1240
|
+
if (i === null) return;
|
|
1241
|
+
refocus.current = null;
|
|
1242
|
+
const buttons = codesPopover.current?.querySelectorAll("[data-remove-code]");
|
|
1243
|
+
if (i >= 0 && buttons && buttons.length > 0) buttons[Math.min(i, buttons.length - 1)].focus();
|
|
1244
|
+
else input.current?.focus();
|
|
1245
|
+
}, [adCodes]);
|
|
1246
|
+
const updateCodes = (next, focusIndex) => {
|
|
1247
|
+
refocus.current = next.length ? focusIndex : -1;
|
|
1248
|
+
if (!next.length) setCodesOpen(false);
|
|
1249
|
+
onAdCodesChange?.(next);
|
|
1250
|
+
};
|
|
1144
1251
|
(0, import_react4.useEffect)(() => {
|
|
1145
1252
|
if (!open) return;
|
|
1146
1253
|
const onKey = (e) => e.key === "Escape" && setOpen(false);
|
|
@@ -1159,27 +1266,158 @@ function SearchBar({
|
|
|
1159
1266
|
"div",
|
|
1160
1267
|
{
|
|
1161
1268
|
className: cx2(
|
|
1162
|
-
"flex min-w-[200px] flex-1 items-stretch rounded-control border border-border-strong bg-input focus-within:outline-2 focus-within:outline-offset-1 focus-within:outline-border-focus",
|
|
1269
|
+
"relative flex min-w-[200px] flex-1 items-stretch rounded-control border border-border-strong bg-input focus-within:outline-2 focus-within:outline-offset-1 focus-within:outline-border-focus",
|
|
1163
1270
|
HEIGHT[size],
|
|
1164
1271
|
className
|
|
1165
1272
|
),
|
|
1166
1273
|
children: [
|
|
1167
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1274
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1275
|
+
"div",
|
|
1276
|
+
{
|
|
1277
|
+
ref: codesRef,
|
|
1278
|
+
className: "flex min-w-0 flex-1 cursor-text items-center gap-2 px-2.5",
|
|
1279
|
+
onMouseDown: (e) => {
|
|
1280
|
+
if (e.target === e.currentTarget) {
|
|
1281
|
+
e.preventDefault();
|
|
1282
|
+
input.current?.focus();
|
|
1283
|
+
}
|
|
1284
|
+
},
|
|
1285
|
+
children: [
|
|
1286
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react7.Search, { size: 15, "aria-hidden": "true", className: "shrink-0 text-text-tertiary" }),
|
|
1287
|
+
adCodeMode && adCodes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1288
|
+
"span",
|
|
1289
|
+
{
|
|
1290
|
+
className: cx2(
|
|
1291
|
+
"inline-flex shrink-0 items-center gap-1 rounded-full py-0.5 pl-2 pr-1 text-xs font-medium",
|
|
1292
|
+
hasMisses ? "bg-status-danger/15 text-text-danger" : "bg-subtle text-text-primary"
|
|
1293
|
+
),
|
|
1294
|
+
children: [
|
|
1295
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1296
|
+
"button",
|
|
1297
|
+
{
|
|
1298
|
+
type: "button",
|
|
1299
|
+
onClick: () => setCodesOpen((o) => !o),
|
|
1300
|
+
"aria-expanded": codesOpen,
|
|
1301
|
+
"aria-haspopup": "dialog",
|
|
1302
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-ad-codes`,
|
|
1303
|
+
className: "inline-flex items-center gap-1 rounded-control focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
|
|
1304
|
+
children: [
|
|
1305
|
+
hasMisses && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react7.AlertCircle, { size: 13, "aria-hidden": "true" }),
|
|
1306
|
+
hasMisses ? `${matchedCount} of ${adCodes.length} matched` : adCodes.length === 1 ? adCodes[0] : `${adCodes.length} Ad Codes`
|
|
1307
|
+
]
|
|
1308
|
+
}
|
|
1309
|
+
),
|
|
1310
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1311
|
+
"button",
|
|
1312
|
+
{
|
|
1313
|
+
type: "button",
|
|
1314
|
+
"aria-label": "Clear all ad codes",
|
|
1315
|
+
onClick: () => updateCodes([], -1),
|
|
1316
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-ad-codes-clear`,
|
|
1317
|
+
className: "inline-flex rounded-full p-0.5 hover:bg-surface focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
|
|
1318
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react7.X, { size: 12, "aria-hidden": "true" })
|
|
1319
|
+
}
|
|
1320
|
+
)
|
|
1321
|
+
]
|
|
1322
|
+
}
|
|
1323
|
+
),
|
|
1324
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1325
|
+
"input",
|
|
1326
|
+
{
|
|
1327
|
+
ref: input,
|
|
1328
|
+
type: "text",
|
|
1329
|
+
value,
|
|
1330
|
+
onChange: (e) => onChange?.(e.target.value),
|
|
1331
|
+
onKeyDown: (e) => {
|
|
1332
|
+
if (!adCodeMode || e.key !== "Enter") return;
|
|
1333
|
+
const typed = parseAdCodes(value ?? "");
|
|
1334
|
+
if (!typed.length) return;
|
|
1335
|
+
e.preventDefault();
|
|
1336
|
+
onAdCodesChange?.(mergeAdCodes(adCodes, typed));
|
|
1337
|
+
onChange?.("");
|
|
1338
|
+
},
|
|
1339
|
+
placeholder: adCodeMode && adCodes.length === 0 ? "Enter ad codes, then press Enter" : placeholder,
|
|
1340
|
+
"aria-label": placeholder,
|
|
1341
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-search`,
|
|
1342
|
+
className: "min-w-0 flex-1 bg-transparent text-dense text-text-primary outline-hidden placeholder:text-text-tertiary"
|
|
1343
|
+
}
|
|
1344
|
+
),
|
|
1345
|
+
adCodeMode && codesOpen && adCodes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1346
|
+
"div",
|
|
1347
|
+
{
|
|
1348
|
+
ref: codesPopover,
|
|
1349
|
+
role: "dialog",
|
|
1350
|
+
"aria-label": "Ad codes",
|
|
1351
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-ad-codes-popover`,
|
|
1352
|
+
className: "absolute right-0 top-full z-50 mt-2 w-110 max-w-[90vw] cursor-auto rounded-card border border-border-default bg-surface p-3 shadow-overlay",
|
|
1353
|
+
children: [
|
|
1354
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "mb-2 text-xs font-medium text-text-secondary", children: isAdCodeMatched ? `${matchedCount} ${matchedCount === 1 ? "ad was" : "ads were"} found` : `${adCodes.length} ${adCodes.length === 1 ? "ad code" : "ad codes"}` }),
|
|
1355
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { className: "flex max-h-50 flex-wrap gap-2 overflow-y-auto p-0.5", children: adCodes.map((code, i) => {
|
|
1356
|
+
const missed = !!isAdCodeMatched && !isAdCodeMatched(code);
|
|
1357
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1358
|
+
"li",
|
|
1359
|
+
{
|
|
1360
|
+
className: cx2(
|
|
1361
|
+
"inline-flex items-center gap-1 rounded-full py-1 pl-2.5 pr-1.5 text-card-title",
|
|
1362
|
+
missed ? "bg-status-danger/15 text-text-danger" : "bg-subtle text-text-primary"
|
|
1363
|
+
),
|
|
1364
|
+
children: [
|
|
1365
|
+
code,
|
|
1366
|
+
missed && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "sr-only", children: " (not found)" }),
|
|
1367
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1368
|
+
"button",
|
|
1369
|
+
{
|
|
1370
|
+
type: "button",
|
|
1371
|
+
"data-remove-code": "",
|
|
1372
|
+
"aria-label": `Remove ${code}`,
|
|
1373
|
+
onClick: () => updateCodes(adCodes.filter((c) => c !== code), i),
|
|
1374
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-ad-code-remove-${slug3(code)}`,
|
|
1375
|
+
className: "inline-flex rounded-full p-0.5 hover:bg-surface focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
|
|
1376
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react7.X, { size: 13, "aria-hidden": "true" })
|
|
1377
|
+
}
|
|
1378
|
+
)
|
|
1379
|
+
]
|
|
1380
|
+
},
|
|
1381
|
+
code
|
|
1382
|
+
);
|
|
1383
|
+
}) }),
|
|
1384
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3 flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1385
|
+
"button",
|
|
1386
|
+
{
|
|
1387
|
+
type: "button",
|
|
1388
|
+
onClick: () => {
|
|
1389
|
+
setCodesOpen(false);
|
|
1390
|
+
input.current?.focus();
|
|
1391
|
+
},
|
|
1392
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-ad-codes-done`,
|
|
1393
|
+
className: "rounded-control bg-brand-primaryAction px-4 py-2 text-dense font-semibold text-brand-onprimary transition hover:brightness-110 focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
|
|
1394
|
+
children: "Search"
|
|
1395
|
+
}
|
|
1396
|
+
) }),
|
|
1397
|
+
onDownloadAdCodes && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 flex items-start gap-2 rounded-control border border-border-default px-3 py-2.5 text-card-title text-text-secondary", children: [
|
|
1398
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react7.AlertCircle, { size: 16, "aria-hidden": "true", className: "mt-0.5 shrink-0 text-text-tertiary" }),
|
|
1399
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
|
|
1400
|
+
hasMisses && "Some ad codes in your search could not be matched. ",
|
|
1401
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1402
|
+
"button",
|
|
1403
|
+
{
|
|
1404
|
+
type: "button",
|
|
1405
|
+
onClick: () => onDownloadAdCodes(adCodes),
|
|
1406
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-ad-codes-download`,
|
|
1407
|
+
className: "font-medium text-text-link underline focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
|
|
1408
|
+
children: "Download"
|
|
1409
|
+
}
|
|
1410
|
+
),
|
|
1411
|
+
" ",
|
|
1412
|
+
hasMisses ? "the results to see the status of each ad code." : "the list of ad codes with their status."
|
|
1413
|
+
] })
|
|
1414
|
+
] })
|
|
1415
|
+
]
|
|
1416
|
+
}
|
|
1417
|
+
)
|
|
1418
|
+
]
|
|
1419
|
+
}
|
|
1420
|
+
),
|
|
1183
1421
|
value && onChange && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1184
1422
|
"button",
|
|
1185
1423
|
{
|
|
@@ -1325,34 +1563,40 @@ function ModeRow({
|
|
|
1325
1563
|
onSelect,
|
|
1326
1564
|
testId
|
|
1327
1565
|
}) {
|
|
1566
|
+
const descId = (0, import_react4.useId)();
|
|
1328
1567
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1329
1568
|
"div",
|
|
1330
1569
|
{
|
|
1331
|
-
role: "radio",
|
|
1332
|
-
tabIndex: 0,
|
|
1333
|
-
"aria-checked": selected,
|
|
1334
|
-
"data-testid": testId,
|
|
1335
1570
|
onClick: onSelect,
|
|
1336
|
-
|
|
1337
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
1338
|
-
e.preventDefault();
|
|
1339
|
-
onSelect();
|
|
1340
|
-
}
|
|
1341
|
-
},
|
|
1342
|
-
className: "flex cursor-pointer flex-col items-stretch gap-1 rounded-control p-1.5 text-left transition-colors hover:bg-subtle focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
|
|
1571
|
+
className: "flex cursor-pointer flex-col items-stretch gap-1 rounded-control p-1.5 text-left transition-colors hover:bg-subtle",
|
|
1343
1572
|
children: [
|
|
1344
1573
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1345
1574
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
1346
1575
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1", children: [
|
|
1347
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1576
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1577
|
+
"button",
|
|
1578
|
+
{
|
|
1579
|
+
type: "button",
|
|
1580
|
+
role: "radio",
|
|
1581
|
+
"aria-checked": selected,
|
|
1582
|
+
"aria-describedby": descId,
|
|
1583
|
+
"data-testid": testId,
|
|
1584
|
+
onClick: (e) => {
|
|
1585
|
+
e.stopPropagation();
|
|
1586
|
+
onSelect();
|
|
1587
|
+
},
|
|
1588
|
+
className: "rounded-control text-left text-[14px] font-semibold text-text-primary focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
|
|
1589
|
+
children: title
|
|
1590
|
+
}
|
|
1591
|
+
),
|
|
1348
1592
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RowInfoTip, { text: infoText })
|
|
1349
1593
|
] }),
|
|
1350
|
-
badge && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1594
|
+
badge && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Badge, { kind: "category", children: badge }),
|
|
1351
1595
|
extra
|
|
1352
1596
|
] }),
|
|
1353
1597
|
selected && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react7.Check, { size: 16, strokeWidth: 2.5, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" })
|
|
1354
1598
|
] }),
|
|
1355
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "block text-[12.5px] leading-snug text-text-secondary", children: description })
|
|
1599
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { id: descId, className: "block text-[12.5px] leading-snug text-text-secondary", children: description })
|
|
1356
1600
|
]
|
|
1357
1601
|
}
|
|
1358
1602
|
);
|
|
@@ -1415,7 +1659,7 @@ function RowInfoTip({ text }) {
|
|
|
1415
1659
|
"aria-label": "More information",
|
|
1416
1660
|
"aria-expanded": open,
|
|
1417
1661
|
"aria-describedby": id,
|
|
1418
|
-
className: "inline-flex text-text-tertiary transition-colors hover:text-text-primary focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
|
|
1662
|
+
className: "-m-1.5 inline-flex size-6 items-center justify-center rounded-control text-text-tertiary transition-colors hover:text-text-primary focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
|
|
1419
1663
|
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react7.AlertCircle, { size: 13, "aria-hidden": "true" })
|
|
1420
1664
|
}
|
|
1421
1665
|
),
|
|
@@ -1632,7 +1876,7 @@ var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
|
1632
1876
|
function cx4(...classes) {
|
|
1633
1877
|
return classes.filter(Boolean).join(" ");
|
|
1634
1878
|
}
|
|
1635
|
-
function
|
|
1879
|
+
function slug4(value) {
|
|
1636
1880
|
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
|
|
1637
1881
|
}
|
|
1638
1882
|
function OptionIcon({ children }) {
|
|
@@ -1752,7 +1996,7 @@ function SelectFilter({
|
|
|
1752
1996
|
type: "button",
|
|
1753
1997
|
role: "option",
|
|
1754
1998
|
"aria-selected": selected,
|
|
1755
|
-
"data-testid": testIdPrefix && `${testIdPrefix}-option-${
|
|
1999
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-option-${slug4(o)}`,
|
|
1756
2000
|
onClick: () => {
|
|
1757
2001
|
onChange(o);
|
|
1758
2002
|
close();
|
|
@@ -2560,7 +2804,7 @@ var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
|
2560
2804
|
function cx8(...parts) {
|
|
2561
2805
|
return parts.filter(Boolean).join(" ");
|
|
2562
2806
|
}
|
|
2563
|
-
function
|
|
2807
|
+
function slug5(value) {
|
|
2564
2808
|
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
|
|
2565
2809
|
}
|
|
2566
2810
|
function SelectionPicker({
|
|
@@ -2757,7 +3001,7 @@ function SelectionPicker({
|
|
|
2757
3001
|
checked: isSel,
|
|
2758
3002
|
onChange: () => toggleRow(row),
|
|
2759
3003
|
ariaLabel: row.name,
|
|
2760
|
-
testId: testIdPrefix && `${testIdPrefix}-row-${
|
|
3004
|
+
testId: testIdPrefix && `${testIdPrefix}-row-${slug5(row.id)}`
|
|
2761
3005
|
}
|
|
2762
3006
|
),
|
|
2763
3007
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cx8("grid gap-2 text-dense text-text-primary", gridForColumns(columns)), children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: cx8("truncate", c.className), children: c.render(row) }, c.key)) }),
|
|
@@ -2975,7 +3219,7 @@ function FilterDropdown({
|
|
|
2975
3219
|
}, [open]);
|
|
2976
3220
|
const count = active.size;
|
|
2977
3221
|
const label = count === 0 ? filter.label : count === 1 ? [...active][0] : "Multiple";
|
|
2978
|
-
const filterSlug =
|
|
3222
|
+
const filterSlug = slug5(filter.label);
|
|
2979
3223
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "relative", children: [
|
|
2980
3224
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2981
3225
|
"button",
|
|
@@ -3028,7 +3272,7 @@ function FilterDropdown({
|
|
|
3028
3272
|
checked: on,
|
|
3029
3273
|
onChange: () => onToggle(opt),
|
|
3030
3274
|
ariaLabel: opt,
|
|
3031
|
-
testId: testIdPrefix && `${testIdPrefix}-filter-${filterSlug}-${
|
|
3275
|
+
testId: testIdPrefix && `${testIdPrefix}-filter-${filterSlug}-${slug5(opt)}`
|
|
3032
3276
|
}
|
|
3033
3277
|
),
|
|
3034
3278
|
opt
|