diff --git a/packages/react-native-ui/src/SearchResults.stories.tsx b/packages/react-native-ui/src/SearchResults.stories.tsx new file mode 100644 index 0000000000..b7bc3fee82 --- /dev/null +++ b/packages/react-native-ui/src/SearchResults.stories.tsx @@ -0,0 +1,102 @@ +import type { StoryObj, Meta } from '@storybook/react'; +import { SearchResults } from './SearchResults'; + +const meta = { + component: SearchResults, + title: 'UI/SearchResults', +} satisfies Meta; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = { + args: { + query: 'bubble', + closeMenu: () => {}, + highlightedIndex: null, + results: [ + { + item: { + type: 'story', + id: 'nestingexample-message-bubble--first', + name: 'First', + title: 'NestingExample/Message/bubble', + importPath: './components/NestingExample/ChatMessageBubble.stories.tsx', + tags: ['story'], + depth: 3, + parent: 'nestingexample-message-bubble', + prepared: false, + refId: 'storybook_internal', + path: ['NestingExample', 'Message', 'bubble'], + status: null, + }, + refIndex: 46, + matches: [ + { + indices: [[0, 5]], + value: 'bubble', + key: 'path', + refIndex: 2, + }, + ], + score: 0.000020134092876783674, + }, + ], + getItemProps: () => ({ + icon: 'story', + result: { + item: { + type: 'story', + id: 'nestingexample-message-bubble--first', + name: 'First', + title: 'NestingExample/Message/bubble', + importPath: './components/NestingExample/ChatMessageBubble.stories.tsx', + tags: ['story'], + depth: 3, + parent: 'nestingexample-message-bubble', + prepared: false, + refId: 'storybook_internal', + path: ['NestingExample', 'Message', 'bubble'], + status: null, + }, + refIndex: 46, + matches: [ + { + indices: [[0, 5]], + value: 'bubble', + key: 'path', + refIndex: 2, + }, + ], + score: 0.000020134092876783674, + }, + score: 0.000020134092876783674, + refIndex: 46, + item: { + type: 'story', + id: 'nestingexample-message-bubble--first', + name: 'First', + title: 'NestingExample/Message/bubble', + importPath: './components/NestingExample/ChatMessageBubble.stories.tsx', + tags: ['story'], + depth: 3, + parent: 'nestingexample-message-bubble', + prepared: false, + refId: 'storybook_internal', + path: ['NestingExample', 'Message', 'bubble'], + status: null, + }, + matches: [ + { + indices: [[0, 5]], + value: 'bubble', + key: 'path', + refIndex: 2, + }, + ], + isHighlighted: false, + onPress: () => {}, + }), + }, +}; diff --git a/packages/react-native-ui/src/SearchResults.tsx b/packages/react-native-ui/src/SearchResults.tsx index 82eea3ca97..155c6959b0 100644 --- a/packages/react-native-ui/src/SearchResults.tsx +++ b/packages/react-native-ui/src/SearchResults.tsx @@ -159,17 +159,20 @@ const Result: FC = React.memo(function Result({ - {item.path.map((group, index) => ( - - - match.refIndex === index)} - > - {group} - - - - ))} + {item.path.map((group, index) => { + const pathSeparator = index === item.path.length - 1 ? '' : '/'; + return ( + + + match.refIndex === index)} + > + {`${group}${pathSeparator}`} + + + + ); + })} {item.status ? i : null}