Skip to content

Commit 777edfe

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 stack of tall modal sheets, the touch flow the Lab prototype ships: - Each step opens above the one that led to it, which stays open beneath; a dismissal closes only the top sheet and reveals the step beneath, so no sheet has a Back action. - Filters lists the filters as rows that edit a filter, each with a trailing remove button (a one-tap filter's row removes it), under a fixed header with Add filter and over a fixed footer with Clear all and Done. With no filter it is one empty state with a centered Add filter. - Clear all asks for confirmation, removes the editable filters, keeps read-only ones, leaves Filters open and announces there. - Add filter lists the grouped fields, or the content search with inline suggestions, and leaves its search unfocused; a vertical touch drag on the rows moves focus off a focused search. A field whose only operator takes no value adds at once. - The value step stages operator → value and confirms from its footer. A lone editor sits on the sheet surface; beside the Operator group each section is a muted container. The flow loads on demand; `adaptive` resolves through the shared compact-touch policy and stays latched until the flow's exit has returned focus. Value editors are Core's own in a sheet presentation; list values edit through the Tokenizer's sheet titled with the field label; nested values use the built-in nested editor. Announcements made while a sheet is open go through the open dialog's own live region. The confirmation and the search-drag handling are the internal modules the Tokenizer sheet shares. Implements `component:PowerSearch` DEC-3 (FR10–FR21, FR15a, AR4–AR6, PR5) and lifts the record's implementation-gap notes, except the sheet's date handling in `timezoneID` (FR11, FR12, FR17).
1 parent 3615956 commit 777edfe

24 files changed

Lines changed: 9493 additions & 274 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 that stack: each step opens above the one that led to it, and dismissing a step reveals the one beneath, so no sheet has a Back action. A Filters sheet lists the active filters as rows that edit a filter, each with a trailing remove button, under a fixed header with Add filter and over a fixed footer with Clear all and Done; with no filter it shows one centered Add filter. Clear all asks for confirmation, removes the editable filters, keeps read-only ones, and leaves Filters open. An Add filter sheet lists the fields grouped (searchable from eight fields), or the content search with the field typeahead's suggestions listed inline, and leaves its search unfocused until tapped; a field whose only operator takes no value adds at once. A value step stages operator → value and confirms from its footer, the editor on the sheet's surface, or in muted sections beside the operator choice. 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. 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: 184 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
),
@@ -2054,3 +2056,184 @@ export const StatusVariantComparison: Story = {
20542056
);
20552057
},
20562058
};
2059+
2060+
// =============================================================================
2061+
// Experimental bottom-sheet presentation
2062+
// =============================================================================
2063+
2064+
// The sheet flow is designed for a phone: view these stories at a compact
2065+
// touch viewport (Storybook's mobile2 preset) to see the sheets as a person
2066+
// would.
2067+
function PhoneFrame({children}: {children: React.ReactNode}) {
2068+
return <div style={{width: 390, maxWidth: '100%'}}>{children}</div>;
2069+
}
2070+
2071+
function FilterDump({filters}: {filters: ReadonlyArray<PowerSearchFilter>}) {
2072+
if (filters.length === 0) {
2073+
return null;
2074+
}
2075+
return (
2076+
<pre
2077+
style={{
2078+
marginTop: 16,
2079+
padding: 12,
2080+
borderRadius: 8,
2081+
fontSize: 12,
2082+
overflow: 'auto',
2083+
maxWidth: 390,
2084+
}}>
2085+
{JSON.stringify(filters, null, 2)}
2086+
</pre>
2087+
);
2088+
}
2089+
2090+
const sheetPresetFilters: ReadonlyArray<PowerSearchFilter> = [
2091+
{
2092+
field: 'status',
2093+
operator: 'any_of',
2094+
value: {type: 'enum_list', value: ['open', 'in_progress']},
2095+
},
2096+
{field: 'priority', operator: 'is', value: {type: 'enum', value: 'p1'}},
2097+
{
2098+
field: 'created',
2099+
operator: 'after',
2100+
value: {type: 'date_absolute', unixSeconds: 1710039600},
2101+
},
2102+
];
2103+
2104+
/**
2105+
* `experimental={{presentation: 'bottom-sheet'}}`: the field is one trigger
2106+
* with display-only tokens; a tap opens the Filters sheet, whose rows edit or
2107+
* remove a filter, Add filter opens above it with the fields, and the value
2108+
* step opens above that and stages operator → value. Dismissing a step
2109+
* reveals the one beneath. Clear all asks first. List values (Assignee, Tags)
2110+
* open the Tokenizer's own sheet above the step.
2111+
*/
2112+
export const ExperimentalBottomSheet: Story = {
2113+
render: args => {
2114+
const [filters, setFilters] =
2115+
useState<ReadonlyArray<PowerSearchFilter>>(sheetPresetFilters);
2116+
return (
2117+
<PhoneFrame>
2118+
<PowerSearch
2119+
{...args}
2120+
config={fullConfig}
2121+
filters={filters}
2122+
onChange={next => setFilters(next)}
2123+
// A count that follows the filters, so a commit from the flow (and
2124+
// Clear all) changes it and the flow announces the change.
2125+
resultCount={Math.max(1, Math.round(240 / (filters.length + 1)))}
2126+
timezoneID="America/Los_Angeles"
2127+
experimental={{presentation: 'bottom-sheet'}}
2128+
/>
2129+
<FilterDump filters={filters} />
2130+
</PhoneFrame>
2131+
);
2132+
},
2133+
name: 'Experimental: bottom sheet (forced)',
2134+
parameters: {viewport: {defaultViewport: 'mobile2'}},
2135+
};
2136+
2137+
/**
2138+
* `experimental={{presentation: 'adaptive'}}`: the sheet flow on a compact
2139+
* coarse-pointer screen, the tokenizer field and editor popover otherwise.
2140+
* Resize the viewport or switch the pointer emulation to see it switch.
2141+
*/
2142+
export const ExperimentalAdaptive: Story = {
2143+
render: args => {
2144+
const [filters, setFilters] =
2145+
useState<ReadonlyArray<PowerSearchFilter>>(sheetPresetFilters);
2146+
return (
2147+
<PhoneFrame>
2148+
<PowerSearch
2149+
{...args}
2150+
config={fullConfig}
2151+
filters={filters}
2152+
onChange={next => setFilters(next)}
2153+
timezoneID="America/Los_Angeles"
2154+
experimental={{presentation: 'adaptive'}}
2155+
/>
2156+
<FilterDump filters={filters} />
2157+
</PhoneFrame>
2158+
);
2159+
},
2160+
name: 'Experimental: adaptive',
2161+
};
2162+
2163+
/**
2164+
* With `contentSearchFieldKey`, Add filter carries the content search: the
2165+
* field typeahead's suggestions list inline under the search box, and a value
2166+
* suggestion commits a filter straight away.
2167+
*/
2168+
export const ExperimentalBottomSheetContentSearch: Story = {
2169+
render: args => {
2170+
const [filters, setFilters] = useState<ReadonlyArray<PowerSearchFilter>>(
2171+
[],
2172+
);
2173+
return (
2174+
<PhoneFrame>
2175+
<PowerSearch
2176+
{...args}
2177+
config={contentSearchConfig}
2178+
filters={filters}
2179+
onChange={next => setFilters(next)}
2180+
placeholder="Search issues…"
2181+
experimental={{presentation: 'bottom-sheet'}}
2182+
/>
2183+
<FilterDump filters={filters} />
2184+
</PhoneFrame>
2185+
);
2186+
},
2187+
name: 'Experimental: bottom sheet with content search',
2188+
parameters: {viewport: {defaultViewport: 'mobile2'}},
2189+
};
2190+
2191+
/**
2192+
* Read-only keeps the Filters sheet as plain rows with Done only; disabled
2193+
* keeps the trigger focusable (aria-disabled) and shows its reason; the result
2194+
* count renders at the end of the field in both presentations.
2195+
*/
2196+
export const ExperimentalBottomSheetStates: Story = {
2197+
render: () => {
2198+
const [filters, setFilters] =
2199+
useState<ReadonlyArray<PowerSearchFilter>>(sheetPresetFilters);
2200+
return (
2201+
<PhoneFrame>
2202+
<div style={{display: 'flex', flexDirection: 'column', gap: 24}}>
2203+
<PowerSearch
2204+
config={fullConfig}
2205+
filters={filters}
2206+
onChange={next => setFilters(next)}
2207+
label="Read-only filters"
2208+
isLabelHidden={false}
2209+
isReadOnly
2210+
resultCount={42}
2211+
experimental={{presentation: 'bottom-sheet'}}
2212+
/>
2213+
<PowerSearch
2214+
config={fullConfig}
2215+
filters={filters}
2216+
onChange={next => setFilters(next)}
2217+
label="Disabled filters"
2218+
isLabelHidden={false}
2219+
isDisabled
2220+
disabledMessage="Pick a project first"
2221+
experimental={{presentation: 'bottom-sheet'}}
2222+
/>
2223+
<PowerSearch
2224+
config={fullConfig}
2225+
filters={filters}
2226+
onChange={next => setFilters(next)}
2227+
label="With a status"
2228+
isLabelHidden={false}
2229+
status={{type: 'error', message: 'Add at least one filter'}}
2230+
startIcon={MagnifyingGlassIcon}
2231+
experimental={{presentation: 'bottom-sheet'}}
2232+
/>
2233+
</div>
2234+
</PhoneFrame>
2235+
);
2236+
},
2237+
name: 'Experimental: bottom sheet states',
2238+
parameters: {viewport: {defaultViewport: 'mobile2'}},
2239+
};

0 commit comments

Comments
 (0)