Skip to content

Commit 8eed499

Browse files
committed
feat(PowerSearch): list value-only matches in the sheet's content search
In the sheet presentation, Add filter's content search lists the value-only matches of opted-in operators (component:PowerSearch FR30) under incremental search results (FR18, spec:AST-092), as the popover's typeahead does. - The rows that need no source show at once. A search-source field's rows come from the same source path as the typeahead's (the same deferred module, the 150 ms hold, one call per distinct source) and join below the rows shown when the source answers. A stale answer is dropped, and the flow closing cancels the query. - While a query waits on a source, the search is busy, with its loading indicator, and shows no empty state. The count is announced once, at settle, inside Add filter. - A field shows at most three rows, and a "More" row only when it has more. A search-source field with no match lists no row. - A value row adds its filter to the draft, as a suggestion that carries a value does. - A "More" row opens the value step with the typed text carried where the editor takes one. A people field's "More" row (its 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. Save adds one filter and shows Filters. An empty Save or a dismissal returns to Add filter with the text kept. The FR18 and FR30 status cells move from the implementation gap to their evidence.
1 parent 35e92a8 commit 8eed499

10 files changed

Lines changed: 1362 additions & 71 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@astryxdesign/core': patch
3+
---
4+
5+
[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.
6+
7+
@imdreamrunner

‎.changeset/powersearch-value-only-matches.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
'@astryxdesign/core': patch
33
---
44

5-
[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. The sheet presentation's content search does not list them.
5+
[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.
66

77
@imdreamrunner

‎apps/storybook/stories/PowerSearch.stories.tsx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,18 @@ export const ValueOnlyMatches: Story = {
17791779
name: 'Value-only matches',
17801780
};
17811781

1782+
// The sheet presentation lists the same rows: the people source's rows join
1783+
// below the others when it answers, and a people field with more than three
1784+
// matches ends with a "More" row that opens its people search on the text.
1785+
export const ValueOnlyMatchesSheet: Story = {
1786+
...ValueOnlyMatches,
1787+
args: {
1788+
...ValueOnlyMatches.args,
1789+
presentation: 'bottom-sheet',
1790+
},
1791+
name: 'Value-only matches (sheet)',
1792+
};
1793+
17821794
export const SizeVariants: Story = {
17831795
render: () => {
17841796
const [smFilters, setSmFilters] = useState<PowerSearchFilter[]>([

‎docs/specs/components/PowerSearch/PowerSearch.spec.md‎

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

‎packages/core/src/PowerSearch/PowerSearch.tsx‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ import {isFocusDetached} from '../utils/isFocusDetached';
7777
import {isRenderable} from '../utils/isRenderable';
7878
import {useInternalConfig} from './useInternalConfig';
7979
import {usePowerSearchSource} from './usePowerSearchSource';
80-
import {findDisallowedOptIns} from './valueOnlyMatchLoader';
80+
import {
81+
findDisallowedOptIns,
82+
hasValueOnlyOptIn,
83+
startValueOnlyMatchesLoad,
84+
} from './valueOnlyMatchLoader';
8185
import {formatDateRange, formatFilterValueForRender} from './formatFilterValue';
8286
import {NestedEditor, PowerSearchEditPopover} from './PowerSearchEditPopover';
8387
import {PowerSearchValueEditor} from './PowerSearchValueEditor';
@@ -670,18 +674,12 @@ export function PowerSearch({
670674
const [isSheetPresented, setIsSheetPresented] = useState(false);
671675
const isSheetPresentation =
672676
isSheetOpen || isSheetPresented || resolvedPresentation === 'bottom-sheet';
673-
// One source for the presentation that renders. Only the typeahead lists
674-
// value-only matches.
675-
const searchSource = usePowerSearchSource(
676-
config,
677-
maxSearchResults,
678-
isSheetPresentation
679-
? undefined
680-
: {
681-
maxSourceItems:
682-
maxOperatorMenuItems ?? DEFAULT_MAX_OPERATOR_MENU_ITEMS,
683-
},
684-
);
677+
// One source for the presentation that renders. Both list value-only
678+
// matches under incremental search results.
679+
const searchSource = usePowerSearchSource(config, maxSearchResults, {
680+
maxSourceItems: maxOperatorMenuItems ?? DEFAULT_MAX_OPERATOR_MENU_ITEMS,
681+
presentation: isSheetPresentation ? 'sheet' : 'popover',
682+
});
685683
const triggerRef = useRef<HTMLButtonElement>(null);
686684
// `hasAutoFocus` applies only to the control the field first mounts. A
687685
// presentation swap remounts the control (combobox input or trigger), and
@@ -1550,9 +1548,13 @@ export function PowerSearch({
15501548
// The flow restores focus to the element that was active when it opened;
15511549
// make sure that is the trigger even for a tap on a token.
15521550
triggerRef.current?.focus({preventScroll: true});
1551+
// Opening the flow is the first intent for Add filter's value-only rows.
1552+
if (hasValueOnlyOptIn(config)) {
1553+
startValueOnlyMatchesLoad();
1554+
}
15531555
setIsSheetPresented(true);
15541556
setIsSheetOpen(true);
1555-
}, [isDisabled]);
1557+
}, [config, isDisabled]);
15561558

15571559
// The field's end lane — the result count and `endContent` — sits outside
15581560
// the trigger button: a caller's action button there keeps its own tab stop

0 commit comments

Comments
 (0)