@mediaradar/design-components 0.40.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 +233 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -7
- package/dist/index.d.ts +50 -7
- package/dist/index.js +240 -45
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -599,10 +599,13 @@ declare function DateRangeFilter({ caption, defaultValue, value: controlledValue
|
|
|
599
599
|
* sub-choice nested under Any Word.
|
|
600
600
|
* Three heights on the one control scale -- sm 32, md 40, lg 44 (default) --
|
|
601
601
|
* so it lines up with the Buttons and dropdowns beside it. A × clears the
|
|
602
|
-
* text once something is typed.
|
|
603
|
-
*
|
|
602
|
+
* text once something is typed. In Ad Code mode (`filterable`, mode
|
|
603
|
+
* `adCode`, with `onAdCodesChange`) typed or pasted codes collect in a chip
|
|
604
|
+
* that opens a list of each code, matched or not.
|
|
605
|
+
* @tokens text-dense, focus-within:outline-border-focus, focus-within:outline-2,
|
|
604
606
|
* focus-within:outline-offset-1, rounded-control, border-border-strong, bg-input, text-text-primary,
|
|
605
607
|
* text-text-tertiary, hover:bg-subtle, bg-brand-primaryAction, bg-subtle,
|
|
608
|
+
* bg-status-danger/15, text-text-danger, text-brand-onprimary, text-xs, text-card-title, text-text-link,
|
|
606
609
|
* bg-surface, border-brand-primaryAction, border-border-default,
|
|
607
610
|
* border-border-interactive, focus-visible:outline-border-focus,
|
|
608
611
|
* hover:text-text-primary, placeholder:text-text-tertiary, rounded-card,
|
|
@@ -621,19 +624,40 @@ declare function DateRangeFilter({ caption, defaultValue, value: controlledValue
|
|
|
621
624
|
* input), so it grants the input no accessible name on its own. The clear
|
|
622
625
|
* × shows only when there's text and `onChange` is given; it empties the
|
|
623
626
|
* field and puts focus back in it.
|
|
627
|
+
* Ad Code mode: Enter splits the field's text into codes (commas, spaces,
|
|
628
|
+
* semicolons and new lines all separate), adds the new ones (case-insensitive
|
|
629
|
+
* duplicates are skipped) and empties the field. The chip reads the code
|
|
630
|
+
* itself, "N Ad Codes", or "M of N matched" in danger colours when
|
|
631
|
+
* `isAdCodeMatched` misses any. It opens a list of every code with a remove
|
|
632
|
+
* button, a Search button that closes it, and, with `onDownloadAdCodes`, a
|
|
633
|
+
* Download link for the status of each code. The list closes on Escape and
|
|
634
|
+
* outside click; removing the last code closes it too.
|
|
635
|
+
* The focus ring is a 2px outline around the frame, offset 1px, so it
|
|
636
|
+
* reaches 3px outside the box. Beside an edge that clips (`overflow-hidden`:
|
|
637
|
+
* a top bar, a scrolling list) that side of the ring is cut off, so leave at
|
|
638
|
+
* least 3px between the box and the edge. The prototype's top bar search
|
|
639
|
+
* moved 4px in (`ml-1`).
|
|
624
640
|
* @a11y The <input> takes its accessible name from `ariaLabel`. The match-mode
|
|
625
641
|
* popover is a radio group (role="radio" + aria-checked) and its trigger
|
|
626
642
|
* reports aria-expanded. Escape closes the popover only, leaving focus in
|
|
627
643
|
* the field -- a consumer nesting this inside another dismissible layer
|
|
628
|
-
* must sequence the two dismissals itself.
|
|
629
|
-
*
|
|
630
|
-
*
|
|
644
|
+
* must sequence the two dismissals itself. Ad Code mode: the chip and its
|
|
645
|
+
* clear-all × are real buttons (the chip reports aria-expanded), the list is
|
|
646
|
+
* role="dialog", every remove button is labelled "Remove <code>", and Escape
|
|
647
|
+
* closes the list and puts focus back in the field. Removing a code moves
|
|
648
|
+
* focus to the next remove button, or back to the field when none is left.
|
|
649
|
+
* @use for every search field: in a filter row (lg), a form (md), a toolbar,
|
|
650
|
+
* dropdown, filter panel or tree picker (sm).
|
|
631
651
|
* @use the size of the controls beside it.
|
|
632
652
|
* @avoid a hand-built search input or a borderless one -- one look everywhere.
|
|
653
|
+
* @avoid placing it flush against an edge that clips: leave at least 3px for
|
|
654
|
+
* the focus ring.
|
|
633
655
|
* @usage
|
|
634
656
|
* ```tsx
|
|
635
657
|
* <SearchBar value={query} onChange={setQuery} />
|
|
636
658
|
* <SearchBar variant="filterable" value={query} onChange={setQuery} matchValue={matchValue} onMatchChange={setMatchValue} />
|
|
659
|
+
* <SearchBar variant="filterable" value={query} onChange={setQuery} matchValue={matchValue} onMatchChange={setMatchValue}
|
|
660
|
+
* adCodes={codes} onAdCodesChange={setCodes} isAdCodeMatched={(c) => found.has(c)} onDownloadAdCodes={exportStatus} />
|
|
637
661
|
* ```
|
|
638
662
|
*/
|
|
639
663
|
type SearchBarVariant = "default" | "filterable";
|
|
@@ -658,13 +682,32 @@ interface SearchBarProps {
|
|
|
658
682
|
/** The 'filterable' variant's dropdown state. */
|
|
659
683
|
matchValue?: SearchMatchValue;
|
|
660
684
|
onMatchChange?: (v: SearchMatchValue) => void;
|
|
685
|
+
/** Ad Code mode: the codes entered so far. Shown as a chip in the field. */
|
|
686
|
+
adCodes?: string[];
|
|
687
|
+
/**
|
|
688
|
+
* Turns on Ad Code mode while the 'filterable' variant's mode is `adCode`:
|
|
689
|
+
* Enter adds the field's codes instead of searching. Receives the new list.
|
|
690
|
+
*/
|
|
691
|
+
onAdCodesChange?: (codes: string[]) => void;
|
|
692
|
+
/** Ad Code mode: whether a code found anything. Misses turn the chip and that code red. */
|
|
693
|
+
isAdCodeMatched?: (code: string) => boolean;
|
|
694
|
+
/**
|
|
695
|
+
* Ad Code mode: shows a Download link in the codes list. Receives the codes;
|
|
696
|
+
* the app writes the file (the prototype exports an .xlsx), so this package
|
|
697
|
+
* carries no spreadsheet library.
|
|
698
|
+
*/
|
|
699
|
+
onDownloadAdCodes?: (codes: string[]) => void;
|
|
661
700
|
className?: string;
|
|
662
701
|
/**
|
|
663
702
|
* Optional prefix for `data-testid` attributes on the input
|
|
664
703
|
* (`${testIdPrefix}-search`), its clear button (`-clear`), the match-type
|
|
665
704
|
* trigger (`-mode-trigger`) and popover (`-mode-popover`), each mode row
|
|
666
705
|
* (`-mode-anyWord`, `-mode-exactMatch`, `-mode-contextual`, `-mode-adCode`),
|
|
667
|
-
*
|
|
706
|
+
* the Or/And radio pair (`-word-join-or`, `-word-join-and`), and in Ad
|
|
707
|
+
* Code mode the chip (`-ad-codes`), its clear-all x (`-ad-codes-clear`),
|
|
708
|
+
* the list (`-ad-codes-popover`), each remove button
|
|
709
|
+
* (`-ad-code-remove-<slugified-code>`), Download (`-ad-codes-download`) and
|
|
710
|
+
* Search (`-ad-codes-done`). Omit
|
|
668
711
|
* entirely for no test-id wiring at all -- added specifically so an
|
|
669
712
|
* existing Playwright suite keyed off these ids (mr-clientapps'
|
|
670
713
|
* `KeywordSearchBar`) doesn't lose its locators when swapped over to
|
|
@@ -672,7 +715,7 @@ interface SearchBarProps {
|
|
|
672
715
|
*/
|
|
673
716
|
testIdPrefix?: string;
|
|
674
717
|
}
|
|
675
|
-
declare function SearchBar({ placeholder, value, onChange, variant, size, matchValue, onMatchChange, className, testIdPrefix, }: SearchBarProps): react.JSX.Element;
|
|
718
|
+
declare function SearchBar({ placeholder, value, onChange, variant, size, matchValue, onMatchChange, adCodes, onAdCodesChange, isAdCodeMatched, onDownloadAdCodes, className, testIdPrefix, }: SearchBarProps): react.JSX.Element;
|
|
676
719
|
|
|
677
720
|
/**
|
|
678
721
|
* @pattern SectionRail
|
package/dist/index.d.ts
CHANGED
|
@@ -599,10 +599,13 @@ declare function DateRangeFilter({ caption, defaultValue, value: controlledValue
|
|
|
599
599
|
* sub-choice nested under Any Word.
|
|
600
600
|
* Three heights on the one control scale -- sm 32, md 40, lg 44 (default) --
|
|
601
601
|
* so it lines up with the Buttons and dropdowns beside it. A × clears the
|
|
602
|
-
* text once something is typed.
|
|
603
|
-
*
|
|
602
|
+
* text once something is typed. In Ad Code mode (`filterable`, mode
|
|
603
|
+
* `adCode`, with `onAdCodesChange`) typed or pasted codes collect in a chip
|
|
604
|
+
* that opens a list of each code, matched or not.
|
|
605
|
+
* @tokens text-dense, focus-within:outline-border-focus, focus-within:outline-2,
|
|
604
606
|
* focus-within:outline-offset-1, rounded-control, border-border-strong, bg-input, text-text-primary,
|
|
605
607
|
* text-text-tertiary, hover:bg-subtle, bg-brand-primaryAction, bg-subtle,
|
|
608
|
+
* bg-status-danger/15, text-text-danger, text-brand-onprimary, text-xs, text-card-title, text-text-link,
|
|
606
609
|
* bg-surface, border-brand-primaryAction, border-border-default,
|
|
607
610
|
* border-border-interactive, focus-visible:outline-border-focus,
|
|
608
611
|
* hover:text-text-primary, placeholder:text-text-tertiary, rounded-card,
|
|
@@ -621,19 +624,40 @@ declare function DateRangeFilter({ caption, defaultValue, value: controlledValue
|
|
|
621
624
|
* input), so it grants the input no accessible name on its own. The clear
|
|
622
625
|
* × shows only when there's text and `onChange` is given; it empties the
|
|
623
626
|
* field and puts focus back in it.
|
|
627
|
+
* Ad Code mode: Enter splits the field's text into codes (commas, spaces,
|
|
628
|
+
* semicolons and new lines all separate), adds the new ones (case-insensitive
|
|
629
|
+
* duplicates are skipped) and empties the field. The chip reads the code
|
|
630
|
+
* itself, "N Ad Codes", or "M of N matched" in danger colours when
|
|
631
|
+
* `isAdCodeMatched` misses any. It opens a list of every code with a remove
|
|
632
|
+
* button, a Search button that closes it, and, with `onDownloadAdCodes`, a
|
|
633
|
+
* Download link for the status of each code. The list closes on Escape and
|
|
634
|
+
* outside click; removing the last code closes it too.
|
|
635
|
+
* The focus ring is a 2px outline around the frame, offset 1px, so it
|
|
636
|
+
* reaches 3px outside the box. Beside an edge that clips (`overflow-hidden`:
|
|
637
|
+
* a top bar, a scrolling list) that side of the ring is cut off, so leave at
|
|
638
|
+
* least 3px between the box and the edge. The prototype's top bar search
|
|
639
|
+
* moved 4px in (`ml-1`).
|
|
624
640
|
* @a11y The <input> takes its accessible name from `ariaLabel`. The match-mode
|
|
625
641
|
* popover is a radio group (role="radio" + aria-checked) and its trigger
|
|
626
642
|
* reports aria-expanded. Escape closes the popover only, leaving focus in
|
|
627
643
|
* the field -- a consumer nesting this inside another dismissible layer
|
|
628
|
-
* must sequence the two dismissals itself.
|
|
629
|
-
*
|
|
630
|
-
*
|
|
644
|
+
* must sequence the two dismissals itself. Ad Code mode: the chip and its
|
|
645
|
+
* clear-all × are real buttons (the chip reports aria-expanded), the list is
|
|
646
|
+
* role="dialog", every remove button is labelled "Remove <code>", and Escape
|
|
647
|
+
* closes the list and puts focus back in the field. Removing a code moves
|
|
648
|
+
* focus to the next remove button, or back to the field when none is left.
|
|
649
|
+
* @use for every search field: in a filter row (lg), a form (md), a toolbar,
|
|
650
|
+
* dropdown, filter panel or tree picker (sm).
|
|
631
651
|
* @use the size of the controls beside it.
|
|
632
652
|
* @avoid a hand-built search input or a borderless one -- one look everywhere.
|
|
653
|
+
* @avoid placing it flush against an edge that clips: leave at least 3px for
|
|
654
|
+
* the focus ring.
|
|
633
655
|
* @usage
|
|
634
656
|
* ```tsx
|
|
635
657
|
* <SearchBar value={query} onChange={setQuery} />
|
|
636
658
|
* <SearchBar variant="filterable" value={query} onChange={setQuery} matchValue={matchValue} onMatchChange={setMatchValue} />
|
|
659
|
+
* <SearchBar variant="filterable" value={query} onChange={setQuery} matchValue={matchValue} onMatchChange={setMatchValue}
|
|
660
|
+
* adCodes={codes} onAdCodesChange={setCodes} isAdCodeMatched={(c) => found.has(c)} onDownloadAdCodes={exportStatus} />
|
|
637
661
|
* ```
|
|
638
662
|
*/
|
|
639
663
|
type SearchBarVariant = "default" | "filterable";
|
|
@@ -658,13 +682,32 @@ interface SearchBarProps {
|
|
|
658
682
|
/** The 'filterable' variant's dropdown state. */
|
|
659
683
|
matchValue?: SearchMatchValue;
|
|
660
684
|
onMatchChange?: (v: SearchMatchValue) => void;
|
|
685
|
+
/** Ad Code mode: the codes entered so far. Shown as a chip in the field. */
|
|
686
|
+
adCodes?: string[];
|
|
687
|
+
/**
|
|
688
|
+
* Turns on Ad Code mode while the 'filterable' variant's mode is `adCode`:
|
|
689
|
+
* Enter adds the field's codes instead of searching. Receives the new list.
|
|
690
|
+
*/
|
|
691
|
+
onAdCodesChange?: (codes: string[]) => void;
|
|
692
|
+
/** Ad Code mode: whether a code found anything. Misses turn the chip and that code red. */
|
|
693
|
+
isAdCodeMatched?: (code: string) => boolean;
|
|
694
|
+
/**
|
|
695
|
+
* Ad Code mode: shows a Download link in the codes list. Receives the codes;
|
|
696
|
+
* the app writes the file (the prototype exports an .xlsx), so this package
|
|
697
|
+
* carries no spreadsheet library.
|
|
698
|
+
*/
|
|
699
|
+
onDownloadAdCodes?: (codes: string[]) => void;
|
|
661
700
|
className?: string;
|
|
662
701
|
/**
|
|
663
702
|
* Optional prefix for `data-testid` attributes on the input
|
|
664
703
|
* (`${testIdPrefix}-search`), its clear button (`-clear`), the match-type
|
|
665
704
|
* trigger (`-mode-trigger`) and popover (`-mode-popover`), each mode row
|
|
666
705
|
* (`-mode-anyWord`, `-mode-exactMatch`, `-mode-contextual`, `-mode-adCode`),
|
|
667
|
-
*
|
|
706
|
+
* the Or/And radio pair (`-word-join-or`, `-word-join-and`), and in Ad
|
|
707
|
+
* Code mode the chip (`-ad-codes`), its clear-all x (`-ad-codes-clear`),
|
|
708
|
+
* the list (`-ad-codes-popover`), each remove button
|
|
709
|
+
* (`-ad-code-remove-<slugified-code>`), Download (`-ad-codes-download`) and
|
|
710
|
+
* Search (`-ad-codes-done`). Omit
|
|
668
711
|
* entirely for no test-id wiring at all -- added specifically so an
|
|
669
712
|
* existing Playwright suite keyed off these ids (mr-clientapps'
|
|
670
713
|
* `KeywordSearchBar`) doesn't lose its locators when swapped over to
|
|
@@ -672,7 +715,7 @@ interface SearchBarProps {
|
|
|
672
715
|
*/
|
|
673
716
|
testIdPrefix?: string;
|
|
674
717
|
}
|
|
675
|
-
declare function SearchBar({ placeholder, value, onChange, variant, size, matchValue, onMatchChange, className, testIdPrefix, }: SearchBarProps): react.JSX.Element;
|
|
718
|
+
declare function SearchBar({ placeholder, value, onChange, variant, size, matchValue, onMatchChange, adCodes, onAdCodesChange, isAdCodeMatched, onDownloadAdCodes, className, testIdPrefix, }: SearchBarProps): react.JSX.Element;
|
|
676
719
|
|
|
677
720
|
/**
|
|
678
721
|
* @pattern SectionRail
|
package/dist/index.js
CHANGED
|
@@ -1071,7 +1071,7 @@ function NavBtn({ children, onClick, ...rest }) {
|
|
|
1071
1071
|
}
|
|
1072
1072
|
|
|
1073
1073
|
// src/SearchBar.tsx
|
|
1074
|
-
import { useEffect as useEffect4, useId as useId3, useRef as useRef4, useState as useState4 } from "react";
|
|
1074
|
+
import { useEffect as useEffect4, useId as useId3, useLayoutEffect as useLayoutEffect2, useRef as useRef4, useState as useState4 } from "react";
|
|
1075
1075
|
import { AlertCircle, Check as Check3, ChevronDown as ChevronDown3, Search as Search3, X as X2 } from "lucide-react";
|
|
1076
1076
|
import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1077
1077
|
var HEIGHT = { sm: "h-8", md: "h-10", lg: "h-11" };
|
|
@@ -1082,6 +1082,23 @@ var MODE_LABEL = {
|
|
|
1082
1082
|
contextual: "Contextual",
|
|
1083
1083
|
adCode: "Ad Code"
|
|
1084
1084
|
};
|
|
1085
|
+
function parseAdCodes(text) {
|
|
1086
|
+
return text.split(/[\s,;]+/).map((c) => c.trim()).filter(Boolean);
|
|
1087
|
+
}
|
|
1088
|
+
function mergeAdCodes(existing, incoming) {
|
|
1089
|
+
const seen = new Set(existing.map((c) => c.toUpperCase()));
|
|
1090
|
+
const out = [...existing];
|
|
1091
|
+
for (const code of incoming) {
|
|
1092
|
+
const key = code.toUpperCase();
|
|
1093
|
+
if (seen.has(key)) continue;
|
|
1094
|
+
seen.add(key);
|
|
1095
|
+
out.push(code);
|
|
1096
|
+
}
|
|
1097
|
+
return out;
|
|
1098
|
+
}
|
|
1099
|
+
function slug3(value) {
|
|
1100
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
|
|
1101
|
+
}
|
|
1085
1102
|
function cx2(...classes) {
|
|
1086
1103
|
return classes.filter(Boolean).join(" ");
|
|
1087
1104
|
}
|
|
@@ -1093,12 +1110,53 @@ function SearchBar({
|
|
|
1093
1110
|
size = "lg",
|
|
1094
1111
|
matchValue,
|
|
1095
1112
|
onMatchChange,
|
|
1113
|
+
adCodes = [],
|
|
1114
|
+
onAdCodesChange,
|
|
1115
|
+
isAdCodeMatched,
|
|
1116
|
+
onDownloadAdCodes,
|
|
1096
1117
|
className,
|
|
1097
1118
|
testIdPrefix
|
|
1098
1119
|
}) {
|
|
1099
1120
|
const [open, setOpen] = useState4(false);
|
|
1100
1121
|
const ref = useRef4(null);
|
|
1101
1122
|
const input = useRef4(null);
|
|
1123
|
+
const [codesOpen, setCodesOpen] = useState4(false);
|
|
1124
|
+
const codesRef = useRef4(null);
|
|
1125
|
+
const codesPopover = useRef4(null);
|
|
1126
|
+
const refocus = useRef4(null);
|
|
1127
|
+
const adCodeMode = variant === "filterable" && matchValue?.mode === "adCode" && !!onAdCodesChange;
|
|
1128
|
+
const matchedCount = adCodes.filter((c) => isAdCodeMatched?.(c)).length;
|
|
1129
|
+
const hasMisses = !!isAdCodeMatched && matchedCount < adCodes.length;
|
|
1130
|
+
useEffect4(() => {
|
|
1131
|
+
if (!codesOpen) return;
|
|
1132
|
+
const onKey = (e) => {
|
|
1133
|
+
if (e.key !== "Escape") return;
|
|
1134
|
+
setCodesOpen(false);
|
|
1135
|
+
input.current?.focus();
|
|
1136
|
+
};
|
|
1137
|
+
const onClick = (e) => {
|
|
1138
|
+
if (codesRef.current && !codesRef.current.contains(e.target)) setCodesOpen(false);
|
|
1139
|
+
};
|
|
1140
|
+
window.addEventListener("keydown", onKey);
|
|
1141
|
+
window.addEventListener("mousedown", onClick);
|
|
1142
|
+
return () => {
|
|
1143
|
+
window.removeEventListener("keydown", onKey);
|
|
1144
|
+
window.removeEventListener("mousedown", onClick);
|
|
1145
|
+
};
|
|
1146
|
+
}, [codesOpen]);
|
|
1147
|
+
useLayoutEffect2(() => {
|
|
1148
|
+
const i = refocus.current;
|
|
1149
|
+
if (i === null) return;
|
|
1150
|
+
refocus.current = null;
|
|
1151
|
+
const buttons = codesPopover.current?.querySelectorAll("[data-remove-code]");
|
|
1152
|
+
if (i >= 0 && buttons && buttons.length > 0) buttons[Math.min(i, buttons.length - 1)].focus();
|
|
1153
|
+
else input.current?.focus();
|
|
1154
|
+
}, [adCodes]);
|
|
1155
|
+
const updateCodes = (next, focusIndex) => {
|
|
1156
|
+
refocus.current = next.length ? focusIndex : -1;
|
|
1157
|
+
if (!next.length) setCodesOpen(false);
|
|
1158
|
+
onAdCodesChange?.(next);
|
|
1159
|
+
};
|
|
1102
1160
|
useEffect4(() => {
|
|
1103
1161
|
if (!open) return;
|
|
1104
1162
|
const onKey = (e) => e.key === "Escape" && setOpen(false);
|
|
@@ -1117,27 +1175,158 @@ function SearchBar({
|
|
|
1117
1175
|
"div",
|
|
1118
1176
|
{
|
|
1119
1177
|
className: cx2(
|
|
1120
|
-
"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",
|
|
1178
|
+
"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",
|
|
1121
1179
|
HEIGHT[size],
|
|
1122
1180
|
className
|
|
1123
1181
|
),
|
|
1124
1182
|
children: [
|
|
1125
|
-
/* @__PURE__ */ jsxs8(
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1183
|
+
/* @__PURE__ */ jsxs8(
|
|
1184
|
+
"div",
|
|
1185
|
+
{
|
|
1186
|
+
ref: codesRef,
|
|
1187
|
+
className: "flex min-w-0 flex-1 cursor-text items-center gap-2 px-2.5",
|
|
1188
|
+
onMouseDown: (e) => {
|
|
1189
|
+
if (e.target === e.currentTarget) {
|
|
1190
|
+
e.preventDefault();
|
|
1191
|
+
input.current?.focus();
|
|
1192
|
+
}
|
|
1193
|
+
},
|
|
1194
|
+
children: [
|
|
1195
|
+
/* @__PURE__ */ jsx9(Search3, { size: 15, "aria-hidden": "true", className: "shrink-0 text-text-tertiary" }),
|
|
1196
|
+
adCodeMode && adCodes.length > 0 && /* @__PURE__ */ jsxs8(
|
|
1197
|
+
"span",
|
|
1198
|
+
{
|
|
1199
|
+
className: cx2(
|
|
1200
|
+
"inline-flex shrink-0 items-center gap-1 rounded-full py-0.5 pl-2 pr-1 text-xs font-medium",
|
|
1201
|
+
hasMisses ? "bg-status-danger/15 text-text-danger" : "bg-subtle text-text-primary"
|
|
1202
|
+
),
|
|
1203
|
+
children: [
|
|
1204
|
+
/* @__PURE__ */ jsxs8(
|
|
1205
|
+
"button",
|
|
1206
|
+
{
|
|
1207
|
+
type: "button",
|
|
1208
|
+
onClick: () => setCodesOpen((o) => !o),
|
|
1209
|
+
"aria-expanded": codesOpen,
|
|
1210
|
+
"aria-haspopup": "dialog",
|
|
1211
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-ad-codes`,
|
|
1212
|
+
className: "inline-flex items-center gap-1 rounded-control focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
|
|
1213
|
+
children: [
|
|
1214
|
+
hasMisses && /* @__PURE__ */ jsx9(AlertCircle, { size: 13, "aria-hidden": "true" }),
|
|
1215
|
+
hasMisses ? `${matchedCount} of ${adCodes.length} matched` : adCodes.length === 1 ? adCodes[0] : `${adCodes.length} Ad Codes`
|
|
1216
|
+
]
|
|
1217
|
+
}
|
|
1218
|
+
),
|
|
1219
|
+
/* @__PURE__ */ jsx9(
|
|
1220
|
+
"button",
|
|
1221
|
+
{
|
|
1222
|
+
type: "button",
|
|
1223
|
+
"aria-label": "Clear all ad codes",
|
|
1224
|
+
onClick: () => updateCodes([], -1),
|
|
1225
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-ad-codes-clear`,
|
|
1226
|
+
className: "inline-flex rounded-full p-0.5 hover:bg-surface focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
|
|
1227
|
+
children: /* @__PURE__ */ jsx9(X2, { size: 12, "aria-hidden": "true" })
|
|
1228
|
+
}
|
|
1229
|
+
)
|
|
1230
|
+
]
|
|
1231
|
+
}
|
|
1232
|
+
),
|
|
1233
|
+
/* @__PURE__ */ jsx9(
|
|
1234
|
+
"input",
|
|
1235
|
+
{
|
|
1236
|
+
ref: input,
|
|
1237
|
+
type: "text",
|
|
1238
|
+
value,
|
|
1239
|
+
onChange: (e) => onChange?.(e.target.value),
|
|
1240
|
+
onKeyDown: (e) => {
|
|
1241
|
+
if (!adCodeMode || e.key !== "Enter") return;
|
|
1242
|
+
const typed = parseAdCodes(value ?? "");
|
|
1243
|
+
if (!typed.length) return;
|
|
1244
|
+
e.preventDefault();
|
|
1245
|
+
onAdCodesChange?.(mergeAdCodes(adCodes, typed));
|
|
1246
|
+
onChange?.("");
|
|
1247
|
+
},
|
|
1248
|
+
placeholder: adCodeMode && adCodes.length === 0 ? "Enter ad codes, then press Enter" : placeholder,
|
|
1249
|
+
"aria-label": placeholder,
|
|
1250
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-search`,
|
|
1251
|
+
className: "min-w-0 flex-1 bg-transparent text-dense text-text-primary outline-hidden placeholder:text-text-tertiary"
|
|
1252
|
+
}
|
|
1253
|
+
),
|
|
1254
|
+
adCodeMode && codesOpen && adCodes.length > 0 && /* @__PURE__ */ jsxs8(
|
|
1255
|
+
"div",
|
|
1256
|
+
{
|
|
1257
|
+
ref: codesPopover,
|
|
1258
|
+
role: "dialog",
|
|
1259
|
+
"aria-label": "Ad codes",
|
|
1260
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-ad-codes-popover`,
|
|
1261
|
+
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",
|
|
1262
|
+
children: [
|
|
1263
|
+
/* @__PURE__ */ jsx9("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"}` }),
|
|
1264
|
+
/* @__PURE__ */ jsx9("ul", { className: "flex max-h-50 flex-wrap gap-2 overflow-y-auto p-0.5", children: adCodes.map((code, i) => {
|
|
1265
|
+
const missed = !!isAdCodeMatched && !isAdCodeMatched(code);
|
|
1266
|
+
return /* @__PURE__ */ jsxs8(
|
|
1267
|
+
"li",
|
|
1268
|
+
{
|
|
1269
|
+
className: cx2(
|
|
1270
|
+
"inline-flex items-center gap-1 rounded-full py-1 pl-2.5 pr-1.5 text-card-title",
|
|
1271
|
+
missed ? "bg-status-danger/15 text-text-danger" : "bg-subtle text-text-primary"
|
|
1272
|
+
),
|
|
1273
|
+
children: [
|
|
1274
|
+
code,
|
|
1275
|
+
missed && /* @__PURE__ */ jsx9("span", { className: "sr-only", children: " (not found)" }),
|
|
1276
|
+
/* @__PURE__ */ jsx9(
|
|
1277
|
+
"button",
|
|
1278
|
+
{
|
|
1279
|
+
type: "button",
|
|
1280
|
+
"data-remove-code": "",
|
|
1281
|
+
"aria-label": `Remove ${code}`,
|
|
1282
|
+
onClick: () => updateCodes(adCodes.filter((c) => c !== code), i),
|
|
1283
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-ad-code-remove-${slug3(code)}`,
|
|
1284
|
+
className: "inline-flex rounded-full p-0.5 hover:bg-surface focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
|
|
1285
|
+
children: /* @__PURE__ */ jsx9(X2, { size: 13, "aria-hidden": "true" })
|
|
1286
|
+
}
|
|
1287
|
+
)
|
|
1288
|
+
]
|
|
1289
|
+
},
|
|
1290
|
+
code
|
|
1291
|
+
);
|
|
1292
|
+
}) }),
|
|
1293
|
+
/* @__PURE__ */ jsx9("div", { className: "mt-3 flex justify-end", children: /* @__PURE__ */ jsx9(
|
|
1294
|
+
"button",
|
|
1295
|
+
{
|
|
1296
|
+
type: "button",
|
|
1297
|
+
onClick: () => {
|
|
1298
|
+
setCodesOpen(false);
|
|
1299
|
+
input.current?.focus();
|
|
1300
|
+
},
|
|
1301
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-ad-codes-done`,
|
|
1302
|
+
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",
|
|
1303
|
+
children: "Search"
|
|
1304
|
+
}
|
|
1305
|
+
) }),
|
|
1306
|
+
onDownloadAdCodes && /* @__PURE__ */ jsxs8("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: [
|
|
1307
|
+
/* @__PURE__ */ jsx9(AlertCircle, { size: 16, "aria-hidden": "true", className: "mt-0.5 shrink-0 text-text-tertiary" }),
|
|
1308
|
+
/* @__PURE__ */ jsxs8("span", { children: [
|
|
1309
|
+
hasMisses && "Some ad codes in your search could not be matched. ",
|
|
1310
|
+
/* @__PURE__ */ jsx9(
|
|
1311
|
+
"button",
|
|
1312
|
+
{
|
|
1313
|
+
type: "button",
|
|
1314
|
+
onClick: () => onDownloadAdCodes(adCodes),
|
|
1315
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-ad-codes-download`,
|
|
1316
|
+
className: "font-medium text-text-link underline focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
|
|
1317
|
+
children: "Download"
|
|
1318
|
+
}
|
|
1319
|
+
),
|
|
1320
|
+
" ",
|
|
1321
|
+
hasMisses ? "the results to see the status of each ad code." : "the list of ad codes with their status."
|
|
1322
|
+
] })
|
|
1323
|
+
] })
|
|
1324
|
+
]
|
|
1325
|
+
}
|
|
1326
|
+
)
|
|
1327
|
+
]
|
|
1328
|
+
}
|
|
1329
|
+
),
|
|
1141
1330
|
value && onChange && /* @__PURE__ */ jsx9(
|
|
1142
1331
|
"button",
|
|
1143
1332
|
{
|
|
@@ -1283,34 +1472,40 @@ function ModeRow({
|
|
|
1283
1472
|
onSelect,
|
|
1284
1473
|
testId
|
|
1285
1474
|
}) {
|
|
1475
|
+
const descId = useId3();
|
|
1286
1476
|
return /* @__PURE__ */ jsxs8(
|
|
1287
1477
|
"div",
|
|
1288
1478
|
{
|
|
1289
|
-
role: "radio",
|
|
1290
|
-
tabIndex: 0,
|
|
1291
|
-
"aria-checked": selected,
|
|
1292
|
-
"data-testid": testId,
|
|
1293
1479
|
onClick: onSelect,
|
|
1294
|
-
|
|
1295
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
1296
|
-
e.preventDefault();
|
|
1297
|
-
onSelect();
|
|
1298
|
-
}
|
|
1299
|
-
},
|
|
1300
|
-
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",
|
|
1480
|
+
className: "flex cursor-pointer flex-col items-stretch gap-1 rounded-control p-1.5 text-left transition-colors hover:bg-subtle",
|
|
1301
1481
|
children: [
|
|
1302
1482
|
/* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1303
1483
|
/* @__PURE__ */ jsxs8("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
1304
1484
|
/* @__PURE__ */ jsxs8("span", { className: "flex items-center gap-1", children: [
|
|
1305
|
-
/* @__PURE__ */ jsx9(
|
|
1485
|
+
/* @__PURE__ */ jsx9(
|
|
1486
|
+
"button",
|
|
1487
|
+
{
|
|
1488
|
+
type: "button",
|
|
1489
|
+
role: "radio",
|
|
1490
|
+
"aria-checked": selected,
|
|
1491
|
+
"aria-describedby": descId,
|
|
1492
|
+
"data-testid": testId,
|
|
1493
|
+
onClick: (e) => {
|
|
1494
|
+
e.stopPropagation();
|
|
1495
|
+
onSelect();
|
|
1496
|
+
},
|
|
1497
|
+
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",
|
|
1498
|
+
children: title
|
|
1499
|
+
}
|
|
1500
|
+
),
|
|
1306
1501
|
/* @__PURE__ */ jsx9(RowInfoTip, { text: infoText })
|
|
1307
1502
|
] }),
|
|
1308
|
-
badge && /* @__PURE__ */ jsx9(
|
|
1503
|
+
badge && /* @__PURE__ */ jsx9(Badge, { kind: "category", children: badge }),
|
|
1309
1504
|
extra
|
|
1310
1505
|
] }),
|
|
1311
1506
|
selected && /* @__PURE__ */ jsx9(Check3, { size: 16, strokeWidth: 2.5, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" })
|
|
1312
1507
|
] }),
|
|
1313
|
-
/* @__PURE__ */ jsx9("span", { className: "block text-[12.5px] leading-snug text-text-secondary", children: description })
|
|
1508
|
+
/* @__PURE__ */ jsx9("span", { id: descId, className: "block text-[12.5px] leading-snug text-text-secondary", children: description })
|
|
1314
1509
|
]
|
|
1315
1510
|
}
|
|
1316
1511
|
);
|
|
@@ -1373,7 +1568,7 @@ function RowInfoTip({ text }) {
|
|
|
1373
1568
|
"aria-label": "More information",
|
|
1374
1569
|
"aria-expanded": open,
|
|
1375
1570
|
"aria-describedby": id,
|
|
1376
|
-
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",
|
|
1571
|
+
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",
|
|
1377
1572
|
children: /* @__PURE__ */ jsx9(AlertCircle, { size: 13, "aria-hidden": "true" })
|
|
1378
1573
|
}
|
|
1379
1574
|
),
|
|
@@ -1560,7 +1755,7 @@ function Option({
|
|
|
1560
1755
|
}
|
|
1561
1756
|
|
|
1562
1757
|
// src/SelectFilter.tsx
|
|
1563
|
-
import { useCallback as useCallback2, useEffect as useEffect6, useLayoutEffect as
|
|
1758
|
+
import { useCallback as useCallback2, useEffect as useEffect6, useLayoutEffect as useLayoutEffect3, useRef as useRef7, useState as useState6 } from "react";
|
|
1564
1759
|
import { createPortal as createPortal2 } from "react-dom";
|
|
1565
1760
|
import { Check as Check5, ChevronDown as ChevronDown5 } from "lucide-react";
|
|
1566
1761
|
|
|
@@ -1590,7 +1785,7 @@ import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
|
1590
1785
|
function cx4(...classes) {
|
|
1591
1786
|
return classes.filter(Boolean).join(" ");
|
|
1592
1787
|
}
|
|
1593
|
-
function
|
|
1788
|
+
function slug4(value) {
|
|
1594
1789
|
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
|
|
1595
1790
|
}
|
|
1596
1791
|
function OptionIcon({ children }) {
|
|
@@ -1632,7 +1827,7 @@ function SelectFilter({
|
|
|
1632
1827
|
const above = r.bottom + 8 + h > window.innerHeight && r.top - 8 - h > 0;
|
|
1633
1828
|
setPos({ top: above ? r.top - 8 - h : r.bottom + 8, left: align === "right" ? r.right - r.width : r.left, width: r.width });
|
|
1634
1829
|
}, [align, options.length]);
|
|
1635
|
-
|
|
1830
|
+
useLayoutEffect3(() => {
|
|
1636
1831
|
if (!open) return;
|
|
1637
1832
|
reposition();
|
|
1638
1833
|
}, [open, reposition]);
|
|
@@ -1710,7 +1905,7 @@ function SelectFilter({
|
|
|
1710
1905
|
type: "button",
|
|
1711
1906
|
role: "option",
|
|
1712
1907
|
"aria-selected": selected,
|
|
1713
|
-
"data-testid": testIdPrefix && `${testIdPrefix}-option-${
|
|
1908
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-option-${slug4(o)}`,
|
|
1714
1909
|
onClick: () => {
|
|
1715
1910
|
onChange(o);
|
|
1716
1911
|
close();
|
|
@@ -2110,7 +2305,7 @@ function StackedColumnPlaceholder({
|
|
|
2110
2305
|
}
|
|
2111
2306
|
|
|
2112
2307
|
// src/Tooltip.tsx
|
|
2113
|
-
import { useEffect as useEffect8, useId as useId4, useLayoutEffect as
|
|
2308
|
+
import { useEffect as useEffect8, useId as useId4, useLayoutEffect as useLayoutEffect4, useRef as useRef9, useState as useState8 } from "react";
|
|
2114
2309
|
import { createPortal as createPortal3 } from "react-dom";
|
|
2115
2310
|
import { jsx as jsx22, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2116
2311
|
function cx6(...parts) {
|
|
@@ -2276,7 +2471,7 @@ function Tooltip({
|
|
|
2276
2471
|
window.addEventListener("keydown", onKey);
|
|
2277
2472
|
return () => window.removeEventListener("keydown", onKey);
|
|
2278
2473
|
}, [anchor]);
|
|
2279
|
-
|
|
2474
|
+
useLayoutEffect4(() => {
|
|
2280
2475
|
if (!anchor) return;
|
|
2281
2476
|
const el = boxRef.current;
|
|
2282
2477
|
if (!el) return;
|
|
@@ -2417,7 +2612,7 @@ function SelectedSection({ count, open, onToggle, children, testIdPrefix }) {
|
|
|
2417
2612
|
}
|
|
2418
2613
|
|
|
2419
2614
|
// src/SelectionPicker.tsx
|
|
2420
|
-
import { useCallback as useCallback3, useEffect as useEffect9, useLayoutEffect as
|
|
2615
|
+
import { useCallback as useCallback3, useEffect as useEffect9, useLayoutEffect as useLayoutEffect5, useMemo as useMemo3, useRef as useRef11, useState as useState9 } from "react";
|
|
2421
2616
|
import { createPortal as createPortal4 } from "react-dom";
|
|
2422
2617
|
import { Search as Search4, Plus as Plus2, Info as Info2, ChevronRight as ChevronRight3, ChevronDown as ChevronDown8, Check as Check6, List, Loader2 } from "lucide-react";
|
|
2423
2618
|
|
|
@@ -2518,7 +2713,7 @@ import { Fragment as Fragment3, jsx as jsx27, jsxs as jsxs25 } from "react/jsx-r
|
|
|
2518
2713
|
function cx8(...parts) {
|
|
2519
2714
|
return parts.filter(Boolean).join(" ");
|
|
2520
2715
|
}
|
|
2521
|
-
function
|
|
2716
|
+
function slug5(value) {
|
|
2522
2717
|
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
|
|
2523
2718
|
}
|
|
2524
2719
|
function SelectionPicker({
|
|
@@ -2715,7 +2910,7 @@ function SelectionPicker({
|
|
|
2715
2910
|
checked: isSel,
|
|
2716
2911
|
onChange: () => toggleRow(row),
|
|
2717
2912
|
ariaLabel: row.name,
|
|
2718
|
-
testId: testIdPrefix && `${testIdPrefix}-row-${
|
|
2913
|
+
testId: testIdPrefix && `${testIdPrefix}-row-${slug5(row.id)}`
|
|
2719
2914
|
}
|
|
2720
2915
|
),
|
|
2721
2916
|
/* @__PURE__ */ jsx27("div", { className: cx8("grid gap-2 text-dense text-text-primary", gridForColumns(columns)), children: columns.map((c) => /* @__PURE__ */ jsx27("span", { className: cx8("truncate", c.className), children: c.render(row) }, c.key)) }),
|
|
@@ -2906,7 +3101,7 @@ function FilterDropdown({
|
|
|
2906
3101
|
const [pos, setPos] = useState9(null);
|
|
2907
3102
|
const searchable = filter.options.length > 8;
|
|
2908
3103
|
const shownOptions = searchable && q.trim() ? filter.options.filter((o) => o.toLowerCase().includes(q.trim().toLowerCase())) : filter.options;
|
|
2909
|
-
|
|
3104
|
+
useLayoutEffect5(() => {
|
|
2910
3105
|
if (!open || !btnRef.current) return;
|
|
2911
3106
|
const r = btnRef.current.getBoundingClientRect();
|
|
2912
3107
|
setPos({ top: r.bottom + 6, left: r.left });
|
|
@@ -2933,7 +3128,7 @@ function FilterDropdown({
|
|
|
2933
3128
|
}, [open]);
|
|
2934
3129
|
const count = active.size;
|
|
2935
3130
|
const label = count === 0 ? filter.label : count === 1 ? [...active][0] : "Multiple";
|
|
2936
|
-
const filterSlug =
|
|
3131
|
+
const filterSlug = slug5(filter.label);
|
|
2937
3132
|
return /* @__PURE__ */ jsxs25("div", { className: "relative", children: [
|
|
2938
3133
|
/* @__PURE__ */ jsxs25(
|
|
2939
3134
|
"button",
|
|
@@ -2986,7 +3181,7 @@ function FilterDropdown({
|
|
|
2986
3181
|
checked: on,
|
|
2987
3182
|
onChange: () => onToggle(opt),
|
|
2988
3183
|
ariaLabel: opt,
|
|
2989
|
-
testId: testIdPrefix && `${testIdPrefix}-filter-${filterSlug}-${
|
|
3184
|
+
testId: testIdPrefix && `${testIdPrefix}-filter-${filterSlug}-${slug5(opt)}`
|
|
2990
3185
|
}
|
|
2991
3186
|
),
|
|
2992
3187
|
opt
|