Apply the auto-fixable lint rules and the formatter, and drop the Vite build artifacts.
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
import React, { KeyboardEventHandler, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import React, {
|
||||
KeyboardEventHandler,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { IconButton } from 'folds';
|
||||
import { Icon, Icons } from '../../components/icons';
|
||||
@@ -28,7 +35,11 @@ type ForumTopicSearchInputProps = {
|
||||
|
||||
type SuggestionMode = 'qualifier' | 'author' | 'title';
|
||||
|
||||
export function ForumTopicSearchInput({ value, onChange, threads = [] }: ForumTopicSearchInputProps) {
|
||||
export function ForumTopicSearchInput({
|
||||
value,
|
||||
onChange,
|
||||
threads = [],
|
||||
}: ForumTopicSearchInputProps) {
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const mirrorRef = useRef<HTMLSpanElement>(null);
|
||||
const pillsRef = useRef<HTMLDivElement>(null);
|
||||
@@ -48,15 +59,14 @@ export function ForumTopicSearchInput({ value, onChange, threads = [] }: ForumTo
|
||||
: TOPIC_SEARCH_QUALIFIERS;
|
||||
|
||||
const authorMatches = useMemo(
|
||||
() =>
|
||||
valueContext?.key === 'from' ? matchAuthorHints(valueContext.partial, authorHints) : [],
|
||||
[authorHints, valueContext]
|
||||
() => (valueContext?.key === 'from' ? matchAuthorHints(valueContext.partial, authorHints) : []),
|
||||
[authorHints, valueContext],
|
||||
);
|
||||
|
||||
const titleMatches = useMemo(
|
||||
() =>
|
||||
valueContext?.key === 'intitle' ? matchTitleHints(valueContext.partial, titleHints) : [],
|
||||
[titleHints, valueContext]
|
||||
[titleHints, valueContext],
|
||||
);
|
||||
|
||||
const suggestionMode: SuggestionMode | null = useMemo(() => {
|
||||
@@ -144,7 +154,7 @@ export function ForumTopicSearchInput({ value, onChange, threads = [] }: ForumTo
|
||||
positionFloatingPills();
|
||||
});
|
||||
},
|
||||
[onChange, positionFloatingPills]
|
||||
[onChange, positionFloatingPills],
|
||||
);
|
||||
|
||||
const insertQualifier = useCallback(
|
||||
@@ -155,7 +165,7 @@ export function ForumTopicSearchInput({ value, onChange, threads = [] }: ForumTo
|
||||
const { value: nextValue, cursor } = insertTopicSearchQualifierAt(value, caretPos, qualifier);
|
||||
applyInputUpdate(nextValue, cursor);
|
||||
},
|
||||
[applyInputUpdate, value]
|
||||
[applyInputUpdate, value],
|
||||
);
|
||||
|
||||
const insertValue = useCallback(
|
||||
@@ -166,7 +176,7 @@ export function ForumTopicSearchInput({ value, onChange, threads = [] }: ForumTo
|
||||
const { value: nextValue, cursor } = insertTopicSearchValueAt(value, caretPos, replacement);
|
||||
applyInputUpdate(nextValue, cursor);
|
||||
},
|
||||
[applyInputUpdate, value]
|
||||
[applyInputUpdate, value],
|
||||
);
|
||||
|
||||
const selectAtIndex = useCallback(
|
||||
@@ -192,7 +202,7 @@ export function ForumTopicSearchInput({ value, onChange, threads = [] }: ForumTo
|
||||
}
|
||||
}
|
||||
},
|
||||
[authorMatches, insertQualifier, insertValue, qualifierMatches, suggestionMode, titleMatches]
|
||||
[authorMatches, insertQualifier, insertValue, qualifierMatches, suggestionMode, titleMatches],
|
||||
);
|
||||
|
||||
const selectHighlighted = useCallback(() => {
|
||||
@@ -204,7 +214,7 @@ export function ForumTopicSearchInput({ value, onChange, threads = [] }: ForumTo
|
||||
if (!suggestionCount) return;
|
||||
setHighlightIndex((idx) => (idx + delta + suggestionCount) % suggestionCount);
|
||||
},
|
||||
[suggestionCount]
|
||||
[suggestionCount],
|
||||
);
|
||||
|
||||
const handleKeyDown: KeyboardEventHandler<HTMLInputElement> = (event) => {
|
||||
@@ -259,8 +269,7 @@ export function ForumTopicSearchInput({ value, onChange, threads = [] }: ForumTo
|
||||
? `title:${valueContext?.partial ?? ''}`
|
||||
: `qualifier:${qualifierPartial}`;
|
||||
|
||||
const nextIndex =
|
||||
tabKey === tabPartial ? (highlightIndex + 1) % suggestionCount : 0;
|
||||
const nextIndex = tabKey === tabPartial ? (highlightIndex + 1) % suggestionCount : 0;
|
||||
setTabPartial(tabKey);
|
||||
setHighlightIndex(nextIndex);
|
||||
selectAtIndex(nextIndex);
|
||||
|
||||
Reference in New Issue
Block a user