mirror of https://github.com/buster-so/buster.git
add shadow and z index to list
This commit is contained in:
parent
f2490ecccd
commit
5f4f3dcde9
|
@ -2,6 +2,7 @@ import type { ListShortcutsResponse } from '@buster/server-shared/shortcuts';
|
||||||
import type { GetSuggestedPromptsResponse } from '@buster/server-shared/user';
|
import type { GetSuggestedPromptsResponse } from '@buster/server-shared/user';
|
||||||
import sampleSize from 'lodash/sampleSize';
|
import sampleSize from 'lodash/sampleSize';
|
||||||
import React, { useMemo, useRef, useState } from 'react';
|
import React, { useMemo, useRef, useState } from 'react';
|
||||||
|
import { createShortcutsMentionsSuggestions } from '@/components/features/input/Mentions/ShortcutsSuggestions/ShortcutsSuggestions';
|
||||||
import { Plus } from '@/components/ui/icons';
|
import { Plus } from '@/components/ui/icons';
|
||||||
import type { MentionSuggestionExtension } from '@/components/ui/inputs/MentionInput';
|
import type { MentionSuggestionExtension } from '@/components/ui/inputs/MentionInput';
|
||||||
import type {
|
import type {
|
||||||
|
@ -48,7 +49,7 @@ export const BusterChatInputBase: React.FC<BusterChatInput> = React.memo(
|
||||||
}, [uniqueSuggestions, shortcutsSuggestions]);
|
}, [uniqueSuggestions, shortcutsSuggestions]);
|
||||||
|
|
||||||
const mentions: MentionSuggestionExtension[] = useMemo(() => {
|
const mentions: MentionSuggestionExtension[] = useMemo(() => {
|
||||||
return [];
|
return [createShortcutsMentionsSuggestions(shortcuts)];
|
||||||
}, [shortcuts]);
|
}, [shortcuts]);
|
||||||
|
|
||||||
const onDictate = useMemoizedFn((transcript: string) => {
|
const onDictate = useMemoizedFn((transcript: string) => {
|
||||||
|
@ -153,6 +154,7 @@ const useShortcuts = (
|
||||||
value: shortcut.name,
|
value: shortcut.name,
|
||||||
label: shortcut.name,
|
label: shortcut.name,
|
||||||
icon: '/',
|
icon: '/',
|
||||||
|
inputValue: `/ ${shortcut.name}`,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -161,6 +163,7 @@ const useShortcuts = (
|
||||||
value: 'createShortcut',
|
value: 'createShortcut',
|
||||||
label: 'Create shortcut',
|
label: 'Create shortcut',
|
||||||
icon: <Plus />,
|
icon: <Plus />,
|
||||||
|
inputValue: '/ Create shortcut',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
console.log('createShortcut');
|
console.log('createShortcut');
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,21 +10,21 @@ import {
|
||||||
} from '@/components/ui/inputs/MentionInput';
|
} from '@/components/ui/inputs/MentionInput';
|
||||||
import { ShortcutPopoverContent } from './ShortcutPopoverContent';
|
import { ShortcutPopoverContent } from './ShortcutPopoverContent';
|
||||||
|
|
||||||
export const createShortcutsSuggestions = (shortcutsResponse: ListShortcutsResponse) => {
|
export const createShortcutsMentionsSuggestions = (
|
||||||
return useMemo(
|
shortcuts: ListShortcutsResponse['shortcuts']
|
||||||
() =>
|
) => {
|
||||||
createMentionSuggestionExtension({
|
return createMentionSuggestionExtension({
|
||||||
trigger: '/',
|
trigger: '/',
|
||||||
items: createAllItems(shortcutsResponse),
|
items: createAllItems(shortcuts),
|
||||||
popoverContent: ShortcutPopoverContent,
|
popoverContent: ShortcutPopoverContent,
|
||||||
}),
|
});
|
||||||
[shortcutsResponse]
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const createAllItems = (shortcutsResponse: ListShortcutsResponse): MentionInputTriggerItem[] => {
|
const createAllItems = (
|
||||||
|
shortcuts: ListShortcutsResponse['shortcuts']
|
||||||
|
): MentionInputTriggerItem[] => {
|
||||||
return [
|
return [
|
||||||
...shortcutsResponse.shortcuts.map(createShortcut),
|
...shortcuts.map(createShortcut),
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{
|
{
|
||||||
value: 'manageShortcuts',
|
value: 'manageShortcuts',
|
||||||
|
|
|
@ -73,8 +73,8 @@ export const MentionInput = forwardRef<MentionInputRef, MentionInputProps>(
|
||||||
Placeholder.configure({ placeholder }),
|
Placeholder.configure({ placeholder }),
|
||||||
MentionExtension(mentions),
|
MentionExtension(mentions),
|
||||||
SubmitOnEnter({
|
SubmitOnEnter({
|
||||||
mentionsByTrigger,
|
|
||||||
onPressEnter,
|
onPressEnter,
|
||||||
|
mentionsByTrigger,
|
||||||
commandListNavigatedRef,
|
commandListNavigatedRef,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
|
@ -57,6 +57,8 @@ export const createMentionSuggestionExtension = ({
|
||||||
element.style.left = `${rect.left}px`;
|
element.style.left = `${rect.left}px`;
|
||||||
element.style.top = `${rect.top}px`;
|
element.style.top = `${rect.top}px`;
|
||||||
element.style.transform = `translateY(1.15lh)`;
|
element.style.transform = `translateY(1.15lh)`;
|
||||||
|
element.classList.add('z-50');
|
||||||
|
element.classList.add('shadow');
|
||||||
|
|
||||||
document.body.appendChild(component.element);
|
document.body.appendChild(component.element);
|
||||||
},
|
},
|
||||||
|
|
|
@ -156,7 +156,6 @@ export const MentionInputSuggestions = forwardRef<
|
||||||
return (
|
return (
|
||||||
<Command
|
<Command
|
||||||
ref={commandRef}
|
ref={commandRef}
|
||||||
value={value}
|
|
||||||
label={ariaLabel}
|
label={ariaLabel}
|
||||||
className={cn('relative border rounded overflow-hidden bg-background shadow', className)}
|
className={cn('relative border rounded overflow-hidden bg-background shadow', className)}
|
||||||
shouldFilter={shouldFilter}
|
shouldFilter={shouldFilter}
|
||||||
|
|
Loading…
Reference in New Issue