From 6476710bb585a933dcdb99ca450ec5d30b0aa5c6 Mon Sep 17 00:00:00 2001 From: Cindy Zhang Date: Thu, 3 Dec 2026 01:16:37 -0800 Subject: [PATCH 1/4] perf(PowerSearch): value-only matches come from an opt-in import, with no on-intent load --- .changeset/powersearch-value-only-opt-in.md | 7 ++ .../storybook/stories/PowerSearch.stories.tsx | 6 +- .../PowerSearch/PowerSearch.spec.md | 16 ++- .../core/src/PowerSearch/PowerSearch.doc.mjs | 3 + .../core/src/PowerSearch/PowerSearch.test.tsx | 27 ++++- packages/core/src/PowerSearch/PowerSearch.tsx | 20 ++-- .../PowerSearchBottomSheet.test.tsx | 38 ++---- packages/core/src/PowerSearch/index.ts | 3 + packages/core/src/PowerSearch/types.ts | 17 ++- .../PowerSearch/usePowerSearchSource.test.ts | 113 +++--------------- .../src/PowerSearch/usePowerSearchSource.ts | 77 +++--------- .../src/PowerSearch/valueOnlyMatchLoader.ts | 69 ----------- .../core/src/PowerSearch/valueOnlyMatches.ts | 21 +++- .../core/src/PowerSearch/valueOnlyOptIn.ts | 38 ++++++ 14 files changed, 175 insertions(+), 280 deletions(-) create mode 100644 .changeset/powersearch-value-only-opt-in.md delete mode 100644 packages/core/src/PowerSearch/valueOnlyMatchLoader.ts create mode 100644 packages/core/src/PowerSearch/valueOnlyOptIn.ts diff --git a/.changeset/powersearch-value-only-opt-in.md b/.changeset/powersearch-value-only-opt-in.md new file mode 100644 index 0000000000000..6396eef80b7a8 --- /dev/null +++ b/.changeset/powersearch-value-only-opt-in.md @@ -0,0 +1,7 @@ +--- +'@astryxdesign/core': patch +--- + +[perf] PowerSearch: value-only matches (operators with `isValueOnlyMatchAllowed: true`) now come from an opt-in import. Pass `valueOnlyMatches: powerSearchValueOnlyMatches` in the config, imported from `@astryxdesign/core`. A page whose configs do not pass it ships none of the matcher's code, and PowerSearch no longer loads it on first focus. An opt-in in a config without the matcher lists no value-only match and warns once in development. + +@cixzhang diff --git a/apps/storybook/stories/PowerSearch.stories.tsx b/apps/storybook/stories/PowerSearch.stories.tsx index 4bb3df788c2b3..76ca25ca53951 100644 --- a/apps/storybook/stories/PowerSearch.stories.tsx +++ b/apps/storybook/stories/PowerSearch.stories.tsx @@ -2,7 +2,10 @@ import React, {useState} from 'react'; import type {Meta, StoryObj} from '@storybook/react'; -import {PowerSearch} from '@astryxdesign/core/PowerSearch'; +import { + PowerSearch, + powerSearchValueOnlyMatches, +} from '@astryxdesign/core/PowerSearch'; import type { PowerSearchConfig, PowerSearchFilter, @@ -1688,6 +1691,7 @@ const valueOnlySlowUserSource: SearchSource = { const valueOnlyConfig: PowerSearchConfig = { name: 'ValueOnlyMatches', + valueOnlyMatches: powerSearchValueOnlyMatches, contentSearchFieldKey: 'title', fields: [ { diff --git a/docs/specs/components/PowerSearch/PowerSearch.spec.md b/docs/specs/components/PowerSearch/PowerSearch.spec.md index cb607229ca190..fe488d869c9d9 100644 --- a/docs/specs/components/PowerSearch/PowerSearch.spec.md +++ b/docs/specs/components/PowerSearch/PowerSearch.spec.md @@ -250,11 +250,12 @@ Consumer migration instructions belong in consumer docs and release notes. ## Public concepts -Two stable public concepts are introduced. The first is the `presentation` +Three stable public concepts are introduced. The first is the `presentation` prop, with the values `'popover' | 'bottom-sheet' | 'adaptive'` and `adaptive` the default, typed by the exported `PowerSearchPresentation`, the value set the selection controls and Tokenizer use (DEC-3). The second is an operator's -`isValueOnlyMatchAllowed` (DEC-8), below. +`isValueOnlyMatchAllowed` (DEC-8), below. The third is the value-only matcher +that a config passes to turn those matches on, below. The inclusive 400–720 CSS px range and conditional alignment of the editor popover are internal PowerSearch readability policy, not callsite options. @@ -273,6 +274,15 @@ search-source operator answers through its existing `searchSource`. The three-ro two-character default minimum, and the 150 ms wait before a source call are internal. +The value-only matcher is a value the package exports as +`powerSearchValueOnlyMatches`, typed `PowerSearchValueOnlyMatches`. A config +passes it as `valueOnlyMatches`; an operator's opt-in answers value-only queries +only when its config has it. A page whose configs never pass it carries none of +its code, and one that passes it imports it statically +(`architecture:component-import-boundaries` INV7, INV10). An opt-in in a config +without the matcher lists no value-only match and warns once in development, +naming `valueOnlyMatches: powerSearchValueOnlyMatches`. + In the sheet presentation the props that describe the tokenizer's typeahead popover have no surface to act on: `menuWidth` and `tokenOverflowBehavior`. Passing either while a field resolves to `bottom-sheet` warns once in @@ -344,7 +354,7 @@ presentation's typeahead, and FR30 the same rows in the sheet's content search. | FR24 | In the popover presentation, a built-in filter token (no `components` Token override) that opens its editor is named by its visible text (field, operator and value); `aria-haspopup="dialog"`, `aria-expanded` is true while its editor is open, and the editor is a dialog named by the token's visible text. Its remove button is named by the remove word and the same visible text. The token's full text is one catalog message; a locale whose full token text is not the label, a space, then the value shows that text in one weight, and the accessible name and the visible text stay the same. A filter whose field the config lacks shows the field key. | `spec:AST-020` FR1; WCAG 2.5.3 and 4.1.2; `component:Token/FR10` | Current contract. | | FR25 | In both presentations a `date_absolute` value whose operator has `isDateOnly` unset or `true`, and each `ABSOLUTE` part of a `date_range` value, is a calendar day: the day its `unixSeconds` falls on in `timezoneID` when the prop is set, else the UTC day. The built-in token's text, the filter's accessible label and every announcement that names the value, the Filters row of the sheet presentation, and the date editor of either presentation all read that one day, with no time of day, so one value is never two days in one field; a `components[type].Token` override formats its own value (FR11) and receives `timezoneID` in its props, as the exported `PowerSearchToken` (the default token) does and reads, and a `components[type].Editor` override and `PowerSearchFilterEditor` receive `timezoneID` in their props so they can read the same day. A day picked in an editor is stored as that day's midnight in the same zone — `timezoneID`'s midnight, else UTC midnight — and the editor reopens on the day it stored, so an edit that keeps the day keeps the instant. Nothing about a value is rewritten by rendering or reopening: a value stored before `timezoneID` was given reads as its day in the zone now given. A `date_range` whose part is `NOW` or `RELATIVE` reads that part resolved to an instant first, then as its day. On the server and in the hydrating render, a `date_range` with a `NOW` or `RELATIVE` part reads as "date range" until the next render reads its days (`spec:AST-013` FR9); a `date_range` whose parts are all `ABSOLUTE` reads its days in every render. A value whose operator sets `isDateOnly: false` is an instant, not a calendar day: FR26 governs it. | DEC-5; `timezoneID` prop contract; `component:DateInput` (a calendar-day control) | Current contract. | | FR26 | A `date_absolute` value whose operator has `isDateOnly: false` is an instant with a time of day. In both presentations its token shows its date and time and the sheet's Filters row shows the same, and its editor reads the stored instant's wall-clock time and stores the wall-clock time entered as the instant it names, both in `timezoneID` when the prop is set, else the viewer's zone — the zone the viewer reads a clock in — so the time typed is the time shown. In the popover presentation that editor is a date picker beside a time field; the sheet presentation's control is FR17's. A `components[type].Editor` override and `PowerSearchFilterEditor` receive `timezoneID` in their props so they can read the same time. A `date_absolute` whose operator has `isDateOnly` unset or `true` keeps its date-only picker and shows no time (FR25). | DEC-6; `OperatorValue.isDateOnly` contract; `component:DateInput`; `component:TimeInput` | Current contract. | -| FR27 | An operator's `isValueOnlyMatchAllowed: true` opts it into value-only matches: the rows it offers for a value-only query, a typed query that starts with no field label, so only the value is typed ("fiction" for `Genre is Fiction`) — one that neither equals a visible field's label nor starts with one followed by a space, both compared without regard to case, as the field-prefixed value match compares them. Unset or `false`, the operator answers only the field-prefixed value match ("Work Area partner"), whose rows do not change. An opted-in operator adds no value-only match while its field's `isValueMatchAllowed` is `false` — that field's `false` turns off every value suggestion of the field, field-prefixed rows and lookups included, and the opt-in then warns once in development, naming the field and the operator — or while the trimmed query is shorter than the field's `typeaheadMinQueryLength`, else shorter than two characters. An opted-in operator whose editor takes arbitrary text — a `string` or `string_list` operator with no `searchSource`, or a `string_list` operator with `isArbitraryStringAllowed: true` — adds one free-text row whose value is the typed text as the content-search row carries it, a `string` or a one-item `string_list`; a `string` operator with a `searchSource` adds only the source rows of FR28, since its editor commits only a source item; while the content-search row shows, the content-search field's default operator adds none, since that row commits the same filter and stays first. An opted-in `enum` or `enum_list` operator adds one row for each value whose label matches the typed text from the start of one of its words (the label's start, or a position after a space or a punctuation mark), compared after the fold `architecture:internationalization/INV17` defines (case, combining marks, the six stroked letters, Turkish ı and İ); a value whose whole label matches comes first, then a label that starts with the text, then the rest, each tier in the config's value order. An opted-in operator with a `searchSource` adds the rows FR28 states. An opted-in operator of any other value type adds none. Each row's text is one catalog message with the field label, the operator label, and the value as its arguments, so a locale can reorder them (`architecture:internationalization/INV1a`): a free-text row's message carries the quotation marks around the typed text, and an enum or search-source row's value is the value's or the item's label, unquoted. In English a row reads "{field label} {operator label} {value}", as the field-prefixed value row for the same filter reads (`Title contains "partner"`, `Work Area is Partner Marketing`), and a search-source row, which has no field-prefixed counterpart, reads the same way (`Owner is Jane Doe`). Choosing a row commits exactly the filter it reads: its field, its operator, and its value — the typed text, the value's key (a one-item list for `enum_list`), or the item FR28 states — in one filter token, as the field-prefixed value row for the same filter commits it. An empty query lists the fields as it does with no operator opted in. | DEC-8; `architecture:internationalization` INV1a, INV17; `architecture:public-component-api` INV3 | Current contract; verified by `usePowerSearchSource.test.ts` and PowerSearch typeahead tests. | +| FR27 | An operator's `isValueOnlyMatchAllowed: true`, in a config whose `valueOnlyMatches` is the exported matcher, opts it into value-only matches: the rows it offers for a value-only query, a typed query that starts with no field label, so only the value is typed ("fiction" for `Genre is Fiction`) — one that neither equals a visible field's label nor starts with one followed by a space, both compared without regard to case, as the field-prefixed value match compares them. Unset or `false`, the operator answers only the field-prefixed value match ("Work Area partner"), whose rows do not change. An opted-in operator adds no value-only match while its field's `isValueMatchAllowed` is `false` — that field's `false` turns off every value suggestion of the field, field-prefixed rows and lookups included, and the opt-in then warns once in development, naming the field and the operator — or while its config has no `valueOnlyMatches`, which warns once in development — or while the trimmed query is shorter than the field's `typeaheadMinQueryLength`, else shorter than two characters. An opted-in operator whose editor takes arbitrary text — a `string` or `string_list` operator with no `searchSource`, or a `string_list` operator with `isArbitraryStringAllowed: true` — adds one free-text row whose value is the typed text as the content-search row carries it, a `string` or a one-item `string_list`; a `string` operator with a `searchSource` adds only the source rows of FR28, since its editor commits only a source item; while the content-search row shows, the content-search field's default operator adds none, since that row commits the same filter and stays first. An opted-in `enum` or `enum_list` operator adds one row for each value whose label matches the typed text from the start of one of its words (the label's start, or a position after a space or a punctuation mark), compared after the fold `architecture:internationalization/INV17` defines (case, combining marks, the six stroked letters, Turkish ı and İ); a value whose whole label matches comes first, then a label that starts with the text, then the rest, each tier in the config's value order. An opted-in operator with a `searchSource` adds the rows FR28 states. An opted-in operator of any other value type adds none. Each row's text is one catalog message with the field label, the operator label, and the value as its arguments, so a locale can reorder them (`architecture:internationalization/INV1a`): a free-text row's message carries the quotation marks around the typed text, and an enum or search-source row's value is the value's or the item's label, unquoted. In English a row reads "{field label} {operator label} {value}", as the field-prefixed value row for the same filter reads (`Title contains "partner"`, `Work Area is Partner Marketing`), and a search-source row, which has no field-prefixed counterpart, reads the same way (`Owner is Jane Doe`). Choosing a row commits exactly the filter it reads: its field, its operator, and its value — the typed text, the value's key (a one-item list for `enum_list`), or the item FR28 states — in one filter token, as the field-prefixed value row for the same filter commits it. An empty query lists the fields as it does with no operator opted in. | DEC-8; `architecture:internationalization` INV1a, INV17; `architecture:public-component-api` INV3 | Current contract; verified by `usePowerSearchSource.test.ts` and PowerSearch typeahead tests. | | FR28 | An opted-in operator with a `searchSource` answers a value-only query through that source, the one its editor searches. PowerSearch calls each distinct source once with the typed text for each query, once that text has stayed unchanged for 150 ms, the delay the operator's value editor waits before it searches the same source, so typing a word sends one call and not one per keystroke. PowerSearch holds that call itself, as `spec:AST-092` leaves a delayed remote request to its source, and the main field's own debounce stays zero, so the rows that need no source show at once. One source object that several opted-in operators share is one source, called once, and PowerSearch lists the items it returns under every opted-in operator that uses it and adds rows to the query (FR27), bounded by `maxOperatorMenuItems` as the editor bounds them, each as a row for that operator that commits the value its editor stores for that item — for an `entity_list`, a list of that one entity with the `photo` the editor keeps. A field with an opted-in operator that has a `searchSource` and that FR27 lets add rows to the query is a search-source field, and its other value-only matches wait with its source rows. The rows of the other fields show at once, without that delay. A search-source field's rows join the list, all together, once its sources, and the sources of every search-source field before it in config order, have settled, appended below the rows shown, so every later list only appends (`spec:AST-092/FR2`) and the fields keep config order. An answer for a query that is no longer current is dropped (`spec:AST-092/FR4`), and a source that has `cancel` is cancelled when its query is superseded or the list closes. A source that rejects, or answers with no item, adds no source rows: its field then adds its other rows alone, if it has any, and nothing shown is removed. The query stays busy until every contributing source has settled, and its result count is announced once, then (`spec:AST-092/FR5`, `FR8`). A source that no opted-in operator adding rows to the query (FR27) uses is left uncalled. A source receives the value-only query as it receives text typed in that operator's value editor, and PowerSearch sends the query to no other source: a source that filters a list in the page keeps the text in the page, and a source that queries a server sends it there. | DEC-8; `spec:AST-092` FR2, FR4, FR5, FR8 | Current contract; verified by `usePowerSearchSource.test.ts` and PowerSearch typeahead tests. | | FR29 | A typed query lists its rows as one flat list, with no group headings, in this order: the content-search row first when it shows, then the field and field-and-operator rows, then the value-only matches of FR27 and FR28, field by field — the fields that need no source in config order, then the search-source fields in config order (FR28) — and, within a field, its opted-in operators in operator order, each one's free-text row before its value rows in FR27's order or the source's. Each row names its field in its own text (`Work Area is Partner Marketing`), so no heading does. A field shows at most three value-only matches. When it has more, a "More {field label} matching '{typed text}'" row follows the field's rows, one catalog message with the field label and the typed text as arguments. It is an option like a field-and-operator row: the arrow keys reach it and it can take the highlight, and choosing it is a selection (`component:BaseTypeahead/FR1`: the query clears and the list closes, and `spec:AST-092/FR4` ends the query) that commits no filter and opens the value editor of the operator of the field's first row not shown, as a field-and-operator row opens it, with the typed text as the editor's search query when the editor searches, through the opening query of `component:BaseTypeahead/FR18`, which `component:Typeahead/FR14` and `component:Tokenizer/FR31` take — a search source, an entity list, or an `enum_list` editor's Tokenizer, which searches the field's own values — or as its value when it is a text field; an `enum` editor, a Selector with no query, opens on its full list. It joins the list with its field's rows, so it too only appends (`spec:AST-092/FR2`). Value-only matches and "More" rows do not count toward `maxSearchResults`, which bounds the other rows of a typed query; the typeahead's 1,000-row ceiling bounds the whole list. Choosing a value row is a selection, as choosing a field-prefixed value row is: it commits the row's filter as one token, and the typed text clears and the list closes (`component:BaseTypeahead/FR1`). The keys stay the typeahead's own (`component:BaseTypeahead/FR5`): ArrowDown and ArrowUp move the highlight through every row and wrap, Enter chooses the highlighted row, and an Enter that IME composition owns chooses nothing. The first row shown is highlighted, and a row that joins later neither takes the highlight nor is chosen on its own (`spec:AST-092/FR6`). With a content-search field the content-search row shows for every value-only query, so Enter commits the content search, also while a search-source field's rows are pending and when no value matches; without one, Enter chooses the first row shown, and nothing while no row shows. Escape closes the list and keeps the typed text, Tab closes it and moves focus on, and a source still pending then settles without reopening the list (`component:BaseTypeahead/FR3`). AR7 states the rows' semantics. | DEC-8; `component:BaseTypeahead` FR1, FR3, FR5, FR18; `spec:AST-092` | Current contract; verified by `usePowerSearchSource.test.ts` and PowerSearch typeahead tests. | | FR30 | In the sheet presentation, Add filter's content search (FR13) lists the value-only matches of FR27 and FR28, ordered and bounded as FR29 states: in the same "Search results" list, after the other suggestions, field by field — the fields that need no source in config order, then the search-source fields in config order — at most three per field, with no headings, and a field's "More" row button after its rows only when it has more. The rows that need no source show at once. A search-source field's rows come from its sources as FR28 states — the same 150 ms hold, one call per distinct source, an answer for a query that is no longer current dropped, and a source that rejects or answers with no item adding no row — and join the list under incremental search results (FR18, `spec:AST-092`): they display after every row shown (`spec:AST-092/FR2`), so no row moves under a finger, and a shown row keeps its element while its item stays (`spec:AST-092/FR7`). A search-source field with no match lists no row. A "More" row, except a people field's (below), opens the value step on that field and on the operator of its first row not listed, above Add filter, as a field row does (FR13), with the typed text carried into the step's editor where that editor has a text or a query of its own: PowerSearch sets it as the value of a `string` text field itself, and it is the query of a `string` search source's typeahead and the query a `string_list` or `entity_list` value's Tokenizer sheet opens with (FR21), both through the opening query of `component:BaseTypeahead/FR18`, which `component:Typeahead/FR14` and `component:Tokenizer/FR31` take; an `enum` or `enum_list` value's RadioList or CheckboxList shows its full list (FR17). The editor owns its own pending state (FR18). A people field's "More" row — a field whose first opted-in operator, in operator order, takes an `entity_list` value and has a `searchSource` — skips the value step and its operator choice: it opens the Tokenizer's own sheet for that operator (FR17, `component:Tokenizer` FR16–FR27), which PowerSearch renders itself, directly above Add filter, titled with the field label and already searching the typed text as its first query, so one tap reaches the people search and Add filter gains no control; the sheet owns its own pending state, as FR18 states for the value step's tokenizers. Its Save, with at least one item chosen, adds that field, that operator, and the chosen items to the draft as one filter (FR15b), recorded as `('add', draft.length)` and announced `Added {label}` inside the Filters sheet (AR6), and closes the Tokenizer sheet and Add filter together to show Filters (FR15a), as a suggestion that carries a value does (FR13). A Save that leaves its draft empty, after its Clear all for one (`component:Tokenizer` FR24, FR26), and a dismissal, which asks first through the Tokenizer's own discard confirmation while its draft has items (`component:Tokenizer` FR27; FR15c's confirmation guards the flow's draft and does not open), add nothing and reveal Add filter with its typed text kept (FR16). A field whose first opted-in operator takes an `entity_list` value with no `searchSource` is not a people field: its "More" row opens the value step, as a choice field's does. A value row adds its filter to the draft as FR13 states for a suggestion that carries a value, and Add filter closes, its typed text with it (FR15a). The keys are the content search's own (FR13): Enter commits the first suggestion, the content-search row, which shows for every value-only query, also while a search-source field's rows are pending, and an IME-composing Enter does nothing; ArrowDown and ArrowUp move focus between the search and the rows; and Escape dismisses Add filter, since the sheet has no list of its own to close. Without a content-search field, Add filter keeps its field list and field search, with no value rows. | DEC-8, DEC-9; FR13, FR15a–FR18, FR21, FR28; `spec:AST-092` | Current contract; verified by focused sheet tests. | diff --git a/packages/core/src/PowerSearch/PowerSearch.doc.mjs b/packages/core/src/PowerSearch/PowerSearch.doc.mjs index 2125318c39094..7952fae935f42 100644 --- a/packages/core/src/PowerSearch/PowerSearch.doc.mjs +++ b/packages/core/src/PowerSearch/PowerSearch.doc.mjs @@ -217,8 +217,11 @@ export const docs = { // "Owner is any of Jane Doe". A field shows at most three such rows. A field // with more ends with "More Genre matching 'fiction'", which opens Genre's // editor. An editor that searches, such as the owner's, opens on the text. +// The config passes the matcher, so pages without it ship none of its code. +import {powerSearchValueOnlyMatches} from '@astryxdesign/core'; const config = { name: 'Books', + valueOnlyMatches: powerSearchValueOnlyMatches, fields: [ { key: 'genre', diff --git a/packages/core/src/PowerSearch/PowerSearch.test.tsx b/packages/core/src/PowerSearch/PowerSearch.test.tsx index f84dd058a2491..20e71335b057d 100644 --- a/packages/core/src/PowerSearch/PowerSearch.test.tsx +++ b/packages/core/src/PowerSearch/PowerSearch.test.tsx @@ -25,7 +25,7 @@ import {__resetLiveRegionsForTest} from '../hooks/useAnnounce'; import type {PowerSearchConfig, PowerSearchFilter} from './types'; import type {SearchSource, SearchableItem} from '../Typeahead/types'; import {InternationalizationProvider} from '../i18n/InternationalizationProvider'; -import {loadValueOnlyMatches} from './valueOnlyMatchLoader'; +import {powerSearchValueOnlyMatches} from './valueOnlyMatches'; import {TestIcon} from '../__tests__/TestIcon'; import {getTooltip} from '../__tests__/tooltipDescription'; @@ -1263,10 +1263,6 @@ describe('field menu after the search source changes', () => { // ============================================================================= describe('value-only matches', () => { - // The module loads on first intent; these cases start after that. - beforeAll(async () => { - await loadValueOnlyMatches(); - }); const genres = ['Fiction', 'Fictional Worlds', 'Science Fiction', 'Fichte']; /** A people source whose answers the test releases. */ function deferredPeople() { @@ -1285,6 +1281,7 @@ describe('value-only matches', () => { extra: Partial = {}, ): PowerSearchConfig { return { + valueOnlyMatches: powerSearchValueOnlyMatches, name: 'Books', fields: [ { @@ -1504,6 +1501,7 @@ describe('value-only matches', () => { it('opens an enum_list field More row on its Tokenizer, searching the text', async () => { const user = userEvent.setup(); const listConfig: PowerSearchConfig = { + valueOnlyMatches: powerSearchValueOnlyMatches, name: 'Tags', fields: [ { @@ -1576,6 +1574,7 @@ describe('value-only matches', () => { try { const people = deferredPeople(); const offConfig: PowerSearchConfig = { + valueOnlyMatches: powerSearchValueOnlyMatches, name: 'off', fields: [ { @@ -1608,6 +1607,24 @@ describe('value-only matches', () => { } }); + it('warns once in development for an opt-in while the config has no matcher', () => { + const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}); + try { + const config: PowerSearchConfig = { + ...makeConfig(deferredPeople().source), + valueOnlyMatches: undefined, + }; + const {rerender} = render(); + rerender(); + const messages = warn.mock.calls + .map(call => String(call[0])) + .filter(message => message.includes('no `valueOnlyMatches`')); + expect(messages).toHaveLength(1); + } finally { + warn.mockRestore(); + } + }); + it('asks a source once for a word typed within 150 ms, while the other rows show at once', async () => { vi.useFakeTimers(); try { diff --git a/packages/core/src/PowerSearch/PowerSearch.tsx b/packages/core/src/PowerSearch/PowerSearch.tsx index 570533d6afd8e..e2722b731897c 100644 --- a/packages/core/src/PowerSearch/PowerSearch.tsx +++ b/packages/core/src/PowerSearch/PowerSearch.tsx @@ -77,11 +77,7 @@ import {isFocusDetached} from '../utils/isFocusDetached'; import {isRenderable} from '../utils/isRenderable'; import {useInternalConfig} from './useInternalConfig'; import {usePowerSearchSource} from './usePowerSearchSource'; -import { - findDisallowedOptIns, - hasValueOnlyOptIn, - startValueOnlyMatchesLoad, -} from './valueOnlyMatchLoader'; +import {findDisallowedOptIns, hasValueOnlyOptIn} from './valueOnlyOptIn'; import {formatDateRange, formatFilterValueForRender} from './formatFilterValue'; import {NestedEditor, PowerSearchEditPopover} from './PowerSearchEditPopover'; import {PowerSearchValueEditor} from './PowerSearchValueEditor'; @@ -654,6 +650,13 @@ export function PowerSearch({ )}: \`isValueOnlyMatchAllowed\` adds no value-only match while the field sets \`isValueMatchAllowed: false\`, which turns off every value suggestion of the field. Remove one of the two.`, disallowedOptIns.length > 0, ); + useDevWarningPerMessage( + 'PowerSearch', + '`isValueOnlyMatchAllowed` adds no value-only match while the config has no `valueOnlyMatches`. Pass `valueOnlyMatches: powerSearchValueOnlyMatches` in the config.', + process.env.NODE_ENV !== 'production' && + config.config.valueOnlyMatches == null && + hasValueOnlyOptIn(config), + ); const t = useComponentTranslator(); const locale = useLocale(); const calendar = useCalendarSystem(undefined, 'PowerSearch'); @@ -678,7 +681,6 @@ export function PowerSearch({ // matches under incremental search results. const searchSource = usePowerSearchSource(config, maxSearchResults, { maxSourceItems: maxOperatorMenuItems ?? DEFAULT_MAX_OPERATOR_MENU_ITEMS, - presentation: isSheetPresentation ? 'sheet' : 'popover', }); const triggerRef = useRef(null); // `hasAutoFocus` applies only to the control the field first mounts. A @@ -1548,13 +1550,9 @@ export function PowerSearch({ // The flow restores focus to the element that was active when it opened; // make sure that is the trigger even for a tap on a token. triggerRef.current?.focus({preventScroll: true}); - // Opening the flow is the first intent for Add filter's value-only rows. - if (hasValueOnlyOptIn(config)) { - startValueOnlyMatchesLoad(); - } setIsSheetPresented(true); setIsSheetOpen(true); - }, [config, isDisabled]); + }, [isDisabled]); // The field's end lane — the result count and `endContent` — sits outside // the trigger button: a caller's action button there keeps its own tab stop diff --git a/packages/core/src/PowerSearch/PowerSearchBottomSheet.test.tsx b/packages/core/src/PowerSearch/PowerSearchBottomSheet.test.tsx index 60bf011af5657..c3b88ae665308 100644 --- a/packages/core/src/PowerSearch/PowerSearchBottomSheet.test.tsx +++ b/packages/core/src/PowerSearch/PowerSearchBottomSheet.test.tsx @@ -58,7 +58,7 @@ import {InternationalizationProvider} from '../i18n/InternationalizationProvider import type {Overrides} from '../i18n/types'; import {useInternalConfig} from './useInternalConfig'; import {usePowerSearchSource} from './usePowerSearchSource'; -import {loadValueOnlyMatches} from './valueOnlyMatchLoader'; +import {powerSearchValueOnlyMatches} from './valueOnlyMatches'; import { createSheetSuggestionSource, filterSignature, @@ -4733,6 +4733,7 @@ describe('PowerSearch value-only matches in the sheet (FR18, FR30)', () => { operators: [{key: 'contains', label: 'contains', value: {type: 'string'}}], }; const valueOnlyConfig: PowerSearchConfig = { + valueOnlyMatches: powerSearchValueOnlyMatches, name: 'ValueOnly', contentSearchFieldKey: 'title', fields: [ @@ -4837,10 +4838,6 @@ describe('PowerSearch value-only matches in the sheet (FR18, FR30)', () => { }); return {texts, stop: () => observer.disconnect()}; } - // Most cases start after the module has loaded. - beforeAll(async () => { - await loadValueOnlyMatches(); - }); beforeEach(() => { ownerSearch.mockClear(); reviewerSearch.mockClear(); @@ -4912,6 +4909,7 @@ describe('PowerSearch value-only matches in the sheet (FR18, FR30)', () => { setup({ config: { name: 'Deferred', + valueOnlyMatches: powerSearchValueOnlyMatches, contentSearchFieldKey: 'title', fields: [titleField, ownerField(deferred.source)], }, @@ -4955,6 +4953,7 @@ describe('PowerSearch value-only matches in the sheet (FR18, FR30)', () => { setup({ config: { name: 'Deferred', + valueOnlyMatches: powerSearchValueOnlyMatches, contentSearchFieldKey: 'title', fields: [titleField, ownerField(deferred.source)], }, @@ -4999,6 +4998,7 @@ describe('PowerSearch value-only matches in the sheet (FR18, FR30)', () => { const source: SearchSource = {...deferred.source, cancel}; const config: PowerSearchConfig = { name: 'Deferred', + valueOnlyMatches: powerSearchValueOnlyMatches, contentSearchFieldKey: 'title', fields: [titleField, ownerField(source)], }; @@ -5026,6 +5026,7 @@ describe('PowerSearch value-only matches in the sheet (FR18, FR30)', () => { const firstCancel = vi.fn(); const configWith = (source: SearchSource): PowerSearchConfig => ({ name: 'Deferred', + valueOnlyMatches: powerSearchValueOnlyMatches, contentSearchFieldKey: 'title', fields: [titleField, ownerField(source)], }); @@ -5090,6 +5091,7 @@ describe('PowerSearch value-only matches in the sheet (FR18, FR30)', () => { { expect(sourceSearch).toHaveBeenCalledTimes(1); }); - it('loads the value-only rows as the flow opens and lists them once they land', async () => { - // A fresh module registry gives a PowerSearch whose value-only module - // has not loaded yet. - vi.resetModules(); - const fresh = await import('./PowerSearch'); - const loader = await import('./valueOnlyMatchLoader'); - render( - {}} - presentation="bottom-sheet" - />, - ); - expect(loader.getLoadedValueOnlyMatches()).toBeNull(); - // The fresh PowerSearch loads its sheet on the first press. - openSheet(); - await waitFor(() => search()); - fireEvent.change(search(), {target: {value: 'fic'}}); - await waitFor(() => - expect(resultNames()).toContain("More Genre matching 'fic'"), - ); - expect(resultNames()[0]).toBe('"fic"'); - expect(loader.getLoadedValueOnlyMatches()).not.toBeNull(); - }); - it('adds a value row to the draft and closes Add filter with its text', () => { const {onChange} = setup({config: valueOnlyConfig}); typeQuery('fic'); diff --git a/packages/core/src/PowerSearch/index.ts b/packages/core/src/PowerSearch/index.ts index 1e37dea8de254..e0e97fcffe6dc 100644 --- a/packages/core/src/PowerSearch/index.ts +++ b/packages/core/src/PowerSearch/index.ts @@ -21,6 +21,8 @@ export {PowerSearchFilterEditor} from './PowerSearchFilterEditor'; export {resolveOperatorLabel} from './resolveOperatorLabel'; +export {powerSearchValueOnlyMatches} from './valueOnlyMatches'; + export { createPowerSearchConfig, usePowerSearchConfig, @@ -30,6 +32,7 @@ export type {FieldDefinition, InferData} from './usePowerSearchConfig'; export type { // Config types PowerSearchConfig, + PowerSearchValueOnlyMatches, PowerSearchField, PowerSearchOperator, PowerSearchOperatorBase, diff --git a/packages/core/src/PowerSearch/types.ts b/packages/core/src/PowerSearch/types.ts index 87c7b99d0fd0f..421eefe322db9 100644 --- a/packages/core/src/PowerSearch/types.ts +++ b/packages/core/src/PowerSearch/types.ts @@ -10,6 +10,7 @@ * - /packages/core/src/PowerSearch/index.ts */ +import type {withValueOnlyMatches} from './valueOnlyMatches'; import type {ComponentType, ReactNode} from 'react'; import type {SearchSource, SearchableItem} from '../Typeahead/types'; @@ -293,8 +294,8 @@ export interface PowerSearchOperatorBase { * `string` or `string_list` operator without a `searchSource` offers the * typed text, an `enum` or `enum_list` operator the values with a word that * starts with it, and an operator with a `searchSource` the items that - * source returns for it. The field's `isValueMatchAllowed: false` turns - * these off too. @default false + * source returns for it. The config's `valueOnlyMatches` must be set; the + * field's `isValueMatchAllowed: false` turns these off too. @default false */ readonly isValueOnlyMatchAllowed?: boolean; } @@ -355,6 +356,18 @@ export interface PowerSearchConfig { readonly fields: ReadonlyArray; /** Key of the field used for content/text search. */ readonly contentSearchFieldKey?: string; + /** + * The value-only matcher: pass `powerSearchValueOnlyMatches`. Operators that + * set `isValueOnlyMatchAllowed` answer a typed value with no field label + * only when the config has it, so a page that never passes it ships none + * of its code. + */ + readonly valueOnlyMatches?: PowerSearchValueOnlyMatches; +} + +/** PowerSearch's value-only matcher, exported as `powerSearchValueOnlyMatches`. */ +export interface PowerSearchValueOnlyMatches { + readonly withValueOnlyMatches: typeof withValueOnlyMatches; } // ============================================================================= diff --git a/packages/core/src/PowerSearch/usePowerSearchSource.test.ts b/packages/core/src/PowerSearch/usePowerSearchSource.test.ts index e7ff150e865ec..7dec6193d9d4c 100644 --- a/packages/core/src/PowerSearch/usePowerSearchSource.test.ts +++ b/packages/core/src/PowerSearch/usePowerSearchSource.test.ts @@ -7,15 +7,7 @@ * @position Testing; validates usePowerSearchSource.ts */ -import { - afterEach, - beforeAll, - beforeEach, - describe, - expect, - it, - vi, -} from 'vitest'; +import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest'; import {renderHook} from '@testing-library/react'; import {usePowerSearchSource} from './usePowerSearchSource'; import {useInternalConfig} from './useInternalConfig'; @@ -25,7 +17,7 @@ import type { PowerSearchItem, } from './types'; import type {SearchSource, SearchableItem} from '../Typeahead/types'; -import {loadValueOnlyMatches} from './valueOnlyMatchLoader'; +import {powerSearchValueOnlyMatches} from './valueOnlyMatches'; // ============================================================================= // Helpers @@ -635,11 +627,6 @@ describe('typed-result cap', () => { // ============================================================================= describe('value-only matches', () => { - // The module loads on first intent; most cases start after that. - beforeAll(async () => { - await loadValueOnlyMatches(); - }); - function createValueOnlySource( config: PowerSearchConfig, maxTypedResults: number = Number.POSITIVE_INFINITY, @@ -686,6 +673,7 @@ describe('value-only matches', () => { ]; const booksConfig: PowerSearchConfig = { + valueOnlyMatches: powerSearchValueOnlyMatches, name: 'books', fields: [ { @@ -739,93 +727,19 @@ describe('value-only matches', () => { ], }; - describe('before the module loads', () => { - // A fresh module registry gives each case a value-only module that has - // not loaded yet. - let fresh: { - usePowerSearchSource: typeof usePowerSearchSource; - getLoadedValueOnlyMatches: () => object | null; - }; - beforeEach(async () => { - vi.resetModules(); - const [hook, loader] = await Promise.all([ - import('./usePowerSearchSource'), - import('./valueOnlyMatchLoader'), - ]); - fresh = { - usePowerSearchSource: hook.usePowerSearchSource, - getLoadedValueOnlyMatches: loader.getLoadedValueOnlyMatches, - }; - }); - function createValueOnlySource(config: PowerSearchConfig) { - const {result} = renderHook(() => - fresh.usePowerSearchSource( - useInternalConfig(config), - Number.POSITIVE_INFINITY, - {maxSourceItems: 10}, - ), - ); - return result.current; - } - const getLoadedValueOnlyMatches = () => fresh.getLoadedValueOnlyMatches(); - - it('loads nothing for a config that opts no operator in', () => { - const source = createValueOnlySource(baseConfig); - void source.bootstrap(); - expect(labels(syncSearch(source, 'title'))).toContain('Title'); - expect(getLoadedValueOnlyMatches()).toBeNull(); - }); - - it("starts no load from the sheet's bootstrap, which the sheet reads during render", () => { - const {result} = renderHook(() => - fresh.usePowerSearchSource( - useInternalConfig(booksConfig), - Number.POSITIVE_INFINITY, - {maxSourceItems: 10, presentation: 'sheet'}, - ), - ); - void result.current.bootstrap(); - expect(getLoadedValueOnlyMatches()).toBeNull(); - }); - - it('starts the load on focus, the bootstrap', async () => { - const source = createValueOnlySource(booksConfig); - void source.bootstrap(); - await vi.waitFor(() => - expect(getLoadedValueOnlyMatches()).not.toBeNull(), - ); - }); - - it('lists the other rows at once and the value-only matches once the module lands', async () => { - const source = createValueOnlySource({ - ...booksConfig, - contentSearchFieldKey: 'title', - }); - const update = vi.fn(); - const pending = source.search('fiction', {update}); - expect(pending).toBeInstanceOf(Promise); - expect(labels(update.mock.lastCall![0])).toEqual(['"fiction"']); - expect(labels(await pending)).toEqual([ - '"fiction"', - 'Genre is Fiction', - 'Genre is Fictional Worlds', - 'Genre is Science Fiction', - ]); - }); - - it('drops a query superseded while the module loads', async () => { - const source = createValueOnlySource(booksConfig); - const first = source.search('fic', {update: vi.fn()}); - source.cancel?.(); - await expect(first).rejects.toThrow(); - }); - }); - it('lists nothing more for an operator that does not opt in', () => { const source = createValueOnlySource(baseConfig); expect(valueOnly(syncSearch(source, 'open'))).toEqual([]); }); + it('lists nothing more for an opted-in operator while the config has no matcher', () => { + const source = createValueOnlySource({ + ...booksConfig, + valueOnlyMatches: undefined, + }); + expect(valueOnly(syncSearch(source, 'fiction'))).toEqual([]); + }); + it('lists a free-text row and enum rows by word start, whole label first, after the other rows', () => { const source = createValueOnlySource(booksConfig); const items = syncSearch(source, 'fiction'); @@ -902,6 +816,7 @@ describe('value-only matches', () => { it('adds nothing, and asks no source, under a field with isValueMatchAllowed false', async () => { const people = deferredSource('people'); const source = createValueOnlySource({ + valueOnlyMatches: powerSearchValueOnlyMatches, name: 'off', fields: [ { @@ -926,6 +841,7 @@ describe('value-only matches', () => { it("shows at most three rows per field, then a More row that opens the first hidden row's operator on the text", () => { const source = createValueOnlySource({ + valueOnlyMatches: powerSearchValueOnlyMatches, name: 'many', fields: [ { @@ -997,6 +913,7 @@ describe('value-only matches', () => { it('gives a string search-source operator only source rows, even with isArbitraryStringAllowed', async () => { const source = createValueOnlySource({ + valueOnlyMatches: powerSearchValueOnlyMatches, name: 'reviewer', fields: [ { @@ -1049,6 +966,7 @@ describe('value-only matches', () => { reviewers: SearchSource = people, ): PowerSearchConfig { return { + valueOnlyMatches: powerSearchValueOnlyMatches, name: 'people', fields: [ { @@ -1200,6 +1118,7 @@ describe('value-only matches', () => { const people = deferredSource('people'); const source = createValueOnlySource( { + valueOnlyMatches: powerSearchValueOnlyMatches, name: 'bound', fields: [ { diff --git a/packages/core/src/PowerSearch/usePowerSearchSource.ts b/packages/core/src/PowerSearch/usePowerSearchSource.ts index 9784821785edc..d3baab39228f1 100644 --- a/packages/core/src/PowerSearch/usePowerSearchSource.ts +++ b/packages/core/src/PowerSearch/usePowerSearchSource.ts @@ -20,25 +20,13 @@ import {resolveOperatorLabel} from './resolveOperatorLabel'; import type {InternalConfig} from './useInternalConfig'; import type {PowerSearchItem, PowerSearchOperator, FilterValue} from './types'; import {useComponentTranslator} from '../i18n/useComponentTranslator'; -import { - getLoadedValueOnlyMatches, - hasValueOnlyOptIn, - loadValueOnlyMatches, - startValueOnlyMatchesLoad, - type ValueOnlyMatchModule, - type ValueOnlyPending, -} from './valueOnlyMatchLoader'; +import type {ValueOnlyPending} from './valueOnlyMatches'; +import {hasValueOnlyOptIn} from './valueOnlyOptIn'; /** How the source answers a value-only query. */ export interface ValueOnlyOptions { /** The rows a source adds per operator, as its value editor bounds them. */ readonly maxSourceItems: number; - /** - * `popover` (the default) starts loading the value-only module from - * `bootstrap`, the typeahead's focus. In the `sheet`, `bootstrap` is read - * during render, so the sheet's opening handler starts the load instead. - */ - readonly presentation?: 'popover' | 'sheet'; } /** @@ -56,12 +44,12 @@ export function usePowerSearchSource( ): SearchSource { const t = useComponentTranslator(); const maxSourceItems = valueOnly?.maxSourceItems; - const loadsOnBootstrap = valueOnly?.presentation !== 'sheet'; return useMemo(() => { - // The query still waiting on the module or on its sources, if any. A - // newer query, a pick, or the list closing cancels it. - const pending: ValueOnlyPending = {query: null, loading: null}; - const hasOptIn = hasValueOnlyOptIn(config); + // The query still waiting on its sources, if any. A newer query, a pick, + // or the list closing cancels it. + const pending: ValueOnlyPending = {query: null}; + const matcher = config.config.valueOnlyMatches; + const hasOptIn = matcher != null && hasValueOnlyOptIn(config); const allItems = buildFieldItems(config); // Resolver stays inline — `t()` internally memoizes both catalog // lookups and parsed IntlMessageFormat instances, so calling it @@ -242,59 +230,32 @@ export function usePowerSearchSource( } const typedRows = results.slice(0, maxTypedResults); - if (maxSourceItems == null || !hasOptIn) { + if (maxSourceItems == null || matcher == null || !hasOptIn) { return typedRows; } - const answer = ( - module: ValueOnlyMatchModule, - ): PowerSearchItem[] | Promise => - module.withValueOnlyMatches({ - config, - query, - t, - typedRows, - hasContentSearchRow, - maxSourceItems, - context, - pending, - }); - const loaded = getLoadedValueOnlyMatches(); - if (loaded != null) { - return answer(loaded); - } - // The module loads on first intent; a query typed while it loads - // lists its other rows now and its value-only matches once it lands. - const token = {}; - pending.loading = token; - context?.update(typedRows); - return loadValueOnlyMatches().then( - async module => { - if (pending.loading !== token) { - throw new Error('The value-only query was superseded.'); - } - pending.loading = null; - return answer(module); - }, - () => typedRows, - ); + return matcher.withValueOnlyMatches({ + config, + query, + t, + typedRows, + hasContentSearchRow, + maxSourceItems, + context, + pending, + }); }, bootstrap(): PowerSearchItem[] { - // Focus is the first intent: the value-only module starts loading. - if (maxSourceItems != null && hasOptIn && loadsOnBootstrap) { - startValueOnlyMatchesLoad(); - } return allItems; }, cancel() { const request = pending.query; pending.query = null; - pending.loading = null; request?.cancel(); }, }; - }, [config, t, maxTypedResults, maxSourceItems, loadsOnBootstrap]); + }, [config, t, maxTypedResults, maxSourceItems]); } interface ValueMatch { diff --git a/packages/core/src/PowerSearch/valueOnlyMatchLoader.ts b/packages/core/src/PowerSearch/valueOnlyMatchLoader.ts deleted file mode 100644 index c97cd216ddc05..0000000000000 --- a/packages/core/src/PowerSearch/valueOnlyMatchLoader.ts +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Meta Platforms, Inc. and affiliates. - -'use client'; - -/** - * @file valueOnlyMatchLoader.ts - * @input valueOnlyMatches, imported on first intent - * @output loadValueOnlyMatches, startValueOnlyMatchesLoad, - * getLoadedValueOnlyMatches, hasValueOnlyOptIn, findDisallowedOptIns, - * ValueOnlyPending; the load is Core's shared module loader - * @position Internal to PowerSearch: the eager wiring of value-only matches. - * Their code loads when a person first shows intent on a field whose config - * opts an operator in, so a page that opts none in never loads it. - */ - -import {createModuleLoader} from '../utils/moduleLoader'; -import type {InternalConfig} from './useInternalConfig'; -import type * as ValueOnlyMatches from './valueOnlyMatches'; - -export type ValueOnlyMatchModule = typeof ValueOnlyMatches; - -/** A query still waiting on the module or on its sources. */ -export interface ValueOnlyPending { - query: {cancel(): void} | null; - loading: object | null; -} - -const importValueOnlyMatches = async () => import('./valueOnlyMatches'); -const loader = createModuleLoader(importValueOnlyMatches); - -/** Loads the module once. A failed load is tried again at the next intent. */ -export async function loadValueOnlyMatches(): Promise { - return loader.load(); -} - -/** Starts the load on a first intent; a failure waits for the next one. */ -export function startValueOnlyMatchesLoad(): void { - void loader.tryLoad(); -} - -export function getLoadedValueOnlyMatches(): ValueOnlyMatchModule | null { - return loader.loaded(); -} - -/** Whether a field that allows value matches has an operator that opts in. */ -export function hasValueOnlyOptIn(config: InternalConfig): boolean { - return config - .getVisibleFields() - .some( - field => - field.isValueMatchAllowed !== false && - field.operators.some(operator => operator.isValueOnlyMatchAllowed), - ); -} - -/** The opted-in operators a field may not use: its value matches are off. */ -export function findDisallowedOptIns( - config: InternalConfig, -): ReadonlyArray<{field: string; operator: string}> { - return config - .getVisibleFields() - .flatMap(field => - field.isValueMatchAllowed === false - ? field.operators - .filter(operator => operator.isValueOnlyMatchAllowed === true) - .map(operator => ({field: field.key, operator: operator.key})) - : [], - ); -} diff --git a/packages/core/src/PowerSearch/valueOnlyMatches.ts b/packages/core/src/PowerSearch/valueOnlyMatches.ts index cca691b4dd5ef..5b588ea5e4535 100644 --- a/packages/core/src/PowerSearch/valueOnlyMatches.ts +++ b/packages/core/src/PowerSearch/valueOnlyMatches.ts @@ -6,8 +6,9 @@ * @output withValueOnlyMatches: a typed query's rows with the value-only * matches of opted-in operators, the per-field bound, the "More" row, and * the held source calls - * @position Internal to PowerSearch: loaded on first intent through - * valueOnlyMatchLoader, so a config that opts no operator in never loads it + * @position PowerSearch's value-only matcher, which a config passes as + * `valueOnlyMatches` (exported as powerSearchValueOnlyMatches), so a page + * whose configs pass none ships none of it * * A value-only query is typed text that starts with no field label. An * operator that sets `isValueOnlyMatchAllowed` answers it with complete @@ -23,7 +24,6 @@ import type { SearchSource, SearchableItem, } from '../Typeahead/types'; -import type {ValueOnlyPending} from './valueOnlyMatchLoader'; import { entityListValueOf, stringListValueOf, @@ -39,6 +39,7 @@ import type { PowerSearchField, PowerSearchItem, PowerSearchOperator, + PowerSearchValueOnlyMatches, } from './types'; registerEnglishFallback(english); @@ -503,3 +504,17 @@ function askSources( }, }; } + +/** A query still waiting on its sources. */ +export interface ValueOnlyPending { + query: {cancel(): void} | null; +} + +/** + * PowerSearch's value-only matcher. Pass it as a config's `valueOnlyMatches` + * to let operators that set `isValueOnlyMatchAllowed` answer a typed value + * with no field label. + */ +export const powerSearchValueOnlyMatches: PowerSearchValueOnlyMatches = { + withValueOnlyMatches, +}; diff --git a/packages/core/src/PowerSearch/valueOnlyOptIn.ts b/packages/core/src/PowerSearch/valueOnlyOptIn.ts new file mode 100644 index 0000000000000..b68adfb30b5a7 --- /dev/null +++ b/packages/core/src/PowerSearch/valueOnlyOptIn.ts @@ -0,0 +1,38 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. + +/** + * @file valueOnlyOptIn.ts + * @input InternalConfig + * @output hasValueOnlyOptIn and findDisallowedOptIns: which operators opt in + * to value-only matches + * @position Internal to PowerSearch: read by the source and the development + * warnings, with no value-only matching code of its own + */ + +import type {InternalConfig} from './useInternalConfig'; + +/** Whether a field that allows value matches has an operator that opts in. */ +export function hasValueOnlyOptIn(config: InternalConfig): boolean { + return config + .getVisibleFields() + .some( + field => + field.isValueMatchAllowed !== false && + field.operators.some(operator => operator.isValueOnlyMatchAllowed), + ); +} + +/** The opted-in operators a field may not use: its value matches are off. */ +export function findDisallowedOptIns( + config: InternalConfig, +): ReadonlyArray<{field: string; operator: string}> { + return config + .getVisibleFields() + .flatMap(field => + field.isValueMatchAllowed === false + ? field.operators + .filter(operator => operator.isValueOnlyMatchAllowed === true) + .map(operator => ({field: field.key, operator: operator.key})) + : [], + ); +} From 78d380be2e9cc6bf77a368efd2db079c20631c68 Mon Sep 17 00:00:00 2001 From: Cindy Zhang Date: Thu, 3 Dec 2026 03:34:56 -0800 Subject: [PATCH 2/4] perf(PowerSearch): the value-only matcher is an opaque handle, like Swipe --- .../PowerSearch/PowerSearch.spec.md | 2 +- packages/core/src/PowerSearch/PowerSearch.tsx | 8 +++-- packages/core/src/PowerSearch/types.ts | 13 ++++++-- .../src/PowerSearch/usePowerSearchSource.ts | 4 +-- .../core/src/PowerSearch/valueOnlyMatches.ts | 6 ++-- .../core/src/PowerSearch/valueOnlyOptIn.ts | 32 ++++++++++++++++++- 6 files changed, 53 insertions(+), 12 deletions(-) diff --git a/docs/specs/components/PowerSearch/PowerSearch.spec.md b/docs/specs/components/PowerSearch/PowerSearch.spec.md index fe488d869c9d9..f0dc788c4d8f2 100644 --- a/docs/specs/components/PowerSearch/PowerSearch.spec.md +++ b/docs/specs/components/PowerSearch/PowerSearch.spec.md @@ -708,7 +708,7 @@ mark implementation and focused real-Chromium verification as pending. | FR24 | `PowerSearchTokenNaming.test.tsx`; real-Chromium accessibility tree of a popover token | Popover token with a value, read-only token, editor open and closed, a verb-last remove word | A token named without its value, a missing or stale `aria-expanded`, an unnamed or non-dialog editor, or a remove name that loses its locale's word order fails. | `audit:PowerSearch/accessibility` | | FR25 | PowerSearch date-zone tests under four host zones (UTC, Los Angeles, Tokyo, Honolulu) with `timezoneID` set to each zone and unset: token text, the removal announcement that carries the accessible label, the editor's opening day, the stored instant after a pick, a round trip that moves the day and back, a `components` Editor override and `PowerSearchFilterEditor` receiving the zone, range parts read and written, and an `isDateOnly: false` value left to FR26; plus the formatter's unit tests | a Los Angeles evening instant with `timezoneID` set and unset, a pick across the US daylight-time change, a `date_range` of two instants | The token and the editor show different days for one value, a re-picked day moves the instant, or a day shows a time | `audit:PowerSearch/interaction` | | FR26 | PowerSearch date-and-time tests under four host zones (UTC, Los Angeles, Tokyo, Honolulu) with `timezoneID` set and unset: the token's date and time, the editor's opening date and time, the stored instant after a time is typed, a `components` Editor override and `PowerSearchFilterEditor` receiving the zone, the editor on a line of its own, and a date-only operator kept on the date picker; plus the sheet's value step opening on the time in `timezoneID` | a Los Angeles evening instant with `isDateOnly: false` and `timezoneID` Los Angeles, Tokyo, empty and unset; the same instant with `isDateOnly: true` | The token shows no time, the editor has no time field or opens on another time than the token shows, a typed time stores a different instant than it names, or a date-only operator gains a time field | `audit:PowerSearch/interaction` | -| FR27–FR29, AR7 | `usePowerSearchSource.test.ts` unit tests with a deferred search source, plus PowerSearch typeahead tests of the rendered rows, the development warning, and the accessibility tree | no operator opted in; opted-in free-text, `enum`, `enum_list`, and `entity_list` operators, a `string` search-source operator with and without `isArbitraryStringAllowed` (source rows only, no free-text row), and a `string_list` search-source operator with it (a free-text row), beside operators not opted in; an opted-in operator under a field with `isValueMatchAllowed: false` (no row, one development warning, and no source call on its account); `typeaheadMinQueryLength` above and below two; a one-character query; a label-led and a bare-label query, and a label-led query in another case; a word-start, a mid-word, an accented, an uppercase, and a Turkish ı query; whole-label and label-start ranking; an `entity_list` row's text and option name; a locale whose row message reorders the field, operator, and value; a field's fourth match and its "More" row, reached by the arrow keys and opening the editor with the text as its search query while the list closes; an `enum` field's "More" row opening the Selector on its full list, and an `enum_list` field's opening its Tokenizer with the text as its search; the content-search row first and highlighted; Enter with and without a content-search row; two search-source fields answering out of order; two opted-in operators sharing one source (one call per query, its items under both, neither call cancelled by the other); the announced count including a "More" row; a superseded query's late answer; the content-search field's own free-text row absent while the content-search row shows; a rejecting source; `maxSearchResults` of 2 with three contributing fields | A value row appears for an operator not opted in, under a disallowing field, or for a label-led or short query; the warning is missing; a mid-word match lists; a row commits another filter than it names; a field shows more than three rows, a fourth match has no "More" row, or the "More" row commits a filter; a later answer inserts above shown rows, or a stale answer shows; or `maxSearchResults` hides a field's rows. | `audit:PowerSearch/interaction` | +| FR27–FR29, AR7 | `usePowerSearchSource.test.ts` unit tests with a deferred search source, plus PowerSearch typeahead tests of the rendered rows, the development warning, and the accessibility tree The config without `valueOnlyMatches` lists no value-only match and warns once in development. | no operator opted in; opted-in free-text, `enum`, `enum_list`, and `entity_list` operators, a `string` search-source operator with and without `isArbitraryStringAllowed` (source rows only, no free-text row), and a `string_list` search-source operator with it (a free-text row), beside operators not opted in; an opted-in operator under a field with `isValueMatchAllowed: false` (no row, one development warning, and no source call on its account); `typeaheadMinQueryLength` above and below two; a one-character query; a label-led and a bare-label query, and a label-led query in another case; a word-start, a mid-word, an accented, an uppercase, and a Turkish ı query; whole-label and label-start ranking; an `entity_list` row's text and option name; a locale whose row message reorders the field, operator, and value; a field's fourth match and its "More" row, reached by the arrow keys and opening the editor with the text as its search query while the list closes; an `enum` field's "More" row opening the Selector on its full list, and an `enum_list` field's opening its Tokenizer with the text as its search; the content-search row first and highlighted; Enter with and without a content-search row; two search-source fields answering out of order; two opted-in operators sharing one source (one call per query, its items under both, neither call cancelled by the other); the announced count including a "More" row; a superseded query's late answer; the content-search field's own free-text row absent while the content-search row shows; a rejecting source; `maxSearchResults` of 2 with three contributing fields; a value-only row from a config without the matcher, or no warning for it | A value row appears for an operator not opted in, under a disallowing field, or for a label-led or short query; the warning is missing; a mid-word match lists; a row commits another filter than it names; a field shows more than three rows, a fourth match has no "More" row, or the "More" row commits a filter; a later answer inserts above shown rows, or a stale answer shows; or `maxSearchResults` hides a field's rows. | `audit:PowerSearch/interaction` | | FR28, FR29, AR7 timing | PowerSearch typeahead tests with fake timers and a deferred search source | a word typed within 150 ms (one source call, with the whole word) while the rows that need no source show at once; Enter while a source is pending, and with no value match; a composing Enter; Escape keeping the text, and a pending answer not reopening the list; a chosen value row clearing the text and closing the list; `aria-activedescendant` naming a highlighted value row and keeping its id as rows append | A source called per keystroke or before the wait; an Enter that waits for or chooses a pending row; a composing Enter that commits; an Escape that clears the text; a chosen row that leaves the text; or an active descendant that is missing or changes for the same row. | `audit:PowerSearch/interaction` | | FR18, FR30, AR7 sheet | Focused PowerSearch sheet tests with a deferred search source: rows that join below the rows shown, no empty state and a busy search while pending, one count announcement at settle, a stale answer dropped, and a "More" row only past three rows | Add filter's content search with opted-in free-text, `enum`, and search-source operators; the rows that need no source shown at once with the search busy, and a search-source field's rows joining below them when a deferred source answers, one call per distinct source after the hold; no empty state while a source is pending, and the count announced once, at settle, inside Add filter; an answer for a superseded query dropped; a search-source field with no match listing no row; a field's fourth match and its "More" row button opening the value step with the text, and no "More" row for a field with three rows or fewer; a "More" row carrying the text into a `string` text field, into a `string` search source's Typeahead query, and into the query a `string_list` value's Tokenizer sheet opens with, and an `enum_list` value's CheckboxList showing its full list; a people field's "More" row opening its Tokenizer sheet directly above Add filter, searching the text, focus on its panel; its Save with an item adding one filter with the field's first opted-in operator, recorded, announced, and showing Filters with focus on its row; its Save after Clear all, a clean dismissal, and a dismissal of a changed draft through its discard confirmation, each revealing Add filter with the text kept and focus on the content search; a field whose first opted-in `entity_list` operator has no `searchSource` opening the value step; no trigger left in Add filter after the people sheet closes; a value row added to the draft and Add filter closed; Enter committing the content-search row, also while a source is pending; a composing Enter; Escape dismissing Add filter; a config with no content-search field | Source matches never list in the sheet, or a "More" row stands in for them; a later row displays above a shown row; an empty state shows while pending; the count is announced before settle or twice; a stale answer shows; a field hides a match with no "More" row; a "More" row drops the text an editor can take; a people field's "More" row opens the value step, or its Save adds the wrong filter; a composing Enter commits. | `audit:PowerSearch/sheet` | | FR10–FR21, AR4–AR6, PR5 | Focused PowerSearch sheet tests with the compact-touch query stubbed both ways, plus real-engine touch evidence, and a real-engine width sweep of a long placeholder in both writing directions | the default resolving both ways, `popover` kept on a compact coarse-pointer screen, forced sheet, adaptive both ways (the default's server markup the same as `popover`'s, server markup and hydration as the popover field on a coarse-pointer client, then the trigger, no recoverable error, focus on the body; with `hasAutoFocus`, the autofocused input's focus ending on the trigger with no `onBlur` or `onFocus` to the caller), trigger name, Filters/Add filter/value steps, each value type, list value through the Tokenizer sheet, Clear all, read-only, disabled while open, focus after each step, focus after an `adaptive` switch from the trigger, the input, a removed control, an open editor popover, and from outside the field, a field inside an open Dialog announcing the count, Clear all, and in-sheet messages inside that Dialog and never on the page body, StrictMode result count, in-sheet live region while a sheet is open (added, removed, count, empty results), Clear all announced only after the dialog's exit, row, token and Removed text sharing one formatter, a date-only value as its day in `timezoneID`, else the UTC day, and a date-and-time value in `timezoneID`, else the viewer's zone, on all three (UTC, Tokyo, Honolulu, unset), summaries and relative-date labels and values from the catalog, the row and Removed through one reorderable message, an unmatched relative-date value as stored, a filter the config no longer knows listed and removable, a cleared number unstaged, a stale read-only filter as a plain row, a removal next to a nested row focusing that row's remove action, a list value joined by the locale's narrow conjunction list in English, Simplified Chinese, Japanese, and German, an empty-result message spoken once per query from its rendered element, a controlled update that removes the edited field moving focus from the replaced body to Cancel and announcing the unavailable state in the sheet while the step is open and never from a step beneath another or retained closed, Apply and Cancel after a controlled update removed the edited filter focusing the nearest row, else Add filter, a row's trailing remove action focusing the next row's remove action, a one-tap `empty`-valued filter added from its field row and removed from its row, Clear all behind its confirmation keeping read-only filters and leaving Filters open, a dismissed step revealing the step beneath with focus restored to it, Add filter opening with its search unfocused and a touch drag on the rows blurring a focused search, a stale filter's step titled as its row reads (raw keys for what is gone, the field's label when the field remains), Cancel from creation after the opening field was removed focusing the Add filter sheet's first control, a removed focused Filters row, a removed Clear all, and a dropped focused field row each handing focus to the nearest remaining row or the sheet's first control, element counts at rest and with each of the Filters, Add filter and value sheets open, and with the Tokenizer's list-value sheet stacked above the value step, under fine and coarse pointers, nothing of the flow in the DOM at rest before a press and after the exit, a nested filter edited and created through the built-in nested editor (its sub-filter rows wrapping inside a 390 and a 414 px sheet; its root operator picker absent on a mixed field, the Operator group in its place), a nested-only field and its suggestion offered, a suggestion's operator checked over the field's default, the Operator group outside a caller's Editor override on a mixed field, a count changed during the exit spoken with Clear all's message as one catalog message after the close, a single choice as a RadioList with one radio group whose arrow keys move and check, a multiple choice as a CheckboxList whose rows Space toggles, right-to-left layout with the row chevrons mirrored in RTL (`design:bidirectionality/DR4`) | A field with a fine pointer or on a screen that is not compact changes by default beyond what FR19 states, `presentation="popover"` presents the sheet flow, a value commits before the step confirms, Clear all removes a read-only filter, the trigger carries native `disabled`, focus lands elsewhere, an announcement reaches a channel outside the modal that holds the field at that moment, or the popover bundle carries the sheets. | `audit:PowerSearch/sheet` | diff --git a/packages/core/src/PowerSearch/PowerSearch.tsx b/packages/core/src/PowerSearch/PowerSearch.tsx index e2722b731897c..ce3864d17fbb1 100644 --- a/packages/core/src/PowerSearch/PowerSearch.tsx +++ b/packages/core/src/PowerSearch/PowerSearch.tsx @@ -77,7 +77,11 @@ import {isFocusDetached} from '../utils/isFocusDetached'; import {isRenderable} from '../utils/isRenderable'; import {useInternalConfig} from './useInternalConfig'; import {usePowerSearchSource} from './usePowerSearchSource'; -import {findDisallowedOptIns, hasValueOnlyOptIn} from './valueOnlyOptIn'; +import { + findDisallowedOptIns, + hasValueOnlyOptIn, + valueOnlyMatcherOf, +} from './valueOnlyOptIn'; import {formatDateRange, formatFilterValueForRender} from './formatFilterValue'; import {NestedEditor, PowerSearchEditPopover} from './PowerSearchEditPopover'; import {PowerSearchValueEditor} from './PowerSearchValueEditor'; @@ -654,7 +658,7 @@ export function PowerSearch({ 'PowerSearch', '`isValueOnlyMatchAllowed` adds no value-only match while the config has no `valueOnlyMatches`. Pass `valueOnlyMatches: powerSearchValueOnlyMatches` in the config.', process.env.NODE_ENV !== 'production' && - config.config.valueOnlyMatches == null && + valueOnlyMatcherOf(config.config.valueOnlyMatches) == null && hasValueOnlyOptIn(config), ); const t = useComponentTranslator(); diff --git a/packages/core/src/PowerSearch/types.ts b/packages/core/src/PowerSearch/types.ts index 421eefe322db9..a5f3a1e244ee1 100644 --- a/packages/core/src/PowerSearch/types.ts +++ b/packages/core/src/PowerSearch/types.ts @@ -10,7 +10,6 @@ * - /packages/core/src/PowerSearch/index.ts */ -import type {withValueOnlyMatches} from './valueOnlyMatches'; import type {ComponentType, ReactNode} from 'react'; import type {SearchSource, SearchableItem} from '../Typeahead/types'; @@ -365,9 +364,17 @@ export interface PowerSearchConfig { readonly valueOnlyMatches?: PowerSearchValueOnlyMatches; } -/** PowerSearch's value-only matcher, exported as `powerSearchValueOnlyMatches`. */ +/** + * PowerSearch's value-only matcher. Callers import it as + * `powerSearchValueOnlyMatches` and pass it only as a config's + * `valueOnlyMatches`; its contents are not public. + */ export interface PowerSearchValueOnlyMatches { - readonly withValueOnlyMatches: typeof withValueOnlyMatches; + /** + * A brand that is never present, so the matcher types of the package and a + * swizzled copy match. + */ + readonly '@astryxdesign/core/power-search/value-only-matches/v1'?: never; } // ============================================================================= diff --git a/packages/core/src/PowerSearch/usePowerSearchSource.ts b/packages/core/src/PowerSearch/usePowerSearchSource.ts index d3baab39228f1..9cc734d828ef7 100644 --- a/packages/core/src/PowerSearch/usePowerSearchSource.ts +++ b/packages/core/src/PowerSearch/usePowerSearchSource.ts @@ -21,7 +21,7 @@ import type {InternalConfig} from './useInternalConfig'; import type {PowerSearchItem, PowerSearchOperator, FilterValue} from './types'; import {useComponentTranslator} from '../i18n/useComponentTranslator'; import type {ValueOnlyPending} from './valueOnlyMatches'; -import {hasValueOnlyOptIn} from './valueOnlyOptIn'; +import {hasValueOnlyOptIn, valueOnlyMatcherOf} from './valueOnlyOptIn'; /** How the source answers a value-only query. */ export interface ValueOnlyOptions { @@ -48,7 +48,7 @@ export function usePowerSearchSource( // The query still waiting on its sources, if any. A newer query, a pick, // or the list closing cancels it. const pending: ValueOnlyPending = {query: null}; - const matcher = config.config.valueOnlyMatches; + const matcher = valueOnlyMatcherOf(config.config.valueOnlyMatches); const hasOptIn = matcher != null && hasValueOnlyOptIn(config); const allItems = buildFieldItems(config); // Resolver stays inline — `t()` internally memoizes both catalog diff --git a/packages/core/src/PowerSearch/valueOnlyMatches.ts b/packages/core/src/PowerSearch/valueOnlyMatches.ts index 5b588ea5e4535..e1754ccbbe916 100644 --- a/packages/core/src/PowerSearch/valueOnlyMatches.ts +++ b/packages/core/src/PowerSearch/valueOnlyMatches.ts @@ -41,6 +41,7 @@ import type { PowerSearchOperator, PowerSearchValueOnlyMatches, } from './types'; +import {makeValueOnlyMatches} from './valueOnlyOptIn'; registerEnglishFallback(english); @@ -515,6 +516,5 @@ export interface ValueOnlyPending { * to let operators that set `isValueOnlyMatchAllowed` answer a typed value * with no field label. */ -export const powerSearchValueOnlyMatches: PowerSearchValueOnlyMatches = { - withValueOnlyMatches, -}; +export const powerSearchValueOnlyMatches: PowerSearchValueOnlyMatches = + makeValueOnlyMatches({withValueOnlyMatches}); diff --git a/packages/core/src/PowerSearch/valueOnlyOptIn.ts b/packages/core/src/PowerSearch/valueOnlyOptIn.ts index b68adfb30b5a7..d65f38689775c 100644 --- a/packages/core/src/PowerSearch/valueOnlyOptIn.ts +++ b/packages/core/src/PowerSearch/valueOnlyOptIn.ts @@ -4,12 +4,42 @@ * @file valueOnlyOptIn.ts * @input InternalConfig * @output hasValueOnlyOptIn and findDisallowedOptIns: which operators opt in - * to value-only matches + * to value-only matches; makeValueOnlyMatches and valueOnlyMatcherOf: the + * matcher a `PowerSearchValueOnlyMatches` value carries * @position Internal to PowerSearch: read by the source and the development * warnings, with no value-only matching code of its own */ +import type {PowerSearchValueOnlyMatches} from './types'; import type {InternalConfig} from './useInternalConfig'; +import type {withValueOnlyMatches} from './valueOnlyMatches'; + +const MATCHER = Symbol.for( + '@astryxdesign/core/power-search/value-only-matcher', +); + +/** The matcher a `PowerSearchValueOnlyMatches` value carries. */ +export interface ValueOnlyMatcher { + readonly withValueOnlyMatches: typeof withValueOnlyMatches; +} + +interface CarriedMatcher { + readonly [MATCHER]?: ValueOnlyMatcher; +} + +/** Wraps a matcher in the opaque value callers pass (valueOnlyMatches.ts). */ +export function makeValueOnlyMatches( + matcher: ValueOnlyMatcher, +): PowerSearchValueOnlyMatches { + return Object.freeze(Object.defineProperty({}, MATCHER, {value: matcher})); +} + +/** The matcher a config's `valueOnlyMatches` carries, or null. */ +export function valueOnlyMatcherOf( + value: PowerSearchValueOnlyMatches | undefined, +): ValueOnlyMatcher | null { + return (value as CarriedMatcher | undefined)?.[MATCHER] ?? null; +} /** Whether a field that allows value matches has an operator that opts in. */ export function hasValueOnlyOptIn(config: InternalConfig): boolean { From d2fb6a8c454e95fcd39617d425c9f248a1d71287 Mon Sep 17 00:00:00 2001 From: Cindy Zhang Date: Thu, 3 Dec 2026 05:52:18 -0800 Subject: [PATCH 3/4] perf(PowerSearch): the matcher handle uses sharedBrand, and the record names the matcher everywhere an opt-in is described --- .../PowerSearch/PowerSearch.spec.md | 44 ++++++++++--------- .../core/src/PowerSearch/valueOnlyOptIn.ts | 18 ++++---- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/docs/specs/components/PowerSearch/PowerSearch.spec.md b/docs/specs/components/PowerSearch/PowerSearch.spec.md index f0dc788c4d8f2..2f3e28db1114a 100644 --- a/docs/specs/components/PowerSearch/PowerSearch.spec.md +++ b/docs/specs/components/PowerSearch/PowerSearch.spec.md @@ -85,8 +85,9 @@ pointer or on a screen that is not compact the field keeps the tokenizer and editor popover, and `presentation="popover"` keeps them on every device. DEC-3 states the flow's shape. A typed value alone can also suggest complete filters, from the operators a -config opts in: a value-only match (FR27). When the Owner field's "is" operator -sets `isValueOnlyMatchAllowed: true`, typing "jane" asks that operator's people +config opts in: a value-only match (FR27). When the config passes +`valueOnlyMatches: powerSearchValueOnlyMatches` and the Owner field's "is" +operator sets `isValueOnlyMatchAllowed: true`, typing "jane" asks that operator's people source and offers `Owner is Jane Doe` after the field and operator matches, so a person who does not know which field holds a value still reaches its filter (DEC-8). @@ -188,7 +189,7 @@ present-tense implementation gap note. field's value suggestions — the field-prefixed value matches every operator offers, and the value-only matches of an operator that opts in — and `false` turns all of them off, lookups included. What a caller that opts an operator - in observes: a value-only query lists that operator's value rows after the field and + in, with the config's `valueOnlyMatches`, observes: a value-only query lists that operator's value rows after the field and field-and-operator rows, at most three per field and then a "More" row when the field has more, from two characters unless the field's `typeaheadMinQueryLength` says otherwise (FR27, FR29); without a @@ -199,6 +200,9 @@ present-tense implementation gap note. not count toward `maxSearchResults`; and the sheet's content search lists the rows that need no source (FR30). An operator that opts in under a field whose `isValueMatchAllowed` is `false` adds nothing and warns once in development. + An operator that opts in while its config has no `valueOnlyMatches` adds + nothing and warns once in development; passing + `valueOnlyMatches: powerSearchValueOnlyMatches` turns its matches on. Consumer migration instructions belong in consumer docs and release notes. @@ -696,24 +700,24 @@ mark implementation and focused real-Chromium verification as pending. ## Verification map -| Contract | Verification | Representative states | Mutation or failure expectation | Audit section | -| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | -| FR1–FR3, FR7 | PowerSearch unit tests plus real-Chromium geometry assertions | 399/400, 720/721, wide outer surface, narrow viewport, LTR/RTL, collision | Removing either clamp, capping the main menu, or allowing viewport overflow fails. | `audit:PowerSearch/layout` | -| FR4–FR6, FR9 | Opening-path tests plus real-Chromium geometry assertions | Add from inner input; edit actual left/right/equidistant token/control; pointer/keyboard; reopen opposite side | Using pointer coordinates, modality, wrapper-only identity, stale identity, or public props fails. | `audit:PowerSearch/interaction` | -| PR1–PR4 | Instrumented unit tests plus first-frame real-Chromium capture | Open, close, reopen opposite side; hidden placement commit; first painted frame | Render-time reads, repeated reads, observers, pointer tracking, or a default-position flash fails. | `audit:PowerSearch/performance` | -| FR8, AR1–AR3 | Existing PowerSearch/editor suites plus focused browser checks | Pointer and keyboard edit, apply, cancel, Escape, light dismiss, focus return, selection, semantics | Focus, semantics, selection, dismissal, or reachability changes fail. | `audit:PowerSearch/accessibility` | +| Contract | Verification | Representative states | Mutation or failure expectation | Audit section | +| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | +| FR1–FR3, FR7 | PowerSearch unit tests plus real-Chromium geometry assertions | 399/400, 720/721, wide outer surface, narrow viewport, LTR/RTL, collision | Removing either clamp, capping the main menu, or allowing viewport overflow fails. | `audit:PowerSearch/layout` | +| FR4–FR6, FR9 | Opening-path tests plus real-Chromium geometry assertions | Add from inner input; edit actual left/right/equidistant token/control; pointer/keyboard; reopen opposite side | Using pointer coordinates, modality, wrapper-only identity, stale identity, or public props fails. | `audit:PowerSearch/interaction` | +| PR1–PR4 | Instrumented unit tests plus first-frame real-Chromium capture | Open, close, reopen opposite side; hidden placement commit; first painted frame | Render-time reads, repeated reads, observers, pointer tracking, or a default-position flash fails. | `audit:PowerSearch/performance` | +| FR8, AR1–AR3 | Existing PowerSearch/editor suites plus focused browser checks | Pointer and keyboard edit, apply, cancel, Escape, light dismiss, focus return, selection, semantics | Focus, semantics, selection, dismissal, or reachability changes fail. | `audit:PowerSearch/accessibility` | | FR15b, FR15c | Focused sheet tests: no `onChange` before Done, Done's replay in order, an unchanged draft's silent close, clean and changed-draft dismissal with Keep editing and Discard changes, read-only filters kept through Clear all and Done, and the popover presentation's at-once reports | -| FR22 | PowerSearch and Tokenizer unit tests | A read-only field with a filter: no Clear all, no token remove control, Backspace on the empty input | A read-only field removes a filter through Backspace, Clear all, or a token control. | `audit:PowerSearch/interaction` | -| FR23 | PowerSearch and Tokenizer unit tests | Clear all with a read-only filter before two editable ones; every filter read-only; Backspace with a read-only last filter; the words with and without a read-only filter left | A read-only filter is removed, Clear all reports an index other than the first removed one, Clear all shows with no editable filter, or its words say every filter went while one remains. | `audit:PowerSearch/interaction` | -| FR24 | `PowerSearchTokenNaming.test.tsx`; real-Chromium accessibility tree of a popover token | Popover token with a value, read-only token, editor open and closed, a verb-last remove word | A token named without its value, a missing or stale `aria-expanded`, an unnamed or non-dialog editor, or a remove name that loses its locale's word order fails. | `audit:PowerSearch/accessibility` | -| FR25 | PowerSearch date-zone tests under four host zones (UTC, Los Angeles, Tokyo, Honolulu) with `timezoneID` set to each zone and unset: token text, the removal announcement that carries the accessible label, the editor's opening day, the stored instant after a pick, a round trip that moves the day and back, a `components` Editor override and `PowerSearchFilterEditor` receiving the zone, range parts read and written, and an `isDateOnly: false` value left to FR26; plus the formatter's unit tests | a Los Angeles evening instant with `timezoneID` set and unset, a pick across the US daylight-time change, a `date_range` of two instants | The token and the editor show different days for one value, a re-picked day moves the instant, or a day shows a time | `audit:PowerSearch/interaction` | -| FR26 | PowerSearch date-and-time tests under four host zones (UTC, Los Angeles, Tokyo, Honolulu) with `timezoneID` set and unset: the token's date and time, the editor's opening date and time, the stored instant after a time is typed, a `components` Editor override and `PowerSearchFilterEditor` receiving the zone, the editor on a line of its own, and a date-only operator kept on the date picker; plus the sheet's value step opening on the time in `timezoneID` | a Los Angeles evening instant with `isDateOnly: false` and `timezoneID` Los Angeles, Tokyo, empty and unset; the same instant with `isDateOnly: true` | The token shows no time, the editor has no time field or opens on another time than the token shows, a typed time stores a different instant than it names, or a date-only operator gains a time field | `audit:PowerSearch/interaction` | -| FR27–FR29, AR7 | `usePowerSearchSource.test.ts` unit tests with a deferred search source, plus PowerSearch typeahead tests of the rendered rows, the development warning, and the accessibility tree The config without `valueOnlyMatches` lists no value-only match and warns once in development. | no operator opted in; opted-in free-text, `enum`, `enum_list`, and `entity_list` operators, a `string` search-source operator with and without `isArbitraryStringAllowed` (source rows only, no free-text row), and a `string_list` search-source operator with it (a free-text row), beside operators not opted in; an opted-in operator under a field with `isValueMatchAllowed: false` (no row, one development warning, and no source call on its account); `typeaheadMinQueryLength` above and below two; a one-character query; a label-led and a bare-label query, and a label-led query in another case; a word-start, a mid-word, an accented, an uppercase, and a Turkish ı query; whole-label and label-start ranking; an `entity_list` row's text and option name; a locale whose row message reorders the field, operator, and value; a field's fourth match and its "More" row, reached by the arrow keys and opening the editor with the text as its search query while the list closes; an `enum` field's "More" row opening the Selector on its full list, and an `enum_list` field's opening its Tokenizer with the text as its search; the content-search row first and highlighted; Enter with and without a content-search row; two search-source fields answering out of order; two opted-in operators sharing one source (one call per query, its items under both, neither call cancelled by the other); the announced count including a "More" row; a superseded query's late answer; the content-search field's own free-text row absent while the content-search row shows; a rejecting source; `maxSearchResults` of 2 with three contributing fields; a value-only row from a config without the matcher, or no warning for it | A value row appears for an operator not opted in, under a disallowing field, or for a label-led or short query; the warning is missing; a mid-word match lists; a row commits another filter than it names; a field shows more than three rows, a fourth match has no "More" row, or the "More" row commits a filter; a later answer inserts above shown rows, or a stale answer shows; or `maxSearchResults` hides a field's rows. | `audit:PowerSearch/interaction` | -| FR28, FR29, AR7 timing | PowerSearch typeahead tests with fake timers and a deferred search source | a word typed within 150 ms (one source call, with the whole word) while the rows that need no source show at once; Enter while a source is pending, and with no value match; a composing Enter; Escape keeping the text, and a pending answer not reopening the list; a chosen value row clearing the text and closing the list; `aria-activedescendant` naming a highlighted value row and keeping its id as rows append | A source called per keystroke or before the wait; an Enter that waits for or chooses a pending row; a composing Enter that commits; an Escape that clears the text; a chosen row that leaves the text; or an active descendant that is missing or changes for the same row. | `audit:PowerSearch/interaction` | -| FR18, FR30, AR7 sheet | Focused PowerSearch sheet tests with a deferred search source: rows that join below the rows shown, no empty state and a busy search while pending, one count announcement at settle, a stale answer dropped, and a "More" row only past three rows | Add filter's content search with opted-in free-text, `enum`, and search-source operators; the rows that need no source shown at once with the search busy, and a search-source field's rows joining below them when a deferred source answers, one call per distinct source after the hold; no empty state while a source is pending, and the count announced once, at settle, inside Add filter; an answer for a superseded query dropped; a search-source field with no match listing no row; a field's fourth match and its "More" row button opening the value step with the text, and no "More" row for a field with three rows or fewer; a "More" row carrying the text into a `string` text field, into a `string` search source's Typeahead query, and into the query a `string_list` value's Tokenizer sheet opens with, and an `enum_list` value's CheckboxList showing its full list; a people field's "More" row opening its Tokenizer sheet directly above Add filter, searching the text, focus on its panel; its Save with an item adding one filter with the field's first opted-in operator, recorded, announced, and showing Filters with focus on its row; its Save after Clear all, a clean dismissal, and a dismissal of a changed draft through its discard confirmation, each revealing Add filter with the text kept and focus on the content search; a field whose first opted-in `entity_list` operator has no `searchSource` opening the value step; no trigger left in Add filter after the people sheet closes; a value row added to the draft and Add filter closed; Enter committing the content-search row, also while a source is pending; a composing Enter; Escape dismissing Add filter; a config with no content-search field | Source matches never list in the sheet, or a "More" row stands in for them; a later row displays above a shown row; an empty state shows while pending; the count is announced before settle or twice; a stale answer shows; a field hides a match with no "More" row; a "More" row drops the text an editor can take; a people field's "More" row opens the value step, or its Save adds the wrong filter; a composing Enter commits. | `audit:PowerSearch/sheet` | -| FR10–FR21, AR4–AR6, PR5 | Focused PowerSearch sheet tests with the compact-touch query stubbed both ways, plus real-engine touch evidence, and a real-engine width sweep of a long placeholder in both writing directions | the default resolving both ways, `popover` kept on a compact coarse-pointer screen, forced sheet, adaptive both ways (the default's server markup the same as `popover`'s, server markup and hydration as the popover field on a coarse-pointer client, then the trigger, no recoverable error, focus on the body; with `hasAutoFocus`, the autofocused input's focus ending on the trigger with no `onBlur` or `onFocus` to the caller), trigger name, Filters/Add filter/value steps, each value type, list value through the Tokenizer sheet, Clear all, read-only, disabled while open, focus after each step, focus after an `adaptive` switch from the trigger, the input, a removed control, an open editor popover, and from outside the field, a field inside an open Dialog announcing the count, Clear all, and in-sheet messages inside that Dialog and never on the page body, StrictMode result count, in-sheet live region while a sheet is open (added, removed, count, empty results), Clear all announced only after the dialog's exit, row, token and Removed text sharing one formatter, a date-only value as its day in `timezoneID`, else the UTC day, and a date-and-time value in `timezoneID`, else the viewer's zone, on all three (UTC, Tokyo, Honolulu, unset), summaries and relative-date labels and values from the catalog, the row and Removed through one reorderable message, an unmatched relative-date value as stored, a filter the config no longer knows listed and removable, a cleared number unstaged, a stale read-only filter as a plain row, a removal next to a nested row focusing that row's remove action, a list value joined by the locale's narrow conjunction list in English, Simplified Chinese, Japanese, and German, an empty-result message spoken once per query from its rendered element, a controlled update that removes the edited field moving focus from the replaced body to Cancel and announcing the unavailable state in the sheet while the step is open and never from a step beneath another or retained closed, Apply and Cancel after a controlled update removed the edited filter focusing the nearest row, else Add filter, a row's trailing remove action focusing the next row's remove action, a one-tap `empty`-valued filter added from its field row and removed from its row, Clear all behind its confirmation keeping read-only filters and leaving Filters open, a dismissed step revealing the step beneath with focus restored to it, Add filter opening with its search unfocused and a touch drag on the rows blurring a focused search, a stale filter's step titled as its row reads (raw keys for what is gone, the field's label when the field remains), Cancel from creation after the opening field was removed focusing the Add filter sheet's first control, a removed focused Filters row, a removed Clear all, and a dropped focused field row each handing focus to the nearest remaining row or the sheet's first control, element counts at rest and with each of the Filters, Add filter and value sheets open, and with the Tokenizer's list-value sheet stacked above the value step, under fine and coarse pointers, nothing of the flow in the DOM at rest before a press and after the exit, a nested filter edited and created through the built-in nested editor (its sub-filter rows wrapping inside a 390 and a 414 px sheet; its root operator picker absent on a mixed field, the Operator group in its place), a nested-only field and its suggestion offered, a suggestion's operator checked over the field's default, the Operator group outside a caller's Editor override on a mixed field, a count changed during the exit spoken with Clear all's message as one catalog message after the close, a single choice as a RadioList with one radio group whose arrow keys move and check, a multiple choice as a CheckboxList whose rows Space toggles, right-to-left layout with the row chevrons mirrored in RTL (`design:bidirectionality/DR4`) | A field with a fine pointer or on a screen that is not compact changes by default beyond what FR19 states, `presentation="popover"` presents the sheet flow, a value commits before the step confirms, Clear all removes a read-only filter, the trigger carries native `disabled`, focus lands elsewhere, an announcement reaches a channel outside the modal that holds the field at that moment, or the popover bundle carries the sheets. | `audit:PowerSearch/sheet` | -| Host `data-*` placement | `PowerSearchBottomSheet.test.tsx` cases "passes data-* attributes to the trigger, the primary control" and "passes data-* attributes to the combobox input in the popover presentation"; the `PowerSearchToken` and `PowerSearchFilterEditor` fixtures in `__tests__/hostDataAttributes.test.tsx` | The sheet trigger, the popover combobox input, the default token, the default editor | An attribute that misses the primary control, lands on a second element, or is dropped by a default fails. | `audit:PowerSearch/interaction` | -| Record structure | `scripts/check-knowledge.mjs` | Component-contract schema and current-authority dependency | Missing or invalid metadata and sections fail repository validation. | `audit:PowerSearch/knowledge` | +| FR22 | PowerSearch and Tokenizer unit tests | A read-only field with a filter: no Clear all, no token remove control, Backspace on the empty input | A read-only field removes a filter through Backspace, Clear all, or a token control. | `audit:PowerSearch/interaction` | +| FR23 | PowerSearch and Tokenizer unit tests | Clear all with a read-only filter before two editable ones; every filter read-only; Backspace with a read-only last filter; the words with and without a read-only filter left | A read-only filter is removed, Clear all reports an index other than the first removed one, Clear all shows with no editable filter, or its words say every filter went while one remains. | `audit:PowerSearch/interaction` | +| FR24 | `PowerSearchTokenNaming.test.tsx`; real-Chromium accessibility tree of a popover token | Popover token with a value, read-only token, editor open and closed, a verb-last remove word | A token named without its value, a missing or stale `aria-expanded`, an unnamed or non-dialog editor, or a remove name that loses its locale's word order fails. | `audit:PowerSearch/accessibility` | +| FR25 | PowerSearch date-zone tests under four host zones (UTC, Los Angeles, Tokyo, Honolulu) with `timezoneID` set to each zone and unset: token text, the removal announcement that carries the accessible label, the editor's opening day, the stored instant after a pick, a round trip that moves the day and back, a `components` Editor override and `PowerSearchFilterEditor` receiving the zone, range parts read and written, and an `isDateOnly: false` value left to FR26; plus the formatter's unit tests | a Los Angeles evening instant with `timezoneID` set and unset, a pick across the US daylight-time change, a `date_range` of two instants | The token and the editor show different days for one value, a re-picked day moves the instant, or a day shows a time | `audit:PowerSearch/interaction` | +| FR26 | PowerSearch date-and-time tests under four host zones (UTC, Los Angeles, Tokyo, Honolulu) with `timezoneID` set and unset: the token's date and time, the editor's opening date and time, the stored instant after a time is typed, a `components` Editor override and `PowerSearchFilterEditor` receiving the zone, the editor on a line of its own, and a date-only operator kept on the date picker; plus the sheet's value step opening on the time in `timezoneID` | a Los Angeles evening instant with `isDateOnly: false` and `timezoneID` Los Angeles, Tokyo, empty and unset; the same instant with `isDateOnly: true` | The token shows no time, the editor has no time field or opens on another time than the token shows, a typed time stores a different instant than it names, or a date-only operator gains a time field | `audit:PowerSearch/interaction` | +| FR27–FR29, AR7 | `usePowerSearchSource.test.ts` unit tests with a deferred search source, plus PowerSearch typeahead tests of the rendered rows, the development warning, and the accessibility tree | no operator opted in; opted-in free-text, `enum`, `enum_list`, and `entity_list` operators, a `string` search-source operator with and without `isArbitraryStringAllowed` (source rows only, no free-text row), and a `string_list` search-source operator with it (a free-text row), beside operators not opted in; an opted-in operator under a field with `isValueMatchAllowed: false` (no row, one development warning, and no source call on its account); `typeaheadMinQueryLength` above and below two; a one-character query; a label-led and a bare-label query, and a label-led query in another case; a word-start, a mid-word, an accented, an uppercase, and a Turkish ı query; whole-label and label-start ranking; an `entity_list` row's text and option name; a locale whose row message reorders the field, operator, and value; a field's fourth match and its "More" row, reached by the arrow keys and opening the editor with the text as its search query while the list closes; an `enum` field's "More" row opening the Selector on its full list, and an `enum_list` field's opening its Tokenizer with the text as its search; the content-search row first and highlighted; Enter with and without a content-search row; two search-source fields answering out of order; two opted-in operators sharing one source (one call per query, its items under both, neither call cancelled by the other); the announced count including a "More" row; a superseded query's late answer; the content-search field's own free-text row absent while the content-search row shows; a rejecting source; `maxSearchResults` of 2 with three contributing fields; an opted-in operator in a config without `valueOnlyMatches` | A value row appears for an operator not opted in, under a disallowing field, or for a label-led or short query; the warning is missing; a mid-word match lists; a row commits another filter than it names; a field shows more than three rows, a fourth match has no "More" row, or the "More" row commits a filter; a later answer inserts above shown rows, or a stale answer shows; or `maxSearchResults` hides a field's rows.; a value-only row from a config without the matcher, or no warning for it | `audit:PowerSearch/interaction` | +| FR28, FR29, AR7 timing | PowerSearch typeahead tests with fake timers and a deferred search source | a word typed within 150 ms (one source call, with the whole word) while the rows that need no source show at once; Enter while a source is pending, and with no value match; a composing Enter; Escape keeping the text, and a pending answer not reopening the list; a chosen value row clearing the text and closing the list; `aria-activedescendant` naming a highlighted value row and keeping its id as rows append | A source called per keystroke or before the wait; an Enter that waits for or chooses a pending row; a composing Enter that commits; an Escape that clears the text; a chosen row that leaves the text; or an active descendant that is missing or changes for the same row. | `audit:PowerSearch/interaction` | +| FR18, FR30, AR7 sheet | Focused PowerSearch sheet tests with a deferred search source: rows that join below the rows shown, no empty state and a busy search while pending, one count announcement at settle, a stale answer dropped, and a "More" row only past three rows | Add filter's content search with opted-in free-text, `enum`, and search-source operators; the rows that need no source shown at once with the search busy, and a search-source field's rows joining below them when a deferred source answers, one call per distinct source after the hold; no empty state while a source is pending, and the count announced once, at settle, inside Add filter; an answer for a superseded query dropped; a search-source field with no match listing no row; a field's fourth match and its "More" row button opening the value step with the text, and no "More" row for a field with three rows or fewer; a "More" row carrying the text into a `string` text field, into a `string` search source's Typeahead query, and into the query a `string_list` value's Tokenizer sheet opens with, and an `enum_list` value's CheckboxList showing its full list; a people field's "More" row opening its Tokenizer sheet directly above Add filter, searching the text, focus on its panel; its Save with an item adding one filter with the field's first opted-in operator, recorded, announced, and showing Filters with focus on its row; its Save after Clear all, a clean dismissal, and a dismissal of a changed draft through its discard confirmation, each revealing Add filter with the text kept and focus on the content search; a field whose first opted-in `entity_list` operator has no `searchSource` opening the value step; no trigger left in Add filter after the people sheet closes; a value row added to the draft and Add filter closed; Enter committing the content-search row, also while a source is pending; a composing Enter; Escape dismissing Add filter; a config with no content-search field | Source matches never list in the sheet, or a "More" row stands in for them; a later row displays above a shown row; an empty state shows while pending; the count is announced before settle or twice; a stale answer shows; a field hides a match with no "More" row; a "More" row drops the text an editor can take; a people field's "More" row opens the value step, or its Save adds the wrong filter; a composing Enter commits. | `audit:PowerSearch/sheet` | +| FR10–FR21, AR4–AR6, PR5 | Focused PowerSearch sheet tests with the compact-touch query stubbed both ways, plus real-engine touch evidence, and a real-engine width sweep of a long placeholder in both writing directions | the default resolving both ways, `popover` kept on a compact coarse-pointer screen, forced sheet, adaptive both ways (the default's server markup the same as `popover`'s, server markup and hydration as the popover field on a coarse-pointer client, then the trigger, no recoverable error, focus on the body; with `hasAutoFocus`, the autofocused input's focus ending on the trigger with no `onBlur` or `onFocus` to the caller), trigger name, Filters/Add filter/value steps, each value type, list value through the Tokenizer sheet, Clear all, read-only, disabled while open, focus after each step, focus after an `adaptive` switch from the trigger, the input, a removed control, an open editor popover, and from outside the field, a field inside an open Dialog announcing the count, Clear all, and in-sheet messages inside that Dialog and never on the page body, StrictMode result count, in-sheet live region while a sheet is open (added, removed, count, empty results), Clear all announced only after the dialog's exit, row, token and Removed text sharing one formatter, a date-only value as its day in `timezoneID`, else the UTC day, and a date-and-time value in `timezoneID`, else the viewer's zone, on all three (UTC, Tokyo, Honolulu, unset), summaries and relative-date labels and values from the catalog, the row and Removed through one reorderable message, an unmatched relative-date value as stored, a filter the config no longer knows listed and removable, a cleared number unstaged, a stale read-only filter as a plain row, a removal next to a nested row focusing that row's remove action, a list value joined by the locale's narrow conjunction list in English, Simplified Chinese, Japanese, and German, an empty-result message spoken once per query from its rendered element, a controlled update that removes the edited field moving focus from the replaced body to Cancel and announcing the unavailable state in the sheet while the step is open and never from a step beneath another or retained closed, Apply and Cancel after a controlled update removed the edited filter focusing the nearest row, else Add filter, a row's trailing remove action focusing the next row's remove action, a one-tap `empty`-valued filter added from its field row and removed from its row, Clear all behind its confirmation keeping read-only filters and leaving Filters open, a dismissed step revealing the step beneath with focus restored to it, Add filter opening with its search unfocused and a touch drag on the rows blurring a focused search, a stale filter's step titled as its row reads (raw keys for what is gone, the field's label when the field remains), Cancel from creation after the opening field was removed focusing the Add filter sheet's first control, a removed focused Filters row, a removed Clear all, and a dropped focused field row each handing focus to the nearest remaining row or the sheet's first control, element counts at rest and with each of the Filters, Add filter and value sheets open, and with the Tokenizer's list-value sheet stacked above the value step, under fine and coarse pointers, nothing of the flow in the DOM at rest before a press and after the exit, a nested filter edited and created through the built-in nested editor (its sub-filter rows wrapping inside a 390 and a 414 px sheet; its root operator picker absent on a mixed field, the Operator group in its place), a nested-only field and its suggestion offered, a suggestion's operator checked over the field's default, the Operator group outside a caller's Editor override on a mixed field, a count changed during the exit spoken with Clear all's message as one catalog message after the close, a single choice as a RadioList with one radio group whose arrow keys move and check, a multiple choice as a CheckboxList whose rows Space toggles, right-to-left layout with the row chevrons mirrored in RTL (`design:bidirectionality/DR4`) | A field with a fine pointer or on a screen that is not compact changes by default beyond what FR19 states, `presentation="popover"` presents the sheet flow, a value commits before the step confirms, Clear all removes a read-only filter, the trigger carries native `disabled`, focus lands elsewhere, an announcement reaches a channel outside the modal that holds the field at that moment, or the popover bundle carries the sheets. | `audit:PowerSearch/sheet` | +| Host `data-*` placement | `PowerSearchBottomSheet.test.tsx` cases "passes data-* attributes to the trigger, the primary control" and "passes data-* attributes to the combobox input in the popover presentation"; the `PowerSearchToken` and `PowerSearchFilterEditor` fixtures in `__tests__/hostDataAttributes.test.tsx` | The sheet trigger, the popover combobox input, the default token, the default editor | An attribute that misses the primary control, lands on a second element, or is dropped by a default fails. | `audit:PowerSearch/interaction` | +| Record structure | `scripts/check-knowledge.mjs` | Component-contract schema and current-authority dependency | Missing or invalid metadata and sections fail repository validation. | `audit:PowerSearch/knowledge` | Current-source Chromium evidence establishes the geometry gap, not implementation completion: diff --git a/packages/core/src/PowerSearch/valueOnlyOptIn.ts b/packages/core/src/PowerSearch/valueOnlyOptIn.ts index d65f38689775c..6f1bb51844dfc 100644 --- a/packages/core/src/PowerSearch/valueOnlyOptIn.ts +++ b/packages/core/src/PowerSearch/valueOnlyOptIn.ts @@ -13,32 +13,32 @@ import type {PowerSearchValueOnlyMatches} from './types'; import type {InternalConfig} from './useInternalConfig'; import type {withValueOnlyMatches} from './valueOnlyMatches'; - -const MATCHER = Symbol.for( - '@astryxdesign/core/power-search/value-only-matcher', -); +import {sharedBrand} from '../utils/sharedRealm'; /** The matcher a `PowerSearchValueOnlyMatches` value carries. */ export interface ValueOnlyMatcher { readonly withValueOnlyMatches: typeof withValueOnlyMatches; } -interface CarriedMatcher { - readonly [MATCHER]?: ValueOnlyMatcher; -} +const matcherBrand = sharedBrand( + 'power-search/value-only-matcher', + 1, +); /** Wraps a matcher in the opaque value callers pass (valueOnlyMatches.ts). */ export function makeValueOnlyMatches( matcher: ValueOnlyMatcher, ): PowerSearchValueOnlyMatches { - return Object.freeze(Object.defineProperty({}, MATCHER, {value: matcher})); + return Object.freeze( + Object.defineProperty({}, matcherBrand.key, {value: matcher}), + ); } /** The matcher a config's `valueOnlyMatches` carries, or null. */ export function valueOnlyMatcherOf( value: PowerSearchValueOnlyMatches | undefined, ): ValueOnlyMatcher | null { - return (value as CarriedMatcher | undefined)?.[MATCHER] ?? null; + return matcherBrand.read(value) ?? null; } /** Whether a field that allows value matches has an operator that opts in. */ From fd0da6bb2dbc7a17a6b239ccd66d3e9ace46ccdc Mon Sep 17 00:00:00 2001 From: Cindy Zhang Date: Thu, 3 Dec 2026 06:44:07 -0800 Subject: [PATCH 4/4] docs(PowerSearch): the pending release notes and the states table name the matcher --- .../powersearch-value-only-matches-sheet.md | 2 +- .changeset/powersearch-value-only-matches.md | 2 +- .changeset/powersearch-value-only-opt-in.md | 7 --- .../PowerSearch/PowerSearch.spec.md | 53 ++++++++++--------- 4 files changed, 29 insertions(+), 35 deletions(-) delete mode 100644 .changeset/powersearch-value-only-opt-in.md diff --git a/.changeset/powersearch-value-only-matches-sheet.md b/.changeset/powersearch-value-only-matches-sheet.md index 2bf442ab16b0f..d1fbf5c44a5d7 100644 --- a/.changeset/powersearch-value-only-matches-sheet.md +++ b/.changeset/powersearch-value-only-matches-sheet.md @@ -2,6 +2,6 @@ '@astryxdesign/core': patch --- -[feat] `PowerSearch`: in the sheet presentation, Add filter's content search lists the value-only matches of operators that set `isValueOnlyMatchAllowed` (`component:PowerSearch` FR30), after its other suggestions, at most three per field, with a "More {field} matching '{text}'" row after a field's rows when it has more. The list follows incremental search results, as the typeahead's does: the rows that need no source show at once, and a search-source field's rows join below them when its source answers, after the same 150 ms hold, with one call per distinct source. While a query waits on a source, the search shows its loading indicator and no empty state, and the result count is announced once, when the query settles. A "More" row opens the value step, carrying the typed text where the editor takes one (a text field's value, a search source's query, or the query a list value's Tokenizer sheet opens with); an `enum` or `enum_list` value lists in full. A people field's "More" row, where the first opted-in operator takes an `entity_list` value with a `searchSource`, opens that operator's Tokenizer sheet directly above Add filter, already searching the text; its Save adds the filter and shows Filters, and an empty Save or a dismissal returns to Add filter with the text kept. +[feat] `PowerSearch`: in the sheet presentation, Add filter's content search lists the value-only matches of operators that set `isValueOnlyMatchAllowed`, in a config that passes `valueOnlyMatches: powerSearchValueOnlyMatches` (`component:PowerSearch` FR30), after its other suggestions, at most three per field, with a "More {field} matching '{text}'" row after a field's rows when it has more. The list follows incremental search results, as the typeahead's does: the rows that need no source show at once, and a search-source field's rows join below them when its source answers, after the same 150 ms hold, with one call per distinct source. While a query waits on a source, the search shows its loading indicator and no empty state, and the result count is announced once, when the query settles. A "More" row opens the value step, carrying the typed text where the editor takes one (a text field's value, a search source's query, or the query a list value's Tokenizer sheet opens with); an `enum` or `enum_list` value lists in full. A people field's "More" row, where the first opted-in operator takes an `entity_list` value with a `searchSource`, opens that operator's Tokenizer sheet directly above Add filter, already searching the text; its Save adds the filter and shows Filters, and an empty Save or a dismissal returns to Add filter with the text kept. @imdreamrunner diff --git a/.changeset/powersearch-value-only-matches.md b/.changeset/powersearch-value-only-matches.md index 961cc32fcf487..e00038eb5735f 100644 --- a/.changeset/powersearch-value-only-matches.md +++ b/.changeset/powersearch-value-only-matches.md @@ -2,6 +2,6 @@ '@astryxdesign/core': patch --- -[feat] `PowerSearch`: an operator's new `isValueOnlyMatchAllowed: true` suggests its complete filters for a typed value alone, with no field label before it (`component:PowerSearch` FR27–FR29, DEC-8). Typing "fiction" offers `Genre is Fiction` after the field and field-and-operator rows: a `string` or `string_list` operator without a `searchSource` offers the typed text, an `enum` or `enum_list` operator the values with a word that starts with it (ignoring case and accents, whole-label matches first), and an operator with a `searchSource` the items that source returns. Each distinct source is asked once per query, once the text has rested 150 ms, and its rows append below the others. A field shows at most three of these rows from two characters (or its `typeaheadMinQueryLength`), with a "More {field} matching '{text}'" row after a field's rows when it has more, which opens that field's value editor, carrying the typed text into an editor that searches (an `enum` field's editor opens on its full list). They do not count toward `maxSearchResults`. The option is off by default, so a config that opts no operator in keeps every list as it is; a field's `isValueMatchAllowed: false` turns these rows off too, and an opt-in under it warns once in development. +[feat] `PowerSearch`: an operator's new `isValueOnlyMatchAllowed: true`, in a config that passes `valueOnlyMatches: powerSearchValueOnlyMatches` (imported from `@astryxdesign/core`), suggests its complete filters for a typed value alone, with no field label before it (`component:PowerSearch` FR27–FR29, DEC-8). Typing "fiction" offers `Genre is Fiction` after the field and field-and-operator rows: a `string` or `string_list` operator without a `searchSource` offers the typed text, an `enum` or `enum_list` operator the values with a word that starts with it (ignoring case and accents, whole-label matches first), and an operator with a `searchSource` the items that source returns. Each distinct source is asked once per query, once the text has rested 150 ms, and its rows append below the others. A field shows at most three of these rows from two characters (or its `typeaheadMinQueryLength`), with a "More {field} matching '{text}'" row after a field's rows when it has more, which opens that field's value editor, carrying the typed text into an editor that searches (an `enum` field's editor opens on its full list). They do not count toward `maxSearchResults`. The option is off by default, so a config that opts no operator in keeps every list as it is, and a page whose configs do not pass the matcher ships none of its code; an opt-in in a config without the matcher lists nothing and warns once in development; a field's `isValueMatchAllowed: false` turns these rows off too, and an opt-in under it warns once in development. @imdreamrunner diff --git a/.changeset/powersearch-value-only-opt-in.md b/.changeset/powersearch-value-only-opt-in.md deleted file mode 100644 index 6396eef80b7a8..0000000000000 --- a/.changeset/powersearch-value-only-opt-in.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@astryxdesign/core': patch ---- - -[perf] PowerSearch: value-only matches (operators with `isValueOnlyMatchAllowed: true`) now come from an opt-in import. Pass `valueOnlyMatches: powerSearchValueOnlyMatches` in the config, imported from `@astryxdesign/core`. A page whose configs do not pass it ships none of the matcher's code, and PowerSearch no longer loads it on first focus. An opt-in in a config without the matcher lists no value-only match and warns once in development. - -@cixzhang diff --git a/docs/specs/components/PowerSearch/PowerSearch.spec.md b/docs/specs/components/PowerSearch/PowerSearch.spec.md index 2f3e28db1114a..745e9fe71b8e8 100644 --- a/docs/specs/components/PowerSearch/PowerSearch.spec.md +++ b/docs/specs/components/PowerSearch/PowerSearch.spec.md @@ -403,31 +403,32 @@ presentation's typeahead, and FR30 the same rows in the sheet's content search. ### Representative states -| State | Required invariant | Allowed variation | -| ------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -| Outer PowerSearch narrower than 400 px | Editor prefers 400 px and logical-start alignment to the outer surface, but yields to available viewport width. | Layer runtime may shift or shrink it to remain visible. | -| Outer PowerSearch from 400 through 720 px | Editor matches the outer surface and remains logical-start aligned. | Existing vertical collision behavior may flip. | -| Wider than 720 px; add from inner input near left | Editor is 720 px wide and prefers the outer surface's physical left edge. | Viewport collision handling may shift it. | -| Wider than 720 px; add from inner input near right | Editor is 720 px wide and prefers the outer surface's physical right edge. | Viewport collision handling may shift it. | -| Wider than 720 px; edit a token/control near either end | Editor is 720 px wide and prefers the outer edge nearest that activated control. | Custom token markup may vary; identity remains exact. | -| Wider than 720 px; opening control is equidistant | Editor is 720 px wide and uses the outer surface's logical-start edge. | Direction determines the physical start edge. | -| Pointer, keyboard, or programmatic activation | The same stable opening control produces the same preferred edge regardless of activation modality. | Focus behavior remains unchanged. | -| Reopen from a control on the opposite side | Opening-control identity and preferred edge are recalculated for the new open, then remain latched until close. | Later layout changes do not move the open editor. | -| Sheet presentation, closed | The trigger shows the tokens or placeholder, `aria-expanded="false"`; its name is the label plus the visible text. | Token wrapping and placeholder text may vary. | -| Sheet presentation, Filters | One tall modal sheet named "Filters": fixed header with Add filter, rows with trailing remove actions scrolling between it and the fixed footer's Done, which applies the draft, and Clear all; with no filter, the centered Add filter is the only action, Done staying while the draft has removals to apply. | Row count and the empty state's guidance text may vary. | -| Sheet presentation, Add filter | Above Filters: fixed header with an unfocused search when one shows, grouped field rows (the ungrouped ones under "General") or the content search's inline suggestions, and a compact empty state when a settled search matches nothing; no Back — a dismissal reveals Filters. | Field search appears from eight fields. | -| Sheet presentation, value step | Above the sheet that led to it: title, operator radios when needed, the staged editor on the sheet surface (or in muted sections with the operator group), Cancel and the confirm action; no Remove. | Editor per value type follows FR17. | -| Sheet presentation, Clear all | A confirmation dialog above Filters; confirming removes the editable filters, keeps read-only ones, and leaves Filters open with focus on it. | The confirmation's wording may vary. | -| Sheet presentation, list value | The Tokenizer's sheet opens above the step, titled with the field label, as the top sheet of the stack under its one scrim; Escape closes it alone. | One backdrop per stack, dismissal at the top sheet (`component:BottomSheet` FR6, FR7). | -| Sheet presentation, disabled while open | The flow closes; focus returns to the trigger; the trigger stays focusable. | Exit motion may vary. | -| Sheet presentation, `adaptive` resolution | The surface follows the shared compact-touch query while closed; an open flow keeps its presentation until it closes. | The query is shared, not PowerSearch-owned. | -| Value-only query, no operator opted in | Field, field-and-operator, and content-search rows only; a value row appears only after a field label. | None. | -| Value-only query, an operator opted in | The content-search row first and highlighted, then field rows, then the opted-in value rows in one flat list, field by field, at most three per field and then a "More" row when the field has more. | Row icons and styling may vary. | -| Value-only query, a search-source field pending | Rows of fields without a source show at once; a search-source field's rows, its free-text rows with them, append below once its source settles, and the highlight stays. | Busy feedback follows `spec:AST-092`. | -| Value-only query shorter than a field's minimum | That field adds no value-only match; its field row follows `typeaheadMinQueryLength`. | None. | -| Value-only query, an opt-in under a disallowing field | No row from that operator, and one development warning naming the field and the operator. | None. | -| Value-only query, keys | Arrows move through every row; Enter chooses the highlighted row, the content-search row while sources are pending or nothing matches; a composing Enter chooses nothing; Escape closes the list and keeps the text. | None. | -| Sheet presentation, value-only query | After the other suggestions, field by field, at most three rows per field and a "More" row when a field has more; source rows join below the rows shown when their source answers, the search busy and no empty state meanwhile; a people field's "More" row opens its people search on the typed text. | Row icons and styling may vary. | +| State | Required invariant | Allowed variation | +| -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| Outer PowerSearch narrower than 400 px | Editor prefers 400 px and logical-start alignment to the outer surface, but yields to available viewport width. | Layer runtime may shift or shrink it to remain visible. | +| Outer PowerSearch from 400 through 720 px | Editor matches the outer surface and remains logical-start aligned. | Existing vertical collision behavior may flip. | +| Wider than 720 px; add from inner input near left | Editor is 720 px wide and prefers the outer surface's physical left edge. | Viewport collision handling may shift it. | +| Wider than 720 px; add from inner input near right | Editor is 720 px wide and prefers the outer surface's physical right edge. | Viewport collision handling may shift it. | +| Wider than 720 px; edit a token/control near either end | Editor is 720 px wide and prefers the outer edge nearest that activated control. | Custom token markup may vary; identity remains exact. | +| Wider than 720 px; opening control is equidistant | Editor is 720 px wide and uses the outer surface's logical-start edge. | Direction determines the physical start edge. | +| Pointer, keyboard, or programmatic activation | The same stable opening control produces the same preferred edge regardless of activation modality. | Focus behavior remains unchanged. | +| Reopen from a control on the opposite side | Opening-control identity and preferred edge are recalculated for the new open, then remain latched until close. | Later layout changes do not move the open editor. | +| Sheet presentation, closed | The trigger shows the tokens or placeholder, `aria-expanded="false"`; its name is the label plus the visible text. | Token wrapping and placeholder text may vary. | +| Sheet presentation, Filters | One tall modal sheet named "Filters": fixed header with Add filter, rows with trailing remove actions scrolling between it and the fixed footer's Done, which applies the draft, and Clear all; with no filter, the centered Add filter is the only action, Done staying while the draft has removals to apply. | Row count and the empty state's guidance text may vary. | +| Sheet presentation, Add filter | Above Filters: fixed header with an unfocused search when one shows, grouped field rows (the ungrouped ones under "General") or the content search's inline suggestions, and a compact empty state when a settled search matches nothing; no Back — a dismissal reveals Filters. | Field search appears from eight fields. | +| Sheet presentation, value step | Above the sheet that led to it: title, operator radios when needed, the staged editor on the sheet surface (or in muted sections with the operator group), Cancel and the confirm action; no Remove. | Editor per value type follows FR17. | +| Sheet presentation, Clear all | A confirmation dialog above Filters; confirming removes the editable filters, keeps read-only ones, and leaves Filters open with focus on it. | The confirmation's wording may vary. | +| Sheet presentation, list value | The Tokenizer's sheet opens above the step, titled with the field label, as the top sheet of the stack under its one scrim; Escape closes it alone. | One backdrop per stack, dismissal at the top sheet (`component:BottomSheet` FR6, FR7). | +| Sheet presentation, disabled while open | The flow closes; focus returns to the trigger; the trigger stays focusable. | Exit motion may vary. | +| Sheet presentation, `adaptive` resolution | The surface follows the shared compact-touch query while closed; an open flow keeps its presentation until it closes. | The query is shared, not PowerSearch-owned. | +| Value-only query, no operator opted in | Field, field-and-operator, and content-search rows only; a value row appears only after a field label. | None. | +| Value-only query, an operator opted in | The content-search row first and highlighted, then field rows, then the opted-in value rows in one flat list, field by field, at most three per field and then a "More" row when the field has more. | Row icons and styling may vary. | +| Value-only query, a search-source field pending | Rows of fields without a source show at once; a search-source field's rows, its free-text rows with them, append below once its source settles, and the highlight stays. | Busy feedback follows `spec:AST-092`. | +| Value-only query shorter than a field's minimum | That field adds no value-only match; its field row follows `typeaheadMinQueryLength`. | None. | +| Value-only query, an opt-in under a disallowing field | No row from that operator, and one development warning naming the field and the operator. | None. | +| Value-only query, an opt-in without the config's matcher | No row from that operator, and one development warning naming `valueOnlyMatches`. | None. | +| Value-only query, keys | Arrows move through every row; Enter chooses the highlighted row, the content-search row while sources are pending or nothing matches; a composing Enter chooses nothing; Escape closes the list and keeps the text. | None. | +| Sheet presentation, value-only query | After the other suggestions, field by field, at most three rows per field and a "More" row when a field has more; source rows join below the rows shown when their source answers, the search busy and no empty state meanwhile; a people field's "More" row opens its people search on the typed text. | Row icons and styling may vary. | ### Transformation and precedence order @@ -712,7 +713,7 @@ mark implementation and focused real-Chromium verification as pending. | FR24 | `PowerSearchTokenNaming.test.tsx`; real-Chromium accessibility tree of a popover token | Popover token with a value, read-only token, editor open and closed, a verb-last remove word | A token named without its value, a missing or stale `aria-expanded`, an unnamed or non-dialog editor, or a remove name that loses its locale's word order fails. | `audit:PowerSearch/accessibility` | | FR25 | PowerSearch date-zone tests under four host zones (UTC, Los Angeles, Tokyo, Honolulu) with `timezoneID` set to each zone and unset: token text, the removal announcement that carries the accessible label, the editor's opening day, the stored instant after a pick, a round trip that moves the day and back, a `components` Editor override and `PowerSearchFilterEditor` receiving the zone, range parts read and written, and an `isDateOnly: false` value left to FR26; plus the formatter's unit tests | a Los Angeles evening instant with `timezoneID` set and unset, a pick across the US daylight-time change, a `date_range` of two instants | The token and the editor show different days for one value, a re-picked day moves the instant, or a day shows a time | `audit:PowerSearch/interaction` | | FR26 | PowerSearch date-and-time tests under four host zones (UTC, Los Angeles, Tokyo, Honolulu) with `timezoneID` set and unset: the token's date and time, the editor's opening date and time, the stored instant after a time is typed, a `components` Editor override and `PowerSearchFilterEditor` receiving the zone, the editor on a line of its own, and a date-only operator kept on the date picker; plus the sheet's value step opening on the time in `timezoneID` | a Los Angeles evening instant with `isDateOnly: false` and `timezoneID` Los Angeles, Tokyo, empty and unset; the same instant with `isDateOnly: true` | The token shows no time, the editor has no time field or opens on another time than the token shows, a typed time stores a different instant than it names, or a date-only operator gains a time field | `audit:PowerSearch/interaction` | -| FR27–FR29, AR7 | `usePowerSearchSource.test.ts` unit tests with a deferred search source, plus PowerSearch typeahead tests of the rendered rows, the development warning, and the accessibility tree | no operator opted in; opted-in free-text, `enum`, `enum_list`, and `entity_list` operators, a `string` search-source operator with and without `isArbitraryStringAllowed` (source rows only, no free-text row), and a `string_list` search-source operator with it (a free-text row), beside operators not opted in; an opted-in operator under a field with `isValueMatchAllowed: false` (no row, one development warning, and no source call on its account); `typeaheadMinQueryLength` above and below two; a one-character query; a label-led and a bare-label query, and a label-led query in another case; a word-start, a mid-word, an accented, an uppercase, and a Turkish ı query; whole-label and label-start ranking; an `entity_list` row's text and option name; a locale whose row message reorders the field, operator, and value; a field's fourth match and its "More" row, reached by the arrow keys and opening the editor with the text as its search query while the list closes; an `enum` field's "More" row opening the Selector on its full list, and an `enum_list` field's opening its Tokenizer with the text as its search; the content-search row first and highlighted; Enter with and without a content-search row; two search-source fields answering out of order; two opted-in operators sharing one source (one call per query, its items under both, neither call cancelled by the other); the announced count including a "More" row; a superseded query's late answer; the content-search field's own free-text row absent while the content-search row shows; a rejecting source; `maxSearchResults` of 2 with three contributing fields; an opted-in operator in a config without `valueOnlyMatches` | A value row appears for an operator not opted in, under a disallowing field, or for a label-led or short query; the warning is missing; a mid-word match lists; a row commits another filter than it names; a field shows more than three rows, a fourth match has no "More" row, or the "More" row commits a filter; a later answer inserts above shown rows, or a stale answer shows; or `maxSearchResults` hides a field's rows.; a value-only row from a config without the matcher, or no warning for it | `audit:PowerSearch/interaction` | +| FR27–FR29, AR7 | `usePowerSearchSource.test.ts` unit tests with a deferred search source, plus PowerSearch typeahead tests of the rendered rows, the development warning, and the accessibility tree | no operator opted in; opted-in free-text, `enum`, `enum_list`, and `entity_list` operators, a `string` search-source operator with and without `isArbitraryStringAllowed` (source rows only, no free-text row), and a `string_list` search-source operator with it (a free-text row), beside operators not opted in; an opted-in operator under a field with `isValueMatchAllowed: false` (no row, one development warning, and no source call on its account); `typeaheadMinQueryLength` above and below two; a one-character query; a label-led and a bare-label query, and a label-led query in another case; a word-start, a mid-word, an accented, an uppercase, and a Turkish ı query; whole-label and label-start ranking; an `entity_list` row's text and option name; a locale whose row message reorders the field, operator, and value; a field's fourth match and its "More" row, reached by the arrow keys and opening the editor with the text as its search query while the list closes; an `enum` field's "More" row opening the Selector on its full list, and an `enum_list` field's opening its Tokenizer with the text as its search; the content-search row first and highlighted; Enter with and without a content-search row; two search-source fields answering out of order; two opted-in operators sharing one source (one call per query, its items under both, neither call cancelled by the other); the announced count including a "More" row; a superseded query's late answer; the content-search field's own free-text row absent while the content-search row shows; a rejecting source; `maxSearchResults` of 2 with three contributing fields; an opted-in operator in a config without `valueOnlyMatches` | A value row appears for an operator not opted in, under a disallowing field, or for a label-led or short query; the warning is missing; a mid-word match lists; a row commits another filter than it names; a field shows more than three rows, a fourth match has no "More" row, or the "More" row commits a filter; a later answer inserts above shown rows, or a stale answer shows; or `maxSearchResults` hides a field's rows; a value-only row from a config without the matcher, or no warning for it. | `audit:PowerSearch/interaction` | | FR28, FR29, AR7 timing | PowerSearch typeahead tests with fake timers and a deferred search source | a word typed within 150 ms (one source call, with the whole word) while the rows that need no source show at once; Enter while a source is pending, and with no value match; a composing Enter; Escape keeping the text, and a pending answer not reopening the list; a chosen value row clearing the text and closing the list; `aria-activedescendant` naming a highlighted value row and keeping its id as rows append | A source called per keystroke or before the wait; an Enter that waits for or chooses a pending row; a composing Enter that commits; an Escape that clears the text; a chosen row that leaves the text; or an active descendant that is missing or changes for the same row. | `audit:PowerSearch/interaction` | | FR18, FR30, AR7 sheet | Focused PowerSearch sheet tests with a deferred search source: rows that join below the rows shown, no empty state and a busy search while pending, one count announcement at settle, a stale answer dropped, and a "More" row only past three rows | Add filter's content search with opted-in free-text, `enum`, and search-source operators; the rows that need no source shown at once with the search busy, and a search-source field's rows joining below them when a deferred source answers, one call per distinct source after the hold; no empty state while a source is pending, and the count announced once, at settle, inside Add filter; an answer for a superseded query dropped; a search-source field with no match listing no row; a field's fourth match and its "More" row button opening the value step with the text, and no "More" row for a field with three rows or fewer; a "More" row carrying the text into a `string` text field, into a `string` search source's Typeahead query, and into the query a `string_list` value's Tokenizer sheet opens with, and an `enum_list` value's CheckboxList showing its full list; a people field's "More" row opening its Tokenizer sheet directly above Add filter, searching the text, focus on its panel; its Save with an item adding one filter with the field's first opted-in operator, recorded, announced, and showing Filters with focus on its row; its Save after Clear all, a clean dismissal, and a dismissal of a changed draft through its discard confirmation, each revealing Add filter with the text kept and focus on the content search; a field whose first opted-in `entity_list` operator has no `searchSource` opening the value step; no trigger left in Add filter after the people sheet closes; a value row added to the draft and Add filter closed; Enter committing the content-search row, also while a source is pending; a composing Enter; Escape dismissing Add filter; a config with no content-search field | Source matches never list in the sheet, or a "More" row stands in for them; a later row displays above a shown row; an empty state shows while pending; the count is announced before settle or twice; a stale answer shows; a field hides a match with no "More" row; a "More" row drops the text an editor can take; a people field's "More" row opens the value step, or its Save adds the wrong filter; a composing Enter commits. | `audit:PowerSearch/sheet` | | FR10–FR21, AR4–AR6, PR5 | Focused PowerSearch sheet tests with the compact-touch query stubbed both ways, plus real-engine touch evidence, and a real-engine width sweep of a long placeholder in both writing directions | the default resolving both ways, `popover` kept on a compact coarse-pointer screen, forced sheet, adaptive both ways (the default's server markup the same as `popover`'s, server markup and hydration as the popover field on a coarse-pointer client, then the trigger, no recoverable error, focus on the body; with `hasAutoFocus`, the autofocused input's focus ending on the trigger with no `onBlur` or `onFocus` to the caller), trigger name, Filters/Add filter/value steps, each value type, list value through the Tokenizer sheet, Clear all, read-only, disabled while open, focus after each step, focus after an `adaptive` switch from the trigger, the input, a removed control, an open editor popover, and from outside the field, a field inside an open Dialog announcing the count, Clear all, and in-sheet messages inside that Dialog and never on the page body, StrictMode result count, in-sheet live region while a sheet is open (added, removed, count, empty results), Clear all announced only after the dialog's exit, row, token and Removed text sharing one formatter, a date-only value as its day in `timezoneID`, else the UTC day, and a date-and-time value in `timezoneID`, else the viewer's zone, on all three (UTC, Tokyo, Honolulu, unset), summaries and relative-date labels and values from the catalog, the row and Removed through one reorderable message, an unmatched relative-date value as stored, a filter the config no longer knows listed and removable, a cleared number unstaged, a stale read-only filter as a plain row, a removal next to a nested row focusing that row's remove action, a list value joined by the locale's narrow conjunction list in English, Simplified Chinese, Japanese, and German, an empty-result message spoken once per query from its rendered element, a controlled update that removes the edited field moving focus from the replaced body to Cancel and announcing the unavailable state in the sheet while the step is open and never from a step beneath another or retained closed, Apply and Cancel after a controlled update removed the edited filter focusing the nearest row, else Add filter, a row's trailing remove action focusing the next row's remove action, a one-tap `empty`-valued filter added from its field row and removed from its row, Clear all behind its confirmation keeping read-only filters and leaving Filters open, a dismissed step revealing the step beneath with focus restored to it, Add filter opening with its search unfocused and a touch drag on the rows blurring a focused search, a stale filter's step titled as its row reads (raw keys for what is gone, the field's label when the field remains), Cancel from creation after the opening field was removed focusing the Add filter sheet's first control, a removed focused Filters row, a removed Clear all, and a dropped focused field row each handing focus to the nearest remaining row or the sheet's first control, element counts at rest and with each of the Filters, Add filter and value sheets open, and with the Tokenizer's list-value sheet stacked above the value step, under fine and coarse pointers, nothing of the flow in the DOM at rest before a press and after the exit, a nested filter edited and created through the built-in nested editor (its sub-filter rows wrapping inside a 390 and a 414 px sheet; its root operator picker absent on a mixed field, the Operator group in its place), a nested-only field and its suggestion offered, a suggestion's operator checked over the field's default, the Operator group outside a caller's Editor override on a mixed field, a count changed during the exit spoken with Clear all's message as one catalog message after the close, a single choice as a RadioList with one radio group whose arrow keys move and check, a multiple choice as a CheckboxList whose rows Space toggles, right-to-left layout with the row chevrons mirrored in RTL (`design:bidirectionality/DR4`) | A field with a fine pointer or on a screen that is not compact changes by default beyond what FR19 states, `presentation="popover"` presents the sheet flow, a value commits before the step confirms, Clear all removes a read-only filter, the trigger carries native `disabled`, focus lands elsewhere, an announcement reaches a channel outside the modal that holds the field at that moment, or the popover bundle carries the sheets. | `audit:PowerSearch/sheet` |