@brainfish-ai/components 0.15.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import { motion, AnimatePresence } from 'framer-motion';
3
3
  import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from '../components/ui/tooltip.js';
4
4
  import { Button } from '../components/ui/button.js';
5
5
  import { XCircle, Check, Copy, CaretDown, ArrowSquareOut, CaretRight, ArrowsVertical, ArrowDown, Globe, LockSimple, MagnifyingGlass, X, Image, ArrowRight, ArrowLeft, ArrowsInSimple, ArrowsOutSimple } from '@phosphor-icons/react';
6
- import { F as FormattedMessage, c as addPopupWidgetUtm } from './FormattedMessage.aTY_CSO9.js';
6
+ import { F as FormattedMessage, c as addPopupWidgetUtm } from './FormattedMessage.DdZqirSo.js';
7
7
  import { appendErrors, useForm, Controller } from 'react-hook-form';
8
8
  import { validateFieldsNatively, toNestErrors } from '@hookform/resolvers';
9
9
  import require$$0 from 'ajv';
@@ -5372,7 +5372,19 @@ function useAutocomplete({
5372
5372
  conversationId,
5373
5373
  allowedRegions
5374
5374
  });
5375
- setSuggestions(payload?.response?.results);
5375
+ if (payload?.response?.results) {
5376
+ const lowerCaseQuery = debouncedQuery.toLowerCase();
5377
+ const sortedSuggestions = payload.response.results.sort((a, b) => {
5378
+ const aStartsWithQuery = a.question.toLowerCase().startsWith(lowerCaseQuery);
5379
+ const bStartsWithQuery = b.question.toLowerCase().startsWith(lowerCaseQuery);
5380
+ if (aStartsWithQuery && !bStartsWithQuery) return -1;
5381
+ if (!aStartsWithQuery && bStartsWithQuery) return 1;
5382
+ return 0;
5383
+ });
5384
+ setSuggestions(sortedSuggestions);
5385
+ } else {
5386
+ setSuggestions([]);
5387
+ }
5376
5388
  } catch (err) {
5377
5389
  console.error("Error fetching autocomplete suggestions:", err);
5378
5390
  setError(err instanceof Error ? err.message : "Failed to fetch suggestions");
@@ -6132,4 +6144,4 @@ const ChatSearch = forwardRef(({ featureFlags, ...props }, ref) => /* @__PURE__
6132
6144
  ChatSearch.displayName = "ChatSearch";
6133
6145
 
6134
6146
  export { ChatSearch as C, ChatSearchProvider as a, useIsChatSearchDirty as b, useChatSearch as u };
6135
- //# sourceMappingURL=ChatSearch.C9Kg6j_Y.js.map
6147
+ //# sourceMappingURL=ChatSearch.DsnO9IEM.js.map