Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(PowerSearch): the sheet's choice lists are standard RadioList and CheckboxList (#10608)

Cindy Zhangaefb30d0c584
diff --git a/.changeset/powersearch-sheet-operator-rows.md b/.changeset/powersearch-sheet-operator-rows.md
new file mode 100644
index 0000000000..99cb2443d0
--- /dev/null
+++ b/.changeset/powersearch-sheet-operator-rows.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] PowerSearch's phone sheet now edits single and multiple choices with the standard RadioList and CheckboxList at their usual spacing, instead of its own 48 px rows, and its Operator radios put the radio at the start of the row, as every RadioList does. The choices use the shared touch band, so their touch targets are smaller than before. End, Home and Enter no longer pick a choice; the arrow keys and Space work as in any RadioList or CheckboxList. Adds a "Sheet presentation · realistic config" story that covers every value type. The desktop editor popover is unchanged.
+
+@cixzhang
diff --git a/apps/sandbox/scripts/next-export-routes.json b/apps/sandbox/scripts/next-export-routes.json
index e20265f555..0f338a474b 100644
--- a/apps/sandbox/scripts/next-export-routes.json
+++ b/apps/sandbox/scripts/next-export-routes.json
@@ -48,6 +48,7 @@
"/pages/palette-generator/",
"/pages/perf-scenes/",
"/pages/polymorphic-link/",
+ "/pages/powersearch-phone/",
"/pages/shell-lab/",
"/pages/showcase-components/",
"/pages/showcase-header/",
diff --git a/apps/sandbox/src/app/(raw)/pages/powersearch-phone/page.tsx b/apps/sandbox/src/app/(raw)/pages/powersearch-phone/page.tsx
new file mode 100644
index 0000000000..dc071a858a
--- /dev/null
+++ b/apps/sandbox/src/app/(raw)/pages/powersearch-phone/page.tsx
@@ -0,0 +1,487 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file page.tsx
+ * @position A standalone phone page for PowerSearch's bottom-sheet flow, with
+ * a config sized like real product filter bars and every value type
+ * PowerSearch edits. The page scrolls as a normal document, so touch
+ * scrolling and the sheets behave as they do in a product, outside any
+ * Storybook frame.
+ * @input None
+ * @output The PowerSearch trigger in a document-scrolling page
+ */
+
+'use client';
+
+import {useState} from 'react';
+import {PowerSearch} from '@astryxdesign/core/PowerSearch';
+import type {
+ PowerSearchConfig,
+ PowerSearchFilter,
+} from '@astryxdesign/core/PowerSearch';
+import type {SearchSource, SearchableItem} from '@astryxdesign/core/Typeahead';
+import {TextInput} from '@astryxdesign/core/TextInput';
+import {Heading, Text} from '@astryxdesign/core/Text';
+
+const priorityValues = [
+ {value: 'p0', label: 'P0 - Critical'},
+ {value: 'p1', label: 'P1 - High'},
+ {value: 'p2', label: 'P2 - Medium'},
+ {value: 'p3', label: 'P3 - Low'},
+];
+
+const tagValues = [
+ {value: 'bug', label: 'Bug'},
+ {value: 'feature', label: 'Feature'},
+ {value: 'docs', label: 'Documentation'},
+ {value: 'perf', label: 'Performance'},
+ {value: 'security', label: 'Security'},
+ {value: 'ux', label: 'UX'},
+ {value: 'infra', label: 'Infrastructure'},
+];
+
+const users: SearchableItem[] = [
+ {
+ id: 'user-1',
+ label: 'Alice Johnson',
+ auxiliaryData: {photo: 'https://i.pravatar.cc/150?u=alice'},
+ },
+ {
+ id: 'user-2',
+ label: 'Bob Smith',
+ auxiliaryData: {photo: 'https://i.pravatar.cc/150?u=bob'},
+ },
+ {
+ id: 'user-3',
+ label: 'Charlie Brown',
+ auxiliaryData: {photo: 'https://i.pravatar.cc/150?u=charlie'},
+ },
+ {
+ id: 'user-4',
+ label: 'Diana Prince',
+ auxiliaryData: {photo: 'https://i.pravatar.cc/150?u=diana'},
+ },
+ {
+ id: 'user-5',
+ label: 'Eve Williams',
+ auxiliaryData: {photo: 'https://i.pravatar.cc/150?u=eve'},
+ },
+ {
+ id: 'user-6',
+ label: 'Frank Miller',
+ auxiliaryData: {photo: 'https://i.pravatar.cc/150?u=frank'},
+ },
+];
+
+const realisticRegions = Array.from({length: 60}, (_, index) => ({
+ value: `region_${index + 1}`,
+ label: `Region ${String(index + 1).padStart(2, '0')} · ${(
+ (index * 7919) %
+ 9000
+ ).toLocaleString('en-US')} items`,
+}));
+
+const realisticStages = [
+ 'Draft',
+ 'Submitted',
+ 'In triage',
+ 'Accepted',
+ 'In progress',
+ 'Blocked by dependency',
+ 'In review',
+ 'Ready to release',
+ 'Released',
+ 'Won’t do',
+ 'Archived',
+].map((label, index) => ({value: `stage_${index}`, label}));
+
+const realisticOwnerSource: SearchSource = {
+ search: async (query: string) => {
+ await new Promise(resolve => setTimeout(resolve, 150));
+ return users.filter(user =>
+ user.label.toLowerCase().includes(query.toLowerCase()),
+ );
+ },
+ bootstrap: () => users,
+};
+
+const realisticTagSource: SearchSource = {
+ search: (query: string) =>
+ tagValues
+ .filter(tag => tag.label.toLowerCase().includes(query.toLowerCase()))
+ .map(tag => ({id: tag.value, label: tag.label})),
+ bootstrap: () => tagValues.map(tag => ({id: tag.value, label: tag.label})),
+};
+
+function RealisticCodeEditor({
+ value,
+ onChange,
+ placeholder,
+ isDisabled,
+}: {
+ value: string | null;
+ onChange: (value: string | null) => void;
+ placeholder: string;
+ isDisabled?: boolean;
+}) {
+ return (
+ <TextInput
+ label="Code"
+ isLabelHidden
+ value={value ?? ''}
+ placeholder={placeholder}
+ isDisabled={isDisabled}
+ width="100%"
+ onChange={next => onChange(next === '' ? null : next.toUpperCase())}
+ />
+ );
+}
+
+const realisticTextOperators: PowerSearchConfig['fields'][number]['operators'] =
+ [
+ {key: 'contains', label: 'contains', value: {type: 'string'}},
+ {key: 'not_contains', label: 'does not contain', value: {type: 'string'}},
+ {key: 'is', label: 'is exactly', value: {type: 'string'}},
+ {key: 'is_not', label: 'is not exactly', value: {type: 'string'}},
+ {key: 'starts', label: 'starts with', value: {type: 'string'}},
+ {key: 'ends', label: 'ends with', value: {type: 'string'}},
+ {key: 'any', label: 'is any of', value: {type: 'string_list'}},
+ {key: 'none', label: 'is none of', value: {type: 'string_list'}},
+ {key: 'set', label: 'is set', value: {type: 'empty'}},
+ {key: 'unset', label: 'is not set', value: {type: 'empty'}},
+ ];
+
+function realisticNumberOperators(
+ type: 'integer' | 'float',
+ units?: string,
+): PowerSearchConfig['fields'][number]['operators'] {
+ const value = {type, minValue: 0, units} as const;
+ return [
+ {key: 'eq', label: 'equals', value},
+ {key: 'ne', label: 'does not equal', value},
+ {key: 'gt', label: 'is greater than', value},
+ {key: 'gte', label: 'is at least', value},
+ {key: 'lt', label: 'is less than', value},
+ {key: 'lte', label: 'is at most', value},
+ {key: 'set', label: 'is set', value: {type: 'empty'}},
+ {key: 'unset', label: 'is not set', value: {type: 'empty'}},
+ ];
+}
+
+const realisticConfig: PowerSearchConfig = {
+ name: 'RealisticSearch',
+ fields: [
+ {
+ key: 'title',
+ label: 'Title',
+ group: 'Basics',
+ defaultOperator: 'contains',
+ operators: realisticTextOperators,
+ },
+ {
+ key: 'stage',
+ label: 'Stage',
+ group: 'Basics',
+ description: 'Where the item is in its workflow, from draft to archived.',
+ operators: [
+ {
+ key: 'is',
+ label: 'is',
+ value: {type: 'enum', values: realisticStages},
+ },
+ {
+ key: 'is_not',
+ label: 'is not',
+ value: {type: 'enum', values: realisticStages},
+ },
+ {
+ key: 'any',
+ label: 'is any of',
+ value: {type: 'enum_list', values: realisticStages},
+ },
+ {
+ key: 'none',
+ label: 'is none of',
+ value: {type: 'enum_list', values: realisticStages},
+ },
+ {key: 'set', label: 'is set', value: {type: 'empty'}},
+ {key: 'unset', label: 'is not set', value: {type: 'empty'}},
+ ],
+ },
+ {
+ key: 'priority',
+ label: 'Priority',
+ group: 'Basics',
+ operators: [
+ {key: 'is', label: 'is', value: {type: 'enum', values: priorityValues}},
+ {
+ key: 'is_not',
+ label: 'is not',
+ value: {type: 'enum', values: priorityValues},
+ },
+ {
+ key: 'any',
+ label: 'is any of',
+ value: {type: 'enum_list', values: priorityValues},
+ },
+ {
+ key: 'none',
+ label: 'is none of',
+ value: {type: 'enum_list', values: priorityValues},
+ },
+ ],
+ },
+ {
+ key: 'region',
+ label: 'Primary delivery region',
+ group: 'Basics',
+ operators: [
+ {
+ key: 'is',
+ label: 'is',
+ value: {type: 'enum', values: realisticRegions},
+ },
+ {
+ key: 'any',
+ label: 'is any of',
+ value: {type: 'enum_list', values: realisticRegions},
+ },
+ {
+ key: 'none',
+ label: 'is none of',
+ value: {type: 'enum_list', values: realisticRegions},
+ },
+ ],
+ },
+ {
+ key: 'owner',
+ label: 'Owner',
+ group: 'People',
+ operators: [
+ {
+ key: 'any',
+ label: 'is any of',
+ value: {type: 'entity_list', searchSource: realisticOwnerSource},
+ },
+ {
+ key: 'none',
+ label: 'is none of',
+ value: {type: 'entity_list', searchSource: realisticOwnerSource},
+ },
+ {key: 'set', label: 'is set', value: {type: 'empty'}},
+ {key: 'unset', label: 'is not set', value: {type: 'empty'}},
+ ],
+ },
+ {
+ key: 'reviewer',
+ label: 'Reviewer (searches as you type)',
+ group: 'People',
+ operators: [
+ {
+ key: 'is',
+ label: 'is',
+ value: {type: 'string', searchSource: realisticOwnerSource},
+ },
+ {
+ key: 'is_not',
+ label: 'is not',
+ value: {type: 'string', searchSource: realisticOwnerSource},
+ },
+ ],
+ },
+ {
+ key: 'labels',
+ label: 'Labels',
+ group: 'People',
+ operators: [
+ {
+ key: 'include',
+ label: 'include',
+ value: {
+ type: 'string_list',
+ searchSource: realisticTagSource,
+ isArbitraryStringAllowed: true,
+ },
+ },
+ {
+ key: 'exclude',
+ label: 'exclude',
+ value: {
+ type: 'string_list',
+ searchSource: realisticTagSource,
+ isArbitraryStringAllowed: true,
+ },
+ },
+ ],
+ },
+ {
+ key: 'estimate',
+ label: 'Estimate',
+ group: 'Numbers',
+ operators: realisticNumberOperators('integer', 'points'),
+ },
+ {
+ key: 'budget',
+ label: 'Approved budget',
+ group: 'Numbers',
+ description:
+ 'The amount approved at the last planning review, in US dollars.',
+ operators: realisticNumberOperators('float', 'USD'),
+ },
+ {
+ key: 'created',
+ label: 'Created',
+ group: 'Dates',
+ operators: [
+ {
+ key: 'on',
+ label: 'is on',
+ value: {type: 'date_absolute', isDateOnly: true},
+ },
+ {
+ key: 'before',
+ label: 'is before',
+ value: {type: 'date_absolute', isDateOnly: true},
+ },
+ {
+ key: 'after',
+ label: 'is after',
+ value: {type: 'date_absolute', isDateOnly: true},
+ },
+ {
+ key: 'within',
+ label: 'is within the last',
+ value: {
+ type: 'date_relative',
+ isPastAllowed: true,
+ isFutureAllowed: false,
+ },
+ },
+ {key: 'between', label: 'is between', value: {type: 'date_range'}},
+ {key: 'set', label: 'is set', value: {type: 'empty'}},
+ ],
+ },
+ {
+ key: 'due',
+ label: 'Due',
+ group: 'Dates',
+ operators: [
+ {
+ key: 'before',
+ label: 'is before',
+ value: {type: 'date_absolute', isDateOnly: false},
+ },
+ {
+ key: 'after',
+ label: 'is after',
+ value: {type: 'date_absolute', isDateOnly: false},
+ },
+ {
+ key: 'next',
+ label: 'is within the next',
+ value: {
+ type: 'date_relative',
+ isPastAllowed: false,
+ isFutureAllowed: true,
+ },
+ },
+ {key: 'unset', label: 'is not set', value: {type: 'empty'}},
+ ],
+ },
+ {
+ key: 'window',
+ label: 'Maintenance window',
+ group: 'Dates',
+ operators: [
+ {key: 'between', label: 'is between', value: {type: 'date_range'}},
+ ],
+ },
+ {
+ key: 'start_time',
+ label: 'Daily start time',
+ group: 'Dates',
+ operators: [
+ {key: 'before', label: 'is before', value: {type: 'time'}},
+ {key: 'after', label: 'is after', value: {type: 'time'}},
+ ],
+ },
+ {
+ key: 'code',
+ label: 'Cost center code',
+ group: 'Other',
+ operators: [
+ {
+ key: 'is',
+ label: 'is',
+ value: {
+ type: 'custom',
+ Editor: RealisticCodeEditor,
+ getString: value => value,
+ },
+ },
+ ],
+ },
+ {
+ key: 'flagged',
+ label: 'Flagged for follow-up only',
+ group: 'Other',
+ operators: [{key: 'yes', label: '', value: {type: 'empty'}}],
+ },
+ {
+ key: 'notes',
+ label: 'Notes',
+ group: 'Other',
+ defaultOperator: 'contains',
+ operators: realisticTextOperators.slice(0, 6),
+ },
+ {
+ key: 'any_of_group',
+ label: 'Any of these conditions',
+ group: 'Other',
+ operators: [
+ {key: 'match_any', label: 'match any', value: {type: 'nested'}},
+ {key: 'match_all', label: 'match all', value: {type: 'nested'}},
+ ],
+ },
+ ],
+};
+
+const realisticPresetFilters: ReadonlyArray<PowerSearchFilter> = [
+ {
+ field: 'stage',
+ operator: 'any',
+ value: {type: 'enum_list', value: ['stage_1', 'stage_4', 'stage_6']},
+ },
+ {field: 'priority', operator: 'is', value: {type: 'enum', value: 'p1'}},
+];
+
+export default function PowerSearchPhonePage() {
+ const [filters, setFilters] = useState<ReadonlyArray<PowerSearchFilter>>(
+ realisticPresetFilters,
+ );
+ return (
+ <main
+ style={{
+ maxWidth: 600,
+ margin: '0 auto',
+ padding: 16,
+ display: 'flex',
+ flexDirection: 'column',
+ gap: 16,
+ }}>
+ <Heading level={1}>Filters on a phone</Heading>
+ <PowerSearch
+ config={realisticConfig}
+ filters={filters}
+ onChange={next => setFilters(next)}
+ timezoneID="America/Los_Angeles"
+ presentation="bottom-sheet"
+ />
+ {Array.from({length: 24}, (_, index) => (
+ <Text key={index} type="body">
+ {`Result ${index + 1}. The page scrolls as a normal document behind the filters, so a sheet opens over a page that scrolls on its own.`}
+ </Text>
+ ))}
+ </main>
+ );
+}
diff --git a/apps/storybook/stories/PowerSearch.stories.tsx b/apps/storybook/stories/PowerSearch.stories.tsx
index e30e86610d..622b7b90ca 100644
--- a/apps/storybook/stories/PowerSearch.stories.tsx
+++ b/apps/storybook/stories/PowerSearch.stories.tsx
@@ -10,6 +10,7 @@ import type {
import type {SearchSource, SearchableItem} from '@astryxdesign/core/Typeahead';
import {Button} from '@astryxdesign/core/Button';
import {MagnifyingGlassIcon} from '@heroicons/react/24/outline';
+import {TextInput} from '@astryxdesign/core/TextInput';
// =============================================================================
// Sample data
@@ -2270,3 +2271,426 @@ export const SheetPresentationStates: Story = {
name: 'Bottom sheet states',
parameters: {viewport: {defaultViewport: 'mobile2'}},
};
+
+// =============================================================================
+// Bottom sheet with a realistic config
+// =============================================================================
+
+// Sized like real product filter bars: 17 fields in groups, most with 4–8
+// operators and some with 10, choice lists of 11 and 60 options, labels up to
+// 29 characters, a few descriptions, option labels that carry counts, and
+// every value type PowerSearch edits. Every name is generic.
+
+const realisticRegions = Array.from({length: 60}, (_, index) => ({
+ value: `region_${index + 1}`,
+ label: `Region ${String(index + 1).padStart(2, '0')} · ${(
+ (index * 7919) %
+ 9000
+ ).toLocaleString('en-US')} items`,
+}));
+
+const realisticStages = [
+ 'Draft',
+ 'Submitted',
+ 'In triage',
+ 'Accepted',
+ 'In progress',
+ 'Blocked by dependency',
+ 'In review',
+ 'Ready to release',
+ 'Released',
+ 'Won’t do',
+ 'Archived',
+].map((label, index) => ({value: `stage_${index}`, label}));
+
+const realisticOwnerSource: SearchSource = {
+ search: async (query: string) => {
+ await new Promise(resolve => setTimeout(resolve, 150));
+ return users.filter(user =>
+ user.label.toLowerCase().includes(query.toLowerCase()),
+ );
+ },
+ bootstrap: () => users,
+};
+
+const realisticTagSource: SearchSource = {
+ search: (query: string) =>
+ tagValues
+ .filter(tag => tag.label.toLowerCase().includes(query.toLowerCase()))
+ .map(tag => ({id: tag.value, label: tag.label})),
+ bootstrap: () => tagValues.map(tag => ({id: tag.value, label: tag.label})),
+};
+
+function RealisticCodeEditor({
+ value,
+ onChange,
+ placeholder,
+ isDisabled,
+}: {
+ value: string | null;
+ onChange: (value: string | null) => void;
+ placeholder: string;
+ isDisabled?: boolean;
+}) {
+ return (
+ <TextInput
+ label="Code"
+ isLabelHidden
+ value={value ?? ''}
+ placeholder={placeholder}
+ isDisabled={isDisabled}
+ width="100%"
+ onChange={next => onChange(next === '' ? null : next.toUpperCase())}
+ />
+ );
+}
+
+const realisticTextOperators: PowerSearchConfig['fields'][number]['operators'] =
+ [
+ {key: 'contains', label: 'contains', value: {type: 'string'}},
+ {key: 'not_contains', label: 'does not contain', value: {type: 'string'}},
+ {key: 'is', label: 'is exactly', value: {type: 'string'}},
+ {key: 'is_not', label: 'is not exactly', value: {type: 'string'}},
+ {key: 'starts', label: 'starts with', value: {type: 'string'}},
+ {key: 'ends', label: 'ends with', value: {type: 'string'}},
+ {key: 'any', label: 'is any of', value: {type: 'string_list'}},
+ {key: 'none', label: 'is none of', value: {type: 'string_list'}},
+ {key: 'set', label: 'is set', value: {type: 'empty'}},
+ {key: 'unset', label: 'is not set', value: {type: 'empty'}},
+ ];
+
+function realisticNumberOperators(
+ type: 'integer' | 'float',
+ units?: string,
+): PowerSearchConfig['fields'][number]['operators'] {
+ const value = {type, minValue: 0, units} as const;
+ return [
+ {key: 'eq', label: 'equals', value},
+ {key: 'ne', label: 'does not equal', value},
+ {key: 'gt', label: 'is greater than', value},
+ {key: 'gte', label: 'is at least', value},
+ {key: 'lt', label: 'is less than', value},
+ {key: 'lte', label: 'is at most', value},
+ {key: 'set', label: 'is set', value: {type: 'empty'}},
+ {key: 'unset', label: 'is not set', value: {type: 'empty'}},
+ ];
+}
+
+const realisticConfig: PowerSearchConfig = {
+ name: 'RealisticSearch',
+ fields: [
+ {
+ key: 'title',
+ label: 'Title',
+ group: 'Basics',
+ defaultOperator: 'contains',
+ operators: realisticTextOperators,
+ },
+ {
+ key: 'stage',
+ label: 'Stage',
+ group: 'Basics',
+ description: 'Where the item is in its workflow, from draft to archived.',
+ operators: [
+ {
+ key: 'is',
+ label: 'is',
+ value: {type: 'enum', values: realisticStages},
+ },
+ {
+ key: 'is_not',
+ label: 'is not',
+ value: {type: 'enum', values: realisticStages},
+ },
+ {
+ key: 'any',
+ label: 'is any of',
+ value: {type: 'enum_list', values: realisticStages},
+ },
+ {
+ key: 'none',
+ label: 'is none of',
+ value: {type: 'enum_list', values: realisticStages},
+ },
+ {key: 'set', label: 'is set', value: {type: 'empty'}},
+ {key: 'unset', label: 'is not set', value: {type: 'empty'}},
+ ],
+ },
+ {
+ key: 'priority',
+ label: 'Priority',
+ group: 'Basics',
+ operators: [
+ {key: 'is', label: 'is', value: {type: 'enum', values: priorityValues}},
+ {
+ key: 'is_not',
+ label: 'is not',
+ value: {type: 'enum', values: priorityValues},
+ },
+ {
+ key: 'any',
+ label: 'is any of',
+ value: {type: 'enum_list', values: priorityValues},
+ },
+ {
+ key: 'none',
+ label: 'is none of',
+ value: {type: 'enum_list', values: priorityValues},
+ },
+ ],
+ },
+ {
+ key: 'region',
+ label: 'Primary delivery region',
+ group: 'Basics',
+ operators: [
+ {
+ key: 'is',
+ label: 'is',
+ value: {type: 'enum', values: realisticRegions},
+ },
+ {
+ key: 'any',
+ label: 'is any of',
+ value: {type: 'enum_list', values: realisticRegions},
+ },
+ {
+ key: 'none',
+ label: 'is none of',
+ value: {type: 'enum_list', values: realisticRegions},
+ },
+ ],
+ },
+ {
+ key: 'owner',
+ label: 'Owner',
+ group: 'People',
+ operators: [
+ {
+ key: 'any',
+ label: 'is any of',
+ value: {type: 'entity_list', searchSource: realisticOwnerSource},
+ },
+ {
+ key: 'none',
+ label: 'is none of',
+ value: {type: 'entity_list', searchSource: realisticOwnerSource},
+ },
+ {key: 'set', label: 'is set', value: {type: 'empty'}},
+ {key: 'unset', label: 'is not set', value: {type: 'empty'}},
+ ],
+ },
+ {
+ key: 'reviewer',
+ label: 'Reviewer (searches as you type)',
+ group: 'People',
+ operators: [
+ {
+ key: 'is',
+ label: 'is',
+ value: {type: 'string', searchSource: realisticOwnerSource},
+ },
+ {
+ key: 'is_not',
+ label: 'is not',
+ value: {type: 'string', searchSource: realisticOwnerSource},
+ },
+ ],
+ },
+ {
+ key: 'labels',
+ label: 'Labels',
+ group: 'People',
+ operators: [
+ {
+ key: 'include',
+ label: 'include',
+ value: {
+ type: 'string_list',
+ searchSource: realisticTagSource,
+ isArbitraryStringAllowed: true,
+ },
+ },
+ {
+ key: 'exclude',
+ label: 'exclude',
+ value: {
+ type: 'string_list',
+ searchSource: realisticTagSource,
+ isArbitraryStringAllowed: true,
+ },
+ },
+ ],
+ },
+ {
+ key: 'estimate',
+ label: 'Estimate',
+ group: 'Numbers',
+ operators: realisticNumberOperators('integer', 'points'),
+ },
+ {
+ key: 'budget',
+ label: 'Approved budget',
+ group: 'Numbers',
+ description:
+ 'The amount approved at the last planning review, in US dollars.',
+ operators: realisticNumberOperators('float', 'USD'),
+ },
+ {
+ key: 'created',
+ label: 'Created',
+ group: 'Dates',
+ operators: [
+ {
+ key: 'on',
+ label: 'is on',
+ value: {type: 'date_absolute', isDateOnly: true},
+ },
+ {
+ key: 'before',
+ label: 'is before',
+ value: {type: 'date_absolute', isDateOnly: true},
+ },
+ {
+ key: 'after',
+ label: 'is after',
+ value: {type: 'date_absolute', isDateOnly: true},
+ },
+ {
+ key: 'within',
+ label: 'is within the last',
+ value: {
+ type: 'date_relative',
+ isPastAllowed: true,
+ isFutureAllowed: false,
+ },
+ },
+ {key: 'between', label: 'is between', value: {type: 'date_range'}},
+ {key: 'set', label: 'is set', value: {type: 'empty'}},
+ ],
+ },
+ {
+ key: 'due',
+ label: 'Due',
+ group: 'Dates',
+ operators: [
+ {
+ key: 'before',
+ label: 'is before',
+ value: {type: 'date_absolute', isDateOnly: false},
+ },
+ {
+ key: 'after',
+ label: 'is after',
+ value: {type: 'date_absolute', isDateOnly: false},
+ },
+ {
+ key: 'next',
+ label: 'is within the next',
+ value: {
+ type: 'date_relative',
+ isPastAllowed: false,
+ isFutureAllowed: true,
+ },
+ },
+ {key: 'unset', label: 'is not set', value: {type: 'empty'}},
+ ],
+ },
+ {
+ key: 'window',
+ label: 'Maintenance window',
+ group: 'Dates',
+ operators: [
+ {key: 'between', label: 'is between', value: {type: 'date_range'}},
+ ],
+ },
+ {
+ key: 'start_time',
+ label: 'Daily start time',
+ group: 'Dates',
+ operators: [
+ {key: 'before', label: 'is before', value: {type: 'time'}},
+ {key: 'after', label: 'is after', value: {type: 'time'}},
+ ],
+ },
+ {
+ key: 'code',
+ label: 'Cost center code',
+ group: 'Other',
+ operators: [
+ {
+ key: 'is',
+ label: 'is',
+ value: {
+ type: 'custom',
+ Editor: RealisticCodeEditor,
+ getString: value => value,
+ },
+ },
+ ],
+ },
+ {
+ key: 'flagged',
+ label: 'Flagged for follow-up only',
+ group: 'Other',
+ operators: [{key: 'yes', label: '', value: {type: 'empty'}}],
+ },
+ {
+ key: 'notes',
+ label: 'Notes',
+ group: 'Other',
+ defaultOperator: 'contains',
+ operators: realisticTextOperators.slice(0, 6),
+ },
+ {
+ key: 'any_of_group',
+ label: 'Any of these conditions',
+ group: 'Other',
+ operators: [
+ {key: 'match_any', label: 'match any', value: {type: 'nested'}},
+ {key: 'match_all', label: 'match all', value: {type: 'nested'}},
+ ],
+ },
+ ],
+};
+
+const realisticPresetFilters: ReadonlyArray<PowerSearchFilter> = [
+ {
+ field: 'stage',
+ operator: 'any',
+ value: {type: 'enum_list', value: ['stage_1', 'stage_4', 'stage_6']},
+ },
+ {field: 'priority', operator: 'is', value: {type: 'enum', value: 'p1'}},
+];
+
+/**
+ * The bottom-sheet presentation with a config sized like real product filter
+ * bars, covering every value type PowerSearch edits: text with ten operators,
+ * a text field that searches as you type, text lists, single and multiple
+ * choice (11 and 60 options), people, whole and decimal numbers with units,
+ * dates with and without a time, relative dates past and future, date
+ * ranges, a time of day, a custom editor, a one-tap filter, and a nested
+ * group.
+ */
+export const SheetPresentationRealisticConfig: Story = {
+ render: args => {
+ const [filters, setFilters] = useState<ReadonlyArray<PowerSearchFilter>>(
+ realisticPresetFilters,
+ );
+ return (
+ <PhoneFrame>
+ <PowerSearch
+ {...args}
+ config={realisticConfig}
+ filters={filters}
+ onChange={next => setFilters(next)}
+ timezoneID="America/Los_Angeles"
+ presentation="bottom-sheet"
+ />
+ <FilterDump filters={filters} />
+ </PhoneFrame>
+ );
+ },
+ name: 'Sheet presentation · realistic config',
+ parameters: {viewport: {defaultViewport: 'mobile2'}},
+};
diff --git a/docs/specs/components/Indicator/Indicator.spec.md b/docs/specs/components/Indicator/Indicator.spec.md
index 02d93adc31..c4d42b84aa 100644
--- a/docs/specs/components/Indicator/Indicator.spec.md
+++ b/docs/specs/components/Indicator/Indicator.spec.md
@@ -99,7 +99,7 @@ Consumer migration instructions belong in consumer docs and release notes.
| ID | Invariant | Basis |
| --- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| FR1 | The default registry maps exactly `check` → CheckIndicator, `checkbox` → CheckboxIndicator, and `radio` → RadioIndicator. | Current tests |
-| FR2 | A host resolves an indicator by name from the nearest theme: the theme's `indicators` entry for that name wins, otherwise the built-in. One override reaches every host that resolves that name. The Tokenizer bottom sheet and the PowerSearch value step render CheckboxIndicator and RadioIndicator directly, so a theme's `checkbox` or `radio` entry does not reach them. An augmented name resolves only when a theme supplies it. | `architecture:theme-authoring-contract`; current tests |
+| FR2 | A host resolves an indicator by name from the nearest theme: the theme's `indicators` entry for that name wins, otherwise the built-in. One override reaches every host that resolves that name. The Tokenizer bottom sheet renders CheckboxIndicator and RadioIndicator directly, so a theme's `checkbox` or `radio` entry does not reach it. An augmented name resolves only when a theme supplies it. | `architecture:theme-authoring-contract`; current tests |
| FR3 | Every built-in indicator root sets `aria-hidden="true"` after caller props, so a caller cannot expose it; the public props type rejects `role` and `tabIndex`. Indicators receive `state`, `size`, `isDisabled`, and `children` and nothing that would give them semantics. | `architecture:public-component-api` INV5; current tests |
| FR4 | Renderable `children` replace the built-in state mark inside the indicator; nullish, boolean, and empty-string children keep it, and `0` counts as content. | Current tests |
| FR5 | RadioIndicator renders one circular span (20 or 24 CSS px) whose border and fill follow the state: an emphasized border on the surface when unchecked, an accent fill when checked with an on-accent dot (8 or 10 CSS px) inside. Disabled halves the opacity and mutes the border (and the fill when unchecked). Under a hover-capable pointer, hovering the host's `indicatorScope` tints it. The dot stays visible under forced colors. Transitions are instant under reduced motion. | Current source and tests |
@@ -169,10 +169,9 @@ their own records.
## Current-state impact
-- **Direct indicator imports (FR2).** The Tokenizer bottom sheet and the
- PowerSearch value step render CheckboxIndicator and RadioIndicator
- directly, so a theme's `checkbox` or `radio` override does
- not reach them.
+- **Direct indicator imports (FR2).** The Tokenizer bottom sheet renders
+ CheckboxIndicator and RadioIndicator directly, so a theme's `checkbox` or
+ `radio` override does not reach it.
## Decision log
diff --git a/docs/specs/components/PowerSearch/PowerSearch.spec.md b/docs/specs/components/PowerSearch/PowerSearch.spec.md
index b1e6517d98..d2f6aa3c24 100644
--- a/docs/specs/components/PowerSearch/PowerSearch.spec.md
+++ b/docs/specs/components/PowerSearch/PowerSearch.spec.md
@@ -269,7 +269,7 @@ FR10–FR21 govern. FR25 governs a date-only value in both, and FR26 a date-and-
| FR15b | One open flow edits one draft of the filter list, which starts as `filters` when the flow opens. Every add, edit and removal (FR15) and Clear all (FR23, DEC-4) changes the draft, and the rows, the empty state and Clear all follow it; `onChange` is not called. Done applies the draft: it replays the recorded edits, in order, onto the field's latest `filters` — an add appends its filter; an edit replaces the first filter matching the one it edited (by field, operator, value and read-only flag); a removal drops the filters it removed — and calls `onChange` once per edit with the list after it and that edit's `changeType` and the `index` in that list, the calls a popover session makes, so a filter the parent added while the flow was open survives; an edit or removal whose target the parent removed meanwhile is skipped; then the flow closes; a draft that equals the filters at open (same filters, in order, by field, operator, value and read-only flag, whatever the order of a value's keys) reports nothing and closes, and so does Done on a field that became read-only or disabled while the flow was open (the draft is dropped), as `component:Tokenizer` FR26 states for its sheet. Done is in the Filters footer and in Add filter's footer when Add filter is the entry point. The field's result count follows the applied filters, so it changes on Done, not on an edit. | DEC-7 | Current contract; verified by focused sheet tests. |
| FR15c | A dismissal of the flow's bottom sheet — Escape, a scrim tap, a swipe, a platform close request on Filters, or on Add filter when it is the entry point — closes the flow directly while the draft equals the filters at open. While the draft differs, it opens the discard confirmation inside the sheet (`SheetConfirmation`, the shape `component:Tokenizer` FR27 states): title "Discard changes?", description "Your changes to the filters haven't been applied.", the destructive Discard changes first in reading order and the safe Keep editing focused first; its scrim and Escape take the safe action. Keep editing closes the confirmation, keeps the draft, and returns focus to the sheet's first control — the Filters header's Add filter, else the sheet's panel; Discard changes closes the flow with no `onChange`, and the next open starts from the applied filters. A dismissal of a step above the bottom sheet reveals the step beneath (FR15a) and asks nothing: the draft is still open. | DEC-7; `component:Tokenizer` FR27 | Current contract; verified by focused sheet tests. |
| FR16 | Focus follows the step: after a commit from the value step while creating, the value step and Add filter close and focus lands on the Filters header's Add filter, ready for the next filter; after a content-search suggestion or an `empty`-valued field row commits a filter directly, that filter's row; after Apply or Cancel from editing, the edited filter's row; after a row's trailing remove action, or a caller's `Editor` override's `onSave(null)` while editing, which closes the value step, the trailing remove action of the nearest remaining row that has one (the following one on a tie) — a plain row, a read-only filter's, has none and is passed over — so a run of removals needs no re-aiming, else Add filter when no such row remains; after Cancel from creation, Add filter is revealed with focus on the field row that opened the step, or on the content search when a suggestion opened it — and when a controlled update has removed that field, or the content-search field itself, the Add filter sheet's first control: its search field when one shows, else its first field row; after Add filter is dismissed, the Filters header's Add filter, or the empty state's; after a caller's `Editor` override calls `onSave(null)` while creating, the same (the flow returns to Filters unchanged, FR14); after a confirmed Clear all, the Filters sheet's first remaining control — a kept read-only filter's row has none, so Add filter — with the sheet still open; after Keep filters, Escape, or a scrim tap dismisses the confirmation, Clear all (`component:Dialog` AR2); and, as one rule for the Filters and Add filter sheets, when a controlled update unmounts the control that holds focus — a filter's row or its remove action, a dropped field's row, Clear all gone with the last editable filter — the nearest remaining row that is a button, counted among the button rows by the removed one's index (the following one, else the last) — a plain row (a read-only filter, or every filter while the field is read-only) is passed over — else the sheet's first control (the Add filter sheet's search field, Add filter in the Filters header or empty state), else the sheet's panel, so focus never lands on the page body inside the open sheet; when a controlled update replaces the value step's body with the unavailable state while focus was on one of its controls, Cancel (FR14); after the flow closes, the trigger. A sheet that opens takes focus on its panel, not on a control, except where this row names one; the Add filter sheet's search fields never take it on open (FR13). | DEC-3; touch-flow evidence | Current contract; verified by focused sheet tests and real-engine touch evidence. |
-| FR17 | The value step edits every value type with the same editor the popover presentation uses (`nested` through its built-in nested editor, FR14), with four sheet-native differences: `enum`, `enum_list`, and `date_relative` render as full-width choice rows with a trailing indicator instead of a dropdown that would stack a second layer on the sheet — `radio` rows in a `radiogroup` named by the field label for `enum` and `date_relative` (a tap selects the row; the group is one tab stop — the checked row, else the first — and the arrow keys move focus and check the row they land on, wrapping, Home and End move to and check the first and last row, and Space or Enter checks the focused row — `spec:AST-020/FR15`), `checkbox` rows in a `group` named by the field label for `enum_list` (a tap toggles the row; each row is its own tab stop, toggled with Space or Enter), each carrying its state as `aria-checked`, as the Tokenizer's sheet rows do; `integer` and `float` stage every parseable keystroke, so the confirm action enables while the person is still typing, and unstage when the field is cleared or stops parsing, so it disables again over an empty field; a `string_list` or `entity_list` value edits through the Tokenizer's own sheet presentation (`component:Tokenizer/FR16–FR24`), its trigger showing the staged tokens in the step and its sheet titled with the field label; and a `date_absolute` value with `isDateOnly` unset or `true`, and a `date_range` value, edit through an inline Calendar on the sheet's surface — no popover opens from a sheet — reading a stored instant as its day in `timezoneID`, else the UTC day, and writing a picked day as that day's midnight in the same zone, the day the trigger's token and the Filters row show (FR11, FR12); a `date_absolute` value with `isDateOnly: false` edits through a date-and-time input, sized for touch, that reads and writes the wall-clock time in `timezoneID`, else the viewer's zone. `maxOperatorMenuItems` caps the string and entity suggestions as in the popover presentation. | DEC-3; touch-flow evidence; current value editors | Current contract; verified by focused sheet tests and real-engine touch evidence. Implementation gap: a date-only `date_absolute` value and a `date_range` value edit through the popover presentation's date fields in their sheet presentation — which read and write the day in `timezoneID`, else the UTC day, as this row states — not through an inline Calendar; a value whose operator sets `isDateOnly: false` edits through the popover presentation's date picker and time field in their sheet presentation, which read and write the wall-clock time this row names, not through one date-and-time input. |
+| FR17 | The value step edits every value type with the same editor the popover presentation uses (`nested` through its built-in nested editor, FR14), with four sheet-native differences: `enum`, `enum_list`, and `date_relative` render as the system's lists instead of a dropdown that would stack a second layer on the sheet — a `component:RadioList` named by the field label for `enum` and `date_relative`, and a `component:CheckboxList` named by the field label for `enum_list`, each at its standard density, with its own spacing, keyboard behavior, and checked state; `integer` and `float` stage every parseable keystroke, so the confirm action enables while the person is still typing, and unstage when the field is cleared or stops parsing, so it disables again over an empty field; a `string_list` or `entity_list` value edits through the Tokenizer's own sheet presentation (`component:Tokenizer/FR16–FR24`), its trigger showing the staged tokens in the step and its sheet titled with the field label; and a `date_absolute` value with `isDateOnly` unset or `true`, and a `date_range` value, edit through an inline Calendar on the sheet's surface — no popover opens from a sheet — reading a stored instant as its day in `timezoneID`, else the UTC day, and writing a picked day as that day's midnight in the same zone, the day the trigger's token and the Filters row show (FR11, FR12); a `date_absolute` value with `isDateOnly: false` edits through a date-and-time input, sized for touch, that reads and writes the wall-clock time in `timezoneID`, else the viewer's zone. `maxOperatorMenuItems` caps the string and entity suggestions as in the popover presentation. | DEC-3; touch-flow evidence; current value editors | Current contract; verified by focused sheet tests and real-engine touch evidence. Implementation gap: a date-only `date_absolute` value and a `date_range` value edit through the popover presentation's date fields in their sheet presentation — which read and write the day in `timezoneID`, else the UTC day, as this row states — not through an inline Calendar; a value whose operator sets `isDateOnly: false` edits through the popover presentation's date picker and time field in their sheet presentation, which read and write the wall-clock time this row names, not through one date-and-time input. |
| FR18 | Every list in the sheets derives synchronously from the config — the field list, its search, the content-search suggestions, and the choice rows — so no sheet shows an empty state before results arrive: "No filters match your search" and "No results found" render only for a non-empty query whose synchronous result set is empty, and only while their sheet is the open one; a sheet that is open beneath another, or closed with its body retained, renders and announces no empty-result or unavailable message (AR6). The value typeaheads and tokenizers inside the value step own their own pending states. | DEC-3; `architecture:react-component-runtime/INV1` | Current contract; verified by focused sheet tests and real-engine touch evidence. |
| FR19 | The result count renders at the end of the field in both presentations and is announced only when it changes after mount; the first render announces nothing, including under StrictMode's effect replay. The announcement takes the route `spec:AST-086/FR14` names for where the field is at that moment: inside the open sheet's dialog while a sheet of the flow is open (AR6), otherwise inside the nearest open native modal that holds the field (a Dialog, a modal Drawer), and the shared polite channel only when no modal does — never a channel the record names itself. | Current popover behavior; `architecture:react-component-runtime/INV3` | Current contract; verified by focused sheet tests and real-engine touch evidence. |
| FR20 | Every string the sheets introduce comes from the `@astryx.powersearch.*` catalog, reusing the existing editor keys where their meaning fits (Cancel, Apply, Operator, Value, Values, Entities, the placeholders, the result count). Content the popover presentation already renders keeps its source — field, operator, and value text from the config and its formatters — except that every label the sheets render for a generated choice comes from the catalog as one ICU message with a plural: the relative-date choice rows (`@astryx.powersearch.sheet.relative{Days,Weeks,Months}{Ago,FromNow}`, the same choices and, in English, the same words as the popover's editor lists) and the value summaries of FR12. | DEC-3; catalog contract | Current contract; verified by focused sheet tests and real-engine touch evidence. |
@@ -309,8 +309,8 @@ FR10–FR21 govern. FR25 governs a date-only value in both, and FR26 a date-and-
more sheet of the same stack above the step.
- **AV6 — Sheet layout.** Sheet padding, the field-list search threshold's
visual placement, row density, and the footer's button widths may vary; the 44
- px minimum hit area of every sheet action and the edge-to-edge rows on the
- body's inset are the constants.
+ px minimum hit area of every sheet action (AR5) and the edge-to-edge Filters
+ and field rows on the body's inset are the constants.
### Representative states
@@ -399,17 +399,17 @@ FR10–FR21 govern. FR25 governs a date-only value in both, and FR26 a date-and-
as its tooltip; the Clear all confirmation is a modal `alertdialog` named
"Clear all filters?" whose actions read "Clear filters" and "Keep filters",
with Keep filters focused when it opens, so a stray Enter keeps the filters; a
- choice row is a `radio` (single choice) or a `checkbox` (`enum_list`) named by
- its visible text and checked through `aria-checked`, in a `radiogroup` or
- `group` named by the field label — the radio group one tab stop with arrow-key
- movement that checks and Space or Enter checking the focused row, the checkbox
- rows one tab stop each toggled by Space or Enter (FR17, `spec:AST-020/FR15`);
- the operator step is a radio group named "Operator" of native radio inputs,
- which the arrow keys move and check and Space checks; the content search is a
- searchbox named "Search" controlling the suggestion list; the field-list
- search is a textbox named "Search filters"; every sheet action has a hit area
- at least 44 px tall, and the trailing remove action and the header's Add
- filter keep their medium visible size, their hit area meeting that minimum.
+ value choice is a radio in a `component:RadioList` (single choice) or a
+ checkbox in a `component:CheckboxList` (`enum_list`), named by the field label
+ (FR17); the operator step is a `component:RadioList` named "Operator"; the
+ content search is a searchbox named "Search" controlling the suggestion list;
+ the field-list search is a textbox named "Search filters"; every sheet action
+ except the choice lists has a hit area at least 44 px tall, and the trailing
+ remove action and the header's Add filter keep their medium visible size,
+ their hit area meeting that minimum. The choice lists — the operator and
+ value RadioList and CheckboxList — follow the standard list density and its
+ shared touch band instead, as they do everywhere else (owner decision,
+ cixzhang, 2026-11-07).
- **AR6 — Announcements and focus.** While a sheet is open, every announcement
the flow makes — `Added {label}` for a committed suggestion or an
`empty`-valued field row, `Removed {label}` for a filter removed by its row's
@@ -564,20 +564,20 @@ mark implementation and focused real-Chromium verification as pending.
## Verification map
-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
-| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
-| FR1–FR3, FR7 | PowerSearch unit tests plus real-Chromium geometry assertions | 399/400, 720/721, wide outer surface, narrow viewport, LTR/RTL, collision | Removing either clamp, capping the main menu, or allowing viewport overflow fails. | `audit:PowerSearch/layout` |
-| FR4–FR6, FR9 | Opening-path tests plus real-Chromium geometry assertions | Add from inner input; edit actual left/right/equidistant token/control; pointer/keyboard; reopen opposite side | Using pointer coordinates, modality, wrapper-only identity, stale identity, or public props fails. | `audit:PowerSearch/interaction` |
-| PR1–PR4 | Instrumented unit tests plus first-frame real-Chromium capture | Open, close, reopen opposite side; hidden placement commit; first painted frame | Render-time reads, repeated reads, observers, pointer tracking, or a default-position flash fails. | `audit:PowerSearch/performance` |
-| FR8, AR1–AR3 | Existing PowerSearch/editor suites plus focused browser checks | Pointer and keyboard edit, apply, cancel, Escape, light dismiss, focus return, selection, semantics | Focus, semantics, selection, dismissal, or reachability changes fail. | `audit:PowerSearch/accessibility` |
+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
+| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
+| FR1–FR3, FR7 | PowerSearch unit tests plus real-Chromium geometry assertions | 399/400, 720/721, wide outer surface, narrow viewport, LTR/RTL, collision | Removing either clamp, capping the main menu, or allowing viewport overflow fails. | `audit:PowerSearch/layout` |
+| FR4–FR6, FR9 | Opening-path tests plus real-Chromium geometry assertions | Add from inner input; edit actual left/right/equidistant token/control; pointer/keyboard; reopen opposite side | Using pointer coordinates, modality, wrapper-only identity, stale identity, or public props fails. | `audit:PowerSearch/interaction` |
+| PR1–PR4 | Instrumented unit tests plus first-frame real-Chromium capture | Open, close, reopen opposite side; hidden placement commit; first painted frame | Render-time reads, repeated reads, observers, pointer tracking, or a default-position flash fails. | `audit:PowerSearch/performance` |
+| FR8, AR1–AR3 | Existing PowerSearch/editor suites plus focused browser checks | Pointer and keyboard edit, apply, cancel, Escape, light dismiss, focus return, selection, semantics | Focus, semantics, selection, dismissal, or reachability changes fail. | `audit:PowerSearch/accessibility` |
| FR15b, FR15c | Focused sheet tests: no `onChange` before Done, Done's replay in order, an unchanged draft's silent close, clean and changed-draft dismissal with Keep editing and Discard changes, read-only filters kept through Clear all and Done, and the popover presentation's at-once reports |
-| FR22 | PowerSearch and Tokenizer unit tests | A read-only field with a filter: no Clear all, no token remove control, Backspace on the empty input | A read-only field removes a filter through Backspace, Clear all, or a token control. | `audit:PowerSearch/interaction` |
-| FR23 | PowerSearch and Tokenizer unit tests | Clear all with a read-only filter before two editable ones; every filter read-only; Backspace with a read-only last filter; the words with and without a read-only filter left | A read-only filter is removed, Clear all reports an index other than the first removed one, Clear all shows with no editable filter, or its words say every filter went while one remains. | `audit:PowerSearch/interaction` |
-| FR24 | `PowerSearchTokenNaming.test.tsx`; real-Chromium accessibility tree of a popover token | Popover token with a value, read-only token, editor open and closed, a verb-last remove word | A token named without its value, a missing or stale `aria-expanded`, an unnamed or non-dialog editor, or a remove name that loses its locale's word order fails. | `audit:PowerSearch/accessibility` |
-| FR25 | PowerSearch date-zone tests under four host zones (UTC, Los Angeles, Tokyo, Honolulu) with `timezoneID` set to each zone and unset: token text, the removal announcement that carries the accessible label, the editor's opening day, the stored instant after a pick, a round trip that moves the day and back, a `components` Editor override and `PowerSearchFilterEditor` receiving the zone, range parts read and written, and an `isDateOnly: false` value left to FR26; plus the formatter's unit tests | a Los Angeles evening instant with `timezoneID` set and unset, a pick across the US daylight-time change, a `date_range` of two instants | The token and the editor show different days for one value, a re-picked day moves the instant, or a day shows a time | `audit:PowerSearch/interaction` |
-| FR26 | PowerSearch date-and-time tests under four host zones (UTC, Los Angeles, Tokyo, Honolulu) with `timezoneID` set and unset: the token's date and time, the editor's opening date and time, the stored instant after a time is typed, a `components` Editor override and `PowerSearchFilterEditor` receiving the zone, the editor on a line of its own, and a date-only operator kept on the date picker; plus the sheet's value step opening on the time in `timezoneID` | a Los Angeles evening instant with `isDateOnly: false` and `timezoneID` Los Angeles, Tokyo, empty and unset; the same instant with `isDateOnly: true` | The token shows no time, the editor has no time field or opens on another time than the token shows, a typed time stores a different instant than it names, or a date-only operator gains a time field | `audit:PowerSearch/interaction` |
-| FR10–FR21, AR4–AR6, PR5 | Focused PowerSearch sheet tests with the compact-touch query stubbed both ways, plus real-engine touch evidence and a real-engine width sweep of a long placeholder in both writing directions | the default resolving both ways, `popover` kept on a compact coarse-pointer screen, forced sheet, adaptive both ways (the default's server markup the same as `popover`'s, server markup and hydration as the popover field on a coarse-pointer client, then the trigger, no recoverable error, focus on the body; with `hasAutoFocus`, the autofocused input's focus ending on the trigger with no `onBlur` or `onFocus` to the caller), trigger name, Filters/Add filter/value steps, each value type, list value through the Tokenizer sheet, Clear all, read-only, disabled while open, focus after each step, focus after an `adaptive` switch from the trigger, the input, a removed control, an open editor popover, and from outside the field, a field inside an open Dialog announcing the count, Clear all, and in-sheet messages inside that Dialog and never on the page body, StrictMode result count, in-sheet live region while a sheet is open (added, removed, count, empty results), Clear all announced only after the dialog's exit, row, token and Removed text sharing one formatter, a date-only value as its day in `timezoneID`, else the UTC day, and a date-and-time value in `timezoneID`, else the viewer's zone, on all three (UTC, Tokyo, Honolulu, unset), summaries and relative-date labels and values from the catalog, the row and Removed through one reorderable message, an unmatched relative-date value as stored, a filter the config no longer knows listed and removable, a cleared number unstaged, choice rows as radios and checkboxes with `aria-checked`, a stale read-only filter as a plain row, a removal next to a nested row focusing that row's remove action, a list value joined by the locale's narrow conjunction list in English, Simplified Chinese, Japanese, and German, an empty-result message spoken once per query from its rendered element, a controlled update that removes the edited field moving focus from the replaced body to Cancel and announcing the unavailable state in the sheet while the step is open and never from a step beneath another or retained closed, Apply and Cancel after a controlled update removed the edited filter focusing the nearest row, else Add filter, a row's trailing remove action focusing the next row's remove action, a one-tap `empty`-valued filter added from its field row and removed from its row, Clear all behind its confirmation keeping read-only filters and leaving Filters open, a dismissed step revealing the step beneath with focus restored to it, Add filter opening with its search unfocused and a touch drag on the rows blurring a focused search, a stale filter's step titled as its row reads (raw keys for what is gone, the field's label when the field remains), Cancel from creation after the opening field was removed focusing the Add filter sheet's first control, a removed focused Filters row, a removed Clear all, and a dropped focused field row each handing focus to the nearest remaining row or the sheet's first control, element counts at rest and with each of the Filters, Add filter and value sheets open, and with the Tokenizer's list-value sheet stacked above the value step, under fine and coarse pointers, nothing of the flow in the DOM at rest before a press and after the exit, a nested filter edited and created through the built-in nested editor (its sub-filter rows wrapping inside a 390 and a 414 px sheet; its root operator picker absent on a mixed field, the Operator group in its place), a nested-only field and its suggestion offered, a suggestion's operator checked over the field's default, the Operator group outside a caller's Editor override on a mixed field, a count changed during the exit spoken with Clear all's message as one catalog message after the close, a radio group's arrow keys, Home, and End moving and checking, Space and Enter checking a focused radio row and toggling a checkbox row, right-to-left layout with the row chevrons mirrored in RTL (`design:bidirectionality/DR4`) | A field with a fine pointer or on a screen that is not compact changes by default beyond what FR19 states, `presentation="popover"` presents the sheet flow, a value commits before the step confirms, Clear all removes a read-only filter, the trigger carries native `disabled`, focus lands elsewhere, an announcement reaches a channel outside the modal that holds the field at that moment, or the popover bundle carries the sheets. | `audit:PowerSearch/sheet` |
-| Record structure | `scripts/check-knowledge.mjs` | Component-contract schema and current-authority dependency | Missing or invalid metadata and sections fail repository validation. | `audit:PowerSearch/knowledge` |
+| FR22 | PowerSearch and Tokenizer unit tests | A read-only field with a filter: no Clear all, no token remove control, Backspace on the empty input | A read-only field removes a filter through Backspace, Clear all, or a token control. | `audit:PowerSearch/interaction` |
+| FR23 | PowerSearch and Tokenizer unit tests | Clear all with a read-only filter before two editable ones; every filter read-only; Backspace with a read-only last filter; the words with and without a read-only filter left | A read-only filter is removed, Clear all reports an index other than the first removed one, Clear all shows with no editable filter, or its words say every filter went while one remains. | `audit:PowerSearch/interaction` |
+| FR24 | `PowerSearchTokenNaming.test.tsx`; real-Chromium accessibility tree of a popover token | Popover token with a value, read-only token, editor open and closed, a verb-last remove word | A token named without its value, a missing or stale `aria-expanded`, an unnamed or non-dialog editor, or a remove name that loses its locale's word order fails. | `audit:PowerSearch/accessibility` |
+| FR25 | PowerSearch date-zone tests under four host zones (UTC, Los Angeles, Tokyo, Honolulu) with `timezoneID` set to each zone and unset: token text, the removal announcement that carries the accessible label, the editor's opening day, the stored instant after a pick, a round trip that moves the day and back, a `components` Editor override and `PowerSearchFilterEditor` receiving the zone, range parts read and written, and an `isDateOnly: false` value left to FR26; plus the formatter's unit tests | a Los Angeles evening instant with `timezoneID` set and unset, a pick across the US daylight-time change, a `date_range` of two instants | The token and the editor show different days for one value, a re-picked day moves the instant, or a day shows a time | `audit:PowerSearch/interaction` |
+| FR26 | PowerSearch date-and-time tests under four host zones (UTC, Los Angeles, Tokyo, Honolulu) with `timezoneID` set and unset: the token's date and time, the editor's opening date and time, the stored instant after a time is typed, a `components` Editor override and `PowerSearchFilterEditor` receiving the zone, the editor on a line of its own, and a date-only operator kept on the date picker; plus the sheet's value step opening on the time in `timezoneID` | a Los Angeles evening instant with `isDateOnly: false` and `timezoneID` Los Angeles, Tokyo, empty and unset; the same instant with `isDateOnly: true` | The token shows no time, the editor has no time field or opens on another time than the token shows, a typed time stores a different instant than it names, or a date-only operator gains a time field | `audit:PowerSearch/interaction` |
+| FR10–FR21, AR4–AR6, PR5 | Focused PowerSearch sheet tests with the compact-touch query stubbed both ways, plus real-engine touch evidence, and a real-engine width sweep of a long placeholder in both writing directions | the default resolving both ways, `popover` kept on a compact coarse-pointer screen, forced sheet, adaptive both ways (the default's server markup the same as `popover`'s, server markup and hydration as the popover field on a coarse-pointer client, then the trigger, no recoverable error, focus on the body; with `hasAutoFocus`, the autofocused input's focus ending on the trigger with no `onBlur` or `onFocus` to the caller), trigger name, Filters/Add filter/value steps, each value type, list value through the Tokenizer sheet, Clear all, read-only, disabled while open, focus after each step, focus after an `adaptive` switch from the trigger, the input, a removed control, an open editor popover, and from outside the field, a field inside an open Dialog announcing the count, Clear all, and in-sheet messages inside that Dialog and never on the page body, StrictMode result count, in-sheet live region while a sheet is open (added, removed, count, empty results), Clear all announced only after the dialog's exit, row, token and Removed text sharing one formatter, a date-only value as its day in `timezoneID`, else the UTC day, and a date-and-time value in `timezoneID`, else the viewer's zone, on all three (UTC, Tokyo, Honolulu, unset), summaries and relative-date labels and values from the catalog, the row and Removed through one reorderable message, an unmatched relative-date value as stored, a filter the config no longer knows listed and removable, a cleared number unstaged, a stale read-only filter as a plain row, a removal next to a nested row focusing that row's remove action, a list value joined by the locale's narrow conjunction list in English, Simplified Chinese, Japanese, and German, an empty-result message spoken once per query from its rendered element, a controlled update that removes the edited field moving focus from the replaced body to Cancel and announcing the unavailable state in the sheet while the step is open and never from a step beneath another or retained closed, Apply and Cancel after a controlled update removed the edited filter focusing the nearest row, else Add filter, a row's trailing remove action focusing the next row's remove action, a one-tap `empty`-valued filter added from its field row and removed from its row, Clear all behind its confirmation keeping read-only filters and leaving Filters open, a dismissed step revealing the step beneath with focus restored to it, Add filter opening with its search unfocused and a touch drag on the rows blurring a focused search, a stale filter's step titled as its row reads (raw keys for what is gone, the field's label when the field remains), Cancel from creation after the opening field was removed focusing the Add filter sheet's first control, a removed focused Filters row, a removed Clear all, and a dropped focused field row each handing focus to the nearest remaining row or the sheet's first control, element counts at rest and with each of the Filters, Add filter and value sheets open, and with the Tokenizer's list-value sheet stacked above the value step, under fine and coarse pointers, nothing of the flow in the DOM at rest before a press and after the exit, a nested filter edited and created through the built-in nested editor (its sub-filter rows wrapping inside a 390 and a 414 px sheet; its root operator picker absent on a mixed field, the Operator group in its place), a nested-only field and its suggestion offered, a suggestion's operator checked over the field's default, the Operator group outside a caller's Editor override on a mixed field, a count changed during the exit spoken with Clear all's message as one catalog message after the close, a single choice as a RadioList with one radio group whose arrow keys move and check, a multiple choice as a CheckboxList whose rows Space toggles, right-to-left layout with the row chevrons mirrored in RTL (`design:bidirectionality/DR4`) | A field with a fine pointer or on a screen that is not compact changes by default beyond what FR19 states, `presentation="popover"` presents the sheet flow, a value commits before the step confirms, Clear all removes a read-only filter, the trigger carries native `disabled`, focus lands elsewhere, an announcement reaches a channel outside the modal that holds the field at that moment, or the popover bundle carries the sheets. | `audit:PowerSearch/sheet` |
+| Record structure | `scripts/check-knowledge.mjs` | Component-contract schema and current-authority dependency | Missing or invalid metadata and sections fail repository validation. | `audit:PowerSearch/knowledge` |
Current-source Chromium evidence establishes the geometry gap, not implementation
completion:
diff --git a/packages/core/src/CheckboxList/CheckboxList.tsx b/packages/core/src/CheckboxList/CheckboxList.tsx
index c184b31d6d..a8560fcddb 100644
--- a/packages/core/src/CheckboxList/CheckboxList.tsx
+++ b/packages/core/src/CheckboxList/CheckboxList.tsx
@@ -34,9 +34,9 @@ import {Field} from '../Field/Field';
import type {InputStatus} from '../Field/types';
import {List} from '../List/List';
import type {ListDensity} from '../List/ListContext';
-import {useTooltip} from '../Tooltip';
+import {useTooltip} from '../Tooltip/useTooltip';
import * as stylex from '@stylexjs/stylex';
-import {mergeProps} from '../utils';
+import {mergeProps} from '../utils/mergeProps';
import {themeProps} from '../utils/themeProps';
import {joinAriaIDs} from '../utils/inputAria';
import {
diff --git a/packages/core/src/PowerSearch/PowerSearchBottomSheet.test.tsx b/packages/core/src/PowerSearch/PowerSearchBottomSheet.test.tsx
index c56d240c8d..e646417097 100644
--- a/packages/core/src/PowerSearch/PowerSearchBottomSheet.test.tsx
+++ b/packages/core/src/PowerSearch/PowerSearchBottomSheet.test.tsx
@@ -463,21 +463,6 @@ function choice(name: string): HTMLElement {
);
}
-function expectBleedChoiceRows(group: HTMLElement): void {
- expect(group.className).toMatch(/choiceList/);
- const rows = group.querySelectorAll('[role="radio"], [role="checkbox"]');
- expect(rows.length).toBeGreaterThan(0);
- for (const row of rows) {
- expect(row.className).toMatch(/choiceRow/);
- }
- const body = group.closest('[class*="body"]');
- expect(body).not.toBeNull();
- const computed = getComputedStyle(body!);
- expect(computed.getPropertyValue('--container-padding-inline-start')).toBe(
- 'var(--spacing-4)',
- );
-}
-
function openAddFlow(): void {
openSheet();
if (within(sheet()).queryByRole('heading', {name: 'Filters'})) {
@@ -2872,7 +2857,6 @@ describe('PowerSearch value step (FR14–FR16)', () => {
// sheet's surface, its rows on the body's inset.
tapRow('Labels');
const group = within(sheet()).getByRole('group', {name: 'Labels'});
- expectBleedChoiceRows(group);
expect(group.closest('[class*="controlSection"]')).toBeNull();
});
@@ -2896,14 +2880,6 @@ describe('PowerSearch value step (FR14–FR16)', () => {
expect(getComputedStyle(valueSection!).backgroundColor).toBe(
'var(--color-background-muted)',
);
- // The section publishes its own padding, so the choice rows run edge to
- // edge inside it.
- expect(values.className).toMatch(/choiceList/);
- expect(
- getComputedStyle(valueSection!).getPropertyValue(
- '--container-padding-inline-start',
- ),
- ).toBe('var(--spacing-3)');
});
it('stages an enum selection and commits it with exact add metadata', () => {
@@ -2933,13 +2909,13 @@ describe('PowerSearch value step (FR14–FR16)', () => {
setup();
openAddFlow();
tapRow('Labels');
- // The whole row is the control: tapping its label toggles it.
- const bug = choice('Bug');
- expect(bug).not.toBeChecked();
- fireEvent.click(within(bug).getByText('Bug'));
+ // Tapping anywhere on a row toggles it, as in any CheckboxList.
+ const group = within(sheet()).getByRole('group', {name: 'Labels'});
+ expect(choice('Bug')).not.toBeChecked();
+ const row = choice('Bug').closest('li');
+ expect(group).toContainElement(row);
+ fireEvent.click(row!);
expect(choice('Bug')).toBeChecked();
- expect(choice('Bug')).toHaveAttribute('role', 'checkbox');
- expect(within(sheet()).getByRole('group', {name: 'Labels'})).toBeTruthy();
});
it('returns focus to Add filter when the closing steps finish their exit, even when the first move did not land (FR16)', () => {
@@ -3110,67 +3086,24 @@ describe('PowerSearch value step (FR14–FR16)', () => {
expect(within(sheet()).getByRole('button', {name: 'Author'})).toHaveFocus();
});
- it('makes a radio group one tab stop whose arrow keys move and check, and leaves checkbox rows one stop each (FR17)', () => {
+ it('edits a single choice with a RadioList and a multiple choice with a CheckboxList, keyboard included (FR17)', async () => {
+ const user = userEvent.setup();
const {onChange} = setup();
openAddFlow();
tapRow('Status');
const group = within(sheet()).getByRole('radiogroup', {name: 'Status'});
+ expect(group).toHaveClass('astryx-radio-list');
const radios = within(group).getAllByRole('radio');
- // Nothing checked yet: the first row is the group's single tab stop.
- expect(radios.map(r => r.tabIndex)).toEqual([0, -1]);
- radios[0].focus();
- fireEvent.keyDown(radios[0], {key: 'ArrowDown'});
- // The arrow moved focus and checked the row it landed on.
- expect(radios[1]).toHaveFocus();
- expect(radios[1]).toBeChecked();
- expect(radios.map(r => r.tabIndex)).toEqual([-1, 0]);
- fireEvent.keyDown(radios[1], {key: 'ArrowUp'});
- expect(radios[0]).toHaveFocus();
- expect(radios[0]).toBeChecked();
- fireEvent.keyDown(radios[0], {key: 'ArrowUp'});
- // Wraps.
- expect(radios[1]).toHaveFocus();
- expect(radios[1]).toBeChecked();
- fireEvent.keyDown(radios[1], {key: 'Home'});
- expect(radios[0]).toBeChecked();
- fireEvent.keyDown(radios[0], {key: 'End'});
- expect(radios[1]).toBeChecked();
- expect(onChange).not.toHaveBeenCalled();
- fireEvent.click(within(sheet()).getByRole('button', {name: 'Cancel'}));
-
- tapRow('Labels');
- const boxes = within(
- within(sheet()).getByRole('group', {name: 'Labels'}),
- ).getAllByRole('checkbox');
- // Every checkbox row is a tab stop; arrows do nothing to them.
- expect(boxes.every(b => b.tabIndex === 0)).toBe(true);
- boxes[0].focus();
- fireEvent.keyDown(boxes[0], {key: 'ArrowDown'});
- expect(boxes[0]).toHaveFocus();
- expect(boxes[0]).not.toBeChecked();
- // Activation (Space/Enter on a button fires click) toggles.
- fireEvent.click(boxes[0]);
- expect(boxes[0]).toBeChecked();
- });
-
- it('checks a focused radio row with Space or Enter and toggles a checkbox row with Space (FR17; AST-020 FR15)', async () => {
- const user = userEvent.setup();
- setup();
- openAddFlow();
- tapRow('Status');
- const radios = within(
- within(sheet()).getByRole('radiogroup', {name: 'Status'}),
- ).getAllByRole('radio');
- radios[0].focus();
- await user.keyboard(' ');
+ // One group of native radios, so the arrow keys move and check.
+ expect(new Set(radios.map(radio => radio.getAttribute('name'))).size).toBe(
+ 1,
+ );
+ await user.click(radios[0]);
expect(radios[0]).toBeChecked();
- // Arrow to the next row without a pointer, then Enter checks it too (it
- // is already checked by the arrow; Enter keeps it so).
await user.keyboard('{ArrowDown}');
expect(radios[1]).toBeChecked();
- await user.keyboard('{Enter}');
- expect(radios[1]).toBeChecked();
expect(radios[0]).not.toBeChecked();
+ expect(onChange).not.toHaveBeenCalled();
fireEvent.click(within(sheet()).getByRole('button', {name: 'Cancel'}));
tapRow('Labels');
@@ -3182,8 +3115,6 @@ describe('PowerSearch value step (FR14–FR16)', () => {
expect(boxes[1]).toBeChecked();
await user.keyboard(' ');
expect(boxes[1]).not.toBeChecked();
- await user.keyboard('{Enter}');
- expect(boxes[1]).toBeChecked();
});
it('stages a multi-select and commits it from the footer', () => {
diff --git a/packages/core/src/PowerSearch/PowerSearchBottomSheet.tsx b/packages/core/src/PowerSearch/PowerSearchBottomSheet.tsx
index 1afef003fc..ccb97b730a 100644
--- a/packages/core/src/PowerSearch/PowerSearchBottomSheet.tsx
+++ b/packages/core/src/PowerSearch/PowerSearchBottomSheet.tsx
@@ -60,15 +60,14 @@ import {EmptyState} from '../EmptyState/EmptyState';
import {Heading} from '../Heading/Heading';
import {Icon} from '../Icon/Icon';
import {IconButton} from '../IconButton/IconButton';
-import {CheckboxIndicator} from '../Indicator/CheckboxIndicator';
-import {RadioIndicator} from '../Indicator/RadioIndicator';
-import {focusOutlineStyles} from '../utils/focusOutline.stylex';
import {isRenderable} from '../utils/isRenderable';
import {containerPaddingInlineVarStyles} from '../Layout/padding.stylex';
import {List} from '../List/List';
import {ListItem} from '../List/ListItem';
import {RadioList} from '../RadioList/RadioList';
import {RadioListItem} from '../RadioList/RadioListItem';
+import {CheckboxList} from '../CheckboxList/CheckboxList';
+import {CheckboxListItem} from '../CheckboxList/CheckboxListItem';
import {Text} from '../Text/Text';
import {TextInput} from '../TextInput/TextInput';
import type {SearchSource} from '../Typeahead/types';
@@ -484,18 +483,12 @@ const styles = stylex.create({
justifyContent: 'center',
},
// With more than one section in the value step, each section is a muted
- // container. Its inline padding is published as container padding, so
- // choice rows run edge to edge inside the section.
+ // container.
controlSection: {
padding: spacingVars['--spacing-3'],
borderRadius: radiusVars['--radius-container'],
backgroundColor: colorVars['--color-background-muted'],
},
- // The operator radios put their indicator at the row's end, as the choice
- // rows do.
- trailingControlRow: {
- flexDirection: 'row-reverse',
- },
// The built-in nested editor's sub-filter rows collapse from one line to
// wrapped lines under a container query on the popover's own container;
// the sheet renders no such container, so the editor's tree root is the
@@ -508,53 +501,6 @@ const styles = stylex.create({
rowValue: {
fontWeight: fontWeightVars['--font-weight-bold'],
},
- // Choice rows run edge to edge on the inset of the surface that holds them,
- // the body or a muted section, with no dividers: the group reaches into
- // that padding and each row pads back out to it.
- choiceList: {
- display: 'flex',
- flexDirection: 'column',
- marginInlineStart: 'calc(-1 * var(--container-padding-inline-start, 0px))',
- marginInlineEnd: 'calc(-1 * var(--container-padding-inline-end, 0px))',
- width:
- 'calc(100% + var(--container-padding-inline-start, 0px) + var(--container-padding-inline-end, 0px))',
- },
- choiceRow: {
- display: 'flex',
- alignItems: 'center',
- gap: spacingVars['--spacing-3'],
- width: '100%',
- minHeight: 44,
- paddingBlock: spacingVars['--spacing-3'],
- paddingInlineStart: 'var(--container-padding-inline-start, 0px)',
- paddingInlineEnd: 'var(--container-padding-inline-end, 0px)',
- borderWidth: 0,
- borderRadius: 0,
- backgroundColor: 'transparent',
- color: colorVars['--color-text-primary'],
- fontFamily: 'inherit',
- textAlign: 'start',
- cursor: {
- default: 'pointer',
- ':is([aria-disabled="true"])': 'default',
- },
- },
- // An aria-disabled row gets no system disabled paint in forced colors;
- // GrayText is the platform's disabled affordance there.
- choiceRowDisabled: {
- color: {
- default: colorVars['--color-text-secondary'],
- '@media (forced-colors: active)': 'GrayText',
- },
- },
- choiceIcon: {
- display: 'inline-flex',
- flexShrink: 0,
- },
- choiceLabel: {
- flexGrow: 1,
- minWidth: 0,
- },
editorInput: {
paddingBlockStart: spacingVars['--spacing-1'],
},
@@ -698,134 +644,65 @@ interface ChoiceItem {
readonly icon?: ReactNode;
}
-// A radio group's one tab stop: the checked row, else the first.
-function radioTabStopOrder(list: HTMLElement): ReadonlyArray<HTMLElement> {
- const rows = Array.from(list.querySelectorAll<HTMLElement>('[role="radio"]'));
- const checked = rows.find(row => row.getAttribute('aria-checked') === 'true');
- return checked == null
- ? rows
- : [checked, ...rows.filter(row => row !== checked)];
-}
-
/**
- * Closed vocabularies render as full-width rows with a trailing check instead
- * of the popover presentation's Selector or Tokenizer: a dropdown layer inside
- * a sheet stacks a second overlay on a surface the person is already inside.
+ * Closed vocabularies render as lists, not as a dropdown. A dropdown layer
+ * inside a sheet stacks a second overlay on a surface the person is already
+ * inside.
*/
-function ChoiceRows({
- items,
- selected,
- isDisabled,
- isMultiple,
- label,
- onToggle,
-}: {
- items: ReadonlyArray<ChoiceItem>;
- selected: ReadonlySet<string>;
- isDisabled?: boolean;
- /** `enum_list`: checkbox rows that toggle. Otherwise radio rows. */
- isMultiple: boolean;
- /** The group's accessible name: the field label. */
- label: string;
- onToggle: (value: string, isSelected: boolean) => void;
-}) {
- // The rows carry their state as state, not as a name suffix: `radio` rows
- // in a `radiogroup` for a single choice, `checkbox` rows in a `group` for
- // `enum_list`, each with `aria-checked`, as the Tokenizer's sheet rows do.
- // Disabled rows stay focusable with `aria-disabled`.
- //
- // Keyboard: a radio group is one tab stop — the checked row, else the
- // first — and the arrow keys move focus and check the row they land on,
- // wrapping; Home and End move to and check the first and last row. The
- // shared list focus owns the tab stop and the moves; a row that takes focus
- // from an arrow, Home or End is checked here. Space and Enter check the
- // focused radio row and toggle a checkbox row: each row is a native
- // `button`, whose activation fires `onClick` for both keys. A checkbox row
- // is its own tab stop.
- const isKeyMoveRef = useRef(false);
- const {listRef, handleKeyDown, handleFocus} =
- useInternalListFocus<HTMLDivElement>({
- itemSelector: '[role="radio"]',
- orientation: 'both',
- hasRovingTabIndex: !isMultiple,
- tabStopOrder: radioTabStopOrder,
- });
- const handleRadioKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
- isKeyMoveRef.current = true;
- try {
- handleKeyDown(event);
- } finally {
- isKeyMoveRef.current = false;
- }
- };
- const handleRadioFocus = (event: React.FocusEvent<HTMLDivElement>) => {
- handleFocus(event);
- if (!isKeyMoveRef.current || isDisabled) {
- return;
- }
- const value = (event.target as HTMLElement).closest<HTMLElement>(
- '[role="radio"]',
- )?.dataset.value;
- if (value != null && !selected.has(value)) {
- onToggle(value, false);
- }
- };
- return (
- <div
- ref={listRef}
- role={isMultiple ? 'group' : 'radiogroup'}
- aria-label={label}
- onKeyDown={isMultiple ? undefined : handleRadioKeyDown}
- onFocus={isMultiple ? undefined : handleRadioFocus}
- {...stylex.props(styles.choiceList)}>
- {items.map(item => {
- const isSelected = selected.has(item.value);
- return (
- <button
+function ChoiceRows(
+ props: {
+ items: ReadonlyArray<ChoiceItem>;
+ selected: ReadonlyArray<string>;
+ isDisabled?: boolean;
+ /** The group's accessible name: the field label. */
+ label: string;
+ } & (
+ | {isMultiple: true; onChange: (values: string[]) => void}
+ | {isMultiple?: false; onChange: (value: string) => void}
+ ),
+) {
+ const {items, selected, isDisabled, label} = props;
+ const itemLabel = (item: ChoiceItem) =>
+ isRenderable(item.icon) ? (
+ <>
+ <span aria-hidden="true">{item.icon}</span> {item.label}
+ </>
+ ) : (
+ item.label
+ );
+ if (props.isMultiple === true) {
+ return (
+ <CheckboxList
+ label={label}
+ isLabelHidden
+ isDisabled={isDisabled}
+ value={[...selected]}
+ onChange={props.onChange}>
+ {items.map(item => (
+ <CheckboxListItem
key={item.value}
- type="button"
- role={isMultiple ? 'checkbox' : 'radio'}
- aria-checked={isSelected}
- aria-disabled={isDisabled || undefined}
- data-value={item.value}
- onClick={() => {
- if (!isDisabled) {
- onToggle(item.value, isSelected);
- }
- }}
- {...stylex.props(
- focusOutlineStyles.focusVisible,
- styles.choiceRow,
- isDisabled && styles.choiceRowDisabled,
- )}>
- {isRenderable(item.icon) && (
- <span aria-hidden="true" {...stylex.props(styles.choiceIcon)}>
- {item.icon}
- </span>
- )}
- <Text
- type="body"
- color={isDisabled ? 'inherit' : undefined}
- xstyle={styles.choiceLabel}>
- {item.label}
- </Text>
- {isMultiple ? (
- <CheckboxIndicator
- state={isSelected ? 'checked' : 'unchecked'}
- size="md"
- isDisabled={isDisabled}
- />
- ) : (
- <RadioIndicator
- state={isSelected ? 'checked' : 'unchecked'}
- size="md"
- isDisabled={isDisabled}
- />
- )}
- </button>
- );
- })}
- </div>
+ value={item.value}
+ label={itemLabel(item)}
+ />
+ ))}
+ </CheckboxList>
+ );
+ }
+ return (
+ <RadioList
+ label={label}
+ isLabelHidden
+ isDisabled={isDisabled}
+ value={selected[0] ?? ''}
+ onChange={props.onChange}>
+ {items.map(item => (
+ <RadioListItem
+ key={item.value}
+ value={item.value}
+ label={itemLabel(item)}
+ />
+ ))}
+ </RadioList>
);
}
@@ -859,14 +736,14 @@ function SheetValueEditor({
}) {
const {buildRelativeDateOptions, PowerSearchValueEditor} = editors;
const t = useComponentTranslator();
- const selectedValues = useMemo<ReadonlySet<string>>(() => {
+ const selectedValues = useMemo<ReadonlyArray<string>>(() => {
if (filterValue?.type === 'enum' || filterValue?.type === 'date_relative') {
- return new Set([filterValue.value]);
+ return [filterValue.value];
}
if (filterValue?.type === 'enum_list') {
- return new Set(filterValue.value);
+ return filterValue.value;
}
- return new Set();
+ return [];
}, [filterValue]);
switch (operatorValue.type) {
@@ -879,9 +756,8 @@ function SheetValueEditor({
items={operatorValue.values}
selected={selectedValues}
isDisabled={isDisabled}
- isMultiple={false}
label={fieldLabel}
- onToggle={value => onChange({type: 'enum', value})}
+ onChange={value => onChange({type: 'enum', value})}
/>
);
case 'enum_list':
@@ -892,16 +768,7 @@ function SheetValueEditor({
isDisabled={isDisabled}
isMultiple
label={fieldLabel}
- onToggle={(value, isSelected) => {
- const existing =
- filterValue?.type === 'enum_list' ? filterValue.value : [];
- onChange({
- type: 'enum_list',
- value: isSelected
- ? existing.filter(v => v !== value)
- : [...existing, value],
- });
- }}
+ onChange={values => onChange({type: 'enum_list', value: values})}
/>
);
case 'date_relative':
@@ -910,9 +777,8 @@ function SheetValueEditor({
items={buildRelativeDateOptions(operatorValue, t)}
selected={selectedValues}
isDisabled={isDisabled}
- isMultiple={false}
label={fieldLabel}
- onToggle={value => onChange({type: 'date_relative', value})}
+ onChange={value => onChange({type: 'date_relative', value})}
/>
);
case 'string':
@@ -2054,10 +1920,7 @@ export function PowerSearchBottomSheet({
styles.scrollContent,
containerPaddingInlineVarStyles[4],
);
- const controlSectionProps = stylex.props(
- styles.controlSection,
- containerPaddingInlineVarStyles[3],
- );
+ const controlSectionProps = stylex.props(styles.controlSection);
// A vertical touch drag on the Add filter rows moves focus off a focused
// search to the sheet, so the software keyboard leaves and the rows can be
@@ -2128,7 +1991,6 @@ export function PowerSearchBottomSheet({
operator: resolveOperatorLabel(operator, t),
})}
value={operator.key}
- xstyle={styles.trailingControlRow}
/>
))}
</RadioList>