Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/powersearch-experimental-bottom-sheet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astryxdesign/core': patch
---

[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.

@imdreamrunner
185 changes: 184 additions & 1 deletion apps/storybook/stories/PowerSearch.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,10 @@ const meta: Meta<typeof PowerSearch> = {
component: PowerSearch,
tags: ['autodocs'],
decorators: [
// A 600px column where there is room that shrinks with the viewport, so
// the stories, the touch presentations above all, fit a phone-sized canvas.
Story => (
<div style={{width: 600}}>
<div style={{display: 'grid', gridTemplateColumns: 'minmax(0, 600px)'}}>
<Story />
</div>
),
Expand Down Expand Up @@ -2054,3 +2056,184 @@ export const StatusVariantComparison: Story = {
);
},
};

// =============================================================================
// Experimental bottom-sheet presentation
// =============================================================================

// The sheet flow is designed for a phone: view these stories at a compact
// touch viewport (Storybook's mobile2 preset) to see the sheets as a person
// would.
function PhoneFrame({children}: {children: React.ReactNode}) {
return <div style={{width: 390, maxWidth: '100%'}}>{children}</div>;
}

function FilterDump({filters}: {filters: ReadonlyArray<PowerSearchFilter>}) {
if (filters.length === 0) {
return null;
}
return (
<pre
style={{
marginTop: 16,
padding: 12,
borderRadius: 8,
fontSize: 12,
overflow: 'auto',
maxWidth: 390,
}}>
{JSON.stringify(filters, null, 2)}
</pre>
);
}

const sheetPresetFilters: ReadonlyArray<PowerSearchFilter> = [
{
field: 'status',
operator: 'any_of',
value: {type: 'enum_list', value: ['open', 'in_progress']},
},
{field: 'priority', operator: 'is', value: {type: 'enum', value: 'p1'}},
{
field: 'created',
operator: 'after',
value: {type: 'date_absolute', unixSeconds: 1710039600},
},
];

/**
* `experimental={{presentation: 'bottom-sheet'}}`: the field is one trigger
* with display-only tokens; a tap opens the Filters sheet, whose rows edit or
* remove a filter, Add filter opens above it with the fields, and the value
* step opens above that and stages operator → value. Dismissing a step
* reveals the one beneath. Clear all asks first. List values (Assignee, Tags)
* open the Tokenizer's own sheet above the step.
*/
export const ExperimentalBottomSheet: Story = {
render: args => {
const [filters, setFilters] =
useState<ReadonlyArray<PowerSearchFilter>>(sheetPresetFilters);
return (
<PhoneFrame>
<PowerSearch
{...args}
config={fullConfig}
filters={filters}
onChange={next => setFilters(next)}
// A count that follows the filters, so a commit from the flow (and
// Clear all) changes it and the flow announces the change.
resultCount={Math.max(1, Math.round(240 / (filters.length + 1)))}
timezoneID="America/Los_Angeles"
experimental={{presentation: 'bottom-sheet'}}
/>
<FilterDump filters={filters} />
</PhoneFrame>
);
},
name: 'Experimental: bottom sheet (forced)',
parameters: {viewport: {defaultViewport: 'mobile2'}},
};

/**
* `experimental={{presentation: 'adaptive'}}`: the sheet flow on a compact
* coarse-pointer screen, the tokenizer field and editor popover otherwise.
* Resize the viewport or switch the pointer emulation to see it switch.
*/
export const ExperimentalAdaptive: Story = {
render: args => {
const [filters, setFilters] =
useState<ReadonlyArray<PowerSearchFilter>>(sheetPresetFilters);
return (
<PhoneFrame>
<PowerSearch
{...args}
config={fullConfig}
filters={filters}
onChange={next => setFilters(next)}
timezoneID="America/Los_Angeles"
experimental={{presentation: 'adaptive'}}
/>
<FilterDump filters={filters} />
</PhoneFrame>
);
},
name: 'Experimental: adaptive',
};

/**
* With `contentSearchFieldKey`, Add filter carries the content search: the
* field typeahead's suggestions list inline under the search box, and a value
* suggestion commits a filter straight away.
*/
export const ExperimentalBottomSheetContentSearch: Story = {
render: args => {
const [filters, setFilters] = useState<ReadonlyArray<PowerSearchFilter>>(
[],
);
return (
<PhoneFrame>
<PowerSearch
{...args}
config={contentSearchConfig}
filters={filters}
onChange={next => setFilters(next)}
placeholder="Search issues…"
experimental={{presentation: 'bottom-sheet'}}
/>
<FilterDump filters={filters} />
</PhoneFrame>
);
},
name: 'Experimental: bottom sheet with content search',
parameters: {viewport: {defaultViewport: 'mobile2'}},
};

/**
* Read-only keeps the Filters sheet as plain rows with Done only; disabled
* keeps the trigger focusable (aria-disabled) and shows its reason; the result
* count renders at the end of the field in both presentations.
*/
export const ExperimentalBottomSheetStates: Story = {
render: () => {
const [filters, setFilters] =
useState<ReadonlyArray<PowerSearchFilter>>(sheetPresetFilters);
return (
<PhoneFrame>
<div style={{display: 'flex', flexDirection: 'column', gap: 24}}>
<PowerSearch
config={fullConfig}
filters={filters}
onChange={next => setFilters(next)}
label="Read-only filters"
isLabelHidden={false}
isReadOnly
resultCount={42}
experimental={{presentation: 'bottom-sheet'}}
/>
<PowerSearch
config={fullConfig}
filters={filters}
onChange={next => setFilters(next)}
label="Disabled filters"
isLabelHidden={false}
isDisabled
disabledMessage="Pick a project first"
experimental={{presentation: 'bottom-sheet'}}
/>
<PowerSearch
config={fullConfig}
filters={filters}
onChange={next => setFilters(next)}
label="With a status"
isLabelHidden={false}
status={{type: 'error', message: 'Add at least one filter'}}
startIcon={MagnifyingGlassIcon}
experimental={{presentation: 'bottom-sheet'}}
/>
</div>
</PhoneFrame>
);
},
name: 'Experimental: bottom sheet states',
parameters: {viewport: {defaultViewport: 'mobile2'}},
};
Loading
Loading