@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.d.cts
CHANGED
|
@@ -56,16 +56,19 @@ declare function InfoTip({ text, size, label, trigger }: InfoTipProps): react.JS
|
|
|
56
56
|
* @pattern AdvertiserQuickFilter
|
|
57
57
|
* @status stable
|
|
58
58
|
* @description Search-first quick filter. Mirrors the standard filter-chip
|
|
59
|
-
* shape (two-line caption + value + chevron) but never preloads the
|
|
60
|
-
* list -- users must search first, since the advertiser pool is
|
|
61
|
-
* endless.
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
59
|
+
* shape (two-line caption + value + chevron) but by default never preloads the
|
|
60
|
+
* option list -- users must search first, since the advertiser pool is
|
|
61
|
+
* effectively endless. With `prepopulate`, a short, known list (leagues,
|
|
62
|
+
* brands on one dashboard) shows in full on open and the search box only
|
|
63
|
+
* narrows it; `pageSize` then lists it a page at a time. Selections are pinned
|
|
64
|
+
* in a "Selected (n)" section at the top so they're never lost when the user
|
|
65
|
+
* runs another search. Named for its original (and still primary) use, but
|
|
66
|
+
* the copy props make it reusable for any dimension that's also search-first
|
|
67
|
+
* in its own filter tray, so the dimension reads the same in the quick bar as
|
|
68
|
+
* it does there.
|
|
66
69
|
* @tokens text-control-caption, rounded-control, rounded-card, border-border-default, border-border-strong,
|
|
67
70
|
* border-border-interactive, border-border-focus, bg-surface, bg-input,
|
|
68
|
-
* shadow-overlay, text-text-primary, text-text-secondary, text-text-tertiary,
|
|
71
|
+
* shadow-overlay, text-xs, text-text-primary, text-text-secondary, text-text-tertiary,
|
|
69
72
|
* text-text-link, bg-brand-primaryAction, text-brand-onprimary,
|
|
70
73
|
* hover:bg-subtle, hover:text-text-primary, placeholder:text-text-tertiary
|
|
71
74
|
* @dependencies lucide-react
|
|
@@ -75,15 +78,21 @@ declare function InfoTip({ text, size, label, trigger }: InfoTipProps): react.JS
|
|
|
75
78
|
* to `onChange`. With `showFooter`, only the Apply button commits -- every
|
|
76
79
|
* other close path discards the draft, so the trigger label never previews
|
|
77
80
|
* an unapplied change. The pinned "selected" section persists across
|
|
78
|
-
* searches and collapses when the search is cleared.
|
|
81
|
+
* searches and collapses when the search is cleared. With `pageSize`, a new
|
|
82
|
+
* query or reopening the tray goes back to the first page.
|
|
79
83
|
* @a11y Trigger is a <button> with aria-expanded and aria-haspopup; the menu is
|
|
80
84
|
* role="dialog", closed on Escape. Option rows are role="checkbox" with
|
|
81
85
|
* aria-checked, so each row is itself the control -- don't wrap them in
|
|
82
|
-
* another clickable element.
|
|
86
|
+
* another clickable element. With `prepopulate`, a visually hidden
|
|
87
|
+
* role="status" line announces the result count ("12 results, showing 10")
|
|
88
|
+
* as the list changes. "Show N more" is a real <button>; after it loads a
|
|
89
|
+
* page, focus moves to the first new option, so keyboard users continue
|
|
90
|
+
* where the list grew instead of losing focus when the button goes away.
|
|
83
91
|
* @usage
|
|
84
92
|
* ```tsx
|
|
85
93
|
* <AdvertiserQuickFilter options={advertisers} selected={selected} onChange={setSelected} />
|
|
86
94
|
* <AdvertiserQuickFilter options={advertisers} selected={selected} onChange={setSelected} showFooter clearValue={defaults} />
|
|
95
|
+
* <AdvertiserQuickFilter caption="League" options={leagues} selected={selected} onChange={setSelected} prepopulate pageSize={10} />
|
|
87
96
|
* ```
|
|
88
97
|
*/
|
|
89
98
|
interface AdvertiserQuickFilterProps {
|
|
@@ -113,6 +122,19 @@ interface AdvertiserQuickFilterProps {
|
|
|
113
122
|
* selection -- still committed back, still removable -- but they narrow
|
|
114
123
|
* nothing, so the trigger label leaves them out of the count. */
|
|
115
124
|
parked?: string[];
|
|
125
|
+
/**
|
|
126
|
+
* List every option as soon as the tray opens, instead of the "start
|
|
127
|
+
* typing" prompt; the search box then only narrows the list. For a short,
|
|
128
|
+
* known list. Leave it off for an effectively endless pool (advertisers).
|
|
129
|
+
* Defaults to false: search first, exactly as before.
|
|
130
|
+
*/
|
|
131
|
+
prepopulate?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* With `prepopulate`: list this many rows at a time, with a "Show N more"
|
|
134
|
+
* button for the next page. Omit to list every option. Ignored without
|
|
135
|
+
* `prepopulate`.
|
|
136
|
+
*/
|
|
137
|
+
pageSize?: number;
|
|
116
138
|
/** Search box placeholder. Override alongside the other copy props when
|
|
117
139
|
* the filter isn't advertisers, so the empty and no-results states name
|
|
118
140
|
* the right dimension. */
|
|
@@ -128,7 +150,8 @@ interface AdvertiserQuickFilterProps {
|
|
|
128
150
|
* (`${testIdPrefix}-trigger`), the popover (`-popover`), the search input
|
|
129
151
|
* (`-search`), the selected-section toggle (`-selected-toggle`), the
|
|
130
152
|
* select-all-visible row (`-select-all-visible`), each option row
|
|
131
|
-
* (`-option-<slugified-id>`),
|
|
153
|
+
* (`-option-<slugified-id>`), the "Show N more" row (`-show-more`), and
|
|
154
|
+
* the footer's Clear All (`-clear-all`) and
|
|
132
155
|
* Apply (`-apply`). Omit entirely for no test-id wiring at all --
|
|
133
156
|
* added specifically so an existing Playwright suite keyed off these ids
|
|
134
157
|
* (mr-clientapps' `AdvertisersPicker`) doesn't lose its locators when
|
|
@@ -136,7 +159,7 @@ interface AdvertiserQuickFilterProps {
|
|
|
136
159
|
*/
|
|
137
160
|
testIdPrefix?: string;
|
|
138
161
|
}
|
|
139
|
-
declare function AdvertiserQuickFilter({ caption, options, selected, onChange, align, icon, showFooter, clearValue, parked, searchPlaceholder, promptLabel, noResultsHint, clearLabel, testIdPrefix, }: AdvertiserQuickFilterProps): react.JSX.Element;
|
|
162
|
+
declare function AdvertiserQuickFilter({ caption, options, selected, onChange, align, icon, showFooter, clearValue, parked, prepopulate, pageSize, searchPlaceholder, promptLabel, noResultsHint, clearLabel, testIdPrefix, }: AdvertiserQuickFilterProps): react.JSX.Element;
|
|
140
163
|
|
|
141
164
|
/**
|
|
142
165
|
* @pattern AdvertiserSearchPrompt
|
|
@@ -576,10 +599,13 @@ declare function DateRangeFilter({ caption, defaultValue, value: controlledValue
|
|
|
576
599
|
* sub-choice nested under Any Word.
|
|
577
600
|
* Three heights on the one control scale -- sm 32, md 40, lg 44 (default) --
|
|
578
601
|
* so it lines up with the Buttons and dropdowns beside it. A × clears the
|
|
579
|
-
* text once something is typed.
|
|
580
|
-
*
|
|
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,
|
|
581
606
|
* focus-within:outline-offset-1, rounded-control, border-border-strong, bg-input, text-text-primary,
|
|
582
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,
|
|
583
609
|
* bg-surface, border-brand-primaryAction, border-border-default,
|
|
584
610
|
* border-border-interactive, focus-visible:outline-border-focus,
|
|
585
611
|
* hover:text-text-primary, placeholder:text-text-tertiary, rounded-card,
|
|
@@ -598,19 +624,40 @@ declare function DateRangeFilter({ caption, defaultValue, value: controlledValue
|
|
|
598
624
|
* input), so it grants the input no accessible name on its own. The clear
|
|
599
625
|
* × shows only when there's text and `onChange` is given; it empties the
|
|
600
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`).
|
|
601
640
|
* @a11y The <input> takes its accessible name from `ariaLabel`. The match-mode
|
|
602
641
|
* popover is a radio group (role="radio" + aria-checked) and its trigger
|
|
603
642
|
* reports aria-expanded. Escape closes the popover only, leaving focus in
|
|
604
643
|
* the field -- a consumer nesting this inside another dismissible layer
|
|
605
|
-
* must sequence the two dismissals itself.
|
|
606
|
-
*
|
|
607
|
-
*
|
|
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).
|
|
608
651
|
* @use the size of the controls beside it.
|
|
609
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.
|
|
610
655
|
* @usage
|
|
611
656
|
* ```tsx
|
|
612
657
|
* <SearchBar value={query} onChange={setQuery} />
|
|
613
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} />
|
|
614
661
|
* ```
|
|
615
662
|
*/
|
|
616
663
|
type SearchBarVariant = "default" | "filterable";
|
|
@@ -635,13 +682,32 @@ interface SearchBarProps {
|
|
|
635
682
|
/** The 'filterable' variant's dropdown state. */
|
|
636
683
|
matchValue?: SearchMatchValue;
|
|
637
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;
|
|
638
700
|
className?: string;
|
|
639
701
|
/**
|
|
640
702
|
* Optional prefix for `data-testid` attributes on the input
|
|
641
703
|
* (`${testIdPrefix}-search`), its clear button (`-clear`), the match-type
|
|
642
704
|
* trigger (`-mode-trigger`) and popover (`-mode-popover`), each mode row
|
|
643
705
|
* (`-mode-anyWord`, `-mode-exactMatch`, `-mode-contextual`, `-mode-adCode`),
|
|
644
|
-
*
|
|
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
|
|
645
711
|
* entirely for no test-id wiring at all -- added specifically so an
|
|
646
712
|
* existing Playwright suite keyed off these ids (mr-clientapps'
|
|
647
713
|
* `KeywordSearchBar`) doesn't lose its locators when swapped over to
|
|
@@ -649,7 +715,7 @@ interface SearchBarProps {
|
|
|
649
715
|
*/
|
|
650
716
|
testIdPrefix?: string;
|
|
651
717
|
}
|
|
652
|
-
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;
|
|
653
719
|
|
|
654
720
|
/**
|
|
655
721
|
* @pattern SectionRail
|
package/dist/index.d.ts
CHANGED
|
@@ -56,16 +56,19 @@ declare function InfoTip({ text, size, label, trigger }: InfoTipProps): react.JS
|
|
|
56
56
|
* @pattern AdvertiserQuickFilter
|
|
57
57
|
* @status stable
|
|
58
58
|
* @description Search-first quick filter. Mirrors the standard filter-chip
|
|
59
|
-
* shape (two-line caption + value + chevron) but never preloads the
|
|
60
|
-
* list -- users must search first, since the advertiser pool is
|
|
61
|
-
* endless.
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
59
|
+
* shape (two-line caption + value + chevron) but by default never preloads the
|
|
60
|
+
* option list -- users must search first, since the advertiser pool is
|
|
61
|
+
* effectively endless. With `prepopulate`, a short, known list (leagues,
|
|
62
|
+
* brands on one dashboard) shows in full on open and the search box only
|
|
63
|
+
* narrows it; `pageSize` then lists it a page at a time. Selections are pinned
|
|
64
|
+
* in a "Selected (n)" section at the top so they're never lost when the user
|
|
65
|
+
* runs another search. Named for its original (and still primary) use, but
|
|
66
|
+
* the copy props make it reusable for any dimension that's also search-first
|
|
67
|
+
* in its own filter tray, so the dimension reads the same in the quick bar as
|
|
68
|
+
* it does there.
|
|
66
69
|
* @tokens text-control-caption, rounded-control, rounded-card, border-border-default, border-border-strong,
|
|
67
70
|
* border-border-interactive, border-border-focus, bg-surface, bg-input,
|
|
68
|
-
* shadow-overlay, text-text-primary, text-text-secondary, text-text-tertiary,
|
|
71
|
+
* shadow-overlay, text-xs, text-text-primary, text-text-secondary, text-text-tertiary,
|
|
69
72
|
* text-text-link, bg-brand-primaryAction, text-brand-onprimary,
|
|
70
73
|
* hover:bg-subtle, hover:text-text-primary, placeholder:text-text-tertiary
|
|
71
74
|
* @dependencies lucide-react
|
|
@@ -75,15 +78,21 @@ declare function InfoTip({ text, size, label, trigger }: InfoTipProps): react.JS
|
|
|
75
78
|
* to `onChange`. With `showFooter`, only the Apply button commits -- every
|
|
76
79
|
* other close path discards the draft, so the trigger label never previews
|
|
77
80
|
* an unapplied change. The pinned "selected" section persists across
|
|
78
|
-
* searches and collapses when the search is cleared.
|
|
81
|
+
* searches and collapses when the search is cleared. With `pageSize`, a new
|
|
82
|
+
* query or reopening the tray goes back to the first page.
|
|
79
83
|
* @a11y Trigger is a <button> with aria-expanded and aria-haspopup; the menu is
|
|
80
84
|
* role="dialog", closed on Escape. Option rows are role="checkbox" with
|
|
81
85
|
* aria-checked, so each row is itself the control -- don't wrap them in
|
|
82
|
-
* another clickable element.
|
|
86
|
+
* another clickable element. With `prepopulate`, a visually hidden
|
|
87
|
+
* role="status" line announces the result count ("12 results, showing 10")
|
|
88
|
+
* as the list changes. "Show N more" is a real <button>; after it loads a
|
|
89
|
+
* page, focus moves to the first new option, so keyboard users continue
|
|
90
|
+
* where the list grew instead of losing focus when the button goes away.
|
|
83
91
|
* @usage
|
|
84
92
|
* ```tsx
|
|
85
93
|
* <AdvertiserQuickFilter options={advertisers} selected={selected} onChange={setSelected} />
|
|
86
94
|
* <AdvertiserQuickFilter options={advertisers} selected={selected} onChange={setSelected} showFooter clearValue={defaults} />
|
|
95
|
+
* <AdvertiserQuickFilter caption="League" options={leagues} selected={selected} onChange={setSelected} prepopulate pageSize={10} />
|
|
87
96
|
* ```
|
|
88
97
|
*/
|
|
89
98
|
interface AdvertiserQuickFilterProps {
|
|
@@ -113,6 +122,19 @@ interface AdvertiserQuickFilterProps {
|
|
|
113
122
|
* selection -- still committed back, still removable -- but they narrow
|
|
114
123
|
* nothing, so the trigger label leaves them out of the count. */
|
|
115
124
|
parked?: string[];
|
|
125
|
+
/**
|
|
126
|
+
* List every option as soon as the tray opens, instead of the "start
|
|
127
|
+
* typing" prompt; the search box then only narrows the list. For a short,
|
|
128
|
+
* known list. Leave it off for an effectively endless pool (advertisers).
|
|
129
|
+
* Defaults to false: search first, exactly as before.
|
|
130
|
+
*/
|
|
131
|
+
prepopulate?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* With `prepopulate`: list this many rows at a time, with a "Show N more"
|
|
134
|
+
* button for the next page. Omit to list every option. Ignored without
|
|
135
|
+
* `prepopulate`.
|
|
136
|
+
*/
|
|
137
|
+
pageSize?: number;
|
|
116
138
|
/** Search box placeholder. Override alongside the other copy props when
|
|
117
139
|
* the filter isn't advertisers, so the empty and no-results states name
|
|
118
140
|
* the right dimension. */
|
|
@@ -128,7 +150,8 @@ interface AdvertiserQuickFilterProps {
|
|
|
128
150
|
* (`${testIdPrefix}-trigger`), the popover (`-popover`), the search input
|
|
129
151
|
* (`-search`), the selected-section toggle (`-selected-toggle`), the
|
|
130
152
|
* select-all-visible row (`-select-all-visible`), each option row
|
|
131
|
-
* (`-option-<slugified-id>`),
|
|
153
|
+
* (`-option-<slugified-id>`), the "Show N more" row (`-show-more`), and
|
|
154
|
+
* the footer's Clear All (`-clear-all`) and
|
|
132
155
|
* Apply (`-apply`). Omit entirely for no test-id wiring at all --
|
|
133
156
|
* added specifically so an existing Playwright suite keyed off these ids
|
|
134
157
|
* (mr-clientapps' `AdvertisersPicker`) doesn't lose its locators when
|
|
@@ -136,7 +159,7 @@ interface AdvertiserQuickFilterProps {
|
|
|
136
159
|
*/
|
|
137
160
|
testIdPrefix?: string;
|
|
138
161
|
}
|
|
139
|
-
declare function AdvertiserQuickFilter({ caption, options, selected, onChange, align, icon, showFooter, clearValue, parked, searchPlaceholder, promptLabel, noResultsHint, clearLabel, testIdPrefix, }: AdvertiserQuickFilterProps): react.JSX.Element;
|
|
162
|
+
declare function AdvertiserQuickFilter({ caption, options, selected, onChange, align, icon, showFooter, clearValue, parked, prepopulate, pageSize, searchPlaceholder, promptLabel, noResultsHint, clearLabel, testIdPrefix, }: AdvertiserQuickFilterProps): react.JSX.Element;
|
|
140
163
|
|
|
141
164
|
/**
|
|
142
165
|
* @pattern AdvertiserSearchPrompt
|
|
@@ -576,10 +599,13 @@ declare function DateRangeFilter({ caption, defaultValue, value: controlledValue
|
|
|
576
599
|
* sub-choice nested under Any Word.
|
|
577
600
|
* Three heights on the one control scale -- sm 32, md 40, lg 44 (default) --
|
|
578
601
|
* so it lines up with the Buttons and dropdowns beside it. A × clears the
|
|
579
|
-
* text once something is typed.
|
|
580
|
-
*
|
|
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,
|
|
581
606
|
* focus-within:outline-offset-1, rounded-control, border-border-strong, bg-input, text-text-primary,
|
|
582
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,
|
|
583
609
|
* bg-surface, border-brand-primaryAction, border-border-default,
|
|
584
610
|
* border-border-interactive, focus-visible:outline-border-focus,
|
|
585
611
|
* hover:text-text-primary, placeholder:text-text-tertiary, rounded-card,
|
|
@@ -598,19 +624,40 @@ declare function DateRangeFilter({ caption, defaultValue, value: controlledValue
|
|
|
598
624
|
* input), so it grants the input no accessible name on its own. The clear
|
|
599
625
|
* × shows only when there's text and `onChange` is given; it empties the
|
|
600
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`).
|
|
601
640
|
* @a11y The <input> takes its accessible name from `ariaLabel`. The match-mode
|
|
602
641
|
* popover is a radio group (role="radio" + aria-checked) and its trigger
|
|
603
642
|
* reports aria-expanded. Escape closes the popover only, leaving focus in
|
|
604
643
|
* the field -- a consumer nesting this inside another dismissible layer
|
|
605
|
-
* must sequence the two dismissals itself.
|
|
606
|
-
*
|
|
607
|
-
*
|
|
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).
|
|
608
651
|
* @use the size of the controls beside it.
|
|
609
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.
|
|
610
655
|
* @usage
|
|
611
656
|
* ```tsx
|
|
612
657
|
* <SearchBar value={query} onChange={setQuery} />
|
|
613
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} />
|
|
614
661
|
* ```
|
|
615
662
|
*/
|
|
616
663
|
type SearchBarVariant = "default" | "filterable";
|
|
@@ -635,13 +682,32 @@ interface SearchBarProps {
|
|
|
635
682
|
/** The 'filterable' variant's dropdown state. */
|
|
636
683
|
matchValue?: SearchMatchValue;
|
|
637
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;
|
|
638
700
|
className?: string;
|
|
639
701
|
/**
|
|
640
702
|
* Optional prefix for `data-testid` attributes on the input
|
|
641
703
|
* (`${testIdPrefix}-search`), its clear button (`-clear`), the match-type
|
|
642
704
|
* trigger (`-mode-trigger`) and popover (`-mode-popover`), each mode row
|
|
643
705
|
* (`-mode-anyWord`, `-mode-exactMatch`, `-mode-contextual`, `-mode-adCode`),
|
|
644
|
-
*
|
|
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
|
|
645
711
|
* entirely for no test-id wiring at all -- added specifically so an
|
|
646
712
|
* existing Playwright suite keyed off these ids (mr-clientapps'
|
|
647
713
|
* `KeywordSearchBar`) doesn't lose its locators when swapped over to
|
|
@@ -649,7 +715,7 @@ interface SearchBarProps {
|
|
|
649
715
|
*/
|
|
650
716
|
testIdPrefix?: string;
|
|
651
717
|
}
|
|
652
|
-
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;
|
|
653
719
|
|
|
654
720
|
/**
|
|
655
721
|
* @pattern SectionRail
|