mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 21:45:31 +09:00
fix(app): backport rendering improvements (#1580)
This commit is contained in:
1 parent
0c291a01da
commit
42cdc1f877
513 files changed
+98743
-70397
No files matched your search
@@ -0,0 +1,50 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {AutocompleteItem} from '@app/features/channel/components/AutocompleteItem';
|
||||
import {type AutocompleteOption, isCommandChoice} from '@app/features/channel/components/AutocompleteTypes';
|
||||
import type React from 'react';
|
||||
|
||||
interface AutocompleteCommandChoiceProps {
|
||||
onSelect: (option: AutocompleteOption) => void;
|
||||
keyboardFocusIndex: number;
|
||||
hoverIndex: number;
|
||||
options: Array<AutocompleteOption>;
|
||||
onMouseEnter: (index: number) => void;
|
||||
onMouseLeave: () => void;
|
||||
rowRefs?: React.MutableRefObject<Array<HTMLButtonElement | null>>;
|
||||
getOptionId?: (index: number) => string;
|
||||
}
|
||||
|
||||
export function AutocompleteCommandChoice({
|
||||
onSelect,
|
||||
keyboardFocusIndex,
|
||||
hoverIndex,
|
||||
options,
|
||||
onMouseEnter,
|
||||
onMouseLeave,
|
||||
rowRefs,
|
||||
getOptionId,
|
||||
}: AutocompleteCommandChoiceProps): React.ReactNode {
|
||||
const choices = options.filter(isCommandChoice);
|
||||
return choices.map((option, index) => (
|
||||
<AutocompleteItem
|
||||
key={option.choice.value}
|
||||
id={getOptionId ? getOptionId(index) : undefined}
|
||||
name={option.choice.name}
|
||||
description={option.description}
|
||||
isKeyboardSelected={index === keyboardFocusIndex}
|
||||
isHovered={index === hoverIndex}
|
||||
onSelect={() => onSelect(option)}
|
||||
onMouseEnter={() => onMouseEnter(index)}
|
||||
onMouseLeave={onMouseLeave}
|
||||
innerRef={
|
||||
rowRefs
|
||||
? (node: HTMLButtonElement | null) => {
|
||||
rowRefs.current[index] = node;
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
data-flx="channel.autocomplete-command-choice.autocomplete-item.select"
|
||||
/>
|
||||
));
|
||||
}
|
||||
Reference in new issue
Block a user