An open source design system that's fully customizable and agent ready
TypeScript
feat(lab): MobilePowerSearch's steps are standalone sheets that replace one another (#8476)
Xinzi Zhoub02fac607010
diff --git a/packages/lab/src/MobilePowerSearch/MobilePowerSearch.doc.mjs b/packages/lab/src/MobilePowerSearch/MobilePowerSearch.doc.mjsindex 3cc29a5eb3..edd4fca1f6 100644--- a/packages/lab/src/MobilePowerSearch/MobilePowerSearch.doc.mjs+++ b/packages/lab/src/MobilePowerSearch/MobilePowerSearch.doc.mjs@@ -107,7 +107,7 @@ export const docs = {],usage: {description:- 'Lab prototype for trying the touch PowerSearch flow. Choose it explicitly on touch layouts (for example `const Search = isTouch ? MobilePowerSearch : PowerSearch`); it never switches on pointer type by itself. The whole field is one Manage filters trigger showing display-only tokens. Tapping it opens a tall Filters sheet listing each filter as a chevron row with its value in bold, Add filter at the top right, and sticky Clear all and Done actions. Opening a row edits that filter in a sheet with Cancel, Apply, and Remove. Add filter opens directly when no filter exists; when the config names a content-search field it carries that search with inline suggestions. Creating a filter drills field → operator (radios, only when a field has more than one) → value. Single and multi-value choices are full-width rows with trailing checks; other value types use the matching Astryx input. Fields whose only operators are nested are left out with a development warning.',+ 'Lab prototype for trying the touch PowerSearch flow. Choose it explicitly on touch layouts (for example `const Search = isTouch ? MobilePowerSearch : PowerSearch`); it never switches on pointer type by itself. The whole field is one Manage filters trigger showing display-only tokens. Tapping it opens a tall Filters sheet listing each filter as a chevron row with its value in bold, Add filter at the top right, and sticky Clear all and Done actions. Opening a row edits that filter in a sheet with Cancel, Apply, and Remove. Add filter opens directly when no filter exists; when the config names a content-search field it carries that search with inline suggestions. Creating a filter drills field → operator (radios, only when a field has more than one) → value. Each step is its own BottomSheet; moving between steps is a BottomSheet replace handoff (the entering step rises above the leaving one under the one scrim), so the steps need no BottomSheetSwitcher. Single and multi-value choices are full-width rows with trailing checks; other value types use the matching Astryx input. Fields whose only operators are nested are left out with a development warning.',bestPractices: [{guidance: true,diff --git a/packages/lab/src/MobilePowerSearch/MobilePowerSearch.test.tsx b/packages/lab/src/MobilePowerSearch/MobilePowerSearch.test.tsxindex 9d29b3dfe6..2aba0934bb 100644--- a/packages/lab/src/MobilePowerSearch/MobilePowerSearch.test.tsx+++ b/packages/lab/src/MobilePowerSearch/MobilePowerSearch.test.tsx@@ -353,8 +353,9 @@ function isSheetOpen(): boolean {}/**- * The switcher gives every step its own dialog. Outgoing dialogs stay open but- * inert until their exit transition completes, so return only the active one.+ * Every step is its own sheet with its own dialog. During a replace handoff+ * the outgoing dialog stays open but inert until its fade completes, so+ * return only the active one.*/function sheet(): HTMLElement {const dialog = document.querySelector<HTMLElement>(@@ -400,8 +401,8 @@ function settleSheets(): void {function tapRow(name: RegExp | string): void {const matches = within(sheet()).getAllByRole('button', {name});- // The switcher keeps the outgoing sheet mounted while the incoming one- // enters; the last match is always on the sheet that just arrived.+ // The replace handoff keeps the outgoing sheet presented while the incoming+ // one enters; the last match is always on the sheet that just arrived.fireEvent.click(matches[matches.length - 1]);}@@ -1448,6 +1449,168 @@ describe('MobilePowerSearch value sheet', () => {// Content search// =============================================================================+describe('MobilePowerSearch step sheets (stacked, replacing)', () => {+ // Three sibling BottomSheets, one per step, controlled by one `step` value:+ // a same-update close and open is the stack's replace handoff. These read+ // only what a person or assistive technology can observe: which dialogs+ // are open, which is modal, and which is inert and hidden.+ function stepDialogs(): HTMLElement[] {+ return Array.from(document.querySelectorAll<HTMLElement>('dialog[open]'));+ }++ it('Filters opens as one modal dialog, named by the step', () => {+ setup({filters: [openFilter]});+ openSheet();+ // One dialog per presented step, each with its own accessible name.+ expect(stepDialogs().map(d => d.getAttribute('aria-label'))).toEqual([+ 'Filters',+ ]);+ expect(sheet()).toHaveAttribute('aria-modal', 'true');+ });++ it('Filters → Add filter is a replace handoff: the entering step is on top, the leaving step stays presented, inert and hidden, then leaves', () => {+ setup({filters: [openFilter]});+ openSheet();+ const filters = sheet();+ tapRow('Add filter');+ const open = stepDialogs();+ expect(open.map(d => d.getAttribute('aria-label'))).toEqual([+ 'Filters',+ 'Add filter',+ ]);+ // The one being replaced: still presented, out of the tab order and the+ // accessibility tree; the entering step is the interactive one.+ expect(filters).toHaveAttribute('inert');+ expect(filters).toHaveAttribute('aria-hidden', 'true');+ expect(sheet()).toHaveAttribute('aria-label', 'Add filter');+ expect(sheet()).not.toHaveAttribute('inert');+ expect(sheet()).not.toHaveAttribute('aria-hidden');+ // The entering step's motion completes first, then the retained step's+ // fade (the stack sequences them): only the new step remains.+ settleSheets();+ settleSheets();+ expect(stepDialogs().map(d => d.getAttribute('aria-label'))).toEqual([+ 'Add filter',+ ]);+ expect(isSheetOpen()).toBe(true);+ });++ it('a step on its own is one open modal dialog, interactive and exposed', () => {+ setup({filters: [openFilter]});+ openSheet();+ settleSheets();+ expect(stepDialogs()).toHaveLength(1);+ expect(sheet()).toHaveAttribute('aria-modal', 'true');+ expect(sheet()).not.toHaveAttribute('inert');+ expect(sheet()).not.toHaveAttribute('aria-hidden');+ });++ it('focus returns to the trigger after a flow that crossed every step (the return target survives each handoff)', () => {+ setup({filters: [openFilter]});+ trigger().focus();+ openSheet();+ tapRow('Add filter');+ settleSheets();+ tapRow(/^Status/);+ settleSheets();+ expect(sheet()).toHaveAttribute(+ 'aria-label',+ expect.stringContaining('Status'),+ );+ // Back from the value step, Back from Add filter, Done from Filters.+ fireEvent.click(within(sheet()).getByRole('button', {name: 'Cancel'}));+ settleSheets();+ expect(sheet()).toHaveAttribute('aria-label', 'Add filter');+ fireEvent.click(within(sheet()).getByRole('button', {name: 'Back'}));+ settleSheets();+ expect(sheet()).toHaveAttribute('aria-label', 'Filters');+ fireEvent.click(within(sheet()).getByRole('button', {name: 'Done'}));+ expect(isSheetOpen()).toBe(false);+ settleSheets();+ expect(trigger()).toHaveFocus();+ });++ it('Escape on the Filters step closes the flow and returns focus to the trigger', () => {+ setup({filters: [openFilter]});+ trigger().focus();+ openSheet();+ settleSheets();+ fireEvent.keyDown(sheet(), {key: 'Escape'});+ expect(isSheetOpen()).toBe(false);+ settleSheets();+ expect(trigger()).toHaveFocus();+ });++ it('a scrim press on the Filters step (purpose info) closes the flow; on the value step (purpose form) it does not', () => {+ setup({filters: [openFilter]});+ openSheet();+ settleSheets();+ // A click on the dialog element itself is the scrim.+ fireEvent.click(sheet());+ expect(isSheetOpen()).toBe(false);+ settleSheets();++ openEditFlow(/^Status/);+ settleSheets();+ expect(sheet()).toHaveAttribute(+ 'aria-label',+ expect.stringContaining('Status'),+ );+ fireEvent.click(sheet());+ expect(isSheetOpen()).toBe(true);+ expect(sheet()).toHaveAttribute(+ 'aria-label',+ expect.stringContaining('Status'),+ );+ });++ it('a downward swipe on the Filters step dismisses the flow', () => {+ setup({filters: [openFilter]});+ openSheet();+ settleSheets();+ const handle = sheet().querySelector<HTMLElement>(+ '.astryx-bottom-sheet > div[aria-hidden="true"]',+ )!;+ fireEvent.pointerDown(handle, {+ pointerId: 1,+ clientY: 0,+ button: 0,+ isPrimary: true,+ pointerType: 'touch',+ });+ fireEvent.pointerMove(handle, {+ pointerId: 1,+ clientY: 40,+ pointerType: 'touch',+ });+ fireEvent.pointerMove(handle, {+ pointerId: 1,+ clientY: 120,+ pointerType: 'touch',+ });+ fireEvent.pointerUp(handle, {+ pointerId: 1,+ clientY: 120,+ pointerType: 'touch',+ });+ expect(isSheetOpen()).toBe(false);+ });++ it('a stale dismissal from the leaving sheet cannot end the flow: a scrim press on the replaced Filters sheet is ignored once the step has moved on', () => {+ setup({filters: [openFilter]});+ openSheet();+ const filters = sheet();+ tapRow('Add filter');+ // The leaving Filters dialog is still presented (fading, inert); a click+ // on its own element is the scrim path, which BottomSheet does not gate+ // on its open state — the flow's per-step guard must ignore it because+ // the flow is on Add filter now.+ fireEvent.click(filters);+ expect(isSheetOpen()).toBe(true);+ expect(sheet()).toHaveAttribute('aria-label', 'Add filter');+ });+});+describe('MobilePowerSearch content search', () => {it('opens empty content-search configurations directly to Add filter with focus in the search', () => {setup({config: contentSearchConfig, placeholder: 'Search content…'});diff --git a/packages/lab/src/MobilePowerSearch/MobilePowerSearch.tsx b/packages/lab/src/MobilePowerSearch/MobilePowerSearch.tsxindex 50aefcd2a4..330726ed1a 100644--- a/packages/lab/src/MobilePowerSearch/MobilePowerSearch.tsx+++ b/packages/lab/src/MobilePowerSearch/MobilePowerSearch.tsx@@ -6,14 +6,16 @@* @file MobilePowerSearch.tsx* @input Core PowerSearch config, filters and onChange (the same props as* @astryxdesign/core PowerSearch); public @astryxdesign/core components only- * (BottomSheet, BottomSheetSwitcher, Button, Field, Heading, Icon, List,+ * (BottomSheet, Button, Field, Heading, Icon, List,* RadioList, Text, TextInput, Token, Tooltip hooks, i18n, hooks, utils,* Layout container-padding styles)* @output Exports MobilePowerSearch — Lab prototype of the touch PowerSearch* flow: the whole field is one "Manage filters" trigger with display-only* tokens, a Filters sheet with chevron rows, Add filter and sticky* Clear all / Done, and a field → operator → value drill-down whose edit- * sheet holds Cancel / Apply / Remove+ * sheet holds Cancel / Apply / Remove; the steps are sibling BottomSheets+ * that replace one another on a same-update switch (one scrim, the+ * entering step above the leaving one)* @position Lab (canary) stack layer 1: validates the touch design before any* Core promotion. The caller chooses it explicitly* (`isTouch ? MobilePowerSearch : PowerSearch`); there is no pointer@@ -68,7 +70,7 @@ import React, {} from 'react';import * as stylex from '@stylexjs/stylex';import type {BaseProps} from '@astryxdesign/core';-import {BottomSheet, BottomSheetSwitcher} from '@astryxdesign/core/BottomSheet';+import {BottomSheet} from '@astryxdesign/core/BottomSheet';import {Button} from '@astryxdesign/core/Button';import {Field,@@ -652,9 +654,9 @@ export function MobilePowerSearch({const [step, setStep] = useState<SheetStep | null>(null);stepRef.current = step;- // The draft outlives a step change on purpose: the switcher keeps the- // outgoing sheet mounted while the incoming one enters, and clearing the- // draft with the step would blank that sheet mid-transition.+ // The draft outlives a step change on purpose: the replace handoff keeps+ // the outgoing sheet presented while the incoming one enters, and clearing+ // the draft with the step would blank that sheet mid-transition.const [draft, setDraft] = useState<FilterDraft | null>(null);const [fieldQuery, setFieldQuery] = useState('');const [contentQuery, setContentQuery] = useState('');@@ -801,8 +803,9 @@ export function MobilePowerSearch({if (isDisabled) {return;}- // The switcher restores focus to the element that was active when its- // dialog opened; make sure that is the trigger even for a tap on a token.+ // A sheet returns focus to the element that was active when its dialog+ // opened, and a replace handoff carries that target from step to step;+ // make sure it is the trigger even for a tap on a token.triggerRef.current?.focus({preventScroll: true});if (filters.length === 0 && isInteractive) {fieldPickerOriginRef.current = 'trigger';@@ -1106,13 +1109,30 @@ export function MobilePowerSearch({setStep('manage');}, [draft, filters, handleRemoveFilter, queueManagerAddFocus]);- const handleActiveSheetChange = useCallback((active: string | null) => {- // The switcher only reports null, for a dismissal the active sheet- // allows. Every step change goes through the handlers above.- if (active == null) {- setStep(null);- }- }, []);+ // Each step sheet is controlled by `step`; a sheet only ever asks to close+ // (a dismissal its `purpose` allows: Escape, the scrim, a swipe), and only+ // the current step's request ends the flow. Every step change goes through+ // the handlers above.+ const handleStepOpenChange = useCallback(+ (sheetStep: SheetStep, isOpen: boolean) => {+ if (!isOpen && stepRef.current === sheetStep) {+ setStep(null);+ }+ },+ [],+ );+ const handleManageOpenChange = useCallback(+ (isOpen: boolean) => handleStepOpenChange('manage', isOpen),+ [handleStepOpenChange],+ );+ const handleFieldsOpenChange = useCallback(+ (isOpen: boolean) => handleStepOpenChange('fields', isOpen),+ [handleStepOpenChange],+ );+ const handleValueOpenChange = useCallback(+ (isOpen: boolean) => handleStepOpenChange('value', isOpen),+ [handleStepOpenChange],+ );const handleFocusWithin = useCallback((event: React.FocusEvent<HTMLDivElement>) => {@@ -1410,413 +1430,411 @@ export function MobilePowerSearch({disabledMessageTooltip.renderTooltip(disabledMessage)}</Field>- <BottomSheetSwitcher- activeSheet={step}- onActiveSheetChange={handleActiveSheetChange}>- <BottomSheet sheetId="manage" label="Filters" height="tall" padding={0}>- <div {...stylex.props(styles.sheet)}>- {sheetStatus}- <div {...stylex.props(styles.header)}>- <div {...stylex.props(styles.headerRow)}>- <div {...stylex.props(styles.headerText)}>- <Heading level={3}>Filters</Heading>- </div>- {isInteractive && (- <Button- ref={managerAddButtonRef}- label="Add filter"- variant="ghost"- xstyle={styles.touchAction}- onClick={openFieldList}- />- )}+ <BottomSheet+ isOpen={step === 'manage'}+ onOpenChange={handleManageOpenChange}+ label="Filters"+ height="tall"+ padding={0}>+ <div {...stylex.props(styles.sheet)}>+ {sheetStatus}+ <div {...stylex.props(styles.header)}>+ <div {...stylex.props(styles.headerRow)}>+ <div {...stylex.props(styles.headerText)}>+ <Heading level={3}>Filters</Heading></div>- </div>- <div {...bodyProps}>- {filterRows.length === 0 ? (- <div {...stylex.props(styles.empty)}>- <Text type="supporting" color="secondary">- No filters selected- </Text>- </div>- ) : (- <List hasDividers density="spacious" edge="bleed">- {filterRows.map(row => {- const canEdit = isInteractive && !row.filter.isReadOnly;- return (- <ListItem- key={row.key}- ref={node => {- if (node == null) {- managerRowsRef.current.delete(row.index);- } else {- managerRowsRef.current.set(row.index, node);- }- }}- label={row.displayLabel}- onClick={- canEdit- ? () => handleFilterEdit(row.index)- : undefined- }- endContent={- canEdit ? (- <Icon- icon="chevronRight"- size="sm"- color="secondary"- xstyle={rtlStyles.mirror}- />- ) : undefined- }- />- );- })}- </List>- )}- </div>- <div {...stylex.props(styles.footer)}>- {isClearAllShown && (+ {isInteractive && (<Button- label="Clear all"+ ref={managerAddButtonRef}+ label="Add filter"variant="ghost"xstyle={styles.touchAction}- onClick={handleClearAll}+ onClick={openFieldList}/>)}- <div- {...stylex.props(- styles.footerActions,- !isClearAllShown && styles.footerSoleAction,- )}>- <Button- label="Done"- variant="primary"- xstyle={styles.touchAction}- onClick={closeSheet}- width={isClearAllShown ? undefined : '100%'}- />- </div></div></div>- </BottomSheet>-- <BottomSheet- sheetId="fields"- label="Add filter"- height="tall"- padding={0}>- <div {...stylex.props(styles.sheet)}>- {sheetStatus}- <div {...stylex.props(styles.header)}>- <div {...stylex.props(styles.headerRow)}>- <Button- label="Back"- icon={- <Icon- icon="chevronLeft"- size="sm"- xstyle={rtlStyles.mirror}- />- }- isIconOnly- variant="ghost"- size="sm"- xstyle={styles.touchIconAction}- onClick={() => {- if (fieldPickerOriginRef.current === 'trigger') {- closeSheet();- return;- }- queueManagerAddFocus();- setStep('manage');- }}- />- <div {...stylex.props(styles.headerText)}>- <Heading level={3}>Add filter</Heading>- </div>+ <div {...bodyProps}>+ {filterRows.length === 0 ? (+ <div {...stylex.props(styles.empty)}>+ <Text type="supporting" color="secondary">+ No filters selected+ </Text></div>- {hasContentSearch ? (- <div ref={contentSearchRef}>- <TextInput- label="Search"- isLabelHidden- role="searchbox"- aria-controls={contentResultsId}- value={contentQuery}- onChange={setContentQuery}- onKeyDown={event => {- if (isImeKeyEvent(event.nativeEvent)) {- return;- }- if (event.key === 'Enter' && contentResults[0] != null) {- event.preventDefault();- handleContentSuggestionSelect(contentResults[0]);- return;+ ) : (+ <List hasDividers density="spacious" edge="bleed">+ {filterRows.map(row => {+ const canEdit = isInteractive && !row.filter.isReadOnly;+ return (+ <ListItem+ key={row.key}+ ref={node => {+ if (node == null) {+ managerRowsRef.current.delete(row.index);+ } else {+ managerRowsRef.current.set(row.index, node);+ }+ }}+ label={row.displayLabel}+ onClick={+ canEdit ? () => handleFilterEdit(row.index) : undefined}- if (event.key === 'ArrowDown') {- event.preventDefault();- contentSuggestionListRef.current- ?.querySelector<HTMLButtonElement>('button')- ?.focus();+ endContent={+ canEdit ? (+ <Icon+ icon="chevronRight"+ size="sm"+ color="secondary"+ xstyle={rtlStyles.mirror}+ />+ ) : undefined}- }}- placeholder={contentSearchPlaceholder}- hasClear- startIcon={- <Icon icon="search" size="sm" color="secondary" />- }- isDisabled={!isInteractive}- width="100%"+ />+ );+ })}+ </List>+ )}+ </div>+ <div {...stylex.props(styles.footer)}>+ {isClearAllShown && (+ <Button+ label="Clear all"+ variant="ghost"+ xstyle={styles.touchAction}+ onClick={handleClearAll}+ />+ )}+ <div+ {...stylex.props(+ styles.footerActions,+ !isClearAllShown && styles.footerSoleAction,+ )}>+ <Button+ label="Done"+ variant="primary"+ xstyle={styles.touchAction}+ onClick={closeSheet}+ width={isClearAllShown ? undefined : '100%'}+ />+ </div>+ </div>+ </div>+ </BottomSheet>++ <BottomSheet+ isOpen={step === 'fields'}+ onOpenChange={handleFieldsOpenChange}+ label="Add filter"+ height="tall"+ padding={0}>+ <div {...stylex.props(styles.sheet)}>+ {sheetStatus}+ <div {...stylex.props(styles.header)}>+ <div {...stylex.props(styles.headerRow)}>+ <Button+ label="Back"+ icon={+ <Icon+ icon="chevronLeft"+ size="sm"+ xstyle={rtlStyles.mirror}/>- </div>- ) : isFieldSearchShown ? (+ }+ isIconOnly+ variant="ghost"+ size="sm"+ xstyle={styles.touchIconAction}+ onClick={() => {+ if (fieldPickerOriginRef.current === 'trigger') {+ closeSheet();+ return;+ }+ queueManagerAddFocus();+ setStep('manage');+ }}+ />+ <div {...stylex.props(styles.headerText)}>+ <Heading level={3}>Add filter</Heading>+ </div>+ </div>+ {hasContentSearch ? (+ <div ref={contentSearchRef}><TextInput- label="Search filters"+ label="Search"isLabelHidden- placeholder="Search filters…"- value={fieldQuery}- onChange={setFieldQuery}+ role="searchbox"+ aria-controls={contentResultsId}+ value={contentQuery}+ onChange={setContentQuery}+ onKeyDown={event => {+ if (isImeKeyEvent(event.nativeEvent)) {+ return;+ }+ if (event.key === 'Enter' && contentResults[0] != null) {+ event.preventDefault();+ handleContentSuggestionSelect(contentResults[0]);+ return;+ }+ if (event.key === 'ArrowDown') {+ event.preventDefault();+ contentSuggestionListRef.current+ ?.querySelector<HTMLButtonElement>('button')+ ?.focus();+ }+ }}+ placeholder={contentSearchPlaceholder}+ hasClearstartIcon={<Icon icon="search" size="sm" color="secondary" />}isDisabled={!isInteractive}width="100%"/>- ) : null}+ </div>+ ) : isFieldSearchShown ? (+ <TextInput+ label="Search filters"+ isLabelHidden+ placeholder="Search filters…"+ value={fieldQuery}+ onChange={setFieldQuery}+ startIcon={<Icon icon="search" size="sm" color="secondary" />}+ isDisabled={!isInteractive}+ width="100%"+ />+ ) : null}+ </div>+ <div {...bodyProps}>+ {hasContentSearch ? (+ contentResults.length > 0 ? (+ <List+ ref={contentSuggestionListRef}+ id={contentResultsId}+ aria-label="Search results"+ hasDividers+ density="spacious"+ edge="bleed">+ {contentResults.map((item, index) => (+ <ListItem+ key={item.id}+ label={item.label}+ isDisabled={!isInteractive}+ onClick={() => handleContentSuggestionSelect(item)}+ onKeyDown={event => {+ if (+ isImeKeyEvent(event.nativeEvent) ||+ (event.key !== 'ArrowDown' && event.key !== 'ArrowUp')+ ) {+ return;+ }+ event.preventDefault();+ const buttons = [+ ...(contentSuggestionListRef.current?.querySelectorAll<HTMLButtonElement>(+ 'button',+ ) ?? []),+ ];+ const nextIndex =+ event.key === 'ArrowDown'+ ? Math.min(index + 1, buttons.length - 1)+ : index - 1;+ if (nextIndex < 0) {+ contentSearchRef.current+ ?.querySelector<HTMLInputElement>('input')+ ?.focus();+ } else {+ buttons[nextIndex]?.focus();+ }+ }}+ />+ ))}+ </List>+ ) : (+ contentQuery.trim() !== '' && (+ <div {...stylex.props(styles.empty)}>+ <Text type="supporting" color="secondary">+ No results found+ </Text>+ </div>+ )+ )+ ) : groupedFields.length === 0 ? (+ <div {...stylex.props(styles.empty)}>+ <Text type="supporting" color="secondary">+ No filters match your search+ </Text>+ </div>+ ) : (+ groupedFields.map(([group, groupFields]) => (+ <List+ key={group}+ hasDividers+ density="spacious"+ header={group === '' ? undefined : group}+ edge="bleed">+ {groupFields.map(field => (+ <ListItem+ key={field.key}+ ref={node => {+ if (node == null) {+ fieldRowsRef.current.delete(field.key);+ } else {+ fieldRowsRef.current.set(field.key, node);+ }+ }}+ label={field.label}+ isDisabled={!isInteractive}+ startContent={field.icon}+ endContent={+ <Icon+ icon="chevronRight"+ size="sm"+ color="secondary"+ xstyle={rtlStyles.mirror}+ />+ }+ onClick={() => handleFieldSelect(field)}+ />+ ))}+ </List>+ ))+ )}+ </div>+ </div>+ </BottomSheet>++ <BottomSheet+ isOpen={step === 'value'}+ onOpenChange={handleValueOpenChange}+ label={editorTitle}+ height="tall"+ padding={0}+ purpose="form">+ <div {...stylex.props(styles.sheet)}>+ {sheetStatus}+ <div {...stylex.props(styles.header)}>+ <div {...stylex.props(styles.headerRow)}>+ <div {...stylex.props(styles.headerText)}>+ <Heading level={3} maxLines={1}>+ {editorTitle}+ </Heading>+ </div></div>+ </div>+ {isDraftRenderable && EditorOverride != null ? (<div {...bodyProps}>- {hasContentSearch ? (- contentResults.length > 0 ? (- <List- ref={contentSuggestionListRef}- id={contentResultsId}- aria-label="Search results"- hasDividers- density="spacious"- edge="bleed">- {contentResults.map((item, index) => (- <ListItem- key={item.id}- label={item.label}- isDisabled={!isInteractive}- onClick={() => handleContentSuggestionSelect(item)}- onKeyDown={event => {- if (- isImeKeyEvent(event.nativeEvent) ||- (event.key !== 'ArrowDown' &&- event.key !== 'ArrowUp')- ) {- return;- }- event.preventDefault();- const buttons = [- ...(contentSuggestionListRef.current?.querySelectorAll<HTMLButtonElement>(- 'button',- ) ?? []),- ];- const nextIndex =- event.key === 'ArrowDown'- ? Math.min(index + 1, buttons.length - 1)- : index - 1;- if (nextIndex < 0) {- contentSearchRef.current- ?.querySelector<HTMLInputElement>('input')- ?.focus();- } else {- buttons[nextIndex]?.focus();+ <EditorOverride+ key={`${draft.mode}-${draft.filterIndex ?? 'new'}-${draft.field}`}+ config={configProp}+ filter={{+ field: draft.field,+ operator: draft.operator,+ value: draft.value,+ }}+ mode={draft.mode}+ onSave={saved => {+ if (saved == null) {+ if (draft.mode === 'edit') {+ handleRemove();+ } else {+ queueManagerAddFocus();+ setStep('manage');+ }+ return;+ }+ commitSavedFilter(draft, saved);+ }}+ onCancel={returnFromValue}+ saveButtonLabel={saveButtonLabel}+ isReadOnly={isEditorDisabled}+ timezoneID={timezoneID}+ />+ </div>+ ) : (+ <>+ <div {...bodyProps}>+ {isDraftRenderable ? (+ <>+ {draftOperators.length > 1 && (+ <RadioList+ label="Operator"+ isLabelHidden+ value={draft.operator ?? ''}+ onChange={operatorKey => {+ const operator = draftOperators.find(+ candidate => candidate.key === operatorKey,+ );+ if (operator != null) {+ handleOperatorSelect(operator);}}}- />- ))}- </List>+ isDisabled={isEditorDisabled}>+ {draftOperators.map(operator => (+ <RadioListItem+ key={operator.key}+ label={`${draftField.label} ${resolveOperatorLabel(operator, t)}`}+ value={operator.key}+ />+ ))}+ </RadioList>+ )}+ <MobilePowerSearchValueEditor+ key={`${draft.field}-${draft.operator}`}+ operatorValue={draftOperator.value}+ filterValue={draft.value}+ onChange={handleDraftValueChange}+ label={draftField.label}+ isDisabled={isEditorDisabled}+ maxMenuItems={maxOperatorMenuItems}+ timezoneID={timezoneID}+ />+ </>) : (- contentQuery.trim() !== '' && (+ // A controlled config update removed the field or operator+ // being edited: say so and keep a way out.+ draft != null && (<div {...stylex.props(styles.empty)}><Text type="supporting" color="secondary">- No results found+ This filter is no longer available</Text></div>)- )- ) : groupedFields.length === 0 ? (- <div {...stylex.props(styles.empty)}>- <Text type="supporting" color="secondary">- No filters match your search- </Text>- </div>- ) : (- groupedFields.map(([group, groupFields]) => (- <List- key={group}- hasDividers- density="spacious"- header={group === '' ? undefined : group}- edge="bleed">- {groupFields.map(field => (- <ListItem- key={field.key}- ref={node => {- if (node == null) {- fieldRowsRef.current.delete(field.key);- } else {- fieldRowsRef.current.set(field.key, node);- }- }}- label={field.label}- isDisabled={!isInteractive}- startContent={field.icon}- endContent={- <Icon- icon="chevronRight"- size="sm"- color="secondary"- xstyle={rtlStyles.mirror}- />- }- onClick={() => handleFieldSelect(field)}- />- ))}- </List>- ))- )}- </div>- </div>- </BottomSheet>-- <BottomSheet- sheetId="value"- label={editorTitle}- height="tall"- padding={0}- purpose="form">- <div {...stylex.props(styles.sheet)}>- {sheetStatus}- <div {...stylex.props(styles.header)}>- <div {...stylex.props(styles.headerRow)}>- <div {...stylex.props(styles.headerText)}>- <Heading level={3} maxLines={1}>- {editorTitle}- </Heading>- </div>- </div>- </div>- {isDraftRenderable && EditorOverride != null ? (- <div {...bodyProps}>- <EditorOverride- key={`${draft.mode}-${draft.filterIndex ?? 'new'}-${draft.field}`}- config={configProp}- filter={{- field: draft.field,- operator: draft.operator,- value: draft.value,- }}- mode={draft.mode}- onSave={saved => {- if (saved == null) {- if (draft.mode === 'edit') {- handleRemove();- } else {- queueManagerAddFocus();- setStep('manage');- }- return;- }- commitSavedFilter(draft, saved);- }}- onCancel={returnFromValue}- saveButtonLabel={saveButtonLabel}- isReadOnly={isEditorDisabled}- timezoneID={timezoneID}- />+ )}</div>- ) : (- <>- <div {...bodyProps}>- {isDraftRenderable ? (- <>- {draftOperators.length > 1 && (- <RadioList- label="Operator"- isLabelHidden- value={draft.operator ?? ''}- onChange={operatorKey => {- const operator = draftOperators.find(- candidate => candidate.key === operatorKey,- );- if (operator != null) {- handleOperatorSelect(operator);- }- }}- isDisabled={isEditorDisabled}>- {draftOperators.map(operator => (- <RadioListItem- key={operator.key}- label={`${draftField.label} ${resolveOperatorLabel(operator, t)}`}- value={operator.key}- />- ))}- </RadioList>- )}- <MobilePowerSearchValueEditor- key={`${draft.field}-${draft.operator}`}- operatorValue={draftOperator.value}- filterValue={draft.value}- onChange={handleDraftValueChange}- label={draftField.label}- isDisabled={isEditorDisabled}- maxMenuItems={maxOperatorMenuItems}- timezoneID={timezoneID}- />- </>- ) : (- // A controlled config update removed the field or operator- // being edited: say so and keep a way out.- draft != null && (- <div {...stylex.props(styles.empty)}>- <Text type="supporting" color="secondary">- This filter is no longer available- </Text>- </div>- )- )}- </div>- <div {...stylex.props(styles.footer)}>- {draft?.mode === 'edit' && !isReadOnly && (+ <div {...stylex.props(styles.footer)}>+ {draft?.mode === 'edit' && !isReadOnly && (+ <Button+ label="Remove"+ variant="ghost"+ isDisabled={isEditorDisabled}+ xstyle={styles.touchAction}+ onClick={handleRemove}+ />+ )}+ <div+ {...stylex.props(+ styles.footerActions,+ isReadOnly && styles.footerSoleAction,+ )}>+ <Button+ label="Cancel"+ variant="ghost"+ xstyle={styles.touchAction}+ onClick={returnFromValue}+ width={isReadOnly ? '100%' : undefined}+ />+ {!isReadOnly && isDraftRenderable && (<Button- label="Remove"- variant="ghost"- isDisabled={isEditorDisabled}+ label={saveButtonLabel}+ variant="primary"+ isDisabled={isSaveDisabled}xstyle={styles.touchAction}- onClick={handleRemove}+ onClick={handleSave}/>)}- <div- {...stylex.props(- styles.footerActions,- isReadOnly && styles.footerSoleAction,- )}>- <Button- label="Cancel"- variant="ghost"- xstyle={styles.touchAction}- onClick={returnFromValue}- width={isReadOnly ? '100%' : undefined}- />- {!isReadOnly && isDraftRenderable && (- <Button- label={saveButtonLabel}- variant="primary"- isDisabled={isSaveDisabled}- xstyle={styles.touchAction}- onClick={handleSave}- />- )}- </div></div>- </>- )}- </div>- </BottomSheet>- </BottomSheetSwitcher>+ </div>+ </>+ )}+ </div>+ </BottomSheet></>);}