@mediaradar/design-components 0.40.0 → 0.42.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/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
- * @tokens text-dense, text-badge, focus-within:outline-border-focus, focus-within:outline-2,
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
- * @use for every search field: in a filter row (lg), a form (md), a toolbar or
630
- * dropdown (sm).
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
- * and the Or/And radio pair (`-word-join-or`, `-word-join-and`). Omit
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
@@ -2584,6 +2627,11 @@ interface PageHeaderProps {
2584
2627
  description?: ReactNode;
2585
2628
  /** The page's main actions, right-aligned -- usually one primary Button. */
2586
2629
  actions?: ReactNode;
2630
+ /**
2631
+ * A status on the title line, after the title -- one Badge saying what
2632
+ * state the thing this page shows is in ("Active", "Trial").
2633
+ */
2634
+ meta?: ReactNode;
2587
2635
  /**
2588
2636
  * The way back up, above the title: an arrow and the parent section's name,
2589
2637
  * "Competitive intel". Give `href`; add `onClick` to route client-side
@@ -2608,6 +2656,7 @@ interface PageHeaderProps {
2608
2656
  * title: ReactNode -- the page's name
2609
2657
  * description?: ReactNode -- one line, about 70 characters at most, on what the user can do here
2610
2658
  * actions?: ReactNode -- primary actions, right-aligned
2659
+ * meta?: ReactNode -- one status Badge on the title line
2611
2660
  * @tokens text-micro, uppercase, tracking-wider, text-text-tertiary,
2612
2661
  * hover:text-text-primary, focus-visible:outline-border-focus, rounded-control, text-xl, font-semibold, tracking-tight, text-text-primary, text-sm, text-text-secondary, max-w-2xl
2613
2662
  * @use at the top of every top-level page.
@@ -2618,6 +2667,10 @@ interface PageHeaderProps {
2618
2667
  * @avoid putting the description to the right of the title. It competes with
2619
2668
  * the actions and wraps unpredictably on narrow screens.
2620
2669
  * @avoid more than one primary action in `actions`.
2670
+ * @use `meta` on a detail page for the one status of the thing it shows (an
2671
+ * account's "Active" Badge), on the title line.
2672
+ * @avoid putting counts, dates or several pills in `meta`; that belongs in the
2673
+ * page body.
2621
2674
  * @avoid a description on every page by habit. Use one only where a first-time
2622
2675
  * user would not know what the page is for; a pipe-separated subtitle beside
2623
2676
  * the title is the pattern this replaces.
@@ -2631,9 +2684,10 @@ interface PageHeaderProps {
2631
2684
  * description="Build tables from MediaRadar data and export them whenever you need."
2632
2685
  * actions={<Button><Plus /> New report</Button>}
2633
2686
  * />
2687
+ * <PageHeader title="Northwind" back={{ label: "Accounts", href: "/accounts" }} meta={<Badge tone="success">Active</Badge>} />
2634
2688
  * ```
2635
2689
  */
2636
- declare function PageHeader({ title, description, actions, back, className }: PageHeaderProps): react.JSX.Element;
2690
+ declare function PageHeader({ title, description, actions, meta, back, className }: PageHeaderProps): react.JSX.Element;
2637
2691
 
2638
2692
  type ModalSize = "sm" | "md" | "lg" | "xl";
2639
2693
  interface ModalProps {
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
- * @tokens text-dense, text-badge, focus-within:outline-border-focus, focus-within:outline-2,
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
- * @use for every search field: in a filter row (lg), a form (md), a toolbar or
630
- * dropdown (sm).
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
- * and the Or/And radio pair (`-word-join-or`, `-word-join-and`). Omit
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
@@ -2584,6 +2627,11 @@ interface PageHeaderProps {
2584
2627
  description?: ReactNode;
2585
2628
  /** The page's main actions, right-aligned -- usually one primary Button. */
2586
2629
  actions?: ReactNode;
2630
+ /**
2631
+ * A status on the title line, after the title -- one Badge saying what
2632
+ * state the thing this page shows is in ("Active", "Trial").
2633
+ */
2634
+ meta?: ReactNode;
2587
2635
  /**
2588
2636
  * The way back up, above the title: an arrow and the parent section's name,
2589
2637
  * "Competitive intel". Give `href`; add `onClick` to route client-side
@@ -2608,6 +2656,7 @@ interface PageHeaderProps {
2608
2656
  * title: ReactNode -- the page's name
2609
2657
  * description?: ReactNode -- one line, about 70 characters at most, on what the user can do here
2610
2658
  * actions?: ReactNode -- primary actions, right-aligned
2659
+ * meta?: ReactNode -- one status Badge on the title line
2611
2660
  * @tokens text-micro, uppercase, tracking-wider, text-text-tertiary,
2612
2661
  * hover:text-text-primary, focus-visible:outline-border-focus, rounded-control, text-xl, font-semibold, tracking-tight, text-text-primary, text-sm, text-text-secondary, max-w-2xl
2613
2662
  * @use at the top of every top-level page.
@@ -2618,6 +2667,10 @@ interface PageHeaderProps {
2618
2667
  * @avoid putting the description to the right of the title. It competes with
2619
2668
  * the actions and wraps unpredictably on narrow screens.
2620
2669
  * @avoid more than one primary action in `actions`.
2670
+ * @use `meta` on a detail page for the one status of the thing it shows (an
2671
+ * account's "Active" Badge), on the title line.
2672
+ * @avoid putting counts, dates or several pills in `meta`; that belongs in the
2673
+ * page body.
2621
2674
  * @avoid a description on every page by habit. Use one only where a first-time
2622
2675
  * user would not know what the page is for; a pipe-separated subtitle beside
2623
2676
  * the title is the pattern this replaces.
@@ -2631,9 +2684,10 @@ interface PageHeaderProps {
2631
2684
  * description="Build tables from MediaRadar data and export them whenever you need."
2632
2685
  * actions={<Button><Plus /> New report</Button>}
2633
2686
  * />
2687
+ * <PageHeader title="Northwind" back={{ label: "Accounts", href: "/accounts" }} meta={<Badge tone="success">Active</Badge>} />
2634
2688
  * ```
2635
2689
  */
2636
- declare function PageHeader({ title, description, actions, back, className }: PageHeaderProps): react.JSX.Element;
2690
+ declare function PageHeader({ title, description, actions, meta, back, className }: PageHeaderProps): react.JSX.Element;
2637
2691
 
2638
2692
  type ModalSize = "sm" | "md" | "lg" | "xl";
2639
2693
  interface ModalProps {