Skip to content

Commit 7e07d10

Browse files
committed
feat(core): PowerSearch touch sheet flow behind experimental.presentation
`experimental={{presentation: 'bottom-sheet' | 'adaptive'}}` makes the whole field one trigger with display-only filter tokens and moves filter editing into a flow of tall modal sheets: Filters (rows, Add filter, Done, Clear all), Add filter (grouped fields or the content search with inline suggestions), and a value step that stages field → operator → value and confirms from its footer. The flow loads on demand; `adaptive` resolves through the shared compact-touch policy. Value editors are Core's own in a sheet presentation; list values edit through the Tokenizer's sheet titled with the field label. Implements `component:PowerSearch` DEC-3 (FR10–FR21, AR4–AR6, PR5) and deletes the record's implementation-gap notes.
1 parent 8ef86f8 commit 7e07d10

12 files changed

Lines changed: 4528 additions & 106 deletions
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+
[experimental] PowerSearch gains a touch surface behind `experimental={{presentation: 'bottom-sheet' | 'adaptive'}}`. `bottom-sheet` makes the whole field one trigger showing display-only filter tokens, and moves filter editing into a flow of tall modal sheets: a Filters sheet listing the active filters as rows with Add filter, Done, and Clear all; an Add filter sheet with the fields grouped (searchable from eight fields), or the content search with the field typeahead's suggestions listed inline; and a value step that stages field → operator → value and confirms from its footer, with Remove while editing. Closed vocabularies are full-width rows, numbers stage as typed, and `string_list` / `entity_list` values edit through the Tokenizer's own sheet presentation titled with the field label. `adaptive` uses the sheet on compact coarse-pointer screens and the popover otherwise, resolved the same way Selector resolves it. The sheet flow loads on demand, so a PowerSearch that does not opt in does not carry it. New `@astryx.powersearch.sheet.*` catalog keys for the sheets' strings; no new theming target. The result-count announcement is now StrictMode-safe in both presentations (no announcement on mount). Anything inside PowerSearch's `experimental` prop may change or be removed in a patch release; omitting it keeps the stable behavior.
6+
7+
@imdreamrunner

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

Lines changed: 179 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,10 @@ const meta: Meta<typeof PowerSearch> = {
452452
component: PowerSearch,
453453
tags: ['autodocs'],
454454
decorators: [
455+
// A 600px column where there is room that shrinks with the viewport, so
456+
// the stories, the touch presentations above all, fit a phone-sized canvas.
455457
Story => (
456-
<div style={{width: 600}}>
458+
<div style={{display: 'grid', gridTemplateColumns: 'minmax(0, 600px)'}}>
457459
<Story />
458460
</div>
459461
),
@@ -1796,3 +1798,179 @@ export const StatusVariantComparison: Story = {
17961798
);
17971799
},
17981800
};
1801+
1802+
// =============================================================================
1803+
// Experimental bottom-sheet presentation
1804+
// =============================================================================
1805+
1806+
// The sheet flow is designed for a phone: view these stories at a compact
1807+
// touch viewport (Storybook's mobile2 preset) to see the sheets as a person
1808+
// would.
1809+
function PhoneFrame({children}: {children: React.ReactNode}) {
1810+
return <div style={{width: 390, maxWidth: '100%'}}>{children}</div>;
1811+
}
1812+
1813+
function FilterDump({filters}: {filters: ReadonlyArray<PowerSearchFilter>}) {
1814+
if (filters.length === 0) {
1815+
return null;
1816+
}
1817+
return (
1818+
<pre
1819+
style={{
1820+
marginTop: 16,
1821+
padding: 12,
1822+
borderRadius: 8,
1823+
fontSize: 12,
1824+
overflow: 'auto',
1825+
maxWidth: 390,
1826+
}}>
1827+
{JSON.stringify(filters, null, 2)}
1828+
</pre>
1829+
);
1830+
}
1831+
1832+
const sheetPresetFilters: ReadonlyArray<PowerSearchFilter> = [
1833+
{
1834+
field: 'status',
1835+
operator: 'any_of',
1836+
value: {type: 'enum_list', value: ['open', 'in_progress']},
1837+
},
1838+
{field: 'priority', operator: 'is', value: {type: 'enum', value: 'p1'}},
1839+
{
1840+
field: 'created',
1841+
operator: 'after',
1842+
value: {type: 'date_absolute', unixSeconds: 1710039600},
1843+
},
1844+
];
1845+
1846+
/**
1847+
* `experimental={{presentation: 'bottom-sheet'}}`: the field is one trigger
1848+
* with display-only tokens; a tap opens the Filters sheet, Add filter lists
1849+
* the fields, and the value step stages field → operator → value. List values
1850+
* (Assignee, Tags) open the Tokenizer's own sheet above the step.
1851+
*/
1852+
export const ExperimentalBottomSheet: Story = {
1853+
render: args => {
1854+
const [filters, setFilters] =
1855+
useState<ReadonlyArray<PowerSearchFilter>>(sheetPresetFilters);
1856+
return (
1857+
<PhoneFrame>
1858+
<PowerSearch
1859+
{...args}
1860+
config={fullConfig}
1861+
filters={filters}
1862+
onChange={next => setFilters(next)}
1863+
timezoneID="America/Los_Angeles"
1864+
experimental={{presentation: 'bottom-sheet'}}
1865+
/>
1866+
<FilterDump filters={filters} />
1867+
</PhoneFrame>
1868+
);
1869+
},
1870+
name: 'Experimental: bottom sheet (forced)',
1871+
parameters: {viewport: {defaultViewport: 'mobile2'}},
1872+
};
1873+
1874+
/**
1875+
* `experimental={{presentation: 'adaptive'}}`: the sheet flow on a compact
1876+
* coarse-pointer screen, the tokenizer field and editor popover otherwise.
1877+
* Resize the viewport or switch the pointer emulation to see it switch.
1878+
*/
1879+
export const ExperimentalAdaptive: Story = {
1880+
render: args => {
1881+
const [filters, setFilters] =
1882+
useState<ReadonlyArray<PowerSearchFilter>>(sheetPresetFilters);
1883+
return (
1884+
<PhoneFrame>
1885+
<PowerSearch
1886+
{...args}
1887+
config={fullConfig}
1888+
filters={filters}
1889+
onChange={next => setFilters(next)}
1890+
timezoneID="America/Los_Angeles"
1891+
experimental={{presentation: 'adaptive'}}
1892+
/>
1893+
<FilterDump filters={filters} />
1894+
</PhoneFrame>
1895+
);
1896+
},
1897+
name: 'Experimental: adaptive',
1898+
};
1899+
1900+
/**
1901+
* With `contentSearchFieldKey`, Add filter carries the content search: the
1902+
* field typeahead's suggestions list inline under the search box, and a value
1903+
* suggestion commits a filter straight away.
1904+
*/
1905+
export const ExperimentalBottomSheetContentSearch: Story = {
1906+
render: args => {
1907+
const [filters, setFilters] = useState<ReadonlyArray<PowerSearchFilter>>(
1908+
[],
1909+
);
1910+
return (
1911+
<PhoneFrame>
1912+
<PowerSearch
1913+
{...args}
1914+
config={contentSearchConfig}
1915+
filters={filters}
1916+
onChange={next => setFilters(next)}
1917+
placeholder="Search issues…"
1918+
experimental={{presentation: 'bottom-sheet'}}
1919+
/>
1920+
<FilterDump filters={filters} />
1921+
</PhoneFrame>
1922+
);
1923+
},
1924+
name: 'Experimental: bottom sheet with content search',
1925+
parameters: {viewport: {defaultViewport: 'mobile2'}},
1926+
};
1927+
1928+
/**
1929+
* Read-only keeps the Filters sheet as plain rows with Done only; disabled
1930+
* keeps the trigger focusable (aria-disabled) and shows its reason; the result
1931+
* count renders at the end of the field in both presentations.
1932+
*/
1933+
export const ExperimentalBottomSheetStates: Story = {
1934+
render: () => {
1935+
const [filters, setFilters] =
1936+
useState<ReadonlyArray<PowerSearchFilter>>(sheetPresetFilters);
1937+
return (
1938+
<PhoneFrame>
1939+
<div style={{display: 'flex', flexDirection: 'column', gap: 24}}>
1940+
<PowerSearch
1941+
config={fullConfig}
1942+
filters={filters}
1943+
onChange={next => setFilters(next)}
1944+
label="Read-only filters"
1945+
isLabelHidden={false}
1946+
isReadOnly
1947+
resultCount={42}
1948+
experimental={{presentation: 'bottom-sheet'}}
1949+
/>
1950+
<PowerSearch
1951+
config={fullConfig}
1952+
filters={filters}
1953+
onChange={next => setFilters(next)}
1954+
label="Disabled filters"
1955+
isLabelHidden={false}
1956+
isDisabled
1957+
disabledMessage="Pick a project first"
1958+
experimental={{presentation: 'bottom-sheet'}}
1959+
/>
1960+
<PowerSearch
1961+
config={fullConfig}
1962+
filters={filters}
1963+
onChange={next => setFilters(next)}
1964+
label="With a status"
1965+
isLabelHidden={false}
1966+
status={{type: 'error', message: 'Add at least one filter'}}
1967+
startIcon={MagnifyingGlassIcon}
1968+
experimental={{presentation: 'bottom-sheet'}}
1969+
/>
1970+
</div>
1971+
</PhoneFrame>
1972+
);
1973+
},
1974+
name: 'Experimental: bottom sheet states',
1975+
parameters: {viewport: {defaultViewport: 'mobile2'}},
1976+
};

‎packages/core/locales/en.json‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,70 @@
255255
"defaultMessage": "{count, number} {count, plural, one {result} other {results}}",
256256
"description": "Live result-count text next to the PowerSearch input, announced to screen readers on change. Example: `12 results`, `1 result`; keep compact."
257257
},
258+
"@astryx.powersearch.sheet.filtersTitle": {
259+
"defaultMessage": "Filters",
260+
"description": "Heading and accessible name of the PowerSearch touch sheet that lists the active filters (experimental bottom-sheet presentation). Plural noun."
261+
},
262+
"@astryx.powersearch.sheet.addFilter": {
263+
"defaultMessage": "Add filter",
264+
"description": "Button label in the PowerSearch touch flow: in the Filters sheet header it opens the field list; in the value step it confirms a new filter. Imperative verb; no leading plus sign."
265+
},
266+
"@astryx.powersearch.sheet.noFilters": {
267+
"defaultMessage": "No filters selected",
268+
"description": "Empty-state text in the PowerSearch Filters sheet when no filter is active. Neutral tone."
269+
},
270+
"@astryx.powersearch.sheet.clearAll": {
271+
"defaultMessage": "Clear all",
272+
"description": "Button label in the PowerSearch Filters sheet footer that removes every active filter and closes the sheet. Imperative verb + determiner."
273+
},
274+
"@astryx.powersearch.sheet.done": {
275+
"defaultMessage": "Done",
276+
"description": "Primary button label in the PowerSearch Filters sheet footer that closes the sheet. Short; marks the end of the filtering task."
277+
},
278+
"@astryx.powersearch.sheet.back": {
279+
"defaultMessage": "Back",
280+
"description": "Icon-only button label in the PowerSearch Add filter sheet that returns to the Filters sheet or closes the flow. Imperative navigation action."
281+
},
282+
"@astryx.powersearch.sheet.search": {
283+
"defaultMessage": "Search",
284+
"description": "Screen-reader-only label of the content-search box at the top of the PowerSearch Add filter sheet; its suggestions list inline below it. Noun or verb as reads best."
285+
},
286+
"@astryx.powersearch.sheet.searchResults": {
287+
"defaultMessage": "Search results",
288+
"description": "Screen-reader-only name of the inline suggestion list under the PowerSearch Add filter sheet's content search. Plural noun."
289+
},
290+
"@astryx.powersearch.sheet.searchFields": {
291+
"defaultMessage": "Search filters",
292+
"description": "Screen-reader-only label of the field-list filter box in the PowerSearch Add filter sheet, shown once the config has eight or more fields. Imperative verb + plural noun."
293+
},
294+
"@astryx.powersearch.sheet.searchFieldsPlaceholder": {
295+
"defaultMessage": "Search filters…",
296+
"description": "Placeholder inside the field-list filter box in the PowerSearch Add filter sheet. Imperative verb; trailing `…` is one character."
297+
},
298+
"@astryx.powersearch.sheet.noMatchingFields": {
299+
"defaultMessage": "No filters match your search",
300+
"description": "Empty-state text in the PowerSearch Add filter sheet when the field-list filter matches no field. Neutral tone."
301+
},
302+
"@astryx.powersearch.sheet.noResults": {
303+
"defaultMessage": "No results found",
304+
"description": "Empty-state text in the PowerSearch Add filter sheet when the content search has no suggestion for the typed query. Neutral tone (not error-y)."
305+
},
306+
"@astryx.powersearch.sheet.editFilter": {
307+
"defaultMessage": "Edit filter",
308+
"description": "Fallback title of the PowerSearch value step while editing, when the field being edited is no longer in the config. Imperative verb."
309+
},
310+
"@astryx.powersearch.sheet.filterUnavailable": {
311+
"defaultMessage": "This filter is no longer available",
312+
"description": "Message in the PowerSearch value step when a config update removed the field or operator being edited; Cancel remains as the way out."
313+
},
314+
"@astryx.powersearch.sheet.remove": {
315+
"defaultMessage": "Remove",
316+
"description": "Button label in the PowerSearch value step footer that deletes the filter being edited. Imperative verb; pairs with Cancel and Apply."
317+
},
318+
"@astryx.powersearch.sheet.selectedChoice": {
319+
"defaultMessage": "{label}, selected",
320+
"description": "Screen-reader-only name of a selected choice row in the PowerSearch value step (enum, multi-value, relative-date rows). `{label}` is the row's visible text; the suffix states the selected state."
321+
},
258322
"@astryx.alertDialog.cancel": {
259323
"defaultMessage": "Cancel",
260324
"description": "Button label on the secondary/dismiss button of an AlertDialog (modal confirmation). Imperative verb; consumers usually override with task-specific text."

‎packages/core/src/DateInput/TouchDateField.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import {
5959
useTransition,
6060
} from 'react';
6161
import * as stylex from '@stylexjs/stylex';
62-
import {BottomSheet} from '../BottomSheet';
62+
import {BottomSheet} from '../BottomSheet/BottomSheet';
6363
import {Button} from '../Button';
6464
import {useCalendarConstraints} from '../Calendar';
6565
import type {DateInputProps} from './DateInput';

‎packages/core/src/PowerSearch/PowerSearch.doc.mjs‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,25 @@ export const docs = {
202202
description:
203203
'StyleX styles for layout customization. Must be a stylex.create() value.',
204204
},
205+
{
206+
name: 'experimental',
207+
type: "{presentation?: 'popover' | 'bottom-sheet' | 'adaptive'}",
208+
stability: 'experimental',
209+
description:
210+
"Experimental options: anything in this object may change or be removed in a patch release, and omitting it keeps the stable behavior. presentation (default 'popover') chooses how the field presents filter editing. popover is the tokenizer field with its typeahead and the editor popover. bottom-sheet makes the whole field one trigger showing display-only filter tokens: it opens a Filters sheet listing the filters as rows with Add filter, Done, and Clear all, an Add filter sheet with the fields (or the content search with inline suggestions), and a value step that stages field → operator → value and confirms from its footer; list values edit through the Tokenizer's own sheet. adaptive uses the bottom sheet on compact touch screens and the popover otherwise, resolved the same way Selector resolves it. In the sheet presentation menuWidth and tokenOverflowBehavior have no surface to act on and warn in development.",
211+
},
212+
],
213+
examples: [
214+
{
215+
label: 'Touch sheet on compact screens (experimental)',
216+
code: `const [filters, setFilters] = useState([]);
217+
<PowerSearch
218+
config={config}
219+
filters={filters}
220+
onChange={next => setFilters(next)}
221+
experimental={{presentation: 'adaptive'}}
222+
/>`,
223+
},
205224
],
206225
// `config` and `filters` are custom values the docsite preview cannot
207226
// generate automatically. Keep this small, but include an initial token so
@@ -439,6 +458,13 @@ export const docsZh = {
439458
type: 'StyleXStyles',
440459
description: '用于布局自定义的 StyleX 样式。必须是 stylex.create() 值。',
441460
},
461+
{
462+
name: 'experimental',
463+
type: "{presentation?: 'popover' | 'bottom-sheet' | 'adaptive'}",
464+
stability: 'experimental',
465+
description:
466+
"实验性选项:此对象中的任何内容都可能在补丁版本中更改或移除;省略它即保持稳定行为。presentation(默认 'popover')决定字段如何呈现筛选编辑:popover 为带有预输入和编辑弹出层的标记字段;bottom-sheet 将整个字段变为一个显示只读筛选标记的触发按钮——点按后打开列出筛选项的「筛选」面板(含添加筛选、完成、全部清除)、列出字段(或带内联建议的内容搜索)的「添加筛选」面板,以及按字段 → 运算符 → 值暂存并在底部确认的取值步骤;列表值通过 Tokenizer 自身的面板编辑。adaptive 在紧凑触摸屏上使用底部面板,其他情况使用 popover,解析方式与 Selector 相同。在底部面板呈现中,menuWidth 和 tokenOverflowBehavior 没有作用对象,并会在开发环境中发出警告。",
467+
},
442468
],
443469
usage: {
444470
description:
@@ -532,5 +558,7 @@ export const docsDense = {
532558
size: 'Search input+token size.',
533559
xstyle:
534560
'StyleX styles for layout customization. Must be stylex.create() value.',
561+
experimental:
562+
"Experimental; may change in a patch. presentation: 'popover' (default, tokenizer field + editor popover) | 'bottom-sheet' (one trigger with display-only tokens + Filters / Add filter / value sheets; list values via Tokenizer's sheet) | 'adaptive' (sheet on compact touch, else popover).",
535563
},
536564
};

0 commit comments

Comments
 (0)