mirror of https://github.com/buster-so/buster.git
input suggestsions classes
This commit is contained in:
parent
e2a298bf9e
commit
e6531430f5
|
@ -73,7 +73,7 @@ export const MentionInput = forwardRef<MentionInputRef, MentionInputProps>(
|
||||||
editable: !disabled && !readOnly,
|
editable: !disabled && !readOnly,
|
||||||
editorProps: {
|
editorProps: {
|
||||||
attributes: {
|
attributes: {
|
||||||
class: cn('p-1', classes, className),
|
class: cn(classes, className),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
onUpdate: ({ editor }) => {
|
onUpdate: ({ editor }) => {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { Command } from 'cmdk';
|
import { Command } from 'cmdk';
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { useMemoizedFn } from '@/hooks/useMemoizedFn';
|
import { useMemoizedFn } from '@/hooks/useMemoizedFn';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
import type { MentionInputRef } from '../MentionInput';
|
import type { MentionInputRef } from '../MentionInput';
|
||||||
import type {
|
import type {
|
||||||
MentionInputSuggestionsOnSelectParams,
|
MentionInputSuggestionsOnSelectParams,
|
||||||
|
@ -22,14 +23,15 @@ export const MentionInputSuggestions = ({
|
||||||
onPressEnter,
|
onPressEnter,
|
||||||
disabled: disabledGlobal = false,
|
disabled: disabledGlobal = false,
|
||||||
onStop,
|
onStop,
|
||||||
sendIcon,
|
|
||||||
secondaryActions,
|
|
||||||
variant = 'default',
|
|
||||||
onChange,
|
onChange,
|
||||||
ariaLabel = 'Mention Input Suggestions',
|
ariaLabel = 'Mention Input Suggestions',
|
||||||
readOnly,
|
readOnly,
|
||||||
autoFocus,
|
autoFocus,
|
||||||
children,
|
children,
|
||||||
|
//container
|
||||||
|
className,
|
||||||
|
inputContainerClassName,
|
||||||
|
suggestionsContainerClassName,
|
||||||
//suggestions
|
//suggestions
|
||||||
suggestionItems,
|
suggestionItems,
|
||||||
closeSuggestionOnSelect = true,
|
closeSuggestionOnSelect = true,
|
||||||
|
@ -128,8 +130,13 @@ export const MentionInputSuggestions = ({
|
||||||
}, [showSuggestionList]);
|
}, [showSuggestionList]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Command ref={commandRef} value={value} label={ariaLabel} className="relative">
|
<Command
|
||||||
<MentionInputSuggestionsContainer>
|
ref={commandRef}
|
||||||
|
value={value}
|
||||||
|
label={ariaLabel}
|
||||||
|
className={cn('relative border rounded overflow-hidden bg-background shadow', className)}
|
||||||
|
>
|
||||||
|
<MentionInputSuggestionsContainer className={inputContainerClassName}>
|
||||||
<MentionInputSuggestionsMentionsInput
|
<MentionInputSuggestionsMentionsInput
|
||||||
ref={mentionsInputRef}
|
ref={mentionsInputRef}
|
||||||
defaultValue={defaultValue}
|
defaultValue={defaultValue}
|
||||||
|
@ -147,7 +154,10 @@ export const MentionInputSuggestions = ({
|
||||||
/>
|
/>
|
||||||
{children}
|
{children}
|
||||||
</MentionInputSuggestionsContainer>
|
</MentionInputSuggestionsContainer>
|
||||||
<MentionInputSuggestionsList show={showSuggestionList}>
|
<MentionInputSuggestionsList
|
||||||
|
show={showSuggestionList}
|
||||||
|
className={suggestionsContainerClassName}
|
||||||
|
>
|
||||||
<MentionInputSuggestionsItemsSelector
|
<MentionInputSuggestionsItemsSelector
|
||||||
suggestionItems={suggestionItems}
|
suggestionItems={suggestionItems}
|
||||||
onSelect={onSelectItem}
|
onSelect={onSelectItem}
|
||||||
|
|
|
@ -61,14 +61,11 @@ export type MentionInputSuggestionsProps<T = string> = {
|
||||||
onSubmit: (value: string) => void;
|
onSubmit: (value: string) => void;
|
||||||
onPressEnter: MentionInputProps['onPressEnter'];
|
onPressEnter: MentionInputProps['onPressEnter'];
|
||||||
onStop: () => void;
|
onStop: () => void;
|
||||||
variant?: 'default';
|
|
||||||
autoFocus?: boolean;
|
autoFocus?: boolean;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
ariaLabel?: string;
|
ariaLabel?: string;
|
||||||
emptyComponent?: React.ReactNode | string | false; //if false, no empty component will be shown
|
emptyComponent?: React.ReactNode | string | false; //if false, no empty component will be shown
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
sendIcon?: React.ReactNode;
|
|
||||||
secondaryActions?: React.ReactNode;
|
|
||||||
//mentions
|
//mentions
|
||||||
onMentionItemClick?: (params: MentionTriggerItem<T>) => void;
|
onMentionItemClick?: (params: MentionTriggerItem<T>) => void;
|
||||||
mentions: MentionSuggestionExtension[];
|
mentions: MentionSuggestionExtension[];
|
||||||
|
@ -81,13 +78,13 @@ export type MentionInputSuggestionsProps<T = string> = {
|
||||||
onSuggestionItemClick?: (params: Omit<MentionInputSuggestionsOnSelectParams, 'onClick'>) => void;
|
onSuggestionItemClick?: (params: Omit<MentionInputSuggestionsOnSelectParams, 'onClick'>) => void;
|
||||||
addSuggestionValueToInput?: boolean; //defaults to true
|
addSuggestionValueToInput?: boolean; //defaults to true
|
||||||
closeSuggestionOnSelect?: boolean; //defaults to true
|
closeSuggestionOnSelect?: boolean; //defaults to true
|
||||||
|
className?: string;
|
||||||
|
inputContainerClassName?: string;
|
||||||
|
suggestionsContainerClassName?: string;
|
||||||
} & Pick<React.ComponentProps<typeof Command>, 'filter' | 'shouldFilter'>;
|
} & Pick<React.ComponentProps<typeof Command>, 'filter' | 'shouldFilter'>;
|
||||||
|
|
||||||
export type MentionInputSuggestionsContainerProps = {
|
export type MentionInputSuggestionsContainerProps = {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
className?: string;
|
className?: string;
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
} & Pick<
|
} & Pick<MentionInputSuggestionsProps, 'submitting' | 'disabled' | 'onStop' | 'onSubmit'>;
|
||||||
MentionInputSuggestionsProps,
|
|
||||||
'sendIcon' | 'secondaryActions' | 'submitting' | 'disabled' | 'onStop' | 'onSubmit' | 'variant'
|
|
||||||
>;
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ export const MentionInputSuggestionsContainer: React.FC<
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
data-testid="mention-input-suggestions-container"
|
data-testid="mention-input-suggestions-container"
|
||||||
className={cn('flex flex-col border rounded overflow-hidden', className)}
|
className={cn('flex flex-col overflow-hidden px-5 py-3', className)}
|
||||||
style={style}
|
style={style}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { Command } from 'cmdk';
|
import { Command } from 'cmdk';
|
||||||
import type React from 'react';
|
import type React from 'react';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
interface MentionInputSuggestionsListProps {
|
interface MentionInputSuggestionsListProps {
|
||||||
className?: string;
|
className?: string;
|
||||||
|
@ -16,7 +17,7 @@ export const MentionInputSuggestionsList = ({
|
||||||
}: MentionInputSuggestionsListProps) => {
|
}: MentionInputSuggestionsListProps) => {
|
||||||
if (!show) return null;
|
if (!show) return null;
|
||||||
return (
|
return (
|
||||||
<Command.List className={className} style={style}>
|
<Command.List className={cn('border-t px-3 py-1.5', className)} style={style}>
|
||||||
{children}
|
{children}
|
||||||
</Command.List>
|
</Command.List>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue