@quantaroute/checkout 1.2.1 → 1.3.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.
@@ -1,7 +1,9 @@
1
- import React, { useEffect, useRef, useState, useCallback } from 'react';
1
+ import React, { useEffect, useRef, useState, useCallback, useId } from 'react';
2
2
  import maplibregl from 'maplibre-gl';
3
3
  import 'maplibre-gl/dist/maplibre-gl.css';
4
- import { getDigiPin, isWithinIndia } from '../core/digipin';
4
+ import { getDigiPin, getLatLngFromDigiPin, isWithinIndia } from '../core/digipin';
5
+ import { autocompleteAddress, looksLikeDigiPin } from '../core/api';
6
+ import type { AutocompleteSuggestion } from '../core/api';
5
7
  import { useGeolocation } from '../hooks/useGeolocation';
6
8
  import type { MapPinSelectorProps } from '../core/types';
7
9
 
@@ -102,33 +104,130 @@ const MapPinSelector: React.FC<MapPinSelectorProps> = ({
102
104
  defaultLat,
103
105
  defaultLng,
104
106
  mapHeight = '380px',
105
- theme: _theme = 'light', // kept for future dark-mode pin tint; unused for now
107
+ theme: _theme = 'light',
106
108
  indiaBoundaryUrl,
109
+ enableSearch = true,
110
+ apiKey,
111
+ apiBaseUrl,
107
112
  }) => {
108
113
  const containerRef = useRef<HTMLDivElement>(null);
109
114
  const mapRef = useRef<maplibregl.Map | null>(null);
110
115
  const markerRef = useRef<maplibregl.Marker | null>(null);
111
116
 
112
- // Compute once here so both state init and the useEffect use the same values.
113
117
  const initLat = defaultLat ?? INDIA_CENTER.lat;
114
118
  const initLng = defaultLng ?? INDIA_CENTER.lng;
115
119
  const hasDefault = defaultLat !== undefined && defaultLng !== undefined;
116
120
 
117
121
  const [lat, setLat] = useState(initLat);
118
122
  const [lng, setLng] = useState(initLng);
119
- // Compute DigiPin eagerly (offline, ~0.1 ms) so the badge shows immediately.
120
123
  const [digipin, setDigipin] = useState<string | null>(() =>
121
124
  computeDigiPinSafe(initLat, initLng)
122
125
  );
123
126
  const [mapLoaded, setMapLoaded] = useState(false);
124
127
 
128
+ // ── Search state ─────────────────────────────────────────────────────────
129
+ const [searchQuery, setSearchQuery] = useState('');
130
+ const [suggestions, setSuggestions] = useState<AutocompleteSuggestion[]>([]);
131
+ const [searchLoading, setSearchLoading] = useState(false);
132
+ const [searchError, setSearchError] = useState<string | null>(null);
133
+ const [dropdownOpen, setDropdownOpen] = useState(false);
134
+ const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);
135
+ const searchInputRef = useRef<HTMLInputElement>(null);
136
+ const listboxId = useId();
137
+
125
138
  const { loading: geoLoading, error: geoError, locate, clearError } = useGeolocation();
126
139
 
127
- // Update DigiPin badge (offline, instant)
128
140
  const refreshDigipin = useCallback((la: number, lo: number) => {
129
141
  setDigipin(computeDigiPinSafe(la, lo));
130
142
  }, []);
131
143
 
144
+ // ── Fly map + move pin to a coord ────────────────────────────────────────
145
+ const flyToCoord = useCallback((la: number, lo: number) => {
146
+ setLat(la);
147
+ setLng(lo);
148
+ refreshDigipin(la, lo);
149
+ if (mapRef.current) {
150
+ mapRef.current.flyTo({ center: [lo, la], zoom: STREET_ZOOM, duration: 900, essential: true });
151
+ }
152
+ markerRef.current?.setLngLat([lo, la]);
153
+ }, [refreshDigipin]);
154
+
155
+ // ── Search input change handler ──────────────────────────────────────────
156
+ const handleSearchChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
157
+ const value = e.target.value;
158
+ setSearchQuery(value);
159
+ setSearchError(null);
160
+
161
+ if (debounceRef.current) clearTimeout(debounceRef.current);
162
+
163
+ const trimmed = value.trim();
164
+
165
+ // Empty — close dropdown
166
+ if (!trimmed) {
167
+ setSuggestions([]);
168
+ setDropdownOpen(false);
169
+ setSearchLoading(false);
170
+ return;
171
+ }
172
+
173
+ // DigiPin input — resolve 100% offline, instant, zero API cost
174
+ if (looksLikeDigiPin(trimmed)) {
175
+ try {
176
+ const coords = getLatLngFromDigiPin(trimmed.toUpperCase());
177
+ const la = parseFloat(coords.latitude);
178
+ const lo = parseFloat(coords.longitude);
179
+ flyToCoord(la, lo);
180
+ setSuggestions([]);
181
+ setDropdownOpen(false);
182
+ setSearchQuery('');
183
+ } catch {
184
+ setSearchError('Invalid DigiPin code');
185
+ }
186
+ return;
187
+ }
188
+
189
+ // Address search — debounce 400 ms, need ≥ 3 chars
190
+ if (trimmed.length < 3) {
191
+ setSuggestions([]);
192
+ setDropdownOpen(false);
193
+ return;
194
+ }
195
+
196
+ setSearchLoading(true);
197
+ debounceRef.current = setTimeout(async () => {
198
+ try {
199
+ const key = apiKey ?? '';
200
+ // Forward current pin position so the API can bias/bound results nearby
201
+ const results = await autocompleteAddress(trimmed, key, apiBaseUrl, 5, lat, lng);
202
+ setSuggestions(results);
203
+ setDropdownOpen(results.length > 0);
204
+ } catch (err) {
205
+ setSearchError(err instanceof Error ? err.message : 'Search failed');
206
+ setSuggestions([]);
207
+ setDropdownOpen(false);
208
+ } finally {
209
+ setSearchLoading(false);
210
+ }
211
+ }, 400);
212
+ }, [apiKey, apiBaseUrl, flyToCoord]);
213
+
214
+ // ── Pick a suggestion from the dropdown ──────────────────────────────────
215
+ const handleSuggestionSelect = useCallback((s: AutocompleteSuggestion) => {
216
+ flyToCoord(s.coordinates.latitude, s.coordinates.longitude);
217
+ setSearchQuery('');
218
+ setSuggestions([]);
219
+ setDropdownOpen(false);
220
+ searchInputRef.current?.blur();
221
+ }, [flyToCoord]);
222
+
223
+ const handleSearchKeyDown = useCallback((e: React.KeyboardEvent<HTMLInputElement>) => {
224
+ if (e.key === 'Escape') {
225
+ setSuggestions([]);
226
+ setDropdownOpen(false);
227
+ setSearchQuery('');
228
+ }
229
+ }, []);
230
+
132
231
  // ── Map initialization (runs once) ────────────────────────────────────────
133
232
  useEffect(() => {
134
233
  if (!containerRef.current) return;
@@ -295,6 +394,118 @@ const MapPinSelector: React.FC<MapPinSelectorProps> = ({
295
394
  </div>
296
395
  </div>
297
396
 
397
+ {/* ── Search bar ── */}
398
+ {enableSearch && (
399
+ <div className="qr-search-bar" role="search">
400
+ <div className="qr-search-bar__input-wrap">
401
+ {/* Search icon */}
402
+ <svg
403
+ className="qr-search-bar__icon"
404
+ aria-hidden="true"
405
+ viewBox="0 0 24 24"
406
+ fill="none"
407
+ stroke="currentColor"
408
+ strokeWidth="2"
409
+ strokeLinecap="round"
410
+ strokeLinejoin="round"
411
+ >
412
+ <circle cx="11" cy="11" r="8" />
413
+ <path d="M21 21l-4.35-4.35" />
414
+ </svg>
415
+
416
+ <input
417
+ ref={searchInputRef}
418
+ type="search"
419
+ className="qr-search-bar__input"
420
+ placeholder="Search address, 'pharmacy near me', or DigiPin…"
421
+ value={searchQuery}
422
+ onChange={handleSearchChange}
423
+ onKeyDown={handleSearchKeyDown}
424
+ autoComplete="off"
425
+ autoCorrect="off"
426
+ autoCapitalize="characters"
427
+ spellCheck={false}
428
+ aria-label="Search address or DigiPin"
429
+ aria-autocomplete="list"
430
+ aria-controls={dropdownOpen ? listboxId : undefined}
431
+ aria-expanded={dropdownOpen}
432
+ />
433
+
434
+ {/* Inline loading spinner */}
435
+ {searchLoading && (
436
+ <span className="qr-search-bar__spinner qr-spinner qr-spinner--sm" aria-hidden="true" />
437
+ )}
438
+
439
+ {/* Clear button */}
440
+ {searchQuery && !searchLoading && (
441
+ <button
442
+ type="button"
443
+ className="qr-search-bar__clear"
444
+ onClick={() => { setSearchQuery(''); setSuggestions([]); setDropdownOpen(false); setSearchError(null); }}
445
+ aria-label="Clear search"
446
+ tabIndex={-1}
447
+ >
448
+ ×
449
+ </button>
450
+ )}
451
+ </div>
452
+
453
+ {/* Inline error */}
454
+ {searchError && (
455
+ <p className="qr-search-bar__error" role="alert">{searchError}</p>
456
+ )}
457
+
458
+ {/* Suggestions dropdown */}
459
+ {dropdownOpen && suggestions.length > 0 && (
460
+ <ul
461
+ id={listboxId}
462
+ className="qr-search-bar__dropdown"
463
+ role="listbox"
464
+ aria-label="Address suggestions"
465
+ >
466
+ {suggestions.map((s, i) => (
467
+ <li
468
+ key={i}
469
+ className="qr-search-bar__suggestion"
470
+ role="option"
471
+ aria-selected="false"
472
+ onMouseDown={(e) => {
473
+ e.preventDefault(); // keep input focus until after click
474
+ handleSuggestionSelect(s);
475
+ }}
476
+ >
477
+ <svg
478
+ className="qr-search-bar__suggestion-icon"
479
+ aria-hidden="true"
480
+ viewBox="0 0 24 24"
481
+ fill="none"
482
+ stroke="currentColor"
483
+ strokeWidth="1.8"
484
+ strokeLinecap="round"
485
+ strokeLinejoin="round"
486
+ >
487
+ <path d="M12 2C8.134 2 5 5.134 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.866-3.134-7-7-7z" />
488
+ <circle cx="12" cy="9" r="2.5" />
489
+ </svg>
490
+ <div className="qr-search-bar__suggestion-text">
491
+ <span className="qr-search-bar__suggestion-name">{s.displayName}</span>
492
+ {s.address && s.address !== s.displayName && (
493
+ <span className="qr-search-bar__suggestion-sub">{s.address}</span>
494
+ )}
495
+ </div>
496
+ </li>
497
+ ))}
498
+ </ul>
499
+ )}
500
+
501
+ {/* DigiPin hint chip */}
502
+ <p className="qr-search-bar__hint">
503
+ <span className="qr-search-bar__hint-chip">DigiPin</span>
504
+ Type your DigiPin code for instant offline lookup — no API call
505
+ </p>
506
+ </div>
507
+ )}
508
+
298
509
  {/* ── Map area ── */}
299
510
  <div className="qr-map-outer" style={{ height: mapHeight }}>
300
511
  {/* MapLibre GL container */}
package/src/core/api.ts CHANGED
@@ -2,6 +2,10 @@ import type { LocationLookupResponse } from './types';
2
2
 
3
3
  const DEFAULT_BASE_URL = 'https://api.quantaroute.com';
4
4
 
5
+ // ─── DigiPin regex (matches "XXX-XXX-XXXX" with valid characters) ─────────────
6
+ // Valid chars: F C 9 8 J 3 2 7 K 4 5 6 L M P T (from the 4×4 DIGIPIN_GRID)
7
+ const DIGIPIN_PATTERN = /^[FC98J327K456LMPT]{3}-[FC98J327K456LMPT]{3}-[FC98J327K456LMPT]{4}$/i;
8
+
5
9
  /**
6
10
  * Cross-platform timeout signal.
7
11
  * AbortSignal.timeout() is not available in React Native / Hermes — fall back
@@ -112,6 +116,94 @@ export async function lookupLocation(
112
116
  return data;
113
117
  }
114
118
 
119
+ // ─── Autocomplete ─────────────────────────────────────────────────────────────
120
+
121
+ /** One address suggestion from /v1/digipin/autocomplete */
122
+ export interface AutocompleteSuggestion {
123
+ displayName: string;
124
+ address: string;
125
+ coordinates: { latitude: number; longitude: number };
126
+ confidence: number;
127
+ addressComponents: {
128
+ house_number?: string;
129
+ road?: string;
130
+ neighbourhood?: string;
131
+ suburb?: string;
132
+ city?: string;
133
+ state?: string;
134
+ postcode?: string;
135
+ country?: string;
136
+ [key: string]: string | undefined;
137
+ };
138
+ }
139
+
140
+ export interface AutocompleteResponse {
141
+ success: boolean;
142
+ data: AutocompleteSuggestion[];
143
+ error?: string;
144
+ message?: string;
145
+ }
146
+
147
+ /**
148
+ * Returns true if the trimmed input looks like a complete DigiPin code.
149
+ * Used to skip the API call and resolve offline instead.
150
+ */
151
+ export function looksLikeDigiPin(input: string): boolean {
152
+ return DIGIPIN_PATTERN.test(input.trim().toUpperCase());
153
+ }
154
+
155
+ /**
156
+ * Call QuantaRoute's autocomplete API.
157
+ * Minimum 3 characters required; max 10 suggestions.
158
+ *
159
+ * Pass userLat / userLng (the map pin's current position) to unlock:
160
+ * – Location-biased results (~50 km soft radius around the pin)
161
+ * – "Near me" / "nearby" keyword support with a tight ~10 km hard radius
162
+ */
163
+ export async function autocompleteAddress(
164
+ query: string,
165
+ apiKey: string,
166
+ baseUrl: string = DEFAULT_BASE_URL,
167
+ limit = 5,
168
+ userLat?: number,
169
+ userLng?: number,
170
+ ): Promise<AutocompleteSuggestion[]> {
171
+ let url =
172
+ `${baseUrl.replace(/\/$/, '')}/v1/digipin/autocomplete` +
173
+ `?q=${encodeURIComponent(query.trim())}&limit=${Math.min(limit, 10)}`;
174
+
175
+ if (typeof userLat === 'number' && typeof userLng === 'number') {
176
+ url += `&lat=${userLat.toFixed(6)}&lng=${userLng.toFixed(6)}`;
177
+ }
178
+
179
+ let res: Response;
180
+ try {
181
+ res = await fetch(url, {
182
+ method: 'GET',
183
+ headers: { 'x-api-key': apiKey },
184
+ signal: makeTimeoutSignal(8_000),
185
+ });
186
+ } catch (err) {
187
+ if (err instanceof Error && (err.name === 'TimeoutError' || err.name === 'AbortError')) {
188
+ throw new Error('Autocomplete request timed out.');
189
+ }
190
+ throw new Error(`Network error: ${err instanceof Error ? err.message : String(err)}`);
191
+ }
192
+
193
+ if (!res.ok) {
194
+ if (res.status === 401 || res.status === 403) {
195
+ throw new Error('Invalid API key.');
196
+ }
197
+ if (res.status === 429) {
198
+ throw new Error('Rate limit exceeded.');
199
+ }
200
+ return []; // silently return empty on other errors
201
+ }
202
+
203
+ const data = (await res.json()) as AutocompleteResponse;
204
+ return data.success ? (data.data ?? []) : [];
205
+ }
206
+
115
207
  /**
116
208
  * Call QuantaRoute's Reverse Geocoding API.
117
209
  * Converts DigiPin → address components from Nominatim/OpenStreetMap.
package/src/core/types.ts CHANGED
@@ -100,6 +100,18 @@ export interface MapPinSelectorProps {
100
100
  * Example: indiaBoundaryUrl="/geojson/india.geojson"
101
101
  */
102
102
  indiaBoundaryUrl?: string;
103
+ /**
104
+ * Show the search bar above the map (default: true).
105
+ * Supports two modes automatically:
106
+ * – Address search → calls /v1/digipin/autocomplete (debounced 400ms)
107
+ * – DigiPin input → decoded offline, zero API call, instant flyTo
108
+ * Pass apiKey to enable address search. DigiPin search always works offline.
109
+ */
110
+ enableSearch?: boolean;
111
+ /** Required when enableSearch is true — used to call the autocomplete API. */
112
+ apiKey?: string;
113
+ /** API base URL for autocomplete. Defaults to https://api.quantaroute.com */
114
+ apiBaseUrl?: string;
103
115
  }
104
116
 
105
117
  export interface AddressFormProps {
@@ -147,4 +159,11 @@ export interface CheckoutWidgetProps {
147
159
  * Example: indiaBoundaryUrl="/geojson/india.geojson"
148
160
  */
149
161
  indiaBoundaryUrl?: string;
162
+ /**
163
+ * Show the smart search bar on the map step (default: true).
164
+ * Supports address search (API) and DigiPin lookup (100% offline).
165
+ * As India Post promotes DigiPin, buyers can just type their 10-char code
166
+ * and the map instantly flies to their ~4m × 4m location — zero API cost.
167
+ */
168
+ enableSearch?: boolean;
150
169
  }
package/src/index.ts CHANGED
@@ -39,8 +39,13 @@ export {
39
39
  } from './core/digipin';
40
40
 
41
41
  // ── API client ────────────────────────────────────────────────────────────────
42
- export { lookupLocation, reverseGeocode } from './core/api';
43
- export type { AddressComponents, ReverseGeocodeResponse } from './core/api';
42
+ export { lookupLocation, reverseGeocode, autocompleteAddress, looksLikeDigiPin } from './core/api';
43
+ export type {
44
+ AddressComponents,
45
+ ReverseGeocodeResponse,
46
+ AutocompleteSuggestion,
47
+ AutocompleteResponse,
48
+ } from './core/api';
44
49
 
45
50
  // ── Hooks ─────────────────────────────────────────────────────────────────────
46
51
  export { useGeolocation } from './hooks/useGeolocation';
@@ -188,6 +188,181 @@
188
188
  height: 16px;
189
189
  }
190
190
 
191
+ /* ── Search bar ──────────────────────────────────────────── */
192
+ .qr-search-bar {
193
+ padding: 10px 12px 6px;
194
+ background: var(--qr-bg);
195
+ border-bottom: 1px solid var(--qr-border);
196
+ position: relative;
197
+ z-index: 30;
198
+ }
199
+
200
+ .qr-search-bar__input-wrap {
201
+ display: flex;
202
+ align-items: center;
203
+ gap: 8px;
204
+ background: var(--qr-bg-subtle);
205
+ border: 1.5px solid var(--qr-border);
206
+ border-radius: var(--qr-radius-sm);
207
+ padding: 0 10px;
208
+ transition: border-color var(--qr-transition), box-shadow var(--qr-transition);
209
+ }
210
+
211
+ .qr-search-bar__input-wrap:focus-within {
212
+ border-color: var(--qr-primary);
213
+ box-shadow: 0 0 0 3px rgba(14,165,233,.12);
214
+ background: var(--qr-bg);
215
+ }
216
+
217
+ .qr-search-bar__icon {
218
+ width: 15px;
219
+ height: 15px;
220
+ color: var(--qr-text-muted);
221
+ flex-shrink: 0;
222
+ }
223
+
224
+ .qr-search-bar__input {
225
+ flex: 1;
226
+ border: none;
227
+ outline: none;
228
+ background: transparent;
229
+ font-family: var(--qr-font);
230
+ font-size: 13px;
231
+ color: var(--qr-text);
232
+ padding: 9px 0;
233
+ /* Remove browser default search-input clear button */
234
+ -webkit-appearance: none;
235
+ appearance: none;
236
+ }
237
+
238
+ .qr-search-bar__input::placeholder {
239
+ color: var(--qr-text-faint);
240
+ }
241
+
242
+ /* Remove native × on search type */
243
+ .qr-search-bar__input::-webkit-search-decoration,
244
+ .qr-search-bar__input::-webkit-search-cancel-button {
245
+ -webkit-appearance: none;
246
+ }
247
+
248
+ .qr-search-bar__spinner {
249
+ flex-shrink: 0;
250
+ border-color: rgba(14,165,233,.25);
251
+ border-top-color: var(--qr-primary);
252
+ }
253
+
254
+ .qr-search-bar__clear {
255
+ flex-shrink: 0;
256
+ background: none;
257
+ border: none;
258
+ cursor: pointer;
259
+ color: var(--qr-text-faint);
260
+ font-size: 18px;
261
+ line-height: 1;
262
+ padding: 0 2px;
263
+ opacity: 0.7;
264
+ transition: opacity var(--qr-transition);
265
+ }
266
+
267
+ .qr-search-bar__clear:hover {
268
+ opacity: 1;
269
+ }
270
+
271
+ /* Error message under input */
272
+ .qr-search-bar__error {
273
+ margin: 4px 2px 0;
274
+ font-size: 11px;
275
+ color: var(--qr-error);
276
+ }
277
+
278
+ /* ── Dropdown ────────────────────────────────────────────── */
279
+ .qr-search-bar__dropdown {
280
+ position: absolute;
281
+ top: calc(100% - 6px);
282
+ left: 12px;
283
+ right: 12px;
284
+ background: var(--qr-bg);
285
+ border: 1.5px solid var(--qr-border);
286
+ border-top: none;
287
+ border-radius: 0 0 var(--qr-radius-sm) var(--qr-radius-sm);
288
+ box-shadow: 0 8px 24px rgba(0,0,0,.12);
289
+ list-style: none;
290
+ margin: 0;
291
+ padding: 4px 0;
292
+ z-index: 200;
293
+ max-height: 240px;
294
+ overflow-y: auto;
295
+ -webkit-overflow-scrolling: touch;
296
+ }
297
+
298
+ .qr-search-bar__suggestion {
299
+ display: flex;
300
+ align-items: flex-start;
301
+ gap: 9px;
302
+ padding: 9px 12px;
303
+ cursor: pointer;
304
+ transition: background var(--qr-transition);
305
+ }
306
+
307
+ .qr-search-bar__suggestion:hover,
308
+ .qr-search-bar__suggestion:focus {
309
+ background: var(--qr-bg-subtle);
310
+ outline: none;
311
+ }
312
+
313
+ .qr-search-bar__suggestion-icon {
314
+ width: 14px;
315
+ height: 14px;
316
+ flex-shrink: 0;
317
+ color: var(--qr-primary);
318
+ margin-top: 2px;
319
+ }
320
+
321
+ .qr-search-bar__suggestion-text {
322
+ display: flex;
323
+ flex-direction: column;
324
+ gap: 1px;
325
+ min-width: 0;
326
+ }
327
+
328
+ .qr-search-bar__suggestion-name {
329
+ font-size: 13px;
330
+ font-weight: 500;
331
+ color: var(--qr-text);
332
+ white-space: nowrap;
333
+ overflow: hidden;
334
+ text-overflow: ellipsis;
335
+ }
336
+
337
+ .qr-search-bar__suggestion-sub {
338
+ font-size: 11px;
339
+ color: var(--qr-text-muted);
340
+ white-space: nowrap;
341
+ overflow: hidden;
342
+ text-overflow: ellipsis;
343
+ }
344
+
345
+ /* ── DigiPin hint below input ────────────────────────────── */
346
+ .qr-search-bar__hint {
347
+ margin: 5px 2px 2px;
348
+ font-size: 11px;
349
+ color: var(--qr-text-faint);
350
+ display: flex;
351
+ align-items: center;
352
+ gap: 5px;
353
+ }
354
+
355
+ .qr-search-bar__hint-chip {
356
+ background: var(--qr-primary-light);
357
+ color: var(--qr-primary);
358
+ font-size: 10px;
359
+ font-weight: 700;
360
+ letter-spacing: 0.04em;
361
+ padding: 1px 6px;
362
+ border-radius: 100px;
363
+ white-space: nowrap;
364
+ }
365
+
191
366
  /* ── Map area ────────────────────────────────────────────── */
192
367
  .qr-map-wrapper {
193
368
  display: flex;
@@ -820,6 +820,93 @@ export const styles = StyleSheet.create({
820
820
  fontWeight: '500',
821
821
  },
822
822
 
823
+ // ── Search bar ──────────────────────────────────────────────────────────────
824
+ searchBar: {
825
+ paddingHorizontal: 12,
826
+ paddingTop: 10,
827
+ paddingBottom: 6,
828
+ backgroundColor: COLORS.bg,
829
+ borderBottomWidth: 1,
830
+ borderBottomColor: COLORS.border,
831
+ },
832
+ searchBarDark: {
833
+ backgroundColor: COLORS.bgDark,
834
+ borderBottomColor: COLORS.borderDark,
835
+ },
836
+ searchInputWrap: {
837
+ flexDirection: 'row',
838
+ alignItems: 'center',
839
+ backgroundColor: COLORS.bgSubtle,
840
+ borderWidth: 1.5,
841
+ borderColor: COLORS.border,
842
+ borderRadius: 8,
843
+ paddingHorizontal: 10,
844
+ },
845
+ searchInputWrapDark: {
846
+ backgroundColor: COLORS.bgSubtleDark,
847
+ borderColor: COLORS.borderDark,
848
+ },
849
+ searchInput: {
850
+ flex: 1,
851
+ paddingVertical: 9,
852
+ fontSize: 13,
853
+ color: COLORS.text,
854
+ },
855
+ searchInputDark: {
856
+ color: COLORS.textDark,
857
+ },
858
+ searchSpinner: {
859
+ marginLeft: 6,
860
+ },
861
+ searchError: {
862
+ marginTop: 4,
863
+ marginLeft: 2,
864
+ fontSize: 11,
865
+ color: COLORS.error,
866
+ },
867
+ searchDropdown: {
868
+ maxHeight: 220,
869
+ borderWidth: 1.5,
870
+ borderColor: COLORS.border,
871
+ borderRadius: 8,
872
+ marginTop: 4,
873
+ backgroundColor: COLORS.bg,
874
+ },
875
+ searchDropdownDark: {
876
+ borderColor: COLORS.borderDark,
877
+ backgroundColor: COLORS.bgDark,
878
+ },
879
+ searchSuggestion: {
880
+ paddingHorizontal: 12,
881
+ paddingVertical: 10,
882
+ borderBottomWidth: StyleSheet.hairlineWidth,
883
+ borderBottomColor: COLORS.border,
884
+ },
885
+ searchSuggestionDark: {
886
+ borderBottomColor: COLORS.borderDark,
887
+ },
888
+ searchSuggestionName: {
889
+ fontSize: 13,
890
+ fontWeight: '500',
891
+ color: COLORS.text,
892
+ },
893
+ searchSuggestionSub: {
894
+ fontSize: 11,
895
+ color: COLORS.textMuted,
896
+ marginTop: 1,
897
+ },
898
+ searchHint: {
899
+ marginTop: 5,
900
+ marginLeft: 2,
901
+ fontSize: 11,
902
+ color: COLORS.textFaint,
903
+ },
904
+ searchHintChip: {
905
+ fontSize: 10,
906
+ fontWeight: '700',
907
+ color: COLORS.primary,
908
+ },
909
+
823
910
  // ── Generic text helpers ────────────────────────────────────────────────────
824
911
  textLight: {
825
912
  color: COLORS.textDark,