@foundrykit/components 2.2.0 → 2.2.3
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.
- package/dist/chunk-4WYKNDYY.js +91 -0
- package/dist/chunk-4WYKNDYY.js.map +1 -0
- package/dist/chunk-5CXNMTIN.js +84 -0
- package/dist/chunk-5CXNMTIN.js.map +1 -0
- package/dist/chunk-B5ZTF5MZ.js +203 -0
- package/dist/chunk-B5ZTF5MZ.js.map +1 -0
- package/dist/chunk-EDNWBEKV.js +51 -0
- package/dist/chunk-EDNWBEKV.js.map +1 -0
- package/dist/chunk-ID7BFTID.js +248 -0
- package/dist/chunk-ID7BFTID.js.map +1 -0
- package/dist/chunk-IYBHXVCH.js +181 -0
- package/dist/chunk-IYBHXVCH.js.map +1 -0
- package/dist/chunk-KQZEF7PS.js +71 -0
- package/dist/chunk-KQZEF7PS.js.map +1 -0
- package/dist/chunk-P3GSYR7O.js +889 -0
- package/dist/chunk-P3GSYR7O.js.map +1 -0
- package/dist/chunk-PKSRYDN4.js +168 -0
- package/dist/chunk-PKSRYDN4.js.map +1 -0
- package/dist/chunk-SFM7ZMG2.js +104 -0
- package/dist/chunk-SFM7ZMG2.js.map +1 -0
- package/dist/chunk-TLQQZJUR.js +126 -0
- package/dist/chunk-TLQQZJUR.js.map +1 -0
- package/dist/chunk-UE7CDYEN.js +59 -0
- package/dist/chunk-UE7CDYEN.js.map +1 -0
- package/dist/chunk-UG7YS3D5.js +198 -0
- package/dist/chunk-UG7YS3D5.js.map +1 -0
- package/dist/components/advanced-search-bar/index.d.ts +308 -0
- package/dist/components/advanced-search-bar/index.js +34 -0
- package/dist/components/advanced-search-bar/index.js.map +1 -0
- package/dist/components/calendar/index.d.ts +20 -0
- package/dist/components/calendar/index.js +11 -0
- package/dist/components/calendar/index.js.map +1 -0
- package/dist/components/carousel/index.d.ts +40 -0
- package/dist/components/carousel/index.js +17 -0
- package/dist/components/carousel/index.js.map +1 -0
- package/dist/components/chart/index.d.ts +59 -0
- package/dist/components/chart/index.js +21 -0
- package/dist/components/chart/index.js.map +1 -0
- package/dist/components/combobox/index.d.ts +33 -0
- package/dist/components/combobox/index.js +10 -0
- package/dist/components/combobox/index.js.map +1 -0
- package/dist/components/command/index.d.ts +33 -0
- package/dist/components/command/index.js +25 -0
- package/dist/components/command/index.js.map +1 -0
- package/dist/components/data-table/index.d.ts +17 -0
- package/dist/components/data-table/index.js +9 -0
- package/dist/components/data-table/index.js.map +1 -0
- package/dist/components/date-picker/index.d.ts +17 -0
- package/dist/components/date-picker/index.js +9 -0
- package/dist/components/date-picker/index.js.map +1 -0
- package/dist/components/form/index.d.ts +37 -0
- package/dist/components/form/index.js +23 -0
- package/dist/components/form/index.js.map +1 -0
- package/dist/components/input-otp/index.d.ts +30 -0
- package/dist/components/input-otp/index.js +15 -0
- package/dist/components/input-otp/index.js.map +1 -0
- package/dist/components/pagination/index.d.ts +26 -0
- package/dist/components/pagination/index.js +20 -0
- package/dist/components/pagination/index.js.map +1 -0
- package/dist/components/search-bar/index.d.ts +17 -0
- package/dist/components/search-bar/index.js +9 -0
- package/dist/components/search-bar/index.js.map +1 -0
- package/dist/components/sidebar/index.d.ts +70 -0
- package/dist/components/sidebar/index.js +652 -0
- package/dist/components/sidebar/index.js.map +1 -0
- package/dist/components/theme-toggle/index.d.ts +20 -0
- package/dist/components/theme-toggle/index.js +9 -0
- package/dist/components/theme-toggle/index.js.map +1 -0
- package/dist/index.d.ts +27 -605
- package/dist/index.js +73 -2337
- package/dist/index.js.map +1 -1
- package/package.json +17 -10
- package/CHANGELOG.md +0 -362
- package/src/components/advanced-search-bar/config.ts +0 -223
- package/src/components/advanced-search-bar/index.tsx +0 -1415
- package/src/components/calendar/config.ts +0 -51
- package/src/components/calendar/index.tsx +0 -225
- package/src/components/carousel/config.ts +0 -28
- package/src/components/carousel/index.tsx +0 -258
- package/src/components/chart/config.ts +0 -28
- package/src/components/chart/index.tsx +0 -365
- package/src/components/combobox/config.ts +0 -28
- package/src/components/combobox/index.tsx +0 -111
- package/src/components/command/config.ts +0 -804
- package/src/components/command/index.tsx +0 -195
- package/src/components/data-table/config.ts +0 -28
- package/src/components/data-table/index.tsx +0 -124
- package/src/components/date-picker/config.ts +0 -55
- package/src/components/date-picker/index.tsx +0 -207
- package/src/components/form/config.ts +0 -21
- package/src/components/form/index.tsx +0 -150
- package/src/components/input-otp/config.ts +0 -28
- package/src/components/input-otp/index.tsx +0 -92
- package/src/components/pagination/config.ts +0 -367
- package/src/components/pagination/index.tsx +0 -135
- package/src/components/search-bar/config.ts +0 -58
- package/src/components/search-bar/index.tsx +0 -70
- package/src/components/sidebar/config.ts +0 -29
- package/src/components/sidebar/index.tsx +0 -723
- package/src/components/theme-toggle/config.ts +0 -27
- package/src/components/theme-toggle/index.tsx +0 -63
- package/src/index.ts +0 -83
- package/tsconfig.json +0 -12
- package/tsconfig.lint.json +0 -8
- package/tsup.config.ts +0 -11
|
@@ -1,1415 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
type EmptyStateBehavior,
|
|
5
|
-
SearchContext,
|
|
6
|
-
useAdvancedSearch,
|
|
7
|
-
} from '@foundrykit/hooks';
|
|
8
|
-
import {
|
|
9
|
-
Badge,
|
|
10
|
-
Button,
|
|
11
|
-
Input,
|
|
12
|
-
ScrollArea,
|
|
13
|
-
Separator,
|
|
14
|
-
} from '@foundrykit/primitives';
|
|
15
|
-
// Re-export types from hooks package
|
|
16
|
-
import type {
|
|
17
|
-
SearchResult,
|
|
18
|
-
SearchSection as SearchSectionType,
|
|
19
|
-
} from '@foundrykit/types';
|
|
20
|
-
import { cn } from '@foundrykit/utils';
|
|
21
|
-
import { Slot } from '@radix-ui/react-slot';
|
|
22
|
-
import { cva, type VariantProps } from 'class-variance-authority';
|
|
23
|
-
import { ChevronDown, Search, X } from 'lucide-react';
|
|
24
|
-
import * as React from 'react';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Props for the AdvancedSearchProvider component.
|
|
28
|
-
* This provider manages the search state and behaviour for all child components.
|
|
29
|
-
*/
|
|
30
|
-
export interface AdvancedSearchProviderProps {
|
|
31
|
-
/** Child components that will have access to the search context */
|
|
32
|
-
children: React.ReactNode;
|
|
33
|
-
/**
|
|
34
|
-
* Function called when user types in the search input.
|
|
35
|
-
* Should return a Promise or array of SearchResult objects.
|
|
36
|
-
* @param query - The search query string
|
|
37
|
-
* @returns Promise<SearchResult[]> | SearchResult[] - Array of search results
|
|
38
|
-
*/
|
|
39
|
-
onSearch?: (query: string) => Promise<SearchResult[]> | SearchResult[];
|
|
40
|
-
/**
|
|
41
|
-
* Function called when user selects a result from the dropdown.
|
|
42
|
-
* @param result - The selected SearchResult object
|
|
43
|
-
*/
|
|
44
|
-
onResultSelect?: (result: SearchResult) => void;
|
|
45
|
-
/**
|
|
46
|
-
* Debounce delay in milliseconds for search requests.
|
|
47
|
-
* @default 300
|
|
48
|
-
*/
|
|
49
|
-
debounceMs?: number;
|
|
50
|
-
/**
|
|
51
|
-
* Minimum number of characters required before triggering search.
|
|
52
|
-
* @default 1
|
|
53
|
-
*/
|
|
54
|
-
minQueryLength?: number;
|
|
55
|
-
/**
|
|
56
|
-
* Behavior when search results are empty or query is too short.
|
|
57
|
-
* - 'show-empty-message': Show "No results found" message
|
|
58
|
-
* - 'hide-until-min-chars': Hide results until minimum characters typed
|
|
59
|
-
* - 'show-all-results': Show initial results when empty
|
|
60
|
-
* @default 'show-empty-message'
|
|
61
|
-
*/
|
|
62
|
-
emptyStateBehaviour?: EmptyStateBehavior;
|
|
63
|
-
/**
|
|
64
|
-
* Initial results to show when component first loads.
|
|
65
|
-
* Useful for showing popular/recent searches.
|
|
66
|
-
*/
|
|
67
|
-
initialResults?: SearchResult[];
|
|
68
|
-
/**
|
|
69
|
-
* Custom styles for different parts of the search component.
|
|
70
|
-
*/
|
|
71
|
-
styles?: {
|
|
72
|
-
/** CSS properties for the results dropdown */
|
|
73
|
-
results?: React.CSSProperties;
|
|
74
|
-
width?: string | number;
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* AdvancedSearchProvider component that manages search state and provides context to child components.
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```tsx
|
|
83
|
-
* <AdvancedSearchProvider
|
|
84
|
-
* onSearch={async (query) => {
|
|
85
|
-
* const results = await searchAPI(query);
|
|
86
|
-
* return results;
|
|
87
|
-
* }}
|
|
88
|
-
* onResultSelect={(result) => {
|
|
89
|
-
* console.log('Selected:', result);
|
|
90
|
-
* }}
|
|
91
|
-
* emptyStateBehaviour="show-all-results"
|
|
92
|
-
* initialResults={popularDestinations}
|
|
93
|
-
* >
|
|
94
|
-
* <AdvancedSearchBar>
|
|
95
|
-
* <SearchInput placeholder="Search destinations..." />
|
|
96
|
-
* <SearchResults />
|
|
97
|
-
* </AdvancedSearchBar>
|
|
98
|
-
* </AdvancedSearchProvider>
|
|
99
|
-
* ```
|
|
100
|
-
*/
|
|
101
|
-
export function AdvancedSearchProvider({
|
|
102
|
-
children,
|
|
103
|
-
onSearch,
|
|
104
|
-
onResultSelect,
|
|
105
|
-
debounceMs = 300,
|
|
106
|
-
minQueryLength = 1,
|
|
107
|
-
emptyStateBehaviour = 'show-empty-message',
|
|
108
|
-
initialResults = [],
|
|
109
|
-
styles = {
|
|
110
|
-
results: {
|
|
111
|
-
maxHeight: '24rem',
|
|
112
|
-
},
|
|
113
|
-
width: '100%',
|
|
114
|
-
},
|
|
115
|
-
}: AdvancedSearchProviderProps) {
|
|
116
|
-
const inputId = React.useId();
|
|
117
|
-
const resultsId = React.useId();
|
|
118
|
-
const [query, setQuery] = React.useState('');
|
|
119
|
-
const [isOpen, setIsOpen] = React.useState(false);
|
|
120
|
-
const [results, setResults] = React.useState<SearchResult[]>(initialResults);
|
|
121
|
-
const [isLoading, setIsLoading] = React.useState(false);
|
|
122
|
-
const [activeIndex, setActiveIndex] = React.useState(-1);
|
|
123
|
-
const timeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
124
|
-
const requestIdRef = React.useRef(0);
|
|
125
|
-
|
|
126
|
-
React.useEffect(() => {
|
|
127
|
-
return () => {
|
|
128
|
-
if (timeoutRef.current) {
|
|
129
|
-
clearTimeout(timeoutRef.current);
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
}, []);
|
|
133
|
-
|
|
134
|
-
const handleSearch = React.useCallback(
|
|
135
|
-
(searchQuery: string) => {
|
|
136
|
-
if (timeoutRef.current) {
|
|
137
|
-
clearTimeout(timeoutRef.current);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
setActiveIndex(-1);
|
|
141
|
-
|
|
142
|
-
const trimmedQuery = searchQuery.trim();
|
|
143
|
-
const isEmptyQuery = trimmedQuery.length === 0;
|
|
144
|
-
const isTooShort = trimmedQuery.length < minQueryLength;
|
|
145
|
-
|
|
146
|
-
if (isEmptyQuery || isTooShort || !onSearch) {
|
|
147
|
-
requestIdRef.current += 1;
|
|
148
|
-
setIsLoading(false);
|
|
149
|
-
setResults(
|
|
150
|
-
emptyStateBehaviour === 'show-all-results' &&
|
|
151
|
-
(isEmptyQuery || isTooShort)
|
|
152
|
-
? initialResults
|
|
153
|
-
: []
|
|
154
|
-
);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const requestId = requestIdRef.current + 1;
|
|
159
|
-
requestIdRef.current = requestId;
|
|
160
|
-
|
|
161
|
-
timeoutRef.current = setTimeout(async () => {
|
|
162
|
-
setIsLoading(true);
|
|
163
|
-
try {
|
|
164
|
-
const searchResults = await onSearch(trimmedQuery);
|
|
165
|
-
if (requestIdRef.current === requestId) {
|
|
166
|
-
setResults(searchResults);
|
|
167
|
-
}
|
|
168
|
-
} catch (error) {
|
|
169
|
-
if (requestIdRef.current === requestId) {
|
|
170
|
-
console.error('Search error:', error);
|
|
171
|
-
setResults([]);
|
|
172
|
-
}
|
|
173
|
-
} finally {
|
|
174
|
-
if (requestIdRef.current === requestId) {
|
|
175
|
-
setIsLoading(false);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}, debounceMs);
|
|
179
|
-
},
|
|
180
|
-
[debounceMs, emptyStateBehaviour, initialResults, minQueryLength, onSearch]
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
const handleResultSelect = React.useCallback(
|
|
184
|
-
(result: SearchResult) => {
|
|
185
|
-
onResultSelect?.(result);
|
|
186
|
-
setQuery(result.title);
|
|
187
|
-
setActiveIndex(-1);
|
|
188
|
-
setIsOpen(false);
|
|
189
|
-
},
|
|
190
|
-
[onResultSelect]
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
const value = React.useMemo(
|
|
194
|
-
() => ({
|
|
195
|
-
query,
|
|
196
|
-
setQuery,
|
|
197
|
-
isOpen,
|
|
198
|
-
setIsOpen,
|
|
199
|
-
inputId,
|
|
200
|
-
resultsId,
|
|
201
|
-
activeIndex,
|
|
202
|
-
setActiveIndex,
|
|
203
|
-
results,
|
|
204
|
-
setResults,
|
|
205
|
-
isLoading,
|
|
206
|
-
setIsLoading,
|
|
207
|
-
onSearch: handleSearch,
|
|
208
|
-
onResultSelect: handleResultSelect,
|
|
209
|
-
emptyStateBehaviour,
|
|
210
|
-
minQueryLength,
|
|
211
|
-
}),
|
|
212
|
-
[
|
|
213
|
-
query,
|
|
214
|
-
isOpen,
|
|
215
|
-
inputId,
|
|
216
|
-
resultsId,
|
|
217
|
-
activeIndex,
|
|
218
|
-
results,
|
|
219
|
-
isLoading,
|
|
220
|
-
handleSearch,
|
|
221
|
-
handleResultSelect,
|
|
222
|
-
emptyStateBehaviour,
|
|
223
|
-
minQueryLength,
|
|
224
|
-
]
|
|
225
|
-
);
|
|
226
|
-
|
|
227
|
-
return (
|
|
228
|
-
<SearchContext.Provider value={value}>
|
|
229
|
-
<div
|
|
230
|
-
style={
|
|
231
|
-
{
|
|
232
|
-
'--results-max-height': styles.results?.maxHeight ?? '24rem',
|
|
233
|
-
width: styles.width,
|
|
234
|
-
} as React.CSSProperties
|
|
235
|
-
}
|
|
236
|
-
>
|
|
237
|
-
{children}
|
|
238
|
-
</div>
|
|
239
|
-
</SearchContext.Provider>
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Variant styles for the search input wrapper.
|
|
245
|
-
* Controls the size and visual appearance of the search input container.
|
|
246
|
-
*/
|
|
247
|
-
const searchInputWrapperVariants = cva('relative flex w-full items-center', {
|
|
248
|
-
variants: {
|
|
249
|
-
size: {
|
|
250
|
-
sm: 'h-8',
|
|
251
|
-
md: 'h-10',
|
|
252
|
-
lg: 'h-12',
|
|
253
|
-
xl: 'h-14',
|
|
254
|
-
},
|
|
255
|
-
variant: {
|
|
256
|
-
default: 'border-input bg-background border',
|
|
257
|
-
ghost: 'bg-transparent',
|
|
258
|
-
filled: 'bg-muted',
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
defaultVariants: {
|
|
262
|
-
size: 'md',
|
|
263
|
-
variant: 'default',
|
|
264
|
-
},
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Variant styles for the search results container.
|
|
269
|
-
* Controls the maximum width of the search results dropdown.
|
|
270
|
-
*/
|
|
271
|
-
const searchResultsVariants = cva('w-full', {
|
|
272
|
-
variants: {
|
|
273
|
-
size: {
|
|
274
|
-
sm: 'max-w-sm',
|
|
275
|
-
md: 'max-w-md',
|
|
276
|
-
lg: 'max-w-lg',
|
|
277
|
-
xl: 'max-w-xl',
|
|
278
|
-
'2xl': 'max-w-2xl',
|
|
279
|
-
full: 'max-w-full',
|
|
280
|
-
},
|
|
281
|
-
},
|
|
282
|
-
defaultVariants: {
|
|
283
|
-
size: 'lg',
|
|
284
|
-
},
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Props for the SearchInput component.
|
|
289
|
-
* Extends standard input props with search-specific functionality.
|
|
290
|
-
*/
|
|
291
|
-
export interface SearchInputProps
|
|
292
|
-
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'>,
|
|
293
|
-
VariantProps<typeof searchInputWrapperVariants> {
|
|
294
|
-
/** Placeholder text shown when input is empty */
|
|
295
|
-
placeholder?: string;
|
|
296
|
-
/** Whether to show the search icon on the left side */
|
|
297
|
-
showSearchIcon?: boolean;
|
|
298
|
-
/** Whether to show the clear button when there's text */
|
|
299
|
-
showClearButton?: boolean;
|
|
300
|
-
/** Callback function called when clear button is clicked */
|
|
301
|
-
onClear?: () => void;
|
|
302
|
-
/** Whether to render as a child component using Slot */
|
|
303
|
-
asChild?: boolean;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* SearchInput component that provides a search input field with optional search icon and clear button.
|
|
308
|
-
* Automatically integrates with the search context to handle query state and search triggering.
|
|
309
|
-
*
|
|
310
|
-
* @example
|
|
311
|
-
* ```tsx
|
|
312
|
-
* <SearchInput
|
|
313
|
-
* placeholder="Search destinations..."
|
|
314
|
-
* size="lg"
|
|
315
|
-
* variant="default"
|
|
316
|
-
* showSearchIcon={true}
|
|
317
|
-
* showClearButton={true}
|
|
318
|
-
* />
|
|
319
|
-
* ```
|
|
320
|
-
*/
|
|
321
|
-
export const SearchInput = React.forwardRef<HTMLInputElement, SearchInputProps>(
|
|
322
|
-
(
|
|
323
|
-
{
|
|
324
|
-
className,
|
|
325
|
-
size,
|
|
326
|
-
variant,
|
|
327
|
-
placeholder = 'Search...',
|
|
328
|
-
showSearchIcon = true,
|
|
329
|
-
showClearButton = true,
|
|
330
|
-
onClear,
|
|
331
|
-
asChild = false,
|
|
332
|
-
...props
|
|
333
|
-
},
|
|
334
|
-
ref
|
|
335
|
-
) => {
|
|
336
|
-
const {
|
|
337
|
-
query,
|
|
338
|
-
setQuery,
|
|
339
|
-
onSearch,
|
|
340
|
-
onResultSelect,
|
|
341
|
-
results,
|
|
342
|
-
isOpen,
|
|
343
|
-
setIsOpen,
|
|
344
|
-
inputId,
|
|
345
|
-
resultsId,
|
|
346
|
-
activeIndex,
|
|
347
|
-
setActiveIndex,
|
|
348
|
-
emptyStateBehaviour,
|
|
349
|
-
minQueryLength,
|
|
350
|
-
} = useAdvancedSearch();
|
|
351
|
-
const Comp = asChild ? Slot : 'div';
|
|
352
|
-
|
|
353
|
-
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
354
|
-
const value = e.target.value;
|
|
355
|
-
setQuery(value);
|
|
356
|
-
|
|
357
|
-
// Handle popover opening based on empty state behaviour
|
|
358
|
-
if (emptyStateBehaviour === 'hide-until-min-chars') {
|
|
359
|
-
setIsOpen(value.length >= minQueryLength);
|
|
360
|
-
} else {
|
|
361
|
-
setIsOpen(true); // Open popover when typing for other behaviours
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// Call onSearch after a small delay to avoid blocking input
|
|
365
|
-
setTimeout(() => {
|
|
366
|
-
onSearch(value);
|
|
367
|
-
}, 0);
|
|
368
|
-
|
|
369
|
-
props.onChange?.(e);
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
373
|
-
// Handle popover opening based on empty state behaviour
|
|
374
|
-
if (emptyStateBehaviour === 'hide-until-min-chars') {
|
|
375
|
-
setIsOpen(query.length >= minQueryLength);
|
|
376
|
-
} else {
|
|
377
|
-
setIsOpen(true); // Open popover when focused for other behaviours
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
props.onFocus?.(e);
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
const handleClear = () => {
|
|
384
|
-
setQuery('');
|
|
385
|
-
setActiveIndex(-1);
|
|
386
|
-
setTimeout(() => {
|
|
387
|
-
onSearch('');
|
|
388
|
-
}, 0);
|
|
389
|
-
onClear?.();
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
393
|
-
props.onKeyDown?.(e);
|
|
394
|
-
if (e.defaultPrevented) return;
|
|
395
|
-
|
|
396
|
-
if (e.key === 'Escape') {
|
|
397
|
-
setIsOpen(false);
|
|
398
|
-
setActiveIndex(-1);
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
if (e.key === 'ArrowDown') {
|
|
403
|
-
e.preventDefault();
|
|
404
|
-
setIsOpen(true);
|
|
405
|
-
setActiveIndex(
|
|
406
|
-
results.length ? (activeIndex + 1) % results.length : -1
|
|
407
|
-
);
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
if (e.key === 'ArrowUp') {
|
|
412
|
-
e.preventDefault();
|
|
413
|
-
setIsOpen(true);
|
|
414
|
-
setActiveIndex(
|
|
415
|
-
results.length
|
|
416
|
-
? activeIndex <= 0
|
|
417
|
-
? results.length - 1
|
|
418
|
-
: activeIndex - 1
|
|
419
|
-
: -1
|
|
420
|
-
);
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
if (e.key === 'Home') {
|
|
425
|
-
if (!results.length) return;
|
|
426
|
-
e.preventDefault();
|
|
427
|
-
setActiveIndex(0);
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
if (e.key === 'End') {
|
|
432
|
-
if (!results.length) return;
|
|
433
|
-
e.preventDefault();
|
|
434
|
-
setActiveIndex(results.length - 1);
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
if (e.key === 'Enter' && activeIndex >= 0 && results[activeIndex]) {
|
|
439
|
-
e.preventDefault();
|
|
440
|
-
onResultSelect(results[activeIndex]);
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
|
|
444
|
-
return (
|
|
445
|
-
<Comp
|
|
446
|
-
className={cn(
|
|
447
|
-
searchInputWrapperVariants({ size, variant }),
|
|
448
|
-
'rounded-md',
|
|
449
|
-
className
|
|
450
|
-
)}
|
|
451
|
-
onClick={e => {
|
|
452
|
-
// Ensure the input gets focus when the wrapper is clicked
|
|
453
|
-
if (e.target !== e.currentTarget) return;
|
|
454
|
-
const input = e.currentTarget.querySelector('input');
|
|
455
|
-
input?.focus();
|
|
456
|
-
}}
|
|
457
|
-
>
|
|
458
|
-
{showSearchIcon && (
|
|
459
|
-
<Search className='text-muted-foreground absolute left-3 h-4 w-4' />
|
|
460
|
-
)}
|
|
461
|
-
<Input
|
|
462
|
-
ref={ref}
|
|
463
|
-
{...props}
|
|
464
|
-
id={inputId}
|
|
465
|
-
type='search'
|
|
466
|
-
role='combobox'
|
|
467
|
-
aria-label='Search'
|
|
468
|
-
aria-autocomplete='list'
|
|
469
|
-
aria-expanded={isOpen}
|
|
470
|
-
aria-controls={resultsId}
|
|
471
|
-
aria-activedescendant={
|
|
472
|
-
activeIndex >= 0 && results[activeIndex]
|
|
473
|
-
? `${resultsId}-option-${results[activeIndex].id}`
|
|
474
|
-
: undefined
|
|
475
|
-
}
|
|
476
|
-
placeholder={placeholder}
|
|
477
|
-
value={query}
|
|
478
|
-
onChange={handleChange}
|
|
479
|
-
onFocus={handleFocus}
|
|
480
|
-
onKeyDown={handleKeyDown}
|
|
481
|
-
className={cn(
|
|
482
|
-
'border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0',
|
|
483
|
-
showSearchIcon && 'pl-10',
|
|
484
|
-
showClearButton && query && 'pr-10'
|
|
485
|
-
)}
|
|
486
|
-
size={undefined}
|
|
487
|
-
/>
|
|
488
|
-
{showClearButton && query && (
|
|
489
|
-
<Button
|
|
490
|
-
type='button'
|
|
491
|
-
variant='ghost'
|
|
492
|
-
size='sm'
|
|
493
|
-
aria-label='Clear search'
|
|
494
|
-
className='absolute right-1 h-6 w-6 p-0'
|
|
495
|
-
onClick={handleClear}
|
|
496
|
-
>
|
|
497
|
-
<X className='h-3 w-3' />
|
|
498
|
-
</Button>
|
|
499
|
-
)}
|
|
500
|
-
</Comp>
|
|
501
|
-
);
|
|
502
|
-
}
|
|
503
|
-
);
|
|
504
|
-
SearchInput.displayName = 'SearchInput';
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Props for the SearchTrigger component.
|
|
508
|
-
* Used to create custom trigger buttons that open the search dropdown.
|
|
509
|
-
*/
|
|
510
|
-
export interface SearchTriggerProps
|
|
511
|
-
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
512
|
-
/** Whether to render as a child component using Slot */
|
|
513
|
-
asChild?: boolean;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* SearchTrigger component that creates a button to open/close the search dropdown.
|
|
518
|
-
* Can be used with asChild to wrap custom button components.
|
|
519
|
-
*
|
|
520
|
-
* @example
|
|
521
|
-
* ```tsx
|
|
522
|
-
* <SearchTrigger asChild>
|
|
523
|
-
* <Button variant="outline" className="w-full justify-start">
|
|
524
|
-
* <Search className="mr-2 h-4 w-4" />
|
|
525
|
-
* Click to search...
|
|
526
|
-
* </Button>
|
|
527
|
-
* </SearchTrigger>
|
|
528
|
-
* ```
|
|
529
|
-
*/
|
|
530
|
-
export const SearchTrigger = React.forwardRef<
|
|
531
|
-
HTMLButtonElement,
|
|
532
|
-
SearchTriggerProps
|
|
533
|
-
>(({ className, asChild = false, children, onClick, ...props }, ref) => {
|
|
534
|
-
const { isOpen, setIsOpen, resultsId } = useAdvancedSearch();
|
|
535
|
-
const Comp = asChild ? Slot : Button;
|
|
536
|
-
|
|
537
|
-
return (
|
|
538
|
-
<Comp
|
|
539
|
-
ref={ref}
|
|
540
|
-
{...props}
|
|
541
|
-
type='button'
|
|
542
|
-
aria-expanded={isOpen}
|
|
543
|
-
aria-controls={resultsId}
|
|
544
|
-
className={cn(className)}
|
|
545
|
-
onClick={event => {
|
|
546
|
-
onClick?.(event);
|
|
547
|
-
if (!event.defaultPrevented) {
|
|
548
|
-
setIsOpen(!isOpen);
|
|
549
|
-
}
|
|
550
|
-
}}
|
|
551
|
-
>
|
|
552
|
-
{children}
|
|
553
|
-
</Comp>
|
|
554
|
-
);
|
|
555
|
-
});
|
|
556
|
-
SearchTrigger.displayName = 'SearchTrigger';
|
|
557
|
-
|
|
558
|
-
/**
|
|
559
|
-
* Props for the SearchResults component.
|
|
560
|
-
* Displays the search results in a scrollable dropdown with customizable sections.
|
|
561
|
-
*/
|
|
562
|
-
export interface SearchResultsProps
|
|
563
|
-
extends React.HTMLAttributes<HTMLDivElement>,
|
|
564
|
-
VariantProps<typeof searchResultsVariants> {
|
|
565
|
-
/** Custom sections to display instead of default results */
|
|
566
|
-
sections?: SearchSectionType[];
|
|
567
|
-
/** Whether to show empty state message when no results */
|
|
568
|
-
showEmptyState?: boolean;
|
|
569
|
-
/** Custom message to show when no results are found */
|
|
570
|
-
emptyStateMessage?: string;
|
|
571
|
-
/** Whether to show loading state while searching */
|
|
572
|
-
showLoadingState?: boolean;
|
|
573
|
-
/** Whether loading replaces results or keeps previous results visible */
|
|
574
|
-
loadingBehaviour?: 'replace-results' | 'preserve-results';
|
|
575
|
-
/** Custom loading state rendered instead of loadingMessage */
|
|
576
|
-
loadingState?: React.ReactNode;
|
|
577
|
-
/** Custom message to show while loading */
|
|
578
|
-
loadingMessage?: string;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
/**
|
|
582
|
-
* SearchResults component that displays search results in a scrollable dropdown.
|
|
583
|
-
* Automatically handles loading states, empty states, and result selection.
|
|
584
|
-
*
|
|
585
|
-
* @example
|
|
586
|
-
* ```tsx
|
|
587
|
-
* <SearchResults
|
|
588
|
-
* size="lg"
|
|
589
|
-
* showEmptyState={true}
|
|
590
|
-
* emptyStateMessage="No destinations found."
|
|
591
|
-
* showLoadingState={true}
|
|
592
|
-
* loadingMessage="Searching destinations..."
|
|
593
|
-
* />
|
|
594
|
-
* ```
|
|
595
|
-
*/
|
|
596
|
-
export const SearchResults = React.forwardRef<
|
|
597
|
-
HTMLDivElement,
|
|
598
|
-
SearchResultsProps
|
|
599
|
-
>(
|
|
600
|
-
(
|
|
601
|
-
{
|
|
602
|
-
className,
|
|
603
|
-
size = 'full',
|
|
604
|
-
sections,
|
|
605
|
-
showEmptyState = true,
|
|
606
|
-
emptyStateMessage = 'No results found',
|
|
607
|
-
showLoadingState = true,
|
|
608
|
-
loadingBehaviour = 'replace-results',
|
|
609
|
-
loadingState,
|
|
610
|
-
loadingMessage = 'Searching...',
|
|
611
|
-
...props
|
|
612
|
-
},
|
|
613
|
-
ref
|
|
614
|
-
) => {
|
|
615
|
-
const {
|
|
616
|
-
results,
|
|
617
|
-
isLoading,
|
|
618
|
-
query,
|
|
619
|
-
onResultSelect,
|
|
620
|
-
resultsId,
|
|
621
|
-
activeIndex,
|
|
622
|
-
emptyStateBehaviour,
|
|
623
|
-
minQueryLength,
|
|
624
|
-
} = useAdvancedSearch();
|
|
625
|
-
|
|
626
|
-
const shouldReplaceResultsWithLoading =
|
|
627
|
-
loadingBehaviour === 'replace-results' || results.length === 0;
|
|
628
|
-
|
|
629
|
-
if (isLoading && showLoadingState && shouldReplaceResultsWithLoading) {
|
|
630
|
-
return (
|
|
631
|
-
<div
|
|
632
|
-
ref={ref}
|
|
633
|
-
id={resultsId}
|
|
634
|
-
className={cn(
|
|
635
|
-
searchResultsVariants({ size }),
|
|
636
|
-
'text-muted-foreground p-4 text-center',
|
|
637
|
-
className
|
|
638
|
-
)}
|
|
639
|
-
role='status'
|
|
640
|
-
aria-live='polite'
|
|
641
|
-
{...props}
|
|
642
|
-
>
|
|
643
|
-
{loadingState ?? loadingMessage}
|
|
644
|
-
</div>
|
|
645
|
-
);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
// Handle different empty state behaviours
|
|
649
|
-
const shouldShowEmptyState =
|
|
650
|
-
results.length === 0 ||
|
|
651
|
-
(!query && emptyStateBehaviour !== 'show-all-results');
|
|
652
|
-
|
|
653
|
-
if (shouldShowEmptyState) {
|
|
654
|
-
if (!showEmptyState) return null;
|
|
655
|
-
|
|
656
|
-
// For hide-until-min-chars behaviour, keep the dropdown hidden until the threshold is met.
|
|
657
|
-
if (
|
|
658
|
-
emptyStateBehaviour === 'hide-until-min-chars' &&
|
|
659
|
-
query.length < minQueryLength
|
|
660
|
-
) {
|
|
661
|
-
return null;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
return (
|
|
665
|
-
<div
|
|
666
|
-
ref={ref}
|
|
667
|
-
id={resultsId}
|
|
668
|
-
className={cn(
|
|
669
|
-
searchResultsVariants({ size }),
|
|
670
|
-
'text-muted-foreground p-4 text-center',
|
|
671
|
-
className
|
|
672
|
-
)}
|
|
673
|
-
role='status'
|
|
674
|
-
aria-live='polite'
|
|
675
|
-
{...props}
|
|
676
|
-
>
|
|
677
|
-
{emptyStateMessage}
|
|
678
|
-
</div>
|
|
679
|
-
);
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
// Use sections if provided, otherwise use default results
|
|
683
|
-
const displaySections = sections || [
|
|
684
|
-
{
|
|
685
|
-
id: 'results',
|
|
686
|
-
title: 'Results',
|
|
687
|
-
results: results,
|
|
688
|
-
},
|
|
689
|
-
];
|
|
690
|
-
|
|
691
|
-
return (
|
|
692
|
-
<div
|
|
693
|
-
ref={ref}
|
|
694
|
-
id={resultsId}
|
|
695
|
-
className={cn(
|
|
696
|
-
searchResultsVariants({ size }),
|
|
697
|
-
'max-h-[var(--results-max-height)]',
|
|
698
|
-
className
|
|
699
|
-
)}
|
|
700
|
-
role='listbox'
|
|
701
|
-
aria-label='Search results'
|
|
702
|
-
aria-busy={isLoading || undefined}
|
|
703
|
-
{...props}
|
|
704
|
-
>
|
|
705
|
-
<ScrollArea className='h-fit max-h-[var(--results-max-height)] *:max-h-[var(--results-max-height)]'>
|
|
706
|
-
<div className='space-y-4 p-4'>
|
|
707
|
-
{displaySections.map((section, index) => (
|
|
708
|
-
<div key={section.id}>
|
|
709
|
-
{index > 0 && <Separator className='my-4' />}
|
|
710
|
-
<div className='space-y-2'>
|
|
711
|
-
<h3 className='text-muted-foreground text-sm font-semibold tracking-wide uppercase'>
|
|
712
|
-
{section.title}
|
|
713
|
-
</h3>
|
|
714
|
-
<div className='space-y-1'>
|
|
715
|
-
{section.results.map((result: SearchResult) => {
|
|
716
|
-
const resultIndex = results.findIndex(
|
|
717
|
-
item => item.id === result.id
|
|
718
|
-
);
|
|
719
|
-
|
|
720
|
-
return (
|
|
721
|
-
<SearchResultItem
|
|
722
|
-
key={result.id}
|
|
723
|
-
id={`${resultsId}-option-${result.id}`}
|
|
724
|
-
result={result}
|
|
725
|
-
isActive={resultIndex === activeIndex}
|
|
726
|
-
onClick={() => onResultSelect(result)}
|
|
727
|
-
/>
|
|
728
|
-
);
|
|
729
|
-
})}
|
|
730
|
-
{section.showMore && section.onShowMore && (
|
|
731
|
-
<Button
|
|
732
|
-
variant='ghost'
|
|
733
|
-
size='sm'
|
|
734
|
-
className='text-muted-foreground w-full justify-start'
|
|
735
|
-
onClick={section.onShowMore}
|
|
736
|
-
>
|
|
737
|
-
Show more
|
|
738
|
-
<ChevronDown className='ml-2 h-3 w-3' />
|
|
739
|
-
</Button>
|
|
740
|
-
)}
|
|
741
|
-
</div>
|
|
742
|
-
</div>
|
|
743
|
-
</div>
|
|
744
|
-
))}
|
|
745
|
-
</div>
|
|
746
|
-
</ScrollArea>
|
|
747
|
-
</div>
|
|
748
|
-
);
|
|
749
|
-
}
|
|
750
|
-
);
|
|
751
|
-
SearchResults.displayName = 'SearchResults';
|
|
752
|
-
|
|
753
|
-
/**
|
|
754
|
-
* Props for the SearchResultItem component.
|
|
755
|
-
* Internal component used to render individual search results.
|
|
756
|
-
*/
|
|
757
|
-
interface SearchResultItemProps {
|
|
758
|
-
/** Stable id used by aria-activedescendant */
|
|
759
|
-
id: string;
|
|
760
|
-
/** The search result data to display */
|
|
761
|
-
result: SearchResult;
|
|
762
|
-
/** Whether this item is currently highlighted by keyboard navigation */
|
|
763
|
-
isActive: boolean;
|
|
764
|
-
/** Callback function called when the result is clicked */
|
|
765
|
-
onClick: () => void;
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
const SearchResultItem = ({
|
|
769
|
-
id,
|
|
770
|
-
result,
|
|
771
|
-
isActive,
|
|
772
|
-
onClick,
|
|
773
|
-
}: SearchResultItemProps) => {
|
|
774
|
-
const itemClasses = cn(
|
|
775
|
-
'hover:bg-accent hover:text-accent-foreground focus-visible:border-ring focus-visible:ring-ring/50 w-full rounded-md text-left transition-colors outline-none focus-visible:ring-[3px]',
|
|
776
|
-
isActive && 'bg-accent text-accent-foreground'
|
|
777
|
-
);
|
|
778
|
-
|
|
779
|
-
if (result.type === 'category') {
|
|
780
|
-
return (
|
|
781
|
-
<div
|
|
782
|
-
id={id}
|
|
783
|
-
role='presentation'
|
|
784
|
-
className='text-muted-foreground p-2 text-sm font-medium'
|
|
785
|
-
>
|
|
786
|
-
{result.title}
|
|
787
|
-
</div>
|
|
788
|
-
);
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
if (result.type === 'suggestion') {
|
|
792
|
-
return (
|
|
793
|
-
<button
|
|
794
|
-
id={id}
|
|
795
|
-
type='button'
|
|
796
|
-
role='option'
|
|
797
|
-
aria-selected={isActive}
|
|
798
|
-
className={cn(itemClasses, 'p-2 text-sm')}
|
|
799
|
-
onClick={onClick}
|
|
800
|
-
>
|
|
801
|
-
{result.title}
|
|
802
|
-
</button>
|
|
803
|
-
);
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
const content = (
|
|
807
|
-
<div className='flex gap-3 p-3'>
|
|
808
|
-
{result.image && (
|
|
809
|
-
<div className='flex-shrink-0'>
|
|
810
|
-
<img
|
|
811
|
-
src={result.image}
|
|
812
|
-
alt={result.title}
|
|
813
|
-
className='h-12 w-12 rounded-md object-cover'
|
|
814
|
-
loading='lazy'
|
|
815
|
-
/>
|
|
816
|
-
</div>
|
|
817
|
-
)}
|
|
818
|
-
<div className='min-w-0 flex-1'>
|
|
819
|
-
<div className='flex items-start justify-between gap-2'>
|
|
820
|
-
<h4 className='truncate text-sm font-semibold'>{result.title}</h4>
|
|
821
|
-
{result.badge && (
|
|
822
|
-
<Badge variant='secondary' className='text-xs'>
|
|
823
|
-
{result.badge}
|
|
824
|
-
</Badge>
|
|
825
|
-
)}
|
|
826
|
-
</div>
|
|
827
|
-
{result.description && (
|
|
828
|
-
<p className='text-muted-foreground mt-1 line-clamp-2 text-xs'>
|
|
829
|
-
{result.description}
|
|
830
|
-
</p>
|
|
831
|
-
)}
|
|
832
|
-
</div>
|
|
833
|
-
</div>
|
|
834
|
-
);
|
|
835
|
-
|
|
836
|
-
if (result.href) {
|
|
837
|
-
return (
|
|
838
|
-
<a
|
|
839
|
-
id={id}
|
|
840
|
-
role='option'
|
|
841
|
-
aria-selected={isActive}
|
|
842
|
-
href={result.href}
|
|
843
|
-
className={cn(itemClasses, 'block')}
|
|
844
|
-
onClick={onClick}
|
|
845
|
-
>
|
|
846
|
-
{content}
|
|
847
|
-
</a>
|
|
848
|
-
);
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
// Complex result with image, description, etc.
|
|
852
|
-
return (
|
|
853
|
-
<button
|
|
854
|
-
id={id}
|
|
855
|
-
type='button'
|
|
856
|
-
role='option'
|
|
857
|
-
aria-selected={isActive}
|
|
858
|
-
className={itemClasses}
|
|
859
|
-
onClick={onClick}
|
|
860
|
-
>
|
|
861
|
-
{content}
|
|
862
|
-
</button>
|
|
863
|
-
);
|
|
864
|
-
};
|
|
865
|
-
|
|
866
|
-
/**
|
|
867
|
-
* Props for the AdvancedSearchBar component.
|
|
868
|
-
* Main container component that orchestrates the search input and results dropdown.
|
|
869
|
-
*/
|
|
870
|
-
export interface AdvancedSearchBarProps
|
|
871
|
-
extends React.HTMLAttributes<HTMLDivElement> {
|
|
872
|
-
/** Controlled open state of the results dropdown */
|
|
873
|
-
open?: boolean;
|
|
874
|
-
/** Callback function called when open state changes */
|
|
875
|
-
onOpenChange?: (open: boolean) => void;
|
|
876
|
-
/**
|
|
877
|
-
* Layout mode for the results panel.
|
|
878
|
-
* - `"popover"` (default): absolutely positioned dropdown below the input.
|
|
879
|
-
* - `"inline"`: normal document flow, rendered inside the same root element.
|
|
880
|
-
*/
|
|
881
|
-
resultsMode?: 'popover' | 'inline';
|
|
882
|
-
/** Extra classes applied to the trigger/input wrapper div. */
|
|
883
|
-
triggerClassName?: string;
|
|
884
|
-
/** Extra classes applied to the results panel wrapper div. */
|
|
885
|
-
resultsClassName?: string;
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
/**
|
|
889
|
-
* AdvancedSearchBar component that provides the main search interface.
|
|
890
|
-
* Combines search input with results dropdown in a compound pattern.
|
|
891
|
-
*
|
|
892
|
-
* @example
|
|
893
|
-
* ```tsx
|
|
894
|
-
* <AdvancedSearchBar>
|
|
895
|
-
* <SearchInput placeholder="Search destinations..." />
|
|
896
|
-
* <SearchResults />
|
|
897
|
-
* </AdvancedSearchBar>
|
|
898
|
-
* ```
|
|
899
|
-
*/
|
|
900
|
-
export const AdvancedSearchBar = React.forwardRef<
|
|
901
|
-
HTMLDivElement,
|
|
902
|
-
AdvancedSearchBarProps
|
|
903
|
-
>(
|
|
904
|
-
(
|
|
905
|
-
{
|
|
906
|
-
className,
|
|
907
|
-
children,
|
|
908
|
-
open,
|
|
909
|
-
onOpenChange,
|
|
910
|
-
resultsMode = 'popover',
|
|
911
|
-
triggerClassName,
|
|
912
|
-
resultsClassName,
|
|
913
|
-
...props
|
|
914
|
-
},
|
|
915
|
-
ref
|
|
916
|
-
) => {
|
|
917
|
-
const { isOpen, setIsOpen, setActiveIndex } = useAdvancedSearch();
|
|
918
|
-
const rootRef = React.useRef<HTMLDivElement | null>(null);
|
|
919
|
-
const previousOpenRef = React.useRef(isOpen);
|
|
920
|
-
|
|
921
|
-
const isControlled = open !== undefined;
|
|
922
|
-
const isOpenState = isControlled ? open : isOpen;
|
|
923
|
-
|
|
924
|
-
React.useEffect(() => {
|
|
925
|
-
if (previousOpenRef.current !== isOpen) {
|
|
926
|
-
previousOpenRef.current = isOpen;
|
|
927
|
-
onOpenChange?.(isOpen);
|
|
928
|
-
}
|
|
929
|
-
}, [isOpen, onOpenChange]);
|
|
930
|
-
|
|
931
|
-
React.useEffect(() => {
|
|
932
|
-
if (!isOpenState) return;
|
|
933
|
-
|
|
934
|
-
const handlePointerDown = (event: PointerEvent) => {
|
|
935
|
-
if (!rootRef.current?.contains(event.target as Node)) {
|
|
936
|
-
setActiveIndex(-1);
|
|
937
|
-
setIsOpen(false);
|
|
938
|
-
onOpenChange?.(false);
|
|
939
|
-
}
|
|
940
|
-
};
|
|
941
|
-
|
|
942
|
-
const handleKeyDown = (event: KeyboardEvent) => {
|
|
943
|
-
if (event.key !== 'Escape') return;
|
|
944
|
-
setActiveIndex(-1);
|
|
945
|
-
setIsOpen(false);
|
|
946
|
-
onOpenChange?.(false);
|
|
947
|
-
const focusTarget = rootRef.current?.querySelector<HTMLElement>(
|
|
948
|
-
'input, button, [href], [tabindex]:not([tabindex="-1"])'
|
|
949
|
-
);
|
|
950
|
-
focusTarget?.focus();
|
|
951
|
-
};
|
|
952
|
-
|
|
953
|
-
document.addEventListener('pointerdown', handlePointerDown);
|
|
954
|
-
document.addEventListener('keydown', handleKeyDown);
|
|
955
|
-
|
|
956
|
-
return () => {
|
|
957
|
-
document.removeEventListener('pointerdown', handlePointerDown);
|
|
958
|
-
document.removeEventListener('keydown', handleKeyDown);
|
|
959
|
-
};
|
|
960
|
-
}, [isOpenState, onOpenChange, setActiveIndex, setIsOpen]);
|
|
961
|
-
|
|
962
|
-
const setRefs = React.useCallback(
|
|
963
|
-
(node: HTMLDivElement | null) => {
|
|
964
|
-
rootRef.current = node;
|
|
965
|
-
if (typeof ref === 'function') {
|
|
966
|
-
ref(node);
|
|
967
|
-
} else if (ref) {
|
|
968
|
-
ref.current = node;
|
|
969
|
-
}
|
|
970
|
-
},
|
|
971
|
-
[ref]
|
|
972
|
-
);
|
|
973
|
-
|
|
974
|
-
const isSearchResultsChild = (child: React.ReactNode) => {
|
|
975
|
-
if (!React.isValidElement(child)) return false;
|
|
976
|
-
const childType = child.type as { displayName?: string };
|
|
977
|
-
|
|
978
|
-
return (
|
|
979
|
-
child.type === SearchResults ||
|
|
980
|
-
childType.displayName === SearchResults.displayName
|
|
981
|
-
);
|
|
982
|
-
};
|
|
983
|
-
|
|
984
|
-
// Results are rendered in the positioned panel; every other authored child is a trigger/input.
|
|
985
|
-
const childrenArray = React.Children.toArray(children);
|
|
986
|
-
const resultsChildren = childrenArray.filter(isSearchResultsChild);
|
|
987
|
-
const triggerChildren = childrenArray.filter(
|
|
988
|
-
child => !isSearchResultsChild(child)
|
|
989
|
-
);
|
|
990
|
-
|
|
991
|
-
const triggerElement = triggerChildren.length ? (
|
|
992
|
-
triggerChildren
|
|
993
|
-
) : (
|
|
994
|
-
<SearchInput />
|
|
995
|
-
);
|
|
996
|
-
const resultsElement = resultsChildren.length ? (
|
|
997
|
-
resultsChildren
|
|
998
|
-
) : (
|
|
999
|
-
<SearchResults />
|
|
1000
|
-
);
|
|
1001
|
-
|
|
1002
|
-
const resultsPanel = isOpenState ? (
|
|
1003
|
-
resultsMode === 'inline' ? (
|
|
1004
|
-
<div className={cn('w-full overflow-hidden', resultsClassName)}>
|
|
1005
|
-
{resultsElement}
|
|
1006
|
-
</div>
|
|
1007
|
-
) : (
|
|
1008
|
-
<div
|
|
1009
|
-
className={cn(
|
|
1010
|
-
'bg-popover text-popover-foreground border-border absolute top-full left-0 z-50 mt-1 max-h-[min(var(--results-max-height),calc(100vh-8rem))] w-full overflow-hidden rounded-md border shadow-lg',
|
|
1011
|
-
resultsClassName
|
|
1012
|
-
)}
|
|
1013
|
-
>
|
|
1014
|
-
{resultsElement}
|
|
1015
|
-
</div>
|
|
1016
|
-
)
|
|
1017
|
-
) : null;
|
|
1018
|
-
|
|
1019
|
-
return (
|
|
1020
|
-
<div
|
|
1021
|
-
ref={setRefs}
|
|
1022
|
-
data-state={isOpenState ? 'open' : 'closed'}
|
|
1023
|
-
className={cn('relative w-full', className)}
|
|
1024
|
-
{...props}
|
|
1025
|
-
>
|
|
1026
|
-
<div className={cn('w-full', triggerClassName)}>{triggerElement}</div>
|
|
1027
|
-
{resultsPanel}
|
|
1028
|
-
</div>
|
|
1029
|
-
);
|
|
1030
|
-
}
|
|
1031
|
-
);
|
|
1032
|
-
AdvancedSearchBar.displayName = 'AdvancedSearchBar';
|
|
1033
|
-
|
|
1034
|
-
// Compound Pattern Components
|
|
1035
|
-
|
|
1036
|
-
/**
|
|
1037
|
-
* Props for the SearchSection component.
|
|
1038
|
-
* Used in compound pattern to create organized sections of search results.
|
|
1039
|
-
*/
|
|
1040
|
-
export interface SearchSectionProps
|
|
1041
|
-
extends React.HTMLAttributes<HTMLDivElement> {
|
|
1042
|
-
/** Title displayed above the section results */
|
|
1043
|
-
title?: string;
|
|
1044
|
-
/** Maximum number of results to show in this section */
|
|
1045
|
-
maxResults?: number;
|
|
1046
|
-
/** Whether to show a "Show more" button */
|
|
1047
|
-
showMore?: boolean;
|
|
1048
|
-
/** Callback function called when "Show more" is clicked */
|
|
1049
|
-
onShowMore?: () => void;
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
/**
|
|
1053
|
-
* SearchSection component for organizing search results into sections.
|
|
1054
|
-
* Used in compound pattern to create structured result displays.
|
|
1055
|
-
*
|
|
1056
|
-
* @example
|
|
1057
|
-
* ```tsx
|
|
1058
|
-
* <SearchSection title="Popular Searches" showMore={true} onShowMore={handleShowMore}>
|
|
1059
|
-
* <SearchItem result={popularResult1} />
|
|
1060
|
-
* <SearchItem result={popularResult2} />
|
|
1061
|
-
* </SearchSection>
|
|
1062
|
-
* ```
|
|
1063
|
-
*/
|
|
1064
|
-
export const SearchSection = React.forwardRef<
|
|
1065
|
-
HTMLDivElement,
|
|
1066
|
-
SearchSectionProps
|
|
1067
|
-
>(({ className, title, showMore, onShowMore, children, ...props }, ref) => {
|
|
1068
|
-
return (
|
|
1069
|
-
<div ref={ref} className={cn('space-y-2', className)} {...props}>
|
|
1070
|
-
{title && (
|
|
1071
|
-
<h3 className='text-muted-foreground text-sm font-semibold tracking-wide uppercase'>
|
|
1072
|
-
{title}
|
|
1073
|
-
</h3>
|
|
1074
|
-
)}
|
|
1075
|
-
<div className='space-y-1'>
|
|
1076
|
-
{children}
|
|
1077
|
-
{showMore && onShowMore && (
|
|
1078
|
-
<Button
|
|
1079
|
-
variant='ghost'
|
|
1080
|
-
size='sm'
|
|
1081
|
-
className='text-muted-foreground w-full justify-start'
|
|
1082
|
-
onClick={onShowMore}
|
|
1083
|
-
>
|
|
1084
|
-
Show more
|
|
1085
|
-
<ChevronDown className='ml-2 h-3 w-3' />
|
|
1086
|
-
</Button>
|
|
1087
|
-
)}
|
|
1088
|
-
</div>
|
|
1089
|
-
</div>
|
|
1090
|
-
);
|
|
1091
|
-
});
|
|
1092
|
-
SearchSection.displayName = 'SearchSection';
|
|
1093
|
-
|
|
1094
|
-
/**
|
|
1095
|
-
* Props for the SearchItem component.
|
|
1096
|
-
* Used in compound pattern to render individual search result items.
|
|
1097
|
-
*/
|
|
1098
|
-
export interface SearchItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
1099
|
-
/** The search result data to display */
|
|
1100
|
-
result?: SearchResult;
|
|
1101
|
-
/** Callback function called when the item is clicked */
|
|
1102
|
-
onClick?: () => void;
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
/**
|
|
1106
|
-
* SearchItem component for rendering individual search result items.
|
|
1107
|
-
* Can be used with result data or custom children in compound pattern.
|
|
1108
|
-
*
|
|
1109
|
-
* @example
|
|
1110
|
-
* ```tsx
|
|
1111
|
-
* <SearchItem result={searchResult} />
|
|
1112
|
-
*
|
|
1113
|
-
* // Or with custom children
|
|
1114
|
-
* <SearchItem onClick={handleClick}>
|
|
1115
|
-
* <div>Custom result display</div>
|
|
1116
|
-
* </SearchItem>
|
|
1117
|
-
* ```
|
|
1118
|
-
*/
|
|
1119
|
-
export const SearchItem = React.forwardRef<HTMLDivElement, SearchItemProps>(
|
|
1120
|
-
({ className, result, onClick, children, ...props }, ref) => {
|
|
1121
|
-
const { onResultSelect } = useAdvancedSearch();
|
|
1122
|
-
|
|
1123
|
-
const handleClick = () => {
|
|
1124
|
-
if (result) {
|
|
1125
|
-
onResultSelect(result);
|
|
1126
|
-
}
|
|
1127
|
-
onClick?.();
|
|
1128
|
-
};
|
|
1129
|
-
|
|
1130
|
-
const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {
|
|
1131
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
1132
|
-
event.preventDefault();
|
|
1133
|
-
handleClick();
|
|
1134
|
-
}
|
|
1135
|
-
};
|
|
1136
|
-
|
|
1137
|
-
// If children are provided, render them directly
|
|
1138
|
-
if (children) {
|
|
1139
|
-
return (
|
|
1140
|
-
<div
|
|
1141
|
-
ref={ref}
|
|
1142
|
-
role='button'
|
|
1143
|
-
tabIndex={0}
|
|
1144
|
-
className={cn('cursor-pointer outline-none', className)}
|
|
1145
|
-
onClick={handleClick}
|
|
1146
|
-
onKeyDown={handleKeyDown}
|
|
1147
|
-
{...props}
|
|
1148
|
-
>
|
|
1149
|
-
{children}
|
|
1150
|
-
</div>
|
|
1151
|
-
);
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
// Otherwise render based on result type
|
|
1155
|
-
if (!result) return null;
|
|
1156
|
-
|
|
1157
|
-
if (result.type === 'category') {
|
|
1158
|
-
return (
|
|
1159
|
-
<div
|
|
1160
|
-
ref={ref}
|
|
1161
|
-
role='presentation'
|
|
1162
|
-
className={cn(
|
|
1163
|
-
'text-muted-foreground p-2 text-sm font-medium',
|
|
1164
|
-
className
|
|
1165
|
-
)}
|
|
1166
|
-
{...props}
|
|
1167
|
-
>
|
|
1168
|
-
{result.title}
|
|
1169
|
-
</div>
|
|
1170
|
-
);
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
if (result.type === 'suggestion') {
|
|
1174
|
-
return (
|
|
1175
|
-
<Button
|
|
1176
|
-
ref={ref as unknown as React.RefObject<HTMLButtonElement>}
|
|
1177
|
-
variant='ghost'
|
|
1178
|
-
size='sm'
|
|
1179
|
-
className={cn('h-auto w-full justify-start p-2', className)}
|
|
1180
|
-
onClick={handleClick}
|
|
1181
|
-
{...(props as React.ButtonHTMLAttributes<HTMLButtonElement>)}
|
|
1182
|
-
>
|
|
1183
|
-
<span className='text-sm'>{result.title}</span>
|
|
1184
|
-
</Button>
|
|
1185
|
-
);
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
// Complex result with image, description, etc.
|
|
1189
|
-
return (
|
|
1190
|
-
<button
|
|
1191
|
-
ref={ref as unknown as React.RefObject<HTMLButtonElement>}
|
|
1192
|
-
type='button'
|
|
1193
|
-
className={cn(
|
|
1194
|
-
'hover:bg-accent hover:text-accent-foreground focus-visible:border-ring focus-visible:ring-ring/50 w-full cursor-pointer rounded-md text-left transition-colors outline-none focus-visible:ring-[3px]',
|
|
1195
|
-
className
|
|
1196
|
-
)}
|
|
1197
|
-
onClick={handleClick}
|
|
1198
|
-
{...(props as React.ButtonHTMLAttributes<HTMLButtonElement>)}
|
|
1199
|
-
>
|
|
1200
|
-
<div className='flex gap-3 p-3'>
|
|
1201
|
-
{result.image && (
|
|
1202
|
-
<div className='flex-shrink-0'>
|
|
1203
|
-
<img
|
|
1204
|
-
src={result.image}
|
|
1205
|
-
alt={result.title}
|
|
1206
|
-
className='h-12 w-12 rounded-md object-cover'
|
|
1207
|
-
loading='lazy'
|
|
1208
|
-
/>
|
|
1209
|
-
</div>
|
|
1210
|
-
)}
|
|
1211
|
-
<div className='min-w-0 flex-1'>
|
|
1212
|
-
<div className='flex items-start justify-between gap-2'>
|
|
1213
|
-
<h4 className='truncate text-sm font-semibold'>{result.title}</h4>
|
|
1214
|
-
{result.badge && (
|
|
1215
|
-
<Badge variant='secondary' className='text-xs'>
|
|
1216
|
-
{result.badge}
|
|
1217
|
-
</Badge>
|
|
1218
|
-
)}
|
|
1219
|
-
</div>
|
|
1220
|
-
{result.description && (
|
|
1221
|
-
<p className='text-muted-foreground mt-1 line-clamp-2 text-xs'>
|
|
1222
|
-
{result.description}
|
|
1223
|
-
</p>
|
|
1224
|
-
)}
|
|
1225
|
-
</div>
|
|
1226
|
-
</div>
|
|
1227
|
-
</button>
|
|
1228
|
-
);
|
|
1229
|
-
}
|
|
1230
|
-
);
|
|
1231
|
-
SearchItem.displayName = 'SearchItem';
|
|
1232
|
-
|
|
1233
|
-
/**
|
|
1234
|
-
* Compound pattern exports for the advanced search bar components.
|
|
1235
|
-
* These provide a more intuitive API for composing search interfaces.
|
|
1236
|
-
*
|
|
1237
|
-
* @example
|
|
1238
|
-
* ```tsx
|
|
1239
|
-
* import * as SearchBar from '@/components/ui/advanced-search-bar'
|
|
1240
|
-
*
|
|
1241
|
-
* <SearchBar.Provider onSearch={handleSearch} onResultSelect={handleSelect}>
|
|
1242
|
-
* <SearchBar.Root>
|
|
1243
|
-
* <SearchBar.Input placeholder="Search..." />
|
|
1244
|
-
* <SearchBar.Results>
|
|
1245
|
-
* <SearchBar.Section title="Popular">
|
|
1246
|
-
* <SearchBar.Item result={popularResult} />
|
|
1247
|
-
* </SearchBar.Section>
|
|
1248
|
-
* </SearchBar.Results>
|
|
1249
|
-
* </SearchBar.Root>
|
|
1250
|
-
* </SearchBar.Provider>
|
|
1251
|
-
* ```
|
|
1252
|
-
*/
|
|
1253
|
-
/**
|
|
1254
|
-
* Provider component exported separately to avoid naming conflicts.
|
|
1255
|
-
* This is the same as AdvancedSearchProvider but with a shorter name for compound pattern usage.
|
|
1256
|
-
*/
|
|
1257
|
-
export {
|
|
1258
|
-
AdvancedSearchBar as Root,
|
|
1259
|
-
AdvancedSearchProvider as Provider,
|
|
1260
|
-
SearchInput as Input,
|
|
1261
|
-
SearchItem as Item,
|
|
1262
|
-
SearchResults as Results,
|
|
1263
|
-
SearchSection as Section,
|
|
1264
|
-
SearchTrigger as Trigger,
|
|
1265
|
-
searchInputWrapperVariants,
|
|
1266
|
-
searchResultsVariants,
|
|
1267
|
-
};
|
|
1268
|
-
|
|
1269
|
-
/**
|
|
1270
|
-
* Wrapper component for documentation and preview purposes.
|
|
1271
|
-
* Provides a complete search implementation with mock data for testing and demos.
|
|
1272
|
-
*
|
|
1273
|
-
* @deprecated Demo-only helper. Prefer composing AdvancedSearchProvider,
|
|
1274
|
-
* AdvancedSearchBar, SearchInput, and SearchResults in application code.
|
|
1275
|
-
*
|
|
1276
|
-
* @param props - Configuration props for the search wrapper
|
|
1277
|
-
* @returns Complete search component with mock functionality
|
|
1278
|
-
*
|
|
1279
|
-
* @example
|
|
1280
|
-
* ```tsx
|
|
1281
|
-
* <AdvancedSearchBarWrapper
|
|
1282
|
-
* emptyStateBehaviour="show-all-results"
|
|
1283
|
-
* size="lg"
|
|
1284
|
-
* variant="default"
|
|
1285
|
-
* useCustomTrigger={false}
|
|
1286
|
-
* />
|
|
1287
|
-
* ```
|
|
1288
|
-
*/
|
|
1289
|
-
export function AdvancedSearchBarWrapper(
|
|
1290
|
-
props: {
|
|
1291
|
-
/** Minimum number of characters required before triggering search */
|
|
1292
|
-
minQueryLength?: number;
|
|
1293
|
-
/** Behaviour when search results are empty or query is too short */
|
|
1294
|
-
emptyStateBehaviour?:
|
|
1295
|
-
| 'show-empty-message'
|
|
1296
|
-
| 'hide-until-min-chars'
|
|
1297
|
-
| 'show-all-results';
|
|
1298
|
-
/** Size variant for the search input */
|
|
1299
|
-
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
1300
|
-
/** Visual variant for the search input */
|
|
1301
|
-
variant?: 'default' | 'ghost' | 'filled';
|
|
1302
|
-
/** Whether to use a custom trigger button instead of input */
|
|
1303
|
-
useCustomTrigger?: boolean;
|
|
1304
|
-
} = {}
|
|
1305
|
-
) {
|
|
1306
|
-
const {
|
|
1307
|
-
minQueryLength = 1,
|
|
1308
|
-
emptyStateBehaviour = 'show-all-results',
|
|
1309
|
-
size = 'md',
|
|
1310
|
-
variant = 'default',
|
|
1311
|
-
useCustomTrigger = false,
|
|
1312
|
-
} = props;
|
|
1313
|
-
|
|
1314
|
-
const mockSearchResults = [
|
|
1315
|
-
{
|
|
1316
|
-
id: '1',
|
|
1317
|
-
title: 'Beach Holidays',
|
|
1318
|
-
description: 'Relaxing beach destinations',
|
|
1319
|
-
type: 'result' as const,
|
|
1320
|
-
badge: 'Popular',
|
|
1321
|
-
},
|
|
1322
|
-
{
|
|
1323
|
-
id: '2',
|
|
1324
|
-
title: 'Adventure Trips',
|
|
1325
|
-
description: 'Exciting adventure experiences',
|
|
1326
|
-
type: 'result' as const,
|
|
1327
|
-
badge: 'New',
|
|
1328
|
-
},
|
|
1329
|
-
{
|
|
1330
|
-
id: '3',
|
|
1331
|
-
title: 'City Breaks',
|
|
1332
|
-
description: 'Urban exploration trips',
|
|
1333
|
-
type: 'result' as const,
|
|
1334
|
-
},
|
|
1335
|
-
{
|
|
1336
|
-
id: '4',
|
|
1337
|
-
title: 'Mountain Retreats',
|
|
1338
|
-
description: 'Peaceful mountain getaways',
|
|
1339
|
-
type: 'result' as const,
|
|
1340
|
-
},
|
|
1341
|
-
{
|
|
1342
|
-
id: '5',
|
|
1343
|
-
title: 'Cultural Tours',
|
|
1344
|
-
description: 'Explore local culture and history',
|
|
1345
|
-
type: 'result' as const,
|
|
1346
|
-
},
|
|
1347
|
-
];
|
|
1348
|
-
|
|
1349
|
-
const handleSearch = async (query: string): Promise<SearchResult[]> => {
|
|
1350
|
-
// Simulate search delay
|
|
1351
|
-
await new Promise(resolve => setTimeout(resolve, 300));
|
|
1352
|
-
|
|
1353
|
-
if (!query.trim()) {
|
|
1354
|
-
return emptyStateBehaviour === 'show-all-results'
|
|
1355
|
-
? mockSearchResults
|
|
1356
|
-
: [];
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
return mockSearchResults.filter(
|
|
1360
|
-
result =>
|
|
1361
|
-
result.title.toLowerCase().includes(query.toLowerCase()) ||
|
|
1362
|
-
result.description.toLowerCase().includes(query.toLowerCase())
|
|
1363
|
-
);
|
|
1364
|
-
};
|
|
1365
|
-
|
|
1366
|
-
const handleResultSelect = (result: SearchResult) => {
|
|
1367
|
-
console.log('Selected result:', result);
|
|
1368
|
-
};
|
|
1369
|
-
|
|
1370
|
-
const getPlaceholder = () => {
|
|
1371
|
-
if (emptyStateBehaviour === 'hide-until-min-chars') {
|
|
1372
|
-
return `Type at least ${minQueryLength} characters...`;
|
|
1373
|
-
}
|
|
1374
|
-
return 'Search destinations...';
|
|
1375
|
-
};
|
|
1376
|
-
|
|
1377
|
-
return (
|
|
1378
|
-
<AdvancedSearchProvider
|
|
1379
|
-
onSearch={handleSearch}
|
|
1380
|
-
onResultSelect={handleResultSelect}
|
|
1381
|
-
debounceMs={300}
|
|
1382
|
-
minQueryLength={minQueryLength}
|
|
1383
|
-
emptyStateBehaviour={emptyStateBehaviour}
|
|
1384
|
-
initialResults={
|
|
1385
|
-
emptyStateBehaviour === 'show-all-results' ? mockSearchResults : []
|
|
1386
|
-
}
|
|
1387
|
-
>
|
|
1388
|
-
<AdvancedSearchBar>
|
|
1389
|
-
{useCustomTrigger ? (
|
|
1390
|
-
<SearchTrigger asChild>
|
|
1391
|
-
<Button variant='outline' className='w-full justify-start'>
|
|
1392
|
-
<Search className='mr-2 h-4 w-4' />
|
|
1393
|
-
Click to search...
|
|
1394
|
-
</Button>
|
|
1395
|
-
</SearchTrigger>
|
|
1396
|
-
) : (
|
|
1397
|
-
<SearchInput
|
|
1398
|
-
placeholder={getPlaceholder()}
|
|
1399
|
-
size={size}
|
|
1400
|
-
variant={variant}
|
|
1401
|
-
showSearchIcon={true}
|
|
1402
|
-
showClearButton={true}
|
|
1403
|
-
/>
|
|
1404
|
-
)}
|
|
1405
|
-
<SearchResults
|
|
1406
|
-
size={size === 'sm' ? 'sm' : size === 'lg' ? 'lg' : 'md'}
|
|
1407
|
-
showEmptyState={true}
|
|
1408
|
-
emptyStateMessage='No destinations found.'
|
|
1409
|
-
showLoadingState={true}
|
|
1410
|
-
loadingMessage='Searching destinations...'
|
|
1411
|
-
/>
|
|
1412
|
-
</AdvancedSearchBar>
|
|
1413
|
-
</AdvancedSearchProvider>
|
|
1414
|
-
);
|
|
1415
|
-
}
|